@mantine/form 6.0.16 → 7.0.0-alpha.21

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 (148) hide show
  1. package/cjs/src/mantine-form/src/Form/Form.js +61 -0
  2. package/cjs/src/mantine-form/src/Form/Form.js.map +1 -0
  3. package/cjs/src/mantine-form/src/FormProvider/FormProvider.js +28 -0
  4. package/cjs/src/mantine-form/src/FormProvider/FormProvider.js.map +1 -0
  5. package/cjs/src/mantine-form/src/filter-errors/filter-errors.js +19 -0
  6. package/cjs/src/mantine-form/src/filter-errors/filter-errors.js.map +1 -0
  7. package/cjs/src/mantine-form/src/form-index.js +8 -0
  8. package/cjs/src/mantine-form/src/form-index.js.map +1 -0
  9. package/cjs/src/mantine-form/src/get-input-on-change/get-input-on-change.js +29 -0
  10. package/cjs/src/mantine-form/src/get-input-on-change/get-input-on-change.js.map +1 -0
  11. package/cjs/src/mantine-form/src/get-status/get-status.js +15 -0
  12. package/cjs/src/mantine-form/src/get-status/get-status.js.map +1 -0
  13. package/cjs/src/mantine-form/src/index.js +36 -0
  14. package/cjs/src/mantine-form/src/index.js.map +1 -0
  15. package/cjs/src/mantine-form/src/lists/change-error-indices.js +63 -0
  16. package/cjs/src/mantine-form/src/lists/change-error-indices.js.map +1 -0
  17. package/cjs/src/mantine-form/src/lists/clear-list-state.js +35 -0
  18. package/cjs/src/mantine-form/src/lists/clear-list-state.js.map +1 -0
  19. package/cjs/src/mantine-form/src/lists/reorder-errors.js +49 -0
  20. package/cjs/src/mantine-form/src/lists/reorder-errors.js.map +1 -0
  21. package/cjs/src/mantine-form/src/paths/get-path.js +23 -0
  22. package/cjs/src/mantine-form/src/paths/get-path.js.map +1 -0
  23. package/cjs/src/mantine-form/src/paths/get-splitted-path.js +13 -0
  24. package/cjs/src/mantine-form/src/paths/get-splitted-path.js.map +1 -0
  25. package/cjs/src/mantine-form/src/paths/insert-path.js +19 -0
  26. package/cjs/src/mantine-form/src/paths/insert-path.js.map +1 -0
  27. package/cjs/src/mantine-form/src/paths/remove-path.js +21 -0
  28. package/cjs/src/mantine-form/src/paths/remove-path.js.map +1 -0
  29. package/cjs/src/mantine-form/src/paths/reorder-path.js +21 -0
  30. package/cjs/src/mantine-form/src/paths/reorder-path.js.map +1 -0
  31. package/cjs/src/mantine-form/src/paths/set-path.js +30 -0
  32. package/cjs/src/mantine-form/src/paths/set-path.js.map +1 -0
  33. package/cjs/src/mantine-form/src/resolvers/joi-resolver/joi-resolver.js +37 -0
  34. package/cjs/src/mantine-form/src/resolvers/joi-resolver/joi-resolver.js.map +1 -0
  35. package/cjs/src/mantine-form/src/resolvers/superstruct-resolver/superstruct-resolver.js +22 -0
  36. package/cjs/src/mantine-form/src/resolvers/superstruct-resolver/superstruct-resolver.js.map +1 -0
  37. package/cjs/src/mantine-form/src/resolvers/yup-resolver/yup-resolver.js +23 -0
  38. package/cjs/src/mantine-form/src/resolvers/yup-resolver/yup-resolver.js.map +1 -0
  39. package/cjs/src/mantine-form/src/resolvers/zod-resolver/zod-resolver.js +20 -0
  40. package/cjs/src/mantine-form/src/resolvers/zod-resolver/zod-resolver.js.map +1 -0
  41. package/cjs/src/mantine-form/src/use-form.js +247 -0
  42. package/cjs/src/mantine-form/src/use-form.js.map +1 -0
  43. package/cjs/src/mantine-form/src/validate/should-validate-on-change.js +21 -0
  44. package/cjs/src/mantine-form/src/validate/should-validate-on-change.js.map +1 -0
  45. package/cjs/src/mantine-form/src/validate/validate-field-value.js +19 -0
  46. package/cjs/src/mantine-form/src/validate/validate-field-value.js.map +1 -0
  47. package/cjs/src/mantine-form/src/validate/validate-values.js +46 -0
  48. package/cjs/src/mantine-form/src/validate/validate-values.js.map +1 -0
  49. package/cjs/src/mantine-form/src/validators/has-length/has-length.js +33 -0
  50. package/cjs/src/mantine-form/src/validators/has-length/has-length.js.map +1 -0
  51. package/cjs/src/mantine-form/src/validators/is-email/is-email.js +12 -0
  52. package/cjs/src/mantine-form/src/validators/is-email/is-email.js.map +1 -0
  53. package/cjs/src/mantine-form/src/validators/is-in-range/is-in-range.js +23 -0
  54. package/cjs/src/mantine-form/src/validators/is-in-range/is-in-range.js.map +1 -0
  55. package/cjs/src/mantine-form/src/validators/is-not-empty/is-not-empty.js +25 -0
  56. package/cjs/src/mantine-form/src/validators/is-not-empty/is-not-empty.js.map +1 -0
  57. package/cjs/src/mantine-form/src/validators/matches/matches.js +16 -0
  58. package/cjs/src/mantine-form/src/validators/matches/matches.js.map +1 -0
  59. package/cjs/src/mantine-form/src/validators/matches-field/matches-field.js +16 -0
  60. package/cjs/src/mantine-form/src/validators/matches-field/matches-field.js.map +1 -0
  61. package/esm/src/mantine-form/src/Form/Form.js +53 -0
  62. package/esm/src/mantine-form/src/Form/Form.js.map +1 -0
  63. package/esm/src/mantine-form/src/FormProvider/FormProvider.js +20 -0
  64. package/esm/src/mantine-form/src/FormProvider/FormProvider.js.map +1 -0
  65. package/esm/src/mantine-form/src/filter-errors/filter-errors.js +15 -0
  66. package/esm/src/mantine-form/src/filter-errors/filter-errors.js.map +1 -0
  67. package/esm/src/mantine-form/src/form-index.js +4 -0
  68. package/esm/src/mantine-form/src/form-index.js.map +1 -0
  69. package/esm/src/mantine-form/src/get-input-on-change/get-input-on-change.js +25 -0
  70. package/esm/src/mantine-form/src/get-input-on-change/get-input-on-change.js.map +1 -0
  71. package/esm/src/mantine-form/src/get-status/get-status.js +11 -0
  72. package/esm/src/mantine-form/src/get-status/get-status.js.map +1 -0
  73. package/esm/src/mantine-form/src/index.js +15 -0
  74. package/esm/src/mantine-form/src/index.js.map +1 -0
  75. package/esm/src/mantine-form/src/lists/change-error-indices.js +59 -0
  76. package/esm/src/mantine-form/src/lists/change-error-indices.js.map +1 -0
  77. package/esm/src/mantine-form/src/lists/clear-list-state.js +31 -0
  78. package/esm/src/mantine-form/src/lists/clear-list-state.js.map +1 -0
  79. package/esm/src/mantine-form/src/lists/reorder-errors.js +45 -0
  80. package/esm/src/mantine-form/src/lists/reorder-errors.js.map +1 -0
  81. package/esm/src/mantine-form/src/paths/get-path.js +19 -0
  82. package/esm/src/mantine-form/src/paths/get-path.js.map +1 -0
  83. package/esm/src/mantine-form/src/paths/get-splitted-path.js +9 -0
  84. package/esm/src/mantine-form/src/paths/get-splitted-path.js.map +1 -0
  85. package/esm/src/mantine-form/src/paths/insert-path.js +15 -0
  86. package/esm/src/mantine-form/src/paths/insert-path.js.map +1 -0
  87. package/esm/src/mantine-form/src/paths/remove-path.js +17 -0
  88. package/esm/src/mantine-form/src/paths/remove-path.js.map +1 -0
  89. package/esm/src/mantine-form/src/paths/reorder-path.js +17 -0
  90. package/esm/src/mantine-form/src/paths/reorder-path.js.map +1 -0
  91. package/esm/src/mantine-form/src/paths/set-path.js +26 -0
  92. package/esm/src/mantine-form/src/paths/set-path.js.map +1 -0
  93. package/esm/src/mantine-form/src/resolvers/joi-resolver/joi-resolver.js +33 -0
  94. package/esm/src/mantine-form/src/resolvers/joi-resolver/joi-resolver.js.map +1 -0
  95. package/esm/src/mantine-form/src/resolvers/superstruct-resolver/superstruct-resolver.js +18 -0
  96. package/esm/src/mantine-form/src/resolvers/superstruct-resolver/superstruct-resolver.js.map +1 -0
  97. package/esm/src/mantine-form/src/resolvers/yup-resolver/yup-resolver.js +19 -0
  98. package/esm/src/mantine-form/src/resolvers/yup-resolver/yup-resolver.js.map +1 -0
  99. package/esm/src/mantine-form/src/resolvers/zod-resolver/zod-resolver.js +16 -0
  100. package/esm/src/mantine-form/src/resolvers/zod-resolver/zod-resolver.js.map +1 -0
  101. package/esm/src/mantine-form/src/use-form.js +239 -0
  102. package/esm/src/mantine-form/src/use-form.js.map +1 -0
  103. package/esm/src/mantine-form/src/validate/should-validate-on-change.js +17 -0
  104. package/esm/src/mantine-form/src/validate/should-validate-on-change.js.map +1 -0
  105. package/esm/src/mantine-form/src/validate/validate-field-value.js +15 -0
  106. package/esm/src/mantine-form/src/validate/validate-field-value.js.map +1 -0
  107. package/esm/src/mantine-form/src/validate/validate-values.js +42 -0
  108. package/esm/src/mantine-form/src/validate/validate-values.js.map +1 -0
  109. package/esm/src/mantine-form/src/validators/has-length/has-length.js +29 -0
  110. package/esm/src/mantine-form/src/validators/has-length/has-length.js.map +1 -0
  111. package/esm/src/mantine-form/src/validators/is-email/is-email.js +8 -0
  112. package/esm/src/mantine-form/src/validators/is-email/is-email.js.map +1 -0
  113. package/esm/src/mantine-form/src/validators/is-in-range/is-in-range.js +19 -0
  114. package/esm/src/mantine-form/src/validators/is-in-range/is-in-range.js.map +1 -0
  115. package/esm/src/mantine-form/src/validators/is-not-empty/is-not-empty.js +21 -0
  116. package/esm/src/mantine-form/src/validators/is-not-empty/is-not-empty.js.map +1 -0
  117. package/esm/src/mantine-form/src/validators/matches/matches.js +12 -0
  118. package/esm/src/mantine-form/src/validators/matches/matches.js.map +1 -0
  119. package/esm/src/mantine-form/src/validators/matches-field/matches-field.js +12 -0
  120. package/esm/src/mantine-form/src/validators/matches-field/matches-field.js.map +1 -0
  121. package/lib/Form/Form.d.ts +1 -1
  122. package/lib/Form/Form.d.ts.map +1 -1
  123. package/lib/get-input-on-change/get-input-on-change.d.ts +1 -0
  124. package/lib/get-input-on-change/get-input-on-change.d.ts.map +1 -1
  125. package/lib/lists/change-error-indices.d.ts +1 -1
  126. package/lib/lists/change-error-indices.d.ts.map +1 -1
  127. package/lib/paths/insert-path.d.ts +1 -1
  128. package/lib/paths/insert-path.d.ts.map +1 -1
  129. package/lib/paths/set-path.d.ts.map +1 -1
  130. package/lib/types.d.ts +2 -2
  131. package/lib/types.d.ts.map +1 -1
  132. package/lib/validate/validate-field-value.d.ts +1 -1
  133. package/lib/validate/validate-field-value.d.ts.map +1 -1
  134. package/lib/validate/validate-values.d.ts +1 -1
  135. package/lib/validate/validate-values.d.ts.map +1 -1
  136. package/lib/validators/has-length/has-length.d.ts +1 -1
  137. package/lib/validators/has-length/has-length.d.ts.map +1 -1
  138. package/lib/validators/is-email/is-email.d.ts +1 -1
  139. package/lib/validators/is-email/is-email.d.ts.map +1 -1
  140. package/lib/validators/is-in-range/is-in-range.d.ts +1 -1
  141. package/lib/validators/is-in-range/is-in-range.d.ts.map +1 -1
  142. package/lib/validators/is-not-empty/is-not-empty.d.ts +1 -1
  143. package/lib/validators/is-not-empty/is-not-empty.d.ts.map +1 -1
  144. package/lib/validators/matches/matches.d.ts +1 -1
  145. package/lib/validators/matches/matches.d.ts.map +1 -1
  146. package/lib/validators/matches-field/matches-field.d.ts +1 -1
  147. package/lib/validators/matches-field/matches-field.d.ts.map +1 -1
  148. package/package.json +10 -5
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __defProps = Object.defineProperties;
13
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
14
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
+ var __spreadValues = (a, b) => {
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
27
+ return a;
28
+ };
29
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
+ var __objRest = (source, exclude) => {
31
+ var target = {};
32
+ for (var prop in source)
33
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
34
+ target[prop] = source[prop];
35
+ if (source != null && __getOwnPropSymbols)
36
+ for (var prop of __getOwnPropSymbols(source)) {
37
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
38
+ target[prop] = source[prop];
39
+ }
40
+ return target;
41
+ };
42
+ const Form = React.forwardRef(
43
+ (_a, ref) => {
44
+ var _b = _a, { form, onSubmit, onReset } = _b, others = __objRest(_b, ["form", "onSubmit", "onReset"]);
45
+ return /* @__PURE__ */ React__default.createElement(
46
+ "form",
47
+ __spreadProps(__spreadValues({}, others), {
48
+ onSubmit: form.onSubmit(typeof onSubmit === "function" ? onSubmit : () => {
49
+ }),
50
+ onReset: (event) => {
51
+ onReset == null ? void 0 : onReset(event);
52
+ form.onReset(event);
53
+ },
54
+ ref
55
+ })
56
+ );
57
+ }
58
+ );
59
+
60
+ exports.Form = Form;
61
+ //# sourceMappingURL=Form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.js","sources":["../../../../../src/Form/Form.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { UseFormReturnType, TransformedValues } from '../types';\n\nexport interface FormProps<Form extends UseFormReturnType<any>>\n extends React.ComponentPropsWithRef<'form'> {\n form: Form;\n onSubmit?(values: TransformedValues<Form>): void;\n}\n\nexport type FormComponent = <Form extends UseFormReturnType<any>>(\n props: FormProps<Form>\n) => JSX.Element | React.ReactNode;\n\nexport const Form: FormComponent = forwardRef(\n <Form extends UseFormReturnType<any>>(\n { form, onSubmit, onReset, ...others }: FormProps<Form>,\n ref: React.ForwardedRef<HTMLFormElement>\n ) => (\n <form\n {...others}\n onSubmit={form.onSubmit(typeof onSubmit === 'function' ? onSubmit : () => {})}\n onReset={(event) => {\n onReset?.(event);\n form.onReset(event);\n }}\n ref={ref}\n />\n )\n);\n"],"names":["forwardRef","React"],"mappings":";;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,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KAAK,KAAK;AAC5B,UAAU,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACpD,UAAU,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,SAAS;AACT,QAAQ,GAAG;AACX,OAAO,CAAC;AACR,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var useForm = require('../use-form.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+
12
+ function createFormContext() {
13
+ const FormContext = React.createContext(null);
14
+ function FormProvider({ form, children }) {
15
+ return /* @__PURE__ */ React__default.createElement(FormContext.Provider, { value: form }, children);
16
+ }
17
+ function useFormContext() {
18
+ const ctx = React.useContext(FormContext);
19
+ if (!ctx) {
20
+ throw new Error("useFormContext was called outside of FormProvider context");
21
+ }
22
+ return ctx;
23
+ }
24
+ return [FormProvider, useFormContext, useForm.useForm];
25
+ }
26
+
27
+ exports.createFormContext = createFormContext;
28
+ //# sourceMappingURL=FormProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormProvider.js","sources":["../../../../../src/FormProvider/FormProvider.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\nimport { useForm } from '../use-form';\nimport { UseFormReturnType, UseForm, _TransformValues } from '../types';\n\nexport interface FormProviderProps<Form> {\n form: Form;\n children: React.ReactNode;\n}\n\nexport function createFormContext<\n Values,\n TransformValues extends _TransformValues<Values> = (values: Values) => Values,\n>() {\n type Form = UseFormReturnType<Values, TransformValues>;\n\n const FormContext = createContext<Form | null>(null);\n\n function FormProvider({ form, children }: FormProviderProps<Form>) {\n return <FormContext.Provider value={form}>{children}</FormContext.Provider>;\n }\n\n function useFormContext() {\n const ctx = useContext(FormContext);\n if (!ctx) {\n throw new Error('useFormContext was called outside of FormProvider context');\n }\n\n return ctx;\n }\n\n return [FormProvider, useFormContext, useForm] as [\n React.FC<FormProviderProps<Form>>,\n () => Form,\n UseForm<Values, TransformValues>,\n ];\n}\n"],"names":["createContext","React","useContext","useForm"],"mappings":";;;;;;;;;;;AAEO,SAAS,iBAAiB,GAAG;AACpC,EAAE,MAAM,WAAW,GAAGA,mBAAa,CAAC,IAAI,CAAC,CAAC;AAC1C,EAAE,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;AAC5C,IAAI,uBAAuBC,cAAK,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;AAChG,GAAG;AACH,EAAE,SAAS,cAAc,GAAG;AAC5B,IAAI,MAAM,GAAG,GAAGC,gBAAU,CAAC,WAAW,CAAC,CAAC;AACxC,IAAI,IAAI,CAAC,GAAG,EAAE;AACd,MAAM,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AACnF,KAAK;AACL,IAAI,OAAO,GAAG,CAAC;AACf,GAAG;AACH,EAAE,OAAO,CAAC,YAAY,EAAE,cAAc,EAAEC,eAAO,CAAC,CAAC;AACjD;;;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function filterErrors(errors) {
6
+ if (errors === null || typeof errors !== "object") {
7
+ return {};
8
+ }
9
+ return Object.keys(errors).reduce((acc, key) => {
10
+ const errorValue = errors[key];
11
+ if (errorValue !== void 0 && errorValue !== null && errorValue !== false) {
12
+ acc[key] = errorValue;
13
+ }
14
+ return acc;
15
+ }, {});
16
+ }
17
+
18
+ exports.filterErrors = filterErrors;
19
+ //# sourceMappingURL=filter-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-errors.js","sources":["../../../../../src/filter-errors/filter-errors.ts"],"sourcesContent":["import type { FormErrors } from '../types';\n\nexport function filterErrors(errors: FormErrors): FormErrors {\n if (errors === null || typeof errors !== 'object') {\n return {};\n }\n\n return Object.keys(errors).reduce<FormErrors>((acc, key) => {\n const errorValue = errors[key];\n\n if (errorValue !== undefined && errorValue !== null && errorValue !== false) {\n acc[key] = errorValue;\n }\n\n return acc;\n }, {});\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,YAAY,CAAC,MAAM,EAAE;AACrC,EAAE,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AACrD,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK;AAClD,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AACnC,IAAI,IAAI,UAAU,KAAK,KAAK,CAAC,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,KAAK,EAAE;AAC9E,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;AAC5B,KAAK;AACL,IAAI,OAAO,GAAG,CAAC;AACf,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const FORM_INDEX = "__MANTINE_FORM_INDEX__";
6
+
7
+ exports.FORM_INDEX = FORM_INDEX;
8
+ //# sourceMappingURL=form-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-index.js","sources":["../../../../src/form-index.ts"],"sourcesContent":["export const FORM_INDEX = '__MANTINE_FORM_INDEX__';\n"],"names":[],"mappings":";;;;AAAY,MAAC,UAAU,GAAG;;;;"}
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getInputOnChange(setValue) {
6
+ return (val) => {
7
+ if (!val) {
8
+ setValue(val);
9
+ } else if (typeof val === "function") {
10
+ setValue(val);
11
+ } else if (typeof val === "object" && "nativeEvent" in val) {
12
+ const { currentTarget } = val;
13
+ if (currentTarget instanceof HTMLInputElement) {
14
+ if (currentTarget.type === "checkbox") {
15
+ setValue(currentTarget.checked);
16
+ } else {
17
+ setValue(currentTarget.value);
18
+ }
19
+ } else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
20
+ setValue(currentTarget.value);
21
+ }
22
+ } else {
23
+ setValue(val);
24
+ }
25
+ };
26
+ }
27
+
28
+ exports.getInputOnChange = getInputOnChange;
29
+ //# sourceMappingURL=get-input-on-change.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-input-on-change.js","sources":["../../../../../src/get-input-on-change/get-input-on-change.ts"],"sourcesContent":["export function getInputOnChange<Value>(\n setValue: (value: Value | ((current: Value) => Value)) => void\n) {\n return (val: Value | React.ChangeEvent<unknown> | ((current: Value) => Value)) => {\n if (!val) {\n setValue(val as Value);\n } else if (typeof val === 'function') {\n setValue(val);\n } else if (typeof val === 'object' && 'nativeEvent' in val) {\n const { currentTarget } = val;\n if (currentTarget instanceof HTMLInputElement) {\n if (currentTarget.type === 'checkbox') {\n setValue(currentTarget.checked as any);\n } else {\n setValue(currentTarget.value as any);\n }\n } else if (\n currentTarget instanceof HTMLTextAreaElement ||\n currentTarget instanceof HTMLSelectElement\n ) {\n setValue(currentTarget.value as any);\n }\n } else {\n setValue(val);\n }\n };\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,gBAAgB,CAAC,QAAQ,EAAE;AAC3C,EAAE,OAAO,CAAC,GAAG,KAAK;AAClB,IAAI,IAAI,CAAC,GAAG,EAAE;AACd,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpB,KAAK,MAAM,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;AAC1C,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpB,KAAK,MAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,aAAa,IAAI,GAAG,EAAE;AAChE,MAAM,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC;AACpC,MAAM,IAAI,aAAa,YAAY,gBAAgB,EAAE;AACrD,QAAQ,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,EAAE;AAC/C,UAAU,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC1C,SAAS,MAAM;AACf,UAAU,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxC,SAAS;AACT,OAAO,MAAM,IAAI,aAAa,YAAY,mBAAmB,IAAI,aAAa,YAAY,iBAAiB,EAAE;AAC7G,QAAQ,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACtC,OAAO;AACP,KAAK,MAAM;AACX,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getStatus(status, path) {
6
+ const paths = Object.keys(status);
7
+ if (typeof path === "string") {
8
+ const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
9
+ return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
10
+ }
11
+ return paths.some((statusPath) => status[statusPath]);
12
+ }
13
+
14
+ exports.getStatus = getStatus;
15
+ //# sourceMappingURL=get-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-status.js","sources":["../../../../../src/get-status/get-status.ts"],"sourcesContent":["import { FormStatus } from '../types';\n\nexport function getStatus(status: FormStatus, path?: unknown) {\n const paths = Object.keys(status);\n\n if (typeof path === 'string') {\n const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));\n return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;\n }\n\n return paths.some((statusPath) => status[statusPath]);\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE;AACxC,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpC,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAChC,IAAI,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC;AACzF,GAAG;AACH,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACxD;;;;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var useForm = require('./use-form.js');
6
+ var FormProvider = require('./FormProvider/FormProvider.js');
7
+ var Form = require('./Form/Form.js');
8
+ var formIndex = require('./form-index.js');
9
+ var zodResolver = require('./resolvers/zod-resolver/zod-resolver.js');
10
+ var superstructResolver = require('./resolvers/superstruct-resolver/superstruct-resolver.js');
11
+ var yupResolver = require('./resolvers/yup-resolver/yup-resolver.js');
12
+ var joiResolver = require('./resolvers/joi-resolver/joi-resolver.js');
13
+ var isNotEmpty = require('./validators/is-not-empty/is-not-empty.js');
14
+ var matches = require('./validators/matches/matches.js');
15
+ var isEmail = require('./validators/is-email/is-email.js');
16
+ var hasLength = require('./validators/has-length/has-length.js');
17
+ var isInRange = require('./validators/is-in-range/is-in-range.js');
18
+ var matchesField = require('./validators/matches-field/matches-field.js');
19
+
20
+
21
+
22
+ exports.useForm = useForm.useForm;
23
+ exports.createFormContext = FormProvider.createFormContext;
24
+ exports.Form = Form.Form;
25
+ exports.FORM_INDEX = formIndex.FORM_INDEX;
26
+ exports.zodResolver = zodResolver.zodResolver;
27
+ exports.superstructResolver = superstructResolver.superstructResolver;
28
+ exports.yupResolver = yupResolver.yupResolver;
29
+ exports.joiResolver = joiResolver.joiResolver;
30
+ exports.isNotEmpty = isNotEmpty.isNotEmpty;
31
+ exports.matches = matches.matches;
32
+ exports.isEmail = isEmail.isEmail;
33
+ exports.hasLength = hasLength.hasLength;
34
+ exports.isInRange = isInRange.isInRange;
35
+ exports.matchesField = matchesField.matchesField;
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var clearListState = require('./clear-list-state.js');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ function getIndexFromKeyAfterPath(key, path) {
24
+ const split = key.substring(path.length + 1).split(".")[0];
25
+ return parseInt(split, 10);
26
+ }
27
+ function changeErrorIndices(path, index, errors, change) {
28
+ if (index === void 0) {
29
+ return errors;
30
+ }
31
+ const pathString = `${String(path)}`;
32
+ let clearedErrors = errors;
33
+ if (change === -1) {
34
+ clearedErrors = clearListState.clearListState(`${pathString}.${index}`, clearedErrors);
35
+ }
36
+ const cloned = __spreadValues({}, clearedErrors);
37
+ const changedKeys = /* @__PURE__ */ new Set();
38
+ Object.entries(clearedErrors).filter(([key]) => {
39
+ if (!key.startsWith(`${pathString}.`)) {
40
+ return false;
41
+ }
42
+ const currIndex = getIndexFromKeyAfterPath(key, pathString);
43
+ if (Number.isNaN(currIndex)) {
44
+ return false;
45
+ }
46
+ return currIndex >= index;
47
+ }).forEach(([key, value]) => {
48
+ const currIndex = getIndexFromKeyAfterPath(key, pathString);
49
+ const newKey = key.replace(
50
+ `${pathString}.${currIndex}`,
51
+ `${pathString}.${currIndex + change}`
52
+ );
53
+ cloned[newKey] = value;
54
+ changedKeys.add(newKey);
55
+ if (!changedKeys.has(key)) {
56
+ delete cloned[key];
57
+ }
58
+ });
59
+ return cloned;
60
+ }
61
+
62
+ exports.changeErrorIndices = changeErrorIndices;
63
+ //# sourceMappingURL=change-error-indices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-error-indices.js","sources":["../../../../../src/lists/change-error-indices.ts"],"sourcesContent":["import { clearListState } from './clear-list-state';\n\n/**\n * Gets the part of the key after the path which can be an index\n */\nfunction getIndexFromKeyAfterPath(key: string, path: string): number {\n const split = key.substring(path.length + 1).split('.')[0];\n return parseInt(split, 10);\n}\n\n/**\n * Changes the indices of every error that is after the given `index` with the given `change` at the given `path`.\n * This requires that the errors are in the format of `path.index` and that the index is a number.\n */\nexport function changeErrorIndices<T extends Record<PropertyKey, any>>(\n path: PropertyKey,\n index: number | undefined,\n errors: T,\n change: 1 | -1\n): T {\n if (index === undefined) {\n return errors;\n }\n const pathString = `${String(path)}`;\n let clearedErrors = errors;\n // Remove all errors if the corresponding item was removed\n if (change === -1) {\n clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);\n }\n\n const cloned = { ...clearedErrors };\n const changedKeys = new Set<string>();\n Object.entries(clearedErrors)\n .filter(([key]) => {\n if (!key.startsWith(`${pathString}.`)) {\n return false;\n }\n const currIndex = getIndexFromKeyAfterPath(key, pathString);\n if (Number.isNaN(currIndex)) {\n return false;\n }\n return currIndex >= index;\n })\n .forEach(([key, value]) => {\n const currIndex = getIndexFromKeyAfterPath(key, pathString);\n\n const newKey: keyof T = key.replace(\n `${pathString}.${currIndex}`,\n `${pathString}.${currIndex + change}`\n );\n cloned[newKey] = value;\n changedKeys.add(newKey);\n if (!changedKeys.has(key)) {\n delete cloned[key];\n }\n });\n\n return cloned;\n}\n"],"names":["clearListState"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,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C,GAAG,CAAC,KAAK;AAClD,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;AAC3C,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,MAAM,SAAS,GAAG,wBAAwB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAChE,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;AACjC,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,OAAO,SAAS,IAAI,KAAK,CAAC;AAC9B,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC/B,IAAI,MAAM,SAAS,GAAG,wBAAwB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAChE,IAAI,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO;AAC9B,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAClC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,CAAC;AAC3C,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AAC3B,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC/B,MAAM,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACzB,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ function clearListState(field, state) {
22
+ if (state === null || typeof state !== "object") {
23
+ return {};
24
+ }
25
+ const clone = __spreadValues({}, state);
26
+ Object.keys(state).forEach((errorKey) => {
27
+ if (errorKey.includes(`${String(field)}.`)) {
28
+ delete clone[errorKey];
29
+ }
30
+ });
31
+ return clone;
32
+ }
33
+
34
+ exports.clearListState = clearListState;
35
+ //# sourceMappingURL=clear-list-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-list-state.js","sources":["../../../../../src/lists/clear-list-state.ts"],"sourcesContent":["export function clearListState<T extends Record<PropertyKey, any>>(\n field: PropertyKey,\n state: T\n): T {\n if (state === null || typeof state !== 'object') {\n return {} as T;\n }\n\n const clone = { ...state };\n Object.keys(state).forEach((errorKey) => {\n if (errorKey.includes(`${String(field)}.`)) {\n delete clone[errorKey];\n }\n });\n\n return clone;\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CA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,CAAC;AAC7B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ function reorderErrors(path, { from, to }, errors) {
22
+ const oldKeyStart = `${path}.${from}`;
23
+ const newKeyStart = `${path}.${to}`;
24
+ const clone = __spreadValues({}, errors);
25
+ Object.keys(errors).every((key) => {
26
+ let oldKey;
27
+ let newKey;
28
+ if (key.startsWith(oldKeyStart)) {
29
+ oldKey = key;
30
+ newKey = key.replace(oldKeyStart, newKeyStart);
31
+ }
32
+ if (key.startsWith(newKeyStart)) {
33
+ oldKey = key.replace(newKeyStart, oldKeyStart);
34
+ newKey = key;
35
+ }
36
+ if (oldKey && newKey) {
37
+ const value1 = clone[oldKey];
38
+ const value2 = clone[newKey];
39
+ value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
40
+ value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
41
+ return false;
42
+ }
43
+ return true;
44
+ });
45
+ return clone;
46
+ }
47
+
48
+ exports.reorderErrors = reorderErrors;
49
+ //# sourceMappingURL=reorder-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder-errors.js","sources":["../../../../../src/lists/reorder-errors.ts"],"sourcesContent":["import { ReorderPayload } from '../types';\n\nexport function reorderErrors<T>(path: unknown, { from, to }: ReorderPayload, errors: T): T {\n const oldKeyStart = `${path}.${from}`;\n const newKeyStart = `${path}.${to}`;\n\n const clone: any = { ...errors };\n Object.keys(errors as any).every((key) => {\n let oldKey;\n let newKey;\n if (key.startsWith(oldKeyStart)) {\n oldKey = key;\n newKey = key.replace(oldKeyStart, newKeyStart);\n }\n if (key.startsWith(newKeyStart)) {\n oldKey = key.replace(newKeyStart, oldKeyStart);\n newKey = key;\n }\n if (oldKey && newKey) {\n const value1 = clone[oldKey];\n const value2 = clone[newKey];\n value2 === undefined ? delete clone[oldKey] : (clone[oldKey] = value2);\n value1 === undefined ? delete clone[newKey] : (clone[newKey] = value1);\n return false;\n }\n return true;\n });\n\n return clone;\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAA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;AACrD,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,KAAK;AACL,IAAI,IAAI,MAAM,IAAI,MAAM,EAAE;AAC1B,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,MAAM,KAAK,KAAK,CAAC,GAAG,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACxE,MAAM,MAAM,KAAK,KAAK,CAAC,GAAG,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACxE,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getSplittedPath = require('./get-splitted-path.js');
6
+
7
+ function getPath(path, values) {
8
+ const splittedPath = getSplittedPath.getSplittedPath(path);
9
+ if (splittedPath.length === 0 || typeof values !== "object" || values === null) {
10
+ return void 0;
11
+ }
12
+ let value = values[splittedPath[0]];
13
+ for (let i = 1; i < splittedPath.length; i += 1) {
14
+ if (value === void 0) {
15
+ break;
16
+ }
17
+ value = value[splittedPath[i]];
18
+ }
19
+ return value;
20
+ }
21
+
22
+ exports.getPath = getPath;
23
+ //# sourceMappingURL=get-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-path.js","sources":["../../../../../src/paths/get-path.ts"],"sourcesContent":["import { getSplittedPath } from './get-splitted-path';\n\nexport function getPath(path: unknown, values: unknown): unknown {\n const splittedPath = getSplittedPath(path);\n\n if (splittedPath.length === 0 || typeof values !== 'object' || values === null) {\n return undefined;\n }\n\n let value = values[splittedPath[0] as keyof typeof values];\n for (let i = 1; i < splittedPath.length; i += 1) {\n if (value === undefined) {\n break;\n }\n\n value = value[splittedPath[i]];\n }\n\n return value;\n}\n"],"names":["getSplittedPath"],"mappings":";;;;;;AACO,SAAS,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;AACtC,EAAE,MAAM,YAAY,GAAGA,+BAAe,CAAC,IAAI,CAAC,CAAC;AAC7C,EAAE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;AAClF,IAAI,OAAO,KAAK,CAAC,CAAC;AAClB,GAAG;AACH,EAAE,IAAI,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACnD,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE;AAC1B,MAAM,MAAM;AACZ,KAAK;AACL,IAAI,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function getSplittedPath(path) {
6
+ if (typeof path !== "string") {
7
+ return [];
8
+ }
9
+ return path.split(".");
10
+ }
11
+
12
+ exports.getSplittedPath = getSplittedPath;
13
+ //# sourceMappingURL=get-splitted-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-splitted-path.js","sources":["../../../../../src/paths/get-splitted-path.ts"],"sourcesContent":["export function getSplittedPath(path: unknown) {\n if (typeof path !== 'string') {\n return [];\n }\n\n return path.split('.');\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,eAAe,CAAC,IAAI,EAAE;AACtC,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAChC,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB;;;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getPath = require('./get-path.js');
6
+ var setPath = require('./set-path.js');
7
+
8
+ function insertPath(path, value, index, values) {
9
+ const currentValue = getPath.getPath(path, values);
10
+ if (!Array.isArray(currentValue)) {
11
+ return values;
12
+ }
13
+ const cloned = [...currentValue];
14
+ cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
15
+ return setPath.setPath(path, cloned, values);
16
+ }
17
+
18
+ exports.insertPath = insertPath;
19
+ //# sourceMappingURL=insert-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-path.js","sources":["../../../../../src/paths/insert-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function insertPath<T>(path: unknown, value: unknown, index: number | undefined, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n const cloned = [...currentValue];\n cloned.splice(typeof index === 'number' ? index : cloned.length, 0, value);\n\n return setPath(path, cloned, values);\n}\n"],"names":["getPath","setPath"],"mappings":";;;;;;;AAEO,SAAS,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;AACvD,EAAE,MAAM,YAAY,GAAGA,eAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;AACnC,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7E,EAAE,OAAOC,eAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvC;;;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getPath = require('./get-path.js');
6
+ var setPath = require('./set-path.js');
7
+
8
+ function removePath(path, index, values) {
9
+ const currentValue = getPath.getPath(path, values);
10
+ if (!Array.isArray(currentValue)) {
11
+ return values;
12
+ }
13
+ return setPath.setPath(
14
+ path,
15
+ currentValue.filter((_, itemIndex) => itemIndex !== index),
16
+ values
17
+ );
18
+ }
19
+
20
+ exports.removePath = removePath;
21
+ //# sourceMappingURL=remove-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-path.js","sources":["../../../../../src/paths/remove-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function removePath<T>(path: unknown, index: number, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n return setPath(\n path,\n currentValue.filter((_, itemIndex) => itemIndex !== index),\n values\n );\n}\n"],"names":["getPath","setPath"],"mappings":";;;;;;;AAEO,SAAS,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;AAChD,EAAE,MAAM,YAAY,GAAGA,eAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,OAAOC,eAAO;AAChB,IAAI,IAAI;AACR,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,SAAS,KAAK,KAAK,CAAC;AAC9D,IAAI,MAAM;AACV,GAAG,CAAC;AACJ;;;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var getPath = require('./get-path.js');
6
+ var setPath = require('./set-path.js');
7
+
8
+ function reorderPath(path, { from, to }, values) {
9
+ const currentValue = getPath.getPath(path, values);
10
+ if (!Array.isArray(currentValue)) {
11
+ return values;
12
+ }
13
+ const cloned = [...currentValue];
14
+ const item = currentValue[from];
15
+ cloned.splice(from, 1);
16
+ cloned.splice(to, 0, item);
17
+ return setPath.setPath(path, cloned, values);
18
+ }
19
+
20
+ exports.reorderPath = reorderPath;
21
+ //# sourceMappingURL=reorder-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder-path.js","sources":["../../../../../src/paths/reorder-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\nimport { ReorderPayload } from '../types';\n\nexport function reorderPath<T>(path: unknown, { from, to }: ReorderPayload, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n const cloned = [...currentValue];\n const item = currentValue[from];\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return setPath(path, cloned, values);\n}\n"],"names":["getPath","setPath"],"mappings":";;;;;;;AAEO,SAAS,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;AACxD,EAAE,MAAM,YAAY,GAAGA,eAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;AACnC,EAAE,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACzB,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAC7B,EAAE,OAAOC,eAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvC;;;;"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('../../../../node_modules/klona/full/index.mjs.js');
6
+ var getSplittedPath = require('./get-splitted-path.js');
7
+
8
+ function setPath(path, value, values) {
9
+ const splittedPath = getSplittedPath.getSplittedPath(path);
10
+ if (splittedPath.length === 0) {
11
+ return values;
12
+ }
13
+ const cloned = index.klona(values);
14
+ if (splittedPath.length === 1) {
15
+ cloned[splittedPath[0]] = value;
16
+ return cloned;
17
+ }
18
+ let val = cloned[splittedPath[0]];
19
+ for (let i = 1; i < splittedPath.length - 1; i += 1) {
20
+ if (val === void 0) {
21
+ return cloned;
22
+ }
23
+ val = val[splittedPath[i]];
24
+ }
25
+ val[splittedPath[splittedPath.length - 1]] = value;
26
+ return cloned;
27
+ }
28
+
29
+ exports.setPath = setPath;
30
+ //# sourceMappingURL=set-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-path.js","sources":["../../../../../src/paths/set-path.ts"],"sourcesContent":["import { klona } from 'klona/full';\nimport { getSplittedPath } from './get-splitted-path';\n\nexport function setPath<T>(path: unknown, value: unknown, values: T): T {\n const splittedPath = getSplittedPath(path);\n\n if (splittedPath.length === 0) {\n return values;\n }\n\n const cloned: any = klona(values);\n\n if (splittedPath.length === 1) {\n cloned[splittedPath[0]] = value;\n return cloned;\n }\n\n let val = cloned[splittedPath[0]];\n\n for (let i = 1; i < splittedPath.length - 1; i += 1) {\n if (val === undefined) {\n return cloned;\n }\n\n val = val[splittedPath[i]];\n }\n\n val[splittedPath[splittedPath.length - 1]] = value;\n\n return cloned;\n}\n"],"names":["getSplittedPath","klona"],"mappings":";;;;;;;AAEO,SAAS,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;AAC7C,EAAE,MAAM,YAAY,GAAGA,+BAAe,CAAC,IAAI,CAAC,CAAC;AAC7C,EAAE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;AACjC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,MAAM,MAAM,GAAGC,WAAK,CAAC,MAAM,CAAC,CAAC;AAC/B,EAAE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;AACjC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,IAAI,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;AACvD,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,EAAE;AACxB,MAAM,OAAO,MAAM,CAAC;AACpB,KAAK;AACL,IAAI,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,GAAG;AACH,EAAE,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AACrD,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ function joiResolver(schema, options) {
22
+ const _schema = schema;
23
+ return (values) => {
24
+ const parsed = _schema.validate(values, __spreadValues({ abortEarly: false }, options));
25
+ if (!parsed.error) {
26
+ return {};
27
+ }
28
+ const results = {};
29
+ parsed.error.details.forEach((error) => {
30
+ results[error.path.join(".")] = error.message;
31
+ });
32
+ return results;
33
+ };
34
+ }
35
+
36
+ exports.joiResolver = joiResolver;
37
+ //# sourceMappingURL=joi-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joi-resolver.js","sources":["../../../../../../src/resolvers/joi-resolver/joi-resolver.ts"],"sourcesContent":["import type { FormErrors } from '../../types';\n\ninterface JoiError {\n path: (string | number)[];\n message: string;\n}\n\ninterface JoiResults {\n success: boolean;\n error: {\n details: JoiError[];\n };\n}\n\ninterface JoiSchema {\n validate(values: Record<string, any>, options: { abortEarly: boolean }): JoiResults;\n}\n\nexport function joiResolver(schema: any, options?: any) {\n const _schema: JoiSchema = schema;\n return (values: Record<string, any>): FormErrors => {\n const parsed = _schema.validate(values, { abortEarly: false, ...options });\n\n if (!parsed.error) {\n return {};\n }\n\n const results: Record<string, any> = {};\n parsed.error.details.forEach((error) => {\n results[error.path.join('.')] = error.message;\n });\n\n return results;\n };\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,M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