@webiny/app-website-builder 6.4.0-beta.2 → 6.4.0-beta.4
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/BaseEditor/components/DragPreview/DragCursorWrapper.d.ts +7 -0
- package/BaseEditor/components/DragPreview/DragCursorWrapper.js +17 -0
- package/BaseEditor/components/DragPreview/DragCursorWrapper.js.map +1 -0
- package/BaseEditor/components/DragPreview/DragPreview.js +37 -0
- package/BaseEditor/components/DragPreview/DragPreview.js.map +1 -0
- package/BaseEditor/components/DragPreview/index.d.ts +1 -0
- package/BaseEditor/components/DragPreview/index.js +1 -0
- package/BaseEditor/components/DragPreview/useDragPosition.d.ts +4 -0
- package/BaseEditor/components/DragPreview/useDragPosition.js +26 -0
- package/BaseEditor/components/DragPreview/useDragPosition.js.map +1 -0
- package/BaseEditor/components/Editor.js +1 -2
- package/BaseEditor/components/Editor.js.map +1 -1
- package/BaseEditor/config/EditorConfig.d.ts +4 -2
- package/BaseEditor/config/Layout.js +1 -1
- package/BaseEditor/config/Layout.js.map +1 -1
- package/BaseEditor/config/Sidebar/Layout.js +8 -14
- package/BaseEditor/config/Sidebar/Layout.js.map +1 -1
- package/BaseEditor/config/Sidebar/Sidebar.d.ts +1 -1
- package/BaseEditor/config/Sidebar/Sidebar.js +1 -1
- package/BaseEditor/config/Sidebar/Sidebar.js.map +1 -1
- package/BaseEditor/config/Sidebar/Tab.d.ts +2 -2
- package/BaseEditor/config/Sidebar/Tab.js +3 -3
- package/BaseEditor/config/Sidebar/Tab.js.map +1 -1
- package/BaseEditor/config/Toolbar/Layout.js +8 -14
- package/BaseEditor/config/Toolbar/Layout.js.map +1 -1
- package/BaseEditor/config/Toolbar/Tab.d.ts +10 -0
- package/BaseEditor/config/Toolbar/Tab.js +13 -0
- package/BaseEditor/config/Toolbar/Tab.js.map +1 -0
- package/BaseEditor/config/Toolbar/Toolbar.d.ts +1 -0
- package/BaseEditor/config/Toolbar/Toolbar.js +4 -2
- package/BaseEditor/config/Toolbar/Toolbar.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/AddressBar/AddressBar.js +1 -4
- package/BaseEditor/defaultConfig/Content/AddressBar/AddressBar.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/AddressBar/BreakpointSelector.js +20 -23
- package/BaseEditor/defaultConfig/Content/AddressBar/BreakpointSelector.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/AddressBar/PreviewDomain.js +1 -1
- package/BaseEditor/defaultConfig/Content/AddressBar/PreviewDomain.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Breadcrumbs/styles.js +2 -2
- package/BaseEditor/defaultConfig/Content/Breadcrumbs/styles.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/ContentPreviewConfig.js +6 -1
- package/BaseEditor/defaultConfig/Content/ContentPreviewConfig.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/DropZoneManager.d.ts +3 -0
- package/BaseEditor/defaultConfig/Content/Preview/DropZoneManager.js +6 -0
- package/BaseEditor/defaultConfig/Content/Preview/DropZoneManager.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/Iframe.js +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/Iframe.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/Overlays/ElementOverlay.js +10 -6
- package/BaseEditor/defaultConfig/Content/Preview/Overlays/ElementOverlay.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/Preview.js +2 -1
- package/BaseEditor/defaultConfig/Content/Preview/Preview.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/PreviewContainer.js +12 -2
- package/BaseEditor/defaultConfig/Content/Preview/PreviewContainer.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/PreviewEvents.js +1 -2
- package/BaseEditor/defaultConfig/Content/Preview/PreviewEvents.js.map +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/useResponsiveContainer.js +1 -1
- package/BaseEditor/defaultConfig/Content/Preview/useResponsiveContainer.js.map +1 -1
- package/BaseEditor/defaultConfig/DefaultEditorConfig.js +3 -5
- package/BaseEditor/defaultConfig/DefaultEditorConfig.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/ElementPreview.d.ts +7 -0
- package/BaseEditor/defaultConfig/Sidebar/ElementPreview.js +23 -0
- package/BaseEditor/defaultConfig/Sidebar/ElementPreview.js.map +1 -0
- package/BaseEditor/defaultConfig/Sidebar/ElementSettings/ElementInputs.js +12 -3
- package/BaseEditor/defaultConfig/Sidebar/ElementSettings/ElementInputs.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/ElementSettings/ElementSettingsGroup.js +6 -0
- package/BaseEditor/defaultConfig/Sidebar/ElementSettings/ElementSettingsGroup.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/ElementSettings/useBindingsForElement.d.ts +5 -5
- package/BaseEditor/defaultConfig/Sidebar/InfoMessage.js +2 -2
- package/BaseEditor/defaultConfig/Sidebar/InfoMessage.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/InheritanceLabel.js +2 -0
- package/BaseEditor/defaultConfig/Sidebar/InheritanceLabel.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/SidebarEmptyState.d.ts +4 -0
- package/BaseEditor/defaultConfig/Sidebar/SidebarEmptyState.js +12 -0
- package/BaseEditor/defaultConfig/Sidebar/SidebarEmptyState.js.map +1 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundColor.js +8 -5
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundColor.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundImage.js +11 -9
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundImage.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundPosition.js +7 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundPosition.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundScaling.js +7 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background/BackgroundScaling.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background.js +8 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Background.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/Border.js +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/Border.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderColor.js +7 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderColor.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderRadius.js +11 -14
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderRadius.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderStyle.js +7 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderStyle.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderWidth.js +11 -14
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border/BorderWidth.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border.js +6 -9
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Border.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout/Alignment.js +8 -5
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout/Alignment.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout/LengthWithUnitInput.js +9 -8
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout/LengthWithUnitInput.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout.js +8 -4
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Layout.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/LinkedEditing.js +1 -5
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/LinkedEditing.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/Margin.js +10 -21
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/Margin.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/MarginPadding.js +2 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/MarginPadding.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/Padding.js +13 -16
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding/Padding.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding.js +6 -9
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/MarginPadding.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Visibility/Visibility.js +21 -7
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/Visibility/Visibility.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/VisibilityGroup.js +4 -3
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/Groups/VisibilityGroup.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/SidebarRow.d.ts +8 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/SidebarRow.js +24 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/SidebarRow.js.map +1 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordion.d.ts +8 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordion.js +11 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordion.js.map +1 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordionItem.d.ts +9 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordionItem.js +45 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleAccordionItem.js.map +1 -0
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleProperties.js +8 -3
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleProperties.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleSettingsGroup.js +8 -7
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StyleSettingsGroup.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.js +2 -2
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.js +3 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.js.map +1 -1
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.js +9 -8
- package/BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.js.map +1 -1
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GridItem.d.ts +5 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GridItem.js +24 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GridItem.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsGrid.d.ts +7 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsGrid.js +18 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsGrid.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsList.d.ts +7 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsList.js +18 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsList.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.js +72 -36
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.js.map +1 -1
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.js +6 -7
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.js.map +1 -1
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/ListItem.d.ts +5 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/ListItem.js +23 -0
- package/BaseEditor/defaultConfig/Toolbar/InsertElements/ListItem.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/ElementActions.d.ts +4 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/ElementActions.js +29 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/ElementActions.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/LayoutIllustration.d.ts +2 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/LayoutIllustration.js +94 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/LayoutIllustration.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/Navigator.js +12 -111
- package/BaseEditor/defaultConfig/Toolbar/Navigator/Navigator.js.map +1 -1
- package/BaseEditor/defaultConfig/Toolbar/Navigator/NavigatorEmptyState.d.ts +2 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/NavigatorEmptyState.js +20 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/NavigatorEmptyState.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/NavigatorTab.js +6 -7
- package/BaseEditor/defaultConfig/Toolbar/Navigator/NavigatorTab.js.map +1 -1
- package/BaseEditor/defaultConfig/Toolbar/Navigator/Placeholder.d.ts +7 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/Placeholder.js +16 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/Placeholder.js.map +1 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/navigatorUtils.d.ts +32 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/navigatorUtils.js +70 -0
- package/BaseEditor/defaultConfig/Toolbar/Navigator/navigatorUtils.js.map +1 -0
- package/BaseEditor/hooks/useCreateElement.d.ts +1 -1
- package/BaseEditor/hooks/useCreateElement.js +1 -3
- package/BaseEditor/hooks/useCreateElement.js.map +1 -1
- package/ecommerce/EcommerceIntegration.js +1 -1
- package/ecommerce/EcommerceIntegration.js.map +1 -1
- package/ecommerce/components/ResourcePage.d.ts +1 -1
- package/ecommerce/components/ResourcePage.js +1 -1
- package/ecommerce/components/ResourcePage.js.map +1 -1
- package/exports/admin/website-builder/lexical.d.ts +18 -17
- package/exports/admin/website-builder/lexical.js +3 -2
- package/features/ecommerce/apis/useEcommerceApi.js +3 -1
- package/features/ecommerce/apis/useEcommerceApi.js.map +1 -1
- package/inputRenderers/BooleanInput.js +15 -4
- package/inputRenderers/BooleanInput.js.map +1 -1
- package/inputRenderers/FileInput.js.map +1 -1
- package/inputRenderers/LexicalInput/DefaultLexicalConfig.js +4 -1
- package/inputRenderers/LexicalInput/DefaultLexicalConfig.js.map +1 -1
- package/inputRenderers/LexicalInput/ExpandEditorAction.js +4 -1
- package/inputRenderers/LexicalInput/ExpandEditorAction.js.map +1 -1
- package/inputRenderers/LexicalInput/LexicalEditor.d.ts +4 -1
- package/inputRenderers/LexicalInput/LexicalEditor.js +13 -2
- package/inputRenderers/LexicalInput/LexicalEditor.js.map +1 -1
- package/inputRenderers/LexicalInput/LexicalEditorConfig.d.ts +18 -0
- package/inputRenderers/LexicalInput/LexicalEditorConfig.js +5 -1
- package/inputRenderers/LexicalInput/LexicalEditorConfig.js.map +1 -1
- package/inputRenderers/LexicalInput/LexicalInput.js +5 -9
- package/inputRenderers/LexicalInput/LexicalInput.js.map +1 -1
- package/inputRenderers/LexicalInput/wbStaticToolbar.css +1 -1
- package/inputRenderers/TextInput.js +3 -1
- package/inputRenderers/TextInput.js.map +1 -1
- package/modules/pages/PageEditor/PageEditorConfig.d.ts +4 -2
- package/modules/pages/PageEditor/PageSettings/PageSettingsPresenter.js +2 -2
- package/modules/pages/PageEditor/PageSettings/PageSettingsPresenter.js.map +1 -1
- package/package.json +31 -29
- package/BaseEditor/components/DragPreview.js +0 -59
- package/BaseEditor/components/DragPreview.js.map +0 -1
- package/ecommerce/components/adaptInputToBind.d.ts +0 -6
- package/ecommerce/components/adaptInputToBind.js +0 -26
- package/ecommerce/components/adaptInputToBind.js.map +0 -1
- /package/BaseEditor/components/{DragPreview.d.ts → DragPreview/DragPreview.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.ts"],"sourcesContent":["import type { useDocumentEditor } from \"~/DocumentEditor/index.js\";\nimport { StylesBindingsProcessor } from \"@webiny/website-builder-sdk\";\nimport type { IMetadata } from \"~/BaseEditor/metadata/index.js\";\nimport {\n BreakpointElementMetadata,\n ElementMetadata,\n NullMetadata,\n StylesMetadata\n} from \"~/BaseEditor/metadata/index.js\";\nimport { Commands } from \"~/BaseEditor/index.js\";\nimport type { Editor } from \"~/editorSdk/Editor.js\";\nimport { autorun, makeAutoObservable, runInAction } from \"mobx\";\nimport { type InheritanceInfo, InheritanceProcessor } from \"@webiny/website-builder-sdk\";\nimport {\n BindingsProcessor,\n type DocumentElementBindings,\n type Document\n} from \"@webiny/website-builder-sdk\";\nimport { $getComponentManifestByElementId } from \"~/editorSdk/utils/index.js\";\nimport { ComponentManifestToAstConverter } from \"@webiny/website-builder-sdk\";\nimport { BASE_BREAKPOINT } from \"~/constants.js\";\n\nexport type ElementBreakpointStyles = {\n styles: Record<string, any>;\n metadata: IMetadata;\n inheritanceMap: InheritanceInfo[\"styles\"];\n};\n\nexport class StylesStore {\n private editor: ReturnType<typeof useDocumentEditor>;\n private elementId: string;\n private breakpointNames: string[];\n private stylesProcessor: StylesBindingsProcessor | undefined;\n private elementMetadata: IMetadata = new NullMetadata();\n private devFriendlyStyles: Record<string, any> = {};\n private localPreviewStyles: Record<string, any> | undefined = undefined;\n private currentBreakpoint: string;\n private inheritanceMap: InheritanceInfo[\"styles\"] = {};\n private rawBindings: DocumentElementBindings = {};\n private bindingsProcessor: BindingsProcessor;\n private inheritanceProcessor: InheritanceProcessor;\n constructor(editor: Editor, elementId: string, breakpointNames: string[]) {\n this.editor = editor;\n this.elementId = elementId;\n this.breakpointNames = breakpointNames;\n\n const manifest = $getComponentManifestByElementId(editor, elementId ?? \"\");\n const inputsAst = ComponentManifestToAstConverter.convert(manifest?.inputs ?? []);\n\n this.bindingsProcessor = new BindingsProcessor(breakpointNames);\n this.inheritanceProcessor = new InheritanceProcessor(breakpointNames, inputsAst);\n\n const document = this.editor.getDocumentState().read();\n const editorState = this.editor.getEditorState().read();\n const breakpoint = editorState.breakpoint ?? BASE_BREAKPOINT;\n this.currentBreakpoint = breakpoint;\n\n // Initial setup.\n this.calculateStuff(document, breakpoint);\n\n autorun(() => {\n const document = this.editor.getDocumentState().read();\n const editorState = this.editor.getEditorState().read();\n const breakpoint = editorState.breakpoint ?? BASE_BREAKPOINT;\n\n runInAction(() => {\n this.currentBreakpoint = breakpoint;\n this.calculateStuff(document, breakpoint);\n });\n });\n\n makeAutoObservable(this);\n }\n\n get vm(): ElementBreakpointStyles {\n return {\n styles: this.localPreviewStyles ?? this.devFriendlyStyles,\n metadata: this.elementMetadata,\n inheritanceMap: this.inheritanceMap\n };\n }\n\n onChange = (cb: (params: { styles: StylesValueObject; metadata: IMetadata }) => void) => {\n if (!this.stylesProcessor) {\n return;\n }\n\n const styles = new StylesValueObject(this.devFriendlyStyles);\n cb({ styles, metadata: this.elementMetadata });\n\n const finalStyles = styles.getAll();\n\n const updatedStyles = this.stylesProcessor.createUpdate(\n finalStyles,\n this.currentBreakpoint\n );\n\n this.editor.updateDocument(document => {\n updatedStyles.applyToDocument(document);\n this.elementMetadata.applyToDocument(document);\n });\n\n this.localPreviewStyles = undefined;\n };\n\n onPreviewChange = (\n cb: (params: { styles: StylesValueObject; metadata: IMetadata }) => void\n ) => {\n if (!this.stylesProcessor) {\n return;\n }\n\n const styles = new StylesValueObject(structuredClone(this.devFriendlyStyles));\n\n cb({ styles, metadata: this.elementMetadata });\n\n const finalStyles = styles.getAll();\n\n this.localPreviewStyles = finalStyles;\n\n const updatedStyles = this.stylesProcessor.createUpdate(\n finalStyles,\n this.currentBreakpoint\n );\n\n this.editor.executeCommand(Commands.PreviewPatchElement, {\n elementId: this.elementId,\n patch: updatedStyles.createJsonPatch(this.rawBindings)\n });\n };\n\n private calculateStuff(document: Document, breakpoint: string) {\n const bindings = document.bindings[this.elementId] ?? {};\n\n this.rawBindings = bindings;\n const resolvedBindings = this.bindingsProcessor.getBindings(bindings, breakpoint);\n\n const inheritanceMap = this.inheritanceProcessor.getInheritanceMap(bindings, breakpoint);\n\n this.inheritanceMap = inheritanceMap.styles;\n\n this.stylesProcessor = new StylesBindingsProcessor(\n this.elementId,\n this.breakpointNames,\n bindings\n );\n\n this.elementMetadata = new StylesMetadata(\n new BreakpointElementMetadata(\n this.breakpointNames,\n breakpoint,\n new ElementMetadata(this.elementId, bindings.metadata)\n )\n );\n\n this.devFriendlyStyles = this.stylesProcessor.toDeepStyles(resolvedBindings.styles);\n }\n}\n\nexport class StylesValueObject {\n private readonly value: Record<string, any>;\n\n constructor(value: any = {}) {\n this.value = value;\n }\n\n set(key: string, value: any) {\n this.value[key] = value;\n }\n\n get(key: string) {\n return this.value[key];\n }\n\n getAll() {\n return this.value;\n }\n\n unset(key: string) {\n delete this.value[key];\n }\n}\n"],"names":["StylesStore","editor","elementId","breakpointNames","NullMetadata","undefined","cb","styles","StylesValueObject","finalStyles","updatedStyles","document","structuredClone","Commands","manifest","$getComponentManifestByElementId","inputsAst","ComponentManifestToAstConverter","BindingsProcessor","InheritanceProcessor","editorState","breakpoint","BASE_BREAKPOINT","autorun","runInAction","makeAutoObservable","bindings","resolvedBindings","inheritanceMap","StylesBindingsProcessor","StylesMetadata","BreakpointElementMetadata","ElementMetadata","value","key"],"mappings":";;;;;;AA4BO,MAAMA;IAaT,YAAYC,MAAc,EAAEC,SAAiB,EAAEC,eAAyB,CAAE;aARlE,eAAe,GAAc,IAAIC;aACjC,iBAAiB,GAAwB,CAAC;aAC1C,kBAAkB,GAAoCC;aAEtD,cAAc,GAA8B,CAAC;aAC7C,WAAW,GAA4B,CAAC;aA4ChD,QAAQ,GAAG,CAACC;YACR,IAAI,CAAC,IAAI,CAAC,eAAe,EACrB;YAGJ,MAAMC,SAAS,IAAIC,kBAAkB,IAAI,CAAC,iBAAiB;YAC3DF,GAAG;gBAAEC;gBAAQ,UAAU,IAAI,CAAC,eAAe;YAAC;YAE5C,MAAME,cAAcF,OAAO,MAAM;YAEjC,MAAMG,gBAAgB,IAAI,CAAC,eAAe,CAAC,YAAY,CACnDD,aACA,IAAI,CAAC,iBAAiB;YAG1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAACE,CAAAA;gBACvBD,cAAc,eAAe,CAACC;gBAC9B,IAAI,CAAC,eAAe,CAAC,eAAe,CAACA;YACzC;YAEA,IAAI,CAAC,kBAAkB,GAAGN;QAC9B;aAEA,eAAe,GAAG,CACdC;YAEA,IAAI,CAAC,IAAI,CAAC,eAAe,EACrB;YAGJ,MAAMC,SAAS,IAAIC,kBAAkBI,
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/StylesStore.ts"],"sourcesContent":["import type { useDocumentEditor } from \"~/DocumentEditor/index.js\";\nimport { StylesBindingsProcessor } from \"@webiny/website-builder-sdk\";\nimport type { IMetadata } from \"~/BaseEditor/metadata/index.js\";\nimport {\n BreakpointElementMetadata,\n ElementMetadata,\n NullMetadata,\n StylesMetadata\n} from \"~/BaseEditor/metadata/index.js\";\nimport { Commands } from \"~/BaseEditor/index.js\";\nimport type { Editor } from \"~/editorSdk/Editor.js\";\nimport { autorun, makeAutoObservable, runInAction, toJS } from \"mobx\";\nimport { type InheritanceInfo, InheritanceProcessor } from \"@webiny/website-builder-sdk\";\nimport {\n BindingsProcessor,\n type DocumentElementBindings,\n type Document\n} from \"@webiny/website-builder-sdk\";\nimport { $getComponentManifestByElementId } from \"~/editorSdk/utils/index.js\";\nimport { ComponentManifestToAstConverter } from \"@webiny/website-builder-sdk\";\nimport { BASE_BREAKPOINT } from \"~/constants.js\";\n\nexport type ElementBreakpointStyles = {\n styles: Record<string, any>;\n metadata: IMetadata;\n inheritanceMap: InheritanceInfo[\"styles\"];\n};\n\nexport class StylesStore {\n private editor: ReturnType<typeof useDocumentEditor>;\n private elementId: string;\n private breakpointNames: string[];\n private stylesProcessor: StylesBindingsProcessor | undefined;\n private elementMetadata: IMetadata = new NullMetadata();\n private devFriendlyStyles: Record<string, any> = {};\n private localPreviewStyles: Record<string, any> | undefined = undefined;\n private currentBreakpoint: string;\n private inheritanceMap: InheritanceInfo[\"styles\"] = {};\n private rawBindings: DocumentElementBindings = {};\n private bindingsProcessor: BindingsProcessor;\n private inheritanceProcessor: InheritanceProcessor;\n constructor(editor: Editor, elementId: string, breakpointNames: string[]) {\n this.editor = editor;\n this.elementId = elementId;\n this.breakpointNames = breakpointNames;\n\n const manifest = $getComponentManifestByElementId(editor, elementId ?? \"\");\n const inputsAst = ComponentManifestToAstConverter.convert(manifest?.inputs ?? []);\n\n this.bindingsProcessor = new BindingsProcessor(breakpointNames);\n this.inheritanceProcessor = new InheritanceProcessor(breakpointNames, inputsAst);\n\n const document = this.editor.getDocumentState().read();\n const editorState = this.editor.getEditorState().read();\n const breakpoint = editorState.breakpoint ?? BASE_BREAKPOINT;\n this.currentBreakpoint = breakpoint;\n\n // Initial setup.\n this.calculateStuff(document, breakpoint);\n\n autorun(() => {\n const document = this.editor.getDocumentState().read();\n const editorState = this.editor.getEditorState().read();\n const breakpoint = editorState.breakpoint ?? BASE_BREAKPOINT;\n\n runInAction(() => {\n this.currentBreakpoint = breakpoint;\n this.calculateStuff(document, breakpoint);\n });\n });\n\n makeAutoObservable(this);\n }\n\n get vm(): ElementBreakpointStyles {\n return {\n styles: this.localPreviewStyles ?? this.devFriendlyStyles,\n metadata: this.elementMetadata,\n inheritanceMap: this.inheritanceMap\n };\n }\n\n onChange = (cb: (params: { styles: StylesValueObject; metadata: IMetadata }) => void) => {\n if (!this.stylesProcessor) {\n return;\n }\n\n const styles = new StylesValueObject(this.devFriendlyStyles);\n cb({ styles, metadata: this.elementMetadata });\n\n const finalStyles = styles.getAll();\n\n const updatedStyles = this.stylesProcessor.createUpdate(\n finalStyles,\n this.currentBreakpoint\n );\n\n this.editor.updateDocument(document => {\n updatedStyles.applyToDocument(document);\n this.elementMetadata.applyToDocument(document);\n });\n\n this.localPreviewStyles = undefined;\n };\n\n onPreviewChange = (\n cb: (params: { styles: StylesValueObject; metadata: IMetadata }) => void\n ) => {\n if (!this.stylesProcessor) {\n return;\n }\n\n const styles = new StylesValueObject(structuredClone(toJS(this.devFriendlyStyles)));\n\n cb({ styles, metadata: this.elementMetadata });\n\n const finalStyles = styles.getAll();\n\n this.localPreviewStyles = finalStyles;\n\n const updatedStyles = this.stylesProcessor.createUpdate(\n finalStyles,\n this.currentBreakpoint\n );\n\n this.editor.executeCommand(Commands.PreviewPatchElement, {\n elementId: this.elementId,\n patch: updatedStyles.createJsonPatch(this.rawBindings)\n });\n };\n\n private calculateStuff(document: Document, breakpoint: string) {\n const bindings = document.bindings[this.elementId] ?? {};\n\n this.rawBindings = bindings;\n const resolvedBindings = this.bindingsProcessor.getBindings(bindings, breakpoint);\n\n const inheritanceMap = this.inheritanceProcessor.getInheritanceMap(bindings, breakpoint);\n\n this.inheritanceMap = inheritanceMap.styles;\n\n this.stylesProcessor = new StylesBindingsProcessor(\n this.elementId,\n this.breakpointNames,\n bindings\n );\n\n this.elementMetadata = new StylesMetadata(\n new BreakpointElementMetadata(\n this.breakpointNames,\n breakpoint,\n new ElementMetadata(this.elementId, bindings.metadata)\n )\n );\n\n this.devFriendlyStyles = this.stylesProcessor.toDeepStyles(resolvedBindings.styles);\n }\n}\n\nexport class StylesValueObject {\n private readonly value: Record<string, any>;\n\n constructor(value: any = {}) {\n this.value = value;\n }\n\n set(key: string, value: any) {\n this.value[key] = value;\n }\n\n get(key: string) {\n return this.value[key];\n }\n\n getAll() {\n return this.value;\n }\n\n unset(key: string) {\n delete this.value[key];\n }\n}\n"],"names":["StylesStore","editor","elementId","breakpointNames","NullMetadata","undefined","cb","styles","StylesValueObject","finalStyles","updatedStyles","document","structuredClone","toJS","Commands","manifest","$getComponentManifestByElementId","inputsAst","ComponentManifestToAstConverter","BindingsProcessor","InheritanceProcessor","editorState","breakpoint","BASE_BREAKPOINT","autorun","runInAction","makeAutoObservable","bindings","resolvedBindings","inheritanceMap","StylesBindingsProcessor","StylesMetadata","BreakpointElementMetadata","ElementMetadata","value","key"],"mappings":"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"}
|
|
@@ -43,6 +43,7 @@ const UnitValuePicker = (props)=>{
|
|
|
43
43
|
}, /*#__PURE__*/ react.createElement(Input, {
|
|
44
44
|
disabled: isAuto,
|
|
45
45
|
size: "md",
|
|
46
|
+
variant: "secondary",
|
|
46
47
|
value: isAuto ? "-" : props.value ?? defaultValue,
|
|
47
48
|
onEnter: onEnter,
|
|
48
49
|
autoSelect: true,
|
|
@@ -50,9 +51,10 @@ const UnitValuePicker = (props)=>{
|
|
|
50
51
|
onBlur: (e)=>setValue(e.target.value),
|
|
51
52
|
autoFocus: true
|
|
52
53
|
})), /*#__PURE__*/ react.createElement("div", {
|
|
53
|
-
className: "
|
|
54
|
+
className: "w-[80px] shrink-0"
|
|
54
55
|
}, /*#__PURE__*/ react.createElement(Select, {
|
|
55
56
|
size: "md",
|
|
57
|
+
variant: "secondary",
|
|
56
58
|
value: props.unit,
|
|
57
59
|
options: props.units,
|
|
58
60
|
onChange: setUnit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Input, Select } from \"@webiny/admin-ui\";\n\nexport type UnitOption = {\n label: string;\n value: string;\n};\n\ninterface UnitValueProps {\n value: string;\n unit: string;\n units: UnitOption[];\n onChange: (value: string) => void;\n onChangePreview: (value: string) => void;\n}\n\nclass Value {\n static from(value: string | undefined) {\n return value === \"auto\" ? 0 : parseInt(value ?? \"0\");\n }\n}\n\nconst capTo100 = [\"%\", \"vh\", \"vw\"];\n\nexport const UnitValuePicker = (props: UnitValueProps) => {\n const [editing, setEditing] = useState(false);\n\n const defaultValue = editing ? \"\" : 0;\n\n const isAuto = props.value === \"auto\";\n\n const currentValue = Value.from(props.value);\n\n const onEnter = () => {\n setValue(props.value);\n };\n\n const setUnit = (unit: string) => {\n const value = capTo100.includes(unit) && currentValue > 100 ? 100 : currentValue;\n props.onChange(unit === \"auto\" ? \"auto\" : `${value}${unit}`);\n };\n\n const setValue = (value: string) => {\n const parsedValue = Value.from(value);\n const finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n props.onChange(`${finalValue}${props.unit}`);\n };\n\n const setPreviewValue = (value: string) => {\n setEditing(true);\n let finalValue: string | number = \"\";\n if (value !== \"\") {\n const parsedValue = parseInt(value);\n finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n }\n props.onChangePreview(`${finalValue}${props.unit}`);\n };\n\n return (\n <div className={\"flex flex-row space-x-sm\"}>\n <div className={\"flex-col\"}>\n <Input\n disabled={isAuto}\n size={\"md\"}\n value={isAuto ? \"-\" : (props.value ?? defaultValue)}\n onEnter={onEnter}\n autoSelect={true}\n onChange={value => setPreviewValue(value)}\n onBlur={e => setValue(e.target.value)}\n autoFocus={true}\n />\n </div>\n <div className={\"
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/UnitValuePicker.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Input, Select } from \"@webiny/admin-ui\";\n\nexport type UnitOption = {\n label: string;\n value: string;\n};\n\ninterface UnitValueProps {\n value: string;\n unit: string;\n units: UnitOption[];\n onChange: (value: string) => void;\n onChangePreview: (value: string) => void;\n}\n\nclass Value {\n static from(value: string | undefined) {\n return value === \"auto\" ? 0 : parseInt(value ?? \"0\");\n }\n}\n\nconst capTo100 = [\"%\", \"vh\", \"vw\"];\n\nexport const UnitValuePicker = (props: UnitValueProps) => {\n const [editing, setEditing] = useState(false);\n\n const defaultValue = editing ? \"\" : 0;\n\n const isAuto = props.value === \"auto\";\n\n const currentValue = Value.from(props.value);\n\n const onEnter = () => {\n setValue(props.value);\n };\n\n const setUnit = (unit: string) => {\n const value = capTo100.includes(unit) && currentValue > 100 ? 100 : currentValue;\n props.onChange(unit === \"auto\" ? \"auto\" : `${value}${unit}`);\n };\n\n const setValue = (value: string) => {\n const parsedValue = Value.from(value);\n const finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n props.onChange(`${finalValue}${props.unit}`);\n };\n\n const setPreviewValue = (value: string) => {\n setEditing(true);\n let finalValue: string | number = \"\";\n if (value !== \"\") {\n const parsedValue = parseInt(value);\n finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n }\n props.onChangePreview(`${finalValue}${props.unit}`);\n };\n\n return (\n <div className={\"flex flex-row space-x-sm\"}>\n <div className={\"flex-col\"}>\n <Input\n disabled={isAuto}\n size={\"md\"}\n variant={\"secondary\"}\n value={isAuto ? \"-\" : (props.value ?? defaultValue)}\n onEnter={onEnter}\n autoSelect={true}\n onChange={value => setPreviewValue(value)}\n onBlur={e => setValue(e.target.value)}\n autoFocus={true}\n />\n </div>\n <div className={\"w-[80px] shrink-0\"}>\n <Select\n size={\"md\"}\n variant={\"secondary\"}\n value={props.unit}\n options={props.units}\n onChange={setUnit}\n displayResetAction={false}\n />\n </div>\n </div>\n );\n};\n"],"names":["Value","value","parseInt","capTo100","UnitValuePicker","props","editing","setEditing","useState","defaultValue","isAuto","currentValue","onEnter","setValue","setUnit","unit","parsedValue","finalValue","isNaN","setPreviewValue","Input","e","Select"],"mappings":";;AAgBA,MAAMA;IACF,OAAO,KAAKC,KAAyB,EAAE;QACnC,OAAOA,AAAU,WAAVA,QAAmB,IAAIC,SAASD,SAAS;IACpD;AACJ;AAEA,MAAME,WAAW;IAAC;IAAK;IAAM;CAAK;AAE3B,MAAMC,kBAAkB,CAACC;IAC5B,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAS;IAEvC,MAAMC,eAAeH,UAAU,KAAK;IAEpC,MAAMI,SAASL,AAAgB,WAAhBA,MAAM,KAAK;IAE1B,MAAMM,eAAeX,MAAM,IAAI,CAACK,MAAM,KAAK;IAE3C,MAAMO,UAAU;QACZC,SAASR,MAAM,KAAK;IACxB;IAEA,MAAMS,UAAU,CAACC;QACb,MAAMd,QAAQE,SAAS,QAAQ,CAACY,SAASJ,eAAe,MAAM,MAAMA;QACpEN,MAAM,QAAQ,CAACU,AAAS,WAATA,OAAkB,SAAS,GAAGd,QAAQc,MAAM;IAC/D;IAEA,MAAMF,WAAW,CAACZ;QACd,MAAMe,cAAchB,MAAM,IAAI,CAACC;QAC/B,MAAMgB,aAAaC,MAAMF,eAAe,IAAIA;QAC5CX,MAAM,QAAQ,CAAC,GAAGY,aAAaZ,MAAM,IAAI,EAAE;IAC/C;IAEA,MAAMc,kBAAkB,CAAClB;QACrBM,WAAW;QACX,IAAIU,aAA8B;QAClC,IAAIhB,AAAU,OAAVA,OAAc;YACd,MAAMe,cAAcd,SAASD;YAC7BgB,aAAaC,MAAMF,eAAe,IAAIA;QAC1C;QACAX,MAAM,eAAe,CAAC,GAAGY,aAAaZ,MAAM,IAAI,EAAE;IACtD;IAEA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;qBACZ,oBAACe,OAAKA;QACF,UAAUV;QACV,MAAM;QACN,SAAS;QACT,OAAOA,SAAS,MAAOL,MAAM,KAAK,IAAII;QACtC,SAASG;QACT,YAAY;QACZ,UAAUX,CAAAA,QAASkB,gBAAgBlB;QACnC,QAAQoB,CAAAA,IAAKR,SAASQ,EAAE,MAAM,CAAC,KAAK;QACpC,WAAW;uBAGnB,oBAAC;QAAI,WAAW;qBACZ,oBAACC,QAAMA;QACH,MAAM;QACN,SAAS;QACT,OAAOjB,MAAM,IAAI;QACjB,SAASA,MAAM,KAAK;QACpB,UAAUS;QACV,oBAAoB;;AAKxC"}
|
|
@@ -50,18 +50,19 @@ const ValueSelector = (props)=>{
|
|
|
50
50
|
setIsOpen(false);
|
|
51
51
|
};
|
|
52
52
|
const classNames = cn([
|
|
53
|
-
"cursor-pointer bg-neutral-base",
|
|
53
|
+
"cursor-pointer bg-neutral-base w-[45px]",
|
|
54
54
|
"border-sm border-solid border-neutral-muted",
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
{
|
|
56
|
+
"bg-success text-neutral-light": props.overridden && props.inheritedFrom
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"text-neutral-dimmed border-neutral-dimmed-darker bg-neutral-subtle pointer-events-none": props.disabled
|
|
60
|
+
},
|
|
61
|
+
"flex flex-row text-sm mx-auto justify-center rounded-sm py-xxs px-xs"
|
|
58
62
|
]);
|
|
59
63
|
const label = /*#__PURE__*/ react.createElement("div", {
|
|
60
64
|
className: classNames,
|
|
61
|
-
onClick: ()=>setIsOpen(true)
|
|
62
|
-
style: {
|
|
63
|
-
width: 45
|
|
64
|
-
}
|
|
65
|
+
onClick: ()=>setIsOpen(true)
|
|
65
66
|
}, props.value ?? 0, " ", props.isKeyword ? null : props.unit);
|
|
66
67
|
const controls = /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(FormComponentLabel, {
|
|
67
68
|
text: props.label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from \"react\";\nimport {\n cn,\n DropdownMenu,\n FormComponentLabel,\n FormComponentNote,\n Input,\n Select,\n Separator\n} from \"@webiny/admin-ui\";\nimport { InheritedFrom } from \"~/BaseEditor/defaultConfig/Sidebar/InheritanceLabel.js\";\nimport { useBreakpoint } from \"~/BaseEditor/hooks/useBreakpoint.js\";\nimport { BASE_BREAKPOINT } from \"~/constants.js\";\nimport { UnitValue } from \"./UnitValue.js\";\n\ntype Option = {\n label: string;\n value: string;\n};\n\ninterface ValueSelectorProps {\n label: React.ReactNode;\n value: string;\n unit: string;\n isKeyword: boolean;\n units: Option[];\n onChange: (value: string) => void;\n onChangePreview: (value: string) => void;\n onReset: () => void;\n inheritedFrom?: string;\n overridden?: boolean;\n disabled?: boolean;\n}\n\nexport const ValueSelector = (props: ValueSelectorProps) => {\n const { breakpoint } = useBreakpoint();\n const [editing, setEditing] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [inputChanged, setInputChanged] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const defaultValue = editing ? \"\" : 0;\n\n const currentValue = UnitValue.from(props.value);\n\n const trackTyping = useCallback(() => {\n setInputChanged(true);\n }, [setInputChanged]);\n\n const onEnter = () => {\n setValue(props.value);\n setIsOpen(false);\n };\n\n const setUnit = (unit: string) => {\n setEditing(false);\n currentValue.setUnit(unit);\n props.onChange(currentValue.toString());\n };\n\n const setValue = (value: string) => {\n const parsedValue = UnitValue.from(value);\n if (!inputChanged) {\n return;\n }\n const finalValue = parsedValue.getValue(\"0\");\n props.onChange(`${finalValue}${props.unit}`);\n\n setInputChanged(false);\n setTimeout(() => {\n setEditing(false);\n }, 20);\n };\n\n const setPreviewValue = (value: string) => {\n setEditing(true);\n let finalValue: string | number = \"\";\n if (value !== \"\") {\n const parsedValue = parseInt(value);\n finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n }\n props.onChangePreview(`${finalValue}${props.unit}`);\n };\n\n const onReset = () => {\n props.onReset();\n setIsOpen(false);\n };\n\n const classNames = cn([\n \"cursor-pointer bg-neutral-base\",\n \"border-sm border-solid border-neutral-muted\",\n
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.js","sources":["../../../../../src/BaseEditor/defaultConfig/Sidebar/StyleSettings/ValueSelector.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from \"react\";\nimport {\n cn,\n DropdownMenu,\n FormComponentLabel,\n FormComponentNote,\n Input,\n Select,\n Separator\n} from \"@webiny/admin-ui\";\nimport { InheritedFrom } from \"~/BaseEditor/defaultConfig/Sidebar/InheritanceLabel.js\";\nimport { useBreakpoint } from \"~/BaseEditor/hooks/useBreakpoint.js\";\nimport { BASE_BREAKPOINT } from \"~/constants.js\";\nimport { UnitValue } from \"./UnitValue.js\";\n\ntype Option = {\n label: string;\n value: string;\n};\n\ninterface ValueSelectorProps {\n label: React.ReactNode;\n value: string;\n unit: string;\n isKeyword: boolean;\n units: Option[];\n onChange: (value: string) => void;\n onChangePreview: (value: string) => void;\n onReset: () => void;\n inheritedFrom?: string;\n overridden?: boolean;\n disabled?: boolean;\n}\n\nexport const ValueSelector = (props: ValueSelectorProps) => {\n const { breakpoint } = useBreakpoint();\n const [editing, setEditing] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [inputChanged, setInputChanged] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const defaultValue = editing ? \"\" : 0;\n\n const currentValue = UnitValue.from(props.value);\n\n const trackTyping = useCallback(() => {\n setInputChanged(true);\n }, [setInputChanged]);\n\n const onEnter = () => {\n setValue(props.value);\n setIsOpen(false);\n };\n\n const setUnit = (unit: string) => {\n setEditing(false);\n currentValue.setUnit(unit);\n props.onChange(currentValue.toString());\n };\n\n const setValue = (value: string) => {\n const parsedValue = UnitValue.from(value);\n if (!inputChanged) {\n return;\n }\n const finalValue = parsedValue.getValue(\"0\");\n props.onChange(`${finalValue}${props.unit}`);\n\n setInputChanged(false);\n setTimeout(() => {\n setEditing(false);\n }, 20);\n };\n\n const setPreviewValue = (value: string) => {\n setEditing(true);\n let finalValue: string | number = \"\";\n if (value !== \"\") {\n const parsedValue = parseInt(value);\n finalValue = isNaN(parsedValue) ? 0 : parsedValue;\n }\n props.onChangePreview(`${finalValue}${props.unit}`);\n };\n\n const onReset = () => {\n props.onReset();\n setIsOpen(false);\n };\n\n const classNames = cn([\n \"cursor-pointer bg-neutral-base w-[45px]\",\n \"border-sm border-solid border-neutral-muted\",\n { \"bg-success text-neutral-light\": props.overridden && props.inheritedFrom },\n {\n \"text-neutral-dimmed border-neutral-dimmed-darker bg-neutral-subtle pointer-events-none\":\n props.disabled\n },\n \"flex flex-row text-sm mx-auto justify-center rounded-sm py-xxs px-xs\"\n ]);\n\n const label = (\n <div className={classNames} onClick={() => setIsOpen(true)}>\n {props.value ?? 0} {props.isKeyword ? null : props.unit}\n </div>\n );\n\n const controls = (\n <>\n <FormComponentLabel text={props.label} />\n <div className={\"flex flex-row space-x-sm\"}>\n <div className={\"flex-col\"}>\n <Input\n onKeyDown={trackTyping}\n inputRef={inputRef}\n disabled={props.isKeyword}\n size={\"md\"}\n value={props.isKeyword ? \"-\" : (props.value ?? defaultValue)}\n onEnter={onEnter}\n autoSelect={true}\n onChange={value => setPreviewValue(value)}\n onBlur={e => setValue(e.target.value)}\n autoFocus={true}\n />\n </div>\n <div className={\"flex-col\"}>\n <Select\n size=\"md\"\n value={props.unit}\n options={props.units}\n onChange={unit => {\n setUnit(unit);\n setTimeout(() => {\n inputRef.current?.focus();\n }, 20);\n }}\n displayResetAction={false}\n />\n </div>\n </div>\n <FormComponentNote text={`Hit \"Enter\" or click outside the menu to close it.`} />\n </>\n );\n\n return (\n <div className={\"flex flex-col w-full\"}>\n <DropdownMenu\n open={isOpen}\n onOpenChange={() => setIsOpen(false)}\n trigger={label}\n align=\"center\"\n side=\"bottom\"\n className={\"shadow-lg\"}\n >\n <div className={\"p-sm text-sm\"} style={{ width: 200 }}>\n {controls}\n {BASE_BREAKPOINT === breakpoint.name ? null : (\n <>\n <Separator variant={\"dimmed\"} margin={\"lg\"} />\n <InheritedFrom\n inheritedFrom={props.inheritedFrom ?? BASE_BREAKPOINT}\n overriddenAt={props.overridden ? breakpoint.name : null}\n onReset={onReset}\n />\n </>\n )}\n </div>\n </DropdownMenu>\n </div>\n );\n};\n"],"names":["ValueSelector","props","breakpoint","useBreakpoint","editing","setEditing","useState","isOpen","setIsOpen","inputChanged","setInputChanged","inputRef","useRef","defaultValue","currentValue","UnitValue","trackTyping","useCallback","onEnter","setValue","setUnit","unit","value","parsedValue","finalValue","setTimeout","setPreviewValue","parseInt","isNaN","onReset","classNames","cn","label","controls","FormComponentLabel","Input","e","Select","FormComponentNote","DropdownMenu","BASE_BREAKPOINT","Separator","InheritedFrom"],"mappings":";;;;;;AAkCO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAS;IACvC,MAAM,CAACC,QAAQC,UAAU,GAAGF,SAAS;IACrC,MAAM,CAACG,cAAcC,gBAAgB,GAAGJ,SAAS;IACjD,MAAMK,WAAWC,OAAgC;IAEjD,MAAMC,eAAeT,UAAU,KAAK;IAEpC,MAAMU,eAAeC,UAAU,IAAI,CAACd,MAAM,KAAK;IAE/C,MAAMe,cAAcC,YAAY;QAC5BP,gBAAgB;IACpB,GAAG;QAACA;KAAgB;IAEpB,MAAMQ,UAAU;QACZC,SAASlB,MAAM,KAAK;QACpBO,UAAU;IACd;IAEA,MAAMY,UAAU,CAACC;QACbhB,WAAW;QACXS,aAAa,OAAO,CAACO;QACrBpB,MAAM,QAAQ,CAACa,aAAa,QAAQ;IACxC;IAEA,MAAMK,WAAW,CAACG;QACd,MAAMC,cAAcR,UAAU,IAAI,CAACO;QACnC,IAAI,CAACb,cACD;QAEJ,MAAMe,aAAaD,YAAY,QAAQ,CAAC;QACxCtB,MAAM,QAAQ,CAAC,GAAGuB,aAAavB,MAAM,IAAI,EAAE;QAE3CS,gBAAgB;QAChBe,WAAW;YACPpB,WAAW;QACf,GAAG;IACP;IAEA,MAAMqB,kBAAkB,CAACJ;QACrBjB,WAAW;QACX,IAAImB,aAA8B;QAClC,IAAIF,AAAU,OAAVA,OAAc;YACd,MAAMC,cAAcI,SAASL;YAC7BE,aAAaI,MAAML,eAAe,IAAIA;QAC1C;QACAtB,MAAM,eAAe,CAAC,GAAGuB,aAAavB,MAAM,IAAI,EAAE;IACtD;IAEA,MAAM4B,UAAU;QACZ5B,MAAM,OAAO;QACbO,UAAU;IACd;IAEA,MAAMsB,aAAaC,GAAG;QAClB;QACA;QACA;YAAE,iCAAiC9B,MAAM,UAAU,IAAIA,MAAM,aAAa;QAAC;QAC3E;YACI,0FACIA,MAAM,QAAQ;QACtB;QACA;KACH;IAED,MAAM+B,QAAQ,WAARA,GACF,oBAAC;QAAI,WAAWF;QAAY,SAAS,IAAMtB,UAAU;OAChDP,MAAM,KAAK,IAAI,GAAE,KAAEA,MAAM,SAAS,GAAG,OAAOA,MAAM,IAAI;IAI/D,MAAMgC,WAAW,WAAXA,GACF,wDACI,oBAACC,oBAAkBA;QAAC,MAAMjC,MAAM,KAAK;sBACrC,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;qBACZ,oBAACkC,OAAKA;QACF,WAAWnB;QACX,UAAUL;QACV,UAAUV,MAAM,SAAS;QACzB,MAAM;QACN,OAAOA,MAAM,SAAS,GAAG,MAAOA,MAAM,KAAK,IAAIY;QAC/C,SAASK;QACT,YAAY;QACZ,UAAUI,CAAAA,QAASI,gBAAgBJ;QACnC,QAAQc,CAAAA,IAAKjB,SAASiB,EAAE,MAAM,CAAC,KAAK;QACpC,WAAW;uBAGnB,oBAAC;QAAI,WAAW;qBACZ,oBAACC,QAAMA;QACH,MAAK;QACL,OAAOpC,MAAM,IAAI;QACjB,SAASA,MAAM,KAAK;QACpB,UAAUoB,CAAAA;YACND,QAAQC;YACRI,WAAW;gBACPd,SAAS,OAAO,EAAE;YACtB,GAAG;QACP;QACA,oBAAoB;wBAIhC,oBAAC2B,mBAAiBA;QAAC,MAAM;;IAIjC,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACC,cAAYA;QACT,MAAMhC;QACN,cAAc,IAAMC,UAAU;QAC9B,SAASwB;QACT,OAAM;QACN,MAAK;QACL,WAAW;qBAEX,oBAAC;QAAI,WAAW;QAAgB,OAAO;YAAE,OAAO;QAAI;OAC/CC,UACAO,oBAAoBtC,WAAW,IAAI,GAAG,OAAO,WAAP,GACnC,wDACI,oBAACuC,WAASA;QAAC,SAAS;QAAU,QAAQ;sBACtC,oBAACC,eAAaA;QACV,eAAezC,MAAM,aAAa,IAAIuC;QACtC,cAAcvC,MAAM,UAAU,GAAGC,WAAW,IAAI,GAAG;QACnD,SAAS2B;;AAQzC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Icon } from "@webiny/admin-ui";
|
|
3
|
+
import { useSelectFromEditor } from "../../../hooks/useSelectFromEditor.js";
|
|
4
|
+
import { InlineSvg } from "./InlineSvg.js";
|
|
5
|
+
const useComponent = (name)=>useSelectFromEditor((state)=>state.components?.[name]);
|
|
6
|
+
const GridItem = ({ item })=>{
|
|
7
|
+
const component = useComponent(item.name);
|
|
8
|
+
if (!component) return /*#__PURE__*/ react.createElement(react.Fragment, null);
|
|
9
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
10
|
+
className: "flex flex-col items-center justify-center gap-sm px-sm py-md bg-neutral-light rounded-lg cursor-grab fill-neutral-strong w-[80px] min-h-[80px]"
|
|
11
|
+
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
12
|
+
label: "Icon",
|
|
13
|
+
icon: /*#__PURE__*/ react.createElement(InlineSvg, {
|
|
14
|
+
src: component.image
|
|
15
|
+
}),
|
|
16
|
+
size: "lg",
|
|
17
|
+
color: "neutral-strong"
|
|
18
|
+
}), /*#__PURE__*/ react.createElement("div", {
|
|
19
|
+
className: "text-sm font-medium text-neutral-strong text-center leading-tight"
|
|
20
|
+
}, component.label ?? component.name));
|
|
21
|
+
};
|
|
22
|
+
export { GridItem };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=GridItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/GridItem.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/GridItem.tsx"],"sourcesContent":["import React from \"react\";\nimport { Icon } from \"@webiny/admin-ui\";\nimport type { ComponentGroupItem, ComponentManifest } from \"@webiny/website-builder-sdk\";\nimport { useSelectFromEditor } from \"~/BaseEditor/hooks/useSelectFromEditor.js\";\nimport { InlineSvg } from \"./InlineSvg.js\";\n\nconst useComponent = (name: string) => {\n return useSelectFromEditor<ComponentManifest | undefined>(state => state.components?.[name]);\n};\n\nexport const GridItem = ({ item }: { item: ComponentGroupItem }) => {\n const component = useComponent(item.name);\n if (!component) {\n return <></>;\n }\n\n return (\n <div className=\"flex flex-col items-center justify-center gap-sm px-sm py-md bg-neutral-light rounded-lg cursor-grab fill-neutral-strong w-[80px] min-h-[80px]\">\n <Icon\n label=\"Icon\"\n icon={<InlineSvg src={component.image!} />}\n size={\"lg\"}\n color={\"neutral-strong\"}\n />\n <div className=\"text-sm font-medium text-neutral-strong text-center leading-tight\">\n {component.label ?? component.name}\n </div>\n </div>\n );\n};\n"],"names":["useComponent","name","useSelectFromEditor","state","GridItem","item","component","Icon","InlineSvg"],"mappings":";;;;AAMA,MAAMA,eAAe,CAACC,OACXC,oBAAmDC,CAAAA,QAASA,MAAM,UAAU,EAAE,CAACF,KAAK;AAGxF,MAAMG,WAAW,CAAC,EAAEC,IAAI,EAAgC;IAC3D,MAAMC,YAAYN,aAAaK,KAAK,IAAI;IACxC,IAAI,CAACC,WACD,OAAO,WAAP,GAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,MAAIA;QACD,OAAM;QACN,oBAAM,oBAACC,WAASA;YAAC,KAAKF,UAAU,KAAK;;QACrC,MAAM;QACN,OAAO;sBAEX,oBAAC;QAAI,WAAU;OACVA,UAAU,KAAK,IAAIA,UAAU,IAAI;AAIlD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ComponentGroupItem } from "@webiny/website-builder-sdk";
|
|
3
|
+
interface GroupItemsGridProps {
|
|
4
|
+
items: ComponentGroupItem[];
|
|
5
|
+
}
|
|
6
|
+
export declare const GroupItemsGrid: ({ items }: GroupItemsGridProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Draggable } from "../../../components/Draggable.js";
|
|
3
|
+
import { GridItem } from "./GridItem.js";
|
|
4
|
+
const GroupItemsGrid = ({ items })=>/*#__PURE__*/ react.createElement("div", {
|
|
5
|
+
className: "grid grid-cols-3 gap-sm px-lg py-sm",
|
|
6
|
+
"data-role": "group-items"
|
|
7
|
+
}, items.map((item)=>/*#__PURE__*/ react.createElement(Draggable, {
|
|
8
|
+
key: item.name,
|
|
9
|
+
type: "ELEMENT",
|
|
10
|
+
item: {
|
|
11
|
+
componentName: item.name
|
|
12
|
+
}
|
|
13
|
+
}, ({ dragRef })=>dragRef(/*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement(GridItem, {
|
|
14
|
+
item: item
|
|
15
|
+
}))))));
|
|
16
|
+
export { GroupItemsGrid };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=GroupItemsGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsGrid.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsGrid.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentGroupItem } from \"@webiny/website-builder-sdk\";\nimport { Draggable } from \"~/BaseEditor/components/Draggable.js\";\nimport { GridItem } from \"./GridItem.js\";\n\ninterface GroupItemsGridProps {\n items: ComponentGroupItem[];\n}\n\nexport const GroupItemsGrid = ({ items }: GroupItemsGridProps) => (\n <div className={\"grid grid-cols-3 gap-sm px-lg py-sm\"} data-role={\"group-items\"}>\n {items.map(item => (\n <Draggable key={item.name} type=\"ELEMENT\" item={{ componentName: item.name }}>\n {({ dragRef }) =>\n dragRef(\n <div>\n <GridItem item={item} />\n </div>\n )\n }\n </Draggable>\n ))}\n </div>\n);\n"],"names":["GroupItemsGrid","items","item","Draggable","dragRef","GridItem"],"mappings":";;;AASO,MAAMA,iBAAiB,CAAC,EAAEC,KAAK,EAAuB,iBACzD,oBAAC;QAAI,WAAW;QAAuC,aAAW;OAC7DA,MAAM,GAAG,CAACC,CAAAA,OAAAA,WAAAA,GACP,oBAACC,WAASA;YAAC,KAAKD,KAAK,IAAI;YAAE,MAAK;YAAU,MAAM;gBAAE,eAAeA,KAAK,IAAI;YAAC;WACtE,CAAC,EAAEE,OAAO,EAAE,GACTA,QAAQ,WAARA,GACI,oBAAC,2BACG,oBAACC,UAAQA;gBAAC,MAAMH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ComponentGroupItem } from "@webiny/website-builder-sdk";
|
|
3
|
+
interface GroupItemsListProps {
|
|
4
|
+
items: ComponentGroupItem[];
|
|
5
|
+
}
|
|
6
|
+
export declare const GroupItemsList: ({ items }: GroupItemsListProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Draggable } from "../../../components/Draggable.js";
|
|
3
|
+
import { ListItem } from "./ListItem.js";
|
|
4
|
+
const GroupItemsList = ({ items })=>/*#__PURE__*/ react.createElement("div", {
|
|
5
|
+
className: "py-sm px-xl flex flex-col gap-y-xs",
|
|
6
|
+
"data-role": "group-items"
|
|
7
|
+
}, items.map((item)=>/*#__PURE__*/ react.createElement(Draggable, {
|
|
8
|
+
key: item.name,
|
|
9
|
+
type: "ELEMENT",
|
|
10
|
+
item: {
|
|
11
|
+
componentName: item.name
|
|
12
|
+
}
|
|
13
|
+
}, ({ dragRef })=>dragRef(/*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement(ListItem, {
|
|
14
|
+
item: item
|
|
15
|
+
}))))));
|
|
16
|
+
export { GroupItemsList };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=GroupItemsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsList.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/GroupItemsList.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentGroupItem } from \"@webiny/website-builder-sdk\";\nimport { Draggable } from \"~/BaseEditor/components/Draggable.js\";\nimport { ListItem } from \"./ListItem.js\";\n\ninterface GroupItemsListProps {\n items: ComponentGroupItem[];\n}\n\nexport const GroupItemsList = ({ items }: GroupItemsListProps) => (\n <div className={\"py-sm px-xl flex flex-col gap-y-xs\"} data-role={\"group-items\"}>\n {items.map(item => (\n <Draggable key={item.name} type=\"ELEMENT\" item={{ componentName: item.name }}>\n {({ dragRef }) =>\n dragRef(\n <div>\n <ListItem item={item} />\n </div>\n )\n }\n </Draggable>\n ))}\n </div>\n);\n"],"names":["GroupItemsList","items","item","Draggable","dragRef","ListItem"],"mappings":";;;AASO,MAAMA,iBAAiB,CAAC,EAAEC,KAAK,EAAuB,iBACzD,oBAAC;QAAI,WAAW;QAAsC,aAAW;OAC5DA,MAAM,GAAG,CAACC,CAAAA,OAAAA,WAAAA,GACP,oBAACC,WAASA;YAAC,KAAKD,KAAK,IAAI;YAAE,MAAK;YAAU,MAAM;gBAAE,eAAeA,KAAK,IAAI;YAAC;WACtE,CAAC,EAAEE,OAAO,EAAE,GACTA,QAAQ,WAARA,GACI,oBAAC,2BACG,oBAACC,UAAQA;gBAAC,MAAMH"}
|
|
@@ -1,45 +1,81 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
import { FillViewportHeight, Icon, InputPrimitive, ScrollArea, Text, ToggleGroupPrimitive } from "@webiny/admin-ui";
|
|
3
|
+
import { ReactComponent } from "@webiny/icons/search.svg";
|
|
4
|
+
import { ReactComponent as format_list_bulleted_svg_ReactComponent } from "@webiny/icons/format_list_bulleted.svg";
|
|
5
|
+
import { ReactComponent as grid_view_svg_ReactComponent } from "@webiny/icons/grid_view.svg";
|
|
6
|
+
import { ReactComponent as dashboard_customize_svg_ReactComponent } from "@webiny/icons/dashboard_customize.svg";
|
|
6
7
|
import { useComponentGroups } from "./useComponentGroups.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { InlineSvg } from "./InlineSvg.js";
|
|
9
|
+
import { GroupItemsList } from "./GroupItemsList.js";
|
|
10
|
+
import { GroupItemsGrid } from "./GroupItemsGrid.js";
|
|
11
|
+
const VIEW_ITEMS = [
|
|
12
|
+
{
|
|
13
|
+
value: "list",
|
|
14
|
+
icon: /*#__PURE__*/ react.createElement(Icon, {
|
|
15
|
+
icon: /*#__PURE__*/ react.createElement(format_list_bulleted_svg_ReactComponent, null),
|
|
16
|
+
label: "List view"
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "grid",
|
|
21
|
+
icon: /*#__PURE__*/ react.createElement(Icon, {
|
|
22
|
+
icon: /*#__PURE__*/ react.createElement(grid_view_svg_ReactComponent, null),
|
|
23
|
+
label: "Grid view"
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
const InsertElements = ()=>{
|
|
28
|
+
const [search, setSearch] = useState("");
|
|
29
|
+
const [viewType, setViewType] = useState("list");
|
|
30
|
+
const groups = useComponentGroups();
|
|
31
|
+
const query = search.toLowerCase().trim();
|
|
32
|
+
const isGrid = "grid" === viewType;
|
|
11
33
|
return /*#__PURE__*/ react.createElement("div", {
|
|
12
|
-
className: "
|
|
13
|
-
}, /*#__PURE__*/ react.createElement(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
className: "mb-sm pt-sm"
|
|
35
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
36
|
+
className: "flex items-center gap-xs mb-md"
|
|
37
|
+
}, /*#__PURE__*/ react.createElement(InputPrimitive, {
|
|
38
|
+
value: search,
|
|
39
|
+
onChange: (value)=>setSearch(value ?? ""),
|
|
40
|
+
onEscape: ()=>setSearch(""),
|
|
41
|
+
placeholder: "Search...",
|
|
42
|
+
startIcon: /*#__PURE__*/ react.createElement(Icon, {
|
|
43
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
44
|
+
label: "Search"
|
|
17
45
|
}),
|
|
46
|
+
variant: "secondary",
|
|
18
47
|
size: "md"
|
|
19
|
-
}), /*#__PURE__*/ react.createElement(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
}), /*#__PURE__*/ react.createElement(ToggleGroupPrimitive, {
|
|
49
|
+
items: VIEW_ITEMS,
|
|
50
|
+
value: viewType,
|
|
51
|
+
onChange: (v)=>v && setViewType(v),
|
|
52
|
+
variant: "ghost",
|
|
53
|
+
size: "md"
|
|
54
|
+
})), /*#__PURE__*/ react.createElement(FillViewportHeight, null, /*#__PURE__*/ react.createElement(ScrollArea, {
|
|
55
|
+
className: "h-full"
|
|
56
|
+
}, /*#__PURE__*/ react.createElement("div", null, groups.map((group)=>{
|
|
57
|
+
const items = query ? group.items.filter((item)=>(item.label ?? item.name).toLowerCase().includes(query)) : group.items;
|
|
58
|
+
if (!items.length) return null;
|
|
59
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
28
60
|
key: group.name,
|
|
29
|
-
|
|
30
|
-
description: group.description
|
|
61
|
+
className: "p-sm flex flex-col gap-y-sm"
|
|
31
62
|
}, /*#__PURE__*/ react.createElement("div", {
|
|
32
|
-
className: "flex
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
className: "flex gap-x-sm"
|
|
64
|
+
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
65
|
+
color: "accent",
|
|
66
|
+
icon: group.icon ? /*#__PURE__*/ react.createElement(InlineSvg, {
|
|
67
|
+
src: group.icon
|
|
68
|
+
}) : /*#__PURE__*/ react.createElement(dashboard_customize_svg_ReactComponent, null),
|
|
69
|
+
label: group.label
|
|
70
|
+
}), /*#__PURE__*/ react.createElement(Text, {
|
|
71
|
+
size: "md",
|
|
72
|
+
className: "font-semibold"
|
|
73
|
+
}, group.label)), isGrid ? /*#__PURE__*/ react.createElement(GroupItemsGrid, {
|
|
74
|
+
items: items
|
|
75
|
+
}) : /*#__PURE__*/ react.createElement(GroupItemsList, {
|
|
76
|
+
items: items
|
|
77
|
+
}));
|
|
78
|
+
})))));
|
|
43
79
|
};
|
|
44
80
|
export { InsertElements };
|
|
45
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.tsx"],"sourcesContent":["import React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElements.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport {\n Icon,\n Text,\n ScrollArea,\n InputPrimitive,\n ToggleGroupPrimitive,\n FillViewportHeight\n} from \"@webiny/admin-ui\";\nimport { ReactComponent as SearchIcon } from \"@webiny/icons/search.svg\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/format_list_bulleted.svg\";\nimport { ReactComponent as GridIcon } from \"@webiny/icons/grid_view.svg\";\nimport { ReactComponent as DashboardIcon } from \"@webiny/icons/dashboard_customize.svg\";\nimport { useComponentGroups } from \"./useComponentGroups.js\";\nimport { InlineSvg } from \"./InlineSvg.js\";\nimport { GroupItemsList } from \"./GroupItemsList.js\";\nimport { GroupItemsGrid } from \"./GroupItemsGrid.js\";\n\nconst VIEW_ITEMS = [\n { value: \"list\", icon: <Icon icon={<ListIcon />} label={\"List view\"} /> },\n { value: \"grid\", icon: <Icon icon={<GridIcon />} label={\"Grid view\"} /> }\n];\n\nexport const InsertElements = () => {\n const [search, setSearch] = useState(\"\");\n const [viewType, setViewType] = useState(\"list\");\n const groups = useComponentGroups();\n const query = search.toLowerCase().trim();\n const isGrid = viewType === \"grid\";\n\n return (\n <div className={\"mb-sm pt-sm\"}>\n <div className={\"flex items-center gap-xs mb-md\"}>\n <InputPrimitive\n value={search}\n onChange={value => setSearch(value ?? \"\")}\n onEscape={() => setSearch(\"\")}\n placeholder={\"Search...\"}\n startIcon={<Icon icon={<SearchIcon />} label={\"Search\"} />}\n variant={\"secondary\"}\n size={\"md\"}\n />\n <ToggleGroupPrimitive\n items={VIEW_ITEMS}\n value={viewType}\n onChange={v => v && setViewType(v)}\n variant={\"ghost\"}\n size={\"md\"}\n />\n </div>\n <FillViewportHeight>\n <ScrollArea className={\"h-full\"}>\n <div>\n {groups.map(group => {\n const items = query\n ? group.items.filter(item =>\n (item.label ?? item.name).toLowerCase().includes(query)\n )\n : group.items;\n\n if (!items.length) {\n return null;\n }\n\n return (\n <div key={group.name} className={\"p-sm flex flex-col gap-y-sm\"}>\n <div className={\"flex gap-x-sm\"}>\n <Icon\n color={\"accent\"}\n icon={\n group.icon ? (\n <InlineSvg src={group.icon} />\n ) : (\n <DashboardIcon />\n )\n }\n label={group.label}\n />\n <Text size={\"md\"} className={\"font-semibold\"}>\n {group.label}\n </Text>\n </div>\n {isGrid ? (\n <GroupItemsGrid items={items} />\n ) : (\n <GroupItemsList items={items} />\n )}\n </div>\n );\n })}\n </div>\n </ScrollArea>\n </FillViewportHeight>\n </div>\n );\n};\n"],"names":["VIEW_ITEMS","Icon","ListIcon","GridIcon","InsertElements","search","setSearch","useState","viewType","setViewType","groups","useComponentGroups","query","isGrid","InputPrimitive","value","SearchIcon","ToggleGroupPrimitive","v","FillViewportHeight","ScrollArea","group","items","item","InlineSvg","DashboardIcon","Text","GroupItemsGrid","GroupItemsList"],"mappings":";;;;;;;;;;AAkBA,MAAMA,aAAa;IACf;QAAE,OAAO;QAAQ,MAAM,WAAN,GAAM,oBAACC,MAAIA;YAAC,oBAAM,oBAACC,yCAAQA;YAAK,OAAO;;IAAgB;IACxE;QAAE,OAAO;QAAQ,MAAM,WAAN,GAAM,oBAACD,MAAIA;YAAC,oBAAM,oBAACE,8BAAQA;YAAK,OAAO;;IAAgB;CAC3E;AAEM,MAAMC,iBAAiB;IAC1B,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAAS;IACrC,MAAM,CAACC,UAAUC,YAAY,GAAGF,SAAS;IACzC,MAAMG,SAASC;IACf,MAAMC,QAAQP,OAAO,WAAW,GAAG,IAAI;IACvC,MAAMQ,SAASL,AAAa,WAAbA;IAEf,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;qBACZ,oBAACM,gBAAcA;QACX,OAAOT;QACP,UAAUU,CAAAA,QAAST,UAAUS,SAAS;QACtC,UAAU,IAAMT,UAAU;QAC1B,aAAa;QACb,yBAAW,oBAACL,MAAIA;YAAC,oBAAM,oBAACe,gBAAUA;YAAK,OAAO;;QAC9C,SAAS;QACT,MAAM;sBAEV,oBAACC,sBAAoBA;QACjB,OAAOjB;QACP,OAAOQ;QACP,UAAUU,CAAAA,IAAKA,KAAKT,YAAYS;QAChC,SAAS;QACT,MAAM;uBAGd,oBAACC,oBAAkBA,MAAAA,WAAAA,GACf,oBAACC,YAAUA;QAAC,WAAW;qBACnB,oBAAC,aACIV,OAAO,GAAG,CAACW,CAAAA;QACR,MAAMC,QAAQV,QACRS,MAAM,KAAK,CAAC,MAAM,CAACE,CAAAA,OACdA,AAAAA,CAAAA,KAAK,KAAK,IAAIA,KAAK,IAAG,EAAG,WAAW,GAAG,QAAQ,CAACX,UAErDS,MAAM,KAAK;QAEjB,IAAI,CAACC,MAAM,MAAM,EACb,OAAO;QAGX,OAAO,WAAP,GACI,oBAAC;YAAI,KAAKD,MAAM,IAAI;YAAE,WAAW;yBAC7B,oBAAC;YAAI,WAAW;yBACZ,oBAACpB,MAAIA;YACD,OAAO;YACP,MACIoB,MAAM,IAAI,GAAG,WAAH,GACN,oBAACG,WAASA;gBAAC,KAAKH,MAAM,IAAI;+BAE1B,oBAACI,wCAAaA;YAGtB,OAAOJ,MAAM,KAAK;0BAEtB,oBAACK,MAAIA;YAAC,MAAM;YAAM,WAAW;WACxBL,MAAM,KAAK,IAGnBR,SAAS,WAATA,GACG,oBAACc,gBAAcA;YAAC,OAAOL;2BAEvB,oBAACM,gBAAcA;YAAC,OAAON;;IAIvC;AAMxB"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
-
import { Icon
|
|
3
|
-
import { ScrollableContainer } from "../../../config/Sidebar/ScrollableContainer.js";
|
|
2
|
+
import { Icon } from "@webiny/admin-ui";
|
|
4
3
|
import { ReactComponent } from "@webiny/icons/add_circle_outline.svg";
|
|
4
|
+
import { Toolbar } from "../../../config/Toolbar/Toolbar.js";
|
|
5
5
|
import { InsertElements } from "./InsertElements.js";
|
|
6
|
-
const InsertElementsTab = ()=>/*#__PURE__*/ react.createElement(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
spacing: "sm",
|
|
6
|
+
const InsertElementsTab = ()=>/*#__PURE__*/ react.createElement(Toolbar.Tab, {
|
|
7
|
+
name: "insert",
|
|
8
|
+
label: "Insert",
|
|
10
9
|
icon: /*#__PURE__*/ react.createElement(Icon, {
|
|
11
10
|
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
12
11
|
label: "Insert Element"
|
|
13
12
|
}),
|
|
14
|
-
|
|
13
|
+
element: /*#__PURE__*/ react.createElement(InsertElements, null)
|
|
15
14
|
});
|
|
16
15
|
export { InsertElementsTab };
|
|
17
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.tsx"],"sourcesContent":["import React from \"react\";\nimport { Icon
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/InsertElementsTab.tsx"],"sourcesContent":["import React from \"react\";\nimport { Icon } from \"@webiny/admin-ui\";\nimport { ReactComponent as InsertIcon } from \"@webiny/icons/add_circle_outline.svg\";\nimport { Toolbar } from \"~/BaseEditor/config/Toolbar/Toolbar.js\";\nimport { InsertElements } from \"./InsertElements.js\";\n\nexport const InsertElementsTab = () => (\n <Toolbar.Tab\n name={\"insert\"}\n label={\"Insert\"}\n icon={<Icon icon={<InsertIcon />} label={\"Insert Element\"} />}\n element={<InsertElements />}\n />\n);\n"],"names":["InsertElementsTab","Toolbar","Icon","InsertIcon","InsertElements"],"mappings":";;;;;AAMO,MAAMA,oBAAoB,kBAC7B,oBAACC,QAAQ,GAAG;QACR,MAAM;QACN,OAAO;QACP,oBAAM,oBAACC,MAAIA;YAAC,oBAAM,oBAACC,gBAAUA;YAAK,OAAO;;QACzC,uBAAS,oBAACC,gBAAcA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Icon } from "@webiny/admin-ui";
|
|
3
|
+
import { useSelectFromEditor } from "../../../hooks/useSelectFromEditor.js";
|
|
4
|
+
import { InlineSvg } from "./InlineSvg.js";
|
|
5
|
+
const useComponent = (name)=>useSelectFromEditor((state)=>state.components?.[name]);
|
|
6
|
+
const ListItem = ({ item })=>{
|
|
7
|
+
const component = useComponent(item.name);
|
|
8
|
+
if (!component) return /*#__PURE__*/ react.createElement(react.Fragment, null);
|
|
9
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
10
|
+
className: "flex flex-row items-center p-sm bg-neutral-light rounded-lg gap-sm cursor-grab fill-neutral-strong"
|
|
11
|
+
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
12
|
+
label: "Icon",
|
|
13
|
+
icon: /*#__PURE__*/ react.createElement(InlineSvg, {
|
|
14
|
+
src: component.image
|
|
15
|
+
}),
|
|
16
|
+
size: "md"
|
|
17
|
+
}), /*#__PURE__*/ react.createElement("div", {
|
|
18
|
+
className: "text-sm font-medium text-neutral-primary"
|
|
19
|
+
}, component.label ?? component.name));
|
|
20
|
+
};
|
|
21
|
+
export { ListItem };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=ListItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/InsertElements/ListItem.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/InsertElements/ListItem.tsx"],"sourcesContent":["import React from \"react\";\nimport { Icon } from \"@webiny/admin-ui\";\nimport type { ComponentGroupItem, ComponentManifest } from \"@webiny/website-builder-sdk\";\nimport { useSelectFromEditor } from \"~/BaseEditor/hooks/useSelectFromEditor.js\";\nimport { InlineSvg } from \"./InlineSvg.js\";\n\nconst useComponent = (name: string) => {\n return useSelectFromEditor<ComponentManifest | undefined>(state => state.components?.[name]);\n};\n\nexport const ListItem = ({ item }: { item: ComponentGroupItem }) => {\n const component = useComponent(item.name);\n if (!component) {\n return <></>;\n }\n\n return (\n <div className=\"flex flex-row items-center p-sm bg-neutral-light rounded-lg gap-sm cursor-grab fill-neutral-strong\">\n <Icon label=\"Icon\" icon={<InlineSvg src={component.image!} />} size={\"md\"} />\n <div className=\"text-sm font-medium text-neutral-primary\">\n {component.label ?? component.name}\n </div>\n </div>\n );\n};\n"],"names":["useComponent","name","useSelectFromEditor","state","ListItem","item","component","Icon","InlineSvg"],"mappings":";;;;AAMA,MAAMA,eAAe,CAACC,OACXC,oBAAmDC,CAAAA,QAASA,MAAM,UAAU,EAAE,CAACF,KAAK;AAGxF,MAAMG,WAAW,CAAC,EAAEC,IAAI,EAAgC;IAC3D,MAAMC,YAAYN,aAAaK,KAAK,IAAI;IACxC,IAAI,CAACC,WACD,OAAO,WAAP,GAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,MAAIA;QAAC,OAAM;QAAO,oBAAM,oBAACC,WAASA;YAAC,KAAKF,UAAU,KAAK;;QAAO,MAAM;sBACrE,oBAAC;QAAI,WAAU;OACVA,UAAU,KAAK,IAAIA,UAAU,IAAI;AAIlD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { Tooltip, Tree } from "@webiny/admin-ui";
|
|
3
|
+
import { ReactComponent } from "@webiny/icons/visibility_off.svg";
|
|
4
|
+
import { useStyles } from "../../../hooks/useStyles.js";
|
|
5
|
+
const ElementActions = ({ elementId })=>{
|
|
6
|
+
const { styles, onChange } = useStyles(elementId);
|
|
7
|
+
const isVisible = "none" !== styles.display;
|
|
8
|
+
const unhideElement = ()=>{
|
|
9
|
+
onChange(({ styles })=>{
|
|
10
|
+
styles.set("display", "flex");
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
if (isVisible) return null;
|
|
14
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
15
|
+
className: "flex"
|
|
16
|
+
}, /*#__PURE__*/ react.createElement(Tooltip, {
|
|
17
|
+
trigger: /*#__PURE__*/ react.createElement(Tree.Item.Icon, {
|
|
18
|
+
size: "sm",
|
|
19
|
+
className: "cursor-pointer",
|
|
20
|
+
element: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
21
|
+
label: "This element is hidden.",
|
|
22
|
+
onClick: unhideElement
|
|
23
|
+
}),
|
|
24
|
+
content: "This element is hidden. Click to unhide."
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
export { ElementActions };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=ElementActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEditor/defaultConfig/Toolbar/Navigator/ElementActions.js","sources":["../../../../../src/BaseEditor/defaultConfig/Toolbar/Navigator/ElementActions.tsx"],"sourcesContent":["import React from \"react\";\nimport { Tooltip, Tree } from \"@webiny/admin-ui\";\nimport { ReactComponent as VisibilityNone } from \"@webiny/icons/visibility_off.svg\";\nimport { useStyles } from \"~/BaseEditor/hooks/useStyles.js\";\n\nexport const ElementActions = ({ elementId }: { elementId: string }) => {\n const { styles, onChange } = useStyles(elementId);\n const isVisible = styles.display !== \"none\";\n\n const unhideElement = () => {\n onChange(({ styles }) => {\n styles.set(\"display\", \"flex\");\n });\n };\n\n if (isVisible) {\n return null;\n }\n\n return (\n <div className={\"flex\"}>\n <Tooltip\n trigger={\n <Tree.Item.Icon\n size={\"sm\"}\n className={\"cursor-pointer\"}\n element={<VisibilityNone />}\n label={\"This element is hidden.\"}\n onClick={unhideElement}\n />\n }\n content={\"This element is hidden. Click to unhide.\"}\n />\n </div>\n );\n};\n"],"names":["ElementActions","elementId","styles","onChange","useStyles","isVisible","unhideElement","Tooltip","Tree","VisibilityNone"],"mappings":";;;;AAKO,MAAMA,iBAAiB,CAAC,EAAEC,SAAS,EAAyB;IAC/D,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,UAAUH;IACvC,MAAMI,YAAYH,AAAmB,WAAnBA,OAAO,OAAO;IAEhC,MAAMI,gBAAgB;QAClBH,SAAS,CAAC,EAAED,MAAM,EAAE;YAChBA,OAAO,GAAG,CAAC,WAAW;QAC1B;IACJ;IAEA,IAAIG,WACA,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACE,SAAOA;QACJ,uBACI,oBAACC,KAAK,IAAI,CAAC,IAAI;YACX,MAAM;YACN,WAAW;YACX,uBAAS,oBAACC,gBAAcA;YACxB,OAAO;YACP,SAASH;;QAGjB,SAAS;;AAIzB"}
|