@sikka/hawa 0.47.0-next → 0.48.1-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.
@@ -17,7 +17,7 @@ import {
17
17
  TabsList,
18
18
  TabsTrigger,
19
19
  Textarea
20
- } from "../chunk-342KIV4R.mjs";
20
+ } from "../chunk-GBLWUEYN.mjs";
21
21
  import {
22
22
  getHotkeyHandler
23
23
  } from "../chunk-WL7C2A5D.mjs";
@@ -483,6 +483,12 @@ var LoginForm = ({
483
483
  import React3, { useState as useState2 } from "react";
484
484
  import { Controller as Controller2, FormProvider, useForm as useForm2 } from "react-hook-form";
485
485
  import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
486
+ import {
487
+ isPossiblePhoneNumber as isPossiblePhoneNumber2,
488
+ isValidPhoneNumber as isValidPhoneNumber2,
489
+ parsePhoneNumber as parsePhoneNumber2,
490
+ validatePhoneNumberLength as validatePhoneNumberLength2
491
+ } from "libphonenumber-js";
486
492
  import * as z2 from "zod";
487
493
  var RegisterForm = ({
488
494
  texts,
@@ -490,10 +496,15 @@ var RegisterForm = ({
490
496
  minPasswordLength = 8,
491
497
  showTermsOption = false,
492
498
  showNewsletterOption = false,
499
+ registerTypes,
493
500
  ...props
494
501
  }) => {
495
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
502
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
496
503
  const [passwordVisible, setPasswordVisible] = useState2(false);
504
+ const [selectedRegisterType, setSelectedRegisterType] = useState2({
505
+ value: ((_a = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _a.value) || "password",
506
+ label: ((_b = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _b.label) || "Password"
507
+ });
497
508
  const thirdPartyAuthTexts = {
498
509
  continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
499
510
  continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
@@ -505,8 +516,12 @@ var RegisterForm = ({
505
516
  };
506
517
  const methods = useForm2();
507
518
  let fieldSchemas = {};
519
+ const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
520
+ if (hasPhoneType && selectedRegisterType.value === "phone") {
521
+ registerFields = ["phone"];
522
+ }
508
523
  registerFields.forEach((field) => {
509
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
524
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
510
525
  switch (field) {
511
526
  case "fullname":
512
527
  fieldSchemas["fullName"] = z2.string().optional();
@@ -531,347 +546,502 @@ var RegisterForm = ({
531
546
  { message: ((_g2 = texts == null ? void 0 : texts.username) == null ? void 0 : _g2.invalid) || "Invalid username" }
532
547
  );
533
548
  break;
549
+ case "phone":
550
+ fieldSchemas["phone"] = z2.string({
551
+ required_error: ((_h2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _h2.required) || "Phone Number Required"
552
+ }).refine(
553
+ (value) => {
554
+ let isPhoneValid = isPossiblePhoneNumber2(value) && isValidPhoneNumber2(value) && validatePhoneNumberLength2(value) === void 0;
555
+ return isPhoneValid;
556
+ },
557
+ { message: ((_i2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _i2.invalid) || "Phone Number Invalid" }
558
+ );
559
+ break;
534
560
  }
535
561
  });
536
- const formSchema = z2.object({
537
- ...fieldSchemas,
538
- password: z2.string({
539
- required_error: ((_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required) || "Password is required"
540
- }).min(minPasswordLength, {
541
- message: ((_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort) || "Password is too short"
542
- }).refine((value) => value !== "", {
543
- message: ((_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required) || "Password is required"
544
- }),
545
- confirm_password: z2.string({
546
- required_error: ((_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required) || "Confirm password required"
547
- }).min(minPasswordLength, {
548
- message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.tooShort) || "Password is too short"
549
- }).refine((value) => value !== "", {
550
- message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.required) || "Confirm password is required"
551
- }),
552
- refCode: z2.string().optional(),
553
- reference: z2.string().optional(),
554
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
555
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
556
- }),
557
- newsletter_accepted: z2.boolean().optional()
558
- }).refine((data) => data.password === data.confirm_password, {
559
- message: ((_g = texts == null ? void 0 : texts.confirm) == null ? void 0 : _g.dontMatch) || "Passwords don't match",
560
- path: ["confirm_password"]
561
- });
562
+ let formSchema;
563
+ if (selectedRegisterType.value === "phone") {
564
+ formSchema = z2.object({
565
+ phone: z2.string({
566
+ required_error: ((_c = texts == null ? void 0 : texts.phone) == null ? void 0 : _c.required) || "Phone Number Required"
567
+ }).refine(
568
+ (value) => {
569
+ let isPhoneValid = isPossiblePhoneNumber2(value) && isValidPhoneNumber2(value) && validatePhoneNumberLength2(value) === void 0;
570
+ return isPhoneValid;
571
+ },
572
+ { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
573
+ ),
574
+ refCode: z2.string().optional(),
575
+ reference: z2.string().optional(),
576
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
577
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
578
+ }),
579
+ newsletter_accepted: z2.boolean().optional()
580
+ });
581
+ } else {
582
+ formSchema = z2.object({
583
+ ...fieldSchemas,
584
+ password: z2.string({
585
+ required_error: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Password is required"
586
+ }).min(minPasswordLength, {
587
+ message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort) || "Password is too short"
588
+ }).refine((value) => value !== "", {
589
+ message: ((_g = texts == null ? void 0 : texts.password) == null ? void 0 : _g.required) || "Password is required"
590
+ }),
591
+ confirm_password: z2.string({
592
+ required_error: ((_h = texts == null ? void 0 : texts.confirm) == null ? void 0 : _h.required) || "Confirm password required"
593
+ }).min(minPasswordLength, {
594
+ message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
595
+ }).refine((value) => value !== "", {
596
+ message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
597
+ }),
598
+ refCode: z2.string().optional(),
599
+ reference: z2.string().optional(),
600
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
601
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
602
+ }),
603
+ newsletter_accepted: z2.boolean().optional()
604
+ }).refine((data) => data.password === data.confirm_password, {
605
+ message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
606
+ path: ["confirm_password"]
607
+ });
608
+ }
562
609
  const { handleSubmit, control, formState } = useForm2({
563
610
  resolver: zodResolver2(formSchema)
564
611
  });
565
- return /* @__PURE__ */ React3.createElement(
566
- "div",
612
+ return /* @__PURE__ */ React3.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ React3.createElement(
613
+ Card,
567
614
  {
615
+ dir: props.direction,
568
616
  className: cn(
569
- "hawa-flex hawa-flex-col hawa-gap-4",
570
- (_h = props.classNames) == null ? void 0 : _h.root
617
+ (_m = props.classNames) == null ? void 0 : _m.card,
618
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
571
619
  )
572
620
  },
573
621
  /* @__PURE__ */ React3.createElement(
574
- Card,
622
+ CardContent,
575
623
  {
576
- dir: props.direction,
577
- className: cn(
578
- (_i = props.classNames) == null ? void 0 : _i.card,
579
- props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
580
- )
624
+ headless: registerTypes ? registerTypes.length <= 1 : true,
625
+ noPadding: props.cardless
581
626
  },
582
- /* @__PURE__ */ React3.createElement(CardContent, { headless: true, noPadding: props.cardless }, /* @__PURE__ */ React3.createElement("div", null, props.showError && /* @__PURE__ */ React3.createElement(
583
- Alert,
627
+ /* @__PURE__ */ React3.createElement(
628
+ "div",
584
629
  {
585
- direction: props.direction,
586
- title: props.errorTitle,
587
- text: props.errorText,
588
- severity: "error",
589
- onAlertClosed: () => {
590
- if (props.onErrorDismissed) {
591
- props.onErrorDismissed();
630
+ className: cn(registerTypes && registerTypes.length > 1 ? "hawa-mt-6 hawa-mb-0" : "")
631
+ },
632
+ props.showError && /* @__PURE__ */ React3.createElement(
633
+ Alert,
634
+ {
635
+ direction: props.direction,
636
+ title: props.errorTitle,
637
+ text: props.errorText,
638
+ severity: "error",
639
+ onAlertClosed: () => {
640
+ if (props.onErrorDismissed) {
641
+ props.onErrorDismissed();
642
+ }
592
643
  }
593
644
  }
594
- }
595
- ), /* @__PURE__ */ React3.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React3.createElement(
596
- "form",
597
- {
598
- noValidate: true,
599
- onSubmit: handleSubmit((e) => {
600
- if (props.onRegister) {
601
- return props.onRegister(e);
602
- } else {
603
- console.log(
604
- "Form is submitted but onRegister prop is missing"
605
- );
606
- }
607
- }),
608
- className: "hawa-flex hawa-flex-col hawa-gap-4"
609
- },
610
- /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
611
- if (fld === "fullname") {
612
- return /* @__PURE__ */ React3.createElement(
613
- Controller2,
645
+ ),
646
+ /* @__PURE__ */ React3.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React3.createElement(
647
+ "form",
648
+ {
649
+ noValidate: true,
650
+ onSubmit: handleSubmit((e) => {
651
+ if (props.onRegister) {
652
+ return props.onRegister(e);
653
+ } else {
654
+ console.log("Form is submitted but onRegister prop is missing");
655
+ }
656
+ }),
657
+ className: "hawa-flex hawa-flex-col hawa-gap-4"
658
+ },
659
+ /* @__PURE__ */ React3.createElement(
660
+ Tabs,
661
+ {
662
+ dir: props.direction,
663
+ value: selectedRegisterType.value,
664
+ onValueChange: (e) => {
665
+ if (props.onRegisterTypeChange) {
666
+ props.onRegisterTypeChange(e);
667
+ }
668
+ setSelectedRegisterType(
669
+ (registerTypes == null ? void 0 : registerTypes.find((r) => r.value === e)) || registerTypes && registerTypes[0] || {
670
+ label: "Password",
671
+ value: "password"
672
+ }
673
+ );
674
+ }
675
+ },
676
+ registerTypes && registerTypes.length > 1 && /* @__PURE__ */ React3.createElement(CardHeader, { className: "hawa-w-full hawa-px-0 hawa-py-0 hawa-mb-4" }, /* @__PURE__ */ React3.createElement(TabsList, { className: "hawa-w-full" }, registerTypes.map((registerType) => /* @__PURE__ */ React3.createElement(TabsTrigger, { value: registerType.value }, registerType.label)))),
677
+ /* @__PURE__ */ React3.createElement(
678
+ TabsContent,
614
679
  {
615
- key: i,
616
- control,
617
- name: "fullName",
618
- render: ({ field }) => {
619
- var _a2, _b2, _c2;
680
+ value: "password",
681
+ className: cn(
682
+ "hawa-flex hawa-flex-col hawa-gap-4",
683
+ selectedRegisterType.value === "password" ? "hawa-block" : "hawa-hidden"
684
+ ),
685
+ dir: props.direction
686
+ },
687
+ /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
688
+ if (fld === "fullname") {
620
689
  return /* @__PURE__ */ React3.createElement(
621
- Input,
690
+ Controller2,
622
691
  {
623
- width: "full",
624
- label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
625
- placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
626
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
627
- ...field
692
+ key: i,
693
+ control,
694
+ name: "fullName",
695
+ render: ({ field }) => {
696
+ var _a2, _b2, _c2;
697
+ return /* @__PURE__ */ React3.createElement(
698
+ Input,
699
+ {
700
+ width: "full",
701
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
702
+ placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
703
+ helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
704
+ ...field
705
+ }
706
+ );
707
+ }
628
708
  }
629
709
  );
630
710
  }
631
- }
632
- );
633
- }
634
- if (fld === "email") {
635
- return /* @__PURE__ */ React3.createElement(
636
- Controller2,
637
- {
638
- key: i,
639
- control,
640
- name: "email",
641
- render: ({ field }) => {
642
- var _a2, _b2, _c2;
711
+ if (fld === "email") {
643
712
  return /* @__PURE__ */ React3.createElement(
644
- Input,
713
+ Controller2,
645
714
  {
646
- dir: "ltr",
647
- inputProps: {
648
- className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
649
- },
650
- width: "full",
651
- autoComplete: "email",
652
- label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
653
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
654
- placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
655
- ...field,
656
- onChange: (e) => {
657
- field.onChange(
658
- e.target.value.toLowerCase().trim()
715
+ key: i,
716
+ control,
717
+ name: "email",
718
+ render: ({ field }) => {
719
+ var _a2, _b2, _c2;
720
+ return /* @__PURE__ */ React3.createElement(
721
+ Input,
722
+ {
723
+ dir: "ltr",
724
+ inputProps: {
725
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
726
+ },
727
+ width: "full",
728
+ autoComplete: "email",
729
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
730
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
731
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
732
+ ...field,
733
+ onChange: (e) => {
734
+ field.onChange(e.target.value.toLowerCase().trim());
735
+ }
736
+ }
659
737
  );
660
738
  }
661
739
  }
662
740
  );
663
741
  }
664
- }
665
- );
666
- }
667
- if (fld === "username") {
668
- return /* @__PURE__ */ React3.createElement(
669
- Controller2,
670
- {
671
- key: i,
672
- control,
673
- name: "username",
674
- render: ({ field }) => {
675
- var _a2, _b2, _c2, _d2;
742
+ if (fld === "username") {
676
743
  return /* @__PURE__ */ React3.createElement(
677
- Input,
744
+ Controller2,
678
745
  {
679
- width: "full",
680
- autoComplete: "username",
681
- label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
682
- labelProps: {
683
- ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
684
- },
685
- helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
686
- placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
687
- ...field
746
+ key: i,
747
+ control,
748
+ name: "username",
749
+ render: ({ field }) => {
750
+ var _a2, _b2, _c2, _d2;
751
+ return /* @__PURE__ */ React3.createElement(
752
+ Input,
753
+ {
754
+ width: "full",
755
+ autoComplete: "username",
756
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
757
+ labelProps: {
758
+ ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
759
+ },
760
+ helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
761
+ placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
762
+ ...field
763
+ }
764
+ );
765
+ }
688
766
  }
689
767
  );
690
768
  }
691
- }
692
- );
693
- }
694
- })),
695
- /* @__PURE__ */ React3.createElement(
696
- Controller2,
697
- {
698
- control,
699
- name: "password",
700
- render: ({ field }) => {
701
- var _a2, _b2, _c2;
702
- return /* @__PURE__ */ React3.createElement(
703
- Input,
769
+ })),
770
+ /* @__PURE__ */ React3.createElement(
771
+ Controller2,
704
772
  {
705
- width: "full",
706
- type: passwordVisible ? "text" : "password",
707
- endIcon: /* @__PURE__ */ React3.createElement(
708
- "div",
709
- {
710
- className: "hawa-cursor-pointer",
711
- onClick: () => setPasswordVisible(!passwordVisible)
712
- },
713
- passwordVisible ? /* @__PURE__ */ React3.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React3.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
714
- " "
715
- ),
716
- autoComplete: "new-password",
717
- label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
718
- placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
719
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
720
- ...field
773
+ control,
774
+ name: "password",
775
+ render: ({ field }) => {
776
+ var _a2, _b2, _c2;
777
+ return /* @__PURE__ */ React3.createElement(
778
+ Input,
779
+ {
780
+ width: "full",
781
+ type: passwordVisible ? "text" : "password",
782
+ autoComplete: "new-password",
783
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
784
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
785
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
786
+ endIcon: /* @__PURE__ */ React3.createElement(
787
+ "div",
788
+ {
789
+ className: "hawa-cursor-pointer",
790
+ onClick: () => setPasswordVisible(!passwordVisible)
791
+ },
792
+ passwordVisible ? /* @__PURE__ */ React3.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React3.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
793
+ " "
794
+ ),
795
+ ...field
796
+ }
797
+ );
798
+ }
721
799
  }
722
- );
723
- }
724
- }
725
- ),
726
- /* @__PURE__ */ React3.createElement(
727
- Controller2,
728
- {
729
- control,
730
- name: "confirm_password",
731
- render: ({ field }) => {
732
- var _a2, _b2, _c2;
733
- return /* @__PURE__ */ React3.createElement(
734
- Input,
800
+ ),
801
+ /* @__PURE__ */ React3.createElement(
802
+ Controller2,
735
803
  {
736
- width: "full",
737
- type: "password",
738
- autoComplete: "new-password",
739
- label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
740
- placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
741
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
742
- ...field
804
+ control,
805
+ name: "confirm_password",
806
+ render: ({ field }) => {
807
+ var _a2, _b2, _c2;
808
+ return /* @__PURE__ */ React3.createElement(
809
+ Input,
810
+ {
811
+ width: "full",
812
+ type: passwordVisible ? "text" : "password",
813
+ autoComplete: "new-password",
814
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
815
+ placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
816
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
817
+ endIcon: /* @__PURE__ */ React3.createElement(
818
+ "div",
819
+ {
820
+ className: "hawa-cursor-pointer",
821
+ onClick: () => setPasswordVisible(!passwordVisible)
822
+ },
823
+ passwordVisible ? /* @__PURE__ */ React3.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React3.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
824
+ " "
825
+ ),
826
+ ...field
827
+ }
828
+ );
829
+ }
743
830
  }
744
- );
745
- }
746
- }
747
- ),
748
- props.additionalInputs,
749
- props.showRefCode && /* @__PURE__ */ React3.createElement(
750
- Controller2,
751
- {
752
- control,
753
- name: "refCode",
754
- render: ({ field }) => {
755
- var _a2;
756
- return /* @__PURE__ */ React3.createElement(
757
- Input,
831
+ ),
832
+ props.additionalInputs,
833
+ props.showRefCode && /* @__PURE__ */ React3.createElement(
834
+ Controller2,
758
835
  {
759
- width: "full",
760
- label: texts == null ? void 0 : texts.refCode,
761
- placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
762
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
763
- ...field
836
+ control,
837
+ name: "refCode",
838
+ render: ({ field }) => {
839
+ var _a2;
840
+ return /* @__PURE__ */ React3.createElement(
841
+ Input,
842
+ {
843
+ width: "full",
844
+ label: texts == null ? void 0 : texts.refCode,
845
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
846
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
847
+ ...field
848
+ }
849
+ );
850
+ }
764
851
  }
765
- );
766
- }
767
- }
768
- ),
769
- props.showUserSource && /* @__PURE__ */ React3.createElement(
770
- Controller2,
771
- {
772
- control,
773
- name: "reference",
774
- render: ({ field }) => {
775
- var _a2, _b2;
776
- return /* @__PURE__ */ React3.createElement(
777
- Select,
852
+ ),
853
+ props.showUserSource && /* @__PURE__ */ React3.createElement(
854
+ Controller2,
778
855
  {
779
- label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
780
- placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
781
- isCreatable: false,
782
- isMulti: false,
783
- isSearchable: false,
784
- isClearable: false,
785
- options: props.userReferenceOptions || [],
786
- onChange: (e) => field.onChange(e)
856
+ control,
857
+ name: "reference",
858
+ render: ({ field }) => {
859
+ var _a2, _b2;
860
+ return /* @__PURE__ */ React3.createElement(
861
+ Select,
862
+ {
863
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
864
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
865
+ isCreatable: false,
866
+ isMulti: false,
867
+ isSearchable: false,
868
+ isClearable: false,
869
+ options: props.userReferenceOptions || [],
870
+ onChange: (e) => field.onChange(e)
871
+ }
872
+ );
873
+ }
787
874
  }
788
- );
789
- }
790
- }
791
- ),
792
- showTermsOption || showNewsletterOption ? /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React3.createElement(
793
- Controller2,
794
- {
795
- control,
796
- name: "terms_accepted",
797
- render: ({ field }) => {
798
- var _a2, _b2;
799
- return /* @__PURE__ */ React3.createElement(
800
- Checkbox,
875
+ )
876
+ ),
877
+ /* @__PURE__ */ React3.createElement(
878
+ TabsContent,
879
+ {
880
+ value: "phone",
881
+ className: cn(
882
+ "hawa-flex hawa-flex-col hawa-gap-4",
883
+ selectedRegisterType.value === "phone" ? "hawa-block" : "hawa-hidden"
884
+ ),
885
+ dir: props.direction
886
+ },
887
+ /* @__PURE__ */ React3.createElement(
888
+ Controller2,
801
889
  {
802
- id: "terms_accepted",
803
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
804
- onCheckedChange: (e) => field.onChange(e),
805
- 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(
806
- "span",
807
- {
808
- onClick: (e) => {
809
- e.preventDefault();
810
- if (props.onRouteToTOS) {
811
- props.onRouteToTOS();
890
+ control,
891
+ name: "phone",
892
+ render: ({ field }) => {
893
+ var _a2, _b2;
894
+ return /* @__PURE__ */ React3.createElement(
895
+ PhoneInput,
896
+ {
897
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
898
+ helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
899
+ preferredCountry: { label: "+966" },
900
+ ...props.phoneInputProps,
901
+ handleChange: (e) => {
902
+ if (isValidPhoneNumber2(e) && isPossiblePhoneNumber2(e) && validatePhoneNumberLength2(e) === void 0) {
903
+ let parsed = parsePhoneNumber2(e);
904
+ field.onChange(parsed.number);
905
+ } else {
906
+ field.onChange(e);
907
+ }
812
908
  }
813
- },
814
- className: "clickable-link"
815
- },
816
- (texts == null ? void 0 : texts.termsText) || "Terms of Service"
817
- )))
909
+ }
910
+ );
911
+ }
818
912
  }
819
- );
820
- }
821
- }
822
- ), showNewsletterOption && /* @__PURE__ */ React3.createElement(
823
- Controller2,
824
- {
825
- control,
826
- name: "newsletter_accepted",
827
- render: ({ field }) => /* @__PURE__ */ React3.createElement(
828
- Checkbox,
913
+ ),
914
+ props.additionalInputs,
915
+ props.showRefCode && /* @__PURE__ */ React3.createElement(
916
+ Controller2,
917
+ {
918
+ control,
919
+ name: "refCode",
920
+ render: ({ field }) => {
921
+ var _a2;
922
+ return /* @__PURE__ */ React3.createElement(
923
+ Input,
924
+ {
925
+ width: "full",
926
+ label: texts == null ? void 0 : texts.refCode,
927
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
928
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
929
+ ...field
930
+ }
931
+ );
932
+ }
933
+ }
934
+ ),
935
+ props.showUserSource && /* @__PURE__ */ React3.createElement(
936
+ Controller2,
937
+ {
938
+ control,
939
+ name: "reference",
940
+ render: ({ field }) => {
941
+ var _a2, _b2;
942
+ return /* @__PURE__ */ React3.createElement(
943
+ Select,
944
+ {
945
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
946
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
947
+ isCreatable: false,
948
+ isMulti: false,
949
+ isSearchable: false,
950
+ isClearable: false,
951
+ options: props.userReferenceOptions || [],
952
+ onChange: (e) => field.onChange(e)
953
+ }
954
+ );
955
+ }
956
+ }
957
+ )
958
+ ),
959
+ showTermsOption || showNewsletterOption ? /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React3.createElement(
960
+ Controller2,
829
961
  {
830
- id: "newsletter_accepted",
831
- label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
832
- onCheckedChange: field.onChange
962
+ control,
963
+ name: "terms_accepted",
964
+ render: ({ field }) => {
965
+ var _a2, _b2;
966
+ return /* @__PURE__ */ React3.createElement(
967
+ Checkbox,
968
+ {
969
+ id: "terms_accepted",
970
+ helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
971
+ onCheckedChange: (e) => field.onChange(e),
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(
973
+ "span",
974
+ {
975
+ onClick: (e) => {
976
+ e.preventDefault();
977
+ if (props.onRouteToTOS) {
978
+ props.onRouteToTOS();
979
+ }
980
+ },
981
+ className: "clickable-link"
982
+ },
983
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
984
+ )))
985
+ }
986
+ );
987
+ }
833
988
  }
834
- )
835
- }
836
- )) : null,
837
- /* @__PURE__ */ React3.createElement(
838
- Button,
839
- {
840
- className: "hawa-w-full",
841
- type: "submit",
842
- isLoading: props.isLoading,
843
- disabled: props.isLoading
844
- },
845
- (texts == null ? void 0 : texts.registerText) || "Register"
846
- ),
847
- props.additionalButtons
848
- )), props.onRouteToLogin && /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-1 hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-white" }, /* @__PURE__ */ React3.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ React3.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))),
849
- props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React3.createElement(
850
- CardFooter,
851
- {
852
- noPadding: props.cardless,
853
- className: cn(
854
- props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
855
- )
856
- },
857
- /* @__PURE__ */ React3.createElement(
858
- AuthButtons,
859
- {
860
- texts: thirdPartyAuthTexts,
861
- viaGoogle: props.viaGoogle,
862
- viaGithub: props.viaGithub,
863
- viaTwitter: props.viaTwitter,
864
- isGoogleLoading: props.isGoogleLoading,
865
- isGithubLoading: props.isGithubLoading,
866
- isTwitterLoading: props.isTwitterLoading,
867
- handleGoogle: props.onGoogleRegister,
868
- handleGithub: props.onGithubRegister,
869
- handleTwitter: props.onTwitterRegister
870
- }
989
+ ), showNewsletterOption && /* @__PURE__ */ React3.createElement(
990
+ Controller2,
991
+ {
992
+ control,
993
+ name: "newsletter_accepted",
994
+ render: ({ field }) => /* @__PURE__ */ React3.createElement(
995
+ Checkbox,
996
+ {
997
+ id: "newsletter_accepted",
998
+ label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
999
+ onCheckedChange: field.onChange
1000
+ }
1001
+ )
1002
+ }
1003
+ )) : null
1004
+ ),
1005
+ /* @__PURE__ */ React3.createElement(
1006
+ Button,
1007
+ {
1008
+ className: "hawa-w-full",
1009
+ type: "submit",
1010
+ isLoading: props.isLoading,
1011
+ disabled: props.isLoading
1012
+ },
1013
+ (texts == null ? void 0 : texts.registerText) || "Register"
1014
+ ),
1015
+ props.additionalButtons
1016
+ )),
1017
+ props.onRouteToLogin && /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-1 hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-white" }, /* @__PURE__ */ React3.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ React3.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login"))
1018
+ )
1019
+ ),
1020
+ props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React3.createElement(
1021
+ CardFooter,
1022
+ {
1023
+ noPadding: props.cardless,
1024
+ className: cn(
1025
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
871
1026
  )
872
- ) : null
873
- )
874
- );
1027
+ },
1028
+ /* @__PURE__ */ React3.createElement(
1029
+ AuthButtons,
1030
+ {
1031
+ texts: thirdPartyAuthTexts,
1032
+ viaGoogle: props.viaGoogle,
1033
+ viaGithub: props.viaGithub,
1034
+ viaTwitter: props.viaTwitter,
1035
+ isGoogleLoading: props.isGoogleLoading,
1036
+ isGithubLoading: props.isGithubLoading,
1037
+ isTwitterLoading: props.isTwitterLoading,
1038
+ handleGoogle: props.onGoogleRegister,
1039
+ handleGithub: props.onGithubRegister,
1040
+ handleTwitter: props.onTwitterRegister
1041
+ }
1042
+ )
1043
+ ) : null
1044
+ ));
875
1045
  };
876
1046
 
877
1047
  // blocks/auth/AppLanding.tsx