@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.
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,347 +11387,502 @@ 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(
11429
- Alert,
11468
+ /* @__PURE__ */ import_react69.default.createElement(
11469
+ "div",
11430
11470
  {
11431
- direction: props.direction,
11432
- title: props.errorTitle,
11433
- text: props.errorText,
11434
- severity: "error",
11435
- onAlertClosed: () => {
11436
- if (props.onErrorDismissed) {
11437
- props.onErrorDismissed();
11471
+ className: cn(registerTypes && registerTypes.length > 1 ? "hawa-mt-6 hawa-mb-0" : "")
11472
+ },
11473
+ props.showError && /* @__PURE__ */ import_react69.default.createElement(
11474
+ Alert,
11475
+ {
11476
+ direction: props.direction,
11477
+ title: props.errorTitle,
11478
+ text: props.errorText,
11479
+ severity: "error",
11480
+ onAlertClosed: () => {
11481
+ if (props.onErrorDismissed) {
11482
+ props.onErrorDismissed();
11483
+ }
11438
11484
  }
11439
11485
  }
11440
- }
11441
- ), /* @__PURE__ */ import_react69.default.createElement(import_react_hook_form2.FormProvider, { ...methods }, /* @__PURE__ */ import_react69.default.createElement(
11442
- "form",
11443
- {
11444
- noValidate: true,
11445
- onSubmit: handleSubmit((e) => {
11446
- if (props.onRegister) {
11447
- return props.onRegister(e);
11448
- } else {
11449
- console.log(
11450
- "Form is submitted but onRegister prop is missing"
11451
- );
11452
- }
11453
- }),
11454
- className: "hawa-flex hawa-flex-col hawa-gap-4"
11455
- },
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(
11459
- import_react_hook_form2.Controller,
11486
+ ),
11487
+ /* @__PURE__ */ import_react69.default.createElement(import_react_hook_form2.FormProvider, { ...methods }, /* @__PURE__ */ import_react69.default.createElement(
11488
+ "form",
11489
+ {
11490
+ noValidate: true,
11491
+ onSubmit: handleSubmit((e) => {
11492
+ if (props.onRegister) {
11493
+ return props.onRegister(e);
11494
+ } else {
11495
+ console.log("Form is submitted but onRegister prop is missing");
11496
+ }
11497
+ }),
11498
+ className: "hawa-flex hawa-flex-col hawa-gap-4"
11499
+ },
11500
+ /* @__PURE__ */ import_react69.default.createElement(
11501
+ Tabs2,
11502
+ {
11503
+ dir: props.direction,
11504
+ value: selectedRegisterType.value,
11505
+ onValueChange: (e) => {
11506
+ if (props.onRegisterTypeChange) {
11507
+ props.onRegisterTypeChange(e);
11508
+ }
11509
+ setSelectedRegisterType(
11510
+ (registerTypes == null ? void 0 : registerTypes.find((r) => r.value === e)) || registerTypes && registerTypes[0] || {
11511
+ label: "Password",
11512
+ value: "password"
11513
+ }
11514
+ );
11515
+ }
11516
+ },
11517
+ registerTypes && registerTypes.length > 1 && /* @__PURE__ */ import_react69.default.createElement(CardHeader, { className: "hawa-w-full hawa-px-0 hawa-py-0 hawa-mb-4" }, /* @__PURE__ */ import_react69.default.createElement(TabsList2, { className: "hawa-w-full" }, registerTypes.map((registerType) => /* @__PURE__ */ import_react69.default.createElement(TabsTrigger2, { value: registerType.value }, registerType.label)))),
11518
+ /* @__PURE__ */ import_react69.default.createElement(
11519
+ TabsContent,
11460
11520
  {
11461
- key: i,
11462
- control,
11463
- name: "fullName",
11464
- render: ({ field }) => {
11465
- var _a2, _b2, _c2;
11521
+ value: "password",
11522
+ className: cn(
11523
+ "hawa-flex hawa-flex-col hawa-gap-4",
11524
+ selectedRegisterType.value === "password" ? "hawa-block" : "hawa-hidden"
11525
+ ),
11526
+ dir: props.direction
11527
+ },
11528
+ /* @__PURE__ */ import_react69.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
11529
+ if (fld === "fullname") {
11466
11530
  return /* @__PURE__ */ import_react69.default.createElement(
11467
- Input,
11531
+ import_react_hook_form2.Controller,
11468
11532
  {
11469
- 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,
11473
- ...field
11533
+ key: i,
11534
+ control,
11535
+ name: "fullName",
11536
+ render: ({ field }) => {
11537
+ var _a2, _b2, _c2;
11538
+ return /* @__PURE__ */ import_react69.default.createElement(
11539
+ Input,
11540
+ {
11541
+ width: "full",
11542
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
11543
+ placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
11544
+ helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
11545
+ ...field
11546
+ }
11547
+ );
11548
+ }
11474
11549
  }
11475
11550
  );
11476
11551
  }
11477
- }
11478
- );
11479
- }
11480
- if (fld === "email") {
11481
- return /* @__PURE__ */ import_react69.default.createElement(
11482
- import_react_hook_form2.Controller,
11483
- {
11484
- key: i,
11485
- control,
11486
- name: "email",
11487
- render: ({ field }) => {
11488
- var _a2, _b2, _c2;
11552
+ if (fld === "email") {
11489
11553
  return /* @__PURE__ */ import_react69.default.createElement(
11490
- Input,
11554
+ import_react_hook_form2.Controller,
11491
11555
  {
11492
- dir: "ltr",
11493
- inputProps: {
11494
- className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
11495
- },
11496
- 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()
11556
+ key: i,
11557
+ control,
11558
+ name: "email",
11559
+ render: ({ field }) => {
11560
+ var _a2, _b2, _c2;
11561
+ return /* @__PURE__ */ import_react69.default.createElement(
11562
+ Input,
11563
+ {
11564
+ dir: "ltr",
11565
+ inputProps: {
11566
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
11567
+ },
11568
+ width: "full",
11569
+ autoComplete: "email",
11570
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
11571
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
11572
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
11573
+ ...field,
11574
+ onChange: (e) => {
11575
+ field.onChange(e.target.value.toLowerCase().trim());
11576
+ }
11577
+ }
11505
11578
  );
11506
11579
  }
11507
11580
  }
11508
11581
  );
11509
11582
  }
11510
- }
11511
- );
11512
- }
11513
- if (fld === "username") {
11514
- return /* @__PURE__ */ import_react69.default.createElement(
11515
- import_react_hook_form2.Controller,
11516
- {
11517
- key: i,
11518
- control,
11519
- name: "username",
11520
- render: ({ field }) => {
11521
- var _a2, _b2, _c2, _d2;
11583
+ if (fld === "username") {
11522
11584
  return /* @__PURE__ */ import_react69.default.createElement(
11523
- Input,
11585
+ import_react_hook_form2.Controller,
11524
11586
  {
11525
- 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,
11533
- ...field
11587
+ key: i,
11588
+ control,
11589
+ name: "username",
11590
+ render: ({ field }) => {
11591
+ var _a2, _b2, _c2, _d2;
11592
+ return /* @__PURE__ */ import_react69.default.createElement(
11593
+ Input,
11594
+ {
11595
+ width: "full",
11596
+ autoComplete: "username",
11597
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
11598
+ labelProps: {
11599
+ ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
11600
+ },
11601
+ helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
11602
+ placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
11603
+ ...field
11604
+ }
11605
+ );
11606
+ }
11534
11607
  }
11535
11608
  );
11536
11609
  }
11537
- }
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,
11610
+ })),
11611
+ /* @__PURE__ */ import_react69.default.createElement(
11612
+ import_react_hook_form2.Controller,
11550
11613
  {
11551
- width: "full",
11552
- type: passwordVisible ? "text" : "password",
11553
- endIcon: /* @__PURE__ */ import_react69.default.createElement(
11554
- "div",
11555
- {
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
11614
+ control,
11615
+ name: "password",
11616
+ render: ({ field }) => {
11617
+ var _a2, _b2, _c2;
11618
+ return /* @__PURE__ */ import_react69.default.createElement(
11619
+ Input,
11620
+ {
11621
+ width: "full",
11622
+ type: passwordVisible ? "text" : "password",
11623
+ autoComplete: "new-password",
11624
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
11625
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
11626
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
11627
+ endIcon: /* @__PURE__ */ import_react69.default.createElement(
11628
+ "div",
11629
+ {
11630
+ className: "hawa-cursor-pointer",
11631
+ onClick: () => setPasswordVisible(!passwordVisible)
11632
+ },
11633
+ passwordVisible ? /* @__PURE__ */ import_react69.default.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ import_react69.default.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
11634
+ " "
11635
+ ),
11636
+ ...field
11637
+ }
11638
+ );
11639
+ }
11567
11640
  }
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,
11641
+ ),
11642
+ /* @__PURE__ */ import_react69.default.createElement(
11643
+ import_react_hook_form2.Controller,
11581
11644
  {
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
11645
+ control,
11646
+ name: "confirm_password",
11647
+ render: ({ field }) => {
11648
+ var _a2, _b2, _c2;
11649
+ return /* @__PURE__ */ import_react69.default.createElement(
11650
+ Input,
11651
+ {
11652
+ width: "full",
11653
+ type: passwordVisible ? "text" : "password",
11654
+ autoComplete: "new-password",
11655
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
11656
+ placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
11657
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
11658
+ endIcon: /* @__PURE__ */ import_react69.default.createElement(
11659
+ "div",
11660
+ {
11661
+ className: "hawa-cursor-pointer",
11662
+ onClick: () => setPasswordVisible(!passwordVisible)
11663
+ },
11664
+ passwordVisible ? /* @__PURE__ */ import_react69.default.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ import_react69.default.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
11665
+ " "
11666
+ ),
11667
+ ...field
11668
+ }
11669
+ );
11670
+ }
11589
11671
  }
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,
11672
+ ),
11673
+ props.additionalInputs,
11674
+ props.showRefCode && /* @__PURE__ */ import_react69.default.createElement(
11675
+ import_react_hook_form2.Controller,
11604
11676
  {
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
11677
+ control,
11678
+ name: "refCode",
11679
+ render: ({ field }) => {
11680
+ var _a2;
11681
+ return /* @__PURE__ */ import_react69.default.createElement(
11682
+ Input,
11683
+ {
11684
+ width: "full",
11685
+ label: texts == null ? void 0 : texts.refCode,
11686
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
11687
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
11688
+ ...field
11689
+ }
11690
+ );
11691
+ }
11610
11692
  }
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,
11693
+ ),
11694
+ props.showUserSource && /* @__PURE__ */ import_react69.default.createElement(
11695
+ import_react_hook_form2.Controller,
11624
11696
  {
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)
11697
+ control,
11698
+ name: "reference",
11699
+ render: ({ field }) => {
11700
+ var _a2, _b2;
11701
+ return /* @__PURE__ */ import_react69.default.createElement(
11702
+ Select,
11703
+ {
11704
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
11705
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
11706
+ isCreatable: false,
11707
+ isMulti: false,
11708
+ isSearchable: false,
11709
+ isClearable: false,
11710
+ options: props.userReferenceOptions || [],
11711
+ onChange: (e) => field.onChange(e)
11712
+ }
11713
+ );
11714
+ }
11633
11715
  }
11634
- );
11635
- }
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(
11646
- Checkbox,
11716
+ )
11717
+ ),
11718
+ /* @__PURE__ */ import_react69.default.createElement(
11719
+ TabsContent,
11720
+ {
11721
+ value: "phone",
11722
+ className: cn(
11723
+ "hawa-flex hawa-flex-col hawa-gap-4",
11724
+ selectedRegisterType.value === "phone" ? "hawa-block" : "hawa-hidden"
11725
+ ),
11726
+ dir: props.direction
11727
+ },
11728
+ /* @__PURE__ */ import_react69.default.createElement(
11729
+ import_react_hook_form2.Controller,
11647
11730
  {
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();
11731
+ control,
11732
+ name: "phone",
11733
+ render: ({ field }) => {
11734
+ var _a2, _b2;
11735
+ return /* @__PURE__ */ import_react69.default.createElement(
11736
+ PhoneInput,
11737
+ {
11738
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
11739
+ helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
11740
+ preferredCountry: { label: "+966" },
11741
+ ...props.phoneInputProps,
11742
+ handleChange: (e) => {
11743
+ if ((0, import_libphonenumber_js2.isValidPhoneNumber)(e) && (0, import_libphonenumber_js2.isPossiblePhoneNumber)(e) && (0, import_libphonenumber_js2.validatePhoneNumberLength)(e) === void 0) {
11744
+ let parsed = (0, import_libphonenumber_js2.parsePhoneNumber)(e);
11745
+ field.onChange(parsed.number);
11746
+ } else {
11747
+ field.onChange(e);
11748
+ }
11658
11749
  }
11659
- },
11660
- className: "clickable-link"
11661
- },
11662
- (texts == null ? void 0 : texts.termsText) || "Terms of Service"
11663
- )))
11750
+ }
11751
+ );
11752
+ }
11664
11753
  }
11665
- );
11666
- }
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,
11754
+ ),
11755
+ props.additionalInputs,
11756
+ props.showRefCode && /* @__PURE__ */ import_react69.default.createElement(
11757
+ import_react_hook_form2.Controller,
11758
+ {
11759
+ control,
11760
+ name: "refCode",
11761
+ render: ({ field }) => {
11762
+ var _a2;
11763
+ return /* @__PURE__ */ import_react69.default.createElement(
11764
+ Input,
11765
+ {
11766
+ width: "full",
11767
+ label: texts == null ? void 0 : texts.refCode,
11768
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
11769
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
11770
+ ...field
11771
+ }
11772
+ );
11773
+ }
11774
+ }
11775
+ ),
11776
+ props.showUserSource && /* @__PURE__ */ import_react69.default.createElement(
11777
+ import_react_hook_form2.Controller,
11778
+ {
11779
+ control,
11780
+ name: "reference",
11781
+ render: ({ field }) => {
11782
+ var _a2, _b2;
11783
+ return /* @__PURE__ */ import_react69.default.createElement(
11784
+ Select,
11785
+ {
11786
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
11787
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
11788
+ isCreatable: false,
11789
+ isMulti: false,
11790
+ isSearchable: false,
11791
+ isClearable: false,
11792
+ options: props.userReferenceOptions || [],
11793
+ onChange: (e) => field.onChange(e)
11794
+ }
11795
+ );
11796
+ }
11797
+ }
11798
+ )
11799
+ ),
11800
+ 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(
11801
+ import_react_hook_form2.Controller,
11675
11802
  {
11676
- id: "newsletter_accepted",
11677
- label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
11678
- onCheckedChange: field.onChange
11803
+ control,
11804
+ name: "terms_accepted",
11805
+ render: ({ field }) => {
11806
+ var _a2, _b2;
11807
+ return /* @__PURE__ */ import_react69.default.createElement(
11808
+ Checkbox,
11809
+ {
11810
+ id: "terms_accepted",
11811
+ helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
11812
+ onCheckedChange: (e) => field.onChange(e),
11813
+ 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(
11814
+ "span",
11815
+ {
11816
+ onClick: (e) => {
11817
+ e.preventDefault();
11818
+ if (props.onRouteToTOS) {
11819
+ props.onRouteToTOS();
11820
+ }
11821
+ },
11822
+ className: "clickable-link"
11823
+ },
11824
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
11825
+ )))
11826
+ }
11827
+ );
11828
+ }
11679
11829
  }
11680
- )
11681
- }
11682
- )) : null,
11683
- /* @__PURE__ */ import_react69.default.createElement(
11684
- Button,
11685
- {
11686
- className: "hawa-w-full",
11687
- type: "submit",
11688
- isLoading: props.isLoading,
11689
- disabled: props.isLoading
11690
- },
11691
- (texts == null ? void 0 : texts.registerText) || "Register"
11692
- ),
11693
- 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
- }
11830
+ ), showNewsletterOption && /* @__PURE__ */ import_react69.default.createElement(
11831
+ import_react_hook_form2.Controller,
11832
+ {
11833
+ control,
11834
+ name: "newsletter_accepted",
11835
+ render: ({ field }) => /* @__PURE__ */ import_react69.default.createElement(
11836
+ Checkbox,
11837
+ {
11838
+ id: "newsletter_accepted",
11839
+ label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
11840
+ onCheckedChange: field.onChange
11841
+ }
11842
+ )
11843
+ }
11844
+ )) : null
11845
+ ),
11846
+ /* @__PURE__ */ import_react69.default.createElement(
11847
+ Button,
11848
+ {
11849
+ className: "hawa-w-full",
11850
+ type: "submit",
11851
+ isLoading: props.isLoading,
11852
+ disabled: props.isLoading
11853
+ },
11854
+ (texts == null ? void 0 : texts.registerText) || "Register"
11855
+ ),
11856
+ props.additionalButtons
11857
+ )),
11858
+ 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"))
11859
+ )
11860
+ ),
11861
+ props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ import_react69.default.createElement(
11862
+ CardFooter,
11863
+ {
11864
+ noPadding: props.cardless,
11865
+ className: cn(
11866
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
11717
11867
  )
11718
- ) : null
11719
- )
11720
- );
11868
+ },
11869
+ /* @__PURE__ */ import_react69.default.createElement(
11870
+ AuthButtons,
11871
+ {
11872
+ texts: thirdPartyAuthTexts,
11873
+ viaGoogle: props.viaGoogle,
11874
+ viaGithub: props.viaGithub,
11875
+ viaTwitter: props.viaTwitter,
11876
+ isGoogleLoading: props.isGoogleLoading,
11877
+ isGithubLoading: props.isGithubLoading,
11878
+ isTwitterLoading: props.isTwitterLoading,
11879
+ handleGoogle: props.onGoogleRegister,
11880
+ handleGithub: props.onGithubRegister,
11881
+ handleTwitter: props.onTwitterRegister
11882
+ }
11883
+ )
11884
+ ) : null
11885
+ ));
11721
11886
  };
11722
11887
 
11723
11888
  // blocks/auth/AppLanding.tsx