@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.
Files changed (133) hide show
  1. package/dist/admin/components/DragPreviews/RelationDragPreview.js +1 -1
  2. package/dist/admin/components/DragPreviews/RelationDragPreview.js.map +1 -1
  3. package/dist/admin/components/DragPreviews/RelationDragPreview.mjs +1 -1
  4. package/dist/admin/components/DragPreviews/RelationDragPreview.mjs.map +1 -1
  5. package/dist/admin/components/LeftMenu.js +34 -30
  6. package/dist/admin/components/LeftMenu.js.map +1 -1
  7. package/dist/admin/components/LeftMenu.mjs +36 -32
  8. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  9. package/dist/admin/content-manager.js.map +1 -1
  10. package/dist/admin/content-manager.mjs.map +1 -1
  11. package/dist/admin/features/DocumentContext.js +71 -0
  12. package/dist/admin/features/DocumentContext.js.map +1 -0
  13. package/dist/admin/features/DocumentContext.mjs +49 -0
  14. package/dist/admin/features/DocumentContext.mjs.map +1 -0
  15. package/dist/admin/features/DocumentRBAC.js +7 -6
  16. package/dist/admin/features/DocumentRBAC.js.map +1 -1
  17. package/dist/admin/features/DocumentRBAC.mjs +7 -6
  18. package/dist/admin/features/DocumentRBAC.mjs.map +1 -1
  19. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  20. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  21. package/dist/admin/history/pages/History.js +9 -1
  22. package/dist/admin/history/pages/History.js.map +1 -1
  23. package/dist/admin/history/pages/History.mjs +9 -1
  24. package/dist/admin/history/pages/History.mjs.map +1 -1
  25. package/dist/admin/hooks/useDocumentActions.js +12 -3
  26. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  27. package/dist/admin/hooks/useDocumentActions.mjs +12 -3
  28. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/EditViewPage.js +95 -84
  30. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  31. package/dist/admin/pages/EditView/EditViewPage.mjs +95 -84
  32. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/DocumentActions.js +26 -11
  34. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/DocumentActions.mjs +26 -11
  36. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/DocumentStatus.js +1 -2
  38. package/dist/admin/pages/EditView/components/DocumentStatus.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/DocumentStatus.mjs +1 -2
  40. package/dist/admin/pages/EditView/components/DocumentStatus.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js +2 -2
  42. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs +2 -2
  44. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +4 -1
  46. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +4 -1
  48. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +5 -3
  50. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +5 -3
  52. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +17 -8
  54. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +17 -8
  56. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
  57. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +16 -1
  58. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  59. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +17 -2
  60. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  61. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +3 -2
  62. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  63. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +3 -2
  64. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  65. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +460 -0
  66. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -0
  67. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +438 -0
  68. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -0
  69. package/dist/admin/pages/EditView/components/FormInputs/{Relations.js → Relations/Relations.js} +65 -42
  70. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -0
  71. package/dist/admin/pages/EditView/components/FormInputs/{Relations.mjs → Relations/Relations.mjs} +66 -43
  72. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -0
  73. package/dist/admin/pages/EditView/components/FormLayout.js +20 -13
  74. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  75. package/dist/admin/pages/EditView/components/FormLayout.mjs +20 -13
  76. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  77. package/dist/admin/pages/EditView/components/InputRenderer.js +35 -8
  78. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  79. package/dist/admin/pages/EditView/components/InputRenderer.mjs +18 -10
  80. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  81. package/dist/admin/pages/ListView/ListViewPage.js +41 -0
  82. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  83. package/dist/admin/pages/ListView/ListViewPage.mjs +42 -1
  84. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  85. package/dist/admin/pages/ListView/components/TableCells/Relations.js +0 -1
  86. package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
  87. package/dist/admin/pages/ListView/components/TableCells/Relations.mjs +0 -1
  88. package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
  89. package/dist/admin/preview/components/PreviewHeader.js +5 -77
  90. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  91. package/dist/admin/preview/components/PreviewHeader.mjs +7 -78
  92. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  93. package/dist/admin/preview/pages/Preview.js +47 -39
  94. package/dist/admin/preview/pages/Preview.js.map +1 -1
  95. package/dist/admin/preview/pages/Preview.mjs +48 -40
  96. package/dist/admin/preview/pages/Preview.mjs.map +1 -1
  97. package/dist/admin/services/documents.js +16 -0
  98. package/dist/admin/services/documents.js.map +1 -1
  99. package/dist/admin/services/documents.mjs +16 -0
  100. package/dist/admin/services/documents.mjs.map +1 -1
  101. package/dist/admin/src/content-manager.d.ts +2 -0
  102. package/dist/admin/src/features/DocumentContext.d.ts +53 -0
  103. package/dist/admin/src/features/DocumentRBAC.d.ts +3 -2
  104. package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -1
  105. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  106. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +8 -0
  107. package/dist/admin/src/pages/EditView/components/FormInputs/{Relations.d.ts → Relations/Relations.d.ts} +8 -2
  108. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +8 -3
  109. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +7 -4
  110. package/dist/admin/src/preview/components/PreviewHeader.d.ts +1 -2
  111. package/dist/admin/src/preview/pages/Preview.d.ts +0 -2
  112. package/dist/admin/translations/en.json.js +3 -0
  113. package/dist/admin/translations/en.json.js.map +1 -1
  114. package/dist/admin/translations/en.json.mjs +3 -0
  115. package/dist/admin/translations/en.json.mjs.map +1 -1
  116. package/dist/admin/translations/zh-Hans.json.js +2 -1
  117. package/dist/admin/translations/zh-Hans.json.js.map +1 -1
  118. package/dist/admin/translations/zh-Hans.json.mjs +2 -1
  119. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -1
  120. package/dist/server/src/index.d.ts +1 -0
  121. package/dist/server/src/index.d.ts.map +1 -1
  122. package/dist/server/src/services/data-mapper.d.ts +1 -0
  123. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  124. package/dist/server/src/services/index.d.ts +1 -0
  125. package/dist/server/src/services/index.d.ts.map +1 -1
  126. package/package.json +8 -8
  127. package/dist/admin/pages/EditView/components/FormInputs/Relations.js.map +0 -1
  128. package/dist/admin/pages/EditView/components/FormInputs/Relations.mjs.map +0 -1
  129. package/dist/admin/preview/components/PreviewContent.js +0 -25
  130. package/dist/admin/preview/components/PreviewContent.js.map +0 -1
  131. package/dist/admin/preview/components/PreviewContent.mjs +0 -23
  132. package/dist/admin/preview/components/PreviewContent.mjs.map +0 -1
  133. package/dist/admin/src/preview/components/PreviewContent.d.ts +0 -2
@@ -0,0 +1,49 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { createContext } from '@strapi/admin/strapi-admin';
4
+ import { useDocument } from '../hooks/useDocument.mjs';
5
+ import { buildValidParams } from '../utils/api.mjs';
6
+
7
+ const [DocumentProvider, useDocumentContext] = createContext('DocumentContext');
8
+ /**
9
+ * TODO: Document in contributor docs, Add unit test
10
+ *
11
+ * This context provider and its associated hook are used to access a document at its root level
12
+ * and expose a function to change the current document being viewed to one of the root level docuemnt's relations.
13
+ *
14
+ * The useDocumentContext hook exposes:
15
+ * - meta: information about the currentDocument,
16
+ * - document: the actual document,
17
+ * - changeDocument: a function to change the current document to one of its relations.
18
+ * - rootDocumentMeta: information about the root level document (current page)
19
+ */ const DocumentContextProvider = ({ children, initialDocument, onPreview })=>{
20
+ /**
21
+ * Initialize with the "root" document and expose a setter method to change to
22
+ * one of the root level document's relations.
23
+ */ const [currentDocumentMeta, changeDocument] = React.useState(initialDocument);
24
+ const params = React.useMemo(()=>buildValidParams(currentDocumentMeta.params ?? {}), [
25
+ currentDocumentMeta.params
26
+ ]);
27
+ const document = useDocument({
28
+ ...currentDocumentMeta,
29
+ params
30
+ });
31
+ const [documentHistory, setDocumentHistory] = React.useState([]);
32
+ return /*#__PURE__*/ jsx(DocumentProvider, {
33
+ changeDocument: changeDocument,
34
+ document: document,
35
+ rootDocumentMeta: {
36
+ documentId: initialDocument.documentId,
37
+ model: initialDocument.model,
38
+ collectionType: initialDocument.collectionType
39
+ },
40
+ meta: currentDocumentMeta,
41
+ documentHistory: documentHistory,
42
+ setDocumentHistory: setDocumentHistory,
43
+ onPreview: onPreview,
44
+ children: children
45
+ });
46
+ };
47
+
48
+ export { DocumentContextProvider, useDocumentContext };
49
+ //# sourceMappingURL=DocumentContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentContext.mjs","sources":["../../../admin/src/features/DocumentContext.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { createContext } from '@strapi/admin/strapi-admin';\n\nimport { useDocument, type UseDocument } from '../hooks/useDocument';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n rootDocumentMeta: DocumentMeta;\n document: ReturnType<UseDocument>;\n meta: DocumentMeta;\n changeDocument: (newRelation: DocumentMeta) => void;\n documentHistory: DocumentMeta[];\n setDocumentHistory: React.Dispatch<React.SetStateAction<DocumentMeta[]>>;\n onPreview?: () => void;\n}\n\nconst [DocumentProvider, useDocumentContext] =\n createContext<DocumentContextValue>('DocumentContext');\n\n/**\n * TODO: Document in contributor docs, Add unit test\n *\n * This context provider and its associated hook are used to access a document at its root level\n * and expose a function to change the current document being viewed to one of the root level docuemnt's relations.\n *\n * The useDocumentContext hook exposes:\n * - meta: information about the currentDocument,\n * - document: the actual document,\n * - changeDocument: a function to change the current document to one of its relations.\n * - rootDocumentMeta: information about the root level document (current page)\n */\nconst DocumentContextProvider = ({\n children,\n initialDocument,\n onPreview,\n}: {\n children: React.ReactNode | React.ReactNode[];\n initialDocument: DocumentMeta;\n onPreview?: () => void;\n}) => {\n /**\n * Initialize with the \"root\" document and expose a setter method to change to\n * one of the root level document's relations.\n */\n const [currentDocumentMeta, changeDocument] = React.useState<DocumentMeta>(initialDocument);\n const params = React.useMemo(\n () => buildValidParams(currentDocumentMeta.params ?? {}),\n [currentDocumentMeta.params]\n );\n const document = useDocument({ ...currentDocumentMeta, params });\n\n const [documentHistory, setDocumentHistory] = React.useState<DocumentMeta[]>([]);\n\n return (\n <DocumentProvider\n changeDocument={changeDocument}\n document={document}\n rootDocumentMeta={{\n documentId: initialDocument.documentId,\n model: initialDocument.model,\n collectionType: initialDocument.collectionType,\n }}\n meta={currentDocumentMeta}\n documentHistory={documentHistory}\n setDocumentHistory={setDocumentHistory}\n onPreview={onPreview}\n >\n {children}\n </DocumentProvider>\n );\n};\n\nexport { useDocumentContext, DocumentContextProvider };\nexport type { DocumentMeta };\n"],"names":["DocumentProvider","useDocumentContext","createContext","DocumentContextProvider","children","initialDocument","onPreview","currentDocumentMeta","changeDocument","React","useState","params","useMemo","buildValidParams","document","useDocument","documentHistory","setDocumentHistory","_jsx","rootDocumentMeta","documentId","model","collectionType","meta"],"mappings":";;;;;;AAwCA,MAAM,CAACA,gBAAAA,EAAkBC,kBAAmB,CAAA,GAC1CC,aAAoC,CAAA,iBAAA;AAEtC;;;;;;;;;;;IAYA,MAAMC,0BAA0B,CAAC,EAC/BC,QAAQ,EACRC,eAAe,EACfC,SAAS,EAKV,GAAA;AACC;;;AAGC,MACD,MAAM,CAACC,mBAAAA,EAAqBC,eAAe,GAAGC,KAAAA,CAAMC,QAAQ,CAAeL,eAAAA,CAAAA;IAC3E,MAAMM,MAAAA,GAASF,KAAMG,CAAAA,OAAO,CAC1B,IAAMC,iBAAiBN,mBAAoBI,CAAAA,MAAM,IAAI,EACrD,CAAA,EAAA;AAACJ,QAAAA,mBAAAA,CAAoBI;AAAO,KAAA,CAAA;AAE9B,IAAA,MAAMG,WAAWC,WAAY,CAAA;AAAE,QAAA,GAAGR,mBAAmB;AAAEI,QAAAA;AAAO,KAAA,CAAA;AAE9D,IAAA,MAAM,CAACK,eAAiBC,EAAAA,kBAAAA,CAAmB,GAAGR,KAAMC,CAAAA,QAAQ,CAAiB,EAAE,CAAA;AAE/E,IAAA,qBACEQ,GAAClB,CAAAA,gBAAAA,EAAAA;QACCQ,cAAgBA,EAAAA,cAAAA;QAChBM,QAAUA,EAAAA,QAAAA;QACVK,gBAAkB,EAAA;AAChBC,YAAAA,UAAAA,EAAYf,gBAAgBe,UAAU;AACtCC,YAAAA,KAAAA,EAAOhB,gBAAgBgB,KAAK;AAC5BC,YAAAA,cAAAA,EAAgBjB,gBAAgBiB;AAClC,SAAA;QACAC,IAAMhB,EAAAA,mBAAAA;QACNS,eAAiBA,EAAAA,eAAAA;QACjBC,kBAAoBA,EAAAA,kBAAAA;QACpBX,SAAWA,EAAAA,SAAAA;AAEVF,QAAAA,QAAAA,EAAAA;;AAGP;;;;"}
@@ -38,20 +38,21 @@ const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext('Docum
38
38
  });
39
39
  /**
40
40
  * @internal This component is not meant to be used outside of the Content Manager plugin.
41
- * It depends on knowing the slug/model of the content-type using the params of the URL.
41
+ * It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.
42
42
  * If you do use the hook outside of the context, we default to `false` for all actions.
43
43
  *
44
44
  * It then creates an list of `can{Action}` that are passed to the context for consumption
45
45
  * within the app to enforce RBAC.
46
- */ const DocumentRBAC = ({ children, permissions })=>{
46
+ */ const DocumentRBAC = ({ children, permissions, model })=>{
47
47
  const { slug } = reactRouterDom.useParams();
48
- if (!slug) {
49
- throw new Error('Cannot find the slug param in the URL');
48
+ if (!slug && !model) {
49
+ throw new Error('Cannot find the slug param in the URL or the model prop is not provided.');
50
50
  }
51
+ const contentTypeUid = model ?? slug;
51
52
  const [{ rawQuery }] = strapiAdmin.useQueryParams();
52
53
  const userPermissions = strapiAdmin.useAuth('DocumentRBAC', (state)=>state.permissions);
53
54
  const contentTypePermissions = React__namespace.useMemo(()=>{
54
- const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === slug);
55
+ const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === contentTypeUid);
55
56
  return contentTypePermissions.reduce((acc, permission)=>{
56
57
  const [action] = permission.action.split('.').slice(-1);
57
58
  return {
@@ -62,7 +63,7 @@ const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext('Docum
62
63
  };
63
64
  }, {});
64
65
  }, [
65
- slug,
66
+ contentTypeUid,
66
67
  userPermissions
67
68
  ]);
68
69
  const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? undefined, // TODO: useRBAC context should be typed and built differently
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentRBAC.js","sources":["../../../admin/src/features/DocumentRBAC.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useRBAC,\n useAuth,\n type Permission,\n createContext,\n Page,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport type { Schema } from '@strapi/types';\n\n/**\n * The boolean values indicate the global actions a user can perform on the document.\n * The `string[]` values tell us specifically which fields the actions can be performed on,\n * for example, if the `canReadFields` array is empty, than no fields can be read by the user.\n * This can happen even if the user can read the document.\n */\ninterface DocumentRBACContextValue {\n canCreate?: boolean;\n canCreateFields: string[];\n canDelete?: boolean;\n canPublish?: boolean;\n canRead?: boolean;\n canReadFields: string[];\n canUpdate?: boolean;\n canUpdateFields: string[];\n canUserAction: (\n fieldName: string,\n fieldsUserCanAction: string[],\n fieldType: Schema.Attribute.Kind\n ) => boolean;\n isLoading: boolean;\n}\n\nconst [DocumentRBACProvider, useDocumentRBAC] = createContext<DocumentRBACContextValue>(\n 'DocumentRBAC',\n {\n canCreate: false,\n canCreateFields: [],\n canDelete: false,\n canPublish: false,\n canRead: false,\n canReadFields: [],\n canUpdate: false,\n canUpdateFields: [],\n canUserAction: () => false,\n isLoading: false,\n }\n);\n\ninterface DocumentRBACProps {\n children: React.ReactNode;\n permissions: Permission[] | null;\n}\n\n/**\n * @internal This component is not meant to be used outside of the Content Manager plugin.\n * It depends on knowing the slug/model of the content-type using the params of the URL.\n * If you do use the hook outside of the context, we default to `false` for all actions.\n *\n * It then creates an list of `can{Action}` that are passed to the context for consumption\n * within the app to enforce RBAC.\n */\nconst DocumentRBAC = ({ children, permissions }: DocumentRBACProps) => {\n const { slug } = useParams<{ slug: string }>();\n\n if (!slug) {\n throw new Error('Cannot find the slug param in the URL');\n }\n const [{ rawQuery }] = useQueryParams<{ plugins?: { i18n?: { locale?: string } } }>();\n\n const userPermissions = useAuth('DocumentRBAC', (state) => state.permissions);\n\n const contentTypePermissions = React.useMemo(() => {\n const contentTypePermissions = userPermissions.filter(\n (permission) => permission.subject === slug\n );\n return contentTypePermissions.reduce<Record<string, Permission[]>>((acc, permission) => {\n const [action] = permission.action.split('.').slice(-1);\n return { ...acc, [action]: [permission] };\n }, {});\n }, [slug, userPermissions]);\n\n const { isLoading, allowedActions } = useRBAC(\n contentTypePermissions,\n permissions ?? undefined,\n // TODO: useRBAC context should be typed and built differently\n // We are passing raw query as context to the hook so that it can\n // rely on the locale provided from DocumentRBAC for its permission calculations.\n rawQuery\n );\n\n const canCreateFields =\n !isLoading && allowedActions.canCreate\n ? extractAndDedupeFields(contentTypePermissions.create)\n : [];\n\n const canReadFields =\n !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];\n\n const canUpdateFields =\n !isLoading && allowedActions.canUpdate\n ? extractAndDedupeFields(contentTypePermissions.update)\n : [];\n\n /**\n * @description Checks if the user can perform an action on a field based on the field names\n * provided as the second argument.\n */\n const canUserAction: DocumentRBACContextValue['canUserAction'] = React.useCallback(\n (fieldName, fieldsUserCanAction, fieldType) => {\n const name = removeNumericalStrings(fieldName.split('.'));\n\n const componentFieldNames = fieldsUserCanAction\n // filter out fields that aren't components (components are dot separated)\n .filter((field) => field.split('.').length > 1);\n\n if (fieldType === 'component') {\n // check if the field name is within any of those arrays\n return componentFieldNames.some((field) => {\n return field.includes(name.join('.'));\n });\n }\n\n /**\n * The field is within a component.\n */\n if (name.length > 1) {\n return componentFieldNames.includes(name.join('.'));\n }\n\n /**\n * just a regular field\n */\n return fieldsUserCanAction.includes(fieldName);\n },\n []\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n return (\n <DocumentRBACProvider\n isLoading={isLoading}\n canCreateFields={canCreateFields}\n canReadFields={canReadFields}\n canUpdateFields={canUpdateFields}\n canUserAction={canUserAction}\n {...allowedActions}\n >\n {children}\n </DocumentRBACProvider>\n );\n};\n\n/**\n * @internal it's really small, but it's used three times in a row and DRY for something this straight forward.\n */\nconst extractAndDedupeFields = (permissions: Permission[] = []) =>\n permissions\n .flatMap((permission) => permission.properties?.fields)\n .filter(\n (field, index, arr): field is string =>\n arr.indexOf(field) === index && typeof field === 'string'\n );\n\n/**\n * @internal removes numerical strings from arrays.\n * @example\n * ```ts\n * const name = 'a.0.b';\n * const res = removeNumericalStrings(name.split('.'));\n * console.log(res); // ['a', 'b']\n * ```\n */\nconst removeNumericalStrings = (arr: string[]) => arr.filter((item) => isNaN(Number(item)));\n\nexport { DocumentRBAC, useDocumentRBAC, DocumentRBACContextValue, DocumentRBACProps };\n"],"names":["DocumentRBACProvider","useDocumentRBAC","createContext","canCreate","canCreateFields","canDelete","canPublish","canRead","canReadFields","canUpdate","canUpdateFields","canUserAction","isLoading","DocumentRBAC","children","permissions","slug","useParams","Error","rawQuery","useQueryParams","userPermissions","useAuth","state","contentTypePermissions","React","useMemo","filter","permission","subject","reduce","acc","action","split","slice","allowedActions","useRBAC","undefined","extractAndDedupeFields","create","read","update","useCallback","fieldName","fieldsUserCanAction","fieldType","name","removeNumericalStrings","componentFieldNames","field","length","some","includes","join","_jsx","Page","Loading","flatMap","properties","fields","index","arr","indexOf","item","isNaN","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,CAACA,oBAAAA,EAAsBC,eAAgB,CAAA,GAAGC,0BAC9C,cACA,EAAA;IACEC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;IACnBC,SAAW,EAAA,KAAA;IACXC,UAAY,EAAA,KAAA;IACZC,OAAS,EAAA,KAAA;AACTC,IAAAA,aAAAA,EAAe,EAAE;IACjBC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,aAAAA,EAAe,IAAM,KAAA;IACrBC,SAAW,EAAA;AACb,CAAA;AAQF;;;;;;;AAOC,UACKC,YAAe,GAAA,CAAC,EAAEC,QAAQ,EAAEC,WAAW,EAAqB,GAAA;IAChE,MAAM,EAAEC,IAAI,EAAE,GAAGC,wBAAAA,EAAAA;AAEjB,IAAA,IAAI,CAACD,IAAM,EAAA;AACT,QAAA,MAAM,I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,EAAAA,aAAAA;AACd,QAAA,GAAGwB,cAAc;AAEjBrB,QAAAA,QAAAA,EAAAA;;AAGP;AAEA;;IAGA,MAAMwB,sBAAyB,GAAA,CAACvB,WAA4B,GAAA,EAAE,GAC5DA,WAAAA,CACG0C,OAAO,CAAC,CAAC7B,UAAAA,GAAeA,UAAW8B,CAAAA,UAAU,EAAEC,MAAAA,CAAAA,CAC/ChC,MAAM,CACL,CAACsB,KAAAA,EAAOW,KAAOC,EAAAA,GAAAA,GACbA,GAAIC,CAAAA,OAAO,CAACb,KAAAA,CAAAA,KAAWW,KAAS,IAAA,OAAOX,KAAU,KAAA,QAAA,CAAA;AAGzD;;;;;;;;IASA,MAAMF,sBAAyB,GAAA,CAACc,GAAkBA,GAAAA,GAAAA,CAAIlC,MAAM,CAAC,CAACoC,IAASC,GAAAA,KAAAA,CAAMC,MAAOF,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA;;;;;"}
1
+ {"version":3,"file":"DocumentRBAC.js","sources":["../../../admin/src/features/DocumentRBAC.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useRBAC,\n useAuth,\n type Permission,\n createContext,\n Page,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport type { Schema } from '@strapi/types';\n\n/**\n * The boolean values indicate the global actions a user can perform on the document.\n * The `string[]` values tell us specifically which fields the actions can be performed on,\n * for example, if the `canReadFields` array is empty, than no fields can be read by the user.\n * This can happen even if the user can read the document.\n */\ninterface DocumentRBACContextValue {\n canCreate?: boolean;\n canCreateFields: string[];\n canDelete?: boolean;\n canPublish?: boolean;\n canRead?: boolean;\n canReadFields: string[];\n canUpdate?: boolean;\n canUpdateFields: string[];\n canUserAction: (\n fieldName: string,\n fieldsUserCanAction: string[],\n fieldType: Schema.Attribute.Kind\n ) => boolean;\n isLoading: boolean;\n}\n\nconst [DocumentRBACProvider, useDocumentRBAC] = createContext<DocumentRBACContextValue>(\n 'DocumentRBAC',\n {\n canCreate: false,\n canCreateFields: [],\n canDelete: false,\n canPublish: false,\n canRead: false,\n canReadFields: [],\n canUpdate: false,\n canUpdateFields: [],\n canUserAction: () => false,\n isLoading: false,\n }\n);\n\ninterface DocumentRBACProps {\n children: React.ReactNode;\n permissions: Permission[] | null;\n model?: string;\n}\n\n/**\n * @internal This component is not meant to be used outside of the Content Manager plugin.\n * It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.\n * If you do use the hook outside of the context, we default to `false` for all actions.\n *\n * It then creates an list of `can{Action}` that are passed to the context for consumption\n * within the app to enforce RBAC.\n */\nconst DocumentRBAC = ({ children, permissions, model }: DocumentRBACProps) => {\n const { slug } = useParams<{ slug: string }>();\n\n if (!slug && !model) {\n throw new Error('Cannot find the slug param in the URL or the model prop is not provided.');\n }\n\n const contentTypeUid = model ?? slug;\n\n const [{ rawQuery }] = useQueryParams<{ plugins?: { i18n?: { locale?: string } } }>();\n\n const userPermissions = useAuth('DocumentRBAC', (state) => state.permissions);\n\n const contentTypePermissions = React.useMemo(() => {\n const contentTypePermissions = userPermissions.filter(\n (permission) => permission.subject === contentTypeUid\n );\n return contentTypePermissions.reduce<Record<string, Permission[]>>((acc, permission) => {\n const [action] = permission.action.split('.').slice(-1);\n return { ...acc, [action]: [permission] };\n }, {});\n }, [contentTypeUid, userPermissions]);\n\n const { isLoading, allowedActions } = useRBAC(\n contentTypePermissions,\n permissions ?? undefined,\n // TODO: useRBAC context should be typed and built differently\n // We are passing raw query as context to the hook so that it can\n // rely on the locale provided from DocumentRBAC for its permission calculations.\n rawQuery\n );\n\n const canCreateFields =\n !isLoading && allowedActions.canCreate\n ? extractAndDedupeFields(contentTypePermissions.create)\n : [];\n\n const canReadFields =\n !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];\n\n const canUpdateFields =\n !isLoading && allowedActions.canUpdate\n ? extractAndDedupeFields(contentTypePermissions.update)\n : [];\n\n /**\n * @description Checks if the user can perform an action on a field based on the field names\n * provided as the second argument.\n */\n const canUserAction: DocumentRBACContextValue['canUserAction'] = React.useCallback(\n (fieldName, fieldsUserCanAction, fieldType) => {\n const name = removeNumericalStrings(fieldName.split('.'));\n\n const componentFieldNames = fieldsUserCanAction\n // filter out fields that aren't components (components are dot separated)\n .filter((field) => field.split('.').length > 1);\n\n if (fieldType === 'component') {\n // check if the field name is within any of those arrays\n return componentFieldNames.some((field) => {\n return field.includes(name.join('.'));\n });\n }\n\n /**\n * The field is within a component.\n */\n if (name.length > 1) {\n return componentFieldNames.includes(name.join('.'));\n }\n\n /**\n * just a regular field\n */\n return fieldsUserCanAction.includes(fieldName);\n },\n []\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n return (\n <DocumentRBACProvider\n isLoading={isLoading}\n canCreateFields={canCreateFields}\n canReadFields={canReadFields}\n canUpdateFields={canUpdateFields}\n canUserAction={canUserAction}\n {...allowedActions}\n >\n {children}\n </DocumentRBACProvider>\n );\n};\n\n/**\n * @internal it's really small, but it's used three times in a row and DRY for something this straight forward.\n */\nconst extractAndDedupeFields = (permissions: Permission[] = []) =>\n permissions\n .flatMap((permission) => permission.properties?.fields)\n .filter(\n (field, index, arr): field is string =>\n arr.indexOf(field) === index && typeof field === 'string'\n );\n\n/**\n * @internal removes numerical strings from arrays.\n * @example\n * ```ts\n * const name = 'a.0.b';\n * const res = removeNumericalStrings(name.split('.'));\n * console.log(res); // ['a', 'b']\n * ```\n */\nconst removeNumericalStrings = (arr: string[]) => arr.filter((item) => isNaN(Number(item)));\n\nexport { DocumentRBAC, useDocumentRBAC, DocumentRBACContextValue, DocumentRBACProps };\n"],"names":["DocumentRBACProvider","useDocumentRBAC","createContext","canCreate","canCreateFields","canDelete","canPublish","canRead","canReadFields","canUpdate","canUpdateFields","canUserAction","isLoading","DocumentRBAC","children","permissions","model","slug","useParams","Error","contentTypeUid","rawQuery","useQueryParams","userPermissions","useAuth","state","contentTypePermissions","React","useMemo","filter","permission","subject","reduce","acc","action","split","slice","allowedActions","useRBAC","undefined","extractAndDedupeFields","create","read","update","useCallback","fieldName","fieldsUserCanAction","fieldType","name","removeNumericalStrings","componentFieldNames","field","length","some","includes","join","_jsx","Page","Loading","flatMap","properties","fields","index","arr","indexOf","item","isNaN","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,CAACA,oBAAAA,EAAsBC,eAAgB,CAAA,GAAGC,0BAC9C,cACA,EAAA;IACEC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;IACnBC,SAAW,EAAA,KAAA;IACXC,UAAY,EAAA,KAAA;IACZC,OAAS,EAAA,KAAA;AACTC,IAAAA,aAAAA,EAAe,EAAE;IACjBC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,aAAAA,EAAe,IAAM,KAAA;IACrBC,SAAW,EAAA;AACb,CAAA;AASF;;;;;;;IAQA,MAAMC,eAAe,CAAC,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAqB,GAAA;IACvE,MAAM,EAAEC,IAAI,EAAE,GAAGC,wBAAAA,EAAAA;IAEjB,IAAI,CAACD,IAAQ,IAAA,CAACD,KAAO,EAAA;AACnB,QAAA,MAAM,IAAIG,KAAM,CAAA,0EAAA,CAAA;AAClB;AAEA,IAAA,MAAMC,iBAAiBJ,KAASC,IAAAA,IAAAA;AAEhC,IAAA,MAAM,CAAC,EAAEI,QAAQ,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;AAEvB,IAAA,MAAMC,kBAAkBC,mBAAQ,CAAA,cAAA,EAAgB,CAACC,KAAAA,GAAUA,MAAMV,WAAW,CAAA;IAE5E,MAAMW,sBAAAA,GAAyBC,gBAAMC,CAAAA,OAAO,CAAC,IAAA;QAC3C,MAAMF,sBAAAA,GAAyBH,gBAAgBM,MAAM,CACnD,CAACC,UAAeA,GAAAA,UAAAA,CAAWC,OAAO,KAAKX,cAAAA,CAAAA;AAEzC,QAAA,OA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A;AAGzD;;;;;;;;IASA,MAAMF,sBAAyB,GAAA,CAACc,GAAkBA,GAAAA,GAAAA,CAAIlC,MAAM,CAAC,CAACoC,IAASC,GAAAA,KAAAA,CAAMC,MAAOF,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA;;;;;"}
@@ -17,20 +17,21 @@ const [DocumentRBACProvider, useDocumentRBAC] = createContext('DocumentRBAC', {
17
17
  });
18
18
  /**
19
19
  * @internal This component is not meant to be used outside of the Content Manager plugin.
20
- * It depends on knowing the slug/model of the content-type using the params of the URL.
20
+ * It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.
21
21
  * If you do use the hook outside of the context, we default to `false` for all actions.
22
22
  *
23
23
  * It then creates an list of `can{Action}` that are passed to the context for consumption
24
24
  * within the app to enforce RBAC.
25
- */ const DocumentRBAC = ({ children, permissions })=>{
25
+ */ const DocumentRBAC = ({ children, permissions, model })=>{
26
26
  const { slug } = useParams();
27
- if (!slug) {
28
- throw new Error('Cannot find the slug param in the URL');
27
+ if (!slug && !model) {
28
+ throw new Error('Cannot find the slug param in the URL or the model prop is not provided.');
29
29
  }
30
+ const contentTypeUid = model ?? slug;
30
31
  const [{ rawQuery }] = useQueryParams();
31
32
  const userPermissions = useAuth('DocumentRBAC', (state)=>state.permissions);
32
33
  const contentTypePermissions = React.useMemo(()=>{
33
- const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === slug);
34
+ const contentTypePermissions = userPermissions.filter((permission)=>permission.subject === contentTypeUid);
34
35
  return contentTypePermissions.reduce((acc, permission)=>{
35
36
  const [action] = permission.action.split('.').slice(-1);
36
37
  return {
@@ -41,7 +42,7 @@ const [DocumentRBACProvider, useDocumentRBAC] = createContext('DocumentRBAC', {
41
42
  };
42
43
  }, {});
43
44
  }, [
44
- slug,
45
+ contentTypeUid,
45
46
  userPermissions
46
47
  ]);
47
48
  const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? undefined, // TODO: useRBAC context should be typed and built differently
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentRBAC.mjs","sources":["../../../admin/src/features/DocumentRBAC.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useRBAC,\n useAuth,\n type Permission,\n createContext,\n Page,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport type { Schema } from '@strapi/types';\n\n/**\n * The boolean values indicate the global actions a user can perform on the document.\n * The `string[]` values tell us specifically which fields the actions can be performed on,\n * for example, if the `canReadFields` array is empty, than no fields can be read by the user.\n * This can happen even if the user can read the document.\n */\ninterface DocumentRBACContextValue {\n canCreate?: boolean;\n canCreateFields: string[];\n canDelete?: boolean;\n canPublish?: boolean;\n canRead?: boolean;\n canReadFields: string[];\n canUpdate?: boolean;\n canUpdateFields: string[];\n canUserAction: (\n fieldName: string,\n fieldsUserCanAction: string[],\n fieldType: Schema.Attribute.Kind\n ) => boolean;\n isLoading: boolean;\n}\n\nconst [DocumentRBACProvider, useDocumentRBAC] = createContext<DocumentRBACContextValue>(\n 'DocumentRBAC',\n {\n canCreate: false,\n canCreateFields: [],\n canDelete: false,\n canPublish: false,\n canRead: false,\n canReadFields: [],\n canUpdate: false,\n canUpdateFields: [],\n canUserAction: () => false,\n isLoading: false,\n }\n);\n\ninterface DocumentRBACProps {\n children: React.ReactNode;\n permissions: Permission[] | null;\n}\n\n/**\n * @internal This component is not meant to be used outside of the Content Manager plugin.\n * It depends on knowing the slug/model of the content-type using the params of the URL.\n * If you do use the hook outside of the context, we default to `false` for all actions.\n *\n * It then creates an list of `can{Action}` that are passed to the context for consumption\n * within the app to enforce RBAC.\n */\nconst DocumentRBAC = ({ children, permissions }: DocumentRBACProps) => {\n const { slug } = useParams<{ slug: string }>();\n\n if (!slug) {\n throw new Error('Cannot find the slug param in the URL');\n }\n const [{ rawQuery }] = useQueryParams<{ plugins?: { i18n?: { locale?: string } } }>();\n\n const userPermissions = useAuth('DocumentRBAC', (state) => state.permissions);\n\n const contentTypePermissions = React.useMemo(() => {\n const contentTypePermissions = userPermissions.filter(\n (permission) => permission.subject === slug\n );\n return contentTypePermissions.reduce<Record<string, Permission[]>>((acc, permission) => {\n const [action] = permission.action.split('.').slice(-1);\n return { ...acc, [action]: [permission] };\n }, {});\n }, [slug, userPermissions]);\n\n const { isLoading, allowedActions } = useRBAC(\n contentTypePermissions,\n permissions ?? undefined,\n // TODO: useRBAC context should be typed and built differently\n // We are passing raw query as context to the hook so that it can\n // rely on the locale provided from DocumentRBAC for its permission calculations.\n rawQuery\n );\n\n const canCreateFields =\n !isLoading && allowedActions.canCreate\n ? extractAndDedupeFields(contentTypePermissions.create)\n : [];\n\n const canReadFields =\n !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];\n\n const canUpdateFields =\n !isLoading && allowedActions.canUpdate\n ? extractAndDedupeFields(contentTypePermissions.update)\n : [];\n\n /**\n * @description Checks if the user can perform an action on a field based on the field names\n * provided as the second argument.\n */\n const canUserAction: DocumentRBACContextValue['canUserAction'] = React.useCallback(\n (fieldName, fieldsUserCanAction, fieldType) => {\n const name = removeNumericalStrings(fieldName.split('.'));\n\n const componentFieldNames = fieldsUserCanAction\n // filter out fields that aren't components (components are dot separated)\n .filter((field) => field.split('.').length > 1);\n\n if (fieldType === 'component') {\n // check if the field name is within any of those arrays\n return componentFieldNames.some((field) => {\n return field.includes(name.join('.'));\n });\n }\n\n /**\n * The field is within a component.\n */\n if (name.length > 1) {\n return componentFieldNames.includes(name.join('.'));\n }\n\n /**\n * just a regular field\n */\n return fieldsUserCanAction.includes(fieldName);\n },\n []\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n return (\n <DocumentRBACProvider\n isLoading={isLoading}\n canCreateFields={canCreateFields}\n canReadFields={canReadFields}\n canUpdateFields={canUpdateFields}\n canUserAction={canUserAction}\n {...allowedActions}\n >\n {children}\n </DocumentRBACProvider>\n );\n};\n\n/**\n * @internal it's really small, but it's used three times in a row and DRY for something this straight forward.\n */\nconst extractAndDedupeFields = (permissions: Permission[] = []) =>\n permissions\n .flatMap((permission) => permission.properties?.fields)\n .filter(\n (field, index, arr): field is string =>\n arr.indexOf(field) === index && typeof field === 'string'\n );\n\n/**\n * @internal removes numerical strings from arrays.\n * @example\n * ```ts\n * const name = 'a.0.b';\n * const res = removeNumericalStrings(name.split('.'));\n * console.log(res); // ['a', 'b']\n * ```\n */\nconst removeNumericalStrings = (arr: string[]) => arr.filter((item) => isNaN(Number(item)));\n\nexport { DocumentRBAC, useDocumentRBAC, DocumentRBACContextValue, DocumentRBACProps };\n"],"names":["DocumentRBACProvider","useDocumentRBAC","createContext","canCreate","canCreateFields","canDelete","canPublish","canRead","canReadFields","canUpdate","canUpdateFields","canUserAction","isLoading","DocumentRBAC","children","permissions","slug","useParams","Error","rawQuery","useQueryParams","userPermissions","useAuth","state","contentTypePermissions","React","useMemo","filter","permission","subject","reduce","acc","action","split","slice","allowedActions","useRBAC","undefined","extractAndDedupeFields","create","read","update","useCallback","fieldName","fieldsUserCanAction","fieldType","name","removeNumericalStrings","componentFieldNames","field","length","some","includes","join","_jsx","Page","Loading","flatMap","properties","fields","index","arr","indexOf","item","isNaN","Number"],"mappings":";;;;;AAqCA,MAAM,CAACA,oBAAAA,EAAsBC,eAAgB,CAAA,GAAGC,cAC9C,cACA,EAAA;IACEC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;IACnBC,SAAW,EAAA,KAAA;IACXC,UAAY,EAAA,KAAA;IACZC,OAAS,EAAA,KAAA;AACTC,IAAAA,aAAAA,EAAe,EAAE;IACjBC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,aAAAA,EAAe,IAAM,KAAA;IACrBC,SAAW,EAAA;AACb,CAAA;AAQF;;;;;;;AAOC,UACKC,YAAe,GAAA,CAAC,EAAEC,QAAQ,EAAEC,WAAW,EAAqB,GAAA;IAChE,MAAM,EAAEC,IAAI,EAAE,GAAGC,SAAAA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EAAAA,aAAAA;QACfE,eAAiBA,EAAAA,eAAAA;QACjBC,aAAeA,EAAAA,aAAAA;AACd,QAAA,GAAGwB,cAAc;AAEjBrB,QAAAA,QAAAA,EAAAA;;AAGP;AAEA;;IAGA,MAAMwB,sBAAyB,GAAA,CAACvB,WAA4B,GAAA,EAAE,GAC5DA,WAAAA,CACG0C,OAAO,CAAC,CAAC7B,UAAAA,GAAeA,UAAW8B,CAAAA,UAAU,EAAEC,MAAAA,CAAAA,CAC/ChC,MAAM,CACL,CAACsB,KAAAA,EAAOW,KAAOC,EAAAA,GAAAA,GACbA,GAAIC,CAAAA,OAAO,CAACb,KAAAA,CAAAA,KAAWW,KAAS,IAAA,OAAOX,KAAU,KAAA,QAAA,CAAA;AAGzD;;;;;;;;IASA,MAAMF,sBAAyB,GAAA,CAACc,GAAkBA,GAAAA,GAAAA,CAAIlC,MAAM,CAAC,CAACoC,IAASC,GAAAA,KAAAA,CAAMC,MAAOF,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA;;;;"}
1
+ {"version":3,"file":"DocumentRBAC.mjs","sources":["../../../admin/src/features/DocumentRBAC.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useRBAC,\n useAuth,\n type Permission,\n createContext,\n Page,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport type { Schema } from '@strapi/types';\n\n/**\n * The boolean values indicate the global actions a user can perform on the document.\n * The `string[]` values tell us specifically which fields the actions can be performed on,\n * for example, if the `canReadFields` array is empty, than no fields can be read by the user.\n * This can happen even if the user can read the document.\n */\ninterface DocumentRBACContextValue {\n canCreate?: boolean;\n canCreateFields: string[];\n canDelete?: boolean;\n canPublish?: boolean;\n canRead?: boolean;\n canReadFields: string[];\n canUpdate?: boolean;\n canUpdateFields: string[];\n canUserAction: (\n fieldName: string,\n fieldsUserCanAction: string[],\n fieldType: Schema.Attribute.Kind\n ) => boolean;\n isLoading: boolean;\n}\n\nconst [DocumentRBACProvider, useDocumentRBAC] = createContext<DocumentRBACContextValue>(\n 'DocumentRBAC',\n {\n canCreate: false,\n canCreateFields: [],\n canDelete: false,\n canPublish: false,\n canRead: false,\n canReadFields: [],\n canUpdate: false,\n canUpdateFields: [],\n canUserAction: () => false,\n isLoading: false,\n }\n);\n\ninterface DocumentRBACProps {\n children: React.ReactNode;\n permissions: Permission[] | null;\n model?: string;\n}\n\n/**\n * @internal This component is not meant to be used outside of the Content Manager plugin.\n * It depends on knowing the slug/model of the content-type using the params of the URL or the model if it is passed as arg.\n * If you do use the hook outside of the context, we default to `false` for all actions.\n *\n * It then creates an list of `can{Action}` that are passed to the context for consumption\n * within the app to enforce RBAC.\n */\nconst DocumentRBAC = ({ children, permissions, model }: DocumentRBACProps) => {\n const { slug } = useParams<{ slug: string }>();\n\n if (!slug && !model) {\n throw new Error('Cannot find the slug param in the URL or the model prop is not provided.');\n }\n\n const contentTypeUid = model ?? slug;\n\n const [{ rawQuery }] = useQueryParams<{ plugins?: { i18n?: { locale?: string } } }>();\n\n const userPermissions = useAuth('DocumentRBAC', (state) => state.permissions);\n\n const contentTypePermissions = React.useMemo(() => {\n const contentTypePermissions = userPermissions.filter(\n (permission) => permission.subject === contentTypeUid\n );\n return contentTypePermissions.reduce<Record<string, Permission[]>>((acc, permission) => {\n const [action] = permission.action.split('.').slice(-1);\n return { ...acc, [action]: [permission] };\n }, {});\n }, [contentTypeUid, userPermissions]);\n\n const { isLoading, allowedActions } = useRBAC(\n contentTypePermissions,\n permissions ?? undefined,\n // TODO: useRBAC context should be typed and built differently\n // We are passing raw query as context to the hook so that it can\n // rely on the locale provided from DocumentRBAC for its permission calculations.\n rawQuery\n );\n\n const canCreateFields =\n !isLoading && allowedActions.canCreate\n ? extractAndDedupeFields(contentTypePermissions.create)\n : [];\n\n const canReadFields =\n !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];\n\n const canUpdateFields =\n !isLoading && allowedActions.canUpdate\n ? extractAndDedupeFields(contentTypePermissions.update)\n : [];\n\n /**\n * @description Checks if the user can perform an action on a field based on the field names\n * provided as the second argument.\n */\n const canUserAction: DocumentRBACContextValue['canUserAction'] = React.useCallback(\n (fieldName, fieldsUserCanAction, fieldType) => {\n const name = removeNumericalStrings(fieldName.split('.'));\n\n const componentFieldNames = fieldsUserCanAction\n // filter out fields that aren't components (components are dot separated)\n .filter((field) => field.split('.').length > 1);\n\n if (fieldType === 'component') {\n // check if the field name is within any of those arrays\n return componentFieldNames.some((field) => {\n return field.includes(name.join('.'));\n });\n }\n\n /**\n * The field is within a component.\n */\n if (name.length > 1) {\n return componentFieldNames.includes(name.join('.'));\n }\n\n /**\n * just a regular field\n */\n return fieldsUserCanAction.includes(fieldName);\n },\n []\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n return (\n <DocumentRBACProvider\n isLoading={isLoading}\n canCreateFields={canCreateFields}\n canReadFields={canReadFields}\n canUpdateFields={canUpdateFields}\n canUserAction={canUserAction}\n {...allowedActions}\n >\n {children}\n </DocumentRBACProvider>\n );\n};\n\n/**\n * @internal it's really small, but it's used three times in a row and DRY for something this straight forward.\n */\nconst extractAndDedupeFields = (permissions: Permission[] = []) =>\n permissions\n .flatMap((permission) => permission.properties?.fields)\n .filter(\n (field, index, arr): field is string =>\n arr.indexOf(field) === index && typeof field === 'string'\n );\n\n/**\n * @internal removes numerical strings from arrays.\n * @example\n * ```ts\n * const name = 'a.0.b';\n * const res = removeNumericalStrings(name.split('.'));\n * console.log(res); // ['a', 'b']\n * ```\n */\nconst removeNumericalStrings = (arr: string[]) => arr.filter((item) => isNaN(Number(item)));\n\nexport { DocumentRBAC, useDocumentRBAC, DocumentRBACContextValue, DocumentRBACProps };\n"],"names":["DocumentRBACProvider","useDocumentRBAC","createContext","canCreate","canCreateFields","canDelete","canPublish","canRead","canReadFields","canUpdate","canUpdateFields","canUserAction","isLoading","DocumentRBAC","children","permissions","model","slug","useParams","Error","contentTypeUid","rawQuery","useQueryParams","userPermissions","useAuth","state","contentTypePermissions","React","useMemo","filter","permission","subject","reduce","acc","action","split","slice","allowedActions","useRBAC","undefined","extractAndDedupeFields","create","read","update","useCallback","fieldName","fieldsUserCanAction","fieldType","name","removeNumericalStrings","componentFieldNames","field","length","some","includes","join","_jsx","Page","Loading","flatMap","properties","fields","index","arr","indexOf","item","isNaN","Number"],"mappings":";;;;;AAqCA,MAAM,CAACA,oBAAAA,EAAsBC,eAAgB,CAAA,GAAGC,cAC9C,cACA,EAAA;IACEC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;IACnBC,SAAW,EAAA,KAAA;IACXC,UAAY,EAAA,KAAA;IACZC,OAAS,EAAA,KAAA;AACTC,IAAAA,aAAAA,EAAe,EAAE;IACjBC,SAAW,EAAA,KAAA;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,aAAAA,EAAe,IAAM,KAAA;IACrBC,SAAW,EAAA;AACb,CAAA;AASF;;;;;;;IAQA,MAAMC,eAAe,CAAC,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAqB,GAAA;IACvE,MAAM,EAAEC,IAAI,EAAE,GAAGC,SAAAA,EAAAA;IAEjB,IAAI,CAACD,IAAQ,IAAA,CAACD,KAAO,EAAA;AACnB,QAAA,MAAM,IAAIG,KAAM,CAAA,0EAAA,CAAA;AAClB;AAEA,IAAA,MAAMC,iBAAiBJ,KAASC,IAAAA,IAAAA;AAEhC,IAAA,MAAM,CAAC,EAAEI,QAAQ,EAAE,CAAC,GAAGC,cAAAA,EAAAA;AAEvB,IAAA,MAAMC,kBAAkBC,OAAQ,CAAA,cAAA,EAAgB,CAACC,KAAAA,GAAUA,MAAMV,WAAW,CAAA;IAE5E,MAAMW,sBAAAA,GAAyBC,KAAMC,CAAAA,OAAO,CAAC,IAAA;QAC3C,MAAMF,sBAAAA,GAAyBH,gBAAgBM,MAAM,CACnD,CAACC,UAAeA,GAAAA,UAAAA,CAAWC,OAAO,KAAKX,cAA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,KAAU,KAAA,QAAA,CAAA;AAGzD;;;;;;;;IASA,MAAMF,sBAAyB,GAAA,CAACc,GAAkBA,GAAAA,GAAAA,CAAIlC,MAAM,CAAC,CAACoC,IAASC,GAAAA,KAAAA,CAAMC,MAAOF,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VersionInputRenderer.js","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { HistoryVersionDataResponse } from '../../../../shared/contracts/history-versions';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\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 CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n if (\n !formattedFieldValue ||\n (formattedFieldValue.results.length === 0 && formattedFieldValue.meta.missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n {/* @ts-expect-error – we dont need closeLabel */}\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue;\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n /* @ts-expect-error – we dont need closeLabel */\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n const { layout } = componentsLayout[props.attribute.component];\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas: configuration.components[props.attribute.component].metadatas,\n fieldSizes,\n schemaAttributes: components[props.attribute.component].attributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","components","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","componentsLayout","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","layout","component","remainingFieldsLayout","getRemaingFieldsLayout","metadatas","schemaAttributes","attributes","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAMA,WAAcC,GAAAA,uBAAAA,CAAOC,kBAAOC,CAAAA,CAAAA,KAAK,CAAC;IAAEC,UAAY,EAAA,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAO,EAAA;IAAGC,MAAQ,EAAA;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,uBAAOO,CAAAA,iBAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAMC,KAAAA,GAAQC,oBAEZJ,CAAAA,KAAAA,CAAMK,IAAI,CAAA;AAEZ;;;AAGC,MACD,IAAIC,mBAAAA;AACJ,IAAA,IAAIH,KAAO,EAAA;AACTG,QAAAA,mBAAAA,GAAsBC,KAAMC,CAAAA,OAAO,CAACL,KAAAA,CAAMM,KAAK,CAC3C,GAAA;AAAEC,YAAAA,OAAAA,EAASP,MAAMM,KAAK;YAAEE,IAAM,EAAA;gBAAEC,YAAc,EAAA;AAAE;AAAE,SAAA,GAClDT,MAAMM,KAAK;AACjB;AAEA,IAAA,IACE,CAACH,mBAAAA,IACAA,mBAAoBI,CAAAA,OAAO,CAACG,MAAM,KAAK,CAAA,IAAKP,mBAAoBK,CAAAA,IAAI,CAACC,YAAY,KAAK,CACvF,EAAA;QACA,qBACEE,eAAA,CAAAC,mB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hB,QAAA;;YAEE,MAAM,EAAEyB,QAAQC,OAAO,EAAE/G,WAAWgH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGxJ,KAAAA;AACjE,YAAA,qBACEgB,cAACoH,CAAAA,yBAAAA,EAAAA;AACE,gBAAA,GAAGoB,SAAS;gBACblE,IAAMA,EAAAA,IAAAA;gBACNlE,WAAaqE,EAAAA,iBAAAA;;AAEbuB,gBAAAA,IAAAA,EAAMhH,KAAMqH,CAAAA,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAUgD,EAAAA;;AAGlB;AACF;AAEA,MAAMR,+BAAAA,GAAkC,CACtClF,SAEA,GAAA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAUmF,WAAW,KAAK,QAAA;;;;"}
1
+ {"version":3,"file":"VersionInputRenderer.js","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { HistoryVersionDataResponse } from '../../../../shared/contracts/history-versions';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\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 CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n if (\n !formattedFieldValue ||\n (formattedFieldValue.results.length === 0 && formattedFieldValue.meta.missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n {/* @ts-expect-error – we dont need closeLabel */}\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue;\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n /* @ts-expect-error – we dont need closeLabel */\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n const { layout } = componentsLayout[props.attribute.component];\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas: configuration.components[props.attribute.component].metadatas,\n fieldSizes,\n schemaAttributes: components[props.attribute.component].attributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","components","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","componentsLayout","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","layout","component","remainingFieldsLayout","getRemaingFieldsLayout","metadatas","schemaAttributes","attributes","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAMA,WAAcC,GAAAA,uBAAAA,CAAOC,kBAAOC,CAAAA,CAAAA,KAAK,CAAC;IAAEC,UAAY,EAAA,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAO,EAAA;IAAGC,MAAQ,EAAA;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,uBAAOO,CAAAA,iBAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAMC,KAAAA,GAAQC,oBAEZJ,CAAAA,KAAAA,CAAMK,IAAI,CAAA;AAEZ;;;AAGC,MACD,IAAIC,mBAAAA;AACJ,IAAA,IAAIH,KAAO,EAAA;AACTG,QAAAA,mBAAAA,GAAsBC,KAAMC,CAAAA,OAAO,CAACL,KAAAA,CAAMM,KAAK,CAC3C,GAAA;AAAEC,YAAA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NlE,WAAaqE,EAAAA,iBAAAA;gBACb0D,OAASnJ,EAAAA,KAAAA,CAAMkC,SAAS,CAACkH,IAAI,CAACrH,GAAG,CAAC,CAACtB,KAAAA,IAAW;AAAEA,wBAAAA;qBAAM,CAAA,CAAA;;AAEtDuG,gBAAAA,IAAAA,EAAMhH,KAAMqH,CAAAA,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAUgD,EAAAA;;AAGhB,QAAA;;YAEE,MAAM,EAAEyB,QAAQC,OAAO,EAAE/G,WAAWgH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGxJ,KAAAA;AACjE,YAAA,qBACEgB,cAACoH,CAAAA,yBAAAA,EAAAA;AACE,gBAAA,GAAGoB,SAAS;gBACblE,IAAMA,EAAAA,IAAAA;gBACNlE,WAAaqE,EAAAA,iBAAAA;;AAEbuB,gBAAAA,IAAAA,EAAMhH,KAAMqH,CAAAA,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAUgD,EAAAA;;AAGlB;AACF;AAEA,MAAMR,+BAAAA,GAAkC,CACtClF,SAEA,GAAA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAUmF,WAAW,KAAK,QAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { HistoryVersionDataResponse } from '../../../../shared/contracts/history-versions';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\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 CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n if (\n !formattedFieldValue ||\n (formattedFieldValue.results.length === 0 && formattedFieldValue.meta.missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n {/* @ts-expect-error – we dont need closeLabel */}\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue;\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n /* @ts-expect-error – we dont need closeLabel */\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n const { layout } = componentsLayout[props.attribute.component];\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas: configuration.components[props.attribute.component].metadatas,\n fieldSizes,\n schemaAttributes: components[props.attribute.component].attributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","components","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","componentsLayout","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","layout","component","remainingFieldsLayout","getRemaingFieldsLayout","metadatas","schemaAttributes","attributes","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAMA,WAAcC,GAAAA,MAAAA,CAAOC,KAAOC,CAAAA,CAAAA,KAAK,CAAC;IAAEC,UAAY,EAAA,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAO,EAAA;IAAGC,MAAQ,EAAA;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,MAAOO,CAAAA,IAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE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EAAMhH,MAAMgH,IAAI;gBAChB5F,WAAaqE,EAAAA,iBAAAA;gBACbb,QAAUgD,EAAAA;;AAGhB;;AAEC,QACD,KAAK,aAAA;AACH,YAAA,qBACE5G,GAACoH,CAAAA,aAAAA,EAAAA;AACE,gBAAA,GAAGpI,KAAK;gBACTsF,IAAMA,EAAAA,IAAAA;gBACNlE,WAAaqE,EAAAA,iBAAAA;gBACb0D,OAASnJ,EAAAA,KAAAA,CAAMkC,SAAS,CAACkH,IAAI,CAACrH,GAAG,CAAC,CAACtB,KAAAA,IAAW;AAAEA,wBAAAA;qBAAM,CAAA,CAAA;;AAEtDuG,gBAAAA,IAAAA,EAAMhH,KAAMqH,CAAAA,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAUgD,EAAAA;;AAGhB,QAAA;;YAEE,MAAM,EAAEyB,QAAQC,OAAO,EAAE/G,WAAWgH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGxJ,KAAAA;AACjE,YAAA,qBACEgB,GAACoH,CAAAA,aAAAA,EAAAA;AACE,gBAAA,GAAGoB,SAAS;gBACblE,IAAMA,EAAAA,IAAAA;gBACNlE,WAAaqE,EAAAA,iBAAAA;;AAEbuB,gBAAAA,IAAAA,EAAMhH,KAAMqH,CAAAA,WAAW,GAAG,cAAA,GAAiBrH,MAAMgH,IAAI;gBACrDpC,QAAUgD,EAAAA;;AAGlB;AACF;AAEA,MAAMR,+BAAAA,GAAkC,CACtClF,SAEA,GAAA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAUmF,WAAW,KAAK,QAAA;;;;"}
1
+ {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { HistoryVersionDataResponse } from '../../../../shared/contracts/history-versions';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\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 CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n if (\n !formattedFieldValue ||\n (formattedFieldValue.results.length === 0 && formattedFieldValue.meta.missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n {/* @ts-expect-error – we dont need closeLabel */}\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue;\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n /* @ts-expect-error – we dont need closeLabel */\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: any) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, any> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n node[key] = node[key] || {};\n }\n\n // Traverse down the tree\n node = node[key];\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n const { layout } = componentsLayout[props.attribute.component];\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas: configuration.components[props.attribute.component].metadatas,\n fieldSizes,\n schemaAttributes: components[props.attribute.component].attributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","components","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","componentsLayout","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","layout","component","remainingFieldsLayout","getRemaingFieldsLayout","metadatas","schemaAttributes","attributes","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAMA,WAAcC,GAAAA,MAAAA,CAAOC,KAAOC,CAAAA,CAAAA,KAAK,CAAC;IAAEC,UAAY,EAAA,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAO,EAAA;IAAGC,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