@mantine/form 9.0.0-alpha.5 → 9.0.0-alpha.7
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/cjs/FormProvider/FormProvider.cjs +26 -21
- package/cjs/FormProvider/FormProvider.cjs.map +1 -1
- package/cjs/_virtual/_rolldown/runtime.cjs +24 -0
- package/cjs/actions/actions.cjs +86 -117
- package/cjs/actions/actions.cjs.map +1 -1
- package/cjs/form-index.cjs +5 -5
- package/cjs/form-index.cjs.map +1 -1
- package/cjs/get-input-on-change/get-input-on-change.cjs +15 -25
- package/cjs/get-input-on-change/get-input-on-change.cjs.map +1 -1
- package/cjs/get-status/get-status.cjs +11 -11
- package/cjs/get-status/get-status.cjs.map +1 -1
- package/cjs/hooks/use-form-errors/filter-errors/filter-errors.cjs +11 -15
- package/cjs/hooks/use-form-errors/filter-errors/filter-errors.cjs.map +1 -1
- package/cjs/hooks/use-form-errors/use-form-errors.cjs +39 -48
- package/cjs/hooks/use-form-errors/use-form-errors.cjs.map +1 -1
- package/cjs/hooks/use-form-list/use-form-list.cjs +47 -51
- package/cjs/hooks/use-form-list/use-form-list.cjs.map +1 -1
- package/cjs/hooks/use-form-status/use-form-status.cjs +95 -128
- package/cjs/hooks/use-form-status/use-form-status.cjs.map +1 -1
- package/cjs/hooks/use-form-validating/use-form-validating.cjs +49 -51
- package/cjs/hooks/use-form-validating/use-form-validating.cjs.map +1 -1
- package/cjs/hooks/use-form-values/use-form-values.cjs +92 -107
- package/cjs/hooks/use-form-values/use-form-values.cjs.map +1 -1
- package/cjs/hooks/use-form-watch/use-form-watch.cjs +41 -57
- package/cjs/hooks/use-form-watch/use-form-watch.cjs.map +1 -1
- package/cjs/index.cjs +35 -38
- package/cjs/lists/change-error-indices.cjs +34 -41
- package/cjs/lists/change-error-indices.cjs.map +1 -1
- package/cjs/lists/clear-list-state.cjs +11 -15
- package/cjs/lists/clear-list-state.cjs.map +1 -1
- package/cjs/lists/reorder-errors.cjs +30 -32
- package/cjs/lists/reorder-errors.cjs.map +1 -1
- package/cjs/paths/get-data-path.cjs +6 -6
- package/cjs/paths/get-data-path.cjs.map +1 -1
- package/cjs/paths/get-path.cjs +14 -19
- package/cjs/paths/get-path.cjs.map +1 -1
- package/cjs/paths/get-splitted-path.cjs +7 -9
- package/cjs/paths/get-splitted-path.cjs.map +1 -1
- package/cjs/paths/insert-path.cjs +12 -15
- package/cjs/paths/insert-path.cjs.map +1 -1
- package/cjs/paths/remove-path.cjs +10 -17
- package/cjs/paths/remove-path.cjs.map +1 -1
- package/cjs/paths/reorder-path.cjs +14 -17
- package/cjs/paths/reorder-path.cjs.map +1 -1
- package/cjs/paths/replace-path.cjs +13 -18
- package/cjs/paths/replace-path.cjs.map +1 -1
- package/cjs/paths/set-path.cjs +22 -26
- package/cjs/paths/set-path.cjs.map +1 -1
- package/cjs/schema-resolver.cjs +24 -0
- package/cjs/schema-resolver.cjs.map +1 -0
- package/cjs/use-field.cjs +94 -131
- package/cjs/use-field.cjs.map +1 -1
- package/cjs/use-form.cjs +316 -379
- package/cjs/use-form.cjs.map +1 -1
- package/cjs/validate/get-rule-for-path.cjs +16 -24
- package/cjs/validate/get-rule-for-path.cjs.map +1 -1
- package/cjs/validate/should-validate-on-change.cjs +10 -17
- package/cjs/validate/should-validate-on-change.cjs.map +1 -1
- package/cjs/validate/validate-field-value.cjs +58 -54
- package/cjs/validate/validate-field-value.cjs.map +1 -1
- package/cjs/validate/validate-values.cjs +77 -108
- package/cjs/validate/validate-values.cjs.map +1 -1
- package/cjs/validators/has-length/has-length.cjs +17 -27
- package/cjs/validators/has-length/has-length.cjs.map +1 -1
- package/cjs/validators/is-email/is-email.cjs +7 -8
- package/cjs/validators/is-email/is-email.cjs.map +1 -1
- package/cjs/validators/is-in-range/is-in-range.cjs +13 -19
- package/cjs/validators/is-in-range/is-in-range.cjs.map +1 -1
- package/cjs/validators/is-json-string/is-json-string.cjs +15 -17
- package/cjs/validators/is-json-string/is-json-string.cjs.map +1 -1
- package/cjs/validators/is-not-empty/is-not-empty.cjs +13 -21
- package/cjs/validators/is-not-empty/is-not-empty.cjs.map +1 -1
- package/cjs/validators/is-not-empty-html/is-not-empty-html.cjs +11 -13
- package/cjs/validators/is-not-empty-html/is-not-empty-html.cjs.map +1 -1
- package/cjs/validators/is-one-of/is-one-of.cjs +9 -9
- package/cjs/validators/is-one-of/is-one-of.cjs.map +1 -1
- package/cjs/validators/is-url/is-url.cjs +25 -33
- package/cjs/validators/is-url/is-url.cjs.map +1 -1
- package/cjs/validators/matches/matches.cjs +10 -12
- package/cjs/validators/matches/matches.cjs.map +1 -1
- package/cjs/validators/matches-field/matches-field.cjs +10 -12
- package/cjs/validators/matches-field/matches-field.cjs.map +1 -1
- package/esm/FormProvider/FormProvider.mjs +25 -19
- package/esm/FormProvider/FormProvider.mjs.map +1 -1
- package/esm/actions/actions.mjs +85 -114
- package/esm/actions/actions.mjs.map +1 -1
- package/esm/form-index.mjs +5 -3
- package/esm/form-index.mjs.map +1 -1
- package/esm/get-input-on-change/get-input-on-change.mjs +15 -23
- package/esm/get-input-on-change/get-input-on-change.mjs.map +1 -1
- package/esm/get-status/get-status.mjs +11 -9
- package/esm/get-status/get-status.mjs.map +1 -1
- package/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs +11 -13
- package/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs.map +1 -1
- package/esm/hooks/use-form-errors/use-form-errors.mjs +38 -46
- package/esm/hooks/use-form-errors/use-form-errors.mjs.map +1 -1
- package/esm/hooks/use-form-list/use-form-list.mjs +46 -49
- package/esm/hooks/use-form-list/use-form-list.mjs.map +1 -1
- package/esm/hooks/use-form-status/use-form-status.mjs +93 -122
- package/esm/hooks/use-form-status/use-form-status.mjs.map +1 -1
- package/esm/hooks/use-form-validating/use-form-validating.mjs +48 -49
- package/esm/hooks/use-form-validating/use-form-validating.mjs.map +1 -1
- package/esm/hooks/use-form-values/use-form-values.mjs +91 -105
- package/esm/hooks/use-form-values/use-form-values.mjs.map +1 -1
- package/esm/hooks/use-form-watch/use-form-watch.mjs +40 -55
- package/esm/hooks/use-form-watch/use-form-watch.mjs.map +1 -1
- package/esm/index.mjs +18 -17
- package/esm/lists/change-error-indices.mjs +34 -39
- package/esm/lists/change-error-indices.mjs.map +1 -1
- package/esm/lists/clear-list-state.mjs +11 -13
- package/esm/lists/clear-list-state.mjs.map +1 -1
- package/esm/lists/reorder-errors.mjs +30 -30
- package/esm/lists/reorder-errors.mjs.map +1 -1
- package/esm/paths/get-data-path.mjs +6 -4
- package/esm/paths/get-data-path.mjs.map +1 -1
- package/esm/paths/get-path.mjs +14 -17
- package/esm/paths/get-path.mjs.map +1 -1
- package/esm/paths/get-splitted-path.mjs +7 -7
- package/esm/paths/get-splitted-path.mjs.map +1 -1
- package/esm/paths/insert-path.mjs +12 -13
- package/esm/paths/insert-path.mjs.map +1 -1
- package/esm/paths/remove-path.mjs +10 -15
- package/esm/paths/remove-path.mjs.map +1 -1
- package/esm/paths/reorder-path.mjs +14 -15
- package/esm/paths/reorder-path.mjs.map +1 -1
- package/esm/paths/replace-path.mjs +13 -16
- package/esm/paths/replace-path.mjs.map +1 -1
- package/esm/paths/set-path.mjs +21 -24
- package/esm/paths/set-path.mjs.map +1 -1
- package/esm/schema-resolver.mjs +24 -0
- package/esm/schema-resolver.mjs.map +1 -0
- package/esm/use-field.mjs +93 -129
- package/esm/use-field.mjs.map +1 -1
- package/esm/use-form.mjs +315 -377
- package/esm/use-form.mjs.map +1 -1
- package/esm/validate/get-rule-for-path.mjs +16 -22
- package/esm/validate/get-rule-for-path.mjs.map +1 -1
- package/esm/validate/should-validate-on-change.mjs +10 -15
- package/esm/validate/should-validate-on-change.mjs.map +1 -1
- package/esm/validate/validate-field-value.mjs +58 -52
- package/esm/validate/validate-field-value.mjs.map +1 -1
- package/esm/validate/validate-values.mjs +77 -106
- package/esm/validate/validate-values.mjs.map +1 -1
- package/esm/validators/has-length/has-length.mjs +17 -25
- package/esm/validators/has-length/has-length.mjs.map +1 -1
- package/esm/validators/is-email/is-email.mjs +7 -6
- package/esm/validators/is-email/is-email.mjs.map +1 -1
- package/esm/validators/is-in-range/is-in-range.mjs +13 -17
- package/esm/validators/is-in-range/is-in-range.mjs.map +1 -1
- package/esm/validators/is-json-string/is-json-string.mjs +15 -15
- package/esm/validators/is-json-string/is-json-string.mjs.map +1 -1
- package/esm/validators/is-not-empty/is-not-empty.mjs +13 -19
- package/esm/validators/is-not-empty/is-not-empty.mjs.map +1 -1
- package/esm/validators/is-not-empty-html/is-not-empty-html.mjs +11 -11
- package/esm/validators/is-not-empty-html/is-not-empty-html.mjs.map +1 -1
- package/esm/validators/is-one-of/is-one-of.mjs +9 -7
- package/esm/validators/is-one-of/is-one-of.mjs.map +1 -1
- package/esm/validators/is-url/is-url.mjs +25 -31
- package/esm/validators/is-url/is-url.mjs.map +1 -1
- package/esm/validators/matches/matches.mjs +10 -10
- package/esm/validators/matches/matches.mjs.map +1 -1
- package/esm/validators/matches-field/matches-field.mjs +10 -10
- package/esm/validators/matches-field/matches-field.mjs.map +1 -1
- package/lib/hooks/use-form-status/use-form-status.d.ts +2 -2
- package/lib/hooks/use-form-values/use-form-values.d.ts +9 -9
- package/lib/hooks/use-form-watch/use-form-watch.d.ts +5 -5
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/schema-resolver.d.ts +5 -0
- package/lib/types.d.ts +19 -18
- package/package.json +5 -1
- package/cjs/index.cjs.map +0 -1
- package/esm/index.mjs.map +0 -1
package/cjs/index.cjs
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.useField = useField.useField;
|
|
37
|
-
exports.formRootRule = validateValues.formRootRule;
|
|
38
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_actions = require("./actions/actions.cjs");
|
|
3
|
+
const require_validate_values = require("./validate/validate-values.cjs");
|
|
4
|
+
const require_form_index = require("./form-index.cjs");
|
|
5
|
+
const require_use_form = require("./use-form.cjs");
|
|
6
|
+
const require_FormProvider = require("./FormProvider/FormProvider.cjs");
|
|
7
|
+
const require_is_not_empty = require("./validators/is-not-empty/is-not-empty.cjs");
|
|
8
|
+
const require_matches = require("./validators/matches/matches.cjs");
|
|
9
|
+
const require_is_email = require("./validators/is-email/is-email.cjs");
|
|
10
|
+
const require_has_length = require("./validators/has-length/has-length.cjs");
|
|
11
|
+
const require_is_in_range = require("./validators/is-in-range/is-in-range.cjs");
|
|
12
|
+
const require_matches_field = require("./validators/matches-field/matches-field.cjs");
|
|
13
|
+
const require_is_not_empty_html = require("./validators/is-not-empty-html/is-not-empty-html.cjs");
|
|
14
|
+
const require_is_json_string = require("./validators/is-json-string/is-json-string.cjs");
|
|
15
|
+
const require_is_url = require("./validators/is-url/is-url.cjs");
|
|
16
|
+
const require_is_one_of = require("./validators/is-one-of/is-one-of.cjs");
|
|
17
|
+
const require_use_field = require("./use-field.cjs");
|
|
18
|
+
const require_schema_resolver = require("./schema-resolver.cjs");
|
|
19
|
+
exports.FORM_INDEX = require_form_index.FORM_INDEX;
|
|
20
|
+
exports.createFormActions = require_actions.createFormActions;
|
|
21
|
+
exports.createFormContext = require_FormProvider.createFormContext;
|
|
22
|
+
exports.formRootRule = require_validate_values.formRootRule;
|
|
23
|
+
exports.hasLength = require_has_length.hasLength;
|
|
24
|
+
exports.isEmail = require_is_email.isEmail;
|
|
25
|
+
exports.isInRange = require_is_in_range.isInRange;
|
|
26
|
+
exports.isJSONString = require_is_json_string.isJSONString;
|
|
27
|
+
exports.isNotEmpty = require_is_not_empty.isNotEmpty;
|
|
28
|
+
exports.isNotEmptyHTML = require_is_not_empty_html.isNotEmptyHTML;
|
|
29
|
+
exports.isOneOf = require_is_one_of.isOneOf;
|
|
30
|
+
exports.isUrl = require_is_url.isUrl;
|
|
31
|
+
exports.matches = require_matches.matches;
|
|
32
|
+
exports.matchesField = require_matches_field.matchesField;
|
|
33
|
+
exports.schemaResolver = require_schema_resolver.schemaResolver;
|
|
34
|
+
exports.useField = require_use_field.useField;
|
|
35
|
+
exports.useForm = require_use_form.useForm;
|
|
@@ -1,46 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_clear_list_state = require("./clear-list-state.cjs");
|
|
3
|
+
//#region packages/@mantine/form/src/lists/change-error-indices.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gets the part of the key after the path which can be an index
|
|
6
|
+
*/
|
|
6
7
|
function getIndexFromKeyAfterPath(key, path) {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const split = key.substring(path.length + 1).split(".")[0];
|
|
9
|
+
return parseInt(split, 10);
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Changes the indices of every error that is after the given `index` with the given `change` at the given `path`.
|
|
13
|
+
* This requires that the errors are in the format of `path.index` and that the index is a number.
|
|
14
|
+
*/
|
|
10
15
|
function changeErrorIndices(path, index, errors, change) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}).forEach(([key, value]) => {
|
|
31
|
-
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
32
|
-
const newKey = key.replace(
|
|
33
|
-
`${pathString}.${currIndex}`,
|
|
34
|
-
`${pathString}.${currIndex + change}`
|
|
35
|
-
);
|
|
36
|
-
cloned[newKey] = value;
|
|
37
|
-
changedKeys.add(newKey);
|
|
38
|
-
if (!changedKeys.has(key)) {
|
|
39
|
-
delete cloned[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return cloned;
|
|
16
|
+
if (index === void 0) return errors;
|
|
17
|
+
const pathString = `${String(path)}`;
|
|
18
|
+
let clearedErrors = errors;
|
|
19
|
+
if (change === -1) clearedErrors = require_clear_list_state.clearListState(`${pathString}.${index}`, clearedErrors);
|
|
20
|
+
const cloned = { ...clearedErrors };
|
|
21
|
+
const changedKeys = /* @__PURE__ */ new Set();
|
|
22
|
+
Object.entries(clearedErrors).filter(([key]) => {
|
|
23
|
+
if (!key.startsWith(`${pathString}.`)) return false;
|
|
24
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
25
|
+
if (Number.isNaN(currIndex)) return false;
|
|
26
|
+
return currIndex >= index;
|
|
27
|
+
}).forEach(([key, value]) => {
|
|
28
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
29
|
+
const newKey = key.replace(`${pathString}.${currIndex}`, `${pathString}.${currIndex + change}`);
|
|
30
|
+
cloned[newKey] = value;
|
|
31
|
+
changedKeys.add(newKey);
|
|
32
|
+
if (!changedKeys.has(key)) delete cloned[key];
|
|
33
|
+
});
|
|
34
|
+
return cloned;
|
|
43
35
|
}
|
|
44
|
-
|
|
36
|
+
//#endregion
|
|
45
37
|
exports.changeErrorIndices = changeErrorIndices;
|
|
46
|
-
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=change-error-indices.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-error-indices.cjs","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"],"
|
|
1
|
+
{"version":3,"file":"change-error-indices.cjs","names":["clearListState"],"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"],"mappings":";;;;;;AAKA,SAAS,yBAAyB,KAAa,MAAsB;CACnE,MAAM,QAAQ,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC;AACxD,QAAO,SAAS,OAAO,GAAG;;;;;;AAO5B,SAAgB,mBACd,MACA,OACA,QACA,QACG;AACH,KAAI,UAAU,KAAA,EACZ,QAAO;CAET,MAAM,aAAa,GAAG,OAAO,KAAK;CAClC,IAAI,gBAAgB;AAEpB,KAAI,WAAW,GACb,iBAAgBA,yBAAAA,eAAe,GAAG,WAAW,GAAG,SAAS,cAAc;CAGzE,MAAM,SAAS,EAAE,GAAG,eAAe;CACnC,MAAM,8BAAc,IAAI,KAAa;AACrC,QAAO,QAAQ,cAAc,CAC1B,QAAQ,CAAC,SAAS;AACjB,MAAI,CAAC,IAAI,WAAW,GAAG,WAAW,GAAG,CACnC,QAAO;EAET,MAAM,YAAY,yBAAyB,KAAK,WAAW;AAC3D,MAAI,OAAO,MAAM,UAAU,CACzB,QAAO;AAET,SAAO,aAAa;GACpB,CACD,SAAS,CAAC,KAAK,WAAW;EACzB,MAAM,YAAY,yBAAyB,KAAK,WAAW;EAE3D,MAAM,SAAkB,IAAI,QAC1B,GAAG,WAAW,GAAG,aACjB,GAAG,WAAW,GAAG,YAAY,SAC9B;AACD,SAAO,UAAU;AACjB,cAAY,IAAI,OAAO;AACvB,MAAI,CAAC,YAAY,IAAI,IAAI,CACvB,QAAO,OAAO;GAEhB;AAEJ,QAAO"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/form/src/lists/clear-list-state.ts
|
|
4
3
|
function clearListState(field, state) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
delete clone[errorKey];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return clone;
|
|
4
|
+
if (state === null || typeof state !== "object") return {};
|
|
5
|
+
const clone = { ...state };
|
|
6
|
+
Object.keys(state).forEach((errorKey) => {
|
|
7
|
+
if (errorKey.includes(`${String(field)}.`)) delete clone[errorKey];
|
|
8
|
+
});
|
|
9
|
+
return clone;
|
|
15
10
|
}
|
|
16
|
-
|
|
11
|
+
//#endregion
|
|
17
12
|
exports.clearListState = clearListState;
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=clear-list-state.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear-list-state.cjs","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"],"
|
|
1
|
+
{"version":3,"file":"clear-list-state.cjs","names":[],"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"],"mappings":";;AAAA,SAAgB,eACd,OACA,OACG;AACH,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO,EAAE;CAGX,MAAM,QAAQ,EAAE,GAAG,OAAO;AAC1B,QAAO,KAAK,MAAM,CAAC,SAAS,aAAa;AACvC,MAAI,SAAS,SAAS,GAAG,OAAO,MAAM,CAAC,GAAG,CACxC,QAAO,MAAM;GAEf;AAEF,QAAO"}
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/form/src/lists/reorder-errors.ts
|
|
4
3
|
function reorderErrors(path, { from, to }, errors) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
return clone;
|
|
4
|
+
const oldKeyStart = `${path}.${from}`;
|
|
5
|
+
const newKeyStart = `${path}.${to}`;
|
|
6
|
+
const clone = { ...errors };
|
|
7
|
+
const processedKeys = /* @__PURE__ */ new Set();
|
|
8
|
+
Object.keys(errors).forEach((key) => {
|
|
9
|
+
if (processedKeys.has(key)) return;
|
|
10
|
+
let oldKey;
|
|
11
|
+
let newKey;
|
|
12
|
+
if (key.startsWith(oldKeyStart)) {
|
|
13
|
+
oldKey = key;
|
|
14
|
+
newKey = key.replace(oldKeyStart, newKeyStart);
|
|
15
|
+
} else if (key.startsWith(newKeyStart)) {
|
|
16
|
+
oldKey = key.replace(newKeyStart, oldKeyStart);
|
|
17
|
+
newKey = key;
|
|
18
|
+
}
|
|
19
|
+
if (oldKey && newKey) {
|
|
20
|
+
const value1 = clone[oldKey];
|
|
21
|
+
const value2 = clone[newKey];
|
|
22
|
+
value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
|
|
23
|
+
value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
|
|
24
|
+
processedKeys.add(oldKey);
|
|
25
|
+
processedKeys.add(newKey);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return clone;
|
|
32
29
|
}
|
|
33
|
-
|
|
30
|
+
//#endregion
|
|
34
31
|
exports.reorderErrors = reorderErrors;
|
|
35
|
-
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=reorder-errors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reorder-errors.cjs","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 const processedKeys = new Set<string>();\n\n Object.keys(errors as any).forEach((key) => {\n if (processedKeys.has(key)) {\n return;\n }\n\n let oldKey;\n let newKey;\n\n if (key.startsWith(oldKeyStart)) {\n oldKey = key;\n newKey = key.replace(oldKeyStart, newKeyStart);\n } else if (key.startsWith(newKeyStart)) {\n oldKey = key.replace(newKeyStart, oldKeyStart);\n newKey = key;\n }\n\n if (oldKey && newKey) {\n const value1 = clone[oldKey];\n const value2 = clone[newKey];\n\n value2 === undefined ? delete clone[oldKey] : (clone[oldKey] = value2);\n value1 === undefined ? delete clone[newKey] : (clone[newKey] = value1);\n\n processedKeys.add(oldKey);\n processedKeys.add(newKey);\n }\n });\n\n return clone;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"reorder-errors.cjs","names":[],"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 const processedKeys = new Set<string>();\n\n Object.keys(errors as any).forEach((key) => {\n if (processedKeys.has(key)) {\n return;\n }\n\n let oldKey;\n let newKey;\n\n if (key.startsWith(oldKeyStart)) {\n oldKey = key;\n newKey = key.replace(oldKeyStart, newKeyStart);\n } else if (key.startsWith(newKeyStart)) {\n oldKey = key.replace(newKeyStart, oldKeyStart);\n newKey = key;\n }\n\n if (oldKey && newKey) {\n const value1 = clone[oldKey];\n const value2 = clone[newKey];\n\n value2 === undefined ? delete clone[oldKey] : (clone[oldKey] = value2);\n value1 === undefined ? delete clone[newKey] : (clone[newKey] = value1);\n\n processedKeys.add(oldKey);\n processedKeys.add(newKey);\n }\n });\n\n return clone;\n}\n"],"mappings":";;AAEA,SAAgB,cAAiB,MAAe,EAAE,MAAM,MAAsB,QAAc;CAC1F,MAAM,cAAc,GAAG,KAAK,GAAG;CAC/B,MAAM,cAAc,GAAG,KAAK,GAAG;CAE/B,MAAM,QAAa,EAAE,GAAG,QAAQ;CAChC,MAAM,gCAAgB,IAAI,KAAa;AAEvC,QAAO,KAAK,OAAc,CAAC,SAAS,QAAQ;AAC1C,MAAI,cAAc,IAAI,IAAI,CACxB;EAGF,IAAI;EACJ,IAAI;AAEJ,MAAI,IAAI,WAAW,YAAY,EAAE;AAC/B,YAAS;AACT,YAAS,IAAI,QAAQ,aAAa,YAAY;aACrC,IAAI,WAAW,YAAY,EAAE;AACtC,YAAS,IAAI,QAAQ,aAAa,YAAY;AAC9C,YAAS;;AAGX,MAAI,UAAU,QAAQ;GACpB,MAAM,SAAS,MAAM;GACrB,MAAM,SAAS,MAAM;AAErB,cAAW,KAAA,IAAY,OAAO,MAAM,UAAW,MAAM,UAAU;AAC/D,cAAW,KAAA,IAAY,OAAO,MAAM,UAAW,MAAM,UAAU;AAE/D,iBAAc,IAAI,OAAO;AACzB,iBAAc,IAAI,OAAO;;GAE3B;AAEF,QAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/form/src/paths/get-data-path.ts
|
|
4
3
|
function getDataPath(formName, fieldPath) {
|
|
5
|
-
|
|
4
|
+
return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();
|
|
6
5
|
}
|
|
7
|
-
|
|
6
|
+
//#endregion
|
|
8
7
|
exports.getDataPath = getDataPath;
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=get-data-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-data-path.cjs","sources":["../../src/paths/get-data-path.ts"],"sourcesContent":["export function getDataPath(formName: string | undefined, fieldPath: PropertyKey) {\n return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();\n}\n"],"
|
|
1
|
+
{"version":3,"file":"get-data-path.cjs","names":[],"sources":["../../src/paths/get-data-path.ts"],"sourcesContent":["export function getDataPath(formName: string | undefined, fieldPath: PropertyKey) {\n return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();\n}\n"],"mappings":";;AAAA,SAAgB,YAAY,UAA8B,WAAwB;AAChF,QAAO,WAAW,GAAG,SAAS,GAAG,UAAU,UAAU,KAAK,UAAU,UAAU"}
|
package/cjs/paths/get-path.cjs
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var getSplittedPath = require('./get-splitted-path.cjs');
|
|
5
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_splitted_path = require("./get-splitted-path.cjs");
|
|
3
|
+
//#region packages/@mantine/form/src/paths/get-path.ts
|
|
6
4
|
function getPath(path, values) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
value = value[splittedPath[i]];
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
5
|
+
const splittedPath = require_get_splitted_path.getSplittedPath(path);
|
|
6
|
+
if (splittedPath.length === 0 || typeof values !== "object" || values === null) return;
|
|
7
|
+
let value = values[splittedPath[0]];
|
|
8
|
+
for (let i = 1; i < splittedPath.length; i += 1) {
|
|
9
|
+
if (value == null) break;
|
|
10
|
+
value = value[splittedPath[i]];
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
19
13
|
}
|
|
20
|
-
|
|
14
|
+
//#endregion
|
|
21
15
|
exports.getPath = getPath;
|
|
22
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=get-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-path.cjs","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 == null) {\n break;\n }\n\n value = value[splittedPath[i]];\n }\n\n return value;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"get-path.cjs","names":["getSplittedPath"],"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 == null) {\n break;\n }\n\n value = value[splittedPath[i]];\n }\n\n return value;\n}\n"],"mappings":";;;AAEA,SAAgB,QAAQ,MAAe,QAA0B;CAC/D,MAAM,eAAeA,0BAAAA,gBAAgB,KAAK;AAE1C,KAAI,aAAa,WAAW,KAAK,OAAO,WAAW,YAAY,WAAW,KACxE;CAGF,IAAI,QAAQ,OAAO,aAAa;AAChC,MAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAAG;AAC/C,MAAI,SAAS,KACX;AAGF,UAAQ,MAAM,aAAa;;AAG7B,QAAO"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/form/src/paths/get-splitted-path.ts
|
|
4
3
|
function getSplittedPath(path) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return path.split(".");
|
|
4
|
+
if (typeof path !== "string") return [];
|
|
5
|
+
return path.split(".");
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
//#endregion
|
|
11
8
|
exports.getSplittedPath = getSplittedPath;
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=get-splitted-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-splitted-path.cjs","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"],"
|
|
1
|
+
{"version":3,"file":"get-splitted-path.cjs","names":[],"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"],"mappings":";;AAAA,SAAgB,gBAAgB,MAAe;AAC7C,KAAI,OAAO,SAAS,SAClB,QAAO,EAAE;AAGX,QAAO,KAAK,MAAM,IAAI"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var setPath = require('./set-path.cjs');
|
|
6
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_path = require("./get-path.cjs");
|
|
3
|
+
const require_set_path = require("./set-path.cjs");
|
|
4
|
+
//#region packages/@mantine/form/src/paths/insert-path.ts
|
|
7
5
|
function insertPath(path, value, index, values) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
|
|
14
|
-
return setPath.setPath(path, cloned, values);
|
|
6
|
+
const currentValue = require_get_path.getPath(path, values);
|
|
7
|
+
if (!Array.isArray(currentValue)) return values;
|
|
8
|
+
const cloned = [...currentValue];
|
|
9
|
+
cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
|
|
10
|
+
return require_set_path.setPath(path, cloned, values);
|
|
15
11
|
}
|
|
16
|
-
|
|
12
|
+
//#endregion
|
|
17
13
|
exports.insertPath = insertPath;
|
|
18
|
-
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=insert-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert-path.cjs","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"],"
|
|
1
|
+
{"version":3,"file":"insert-path.cjs","names":["getPath","setPath"],"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"],"mappings":";;;;AAGA,SAAgB,WAAc,MAAe,OAAgB,OAA2B,QAAW;CACjG,MAAM,eAAeA,iBAAAA,QAAQ,MAAM,OAAO;AAE1C,KAAI,CAAC,MAAM,QAAQ,aAAa,CAC9B,QAAO;CAGT,MAAM,SAAS,CAAC,GAAG,aAAa;AAChC,QAAO,OAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,QAAQ,GAAG,MAAM;AAE1E,QAAOC,iBAAAA,QAAQ,MAAM,QAAQ,OAAO"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var setPath = require('./set-path.cjs');
|
|
6
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_path = require("./get-path.cjs");
|
|
3
|
+
const require_set_path = require("./set-path.cjs");
|
|
4
|
+
//#region packages/@mantine/form/src/paths/remove-path.ts
|
|
7
5
|
function removePath(path, index, values) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return setPath.setPath(
|
|
13
|
-
path,
|
|
14
|
-
currentValue.filter((_, itemIndex) => itemIndex !== index),
|
|
15
|
-
values
|
|
16
|
-
);
|
|
6
|
+
const currentValue = require_get_path.getPath(path, values);
|
|
7
|
+
if (!Array.isArray(currentValue)) return values;
|
|
8
|
+
return require_set_path.setPath(path, currentValue.filter((_, itemIndex) => itemIndex !== index), values);
|
|
17
9
|
}
|
|
18
|
-
|
|
10
|
+
//#endregion
|
|
19
11
|
exports.removePath = removePath;
|
|
20
|
-
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=remove-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-path.cjs","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"],"
|
|
1
|
+
{"version":3,"file":"remove-path.cjs","names":["getPath","setPath"],"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"],"mappings":";;;;AAGA,SAAgB,WAAc,MAAe,OAAe,QAAW;CACrE,MAAM,eAAeA,iBAAAA,QAAQ,MAAM,OAAO;AAE1C,KAAI,CAAC,MAAM,QAAQ,aAAa,CAC9B,QAAO;AAGT,QAAOC,iBAAAA,QACL,MACA,aAAa,QAAQ,GAAG,cAAc,cAAc,MAAM,EAC1D,OACD"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var setPath = require('./set-path.cjs');
|
|
6
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_path = require("./get-path.cjs");
|
|
3
|
+
const require_set_path = require("./set-path.cjs");
|
|
4
|
+
//#region packages/@mantine/form/src/paths/reorder-path.ts
|
|
7
5
|
function reorderPath(path, { from, to }, values) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
cloned.splice(to, 0, item);
|
|
16
|
-
return setPath.setPath(path, cloned, values);
|
|
6
|
+
const currentValue = require_get_path.getPath(path, values);
|
|
7
|
+
if (!Array.isArray(currentValue)) return values;
|
|
8
|
+
const cloned = [...currentValue];
|
|
9
|
+
const item = currentValue[from];
|
|
10
|
+
cloned.splice(from, 1);
|
|
11
|
+
cloned.splice(to, 0, item);
|
|
12
|
+
return require_set_path.setPath(path, cloned, values);
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
//#endregion
|
|
19
15
|
exports.reorderPath = reorderPath;
|
|
20
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=reorder-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reorder-path.cjs","sources":["../../src/paths/reorder-path.ts"],"sourcesContent":["import { ReorderPayload } from '../types';\nimport { getPath } from './get-path';\nimport { setPath } from './set-path';\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"],"
|
|
1
|
+
{"version":3,"file":"reorder-path.cjs","names":["getPath","setPath"],"sources":["../../src/paths/reorder-path.ts"],"sourcesContent":["import { ReorderPayload } from '../types';\nimport { getPath } from './get-path';\nimport { setPath } from './set-path';\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"],"mappings":";;;;AAIA,SAAgB,YAAe,MAAe,EAAE,MAAM,MAAsB,QAAW;CACrF,MAAM,eAAeA,iBAAAA,QAAQ,MAAM,OAAO;AAE1C,KAAI,CAAC,MAAM,QAAQ,aAAa,CAC9B,QAAO;CAGT,MAAM,SAAS,CAAC,GAAG,aAAa;CAChC,MAAM,OAAO,aAAa;AAC1B,QAAO,OAAO,MAAM,EAAE;AACtB,QAAO,OAAO,IAAI,GAAG,KAAK;AAE1B,QAAOC,iBAAAA,QAAQ,MAAM,QAAQ,OAAO"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var setPath = require('./set-path.cjs');
|
|
6
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_path = require("./get-path.cjs");
|
|
3
|
+
const require_set_path = require("./set-path.cjs");
|
|
4
|
+
//#region packages/@mantine/form/src/paths/replace-path.ts
|
|
7
5
|
function replacePath(path, item, index, values) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const cloned = [...currentValue];
|
|
16
|
-
cloned[index] = item;
|
|
17
|
-
return setPath.setPath(path, cloned, values);
|
|
6
|
+
const currentValue = require_get_path.getPath(path, values);
|
|
7
|
+
if (!Array.isArray(currentValue)) return values;
|
|
8
|
+
if (currentValue.length <= index) return values;
|
|
9
|
+
const cloned = [...currentValue];
|
|
10
|
+
cloned[index] = item;
|
|
11
|
+
return require_set_path.setPath(path, cloned, values);
|
|
18
12
|
}
|
|
19
|
-
|
|
13
|
+
//#endregion
|
|
20
14
|
exports.replacePath = replacePath;
|
|
21
|
-
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=replace-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-path.cjs","sources":["../../src/paths/replace-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function replacePath<T>(path: unknown, item: unknown, index: number, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n if (currentValue.length <= index) {\n return values;\n }\n\n const cloned = [...currentValue];\n cloned[index] = item;\n\n return setPath(path, cloned, values);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"replace-path.cjs","names":["getPath","setPath"],"sources":["../../src/paths/replace-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function replacePath<T>(path: unknown, item: unknown, index: number, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n if (currentValue.length <= index) {\n return values;\n }\n\n const cloned = [...currentValue];\n cloned[index] = item;\n\n return setPath(path, cloned, values);\n}\n"],"mappings":";;;;AAGA,SAAgB,YAAe,MAAe,MAAe,OAAe,QAAW;CACrF,MAAM,eAAeA,iBAAAA,QAAQ,MAAM,OAAO;AAE1C,KAAI,CAAC,MAAM,QAAQ,aAAa,CAC9B,QAAO;AAGT,KAAI,aAAa,UAAU,MACzB,QAAO;CAGT,MAAM,SAAS,CAAC,GAAG,aAAa;AAChC,QAAO,SAAS;AAEhB,QAAOC,iBAAAA,QAAQ,MAAM,QAAQ,OAAO"}
|