strapi-plugin-navigation 3.0.4 → 3.0.6

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/README.md CHANGED
@@ -113,7 +113,7 @@ Complete installation requirements are exact same as for Strapi itself and can b
113
113
 
114
114
  **Supported Strapi versions**:
115
115
 
116
- - Strapi v5.6.0 (recently tested)
116
+ - Strapi v5.8.1 (recently tested)
117
117
  - Strapi v5.x
118
118
 
119
119
  > This plugin is designed for **Strapi v5** and is not working with v4.x. To get version for **Strapi v4** install version [v4.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v4).
@@ -48,10 +48,10 @@ const NavigationIconSvg = styled__default.default.svg`
48
48
  fill: ${({ theme: theme2 }) => theme2.colors.neutral500};
49
49
  }
50
50
  `;
51
- const NavigationIcon = ({ width = 24, height = 24 }) => /* @__PURE__ */ jsxRuntime.jsx(
51
+ const NavigationIcon = ({ width = 20, height = 20 }) => /* @__PURE__ */ jsxRuntime.jsx(
52
52
  NavigationIconSvg,
53
53
  {
54
- viewBox: `0px 0px ${width}px ${height}px`,
54
+ viewBox: `0 0 ${width} ${height}`,
55
55
  xmlns: "http://www.w3.org/2000/svg",
56
56
  height,
57
57
  width,
@@ -2519,7 +2519,7 @@ function isTopLayer(element) {
2519
2519
  function isContainingBlock(elementOrCss) {
2520
2520
  const webkit2 = isWebKit();
2521
2521
  const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2522
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
2522
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
2523
2523
  }
2524
2524
  function getContainingBlock(element) {
2525
2525
  let currentNode = getParentNode(element);
@@ -3025,6 +3025,9 @@ const platform = {
3025
3025
  isElement,
3026
3026
  isRTL
3027
3027
  };
3028
+ function rectsAreEqual(a, b) {
3029
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3030
+ }
3028
3031
  function observeMove(element, onMove) {
3029
3032
  let io = null;
3030
3033
  let timeoutId;
@@ -3043,12 +3046,13 @@ function observeMove(element, onMove) {
3043
3046
  threshold = 1;
3044
3047
  }
3045
3048
  cleanup();
3049
+ const elementRectForRootMargin = element.getBoundingClientRect();
3046
3050
  const {
3047
3051
  left,
3048
3052
  top: top2,
3049
3053
  width,
3050
3054
  height
3051
- } = element.getBoundingClientRect();
3055
+ } = elementRectForRootMargin;
3052
3056
  if (!skip) {
3053
3057
  onMove();
3054
3058
  }
@@ -3079,6 +3083,9 @@ function observeMove(element, onMove) {
3079
3083
  refresh(false, ratio);
3080
3084
  }
3081
3085
  }
3086
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
3087
+ refresh();
3088
+ }
3082
3089
  isFirstUpdate = false;
3083
3090
  }
3084
3091
  try {
@@ -3142,7 +3149,7 @@ function autoUpdate(reference, floating, update, options) {
3142
3149
  }
3143
3150
  function frameLoop() {
3144
3151
  const nextRefRect = getBoundingClientRect(reference);
3145
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
3152
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
3146
3153
  update();
3147
3154
  }
3148
3155
  prevRefRect = nextRefRect;
@@ -20173,7 +20180,7 @@ function findMinIndex(value, array) {
20173
20180
  }
20174
20181
  function countColumn(string2, tabSize, to = string2.length) {
20175
20182
  let n = 0;
20176
- for (let i = 0; i < to; ) {
20183
+ for (let i = 0; i < to && i < string2.length; ) {
20177
20184
  if (string2.charCodeAt(i) == 9) {
20178
20185
  n += tabSize - n % tabSize;
20179
20186
  i++;
@@ -24021,16 +24028,16 @@ function applyDOMChange(view, domChange) {
24021
24028
  return false;
24022
24029
  if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
24023
24030
  change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
24031
+ } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24032
+ if (newSel && change.insert.length == 2)
24033
+ newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24034
+ change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
24024
24035
  } else if (change && change.from >= sel.from && change.to <= sel.to && (change.from != sel.from || change.to != sel.to) && sel.to - sel.from - (change.to - change.from) <= 4) {
24025
24036
  change = {
24026
24037
  from: sel.from,
24027
24038
  to: sel.to,
24028
24039
  insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
24029
24040
  };
24030
- } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24031
- if (newSel && change.insert.length == 2)
24032
- newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24033
- change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
24034
24041
  } else if (browser.chrome && change && change.from == change.to && change.from == sel.head && change.insert.toString() == "\n " && view.lineWrapping) {
24035
24042
  if (newSel)
24036
24043
  newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
@@ -25666,6 +25673,10 @@ function visiblePixelRange(dom, paddingTop) {
25666
25673
  bottom: Math.max(top2, bottom) - (rect.top + paddingTop)
25667
25674
  };
25668
25675
  }
25676
+ function inWindow(elt) {
25677
+ let rect = elt.getBoundingClientRect(), win = elt.ownerDocument.defaultView || window;
25678
+ return rect.left < win.innerWidth && rect.right > 0 && rect.top < win.innerHeight && rect.bottom > 0;
25679
+ }
25669
25680
  function fullPixelRange(dom, paddingTop) {
25670
25681
  let rect = dom.getBoundingClientRect();
25671
25682
  return {
@@ -25866,7 +25877,7 @@ class ViewState {
25866
25877
  if (inView)
25867
25878
  measureContent = true;
25868
25879
  }
25869
- if (!this.inView && !this.scrollTarget)
25880
+ if (!this.inView && !this.scrollTarget && !inWindow(view.dom))
25870
25881
  return 0;
25871
25882
  let contentWidth = domRect.width;
25872
25883
  if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
@@ -26983,7 +26994,7 @@ class EditContextManager {
26983
26994
  selectionEnd: this.toContextPos(view.state.selection.main.head)
26984
26995
  });
26985
26996
  this.handlers.textupdate = (e) => {
26986
- let { anchor } = view.state.selection.main;
26997
+ let main = view.state.selection.main, { anchor, head } = main;
26987
26998
  let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
26988
26999
  if (view.inputState.composing >= 0 && !this.composing)
26989
27000
  this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
@@ -26992,8 +27003,14 @@ class EditContextManager {
26992
27003
  change.from = anchor;
26993
27004
  else if (change.to == this.to && anchor > this.to)
26994
27005
  change.to = anchor;
26995
- if (change.from == change.to && !change.insert.length)
27006
+ if (change.from == change.to && !change.insert.length) {
27007
+ let newSel = EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd));
27008
+ if (!newSel.main.eq(main))
27009
+ view.dispatch({ selection: newSel, userEvent: "select" });
26996
27010
  return;
27011
+ }
27012
+ if ((browser.mac || browser.android) && change.from == head - 1 && /^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
27013
+ change = { from, to, insert: Text.of([e.text.replace(".", " ")]) };
26997
27014
  this.pendingContextChange = change;
26998
27015
  if (!view.state.readOnly) {
26999
27016
  let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
@@ -51178,6 +51195,26 @@ const useContentTypes$1 = () => {
51178
51195
  staleTime: 1e3 * 60 * 3
51179
51196
  });
51180
51197
  };
51198
+ const useResetNavigations = () => {
51199
+ const fetch2 = admin.getFetchClient();
51200
+ const apiClient = getApiClient(fetch2);
51201
+ const queryClient2 = reactQuery.useQueryClient();
51202
+ return () => {
51203
+ queryClient2.resetQueries({
51204
+ queryKey: apiClient.readAllIndex()
51205
+ });
51206
+ };
51207
+ };
51208
+ const useResetContentTypes = () => {
51209
+ const fetch2 = admin.getFetchClient();
51210
+ const apiClient = getApiClient(fetch2);
51211
+ const queryClient2 = reactQuery.useQueryClient();
51212
+ return () => {
51213
+ queryClient2.resetQueries({
51214
+ queryKey: apiClient.readContentTypeIndex()
51215
+ });
51216
+ };
51217
+ };
51181
51218
  const useNavigations = () => {
51182
51219
  const fetch2 = admin.getFetchClient();
51183
51220
  const apiClient = getApiClient(fetch2);
@@ -51270,7 +51307,9 @@ const usePurgeNavigation = () => {
51270
51307
  if (!documentIds?.length) {
51271
51308
  return apiClient.purge({});
51272
51309
  }
51273
- return Promise.all(documentIds.map((documentId) => apiClient.purge({ documentId, withLangVersions: true })));
51310
+ return Promise.all(
51311
+ documentIds.map((documentId) => apiClient.purge({ documentId, withLangVersions: true }))
51312
+ );
51274
51313
  }
51275
51314
  });
51276
51315
  };
@@ -53492,12 +53531,8 @@ const NavigationItemForm = ({
53492
53531
  );
53493
53532
  }
53494
53533
  };
53495
- const renderError = (error) => {
53496
- const errorOccurence = lodash$1.get(formError, error);
53497
- if (errorOccurence) {
53498
- return formatMessage(getTrad(error));
53499
- }
53500
- return void 0;
53534
+ const renderError = (field, messageKey) => {
53535
+ return lodash$1.get(formError, field) ? formatMessage(getTrad(messageKey ?? field)) : void 0;
53501
53536
  };
53502
53537
  const initialRelatedTypeSelected = current.type === "INTERNAL" ? current.relatedType : void 0;
53503
53538
  const {
@@ -53839,7 +53874,7 @@ const NavigationItemForm = ({
53839
53874
  label: formatMessage(
53840
53875
  getTrad(`popup.item.form.${pathSourceName}.label`, "Path")
53841
53876
  ),
53842
- error: renderError(pathSourceName),
53877
+ error: renderError(pathSourceName, `popup.item.form.${pathSourceName}.validation.type`),
53843
53878
  hint: [
53844
53879
  formatMessage(
53845
53880
  getTrad(`popup.item.form.${pathSourceName}.placeholder`, "e.g. Blog")
@@ -54279,6 +54314,8 @@ const Inner$1 = () => {
54279
54314
  () => (localeQuery.data ? [localeQuery.data.defaultLocale, ...localeQuery.data.restLocale] : []).filter((locale) => locale !== currentLocale),
54280
54315
  [localeQuery.data, currentLocale]
54281
54316
  );
54317
+ const resetContentTypes = useResetContentTypes();
54318
+ const resetNavigations = useResetNavigations();
54282
54319
  const {
54283
54320
  i18nCopyItemsModal,
54284
54321
  i18nCopySourceLocale,
@@ -54301,7 +54338,12 @@ const Inner$1 = () => {
54301
54338
  {
54302
54339
  onSuccess(res) {
54303
54340
  copyNavigationI18nMutation.reset();
54304
- setCurrentNavigation(res.data);
54341
+ setCurrentNavigation({
54342
+ ...res.data,
54343
+ items: res.data.items.map(appendViewId)
54344
+ });
54345
+ resetContentTypes();
54346
+ resetNavigations();
54305
54347
  }
54306
54348
  }
54307
54349
  );
@@ -54603,10 +54645,10 @@ const TextArrayInput = ({ onChange, initialValue, ...props }) => {
54603
54645
  const [value, setValue] = React.useState(
54604
54646
  lodash$1.isArray(initialValue) ? initialValue.reduce((acc, cur2) => `${acc}${cur2}; `, "") : ""
54605
54647
  );
54606
- const handleOnChange = (value2) => {
54607
- const newValue = value2;
54608
- const valuesArray = newValue.split(";").map((v) => v.trim()).filter((v) => !!v.length);
54609
- setValue(value2);
54648
+ const handleOnChange = (event) => {
54649
+ const newValue = event?.target.value ?? "";
54650
+ const valuesArray = newValue.split(";").map((value2) => value2.trim()).filter((value2) => !!value2.length);
54651
+ setValue(newValue ?? "");
54610
54652
  onChange(valuesArray);
54611
54653
  };
54612
54654
  return /* @__PURE__ */ jsxRuntime.jsx(TextInput, { ...props, onChange: handleOnChange, value });
@@ -55739,7 +55781,7 @@ const Inner = () => {
55739
55781
  ) })
55740
55782
  ] })
55741
55783
  ] }) }),
55742
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { ...BOX_DEFAULT_PROPS, width: "100%", gap: 2, direction: "column", alignItems: "flex-start", children: [
55784
+ /* @__PURE__ */ jsxRuntime.jsxs(Box, { ...BOX_DEFAULT_PROPS, width: "100%", children: [
55743
55785
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "delta", as: "h2", children: formatMessage(getTrad("pages.settings.customFields.title")) }),
55744
55786
  /* @__PURE__ */ jsxRuntime.jsx(Box, { padding: 1 }),
55745
55787
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -28,10 +28,10 @@ const NavigationIconSvg = styled.svg`
28
28
  fill: ${({ theme: theme2 }) => theme2.colors.neutral500};
29
29
  }
30
30
  `;
31
- const NavigationIcon = ({ width = 24, height = 24 }) => /* @__PURE__ */ jsx(
31
+ const NavigationIcon = ({ width = 20, height = 20 }) => /* @__PURE__ */ jsx(
32
32
  NavigationIconSvg,
33
33
  {
34
- viewBox: `0px 0px ${width}px ${height}px`,
34
+ viewBox: `0 0 ${width} ${height}`,
35
35
  xmlns: "http://www.w3.org/2000/svg",
36
36
  height,
37
37
  width,
@@ -2499,7 +2499,7 @@ function isTopLayer(element) {
2499
2499
  function isContainingBlock(elementOrCss) {
2500
2500
  const webkit2 = isWebKit();
2501
2501
  const css2 = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2502
- return css2.transform !== "none" || css2.perspective !== "none" || (css2.containerType ? css2.containerType !== "normal" : false) || !webkit2 && (css2.backdropFilter ? css2.backdropFilter !== "none" : false) || !webkit2 && (css2.filter ? css2.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css2.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css2.contain || "").includes(value));
2502
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css2[value] ? css2[value] !== "none" : false) || (css2.containerType ? css2.containerType !== "normal" : false) || !webkit2 && (css2.backdropFilter ? css2.backdropFilter !== "none" : false) || !webkit2 && (css2.filter ? css2.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css2.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css2.contain || "").includes(value));
2503
2503
  }
2504
2504
  function getContainingBlock(element) {
2505
2505
  let currentNode = getParentNode(element);
@@ -3005,6 +3005,9 @@ const platform = {
3005
3005
  isElement,
3006
3006
  isRTL
3007
3007
  };
3008
+ function rectsAreEqual(a, b) {
3009
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3010
+ }
3008
3011
  function observeMove(element, onMove) {
3009
3012
  let io = null;
3010
3013
  let timeoutId;
@@ -3023,12 +3026,13 @@ function observeMove(element, onMove) {
3023
3026
  threshold = 1;
3024
3027
  }
3025
3028
  cleanup();
3029
+ const elementRectForRootMargin = element.getBoundingClientRect();
3026
3030
  const {
3027
3031
  left,
3028
3032
  top: top2,
3029
3033
  width,
3030
3034
  height
3031
- } = element.getBoundingClientRect();
3035
+ } = elementRectForRootMargin;
3032
3036
  if (!skip) {
3033
3037
  onMove();
3034
3038
  }
@@ -3059,6 +3063,9 @@ function observeMove(element, onMove) {
3059
3063
  refresh(false, ratio);
3060
3064
  }
3061
3065
  }
3066
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
3067
+ refresh();
3068
+ }
3062
3069
  isFirstUpdate = false;
3063
3070
  }
3064
3071
  try {
@@ -3122,7 +3129,7 @@ function autoUpdate(reference, floating, update, options) {
3122
3129
  }
3123
3130
  function frameLoop() {
3124
3131
  const nextRefRect = getBoundingClientRect(reference);
3125
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
3132
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
3126
3133
  update();
3127
3134
  }
3128
3135
  prevRefRect = nextRefRect;
@@ -20153,7 +20160,7 @@ function findMinIndex(value, array) {
20153
20160
  }
20154
20161
  function countColumn(string2, tabSize, to = string2.length) {
20155
20162
  let n = 0;
20156
- for (let i = 0; i < to; ) {
20163
+ for (let i = 0; i < to && i < string2.length; ) {
20157
20164
  if (string2.charCodeAt(i) == 9) {
20158
20165
  n += tabSize - n % tabSize;
20159
20166
  i++;
@@ -24001,16 +24008,16 @@ function applyDOMChange(view, domChange) {
24001
24008
  return false;
24002
24009
  if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
24003
24010
  change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
24011
+ } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24012
+ if (newSel && change.insert.length == 2)
24013
+ newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24014
+ change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
24004
24015
  } else if (change && change.from >= sel.from && change.to <= sel.to && (change.from != sel.from || change.to != sel.to) && sel.to - sel.from - (change.to - change.from) <= 4) {
24005
24016
  change = {
24006
24017
  from: sel.from,
24007
24018
  to: sel.to,
24008
24019
  insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
24009
24020
  };
24010
- } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24011
- if (newSel && change.insert.length == 2)
24012
- newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24013
- change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
24014
24021
  } else if (browser.chrome && change && change.from == change.to && change.from == sel.head && change.insert.toString() == "\n " && view.lineWrapping) {
24015
24022
  if (newSel)
24016
24023
  newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
@@ -25646,6 +25653,10 @@ function visiblePixelRange(dom, paddingTop) {
25646
25653
  bottom: Math.max(top2, bottom) - (rect.top + paddingTop)
25647
25654
  };
25648
25655
  }
25656
+ function inWindow(elt) {
25657
+ let rect = elt.getBoundingClientRect(), win = elt.ownerDocument.defaultView || window;
25658
+ return rect.left < win.innerWidth && rect.right > 0 && rect.top < win.innerHeight && rect.bottom > 0;
25659
+ }
25649
25660
  function fullPixelRange(dom, paddingTop) {
25650
25661
  let rect = dom.getBoundingClientRect();
25651
25662
  return {
@@ -25846,7 +25857,7 @@ class ViewState {
25846
25857
  if (inView)
25847
25858
  measureContent = true;
25848
25859
  }
25849
- if (!this.inView && !this.scrollTarget)
25860
+ if (!this.inView && !this.scrollTarget && !inWindow(view.dom))
25850
25861
  return 0;
25851
25862
  let contentWidth = domRect.width;
25852
25863
  if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
@@ -26963,7 +26974,7 @@ class EditContextManager {
26963
26974
  selectionEnd: this.toContextPos(view.state.selection.main.head)
26964
26975
  });
26965
26976
  this.handlers.textupdate = (e) => {
26966
- let { anchor } = view.state.selection.main;
26977
+ let main = view.state.selection.main, { anchor, head } = main;
26967
26978
  let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
26968
26979
  if (view.inputState.composing >= 0 && !this.composing)
26969
26980
  this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
@@ -26972,8 +26983,14 @@ class EditContextManager {
26972
26983
  change.from = anchor;
26973
26984
  else if (change.to == this.to && anchor > this.to)
26974
26985
  change.to = anchor;
26975
- if (change.from == change.to && !change.insert.length)
26986
+ if (change.from == change.to && !change.insert.length) {
26987
+ let newSel = EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd));
26988
+ if (!newSel.main.eq(main))
26989
+ view.dispatch({ selection: newSel, userEvent: "select" });
26976
26990
  return;
26991
+ }
26992
+ if ((browser.mac || browser.android) && change.from == head - 1 && /^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
26993
+ change = { from, to, insert: Text.of([e.text.replace(".", " ")]) };
26977
26994
  this.pendingContextChange = change;
26978
26995
  if (!view.state.readOnly) {
26979
26996
  let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
@@ -51158,6 +51175,26 @@ const useContentTypes$1 = () => {
51158
51175
  staleTime: 1e3 * 60 * 3
51159
51176
  });
51160
51177
  };
51178
+ const useResetNavigations = () => {
51179
+ const fetch2 = getFetchClient();
51180
+ const apiClient = getApiClient(fetch2);
51181
+ const queryClient2 = useQueryClient();
51182
+ return () => {
51183
+ queryClient2.resetQueries({
51184
+ queryKey: apiClient.readAllIndex()
51185
+ });
51186
+ };
51187
+ };
51188
+ const useResetContentTypes = () => {
51189
+ const fetch2 = getFetchClient();
51190
+ const apiClient = getApiClient(fetch2);
51191
+ const queryClient2 = useQueryClient();
51192
+ return () => {
51193
+ queryClient2.resetQueries({
51194
+ queryKey: apiClient.readContentTypeIndex()
51195
+ });
51196
+ };
51197
+ };
51161
51198
  const useNavigations = () => {
51162
51199
  const fetch2 = getFetchClient();
51163
51200
  const apiClient = getApiClient(fetch2);
@@ -51250,7 +51287,9 @@ const usePurgeNavigation = () => {
51250
51287
  if (!documentIds?.length) {
51251
51288
  return apiClient.purge({});
51252
51289
  }
51253
- return Promise.all(documentIds.map((documentId) => apiClient.purge({ documentId, withLangVersions: true })));
51290
+ return Promise.all(
51291
+ documentIds.map((documentId) => apiClient.purge({ documentId, withLangVersions: true }))
51292
+ );
51254
51293
  }
51255
51294
  });
51256
51295
  };
@@ -53472,12 +53511,8 @@ const NavigationItemForm = ({
53472
53511
  );
53473
53512
  }
53474
53513
  };
53475
- const renderError = (error) => {
53476
- const errorOccurence = get(formError, error);
53477
- if (errorOccurence) {
53478
- return formatMessage(getTrad(error));
53479
- }
53480
- return void 0;
53514
+ const renderError = (field, messageKey) => {
53515
+ return get(formError, field) ? formatMessage(getTrad(messageKey ?? field)) : void 0;
53481
53516
  };
53482
53517
  const initialRelatedTypeSelected = current.type === "INTERNAL" ? current.relatedType : void 0;
53483
53518
  const {
@@ -53819,7 +53854,7 @@ const NavigationItemForm = ({
53819
53854
  label: formatMessage(
53820
53855
  getTrad(`popup.item.form.${pathSourceName}.label`, "Path")
53821
53856
  ),
53822
- error: renderError(pathSourceName),
53857
+ error: renderError(pathSourceName, `popup.item.form.${pathSourceName}.validation.type`),
53823
53858
  hint: [
53824
53859
  formatMessage(
53825
53860
  getTrad(`popup.item.form.${pathSourceName}.placeholder`, "e.g. Blog")
@@ -54259,6 +54294,8 @@ const Inner$1 = () => {
54259
54294
  () => (localeQuery.data ? [localeQuery.data.defaultLocale, ...localeQuery.data.restLocale] : []).filter((locale) => locale !== currentLocale),
54260
54295
  [localeQuery.data, currentLocale]
54261
54296
  );
54297
+ const resetContentTypes = useResetContentTypes();
54298
+ const resetNavigations = useResetNavigations();
54262
54299
  const {
54263
54300
  i18nCopyItemsModal,
54264
54301
  i18nCopySourceLocale,
@@ -54281,7 +54318,12 @@ const Inner$1 = () => {
54281
54318
  {
54282
54319
  onSuccess(res) {
54283
54320
  copyNavigationI18nMutation.reset();
54284
- setCurrentNavigation(res.data);
54321
+ setCurrentNavigation({
54322
+ ...res.data,
54323
+ items: res.data.items.map(appendViewId)
54324
+ });
54325
+ resetContentTypes();
54326
+ resetNavigations();
54285
54327
  }
54286
54328
  }
54287
54329
  );
@@ -54583,10 +54625,10 @@ const TextArrayInput = ({ onChange, initialValue, ...props }) => {
54583
54625
  const [value, setValue] = useState(
54584
54626
  isArray(initialValue) ? initialValue.reduce((acc, cur2) => `${acc}${cur2}; `, "") : ""
54585
54627
  );
54586
- const handleOnChange = (value2) => {
54587
- const newValue = value2;
54588
- const valuesArray = newValue.split(";").map((v) => v.trim()).filter((v) => !!v.length);
54589
- setValue(value2);
54628
+ const handleOnChange = (event) => {
54629
+ const newValue = event?.target.value ?? "";
54630
+ const valuesArray = newValue.split(";").map((value2) => value2.trim()).filter((value2) => !!value2.length);
54631
+ setValue(newValue ?? "");
54590
54632
  onChange(valuesArray);
54591
54633
  };
54592
54634
  return /* @__PURE__ */ jsx(TextInput, { ...props, onChange: handleOnChange, value });
@@ -55719,7 +55761,7 @@ const Inner = () => {
55719
55761
  ) })
55720
55762
  ] })
55721
55763
  ] }) }),
55722
- /* @__PURE__ */ jsxs(Box, { ...BOX_DEFAULT_PROPS, width: "100%", gap: 2, direction: "column", alignItems: "flex-start", children: [
55764
+ /* @__PURE__ */ jsxs(Box, { ...BOX_DEFAULT_PROPS, width: "100%", children: [
55723
55765
  /* @__PURE__ */ jsx(Typography, { variant: "delta", as: "h2", children: formatMessage(getTrad("pages.settings.customFields.title")) }),
55724
55766
  /* @__PURE__ */ jsx(Box, { padding: 1 }),
55725
55767
  /* @__PURE__ */ jsx(
@@ -29,6 +29,8 @@ export declare const useContentTypes: () => import("@tanstack/react-query").UseQ
29
29
  isDisplayed: boolean;
30
30
  apiID: string;
31
31
  }[], Error>;
32
+ export declare const useResetNavigations: () => () => void;
33
+ export declare const useResetContentTypes: () => () => void;
32
34
  export declare const useNavigations: () => import("@tanstack/react-query").UseQueryResult<{
33
35
  id: number;
34
36
  name: string;
@@ -145,3 +147,4 @@ export declare const useI18nCopyNavigationItemsModal: (onConfirm: ConfirmEffect)
145
147
  i18nCopyItemsModal: import("react/jsx-runtime").JSX.Element | null;
146
148
  i18nCopySourceLocale: string | undefined;
147
149
  };
150
+ export declare const appendViewId: (item: NavigationItemSchema) => NavigationItemSchema;
@@ -14903,7 +14903,8 @@ const processItems = (context) => async (item) => {
14903
14903
  items: item.items ? await Promise.all(item.items.map(processItems(context))) : [],
14904
14904
  master: context.master,
14905
14905
  parent: void 0,
14906
- related: item.related
14906
+ related: item.related,
14907
+ additionalFields: item.additionalFields
14907
14908
  };
14908
14909
  };
14909
14910
  const intercalate = (glue, arr) => arr.slice(1).reduce((acc, element) => acc.concat([glue, element]), arr.slice(0, 1));
@@ -15108,7 +15109,7 @@ const adminService = (context) => ({
15108
15109
  ).sort((a, b) => a.order - b.order)
15109
15110
  }));
15110
15111
  },
15111
- async getById({ documentId, locale: locale2 }) {
15112
+ async getById({ documentId, locale: locale2, populate: populate2 = [] }) {
15112
15113
  const commonService2 = getPluginService(context, "common");
15113
15114
  const { defaultLocale } = await commonService2.readLocale();
15114
15115
  const filters2 = {
@@ -15123,7 +15124,7 @@ const adminService = (context) => ({
15123
15124
  locale: locale2 || defaultLocale,
15124
15125
  limit: Number.MAX_SAFE_INTEGER,
15125
15126
  order: [{ order: "asc" }],
15126
- populate: ["parent", "audience"]
15127
+ populate: ["parent", "audience", ...populate2]
15127
15128
  });
15128
15129
  return {
15129
15130
  ...navigation2,
@@ -15263,9 +15264,7 @@ const adminService = (context) => ({
15263
15264
  filters: { documentId: navigation2.documentId },
15264
15265
  populate: "*"
15265
15266
  });
15266
- await cleanNavigationItems(
15267
- allNavigations.map(({ id }) => id)
15268
- );
15267
+ await cleanNavigationItems(allNavigations.map(({ id }) => id));
15269
15268
  await navigationRepository.remove({ documentId: navigation2.documentId });
15270
15269
  sendAuditLog(auditLog, "onNavigationDeletion", {
15271
15270
  entity: navigationAsDTO,
@@ -15313,9 +15312,9 @@ const adminService = (context) => ({
15313
15312
  }) {
15314
15313
  const targetEntity = await this.getById({ documentId, locale: target });
15315
15314
  return await this.i18nNavigationContentsCopy({
15316
- source: await this.getById({ documentId, locale: source }),
15315
+ source: await this.getById({ documentId, locale: source, populate: ["related"] }),
15317
15316
  target: targetEntity
15318
- }).then(() => this.getById({ documentId, locale: target })).then((newEntity) => {
15317
+ }).then(() => this.getById({ documentId, locale: target, populate: ["related"] })).then((newEntity) => {
15319
15318
  sendAuditLog(auditLog, "onChangeNavigation", {
15320
15319
  actionType: "UPDATE",
15321
15320
  oldEntity: targetEntity,
@@ -15521,11 +15520,12 @@ const clientService = (context) => ({
15521
15520
  return navigations;
15522
15521
  },
15523
15522
  renderRFRNavigationItem({ item }) {
15524
- const { uiRouterKey, title, path: path2, type: type2, audience: audience2 } = item;
15523
+ const { uiRouterKey, title, path: path2, type: type2, audience: audience2, additionalFields } = item;
15525
15524
  const itemCommon = {
15526
15525
  label: title,
15527
15526
  type: type2,
15528
- audience: audience2?.map(({ key }) => key)
15527
+ audience: audience2?.map(({ key }) => key),
15528
+ additionalFields
15529
15529
  };
15530
15530
  if (type2 === "WRAPPER") {
15531
15531
  return { ...itemCommon };
@@ -15554,7 +15554,21 @@ const clientService = (context) => ({
15554
15554
  throw new NavigationError("Unknown item type", item);
15555
15555
  },
15556
15556
  renderRFRPage({ item, parent, enabledCustomFieldsNames }) {
15557
- const { documentId, uiRouterKey, title, path: path2, related, type: type2, audience: audience2, menuAttached } = item;
15557
+ const {
15558
+ documentId,
15559
+ uiRouterKey,
15560
+ title,
15561
+ path: path2,
15562
+ related,
15563
+ type: type2,
15564
+ audience: audience2,
15565
+ menuAttached,
15566
+ additionalFields
15567
+ } = item;
15568
+ const additionalFieldsRendered = enabledCustomFieldsNames.reduce(
15569
+ (acc, field) => ({ ...acc, [field]: additionalFields?.[field] }),
15570
+ {}
15571
+ );
15558
15572
  return {
15559
15573
  id: uiRouterKey,
15560
15574
  documentId,
@@ -15567,10 +15581,7 @@ const clientService = (context) => ({
15567
15581
  parent,
15568
15582
  audience: audience2,
15569
15583
  menuAttached,
15570
- ...enabledCustomFieldsNames.reduce(
15571
- (acc, field) => ({ ...acc, [field]: ___default.get(item, field) }),
15572
- {}
15573
- )
15584
+ additionalFields: additionalFieldsRendered
15574
15585
  };
15575
15586
  },
15576
15587
  renderRFR({
@@ -15725,9 +15736,10 @@ const clientService = (context) => ({
15725
15736
  populate: ["audience", "parent", "related"]
15726
15737
  });
15727
15738
  const mappedItems = await commonService2.mapToNavigationItemDTO({
15739
+ locale: locale2,
15740
+ master: navigation2,
15728
15741
  navigationItems,
15729
- populate: populate2,
15730
- master: navigation2
15742
+ populate: populate2
15731
15743
  });
15732
15744
  const { contentTypes: contentTypes2, contentTypesNameFields: contentTypesNameFields2, additionalFields } = await adminService2.config({
15733
15745
  viaSettingsPage: false
@@ -15746,7 +15758,7 @@ const clientService = (context) => ({
15746
15758
  );
15747
15759
  const additionalFieldsMapper = (item) => (acc, field) => {
15748
15760
  const fieldDefinition = customFieldsDefinitions.find(({ name }) => name === field);
15749
- let content = ___default.get(item, `additionalFields.${field}`);
15761
+ let content = item.additionalFields?.[field];
15750
15762
  if (content) {
15751
15763
  switch (fieldDefinition?.type) {
15752
15764
  case "media":
@@ -15827,22 +15839,18 @@ const clientService = (context) => ({
15827
15839
  cache.set(documentId, nestedOrders);
15828
15840
  return nestedOrders;
15829
15841
  };
15830
- return result.map(({ additionalFields: additionalFields2, ...item }) => {
15831
- const customFields = enabledCustomFieldsNames.reduce(
15842
+ return result.map((item) => {
15843
+ const additionalFieldsMapped = enabledCustomFieldsNames.reduce(
15832
15844
  additionalFieldsMapper(item),
15833
15845
  {}
15834
15846
  );
15835
15847
  return {
15836
15848
  ...item,
15837
15849
  audience: item.audience?.map((_) => _.key),
15838
- title: composeItemTitle(
15839
- { ...item, additionalFields: additionalFields2 },
15840
- contentTypesNameFields2,
15841
- contentTypes2
15842
- ) || "",
15850
+ title: composeItemTitle(item, contentTypesNameFields2, contentTypes2) || "",
15843
15851
  related: wrapContentType(item.related),
15844
15852
  items: null,
15845
- ...customFields
15853
+ additionalFields: additionalFieldsMapped
15846
15854
  };
15847
15855
  }).sort(
15848
15856
  (a, b) => compareArraysOfNumbers(getNestedOrders(a.documentId), getNestedOrders(b.documentId))
@@ -15932,13 +15940,46 @@ const commonService = (context) => ({
15932
15940
  return await strapi.store({ type: "plugin", name: "navigation" });
15933
15941
  },
15934
15942
  async mapToNavigationItemDTO({
15935
- navigationItems,
15936
- populate: populate2,
15943
+ locale: locale2,
15937
15944
  master,
15938
- parent
15945
+ navigationItems,
15946
+ parent,
15947
+ populate: populate2
15939
15948
  }) {
15940
15949
  const result = [];
15941
- for (const navigationItem2 of navigationItems) {
15950
+ const pluginStore = await this.getPluginStore();
15951
+ const config2 = await pluginStore.get({
15952
+ key: "config"
15953
+ }).then(configSchema.parse);
15954
+ const extendedNavigationItems = await Promise.all(
15955
+ navigationItems.map(async (item) => {
15956
+ if (!item.related?.__type || !item.related.documentId) {
15957
+ return item;
15958
+ }
15959
+ const fieldsToPopulate = config2.contentTypesPopulate[item.related.__type];
15960
+ if (!fieldsToPopulate?.length) {
15961
+ return item;
15962
+ }
15963
+ const repository = getGenericRepository({ strapi }, item.related.__type);
15964
+ const related = await repository.findById(
15965
+ item.related.documentId,
15966
+ fieldsToPopulate,
15967
+ "published",
15968
+ {
15969
+ locale: locale2
15970
+ }
15971
+ );
15972
+ return {
15973
+ ...item,
15974
+ related: {
15975
+ ...related,
15976
+ __type: item.related.__type,
15977
+ documentId: item.related.documentId
15978
+ }
15979
+ };
15980
+ })
15981
+ );
15982
+ for (const navigationItem2 of extendedNavigationItems) {
15942
15983
  const { items = [], ...base } = navigationItem2;
15943
15984
  result.push({
15944
15985
  ...base,
@@ -15947,7 +15988,8 @@ const commonService = (context) => ({
15947
15988
  navigationItems: items,
15948
15989
  populate: populate2,
15949
15990
  master,
15950
- parent: base
15991
+ parent: base,
15992
+ locale: locale2
15951
15993
  })
15952
15994
  });
15953
15995
  }
@@ -14865,7 +14865,8 @@ const processItems = (context) => async (item) => {
14865
14865
  items: item.items ? await Promise.all(item.items.map(processItems(context))) : [],
14866
14866
  master: context.master,
14867
14867
  parent: void 0,
14868
- related: item.related
14868
+ related: item.related,
14869
+ additionalFields: item.additionalFields
14869
14870
  };
14870
14871
  };
14871
14872
  const intercalate = (glue, arr) => arr.slice(1).reduce((acc, element) => acc.concat([glue, element]), arr.slice(0, 1));
@@ -15070,7 +15071,7 @@ const adminService = (context) => ({
15070
15071
  ).sort((a, b) => a.order - b.order)
15071
15072
  }));
15072
15073
  },
15073
- async getById({ documentId, locale: locale2 }) {
15074
+ async getById({ documentId, locale: locale2, populate: populate2 = [] }) {
15074
15075
  const commonService2 = getPluginService(context, "common");
15075
15076
  const { defaultLocale } = await commonService2.readLocale();
15076
15077
  const filters2 = {
@@ -15085,7 +15086,7 @@ const adminService = (context) => ({
15085
15086
  locale: locale2 || defaultLocale,
15086
15087
  limit: Number.MAX_SAFE_INTEGER,
15087
15088
  order: [{ order: "asc" }],
15088
- populate: ["parent", "audience"]
15089
+ populate: ["parent", "audience", ...populate2]
15089
15090
  });
15090
15091
  return {
15091
15092
  ...navigation2,
@@ -15225,9 +15226,7 @@ const adminService = (context) => ({
15225
15226
  filters: { documentId: navigation2.documentId },
15226
15227
  populate: "*"
15227
15228
  });
15228
- await cleanNavigationItems(
15229
- allNavigations.map(({ id }) => id)
15230
- );
15229
+ await cleanNavigationItems(allNavigations.map(({ id }) => id));
15231
15230
  await navigationRepository.remove({ documentId: navigation2.documentId });
15232
15231
  sendAuditLog(auditLog, "onNavigationDeletion", {
15233
15232
  entity: navigationAsDTO,
@@ -15275,9 +15274,9 @@ const adminService = (context) => ({
15275
15274
  }) {
15276
15275
  const targetEntity = await this.getById({ documentId, locale: target });
15277
15276
  return await this.i18nNavigationContentsCopy({
15278
- source: await this.getById({ documentId, locale: source }),
15277
+ source: await this.getById({ documentId, locale: source, populate: ["related"] }),
15279
15278
  target: targetEntity
15280
- }).then(() => this.getById({ documentId, locale: target })).then((newEntity) => {
15279
+ }).then(() => this.getById({ documentId, locale: target, populate: ["related"] })).then((newEntity) => {
15281
15280
  sendAuditLog(auditLog, "onChangeNavigation", {
15282
15281
  actionType: "UPDATE",
15283
15282
  oldEntity: targetEntity,
@@ -15483,11 +15482,12 @@ const clientService = (context) => ({
15483
15482
  return navigations;
15484
15483
  },
15485
15484
  renderRFRNavigationItem({ item }) {
15486
- const { uiRouterKey, title, path: path2, type: type2, audience: audience2 } = item;
15485
+ const { uiRouterKey, title, path: path2, type: type2, audience: audience2, additionalFields } = item;
15487
15486
  const itemCommon = {
15488
15487
  label: title,
15489
15488
  type: type2,
15490
- audience: audience2?.map(({ key }) => key)
15489
+ audience: audience2?.map(({ key }) => key),
15490
+ additionalFields
15491
15491
  };
15492
15492
  if (type2 === "WRAPPER") {
15493
15493
  return { ...itemCommon };
@@ -15516,7 +15516,21 @@ const clientService = (context) => ({
15516
15516
  throw new NavigationError("Unknown item type", item);
15517
15517
  },
15518
15518
  renderRFRPage({ item, parent, enabledCustomFieldsNames }) {
15519
- const { documentId, uiRouterKey, title, path: path2, related, type: type2, audience: audience2, menuAttached } = item;
15519
+ const {
15520
+ documentId,
15521
+ uiRouterKey,
15522
+ title,
15523
+ path: path2,
15524
+ related,
15525
+ type: type2,
15526
+ audience: audience2,
15527
+ menuAttached,
15528
+ additionalFields
15529
+ } = item;
15530
+ const additionalFieldsRendered = enabledCustomFieldsNames.reduce(
15531
+ (acc, field) => ({ ...acc, [field]: additionalFields?.[field] }),
15532
+ {}
15533
+ );
15520
15534
  return {
15521
15535
  id: uiRouterKey,
15522
15536
  documentId,
@@ -15529,10 +15543,7 @@ const clientService = (context) => ({
15529
15543
  parent,
15530
15544
  audience: audience2,
15531
15545
  menuAttached,
15532
- ...enabledCustomFieldsNames.reduce(
15533
- (acc, field) => ({ ...acc, [field]: get$1(item, field) }),
15534
- {}
15535
- )
15546
+ additionalFields: additionalFieldsRendered
15536
15547
  };
15537
15548
  },
15538
15549
  renderRFR({
@@ -15687,9 +15698,10 @@ const clientService = (context) => ({
15687
15698
  populate: ["audience", "parent", "related"]
15688
15699
  });
15689
15700
  const mappedItems = await commonService2.mapToNavigationItemDTO({
15701
+ locale: locale2,
15702
+ master: navigation2,
15690
15703
  navigationItems,
15691
- populate: populate2,
15692
- master: navigation2
15704
+ populate: populate2
15693
15705
  });
15694
15706
  const { contentTypes: contentTypes2, contentTypesNameFields: contentTypesNameFields2, additionalFields } = await adminService2.config({
15695
15707
  viaSettingsPage: false
@@ -15708,7 +15720,7 @@ const clientService = (context) => ({
15708
15720
  );
15709
15721
  const additionalFieldsMapper = (item) => (acc, field) => {
15710
15722
  const fieldDefinition = customFieldsDefinitions.find(({ name }) => name === field);
15711
- let content = get$1(item, `additionalFields.${field}`);
15723
+ let content = item.additionalFields?.[field];
15712
15724
  if (content) {
15713
15725
  switch (fieldDefinition?.type) {
15714
15726
  case "media":
@@ -15789,22 +15801,18 @@ const clientService = (context) => ({
15789
15801
  cache.set(documentId, nestedOrders);
15790
15802
  return nestedOrders;
15791
15803
  };
15792
- return result.map(({ additionalFields: additionalFields2, ...item }) => {
15793
- const customFields = enabledCustomFieldsNames.reduce(
15804
+ return result.map((item) => {
15805
+ const additionalFieldsMapped = enabledCustomFieldsNames.reduce(
15794
15806
  additionalFieldsMapper(item),
15795
15807
  {}
15796
15808
  );
15797
15809
  return {
15798
15810
  ...item,
15799
15811
  audience: item.audience?.map((_) => _.key),
15800
- title: composeItemTitle(
15801
- { ...item, additionalFields: additionalFields2 },
15802
- contentTypesNameFields2,
15803
- contentTypes2
15804
- ) || "",
15812
+ title: composeItemTitle(item, contentTypesNameFields2, contentTypes2) || "",
15805
15813
  related: wrapContentType(item.related),
15806
15814
  items: null,
15807
- ...customFields
15815
+ additionalFields: additionalFieldsMapped
15808
15816
  };
15809
15817
  }).sort(
15810
15818
  (a, b) => compareArraysOfNumbers(getNestedOrders(a.documentId), getNestedOrders(b.documentId))
@@ -15894,13 +15902,46 @@ const commonService = (context) => ({
15894
15902
  return await strapi.store({ type: "plugin", name: "navigation" });
15895
15903
  },
15896
15904
  async mapToNavigationItemDTO({
15897
- navigationItems,
15898
- populate: populate2,
15905
+ locale: locale2,
15899
15906
  master,
15900
- parent
15907
+ navigationItems,
15908
+ parent,
15909
+ populate: populate2
15901
15910
  }) {
15902
15911
  const result = [];
15903
- for (const navigationItem2 of navigationItems) {
15912
+ const pluginStore = await this.getPluginStore();
15913
+ const config2 = await pluginStore.get({
15914
+ key: "config"
15915
+ }).then(configSchema.parse);
15916
+ const extendedNavigationItems = await Promise.all(
15917
+ navigationItems.map(async (item) => {
15918
+ if (!item.related?.__type || !item.related.documentId) {
15919
+ return item;
15920
+ }
15921
+ const fieldsToPopulate = config2.contentTypesPopulate[item.related.__type];
15922
+ if (!fieldsToPopulate?.length) {
15923
+ return item;
15924
+ }
15925
+ const repository = getGenericRepository({ strapi }, item.related.__type);
15926
+ const related = await repository.findById(
15927
+ item.related.documentId,
15928
+ fieldsToPopulate,
15929
+ "published",
15930
+ {
15931
+ locale: locale2
15932
+ }
15933
+ );
15934
+ return {
15935
+ ...item,
15936
+ related: {
15937
+ ...related,
15938
+ __type: item.related.__type,
15939
+ documentId: item.related.documentId
15940
+ }
15941
+ };
15942
+ })
15943
+ );
15944
+ for (const navigationItem2 of extendedNavigationItems) {
15904
15945
  const { items = [], ...base } = navigationItem2;
15905
15946
  result.push({
15906
15947
  ...base,
@@ -15909,7 +15950,8 @@ const commonService = (context) => ({
15909
15950
  navigationItems: items,
15910
15951
  populate: populate2,
15911
15952
  master,
15912
- parent: base
15953
+ parent: base,
15954
+ locale: locale2
15913
15955
  })
15914
15956
  });
15915
15957
  }
@@ -20,7 +20,7 @@ export default function adminController(context: {
20
20
  visible: boolean;
21
21
  items?: import("../schemas").NavigationItemDBSchema[] | undefined;
22
22
  }[]>;
23
- getById({ documentId, locale }: import("../services/admin/types").GetByIdInput): Promise<{
23
+ getById({ documentId, locale, populate }: import("../services/admin/types").GetByIdInput): Promise<{
24
24
  name: string;
25
25
  id: number;
26
26
  documentId: string;
@@ -96,7 +96,7 @@ export default function adminController(context: {
96
96
  tag?: string | undefined;
97
97
  }> | undefined): Promise<void>;
98
98
  }>;
99
- mapToNavigationItemDTO({ navigationItems, populate, master, parent, }: import("../services/common/types").MapToNavigationItemDTOInput): Promise<import("../dtos").NavigationItemDTO[]>;
99
+ mapToNavigationItemDTO({ locale, master, navigationItems, parent, populate, }: import("../services/common/types").MapToNavigationItemDTOInput): Promise<import("../dtos").NavigationItemDTO[]>;
100
100
  setDefaultConfig(): Promise<{
101
101
  additionalFields: ("audience" | {
102
102
  type: "string" | "boolean";
@@ -77,6 +77,7 @@ export default function clientController(context: {
77
77
  title: string;
78
78
  related: any;
79
79
  items: null;
80
+ additionalFields: {};
80
81
  path?: string | null | undefined;
81
82
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
82
83
  id: number;
@@ -99,6 +100,7 @@ export default function clientController(context: {
99
100
  title: string;
100
101
  related: any;
101
102
  items: null;
103
+ additionalFields: {};
102
104
  path?: string | null | undefined;
103
105
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
104
106
  id: number;
@@ -121,6 +123,7 @@ export default function clientController(context: {
121
123
  title: string;
122
124
  related: any;
123
125
  items: null;
126
+ additionalFields: {};
124
127
  path?: string | null | undefined;
125
128
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
126
129
  id: number;
@@ -153,6 +156,7 @@ export default function clientController(context: {
153
156
  title: string;
154
157
  related: any;
155
158
  items: null;
159
+ additionalFields: {};
156
160
  path?: string | null | undefined;
157
161
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
158
162
  id: number;
@@ -175,6 +179,7 @@ export default function clientController(context: {
175
179
  title: string;
176
180
  related: any;
177
181
  items: null;
182
+ additionalFields: {};
178
183
  path?: string | null | undefined;
179
184
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
180
185
  id: number;
@@ -14,6 +14,7 @@ export declare const renderNavigationChild: ({ strapi, nexus }: any) => {
14
14
  title: string;
15
15
  related: any;
16
16
  items: null;
17
+ additionalFields: {};
17
18
  path?: string | null | undefined;
18
19
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
19
20
  id: number;
@@ -15,6 +15,7 @@ export declare const renderNavigation: ({ strapi, nexus }: any) => {
15
15
  title: string;
16
16
  related: any;
17
17
  items: null;
18
+ additionalFields: {};
18
19
  path?: string | null | undefined;
19
20
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
20
21
  id: number;
@@ -274,7 +274,7 @@ declare const _default: {
274
274
  visible: boolean;
275
275
  items?: import("./schemas").NavigationItemDBSchema[] | undefined;
276
276
  }[]>;
277
- getById({ documentId, locale }: import("./services/admin/types").GetByIdInput): Promise<{
277
+ getById({ documentId, locale, populate }: import("./services/admin/types").GetByIdInput): Promise<{
278
278
  name: string;
279
279
  id: number;
280
280
  documentId: string;
@@ -354,7 +354,7 @@ declare const _default: {
354
354
  tag?: string | undefined;
355
355
  }> | undefined): Promise<void>;
356
356
  }>;
357
- mapToNavigationItemDTO({ navigationItems, populate, master, parent, }: import("./services/common/types").MapToNavigationItemDTOInput): Promise<import("./dtos").NavigationItemDTO[]>;
357
+ mapToNavigationItemDTO({ locale, master, navigationItems, parent, populate, }: import("./services/common/types").MapToNavigationItemDTOInput): Promise<import("./dtos").NavigationItemDTO[]>;
358
358
  setDefaultConfig(): Promise<{
359
359
  additionalFields: ("audience" | {
360
360
  type: "string" | "boolean";
@@ -511,6 +511,7 @@ declare const _default: {
511
511
  title: string;
512
512
  related: any;
513
513
  items: null;
514
+ additionalFields: {};
514
515
  path?: string | null | undefined;
515
516
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
516
517
  id: number;
@@ -533,6 +534,7 @@ declare const _default: {
533
534
  title: string;
534
535
  related: any;
535
536
  items: null;
537
+ additionalFields: {};
536
538
  path?: string | null | undefined;
537
539
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
538
540
  id: number;
@@ -555,6 +557,7 @@ declare const _default: {
555
557
  title: string;
556
558
  related: any;
557
559
  items: null;
560
+ additionalFields: {};
558
561
  path?: string | null | undefined;
559
562
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
560
563
  id: number;
@@ -9,7 +9,7 @@ declare const adminService: (context: {
9
9
  config({ viaSettingsPage }: ConfigInput): Promise<NavigationPluginConfigDTO>;
10
10
  configContentTypes({ viaSettingsPage, }: ConfigInput): Promise<ConfigContentTypeDTO[]>;
11
11
  get({ ids, locale }: GetInput): Promise<NavigationDBSchema[]>;
12
- getById({ documentId, locale }: GetByIdInput): Promise<NavigationDBSchema>;
12
+ getById({ documentId, locale, populate }: GetByIdInput): Promise<NavigationDBSchema>;
13
13
  post({ auditLog, payload }: PostInput): Promise<NavigationDTO>;
14
14
  put({ auditLog, payload }: PutInput): Promise<NavigationDBSchema>;
15
15
  delete({ auditLog, documentId }: DeleteInput): Promise<void>;
@@ -10,6 +10,7 @@ export interface GetInput {
10
10
  export interface GetByIdInput {
11
11
  documentId: string;
12
12
  locale?: string;
13
+ populate?: Array<string>;
13
14
  }
14
15
  export interface PostInput {
15
16
  payload: CreateNavigationSchema;
@@ -31,6 +31,7 @@ declare const clientService: (context: {
31
31
  title: string;
32
32
  related: any;
33
33
  items: null;
34
+ additionalFields: {};
34
35
  path?: string | null | undefined;
35
36
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
36
37
  id: number;
@@ -53,6 +54,7 @@ declare const clientService: (context: {
53
54
  title: string;
54
55
  related: any;
55
56
  items: null;
57
+ additionalFields: {};
56
58
  path?: string | null | undefined;
57
59
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
58
60
  id: number;
@@ -75,6 +77,7 @@ declare const clientService: (context: {
75
77
  title: string;
76
78
  related: any;
77
79
  items: null;
80
+ additionalFields: {};
78
81
  path?: string | null | undefined;
79
82
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
80
83
  id: number;
@@ -24,7 +24,7 @@ export interface RenderRFRInput {
24
24
  enabledCustomFieldsNames: string[];
25
25
  }
26
26
  export interface RenderRFRNavInput {
27
- item: Pick<NavigationItemDTO, 'uiRouterKey' | 'title' | 'path' | 'type' | 'audience'>;
27
+ item: Pick<NavigationItemDTO, 'uiRouterKey' | 'title' | 'path' | 'type' | 'audience' | 'additionalFields'>;
28
28
  }
29
29
  export interface RenderRFRPageInput {
30
30
  item: Omit<NavigationItemDTO, 'items' | 'parent' | 'master'>;
@@ -8,7 +8,7 @@ declare const commonService: (context: {
8
8
  strapi: Core.Strapi;
9
9
  }) => {
10
10
  getPluginStore(): Promise<ReturnType<typeof strapi.store>>;
11
- mapToNavigationItemDTO({ navigationItems, populate, master, parent, }: MapToNavigationItemDTOInput): Promise<NavigationItemDTO[]>;
11
+ mapToNavigationItemDTO({ locale, master, navigationItems, parent, populate, }: MapToNavigationItemDTOInput): Promise<NavigationItemDTO[]>;
12
12
  setDefaultConfig(): Promise<NavigationPluginConfigDBSchema>;
13
13
  getBranchName({ item }: GetBranchNameInput): NavigationActionsCategories | void;
14
14
  analyzeBranch({ masterEntity, navigationItems, parentItem, prevAction, }: AnalyzeBranchInput): Promise<NavigationAction[]>;
@@ -18,6 +18,7 @@ export interface MapToNavigationItemDTOInput {
18
18
  populate: unknown;
19
19
  master?: Omit<NavigationDTO, 'items'>;
20
20
  parent?: NavigationItemDTO;
21
+ locale?: string;
21
22
  }
22
23
  export interface CreateBranchInput {
23
24
  navigationItems: CreateBranchNavigationItemDTO[];
@@ -17,7 +17,7 @@ declare const _default: {
17
17
  visible: boolean;
18
18
  items?: import("../schemas").NavigationItemDBSchema[] | undefined;
19
19
  }[]>;
20
- getById({ documentId, locale }: import("./admin/types").GetByIdInput): Promise<{
20
+ getById({ documentId, locale, populate }: import("./admin/types").GetByIdInput): Promise<{
21
21
  name: string;
22
22
  id: number;
23
23
  documentId: string;
@@ -95,7 +95,7 @@ declare const _default: {
95
95
  tag?: string | undefined;
96
96
  }> | undefined): Promise<void>;
97
97
  }>;
98
- mapToNavigationItemDTO({ navigationItems, populate, master, parent, }: import("./common/types").MapToNavigationItemDTOInput): Promise<import("../dtos").NavigationItemDTO[]>;
98
+ mapToNavigationItemDTO({ locale, master, navigationItems, parent, populate, }: import("./common/types").MapToNavigationItemDTOInput): Promise<import("../dtos").NavigationItemDTO[]>;
99
99
  setDefaultConfig(): Promise<{
100
100
  additionalFields: ("audience" | {
101
101
  type: "string" | "boolean";
@@ -252,6 +252,7 @@ declare const _default: {
252
252
  title: string;
253
253
  related: any;
254
254
  items: null;
255
+ additionalFields: {};
255
256
  path?: string | null | undefined;
256
257
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
257
258
  id: number;
@@ -274,6 +275,7 @@ declare const _default: {
274
275
  title: string;
275
276
  related: any;
276
277
  items: null;
278
+ additionalFields: {};
277
279
  path?: string | null | undefined;
278
280
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
279
281
  id: number;
@@ -296,6 +298,7 @@ declare const _default: {
296
298
  title: string;
297
299
  related: any;
298
300
  items: null;
301
+ additionalFields: {};
299
302
  path?: string | null | undefined;
300
303
  type: "INTERNAL" | "EXTERNAL" | "WRAPPER";
301
304
  id: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-navigation",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "Strapi - Navigation plugin",
5
5
  "strapi": {
6
6
  "name": "navigation",
@@ -48,7 +48,7 @@
48
48
  "react-dnd": "^16.0.1",
49
49
  "react-dnd-html5-backend": "^16.0.1",
50
50
  "react-dom": "^18.2.0",
51
- "react-intl": "6.6.8",
51
+ "react-intl": "6.6.2",
52
52
  "react-router-dom": "^6.22.3",
53
53
  "uuid": "^10.0.0",
54
54
  "zod": "^3.22.5"
@@ -60,11 +60,11 @@
60
60
  "@sensinum/strapi-utils": "^1.0.4",
61
61
  "@strapi/design-system": "2.0.0-rc.14",
62
62
  "@strapi/icons": "2.0.0-rc.14",
63
- "@strapi/plugin-graphql": "^5.6.0",
64
- "@strapi/sdk-plugin": "^5.2.8",
65
- "@strapi/strapi": "^5.6.0",
66
- "@strapi/types": "^5.6.0",
67
- "@strapi/typescript-utils": "^5.6.0",
63
+ "@strapi/plugin-graphql": "^5.8.1",
64
+ "@strapi/sdk-plugin": "^5.3.0",
65
+ "@strapi/strapi": "^5.8.1",
66
+ "@strapi/types": "^5.8.1",
67
+ "@strapi/typescript-utils": "^5.8.1",
68
68
  "@types/jest": "^29.5.12",
69
69
  "@types/koa": "^2.15.0",
70
70
  "@types/koa-bodyparser": "^4.3.12",
@@ -90,9 +90,9 @@
90
90
  "prettier": "^3.3.3",
91
91
  "react": "^18.3.1",
92
92
  "react-dom": "^18.3.1",
93
- "react-intl": "^6.6.8",
93
+ "react-intl": "^6.6.2",
94
94
  "react-query": "3.39.3",
95
- "react-router-dom": "^6.26.2",
95
+ "react-router-dom": "^6.22.3",
96
96
  "strapi-plugin-rest-cache": "^4.2.9",
97
97
  "styled-components": "^6.1.13",
98
98
  "ts-jest": "^29.1.4",
@@ -100,11 +100,11 @@
100
100
  "typescript": "^5.6.2"
101
101
  },
102
102
  "peerDependencies": {
103
- "@strapi/sdk-plugin": "^5.2.8",
104
- "@strapi/strapi": "^5.6.0",
103
+ "@strapi/sdk-plugin": "^5.3.0",
104
+ "@strapi/strapi": "^5.8.1",
105
105
  "react": "^18.3.1",
106
106
  "react-dom": "^18.3.1",
107
- "react-router-dom": "^6.26.2",
107
+ "react-router-dom": "^6.22.3",
108
108
  "styled-components": "^6.1.13"
109
109
  },
110
110
  "husky": {