@sikka/hawa 0.49.7-next → 0.49.9-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
@@ -10309,8 +10309,15 @@ var RegisterForm = ({
10309
10309
  continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
10310
10310
  continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
10311
10311
  };
10312
- const methods = useForm2();
10313
10312
  let fieldSchemas = {};
10313
+ let remainingFieldsSchema = z2.object({
10314
+ refCode: z2.string().optional(),
10315
+ reference: z2.string().optional(),
10316
+ terms_accepted: showTermsOption ? z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
10317
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
10318
+ }) : z2.boolean().optional(),
10319
+ newsletter_accepted: z2.boolean().optional()
10320
+ });
10314
10321
  const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
10315
10322
  if (hasPhoneType && selectedRegisterType.value === "phone") {
10316
10323
  registerFields = ["phone"];
@@ -10365,13 +10372,7 @@ var RegisterForm = ({
10365
10372
  return isPhoneValid;
10366
10373
  },
10367
10374
  { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
10368
- ),
10369
- refCode: z2.string().optional(),
10370
- reference: z2.string().optional(),
10371
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
10372
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
10373
- }),
10374
- newsletter_accepted: z2.boolean().optional()
10375
+ )
10375
10376
  });
10376
10377
  } else {
10377
10378
  formSchema = z2.object({
@@ -10389,21 +10390,24 @@ var RegisterForm = ({
10389
10390
  message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
10390
10391
  }).refine((value) => value !== "", {
10391
10392
  message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
10392
- }),
10393
- refCode: z2.string().optional(),
10394
- reference: z2.string().optional(),
10395
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
10396
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
10397
- }),
10398
- newsletter_accepted: z2.boolean().optional()
10393
+ })
10399
10394
  }).refine((data) => data.password === data.confirm_password, {
10400
10395
  message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
10401
10396
  path: ["confirm_password"]
10402
10397
  });
10403
10398
  }
10404
- const { handleSubmit, control, formState } = useForm2({
10405
- resolver: zodResolver2(formSchema)
10399
+ let finalSchema = z2.intersection(formSchema, remainingFieldsSchema);
10400
+ const methods = useForm2({
10401
+ resolver: zodResolver2(finalSchema)
10406
10402
  });
10403
+ const onSubmit = (data) => {
10404
+ console.log("Form submitted with data:", data);
10405
+ if (props.onRegister) {
10406
+ props.onRegister(data);
10407
+ } else {
10408
+ console.log("onRegister prop is missing");
10409
+ }
10410
+ };
10407
10411
  return /* @__PURE__ */ React83.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ React83.createElement(
10408
10412
  Card,
10409
10413
  {
@@ -10443,13 +10447,7 @@ var RegisterForm = ({
10443
10447
  {
10444
10448
  id: "register_form",
10445
10449
  noValidate: true,
10446
- onSubmit: handleSubmit((e) => {
10447
- if (props.onRegister) {
10448
- return props.onRegister(e);
10449
- } else {
10450
- console.log("Form is submitted but onRegister prop is missing");
10451
- }
10452
- }),
10450
+ onSubmit: methods.handleSubmit(onSubmit),
10453
10451
  className: "hawa-flex hawa-flex-col hawa-gap-4"
10454
10452
  },
10455
10453
  /* @__PURE__ */ React83.createElement(
@@ -10486,7 +10484,7 @@ var RegisterForm = ({
10486
10484
  Controller2,
10487
10485
  {
10488
10486
  key: i,
10489
- control,
10487
+ control: methods.control,
10490
10488
  name: "fullName",
10491
10489
  render: ({ field }) => {
10492
10490
  var _a2, _b2, _c2;
@@ -10496,7 +10494,7 @@ var RegisterForm = ({
10496
10494
  width: "full",
10497
10495
  label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
10498
10496
  placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
10499
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
10497
+ helperText: (_c2 = methods.formState.errors.fullName) == null ? void 0 : _c2.message,
10500
10498
  ...field
10501
10499
  }
10502
10500
  );
@@ -10509,7 +10507,7 @@ var RegisterForm = ({
10509
10507
  Controller2,
10510
10508
  {
10511
10509
  key: i,
10512
- control,
10510
+ control: methods.control,
10513
10511
  name: "email",
10514
10512
  render: ({ field }) => {
10515
10513
  var _a2, _b2, _c2;
@@ -10523,7 +10521,7 @@ var RegisterForm = ({
10523
10521
  width: "full",
10524
10522
  autoComplete: "email",
10525
10523
  label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
10526
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
10524
+ helperText: (_b2 = methods.formState.errors.email) == null ? void 0 : _b2.message,
10527
10525
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
10528
10526
  ...field,
10529
10527
  onChange: (e) => {
@@ -10540,7 +10538,7 @@ var RegisterForm = ({
10540
10538
  Controller2,
10541
10539
  {
10542
10540
  key: i,
10543
- control,
10541
+ control: methods.control,
10544
10542
  name: "username",
10545
10543
  render: ({ field }) => {
10546
10544
  var _a2, _b2, _c2, _d2, _e2;
@@ -10553,7 +10551,7 @@ var RegisterForm = ({
10553
10551
  labelProps: ((_b2 = props.usernameOptions) == null ? void 0 : _b2.label) ? {
10554
10552
  ...(_c2 = props.usernameOptions) == null ? void 0 : _c2.label
10555
10553
  } : void 0,
10556
- helperText: (_d2 = formState.errors.username) == null ? void 0 : _d2.message,
10554
+ helperText: (_d2 = methods.formState.errors.username) == null ? void 0 : _d2.message,
10557
10555
  placeholder: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.placeholder,
10558
10556
  ...field
10559
10557
  }
@@ -10566,7 +10564,7 @@ var RegisterForm = ({
10566
10564
  /* @__PURE__ */ React83.createElement(
10567
10565
  Controller2,
10568
10566
  {
10569
- control,
10567
+ control: methods.control,
10570
10568
  name: "password",
10571
10569
  render: ({ field }) => {
10572
10570
  var _a2, _b2, _c2;
@@ -10578,7 +10576,7 @@ var RegisterForm = ({
10578
10576
  autoComplete: "new-password",
10579
10577
  label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
10580
10578
  placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
10581
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
10579
+ helperText: (_c2 = methods.formState.errors.password) == null ? void 0 : _c2.message,
10582
10580
  endIcon: /* @__PURE__ */ React83.createElement(
10583
10581
  "div",
10584
10582
  {
@@ -10597,7 +10595,7 @@ var RegisterForm = ({
10597
10595
  /* @__PURE__ */ React83.createElement(
10598
10596
  Controller2,
10599
10597
  {
10600
- control,
10598
+ control: methods.control,
10601
10599
  name: "confirm_password",
10602
10600
  render: ({ field }) => {
10603
10601
  var _a2, _b2, _c2;
@@ -10609,7 +10607,7 @@ var RegisterForm = ({
10609
10607
  autoComplete: "new-password",
10610
10608
  label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
10611
10609
  placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
10612
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
10610
+ helperText: (_c2 = methods.formState.errors.confirm_password) == null ? void 0 : _c2.message,
10613
10611
  endIcon: /* @__PURE__ */ React83.createElement(
10614
10612
  "div",
10615
10613
  {
@@ -10629,7 +10627,7 @@ var RegisterForm = ({
10629
10627
  props.showRefCode && /* @__PURE__ */ React83.createElement(
10630
10628
  Controller2,
10631
10629
  {
10632
- control,
10630
+ control: methods.control,
10633
10631
  name: "refCode",
10634
10632
  render: ({ field }) => {
10635
10633
  var _a2;
@@ -10639,7 +10637,7 @@ var RegisterForm = ({
10639
10637
  width: "full",
10640
10638
  label: texts == null ? void 0 : texts.refCode,
10641
10639
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
10642
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
10640
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
10643
10641
  ...field
10644
10642
  }
10645
10643
  );
@@ -10649,7 +10647,7 @@ var RegisterForm = ({
10649
10647
  props.showUserSource && /* @__PURE__ */ React83.createElement(
10650
10648
  Controller2,
10651
10649
  {
10652
- control,
10650
+ control: methods.control,
10653
10651
  name: "reference",
10654
10652
  render: ({ field }) => {
10655
10653
  var _a2, _b2;
@@ -10683,7 +10681,7 @@ var RegisterForm = ({
10683
10681
  /* @__PURE__ */ React83.createElement(
10684
10682
  Controller2,
10685
10683
  {
10686
- control,
10684
+ control: methods.control,
10687
10685
  name: "phone",
10688
10686
  render: ({ field }) => {
10689
10687
  var _a2, _b2;
@@ -10691,7 +10689,7 @@ var RegisterForm = ({
10691
10689
  PhoneInput,
10692
10690
  {
10693
10691
  label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
10694
- helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
10692
+ helperText: (_b2 = methods.formState.errors.phone) == null ? void 0 : _b2.message,
10695
10693
  preferredCountry: { label: "+966" },
10696
10694
  ...props.phoneInputProps,
10697
10695
  handleChange: (e) => {
@@ -10711,7 +10709,7 @@ var RegisterForm = ({
10711
10709
  props.showRefCode && /* @__PURE__ */ React83.createElement(
10712
10710
  Controller2,
10713
10711
  {
10714
- control,
10712
+ control: methods.control,
10715
10713
  name: "refCode",
10716
10714
  render: ({ field }) => {
10717
10715
  var _a2;
@@ -10721,7 +10719,7 @@ var RegisterForm = ({
10721
10719
  width: "full",
10722
10720
  label: texts == null ? void 0 : texts.refCode,
10723
10721
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
10724
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
10722
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
10725
10723
  ...field
10726
10724
  }
10727
10725
  );
@@ -10731,7 +10729,7 @@ var RegisterForm = ({
10731
10729
  props.showUserSource && /* @__PURE__ */ React83.createElement(
10732
10730
  Controller2,
10733
10731
  {
10734
- control,
10732
+ control: methods.control,
10735
10733
  name: "reference",
10736
10734
  render: ({ field }) => {
10737
10735
  var _a2, _b2;
@@ -10755,7 +10753,7 @@ var RegisterForm = ({
10755
10753
  showTermsOption || showNewsletterOption ? /* @__PURE__ */ React83.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React83.createElement(
10756
10754
  Controller2,
10757
10755
  {
10758
- control,
10756
+ control: methods.control,
10759
10757
  name: "terms_accepted",
10760
10758
  render: ({ field }) => {
10761
10759
  var _a2, _b2;
@@ -10763,7 +10761,7 @@ var RegisterForm = ({
10763
10761
  Checkbox,
10764
10762
  {
10765
10763
  id: "terms_accepted",
10766
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
10764
+ helperText: (_b2 = (_a2 = methods.formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
10767
10765
  onCheckedChange: (e) => field.onChange(e),
10768
10766
  label: /* @__PURE__ */ React83.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5 hawa-whitespace-nowrap hawa-flex-wrap" }, (texts == null ? void 0 : texts.iAcceptText) || "I accept the", " ", /* @__PURE__ */ React83.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React83.createElement(
10769
10767
  "span",
@@ -10785,7 +10783,7 @@ var RegisterForm = ({
10785
10783
  ), showNewsletterOption && /* @__PURE__ */ React83.createElement(
10786
10784
  Controller2,
10787
10785
  {
10788
- control,
10786
+ control: methods.control,
10789
10787
  name: "newsletter_accepted",
10790
10788
  render: ({ field }) => /* @__PURE__ */ React83.createElement(
10791
10789
  Checkbox,
@@ -11091,63 +11089,71 @@ var CodeConfirmation = ({ codeLength = 6, ...props }) => {
11091
11089
  }
11092
11090
  };
11093
11091
  }, []);
11094
- return /* @__PURE__ */ React88.createElement(Card, null, /* @__PURE__ */ React88.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React88.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React88.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React88.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React88.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React88.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React88.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React88.createElement(
11095
- "form",
11092
+ return /* @__PURE__ */ React88.createElement(
11093
+ Card,
11096
11094
  {
11097
- noValidate: true,
11098
- onSubmit: handleSubmit((e) => {
11099
- if (props.onConfirm) {
11100
- return props.onConfirm(e);
11101
- } else {
11102
- console.log("Form is submitted but onConfirm prop is missing");
11103
- }
11104
- })
11095
+ className: cn(
11096
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
11097
+ )
11105
11098
  },
11106
- /* @__PURE__ */ React88.createElement(
11107
- Controller5,
11108
- {
11109
- control,
11110
- name: "otp_code",
11111
- render: ({ field }) => {
11112
- var _a2;
11113
- return /* @__PURE__ */ React88.createElement(
11114
- PinInput,
11115
- {
11116
- maxLength: codeLength,
11117
- helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
11118
- ...field
11119
- }
11120
- );
11121
- }
11122
- }
11123
- ),
11124
- showResendTimer ? /* @__PURE__ */ React88.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, (_e = props.texts) == null ? void 0 : _e.resendCodeTimer, " ", /* @__PURE__ */ React88.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React88.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React88.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React88.createElement(
11125
- "span",
11126
- {
11127
- className: "clickable-link",
11128
- onClick: () => {
11129
- startResendTimer();
11130
- props.onResend();
11131
- }
11132
- },
11133
- ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
11134
- )),
11135
- /* @__PURE__ */ React88.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React88.createElement(
11136
- Button,
11099
+ /* @__PURE__ */ React88.createElement(CardContent, { headless: true, noPadding: props.cardless }, props.showError && /* @__PURE__ */ React88.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React88.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React88.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React88.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React88.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React88.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React88.createElement(
11100
+ "form",
11137
11101
  {
11138
- type: "button",
11139
- onClick: () => {
11140
- if (props.onCancel) {
11141
- return props.onCancel();
11102
+ noValidate: true,
11103
+ onSubmit: handleSubmit((e) => {
11104
+ if (props.onConfirm) {
11105
+ return props.onConfirm(e);
11142
11106
  } else {
11143
- console.log("Cancel button clicked but onCancel prop is missing");
11107
+ console.log("Form is submitted but onConfirm prop is missing");
11144
11108
  }
11145
- },
11146
- variant: "outline"
11109
+ })
11147
11110
  },
11148
- ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
11149
- ), /* @__PURE__ */ React88.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
11150
- )));
11111
+ /* @__PURE__ */ React88.createElement(
11112
+ Controller5,
11113
+ {
11114
+ control,
11115
+ name: "otp_code",
11116
+ render: ({ field }) => {
11117
+ var _a2;
11118
+ return /* @__PURE__ */ React88.createElement(
11119
+ PinInput,
11120
+ {
11121
+ maxLength: codeLength,
11122
+ helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
11123
+ ...field
11124
+ }
11125
+ );
11126
+ }
11127
+ }
11128
+ ),
11129
+ showResendTimer ? /* @__PURE__ */ React88.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, (_e = props.texts) == null ? void 0 : _e.resendCodeTimer, " ", /* @__PURE__ */ React88.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React88.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React88.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React88.createElement(
11130
+ "span",
11131
+ {
11132
+ className: "clickable-link",
11133
+ onClick: () => {
11134
+ startResendTimer();
11135
+ props.onResend();
11136
+ }
11137
+ },
11138
+ ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
11139
+ )),
11140
+ /* @__PURE__ */ React88.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React88.createElement(
11141
+ Button,
11142
+ {
11143
+ type: "button",
11144
+ onClick: () => {
11145
+ if (props.onCancel) {
11146
+ return props.onCancel();
11147
+ } else {
11148
+ console.log("Cancel button clicked but onCancel prop is missing");
11149
+ }
11150
+ },
11151
+ variant: "outline"
11152
+ },
11153
+ ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
11154
+ ), /* @__PURE__ */ React88.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
11155
+ ))
11156
+ );
11151
11157
  };
11152
11158
 
11153
11159
  // blocks/feedback/UserReferralSource.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.49.7-next",
3
+ "version": "0.49.9-next",
4
4
  "description": "Modern UI Kit made with Tailwind",
5
5
  "author": {
6
6
  "name": "Sikka Software",