@strapi/content-manager 0.0.0-next.e98ae27d8c69c68823eb7c46cf329385637ba393 → 0.0.0-next.eb48c73c86cbc452c1ba8d727106f9ed9da0c834
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/chunks/{ComponentConfigurationPage-Bn-SMKJG.js → ComponentConfigurationPage-B-gE3kXG.js} +5 -6
- package/dist/admin/chunks/{ComponentConfigurationPage-Bn-SMKJG.js.map → ComponentConfigurationPage-B-gE3kXG.js.map} +1 -1
- package/dist/admin/chunks/{ComponentConfigurationPage-Cqi5KqZa.mjs → ComponentConfigurationPage-R5N6EwIp.mjs} +5 -6
- package/dist/admin/chunks/{ComponentConfigurationPage-Cqi5KqZa.mjs.map → ComponentConfigurationPage-R5N6EwIp.mjs.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-Dm16gciL.mjs → EditConfigurationPage-0y9O2nBU.mjs} +5 -6
- package/dist/admin/chunks/{EditConfigurationPage-Dm16gciL.mjs.map → EditConfigurationPage-0y9O2nBU.mjs.map} +1 -1
- package/dist/admin/chunks/{EditConfigurationPage-CRxsqOhS.js → EditConfigurationPage-C62WuGTf.js} +5 -6
- package/dist/admin/chunks/{EditConfigurationPage-CRxsqOhS.js.map → EditConfigurationPage-C62WuGTf.js.map} +1 -1
- package/dist/admin/chunks/{EditViewPage-Dk8CeS40.js → EditViewPage-CiYAHBOX.js} +102 -95
- package/dist/admin/chunks/EditViewPage-CiYAHBOX.js.map +1 -0
- package/dist/admin/chunks/{EditViewPage-eTCSh2HB.mjs → EditViewPage-CkO2YLdg.mjs} +102 -95
- package/dist/admin/chunks/EditViewPage-CkO2YLdg.mjs.map +1 -0
- package/dist/admin/chunks/{Form-PB1sNax8.js → Form-DUs6lQ0C.js} +5 -5
- package/dist/admin/chunks/{Form-PB1sNax8.js.map → Form-DUs6lQ0C.js.map} +1 -1
- package/dist/admin/chunks/{Form-K_hq8zU4.mjs → Form-Db9A3cMO.mjs} +3 -3
- package/dist/admin/chunks/{Form-K_hq8zU4.mjs.map → Form-Db9A3cMO.mjs.map} +1 -1
- package/dist/admin/chunks/{History-CD5uVchr.mjs → History-BQ7IAJjV.mjs} +16 -12
- package/dist/admin/chunks/History-BQ7IAJjV.mjs.map +1 -0
- package/dist/admin/chunks/{History-CfsF-U-3.js → History-D99wxPry.js} +17 -13
- package/dist/admin/chunks/History-D99wxPry.js.map +1 -0
- package/dist/admin/chunks/{Input-grmHplxs.mjs → Input-CHDnpU3S.mjs} +1340 -55
- package/dist/admin/chunks/Input-CHDnpU3S.mjs.map +1 -0
- package/dist/admin/chunks/{Input-CU93J6dl.js → Input-Gop65dq6.js} +1352 -64
- package/dist/admin/chunks/Input-Gop65dq6.js.map +1 -0
- package/dist/admin/chunks/{ListConfigurationPage-Eo8txFp0.mjs → ListConfigurationPage-Bte99c0c.mjs} +4 -5
- package/dist/admin/chunks/{ListConfigurationPage-Eo8txFp0.mjs.map → ListConfigurationPage-Bte99c0c.mjs.map} +1 -1
- package/dist/admin/chunks/{ListConfigurationPage-nZti--Mw.js → ListConfigurationPage-pAdM7Lbn.js} +6 -7
- package/dist/admin/chunks/{ListConfigurationPage-nZti--Mw.js.map → ListConfigurationPage-pAdM7Lbn.js.map} +1 -1
- package/dist/admin/chunks/{ListViewPage-BBX-zSka.mjs → ListViewPage-7RTPaDs2.mjs} +3 -5
- package/dist/admin/chunks/ListViewPage-7RTPaDs2.mjs.map +1 -0
- package/dist/admin/chunks/{ListViewPage-DQYvHCxn.js → ListViewPage-CaBwwCVc.js} +7 -9
- package/dist/admin/chunks/ListViewPage-CaBwwCVc.js.map +1 -0
- package/dist/admin/chunks/{NoContentTypePage-C-rbOQO1.mjs → NoContentTypePage-CuTk3q_I.mjs} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-C-rbOQO1.mjs.map → NoContentTypePage-CuTk3q_I.mjs.map} +1 -1
- package/dist/admin/chunks/{NoContentTypePage-ChYgz3sN.js → NoContentTypePage-DLD28j4F.js} +2 -2
- package/dist/admin/chunks/{NoContentTypePage-ChYgz3sN.js.map → NoContentTypePage-DLD28j4F.js.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-CuxrInhz.mjs → NoPermissionsPage-DSIlPmvv.mjs} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-CuxrInhz.mjs.map → NoPermissionsPage-DSIlPmvv.mjs.map} +1 -1
- package/dist/admin/chunks/{NoPermissionsPage-H4SAlJeF.js → NoPermissionsPage-iVMEcUp0.js} +2 -2
- package/dist/admin/chunks/{NoPermissionsPage-H4SAlJeF.js.map → NoPermissionsPage-iVMEcUp0.js.map} +1 -1
- package/dist/admin/chunks/{Preview-HqnNXn4S.mjs → Preview-35wsOM_p.mjs} +136 -211
- package/dist/admin/chunks/Preview-35wsOM_p.mjs.map +1 -0
- package/dist/admin/chunks/{Preview-Bz2dgOiw.js → Preview-CSU1sCSK.js} +134 -209
- package/dist/admin/chunks/Preview-CSU1sCSK.js.map +1 -0
- package/dist/admin/chunks/{en-CImiNxXE.mjs → en-C2zEwS3-.mjs} +4 -1
- package/dist/admin/chunks/{en-CImiNxXE.mjs.map → en-C2zEwS3-.mjs.map} +1 -1
- package/dist/admin/chunks/{en-CLf4SuMQ.js → en-G976DLsg.js} +4 -1
- package/dist/admin/chunks/{en-CLf4SuMQ.js.map → en-G976DLsg.js.map} +1 -1
- package/dist/admin/chunks/{index-DfX0uEQT.js → index-Cmh0Byay.js} +213 -129
- package/dist/admin/chunks/index-Cmh0Byay.js.map +1 -0
- package/dist/admin/chunks/{index-CS_nLuw2.mjs → index-DFvqTQvr.mjs} +212 -131
- package/dist/admin/chunks/index-DFvqTQvr.mjs.map +1 -0
- package/dist/admin/chunks/{layout-B4Uk0v1z.js → layout-DuH1v82S.js} +86 -13
- package/dist/admin/chunks/layout-DuH1v82S.js.map +1 -0
- package/dist/admin/chunks/{layout-BInXGFmo.mjs → layout-zQ9o6rg0.mjs} +78 -5
- package/dist/admin/chunks/layout-zQ9o6rg0.mjs.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-gcqEJMnO.js → objects-BJTP843m.js} +73 -1
- package/dist/admin/chunks/objects-BJTP843m.js.map +1 -0
- package/dist/admin/chunks/{useDragAndDrop-HYwNDExe.mjs → objects-D2z-IJgu.mjs} +72 -2
- package/dist/admin/chunks/objects-D2z-IJgu.mjs.map +1 -0
- package/dist/admin/chunks/{relations-9C5dQI9e.js → usePrev-B_pceXQ5.js} +18 -2
- package/dist/admin/chunks/usePrev-B_pceXQ5.js.map +1 -0
- package/dist/admin/chunks/{relations-CwL0ThH9.mjs → usePrev-CJFOGBK2.mjs} +18 -4
- package/dist/admin/chunks/usePrev-CJFOGBK2.mjs.map +1 -0
- package/dist/admin/chunks/{zh-Hans-CI0HKio3.mjs → zh-Hans-DEAhqI3x.mjs} +3 -2
- package/dist/admin/chunks/{zh-Hans-CI0HKio3.mjs.map → zh-Hans-DEAhqI3x.mjs.map} +1 -1
- package/dist/admin/chunks/{zh-Hans-JVK9x7xr.js → zh-Hans-Djj7eGpO.js} +3 -2
- package/dist/admin/chunks/{zh-Hans-JVK9x7xr.js.map → zh-Hans-Djj7eGpO.js.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/content-manager.d.ts +3 -0
- package/dist/admin/src/features/DocumentContext.d.ts +53 -0
- package/dist/admin/src/features/DocumentRBAC.d.ts +3 -2
- package/dist/admin/src/hooks/useDocument.d.ts +2 -0
- package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +8 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/{Relations.d.ts → Relations/Relations.d.ts} +9 -4
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +8 -3
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +7 -4
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +1 -2
- package/package.json +6 -6
- package/dist/admin/chunks/EditViewPage-Dk8CeS40.js.map +0 -1
- package/dist/admin/chunks/EditViewPage-eTCSh2HB.mjs.map +0 -1
- package/dist/admin/chunks/History-CD5uVchr.mjs.map +0 -1
- package/dist/admin/chunks/History-CfsF-U-3.js.map +0 -1
- package/dist/admin/chunks/Input-CU93J6dl.js.map +0 -1
- package/dist/admin/chunks/Input-grmHplxs.mjs.map +0 -1
- package/dist/admin/chunks/ListViewPage-BBX-zSka.mjs.map +0 -1
- package/dist/admin/chunks/ListViewPage-DQYvHCxn.js.map +0 -1
- package/dist/admin/chunks/Preview-Bz2dgOiw.js.map +0 -1
- package/dist/admin/chunks/Preview-HqnNXn4S.mjs.map +0 -1
- package/dist/admin/chunks/Relations-BMvL4yMN.mjs +0 -1291
- package/dist/admin/chunks/Relations-BMvL4yMN.mjs.map +0 -1
- package/dist/admin/chunks/Relations-CbCAt692.js +0 -1318
- package/dist/admin/chunks/Relations-CbCAt692.js.map +0 -1
- package/dist/admin/chunks/index-CS_nLuw2.mjs.map +0 -1
- package/dist/admin/chunks/index-DfX0uEQT.js.map +0 -1
- package/dist/admin/chunks/layout-B4Uk0v1z.js.map +0 -1
- package/dist/admin/chunks/layout-BInXGFmo.mjs.map +0 -1
- package/dist/admin/chunks/objects-C3EebVVe.js +0 -76
- package/dist/admin/chunks/objects-C3EebVVe.js.map +0 -1
- package/dist/admin/chunks/objects-wl73iEma.mjs +0 -73
- package/dist/admin/chunks/objects-wl73iEma.mjs.map +0 -1
- package/dist/admin/chunks/relations-9C5dQI9e.js.map +0 -1
- package/dist/admin/chunks/relations-CwL0ThH9.mjs.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-HYwNDExe.mjs.map +0 -1
- package/dist/admin/chunks/useDragAndDrop-gcqEJMnO.js.map +0 -1
- package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs +0 -18
- package/dist/admin/chunks/usePrev-Bjw2dhmq.mjs.map +0 -1
- package/dist/admin/chunks/usePrev-DIYl-IAL.js +0 -21
- package/dist/admin/chunks/usePrev-DIYl-IAL.js.map +0 -1
- package/dist/admin/src/preview/components/PreviewContent.d.ts +0 -3
@@ -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
|
-
|
247
|
-
|
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","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AK,CAAC,GAAGtC,CAAI,GAAA,CAAA,CAAA,CAAA;QAE1D,IAAIqC,UAAAA,KAAeZ,QAASY,CAAAA,UAAAA,CAAAA,IAAe9C,MAAMC,OAAO,CAAC6C,WAAU,CAAI,EAAA;AACrEH,YAAAA,MAAAA,GAASA,MAAM,CAACE,WAAY,CAAA,GAAGH,KAAMI,CAAAA,UAAAA,CAAAA;SAChC,MAAA;AACL,YAAA,MAAME,QAAmBJ,GAAAA,SAAS,CAACnC,CAAAA,GAAI,CAAE,CAAA;YACzCkC,MAASA,GAAAA,MAAM,CAACE,WAAAA,CAAY,GAAGV,SAAAA,CAAUa,QAAaV,CAAAA,IAAAA,MAAAA,CAAOU,QAAa,CAAA,IAAA,CAAA,GAAI,EAAE,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-
|
5
|
+
var index = require('./index-Cmh0Byay.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
|
-
|
193
|
+
exports.usePrev = usePrev;
|
194
|
+
//# sourceMappingURL=usePrev-B_pceXQ5.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePrev-B_pceXQ5.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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EV,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 {
|
3
|
+
import { l as contentManagerApi } from './index-DFvqTQvr.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
|
-
|
173
|
-
|
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-CJFOGBK2.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePrev-CJFOGBK2.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,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,GAAeC,iBAAkBC,CAAAA,eAAe,CAAC;IACrDC,SAAW,EAAA,CAACC,SAAW;YACrBC,YAAcD,EAAAA,KAAAA,CAAME,KAAK,CAKvB;gBACAA,KAAO,EAAA,CAAC,EAAEC,KAAK,EAAEC,EAAE,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAA;oBACxC,OAAO;wBACLC,GAAK,EAAA,CAAC,2BAA2B,EAAEJ,KAAM,CAAA,CAAC,EAAEC,EAAG,CAAA,CAAC,EAAEC,WAAAA,CAAY,CAAC;wBAC/DG,MAAQ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AOD,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;;;;"}
|
@@ -148,7 +148,8 @@ var zhHans = {
|
|
148
148
|
"Settings.application.description": "管理面板的全局信息",
|
149
149
|
"Settings.application.edition-title": "当前计划",
|
150
150
|
"Settings.application.ee-or-ce": "{communityEdition, select, true {社区版} other {企业版}}",
|
151
|
-
"Settings.application.ee.admin-seats.add-seats": "
|
151
|
+
"Settings.application.ee.admin-seats.add-seats": "管理座位",
|
152
|
+
"Settings.application.ee.admin-seats.support": "请联系支持团队",
|
152
153
|
"Settings.application.ee.admin-seats.at-limit-tooltip": "已达上限:添加座位以邀请更多用户",
|
153
154
|
"Settings.application.ee.admin-seats.count": "<text>{enforcementUserCount}</text>/{permittedSeats}",
|
154
155
|
"Settings.application.get-help": "获取帮助",
|
@@ -931,4 +932,4 @@ var zhHans = {
|
|
931
932
|
};
|
932
933
|
|
933
934
|
export { Analytics, Documentation, Email, Password, Provider, ResetPasswordToken, Role, Username, Users, anErrorOccurred, clearLabel, dark, zhHans as default, light, or, selectButtonTitle, skipToContent, submit };
|
934
|
-
//# sourceMappingURL=zh-Hans-
|
935
|
+
//# sourceMappingURL=zh-Hans-DEAhqI3x.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zh-Hans-
|
1
|
+
{"version":3,"file":"zh-Hans-DEAhqI3x.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -150,7 +150,8 @@ var zhHans = {
|
|
150
150
|
"Settings.application.description": "管理面板的全局信息",
|
151
151
|
"Settings.application.edition-title": "当前计划",
|
152
152
|
"Settings.application.ee-or-ce": "{communityEdition, select, true {社区版} other {企业版}}",
|
153
|
-
"Settings.application.ee.admin-seats.add-seats": "
|
153
|
+
"Settings.application.ee.admin-seats.add-seats": "管理座位",
|
154
|
+
"Settings.application.ee.admin-seats.support": "请联系支持团队",
|
154
155
|
"Settings.application.ee.admin-seats.at-limit-tooltip": "已达上限:添加座位以邀请更多用户",
|
155
156
|
"Settings.application.ee.admin-seats.count": "<text>{enforcementUserCount}</text>/{permittedSeats}",
|
156
157
|
"Settings.application.get-help": "获取帮助",
|
@@ -950,4 +951,4 @@ exports.or = or;
|
|
950
951
|
exports.selectButtonTitle = selectButtonTitle;
|
951
952
|
exports.skipToContent = skipToContent;
|
952
953
|
exports.submit = submit;
|
953
|
-
//# sourceMappingURL=zh-Hans-
|
954
|
+
//# sourceMappingURL=zh-Hans-Djj7eGpO.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zh-Hans-
|
1
|
+
{"version":3,"file":"zh-Hans-Djj7eGpO.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/admin/index.js
CHANGED
@@ -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-
|
6
|
+
var index = require('./chunks/index-Cmh0Byay.js');
|
7
7
|
require('prismjs');
|
8
8
|
require('react/jsx-runtime');
|
9
9
|
require('@strapi/admin/strapi-admin');
|
package/dist/admin/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import '@strapi/icons';
|
2
|
-
export {
|
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-DFvqTQvr.mjs';
|
3
3
|
import 'prismjs';
|
4
4
|
import 'react/jsx-runtime';
|
5
5
|
import '@strapi/admin/strapi-admin';
|
@@ -57,6 +57,9 @@ interface PanelComponent extends DescriptionComponent<PanelComponentProps, Panel
|
|
57
57
|
type?: 'actions' | 'releases';
|
58
58
|
}
|
59
59
|
interface DocumentActionProps extends EditViewContext {
|
60
|
+
onPreview?: () => void;
|
61
|
+
fromPreview?: boolean;
|
62
|
+
fromRelationModal?: boolean;
|
60
63
|
}
|
61
64
|
interface DocumentActionComponent extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {
|
62
65
|
type?: 'clone' | 'configure-the-view' | 'delete' | 'discard' | 'edit' | 'edit-the-model' | 'history' | 'publish' | 'unpublish' | 'update';
|
@@ -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 };
|
@@ -34,6 +34,7 @@ type UseDocument = (args: UseDocumentArgs, opts?: UseDocumentOpts) => {
|
|
34
34
|
schema?: Schema;
|
35
35
|
schemas?: Schema[];
|
36
36
|
hasError?: boolean;
|
37
|
+
refetch: () => void;
|
37
38
|
validate: (document: Document) => null | FormErrors;
|
38
39
|
/**
|
39
40
|
* Get the document's title
|
@@ -91,6 +92,7 @@ declare const useDoc: () => {
|
|
91
92
|
schema?: ContentType | undefined;
|
92
93
|
schemas?: ContentType[] | undefined;
|
93
94
|
hasError?: boolean | undefined;
|
95
|
+
refetch: () => void;
|
94
96
|
validate: (document: Document) => null | FormErrors;
|
95
97
|
/**
|
96
98
|
* Get the document's title
|
@@ -16,7 +16,7 @@ type BulkOperationResponse<TResponse extends {
|
|
16
16
|
}> = Pick<TResponse, 'data'> | {
|
17
17
|
error: BaseQueryError | SerializedError;
|
18
18
|
};
|
19
|
-
type UseDocumentActions = () => {
|
19
|
+
type UseDocumentActions = (fromPreview?: boolean, fromRelationModal?: boolean) => {
|
20
20
|
/**
|
21
21
|
* @description Attempts to clone a document based on the provided sourceId.
|
22
22
|
* This will return a list of the fields as an error if it's unable to clone.
|
@@ -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 '
|
5
|
-
import { RelationResult } from '
|
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
|
-
|
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").
|
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
|
-
},
|
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
|
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
|
-
|
7
|
-
|
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 };
|