@strapi/plugin-users-permissions 5.0.0-beta.11 → 5.0.0-beta.12

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 (27) hide show
  1. package/dist/_chunks/{index-DPPPDM5v.mjs → index-B1Ye9y8X.mjs} +2 -2
  2. package/dist/_chunks/{index-DPPPDM5v.mjs.map → index-B1Ye9y8X.mjs.map} +1 -1
  3. package/dist/_chunks/{index-xP-F2lwk.mjs → index-BTZg2YpL.mjs} +3 -3
  4. package/dist/_chunks/{index-xP-F2lwk.mjs.map → index-BTZg2YpL.mjs.map} +1 -1
  5. package/dist/_chunks/{index-C61Rq3Wy.js → index-B_fbKBz0.js} +7 -7
  6. package/dist/_chunks/{index-C61Rq3Wy.js.map → index-B_fbKBz0.js.map} +1 -1
  7. package/dist/_chunks/{index-C5qelx5h.js → index-BiAaeYqd.js} +8 -8
  8. package/dist/_chunks/{index-C5qelx5h.js.map → index-BiAaeYqd.js.map} +1 -1
  9. package/dist/_chunks/{index--GpG6tLA.js → index-Cu1MsLGr.js} +4 -4
  10. package/dist/_chunks/{index--GpG6tLA.js.map → index-Cu1MsLGr.js.map} +1 -1
  11. package/dist/_chunks/{index-CulAxKsW.js → index-JDJf0B7o.js} +2 -2
  12. package/dist/_chunks/{index-CulAxKsW.js.map → index-JDJf0B7o.js.map} +1 -1
  13. package/dist/_chunks/{index-CeYJys9a.mjs → index-KWQW0UGL.mjs} +8 -8
  14. package/dist/_chunks/{index-CeYJys9a.mjs.map → index-KWQW0UGL.mjs.map} +1 -1
  15. package/dist/_chunks/{index-C5U4ePo7.mjs → index-YCe-Gvk8.mjs} +2 -2
  16. package/dist/_chunks/{index-C5U4ePo7.mjs.map → index-YCe-Gvk8.mjs.map} +1 -1
  17. package/dist/_chunks/{index-UMWzcJhY.js → index-iSYNFhBE.js} +2 -2
  18. package/dist/_chunks/{index-UMWzcJhY.js.map → index-iSYNFhBE.js.map} +1 -1
  19. package/dist/_chunks/{index-_80225_r.mjs → index-kKZJwfmD.mjs} +3 -3
  20. package/dist/_chunks/{index-_80225_r.mjs.map → index-kKZJwfmD.mjs.map} +1 -1
  21. package/dist/_chunks/{index-7Wlj8eA7-7OWx8SwS.js → index-wHs6nj5s-CEl8tdQF.js} +35 -6
  22. package/dist/_chunks/{index-7Wlj8eA7-7OWx8SwS.js.map → index-wHs6nj5s-CEl8tdQF.js.map} +1 -1
  23. package/dist/_chunks/{index-7Wlj8eA7-DHTckV6T.mjs → index-wHs6nj5s-XtTr6Gs9.mjs} +35 -6
  24. package/dist/_chunks/{index-7Wlj8eA7-DHTckV6T.mjs.map → index-wHs6nj5s-XtTr6Gs9.mjs.map} +1 -1
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +1 -1
  27. 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 error = useForm("useField", (state) => getIn(state.errors, path));
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 MesaageDescriptor, so we need to handle both cases.
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-7Wlj8eA7-DHTckV6T.mjs.map
11478
+ //# sourceMappingURL=index-wHs6nj5s-XtTr6Gs9.mjs.map