@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.
@@ -1,10 +1,15 @@
1
1
  "use client";
2
2
  import {
3
- Input
4
- } from "../../chunk-EOH6A3GR.mjs";
3
+ Input,
4
+ Tabs,
5
+ TabsContent,
6
+ TabsList,
7
+ TabsTrigger
8
+ } from "../../chunk-JFWD2ICY.mjs";
5
9
  import {
6
10
  StopPropagationWrapper
7
11
  } from "../../chunk-47APBDKK.mjs";
12
+ import "../../chunk-C2UOOH4X.mjs";
8
13
  import {
9
14
  Select
10
15
  } from "../../chunk-AWJSHOYU.mjs";
@@ -2899,6 +2904,12 @@ var LoginForm = ({
2899
2904
  import React7, { useState as useState4 } from "react";
2900
2905
  import { Controller as Controller2, FormProvider, useForm as useForm2 } from "react-hook-form";
2901
2906
  import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
2907
+ import {
2908
+ isPossiblePhoneNumber as isPossiblePhoneNumber2,
2909
+ isValidPhoneNumber as isValidPhoneNumber2,
2910
+ parsePhoneNumber as parsePhoneNumber2,
2911
+ validatePhoneNumberLength as validatePhoneNumberLength2
2912
+ } from "libphonenumber-js";
2902
2913
  import * as z2 from "zod";
2903
2914
 
2904
2915
  // elements/checkbox/Checkbox.tsx
@@ -3044,10 +3055,15 @@ var RegisterForm = ({
3044
3055
  minPasswordLength = 8,
3045
3056
  showTermsOption = false,
3046
3057
  showNewsletterOption = false,
3058
+ registerTypes,
3047
3059
  ...props
3048
3060
  }) => {
3049
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3061
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3050
3062
  const [passwordVisible, setPasswordVisible] = useState4(false);
3063
+ const [selectedRegisterType, setSelectedRegisterType] = useState4({
3064
+ value: ((_a = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _a.value) || "password",
3065
+ label: ((_b = registerTypes == null ? void 0 : registerTypes[0]) == null ? void 0 : _b.label) || "Password"
3066
+ });
3051
3067
  const thirdPartyAuthTexts = {
3052
3068
  continueWithGoogle: texts == null ? void 0 : texts.continueWithGoogle,
3053
3069
  continueWithTwitter: texts == null ? void 0 : texts.continueWithTwitter,
@@ -3059,8 +3075,12 @@ var RegisterForm = ({
3059
3075
  };
3060
3076
  const methods = useForm2();
3061
3077
  let fieldSchemas = {};
3078
+ const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
3079
+ if (hasPhoneType && selectedRegisterType.value === "phone") {
3080
+ registerFields = ["phone"];
3081
+ }
3062
3082
  registerFields.forEach((field) => {
3063
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
3083
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
3064
3084
  switch (field) {
3065
3085
  case "fullname":
3066
3086
  fieldSchemas["fullName"] = z2.string().optional();
@@ -3085,347 +3105,502 @@ var RegisterForm = ({
3085
3105
  { message: ((_g2 = texts == null ? void 0 : texts.username) == null ? void 0 : _g2.invalid) || "Invalid username" }
3086
3106
  );
3087
3107
  break;
3108
+ case "phone":
3109
+ fieldSchemas["phone"] = z2.string({
3110
+ required_error: ((_h2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _h2.required) || "Phone Number Required"
3111
+ }).refine(
3112
+ (value) => {
3113
+ let isPhoneValid = isPossiblePhoneNumber2(value) && isValidPhoneNumber2(value) && validatePhoneNumberLength2(value) === void 0;
3114
+ return isPhoneValid;
3115
+ },
3116
+ { message: ((_i2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _i2.invalid) || "Phone Number Invalid" }
3117
+ );
3118
+ break;
3088
3119
  }
3089
3120
  });
3090
- const formSchema = z2.object({
3091
- ...fieldSchemas,
3092
- password: z2.string({
3093
- required_error: ((_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required) || "Password is required"
3094
- }).min(minPasswordLength, {
3095
- message: ((_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort) || "Password is too short"
3096
- }).refine((value) => value !== "", {
3097
- message: ((_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required) || "Password is required"
3098
- }),
3099
- confirm_password: z2.string({
3100
- required_error: ((_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required) || "Confirm password required"
3101
- }).min(minPasswordLength, {
3102
- message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.tooShort) || "Password is too short"
3103
- }).refine((value) => value !== "", {
3104
- message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.required) || "Confirm password is required"
3105
- }),
3106
- refCode: z2.string().optional(),
3107
- reference: z2.string().optional(),
3108
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
3109
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
3110
- }),
3111
- newsletter_accepted: z2.boolean().optional()
3112
- }).refine((data) => data.password === data.confirm_password, {
3113
- message: ((_g = texts == null ? void 0 : texts.confirm) == null ? void 0 : _g.dontMatch) || "Passwords don't match",
3114
- path: ["confirm_password"]
3115
- });
3121
+ let formSchema;
3122
+ if (selectedRegisterType.value === "phone") {
3123
+ formSchema = z2.object({
3124
+ phone: z2.string({
3125
+ required_error: ((_c = texts == null ? void 0 : texts.phone) == null ? void 0 : _c.required) || "Phone Number Required"
3126
+ }).refine(
3127
+ (value) => {
3128
+ let isPhoneValid = isPossiblePhoneNumber2(value) && isValidPhoneNumber2(value) && validatePhoneNumberLength2(value) === void 0;
3129
+ return isPhoneValid;
3130
+ },
3131
+ { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
3132
+ ),
3133
+ refCode: z2.string().optional(),
3134
+ reference: z2.string().optional(),
3135
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
3136
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
3137
+ }),
3138
+ newsletter_accepted: z2.boolean().optional()
3139
+ });
3140
+ } else {
3141
+ formSchema = z2.object({
3142
+ ...fieldSchemas,
3143
+ password: z2.string({
3144
+ required_error: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Password is required"
3145
+ }).min(minPasswordLength, {
3146
+ message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort) || "Password is too short"
3147
+ }).refine((value) => value !== "", {
3148
+ message: ((_g = texts == null ? void 0 : texts.password) == null ? void 0 : _g.required) || "Password is required"
3149
+ }),
3150
+ confirm_password: z2.string({
3151
+ required_error: ((_h = texts == null ? void 0 : texts.confirm) == null ? void 0 : _h.required) || "Confirm password required"
3152
+ }).min(minPasswordLength, {
3153
+ message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
3154
+ }).refine((value) => value !== "", {
3155
+ message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
3156
+ }),
3157
+ refCode: z2.string().optional(),
3158
+ reference: z2.string().optional(),
3159
+ terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
3160
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
3161
+ }),
3162
+ newsletter_accepted: z2.boolean().optional()
3163
+ }).refine((data) => data.password === data.confirm_password, {
3164
+ message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
3165
+ path: ["confirm_password"]
3166
+ });
3167
+ }
3116
3168
  const { handleSubmit, control, formState } = useForm2({
3117
3169
  resolver: zodResolver2(formSchema)
3118
3170
  });
3119
- return /* @__PURE__ */ React7.createElement(
3120
- "div",
3171
+ return /* @__PURE__ */ React7.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ React7.createElement(
3172
+ Card,
3121
3173
  {
3174
+ dir: props.direction,
3122
3175
  className: cn(
3123
- "hawa-flex hawa-flex-col hawa-gap-4",
3124
- (_h = props.classNames) == null ? void 0 : _h.root
3176
+ (_m = props.classNames) == null ? void 0 : _m.card,
3177
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
3125
3178
  )
3126
3179
  },
3127
3180
  /* @__PURE__ */ React7.createElement(
3128
- Card,
3181
+ CardContent,
3129
3182
  {
3130
- dir: props.direction,
3131
- className: cn(
3132
- (_i = props.classNames) == null ? void 0 : _i.card,
3133
- props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
3134
- )
3183
+ headless: registerTypes ? registerTypes.length <= 1 : true,
3184
+ noPadding: props.cardless
3135
3185
  },
3136
- /* @__PURE__ */ React7.createElement(CardContent, { headless: true, noPadding: props.cardless }, /* @__PURE__ */ React7.createElement("div", null, props.showError && /* @__PURE__ */ React7.createElement(
3137
- Alert,
3186
+ /* @__PURE__ */ React7.createElement(
3187
+ "div",
3138
3188
  {
3139
- direction: props.direction,
3140
- title: props.errorTitle,
3141
- text: props.errorText,
3142
- severity: "error",
3143
- onAlertClosed: () => {
3144
- if (props.onErrorDismissed) {
3145
- props.onErrorDismissed();
3189
+ className: cn(registerTypes && registerTypes.length > 1 ? "hawa-mt-6 hawa-mb-0" : "")
3190
+ },
3191
+ props.showError && /* @__PURE__ */ React7.createElement(
3192
+ Alert,
3193
+ {
3194
+ direction: props.direction,
3195
+ title: props.errorTitle,
3196
+ text: props.errorText,
3197
+ severity: "error",
3198
+ onAlertClosed: () => {
3199
+ if (props.onErrorDismissed) {
3200
+ props.onErrorDismissed();
3201
+ }
3146
3202
  }
3147
3203
  }
3148
- }
3149
- ), /* @__PURE__ */ React7.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React7.createElement(
3150
- "form",
3151
- {
3152
- noValidate: true,
3153
- onSubmit: handleSubmit((e) => {
3154
- if (props.onRegister) {
3155
- return props.onRegister(e);
3156
- } else {
3157
- console.log(
3158
- "Form is submitted but onRegister prop is missing"
3159
- );
3160
- }
3161
- }),
3162
- className: "hawa-flex hawa-flex-col hawa-gap-4"
3163
- },
3164
- /* @__PURE__ */ React7.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
3165
- if (fld === "fullname") {
3166
- return /* @__PURE__ */ React7.createElement(
3167
- Controller2,
3204
+ ),
3205
+ /* @__PURE__ */ React7.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React7.createElement(
3206
+ "form",
3207
+ {
3208
+ noValidate: true,
3209
+ onSubmit: handleSubmit((e) => {
3210
+ if (props.onRegister) {
3211
+ return props.onRegister(e);
3212
+ } else {
3213
+ console.log("Form is submitted but onRegister prop is missing");
3214
+ }
3215
+ }),
3216
+ className: "hawa-flex hawa-flex-col hawa-gap-4"
3217
+ },
3218
+ /* @__PURE__ */ React7.createElement(
3219
+ Tabs,
3220
+ {
3221
+ dir: props.direction,
3222
+ value: selectedRegisterType.value,
3223
+ onValueChange: (e) => {
3224
+ if (props.onRegisterTypeChange) {
3225
+ props.onRegisterTypeChange(e);
3226
+ }
3227
+ setSelectedRegisterType(
3228
+ (registerTypes == null ? void 0 : registerTypes.find((r) => r.value === e)) || registerTypes && registerTypes[0] || {
3229
+ label: "Password",
3230
+ value: "password"
3231
+ }
3232
+ );
3233
+ }
3234
+ },
3235
+ registerTypes && registerTypes.length > 1 && /* @__PURE__ */ React7.createElement(CardHeader, { className: "hawa-w-full hawa-px-0 hawa-py-0 hawa-mb-4" }, /* @__PURE__ */ React7.createElement(TabsList, { className: "hawa-w-full" }, registerTypes.map((registerType) => /* @__PURE__ */ React7.createElement(TabsTrigger, { value: registerType.value }, registerType.label)))),
3236
+ /* @__PURE__ */ React7.createElement(
3237
+ TabsContent,
3168
3238
  {
3169
- key: i,
3170
- control,
3171
- name: "fullName",
3172
- render: ({ field }) => {
3173
- var _a2, _b2, _c2;
3239
+ value: "password",
3240
+ className: cn(
3241
+ "hawa-flex hawa-flex-col hawa-gap-4",
3242
+ selectedRegisterType.value === "password" ? "hawa-block" : "hawa-hidden"
3243
+ ),
3244
+ dir: props.direction
3245
+ },
3246
+ /* @__PURE__ */ React7.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-4" }, registerFields.map((fld, i) => {
3247
+ if (fld === "fullname") {
3174
3248
  return /* @__PURE__ */ React7.createElement(
3175
- Input,
3249
+ Controller2,
3176
3250
  {
3177
- width: "full",
3178
- label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
3179
- placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
3180
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
3181
- ...field
3251
+ key: i,
3252
+ control,
3253
+ name: "fullName",
3254
+ render: ({ field }) => {
3255
+ var _a2, _b2, _c2;
3256
+ return /* @__PURE__ */ React7.createElement(
3257
+ Input,
3258
+ {
3259
+ width: "full",
3260
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
3261
+ placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
3262
+ helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
3263
+ ...field
3264
+ }
3265
+ );
3266
+ }
3182
3267
  }
3183
3268
  );
3184
3269
  }
3185
- }
3186
- );
3187
- }
3188
- if (fld === "email") {
3189
- return /* @__PURE__ */ React7.createElement(
3190
- Controller2,
3191
- {
3192
- key: i,
3193
- control,
3194
- name: "email",
3195
- render: ({ field }) => {
3196
- var _a2, _b2, _c2;
3270
+ if (fld === "email") {
3197
3271
  return /* @__PURE__ */ React7.createElement(
3198
- Input,
3272
+ Controller2,
3199
3273
  {
3200
- dir: "ltr",
3201
- inputProps: {
3202
- className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
3203
- },
3204
- width: "full",
3205
- autoComplete: "email",
3206
- label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
3207
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
3208
- placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
3209
- ...field,
3210
- onChange: (e) => {
3211
- field.onChange(
3212
- e.target.value.toLowerCase().trim()
3274
+ key: i,
3275
+ control,
3276
+ name: "email",
3277
+ render: ({ field }) => {
3278
+ var _a2, _b2, _c2;
3279
+ return /* @__PURE__ */ React7.createElement(
3280
+ Input,
3281
+ {
3282
+ dir: "ltr",
3283
+ inputProps: {
3284
+ className: props.direction === "rtl" ? "hawa-text-right" : "hawa-text-left"
3285
+ },
3286
+ width: "full",
3287
+ autoComplete: "email",
3288
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
3289
+ helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
3290
+ placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
3291
+ ...field,
3292
+ onChange: (e) => {
3293
+ field.onChange(e.target.value.toLowerCase().trim());
3294
+ }
3295
+ }
3213
3296
  );
3214
3297
  }
3215
3298
  }
3216
3299
  );
3217
3300
  }
3218
- }
3219
- );
3220
- }
3221
- if (fld === "username") {
3222
- return /* @__PURE__ */ React7.createElement(
3223
- Controller2,
3224
- {
3225
- key: i,
3226
- control,
3227
- name: "username",
3228
- render: ({ field }) => {
3229
- var _a2, _b2, _c2, _d2;
3301
+ if (fld === "username") {
3230
3302
  return /* @__PURE__ */ React7.createElement(
3231
- Input,
3303
+ Controller2,
3232
3304
  {
3233
- width: "full",
3234
- autoComplete: "username",
3235
- label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
3236
- labelProps: {
3237
- ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
3238
- },
3239
- helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
3240
- placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
3241
- ...field
3305
+ key: i,
3306
+ control,
3307
+ name: "username",
3308
+ render: ({ field }) => {
3309
+ var _a2, _b2, _c2, _d2;
3310
+ return /* @__PURE__ */ React7.createElement(
3311
+ Input,
3312
+ {
3313
+ width: "full",
3314
+ autoComplete: "username",
3315
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
3316
+ labelProps: {
3317
+ ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
3318
+ },
3319
+ helperText: (_c2 = formState.errors.username) == null ? void 0 : _c2.message,
3320
+ placeholder: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.placeholder,
3321
+ ...field
3322
+ }
3323
+ );
3324
+ }
3242
3325
  }
3243
3326
  );
3244
3327
  }
3245
- }
3246
- );
3247
- }
3248
- })),
3249
- /* @__PURE__ */ React7.createElement(
3250
- Controller2,
3251
- {
3252
- control,
3253
- name: "password",
3254
- render: ({ field }) => {
3255
- var _a2, _b2, _c2;
3256
- return /* @__PURE__ */ React7.createElement(
3257
- Input,
3328
+ })),
3329
+ /* @__PURE__ */ React7.createElement(
3330
+ Controller2,
3258
3331
  {
3259
- width: "full",
3260
- type: passwordVisible ? "text" : "password",
3261
- endIcon: /* @__PURE__ */ React7.createElement(
3262
- "div",
3263
- {
3264
- className: "hawa-cursor-pointer",
3265
- onClick: () => setPasswordVisible(!passwordVisible)
3266
- },
3267
- passwordVisible ? /* @__PURE__ */ React7.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React7.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
3268
- " "
3269
- ),
3270
- autoComplete: "new-password",
3271
- label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
3272
- placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
3273
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
3274
- ...field
3332
+ control,
3333
+ name: "password",
3334
+ render: ({ field }) => {
3335
+ var _a2, _b2, _c2;
3336
+ return /* @__PURE__ */ React7.createElement(
3337
+ Input,
3338
+ {
3339
+ width: "full",
3340
+ type: passwordVisible ? "text" : "password",
3341
+ autoComplete: "new-password",
3342
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
3343
+ placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
3344
+ helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
3345
+ endIcon: /* @__PURE__ */ React7.createElement(
3346
+ "div",
3347
+ {
3348
+ className: "hawa-cursor-pointer",
3349
+ onClick: () => setPasswordVisible(!passwordVisible)
3350
+ },
3351
+ passwordVisible ? /* @__PURE__ */ React7.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React7.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
3352
+ " "
3353
+ ),
3354
+ ...field
3355
+ }
3356
+ );
3357
+ }
3275
3358
  }
3276
- );
3277
- }
3278
- }
3279
- ),
3280
- /* @__PURE__ */ React7.createElement(
3281
- Controller2,
3282
- {
3283
- control,
3284
- name: "confirm_password",
3285
- render: ({ field }) => {
3286
- var _a2, _b2, _c2;
3287
- return /* @__PURE__ */ React7.createElement(
3288
- Input,
3359
+ ),
3360
+ /* @__PURE__ */ React7.createElement(
3361
+ Controller2,
3289
3362
  {
3290
- width: "full",
3291
- type: "password",
3292
- autoComplete: "new-password",
3293
- label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
3294
- placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
3295
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
3296
- ...field
3363
+ control,
3364
+ name: "confirm_password",
3365
+ render: ({ field }) => {
3366
+ var _a2, _b2, _c2;
3367
+ return /* @__PURE__ */ React7.createElement(
3368
+ Input,
3369
+ {
3370
+ width: "full",
3371
+ type: passwordVisible ? "text" : "password",
3372
+ autoComplete: "new-password",
3373
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
3374
+ placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
3375
+ helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
3376
+ endIcon: /* @__PURE__ */ React7.createElement(
3377
+ "div",
3378
+ {
3379
+ className: "hawa-cursor-pointer",
3380
+ onClick: () => setPasswordVisible(!passwordVisible)
3381
+ },
3382
+ passwordVisible ? /* @__PURE__ */ React7.createElement(EyeIcon, { className: "hawa-text-gray-500" }) : /* @__PURE__ */ React7.createElement(HiddenEyeIcon, { className: "hawa-text-gray-500" }),
3383
+ " "
3384
+ ),
3385
+ ...field
3386
+ }
3387
+ );
3388
+ }
3297
3389
  }
3298
- );
3299
- }
3300
- }
3301
- ),
3302
- props.additionalInputs,
3303
- props.showRefCode && /* @__PURE__ */ React7.createElement(
3304
- Controller2,
3305
- {
3306
- control,
3307
- name: "refCode",
3308
- render: ({ field }) => {
3309
- var _a2;
3310
- return /* @__PURE__ */ React7.createElement(
3311
- Input,
3390
+ ),
3391
+ props.additionalInputs,
3392
+ props.showRefCode && /* @__PURE__ */ React7.createElement(
3393
+ Controller2,
3312
3394
  {
3313
- width: "full",
3314
- label: texts == null ? void 0 : texts.refCode,
3315
- placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
3316
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
3317
- ...field
3395
+ control,
3396
+ name: "refCode",
3397
+ render: ({ field }) => {
3398
+ var _a2;
3399
+ return /* @__PURE__ */ React7.createElement(
3400
+ Input,
3401
+ {
3402
+ width: "full",
3403
+ label: texts == null ? void 0 : texts.refCode,
3404
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
3405
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
3406
+ ...field
3407
+ }
3408
+ );
3409
+ }
3318
3410
  }
3319
- );
3320
- }
3321
- }
3322
- ),
3323
- props.showUserSource && /* @__PURE__ */ React7.createElement(
3324
- Controller2,
3325
- {
3326
- control,
3327
- name: "reference",
3328
- render: ({ field }) => {
3329
- var _a2, _b2;
3330
- return /* @__PURE__ */ React7.createElement(
3331
- Select,
3411
+ ),
3412
+ props.showUserSource && /* @__PURE__ */ React7.createElement(
3413
+ Controller2,
3332
3414
  {
3333
- label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
3334
- placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
3335
- isCreatable: false,
3336
- isMulti: false,
3337
- isSearchable: false,
3338
- isClearable: false,
3339
- options: props.userReferenceOptions || [],
3340
- onChange: (e) => field.onChange(e)
3415
+ control,
3416
+ name: "reference",
3417
+ render: ({ field }) => {
3418
+ var _a2, _b2;
3419
+ return /* @__PURE__ */ React7.createElement(
3420
+ Select,
3421
+ {
3422
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
3423
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
3424
+ isCreatable: false,
3425
+ isMulti: false,
3426
+ isSearchable: false,
3427
+ isClearable: false,
3428
+ options: props.userReferenceOptions || [],
3429
+ onChange: (e) => field.onChange(e)
3430
+ }
3431
+ );
3432
+ }
3341
3433
  }
3342
- );
3343
- }
3344
- }
3345
- ),
3346
- showTermsOption || showNewsletterOption ? /* @__PURE__ */ React7.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React7.createElement(
3347
- Controller2,
3348
- {
3349
- control,
3350
- name: "terms_accepted",
3351
- render: ({ field }) => {
3352
- var _a2, _b2;
3353
- return /* @__PURE__ */ React7.createElement(
3354
- Checkbox,
3434
+ )
3435
+ ),
3436
+ /* @__PURE__ */ React7.createElement(
3437
+ TabsContent,
3438
+ {
3439
+ value: "phone",
3440
+ className: cn(
3441
+ "hawa-flex hawa-flex-col hawa-gap-4",
3442
+ selectedRegisterType.value === "phone" ? "hawa-block" : "hawa-hidden"
3443
+ ),
3444
+ dir: props.direction
3445
+ },
3446
+ /* @__PURE__ */ React7.createElement(
3447
+ Controller2,
3355
3448
  {
3356
- id: "terms_accepted",
3357
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
3358
- onCheckedChange: (e) => field.onChange(e),
3359
- label: /* @__PURE__ */ React7.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__ */ React7.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React7.createElement(
3360
- "span",
3361
- {
3362
- onClick: (e) => {
3363
- e.preventDefault();
3364
- if (props.onRouteToTOS) {
3365
- props.onRouteToTOS();
3449
+ control,
3450
+ name: "phone",
3451
+ render: ({ field }) => {
3452
+ var _a2, _b2;
3453
+ return /* @__PURE__ */ React7.createElement(
3454
+ PhoneInput,
3455
+ {
3456
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
3457
+ helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
3458
+ preferredCountry: { label: "+966" },
3459
+ ...props.phoneInputProps,
3460
+ handleChange: (e) => {
3461
+ if (isValidPhoneNumber2(e) && isPossiblePhoneNumber2(e) && validatePhoneNumberLength2(e) === void 0) {
3462
+ let parsed = parsePhoneNumber2(e);
3463
+ field.onChange(parsed.number);
3464
+ } else {
3465
+ field.onChange(e);
3466
+ }
3366
3467
  }
3367
- },
3368
- className: "clickable-link"
3369
- },
3370
- (texts == null ? void 0 : texts.termsText) || "Terms of Service"
3371
- )))
3468
+ }
3469
+ );
3470
+ }
3372
3471
  }
3373
- );
3374
- }
3375
- }
3376
- ), showNewsletterOption && /* @__PURE__ */ React7.createElement(
3377
- Controller2,
3378
- {
3379
- control,
3380
- name: "newsletter_accepted",
3381
- render: ({ field }) => /* @__PURE__ */ React7.createElement(
3382
- Checkbox,
3472
+ ),
3473
+ props.additionalInputs,
3474
+ props.showRefCode && /* @__PURE__ */ React7.createElement(
3475
+ Controller2,
3476
+ {
3477
+ control,
3478
+ name: "refCode",
3479
+ render: ({ field }) => {
3480
+ var _a2;
3481
+ return /* @__PURE__ */ React7.createElement(
3482
+ Input,
3483
+ {
3484
+ width: "full",
3485
+ label: texts == null ? void 0 : texts.refCode,
3486
+ placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
3487
+ helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
3488
+ ...field
3489
+ }
3490
+ );
3491
+ }
3492
+ }
3493
+ ),
3494
+ props.showUserSource && /* @__PURE__ */ React7.createElement(
3495
+ Controller2,
3496
+ {
3497
+ control,
3498
+ name: "reference",
3499
+ render: ({ field }) => {
3500
+ var _a2, _b2;
3501
+ return /* @__PURE__ */ React7.createElement(
3502
+ Select,
3503
+ {
3504
+ label: ((_a2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _a2.label) || "How did you learn about us?",
3505
+ placeholder: (_b2 = texts == null ? void 0 : texts.userReference) == null ? void 0 : _b2.placeholder,
3506
+ isCreatable: false,
3507
+ isMulti: false,
3508
+ isSearchable: false,
3509
+ isClearable: false,
3510
+ options: props.userReferenceOptions || [],
3511
+ onChange: (e) => field.onChange(e)
3512
+ }
3513
+ );
3514
+ }
3515
+ }
3516
+ )
3517
+ ),
3518
+ showTermsOption || showNewsletterOption ? /* @__PURE__ */ React7.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React7.createElement(
3519
+ Controller2,
3383
3520
  {
3384
- id: "newsletter_accepted",
3385
- label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
3386
- onCheckedChange: field.onChange
3521
+ control,
3522
+ name: "terms_accepted",
3523
+ render: ({ field }) => {
3524
+ var _a2, _b2;
3525
+ return /* @__PURE__ */ React7.createElement(
3526
+ Checkbox,
3527
+ {
3528
+ id: "terms_accepted",
3529
+ helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
3530
+ onCheckedChange: (e) => field.onChange(e),
3531
+ label: /* @__PURE__ */ React7.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__ */ React7.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React7.createElement(
3532
+ "span",
3533
+ {
3534
+ onClick: (e) => {
3535
+ e.preventDefault();
3536
+ if (props.onRouteToTOS) {
3537
+ props.onRouteToTOS();
3538
+ }
3539
+ },
3540
+ className: "clickable-link"
3541
+ },
3542
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
3543
+ )))
3544
+ }
3545
+ );
3546
+ }
3387
3547
  }
3388
- )
3389
- }
3390
- )) : null,
3391
- /* @__PURE__ */ React7.createElement(
3392
- Button,
3393
- {
3394
- className: "hawa-w-full",
3395
- type: "submit",
3396
- isLoading: props.isLoading,
3397
- disabled: props.isLoading
3398
- },
3399
- (texts == null ? void 0 : texts.registerText) || "Register"
3400
- ),
3401
- props.additionalButtons
3402
- )), props.onRouteToLogin && /* @__PURE__ */ React7.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__ */ React7.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ React7.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))),
3403
- props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React7.createElement(
3404
- CardFooter,
3405
- {
3406
- noPadding: props.cardless,
3407
- className: cn(
3408
- props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
3409
- )
3410
- },
3411
- /* @__PURE__ */ React7.createElement(
3412
- AuthButtons,
3413
- {
3414
- texts: thirdPartyAuthTexts,
3415
- viaGoogle: props.viaGoogle,
3416
- viaGithub: props.viaGithub,
3417
- viaTwitter: props.viaTwitter,
3418
- isGoogleLoading: props.isGoogleLoading,
3419
- isGithubLoading: props.isGithubLoading,
3420
- isTwitterLoading: props.isTwitterLoading,
3421
- handleGoogle: props.onGoogleRegister,
3422
- handleGithub: props.onGithubRegister,
3423
- handleTwitter: props.onTwitterRegister
3424
- }
3548
+ ), showNewsletterOption && /* @__PURE__ */ React7.createElement(
3549
+ Controller2,
3550
+ {
3551
+ control,
3552
+ name: "newsletter_accepted",
3553
+ render: ({ field }) => /* @__PURE__ */ React7.createElement(
3554
+ Checkbox,
3555
+ {
3556
+ id: "newsletter_accepted",
3557
+ label: (texts == null ? void 0 : texts.subscribeToNewsletter) || "Subscribe to our newsletter",
3558
+ onCheckedChange: field.onChange
3559
+ }
3560
+ )
3561
+ }
3562
+ )) : null
3563
+ ),
3564
+ /* @__PURE__ */ React7.createElement(
3565
+ Button,
3566
+ {
3567
+ className: "hawa-w-full",
3568
+ type: "submit",
3569
+ isLoading: props.isLoading,
3570
+ disabled: props.isLoading
3571
+ },
3572
+ (texts == null ? void 0 : texts.registerText) || "Register"
3573
+ ),
3574
+ props.additionalButtons
3575
+ )),
3576
+ props.onRouteToLogin && /* @__PURE__ */ React7.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__ */ React7.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ React7.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login"))
3577
+ )
3578
+ ),
3579
+ props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React7.createElement(
3580
+ CardFooter,
3581
+ {
3582
+ noPadding: props.cardless,
3583
+ className: cn(
3584
+ props.logosOnly ? "hawa-flex hawa-flex-row hawa-justify-center hawa-gap-2" : "hawa-grid hawa-grid-cols-1 hawa-gap-2"
3425
3585
  )
3426
- ) : null
3427
- )
3428
- );
3586
+ },
3587
+ /* @__PURE__ */ React7.createElement(
3588
+ AuthButtons,
3589
+ {
3590
+ texts: thirdPartyAuthTexts,
3591
+ viaGoogle: props.viaGoogle,
3592
+ viaGithub: props.viaGithub,
3593
+ viaTwitter: props.viaTwitter,
3594
+ isGoogleLoading: props.isGoogleLoading,
3595
+ isGithubLoading: props.isGithubLoading,
3596
+ isTwitterLoading: props.isTwitterLoading,
3597
+ handleGoogle: props.onGoogleRegister,
3598
+ handleGithub: props.onGithubRegister,
3599
+ handleTwitter: props.onTwitterRegister
3600
+ }
3601
+ )
3602
+ ) : null
3603
+ ));
3429
3604
  };
3430
3605
 
3431
3606
  // blocks/auth/AppLanding.tsx