@strapi/plugin-users-permissions 5.0.0-beta.11 → 5.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{index-CulAxKsW.js → index-BTZsAlY2.js} +2 -2
- package/dist/_chunks/{index-CulAxKsW.js.map → index-BTZsAlY2.js.map} +1 -1
- package/dist/_chunks/{index-C61Rq3Wy.js → index-CW0a6j0J.js} +7 -7
- package/dist/_chunks/{index-C61Rq3Wy.js.map → index-CW0a6j0J.js.map} +1 -1
- package/dist/_chunks/{index-_80225_r.mjs → index-CneVePmG.mjs} +3 -3
- package/dist/_chunks/{index-_80225_r.mjs.map → index-CneVePmG.mjs.map} +1 -1
- package/dist/_chunks/{index--GpG6tLA.js → index-CtB48krf.js} +4 -4
- package/dist/_chunks/{index--GpG6tLA.js.map → index-CtB48krf.js.map} +1 -1
- package/dist/_chunks/{index-DPPPDM5v.mjs → index-DVrbA-Qn.mjs} +2 -2
- package/dist/_chunks/{index-DPPPDM5v.mjs.map → index-DVrbA-Qn.mjs.map} +1 -1
- package/dist/_chunks/{index-CeYJys9a.mjs → index-D_vo9Bc-.mjs} +8 -8
- package/dist/_chunks/{index-CeYJys9a.mjs.map → index-D_vo9Bc-.mjs.map} +1 -1
- package/dist/_chunks/{index-C5qelx5h.js → index-DeU2suDQ.js} +8 -8
- package/dist/_chunks/{index-C5qelx5h.js.map → index-DeU2suDQ.js.map} +1 -1
- package/dist/_chunks/{index-7Wlj8eA7-7OWx8SwS.js → index-PwwSuHm0-CEl8tdQF.js} +35 -6
- package/dist/_chunks/{index-7Wlj8eA7-7OWx8SwS.js.map → index-PwwSuHm0-CEl8tdQF.js.map} +1 -1
- package/dist/_chunks/{index-7Wlj8eA7-DHTckV6T.mjs → index-PwwSuHm0-XtTr6Gs9.mjs} +35 -6
- package/dist/_chunks/{index-7Wlj8eA7-DHTckV6T.mjs.map → index-PwwSuHm0-XtTr6Gs9.mjs.map} +1 -1
- package/dist/_chunks/{index-UMWzcJhY.js → index-XRC2Nh3R.js} +2 -2
- package/dist/_chunks/{index-UMWzcJhY.js.map → index-XRC2Nh3R.js.map} +1 -1
- package/dist/_chunks/{index-xP-F2lwk.mjs → index-a0Cfu2WU.mjs} +3 -3
- package/dist/_chunks/{index-xP-F2lwk.mjs.map → index-a0Cfu2WU.mjs.map} +1 -1
- package/dist/_chunks/{index-C5U4ePo7.mjs → index-lBBcBGDb.mjs} +2 -2
- package/dist/_chunks/{index-C5U4ePo7.mjs.map → index-lBBcBGDb.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/package.json +4 -4
|
@@ -10169,11 +10169,11 @@ const [FormProvider, useForm] = createContext("Form", {
|
|
|
10169
10169
|
values: {}
|
|
10170
10170
|
});
|
|
10171
10171
|
React.forwardRef(
|
|
10172
|
-
({ disabled = false, method, onSubmit, ...props }, ref) => {
|
|
10172
|
+
({ disabled = false, method, onSubmit, initialErrors, ...props }, ref) => {
|
|
10173
10173
|
const formRef = React.useRef(null);
|
|
10174
10174
|
const initialValues = React.useRef(props.initialValues ?? {});
|
|
10175
10175
|
const [state, dispatch] = React.useReducer(reducer, {
|
|
10176
|
-
errors: {},
|
|
10176
|
+
errors: initialErrors ?? {},
|
|
10177
10177
|
isSubmitting: false,
|
|
10178
10178
|
values: props.initialValues ?? {}
|
|
10179
10179
|
});
|
|
@@ -10511,11 +10511,40 @@ const useField = (path) => {
|
|
|
10511
10511
|
(state) => getIn(state.values, path)
|
|
10512
10512
|
);
|
|
10513
10513
|
const handleChange = useForm("useField", (state) => state.onChange);
|
|
10514
|
-
const
|
|
10514
|
+
const formatNestedErrorMessages = (stateErrors) => {
|
|
10515
|
+
const nestedErrors = {};
|
|
10516
|
+
Object.entries(stateErrors).forEach(([key, value2]) => {
|
|
10517
|
+
let current = nestedErrors;
|
|
10518
|
+
const pathParts = key.split(".");
|
|
10519
|
+
pathParts.forEach((part, index) => {
|
|
10520
|
+
const isLastPart = index === pathParts.length - 1;
|
|
10521
|
+
if (isLastPart) {
|
|
10522
|
+
if (typeof value2 === "string") {
|
|
10523
|
+
current[part] = value2;
|
|
10524
|
+
} else if (isErrorMessageDescriptor(value2)) {
|
|
10525
|
+
current[part] = formatMessage(value2);
|
|
10526
|
+
} else {
|
|
10527
|
+
setIn(current, part, value2);
|
|
10528
|
+
}
|
|
10529
|
+
} else {
|
|
10530
|
+
if (!current[part]) {
|
|
10531
|
+
const isArray2 = !isNaN(Number(pathParts[index + 1]));
|
|
10532
|
+
current[part] = isArray2 ? [] : {};
|
|
10533
|
+
}
|
|
10534
|
+
current = current[part];
|
|
10535
|
+
}
|
|
10536
|
+
});
|
|
10537
|
+
});
|
|
10538
|
+
return nestedErrors;
|
|
10539
|
+
};
|
|
10540
|
+
const error = useForm(
|
|
10541
|
+
"useField",
|
|
10542
|
+
(state) => getIn(formatNestedErrorMessages(state.errors), path)
|
|
10543
|
+
);
|
|
10515
10544
|
return {
|
|
10516
10545
|
initialValue,
|
|
10517
10546
|
/**
|
|
10518
|
-
* Errors can be a string, or a
|
|
10547
|
+
* Errors can be a string, or a MessageDescriptor, so we need to handle both cases.
|
|
10519
10548
|
* If it's anything else, we don't return it.
|
|
10520
10549
|
*/
|
|
10521
10550
|
error: isErrorMessageDescriptor(error) ? formatMessage(
|
|
@@ -10530,7 +10559,7 @@ const useField = (path) => {
|
|
|
10530
10559
|
};
|
|
10531
10560
|
};
|
|
10532
10561
|
const isErrorMessageDescriptor = (object) => {
|
|
10533
|
-
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
|
10562
|
+
return typeof object === "object" && object !== null && !Array.isArray(object) && "id" in object && "defaultMessage" in object;
|
|
10534
10563
|
};
|
|
10535
10564
|
const useFocusInputField = (name) => {
|
|
10536
10565
|
const { search: searchString } = useLocation();
|
|
@@ -11446,4 +11475,4 @@ export {
|
|
|
11446
11475
|
Layouts as L,
|
|
11447
11476
|
useTracking as u
|
|
11448
11477
|
};
|
|
11449
|
-
//# sourceMappingURL=index-
|
|
11478
|
+
//# sourceMappingURL=index-PwwSuHm0-XtTr6Gs9.mjs.map
|