@alpaca-editor/core 1.0.3939 → 1.0.3941
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.
- package/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { classNames } from "primereact/utils";
|
|
2
|
-
|
|
3
|
-
export function SimpleTable<T>({
|
|
4
|
-
items,
|
|
5
|
-
columns,
|
|
6
|
-
onRowHover,
|
|
7
|
-
onRowClick,
|
|
8
|
-
rowClassName,
|
|
9
|
-
}: {
|
|
10
|
-
items: T[];
|
|
11
|
-
columns: {
|
|
12
|
-
header: React.ReactNode;
|
|
13
|
-
body: (item: T) => React.ReactNode;
|
|
14
|
-
className?: string;
|
|
15
|
-
}[];
|
|
16
|
-
|
|
17
|
-
onRowClick?: (data: {
|
|
18
|
-
item: T;
|
|
19
|
-
event: React.MouseEvent<HTMLTableRowElement>;
|
|
20
|
-
}) => void;
|
|
21
|
-
onRowHover?: (item: T | undefined) => void;
|
|
22
|
-
rowClassName?: (item: T) => string;
|
|
23
|
-
}) {
|
|
24
|
-
return (
|
|
25
|
-
<table className="text-surface min-w-full table-auto text-left text-xs font-light">
|
|
26
|
-
<thead className="border-b border-neutral-200 font-medium">
|
|
27
|
-
<tr>
|
|
28
|
-
{columns.map((col, index) => (
|
|
29
|
-
<th key={index} className="px-1.5 py-1.5">
|
|
30
|
-
{col.header}
|
|
31
|
-
</th>
|
|
32
|
-
))}
|
|
33
|
-
</tr>
|
|
34
|
-
</thead>
|
|
35
|
-
<tbody>
|
|
36
|
-
{items.map((item, index) => (
|
|
37
|
-
<tr
|
|
38
|
-
className={classNames(
|
|
39
|
-
"border-b border-neutral-200",
|
|
40
|
-
onRowClick ? "cursor-pointer hover:bg-neutral-100" : "",
|
|
41
|
-
rowClassName ? rowClassName(item) : "",
|
|
42
|
-
)}
|
|
43
|
-
onClick={(ev) => {
|
|
44
|
-
if (onRowClick) onRowClick({ item, event: ev });
|
|
45
|
-
}}
|
|
46
|
-
onMouseOver={() => onRowHover?.(item)}
|
|
47
|
-
onMouseLeave={() => onRowHover?.(undefined)}
|
|
48
|
-
key={index}
|
|
49
|
-
>
|
|
50
|
-
{columns.map((col, index) => (
|
|
51
|
-
<td className={classNames("p-2", col.className)} key={index}>
|
|
52
|
-
{col.body(item)}
|
|
53
|
-
</td>
|
|
54
|
-
))}
|
|
55
|
-
</tr>
|
|
56
|
-
))}
|
|
57
|
-
</tbody>
|
|
58
|
-
</table>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { twMerge } from "tailwind-merge";
|
|
2
|
-
|
|
3
|
-
export type Tab = {
|
|
4
|
-
label: string;
|
|
5
|
-
content: React.ReactNode;
|
|
6
|
-
id: string;
|
|
7
|
-
testId?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function SimpleTabs({
|
|
11
|
-
tabs,
|
|
12
|
-
setActiveTab,
|
|
13
|
-
activeTab,
|
|
14
|
-
className,
|
|
15
|
-
}: {
|
|
16
|
-
tabs: Tab[];
|
|
17
|
-
setActiveTab: (index: number) => void;
|
|
18
|
-
activeTab: number;
|
|
19
|
-
className?: string;
|
|
20
|
-
}) {
|
|
21
|
-
if (activeTab > tabs.length - 1) {
|
|
22
|
-
activeTab = 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (activeTab < 0) {
|
|
26
|
-
activeTab = 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (tabs.length === 0) return null;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
<div className={twMerge("flex gap-4 pb-1", className)}>
|
|
34
|
-
{tabs.map((tab, index) => (
|
|
35
|
-
<button
|
|
36
|
-
id={tab.id}
|
|
37
|
-
className={activeTab === index ? "active-tab" : "cursor-pointer"}
|
|
38
|
-
key={tab.id}
|
|
39
|
-
data-testid={tab.testId}
|
|
40
|
-
onClick={() => setActiveTab(index)}
|
|
41
|
-
style={{
|
|
42
|
-
fontWeight: index === activeTab ? "bold" : "normal",
|
|
43
|
-
borderBottom: index === activeTab ? "3px solid black" : "none",
|
|
44
|
-
marginBottom: index === activeTab ? "0" : "3px",
|
|
45
|
-
color: index === activeTab ? "black" : "gray",
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
{tab.label}
|
|
49
|
-
</button>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
{tabs[activeTab]?.content}
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
-
import { flushSync } from "react-dom";
|
|
3
|
-
|
|
4
|
-
export type SplitterPanel = {
|
|
5
|
-
defaultSize: number | "auto";
|
|
6
|
-
name: string;
|
|
7
|
-
content: React.ReactNode;
|
|
8
|
-
collapsible?: boolean;
|
|
9
|
-
hidden?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
interface SplitterProps {
|
|
13
|
-
panels: SplitterPanel[];
|
|
14
|
-
localStorageKey?: string;
|
|
15
|
-
expandLabel?: React.ReactNode;
|
|
16
|
-
growablePanelIndex?: number; // Index of the panel that grows/shrinks
|
|
17
|
-
direction?: "horizontal" | "vertical"; // New prop for direction
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type StoredSizes = { panels: PanelSizes; lastCollapsed: boolean };
|
|
21
|
-
type PanelSizes = { [name: string]: number | "auto" };
|
|
22
|
-
|
|
23
|
-
export const Splitter: React.FC<SplitterProps> = ({
|
|
24
|
-
panels,
|
|
25
|
-
localStorageKey = "splitter-sizes",
|
|
26
|
-
expandLabel = "Expand",
|
|
27
|
-
direction = "horizontal", // Default to horizontal for backward compatibility
|
|
28
|
-
}) => {
|
|
29
|
-
const totalPanels = panels.length;
|
|
30
|
-
|
|
31
|
-
const [panelSizes, setPanelSizes] = useState<PanelSizes | null>(() => {
|
|
32
|
-
// Load sizes from local storage on initial render
|
|
33
|
-
const storedSizes = localStorage.getItem(localStorageKey);
|
|
34
|
-
if (storedSizes) {
|
|
35
|
-
try {
|
|
36
|
-
const parsedSizes = JSON.parse(storedSizes);
|
|
37
|
-
return (parsedSizes as StoredSizes).panels;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return null; // Or fallback to default if parsing fails
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null; // No stored sizes, initial render will handle defaults
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const panelRefs = useRef<Array<HTMLDivElement | null>>([]);
|
|
46
|
-
const splitterRef = useRef<HTMLDivElement | null>(null);
|
|
47
|
-
const lastPanelCollapsible = panels[panels.length - 1]?.collapsible;
|
|
48
|
-
|
|
49
|
-
const [isLastPanelCollapsed, setIsLastPanelCollapsed] = useState(() => {
|
|
50
|
-
const storedSizes = localStorage.getItem(localStorageKey);
|
|
51
|
-
if (storedSizes) {
|
|
52
|
-
const parsedSizes = JSON.parse(storedSizes);
|
|
53
|
-
return (parsedSizes as StoredSizes).lastCollapsed;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const [isResizing, setIsResizing] = useState(false);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!panelSizes && splitterRef.current) {
|
|
62
|
-
const initialSizes: PanelSizes = {};
|
|
63
|
-
|
|
64
|
-
panels.forEach((panel) => {
|
|
65
|
-
initialSizes[panel.name] = panel.defaultSize;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
setPanelSizes(initialSizes);
|
|
69
|
-
}
|
|
70
|
-
}, [panels]);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (panelSizes) {
|
|
74
|
-
const storedSizes: StoredSizes = {
|
|
75
|
-
panels: panelSizes,
|
|
76
|
-
lastCollapsed: isLastPanelCollapsed ?? false,
|
|
77
|
-
};
|
|
78
|
-
localStorage.setItem(localStorageKey, JSON.stringify(storedSizes));
|
|
79
|
-
}
|
|
80
|
-
}, [panelSizes, localStorageKey, isLastPanelCollapsed]);
|
|
81
|
-
|
|
82
|
-
const toggleLastPanelCollapse = () => {
|
|
83
|
-
if (lastPanelCollapsible) {
|
|
84
|
-
document.startViewTransition(() => {
|
|
85
|
-
flushSync(() => {
|
|
86
|
-
setIsLastPanelCollapsed((prev) => !prev);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const isLastResizer = (index: number) => index === panels.length - 2;
|
|
93
|
-
|
|
94
|
-
const getFlexBasis = (index: number): string => {
|
|
95
|
-
if (!panelSizes) return "1fr"; // Or a default like "1fr"
|
|
96
|
-
|
|
97
|
-
const panelName = panels[index]!.name;
|
|
98
|
-
const size =
|
|
99
|
-
index === panels.length - 1 &&
|
|
100
|
-
isLastPanelCollapsed &&
|
|
101
|
-
lastPanelCollapsible
|
|
102
|
-
? 0
|
|
103
|
-
: panelSizes[panelName] || panels[index]!.defaultSize;
|
|
104
|
-
|
|
105
|
-
if (typeof size === "number") {
|
|
106
|
-
return `${size}px`;
|
|
107
|
-
} else if (size === "auto") {
|
|
108
|
-
return "auto";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return "1fr"; //default
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const getExpandButton = () => {
|
|
115
|
-
const isHorizontal = direction === "horizontal";
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<div
|
|
119
|
-
onClick={!isResizing ? toggleLastPanelCollapse : undefined}
|
|
120
|
-
className="flex cursor-pointer items-center justify-center bg-gray-200 p-1 text-gray-500 select-none hover:bg-blue-700 hover:text-white"
|
|
121
|
-
style={{
|
|
122
|
-
writingMode: isHorizontal ? "vertical-rl" : "horizontal-tb",
|
|
123
|
-
userSelect: "none",
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
{expandLabel}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const getSplitter = (index: number) => {
|
|
132
|
-
const isHorizontal = direction === "horizontal";
|
|
133
|
-
|
|
134
|
-
const handleDragStart = (clientX: number, clientY: number) => {
|
|
135
|
-
const isHorizontal = direction === "horizontal";
|
|
136
|
-
const startCoord = isHorizontal ? clientX : clientY;
|
|
137
|
-
const initialSizes = panelSizes ? { ...panelSizes } : {};
|
|
138
|
-
|
|
139
|
-
const panelElement = panelRefs.current[index];
|
|
140
|
-
const nextPanelElement = panelRefs.current[index + 1];
|
|
141
|
-
|
|
142
|
-
if (!panelElement || !nextPanelElement) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const panelSize = isHorizontal
|
|
147
|
-
? panelElement.offsetWidth
|
|
148
|
-
: panelElement.offsetHeight;
|
|
149
|
-
const nextPanelSize = isHorizontal
|
|
150
|
-
? nextPanelElement.offsetWidth
|
|
151
|
-
: nextPanelElement.offsetHeight;
|
|
152
|
-
|
|
153
|
-
setIsResizing(true);
|
|
154
|
-
|
|
155
|
-
let isDragging = true;
|
|
156
|
-
|
|
157
|
-
const handleMove = (moveClientX: number, moveClientY: number) => {
|
|
158
|
-
if (!isDragging) return;
|
|
159
|
-
|
|
160
|
-
const currentCoord = isHorizontal ? moveClientX : moveClientY;
|
|
161
|
-
const delta = currentCoord - startCoord;
|
|
162
|
-
const newPanelSize = panelSize + delta;
|
|
163
|
-
const newNextPanelSize = nextPanelSize - delta;
|
|
164
|
-
|
|
165
|
-
const minPanelSize = 50;
|
|
166
|
-
|
|
167
|
-
// Check if the next panel (which could be the last panel) should be collapsed
|
|
168
|
-
const isNextPanelLast = index + 1 === panels.length - 1;
|
|
169
|
-
const isNextPanelCollapsible = panels[index + 1]?.collapsible;
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
newNextPanelSize < minPanelSize &&
|
|
173
|
-
isNextPanelLast &&
|
|
174
|
-
isNextPanelCollapsible
|
|
175
|
-
) {
|
|
176
|
-
// Auto-collapse the last panel when it reaches minimum size
|
|
177
|
-
setIsLastPanelCollapsed(true);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (newPanelSize < minPanelSize || newNextPanelSize < minPanelSize) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const updatedSizes: PanelSizes = { ...initialSizes };
|
|
186
|
-
updatedSizes[panels[index]!.name] = newPanelSize;
|
|
187
|
-
updatedSizes[panels[index + 1]!.name] = newNextPanelSize;
|
|
188
|
-
setPanelSizes(updatedSizes);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const handleEnd = () => {
|
|
192
|
-
isDragging = false;
|
|
193
|
-
setIsResizing(false);
|
|
194
|
-
|
|
195
|
-
// Remove all event listeners
|
|
196
|
-
window.removeEventListener("mousemove", onMouseMove);
|
|
197
|
-
window.removeEventListener("mouseup", onMouseUp);
|
|
198
|
-
window.removeEventListener("touchmove", onTouchMove);
|
|
199
|
-
window.removeEventListener("touchend", onTouchEnd);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const onMouseMove = (moveEvent: MouseEvent) => {
|
|
203
|
-
handleMove(moveEvent.clientX, moveEvent.clientY);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const onMouseUp = () => {
|
|
207
|
-
handleEnd();
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const onTouchMove = (moveEvent: TouchEvent) => {
|
|
211
|
-
if (moveEvent.touches.length === 1) {
|
|
212
|
-
const touch = moveEvent.touches[0];
|
|
213
|
-
if (touch) {
|
|
214
|
-
handleMove(touch.clientX, touch.clientY);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const onTouchEnd = () => {
|
|
220
|
-
handleEnd();
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
// Add both mouse and touch event listeners
|
|
224
|
-
window.addEventListener("mousemove", onMouseMove);
|
|
225
|
-
window.addEventListener("mouseup", onMouseUp);
|
|
226
|
-
window.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
227
|
-
window.addEventListener("touchend", onTouchEnd);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
if (lastPanelCollapsible && isLastPanelCollapsed && isLastResizer(index)) {
|
|
231
|
-
return getExpandButton();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return (
|
|
235
|
-
<div
|
|
236
|
-
className={`relative flex ${
|
|
237
|
-
isHorizontal
|
|
238
|
-
? "h-full w-[12px] cursor-ew-resize md:w-[4px]"
|
|
239
|
-
: "h-[12px] w-full cursor-ns-resize md:h-[12px]"
|
|
240
|
-
} shrink-0 items-center justify-center bg-gray-300 select-none hover:bg-gray-400`}
|
|
241
|
-
style={{
|
|
242
|
-
touchAction: "none",
|
|
243
|
-
minHeight: isHorizontal ? undefined : "12px",
|
|
244
|
-
minWidth: isHorizontal ? "4px" : undefined,
|
|
245
|
-
boxSizing: "border-box",
|
|
246
|
-
userSelect: "none",
|
|
247
|
-
zIndex: 9999, // Ensure we're above any nested splitters
|
|
248
|
-
}}
|
|
249
|
-
onDoubleClick={
|
|
250
|
-
isLastResizer(index) ? toggleLastPanelCollapse : undefined
|
|
251
|
-
}
|
|
252
|
-
onMouseDown={(event) => {
|
|
253
|
-
handleDragStart(event.clientX, event.clientY);
|
|
254
|
-
}}
|
|
255
|
-
onTouchStart={(event) => {
|
|
256
|
-
if (event.touches.length === 1) {
|
|
257
|
-
const touch = event.touches[0];
|
|
258
|
-
if (touch) {
|
|
259
|
-
handleDragStart(touch.clientX, touch.clientY);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}}
|
|
263
|
-
>
|
|
264
|
-
{/* Visual indicator line for mobile splitters */}
|
|
265
|
-
<div
|
|
266
|
-
className={`${
|
|
267
|
-
isHorizontal
|
|
268
|
-
? "h-8 w-[2px] bg-gray-500 md:hidden"
|
|
269
|
-
: "h-[2px] w-8 bg-gray-500 md:hidden"
|
|
270
|
-
}`}
|
|
271
|
-
/>
|
|
272
|
-
</div>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<div
|
|
278
|
-
className={`flex ${direction === "horizontal" ? "flex-row" : "flex-col"} h-full w-full overflow-hidden`}
|
|
279
|
-
ref={splitterRef}
|
|
280
|
-
>
|
|
281
|
-
{panels.map((panel, index) => (
|
|
282
|
-
<React.Fragment key={panel.name}>
|
|
283
|
-
<div
|
|
284
|
-
ref={(el) => {
|
|
285
|
-
panelRefs.current[index] = el;
|
|
286
|
-
}}
|
|
287
|
-
className="relative"
|
|
288
|
-
style={{
|
|
289
|
-
flex: `${panel.defaultSize === "auto" ? 1 : 0} 1 ${getFlexBasis(
|
|
290
|
-
index,
|
|
291
|
-
)}`,
|
|
292
|
-
|
|
293
|
-
minWidth: direction === "horizontal" ? 0 : undefined,
|
|
294
|
-
minHeight: direction === "vertical" ? 0 : undefined,
|
|
295
|
-
display:
|
|
296
|
-
(panel.collapsible &&
|
|
297
|
-
isLastPanelCollapsed &&
|
|
298
|
-
index === totalPanels - 1) ||
|
|
299
|
-
panel.hidden
|
|
300
|
-
? "none"
|
|
301
|
-
: "block",
|
|
302
|
-
}}
|
|
303
|
-
>
|
|
304
|
-
{panel.content}
|
|
305
|
-
</div>
|
|
306
|
-
{index < panels.length - 1 &&
|
|
307
|
-
!panels[index]?.hidden &&
|
|
308
|
-
!panels[index + 1]?.hidden &&
|
|
309
|
-
getSplitter(index)}
|
|
310
|
-
</React.Fragment>
|
|
311
|
-
))}
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import "allotment/dist/style.css";
|
|
2
|
-
import { Allotment, AllotmentHandle } from "allotment";
|
|
3
|
-
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { classNames } from "primereact/utils";
|
|
7
|
-
import { Panel } from "../../config/types";
|
|
8
|
-
|
|
9
|
-
export function StackedPanels({ panels }: { panels: Panel[] }) {
|
|
10
|
-
const splitter = useRef<AllotmentHandle>(null);
|
|
11
|
-
|
|
12
|
-
const [sizes, setSizes] = useState<number[]>([]);
|
|
13
|
-
const [preferredSizes, setPreferredSizes] = useState<number[] | undefined>(
|
|
14
|
-
undefined
|
|
15
|
-
);
|
|
16
|
-
const [panelsExpanded, setPanelsExpanded] = useState<boolean[]>([]);
|
|
17
|
-
const [sizeToSet, setSizeToSet] = useState<number[] | undefined>();
|
|
18
|
-
|
|
19
|
-
const panelHeaderSize = 30;
|
|
20
|
-
const toggle = (panelIndex: number) => {
|
|
21
|
-
const newSize = panelsExpanded[panelIndex]
|
|
22
|
-
? panelHeaderSize
|
|
23
|
-
: (preferredSizes || sizes)[panelIndex];
|
|
24
|
-
|
|
25
|
-
resizePanel(panelIndex, newSize);
|
|
26
|
-
|
|
27
|
-
setPanelsExpanded((x) => {
|
|
28
|
-
const newState = [...x];
|
|
29
|
-
newState[panelIndex] = !newState[panelIndex];
|
|
30
|
-
return newState;
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setPanelsExpanded(panels.map(() => true));
|
|
36
|
-
setPreferredSizes(() => panels.map((x) => x.initialSize));
|
|
37
|
-
}, [panels]);
|
|
38
|
-
|
|
39
|
-
const resizePanel = (panelIndex: number, newSize: number) => {
|
|
40
|
-
const totalSize = sizes.reduce((a, b) => a + b, 0);
|
|
41
|
-
const totalOther = totalSize - sizes[panelIndex];
|
|
42
|
-
const tmpSizes = [...sizes];
|
|
43
|
-
tmpSizes[panelIndex] = newSize;
|
|
44
|
-
const percentages = tmpSizes.map((x) => x / totalOther);
|
|
45
|
-
percentages[panelIndex] = 0;
|
|
46
|
-
const remaining = totalSize - newSize;
|
|
47
|
-
const newSizes = percentages.map((x) => x * remaining);
|
|
48
|
-
newSizes[panelIndex] = newSize;
|
|
49
|
-
setSizes(newSizes);
|
|
50
|
-
|
|
51
|
-
setSizeToSet(newSizes);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (sizeToSet) splitter.current?.resize(sizeToSet);
|
|
56
|
-
}, [sizeToSet]);
|
|
57
|
-
|
|
58
|
-
const getHeader = (panel: any, index: number) => {
|
|
59
|
-
if (panel.header) return panel.header({ panel, index });
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
className={classNames(
|
|
64
|
-
"p-1.5 bg-gray-50 uppercase text-gray-500 text-xs flex justify items-center cursor-pointer",
|
|
65
|
-
panelsExpanded[index] ? "border-b" : ""
|
|
66
|
-
)}
|
|
67
|
-
onClick={() => toggle(index)}
|
|
68
|
-
>
|
|
69
|
-
{panel.icon &&
|
|
70
|
-
(typeof panel.icon === "string" ? (
|
|
71
|
-
<i className={classNames(panel.icon, "pi mr-1.5")}></i>
|
|
72
|
-
) : (
|
|
73
|
-
<div className="w-4 h-4 mr-1.5">{panel.icon}</div>
|
|
74
|
-
))}
|
|
75
|
-
<div className="mr-auto">{panel.title}</div>
|
|
76
|
-
<i
|
|
77
|
-
className={classNames(
|
|
78
|
-
panelsExpanded[index] ? "pi-chevron-up" : "pi-chevron-down",
|
|
79
|
-
"pi text-sm"
|
|
80
|
-
)}
|
|
81
|
-
></i>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const initalSizes = panels.map((x) => x.initialSize);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<Allotment
|
|
90
|
-
vertical={true}
|
|
91
|
-
snap={true}
|
|
92
|
-
ref={splitter}
|
|
93
|
-
defaultSizes={initalSizes}
|
|
94
|
-
onChange={(s) => {
|
|
95
|
-
if (sizes.join(",") != s.join(",")) setSizes(s);
|
|
96
|
-
|
|
97
|
-
const newPreferred = [...(preferredSizes || s)];
|
|
98
|
-
s.forEach((x, i) => {
|
|
99
|
-
if (x > panelHeaderSize) newPreferred[i] = x;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
setPreferredSizes(newPreferred);
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
{panels.map((panel, index) => (
|
|
106
|
-
<Allotment.Pane
|
|
107
|
-
key={index}
|
|
108
|
-
// preferredSize={(preferredSizes || initalSizes)[index] + "%"}
|
|
109
|
-
maxSize={
|
|
110
|
-
panelsExpanded.length <= index || panelsExpanded[index]
|
|
111
|
-
? 10000
|
|
112
|
-
: panelHeaderSize
|
|
113
|
-
}
|
|
114
|
-
>
|
|
115
|
-
<div className="flex flex-col h-full">
|
|
116
|
-
{getHeader(panel, index)}
|
|
117
|
-
{panelsExpanded[index] && (
|
|
118
|
-
<div className="overflow-hidden relative flex-1">
|
|
119
|
-
<div
|
|
120
|
-
className={classNames(
|
|
121
|
-
"inset-0 absolute",
|
|
122
|
-
panel.noOverflow ? "" : "overflow-y-auto"
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
{panel.content}
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
</Allotment.Pane>
|
|
131
|
-
))}
|
|
132
|
-
</Allotment>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { InsertOption } from "../../types";
|
|
2
|
-
import { EditContextType } from "../client/editContext";
|
|
3
|
-
import { getComponentById } from "../componentTreeHelper";
|
|
4
|
-
import { Page, Placeholder } from "../pageModel";
|
|
5
|
-
|
|
6
|
-
export function getInsertOptionsForCurrentSelection(
|
|
7
|
-
editContext: EditContextType
|
|
8
|
-
): InsertOption[] {
|
|
9
|
-
const page = editContext.page;
|
|
10
|
-
|
|
11
|
-
if (!page) return [];
|
|
12
|
-
|
|
13
|
-
const insertingPlaceholderKeys = [editContext.selectedForInsertion]
|
|
14
|
-
.map((x) => getComponentById(x, editContext.page!))
|
|
15
|
-
.filter((x) => x)
|
|
16
|
-
.reduce(
|
|
17
|
-
(a, x) => a.concat(x!.placeholders?.map((y: Placeholder) => y.key) || []),
|
|
18
|
-
[] as string[]
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const selectedPlaceholderKeys = [
|
|
22
|
-
//...selection.filter((x) => x.indexOf("_") > 0),
|
|
23
|
-
...insertingPlaceholderKeys,
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
function collectInsertOptions(
|
|
27
|
-
page: Page,
|
|
28
|
-
placeholderKeys: string[]
|
|
29
|
-
): InsertOption[] {
|
|
30
|
-
const insertOptionsMap: Map<string, InsertOption> = new Map();
|
|
31
|
-
|
|
32
|
-
function traverse(placeholders: Placeholder[]) {
|
|
33
|
-
for (const placeholder of placeholders) {
|
|
34
|
-
if (
|
|
35
|
-
placeholder &&
|
|
36
|
-
(placeholderKeys.length === 0 ||
|
|
37
|
-
placeholderKeys.includes(placeholder.key))
|
|
38
|
-
) {
|
|
39
|
-
for (const option of placeholder.insertOptions) {
|
|
40
|
-
insertOptionsMap.set(option.typeId, option);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
for (const component of placeholder.components) {
|
|
44
|
-
if (component.placeholders) traverse(component.placeholders);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
traverse(page.rootComponent.placeholders);
|
|
50
|
-
|
|
51
|
-
// Convert the map back into an array of objects
|
|
52
|
-
const insertOptionsArray: InsertOption[] = Array.from(
|
|
53
|
-
insertOptionsMap.values()
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
insertOptionsArray.sort((a, b) => a.name.localeCompare(b.name));
|
|
57
|
-
|
|
58
|
-
return insertOptionsArray;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const currentInsertOptions = page
|
|
62
|
-
? collectInsertOptions(page, selectedPlaceholderKeys)
|
|
63
|
-
: [];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// console.log(currentInsertOptions, selectedPlaceholderKeys, page);
|
|
67
|
-
|
|
68
|
-
return currentInsertOptions;
|
|
69
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getCreateAndSwitchToNewVersionCommand } from "../commands/createVersionCommand";
|
|
2
|
-
import { Language } from "../pageModel";
|
|
3
|
-
import { EditContextType } from "../client/editContext";
|
|
4
|
-
|
|
5
|
-
export const confirmCreateVersion = (
|
|
6
|
-
editContext: EditContextType,
|
|
7
|
-
language: Language
|
|
8
|
-
) => {
|
|
9
|
-
editContext.confirm({
|
|
10
|
-
message:
|
|
11
|
-
"This page has no version in language " +
|
|
12
|
-
language.name +
|
|
13
|
-
" (" +
|
|
14
|
-
language.languageCode +
|
|
15
|
-
"). Do you want to create a new version?",
|
|
16
|
-
header: "Create Language Version?",
|
|
17
|
-
icon: "pi pi-exclamation-triangle",
|
|
18
|
-
acceptLabel: "Yes, create version",
|
|
19
|
-
rejectLabel: "No",
|
|
20
|
-
accept: async () => {
|
|
21
|
-
await editContext?.executeCommand({
|
|
22
|
-
command: getCreateAndSwitchToNewVersionCommand({
|
|
23
|
-
language: language.languageCode,
|
|
24
|
-
}),
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
);
|
|
29
|
-
};
|