@strapi/content-manager 5.57.0 → 5.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/admin/components/ConfigurationForm/Fields.js +4 -3
  2. package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
  3. package/dist/admin/components/ConfigurationForm/Fields.mjs +4 -3
  4. package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
  5. package/dist/admin/components/RelativeTime.js +2 -1
  6. package/dist/admin/components/RelativeTime.js.map +1 -1
  7. package/dist/admin/components/RelativeTime.mjs +2 -1
  8. package/dist/admin/components/RelativeTime.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/history/components/VersionContent.js +8 -8
  12. package/dist/admin/history/components/VersionContent.js.map +1 -1
  13. package/dist/admin/history/components/VersionContent.mjs +8 -8
  14. package/dist/admin/history/components/VersionContent.mjs.map +1 -1
  15. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  16. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  17. package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
  18. package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
  19. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  20. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
  22. package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +2 -2
  24. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +2 -2
  26. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +7 -6
  28. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +7 -6
  30. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +2 -1
  32. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +2 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.js +2 -1
  36. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.mjs +2 -1
  38. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +4 -3
  40. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +4 -3
  42. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  44. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +31 -11
  46. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +32 -12
  48. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/UID.js +2 -1
  50. package/dist/admin/pages/EditView/components/FormInputs/UID.js.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/UID.mjs +2 -1
  52. package/dist/admin/pages/EditView/components/FormInputs/UID.mjs.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
  54. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormLayout.js +4 -4
  56. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  57. package/dist/admin/pages/EditView/components/FormLayout.mjs +4 -4
  58. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  59. package/dist/admin/pages/EditView/components/Panels.js.map +1 -1
  60. package/dist/admin/pages/EditView/components/Panels.mjs.map +1 -1
  61. package/dist/admin/pages/EditView/utils/data.js +3 -3
  62. package/dist/admin/pages/EditView/utils/data.js.map +1 -1
  63. package/dist/admin/pages/EditView/utils/data.mjs +3 -3
  64. package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
  65. package/dist/admin/pages/ListConfiguration/components/Settings.js +3 -3
  66. package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
  67. package/dist/admin/pages/ListConfiguration/components/Settings.mjs +3 -3
  68. package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
  69. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js +2 -2
  70. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js.map +1 -1
  71. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs +2 -2
  72. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs.map +1 -1
  73. package/dist/admin/pages/ListView/ListViewPage.js +73 -13
  74. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  75. package/dist/admin/pages/ListView/ListViewPage.mjs +74 -14
  76. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  77. package/dist/admin/pages/ListView/components/AutoCloneFailureModal.js +1 -1
  78. package/dist/admin/pages/ListView/components/AutoCloneFailureModal.js.map +1 -1
  79. package/dist/admin/pages/ListView/components/AutoCloneFailureModal.mjs +1 -1
  80. package/dist/admin/pages/ListView/components/AutoCloneFailureModal.mjs.map +1 -1
  81. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js.map +1 -1
  82. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs.map +1 -1
  83. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js +4 -1
  84. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
  85. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs +4 -1
  86. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
  87. package/dist/admin/pages/ListView/components/Filters.js +12 -10
  88. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  89. package/dist/admin/pages/ListView/components/Filters.mjs +12 -10
  90. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  91. package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
  92. package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
  93. package/dist/admin/pages/ListView/components/ViewSettingsMenu.js +2 -1
  94. package/dist/admin/pages/ListView/components/ViewSettingsMenu.js.map +1 -1
  95. package/dist/admin/pages/ListView/components/ViewSettingsMenu.mjs +2 -1
  96. package/dist/admin/pages/ListView/components/ViewSettingsMenu.mjs.map +1 -1
  97. package/dist/admin/pages/ListView/utils/applyAttributeRenames.js +68 -0
  98. package/dist/admin/pages/ListView/utils/applyAttributeRenames.js.map +1 -0
  99. package/dist/admin/pages/ListView/utils/applyAttributeRenames.mjs +64 -0
  100. package/dist/admin/pages/ListView/utils/applyAttributeRenames.mjs.map +1 -0
  101. package/dist/admin/preview/components/PreviewHeader.js +3 -1
  102. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  103. package/dist/admin/preview/components/PreviewHeader.mjs +3 -1
  104. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  105. package/dist/admin/services/relations.js +5 -2
  106. package/dist/admin/services/relations.js.map +1 -1
  107. package/dist/admin/services/relations.mjs +5 -2
  108. package/dist/admin/services/relations.mjs.map +1 -1
  109. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +1 -1
  110. package/dist/admin/src/pages/ListView/utils/applyAttributeRenames.d.ts +12 -0
  111. package/dist/admin/translations/eu.json.js +3 -3
  112. package/dist/admin/translations/eu.json.mjs +3 -3
  113. package/dist/admin/translations/gu.json.js +4 -4
  114. package/dist/admin/translations/gu.json.mjs +4 -4
  115. package/dist/admin/translations/hi.json.js +9 -9
  116. package/dist/admin/translations/hi.json.mjs +9 -9
  117. package/dist/admin/translations/ml.json.js +6 -6
  118. package/dist/admin/translations/ml.json.mjs +6 -6
  119. package/dist/admin/translations/sa.json.js +10 -10
  120. package/dist/admin/translations/sa.json.mjs +10 -10
  121. package/dist/server/history/entitlements.js +26 -0
  122. package/dist/server/history/entitlements.js.map +1 -0
  123. package/dist/server/history/entitlements.mjs +24 -0
  124. package/dist/server/history/entitlements.mjs.map +1 -0
  125. package/dist/server/history/index.js +3 -0
  126. package/dist/server/history/index.js.map +1 -1
  127. package/dist/server/history/index.mjs +3 -0
  128. package/dist/server/history/index.mjs.map +1 -1
  129. package/dist/server/history/services/utils.js +19 -8
  130. package/dist/server/history/services/utils.js.map +1 -1
  131. package/dist/server/history/services/utils.mjs +18 -9
  132. package/dist/server/history/services/utils.mjs.map +1 -1
  133. package/dist/server/homepage/services/homepage.js.map +1 -1
  134. package/dist/server/homepage/services/homepage.mjs.map +1 -1
  135. package/dist/server/preview/services/preview-config.js.map +1 -1
  136. package/dist/server/preview/services/preview-config.mjs.map +1 -1
  137. package/dist/server/register.js +6 -0
  138. package/dist/server/register.js.map +1 -1
  139. package/dist/server/register.mjs +6 -0
  140. package/dist/server/register.mjs.map +1 -1
  141. package/dist/server/services/components.js.map +1 -1
  142. package/dist/server/services/components.mjs.map +1 -1
  143. package/dist/server/services/configuration/rename-fields.js +68 -0
  144. package/dist/server/services/configuration/rename-fields.js.map +1 -0
  145. package/dist/server/services/configuration/rename-fields.mjs +66 -0
  146. package/dist/server/services/configuration/rename-fields.mjs.map +1 -0
  147. package/dist/server/services/utils/configuration/attribute-renames.js +164 -0
  148. package/dist/server/services/utils/configuration/attribute-renames.js.map +1 -0
  149. package/dist/server/services/utils/configuration/attribute-renames.mjs +161 -0
  150. package/dist/server/services/utils/configuration/attribute-renames.mjs.map +1 -0
  151. package/dist/server/services/utils/configuration/attributes.js +12 -12
  152. package/dist/server/services/utils/configuration/attributes.js.map +1 -1
  153. package/dist/server/services/utils/configuration/attributes.mjs +12 -12
  154. package/dist/server/services/utils/configuration/attributes.mjs.map +1 -1
  155. package/dist/server/src/history/entitlements.d.ts +9 -0
  156. package/dist/server/src/history/entitlements.d.ts.map +1 -0
  157. package/dist/server/src/history/index.d.ts.map +1 -1
  158. package/dist/server/src/history/services/utils.d.ts +6 -0
  159. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  160. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
  161. package/dist/server/src/index.d.ts +2 -0
  162. package/dist/server/src/index.d.ts.map +1 -1
  163. package/dist/server/src/preview/services/index.d.ts.map +1 -1
  164. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
  165. package/dist/server/src/register.d.ts.map +1 -1
  166. package/dist/server/src/services/components.d.ts +2 -0
  167. package/dist/server/src/services/components.d.ts.map +1 -1
  168. package/dist/server/src/services/configuration/rename-fields.d.ts +15 -0
  169. package/dist/server/src/services/configuration/rename-fields.d.ts.map +1 -0
  170. package/dist/server/src/services/index.d.ts +2 -0
  171. package/dist/server/src/services/index.d.ts.map +1 -1
  172. package/dist/server/src/services/utils/configuration/attribute-renames.d.ts +57 -0
  173. package/dist/server/src/services/utils/configuration/attribute-renames.d.ts.map +1 -0
  174. package/dist/shared/contracts/content-types.d.ts +5 -0
  175. package/dist/shared/contracts/content-types.d.ts.map +1 -1
  176. package/dist/shared/contracts/relations.d.ts +1 -0
  177. package/dist/shared/contracts/relations.d.ts.map +1 -1
  178. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"Fields.mjs","sources":["../../../../admin/src/components/ConfigurationForm/Fields.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useDroppable, DndContext, UniqueIdentifier, DragOverlay } from '@dnd-kit/core';\nimport { arraySwap, SortableContext, useSortable, rectSwappingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { useField, useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Modal,\n Box,\n Flex,\n Grid,\n IconButton,\n IconButtonComponent,\n Typography,\n Link,\n Menu,\n} from '@strapi/design-system';\nimport { Cog, Cross, Drag, Pencil, Plus } from '@strapi/icons';\nimport { generateNKeysBetween as generateNKeysBetweenImpl } from 'fractional-indexing';\nimport { produce } from 'immer';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../../utils/translations';\nimport { ComponentIcon } from '../ComponentIcon';\n\nimport { EditFieldForm, EditFieldFormProps } from './EditFieldForm';\n\nimport type { ConfigurationFormData, EditFieldSpacerLayout } from './Form';\nimport type { EditLayout } from '../../hooks/useDocumentLayout';\n\ntype FormField = ConfigurationFormData['layout'][number]['children'][number];\ntype Field = Omit<ConfigurationFormData['layout'][number]['children'][number], '__temp_key__'>;\n\nconst GRID_COLUMNS = 12;\n\n/* -------------------------------------------------------------------------------------------------\n * Drag and Drop\n * -----------------------------------------------------------------------------------------------*/\n\nconst DroppableContainer = ({\n id,\n children,\n}: {\n id: string;\n children: (props: ReturnType<typeof useDroppable>) => React.ReactNode;\n}) => {\n const droppable = useDroppable({\n id,\n });\n\n return children(droppable);\n};\n\nexport const SortableItem = ({ id, children }: { id: string; children: React.ReactNode }) => {\n const { attributes, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n const style = {\n transform: CSS.Transform.toString({\n x: transform?.x ?? 0,\n y: transform?.y ?? 0,\n // Avoid any scaling animations which can visually \"squish\" or\n // \"stretch\" neighbouring cards in mixed-width grids (4/8/12 cols).\n scaleX: 1,\n scaleY: 1,\n }),\n transition,\n height: '100%',\n opacity: isDragging ? 0.6 : 1,\n outlineOffset: 2,\n };\n\n return (\n <div ref={setNodeRef} style={style} {...attributes}>\n {children}\n </div>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Fields\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldsProps extends Pick<EditLayout, 'metadatas'>, Pick<FieldProps, 'components'> {\n attributes: {\n [key: string]: FieldProps['attribute'];\n };\n fieldSizes: Record<string, number>;\n components: EditLayout['components'];\n}\n\n/**\n * Compute uids and formName for drag and drop items for the incoming layout\n */\nconst createDragAndDropContainersFromLayout = (layout: ConfigurationFormData['layout']) => {\n return layout.map((row, containerIndex) => ({\n ...row,\n // Use unique ids for drag and drop items\n dndId: `container-${containerIndex}`,\n children: row.children.map((child, childIndex) => ({\n ...child,\n dndId: `container-${containerIndex}-child-${childIndex}`,\n\n // The formName must be recomputed each time an item is moved\n formName: `layout.${containerIndex}.children.${childIndex}`,\n })),\n }));\n};\n\nconst Fields = ({ attributes, fieldSizes, components, metadatas = {} }: FieldsProps) => {\n const { formatMessage } = useIntl();\n\n const layout = useForm<ConfigurationFormData['layout']>(\n 'Fields',\n (state) => (state.values as ConfigurationFormData).layout ?? []\n );\n\n const onChange = useForm('Fields', (state) => state.onChange);\n const addFieldRow = useForm('Fields', (state) => state.addFieldRow);\n const removeFieldRow = useForm('Fields', (state) => state.removeFieldRow);\n\n const existingFields = layout.map((row) => row.children.map((field) => field.name)).flat();\n\n /**\n * Get the fields that are not already in the layout\n * But also check that they are visible before we give users\n * the option to display them. e.g. `id` is not visible.\n */\n const remainingFields = Object.entries(metadatas).reduce<Field[]>((acc, current) => {\n const [name, { visible, ...field }] = current;\n\n if (!existingFields.includes(name) && visible === true) {\n const type = attributes[name]?.type;\n const size = type ? fieldSizes[type] : GRID_COLUMNS;\n\n acc.push({\n ...field,\n label: field.label ?? name,\n name,\n size,\n });\n }\n\n return acc;\n }, []);\n\n const handleRemoveField =\n (rowIndex: number, fieldIndex: number): FieldProps['onRemoveField'] =>\n () => {\n if (layout[rowIndex].children.length === 1) {\n removeFieldRow(`layout`, rowIndex);\n } else {\n onChange(`layout.${rowIndex}.children`, [\n ...layout[rowIndex].children.slice(0, fieldIndex),\n ...layout[rowIndex].children.slice(fieldIndex + 1),\n ]);\n }\n };\n\n const handleAddField = (field: Field) => () => {\n addFieldRow('layout', { children: [field] });\n };\n\n const [containers, setContainers] = React.useState(() =>\n createDragAndDropContainersFromLayout(layout)\n );\n type Container = (typeof containers)[number];\n const [activeDragItem, setActiveDragItem] = React.useState<Container['children'][number] | null>(\n null\n );\n\n /**\n * Finds either the parent container id or the child id within a container\n */\n function findContainer(id: UniqueIdentifier, containersAsDictionary: Record<string, Container>) {\n // If the id is a key, then it is the parent container\n if (id in containersAsDictionary) {\n return id;\n }\n\n // Otherwise, it is a child inside a container\n return Object.keys(containersAsDictionary).find((key) =>\n containersAsDictionary[key].children.find((child) => child.dndId === id)\n );\n }\n\n /**\n * Gets an item from a container based on its id\n */\n const getItemFromContainer = (id: UniqueIdentifier, container: Container) => {\n return container.children.find((item) => id === item.dndId);\n };\n\n /**\n * Gets the containers as dictionary for quick lookup\n */\n const getContainersAsDictionary = () => {\n return Object.fromEntries(containers.map((container) => [container.dndId, container]));\n };\n\n /**\n * Recomputes the empty space in the grid\n */\n const createContainersWithSpacers = (layout: typeof containers) => {\n return layout\n .map((row) => ({\n ...row,\n children: row.children.filter((field) => field.name !== TEMP_FIELD_NAME),\n }))\n .filter((row) => row.children.length > 0)\n .map((row) => {\n const totalSpaceTaken = row.children.reduce((acc, curr) => acc + curr.size, 0);\n\n if (totalSpaceTaken < GRID_COLUMNS) {\n const [spacerKey] = generateNKeysBetweenImpl(\n row.children.at(-1)?.__temp_key__,\n undefined,\n 1\n );\n\n return {\n ...row,\n children: [\n ...row.children,\n {\n name: TEMP_FIELD_NAME,\n size: GRID_COLUMNS - totalSpaceTaken,\n __temp_key__: spacerKey,\n } satisfies EditFieldSpacerLayout,\n ],\n };\n }\n\n return row;\n });\n };\n\n /**\n * When layout changes (e.g. when a field size is changed or the containers are reordered)\n * we need to update the ids and form names\n */\n React.useEffect(() => {\n const containers = createDragAndDropContainersFromLayout(layout);\n setContainers(containers);\n }, [layout, setContainers]);\n\n return (\n <DndContext\n onDragStart={(event) => {\n const containersAsDictionary = getContainersAsDictionary();\n\n const activeContainer = findContainer(event.active.id, containersAsDictionary);\n\n if (!activeContainer) return;\n\n const activeItem = getItemFromContainer(\n event.active.id,\n containersAsDictionary[activeContainer]\n );\n\n if (activeItem) {\n setActiveDragItem(activeItem);\n }\n }}\n onDragOver={({ active, over }) => {\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(active.id, containersAsDictionary);\n const overContainer = findContainer(over?.id ?? '', containersAsDictionary);\n const activeContainerIndex = containers.findIndex(\n (container) => container.dndId === activeContainer\n );\n const overContainerIndex = containers.findIndex(\n (container) => container.dndId === overContainer\n );\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const draggedItem = getItemFromContainer(\n active.id,\n containersAsDictionary[activeContainer]\n );\n const overItem = getItemFromContainer(\n over?.id ?? '',\n containersAsDictionary[overContainer]\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (item) => item.dndId === over?.id\n );\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (item) => item.dndId === active.id\n );\n\n if (!draggedItem) return;\n\n // Handle a full width field being dragged\n if (draggedItem?.size === GRID_COLUMNS) {\n // Swap the items in the containers\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = containers[overContainerIndex].children;\n draft[overContainerIndex].children = containers[activeContainerIndex].children;\n });\n setContainers(update);\n return;\n }\n\n /**\n * Handle an item being dragged from one container to another,\n * the item is removed from its current container, and then added to its new container\n * An item can only be added in a container if there is enough space\n */\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = draft[activeContainerIndex].children.filter(\n (item) => item.dndId !== active.id\n );\n\n const targetChildren = draft[overContainerIndex].children;\n const spaceTaken = targetChildren.reduce((acc, curr) => {\n if (curr.name === TEMP_FIELD_NAME) {\n return acc;\n }\n\n return acc + curr.size;\n }, 0);\n const isNotEnoughSpace = spaceTaken + draggedItem.size > GRID_COLUMNS;\n const canSwapSameSizeItem =\n overItem &&\n overItem.name !== TEMP_FIELD_NAME &&\n overItem.size === draggedItem.size &&\n activeIndex !== -1 &&\n overIndex !== -1;\n const canCreateNewRowForItem =\n activeContainerIndex !== overContainerIndex &&\n GRID_COLUMNS - spaceTaken < draggedItem.size;\n const isHoveringOverSpacer = overItem?.name === TEMP_FIELD_NAME;\n\n /**\n * Not enough space in the hovered row\n *\n * We still want:\n * - ability to swap items of the same size\n * - ability to create a single extra row to host the dragged item\n * when surrounding rows are full\n */\n if (isNotEnoughSpace) {\n // Try a simple swap when target item is of the same size\n if (canSwapSameSizeItem) {\n const sourceChildren = draft[activeContainerIndex].children;\n\n // Put the hovered item back where the dragged item came from\n sourceChildren.splice(activeIndex, 0, overItem);\n\n // Swap the hovered item with the dragged one in the target row\n const draftOverIndex = targetChildren.findIndex(\n (item) => item.dndId === overItem.dndId\n );\n\n if (draftOverIndex !== -1) {\n targetChildren.splice(draftOverIndex, 1, draggedItem);\n }\n\n return;\n }\n\n // If there is absolutely no space left in the target row and the\n // dragged item comes from a different row, add it to a new row\n if (canCreateNewRowForItem) {\n // Default: insert a new row after the row being hovered (between that row and the\n // next). For row 0, use index 0 instead so fields that are not full-width can still\n // be moved above the first row—there is no separate drop area above it in the UI.\n const insertIndex = overContainerIndex === 0 ? 0 : overContainerIndex + 1;\n\n /**\n * When inserting *after* the hovered row, reuse the following row if it only\n * contains spacers. Skip when inserting at index 0 — draft[0] is the hovered row.\n */\n if (insertIndex > overContainerIndex) {\n const existingRow = draft[insertIndex];\n\n if (existingRow) {\n const nonTempChildren = existingRow.children.filter(\n (child) => child.name !== TEMP_FIELD_NAME\n );\n const isNextRowEmpty = nonTempChildren.length === 0;\n\n // If the row directly after is empty (only spacers), reuse it\n // instead of creating yet another row.\n if (isNextRowEmpty) {\n existingRow.children = [draggedItem];\n return;\n }\n }\n }\n\n const newContainerPrototype = draft[overContainerIndex];\n\n // Using draft.length directly can collide with an existing container id\n // (e.g. after rows were removed), causing React key conflicts and flicker.\n const findFreeContainerId = (i: number): string =>\n containersAsDictionary[`container-${i}`]\n ? findFreeContainerId(i + 1)\n : `container-${i}`;\n const newContainerId = findFreeContainerId(draft.length);\n\n draft.splice(insertIndex, 0, {\n ...newContainerPrototype,\n dndId: newContainerId,\n children: [draggedItem],\n });\n\n return;\n }\n }\n\n // There is enough room in the target row\n if (isHoveringOverSpacer) {\n // We are over an invisible spacer, replace it with the dragged item\n targetChildren.splice(overIndex, 1, draggedItem);\n return;\n }\n\n // There is room for the item in the container, drop it\n targetChildren.splice(overIndex, 0, draggedItem);\n });\n\n setContainers(update.filter((container) => container.children.length > 0));\n }}\n onDragEnd={(event) => {\n const { active, over } = event;\n const { id } = active;\n const overId = over?.id;\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(id, containersAsDictionary);\n const overContainer = findContainer(overId!, containersAsDictionary);\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (children) => children.dndId === id\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (children) => children.dndId === overId\n );\n\n const movedContainerItems = produce(containersAsDictionary, (draft) => {\n if (\n activeIndex >= 0 &&\n overIndex >= 0 &&\n activeIndex !== overIndex &&\n activeContainer === overContainer\n ) {\n // Move items around inside their own container\n draft[activeContainer].children = arraySwap(\n draft[activeContainer].children,\n activeIndex,\n overIndex\n );\n }\n });\n\n // Remove properties the server does not expect before updating the form\n const updatedContainers = Object.values(movedContainerItems);\n const updatedContainersWithSpacers = createContainersWithSpacers(\n updatedContainers\n ) as typeof containers;\n const updatedLayout = updatedContainersWithSpacers.map(\n ({ dndId: _dndId, children, ...container }) => ({\n ...container,\n children: children.map(({ dndId: _dndId, formName: _formName, ...child }) => child),\n })\n );\n\n // Update the layout\n onChange('layout', updatedLayout);\n setActiveDragItem(null);\n }}\n >\n <Flex paddingTop={6} direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex alignItems=\"flex-start\" direction=\"column\" justifyContent=\"space-between\">\n <Typography fontWeight=\"bold\">\n {formatMessage({\n id: getTranslation('containers.list.displayedFields'),\n defaultMessage: 'Displayed fields',\n })}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: 'containers.SettingPage.editSettings.description',\n defaultMessage: 'Drag & drop the fields to build the layout',\n })}\n </Typography>\n </Flex>\n <Box padding={4} hasRadius borderStyle=\"dashed\" borderWidth=\"1px\" borderColor=\"neutral300\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {containers.map((container, containerIndex) => (\n <SortableContext\n key={container.dndId}\n id={container.dndId}\n items={container.children.map((child) => ({ id: child.dndId }))}\n strategy={rectSwappingStrategy}\n >\n <DroppableContainer id={container.dndId}>\n {({ setNodeRef }) => (\n <Grid.Root key={container.dndId} ref={setNodeRef} gap={2}>\n {container.children.map((child, childIndex) => (\n <Grid.Item\n col={child.size}\n xs={12}\n key={child.dndId}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <SortableItem id={child.dndId}>\n <Field\n attribute={attributes[child.name]}\n components={components}\n name={child.formName}\n onRemoveField={handleRemoveField(containerIndex, childIndex)}\n dndId={child.dndId}\n />\n </SortableItem>\n </Grid.Item>\n ))}\n </Grid.Root>\n )}\n </DroppableContainer>\n </SortableContext>\n ))}\n <DragOverlay>\n {activeDragItem ? (\n <Field\n attribute={attributes[activeDragItem.name]}\n components={components}\n name={activeDragItem.formName}\n dndId={activeDragItem.dndId}\n />\n ) : null}\n </DragOverlay>\n <Menu.Root>\n <Menu.Trigger\n startIcon={<Plus />}\n endIcon={null}\n disabled={remainingFields.length === 0}\n fullWidth\n variant=\"secondary\"\n >\n {formatMessage({\n id: getTranslation('containers.SettingPage.add.field'),\n defaultMessage: 'Insert another field',\n })}\n </Menu.Trigger>\n <Menu.Content>\n {remainingFields.map((field) => (\n <Menu.Item key={field.name} onSelect={handleAddField(field)}>\n {field.label}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Root>\n </Flex>\n </Box>\n </Flex>\n </DndContext>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldProps extends Pick<EditFieldFormProps, 'name' | 'attribute'> {\n components: EditLayout['components'];\n dndId: string;\n onRemoveField?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nconst TEMP_FIELD_NAME = '_TEMP_';\n\n/**\n * Displays a field in the layout with drag options, also\n * opens a modal to edit the details of said field.\n */\nconst Field = ({ attribute, components, name, onRemoveField, dndId }: FieldProps) => {\n const isDesktop = useIsDesktop();\n const [isModalOpen, setIsModalOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n const { value } = useField<FormField>(name);\n const { listeners, setActivatorNodeRef } = useSortable({\n id: dndId,\n });\n\n const handleRemoveField: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (onRemoveField) {\n onRemoveField?.(e);\n }\n };\n\n const onEditFieldMeta: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n setIsModalOpen(true);\n };\n\n if (!value) {\n return null;\n }\n\n if (value.name === TEMP_FIELD_NAME) {\n return <Flex tag=\"span\" height=\"100%\" style={{ opacity: 0 }} />;\n }\n\n if (!attribute) {\n return null;\n }\n\n return (\n <Modal.Root open={isModalOpen} onOpenChange={setIsModalOpen}>\n <Flex\n borderColor=\"neutral150\"\n background=\"neutral100\"\n hasRadius\n gap={3}\n cursor=\"pointer\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n position=\"relative\"\n >\n {isDesktop && (\n <DragButton\n ref={setActivatorNodeRef}\n tag=\"span\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.move.field'),\n defaultMessage: 'Move {item}',\n },\n { item: value.label }\n )}\n {...listeners}\n >\n <Drag />\n </DragButton>\n )}\n <Flex direction=\"column\" alignItems=\"flex-start\" grow={1} overflow=\"hidden\">\n <Flex gap={3} justifyContent=\"space-between\" width=\"100%\">\n <Typography ellipsis fontWeight=\"bold\">\n {value.label}\n </Typography>\n <Flex position=\"relative\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n background=\"transparent\"\n onClick={onEditFieldMeta}\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.edit.field'),\n defaultMessage: 'Edit {item}',\n },\n { item: value.label }\n )}\n >\n <Pencil />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n onClick={handleRemoveField}\n background=\"transparent\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.delete.field'),\n defaultMessage: 'Delete {item}',\n },\n { item: value.label }\n )}\n >\n <Cross />\n </IconButton>\n </Flex>\n </Flex>\n {attribute?.type === 'component' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n direction=\"column\"\n gap={2}\n width=\"100%\"\n >\n <Grid.Root gap={4} width=\"100%\">\n {components[attribute.component].layout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item\n key={field.name}\n col={size}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <Flex\n alignItems=\"center\"\n background=\"neutral0\"\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={3}\n paddingRight={3}\n hasRadius\n borderColor=\"neutral200\"\n >\n <Typography textColor=\"neutral800\">{field.name}</Typography>\n </Flex>\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n <Link\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n startIcon={<Cog />}\n tag={NavLink}\n to={`../components/${attribute.component}/configurations/edit`}\n >\n {formatMessage({\n id: getTranslation('components.FieldItem.linkToComponentLayout'),\n defaultMessage: \"Set the component's layout\",\n })}\n </Link>\n </Flex>\n ) : null}\n {attribute?.type === 'dynamiczone' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n gap={2}\n width=\"100%\"\n wrap=\"wrap\"\n >\n {attribute?.components.map((uid) => (\n <ComponentLink\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n key={uid}\n to={`../components/${uid}/configurations/edit`}\n >\n <ComponentIcon icon={components[uid].settings.icon} />\n <Typography fontSize={1} textColor=\"neutral600\" fontWeight=\"bold\">\n {components[uid].settings.displayName}\n </Typography>\n </ComponentLink>\n ))}\n </Flex>\n ) : null}\n </Flex>\n </Flex>\n {value.name !== TEMP_FIELD_NAME && (\n <EditFieldForm attribute={attribute} name={name} onClose={() => setIsModalOpen(false)} />\n )}\n </Modal.Root>\n );\n};\n\nconst DragButton = styled<IconButtonComponent<'span'>>(IconButton)`\n height: unset;\n align-self: stretch;\n display: flex;\n align-items: center;\n padding: 0;\n border: none;\n background-color: transparent;\n border-radius: 0px;\n border-right: 1px solid ${({ theme }) => theme.colors.neutral150};\n cursor: all-scroll;\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst ComponentLink = styled(NavLink)`\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: ${({ theme }) => theme.spaces[1]};\n padding: ${(props) => props.theme.spaces[2]};\n border: 1px solid ${({ theme }) => theme.colors.neutral200};\n background: ${({ theme }) => theme.colors.neutral0};\n width: 14rem;\n border-radius: ${({ theme }) => theme.borderRadius};\n text-decoration: none;\n\n &:focus,\n &:hover {\n ${({ theme }) => `\n background-color: ${theme.colors.primary100};\n border-color: ${theme.colors.primary200};\n\n ${Typography} {\n color: ${theme.colors.primary600};\n }\n `}\n\n /* > ComponentIcon */\n > div:first-child {\n background: ${({ theme }) => theme.colors.primary200};\n color: ${({ theme }) => theme.colors.primary600};\n\n svg {\n path {\n fill: ${({ theme }) => theme.colors.primary600};\n }\n }\n }\n }\n`;\n\nexport { Fields, TEMP_FIELD_NAME };\nexport type { FieldsProps };\n"],"names":["GRID_COLUMNS","DroppableContainer","id","children","droppable","useDroppable","SortableItem","attributes","setNodeRef","transform","transition","isDragging","useSortable","style","CSS","Transform","toString","x","y","scaleX","scaleY","height","opacity","outlineOffset","_jsx","div","ref","createDragAndDropContainersFromLayout","layout","map","row","containerIndex","dndId","child","childIndex","formName","Fields","fieldSizes","components","metadatas","formatMessage","useIntl","useForm","state","values","onChange","addFieldRow","removeFieldRow","existingFields","field","name","flat","remainingFields","Object","entries","reduce","acc","current","visible","includes","type","size","push","label","handleRemoveField","rowIndex","fieldIndex","length","slice","handleAddField","containers","setContainers","React","useState","activeDragItem","setActiveDragItem","findContainer","containersAsDictionary","keys","find","key","getItemFromContainer","container","item","getContainersAsDictionary","fromEntries","createContainersWithSpacers","filter","TEMP_FIELD_NAME","totalSpaceTaken","curr","spacerKey","generateNKeysBetweenImpl","at","__temp_key__","undefined","useEffect","DndContext","onDragStart","event","activeContainer","active","activeItem","onDragOver","over","overContainer","activeContainerIndex","findIndex","overContainerIndex","draggedItem","overItem","overIndex","activeIndex","update","produce","draft","targetChildren","spaceTaken","isNotEnoughSpace","canSwapSameSizeItem","canCreateNewRowForItem","isHoveringOverSpacer","sourceChildren","splice","draftOverIndex","insertIndex","existingRow","nonTempChildren","isNextRowEmpty","newContainerPrototype","findFreeContainerId","i","newContainerId","onDragEnd","overId","movedContainerItems","arraySwap","updatedContainers","updatedContainersWithSpacers","updatedLayout","_dndId","_formName","_jsxs","Flex","paddingTop","direction","alignItems","gap","justifyContent","Typography","fontWeight","getTranslation","defaultMessage","variant","textColor","Box","padding","hasRadius","borderStyle","borderWidth","borderColor","SortableContext","items","strategy","rectSwappingStrategy","Grid","Root","Item","col","xs","Field","attribute","onRemoveField","DragOverlay","Menu","Trigger","startIcon","Plus","endIcon","disabled","fullWidth","Content","onSelect","isDesktop","useIsDesktop","isModalOpen","setIsModalOpen","value","useField","listeners","setActivatorNodeRef","e","preventDefault","stopPropagation","onEditFieldMeta","tag","Modal","open","onOpenChange","background","cursor","onClick","position","DragButton","withTooltip","Drag","grow","overflow","width","ellipsis","IconButton","Pencil","Cross","paddingRight","paddingBottom","paddingLeft","component","Link","Cog","NavLink","to","wrap","uid","ComponentLink","ComponentIcon","icon","settings","fontSize","displayName","EditFieldForm","onClose","styled","theme","colors","neutral150","spaces","props","neutral200","neutral0","borderRadius","primary100","primary200","primary600"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAMA,YAAAA,GAAe,EAAA;AAErB;;AAEkG,qGAElG,MAAMC,kBAAAA,GAAqB,CAAC,EAC1BC,EAAE,EACFC,QAAQ,EAIT,GAAA;AACC,IAAA,MAAMC,YAAYC,YAAAA,CAAa;AAC7BH,QAAAA;AACF,KAAA,CAAA;AAEA,IAAA,OAAOC,QAAAA,CAASC,SAAAA,CAAAA;AAClB,CAAA;MAEaE,YAAAA,GAAe,CAAC,EAAEJ,EAAE,EAAEC,QAAQ,EAA6C,GAAA;AACtF,IAAA,MAAM,EAAEI,UAAU,EAAEC,UAAU,EAAEC,SAAS,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,WAAAA,CAAY;AAChFV,QAAAA;AACF,KAAA,CAAA;AAEA,IAAA,MAAMW,KAAAA,GAAQ;AACZJ,QAAAA,SAAAA,EAAWK,GAAAA,CAAIC,SAAS,CAACC,QAAQ,CAAC;AAChCC,YAAAA,CAAAA,EAAGR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AAAA,CAAMC,MAAM,CAACO,UAAU,CAAC;AAC9B,oBAAA,EAAER,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;;AAExC,MAAA,EAAE5F,UAAAA,CAAW;AACF,iBAAA,EAAEmF,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;AAEvC,IAAA,CAAC;;;;kBAIa,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;aAC9C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;gBAItC,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;;AAKzD,CAAC;;;;"}
1
+ {"version":3,"file":"Fields.mjs","sources":["../../../../admin/src/components/ConfigurationForm/Fields.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useDroppable, DndContext, UniqueIdentifier, DragOverlay } from '@dnd-kit/core';\nimport { arraySwap, SortableContext, useSortable, rectSwappingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { useField, useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Modal,\n Box,\n Flex,\n Grid,\n IconButton,\n IconButtonComponent,\n Typography,\n Link,\n Menu,\n} from '@strapi/design-system';\nimport { Cog, Cross, Drag, Pencil, Plus } from '@strapi/icons';\nimport { generateNKeysBetween as generateNKeysBetweenImpl } from 'fractional-indexing';\nimport { produce } from 'immer';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../../utils/translations';\nimport { ComponentIcon } from '../ComponentIcon';\n\nimport { EditFieldForm, EditFieldFormProps } from './EditFieldForm';\n\nimport type { ConfigurationFormData, EditFieldSpacerLayout } from './Form';\nimport type { EditLayout } from '../../hooks/useDocumentLayout';\n\nconst EMPTY_METADATAS: NonNullable<FieldsProps['metadatas']> = {};\n\ntype FormField = ConfigurationFormData['layout'][number]['children'][number];\ntype Field = Omit<ConfigurationFormData['layout'][number]['children'][number], '__temp_key__'>;\n\nconst GRID_COLUMNS = 12;\n\n/* -------------------------------------------------------------------------------------------------\n * Drag and Drop\n * -----------------------------------------------------------------------------------------------*/\n\nconst DroppableContainer = ({\n id,\n children,\n}: {\n id: string;\n children: (props: ReturnType<typeof useDroppable>) => React.ReactNode;\n}) => {\n const droppable = useDroppable({\n id,\n });\n\n return children(droppable);\n};\n\nexport const SortableItem = ({ id, children }: { id: string; children: React.ReactNode }) => {\n const { attributes, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n const style = {\n transform: CSS.Transform.toString({\n x: transform?.x ?? 0,\n y: transform?.y ?? 0,\n // Avoid any scaling animations which can visually \"squish\" or\n // \"stretch\" neighbouring cards in mixed-width grids (4/8/12 cols).\n scaleX: 1,\n scaleY: 1,\n }),\n transition,\n height: '100%',\n opacity: isDragging ? 0.6 : 1,\n outlineOffset: 2,\n };\n\n return (\n <div ref={setNodeRef} style={style} {...attributes}>\n {children}\n </div>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Fields\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldsProps extends Pick<EditLayout, 'metadatas'>, Pick<FieldProps, 'components'> {\n attributes: {\n [key: string]: FieldProps['attribute'];\n };\n fieldSizes: Record<string, number>;\n components: EditLayout['components'];\n}\n\n/**\n * Compute uids and formName for drag and drop items for the incoming layout\n */\nconst createDragAndDropContainersFromLayout = (layout: ConfigurationFormData['layout']) => {\n return layout.map((row, containerIndex) => ({\n ...row,\n // Use unique ids for drag and drop items\n dndId: `container-${containerIndex}`,\n children: row.children.map((child, childIndex) => ({\n ...child,\n dndId: `container-${containerIndex}-child-${childIndex}`,\n\n // The formName must be recomputed each time an item is moved\n formName: `layout.${containerIndex}.children.${childIndex}`,\n })),\n }));\n};\n\nconst Fields = ({\n attributes,\n fieldSizes,\n components,\n metadatas = EMPTY_METADATAS,\n}: FieldsProps) => {\n const { formatMessage } = useIntl();\n\n const layout = useForm<ConfigurationFormData['layout']>(\n 'Fields',\n (state) => (state.values as ConfigurationFormData).layout ?? []\n );\n\n const onChange = useForm('Fields', (state) => state.onChange);\n const addFieldRow = useForm('Fields', (state) => state.addFieldRow);\n const removeFieldRow = useForm('Fields', (state) => state.removeFieldRow);\n\n const existingFields = new Set(layout.flatMap((row) => row.children.map((field) => field.name)));\n\n /**\n * Get the fields that are not already in the layout\n * But also check that they are visible before we give users\n * the option to display them. e.g. `id` is not visible.\n */\n const remainingFields = Object.entries(metadatas).reduce<Field[]>((acc, current) => {\n const [name, { visible, ...field }] = current;\n\n if (!existingFields.has(name) && visible === true) {\n const type = attributes[name]?.type;\n const size = type ? fieldSizes[type] : GRID_COLUMNS;\n\n acc.push({\n ...field,\n label: field.label ?? name,\n name,\n size,\n });\n }\n\n return acc;\n }, []);\n\n const handleRemoveField =\n (rowIndex: number, fieldIndex: number): FieldProps['onRemoveField'] =>\n () => {\n if (layout[rowIndex].children.length === 1) {\n removeFieldRow(`layout`, rowIndex);\n } else {\n onChange(`layout.${rowIndex}.children`, [\n ...layout[rowIndex].children.slice(0, fieldIndex),\n ...layout[rowIndex].children.slice(fieldIndex + 1),\n ]);\n }\n };\n\n const handleAddField = (field: Field) => () => {\n addFieldRow('layout', { children: [field] });\n };\n\n const [containers, setContainers] = React.useState(() =>\n createDragAndDropContainersFromLayout(layout)\n );\n type Container = (typeof containers)[number];\n const [activeDragItem, setActiveDragItem] = React.useState<Container['children'][number] | null>(\n null\n );\n\n /**\n * Finds either the parent container id or the child id within a container\n */\n function findContainer(id: UniqueIdentifier, containersAsDictionary: Record<string, Container>) {\n // If the id is a key, then it is the parent container\n if (id in containersAsDictionary) {\n return id;\n }\n\n // Otherwise, it is a child inside a container\n return Object.keys(containersAsDictionary).find((key) =>\n containersAsDictionary[key].children.find((child) => child.dndId === id)\n );\n }\n\n /**\n * Gets an item from a container based on its id\n */\n const getItemFromContainer = (id: UniqueIdentifier, container: Container) => {\n return container.children.find((item) => id === item.dndId);\n };\n\n /**\n * Gets the containers as dictionary for quick lookup\n */\n const getContainersAsDictionary = () => {\n return Object.fromEntries(containers.map((container) => [container.dndId, container]));\n };\n\n /**\n * Recomputes the empty space in the grid\n */\n const createContainersWithSpacers = (layout: typeof containers) => {\n return layout\n .map((row) => ({\n ...row,\n children: row.children.filter((field) => field.name !== TEMP_FIELD_NAME),\n }))\n .filter((row) => row.children.length > 0)\n .map((row) => {\n const totalSpaceTaken = row.children.reduce((acc, curr) => acc + curr.size, 0);\n\n if (totalSpaceTaken < GRID_COLUMNS) {\n const [spacerKey] = generateNKeysBetweenImpl(\n row.children.at(-1)?.__temp_key__,\n undefined,\n 1\n );\n\n return {\n ...row,\n children: [\n ...row.children,\n {\n name: TEMP_FIELD_NAME,\n size: GRID_COLUMNS - totalSpaceTaken,\n __temp_key__: spacerKey,\n } satisfies EditFieldSpacerLayout,\n ],\n };\n }\n\n return row;\n });\n };\n\n /**\n * When layout changes (e.g. when a field size is changed or the containers are reordered)\n * we need to update the ids and form names\n */\n React.useEffect(() => {\n const containers = createDragAndDropContainersFromLayout(layout);\n setContainers(containers);\n }, [layout, setContainers]);\n\n return (\n <DndContext\n onDragStart={(event) => {\n const containersAsDictionary = getContainersAsDictionary();\n\n const activeContainer = findContainer(event.active.id, containersAsDictionary);\n\n if (!activeContainer) return;\n\n const activeItem = getItemFromContainer(\n event.active.id,\n containersAsDictionary[activeContainer]\n );\n\n if (activeItem) {\n setActiveDragItem(activeItem);\n }\n }}\n onDragOver={({ active, over }) => {\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(active.id, containersAsDictionary);\n const overContainer = findContainer(over?.id ?? '', containersAsDictionary);\n const activeContainerIndex = containers.findIndex(\n (container) => container.dndId === activeContainer\n );\n const overContainerIndex = containers.findIndex(\n (container) => container.dndId === overContainer\n );\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const draggedItem = getItemFromContainer(\n active.id,\n containersAsDictionary[activeContainer]\n );\n const overItem = getItemFromContainer(\n over?.id ?? '',\n containersAsDictionary[overContainer]\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (item) => item.dndId === over?.id\n );\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (item) => item.dndId === active.id\n );\n\n if (!draggedItem) return;\n\n // Handle a full width field being dragged\n if (draggedItem?.size === GRID_COLUMNS) {\n // Swap the items in the containers\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = containers[overContainerIndex].children;\n draft[overContainerIndex].children = containers[activeContainerIndex].children;\n });\n setContainers(update);\n return;\n }\n\n /**\n * Handle an item being dragged from one container to another,\n * the item is removed from its current container, and then added to its new container\n * An item can only be added in a container if there is enough space\n */\n const update = produce(containers, (draft) => {\n draft[activeContainerIndex].children = draft[activeContainerIndex].children.filter(\n (item) => item.dndId !== active.id\n );\n\n const targetChildren = draft[overContainerIndex].children;\n const spaceTaken = targetChildren.reduce((acc, curr) => {\n if (curr.name === TEMP_FIELD_NAME) {\n return acc;\n }\n\n return acc + curr.size;\n }, 0);\n const isNotEnoughSpace = spaceTaken + draggedItem.size > GRID_COLUMNS;\n const canSwapSameSizeItem =\n overItem &&\n overItem.name !== TEMP_FIELD_NAME &&\n overItem.size === draggedItem.size &&\n activeIndex !== -1 &&\n overIndex !== -1;\n const canCreateNewRowForItem =\n activeContainerIndex !== overContainerIndex &&\n GRID_COLUMNS - spaceTaken < draggedItem.size;\n const isHoveringOverSpacer = overItem?.name === TEMP_FIELD_NAME;\n\n /**\n * Not enough space in the hovered row\n *\n * We still want:\n * - ability to swap items of the same size\n * - ability to create a single extra row to host the dragged item\n * when surrounding rows are full\n */\n if (isNotEnoughSpace) {\n // Try a simple swap when target item is of the same size\n if (canSwapSameSizeItem) {\n const sourceChildren = draft[activeContainerIndex].children;\n\n // Put the hovered item back where the dragged item came from\n sourceChildren.splice(activeIndex, 0, overItem);\n\n // Swap the hovered item with the dragged one in the target row\n const draftOverIndex = targetChildren.findIndex(\n (item) => item.dndId === overItem.dndId\n );\n\n if (draftOverIndex !== -1) {\n targetChildren.splice(draftOverIndex, 1, draggedItem);\n }\n\n return;\n }\n\n // If there is absolutely no space left in the target row and the\n // dragged item comes from a different row, add it to a new row\n if (canCreateNewRowForItem) {\n // Default: insert a new row after the row being hovered (between that row and the\n // next). For row 0, use index 0 instead so fields that are not full-width can still\n // be moved above the first row—there is no separate drop area above it in the UI.\n const insertIndex = overContainerIndex === 0 ? 0 : overContainerIndex + 1;\n\n /**\n * When inserting *after* the hovered row, reuse the following row if it only\n * contains spacers. Skip when inserting at index 0 — draft[0] is the hovered row.\n */\n if (insertIndex > overContainerIndex) {\n const existingRow = draft[insertIndex];\n\n if (existingRow) {\n const nonTempChildren = existingRow.children.filter(\n (child) => child.name !== TEMP_FIELD_NAME\n );\n const isNextRowEmpty = nonTempChildren.length === 0;\n\n // If the row directly after is empty (only spacers), reuse it\n // instead of creating yet another row.\n if (isNextRowEmpty) {\n existingRow.children = [draggedItem];\n return;\n }\n }\n }\n\n const newContainerPrototype = draft[overContainerIndex];\n\n // Using draft.length directly can collide with an existing container id\n // (e.g. after rows were removed), causing React key conflicts and flicker.\n const findFreeContainerId = (i: number): string =>\n containersAsDictionary[`container-${i}`]\n ? findFreeContainerId(i + 1)\n : `container-${i}`;\n const newContainerId = findFreeContainerId(draft.length);\n\n draft.splice(insertIndex, 0, {\n ...newContainerPrototype,\n dndId: newContainerId,\n children: [draggedItem],\n });\n\n return;\n }\n }\n\n // There is enough room in the target row\n if (isHoveringOverSpacer) {\n // We are over an invisible spacer, replace it with the dragged item\n targetChildren.splice(overIndex, 1, draggedItem);\n return;\n }\n\n // There is room for the item in the container, drop it\n targetChildren.splice(overIndex, 0, draggedItem);\n });\n\n setContainers(update.filter((container) => container.children.length > 0));\n }}\n onDragEnd={(event) => {\n const { active, over } = event;\n const { id } = active;\n const overId = over?.id;\n const containersAsDictionary = getContainersAsDictionary();\n const activeContainer = findContainer(id, containersAsDictionary);\n const overContainer = findContainer(overId!, containersAsDictionary);\n\n if (!activeContainer || !overContainer) {\n return;\n }\n\n const activeIndex = containersAsDictionary[activeContainer].children.findIndex(\n (children) => children.dndId === id\n );\n const overIndex = containersAsDictionary[overContainer].children.findIndex(\n (children) => children.dndId === overId\n );\n\n const movedContainerItems = produce(containersAsDictionary, (draft) => {\n if (\n activeIndex >= 0 &&\n overIndex >= 0 &&\n activeIndex !== overIndex &&\n activeContainer === overContainer\n ) {\n // Move items around inside their own container\n draft[activeContainer].children = arraySwap(\n draft[activeContainer].children,\n activeIndex,\n overIndex\n );\n }\n });\n\n // Remove properties the server does not expect before updating the form\n const updatedContainers = Object.values(movedContainerItems);\n const updatedContainersWithSpacers = createContainersWithSpacers(\n updatedContainers\n ) as typeof containers;\n const updatedLayout = updatedContainersWithSpacers.map(\n ({ dndId: _dndId, children, ...container }) => ({\n ...container,\n children: children.map(({ dndId: _dndId, formName: _formName, ...child }) => child),\n })\n );\n\n // Update the layout\n onChange('layout', updatedLayout);\n setActiveDragItem(null);\n }}\n >\n <Flex paddingTop={6} direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex alignItems=\"flex-start\" direction=\"column\" justifyContent=\"space-between\">\n <Typography fontWeight=\"bold\">\n {formatMessage({\n id: getTranslation('containers.list.displayedFields'),\n defaultMessage: 'Displayed fields',\n })}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: 'containers.SettingPage.editSettings.description',\n defaultMessage: 'Drag & drop the fields to build the layout',\n })}\n </Typography>\n </Flex>\n <Box padding={4} hasRadius borderStyle=\"dashed\" borderWidth=\"1px\" borderColor=\"neutral300\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {containers.map((container, containerIndex) => (\n <SortableContext\n key={container.dndId}\n id={container.dndId}\n items={container.children.map((child) => ({ id: child.dndId }))}\n strategy={rectSwappingStrategy}\n >\n <DroppableContainer id={container.dndId}>\n {({ setNodeRef }) => (\n <Grid.Root key={container.dndId} ref={setNodeRef} gap={2}>\n {container.children.map((child, childIndex) => (\n <Grid.Item\n col={child.size}\n xs={12}\n key={child.dndId}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <SortableItem id={child.dndId}>\n <Field\n attribute={attributes[child.name]}\n components={components}\n name={child.formName}\n onRemoveField={handleRemoveField(containerIndex, childIndex)}\n dndId={child.dndId}\n />\n </SortableItem>\n </Grid.Item>\n ))}\n </Grid.Root>\n )}\n </DroppableContainer>\n </SortableContext>\n ))}\n <DragOverlay>\n {activeDragItem ? (\n <Field\n attribute={attributes[activeDragItem.name]}\n components={components}\n name={activeDragItem.formName}\n dndId={activeDragItem.dndId}\n />\n ) : null}\n </DragOverlay>\n <Menu.Root>\n <Menu.Trigger\n startIcon={<Plus />}\n endIcon={null}\n disabled={remainingFields.length === 0}\n fullWidth\n variant=\"secondary\"\n >\n {formatMessage({\n id: getTranslation('containers.SettingPage.add.field'),\n defaultMessage: 'Insert another field',\n })}\n </Menu.Trigger>\n <Menu.Content>\n {remainingFields.map((field) => (\n <Menu.Item key={field.name} onSelect={handleAddField(field)}>\n {field.label}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Root>\n </Flex>\n </Box>\n </Flex>\n </DndContext>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface FieldProps extends Pick<EditFieldFormProps, 'name' | 'attribute'> {\n components: EditLayout['components'];\n dndId: string;\n onRemoveField?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nconst TEMP_FIELD_NAME = '_TEMP_';\n\n/**\n * Displays a field in the layout with drag options, also\n * opens a modal to edit the details of said field.\n */\nconst Field = ({ attribute, components, name, onRemoveField, dndId }: FieldProps) => {\n const isDesktop = useIsDesktop();\n const [isModalOpen, setIsModalOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n const { value } = useField<FormField>(name);\n const { listeners, setActivatorNodeRef } = useSortable({\n id: dndId,\n });\n\n const handleRemoveField: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (onRemoveField) {\n onRemoveField?.(e);\n }\n };\n\n const onEditFieldMeta: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n setIsModalOpen(true);\n };\n\n if (!value) {\n return null;\n }\n\n if (value.name === TEMP_FIELD_NAME) {\n return <Flex tag=\"span\" height=\"100%\" style={{ opacity: 0 }} />;\n }\n\n if (!attribute) {\n return null;\n }\n\n return (\n <Modal.Root open={isModalOpen} onOpenChange={setIsModalOpen}>\n <Flex\n borderColor=\"neutral150\"\n background=\"neutral100\"\n hasRadius\n gap={3}\n cursor=\"pointer\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n position=\"relative\"\n >\n {isDesktop && (\n <DragButton\n ref={setActivatorNodeRef}\n tag=\"span\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.move.field'),\n defaultMessage: 'Move {item}',\n },\n { item: value.label }\n )}\n {...listeners}\n >\n <Drag />\n </DragButton>\n )}\n <Flex direction=\"column\" alignItems=\"flex-start\" grow={1} overflow=\"hidden\">\n <Flex gap={3} justifyContent=\"space-between\" width=\"100%\">\n <Typography ellipsis fontWeight=\"bold\">\n {value.label}\n </Typography>\n <Flex position=\"relative\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n background=\"transparent\"\n onClick={onEditFieldMeta}\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.edit.field'),\n defaultMessage: 'Edit {item}',\n },\n { item: value.label }\n )}\n >\n <Pencil />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n onClick={handleRemoveField}\n background=\"transparent\"\n withTooltip={false}\n label={formatMessage(\n {\n id: getTranslation('components.DraggableCard.delete.field'),\n defaultMessage: 'Delete {item}',\n },\n { item: value.label }\n )}\n >\n <Cross />\n </IconButton>\n </Flex>\n </Flex>\n {attribute?.type === 'component' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n direction=\"column\"\n gap={2}\n width=\"100%\"\n >\n <Grid.Root gap={4} width=\"100%\">\n {components[attribute.component].layout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item\n key={field.name}\n col={size}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <Flex\n alignItems=\"center\"\n background=\"neutral0\"\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={3}\n paddingRight={3}\n hasRadius\n borderColor=\"neutral200\"\n >\n <Typography textColor=\"neutral800\">{field.name}</Typography>\n </Flex>\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n <Link\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n startIcon={<Cog />}\n tag={NavLink}\n to={`../components/${attribute.component}/configurations/edit`}\n >\n {formatMessage({\n id: getTranslation('components.FieldItem.linkToComponentLayout'),\n defaultMessage: \"Set the component's layout\",\n })}\n </Link>\n </Flex>\n ) : null}\n {attribute?.type === 'dynamiczone' ? (\n <Flex\n paddingTop={3}\n paddingRight={3}\n paddingBottom={3}\n paddingLeft={0}\n alignItems=\"flex-start\"\n gap={2}\n width=\"100%\"\n wrap=\"wrap\"\n >\n {attribute?.components.map((uid) => (\n <ComponentLink\n // used to stop the edit form from appearing when we click here.\n onClick={(e) => e.stopPropagation()}\n key={uid}\n to={`../components/${uid}/configurations/edit`}\n >\n <ComponentIcon icon={components[uid].settings.icon} />\n <Typography fontSize={1} textColor=\"neutral600\" fontWeight=\"bold\">\n {components[uid].settings.displayName}\n </Typography>\n </ComponentLink>\n ))}\n </Flex>\n ) : null}\n </Flex>\n </Flex>\n {value.name !== TEMP_FIELD_NAME && (\n <EditFieldForm attribute={attribute} name={name} onClose={() => setIsModalOpen(false)} />\n )}\n </Modal.Root>\n );\n};\n\nconst DragButton = styled<IconButtonComponent<'span'>>(IconButton)`\n height: unset;\n align-self: stretch;\n display: flex;\n align-items: center;\n padding: 0;\n border: none;\n background-color: transparent;\n border-radius: 0px;\n border-right: 1px solid ${({ theme }) => theme.colors.neutral150};\n cursor: all-scroll;\n\n svg {\n width: 1.2rem;\n height: 1.2rem;\n }\n`;\n\nconst ComponentLink = styled(NavLink)`\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: ${({ theme }) => theme.spaces[1]};\n padding: ${(props) => props.theme.spaces[2]};\n border: 1px solid ${({ theme }) => theme.colors.neutral200};\n background: ${({ theme }) => theme.colors.neutral0};\n width: 14rem;\n border-radius: ${({ theme }) => theme.borderRadius};\n text-decoration: none;\n\n &:focus,\n &:hover {\n ${({ theme }) => `\n background-color: ${theme.colors.primary100};\n border-color: ${theme.colors.primary200};\n\n ${Typography} {\n color: ${theme.colors.primary600};\n }\n `}\n\n /* > ComponentIcon */\n > div:first-child {\n background: ${({ theme }) => theme.colors.primary200};\n color: ${({ theme }) => theme.colors.primary600};\n\n svg {\n path {\n fill: ${({ theme }) => theme.colors.primary600};\n }\n }\n }\n }\n`;\n\nexport { Fields, TEMP_FIELD_NAME };\nexport type { FieldsProps };\n"],"names":["EMPTY_METADATAS","GRID_COLUMNS","DroppableContainer","id","children","droppable","useDroppable","SortableItem","attributes","setNodeRef","transform","transition","isDragging","useSortable","style","CSS","Transform","toString","x","y","scaleX","scaleY","height","opacity","outlineOffset","_jsx","div","ref","createDragAndDropContainersFromLayout","layout","map","row","containerIndex","dndId","child","childIndex","formName","Fields","fieldSizes","components","metadatas","formatMessage","useIntl","useForm","state","values","onChange","addFieldRow","removeFieldRow","existingFields","Set","flatMap","field","name","remainingFields","Object","entries","reduce","acc","current","visible","has","type","size","push","label","handleRemoveField","rowIndex","fieldIndex","length","slice","handleAddField","containers","setContainers","React","useState","activeDragItem","setActiveDragItem","findContainer","containersAsDictionary","keys","find","key","getItemFromContainer","container","item","getContainersAsDictionary","fromEntries","createContainersWithSpacers","filter","TEMP_FIELD_NAME","totalSpaceTaken","curr","spacerKey","generateNKeysBetweenImpl","at","__temp_key__","undefined","useEffect","DndContext","onDragStart","event","activeContainer","active","activeItem","onDragOver","over","overContainer","activeContainerIndex","findIndex","overContainerIndex","draggedItem","overItem","overIndex","activeIndex","update","produce","draft","targetChildren","spaceTaken","isNotEnoughSpace","canSwapSameSizeItem","canCreateNewRowForItem","isHoveringOverSpacer","sourceChildren","splice","draftOverIndex","insertIndex","existingRow","nonTempChildren","isNextRowEmpty","newContainerPrototype","findFreeContainerId","i","newContainerId","onDragEnd","overId","movedContainerItems","arraySwap","updatedContainers","updatedContainersWithSpacers","updatedLayout","_dndId","_formName","_jsxs","Flex","paddingTop","direction","alignItems","gap","justifyContent","Typography","fontWeight","getTranslation","defaultMessage","variant","textColor","Box","padding","hasRadius","borderStyle","borderWidth","borderColor","SortableContext","items","strategy","rectSwappingStrategy","Grid","Root","Item","col","xs","Field","attribute","onRemoveField","DragOverlay","Menu","Trigger","startIcon","Plus","endIcon","disabled","fullWidth","Content","onSelect","isDesktop","useIsDesktop","isModalOpen","setIsModalOpen","value","useField","listeners","setActivatorNodeRef","e","preventDefault","stopPropagation","onEditFieldMeta","tag","Modal","open","onOpenChange","background","cursor","onClick","position","DragButton","withTooltip","Drag","grow","overflow","width","ellipsis","IconButton","Pencil","Cross","paddingRight","paddingBottom","paddingLeft","component","Link","Cog","NavLink","to","wrap","uid","ComponentLink","ComponentIcon","icon","settings","fontSize","displayName","EditFieldForm","onClose","styled","theme","colors","neutral150","spaces","props","neutral200","neutral0","borderRadius","primary100","primary200","primary600"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAMA,kBAAyD,EAAC;AAKhE,MAAMC,YAAAA,GAAe,EAAA;AAErB;;AAEkG,qGAElG,MAAMC,kBAAAA,GAAqB,CAAC,EAC1BC,EAAE,EACFC,QAAQ,EAIT,GAAA;AACC,IAAA,MAAMC,YAAYC,YAAAA,CAAa;AAC7BH,QAAAA;AACF,KAAA,C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C,CAAA,CAAE,CAAC;WAC7B,EAAE,CAACC,QAAUA,KAAAA,CAAMJ,KAAK,CAACG,MAAM,CAAC,EAAE,CAAC;oBAC1B,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACI,UAAU,CAAC;cAC/C,EAAE,CAAC,EAAEL,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACK,QAAQ,CAAC;;AAEpC,iBAAA,EAAE,CAAC,EAAEN,KAAK,EAAE,GAAKA,KAAAA,CAAMO,YAAY,CAAC;;;;;AAKjD,IAAA,EAAE,CAAC,EAAEP,KAAK,EAAE,GAAK;AACG,wBAAA,EAAEA,KAAAA,CAAMC,MAAM,CAACO,UAAU,CAAC;AAC9B,oBAAA,EAAER,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;;AAExC,MAAA,EAAE5F,UAAAA,CAAW;AACF,iBAAA,EAAEmF,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;AAEvC,IAAA,CAAC;;;;kBAIa,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACQ,UAAU,CAAC;aAC9C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;gBAItC,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACS,UAAU,CAAC;;;;;AAKzD,CAAC;;;;"}
@@ -25,6 +25,7 @@ function _interopNamespace(e) {
25
25
 
26
26
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
27
 
28
+ const EMPTY_CUSTOM_INTERVALS = [];
28
29
  const intervals = [
29
30
  'years',
30
31
  'months',
@@ -46,7 +47,7 @@ const intervals = [
46
47
  * { unit: 'hours', threshold: 1, text: 'last hour' },
47
48
  * ]}
48
49
  * ```
49
- */ const RelativeTime = /*#__PURE__*/ React__namespace.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
50
+ */ const RelativeTime = /*#__PURE__*/ React__namespace.forwardRef(({ timestamp, customIntervals = EMPTY_CUSTOM_INTERVALS, ...restProps }, forwardedRef)=>{
50
51
  const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
51
52
  // Invalid Date: intervalToDuration throws RangeError (see #27382).
52
53
  if (!dateFns.isValid(timestamp)) {
@@ -1 +1 @@
1
- {"version":3,"file":"RelativeTime.js","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,gBAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkB,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,iBAAAA,EAAAA;;IAGvD,IAAI,CAACC,gBAAQR,SAAAA,CAAAA,EAAY;AACvB,QAAA,qBACES,cAAA,CAACC,MAAAA,EAAAA;YAAKC,GAAAA,EAAKR,YAAAA;YAAcS,IAAAA,EAAK,MAAA;AAAQ,Y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ativeTime.js","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst EMPTY_CUSTOM_INTERVALS: NonNullable<RelativeTimeProps['customIntervals']> = [];\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = EMPTY_CUSTOM_INTERVALS, ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["EMPTY_CUSTOM_INTERVALS","intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,yBAA4E,EAAE;AAEpF,MAAMC,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,gBAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkBN,sBAAsB,EAAE,GAAGO,WAAW,EAAEC,YAAAA,GAAAA;AACtE,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,iBAAAA,EAAAA;;IAGvD,IAAI,CAACC,gBAAQR,SAAAA,CAAAA,EAAY;AACvB,QAAA,qBACES,cAAA,CAACC,MAAAA,EAAAA;YAAKC,GAAAA,EAAKR,YAAAA;YAAcS,IAAAA,EAAK,MAAA;AAAQ,YAAA,GAAGV,SAAS;AAAE,YAAA,QAAA,EAAA;;AAIxD,IAAA;AAEA;;QAGA,MAAMW,WAAWC,0BAAAA,CAAmB;QAClCC,KAAAA,EAAOf,SAAAA;AACPgB,QAAAA,GAAAA,EAAKC,KAAKC,GAAG;AAEf,KAAA,CAAA;AAEA,IAAA,MAAMC,IAAAA,GACJvB,SAAAA,CAAUwB,IAAI,CAAC,CAACC,YAAAA,GAAAA;QACd,OAAOR,QAAQ,CAACQ,YAAAA,CAAa,GAAG,CAAA,IAAKC,OAAOC,IAAI,CAACV,QAAAA,CAAAA,CAAUW,QAAQ,CAACH,YAAAA,CAAAA;IACtE,CAAA,CAAA,IAAM,SAAA;IAER,MAAMI,YAAAA,GAAeC,cAAAA,CAAO1B,SAAAA,CAAAA,GAAa,CAACa,QAAQ,CAACM,IAAAA,CAAK,GAAGN,QAAQ,CAACM,IAAAA,CAAK;;AAGzE,IAAA,MAAMQ,cAAAA,GAAiB1B,eAAAA,CAAgBmB,IAAI,CACzC,CAACQ,MAAAA,GAAWf,QAAQ,CAACe,MAAAA,CAAOT,IAAI,CAAC,GAAGS,OAAOC,SAAS,CAAA;AAGtD,IAAA,MAAMC,cAAcH,cAAAA,GAChBA,cAAAA,CAAeI,IAAI,GACnB3B,kBAAAA,CAAmBqB,cAAcN,IAAAA,EAAM;QAAEa,OAAAA,EAAS;AAAO,KAAA,CAAA;AAE7D,IAAA,qBACEvB,cAAA,CAACC,MAAAA,EAAAA;QACCC,GAAAA,EAAKR,YAAAA;AACL8B,QAAAA,QAAAA,EAAUjC,UAAUkC,WAAW,EAAA;QAC/BtB,IAAAA,EAAK,MAAA;AACLuB,QAAAA,KAAAA,EAAO,GAAG9B,UAAAA,CAAWL,SAAAA,CAAAA,CAAW,CAAC,EAAEM,WAAWN,SAAAA,CAAAA,CAAAA,CAAY;AACzD,QAAA,GAAGE,SAAS;AAEZ4B,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { isValid, intervalToDuration, isPast } from 'date-fns';
4
4
  import { useIntl } from 'react-intl';
5
5
 
6
+ const EMPTY_CUSTOM_INTERVALS = [];
6
7
  const intervals = [
7
8
  'years',
8
9
  'months',
@@ -24,7 +25,7 @@ const intervals = [
24
25
  * { unit: 'hours', threshold: 1, text: 'last hour' },
25
26
  * ]}
26
27
  * ```
27
- */ const RelativeTime = /*#__PURE__*/ React.forwardRef(({ timestamp, customIntervals = [], ...restProps }, forwardedRef)=>{
28
+ */ const RelativeTime = /*#__PURE__*/ React.forwardRef(({ timestamp, customIntervals = EMPTY_CUSTOM_INTERVALS, ...restProps }, forwardedRef)=>{
28
29
  const { formatRelativeTime, formatDate, formatTime } = useIntl();
29
30
  // Invalid Date: intervalToDuration throws RangeError (see #27382).
30
31
  if (!isValid(timestamp)) {
@@ -1 +1 @@
1
- {"version":3,"file":"RelativeTime.mjs","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;AAKA,MAAMA,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,KAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkB,EAAE,EAAE,GAAGC,WAAW,EAAEC,YAAAA,GAAAA;AAClD,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,OAAAA,EAAAA;;IAGvD,IAAI,CAACC,QAAQR,SAAAA,CAAA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CAAAA,CAAAA,CAAY;AACzD,QAAA,GAAGE,SAAS;AAEZ4B,QAAAA,QAAAA,EAAAA;;AAGP,CAAA;;;;"}
1
+ {"version":3,"file":"RelativeTime.mjs","sources":["../../../admin/src/components/RelativeTime.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Duration, intervalToDuration, isPast, isValid } from 'date-fns';\nimport { useIntl } from 'react-intl';\n\nconst EMPTY_CUSTOM_INTERVALS: NonNullable<RelativeTimeProps['customIntervals']> = [];\n\nconst intervals: Array<keyof Duration> = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];\n\ninterface CustomInterval {\n unit: keyof Duration;\n text: string;\n threshold: number;\n}\n\ninterface RelativeTimeProps extends React.ComponentPropsWithoutRef<'time'> {\n timestamp: Date;\n customIntervals?: CustomInterval[];\n}\n\n/**\n * Displays the relative time between a given timestamp and the current time.\n * You can display a custom message for given time intervals by passing an array of custom intervals.\n *\n * @example\n * ```jsx\n * <caption>Display \"last hour\" if the timestamp is less than an hour ago</caption>\n * <RelativeTime\n * timestamp={new Date('2021-01-01')}\n * customIntervals={[\n * { unit: 'hours', threshold: 1, text: 'last hour' },\n * ]}\n * ```\n */\nconst RelativeTime = React.forwardRef<HTMLTimeElement, RelativeTimeProps>(\n ({ timestamp, customIntervals = EMPTY_CUSTOM_INTERVALS, ...restProps }, forwardedRef) => {\n const { formatRelativeTime, formatDate, formatTime } = useIntl();\n\n // Invalid Date: intervalToDuration throws RangeError (see #27382).\n if (!isValid(timestamp)) {\n return (\n <time ref={forwardedRef} role=\"time\" {...restProps}>\n -\n </time>\n );\n }\n\n /**\n * TODO: make this auto-update, like a clock.\n */\n const interval = intervalToDuration({\n start: timestamp,\n end: Date.now(),\n // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.\n }) as Required<Duration>;\n\n const unit =\n intervals.find((intervalUnit) => {\n return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);\n }) ?? 'seconds';\n\n const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];\n\n // Display custom text if interval is less than the threshold\n const customInterval = customIntervals.find(\n (custom) => interval[custom.unit] < custom.threshold\n );\n\n const displayText = customInterval\n ? customInterval.text\n : formatRelativeTime(relativeTime, unit, { numeric: 'auto' });\n\n return (\n <time\n ref={forwardedRef}\n dateTime={timestamp.toISOString()}\n role=\"time\"\n title={`${formatDate(timestamp)} ${formatTime(timestamp)}`}\n {...restProps}\n >\n {displayText}\n </time>\n );\n }\n);\n\nexport { RelativeTime };\nexport type { CustomInterval, RelativeTimeProps };\n"],"names":["EMPTY_CUSTOM_INTERVALS","intervals","RelativeTime","React","forwardRef","timestamp","customIntervals","restProps","forwardedRef","formatRelativeTime","formatDate","formatTime","useIntl","isValid","_jsx","time","ref","role","interval","intervalToDuration","start","end","Date","now","unit","find","intervalUnit","Object","keys","includes","relativeTime","isPast","customInterval","custom","threshold","displayText","text","numeric","dateTime","toISOString","title"],"mappings":";;;;;AAKA,MAAMA,yBAA4E,EAAE;AAEpF,MAAMC,SAAAA,GAAmC;AAAC,IAAA,OAAA;AAAS,IAAA,QAAA;AAAU,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA;AAAU,CAAA;AAanG;;;;;;;;;;;;;AAaC,IACD,MAAMC,YAAAA,iBAAeC,KAAAA,CAAMC,UAAU,CACnC,CAAC,EAAEC,SAAS,EAAEC,eAAAA,GAAkBN,sBAAsB,EAAE,GAAGO,WAAW,EAAEC,YAAAA,GAAAA;AACtE,IAAA,MAAM,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,OAAAA,EAAAA;;IAGvD,IAAI,CAACC,QAAQR,SAAAA,CAAAA,EAAY;AACvB,QAAA,qBACES,GAAA,CAACC,MAAAA,EAAAA;YAAKC,GAAAA,EAAKR,YAAAA;YAAcS,IAAAA,EAAK,MAAA;AAAQ,YAAA,GAAGV,SAAS;AAAE,YAAA,QAAA,EAAA;;AAI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cesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IAAI,CAACE,mBAAmB,GAAG;gBAAE,GAAG,IAAI,CAACA,mBAAmB;AAAE,gBAAA,GAAGF;AAAO,aAAA;QACtE,CAAA,MAAO;AACL,YAAA,MAAM,IAAIG,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBACrGJ,MAAAA,CAAAA,CAAAA,CACC,CAAA;AAEP,QAAA;AACF,IAAA;AAIAK,IAAAA,oBAAAA,CAAqBC,MAA6D,EAAE;QAClF,IAAIC,KAAAA,CAAMC,OAAO,CAACF,MAAAA,CAAAA,EAAS;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UAAU,EAAEC,KAAAA,CAAM,8EAA8E,CAAC,CAAA;AAEvG,QAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"content-manager.js","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent extends DescriptionComponent<\n DocumentActionProps,\n DocumentActionDescription\n> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent extends DescriptionComponent<\n HeaderActionProps,\n HeaderActionDescription\n> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent extends DescriptionComponent<\n BulkActionComponentProps,\n BulkActionDescription\n> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;;;AA0HA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IAAI,CAACE,mBAAmB,GAAG;gBAAE,GAAG,IAAI,CAACA,mBAAmB;AAAE,gBAAA,GAAGF;AAAO,aAAA;QACtE,CAAA,MAAO;AACL,YAAA,MAAM,IAAIG,KAAAA,CACR,CAAC,oGAAoG,EAAEC,i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AS,UAAA,EAAY;AAC9B,YAAA,MAAM,IAAI/C,KAAAA,CACR,CAAC,6BAA6B,EAAE6C,QAAQ,qBAAqB,EAAED,OAAAA,CAAQ,oEAAoE,EAAE3C,gBAAAA,CAC3I8C,IAAAA,CAAAA,CACA,UAAU,EAAEC,KAAAA,CAAM,8EAA8E,CAAC,CAAA;AAEvG,QAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"content-manager.mjs","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent\n extends DescriptionComponent<DocumentActionProps, DocumentActionDescription> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent\n extends DescriptionComponent<HeaderActionProps, HeaderActionDescription> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent\n extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;AAoHA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAAEC,iBAAiBH,MAAAA,CAAAA,CAAAA,CAAS,CAAA;AAErI,YAAA;YACA,IAAI,CAACC,mBAAmB,GAAGD,MAAAA;QAC7B,CAAA,MAAO,IAAI,OAAOD,MAAAA,KAAW,QAAA,EAAU;YACrC,IA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MnC,wBAAAA,GAA2B,CAACqC,KAAAA,EAAkBC,OAAAA,EAAiBC,OAAAA,GAAAA;IACnEF,KAAAA,CAAMG,OAAO,CAAC,CAACC,IAAAA,EAAMC,KAAAA,GAAAA;QACnB,IAAI,OAAOD,SAAS,UAAA,EAAY;AAC9B,YAAA,MAAM,IAAI/C,KAAAA,CACR,CAAC,6BAA6B,EAAE6C,QAAQ,qBAAqB,EAAED,OAAAA,CAAQ,oEAAoE,EAAE3C,gBAAAA,CAC3I8C,IAAAA,CAAAA,CACA,UAAU,EAAEC,KAAAA,CAAM,8EAA8E,CAAC,CAAA;AAEvG,QAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"content-manager.mjs","sources":["../../admin/src/content-manager.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\n\nimport { INJECTION_ZONES } from './components/InjectionZone';\nimport { PLUGIN_ID } from './constants/plugin';\nimport {\n DEFAULT_ACTIONS,\n type DocumentActionPosition,\n type DocumentActionDescription,\n} from './pages/EditView/components/DocumentActions';\nimport { RichTextBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/BlocksEditor';\nimport { defaultBlocksStore } from './pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore';\nimport {\n DEFAULT_HEADER_ACTIONS,\n type HeaderActionDescription,\n} from './pages/EditView/components/Header';\nimport { ActionsPanel, type PanelDescription } from './pages/EditView/components/Panels';\nimport {\n DEFAULT_BULK_ACTIONS,\n type BulkActionDescription,\n} from './pages/ListView/components/BulkActions/Actions';\nimport { DEFAULT_TABLE_ROW_ACTIONS } from './pages/ListView/components/TableActions';\n\nimport type { Document } from './hooks/useDocument';\nimport type { DocumentMetadata } from '../../shared/contracts/collection-types';\nimport type { DescriptionComponent, PluginConfig } from '@strapi/admin/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * Configuration Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DescriptionReducer<Config extends object> = (prev: Config[]) => Config[];\ntype DescriptionObjReducer<Config extends object> = (prev: Config) => Config;\n\ninterface EditViewContext {\n /**\n * This will ONLY be null, if the content-type\n * does not have draft & published enabled.\n */\n activeTab: 'draft' | 'published' | null;\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n document?: Document;\n /**\n * this will be undefined if someone is creating an entry.\n */\n documentId?: string;\n /**\n * this will be undefined if someone is creating an entry.\n */\n meta?: DocumentMetadata;\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface ListViewContext {\n /**\n * Will be either 'single-types' | 'collection-types'\n */\n collectionType: string;\n /**\n * The current selected documents in the table\n */\n documents: Document[];\n /**\n * The current content-type's model.\n */\n model: string;\n}\n\ninterface PanelComponentProps extends EditViewContext {}\n\ninterface PanelComponent extends DescriptionComponent<PanelComponentProps, PanelDescription> {\n /**\n * The defaults are added by Strapi only, if you're providing your own component,\n * you do not need to provide this.\n */\n type?: 'actions' | 'releases';\n}\n\ninterface DocumentActionProps extends EditViewContext {}\n\ninterface DocumentActionComponent extends DescriptionComponent<\n DocumentActionProps,\n DocumentActionDescription\n> {\n type?:\n | 'clone'\n | 'configure-the-view'\n | 'delete'\n | 'discard'\n | 'edit'\n | 'edit-the-model'\n | 'history'\n | 'publish'\n | 'unpublish'\n | 'update';\n position?: DocumentActionDescription['position'];\n}\n\ninterface HeaderActionProps extends EditViewContext {}\n\ninterface HeaderActionComponent extends DescriptionComponent<\n HeaderActionProps,\n HeaderActionDescription\n> {}\n\ninterface BulkActionComponentProps extends ListViewContext {}\n\ninterface BulkActionComponent extends DescriptionComponent<\n BulkActionComponentProps,\n BulkActionDescription\n> {\n type?: 'delete' | 'publish' | 'unpublish';\n}\n\n/* -------------------------------------------------------------------------------------------------\n * ContentManager plugin\n * -----------------------------------------------------------------------------------------------*/\n\nclass ContentManagerPlugin {\n /**\n * The following properties are the stored ones provided by any plugins registering with\n * the content-manager. The function calls however, need to be called at runtime in the\n * application, so instead we collate them and run them later with the complete list incl.\n * ones already registered & the context of the view.\n */\n richTextBlocksStore: RichTextBlocksStore = { ...defaultBlocksStore };\n bulkActions: BulkActionComponent[] = [...DEFAULT_BULK_ACTIONS];\n documentActions: DocumentActionComponent[] = [\n ...DEFAULT_ACTIONS,\n ...DEFAULT_TABLE_ROW_ACTIONS,\n ...DEFAULT_HEADER_ACTIONS,\n ];\n editViewSidePanels: PanelComponent[] = [ActionsPanel];\n headerActions: HeaderActionComponent[] = [];\n\n constructor() {}\n\n addRichTextBlocks(blocks: RichTextBlocksStore): void;\n addRichTextBlocks(blocks: DescriptionObjReducer<RichTextBlocksStore>): void;\n addRichTextBlocks(blocks: RichTextBlocksStore | DescriptionObjReducer<RichTextBlocksStore>) {\n if (typeof blocks === 'function') {\n const result = blocks(this.richTextBlocksStore);\n if (typeof result !== 'object' || result === null) {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(result)}`\n );\n }\n this.richTextBlocksStore = result;\n } else if (typeof blocks === 'object') {\n this.richTextBlocksStore = { ...this.richTextBlocksStore, ...blocks };\n } else {\n throw new Error(\n `Expected the \\`blocks\\` passed to \\`addRichTextBlocks\\` to be an object or a function, but received ${getPrintableType(\n blocks\n )}`\n );\n }\n }\n\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent>): void;\n addEditViewSidePanel(panels: PanelComponent[]): void;\n addEditViewSidePanel(panels: DescriptionReducer<PanelComponent> | PanelComponent[]) {\n if (Array.isArray(panels)) {\n validateDescriptionItems(panels, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = [...this.editViewSidePanels, ...panels];\n } else if (typeof panels === 'function') {\n const result = panels(this.editViewSidePanels);\n validateDescriptionItems(result, 'addEditViewSidePanel', 'panels');\n this.editViewSidePanels = result;\n } else {\n throw new Error(\n `Expected the \\`panels\\` passed to \\`addEditViewSidePanel\\` to be an array or a function, but received ${getPrintableType(\n panels\n )}`\n );\n }\n }\n\n addDocumentAction(actions: DescriptionReducer<DocumentActionComponent>): void;\n addDocumentAction(actions: DocumentActionComponent[]): void;\n addDocumentAction(\n actions: DescriptionReducer<DocumentActionComponent> | DocumentActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentAction', 'actions');\n this.documentActions = [...this.documentActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.documentActions);\n validateDescriptionItems(result, 'addDocumentAction', 'actions');\n this.documentActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addDocumentHeaderAction(actions: DescriptionReducer<HeaderActionComponent>): void;\n addDocumentHeaderAction(actions: HeaderActionComponent[]): void;\n addDocumentHeaderAction(\n actions: DescriptionReducer<HeaderActionComponent> | HeaderActionComponent[]\n ) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addDocumentHeaderAction', 'actions');\n this.headerActions = [...this.headerActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.headerActions);\n validateDescriptionItems(result, 'addDocumentHeaderAction', 'actions');\n this.headerActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addDocumentHeaderAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n addBulkAction(actions: DescriptionReducer<BulkActionComponent>): void;\n addBulkAction(actions: BulkActionComponent[]): void;\n addBulkAction(actions: DescriptionReducer<BulkActionComponent> | BulkActionComponent[]) {\n if (Array.isArray(actions)) {\n validateDescriptionItems(actions, 'addBulkAction', 'actions');\n this.bulkActions = [...this.bulkActions, ...actions];\n } else if (typeof actions === 'function') {\n const result = actions(this.bulkActions);\n validateDescriptionItems(result, 'addBulkAction', 'actions');\n this.bulkActions = result;\n } else {\n throw new Error(\n `Expected the \\`actions\\` passed to \\`addBulkAction\\` to be an array or a function, but received ${getPrintableType(\n actions\n )}`\n );\n }\n }\n\n get config() {\n return {\n id: PLUGIN_ID,\n name: 'Content Manager',\n injectionZones: INJECTION_ZONES,\n apis: {\n addBulkAction: this.addBulkAction.bind(this),\n addDocumentAction: this.addDocumentAction.bind(this),\n addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),\n addEditViewSidePanel: this.addEditViewSidePanel.bind(this),\n addRichTextBlocks: this.addRichTextBlocks.bind(this),\n getBulkActions: () => this.bulkActions,\n getDocumentActions: (position?: DocumentActionPosition) => {\n /**\n * When possible, pre-filter the actions by the components static position property.\n * This avoids rendering the actions in multiple places where they weren't displayed,\n * which wasn't visible but created issues with useEffect for instance.\n * The response should still be filtered by the position, as the static property is new\n * and not mandatory to avoid a breaking change.\n */\n if (position) {\n return this.documentActions.filter((action) => {\n return action.position == undefined || [action.position].flat().includes(position);\n });\n }\n\n return this.documentActions;\n },\n getEditViewSidePanels: () => this.editViewSidePanels,\n getHeaderActions: () => this.headerActions,\n getRichTextBlocks: () => ({ ...this.richTextBlocksStore }),\n },\n } satisfies PluginConfig;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getPrintableType\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Gets the human-friendly printable type name for the given value, for instance it will yield\n * `array` instead of `object`, as the native `typeof` operator would do.\n */\nconst getPrintableType = (value: unknown): string => {\n const nativeType = typeof value;\n\n if (nativeType === 'object') {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (value instanceof Object && value.constructor.name !== 'Object') {\n return value.constructor.name;\n }\n }\n\n return nativeType;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * validateDescriptionItems\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Descriptions must be functions (they're rendered as components so hooks can be used\n * inside them), not plain objects. Passing a plain object crashes deep inside\n * `DescriptionComponentRenderer` with an unhelpful `description is not a function` error, so we\n * validate eagerly here to fail fast with a clear message pointing at the offending API call.\n */\nconst validateDescriptionItems = (items: unknown[], apiName: string, argName: string): void => {\n items.forEach((item, index) => {\n if (typeof item !== 'function') {\n throw new Error(\n `Expected every item in the \\`${argName}\\` array passed to \\`${apiName}\\` to be a function that returns a description object, but received ${getPrintableType(\n item\n )} at index ${index}. Did you forget to wrap it in a function, e.g. \\`() => ({ ...yourAction })\\`?`\n );\n }\n });\n};\n\nexport { ContentManagerPlugin };\nexport type {\n EditViewContext,\n ListViewContext,\n BulkActionComponent,\n BulkActionComponentProps,\n BulkActionDescription,\n DescriptionComponent,\n DescriptionReducer,\n PanelComponentProps,\n PanelComponent,\n PanelDescription,\n DocumentActionComponent,\n DocumentActionDescription,\n DocumentActionProps,\n HeaderActionComponent,\n HeaderActionDescription,\n HeaderActionProps,\n};\n"],"names":["ContentManagerPlugin","addRichTextBlocks","blocks","result","richTextBlocksStore","Error","getPrintableType","addEditViewSidePanel","panels","Array","isArray","validateDescriptionItems","editViewSidePanels","addDocumentAction","actions","documentActions","addDocumentHeaderAction","headerActions","addBulkAction","bulkActions","config","id","PLUGIN_ID","name","injectionZones","INJECTION_ZONES","apis","bind","getBulkActions","getDocumentActions","position","filter","action","undefined","flat","includes","getEditViewSidePanels","getHeaderActions","getRichTextBlocks","defaultBlocksStore","DEFAULT_BULK_ACTIONS","DEFAULT_ACTIONS","DEFAULT_TABLE_ROW_ACTIONS","DEFAULT_HEADER_ACTIONS","ActionsPanel","value","nativeType","Object","items","apiName","argName","forEach","item","index"],"mappings":";;;;;;;;;AA0HA;;AAEkG,qGAElG,MAAMA,oBAAAA,CAAAA;AAqBJC,IAAAA,iBAAAA,CAAkBC,MAAwE,EAAE;QAC1F,IAAI,OAAOA,WAAW,UAAA,EAAY;AAChC,YAAA,MAAMC,MAAAA,GAASD,MAAAA,CAAO,IAAI,CAACE,mBAAmB,CAAA;AAC9C,YAAA,IAAI,OAAOD,MAAAA,KAAW,QAAA,IAAYA,MAAAA,KAAW,IAAA,EAAM;AACjD,gBAAA,MAAM,IAAIE,KAAAA,CACR,CAAC,oGAAoG,EAA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