@gravity-ui/page-constructor 8.5.0-alpha.2 → 8.5.0-alpha.5
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_deprecated.d.ts +1 -1
- package/build/cjs/blocks/ExtendedFeatures/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/FilterBlock/index.d.ts +1 -1
- package/build/cjs/blocks/FilterBlock/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Form/index.d.ts +1 -1
- package/build/cjs/blocks/Form/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/cjs/blocks/HeaderSlider/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Icons/index.d.ts +1 -1
- package/build/cjs/blocks/Icons/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Info/index.d.ts +1 -1
- package/build/cjs/blocks/Info/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Map/index.d.ts +1 -1
- package/build/cjs/blocks/Map/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Media/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/PromoFeaturesBlock/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Questions/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Share/index.d.ts +1 -1
- package/build/cjs/blocks/Share/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Slider/index.d.ts +1 -1
- package/build/cjs/blocks/Slider/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Table/index.d.ts +1 -1
- package/build/cjs/blocks/Table/index_deprecated.d.ts +1 -1
- package/build/cjs/blocks/Tabs/index.d.ts +1 -1
- package/build/cjs/blocks/Tabs/index_deprecated.d.ts +1 -1
- package/build/cjs/form-builder-v2/CanvasContentContext.d.ts +18 -0
- package/build/cjs/form-builder-v2/CanvasContentContext.js +21 -0
- package/build/cjs/form-builder-v2/CanvasContentContext.js.map +1 -0
- package/build/cjs/form-builder-v2/FormBuilderV2.css +93 -0
- package/build/cjs/form-builder-v2/FormBuilderV2.d.ts +10 -0
- package/build/cjs/form-builder-v2/FormBuilderV2.js +123 -0
- package/build/cjs/form-builder-v2/FormBuilderV2.js.map +1 -0
- package/build/cjs/form-builder-v2/components/Canvas/Canvas.css +15 -0
- package/build/cjs/form-builder-v2/components/Canvas/Canvas.d.ts +8 -0
- package/build/cjs/form-builder-v2/components/Canvas/Canvas.js +17 -0
- package/build/cjs/form-builder-v2/components/Canvas/Canvas.js.map +1 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/CanvasCard.css +133 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/CanvasCard.d.ts +9 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/CanvasCard.js +72 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/CanvasCard.js.map +1 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/FieldPreview.d.ts +6 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/FieldPreview.js +44 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/FieldPreview.js.map +1 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.d.ts +9 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.js +20 -0
- package/build/cjs/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.js.map +1 -0
- package/build/cjs/form-builder-v2/components/ContentTab/ContentTab.css +22 -0
- package/build/cjs/form-builder-v2/components/ContentTab/ContentTab.d.ts +1 -0
- package/build/cjs/form-builder-v2/components/ContentTab/ContentTab.js +21 -0
- package/build/cjs/form-builder-v2/components/ContentTab/ContentTab.js.map +1 -0
- package/build/cjs/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.css +13 -0
- package/build/cjs/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.d.ts +7 -0
- package/build/cjs/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.js +24 -0
- package/build/cjs/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/FieldSettings.css +30 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/FieldSettings.d.ts +6 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/FieldSettings.js +49 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/FieldSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.d.ts +12 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.js +11 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/OptionsSettings.d.ts +12 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/OptionsSettings.js +38 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/OptionsSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/Row.d.ts +7 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/Row.js +9 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/Row.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SectionSettings.d.ts +9 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SectionSettings.js +40 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SectionSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SwitchSettings.d.ts +12 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SwitchSettings.js +11 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/SwitchSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.d.ts +12 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.js +11 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextSettings.d.ts +11 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextSettings.js +53 -0
- package/build/cjs/form-builder-v2/components/FieldSettings/fields/TextSettings.js.map +1 -0
- package/build/cjs/form-builder-v2/components/Inspector/Inspector.css +20 -0
- package/build/cjs/form-builder-v2/components/Inspector/Inspector.d.ts +1 -0
- package/build/cjs/form-builder-v2/components/Inspector/Inspector.js +20 -0
- package/build/cjs/form-builder-v2/components/Inspector/Inspector.js.map +1 -0
- package/build/cjs/form-builder-v2/components/Palette/Palette.css +56 -0
- package/build/cjs/form-builder-v2/components/Palette/Palette.d.ts +4 -0
- package/build/cjs/form-builder-v2/components/Palette/Palette.js +62 -0
- package/build/cjs/form-builder-v2/components/Palette/Palette.js.map +1 -0
- package/build/cjs/form-builder-v2/components/ResizeHandle/ResizeHandle.css +29 -0
- package/build/cjs/form-builder-v2/components/ResizeHandle/ResizeHandle.d.ts +9 -0
- package/build/cjs/form-builder-v2/components/ResizeHandle/ResizeHandle.js +98 -0
- package/build/cjs/form-builder-v2/components/ResizeHandle/ResizeHandle.js.map +1 -0
- package/build/cjs/form-builder-v2/components/SchemaPopup/SchemaPopup.css +49 -0
- package/build/cjs/form-builder-v2/components/SchemaPopup/SchemaPopup.d.ts +11 -0
- package/build/cjs/form-builder-v2/components/SchemaPopup/SchemaPopup.js +82 -0
- package/build/cjs/form-builder-v2/components/SchemaPopup/SchemaPopup.js.map +1 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/WhenEditor.css +24 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/WhenEditor.d.ts +8 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/WhenEditor.js +50 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/WhenEditor.js.map +1 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/utils.d.ts +24 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/utils.js +83 -0
- package/build/cjs/form-builder-v2/components/WhenEditor/utils.js.map +1 -0
- package/build/cjs/form-builder-v2/hooks/FormContext.d.ts +11 -0
- package/build/cjs/form-builder-v2/hooks/FormContext.js +22 -0
- package/build/cjs/form-builder-v2/hooks/FormContext.js.map +1 -0
- package/build/cjs/form-builder-v2/hooks/useFormFields.d.ts +23 -0
- package/build/cjs/form-builder-v2/hooks/useFormFields.js +144 -0
- package/build/cjs/form-builder-v2/hooks/useFormFields.js.map +1 -0
- package/build/cjs/form-builder-v2/index.d.ts +2 -0
- package/build/cjs/form-builder-v2/index.js +6 -0
- package/build/cjs/form-builder-v2/index.js.map +1 -0
- package/build/cjs/form-builder-v2/styles/variables.css +0 -0
- package/build/cjs/form-builder-v2/types.d.ts +32 -0
- package/build/cjs/form-builder-v2/types.js +3 -0
- package/build/cjs/form-builder-v2/types.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/cn.d.ts +2 -0
- package/build/cjs/form-builder-v2/utils/cn.js +7 -0
- package/build/cjs/form-builder-v2/utils/cn.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/dragData.d.ts +18 -0
- package/build/cjs/form-builder-v2/utils/dragData.js +18 -0
- package/build/cjs/form-builder-v2/utils/dragData.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldDefaults.d.ts +2 -0
- package/build/cjs/form-builder-v2/utils/fieldDefaults.js +51 -0
- package/build/cjs/form-builder-v2/utils/fieldDefaults.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldGroups.d.ts +3 -0
- package/build/cjs/form-builder-v2/utils/fieldGroups.js +26 -0
- package/build/cjs/form-builder-v2/utils/fieldGroups.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldMeta.d.ts +6 -0
- package/build/cjs/form-builder-v2/utils/fieldMeta.js +45 -0
- package/build/cjs/form-builder-v2/utils/fieldMeta.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldNames.d.ts +8 -0
- package/build/cjs/form-builder-v2/utils/fieldNames.js +75 -0
- package/build/cjs/form-builder-v2/utils/fieldNames.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldTree.d.ts +2 -0
- package/build/cjs/form-builder-v2/utils/fieldTree.js +7 -0
- package/build/cjs/form-builder-v2/utils/fieldTree.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/fieldTreeOps.d.ts +13 -0
- package/build/cjs/form-builder-v2/utils/fieldTreeOps.js +80 -0
- package/build/cjs/form-builder-v2/utils/fieldTreeOps.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/parseSchema.d.ts +9 -0
- package/build/cjs/form-builder-v2/utils/parseSchema.js +102 -0
- package/build/cjs/form-builder-v2/utils/parseSchema.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/stripIds.d.ts +3 -0
- package/build/cjs/form-builder-v2/utils/stripIds.js +12 -0
- package/build/cjs/form-builder-v2/utils/stripIds.js.map +1 -0
- package/build/cjs/form-builder-v2/utils/treeWalk.d.ts +4 -0
- package/build/cjs/form-builder-v2/utils/treeWalk.js +45 -0
- package/build/cjs/form-builder-v2/utils/treeWalk.js.map +1 -0
- package/build/cjs/form-generator-v2/components/constants.d.ts +11 -11
- package/build/cjs/form-generator-v2/index.d.ts +2 -0
- package/build/cjs/form-generator-v2/index.js +8 -0
- package/build/cjs/form-generator-v2/index.js.map +1 -0
- package/build/esm/blocks/ContentLayout/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/ExtendedFeatures/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/FilterBlock/index.d.ts +1 -1
- package/build/esm/blocks/FilterBlock/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Form/index.d.ts +1 -1
- package/build/esm/blocks/Form/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/HeaderSlider/index.d.ts +1 -1
- package/build/esm/blocks/HeaderSlider/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Icons/index.d.ts +1 -1
- package/build/esm/blocks/Icons/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Info/index.d.ts +1 -1
- package/build/esm/blocks/Info/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Map/index.d.ts +1 -1
- package/build/esm/blocks/Map/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Media/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/PromoFeaturesBlock/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Questions/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Share/index.d.ts +1 -1
- package/build/esm/blocks/Share/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Slider/index.d.ts +1 -1
- package/build/esm/blocks/Slider/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Table/index.d.ts +1 -1
- package/build/esm/blocks/Table/index_deprecated.d.ts +1 -1
- package/build/esm/blocks/Tabs/index.d.ts +1 -1
- package/build/esm/blocks/Tabs/index_deprecated.d.ts +1 -1
- package/build/esm/form-builder-v2/CanvasContentContext.d.ts +18 -0
- package/build/esm/form-builder-v2/CanvasContentContext.js +15 -0
- package/build/esm/form-builder-v2/CanvasContentContext.js.map +1 -0
- package/build/esm/form-builder-v2/FormBuilderV2.css +93 -0
- package/build/esm/form-builder-v2/FormBuilderV2.d.ts +11 -0
- package/build/esm/form-builder-v2/FormBuilderV2.js +119 -0
- package/build/esm/form-builder-v2/FormBuilderV2.js.map +1 -0
- package/build/esm/form-builder-v2/components/Canvas/Canvas.css +15 -0
- package/build/esm/form-builder-v2/components/Canvas/Canvas.d.ts +9 -0
- package/build/esm/form-builder-v2/components/Canvas/Canvas.js +14 -0
- package/build/esm/form-builder-v2/components/Canvas/Canvas.js.map +1 -0
- package/build/esm/form-builder-v2/components/CanvasCard/CanvasCard.css +133 -0
- package/build/esm/form-builder-v2/components/CanvasCard/CanvasCard.d.ts +10 -0
- package/build/esm/form-builder-v2/components/CanvasCard/CanvasCard.js +68 -0
- package/build/esm/form-builder-v2/components/CanvasCard/CanvasCard.js.map +1 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/FieldPreview.d.ts +6 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/FieldPreview.js +39 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/FieldPreview.js.map +1 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.d.ts +9 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.js +16 -0
- package/build/esm/form-builder-v2/components/CanvasCard/components/SectionChildrenDropZone.js.map +1 -0
- package/build/esm/form-builder-v2/components/ContentTab/ContentTab.css +22 -0
- package/build/esm/form-builder-v2/components/ContentTab/ContentTab.d.ts +2 -0
- package/build/esm/form-builder-v2/components/ContentTab/ContentTab.js +17 -0
- package/build/esm/form-builder-v2/components/ContentTab/ContentTab.js.map +1 -0
- package/build/esm/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.css +13 -0
- package/build/esm/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.d.ts +8 -0
- package/build/esm/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.js +21 -0
- package/build/esm/form-builder-v2/components/DragOverlayPreview/DragOverlayPreview.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/FieldSettings.css +30 -0
- package/build/esm/form-builder-v2/components/FieldSettings/FieldSettings.d.ts +7 -0
- package/build/esm/form-builder-v2/components/FieldSettings/FieldSettings.js +45 -0
- package/build/esm/form-builder-v2/components/FieldSettings/FieldSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.d.ts +12 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.js +6 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/ColorInputSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/OptionsSettings.d.ts +12 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/OptionsSettings.js +33 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/OptionsSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/Row.d.ts +7 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/Row.js +5 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/Row.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SectionSettings.d.ts +9 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SectionSettings.js +35 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SectionSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SwitchSettings.d.ts +12 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SwitchSettings.js +6 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/SwitchSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.d.ts +12 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.js +6 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextFieldSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextSettings.d.ts +11 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextSettings.js +48 -0
- package/build/esm/form-builder-v2/components/FieldSettings/fields/TextSettings.js.map +1 -0
- package/build/esm/form-builder-v2/components/Inspector/Inspector.css +20 -0
- package/build/esm/form-builder-v2/components/Inspector/Inspector.d.ts +2 -0
- package/build/esm/form-builder-v2/components/Inspector/Inspector.js +16 -0
- package/build/esm/form-builder-v2/components/Inspector/Inspector.js.map +1 -0
- package/build/esm/form-builder-v2/components/Palette/Palette.css +56 -0
- package/build/esm/form-builder-v2/components/Palette/Palette.d.ts +5 -0
- package/build/esm/form-builder-v2/components/Palette/Palette.js +58 -0
- package/build/esm/form-builder-v2/components/Palette/Palette.js.map +1 -0
- package/build/esm/form-builder-v2/components/ResizeHandle/ResizeHandle.css +29 -0
- package/build/esm/form-builder-v2/components/ResizeHandle/ResizeHandle.d.ts +10 -0
- package/build/esm/form-builder-v2/components/ResizeHandle/ResizeHandle.js +94 -0
- package/build/esm/form-builder-v2/components/ResizeHandle/ResizeHandle.js.map +1 -0
- package/build/esm/form-builder-v2/components/SchemaPopup/SchemaPopup.css +49 -0
- package/build/esm/form-builder-v2/components/SchemaPopup/SchemaPopup.d.ts +12 -0
- package/build/esm/form-builder-v2/components/SchemaPopup/SchemaPopup.js +78 -0
- package/build/esm/form-builder-v2/components/SchemaPopup/SchemaPopup.js.map +1 -0
- package/build/esm/form-builder-v2/components/WhenEditor/WhenEditor.css +24 -0
- package/build/esm/form-builder-v2/components/WhenEditor/WhenEditor.d.ts +9 -0
- package/build/esm/form-builder-v2/components/WhenEditor/WhenEditor.js +46 -0
- package/build/esm/form-builder-v2/components/WhenEditor/WhenEditor.js.map +1 -0
- package/build/esm/form-builder-v2/components/WhenEditor/utils.d.ts +24 -0
- package/build/esm/form-builder-v2/components/WhenEditor/utils.js +76 -0
- package/build/esm/form-builder-v2/components/WhenEditor/utils.js.map +1 -0
- package/build/esm/form-builder-v2/hooks/FormContext.d.ts +11 -0
- package/build/esm/form-builder-v2/hooks/FormContext.js +16 -0
- package/build/esm/form-builder-v2/hooks/FormContext.js.map +1 -0
- package/build/esm/form-builder-v2/hooks/useFormFields.d.ts +23 -0
- package/build/esm/form-builder-v2/hooks/useFormFields.js +139 -0
- package/build/esm/form-builder-v2/hooks/useFormFields.js.map +1 -0
- package/build/esm/form-builder-v2/index.d.ts +2 -0
- package/build/esm/form-builder-v2/index.js +3 -0
- package/build/esm/form-builder-v2/index.js.map +1 -0
- package/build/esm/form-builder-v2/styles/variables.css +0 -0
- package/build/esm/form-builder-v2/types.d.ts +32 -0
- package/build/esm/form-builder-v2/types.js +2 -0
- package/build/esm/form-builder-v2/types.js.map +1 -0
- package/build/esm/form-builder-v2/utils/cn.d.ts +2 -0
- package/build/esm/form-builder-v2/utils/cn.js +4 -0
- package/build/esm/form-builder-v2/utils/cn.js.map +1 -0
- package/build/esm/form-builder-v2/utils/dragData.d.ts +18 -0
- package/build/esm/form-builder-v2/utils/dragData.js +11 -0
- package/build/esm/form-builder-v2/utils/dragData.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldDefaults.d.ts +2 -0
- package/build/esm/form-builder-v2/utils/fieldDefaults.js +47 -0
- package/build/esm/form-builder-v2/utils/fieldDefaults.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldGroups.d.ts +3 -0
- package/build/esm/form-builder-v2/utils/fieldGroups.js +21 -0
- package/build/esm/form-builder-v2/utils/fieldGroups.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldMeta.d.ts +6 -0
- package/build/esm/form-builder-v2/utils/fieldMeta.js +42 -0
- package/build/esm/form-builder-v2/utils/fieldMeta.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldNames.d.ts +8 -0
- package/build/esm/form-builder-v2/utils/fieldNames.js +66 -0
- package/build/esm/form-builder-v2/utils/fieldNames.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldTree.d.ts +2 -0
- package/build/esm/form-builder-v2/utils/fieldTree.js +3 -0
- package/build/esm/form-builder-v2/utils/fieldTree.js.map +1 -0
- package/build/esm/form-builder-v2/utils/fieldTreeOps.d.ts +13 -0
- package/build/esm/form-builder-v2/utils/fieldTreeOps.js +69 -0
- package/build/esm/form-builder-v2/utils/fieldTreeOps.js.map +1 -0
- package/build/esm/form-builder-v2/utils/parseSchema.d.ts +9 -0
- package/build/esm/form-builder-v2/utils/parseSchema.js +98 -0
- package/build/esm/form-builder-v2/utils/parseSchema.js.map +1 -0
- package/build/esm/form-builder-v2/utils/stripIds.d.ts +3 -0
- package/build/esm/form-builder-v2/utils/stripIds.js +8 -0
- package/build/esm/form-builder-v2/utils/stripIds.js.map +1 -0
- package/build/esm/form-builder-v2/utils/treeWalk.d.ts +4 -0
- package/build/esm/form-builder-v2/utils/treeWalk.js +39 -0
- package/build/esm/form-builder-v2/utils/treeWalk.js.map +1 -0
- package/build/esm/form-generator-v2/components/constants.d.ts +11 -11
- package/build/esm/form-generator-v2/index.d.ts +2 -0
- package/build/esm/form-generator-v2/index.js +3 -0
- package/build/esm/form-generator-v2/index.js.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { When } from "../../../form-generator-v2/types.js";
|
|
2
|
+
export type Condition = {
|
|
3
|
+
field: string;
|
|
4
|
+
operator: '===' | '!==';
|
|
5
|
+
value: string | boolean;
|
|
6
|
+
};
|
|
7
|
+
export type Combinator = {
|
|
8
|
+
operator: '&&' | '||';
|
|
9
|
+
};
|
|
10
|
+
export declare const OPERATOR_OPTIONS: {
|
|
11
|
+
value: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const COMBINATOR_OPTIONS: {
|
|
15
|
+
value: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const parse: (when: When | undefined) => {
|
|
19
|
+
conditions: Condition[];
|
|
20
|
+
combinators: Combinator[];
|
|
21
|
+
};
|
|
22
|
+
export declare const serialize: (conditions: Condition[], combinators: Combinator[]) => When | undefined;
|
|
23
|
+
export declare const coerceValue: (raw: string) => string | boolean;
|
|
24
|
+
export declare const displayValue: (value: string | boolean | undefined) => string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const OPERATOR_OPTIONS = [
|
|
2
|
+
{ value: '===', content: 'is' },
|
|
3
|
+
{ value: '!==', content: 'is not' },
|
|
4
|
+
];
|
|
5
|
+
export const COMBINATOR_OPTIONS = [
|
|
6
|
+
{ value: '&&', content: 'AND' },
|
|
7
|
+
{ value: '||', content: 'OR' },
|
|
8
|
+
];
|
|
9
|
+
export const parse = (when) => {
|
|
10
|
+
const conditions = [];
|
|
11
|
+
const combinators = [];
|
|
12
|
+
if (!when)
|
|
13
|
+
return { conditions, combinators };
|
|
14
|
+
let lastWasCombinator = false;
|
|
15
|
+
for (const entry of when) {
|
|
16
|
+
const isCondition = Boolean(entry.field) && (entry.operator === '===' || entry.operator === '!==');
|
|
17
|
+
const isCombinator = !entry.field && (entry.operator === '&&' || entry.operator === '||');
|
|
18
|
+
if (isCondition) {
|
|
19
|
+
conditions.push({
|
|
20
|
+
field: entry.field,
|
|
21
|
+
operator: entry.operator,
|
|
22
|
+
value: entry.value ?? '',
|
|
23
|
+
});
|
|
24
|
+
lastWasCombinator = false;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (isCombinator) {
|
|
28
|
+
if (conditions.length === 0 || lastWasCombinator)
|
|
29
|
+
continue;
|
|
30
|
+
combinators.push({ operator: entry.operator });
|
|
31
|
+
lastWasCombinator = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (lastWasCombinator) {
|
|
35
|
+
combinators.pop();
|
|
36
|
+
}
|
|
37
|
+
while (combinators.length < conditions.length - 1) {
|
|
38
|
+
combinators.push({ operator: '&&' });
|
|
39
|
+
}
|
|
40
|
+
if (combinators.length > Math.max(0, conditions.length - 1)) {
|
|
41
|
+
combinators.length = Math.max(0, conditions.length - 1);
|
|
42
|
+
}
|
|
43
|
+
return { conditions, combinators };
|
|
44
|
+
};
|
|
45
|
+
export const serialize = (conditions, combinators) => {
|
|
46
|
+
if (conditions.length === 0)
|
|
47
|
+
return undefined;
|
|
48
|
+
const out = [];
|
|
49
|
+
conditions.forEach((cond, i) => {
|
|
50
|
+
if (i > 0) {
|
|
51
|
+
const combinator = combinators[i - 1] ?? { operator: '&&' };
|
|
52
|
+
out.push({ operator: combinator.operator });
|
|
53
|
+
}
|
|
54
|
+
out.push({
|
|
55
|
+
field: cond.field,
|
|
56
|
+
operator: cond.operator,
|
|
57
|
+
value: cond.value,
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return out;
|
|
61
|
+
};
|
|
62
|
+
export const coerceValue = (raw) => {
|
|
63
|
+
if (raw === 'true')
|
|
64
|
+
return true;
|
|
65
|
+
if (raw === 'false')
|
|
66
|
+
return false;
|
|
67
|
+
return raw;
|
|
68
|
+
};
|
|
69
|
+
export const displayValue = (value) => {
|
|
70
|
+
if (value === true)
|
|
71
|
+
return 'true';
|
|
72
|
+
if (value === false)
|
|
73
|
+
return 'false';
|
|
74
|
+
return value ?? '';
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"../../../../../src","sources":["form-builder-v2/components/WhenEditor/utils.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAC;IAC7B,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAC;CACpC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,EAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC;IAC7B,EAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,CACjB,IAAsB,EAC8B,EAAE;IACtD,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,MAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC;IAE5C,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,WAAW,GACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC;QACnF,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAE1F,IAAI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U,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACR,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;YAC1D,GAAG,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAC,CAAC,CAAC;QAC9C,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;SACpB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAoB,EAAE;IACzD,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmC,EAAU,EAAE;IACxE,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,OAAO,CAAC;IACpC,OAAO,KAAK,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import type {When} from '../../../form-generator-v2/types';\n\nexport type Condition = {field: string; operator: '===' | '!=='; value: string | boolean};\nexport type Combinator = {operator: '&&' | '||'};\n\nexport const OPERATOR_OPTIONS = [\n {value: '===', content: 'is'},\n {value: '!==', content: 'is not'},\n];\n\nexport const COMBINATOR_OPTIONS = [\n {value: '&&', content: 'AND'},\n {value: '||', content: 'OR'},\n];\n\nexport const parse = (\n when: When | undefined,\n): {conditions: Condition[]; combinators: Combinator[]} => {\n const conditions: Condition[] = [];\n const combinators: Combinator[] = [];\n if (!when) return {conditions, combinators};\n\n let lastWasCombinator = false;\n\n for (const entry of when) {\n const isCondition =\n Boolean(entry.field) && (entry.operator === '===' || entry.operator === '!==');\n const isCombinator = !entry.field && (entry.operator === '&&' || entry.operator === '||');\n\n if (isCondition) {\n conditions.push({\n field: entry.field as string,\n operator: entry.operator as '===' | '!==',\n value: entry.value ?? '',\n });\n lastWasCombinator = false;\n continue;\n }\n\n if (isCombinator) {\n if (conditions.length === 0 || lastWasCombinator) continue;\n combinators.push({operator: entry.operator as '&&' | '||'});\n lastWasCombinator = true;\n }\n }\n\n if (lastWasCombinator) {\n combinators.pop();\n }\n\n while (combinators.length < conditions.length - 1) {\n combinators.push({operator: '&&'});\n }\n\n if (combinators.length > Math.max(0, conditions.length - 1)) {\n combinators.length = Math.max(0, conditions.length - 1);\n }\n\n return {conditions, combinators};\n};\n\nexport const serialize = (conditions: Condition[], combinators: Combinator[]): When | undefined => {\n if (conditions.length === 0) return undefined;\n const out: When = [];\n conditions.forEach((cond, i) => {\n if (i > 0) {\n const combinator = combinators[i - 1] ?? {operator: '&&'};\n out.push({operator: combinator.operator});\n }\n out.push({\n field: cond.field,\n operator: cond.operator,\n value: cond.value,\n });\n });\n return out;\n};\n\nexport const coerceValue = (raw: string): string | boolean => {\n if (raw === 'true') return true;\n if (raw === 'false') return false;\n return raw;\n};\n\nexport const displayValue = (value: string | boolean | undefined): string => {\n if (value === true) return 'true';\n if (value === false) return 'false';\n return value ?? '';\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FormContextType, FormField } from "../types.js";
|
|
3
|
+
export declare const FormContext: React.Context<FormContextType | null>;
|
|
4
|
+
interface FormProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
formFields: FormField[];
|
|
7
|
+
onChange?: (fields: FormField[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const FormProvider: ({ children, formFields, onChange }: FormProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const useFormContext: () => FormContextType;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useFormFields } from "./useFormFields.js";
|
|
4
|
+
export const FormContext = React.createContext(null);
|
|
5
|
+
export const FormProvider = ({ children, formFields, onChange }) => {
|
|
6
|
+
const value = useFormFields({ initialFields: formFields, onChange });
|
|
7
|
+
return _jsx(FormContext.Provider, { value: value, children: children });
|
|
8
|
+
};
|
|
9
|
+
export const useFormContext = () => {
|
|
10
|
+
const context = React.useContext(FormContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error('useFormContext must be used within a FormProvider');
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=FormContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormContext.js","sourceRoot":"../../../../src","sources":["form-builder-v2/hooks/FormContext.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAC,aAAa,EAAC,2BAAwB;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAyB,IAAI,CAAC,CAAC;AAQ7E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAoB,EAAE,EAAE;IAChF,MAAM,KAAK,GAAG,aAAa,CAAC,EAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAC,CAAC,CAAC;IACnE,OAAO,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AACjF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAoB,EAAE;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {FormContextType, FormField} from '../types';\n\nimport {useFormFields} from './useFormFields';\n\nexport const FormContext = React.createContext<FormContextType | null>(null);\n\ninterface FormProviderProps {\n children: React.ReactNode;\n formFields: FormField[];\n onChange?: (fields: FormField[]) => void;\n}\n\nexport const FormProvider = ({children, formFields, onChange}: FormProviderProps) => {\n const value = useFormFields({initialFields: formFields, onChange});\n return <FormContext.Provider value={value}>{children}</FormContext.Provider>;\n};\n\nexport const useFormContext = (): FormContextType => {\n const context = React.useContext(FormContext);\n if (!context) {\n throw new Error('useFormContext must be used within a FormProvider');\n }\n return context;\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BuilderFieldType, FieldUpdate, FormField } from "../types.js";
|
|
2
|
+
interface UseFormFieldsProps {
|
|
3
|
+
initialFields: FormField[];
|
|
4
|
+
onChange?: (fields: FormField[]) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useFormFields: ({ initialFields, onChange }: UseFormFieldsProps) => {
|
|
7
|
+
formFields: FormField[];
|
|
8
|
+
selectedFieldId: string | null;
|
|
9
|
+
addField: (type: BuilderFieldType) => void;
|
|
10
|
+
addFieldToSection: (sectionId: string, type: BuilderFieldType) => void;
|
|
11
|
+
insertFieldBefore: (targetId: string, type: BuilderFieldType) => void;
|
|
12
|
+
insertFieldAfter: (targetId: string, type: BuilderFieldType) => void;
|
|
13
|
+
moveFieldToSection: (fieldId: string, targetSectionId: string) => void;
|
|
14
|
+
removeField: (fieldId: string) => void;
|
|
15
|
+
duplicateField: (fieldId: string) => void;
|
|
16
|
+
updateField: (fieldId: string, updates: FieldUpdate) => void;
|
|
17
|
+
moveFieldUp: (fieldId: string) => void;
|
|
18
|
+
moveFieldDown: (fieldId: string) => void;
|
|
19
|
+
setAllFields: (next: FormField[]) => void;
|
|
20
|
+
resetForm: () => void;
|
|
21
|
+
selectField: (fieldId: string | null) => void;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createDefaultField } from "../utils/fieldDefaults.js";
|
|
3
|
+
import { collectNames, maxIdNumericSuffix, prefixNameForArrayMode, stripArrayModePrefix, } from "../utils/fieldNames.js";
|
|
4
|
+
import { findFieldById } from "../utils/fieldTree.js";
|
|
5
|
+
import { addChildToSectionDeep, containsId, duplicateFieldDeep, insertAtTargetDeep, isArrayModeSection, removeFieldDeep, swapInListDeep, updateFieldDeep, } from "../utils/fieldTreeOps.js";
|
|
6
|
+
export const useFormFields = ({ initialFields, onChange }) => {
|
|
7
|
+
const [formFields, setFormFields] = React.useState(initialFields);
|
|
8
|
+
const [selectedFieldId, setSelectedFieldId] = React.useState(null);
|
|
9
|
+
const idCounter = React.useRef(maxIdNumericSuffix(initialFields) + 1);
|
|
10
|
+
const generateId = React.useCallback(() => {
|
|
11
|
+
const id = `fb2_${idCounter.current}`;
|
|
12
|
+
idCounter.current += 1;
|
|
13
|
+
return id;
|
|
14
|
+
}, []);
|
|
15
|
+
const generateName = React.useCallback(() => `field_${idCounter.current}`, []);
|
|
16
|
+
const commit = React.useCallback((next) => {
|
|
17
|
+
setFormFields(next);
|
|
18
|
+
onChange?.(next);
|
|
19
|
+
}, [onChange]);
|
|
20
|
+
const addField = React.useCallback((type) => {
|
|
21
|
+
const id = generateId();
|
|
22
|
+
const name = generateName();
|
|
23
|
+
const newField = createDefaultField(type, name, id);
|
|
24
|
+
commit([...formFields, newField]);
|
|
25
|
+
}, [commit, formFields, generateId, generateName]);
|
|
26
|
+
const addFieldToSection = React.useCallback((sectionId, type) => {
|
|
27
|
+
const id = generateId();
|
|
28
|
+
const baseName = generateName();
|
|
29
|
+
const arrayMode = isArrayModeSection(formFields, sectionId);
|
|
30
|
+
const name = arrayMode ? prefixNameForArrayMode(baseName) : baseName;
|
|
31
|
+
const newChild = createDefaultField(type, name, id);
|
|
32
|
+
commit(addChildToSectionDeep(formFields, sectionId, newChild));
|
|
33
|
+
}, [commit, formFields, generateId, generateName]);
|
|
34
|
+
const insertFieldRelative = React.useCallback((targetId, type, offset) => {
|
|
35
|
+
const makeField = (arrayMode) => {
|
|
36
|
+
const id = generateId();
|
|
37
|
+
const baseName = generateName();
|
|
38
|
+
const name = arrayMode ? prefixNameForArrayMode(baseName) : baseName;
|
|
39
|
+
return createDefaultField(type, name, id);
|
|
40
|
+
};
|
|
41
|
+
const result = insertAtTargetDeep(formFields, targetId, offset, makeField);
|
|
42
|
+
if (result === null) {
|
|
43
|
+
const fallback = makeField(false);
|
|
44
|
+
commit([...formFields, fallback]);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
commit(result);
|
|
48
|
+
}, [commit, formFields, generateId, generateName]);
|
|
49
|
+
const insertFieldBefore = React.useCallback((targetId, type) => insertFieldRelative(targetId, type, 0), [insertFieldRelative]);
|
|
50
|
+
const insertFieldAfter = React.useCallback((targetId, type) => insertFieldRelative(targetId, type, 1), [insertFieldRelative]);
|
|
51
|
+
const removeField = React.useCallback((fieldId) => {
|
|
52
|
+
commit(removeFieldDeep(formFields, fieldId));
|
|
53
|
+
}, [commit, formFields]);
|
|
54
|
+
const moveFieldToSection = React.useCallback((fieldId, targetSectionId) => {
|
|
55
|
+
if (fieldId === targetSectionId)
|
|
56
|
+
return;
|
|
57
|
+
const sourceField = findFieldById(formFields, fieldId);
|
|
58
|
+
if (!sourceField)
|
|
59
|
+
return;
|
|
60
|
+
const targetField = findFieldById(formFields, targetSectionId);
|
|
61
|
+
if (!targetField || targetField.type !== 'section') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (sourceField.type === 'section' && containsId(sourceField, targetSectionId)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const withoutField = removeFieldDeep(formFields, fieldId);
|
|
68
|
+
const targetIsArray = isArrayModeSection(withoutField, targetSectionId);
|
|
69
|
+
let movedField = sourceField;
|
|
70
|
+
if (sourceField.type !== 'section' && sourceField.type !== 'text') {
|
|
71
|
+
const currentHasIndex = sourceField.name.includes('{{index}}');
|
|
72
|
+
if (targetIsArray && !currentHasIndex) {
|
|
73
|
+
movedField = {
|
|
74
|
+
...sourceField,
|
|
75
|
+
name: prefixNameForArrayMode(sourceField.name),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (!targetIsArray && currentHasIndex) {
|
|
79
|
+
movedField = {
|
|
80
|
+
...sourceField,
|
|
81
|
+
name: stripArrayModePrefix(sourceField.name),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const result = addChildToSectionDeep(withoutField, targetSectionId, movedField);
|
|
86
|
+
commit(result);
|
|
87
|
+
}, [commit, formFields]);
|
|
88
|
+
const duplicateField = React.useCallback((fieldId) => {
|
|
89
|
+
const existingNames = collectNames(formFields);
|
|
90
|
+
const result = duplicateFieldDeep(formFields, fieldId, generateId, existingNames);
|
|
91
|
+
if (result !== null) {
|
|
92
|
+
commit(result);
|
|
93
|
+
}
|
|
94
|
+
}, [commit, formFields, generateId]);
|
|
95
|
+
const updateField = React.useCallback((fieldId, updates) => {
|
|
96
|
+
commit(updateFieldDeep(formFields, fieldId, updates));
|
|
97
|
+
}, [commit, formFields]);
|
|
98
|
+
const moveFieldUp = React.useCallback((fieldId) => {
|
|
99
|
+
const result = swapInListDeep(formFields, fieldId, -1);
|
|
100
|
+
if (result.handled) {
|
|
101
|
+
commit(result.fields);
|
|
102
|
+
}
|
|
103
|
+
}, [commit, formFields]);
|
|
104
|
+
const moveFieldDown = React.useCallback((fieldId) => {
|
|
105
|
+
const result = swapInListDeep(formFields, fieldId, 1);
|
|
106
|
+
if (result.handled) {
|
|
107
|
+
commit(result.fields);
|
|
108
|
+
}
|
|
109
|
+
}, [commit, formFields]);
|
|
110
|
+
const setAllFields = React.useCallback((next) => {
|
|
111
|
+
idCounter.current = Math.max(idCounter.current, maxIdNumericSuffix(next) + 1);
|
|
112
|
+
commit(next);
|
|
113
|
+
}, [commit]);
|
|
114
|
+
const resetForm = React.useCallback(() => {
|
|
115
|
+
commit([]);
|
|
116
|
+
setSelectedFieldId(null);
|
|
117
|
+
}, [commit]);
|
|
118
|
+
const selectField = React.useCallback((fieldId) => {
|
|
119
|
+
setSelectedFieldId(fieldId);
|
|
120
|
+
}, []);
|
|
121
|
+
return {
|
|
122
|
+
formFields,
|
|
123
|
+
selectedFieldId,
|
|
124
|
+
addField,
|
|
125
|
+
addFieldToSection,
|
|
126
|
+
insertFieldBefore,
|
|
127
|
+
insertFieldAfter,
|
|
128
|
+
moveFieldToSection,
|
|
129
|
+
removeField,
|
|
130
|
+
duplicateField,
|
|
131
|
+
updateField,
|
|
132
|
+
moveFieldUp,
|
|
133
|
+
moveFieldDown,
|
|
134
|
+
setAllFields,
|
|
135
|
+
resetForm,
|
|
136
|
+
selectField,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=useFormFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormFields.js","sourceRoot":"../../../../src","sources":["form-builder-v2/hooks/useFormFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,kBAAkB,EAAC,kCAA+B;AAC1D,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACvB,+BAA4B;AAC7B,OAAO,EAAC,aAAa,EAAC,8BAA2B;AACjD,OAAO,EACH,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,E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M,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,EACD,CAAC,MAAM,CAAC,CACX,CAAC;IAEF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACrC,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,OAAsB,EAAE,EAAE;QAC7D,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACH,UAAU;QACV,eAAe;QACf,QAAQ;QACR,iBAAiB;QACjB,iBAAiB;QACjB,gBAAgB;QAChB,kBAAkB;QAClB,WAAW;QACX,cAAc;QACd,WAAW;QACX,WAAW;QACX,aAAa;QACb,YAAY;QACZ,SAAS;QACT,WAAW;KACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BuilderFieldType, FieldUpdate, FormField} from '../types';\nimport {createDefaultField} from '../utils/fieldDefaults';\nimport {\n collectNames,\n maxIdNumericSuffix,\n prefixNameForArrayMode,\n stripArrayModePrefix,\n} from '../utils/fieldNames';\nimport {findFieldById} from '../utils/fieldTree';\nimport {\n addChildToSectionDeep,\n containsId,\n duplicateFieldDeep,\n insertAtTargetDeep,\n isArrayModeSection,\n removeFieldDeep,\n swapInListDeep,\n updateFieldDeep,\n} from '../utils/fieldTreeOps';\n\ninterface UseFormFieldsProps {\n initialFields: FormField[];\n onChange?: (fields: FormField[]) => void;\n}\n\nexport const useFormFields = ({initialFields, onChange}: UseFormFieldsProps) => {\n const [formFields, setFormFields] = React.useState<FormField[]>(initialFields);\n const [selectedFieldId, setSelectedFieldId] = React.useState<string | null>(null);\n const idCounter = React.useRef<number>(maxIdNumericSuffix(initialFields) + 1);\n\n const generateId = React.useCallback(() => {\n const id = `fb2_${idCounter.current}`;\n idCounter.current += 1;\n return id;\n }, []);\n\n const generateName = React.useCallback(() => `field_${idCounter.current}`, []);\n\n const commit = React.useCallback(\n (next: FormField[]) => {\n setFormFields(next);\n onChange?.(next);\n },\n [onChange],\n );\n\n const addField = React.useCallback(\n (type: BuilderFieldType) => {\n const id = generateId();\n const name = generateName();\n const newField = createDefaultField(type, name, id);\n commit([...formFields, newField]);\n },\n [commit, formFields, generateId, generateName],\n );\n\n const addFieldToSection = React.useCallback(\n (sectionId: string, type: BuilderFieldType) => {\n const id = generateId();\n const baseName = generateName();\n const arrayMode = isArrayModeSection(formFields, sectionId);\n const name = arrayMode ? prefixNameForArrayMode(baseName) : baseName;\n const newChild = createDefaultField(type, name, id);\n commit(addChildToSectionDeep(formFields, sectionId, newChild));\n },\n [commit, formFields, generateId, generateName],\n );\n\n const insertFieldRelative = React.useCallback(\n (targetId: string, type: BuilderFieldType, offset: 0 | 1) => {\n const makeField = (arrayMode: boolean): FormField => {\n const id = generateId();\n const baseName = generateName();\n const name = arrayMode ? prefixNameForArrayMode(baseName) : baseName;\n return createDefaultField(type, name, id);\n };\n const result = insertAtTargetDeep(formFields, targetId, offset, makeField);\n if (result === null) {\n const fallback = makeField(false);\n commit([...formFields, fallback]);\n return;\n }\n commit(result);\n },\n [commit, formFields, generateId, generateName],\n );\n\n const insertFieldBefore = React.useCallback(\n (targetId: string, type: BuilderFieldType) => insertFieldRelative(targetId, type, 0),\n [insertFieldRelative],\n );\n\n const insertFieldAfter = React.useCallback(\n (targetId: string, type: BuilderFieldType) => insertFieldRelative(targetId, type, 1),\n [insertFieldRelative],\n );\n\n const removeField = React.useCallback(\n (fieldId: string) => {\n commit(removeFieldDeep(formFields, fieldId));\n },\n [commit, formFields],\n );\n\n const moveFieldToSection = React.useCallback(\n (fieldId: string, targetSectionId: string) => {\n if (fieldId === targetSectionId) return;\n\n const sourceField = findFieldById(formFields, fieldId);\n if (!sourceField) return;\n\n const targetField = findFieldById(formFields, targetSectionId);\n if (!targetField || targetField.type !== 'section') {\n return;\n }\n\n if (sourceField.type === 'section' && containsId(sourceField, targetSectionId)) {\n return;\n }\n\n const withoutField = removeFieldDeep(formFields, fieldId);\n const targetIsArray = isArrayModeSection(withoutField, targetSectionId);\n\n let movedField = sourceField;\n if (sourceField.type !== 'section' && sourceField.type !== 'text') {\n const currentHasIndex = sourceField.name.includes('{{index}}');\n if (targetIsArray && !currentHasIndex) {\n movedField = {\n ...sourceField,\n name: prefixNameForArrayMode(sourceField.name),\n };\n } else if (!targetIsArray && currentHasIndex) {\n movedField = {\n ...sourceField,\n name: stripArrayModePrefix(sourceField.name),\n };\n }\n }\n\n const result = addChildToSectionDeep(withoutField, targetSectionId, movedField);\n commit(result);\n },\n [commit, formFields],\n );\n\n const duplicateField = React.useCallback(\n (fieldId: string) => {\n const existingNames = collectNames(formFields);\n const result = duplicateFieldDeep(formFields, fieldId, generateId, existingNames);\n if (result !== null) {\n commit(result);\n }\n },\n [commit, formFields, generateId],\n );\n\n const updateField = React.useCallback(\n (fieldId: string, updates: FieldUpdate) => {\n commit(updateFieldDeep(formFields, fieldId, updates));\n },\n [commit, formFields],\n );\n\n const moveFieldUp = React.useCallback(\n (fieldId: string) => {\n const result = swapInListDeep(formFields, fieldId, -1);\n if (result.handled) {\n commit(result.fields);\n }\n },\n [commit, formFields],\n );\n\n const moveFieldDown = React.useCallback(\n (fieldId: string) => {\n const result = swapInListDeep(formFields, fieldId, 1);\n if (result.handled) {\n commit(result.fields);\n }\n },\n [commit, formFields],\n );\n\n const setAllFields = React.useCallback(\n (next: FormField[]) => {\n idCounter.current = Math.max(idCounter.current, maxIdNumericSuffix(next) + 1);\n commit(next);\n },\n [commit],\n );\n\n const resetForm = React.useCallback(() => {\n commit([]);\n setSelectedFieldId(null);\n }, [commit]);\n\n const selectField = React.useCallback((fieldId: string | null) => {\n setSelectedFieldId(fieldId);\n }, []);\n\n return {\n formFields,\n selectedFieldId,\n addField,\n addFieldToSection,\n insertFieldBefore,\n insertFieldAfter,\n moveFieldToSection,\n removeField,\n duplicateField,\n updateField,\n moveFieldUp,\n moveFieldDown,\n setAllFields,\n resetForm,\n selectField,\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["form-builder-v2/index.ts"],"names":[],"mappings":"AAAA,mCAAgC;AAChC,2BAAwB","sourcesContent":["export * from './FormBuilderV2';\nexport * from './types';\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ColorField, SectionField, SegmentedRadioGroupField, SelectField, SwitchField, Text, TextField } from "../form-generator-v2/types.js";
|
|
2
|
+
type LeafField = TextField | SelectField | SegmentedRadioGroupField | Text | SwitchField | ColorField;
|
|
3
|
+
export type BuilderLeafField = LeafField & {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export type BuilderSectionField = Omit<SectionField, 'fields'> & {
|
|
7
|
+
id: string;
|
|
8
|
+
fields: FormField[];
|
|
9
|
+
};
|
|
10
|
+
export type FormField = BuilderLeafField | BuilderSectionField;
|
|
11
|
+
export type BuilderFieldType = FormField['type'];
|
|
12
|
+
export type FieldUpdate = Partial<LeafField> | Partial<Omit<BuilderSectionField, 'id'>>;
|
|
13
|
+
export interface FormFieldsActions {
|
|
14
|
+
addField: (type: BuilderFieldType) => void;
|
|
15
|
+
addFieldToSection: (sectionId: string, type: BuilderFieldType) => void;
|
|
16
|
+
insertFieldBefore: (targetId: string, type: BuilderFieldType) => void;
|
|
17
|
+
insertFieldAfter: (targetId: string, type: BuilderFieldType) => void;
|
|
18
|
+
moveFieldToSection: (fieldId: string, sectionId: string) => void;
|
|
19
|
+
removeField: (fieldId: string) => void;
|
|
20
|
+
duplicateField: (fieldId: string) => void;
|
|
21
|
+
updateField: (fieldId: string, updates: FieldUpdate) => void;
|
|
22
|
+
moveFieldUp: (fieldId: string) => void;
|
|
23
|
+
moveFieldDown: (fieldId: string) => void;
|
|
24
|
+
setAllFields: (fields: FormField[]) => void;
|
|
25
|
+
resetForm: () => void;
|
|
26
|
+
selectField: (fieldId: string | null) => void;
|
|
27
|
+
}
|
|
28
|
+
export interface FormContextType extends FormFieldsActions {
|
|
29
|
+
formFields: FormField[];
|
|
30
|
+
selectedFieldId: string | null;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["form-builder-v2/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ColorField,\n SectionField,\n SegmentedRadioGroupField,\n SelectField,\n SwitchField,\n Text,\n TextField,\n} from '../form-generator-v2/types';\n\ntype LeafField =\n | TextField\n | SelectField\n | SegmentedRadioGroupField\n | Text\n | SwitchField\n | ColorField;\n\nexport type BuilderLeafField = LeafField & {id: string};\nexport type BuilderSectionField = Omit<SectionField, 'fields'> & {\n id: string;\n fields: FormField[];\n};\n\nexport type FormField = BuilderLeafField | BuilderSectionField;\n\nexport type BuilderFieldType = FormField['type'];\n\nexport type FieldUpdate = Partial<LeafField> | Partial<Omit<BuilderSectionField, 'id'>>;\n\nexport interface FormFieldsActions {\n addField: (type: BuilderFieldType) => void;\n addFieldToSection: (sectionId: string, type: BuilderFieldType) => void;\n insertFieldBefore: (targetId: string, type: BuilderFieldType) => void;\n insertFieldAfter: (targetId: string, type: BuilderFieldType) => void;\n moveFieldToSection: (fieldId: string, sectionId: string) => void;\n removeField: (fieldId: string) => void;\n duplicateField: (fieldId: string) => void;\n updateField: (fieldId: string, updates: FieldUpdate) => void;\n moveFieldUp: (fieldId: string) => void;\n moveFieldDown: (fieldId: string) => void;\n setAllFields: (fields: FormField[]) => void;\n resetForm: () => void;\n selectField: (fieldId: string | null) => void;\n}\n\nexport interface FormContextType extends FormFieldsActions {\n formFields: FormField[];\n selectedFieldId: string | null;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.js","sourceRoot":"../../../../src","sources":["form-builder-v2/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,EAAC,CAAC,EAAE,yBAAyB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAC,CAAC,CAAC","sourcesContent":["import {withNaming} from '@bem-react/classname';\n\nexport const FORM_BUILDER_V2_NAMESPACE = 'pcformbuilderv2-';\n\nexport const formBuilderV2Cn = withNaming({n: FORM_BUILDER_V2_NAMESPACE, e: '__', m: '_'});\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Data } from '@dnd-kit/abstract';
|
|
2
|
+
import type { BuilderFieldType } from "../types.js";
|
|
3
|
+
export interface PaletteDragData extends Data {
|
|
4
|
+
kind: 'palette';
|
|
5
|
+
type: BuilderFieldType;
|
|
6
|
+
}
|
|
7
|
+
export interface CardDragData extends Data {
|
|
8
|
+
kind: 'card';
|
|
9
|
+
group: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SectionDropData extends Data {
|
|
12
|
+
kind: 'section-drop';
|
|
13
|
+
sectionId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function isPaletteData(data: Data | null | undefined): data is PaletteDragData;
|
|
16
|
+
export declare function isCardData(data: Data | null | undefined): data is CardDragData;
|
|
17
|
+
export declare function isSectionDropData(data: Data | null | undefined): data is SectionDropData;
|
|
18
|
+
export declare const isDropAfter: (pointerY: number | undefined, targetCenterY: number | undefined) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function isPaletteData(data) {
|
|
2
|
+
return data !== null && data !== undefined && data.kind === 'palette';
|
|
3
|
+
}
|
|
4
|
+
export function isCardData(data) {
|
|
5
|
+
return data !== null && data !== undefined && data.kind === 'card';
|
|
6
|
+
}
|
|
7
|
+
export function isSectionDropData(data) {
|
|
8
|
+
return data !== null && data !== undefined && data.kind === 'section-drop';
|
|
9
|
+
}
|
|
10
|
+
export const isDropAfter = (pointerY, targetCenterY) => pointerY !== undefined && targetCenterY !== undefined && pointerY > targetCenterY;
|
|
11
|
+
//# sourceMappingURL=dragData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dragData.js","sourceRoot":"../../../../src","sources":["form-builder-v2/utils/dragData.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,aAAa,CAAC,IAA6B;IACvD,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAA6B;IACpD,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAA6B;IAC3D,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,QAA4B,EAC5B,aAAiC,EAC1B,EAAE,CAAC,QAAQ,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,IAAI,QAAQ,GAAG,aAAa,CAAC","sourcesContent":["import type {Data} from '@dnd-kit/abstract';\n\nimport type {BuilderFieldType} from '../types';\n\nexport interface PaletteDragData extends Data {\n kind: 'palette';\n type: BuilderFieldType;\n}\n\nexport interface CardDragData extends Data {\n kind: 'card';\n group: string;\n}\n\nexport interface SectionDropData extends Data {\n kind: 'section-drop';\n sectionId: string;\n}\n\nexport function isPaletteData(data: Data | null | undefined): data is PaletteDragData {\n return data !== null && data !== undefined && data.kind === 'palette';\n}\n\nexport function isCardData(data: Data | null | undefined): data is CardDragData {\n return data !== null && data !== undefined && data.kind === 'card';\n}\n\nexport function isSectionDropData(data: Data | null | undefined): data is SectionDropData {\n return data !== null && data !== undefined && data.kind === 'section-drop';\n}\n\nexport const isDropAfter = (\n pointerY: number | undefined,\n targetCenterY: number | undefined,\n): boolean => pointerY !== undefined && targetCenterY !== undefined && pointerY > targetCenterY;\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const createDefaultField = (type, name, id) => {
|
|
2
|
+
switch (type) {
|
|
3
|
+
case 'textInput':
|
|
4
|
+
return { type, name, title: 'Text input', id };
|
|
5
|
+
case 'textArea':
|
|
6
|
+
return { type, name, title: 'Text area', id };
|
|
7
|
+
case 'switch':
|
|
8
|
+
return { type, name, title: 'Switch', id };
|
|
9
|
+
case 'colorInput':
|
|
10
|
+
return { type, name, title: 'Color', defaultValue: '#000000', id };
|
|
11
|
+
case 'select':
|
|
12
|
+
return {
|
|
13
|
+
type,
|
|
14
|
+
name,
|
|
15
|
+
title: 'Select',
|
|
16
|
+
options: [
|
|
17
|
+
{ value: 'option1', content: 'Option 1' },
|
|
18
|
+
{ value: 'option2', content: 'Option 2' },
|
|
19
|
+
],
|
|
20
|
+
id,
|
|
21
|
+
};
|
|
22
|
+
case 'segmentedRadioGroup':
|
|
23
|
+
return {
|
|
24
|
+
type,
|
|
25
|
+
name,
|
|
26
|
+
title: 'Segmented radio',
|
|
27
|
+
options: [
|
|
28
|
+
{ value: 'option1', content: 'Option 1' },
|
|
29
|
+
{ value: 'option2', content: 'Option 2' },
|
|
30
|
+
],
|
|
31
|
+
id,
|
|
32
|
+
};
|
|
33
|
+
case 'text':
|
|
34
|
+
return { type, text: 'Static text', id };
|
|
35
|
+
case 'section':
|
|
36
|
+
return {
|
|
37
|
+
type,
|
|
38
|
+
title: 'Section',
|
|
39
|
+
opened: true,
|
|
40
|
+
fields: [],
|
|
41
|
+
id,
|
|
42
|
+
};
|
|
43
|
+
default:
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=fieldDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldDefaults.js","sourceRoot":"../../../../src","sources":["form-builder-v2/utils/fieldDefaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAsB,EAAE,IAAY,EAAE,EAAU,EAAa,EAAE;IAC9F,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,WAAW;YACZ,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAC,CAAC;QACjD,KAAK,UAAU;YACX,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAC,CAAC;QAChD,KAAK,QAAQ;YACT,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAC,CAAC;QAC7C,KAAK,YAAY;YACb,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAC,CAAC;QACrE,KAAK,QAAQ;YACT,OAAO;gBACH,IAAI;gBACJ,IAAI;gBACJ,KAAK,EAAE,QAAQ;gBACf,OAAO,EAAE;oBACL,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAC;oBACvC,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAC;iBAC1C;gBACD,EAAE;aACL,CAAC;QACN,KAAK,qBAAqB;YACtB,OAAO;gBACH,IAAI;gBACJ,IAAI;gBACJ,KAAK,EAAE,iBAAiB;gBACxB,OAAO,EAAE;oBACL,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAC;oBACvC,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAC;iBAC1C;gBACD,EAAE;aACL,CAAC;QACN,KAAK,MAAM;YACP,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAC,CAAC;QAC3C,KAAK,SAAS;YACV,OAAO;gBACH,IAAI;gBACJ,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,EAAE;gBACV,EAAE;aACL,CAAC;QACN;YACI,OAAO,SAAkB,CAAC;IAClC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {BuilderFieldType, FormField} from '../types';\n\nexport const createDefaultField = (type: BuilderFieldType, name: string, id: string): FormField => {\n switch (type) {\n case 'textInput':\n return {type, name, title: 'Text input', id};\n case 'textArea':\n return {type, name, title: 'Text area', id};\n case 'switch':\n return {type, name, title: 'Switch', id};\n case 'colorInput':\n return {type, name, title: 'Color', defaultValue: '#000000', id};\n case 'select':\n return {\n type,\n name,\n title: 'Select',\n options: [\n {value: 'option1', content: 'Option 1'},\n {value: 'option2', content: 'Option 2'},\n ],\n id,\n };\n case 'segmentedRadioGroup':\n return {\n type,\n name,\n title: 'Segmented radio',\n options: [\n {value: 'option1', content: 'Option 1'},\n {value: 'option2', content: 'Option 2'},\n ],\n id,\n };\n case 'text':\n return {type, text: 'Static text', id};\n case 'section':\n return {\n type,\n title: 'Section',\n opened: true,\n fields: [],\n id,\n };\n default:\n return undefined as never;\n }\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { walkFields } from "./treeWalk.js";
|
|
2
|
+
export const buildGroupsMap = (fields) => {
|
|
3
|
+
const groups = { root: fields };
|
|
4
|
+
walkFields(fields, (field) => {
|
|
5
|
+
if (field.type === 'section') {
|
|
6
|
+
groups[`section:${field.id}`] = field.fields;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return groups;
|
|
10
|
+
};
|
|
11
|
+
export const applyGroupsMap = (groups) => {
|
|
12
|
+
const transform = (fields) => fields.map((field) => {
|
|
13
|
+
if (field.type === 'section') {
|
|
14
|
+
const childGroup = groups[`section:${field.id}`] ?? field.fields;
|
|
15
|
+
return { ...field, fields: transform(childGroup) };
|
|
16
|
+
}
|
|
17
|
+
return field;
|
|
18
|
+
});
|
|
19
|
+
return transform(groups.root ?? []);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=fieldGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldGroups.js","sourceRoot":"../../../../src","sources":["form-builder-v2/utils/fieldGroups.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,sBAAmB;AAEtC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAmB,EAA+B,EAAE;IAC/E,MAAM,MAAM,GAAgC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAC3D,UAAU,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QACzB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,WAAW,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAmC,EAAe,EAAE;IAC/E,MAAM,SAAS,GAAG,CAAC,MAAmB,EAAe,EAAE,CACnD,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACjB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC;YACjE,OAAO,EAAC,GAAG,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,EAAC,CAAC;QACrD,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IACP,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import {FormField} from '../types';\n\nimport {walkFields} from './treeWalk';\n\nexport const buildGroupsMap = (fields: FormField[]): Record<string, FormField[]> => {\n const groups: Record<string, FormField[]> = {root: fields};\n walkFields(fields, (field) => {\n if (field.type === 'section') {\n groups[`section:${field.id}`] = field.fields;\n }\n });\n return groups;\n};\n\nexport const applyGroupsMap = (groups: Record<string, FormField[]>): FormField[] => {\n const transform = (fields: FormField[]): FormField[] =>\n fields.map((field) => {\n if (field.type === 'section') {\n const childGroup = groups[`section:${field.id}`] ?? field.fields;\n return {...field, fields: transform(childGroup)};\n }\n return field;\n });\n return transform(groups.root ?? []);\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IconData } from '@gravity-ui/uikit';
|
|
2
|
+
import type { BuilderFieldType } from "../types.js";
|
|
3
|
+
export declare const TYPE_LABELS: Record<BuilderFieldType, string>;
|
|
4
|
+
export declare const PALETTE_LABELS: Record<BuilderFieldType, string>;
|
|
5
|
+
export declare const TYPE_ICONS: Record<BuilderFieldType, IconData>;
|
|
6
|
+
export declare const FIELD_TYPES: BuilderFieldType[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChevronsExpandVertical, CircleInfo, Cubes3, Droplet, FontCursor, ListCheck, TextAlignLeft, ToggleOn, } from '@gravity-ui/icons';
|
|
2
|
+
export const TYPE_LABELS = {
|
|
3
|
+
textInput: 'Text input',
|
|
4
|
+
textArea: 'Text area',
|
|
5
|
+
select: 'Select',
|
|
6
|
+
segmentedRadioGroup: 'Segmented radio',
|
|
7
|
+
switch: 'Switch',
|
|
8
|
+
colorInput: 'Color input',
|
|
9
|
+
text: 'Static text',
|
|
10
|
+
section: 'Section',
|
|
11
|
+
};
|
|
12
|
+
export const PALETTE_LABELS = {
|
|
13
|
+
textInput: 'Text',
|
|
14
|
+
textArea: 'Text area',
|
|
15
|
+
select: 'Select',
|
|
16
|
+
segmentedRadioGroup: 'Radio',
|
|
17
|
+
switch: 'Switch',
|
|
18
|
+
colorInput: 'Color',
|
|
19
|
+
text: 'Hint',
|
|
20
|
+
section: 'Section',
|
|
21
|
+
};
|
|
22
|
+
export const TYPE_ICONS = {
|
|
23
|
+
textInput: FontCursor,
|
|
24
|
+
textArea: TextAlignLeft,
|
|
25
|
+
select: ChevronsExpandVertical,
|
|
26
|
+
segmentedRadioGroup: ListCheck,
|
|
27
|
+
switch: ToggleOn,
|
|
28
|
+
colorInput: Droplet,
|
|
29
|
+
text: CircleInfo,
|
|
30
|
+
section: Cubes3,
|
|
31
|
+
};
|
|
32
|
+
export const FIELD_TYPES = [
|
|
33
|
+
'textInput',
|
|
34
|
+
'textArea',
|
|
35
|
+
'select',
|
|
36
|
+
'segmentedRadioGroup',
|
|
37
|
+
'switch',
|
|
38
|
+
'colorInput',
|
|
39
|
+
'text',
|
|
40
|
+
'section',
|
|
41
|
+
];
|
|
42
|
+
//# sourceMappingURL=fieldMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldMeta.js","sourceRoot":"../../../../src","sources":["form-builder-v2/utils/fieldMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACtB,UAAU,EACV,MAAM,EACN,OAAO,EACP,UAAU,EACV,SAAS,EACT,aAAa,EACb,QAAQ,GACX,MAAM,mBAAmB,CAAC;AAK3B,MAAM,CAAC,MAAM,WAAW,GAAqC;IACzD,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,iBAAiB;IACtC,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,aAAa;IACzB,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAqC;IAC5D,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,OAAO;IAC5B,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAuC;IAC1D,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,aAAa;IACvB,MAAM,EAAE,sBAAsB;IAC9B,mBAAmB,EAAE,SAAS;IAC9B,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC3C,WAAW;IACX,UAAU;IACV,QAAQ;IACR,qBAAqB;IACrB,QAAQ;IACR,YAAY;IACZ,MAAM;IACN,SAAS;CACZ,CAAC","sourcesContent":["import {\n ChevronsExpandVertical,\n CircleInfo,\n Cubes3,\n Droplet,\n FontCursor,\n ListCheck,\n TextAlignLeft,\n ToggleOn,\n} from '@gravity-ui/icons';\nimport type {IconData} from '@gravity-ui/uikit';\n\nimport type {BuilderFieldType} from '../types';\n\nexport const TYPE_LABELS: Record<BuilderFieldType, string> = {\n textInput: 'Text input',\n textArea: 'Text area',\n select: 'Select',\n segmentedRadioGroup: 'Segmented radio',\n switch: 'Switch',\n colorInput: 'Color input',\n text: 'Static text',\n section: 'Section',\n};\n\nexport const PALETTE_LABELS: Record<BuilderFieldType, string> = {\n textInput: 'Text',\n textArea: 'Text area',\n select: 'Select',\n segmentedRadioGroup: 'Radio',\n switch: 'Switch',\n colorInput: 'Color',\n text: 'Hint',\n section: 'Section',\n};\n\nexport const TYPE_ICONS: Record<BuilderFieldType, IconData> = {\n textInput: FontCursor,\n textArea: TextAlignLeft,\n select: ChevronsExpandVertical,\n segmentedRadioGroup: ListCheck,\n switch: ToggleOn,\n colorInput: Droplet,\n text: CircleInfo,\n section: Cubes3,\n};\n\nexport const FIELD_TYPES: BuilderFieldType[] = [\n 'textInput',\n 'textArea',\n 'select',\n 'segmentedRadioGroup',\n 'switch',\n 'colorInput',\n 'text',\n 'section',\n];\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormField } from "../types.js";
|
|
2
|
+
export declare const ARRAY_ITEM_PREFIX = "items[{{index}}].";
|
|
3
|
+
export declare const prefixNameForArrayMode: (name: string) => string;
|
|
4
|
+
export declare const stripArrayModePrefix: (name: string) => string;
|
|
5
|
+
export declare const collectNames: (fields: FormField[]) => Set<string>;
|
|
6
|
+
export declare const cloneFieldWithNewIds: (field: FormField, generateId: () => string, existingNames: Set<string>) => FormField;
|
|
7
|
+
export declare const transformChildNames: (fields: FormField[], transform: (name: string) => string) => FormField[];
|
|
8
|
+
export declare const maxIdNumericSuffix: (fields: FormField[]) => number;
|