@sikka/hawa 0.49.7-next → 0.49.9-next

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2925,8 +2925,15 @@ var RegisterForm = ({
2925
2925
  continueWithEmail: texts == null ? void 0 : texts.continueWithEmail,
2926
2926
  continueWithPhone: texts == null ? void 0 : texts.continueWithPhone
2927
2927
  };
2928
- const methods = useForm2();
2929
2928
  let fieldSchemas = {};
2929
+ let remainingFieldsSchema = z2.object({
2930
+ refCode: z2.string().optional(),
2931
+ reference: z2.string().optional(),
2932
+ terms_accepted: showTermsOption ? z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
2933
+ message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
2934
+ }) : z2.boolean().optional(),
2935
+ newsletter_accepted: z2.boolean().optional()
2936
+ });
2930
2937
  const hasPhoneType = registerTypes == null ? void 0 : registerTypes.some((type) => type.value === "phone");
2931
2938
  if (hasPhoneType && selectedRegisterType.value === "phone") {
2932
2939
  registerFields = ["phone"];
@@ -2981,13 +2988,7 @@ var RegisterForm = ({
2981
2988
  return isPhoneValid;
2982
2989
  },
2983
2990
  { message: ((_d = texts == null ? void 0 : texts.phone) == null ? void 0 : _d.invalid) || "Phone Number Invalid" }
2984
- ),
2985
- refCode: z2.string().optional(),
2986
- reference: z2.string().optional(),
2987
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
2988
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
2989
- }),
2990
- newsletter_accepted: z2.boolean().optional()
2991
+ )
2991
2992
  });
2992
2993
  } else {
2993
2994
  formSchema = z2.object({
@@ -3005,21 +3006,24 @@ var RegisterForm = ({
3005
3006
  message: ((_i = texts == null ? void 0 : texts.password) == null ? void 0 : _i.tooShort) || "Password is too short"
3006
3007
  }).refine((value) => value !== "", {
3007
3008
  message: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Confirm password is required"
3008
- }),
3009
- refCode: z2.string().optional(),
3010
- reference: z2.string().optional(),
3011
- terms_accepted: z2.boolean({ required_error: (texts == null ? void 0 : texts.termsRequired) || "Terms required" }).refine((value) => value, {
3012
- message: (texts == null ? void 0 : texts.termsRequired) || "Terms required"
3013
- }),
3014
- newsletter_accepted: z2.boolean().optional()
3009
+ })
3015
3010
  }).refine((data) => data.password === data.confirm_password, {
3016
3011
  message: ((_k = texts == null ? void 0 : texts.confirm) == null ? void 0 : _k.dontMatch) || "Passwords don't match",
3017
3012
  path: ["confirm_password"]
3018
3013
  });
3019
3014
  }
3020
- const { handleSubmit, control, formState } = useForm2({
3021
- resolver: zodResolver2(formSchema)
3015
+ let finalSchema = z2.intersection(formSchema, remainingFieldsSchema);
3016
+ const methods = useForm2({
3017
+ resolver: zodResolver2(finalSchema)
3022
3018
  });
3019
+ const onSubmit = (data) => {
3020
+ console.log("Form submitted with data:", data);
3021
+ if (props.onRegister) {
3022
+ props.onRegister(data);
3023
+ } else {
3024
+ console.log("onRegister prop is missing");
3025
+ }
3026
+ };
3023
3027
  return /* @__PURE__ */ React7.createElement("div", { className: cn("hawa-flex hawa-flex-col", (_l = props.classNames) == null ? void 0 : _l.root) }, /* @__PURE__ */ React7.createElement(
3024
3028
  Card,
3025
3029
  {
@@ -3059,13 +3063,7 @@ var RegisterForm = ({
3059
3063
  {
3060
3064
  id: "register_form",
3061
3065
  noValidate: true,
3062
- onSubmit: handleSubmit((e) => {
3063
- if (props.onRegister) {
3064
- return props.onRegister(e);
3065
- } else {
3066
- console.log("Form is submitted but onRegister prop is missing");
3067
- }
3068
- }),
3066
+ onSubmit: methods.handleSubmit(onSubmit),
3069
3067
  className: "hawa-flex hawa-flex-col hawa-gap-4"
3070
3068
  },
3071
3069
  /* @__PURE__ */ React7.createElement(
@@ -3102,7 +3100,7 @@ var RegisterForm = ({
3102
3100
  Controller2,
3103
3101
  {
3104
3102
  key: i,
3105
- control,
3103
+ control: methods.control,
3106
3104
  name: "fullName",
3107
3105
  render: ({ field }) => {
3108
3106
  var _a2, _b2, _c2;
@@ -3112,7 +3110,7 @@ var RegisterForm = ({
3112
3110
  width: "full",
3113
3111
  label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
3114
3112
  placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
3115
- helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
3113
+ helperText: (_c2 = methods.formState.errors.fullName) == null ? void 0 : _c2.message,
3116
3114
  ...field
3117
3115
  }
3118
3116
  );
@@ -3125,7 +3123,7 @@ var RegisterForm = ({
3125
3123
  Controller2,
3126
3124
  {
3127
3125
  key: i,
3128
- control,
3126
+ control: methods.control,
3129
3127
  name: "email",
3130
3128
  render: ({ field }) => {
3131
3129
  var _a2, _b2, _c2;
@@ -3139,7 +3137,7 @@ var RegisterForm = ({
3139
3137
  width: "full",
3140
3138
  autoComplete: "email",
3141
3139
  label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
3142
- helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
3140
+ helperText: (_b2 = methods.formState.errors.email) == null ? void 0 : _b2.message,
3143
3141
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
3144
3142
  ...field,
3145
3143
  onChange: (e) => {
@@ -3156,7 +3154,7 @@ var RegisterForm = ({
3156
3154
  Controller2,
3157
3155
  {
3158
3156
  key: i,
3159
- control,
3157
+ control: methods.control,
3160
3158
  name: "username",
3161
3159
  render: ({ field }) => {
3162
3160
  var _a2, _b2, _c2, _d2, _e2;
@@ -3169,7 +3167,7 @@ var RegisterForm = ({
3169
3167
  labelProps: ((_b2 = props.usernameOptions) == null ? void 0 : _b2.label) ? {
3170
3168
  ...(_c2 = props.usernameOptions) == null ? void 0 : _c2.label
3171
3169
  } : void 0,
3172
- helperText: (_d2 = formState.errors.username) == null ? void 0 : _d2.message,
3170
+ helperText: (_d2 = methods.formState.errors.username) == null ? void 0 : _d2.message,
3173
3171
  placeholder: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.placeholder,
3174
3172
  ...field
3175
3173
  }
@@ -3182,7 +3180,7 @@ var RegisterForm = ({
3182
3180
  /* @__PURE__ */ React7.createElement(
3183
3181
  Controller2,
3184
3182
  {
3185
- control,
3183
+ control: methods.control,
3186
3184
  name: "password",
3187
3185
  render: ({ field }) => {
3188
3186
  var _a2, _b2, _c2;
@@ -3194,7 +3192,7 @@ var RegisterForm = ({
3194
3192
  autoComplete: "new-password",
3195
3193
  label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
3196
3194
  placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
3197
- helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
3195
+ helperText: (_c2 = methods.formState.errors.password) == null ? void 0 : _c2.message,
3198
3196
  endIcon: /* @__PURE__ */ React7.createElement(
3199
3197
  "div",
3200
3198
  {
@@ -3213,7 +3211,7 @@ var RegisterForm = ({
3213
3211
  /* @__PURE__ */ React7.createElement(
3214
3212
  Controller2,
3215
3213
  {
3216
- control,
3214
+ control: methods.control,
3217
3215
  name: "confirm_password",
3218
3216
  render: ({ field }) => {
3219
3217
  var _a2, _b2, _c2;
@@ -3225,7 +3223,7 @@ var RegisterForm = ({
3225
3223
  autoComplete: "new-password",
3226
3224
  label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
3227
3225
  placeholder: ((_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder) || "Confirm your Password",
3228
- helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
3226
+ helperText: (_c2 = methods.formState.errors.confirm_password) == null ? void 0 : _c2.message,
3229
3227
  endIcon: /* @__PURE__ */ React7.createElement(
3230
3228
  "div",
3231
3229
  {
@@ -3245,7 +3243,7 @@ var RegisterForm = ({
3245
3243
  props.showRefCode && /* @__PURE__ */ React7.createElement(
3246
3244
  Controller2,
3247
3245
  {
3248
- control,
3246
+ control: methods.control,
3249
3247
  name: "refCode",
3250
3248
  render: ({ field }) => {
3251
3249
  var _a2;
@@ -3255,7 +3253,7 @@ var RegisterForm = ({
3255
3253
  width: "full",
3256
3254
  label: texts == null ? void 0 : texts.refCode,
3257
3255
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
3258
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
3256
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
3259
3257
  ...field
3260
3258
  }
3261
3259
  );
@@ -3265,7 +3263,7 @@ var RegisterForm = ({
3265
3263
  props.showUserSource && /* @__PURE__ */ React7.createElement(
3266
3264
  Controller2,
3267
3265
  {
3268
- control,
3266
+ control: methods.control,
3269
3267
  name: "reference",
3270
3268
  render: ({ field }) => {
3271
3269
  var _a2, _b2;
@@ -3299,7 +3297,7 @@ var RegisterForm = ({
3299
3297
  /* @__PURE__ */ React7.createElement(
3300
3298
  Controller2,
3301
3299
  {
3302
- control,
3300
+ control: methods.control,
3303
3301
  name: "phone",
3304
3302
  render: ({ field }) => {
3305
3303
  var _a2, _b2;
@@ -3307,7 +3305,7 @@ var RegisterForm = ({
3307
3305
  PhoneInput,
3308
3306
  {
3309
3307
  label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
3310
- helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
3308
+ helperText: (_b2 = methods.formState.errors.phone) == null ? void 0 : _b2.message,
3311
3309
  preferredCountry: { label: "+966" },
3312
3310
  ...props.phoneInputProps,
3313
3311
  handleChange: (e) => {
@@ -3327,7 +3325,7 @@ var RegisterForm = ({
3327
3325
  props.showRefCode && /* @__PURE__ */ React7.createElement(
3328
3326
  Controller2,
3329
3327
  {
3330
- control,
3328
+ control: methods.control,
3331
3329
  name: "refCode",
3332
3330
  render: ({ field }) => {
3333
3331
  var _a2;
@@ -3337,7 +3335,7 @@ var RegisterForm = ({
3337
3335
  width: "full",
3338
3336
  label: texts == null ? void 0 : texts.refCode,
3339
3337
  placeholder: (texts == null ? void 0 : texts.refCodePlaceholder) || "Enter the referral code",
3340
- helperText: (_a2 = formState.errors.refCode) == null ? void 0 : _a2.message,
3338
+ helperText: (_a2 = methods.formState.errors.refCode) == null ? void 0 : _a2.message,
3341
3339
  ...field
3342
3340
  }
3343
3341
  );
@@ -3347,7 +3345,7 @@ var RegisterForm = ({
3347
3345
  props.showUserSource && /* @__PURE__ */ React7.createElement(
3348
3346
  Controller2,
3349
3347
  {
3350
- control,
3348
+ control: methods.control,
3351
3349
  name: "reference",
3352
3350
  render: ({ field }) => {
3353
3351
  var _a2, _b2;
@@ -3371,7 +3369,7 @@ var RegisterForm = ({
3371
3369
  showTermsOption || showNewsletterOption ? /* @__PURE__ */ React7.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3 hawa-mb-2" }, showTermsOption && /* @__PURE__ */ React7.createElement(
3372
3370
  Controller2,
3373
3371
  {
3374
- control,
3372
+ control: methods.control,
3375
3373
  name: "terms_accepted",
3376
3374
  render: ({ field }) => {
3377
3375
  var _a2, _b2;
@@ -3379,7 +3377,7 @@ var RegisterForm = ({
3379
3377
  Checkbox,
3380
3378
  {
3381
3379
  id: "terms_accepted",
3382
- helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
3380
+ helperText: (_b2 = (_a2 = methods.formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
3383
3381
  onCheckedChange: (e) => field.onChange(e),
3384
3382
  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(
3385
3383
  "span",
@@ -3401,7 +3399,7 @@ var RegisterForm = ({
3401
3399
  ), showNewsletterOption && /* @__PURE__ */ React7.createElement(
3402
3400
  Controller2,
3403
3401
  {
3404
- control,
3402
+ control: methods.control,
3405
3403
  name: "newsletter_accepted",
3406
3404
  render: ({ field }) => /* @__PURE__ */ React7.createElement(
3407
3405
  Checkbox,
@@ -3841,63 +3839,71 @@ var CodeConfirmation = ({ codeLength = 6, ...props }) => {
3841
3839
  }
3842
3840
  };
3843
3841
  }, []);
3844
- return /* @__PURE__ */ React13.createElement(Card, null, /* @__PURE__ */ React13.createElement(CardContent, { headless: true }, props.showError && /* @__PURE__ */ React13.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React13.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React13.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React13.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React13.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React13.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React13.createElement(
3845
- "form",
3842
+ return /* @__PURE__ */ React13.createElement(
3843
+ Card,
3846
3844
  {
3847
- noValidate: true,
3848
- onSubmit: handleSubmit((e) => {
3849
- if (props.onConfirm) {
3850
- return props.onConfirm(e);
3851
- } else {
3852
- console.log("Form is submitted but onConfirm prop is missing");
3853
- }
3854
- })
3845
+ className: cn(
3846
+ props.cardless && "hawa-border-none hawa-bg-transparent !hawa-shadow-none !hawa-drop-shadow-none"
3847
+ )
3855
3848
  },
3856
- /* @__PURE__ */ React13.createElement(
3857
- Controller5,
3858
- {
3859
- control,
3860
- name: "otp_code",
3861
- render: ({ field }) => {
3862
- var _a2;
3863
- return /* @__PURE__ */ React13.createElement(
3864
- PinInput,
3865
- {
3866
- maxLength: codeLength,
3867
- helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
3868
- ...field
3869
- }
3870
- );
3871
- }
3872
- }
3873
- ),
3874
- showResendTimer ? /* @__PURE__ */ React13.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, (_e = props.texts) == null ? void 0 : _e.resendCodeTimer, " ", /* @__PURE__ */ React13.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React13.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React13.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React13.createElement(
3875
- "span",
3876
- {
3877
- className: "clickable-link",
3878
- onClick: () => {
3879
- startResendTimer();
3880
- props.onResend();
3881
- }
3882
- },
3883
- ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
3884
- )),
3885
- /* @__PURE__ */ React13.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React13.createElement(
3886
- Button,
3849
+ /* @__PURE__ */ React13.createElement(CardContent, { headless: true, noPadding: props.cardless }, props.showError && /* @__PURE__ */ React13.createElement(Alert, { title: props.errorTitle, text: props.errorText, severity: "error" }), /* @__PURE__ */ React13.createElement("div", { className: "hawa-mb-4 dark:hawa-text-white" }, /* @__PURE__ */ React13.createElement("div", { className: "hawa-text-lg hawa-font-bold" }, ((_c = props.texts) == null ? void 0 : _c.checkYourIdentifier) || "Please check your phone"), /* @__PURE__ */ React13.createElement("div", { className: "hawa-text-muted-foreground hawa-flex hawa-flex-row" }, /* @__PURE__ */ React13.createElement("span", null, `${(_d = props.texts) == null ? void 0 : _d.weSentCode} ` || `We've sent a code to `, /* @__PURE__ */ React13.createElement("span", { dir: "ltr" }, props.identifier)))), /* @__PURE__ */ React13.createElement(
3850
+ "form",
3887
3851
  {
3888
- type: "button",
3889
- onClick: () => {
3890
- if (props.onCancel) {
3891
- return props.onCancel();
3852
+ noValidate: true,
3853
+ onSubmit: handleSubmit((e) => {
3854
+ if (props.onConfirm) {
3855
+ return props.onConfirm(e);
3892
3856
  } else {
3893
- console.log("Cancel button clicked but onCancel prop is missing");
3857
+ console.log("Form is submitted but onConfirm prop is missing");
3894
3858
  }
3895
- },
3896
- variant: "outline"
3859
+ })
3897
3860
  },
3898
- ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
3899
- ), /* @__PURE__ */ React13.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
3900
- )));
3861
+ /* @__PURE__ */ React13.createElement(
3862
+ Controller5,
3863
+ {
3864
+ control,
3865
+ name: "otp_code",
3866
+ render: ({ field }) => {
3867
+ var _a2;
3868
+ return /* @__PURE__ */ React13.createElement(
3869
+ PinInput,
3870
+ {
3871
+ maxLength: codeLength,
3872
+ helperText: (_a2 = formState.errors.otp_code) == null ? void 0 : _a2.message,
3873
+ ...field
3874
+ }
3875
+ );
3876
+ }
3877
+ }
3878
+ ),
3879
+ showResendTimer ? /* @__PURE__ */ React13.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, (_e = props.texts) == null ? void 0 : _e.resendCodeTimer, " ", /* @__PURE__ */ React13.createElement("strong", null, remainingTime), " ", (_f = props.texts) == null ? void 0 : _f.seconds) : /* @__PURE__ */ React13.createElement("div", { className: "hawa-py-2 hawa-text-center hawa-text-xs hawa-text-muted-foreground" }, /* @__PURE__ */ React13.createElement("span", null, (_h = (_g = props.texts) == null ? void 0 : _g.didntGetCode) != null ? _h : "Didn't get the code?"), " ", /* @__PURE__ */ React13.createElement(
3880
+ "span",
3881
+ {
3882
+ className: "clickable-link",
3883
+ onClick: () => {
3884
+ startResendTimer();
3885
+ props.onResend();
3886
+ }
3887
+ },
3888
+ ((_i = props.texts) == null ? void 0 : _i.resendCode) || "Click to resend"
3889
+ )),
3890
+ /* @__PURE__ */ React13.createElement("div", { className: "hawa-mt-4 hawa-grid hawa-grid-cols-2 hawa-gap-2" }, /* @__PURE__ */ React13.createElement(
3891
+ Button,
3892
+ {
3893
+ type: "button",
3894
+ onClick: () => {
3895
+ if (props.onCancel) {
3896
+ return props.onCancel();
3897
+ } else {
3898
+ console.log("Cancel button clicked but onCancel prop is missing");
3899
+ }
3900
+ },
3901
+ variant: "outline"
3902
+ },
3903
+ ((_j = props.texts) == null ? void 0 : _j.cancel) || "Cancel"
3904
+ ), /* @__PURE__ */ React13.createElement(Button, { isLoading: props.confirmLoading }, ((_k = props.texts) == null ? void 0 : _k.confirm) || "Confirm"))
3905
+ ))
3906
+ );
3901
3907
  };
3902
3908
  export {
3903
3909
  AppLanding,
@@ -280,6 +280,7 @@ type TConfirmation = {
280
280
  onConfirm?: any;
281
281
  onResend?: any;
282
282
  onCancel?: any;
283
+ cardless?: boolean;
283
284
  codeLength?: number;
284
285
  };
285
286
  declare const CodeConfirmation: FC<TConfirmation>;
@@ -280,6 +280,7 @@ type TConfirmation = {
280
280
  onConfirm?: any;
281
281
  onResend?: any;
282
282
  onCancel?: any;
283
+ cardless?: boolean;
283
284
  codeLength?: number;
284
285
  };
285
286
  declare const CodeConfirmation: FC<TConfirmation>;