@strapi/content-manager 0.0.0-experimental.6b93a97ac754785f7894c17263d3b4fd5272454a → 0.0.0-experimental.6cc8ff695218d5a391739344d308dfb3683215c1
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/components/DragPreviews/RelationDragPreview.js +1 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.js.map +1 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.mjs +1 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.mjs.map +1 -1
- package/dist/admin/components/LeftMenu.js +34 -30
- package/dist/admin/components/LeftMenu.js.map +1 -1
- package/dist/admin/components/LeftMenu.mjs +36 -32
- package/dist/admin/components/LeftMenu.mjs.map +1 -1
- package/dist/admin/content-manager.js.map +1 -1
- package/dist/admin/content-manager.mjs.map +1 -1
- package/dist/admin/features/DocumentContext.js +71 -0
- package/dist/admin/features/DocumentContext.js.map +1 -0
- package/dist/admin/features/DocumentContext.mjs +49 -0
- package/dist/admin/features/DocumentContext.mjs.map +1 -0
- package/dist/admin/features/DocumentRBAC.js +7 -6
- package/dist/admin/features/DocumentRBAC.js.map +1 -1
- package/dist/admin/features/DocumentRBAC.mjs +7 -6
- package/dist/admin/features/DocumentRBAC.mjs.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/history/pages/History.js +9 -1
- package/dist/admin/history/pages/History.js.map +1 -1
- package/dist/admin/history/pages/History.mjs +9 -1
- package/dist/admin/history/pages/History.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js +12 -3
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +12 -3
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +95 -84
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +95 -84
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +26 -11
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +26 -11
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentStatus.js +1 -2
- package/dist/admin/pages/EditView/components/DocumentStatus.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentStatus.mjs +1 -2
- package/dist/admin/pages/EditView/components/DocumentStatus.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +5 -3
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +5 -3
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +17 -8
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +17 -8
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +16 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +17 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +3 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +3 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +460 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +438 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/{Relations.js → Relations/Relations.js} +65 -42
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/{Relations.mjs → Relations/Relations.mjs} +66 -43
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -0
- package/dist/admin/pages/EditView/components/FormLayout.js +20 -13
- package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.mjs +20 -13
- package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +35 -8
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +18 -10
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +41 -0
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +42 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.js +0 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.mjs +0 -1
- package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.js +5 -77
- package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.mjs +7 -78
- package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
- package/dist/admin/preview/pages/Preview.js +47 -39
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +48 -40
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/services/documents.js +16 -0
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +16 -0
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/content-manager.d.ts +2 -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/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} +8 -2
- 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/dist/admin/src/preview/pages/Preview.d.ts +0 -2
- package/dist/admin/translations/en.json.js +3 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +3 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/translations/zh-Hans.json.js +2 -1
- package/dist/admin/translations/zh-Hans.json.js.map +1 -1
- package/dist/admin/translations/zh-Hans.json.mjs +2 -1
- package/dist/admin/translations/zh-Hans.json.mjs.map +1 -1
- package/dist/server/src/index.d.ts +1 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/data-mapper.d.ts +1 -0
- package/dist/server/src/services/data-mapper.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/admin/pages/EditView/components/FormInputs/Relations.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations.mjs.map +0 -1
- package/dist/admin/preview/components/PreviewContent.js +0 -25
- package/dist/admin/preview/components/PreviewContent.js.map +0 -1
- package/dist/admin/preview/components/PreviewContent.mjs +0 -23
- package/dist/admin/preview/components/PreviewContent.mjs.map +0 -1
- package/dist/admin/src/preview/components/PreviewContent.d.ts +0 -2
package/dist/admin/pages/EditView/components/FormInputs/{Relations.mjs → Relations/Relations.mjs}
RENAMED
@@ -1,26 +1,26 @@
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
2
2
|
import * as React from 'react';
|
3
3
|
import { useQueryParams, useForm, useField, useNotification, useFocusInputField } from '@strapi/admin/strapi-admin';
|
4
|
-
import { Flex, Box, Link, TextButton, Field, Combobox, ComboboxOption, Typography, VisuallyHidden, useComposedRefs, IconButton
|
4
|
+
import { Flex, Box, Link, TextButton, Field, Combobox, ComboboxOption, Typography, VisuallyHidden, useComposedRefs, IconButton } from '@strapi/design-system';
|
5
5
|
import { ArrowClockwise, Drag, Cross } from '@strapi/icons';
|
6
6
|
import { generateNKeysBetween } from 'fractional-indexing';
|
7
7
|
import pipe from 'lodash/fp/pipe';
|
8
8
|
import { getEmptyImage } from 'react-dnd-html5-backend';
|
9
9
|
import { useIntl } from 'react-intl';
|
10
|
-
import { NavLink } from 'react-router-dom';
|
11
10
|
import { FixedSizeList } from 'react-window';
|
12
11
|
import { styled } from 'styled-components';
|
13
|
-
import { COLLECTION_TYPES } from '
|
14
|
-
import { ItemTypes } from '
|
15
|
-
import {
|
16
|
-
import {
|
17
|
-
import { useDragAndDrop, DROP_SENSITIVITY } from '
|
18
|
-
import { useGetRelationsQuery, useLazySearchRelationsQuery } from '
|
19
|
-
import { buildValidParams } from '
|
20
|
-
import { getRelationLabel } from '
|
21
|
-
import { getTranslation } from '
|
22
|
-
import { DocumentStatus } from '
|
23
|
-
import { useComponent } from '
|
12
|
+
import { COLLECTION_TYPES } from '../../../../../constants/collections.mjs';
|
13
|
+
import { ItemTypes } from '../../../../../constants/dragAndDrop.mjs';
|
14
|
+
import { useDocumentContext } from '../../../../../features/DocumentContext.mjs';
|
15
|
+
import { useDebounce } from '../../../../../hooks/useDebounce.mjs';
|
16
|
+
import { useDragAndDrop, DROP_SENSITIVITY } from '../../../../../hooks/useDragAndDrop.mjs';
|
17
|
+
import { useGetRelationsQuery, useLazySearchRelationsQuery } from '../../../../../services/relations.mjs';
|
18
|
+
import { buildValidParams } from '../../../../../utils/api.mjs';
|
19
|
+
import { getRelationLabel } from '../../../../../utils/relations.mjs';
|
20
|
+
import { getTranslation } from '../../../../../utils/translations.mjs';
|
21
|
+
import { DocumentStatus } from '../../DocumentStatus.mjs';
|
22
|
+
import { useComponent } from '../ComponentContext.mjs';
|
23
|
+
import { RelationModalForm, getCollectionType } from './RelationModal.mjs';
|
24
24
|
|
25
25
|
/**
|
26
26
|
* Remove a relation, whether it's been already saved or not.
|
@@ -75,12 +75,17 @@ const ONE_WAY_RELATIONS = [
|
|
75
75
|
* At present we do not expose this to plugin developers, however, they are able to overwrite it themselves should
|
76
76
|
* they wish to do so.
|
77
77
|
*/ const RelationsField = /*#__PURE__*/ React.forwardRef(({ disabled, label, ...props }, ref)=>{
|
78
|
+
const currentDocumentMeta = useDocumentContext('RelationsField', (state)=>state.meta);
|
79
|
+
const currentDocument = useDocumentContext('RelationsField', (state)=>state.document);
|
80
|
+
const rootDocumentMeta = useDocumentContext('RelationsField', (state)=>state.rootDocumentMeta);
|
78
81
|
const [currentPage, setCurrentPage] = React.useState(1);
|
79
|
-
const
|
80
|
-
const
|
82
|
+
const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;
|
83
|
+
const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;
|
84
|
+
// Use the documentId from the actual document, not the params (meta)
|
85
|
+
const documentId = currentDocument.document?.documentId;
|
81
86
|
const { formatMessage } = useIntl();
|
82
87
|
const [{ query }] = useQueryParams();
|
83
|
-
const params = buildValidParams(query);
|
88
|
+
const params = documentMeta.params ?? buildValidParams(query);
|
84
89
|
const isMorph = props.attribute.relation.toLowerCase().includes('morph');
|
85
90
|
const isDisabled = isMorph || disabled;
|
86
91
|
const { componentId, componentUID } = useComponent('RelationsField', ({ uid, id })=>({
|
@@ -93,22 +98,29 @@ const ONE_WAY_RELATIONS = [
|
|
93
98
|
}, [
|
94
99
|
isSubmitting
|
95
100
|
]);
|
101
|
+
const component = componentUID && currentDocument.components[componentUID];
|
96
102
|
/**
|
97
103
|
* We'll always have a documentId in a created entry, so we look for a componentId first.
|
98
104
|
* Same with `uid` and `documentModel`.
|
99
|
-
*/ const
|
100
|
-
const
|
105
|
+
*/ const model = component ? component.uid : documentMeta.model;
|
106
|
+
const id = component && componentId ? componentId.toString() : documentId;
|
101
107
|
/**
|
102
108
|
* The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.
|
103
109
|
* Where the above example would a nested field within two components, however
|
104
110
|
* we only require the field on the component not the complete path since we query
|
105
111
|
* individual components. Therefore we split the string and take the last item.
|
106
112
|
*/ const [targetField] = props.name.split('.').slice(-1);
|
113
|
+
const schemaAttributes = component ? component.attributes ?? {} : currentDocument.schema?.attributes ?? {};
|
114
|
+
/**
|
115
|
+
* Confirm the target field is related to the current document.
|
116
|
+
* Since relations can exist in a modal on top of the root document,
|
117
|
+
* we need to ensure we are fetching relations for the correct document (root document vs related document),
|
118
|
+
*/ const isRelatedToCurrentDocument = Object.values(schemaAttributes).filter((attribute)=>attribute.type === 'relation' && 'target' in attribute && 'target' in props.attribute && attribute.target === props.attribute.target).length > 0;
|
107
119
|
const { data, isLoading, isFetching } = useGetRelationsQuery({
|
108
120
|
model,
|
109
121
|
targetField,
|
110
122
|
// below we don't run the query if there is no id.
|
111
|
-
id
|
123
|
+
id,
|
112
124
|
params: {
|
113
125
|
...params,
|
114
126
|
pageSize: RELATIONS_TO_DISPLAY,
|
@@ -116,7 +128,7 @@ const ONE_WAY_RELATIONS = [
|
|
116
128
|
}
|
117
129
|
}, {
|
118
130
|
refetchOnMountOrArgChange: true,
|
119
|
-
skip: !id,
|
131
|
+
skip: !id || !isRelatedToCurrentDocument,
|
120
132
|
selectFromResult: (result)=>{
|
121
133
|
return {
|
122
134
|
...result,
|
@@ -225,10 +237,11 @@ const ONE_WAY_RELATIONS = [
|
|
225
237
|
/*#__PURE__*/ jsx(RelationsInput, {
|
226
238
|
disabled: isDisabled,
|
227
239
|
// NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)
|
228
|
-
id: componentUID ? componentId ? `${componentId}` : '' : documentId,
|
240
|
+
id: componentUID && component ? componentId ? `${componentId}` : '' : documentId,
|
229
241
|
label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`,
|
230
242
|
model: model,
|
231
243
|
onChange: handleConnect,
|
244
|
+
isRelatedToCurrentDocument: isRelatedToCurrentDocument,
|
232
245
|
...props
|
233
246
|
}),
|
234
247
|
'pagination' in data && data.pagination && data.pagination.pageCount > data.pagination.page ? /*#__PURE__*/ jsx(TextButton, {
|
@@ -251,7 +264,9 @@ const ONE_WAY_RELATIONS = [
|
|
251
264
|
disabled: isDisabled,
|
252
265
|
name: props.name,
|
253
266
|
isLoading: isFetchingMoreRelations,
|
254
|
-
relationType: props.attribute.relation
|
267
|
+
relationType: props.attribute.relation,
|
268
|
+
// @ts-expect-error – targetModel does exist on the attribute. But it's not typed.
|
269
|
+
targetModel: props.attribute.targetModel
|
255
270
|
})
|
256
271
|
]
|
257
272
|
});
|
@@ -294,7 +309,7 @@ const ONE_WAY_RELATIONS = [
|
|
294
309
|
/**
|
295
310
|
* @description Contains all the logic for the combobox that can search
|
296
311
|
* for relations and then add them to the field's connect array.
|
297
|
-
*/ const RelationsInput = ({ hint, id, model, label, labelAction, name, mainField, placeholder, required, unique: _unique, 'aria-label': _ariaLabel, onChange, ...props })=>{
|
312
|
+
*/ const RelationsInput = ({ hint, id, model, label, labelAction, name, mainField, placeholder, required, unique: _unique, 'aria-label': _ariaLabel, onChange, isRelatedToCurrentDocument, ...props })=>{
|
298
313
|
const [textValue, setTextValue] = React.useState('');
|
299
314
|
const [searchParams, setSearchParams] = React.useState({
|
300
315
|
_q: '',
|
@@ -302,6 +317,10 @@ const ONE_WAY_RELATIONS = [
|
|
302
317
|
});
|
303
318
|
const { toggleNotification } = useNotification();
|
304
319
|
const [{ query }] = useQueryParams();
|
320
|
+
const currentDocumentMeta = useDocumentContext('RelationsInput', (state)=>state.meta);
|
321
|
+
const rootDocumentMeta = useDocumentContext('RelationsInput', (state)=>state.rootDocumentMeta);
|
322
|
+
const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;
|
323
|
+
const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;
|
305
324
|
const { formatMessage } = useIntl();
|
306
325
|
const fieldRef = useFocusInputField(name);
|
307
326
|
const field = useField(name);
|
@@ -319,11 +338,14 @@ const ONE_WAY_RELATIONS = [
|
|
319
338
|
* we only require the field on the component not the complete path since we query
|
320
339
|
* individual components. Therefore we split the string and take the last item.
|
321
340
|
*/ const [targetField] = name.split('.').slice(-1);
|
341
|
+
// Return early if there is no relation to the document
|
342
|
+
if (!isRelatedToCurrentDocument) return;
|
343
|
+
const params = documentMeta.params ?? buildValidParams(query);
|
322
344
|
searchForTrigger({
|
323
345
|
model,
|
324
346
|
targetField,
|
325
347
|
params: {
|
326
|
-
...
|
348
|
+
...params,
|
327
349
|
id: id ?? '',
|
328
350
|
pageSize: 10,
|
329
351
|
idsToInclude: field.value?.disconnect?.map((rel)=>rel.id.toString()) ?? [],
|
@@ -339,7 +361,9 @@ const ONE_WAY_RELATIONS = [
|
|
339
361
|
name,
|
340
362
|
query,
|
341
363
|
searchForTrigger,
|
342
|
-
searchParamsDebounced
|
364
|
+
searchParamsDebounced,
|
365
|
+
isRelatedToCurrentDocument,
|
366
|
+
documentMeta
|
343
367
|
]);
|
344
368
|
const handleSearch = async (search)=>{
|
345
369
|
setSearchParams((s)=>({
|
@@ -461,7 +485,7 @@ const ONE_WAY_RELATIONS = [
|
|
461
485
|
* RelationsList
|
462
486
|
* -----------------------------------------------------------------------------------------------*/ const RELATION_ITEM_HEIGHT = 50;
|
463
487
|
const RELATION_GUTTER = 4;
|
464
|
-
const RelationsList = ({ data, serverData, disabled, name, isLoading, relationType })=>{
|
488
|
+
const RelationsList = ({ data, serverData, disabled, name, isLoading, relationType, targetModel })=>{
|
465
489
|
const ariaDescriptionId = React.useId();
|
466
490
|
const { formatMessage } = useIntl();
|
467
491
|
const listRef = React.useRef(null);
|
@@ -545,8 +569,8 @@ const RelationsList = ({ data, serverData, disabled, name, isLoading, relationTy
|
|
545
569
|
...{
|
546
570
|
apiData: {
|
547
571
|
id: relation.id,
|
548
|
-
documentId: relation.documentId,
|
549
|
-
locale: relation.locale,
|
572
|
+
documentId: relation.documentId ?? relation.apiData?.documentId ?? '',
|
573
|
+
locale: relation.locale || relation.apiData?.locale,
|
550
574
|
position
|
551
575
|
}
|
552
576
|
}
|
@@ -625,7 +649,8 @@ const RelationsList = ({ data, serverData, disabled, name, isLoading, relationTy
|
|
625
649
|
handleMoveItem,
|
626
650
|
name,
|
627
651
|
handleDisconnect,
|
628
|
-
relations: data
|
652
|
+
relations: data,
|
653
|
+
targetModel
|
629
654
|
},
|
630
655
|
itemKey: (index)=>data[index].id,
|
631
656
|
innerElementType: "ol",
|
@@ -666,9 +691,9 @@ const ShadowBox = styled(Box)`
|
|
666
691
|
}
|
667
692
|
`;
|
668
693
|
const ListItem = ({ data, index, style })=>{
|
669
|
-
const { ariaDescribedBy, canDrag = false, disabled = false, handleCancel, handleDisconnect, handleDropItem, handleGrabItem, handleMoveItem, name, relations } = data;
|
694
|
+
const { ariaDescribedBy, canDrag = false, disabled = false, handleCancel, handleDisconnect, handleDropItem, handleGrabItem, handleMoveItem, name, relations, targetModel } = data;
|
670
695
|
const { formatMessage } = useIntl();
|
671
|
-
const { href, id, label, status } = relations[index];
|
696
|
+
const { href, id, label, status, documentId, apiData, locale } = relations[index];
|
672
697
|
const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(canDrag && !disabled, {
|
673
698
|
type: `${ItemTypes.RELATION}_${name}`,
|
674
699
|
index,
|
@@ -735,18 +760,16 @@ const ListItem = ({ data, index, style })=>{
|
|
735
760
|
paddingTop: 1,
|
736
761
|
paddingBottom: 1,
|
737
762
|
paddingRight: 4,
|
738
|
-
children: /*#__PURE__*/ jsx(
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
children: label
|
749
|
-
})
|
763
|
+
children: /*#__PURE__*/ jsx(RelationModalForm, {
|
764
|
+
triggerButtonLabel: label,
|
765
|
+
relation: {
|
766
|
+
documentId: documentId ?? apiData?.documentId,
|
767
|
+
model: targetModel,
|
768
|
+
collectionType: getCollectionType(href),
|
769
|
+
params: {
|
770
|
+
locale: locale || apiData?.locale || null
|
771
|
+
}
|
772
|
+
}
|
750
773
|
})
|
751
774
|
}),
|
752
775
|
status ? /*#__PURE__*/ jsx(DocumentStatus, {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Relations.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/Relations.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n type InputProps,\n useField,\n useForm,\n useNotification,\n useFocusInputField,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Combobox,\n ComboboxOption,\n Flex,\n IconButton,\n TextButton,\n Typography,\n VisuallyHidden,\n useComposedRefs,\n Link,\n Field,\n FlexComponent,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Cross, Drag, ArrowClockwise } from '@strapi/icons';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { FixedSizeList, ListChildComponentProps } from 'react-window';\nimport { styled } from 'styled-components';\n\nimport { RelationDragPreviewProps } from '../../../../../components/DragPreviews/RelationDragPreview';\nimport { COLLECTION_TYPES } from '../../../../../constants/collections';\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../features/DocumentContext';\nimport { useDebounce } from '../../../../../hooks/useDebounce';\nimport { type EditFieldLayout } from '../../../../../hooks/useDocumentLayout';\nimport {\n DROP_SENSITIVITY,\n UseDragAndDropOptions,\n useDragAndDrop,\n} from '../../../../../hooks/useDragAndDrop';\nimport {\n useGetRelationsQuery,\n useLazySearchRelationsQuery,\n RelationResult,\n} from '../../../../../services/relations';\nimport { buildValidParams } from '../../../../../utils/api';\nimport { getRelationLabel } from '../../../../../utils/relations';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { useComponent } from '../ComponentContext';\nimport { RelationModalForm, getCollectionType } from '../Relations/RelationModal';\n\nimport type { Schema } from '@strapi/types';\n\n/**\n * Remove a relation, whether it's been already saved or not.\n * It's used both in RelationsList, where the \"remove relation\" button is, and in the input,\n * because we sometimes need to remove a previous relation when selecting a new one.\n */\nfunction useHandleDisconnect(fieldName: string, consumerName: string) {\n const field = useField(fieldName);\n const removeFieldRow = useForm(consumerName, (state) => state.removeFieldRow);\n const addFieldRow = useForm(consumerName, (state) => state.addFieldRow);\n\n const handleDisconnect: ListItemProps['data']['handleDisconnect'] = (relation) => {\n if (field.value && field.value.connect) {\n /**\n * A relation will exist in the `connect` array _if_ it has\n * been added without saving. In this case, we just remove it\n * from the connect array\n */\n const indexOfRelationInConnectArray = field.value.connect.findIndex(\n (rel: NonNullable<RelationsFormValue['connect']>[number]) => rel.id === relation.id\n );\n\n if (indexOfRelationInConnectArray >= 0) {\n removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);\n return;\n }\n }\n\n addFieldRow(`${fieldName}.disconnect`, {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n },\n });\n };\n\n return handleDisconnect;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsField\n * -----------------------------------------------------------------------------------------------*/\n\nconst RELATIONS_TO_DISPLAY = 5;\nconst ONE_WAY_RELATIONS = ['oneWay', 'oneToOne', 'manyToOne', 'oneToManyMorph', 'oneToOneMorph'];\n\ntype RelationPosition =\n | (Pick<RelationResult, 'status' | 'locale'> & {\n before: string;\n end?: never;\n })\n | { end: boolean; before?: never; status?: never; locale?: never };\n\ninterface Relation extends Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> {\n href: string;\n label: string;\n position?: RelationPosition;\n __temp_key__: string;\n apiData?: {\n documentId: RelationResult['documentId'];\n id: RelationResult['id'];\n locale?: RelationResult['locale'];\n position: RelationPosition;\n };\n}\n\ninterface RelationsFieldProps\n extends Omit<Extract<EditFieldLayout, { type: 'relation' }>, 'size' | 'hint'>,\n Pick<InputProps, 'hint'> {}\n\nexport interface RelationsFormValue {\n connect?: Relation[];\n disconnect?: Pick<Relation, 'id'>[];\n}\n\n/**\n * TODO: we get a rather ugly flash when we remove a single relation from the list leaving\n * no other relations when we press save. The initial relation re-renders, probably because\n * of the lag in the Form cleaning it's \"disconnect\" array, whilst our data has not been invalidated.\n *\n * Could we invalidate relation data on the document actions? Should we?\n */\n\n/**\n * @internal\n * @description The relations field holds a lot of domain logic for handling relations which is rather complicated\n * At present we do not expose this to plugin developers, however, they are able to overwrite it themselves should\n * they wish to do so.\n */\nconst RelationsField = React.forwardRef<HTMLDivElement, RelationsFieldProps>(\n ({ disabled, label, ...props }, ref) => {\n const currentDocumentMeta = useDocumentContext('RelationsField', (state) => state.meta);\n const currentDocument = useDocumentContext('RelationsField', (state) => state.document);\n const rootDocumentMeta = useDocumentContext(\n 'RelationsField',\n (state) => state.rootDocumentMeta\n );\n\n const [currentPage, setCurrentPage] = React.useState(1);\n const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;\n const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;\n\n // Use the documentId from the actual document, not the params (meta)\n const documentId = currentDocument.document?.documentId;\n\n const { formatMessage } = useIntl();\n\n const [{ query }] = useQueryParams();\n const params = documentMeta.params ?? buildValidParams(query);\n\n const isMorph = props.attribute.relation.toLowerCase().includes('morph');\n const isDisabled = isMorph || disabled;\n\n const { componentId, componentUID } = useComponent('RelationsField', ({ uid, id }) => ({\n componentId: id,\n componentUID: uid,\n }));\n\n const isSubmitting = useForm('RelationsList', (state) => state.isSubmitting);\n\n React.useEffect(() => {\n setCurrentPage(1);\n }, [isSubmitting]);\n\n const component = componentUID && currentDocument.components[componentUID];\n /**\n * We'll always have a documentId in a created entry, so we look for a componentId first.\n * Same with `uid` and `documentModel`.\n */\n const model = component ? component.uid : documentMeta.model;\n const id = component && componentId ? componentId.toString() : documentId;\n\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = props.name.split('.').slice(-1);\n\n const schemaAttributes = component\n ? (component.attributes ?? {})\n : (currentDocument.schema?.attributes ?? {});\n\n /**\n * Confirm the target field is related to the current document.\n * Since relations can exist in a modal on top of the root document,\n * we need to ensure we are fetching relations for the correct document (root document vs related document),\n */\n const isRelatedToCurrentDocument =\n Object.values(schemaAttributes).filter(\n (attribute) =>\n attribute.type === 'relation' &&\n 'target' in attribute &&\n 'target' in props.attribute &&\n attribute.target === props.attribute.target\n ).length > 0;\n\n const { data, isLoading, isFetching } = useGetRelationsQuery(\n {\n model,\n targetField,\n // below we don't run the query if there is no id.\n id,\n params: {\n ...params,\n pageSize: RELATIONS_TO_DISPLAY,\n page: currentPage,\n },\n },\n {\n refetchOnMountOrArgChange: true,\n skip: !id || !isRelatedToCurrentDocument,\n selectFromResult: (result) => {\n return {\n ...result,\n data: {\n ...result.data,\n results: result.data?.results ? result.data.results : [],\n },\n };\n },\n }\n );\n\n const handleLoadMore = () => {\n setCurrentPage((prev) => prev + 1);\n };\n\n const field = useField(props.name);\n\n const isFetchingMoreRelations = isLoading || isFetching;\n\n const realServerRelationsCount =\n 'pagination' in data && data.pagination ? data.pagination.total : 0;\n\n /**\n * Items that are already connected, but reordered would be in\n * this list, so to get an accurate figure, we remove them.\n */\n const relationsConnected =\n (field.value?.connect ?? []).filter(\n (rel: Relation) => data.results.findIndex((relation) => relation.id === rel.id) === -1\n ).length ?? 0;\n const relationsDisconnected = field.value?.disconnect?.length ?? 0;\n\n const relationsCount = realServerRelationsCount + relationsConnected - relationsDisconnected;\n\n /**\n * This is it, the source of truth for reordering in conjunction with partial loading & updating\n * of relations. Relations on load are given __temp_key__ when fetched, because we don't want to\n * create brand new keys everytime the data updates, just keep adding them onto the newly loaded ones.\n */\n const relations = React.useMemo(() => {\n const ctx = {\n field: field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}`,\n mainField: props.mainField,\n };\n\n /**\n * Tidy up our data.\n */\n const transformations = pipe(\n removeConnected(ctx),\n removeDisconnected(ctx),\n addLabelAndHref(ctx)\n );\n\n const transformedRels = transformations([...data.results]);\n\n /**\n * THIS IS CRUCIAL. If you don't sort by the __temp_key__ which comes from fractional indexing\n * then the list will be in the wrong order.\n */\n return [...transformedRels, ...(field.value?.connect ?? [])].sort((a, b) => {\n if (a.__temp_key__ < b.__temp_key__) return -1;\n if (a.__temp_key__ > b.__temp_key__) return 1;\n return 0;\n });\n }, [\n data.results,\n field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n props.attribute.targetModel,\n props.mainField,\n ]);\n\n const handleDisconnect = useHandleDisconnect(props.name, 'RelationsField');\n\n const handleConnect: RelationsInputProps['onChange'] = (relation) => {\n const [lastItemInList] = relations.slice(-1);\n\n const item = {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n },\n status: relation.status,\n /**\n * If there's a last item, that's the first key we use to generate out next one.\n */\n __temp_key__: generateNKeysBetween(lastItemInList?.__temp_key__ ?? null, null, 1)[0],\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `id` property with the exact same data.\n [props.mainField?.name ?? 'documentId']: relation[props.mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, props.mainField),\n // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n\n if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {\n // Remove any existing relation so they can be replaced with the new one\n field.value?.connect?.forEach(handleDisconnect);\n relations.forEach(handleDisconnect);\n\n field.onChange(`${props.name}.connect`, [item]);\n } else {\n field.onChange(`${props.name}.connect`, [...(field.value?.connect ?? []), item]);\n }\n };\n\n return (\n <Flex\n ref={ref}\n direction=\"column\"\n gap={3}\n justifyContent=\"space-between\"\n alignItems=\"stretch\"\n wrap=\"wrap\"\n >\n <StyledFlex direction=\"column\" alignItems=\"start\" gap={2} width=\"100%\">\n <RelationsInput\n disabled={isDisabled}\n // NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)\n id={componentUID && component ? (componentId ? `${componentId}` : '') : documentId}\n label={`${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`}\n model={model}\n onChange={handleConnect}\n isRelatedToCurrentDocument={isRelatedToCurrentDocument}\n {...props}\n />\n {'pagination' in data &&\n data.pagination &&\n data.pagination.pageCount > data.pagination.page ? (\n <TextButton\n disabled={isFetchingMoreRelations}\n onClick={handleLoadMore}\n loading={isFetchingMoreRelations}\n startIcon={<ArrowClockwise />}\n // prevent the label from line-wrapping\n shrink={0}\n >\n {formatMessage({\n id: getTranslation('relation.loadMore'),\n defaultMessage: 'Load More',\n })}\n </TextButton>\n ) : null}\n </StyledFlex>\n <RelationsList\n data={relations}\n serverData={data.results}\n disabled={isDisabled}\n name={props.name}\n isLoading={isFetchingMoreRelations}\n relationType={props.attribute.relation}\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n targetModel={props.attribute.targetModel}\n />\n </Flex>\n );\n }\n);\n\n/**\n * TODO: this can be removed once we stop shipping Inputs with\n * labels wrapped round in DS@2.\n */\nconst StyledFlex = styled<FlexComponent>(Flex)`\n & > div {\n width: 100%;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Relation Transformations\n * -----------------------------------------------------------------------------------------------*/\n\ninterface TransformationContext extends Pick<RelationsFieldProps, 'mainField'> {\n field?: RelationsFormValue;\n href: string;\n}\n\n/**\n * If it's in the connected array, it can get out of our data array,\n * we'll be putting it back in later and sorting it anyway.\n */\nconst removeConnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]) => {\n return relations.filter((relation) => {\n const connectedRelations = field?.connect ?? [];\n\n return connectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n };\n\n/**\n * @description Removes relations that are in the `disconnect` array of the field\n */\nconst removeDisconnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]): RelationResult[] =>\n relations.filter((relation) => {\n const disconnectedRelations = field?.disconnect ?? [];\n\n return disconnectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n\n/**\n * @description Adds a label and href to the relation object we use this to render\n * a better UI where we can link to the relation and display a human-readable label.\n */\nconst addLabelAndHref =\n ({ mainField, href }: TransformationContext) =>\n (relations: RelationResult[]): Relation[] =>\n relations.map((relation) => {\n return {\n ...relation,\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.\n [mainField?.name ?? 'documentId']: relation[mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, mainField),\n href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n });\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsInput\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RelationsInputProps extends Omit<RelationsFieldProps, 'type'> {\n id?: string;\n model: string;\n isRelatedToCurrentDocument: boolean;\n onChange: (\n relation: Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> & {\n [key: string]: any;\n }\n ) => void;\n}\n\n/**\n * @description Contains all the logic for the combobox that can search\n * for relations and then add them to the field's connect array.\n */\nconst RelationsInput = ({\n hint,\n id,\n model,\n label,\n labelAction,\n name,\n mainField,\n placeholder,\n required,\n unique: _unique,\n 'aria-label': _ariaLabel,\n onChange,\n isRelatedToCurrentDocument,\n ...props\n}: RelationsInputProps) => {\n const [textValue, setTextValue] = React.useState<string | undefined>('');\n const [searchParams, setSearchParams] = React.useState({\n _q: '',\n page: 1,\n });\n const { toggleNotification } = useNotification();\n const [{ query }] = useQueryParams();\n const currentDocumentMeta = useDocumentContext('RelationsInput', (state) => state.meta);\n const rootDocumentMeta = useDocumentContext('RelationsInput', (state) => state.rootDocumentMeta);\n const isRootDocument = rootDocumentMeta.documentId === currentDocumentMeta.documentId;\n const documentMeta = isRootDocument ? rootDocumentMeta : currentDocumentMeta;\n\n const { formatMessage } = useIntl();\n const fieldRef = useFocusInputField<HTMLInputElement>(name);\n const field = useField<RelationsFormValue>(name);\n\n const searchParamsDebounced = useDebounce(searchParams, 300);\n const [searchForTrigger, { data, isLoading }] = useLazySearchRelationsQuery();\n\n /**\n * Because we're using a lazy query, we need to trigger the search\n * when the component mounts and when the search params change.\n * We also need to trigger the search when the field value changes\n * so that we can filter out the relations that are already connected.\n */\n React.useEffect(() => {\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = name.split('.').slice(-1);\n\n // Return early if there is no relation to the document\n if (!isRelatedToCurrentDocument) return;\n\n const params = documentMeta.params ?? buildValidParams(query);\n\n searchForTrigger({\n model,\n targetField,\n params: {\n ...params,\n id: id ?? '',\n pageSize: 10,\n idsToInclude: field.value?.disconnect?.map((rel) => rel.id.toString()) ?? [],\n idsToOmit: field.value?.connect?.map((rel) => rel.id.toString()) ?? [],\n ...searchParamsDebounced,\n },\n });\n }, [\n field.value?.connect,\n field.value?.disconnect,\n id,\n model,\n name,\n query,\n searchForTrigger,\n searchParamsDebounced,\n isRelatedToCurrentDocument,\n documentMeta,\n ]);\n\n const handleSearch = async (search: string) => {\n setSearchParams((s) => ({ ...s, _q: search, page: 1 }));\n };\n\n const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;\n\n const options = data?.results ?? [];\n\n const handleChange = (relationId?: string) => {\n if (!relationId) {\n return;\n }\n\n const relation = options.find((opt) => opt.id.toString() === relationId);\n\n if (!relation) {\n // This is very unlikely to happen, but it ensures we don't have any data for.\n console.error(\n \"You've tried to add a relation with an id that does not exist in the options you can see, this is likely a bug with Strapi. Please open an issue.\"\n );\n\n toggleNotification({\n message: formatMessage({\n id: getTranslation('relation.error-adding-relation'),\n defaultMessage: 'An error occurred while trying to add the relation.',\n }),\n type: 'danger',\n });\n\n return;\n }\n\n /**\n * You need to give this relation a correct _temp_key_ but\n * this component doesn't know about those ones, you can't rely\n * on the connect array because that doesn't hold items that haven't\n * moved. So use a callback to fill in the gaps when connecting.\n *\n */\n onChange(relation);\n };\n\n const handleLoadMore = () => {\n if (!data || !data.pagination) {\n return;\n } else if (data.pagination.page < data.pagination.pageCount) {\n setSearchParams((s) => ({ ...s, page: s.page + 1 }));\n }\n };\n\n React.useLayoutEffect(() => {\n setTextValue('');\n }, [field.value]);\n\n return (\n <Field.Root error={field.error} hint={hint} name={name} required={required}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <Combobox\n ref={fieldRef}\n name={name}\n autocomplete=\"list\"\n placeholder={\n placeholder ||\n formatMessage({\n id: getTranslation('relation.add'),\n defaultMessage: 'Add relation',\n })\n }\n hasMoreItems={hasNextPage}\n loading={isLoading}\n onOpenChange={() => {\n handleSearch(textValue ?? '');\n }}\n noOptionsMessage={() =>\n formatMessage({\n id: getTranslation('relation.notAvailable'),\n defaultMessage: 'No relations available',\n })\n }\n loadingMessage={formatMessage({\n id: getTranslation('relation.isLoading'),\n defaultMessage: 'Relations are loading',\n })}\n onLoadMore={handleLoadMore}\n textValue={textValue}\n onChange={handleChange}\n onTextValueChange={(text) => {\n setTextValue(text);\n }}\n onInputChange={(event) => {\n handleSearch(event.currentTarget.value);\n }}\n {...props}\n >\n {options.map((opt) => {\n const textValue = getRelationLabel(opt, mainField);\n\n return (\n <ComboboxOption key={opt.id} value={opt.id.toString()} textValue={textValue}>\n <Flex gap={2} justifyContent=\"space-between\">\n <Typography ellipsis>{textValue}</Typography>\n {opt.status ? <DocumentStatus status={opt.status} /> : null}\n </Flex>\n </ComboboxOption>\n );\n })}\n </Combobox>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsList\n * -----------------------------------------------------------------------------------------------*/\nconst RELATION_ITEM_HEIGHT = 50;\nconst RELATION_GUTTER = 4;\n\ninterface RelationsListProps extends Pick<RelationsFieldProps, 'disabled' | 'name'> {\n data: Relation[];\n isLoading?: boolean;\n relationType: Schema.Attribute.RelationKind.Any;\n /**\n * The existing relations connected on the server. We need these to diff against.\n */\n serverData: RelationResult[];\n targetModel: string;\n}\n\nconst RelationsList = ({\n data,\n serverData,\n disabled,\n name,\n isLoading,\n relationType,\n targetModel,\n}: RelationsListProps) => {\n const ariaDescriptionId = React.useId();\n const { formatMessage } = useIntl();\n const listRef = React.useRef<FixedSizeList>(null);\n const outerListRef = React.useRef<HTMLUListElement>(null);\n const [overflow, setOverflow] = React.useState<'top' | 'bottom' | 'top-bottom'>();\n const [liveText, setLiveText] = React.useState('');\n const field = useField(name);\n\n React.useEffect(() => {\n if (data.length <= RELATIONS_TO_DISPLAY) {\n return setOverflow(undefined);\n }\n\n const handleNativeScroll = (e: Event) => {\n const el = e.target as HTMLUListElement;\n const parentScrollContainerHeight = (el.parentNode as HTMLDivElement).scrollHeight;\n const maxScrollBottom = el.scrollHeight - el.scrollTop;\n\n if (el.scrollTop === 0) {\n return setOverflow('bottom');\n }\n\n if (maxScrollBottom === parentScrollContainerHeight) {\n return setOverflow('top');\n }\n\n return setOverflow('top-bottom');\n };\n\n const outerListRefCurrent = outerListRef?.current;\n\n if (!isLoading && data.length > 0 && outerListRefCurrent) {\n outerListRef.current.addEventListener('scroll', handleNativeScroll);\n }\n\n return () => {\n if (outerListRefCurrent) {\n outerListRefCurrent.removeEventListener('scroll', handleNativeScroll);\n }\n };\n }, [isLoading, data.length]);\n\n const getItemPos = (index: number) => `${index + 1} of ${data.length}`;\n\n const handleMoveItem: UseDragAndDropOptions['onMoveItem'] = (newIndex, oldIndex) => {\n const item = data[oldIndex];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(newIndex),\n }\n )\n );\n\n /**\n * Splicing mutates the array, so we need to create a new array\n */\n const newData = [...data];\n const currentRow = data[oldIndex];\n\n const startKey =\n oldIndex > newIndex ? newData[newIndex - 1]?.__temp_key__ : newData[newIndex]?.__temp_key__;\n const endKey =\n oldIndex > newIndex ? newData[newIndex]?.__temp_key__ : newData[newIndex + 1]?.__temp_key__;\n\n /**\n * We're moving the relation between two other relations, so\n * we need to generate a new key that keeps the order\n */\n const [newKey] = generateNKeysBetween(startKey, endKey, 1);\n\n newData.splice(oldIndex, 1);\n newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });\n\n /**\n * Now we diff against the server to understand what's different so we\n * can keep the connect array nice and tidy. It also needs reversing because\n * we reverse the relations from the server in the first place.\n */\n const connectedRelations = newData\n .reduce<Relation[]>((acc, relation, currentIndex, array) => {\n const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);\n\n const relationInFront = array[currentIndex + 1];\n\n if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {\n const position = relationInFront\n ? {\n before: relationInFront.documentId,\n locale: relationInFront.locale,\n status:\n 'publishedAt' in relationInFront && relationInFront.publishedAt\n ? ('published' as Relation['status'])\n : ('draft' as Relation['status']),\n }\n : { end: true };\n\n const relationWithPosition: Relation = {\n ...relation,\n ...{\n apiData: {\n id: relation.id,\n documentId: relation.documentId ?? relation.apiData?.documentId ?? '',\n locale: relation.locale || relation.apiData?.locale,\n position,\n },\n },\n };\n\n return [...acc, relationWithPosition];\n }\n\n return acc;\n }, [])\n .toReversed();\n\n field.onChange(`${name}.connect`, connectedRelations);\n };\n\n const handleGrabItem: UseDragAndDropOptions['onGrabItem'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem: UseDragAndDropOptions['onDropItem'] = (index) => {\n const { href: _href, label, ...item } = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleCancel: UseDragAndDropOptions['onCancel'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: item.label ?? item.documentId,\n }\n )\n );\n };\n\n const handleDisconnect = useHandleDisconnect(name, 'RelationsList');\n\n /**\n * These relation types will only ever have one item\n * in their list, so you can't reorder a single item!\n */\n const canReorder = !ONE_WAY_RELATIONS.includes(relationType);\n\n const dynamicListHeight =\n data.length > RELATIONS_TO_DISPLAY\n ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) +\n RELATION_ITEM_HEIGHT / 2\n : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);\n\n return (\n <ShadowBox $overflowDirection={overflow}>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n {/* @ts-expect-error – width is expected, but we've not needed to pass it before. */}\n <FixedSizeList\n height={dynamicListHeight}\n ref={listRef}\n outerRef={outerListRef}\n itemCount={data.length}\n itemSize={RELATION_ITEM_HEIGHT + RELATION_GUTTER}\n itemData={{\n ariaDescribedBy: ariaDescriptionId,\n canDrag: canReorder,\n disabled,\n handleCancel,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n handleDisconnect,\n relations: data,\n targetModel,\n }}\n itemKey={(index) => data[index].id}\n innerElementType=\"ol\"\n >\n {ListItem}\n </FixedSizeList>\n </ShadowBox>\n );\n};\n\nconst ShadowBox = styled<BoxComponent>(Box)<{\n $overflowDirection?: 'top-bottom' | 'top' | 'bottom';\n}>`\n position: relative;\n overflow: hidden;\n flex: 1;\n\n &:before,\n &:after {\n position: absolute;\n width: 100%;\n height: 4px;\n z-index: 1;\n }\n\n &:before {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n top: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'top' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n\n &:after {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n bottom: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'bottom' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * ListItem\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ListItemProps extends Pick<ListChildComponentProps, 'style' | 'index'> {\n data: {\n ariaDescribedBy: string;\n canDrag?: boolean;\n disabled?: boolean;\n handleCancel: UseDragAndDropOptions['onCancel'];\n handleDropItem: UseDragAndDropOptions['onDropItem'];\n handleGrabItem: UseDragAndDropOptions['onGrabItem'];\n handleMoveItem: UseDragAndDropOptions['onMoveItem'];\n handleDisconnect: (relation: Relation) => void;\n name: string;\n relations: Relation[];\n targetModel: string;\n };\n}\n\nconst ListItem = ({ data, index, style }: ListItemProps) => {\n const {\n ariaDescribedBy,\n canDrag = false,\n disabled = false,\n handleCancel,\n handleDisconnect,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n relations,\n targetModel,\n } = data;\n\n const { formatMessage } = useIntl();\n\n const { href, id, label, status, documentId, apiData, locale } = relations[index];\n\n const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop<number, Omit<RelationDragPreviewProps, 'width'>, HTMLDivElement>(\n canDrag && !disabled,\n {\n type: `${ItemTypes.RELATION}_${name}`,\n index,\n item: {\n displayedValue: label,\n status,\n id: id,\n index,\n },\n onMoveItem: handleMoveItem,\n onDropItem: handleDropItem,\n onGrabItem: handleGrabItem,\n onCancel: handleCancel,\n dropSensitivity: DROP_SENSITIVITY.REGULAR,\n }\n );\n\n const composedRefs = useComposedRefs<HTMLDivElement>(relationRef, dragRef);\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage());\n }, [dragPreviewRef]);\n\n return (\n <Box\n style={style}\n tag=\"li\"\n ref={dropRef}\n aria-describedby={ariaDescribedBy}\n cursor={canDrag ? 'all-scroll' : 'default'}\n >\n {isDragging ? (\n <RelationItemPlaceholder />\n ) : (\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={canDrag ? 2 : 4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background={disabled ? 'neutral150' : 'neutral0'}\n justifyContent=\"space-between\"\n ref={composedRefs}\n data-handler-id={handlerId}\n >\n <FlexWrapper gap={1}>\n {canDrag ? (\n <IconButton\n tag=\"div\"\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.RelationInput.icon-button-aria-label'),\n defaultMessage: 'Drag',\n })}\n variant=\"ghost\"\n onKeyDown={handleKeyDown}\n disabled={disabled}\n >\n <Drag />\n </IconButton>\n ) : null}\n <Flex width=\"100%\" minWidth={0} justifyContent=\"space-between\">\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <RelationModalForm\n triggerButtonLabel={label}\n relation={{\n documentId: documentId ?? apiData?.documentId,\n model: targetModel,\n collectionType: getCollectionType(href)!,\n params: {\n locale: locale || apiData?.locale || null,\n },\n }}\n />\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <Box paddingLeft={4}>\n <IconButton\n onClick={() => handleDisconnect(relations[index])}\n disabled={disabled}\n label={formatMessage({\n id: getTranslation('relation.disconnect'),\n defaultMessage: 'Remove',\n })}\n variant=\"ghost\"\n size=\"S\"\n >\n <Cross />\n </IconButton>\n </Box>\n </Flex>\n )}\n </Box>\n );\n};\n\nconst FlexWrapper = styled<FlexComponent>(Flex)`\n width: 100%;\n /* Used to prevent endAction to be pushed out of container */\n min-width: 0;\n\n & > div[role='button'] {\n cursor: all-scroll;\n }\n`;\n\nconst DisconnectButton = styled.button`\n svg path {\n fill: ${({ theme, disabled }) =>\n disabled ? theme.colors.neutral600 : theme.colors.neutral500};\n }\n\n &:hover svg path,\n &:focus svg path {\n fill: ${({ theme, disabled }) => !disabled && theme.colors.neutral600};\n }\n`;\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst RelationItemPlaceholder = () => (\n <Box\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderStyle=\"dashed\"\n borderColor=\"primary600\"\n borderWidth=\"1px\"\n background=\"primary100\"\n height={`calc(100% - ${RELATION_GUTTER}px)`}\n />\n);\n\nconst MemoizedRelationsField = React.memo(RelationsField);\n\nexport { MemoizedRelationsField as RelationsInput, FlexWrapper, DisconnectButton, LinkEllipsis };\nexport type { RelationsFieldProps };\n"],"names":["useHandleDisconnect","fieldName","consumerName","field","useField","removeFieldRow","useForm","state","addFieldRow","handleDisconnect","relation","value","connect","indexOfRelationInConnectArray","findIndex","rel","id","apiData","documentId","locale","RELATIONS_TO_DISPLAY","ONE_WAY_RELATIONS","RelationsField","React","forwardRef","disabled","label","props","ref","currentDocumentMeta","useDocumentContext","meta","currentDocument","document","rootDocumentMeta","currentPage","setCurrentPage","useState","isRootDocument","documentMeta","formatMessage","useIntl","query","useQueryParams","params","buildValidParams","isMorph","attribute","toLowerCase","includes","isDisabled","componentId","componentUID","useComponent","uid","isSubmitting","useEffect","component","components","model","toString","targetField","name","split","slice","schemaAttributes","attributes","schema","isRelatedToCurrentDocument","Object","values","filter","type","target","length","data","isLoading","isFetching","useGetRelationsQuery","pageSize","page","refetchOnMountOrArgChange","skip","selectFromResult","result","results","handleLoadMore","prev","isFetchingMoreRelations","realServerRelationsCount","pagination","total","relationsConnected","relationsDisconnected","disconnect","relationsCount","relations","useMemo","ctx","href","COLLECTION_TYPES","targetModel","mainField","transformations","pipe","removeConnected","removeDisconnected","addLabelAndHref","transformedRels","sort","a","b","__temp_key__","handleConnect","lastItemInList","item","status","generateNKeysBetween","getRelationLabel","forEach","onChange","_jsxs","Flex","direction","gap","justifyContent","alignItems","wrap","StyledFlex","width","_jsx","RelationsInput","pageCount","TextButton","onClick","loading","startIcon","ArrowClockwise","shrink","getTranslation","defaultMessage","RelationsList","serverData","relationType","styled","connectedRelations","disconnectedRelations","map","hint","labelAction","placeholder","required","unique","_unique","_ariaLabel","textValue","setTextValue","searchParams","setSearchParams","_q","toggleNotification","useNotification","fieldRef","useFocusInputField","searchParamsDebounced","useDebounce","searchForTrigger","useLazySearchRelationsQuery","idsToInclude","idsToOmit","handleSearch","search","s","hasNextPage","options","handleChange","relationId","find","opt","console","error","message","useLayoutEffect","Field","Root","Label","action","Combobox","autocomplete","hasMoreItems","onOpenChange","noOptionsMessage","loadingMessage","onLoadMore","onTextValueChange","text","onInputChange","event","currentTarget","ComboboxOption","Typography","ellipsis","DocumentStatus","Error","Hint","RELATION_ITEM_HEIGHT","RELATION_GUTTER","ariaDescriptionId","useId","listRef","useRef","outerListRef","overflow","setOverflow","liveText","setLiveText","undefined","handleNativeScroll","e","el","parentScrollContainerHeight","parentNode","scrollHeight","maxScrollBottom","scrollTop","outerListRefCurrent","current","addEventListener","removeEventListener","getItemPos","index","handleMoveItem","newIndex","oldIndex","position","newData","currentRow","startKey","endKey","newKey","splice","reduce","acc","currentIndex","array","relationOnServer","oldRelation","relationInFront","before","publishedAt","end","relationWithPosition","toReversed","handleGrabItem","handleDropItem","_href","handleCancel","canReorder","dynamicListHeight","Math","min","ShadowBox","$overflowDirection","VisuallyHidden","aria-live","FixedSizeList","height","outerRef","itemCount","itemSize","itemData","ariaDescribedBy","canDrag","itemKey","innerElementType","ListItem","Box","style","handlerId","isDragging","handleKeyDown","relationRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","RELATION","displayedValue","onMoveItem","onDropItem","onGrabItem","onCancel","dropSensitivity","DROP_SENSITIVITY","REGULAR","composedRefs","useComposedRefs","getEmptyImage","tag","aria-describedby","cursor","RelationItemPlaceholder","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","data-handler-id","FlexWrapper","IconButton","role","tabIndex","withTooltip","variant","onKeyDown","Drag","minWidth","RelationModalForm","triggerButtonLabel","collectionType","getCollectionType","size","Cross","DisconnectButton","button","theme","colors","neutral600","neutral500","LinkEllipsis","Link","borderStyle","borderWidth","MemoizedRelationsField","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0DA;;;;AAIC,IACD,SAASA,mBAAAA,CAAoBC,SAAiB,EAAEC,YAAoB,EAAA;AAClE,IAAA,MAAMC,QAAQC,QAASH,CAAAA,SAAAA,CAAAA;AACvB,IAAA,MAAMI,iBAAiBC,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMF,cAAc,CAAA;AAC5E,IAAA,MAAMG,cAAcF,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMC,WAAW,CAAA;AAEtE,IAAA,MAAMC,mBAA8D,CAACC,QAAAA,GAAAA;AACnE,QAAA,IAAIP,MAAMQ,KAAK,IAAIR,MAAMQ,KAAK,CAACC,OAAO,EAAE;AACtC;;;;AAIC,UACD,MAAMC,6BAAAA,GAAgCV,KAAMQ,CAAAA,KAAK,CAACC,OAAO,CAACE,SAAS,CACjE,CAACC,GAA4DA,GAAAA,GAAAA,CAAIC,EAAE,KAAKN,SAASM,EAAE,CAAA;AAGrF,YAAA,IAAIH,iCAAiC,CAAG,EAAA;AACtCR,gBAAAA,cAAAA,CAAe,CAAC,EAAEJ,SAAU,CAAA,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EAAE,GAAK,CAACA,QAAY+S,IAAAA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;AAE1E;AAEME,MAAAA,YAAAA,GAAe5L,MAAO6L,CAAAA,IAAAA,CAAK;;;;;;;;;AASjC;AAEA,MAAM/B,uBAAAA,GAA0B,kBAC9B5K,GAACkJ,CAAAA,GAAAA,EAAAA;QACC2B,UAAY,EAAA,CAAA;QACZC,aAAe,EAAA,CAAA;QACfC,WAAa,EAAA,CAAA;QACbC,YAAc,EAAA,CAAA;QACdC,SAAS,EAAA,IAAA;QACT2B,WAAY,EAAA,QAAA;QACZ1B,WAAY,EAAA,YAAA;QACZ2B,WAAY,EAAA,KAAA;QACZ1B,UAAW,EAAA,YAAA;AACX3C,QAAAA,MAAAA,EAAQ,CAAC,YAAY,EAAE5D,eAAAA,CAAgB,GAAG;;AAIxCkI,MAAAA,sBAAAA,iBAAyBzT,KAAM0T,CAAAA,IAAI,CAAC3T,cAAAA;;;;"}
|
@@ -4,7 +4,6 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var designSystem = require('@strapi/design-system');
|
5
5
|
var reactIntl = require('react-intl');
|
6
6
|
var styledComponents = require('styled-components');
|
7
|
-
var useDocument = require('../../../hooks/useDocument.js');
|
8
7
|
var InputRenderer = require('./InputRenderer.js');
|
9
8
|
|
10
9
|
const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
@@ -13,16 +12,22 @@ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
|
13
12
|
const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
|
14
13
|
container-type: inline-size;
|
15
14
|
`;
|
16
|
-
const ResponsiveGridItem =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
const ResponsiveGridItem = /**
|
16
|
+
* TODO:
|
17
|
+
* JSDOM cannot handle container queries.
|
18
|
+
* This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error
|
19
|
+
* for failing to parse the stylesheet.
|
20
|
+
*/ process.env.NODE_ENV !== 'test' ? styledComponents.styled(designSystem.Grid.Item)`
|
21
|
+
grid-column: span 12;
|
22
|
+
@container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
23
|
+
${({ col })=>col && `grid-column: span ${col};`}
|
24
|
+
}
|
25
|
+
` : styledComponents.styled(designSystem.Grid.Item)`
|
26
|
+
grid-column: span 12;
|
27
|
+
`;
|
28
|
+
const FormLayout = ({ layout, document, hasBackground = true })=>{
|
24
29
|
const { formatMessage } = reactIntl.useIntl();
|
25
|
-
const
|
30
|
+
const model = document.schema?.modelName;
|
26
31
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
27
32
|
direction: "column",
|
28
33
|
alignItems: "stretch",
|
@@ -47,13 +52,14 @@ const FormLayout = ({ layout, hasBackground = false })=>{
|
|
47
52
|
direction: "column",
|
48
53
|
alignItems: "stretch",
|
49
54
|
children: /*#__PURE__*/ jsxRuntime.jsx(InputRenderer.InputRenderer, {
|
50
|
-
...fieldWithTranslatedLabel
|
55
|
+
...fieldWithTranslatedLabel,
|
56
|
+
document: document
|
51
57
|
})
|
52
58
|
})
|
53
59
|
}, field.name);
|
54
60
|
}
|
55
61
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
56
|
-
|
62
|
+
...hasBackground && {
|
57
63
|
padding: 6,
|
58
64
|
borderColor: 'neutral150',
|
59
65
|
background: 'neutral0',
|
@@ -81,7 +87,8 @@ const FormLayout = ({ layout, hasBackground = false })=>{
|
|
81
87
|
direction: "column",
|
82
88
|
alignItems: "stretch",
|
83
89
|
children: /*#__PURE__*/ jsxRuntime.jsx(InputRenderer.InputRenderer, {
|
84
|
-
...fieldWithTranslatedLabel
|
90
|
+
...fieldWithTranslatedLabel,
|
91
|
+
document: document
|
85
92
|
})
|
86
93
|
}, field.name);
|
87
94
|
})
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FormLayout.js","sources":["../../../../../admin/src/pages/EditView/components/FormLayout.tsx"],"sourcesContent":["import { Box, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport {
|
1
|
+
{"version":3,"file":"FormLayout.js","sources":["../../../../../admin/src/pages/EditView/components/FormLayout.tsx"],"sourcesContent":["import { Box, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\n\nimport { InputRenderer } from './InputRenderer';\n\nimport type { UseDocument } from '../../../hooks/useDocument';\n\nexport const RESPONSIVE_CONTAINER_BREAKPOINTS = {\n sm: '27.5rem', // 440px\n};\n\nexport const ResponsiveGridRoot = styled(Grid.Root)`\n container-type: inline-size;\n`;\n\nexport const ResponsiveGridItem =\n /**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\n process.env.NODE_ENV !== 'test'\n ? styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {\n ${({ col }) => col && `grid-column: span ${col};`}\n }\n `\n : styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n `;\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {\n hasBackground?: boolean;\n model?: string;\n document: ReturnType<UseDocument>;\n}\n\nconst FormLayout = ({ layout, document, hasBackground = true }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const model = document.schema?.modelName;\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel, index) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item col={12} s={12} xs={12} direction=\"column\" alignItems=\"stretch\">\n <InputRenderer {...fieldWithTranslatedLabel} document={document} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n key={index}\n {...(hasBackground && {\n padding: 6,\n borderColor: 'neutral150',\n background: 'neutral0',\n hasRadius: true,\n shadow: 'tableShadow',\n })}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => (\n <ResponsiveGridRoot key={gridRowIndex} gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n return (\n <ResponsiveGridItem\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer {...fieldWithTranslatedLabel} document={document} />\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n ))}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n );\n};\n\nexport { FormLayout, FormLayoutProps };\n"],"names":["RESPONSIVE_CONTAINER_BREAKPOINTS","sm","ResponsiveGridRoot","styled","Grid","Root","ResponsiveGridItem","process","env","NODE_ENV","Item","col","FormLayout","layout","document","hasBackground","formatMessage","useIntl","model","schema","modelName","_jsx","Flex","direction","alignItems","gap","map","panel","index","some","row","field","type","fieldWithTranslatedLabel","label","id","name","defaultMessage","s","xs","InputRenderer","Box","padding","borderColor","background","hasRadius","shadow","gridRowIndex","size"],"mappings":";;;;;;;;MAUaA,gCAAmC,GAAA;IAC9CC,EAAI,EAAA;AACN;MAEaC,kBAAqBC,GAAAA,uBAAAA,CAAOC,iBAAKC,CAAAA,IAAI,CAAC;;AAEnD;MAEaC,kBACX;;;;;MAMAC,OAAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,SACrBN,uBAAOC,CAAAA,iBAAAA,CAAKM,IAA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qCAAA;AACF,iCAAA;AACA,gCAAA,qBACEb,cAACf,CAAAA,kBAAAA,EAAAA;oCACCK,GAAKqC,EAAAA,IAAAA;oCAELV,CAAG,EAAA,EAAA;oCACHC,EAAI,EAAA,EAAA;oCACJhB,SAAU,EAAA,QAAA;oCACVC,UAAW,EAAA,SAAA;AAEX,oCAAA,QAAA,gBAAAH,cAACmB,CAAAA,2BAAAA,EAAAA;AAAe,wCAAA,GAAGP,wBAAwB;wCAAEnB,QAAUA,EAAAA;;AANlDiB,iCAAAA,EAAAA,KAAAA,CAAMK,IAAI,CAAA;AASrB,6BAAA;AArBuBW,yBAAAA,EAAAA,YAAAA,CAAAA;;AAXxBnB,aAAAA,EAAAA,KAAAA,CAAAA;AAsCX,SAAA;;AAGN;;;;;;;"}
|
@@ -2,7 +2,6 @@ import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Grid, Flex, Box } from '@strapi/design-system';
|
3
3
|
import { useIntl } from 'react-intl';
|
4
4
|
import { styled } from 'styled-components';
|
5
|
-
import { useDoc } from '../../../hooks/useDocument.mjs';
|
6
5
|
import { InputRenderer as MemoizedInputRenderer } from './InputRenderer.mjs';
|
7
6
|
|
8
7
|
const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
@@ -11,16 +10,22 @@ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
|
11
10
|
const ResponsiveGridRoot = styled(Grid.Root)`
|
12
11
|
container-type: inline-size;
|
13
12
|
`;
|
14
|
-
const ResponsiveGridItem =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
const ResponsiveGridItem = /**
|
14
|
+
* TODO:
|
15
|
+
* JSDOM cannot handle container queries.
|
16
|
+
* This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error
|
17
|
+
* for failing to parse the stylesheet.
|
18
|
+
*/ process.env.NODE_ENV !== 'test' ? styled(Grid.Item)`
|
19
|
+
grid-column: span 12;
|
20
|
+
@container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
21
|
+
${({ col })=>col && `grid-column: span ${col};`}
|
22
|
+
}
|
23
|
+
` : styled(Grid.Item)`
|
24
|
+
grid-column: span 12;
|
25
|
+
`;
|
26
|
+
const FormLayout = ({ layout, document, hasBackground = true })=>{
|
22
27
|
const { formatMessage } = useIntl();
|
23
|
-
const
|
28
|
+
const model = document.schema?.modelName;
|
24
29
|
return /*#__PURE__*/ jsx(Flex, {
|
25
30
|
direction: "column",
|
26
31
|
alignItems: "stretch",
|
@@ -45,13 +50,14 @@ const FormLayout = ({ layout, hasBackground = false })=>{
|
|
45
50
|
direction: "column",
|
46
51
|
alignItems: "stretch",
|
47
52
|
children: /*#__PURE__*/ jsx(MemoizedInputRenderer, {
|
48
|
-
...fieldWithTranslatedLabel
|
53
|
+
...fieldWithTranslatedLabel,
|
54
|
+
document: document
|
49
55
|
})
|
50
56
|
})
|
51
57
|
}, field.name);
|
52
58
|
}
|
53
59
|
return /*#__PURE__*/ jsx(Box, {
|
54
|
-
|
60
|
+
...hasBackground && {
|
55
61
|
padding: 6,
|
56
62
|
borderColor: 'neutral150',
|
57
63
|
background: 'neutral0',
|
@@ -79,7 +85,8 @@ const FormLayout = ({ layout, hasBackground = false })=>{
|
|
79
85
|
direction: "column",
|
80
86
|
alignItems: "stretch",
|
81
87
|
children: /*#__PURE__*/ jsx(MemoizedInputRenderer, {
|
82
|
-
...fieldWithTranslatedLabel
|
88
|
+
...fieldWithTranslatedLabel,
|
89
|
+
document: document
|
83
90
|
})
|
84
91
|
}, field.name);
|
85
92
|
})
|