@sikka/hawa 0.20.7-next → 0.20.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.
package/dist/index.js CHANGED
@@ -11107,17 +11107,31 @@ var ContactForm = ({
11107
11107
  }) => {
11108
11108
  var _a, _b, _c;
11109
11109
  const contactFormSchema = z8.object({
11110
- name: z8.string({ required_error: texts == null ? void 0 : texts.name.required }).min(1, texts == null ? void 0 : texts.name.required),
11111
- email: z8.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 }),
11112
- message: z8.string({ required_error: texts == null ? void 0 : texts.message.required }).min(10, texts == null ? void 0 : texts.message.invalid)
11110
+ name: z8.string({ required_error: texts == null ? void 0 : texts.name.required }).min(1, texts == null ? void 0 : texts.name.required).default(""),
11111
+ email: z8.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 }).default(""),
11112
+ message: z8.string({ required_error: texts == null ? void 0 : texts.message.required }).min(10, texts == null ? void 0 : texts.message.invalid).default("")
11113
11113
  });
11114
11114
  const {
11115
11115
  control,
11116
11116
  handleSubmit,
11117
- formState: { errors }
11117
+ formState: { errors },
11118
+ reset
11118
11119
  } = (0, import_react_hook_form9.useForm)({
11119
- resolver: (0, import_zod8.zodResolver)(contactFormSchema)
11120
+ resolver: (0, import_zod8.zodResolver)(contactFormSchema),
11121
+ defaultValues: {
11122
+ name: "",
11123
+ email: "",
11124
+ message: ""
11125
+ }
11120
11126
  });
11127
+ const handleFormSubmit = (data) => {
11128
+ if (onSubmit) {
11129
+ onSubmit(data);
11130
+ reset();
11131
+ } else {
11132
+ console.log("Form is submitted but onSubmit prop is missing");
11133
+ }
11134
+ };
11121
11135
  let sizeStyle = {
11122
11136
  sm: "hawa-max-w-sm",
11123
11137
  default: "hawa-w-full"
@@ -11135,13 +11149,7 @@ var ContactForm = ({
11135
11149
  "form",
11136
11150
  {
11137
11151
  noValidate: true,
11138
- onSubmit: handleSubmit((e) => {
11139
- if (onSubmit) {
11140
- return onSubmit(e);
11141
- } else {
11142
- console.log("Form is submitted but onSubmit prop is missing");
11143
- }
11144
- }),
11152
+ onSubmit: handleSubmit(handleFormSubmit),
11145
11153
  className: "hawa-space-y-2",
11146
11154
  id: formId,
11147
11155
  autoComplete: formAutoComplete
@@ -11169,9 +11177,8 @@ var ContactForm = ({
11169
11177
  {
11170
11178
  label: texts == null ? void 0 : texts.name.label,
11171
11179
  id: texts == null ? void 0 : texts.name.label,
11172
- placeholder: texts == null ? void 0 : texts.name.placeholder,
11173
- type: "text",
11174
11180
  ...field,
11181
+ placeholder: texts == null ? void 0 : texts.name.placeholder,
11175
11182
  helperText: (_a2 = errors.name) == null ? void 0 : _a2.message
11176
11183
  }
11177
11184
  );
@@ -11188,7 +11195,6 @@ var ContactForm = ({
11188
11195
  return /* @__PURE__ */ import_react69.default.createElement(
11189
11196
  Input,
11190
11197
  {
11191
- type: "text",
11192
11198
  label: texts == null ? void 0 : texts.email.label,
11193
11199
  id: texts == null ? void 0 : texts.email.label,
11194
11200
  ...field,
package/dist/index.mjs CHANGED
@@ -10882,17 +10882,31 @@ var ContactForm = ({
10882
10882
  }) => {
10883
10883
  var _a, _b, _c;
10884
10884
  const contactFormSchema = z8.object({
10885
- name: z8.string({ required_error: texts == null ? void 0 : texts.name.required }).min(1, texts == null ? void 0 : texts.name.required),
10886
- email: z8.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 }),
10887
- message: z8.string({ required_error: texts == null ? void 0 : texts.message.required }).min(10, texts == null ? void 0 : texts.message.invalid)
10885
+ name: z8.string({ required_error: texts == null ? void 0 : texts.name.required }).min(1, texts == null ? void 0 : texts.name.required).default(""),
10886
+ email: z8.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 }).default(""),
10887
+ message: z8.string({ required_error: texts == null ? void 0 : texts.message.required }).min(10, texts == null ? void 0 : texts.message.invalid).default("")
10888
10888
  });
10889
10889
  const {
10890
10890
  control,
10891
10891
  handleSubmit,
10892
- formState: { errors }
10892
+ formState: { errors },
10893
+ reset
10893
10894
  } = useForm9({
10894
- resolver: zodResolver8(contactFormSchema)
10895
+ resolver: zodResolver8(contactFormSchema),
10896
+ defaultValues: {
10897
+ name: "",
10898
+ email: "",
10899
+ message: ""
10900
+ }
10895
10901
  });
10902
+ const handleFormSubmit = (data) => {
10903
+ if (onSubmit) {
10904
+ onSubmit(data);
10905
+ reset();
10906
+ } else {
10907
+ console.log("Form is submitted but onSubmit prop is missing");
10908
+ }
10909
+ };
10896
10910
  let sizeStyle = {
10897
10911
  sm: "hawa-max-w-sm",
10898
10912
  default: "hawa-w-full"
@@ -10910,13 +10924,7 @@ var ContactForm = ({
10910
10924
  "form",
10911
10925
  {
10912
10926
  noValidate: true,
10913
- onSubmit: handleSubmit((e) => {
10914
- if (onSubmit) {
10915
- return onSubmit(e);
10916
- } else {
10917
- console.log("Form is submitted but onSubmit prop is missing");
10918
- }
10919
- }),
10927
+ onSubmit: handleSubmit(handleFormSubmit),
10920
10928
  className: "hawa-space-y-2",
10921
10929
  id: formId,
10922
10930
  autoComplete: formAutoComplete
@@ -10944,9 +10952,8 @@ var ContactForm = ({
10944
10952
  {
10945
10953
  label: texts == null ? void 0 : texts.name.label,
10946
10954
  id: texts == null ? void 0 : texts.name.label,
10947
- placeholder: texts == null ? void 0 : texts.name.placeholder,
10948
- type: "text",
10949
10955
  ...field,
10956
+ placeholder: texts == null ? void 0 : texts.name.placeholder,
10950
10957
  helperText: (_a2 = errors.name) == null ? void 0 : _a2.message
10951
10958
  }
10952
10959
  );
@@ -10963,7 +10970,6 @@ var ContactForm = ({
10963
10970
  return /* @__PURE__ */ React95.createElement(
10964
10971
  Input,
10965
10972
  {
10966
- type: "text",
10967
10973
  label: texts == null ? void 0 : texts.email.label,
10968
10974
  id: texts == null ? void 0 : texts.email.label,
10969
10975
  ...field,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.20.7-next",
3
+ "version": "0.20.9-next",
4
4
  "description": "Modern UI Kit made with Tailwind",
5
5
  "author": {
6
6
  "name": "Sikka Software",