@webiny/app-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/ContentEntriesModule.js +3 -3
  2. package/ContentEntriesModule.js.map +1 -1
  3. package/HeadlessCMS.js +7 -2
  4. package/HeadlessCMS.js.map +1 -1
  5. package/admin/RoutesConfig.js +14 -1
  6. package/admin/RoutesConfig.js.map +1 -1
  7. package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
  8. package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
  9. package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
  10. package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
  11. package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
  12. package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
  13. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
  14. package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
  15. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
  16. package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
  17. package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
  18. package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
  19. package/admin/components/ContentModelEditor/evaluateExpression.js +4 -0
  20. package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
  21. package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
  22. package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
  23. package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
  24. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
  25. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
  26. package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
  27. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
  28. package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
  29. package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
  30. package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
  31. package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
  32. package/admin/components/FieldEditor/Field.js +1 -1
  33. package/admin/components/FieldEditor/Field.js.map +1 -1
  34. package/admin/components/FieldEditor/FieldEditor.js +2 -2
  35. package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
  36. package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
  37. package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
  38. package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
  39. package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
  40. package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
  41. package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
  42. package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
  43. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
  44. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
  45. package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
  46. package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
  47. package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
  48. package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
  49. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
  50. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
  51. package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
  52. package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
  53. package/admin/config/contentEntries/list/Browser/index.js +2 -0
  54. package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
  55. package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
  56. package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
  57. package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
  58. package/admin/graphql/contentModels.d.ts +1 -1
  59. package/admin/graphql/contentModels.js +2 -1
  60. package/admin/graphql/contentModels.js.map +1 -1
  61. package/admin/plugins/editor/formSettings/components/GeneralSettings.js +24 -1
  62. package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
  63. package/exports/admin/cms/entry/editor.d.ts +1 -0
  64. package/exports/admin/cms/entry/editor.js +1 -0
  65. package/exports/admin/cms/entry/list.d.ts +2 -0
  66. package/exports/admin/cms/entry/list.js +2 -0
  67. package/exports/admin/cms.d.ts +2 -0
  68. package/exports/admin/cms.js +2 -0
  69. package/features/contentEntry/EntryGraphQLFields.js +1 -1
  70. package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
  71. package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
  72. package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
  73. package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
  74. package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
  75. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
  76. package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
  77. package/features/contentEntry/refTypes.d.ts +7 -0
  78. package/features/contentEntry/refTypes.js.map +1 -1
  79. package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
  80. package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
  81. package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
  82. package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
  83. package/features/formModel/mappers/AssetFieldMapper.js +13 -0
  84. package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
  85. package/features/formModel/mappers/index.js +2 -0
  86. package/features/formModel/mappers/index.js.map +1 -1
  87. package/features/model/updateModel/UpdateModelGateway.js +1 -0
  88. package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
  89. package/index.d.ts +1 -1
  90. package/index.js +1 -1
  91. package/package.json +24 -24
  92. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +4 -0
  93. package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
  94. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +6 -0
  95. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
  96. package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
  97. package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +14 -0
  98. package/presentation/contentEntries/preview/LivePreviewPresenter.js +33 -0
  99. package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
  100. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
  101. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +27 -0
  102. package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
  103. package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
  104. package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
  105. package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
  106. package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
  107. package/presentation/contentEntries/preview/PreviewDecorator.js +48 -0
  108. package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
  109. package/presentation/contentEntries/preview/PreviewPane.d.ts +9 -0
  110. package/presentation/contentEntries/preview/PreviewPane.js +181 -0
  111. package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
  112. package/presentation/contentEntries/preview/abstractions.d.ts +16 -0
  113. package/presentation/contentEntries/preview/abstractions.js +5 -0
  114. package/presentation/contentEntries/preview/abstractions.js.map +1 -0
  115. package/presentation/contentEntries/preview/feature.d.ts +3 -0
  116. package/presentation/contentEntries/preview/feature.js +17 -0
  117. package/presentation/contentEntries/preview/feature.js.map +1 -0
  118. package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +5 -0
  119. package/presentation/contentEntries/preview/resolvePreviewUrl.js +29 -0
  120. package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
  121. package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
  122. package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
  123. package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
  124. package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
  125. package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
  126. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
  127. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
  128. package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
  129. package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
  130. package/presentation/contentEntries/views/ContentEntriesListLayout.js +3 -2
  131. package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
  132. package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
  133. package/presentation/contentEntries/views/ContentEntryFormView.js +5 -6
  134. package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
  135. package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
  136. package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
  137. package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
  138. package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
  139. package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
  140. package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
  141. package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
  142. package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
  143. package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
  144. package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
  145. package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
  146. package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
  147. package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
  148. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
  149. package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
  150. package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
  151. package/presentation/contentModels/components/ContentModels.d.ts +2 -2
  152. package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
  153. package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
  154. package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
  155. package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
  156. package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
  157. package/presentation/fieldEditor/groups/ValidationsGroup.js +1 -1
  158. package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
  159. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
  160. package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
  161. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
  162. package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
  163. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
  164. package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
  165. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
  166. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
  167. package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
  168. package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
  169. package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
  170. package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
  171. package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
  172. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
  173. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
  174. package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
  175. package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
  176. package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
  177. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
  178. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
  179. package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
  180. package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
  181. package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
  182. package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
  183. package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
  184. package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
  185. package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
  186. package/presentation/fieldTypes/abstractions.d.ts +12 -0
  187. package/presentation/fieldTypes/abstractions.js.map +1 -1
  188. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
  189. package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
  190. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
  191. package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
  192. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
  193. package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
  194. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
  195. package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
  196. package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
  197. package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
  198. package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
  199. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
  200. package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
  201. package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
  202. package/presentation/importContentModels/components/DataList.d.ts +2 -2
  203. package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
  204. package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
  205. package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
  206. package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
  207. package/presentation/modelGroup/ModelGroupPresenter.js +7 -9
  208. package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
  209. package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
  210. package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
  211. package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"admin/components/FieldEditor/FieldEditorContext.js","sources":["../../../../src/admin/components/FieldEditor/FieldEditorContext.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport dot from \"dot-prop-immutable\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport { useContainer } from \"@webiny/app\";\nimport type {\n CmsEditorFieldId,\n CmsEditorFieldsLayout,\n CmsModelField,\n CmsLayoutField,\n CmsEditorLayoutCell,\n DragSource,\n FieldLayoutPosition\n} from \"~/types.js\";\nimport { isLayoutField } from \"~/types.js\";\nimport * as utils from \"./utils/index.js\";\nimport type { FieldEditorProps } from \"./FieldEditor.js\";\nimport type { DragSourceMonitor } from \"react-dnd\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\nimport type { DragObject } from \"../Droppable.js\";\nimport { CmsFieldType, type ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport {\n CmsFieldRenderer,\n type ICmsFieldRenderer\n} from \"~/presentation/fieldRenderers/abstractions.js\";\nimport {\n CmsLayoutFieldType,\n type ICmsLayoutFieldType\n} from \"~/presentation/fieldTypes/abstractions.js\";\n\ninterface DropTarget {\n row: number;\n index: number | null;\n}\n\n/**\n * Property in GetFieldParams can be any key from CmsEditorField, but TS does not allow union types\n */\ninterface GetFieldParams {\n id?: string;\n fieldId?: string;\n}\ninterface InsertFieldParams {\n field: CmsModelField;\n position: FieldLayoutPosition;\n}\ninterface AddFieldCallable {\n (field: CmsModelField): void;\n}\ninterface RemoveFieldCallable {\n (fieldId: string): void;\n}\ninterface MoveFieldParams {\n field: CmsEditorFieldId | CmsModelField;\n position: FieldLayoutPosition;\n}\ninterface GetFieldsInLayoutCallable {\n (): (CmsModelField | CmsLayoutField)[][];\n}\ninterface InsertLayoutCellCallable {\n (field: Omit<CmsLayoutField, \"id\"> | CmsLayoutField, position: FieldLayoutPosition): void;\n}\ninterface UpdateLayoutCellCallable {\n (fieldId: string, field: CmsLayoutField): void;\n}\ninterface DeleteLayoutCellCallable {\n (fieldId: string): void;\n}\ninterface MoveLayoutCellCallable {\n (fieldId: string, position: FieldLayoutPosition): void;\n}\ninterface GetLayoutFieldTypeCallable {\n (type: string): ICmsLayoutFieldType | undefined;\n}\ninterface GetFieldCallable {\n (query: GetFieldParams): CmsModelField | undefined;\n}\ninterface GetFieldRendererCallable {\n (rendererName: string): ICmsFieldRenderer | undefined;\n}\ninterface OnFieldDropCallable {\n (source: Partial<DragSource>, target: DropTarget): void;\n}\ninterface InsertFieldCallable {\n (params: InsertFieldParams): void;\n}\ninterface MoveFieldCallable {\n (params: MoveFieldParams): void;\n}\ninterface OnEndDragCallable<DragObject = unknown, DropResult = unknown> {\n (item: DragSource, monitor: DragSourceMonitor<DragObject, DropResult>): void;\n}\ninterface MoveRowCallable {\n (source: number, destination: number): void;\n}\ninterface UpdateFieldCallable {\n (field: CmsModelField): void;\n}\ninterface DeleteFieldCallable {\n (field: Pick<CmsModelField, \"id\">): void;\n}\nexport interface IsVisibleCallable {\n (item: DragSource): boolean;\n}\ninterface NoConflictCallable {\n (cb?: IsVisibleCallable): (item: DragSource) => boolean;\n}\nexport interface FieldEditorContext {\n fields: (CmsModelField | CmsLayoutField)[][];\n noConflict: NoConflictCallable;\n layout: CmsEditorFieldsLayout;\n onChange?: (data: any) => void;\n getFieldsInLayout: GetFieldsInLayoutCallable;\n getFieldType: (type: string) => ICmsFieldType | undefined;\n getField: GetFieldCallable;\n getFieldRenderer: GetFieldRendererCallable;\n editField: (field: CmsModelField | null) => void;\n field: CmsModelField | null;\n parent?: CmsModelField;\n parentEditorContext?: FieldEditorContext;\n depth: number;\n dropTarget: DropTarget;\n onFieldDrop: OnFieldDropCallable;\n onEndDrag: OnEndDragCallable;\n insertField: InsertFieldCallable;\n moveField: MoveFieldCallable;\n moveRow: MoveRowCallable;\n updateField: UpdateFieldCallable;\n deleteField: DeleteFieldCallable;\n insertLayoutCell: InsertLayoutCellCallable;\n updateLayoutCell: UpdateLayoutCellCallable;\n deleteLayoutCell: DeleteLayoutCellCallable;\n moveLayoutCell: MoveLayoutCellCallable;\n getLayoutFieldType: GetLayoutFieldTypeCallable;\n addField: AddFieldCallable;\n removeField: RemoveFieldCallable;\n}\n\ninterface FieldEditorProviderProps extends FieldEditorProps {\n children: React.ReactElement;\n}\n\ntype DropResult = {\n dropTarget: string | null;\n};\n\nexport const FieldEditorContext = React.createContext<FieldEditorContext | undefined>(undefined);\n/**\n * We try to generate the random id string but with the check that it does not exist already.\n * Chances that the same string exists are quite small, but let's check it anyway.\n *\n * In most cases, there will be no iterations anyway...\n */\nconst maxGenerateIdIterations = 100;\nconst generateFieldId = (layout: string[]): string => {\n let id = generateAlphaNumericLowerCaseId(8);\n\n let iteration = 0;\n while (layout.includes(id) && iteration < maxGenerateIdIterations) {\n id = generateAlphaNumericLowerCaseId(8);\n iteration++;\n }\n if (iteration >= maxGenerateIdIterations) {\n throw new Error(`Could not generate field ID in ${maxGenerateIdIterations} iterations.`);\n }\n return id;\n};\n\ninterface State {\n layout: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n field: CmsModelField | null;\n dropTarget: DropTarget;\n}\nexport const FieldEditorProvider = ({\n parent,\n fields,\n layout,\n onChange,\n children\n}: FieldEditorProviderProps) => {\n // We need to determine depth of this provider so we can render drop zones with correct z-indexes.\n let depth = 0;\n let parentEditorContext: FieldEditorContext | undefined;\n try {\n const editor = useModelFieldEditor();\n depth = editor.depth + 1;\n parentEditorContext = editor;\n } catch {\n // There's no parent provider, so this is the top-level one.\n }\n\n const container = useContainer();\n const fieldTypesMap = useMemo(() => {\n const all = container.resolveAll(CmsFieldType);\n const map = new Map<string, ICmsFieldType>();\n for (const ft of all) {\n map.set(ft.type, ft);\n }\n return map;\n }, [container]);\n\n const fieldRenderersMap = useMemo(() => {\n const all = container.resolveAll(CmsFieldRenderer);\n const map = new Map<string, ICmsFieldRenderer>();\n for (const r of all) {\n map.set(r.rendererName, r);\n }\n return map;\n }, [container]);\n\n const layoutFieldTypesMap = useMemo(() => {\n const all = container.resolveAll(CmsLayoutFieldType);\n const map = new Map<string, ICmsLayoutFieldType>();\n for (const lft of all) {\n map.set(lft.type, lft);\n }\n return map;\n }, [container]);\n\n const [state, setState] = useState<State>({\n layout,\n fields,\n field: null,\n dropTarget: {\n row: -1,\n index: null\n }\n });\n\n useDeepCompareEffect(() => {\n onChange({ fields: state.fields, layout: state.layout });\n }, [state.fields, state.layout]);\n\n const editField = useCallback((field: CmsModelField | null) => {\n setState(state => ({ ...state, field }));\n }, []);\n\n const onDropTarget = {\n dropTarget: parent ? parent.fieldId : null\n };\n\n const onFieldDrop = useCallback<OnFieldDropCallable>((source, dropTarget) => {\n const { pos, type, fieldType, field, fields = [] } = source;\n\n const parentId = parent ? parent.fieldId : null;\n\n if (type === \"row\") {\n if (parentId !== source.parent) {\n // We're dragging an existing row from another fieldset\n fields.forEach((field, index) => {\n insertField({\n field,\n position: {\n row: dropTarget.row,\n index: index === 0 ? null : index\n }\n });\n });\n } else if (pos && pos.row !== undefined) {\n // We're dragging a row within the same fieldset\n moveRow(pos.row, dropTarget.row);\n }\n\n return onDropTarget;\n }\n\n // Handle new layout field drops (separator, alert, tabs, etc.)\n if (type === \"newLayoutField\") {\n const lft = getLayoutFieldType(source.layoutFieldType || \"\");\n if (!lft) {\n return null;\n }\n const layoutField = lft.createField();\n insertLayoutCell(layoutField, dropTarget);\n return null;\n }\n\n // Handle moving an existing layout field to a new position\n if (type === \"layoutField\") {\n if (source.layoutField) {\n if (parentId !== source.parent) {\n // Cross-parent: insert a copy of the layout field into this context\n insertLayoutCell(source.layoutField, dropTarget);\n // Also add any fields carried by this layout field (e.g. fields inside tabs)\n if (fields.length > 0) {\n for (const f of fields) {\n addField(f);\n }\n }\n } else {\n // Same parent: move within this context\n moveLayoutCell(source.layoutField.id, dropTarget);\n }\n }\n return onDropTarget;\n }\n\n // If source pos is set, we are moving an existing field.\n if (pos) {\n if (!field) {\n return onDropTarget;\n }\n if (parentId !== source.parent) {\n // We're dragging an existing field from another fieldset\n insertField({ field, position: dropTarget });\n } else {\n // We're dragging a field within the same fieldset\n moveField({ field, position: dropTarget });\n }\n return onDropTarget;\n }\n\n if (!fieldType) {\n return null;\n }\n const ft = fieldTypesMap.get(fieldType);\n if (!ft) {\n return null;\n }\n\n const fieldData = ft.createField() as CmsModelField;\n\n if (ft.canEditSettings !== false) {\n editField(fieldData);\n setState(state => ({\n ...state,\n dropTarget\n }));\n } else {\n insertField({ field: fieldData, position: dropTarget });\n }\n return null;\n }, []);\n\n const onEndDrag: OnEndDragCallable<DragObject, DropResult> = (\n { type, field, fields, layoutField },\n monitor\n ) => {\n if (!monitor.didDrop()) {\n return;\n }\n\n // Check if we dropped outside of the source fieldset, and if yes, remove the item from the original parent.\n const monitorResult = monitor.getDropResult();\n const parentId = parent ? parent.fieldId : null;\n if (monitorResult?.dropTarget === parentId) {\n return;\n }\n\n if (type === \"layoutField\" && layoutField?.id) {\n deleteLayoutCell(layoutField.id);\n return;\n }\n\n const removeFields = type === \"row\" ? fields || [] : field ? [field] : [];\n removeFields.forEach(field => deleteField(field));\n };\n\n const getFieldsInLayout: GetFieldsInLayoutCallable = () => {\n // Replace every field ID with actual field object, pass through layout fields.\n return state.layout\n .filter(arr => arr.length)\n .map(row => {\n return row\n .map((cell: CmsEditorLayoutCell) => {\n if (isLayoutField(cell)) {\n return cell;\n }\n return getField({ id: cell });\n })\n .filter(Boolean);\n })\n .filter(row => {\n return row.length > 0;\n }) as (CmsModelField | CmsLayoutField)[][];\n };\n\n const getFieldRenderer: GetFieldRendererCallable = name => {\n return fieldRenderersMap.get(name);\n };\n\n /**\n * Checks if field of given type already exists in the list of fields.\n */\n const getField: GetFieldCallable = query => {\n return state.fields.find(field => {\n for (const key in query) {\n if (!(key in field)) {\n return false;\n }\n\n if (field[key as keyof typeof field] !== query[key as keyof typeof query]) {\n return false;\n }\n }\n\n return true;\n });\n };\n\n /**\n * Inserts a new field into the target position.\n */\n const insertField: InsertFieldCallable = ({ field, position }) => {\n if (!field.id) {\n field.id = generateFieldId(\n layout.flat().filter((c): c is string => typeof c === \"string\")\n );\n }\n\n if (!field.type) {\n throw new Error(`Field \"type\" missing.`);\n }\n\n if (!fieldTypesMap.has(field.type)) {\n throw new Error(`No field type found for \"${field.type}\".`);\n }\n\n setState(prev => {\n const next: State = {\n ...prev,\n fields: (prev.fields || []).concat(field)\n };\n\n // Move field to position where it was dropped.\n return utils.moveField({ field, position, data: next });\n });\n };\n\n /**\n * Moves field to the given target position.\n */\n const moveField: MoveFieldCallable = ({ field, position }) => {\n setState(data => {\n return utils.moveField<State>({ field, position, data });\n });\n };\n\n /**\n * Moves row to a destination row.\n */\n const moveRow: MoveRowCallable = (source, destination) => {\n setState(data => {\n return utils.moveRow({ data, source, destination });\n });\n };\n\n /**\n * Updates field.\n */\n const updateField: UpdateFieldCallable = field => {\n setState(data => {\n for (let i = 0; i < data.fields.length; i++) {\n if (data.fields[i].id === field.id) {\n return dot.set(data, `fields.${i}`, field);\n }\n }\n return data;\n });\n };\n\n /**\n * Deletes a field (both from the list of field and the layout).\n */\n const deleteField: DeleteFieldCallable = field => {\n setState(data => {\n return utils.deleteField({ field, data });\n });\n };\n\n /**\n * Add a field to the fields array without placing it in the layout.\n * Used by tabs to hoist fields to the parent context.\n */\n const addField: AddFieldCallable = field => {\n setState(prev => {\n // Don't add if already exists\n if (prev.fields.some(f => f.id === field.id)) {\n return prev;\n }\n return { ...prev, fields: [...prev.fields, field] };\n });\n };\n\n /**\n * Remove a field from the fields array by ID.\n * Used by tabs to un-hoist fields from the parent context.\n */\n const removeField: RemoveFieldCallable = fieldId => {\n setState(prev => ({\n ...prev,\n fields: prev.fields.filter(f => f.id !== fieldId)\n }));\n };\n\n const getLayoutFieldType: GetLayoutFieldTypeCallable = type => {\n return layoutFieldTypesMap.get(type);\n };\n\n /**\n * Insert a layout field into the layout at the given position.\n */\n const insertLayoutCell: InsertLayoutCellCallable = (layoutField, position) => {\n // Auto-assign a unique ID to the layout field.\n const cell = {\n ...layoutField,\n id: generateAlphaNumericLowerCaseId(8)\n } as CmsLayoutField;\n\n setState(prev => {\n const newLayout = [...prev.layout.map(row => [...row])];\n const { row } = position;\n\n // Layout fields always occupy a full row.\n newLayout.splice(row, 0, [cell]);\n\n return { ...prev, layout: newLayout.filter(r => r.length > 0) };\n });\n };\n\n /**\n * Update a layout field found by its ID.\n */\n const updateLayoutCell: UpdateLayoutCellCallable = (fieldId, layoutField) => {\n setState(prev => {\n const newLayout = prev.layout.map(row =>\n row.map(cell => {\n if (isLayoutField(cell) && cell.id === fieldId) {\n return { ...layoutField, id: fieldId };\n }\n return cell;\n })\n );\n return { ...prev, layout: newLayout };\n });\n };\n\n /**\n * Delete a layout field found by its ID.\n * If it's a tabs layout field, also remove all hoisted fields from the fields array.\n */\n const deleteLayoutCell: DeleteLayoutCellCallable = fieldId => {\n setState(prev => {\n let fields = prev.fields;\n\n // Find the descriptor to check if it's tabs (need to clean up hoisted fields)\n for (const row of prev.layout) {\n for (const cell of row) {\n if (isLayoutField(cell) && cell.id === fieldId && cell.type === \"tabs\") {\n const tabsField =\n cell as import(\"@webiny/app-headless-cms-common/types/model.js\").CmsTabLayoutField;\n const fieldIdsInTabs = new Set<string>();\n tabsField.tabs.forEach(tab => {\n tab.layout.forEach(r => {\n r.forEach(c => {\n if (typeof c === \"string\") {\n fieldIdsInTabs.add(c);\n }\n });\n });\n });\n if (fieldIdsInTabs.size > 0) {\n fields = fields.filter(f => !fieldIdsInTabs.has(f.id));\n }\n }\n }\n }\n\n const newLayout = prev.layout.map(row =>\n row.filter(cell => !(isLayoutField(cell) && cell.id === fieldId))\n );\n\n return {\n ...prev,\n fields,\n layout: newLayout.filter(r => r.length > 0)\n };\n });\n };\n\n /**\n * Move a layout field (found by its ID) to a new position.\n */\n const moveLayoutCell: MoveLayoutCellCallable = (fieldId, position) => {\n setState(prev => {\n // Find the layout field by ID.\n let layoutField: CmsLayoutField | undefined;\n let sourceRow = -1;\n\n for (let ri = 0; ri < prev.layout.length; ri++) {\n for (const cell of prev.layout[ri]) {\n if (isLayoutField(cell) && cell.id === fieldId) {\n layoutField = cell;\n sourceRow = ri;\n break;\n }\n }\n if (layoutField) {\n break;\n }\n }\n\n if (!layoutField || sourceRow === -1) {\n return prev;\n }\n\n // 1. Remove the layout field from its source position.\n const withoutSource = prev.layout.map(row =>\n row.filter(cell => !(isLayoutField(cell) && cell.id === fieldId))\n );\n\n // 2. Was the source row emptied?\n const sourceRowEmptied = withoutSource[sourceRow].length === 0;\n\n // 3. Calculate the effective target row index.\n // The drop target row was computed against the original layout.\n // If we emptied a source row that was BEFORE the target, shift down by 1.\n let targetRow = position.row;\n if (sourceRowEmptied && sourceRow < targetRow) {\n targetRow--;\n }\n\n // 4. Remove empty rows.\n const cleaned = withoutSource.filter(r => r.length > 0);\n\n // 5. Clamp target row and insert the layout field as its own row.\n targetRow = Math.max(0, Math.min(targetRow, cleaned.length));\n cleaned.splice(targetRow, 0, [layoutField]);\n\n return { ...prev, layout: cleaned };\n });\n };\n\n const noConflict: NoConflictCallable = useCallback(\n (isVisible?: IsVisibleCallable) => item => {\n const sameParent = item.parent === onDropTarget.dropTarget;\n const draggedFields: string[] = [];\n switch (item.type) {\n case \"row\":\n (item.fields || []).forEach(field => draggedFields.push(field.fieldId));\n break;\n case \"field\":\n if (!item.field) {\n break;\n }\n draggedFields.push(item.field.fieldId);\n break;\n default:\n break;\n }\n\n if (\n draggedFields.length &&\n !sameParent &&\n fields.some(field => draggedFields.includes(field.fieldId))\n ) {\n return false;\n }\n\n return typeof isVisible === \"function\" ? isVisible(item) : true;\n },\n [fields.map(f => f.fieldId).join(\".\")]\n );\n\n const value: FieldEditorContext = {\n parent,\n parentEditorContext,\n depth,\n getFieldsInLayout,\n getFieldType: (type: string) => fieldTypesMap.get(type),\n getFieldRenderer,\n getField,\n editField,\n field: state.field,\n dropTarget: state.dropTarget,\n onFieldDrop,\n onEndDrag,\n insertField,\n moveField,\n moveRow,\n updateField,\n deleteField,\n insertLayoutCell,\n updateLayoutCell,\n deleteLayoutCell,\n moveLayoutCell,\n getLayoutFieldType,\n addField,\n removeField,\n fields: getFieldsInLayout(),\n noConflict,\n layout: state.layout\n };\n\n return <FieldEditorContext.Provider value={value}>{children}</FieldEditorContext.Provider>;\n};\n"],"names":["FieldEditorContext","React","undefined","maxGenerateIdIterations","generateFieldId","layout","id","generateAlphaNumericLowerCaseId","iteration","Error","FieldEditorProvider","parent","fields","onChange","children","depth","parentEditorContext","editor","useModelFieldEditor","container","useContainer","fieldTypesMap","useMemo","all","CmsFieldType","map","Map","ft","fieldRenderersMap","CmsFieldRenderer","r","layoutFieldTypesMap","CmsLayoutFieldType","lft","state","setState","useState","useDeepCompareEffect","editField","useCallback","field","onDropTarget","onFieldDrop","source","dropTarget","pos","type","fieldType","parentId","index","insertField","moveRow","getLayoutFieldType","layoutField","insertLayoutCell","f","addField","moveLayoutCell","moveField","fieldData","onEndDrag","monitor","monitorResult","deleteLayoutCell","removeFields","deleteField","getFieldsInLayout","arr","row","cell","isLayoutField","getField","Boolean","getFieldRenderer","name","query","key","position","c","prev","next","utils","data","destination","updateField","i","dot","removeField","fieldId","newLayout","updateLayoutCell","tabsField","fieldIdsInTabs","Set","tab","sourceRow","ri","withoutSource","sourceRowEmptied","targetRow","cleaned","Math","noConflict","isVisible","item","sameParent","draggedFields","value"],"mappings":";;;;;;;;;;AAkJO,MAAMA,qBAAqB,WAAHA,GAAGC,MAAAA,aAAmB,CAAiCC;AAOtF,MAAMC,0BAA0B;AAChC,MAAMC,kBAAkB,CAACC;IACrB,IAAIC,KAAKC,gCAAgC;IAEzC,IAAIC,YAAY;IAChB,MAAOH,OAAO,QAAQ,CAACC,OAAOE,YAAYL,wBAAyB;QAC/DG,KAAKC,gCAAgC;QACrCC;IACJ;IACA,IAAIA,aAAaL,yBACb,MAAM,IAAIM,MAAM,CAAC,+BAA+B,EAAEN,wBAAwB,YAAY,CAAC;IAE3F,OAAOG;AACX;AAQO,MAAMI,sBAAsB,CAAC,EAChCC,MAAM,EACNC,MAAM,EACNP,MAAM,EACNQ,QAAQ,EACRC,QAAQ,EACe;IAEvB,IAAIC,QAAQ;IACZ,IAAIC;IACJ,IAAI;QACA,MAAMC,SAASC;QACfH,QAAQE,OAAO,KAAK,GAAG;QACvBD,sBAAsBC;IAC1B,EAAE,OAAM,CAER;IAEA,MAAME,YAAYC;IAClB,MAAMC,gBAAgBC,QAAQ;QAC1B,MAAMC,MAAMJ,UAAU,UAAU,CAACK;QACjC,MAAMC,MAAM,IAAIC;QAChB,KAAK,MAAMC,MAAMJ,IACbE,IAAI,G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C5F,OAAO,GAAG,CAAC2C,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;KAAK;IAG1C,MAAMoD,QAA4B;QAC9BhG;QACAK;QACAD;QACAmD;QACA,cAAc,CAACpB,OAAiBzB,cAAc,GAAG,CAACyB;QAClD2B;QACAF;QACAjC;QACA,OAAOJ,MAAM,KAAK;QAClB,YAAYA,MAAM,UAAU;QAC5BQ;QACAkB;QACAV;QACAQ;QACAP;QACAiC;QACAnB;QACAX;QACAoC;QACA3B;QACAN;QACAL;QACAI;QACA+B;QACA,QAAQrB;QACRoC;QACA,QAAQpE,MAAM,MAAM;IACxB;IAEA,OAAO,WAAP,GAAO,oBAAClC,mBAAmB,QAAQ;QAAC,OAAO2G;OAAQ7F;AACvD"}
1
+ {"version":3,"file":"admin/components/FieldEditor/FieldEditorContext.js","sources":["../../../../src/admin/components/FieldEditor/FieldEditorContext.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport dot from \"dot-prop-immutable\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport { useContainer } from \"@webiny/app\";\nimport type {\n CmsEditorFieldId,\n CmsEditorFieldsLayout,\n CmsModelField,\n CmsLayoutField,\n CmsEditorLayoutCell,\n DragSource,\n FieldLayoutPosition\n} from \"~/types.js\";\nimport { isLayoutField } from \"~/types.js\";\nimport * as utils from \"./utils/index.js\";\nimport type { FieldEditorProps } from \"./FieldEditor.js\";\nimport type { DragSourceMonitor } from \"react-dnd\";\nimport { useModelFieldEditor } from \"~/admin/components/FieldEditor/useModelFieldEditor.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\nimport type { DragObject } from \"../Droppable.js\";\nimport { CmsFieldType, type ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport {\n CmsFieldRenderer,\n type ICmsFieldRenderer\n} from \"~/presentation/fieldRenderers/abstractions.js\";\nimport {\n CmsLayoutFieldType,\n type ICmsLayoutFieldType\n} from \"~/presentation/fieldTypes/abstractions.js\";\n\ninterface DropTarget {\n row: number;\n index: number | null;\n}\n\n/**\n * Property in GetFieldParams can be any key from CmsEditorField, but TS does not allow union types\n */\ninterface GetFieldParams {\n id?: string;\n fieldId?: string;\n}\ninterface InsertFieldParams {\n field: CmsModelField;\n position: FieldLayoutPosition;\n}\ninterface AddFieldCallable {\n (field: CmsModelField): void;\n}\ninterface RemoveFieldCallable {\n (fieldId: string): void;\n}\ninterface MoveFieldParams {\n field: CmsEditorFieldId | CmsModelField;\n position: FieldLayoutPosition;\n}\ninterface GetFieldsInLayoutCallable {\n (): (CmsModelField | CmsLayoutField)[][];\n}\ninterface InsertLayoutCellCallable {\n (field: Omit<CmsLayoutField, \"id\"> | CmsLayoutField, position: FieldLayoutPosition): void;\n}\ninterface UpdateLayoutCellCallable {\n (fieldId: string, field: CmsLayoutField): void;\n}\ninterface DeleteLayoutCellCallable {\n (fieldId: string): void;\n}\ninterface MoveLayoutCellCallable {\n (fieldId: string, position: FieldLayoutPosition): void;\n}\ninterface GetLayoutFieldTypeCallable {\n (type: string): ICmsLayoutFieldType | undefined;\n}\ninterface GetFieldCallable {\n (query: GetFieldParams): CmsModelField | undefined;\n}\ninterface GetFieldRendererCallable {\n (rendererName: string): ICmsFieldRenderer | undefined;\n}\ninterface OnFieldDropCallable {\n (source: Partial<DragSource>, target: DropTarget): void;\n}\ninterface InsertFieldCallable {\n (params: InsertFieldParams): void;\n}\ninterface MoveFieldCallable {\n (params: MoveFieldParams): void;\n}\ninterface OnEndDragCallable<DragObject = unknown, DropResult = unknown> {\n (item: DragSource, monitor: DragSourceMonitor<DragObject, DropResult>): void;\n}\ninterface MoveRowCallable {\n (source: number, destination: number): void;\n}\ninterface UpdateFieldCallable {\n (field: CmsModelField): void;\n}\ninterface DeleteFieldCallable {\n (field: Pick<CmsModelField, \"id\">): void;\n}\nexport interface IsVisibleCallable {\n (item: DragSource): boolean;\n}\ninterface NoConflictCallable {\n (cb?: IsVisibleCallable): (item: DragSource) => boolean;\n}\nexport interface FieldEditorContext {\n fields: (CmsModelField | CmsLayoutField)[][];\n noConflict: NoConflictCallable;\n layout: CmsEditorFieldsLayout;\n onChange?: (data: any) => void;\n getFieldsInLayout: GetFieldsInLayoutCallable;\n getFieldType: (typeOrField: string | CmsModelField) => ICmsFieldType | undefined;\n getField: GetFieldCallable;\n getFieldRenderer: GetFieldRendererCallable;\n editField: (field: CmsModelField | null) => void;\n field: CmsModelField | null;\n parent?: CmsModelField;\n parentEditorContext?: FieldEditorContext;\n depth: number;\n dropTarget: DropTarget;\n onFieldDrop: OnFieldDropCallable;\n onEndDrag: OnEndDragCallable;\n insertField: InsertFieldCallable;\n moveField: MoveFieldCallable;\n moveRow: MoveRowCallable;\n updateField: UpdateFieldCallable;\n deleteField: DeleteFieldCallable;\n insertLayoutCell: InsertLayoutCellCallable;\n updateLayoutCell: UpdateLayoutCellCallable;\n deleteLayoutCell: DeleteLayoutCellCallable;\n moveLayoutCell: MoveLayoutCellCallable;\n getLayoutFieldType: GetLayoutFieldTypeCallable;\n addField: AddFieldCallable;\n removeField: RemoveFieldCallable;\n}\n\ninterface FieldEditorProviderProps extends FieldEditorProps {\n children: React.ReactElement;\n}\n\ntype DropResult = {\n dropTarget: string | null;\n};\n\nexport const FieldEditorContext = React.createContext<FieldEditorContext | undefined>(undefined);\n/**\n * We try to generate the random id string but with the check that it does not exist already.\n * Chances that the same string exists are quite small, but let's check it anyway.\n *\n * In most cases, there will be no iterations anyway...\n */\nconst maxGenerateIdIterations = 100;\nconst generateFieldId = (layout: string[]): string => {\n let id = generateAlphaNumericLowerCaseId(8);\n\n let iteration = 0;\n while (layout.includes(id) && iteration < maxGenerateIdIterations) {\n id = generateAlphaNumericLowerCaseId(8);\n iteration++;\n }\n if (iteration >= maxGenerateIdIterations) {\n throw new Error(`Could not generate field ID in ${maxGenerateIdIterations} iterations.`);\n }\n return id;\n};\n\ninterface State {\n layout: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n field: CmsModelField | null;\n dropTarget: DropTarget;\n}\nexport const FieldEditorProvider = ({\n parent,\n fields,\n layout,\n onChange,\n children\n}: FieldEditorProviderProps) => {\n // We need to determine depth of this provider so we can render drop zones with correct z-indexes.\n let depth = 0;\n let parentEditorContext: FieldEditorContext | undefined;\n try {\n const editor = useModelFieldEditor();\n depth = editor.depth + 1;\n parentEditorContext = editor;\n } catch {\n // There's no parent provider, so this is the top-level one.\n }\n\n const container = useContainer();\n const fieldTypesMap = useMemo(() => {\n const all = container.resolveAll(CmsFieldType);\n const map = new Map<string, ICmsFieldType>();\n for (const ft of all) {\n map.set(ft.type, ft);\n }\n return map;\n }, [container]);\n\n const fieldRenderersMap = useMemo(() => {\n const all = container.resolveAll(CmsFieldRenderer);\n const map = new Map<string, ICmsFieldRenderer>();\n for (const r of all) {\n map.set(r.rendererName, r);\n }\n return map;\n }, [container]);\n\n const layoutFieldTypesMap = useMemo(() => {\n const all = container.resolveAll(CmsLayoutFieldType);\n const map = new Map<string, ICmsLayoutFieldType>();\n for (const lft of all) {\n map.set(lft.type, lft);\n }\n return map;\n }, [container]);\n\n const [state, setState] = useState<State>({\n layout,\n fields,\n field: null,\n dropTarget: {\n row: -1,\n index: null\n }\n });\n\n useDeepCompareEffect(() => {\n onChange({ fields: state.fields, layout: state.layout });\n }, [state.fields, state.layout]);\n\n const editField = useCallback((field: CmsModelField | null) => {\n setState(state => ({ ...state, field }));\n }, []);\n\n const onDropTarget = {\n dropTarget: parent ? parent.fieldId : null\n };\n\n const onFieldDrop = useCallback<OnFieldDropCallable>((source, dropTarget) => {\n const { pos, type, fieldType, field, fields = [] } = source;\n\n const parentId = parent ? parent.fieldId : null;\n\n if (type === \"row\") {\n if (parentId !== source.parent) {\n // We're dragging an existing row from another fieldset\n fields.forEach((field, index) => {\n insertField({\n field,\n position: {\n row: dropTarget.row,\n index: index === 0 ? null : index\n }\n });\n });\n } else if (pos && pos.row !== undefined) {\n // We're dragging a row within the same fieldset\n moveRow(pos.row, dropTarget.row);\n }\n\n return onDropTarget;\n }\n\n // Handle new layout field drops (separator, alert, tabs, etc.)\n if (type === \"newLayoutField\") {\n const lft = getLayoutFieldType(source.layoutFieldType || \"\");\n if (!lft) {\n return null;\n }\n const layoutField = lft.createField();\n insertLayoutCell(layoutField, dropTarget);\n return null;\n }\n\n // Handle moving an existing layout field to a new position\n if (type === \"layoutField\") {\n if (source.layoutField) {\n if (parentId !== source.parent) {\n // Cross-parent: insert a copy of the layout field into this context\n insertLayoutCell(source.layoutField, dropTarget);\n // Also add any fields carried by this layout field (e.g. fields inside tabs)\n if (fields.length > 0) {\n for (const f of fields) {\n addField(f);\n }\n }\n } else {\n // Same parent: move within this context\n moveLayoutCell(source.layoutField.id, dropTarget);\n }\n }\n return onDropTarget;\n }\n\n // If source pos is set, we are moving an existing field.\n if (pos) {\n if (!field) {\n return onDropTarget;\n }\n if (parentId !== source.parent) {\n // We're dragging an existing field from another fieldset\n insertField({ field, position: dropTarget });\n } else {\n // We're dragging a field within the same fieldset\n moveField({ field, position: dropTarget });\n }\n return onDropTarget;\n }\n\n if (!fieldType) {\n return null;\n }\n const ft = fieldTypesMap.get(fieldType);\n if (!ft) {\n return null;\n }\n\n const fieldData = ft.createField() as CmsModelField;\n\n if (ft.canEditSettings !== false) {\n editField(fieldData);\n setState(state => ({\n ...state,\n dropTarget\n }));\n } else {\n insertField({ field: fieldData, position: dropTarget });\n }\n return null;\n }, []);\n\n const onEndDrag: OnEndDragCallable<DragObject, DropResult> = (\n { type, field, fields, layoutField },\n monitor\n ) => {\n if (!monitor.didDrop()) {\n return;\n }\n\n // Check if we dropped outside of the source fieldset, and if yes, remove the item from the original parent.\n const monitorResult = monitor.getDropResult();\n const parentId = parent ? parent.fieldId : null;\n if (monitorResult?.dropTarget === parentId) {\n return;\n }\n\n if (type === \"layoutField\" && layoutField?.id) {\n deleteLayoutCell(layoutField.id);\n return;\n }\n\n const removeFields = type === \"row\" ? fields || [] : field ? [field] : [];\n removeFields.forEach(field => deleteField(field));\n };\n\n const getFieldsInLayout: GetFieldsInLayoutCallable = () => {\n // Replace every field ID with actual field object, pass through layout fields.\n return state.layout\n .filter(arr => arr.length)\n .map(row => {\n return row\n .map((cell: CmsEditorLayoutCell) => {\n if (isLayoutField(cell)) {\n return cell;\n }\n return getField({ id: cell });\n })\n .filter(Boolean);\n })\n .filter(row => {\n return row.length > 0;\n }) as (CmsModelField | CmsLayoutField)[][];\n };\n\n const getFieldRenderer: GetFieldRendererCallable = name => {\n return fieldRenderersMap.get(name);\n };\n\n /**\n * Checks if field of given type already exists in the list of fields.\n */\n const getField: GetFieldCallable = query => {\n return state.fields.find(field => {\n for (const key in query) {\n if (!(key in field)) {\n return false;\n }\n\n if (field[key as keyof typeof field] !== query[key as keyof typeof query]) {\n return false;\n }\n }\n\n return true;\n });\n };\n\n /**\n * Inserts a new field into the target position.\n */\n const insertField: InsertFieldCallable = ({ field, position }) => {\n if (!field.id) {\n field.id = generateFieldId(\n layout.flat().filter((c): c is string => typeof c === \"string\")\n );\n }\n\n if (!field.type) {\n throw new Error(`Field \"type\" missing.`);\n }\n\n if (!fieldTypesMap.has(field.type)) {\n throw new Error(`No field type found for \"${field.type}\".`);\n }\n\n setState(prev => {\n const next: State = {\n ...prev,\n fields: (prev.fields || []).concat(field)\n };\n\n // Move field to position where it was dropped.\n return utils.moveField({ field, position, data: next });\n });\n };\n\n /**\n * Moves field to the given target position.\n */\n const moveField: MoveFieldCallable = ({ field, position }) => {\n setState(data => {\n return utils.moveField<State>({ field, position, data });\n });\n };\n\n /**\n * Moves row to a destination row.\n */\n const moveRow: MoveRowCallable = (source, destination) => {\n setState(data => {\n return utils.moveRow({ data, source, destination });\n });\n };\n\n /**\n * Updates field.\n */\n const updateField: UpdateFieldCallable = field => {\n setState(data => {\n for (let i = 0; i < data.fields.length; i++) {\n if (data.fields[i].id === field.id) {\n return dot.set(data, `fields.${i}`, field);\n }\n }\n return data;\n });\n };\n\n /**\n * Deletes a field (both from the list of field and the layout).\n */\n const deleteField: DeleteFieldCallable = field => {\n setState(data => {\n return utils.deleteField({ field, data });\n });\n };\n\n /**\n * Add a field to the fields array without placing it in the layout.\n * Used by tabs to hoist fields to the parent context.\n */\n const addField: AddFieldCallable = field => {\n setState(prev => {\n // Don't add if already exists\n if (prev.fields.some(f => f.id === field.id)) {\n return prev;\n }\n return { ...prev, fields: [...prev.fields, field] };\n });\n };\n\n /**\n * Remove a field from the fields array by ID.\n * Used by tabs to un-hoist fields from the parent context.\n */\n const removeField: RemoveFieldCallable = fieldId => {\n setState(prev => ({\n ...prev,\n fields: prev.fields.filter(f => f.id !== fieldId)\n }));\n };\n\n const getLayoutFieldType: GetLayoutFieldTypeCallable = type => {\n return layoutFieldTypesMap.get(type);\n };\n\n /**\n * Insert a layout field into the layout at the given position.\n */\n const insertLayoutCell: InsertLayoutCellCallable = (layoutField, position) => {\n // Auto-assign a unique ID to the layout field.\n const cell = {\n ...layoutField,\n id: generateAlphaNumericLowerCaseId(8)\n } as CmsLayoutField;\n\n setState(prev => {\n const newLayout = [...prev.layout.map(row => [...row])];\n const { row } = position;\n\n // Layout fields always occupy a full row.\n newLayout.splice(row, 0, [cell]);\n\n return { ...prev, layout: newLayout.filter(r => r.length > 0) };\n });\n };\n\n /**\n * Update a layout field found by its ID.\n */\n const updateLayoutCell: UpdateLayoutCellCallable = (fieldId, layoutField) => {\n setState(prev => {\n const newLayout = prev.layout.map(row =>\n row.map(cell => {\n if (isLayoutField(cell) && cell.id === fieldId) {\n return { ...layoutField, id: fieldId };\n }\n return cell;\n })\n );\n return { ...prev, layout: newLayout };\n });\n };\n\n /**\n * Delete a layout field found by its ID.\n * If it's a tabs layout field, also remove all hoisted fields from the fields array.\n */\n const deleteLayoutCell: DeleteLayoutCellCallable = fieldId => {\n setState(prev => {\n let fields = prev.fields;\n\n // Find the descriptor to check if it's tabs (need to clean up hoisted fields)\n for (const row of prev.layout) {\n for (const cell of row) {\n if (isLayoutField(cell) && cell.id === fieldId && cell.type === \"tabs\") {\n const tabsField =\n cell as import(\"@webiny/app-headless-cms-common/types/model.js\").CmsTabLayoutField;\n const fieldIdsInTabs = new Set<string>();\n tabsField.tabs.forEach(tab => {\n tab.layout.forEach(r => {\n r.forEach(c => {\n if (typeof c === \"string\") {\n fieldIdsInTabs.add(c);\n }\n });\n });\n });\n if (fieldIdsInTabs.size > 0) {\n fields = fields.filter(f => !fieldIdsInTabs.has(f.id));\n }\n }\n }\n }\n\n const newLayout = prev.layout.map(row =>\n row.filter(cell => !(isLayoutField(cell) && cell.id === fieldId))\n );\n\n return {\n ...prev,\n fields,\n layout: newLayout.filter(r => r.length > 0)\n };\n });\n };\n\n /**\n * Move a layout field (found by its ID) to a new position.\n */\n const moveLayoutCell: MoveLayoutCellCallable = (fieldId, position) => {\n setState(prev => {\n // Find the layout field by ID.\n let layoutField: CmsLayoutField | undefined;\n let sourceRow = -1;\n\n for (let ri = 0; ri < prev.layout.length; ri++) {\n for (const cell of prev.layout[ri]) {\n if (isLayoutField(cell) && cell.id === fieldId) {\n layoutField = cell;\n sourceRow = ri;\n break;\n }\n }\n if (layoutField) {\n break;\n }\n }\n\n if (!layoutField || sourceRow === -1) {\n return prev;\n }\n\n // 1. Remove the layout field from its source position.\n const withoutSource = prev.layout.map(row =>\n row.filter(cell => !(isLayoutField(cell) && cell.id === fieldId))\n );\n\n // 2. Was the source row emptied?\n const sourceRowEmptied = withoutSource[sourceRow].length === 0;\n\n // 3. Calculate the effective target row index.\n // The drop target row was computed against the original layout.\n // If we emptied a source row that was BEFORE the target, shift down by 1.\n let targetRow = position.row;\n if (sourceRowEmptied && sourceRow < targetRow) {\n targetRow--;\n }\n\n // 4. Remove empty rows.\n const cleaned = withoutSource.filter(r => r.length > 0);\n\n // 5. Clamp target row and insert the layout field as its own row.\n targetRow = Math.max(0, Math.min(targetRow, cleaned.length));\n cleaned.splice(targetRow, 0, [layoutField]);\n\n return { ...prev, layout: cleaned };\n });\n };\n\n const noConflict: NoConflictCallable = useCallback(\n (isVisible?: IsVisibleCallable) => item => {\n const sameParent = item.parent === onDropTarget.dropTarget;\n const draggedFields: string[] = [];\n switch (item.type) {\n case \"row\":\n (item.fields || []).forEach(field => draggedFields.push(field.fieldId));\n break;\n case \"field\":\n if (!item.field) {\n break;\n }\n draggedFields.push(item.field.fieldId);\n break;\n default:\n break;\n }\n\n if (\n draggedFields.length &&\n !sameParent &&\n fields.some(field => draggedFields.includes(field.fieldId))\n ) {\n return false;\n }\n\n return typeof isVisible === \"function\" ? isVisible(item) : true;\n },\n [fields.map(f => f.fieldId).join(\".\")]\n );\n\n const value: FieldEditorContext = {\n parent,\n parentEditorContext,\n depth,\n getFieldsInLayout,\n getFieldType: (typeOrField: string | CmsModelField) => {\n if (typeof typeOrField === \"string\") {\n return fieldTypesMap.get(typeOrField);\n }\n // Prefer an explicit `matches()` (e.g. the Asset field, stored as\n // `object`, resolves to the Asset descriptor rather than Object) before\n // falling back to a plain type match.\n const field = typeOrField;\n for (const ft of fieldTypesMap.values()) {\n if (ft.matches?.(field)) {\n return ft;\n }\n }\n return fieldTypesMap.get(field.type);\n },\n getFieldRenderer,\n getField,\n editField,\n field: state.field,\n dropTarget: state.dropTarget,\n onFieldDrop,\n onEndDrag,\n insertField,\n moveField,\n moveRow,\n updateField,\n deleteField,\n insertLayoutCell,\n updateLayoutCell,\n deleteLayoutCell,\n moveLayoutCell,\n getLayoutFieldType,\n addField,\n removeField,\n fields: getFieldsInLayout(),\n noConflict,\n layout: state.layout\n };\n\n return <FieldEditorContext.Provider value={value}>{children}</FieldEditorContext.Provider>;\n};\n"],"names":["FieldEditorContext","React","undefined","maxGenerateIdIterations","generateFieldId","layout","id","generateAlphaNumericLowerCaseId","iteration","Error","FieldEditorProvider","parent","fields","onChange","children","depth","parentEditorContext","editor","useModelFieldEditor","container","useContainer","fieldTypesMap","useMemo","all","CmsFieldType","map","Map","ft","fieldRenderersMap","CmsFieldRenderer","r","layoutFieldTypesMap","CmsLayoutFieldType","lft","state","setState","useState","useDeepCompareEffect","editField","useCallback","field","onDropTarget","onFieldDrop","source","dropTarget","pos","type","fieldType","parentId","index","insertField","moveRow","getLayoutFieldType","layoutField","insertLayoutCell","f","addField","moveLayoutCell","moveField","fieldData","onEndDrag","monitor","monitorResult","deleteLayoutCell","removeFields","deleteField","getFieldsInLayout","arr","row","cell","isLayoutField","getField","Boolean","getFieldRenderer","name","query","key","position","c","prev","next","utils","data","destination","updateField","i","dot","removeField","fieldId","newLayout","updateLayoutCell","tabsField","fieldIdsInTabs","Set","tab","sourceRow","ri","withoutSource","sourceRowEmptied","targetRow","cleaned","Math","noConflict","isVisible","item","sameParent","draggedFields","value","typeOrField"],"mappings":";;;;;;;;;;AAkJO,MAAMA,qBAAqB,WAAHA,GAAGC,MAAAA,aAAmB,CAAiCC;AAOtF,MAAMC,0BAA0B;AAChC,MAAMC,kBAAkB,CAACC;IACrB,IAAIC,KAAKC,gCAAgC;IAEzC,IAAIC,YAAY;IAChB,MAAOH,OAAO,QAAQ,CAACC,OAAOE,YAAYL,wBAAyB;QAC/DG,KAAKC,gCAAgC;QACrCC;IACJ;IACA,IAAIA,aAAaL,yBACb,MAAM,IAAIM,MAAM,CAAC,+BAA+B,EAAEN,wBAAwB,YAAY,CAAC;IAE3F,OAAOG;AACX;AAQO,MAAMI,sBAAsB,CAAC,EAChCC,MAAM,EACNC,MAAM,EACNP,MAAM,EACNQ,QAAQ,EACRC,QAAQ,EACe;IAEvB,IAAIC,QAAQ;IACZ,IAAIC;IACJ,IAAI;QACA,MAAMC,SAASC;QACfH,QAAQE,OAAO,KAAK,GAAG;QACvBD,sBAAsBC;IAC1B,EAAE,OAAM,CAER;IAEA,MAAME,YAAYC;IAClB,MAAMC,gBAAgBC,QAAQ;QAC1B,MAAMC,MAAMJ,UAAU,UAAU,CAACK;QACjC,MAAMC,MAAM,IAAIC;QAChB,KAAK,MAAMC,MAAMJ,IACbE,IAAI,GAAG,CAACE,GAAG,IAAI,EAAEA;QAErB,OAAOF;IACX,GAAG;QAACN;KAAU;IAEd,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AK;IAG1C,MAAMoD,QAA4B;QAC9BhG;QACAK;QACAD;QACAmD;QACA,cAAc,CAAC0C;YACX,IAAI,AAAuB,YAAvB,OAAOA,aACP,OAAOvF,cAAc,GAAG,CAACuF;YAK7B,MAAMpE,QAAQoE;YACd,KAAK,MAAMjF,MAAMN,cAAc,MAAM,GACjC,IAAIM,GAAG,OAAO,GAAGa,QACb,OAAOb;YAGf,OAAON,cAAc,GAAG,CAACmB,MAAM,IAAI;QACvC;QACAiC;QACAF;QACAjC;QACA,OAAOJ,MAAM,KAAK;QAClB,YAAYA,MAAM,UAAU;QAC5BQ;QACAkB;QACAV;QACAQ;QACAP;QACAiC;QACAnB;QACAX;QACAoC;QACA3B;QACAN;QACAL;QACAI;QACA+B;QACA,QAAQrB;QACRoC;QACA,QAAQpE,MAAM,MAAM;IACxB;IAEA,OAAO,WAAP,GAAO,oBAAClC,mBAAmB,QAAQ;QAAC,OAAO2G;OAAQ7F;AACvD"}
@@ -3,18 +3,22 @@ import { StaticToolbar } from "@webiny/lexical-editor";
3
3
  import { LexicalEditor } from "@webiny/app-admin";
4
4
  const placeholderStyles = {
5
5
  position: "absolute",
6
- top: 40,
7
- left: 25
6
+ top: 0,
7
+ left: 0,
8
+ padding: "8px 12px",
9
+ marginTop: 0,
10
+ color: "var(--text-color-neutral-muted)"
8
11
  };
9
12
  const contentEditableStyles = {
10
13
  minHeight: 200,
11
14
  display: "block",
12
- padding: 10
15
+ padding: "8px 12px"
13
16
  };
14
17
  const styles = {
15
- backgroundColor: "#fff",
16
- border: "1px solid #e1e1e1",
17
- padding: "10px 14px",
18
+ backgroundColor: "var(--color-neutral-base)",
19
+ border: "1px solid var(--border-color-neutral-muted)",
20
+ borderTop: "none",
21
+ borderRadius: "0 0 var(--radius-md) var(--radius-md)",
18
22
  minHeight: 200,
19
23
  maxHeight: 350
20
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"admin/components/LexicalCmsEditor/LexicalEditor.js","sources":["../../../../src/admin/components/LexicalCmsEditor/LexicalEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { StaticToolbar } from \"@webiny/lexical-editor\";\nimport { LexicalEditor as BaseLexicalEditor } from \"@webiny/app-admin\";\n\nconst placeholderStyles: React.CSSProperties = { position: \"absolute\", top: 40, left: 25 };\n\nconst contentEditableStyles: React.CSSProperties = {\n minHeight: 200,\n display: \"block\",\n padding: 10\n};\n\nconst styles: React.CSSProperties = {\n backgroundColor: \"#fff\",\n border: \"1px solid #e1e1e1\",\n padding: \"10px 14px\",\n minHeight: 200,\n maxHeight: 350\n};\n\nconst toolbar = <StaticToolbar />;\n\nexport type LexicalEditorProps = Omit<BaseLexicalEditor.Props, \"theme\">;\n\nexport const LexicalEditor = (props: LexicalEditorProps) => {\n return (\n <BaseLexicalEditor\n {...props}\n focus={true}\n staticToolbar={toolbar}\n tag={\"p\"}\n placeholder={props?.placeholder || \"Enter your text here...\"}\n placeholderStyles={placeholderStyles}\n contentEditableStyles={contentEditableStyles}\n styles={styles}\n />\n );\n};\n"],"names":["placeholderStyles","contentEditableStyles","styles","toolbar","StaticToolbar","LexicalEditor","props","BaseLexicalEditor"],"mappings":";;;AAIA,MAAMA,oBAAyC;IAAE,UAAU;IAAY,KAAK;IAAI,MAAM;AAAG;AAEzF,MAAMC,wBAA6C;IAC/C,WAAW;IACX,SAAS;IACT,SAAS;AACb;AAEA,MAAMC,SAA8B;IAChC,iBAAiB;IACjB,QAAQ;IACR,SAAS;IACT,WAAW;IACX,WAAW;AACf;AAEA,MAAMC,UAAU,WAAHA,GAAG,oBAACC,eAAaA;AAIvB,MAAMC,8BAAgB,CAACC,QACnB,WAAP,GACI,oBAACC,eAAiBA;QACb,GAAGD,KAAK;QACT,OAAO;QACP,eAAeH;QACf,KAAK;QACL,aAAaG,OAAO,eAAe;QACnC,mBAAmBN;QACnB,uBAAuBC;QACvB,QAAQC"}
1
+ {"version":3,"file":"admin/components/LexicalCmsEditor/LexicalEditor.js","sources":["../../../../src/admin/components/LexicalCmsEditor/LexicalEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { StaticToolbar } from \"@webiny/lexical-editor\";\nimport { LexicalEditor as BaseLexicalEditor } from \"@webiny/app-admin\";\n\n// Overlay the contentEditable: same origin + same padding as `contentEditableStyles`, and\n// neutralize the Placeholder component's default -20px margin. This makes the placeholder's\n// first line land exactly on the editor's text start.\nconst placeholderStyles: React.CSSProperties = {\n position: \"absolute\",\n top: 0,\n left: 0,\n padding: \"8px 12px\",\n marginTop: 0,\n // Font size/family come from the paragraph typography class (applied by RichTextEditor);\n // keep the placeholder muted.\n color: \"var(--text-color-neutral-muted)\"\n};\n\nconst contentEditableStyles: React.CSSProperties = {\n minHeight: 200,\n display: \"block\",\n padding: \"8px 12px\"\n};\n\nconst styles: React.CSSProperties = {\n backgroundColor: \"var(--color-neutral-base)\",\n border: \"1px solid var(--border-color-neutral-muted)\",\n // The static toolbar sits directly above and carries the top border, so the body\n // drops its top border and rounds only the bottom corners — together one seamless\n // rounded container, no internal divider (matches Figma).\n borderTop: \"none\",\n borderRadius: \"0 0 var(--radius-md) var(--radius-md)\",\n // Padding lives on the contentEditable only (avoids doubled inset).\n minHeight: 200,\n maxHeight: 350\n};\n\nconst toolbar = <StaticToolbar />;\n\nexport type LexicalEditorProps = Omit<BaseLexicalEditor.Props, \"theme\">;\n\nexport const LexicalEditor = (props: LexicalEditorProps) => {\n return (\n <BaseLexicalEditor\n {...props}\n focus={true}\n staticToolbar={toolbar}\n tag={\"p\"}\n placeholder={props?.placeholder || \"Enter your text here...\"}\n placeholderStyles={placeholderStyles}\n contentEditableStyles={contentEditableStyles}\n styles={styles}\n />\n );\n};\n"],"names":["placeholderStyles","contentEditableStyles","styles","toolbar","StaticToolbar","LexicalEditor","props","BaseLexicalEditor"],"mappings":";;;AAOA,MAAMA,oBAAyC;IAC3C,UAAU;IACV,KAAK;IACL,MAAM;IACN,SAAS;IACT,WAAW;IAGX,OAAO;AACX;AAEA,MAAMC,wBAA6C;IAC/C,WAAW;IACX,SAAS;IACT,SAAS;AACb;AAEA,MAAMC,SAA8B;IAChC,iBAAiB;IACjB,QAAQ;IAIR,WAAW;IACX,cAAc;IAEd,WAAW;IACX,WAAW;AACf;AAEA,MAAMC,UAAU,WAAHA,GAAG,oBAACC,eAAaA;AAIvB,MAAMC,8BAAgB,CAACC,QACnB,WAAP,GACI,oBAACC,eAAiBA;QACb,GAAGD,KAAK;QACT,OAAO;QACP,eAAeH;QACf,KAAK;QACL,aAAaG,OAAO,eAAe;QACnC,mBAAmBN;QACnB,uBAAuBC;QACvB,QAAQC"}
@@ -41,14 +41,15 @@ const TypographyDropDown = ()=>{
41
41
  element
42
42
  ]);
43
43
  return /*#__PURE__*/ react.createElement(react.Fragment, null, styles?.length ? /*#__PURE__*/ react.createElement(DropDown, {
44
- buttonClassName: "toolbar-item typography-dropdown",
44
+ buttonClassName: "toolbar-item typography-dropdown block-type-dropdown",
45
45
  buttonAriaLabel: "Typography formatting options",
46
46
  buttonLabel: value?.label || "Typography",
47
47
  stopCloseOnClickSelf: true,
48
48
  disabled: false,
49
49
  showScroll: true
50
50
  }, styles?.map((option)=>/*#__PURE__*/ react.createElement(DropDownItem, {
51
- className: `item typography-item ${value?.id === option.id ? "active dropdown-item-active" : ""}`,
51
+ className: "item typography-item",
52
+ selected: value?.id === option.id,
52
53
  onClick: ()=>applyTypography(option),
53
54
  key: option.id
54
55
  }, /*#__PURE__*/ react.createElement("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"admin/components/LexicalCmsEditor/TypographyDropDown.js","sources":["../../../../src/admin/components/LexicalCmsEditor/TypographyDropDown.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { $getNearestNodeOfType } from \"@lexical/utils\";\nimport {\n DropDown,\n DropDownItem,\n useCurrentSelection,\n useCurrentElement,\n useTypographyAction\n} from \"@webiny/lexical-editor\";\nimport {\n $isHeadingNode,\n $isParagraphNode,\n $isQuoteNode,\n $isListNode,\n ListNode\n} from \"@webiny/lexical-nodes\";\nimport { useAdminConfig } from \"@webiny/app-admin\";\n\nexport type TypographyStyle = {\n id: string;\n label: string;\n tag: string;\n className: string;\n};\n\nexport const TypographyDropDown = () => {\n const { value, applyTypography } = useTypographyAction();\n const { lexicalTheme } = useAdminConfig();\n\n const [styles, setStyles] = useState<TypographyStyle[]>([]);\n const { element } = useCurrentElement();\n const { rangeSelection } = useCurrentSelection();\n\n const getAllTextStyles = (): TypographyStyle[] => {\n const headingsStyles = lexicalTheme.typography.headings || [];\n const paragraphStyles = lexicalTheme.typography.paragraphs || [];\n\n return [...headingsStyles, ...paragraphStyles];\n };\n\n const getListStyles = (tag: string): TypographyStyle[] => {\n const listStyles = lexicalTheme.typography.lists?.filter(x => x.tag === tag) || [];\n if (listStyles.length > 0) {\n return listStyles;\n }\n\n const fallbackTag = tag === \"ul\" ? \"ol\" : \"ul\";\n return lexicalTheme.typography.lists?.filter(x => x.tag === fallbackTag) || [];\n };\n\n useEffect(() => {\n if (!element || !rangeSelection) {\n return;\n }\n\n if ($isParagraphNode(element) || $isHeadingNode(element)) {\n setStyles(getAllTextStyles());\n } else if ($isListNode(element)) {\n let type;\n try {\n const anchorNode = rangeSelection.anchor.getNode();\n const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);\n if (parentList) {\n type = parentList.getListType();\n }\n } catch {\n type = element.getListType();\n }\n\n if (type === \"bullet\") {\n setStyles(getListStyles(\"ul\"));\n } else {\n setStyles(getListStyles(\"ol\"));\n }\n } else if ($isQuoteNode(element)) {\n setStyles(lexicalTheme.typography.quotes || []);\n } else {\n setStyles([]);\n }\n }, [element]);\n\n return (\n <>\n {!!styles?.length ? (\n <DropDown\n buttonClassName=\"toolbar-item typography-dropdown\"\n buttonAriaLabel={\"Typography formatting options\"}\n buttonLabel={value?.label || \"Typography\"}\n stopCloseOnClickSelf={true}\n disabled={false}\n showScroll={true}\n >\n {styles?.map(option => (\n <DropDownItem\n className={`item typography-item ${\n value?.id === option.id ? \"active dropdown-item-active\" : \"\"\n }`}\n onClick={() => applyTypography(option)}\n key={option.id}\n >\n <span className=\"text\">{option.label}</span>\n </DropDownItem>\n ))}\n </DropDown>\n ) : null}\n </>\n );\n};\n"],"names":["TypographyDropDown","value","applyTypography","useTypographyAction","lexicalTheme","useAdminConfig","styles","setStyles","useState","element","useCurrentElement","rangeSelection","useCurrentSelection","getAllTextStyles","headingsStyles","paragraphStyles","getListStyles","tag","listStyles","x","fallbackTag","useEffect","$isParagraphNode","$isHeadingNode","$isListNode","type","anchorNode","parentList","$getNearestNodeOfType","ListNode","$isQuoteNode","DropDown","option","DropDownItem"],"mappings":";;;;;AAyBO,MAAMA,qBAAqB;IAC9B,MAAM,EAAEC,KAAK,EAAEC,eAAe,EAAE,GAAGC;IACnC,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAA4B,EAAE;IAC1D,MAAM,EAAEC,OAAO,EAAE,GAAGC;IACpB,MAAM,EAAEC,cAAc,EAAE,GAAGC;IAE3B,MAAMC,mBAAmB;QACrB,MAAMC,iBAAiBV,aAAa,UAAU,CAAC,QAAQ,IAAI,EAAE;QAC7D,MAAMW,kBAAkBX,aAAa,UAAU,CAAC,UAAU,IAAI,EAAE;QAEhE,OAAO;eAAIU;eAAmBC;SAAgB;IAClD;IAEA,MAAMC,gBAAgB,CAACC;QACnB,MAAMC,aAAad,aAAa,UAAU,CAAC,KAAK,EAAE,OAAOe,CAAAA,IAAKA,EAAE,GAAG,KAAKF,QAAQ,EAAE;QAClF,IAAIC,WAAW,MAAM,GAAG,GACpB,OAAOA;QAGX,MAAME,cAAcH,AAAQ,SAARA,MAAe,OAAO;QAC1C,OAAOb,aAAa,UAAU,CAAC,KAAK,EAAE,OAAOe,CAAAA,IAAKA,EAAE,GAAG,KAAKC,gBAAgB,EAAE;IAClF;IAEAC,UAAU;QACN,IAAI,CAACZ,WAAW,CAACE,gBACb;QAGJ,IAAIW,iBAAiBb,YAAYc,eAAed,UAC5CF,UAAUM;aACP,IAAIW,YAAYf,UAAU;YAC7B,IAAIgB;YACJ,IAAI;gBACA,MAAMC,aAAaf,eAAe,MAAM,CAAC,OAAO;gBAChD,MAAMgB,aAAaC,sBAAgCF,YAAYG;gBAC/D,IAAIF,YACAF,OAAOE,WAAW,WAAW;YAErC,EAAE,OAAM;gBACJF,OAAOhB,QAAQ,WAAW;YAC9B;YAEa,aAATgB,OACAlB,UAAUS,cAAc,SAExBT,UAAUS,cAAc;QAEhC,OAAWc,aAAarB,WACpBF,UAAUH,aAAa,UAAU,CAAC,MAAM,IAAI,EAAE,IAE9CG,UAAU,EAAE;IAEpB,GAAG;QAACE;KAAQ;IAEZ,OAAO,WAAP,GACI,0CACK,AAAEH,QAAQ,SAAS,WAAT,GACP,oBAACyB,UAAQA;QACL,iBAAgB;QAChB,iBAAiB;QACjB,aAAa9B,OAAO,SAAS;QAC7B,sBAAsB;QACtB,UAAU;QACV,YAAY;OAEXK,QAAQ,IAAI0B,CAAAA,SAAAA,WAAAA,GACT,oBAACC,cAAYA;YACT,WAAW,CAAC,qBAAqB,EAC7BhC,OAAO,OAAO+B,OAAO,EAAE,GAAG,gCAAgC,IAC5D;YACF,SAAS,IAAM9B,gBAAgB8B;YAC/B,KAAKA,OAAO,EAAE;yBAEd,oBAAC;YAAK,WAAU;WAAQA,OAAO,KAAK,OAIhD;AAGhB"}
1
+ {"version":3,"file":"admin/components/LexicalCmsEditor/TypographyDropDown.js","sources":["../../../../src/admin/components/LexicalCmsEditor/TypographyDropDown.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { $getNearestNodeOfType } from \"@lexical/utils\";\nimport {\n DropDown,\n DropDownItem,\n useCurrentSelection,\n useCurrentElement,\n useTypographyAction\n} from \"@webiny/lexical-editor\";\nimport {\n $isHeadingNode,\n $isParagraphNode,\n $isQuoteNode,\n $isListNode,\n ListNode\n} from \"@webiny/lexical-nodes\";\nimport { useAdminConfig } from \"@webiny/app-admin\";\n\nexport type TypographyStyle = {\n id: string;\n label: string;\n tag: string;\n className: string;\n};\n\nexport const TypographyDropDown = () => {\n const { value, applyTypography } = useTypographyAction();\n const { lexicalTheme } = useAdminConfig();\n\n const [styles, setStyles] = useState<TypographyStyle[]>([]);\n const { element } = useCurrentElement();\n const { rangeSelection } = useCurrentSelection();\n\n const getAllTextStyles = (): TypographyStyle[] => {\n const headingsStyles = lexicalTheme.typography.headings || [];\n const paragraphStyles = lexicalTheme.typography.paragraphs || [];\n\n return [...headingsStyles, ...paragraphStyles];\n };\n\n const getListStyles = (tag: string): TypographyStyle[] => {\n const listStyles = lexicalTheme.typography.lists?.filter(x => x.tag === tag) || [];\n if (listStyles.length > 0) {\n return listStyles;\n }\n\n const fallbackTag = tag === \"ul\" ? \"ol\" : \"ul\";\n return lexicalTheme.typography.lists?.filter(x => x.tag === fallbackTag) || [];\n };\n\n useEffect(() => {\n if (!element || !rangeSelection) {\n return;\n }\n\n if ($isParagraphNode(element) || $isHeadingNode(element)) {\n setStyles(getAllTextStyles());\n } else if ($isListNode(element)) {\n let type;\n try {\n const anchorNode = rangeSelection.anchor.getNode();\n const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);\n if (parentList) {\n type = parentList.getListType();\n }\n } catch {\n type = element.getListType();\n }\n\n if (type === \"bullet\") {\n setStyles(getListStyles(\"ul\"));\n } else {\n setStyles(getListStyles(\"ol\"));\n }\n } else if ($isQuoteNode(element)) {\n setStyles(lexicalTheme.typography.quotes || []);\n } else {\n setStyles([]);\n }\n }, [element]);\n\n return (\n <>\n {!!styles?.length ? (\n <DropDown\n buttonClassName=\"toolbar-item typography-dropdown block-type-dropdown\"\n buttonAriaLabel={\"Typography formatting options\"}\n buttonLabel={value?.label || \"Typography\"}\n stopCloseOnClickSelf={true}\n disabled={false}\n showScroll={true}\n >\n {styles?.map(option => (\n <DropDownItem\n className=\"item typography-item\"\n selected={value?.id === option.id}\n onClick={() => applyTypography(option)}\n key={option.id}\n >\n <span className=\"text\">{option.label}</span>\n </DropDownItem>\n ))}\n </DropDown>\n ) : null}\n </>\n );\n};\n"],"names":["TypographyDropDown","value","applyTypography","useTypographyAction","lexicalTheme","useAdminConfig","styles","setStyles","useState","element","useCurrentElement","rangeSelection","useCurrentSelection","getAllTextStyles","headingsStyles","paragraphStyles","getListStyles","tag","listStyles","x","fallbackTag","useEffect","$isParagraphNode","$isHeadingNode","$isListNode","type","anchorNode","parentList","$getNearestNodeOfType","ListNode","$isQuoteNode","DropDown","option","DropDownItem"],"mappings":";;;;;AAyBO,MAAMA,qBAAqB;IAC9B,MAAM,EAAEC,KAAK,EAAEC,eAAe,EAAE,GAAGC;IACnC,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAA4B,EAAE;IAC1D,MAAM,EAAEC,OAAO,EAAE,GAAGC;IACpB,MAAM,EAAEC,cAAc,EAAE,GAAGC;IAE3B,MAAMC,mBAAmB;QACrB,MAAMC,iBAAiBV,aAAa,UAAU,CAAC,QAAQ,IAAI,EAAE;QAC7D,MAAMW,kBAAkBX,aAAa,UAAU,CAAC,UAAU,IAAI,EAAE;QAEhE,OAAO;eAAIU;eAAmBC;SAAgB;IAClD;IAEA,MAAMC,gBAAgB,CAACC;QACnB,MAAMC,aAAad,aAAa,UAAU,CAAC,KAAK,EAAE,OAAOe,CAAAA,IAAKA,EAAE,GAAG,KAAKF,QAAQ,EAAE;QAClF,IAAIC,WAAW,MAAM,GAAG,GACpB,OAAOA;QAGX,MAAME,cAAcH,AAAQ,SAARA,MAAe,OAAO;QAC1C,OAAOb,aAAa,UAAU,CAAC,KAAK,EAAE,OAAOe,CAAAA,IAAKA,EAAE,GAAG,KAAKC,gBAAgB,EAAE;IAClF;IAEAC,UAAU;QACN,IAAI,CAACZ,WAAW,CAACE,gBACb;QAGJ,IAAIW,iBAAiBb,YAAYc,eAAed,UAC5CF,UAAUM;aACP,IAAIW,YAAYf,UAAU;YAC7B,IAAIgB;YACJ,IAAI;gBACA,MAAMC,aAAaf,eAAe,MAAM,CAAC,OAAO;gBAChD,MAAMgB,aAAaC,sBAAgCF,YAAYG;gBAC/D,IAAIF,YACAF,OAAOE,WAAW,WAAW;YAErC,EAAE,OAAM;gBACJF,OAAOhB,QAAQ,WAAW;YAC9B;YAEa,aAATgB,OACAlB,UAAUS,cAAc,SAExBT,UAAUS,cAAc;QAEhC,OAAWc,aAAarB,WACpBF,UAAUH,aAAa,UAAU,CAAC,MAAM,IAAI,EAAE,IAE9CG,UAAU,EAAE;IAEpB,GAAG;QAACE;KAAQ;IAEZ,OAAO,WAAP,GACI,0CACK,AAAEH,QAAQ,SAAS,WAAT,GACP,oBAACyB,UAAQA;QACL,iBAAgB;QAChB,iBAAiB;QACjB,aAAa9B,OAAO,SAAS;QAC7B,sBAAsB;QACtB,UAAU;QACV,YAAY;OAEXK,QAAQ,IAAI0B,CAAAA,SAAAA,WAAAA,GACT,oBAACC,cAAYA;YACT,WAAU;YACV,UAAUhC,OAAO,OAAO+B,OAAO,EAAE;YACjC,SAAS,IAAM9B,gBAAgB8B;YAC/B,KAAKA,OAAO,EAAE;yBAEd,oBAAC;YAAK,WAAU;WAAQA,OAAO,KAAK,OAIhD;AAGhB"}
@@ -1,7 +1,64 @@
1
1
  import React from "react";
2
2
  import { Width } from "./Width.js";
3
3
  import { NewEntryWizard } from "./NewEntryWizard.js";
4
- export declare const ContentEntryEditorConfig: (({ priority, children }: import("@webiny/react-properties").ConfigProps) => React.JSX.Element) & {
4
+ declare const InternalEditorConfig: ({ children }: {
5
+ children: React.ReactNode;
6
+ }) => React.JSX.Element;
7
+ declare const PublicEditorConfig: {
8
+ ({ children }: {
9
+ children: React.ReactNode;
10
+ }): React.JSX.Element;
11
+ displayName: string;
12
+ };
13
+ export declare const ContentEntryEditorConfig: typeof PublicEditorConfig & {
14
+ Actions: {
15
+ ButtonAction: ((props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element) & {
16
+ original: (props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element;
17
+ originalName: string;
18
+ displayName: string;
19
+ } & {
20
+ original: ((props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element) & {
21
+ original: (props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element;
22
+ originalName: string;
23
+ displayName: string;
24
+ };
25
+ originalName: string;
26
+ displayName: string;
27
+ } & {
28
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<((props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element) & {
29
+ original: (props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element;
30
+ originalName: string;
31
+ displayName: string;
32
+ }>) => (props: unknown) => React.JSX.Element;
33
+ } & {
34
+ useButtons: () => import("@webiny/app-admin/components/Buttons/useButtons.js").ButtonsProviderContext;
35
+ };
36
+ MenuItemAction: ((props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element) & {
37
+ original: (props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element;
38
+ originalName: string;
39
+ displayName: string;
40
+ } & {
41
+ original: ((props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element) & {
42
+ original: (props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element;
43
+ originalName: string;
44
+ displayName: string;
45
+ };
46
+ originalName: string;
47
+ displayName: string;
48
+ } & {
49
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<((props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element) & {
50
+ original: (props: import("./Actions/MenuItemAction.js").MenuItemActionProps) => React.JSX.Element;
51
+ originalName: string;
52
+ displayName: string;
53
+ }>) => (props: unknown) => React.JSX.Element;
54
+ } & {
55
+ useOptionsMenuItem: () => import("@webiny/app-admin/components/OptionsMenu/useOptionsMenuItem.js").OptionsMenuItemProviderContext;
56
+ };
57
+ };
58
+ Width: typeof Width;
59
+ NewEntryWizard: typeof NewEntryWizard;
60
+ };
61
+ export declare const InternalContentEntryEditorConfig: typeof InternalEditorConfig & {
5
62
  Actions: {
6
63
  ButtonAction: ((props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element) & {
7
64
  original: (props: import("./Actions/ButtonAction.js").ButtonActionProps) => React.JSX.Element;
@@ -54,5 +111,6 @@ export declare function useContentEntryEditorConfig(): {
54
111
  buttonActions: import("./Actions/BaseAction.js").BaseActionConfig<"button-action">[];
55
112
  menuItemActions: import("./Actions/BaseAction.js").BaseActionConfig<"menu-item-action">[];
56
113
  width: string;
57
- newEntryWizard: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
114
+ newEntryWizard: React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
58
115
  };
116
+ export {};
@@ -1,10 +1,22 @@
1
- import { useMemo } from "react";
1
+ import react, { useMemo } from "react";
2
2
  import { createConfigurableComponent } from "@webiny/react-properties";
3
3
  import { Actions } from "./Actions/index.js";
4
4
  import { Width } from "./Width.js";
5
5
  import { NewEntryWizard } from "./NewEntryWizard.js";
6
6
  const base = createConfigurableComponent("ContentEntryEditorConfig");
7
- const ContentEntryEditorConfig = Object.assign(base.Config, {
7
+ const InternalEditorConfig = ({ children })=>/*#__PURE__*/ react.createElement(base.Config, {
8
+ priority: "primary"
9
+ }, children);
10
+ const PublicEditorConfig = ({ children })=>/*#__PURE__*/ react.createElement(base.Config, {
11
+ priority: "secondary"
12
+ }, children);
13
+ PublicEditorConfig.displayName = "ContentEntryEditorConfig";
14
+ const ContentEntryEditorConfig = Object.assign(PublicEditorConfig, {
15
+ Actions: Actions,
16
+ Width: Width,
17
+ NewEntryWizard: NewEntryWizard
18
+ });
19
+ const InternalContentEntryEditorConfig = Object.assign(InternalEditorConfig, {
8
20
  Actions: Actions,
9
21
  Width: Width,
10
22
  NewEntryWizard: NewEntryWizard
@@ -13,6 +25,7 @@ const ContentEntryEditorWithConfig = base.WithConfig;
13
25
  function useContentEntryEditorConfig() {
14
26
  const config = base.useConfig();
15
27
  const actions = config.actions || [];
28
+ const wizards = config.newEntryWizards || [];
16
29
  return useMemo(()=>({
17
30
  buttonActions: [
18
31
  ...actions.filter((action)=>"button-action" === action.$type) || []
@@ -20,12 +33,12 @@ function useContentEntryEditorConfig() {
20
33
  menuItemActions: [
21
34
  ...actions.filter((action)=>"menu-item-action" === action.$type) || []
22
35
  ],
23
- width: config.width || "1020px",
24
- newEntryWizard: config.newEntryWizard ?? null
36
+ width: void 0 !== config.width ? config.width : "1020px",
37
+ newEntryWizard: wizards.at(-1)?.element ?? null
25
38
  }), [
26
39
  config
27
40
  ]);
28
41
  }
29
- export { ContentEntryEditorConfig, ContentEntryEditorWithConfig, useContentEntryEditorConfig };
42
+ export { ContentEntryEditorConfig, ContentEntryEditorWithConfig, InternalContentEntryEditorConfig, useContentEntryEditorConfig };
30
43
 
31
44
  //# sourceMappingURL=ContentEntryEditorConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin/config/contentEntries/editor/ContentEntryEditorConfig.js","sources":["../../../../../src/admin/config/contentEntries/editor/ContentEntryEditorConfig.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { createConfigurableComponent } from \"@webiny/react-properties\";\nimport type { ActionsConfig } from \"./Actions/index.js\";\nimport { Actions } from \"./Actions/index.js\";\nimport { Width } from \"./Width.js\";\nimport { NewEntryWizard } from \"./NewEntryWizard.js\";\n\nconst base = createConfigurableComponent<ContentEntryEditorConfig>(\"ContentEntryEditorConfig\");\n\nexport const ContentEntryEditorConfig = Object.assign(base.Config, {\n Actions,\n Width,\n NewEntryWizard\n});\n\nexport const ContentEntryEditorWithConfig = base.WithConfig;\n\ninterface ContentEntryEditorConfig {\n actions: ActionsConfig;\n width: string;\n newEntryWizard: React.ReactElement | null;\n}\n\nexport function useContentEntryEditorConfig() {\n const config = base.useConfig();\n\n const actions = config.actions || [];\n\n return useMemo(\n () => ({\n buttonActions: [...(actions.filter(action => action.$type === \"button-action\") || [])],\n menuItemActions: [\n ...(actions.filter(action => action.$type === \"menu-item-action\") || [])\n ],\n width: config.width || \"1020px\",\n newEntryWizard: (config.newEntryWizard as React.ReactElement) ?? null\n }),\n [config]\n );\n}\n"],"names":["base","createConfigurableComponent","ContentEntryEditorConfig","Object","Actions","Width","NewEntryWizard","ContentEntryEditorWithConfig","useContentEntryEditorConfig","config","actions","useMemo","action"],"mappings":";;;;;AAOA,MAAMA,OAAOC,4BAAsD;AAE5D,MAAMC,2BAA2BC,OAAO,MAAM,CAACH,KAAK,MAAM,EAAE;IAC/DI,SAAOA;IACPC,OAAKA;IACLC,gBAAcA;AAClB;AAEO,MAAMC,+BAA+BP,KAAK,UAAU;AAQpD,SAASQ;IACZ,MAAMC,SAAST,KAAK,SAAS;IAE7B,MAAMU,UAAUD,OAAO,OAAO,IAAI,EAAE;IAEpC,OAAOE,QACH,IAAO;YACH,eAAe;mBAAKD,QAAQ,MAAM,CAACE,CAAAA,SAAUA,AAAiB,oBAAjBA,OAAO,KAAK,KAAyB,EAAE;aAAE;YACtF,iBAAiB;mBACTF,QAAQ,MAAM,CAACE,CAAAA,SAAUA,AAAiB,uBAAjBA,OAAO,KAAK,KAA4B,EAAE;aAC1E;YACD,OAAOH,OAAO,KAAK,IAAI;YACvB,gBAAiBA,OAAO,cAAc,IAA2B;QACrE,IACA;QAACA;KAAO;AAEhB"}
1
+ {"version":3,"file":"admin/config/contentEntries/editor/ContentEntryEditorConfig.js","sources":["../../../../../src/admin/config/contentEntries/editor/ContentEntryEditorConfig.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { createConfigurableComponent } from \"@webiny/react-properties\";\nimport type { ActionsConfig } from \"./Actions/index.js\";\nimport { Actions } from \"./Actions/index.js\";\nimport { Width } from \"./Width.js\";\nimport { NewEntryWizard } from \"./NewEntryWizard.js\";\nimport type { NewEntryWizardConfig } from \"./NewEntryWizard.js\";\n\nconst base = createConfigurableComponent<ContentEntryEditorConfig>(\"ContentEntryEditorConfig\");\n\nconst InternalEditorConfig = ({ children }: { children: React.ReactNode }) => {\n return <base.Config priority={\"primary\"}>{children}</base.Config>;\n};\n\nconst PublicEditorConfig = ({ children }: { children: React.ReactNode }) => {\n return <base.Config priority={\"secondary\"}>{children}</base.Config>;\n};\n\nPublicEditorConfig.displayName = \"ContentEntryEditorConfig\";\n\nexport const ContentEntryEditorConfig = Object.assign(PublicEditorConfig, {\n Actions,\n Width,\n NewEntryWizard\n});\n\nexport const InternalContentEntryEditorConfig = Object.assign(InternalEditorConfig, {\n Actions,\n Width,\n NewEntryWizard\n});\n\nexport const ContentEntryEditorWithConfig = base.WithConfig;\n\ninterface ContentEntryEditorConfig {\n actions: ActionsConfig;\n width: string;\n newEntryWizards: NewEntryWizardConfig[];\n}\n\nexport function useContentEntryEditorConfig() {\n const config = base.useConfig();\n\n const actions = config.actions || [];\n const wizards = (config.newEntryWizards as NewEntryWizardConfig[]) || [];\n\n return useMemo(\n () => ({\n buttonActions: [...(actions.filter(action => action.$type === \"button-action\") || [])],\n menuItemActions: [\n ...(actions.filter(action => action.$type === \"menu-item-action\") || [])\n ],\n width: config.width !== undefined ? config.width : \"1020px\",\n newEntryWizard: wizards.at(-1)?.element ?? null\n }),\n [config]\n );\n}\n"],"names":["base","createConfigurableComponent","InternalEditorConfig","children","PublicEditorConfig","ContentEntryEditorConfig","Object","Actions","Width","NewEntryWizard","InternalContentEntryEditorConfig","ContentEntryEditorWithConfig","useContentEntryEditorConfig","config","actions","wizards","useMemo","action","undefined"],"mappings":";;;;;AAQA,MAAMA,OAAOC,4BAAsD;AAEnE,MAAMC,uBAAuB,CAAC,EAAEC,QAAQ,EAAiC,GAC9D,WAAP,GAAO,oBAACH,KAAK,MAAM;QAAC,UAAU;OAAYG;AAG9C,MAAMC,qBAAqB,CAAC,EAAED,QAAQ,EAAiC,GAC5D,WAAP,GAAO,oBAACH,KAAK,MAAM;QAAC,UAAU;OAAcG;AAGhDC,mBAAmB,WAAW,GAAG;AAE1B,MAAMC,2BAA2BC,OAAO,MAAM,CAACF,oBAAoB;IACtEG,SAAOA;IACPC,OAAKA;IACLC,gBAAcA;AAClB;AAEO,MAAMC,mCAAmCJ,OAAO,MAAM,CAACJ,sBAAsB;IAChFK,SAAOA;IACPC,OAAKA;IACLC,gBAAcA;AAClB;AAEO,MAAME,+BAA+BX,KAAK,UAAU;AAQpD,SAASY;IACZ,MAAMC,SAASb,KAAK,SAAS;IAE7B,MAAMc,UAAUD,OAAO,OAAO,IAAI,EAAE;IACpC,MAAME,UAAWF,OAAO,eAAe,IAA+B,EAAE;IAExE,OAAOG,QACH,IAAO;YACH,eAAe;mBAAKF,QAAQ,MAAM,CAACG,CAAAA,SAAUA,AAAiB,oBAAjBA,OAAO,KAAK,KAAyB,EAAE;aAAE;YACtF,iBAAiB;mBACTH,QAAQ,MAAM,CAACG,CAAAA,SAAUA,AAAiB,uBAAjBA,OAAO,KAAK,KAA4B,EAAE;aAC1E;YACD,OAAOJ,AAAiBK,WAAjBL,OAAO,KAAK,GAAiBA,OAAO,KAAK,GAAG;YACnD,gBAAgBE,QAAQ,EAAE,CAAC,KAAK,WAAW;QAC/C,IACA;QAACF;KAAO;AAEhB"}
@@ -1,6 +1,13 @@
1
1
  import React from "react";
2
+ export interface NewEntryWizardConfig {
3
+ name: string;
4
+ element: React.ReactElement;
5
+ }
2
6
  export interface NewEntryWizardProps {
7
+ name: string;
8
+ before?: string;
9
+ after?: string;
3
10
  modelIds?: string[];
4
11
  element: React.ReactElement;
5
12
  }
6
- export declare const NewEntryWizard: ({ element, modelIds }: NewEntryWizardProps) => React.JSX.Element;
13
+ export declare const NewEntryWizard: ({ name, before, after, element, modelIds }: NewEntryWizardProps) => React.JSX.Element;
@@ -1,13 +1,28 @@
1
1
  import react from "react";
2
- import { Property } from "@webiny/react-properties";
2
+ import { Property, useIdGenerator } from "@webiny/react-properties";
3
3
  import { IsApplicableToCurrentModel } from "../../IsApplicableToCurrentModel.js";
4
- const NewEntryWizard = ({ element, modelIds = [] })=>/*#__PURE__*/ react.createElement(IsApplicableToCurrentModel, {
4
+ const NewEntryWizard = ({ name, before, after, element, modelIds = [] })=>{
5
+ const getId = useIdGenerator("newEntryWizard");
6
+ const placeBefore = void 0 !== before ? getId(before) : void 0;
7
+ const placeAfter = void 0 !== after ? getId(after) : void 0;
8
+ return /*#__PURE__*/ react.createElement(IsApplicableToCurrentModel, {
5
9
  modelIds: modelIds
6
10
  }, /*#__PURE__*/ react.createElement(Property, {
7
- id: "contentEntryForm:newEntryWizard",
8
- name: "newEntryWizard",
11
+ id: getId(name),
12
+ name: "newEntryWizards",
13
+ array: true,
14
+ before: placeBefore,
15
+ after: placeAfter
16
+ }, /*#__PURE__*/ react.createElement(Property, {
17
+ id: getId(name, "name"),
18
+ name: "name",
19
+ value: name
20
+ }), /*#__PURE__*/ react.createElement(Property, {
21
+ id: getId(name, "element"),
22
+ name: "element",
9
23
  value: element
10
- }));
24
+ })));
25
+ };
11
26
  export { NewEntryWizard };
12
27
 
13
28
  //# sourceMappingURL=NewEntryWizard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin/config/contentEntries/editor/NewEntryWizard.js","sources":["../../../../../src/admin/config/contentEntries/editor/NewEntryWizard.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\nimport { IsApplicableToCurrentModel } from \"~/admin/config/IsApplicableToCurrentModel.js\";\n\nexport interface NewEntryWizardProps {\n modelIds?: string[];\n element: React.ReactElement;\n}\n\nexport const NewEntryWizard = ({ element, modelIds = [] }: NewEntryWizardProps) => {\n return (\n <IsApplicableToCurrentModel modelIds={modelIds}>\n <Property id=\"contentEntryForm:newEntryWizard\" name=\"newEntryWizard\" value={element} />\n </IsApplicableToCurrentModel>\n );\n};\n"],"names":["NewEntryWizard","element","modelIds","IsApplicableToCurrentModel","Property"],"mappings":";;;AASO,MAAMA,iBAAiB,CAAC,EAAEC,OAAO,EAAEC,WAAW,EAAE,EAAuB,GACnE,WAAP,GACI,oBAACC,4BAA0BA;QAAC,UAAUD;qBAClC,oBAACE,UAAQA;QAAC,IAAG;QAAkC,MAAK;QAAiB,OAAOH"}
1
+ {"version":3,"file":"admin/config/contentEntries/editor/NewEntryWizard.js","sources":["../../../../../src/admin/config/contentEntries/editor/NewEntryWizard.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { IsApplicableToCurrentModel } from \"~/admin/config/IsApplicableToCurrentModel.js\";\n\nexport interface NewEntryWizardConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface NewEntryWizardProps {\n name: string;\n before?: string;\n after?: string;\n modelIds?: string[];\n element: React.ReactElement;\n}\n\nexport const NewEntryWizard = ({\n name,\n before,\n after,\n element,\n modelIds = []\n}: NewEntryWizardProps) => {\n const getId = useIdGenerator(\"newEntryWizard\");\n\n const placeBefore = before !== undefined ? getId(before) : undefined;\n const placeAfter = after !== undefined ? getId(after) : undefined;\n\n return (\n <IsApplicableToCurrentModel modelIds={modelIds}>\n <Property\n id={getId(name)}\n name={\"newEntryWizards\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n >\n <Property id={getId(name, \"name\")} name={\"name\"} value={name} />\n <Property id={getId(name, \"element\")} name={\"element\"} value={element} />\n </Property>\n </IsApplicableToCurrentModel>\n );\n};\n"],"names":["NewEntryWizard","name","before","after","element","modelIds","getId","useIdGenerator","placeBefore","undefined","placeAfter","IsApplicableToCurrentModel","Property"],"mappings":";;;AAiBO,MAAMA,iBAAiB,CAAC,EAC3BC,IAAI,EACJC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,WAAW,EAAE,EACK;IAClB,MAAMC,QAAQC,eAAe;IAE7B,MAAMC,cAAcN,AAAWO,WAAXP,SAAuBI,MAAMJ,UAAUO;IAC3D,MAAMC,aAAaP,AAAUM,WAAVN,QAAsBG,MAAMH,SAASM;IAExD,OAAO,WAAP,GACI,oBAACE,4BAA0BA;QAAC,UAAUN;qBAClC,oBAACO,UAAQA;QACL,IAAIN,MAAML;QACV,MAAM;QACN,OAAO;QACP,QAAQO;QACR,OAAOE;qBAEP,oBAACE,UAAQA;QAAC,IAAIN,MAAML,MAAM;QAAS,MAAM;QAAQ,OAAOA;sBACxD,oBAACW,UAAQA;QAAC,IAAIN,MAAML,MAAM;QAAY,MAAM;QAAW,OAAOG;;AAI9E"}
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import type { BreadcrumbLink } from "@webiny/app-admin";
3
+ export interface BreadcrumbRootConfig {
4
+ label: string;
5
+ to?: BreadcrumbLink;
6
+ }
7
+ export interface BreadcrumbRootProps {
8
+ /** Label of the leading breadcrumb (e.g. "Headless CMS", "Tenant Manager"). */
9
+ label: string;
10
+ /** Optional link for the root entry. */
11
+ to?: BreadcrumbLink;
12
+ /** Restrict this root to specific models (e.g. the tenant model). Empty = all models. */
13
+ modelIds?: string[];
14
+ }
15
+ /**
16
+ * Overrides the leading breadcrumb of the content-entries trail for apps that embed the
17
+ * entries view (e.g. Tenant Manager reuses it for the tenant model). Scope it with `modelIds`,
18
+ * mirroring the column/filter configs. When unset, the entries view defaults to "Headless CMS".
19
+ */
20
+ export declare const BreadcrumbRoot: (({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null) & {
21
+ original: ({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null;
22
+ originalName: string;
23
+ displayName: string;
24
+ } & {
25
+ original: (({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null) & {
26
+ original: ({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null;
27
+ originalName: string;
28
+ displayName: string;
29
+ };
30
+ originalName: string;
31
+ displayName: string;
32
+ } & {
33
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null) & {
34
+ original: ({ label, to, modelIds }: BreadcrumbRootProps) => React.JSX.Element | null;
35
+ originalName: string;
36
+ displayName: string;
37
+ }>) => (props: unknown) => React.JSX.Element;
38
+ };
@@ -0,0 +1,23 @@
1
+ import react from "react";
2
+ import { Property, useIdGenerator } from "@webiny/react-properties";
3
+ import { makeDecoratable } from "@webiny/react-composition";
4
+ import { useModel } from "../../../../hooks/index.js";
5
+ const BreadcrumbRoot = makeDecoratable("BreadcrumbRoot", ({ label, to, modelIds = [] })=>{
6
+ const { model } = useModel();
7
+ const getId = useIdGenerator("breadcrumbRoot");
8
+ if (modelIds.length > 0 && !modelIds.includes(model.modelId)) return null;
9
+ return /*#__PURE__*/ react.createElement(Property, {
10
+ id: "browser",
11
+ name: "browser"
12
+ }, /*#__PURE__*/ react.createElement(Property, {
13
+ id: getId("breadcrumbRoot"),
14
+ name: "breadcrumbRoot",
15
+ value: {
16
+ label,
17
+ to
18
+ }
19
+ }));
20
+ });
21
+ export { BreadcrumbRoot };
22
+
23
+ //# sourceMappingURL=BreadcrumbRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/config/contentEntries/list/Browser/BreadcrumbRoot.js","sources":["../../../../../../src/admin/config/contentEntries/list/Browser/BreadcrumbRoot.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport type { BreadcrumbLink } from \"@webiny/app-admin\";\nimport { useModel } from \"~/admin/hooks/index.js\";\n\nexport interface BreadcrumbRootConfig {\n label: string;\n to?: BreadcrumbLink;\n}\n\nexport interface BreadcrumbRootProps {\n /** Label of the leading breadcrumb (e.g. \"Headless CMS\", \"Tenant Manager\"). */\n label: string;\n /** Optional link for the root entry. */\n to?: BreadcrumbLink;\n /** Restrict this root to specific models (e.g. the tenant model). Empty = all models. */\n modelIds?: string[];\n}\n\n/**\n * Overrides the leading breadcrumb of the content-entries trail for apps that embed the\n * entries view (e.g. Tenant Manager reuses it for the tenant model). Scope it with `modelIds`,\n * mirroring the column/filter configs. When unset, the entries view defaults to \"Headless CMS\".\n */\nexport const BreadcrumbRoot = makeDecoratable(\n \"BreadcrumbRoot\",\n ({ label, to, modelIds = [] }: BreadcrumbRootProps) => {\n const { model } = useModel();\n const getId = useIdGenerator(\"breadcrumbRoot\");\n\n if (modelIds.length > 0 && !modelIds.includes(model.modelId)) {\n return null;\n }\n\n return (\n <Property id=\"browser\" name={\"browser\"}>\n <Property\n id={getId(\"breadcrumbRoot\")}\n name={\"breadcrumbRoot\"}\n value={{ label, to }}\n />\n </Property>\n );\n }\n);\n"],"names":["BreadcrumbRoot","makeDecoratable","label","to","modelIds","model","useModel","getId","useIdGenerator","Property"],"mappings":";;;;AAyBO,MAAMA,iBAAiBC,gBAC1B,kBACA,CAAC,EAAEC,KAAK,EAAEC,EAAE,EAAEC,WAAW,EAAE,EAAuB;IAC9C,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,QAAQC,eAAe;IAE7B,IAAIJ,SAAS,MAAM,GAAG,KAAK,CAACA,SAAS,QAAQ,CAACC,MAAM,OAAO,GACvD,OAAO;IAGX,OAAO,WAAP,GACI,oBAACI,UAAQA;QAAC,IAAG;QAAU,MAAM;qBACzB,oBAACA,UAAQA;QACL,IAAIF,MAAM;QACV,MAAM;QACN,OAAO;YAAEL;YAAOC;QAAG;;AAInC"}
@@ -9,6 +9,7 @@ import { FolderConfig } from "@webiny/app-aco/config/folder";
9
9
  import { RecordConfig } from "@webiny/app-aco/config/record";
10
10
  import type { SidebarFooterConfig } from "./SidebarFooter.js";
11
11
  import { SidebarFooter } from "./SidebarFooter.js";
12
+ import type { BreadcrumbRootConfig } from "./BreadcrumbRoot.js";
12
13
  export type { SidebarFooterConfig };
13
14
  export interface BrowserConfig {
14
15
  advancedSearch: AdvancedSearchConfig;
@@ -19,6 +20,7 @@ export interface BrowserConfig {
19
20
  filters: FilterConfig[];
20
21
  filtersToWhere: FiltersToWhereConverter[];
21
22
  sidebarFooter: SidebarFooterConfig[];
23
+ breadcrumbRoot?: BreadcrumbRootConfig;
22
24
  }
23
25
  export declare const Browser: {
24
26
  AdvancedSearch: {
@@ -49,6 +51,25 @@ export declare const Browser: {
49
51
  useButtons: () => import("@webiny/app-admin/components/Buttons/useButtons.js").ButtonsProviderContext;
50
52
  useDialog: () => import("@webiny/app-admin/index.js").UseDialogWithReportResponse;
51
53
  };
54
+ BreadcrumbRoot: (({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null) & {
55
+ original: ({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null;
56
+ originalName: string;
57
+ displayName: string;
58
+ } & {
59
+ original: (({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null) & {
60
+ original: ({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null;
61
+ originalName: string;
62
+ displayName: string;
63
+ };
64
+ originalName: string;
65
+ displayName: string;
66
+ } & {
67
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null) & {
68
+ original: ({ label, to, modelIds }: import("./BreadcrumbRoot.js").BreadcrumbRootProps) => import("react").JSX.Element | null;
69
+ originalName: string;
70
+ displayName: string;
71
+ }>) => (props: unknown) => React.JSX.Element;
72
+ };
52
73
  Filter: (({ name, element, modelIds, after, before, remove }: import("./Filter.js").FilterProps) => import("react").JSX.Element | null) & {
53
74
  original: ({ name, element, modelIds, after, before, remove }: import("./Filter.js").FilterProps) => import("react").JSX.Element | null;
54
75
  originalName: string;
@@ -7,9 +7,11 @@ import { FolderAction } from "./FolderAction.js";
7
7
  import { Table } from "./Table/index.js";
8
8
  import { FolderDropConfirmation } from "./FolderDropConfirmation.js";
9
9
  import { SidebarFooter } from "./SidebarFooter.js";
10
+ import { BreadcrumbRoot } from "./BreadcrumbRoot.js";
10
11
  const Browser = {
11
12
  AdvancedSearch: AdvancedSearch,
12
13
  BulkAction: BulkAction,
14
+ BreadcrumbRoot: BreadcrumbRoot,
13
15
  Filter: Filter,
14
16
  FiltersToWhere: FiltersToWhere,
15
17
  Table: Table,