@gravity-ui/page-constructor 5.14.4-alpha.0 → 5.14.4-alpha.2
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/README.md +31 -1
- package/build/cjs/blocks/CardLayout/index.d.ts +1 -1
- package/build/cjs/blocks/ContentLayout/index.d.ts +1 -1
- package/build/cjs/blocks/ExtendedFeatures/index.d.ts +1 -1
- package/build/cjs/blocks/FilterBlock/index.d.ts +1 -1
- package/build/cjs/blocks/Form/index.d.ts +1 -1
- package/build/cjs/blocks/Header/dynamic-form.d.ts +2 -2
- package/build/cjs/blocks/Header/index.d.ts +1 -1
- package/build/cjs/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/cjs/blocks/Icons/index.d.ts +1 -1
- package/build/cjs/blocks/Info/index.d.ts +1 -1
- package/build/cjs/blocks/Map/index.d.ts +1 -1
- package/build/cjs/blocks/Media/index.d.ts +1 -1
- package/build/cjs/blocks/PromoFeaturesBlock/index.d.ts +1 -1
- package/build/cjs/blocks/Questions/index.d.ts +1 -1
- package/build/cjs/blocks/Share/index.d.ts +1 -1
- package/build/cjs/blocks/Slider/dynamic-form.d.ts +3 -3
- package/build/cjs/blocks/Slider/index.d.ts +1 -1
- package/build/cjs/blocks/Table/index.d.ts +1 -1
- package/build/cjs/blocks/Tabs/index.d.ts +1 -1
- package/build/cjs/blocks/TestEditorBlock/form.d.ts +1 -1
- package/build/cjs/blocks/TestEditorBlock/index.d.ts +1 -1
- package/build/cjs/common/hooks/usePostMessage.d.ts +11 -0
- package/build/cjs/common/hooks/usePostMessage.js +94 -0
- package/build/{esm → cjs/common}/types/actions/initial.d.ts +1 -1
- package/build/{esm → cjs/common}/types/actions/other.d.ts +1 -1
- package/build/cjs/{types → common/types}/actions/reorder.d.ts +3 -1
- package/build/cjs/{types/index.d.ts → common/types/common.d.ts} +3 -3
- package/build/cjs/{types/dynamic-form.d.ts → common/types/forms.d.ts} +2 -1
- package/build/cjs/common/types/index.d.ts +4 -0
- package/build/cjs/common/types/index.js +7 -0
- package/build/cjs/{context/messagesContext/types.d.ts → common/types/messages.d.ts} +1 -1
- package/build/cjs/components/Image/dynamic-form.d.ts +1 -1
- package/build/cjs/constructor-items.d.ts +7 -1
- package/build/cjs/constructor-items.js +6 -0
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/hooks/useEditorBlockMouseEvents.js +1 -1
- package/build/cjs/context/editorContext/store.d.ts +1 -1
- package/build/cjs/context/editorContext/store.js +7 -7
- package/build/cjs/context/messagesContext/hooks/useMessageObserver.d.ts +1 -1
- package/build/cjs/context/messagesContext/hooks/useMessageSender.d.ts +1 -1
- package/build/cjs/context/messagesContext/messagesContext.d.ts +1 -2
- package/build/cjs/context/messagesContext/messagesProvider.js +7 -53
- package/build/cjs/context/messagesContext/store.d.ts +1 -2
- package/build/cjs/editor/data/templates/test-editor-block.json +18 -0
- package/build/cjs/editor-v2/components/BigOverlay/BigOverlay.css +33 -0
- package/build/cjs/editor-v2/components/BigOverlay/BigOverlay.d.ts +6 -0
- package/build/cjs/editor-v2/components/BigOverlay/BigOverlay.js +40 -0
- package/build/cjs/editor-v2/components/BlockConfig/BlockConfig.css +33 -0
- package/build/cjs/editor-v2/components/BlockConfig/BlockConfig.d.ts +6 -0
- package/build/cjs/editor-v2/components/BlockConfig/BlockConfig.js +35 -0
- package/build/cjs/editor-v2/components/BlocksList/BlocksList.css +42 -0
- package/build/cjs/editor-v2/components/BlocksList/BlocksList.d.ts +7 -0
- package/build/cjs/editor-v2/components/BlocksList/BlocksList.js +22 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.css +2 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js +118 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +61 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +32 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.css +38 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js +83 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +28 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js +14 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.js +17 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.css +5 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js +16 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +34 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js +16 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.js +14 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +14 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.js +22 -0
- package/build/cjs/editor-v2/components/GlobalConfig/GlobalConfig.css +22 -0
- package/build/cjs/editor-v2/components/GlobalConfig/GlobalConfig.d.ts +6 -0
- package/build/cjs/editor-v2/components/GlobalConfig/GlobalConfig.js +18 -0
- package/build/cjs/editor-v2/components/MiddleScreen/MiddleScreen.css +53 -0
- package/build/cjs/editor-v2/components/MiddleScreen/MiddleScreen.d.ts +6 -0
- package/build/cjs/editor-v2/components/MiddleScreen/MiddleScreen.js +34 -0
- package/build/cjs/editor-v2/components/Overlay/Overlay.css +56 -0
- package/build/cjs/editor-v2/components/Overlay/Overlay.d.ts +6 -0
- package/build/cjs/editor-v2/components/Overlay/Overlay.js +71 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.css +66 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.d.ts +7 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.js +68 -0
- package/build/cjs/editor-v2/components/Source/Source.css +21 -0
- package/build/cjs/editor-v2/components/Source/Source.d.ts +6 -0
- package/build/cjs/editor-v2/components/Source/Source.js +30 -0
- package/build/cjs/editor-v2/components/SourceCode/SourceCode.css +44 -0
- package/build/cjs/editor-v2/components/SourceCode/SourceCode.d.ts +6 -0
- package/build/cjs/editor-v2/components/SourceCode/SourceCode.js +55 -0
- package/build/cjs/editor-v2/components/TopBar/TopBar.css +34 -0
- package/build/cjs/editor-v2/components/TopBar/TopBar.d.ts +10 -0
- package/build/cjs/editor-v2/components/TopBar/TopBar.js +15 -0
- package/build/cjs/editor-v2/components/Tree/Tree.css +148 -0
- package/build/cjs/editor-v2/components/Tree/Tree.d.ts +7 -0
- package/build/cjs/editor-v2/components/Tree/Tree.js +32 -0
- package/build/cjs/editor-v2/components/ViewSwitches/ViewSwitches.css +23 -0
- package/build/cjs/editor-v2/components/ViewSwitches/ViewSwitches.d.ts +10 -0
- package/build/cjs/editor-v2/components/ViewSwitches/ViewSwitches.js +22 -0
- package/build/cjs/editor-v2/constants.d.ts +1 -0
- package/build/cjs/editor-v2/constants.js +4 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.css +54 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.d.ts +9 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.js +66 -0
- package/build/cjs/editor-v2/containers/Editor/hooks/useAdminInitialize.d.ts +2 -0
- package/build/cjs/editor-v2/containers/Editor/hooks/useAdminInitialize.js +25 -0
- package/build/cjs/editor-v2/context/contentConfig/contentConfigContext.d.ts +10 -0
- package/build/cjs/editor-v2/context/contentConfig/contentConfigContext.js +9 -0
- package/build/cjs/editor-v2/context/contentConfig/contentConfigProvider.d.ts +8 -0
- package/build/cjs/editor-v2/context/contentConfig/contentConfigProvider.js +19 -0
- package/build/cjs/editor-v2/context/contentConfig/hooks/useContentConfigStore.d.ts +2 -0
- package/build/cjs/editor-v2/context/contentConfig/hooks/useContentConfigStore.js +15 -0
- package/build/cjs/editor-v2/context/contentConfig/index.d.ts +4 -0
- package/build/cjs/editor-v2/context/contentConfig/index.js +7 -0
- package/build/cjs/editor-v2/context/contentConfig/store.d.ts +35 -0
- package/build/cjs/editor-v2/context/contentConfig/store.js +106 -0
- package/build/cjs/editor-v2/context/editorContext/editorContext.d.ts +11 -0
- package/build/cjs/editor-v2/context/editorContext/editorContext.js +10 -0
- package/build/cjs/editor-v2/context/editorContext/editorProvider.d.ts +2 -0
- package/build/cjs/editor-v2/context/editorContext/editorProvider.js +15 -0
- package/build/cjs/editor-v2/context/editorContext/hooks/useEditorStore.d.ts +2 -0
- package/build/cjs/editor-v2/context/editorContext/hooks/useEditorStore.js +15 -0
- package/build/cjs/editor-v2/context/editorContext/index.d.ts +4 -0
- package/build/cjs/editor-v2/context/editorContext/index.js +7 -0
- package/build/cjs/editor-v2/context/editorContext/store.d.ts +26 -0
- package/build/cjs/editor-v2/context/editorContext/store.js +55 -0
- package/build/cjs/editor-v2/context/iframeContext/hooks/useIframeStore.d.ts +2 -0
- package/build/cjs/editor-v2/context/iframeContext/hooks/useIframeStore.js +15 -0
- package/build/cjs/editor-v2/context/iframeContext/iframeContext.d.ts +13 -0
- package/build/cjs/editor-v2/context/iframeContext/iframeContext.js +9 -0
- package/build/cjs/editor-v2/context/iframeContext/iframeProvider.d.ts +7 -0
- package/build/cjs/editor-v2/context/iframeContext/iframeProvider.js +23 -0
- package/build/cjs/editor-v2/context/iframeContext/index.d.ts +4 -0
- package/build/cjs/editor-v2/context/iframeContext/index.js +7 -0
- package/build/cjs/editor-v2/context/iframeContext/store.d.ts +26 -0
- package/build/cjs/editor-v2/context/iframeContext/store.js +45 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessageObserver.d.ts +4 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessageObserver.js +17 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessageSender.d.ts +2 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessageSender.js +11 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessagesStore.d.ts +2 -0
- package/build/cjs/editor-v2/context/messagesContext/hooks/useMessagesStore.js +15 -0
- package/build/cjs/editor-v2/context/messagesContext/index.d.ts +5 -0
- package/build/cjs/editor-v2/context/messagesContext/index.js +8 -0
- package/build/cjs/editor-v2/context/messagesContext/messagesContext.d.ts +13 -0
- package/build/cjs/editor-v2/context/messagesContext/messagesContext.js +12 -0
- package/build/cjs/editor-v2/context/messagesContext/messagesProvider.d.ts +2 -0
- package/build/cjs/editor-v2/context/messagesContext/messagesProvider.js +35 -0
- package/build/cjs/editor-v2/context/messagesContext/store.d.ts +22 -0
- package/build/cjs/editor-v2/context/messagesContext/store.js +17 -0
- package/build/cjs/editor-v2/icons/Tablet.d.ts +2 -0
- package/build/cjs/editor-v2/icons/Tablet.js +9 -0
- package/build/cjs/editor-v2/index.d.ts +2 -0
- package/build/cjs/editor-v2/index.js +7 -0
- package/build/cjs/editor-v2/styles/mixins.css +0 -0
- package/build/cjs/editor-v2/styles/root.css +9 -0
- package/build/cjs/editor-v2/styles/variables.css +0 -0
- package/build/cjs/editor-v2/utils/code.d.ts +6 -0
- package/build/cjs/editor-v2/utils/code.js +11 -0
- package/build/cjs/editor-v2/utils/index.d.ts +17 -0
- package/build/cjs/editor-v2/utils/index.js +151 -0
- package/build/cjs/editor-v2/utils/store.d.ts +14 -0
- package/build/cjs/editor-v2/utils/store.js +9 -0
- package/build/cjs/hooks/useEditorInitialize.js +9 -9
- package/build/cjs/sub-blocks/BackgroundCard/dynamic-form.d.ts +2 -2
- package/build/cjs/sub-blocks/LayoutItem/form.d.ts +1 -1
- package/build/cjs/utils/form-generator.d.ts +1 -1
- package/build/esm/blocks/CardLayout/index.d.ts +1 -1
- package/build/esm/blocks/ContentLayout/index.d.ts +1 -1
- package/build/esm/blocks/ExtendedFeatures/index.d.ts +1 -1
- package/build/esm/blocks/FilterBlock/index.d.ts +1 -1
- package/build/esm/blocks/Form/index.d.ts +1 -1
- package/build/esm/blocks/Header/dynamic-form.d.ts +2 -2
- package/build/esm/blocks/Header/index.d.ts +1 -1
- package/build/esm/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/esm/blocks/Icons/index.d.ts +1 -1
- package/build/esm/blocks/Info/index.d.ts +1 -1
- package/build/esm/blocks/Map/index.d.ts +1 -1
- package/build/esm/blocks/Media/index.d.ts +1 -1
- package/build/esm/blocks/PromoFeaturesBlock/index.d.ts +1 -1
- package/build/esm/blocks/Questions/index.d.ts +1 -1
- package/build/esm/blocks/Share/index.d.ts +1 -1
- package/build/esm/blocks/Slider/dynamic-form.d.ts +3 -3
- package/build/esm/blocks/Slider/index.d.ts +1 -1
- package/build/esm/blocks/Table/index.d.ts +1 -1
- package/build/esm/blocks/Tabs/index.d.ts +1 -1
- package/build/esm/blocks/TestEditorBlock/form.d.ts +1 -1
- package/build/esm/blocks/TestEditorBlock/index.d.ts +1 -1
- package/build/esm/common/hooks/usePostMessage.d.ts +11 -0
- package/build/esm/common/hooks/usePostMessage.js +90 -0
- package/build/{cjs → esm/common}/types/actions/initial.d.ts +1 -1
- package/build/{cjs → esm/common}/types/actions/other.d.ts +1 -1
- package/build/esm/{types → common/types}/actions/reorder.d.ts +3 -1
- package/build/esm/{types/index.d.ts → common/types/common.d.ts} +3 -3
- package/build/esm/{types/dynamic-form.d.ts → common/types/forms.d.ts} +2 -1
- package/build/esm/common/types/index.d.ts +4 -0
- package/build/esm/common/types/index.js +4 -0
- package/build/esm/{context/messagesContext/types.d.ts → common/types/messages.d.ts} +1 -1
- package/build/esm/components/Image/dynamic-form.d.ts +1 -1
- package/build/esm/constructor-items.d.ts +7 -1
- package/build/esm/constructor-items.js +6 -0
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/hooks/useEditorBlockMouseEvents.js +1 -1
- package/build/esm/context/editorContext/store.d.ts +1 -1
- package/build/esm/context/editorContext/store.js +1 -1
- package/build/esm/context/messagesContext/hooks/useMessageObserver.d.ts +1 -1
- package/build/esm/context/messagesContext/hooks/useMessageSender.d.ts +1 -1
- package/build/esm/context/messagesContext/messagesContext.d.ts +1 -2
- package/build/esm/context/messagesContext/messagesProvider.js +8 -54
- package/build/esm/context/messagesContext/store.d.ts +1 -2
- package/build/esm/editor/data/templates/test-editor-block.json +18 -0
- package/build/esm/editor-v2/components/BigOverlay/BigOverlay.css +33 -0
- package/build/esm/editor-v2/components/BigOverlay/BigOverlay.d.ts +7 -0
- package/build/esm/editor-v2/components/BigOverlay/BigOverlay.js +38 -0
- package/build/esm/editor-v2/components/BlockConfig/BlockConfig.css +33 -0
- package/build/esm/editor-v2/components/BlockConfig/BlockConfig.d.ts +7 -0
- package/build/esm/editor-v2/components/BlockConfig/BlockConfig.js +33 -0
- package/build/esm/editor-v2/components/BlocksList/BlocksList.css +42 -0
- package/build/esm/editor-v2/components/BlocksList/BlocksList.d.ts +8 -0
- package/build/esm/editor-v2/components/BlocksList/BlocksList.js +20 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.css +2 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js +116 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +61 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +13 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +30 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.css +38 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +14 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js +81 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +11 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +25 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.d.ts +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js +11 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.js +14 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.css +5 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +13 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js +14 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +32 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.js +13 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.js +11 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +11 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.js +16 -0
- package/build/esm/editor-v2/components/GlobalConfig/GlobalConfig.css +22 -0
- package/build/esm/editor-v2/components/GlobalConfig/GlobalConfig.d.ts +7 -0
- package/build/esm/editor-v2/components/GlobalConfig/GlobalConfig.js +16 -0
- package/build/esm/editor-v2/components/MiddleScreen/MiddleScreen.css +53 -0
- package/build/esm/editor-v2/components/MiddleScreen/MiddleScreen.d.ts +7 -0
- package/build/esm/editor-v2/components/MiddleScreen/MiddleScreen.js +32 -0
- package/build/esm/editor-v2/components/Overlay/Overlay.css +56 -0
- package/build/esm/editor-v2/components/Overlay/Overlay.d.ts +7 -0
- package/build/esm/editor-v2/components/Overlay/Overlay.js +69 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.css +66 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.d.ts +8 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.js +64 -0
- package/build/esm/editor-v2/components/Source/Source.css +21 -0
- package/build/esm/editor-v2/components/Source/Source.d.ts +7 -0
- package/build/esm/editor-v2/components/Source/Source.js +28 -0
- package/build/esm/editor-v2/components/SourceCode/SourceCode.css +44 -0
- package/build/esm/editor-v2/components/SourceCode/SourceCode.d.ts +7 -0
- package/build/esm/editor-v2/components/SourceCode/SourceCode.js +53 -0
- package/build/esm/editor-v2/components/TopBar/TopBar.css +34 -0
- package/build/esm/editor-v2/components/TopBar/TopBar.d.ts +11 -0
- package/build/esm/editor-v2/components/TopBar/TopBar.js +13 -0
- package/build/esm/editor-v2/components/Tree/Tree.css +148 -0
- package/build/esm/editor-v2/components/Tree/Tree.d.ts +8 -0
- package/build/esm/editor-v2/components/Tree/Tree.js +30 -0
- package/build/esm/editor-v2/components/ViewSwitches/ViewSwitches.css +23 -0
- package/build/esm/editor-v2/components/ViewSwitches/ViewSwitches.d.ts +11 -0
- package/build/esm/editor-v2/components/ViewSwitches/ViewSwitches.js +20 -0
- package/build/esm/editor-v2/constants.d.ts +1 -0
- package/build/esm/editor-v2/constants.js +1 -0
- package/build/esm/editor-v2/containers/Editor/Editor.css +54 -0
- package/build/esm/editor-v2/containers/Editor/Editor.d.ts +10 -0
- package/build/esm/editor-v2/containers/Editor/Editor.js +62 -0
- package/build/esm/editor-v2/containers/Editor/hooks/useAdminInitialize.d.ts +2 -0
- package/build/esm/editor-v2/containers/Editor/hooks/useAdminInitialize.js +23 -0
- package/build/esm/editor-v2/context/contentConfig/contentConfigContext.d.ts +10 -0
- package/build/esm/editor-v2/context/contentConfig/contentConfigContext.js +5 -0
- package/build/esm/editor-v2/context/contentConfig/contentConfigProvider.d.ts +8 -0
- package/build/esm/editor-v2/context/contentConfig/contentConfigProvider.js +14 -0
- package/build/esm/editor-v2/context/contentConfig/hooks/useContentConfigStore.d.ts +2 -0
- package/build/esm/editor-v2/context/contentConfig/hooks/useContentConfigStore.js +11 -0
- package/build/esm/editor-v2/context/contentConfig/index.d.ts +4 -0
- package/build/esm/editor-v2/context/contentConfig/index.js +4 -0
- package/build/esm/editor-v2/context/contentConfig/store.d.ts +35 -0
- package/build/esm/editor-v2/context/contentConfig/store.js +102 -0
- package/build/esm/editor-v2/context/editorContext/editorContext.d.ts +11 -0
- package/build/esm/editor-v2/context/editorContext/editorContext.js +6 -0
- package/build/esm/editor-v2/context/editorContext/editorProvider.d.ts +2 -0
- package/build/esm/editor-v2/context/editorContext/editorProvider.js +10 -0
- package/build/esm/editor-v2/context/editorContext/hooks/useEditorStore.d.ts +2 -0
- package/build/esm/editor-v2/context/editorContext/hooks/useEditorStore.js +11 -0
- package/build/esm/editor-v2/context/editorContext/index.d.ts +4 -0
- package/build/esm/editor-v2/context/editorContext/index.js +4 -0
- package/build/esm/editor-v2/context/editorContext/store.d.ts +26 -0
- package/build/esm/editor-v2/context/editorContext/store.js +52 -0
- package/build/esm/editor-v2/context/iframeContext/hooks/useIframeStore.d.ts +2 -0
- package/build/esm/editor-v2/context/iframeContext/hooks/useIframeStore.js +11 -0
- package/build/esm/editor-v2/context/iframeContext/iframeContext.d.ts +13 -0
- package/build/esm/editor-v2/context/iframeContext/iframeContext.js +5 -0
- package/build/esm/editor-v2/context/iframeContext/iframeProvider.d.ts +7 -0
- package/build/esm/editor-v2/context/iframeContext/iframeProvider.js +18 -0
- package/build/esm/editor-v2/context/iframeContext/index.d.ts +4 -0
- package/build/esm/editor-v2/context/iframeContext/index.js +4 -0
- package/build/esm/editor-v2/context/iframeContext/store.d.ts +26 -0
- package/build/esm/editor-v2/context/iframeContext/store.js +42 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessageObserver.d.ts +4 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessageObserver.js +12 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessageSender.d.ts +2 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessageSender.js +7 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessagesStore.d.ts +2 -0
- package/build/esm/editor-v2/context/messagesContext/hooks/useMessagesStore.js +11 -0
- package/build/esm/editor-v2/context/messagesContext/index.d.ts +5 -0
- package/build/esm/editor-v2/context/messagesContext/index.js +5 -0
- package/build/esm/editor-v2/context/messagesContext/messagesContext.d.ts +13 -0
- package/build/esm/editor-v2/context/messagesContext/messagesContext.js +8 -0
- package/build/esm/editor-v2/context/messagesContext/messagesProvider.d.ts +2 -0
- package/build/esm/editor-v2/context/messagesContext/messagesProvider.js +30 -0
- package/build/esm/editor-v2/context/messagesContext/store.d.ts +22 -0
- package/build/esm/editor-v2/context/messagesContext/store.js +14 -0
- package/build/esm/editor-v2/icons/Tablet.d.ts +2 -0
- package/build/esm/editor-v2/icons/Tablet.js +4 -0
- package/build/esm/editor-v2/index.d.ts +2 -0
- package/build/esm/editor-v2/index.js +2 -0
- package/build/esm/editor-v2/styles/mixins.css +0 -0
- package/build/esm/editor-v2/styles/root.css +9 -0
- package/build/esm/editor-v2/styles/variables.css +0 -0
- package/build/esm/editor-v2/utils/code.d.ts +6 -0
- package/build/esm/editor-v2/utils/code.js +6 -0
- package/build/esm/editor-v2/utils/index.d.ts +17 -0
- package/build/esm/editor-v2/utils/index.js +134 -0
- package/build/esm/editor-v2/utils/store.d.ts +14 -0
- package/build/esm/editor-v2/utils/store.js +5 -0
- package/build/esm/hooks/useEditorInitialize.js +1 -1
- package/build/esm/sub-blocks/BackgroundCard/dynamic-form.d.ts +2 -2
- package/build/esm/sub-blocks/LayoutItem/form.d.ts +1 -1
- package/build/esm/utils/form-generator.d.ts +1 -1
- package/package.json +12 -3
- package/widget/index.js +1 -1
- package/build/cjs/{types → common/types}/actions/codes.d.ts +0 -0
- package/build/cjs/{types → common/types}/actions/codes.js +0 -0
- package/build/cjs/{types → common/types}/actions/index.d.ts +1 -1
- package/build/cjs/{types → common/types}/actions/index.js +1 -1
- package/build/cjs/{types → common/types}/actions/initial.js +0 -0
- package/build/cjs/{types → common/types}/actions/insert.d.ts +0 -0
- package/build/cjs/{types → common/types}/actions/insert.js +0 -0
- package/build/cjs/{types → common/types}/actions/other.js +0 -0
- package/build/cjs/{types → common/types}/actions/overlay.d.ts +0 -0
- package/build/cjs/{types → common/types}/actions/overlay.js +0 -0
- package/build/cjs/{types → common/types}/actions/reorder.js +0 -0
- package/build/cjs/{types → common/types}/actions/select.d.ts +0 -0
- package/build/cjs/{types → common/types}/actions/select.js +0 -0
- package/build/cjs/{context/messagesContext/types.js → common/types/common.js} +0 -0
- package/build/cjs/{types/dynamic-form.js → common/types/forms.js} +0 -0
- package/build/cjs/{types/index.js → common/types/messages.js} +0 -0
- package/build/esm/{types → common/types}/actions/codes.d.ts +0 -0
- package/build/esm/{types → common/types}/actions/codes.js +0 -0
- package/build/esm/{types → common/types}/actions/index.d.ts +1 -1
- package/build/esm/{types → common/types}/actions/index.js +1 -1
- /package/build/esm/{types → common/types}/actions/initial.js +0 -0
- /package/build/esm/{types → common/types}/actions/insert.d.ts +0 -0
- /package/build/esm/{types → common/types}/actions/insert.js +0 -0
- /package/build/esm/{types → common/types}/actions/other.js +0 -0
- /package/build/esm/{types → common/types}/actions/overlay.d.ts +0 -0
- /package/build/esm/{types → common/types}/actions/overlay.js +0 -0
- /package/build/esm/{types → common/types}/actions/reorder.js +0 -0
- /package/build/esm/{types → common/types}/actions/select.d.ts +0 -0
- /package/build/esm/{types → common/types}/actions/select.js +0 -0
- /package/build/esm/{context/messagesContext/types.js → common/types/common.js} +0 -0
- /package/build/esm/{types/dynamic-form.js → common/types/forms.js} +0 -0
- /package/build/esm/{types/index.js → common/types/messages.js} +0 -0
|
@@ -1,66 +1,20 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { usePostMessage } from '../../common/hooks/usePostMessage';
|
|
2
3
|
import { useEditorStore } from '../editorContext';
|
|
3
4
|
import { PostMessageContext } from './messagesContext';
|
|
4
5
|
import { createMessagesStore } from './store';
|
|
5
|
-
const DEBUG_MODE = false;
|
|
6
6
|
export const PostMessageProvider = ({ children }) => {
|
|
7
|
+
var _a;
|
|
7
8
|
const storeRef = useRef();
|
|
8
9
|
if (!storeRef.current) {
|
|
9
10
|
storeRef.current = createMessagesStore();
|
|
10
11
|
}
|
|
11
12
|
const editorStore = useEditorStore();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const storesWithReducer = [editorStore];
|
|
18
|
-
const { type, payload } = action;
|
|
19
|
-
const store = storeRef.current;
|
|
20
|
-
if (!type) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (store) {
|
|
24
|
-
const { subscribers } = store.getState();
|
|
25
|
-
const foundedSubscribers = subscribers.filter((subscriber) => subscriber.action === type);
|
|
26
|
-
for (const storeWithReducer of storesWithReducer) {
|
|
27
|
-
storeWithReducer.reducer(action, meta);
|
|
28
|
-
}
|
|
29
|
-
if (foundedSubscribers.length) {
|
|
30
|
-
for (const subscriber of foundedSubscribers) {
|
|
31
|
-
subscriber.handler(payload, meta);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [editorStore]);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const onMessage = (e) => {
|
|
38
|
-
const { action, debug } = e.data;
|
|
39
|
-
if (action && action.type) {
|
|
40
|
-
if (debug) {
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
|
-
console.log(`🔵 ➡️ Editor ${action.type}`, action.payload);
|
|
43
|
-
}
|
|
44
|
-
notifySubscribers(action, 'editor');
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
window.addEventListener('message', onMessage);
|
|
48
|
-
return () => {
|
|
49
|
-
window.removeEventListener('message', onMessage);
|
|
50
|
-
};
|
|
51
|
-
}, [notifySubscribers]);
|
|
52
|
-
const sendMessage = useCallback((action, { debug = DEBUG_MODE, direction = 'both' } = {}) => {
|
|
53
|
-
if (debug) {
|
|
54
|
-
// eslint-disable-next-line no-console
|
|
55
|
-
console.log(`🟢 Website ➡️ ${action.type}`, action.payload);
|
|
56
|
-
}
|
|
57
|
-
if (direction === 'both' || direction === 'editor') {
|
|
58
|
-
sendPostMessage({ action, debug });
|
|
59
|
-
}
|
|
60
|
-
if (direction === 'both' || direction === 'pc') {
|
|
61
|
-
notifySubscribers(action, 'pc');
|
|
62
|
-
}
|
|
63
|
-
}, [notifySubscribers, sendPostMessage]);
|
|
13
|
+
const storesWithReducer = [editorStore];
|
|
14
|
+
const { sendMessage } = usePostMessage({
|
|
15
|
+
subscribers: (_a = storeRef.current) === null || _a === void 0 ? void 0 : _a.getState().subscribers,
|
|
16
|
+
storesWithReducer,
|
|
17
|
+
});
|
|
64
18
|
return (React.createElement(PostMessageContext.Provider, { value: {
|
|
65
19
|
state: storeRef.current,
|
|
66
20
|
sendMessage: sendMessage,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"template": {
|
|
3
|
+
"type": "test-editor-block",
|
|
4
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
5
|
+
"table": {
|
|
6
|
+
"content": [
|
|
7
|
+
["Lorem", "ipsum 1", "dolor 2", "sit 3"],
|
|
8
|
+
["Lorem 1", "0", "0", "0"],
|
|
9
|
+
["Lorem 2", "0", "0", "1"],
|
|
10
|
+
["Lorem 3", "0", "0", "1"],
|
|
11
|
+
["Lorem 4", "0", "1", "1"],
|
|
12
|
+
["Lorem 5", "1", "1", "1"]
|
|
13
|
+
],
|
|
14
|
+
"legend": ["ipsum 1", "ipsum 2"],
|
|
15
|
+
"justify": ["start", "center", "center", "center"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
body {
|
|
4
|
+
--pc-editor-header-height: 48px;
|
|
5
|
+
--pc-editor-code-header-height: 36px;
|
|
6
|
+
--pc-editor-divider-width: 12px;
|
|
7
|
+
--pc-editor-left-column-width: calc(400px + var(--pc-editor-divider-width));
|
|
8
|
+
--pc-editor-base-color: var(--g-color-base-brand);
|
|
9
|
+
--pc-editor-control-color: var(--g-color-base-brand);
|
|
10
|
+
--pc-editor-control-icon-color: var(--g-color-text-dark-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pc-big-overlay {
|
|
14
|
+
position: absolute;
|
|
15
|
+
left: 0;
|
|
16
|
+
top: 0;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
}
|
|
21
|
+
.pc-big-overlay__border {
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
position: absolute;
|
|
24
|
+
width: 40px;
|
|
25
|
+
height: 40px;
|
|
26
|
+
margin-left: -20px;
|
|
27
|
+
margin-top: -20px;
|
|
28
|
+
background-color: var(--g-color-base-brand);
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
border-radius: 10px;
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useContext, useState } from 'react';
|
|
2
|
+
import { Stop } from '@gravity-ui/icons';
|
|
3
|
+
import { ActionTypes, } from '../../../common/types';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import { IframeContext, useIframeStore } from '../../context/iframeContext';
|
|
6
|
+
import { useMessageObserver } from '../../context/messagesContext';
|
|
7
|
+
import './BigOverlay.css';
|
|
8
|
+
const b = block('big-overlay');
|
|
9
|
+
const BigOverlay = ({ className }) => {
|
|
10
|
+
const { zoom } = useIframeStore();
|
|
11
|
+
const { iframeElement } = useContext(IframeContext);
|
|
12
|
+
const [mousePosition, setMousePosition] = useState(undefined);
|
|
13
|
+
useMessageObserver(ActionTypes.OverlayModeOnMove, (payload, meta) => {
|
|
14
|
+
if (payload && payload.cursor) {
|
|
15
|
+
const { x, y } = payload.cursor;
|
|
16
|
+
const iframeRect = iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.getClientRects().item(0);
|
|
17
|
+
if (iframeRect) {
|
|
18
|
+
const zoomedX = (x * zoom) / 100;
|
|
19
|
+
const zoomedY = (y * zoom) / 100;
|
|
20
|
+
const newX = meta.source === 'editor' ? x : zoomedX + iframeRect.x;
|
|
21
|
+
const newY = meta.source === 'editor' ? y : zoomedY + iframeRect.y;
|
|
22
|
+
setMousePosition({ x: newX, y: newY });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, [iframeElement, zoom]);
|
|
26
|
+
useMessageObserver(ActionTypes.InsertModeDisable, () => {
|
|
27
|
+
setMousePosition(undefined);
|
|
28
|
+
});
|
|
29
|
+
useMessageObserver(ActionTypes.ReorderModeDisable, () => {
|
|
30
|
+
setMousePosition(undefined);
|
|
31
|
+
});
|
|
32
|
+
return (React.createElement("div", { className: b(null, className) }, mousePosition ? (React.createElement("div", { className: b('border'), style: {
|
|
33
|
+
top: mousePosition.y,
|
|
34
|
+
left: mousePosition.x,
|
|
35
|
+
} },
|
|
36
|
+
React.createElement(Stop, { height: 20, width: 20 }))) : null));
|
|
37
|
+
};
|
|
38
|
+
export default BigOverlay;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
body {
|
|
4
|
+
--pc-editor-header-height: 48px;
|
|
5
|
+
--pc-editor-code-header-height: 36px;
|
|
6
|
+
--pc-editor-divider-width: 12px;
|
|
7
|
+
--pc-editor-left-column-width: calc(400px + var(--pc-editor-divider-width));
|
|
8
|
+
--pc-editor-base-color: var(--g-color-base-brand);
|
|
9
|
+
--pc-editor-control-color: var(--g-color-base-brand);
|
|
10
|
+
--pc-editor-control-icon-color: var(--g-color-text-dark-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pc-block-config {
|
|
14
|
+
padding: 12px;
|
|
15
|
+
}
|
|
16
|
+
.pc-block-config__title {
|
|
17
|
+
margin-bottom: 16px;
|
|
18
|
+
margin-top: 8px;
|
|
19
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
20
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
21
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
22
|
+
}
|
|
23
|
+
.pc-block-config__empty {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
align-items: center;
|
|
27
|
+
text-align: center;
|
|
28
|
+
height: 100%;
|
|
29
|
+
width: 100%;
|
|
30
|
+
font-size: var(--g-text-body-2-font-size);
|
|
31
|
+
line-height: var(--g-text-body-2-line-height);
|
|
32
|
+
font-weight: var(--g-text-body-font-weight);
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { block } from '../../../utils';
|
|
4
|
+
import { useContentConfigStore } from '../../context/contentConfig';
|
|
5
|
+
import { useEditorStore } from '../../context/editorContext';
|
|
6
|
+
import { generateChildrenPathFromArray } from '../../utils';
|
|
7
|
+
import DynamicForm from '../DynamicForm/DynamicForm';
|
|
8
|
+
import './BlockConfig.css';
|
|
9
|
+
const b = block('block-config');
|
|
10
|
+
const BlockConfig = ({ className }) => {
|
|
11
|
+
const { selectedBlock } = useEditorStore();
|
|
12
|
+
const { config, blocks, subBlocks, updateField } = useContentConfigStore();
|
|
13
|
+
const currentBlockPath = (selectedBlock === null || selectedBlock === void 0 ? void 0 : selectedBlock.path)
|
|
14
|
+
? generateChildrenPathFromArray(selectedBlock === null || selectedBlock === void 0 ? void 0 : selectedBlock.path)
|
|
15
|
+
: '[]';
|
|
16
|
+
const currentConfig = _.get(config.blocks, currentBlockPath || '');
|
|
17
|
+
const currentSchema = [...blocks, ...subBlocks].find(({ type }) => type === (currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.type));
|
|
18
|
+
const onUpdate = (key, value) => {
|
|
19
|
+
updateField('blocks' + currentBlockPath + '.' + key, value);
|
|
20
|
+
};
|
|
21
|
+
if (!currentConfig) {
|
|
22
|
+
return React.createElement("div", { className: b('empty') }, "Select block for start");
|
|
23
|
+
}
|
|
24
|
+
if (!currentSchema) {
|
|
25
|
+
return React.createElement("div", { className: b('empty') },
|
|
26
|
+
"Not supported: ",
|
|
27
|
+
currentConfig.type);
|
|
28
|
+
}
|
|
29
|
+
return (React.createElement("div", { className: b(null, className) },
|
|
30
|
+
React.createElement("div", { className: b('title') }, currentSchema.schema.name),
|
|
31
|
+
React.createElement(DynamicForm, { contentConfig: currentConfig, blockConfig: currentSchema.schema.inputs, onUpdate: onUpdate })));
|
|
32
|
+
};
|
|
33
|
+
export default BlockConfig;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
body {
|
|
4
|
+
--pc-editor-header-height: 48px;
|
|
5
|
+
--pc-editor-code-header-height: 36px;
|
|
6
|
+
--pc-editor-divider-width: 12px;
|
|
7
|
+
--pc-editor-left-column-width: calc(400px + var(--pc-editor-divider-width));
|
|
8
|
+
--pc-editor-base-color: var(--g-color-base-brand);
|
|
9
|
+
--pc-editor-control-color: var(--g-color-base-brand);
|
|
10
|
+
--pc-editor-control-icon-color: var(--g-color-text-dark-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pc-blocks-list {
|
|
14
|
+
padding: 12px;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
.pc-blocks-list__card {
|
|
20
|
+
padding: 8px;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
user-select: none;
|
|
23
|
+
margin-bottom: 8px;
|
|
24
|
+
}
|
|
25
|
+
.pc-blocks-list__card:last-child {
|
|
26
|
+
margin-bottom: 0;
|
|
27
|
+
}
|
|
28
|
+
.pc-blocks-list__card:active {
|
|
29
|
+
background-color: var(--g-color-base-generic-hover);
|
|
30
|
+
}
|
|
31
|
+
.pc-blocks-list__title {
|
|
32
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
33
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
34
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
35
|
+
margin-bottom: 10px;
|
|
36
|
+
}
|
|
37
|
+
.pc-blocks-list__section {
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
}
|
|
40
|
+
.pc-blocks-list__section:last-child {
|
|
41
|
+
margin-bottom: 0;
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ItemConfig } from '../../../common/types';
|
|
3
|
+
import './BlocksList.css';
|
|
4
|
+
export interface BlocksListProps {
|
|
5
|
+
blocks: ItemConfig[];
|
|
6
|
+
}
|
|
7
|
+
declare const BlocksList: (_p: PropsWithChildren<BlocksListProps>) => JSX.Element;
|
|
8
|
+
export default BlocksList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Card } from '@gravity-ui/uikit';
|
|
3
|
+
import { ActionTypes } from '../../../common/types';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import { useContentConfigStore } from '../../context/contentConfig';
|
|
6
|
+
import { useMessageSender } from '../../context/messagesContext';
|
|
7
|
+
import './BlocksList.css';
|
|
8
|
+
const b = block('blocks-list');
|
|
9
|
+
const BlocksList = (_p) => {
|
|
10
|
+
const { blocks } = useContentConfigStore();
|
|
11
|
+
const sendMessage = useMessageSender();
|
|
12
|
+
const onMouseDown = useCallback((blockType) => {
|
|
13
|
+
sendMessage({ type: ActionTypes.InsertModeEnable, payload: { blockType } });
|
|
14
|
+
}, [sendMessage]);
|
|
15
|
+
return (React.createElement("div", { className: b() },
|
|
16
|
+
React.createElement("div", { className: b('section') },
|
|
17
|
+
React.createElement("div", { className: b('title') }, "Blocks"),
|
|
18
|
+
blocks.map(({ type, schema: { name } }) => (React.createElement(Card, { key: type, className: b('card'), onMouseDown: () => onMouseDown(type) }, name))))));
|
|
19
|
+
};
|
|
20
|
+
export default BlocksList;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConfigInput } from '../../../common/types';
|
|
3
|
+
import { ClassNameProps, PageContent } from '../../../models';
|
|
4
|
+
import './DynamicForm.css';
|
|
5
|
+
export type DynamicFormValue = string | number | [] | object | boolean | PageContent | undefined;
|
|
6
|
+
interface DynamicFormProps extends ClassNameProps {
|
|
7
|
+
blockConfig: Array<ConfigInput>;
|
|
8
|
+
contentConfig: PageContent;
|
|
9
|
+
onUpdate: (key: string, value: DynamicFormValue) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const DynamicForm: React.FC<DynamicFormProps>;
|
|
12
|
+
export default DynamicForm;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { block } from '../../../utils';
|
|
4
|
+
import ArrayDynamicField from './Fields/Array/Array';
|
|
5
|
+
import BooleanDynamicField from './Fields/Boolean/Boolean';
|
|
6
|
+
import NumberDynamicField from './Fields/Number/Number';
|
|
7
|
+
import ObjectDynamicField from './Fields/Object/Object';
|
|
8
|
+
import OneOfDynamicField from './Fields/OneOf/OneOf';
|
|
9
|
+
import SelectDynamicField from './Fields/Select/Select';
|
|
10
|
+
import TextDynamicField from './Fields/Text/Text';
|
|
11
|
+
import TextAreaDynamicField from './Fields/TextArea/TextArea';
|
|
12
|
+
import { getContent, getFullPath } from './utils';
|
|
13
|
+
import './DynamicForm.css';
|
|
14
|
+
const b = block('dynamic-form');
|
|
15
|
+
const DynamicForm = (props) => {
|
|
16
|
+
const { blockConfig, onUpdate, contentConfig } = props;
|
|
17
|
+
const inputs = blockConfig;
|
|
18
|
+
const getData = useCallback((variable) => {
|
|
19
|
+
if (variable.startsWith('block.')) {
|
|
20
|
+
const purePath = variable.replace('block.', '');
|
|
21
|
+
return _.get(contentConfig, purePath);
|
|
22
|
+
}
|
|
23
|
+
if ((variable.startsWith(`'`) && variable.endsWith(`'`)) ||
|
|
24
|
+
(variable.startsWith(`"`) && variable.endsWith(`"`))) {
|
|
25
|
+
// @ts-ignore TODO: replaceAll types
|
|
26
|
+
return variable.replaceAll(`'`, '').replaceAll(`"`, '');
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}, [contentConfig]);
|
|
30
|
+
const decide = useCallback((showIf) => {
|
|
31
|
+
const parts = showIf.split(' ');
|
|
32
|
+
if (!(parts.length === 3)) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log('Something bad happened in showIf, ignored');
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const [firstVariable, equals, secondVariable] = parts;
|
|
38
|
+
const data1 = getData(firstVariable);
|
|
39
|
+
const data2 = getData(secondVariable);
|
|
40
|
+
if (equals === '===') {
|
|
41
|
+
return data1 === data2;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return data1 !== data2;
|
|
45
|
+
}
|
|
46
|
+
}, [getData]);
|
|
47
|
+
const renderInput = useCallback((input) => {
|
|
48
|
+
const fieldPath = input.name;
|
|
49
|
+
const fieldValue = getContent(contentConfig, input.name);
|
|
50
|
+
if (input.showIf) {
|
|
51
|
+
const decision = decide(input.showIf);
|
|
52
|
+
if (!decision) {
|
|
53
|
+
return React.createElement("div", null,
|
|
54
|
+
"Hidden Field: ",
|
|
55
|
+
input.name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Text, Select, Boolean and etc
|
|
59
|
+
const onSimpleDynamicFieldUpdate = (value) => {
|
|
60
|
+
onUpdate(fieldPath, value);
|
|
61
|
+
};
|
|
62
|
+
// Array and Objects
|
|
63
|
+
const onComplexDynamicFieldUpdate = (key, value) => {
|
|
64
|
+
onUpdate(getFullPath(fieldPath, key), value);
|
|
65
|
+
};
|
|
66
|
+
switch (input.type) {
|
|
67
|
+
case 'text': {
|
|
68
|
+
return (React.createElement(TextDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
69
|
+
}
|
|
70
|
+
case 'boolean': {
|
|
71
|
+
return (React.createElement(BooleanDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
72
|
+
}
|
|
73
|
+
case 'textarea': {
|
|
74
|
+
return (React.createElement(TextAreaDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
75
|
+
}
|
|
76
|
+
case 'select': {
|
|
77
|
+
return (React.createElement(SelectDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), input: input, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
78
|
+
}
|
|
79
|
+
case 'number': {
|
|
80
|
+
return (React.createElement(NumberDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
81
|
+
}
|
|
82
|
+
case 'object': {
|
|
83
|
+
if (!input || !('properties' in input)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return (React.createElement(ObjectDynamicField, { onRefresh: (value) => onUpdate(fieldPath, value), blockConfig: input.properties, title: input.title, value: fieldValue, onUpdate: onComplexDynamicFieldUpdate }));
|
|
87
|
+
}
|
|
88
|
+
case 'array': {
|
|
89
|
+
return (React.createElement(ArrayDynamicField, { blockConfig: input, title: input.title, values: fieldValue, onUpdate: onComplexDynamicFieldUpdate }));
|
|
90
|
+
}
|
|
91
|
+
case 'oneOf': {
|
|
92
|
+
if (!input || !('options' in input)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return (React.createElement(OneOfDynamicField, { inputConfig: input, contentConfig: contentConfig, onUpdate: onComplexDynamicFieldUpdate }));
|
|
96
|
+
}
|
|
97
|
+
default: {
|
|
98
|
+
return React.createElement("div", null,
|
|
99
|
+
"Ignore ",
|
|
100
|
+
JSON.stringify(input));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}, [contentConfig, decide, onUpdate]);
|
|
104
|
+
const sortedInputs = inputs.sort((x, y) => {
|
|
105
|
+
const nestingFieldTypes = ['object', 'array', 'oneOf'];
|
|
106
|
+
if (nestingFieldTypes.includes(x.type)) {
|
|
107
|
+
return 1;
|
|
108
|
+
}
|
|
109
|
+
if (nestingFieldTypes.includes(y.type)) {
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
return 0;
|
|
113
|
+
});
|
|
114
|
+
return (React.createElement("div", { className: b() }, sortedInputs.map((input, index) => (React.createElement(React.Fragment, { key: index }, renderInput(input))))));
|
|
115
|
+
};
|
|
116
|
+
export default DynamicForm;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
body {
|
|
4
|
+
--pc-editor-header-height: 48px;
|
|
5
|
+
--pc-editor-code-header-height: 36px;
|
|
6
|
+
--pc-editor-divider-width: 12px;
|
|
7
|
+
--pc-editor-left-column-width: calc(400px + var(--pc-editor-divider-width));
|
|
8
|
+
--pc-editor-base-color: var(--g-color-base-brand);
|
|
9
|
+
--pc-editor-control-color: var(--g-color-base-brand);
|
|
10
|
+
--pc-editor-control-icon-color: var(--g-color-text-dark-primary);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pc-field-base {
|
|
14
|
+
position: relative;
|
|
15
|
+
margin-top: 20px;
|
|
16
|
+
}
|
|
17
|
+
.pc-field-base:hover > .pc-field-base__top > .pc-field-base__button {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
}
|
|
20
|
+
.pc-field-base__top {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 4px;
|
|
24
|
+
margin-bottom: 8px;
|
|
25
|
+
}
|
|
26
|
+
.pc-field-base__foldable {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
.pc-field-base__non-foldable:before {
|
|
32
|
+
position: absolute;
|
|
33
|
+
right: calc(100% + 5px);
|
|
34
|
+
}
|
|
35
|
+
.pc-field-base__button {
|
|
36
|
+
transition: opacity 0.3s ease;
|
|
37
|
+
opacity: 0;
|
|
38
|
+
}
|
|
39
|
+
.pc-field-base__title {
|
|
40
|
+
font-size: var(--g-text-body-2-font-size);
|
|
41
|
+
line-height: var(--g-text-body-2-line-height);
|
|
42
|
+
font-weight: var(--g-text-body-font-weight);
|
|
43
|
+
}
|
|
44
|
+
.pc-field-base__title_size_s {
|
|
45
|
+
font-size: var(--g-text-body-1-font-size);
|
|
46
|
+
line-height: var(--g-text-body-1-line-height);
|
|
47
|
+
font-weight: var(--g-text-body-font-weight);
|
|
48
|
+
}
|
|
49
|
+
.pc-field-base__title_size_m {
|
|
50
|
+
font-size: var(--g-text-body-2-font-size);
|
|
51
|
+
line-height: var(--g-text-body-2-line-height);
|
|
52
|
+
font-weight: var(--g-text-body-font-weight);
|
|
53
|
+
}
|
|
54
|
+
.pc-field-base__title_size_l {
|
|
55
|
+
font-size: var(--g-text-body-3-font-size);
|
|
56
|
+
line-height: var(--g-text-body-3-line-height);
|
|
57
|
+
font-weight: var(--g-text-body-font-weight);
|
|
58
|
+
}
|
|
59
|
+
.pc-field-base:first-child {
|
|
60
|
+
margin-top: 0;
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { ClassNameProps } from '../../../../models';
|
|
3
|
+
import './FieldBase.css';
|
|
4
|
+
export interface FieldBaseParams {
|
|
5
|
+
title?: string;
|
|
6
|
+
textSize?: 's' | 'm' | 'l';
|
|
7
|
+
onRefresh?: (value: undefined) => void;
|
|
8
|
+
expandable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface FieldBaseProps extends ClassNameProps, PropsWithChildren, FieldBaseParams {
|
|
11
|
+
}
|
|
12
|
+
declare const FieldBase: React.FC<FieldBaseProps>;
|
|
13
|
+
export default FieldBase;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ArrowRotateLeft } from '@gravity-ui/icons';
|
|
3
|
+
import { ArrowToggle, Button, Icon } from '@gravity-ui/uikit';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import { block } from '../../../../utils';
|
|
6
|
+
import './FieldBase.css';
|
|
7
|
+
const b = block('field-base');
|
|
8
|
+
const FieldBase = (props) => {
|
|
9
|
+
const { className, title, textSize, children, onRefresh, expandable = false } = props;
|
|
10
|
+
const [showChildren, setShowChildren] = useState(!expandable);
|
|
11
|
+
const titleComponent = React.useMemo(() => {
|
|
12
|
+
if (title) {
|
|
13
|
+
const defaultTitle = (React.createElement("div", { className: b('title', { size: textSize }) }, _.capitalize(title)));
|
|
14
|
+
if (expandable) {
|
|
15
|
+
return (React.createElement("div", { className: b('foldable'), onClick: () => setShowChildren(!showChildren) },
|
|
16
|
+
React.createElement(ArrowToggle, { direction: showChildren ? 'bottom' : 'right', className: b('arrow-toggle') }),
|
|
17
|
+
defaultTitle));
|
|
18
|
+
}
|
|
19
|
+
return React.createElement("div", { className: b('non-foldable') }, defaultTitle);
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}, [expandable, showChildren, textSize, title]);
|
|
23
|
+
return (React.createElement("div", { className: b(null, className) },
|
|
24
|
+
title && (React.createElement("div", { className: b('top') },
|
|
25
|
+
titleComponent,
|
|
26
|
+
onRefresh && (React.createElement(Button, { className: b('button'), onClick: () => onRefresh(undefined), view: 'flat', size: 'xs' },
|
|
27
|
+
React.createElement(Icon, { data: ArrowRotateLeft, size: 14 }))))),
|
|
28
|
+
(!title || showChildren) && React.createElement("div", { className: b('children') }, children)));
|
|
29
|
+
};
|
|
30
|
+
export default FieldBase;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-array-dynamic-field__card {
|
|
4
|
+
padding: 12px;
|
|
5
|
+
margin-top: 12px;
|
|
6
|
+
}
|
|
7
|
+
.pc-array-dynamic-field__card:first-child {
|
|
8
|
+
margin-bottom: 0;
|
|
9
|
+
}
|
|
10
|
+
.pc-array-dynamic-field__row {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
margin-top: 10px;
|
|
16
|
+
}
|
|
17
|
+
.pc-array-dynamic-field__row:first-child {
|
|
18
|
+
margin-top: 0;
|
|
19
|
+
}
|
|
20
|
+
.pc-array-dynamic-field__card-head {
|
|
21
|
+
margin-bottom: 8px;
|
|
22
|
+
}
|
|
23
|
+
.pc-array-dynamic-field__row-title {
|
|
24
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
25
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
26
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
27
|
+
}
|
|
28
|
+
.pc-array-dynamic-field__row-title, .pc-array-dynamic-field__row-field {
|
|
29
|
+
flex: 1;
|
|
30
|
+
}
|
|
31
|
+
.pc-array-dynamic-field__empty {
|
|
32
|
+
padding: 10px;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
.pc-array-dynamic-field__add-button {
|
|
37
|
+
margin-top: 12px;
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrayObjectInput, ArrayTextInput } from '../../../../../common/types';
|
|
3
|
+
import { ClassNameProps } from '../../../../../models';
|
|
4
|
+
import { DynamicFormValue } from '../../DynamicForm';
|
|
5
|
+
import './Array.css';
|
|
6
|
+
type ArrayInput = ArrayTextInput | ArrayObjectInput;
|
|
7
|
+
interface ArrayFieldProps extends ClassNameProps {
|
|
8
|
+
title: string;
|
|
9
|
+
values: Array<DynamicFormValue>;
|
|
10
|
+
onUpdate: (key: string, value: DynamicFormValue) => void;
|
|
11
|
+
blockConfig: ArrayInput;
|
|
12
|
+
}
|
|
13
|
+
declare const ArrayDynamicField: React.FC<ArrayFieldProps>;
|
|
14
|
+
export default ArrayDynamicField;
|