@alpaca-editor/core 1.0.3938 → 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/ContentTree.js +12 -8
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/ContextMenu.d.ts +1 -1
- package/dist/editor/ContextMenu.js +17 -3
- package/dist/editor/ContextMenu.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +18 -0
- package/dist/editor/FieldActionsOverlay.js +139 -0
- package/dist/editor/FieldActionsOverlay.js.map +1 -0
- package/dist/editor/FieldHistory.d.ts +2 -1
- package/dist/editor/FieldHistory.js +11 -8
- package/dist/editor/FieldHistory.js.map +1 -1
- package/dist/editor/FieldListField.js +14 -17
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +43 -3
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +19 -10
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AiTerminal.js +27 -41
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +48 -18
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +1 -1
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/itemsRepository.js +126 -90
- package/dist/editor/client/itemsRepository.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 +3 -4
- package/dist/editor/menubar/BrowseHistory.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +62 -10
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.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/page-viewer/PageViewerFrame.js +98 -2
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/pageModel.d.ts +14 -0
- package/dist/editor/reviews/Comment.js +3 -2
- 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/services/editService.d.ts +1 -1
- package/dist/editor/services/editService.js +2 -1
- package/dist/editor/services/editService.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/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/ui/ItemList.d.ts +16 -0
- package/dist/editor/ui/ItemList.js +19 -0
- package/dist/editor/ui/ItemList.js.map +1 -0
- package/dist/editor/ui/ItemSearch.js +2 -12
- package/dist/editor/ui/ItemSearch.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 +64 -13
- 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 -727
- package/src/editor/ContextMenu.tsx +0 -212
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -74
- 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 -212
- 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 -93
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -514
- 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 -2197
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -412
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -538
- 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 -37
- 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 -141
- 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 -879
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -208
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -308
- 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 -486
- 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 -708
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -190
- 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,227 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { WizardData, WizardPageModel } from "../PageWizard";
|
|
3
|
-
|
|
4
|
-
import { useEditContext } from "../../editor/client/editContext";
|
|
5
|
-
import { executePrompt } from "../../editor/services/aiService";
|
|
6
|
-
import { createWizardAiContext } from "../service";
|
|
7
|
-
import { Components } from "./Components";
|
|
8
|
-
import { Splitter, SplitterPanel } from "../../editor/ui/Splitter";
|
|
9
|
-
import { convertPageSchemaToWizardComponents } from "./schema";
|
|
10
|
-
import { StepComponentProps } from "../../config/types";
|
|
11
|
-
import { ActionButton } from "../../components/ActionButton";
|
|
12
|
-
import { ComponentTypeSelector } from "./ComponentTypesSelector";
|
|
13
|
-
export function LayoutStep({
|
|
14
|
-
wizard,
|
|
15
|
-
step,
|
|
16
|
-
data,
|
|
17
|
-
setData,
|
|
18
|
-
setStepCompleted,
|
|
19
|
-
internalState,
|
|
20
|
-
setInternalState,
|
|
21
|
-
}: StepComponentProps) {
|
|
22
|
-
const editContext = useEditContext();
|
|
23
|
-
const abortController = new AbortController();
|
|
24
|
-
|
|
25
|
-
const localAbortController = abortController || new AbortController();
|
|
26
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
27
|
-
|
|
28
|
-
const [message, setMessage] = useState<string>();
|
|
29
|
-
|
|
30
|
-
const [selectedComponentTypes, setSelectedComponentTypes] = useState<
|
|
31
|
-
string[]
|
|
32
|
-
>([]);
|
|
33
|
-
|
|
34
|
-
const [customInstructions, setCustomInstructions] = useState<string>();
|
|
35
|
-
|
|
36
|
-
if (!editContext) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (data.pageModel?.components?.length) {
|
|
42
|
-
setStepCompleted(!isLoading);
|
|
43
|
-
}
|
|
44
|
-
}, [data.pageModel, isLoading]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
setCustomInstructions(step.fields.instructions);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
const createLayout = async () => {
|
|
51
|
-
try {
|
|
52
|
-
setIsLoading(true);
|
|
53
|
-
|
|
54
|
-
// Parse schema if it's a string
|
|
55
|
-
const schema =
|
|
56
|
-
typeof wizard.schema === "string"
|
|
57
|
-
? JSON.parse(wizard.schema)
|
|
58
|
-
: wizard.schema;
|
|
59
|
-
|
|
60
|
-
// Filter the schema based on selected component types and placeholders
|
|
61
|
-
const filteredSchema = convertPageSchemaToWizardComponents(
|
|
62
|
-
schema,
|
|
63
|
-
selectedComponentTypes,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const result = await executePrompt(
|
|
67
|
-
[
|
|
68
|
-
{
|
|
69
|
-
content: `${customInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; components: Component[]; message: string; };
|
|
70
|
-
Component = { name: string, type: string; fields: Field[]; placeholder?: string; children?: Component[]; };
|
|
71
|
-
Field = { name: string; value: string; type: string; };
|
|
72
|
-
Generate a descriptive name for each component including the topic.
|
|
73
|
-
Only use component types that are in the page schema. Also suggest a page name following default sitecore item naming conventions (no underscores, no white space, no umlaute, no special characters, hyphens are allowed) and the page meta description.
|
|
74
|
-
Component types: ${JSON.stringify(
|
|
75
|
-
filteredSchema,
|
|
76
|
-
)} Root level component types ${filteredSchema
|
|
77
|
-
.filter((c) => c.allowedOnRoot)
|
|
78
|
-
.map((c) => c.type)
|
|
79
|
-
.join(", ")}
|
|
80
|
-
Tell the user your reasoning in the message field.
|
|
81
|
-
Fill image ids into picture / image fields.
|
|
82
|
-
Input data: ${JSON.stringify(data)}`,
|
|
83
|
-
|
|
84
|
-
name: "system",
|
|
85
|
-
role: "system",
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
editContext,
|
|
89
|
-
createWizardAiContext,
|
|
90
|
-
{},
|
|
91
|
-
{ signal: localAbortController.signal },
|
|
92
|
-
"gpt-4.1",
|
|
93
|
-
(response) => {
|
|
94
|
-
try {
|
|
95
|
-
const newLayout = JSON.parse(response.content) as WizardPageModel;
|
|
96
|
-
|
|
97
|
-
if (newLayout) {
|
|
98
|
-
setData((prev: WizardData) => ({
|
|
99
|
-
...prev,
|
|
100
|
-
pageModel: newLayout,
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
setMessage(newLayout.message);
|
|
105
|
-
} catch (parseError: unknown) {}
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const pageModel = JSON.parse(result.content);
|
|
110
|
-
|
|
111
|
-
setData({
|
|
112
|
-
...data,
|
|
113
|
-
pageModel: JSON.parse(result.content),
|
|
114
|
-
customInstructions,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
setMessage(pageModel.message);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.error(error);
|
|
120
|
-
} finally {
|
|
121
|
-
setIsLoading(false);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Toggle placeholder selection
|
|
126
|
-
|
|
127
|
-
// Regenerate layout with current selected component types and placeholders
|
|
128
|
-
const regenerateLayout = () => {
|
|
129
|
-
createLayout();
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (!selectedComponentTypes.length) return;
|
|
134
|
-
|
|
135
|
-
// Only set custom instructions if they're not already set or if step.instructions has changed
|
|
136
|
-
if (customInstructions !== step.fields.instructions) {
|
|
137
|
-
setCustomInstructions(step.fields.instructions);
|
|
138
|
-
}
|
|
139
|
-
}, [step.fields.instructions, selectedComponentTypes]);
|
|
140
|
-
|
|
141
|
-
// Custom instructions panel
|
|
142
|
-
const customInstructionsPanel = () => {
|
|
143
|
-
return (
|
|
144
|
-
<div className="mb-4">
|
|
145
|
-
<h3 className="text-sm font-bold">Instructions</h3>
|
|
146
|
-
<div className="mb-3 text-xs text-gray-500">
|
|
147
|
-
Provide guidance for the AI when generating your layout
|
|
148
|
-
</div>
|
|
149
|
-
<textarea
|
|
150
|
-
value={customInstructions}
|
|
151
|
-
onChange={(e) => setCustomInstructions(e.target.value)}
|
|
152
|
-
placeholder="Example: Make it modern and minimalist. Focus on images. Include a hero section at the top."
|
|
153
|
-
className="h-48 w-full rounded border border-gray-300 px-3 py-2 text-sm focus:ring-1 focus:ring-blue-500 focus:outline-none"
|
|
154
|
-
disabled={isLoading}
|
|
155
|
-
/>
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const settingsPanel: SplitterPanel = {
|
|
161
|
-
name: "Settings",
|
|
162
|
-
collapsible: false,
|
|
163
|
-
defaultSize: 450,
|
|
164
|
-
content: (
|
|
165
|
-
<div className="absolute inset-0 flex h-full flex-col overflow-auto pr-4">
|
|
166
|
-
{customInstructionsPanel()}
|
|
167
|
-
<ComponentTypeSelector
|
|
168
|
-
selectedComponentTypes={selectedComponentTypes}
|
|
169
|
-
setSelectedComponentTypes={setSelectedComponentTypes}
|
|
170
|
-
schema={wizard.schema}
|
|
171
|
-
data={data}
|
|
172
|
-
setData={setData}
|
|
173
|
-
step={step}
|
|
174
|
-
/>
|
|
175
|
-
<div className="flex gap-2">
|
|
176
|
-
<ActionButton
|
|
177
|
-
onClick={regenerateLayout}
|
|
178
|
-
disabled={isLoading || selectedComponentTypes.length === 0}
|
|
179
|
-
isLoading={isLoading}
|
|
180
|
-
loadingText="Working"
|
|
181
|
-
className="flex-1"
|
|
182
|
-
>
|
|
183
|
-
{data.pageModel ? "Regenerate Layout" : "Generate Layout"}
|
|
184
|
-
</ActionButton>
|
|
185
|
-
{/* Abort button - only visible when loading */}
|
|
186
|
-
{isLoading && (
|
|
187
|
-
<button
|
|
188
|
-
onClick={() => {
|
|
189
|
-
localAbortController.abort();
|
|
190
|
-
setIsLoading(false);
|
|
191
|
-
}}
|
|
192
|
-
className="flex items-center gap-1 rounded bg-red-500 px-2 py-1 text-xs text-white hover:bg-red-600"
|
|
193
|
-
>
|
|
194
|
-
<span className="pi pi-times"></span>
|
|
195
|
-
Abort
|
|
196
|
-
</button>
|
|
197
|
-
)}
|
|
198
|
-
</div>
|
|
199
|
-
<div className="p-2 text-xs text-gray-500">{message}</div>
|
|
200
|
-
</div>
|
|
201
|
-
),
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const layoutPanel: SplitterPanel = {
|
|
205
|
-
name: "Layout",
|
|
206
|
-
defaultSize: "auto",
|
|
207
|
-
collapsible: false,
|
|
208
|
-
content: (
|
|
209
|
-
<div className="absolute inset-2 flex flex-col items-center justify-center text-gray-600">
|
|
210
|
-
<Components
|
|
211
|
-
pageModel={data.pageModel}
|
|
212
|
-
onComponentRemoved={() => setData({ ...data })}
|
|
213
|
-
onFieldEdited={() => setData({ ...data })}
|
|
214
|
-
thumbnails={internalState.thumbnails}
|
|
215
|
-
setInternalState={setInternalState}
|
|
216
|
-
/>
|
|
217
|
-
</div>
|
|
218
|
-
),
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
<Splitter
|
|
223
|
-
panels={[settingsPanel, layoutPanel]}
|
|
224
|
-
localStorageKey="editor.page-wizard.layout"
|
|
225
|
-
/>
|
|
226
|
-
);
|
|
227
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { FullItem } from "../../editor/pageModel";
|
|
3
|
-
import { WizardPageModel } from "../PageWizard";
|
|
4
|
-
import { executePrompt } from "../../editor/services/aiService";
|
|
5
|
-
import { createWizardAiContext } from "../service";
|
|
6
|
-
import { useEditContext } from "../../editor/client/editContext";
|
|
7
|
-
import { InputTextarea } from "primereact/inputtextarea";
|
|
8
|
-
import { WizardBox } from "../WizardBox";
|
|
9
|
-
import { FileText } from "lucide-react";
|
|
10
|
-
import { StepComponentProps } from "../../config/types";
|
|
11
|
-
import Generate from "./Generate";
|
|
12
|
-
|
|
13
|
-
export function MetaDataStep({
|
|
14
|
-
parentItem,
|
|
15
|
-
pageModel,
|
|
16
|
-
setPageModel,
|
|
17
|
-
step,
|
|
18
|
-
data,
|
|
19
|
-
setStepCompleted,
|
|
20
|
-
}: StepComponentProps) {
|
|
21
|
-
const [isGenerating, setIsGenerating] = useState(false);
|
|
22
|
-
const [fullParentItem, setFullParentItem] = useState<FullItem>();
|
|
23
|
-
const editContext = useEditContext();
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (!editContext) return;
|
|
27
|
-
|
|
28
|
-
if (editContext.mode !== "edit") {
|
|
29
|
-
editContext.setMode("edit");
|
|
30
|
-
}
|
|
31
|
-
}, [editContext]);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const loadParentItem = async () => {
|
|
35
|
-
if (!parentItem) return;
|
|
36
|
-
const item = await editContext?.itemsRepository.getItem(parentItem);
|
|
37
|
-
setFullParentItem(item);
|
|
38
|
-
};
|
|
39
|
-
loadParentItem();
|
|
40
|
-
}, [parentItem]);
|
|
41
|
-
|
|
42
|
-
// Mark step as completed immediately since this is now just informational
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setStepCompleted(true);
|
|
45
|
-
}, [setStepCompleted]);
|
|
46
|
-
|
|
47
|
-
// Auto-generate meta description and keywords if not set
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (!editContext) return;
|
|
50
|
-
|
|
51
|
-
const generateMetaFields = async () => {
|
|
52
|
-
const metaInstructions =
|
|
53
|
-
step.fields["Instructions for generating item name and meta fields"];
|
|
54
|
-
|
|
55
|
-
setIsGenerating(true);
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const abortController = new AbortController();
|
|
59
|
-
|
|
60
|
-
const result = await executePrompt(
|
|
61
|
-
[
|
|
62
|
-
{
|
|
63
|
-
content: `${metaInstructions?.trim()} Reply with a json object of type PageModel = { metaDescription: string; metaKeywords: string; };
|
|
64
|
-
Generate SEO-optimized meta description and keywords.
|
|
65
|
-
The language of the page is ${parentItem?.language || "en"}.
|
|
66
|
-
Input data: ${JSON.stringify(data)}`,
|
|
67
|
-
name: "system",
|
|
68
|
-
role: "system",
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
editContext,
|
|
72
|
-
createWizardAiContext,
|
|
73
|
-
{},
|
|
74
|
-
{ signal: abortController.signal },
|
|
75
|
-
"gpt-4.1",
|
|
76
|
-
(response) => {
|
|
77
|
-
try {
|
|
78
|
-
const newLayout = JSON.parse(response.content) as WizardPageModel;
|
|
79
|
-
|
|
80
|
-
setPageModel({
|
|
81
|
-
...pageModel,
|
|
82
|
-
metaDescription: newLayout.metaDescription,
|
|
83
|
-
metaKeywords: newLayout.metaKeywords,
|
|
84
|
-
});
|
|
85
|
-
} catch (parseError: unknown) {}
|
|
86
|
-
},
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const pageModelResult = JSON.parse(result.content) as WizardPageModel;
|
|
90
|
-
setPageModel({
|
|
91
|
-
...pageModel,
|
|
92
|
-
metaDescription: pageModelResult.metaDescription,
|
|
93
|
-
metaKeywords: pageModelResult.metaKeywords,
|
|
94
|
-
});
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.error("Error generating meta fields", error);
|
|
97
|
-
} finally {
|
|
98
|
-
setIsGenerating(false);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
if (!pageModel.metaDescription && !pageModel.metaKeywords) {
|
|
103
|
-
generateMetaFields();
|
|
104
|
-
}
|
|
105
|
-
}, []);
|
|
106
|
-
|
|
107
|
-
const handleInputChange = (field: keyof typeof pageModel, value: string) => {
|
|
108
|
-
const updatedPageModel = {
|
|
109
|
-
...pageModel,
|
|
110
|
-
[field]: value,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
setPageModel(updatedPageModel);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<div className="flex h-full flex-col md:flex-row">
|
|
118
|
-
<WizardBox
|
|
119
|
-
title="SEO Settings"
|
|
120
|
-
icon={<FileText />}
|
|
121
|
-
description="Configure meta information for SEO optimization"
|
|
122
|
-
className="flex-1"
|
|
123
|
-
>
|
|
124
|
-
<div className="flex h-full flex-col items-stretch">
|
|
125
|
-
<div className="relative flex-1">
|
|
126
|
-
{isGenerating ? (
|
|
127
|
-
<div className="flex h-full items-center justify-center">
|
|
128
|
-
<Generate title="Generating SEO fields..." />
|
|
129
|
-
</div>
|
|
130
|
-
) : (
|
|
131
|
-
<>
|
|
132
|
-
<div className="mb-4">
|
|
133
|
-
<label
|
|
134
|
-
htmlFor="metaDescription"
|
|
135
|
-
className="mb-1 block text-sm font-medium"
|
|
136
|
-
>
|
|
137
|
-
Meta Description
|
|
138
|
-
</label>
|
|
139
|
-
<InputTextarea
|
|
140
|
-
id="metaDescription"
|
|
141
|
-
className="min-h-[100px] w-full rounded border p-2 text-sm"
|
|
142
|
-
value={pageModel.metaDescription}
|
|
143
|
-
onChange={(e) =>
|
|
144
|
-
handleInputChange("metaDescription", e.target.value)
|
|
145
|
-
}
|
|
146
|
-
placeholder="Enter meta description"
|
|
147
|
-
/>
|
|
148
|
-
</div>
|
|
149
|
-
<div className="mb-4">
|
|
150
|
-
<label
|
|
151
|
-
htmlFor="metaKeywords"
|
|
152
|
-
className="mb-1 block text-sm font-medium"
|
|
153
|
-
>
|
|
154
|
-
Meta Keywords
|
|
155
|
-
</label>
|
|
156
|
-
<InputTextarea
|
|
157
|
-
id="metaKeywords"
|
|
158
|
-
className="min-h-[100px] w-full rounded border p-2 text-sm"
|
|
159
|
-
value={pageModel.metaKeywords}
|
|
160
|
-
onChange={(e) =>
|
|
161
|
-
handleInputChange("metaKeywords", e.target.value)
|
|
162
|
-
}
|
|
163
|
-
placeholder="Enter meta keywords"
|
|
164
|
-
/>
|
|
165
|
-
</div>
|
|
166
|
-
</>
|
|
167
|
-
)}
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
</WizardBox>
|
|
171
|
-
</div>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { WizardData } from "../PageWizard";
|
|
3
|
-
import { useEditContext } from "../../editor/client/editContext";
|
|
4
|
-
import { executePrompt } from "../../editor/services/aiService";
|
|
5
|
-
import { createWizardAiContext } from "../service";
|
|
6
|
-
import { classNames } from "primereact/utils";
|
|
7
|
-
import { InputTextarea } from "primereact/inputtextarea";
|
|
8
|
-
import { StepComponentProps } from "../../config/types";
|
|
9
|
-
import { ActionButton } from "../../components/ActionButton";
|
|
10
|
-
import Generate from "./Generate";
|
|
11
|
-
import { WizardBox } from "../WizardBox";
|
|
12
|
-
import { WizardBoxConnector } from "../WizardBoxConnector";
|
|
13
|
-
import { Settings, CheckSquare } from "lucide-react";
|
|
14
|
-
|
|
15
|
-
type Option = {
|
|
16
|
-
title: string;
|
|
17
|
-
description: string;
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type Response = {
|
|
22
|
-
options: Option[];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export function SelectStep({
|
|
26
|
-
step,
|
|
27
|
-
data,
|
|
28
|
-
setData,
|
|
29
|
-
setStepCompleted,
|
|
30
|
-
internalState,
|
|
31
|
-
setInternalState,
|
|
32
|
-
}: StepComponentProps) {
|
|
33
|
-
const editContext = useEditContext();
|
|
34
|
-
const [options, setOptions] = useState<Option[]>([]);
|
|
35
|
-
const [loading, setLoading] = useState(false);
|
|
36
|
-
const [error, setError] = useState<string | null>(null);
|
|
37
|
-
const [selectedOptions, setSelectedOptions] = useState<string[]>([]);
|
|
38
|
-
const [instructions, setInstructions] = useState(step.fields.instructions);
|
|
39
|
-
|
|
40
|
-
// Get the property name from the step or use "choice" as default
|
|
41
|
-
const propertyName = step.fields.propertyName || "selectedOptions";
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (data[propertyName]?.length) {
|
|
45
|
-
setStepCompleted(true);
|
|
46
|
-
}
|
|
47
|
-
}, [data]);
|
|
48
|
-
|
|
49
|
-
// Initialize the property in data
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!data[propertyName]) {
|
|
52
|
-
setData((prevData: WizardData) => ({
|
|
53
|
-
...prevData,
|
|
54
|
-
[propertyName]: [],
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
}, [propertyName, setData]);
|
|
58
|
-
|
|
59
|
-
const generateOptions = async () => {
|
|
60
|
-
if (!editContext) return;
|
|
61
|
-
|
|
62
|
-
setLoading(true);
|
|
63
|
-
setError(null);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
// Create a prompt based on step instructions and data
|
|
67
|
-
const prompt = `${step.fields.systemInstructions}\n${instructions}\n\nCurrent data: ${JSON.stringify(
|
|
68
|
-
data,
|
|
69
|
-
null,
|
|
70
|
-
2,
|
|
71
|
-
)}`;
|
|
72
|
-
|
|
73
|
-
// Call the executePrompt function with the prompt
|
|
74
|
-
const result = await executePrompt(
|
|
75
|
-
[
|
|
76
|
-
{
|
|
77
|
-
content: `You are a helpful assistant that generates options for a wizard select step.
|
|
78
|
-
Generate a JSON array of options based on the instructions and current data.
|
|
79
|
-
ONLY respond with a valid JSON array without any explanation or additional text.
|
|
80
|
-
JSON format: {options: {title: string, description: string}[] }`,
|
|
81
|
-
name: "system",
|
|
82
|
-
role: "system",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
content: prompt,
|
|
86
|
-
name: "user",
|
|
87
|
-
role: "user",
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
editContext,
|
|
91
|
-
createWizardAiContext,
|
|
92
|
-
{ allowedFunctions: [] },
|
|
93
|
-
undefined,
|
|
94
|
-
step.fields.aiModel || "gpt-4.1",
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
// Parse the result and set options
|
|
98
|
-
if (result && result.content) {
|
|
99
|
-
try {
|
|
100
|
-
const generatedOptions = JSON.parse(result.content) as Response;
|
|
101
|
-
for (let i = 0; i < generatedOptions.options.length; i++) {
|
|
102
|
-
generatedOptions.options[i]!.id = i.toString();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
setOptions(generatedOptions.options);
|
|
106
|
-
setInternalState((state: any) => ({
|
|
107
|
-
...state,
|
|
108
|
-
[step.id + "options"]: generatedOptions.options,
|
|
109
|
-
}));
|
|
110
|
-
} catch (parseError) {
|
|
111
|
-
console.error("Error parsing options:", parseError);
|
|
112
|
-
setError(
|
|
113
|
-
"Failed to parse options. The response was not in the expected format.",
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
setError("No options were generated. Please try again.");
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
setError("Failed to generate options. Please try again.");
|
|
121
|
-
console.error("Error generating options:", err);
|
|
122
|
-
} finally {
|
|
123
|
-
setLoading(false);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// Generate options on component mount
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
if (internalState[step.id + "options"]?.length > 0) {
|
|
130
|
-
setOptions(internalState[step.id + "options"]);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
generateOptions();
|
|
134
|
-
}, [step.fields.instructions, internalState]);
|
|
135
|
-
|
|
136
|
-
// Sync data[propertyName] with selectedOptions state
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
const currentSelections = (data[propertyName] as Array<Option>) || [];
|
|
139
|
-
setSelectedOptions(currentSelections.map((option: Option) => option.id));
|
|
140
|
-
}, [data, propertyName]);
|
|
141
|
-
|
|
142
|
-
// Handle option selection
|
|
143
|
-
const handleOptionSelect = (option: Option) => {
|
|
144
|
-
setData((prevData: WizardData) => {
|
|
145
|
-
const currentData = [
|
|
146
|
-
...((prevData[propertyName] as Array<Option>) || []),
|
|
147
|
-
];
|
|
148
|
-
const isSelected = currentData.some((o: Option) => o.id === option.id);
|
|
149
|
-
|
|
150
|
-
let updatedData;
|
|
151
|
-
if (isSelected) {
|
|
152
|
-
// Remove option if already selected
|
|
153
|
-
updatedData = currentData.filter((o: Option) => o.id !== option.id);
|
|
154
|
-
} else {
|
|
155
|
-
// Add option if not selected
|
|
156
|
-
updatedData = [...currentData, option];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
...prevData,
|
|
161
|
-
[propertyName]: updatedData,
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
if (error) {
|
|
167
|
-
return (
|
|
168
|
-
<div className="p-4 text-red-500">
|
|
169
|
-
{error}
|
|
170
|
-
<button
|
|
171
|
-
className="ml-4 rounded bg-blue-500 px-2 py-1 text-white"
|
|
172
|
-
onClick={() => window.location.reload()}
|
|
173
|
-
>
|
|
174
|
-
Retry
|
|
175
|
-
</button>
|
|
176
|
-
</div>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return (
|
|
181
|
-
<div className="flex h-full flex-col md:flex-row">
|
|
182
|
-
<WizardBox
|
|
183
|
-
title={step.fields.configureTitle || "Configuration"}
|
|
184
|
-
icon={<Settings />}
|
|
185
|
-
description={
|
|
186
|
-
step.fields.configureDescription ||
|
|
187
|
-
"Configure instructions and regenerate options"
|
|
188
|
-
}
|
|
189
|
-
className="md:w-96"
|
|
190
|
-
>
|
|
191
|
-
<div className="flex h-full flex-col items-stretch">
|
|
192
|
-
<div className="relative flex-1">
|
|
193
|
-
<div className="absolute inset-0 overflow-y-auto">
|
|
194
|
-
<h3 className="text-sm font-bold">Instructions</h3>
|
|
195
|
-
<InputTextarea
|
|
196
|
-
className="h-48 w-full text-sm"
|
|
197
|
-
value={instructions}
|
|
198
|
-
onChange={(e) => setInstructions(e.target.value)}
|
|
199
|
-
placeholder="Enter instructions for generating the options"
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
<div className="py-2">
|
|
204
|
-
<ActionButton
|
|
205
|
-
onClick={generateOptions}
|
|
206
|
-
isLoading={loading}
|
|
207
|
-
disabled={loading}
|
|
208
|
-
loadingText="Thinking..."
|
|
209
|
-
className="w-full"
|
|
210
|
-
>
|
|
211
|
-
Regenerate Options
|
|
212
|
-
</ActionButton>
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
</WizardBox>
|
|
216
|
-
<WizardBoxConnector />
|
|
217
|
-
<WizardBox
|
|
218
|
-
title={step.fields.selectOptionsTitle || "Select Options"}
|
|
219
|
-
icon={<CheckSquare />}
|
|
220
|
-
description={
|
|
221
|
-
step.fields.selectOptionsDescription ||
|
|
222
|
-
"Choose from the generated options below"
|
|
223
|
-
}
|
|
224
|
-
className="flex-1"
|
|
225
|
-
>
|
|
226
|
-
<div className="h-full">
|
|
227
|
-
{loading && (
|
|
228
|
-
<div className="flex h-full items-center justify-center">
|
|
229
|
-
<Generate
|
|
230
|
-
title={
|
|
231
|
-
step.fields.generatingOptionsText || "Generating options..."
|
|
232
|
-
}
|
|
233
|
-
/>
|
|
234
|
-
</div>
|
|
235
|
-
)}
|
|
236
|
-
{!loading && (
|
|
237
|
-
<div>
|
|
238
|
-
{options.length === 0 ? (
|
|
239
|
-
<div className="p-4 text-gray-500">
|
|
240
|
-
No options available. Try refreshing the page.
|
|
241
|
-
</div>
|
|
242
|
-
) : (
|
|
243
|
-
options.map((option, index) => {
|
|
244
|
-
const isSelected = selectedOptions.includes(option.id);
|
|
245
|
-
|
|
246
|
-
return (
|
|
247
|
-
<div
|
|
248
|
-
key={option.id}
|
|
249
|
-
className={classNames(
|
|
250
|
-
"mb-3 flex items-center rounded border-2 bg-white p-3",
|
|
251
|
-
index % 2 === 0
|
|
252
|
-
? "animate-fadeRight"
|
|
253
|
-
: "animate-fadeLeft",
|
|
254
|
-
isSelected
|
|
255
|
-
? "text-theme-secondary border-theme-secondary"
|
|
256
|
-
: "border-gray-300 text-gray-600",
|
|
257
|
-
)}
|
|
258
|
-
onClick={() => handleOptionSelect(option)}
|
|
259
|
-
>
|
|
260
|
-
<div className="flex flex-1 cursor-pointer flex-col">
|
|
261
|
-
<div className="font-medium">{option.title}</div>
|
|
262
|
-
<div className="text-xs text-gray-600">
|
|
263
|
-
{option.description}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
{isSelected && (
|
|
267
|
-
<div className="bg-theme-secondary ml-2 flex h-6 w-6 items-center justify-center rounded-full text-white">
|
|
268
|
-
✓
|
|
269
|
-
</div>
|
|
270
|
-
)}
|
|
271
|
-
</div>
|
|
272
|
-
);
|
|
273
|
-
})
|
|
274
|
-
)}
|
|
275
|
-
</div>
|
|
276
|
-
)}
|
|
277
|
-
</div>
|
|
278
|
-
</WizardBox>
|
|
279
|
-
</div>
|
|
280
|
-
);
|
|
281
|
-
}
|