@k3-universe/react-kit 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18167 -15061
- package/dist/kit/builder/form/components/FormBuilder.d.ts +46 -14
- package/dist/kit/builder/form/components/FormBuilder.d.ts.map +1 -1
- package/dist/kit/builder/form/components/FormBuilderField.d.ts.map +1 -1
- package/dist/kit/builder/form/components/fields/AutocompleteField.d.ts.map +1 -1
- package/dist/kit/builder/form/components/fields/DatePickerField.d.ts +3 -0
- package/dist/kit/builder/form/components/fields/DatePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/DateRangePickerField.d.ts +3 -0
- package/dist/kit/builder/form/components/fields/DateRangePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts +4 -0
- package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts +4 -0
- package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/MonthPickerField.d.ts +3 -0
- package/dist/kit/builder/form/components/fields/MonthPickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/MonthRangePickerField.d.ts +3 -0
- package/dist/kit/builder/form/components/fields/MonthRangePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/TimePickerField.d.ts +4 -0
- package/dist/kit/builder/form/components/fields/TimePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts +4 -0
- package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts.map +1 -0
- package/dist/kit/builder/form/components/fields/index.d.ts +8 -0
- package/dist/kit/builder/form/components/fields/index.d.ts.map +1 -1
- package/dist/kit/builder/section/SectionBuilder.d.ts.map +1 -1
- package/dist/kit/builder/section/types.d.ts +12 -1
- package/dist/kit/builder/section/types.d.ts.map +1 -1
- package/dist/kit/builder/stack-dialog/context.d.ts +3 -0
- package/dist/kit/builder/stack-dialog/context.d.ts.map +1 -0
- package/dist/kit/builder/stack-dialog/hooks.d.ts +6 -0
- package/dist/kit/builder/stack-dialog/hooks.d.ts.map +1 -0
- package/dist/kit/builder/stack-dialog/index.d.ts +5 -0
- package/dist/kit/builder/stack-dialog/index.d.ts.map +1 -0
- package/dist/kit/builder/stack-dialog/provider.d.ts +3 -0
- package/dist/kit/builder/stack-dialog/provider.d.ts.map +1 -0
- package/dist/kit/builder/stack-dialog/renderer.d.ts +6 -0
- package/dist/kit/builder/stack-dialog/renderer.d.ts.map +1 -0
- package/dist/kit/builder/stack-dialog/types.d.ts +20 -0
- package/dist/kit/builder/stack-dialog/types.d.ts.map +1 -0
- package/dist/kit/components/autocomplete/Autocomplete.d.ts +35 -3
- package/dist/kit/components/autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/kit/components/autocomplete/index.d.ts +1 -0
- package/dist/kit/components/autocomplete/index.d.ts.map +1 -1
- package/dist/kit/components/datepicker/DatePicker.d.ts +27 -0
- package/dist/kit/components/datepicker/DatePicker.d.ts.map +1 -0
- package/dist/kit/components/datepicker/DateRangePicker.d.ts +41 -0
- package/dist/kit/components/datepicker/DateRangePicker.d.ts.map +1 -0
- package/dist/kit/components/datetimepicker/DateTimePicker.d.ts +32 -0
- package/dist/kit/components/datetimepicker/DateTimePicker.d.ts.map +1 -0
- package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts +39 -0
- package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts.map +1 -0
- package/dist/kit/components/datetimepicker/index.d.ts +5 -0
- package/dist/kit/components/datetimepicker/index.d.ts.map +1 -0
- package/dist/kit/components/monthpicker/MonthInput.d.ts +26 -0
- package/dist/kit/components/monthpicker/MonthInput.d.ts.map +1 -0
- package/dist/kit/components/monthpicker/MonthPicker.d.ts +32 -0
- package/dist/kit/components/monthpicker/MonthPicker.d.ts.map +1 -0
- package/dist/kit/components/monthpicker/MonthRangeInput.d.ts +31 -0
- package/dist/kit/components/monthpicker/MonthRangeInput.d.ts.map +1 -0
- package/dist/kit/components/monthpicker/MonthRangePicker.d.ts +48 -0
- package/dist/kit/components/monthpicker/MonthRangePicker.d.ts.map +1 -0
- package/dist/kit/components/timepicker/TimePicker.d.ts +26 -0
- package/dist/kit/components/timepicker/TimePicker.d.ts.map +1 -0
- package/dist/kit/components/timepicker/TimeRangePicker.d.ts +31 -0
- package/dist/kit/components/timepicker/TimeRangePicker.d.ts.map +1 -0
- package/dist/kit/components/timepicker/index.d.ts +5 -0
- package/dist/kit/components/timepicker/index.d.ts.map +1 -0
- package/dist/kit/themes/clean-slate.css +181 -1
- package/dist/kit/themes/default.css +181 -1
- package/dist/kit/themes/minimal-modern.css +181 -1
- package/dist/kit/themes/spotify.css +181 -1
- package/package.json +1 -1
- package/src/kit/builder/form/components/FormBuilder.tsx +380 -145
- package/src/kit/builder/form/components/FormBuilderField.tsx +100 -3
- package/src/kit/builder/form/components/fields/AutocompleteField.tsx +29 -1
- package/src/kit/builder/form/components/fields/DatePickerField.tsx +24 -0
- package/src/kit/builder/form/components/fields/DateRangePickerField.tsx +41 -0
- package/src/kit/builder/form/components/fields/DateTimePickerField.tsx +33 -0
- package/src/kit/builder/form/components/fields/DateTimeRangePickerField.tsx +42 -0
- package/src/kit/builder/form/components/fields/MonthPickerField.tsx +26 -0
- package/src/kit/builder/form/components/fields/MonthRangePickerField.tsx +35 -0
- package/src/kit/builder/form/components/fields/TimePickerField.tsx +30 -0
- package/src/kit/builder/form/components/fields/TimeRangePickerField.tsx +37 -0
- package/src/kit/builder/form/components/fields/index.ts +8 -0
- package/src/kit/builder/section/SectionBuilder.tsx +24 -2
- package/src/kit/builder/section/types.ts +15 -1
- package/src/kit/builder/stack-dialog/context.ts +9 -0
- package/src/kit/builder/stack-dialog/hooks.ts +11 -0
- package/src/kit/builder/stack-dialog/index.ts +13 -0
- package/src/kit/builder/stack-dialog/provider.tsx +55 -0
- package/src/kit/builder/stack-dialog/renderer.tsx +33 -0
- package/src/kit/builder/stack-dialog/types.ts +22 -0
- package/src/kit/components/autocomplete/Autocomplete.tsx +783 -233
- package/src/kit/components/autocomplete/index.ts +1 -0
- package/src/kit/components/datepicker/DatePicker.tsx +149 -0
- package/src/kit/components/datepicker/DateRangePicker.tsx +454 -0
- package/src/kit/components/datetimepicker/DateTimePicker.tsx +314 -0
- package/src/kit/components/datetimepicker/DateTimeRangePicker.tsx +486 -0
- package/src/kit/components/datetimepicker/index.ts +3 -0
- package/src/kit/components/monthpicker/MonthInput.tsx +122 -0
- package/src/kit/components/monthpicker/MonthPicker.tsx +223 -0
- package/src/kit/components/monthpicker/MonthRangeInput.tsx +132 -0
- package/src/kit/components/monthpicker/MonthRangePicker.tsx +407 -0
- package/src/kit/components/timepicker/TimePicker.tsx +311 -0
- package/src/kit/components/timepicker/TimeRangePicker.tsx +291 -0
- package/src/kit/components/timepicker/index.ts +3 -0
- package/src/stories/kit/builder/Form.Autocomplete.stories.tsx +210 -0
- package/src/stories/kit/builder/Form.Complex.stories.tsx +101 -0
- package/src/stories/kit/builder/Form.DateTime.stories.tsx +66 -0
- package/src/stories/kit/builder/Form.Dynamic.stories.tsx +149 -0
- package/src/stories/kit/builder/Form.Pickers.stories.tsx +71 -0
- package/src/stories/kit/builder/Form.Time.stories.tsx +64 -0
- package/src/stories/kit/builder/Section.stories.tsx +58 -2
- package/src/stories/kit/components/Autocomplete.stories.tsx +27 -0
- package/src/stories/kit/components/DatePicker.stories.tsx +128 -0
- package/src/stories/kit/components/DateRangePicker.stories.tsx +154 -0
- package/src/stories/kit/components/MonthPicker.stories.tsx +80 -0
- package/src/stories/kit/components/MonthRangePicker.stories.tsx +98 -0
- package/src/stories/kit/components/TimePicker.stories.tsx +69 -0
- package/src/stories/kit/components/TimeRangePicker.stories.tsx +37 -0
- package/storybook-static/assets/Accordion.stories-KU4JBR8U.js +52 -0
- package/storybook-static/assets/AdminLayout-CPvVCwfY.js +53 -0
- package/storybook-static/assets/AdminLayout.Basic.stories-DkP2UVXe.js +4 -0
- package/storybook-static/assets/AdminLayout.Collapsible.stories-BuuVjtpW.js +4 -0
- package/storybook-static/assets/AdminLayout.Complex.stories-D-k4H0hJ.js +29 -0
- package/storybook-static/assets/AdminLayout.CustomSidebarHeaderComponent.stories-B_0IEDd4.js +9 -0
- package/storybook-static/assets/AdminLayout.CustomSidebarTitleAndIcon.stories-CvAeXUyA.js +4 -0
- package/storybook-static/assets/AdminLayout.HeaderSlots.stories-RBFHoSZK.js +7 -0
- package/storybook-static/assets/Alert.stories-DKxKtIc0.js +27 -0
- package/storybook-static/assets/AlertDialog.stories-BqTpZ_nG.js +43 -0
- package/storybook-static/assets/AspectRatio.stories-DPO9QQ5F.js +22 -0
- package/storybook-static/assets/Autocomplete-Cpg4CaJe.js +56 -0
- package/storybook-static/assets/Autocomplete.stories-CWj4G5fh.js +56 -0
- package/storybook-static/assets/Avatar.stories-DPhov_2g.js +12 -0
- package/storybook-static/assets/Badge.stories-DFKrRdXq.js +12 -0
- package/storybook-static/assets/Breadcrumb.stories-CTE6CZUC.js +25 -0
- package/storybook-static/assets/Button.stories-cbt2InL-.js +26 -0
- package/storybook-static/assets/Calendar.stories-DRhTw_43.js +3 -0
- package/storybook-static/assets/Card.stories-Isf6n_K3.js +15 -0
- package/storybook-static/assets/Carousel.stories-Cmg0I3fR.js +15 -0
- package/storybook-static/assets/Chart.stories-aQ-fNijT.js +126 -0
- package/storybook-static/assets/Checkbox.stories-B7YMXPDc.js +12 -0
- package/storybook-static/assets/Collapsible.stories-BUzl17ZZ.js +18 -0
- package/storybook-static/assets/Combination-BdQWAuko.js +41 -0
- package/storybook-static/assets/Command.stories-DzBlWQs0.js +30 -0
- package/storybook-static/assets/ContextMenu.stories-CJlBQyXc.js +31 -0
- package/storybook-static/assets/DataTable.Basic.stories-BWYKFDmK.js +6 -0
- package/storybook-static/assets/DataTable.Filters.stories-uZdtJk8t.js +21 -0
- package/storybook-static/assets/DataTable.Pagination.stories-C5N1khkp.js +24 -0
- package/storybook-static/assets/DataTable.SelectionAndActions.stories-FhCqZKvO.js +26 -0
- package/storybook-static/assets/DataTable.Sorting.stories-D-k7EtRj.js +6 -0
- package/storybook-static/assets/Dialog.stories-C62AF-Gx.js +54 -0
- package/storybook-static/assets/Dialog.stories-lrjRwOus.js +18 -0
- package/storybook-static/assets/Drawer.stories-CGjkdJeV.js +24 -0
- package/storybook-static/assets/DropdownMenu.stories-DkGClRAA.js +35 -0
- package/storybook-static/assets/Form.ArrayLayouts.stories-C5d_062d.js +130 -0
- package/storybook-static/assets/Form.Autocomplete.stories-CPZPkk4o.js +142 -0
- package/storybook-static/assets/Form.Basic.stories-Bhcu3-3n.js +58 -0
- package/storybook-static/assets/Form.Complex.stories-QnXh5a7Q.js +361 -0
- package/storybook-static/assets/Form.Dynamic.stories-DFW6wIuT.js +502 -0
- package/storybook-static/assets/Form.Simple.stories-BhJcyhbE.js +53 -0
- package/storybook-static/assets/Form.stories-PFNsMYxO.js +3 -0
- package/storybook-static/assets/FormBuilder-BQBBxo_k.js +5 -0
- package/storybook-static/assets/HoverCard.stories-CAlQEVn8.js +21 -0
- package/storybook-static/assets/Input.stories-CEhODt0V.js +16 -0
- package/storybook-static/assets/InputOtp.stories-DSvNP4dS.js +42 -0
- package/storybook-static/assets/Label.stories-B3pa8ZLY.js +14 -0
- package/storybook-static/assets/Login.stories-C7KQkmR_.js +37 -0
- package/storybook-static/assets/Menubar.stories-CHXhSHxc.js +44 -0
- package/storybook-static/assets/MonthPicker.stories-BnrOc4fm.js +99 -0
- package/storybook-static/assets/MonthRangePicker.stories-55Gk1t-7.js +134 -0
- package/storybook-static/assets/NavigationMenu.stories-CXoS080P.js +30 -0
- package/storybook-static/assets/Page.stories-GdSJgZ6-.js +91 -0
- package/storybook-static/assets/Pagination.stories-BEBwqH4N.js +29 -0
- package/storybook-static/assets/Popover.stories-BICy98Cw.js +15 -0
- package/storybook-static/assets/Progress.stories-DECHNOME.js +8 -0
- package/storybook-static/assets/RadioGroup.stories-DA7-uKfV.js +16 -0
- package/storybook-static/assets/Resizable.stories-B99kWkH7.js +25 -0
- package/storybook-static/assets/ScrollArea.stories-BqvUAXqU.js +12 -0
- package/storybook-static/assets/Section.stories-lFMlFBQn.js +277 -0
- package/storybook-static/assets/SectionBuilder-BQW705x0.js +1 -0
- package/storybook-static/assets/Select.stories-BsKyZ6Io.js +17 -0
- package/storybook-static/assets/Separator.stories-BTDOaOM2.js +17 -0
- package/storybook-static/assets/Sheet.stories-Cam1gR6G.js +24 -0
- package/storybook-static/assets/Sidebar.stories-DnOa6G7y.js +106 -0
- package/storybook-static/assets/Skeleton.stories-BQNIuIe5.js +9 -0
- package/storybook-static/assets/Slider.stories-Bslq7hjq.js +6 -0
- package/storybook-static/assets/Sonner.stories-D34pBBtI.js +18 -0
- package/storybook-static/assets/Switch.stories-Puyb1-Bx.js +3 -0
- package/storybook-static/assets/Table.stories-ClZxAhut.js +35 -0
- package/storybook-static/assets/Tabs.stories-CURNTETB.js +10 -0
- package/storybook-static/assets/Textarea.stories-Cf1ZBrWw.js +17 -0
- package/storybook-static/assets/Toggle.stories-CdMHY_bi.js +3 -0
- package/storybook-static/assets/ToggleGroup.stories-BM68m1dX.js +13 -0
- package/storybook-static/assets/Tooltip.stories-DiQv64dM.js +10 -0
- package/storybook-static/assets/accordion-DVgwQcnw.js +1 -0
- package/storybook-static/assets/alert-dialog-DCUEwpqm.js +7 -0
- package/storybook-static/assets/avatar-BzwOE-mi.js +1 -0
- package/storybook-static/assets/axe-HmUsR1st.js +30 -0
- package/storybook-static/assets/badge-BnQWua6u.js +1 -0
- package/storybook-static/assets/button-0oMkiryo.js +1 -0
- package/storybook-static/assets/card-BJpPOzP8.js +1 -0
- package/storybook-static/assets/chart-column-DZGb4ZZS.js +6 -0
- package/storybook-static/assets/check-B9hBGj6o.js +6 -0
- package/storybook-static/assets/checkbox-CyIeaWHX.js +1 -0
- package/storybook-static/assets/chevron-down-D_37S6il.js +6 -0
- package/storybook-static/assets/chevron-left-BBoN0vbI.js +6 -0
- package/storybook-static/assets/chevron-right-B5vIMLxK.js +6 -0
- package/storybook-static/assets/circle-C5Lzx6Nx.js +6 -0
- package/storybook-static/assets/clean-slate-D1HmMFJM.css +1 -0
- package/storybook-static/assets/command-Csa9p8_a.js +6 -0
- package/storybook-static/assets/createLucideIcon-BrHXro7t.js +21 -0
- package/storybook-static/assets/default-CN_Fo1GY.css +1 -0
- package/storybook-static/assets/dependencies-ctrV69dx.js +1 -0
- package/storybook-static/assets/dialog-CsnqITTn.js +1 -0
- package/storybook-static/assets/dropdown-menu-BWxxwPHL.js +1 -0
- package/storybook-static/assets/ellipsis-BRS038RR.js +6 -0
- package/storybook-static/assets/grip-vertical-BxXG8KNA.js +6 -0
- package/storybook-static/assets/iframe-C9bogcIc.css +1 -0
- package/storybook-static/assets/iframe-v7iAhKit.js +1555 -0
- package/storybook-static/assets/index-0-qMRXou.js +1 -0
- package/storybook-static/assets/index-AvwFFKJc.js +1 -0
- package/storybook-static/assets/index-BVDb4dFc.js +1 -0
- package/storybook-static/assets/index-B_qx7A5T.js +1 -0
- package/storybook-static/assets/index-BdQq_4o_.js +1 -0
- package/storybook-static/assets/index-BfiCOk42.js +1 -0
- package/storybook-static/assets/index-Bv9yk470.js +1 -0
- package/storybook-static/assets/index-Bw1A27Kp.js +1 -0
- package/storybook-static/assets/index-ByqivBWx.js +1 -0
- package/storybook-static/assets/index-C9Ta0ZTH.js +1 -0
- package/storybook-static/assets/index-CDY5kTx5.js +1 -0
- package/storybook-static/assets/index-CGnyVRgB.js +1 -0
- package/storybook-static/assets/index-CGrAONsN.js +1 -0
- package/storybook-static/assets/index-CWjrGFAQ.js +1 -0
- package/storybook-static/assets/index-CwBdPBFz.js +9 -0
- package/storybook-static/assets/index-D8RXF03I.js +1 -0
- package/storybook-static/assets/index-DLIxT4Z7.js +1 -0
- package/storybook-static/assets/index-DW48STyt.js +1 -0
- package/storybook-static/assets/index-DbaA6-o1.js +1 -0
- package/storybook-static/assets/index-Dph_5COR.js +1 -0
- package/storybook-static/assets/index-DrN5n71E.js +1 -0
- package/storybook-static/assets/index-Tp9IdbR8.js +1 -0
- package/storybook-static/assets/index-WyF3-wTE.js +9 -0
- package/storybook-static/assets/index-XSmPROEP.js +1 -0
- package/storybook-static/assets/index-Z6wF44KX.js +5 -0
- package/storybook-static/assets/index-_RPqOjlQ.js +1 -0
- package/storybook-static/assets/index-jrimW4QO.js +1 -0
- package/storybook-static/assets/index-nqc17SX4.js +1 -0
- package/storybook-static/assets/input-11YRd9gD.js +1 -0
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/label-Do8ODIVk.js +1 -0
- package/storybook-static/assets/lodash-DDwpuhPG.js +73 -0
- package/storybook-static/assets/matchers-7Z3WT2CE-T3xScrR7.js +14 -0
- package/storybook-static/assets/minimal-modern-BlYVzfQU.css +1 -0
- package/storybook-static/assets/popover-CcciSWAw.js +1 -0
- package/storybook-static/assets/preload-helper-Dp1pzeXC.js +1 -0
- package/storybook-static/assets/radio-group-DiJ0Y_KQ.js +1 -0
- package/storybook-static/assets/react-18-Cr9fq_Ip.js +25 -0
- package/storybook-static/assets/react-icons.esm-B_ULMmNU.js +1 -0
- package/storybook-static/assets/refresh-cw-BmRDhIV_.js +6 -0
- package/storybook-static/assets/schemas-CGNYCiJ6.js +18 -0
- package/storybook-static/assets/section-factories-DCCY9R35.js +1 -0
- package/storybook-static/assets/select-DDrkxaOg.js +6 -0
- package/storybook-static/assets/separator-o5SAUnaJ.js +1 -0
- package/storybook-static/assets/settings-2-xWGvvbG6.js +6 -0
- package/storybook-static/assets/sheet-C7jhU3XE.js +1 -0
- package/storybook-static/assets/shopping-cart-BFlrufvo.js +11 -0
- package/storybook-static/assets/sidebar-C8hU1Mxy.js +6 -0
- package/storybook-static/assets/skeleton-CjDnQs43.js +1 -0
- package/storybook-static/assets/spotify-CUDj7g8m.css +1 -0
- package/storybook-static/assets/switch-CKGRuk3u.js +1 -0
- package/storybook-static/assets/table-CP3vMqFn.js +1 -0
- package/storybook-static/assets/tabs-CopK2m3j.js +1 -0
- package/storybook-static/assets/textarea-Dw2vruMl.js +1 -0
- package/storybook-static/assets/toggle-DmHbWetf.js +16 -0
- package/storybook-static/assets/tooltip-_LqYEYFw.js +1 -0
- package/storybook-static/assets/trash-2-xdbApPby.js +11 -0
- package/storybook-static/assets/utils-D-KgF5mV.js +1 -0
- package/storybook-static/assets/x-B1a4fyWM.js +6 -0
- package/storybook-static/favicon-wrapper.svg +46 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +687 -0
- package/storybook-static/index.d.ts +64 -0
- package/storybook-static/index.d.ts.map +1 -0
- package/storybook-static/index.html +166 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/kit/builder/data-table/components/DataTable.d.ts +37 -0
- package/storybook-static/kit/builder/data-table/components/DataTable.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/components/DataTableColumnHeader.d.ts +8 -0
- package/storybook-static/kit/builder/data-table/components/DataTableColumnHeader.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/components/DataTablePagination.d.ts +6 -0
- package/storybook-static/kit/builder/data-table/components/DataTablePagination.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/components/DataTableViewOptions.d.ts +5 -0
- package/storybook-static/kit/builder/data-table/components/DataTableViewOptions.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/index.d.ts +7 -0
- package/storybook-static/kit/builder/data-table/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/types.d.ts +27 -0
- package/storybook-static/kit/builder/data-table/types.d.ts.map +1 -0
- package/storybook-static/kit/builder/data-table/utils/dotAccessor.d.ts +2 -0
- package/storybook-static/kit/builder/data-table/utils/dotAccessor.d.ts.map +1 -0
- package/storybook-static/kit/builder/dialog/index.d.ts +3 -0
- package/storybook-static/kit/builder/dialog/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/dialog/provider.d.ts +26 -0
- package/storybook-static/kit/builder/dialog/provider.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/FormBuilder.d.ts +137 -0
- package/storybook-static/kit/builder/form/components/FormBuilder.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/FormBuilderActions.d.ts +20 -0
- package/storybook-static/kit/builder/form/components/FormBuilderActions.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/FormBuilderField.d.ts +12 -0
- package/storybook-static/kit/builder/form/components/FormBuilderField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/ArrayField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/ArrayField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/AutocompleteField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/AutocompleteField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/CheckboxField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/CheckboxField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/DateField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/DateField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/FileField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/FileField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/NumberField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/NumberField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/ObjectField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/ObjectField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/RadioField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/RadioField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/SelectField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/SelectField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/SwitchField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/SwitchField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/TextField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/TextField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/TextareaField.d.ts +3 -0
- package/storybook-static/kit/builder/form/components/fields/TextareaField.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/index.d.ts +14 -0
- package/storybook-static/kit/builder/form/components/fields/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/fields/types.d.ts +14 -0
- package/storybook-static/kit/builder/form/components/fields/types.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/components/index.d.ts +4 -0
- package/storybook-static/kit/builder/form/components/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/index.d.ts +3 -0
- package/storybook-static/kit/builder/form/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/common-forms.d.ts +7 -0
- package/storybook-static/kit/builder/form/utils/common-forms.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/dependencies.d.ts +41 -0
- package/storybook-static/kit/builder/form/utils/dependencies.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/field-factories.d.ts +23 -0
- package/storybook-static/kit/builder/form/utils/field-factories.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/index.d.ts +15 -0
- package/storybook-static/kit/builder/form/utils/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/section-factories.d.ts +7 -0
- package/storybook-static/kit/builder/form/utils/section-factories.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/transformers.d.ts +6 -0
- package/storybook-static/kit/builder/form/utils/transformers.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/validations.d.ts +13 -0
- package/storybook-static/kit/builder/form/utils/validations.d.ts.map +1 -0
- package/storybook-static/kit/builder/form/utils/validators.d.ts +8 -0
- package/storybook-static/kit/builder/form/utils/validators.d.ts.map +1 -0
- package/storybook-static/kit/builder/page/Page.d.ts +48 -0
- package/storybook-static/kit/builder/page/Page.d.ts.map +1 -0
- package/storybook-static/kit/builder/page/index.d.ts +2 -0
- package/storybook-static/kit/builder/page/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/section/SectionBuilder.d.ts +3 -0
- package/storybook-static/kit/builder/section/SectionBuilder.d.ts.map +1 -0
- package/storybook-static/kit/builder/section/index.d.ts +3 -0
- package/storybook-static/kit/builder/section/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/section/types.d.ts +70 -0
- package/storybook-static/kit/builder/section/types.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/context.d.ts +3 -0
- package/storybook-static/kit/builder/stack-dialog/context.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/hooks.d.ts +6 -0
- package/storybook-static/kit/builder/stack-dialog/hooks.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/index.d.ts +5 -0
- package/storybook-static/kit/builder/stack-dialog/index.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/provider.d.ts +3 -0
- package/storybook-static/kit/builder/stack-dialog/provider.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/renderer.d.ts +6 -0
- package/storybook-static/kit/builder/stack-dialog/renderer.d.ts.map +1 -0
- package/storybook-static/kit/builder/stack-dialog/types.d.ts +20 -0
- package/storybook-static/kit/builder/stack-dialog/types.d.ts.map +1 -0
- package/storybook-static/kit/components/autocomplete/Autocomplete.d.ts +53 -0
- package/storybook-static/kit/components/autocomplete/Autocomplete.d.ts.map +1 -0
- package/storybook-static/kit/components/autocomplete/index.d.ts +4 -0
- package/storybook-static/kit/components/autocomplete/index.d.ts.map +1 -0
- package/storybook-static/kit/components/autocomplete/types.d.ts +19 -0
- package/storybook-static/kit/components/autocomplete/types.d.ts.map +1 -0
- package/storybook-static/kit/components/login/Login.d.ts +29 -0
- package/storybook-static/kit/components/login/Login.d.ts.map +1 -0
- package/storybook-static/kit/components/login/index.d.ts +2 -0
- package/storybook-static/kit/components/login/index.d.ts.map +1 -0
- package/storybook-static/kit/components/monthpicker/MonthPicker.d.ts +32 -0
- package/storybook-static/kit/components/monthpicker/MonthPicker.d.ts.map +1 -0
- package/storybook-static/kit/components/monthpicker/MonthRangePicker.d.ts +48 -0
- package/storybook-static/kit/components/monthpicker/MonthRangePicker.d.ts.map +1 -0
- package/storybook-static/kit/layouts/admin/components/AdminLayout.d.ts +17 -0
- package/storybook-static/kit/layouts/admin/components/AdminLayout.d.ts.map +1 -0
- package/storybook-static/kit/layouts/admin/components/ThemeToggle.d.ts +5 -0
- package/storybook-static/kit/layouts/admin/components/ThemeToggle.d.ts.map +1 -0
- package/storybook-static/kit/layouts/admin/hooks/menu.d.ts +13 -0
- package/storybook-static/kit/layouts/admin/hooks/menu.d.ts.map +1 -0
- package/storybook-static/kit/layouts/admin/providers/AdminMenuProvider.d.ts +7 -0
- package/storybook-static/kit/layouts/admin/providers/AdminMenuProvider.d.ts.map +1 -0
- package/storybook-static/kit/layouts/admin/types/index.d.ts +27 -0
- package/storybook-static/kit/layouts/admin/types/index.d.ts.map +1 -0
- package/storybook-static/kit/providers/ThemeProvider.d.ts +14 -0
- package/storybook-static/kit/providers/ThemeProvider.d.ts.map +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/a11y-5/manager-bundle.js +5 -0
- package/storybook-static/sb-addons/essentials-backgrounds-1/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-measure-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-3/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/interactions-4/manager-bundle.js +57 -0
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
- package/storybook-static/sb-addons/storysource-6/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon-wrapper.svg +46 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +797 -0
- package/storybook-static/sb-manager/globals-runtime.js +69653 -0
- package/storybook-static/sb-manager/globals.js +34 -0
- package/storybook-static/sb-manager/runtime.js +13181 -0
- package/storybook-static/shadcn/hooks/use-mobile.d.ts +2 -0
- package/storybook-static/shadcn/hooks/use-mobile.d.ts.map +1 -0
- package/storybook-static/shadcn/lib/utils.d.ts +3 -0
- package/storybook-static/shadcn/lib/utils.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/accordion.d.ts +8 -0
- package/storybook-static/shadcn/ui/accordion.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/alert-dialog.d.ts +15 -0
- package/storybook-static/shadcn/ui/alert-dialog.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/alert.d.ts +10 -0
- package/storybook-static/shadcn/ui/alert.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/aspect-ratio.d.ts +4 -0
- package/storybook-static/shadcn/ui/aspect-ratio.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/avatar.d.ts +7 -0
- package/storybook-static/shadcn/ui/avatar.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/badge.d.ts +10 -0
- package/storybook-static/shadcn/ui/badge.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/breadcrumb.d.ts +12 -0
- package/storybook-static/shadcn/ui/breadcrumb.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/button.d.ts +11 -0
- package/storybook-static/shadcn/ui/button.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/calendar.d.ts +9 -0
- package/storybook-static/shadcn/ui/calendar.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/card.d.ts +10 -0
- package/storybook-static/shadcn/ui/card.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/carousel.d.ts +20 -0
- package/storybook-static/shadcn/ui/carousel.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/chart.d.ts +41 -0
- package/storybook-static/shadcn/ui/chart.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/checkbox.d.ts +5 -0
- package/storybook-static/shadcn/ui/checkbox.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/collapsible.d.ts +6 -0
- package/storybook-static/shadcn/ui/collapsible.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/command.d.ts +19 -0
- package/storybook-static/shadcn/ui/command.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/context-menu.d.ts +26 -0
- package/storybook-static/shadcn/ui/context-menu.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/dialog.d.ts +16 -0
- package/storybook-static/shadcn/ui/dialog.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/drawer.d.ts +14 -0
- package/storybook-static/shadcn/ui/drawer.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/dropdown-menu.d.ts +26 -0
- package/storybook-static/shadcn/ui/dropdown-menu.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/form.d.ts +25 -0
- package/storybook-static/shadcn/ui/form.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/hover-card.d.ts +7 -0
- package/storybook-static/shadcn/ui/hover-card.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/input-otp.d.ts +12 -0
- package/storybook-static/shadcn/ui/input-otp.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/input.d.ts +4 -0
- package/storybook-static/shadcn/ui/input.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/label.d.ts +5 -0
- package/storybook-static/shadcn/ui/label.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/menubar.d.ts +27 -0
- package/storybook-static/shadcn/ui/menubar.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/navigation-menu.d.ts +15 -0
- package/storybook-static/shadcn/ui/navigation-menu.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/pagination.d.ts +14 -0
- package/storybook-static/shadcn/ui/pagination.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/popover.d.ts +8 -0
- package/storybook-static/shadcn/ui/popover.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/progress.d.ts +5 -0
- package/storybook-static/shadcn/ui/progress.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/radio-group.d.ts +6 -0
- package/storybook-static/shadcn/ui/radio-group.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/resizable.d.ts +9 -0
- package/storybook-static/shadcn/ui/resizable.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/scroll-area.d.ts +6 -0
- package/storybook-static/shadcn/ui/scroll-area.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/select.d.ts +16 -0
- package/storybook-static/shadcn/ui/select.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/separator.d.ts +5 -0
- package/storybook-static/shadcn/ui/separator.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/sheet.d.ts +14 -0
- package/storybook-static/shadcn/ui/sheet.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/sidebar.d.ts +70 -0
- package/storybook-static/shadcn/ui/sidebar.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/skeleton.d.ts +3 -0
- package/storybook-static/shadcn/ui/skeleton.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/slider.d.ts +5 -0
- package/storybook-static/shadcn/ui/slider.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/sonner.d.ts +4 -0
- package/storybook-static/shadcn/ui/sonner.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/switch.d.ts +5 -0
- package/storybook-static/shadcn/ui/switch.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/table.d.ts +11 -0
- package/storybook-static/shadcn/ui/table.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/tabs.d.ts +8 -0
- package/storybook-static/shadcn/ui/tabs.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/textarea.d.ts +4 -0
- package/storybook-static/shadcn/ui/textarea.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/toggle-group.d.ts +8 -0
- package/storybook-static/shadcn/ui/toggle-group.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/toggle.d.ts +10 -0
- package/storybook-static/shadcn/ui/toggle.d.ts.map +1 -0
- package/storybook-static/shadcn/ui/tooltip.d.ts +8 -0
- package/storybook-static/shadcn/ui/tooltip.d.ts.map +1 -0
- package/storybook-static/vite-inject-mocker-entry.js +18 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
3
|
import { useForm, useWatch, type Control, type FieldValues } from 'react-hook-form';
|
|
3
4
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
5
|
import { z } from 'zod';
|
|
@@ -6,8 +7,16 @@ import { cn } from '../../../../shadcn/lib/utils';
|
|
|
6
7
|
import { Button } from '../../../../shadcn/ui/button';
|
|
7
8
|
import { FormBuilderField } from './FormBuilderField';
|
|
8
9
|
import SectionBuilder from '../../section/SectionBuilder';
|
|
9
|
-
import type {
|
|
10
|
-
|
|
10
|
+
import type {
|
|
11
|
+
SectionLayout,
|
|
12
|
+
SectionGridOptions,
|
|
13
|
+
SectionFlexOptions,
|
|
14
|
+
SectionNode,
|
|
15
|
+
} from '../../section/types';
|
|
16
|
+
import type {
|
|
17
|
+
AutocompleteFetcher,
|
|
18
|
+
AutocompleteOption,
|
|
19
|
+
} from '../../../components/autocomplete/types';
|
|
11
20
|
|
|
12
21
|
export interface FormBuilderFieldConfig {
|
|
13
22
|
id?: string; // Optional ID for test fixtures
|
|
@@ -24,7 +33,15 @@ export interface FormBuilderFieldConfig {
|
|
|
24
33
|
| 'checkbox'
|
|
25
34
|
| 'switch'
|
|
26
35
|
| 'radio'
|
|
27
|
-
| 'date'
|
|
36
|
+
| 'date' // native input date
|
|
37
|
+
| 'date_picker' // UI DatePicker
|
|
38
|
+
| 'date_range' // UI DateRangePicker
|
|
39
|
+
| 'month' // UI MonthPicker (single month Date)
|
|
40
|
+
| 'month_range' // UI MonthRangePicker { start: Date, end: Date }
|
|
41
|
+
| 'time' // UI TimePicker (Date with time part)
|
|
42
|
+
| 'time_range' // UI TimeRangePicker { from: Date, to: Date }
|
|
43
|
+
| 'date_time' // UI DateTimePicker (Date with date+time)
|
|
44
|
+
| 'date_time_range' // UI DateTimeRangePicker { from: Date, to: Date }
|
|
28
45
|
| 'file'
|
|
29
46
|
| 'object'
|
|
30
47
|
| 'array';
|
|
@@ -42,25 +59,35 @@ export interface FormBuilderFieldConfig {
|
|
|
42
59
|
option: AutocompleteOption,
|
|
43
60
|
selected: boolean
|
|
44
61
|
) => React.ReactNode;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
// New autocomplete features
|
|
63
|
+
multiple?: boolean;
|
|
64
|
+
allowCustomValue?: boolean;
|
|
65
|
+
chipVariant?: 'default' | 'secondary' | 'destructive' | 'outline';
|
|
66
|
+
chipClassName?: string;
|
|
67
|
+
clearable?: boolean;
|
|
68
|
+
initialSelectedOptions?: AutocompleteOption | AutocompleteOption[] | null;
|
|
69
|
+
loadSelected?: (values: Array<string | number>) => Promise<AutocompleteOption[]>;
|
|
70
|
+
validation?:
|
|
71
|
+
| z.ZodType<unknown>
|
|
72
|
+
| {
|
|
73
|
+
pattern?: { value: RegExp; message: string };
|
|
74
|
+
min?: { value: number; message: string };
|
|
75
|
+
max?: { value: number; message: string };
|
|
76
|
+
minLength?: { value: number; message: string };
|
|
77
|
+
maxLength?: { value: number; message: string };
|
|
78
|
+
};
|
|
79
|
+
defaultValue?: unknown;
|
|
53
80
|
fields?: FormBuilderFieldConfig[]; // For nested object/array fields
|
|
54
81
|
dependencies?: {
|
|
55
82
|
field: string;
|
|
56
|
-
condition: (value:
|
|
83
|
+
condition: (value: unknown) => boolean;
|
|
57
84
|
action: 'show' | 'hide' | 'enable' | 'disable' | 'setValue';
|
|
58
|
-
value?:
|
|
85
|
+
value?: unknown;
|
|
59
86
|
}[];
|
|
60
87
|
onChange?: (
|
|
61
|
-
value:
|
|
62
|
-
setValue: (field: string, value:
|
|
63
|
-
getValues: () =>
|
|
88
|
+
value: unknown,
|
|
89
|
+
setValue: (field: string, value: unknown) => void,
|
|
90
|
+
getValues: () => Record<string, unknown>
|
|
64
91
|
) => void;
|
|
65
92
|
className?: string;
|
|
66
93
|
gridCols?: number;
|
|
@@ -73,8 +100,8 @@ export interface FormBuilderFieldConfig {
|
|
|
73
100
|
field: FormBuilderFieldConfig;
|
|
74
101
|
control: Control<FieldValues>;
|
|
75
102
|
fieldPath: string;
|
|
76
|
-
value:
|
|
77
|
-
onChange: (value:
|
|
103
|
+
value: unknown;
|
|
104
|
+
onChange: (value: unknown) => void;
|
|
78
105
|
addItem: () => void;
|
|
79
106
|
removeItem: (index: number) => void;
|
|
80
107
|
disabled?: boolean;
|
|
@@ -88,20 +115,34 @@ export interface FormBuilderFieldConfig {
|
|
|
88
115
|
};
|
|
89
116
|
conditional?: {
|
|
90
117
|
field: string;
|
|
91
|
-
value:
|
|
118
|
+
value: unknown;
|
|
92
119
|
}; // For conditional field visibility
|
|
93
120
|
hidden?: boolean; // Declarative hide
|
|
94
121
|
// Label placement control across inputs
|
|
95
122
|
labelPlacement?: 'stacked' | 'inline' | 'hidden';
|
|
96
123
|
// Wrapper container className (applies to the field wrapper, not the input)
|
|
97
124
|
wrapperClassName?: string;
|
|
125
|
+
// Picker-specific optional props (passed through to components when applicable)
|
|
126
|
+
minDate?: Date;
|
|
127
|
+
maxDate?: Date;
|
|
128
|
+
disabledDates?: Array<Date | { from: Date; to: Date }>;
|
|
129
|
+
numberOfMonths?: number;
|
|
130
|
+
popoverSide?: 'top' | 'right' | 'bottom' | 'left';
|
|
131
|
+
showFooter?: boolean;
|
|
132
|
+
cancelLabel?: string;
|
|
133
|
+
applyLabel?: string;
|
|
134
|
+
// Time picker specific
|
|
135
|
+
timePrecision?: 'hour' | 'minute' | 'second';
|
|
136
|
+
hourCycle?: 12 | 24;
|
|
137
|
+
minuteStep?: number;
|
|
138
|
+
secondStep?: number;
|
|
98
139
|
}
|
|
99
140
|
|
|
100
141
|
export interface FormBuilderSectionConfig {
|
|
101
142
|
id?: string;
|
|
102
143
|
title?: string;
|
|
103
144
|
description?: string;
|
|
104
|
-
fields
|
|
145
|
+
fields?: FormBuilderFieldConfig[];
|
|
105
146
|
variant?: 'card' | 'separator' | 'plain';
|
|
106
147
|
className?: string;
|
|
107
148
|
collapsible?: boolean;
|
|
@@ -110,19 +151,30 @@ export interface FormBuilderSectionConfig {
|
|
|
110
151
|
grid?: SectionGridOptions;
|
|
111
152
|
flex?: SectionFlexOptions;
|
|
112
153
|
hidden?: boolean; // Declarative hide
|
|
154
|
+
// Tabs layout support: when layout === 'tabs', provide tabs instead of direct fields
|
|
155
|
+
tabs?: Array<{
|
|
156
|
+
id: string;
|
|
157
|
+
label: React.ReactNode;
|
|
158
|
+
sections: FormBuilderSectionConfig[];
|
|
159
|
+
className?: string;
|
|
160
|
+
contentClassName?: string;
|
|
161
|
+
}>;
|
|
162
|
+
defaultTabId?: string;
|
|
163
|
+
tabsListClassName?: string;
|
|
164
|
+
tabsContentClassName?: string;
|
|
113
165
|
}
|
|
114
166
|
|
|
115
167
|
export interface FormBuilderProps {
|
|
116
168
|
sections: FormBuilderSectionConfig[];
|
|
117
|
-
schema?: z.ZodType<
|
|
118
|
-
defaultValues?: Record<string,
|
|
119
|
-
onSubmit: (data:
|
|
169
|
+
schema?: z.ZodType<unknown>;
|
|
170
|
+
defaultValues?: Record<string, unknown> | null;
|
|
171
|
+
onSubmit: (data: unknown) => void | Promise<void>;
|
|
120
172
|
onCancel?: () => void;
|
|
121
173
|
onReset?: () => void;
|
|
122
174
|
onFieldChange?: (
|
|
123
175
|
name: string,
|
|
124
|
-
value:
|
|
125
|
-
allValues: Record<string,
|
|
176
|
+
value: unknown,
|
|
177
|
+
allValues: Record<string, unknown>
|
|
126
178
|
) => void;
|
|
127
179
|
submitLabel?: string;
|
|
128
180
|
cancelLabel?: string;
|
|
@@ -160,15 +212,21 @@ export function FormBuilder({
|
|
|
160
212
|
const generatedSchema = useMemo(() => {
|
|
161
213
|
if (schema) return schema;
|
|
162
214
|
|
|
163
|
-
const generateFieldSchema = (
|
|
215
|
+
const generateFieldSchema = (
|
|
216
|
+
field: FormBuilderFieldConfig
|
|
217
|
+
): z.ZodType<unknown> => {
|
|
164
218
|
if (field.validation && field.validation instanceof z.ZodType) {
|
|
165
219
|
return field.validation;
|
|
166
220
|
}
|
|
167
221
|
|
|
168
222
|
// Handle validation object format
|
|
169
|
-
if (
|
|
223
|
+
if (
|
|
224
|
+
field.validation &&
|
|
225
|
+
typeof field.validation === 'object' &&
|
|
226
|
+
!(field.validation instanceof z.ZodType)
|
|
227
|
+
) {
|
|
170
228
|
const validationObj = field.validation;
|
|
171
|
-
let baseSchema: z.ZodType<
|
|
229
|
+
let baseSchema: z.ZodType<unknown>;
|
|
172
230
|
|
|
173
231
|
// Determine base schema type
|
|
174
232
|
switch (field.type) {
|
|
@@ -178,41 +236,79 @@ export function FormBuilder({
|
|
|
178
236
|
case 'number':
|
|
179
237
|
baseSchema = z.number();
|
|
180
238
|
break;
|
|
181
|
-
case '
|
|
182
|
-
|
|
239
|
+
case 'date_picker':
|
|
240
|
+
case 'month':
|
|
241
|
+
case 'date':
|
|
242
|
+
case 'time':
|
|
243
|
+
case 'date_time':
|
|
244
|
+
baseSchema = z.date();
|
|
245
|
+
break;
|
|
246
|
+
case 'date_range':
|
|
247
|
+
case 'time_range':
|
|
248
|
+
case 'date_time_range':
|
|
249
|
+
baseSchema = z
|
|
250
|
+
.object({ from: z.date().optional().nullable(), to: z.date().optional().nullable() })
|
|
251
|
+
.nullable();
|
|
252
|
+
break;
|
|
253
|
+
case 'month_range':
|
|
254
|
+
baseSchema = z
|
|
255
|
+
.object({ start: z.date().optional().nullable(), end: z.date().optional().nullable() })
|
|
256
|
+
.nullable();
|
|
257
|
+
break;
|
|
258
|
+
case 'autocomplete': {
|
|
259
|
+
const single = z
|
|
260
|
+
.union([z.string(), z.number(), z.object({})])
|
|
261
|
+
.nullable();
|
|
262
|
+
const multi = z.array(
|
|
263
|
+
z.union([z.string(), z.number(), z.object({})])
|
|
264
|
+
);
|
|
265
|
+
baseSchema = field.multiple ? multi : single;
|
|
183
266
|
break;
|
|
267
|
+
}
|
|
184
268
|
case 'checkbox':
|
|
185
269
|
case 'switch':
|
|
186
270
|
baseSchema = z.boolean();
|
|
187
271
|
break;
|
|
188
|
-
case 'date':
|
|
189
|
-
baseSchema = z.date();
|
|
190
|
-
break;
|
|
191
272
|
default:
|
|
192
273
|
baseSchema = z.string();
|
|
193
274
|
}
|
|
194
275
|
|
|
195
276
|
// Apply validation constraints
|
|
196
277
|
if (validationObj.pattern && baseSchema instanceof z.ZodString) {
|
|
197
|
-
baseSchema = baseSchema.regex(
|
|
278
|
+
baseSchema = baseSchema.regex(
|
|
279
|
+
validationObj.pattern.value,
|
|
280
|
+
validationObj.pattern.message
|
|
281
|
+
);
|
|
198
282
|
}
|
|
199
283
|
if (validationObj.min && baseSchema instanceof z.ZodNumber) {
|
|
200
|
-
baseSchema = baseSchema.min(
|
|
284
|
+
baseSchema = baseSchema.min(
|
|
285
|
+
validationObj.min.value,
|
|
286
|
+
validationObj.min.message
|
|
287
|
+
);
|
|
201
288
|
}
|
|
202
289
|
if (validationObj.max && baseSchema instanceof z.ZodNumber) {
|
|
203
|
-
baseSchema = baseSchema.max(
|
|
290
|
+
baseSchema = baseSchema.max(
|
|
291
|
+
validationObj.max.value,
|
|
292
|
+
validationObj.max.message
|
|
293
|
+
);
|
|
204
294
|
}
|
|
205
295
|
if (validationObj.minLength && baseSchema instanceof z.ZodString) {
|
|
206
|
-
baseSchema = baseSchema.min(
|
|
296
|
+
baseSchema = baseSchema.min(
|
|
297
|
+
validationObj.minLength.value,
|
|
298
|
+
validationObj.minLength.message
|
|
299
|
+
);
|
|
207
300
|
}
|
|
208
301
|
if (validationObj.maxLength && baseSchema instanceof z.ZodString) {
|
|
209
|
-
baseSchema = baseSchema.max(
|
|
302
|
+
baseSchema = baseSchema.max(
|
|
303
|
+
validationObj.maxLength.value,
|
|
304
|
+
validationObj.maxLength.message
|
|
305
|
+
);
|
|
210
306
|
}
|
|
211
307
|
|
|
212
308
|
return field.required ? baseSchema : baseSchema.optional();
|
|
213
309
|
}
|
|
214
310
|
|
|
215
|
-
let fieldSchema: z.ZodType<
|
|
311
|
+
let fieldSchema: z.ZodType<unknown>;
|
|
216
312
|
|
|
217
313
|
switch (field.type) {
|
|
218
314
|
case 'email':
|
|
@@ -221,60 +317,85 @@ export function FormBuilder({
|
|
|
221
317
|
case 'number':
|
|
222
318
|
fieldSchema = z.number();
|
|
223
319
|
break;
|
|
224
|
-
case '
|
|
225
|
-
|
|
320
|
+
case 'date_picker':
|
|
321
|
+
case 'month':
|
|
322
|
+
case 'date':
|
|
323
|
+
case 'time':
|
|
324
|
+
case 'date_time':
|
|
325
|
+
fieldSchema = z.date();
|
|
326
|
+
break;
|
|
327
|
+
case 'date_range':
|
|
328
|
+
case 'time_range':
|
|
329
|
+
case 'date_time_range':
|
|
330
|
+
fieldSchema = z
|
|
331
|
+
.object({ from: z.date().optional().nullable(), to: z.date().optional().nullable() })
|
|
332
|
+
.nullable();
|
|
226
333
|
break;
|
|
334
|
+
case 'month_range':
|
|
335
|
+
fieldSchema = z
|
|
336
|
+
.object({ start: z.date().optional().nullable(), end: z.date().optional().nullable() })
|
|
337
|
+
.nullable();
|
|
338
|
+
break;
|
|
339
|
+
case 'autocomplete': {
|
|
340
|
+
const single = z
|
|
341
|
+
.union([z.string(), z.number(), z.object({})])
|
|
342
|
+
.nullable();
|
|
343
|
+
const multi = z.array(
|
|
344
|
+
z.union([z.string(), z.number(), z.object({})])
|
|
345
|
+
);
|
|
346
|
+
fieldSchema = field.multiple ? multi : single;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
227
349
|
case 'checkbox':
|
|
228
350
|
case 'switch':
|
|
229
351
|
fieldSchema = z.boolean();
|
|
230
352
|
break;
|
|
231
|
-
case 'date':
|
|
232
|
-
fieldSchema = z.date();
|
|
233
|
-
break;
|
|
234
353
|
case 'select':
|
|
235
354
|
case 'radio':
|
|
236
355
|
if (field.options && field.options.length > 0) {
|
|
237
356
|
// Build a union of literals to allow specific values, including null if present
|
|
238
|
-
const literals = field.options.map(opt =>
|
|
357
|
+
const literals: Array<z.ZodLiteral<string | number | null>> = field.options.map((opt) =>
|
|
358
|
+
z.literal(opt.value as string | number | null)
|
|
359
|
+
);
|
|
239
360
|
if (literals.length === 1) {
|
|
240
361
|
fieldSchema = literals[0];
|
|
362
|
+
} else {
|
|
363
|
+
fieldSchema = z.union(
|
|
364
|
+
literals as [
|
|
365
|
+
z.ZodLiteral<string | number | null>,
|
|
366
|
+
...z.ZodLiteral<string | number | null>[]
|
|
367
|
+
]
|
|
368
|
+
);
|
|
241
369
|
}
|
|
242
|
-
|
|
243
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
|
-
fieldSchema = z.union(literals as any);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
370
|
+
} else {
|
|
248
371
|
fieldSchema = z.string();
|
|
249
372
|
}
|
|
250
373
|
break;
|
|
251
374
|
case 'object':
|
|
252
375
|
if (field.fields) {
|
|
253
|
-
const objectSchema: Record<string, z.ZodType<
|
|
254
|
-
field.fields
|
|
376
|
+
const objectSchema: Record<string, z.ZodType<unknown>> = {};
|
|
377
|
+
for (const subField of field.fields) {
|
|
255
378
|
objectSchema[subField.name] = generateFieldSchema(subField);
|
|
256
|
-
}
|
|
379
|
+
}
|
|
257
380
|
fieldSchema = z.object(objectSchema);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
381
|
+
} else {
|
|
260
382
|
fieldSchema = z.object({});
|
|
261
383
|
}
|
|
262
384
|
break;
|
|
263
385
|
case 'array':
|
|
264
386
|
if (field.fields && field.fields.length > 0) {
|
|
265
|
-
const arrayItemSchema
|
|
266
|
-
|
|
387
|
+
const arrayItemSchema =
|
|
388
|
+
field.fields.length === 1
|
|
267
389
|
? generateFieldSchema(field.fields[0])
|
|
268
390
|
: z.object(
|
|
269
391
|
field.fields.reduce((acc, subField) => {
|
|
270
392
|
acc[subField.name] = generateFieldSchema(subField);
|
|
271
393
|
return acc;
|
|
272
|
-
}, {} as Record<string, z.ZodType<
|
|
394
|
+
}, {} as Record<string, z.ZodType<unknown>>)
|
|
273
395
|
);
|
|
274
396
|
fieldSchema = z.array(arrayItemSchema);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
fieldSchema = z.array(z.any());
|
|
397
|
+
} else {
|
|
398
|
+
fieldSchema = z.array(z.unknown());
|
|
278
399
|
}
|
|
279
400
|
break;
|
|
280
401
|
default:
|
|
@@ -284,39 +405,53 @@ export function FormBuilder({
|
|
|
284
405
|
return field.required ? fieldSchema : fieldSchema.optional();
|
|
285
406
|
};
|
|
286
407
|
|
|
287
|
-
const schemaObject: Record<string, z.ZodType<
|
|
408
|
+
const schemaObject: Record<string, z.ZodType<unknown>> = {};
|
|
288
409
|
|
|
289
|
-
|
|
290
|
-
section
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
410
|
+
const forEachField = (secs: FormBuilderSectionConfig[]) => {
|
|
411
|
+
for (const section of secs) {
|
|
412
|
+
// Traverse tabs if present
|
|
413
|
+
if (section.tabs && section.tabs.length > 0) {
|
|
414
|
+
for (const tab of section.tabs) {
|
|
415
|
+
forEachField(tab.sections);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
for (const field of (section.fields ?? [])) {
|
|
419
|
+
schemaObject[field.name] = generateFieldSchema(field);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
forEachField(sections);
|
|
294
425
|
|
|
295
426
|
return z.object(schemaObject);
|
|
296
427
|
}, [sections, schema]);
|
|
297
428
|
|
|
298
429
|
// Generate default values from field configs
|
|
299
430
|
const generatedDefaultValues = useMemo(() => {
|
|
300
|
-
const values: Record<string,
|
|
431
|
+
const values: Record<string, unknown> = { ...defaultValues };
|
|
301
432
|
|
|
302
433
|
const processFields = (fields: FormBuilderFieldConfig[]) => {
|
|
303
|
-
|
|
434
|
+
for (const field of fields) {
|
|
304
435
|
if (
|
|
305
|
-
values[field.name] === undefined
|
|
306
|
-
|
|
436
|
+
values[field.name] === undefined &&
|
|
437
|
+
field.defaultValue !== undefined
|
|
307
438
|
) {
|
|
308
439
|
values[field.name] = field.defaultValue;
|
|
309
440
|
}
|
|
310
441
|
|
|
311
442
|
if (field.type === 'object' && field.fields) {
|
|
312
443
|
if (!values[field.name]) values[field.name] = {};
|
|
313
|
-
const nestedValues: Record<string,
|
|
314
|
-
field.fields
|
|
444
|
+
const nestedValues: Record<string, unknown> = {};
|
|
445
|
+
for (const subField of field.fields) {
|
|
315
446
|
if (subField.defaultValue !== undefined) {
|
|
316
447
|
nestedValues[subField.name] = subField.defaultValue;
|
|
317
448
|
}
|
|
318
|
-
}
|
|
319
|
-
|
|
449
|
+
}
|
|
450
|
+
const existing =
|
|
451
|
+
values[field.name] && typeof values[field.name] === 'object'
|
|
452
|
+
? (values[field.name] as Record<string, unknown>)
|
|
453
|
+
: {};
|
|
454
|
+
values[field.name] = { ...nestedValues, ...existing };
|
|
320
455
|
}
|
|
321
456
|
|
|
322
457
|
if (field.type === 'array' && field.fields) {
|
|
@@ -324,17 +459,30 @@ export function FormBuilder({
|
|
|
324
459
|
values[field.name] = field.defaultValue || [];
|
|
325
460
|
}
|
|
326
461
|
}
|
|
327
|
-
}
|
|
462
|
+
}
|
|
328
463
|
};
|
|
329
464
|
|
|
330
|
-
|
|
465
|
+
const forEachSection = (secs: FormBuilderSectionConfig[]) => {
|
|
466
|
+
for (const section of secs) {
|
|
467
|
+
if (section.tabs && section.tabs.length > 0) {
|
|
468
|
+
for (const tab of section.tabs) {
|
|
469
|
+
forEachSection(tab.sections);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
processFields(section.fields ?? []);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
forEachSection(sections);
|
|
331
477
|
|
|
332
478
|
return values;
|
|
333
479
|
}, [sections, defaultValues]);
|
|
334
480
|
|
|
335
|
-
const form = useForm<
|
|
336
|
-
|
|
337
|
-
|
|
481
|
+
const form = useForm<FieldValues>({
|
|
482
|
+
// Dynamic schema shape: cast to any to satisfy resolver generics
|
|
483
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
484
|
+
resolver: zodResolver(generatedSchema as any) as unknown as import('react-hook-form').Resolver<FieldValues, any, FieldValues>,
|
|
485
|
+
defaultValues: generatedDefaultValues as FieldValues,
|
|
338
486
|
});
|
|
339
487
|
|
|
340
488
|
const { control, handleSubmit, reset, setValue, getValues } = form;
|
|
@@ -342,11 +490,21 @@ export function FormBuilder({
|
|
|
342
490
|
// Determine dependency fields to watch
|
|
343
491
|
const dependencyFields = useMemo(() => {
|
|
344
492
|
const set = new Set<string>();
|
|
345
|
-
|
|
346
|
-
section
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
493
|
+
const forEachField = (secs: FormBuilderSectionConfig[]) => {
|
|
494
|
+
for (const section of secs) {
|
|
495
|
+
if (section.tabs && section.tabs.length > 0) {
|
|
496
|
+
for (const tab of section.tabs) {
|
|
497
|
+
forEachField(tab.sections);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
for (const f of (section.fields ?? [])) {
|
|
501
|
+
for (const d of f.dependencies || []) {
|
|
502
|
+
set.add(d.field);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
forEachField(sections);
|
|
350
508
|
return Array.from(set);
|
|
351
509
|
}, [sections]);
|
|
352
510
|
|
|
@@ -356,16 +514,20 @@ export function FormBuilder({
|
|
|
356
514
|
// Always call useWatch to satisfy hooks rules. Passing an empty array is safe and returns an empty array.
|
|
357
515
|
const depValuesArr = useWatch({ control, name: dependencyFields });
|
|
358
516
|
const watchedValues = useMemo(() => {
|
|
359
|
-
if (!hasDependencies) return {} as Record<string,
|
|
360
|
-
const obj: Record<string,
|
|
361
|
-
dependencyFields.forEach((n, i) => {
|
|
517
|
+
if (!hasDependencies) return {} as Record<string, unknown>;
|
|
518
|
+
const obj: Record<string, unknown> = {};
|
|
519
|
+
dependencyFields.forEach((n, i) => {
|
|
520
|
+
obj[n] = (depValuesArr as unknown[])[i];
|
|
521
|
+
});
|
|
362
522
|
return obj;
|
|
363
523
|
// dependencyFields is stable from sections; depValuesArr changes only when values change
|
|
364
524
|
}, [hasDependencies, dependencyFields, depValuesArr]);
|
|
365
525
|
|
|
366
526
|
// Handle field dependencies
|
|
367
527
|
// Queue dependency-driven value updates to avoid calling setValue during render
|
|
368
|
-
const pendingValueUpdatesRef = useRef<Array<{ name: string; value:
|
|
528
|
+
const pendingValueUpdatesRef = useRef<Array<{ name: string; value: unknown }>>(
|
|
529
|
+
[]
|
|
530
|
+
);
|
|
369
531
|
|
|
370
532
|
const handleFieldDependencies = useCallback(
|
|
371
533
|
(field: FormBuilderFieldConfig) => {
|
|
@@ -373,7 +535,7 @@ export function FormBuilder({
|
|
|
373
535
|
|
|
374
536
|
const result: { disabled?: boolean; hidden?: boolean } = {};
|
|
375
537
|
|
|
376
|
-
field.dependencies
|
|
538
|
+
for (const dep of field.dependencies) {
|
|
377
539
|
const dependentValue = watchedValues[dep.field];
|
|
378
540
|
const conditionMet = dep.condition(dependentValue);
|
|
379
541
|
|
|
@@ -395,53 +557,61 @@ export function FormBuilder({
|
|
|
395
557
|
const currentValue = getValues(field.name);
|
|
396
558
|
if (currentValue !== dep.value) {
|
|
397
559
|
// Defer the update to an effect to prevent state changes during render
|
|
398
|
-
pendingValueUpdatesRef.current.push({
|
|
560
|
+
pendingValueUpdatesRef.current.push({
|
|
561
|
+
name: field.name,
|
|
562
|
+
value: dep.value,
|
|
563
|
+
});
|
|
399
564
|
}
|
|
400
565
|
}
|
|
401
566
|
break;
|
|
402
567
|
}
|
|
403
|
-
}
|
|
568
|
+
}
|
|
404
569
|
|
|
405
570
|
return result;
|
|
406
571
|
},
|
|
407
|
-
[hasDependencies, watchedValues, getValues]
|
|
572
|
+
[hasDependencies, watchedValues, getValues]
|
|
408
573
|
);
|
|
409
574
|
|
|
410
575
|
// Flush any pending setValue updates after watchedValues change
|
|
411
576
|
useEffect(() => {
|
|
412
577
|
if (pendingValueUpdatesRef.current.length === 0) return;
|
|
413
|
-
const updatesMap = new Map<string,
|
|
578
|
+
const updatesMap = new Map<string, unknown>();
|
|
414
579
|
// last write wins per field
|
|
415
|
-
|
|
580
|
+
for (const { name, value } of pendingValueUpdatesRef.current) {
|
|
581
|
+
updatesMap.set(name, value);
|
|
582
|
+
}
|
|
416
583
|
pendingValueUpdatesRef.current = [];
|
|
417
|
-
|
|
584
|
+
for (const [name, value] of updatesMap) {
|
|
418
585
|
const current = getValues(name);
|
|
419
586
|
if (current !== value) {
|
|
420
|
-
setValue(name, value, {
|
|
587
|
+
setValue(name, value, {
|
|
588
|
+
shouldDirty: false,
|
|
589
|
+
shouldTouch: false,
|
|
590
|
+
shouldValidate: false,
|
|
591
|
+
});
|
|
421
592
|
}
|
|
422
|
-
}
|
|
423
|
-
}, [
|
|
593
|
+
}
|
|
594
|
+
}, [setValue, getValues]);
|
|
424
595
|
|
|
425
596
|
// Handle field change with custom onChange
|
|
426
597
|
const handleFieldChange = useCallback(
|
|
427
|
-
(field: FormBuilderFieldConfig, value:
|
|
598
|
+
(field: FormBuilderFieldConfig, value: unknown) => {
|
|
428
599
|
if (field.onChange) {
|
|
429
600
|
field.onChange(value, setValue, getValues);
|
|
430
601
|
}
|
|
431
602
|
},
|
|
432
|
-
[setValue, getValues]
|
|
603
|
+
[setValue, getValues]
|
|
433
604
|
);
|
|
434
605
|
|
|
435
606
|
const handleFormSubmit = useCallback(
|
|
436
|
-
async (data:
|
|
607
|
+
async (data: unknown) => {
|
|
437
608
|
try {
|
|
438
609
|
await onSubmit(data);
|
|
439
|
-
}
|
|
440
|
-
catch (error) {
|
|
610
|
+
} catch (error) {
|
|
441
611
|
console.error('Form submission error:', error);
|
|
442
612
|
}
|
|
443
613
|
},
|
|
444
|
-
[onSubmit]
|
|
614
|
+
[onSubmit]
|
|
445
615
|
);
|
|
446
616
|
|
|
447
617
|
const handleReset = useCallback(() => {
|
|
@@ -451,52 +621,103 @@ export function FormBuilder({
|
|
|
451
621
|
|
|
452
622
|
// Build SectionBuilder nodes from form sections/fields
|
|
453
623
|
const sectionNodes: SectionNode[] = useMemo(() => {
|
|
454
|
-
|
|
455
|
-
|
|
624
|
+
const buildLeavesFromFields = (fields?: FormBuilderFieldConfig[]): SectionNode['children'] =>
|
|
625
|
+
(fields ?? [])
|
|
626
|
+
.map((field) => {
|
|
627
|
+
const fieldState = handleFieldDependencies(field);
|
|
628
|
+
if (field.hidden || fieldState.hidden) return null;
|
|
629
|
+
|
|
630
|
+
const spanMd = Math.max(1, Math.min(12, field.gridCols ?? 1));
|
|
631
|
+
|
|
632
|
+
return {
|
|
633
|
+
key: field.name,
|
|
634
|
+
span: { base: 1, md: spanMd },
|
|
635
|
+
className: field.wrapperClassName,
|
|
636
|
+
hidden: field.hidden,
|
|
637
|
+
content: (
|
|
638
|
+
<FormBuilderField
|
|
639
|
+
key={field.name}
|
|
640
|
+
field={{
|
|
641
|
+
...field,
|
|
642
|
+
disabled: field.disabled || fieldState.disabled,
|
|
643
|
+
}}
|
|
644
|
+
control={control}
|
|
645
|
+
onChange={(value) => {
|
|
646
|
+
handleFieldChange(field, value);
|
|
647
|
+
onFieldChange?.(field.name, value, getValues());
|
|
648
|
+
}}
|
|
649
|
+
onFieldChange={onFieldChange}
|
|
650
|
+
/>
|
|
651
|
+
),
|
|
652
|
+
};
|
|
653
|
+
})
|
|
654
|
+
.filter(Boolean) as SectionNode['children'];
|
|
655
|
+
|
|
656
|
+
const buildSectionNode = (
|
|
657
|
+
section: FormBuilderSectionConfig,
|
|
658
|
+
sectionIndex: number,
|
|
659
|
+
): SectionNode => {
|
|
660
|
+
const baseNode: SectionNode = {
|
|
456
661
|
id: section.id ?? `section-${sectionIndex}`,
|
|
457
662
|
title: section.title,
|
|
458
663
|
subtitle: section.description,
|
|
459
664
|
variant: section.variant ?? 'plain',
|
|
460
665
|
className: section.className,
|
|
461
|
-
layout: section.layout ?? 'grid',
|
|
666
|
+
layout: section.layout ?? (section.tabs && section.tabs.length > 0 ? 'tabs' : 'grid'),
|
|
462
667
|
grid: section.grid ?? { cols: 1, mdCols: 2, gap: 'gap-4' },
|
|
463
668
|
flex: section.flex,
|
|
464
669
|
hidden: section.hidden,
|
|
465
|
-
children: section.fields
|
|
466
|
-
.map((field) => {
|
|
467
|
-
const fieldState = handleFieldDependencies(field);
|
|
468
|
-
if (field.hidden || fieldState.hidden) return null;
|
|
469
|
-
|
|
470
|
-
const spanMd = Math.max(1, Math.min(12, field.gridCols ?? 1));
|
|
471
|
-
|
|
472
|
-
return {
|
|
473
|
-
key: field.name,
|
|
474
|
-
span: { base: 1, md: spanMd },
|
|
475
|
-
className: field.wrapperClassName,
|
|
476
|
-
hidden: field.hidden,
|
|
477
|
-
content: (
|
|
478
|
-
<FormBuilderField
|
|
479
|
-
key={field.name}
|
|
480
|
-
field={{ ...field, disabled: field.disabled || fieldState.disabled }}
|
|
481
|
-
control={control}
|
|
482
|
-
onChange={(value) => {
|
|
483
|
-
handleFieldChange(field, value);
|
|
484
|
-
onFieldChange?.(field.name, value, getValues());
|
|
485
|
-
}}
|
|
486
|
-
onFieldChange={onFieldChange}
|
|
487
|
-
/>
|
|
488
|
-
),
|
|
489
|
-
};
|
|
490
|
-
})
|
|
491
|
-
.filter(Boolean) as SectionNode['children'],
|
|
492
670
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
671
|
+
|
|
672
|
+
// Tabs layout
|
|
673
|
+
if (baseNode.layout === 'tabs' && section.tabs && section.tabs.length > 0) {
|
|
674
|
+
baseNode.defaultTabId = section.defaultTabId ?? section.tabs[0]?.id;
|
|
675
|
+
baseNode.tabsListClassName = section.tabsListClassName;
|
|
676
|
+
baseNode.tabsContentClassName = section.tabsContentClassName;
|
|
677
|
+
baseNode.tabs = section.tabs.map((tab, _tabIdx) => {
|
|
678
|
+
// Each tab can contain multiple sub-sections; wrap them under a container node
|
|
679
|
+
const nestedNodes = tab.sections.map((subSection, subIdx) => buildSectionNode(subSection, subIdx));
|
|
680
|
+
const containerNode: SectionNode = {
|
|
681
|
+
id: `${baseNode.id}-tab-${tab.id}`,
|
|
682
|
+
title: undefined,
|
|
683
|
+
subtitle: undefined,
|
|
684
|
+
variant: 'plain',
|
|
685
|
+
layout: 'grid',
|
|
686
|
+
grid: section.grid ?? { cols: 1, mdCols: 2, gap: 'gap-4' },
|
|
687
|
+
children: nestedNodes,
|
|
688
|
+
} as SectionNode;
|
|
689
|
+
return {
|
|
690
|
+
id: tab.id,
|
|
691
|
+
label: tab.label,
|
|
692
|
+
className: tab.className,
|
|
693
|
+
contentClassName: tab.contentClassName,
|
|
694
|
+
node: containerNode,
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
return baseNode;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// Regular non-tab section with direct fields
|
|
701
|
+
baseNode.children = buildLeavesFromFields(section.fields);
|
|
702
|
+
return baseNode;
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
return sections.map((section, sectionIndex) => buildSectionNode(section, sectionIndex));
|
|
706
|
+
}, [
|
|
707
|
+
sections,
|
|
708
|
+
control,
|
|
709
|
+
handleFieldDependencies,
|
|
710
|
+
handleFieldChange,
|
|
711
|
+
onFieldChange,
|
|
712
|
+
getValues,
|
|
713
|
+
]);
|
|
496
714
|
|
|
497
715
|
return (
|
|
498
716
|
<div className={cn('space-y-6', className)}>
|
|
499
|
-
<form
|
|
717
|
+
<form
|
|
718
|
+
onSubmit={handleSubmit(handleFormSubmit)}
|
|
719
|
+
className={cn('space-y-6', formClassName)}
|
|
720
|
+
>
|
|
500
721
|
<SectionBuilder sections={sectionNodes} />
|
|
501
722
|
|
|
502
723
|
{showActions && (
|
|
@@ -505,21 +726,35 @@ export function FormBuilder({
|
|
|
505
726
|
'flex flex-col sm:flex-row gap-3',
|
|
506
727
|
showActionsSeparator && 'pt-6',
|
|
507
728
|
showActionsSeparator && 'border-t',
|
|
508
|
-
actionsClassName
|
|
729
|
+
actionsClassName
|
|
509
730
|
)}
|
|
510
731
|
>
|
|
511
|
-
<Button
|
|
732
|
+
<Button
|
|
733
|
+
type="submit"
|
|
734
|
+
disabled={isSubmitting}
|
|
735
|
+
className="sm:order-last"
|
|
736
|
+
>
|
|
512
737
|
{isSubmitting ? 'Submitting...' : submitLabel}
|
|
513
738
|
</Button>
|
|
514
739
|
|
|
515
740
|
{onCancel && (
|
|
516
|
-
<Button
|
|
741
|
+
<Button
|
|
742
|
+
type="button"
|
|
743
|
+
variant="outline"
|
|
744
|
+
onClick={onCancel}
|
|
745
|
+
disabled={isSubmitting}
|
|
746
|
+
>
|
|
517
747
|
{cancelLabel}
|
|
518
748
|
</Button>
|
|
519
749
|
)}
|
|
520
750
|
|
|
521
751
|
{onReset && (
|
|
522
|
-
<Button
|
|
752
|
+
<Button
|
|
753
|
+
type="button"
|
|
754
|
+
variant="outline"
|
|
755
|
+
onClick={handleReset}
|
|
756
|
+
disabled={isSubmitting}
|
|
757
|
+
>
|
|
523
758
|
{resetLabel}
|
|
524
759
|
</Button>
|
|
525
760
|
)}
|