@sikka/hawa 0.27.12-next → 0.27.14-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.
@@ -66,11 +66,6 @@ module.exports = __toCommonJS(blocks_exports);
66
66
  var import_react13 = __toESM(require("react"));
67
67
  var import_react_hook_form = require("react-hook-form");
68
68
  var import_zod = require("@hookform/resolvers/zod");
69
- var import_libphonenumber_js = require("libphonenumber-js");
70
- var z = __toESM(require("zod"));
71
-
72
- // elements/alert/Alert.tsx
73
- var import_react2 = __toESM(require("react"));
74
69
 
75
70
  // util/index.ts
76
71
  var import_clsx = require("clsx");
@@ -79,6 +74,13 @@ function cn(...inputs) {
79
74
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
80
75
  }
81
76
 
77
+ // blocks/auth/LoginForm.tsx
78
+ var import_libphonenumber_js = require("libphonenumber-js");
79
+ var z = __toESM(require("zod"));
80
+
81
+ // elements/alert/Alert.tsx
82
+ var import_react2 = __toESM(require("react"));
83
+
82
84
  // elements/button/Button.tsx
83
85
  var React2 = __toESM(require("react"));
84
86
  var import_class_variance_authority = require("class-variance-authority");
@@ -3239,7 +3241,7 @@ var AuthButtons = (props) => {
3239
3241
 
3240
3242
  // blocks/auth/LoginForm.tsx
3241
3243
  var LoginForm = ({
3242
- loginType,
3244
+ loginType = "email",
3243
3245
  texts,
3244
3246
  passwordLength = 8,
3245
3247
  ...props
@@ -3258,33 +3260,45 @@ var LoginForm = ({
3258
3260
  let formSchema;
3259
3261
  if (loginType === "email") {
3260
3262
  formSchema = z.object({
3261
- email: z.string({ required_error: (_a = texts == null ? void 0 : texts.email) == null ? void 0 : _a.required }).min(1, { message: (_b = texts == null ? void 0 : texts.email) == null ? void 0 : _b.required }).email({ message: (_c = texts == null ? void 0 : texts.email) == null ? void 0 : _c.invalid }),
3262
- password: z.string({ required_error: (_d = texts == null ? void 0 : texts.password) == null ? void 0 : _d.required }).min(1, { message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required }).min(passwordLength, { message: (_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort })
3263
+ email: z.string({ required_error: ((_a = texts == null ? void 0 : texts.email) == null ? void 0 : _a.required) || "Email Required" }).min(1, { message: ((_b = texts == null ? void 0 : texts.email) == null ? void 0 : _b.required) || "Email Required" }).email({ message: ((_c = texts == null ? void 0 : texts.email) == null ? void 0 : _c.invalid) || "Email Invalid" }),
3264
+ password: z.string({
3265
+ required_error: ((_d = texts == null ? void 0 : texts.password) == null ? void 0 : _d.required) || "Password Required"
3266
+ }).min(1, { message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Password Required" }).min(passwordLength, {
3267
+ message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort) || "Password too short"
3268
+ })
3263
3269
  });
3264
3270
  } else if (loginType === "username") {
3265
3271
  formSchema = z.object({
3266
- username: z.string({ required_error: (_g = texts == null ? void 0 : texts.username) == null ? void 0 : _g.required }).min(2, { message: (_h = texts == null ? void 0 : texts.username) == null ? void 0 : _h.tooShort }).refine(
3272
+ username: z.string({
3273
+ required_error: ((_g = texts == null ? void 0 : texts.username) == null ? void 0 : _g.required) || "Username Required"
3274
+ }).min(2, { message: ((_h = texts == null ? void 0 : texts.username) == null ? void 0 : _h.tooShort) || "Username too short" }).refine(
3267
3275
  (value) => {
3268
3276
  const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
3269
3277
  return isValid;
3270
3278
  },
3271
- { message: (_i = texts == null ? void 0 : texts.username) == null ? void 0 : _i.invalid }
3279
+ { message: ((_i = texts == null ? void 0 : texts.username) == null ? void 0 : _i.invalid) || "Username Invalid" }
3272
3280
  ),
3273
- password: z.string({ required_error: (_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required }).min(1, { message: (_k = texts == null ? void 0 : texts.password) == null ? void 0 : _k.required }).min(passwordLength, { message: (_l = texts == null ? void 0 : texts.password) == null ? void 0 : _l.tooShort })
3281
+ password: z.string({
3282
+ required_error: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Password Required"
3283
+ }).min(1, { message: ((_k = texts == null ? void 0 : texts.password) == null ? void 0 : _k.required) || "Password Required" }).min(passwordLength, {
3284
+ message: ((_l = texts == null ? void 0 : texts.password) == null ? void 0 : _l.tooShort) || "Password too short"
3285
+ })
3274
3286
  });
3275
3287
  } else if (loginType === "phone") {
3276
3288
  formSchema = z.object({
3277
- phone: z.string({ required_error: (_m = texts == null ? void 0 : texts.phone) == null ? void 0 : _m.required }).refine(
3289
+ phone: z.string({
3290
+ required_error: ((_m = texts == null ? void 0 : texts.phone) == null ? void 0 : _m.required) || "Phone Number Required"
3291
+ }).refine(
3278
3292
  (value) => {
3279
3293
  let phoneNumber = (0, import_libphonenumber_js.parsePhoneNumber)(value);
3280
3294
  return phoneNumber.isValid();
3281
3295
  },
3282
- { message: (_n = texts == null ? void 0 : texts.phone) == null ? void 0 : _n.invalid }
3296
+ { message: ((_n = texts == null ? void 0 : texts.phone) == null ? void 0 : _n.invalid) || "Phone Number Invalid" }
3283
3297
  )
3284
3298
  });
3285
3299
  } else if (loginType === "link") {
3286
3300
  formSchema = z.object({
3287
- email: z.string({ required_error: (_o = texts == null ? void 0 : texts.email) == null ? void 0 : _o.required }).min(1, { message: (_p = texts == null ? void 0 : texts.email) == null ? void 0 : _p.required }).email({ message: (_q = texts == null ? void 0 : texts.email) == null ? void 0 : _q.invalid })
3301
+ email: z.string({ required_error: ((_o = texts == null ? void 0 : texts.email) == null ? void 0 : _o.required) || "Email Required" }).min(1, { message: ((_p = texts == null ? void 0 : texts.email) == null ? void 0 : _p.required) || "Email Required" }).email({ message: ((_q = texts == null ? void 0 : texts.email) == null ? void 0 : _q.invalid) || "Email Invalid" })
3288
3302
  });
3289
3303
  } else {
3290
3304
  formSchema = z.object({});
@@ -3311,7 +3325,7 @@ var LoginForm = ({
3311
3325
  dir: "ltr",
3312
3326
  width: "full",
3313
3327
  autoComplete: "email",
3314
- label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
3328
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
3315
3329
  helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
3316
3330
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "contact@sikka.io",
3317
3331
  ...field
@@ -3348,7 +3362,7 @@ var LoginForm = ({
3348
3362
  );
3349
3363
  }
3350
3364
  }
3351
- ), !props.withoutResetPassword && /* @__PURE__ */ import_react13.default.createElement(
3365
+ ), props.withResetPassword && /* @__PURE__ */ import_react13.default.createElement(
3352
3366
  "div",
3353
3367
  {
3354
3368
  onClick: props.onForgotPassword,
@@ -3390,7 +3404,7 @@ var LoginForm = ({
3390
3404
  width: "full",
3391
3405
  autoComplete: "current-password",
3392
3406
  type: passwordVisible ? "text" : "password",
3393
- label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
3407
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
3394
3408
  endIcon: /* @__PURE__ */ import_react13.default.createElement(
3395
3409
  "div",
3396
3410
  {
@@ -3406,7 +3420,7 @@ var LoginForm = ({
3406
3420
  );
3407
3421
  }
3408
3422
  }
3409
- ), !props.withoutResetPassword && /* @__PURE__ */ import_react13.default.createElement(
3423
+ ), props.withResetPassword && /* @__PURE__ */ import_react13.default.createElement(
3410
3424
  "div",
3411
3425
  {
3412
3426
  onClick: props.onForgotPassword,
@@ -3425,7 +3439,7 @@ var LoginForm = ({
3425
3439
  return /* @__PURE__ */ import_react13.default.createElement(
3426
3440
  PhoneInput,
3427
3441
  {
3428
- label: (_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label,
3442
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
3429
3443
  helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
3430
3444
  preferredCountry: { label: "+966" },
3431
3445
  handleChange: (e) => field.onChange((0, import_libphonenumber_js.parsePhoneNumber)(e).number)
@@ -3681,6 +3695,8 @@ var StopPropagationWrapper = (props) => {
3681
3695
  var RegisterForm = ({
3682
3696
  texts,
3683
3697
  registerFields = ["email"],
3698
+ showTermsOption = false,
3699
+ showNewsletterOption = false,
3684
3700
  ...props
3685
3701
  }) => {
3686
3702
  var _a, _b, _c, _d, _e, _f;
@@ -3703,26 +3719,38 @@ var RegisterForm = ({
3703
3719
  fieldSchemas["fullName"] = z2.string().optional();
3704
3720
  break;
3705
3721
  case "email":
3706
- fieldSchemas["email"] = z2.string({ required_error: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.required }).email({ message: (_b2 = texts == null ? void 0 : texts.email) == null ? void 0 : _b2.invalid }).min(1, { message: (_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.required });
3722
+ fieldSchemas["email"] = z2.string({
3723
+ required_error: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.required) || "Email is required"
3724
+ }).email({ message: ((_b2 = texts == null ? void 0 : texts.email) == null ? void 0 : _b2.invalid) || "Invalid email" }).min(1, { message: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.required) || "Email is required" });
3707
3725
  break;
3708
3726
  case "username":
3709
- fieldSchemas["username"] = z2.string({ required_error: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.required }).min(1, { message: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.required }).refine(
3727
+ fieldSchemas["username"] = z2.string({
3728
+ required_error: ((_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.required) || "Username is required"
3729
+ }).min(1, {
3730
+ message: ((_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.required) || "Username is required"
3731
+ }).refine(
3710
3732
  (value) => {
3711
3733
  const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
3712
3734
  return isValid;
3713
3735
  },
3714
- { message: (_f2 = texts == null ? void 0 : texts.username) == null ? void 0 : _f2.invalid }
3736
+ { message: ((_f2 = texts == null ? void 0 : texts.username) == null ? void 0 : _f2.invalid) || "Invalid username" }
3715
3737
  );
3716
3738
  break;
3717
3739
  }
3718
3740
  });
3719
3741
  const formSchema = z2.object({
3720
3742
  ...fieldSchemas,
3721
- password: z2.string({ required_error: (_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required }).min(5, { message: (_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort }).refine((value) => value !== "", {
3722
- message: (_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required
3743
+ password: z2.string({
3744
+ required_error: ((_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required) || "Password is required"
3745
+ }).min(5, {
3746
+ message: ((_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort) || "Password is too short"
3747
+ }).refine((value) => value !== "", {
3748
+ message: ((_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required) || "Password is required"
3723
3749
  }),
3724
- confirm_password: z2.string({ required_error: (_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required }).refine((value) => value !== "", {
3725
- message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required
3750
+ confirm_password: z2.string({
3751
+ required_error: ((_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required) || "Confirm password required"
3752
+ }).refine((value) => value !== "", {
3753
+ message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Confirm password is required"
3726
3754
  }),
3727
3755
  refCode: z2.string().optional(),
3728
3756
  reference: z2.string().optional(),
@@ -3771,7 +3799,7 @@ var RegisterForm = ({
3771
3799
  Input,
3772
3800
  {
3773
3801
  width: "full",
3774
- label: (_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label,
3802
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
3775
3803
  placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
3776
3804
  helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
3777
3805
  ...field
@@ -3799,7 +3827,7 @@ var RegisterForm = ({
3799
3827
  },
3800
3828
  width: "full",
3801
3829
  autoComplete: "email",
3802
- label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
3830
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
3803
3831
  helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
3804
3832
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
3805
3833
  ...field
@@ -3823,7 +3851,7 @@ var RegisterForm = ({
3823
3851
  {
3824
3852
  width: "full",
3825
3853
  autoComplete: "username",
3826
- label: (_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label,
3854
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
3827
3855
  labelProps: {
3828
3856
  ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
3829
3857
  },
@@ -3859,7 +3887,7 @@ var RegisterForm = ({
3859
3887
  " "
3860
3888
  ),
3861
3889
  autoComplete: "new-password",
3862
- label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
3890
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
3863
3891
  placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
3864
3892
  helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
3865
3893
  ...field
@@ -3881,7 +3909,7 @@ var RegisterForm = ({
3881
3909
  width: "full",
3882
3910
  type: "password",
3883
3911
  autoComplete: "new-password",
3884
- label: (_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label,
3912
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
3885
3913
  placeholder: (_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder,
3886
3914
  helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
3887
3915
  ...field
@@ -3936,7 +3964,7 @@ var RegisterForm = ({
3936
3964
  }
3937
3965
  }
3938
3966
  ),
3939
- /* @__PURE__ */ import_react15.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3" }, props.showTermsOption && /* @__PURE__ */ import_react15.default.createElement(
3967
+ /* @__PURE__ */ import_react15.default.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3" }, showTermsOption && /* @__PURE__ */ import_react15.default.createElement(
3940
3968
  import_react_hook_form2.Controller,
3941
3969
  {
3942
3970
  control,
@@ -3949,19 +3977,19 @@ var RegisterForm = ({
3949
3977
  id: "terms_accepted",
3950
3978
  helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
3951
3979
  onCheckedChange: (e) => field.onChange(e),
3952
- label: /* @__PURE__ */ import_react15.default.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5" }, /* @__PURE__ */ import_react15.default.createElement("span", null, texts == null ? void 0 : texts.iAcceptText), " ", /* @__PURE__ */ import_react15.default.createElement(StopPropagationWrapper, null, /* @__PURE__ */ import_react15.default.createElement(
3980
+ label: /* @__PURE__ */ import_react15.default.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5" }, /* @__PURE__ */ import_react15.default.createElement("span", null, (texts == null ? void 0 : texts.iAcceptText) || "I accept the "), " ", /* @__PURE__ */ import_react15.default.createElement(StopPropagationWrapper, null, /* @__PURE__ */ import_react15.default.createElement(
3953
3981
  "a",
3954
3982
  {
3955
3983
  onClick: props.onRouteToTOS,
3956
3984
  className: "clickable-link"
3957
3985
  },
3958
- texts == null ? void 0 : texts.termsText
3986
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
3959
3987
  )))
3960
3988
  }
3961
3989
  );
3962
3990
  }
3963
3991
  }
3964
- ), props.showNewsletterOption && /* @__PURE__ */ import_react15.default.createElement(
3992
+ ), showNewsletterOption && /* @__PURE__ */ import_react15.default.createElement(
3965
3993
  import_react_hook_form2.Controller,
3966
3994
  {
3967
3995
  control,
@@ -3987,7 +4015,7 @@ var RegisterForm = ({
3987
4015
  (texts == null ? void 0 : texts.registerText) || "Register"
3988
4016
  ),
3989
4017
  props.additionalButtons
3990
- )), /* @__PURE__ */ import_react15.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_react15.default.createElement("span", null, texts == null ? void 0 : texts.existingUserText), /* @__PURE__ */ import_react15.default.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ import_react15.default.createElement(
4018
+ )), /* @__PURE__ */ import_react15.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_react15.default.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ import_react15.default.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ import_react15.default.createElement(
3991
4019
  CardFooter,
3992
4020
  {
3993
4021
  className: cn(
@@ -131,7 +131,7 @@ var AuthButtons = (props) => {
131
131
 
132
132
  // blocks/auth/LoginForm.tsx
133
133
  var LoginForm = ({
134
- loginType,
134
+ loginType = "email",
135
135
  texts,
136
136
  passwordLength = 8,
137
137
  ...props
@@ -150,33 +150,45 @@ var LoginForm = ({
150
150
  let formSchema;
151
151
  if (loginType === "email") {
152
152
  formSchema = z.object({
153
- email: z.string({ required_error: (_a = texts == null ? void 0 : texts.email) == null ? void 0 : _a.required }).min(1, { message: (_b = texts == null ? void 0 : texts.email) == null ? void 0 : _b.required }).email({ message: (_c = texts == null ? void 0 : texts.email) == null ? void 0 : _c.invalid }),
154
- password: z.string({ required_error: (_d = texts == null ? void 0 : texts.password) == null ? void 0 : _d.required }).min(1, { message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required }).min(passwordLength, { message: (_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort })
153
+ email: z.string({ required_error: ((_a = texts == null ? void 0 : texts.email) == null ? void 0 : _a.required) || "Email Required" }).min(1, { message: ((_b = texts == null ? void 0 : texts.email) == null ? void 0 : _b.required) || "Email Required" }).email({ message: ((_c = texts == null ? void 0 : texts.email) == null ? void 0 : _c.invalid) || "Email Invalid" }),
154
+ password: z.string({
155
+ required_error: ((_d = texts == null ? void 0 : texts.password) == null ? void 0 : _d.required) || "Password Required"
156
+ }).min(1, { message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Password Required" }).min(passwordLength, {
157
+ message: ((_f = texts == null ? void 0 : texts.password) == null ? void 0 : _f.tooShort) || "Password too short"
158
+ })
155
159
  });
156
160
  } else if (loginType === "username") {
157
161
  formSchema = z.object({
158
- username: z.string({ required_error: (_g = texts == null ? void 0 : texts.username) == null ? void 0 : _g.required }).min(2, { message: (_h = texts == null ? void 0 : texts.username) == null ? void 0 : _h.tooShort }).refine(
162
+ username: z.string({
163
+ required_error: ((_g = texts == null ? void 0 : texts.username) == null ? void 0 : _g.required) || "Username Required"
164
+ }).min(2, { message: ((_h = texts == null ? void 0 : texts.username) == null ? void 0 : _h.tooShort) || "Username too short" }).refine(
159
165
  (value) => {
160
166
  const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
161
167
  return isValid;
162
168
  },
163
- { message: (_i = texts == null ? void 0 : texts.username) == null ? void 0 : _i.invalid }
169
+ { message: ((_i = texts == null ? void 0 : texts.username) == null ? void 0 : _i.invalid) || "Username Invalid" }
164
170
  ),
165
- password: z.string({ required_error: (_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required }).min(1, { message: (_k = texts == null ? void 0 : texts.password) == null ? void 0 : _k.required }).min(passwordLength, { message: (_l = texts == null ? void 0 : texts.password) == null ? void 0 : _l.tooShort })
171
+ password: z.string({
172
+ required_error: ((_j = texts == null ? void 0 : texts.password) == null ? void 0 : _j.required) || "Password Required"
173
+ }).min(1, { message: ((_k = texts == null ? void 0 : texts.password) == null ? void 0 : _k.required) || "Password Required" }).min(passwordLength, {
174
+ message: ((_l = texts == null ? void 0 : texts.password) == null ? void 0 : _l.tooShort) || "Password too short"
175
+ })
166
176
  });
167
177
  } else if (loginType === "phone") {
168
178
  formSchema = z.object({
169
- phone: z.string({ required_error: (_m = texts == null ? void 0 : texts.phone) == null ? void 0 : _m.required }).refine(
179
+ phone: z.string({
180
+ required_error: ((_m = texts == null ? void 0 : texts.phone) == null ? void 0 : _m.required) || "Phone Number Required"
181
+ }).refine(
170
182
  (value) => {
171
183
  let phoneNumber = parsePhoneNumber(value);
172
184
  return phoneNumber.isValid();
173
185
  },
174
- { message: (_n = texts == null ? void 0 : texts.phone) == null ? void 0 : _n.invalid }
186
+ { message: ((_n = texts == null ? void 0 : texts.phone) == null ? void 0 : _n.invalid) || "Phone Number Invalid" }
175
187
  )
176
188
  });
177
189
  } else if (loginType === "link") {
178
190
  formSchema = z.object({
179
- email: z.string({ required_error: (_o = texts == null ? void 0 : texts.email) == null ? void 0 : _o.required }).min(1, { message: (_p = texts == null ? void 0 : texts.email) == null ? void 0 : _p.required }).email({ message: (_q = texts == null ? void 0 : texts.email) == null ? void 0 : _q.invalid })
191
+ email: z.string({ required_error: ((_o = texts == null ? void 0 : texts.email) == null ? void 0 : _o.required) || "Email Required" }).min(1, { message: ((_p = texts == null ? void 0 : texts.email) == null ? void 0 : _p.required) || "Email Required" }).email({ message: ((_q = texts == null ? void 0 : texts.email) == null ? void 0 : _q.invalid) || "Email Invalid" })
180
192
  });
181
193
  } else {
182
194
  formSchema = z.object({});
@@ -203,7 +215,7 @@ var LoginForm = ({
203
215
  dir: "ltr",
204
216
  width: "full",
205
217
  autoComplete: "email",
206
- label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
218
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
207
219
  helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
208
220
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "contact@sikka.io",
209
221
  ...field
@@ -240,7 +252,7 @@ var LoginForm = ({
240
252
  );
241
253
  }
242
254
  }
243
- ), !props.withoutResetPassword && /* @__PURE__ */ React2.createElement(
255
+ ), props.withResetPassword && /* @__PURE__ */ React2.createElement(
244
256
  "div",
245
257
  {
246
258
  onClick: props.onForgotPassword,
@@ -282,7 +294,7 @@ var LoginForm = ({
282
294
  width: "full",
283
295
  autoComplete: "current-password",
284
296
  type: passwordVisible ? "text" : "password",
285
- label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
297
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
286
298
  endIcon: /* @__PURE__ */ React2.createElement(
287
299
  "div",
288
300
  {
@@ -298,7 +310,7 @@ var LoginForm = ({
298
310
  );
299
311
  }
300
312
  }
301
- ), !props.withoutResetPassword && /* @__PURE__ */ React2.createElement(
313
+ ), props.withResetPassword && /* @__PURE__ */ React2.createElement(
302
314
  "div",
303
315
  {
304
316
  onClick: props.onForgotPassword,
@@ -317,7 +329,7 @@ var LoginForm = ({
317
329
  return /* @__PURE__ */ React2.createElement(
318
330
  PhoneInput,
319
331
  {
320
- label: (_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label,
332
+ label: ((_a2 = texts == null ? void 0 : texts.phone) == null ? void 0 : _a2.label) || "Phone Number",
321
333
  helperText: (_b2 = formState.errors.phone) == null ? void 0 : _b2.message,
322
334
  preferredCountry: { label: "+966" },
323
335
  handleChange: (e) => field.onChange(parsePhoneNumber(e).number)
@@ -426,6 +438,8 @@ import * as z2 from "zod";
426
438
  var RegisterForm = ({
427
439
  texts,
428
440
  registerFields = ["email"],
441
+ showTermsOption = false,
442
+ showNewsletterOption = false,
429
443
  ...props
430
444
  }) => {
431
445
  var _a, _b, _c, _d, _e, _f;
@@ -448,26 +462,38 @@ var RegisterForm = ({
448
462
  fieldSchemas["fullName"] = z2.string().optional();
449
463
  break;
450
464
  case "email":
451
- fieldSchemas["email"] = z2.string({ required_error: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.required }).email({ message: (_b2 = texts == null ? void 0 : texts.email) == null ? void 0 : _b2.invalid }).min(1, { message: (_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.required });
465
+ fieldSchemas["email"] = z2.string({
466
+ required_error: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.required) || "Email is required"
467
+ }).email({ message: ((_b2 = texts == null ? void 0 : texts.email) == null ? void 0 : _b2.invalid) || "Invalid email" }).min(1, { message: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.required) || "Email is required" });
452
468
  break;
453
469
  case "username":
454
- fieldSchemas["username"] = z2.string({ required_error: (_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.required }).min(1, { message: (_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.required }).refine(
470
+ fieldSchemas["username"] = z2.string({
471
+ required_error: ((_d2 = texts == null ? void 0 : texts.username) == null ? void 0 : _d2.required) || "Username is required"
472
+ }).min(1, {
473
+ message: ((_e2 = texts == null ? void 0 : texts.username) == null ? void 0 : _e2.required) || "Username is required"
474
+ }).refine(
455
475
  (value) => {
456
476
  const isValid = /^[a-zA-Z][a-zA-Z0-9_-]{2,14}$/.test(value);
457
477
  return isValid;
458
478
  },
459
- { message: (_f2 = texts == null ? void 0 : texts.username) == null ? void 0 : _f2.invalid }
479
+ { message: ((_f2 = texts == null ? void 0 : texts.username) == null ? void 0 : _f2.invalid) || "Invalid username" }
460
480
  );
461
481
  break;
462
482
  }
463
483
  });
464
484
  const formSchema = z2.object({
465
485
  ...fieldSchemas,
466
- password: z2.string({ required_error: (_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required }).min(5, { message: (_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort }).refine((value) => value !== "", {
467
- message: (_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required
486
+ password: z2.string({
487
+ required_error: ((_a = texts == null ? void 0 : texts.password) == null ? void 0 : _a.required) || "Password is required"
488
+ }).min(5, {
489
+ message: ((_b = texts == null ? void 0 : texts.password) == null ? void 0 : _b.tooShort) || "Password is too short"
490
+ }).refine((value) => value !== "", {
491
+ message: ((_c = texts == null ? void 0 : texts.password) == null ? void 0 : _c.required) || "Password is required"
468
492
  }),
469
- confirm_password: z2.string({ required_error: (_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required }).refine((value) => value !== "", {
470
- message: (_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required
493
+ confirm_password: z2.string({
494
+ required_error: ((_d = texts == null ? void 0 : texts.confirm) == null ? void 0 : _d.required) || "Confirm password required"
495
+ }).refine((value) => value !== "", {
496
+ message: ((_e = texts == null ? void 0 : texts.password) == null ? void 0 : _e.required) || "Confirm password is required"
471
497
  }),
472
498
  refCode: z2.string().optional(),
473
499
  reference: z2.string().optional(),
@@ -516,7 +542,7 @@ var RegisterForm = ({
516
542
  Input,
517
543
  {
518
544
  width: "full",
519
- label: (_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label,
545
+ label: ((_a2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _a2.label) || "Full Name",
520
546
  placeholder: (_b2 = texts == null ? void 0 : texts.fullName) == null ? void 0 : _b2.placeholder,
521
547
  helperText: (_c2 = formState.errors.fullName) == null ? void 0 : _c2.message,
522
548
  ...field
@@ -544,7 +570,7 @@ var RegisterForm = ({
544
570
  },
545
571
  width: "full",
546
572
  autoComplete: "email",
547
- label: (_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label,
573
+ label: ((_a2 = texts == null ? void 0 : texts.email) == null ? void 0 : _a2.label) || "Email",
548
574
  helperText: (_b2 = formState.errors.email) == null ? void 0 : _b2.message,
549
575
  placeholder: ((_c2 = texts == null ? void 0 : texts.email) == null ? void 0 : _c2.placeholder) || "Enter your email",
550
576
  ...field
@@ -568,7 +594,7 @@ var RegisterForm = ({
568
594
  {
569
595
  width: "full",
570
596
  autoComplete: "username",
571
- label: (_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label,
597
+ label: ((_a2 = texts == null ? void 0 : texts.username) == null ? void 0 : _a2.label) || "Username",
572
598
  labelProps: {
573
599
  ...(_b2 = props.usernameOptions) == null ? void 0 : _b2.label
574
600
  },
@@ -604,7 +630,7 @@ var RegisterForm = ({
604
630
  " "
605
631
  ),
606
632
  autoComplete: "new-password",
607
- label: (_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label,
633
+ label: ((_a2 = texts == null ? void 0 : texts.password) == null ? void 0 : _a2.label) || "Password",
608
634
  placeholder: (_b2 = texts == null ? void 0 : texts.password) == null ? void 0 : _b2.placeholder,
609
635
  helperText: (_c2 = formState.errors.password) == null ? void 0 : _c2.message,
610
636
  ...field
@@ -626,7 +652,7 @@ var RegisterForm = ({
626
652
  width: "full",
627
653
  type: "password",
628
654
  autoComplete: "new-password",
629
- label: (_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label,
655
+ label: ((_a2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _a2.label) || "Confirm Password",
630
656
  placeholder: (_b2 = texts == null ? void 0 : texts.confirm) == null ? void 0 : _b2.placeholder,
631
657
  helperText: (_c2 = formState.errors.confirm_password) == null ? void 0 : _c2.message,
632
658
  ...field
@@ -681,7 +707,7 @@ var RegisterForm = ({
681
707
  }
682
708
  }
683
709
  ),
684
- /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3" }, props.showTermsOption && /* @__PURE__ */ React3.createElement(
710
+ /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-col hawa-gap-3" }, showTermsOption && /* @__PURE__ */ React3.createElement(
685
711
  Controller2,
686
712
  {
687
713
  control,
@@ -694,19 +720,19 @@ var RegisterForm = ({
694
720
  id: "terms_accepted",
695
721
  helperText: (_b2 = (_a2 = formState.errors.terms_accepted) == null ? void 0 : _a2.message) == null ? void 0 : _b2.toString(),
696
722
  onCheckedChange: (e) => field.onChange(e),
697
- label: /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5" }, /* @__PURE__ */ React3.createElement("span", null, texts == null ? void 0 : texts.iAcceptText), " ", /* @__PURE__ */ React3.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React3.createElement(
723
+ label: /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-gap-0.5" }, /* @__PURE__ */ React3.createElement("span", null, (texts == null ? void 0 : texts.iAcceptText) || "I accept the "), " ", /* @__PURE__ */ React3.createElement(StopPropagationWrapper, null, /* @__PURE__ */ React3.createElement(
698
724
  "a",
699
725
  {
700
726
  onClick: props.onRouteToTOS,
701
727
  className: "clickable-link"
702
728
  },
703
- texts == null ? void 0 : texts.termsText
729
+ (texts == null ? void 0 : texts.termsText) || "Terms of Service"
704
730
  )))
705
731
  }
706
732
  );
707
733
  }
708
734
  }
709
- ), props.showNewsletterOption && /* @__PURE__ */ React3.createElement(
735
+ ), showNewsletterOption && /* @__PURE__ */ React3.createElement(
710
736
  Controller2,
711
737
  {
712
738
  control,
@@ -732,7 +758,7 @@ var RegisterForm = ({
732
758
  (texts == null ? void 0 : texts.registerText) || "Register"
733
759
  ),
734
760
  props.additionalButtons
735
- )), /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-1 hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-white" }, /* @__PURE__ */ React3.createElement("span", null, texts == null ? void 0 : texts.existingUserText), /* @__PURE__ */ React3.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React3.createElement(
761
+ )), /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-center hawa-gap-1 hawa-p-3 hawa-text-center hawa-text-sm hawa-font-normal dark:hawa-text-white" }, /* @__PURE__ */ React3.createElement("span", null, (texts == null ? void 0 : texts.existingUserText) || "Already have an account?"), /* @__PURE__ */ React3.createElement("span", { onClick: props.onRouteToLogin, className: "clickable-link" }, (texts == null ? void 0 : texts.loginText) || "Login")))), props.viaGithub || props.viaGoogle || props.viaTwitter ? /* @__PURE__ */ React3.createElement(
736
762
  CardFooter,
737
763
  {
738
764
  className: cn(
package/dist/index.d.mts CHANGED
@@ -1426,7 +1426,7 @@ type LoginFormTypes = {
1426
1426
  /** Login identifier type user will use to log in. */
1427
1427
  loginType?: "email" | "username" | "phone" | "link";
1428
1428
  /** If true, the reset password option is hidden. */
1429
- withoutResetPassword?: boolean;
1429
+ withResetPassword?: boolean;
1430
1430
  /** If true, the register option is hidden. */
1431
1431
  allowRegister?: boolean;
1432
1432
  /** If true, a loading spinner is displayed within the main form submit button. */
@@ -1444,7 +1444,7 @@ type LoginFormTypes = {
1444
1444
  /** If true, Twitter login option is displayed. */
1445
1445
  viaTwitter?: boolean;
1446
1446
  /** Function to handle form submission. */
1447
- onLogin?: (e: any) => void;
1447
+ onLogin: (e: any) => void;
1448
1448
  /** Function to route user to the register page. */
1449
1449
  onRouteToRegister?: () => void;
1450
1450
  /** Function to handle forgotten password case. */
package/dist/index.d.ts CHANGED
@@ -1426,7 +1426,7 @@ type LoginFormTypes = {
1426
1426
  /** Login identifier type user will use to log in. */
1427
1427
  loginType?: "email" | "username" | "phone" | "link";
1428
1428
  /** If true, the reset password option is hidden. */
1429
- withoutResetPassword?: boolean;
1429
+ withResetPassword?: boolean;
1430
1430
  /** If true, the register option is hidden. */
1431
1431
  allowRegister?: boolean;
1432
1432
  /** If true, a loading spinner is displayed within the main form submit button. */
@@ -1444,7 +1444,7 @@ type LoginFormTypes = {
1444
1444
  /** If true, Twitter login option is displayed. */
1445
1445
  viaTwitter?: boolean;
1446
1446
  /** Function to handle form submission. */
1447
- onLogin?: (e: any) => void;
1447
+ onLogin: (e: any) => void;
1448
1448
  /** Function to route user to the register page. */
1449
1449
  onRouteToRegister?: () => void;
1450
1450
  /** Function to handle forgotten password case. */