@sikka/hawa 0.6.5-next → 0.6.10-next

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1149,7 +1149,7 @@ var Radio = ({
1149
1149
  {
1150
1150
  className: cn(
1151
1151
  "radio-item radio-item-bordered hawa-flex hawa-items-center hawa-transition-all",
1152
- props.direction === "rtl" ? "margin-left" : "margin-right"
1152
+ props.direction === "rtl" ? "margin-left right-19px" : "margin-right left-23px"
1153
1153
  ),
1154
1154
  key: i + 1
1155
1155
  },
@@ -1199,13 +1199,12 @@ var Radio = ({
1199
1199
  /* @__PURE__ */ React16.createElement("div", { className: "hawa-block hawa-h-full hawa-w-full" }, /* @__PURE__ */ React16.createElement("div", { className: "hawa-w-full hawa-text-lg hawa-font-semibold" }, opt.label), /* @__PURE__ */ React16.createElement("div", { className: "hawa-w-full" }, opt.sublabel))
1200
1200
  ))));
1201
1201
  default:
1202
- console.log("ds", parentDirection);
1203
1202
  return /* @__PURE__ */ React16.createElement("div", { className: cn(orientationStyle[orientation], "hawa-gap-2") }, props.options && props.options.map((opt, i) => /* @__PURE__ */ React16.createElement(
1204
1203
  "div",
1205
1204
  {
1206
1205
  className: cn(
1207
1206
  "radio-item radio-item-default hawa-flex hawa-items-center hawa-transition-all",
1208
- props.direction === "rtl" ? "margin-left" : "margin-right"
1207
+ props.direction === "rtl" ? "margin-left right-3px" : "margin-right left-3px"
1209
1208
  ),
1210
1209
  key: i + 1
1211
1210
  },
@@ -1444,7 +1443,7 @@ var PopoverContent = React21.forwardRef(({ className, align = "center", sideOffs
1444
1443
  align,
1445
1444
  sideOffset,
1446
1445
  className: cn(
1447
- "hawa-z-50 hawa-rounded hawa-border hawa-bg-popover hawa-p-4 hawa-text-popover-foreground hawa-shadow-md hawa-outline-none data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=open]:hawa-fade-in-0 data-[state=closed]:hawa-zoom-out-95 data-[state=open]:hawa-zoom-in-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2 dark:hawa-shadow-dark",
1446
+ "hawa-z-50 hawa-rounded hawa-border hawa-bg-popover hawa-p-4 hawa-text-popover-foreground hawa-shadow-md hawa-outline-none data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=open]:hawa-fade-in-0 data-[state=closed]:hawa-zoom-out-95 data-[state=open]:hawa-zoom-in-95 data-[side=bottom]:hawa-slide-in-from-top-2 data-[side=left]:hawa-slide-in-from-right-2 data-[side=right]:hawa-slide-in-from-left-2 data-[side=top]:hawa-slide-in-from-bottom-2 dark:dark-shadow",
1448
1447
  className
1449
1448
  ),
1450
1449
  ...props
@@ -1888,25 +1887,32 @@ var PinInput = ({
1888
1887
  }
1889
1888
  }
1890
1889
  };
1891
- return /* @__PURE__ */ React26.createElement("div", { className: "hawa-flex hawa-w-full hawa-flex-row hawa-justify-center hawa-gap-2", dir: "ltr" }, pin.map((value, index) => /* @__PURE__ */ React26.createElement(
1892
- "input",
1893
- {
1894
- key: index,
1895
- type: "text",
1896
- maxLength: 1,
1897
- value,
1898
- id: `input-${index}`,
1899
- pattern: "[0-9]*",
1900
- className: clsx7(
1901
- "hawa-h-10 hawa-rounded hawa-border hawa-bg-background hawa-text-center",
1902
- width === "full" ? "hawa-w-full" : "hawa-w-10"
1903
- ),
1904
- onChange: (e) => handleChange(e, index),
1905
- onKeyDown: (e) => handleKeyDown(e, index),
1906
- onFocus: (e) => e.target.select(),
1907
- ...props
1908
- }
1909
- )));
1890
+ return /* @__PURE__ */ React26.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-2" }, /* @__PURE__ */ React26.createElement(
1891
+ "div",
1892
+ {
1893
+ className: "hawa-flex hawa-w-full hawa-flex-row hawa-justify-center hawa-gap-2",
1894
+ dir: "ltr"
1895
+ },
1896
+ pin.map((value, index) => /* @__PURE__ */ React26.createElement(
1897
+ "input",
1898
+ {
1899
+ key: index,
1900
+ type: "text",
1901
+ maxLength: 1,
1902
+ value,
1903
+ id: `input-${index}`,
1904
+ pattern: "[0-9]*",
1905
+ className: clsx7(
1906
+ "hawa-h-10 hawa-rounded hawa-border hawa-bg-background hawa-text-center",
1907
+ width === "full" ? "hawa-w-full" : "hawa-w-10"
1908
+ ),
1909
+ onChange: (e) => handleChange(e, index),
1910
+ onKeyDown: (e) => handleKeyDown(e, index),
1911
+ onFocus: (e) => e.target.select(),
1912
+ ...props
1913
+ }
1914
+ ))
1915
+ ), props.helperText && /* @__PURE__ */ React26.createElement("p", { className: "hawa-mb-0 hawa-mt-0 hawa-text-xs hawa-text-red-600 dark:hawa-text-red-500" }, props.helperText));
1910
1916
  };
1911
1917
 
1912
1918
  // components/elements/FileDropzone.tsx
@@ -3897,10 +3903,19 @@ var Menu = ({
3897
3903
  innerRef,
3898
3904
  ...props
3899
3905
  }) => {
3906
+ const menuOpen = props.selectProps.menuIsOpen;
3900
3907
  return /* @__PURE__ */ React29.createElement(
3901
3908
  "div",
3902
3909
  {
3903
- className: "hawa-absolute hawa-z-10 hawa-mt-2 hawa-flex hawa-w-full hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-p-1.5",
3910
+ className: cn(
3911
+ "hawa-absolute hawa-shadow-md dark:dark-shadow hawa-z-10 hawa-mt-2 hawa-flex hawa-w-full hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-p-1.5",
3912
+ menuOpen && "hawa-zoom-in-95 hawa-animate-in hawa-fade-in-0 "
3913
+ // menuOpen
3914
+ // ? "hawa-zoom-in-95 hawa-animate-in hawa-fade-in-0 "
3915
+ // : "hawa-zoom-out-95 hawa-fade-out-0 hawa-animate-out"
3916
+ // "hawa-zoom-in-95 hawa-animate-in hawa-animate-out hawa-fade-out-0 hawa-fade-in-0 hawa-zoom-out-95"
3917
+ // "data-[state=open]:hawa-zoom-in-95 data-[state=open]:hawa-animate-in data-[state=closed]:hawa-animate-out data-[state=closed]:hawa-fade-out-0 data-[state=open]:hawa-fade-in-0 data-[state=closed]:hawa-zoom-out-95"
3918
+ ),
3904
3919
  ref: innerRef,
3905
3920
  ...innerProps
3906
3921
  },
@@ -3915,15 +3930,17 @@ var Option = ({
3915
3930
  innerRef,
3916
3931
  size = "normal",
3917
3932
  ...props
3918
- }) => /* @__PURE__ */ React29.createElement(
3919
- "div",
3920
- {
3921
- ref: innerRef,
3922
- className: "hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hover:hawa-bg-primary hover:hawa-text-primary-foreground",
3923
- ...innerProps
3924
- },
3925
- children
3926
- );
3933
+ }) => {
3934
+ return /* @__PURE__ */ React29.createElement(
3935
+ "div",
3936
+ {
3937
+ ref: innerRef,
3938
+ className: "hawa-flex hawa-cursor-pointer hawa-select-none hawa-flex-row hawa-items-center hawa-justify-between hawa-rounded-inner hawa-p-1 hawa-px-2 hover:hawa-bg-primary hawa-transition-all hover:hawa-text-primary-foreground ",
3939
+ ...innerProps
3940
+ },
3941
+ children
3942
+ );
3943
+ };
3927
3944
  var Select = (props) => {
3928
3945
  const Control = ({
3929
3946
  // cx,
@@ -3965,6 +3982,15 @@ var Select = (props) => {
3965
3982
  {
3966
3983
  noOptionsMessage: NoOption,
3967
3984
  classNames: {
3985
+ // menuList: (d) => {
3986
+ // console.log("d is ", d.selectProps.menuIsOpen);
3987
+ // return cn(
3988
+ // "hawa-absolute hawa-shadow-md dark:dark-shadow hawa-z-10 hawa-mt-2 hawa-flex hawa-w-full hawa-flex-col hawa-justify-start hawa-rounded hawa-border hawa-bg-background hawa-p-1.5",
3989
+ // d.selectProps.menuIsOpen
3990
+ // ? "hawa-zoom-in-95 hawa-animate-in hawa-fade-in-0 "
3991
+ // : "hawa-zoom-out-95 hawa-fade-out-0 hawa-animate-out"
3992
+ // );
3993
+ // },
3968
3994
  control: () => cn(
3969
3995
  " hawa-text-sm hawa-flex hawa-p-2 hawa-w-full hawa-rounded hawa-border hawa-bg-background hawa-text-gray-900 focus:hawa-border-blue-500 focus:hawa-ring-blue-500 dark:focus:hawa-ring-blue-500",
3970
3996
  props.controlClassNames
@@ -3988,6 +4014,7 @@ var Select = (props) => {
3988
4014
  isClearable: props.isClearable,
3989
4015
  isMulti: props.isMulti,
3990
4016
  isSearchable: props.isSearchable,
4017
+ placeholder: props.placeholder,
3991
4018
  autoFocus: true,
3992
4019
  onChange: (newValue, action) => (
3993
4020
  // props.onChange(newValue.label, action)
@@ -4020,7 +4047,8 @@ var Select = (props) => {
4020
4047
  isClearable: props.isClearable,
4021
4048
  isMulti: props.isMulti,
4022
4049
  isSearchable: props.isSearchable,
4023
- onCreateOption: () => console.log("im changing"),
4050
+ placeholder: props.placeholder,
4051
+ onCreateOption: props.handleCreateOption,
4024
4052
  onChange: (newValue, action) => props.onChange(newValue, action),
4025
4053
  onInputChange: (newValue, action) => props.onInputChange(newValue, action),
4026
4054
  components: {
@@ -4205,7 +4233,7 @@ var TableHead = React33.forwardRef(
4205
4233
  ref,
4206
4234
  className: cn(
4207
4235
  "hawa-bg-muted/60 dark:hawa-bg-muted/40 hawa-text-start hawa-align-middle hawa-font-medium hawa-text-muted-foreground [&:has([role=checkbox])]:hawa-pr-0 [&:not(:last-child)&:not(:first-child)]:hawa-border-x",
4208
- "[&:not(:last-child)]:hawa-border-r",
4236
+ props.dir === "rtl" ? "[&:not(:last-child)]:hawa-border-l" : "[&:not(:last-child)]:hawa-border-r",
4209
4237
  props.condensed ? "hawa-h-8" : "hawa-h-12",
4210
4238
  props.clickable ? "hawa-px-1" : "hawa-px-4",
4211
4239
  //First and last columns
@@ -4269,7 +4297,8 @@ var TableCell = React33.forwardRef(
4269
4297
  props.condensed ? "hawa-p-0 hawa-px-4" : "hawa-p-4",
4270
4298
  "hawa-align-middle [&:has([role=checkbox])]:hawa-pr-0 ",
4271
4299
  "[&:not(:last-child)&:not(:first-child)]:hawa-border-x",
4272
- "[&:not(:last-child)]:hawa-border-r",
4300
+ // "[&:not(:last-child)]:hawa-border-r",
4301
+ props.dir === "rtl" ? "[&:not(:last-child)]:hawa-border-l" : "[&:not(:last-child)]:hawa-border-r",
4273
4302
  className
4274
4303
  ),
4275
4304
  ...props
@@ -4477,6 +4506,7 @@ var SimpleTable = ({
4477
4506
  TableHead,
4478
4507
  {
4479
4508
  condensed: props.condensed,
4509
+ dir: props.direction,
4480
4510
  key: header.id
4481
4511
  },
4482
4512
  header.isPlaceholder ? null : flexRender2(
@@ -4490,10 +4520,18 @@ var SimpleTable = ({
4490
4520
  key: row.id,
4491
4521
  "data-state": row.getIsSelected() && "selected"
4492
4522
  },
4493
- row.getVisibleCells().map((cell) => /* @__PURE__ */ React35.createElement(TableCell, { condensed: props.condensed, key: cell.id }, flexRender2(
4494
- cell.column.columnDef.cell,
4495
- cell.getContext()
4496
- )))
4523
+ row.getVisibleCells().map((cell) => /* @__PURE__ */ React35.createElement(
4524
+ TableCell,
4525
+ {
4526
+ dir: props.direction,
4527
+ condensed: props.condensed,
4528
+ key: cell.id
4529
+ },
4530
+ flexRender2(
4531
+ cell.column.columnDef.cell,
4532
+ cell.getContext()
4533
+ )
4534
+ ))
4497
4535
  )) : /* @__PURE__ */ React35.createElement(TableRow, null, /* @__PURE__ */ React35.createElement(
4498
4536
  TableCell,
4499
4537
  {
@@ -5941,6 +5979,7 @@ var AppLayout = ({
5941
5979
  /* @__PURE__ */ React50.createElement(
5942
5980
  "div",
5943
5981
  {
5982
+ onClick: props.onLogoClick,
5944
5983
  dir: direction,
5945
5984
  className: "hawa-fixed hawa-z-50 hawa-mb-2 hawa-flex hawa-h-14 hawa-w-full hawa-flex-row hawa-items-center hawa-justify-center hawa-bg-primary-foreground hawa-transition-all",
5946
5985
  style: {
@@ -6101,9 +6140,9 @@ import { Controller as Controller2, useForm } from "react-hook-form";
6101
6140
  import { zodResolver } from "@hookform/resolvers/zod";
6102
6141
  import * as z from "zod";
6103
6142
  var LoginForm = (props) => {
6104
- let formSchema2;
6143
+ let formSchema;
6105
6144
  if (props.loginType === "email") {
6106
- formSchema2 = z.object({
6145
+ formSchema = z.object({
6107
6146
  email: z.string({
6108
6147
  required_error: props.texts?.emailRequiredText
6109
6148
  }).nonempty({ message: props.texts?.emailRequiredText }).email({ message: props.texts?.emailInvalidText }),
@@ -6112,21 +6151,21 @@ var LoginForm = (props) => {
6112
6151
  }).min(5, { message: "Password must be at least 5 characters long" }).nonempty({ message: props.texts?.passwordRequiredText })
6113
6152
  });
6114
6153
  } else if (props.loginType === "username") {
6115
- formSchema2 = z.object({
6154
+ formSchema = z.object({
6116
6155
  username: z.string().min(2, { message: "Username must be at least 2 characters" }).nonempty({ message: props.texts?.usernameRequired }),
6117
6156
  password: z.string({
6118
6157
  required_error: props.texts?.passwordRequiredText
6119
6158
  }).min(5, { message: "Password must be at least 5 characters long" }).nonempty({ message: props.texts?.passwordRequiredText })
6120
6159
  });
6121
6160
  } else if (props.loginType === "phone") {
6122
- formSchema2 = z.object({
6161
+ formSchema = z.object({
6123
6162
  phone: z.string().nonempty({ message: "Phone number is required" })
6124
6163
  });
6125
6164
  } else {
6126
- formSchema2 = z.object({});
6165
+ formSchema = z.object({});
6127
6166
  }
6128
6167
  const { handleSubmit, control, formState } = useForm({
6129
- resolver: zodResolver(formSchema2)
6168
+ resolver: zodResolver(formSchema)
6130
6169
  });
6131
6170
  return /* @__PURE__ */ React52.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, /* @__PURE__ */ React52.createElement(Card, { dir: props.direction }, /* @__PURE__ */ React52.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React52.createElement(
6132
6171
  Alert,
@@ -6141,7 +6180,6 @@ var LoginForm = (props) => {
6141
6180
  className: "hawa-flex hawa-flex-col hawa-gap-4",
6142
6181
  onSubmit: handleSubmit((e) => {
6143
6182
  if (props.handleLogin) {
6144
- console.log("attempting to login");
6145
6183
  return props.handleLogin(e);
6146
6184
  } else {
6147
6185
  console.log(
@@ -6313,6 +6351,7 @@ var RegisterForm = (props) => {
6313
6351
  passwordPlaceholder,
6314
6352
  passwordRequiredText,
6315
6353
  passwordTooShortText,
6354
+ passwordsDontMatch,
6316
6355
  confirmPasswordRequired,
6317
6356
  confirmPasswordPlaceholder,
6318
6357
  termsRequiredText,
@@ -6332,7 +6371,7 @@ var RegisterForm = (props) => {
6332
6371
  break;
6333
6372
  }
6334
6373
  });
6335
- const formSchema2 = z2.object({
6374
+ const formSchema = z2.object({
6336
6375
  ...fieldSchemas,
6337
6376
  password: z2.string({ required_error: passwordRequiredText }).min(5, { message: passwordTooShortText }).refine((value) => value !== "", { message: passwordRequiredText }),
6338
6377
  confirm_password: z2.string({ required_error: confirmPasswordRequired }).refine((value) => value !== "", { message: passwordRequiredText }),
@@ -6341,11 +6380,11 @@ var RegisterForm = (props) => {
6341
6380
  terms_accepted: z2.boolean({ required_error: termsRequiredText }).refine((value) => value, { message: termsRequiredText }),
6342
6381
  newsletter_accepted: z2.boolean().optional()
6343
6382
  }).refine((data) => data.password === data.confirm_password, {
6344
- message: "Passwords don't match",
6383
+ message: passwordsDontMatch,
6345
6384
  path: ["confirm_password"]
6346
6385
  });
6347
6386
  const { handleSubmit, control, formState } = useForm2({
6348
- resolver: zodResolver2(formSchema2)
6387
+ resolver: zodResolver2(formSchema)
6349
6388
  });
6350
6389
  return /* @__PURE__ */ React53.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, /* @__PURE__ */ React53.createElement(Card, { dir: props.direction }, /* @__PURE__ */ React53.createElement(CardContent, { headless: true }, /* @__PURE__ */ React53.createElement("div", null, props.showError && /* @__PURE__ */ React53.createElement(
6351
6390
  Alert,
@@ -6357,7 +6396,15 @@ var RegisterForm = (props) => {
6357
6396
  ), /* @__PURE__ */ React53.createElement(FormProvider2, { ...methods }, /* @__PURE__ */ React53.createElement(
6358
6397
  "form",
6359
6398
  {
6360
- onSubmit: handleSubmit(props.handleRegister),
6399
+ onSubmit: handleSubmit((e) => {
6400
+ if (props.handleRegister) {
6401
+ return props.handleRegister(e);
6402
+ } else {
6403
+ console.log(
6404
+ "Form is submitted but handleRegister prop is missing"
6405
+ );
6406
+ }
6407
+ }),
6361
6408
  className: "hawa-flex hawa-flex-col hawa-gap-4"
6362
6409
  },
6363
6410
  /* @__PURE__ */ React53.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, props.registerFields.map((fld, i) => {
@@ -6683,7 +6730,7 @@ var AppLanding = (props) => {
6683
6730
  ), !props.withoutSignUp && /* @__PURE__ */ React54.createElement("div", { className: "hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-gray-300" }, props.texts?.newUserText, " ", /* @__PURE__ */ React54.createElement(
6684
6731
  "span",
6685
6732
  {
6686
- onClick: props.handleRouteToSignUp,
6733
+ onClick: props.handleRouteToRegister,
6687
6734
  className: "clickable-link"
6688
6735
  },
6689
6736
  props.texts?.createAccount
@@ -6777,7 +6824,7 @@ import { Controller as Controller4, useForm as useForm3 } from "react-hook-form"
6777
6824
  import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
6778
6825
  import * as z3 from "zod";
6779
6826
  var NewPasswordForm = (props) => {
6780
- const formSchema2 = z3.object({
6827
+ const formSchema = z3.object({
6781
6828
  password: z3.string({ required_error: props.texts.passwordRequiredText }).min(5, { message: props.texts.passwordTooShortText }).refine((value) => value !== "", {
6782
6829
  message: props.texts.passwordRequiredText
6783
6830
  }),
@@ -6789,7 +6836,7 @@ var NewPasswordForm = (props) => {
6789
6836
  path: ["confirm_password"]
6790
6837
  });
6791
6838
  const { handleSubmit, control, formState } = useForm3({
6792
- resolver: zodResolver3(formSchema2)
6839
+ resolver: zodResolver3(formSchema)
6793
6840
  });
6794
6841
  const [matchError, setMatchError] = useState20(false);
6795
6842
  return /* @__PURE__ */ React56.createElement(Card, { dir: props.direction }, matchError && /* @__PURE__ */ React56.createElement(Alert, { text: props.texts.passwordMatchError, severity: "error" }), props.passwordChanged ? /* @__PURE__ */ React56.createElement(CardContent, { headless: true }, /* @__PURE__ */ React56.createElement("div", { className: "hawa-text-center" }, props.texts.passwordChanged)) : /* @__PURE__ */ React56.createElement(
@@ -6797,7 +6844,6 @@ var NewPasswordForm = (props) => {
6797
6844
  {
6798
6845
  onSubmit: handleSubmit((e) => {
6799
6846
  if (props.handleNewPassword) {
6800
- console.log("attempting to login");
6801
6847
  return props.handleNewPassword(e);
6802
6848
  } else {
6803
6849
  console.log(
@@ -6864,18 +6910,17 @@ import { Controller as Controller5, useForm as useForm4 } from "react-hook-form"
6864
6910
  import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
6865
6911
  import * as z4 from "zod";
6866
6912
  var ResetPasswordForm = (props) => {
6867
- const formSchema2 = z4.object({
6913
+ const formSchema = z4.object({
6868
6914
  email: z4.string({ required_error: props.texts?.emailRequiredText }).email({ message: props.texts?.emailInvalidText }).nonempty({ message: props.texts?.emailRequiredText })
6869
6915
  });
6870
6916
  const { handleSubmit, control, formState } = useForm4({
6871
- resolver: zodResolver4(formSchema2)
6917
+ resolver: zodResolver4(formSchema)
6872
6918
  });
6873
6919
  return /* @__PURE__ */ React57.createElement(Card, { dir: props.direction }, !props.sent ? /* @__PURE__ */ React57.createElement(React57.Fragment, null, !props.headless && /* @__PURE__ */ React57.createElement(CardHeader, null, /* @__PURE__ */ React57.createElement(CardTitle, null, "Reset Password"), /* @__PURE__ */ React57.createElement(CardDescription, null, "Enter your email to reset your account password")), /* @__PURE__ */ React57.createElement(
6874
6920
  "form",
6875
6921
  {
6876
6922
  onSubmit: handleSubmit((e) => {
6877
6923
  if (props.handleResetPassword) {
6878
- console.log("attempting to login");
6879
6924
  return props.handleResetPassword(e);
6880
6925
  } else {
6881
6926
  console.log(
@@ -6915,9 +6960,17 @@ var ResetPasswordForm = (props) => {
6915
6960
  };
6916
6961
 
6917
6962
  // components/blocks/auth/CodeConfirmation.tsx
6918
- import React58, { useState as useState21 } from "react";
6963
+ import React58 from "react";
6964
+ import { Controller as Controller6, useForm as useForm5 } from "react-hook-form";
6965
+ import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
6966
+ import * as z5 from "zod";
6919
6967
  var CodeConfirmation = (props) => {
6920
- const [pins, setPins] = useState21(null);
6968
+ const formSchema = z5.object({
6969
+ otp_code: z5.string({ required_error: props.texts?.codeRequiredText }).min(6, { message: props.texts?.codeTooShort })
6970
+ });
6971
+ const { handleSubmit, control, formState, setValue } = useForm5({
6972
+ resolver: zodResolver5(formSchema)
6973
+ });
6921
6974
  return /* @__PURE__ */ React58.createElement(Card, null, /* @__PURE__ */ React58.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React58.createElement(
6922
6975
  Alert,
6923
6976
  {
@@ -6928,14 +6981,32 @@ var CodeConfirmation = (props) => {
6928
6981
  ), /* @__PURE__ */ React58.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React58.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, props.texts?.checkYourPhone ?? "Please check your phone"), /* @__PURE__ */ React58.createElement("div", { className: "hawa-text-muted-foreground" }, /* @__PURE__ */ React58.createElement("span", null, props.texts?.weSentCode ?? "We've sent a code to "), /* @__PURE__ */ React58.createElement("span", null, props.phoneNumber)), " "), /* @__PURE__ */ React58.createElement(
6929
6982
  "form",
6930
6983
  {
6931
- onSubmit: (e) => {
6932
- e.preventDefault();
6933
- if (pins) {
6934
- props.submitConfirmation(pins);
6984
+ onSubmit: handleSubmit((e) => {
6985
+ if (props.handleConfirm) {
6986
+ return props.handleConfirm(e);
6987
+ } else {
6988
+ console.log(
6989
+ "Form is submitted but handleConfirm prop is missing"
6990
+ );
6935
6991
  }
6936
- }
6992
+ })
6937
6993
  },
6938
- /* @__PURE__ */ React58.createElement(PinInput, { width: "full", digits: 6, getPins: (e) => setPins(e) }),
6994
+ /* @__PURE__ */ React58.createElement(
6995
+ Controller6,
6996
+ {
6997
+ control,
6998
+ name: "otp_code",
6999
+ render: ({ field }) => /* @__PURE__ */ React58.createElement(
7000
+ PinInput,
7001
+ {
7002
+ width: "full",
7003
+ digits: 6,
7004
+ getPins: (e) => setValue("otp_code", e.join("")),
7005
+ helperText: formState.errors.otp_code?.message
7006
+ }
7007
+ )
7008
+ }
7009
+ ),
6939
7010
  /* @__PURE__ */ React58.createElement("div", { className: " hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React58.createElement("span", null, props.texts?.didntGetCode ?? "Didn't get the code?"), " ", /* @__PURE__ */ React58.createElement("span", { className: "clickable-link" }, props.texts?.resendCode ?? "Click to resend")),
6940
7011
  /* @__PURE__ */ React58.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React58.createElement(Button, { variant: "secondary" }, props.texts?.cancel ?? "Cancel"), /* @__PURE__ */ React58.createElement(Button, null, props.texts?.confirm ?? "Confirm"))
6941
7012
  )));
@@ -7345,26 +7416,32 @@ var VeryBadEmoji = () => /* @__PURE__ */ React61.createElement(
7345
7416
 
7346
7417
  // components/blocks/feedback/FeedbackForm.tsx
7347
7418
  import React62 from "react";
7348
- import { useForm as useForm5, Controller as Controller6 } from "react-hook-form";
7349
- import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
7350
- import * as z5 from "zod";
7351
- var formSchema = z5.object({
7352
- requestType: z5.string().nonempty({ message: "Request type is required." }),
7353
- description: z5.string().min(10, { message: "Description must be at least 10 characters." })
7354
- });
7355
- var FeedbackForm = ({ onSubmit }) => {
7356
- const { handleSubmit, control, formState } = useForm5({
7357
- resolver: zodResolver5(formSchema)
7419
+ import { useForm as useForm6, Controller as Controller7 } from "react-hook-form";
7420
+ import { zodResolver as zodResolver6 } from "@hookform/resolvers/zod";
7421
+ import * as z6 from "zod";
7422
+ var FeedbackForm = (props) => {
7423
+ const formSchema = z6.object({
7424
+ requestType: z6.string({ required_error: props.texts.requestTypeRequired }).nonempty({ message: props.texts.requestTypeRequired }),
7425
+ description: z6.string({ required_error: props.texts.descriptionRequired }).min(10, { message: props.texts.descriptionTooShort })
7426
+ });
7427
+ const { handleSubmit, control, formState } = useForm6({
7428
+ resolver: zodResolver6(formSchema)
7358
7429
  });
7359
7430
  return /* @__PURE__ */ React62.createElement(Card, null, /* @__PURE__ */ React62.createElement(CardContent, { headless: true }, /* @__PURE__ */ React62.createElement(
7360
7431
  "form",
7361
7432
  {
7362
- onSubmit: handleSubmit(onSubmit),
7433
+ onSubmit: handleSubmit((e) => {
7434
+ if (props.onSubmit) {
7435
+ return props.onSubmit(e);
7436
+ } else {
7437
+ console.log("Form is submitted but onSubmit prop is missing");
7438
+ }
7439
+ }),
7363
7440
  className: "hawa-flex hawa-flex-col hawa-gap-4"
7364
7441
  },
7365
- /* @__PURE__ */ React62.createElement(Label, null, "Request Type:"),
7442
+ /* @__PURE__ */ React62.createElement(Label, null, props.texts?.requestType),
7366
7443
  /* @__PURE__ */ React62.createElement(
7367
- Controller6,
7444
+ Controller7,
7368
7445
  {
7369
7446
  name: "requestType",
7370
7447
  control,
@@ -7396,9 +7473,9 @@ var FeedbackForm = ({ onSubmit }) => {
7396
7473
  )
7397
7474
  }
7398
7475
  ),
7399
- /* @__PURE__ */ React62.createElement(Label, null, "Description:"),
7476
+ /* @__PURE__ */ React62.createElement(Label, null, props.texts.description),
7400
7477
  /* @__PURE__ */ React62.createElement(
7401
- Controller6,
7478
+ Controller7,
7402
7479
  {
7403
7480
  name: "description",
7404
7481
  control,
@@ -7411,7 +7488,7 @@ var FeedbackForm = ({ onSubmit }) => {
7411
7488
  )
7412
7489
  }
7413
7490
  ),
7414
- /* @__PURE__ */ React62.createElement(Button, { type: "submit" }, "Submit")
7491
+ /* @__PURE__ */ React62.createElement(Button, { type: "submit" }, props.texts?.submit)
7415
7492
  )));
7416
7493
  };
7417
7494
 
@@ -7477,9 +7554,9 @@ var Testimonial = (props) => {
7477
7554
 
7478
7555
  // components/blocks/misc/LeadGenerator.tsx
7479
7556
  import React66 from "react";
7480
- import { useForm as useForm6, Controller as Controller7 } from "react-hook-form";
7557
+ import { useForm as useForm7, Controller as Controller8 } from "react-hook-form";
7481
7558
  var LeadGenerator = ({ texts, submitHandler }) => {
7482
- const { handleSubmit, control, formState } = useForm6();
7559
+ const { handleSubmit, control, formState } = useForm7();
7483
7560
  const onSubmit = (data) => {
7484
7561
  if (submitHandler) {
7485
7562
  submitHandler(data.email);
@@ -7494,7 +7571,7 @@ var LeadGenerator = ({ texts, submitHandler }) => {
7494
7571
  onSubmit: handleSubmit(onSubmit)
7495
7572
  },
7496
7573
  /* @__PURE__ */ React66.createElement(
7497
- Controller7,
7574
+ Controller8,
7498
7575
  {
7499
7576
  name: "email",
7500
7577
  control,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.6.5-next",
3
+ "version": "0.6.10-next",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {