@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
@@ -10195,11 +10195,11 @@ const [FormProvider, useForm] = createContext("Form", {
10195
10195
  values: {}
10196
10196
  });
10197
10197
  React__namespace.forwardRef(
10198
- ({ disabled = false, method, onSubmit, ...props }, ref) => {
10198
+ ({ disabled = false, method, onSubmit, initialErrors, ...props }, ref) => {
10199
10199
  const formRef = React__namespace.useRef(null);
10200
10200
  const initialValues = React__namespace.useRef(props.initialValues ?? {});
10201
10201
  const [state, dispatch] = React__namespace.useReducer(reducer, {
10202
- errors: {},
10202
+ errors: initialErrors ?? {},
10203
10203
  isSubmitting: false,
10204
10204
  values: props.initialValues ?? {}
10205
10205
  });
@@ -10537,11 +10537,40 @@ const useField = (path) => {
10537
10537
  (state) => getIn(state.values, path)
10538
10538
  );
10539
10539
  const handleChange = useForm("useField", (state) => state.onChange);
10540
- const error = useForm("useField", (state) => getIn(state.errors, path));
10540
+ const formatNestedErrorMessages = (stateErrors) => {
10541
+ const nestedErrors = {};
10542
+ Object.entries(stateErrors).forEach(([key, value2]) => {
10543
+ let current = nestedErrors;
10544
+ const pathParts = key.split(".");
10545
+ pathParts.forEach((part, index) => {
10546
+ const isLastPart = index === pathParts.length - 1;
10547
+ if (isLastPart) {
10548
+ if (typeof value2 === "string") {
10549
+ current[part] = value2;
10550
+ } else if (isErrorMessageDescriptor(value2)) {
10551
+ current[part] = formatMessage(value2);
10552
+ } else {
10553
+ setIn(current, part, value2);
10554
+ }
10555
+ } else {
10556
+ if (!current[part]) {
10557
+ const isArray2 = !isNaN(Number(pathParts[index + 1]));
10558
+ current[part] = isArray2 ? [] : {};
10559
+ }
10560
+ current = current[part];
10561
+ }
10562
+ });
10563
+ });
10564
+ return nestedErrors;
10565
+ };
10566
+ const error = useForm(
10567
+ "useField",
10568
+ (state) => getIn(formatNestedErrorMessages(state.errors), path)
10569
+ );
10541
10570
  return {
10542
10571
  initialValue,
10543
10572
  /**
10544
- * Errors can be a string, or a MesaageDescriptor, so we need to handle both cases.
10573
+ * Errors can be a string, or a MessageDescriptor, so we need to handle both cases.
10545
10574
  * If it's anything else, we don't return it.
10546
10575
  */
10547
10576
  error: isErrorMessageDescriptor(error) ? formatMessage(
@@ -10556,7 +10585,7 @@ const useField = (path) => {
10556
10585
  };
10557
10586
  };
10558
10587
  const isErrorMessageDescriptor = (object) => {
10559
- return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
10588
+ return typeof object === "object" && object !== null && !Array.isArray(object) && "id" in object && "defaultMessage" in object;
10560
10589
  };
10561
10590
  const useFocusInputField = (name) => {
10562
10591
  const { search: searchString } = reactRouterDom.useLocation();
@@ -11470,4 +11499,4 @@ adminApi.enhanceEndpoints({
11470
11499
  });
11471
11500
  exports.Layouts = Layouts;
11472
11501
  exports.useTracking = useTracking;
11473
- //# sourceMappingURL=index-7Wlj8eA7-7OWx8SwS.js.map
11502
+ //# sourceMappingURL=index-wHs6nj5s-CEl8tdQF.js.map