@axenstudio/axen-form 0.1.1

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.
Files changed (210) hide show
  1. package/README.md +665 -0
  2. package/dist/adapters/yupAdapter.cjs +61 -0
  3. package/dist/adapters/yupAdapter.d.ts +21 -0
  4. package/dist/adapters/yupAdapter.d.ts.map +1 -0
  5. package/dist/adapters/yupAdapter.js +61 -0
  6. package/dist/adapters/zodAdapter.cjs +59 -0
  7. package/dist/adapters/zodAdapter.d.ts +22 -0
  8. package/dist/adapters/zodAdapter.d.ts.map +1 -0
  9. package/dist/adapters/zodAdapter.js +59 -0
  10. package/dist/core/dateUtils.cjs +69 -0
  11. package/dist/core/dateUtils.d.ts +28 -0
  12. package/dist/core/dateUtils.d.ts.map +1 -0
  13. package/dist/core/dateUtils.js +69 -0
  14. package/dist/core/formStore.cjs +184 -0
  15. package/dist/core/formStore.d.ts +39 -0
  16. package/dist/core/formStore.d.ts.map +1 -0
  17. package/dist/core/formStore.js +184 -0
  18. package/dist/core/numberUtils.cjs +59 -0
  19. package/dist/core/numberUtils.d.ts +26 -0
  20. package/dist/core/numberUtils.d.ts.map +1 -0
  21. package/dist/core/numberUtils.js +59 -0
  22. package/dist/core/pathUtils.cjs +44 -0
  23. package/dist/core/pathUtils.d.ts +15 -0
  24. package/dist/core/pathUtils.d.ts.map +1 -0
  25. package/dist/core/pathUtils.js +44 -0
  26. package/dist/core/payloadUtils.cjs +26 -0
  27. package/dist/core/payloadUtils.d.ts +22 -0
  28. package/dist/core/payloadUtils.d.ts.map +1 -0
  29. package/dist/core/payloadUtils.js +26 -0
  30. package/dist/core/validation.cjs +41 -0
  31. package/dist/core/validation.d.ts +7 -0
  32. package/dist/core/validation.d.ts.map +1 -0
  33. package/dist/core/validation.js +41 -0
  34. package/dist/fields/AutocompleteField/AutocompleteField.cjs +242 -0
  35. package/dist/fields/AutocompleteField/AutocompleteField.d.ts +6 -0
  36. package/dist/fields/AutocompleteField/AutocompleteField.d.ts.map +1 -0
  37. package/dist/fields/AutocompleteField/AutocompleteField.js +242 -0
  38. package/dist/fields/AutocompleteField/AutocompleteField.module.css +168 -0
  39. package/dist/fields/AutocompleteField/AutocompleteField.module.css.cjs +44 -0
  40. package/dist/fields/AutocompleteField/AutocompleteField.module.css.js +44 -0
  41. package/dist/fields/AutocompleteMultiField/AutocompleteMultiField.cjs +286 -0
  42. package/dist/fields/AutocompleteMultiField/AutocompleteMultiField.d.ts +6 -0
  43. package/dist/fields/AutocompleteMultiField/AutocompleteMultiField.d.ts.map +1 -0
  44. package/dist/fields/AutocompleteMultiField/AutocompleteMultiField.js +286 -0
  45. package/dist/fields/AutocompletePredictField/AutocompletePredictField.cjs +289 -0
  46. package/dist/fields/AutocompletePredictField/AutocompletePredictField.d.ts +10 -0
  47. package/dist/fields/AutocompletePredictField/AutocompletePredictField.d.ts.map +1 -0
  48. package/dist/fields/AutocompletePredictField/AutocompletePredictField.js +289 -0
  49. package/dist/fields/CheckboxField/CheckboxField.cjs +60 -0
  50. package/dist/fields/CheckboxField/CheckboxField.d.ts +3 -0
  51. package/dist/fields/CheckboxField/CheckboxField.d.ts.map +1 -0
  52. package/dist/fields/CheckboxField/CheckboxField.js +60 -0
  53. package/dist/fields/CheckboxField/CheckboxField.module.css +29 -0
  54. package/dist/fields/CheckboxField/CheckboxField.module.css.cjs +11 -0
  55. package/dist/fields/CheckboxField/CheckboxField.module.css.js +11 -0
  56. package/dist/fields/ColorField/ColorField.cjs +69 -0
  57. package/dist/fields/ColorField/ColorField.d.ts +3 -0
  58. package/dist/fields/ColorField/ColorField.d.ts.map +1 -0
  59. package/dist/fields/ColorField/ColorField.js +69 -0
  60. package/dist/fields/ColorField/ColorField.module.css +33 -0
  61. package/dist/fields/ColorField/ColorField.module.css.cjs +14 -0
  62. package/dist/fields/ColorField/ColorField.module.css.js +14 -0
  63. package/dist/fields/CurrencyField/CurrencyField.cjs +120 -0
  64. package/dist/fields/CurrencyField/CurrencyField.d.ts +10 -0
  65. package/dist/fields/CurrencyField/CurrencyField.d.ts.map +1 -0
  66. package/dist/fields/CurrencyField/CurrencyField.js +120 -0
  67. package/dist/fields/DateField/DateField.cjs +70 -0
  68. package/dist/fields/DateField/DateField.d.ts +7 -0
  69. package/dist/fields/DateField/DateField.d.ts.map +1 -0
  70. package/dist/fields/DateField/DateField.js +70 -0
  71. package/dist/fields/DateTimeField/DateTimeField.cjs +71 -0
  72. package/dist/fields/DateTimeField/DateTimeField.d.ts +8 -0
  73. package/dist/fields/DateTimeField/DateTimeField.d.ts.map +1 -0
  74. package/dist/fields/DateTimeField/DateTimeField.js +71 -0
  75. package/dist/fields/EmailField/EmailField.cjs +57 -0
  76. package/dist/fields/EmailField/EmailField.d.ts +3 -0
  77. package/dist/fields/EmailField/EmailField.d.ts.map +1 -0
  78. package/dist/fields/EmailField/EmailField.js +57 -0
  79. package/dist/fields/NumberField/NumberField.cjs +110 -0
  80. package/dist/fields/NumberField/NumberField.d.ts +10 -0
  81. package/dist/fields/NumberField/NumberField.d.ts.map +1 -0
  82. package/dist/fields/NumberField/NumberField.js +110 -0
  83. package/dist/fields/PasswordField/PasswordField.cjs +77 -0
  84. package/dist/fields/PasswordField/PasswordField.d.ts +3 -0
  85. package/dist/fields/PasswordField/PasswordField.d.ts.map +1 -0
  86. package/dist/fields/PasswordField/PasswordField.js +77 -0
  87. package/dist/fields/PasswordField/PasswordField.module.css +41 -0
  88. package/dist/fields/PasswordField/PasswordField.module.css.cjs +14 -0
  89. package/dist/fields/PasswordField/PasswordField.module.css.js +14 -0
  90. package/dist/fields/PhoneField/PhoneField.cjs +58 -0
  91. package/dist/fields/PhoneField/PhoneField.d.ts +3 -0
  92. package/dist/fields/PhoneField/PhoneField.d.ts.map +1 -0
  93. package/dist/fields/PhoneField/PhoneField.js +58 -0
  94. package/dist/fields/RadioField/RadioField.cjs +66 -0
  95. package/dist/fields/RadioField/RadioField.d.ts +3 -0
  96. package/dist/fields/RadioField/RadioField.d.ts.map +1 -0
  97. package/dist/fields/RadioField/RadioField.js +66 -0
  98. package/dist/fields/RadioField/RadioField.module.css +34 -0
  99. package/dist/fields/RadioField/RadioField.module.css.cjs +14 -0
  100. package/dist/fields/RadioField/RadioField.module.css.js +14 -0
  101. package/dist/fields/SelectField/SelectField.cjs +58 -0
  102. package/dist/fields/SelectField/SelectField.d.ts +3 -0
  103. package/dist/fields/SelectField/SelectField.d.ts.map +1 -0
  104. package/dist/fields/SelectField/SelectField.js +58 -0
  105. package/dist/fields/SliderField/SliderField.cjs +79 -0
  106. package/dist/fields/SliderField/SliderField.d.ts +7 -0
  107. package/dist/fields/SliderField/SliderField.d.ts.map +1 -0
  108. package/dist/fields/SliderField/SliderField.js +79 -0
  109. package/dist/fields/SliderField/SliderField.module.css +76 -0
  110. package/dist/fields/SliderField/SliderField.module.css.cjs +14 -0
  111. package/dist/fields/SliderField/SliderField.module.css.js +14 -0
  112. package/dist/fields/SwitchField/SwitchField.cjs +65 -0
  113. package/dist/fields/SwitchField/SwitchField.d.ts +3 -0
  114. package/dist/fields/SwitchField/SwitchField.d.ts.map +1 -0
  115. package/dist/fields/SwitchField/SwitchField.js +65 -0
  116. package/dist/fields/SwitchField/SwitchField.module.css +79 -0
  117. package/dist/fields/SwitchField/SwitchField.module.css.cjs +17 -0
  118. package/dist/fields/SwitchField/SwitchField.module.css.js +17 -0
  119. package/dist/fields/TextField/TextField.cjs +56 -0
  120. package/dist/fields/TextField/TextField.d.ts +3 -0
  121. package/dist/fields/TextField/TextField.d.ts.map +1 -0
  122. package/dist/fields/TextField/TextField.js +56 -0
  123. package/dist/fields/TextareaField/TextareaField.cjs +57 -0
  124. package/dist/fields/TextareaField/TextareaField.d.ts +5 -0
  125. package/dist/fields/TextareaField/TextareaField.d.ts.map +1 -0
  126. package/dist/fields/TextareaField/TextareaField.js +57 -0
  127. package/dist/fields/TimeField/TimeField.cjs +67 -0
  128. package/dist/fields/TimeField/TimeField.d.ts +6 -0
  129. package/dist/fields/TimeField/TimeField.d.ts.map +1 -0
  130. package/dist/fields/TimeField/TimeField.js +67 -0
  131. package/dist/fields/defaultComponentMap.cjs +43 -0
  132. package/dist/fields/defaultComponentMap.d.ts +7 -0
  133. package/dist/fields/defaultComponentMap.d.ts.map +1 -0
  134. package/dist/fields/defaultComponentMap.js +43 -0
  135. package/dist/fields/fieldBase.module.css +201 -0
  136. package/dist/fields/fieldBase.module.css.cjs +50 -0
  137. package/dist/fields/fieldBase.module.css.js +50 -0
  138. package/dist/fields/fieldUtils.cjs +26 -0
  139. package/dist/fields/fieldUtils.d.ts +24 -0
  140. package/dist/fields/fieldUtils.d.ts.map +1 -0
  141. package/dist/fields/fieldUtils.js +26 -0
  142. package/dist/index.cjs +99 -0
  143. package/dist/index.d.ts +42 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +99 -0
  146. package/dist/layout/Box/Box.cjs +70 -0
  147. package/dist/layout/Box/Box.d.ts +6 -0
  148. package/dist/layout/Box/Box.d.ts.map +1 -0
  149. package/dist/layout/Box/Box.js +70 -0
  150. package/dist/layout/Box/Box.module.css +3 -0
  151. package/dist/layout/Box/Box.module.css.cjs +8 -0
  152. package/dist/layout/Box/Box.module.css.js +8 -0
  153. package/dist/layout/Divider/Divider.cjs +20 -0
  154. package/dist/layout/Divider/Divider.d.ts +6 -0
  155. package/dist/layout/Divider/Divider.d.ts.map +1 -0
  156. package/dist/layout/Divider/Divider.js +20 -0
  157. package/dist/layout/Divider/Divider.module.css +25 -0
  158. package/dist/layout/Divider/Divider.module.css.cjs +14 -0
  159. package/dist/layout/Divider/Divider.module.css.js +14 -0
  160. package/dist/layout/Grid/Grid.cjs +106 -0
  161. package/dist/layout/Grid/Grid.d.ts +7 -0
  162. package/dist/layout/Grid/Grid.d.ts.map +1 -0
  163. package/dist/layout/Grid/Grid.js +106 -0
  164. package/dist/layout/Grid/Grid.module.css +43 -0
  165. package/dist/layout/Grid/Grid.module.css.cjs +23 -0
  166. package/dist/layout/Grid/Grid.module.css.js +23 -0
  167. package/dist/layout/Spacer/Spacer.cjs +30 -0
  168. package/dist/layout/Spacer/Spacer.d.ts +21 -0
  169. package/dist/layout/Spacer/Spacer.d.ts.map +1 -0
  170. package/dist/layout/Spacer/Spacer.js +30 -0
  171. package/dist/layout/Stack/Stack.cjs +52 -0
  172. package/dist/layout/Stack/Stack.d.ts +7 -0
  173. package/dist/layout/Stack/Stack.d.ts.map +1 -0
  174. package/dist/layout/Stack/Stack.js +52 -0
  175. package/dist/layout/Stack/Stack.module.css +3 -0
  176. package/dist/layout/Stack/Stack.module.css.cjs +8 -0
  177. package/dist/layout/Stack/Stack.module.css.js +8 -0
  178. package/dist/layout/index.d.ts +6 -0
  179. package/dist/layout/index.d.ts.map +1 -0
  180. package/dist/react/AxenArrayField.cjs +80 -0
  181. package/dist/react/AxenArrayField.d.ts +15 -0
  182. package/dist/react/AxenArrayField.d.ts.map +1 -0
  183. package/dist/react/AxenArrayField.js +80 -0
  184. package/dist/react/AxenField.cjs +62 -0
  185. package/dist/react/AxenField.d.ts +13 -0
  186. package/dist/react/AxenField.d.ts.map +1 -0
  187. package/dist/react/AxenField.js +62 -0
  188. package/dist/react/AxenForm.cjs +134 -0
  189. package/dist/react/AxenForm.d.ts +7 -0
  190. package/dist/react/AxenForm.d.ts.map +1 -0
  191. package/dist/react/AxenForm.js +134 -0
  192. package/dist/react/FormContext.cjs +13 -0
  193. package/dist/react/FormContext.d.ts +11 -0
  194. package/dist/react/FormContext.d.ts.map +1 -0
  195. package/dist/react/FormContext.js +13 -0
  196. package/dist/react/useAxenForm.cjs +88 -0
  197. package/dist/react/useAxenForm.d.ts +8 -0
  198. package/dist/react/useAxenForm.d.ts.map +1 -0
  199. package/dist/react/useAxenForm.js +88 -0
  200. package/dist/react/useField.cjs +41 -0
  201. package/dist/react/useField.d.ts +13 -0
  202. package/dist/react/useField.d.ts.map +1 -0
  203. package/dist/react/useField.js +41 -0
  204. package/dist/react/useFieldArray.cjs +74 -0
  205. package/dist/react/useFieldArray.d.ts +5 -0
  206. package/dist/react/useFieldArray.d.ts.map +1 -0
  207. package/dist/react/useFieldArray.js +74 -0
  208. package/dist/types.d.ts +226 -0
  209. package/dist/types.d.ts.map +1 -0
  210. package/package.json +87 -0
@@ -0,0 +1,70 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { formatDateLocale, getDefaultLocale } from "../../core/dateUtils.js";
3
+ import styles from "../fieldBase.module.css.js";
4
+ import { ariaProps, cx, labelId, helperId } from "../fieldUtils.js";
5
+ function DateField({
6
+ name,
7
+ value,
8
+ onChange,
9
+ onBlur,
10
+ error,
11
+ helperText,
12
+ label,
13
+ placeholder,
14
+ disabled,
15
+ readOnly,
16
+ required,
17
+ min,
18
+ max,
19
+ locale
20
+ }) {
21
+ const aria = ariaProps(name, { error, helperText, required, label });
22
+ const resolvedLocale = locale ?? getDefaultLocale();
23
+ const dateValue = typeof value === "string" ? value : "";
24
+ const displayText = dateValue ? formatDateLocale(dateValue, resolvedLocale) : "";
25
+ const handleChange = (e) => {
26
+ onChange(e);
27
+ };
28
+ return /* @__PURE__ */ jsxs("div", { className: styles.wrapper, children: [
29
+ label && /* @__PURE__ */ jsx(
30
+ "label",
31
+ {
32
+ id: labelId(name),
33
+ htmlFor: name,
34
+ className: cx(styles.label, required && styles.labelRequired),
35
+ children: label
36
+ }
37
+ ),
38
+ /* @__PURE__ */ jsx(
39
+ "input",
40
+ {
41
+ ...aria,
42
+ type: "date",
43
+ name,
44
+ value: dateValue,
45
+ onChange: handleChange,
46
+ onBlur,
47
+ placeholder,
48
+ disabled,
49
+ readOnly,
50
+ min,
51
+ max,
52
+ lang: resolvedLocale,
53
+ className: cx(styles.input, error && styles.inputError)
54
+ }
55
+ ),
56
+ displayText && /* @__PURE__ */ jsx("span", { className: styles.helperText, "aria-hidden": "true", children: displayText }),
57
+ helperText && /* @__PURE__ */ jsx(
58
+ "span",
59
+ {
60
+ id: helperId(name),
61
+ className: cx(styles.helperText, error && styles.helperTextError),
62
+ role: error ? "alert" : void 0,
63
+ children: helperText
64
+ }
65
+ )
66
+ ] });
67
+ }
68
+ export {
69
+ DateField
70
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const dateUtils = require("../../core/dateUtils.cjs");
5
+ const fieldBase_module = require("../fieldBase.module.css.cjs");
6
+ const fieldUtils = require("../fieldUtils.cjs");
7
+ function DateTimeField({
8
+ name,
9
+ value,
10
+ onChange,
11
+ onBlur,
12
+ error,
13
+ helperText,
14
+ label,
15
+ placeholder,
16
+ disabled,
17
+ readOnly,
18
+ required,
19
+ min,
20
+ max,
21
+ locale,
22
+ ampm
23
+ }) {
24
+ const aria = fieldUtils.ariaProps(name, { error, helperText, required, label });
25
+ const resolvedLocale = locale ?? dateUtils.getDefaultLocale();
26
+ const dtValue = typeof value === "string" ? value : "";
27
+ const displayText = dtValue ? dateUtils.formatDateTimeLocale(dtValue, resolvedLocale, ampm) : "";
28
+ const handleChange = (e) => {
29
+ onChange(e);
30
+ };
31
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldBase_module.default.wrapper, children: [
32
+ label && /* @__PURE__ */ jsxRuntime.jsx(
33
+ "label",
34
+ {
35
+ id: fieldUtils.labelId(name),
36
+ htmlFor: name,
37
+ className: fieldUtils.cx(fieldBase_module.default.label, required && fieldBase_module.default.labelRequired),
38
+ children: label
39
+ }
40
+ ),
41
+ /* @__PURE__ */ jsxRuntime.jsx(
42
+ "input",
43
+ {
44
+ ...aria,
45
+ type: "datetime-local",
46
+ name,
47
+ value: dtValue,
48
+ onChange: handleChange,
49
+ onBlur,
50
+ placeholder,
51
+ disabled,
52
+ readOnly,
53
+ min,
54
+ max,
55
+ lang: resolvedLocale,
56
+ className: fieldUtils.cx(fieldBase_module.default.input, error && fieldBase_module.default.inputError)
57
+ }
58
+ ),
59
+ displayText && /* @__PURE__ */ jsxRuntime.jsx("span", { className: fieldBase_module.default.helperText, "aria-hidden": "true", children: displayText }),
60
+ helperText && /* @__PURE__ */ jsxRuntime.jsx(
61
+ "span",
62
+ {
63
+ id: fieldUtils.helperId(name),
64
+ className: fieldUtils.cx(fieldBase_module.default.helperText, error && fieldBase_module.default.helperTextError),
65
+ role: error ? "alert" : void 0,
66
+ children: helperText
67
+ }
68
+ )
69
+ ] });
70
+ }
71
+ exports.DateTimeField = DateTimeField;
@@ -0,0 +1,8 @@
1
+ import { FieldComponentProps } from '../../types';
2
+ export declare function DateTimeField({ name, value, onChange, onBlur, error, helperText, label, placeholder, disabled, readOnly, required, min, max, locale, ampm, }: Readonly<FieldComponentProps & {
3
+ min?: string;
4
+ max?: string;
5
+ locale?: string;
6
+ ampm?: boolean;
7
+ }>): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=DateTimeField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateTimeField.d.ts","sourceRoot":"","sources":["../../../src/fields/DateTimeField/DateTimeField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIvD,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,GAAG,EACH,MAAM,EACN,IAAI,GACL,EAAE,QAAQ,CACT,mBAAmB,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CACtF,2CAyDA"}
@@ -0,0 +1,71 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { formatDateTimeLocale, getDefaultLocale } from "../../core/dateUtils.js";
3
+ import styles from "../fieldBase.module.css.js";
4
+ import { ariaProps, cx, labelId, helperId } from "../fieldUtils.js";
5
+ function DateTimeField({
6
+ name,
7
+ value,
8
+ onChange,
9
+ onBlur,
10
+ error,
11
+ helperText,
12
+ label,
13
+ placeholder,
14
+ disabled,
15
+ readOnly,
16
+ required,
17
+ min,
18
+ max,
19
+ locale,
20
+ ampm
21
+ }) {
22
+ const aria = ariaProps(name, { error, helperText, required, label });
23
+ const resolvedLocale = locale ?? getDefaultLocale();
24
+ const dtValue = typeof value === "string" ? value : "";
25
+ const displayText = dtValue ? formatDateTimeLocale(dtValue, resolvedLocale, ampm) : "";
26
+ const handleChange = (e) => {
27
+ onChange(e);
28
+ };
29
+ return /* @__PURE__ */ jsxs("div", { className: styles.wrapper, children: [
30
+ label && /* @__PURE__ */ jsx(
31
+ "label",
32
+ {
33
+ id: labelId(name),
34
+ htmlFor: name,
35
+ className: cx(styles.label, required && styles.labelRequired),
36
+ children: label
37
+ }
38
+ ),
39
+ /* @__PURE__ */ jsx(
40
+ "input",
41
+ {
42
+ ...aria,
43
+ type: "datetime-local",
44
+ name,
45
+ value: dtValue,
46
+ onChange: handleChange,
47
+ onBlur,
48
+ placeholder,
49
+ disabled,
50
+ readOnly,
51
+ min,
52
+ max,
53
+ lang: resolvedLocale,
54
+ className: cx(styles.input, error && styles.inputError)
55
+ }
56
+ ),
57
+ displayText && /* @__PURE__ */ jsx("span", { className: styles.helperText, "aria-hidden": "true", children: displayText }),
58
+ helperText && /* @__PURE__ */ jsx(
59
+ "span",
60
+ {
61
+ id: helperId(name),
62
+ className: cx(styles.helperText, error && styles.helperTextError),
63
+ role: error ? "alert" : void 0,
64
+ children: helperText
65
+ }
66
+ )
67
+ ] });
68
+ }
69
+ export {
70
+ DateTimeField
71
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const fieldBase_module = require("../fieldBase.module.css.cjs");
5
+ const fieldUtils = require("../fieldUtils.cjs");
6
+ function EmailField({
7
+ name,
8
+ value,
9
+ onChange,
10
+ onBlur,
11
+ error,
12
+ helperText,
13
+ label,
14
+ placeholder,
15
+ disabled,
16
+ readOnly,
17
+ required
18
+ }) {
19
+ const aria = fieldUtils.ariaProps(name, { error, helperText, required, label });
20
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldBase_module.default.wrapper, children: [
21
+ label && /* @__PURE__ */ jsxRuntime.jsx(
22
+ "label",
23
+ {
24
+ id: fieldUtils.labelId(name),
25
+ htmlFor: name,
26
+ className: fieldUtils.cx(fieldBase_module.default.label, required && fieldBase_module.default.labelRequired),
27
+ children: label
28
+ }
29
+ ),
30
+ /* @__PURE__ */ jsxRuntime.jsx(
31
+ "input",
32
+ {
33
+ ...aria,
34
+ type: "email",
35
+ name,
36
+ value: value ?? "",
37
+ onChange,
38
+ onBlur,
39
+ placeholder,
40
+ disabled,
41
+ readOnly,
42
+ autoComplete: "email",
43
+ className: fieldUtils.cx(fieldBase_module.default.input, error && fieldBase_module.default.inputError)
44
+ }
45
+ ),
46
+ helperText && /* @__PURE__ */ jsxRuntime.jsx(
47
+ "span",
48
+ {
49
+ id: fieldUtils.helperId(name),
50
+ className: fieldUtils.cx(fieldBase_module.default.helperText, error && fieldBase_module.default.helperTextError),
51
+ role: error ? "alert" : void 0,
52
+ children: helperText
53
+ }
54
+ )
55
+ ] });
56
+ }
57
+ exports.EmailField = EmailField;
@@ -0,0 +1,3 @@
1
+ import { FieldComponentProps } from '../../types';
2
+ export declare function EmailField({ name, value, onChange, onBlur, error, helperText, label, placeholder, disabled, readOnly, required, }: Readonly<FieldComponentProps>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=EmailField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailField.d.ts","sourceRoot":"","sources":["../../../src/fields/EmailField/EmailField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIvD,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE,QAAQ,CAAC,mBAAmB,CAAC,2CAsC/B"}
@@ -0,0 +1,57 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import styles from "../fieldBase.module.css.js";
3
+ import { ariaProps, cx, labelId, helperId } from "../fieldUtils.js";
4
+ function EmailField({
5
+ name,
6
+ value,
7
+ onChange,
8
+ onBlur,
9
+ error,
10
+ helperText,
11
+ label,
12
+ placeholder,
13
+ disabled,
14
+ readOnly,
15
+ required
16
+ }) {
17
+ const aria = ariaProps(name, { error, helperText, required, label });
18
+ return /* @__PURE__ */ jsxs("div", { className: styles.wrapper, children: [
19
+ label && /* @__PURE__ */ jsx(
20
+ "label",
21
+ {
22
+ id: labelId(name),
23
+ htmlFor: name,
24
+ className: cx(styles.label, required && styles.labelRequired),
25
+ children: label
26
+ }
27
+ ),
28
+ /* @__PURE__ */ jsx(
29
+ "input",
30
+ {
31
+ ...aria,
32
+ type: "email",
33
+ name,
34
+ value: value ?? "",
35
+ onChange,
36
+ onBlur,
37
+ placeholder,
38
+ disabled,
39
+ readOnly,
40
+ autoComplete: "email",
41
+ className: cx(styles.input, error && styles.inputError)
42
+ }
43
+ ),
44
+ helperText && /* @__PURE__ */ jsx(
45
+ "span",
46
+ {
47
+ id: helperId(name),
48
+ className: cx(styles.helperText, error && styles.helperTextError),
49
+ role: error ? "alert" : void 0,
50
+ children: helperText
51
+ }
52
+ )
53
+ ] });
54
+ }
55
+ export {
56
+ EmailField
57
+ };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const numberUtils = require("../../core/numberUtils.cjs");
6
+ const fieldBase_module = require("../fieldBase.module.css.cjs");
7
+ const fieldUtils = require("../fieldUtils.cjs");
8
+ function NumberField({
9
+ name,
10
+ value,
11
+ onChange: _onChange,
12
+ onBlur,
13
+ error,
14
+ helperText,
15
+ label,
16
+ placeholder,
17
+ disabled,
18
+ readOnly,
19
+ required,
20
+ min,
21
+ max,
22
+ step,
23
+ prefix,
24
+ suffix,
25
+ locale,
26
+ form
27
+ }) {
28
+ const inputRef = react.useRef(null);
29
+ const nextCursorRef = react.useRef(null);
30
+ const fieldLocale = locale ?? "en-US";
31
+ react.useLayoutEffect(() => {
32
+ if (nextCursorRef.current !== null && inputRef.current) {
33
+ inputRef.current.setSelectionRange(nextCursorRef.current, nextCursorRef.current);
34
+ nextCursorRef.current = null;
35
+ }
36
+ });
37
+ const handleChange = react.useCallback(
38
+ (e) => {
39
+ const raw = e.target.value;
40
+ const cursorPos = e.target.selectionStart ?? 0;
41
+ const cleaned = numberUtils.stripNonNumeric(raw, fieldLocale);
42
+ if (cleaned === "" || cleaned === "-") {
43
+ form.setFieldValue(name, cleaned === "-" ? cleaned : "");
44
+ return;
45
+ }
46
+ const numValue = Number.parseFloat(cleaned);
47
+ if (Number.isNaN(numValue)) return;
48
+ let clamped = numValue;
49
+ if (min !== void 0 && clamped < min) clamped = min;
50
+ if (max !== void 0 && clamped > max) clamped = max;
51
+ form.setFieldValue(name, clamped);
52
+ const formatted = numberUtils.formatNumber(clamped, { locale: fieldLocale });
53
+ nextCursorRef.current = numberUtils.calculateCursorPosition(raw, formatted, cursorPos, fieldLocale);
54
+ },
55
+ [form, name, min, max, fieldLocale]
56
+ );
57
+ let displayValue = "";
58
+ if (value !== "" && value != null) {
59
+ displayValue = typeof value === "number" ? numberUtils.formatNumber(value, { locale: fieldLocale }) : String(value);
60
+ }
61
+ const aria = fieldUtils.ariaProps(name, { error, helperText, required, label });
62
+ const hasAdornment = prefix || suffix;
63
+ const inputEl = /* @__PURE__ */ jsxRuntime.jsx(
64
+ "input",
65
+ {
66
+ ...aria,
67
+ ref: inputRef,
68
+ type: "text",
69
+ inputMode: "decimal",
70
+ name,
71
+ value: displayValue,
72
+ onChange: handleChange,
73
+ onBlur,
74
+ placeholder,
75
+ disabled,
76
+ readOnly,
77
+ step,
78
+ className: fieldUtils.cx(
79
+ hasAdornment ? fieldUtils.cx(fieldBase_module.default.input, fieldBase_module.default.inputGroupInput) : fieldBase_module.default.input,
80
+ error && fieldBase_module.default.inputError
81
+ )
82
+ }
83
+ );
84
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldBase_module.default.wrapper, children: [
85
+ label && /* @__PURE__ */ jsxRuntime.jsx(
86
+ "label",
87
+ {
88
+ id: fieldUtils.labelId(name),
89
+ htmlFor: name,
90
+ className: fieldUtils.cx(fieldBase_module.default.label, required && fieldBase_module.default.labelRequired),
91
+ children: label
92
+ }
93
+ ),
94
+ hasAdornment ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldBase_module.default.inputGroup, children: [
95
+ prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: fieldBase_module.default.inputPrefix, children: prefix }),
96
+ inputEl,
97
+ suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: fieldBase_module.default.inputSuffix, children: suffix })
98
+ ] }) : inputEl,
99
+ helperText && /* @__PURE__ */ jsxRuntime.jsx(
100
+ "span",
101
+ {
102
+ id: fieldUtils.helperId(name),
103
+ className: fieldUtils.cx(fieldBase_module.default.helperText, error && fieldBase_module.default.helperTextError),
104
+ role: error ? "alert" : void 0,
105
+ children: helperText
106
+ }
107
+ )
108
+ ] });
109
+ }
110
+ exports.NumberField = NumberField;
@@ -0,0 +1,10 @@
1
+ import { FieldComponentProps } from '../../types';
2
+ export declare function NumberField({ name, value, onChange: _onChange, onBlur, error, helperText, label, placeholder, disabled, readOnly, required, min, max, step, prefix, suffix, locale, form, }: FieldComponentProps & {
3
+ min?: number;
4
+ max?: number;
5
+ step?: number;
6
+ prefix?: string;
7
+ suffix?: string;
8
+ locale?: string;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=NumberField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/fields/NumberField/NumberField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIvD,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,QAAQ,EAAE,SAAS,EACnB,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,MAAM,EACN,MAAM,EACN,MAAM,EACN,IAAI,GACL,EAAE,mBAAmB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,2CA0GA"}
@@ -0,0 +1,110 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useLayoutEffect, useCallback } from "react";
3
+ import { stripNonNumeric, formatNumber, calculateCursorPosition } from "../../core/numberUtils.js";
4
+ import styles from "../fieldBase.module.css.js";
5
+ import { ariaProps, cx, labelId, helperId } from "../fieldUtils.js";
6
+ function NumberField({
7
+ name,
8
+ value,
9
+ onChange: _onChange,
10
+ onBlur,
11
+ error,
12
+ helperText,
13
+ label,
14
+ placeholder,
15
+ disabled,
16
+ readOnly,
17
+ required,
18
+ min,
19
+ max,
20
+ step,
21
+ prefix,
22
+ suffix,
23
+ locale,
24
+ form
25
+ }) {
26
+ const inputRef = useRef(null);
27
+ const nextCursorRef = useRef(null);
28
+ const fieldLocale = locale ?? "en-US";
29
+ useLayoutEffect(() => {
30
+ if (nextCursorRef.current !== null && inputRef.current) {
31
+ inputRef.current.setSelectionRange(nextCursorRef.current, nextCursorRef.current);
32
+ nextCursorRef.current = null;
33
+ }
34
+ });
35
+ const handleChange = useCallback(
36
+ (e) => {
37
+ const raw = e.target.value;
38
+ const cursorPos = e.target.selectionStart ?? 0;
39
+ const cleaned = stripNonNumeric(raw, fieldLocale);
40
+ if (cleaned === "" || cleaned === "-") {
41
+ form.setFieldValue(name, cleaned === "-" ? cleaned : "");
42
+ return;
43
+ }
44
+ const numValue = Number.parseFloat(cleaned);
45
+ if (Number.isNaN(numValue)) return;
46
+ let clamped = numValue;
47
+ if (min !== void 0 && clamped < min) clamped = min;
48
+ if (max !== void 0 && clamped > max) clamped = max;
49
+ form.setFieldValue(name, clamped);
50
+ const formatted = formatNumber(clamped, { locale: fieldLocale });
51
+ nextCursorRef.current = calculateCursorPosition(raw, formatted, cursorPos, fieldLocale);
52
+ },
53
+ [form, name, min, max, fieldLocale]
54
+ );
55
+ let displayValue = "";
56
+ if (value !== "" && value != null) {
57
+ displayValue = typeof value === "number" ? formatNumber(value, { locale: fieldLocale }) : String(value);
58
+ }
59
+ const aria = ariaProps(name, { error, helperText, required, label });
60
+ const hasAdornment = prefix || suffix;
61
+ const inputEl = /* @__PURE__ */ jsx(
62
+ "input",
63
+ {
64
+ ...aria,
65
+ ref: inputRef,
66
+ type: "text",
67
+ inputMode: "decimal",
68
+ name,
69
+ value: displayValue,
70
+ onChange: handleChange,
71
+ onBlur,
72
+ placeholder,
73
+ disabled,
74
+ readOnly,
75
+ step,
76
+ className: cx(
77
+ hasAdornment ? cx(styles.input, styles.inputGroupInput) : styles.input,
78
+ error && styles.inputError
79
+ )
80
+ }
81
+ );
82
+ return /* @__PURE__ */ jsxs("div", { className: styles.wrapper, children: [
83
+ label && /* @__PURE__ */ jsx(
84
+ "label",
85
+ {
86
+ id: labelId(name),
87
+ htmlFor: name,
88
+ className: cx(styles.label, required && styles.labelRequired),
89
+ children: label
90
+ }
91
+ ),
92
+ hasAdornment ? /* @__PURE__ */ jsxs("div", { className: styles.inputGroup, children: [
93
+ prefix && /* @__PURE__ */ jsx("span", { className: styles.inputPrefix, children: prefix }),
94
+ inputEl,
95
+ suffix && /* @__PURE__ */ jsx("span", { className: styles.inputSuffix, children: suffix })
96
+ ] }) : inputEl,
97
+ helperText && /* @__PURE__ */ jsx(
98
+ "span",
99
+ {
100
+ id: helperId(name),
101
+ className: cx(styles.helperText, error && styles.helperTextError),
102
+ role: error ? "alert" : void 0,
103
+ children: helperText
104
+ }
105
+ )
106
+ ] });
107
+ }
108
+ export {
109
+ NumberField
110
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const fieldBase_module = require("../fieldBase.module.css.cjs");
6
+ const fieldUtils = require("../fieldUtils.cjs");
7
+ const PasswordField_module = require("./PasswordField.module.css.cjs");
8
+ function PasswordField({
9
+ name,
10
+ value,
11
+ onChange,
12
+ onBlur,
13
+ error,
14
+ helperText,
15
+ label,
16
+ placeholder,
17
+ disabled,
18
+ readOnly,
19
+ required
20
+ }) {
21
+ const [visible, setVisible] = react.useState(false);
22
+ const aria = fieldUtils.ariaProps(name, { error, helperText, required, label });
23
+ const toggleVisible = react.useCallback(() => {
24
+ setVisible((v) => !v);
25
+ }, []);
26
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldBase_module.default.wrapper, children: [
27
+ label && /* @__PURE__ */ jsxRuntime.jsx(
28
+ "label",
29
+ {
30
+ id: fieldUtils.labelId(name),
31
+ htmlFor: name,
32
+ className: fieldUtils.cx(fieldBase_module.default.label, required && fieldBase_module.default.labelRequired),
33
+ children: label
34
+ }
35
+ ),
36
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: PasswordField_module.default.inputWrap, children: [
37
+ /* @__PURE__ */ jsxRuntime.jsx(
38
+ "input",
39
+ {
40
+ ...aria,
41
+ type: visible ? "text" : "password",
42
+ name,
43
+ value: value ?? "",
44
+ onChange,
45
+ onBlur,
46
+ placeholder,
47
+ disabled,
48
+ readOnly,
49
+ autoComplete: "current-password",
50
+ className: fieldUtils.cx(fieldBase_module.default.input, error && fieldBase_module.default.inputError, PasswordField_module.default.passwordInput)
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsxRuntime.jsx(
54
+ "button",
55
+ {
56
+ type: "button",
57
+ className: PasswordField_module.default.toggle,
58
+ onClick: toggleVisible,
59
+ "aria-label": visible ? "Hide password" : "Show password",
60
+ tabIndex: -1,
61
+ disabled,
62
+ children: visible ? "◉" : "○"
63
+ }
64
+ )
65
+ ] }),
66
+ helperText && /* @__PURE__ */ jsxRuntime.jsx(
67
+ "span",
68
+ {
69
+ id: fieldUtils.helperId(name),
70
+ className: fieldUtils.cx(fieldBase_module.default.helperText, error && fieldBase_module.default.helperTextError),
71
+ role: error ? "alert" : void 0,
72
+ children: helperText
73
+ }
74
+ )
75
+ ] });
76
+ }
77
+ exports.PasswordField = PasswordField;
@@ -0,0 +1,3 @@
1
+ import { FieldComponentProps } from '../../types';
2
+ export declare function PasswordField({ name, value, onChange, onBlur, error, helperText, label, placeholder, disabled, readOnly, required, }: Readonly<FieldComponentProps>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=PasswordField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordField.d.ts","sourceRoot":"","sources":["../../../src/fields/PasswordField/PasswordField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE,QAAQ,CAAC,mBAAmB,CAAC,2CAuD/B"}