@object-ui/components 3.1.5 → 3.3.1
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/CHANGELOG.md +38 -0
- package/README.md +21 -1
- package/dist/index.css +6339 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31896 -31523
- package/dist/index.umd.cjs +40 -40
- package/dist/{src → packages/components/src}/custom/empty.d.ts +12 -1
- package/dist/{src → packages/components/src}/custom/mobile-dialog-content.d.ts +1 -1
- package/dist/{src → packages/components/src}/renderers/action/action-bar.d.ts +12 -1
- package/dist/{src → packages/components/src}/ui/accordion.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/alert-dialog.d.ts +1 -1
- package/dist/packages/components/src/ui/aspect-ratio.d.ts +10 -0
- package/dist/{src → packages/components/src}/ui/avatar.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/button.d.ts +1 -1
- package/dist/packages/components/src/ui/chart.d.ts +56 -0
- package/dist/{src → packages/components/src}/ui/checkbox.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/collapsible.d.ts +8 -1
- package/dist/{src → packages/components/src}/ui/command.d.ts +2 -2
- package/dist/{src → packages/components/src}/ui/context-menu.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/dialog.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/drawer.d.ts +6 -10
- package/dist/{src → packages/components/src}/ui/dropdown-menu.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/form.d.ts +2 -2
- package/dist/{src → packages/components/src}/ui/hover-card.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/label.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/menubar.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/navigation-menu.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/popover.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/progress.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/radio-group.d.ts +1 -1
- package/dist/packages/components/src/ui/resizable.d.ts +7 -0
- package/dist/{src → packages/components/src}/ui/scroll-area.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/select.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/separator.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/sheet.d.ts +1 -2
- package/dist/{src → packages/components/src}/ui/sidebar.d.ts +1 -8
- package/dist/{src → packages/components/src}/ui/slider.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/switch.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/tabs.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/toast.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/toggle-group.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/toggle.d.ts +1 -1
- package/dist/{src → packages/components/src}/ui/tooltip.d.ts +1 -1
- package/package.json +68 -20
- package/.turbo/turbo-build.log +0 -64
- package/README_SHADCN_SYNC.md +0 -281
- package/TESTING.md +0 -335
- package/dist/src/ui/aspect-ratio.d.ts +0 -3
- package/dist/src/ui/chart.d.ts +0 -68
- package/dist/src/ui/resizable.d.ts +0 -14
- package/docs/FilterBuilder.md +0 -268
- package/metadata/Chart.component.yml +0 -30
- package/metadata/FilterBuilder.component.yml +0 -39
- package/metadata/GridLayout.component.yml +0 -27
- package/metadata/Menu.component.yml +0 -31
- package/metadata/ObjectForm.component.yml +0 -34
- package/metadata/ObjectGrid.component.yml +0 -72
- package/metadata/Page.component.yml +0 -24
- package/postcss.config.js +0 -14
- package/shadcn-components.json +0 -440
- package/src/SchemaRenderer.tsx +0 -28
- package/src/__tests__/PageRendererRegions.test.tsx +0 -668
- package/src/__tests__/README.md +0 -124
- package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +0 -811
- package/src/__tests__/__snapshots__/snapshot.test.tsx.snap +0 -327
- package/src/__tests__/accessibility.test.tsx +0 -137
- package/src/__tests__/action-bar.test.tsx +0 -206
- package/src/__tests__/api-consistency.test.tsx +0 -596
- package/src/__tests__/basic-renderers.test.tsx +0 -255
- package/src/__tests__/color-contrast.test.tsx +0 -212
- package/src/__tests__/complex-disclosure-renderers.test.tsx +0 -302
- package/src/__tests__/compliance.test.tsx +0 -72
- package/src/__tests__/config-field-renderer.test.tsx +0 -307
- package/src/__tests__/config-panel-renderer.test.tsx +0 -580
- package/src/__tests__/config-primitives.test.tsx +0 -106
- package/src/__tests__/edge-cases.test.tsx +0 -285
- package/src/__tests__/feedback-overlay-renderers.test.tsx +0 -349
- package/src/__tests__/filter-builder.test.tsx +0 -409
- package/src/__tests__/form-renderers.test.tsx +0 -364
- package/src/__tests__/layout-data-renderers.test.tsx +0 -340
- package/src/__tests__/mobile-accessibility.test.tsx +0 -120
- package/src/__tests__/navigation-overlay.test.tsx +0 -370
- package/src/__tests__/snapshot-critical.test.tsx +0 -317
- package/src/__tests__/snapshot.test.tsx +0 -205
- package/src/__tests__/test-utils.tsx +0 -190
- package/src/__tests__/use-config-draft.test.tsx +0 -295
- package/src/__tests__/view-compliance.test.tsx +0 -153
- package/src/__tests__/wcag-audit.test.tsx +0 -493
- package/src/custom/action-param-dialog.tsx +0 -264
- package/src/custom/button-group.tsx +0 -91
- package/src/custom/combobox.tsx +0 -104
- package/src/custom/config-field-renderer.tsx +0 -276
- package/src/custom/config-panel-renderer.tsx +0 -306
- package/src/custom/config-row.tsx +0 -50
- package/src/custom/date-picker.tsx +0 -61
- package/src/custom/empty.tsx +0 -112
- package/src/custom/field.tsx +0 -81
- package/src/custom/filter-builder.tsx +0 -418
- package/src/custom/index.ts +0 -21
- package/src/custom/input-group.tsx +0 -53
- package/src/custom/item.tsx +0 -201
- package/src/custom/kbd.tsx +0 -36
- package/src/custom/mobile-dialog-content.tsx +0 -67
- package/src/custom/native-select.tsx +0 -33
- package/src/custom/navigation-overlay.tsx +0 -334
- package/src/custom/section-header.tsx +0 -68
- package/src/custom/sort-builder.tsx +0 -129
- package/src/custom/spinner.tsx +0 -26
- package/src/custom/view-skeleton.tsx +0 -243
- package/src/custom/view-states.tsx +0 -153
- package/src/debug/DebugPanel.tsx +0 -313
- package/src/debug/__tests__/DebugPanel.test.tsx +0 -134
- package/src/debug/index.ts +0 -10
- package/src/hooks/use-config-draft.ts +0 -127
- package/src/hooks/use-mobile.tsx +0 -27
- package/src/index.css +0 -131
- package/src/index.ts +0 -47
- package/src/lib/use-sync-external-store-shim.ts +0 -10
- package/src/lib/use-sync-external-store-with-selector-shim.ts +0 -90
- package/src/lib/utils.tsx +0 -35
- package/src/new-components.test.ts +0 -73
- package/src/renderers/action/action-bar.tsx +0 -221
- package/src/renderers/action/action-button.tsx +0 -158
- package/src/renderers/action/action-group.tsx +0 -270
- package/src/renderers/action/action-icon.tsx +0 -150
- package/src/renderers/action/action-menu.tsx +0 -203
- package/src/renderers/action/index.ts +0 -19
- package/src/renderers/action/resolve-icon.ts +0 -35
- package/src/renderers/basic/button-group.tsx +0 -79
- package/src/renderers/basic/div.tsx +0 -60
- package/src/renderers/basic/html.tsx +0 -43
- package/src/renderers/basic/icon.tsx +0 -89
- package/src/renderers/basic/image.tsx +0 -49
- package/src/renderers/basic/index.ts +0 -18
- package/src/renderers/basic/navigation-menu.tsx +0 -81
- package/src/renderers/basic/pagination.tsx +0 -109
- package/src/renderers/basic/separator.tsx +0 -57
- package/src/renderers/basic/span.tsx +0 -63
- package/src/renderers/basic/text.tsx +0 -52
- package/src/renderers/complex/README-KANBAN.md +0 -208
- package/src/renderers/complex/TIMELINE.md +0 -353
- package/src/renderers/complex/__tests__/data-table-airtable-ux.test.tsx +0 -239
- package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +0 -275
- package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +0 -120
- package/src/renderers/complex/__tests__/data-table-editing.test.tsx +0 -221
- package/src/renderers/complex/__tests__/data-table.test.ts +0 -76
- package/src/renderers/complex/carousel.tsx +0 -69
- package/src/renderers/complex/data-table.tsx +0 -1243
- package/src/renderers/complex/filter-builder.tsx +0 -77
- package/src/renderers/complex/index.ts +0 -16
- package/src/renderers/complex/resizable.tsx +0 -66
- package/src/renderers/complex/scroll-area.tsx +0 -58
- package/src/renderers/complex/table.tsx +0 -95
- package/src/renderers/data-display/alert.tsx +0 -46
- package/src/renderers/data-display/avatar.tsx +0 -38
- package/src/renderers/data-display/badge.tsx +0 -55
- package/src/renderers/data-display/breadcrumb.tsx +0 -61
- package/src/renderers/data-display/index.ts +0 -18
- package/src/renderers/data-display/kbd.tsx +0 -50
- package/src/renderers/data-display/list.tsx +0 -75
- package/src/renderers/data-display/statistic.tsx +0 -95
- package/src/renderers/data-display/table.tsx +0 -78
- package/src/renderers/data-display/tree-view.tsx +0 -176
- package/src/renderers/disclosure/accordion.tsx +0 -69
- package/src/renderers/disclosure/collapsible.tsx +0 -53
- package/src/renderers/disclosure/index.ts +0 -11
- package/src/renderers/disclosure/toggle-group.tsx +0 -79
- package/src/renderers/feedback/empty.tsx +0 -49
- package/src/renderers/feedback/index.ts +0 -16
- package/src/renderers/feedback/loading.tsx +0 -78
- package/src/renderers/feedback/progress.tsx +0 -29
- package/src/renderers/feedback/skeleton.tsx +0 -31
- package/src/renderers/feedback/sonner.tsx +0 -56
- package/src/renderers/feedback/spinner.tsx +0 -55
- package/src/renderers/feedback/toast.tsx +0 -59
- package/src/renderers/feedback/toaster.tsx +0 -23
- package/src/renderers/form/button.tsx +0 -103
- package/src/renderers/form/calendar.tsx +0 -34
- package/src/renderers/form/checkbox.tsx +0 -71
- package/src/renderers/form/combobox.tsx +0 -48
- package/src/renderers/form/command.tsx +0 -58
- package/src/renderers/form/date-picker.tsx +0 -84
- package/src/renderers/form/file-upload.tsx +0 -184
- package/src/renderers/form/form.tsx +0 -533
- package/src/renderers/form/index.ts +0 -26
- package/src/renderers/form/input-otp.tsx +0 -51
- package/src/renderers/form/input.tsx +0 -121
- package/src/renderers/form/label.tsx +0 -45
- package/src/renderers/form/radio-group.tsx +0 -63
- package/src/renderers/form/select.tsx +0 -94
- package/src/renderers/form/slider.tsx +0 -61
- package/src/renderers/form/switch.tsx +0 -48
- package/src/renderers/form/textarea.tsx +0 -76
- package/src/renderers/form/toggle.tsx +0 -42
- package/src/renderers/index.ts +0 -18
- package/src/renderers/layout/aspect-ratio.tsx +0 -51
- package/src/renderers/layout/card.tsx +0 -85
- package/src/renderers/layout/container.tsx +0 -122
- package/src/renderers/layout/flex.tsx +0 -132
- package/src/renderers/layout/grid.tsx +0 -178
- package/src/renderers/layout/index.ts +0 -19
- package/src/renderers/layout/page.tsx +0 -466
- package/src/renderers/layout/semantic.tsx +0 -48
- package/src/renderers/layout/stack.tsx +0 -132
- package/src/renderers/layout/tabs.tsx +0 -97
- package/src/renderers/navigation/header-bar.tsx +0 -118
- package/src/renderers/navigation/index.ts +0 -10
- package/src/renderers/navigation/sidebar.tsx +0 -208
- package/src/renderers/overlay/alert-dialog.tsx +0 -72
- package/src/renderers/overlay/context-menu.tsx +0 -100
- package/src/renderers/overlay/dialog.tsx +0 -77
- package/src/renderers/overlay/drawer.tsx +0 -77
- package/src/renderers/overlay/dropdown-menu.tsx +0 -99
- package/src/renderers/overlay/hover-card.tsx +0 -55
- package/src/renderers/overlay/index.ts +0 -18
- package/src/renderers/overlay/menubar.tsx +0 -76
- package/src/renderers/overlay/popover.tsx +0 -56
- package/src/renderers/overlay/sheet.tsx +0 -77
- package/src/renderers/overlay/tooltip.tsx +0 -67
- package/src/renderers/placeholders.tsx +0 -107
- package/src/stories/CRMApp.stories.tsx +0 -706
- package/src/stories/ConfigPanel.stories.tsx +0 -232
- package/src/stories/Guide.mdx +0 -55
- package/src/stories/MockedData.stories.tsx +0 -121
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -68
- package/src/stories-json/Accessibility.mdx +0 -297
- package/src/stories-json/EdgeCases.stories.tsx +0 -160
- package/src/stories-json/GettingStarted.mdx +0 -89
- package/src/stories-json/Introduction.mdx +0 -127
- package/src/stories-json/accordion.stories.tsx +0 -43
- package/src/stories-json/aggrid.stories.tsx +0 -103
- package/src/stories-json/alert.stories.tsx +0 -39
- package/src/stories-json/aspect-ratio.stories.tsx +0 -34
- package/src/stories-json/avatar.stories.tsx +0 -38
- package/src/stories-json/badge.stories.tsx +0 -53
- package/src/stories-json/breadcrumb.stories.tsx +0 -30
- package/src/stories-json/button-group.stories.tsx +0 -43
- package/src/stories-json/button.stories.tsx +0 -73
- package/src/stories-json/calendar.stories.tsx +0 -85
- package/src/stories-json/card.stories.tsx +0 -48
- package/src/stories-json/carousel.stories.tsx +0 -33
- package/src/stories-json/charts.stories.tsx +0 -195
- package/src/stories-json/chatbot.stories.tsx +0 -248
- package/src/stories-json/code-editor.stories.tsx +0 -92
- package/src/stories-json/collapsible.stories.tsx +0 -40
- package/src/stories-json/controls.stories.tsx +0 -36
- package/src/stories-json/crm-live-data.stories.tsx +0 -154
- package/src/stories-json/dashboard.stories.tsx +0 -318
- package/src/stories-json/data-table.stories.tsx +0 -136
- package/src/stories-json/data_display_extras.stories.tsx +0 -102
- package/src/stories-json/date-picker.stories.tsx +0 -28
- package/src/stories-json/detail-view.stories.tsx +0 -258
- package/src/stories-json/dialog.stories.tsx +0 -43
- package/src/stories-json/feedback_extras.stories.tsx +0 -40
- package/src/stories-json/feedback_others.stories.tsx +0 -46
- package/src/stories-json/form-variants.stories.tsx +0 -210
- package/src/stories-json/form_advanced.stories.tsx +0 -117
- package/src/stories-json/form_extras.stories.tsx +0 -123
- package/src/stories-json/grid.stories.tsx +0 -56
- package/src/stories-json/icon.stories.tsx +0 -36
- package/src/stories-json/input.stories.tsx +0 -52
- package/src/stories-json/kanban.stories.tsx +0 -295
- package/src/stories-json/layout_extended.stories.tsx +0 -76
- package/src/stories-json/layout_flex.stories.tsx +0 -107
- package/src/stories-json/list-view.stories.tsx +0 -97
- package/src/stories-json/markdown.stories.tsx +0 -129
- package/src/stories-json/menus.stories.tsx +0 -63
- package/src/stories-json/metric-card.stories.tsx +0 -143
- package/src/stories-json/navigation-menu.stories.tsx +0 -37
- package/src/stories-json/object-aggrid-advanced.stories.tsx +0 -389
- package/src/stories-json/object-aggrid.stories.tsx +0 -252
- package/src/stories-json/object-form.stories.tsx +0 -130
- package/src/stories-json/object-gantt.stories.tsx +0 -114
- package/src/stories-json/object-grid.stories.tsx +0 -315
- package/src/stories-json/object-map.stories.tsx +0 -116
- package/src/stories-json/object-view.stories.tsx +0 -118
- package/src/stories-json/overlay_extras.stories.tsx +0 -113
- package/src/stories-json/overlay_others.stories.tsx +0 -76
- package/src/stories-json/page.stories.tsx +0 -55
- package/src/stories-json/reports.stories.tsx +0 -163
- package/src/stories-json/resizable.stories.tsx +0 -44
- package/src/stories-json/select.stories.tsx +0 -34
- package/src/stories-json/separator.stories.tsx +0 -41
- package/src/stories-json/sidebar.stories.tsx +0 -147
- package/src/stories-json/statistic.stories.tsx +0 -44
- package/src/stories-json/tabs.stories.tsx +0 -51
- package/src/stories-json/timeline.stories.tsx +0 -188
- package/src/stories-json/typography.stories.tsx +0 -45
- package/src/types/config-panel.ts +0 -101
- package/src/ui/accordion.tsx +0 -66
- package/src/ui/alert-dialog.tsx +0 -149
- package/src/ui/alert.tsx +0 -67
- package/src/ui/aspect-ratio.tsx +0 -15
- package/src/ui/avatar.tsx +0 -58
- package/src/ui/badge.tsx +0 -44
- package/src/ui/breadcrumb.tsx +0 -123
- package/src/ui/button.tsx +0 -66
- package/src/ui/calendar.tsx +0 -221
- package/src/ui/card.tsx +0 -87
- package/src/ui/carousel.tsx +0 -270
- package/src/ui/chart.tsx +0 -367
- package/src/ui/checkbox.tsx +0 -38
- package/src/ui/collapsible.tsx +0 -19
- package/src/ui/command.tsx +0 -161
- package/src/ui/context-menu.tsx +0 -208
- package/src/ui/dialog.tsx +0 -147
- package/src/ui/drawer.tsx +0 -126
- package/src/ui/dropdown-menu.tsx +0 -208
- package/src/ui/form.tsx +0 -186
- package/src/ui/hover-card.tsx +0 -37
- package/src/ui/index.ts +0 -56
- package/src/ui/input-otp.tsx +0 -79
- package/src/ui/input.tsx +0 -30
- package/src/ui/label.tsx +0 -34
- package/src/ui/menubar.tsx +0 -264
- package/src/ui/navigation-menu.tsx +0 -136
- package/src/ui/pagination.tsx +0 -125
- package/src/ui/popover.tsx +0 -39
- package/src/ui/progress.tsx +0 -36
- package/src/ui/radio-group.tsx +0 -52
- package/src/ui/resizable.tsx +0 -53
- package/src/ui/scroll-area.tsx +0 -56
- package/src/ui/select.tsx +0 -168
- package/src/ui/separator.tsx +0 -39
- package/src/ui/sheet.tsx +0 -151
- package/src/ui/sidebar.tsx +0 -866
- package/src/ui/skeleton.tsx +0 -23
- package/src/ui/slider.tsx +0 -40
- package/src/ui/sonner.tsx +0 -53
- package/src/ui/switch.tsx +0 -37
- package/src/ui/table.tsx +0 -125
- package/src/ui/tabs.tsx +0 -63
- package/src/ui/textarea.tsx +0 -30
- package/src/ui/toast.tsx +0 -137
- package/src/ui/toggle-group.tsx +0 -69
- package/src/ui/toggle.tsx +0 -53
- package/src/ui/tooltip.tsx +0 -38
- package/src/ui/typography.tsx +0 -85
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -70
- package/vitest.config.ts +0 -5
- /package/dist/{src → packages/components/src}/SchemaRenderer.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/action-param-dialog.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/button-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/combobox.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/config-field-renderer.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/config-panel-renderer.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/config-row.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/date-picker.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/field.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/filter-builder.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/input-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/item.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/kbd.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/native-select.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/navigation-overlay.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/section-header.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/sort-builder.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/spinner.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/view-skeleton.d.ts +0 -0
- /package/dist/{src → packages/components/src}/custom/view-states.d.ts +0 -0
- /package/dist/{src → packages/components/src}/debug/DebugPanel.d.ts +0 -0
- /package/dist/{src → packages/components/src}/debug/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/hooks/use-config-draft.d.ts +0 -0
- /package/dist/{src → packages/components/src}/hooks/use-mobile.d.ts +0 -0
- /package/dist/{src → packages/components/src}/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/lib/use-sync-external-store-shim.d.ts +0 -0
- /package/dist/{src → packages/components/src}/lib/use-sync-external-store-with-selector-shim.d.ts +0 -0
- /package/dist/{src → packages/components/src}/lib/utils.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/action-button.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/action-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/action-icon.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/action-menu.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/action/resolve-icon.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/button-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/div.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/html.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/icon.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/image.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/navigation-menu.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/pagination.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/separator.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/span.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/basic/text.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/carousel.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/data-table.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/filter-builder.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/resizable.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/scroll-area.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/complex/table.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/alert.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/avatar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/badge.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/breadcrumb.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/kbd.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/list.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/statistic.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/table.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/data-display/tree-view.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/disclosure/accordion.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/disclosure/collapsible.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/disclosure/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/disclosure/toggle-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/empty.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/loading.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/progress.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/skeleton.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/sonner.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/spinner.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/toast.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/feedback/toaster.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/button.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/calendar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/checkbox.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/combobox.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/command.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/date-picker.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/file-upload.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/form.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/input-otp.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/input.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/label.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/radio-group.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/select.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/slider.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/switch.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/textarea.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/form/toggle.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/aspect-ratio.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/card.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/container.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/flex.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/grid.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/page.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/semantic.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/stack.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/layout/tabs.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/navigation/header-bar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/navigation/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/navigation/sidebar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/alert-dialog.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/context-menu.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/dialog.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/drawer.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/dropdown-menu.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/hover-card.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/menubar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/popover.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/sheet.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/overlay/tooltip.d.ts +0 -0
- /package/dist/{src → packages/components/src}/renderers/placeholders.d.ts +0 -0
- /package/dist/{src → packages/components/src}/types/config-panel.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/alert.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/badge.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/breadcrumb.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/calendar.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/card.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/carousel.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/index.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/input-otp.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/input.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/pagination.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/skeleton.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/sonner.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/table.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/textarea.d.ts +0 -0
- /package/dist/{src → packages/components/src}/ui/typography.d.ts +0 -0
|
@@ -1,533 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
-
import type { FormSchema, FormField as FormFieldConfig, ValidationRule, FieldCondition, SelectOption } from '@object-ui/types';
|
|
11
|
-
import { useForm } from 'react-hook-form';
|
|
12
|
-
import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage, FormDescription } from '../../ui/form';
|
|
13
|
-
import { Button } from '../../ui/button';
|
|
14
|
-
import { Input } from '../../ui/input';
|
|
15
|
-
import { Textarea } from '../../ui/textarea';
|
|
16
|
-
import { Checkbox } from '../../ui/checkbox';
|
|
17
|
-
import { Switch } from '../../ui/switch';
|
|
18
|
-
import {
|
|
19
|
-
Select,
|
|
20
|
-
SelectTrigger,
|
|
21
|
-
SelectValue,
|
|
22
|
-
SelectContent,
|
|
23
|
-
SelectItem
|
|
24
|
-
} from '../../ui/select';
|
|
25
|
-
import { renderChildren } from '../../lib/utils';
|
|
26
|
-
import { Alert, AlertDescription } from '../../ui/alert';
|
|
27
|
-
import { AlertCircle, Loader2 } from 'lucide-react';
|
|
28
|
-
import { cn } from '../../lib/utils';
|
|
29
|
-
import React from 'react';
|
|
30
|
-
import { SchemaRendererContext } from '@object-ui/react';
|
|
31
|
-
|
|
32
|
-
// Form renderer component - Airtable-style feature-complete form
|
|
33
|
-
ComponentRegistry.register('form',
|
|
34
|
-
({ schema, className, onAction, ...props }: { schema: FormSchema; className?: string; onAction?: (action: any) => void; [key: string]: any }) => {
|
|
35
|
-
const {
|
|
36
|
-
defaultValues = {},
|
|
37
|
-
fields = [],
|
|
38
|
-
submitLabel = 'Submit',
|
|
39
|
-
cancelLabel = 'Cancel',
|
|
40
|
-
showCancel = false,
|
|
41
|
-
showSubmit = true,
|
|
42
|
-
layout = 'vertical',
|
|
43
|
-
columns = 1,
|
|
44
|
-
onSubmit: onSubmitProp,
|
|
45
|
-
onChange: onChangeProp,
|
|
46
|
-
onCancel: onCancelProp,
|
|
47
|
-
resetOnSubmit = false,
|
|
48
|
-
validationMode = 'onSubmit',
|
|
49
|
-
disabled = false,
|
|
50
|
-
} = schema;
|
|
51
|
-
|
|
52
|
-
// Initialize react-hook-form
|
|
53
|
-
const form = useForm({
|
|
54
|
-
defaultValues,
|
|
55
|
-
mode: validationMode,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
59
|
-
const [submitError, setSubmitError] = React.useState<string | null>(null);
|
|
60
|
-
|
|
61
|
-
// Read DataSource from SchemaRendererContext and propagate it to field
|
|
62
|
-
// widgets as a prop so they can dynamically load related records.
|
|
63
|
-
const schemaCtx = React.useContext(SchemaRendererContext);
|
|
64
|
-
const contextDataSource = schemaCtx?.dataSource ?? null;
|
|
65
|
-
|
|
66
|
-
// React to defaultValues changes
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
form.reset(defaultValues);
|
|
69
|
-
}, [defaultValues]);
|
|
70
|
-
|
|
71
|
-
// Watch for form changes - only track changes when onAction is available
|
|
72
|
-
React.useEffect(() => {
|
|
73
|
-
if (onAction) {
|
|
74
|
-
const subscription = form.watch((data) => {
|
|
75
|
-
onAction({
|
|
76
|
-
type: 'form_change',
|
|
77
|
-
data,
|
|
78
|
-
formData: data,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
return () => subscription.unsubscribe();
|
|
82
|
-
}
|
|
83
|
-
}, [form, onAction]);
|
|
84
|
-
|
|
85
|
-
// Handle form submission
|
|
86
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
87
|
-
setIsSubmitting(true);
|
|
88
|
-
setSubmitError(null);
|
|
89
|
-
|
|
90
|
-
// Defensive check: If data is an Event, use getValues()
|
|
91
|
-
let formData = data;
|
|
92
|
-
// Check for Event-like properties
|
|
93
|
-
const isEvent = data && (
|
|
94
|
-
(data as any).nativeEvent ||
|
|
95
|
-
typeof (data as any).preventDefault === 'function' ||
|
|
96
|
-
typeof (data as any).stopPropagation === 'function' ||
|
|
97
|
-
(data as any).target ||
|
|
98
|
-
(data as any).bubbles
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
if (isEvent) {
|
|
102
|
-
// This should not happen with RHF handleSubmit, but just in case
|
|
103
|
-
formData = form.getValues();
|
|
104
|
-
} else if (!formData || Object.keys(formData).length === 0) {
|
|
105
|
-
// Fallback: if data is empty check getValues(), in case RHF failed to pass it for some reason
|
|
106
|
-
const values = form.getValues();
|
|
107
|
-
if (values && Object.keys(values).length > 0) {
|
|
108
|
-
formData = values;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
if (onAction) {
|
|
114
|
-
const result = await onAction({
|
|
115
|
-
type: 'form_submit',
|
|
116
|
-
data: formData,
|
|
117
|
-
formData: formData,
|
|
118
|
-
}) as any;
|
|
119
|
-
|
|
120
|
-
// Check if submission returned an error
|
|
121
|
-
if (result?.error) {
|
|
122
|
-
setSubmitError(result.error);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (onSubmitProp && typeof onSubmitProp === 'function') {
|
|
128
|
-
await onSubmitProp(formData);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (resetOnSubmit) {
|
|
132
|
-
form.reset();
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
// Handle different error types safely
|
|
136
|
-
const errorMessage = error instanceof Error
|
|
137
|
-
? error.message
|
|
138
|
-
: typeof error === 'string'
|
|
139
|
-
? error
|
|
140
|
-
: 'An error occurred during submission';
|
|
141
|
-
setSubmitError(errorMessage);
|
|
142
|
-
|
|
143
|
-
// Log errors for debugging (dev environment only)
|
|
144
|
-
// process may not be defined in all environments
|
|
145
|
-
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
|
|
146
|
-
console.error('Form submission error:', error);
|
|
147
|
-
}
|
|
148
|
-
} finally {
|
|
149
|
-
setIsSubmitting(false);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// Handle cancel
|
|
154
|
-
const handleCancel = () => {
|
|
155
|
-
form.reset();
|
|
156
|
-
|
|
157
|
-
if (onCancelProp && typeof onCancelProp === 'function') {
|
|
158
|
-
onCancelProp();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (onAction) {
|
|
162
|
-
onAction({
|
|
163
|
-
type: 'form_cancel',
|
|
164
|
-
data: form.getValues(),
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// Determine grid classes based on columns (explicit classes for Tailwind JIT)
|
|
170
|
-
// Mobile-first: 1 column on mobile, responsive breakpoints for larger screens
|
|
171
|
-
const gridColsClass =
|
|
172
|
-
columns === 1 ? '' :
|
|
173
|
-
columns === 2 ? 'md:grid-cols-2' :
|
|
174
|
-
columns === 3 ? 'md:grid-cols-2 lg:grid-cols-3' :
|
|
175
|
-
'md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4';
|
|
176
|
-
|
|
177
|
-
const gridClass = columns > 1
|
|
178
|
-
? cn('grid gap-4', gridColsClass)
|
|
179
|
-
: 'space-y-4';
|
|
180
|
-
|
|
181
|
-
// Extract designer-related props and conflicting handlers
|
|
182
|
-
const {
|
|
183
|
-
'data-obj-id': dataObjId,
|
|
184
|
-
'data-obj-type': dataObjType,
|
|
185
|
-
style,
|
|
186
|
-
onSubmit: _ignoredOnSubmit, // Prevent overwriting our handleSubmit
|
|
187
|
-
onChange: _ignoredOnChange, // Prevent overwriting our onChange
|
|
188
|
-
// Extract schema props that should not be spread to DOM (handled separately by schema destructuring above)
|
|
189
|
-
submitLabel: _submitLabel,
|
|
190
|
-
cancelLabel: _cancelLabel,
|
|
191
|
-
showSubmit: _showSubmit,
|
|
192
|
-
showCancel: _showCancel,
|
|
193
|
-
resetOnSubmit: _resetOnSubmit,
|
|
194
|
-
defaultValues: _defaultValues,
|
|
195
|
-
inputType: _inputType,
|
|
196
|
-
...formProps
|
|
197
|
-
} = props;
|
|
198
|
-
|
|
199
|
-
return (
|
|
200
|
-
<Form {...form}>
|
|
201
|
-
<form
|
|
202
|
-
onSubmit={handleSubmit}
|
|
203
|
-
className={className}
|
|
204
|
-
{...formProps}
|
|
205
|
-
// Apply designer props
|
|
206
|
-
data-obj-id={dataObjId}
|
|
207
|
-
data-obj-type={dataObjType}
|
|
208
|
-
style={style}
|
|
209
|
-
>
|
|
210
|
-
{/* Form Error Alert */}
|
|
211
|
-
{submitError && (
|
|
212
|
-
<Alert variant="destructive" className="mb-4">
|
|
213
|
-
<AlertCircle className="h-4 w-4" />
|
|
214
|
-
<AlertDescription>{submitError}</AlertDescription>
|
|
215
|
-
</Alert>
|
|
216
|
-
)}
|
|
217
|
-
|
|
218
|
-
{/* Form Fields */}
|
|
219
|
-
{schema.children ? (
|
|
220
|
-
// If children are provided directly, render them
|
|
221
|
-
<div className={schema.fieldContainerClass || 'space-y-4'}>
|
|
222
|
-
{renderChildren(schema.children)}
|
|
223
|
-
</div>
|
|
224
|
-
) : (
|
|
225
|
-
// Otherwise render fields from schema
|
|
226
|
-
<div className={schema.fieldContainerClass || gridClass}>
|
|
227
|
-
{fields.map((field: FormFieldConfig) => {
|
|
228
|
-
const {
|
|
229
|
-
name,
|
|
230
|
-
label,
|
|
231
|
-
description,
|
|
232
|
-
type = 'input',
|
|
233
|
-
required = false,
|
|
234
|
-
disabled: fieldDisabled = false,
|
|
235
|
-
validation = {},
|
|
236
|
-
condition,
|
|
237
|
-
colSpan,
|
|
238
|
-
hidden,
|
|
239
|
-
widget,
|
|
240
|
-
visibleOn,
|
|
241
|
-
readonly,
|
|
242
|
-
...fieldProps
|
|
243
|
-
} = field;
|
|
244
|
-
|
|
245
|
-
// Skip hidden fields
|
|
246
|
-
if (hidden) return null;
|
|
247
|
-
|
|
248
|
-
// Handle conditional rendering with null/undefined safety
|
|
249
|
-
if (condition) {
|
|
250
|
-
const watchField = condition.field;
|
|
251
|
-
const watchValue = form.watch(watchField);
|
|
252
|
-
|
|
253
|
-
// Check for null/undefined before evaluating conditions
|
|
254
|
-
const hasValue = watchValue !== undefined && watchValue !== null;
|
|
255
|
-
|
|
256
|
-
if (condition.equals !== undefined && watchValue !== condition.equals) {
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
if (condition.notEquals !== undefined && watchValue === condition.notEquals) {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
if (condition.in && (!hasValue || !condition.in.includes(watchValue))) {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Build validation rules
|
|
268
|
-
const rules: any = {
|
|
269
|
-
...validation,
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
if (required) {
|
|
273
|
-
rules.required = typeof validation.required === 'string'
|
|
274
|
-
? validation.required
|
|
275
|
-
: `${label || name} is required`;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Use field.id or field.name for stable keys (never use index alone)
|
|
279
|
-
const fieldKey = field.id ?? name;
|
|
280
|
-
|
|
281
|
-
// Resolve the component type: prefer widget override, fallback to field type
|
|
282
|
-
const resolvedType = widget || type;
|
|
283
|
-
|
|
284
|
-
// colSpan classes for grid layout
|
|
285
|
-
const colSpanClass = colSpan && colSpan > 1
|
|
286
|
-
? colSpan === 2 ? 'col-span-2'
|
|
287
|
-
: colSpan === 3 ? 'col-span-3'
|
|
288
|
-
: colSpan >= 4 ? 'col-span-4'
|
|
289
|
-
: ''
|
|
290
|
-
: '';
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<FormField
|
|
294
|
-
key={fieldKey}
|
|
295
|
-
control={form.control}
|
|
296
|
-
name={name}
|
|
297
|
-
rules={rules}
|
|
298
|
-
render={({ field: formField }) => (
|
|
299
|
-
<FormItem className={colSpanClass || undefined}>
|
|
300
|
-
{label && (
|
|
301
|
-
<FormLabel className="text-xs sm:text-sm">
|
|
302
|
-
{label}
|
|
303
|
-
{required && (
|
|
304
|
-
<span className="text-destructive ml-1" aria-label="required">
|
|
305
|
-
*
|
|
306
|
-
</span>
|
|
307
|
-
)}
|
|
308
|
-
</FormLabel>
|
|
309
|
-
)}
|
|
310
|
-
<FormControl>
|
|
311
|
-
{/* Render the actual field component based on resolved type */}
|
|
312
|
-
{renderFieldComponent(resolvedType, {
|
|
313
|
-
...fieldProps,
|
|
314
|
-
// specialized fields needs raw metadata, but we should traverse down if it exists
|
|
315
|
-
// field is the field configuration loop variable
|
|
316
|
-
field: (field as any).field || field,
|
|
317
|
-
...formField,
|
|
318
|
-
inputType: fieldProps.inputType,
|
|
319
|
-
options: fieldProps.options,
|
|
320
|
-
placeholder: fieldProps.placeholder,
|
|
321
|
-
disabled: disabled || fieldDisabled || readonly || isSubmitting,
|
|
322
|
-
dataSource: contextDataSource,
|
|
323
|
-
})}
|
|
324
|
-
</FormControl>
|
|
325
|
-
{description && (
|
|
326
|
-
<FormDescription>{description}</FormDescription>
|
|
327
|
-
)}
|
|
328
|
-
<FormMessage />
|
|
329
|
-
</FormItem>
|
|
330
|
-
)}
|
|
331
|
-
/>
|
|
332
|
-
);
|
|
333
|
-
})}
|
|
334
|
-
</div>
|
|
335
|
-
)}
|
|
336
|
-
|
|
337
|
-
{/* Form Actions */}
|
|
338
|
-
{(schema.showActions !== false) && (
|
|
339
|
-
<div className={`flex flex-col sm:flex-row gap-2 ${layout === 'horizontal' ? 'sm:justify-end' : 'sm:justify-start'} mt-6`}>
|
|
340
|
-
{showCancel && (
|
|
341
|
-
<Button
|
|
342
|
-
type="button"
|
|
343
|
-
variant="outline"
|
|
344
|
-
onClick={handleCancel}
|
|
345
|
-
disabled={isSubmitting || disabled}
|
|
346
|
-
className="w-full sm:w-auto"
|
|
347
|
-
>
|
|
348
|
-
{cancelLabel}
|
|
349
|
-
</Button>
|
|
350
|
-
)}
|
|
351
|
-
{showSubmit && (
|
|
352
|
-
<Button
|
|
353
|
-
type="submit"
|
|
354
|
-
disabled={isSubmitting || disabled}
|
|
355
|
-
className="w-full sm:w-auto"
|
|
356
|
-
>
|
|
357
|
-
{isSubmitting && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
358
|
-
{submitLabel}
|
|
359
|
-
</Button>
|
|
360
|
-
)}
|
|
361
|
-
</div>
|
|
362
|
-
)}
|
|
363
|
-
</form>
|
|
364
|
-
</Form>
|
|
365
|
-
);
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
namespace: 'ui',
|
|
369
|
-
label: 'Form',
|
|
370
|
-
inputs: [
|
|
371
|
-
{
|
|
372
|
-
name: 'fields',
|
|
373
|
-
type: 'array',
|
|
374
|
-
label: 'Fields',
|
|
375
|
-
description: 'Array of field configurations with name, label, type, validation, etc.'
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
name: 'defaultValues',
|
|
379
|
-
type: 'object',
|
|
380
|
-
label: 'Default Values',
|
|
381
|
-
description: 'Object with default values for form fields'
|
|
382
|
-
},
|
|
383
|
-
{ name: 'submitLabel', type: 'string', label: 'Submit Button Label', defaultValue: 'Submit' },
|
|
384
|
-
{ name: 'cancelLabel', type: 'string', label: 'Cancel Button Label', defaultValue: 'Cancel' },
|
|
385
|
-
{ name: 'showCancel', type: 'boolean', label: 'Show Cancel Button', defaultValue: false },
|
|
386
|
-
{
|
|
387
|
-
name: 'layout',
|
|
388
|
-
type: 'enum',
|
|
389
|
-
enum: ['vertical', 'horizontal'],
|
|
390
|
-
label: 'Layout',
|
|
391
|
-
defaultValue: 'vertical'
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
name: 'columns',
|
|
395
|
-
type: 'number',
|
|
396
|
-
label: 'Number of Columns',
|
|
397
|
-
defaultValue: 1,
|
|
398
|
-
description: 'For multi-column layouts (1-4)'
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: 'validationMode',
|
|
402
|
-
type: 'enum',
|
|
403
|
-
enum: ['onSubmit', 'onBlur', 'onChange', 'onTouched', 'all'],
|
|
404
|
-
label: 'Validation Mode',
|
|
405
|
-
defaultValue: 'onSubmit'
|
|
406
|
-
},
|
|
407
|
-
{ name: 'resetOnSubmit', type: 'boolean', label: 'Reset After Submit', defaultValue: false },
|
|
408
|
-
{ name: 'disabled', type: 'boolean', label: 'Disabled', defaultValue: false },
|
|
409
|
-
{ name: 'className', type: 'string', label: 'CSS Class' },
|
|
410
|
-
{ name: 'fieldContainerClass', type: 'string', label: 'Field Container CSS Class' }
|
|
411
|
-
],
|
|
412
|
-
defaultProps: {
|
|
413
|
-
submitLabel: 'Submit',
|
|
414
|
-
cancelLabel: 'Cancel',
|
|
415
|
-
showCancel: false,
|
|
416
|
-
layout: 'vertical',
|
|
417
|
-
columns: 1,
|
|
418
|
-
validationMode: 'onSubmit',
|
|
419
|
-
resetOnSubmit: false,
|
|
420
|
-
disabled: false,
|
|
421
|
-
fields: [
|
|
422
|
-
{
|
|
423
|
-
name: 'name',
|
|
424
|
-
label: 'Name',
|
|
425
|
-
type: 'input',
|
|
426
|
-
required: true,
|
|
427
|
-
placeholder: 'Enter your name',
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
name: 'email',
|
|
431
|
-
label: 'Email',
|
|
432
|
-
type: 'input',
|
|
433
|
-
inputType: 'email',
|
|
434
|
-
required: true,
|
|
435
|
-
placeholder: 'Enter your email',
|
|
436
|
-
},
|
|
437
|
-
],
|
|
438
|
-
},
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
// Helper function to render field components with proper typing
|
|
443
|
-
interface RenderFieldProps {
|
|
444
|
-
inputType?: string;
|
|
445
|
-
options?: SelectOption[];
|
|
446
|
-
placeholder?: string;
|
|
447
|
-
value?: any;
|
|
448
|
-
onChange?: (value: any) => void;
|
|
449
|
-
disabled?: boolean;
|
|
450
|
-
[key: string]: any;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function renderFieldComponent(type: string, props: RenderFieldProps) {
|
|
454
|
-
// 1. Try to resolve specialized field widget from registry first
|
|
455
|
-
// We prioritize registry components (e.g., 'field.currency', 'field.date')
|
|
456
|
-
const RegisteredComponent = ComponentRegistry.get(type);
|
|
457
|
-
|
|
458
|
-
if (RegisteredComponent) {
|
|
459
|
-
// For specialized fields (e.g. fields package), they expect 'field' prop.
|
|
460
|
-
// Ensure we pass all props.
|
|
461
|
-
// Also pass 'schema' for standard renderers that expect it
|
|
462
|
-
return <RegisteredComponent schema={props} {...props} />;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const { inputType, options = [], placeholder, ...fieldProps } = props;
|
|
466
|
-
|
|
467
|
-
switch (type) {
|
|
468
|
-
case 'input':
|
|
469
|
-
if (inputType === 'file') {
|
|
470
|
-
// File inputs cannot be controlled with value prop
|
|
471
|
-
const { value, ...fileProps } = fieldProps;
|
|
472
|
-
return <Input type="file" placeholder={placeholder} className="min-h-[44px] sm:min-h-0" {...fileProps} />;
|
|
473
|
-
}
|
|
474
|
-
return <Input type={inputType || 'text'} placeholder={placeholder} className="min-h-[44px] sm:min-h-0" {...fieldProps} value={fieldProps.value ?? ''} />;
|
|
475
|
-
|
|
476
|
-
case 'textarea':
|
|
477
|
-
return <Textarea placeholder={placeholder} className="min-h-[44px] sm:min-h-0" {...fieldProps} value={fieldProps.value ?? ''} />;
|
|
478
|
-
|
|
479
|
-
case 'checkbox': {
|
|
480
|
-
// For checkbox, we need to handle the value differently
|
|
481
|
-
const { value, onChange, ...checkboxProps } = fieldProps;
|
|
482
|
-
return (
|
|
483
|
-
<Checkbox
|
|
484
|
-
checked={value}
|
|
485
|
-
onCheckedChange={onChange}
|
|
486
|
-
className="min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0"
|
|
487
|
-
{...checkboxProps}
|
|
488
|
-
/>
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
case 'switch': {
|
|
493
|
-
// For switch, we need to handle the value differently (same as checkbox)
|
|
494
|
-
const { value, onChange, ...switchProps } = fieldProps;
|
|
495
|
-
return (
|
|
496
|
-
<Switch
|
|
497
|
-
checked={value}
|
|
498
|
-
onCheckedChange={onChange}
|
|
499
|
-
className="min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0"
|
|
500
|
-
{...switchProps}
|
|
501
|
-
/>
|
|
502
|
-
);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
case 'select': {
|
|
506
|
-
// For select with react-hook-form, we need to handle the onChange
|
|
507
|
-
const { value: selectValue, onChange: selectOnChange, ...selectProps } = fieldProps;
|
|
508
|
-
|
|
509
|
-
// Safety check for options
|
|
510
|
-
if (!options || options.length === 0) {
|
|
511
|
-
return <div className="text-sm text-muted-foreground">No options available</div>;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return (
|
|
515
|
-
<Select value={selectValue} onValueChange={selectOnChange} {...selectProps}>
|
|
516
|
-
<SelectTrigger className="min-h-[44px] sm:min-h-0">
|
|
517
|
-
<SelectValue placeholder={placeholder ?? 'Select an option'} />
|
|
518
|
-
</SelectTrigger>
|
|
519
|
-
<SelectContent>
|
|
520
|
-
{options.map((opt: SelectOption) => (
|
|
521
|
-
<SelectItem key={opt.value} value={opt.value}>
|
|
522
|
-
{opt.label}
|
|
523
|
-
</SelectItem>
|
|
524
|
-
))}
|
|
525
|
-
</SelectContent>
|
|
526
|
-
</Select>
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
default:
|
|
531
|
-
return <Input type={inputType || 'text'} placeholder={placeholder} {...fieldProps} />;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import './form';
|
|
10
|
-
import './button';
|
|
11
|
-
import './label';
|
|
12
|
-
import './input';
|
|
13
|
-
import './textarea';
|
|
14
|
-
|
|
15
|
-
import './checkbox';
|
|
16
|
-
import './switch';
|
|
17
|
-
import './select';
|
|
18
|
-
import './radio-group';
|
|
19
|
-
import './slider';
|
|
20
|
-
import './toggle';
|
|
21
|
-
import './input-otp';
|
|
22
|
-
import './calendar';
|
|
23
|
-
import './date-picker';
|
|
24
|
-
import './file-upload';
|
|
25
|
-
import './combobox';
|
|
26
|
-
import './command';
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
-
import type { InputOTPSchema } from '@object-ui/types';
|
|
11
|
-
import { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from '../../ui';
|
|
12
|
-
|
|
13
|
-
ComponentRegistry.register('input-otp',
|
|
14
|
-
({ schema, className, onChange, value, ...props }: { schema: InputOTPSchema; className?: string; [key: string]: any }) => {
|
|
15
|
-
const length = schema.maxLength || 6;
|
|
16
|
-
const slots = Array.from({ length });
|
|
17
|
-
|
|
18
|
-
const handleChange = (val: string) => {
|
|
19
|
-
if (onChange) {
|
|
20
|
-
onChange(val);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<InputOTP
|
|
26
|
-
maxLength={length}
|
|
27
|
-
className={className}
|
|
28
|
-
value={value ?? schema.value}
|
|
29
|
-
onChange={handleChange}
|
|
30
|
-
{...props}
|
|
31
|
-
>
|
|
32
|
-
<InputOTPGroup>
|
|
33
|
-
{slots.map((_, i) => (
|
|
34
|
-
<InputOTPSlot key={i} index={i} />
|
|
35
|
-
))}
|
|
36
|
-
</InputOTPGroup>
|
|
37
|
-
</InputOTP>
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
namespace: 'ui',
|
|
42
|
-
label: 'Input OTP',
|
|
43
|
-
inputs: [
|
|
44
|
-
{ name: 'maxLength', type: 'number', label: 'Max Length', defaultValue: 6 },
|
|
45
|
-
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
46
|
-
],
|
|
47
|
-
defaultProps: {
|
|
48
|
-
maxLength: 6
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
);
|