@strapi/content-manager 5.13.0-beta.1 → 5.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/admin/components/LeftMenu.js +30 -34
  2. package/dist/admin/components/LeftMenu.js.map +1 -1
  3. package/dist/admin/components/LeftMenu.mjs +32 -36
  4. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  5. package/dist/admin/hooks/useDocumentActions.js +5 -1
  6. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  7. package/dist/admin/hooks/useDocumentActions.mjs +5 -1
  8. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  10. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  11. package/dist/admin/index.js +1 -3
  12. package/dist/admin/index.js.map +1 -1
  13. package/dist/admin/pages/EditView/components/DocumentActions.js +206 -21
  14. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/DocumentActions.mjs +208 -23
  16. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  17. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +128 -55
  18. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  19. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  20. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +89 -50
  22. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +91 -52
  24. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormLayout.js +3 -3
  26. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormLayout.mjs +3 -3
  28. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  29. package/dist/admin/pages/ListView/ListViewPage.js +0 -77
  30. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  31. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -78
  32. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  33. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  34. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  35. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +0 -1
  36. package/dist/admin/translations/en.json.js +2 -1
  37. package/dist/admin/translations/en.json.js.map +1 -1
  38. package/dist/admin/translations/en.json.mjs +2 -1
  39. package/dist/admin/translations/en.json.mjs.map +1 -1
  40. package/dist/admin/translations/ru.json.js +235 -226
  41. package/dist/admin/translations/ru.json.js.map +1 -1
  42. package/dist/admin/translations/ru.json.mjs +230 -226
  43. package/dist/admin/translations/ru.json.mjs.map +1 -1
  44. package/dist/server/src/index.d.ts +0 -1
  45. package/dist/server/src/index.d.ts.map +1 -1
  46. package/dist/server/src/services/data-mapper.d.ts +0 -1
  47. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  48. package/dist/server/src/services/index.d.ts +0 -1
  49. package/dist/server/src/services/index.d.ts.map +1 -1
  50. package/package.json +5 -5
  51. package/dist/server/src/services/homepage.d.ts +0 -11
  52. package/dist/server/src/services/homepage.d.ts.map +0 -1
@@ -20,6 +20,7 @@ var DocumentRBAC = require('../../../../../features/DocumentRBAC.js');
20
20
  var validation = require('../../../../../utils/validation.js');
21
21
  var DocumentActions = require('../../DocumentActions.js');
22
22
  var FormLayout = require('../../FormLayout.js');
23
+ var ComponentContext = require('../ComponentContext.js');
23
24
 
24
25
  function _interopNamespaceDefault(e) {
25
26
  var n = Object.create(null);
@@ -51,23 +52,37 @@ const StyledModalContent = styledComponents.styled(designSystem.Modal.Content)`
51
52
  height: 90%;
52
53
  max-height: 100%;
53
54
  `;
55
+ const getFullPageUrl = (currentDocumentMeta)=>{
56
+ const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
57
+ const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
58
+ return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
59
+ };
54
60
  function reducer(state, action) {
55
61
  switch(action.type){
56
62
  case 'GO_TO_RELATION':
57
63
  if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
58
64
  return {
59
65
  ...state,
60
- confirmDialogIntent: action.payload.document
66
+ confirmDialogIntent: action.payload.document,
67
+ fieldToConnect: action.payload.fieldToConnect,
68
+ fieldToConnectUID: action.payload.fieldToConnectUID
61
69
  };
62
70
  }
71
+ const lastItemDocumentHistory = state.documentHistory.at(-1);
72
+ const hasToResetDocumentHistory = lastItemDocumentHistory && !lastItemDocumentHistory.documentId;
63
73
  return {
64
74
  ...state,
65
- documentHistory: [
75
+ // Reset document history if the last item has documentId undefined
76
+ documentHistory: hasToResetDocumentHistory ? [
77
+ action.payload.document
78
+ ] : [
66
79
  ...state.documentHistory,
67
80
  action.payload.document
68
81
  ],
69
82
  confirmDialogIntent: null,
70
- isModalOpen: true
83
+ isModalOpen: true,
84
+ fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,
85
+ fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID
71
86
  };
72
87
  case 'GO_BACK':
73
88
  if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
@@ -95,6 +110,21 @@ function reducer(state, action) {
95
110
  isModalOpen: false,
96
111
  confirmDialogIntent: null
97
112
  };
113
+ case 'GO_TO_CREATED_RELATION':
114
+ return {
115
+ ...state,
116
+ // Reset document history if the last item has documentId undefined
117
+ documentHistory: state.documentHistory ? [
118
+ ...state.documentHistory.slice(0, -1),
119
+ action.payload.document
120
+ ] : [
121
+ action.payload.document
122
+ ],
123
+ confirmDialogIntent: null,
124
+ isModalOpen: true,
125
+ fieldToConnect: undefined,
126
+ fieldToConnectUID: undefined
127
+ };
98
128
  case 'CANCEL_CONFIRM_DIALOG':
99
129
  return {
100
130
  ...state,
@@ -124,21 +154,17 @@ function reducer(state, action) {
124
154
  }
125
155
  }
126
156
  const [RelationModalProvider, useRelationModal] = strapiAdmin.createContext('RelationModal');
127
- const getFullPageUrl = (currentDocumentMeta)=>{
128
- const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
129
- const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
130
- return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
131
- };
132
- /**
133
- * Component responsible of rendering its children wrapped in a modal, form and context if needed
134
- */ const RelationModalRenderer = ({ children, trigger, relation })=>{
135
- const { formatMessage } = reactIntl.useIntl();
136
- const navigate = reactRouterDom.useNavigate();
157
+ function isRenderProp(children) {
158
+ return typeof children === 'function';
159
+ }
160
+ const RootRelationRenderer = (props)=>{
161
+ const { children } = props;
137
162
  const [state, dispatch] = React__namespace.useReducer(reducer, {
138
163
  documentHistory: [],
139
164
  confirmDialogIntent: null,
140
165
  isModalOpen: false,
141
- hasUnsavedChanges: false
166
+ hasUnsavedChanges: false,
167
+ fieldToConnect: undefined
142
168
  });
143
169
  const rootDocument = useDocument.useDoc();
144
170
  const [{ query }] = strapiAdmin.useQueryParams();
@@ -153,11 +179,9 @@ const getFullPageUrl = (currentDocumentMeta)=>{
153
179
  };
154
180
  const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;
155
181
  const currentDocument = useDocument.useDocument(currentDocumentMeta);
156
- const parentContextValue = useRelationModal('RelationContextWrapper', (state)=>state, false);
157
- // A parent relation is already rendering a modal. In this case simply render the trigger
158
- if (parentContextValue) {
159
- return trigger;
160
- }
182
+ // TODO: check if we can remove the single type check
183
+ const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
184
+ const isCreating = !currentDocumentMeta.documentId && !isSingleType;
161
185
  /**
162
186
  * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the
163
187
  * pieces that will be used by potential child relations: the context, header, form, and footer.
@@ -167,18 +191,64 @@ const getFullPageUrl = (currentDocumentMeta)=>{
167
191
  rootDocumentMeta: rootDocumentMeta,
168
192
  currentDocumentMeta: currentDocumentMeta,
169
193
  currentDocument: currentDocument,
194
+ isCreating: isCreating,
195
+ children: /*#__PURE__*/ jsxRuntime.jsx(RelationModal, {
196
+ children: isRenderProp(children) ? children({
197
+ dispatch
198
+ }) : props.relation && /*#__PURE__*/ jsxRuntime.jsx(RelationModalTrigger, {
199
+ relation: props.relation,
200
+ children: children
201
+ })
202
+ })
203
+ });
204
+ };
205
+ const NestedRelationRenderer = (props)=>{
206
+ const { children } = props;
207
+ const dispatch = useRelationModal('NestedRelation', (state)=>state.dispatch);
208
+ return isRenderProp(children) ? children({
209
+ dispatch
210
+ }) : props.relation && /*#__PURE__*/ jsxRuntime.jsx(RelationModalTrigger, {
211
+ relation: props.relation,
212
+ children: children
213
+ }); /* This is the trigger that will be rendered in the parent relation */
214
+ };
215
+ /**
216
+ * Component responsible for rendering its children wrapped in a modal, form and context if needed
217
+ */ const RelationModalRenderer = (props)=>{
218
+ // We're in a nested relation if the relation modal context is not undefined
219
+ const isNested = useRelationModal('RelationContextWrapper', (state)=>state != undefined, false);
220
+ return isNested ? /*#__PURE__*/ jsxRuntime.jsx(NestedRelationRenderer, {
221
+ ...props
222
+ }) : /*#__PURE__*/ jsxRuntime.jsx(RootRelationRenderer, {
223
+ ...props
224
+ });
225
+ };
226
+ /* -------------------------------------------------------------------------------------------------
227
+ * RelationModal
228
+ * -----------------------------------------------------------------------------------------------*/ const generateCreateUrl = (currentDocumentMeta)=>{
229
+ return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : ''}`;
230
+ };
231
+ const RelationModal = ({ children })=>{
232
+ const { formatMessage } = reactIntl.useIntl();
233
+ const navigate = reactRouterDom.useNavigate();
234
+ const state = useRelationModal('RelationModalForm', (state)=>state.state);
235
+ const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
236
+ const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
237
+ const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
238
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
239
+ /*
240
+ * We must wrap the modal window with Component Provider with reset values
241
+ * to avoid inheriting id and uid from the root document and having weird
242
+ * behaviors with simple relationships..
243
+ */ return /*#__PURE__*/ jsxRuntime.jsx(ComponentContext.ComponentProvider, {
244
+ id: undefined,
245
+ level: -1,
246
+ uid: undefined,
247
+ type: undefined,
170
248
  children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Root, {
171
249
  open: state.isModalOpen,
172
250
  onOpenChange: (open)=>{
173
- if (open) {
174
- dispatch({
175
- type: 'GO_TO_RELATION',
176
- payload: {
177
- document: relation,
178
- shouldBypassConfirmation: false
179
- }
180
- });
181
- } else {
251
+ if (!open) {
182
252
  dispatch({
183
253
  type: 'CLOSE_MODAL',
184
254
  payload: {
@@ -188,7 +258,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
188
258
  }
189
259
  },
190
260
  children: [
191
- trigger,
261
+ children,
192
262
  /*#__PURE__*/ jsxRuntime.jsxs(StyledModalContent, {
193
263
  children: [
194
264
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
@@ -223,7 +293,10 @@ const getFullPageUrl = (currentDocumentMeta)=>{
223
293
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
224
294
  tag: "span",
225
295
  fontWeight: 600,
226
- children: formatMessage({
296
+ children: isCreating ? formatMessage({
297
+ id: 'content-manager.relation.create',
298
+ defaultMessage: 'Create a relation'
299
+ }) : formatMessage({
227
300
  id: 'content-manager.components.RelationInputModal.modal-title',
228
301
  defaultMessage: 'Edit a relation'
229
302
  })
@@ -236,7 +309,11 @@ const getFullPageUrl = (currentDocumentMeta)=>{
236
309
  type: 'GO_FULL_PAGE'
237
310
  });
238
311
  if (!state.hasUnsavedChanges) {
239
- navigate(getFullPageUrl(currentDocumentMeta));
312
+ if (isCreating) {
313
+ navigate(generateCreateUrl(currentDocumentMeta));
314
+ } else {
315
+ navigate(getFullPageUrl(currentDocumentMeta));
316
+ }
240
317
  }
241
318
  },
242
319
  variant: "tertiary",
@@ -251,8 +328,8 @@ const getFullPageUrl = (currentDocumentMeta)=>{
251
328
  }),
252
329
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
253
330
  children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Form, {
254
- method: "PUT",
255
- initialValues: currentDocument.getInitialFormValues(),
331
+ method: isCreating ? 'POST' : 'PUT',
332
+ initialValues: currentDocument.getInitialFormValues(isCreating),
256
333
  validate: (values, options)=>{
257
334
  const yupSchema = validation.createYupSchema(currentDocument.schema?.attributes, currentDocument.components, {
258
335
  status: currentDocument.document?.status,
@@ -262,7 +339,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
262
339
  abortEarly: false
263
340
  });
264
341
  },
265
- children: children
342
+ children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalBody, {})
266
343
  })
267
344
  })
268
345
  ]
@@ -273,7 +350,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
273
350
  };
274
351
  /**
275
352
  * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.
276
- * Will be wrapped in a Modal.Body by the RelationModalRenderer.
353
+ * Will be wrapped in a Modal.Body by the RelationModal component.
277
354
  * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.
278
355
  */ const RelationModalBody = ()=>{
279
356
  const navigate = reactRouterDom.useNavigate();
@@ -284,6 +361,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
284
361
  const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
285
362
  const rootDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.rootDocumentMeta);
286
363
  const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
364
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
287
365
  /**
288
366
  * One-way sync the modified state from the form to the modal state.
289
367
  * It is needed because we need to consume state from the form context in order to lift it up
@@ -325,7 +403,11 @@ const getFullPageUrl = (currentDocumentMeta)=>{
325
403
  if (isRootDocumentUrl) {
326
404
  handleCloseModal(true);
327
405
  } else {
328
- navigate(fullPageUrl);
406
+ if (isCreating) {
407
+ navigate(generateCreateUrl(currentDocumentMeta));
408
+ } else {
409
+ navigate(fullPageUrl);
410
+ }
329
411
  }
330
412
  };
331
413
  const handleConfirm = ()=>{
@@ -355,7 +437,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
355
437
  };
356
438
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
357
439
  children: [
358
- /*#__PURE__*/ jsxRuntime.jsx(RelationEditView, {}),
440
+ /*#__PURE__*/ jsxRuntime.jsx(RelationModalForm, {}),
359
441
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Root, {
360
442
  open: state.confirmDialogIntent != null,
361
443
  children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, {
@@ -373,7 +455,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
373
455
  ]
374
456
  });
375
457
  };
376
- const ModalTrigger = ({ children, relation })=>{
458
+ const RelationModalTrigger = ({ children, relation })=>{
377
459
  const dispatch = useRelationModal('ModalTrigger', (state)=>state.dispatch);
378
460
  return /*#__PURE__*/ jsxRuntime.jsx(StyledTextButton, {
379
461
  onClick: ()=>{
@@ -388,16 +470,6 @@ const ModalTrigger = ({ children, relation })=>{
388
470
  children: children
389
471
  });
390
472
  };
391
- const RelationModal = /*#__PURE__*/ React__namespace.memo(({ relation, children })=>{
392
- return /*#__PURE__*/ jsxRuntime.jsx(RelationModalRenderer, {
393
- relation: relation,
394
- trigger: /*#__PURE__*/ jsxRuntime.jsx(ModalTrigger, {
395
- relation: relation,
396
- children: children
397
- }),
398
- children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalBody, {})
399
- });
400
- });
401
473
  const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
402
474
  max-width: 100%;
403
475
  & > span {
@@ -411,13 +483,14 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
411
483
  /**
412
484
  * The mini edit view for a relation that is displayed inside a modal.
413
485
  * It's complete with its header, document actions and form layout.
414
- */ const RelationEditView = ()=>{
486
+ */ const RelationModalForm = ()=>{
415
487
  const { formatMessage } = reactIntl.useIntl();
416
- const currentDocumentMeta = useRelationModal('RelationModalBody', (state)=>state.currentDocumentMeta);
417
- const currentDocument = useRelationModal('RelationModalBody', (state)=>state.currentDocument);
488
+ const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
489
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
490
+ const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
418
491
  const documentLayoutResponse = useDocumentLayout.useDocumentLayout(currentDocumentMeta.model);
419
- const plugins = strapiAdmin.useStrapiApp('RelationModalBody', (state)=>state.plugins);
420
- const initialValues = currentDocument.getInitialFormValues();
492
+ const plugins = strapiAdmin.useStrapiApp('RelationModalForm', (state)=>state.plugins);
493
+ const initialValues = isCreating ? currentDocument.getInitialFormValues(isCreating) : currentDocument.getInitialFormValues();
421
494
  const { permissions = [], isLoading: isLoadingPermissions, error } = strapiAdmin.useRBAC(plugin.PERMISSIONS.map((action)=>({
422
495
  action,
423
496
  subject: currentDocumentMeta.model
@@ -432,7 +505,7 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
432
505
  })
433
506
  });
434
507
  }
435
- if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !currentDocument.document || !currentDocument.meta || !currentDocument.schema || !initialValues) {
508
+ if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !isCreating && !currentDocument.document || !isCreating && !currentDocument.meta || !currentDocument.schema || !initialValues) {
436
509
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
437
510
  alignItems: "center",
438
511
  height: "100%",
@@ -541,7 +614,7 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
541
614
  });
542
615
  };
543
616
 
544
- exports.RelationModal = RelationModal;
617
+ exports.RelationModalRenderer = RelationModalRenderer;
545
618
  exports.getCollectionType = getCollectionType;
546
619
  exports.reducer = reducer;
547
620
  exports.useRelationModal = useRelationModal;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationModal.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Dialog,\n EmptyStateLayout,\n Flex,\n IconButton,\n Loader,\n Modal,\n Typography,\n TextButton,\n} from '@strapi/design-system';\nimport { ArrowLeft, ArrowsOut, WarningCircle } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../../../constants/collections';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { buildValidParams } from '../../../../../exports';\nimport { DocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDoc, useDocument, type UseDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta } from '../../../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { useLazyGetDocumentQuery } from '../../../../../services/documents';\nimport { createYupSchema } from '../../../../../utils/validation';\nimport { DocumentActionButton } from '../../../components/DocumentActions';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { FormLayout } from '../../FormLayout';\n\nimport type { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\n\nexport function getCollectionType(url: string) {\n const regex = new RegExp(`(${COLLECTION_TYPES}|${SINGLE_TYPES})`);\n const match = url.match(regex);\n return match ? match[1] : undefined;\n}\n\nconst StyledModalContent = styled(Modal.Content)`\n width: 90%;\n max-width: 100%;\n height: 90%;\n max-height: 100%;\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * RelationContextWrapper\n * -----------------------------------------------------------------------------------------------*/\n\ninterface State {\n documentHistory: DocumentMeta[];\n confirmDialogIntent:\n | null // No dialog\n | 'close' // Close the modal\n | 'back' // Go back one document in the modal's history\n | 'navigate' // Open the document in the edit view instead of in the modal\n | DocumentMeta; // Open a specific document in the modal\n isModalOpen: boolean;\n hasUnsavedChanges: boolean;\n}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n };\n }\n | {\n type: 'GO_BACK';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'GO_FULL_PAGE';\n }\n | {\n type: 'CANCEL_CONFIRM_DIALOG';\n }\n | {\n type: 'CLOSE_MODAL';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'SET_HAS_UNSAVED_CHANGES';\n payload: { hasUnsavedChanges: boolean };\n };\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'GO_TO_RELATION':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: action.payload.document };\n }\n\n return {\n ...state,\n documentHistory: [...state.documentHistory, action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n };\n case 'GO_BACK':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'back' };\n }\n\n return {\n ...state,\n documentHistory: state.documentHistory.slice(0, -1),\n confirmDialogIntent: null,\n };\n case 'GO_FULL_PAGE':\n if (state.hasUnsavedChanges) {\n return { ...state, confirmDialogIntent: 'navigate' };\n }\n\n return {\n ...state,\n documentHistory: [],\n hasUnsavedChanges: false,\n isModalOpen: false,\n confirmDialogIntent: null,\n };\n case 'CANCEL_CONFIRM_DIALOG':\n return {\n ...state,\n confirmDialogIntent: null,\n };\n case 'CLOSE_MODAL':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'close' };\n }\n\n return {\n ...state,\n documentHistory: [],\n confirmDialogIntent: null,\n hasUnsavedChanges: false,\n isModalOpen: false,\n };\n case 'SET_HAS_UNSAVED_CHANGES':\n return {\n ...state,\n hasUnsavedChanges: action.payload.hasUnsavedChanges,\n };\n default:\n return state;\n }\n}\n\ninterface RelationModalContextValue {\n state: State;\n dispatch: React.Dispatch<Action>;\n rootDocumentMeta: DocumentMeta;\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n onPreview?: () => void;\n}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\n\nconst getFullPageUrl = (currentDocumentMeta: DocumentMeta): string => {\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const queryParams = currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : '';\n\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;\n};\n\n/**\n * Component responsible of rendering its children wrapped in a modal, form and context if needed\n */\nconst RelationModalRenderer = ({\n children,\n trigger,\n relation,\n}: {\n children: React.ReactNode;\n trigger: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n\n const [state, dispatch] = React.useReducer(reducer, {\n documentHistory: [],\n confirmDialogIntent: null,\n isModalOpen: false,\n hasUnsavedChanges: false,\n });\n\n const rootDocument = useDoc();\n const [{ query }] = useQueryParams();\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n\n const rootDocumentMeta: DocumentMeta = {\n documentId: rootDocument.document?.documentId || '',\n model: rootDocument.model,\n collectionType: rootDocument.collectionType,\n params,\n };\n\n const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;\n const currentDocument = useDocument(currentDocumentMeta);\n\n const parentContextValue = useRelationModal('RelationContextWrapper', (state) => state, false);\n\n // A parent relation is already rendering a modal. In this case simply render the trigger\n if (parentContextValue) {\n return trigger;\n }\n\n /**\n * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the\n * pieces that will be used by potential child relations: the context, header, form, and footer.\n */\n return (\n <RelationModalProvider\n state={state}\n dispatch={dispatch}\n rootDocumentMeta={rootDocumentMeta}\n currentDocumentMeta={currentDocumentMeta}\n currentDocument={currentDocument}\n >\n <Modal.Root\n open={state.isModalOpen}\n onOpenChange={(open) => {\n if (open) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n });\n } else {\n dispatch({\n type: 'CLOSE_MODAL',\n payload: { shouldBypassConfirmation: false },\n });\n }\n }}\n >\n {trigger}\n <StyledModalContent>\n <Modal.Header gap={2}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\" width=\"100%\">\n <Flex gap={2}>\n <IconButton\n withTooltip={false}\n label={formatMessage({ id: 'global.back', defaultMessage: 'Back' })}\n variant=\"ghost\"\n disabled={state.documentHistory.length < 2}\n onClick={() => {\n dispatch({\n type: 'GO_BACK',\n payload: { shouldBypassConfirmation: false },\n });\n }}\n marginRight={1}\n >\n <ArrowLeft />\n </IconButton>\n <Typography tag=\"span\" fontWeight={600}>\n {formatMessage({\n id: 'content-manager.components.RelationInputModal.modal-title',\n defaultMessage: 'Edit a relation',\n })}\n </Typography>\n </Flex>\n <IconButton\n onClick={() => {\n dispatch({\n type: 'GO_FULL_PAGE',\n });\n if (!state.hasUnsavedChanges) {\n navigate(getFullPageUrl(currentDocumentMeta));\n }\n }}\n variant=\"tertiary\"\n label={formatMessage({\n id: 'content-manager.components.RelationInputModal.button-fullpage',\n defaultMessage: 'Go to entry',\n })}\n >\n <ArrowsOut />\n </IconButton>\n </Flex>\n </Modal.Header>\n <Modal.Body>\n <FormContext\n method=\"PUT\"\n initialValues={currentDocument.getInitialFormValues()}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n currentDocument.schema?.attributes,\n currentDocument.components,\n {\n status: currentDocument.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n {children}\n </FormContext>\n </Modal.Body>\n </StyledModalContent>\n </Modal.Root>\n </RelationModalProvider>\n );\n};\n\n/**\n * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.\n * Will be wrapped in a Modal.Body by the RelationModalRenderer.\n * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.\n */\nconst RelationModalBody = () => {\n const navigate = useNavigate();\n const { pathname, search } = useLocation();\n const { formatMessage } = useIntl();\n\n const [triggerRefetchDocument] = useLazyGetDocumentQuery();\n\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n\n /**\n * One-way sync the modified state from the form to the modal state.\n * It is needed because we need to consume state from the form context in order to lift it up\n * into the modal context. It is not possible otherwise because the modal needs the form state,\n * but it must be a parent of the form.\n */\n const modified = useForm('FormWatcher', (state) => state.modified);\n const isSubmitting = useForm('FormWatcher', (state) => state.isSubmitting);\n const hasUnsavedChanges = modified && !isSubmitting;\n React.useEffect(() => {\n dispatch({ type: 'SET_HAS_UNSAVED_CHANGES', payload: { hasUnsavedChanges } });\n }, [hasUnsavedChanges, dispatch]);\n\n const handleCloseModal = (shouldBypassConfirmation: boolean) => {\n dispatch({ type: 'CLOSE_MODAL', payload: { shouldBypassConfirmation } });\n\n if (shouldBypassConfirmation || !state.hasUnsavedChanges) {\n // TODO: check if we can avoid this by relying on RTK invalidatesTags.\n // If so we can delete this function and dispatch the events directly\n triggerRefetchDocument(\n // TODO check if params should be removed (as they were before)\n rootDocumentMeta,\n // Favor the cache\n true\n );\n }\n };\n\n const handleRedirection = () => {\n const editViewUrl = `${pathname}${search}`;\n const fullPageUrl = getFullPageUrl(currentDocumentMeta);\n const isRootDocumentUrl = editViewUrl.includes(fullPageUrl);\n\n if (isRootDocumentUrl) {\n handleCloseModal(true);\n } else {\n navigate(fullPageUrl);\n }\n };\n\n const handleConfirm = () => {\n if (state.confirmDialogIntent === null) {\n return;\n }\n if (state.confirmDialogIntent === 'navigate') {\n handleRedirection();\n } else if (state.confirmDialogIntent === 'back') {\n dispatch({ type: 'GO_BACK', payload: { shouldBypassConfirmation: true } });\n } else if (state.confirmDialogIntent === 'close') {\n handleCloseModal(true);\n } else if ('documentId' in state.confirmDialogIntent) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: state.confirmDialogIntent, shouldBypassConfirmation: true },\n });\n }\n };\n\n return (\n <>\n <RelationEditView />\n <Dialog.Root open={state.confirmDialogIntent != null}>\n <ConfirmDialog\n onConfirm={() => handleConfirm()}\n onCancel={() => dispatch({ type: 'CANCEL_CONFIRM_DIALOG' })}\n variant=\"danger\"\n >\n {formatMessage({\n id: 'content-manager.components.RelationInputModal.confirmation-message',\n defaultMessage:\n 'Some changes were not saved. Are you sure you want to close this relation? All changes that were not saved will be lost.',\n })}\n </ConfirmDialog>\n </Dialog.Root>\n </>\n );\n};\n\nconst ModalTrigger = ({\n children,\n relation,\n}: {\n children: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const dispatch = useRelationModal('ModalTrigger', (state) => state.dispatch);\n\n return (\n <StyledTextButton\n onClick={() => {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n });\n }}\n >\n {children}\n </StyledTextButton>\n );\n};\n\ninterface RelationModalProps {\n children: React.ReactNode;\n relation: DocumentMeta;\n}\n\nconst RelationModal = React.memo(({ relation, children }: RelationModalProps) => {\n return (\n <RelationModalRenderer\n relation={relation}\n trigger={<ModalTrigger relation={relation}>{children}</ModalTrigger>}\n >\n <RelationModalBody />\n </RelationModalRenderer>\n );\n});\n\nconst StyledTextButton = styled(TextButton)`\n max-width: 100%;\n & > span {\n font-size: ${({ theme }) => theme.fontSizes[2]};\n width: inherit;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\n/**\n * The mini edit view for a relation that is displayed inside a modal.\n * It's complete with its header, document actions and form layout.\n */\nconst RelationEditView = () => {\n const { formatMessage } = useIntl();\n\n const currentDocumentMeta = useRelationModal(\n 'RelationModalBody',\n (state) => state.currentDocumentMeta\n );\n const currentDocument = useRelationModal('RelationModalBody', (state) => state.currentDocument);\n const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);\n const plugins = useStrapiApp('RelationModalBody', (state) => state.plugins);\n\n const initialValues = currentDocument.getInitialFormValues();\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: currentDocumentMeta.model,\n }))\n );\n\n const isLoading =\n isLoadingPermissions || documentLayoutResponse.isLoading || currentDocument.isLoading;\n\n if (isLoading && !currentDocument.document?.documentId) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n if (\n error ||\n !currentDocumentMeta.model ||\n documentLayoutResponse.error ||\n !currentDocument.document ||\n !currentDocument.meta ||\n !currentDocument.schema ||\n !initialValues\n ) {\n return (\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n />\n </Flex>\n );\n }\n\n const documentTitle = currentDocument.getTitle(documentLayoutResponse.edit.settings.mainField);\n const hasDraftAndPublished = currentDocument.schema?.options?.draftAndPublish ?? false;\n\n const props = {\n activeTab: 'draft',\n collectionType: currentDocumentMeta.collectionType,\n model: currentDocumentMeta.model,\n documentId: currentDocumentMeta.documentId,\n document: currentDocument.document,\n meta: currentDocument.meta,\n } satisfies DocumentActionProps;\n\n return (\n <DocumentRBAC permissions={permissions} model={currentDocumentMeta.model}>\n <Flex alignItems=\"flex-start\" direction=\"column\" gap={2}>\n <Flex width=\"100%\" justifyContent=\"space-between\" gap={2}>\n <Typography tag=\"h2\" variant=\"alpha\">\n {documentTitle}\n </Typography>\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={props}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('relation-modal')}\n >\n {(actions) => {\n const filteredActions = actions.filter((action) => {\n return [action.position].flat().includes('relation-modal');\n });\n const [primaryAction, secondaryAction] = filteredActions;\n\n if (!primaryAction && !secondaryAction) return null;\n\n // Both actions are available when draft and publish enabled\n if (primaryAction && secondaryAction) {\n return (\n <>\n {/* Save */}\n <DocumentActionButton\n {...secondaryAction}\n variant={secondaryAction.variant || 'secondary'}\n />\n {/* Publish */}\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'default'}\n />\n </>\n );\n }\n\n // Otherwise we just have the save action\n return (\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'secondary'}\n />\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n </Flex>\n {hasDraftAndPublished ? (\n <Box>\n <DocumentStatus status={currentDocument.document?.status} />\n </Box>\n ) : null}\n </Flex>\n\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\" paddingTop={7}>\n <Box overflow=\"auto\" flex={1}>\n <FormLayout\n layout={documentLayoutResponse.edit.layout}\n document={currentDocument}\n hasBackground={false}\n />\n </Box>\n </Flex>\n </DocumentRBAC>\n );\n};\n\nexport { RelationModal, reducer, useRelationModal };\nexport type { State, Action };\n"],"names":["getCollectionType","url","regex","RegExp","COLLECTION_TYPES","SINGLE_TYPES","match","undefined","StyledModalContent","styled","Modal","Content","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","documentHistory","isModalOpen","slice","RelationModalProvider","useRelationModal","createContext","getFullPageUrl","currentDocumentMeta","isSingleType","collectionType","queryParams","params","locale","model","documentId","RelationModalRenderer","children","trigger","relation","formatMessage","useIntl","navigate","useNavigate","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","at","currentDocument","useDocument","parentContextValue","_jsx","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","id","defaultMessage","variant","disabled","length","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","initialValues","getInitialFormValues","validate","values","options","yupSchema","createYupSchema","schema","attributes","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","useEffect","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","includes","handleConfirm","_Fragment","RelationEditView","Dialog","ConfirmDialog","onConfirm","onCancel","ModalTrigger","StyledTextButton","RelationModal","memo","TextButton","theme","fontSizes","documentLayoutResponse","useDocumentLayout","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","meta","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","edit","settings","mainField","hasDraftAndPublished","draftAndPublish","props","activeTab","DocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","filter","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","layout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,4BAAAA,CAAiB,CAAC,EAAEC,wBAAa,CAAA,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAIK,CAAAA,KAAK,CAACJ,KAAAA,CAAAA;AACxB,IAAA,OAAOI,KAAQA,GAAAA,KAAK,CAAC,CAAA,CAAE,GAAGC,SAAAA;AAC5B;AAEA,MAAMC,kBAAqBC,GAAAA,uBAAAA,CAAOC,kBAAMC,CAAAA,OAAO,CAAC;;;;;AAKhD,CAAC;AA6CD,SAASC,OAAAA,CAAQC,KAAY,EAAEC,MAAc,EAAA;AAC3C,IAAA,OAAQA,OAAOC,IAAI;QACjB,KAAK,gBAAA;YACH,IAAIF,KAAAA,CAAMG,iBAAiB,IAAI,CAACF,OAAOG,OAAO,CAACC,wBAAwB,EAAE;gBACvE,OAAO;AAAE,oBAAA,GAAGL,KAAK;oBAAEM,mBAAqBL,EAAAA,MAAAA,CAAOG,OAAO,CAACG;AAAS,iBAAA;AAClE;YAEA,OAAO;AACL,gBAAA,GAAGP,KAAK;gBACRQ,eAAiB,EAAA;AAAIR,oBAAAA,GAAAA,KAAAA,CAAMQ,eAAe;oBAAEP,MAAOG,CAAAA,OAAO,CAACG;AAAS,iBAAA;gBACpED,mBAAqB,EAAA,IAAA;gBACrBG,WAAa,EAAA;AACf,aAAA;QACF,KAAK,SAAA;YACH,IAAIT,KAAAA,CAAMG,iBAAiB,IAAI,CAACF,OA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AA;AACE,4CAAA,GAAGF,aAAa;4CACjB/F,OAAS+F,EAAAA,aAAAA,CAAc/F,OAAO,IAAI;;AAGxC;;;;;AAILgF,oBAAAA,oBAAAA,iBACChG,cAACkH,CAAAA,gBAAAA,EAAAA;AACC,wBAAA,QAAA,gBAAAlH,cAACmH,CAAAA,6BAAAA,EAAAA;4BAAe5E,MAAQ1C,EAAAA,eAAAA,CAAgBnC,QAAQ,EAAE6E;;AAElD,qBAAA,CAAA,GAAA;;;0BAGNvC,cAACO,CAAAA,iBAAAA,EAAAA;gBAAK6G,IAAM,EAAA,CAAA;gBAAGC,QAAS,EAAA,MAAA;gBAAO5G,UAAW,EAAA,SAAA;gBAAU6G,UAAY,EAAA,CAAA;AAC9D,gBAAA,QAAA,gBAAAtH,cAACkH,CAAAA,gBAAAA,EAAAA;oBAAIG,QAAS,EAAA,MAAA;oBAAOD,IAAM,EAAA,CAAA;AACzB,oBAAA,QAAA,gBAAApH,cAACuH,CAAAA,qBAAAA,EAAAA;wBACCC,MAAQjD,EAAAA,sBAAAA,CAAuBsB,IAAI,CAAC2B,MAAM;wBAC1C9J,QAAUmC,EAAAA,eAAAA;wBACV4H,aAAe,EAAA;;;;;;AAM3B,CAAA;;;;;;;"}
1
+ {"version":3,"file":"RelationModal.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Dialog,\n EmptyStateLayout,\n Flex,\n IconButton,\n Loader,\n Modal,\n Typography,\n TextButton,\n} from '@strapi/design-system';\nimport { ArrowLeft, ArrowsOut, WarningCircle } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../../../constants/collections';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { buildValidParams } from '../../../../../exports';\nimport { DocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDoc, useDocument, type UseDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta } from '../../../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { useLazyGetDocumentQuery } from '../../../../../services/documents';\nimport { createYupSchema } from '../../../../../utils/validation';\nimport { DocumentActionButton } from '../../../components/DocumentActions';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { FormLayout } from '../../FormLayout';\nimport { ComponentProvider } from '../ComponentContext';\n\nimport type { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\n\nexport function getCollectionType(url: string) {\n const regex = new RegExp(`(${COLLECTION_TYPES}|${SINGLE_TYPES})`);\n const match = url.match(regex);\n return match ? match[1] : undefined;\n}\n\nconst StyledModalContent = styled(Modal.Content)`\n width: 90%;\n max-width: 100%;\n height: 90%;\n max-height: 100%;\n`;\n\nconst getFullPageUrl = (currentDocumentMeta: DocumentMeta): string => {\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const queryParams = currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : '';\n\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModalRenderer\n * -----------------------------------------------------------------------------------------------*/\n\ninterface State {\n documentHistory: DocumentMeta[];\n confirmDialogIntent:\n | null // No dialog\n | 'close' // Close the modal\n | 'back' // Go back one document in the modal's history\n | 'navigate' // Open the document in the edit view instead of in the modal\n | DocumentMeta; // Open a specific document in the modal\n isModalOpen: boolean;\n hasUnsavedChanges: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n };\n }\n | {\n type: 'GO_BACK';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'GO_FULL_PAGE';\n }\n | {\n type: 'GO_TO_CREATED_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n };\n }\n | {\n type: 'CANCEL_CONFIRM_DIALOG';\n }\n | {\n type: 'CLOSE_MODAL';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'SET_HAS_UNSAVED_CHANGES';\n payload: { hasUnsavedChanges: boolean };\n };\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'GO_TO_RELATION':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return {\n ...state,\n confirmDialogIntent: action.payload.document,\n fieldToConnect: action.payload.fieldToConnect,\n fieldToConnectUID: action.payload.fieldToConnectUID,\n };\n }\n\n const lastItemDocumentHistory = state.documentHistory.at(-1);\n const hasToResetDocumentHistory =\n lastItemDocumentHistory && !lastItemDocumentHistory.documentId;\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: hasToResetDocumentHistory\n ? [action.payload.document]\n : [...state.documentHistory, action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,\n fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID,\n };\n case 'GO_BACK':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'back' };\n }\n\n return {\n ...state,\n documentHistory: state.documentHistory.slice(0, -1),\n confirmDialogIntent: null,\n };\n case 'GO_FULL_PAGE':\n if (state.hasUnsavedChanges) {\n return { ...state, confirmDialogIntent: 'navigate' };\n }\n\n return {\n ...state,\n documentHistory: [],\n hasUnsavedChanges: false,\n isModalOpen: false,\n confirmDialogIntent: null,\n };\n case 'GO_TO_CREATED_RELATION':\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: state.documentHistory\n ? [...state.documentHistory.slice(0, -1), action.payload.document]\n : [action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: undefined,\n fieldToConnectUID: undefined,\n };\n case 'CANCEL_CONFIRM_DIALOG':\n return {\n ...state,\n confirmDialogIntent: null,\n };\n case 'CLOSE_MODAL':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'close' };\n }\n\n return {\n ...state,\n documentHistory: [],\n confirmDialogIntent: null,\n hasUnsavedChanges: false,\n isModalOpen: false,\n };\n case 'SET_HAS_UNSAVED_CHANGES':\n return {\n ...state,\n hasUnsavedChanges: action.payload.hasUnsavedChanges,\n };\n default:\n return state;\n }\n}\n\ninterface RelationModalContextValue {\n state: State;\n dispatch: React.Dispatch<Action>;\n rootDocumentMeta: DocumentMeta;\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n onPreview?: () => void;\n isCreating: boolean;\n}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\n\nfunction isRenderProp(\n children: RelationModalRendererProps['children']\n): children is (props: { dispatch: (action: Action) => void }) => React.ReactNode {\n return typeof children === 'function';\n}\n\ntype RelationModalRendererProps =\n // Is editing\n | {\n relation: DocumentMeta;\n children: React.ReactNode;\n }\n // Is creating\n | {\n relation?: never;\n children: (props: { dispatch: (action: Action) => void }) => React.ReactNode;\n };\n\nconst RootRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n\n const [state, dispatch] = React.useReducer(reducer, {\n documentHistory: [],\n confirmDialogIntent: null,\n isModalOpen: false,\n hasUnsavedChanges: false,\n fieldToConnect: undefined,\n });\n\n const rootDocument = useDoc();\n const [{ query }] = useQueryParams();\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n\n const rootDocumentMeta: DocumentMeta = {\n documentId: rootDocument.document?.documentId || '',\n model: rootDocument.model,\n collectionType: rootDocument.collectionType,\n params,\n };\n\n const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;\n const currentDocument = useDocument(currentDocumentMeta);\n // TODO: check if we can remove the single type check\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const isCreating = !currentDocumentMeta.documentId && !isSingleType;\n /**\n * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the\n * pieces that will be used by potential child relations: the context, header, form, and footer.\n */\n return (\n <RelationModalProvider\n state={state}\n dispatch={dispatch}\n rootDocumentMeta={rootDocumentMeta}\n currentDocumentMeta={currentDocumentMeta}\n currentDocument={currentDocument}\n isCreating={isCreating}\n >\n <RelationModal>\n {isRenderProp(children)\n ? children({ dispatch })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n )}\n </RelationModal>\n </RelationModalProvider>\n );\n};\n\nconst NestedRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n const dispatch = useRelationModal('NestedRelation', (state) => state.dispatch);\n\n return isRenderProp(children)\n ? children({ dispatch })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n ); /* This is the trigger that will be rendered in the parent relation */\n};\n\n/**\n * Component responsible for rendering its children wrapped in a modal, form and context if needed\n */\nconst RelationModalRenderer = (props: RelationModalRendererProps) => {\n // We're in a nested relation if the relation modal context is not undefined\n const isNested = useRelationModal('RelationContextWrapper', (state) => state != undefined, false);\n\n return isNested ? <NestedRelationRenderer {...props} /> : <RootRelationRenderer {...props} />;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModal\n * -----------------------------------------------------------------------------------------------*/\nconst generateCreateUrl = (currentDocumentMeta: DocumentMeta) => {\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${\n currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : ''\n }`;\n};\n\nconst RelationModal = ({ children }: { children: React.ReactNode }) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n\n /*\n * We must wrap the modal window with Component Provider with reset values\n * to avoid inheriting id and uid from the root document and having weird\n * behaviors with simple relationships..\n */\n return (\n <ComponentProvider id={undefined} level={-1} uid={undefined} type={undefined}>\n <Modal.Root\n open={state.isModalOpen}\n onOpenChange={(open) => {\n if (!open) {\n dispatch({\n type: 'CLOSE_MODAL',\n payload: { shouldBypassConfirmation: false },\n });\n }\n }}\n >\n {children}\n <StyledModalContent>\n <Modal.Header gap={2}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\" width=\"100%\">\n <Flex gap={2}>\n <IconButton\n withTooltip={false}\n label={formatMessage({ id: 'global.back', defaultMessage: 'Back' })}\n variant=\"ghost\"\n disabled={state.documentHistory.length < 2}\n onClick={() => {\n dispatch({\n type: 'GO_BACK',\n payload: { shouldBypassConfirmation: false },\n });\n }}\n marginRight={1}\n >\n <ArrowLeft />\n </IconButton>\n <Typography tag=\"span\" fontWeight={600}>\n {isCreating\n ? formatMessage({\n id: 'content-manager.relation.create',\n defaultMessage: 'Create a relation',\n })\n : formatMessage({\n id: 'content-manager.components.RelationInputModal.modal-title',\n defaultMessage: 'Edit a relation',\n })}\n </Typography>\n </Flex>\n <IconButton\n onClick={() => {\n dispatch({\n type: 'GO_FULL_PAGE',\n });\n if (!state.hasUnsavedChanges) {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(getFullPageUrl(currentDocumentMeta));\n }\n }\n }}\n variant=\"tertiary\"\n label={formatMessage({\n id: 'content-manager.components.RelationInputModal.button-fullpage',\n defaultMessage: 'Go to entry',\n })}\n >\n <ArrowsOut />\n </IconButton>\n </Flex>\n </Modal.Header>\n <Modal.Body>\n <FormContext\n method={isCreating ? 'POST' : 'PUT'}\n initialValues={currentDocument.getInitialFormValues(isCreating)}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n currentDocument.schema?.attributes,\n currentDocument.components,\n {\n status: currentDocument.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n <RelationModalBody />\n </FormContext>\n </Modal.Body>\n </StyledModalContent>\n </Modal.Root>\n </ComponentProvider>\n );\n};\n/**\n * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.\n * Will be wrapped in a Modal.Body by the RelationModal component.\n * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.\n */\nconst RelationModalBody = () => {\n const navigate = useNavigate();\n const { pathname, search } = useLocation();\n const { formatMessage } = useIntl();\n\n const [triggerRefetchDocument] = useLazyGetDocumentQuery();\n\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n\n /**\n * One-way sync the modified state from the form to the modal state.\n * It is needed because we need to consume state from the form context in order to lift it up\n * into the modal context. It is not possible otherwise because the modal needs the form state,\n * but it must be a parent of the form.\n */\n const modified = useForm('FormWatcher', (state) => state.modified);\n const isSubmitting = useForm('FormWatcher', (state) => state.isSubmitting);\n const hasUnsavedChanges = modified && !isSubmitting;\n React.useEffect(() => {\n dispatch({ type: 'SET_HAS_UNSAVED_CHANGES', payload: { hasUnsavedChanges } });\n }, [hasUnsavedChanges, dispatch]);\n\n const handleCloseModal = (shouldBypassConfirmation: boolean) => {\n dispatch({ type: 'CLOSE_MODAL', payload: { shouldBypassConfirmation } });\n\n if (shouldBypassConfirmation || !state.hasUnsavedChanges) {\n // TODO: check if we can avoid this by relying on RTK invalidatesTags.\n // If so we can delete this function and dispatch the events directly\n triggerRefetchDocument(\n // TODO check if params should be removed (as they were before)\n rootDocumentMeta,\n // Favor the cache\n true\n );\n }\n };\n\n const handleRedirection = () => {\n const editViewUrl = `${pathname}${search}`;\n const fullPageUrl = getFullPageUrl(currentDocumentMeta);\n const isRootDocumentUrl = editViewUrl.includes(fullPageUrl);\n\n if (isRootDocumentUrl) {\n handleCloseModal(true);\n } else {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(fullPageUrl);\n }\n }\n };\n\n const handleConfirm = () => {\n if (state.confirmDialogIntent === null) {\n return;\n }\n if (state.confirmDialogIntent === 'navigate') {\n handleRedirection();\n } else if (state.confirmDialogIntent === 'back') {\n dispatch({ type: 'GO_BACK', payload: { shouldBypassConfirmation: true } });\n } else if (state.confirmDialogIntent === 'close') {\n handleCloseModal(true);\n } else if ('documentId' in state.confirmDialogIntent) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: state.confirmDialogIntent, shouldBypassConfirmation: true },\n });\n }\n };\n\n return (\n <>\n <RelationModalForm />\n <Dialog.Root open={state.confirmDialogIntent != null}>\n <ConfirmDialog\n onConfirm={() => handleConfirm()}\n onCancel={() => dispatch({ type: 'CANCEL_CONFIRM_DIALOG' })}\n variant=\"danger\"\n >\n {formatMessage({\n id: 'content-manager.components.RelationInputModal.confirmation-message',\n defaultMessage:\n 'Some changes were not saved. Are you sure you want to close this relation? All changes that were not saved will be lost.',\n })}\n </ConfirmDialog>\n </Dialog.Root>\n </>\n );\n};\n\nconst RelationModalTrigger = ({\n children,\n relation,\n}: {\n children: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const dispatch = useRelationModal('ModalTrigger', (state) => state.dispatch);\n\n return (\n <StyledTextButton\n onClick={() => {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n });\n }}\n >\n {children}\n </StyledTextButton>\n );\n};\n\nconst StyledTextButton = styled(TextButton)`\n max-width: 100%;\n & > span {\n font-size: ${({ theme }) => theme.fontSizes[2]};\n width: inherit;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\n/**\n * The mini edit view for a relation that is displayed inside a modal.\n * It's complete with its header, document actions and form layout.\n */\nconst RelationModalForm = () => {\n const { formatMessage } = useIntl();\n\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);\n const plugins = useStrapiApp('RelationModalForm', (state) => state.plugins);\n\n const initialValues = isCreating\n ? currentDocument.getInitialFormValues(isCreating)\n : currentDocument.getInitialFormValues();\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: currentDocumentMeta.model,\n }))\n );\n\n const isLoading =\n isLoadingPermissions || documentLayoutResponse.isLoading || currentDocument.isLoading;\n\n if (isLoading && !currentDocument.document?.documentId) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n if (\n error ||\n !currentDocumentMeta.model ||\n documentLayoutResponse.error ||\n (!isCreating && !currentDocument.document) ||\n (!isCreating && !currentDocument.meta) ||\n !currentDocument.schema ||\n !initialValues\n ) {\n return (\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n />\n </Flex>\n );\n }\n\n const documentTitle = currentDocument.getTitle(documentLayoutResponse.edit.settings.mainField);\n const hasDraftAndPublished = currentDocument.schema?.options?.draftAndPublish ?? false;\n\n const props = {\n activeTab: 'draft',\n collectionType: currentDocumentMeta.collectionType,\n model: currentDocumentMeta.model,\n documentId: currentDocumentMeta.documentId,\n document: currentDocument.document,\n meta: currentDocument.meta,\n } satisfies DocumentActionProps;\n\n return (\n <DocumentRBAC permissions={permissions} model={currentDocumentMeta.model}>\n <Flex alignItems=\"flex-start\" direction=\"column\" gap={2}>\n <Flex width=\"100%\" justifyContent=\"space-between\" gap={2}>\n <Typography tag=\"h2\" variant=\"alpha\">\n {documentTitle}\n </Typography>\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={props}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('relation-modal')}\n >\n {(actions) => {\n const filteredActions = actions.filter((action) => {\n return [action.position].flat().includes('relation-modal');\n });\n const [primaryAction, secondaryAction] = filteredActions;\n\n if (!primaryAction && !secondaryAction) return null;\n\n // Both actions are available when draft and publish enabled\n if (primaryAction && secondaryAction) {\n return (\n <>\n {/* Save */}\n <DocumentActionButton\n {...secondaryAction}\n variant={secondaryAction.variant || 'secondary'}\n />\n {/* Publish */}\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'default'}\n />\n </>\n );\n }\n\n // Otherwise we just have the save action\n return (\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'secondary'}\n />\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n </Flex>\n {hasDraftAndPublished ? (\n <Box>\n <DocumentStatus status={currentDocument.document?.status} />\n </Box>\n ) : null}\n </Flex>\n\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\" paddingTop={7}>\n <Box overflow=\"auto\" flex={1}>\n <FormLayout\n layout={documentLayoutResponse.edit.layout}\n document={currentDocument}\n hasBackground={false}\n />\n </Box>\n </Flex>\n </DocumentRBAC>\n );\n};\n\nexport { reducer, RelationModalRenderer, useRelationModal };\nexport type { State, Action };\n"],"names":["getCollectionType","url","regex","RegExp","COLLECTION_TYPES","SINGLE_TYPES","match","undefined","StyledModalContent","styled","Modal","Content","getFullPageUrl","currentDocumentMeta","isSingleType","collectionType","queryParams","params","locale","model","documentId","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","fieldToConnect","fieldToConnectUID","lastItemDocumentHistory","documentHistory","at","hasToResetDocumentHistory","isModalOpen","slice","RelationModalProvider","useRelationModal","createContext","isRenderProp","children","RootRelationRenderer","props","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","currentDocument","useDocument","isCreating","_jsx","RelationModal","relation","RelationModalTrigger","NestedRelationRenderer","RelationModalRenderer","isNested","generateCreateUrl","formatMessage","useIntl","navigate","useNavigate","ComponentProvider","id","level","uid","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","defaultMessage","variant","disabled","length","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","initialValues","getInitialFormValues","validate","values","options","yupSchema","createYupSchema","schema","attributes","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","useEffect","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","includes","handleConfirm","_Fragment","RelationModalForm","Dialog","ConfirmDialog","onConfirm","onCancel","StyledTextButton","TextButton","theme","fontSizes","documentLayoutResponse","useDocumentLayout","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","meta","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","edit","settings","mainField","hasDraftAndPublished","draftAndPublish","activeTab","DocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","filter","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","layout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,4BAAAA,CAAiB,CAAC,EAAEC,wBAAa,CAAA,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAIK,CAAAA,KAAK,CAACJ,KAAAA,CAAAA;AACxB,IAAA,OAAOI,KAAQA,GAAAA,KAAK,CAAC,CAAA,CAAE,GAAGC,SAAAA;AAC5B;AAEA,MAAMC,kBAAqBC,GAAAA,uBAAAA,CAAOC,kBAAMC,CAAAA,OAAO,CAAC;;;;;AAKhD,CAAC;AAED,MAAMC,iBAAiB,CAACC,mBAAAA,GAAAA;IACtB,MAAMC,YAAAA,GAAeD,mBAAoBE,CAAAA,cAAc,KAAKV,wBAAAA;AAC5D,IAAA,MAAMW,WAAcH,GAAAA,mBAAAA,CAAoBI,MAAM,EAAEC,SAC5C,CAAC,uBAAuB,EAAEL,mBAAAA,CAAoBI,MAAM,CAACC,MAAM,CAAC,CAAC,GAC7D,EAAA;IAEJ,OAAO,CAAC,iBAAiB,EAAEL,mBAAAA,CAAoBE,cAAc,CAAC,CAAC,EAAEF,mBAAoBM,CAAAA,KAAK,CAAC,EAAEL,YAAAA,GAAe,KAAK,GAAMD,GAAAA,mBAAAA,CAAoBO,UAAU,CAAC,EAAEJ,YAAY,CAAC;AACvK,CAAA;AA0DA,SAASK,OAAAA,CAAQC,KAAY,EAAEC,MAAc,EAAA;AAC3C,IAAA,OAAQA,OAAOC,IAAI;QACjB,KAAK,gBAAA;YACH,IAAIF,KAAAA,CAAMG,iBAAiB,I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