@constructive-io/ui 0.4.1 → 0.6.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/LICENSE +21 -0
- package/README.md +17 -22
- package/dist/button-D4vqTxhp.d.cts +20 -0
- package/dist/button-D4vqTxhp.d.ts +20 -0
- package/dist/components/alert-dialog.cjs +129 -0
- package/dist/components/alert-dialog.cjs.map +1 -0
- package/dist/components/alert-dialog.d.cts +33 -0
- package/dist/components/alert-dialog.d.ts +23 -21
- package/dist/components/alert-dialog.js +98 -296
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.cjs +62 -0
- package/dist/components/alert.cjs.map +1 -0
- package/dist/components/alert.d.cts +19 -0
- package/dist/components/alert.d.ts +18 -13
- package/dist/components/alert.js +49 -31
- package/dist/components/alert.js.map +1 -1
- package/dist/components/app-bar.cjs +81 -0
- package/dist/components/app-bar.cjs.map +1 -0
- package/dist/components/app-bar.d.cts +27 -0
- package/dist/components/app-bar.d.ts +27 -0
- package/dist/components/app-bar.js +77 -0
- package/dist/components/app-bar.js.map +1 -0
- package/dist/components/app-shell.cjs +267 -0
- package/dist/components/app-shell.cjs.map +1 -0
- package/dist/components/app-shell.d.cts +98 -0
- package/dist/components/app-shell.d.ts +98 -0
- package/dist/components/app-shell.js +264 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/autocomplete.cjs +167 -0
- package/dist/components/autocomplete.cjs.map +1 -0
- package/dist/components/autocomplete.d.cts +28 -0
- package/dist/components/autocomplete.d.ts +24 -24
- package/dist/components/autocomplete.js +146 -397
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.cjs +39 -0
- package/dist/components/avatar.cjs.map +1 -0
- package/dist/components/avatar.d.cts +13 -0
- package/dist/components/avatar.d.ts +11 -11
- package/dist/components/avatar.js +24 -27
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.cjs +48 -0
- package/dist/components/badge.cjs.map +1 -0
- package/dist/components/badge.d.cts +15 -0
- package/dist/components/badge.d.ts +13 -13
- package/dist/components/badge.js +39 -38
- package/dist/components/badge.js.map +1 -1
- package/dist/components/breadcrumb.cjs +89 -0
- package/dist/components/breadcrumb.cjs.map +1 -0
- package/dist/components/breadcrumb.d.cts +15 -0
- package/dist/components/breadcrumb.d.ts +14 -13
- package/dist/components/breadcrumb.js +63 -137
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.cjs +75 -0
- package/dist/components/button.cjs.map +1 -0
- package/dist/components/button.d.cts +2 -0
- package/dist/components/button.d.ts +2 -17
- package/dist/components/button.js +66 -57
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-rac.cjs +72 -0
- package/dist/components/calendar-rac.cjs.map +1 -0
- package/dist/components/calendar-rac.d.cts +13 -0
- package/dist/components/calendar-rac.d.ts +8 -8
- package/dist/components/calendar-rac.js +49 -61
- package/dist/components/calendar-rac.js.map +1 -1
- package/dist/components/card.cjs +86 -0
- package/dist/components/card.cjs.map +1 -0
- package/dist/components/card.d.cts +17 -0
- package/dist/components/card.d.ts +15 -17
- package/dist/components/card.js +58 -57
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +19 -0
- package/dist/components/checkbox-group.cjs.map +1 -0
- package/dist/components/checkbox-group.d.cts +7 -0
- package/dist/components/checkbox-group.d.ts +5 -5
- package/dist/components/checkbox-group.js +12 -10
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/checkbox.cjs +67 -0
- package/dist/components/checkbox.cjs.map +1 -0
- package/dist/components/checkbox.d.cts +8 -0
- package/dist/components/checkbox.d.ts +6 -6
- package/dist/components/checkbox.js +58 -61
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.cjs +90 -0
- package/dist/components/collapsible.cjs.map +1 -0
- package/dist/components/collapsible.d.cts +45 -0
- package/dist/components/collapsible.d.ts +19 -28
- package/dist/components/collapsible.js +74 -112
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.cjs +257 -0
- package/dist/components/combobox.cjs.map +1 -0
- package/dist/components/combobox.d.cts +44 -0
- package/dist/components/combobox.d.ts +36 -36
- package/dist/components/combobox.js +229 -515
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.cjs +139 -0
- package/dist/components/command.cjs.map +1 -0
- package/dist/components/command.d.cts +24 -0
- package/dist/components/command.d.ts +22 -22
- package/dist/components/command.js +109 -240
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.cjs +139 -0
- package/dist/components/dialog.cjs.map +1 -0
- package/dist/components/dialog.d.cts +31 -0
- package/dist/components/dialog.d.ts +27 -31
- package/dist/components/dialog.js +112 -429
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.cjs +90 -0
- package/dist/components/dock.cjs.map +1 -0
- package/dist/components/dock.d.cts +30 -0
- package/dist/components/dock.d.ts +25 -26
- package/dist/components/dock.js +78 -104
- package/dist/components/dock.js.map +1 -1
- package/dist/components/drawer.cjs +115 -0
- package/dist/components/drawer.cjs.map +1 -0
- package/dist/components/drawer.d.cts +16 -0
- package/dist/components/drawer.d.ts +15 -15
- package/dist/components/drawer.js +77 -121
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +217 -0
- package/dist/components/dropdown-menu.cjs.map +1 -0
- package/dist/components/dropdown-menu.d.cts +53 -0
- package/dist/components/dropdown-menu.d.ts +49 -46
- package/dist/components/dropdown-menu.js +177 -357
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty.cjs +72 -0
- package/dist/components/empty.cjs.map +1 -0
- package/dist/components/empty.d.cts +15 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +64 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.cjs +186 -0
- package/dist/components/field.cjs.map +1 -0
- package/dist/components/field.d.cts +46 -0
- package/dist/components/field.d.ts +44 -49
- package/dist/components/field.js +166 -108
- package/dist/components/field.js.map +1 -1
- package/dist/components/flickering-grid.cjs +153 -0
- package/dist/components/flickering-grid.cjs.map +1 -0
- package/dist/components/flickering-grid.d.cts +16 -0
- package/dist/components/flickering-grid.d.ts +14 -13
- package/dist/components/flickering-grid.js +144 -141
- package/dist/components/flickering-grid.js.map +1 -1
- package/dist/components/flow-zoom-panel.cjs +62 -0
- package/dist/components/flow-zoom-panel.cjs.map +1 -0
- package/dist/components/flow-zoom-panel.d.cts +12 -0
- package/dist/components/flow-zoom-panel.d.ts +12 -0
- package/dist/components/flow-zoom-panel.js +61 -0
- package/dist/components/flow-zoom-panel.js.map +1 -0
- package/dist/components/form-control.cjs +65 -0
- package/dist/components/form-control.cjs.map +1 -0
- package/dist/components/form-control.d.cts +15 -0
- package/dist/components/form-control.d.ts +11 -11
- package/dist/components/form-control.js +56 -167
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.cjs +102 -0
- package/dist/components/form.cjs.map +1 -0
- package/dist/components/form.d.cts +2 -0
- package/dist/components/form.d.ts +2 -37
- package/dist/components/form.js +76 -163
- package/dist/components/form.js.map +1 -1
- package/dist/components/input-group.cjs +70 -0
- package/dist/components/input-group.cjs.map +1 -0
- package/dist/components/input-group.d.cts +16 -0
- package/dist/components/input-group.d.ts +14 -16
- package/dist/components/input-group.js +51 -163
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +37 -0
- package/dist/components/input.cjs.map +1 -0
- package/dist/components/input.d.cts +2 -0
- package/dist/components/input.d.ts +2 -11
- package/dist/components/input.js +30 -54
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.cjs +147 -0
- package/dist/components/json-input.cjs.map +1 -0
- package/dist/components/json-input.d.cts +26 -0
- package/dist/components/json-input.d.ts +20 -19
- package/dist/components/json-input.js +132 -340
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/label.cjs +27 -0
- package/dist/components/label.cjs.map +1 -0
- package/dist/components/label.d.cts +11 -0
- package/dist/components/label.d.ts +6 -6
- package/dist/components/label.js +17 -20
- package/dist/components/label.js.map +1 -1
- package/dist/components/motion-grid.cjs +68 -0
- package/dist/components/motion-grid.cjs.map +1 -0
- package/dist/components/motion-grid.d.cts +20 -0
- package/dist/components/motion-grid.d.ts +15 -15
- package/dist/components/motion-grid.js +59 -75
- package/dist/components/motion-grid.js.map +1 -1
- package/dist/components/multi-select.cjs +573 -0
- package/dist/components/multi-select.cjs.map +1 -0
- package/dist/components/multi-select.d.cts +198 -0
- package/dist/components/multi-select.d.ts +173 -173
- package/dist/components/multi-select.js +562 -874
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/page-header.cjs +30 -0
- package/dist/components/page-header.cjs.map +1 -0
- package/dist/components/page-header.d.cts +17 -0
- package/dist/components/page-header.d.ts +11 -11
- package/dist/components/page-header.js +23 -11
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/pagination.cjs +95 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +17 -0
- package/dist/components/pagination.d.ts +15 -17
- package/dist/components/pagination.js +70 -128
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.cjs +97 -0
- package/dist/components/popover.cjs.map +1 -0
- package/dist/components/popover.d.cts +40 -0
- package/dist/components/popover.d.ts +33 -28
- package/dist/components/popover.js +78 -178
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.cjs +156 -0
- package/dist/components/portal.cjs.map +1 -0
- package/dist/components/portal.d.cts +118 -0
- package/dist/components/portal.d.ts +33 -23
- package/dist/components/portal.js +128 -57
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.cjs +30 -0
- package/dist/components/progress.cjs.map +1 -0
- package/dist/components/progress.d.cts +10 -0
- package/dist/components/progress.d.ts +8 -8
- package/dist/components/progress.js +21 -24
- package/dist/components/progress.js.map +1 -1
- package/dist/components/progressive-blur-scroll-container.cjs +76 -0
- package/dist/components/progressive-blur-scroll-container.cjs.map +1 -0
- package/dist/components/progressive-blur-scroll-container.d.cts +25 -0
- package/dist/components/progressive-blur-scroll-container.d.ts +19 -19
- package/dist/components/progressive-blur-scroll-container.js +70 -137
- package/dist/components/progressive-blur-scroll-container.js.map +1 -1
- package/dist/components/progressive-blur.cjs +46 -0
- package/dist/components/progressive-blur.cjs.map +1 -0
- package/dist/components/progressive-blur.d.cts +17 -0
- package/dist/components/progressive-blur.d.ts +15 -14
- package/dist/components/progressive-blur.js +38 -63
- package/dist/components/progressive-blur.js.map +1 -1
- package/dist/components/radio-group.cjs +38 -0
- package/dist/components/radio-group.cjs.map +1 -0
- package/dist/components/radio-group.d.cts +10 -0
- package/dist/components/radio-group.d.ts +8 -8
- package/dist/components/radio-group.js +28 -30
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/record-picker.cjs +8 -0
- package/dist/components/record-picker.d.cts +16 -0
- package/dist/components/record-picker.d.ts +13 -13
- package/dist/components/record-picker.js +5 -364
- package/dist/components/resizable.cjs +50 -0
- package/dist/components/resizable.cjs.map +1 -0
- package/dist/components/resizable.d.cts +11 -0
- package/dist/components/resizable.d.ts +10 -10
- package/dist/components/resizable.js +29 -37
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/responsive-diagram.cjs +56 -0
- package/dist/components/responsive-diagram.cjs.map +1 -0
- package/dist/components/responsive-diagram.d.cts +10 -0
- package/dist/components/responsive-diagram.d.ts +7 -7
- package/dist/components/responsive-diagram.js +50 -60
- package/dist/components/responsive-diagram.js.map +1 -1
- package/dist/components/scroll-area.cjs +46 -0
- package/dist/components/scroll-area.cjs.map +1 -0
- package/dist/components/scroll-area.d.cts +12 -0
- package/dist/components/scroll-area.d.ts +11 -11
- package/dist/components/scroll-area.js +35 -62
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/select.cjs +204 -0
- package/dist/components/select.cjs.map +1 -0
- package/dist/components/select.d.cts +47 -0
- package/dist/components/select.d.ts +38 -38
- package/dist/components/select.js +172 -269
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +23 -0
- package/dist/components/separator.cjs.map +1 -0
- package/dist/components/separator.d.cts +2 -0
- package/dist/components/separator.d.ts +2 -11
- package/dist/components/separator.js +14 -18
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sheet.cjs +19 -0
- package/dist/components/sheet.d.cts +107 -0
- package/dist/components/sheet.d.ts +85 -90
- package/dist/components/sheet.js +3 -598
- package/dist/components/sidebar.cjs +29 -0
- package/dist/components/sidebar.d.cts +67 -0
- package/dist/components/sidebar.d.ts +63 -73
- package/dist/components/sidebar.js +3 -1215
- package/dist/components/skeleton.cjs +24 -0
- package/dist/components/skeleton.cjs.map +1 -0
- package/dist/components/skeleton.d.cts +11 -0
- package/dist/components/skeleton.d.ts +10 -6
- package/dist/components/skeleton.js +15 -10
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/sonner.cjs +23 -0
- package/dist/components/sonner.cjs.map +1 -0
- package/dist/components/sonner.d.cts +10 -0
- package/dist/components/sonner.d.ts +7 -7
- package/dist/components/sonner.js +17 -18
- package/dist/components/sonner.js.map +1 -1
- package/dist/components/stack/index.cjs +44 -0
- package/dist/components/stack/index.d.cts +2 -0
- package/dist/components/stack/index.d.ts +2 -674
- package/dist/components/stack/index.js +3 -1444
- package/dist/components/stepper.cjs +160 -0
- package/dist/components/stepper.cjs.map +1 -0
- package/dist/components/stepper.d.cts +32 -0
- package/dist/components/stepper.d.ts +27 -25
- package/dist/components/stepper.js +133 -261
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.cjs +35 -0
- package/dist/components/switch.cjs.map +1 -0
- package/dist/components/switch.d.cts +8 -0
- package/dist/components/switch.d.ts +7 -7
- package/dist/components/switch.js +26 -34
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +85 -0
- package/dist/components/table.cjs.map +1 -0
- package/dist/components/table.d.cts +23 -0
- package/dist/components/table.d.ts +23 -15
- package/dist/components/table.js +56 -46
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +49 -0
- package/dist/components/tabs.cjs.map +1 -0
- package/dist/components/tabs.d.cts +10 -0
- package/dist/components/tabs.d.ts +9 -9
- package/dist/components/tabs.js +31 -36
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.cjs +132 -0
- package/dist/components/tags.cjs.map +1 -0
- package/dist/components/tags.d.cts +36 -0
- package/dist/components/tags.d.ts +24 -28
- package/dist/components/tags.js +114 -438
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.cjs +34 -0
- package/dist/components/textarea.cjs.map +1 -0
- package/dist/components/textarea.d.cts +10 -0
- package/dist/components/textarea.d.ts +8 -8
- package/dist/components/textarea.js +27 -48
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/toast/index.cjs +9 -0
- package/dist/components/toast/index.d.cts +2 -0
- package/dist/components/toast/index.d.ts +2 -52
- package/dist/components/toast/index.js +3 -623
- package/dist/components/tooltip.cjs +67 -0
- package/dist/components/tooltip.cjs.map +1 -0
- package/dist/components/tooltip.d.cts +2 -0
- package/dist/components/tooltip.d.ts +2 -29
- package/dist/components/tooltip.js +53 -166
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unlink-button.cjs +24 -0
- package/dist/components/unlink-button.cjs.map +1 -0
- package/dist/components/unlink-button.d.cts +14 -0
- package/dist/components/unlink-button.d.ts +11 -11
- package/dist/components/unlink-button.js +18 -86
- package/dist/components/unlink-button.js.map +1 -1
- package/dist/form-DgRTv7O7.d.ts +54 -0
- package/dist/form-DoZEWSzb.d.cts +54 -0
- package/dist/index-CjA4CENl.d.cts +684 -0
- package/dist/index-CjA4CENl.d.ts +684 -0
- package/dist/index-UnM04j0t.d.cts +58 -0
- package/dist/index-UnM04j0t.d.ts +58 -0
- package/dist/index.cjs +408 -9346
- package/dist/index.d.cts +224 -2548
- package/dist/index.d.ts +224 -2548
- package/dist/index.js +65 -9022
- package/dist/input-CBrCuMH8.d.cts +11 -0
- package/dist/input-CBrCuMH8.d.ts +11 -0
- package/dist/motion-config-COCFHq1L.cjs +271 -0
- package/dist/motion-config-COCFHq1L.cjs.map +1 -0
- package/dist/motion-config-COsZ6azM.js +241 -0
- package/dist/motion-config-COsZ6azM.js.map +1 -0
- package/dist/record-picker-BbxngCeV.js +162 -0
- package/dist/record-picker-BbxngCeV.js.map +1 -0
- package/dist/record-picker-Bz4FApxD.cjs +167 -0
- package/dist/record-picker-Bz4FApxD.cjs.map +1 -0
- package/dist/rolldown-runtime-D_qnwXdH.cjs +35 -0
- package/dist/separator-BQEsr0Rc.d.cts +11 -0
- package/dist/separator-BQEsr0Rc.d.ts +11 -0
- package/dist/sheet-BLHnhLRH.js +425 -0
- package/dist/sheet-BLHnhLRH.js.map +1 -0
- package/dist/sheet-BdA0rfIz.cjs +515 -0
- package/dist/sheet-BdA0rfIz.cjs.map +1 -0
- package/dist/sidebar-CPy_fibW.cjs +608 -0
- package/dist/sidebar-CPy_fibW.cjs.map +1 -0
- package/dist/sidebar-Cfax0g0_.js +463 -0
- package/dist/sidebar-Cfax0g0_.js.map +1 -0
- package/dist/slot-C-jEfihz.cjs +122 -0
- package/dist/slot-C-jEfihz.cjs.map +1 -0
- package/dist/slot-EL8zfLG0.js +97 -0
- package/dist/slot-EL8zfLG0.js.map +1 -0
- package/dist/stack-DKdvlOM6.cjs +1771 -0
- package/dist/stack-DKdvlOM6.cjs.map +1 -0
- package/dist/stack-jMdxDrex.js +1531 -0
- package/dist/stack-jMdxDrex.js.map +1 -0
- package/dist/toast-D6MqijT2.cjs +316 -0
- package/dist/toast-D6MqijT2.cjs.map +1 -0
- package/dist/toast-D_BOLzm3.js +287 -0
- package/dist/toast-D_BOLzm3.js.map +1 -0
- package/dist/tooltip-CTRQoN1A.d.cts +29 -0
- package/dist/tooltip-CTRQoN1A.d.ts +29 -0
- package/dist/utils-BkMLyah9.js +12 -0
- package/dist/utils-BkMLyah9.js.map +1 -0
- package/dist/utils-CzTQ3-VI.cjs +17 -0
- package/dist/utils-CzTQ3-VI.cjs.map +1 -0
- package/package.json +288 -47
- package/src/styles/globals.css +155 -203
- package/dist/components/org-chart/index.d.ts +0 -54
- package/dist/components/org-chart/index.js +0 -861
- package/dist/components/org-chart/index.js.map +0 -1
- package/dist/components/record-picker.js.map +0 -1
- package/dist/components/sheet.js.map +0 -1
- package/dist/components/sidebar.js.map +0 -1
- package/dist/components/stack/index.js.map +0 -1
- package/dist/components/toast/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/components/form.js
CHANGED
|
@@ -1,179 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
|
-
import { twMerge } from 'tailwind-merge';
|
|
1
|
+
'use client';
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const slotPropValue = slotProps[propName];
|
|
24
|
-
const childPropValue = childProps[propName];
|
|
25
|
-
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
|
|
26
|
-
overrideProps[propName] = (...args) => {
|
|
27
|
-
childPropValue(...args);
|
|
28
|
-
slotPropValue(...args);
|
|
29
|
-
};
|
|
30
|
-
} else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
|
|
31
|
-
overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
32
|
-
} else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
|
|
33
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return { ...slotProps, ...overrideProps };
|
|
37
|
-
}
|
|
38
|
-
function isSlottable(child) {
|
|
39
|
-
return React.isValidElement(child);
|
|
40
|
-
}
|
|
41
|
-
var Slot = React.forwardRef((props, forwardedRef) => {
|
|
42
|
-
const { children, ...slotProps } = props;
|
|
43
|
-
if (isSlottable(children)) {
|
|
44
|
-
const childProps = children.props;
|
|
45
|
-
const childRef = childProps.ref;
|
|
46
|
-
return React.cloneElement(children, {
|
|
47
|
-
...mergeProps(slotProps, childProps),
|
|
48
|
-
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (React.Children.count(children) > 1) {
|
|
52
|
-
const childrenArray = React.Children.toArray(children);
|
|
53
|
-
const slottableChild = childrenArray.find(
|
|
54
|
-
(child) => React.isValidElement(child) && child.type === Slottable
|
|
55
|
-
);
|
|
56
|
-
if (slottableChild) {
|
|
57
|
-
const newElement = slottableChild.props.children;
|
|
58
|
-
if (isSlottable(newElement)) {
|
|
59
|
-
const newElementProps = newElement.props;
|
|
60
|
-
const newChildren = childrenArray.map((child) => {
|
|
61
|
-
if (child === slottableChild) {
|
|
62
|
-
return React.Children.count(newElementProps.children) > 1 ? React.Children.only(null) : newElementProps.children;
|
|
63
|
-
}
|
|
64
|
-
return child;
|
|
65
|
-
});
|
|
66
|
-
const childRef = newElementProps.ref;
|
|
67
|
-
return React.cloneElement(newElement, {
|
|
68
|
-
...mergeProps(slotProps, newElementProps),
|
|
69
|
-
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
70
|
-
children: newChildren
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
76
|
-
});
|
|
77
|
-
Slot.displayName = "Slot";
|
|
78
|
-
function Slottable({ children }) {
|
|
79
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
80
|
-
}
|
|
81
|
-
function cn(...inputs) {
|
|
82
|
-
return twMerge(clsx(inputs));
|
|
83
|
-
}
|
|
84
|
-
function Label({ className, ...props }) {
|
|
85
|
-
return /* @__PURE__ */ jsx(
|
|
86
|
-
"label",
|
|
87
|
-
{
|
|
88
|
-
"data-slot": "label",
|
|
89
|
-
className: cn(
|
|
90
|
-
`text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none
|
|
91
|
-
group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50
|
|
92
|
-
data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
|
|
93
|
-
className
|
|
94
|
-
),
|
|
95
|
-
...props
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
var Form = FormProvider;
|
|
100
|
-
var FormFieldContext = React.createContext({});
|
|
101
|
-
var FormField = ({
|
|
102
|
-
...props
|
|
103
|
-
}) => {
|
|
104
|
-
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
3
|
+
import { t as cn } from "../utils-BkMLyah9.js";
|
|
4
|
+
import { t as Slot } from "../slot-EL8zfLG0.js";
|
|
5
|
+
import { Label } from "./label.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Controller, FormProvider, useFormContext, useFormState } from "react-hook-form";
|
|
9
|
+
|
|
10
|
+
//#region src/components/form.tsx
|
|
11
|
+
const Form = FormProvider;
|
|
12
|
+
const FormFieldContext = React$1.createContext({});
|
|
13
|
+
const FormField = ({ ...props }) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
15
|
+
value: { name: props.name },
|
|
16
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
17
|
+
});
|
|
105
18
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
...fieldState
|
|
123
|
-
};
|
|
19
|
+
const useFormField = () => {
|
|
20
|
+
const fieldContext = React$1.useContext(FormFieldContext);
|
|
21
|
+
const itemContext = React$1.useContext(FormItemContext);
|
|
22
|
+
const { getFieldState } = useFormContext();
|
|
23
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
24
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
25
|
+
if (!fieldContext) throw new Error("useFormField should be used within <FormField>");
|
|
26
|
+
const { id } = itemContext;
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
name: fieldContext.name,
|
|
30
|
+
formItemId: `${id}-form-item`,
|
|
31
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
32
|
+
formMessageId: `${id}-form-item-message`,
|
|
33
|
+
...fieldState
|
|
34
|
+
};
|
|
124
35
|
};
|
|
125
|
-
|
|
36
|
+
const FormItemContext = React$1.createContext({});
|
|
126
37
|
function FormItem({ className, ...props }) {
|
|
127
|
-
|
|
128
|
-
|
|
38
|
+
const id = React$1.useId();
|
|
39
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
40
|
+
value: { id },
|
|
41
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
42
|
+
"data-slot": "form-item",
|
|
43
|
+
className: cn("grid gap-2", className),
|
|
44
|
+
...props
|
|
45
|
+
})
|
|
46
|
+
});
|
|
129
47
|
}
|
|
130
48
|
function FormLabel({ className, ...props }) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
...props
|
|
140
|
-
}
|
|
141
|
-
);
|
|
49
|
+
const { error, formItemId } = useFormField();
|
|
50
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
51
|
+
"data-slot": "form-label",
|
|
52
|
+
"data-error": !!error,
|
|
53
|
+
className: cn("data-[error=true]:text-destructive", className),
|
|
54
|
+
htmlFor: formItemId,
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
142
57
|
}
|
|
143
58
|
function FormControl({ ...props }) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
...props
|
|
153
|
-
}
|
|
154
|
-
);
|
|
59
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
60
|
+
return /* @__PURE__ */ jsx(Slot, {
|
|
61
|
+
"data-slot": "form-control",
|
|
62
|
+
id: formItemId,
|
|
63
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
64
|
+
"aria-invalid": !!error,
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
155
67
|
}
|
|
156
68
|
function FormDescription({ className, ...props }) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
...props
|
|
165
|
-
}
|
|
166
|
-
);
|
|
69
|
+
const { formDescriptionId } = useFormField();
|
|
70
|
+
return /* @__PURE__ */ jsx("p", {
|
|
71
|
+
"data-slot": "form-description",
|
|
72
|
+
id: formDescriptionId,
|
|
73
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
74
|
+
...props
|
|
75
|
+
});
|
|
167
76
|
}
|
|
168
77
|
function FormMessage({ className, ...props }) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
78
|
+
const { error, formMessageId } = useFormField();
|
|
79
|
+
const body = error ? String(error?.message ?? "") : props.children;
|
|
80
|
+
if (!body) return null;
|
|
81
|
+
return /* @__PURE__ */ jsx("p", {
|
|
82
|
+
"data-slot": "form-message",
|
|
83
|
+
id: formMessageId,
|
|
84
|
+
className: cn("text-destructive text-sm", className),
|
|
85
|
+
...props,
|
|
86
|
+
children: body
|
|
87
|
+
});
|
|
175
88
|
}
|
|
176
89
|
|
|
90
|
+
//#endregion
|
|
177
91
|
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
|
|
178
|
-
//# sourceMappingURL=form.js.map
|
|
179
92
|
//# sourceMappingURL=form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/slot.tsx","../../src/lib/utils.ts","../../src/components/label.tsx","../../src/components/form.tsx"],"names":["jsx","React2"],"mappings":";;;;;;AAQA,SAAS,eAAkB,IAAA,EAA0D;AACpF,EAAA,OAAO,CAAC,IAAA,KAAS;AAChB,IAAA,IAAA,CAAK,OAAA,CAAQ,CAAC,GAAA,KAAQ;AACrB,MAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC9B,QAAA,GAAA,CAAI,IAAI,CAAA;AAAA,MACT,CAAA,MAAA,IAAW,OAAO,IAAA,EAAM;AACvB,QAAC,IAAyC,OAAA,GAAU,IAAA;AAAA,MACrD;AAAA,IACD,CAAC,CAAA;AAAA,EACF,CAAA;AACD;AAMA,SAAS,UAAA,CACR,WACA,UAAA,EAC0B;AAC1B,EAAA,MAAM,aAAA,GAAyC,EAAE,GAAG,UAAA,EAAW;AAE/D,EAAA,KAAA,MAAW,YAAY,UAAA,EAAY;AAElC,IAAA,IAAI,aAAa,KAAA,EAAO;AAExB,IAAA,MAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,WAAW,QAAQ,CAAA;AAG1C,IAAA,IAAI,UAAA,CAAW,KAAK,QAAQ,CAAA,IAAK,OAAO,aAAA,KAAkB,UAAA,IAAc,OAAO,cAAA,KAAmB,UAAA,EAAY;AAC7G,MAAA,aAAA,CAAc,QAAQ,CAAA,GAAI,CAAA,GAAI,IAAA,KAAoB;AACjD,QAAA,cAAA,CAAe,GAAG,IAAI,CAAA;AACtB,QAAA,aAAA,CAAc,GAAG,IAA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AAA,MACJ,kBAAA,EAAkB,CAAC,KAAA,GAAQ,CAAA,EAAG,iBAAiB,CAAA,CAAA,GAAK,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA;AAAA,MACzF,cAAA,EAAc,CAAC,CAAC,KAAA;AAAA,MACf,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,eAAA,CAAgB,EAAE,SAAA,EAAW,GAAG,OAAM,EAA8B;AAC5E,EAAA,MAAM,EAAE,iBAAA,EAAkB,GAAI,YAAA,EAAa;AAE3C,EAAA,uBACCA,GAAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACV,EAAA,EAAI,iBAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACL;AAEF;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAA8B;AACxE,EAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAc,GAAI,YAAA,EAAa;AAC9C,EAAA,MAAM,OAAO,KAAA,GAAQ,MAAA,CAAO,OAAO,OAAA,IAAW,EAAE,IAAI,KAAA,CAAM,QAAA;AAE1D,EAAA,IAAI,CAAC,IAAA,EAAM;AACV,IAAA,OAAO,IAAA;AAAA,EACR;AAEA,EAAA,uBACCA,GAAAA,CAAC,GAAA,EAAA,EAAE,WAAA,EAAU,gBAAe,EAAA,EAAI,aAAA,EAAe,SAAA,EAAW,EAAA,CAAG,0BAAA,EAA4B,SAAS,CAAA,EAAI,GAAG,OACvG,QAAA,EAAA,IAAA,EACF,CAAA;AAEF","file":"form.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * Merges refs into a single callback ref.\n * React 19 compatible - handles refs as regular props.\n */\nfunction composeRefs<T>(...refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {\n\treturn (node) => {\n\t\trefs.forEach((ref) => {\n\t\t\tif (typeof ref === 'function') {\n\t\t\t\tref(node);\n\t\t\t} else if (ref != null) {\n\t\t\t\t(ref as React.MutableRefObject<T | null>).current = node;\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Merges props, handling special cases for className, style, and event handlers.\n * Excludes 'ref' from merging as it's handled separately.\n */\nfunction mergeProps(\n\tslotProps: Record<string, unknown>,\n\tchildProps: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst overrideProps: Record<string, unknown> = { ...childProps };\n\n\tfor (const propName in childProps) {\n\t\t// Skip ref - handled separately for composition\n\t\tif (propName === 'ref') continue;\n\n\t\tconst slotPropValue = slotProps[propName];\n\t\tconst childPropValue = childProps[propName];\n\n\t\t// Compose event handlers\n\t\tif (/^on[A-Z]/.test(propName) && typeof slotPropValue === 'function' && typeof childPropValue === 'function') {\n\t\t\toverrideProps[propName] = (...args: unknown[]) => {\n\t\t\t\tchildPropValue(...args);\n\t\t\t\tslotPropValue(...args);\n\t\t\t};\n\t\t}\n\t\t// Merge className\n\t\telse if (propName === 'className' && typeof slotPropValue === 'string' && typeof childPropValue === 'string') {\n\t\t\toverrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();\n\t\t}\n\t\t// Merge style\n\t\telse if (propName === 'style' && typeof slotPropValue === 'object' && typeof childPropValue === 'object') {\n\t\t\toverrideProps[propName] = { ...slotPropValue, ...childPropValue };\n\t\t}\n\t}\n\n\treturn { ...slotProps, ...overrideProps };\n}\n\n/**\n * Merges props from a parent component with a child element's props,\n * including proper ref composition. Use this in render prop patterns\n * where the parent needs to merge its props with the child's.\n *\n * @param parentProps - Props from the parent component (e.g., triggerProps from Base UI)\n * @param childElement - The child React element whose props will be merged\n * @returns Merged props object ready to pass to React.cloneElement\n */\nfunction mergePropsWithRef<T = HTMLElement>(\n\tparentProps: Record<string, unknown>,\n\tchildElement: React.ReactElement,\n): Record<string, unknown> {\n\tconst childProps = childElement.props as Record<string, unknown>;\n\tconst parentRef = parentProps.ref as React.Ref<T> | undefined;\n\tconst childRef = childProps.ref as React.Ref<T> | undefined;\n\n\tconst mergedProps = mergeProps(parentProps, childProps);\n\n\t// Compose refs if either exists\n\tif (parentRef || childRef) {\n\t\tmergedProps.ref = composeRefs(parentRef, childRef);\n\t}\n\n\treturn mergedProps;\n}\n\n/**\n * Check if a value is a valid slottable child (single React element).\n */\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n\treturn React.isValidElement(child);\n}\n\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n\tchildren?: React.ReactNode;\n}\n\n/**\n * Slot component - renders its child element with merged props.\n * Used for the `asChild` pattern where parent props are passed to child.\n * React 19 compatible - accesses ref from props instead of element.ref.\n */\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n\tconst { children, ...slotProps } = props;\n\n\t// Handle single child\n\tif (isSlottable(children)) {\n\t\tconst childProps = children.props as Record<string, unknown>;\n\t\t// React 19: ref is now a regular prop, not element.ref\n\t\tconst childRef = childProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\treturn React.cloneElement(children, {\n\t\t\t...mergeProps(slotProps, childProps),\n\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t} as React.Attributes);\n\t}\n\n\t// Handle multiple children - wrap Slottable content\n\tif (React.Children.count(children) > 1) {\n\t\tconst childrenArray = React.Children.toArray(children);\n\t\tconst slottableChild = childrenArray.find(\n\t\t\t(child) => React.isValidElement(child) && child.type === Slottable,\n\t\t) as React.ReactElement<{ children: React.ReactNode }> | undefined;\n\n\t\tif (slottableChild) {\n\t\t\tconst newElement = slottableChild.props.children;\n\t\t\tif (isSlottable(newElement)) {\n\t\t\t\tconst newElementProps = newElement.props as Record<string, unknown> & { children?: React.ReactNode };\n\t\t\t\tconst newChildren = childrenArray.map((child) => {\n\t\t\t\t\tif (child === slottableChild) {\n\t\t\t\t\t\treturn React.Children.count(newElementProps.children) > 1\n\t\t\t\t\t\t\t? React.Children.only(null)\n\t\t\t\t\t\t\t: newElementProps.children;\n\t\t\t\t\t}\n\t\t\t\t\treturn child;\n\t\t\t\t});\n\n\t\t\t\t// React 19: ref is now a regular prop\n\t\t\t\tconst childRef = newElementProps.ref as React.Ref<HTMLElement> | undefined;\n\n\t\t\t\treturn React.cloneElement(newElement, {\n\t\t\t\t\t...mergeProps(slotProps, newElementProps),\n\t\t\t\t\tref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,\n\t\t\t\t\tchildren: newChildren,\n\t\t\t\t} as React.Attributes);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Fallback: render children as-is (shouldn't normally happen with proper usage)\n\treturn <>{children}</>;\n});\n\nSlot.displayName = 'Slot';\n\n/**\n * Slottable component - marks content that should receive slot props.\n * Used when Slot has multiple children and you want to specify which one receives props.\n */\nfunction Slottable({ children }: { children: React.ReactNode }) {\n\treturn <>{children}</>;\n}\n\nexport { Slot, Slottable, composeRefs, mergeProps, mergePropsWithRef };\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '../lib/utils';\n\ntype LabelProps = React.ComponentProps<'label'>;\n\n/**\n * Label component for form controls.\n * Uses a standard HTML label element for maximum compatibility.\n */\nfunction Label({ className, ...props }: LabelProps) {\n\treturn (\n\t\t<label\n\t\t\tdata-slot=\"label\"\n\t\t\tclassName={cn(\n\t\t\t\t`text-foreground text-sm leading-4 font-medium select-none group-data-[disabled=true]:pointer-events-none\n\t\t\t\tgroup-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\n\t\t\t\tdata-[disabled]:pointer-events-none data-[disabled]:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Label };\nexport type { LabelProps };\n","'use client';\n\nimport * as React from 'react';\nimport { Slot } from '../lib/slot';\nimport {\n\tController,\n\tFormProvider,\n\tuseFormContext,\n\tuseFormState,\n\ttype ControllerProps,\n\ttype FieldPath,\n\ttype FieldValues,\n} from 'react-hook-form';\n\nimport { cn } from '../lib/utils';\nimport { Label } from './label';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n\tname: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n\t...props\n}: ControllerProps<TFieldValues, TName>) => {\n\treturn (\n\t\t<FormFieldContext.Provider value={{ name: props.name }}>\n\t\t\t<Controller {...props} />\n\t\t</FormFieldContext.Provider>\n\t);\n};\n\nconst useFormField = () => {\n\tconst fieldContext = React.useContext(FormFieldContext);\n\tconst itemContext = React.useContext(FormItemContext);\n\tconst { getFieldState } = useFormContext();\n\tconst formState = useFormState({ name: fieldContext.name });\n\tconst fieldState = getFieldState(fieldContext.name, formState);\n\n\tif (!fieldContext) {\n\t\tthrow new Error('useFormField should be used within <FormField>');\n\t}\n\n\tconst { id } = itemContext;\n\n\treturn {\n\t\tid,\n\t\tname: fieldContext.name,\n\t\tformItemId: `${id}-form-item`,\n\t\tformDescriptionId: `${id}-form-item-description`,\n\t\tformMessageId: `${id}-form-item-message`,\n\t\t...fieldState,\n\t};\n};\n\ntype FormItemContextValue = {\n\tid: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n\tconst id = React.useId();\n\n\treturn (\n\t\t<FormItemContext.Provider value={{ id }}>\n\t\t\t<div data-slot=\"form-item\" className={cn('grid gap-2', className)} {...props} />\n\t\t</FormItemContext.Provider>\n\t);\n}\n\nfunction FormLabel({ className, ...props }: React.ComponentProps<typeof Label>) {\n\tconst { error, formItemId } = useFormField();\n\n\treturn (\n\t\t<Label\n\t\t\tdata-slot=\"form-label\"\n\t\t\tdata-error={!!error}\n\t\t\tclassName={cn('data-[error=true]:text-destructive', className)}\n\t\t\thtmlFor={formItemId}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n\tconst { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n\treturn (\n\t\t<Slot\n\t\t\tdata-slot=\"form-control\"\n\t\t\tid={formItemId}\n\t\t\taria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n\t\t\taria-invalid={!!error}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { formDescriptionId } = useFormField();\n\n\treturn (\n\t\t<p\n\t\t\tdata-slot=\"form-description\"\n\t\t\tid={formDescriptionId}\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { error, formMessageId } = useFormField();\n\tconst body = error ? String(error?.message ?? '') : props.children;\n\n\tif (!body) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<p data-slot=\"form-message\" id={formMessageId} className={cn('text-destructive text-sm', className)} {...props}>\n\t\t\t{body}\n\t\t</p>\n\t);\n}\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };\n"]}
|
|
1
|
+
{"version":3,"file":"form.js","names":["React"],"sources":["../../src/components/form.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Slot } from '../lib/slot';\nimport {\n\tController,\n\tFormProvider,\n\tuseFormContext,\n\tuseFormState,\n\ttype ControllerProps,\n\ttype FieldPath,\n\ttype FieldValues,\n} from 'react-hook-form';\n\nimport { cn } from '../lib/utils';\nimport { Label } from './label';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n\tname: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n\t...props\n}: ControllerProps<TFieldValues, TName>) => {\n\treturn (\n\t\t<FormFieldContext.Provider value={{ name: props.name }}>\n\t\t\t<Controller {...props} />\n\t\t</FormFieldContext.Provider>\n\t);\n};\n\nconst useFormField = () => {\n\tconst fieldContext = React.useContext(FormFieldContext);\n\tconst itemContext = React.useContext(FormItemContext);\n\tconst { getFieldState } = useFormContext();\n\tconst formState = useFormState({ name: fieldContext.name });\n\tconst fieldState = getFieldState(fieldContext.name, formState);\n\n\tif (!fieldContext) {\n\t\tthrow new Error('useFormField should be used within <FormField>');\n\t}\n\n\tconst { id } = itemContext;\n\n\treturn {\n\t\tid,\n\t\tname: fieldContext.name,\n\t\tformItemId: `${id}-form-item`,\n\t\tformDescriptionId: `${id}-form-item-description`,\n\t\tformMessageId: `${id}-form-item-message`,\n\t\t...fieldState,\n\t};\n};\n\ntype FormItemContextValue = {\n\tid: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n\tconst id = React.useId();\n\n\treturn (\n\t\t<FormItemContext.Provider value={{ id }}>\n\t\t\t<div data-slot=\"form-item\" className={cn('grid gap-2', className)} {...props} />\n\t\t</FormItemContext.Provider>\n\t);\n}\n\nfunction FormLabel({ className, ...props }: React.ComponentProps<typeof Label>) {\n\tconst { error, formItemId } = useFormField();\n\n\treturn (\n\t\t<Label\n\t\t\tdata-slot=\"form-label\"\n\t\t\tdata-error={!!error}\n\t\t\tclassName={cn('data-[error=true]:text-destructive', className)}\n\t\t\thtmlFor={formItemId}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n\tconst { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n\treturn (\n\t\t<Slot\n\t\t\tdata-slot=\"form-control\"\n\t\t\tid={formItemId}\n\t\t\taria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n\t\t\taria-invalid={!!error}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { formDescriptionId } = useFormField();\n\n\treturn (\n\t\t<p\n\t\t\tdata-slot=\"form-description\"\n\t\t\tid={formDescriptionId}\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n\tconst { error, formMessageId } = useFormField();\n\tconst body = error ? String(error?.message ?? '') : props.children;\n\n\tif (!body) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<p data-slot=\"form-message\" id={formMessageId} className={cn('text-destructive text-sm', className)} {...props}>\n\t\t\t{body}\n\t\t</p>\n\t);\n}\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,OAAO;AASb,MAAM,mBAAmBA,QAAM,cAAqC,CAAC,CAA0B;AAE/F,MAAM,aAGJ,EACD,GAAG,YACwC;CAC3C,OACC,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,EAAE,MAAM,MAAM,KAAK;YACpD,oBAAC,YAAD,EAAY,GAAI,MAAQ;CACE;AAE7B;AAEA,MAAM,qBAAqB;CAC1B,MAAM,eAAeA,QAAM,WAAW,gBAAgB;CACtD,MAAM,cAAcA,QAAM,WAAW,eAAe;CACpD,MAAM,EAAE,kBAAkB,eA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,SAAS,YAAY,EAAE,WAAW,GAAG,SAAoC;CACxE,MAAM,EAAE,OAAO,kBAAkB,aAAa;CAC9C,MAAM,OAAO,QAAQ,OAAO,OAAO,WAAW,EAAE,IAAI,MAAM;CAE1D,IAAI,CAAC,MACJ,OAAO;CAGR,OACC,oBAAC,KAAD;EAAG,aAAU;EAAe,IAAI;EAAe,WAAW,GAAG,4BAA4B,SAAS;EAAG,GAAI;YACvG;CACC;AAEL"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_utils = require('../utils-CzTQ3-VI.cjs');
|
|
5
|
+
const require_components_input = require('./input.cjs');
|
|
6
|
+
const require_components_textarea = require('./textarea.cjs');
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let class_variance_authority = require("class-variance-authority");
|
|
9
|
+
|
|
10
|
+
//#region src/components/input-group.tsx
|
|
11
|
+
function InputGroup({ className, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
13
|
+
className: require_utils.cn("relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background bg-clip-padding text-base transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid=true],textarea[aria-invalid=true]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-primary/60 has-[input[aria-invalid=true],textarea[aria-invalid=true]]:border-destructive/36 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid=true],textarea[aria-invalid=true]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] has-[input:focus-visible,textarea:focus-visible]:ring-primary/35 sm:text-sm dark:bg-input/32 dark:bg-clip-border dark:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid=true],textarea[aria-invalid=true]]:before:shadow-[0_-1px_--theme(--color-white/8%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]", className),
|
|
14
|
+
"data-slot": "input-group",
|
|
15
|
+
role: "group",
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const inputGroupAddonVariants = (0, class_variance_authority.cva)("[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80", {
|
|
20
|
+
defaultVariants: { align: "inline-start" },
|
|
21
|
+
variants: { align: {
|
|
22
|
+
"block-end": "order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]",
|
|
23
|
+
"block-start": "order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]",
|
|
24
|
+
"inline-end": "has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]",
|
|
25
|
+
"inline-start": "has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]"
|
|
26
|
+
} }
|
|
27
|
+
});
|
|
28
|
+
function InputGroupAddon({ className, align = "inline-start", ...props }) {
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
30
|
+
className: require_utils.cn(inputGroupAddonVariants({ align }), className),
|
|
31
|
+
"data-align": align,
|
|
32
|
+
"data-slot": "input-group-addon",
|
|
33
|
+
onMouseDown: (e) => {
|
|
34
|
+
if (e.target.closest("button, a")) return;
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
const parent = e.currentTarget.parentElement;
|
|
37
|
+
const input = parent?.querySelector("input, textarea");
|
|
38
|
+
if (input && !parent?.querySelector("input:focus, textarea:focus")) input.focus();
|
|
39
|
+
},
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function InputGroupText({ className, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
45
|
+
className: require_utils.cn("[&_svg]:-mx-0.5 line-clamp-1 flex items-center gap-2 text-muted-foreground in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none", className),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function InputGroupInput({ className, ...props }) {
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input.Input, {
|
|
51
|
+
className,
|
|
52
|
+
unstyled: true,
|
|
53
|
+
...props
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function InputGroupTextarea({ className, ...props }) {
|
|
57
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_textarea.Textarea, {
|
|
58
|
+
className,
|
|
59
|
+
unstyled: true,
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.InputGroup = InputGroup;
|
|
66
|
+
exports.InputGroupAddon = InputGroupAddon;
|
|
67
|
+
exports.InputGroupInput = InputGroupInput;
|
|
68
|
+
exports.InputGroupText = InputGroupText;
|
|
69
|
+
exports.InputGroupTextarea = InputGroupTextarea;
|
|
70
|
+
//# sourceMappingURL=input-group.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-group.cjs","names":["cn","Input","Textarea"],"sources":["../../src/components/input-group.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\n\nimport { cn } from \"../lib/utils\";\nimport { Input, type InputProps } from \"./input\";\nimport { Textarea, type TextareaProps } from \"./textarea\";\n\nfunction InputGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n className={cn(\n // Match aria-invalid=\"true\" only. aria-invalid=\"false\" must not paint as invalid.\n \"relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background bg-clip-padding text-base transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid=true],textarea[aria-invalid=true]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-primary/60 has-[input[aria-invalid=true],textarea[aria-invalid=true]]:border-destructive/36 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid=true],textarea[aria-invalid=true]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] has-[input:focus-visible,textarea:focus-visible]:ring-primary/35 sm:text-sm dark:bg-input/32 dark:bg-clip-border dark:has-[input[aria-invalid=true],textarea[aria-invalid=true]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid=true],textarea[aria-invalid=true]]:before:shadow-[0_-1px_--theme(--color-white/8%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]\",\n className,\n )}\n data-slot=\"input-group\"\n role=\"group\"\n {...props}\n />\n );\n}\n\nconst inputGroupAddonVariants = cva(\n \"[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80\",\n {\n defaultVariants: {\n align: \"inline-start\",\n },\n variants: {\n align: {\n \"block-end\":\n \"order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]\",\n \"block-start\":\n \"order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]\",\n \"inline-end\":\n \"has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]\",\n \"inline-start\":\n \"has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]\",\n },\n },\n },\n);\n\nfunction InputGroupAddon({\n className,\n align = \"inline-start\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof inputGroupAddonVariants>) {\n return (\n <div\n className={cn(inputGroupAddonVariants({ align }), className)}\n data-align={align}\n data-slot=\"input-group-addon\"\n onMouseDown={(e) => {\n const target = e.target as HTMLElement;\n const isInteractive = target.closest(\"button, a\");\n if (isInteractive) return;\n e.preventDefault();\n const parent = e.currentTarget.parentElement;\n const input = parent?.querySelector<\n HTMLInputElement | HTMLTextAreaElement\n >(\"input, textarea\");\n if (input && !parent?.querySelector(\"input:focus, textarea:focus\")) {\n input.focus();\n }\n }}\n {...props}\n />\n );\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n className={cn(\n \"[&_svg]:-mx-0.5 line-clamp-1 flex items-center gap-2 text-muted-foreground in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction InputGroupInput({ className, ...props }: InputProps) {\n return <Input className={className} unstyled {...props} />;\n}\n\nfunction InputGroupTextarea({ className, ...props }: TextareaProps) {\n return <Textarea className={className} unstyled {...props} />;\n}\n\nexport {\n InputGroup,\n InputGroupAddon,\n InputGroupText,\n InputGroupInput,\n InputGroupTextarea,\n};\n"],"mappings":";;;;;;;;;;AASA,SAAS,WAAW,EAAE,WAAW,GAAG,SAAsC;CACxE,OACE,2CAAC,OAAD;EACE,WAAWA,iBAET,u1EACA,SACF;EACA,aAAU;EACV,MAAK;EACL,GAAI;CACL;AAEL;AAEA,MAAM,4DACJ,kcACA;CACE,iBAAiB,EACf,OAAO,eACT;CACA,UAAU,EACR,OAAO;EACL,aACE;EACF,eACE;EACF,cACE;EACF,gBACE;CACJ,EACF;AACF,CACF;AAEA,SAAS,gBAAgB,EACvB,WACA,QAAQ,gBACR,GAAG,SAC0E;CAC7E,OACE,2CAAC,OAAD;EACE,WAAWA,iBAAG,wBAAwB,EAAE,MAAM,CAAC,GAAG,SAAS;EAC3D,cAAY;EACZ,aAAU;EACV,cAAc,MAAM;GAGlB,IAFe,EAAE,OACY,QAAQ,WACrB,GAAG;GACnB,EAAE,eAAe;GACjB,MAAM,SAAS,EAAE,cAAc;GAC/B,MAAM,QAAQ,QAAQ,cAEpB,iBAAiB;GACnB,IAAI,SAAS,CAAC,QAAQ,cAAc,6BAA6B,GAC/D,MAAM,MAAM;EAEhB;EACA,GAAI;CACL;AAEL;AAEA,SAAS,eAAe,EAAE,WAAW,GAAG,SAAuC;CAC7E,OACE,2CAAC,QAAD;EACE,WAAWA,iBACT,2WACA,SACF;EACA,GAAI;CACL;AAEL;AAEA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAqB;CAC5D,OAAO,2CAACC,gCAAD;EAAkB;EAAW;EAAS,GAAI;CAAQ;AAC3D;AAEA,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAwB;CAClE,OAAO,2CAACC,sCAAD;EAAqB;EAAW;EAAS,GAAI;CAAQ;AAC9D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { n as InputProps } from "../input-CBrCuMH8.cjs";
|
|
2
|
+
import { TextareaProps } from "./textarea.cjs";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { VariantProps } from "class-variance-authority";
|
|
5
|
+
//#region src/components/input-group.d.ts
|
|
6
|
+
declare function InputGroup({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
7
|
+
declare const inputGroupAddonVariants: (props?: ({
|
|
8
|
+
align?: "inline-start" | "block-end" | "block-start" | "inline-end" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
declare function InputGroupAddon({ className, align, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>): React$1.JSX.Element;
|
|
11
|
+
declare function InputGroupText({ className, ...props }: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
12
|
+
declare function InputGroupInput({ className, ...props }: InputProps): React$1.JSX.Element;
|
|
13
|
+
declare function InputGroupTextarea({ className, ...props }: TextareaProps): React$1.JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, InputGroupTextarea };
|
|
16
|
+
//# sourceMappingURL=input-group.d.cts.map
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import '@base-ui/react/input';
|
|
8
|
-
|
|
9
|
-
declare function InputGroup({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1
|
+
import { n as InputProps } from "../input-CBrCuMH8.js";
|
|
2
|
+
import { TextareaProps } from "./textarea.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { VariantProps } from "class-variance-authority";
|
|
5
|
+
//#region src/components/input-group.d.ts
|
|
6
|
+
declare function InputGroup({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
10
7
|
declare const inputGroupAddonVariants: (props?: ({
|
|
11
|
-
|
|
12
|
-
} &
|
|
13
|
-
declare function InputGroupAddon({ className, align, ...props }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>):
|
|
14
|
-
declare function InputGroupText({ className, ...props }: React.ComponentProps<"span">):
|
|
15
|
-
declare function InputGroupInput({ className, ...props }: InputProps):
|
|
16
|
-
declare function InputGroupTextarea({ className, ...props }: TextareaProps):
|
|
17
|
-
|
|
8
|
+
align?: "inline-start" | "block-end" | "block-start" | "inline-end" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
declare function InputGroupAddon({ className, align, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>): React$1.JSX.Element;
|
|
11
|
+
declare function InputGroupText({ className, ...props }: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
12
|
+
declare function InputGroupInput({ className, ...props }: InputProps): React$1.JSX.Element;
|
|
13
|
+
declare function InputGroupTextarea({ className, ...props }: TextareaProps): React$1.JSX.Element;
|
|
14
|
+
//#endregion
|
|
18
15
|
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, InputGroupTextarea };
|
|
16
|
+
//# sourceMappingURL=input-group.d.ts.map
|