Skip to content

Commit

Permalink
fix: add onRegisterTypeChange prop to RegisterForm
Browse files Browse the repository at this point in the history
closes #84
  • Loading branch information
zaaakher committed Aug 17, 2024
1 parent 874cb21 commit f23b482
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 6 deletions.
7 changes: 7 additions & 0 deletions apps/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# hawa-docs

## 0.0.115

### Patch Changes

- Updated dependencies
- @sikka/hawa@0.48.1

## 0.0.114

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawa-docs",
"version": "0.0.114",
"version": "0.0.115",
"private": true,
"scripts": {
"dev": "next dev -p 3001",
Expand Down
7 changes: 7 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sikka/hawa

## 0.48.1

### Patch Changes

- Fix: add `onRegisterTypeChange` prop to `RegisterForm`
- Fix: missing space above `Alert` box in `RegisterForm`

## 0.48.0

### Minor Changes
Expand Down
17 changes: 14 additions & 3 deletions packages/components/blocks/auth/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ type RegisterFormTypes = {
onRouteToTOS?: () => void;
/** Callback function triggered when the error alert is dismissed. */
onErrorDismissed?: () => void;

/*
* Callback function triggered when the register type is changed.
* @param e - The new register type.
* */
onRegisterTypeChange?: (e: string) => void;

/** Determines whether to show an error alert. */
showError?: boolean;
/** Title for the error alert. */
Expand Down Expand Up @@ -111,6 +118,7 @@ type RegisterFormTypes = {
* @default "email"
*/
registerTypes?: { label: string; value: string }[];

/** Props to pass to the PhoneInput component */
phoneInputProps?: PhoneInputProps;
};
Expand Down Expand Up @@ -316,15 +324,18 @@ export const RegisterForm: FC<RegisterFormTypes> = ({
<Tabs
dir={props.direction}
value={selectedRegisterType.value}
onValueChange={(e) =>
onValueChange={(e) => {
if (props.onRegisterTypeChange) {
props.onRegisterTypeChange(e);
}
setSelectedRegisterType(
registerTypes?.find((r) => r.value === e) ||
(registerTypes && registerTypes[0]) || {
label: "Password",
value: "password",
},
)
}
);
}}
>
{registerTypes && registerTypes.length > 1 && (
<CardHeader className="hawa-w-full hawa-px-0 hawa-py-0 hawa-mb-4">
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sikka/hawa",
"version": "0.48.0",
"version": "0.48.1",
"description": "Modern UI Kit made with Tailwind",
"author": {
"name": "Sikka Software",
Expand Down
7 changes: 7 additions & 0 deletions packages/storybook/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# hawa-storybook

## 0.26.137

### Patch Changes

- Updated dependencies
- @sikka/hawa@0.48.1

## 0.26.136

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawa-storybook",
"version": "0.26.136",
"version": "0.26.137",
"description": "Modern UI Kit made with Tailwind",
"author": {
"name": "Sikka Software",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const Minimal: Story = {
{ label: t("password"), value: "password" },
{ label: t("phone"), value: "phone" },
]}
onRegisterTypeChange={(type) => console.log(type)}
/>
</div>
);
Expand Down

0 comments on commit f23b482

Please sign in to comment.