@gravity-ui/page-constructor 6.3.2-alpha.0 → 6.3.2-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/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/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/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/index.d.ts +1 -1
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.css +0 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js +115 -0
- package/build/cjs/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +89 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +27 -0
- package/build/cjs/editor-v2/components/DynamicForm/FieldBase/FieldBase.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.css +37 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js +68 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +10 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +22 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.css +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.js +16 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Number/Number.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +10 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js +12 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +6 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +9 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +35 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.css +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.d.ts +11 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js +14 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/Text/Text.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +8 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +13 -0
- package/build/cjs/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js.map +1 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.js +23 -0
- package/build/cjs/editor-v2/components/DynamicForm/utils.js.map +1 -0
- package/build/cjs/editor-v2/components/Panels/Panels.css +37 -0
- package/build/cjs/editor-v2/components/Panels/Panels.d.ts +8 -0
- package/build/cjs/editor-v2/components/Panels/Panels.js +28 -0
- package/build/cjs/editor-v2/components/Panels/Panels.js.map +1 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.css +24 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.d.ts +10 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.js +13 -0
- package/build/cjs/editor-v2/components/Sidebar/Sidebar.js.map +1 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.css +29 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.d.ts +6 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js +17 -0
- package/build/cjs/editor-v2/components/StoreViewer/StoreViewer.js.map +1 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.css +26 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.d.ts +13 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.js +32 -0
- package/build/cjs/editor-v2/components/Tabs/Tabs.js.map +1 -0
- package/build/cjs/editor-v2/constants.d.ts +1 -0
- package/build/cjs/editor-v2/constants.js +5 -0
- package/build/cjs/editor-v2/constants.js.map +1 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.css +35 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.d.ts +4 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js +58 -0
- package/build/cjs/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.css +33 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.d.ts +5 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.js +28 -0
- package/build/cjs/editor-v2/containers/BlockConfig/BlockConfig.js.map +1 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.css +65 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.d.ts +2 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.js +43 -0
- package/build/cjs/editor-v2/containers/BlocksList/BlocksList.js.map +1 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.css +51 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.d.ts +21 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.js +40 -0
- package/build/cjs/editor-v2/containers/Editor/Editor.js.map +1 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.css +24 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.d.ts +5 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.js +17 -0
- package/build/cjs/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.css +62 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.d.ts +7 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js +34 -0
- package/build/cjs/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.css +60 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.d.ts +6 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js +90 -0
- package/build/cjs/editor-v2/containers/Overlay/Overlay.js.map +1 -0
- package/build/cjs/editor-v2/containers/Source/Source.css +27 -0
- package/build/cjs/editor-v2/containers/Source/Source.d.ts +2 -0
- package/build/cjs/editor-v2/containers/Source/Source.js +28 -0
- package/build/cjs/editor-v2/containers/Source/Source.js.map +1 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.css +50 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.d.ts +6 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.js +41 -0
- package/build/cjs/editor-v2/containers/SourceCode/SourceCode.js.map +1 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.css +3 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.d.ts +7 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js +18 -0
- package/build/cjs/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.css +38 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.d.ts +14 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.js +49 -0
- package/build/cjs/editor-v2/containers/Tree/DragContext.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.css +23 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.d.ts +2 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.js +36 -0
- package/build/cjs/editor-v2/containers/Tree/Tree.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.css +28 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.d.ts +16 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.js +61 -0
- package/build/cjs/editor-v2/containers/Tree/TreeContent.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.css +66 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.d.ts +13 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.js +144 -0
- package/build/cjs/editor-v2/containers/Tree/TreeItem.js.map +1 -0
- package/build/cjs/editor-v2/containers/Tree/index.d.ts +4 -0
- package/build/cjs/editor-v2/containers/Tree/index.js +10 -0
- package/build/cjs/editor-v2/containers/Tree/index.js.map +1 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.css +23 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.d.ts +3 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js +54 -0
- package/build/cjs/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.d.ts +7 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.js +10 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreContext.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.d.ts +5 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js +35 -0
- package/build/cjs/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -0
- package/build/cjs/editor-v2/context/editorStore/index.d.ts +2 -0
- package/build/cjs/editor-v2/context/editorStore/index.js +6 -0
- package/build/cjs/editor-v2/context/editorStore/index.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.d.ts +12 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.js +14 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeContext.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.d.ts +7 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.js +21 -0
- package/build/cjs/editor-v2/context/iframeContext/IframeProvider.js.map +1 -0
- package/build/cjs/editor-v2/context/iframeContext/index.d.ts +2 -0
- package/build/cjs/editor-v2/context/iframeContext/index.js +6 -0
- package/build/cjs/editor-v2/context/iframeContext/index.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.d.ts +16 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.js +77 -0
- package/build/cjs/editor-v2/hooks/useEditorTabs.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.d.ts +2 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js +31 -0
- package/build/cjs/editor-v2/hooks/useMainEditorInitialize.js.map +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.d.ts +1 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.js +13 -0
- package/build/cjs/editor-v2/hooks/useMainEditorStore.js.map +1 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.d.ts +6 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js +19 -0
- package/build/cjs/editor-v2/hooks/usePostMessageEvents.js.map +1 -0
- package/build/cjs/editor-v2/index.d.ts +2 -0
- package/build/cjs/editor-v2/index.js +8 -0
- package/build/cjs/editor-v2/index.js.map +1 -0
- package/build/cjs/editor-v2/store.d.ts +48 -0
- package/build/cjs/editor-v2/store.js +181 -0
- package/build/cjs/editor-v2/store.js.map +1 -0
- package/build/cjs/editor-v2/styles/mixins.css +0 -0
- package/build/cjs/editor-v2/styles/root.css +12 -0
- package/build/cjs/editor-v2/styles/variables.css +0 -0
- package/build/cjs/editor-v2/utils/cn.d.ts +2 -0
- package/build/cjs/editor-v2/utils/cn.js +7 -0
- package/build/cjs/editor-v2/utils/cn.js.map +1 -0
- package/build/cjs/editor-v2/utils/code.d.ts +6 -0
- package/build/cjs/editor-v2/utils/code.js +13 -0
- package/build/cjs/editor-v2/utils/code.js.map +1 -0
- package/build/cjs/editor-v2/utils/index.d.ts +18 -0
- package/build/cjs/editor-v2/utils/index.js +159 -0
- package/build/cjs/editor-v2/utils/index.js.map +1 -0
- 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/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/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/index.d.ts +1 -1
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.css +0 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js +113 -0
- package/build/esm/editor-v2/components/DynamicForm/DynamicForm.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.css +89 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.d.ts +13 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.js +25 -0
- package/build/esm/editor-v2/components/DynamicForm/FieldBase/FieldBase.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.css +37 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.d.ts +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js +66 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/Array.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js +19 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Boolean/Boolean.css +3 -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/Boolean/Boolean.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.js +13 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Number/Number.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js +9 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Object/Object.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.css +6 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.d.ts +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js +33 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/OneOf/OneOf.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.css +3 -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 +12 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Select/Select.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.js +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/Text/Text.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.d.ts +8 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js +10 -0
- package/build/esm/editor-v2/components/DynamicForm/Fields/TextArea/TextArea.js.map +1 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.d.ts +3 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.js +17 -0
- package/build/esm/editor-v2/components/DynamicForm/utils.js.map +1 -0
- package/build/esm/editor-v2/components/Panels/Panels.css +37 -0
- package/build/esm/editor-v2/components/Panels/Panels.d.ts +9 -0
- package/build/esm/editor-v2/components/Panels/Panels.js +24 -0
- package/build/esm/editor-v2/components/Panels/Panels.js.map +1 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.css +24 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.d.ts +11 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.js +9 -0
- package/build/esm/editor-v2/components/Sidebar/Sidebar.js.map +1 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.css +29 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.d.ts +7 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js +15 -0
- package/build/esm/editor-v2/components/StoreViewer/StoreViewer.js.map +1 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.css +26 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.d.ts +14 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.js +30 -0
- package/build/esm/editor-v2/components/Tabs/Tabs.js.map +1 -0
- package/build/esm/editor-v2/constants.d.ts +1 -0
- package/build/esm/editor-v2/constants.js +2 -0
- package/build/esm/editor-v2/constants.js.map +1 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.css +35 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.d.ts +5 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js +56 -0
- package/build/esm/editor-v2/containers/BigOverlay/BigOverlay.js.map +1 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.css +33 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.d.ts +6 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.js +26 -0
- package/build/esm/editor-v2/containers/BlockConfig/BlockConfig.js.map +1 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.css +65 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.d.ts +3 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.js +41 -0
- package/build/esm/editor-v2/containers/BlocksList/BlocksList.js.map +1 -0
- package/build/esm/editor-v2/containers/Editor/Editor.css +51 -0
- package/build/esm/editor-v2/containers/Editor/Editor.d.ts +22 -0
- package/build/esm/editor-v2/containers/Editor/Editor.js +36 -0
- package/build/esm/editor-v2/containers/Editor/Editor.js.map +1 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.css +24 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.d.ts +6 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.js +15 -0
- package/build/esm/editor-v2/containers/GlobalConfig/GlobalConfig.js.map +1 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.css +62 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.d.ts +8 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js +32 -0
- package/build/esm/editor-v2/containers/MiddleScreen/MiddleScreen.js.map +1 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.css +60 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.d.ts +7 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.js +88 -0
- package/build/esm/editor-v2/containers/Overlay/Overlay.js.map +1 -0
- package/build/esm/editor-v2/containers/Source/Source.css +27 -0
- package/build/esm/editor-v2/containers/Source/Source.d.ts +3 -0
- package/build/esm/editor-v2/containers/Source/Source.js +26 -0
- package/build/esm/editor-v2/containers/Source/Source.js.map +1 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.css +50 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.d.ts +7 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.js +39 -0
- package/build/esm/editor-v2/containers/SourceCode/SourceCode.js.map +1 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.css +3 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.d.ts +8 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js +14 -0
- package/build/esm/editor-v2/containers/SourceCode/UpdateModal/UpdateModal.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.css +38 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.d.ts +15 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.js +45 -0
- package/build/esm/editor-v2/containers/Tree/DragContext.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/Tree.css +23 -0
- package/build/esm/editor-v2/containers/Tree/Tree.d.ts +3 -0
- package/build/esm/editor-v2/containers/Tree/Tree.js +34 -0
- package/build/esm/editor-v2/containers/Tree/Tree.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.css +28 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.d.ts +17 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.js +57 -0
- package/build/esm/editor-v2/containers/Tree/TreeContent.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.css +66 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.d.ts +14 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.js +140 -0
- package/build/esm/editor-v2/containers/Tree/TreeItem.js.map +1 -0
- package/build/esm/editor-v2/containers/Tree/index.d.ts +4 -0
- package/build/esm/editor-v2/containers/Tree/index.js +5 -0
- package/build/esm/editor-v2/containers/Tree/index.js.map +1 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.css +23 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.d.ts +4 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js +52 -0
- package/build/esm/editor-v2/containers/ViewSwitches/ViewSwitches.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.d.ts +7 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.js +6 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreContext.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.d.ts +5 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js +30 -0
- package/build/esm/editor-v2/context/editorStore/MainEditorStoreProvider.js.map +1 -0
- package/build/esm/editor-v2/context/editorStore/index.d.ts +2 -0
- package/build/esm/editor-v2/context/editorStore/index.js +3 -0
- package/build/esm/editor-v2/context/editorStore/index.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.d.ts +12 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.js +10 -0
- package/build/esm/editor-v2/context/iframeContext/IframeContext.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.d.ts +7 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.js +16 -0
- package/build/esm/editor-v2/context/iframeContext/IframeProvider.js.map +1 -0
- package/build/esm/editor-v2/context/iframeContext/index.d.ts +2 -0
- package/build/esm/editor-v2/context/iframeContext/index.js +3 -0
- package/build/esm/editor-v2/context/iframeContext/index.js.map +1 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.d.ts +16 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.js +72 -0
- package/build/esm/editor-v2/hooks/useEditorTabs.js.map +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.d.ts +2 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js +29 -0
- package/build/esm/editor-v2/hooks/useMainEditorInitialize.js.map +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.d.ts +1 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.js +8 -0
- package/build/esm/editor-v2/hooks/useMainEditorStore.js.map +1 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.d.ts +6 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js +15 -0
- package/build/esm/editor-v2/hooks/usePostMessageEvents.js.map +1 -0
- package/build/esm/editor-v2/index.d.ts +2 -0
- package/build/esm/editor-v2/index.js +3 -0
- package/build/esm/editor-v2/index.js.map +1 -0
- package/build/esm/editor-v2/store.d.ts +48 -0
- package/build/esm/editor-v2/store.js +177 -0
- package/build/esm/editor-v2/store.js.map +1 -0
- package/build/esm/editor-v2/styles/mixins.css +0 -0
- package/build/esm/editor-v2/styles/root.css +12 -0
- package/build/esm/editor-v2/styles/variables.css +0 -0
- package/build/esm/editor-v2/utils/cn.d.ts +2 -0
- package/build/esm/editor-v2/utils/cn.js +4 -0
- package/build/esm/editor-v2/utils/cn.js.map +1 -0
- package/build/esm/editor-v2/utils/code.d.ts +6 -0
- package/build/esm/editor-v2/utils/code.js +9 -0
- package/build/esm/editor-v2/utils/code.js.map +1 -0
- package/build/esm/editor-v2/utils/index.d.ts +18 -0
- package/build/esm/editor-v2/utils/index.js +141 -0
- package/build/esm/editor-v2/utils/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ declare const TestEditorBlockConfig: {
|
|
|
2
2
|
component: (props: import("./TestEditorBlock.js").TestEditorBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
schema: {
|
|
4
4
|
name: string;
|
|
5
|
-
inputs: (import("
|
|
5
|
+
inputs: (import("../../editor-v2/index.js").TextInput | import("../../editor-v2/index.js").BooleanInput | import("../../editor-v2/index.js").NumberInput | import("../../editor-v2/index.js").TextAreaInput | import("../../editor-v2/index.js").SelectSingleInput | import("../../editor-v2/index.js").SelectMultipleInput | import("../../editor-v2/index.js").ObjectInput | import("../../editor-v2/index.js").ArrayTextInput | import("../../editor-v2/index.js").ArrayObjectInput | import("../../editor-v2/index.js").OneOfInput)[];
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
8
|
export declare const TestEditorBlockSchema: {
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigInput, DynamicFormValue } from "../../../../common/types/index.js";
|
|
2
|
+
interface DynamicFormProps {
|
|
3
|
+
blockConfig: Array<ConfigInput>;
|
|
4
|
+
contentConfig?: DynamicFormValue;
|
|
5
|
+
onUpdate: (key: string, value: DynamicFormValue) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const DynamicForm: ({ blockConfig, onUpdate, contentConfig }: DynamicFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default DynamicForm;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
+
const React = tslib_1.__importStar(require("react"));
|
|
7
|
+
const cn_1 = require("../../utils/cn.js");
|
|
8
|
+
const Array_1 = tslib_1.__importDefault(require("./Fields/Array/Array.js"));
|
|
9
|
+
const Boolean_1 = tslib_1.__importDefault(require("./Fields/Boolean/Boolean.js"));
|
|
10
|
+
const Number_1 = tslib_1.__importDefault(require("./Fields/Number/Number.js"));
|
|
11
|
+
const Object_1 = tslib_1.__importDefault(require("./Fields/Object/Object.js"));
|
|
12
|
+
const OneOf_1 = tslib_1.__importDefault(require("./Fields/OneOf/OneOf.js"));
|
|
13
|
+
const Select_1 = tslib_1.__importDefault(require("./Fields/Select/Select.js"));
|
|
14
|
+
const Text_1 = tslib_1.__importDefault(require("./Fields/Text/Text.js"));
|
|
15
|
+
const TextArea_1 = tslib_1.__importDefault(require("./Fields/TextArea/TextArea.js"));
|
|
16
|
+
const utils_1 = require("./utils.js");
|
|
17
|
+
const b = (0, cn_1.editorCn)('dynamic-form');
|
|
18
|
+
const DynamicForm = ({ blockConfig, onUpdate, contentConfig }) => {
|
|
19
|
+
const inputs = blockConfig;
|
|
20
|
+
const getData = React.useCallback((variable) => {
|
|
21
|
+
if (variable.startsWith('block.')) {
|
|
22
|
+
const purePath = variable.replace('block.', '');
|
|
23
|
+
return lodash_1.default.get(contentConfig, purePath);
|
|
24
|
+
}
|
|
25
|
+
if ((variable.startsWith(`'`) && variable.endsWith(`'`)) ||
|
|
26
|
+
(variable.startsWith(`"`) && variable.endsWith(`"`))) {
|
|
27
|
+
// @ts-ignore TODO: replaceAll types
|
|
28
|
+
return variable.replaceAll(`'`, '').replaceAll(`"`, '');
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}, [contentConfig]);
|
|
32
|
+
const decide = React.useCallback((showIf) => {
|
|
33
|
+
const parts = showIf.split(' ');
|
|
34
|
+
if (!(parts.length === 3)) {
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log('Something bad happened in showIf, ignored');
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const [firstVariable, equals, secondVariable] = parts;
|
|
40
|
+
const data1 = getData(firstVariable);
|
|
41
|
+
const data2 = getData(secondVariable);
|
|
42
|
+
if (equals === '===') {
|
|
43
|
+
return data1 === data2;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return data1 !== data2;
|
|
47
|
+
}
|
|
48
|
+
}, [getData]);
|
|
49
|
+
const renderInput = React.useCallback((input) => {
|
|
50
|
+
const fieldPath = input.name;
|
|
51
|
+
const fieldValue = (0, utils_1.getContent)(contentConfig, input.name);
|
|
52
|
+
if (input.showIf) {
|
|
53
|
+
const decision = decide(input.showIf);
|
|
54
|
+
if (!decision) {
|
|
55
|
+
return (0, jsx_runtime_1.jsxs)("div", { children: ["Hidden Field: ", 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((0, utils_1.getFullPath)(fieldPath, key), value);
|
|
65
|
+
};
|
|
66
|
+
switch (input.type) {
|
|
67
|
+
case 'text': {
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(Text_1.default, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
69
|
+
}
|
|
70
|
+
case 'boolean': {
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(Boolean_1.default, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
72
|
+
}
|
|
73
|
+
case 'textarea': {
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(TextArea_1.default, { onRefresh: (value) => onUpdate(fieldPath, value), title: input.title, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
75
|
+
}
|
|
76
|
+
case 'select': {
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(Select_1.default, { onRefresh: (value) => onUpdate(fieldPath, value), input: input, value: fieldValue, onUpdate: onSimpleDynamicFieldUpdate }));
|
|
78
|
+
}
|
|
79
|
+
case 'number': {
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(Number_1.default, { 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 ((0, jsx_runtime_1.jsx)(Object_1.default, { onRefresh: (value) => onUpdate(fieldPath, value), blockConfig: input.properties, title: input.title, value: fieldValue, onUpdate: onComplexDynamicFieldUpdate }));
|
|
87
|
+
}
|
|
88
|
+
case 'array': {
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(Array_1.default, { 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 ((0, jsx_runtime_1.jsx)(OneOf_1.default, { inputConfig: input, contentConfig: contentConfig, onUpdate: onComplexDynamicFieldUpdate }));
|
|
96
|
+
}
|
|
97
|
+
default: {
|
|
98
|
+
return (0, jsx_runtime_1.jsxs)("div", { children: ["Ignore ", JSON.stringify(input)] });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, [contentConfig, decide, onUpdate]);
|
|
102
|
+
const sortedInputs = inputs.sort((x, y) => {
|
|
103
|
+
const nestingFieldTypes = ['object', 'array', 'oneOf'];
|
|
104
|
+
if (nestingFieldTypes.includes(x.type)) {
|
|
105
|
+
return 1;
|
|
106
|
+
}
|
|
107
|
+
if (nestingFieldTypes.includes(y.type)) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
});
|
|
112
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: b(), children: sortedInputs.map((input, index) => ((0, jsx_runtime_1.jsx)(React.Fragment, { children: renderInput(input) }, index))) }));
|
|
113
|
+
};
|
|
114
|
+
exports.default = DynamicForm;
|
|
115
|
+
//# sourceMappingURL=DynamicForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicForm.js","sourceRoot":"../../../../../src","sources":["editor-v2/components/DynamicForm/DynamicForm.tsx"],"names":[],"mappings":";;;;AAAA,4DAAuB;AACvB,qDAA+B;AAG/B,0CAAwC;AAGxC,4EAAqD;AACrD,kFAA2D;AAC3D,+EAAwD;AACxD,+EAAwD;AACxD,4EAA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,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,CAAC;QACb,CAAC;QACD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,CACH,gCAAK,SAAS,EAAE,CAAC,EAAE,YACd,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAChC,uBAAC,KAAK,CAAC,QAAQ,cAAc,WAAW,CAAC,KAAK,CAAC,IAA1B,KAAK,CAAuC,CACpE,CAAC,GACA,CACT,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC","sourcesContent":["import _ from 'lodash';\nimport * as React from 'react';\n\nimport {ConfigInput, DynamicFormValue} from '../../../../common/types';\nimport {editorCn} from '../../utils/cn';\n\nimport './DynamicForm.scss';\nimport ArrayDynamicField from './Fields/Array/Array';\nimport BooleanDynamicField from './Fields/Boolean/Boolean';\nimport NumberDynamicField from './Fields/Number/Number';\nimport ObjectDynamicField from './Fields/Object/Object';\nimport OneOfDynamicField from './Fields/OneOf/OneOf';\nimport SelectDynamicField from './Fields/Select/Select';\nimport TextDynamicField from './Fields/Text/Text';\nimport TextAreaDynamicField from './Fields/TextArea/TextArea';\nimport {getContent, getFullPath} from './utils';\n\nconst b = editorCn('dynamic-form');\n\ninterface DynamicFormProps {\n blockConfig: Array<ConfigInput>;\n contentConfig?: DynamicFormValue;\n onUpdate: (key: string, value: DynamicFormValue) => void;\n className?: string;\n}\n\nconst DynamicForm = ({blockConfig, onUpdate, contentConfig}: DynamicFormProps) => {\n const inputs = blockConfig;\n\n const getData = React.useCallback(\n (variable: string) => {\n if (variable.startsWith('block.')) {\n const purePath = variable.replace('block.', '');\n return _.get(contentConfig, purePath);\n }\n\n if (\n (variable.startsWith(`'`) && variable.endsWith(`'`)) ||\n (variable.startsWith(`\"`) && variable.endsWith(`\"`))\n ) {\n // @ts-ignore TODO: replaceAll types\n return variable.replaceAll(`'`, '').replaceAll(`\"`, '');\n }\n\n return undefined;\n },\n [contentConfig],\n );\n\n const decide = React.useCallback(\n (showIf: string): boolean => {\n const parts = showIf.split(' ');\n\n if (!(parts.length === 3)) {\n // eslint-disable-next-line no-console\n console.log('Something bad happened in showIf, ignored');\n return true;\n }\n\n const [firstVariable, equals, secondVariable] = parts;\n\n const data1 = getData(firstVariable);\n const data2 = getData(secondVariable);\n\n if (equals === '===') {\n return data1 === data2;\n } else {\n return data1 !== data2;\n }\n },\n [getData],\n );\n\n const renderInput = React.useCallback(\n (input: ConfigInput) => {\n const fieldPath = input.name;\n const fieldValue = getContent(contentConfig, input.name);\n\n if (input.showIf) {\n const decision = decide(input.showIf);\n\n if (!decision) {\n return <div>Hidden Field: {input.name}</div>;\n }\n }\n\n // Text, Select, Boolean and etc\n const onSimpleDynamicFieldUpdate = (value: DynamicFormValue) => {\n onUpdate(fieldPath, value);\n };\n\n // Array and Objects\n const onComplexDynamicFieldUpdate = (key: string, value: DynamicFormValue) => {\n onUpdate(getFullPath(fieldPath, key), value);\n };\n\n switch (input.type) {\n case 'text': {\n return (\n <TextDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n title={input.title}\n value={fieldValue}\n onUpdate={onSimpleDynamicFieldUpdate}\n />\n );\n }\n case 'boolean': {\n return (\n <BooleanDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n title={input.title}\n value={fieldValue}\n onUpdate={onSimpleDynamicFieldUpdate}\n />\n );\n }\n case 'textarea': {\n return (\n <TextAreaDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n title={input.title}\n value={fieldValue}\n onUpdate={onSimpleDynamicFieldUpdate}\n />\n );\n }\n case 'select': {\n return (\n <SelectDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n input={input}\n value={fieldValue}\n onUpdate={onSimpleDynamicFieldUpdate}\n />\n );\n }\n case 'number': {\n return (\n <NumberDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n title={input.title}\n value={fieldValue}\n onUpdate={onSimpleDynamicFieldUpdate}\n />\n );\n }\n case 'object': {\n if (!input || !('properties' in input)) {\n return null;\n }\n\n return (\n <ObjectDynamicField\n onRefresh={(value) => onUpdate(fieldPath, value)}\n blockConfig={input.properties}\n title={input.title}\n value={fieldValue}\n onUpdate={onComplexDynamicFieldUpdate}\n />\n );\n }\n case 'array': {\n return (\n <ArrayDynamicField\n blockConfig={input}\n title={input.title}\n values={fieldValue}\n onUpdate={onComplexDynamicFieldUpdate}\n />\n );\n }\n case 'oneOf': {\n if (!input || !('options' in input)) {\n return null;\n }\n\n return (\n <OneOfDynamicField\n inputConfig={input}\n contentConfig={contentConfig}\n onUpdate={onComplexDynamicFieldUpdate}\n />\n );\n }\n default: {\n return <div>Ignore {JSON.stringify(input)}</div>;\n }\n }\n },\n [contentConfig, decide, onUpdate],\n );\n\n const sortedInputs = inputs.sort((x, y) => {\n const nestingFieldTypes = ['object', 'array', 'oneOf'];\n if (nestingFieldTypes.includes(x.type)) {\n return 1;\n }\n if (nestingFieldTypes.includes(y.type)) {\n return -1;\n }\n return 0;\n });\n\n return (\n <div className={b()}>\n {sortedInputs.map((input, index) => (\n <React.Fragment key={index}>{renderInput(input)}</React.Fragment>\n ))}\n </div>\n );\n};\n\nexport default DynamicForm;\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.g-root {
|
|
2
|
+
--g-color-base-brand: var(--g-color-private-black-550-solid);
|
|
3
|
+
--g-color-base-brand-hover: var(--g-color-private-black-600-solid);
|
|
4
|
+
--g-color-base-selection: var(--g-color-private-black-200);
|
|
5
|
+
--g-color-base-selection-hover: var(--g-color-private-black-300);
|
|
6
|
+
--g-color-base-brand: var(--g-color-text-primary);
|
|
7
|
+
--g-color-base-brand-hover: var(--g-color-text-complementary);
|
|
8
|
+
--g-color-text-brand-contrast: var(--g-color-text-light-primary);
|
|
9
|
+
--g-color-line-brand: var(--g-color-text-primary);
|
|
10
|
+
--g-color-text-brand: var(--g-color-private-brand-700-solid);
|
|
11
|
+
--g-color-text-brand-heavy: var(--g-color-private-black-700-solid);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.pceditor-field-base {
|
|
15
|
+
padding: 16px 12px;
|
|
16
|
+
border-bottom: 1px solid var(--g-color-line-generic);
|
|
17
|
+
position: relative;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
align-items: flex-start;
|
|
21
|
+
gap: 8px;
|
|
22
|
+
}
|
|
23
|
+
.pceditor-field-base:hover > .pceditor-field-base__top > .pceditor-field-base__button {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
}
|
|
26
|
+
.pceditor-field-base_expandable {
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: 16px;
|
|
29
|
+
}
|
|
30
|
+
.pceditor-field-base_expandable > .pceditor-field-base__top {
|
|
31
|
+
width: 100%;
|
|
32
|
+
flex-basis: initial;
|
|
33
|
+
}
|
|
34
|
+
.pceditor-field-base_expandable > .pceditor-field-base__children {
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
.pceditor-field-base__top {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 4px;
|
|
41
|
+
flex: 0 0 64px;
|
|
42
|
+
word-break: break-all;
|
|
43
|
+
}
|
|
44
|
+
.pceditor-field-base__children {
|
|
45
|
+
flex: 2 1 auto;
|
|
46
|
+
}
|
|
47
|
+
.pceditor-field-base__foldable {
|
|
48
|
+
width: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: space-between;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
.pceditor-field-base__non-foldable:before {
|
|
55
|
+
position: absolute;
|
|
56
|
+
right: calc(100% + 5px);
|
|
57
|
+
}
|
|
58
|
+
.pceditor-field-base__button {
|
|
59
|
+
transition: opacity 0.3s ease;
|
|
60
|
+
opacity: 0;
|
|
61
|
+
}
|
|
62
|
+
.pceditor-field-base__title {
|
|
63
|
+
font-family: var(--g-text-body-font-family);
|
|
64
|
+
font-weight: var(--g-text-body-font-weight);
|
|
65
|
+
font-size: var(--g-text-body-2-font-size);
|
|
66
|
+
line-height: var(--g-text-body-2-line-height);
|
|
67
|
+
margin: 5px 0;
|
|
68
|
+
}
|
|
69
|
+
.pceditor-field-base__title_size_s {
|
|
70
|
+
font-family: var(--g-text-body-font-family);
|
|
71
|
+
font-weight: var(--g-text-body-font-weight);
|
|
72
|
+
font-size: var(--g-text-body-1-font-size);
|
|
73
|
+
line-height: var(--g-text-body-1-line-height);
|
|
74
|
+
}
|
|
75
|
+
.pceditor-field-base__title_size_m {
|
|
76
|
+
font-family: var(--g-text-body-font-family);
|
|
77
|
+
font-weight: var(--g-text-body-font-weight);
|
|
78
|
+
font-size: var(--g-text-body-2-font-size);
|
|
79
|
+
line-height: var(--g-text-body-2-line-height);
|
|
80
|
+
}
|
|
81
|
+
.pceditor-field-base__title_size_l {
|
|
82
|
+
font-family: var(--g-text-body-font-family);
|
|
83
|
+
font-weight: var(--g-text-body-font-weight);
|
|
84
|
+
font-size: var(--g-text-body-3-font-size);
|
|
85
|
+
line-height: var(--g-text-body-3-line-height);
|
|
86
|
+
}
|
|
87
|
+
.pceditor-field-base:last-child {
|
|
88
|
+
border-bottom: none;
|
|
89
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface FieldBaseParams {
|
|
3
|
+
title?: string;
|
|
4
|
+
textSize?: 's' | 'm' | 'l';
|
|
5
|
+
onRefresh?: (value: undefined) => void;
|
|
6
|
+
expandable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface FieldBaseProps extends React.PropsWithChildren, FieldBaseParams {
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const FieldBase: React.FC<FieldBaseProps>;
|
|
12
|
+
export default FieldBase;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
+
const React = tslib_1.__importStar(require("react"));
|
|
8
|
+
const cn_1 = require("../../../utils/cn.js");
|
|
9
|
+
const b = (0, cn_1.editorCn)('field-base');
|
|
10
|
+
const FieldBase = ({ className, title, textSize = 's', children, expandable = false, }) => {
|
|
11
|
+
const [showChildren, setShowChildren] = React.useState(!expandable);
|
|
12
|
+
const titleComponent = React.useMemo(() => {
|
|
13
|
+
if (title) {
|
|
14
|
+
const defaultTitle = ((0, jsx_runtime_1.jsx)("div", { className: b('title', { size: textSize }), children: lodash_1.default.capitalize(title) }));
|
|
15
|
+
if (expandable) {
|
|
16
|
+
return (
|
|
17
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
18
|
+
(0, jsx_runtime_1.jsxs)("div", { className: b('foldable'), onClick: () => setShowChildren(!showChildren), children: [defaultTitle, (0, jsx_runtime_1.jsx)(uikit_1.ArrowToggle, { direction: showChildren ? 'bottom' : 'right', className: b('arrow-toggle') })] }));
|
|
19
|
+
}
|
|
20
|
+
return (0, jsx_runtime_1.jsx)("div", { className: b('non-foldable'), children: defaultTitle });
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}, [expandable, showChildren, textSize, title]);
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ expandable }, className), children: [title && (0, jsx_runtime_1.jsx)("div", { className: b('top'), children: titleComponent }), (!title || showChildren) && (0, jsx_runtime_1.jsx)("div", { className: b('children'), children: children })] }));
|
|
25
|
+
};
|
|
26
|
+
exports.default = FieldBase;
|
|
27
|
+
//# sourceMappingURL=FieldBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldBase.js","sourceRoot":"../../../../../../src","sources":["editor-v2/components/DynamicForm/FieldBase/FieldBase.tsx"],"names":[],"mappings":";;;;AAAA,6CAA8C;AAC9C,4DAAuB;AACvB,qDAA+B;AAE/B,6CAA2C;AAI3C,MAAM,CAAC,GAAG,IAAA,aAAQ,EAAC,YAAY,CAAC,CAAC;AAajC,MAAM,SAAS,GAA6B,CAAC,EACzC,SAAS,EACT,KAAK,EACL,QAAQ,GAAG,GAAG,EACd,QAAQ,EACR,UAAU,GAAG,KAAK,GACrB,EAAE,EAAE;IACD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;IAEpE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtC,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,YAAY,GAAG,CACjB,gCAAK,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,YAAG,gBAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAO,CAC5E,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACb,OAAO;gBACH,yGAAyG;gBACzG,iCAAK,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,YAAY,CAAC,aACvE,YAAY,EACb,uBAAC,mBAAW,IACR,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAC5C,SAAS,EAAE,CAAC,CAAC,cAAc,CAAC,GAC9B,IACA,CACT,CAAC;YACN,CAAC;YAED,OAAO,gCAAK,SAAS,EAAE,CAAC,CAAC,cAAc,CAAC,YAAG,YAAY,GAAO,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEhD,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAC,UAAU,EAAC,EAAE,SAAS,CAAC,aACrC,KAAK,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,YAAG,cAAc,GAAO,EACzD,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,YAAG,QAAQ,GAAO,IAC1E,CACT,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["import {ArrowToggle} from '@gravity-ui/uikit';\nimport _ from 'lodash';\nimport * as React from 'react';\n\nimport {editorCn} from '../../../utils/cn';\n\nimport './FieldBase.scss';\n\nconst b = editorCn('field-base');\n\nexport interface FieldBaseParams {\n title?: string;\n textSize?: 's' | 'm' | 'l';\n onRefresh?: (value: undefined) => void;\n expandable?: boolean;\n}\n\nexport interface FieldBaseProps extends React.PropsWithChildren, FieldBaseParams {\n className?: string;\n}\n\nconst FieldBase: React.FC<FieldBaseProps> = ({\n className,\n title,\n textSize = 's',\n children,\n expandable = false,\n}) => {\n const [showChildren, setShowChildren] = React.useState(!expandable);\n\n const titleComponent = React.useMemo(() => {\n if (title) {\n const defaultTitle = (\n <div className={b('title', {size: textSize})}>{_.capitalize(title)}</div>\n );\n\n if (expandable) {\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n <div className={b('foldable')} onClick={() => setShowChildren(!showChildren)}>\n {defaultTitle}\n <ArrowToggle\n direction={showChildren ? 'bottom' : 'right'}\n className={b('arrow-toggle')}\n />\n </div>\n );\n }\n\n return <div className={b('non-foldable')}>{defaultTitle}</div>;\n }\n\n return null;\n }, [expandable, showChildren, textSize, title]);\n\n return (\n <div className={b({expandable}, className)}>\n {title && <div className={b('top')}>{titleComponent}</div>}\n {(!title || showChildren) && <div className={b('children')}>{children}</div>}\n </div>\n );\n};\n\nexport default FieldBase;\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.pceditor-array-dynamic-field__card {
|
|
2
|
+
padding: 12px;
|
|
3
|
+
margin-top: 12px;
|
|
4
|
+
}
|
|
5
|
+
.pceditor-array-dynamic-field__card:first-child {
|
|
6
|
+
margin-bottom: 0;
|
|
7
|
+
}
|
|
8
|
+
.pceditor-array-dynamic-field__row {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
gap: 10px;
|
|
13
|
+
margin-top: 10px;
|
|
14
|
+
}
|
|
15
|
+
.pceditor-array-dynamic-field__row:first-child {
|
|
16
|
+
margin-top: 0;
|
|
17
|
+
}
|
|
18
|
+
.pceditor-array-dynamic-field__card-head {
|
|
19
|
+
margin-bottom: 8px;
|
|
20
|
+
}
|
|
21
|
+
.pceditor-array-dynamic-field__row-title {
|
|
22
|
+
font-family: var(--g-text-subheader-font-family);
|
|
23
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
24
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
25
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
26
|
+
}
|
|
27
|
+
.pceditor-array-dynamic-field__row-title, .pceditor-array-dynamic-field__row-field {
|
|
28
|
+
flex: 1;
|
|
29
|
+
}
|
|
30
|
+
.pceditor-array-dynamic-field__empty {
|
|
31
|
+
padding: 10px;
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
}
|
|
35
|
+
.pceditor-array-dynamic-field__add-button {
|
|
36
|
+
margin-top: 12px;
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ArrayObjectInput, ArrayTextInput, DynamicFormValue } from "../../../../../../common/types/index.js";
|
|
2
|
+
type ArrayInput = ArrayTextInput | ArrayObjectInput;
|
|
3
|
+
interface ArrayFieldProps {
|
|
4
|
+
title: string;
|
|
5
|
+
values: Array<DynamicFormValue>;
|
|
6
|
+
onUpdate: (key: string, value: DynamicFormValue) => void;
|
|
7
|
+
blockConfig: ArrayInput;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const ArrayDynamicField: ({ title, values, onUpdate, className, blockConfig }: ArrayFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default ArrayDynamicField;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const React = tslib_1.__importStar(require("react"));
|
|
8
|
+
const utils_1 = require("../../../../utils/index.js");
|
|
9
|
+
const cn_1 = require("../../../../utils/cn.js");
|
|
10
|
+
const DynamicForm_1 = tslib_1.__importDefault(require("../../DynamicForm.js"));
|
|
11
|
+
const FieldBase_1 = tslib_1.__importDefault(require("../../FieldBase/FieldBase.js"));
|
|
12
|
+
const Text_1 = tslib_1.__importDefault(require("../Text/Text.js"));
|
|
13
|
+
const ItemButton_1 = tslib_1.__importDefault(require("./ItemButton/ItemButton.js"));
|
|
14
|
+
const b = (0, cn_1.editorCn)('array-dynamic-field');
|
|
15
|
+
const ArrayDynamicField = ({ title, values, onUpdate, className, blockConfig }) => {
|
|
16
|
+
const haveItems = values && Array.isArray(values) && values.length;
|
|
17
|
+
const onAddItem = React.useCallback(() => {
|
|
18
|
+
if (blockConfig.arrayType === 'text') {
|
|
19
|
+
onUpdate('', haveItems ? [...values, ''] : ['']);
|
|
20
|
+
}
|
|
21
|
+
else if (blockConfig.arrayType === 'object') {
|
|
22
|
+
onUpdate('', haveItems ? [...values, {}] : [{}]);
|
|
23
|
+
}
|
|
24
|
+
}, [blockConfig.arrayType, haveItems, onUpdate, values]);
|
|
25
|
+
const onDeleteItem = React.useCallback((index) => {
|
|
26
|
+
if (Array.isArray(values)) {
|
|
27
|
+
const newArray = (0, utils_1.removeFromArray)(values, index);
|
|
28
|
+
onUpdate('', newArray);
|
|
29
|
+
}
|
|
30
|
+
}, [onUpdate, values]);
|
|
31
|
+
const onReorderItem = React.useCallback((index, placement) => {
|
|
32
|
+
if (Array.isArray(values)) {
|
|
33
|
+
const newArray = (0, utils_1.swapArrayItems)(values, index, placement === 'up' ? index - 1 : index + 1);
|
|
34
|
+
onUpdate('', newArray);
|
|
35
|
+
}
|
|
36
|
+
}, [onUpdate, values]);
|
|
37
|
+
const renderInput = React.useCallback((value, index) => {
|
|
38
|
+
const arrayItemButton = ((0, jsx_runtime_1.jsx)(ItemButton_1.default, { onRemove: () => onDeleteItem(index), onReorderUp: () => onReorderItem(index, 'up'), onReorderDown: () => onReorderItem(index, 'down'), disableReorderUp: index === 0, disableReorderDown: Boolean(haveItems) && values.length === index + 1 }));
|
|
39
|
+
switch (blockConfig.arrayType) {
|
|
40
|
+
case 'text': {
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: b('row'), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { className: b('row-field'), value: String(value), onUpdate: (updateValue) => onUpdate(`[${index}]`, updateValue), onRefresh: (updatedValue) => onUpdate('', updatedValue) }), arrayItemButton] }));
|
|
42
|
+
}
|
|
43
|
+
case 'object': {
|
|
44
|
+
if (!blockConfig.properties) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(uikit_1.Card, { className: b('card'), children: [(0, jsx_runtime_1.jsxs)("div", { className: `${b('row')} ${b('card-head')}`, children: [(0, jsx_runtime_1.jsxs)("div", { className: b('row-title'), children: ["#", index] }), arrayItemButton] }), (0, jsx_runtime_1.jsx)(DynamicForm_1.default, { contentConfig: value, blockConfig: blockConfig.properties, onUpdate: (key, updateValue) => onUpdate(`[${index}].${key}`, updateValue) })] }, index));
|
|
48
|
+
}
|
|
49
|
+
default: {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [blockConfig, haveItems, onDeleteItem, onReorderItem, onUpdate, values]);
|
|
54
|
+
const renderInputs = React.useCallback(() => {
|
|
55
|
+
if (haveItems) {
|
|
56
|
+
const renderItems = values
|
|
57
|
+
.map(renderInput)
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [renderItems, (0, jsx_runtime_1.jsxs)(uikit_1.Button, { className: b('add-button'), onClick: onAddItem, children: [(0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Plus }), blockConfig.buttonText] })] }));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: b('empty'), children: (0, jsx_runtime_1.jsxs)(uikit_1.Button, { className: b('add-button'), onClick: onAddItem, children: [(0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Plus }), "Please, add new item"] }) }));
|
|
63
|
+
}
|
|
64
|
+
}, [blockConfig.buttonText, haveItems, onAddItem, renderInput, values]);
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(FieldBase_1.default, { title: title, className: b(null, className), onRefresh: (value) => onUpdate('', value), expandable: true, children: (0, jsx_runtime_1.jsx)(uikit_1.Card, { className: b('card'), children: renderInputs() }) }));
|
|
66
|
+
};
|
|
67
|
+
exports.default = ArrayDynamicField;
|
|
68
|
+
//# sourceMappingURL=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AC,WAAW,CAAC,GAAG,EAAE;QACxC,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,WAAW,GAAG,MAAM;iBACrB,GAAG,CAAC,WAAW,CAAC;iBAChB,MAAM,CAAC,OAAO,CAAiC,CAAC;YACrD,OAAO,CACH,wBAAC,KAAK,CAAC,QAAQ,eACV,WAAW,EACZ,wBAAC,cAAM,IAAC,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,SAAS,aAClD,uBAAC,YAAI,IAAC,IAAI,EAAE,YAAI,GAAI,EACnB,WAAW,CAAC,UAAU,IAClB,IACI,CACpB,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,OAAO,CACH,gCAAK,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,YACtB,wBAAC,cAAM,IAAC,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,SAAS,aAClD,uBAAC,YAAI,IAAC,IAAI,EAAE,YAAI,GAAI,4BAEf,GACP,CACT,CAAC;QACN,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAExE,OAAO,CACH,uBAAC,mBAAS,IACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAC7B,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,EACzC,UAAU,kBAEV,uBAAC,YAAI,IAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,YAAG,YAAY,EAAE,GAAQ,GAC3C,CACf,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC","sourcesContent":["import {Plus} from '@gravity-ui/icons';\nimport {Button, Card, Icon} from '@gravity-ui/uikit';\nimport * as React from 'react';\n\nimport {ArrayObjectInput, ArrayTextInput, DynamicFormValue} from '../../../../../../common/types';\nimport {removeFromArray, swapArrayItems} from '../../../../utils';\nimport {editorCn} from '../../../../utils/cn';\nimport DynamicForm from '../../DynamicForm';\nimport FieldBase from '../../FieldBase/FieldBase';\nimport Text from '../Text/Text';\n\nimport './Array.scss';\nimport ItemButton from './ItemButton/ItemButton';\n\nconst b = editorCn('array-dynamic-field');\n\ntype ArrayInput = ArrayTextInput | ArrayObjectInput;\n\ninterface ArrayFieldProps {\n title: string;\n values: Array<DynamicFormValue>;\n onUpdate: (key: string, value: DynamicFormValue) => void;\n blockConfig: ArrayInput;\n className?: string;\n}\n\nconst ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: ArrayFieldProps) => {\n const haveItems = values && Array.isArray(values) && values.length;\n\n const onAddItem = React.useCallback(() => {\n if (blockConfig.arrayType === 'text') {\n onUpdate('', haveItems ? [...values, ''] : ['']);\n } else if (blockConfig.arrayType === 'object') {\n onUpdate('', haveItems ? [...values, {}] : [{}]);\n }\n }, [blockConfig.arrayType, haveItems, onUpdate, values]);\n\n const onDeleteItem = React.useCallback(\n (index: number) => {\n if (Array.isArray(values)) {\n const newArray = removeFromArray(values, index);\n onUpdate('', newArray);\n }\n },\n [onUpdate, values],\n );\n\n const onReorderItem = React.useCallback(\n (index: number, placement: 'up' | 'down') => {\n if (Array.isArray(values)) {\n const newArray = swapArrayItems(\n values,\n index,\n placement === 'up' ? index - 1 : index + 1,\n );\n onUpdate('', newArray);\n }\n },\n [onUpdate, values],\n );\n\n const renderInput = React.useCallback(\n (value: DynamicFormValue, index: number) => {\n const arrayItemButton = (\n <ItemButton\n onRemove={() => onDeleteItem(index)}\n onReorderUp={() => onReorderItem(index, 'up')}\n onReorderDown={() => onReorderItem(index, 'down')}\n disableReorderUp={index === 0}\n disableReorderDown={Boolean(haveItems) && values.length === index + 1}\n />\n );\n\n switch (blockConfig.arrayType) {\n case 'text': {\n return (\n <div className={b('row')}>\n <Text\n className={b('row-field')}\n value={String(value)}\n onUpdate={(updateValue) => onUpdate(`[${index}]`, updateValue)}\n onRefresh={(updatedValue) => onUpdate('', updatedValue)}\n />\n {arrayItemButton}\n </div>\n );\n }\n case 'object': {\n if (!blockConfig.properties) {\n return null;\n }\n return (\n <Card key={index} className={b('card')}>\n <div className={`${b('row')} ${b('card-head')}`}>\n <div className={b('row-title')}>#{index}</div>\n {arrayItemButton}\n </div>\n <DynamicForm\n contentConfig={value}\n blockConfig={blockConfig.properties}\n onUpdate={(key, updateValue) =>\n onUpdate(`[${index}].${key}`, updateValue)\n }\n />\n </Card>\n );\n }\n default: {\n return null;\n }\n }\n },\n [blockConfig, haveItems, onDeleteItem, onReorderItem, onUpdate, values],\n );\n\n const renderInputs = React.useCallback(() => {\n if (haveItems) {\n const renderItems = values\n .map(renderInput)\n .filter(Boolean) as unknown as React.ReactNode[];\n return (\n <React.Fragment>\n {renderItems}\n <Button className={b('add-button')} onClick={onAddItem}>\n <Icon data={Plus} />\n {blockConfig.buttonText}\n </Button>\n </React.Fragment>\n );\n } else {\n return (\n <div className={b('empty')}>\n <Button className={b('add-button')} onClick={onAddItem}>\n <Icon data={Plus} />\n Please, add new item\n </Button>\n </div>\n );\n }\n }, [blockConfig.buttonText, haveItems, onAddItem, renderInput, values]);\n\n return (\n <FieldBase\n title={title}\n className={b(null, className)}\n onRefresh={(value) => onUpdate('', value)}\n expandable\n >\n <Card className={b('card')}>{renderInputs()}</Card>\n </FieldBase>\n );\n};\n\nexport default ArrayDynamicField;\n"]}
|