@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.
@@ -515,8 +515,15 @@ var RegisterForm = ({
515
515
  continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
516
516
  continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
517
517
  };
518
- const methods = useForm2();
519
518
  let fieldSchemas = {};
519
+ let remainingFieldsSchema = z2.object({
520
+ refCode: z2.string().optional(),
521
+ reference: z2.string().optional(),
522
+ terms_accepted: showTermsOption ? z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
523
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
524
+ }) : z2.boolean().optional(),
525
+ newsletter_accepted: z2.boolean().optional()
526
+ });
520
527
  const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
521
528
  if (hasPhoneType && selectedRegisterType.value === "phone") {
522
529
  registerFields = ["phone"];
@@ -571,13 +578,7 @@ var RegisterForm = ({
571
578
  return isPhoneValid;
572
579
  },
573
580
  { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
574
- ),
575
- refCode: z2.string().optional(),
576
- reference: z2.string().optional(),
577
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
578
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
579
- }),
580
- newsletter_accepted: z2.boolean().optional()
581
+ )
581
582
  });
582
583
  } else {
583
584
  formSchema = z2.object({
@@ -595,21 +596,24 @@ var RegisterForm = ({
595
596
  message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
596
597
  }).refine((value) => value !== "", {
597
598
  message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
598
- }),
599
- refCode: z2.string().optional(),
600
- reference: z2.string().optional(),
601
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
602
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
603
- }),
604
- newsletter_accepted: z2.boolean().optional()
599
+ })
605
600
  }).refine((data) => data.password === data.confirm_password, {
606
601
  message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
607
602
  path: ["confirm_password"]
608
603
  });
609
604
  }
610
- const { handleSubmit, control, formState } = useForm2({
611
- resolver: zodResolver2(formSchema)
605
+ let finalSchema = z2.intersection(formSchema, remainingFieldsSchema);
606
+ const methods = useForm2({
607
+ resolver: zodResolver2(finalSchema)
612
608
  });
609
+ const onSubmit = (data) => {
610
+ console.log("Form submitted with data:", data);
611
+ if (props.onRegister) {
612
+ props.onRegister(data);
613
+ } else {
614
+ console.log("onRegister prop is missing");
615
+ }
616
+ };
613
617
  return /* @__PURE__ */ React3.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ React3.createElement(
614
618
  Card,
615
619
  {
@@ -649,13 +653,7 @@ var RegisterForm = ({
649
653
  {
650
654
  id: "register_form",
651
655
  noValidate: true,
652
- onSubmit: handleSubmit((e) => {
653
- if (props.onRegister) {
654
- return props.onRegister(e);
655
- } else {
656
- console.log("Form is submitted but onRegister prop is missing");
657
- }
658
- }),
656
+ onSubmit: methods.handleSubmit(onSubmit),
659
657
  className: "hawa-flex hawa-flex-col hawa-gap-4"
660
658
  },
661
659
  /* @__PURE__ */ React3.createElement(
@@ -692,7 +690,7 @@ var RegisterForm = ({
692
690
  Controller2,
693
691
  {
694
692
  key: i,
695
- control,
693
+ control: methods.control,
696
694
  name: "fullName",
697
695
  render: ({ field }) => {
698
696
  var _a2, _b2, _c2;
@@ -702,7 +700,7 @@ var RegisterForm = ({
702
700
  width: "full",
703
701
  label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
704
702
  placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
705
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
703
+ helperText: (_c2 = methods.formState.errors.fullName) == null ? void 0 : _c2.message,
706
704
  ...field
707
705
  }
708
706
  );
@@ -715,7 +713,7 @@ var RegisterForm = ({
715
713
  Controller2,
716
714
  {
717
715
  key: i,
718
- control,
716
+ control: methods.control,
719
717
  name: "email",
720
718
  render: ({ field }) => {
721
719
  var _a2, _b2, _c2;
@@ -729,7 +727,7 @@ var RegisterForm = ({
729
727
  width: "full",
730
728
  autoComplete: "email",
731
729
  label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
732
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
730
+ helperText: (_b2 = methods.formState.errors.email) == null ? void 0 : _b2.message,
733
731
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
734
732
  ...field,
735
733
  onChange: (e) => {
@@ -746,7 +744,7 @@ var RegisterForm = ({
746
744
  Controller2,
747
745
  {
748
746
  key: i,
749
- control,
747
+ control: methods.control,
750
748
  name: "username",
751
749
  render: ({ field }) => {
752
750
  var _a2, _b2, _c2, _d2, _e2;
@@ -759,7 +757,7 @@ var RegisterForm = ({
759
757
  labelProps: ((_b2 = props.usernameOptions) == null ? void 0 : _b2.label) ? {
760
758
  ...(_c2 = props.usernameOptions) == null ? void 0 : _c2.label
761
759
  } : void 0,
762
- helperText: (_d2 = formState.errors.username) == null ? void 0 : _d2.message,
760
+ helperText: (_d2 = methods.formState.errors.username) == null ? void 0 : _d2.message,
763
761
  placeholder: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.placeholder,
764
762
  ...field
765
763
  }
@@ -772,7 +770,7 @@ var RegisterForm = ({
772
770
  /* @__PURE__ */ React3.createElement(
773
771
  Controller2,
774
772
  {
775
- control,
773
+ control: methods.control,
776
774
  name: "password",
777
775
  render: ({ field }) => {
778
776
  var _a2, _b2, _c2;
@@ -784,7 +782,7 @@ var RegisterForm = ({
784
782
  autoComplete: "new-password",
785
783
  label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
786
784
  placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
787
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
785
+ helperText: (_c2 = methods.formState.errors.password) == null ? void 0 : _c2.message,
788
786
  endIcon: /* @__PURE__ */ React3.createElement(
789
787
  "div",
790
788
  {
@@ -803,7 +801,7 @@ var RegisterForm = ({
803
801
  /* @__PURE__ */ React3.createElement(
804
802
  Controller2,
805
803
  {
806
- control,
804
+ control: methods.control,
807
805
  name: "confirm_password",
808
806
  render: ({ field }) => {
809
807
  var _a2, _b2, _c2;
@@ -815,7 +813,7 @@ var RegisterForm = ({
815
813
  autoComplete: "new-password",
816
814
  label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
817
815
  placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
818
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
816
+ helperText: (_c2 = methods.formState.errors.confirm_password) == null ? void 0 : _c2.message,
819
817
  endIcon: /* @__PURE__ */ React3.createElement(
820
818
  "div",
821
819
  {
@@ -835,7 +833,7 @@ var RegisterForm = ({
835
833
  props.showRefCode && /* @__PURE__ */ React3.createElement(
836
834
  Controller2,
837
835
  {
838
- control,
836
+ control: methods.control,
839
837
  name: "refCode",
840
838
  render: ({ field }) => {
841
839
  var _a2;
@@ -845,7 +843,7 @@ var RegisterForm = ({
845
843
  width: "full",
846
844
  label: texts == null ? void 0 : texts.refCode,
847
845
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
848
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
846
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
849
847
  ...field
850
848
  }
851
849
  );
@@ -855,7 +853,7 @@ var RegisterForm = ({
855
853
  props.showUserSource && /* @__PURE__ */ React3.createElement(
856
854
  Controller2,
857
855
  {
858
- control,
856
+ control: methods.control,
859
857
  name: "reference",
860
858
  render: ({ field }) => {
861
859
  var _a2, _b2;
@@ -889,7 +887,7 @@ var RegisterForm = ({
889
887
  /* @__PURE__ */ React3.createElement(
890
888
  Controller2,
891
889
  {
892
- control,
890
+ control: methods.control,
893
891
  name: "phone",
894
892
  render: ({ field }) => {
895
893
  var _a2, _b2;
@@ -897,7 +895,7 @@ var RegisterForm = ({
897
895
  PhoneInput,
898
896
  {
899
897
  label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
900
- helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
898
+ helperText: (_b2 = methods.formState.errors.phone) == null ? void 0 : _b2.message,
901
899
  preferredCountry: { label: "+966" },
902
900
  ...props.phoneInputProps,
903
901
  handleChange: (e) => {
@@ -917,7 +915,7 @@ var RegisterForm = ({
917
915
  props.showRefCode && /* @__PURE__ */ React3.createElement(
918
916
  Controller2,
919
917
  {
920
- control,
918
+ control: methods.control,
921
919
  name: "refCode",
922
920
  render: ({ field }) => {
923
921
  var _a2;
@@ -927,7 +925,7 @@ var RegisterForm = ({
927
925
  width: "full",
928
926
  label: texts == null ? void 0 : texts.refCode,
929
927
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
930
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
928
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
931
929
  ...field
932
930
  }
933
931
  );
@@ -937,7 +935,7 @@ var RegisterForm = ({
937
935
  props.showUserSource && /* @__PURE__ */ React3.createElement(
938
936
  Controller2,
939
937
  {
940
- control,
938
+ control: methods.control,
941
939
  name: "reference",
942
940
  render: ({ field }) => {
943
941
  var _a2, _b2;
@@ -961,7 +959,7 @@ var RegisterForm = ({
961
959
  showTermsOption || showNewsletterOption ? /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React3.createElement(
962
960
  Controller2,
963
961
  {
964
- control,
962
+ control: methods.control,
965
963
  name: "terms_accepted",
966
964
  render: ({ field }) => {
967
965
  var _a2, _b2;
@@ -969,7 +967,7 @@ var RegisterForm = ({
969
967
  Checkbox,
970
968
  {
971
969
  id: "terms_accepted",
972
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
970
+ helperText: (_b2 = (_a2 = methods.formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
973
971
  onCheckedChange: (e) => field.onChange(e),
974
972
  label: /* @__PURE__ */ React3.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__ */ React3.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React3.createElement(
975
973
  "span",
@@ -991,7 +989,7 @@ var RegisterForm = ({
991
989
  ), showNewsletterOption && /* @__PURE__ */ React3.createElement(
992
990
  Controller2,
993
991
  {
994
- control,
992
+ control: methods.control,
995
993
  name: "newsletter_accepted",
996
994
  render: ({ field }) => /* @__PURE__ */ React3.createElement(
997
995
  Checkbox,
@@ -1297,63 +1295,71 @@ var CodeConfirmation = ({ codeLength = 6, ...props }) => {
1297
1295
  }
1298
1296
  };
1299
1297
  }, []);
1300
- return /* @__PURE__ */ React8.createElement(Card, null, /* @__PURE__ */ React8.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React8.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React8.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React8.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React8.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React8.createElement(
1301
- "form",
1298
+ return /* @__PURE__ */ React8.createElement(
1299
+ Card,
1302
1300
  {
1303
- noValidate: true,
1304
- onSubmit: handleSubmit((e) => {
1305
- if (props.onConfirm) {
1306
- return props.onConfirm(e);
1307
- } else {
1308
- console.log("Form is submitted but onConfirm prop is missing");
1309
- }
1310
- })
1301
+ className: cn(
1302
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
1303
+ )
1311
1304
  },
1312
- /* @__PURE__ */ React8.createElement(
1313
- Controller5,
1314
- {
1315
- control,
1316
- name: "otp_code",
1317
- render: ({ field }) => {
1318
- var _a2;
1319
- return /* @__PURE__ */ React8.createElement(
1320
- PinInput,
1321
- {
1322
- maxLength: codeLength,
1323
- helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
1324
- ...field
1325
- }
1326
- );
1327
- }
1328
- }
1329
- ),
1330
- showResendTimer ? /* @__PURE__ */ React8.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__ */ React8.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React8.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React8.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React8.createElement(
1331
- "span",
1332
- {
1333
- className: "clickable-link",
1334
- onClick: () => {
1335
- startResendTimer();
1336
- props.onResend();
1337
- }
1338
- },
1339
- ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
1340
- )),
1341
- /* @__PURE__ */ React8.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React8.createElement(
1342
- Button,
1305
+ /* @__PURE__ */ React8.createElement(CardContent, { headless: true, noPadding: props.cardless }, props.showError && /* @__PURE__ */ React8.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React8.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React8.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React8.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React8.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React8.createElement(
1306
+ "form",
1343
1307
  {
1344
- type: "button",
1345
- onClick: () => {
1346
- if (props.onCancel) {
1347
- return props.onCancel();
1308
+ noValidate: true,
1309
+ onSubmit: handleSubmit((e) => {
1310
+ if (props.onConfirm) {
1311
+ return props.onConfirm(e);
1348
1312
  } else {
1349
- console.log("Cancel button clicked but onCancel prop is missing");
1313
+ console.log("Form is submitted but onConfirm prop is missing");
1350
1314
  }
1351
- },
1352
- variant: "outline"
1315
+ })
1353
1316
  },
1354
- ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
1355
- ), /* @__PURE__ */ React8.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
1356
- )));
1317
+ /* @__PURE__ */ React8.createElement(
1318
+ Controller5,
1319
+ {
1320
+ control,
1321
+ name: "otp_code",
1322
+ render: ({ field }) => {
1323
+ var _a2;
1324
+ return /* @__PURE__ */ React8.createElement(
1325
+ PinInput,
1326
+ {
1327
+ maxLength: codeLength,
1328
+ helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
1329
+ ...field
1330
+ }
1331
+ );
1332
+ }
1333
+ }
1334
+ ),
1335
+ showResendTimer ? /* @__PURE__ */ React8.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__ */ React8.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React8.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React8.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React8.createElement(
1336
+ "span",
1337
+ {
1338
+ className: "clickable-link",
1339
+ onClick: () => {
1340
+ startResendTimer();
1341
+ props.onResend();
1342
+ }
1343
+ },
1344
+ ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
1345
+ )),
1346
+ /* @__PURE__ */ React8.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React8.createElement(
1347
+ Button,
1348
+ {
1349
+ type: "button",
1350
+ onClick: () => {
1351
+ if (props.onCancel) {
1352
+ return props.onCancel();
1353
+ } else {
1354
+ console.log("Cancel button clicked but onCancel prop is missing");
1355
+ }
1356
+ },
1357
+ variant: "outline"
1358
+ },
1359
+ ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
1360
+ ), /* @__PURE__ */ React8.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
1361
+ ))
1362
+ );
1357
1363
  };
1358
1364
 
1359
1365
  // blocks/feedback/UserReferralSource.tsx
package/dist/index.d.mts CHANGED
@@ -1903,6 +1903,7 @@ type TConfirmation = {
1903
1903
  onConfirm?: any;
1904
1904
  onResend?: any;
1905
1905
  onCancel?: any;
1906
+ cardless?: boolean;
1906
1907
  codeLength?: number;
1907
1908
  };
1908
1909
  declare const CodeConfirmation: FC<TConfirmation>;
package/dist/index.d.ts CHANGED
@@ -1903,6 +1903,7 @@ type TConfirmation = {
1903
1903
  onConfirm?: any;
1904
1904
  onResend?: any;
1905
1905
  onCancel?: any;
1906
+ cardless?: boolean;
1906
1907
  codeLength?: number;
1907
1908
  };
1908
1909
  declare const CodeConfirmation: FC<TConfirmation>;