@strapi/content-manager 5.11.0 → 5.12.0-beta.0

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 (105) hide show
  1. package/dist/admin/chunks/{ComponentConfigurationPage-BBCYsnnE.js → ComponentConfigurationPage-CBvwLnAK.js} +5 -6
  2. package/dist/admin/chunks/{ComponentConfigurationPage-BBCYsnnE.js.map → ComponentConfigurationPage-CBvwLnAK.js.map} +1 -1
  3. package/dist/admin/chunks/{ComponentConfigurationPage-DNBN8tI3.mjs → ComponentConfigurationPage-w_ss7xEy.mjs} +5 -6
  4. package/dist/admin/chunks/{ComponentConfigurationPage-DNBN8tI3.mjs.map → ComponentConfigurationPage-w_ss7xEy.mjs.map} +1 -1
  5. package/dist/admin/chunks/{EditConfigurationPage-Cu0Vt-uc.js → EditConfigurationPage-CbAhYSyH.js} +5 -6
  6. package/dist/admin/chunks/{EditConfigurationPage-Cu0Vt-uc.js.map → EditConfigurationPage-CbAhYSyH.js.map} +1 -1
  7. package/dist/admin/chunks/{EditConfigurationPage-CoivzF-x.mjs → EditConfigurationPage-D1iHIzSR.mjs} +5 -6
  8. package/dist/admin/chunks/{EditConfigurationPage-CoivzF-x.mjs.map → EditConfigurationPage-D1iHIzSR.mjs.map} +1 -1
  9. package/dist/admin/chunks/{EditViewPage-BpGtaOKG.mjs → EditViewPage-BtunY0ZP.mjs} +102 -95
  10. package/dist/admin/chunks/EditViewPage-BtunY0ZP.mjs.map +1 -0
  11. package/dist/admin/chunks/{EditViewPage-B48r4DLX.js → EditViewPage-Cf_TPJZd.js} +102 -95
  12. package/dist/admin/chunks/EditViewPage-Cf_TPJZd.js.map +1 -0
  13. package/dist/admin/chunks/{Form-rQQtxfmF.mjs → Form-DsvK3WTh.mjs} +3 -3
  14. package/dist/admin/chunks/{Form-rQQtxfmF.mjs.map → Form-DsvK3WTh.mjs.map} +1 -1
  15. package/dist/admin/chunks/{Form-DD49gSWW.js → Form-UMrizqJP.js} +5 -5
  16. package/dist/admin/chunks/{Form-DD49gSWW.js.map → Form-UMrizqJP.js.map} +1 -1
  17. package/dist/admin/chunks/{History-RLJ9Svg6.js → History-Crvb_hzd.js} +17 -13
  18. package/dist/admin/chunks/History-Crvb_hzd.js.map +1 -0
  19. package/dist/admin/chunks/{History-BdsTgpW-.mjs → History-DsRVSUF7.mjs} +16 -12
  20. package/dist/admin/chunks/History-DsRVSUF7.mjs.map +1 -0
  21. package/dist/admin/chunks/{Input-BUVu6H9n.js → Input-C2r54bIL.js} +1327 -64
  22. package/dist/admin/chunks/Input-C2r54bIL.js.map +1 -0
  23. package/dist/admin/chunks/{Input-CtIJ2J0c.mjs → Input-D6obstp0.mjs} +1315 -55
  24. package/dist/admin/chunks/Input-D6obstp0.mjs.map +1 -0
  25. package/dist/admin/chunks/{ListConfigurationPage-38s4e-VJ.mjs → ListConfigurationPage-DW-wAwmW.mjs} +4 -5
  26. package/dist/admin/chunks/{ListConfigurationPage-38s4e-VJ.mjs.map → ListConfigurationPage-DW-wAwmW.mjs.map} +1 -1
  27. package/dist/admin/chunks/{ListConfigurationPage-DfnrA3dw.js → ListConfigurationPage-DlQ2pLyr.js} +6 -7
  28. package/dist/admin/chunks/{ListConfigurationPage-DfnrA3dw.js.map → ListConfigurationPage-DlQ2pLyr.js.map} +1 -1
  29. package/dist/admin/chunks/{ListViewPage-BTmlktgT.mjs → ListViewPage-DcUhPA9a.mjs} +3 -4
  30. package/dist/admin/chunks/{ListViewPage-BTmlktgT.mjs.map → ListViewPage-DcUhPA9a.mjs.map} +1 -1
  31. package/dist/admin/chunks/{ListViewPage-D9-LGPq_.js → ListViewPage-nJJ227Fo.js} +7 -8
  32. package/dist/admin/chunks/{ListViewPage-D9-LGPq_.js.map → ListViewPage-nJJ227Fo.js.map} +1 -1
  33. package/dist/admin/chunks/{NoContentTypePage-owzdv-pl.js → NoContentTypePage-Cxt-uFq7.js} +2 -2
  34. package/dist/admin/chunks/{NoContentTypePage-owzdv-pl.js.map → NoContentTypePage-Cxt-uFq7.js.map} +1 -1
  35. package/dist/admin/chunks/{NoContentTypePage-CcyR2i1K.mjs → NoContentTypePage-DbRXR2cr.mjs} +2 -2
  36. package/dist/admin/chunks/{NoContentTypePage-CcyR2i1K.mjs.map → NoContentTypePage-DbRXR2cr.mjs.map} +1 -1
  37. package/dist/admin/chunks/{NoPermissionsPage-CM_r8w5u.js → NoPermissionsPage-BeMTv_SG.js} +2 -2
  38. package/dist/admin/chunks/{NoPermissionsPage-CM_r8w5u.js.map → NoPermissionsPage-BeMTv_SG.js.map} +1 -1
  39. package/dist/admin/chunks/{NoPermissionsPage-lBonAXej.mjs → NoPermissionsPage-RWPwNESA.mjs} +2 -2
  40. package/dist/admin/chunks/{NoPermissionsPage-lBonAXej.mjs.map → NoPermissionsPage-RWPwNESA.mjs.map} +1 -1
  41. package/dist/admin/chunks/{Preview-Bv3GKyWZ.js → Preview-CCjSV5Iu.js} +119 -200
  42. package/dist/admin/chunks/Preview-CCjSV5Iu.js.map +1 -0
  43. package/dist/admin/chunks/{Preview-Dh5Z7aGp.mjs → Preview-aVLT3LM_.mjs} +123 -204
  44. package/dist/admin/chunks/Preview-aVLT3LM_.mjs.map +1 -0
  45. package/dist/admin/chunks/{en-CImiNxXE.mjs → en-C2zEwS3-.mjs} +4 -1
  46. package/dist/admin/chunks/{en-CImiNxXE.mjs.map → en-C2zEwS3-.mjs.map} +1 -1
  47. package/dist/admin/chunks/{en-CLf4SuMQ.js → en-G976DLsg.js} +4 -1
  48. package/dist/admin/chunks/{en-CLf4SuMQ.js.map → en-G976DLsg.js.map} +1 -1
  49. package/dist/admin/chunks/{index-CGBB9Dho.js → index-BA_JLxKS.js} +185 -121
  50. package/dist/admin/chunks/index-BA_JLxKS.js.map +1 -0
  51. package/dist/admin/chunks/{index-BkM_Z7pU.mjs → index-CIOT3ggy.mjs} +184 -123
  52. package/dist/admin/chunks/index-CIOT3ggy.mjs.map +1 -0
  53. package/dist/admin/chunks/{layout-Dbmjk7mC.js → layout-C510xcd6.js} +86 -13
  54. package/dist/admin/chunks/layout-C510xcd6.js.map +1 -0
  55. package/dist/admin/chunks/{layout-D8ji6QNJ.mjs → layout-DjT9cccU.mjs} +78 -5
  56. package/dist/admin/chunks/layout-DjT9cccU.mjs.map +1 -0
  57. package/dist/admin/chunks/{useDragAndDrop-gcqEJMnO.js → objects-BJTP843m.js} +73 -1
  58. package/dist/admin/chunks/objects-BJTP843m.js.map +1 -0
  59. package/dist/admin/chunks/{useDragAndDrop-HYwNDExe.mjs → objects-D2z-IJgu.mjs} +72 -2
  60. package/dist/admin/chunks/objects-D2z-IJgu.mjs.map +1 -0
  61. package/dist/admin/chunks/{relations-jNJK8ESO.js → usePrev-BglKW7a4.js} +18 -2
  62. package/dist/admin/chunks/usePrev-BglKW7a4.js.map +1 -0
  63. package/dist/admin/chunks/{relations-Dv0FHoBS.mjs → usePrev-DAWUYIPh.mjs} +18 -4
  64. package/dist/admin/chunks/usePrev-DAWUYIPh.mjs.map +1 -0
  65. package/dist/admin/index.js +1 -1
  66. package/dist/admin/index.mjs +1 -1
  67. package/dist/admin/src/features/DocumentContext.d.ts +53 -0
  68. package/dist/admin/src/features/DocumentRBAC.d.ts +3 -2
  69. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  70. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +8 -0
  71. package/dist/admin/src/pages/EditView/components/FormInputs/{Relations.d.ts → Relations/Relations.d.ts} +9 -4
  72. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +8 -3
  73. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +7 -4
  74. package/dist/admin/src/preview/components/PreviewHeader.d.ts +1 -2
  75. package/dist/admin/src/preview/pages/Preview.d.ts +0 -2
  76. package/package.json +5 -5
  77. package/dist/admin/chunks/EditViewPage-B48r4DLX.js.map +0 -1
  78. package/dist/admin/chunks/EditViewPage-BpGtaOKG.mjs.map +0 -1
  79. package/dist/admin/chunks/History-BdsTgpW-.mjs.map +0 -1
  80. package/dist/admin/chunks/History-RLJ9Svg6.js.map +0 -1
  81. package/dist/admin/chunks/Input-BUVu6H9n.js.map +0 -1
  82. package/dist/admin/chunks/Input-CtIJ2J0c.mjs.map +0 -1
  83. package/dist/admin/chunks/Preview-Bv3GKyWZ.js.map +0 -1
  84. package/dist/admin/chunks/Preview-Dh5Z7aGp.mjs.map +0 -1
  85. package/dist/admin/chunks/Relations-DP5krCGC.mjs +0 -1291
  86. package/dist/admin/chunks/Relations-DP5krCGC.mjs.map +0 -1
  87. package/dist/admin/chunks/Relations-T8Cr0N9M.js +0 -1318
  88. package/dist/admin/chunks/Relations-T8Cr0N9M.js.map +0 -1
  89. package/dist/admin/chunks/index-BkM_Z7pU.mjs.map +0 -1
  90. package/dist/admin/chunks/index-CGBB9Dho.js.map +0 -1
  91. package/dist/admin/chunks/layout-D8ji6QNJ.mjs.map +0 -1
  92. package/dist/admin/chunks/layout-Dbmjk7mC.js.map +0 -1
  93. package/dist/admin/chunks/objects-C3EebVVe.js +0 -76
  94. package/dist/admin/chunks/objects-C3EebVVe.js.map +0 -1
  95. package/dist/admin/chunks/objects-wl73iEma.mjs +0 -73
  96. package/dist/admin/chunks/objects-wl73iEma.mjs.map +0 -1
  97. package/dist/admin/chunks/relations-Dv0FHoBS.mjs.map +0 -1
  98. package/dist/admin/chunks/relations-jNJK8ESO.js.map +0 -1
  99. package/dist/admin/chunks/useDragAndDrop-HYwNDExe.mjs.map +0 -1
  100. package/dist/admin/chunks/useDragAndDrop-gcqEJMnO.js.map +0 -1
  101. package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs +0 -18
  102. package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs.map +0 -1
  103. package/dist/admin/chunks/usePrev-DIYl-IAL.js +0 -21
  104. package/dist/admin/chunks/usePrev-DIYl-IAL.js.map +0 -1
  105. package/dist/admin/src/preview/components/PreviewContent.d.ts +0 -2
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useDrop, useDrag } from 'react-dnd';
3
+ import clone from 'lodash/clone';
4
+ import toPath from 'lodash/toPath';
3
5
 
4
6
  const ItemTypes = {
5
7
  COMPONENT: 'component',
@@ -243,5 +245,73 @@ const DROP_SENSITIVITY = {
243
245
  ];
244
246
  };
245
247
 
246
- export { DROP_SENSITIVITY as D, ItemTypes as I, DIRECTIONS as a, useDragAndDrop as u };
247
- //# sourceMappingURL=useDragAndDrop-HYwNDExe.mjs.map
248
+ /**
249
+ * Deeply get a value from an object via its path.
250
+ */ function getIn(obj, key, def, pathStartIndex = 0) {
251
+ const path = toPath(key);
252
+ while(obj && pathStartIndex < path.length){
253
+ obj = obj[path[pathStartIndex++]];
254
+ }
255
+ // check if path is not in the end
256
+ if (pathStartIndex !== path.length && !obj) {
257
+ return def;
258
+ }
259
+ return obj === undefined ? def : obj;
260
+ }
261
+ /** @internal is the given object an Object? */ const isObject = (obj)=>obj !== null && typeof obj === 'object' && !Array.isArray(obj);
262
+ /** @internal is the given object an integer? */ const isInteger = (obj)=>String(Math.floor(Number(obj))) === obj;
263
+ /**
264
+ * Deeply set a value from in object via its path. If the value at `path`
265
+ * has changed, return a shallow copy of obj with `value` set at `path`.
266
+ * If `value` has not changed, return the original `obj`.
267
+ *
268
+ * Existing objects / arrays along `path` are also shallow copied. Sibling
269
+ * objects along path retain the same internal js reference. Since new
270
+ * objects / arrays are only created along `path`, we can test if anything
271
+ * changed in a nested structure by comparing the object's reference in
272
+ * the old and new object, similar to how russian doll cache invalidation
273
+ * works.
274
+ *
275
+ * In earlier versions of this function, which used cloneDeep, there were
276
+ * issues whereby settings a nested value would mutate the parent
277
+ * instead of creating a new object. `clone` avoids that bug making a
278
+ * shallow copy of the objects along the update path
279
+ * so no object is mutated in place.
280
+ *
281
+ * Before changing this function, please read through the following
282
+ * discussions.
283
+ *
284
+ * @see https://github.com/developit/linkstate
285
+ * @see https://github.com/jaredpalmer/formik/pull/123
286
+ */ function setIn(obj, path, value) {
287
+ const res = clone(obj); // this keeps inheritance when obj is a class
288
+ let resVal = res;
289
+ let i = 0;
290
+ const pathArray = toPath(path);
291
+ for(; i < pathArray.length - 1; i++){
292
+ const currentPath = pathArray[i];
293
+ const currentObj = getIn(obj, pathArray.slice(0, i + 1));
294
+ if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) {
295
+ resVal = resVal[currentPath] = clone(currentObj);
296
+ } else {
297
+ const nextPath = pathArray[i + 1];
298
+ resVal = resVal[currentPath] = isInteger(nextPath) && Number(nextPath) >= 0 ? [] : {};
299
+ }
300
+ }
301
+ // Return original object if new value is the same as current
302
+ if ((i === 0 ? obj : resVal)[pathArray[i]] === value) {
303
+ return obj;
304
+ }
305
+ {
306
+ delete resVal[pathArray[i]];
307
+ }
308
+ // If the path array has a single element, the loop did not run.
309
+ // Deleting on `resVal` had no effect in this scenario, so we delete on the result instead.
310
+ if (i === 0 && value === undefined) {
311
+ delete res[pathArray[i]];
312
+ }
313
+ return res;
314
+ }
315
+
316
+ export { DIRECTIONS as D, ItemTypes as I, DROP_SENSITIVITY as a, getIn as g, setIn as s, useDragAndDrop as u };
317
+ //# sourceMappingURL=objects-D2z-IJgu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects-D2z-IJgu.mjs","sources":["../../../admin/src/constants/dragAndDrop.ts","../../../admin/src/hooks/useKeyboardDragAndDrop.ts","../../../admin/src/hooks/useDragAndDrop.ts","../../../admin/src/utils/objects.ts"],"sourcesContent":["export const ItemTypes = {\n COMPONENT: 'component',\n EDIT_FIELD: 'editField',\n FIELD: 'field',\n DYNAMIC_ZONE: 'dynamicZone',\n RELATION: 'relation',\n BLOCKS: 'blocks',\n} as const;\n","import * as React from 'react';\n\nexport type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number> = number> = {\n onCancel?: (index: TIndex) => void;\n onDropItem?: (currentIndex: TIndex, newIndex?: TIndex) => void;\n onGrabItem?: (index: TIndex) => void;\n onMoveItem?: (newIndex: TIndex, currentIndex: TIndex) => void;\n};\n\n/**\n * Utility hook designed to implement keyboard accessibile drag and drop by\n * returning an onKeyDown handler to be passed to the drag icon button.\n *\n * @internal - You should use `useDragAndDrop` instead.\n */\nexport const useKeyboardDragAndDrop = <TIndex extends number | Array<number> = number>(\n active: boolean,\n index: TIndex,\n { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>\n) => {\n const [isSelected, setIsSelected] = React.useState(false);\n\n const handleMove = (movement: 'UP' | 'DOWN') => {\n if (!isSelected) {\n return;\n }\n if (typeof index === 'number' && onMoveItem) {\n if (movement === 'UP') {\n onMoveItem((index - 1) as TIndex, index);\n } else if (movement === 'DOWN') {\n onMoveItem((index + 1) as TIndex, index);\n }\n }\n };\n\n const handleDragClick = () => {\n if (isSelected) {\n if (onDropItem) {\n onDropItem(index);\n }\n setIsSelected(false);\n } else {\n if (onGrabItem) {\n onGrabItem(index);\n }\n setIsSelected(true);\n }\n };\n\n const handleCancel = () => {\n if (isSelected) {\n setIsSelected(false);\n\n if (onCancel) {\n onCancel(index);\n }\n }\n };\n\n const handleKeyDown = <E extends Element>(e: React.KeyboardEvent<E>) => {\n if (!active) {\n return;\n }\n\n if (e.key === 'Tab' && !isSelected) {\n return;\n }\n\n e.preventDefault();\n\n switch (e.key) {\n case ' ':\n case 'Enter':\n handleDragClick();\n break;\n\n case 'Escape':\n handleCancel();\n break;\n\n case 'ArrowDown':\n case 'ArrowRight':\n handleMove('DOWN');\n break;\n\n case 'ArrowUp':\n case 'ArrowLeft':\n handleMove('UP');\n break;\n\n default:\n }\n };\n\n return handleKeyDown;\n};\n","import * as React from 'react';\n\nimport {\n useDrag,\n useDrop,\n type HandlerManager,\n type ConnectDragSource,\n type ConnectDropTarget,\n type ConnectDragPreview,\n type DragSourceMonitor,\n} from 'react-dnd';\n\nimport {\n useKeyboardDragAndDrop,\n type UseKeyboardDragAndDropCallbacks,\n} from './useKeyboardDragAndDrop';\n\nimport type { Data } from '@strapi/types';\n\nconst DIRECTIONS = {\n UPWARD: 'upward',\n DOWNWARD: 'downward',\n} as const;\n\nconst DROP_SENSITIVITY = {\n REGULAR: 'regular',\n IMMEDIATE: 'immediate',\n} as const;\n\ninterface UseDragAndDropOptions<\n TIndex extends number | Array<number> = number,\n TItem extends { index: TIndex } = { index: TIndex },\n> extends UseKeyboardDragAndDropCallbacks<TIndex> {\n type?: string;\n index: TIndex;\n item?: TItem;\n onStart?: () => void;\n onEnd?: () => void;\n dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];\n}\n\ntype Identifier = ReturnType<HandlerManager['getHandlerId']>;\n\ntype UseDragAndDropReturn<E extends Element = HTMLElement> = [\n props: {\n handlerId: Identifier;\n isDragging: boolean;\n handleKeyDown: <E extends Element>(event: React.KeyboardEvent<E>) => void;\n isOverDropTarget: boolean;\n direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;\n },\n objectRef: React.RefObject<E>,\n dropRef: ConnectDropTarget,\n dragRef: ConnectDragSource,\n dragPreviewRef: ConnectDragPreview,\n];\n\ntype DropCollectedProps = {\n handlerId: Identifier;\n isOver: boolean;\n};\n\n/**\n * A utility hook abstracting the general drag and drop hooks from react-dnd.\n * Centralising the same behaviours and by default offering keyboard support.\n */\nconst useDragAndDrop = <\n TIndex extends number | Array<number>,\n TItem extends { index: TIndex; id?: Data.ID; [key: string]: unknown } = {\n index: TIndex;\n [key: string]: unknown;\n },\n E extends Element = HTMLElement,\n>(\n active: boolean,\n {\n type = 'STRAPI_DND',\n index,\n item,\n onStart,\n onEnd,\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n dropSensitivity = DROP_SENSITIVITY.REGULAR,\n }: UseDragAndDropOptions<TIndex, TItem>\n): UseDragAndDropReturn<E> => {\n const objectRef = React.useRef<E>(null);\n\n const [{ handlerId, isOver }, dropRef] = useDrop<TItem, void, DropCollectedProps>({\n accept: type,\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n isOver: monitor.isOver({ shallow: true }),\n };\n },\n drop(item) {\n const draggedIndex = item.index;\n const newIndex = index;\n\n if (isOver && onDropItem) {\n onDropItem(draggedIndex, newIndex);\n }\n },\n hover(item, monitor) {\n if (!objectRef.current || !onMoveItem) {\n return;\n }\n\n const dragIndex = item.index;\n const newIndex = index;\n\n const hoverBoundingRect = objectRef.current?.getBoundingClientRect();\n const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;\n if (typeof dragIndex === 'number' && typeof newIndex === 'number') {\n if (dragIndex === newIndex) {\n // Don't replace items with themselves\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (dragIndex < newIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (dragIndex > newIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n\n // Time to actually perform the action\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n } else {\n // Using numbers as indices doesn't work for nested list items with path like [1, 1, 0]\n if (Array.isArray(dragIndex) && Array.isArray(newIndex)) {\n // Indices comparison to find item position in nested list\n const minLength = Math.min(dragIndex.length, newIndex.length);\n let areEqual = true;\n let isLessThan = false;\n let isGreaterThan = false;\n\n for (let i = 0; i < minLength; i++) {\n if (dragIndex[i] < newIndex[i]) {\n isLessThan = true;\n areEqual = false;\n break;\n } else if (dragIndex[i] > newIndex[i]) {\n isGreaterThan = true;\n areEqual = false;\n break;\n }\n }\n\n // Don't replace items with themselves\n if (areEqual && dragIndex.length === newIndex.length) {\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (isLessThan && !isGreaterThan && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (isGreaterThan && !isLessThan && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n }\n\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n }\n },\n });\n\n const getDragDirection = (monitor: DragSourceMonitor<TItem, void>) => {\n if (\n monitor &&\n monitor.isDragging() &&\n !monitor.didDrop() &&\n monitor.getInitialClientOffset() &&\n monitor.getClientOffset()\n ) {\n const deltaY = monitor.getInitialClientOffset()!.y - monitor.getClientOffset()!.y;\n\n if (deltaY > 0) return DIRECTIONS.UPWARD;\n\n if (deltaY < 0) return DIRECTIONS.DOWNWARD;\n\n return null;\n }\n\n return null;\n };\n\n const [{ isDragging, direction }, dragRef, dragPreviewRef] = useDrag({\n type,\n item() {\n if (onStart) {\n onStart();\n }\n\n /**\n * This will be attached and it helps define the preview sizes\n * when a component is flexy e.g. Relations\n */\n const { width } = objectRef.current?.getBoundingClientRect() ?? {};\n\n return { index, width, ...item };\n },\n end() {\n if (onEnd) {\n onEnd();\n }\n },\n canDrag: active,\n /**\n * This is useful when the item is in a virtualized list.\n * However, if we don't have an ID then we want the libraries\n * defaults to take care of this.\n */\n isDragging: item?.id\n ? (monitor) => {\n return item.id === monitor.getItem().id;\n }\n : undefined,\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n initialOffset: monitor.getInitialClientOffset(),\n currentOffset: monitor.getClientOffset(),\n direction: getDragDirection(monitor),\n }),\n });\n\n const handleKeyDown = useKeyboardDragAndDrop(active, index, {\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n });\n\n return [\n { handlerId, isDragging, handleKeyDown, isOverDropTarget: isOver, direction },\n objectRef,\n dropRef,\n dragRef,\n dragPreviewRef,\n ];\n};\n\nexport {\n useDragAndDrop,\n UseDragAndDropReturn,\n UseDragAndDropOptions,\n DIRECTIONS,\n DROP_SENSITIVITY,\n};\n","import clone from 'lodash/clone';\nimport toPath from 'lodash/toPath';\n\n/**\n * Deeply get a value from an object via its path.\n */\nexport function getIn(obj: any, key: string | string[], def?: any, pathStartIndex: number = 0) {\n const path = toPath(key);\n while (obj && pathStartIndex < path.length) {\n obj = obj[path[pathStartIndex++]];\n }\n\n // check if path is not in the end\n if (pathStartIndex !== path.length && !obj) {\n return def;\n }\n\n return obj === undefined ? def : obj;\n}\n\n/** @internal is the given object an Object? */\nexport const isObject = (obj: any): obj is object =>\n obj !== null && typeof obj === 'object' && !Array.isArray(obj);\n\n/** @internal is the given object an integer? */\nexport const isInteger = (obj: any): boolean => String(Math.floor(Number(obj))) === obj;\n\n/**\n * Deeply set a value from in object via its path. If the value at `path`\n * has changed, return a shallow copy of obj with `value` set at `path`.\n * If `value` has not changed, return the original `obj`.\n *\n * Existing objects / arrays along `path` are also shallow copied. Sibling\n * objects along path retain the same internal js reference. Since new\n * objects / arrays are only created along `path`, we can test if anything\n * changed in a nested structure by comparing the object's reference in\n * the old and new object, similar to how russian doll cache invalidation\n * works.\n *\n * In earlier versions of this function, which used cloneDeep, there were\n * issues whereby settings a nested value would mutate the parent\n * instead of creating a new object. `clone` avoids that bug making a\n * shallow copy of the objects along the update path\n * so no object is mutated in place.\n *\n * Before changing this function, please read through the following\n * discussions.\n *\n * @see https://github.com/developit/linkstate\n * @see https://github.com/jaredpalmer/formik/pull/123\n */\nexport function setIn(obj: any, path: string, value: any): any {\n const res: any = clone(obj); // this keeps inheritance when obj is a class\n let resVal: any = res;\n let i = 0;\n const pathArray = toPath(path);\n\n for (; i < pathArray.length - 1; i++) {\n const currentPath: string = pathArray[i];\n const currentObj: any = getIn(obj, pathArray.slice(0, i + 1));\n\n if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) {\n resVal = resVal[currentPath] = clone(currentObj);\n } else {\n const nextPath: string = pathArray[i + 1];\n resVal = resVal[currentPath] = isInteger(nextPath) && Number(nextPath) >= 0 ? [] : {};\n }\n }\n\n // Return original object if new value is the same as current\n if ((i === 0 ? obj : resVal)[pathArray[i]] === value) {\n return obj;\n }\n\n if (value === undefined) {\n delete resVal[pathArray[i]];\n } else {\n resVal[pathArray[i]] = value;\n }\n\n // If the path array has a single element, the loop did not run.\n // Deleting on `resVal` had no effect in this scenario, so we delete on the result instead.\n if (i === 0 && value === undefined) {\n delete res[pathArray[i]];\n }\n\n return res;\n}\n"],"names":["ItemTypes","COMPONENT","EDIT_FIELD","FIELD","DYNAMIC_ZONE","RELATION","BLOCKS","useKeyboardDragAndDrop","active","index","onCancel","onDropItem","onGrabItem","onMoveItem","isSelected","setIsSelected","React","useState","handleMove","movement","handleDragClick","handleCancel","handleKeyDown","e","key","preventDefault","DIRECTIONS","UPWARD","DOWNWARD","DROP_SENSITIVITY","REGULAR","IMMEDIATE","useDragAndDrop","type","item","onStart","onEnd","dropSensitivity","objectRef","useRef","handlerId","isOver","dropRef","useDrop","accept","collect","monitor","getHandlerId","shallow","drop","draggedIndex","newIndex","hover","current","dragIndex","hoverBoundingRect","getBoundingClientRect","hoverMiddleY","bottom","top","clientOffset","getClientOffset","hoverClientY","y","Array","isArray","minLength","Math","min","length","areEqual","isLessThan","isGreaterThan","i","getDragDirection","isDragging","didDrop","getInitialClientOffset","deltaY","direction","dragRef","dragPreviewRef","useDrag","width","end","canDrag","id","getItem","undefined","initialOffset","currentOffset","isOverDropTarget","getIn","obj","def","pathStartIndex","path","toPath","isObject","isInteger","String","floor","Number","setIn","value","res","clone","resVal","pathArray","currentPath","currentObj","slice","nextPath"],"mappings":";;;;;MAAaA,SAAY,GAAA;IACvBC,SAAW,EAAA,WAAA;IACXC,UAAY,EAAA,WAAA;IACZC,KAAO,EAAA,OAAA;IACPC,YAAc,EAAA,aAAA;IACdC,QAAU,EAAA,UAAA;IACVC,MAAQ,EAAA;AACV;;ACEA;;;;;AAKC,IACM,MAAMC,sBAAyB,GAAA,CACpCC,QACAC,KACA,EAAA,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAA2C,GAAA;AAEzF,IAAA,MAAM,CAACC,UAAYC,EAAAA,aAAAA,CAAc,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;AAEnD,I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GAAG,EAAC;AACtF;AACF;;AAGA,IAAA,IAAI,CAACvC,CAAM,KAAA,CAAA,GAAIoB,GAAMc,GAAAA,MAAK,EAAGC,SAAS,CAACnC,CAAE,CAAA,CAAC,KAAK+B,KAAO,EAAA;QACpD,OAAOX,GAAAA;AACT;AAEA,IAAyB;AACvB,QAAA,OAAOc,MAAM,CAACC,SAAS,CAACnC,EAAE,CAAC;;;;IAO7B,IAAIA,CAAAA,KAAM,CAAK+B,IAAAA,KAAAA,KAAUhB,SAAW,EAAA;AAClC,QAAA,OAAOiB,GAAG,CAACG,SAAS,CAACnC,EAAE,CAAC;AAC1B;IAEA,OAAOgC,GAAAA;AACT;;;;"}
@@ -2,7 +2,11 @@
2
2
 
3
3
  var React = require('react');
4
4
  var fractionalIndexing = require('fractional-indexing');
5
- var index = require('./index-CGBB9Dho.js');
5
+ var index = require('./index-BA_JLxKS.js');
6
+
7
+ const prefixFileUrlWithBackendUrl = (fileURL)=>{
8
+ return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;
9
+ };
6
10
 
7
11
  function useDebounce(value, delay) {
8
12
  const [debouncedValue, setDebouncedValue] = React.useState(value);
@@ -171,8 +175,20 @@ const { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;
171
175
  return relation.documentId;
172
176
  };
173
177
 
178
+ const usePrev = (value)=>{
179
+ const ref = React.useRef();
180
+ React.useEffect(()=>{
181
+ ref.current = value;
182
+ }, [
183
+ value
184
+ ]);
185
+ return ref.current;
186
+ };
187
+
174
188
  exports.getRelationLabel = getRelationLabel;
189
+ exports.prefixFileUrlWithBackendUrl = prefixFileUrlWithBackendUrl;
175
190
  exports.useDebounce = useDebounce;
176
191
  exports.useGetRelationsQuery = useGetRelationsQuery;
177
192
  exports.useLazySearchRelationsQuery = useLazySearchRelationsQuery;
178
- //# sourceMappingURL=relations-jNJK8ESO.js.map
193
+ exports.usePrev = usePrev;
194
+ //# sourceMappingURL=usePrev-BglKW7a4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrev-BglKW7a4.js","sources":["../../../admin/src/utils/urls.ts","../../../admin/src/hooks/useDebounce.ts","../../../admin/src/services/relations.ts","../../../admin/src/utils/relations.ts","../../../admin/src/hooks/usePrev.ts"],"sourcesContent":["const prefixFileUrlWithBackendUrl = (fileURL?: string): string | undefined => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n\nexport { prefixFileUrlWithBackendUrl };\n","import { useEffect, useState } from 'react';\n\nexport function useDebounce<TValue>(value: TValue, delay: number): TValue {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n","import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n","import { useEffect, useRef } from 'react';\n\nexport const usePrev = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n"],"names":["prefixFileUrlWithBackendUrl","fileURL","startsWith","window","strapi","backendURL","useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","handler","setTimeout","clearTimeout","relationsApi","contentManagerApi","injectEndpoints","endpoints","build","getRelations","query","model","id","targetField","params","url","method","config","serializeQueryArgs","args","endpointName","queryArgs","locale","status","merge","currentCache","newItems","pagination","page","results","prepareTempKeys","forceRefetch","currentArg","previousArg","pageSize","transformResponse","response","toReversed","providesTags","searchRelations","_q","idsToOmit","idsToInclude","existingIds","map","item","documentId","uniqueNewItems","filter","includes","push","relations","existingRelations","firstItem","slice","keys","generateNKeysBetween","__temp_key__","length","datum","index","useGetRelationsQuery","useLazySearchRelationsQuery","getRelationLabel","relation","mainField","label","name","usePrev","ref","useRef","current"],"mappings":";;;;;;AAAA,MAAMA,8BAA8B,CAACC,OAAAA,GAAAA;AACnC,IAAA,OAAO,CAAC,CAACA,OAAAA,IAAWA,OAAQC,CAAAA,UAAU,CAAC,GAAO,CAAA,GAAA,CAAC,EAAEC,MAAAA,CAAOC,MAAM,CAACC,UAAU,CAAC,EAAEJ,OAAAA,CAAQ,CAAC,GAAGA,OAAAA;AAC1F;;ACAO,SAASK,WAAAA,CAAoBC,KAAa,EAAEC,KAAa,EAAA;AAC9D,IAAA,MAAM,CAACC,cAAAA,EAAgBC,iBAAkB,CAAA,GAAGC,cAASJ,CAAAA,KAAAA,CAAAA;IAErDK,eAAU,CAAA,IAAA;AACR,QAAA,MAAMC,UAAUC,UAAW,CAAA,IAAA;YACzBJ,iBAAkBH,CAAAA,KAAAA,CAAAA;SACjBC,EAAAA,KAAAA,CAAAA;QAEH,OAAO,IAAA;YACLO,YAAaF,CAAAA,OAAAA,CAAAA;AACf,SAAA;KACC,EAAA;AAACN,QAAAA,KAAAA;AAAOC,QAAAA;AAAM,KAAA,CAAA;IAEjB,OAAOC,cAAAA;AACT;;ACkBA,MAAMO,YAAAA,GAA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ACK,KAAM;SAC3B,CAAA,CAAA;AACF,CAAA;AAEA,MAAM,EAAEC,oBAAoB,EAAEC,2BAA2B,EAAE,GAAG1D;;AC/L9D;;;;;;;IAQA,MAAM2D,gBAAmB,GAAA,CAACC,QAA0BC,EAAAA,SAAAA,GAAAA;AAClD,IAAA,MAAMC,KAAQD,GAAAA,SAAAA,IAAaD,QAAQ,CAACC,SAAUE,CAAAA,IAAI,CAAC,GAAGH,QAAQ,CAACC,SAAUE,CAAAA,IAAI,CAAC,GAAG,IAAA;IAEjF,IAAI,OAAOD,UAAU,QAAU,EAAA;QAC7B,OAAOA,KAAAA;AACT;AAEA,IAAA,OAAOF,SAASlB,UAAU;AAC5B;;ACjBO,MAAMsB,UAAU,CAAIzE,KAAAA,GAAAA;AACzB,IAAA,MAAM0E,GAAMC,GAAAA,YAAAA,EAAAA;IAEZtE,eAAU,CAAA,IAAA;AACRqE,QAAAA,GAAAA,CAAIE,OAAO,GAAG5E,KAAAA;KACb,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,OAAO0E,IAAIE,OAAO;AACpB;;;;;;;;;"}
@@ -1,6 +1,10 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState, useEffect, useRef } from 'react';
2
2
  import { generateNKeysBetween } from 'fractional-indexing';
3
- import { e as contentManagerApi } from './index-BkM_Z7pU.mjs';
3
+ import { l as contentManagerApi } from './index-CIOT3ggy.mjs';
4
+
5
+ const prefixFileUrlWithBackendUrl = (fileURL)=>{
6
+ return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;
7
+ };
4
8
 
5
9
  function useDebounce(value, delay) {
6
10
  const [debouncedValue, setDebouncedValue] = useState(value);
@@ -169,5 +173,15 @@ const { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;
169
173
  return relation.documentId;
170
174
  };
171
175
 
172
- export { useDebounce as a, useLazySearchRelationsQuery as b, getRelationLabel as g, useGetRelationsQuery as u };
173
- //# sourceMappingURL=relations-Dv0FHoBS.mjs.map
176
+ const usePrev = (value)=>{
177
+ const ref = useRef();
178
+ useEffect(()=>{
179
+ ref.current = value;
180
+ }, [
181
+ value
182
+ ]);
183
+ return ref.current;
184
+ };
185
+
186
+ export { useDebounce as a, useLazySearchRelationsQuery as b, usePrev as c, getRelationLabel as g, prefixFileUrlWithBackendUrl as p, useGetRelationsQuery as u };
187
+ //# sourceMappingURL=usePrev-DAWUYIPh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrev-DAWUYIPh.mjs","sources":["../../../admin/src/utils/urls.ts","../../../admin/src/hooks/useDebounce.ts","../../../admin/src/services/relations.ts","../../../admin/src/utils/relations.ts","../../../admin/src/hooks/usePrev.ts"],"sourcesContent":["const prefixFileUrlWithBackendUrl = (fileURL?: string): string | undefined => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n\nexport { prefixFileUrlWithBackendUrl };\n","import { useEffect, useState } from 'react';\n\nexport function useDebounce<TValue>(value: TValue, delay: number): TValue {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n","import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n *\n * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n","import { useEffect, useRef } from 'react';\n\nexport const usePrev = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n"],"names":["prefixFileUrlWithBackendUrl","fileURL","startsWith","window","strapi","backendURL","useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","handler","setTimeout","clearTimeout","relationsApi","contentManagerApi","injectEndpoints","endpoints","build","getRelations","query","model","id","targetField","params","url","method","config","serializeQueryArgs","args","endpointName","queryArgs","locale","status","merge","currentCache","newItems","pagination","page","results","prepareTempKeys","forceRefetch","currentArg","previousArg","pageSize","transformResponse","response","toReversed","providesTags","searchRelations","_q","idsToOmit","idsToInclude","existingIds","map","item","documentId","uniqueNewItems","filter","includes","push","relations","existingRelations","firstItem","slice","keys","generateNKeysBetween","__temp_key__","length","datum","index","useGetRelationsQuery","useLazySearchRelationsQuery","getRelationLabel","relation","mainField","label","name","usePrev","ref","useRef","current"],"mappings":";;;;AAAA,MAAMA,8BAA8B,CAACC,OAAAA,GAAAA;AACnC,IAAA,OAAO,CAAC,CAACA,OAAAA,IAAWA,OAAQC,CAAAA,UAAU,CAAC,GAAO,CAAA,GAAA,CAAC,EAAEC,MAAAA,CAAOC,MAAM,CAACC,UAAU,CAAC,EAAEJ,OAAAA,CAAQ,CAAC,GAAGA,OAAAA;AAC1F;;ACAO,SAASK,WAAAA,CAAoBC,KAAa,EAAEC,KAAa,EAAA;AAC9D,IAAA,MAAM,CAACC,cAAAA,EAAgBC,iBAAkB,CAAA,GAAGC,QAASJ,CAAAA,KAAAA,CAAAA;IAErDK,SAAU,CAAA,IAAA;AACR,QAA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,CAAU,GAAGD,iBAAAA,CAAkBE,KAAK,CAAC,CAAA,CAAA;AAC5C,IAAA,MAAMC,OAAOC,oBAAqB,CAAA,IAAA,EAAMH,WAAWI,YAAgB,IAAA,IAAA,EAAMN,UAAUO,MAAM,CAAA;AAEzF,IAAA,OAAOP,UAAUP,GAAG,CAAC,CAACe,KAAAA,EAAOC,SAAW;AACtC,YAAA,GAAGD,KAAK;YACRF,YAAcF,EAAAA,IAAI,CAACK,KAAM;SAC3B,CAAA,CAAA;AACF,CAAA;AAEA,MAAM,EAAEC,oBAAoB,EAAEC,2BAA2B,EAAE,GAAG1D;;AC/L9D;;;;;;;IAQA,MAAM2D,gBAAmB,GAAA,CAACC,QAA0BC,EAAAA,SAAAA,GAAAA;AAClD,IAAA,MAAMC,KAAQD,GAAAA,SAAAA,IAAaD,QAAQ,CAACC,SAAUE,CAAAA,IAAI,CAAC,GAAGH,QAAQ,CAACC,SAAUE,CAAAA,IAAI,CAAC,GAAG,IAAA;IAEjF,IAAI,OAAOD,UAAU,QAAU,EAAA;QAC7B,OAAOA,KAAAA;AACT;AAEA,IAAA,OAAOF,SAASlB,UAAU;AAC5B;;ACjBO,MAAMsB,UAAU,CAAIzE,KAAAA,GAAAA;AACzB,IAAA,MAAM0E,GAAMC,GAAAA,MAAAA,EAAAA;IAEZtE,SAAU,CAAA,IAAA;AACRqE,QAAAA,GAAAA,CAAIE,OAAO,GAAG5E,KAAAA;KACb,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,OAAO0E,IAAIE,OAAO;AACpB;;;;"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('@strapi/icons');
6
- var index = require('./chunks/index-CGBB9Dho.js');
6
+ var index = require('./chunks/index-BA_JLxKS.js');
7
7
  require('prismjs');
8
8
  require('react/jsx-runtime');
9
9
  require('@strapi/admin/strapi-admin');
@@ -1,5 +1,5 @@
1
1
  import '@strapi/icons';
2
- export { l as DocumentRBAC, D as DocumentStatus, d as buildValidParams, Q as default, U as unstable_useContentManagerContext, M as unstable_useDocument, V as unstable_useDocumentActions, h as unstable_useDocumentLayout, f as useDocumentRBAC } from './chunks/index-BkM_Z7pU.mjs';
2
+ export { i as DocumentRBAC, D as DocumentStatus, k as buildValidParams, W as default, X as unstable_useContentManagerContext, U as unstable_useDocument, Y as unstable_useDocumentActions, d as unstable_useDocumentLayout, o as useDocumentRBAC } from './chunks/index-CIOT3ggy.mjs';
3
3
  import 'prismjs';
4
4
  import 'react/jsx-runtime';
5
5
  import '@strapi/admin/strapi-admin';
@@ -0,0 +1,53 @@
1
+ import * as React from 'react';
2
+ import { type UseDocument } from '../hooks/useDocument';
3
+ interface DocumentMeta {
4
+ /**
5
+ * The equivalent of the ":id" url param value
6
+ * i.e. gus5a67jcboa3o2zjnz39mb1
7
+ */
8
+ documentId: string;
9
+ /**
10
+ * The equivalent of the url ":slug" param value
11
+ * i.e. api::articles.article
12
+ */
13
+ model: string;
14
+ /**
15
+ * The equivalent of the url ":collectionType" param value
16
+ * i.e. collection-types or single-types
17
+ */
18
+ collectionType: string;
19
+ /**
20
+ * Query params object
21
+ * i.e. { locale: 'fr' }
22
+ */
23
+ params?: Record<string, string | string[] | null>;
24
+ }
25
+ interface DocumentContextValue {
26
+ rootDocumentMeta: DocumentMeta;
27
+ document: ReturnType<UseDocument>;
28
+ meta: DocumentMeta;
29
+ changeDocument: (newRelation: DocumentMeta) => void;
30
+ documentHistory: DocumentMeta[];
31
+ setDocumentHistory: React.Dispatch<React.SetStateAction<DocumentMeta[]>>;
32
+ onPreview?: () => void;
33
+ }
34
+ declare const useDocumentContext: <Selected>(consumerName: string, selector: (value: DocumentContextValue) => Selected) => Selected;
35
+ /**
36
+ * TODO: Document in contributor docs, Add unit test
37
+ *
38
+ * This context provider and its associated hook are used to access a document at its root level
39
+ * and expose a function to change the current document being viewed to one of the root level docuemnt's relations.
40
+ *
41
+ * The useDocumentContext hook exposes:
42
+ * - meta: information about the currentDocument,
43
+ * - document: the actual document,
44
+ * - changeDocument: a function to change the current document to one of its relations.
45
+ * - rootDocumentMeta: information about the root level document (current page)
46
+ */
47
+ declare const DocumentContextProvider: ({ children, initialDocument, onPreview, }: {
48
+ children: React.ReactNode | React.ReactNode[];
49
+ initialDocument: DocumentMeta;
50
+ onPreview?: () => void;
51
+ }) => import("react/jsx-runtime").JSX.Element;
52
+ export { useDocumentContext, DocumentContextProvider };
53
+ export type { DocumentMeta };
@@ -23,14 +23,15 @@ declare const useDocumentRBAC: <Selected>(consumerName: string, selector: (value
23
23
  interface DocumentRBACProps {
24
24
  children: React.ReactNode;
25
25
  permissions: Permission[] | null;
26
+ model?: string;
26
27
  }
27
28
  /**
28
29
  * @internal This component is not meant to be used outside of the Content Manager plugin.
29
- * It depends on knowing the slug/model of the content-type using the params of the URL.
30
+ * It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.
30
31
  * If you do use the hook outside of the context, we default to `false` for all actions.
31
32
  *
32
33
  * It then creates an list of `can{Action}` that are passed to the context for consumption
33
34
  * within the app to enforce RBAC.
34
35
  */
35
- declare const DocumentRBAC: ({ children, permissions }: DocumentRBACProps) => import("react/jsx-runtime").JSX.Element;
36
+ declare const DocumentRBAC: ({ children, permissions, model }: DocumentRBACProps) => import("react/jsx-runtime").JSX.Element;
36
37
  export { DocumentRBAC, useDocumentRBAC, DocumentRBACContextValue, DocumentRBACProps };
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { NotificationConfig } from '@strapi/admin/strapi-admin';
3
3
  import { ButtonProps } from '@strapi/design-system';
4
4
  import type { DocumentActionComponent } from '../../../content-manager';
5
- type DocumentActionPosition = 'panel' | 'header' | 'table-row' | 'preview';
5
+ type DocumentActionPosition = 'panel' | 'header' | 'table-row' | 'preview' | 'relation-modal';
6
6
  interface DocumentActionDescription {
7
7
  label: string;
8
8
  onClick?: (event: React.SyntheticEvent) => Promise<boolean | void> | boolean | void;
@@ -0,0 +1,8 @@
1
+ import { type DocumentMeta } from '../../../../../features/DocumentContext';
2
+ interface RelationModalProps {
3
+ triggerButtonLabel: string;
4
+ relation: DocumentMeta;
5
+ }
6
+ export declare function getCollectionType(url: string): string | undefined;
7
+ declare const RelationModalForm: ({ relation, triggerButtonLabel }: RelationModalProps) => import("react/jsx-runtime").JSX.Element;
8
+ export { RelationModalForm };
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { type InputProps } from '@strapi/admin/strapi-admin';
3
3
  import { FlexComponent } from '@strapi/design-system';
4
- import { type EditFieldLayout } from '../../../../hooks/useDocumentLayout';
5
- import { RelationResult } from '../../../../services/relations';
4
+ import { type EditFieldLayout } from '../../../../../hooks/useDocumentLayout';
5
+ import { RelationResult } from '../../../../../services/relations';
6
6
  type RelationPosition = (Pick<RelationResult, 'status' | 'locale'> & {
7
7
  before: string;
8
8
  end?: never;
@@ -17,6 +17,12 @@ interface Relation extends Pick<RelationResult, 'documentId' | 'id' | 'locale' |
17
17
  label: string;
18
18
  position?: RelationPosition;
19
19
  __temp_key__: string;
20
+ apiData?: {
21
+ documentId: RelationResult['documentId'];
22
+ id: RelationResult['id'];
23
+ locale?: RelationResult['locale'];
24
+ position: RelationPosition;
25
+ };
20
26
  }
21
27
  interface RelationsFieldProps extends Omit<Extract<EditFieldLayout, {
22
28
  type: 'relation';
@@ -34,6 +40,5 @@ declare const LinkEllipsis: import("styled-components").IStyledComponent<"web",
34
40
  ref?: ((instance: unknown) => void) | React.RefObject<unknown> | null | undefined;
35
41
  }, never>> & Omit<(<C extends React.ElementType<any, keyof React.JSX.IntrinsicElements> = "a">(props: React.PropsWithoutRef<import("@strapi/design-system").LinkProps<C>> & React.RefAttributes<unknown>) => React.ReactNode), keyof React.Component<any, {}, any>>;
36
42
  declare const MemoizedRelationsField: React.MemoExoticComponent<React.ForwardRefExoticComponent<RelationsFieldProps & React.RefAttributes<HTMLDivElement>>>;
37
- declare const MemoizedUnstableRelationsField: React.MemoExoticComponent<React.ForwardRefExoticComponent<RelationsFieldProps & React.RefAttributes<HTMLDivElement>>>;
38
- export { MemoizedRelationsField as RelationsInput, MemoizedUnstableRelationsField as UnstableRelationsInput, FlexWrapper, DisconnectButton, LinkEllipsis, };
43
+ export { MemoizedRelationsField as RelationsInput, FlexWrapper, DisconnectButton, LinkEllipsis };
39
44
  export type { RelationsFieldProps };
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Grid } from '@strapi/design-system';
3
3
  import { EditLayout } from '../../../hooks/useDocumentLayout';
4
+ import type { UseDocument } from '../../../hooks/useDocument';
4
5
  export declare const RESPONSIVE_CONTAINER_BREAKPOINTS: {
5
6
  sm: string;
6
7
  };
@@ -14,7 +15,7 @@ export declare const ResponsiveGridRoot: import("styled-components").IStyledComp
14
15
  }, "ref"> & {
15
16
  ref?: any;
16
17
  }, never>> & Omit<Grid.Component<"div">, keyof import("react").Component<any, {}, any>>;
17
- export declare const ResponsiveGridItem: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
18
+ export declare const ResponsiveGridItem: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<Omit<import("@strapi/design-system").TransientBoxProps & {
18
19
  children?: import("react").ReactNode;
19
20
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
20
21
  ref?: any;
@@ -25,9 +26,13 @@ export declare const ResponsiveGridItem: import("styled-components").IStyledComp
25
26
  m?: number | undefined;
26
27
  }, "ref"> & {
27
28
  ref?: any;
28
- }, never>> & Omit<Grid.ItemComponent<"div">, keyof import("react").Component<any, {}, any>>;
29
+ }, {
30
+ col: number;
31
+ }>> & Omit<Grid.ItemComponent<"div">, keyof import("react").Component<any, {}, any>>;
29
32
  interface FormLayoutProps extends Pick<EditLayout, 'layout'> {
30
33
  hasBackground?: boolean;
34
+ model?: string;
35
+ document: ReturnType<UseDocument>;
31
36
  }
32
- declare const FormLayout: ({ layout, hasBackground }: FormLayoutProps) => import("react/jsx-runtime").JSX.Element;
37
+ declare const FormLayout: ({ layout, document, hasBackground }: FormLayoutProps) => import("react/jsx-runtime").JSX.Element;
33
38
  export { FormLayout, FormLayoutProps };
@@ -1,9 +1,12 @@
1
- import { ReactNode } from 'react';
1
+ import * as React from 'react';
2
+ import { UseDocument } from '../../../hooks/useDocument';
2
3
  import type { EditFieldLayout } from '../../../hooks/useDocumentLayout';
3
4
  import type { Schema } from '@strapi/types';
4
5
  import type { DistributiveOmit } from 'react-redux';
5
- type InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'>;
6
- declare const useFieldHint: (hint: ReactNode, attribute: Schema.Attribute.AnyAttribute) => string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | (string | import("react/jsx-runtime").JSX.Element | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | import("react").ReactPortal)[] | null | undefined;
7
- declare const MemoizedInputRenderer: import("react").MemoExoticComponent<({ visible, hint: providedHint, ...props }: InputRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
6
+ type InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {
7
+ document: ReturnType<UseDocument>;
8
+ };
9
+ declare const useFieldHint: (hint: React.ReactNode, attribute: Schema.Attribute.AnyAttribute) => string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | (string | import("react/jsx-runtime").JSX.Element | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[] | null | undefined;
10
+ declare const MemoizedInputRenderer: React.MemoExoticComponent<({ visible, hint: providedHint, document, ...props }: InputRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
8
11
  export type { InputRendererProps };
9
12
  export { MemoizedInputRenderer as InputRenderer, useFieldHint };
@@ -1,3 +1,2 @@
1
- declare const UnstablePreviewHeader: () => import("react/jsx-runtime").JSX.Element;
2
1
  declare const PreviewHeader: () => import("react/jsx-runtime").JSX.Element;
3
- export { PreviewHeader, UnstablePreviewHeader };
2
+ export { PreviewHeader };
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import { type UseDocument } from '../../hooks/useDocument';
3
2
  import { type EditLayout } from '../../hooks/useDocumentLayout';
4
3
  interface PreviewContextValue {
@@ -8,7 +7,6 @@ interface PreviewContextValue {
8
7
  meta: NonNullable<ReturnType<UseDocument>['meta']>;
9
8
  schema: NonNullable<ReturnType<UseDocument>['schema']>;
10
9
  layout: EditLayout;
11
- iframeRef?: React.RefObject<HTMLIFrameElement>;
12
10
  }
13
11
  declare const usePreviewContext: <Selected>(consumerName: string, selector: (value: PreviewContextValue) => Selected) => Selected;
14
12
  declare const ProtectedPreviewPage: () => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/content-manager",
3
- "version": "5.11.0",
3
+ "version": "5.12.0-beta.0",
4
4
  "description": "A powerful UI to easily manage your data.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,8 +66,8 @@
66
66
  "@sindresorhus/slugify": "1.1.0",
67
67
  "@strapi/design-system": "2.0.0-rc.18",
68
68
  "@strapi/icons": "2.0.0-rc.18",
69
- "@strapi/types": "5.11.0",
70
- "@strapi/utils": "5.11.0",
69
+ "@strapi/types": "5.12.0-beta.0",
70
+ "@strapi/utils": "5.12.0-beta.0",
71
71
  "codemirror5": "npm:codemirror@^5.65.11",
72
72
  "date-fns": "2.30.0",
73
73
  "fractional-indexing": "3.2.0",
@@ -102,8 +102,8 @@
102
102
  "yup": "0.32.9"
103
103
  },
104
104
  "devDependencies": {
105
- "@strapi/admin": "5.11.0",
106
- "@strapi/database": "5.11.0",
105
+ "@strapi/admin": "5.12.0-beta.0",
106
+ "@strapi/database": "5.12.0-beta.0",
107
107
  "@testing-library/react": "15.0.7",
108
108
  "@types/jest": "29.5.2",
109
109
  "@types/lodash": "^4.14.191",
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditViewPage-B48r4DLX.js","sources":["../../../admin/src/hooks/useOnce.ts","../../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n getTitle,\n getInitialFormValues,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n const initialValues = getInitialFormValues(isCreatingDocument);\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues || hasError) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{getTitle(mainField)}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={getTitle(mainField)}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["useOnce","effect","React","useEffect","emptyDeps","EditViewPage","location","useLocation","query","status","setQuery","useQueryParams","formatMessage","useIntl","toggleNotification","useNotification","document","meta","isLoading","isLoadingDocument","schema","components","collectionType","id","model","hasError","getTitle","getInitialFormValues","useDoc","hasDraftAndPublished","options","draftAndPublish","state","type","message","error","timeout","isLoadingActionsRBAC","useDocumentRBAC","isSingleType","SINGLE_TYPES","isCreatingDocument","isLoadingLayout","edit","layout","settings","mainField","useDocumentLayout","isLazyLoading","useLazyComponents","initialValues","documentId","_jsx","Page","Loading","Error","handleTabChange","validateSync","values","yupSchema","createYupSchema","attributes","abortEarly","_jsxs","Main","paddingLeft","paddingRight","Title","Form","disabled","method","validate","initialErrors","forceValidation","resetForm","_Fragment","Header","isCreating","getDocumentStatus","undefined","title","Tabs","Root","variant","value","onValueChange","List","aria-label","getTranslation","defaultMessage","StatusTab","availableStatus","length","Grid","paddingTop","gap","Item","col","s","direction","alignItems","Content","FormLayout","Panels","Blocker","onProceed","styled","Trigger","docStatus","statuses","find","doc","publishedAt","ProtectedEditViewPage","slug","useParams","permissions","useRBAC","PERMISSIONS","map","action","subject","Protect","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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