@sikka/hawa 0.47.0-next → 0.48.0-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.js CHANGED
@@ -11329,6 +11329,7 @@ var LoginForm = ({
11329
11329
  var import_react69 = __toESM(require("react"));
11330
11330
  var import_react_hook_form2 = require("react-hook-form");
11331
11331
  var import_zod2 = require("@hookform/resolvers/zod");
11332
+ var import_libphonenumber_js2 = require("libphonenumber-js");
11332
11333
  var z2 = __toESM(require("zod"));
11333
11334
  var RegisterForm = ({
11334
11335
  texts,
@@ -11336,10 +11337,15 @@ var RegisterForm = ({
11336
11337
  minPasswordLength = 8,
11337
11338
  showTermsOption = false,
11338
11339
  showNewsletterOption = false,
11340
+ registerTypes,
11339
11341
  ...props
11340
11342
  }) => {
11341
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
11343
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
11342
11344
  const [passwordVisible, setPasswordVisible] = (0, import_react69.useState)(false);
11345
+ const [selectedRegisterType, setSelectedRegisterType] = (0, import_react69.useState)({
11346
+ value: ((_a = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _a.value) || "password",
11347
+ label: ((_b = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _b.label) || "Password"
11348
+ });
11343
11349
  const thirdPartyAuthTexts = {
11344
11350
  continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
11345
11351
  continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
@@ -11351,8 +11357,12 @@ var RegisterForm = ({
11351
11357
  };
11352
11358
  const methods = (0, import_react_hook_form2.useForm)();
11353
11359
  let fieldSchemas = {};
11360
+ const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
11361
+ if (hasPhoneType && selectedRegisterType.value === "phone") {
11362
+ registerFields = ["phone"];
11363
+ }
11354
11364
  registerFields.forEach((field) => {
11355
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
11365
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
11356
11366
  switch (field) {
11357
11367
  case "fullname":
11358
11368
  fieldSchemas["fullName"] = z2.string().optional();
@@ -11377,55 +11387,85 @@ var RegisterForm = ({
11377
11387
  { message: ((_g2 = texts == null ? void 0 : texts.username) == null ? void 0 : _g2.invalid) || "Invalid username" }
11378
11388
  );
11379
11389
  break;
11390
+ case "phone":
11391
+ fieldSchemas["phone"] = z2.string({
11392
+ required_error: ((_h2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _h2.required) || "Phone Number Required"
11393
+ }).refine(
11394
+ (value) => {
11395
+ let isPhoneValid = (0, import_libphonenumber_js2.isPossiblePhoneNumber)(value) && (0, import_libphonenumber_js2.isValidPhoneNumber)(value) && (0, import_libphonenumber_js2.validatePhoneNumberLength)(value) === void 0;
11396
+ return isPhoneValid;
11397
+ },
11398
+ { message: ((_i2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _i2.invalid) || "Phone Number Invalid" }
11399
+ );
11400
+ break;
11380
11401
  }
11381
11402
  });
11382
- const formSchema = z2.object({
11383
- ...fieldSchemas,
11384
- password: z2.string({
11385
- required_error: ((_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required) || "Password is required"
11386
- }).min(minPasswordLength, {
11387
- message: ((_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort) || "Password is too short"
11388
- }).refine((value) => value !== "", {
11389
- message: ((_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required) || "Password is required"
11390
- }),
11391
- confirm_password: z2.string({
11392
- required_error: ((_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required) || "Confirm password required"
11393
- }).min(minPasswordLength, {
11394
- message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.tooShort) || "Password is too short"
11395
- }).refine((value) => value !== "", {
11396
- message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.required) || "Confirm password is required"
11397
- }),
11398
- refCode: z2.string().optional(),
11399
- reference: z2.string().optional(),
11400
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
11401
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
11402
- }),
11403
- newsletter_accepted: z2.boolean().optional()
11404
- }).refine((data) => data.password === data.confirm_password, {
11405
- message: ((_g = texts == null ? void 0 : texts.confirm) == null ? void 0 : _g.dontMatch) || "Passwords don't match",
11406
- path: ["confirm_password"]
11407
- });
11403
+ let formSchema;
11404
+ if (selectedRegisterType.value === "phone") {
11405
+ formSchema = z2.object({
11406
+ phone: z2.string({
11407
+ required_error: ((_c = texts == null ? void 0 : texts.phone) == null ? void 0 : _c.required) || "Phone Number Required"
11408
+ }).refine(
11409
+ (value) => {
11410
+ let isPhoneValid = (0, import_libphonenumber_js2.isPossiblePhoneNumber)(value) && (0, import_libphonenumber_js2.isValidPhoneNumber)(value) && (0, import_libphonenumber_js2.validatePhoneNumberLength)(value) === void 0;
11411
+ return isPhoneValid;
11412
+ },
11413
+ { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
11414
+ ),
11415
+ refCode: z2.string().optional(),
11416
+ reference: z2.string().optional(),
11417
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
11418
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
11419
+ }),
11420
+ newsletter_accepted: z2.boolean().optional()
11421
+ });
11422
+ } else {
11423
+ formSchema = z2.object({
11424
+ ...fieldSchemas,
11425
+ password: z2.string({
11426
+ required_error: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Password is required"
11427
+ }).min(minPasswordLength, {
11428
+ message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort) || "Password is too short"
11429
+ }).refine((value) => value !== "", {
11430
+ message: ((_g = texts == null ? void 0 : texts.password) == null ? void 0 : _g.required) || "Password is required"
11431
+ }),
11432
+ confirm_password: z2.string({
11433
+ required_error: ((_h = texts == null ? void 0 : texts.confirm) == null ? void 0 : _h.required) || "Confirm password required"
11434
+ }).min(minPasswordLength, {
11435
+ message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
11436
+ }).refine((value) => value !== "", {
11437
+ message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
11438
+ }),
11439
+ refCode: z2.string().optional(),
11440
+ reference: z2.string().optional(),
11441
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
11442
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
11443
+ }),
11444
+ newsletter_accepted: z2.boolean().optional()
11445
+ }).refine((data) => data.password === data.confirm_password, {
11446
+ message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
11447
+ path: ["confirm_password"]
11448
+ });
11449
+ }
11408
11450
  const { handleSubmit, control, formState } = (0, import_react_hook_form2.useForm)({
11409
11451
  resolver: (0, import_zod2.zodResolver)(formSchema)
11410
11452
  });
11411
- return /* @__PURE__ */ import_react69.default.createElement(
11412
- "div",
11453
+ return /* @__PURE__ */ import_react69.default.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ import_react69.default.createElement(
11454
+ Card,
11413
11455
  {
11456
+ dir: props.direction,
11414
11457
  className: cn(
11415
- "hawa-flex hawa-flex-col hawa-gap-4",
11416
- (_h = props.classNames) == null ? void 0 : _h.root
11458
+ (_m = props.classNames) == null ? void 0 : _m.card,
11459
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
11417
11460
  )
11418
11461
  },
11419
11462
  /* @__PURE__ */ import_react69.default.createElement(
11420
- Card,
11463
+ CardContent,
11421
11464
  {
11422
- dir: props.direction,
11423
- className: cn(
11424
- (_i = props.classNames) == null ? void 0 : _i.card,
11425
- props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
11426
- )
11465
+ headless: registerTypes ? registerTypes.length <= 1 : true,
11466
+ noPadding: props.cardless
11427
11467
  },
11428
- /* @__PURE__ */ import_react69.default.createElement(CardContent, { headless: true, noPadding: props.cardless }, /* @__PURE__ */ import_react69.default.createElement("div", null, props.showError && /* @__PURE__ */ import_react69.default.createElement(
11468
+ /* @__PURE__ */ import_react69.default.createElement("div", null, props.showError && /* @__PURE__ */ import_react69.default.createElement(
11429
11469
  Alert,
11430
11470
  {
11431
11471
  direction: props.direction,
@@ -11446,240 +11486,352 @@ var RegisterForm = ({
11446
11486
  if (props.onRegister) {
11447
11487
  return props.onRegister(e);
11448
11488
  } else {
11449
- console.log(
11450
- "Form is submitted but onRegister prop is missing"
11451
- );
11489
+ console.log("Form is submitted but onRegister prop is missing");
11452
11490
  }
11453
11491
  }),
11454
11492
  className: "hawa-flex hawa-flex-col hawa-gap-4"
11455
11493
  },
11456
- /* @__PURE__ */ import_react69.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
11457
- if (fld === "fullname") {
11458
- return /* @__PURE__ */ import_react69.default.createElement(
11494
+ /* @__PURE__ */ import_react69.default.createElement(
11495
+ Tabs2,
11496
+ {
11497
+ dir: props.direction,
11498
+ value: selectedRegisterType.value,
11499
+ onValueChange: (e) => setSelectedRegisterType(
11500
+ (registerTypes == null ? void 0 : registerTypes.find((r) => r.value === e)) || registerTypes && registerTypes[0] || {
11501
+ label: "Password",
11502
+ value: "password"
11503
+ }
11504
+ )
11505
+ },
11506
+ registerTypes && registerTypes.length > 1 && /* @__PURE__ */ import_react69.default.createElement(CardHeader, { className: "hawa-w-full hawa-px-0 hawa-py-0 hawa-my-4 hawa-mt-6" }, /* @__PURE__ */ import_react69.default.createElement(TabsList2, { className: "hawa-w-full" }, registerTypes.map((registerType) => /* @__PURE__ */ import_react69.default.createElement(TabsTrigger2, { value: registerType.value }, registerType.label)))),
11507
+ /* @__PURE__ */ import_react69.default.createElement(
11508
+ TabsContent,
11509
+ {
11510
+ value: "password",
11511
+ className: cn(
11512
+ "hawa-flex hawa-flex-col hawa-gap-4",
11513
+ selectedRegisterType.value === "password" ? "hawa-block" : "hawa-hidden"
11514
+ ),
11515
+ dir: props.direction
11516
+ },
11517
+ /* @__PURE__ */ import_react69.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
11518
+ if (fld === "fullname") {
11519
+ return /* @__PURE__ */ import_react69.default.createElement(
11520
+ import_react_hook_form2.Controller,
11521
+ {
11522
+ key: i,
11523
+ control,
11524
+ name: "fullName",
11525
+ render: ({ field }) => {
11526
+ var _a2, _b2, _c2;
11527
+ return /* @__PURE__ */ import_react69.default.createElement(
11528
+ Input,
11529
+ {
11530
+ width: "full",
11531
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
11532
+ placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
11533
+ helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
11534
+ ...field
11535
+ }
11536
+ );
11537
+ }
11538
+ }
11539
+ );
11540
+ }
11541
+ if (fld === "email") {
11542
+ return /* @__PURE__ */ import_react69.default.createElement(
11543
+ import_react_hook_form2.Controller,
11544
+ {
11545
+ key: i,
11546
+ control,
11547
+ name: "email",
11548
+ render: ({ field }) => {
11549
+ var _a2, _b2, _c2;
11550
+ return /* @__PURE__ */ import_react69.default.createElement(
11551
+ Input,
11552
+ {
11553
+ dir: "ltr",
11554
+ inputProps: {
11555
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
11556
+ },
11557
+ width: "full",
11558
+ autoComplete: "email",
11559
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
11560
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
11561
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
11562
+ ...field,
11563
+ onChange: (e) => {
11564
+ field.onChange(e.target.value.toLowerCase().trim());
11565
+ }
11566
+ }
11567
+ );
11568
+ }
11569
+ }
11570
+ );
11571
+ }
11572
+ if (fld === "username") {
11573
+ return /* @__PURE__ */ import_react69.default.createElement(
11574
+ import_react_hook_form2.Controller,
11575
+ {
11576
+ key: i,
11577
+ control,
11578
+ name: "username",
11579
+ render: ({ field }) => {
11580
+ var _a2, _b2, _c2, _d2;
11581
+ return /* @__PURE__ */ import_react69.default.createElement(
11582
+ Input,
11583
+ {
11584
+ width: "full",
11585
+ autoComplete: "username",
11586
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
11587
+ labelProps: {
11588
+ ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
11589
+ },
11590
+ helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
11591
+ placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
11592
+ ...field
11593
+ }
11594
+ );
11595
+ }
11596
+ }
11597
+ );
11598
+ }
11599
+ })),
11600
+ /* @__PURE__ */ import_react69.default.createElement(
11459
11601
  import_react_hook_form2.Controller,
11460
11602
  {
11461
- key: i,
11462
11603
  control,
11463
- name: "fullName",
11604
+ name: "password",
11464
11605
  render: ({ field }) => {
11465
11606
  var _a2, _b2, _c2;
11466
11607
  return /* @__PURE__ */ import_react69.default.createElement(
11467
11608
  Input,
11468
11609
  {
11469
11610
  width: "full",
11470
- label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
11471
- placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
11472
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
11611
+ type: passwordVisible ? "text" : "password",
11612
+ autoComplete: "new-password",
11613
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
11614
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
11615
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
11616
+ endIcon: /* @__PURE__ */ import_react69.default.createElement(
11617
+ "div",
11618
+ {
11619
+ className: "hawa-cursor-pointer",
11620
+ onClick: () => setPasswordVisible(!passwordVisible)
11621
+ },
11622
+ passwordVisible ? /* @__PURE__ */ import_react69.default.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ import_react69.default.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
11623
+ " "
11624
+ ),
11473
11625
  ...field
11474
11626
  }
11475
11627
  );
11476
11628
  }
11477
11629
  }
11478
- );
11479
- }
11480
- if (fld === "email") {
11481
- return /* @__PURE__ */ import_react69.default.createElement(
11630
+ ),
11631
+ /* @__PURE__ */ import_react69.default.createElement(
11482
11632
  import_react_hook_form2.Controller,
11483
11633
  {
11484
- key: i,
11485
11634
  control,
11486
- name: "email",
11635
+ name: "confirm_password",
11487
11636
  render: ({ field }) => {
11488
11637
  var _a2, _b2, _c2;
11489
11638
  return /* @__PURE__ */ import_react69.default.createElement(
11490
11639
  Input,
11491
11640
  {
11492
- dir: "ltr",
11493
- inputProps: {
11494
- className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
11495
- },
11496
11641
  width: "full",
11497
- autoComplete: "email",
11498
- label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
11499
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
11500
- placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
11501
- ...field,
11502
- onChange: (e) => {
11503
- field.onChange(
11504
- e.target.value.toLowerCase().trim()
11505
- );
11506
- }
11642
+ type: passwordVisible ? "text" : "password",
11643
+ autoComplete: "new-password",
11644
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
11645
+ placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
11646
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
11647
+ endIcon: /* @__PURE__ */ import_react69.default.createElement(
11648
+ "div",
11649
+ {
11650
+ className: "hawa-cursor-pointer",
11651
+ onClick: () => setPasswordVisible(!passwordVisible)
11652
+ },
11653
+ passwordVisible ? /* @__PURE__ */ import_react69.default.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ import_react69.default.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
11654
+ " "
11655
+ ),
11656
+ ...field
11507
11657
  }
11508
11658
  );
11509
11659
  }
11510
11660
  }
11511
- );
11512
- }
11513
- if (fld === "username") {
11514
- return /* @__PURE__ */ import_react69.default.createElement(
11661
+ ),
11662
+ props.additionalInputs,
11663
+ props.showRefCode && /* @__PURE__ */ import_react69.default.createElement(
11515
11664
  import_react_hook_form2.Controller,
11516
11665
  {
11517
- key: i,
11518
11666
  control,
11519
- name: "username",
11667
+ name: "refCode",
11520
11668
  render: ({ field }) => {
11521
- var _a2, _b2, _c2, _d2;
11669
+ var _a2;
11522
11670
  return /* @__PURE__ */ import_react69.default.createElement(
11523
11671
  Input,
11524
11672
  {
11525
11673
  width: "full",
11526
- autoComplete: "username",
11527
- label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
11528
- labelProps: {
11529
- ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
11530
- },
11531
- helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
11532
- placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
11674
+ label: texts == null ? void 0 : texts.refCode,
11675
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
11676
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
11533
11677
  ...field
11534
11678
  }
11535
11679
  );
11536
11680
  }
11537
11681
  }
11538
- );
11539
- }
11540
- })),
11541
- /* @__PURE__ */ import_react69.default.createElement(
11542
- import_react_hook_form2.Controller,
11543
- {
11544
- control,
11545
- name: "password",
11546
- render: ({ field }) => {
11547
- var _a2, _b2, _c2;
11548
- return /* @__PURE__ */ import_react69.default.createElement(
11549
- Input,
11550
- {
11551
- width: "full",
11552
- type: passwordVisible ? "text" : "password",
11553
- endIcon: /* @__PURE__ */ import_react69.default.createElement(
11554
- "div",
11682
+ ),
11683
+ props.showUserSource && /* @__PURE__ */ import_react69.default.createElement(
11684
+ import_react_hook_form2.Controller,
11685
+ {
11686
+ control,
11687
+ name: "reference",
11688
+ render: ({ field }) => {
11689
+ var _a2, _b2;
11690
+ return /* @__PURE__ */ import_react69.default.createElement(
11691
+ Select,
11555
11692
  {
11556
- className: "hawa-cursor-pointer",
11557
- onClick: () => setPasswordVisible(!passwordVisible)
11558
- },
11559
- passwordVisible ? /* @__PURE__ */ import_react69.default.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ import_react69.default.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
11560
- " "
11561
- ),
11562
- autoComplete: "new-password",
11563
- label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
11564
- placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
11565
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
11566
- ...field
11693
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
11694
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
11695
+ isCreatable: false,
11696
+ isMulti: false,
11697
+ isSearchable: false,
11698
+ isClearable: false,
11699
+ options: props.userReferenceOptions || [],
11700
+ onChange: (e) => field.onChange(e)
11701
+ }
11702
+ );
11567
11703
  }
11568
- );
11569
- }
11570
- }
11571
- ),
11572
- /* @__PURE__ */ import_react69.default.createElement(
11573
- import_react_hook_form2.Controller,
11574
- {
11575
- control,
11576
- name: "confirm_password",
11577
- render: ({ field }) => {
11578
- var _a2, _b2, _c2;
11579
- return /* @__PURE__ */ import_react69.default.createElement(
11580
- Input,
11581
- {
11582
- width: "full",
11583
- type: "password",
11584
- autoComplete: "new-password",
11585
- label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
11586
- placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
11587
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
11588
- ...field
11704
+ }
11705
+ )
11706
+ ),
11707
+ /* @__PURE__ */ import_react69.default.createElement(
11708
+ TabsContent,
11709
+ {
11710
+ value: "phone",
11711
+ className: cn(
11712
+ "hawa-flex hawa-flex-col hawa-gap-4",
11713
+ selectedRegisterType.value === "phone" ? "hawa-block" : "hawa-hidden"
11714
+ ),
11715
+ dir: props.direction
11716
+ },
11717
+ /* @__PURE__ */ import_react69.default.createElement(
11718
+ import_react_hook_form2.Controller,
11719
+ {
11720
+ control,
11721
+ name: "phone",
11722
+ render: ({ field }) => {
11723
+ var _a2, _b2;
11724
+ return /* @__PURE__ */ import_react69.default.createElement(
11725
+ PhoneInput,
11726
+ {
11727
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
11728
+ helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
11729
+ preferredCountry: { label: "+966" },
11730
+ ...props.phoneInputProps,
11731
+ handleChange: (e) => {
11732
+ if ((0, import_libphonenumber_js2.isValidPhoneNumber)(e) && (0, import_libphonenumber_js2.isPossiblePhoneNumber)(e) && (0, import_libphonenumber_js2.validatePhoneNumberLength)(e) === void 0) {
11733
+ let parsed = (0, import_libphonenumber_js2.parsePhoneNumber)(e);
11734
+ field.onChange(parsed.number);
11735
+ } else {
11736
+ field.onChange(e);
11737
+ }
11738
+ }
11739
+ }
11740
+ );
11589
11741
  }
11590
- );
11591
- }
11592
- }
11593
- ),
11594
- props.additionalInputs,
11595
- props.showRefCode && /* @__PURE__ */ import_react69.default.createElement(
11596
- import_react_hook_form2.Controller,
11597
- {
11598
- control,
11599
- name: "refCode",
11600
- render: ({ field }) => {
11601
- var _a2;
11602
- return /* @__PURE__ */ import_react69.default.createElement(
11603
- Input,
11604
- {
11605
- width: "full",
11606
- label: texts == null ? void 0 : texts.refCode,
11607
- placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
11608
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
11609
- ...field
11742
+ }
11743
+ ),
11744
+ props.additionalInputs,
11745
+ props.showRefCode && /* @__PURE__ */ import_react69.default.createElement(
11746
+ import_react_hook_form2.Controller,
11747
+ {
11748
+ control,
11749
+ name: "refCode",
11750
+ render: ({ field }) => {
11751
+ var _a2;
11752
+ return /* @__PURE__ */ import_react69.default.createElement(
11753
+ Input,
11754
+ {
11755
+ width: "full",
11756
+ label: texts == null ? void 0 : texts.refCode,
11757
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
11758
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
11759
+ ...field
11760
+ }
11761
+ );
11610
11762
  }
11611
- );
11612
- }
11613
- }
11614
- ),
11615
- props.showUserSource && /* @__PURE__ */ import_react69.default.createElement(
11616
- import_react_hook_form2.Controller,
11617
- {
11618
- control,
11619
- name: "reference",
11620
- render: ({ field }) => {
11621
- var _a2, _b2;
11622
- return /* @__PURE__ */ import_react69.default.createElement(
11623
- Select,
11624
- {
11625
- label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
11626
- placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
11627
- isCreatable: false,
11628
- isMulti: false,
11629
- isSearchable: false,
11630
- isClearable: false,
11631
- options: props.userReferenceOptions || [],
11632
- onChange: (e) => field.onChange(e)
11763
+ }
11764
+ ),
11765
+ props.showUserSource && /* @__PURE__ */ import_react69.default.createElement(
11766
+ import_react_hook_form2.Controller,
11767
+ {
11768
+ control,
11769
+ name: "reference",
11770
+ render: ({ field }) => {
11771
+ var _a2, _b2;
11772
+ return /* @__PURE__ */ import_react69.default.createElement(
11773
+ Select,
11774
+ {
11775
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
11776
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
11777
+ isCreatable: false,
11778
+ isMulti: false,
11779
+ isSearchable: false,
11780
+ isClearable: false,
11781
+ options: props.userReferenceOptions || [],
11782
+ onChange: (e) => field.onChange(e)
11783
+ }
11784
+ );
11633
11785
  }
11634
- );
11786
+ }
11787
+ )
11788
+ ),
11789
+ showTermsOption || showNewsletterOption ? /* @__PURE__ */ import_react69.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ import_react69.default.createElement(
11790
+ import_react_hook_form2.Controller,
11791
+ {
11792
+ control,
11793
+ name: "terms_accepted",
11794
+ render: ({ field }) => {
11795
+ var _a2, _b2;
11796
+ return /* @__PURE__ */ import_react69.default.createElement(
11797
+ Checkbox,
11798
+ {
11799
+ id: "terms_accepted",
11800
+ helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
11801
+ onCheckedChange: (e) => field.onChange(e),
11802
+ label: /* @__PURE__ */ import_react69.default.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__ */ import_react69.default.createElement(StopPropagationWrapper, null, /* @__PURE__ */ import_react69.default.createElement(
11803
+ "span",
11804
+ {
11805
+ onClick: (e) => {
11806
+ e.preventDefault();
11807
+ if (props.onRouteToTOS) {
11808
+ props.onRouteToTOS();
11809
+ }
11810
+ },
11811
+ className: "clickable-link"
11812
+ },
11813
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
11814
+ )))
11815
+ }
11816
+ );
11817
+ }
11635
11818
  }
11636
- }
11637
- ),
11638
- showTermsOption || showNewsletterOption ? /* @__PURE__ */ import_react69.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ import_react69.default.createElement(
11639
- import_react_hook_form2.Controller,
11640
- {
11641
- control,
11642
- name: "terms_accepted",
11643
- render: ({ field }) => {
11644
- var _a2, _b2;
11645
- return /* @__PURE__ */ import_react69.default.createElement(
11819
+ ), showNewsletterOption && /* @__PURE__ */ import_react69.default.createElement(
11820
+ import_react_hook_form2.Controller,
11821
+ {
11822
+ control,
11823
+ name: "newsletter_accepted",
11824
+ render: ({ field }) => /* @__PURE__ */ import_react69.default.createElement(
11646
11825
  Checkbox,
11647
11826
  {
11648
- id: "terms_accepted",
11649
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
11650
- onCheckedChange: (e) => field.onChange(e),
11651
- label: /* @__PURE__ */ import_react69.default.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__ */ import_react69.default.createElement(StopPropagationWrapper, null, /* @__PURE__ */ import_react69.default.createElement(
11652
- "span",
11653
- {
11654
- onClick: (e) => {
11655
- e.preventDefault();
11656
- if (props.onRouteToTOS) {
11657
- props.onRouteToTOS();
11658
- }
11659
- },
11660
- className: "clickable-link"
11661
- },
11662
- (texts == null ? void 0 : texts.termsText) || "Terms of Service"
11663
- )))
11827
+ id: "newsletter_accepted",
11828
+ label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
11829
+ onCheckedChange: field.onChange
11664
11830
  }
11665
- );
11831
+ )
11666
11832
  }
11667
- }
11668
- ), showNewsletterOption && /* @__PURE__ */ import_react69.default.createElement(
11669
- import_react_hook_form2.Controller,
11670
- {
11671
- control,
11672
- name: "newsletter_accepted",
11673
- render: ({ field }) => /* @__PURE__ */ import_react69.default.createElement(
11674
- Checkbox,
11675
- {
11676
- id: "newsletter_accepted",
11677
- label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
11678
- onCheckedChange: field.onChange
11679
- }
11680
- )
11681
- }
11682
- )) : null,
11833
+ )) : null
11834
+ ),
11683
11835
  /* @__PURE__ */ import_react69.default.createElement(
11684
11836
  Button,
11685
11837
  {
@@ -11691,33 +11843,33 @@ var RegisterForm = ({
11691
11843
  (texts == null ? void 0 : texts.registerText) || "Register"
11692
11844
  ),
11693
11845
  props.additionalButtons
11694
- )), props.onRouteToLogin && /* @__PURE__ */ import_react69.default.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__ */ import_react69.default.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ import_react69.default.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))),
11695
- props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ import_react69.default.createElement(
11696
- CardFooter,
11697
- {
11698
- noPadding: props.cardless,
11699
- className: cn(
11700
- props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
11701
- )
11702
- },
11703
- /* @__PURE__ */ import_react69.default.createElement(
11704
- AuthButtons,
11705
- {
11706
- texts: thirdPartyAuthTexts,
11707
- viaGoogle: props.viaGoogle,
11708
- viaGithub: props.viaGithub,
11709
- viaTwitter: props.viaTwitter,
11710
- isGoogleLoading: props.isGoogleLoading,
11711
- isGithubLoading: props.isGithubLoading,
11712
- isTwitterLoading: props.isTwitterLoading,
11713
- handleGoogle: props.onGoogleRegister,
11714
- handleGithub: props.onGithubRegister,
11715
- handleTwitter: props.onTwitterRegister
11716
- }
11846
+ )), props.onRouteToLogin && /* @__PURE__ */ import_react69.default.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__ */ import_react69.default.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ import_react69.default.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))
11847
+ ),
11848
+ props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ import_react69.default.createElement(
11849
+ CardFooter,
11850
+ {
11851
+ noPadding: props.cardless,
11852
+ className: cn(
11853
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
11717
11854
  )
11718
- ) : null
11719
- )
11720
- );
11855
+ },
11856
+ /* @__PURE__ */ import_react69.default.createElement(
11857
+ AuthButtons,
11858
+ {
11859
+ texts: thirdPartyAuthTexts,
11860
+ viaGoogle: props.viaGoogle,
11861
+ viaGithub: props.viaGithub,
11862
+ viaTwitter: props.viaTwitter,
11863
+ isGoogleLoading: props.isGoogleLoading,
11864
+ isGithubLoading: props.isGithubLoading,
11865
+ isTwitterLoading: props.isTwitterLoading,
11866
+ handleGoogle: props.onGoogleRegister,
11867
+ handleGithub: props.onGithubRegister,
11868
+ handleTwitter: props.onTwitterRegister
11869
+ }
11870
+ )
11871
+ ) : null
11872
+ ));
11721
11873
  };
11722
11874
 
11723
11875
  // blocks/auth/AppLanding.tsx