@alpaca-editor/core 1.0.0 → 1.0.3764-editor-mono

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 (223) hide show
  1. package/dist/client-components/api.js +6 -0
  2. package/dist/client-components/index.js +36 -0
  3. package/dist/components/ActionButton.js +9 -0
  4. package/dist/components/Error.js +28 -0
  5. package/dist/config/config.js +654 -0
  6. package/dist/config/types.js +2 -0
  7. package/dist/editor/ComponentInfo.js +31 -0
  8. package/dist/editor/ConfirmationDialog.js +32 -0
  9. package/dist/editor/ContentTree.js +406 -0
  10. package/dist/editor/ContextMenu.js +117 -0
  11. package/dist/editor/Editor.js +55 -0
  12. package/dist/editor/EditorWarning.js +13 -0
  13. package/dist/editor/EditorWarnings.js +24 -0
  14. package/dist/editor/FieldEditorPopup.js +24 -0
  15. package/dist/editor/FieldHistory.js +40 -0
  16. package/dist/editor/FieldList.js +63 -0
  17. package/dist/editor/FieldListField.js +164 -0
  18. package/dist/editor/FieldListFieldWithFallbacks.js +114 -0
  19. package/dist/editor/FloatingToolbar.js +92 -0
  20. package/dist/editor/ImageEditor.js +55 -0
  21. package/dist/editor/InsertMenu.js +164 -0
  22. package/dist/editor/ItemInfo.js +30 -0
  23. package/dist/editor/LinkEditorDialog.js +89 -0
  24. package/dist/editor/MainLayout.js +46 -0
  25. package/dist/editor/NewEditorClient.js +9 -0
  26. package/dist/editor/PictureCropper.js +332 -0
  27. package/dist/editor/PictureEditor.js +104 -0
  28. package/dist/editor/PictureEditorDialog.js +194 -0
  29. package/dist/editor/ScrollingContentTree.js +30 -0
  30. package/dist/editor/Terminal.js +109 -0
  31. package/dist/editor/Titlebar.js +11 -0
  32. package/dist/editor/ai/AiPopup.js +25 -0
  33. package/dist/editor/ai/AiResponseMessage.js +24 -0
  34. package/dist/editor/ai/AiTerminal.js +241 -0
  35. package/dist/editor/ai/AiToolCall.js +18 -0
  36. package/dist/editor/ai/EditorAiTerminal.js +9 -0
  37. package/dist/editor/ai/editorAiContext.js +14 -0
  38. package/dist/editor/client/DialogContext.js +29 -0
  39. package/dist/editor/client/EditorClient.js +1336 -0
  40. package/dist/editor/client/GenericDialog.js +27 -0
  41. package/dist/editor/client/editContext.js +59 -0
  42. package/dist/editor/client/helpers.js +31 -0
  43. package/dist/editor/client/itemsRepository.js +255 -0
  44. package/dist/editor/client/operations.js +398 -0
  45. package/dist/editor/client/pageModelBuilder.js +129 -0
  46. package/dist/editor/commands/commands.js +2 -0
  47. package/dist/editor/commands/componentCommands.js +277 -0
  48. package/dist/editor/commands/createVersionCommand.js +26 -0
  49. package/dist/editor/commands/deleteVersionCommand.js +55 -0
  50. package/dist/editor/commands/itemCommands.js +134 -0
  51. package/dist/editor/commands/localizeItem/LocalizeItemDialog.js +94 -0
  52. package/dist/editor/commands/undo.js +32 -0
  53. package/dist/editor/component-designer/ComponentDesigner.js +58 -0
  54. package/dist/editor/component-designer/ComponentDesignerAiTerminal.js +9 -0
  55. package/dist/editor/component-designer/ComponentDesignerMenu.js +67 -0
  56. package/dist/editor/component-designer/ComponentEditor.js +59 -0
  57. package/dist/editor/component-designer/ComponentRenderingCodeEditor.js +16 -0
  58. package/dist/editor/component-designer/ComponentRenderingEditor.js +71 -0
  59. package/dist/editor/component-designer/ComponentsDropdown.js +22 -0
  60. package/dist/editor/component-designer/PlaceholdersEditor.js +70 -0
  61. package/dist/editor/component-designer/RenderingsDropdown.js +25 -0
  62. package/dist/editor/component-designer/TemplateEditor.js +144 -0
  63. package/dist/editor/component-designer/aiContext.js +18 -0
  64. package/dist/editor/componentTreeHelper.js +97 -0
  65. package/dist/editor/control-center/ControlCenterMenu.js +59 -0
  66. package/dist/editor/control-center/IndexOverview.js +27 -0
  67. package/dist/editor/control-center/IndexSettings.js +106 -0
  68. package/dist/editor/control-center/Status.js +7 -0
  69. package/dist/editor/editor-warnings/ItemLocked.js +40 -0
  70. package/dist/editor/editor-warnings/NoLanguageWriteAccess.js +16 -0
  71. package/dist/editor/editor-warnings/NoWorkflowWriteAccess.js +16 -0
  72. package/dist/editor/editor-warnings/NoWriteAccess.js +14 -0
  73. package/dist/editor/editor-warnings/ValidationErrors.js +27 -0
  74. package/dist/editor/field-types/AttachmentEditor.js +7 -0
  75. package/dist/editor/field-types/CheckboxEditor.js +32 -0
  76. package/dist/editor/field-types/DropLinkEditor.js +51 -0
  77. package/dist/editor/field-types/DropListEditor.js +58 -0
  78. package/dist/editor/field-types/ImageFieldEditor.js +36 -0
  79. package/dist/editor/field-types/InternalLinkFieldEditor.js +64 -0
  80. package/dist/editor/field-types/LinkFieldEditor.js +58 -0
  81. package/dist/editor/field-types/MultiLineText.js +35 -0
  82. package/dist/editor/field-types/PictureFieldEditor.js +59 -0
  83. package/dist/editor/field-types/RawEditor.js +33 -0
  84. package/dist/editor/field-types/ReactQuill.js +366 -0
  85. package/dist/editor/field-types/RichTextEditor.js +46 -0
  86. package/dist/editor/field-types/RichTextEditorComponent.js +72 -0
  87. package/dist/editor/field-types/SingleLineText.js +92 -0
  88. package/dist/editor/field-types/TreeListEditor.js +137 -0
  89. package/dist/editor/fieldTypes.js +2 -0
  90. package/dist/editor/media-selector/AiImageSearch.js +110 -0
  91. package/dist/editor/media-selector/AiImageSearchPrompt.js +58 -0
  92. package/dist/editor/media-selector/MediaSelector.js +11 -0
  93. package/dist/editor/media-selector/Preview.js +9 -0
  94. package/dist/editor/media-selector/Thumbnails.js +11 -0
  95. package/dist/editor/media-selector/TreeSelector.js +171 -0
  96. package/dist/editor/media-selector/UploadZone.js +80 -0
  97. package/dist/editor/menubar/ActionsMenu.js +33 -0
  98. package/dist/editor/menubar/ActiveUsers.js +13 -0
  99. package/dist/editor/menubar/ApproveAndPublish.js +13 -0
  100. package/dist/editor/menubar/BrowseHistory.js +14 -0
  101. package/dist/editor/menubar/ItemLanguageVersion.js +36 -0
  102. package/dist/editor/menubar/LanguageSelector.js +33 -0
  103. package/dist/editor/menubar/Menu.js +65 -0
  104. package/dist/editor/menubar/NavButtons.js +43 -0
  105. package/dist/editor/menubar/PageSelector.js +50 -0
  106. package/dist/editor/menubar/PageViewerControls.js +37 -0
  107. package/dist/editor/menubar/Separator.js +8 -0
  108. package/dist/editor/menubar/SiteInfo.js +26 -0
  109. package/dist/editor/menubar/User.js +18 -0
  110. package/dist/editor/menubar/VersionSelector.js +49 -0
  111. package/dist/editor/page-editor-chrome/CommentHighlighting.js +214 -0
  112. package/dist/editor/page-editor-chrome/CommentHighlightings.js +17 -0
  113. package/dist/editor/page-editor-chrome/FieldActionIndicator.js +27 -0
  114. package/dist/editor/page-editor-chrome/FieldActionIndicators.js +15 -0
  115. package/dist/editor/page-editor-chrome/FieldEditedIndicator.js +27 -0
  116. package/dist/editor/page-editor-chrome/FieldEditedIndicators.js +15 -0
  117. package/dist/editor/page-editor-chrome/FrameMenu.js +178 -0
  118. package/dist/editor/page-editor-chrome/FrameMenus.js +24 -0
  119. package/dist/editor/page-editor-chrome/InlineEditor.js +101 -0
  120. package/dist/editor/page-editor-chrome/LockedFieldIndicator.js +35 -0
  121. package/dist/editor/page-editor-chrome/NoLayout.js +21 -0
  122. package/dist/editor/page-editor-chrome/PageEditorChrome.js +65 -0
  123. package/dist/editor/page-editor-chrome/PictureEditorOverlay.js +109 -0
  124. package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +82 -0
  125. package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +147 -0
  126. package/dist/editor/page-viewer/DeviceToolbar.js +21 -0
  127. package/dist/editor/page-viewer/EditorForm.js +130 -0
  128. package/dist/editor/page-viewer/MiniMap.js +257 -0
  129. package/dist/editor/page-viewer/PageViewer.js +64 -0
  130. package/dist/editor/page-viewer/PageViewerFrame.js +696 -0
  131. package/dist/editor/page-viewer/pageViewContext.js +117 -0
  132. package/dist/editor/pageModel.js +2 -0
  133. package/dist/editor/picture-shared.js +28 -0
  134. package/dist/editor/reviews/Comment.js +112 -0
  135. package/dist/editor/reviews/Comments.js +24 -0
  136. package/dist/editor/reviews/PreviewInfo.js +13 -0
  137. package/dist/editor/reviews/Reviews.js +165 -0
  138. package/dist/editor/reviews/reviewCommands.js +44 -0
  139. package/dist/editor/reviews/useReviews.js +48 -0
  140. package/dist/editor/services/aiService.js +99 -0
  141. package/dist/editor/services/componentDesignerService.js +79 -0
  142. package/dist/editor/services/contentService.js +104 -0
  143. package/dist/editor/services/editService.js +322 -0
  144. package/dist/editor/services/indexService.js +25 -0
  145. package/dist/editor/services/reviewsService.js +43 -0
  146. package/dist/editor/services/serviceHelper.js +67 -0
  147. package/dist/editor/services/systemService.js +7 -0
  148. package/dist/editor/services/translationService.js +15 -0
  149. package/dist/editor/services-server/api.js +119 -0
  150. package/dist/editor/services-server/graphQL.js +56 -0
  151. package/dist/editor/sidebar/ComponentPalette.js +55 -0
  152. package/dist/editor/sidebar/ComponentTree.js +362 -0
  153. package/dist/editor/sidebar/Debug.js +60 -0
  154. package/dist/editor/sidebar/DictionaryEditor.js +160 -0
  155. package/dist/editor/sidebar/EditHistory.js +74 -0
  156. package/dist/editor/sidebar/GraphQL.js +115 -0
  157. package/dist/editor/sidebar/Insert.js +24 -0
  158. package/dist/editor/sidebar/MainContentTree.js +52 -0
  159. package/dist/editor/sidebar/Performance.js +34 -0
  160. package/dist/editor/sidebar/Sessions.js +31 -0
  161. package/dist/editor/sidebar/Sidebar.js +15 -0
  162. package/dist/editor/sidebar/SidebarView.js +76 -0
  163. package/dist/editor/sidebar/Translations.js +160 -0
  164. package/dist/editor/sidebar/Validation.js +52 -0
  165. package/dist/editor/sidebar/ViewSelector.js +15 -0
  166. package/dist/editor/sidebar/Workbox.js +80 -0
  167. package/dist/editor/ui/CenteredMessage.js +7 -0
  168. package/dist/editor/ui/CopyToClipboardButton.js +17 -0
  169. package/dist/editor/ui/DialogButtons.js +7 -0
  170. package/dist/editor/ui/Icons.js +75 -0
  171. package/dist/editor/ui/ItemNameDialog.js +45 -0
  172. package/dist/editor/ui/ItemNameDialogNew.js +61 -0
  173. package/dist/editor/ui/ItemSearch.js +93 -0
  174. package/dist/editor/ui/PerfectTree.js +223 -0
  175. package/dist/editor/ui/Section.js +12 -0
  176. package/dist/editor/ui/SimpleIconButton.js +11 -0
  177. package/dist/editor/ui/SimpleMenu.js +9 -0
  178. package/dist/editor/ui/SimpleTable.js +11 -0
  179. package/dist/editor/ui/SimpleTabs.js +21 -0
  180. package/dist/editor/ui/SimpleToolbar.js +7 -0
  181. package/dist/editor/ui/Spinner.js +7 -0
  182. package/dist/editor/ui/Splitter.js +187 -0
  183. package/dist/editor/ui/StackedPanels.js +69 -0
  184. package/dist/editor/ui/Toolbar.js +7 -0
  185. package/dist/editor/utils/id-helper.js +7 -0
  186. package/dist/editor/utils/insertOptions.js +45 -0
  187. package/dist/editor/utils/itemutils.js +25 -0
  188. package/dist/editor/utils/useMemoDebug.js +20 -0
  189. package/dist/editor/utils.js +328 -0
  190. package/dist/editor/views/CompareView.js +147 -0
  191. package/dist/editor/views/EditView.js +17 -0
  192. package/dist/editor/views/ItemEditor.js +24 -0
  193. package/dist/editor/views/SingleEditView.js +25 -0
  194. package/dist/index.js +22 -0
  195. package/dist/page-wizard/PageWizard.js +62 -0
  196. package/dist/page-wizard/SelectWizard.js +43 -0
  197. package/dist/page-wizard/WizardSteps.js +71 -0
  198. package/dist/page-wizard/service.js +26 -0
  199. package/dist/page-wizard/startPageWizardCommand.js +23 -0
  200. package/dist/page-wizard/steps/BuildPageStep.js +138 -0
  201. package/dist/page-wizard/steps/CollectStep.js +124 -0
  202. package/dist/page-wizard/steps/ComponentTypesSelector.js +211 -0
  203. package/dist/page-wizard/steps/Components.js +94 -0
  204. package/dist/page-wizard/steps/CreatePage.js +142 -0
  205. package/dist/page-wizard/steps/CreatePageAndLayoutStep.js +230 -0
  206. package/dist/page-wizard/steps/EditButton.js +7 -0
  207. package/dist/page-wizard/steps/FieldEditor.js +30 -0
  208. package/dist/page-wizard/steps/Generate.js +11 -0
  209. package/dist/page-wizard/steps/ImagesStep.js +159 -0
  210. package/dist/page-wizard/steps/LayoutStep.js +120 -0
  211. package/dist/page-wizard/steps/SelectStep.js +150 -0
  212. package/dist/page-wizard/steps/schema.js +140 -0
  213. package/dist/page-wizard/steps/usePageCreator.js +194 -0
  214. package/dist/splash-screen/NewPage.js +131 -0
  215. package/dist/splash-screen/SectionHeadline.js +9 -0
  216. package/dist/splash-screen/SplashScreen.js +81 -0
  217. package/dist/tour/Tour.js +321 -0
  218. package/dist/tour/default-tour.js +231 -0
  219. package/dist/tour/preview-tour.js +93 -0
  220. package/dist/tsconfig.build.tsbuildinfo +1 -0
  221. package/dist/types.js +2 -0
  222. package/package.json +1 -1
  223. package/src/editor/sidebar/ComponentTree.tsx +512 -512
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ComponentInfo = ComponentInfo;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const CopyToClipboardButton_1 = require("./ui/CopyToClipboardButton");
8
+ const Section_1 = require("./ui/Section");
9
+ const editContext_1 = require("./client/editContext");
10
+ function ComponentInfo({ component }) {
11
+ if (!component)
12
+ return null;
13
+ const editContext = (0, editContext_1.useEditContext)();
14
+ const [layoutItem, setLayoutItem] = (0, react_1.useState)();
15
+ (0, react_1.useEffect)(() => {
16
+ if (!component.layoutId) {
17
+ setLayoutItem(undefined);
18
+ return;
19
+ }
20
+ editContext.itemsRepository
21
+ .getItem({
22
+ id: component.layoutId,
23
+ language: editContext.currentItemDescriptor.language,
24
+ version: 0,
25
+ })
26
+ .then(setLayoutItem);
27
+ }, [component.layoutId]);
28
+ const hostingPageItem = layoutItem ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: "Source:" }), (0, jsx_runtime_1.jsxs)("div", { children: [layoutItem.path, " ID: ", layoutItem.id] })] })) : null;
29
+ const linkedComponent = component.datasourceItem ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: "Source:" }), (0, jsx_runtime_1.jsxs)("div", { children: [component.datasourceItem.path, " (", component.datasourceItem.id, ")"] })] })) : null;
30
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h2", { className: "py-3 px-3 text-l font-bold my-2", children: component.name }), (0, jsx_runtime_1.jsx)(Section_1.Section, { title: "Info", children: (0, jsx_runtime_1.jsxs)("div", { className: "grid grid-cols-[min-content_1fr] gap-3 text-xs bg-gray-100", children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: "ID:" }), (0, jsx_runtime_1.jsxs)("div", { children: [component.id, " ", (0, jsx_runtime_1.jsx)(CopyToClipboardButton_1.CopyToClipboardButton, { text: component.id })] }), (0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: "Template" }), (0, jsx_runtime_1.jsxs)("div", { children: ["(", component.datasourceItem?.templateId, component.datasourceItem && ((0, jsx_runtime_1.jsx)(CopyToClipboardButton_1.CopyToClipboardButton, { text: component.datasourceItem.templateId })), ")"] }), (0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: "Languages" }), (0, jsx_runtime_1.jsx)("div", { children: component.datasourceItem?.translations?.join(", ") }), hostingPageItem, linkedComponent] }) })] }));
31
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const dialog_1 = require("primereact/dialog");
6
+ const button_1 = require("primereact/button");
7
+ const ConfirmationDialog = (0, react_1.forwardRef)((_props, ref) => {
8
+ const [visible, setVisible] = (0, react_1.useState)(false);
9
+ const [props, setProps] = (0, react_1.useState)();
10
+ const showAccept = props?.accept === undefined ? true : props.accept;
11
+ (0, react_1.useImperativeHandle)(ref, () => ({
12
+ confirm: (props) => {
13
+ setVisible(true);
14
+ setProps(props);
15
+ },
16
+ }));
17
+ const handleAccept = () => {
18
+ props?.accept();
19
+ setVisible(false);
20
+ };
21
+ const handleReject = () => {
22
+ if (props?.reject)
23
+ props.reject();
24
+ setVisible(false);
25
+ };
26
+ const handleCancel = () => {
27
+ setVisible(false);
28
+ };
29
+ const dialogFooter = ((0, jsx_runtime_1.jsxs)("div", { children: [showAccept && ((0, jsx_runtime_1.jsx)(button_1.Button, { label: props?.acceptLabel || "Yes", icon: props?.acceptIcon || "pi pi-check", onClick: handleAccept, className: "p-button-text" })), props?.rejectLabel && ((0, jsx_runtime_1.jsx)(button_1.Button, { label: props?.rejectLabel, icon: props?.rejectIcon || "pi pi-times", onClick: handleReject, className: "p-button-text" })), props?.showCancel && ((0, jsx_runtime_1.jsx)(button_1.Button, { label: "Cancel", icon: "pi pi-ban", onClick: handleCancel, className: "p-button-text" }))] }));
30
+ return (visible && ((0, jsx_runtime_1.jsx)(dialog_1.Dialog, { header: props?.header || "Confirm", visible: visible, style: { maxWidth: "50vw" }, footer: dialogFooter, onHide: handleCancel, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 p-3", children: [props?.icon && (0, jsx_runtime_1.jsx)("i", { className: props.icon + " text-3xl" }), props?.message] }) })));
31
+ });
32
+ exports.default = ConfirmationDialog;
@@ -0,0 +1,406 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.default = ContentTree;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const editContext_1 = require("./client/editContext");
7
+ const react_1 = require("react");
8
+ const contentService_1 = require("./services/contentService");
9
+ const contextmenu_1 = require("primereact/contextmenu");
10
+ const ItemNameDialog_1 = require("./ui/ItemNameDialog");
11
+ const utils_1 = require("./utils");
12
+ const Spinner_1 = require("./ui/Spinner");
13
+ const PerfectTree_1 = require("./ui/PerfectTree");
14
+ // Create a memoized version of PerfectTree
15
+ const MemoizedPerfectTree = (0, react_1.memo)(PerfectTree_1.PerfectTree);
16
+ function ContentTree({ isDraggable, dragStart, dragEnd, expandIdPath, selectionMode, selectedItemIds, rootItemId, rootItemIds, onSelectionChange, filter, templateIds, className, includeEmbeddedItems, onDoubleClick, selectPagesOnly, renderNode, onItemInserted, language, includeItemPath, }) {
17
+ const [treeNodes, setTreeNodes] = (0, react_1.useState)([]);
18
+ const [selectedNodeElement, setSelectedNodeElement] = (0, react_1.useState)(null);
19
+ const [selectedKeys, setSelectedKeys] = (0, react_1.useState)([]);
20
+ const [expandedKeys, setExpandedKeys] = (0, react_1.useState)([]);
21
+ const treeContainerRef = (0, react_1.useRef)(null);
22
+ const editContext = (0, editContext_1.useEditContext)();
23
+ const nodeDictionary = (0, react_1.useRef)({});
24
+ const cm = (0, react_1.useRef)(null);
25
+ const [menu, setMenu] = (0, react_1.useState)([]);
26
+ const itemNameDialogRef = (0, react_1.useRef)(null);
27
+ const editContextRef = (0, editContext_1.useEditContextRef)();
28
+ const lastSelectedItemId = (0, react_1.useRef)(undefined);
29
+ const loadNodeChildren = (0, react_1.useCallback)(async (node) => {
30
+ if (!editContext)
31
+ return [];
32
+ let children = await (0, contentService_1.getChildren)(node.key, editContext.sessionId, templateIds, includeEmbeddedItems ?? false, language, includeItemPath ? "path,idPath" : undefined);
33
+ if (filter)
34
+ children = filter(children);
35
+ return children.map((x) => ({
36
+ key: x.id,
37
+ label: x.name,
38
+ iconUrl: (0, utils_1.getAbsoluteIconUrl)(x.icon),
39
+ isDraggable: isDraggable && isDraggable(x),
40
+ selectable: !selectPagesOnly || x.hasLayout,
41
+ data: x,
42
+ hasChildren: x.hasChildren,
43
+ parent: node,
44
+ }));
45
+ }, [
46
+ editContext,
47
+ filter,
48
+ includeEmbeddedItems,
49
+ isDraggable,
50
+ language,
51
+ selectPagesOnly,
52
+ templateIds,
53
+ includeItemPath,
54
+ ]);
55
+ const updateCorrespondingNode = (0, react_1.useCallback)((x, parent) => {
56
+ const node = nodeDictionary.current[x.id];
57
+ if (!node)
58
+ return;
59
+ node.label = x.name;
60
+ node.iconUrl = (0, utils_1.getAbsoluteIconUrl)(x.icon);
61
+ node.isDraggable =
62
+ isDraggable &&
63
+ isDraggable({
64
+ ...x,
65
+ isComponent: !x.hasLayout,
66
+ thumbUrl: "",
67
+ previewUrl: "",
68
+ });
69
+ node.selectable = !selectPagesOnly || x.hasLayout;
70
+ node.data = x;
71
+ node.hasChildren = x.hasChildren;
72
+ node.parent = parent;
73
+ }, [isDraggable, selectPagesOnly]);
74
+ const loadNode = (0, react_1.useCallback)(async (descriptor) => {
75
+ const item = await editContext?.itemsRepository.getItem(descriptor);
76
+ if (!item)
77
+ return;
78
+ return {
79
+ key: item.id,
80
+ label: item.name,
81
+ iconUrl: (0, utils_1.getAbsoluteIconUrl)(item.icon),
82
+ isDraggable: isDraggable &&
83
+ isDraggable({
84
+ ...item,
85
+ isComponent: !item.hasLayout,
86
+ thumbUrl: "",
87
+ previewUrl: "",
88
+ }),
89
+ selectable: !selectPagesOnly || item.hasLayout,
90
+ data: item,
91
+ hasChildren: item.hasChildren,
92
+ };
93
+ }, [editContext?.itemsRepository, isDraggable, selectPagesOnly]);
94
+ const loadRootNodes = (0, react_1.useCallback)(async (force = false) => {
95
+ if (!force && treeNodes.length > 0)
96
+ return treeNodes;
97
+ if (rootItemId)
98
+ return await loadNodeChildren({ key: rootItemId, label: "" });
99
+ return await Promise.all(rootItemIds
100
+ ?.map((rootItemId) => loadNode({
101
+ id: rootItemId,
102
+ language,
103
+ version: 0,
104
+ }))
105
+ .filter((x) => x) || []);
106
+ }, [loadNode, loadNodeChildren, rootItemId, rootItemIds, language]);
107
+ const doPreloadNodes = (0, react_1.useCallback)(async (expandedKeys, treeNodes) => {
108
+ for (let i = 0; i < treeNodes.length; i++) {
109
+ const node = treeNodes[i];
110
+ if (!node)
111
+ continue;
112
+ let children = node.children;
113
+ if (expandedKeys.includes(node.key) && !children) {
114
+ children = node.data.hasChildren ? await loadNodeChildren(node) : [];
115
+ node.children = children;
116
+ }
117
+ if (expandedKeys.includes(node.key) &&
118
+ children &&
119
+ children.length > 0) {
120
+ await doPreloadNodes(expandedKeys, children);
121
+ }
122
+ }
123
+ }, [loadNodeChildren]);
124
+ const preLoadNodes = (0, react_1.useCallback)(async (expandedKeys, force) => {
125
+ const rootNodes = await loadRootNodes(force);
126
+ await doPreloadNodes(expandedKeys, rootNodes);
127
+ setTreeNodes([...rootNodes.filter((x) => x)]);
128
+ }, [doPreloadNodes, loadRootNodes]);
129
+ const refreshNode = (0, react_1.useCallback)(async (node) => {
130
+ const tempNode = { ...node };
131
+ tempNode.children = undefined;
132
+ await doPreloadNodes(expandedKeys || [], [tempNode]);
133
+ const item = await editContext?.itemsRepository.getItem(node.data);
134
+ if (item)
135
+ updateCorrespondingNode(item, node);
136
+ node.children = tempNode.children;
137
+ }, [
138
+ editContext?.itemsRepository,
139
+ expandedKeys,
140
+ doPreloadNodes,
141
+ updateCorrespondingNode,
142
+ ]);
143
+ (0, react_1.useEffect)(() => {
144
+ preLoadNodes(expandedKeys || [], false);
145
+ }, [language, preLoadNodes, expandedKeys]);
146
+ (0, react_1.useEffect)(() => {
147
+ if (!editContext?.itemsRepository)
148
+ return;
149
+ const unsubscribe = editContext.itemsRepository.subscribeItemsChanged(async (items) => {
150
+ const nodes = items
151
+ .map((x) => x.action === "delete" && x.parentId
152
+ ? nodeDictionary.current[x.parentId]
153
+ : nodeDictionary.current[x.item.id])
154
+ .filter((x) => x);
155
+ if (nodes.length === 0)
156
+ return;
157
+ await Promise.all(nodes.map(async (x) => {
158
+ if (x)
159
+ await refreshNode(x);
160
+ }));
161
+ setTreeNodes((prev) => [...prev]);
162
+ });
163
+ return () => {
164
+ unsubscribe();
165
+ };
166
+ }, [editContext?.itemsRepository, refreshNode]);
167
+ function getExpandedKeys() {
168
+ const newExpandedKeys = [];
169
+ if (rootItemId)
170
+ newExpandedKeys.push(rootItemId.toLowerCase().replace(/[{}]/g, ""));
171
+ if (!expandIdPath)
172
+ return newExpandedKeys;
173
+ const idPathArray = expandIdPath.toLowerCase().split("/");
174
+ idPathArray.forEach((x) => {
175
+ if (x !== "")
176
+ newExpandedKeys.push(x.substring(1, x.length - 1));
177
+ });
178
+ return newExpandedKeys;
179
+ }
180
+ (0, react_1.useEffect)(() => {
181
+ const newExpandedKeys = getExpandedKeys();
182
+ const hasNewKeys = newExpandedKeys.some((key) => !expandedKeys.includes(key));
183
+ if (hasNewKeys) {
184
+ setExpandedKeys([...new Set([...expandedKeys, ...newExpandedKeys])]);
185
+ }
186
+ }, [expandIdPath, preLoadNodes]);
187
+ (0, react_1.useEffect)(() => {
188
+ const newNodeDictionary = {};
189
+ createMap(treeNodes, newNodeDictionary);
190
+ nodeDictionary.current = newNodeDictionary;
191
+ }, [treeNodes]);
192
+ function createMap(treeNodes, nodeDictionary) {
193
+ treeNodes.forEach((n) => {
194
+ if (n.key)
195
+ nodeDictionary[n.key] = n;
196
+ if (n.children)
197
+ createMap(n.children, nodeDictionary);
198
+ });
199
+ }
200
+ const nodeTemplate = (0, react_1.useCallback)((node) => {
201
+ let label = (0, jsx_runtime_1.jsx)("span", { children: node.label });
202
+ if (node.url) {
203
+ label = ((0, jsx_runtime_1.jsx)("a", { onDragStart: (e) => e.preventDefault(), href: node.url, className: "text-primary font-semibold hover:underline", children: node.label }));
204
+ }
205
+ const getNodeCursor = (node) => {
206
+ if (node.isDraggable)
207
+ return "cursor-grab";
208
+ return "";
209
+ };
210
+ return ((0, jsx_runtime_1.jsxs)("span", {
211
+ // onDragStart={(event: React.DragEvent<HTMLDivElement>) => {
212
+ // handleDragStart(node, event);
213
+ // }}
214
+ // onDragEnd={handleDragEnd}
215
+ // draggable={node.isDraggable}
216
+ className: `flex items-center gap-2 text-xs ${getNodeCursor(node)} ${node.className}`, children: [(0, jsx_runtime_1.jsx)("img", { src: node.iconUrl, style: { height: "16px" }, width: "16", height: "16", onDragStart: (e) => e.preventDefault() }), label] }));
217
+ }, []);
218
+ function handleDragStart(data) {
219
+ const items = data.isMultiSelect
220
+ ? selectedItemIds?.map((x) => nodeDictionary.current[x]?.data)
221
+ : [data.node.data];
222
+ setTimeout(() => {
223
+ editContextRef.current?.dragStart({
224
+ type: "items",
225
+ typeId: data.node.data.templateId,
226
+ items: items,
227
+ });
228
+ }, 10);
229
+ //dragStart?.(data.node.data);
230
+ data.event.stopPropagation();
231
+ }
232
+ function handleDrop(parent, index, event) {
233
+ const object = editContextRef.current?.dragObject;
234
+ if (!object)
235
+ return;
236
+ if (object.type === "items" && object.items) {
237
+ editContextRef.current?.operations.moveItems(object.items, parent.data, index);
238
+ }
239
+ event.stopPropagation();
240
+ }
241
+ function handleDragEnd() {
242
+ editContextRef.current?.dragEnd();
243
+ if (dragEnd)
244
+ dragEnd();
245
+ }
246
+ (0, react_1.useEffect)(() => {
247
+ if (!selectedNodeElement)
248
+ return;
249
+ const container = treeContainerRef.current;
250
+ if (!container)
251
+ return;
252
+ if (!treeContainerRef.current)
253
+ return;
254
+ const containerRect = treeContainerRef.current.getBoundingClientRect();
255
+ const nodeRect = selectedNodeElement.getBoundingClientRect();
256
+ if (nodeRect.top < containerRect.top ||
257
+ nodeRect.top > containerRect.bottom) {
258
+ selectedNodeElement.scrollIntoView({
259
+ behavior: "smooth",
260
+ block: "center",
261
+ inline: "center",
262
+ });
263
+ }
264
+ }, [selectedNodeElement]);
265
+ (0, react_1.useEffect)(() => {
266
+ setSelectedKeys(selectedItemIds || []);
267
+ }, [selectedItemIds]);
268
+ const itemCommands = editContext?.configuration.commands.allItemCommands || [];
269
+ const onContextMenu = (0, react_1.useCallback)(async (node, originalEvent) => {
270
+ console.log("CONTEXT MENU", node);
271
+ const key = node.key;
272
+ let itemIds = selectedItemIds;
273
+ if (!itemIds || !itemIds.includes(key)) {
274
+ if (onSelectionChange && selectionMode == "single") {
275
+ onSelectionChange([node.data]);
276
+ }
277
+ itemIds = [key];
278
+ }
279
+ const items = await editContext?.itemsRepository.getItems(itemIds.map((x) => ({
280
+ id: x,
281
+ language: editContext.contentEditorItem?.language || "en",
282
+ version: 0,
283
+ })));
284
+ console.log("ITEMS", items);
285
+ if (!items || items.length === 0)
286
+ return;
287
+ const menuItems = await editContext?.configuration.editor.contentTree.contextMenu.factory({
288
+ items: items,
289
+ editContext: editContext,
290
+ commandCallback: (command, result) => {
291
+ if (command.id === "insertItem") {
292
+ const item = result;
293
+ if (item) {
294
+ setExpandedKeys((keys) => [...keys, item.id]);
295
+ onItemInserted?.(item);
296
+ }
297
+ }
298
+ },
299
+ });
300
+ if (menuItems)
301
+ setMenu(menuItems);
302
+ console.log("SHOWING CONTEXT MENU", originalEvent);
303
+ cm.current?.show(originalEvent);
304
+ }, [
305
+ itemCommands,
306
+ editContext,
307
+ selectedItemIds,
308
+ onSelectionChange,
309
+ selectionMode,
310
+ onItemInserted,
311
+ ]);
312
+ // Memoize the toggle expand handler
313
+ const handleToggleExpand = (0, react_1.useCallback)((nodeKey) => {
314
+ setExpandedKeys((value) => {
315
+ if (value.includes(nodeKey))
316
+ return value.filter((x) => x !== nodeKey);
317
+ else
318
+ return [...value, nodeKey];
319
+ });
320
+ }, []);
321
+ // Memoize the node selection handler
322
+ const handleNodeSelect = (0, react_1.useCallback)((nodeKey, ev) => {
323
+ let newSelection = [...selectedKeys];
324
+ if (selectionMode == "multiple" &&
325
+ ev.shiftKey &&
326
+ lastSelectedItemId.current) {
327
+ // Get the nodes
328
+ const lastNode = nodeDictionary.current[lastSelectedItemId.current];
329
+ const currentNode = nodeDictionary.current[nodeKey];
330
+ // Check if both nodes exist and have the same parent
331
+ if (lastNode &&
332
+ currentNode &&
333
+ lastNode.parent?.key === currentNode.parent?.key) {
334
+ const parentNode = lastNode.parent;
335
+ // Get all children of the parent
336
+ const siblings = parentNode?.children || [];
337
+ // Find indices of selected nodes
338
+ const siblingKeys = siblings.map((node) => node.key);
339
+ const lastNodeIndex = siblingKeys.indexOf(lastSelectedItemId.current);
340
+ const currentNodeIndex = siblingKeys.indexOf(nodeKey);
341
+ // Determine start and end indices
342
+ const startIdx = Math.min(lastNodeIndex, currentNodeIndex);
343
+ const endIdx = Math.max(lastNodeIndex, currentNodeIndex);
344
+ // Get all nodes between (inclusive)
345
+ const nodesToSelect = siblingKeys.slice(startIdx, endIdx + 1);
346
+ // Combine with existing selection
347
+ newSelection = [...new Set([...newSelection, ...nodesToSelect])];
348
+ }
349
+ else {
350
+ // If not on same level, just select the current node
351
+ newSelection = [nodeKey];
352
+ }
353
+ }
354
+ else if (selectionMode === "multiple" && ev.ctrlKey) {
355
+ newSelection = selectedKeys.includes(nodeKey)
356
+ ? selectedKeys.filter((x) => x !== nodeKey)
357
+ : [...selectedKeys, nodeKey];
358
+ }
359
+ else {
360
+ lastSelectedItemId.current = nodeKey;
361
+ newSelection = [nodeKey];
362
+ }
363
+ setSelectedKeys(newSelection);
364
+ if (onSelectionChange) {
365
+ const selectedNodes = newSelection
366
+ .filter((key) => nodeDictionary.current[key])
367
+ .map((key) => nodeDictionary.current[key]);
368
+ onSelectionChange(selectedNodes.map((x) => x?.data));
369
+ }
370
+ }, [onSelectionChange, selectionMode, selectedKeys]);
371
+ // Memoize the renderNode function
372
+ const memoizedRenderNode = (0, react_1.useMemo)(() => {
373
+ if (renderNode) {
374
+ return (node) => renderNode(node, (n) => nodeTemplate(n));
375
+ }
376
+ return nodeTemplate;
377
+ }, [renderNode, nodeTemplate]);
378
+ // Memoize the double click handler
379
+ const handleDoubleClick = (0, react_1.useCallback)((node) => {
380
+ onDoubleClick?.(nodeDictionary.current[node.key]?.data);
381
+ }, [onDoubleClick]);
382
+ // Memoize treeNodes to prevent unnecessary re-renders
383
+ const memoizedTreeNodes = (0, react_1.useMemo)(() => treeNodes, [treeNodes]);
384
+ const loadChildren = (0, react_1.useCallback)(async (node, forceReload = false) => {
385
+ if (!node.children || forceReload) {
386
+ const nodes = await loadNodeChildren(node);
387
+ node.children = nodes;
388
+ console.log("LOAD CHILDREN COMPLETED", node.key, nodes);
389
+ setTreeNodes((prev) => [...prev]);
390
+ }
391
+ }, [loadNodeChildren]);
392
+ const loadOnExpand = (0, react_1.useCallback)(async (node) => {
393
+ node.children = null;
394
+ setTreeNodes([...treeNodes]);
395
+ await loadChildren(node);
396
+ }, [loadChildren, treeNodes]);
397
+ const handleDragOverZone = (0, react_1.useCallback)((node, index, event) => {
398
+ return true;
399
+ }, []);
400
+ if (!memoizedTreeNodes.length)
401
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-full items-center justify-center gap-2 bg-gray-50 text-sm text-gray-500", children: [(0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { size: "3xl" }), " Loading..."] }));
402
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ItemNameDialog_1.ItemNameDialog, { ref: itemNameDialogRef }), (0, jsx_runtime_1.jsx)(contextmenu_1.ContextMenu, { model: menu, ref: cm, className: "text-sm" }), (0, jsx_runtime_1.jsx)("div", { className: className, ref: treeContainerRef, children: (0, jsx_runtime_1.jsx)(MemoizedPerfectTree, { nodes: memoizedTreeNodes, expandedKeys: expandedKeys, onToggleExpand: handleToggleExpand, renderNode: memoizedRenderNode, onLazyLoad: loadOnExpand, onDoubleClick: handleDoubleClick, onSelect: handleNodeSelect, selectedKeys: selectedKeys, onContextMenu: onContextMenu, enableDragAndDrop: true, onStartDrag: handleDragStart, onDragOverZone: handleDragOverZone, onDragEnd: handleDragEnd, isDragging: editContext?.dragObject !== undefined, onDrop: (parent, index, event) => {
403
+ console.log("DROP", parent, index, event);
404
+ handleDrop(parent, index, event);
405
+ } }) })] }));
406
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditContextMenu = void 0;
4
+ exports.showComponentContextMenu = showComponentContextMenu;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const contextmenu_1 = require("primereact/contextmenu");
8
+ // export function getFieldContextMenu(
9
+ // field: Field,
10
+ // editContext: EditContextType,
11
+ // customButtons: EditButton[] = []
12
+ // ) {
13
+ // return (e: any) => {
14
+ // e.preventDefault();
15
+ // e.stopPropagation();
16
+ // const menuItems: MenuItem[] = getComponentMenuItems(
17
+ // editContext,
18
+ // getComponentById(field._editor!.descriptor.item.id, editContext.page!)!
19
+ // );
20
+ // if (customButtons.length) {
21
+ // if (menuItems.length)
22
+ // menuItems.push({
23
+ // separator: true,
24
+ // });
25
+ // customButtons.forEach((button) => {
26
+ // menuItems.push({
27
+ // label: button.label,
28
+ // command: (ev) => button.onClick(ev.originalEvent as any),
29
+ // icon: button.icon,
30
+ // });
31
+ // });
32
+ // }
33
+ // if (field._editor?.buttons?.length) {
34
+ // if (menuItems.length)
35
+ // menuItems.push({
36
+ // separator: true,
37
+ // });
38
+ // field._editor?.buttons.forEach((button: FieldButton) => {
39
+ // menuItems.push({
40
+ // label: button.label,
41
+ // command: () => {
42
+ // editContext!.triggerFieldAction(field._editor!.descriptor, button);
43
+ // },
44
+ // icon: button.icon ? "pi " + button.icon : undefined,
45
+ // });
46
+ // });
47
+ // }
48
+ // if (!e.ctrlKey && !e.shiftKey && !e.altKey && menuItems.length) {
49
+ // editContext.select([field._editor!.descriptor.item.id]);
50
+ // editContext!.setFocusedField(field._editor!.descriptor, false);
51
+ // editContext!.showContextMenu(e, menuItems);
52
+ // }
53
+ // };
54
+ // }
55
+ function showComponentContextMenu(components, editContext, field, fieldButtons) {
56
+ const componentCommandMenuItems = getComponentMenuItems(editContext, components);
57
+ const menuItems = componentCommandMenuItems;
58
+ if (!editContext.readonly && field && fieldButtons?.length) {
59
+ if (menuItems.length)
60
+ menuItems.push({
61
+ separator: true,
62
+ });
63
+ fieldButtons.forEach((button) => {
64
+ menuItems.push({
65
+ label: button.label,
66
+ command: () => {
67
+ editContext.triggerFieldAction(field, button);
68
+ },
69
+ icon: button.icon ? "pi " + button.icon : undefined,
70
+ });
71
+ });
72
+ }
73
+ return (e) => {
74
+ if (!e.shiftKey && !e.altKey) {
75
+ if (menuItems.length) {
76
+ // editContext.select([component.id]);
77
+ editContext.showContextMenu(e, menuItems);
78
+ }
79
+ return true;
80
+ }
81
+ return false;
82
+ };
83
+ }
84
+ exports.EditContextMenu = (0, react_1.forwardRef)((props, ref) => {
85
+ const cm = (0, react_1.useRef)(null);
86
+ const [menuItems, setMenuItems] = (0, react_1.useState)([]);
87
+ if (!props)
88
+ return;
89
+ (0, react_1.useImperativeHandle)(ref, () => ({
90
+ show: (e, items) => {
91
+ if (!e.ctrlKey && !e.shiftKey && !e.altKey) {
92
+ setMenuItems(items);
93
+ e.preventDefault();
94
+ cm.current?.show(e);
95
+ }
96
+ },
97
+ close: (event) => {
98
+ cm.current?.hide(event);
99
+ },
100
+ }));
101
+ return (0, jsx_runtime_1.jsx)(contextmenu_1.ContextMenu, { model: menuItems, ref: cm });
102
+ });
103
+ function getComponentMenuItems(editContext, components) {
104
+ const componentCommands = editContext.getComponentCommands(components);
105
+ const componentCommandMenuItems = componentCommands.map((x) => {
106
+ return {
107
+ label: x.label,
108
+ icon: x.icon,
109
+ command: (ev) => editContext.executeCommand({
110
+ command: x,
111
+ event: ev.originalEvent,
112
+ }),
113
+ disabled: editContext.isCommandDisabled({ command: x }),
114
+ };
115
+ });
116
+ return componentCommandMenuItems;
117
+ }
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.Editor = Editor;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const EditorClient_1 = require("./client/EditorClient");
10
+ const DialogContext_1 = require("./client/DialogContext");
11
+ const react_1 = require("react");
12
+ const editService_1 = require("./services/editService");
13
+ const systemService_1 = require("./services/systemService");
14
+ const react_uuid_1 = __importDefault(require("react-uuid"));
15
+ const config_1 = require("../config/config");
16
+ function Editor({ configure, className, page, }) {
17
+ const [config, setConfig] = (0, react_1.useState)();
18
+ const [userInfo, setUserInfo] = (0, react_1.useState)();
19
+ const [systemStatus, setSystemStatus] = (0, react_1.useState)();
20
+ const sessionId = typeof window !== "undefined"
21
+ ? sessionStorage.getItem("sessionId") || (0, react_uuid_1.default)()
22
+ : (0, react_uuid_1.default)();
23
+ (0, react_1.useEffect)(() => {
24
+ // Get user info and system status
25
+ (0, editService_1.getUserInfo)().then((userInfo) => {
26
+ if (!userInfo) {
27
+ window.location.href = "/sitecore/login";
28
+ return;
29
+ }
30
+ setUserInfo(userInfo);
31
+ });
32
+ (0, systemService_1.getSystemStatus)().then((status) => {
33
+ if (status.data) {
34
+ setSystemStatus(status.data);
35
+ }
36
+ });
37
+ }, []);
38
+ (0, react_1.useEffect)(() => {
39
+ if (!userInfo || !systemStatus)
40
+ return;
41
+ const config = configure({
42
+ configuration: (0, config_1.getConfiguration)(),
43
+ user: userInfo,
44
+ });
45
+ setConfig(config);
46
+ }, [userInfo, systemStatus]);
47
+ if (!userInfo || !systemStatus)
48
+ return null;
49
+ if (systemStatus.messages.some((m) => m.severity === "error")) {
50
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "fixed inset-0 flex flex-col items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-2xl", children: "Please fix the following issues:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-sm text-red-500", children: systemStatus.messages.map((m) => ((0, jsx_runtime_1.jsx)("div", { children: m.message }, m.message))) }), (0, jsx_runtime_1.jsx)("p", { children: "Check the logs for more details." })] }));
51
+ }
52
+ if (!config)
53
+ return null;
54
+ return ((0, jsx_runtime_1.jsx)(DialogContext_1.DialogProvider, { children: (0, jsx_runtime_1.jsx)(EditorClient_1.EditorClient, { configuration: config, className: className, item: page, sessionId: sessionId }) }));
55
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditorWarning = EditorWarning;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const utils_1 = require("primereact/utils");
6
+ function EditorWarning({ title, severity = "warning", children, }) {
7
+ const background = severity === "info"
8
+ ? "bg-blue-100"
9
+ : severity === "error"
10
+ ? "bg-red-100"
11
+ : "bg-yellow-100";
12
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.classNames)(background, "text-sm text-gray-500 border-b border-yellow-300 flex gap-2 items-stretch"), children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-yellow-200 px-4 flex items-center text-gray-900", children: (0, jsx_runtime_1.jsx)("span", { className: "pi pi-exclamation-triangle text-2xl" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "p-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "font-bold", children: title }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs", children: children })] })] }));
13
+ }