@constructive-io/ui 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button-D4vqTxhp.d.cts +20 -0
- package/dist/button-D4vqTxhp.d.ts +20 -0
- package/dist/components/alert-dialog.cjs +98 -302
- package/dist/components/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog.d.cts +22 -21
- package/dist/components/alert-dialog.d.ts +22 -21
- package/dist/components/alert-dialog.js +96 -281
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.cjs +51 -108
- package/dist/components/alert.cjs.map +1 -1
- package/dist/components/alert.d.cts +13 -13
- package/dist/components/alert.d.ts +13 -13
- package/dist/components/alert.js +49 -87
- package/dist/components/alert.js.map +1 -1
- package/dist/components/app-bar.cjs +73 -359
- package/dist/components/app-bar.cjs.map +1 -1
- package/dist/components/app-bar.d.cts +21 -20
- package/dist/components/app-bar.d.ts +21 -20
- package/dist/components/app-bar.js +71 -338
- package/dist/components/app-bar.js.map +1 -1
- package/dist/components/app-shell.cjs +252 -1777
- package/dist/components/app-shell.cjs.map +1 -1
- package/dist/components/app-shell.d.cts +77 -85
- package/dist/components/app-shell.d.ts +77 -85
- package/dist/components/app-shell.js +249 -1756
- package/dist/components/app-shell.js.map +1 -1
- package/dist/components/autocomplete.cjs +146 -397
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.d.cts +24 -24
- package/dist/components/autocomplete.d.ts +24 -24
- package/dist/components/autocomplete.js +146 -376
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.cjs +26 -38
- package/dist/components/avatar.cjs.map +1 -1
- package/dist/components/avatar.d.cts +11 -10
- package/dist/components/avatar.d.ts +11 -10
- package/dist/components/avatar.js +24 -37
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.cjs +42 -60
- package/dist/components/badge.cjs.map +1 -1
- package/dist/components/badge.d.cts +13 -13
- 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 +65 -94
- package/dist/components/breadcrumb.cjs.map +1 -1
- package/dist/components/breadcrumb.d.cts +14 -13
- package/dist/components/breadcrumb.d.ts +14 -13
- package/dist/components/breadcrumb.js +63 -73
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.cjs +68 -162
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +2 -20
- package/dist/components/button.d.ts +2 -20
- package/dist/components/button.js +65 -140
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-rac.cjs +49 -62
- package/dist/components/calendar-rac.cjs.map +1 -1
- package/dist/components/calendar-rac.d.cts +8 -8
- 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 +61 -74
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +15 -16
- package/dist/components/card.d.ts +15 -16
- package/dist/components/card.js +58 -72
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +12 -11
- package/dist/components/checkbox-group.cjs.map +1 -1
- package/dist/components/checkbox-group.d.cts +5 -5
- 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 +60 -114
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.d.cts +6 -6
- package/dist/components/checkbox.d.ts +6 -6
- package/dist/components/checkbox.js +58 -93
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.cjs +76 -113
- package/dist/components/collapsible.cjs.map +1 -1
- package/dist/components/collapsible.d.cts +16 -15
- package/dist/components/collapsible.d.ts +16 -15
- package/dist/components/collapsible.js +74 -92
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.cjs +213 -507
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.d.cts +36 -35
- package/dist/components/combobox.d.ts +36 -35
- package/dist/components/combobox.js +229 -504
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.cjs +102 -199
- package/dist/components/command.cjs.map +1 -1
- package/dist/components/command.d.cts +22 -21
- package/dist/components/command.d.ts +22 -21
- package/dist/components/command.js +100 -198
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.cjs +110 -402
- package/dist/components/dialog.cjs.map +1 -1
- package/dist/components/dialog.d.cts +27 -26
- package/dist/components/dialog.d.ts +27 -26
- package/dist/components/dialog.js +107 -380
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.cjs +80 -111
- package/dist/components/dock.cjs.map +1 -1
- package/dist/components/dock.d.cts +25 -25
- package/dist/components/dock.d.ts +25 -25
- package/dist/components/dock.js +78 -106
- package/dist/components/dock.js.map +1 -1
- package/dist/components/drawer.cjs +77 -111
- package/dist/components/drawer.cjs.map +1 -1
- package/dist/components/drawer.d.cts +15 -14
- package/dist/components/drawer.d.ts +15 -14
- package/dist/components/drawer.js +75 -90
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +163 -238
- package/dist/components/dropdown-menu.cjs.map +1 -1
- package/dist/components/dropdown-menu.d.cts +44 -43
- package/dist/components/dropdown-menu.d.ts +44 -43
- package/dist/components/dropdown-menu.js +161 -217
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty.cjs +51 -85
- package/dist/components/empty.cjs.map +1 -1
- package/dist/components/empty.d.cts +13 -13
- package/dist/components/empty.d.ts +13 -13
- package/dist/components/empty.js +48 -83
- package/dist/components/empty.js.map +1 -1
- package/dist/components/field.cjs +150 -259
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +39 -39
- package/dist/components/field.d.ts +39 -39
- package/dist/components/field.js +148 -238
- package/dist/components/field.js.map +1 -1
- package/dist/components/flickering-grid.cjs +143 -166
- package/dist/components/flickering-grid.cjs.map +1 -1
- package/dist/components/flickering-grid.d.cts +14 -13
- package/dist/components/flickering-grid.d.ts +14 -13
- package/dist/components/flickering-grid.js +141 -161
- package/dist/components/flickering-grid.js.map +1 -1
- package/dist/components/flow-zoom-panel.cjs +56 -188
- package/dist/components/flow-zoom-panel.cjs.map +1 -1
- package/dist/components/flow-zoom-panel.d.cts +9 -9
- package/dist/components/flow-zoom-panel.d.ts +9 -9
- package/dist/components/flow-zoom-panel.js +56 -168
- package/dist/components/flow-zoom-panel.js.map +1 -1
- package/dist/components/form-control.cjs +58 -186
- package/dist/components/form-control.cjs.map +1 -1
- package/dist/components/form-control.d.cts +11 -10
- package/dist/components/form-control.d.ts +11 -10
- package/dist/components/form-control.js +56 -165
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.cjs +78 -184
- package/dist/components/form.cjs.map +1 -1
- package/dist/components/form.d.cts +2 -36
- package/dist/components/form.d.ts +2 -36
- package/dist/components/form.js +76 -163
- package/dist/components/form.js.map +1 -1
- package/dist/components/input-group.cjs +51 -165
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +14 -15
- package/dist/components/input-group.d.ts +14 -15
- package/dist/components/input-group.js +51 -164
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +30 -55
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +2 -10
- package/dist/components/input.d.ts +2 -10
- package/dist/components/input.js +30 -54
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.cjs +133 -337
- package/dist/components/json-input.cjs.map +1 -1
- package/dist/components/json-input.d.cts +20 -19
- package/dist/components/json-input.d.ts +20 -19
- package/dist/components/json-input.js +132 -317
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/label.cjs +19 -21
- package/dist/components/label.cjs.map +1 -1
- package/dist/components/label.d.cts +6 -5
- package/dist/components/label.d.ts +6 -5
- package/dist/components/label.js +17 -20
- package/dist/components/label.js.map +1 -1
- package/dist/components/motion-grid.cjs +61 -101
- package/dist/components/motion-grid.cjs.map +1 -1
- package/dist/components/motion-grid.d.cts +15 -14
- package/dist/components/motion-grid.d.ts +15 -14
- package/dist/components/motion-grid.js +59 -80
- package/dist/components/motion-grid.js.map +1 -1
- package/dist/components/multi-select.cjs +563 -786
- package/dist/components/multi-select.cjs.map +1 -1
- package/dist/components/multi-select.d.cts +173 -173
- package/dist/components/multi-select.d.ts +173 -173
- package/dist/components/multi-select.js +561 -765
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/page-header.cjs +24 -13
- package/dist/components/page-header.cjs.map +1 -1
- package/dist/components/page-header.d.cts +11 -11
- 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 +72 -272
- package/dist/components/pagination.cjs.map +1 -1
- package/dist/components/pagination.d.cts +15 -16
- package/dist/components/pagination.d.ts +15 -16
- package/dist/components/pagination.js +69 -250
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.cjs +68 -111
- package/dist/components/popover.cjs.map +1 -1
- package/dist/components/popover.d.cts +31 -30
- package/dist/components/popover.d.ts +31 -30
- package/dist/components/popover.js +66 -90
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.cjs +128 -81
- package/dist/components/portal.cjs.map +1 -1
- package/dist/components/portal.d.cts +24 -23
- package/dist/components/portal.d.ts +24 -23
- package/dist/components/portal.js +126 -60
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.cjs +23 -24
- package/dist/components/progress.cjs.map +1 -1
- package/dist/components/progress.d.cts +8 -7
- package/dist/components/progress.d.ts +8 -7
- package/dist/components/progress.js +21 -23
- package/dist/components/progress.js.map +1 -1
- package/dist/components/progressive-blur-scroll-container.cjs +70 -138
- package/dist/components/progressive-blur-scroll-container.cjs.map +1 -1
- package/dist/components/progressive-blur-scroll-container.d.cts +19 -19
- 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 +40 -64
- package/dist/components/progressive-blur.cjs.map +1 -1
- package/dist/components/progressive-blur.d.cts +15 -14
- 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 +28 -42
- package/dist/components/radio-group.cjs.map +1 -1
- package/dist/components/radio-group.d.cts +8 -8
- package/dist/components/radio-group.d.ts +8 -8
- package/dist/components/radio-group.js +28 -41
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/record-picker.cjs +6 -418
- package/dist/components/record-picker.d.cts +13 -13
- package/dist/components/record-picker.d.ts +13 -13
- package/dist/components/record-picker.js +5 -397
- package/dist/components/resizable.cjs +32 -58
- package/dist/components/resizable.cjs.map +1 -1
- package/dist/components/resizable.d.cts +10 -9
- package/dist/components/resizable.d.ts +10 -9
- package/dist/components/resizable.js +29 -37
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/responsive-diagram.cjs +50 -61
- package/dist/components/responsive-diagram.cjs.map +1 -1
- package/dist/components/responsive-diagram.d.cts +7 -7
- 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 +37 -83
- package/dist/components/scroll-area.cjs.map +1 -1
- package/dist/components/scroll-area.d.cts +9 -8
- package/dist/components/scroll-area.d.ts +9 -8
- package/dist/components/scroll-area.js +35 -62
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/select.cjs +175 -300
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +36 -35
- package/dist/components/select.d.ts +36 -35
- package/dist/components/select.js +172 -278
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +16 -19
- package/dist/components/separator.cjs.map +1 -1
- package/dist/components/separator.d.cts +2 -10
- package/dist/components/separator.d.ts +2 -10
- package/dist/components/separator.js +14 -18
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sheet.cjs +17 -487
- package/dist/components/sheet.d.cts +85 -85
- package/dist/components/sheet.d.ts +85 -85
- package/dist/components/sheet.js +3 -453
- package/dist/components/sidebar.cjs +27 -1298
- package/dist/components/sidebar.d.cts +62 -65
- package/dist/components/sidebar.d.ts +62 -65
- package/dist/components/sidebar.js +3 -1254
- package/dist/components/skeleton.cjs +18 -30
- package/dist/components/skeleton.cjs.map +1 -1
- package/dist/components/skeleton.d.cts +6 -5
- package/dist/components/skeleton.d.ts +6 -5
- package/dist/components/skeleton.js +15 -28
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/sonner.cjs +17 -19
- package/dist/components/sonner.cjs.map +1 -1
- package/dist/components/sonner.d.cts +7 -7
- 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 +43 -1515
- package/dist/components/stack/index.d.cts +2 -672
- package/dist/components/stack/index.d.ts +2 -672
- package/dist/components/stack/index.js +3 -1455
- package/dist/components/stepper.cjs +131 -285
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.d.cts +27 -26
- package/dist/components/stepper.d.ts +27 -26
- package/dist/components/stepper.js +130 -265
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.cjs +21 -32
- package/dist/components/switch.cjs.map +1 -1
- package/dist/components/switch.d.cts +7 -6
- package/dist/components/switch.d.ts +7 -6
- package/dist/components/switch.js +19 -31
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +58 -106
- package/dist/components/table.cjs.map +1 -1
- package/dist/components/table.d.cts +17 -16
- package/dist/components/table.d.ts +17 -16
- package/dist/components/table.js +55 -104
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +31 -35
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.d.cts +9 -8
- package/dist/components/tabs.d.ts +9 -8
- package/dist/components/tabs.js +29 -34
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.cjs +114 -433
- package/dist/components/tags.cjs.map +1 -1
- package/dist/components/tags.d.cts +24 -28
- package/dist/components/tags.d.ts +24 -28
- package/dist/components/tags.js +114 -413
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.cjs +27 -49
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.d.cts +8 -7
- package/dist/components/textarea.d.ts +8 -7
- package/dist/components/textarea.js +27 -48
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/toast/index.cjs +9 -612
- package/dist/components/toast/index.d.cts +2 -52
- package/dist/components/toast/index.d.ts +2 -52
- package/dist/components/toast/index.js +3 -586
- package/dist/components/tooltip.cjs +47 -72
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +2 -28
- package/dist/components/tooltip.d.ts +2 -28
- package/dist/components/tooltip.js +45 -51
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unlink-button.cjs +19 -192
- package/dist/components/unlink-button.cjs.map +1 -1
- package/dist/components/unlink-button.d.cts +11 -11
- package/dist/components/unlink-button.d.ts +11 -11
- package/dist/components/unlink-button.js +18 -170
- 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 -8697
- package/dist/index.d.cts +224 -2136
- package/dist/index.d.ts +224 -2136
- package/dist/index.js +65 -8350
- 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-BavjjJp0.cjs +625 -0
- package/dist/sidebar-BavjjJp0.cjs.map +1 -0
- package/dist/sidebar-DeoL2ttp.js +481 -0
- package/dist/sidebar-DeoL2ttp.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 +5 -5
- package/dist/components/record-picker.cjs.map +0 -1
- package/dist/components/record-picker.js.map +0 -1
- package/dist/components/sheet.cjs.map +0 -1
- package/dist/components/sheet.js.map +0 -1
- package/dist/components/sidebar.cjs.map +0 -1
- package/dist/components/sidebar.js.map +0 -1
- package/dist/components/stack/index.cjs.map +0 -1
- package/dist/components/stack/index.js.map +0 -1
- package/dist/components/toast/index.cjs.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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
const require_rolldown_runtime = require('./rolldown-runtime-D_qnwXdH.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
react = require_rolldown_runtime.__toESM(react, 1);
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
|
|
7
|
+
//#region src/lib/slot.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Merges refs into a single callback ref.
|
|
10
|
+
* React 19 compatible - handles refs as regular props.
|
|
11
|
+
*/
|
|
12
|
+
function composeRefs(...refs) {
|
|
13
|
+
return (node) => {
|
|
14
|
+
refs.forEach((ref) => {
|
|
15
|
+
if (typeof ref === "function") ref(node);
|
|
16
|
+
else if (ref != null) ref.current = node;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Merges props, handling special cases for className, style, and event handlers.
|
|
22
|
+
* Excludes 'ref' from merging as it's handled separately.
|
|
23
|
+
*/
|
|
24
|
+
function mergeProps(slotProps, childProps) {
|
|
25
|
+
const overrideProps = { ...childProps };
|
|
26
|
+
for (const propName in childProps) {
|
|
27
|
+
if (propName === "ref") continue;
|
|
28
|
+
const slotPropValue = slotProps[propName];
|
|
29
|
+
const childPropValue = childProps[propName];
|
|
30
|
+
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") overrideProps[propName] = (...args) => {
|
|
31
|
+
childPropValue(...args);
|
|
32
|
+
slotPropValue(...args);
|
|
33
|
+
};
|
|
34
|
+
else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
35
|
+
else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") overrideProps[propName] = {
|
|
36
|
+
...slotPropValue,
|
|
37
|
+
...childPropValue
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...slotProps,
|
|
42
|
+
...overrideProps
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a value is a valid slottable child (single React element).
|
|
47
|
+
*/
|
|
48
|
+
function isSlottable(child) {
|
|
49
|
+
return react.isValidElement(child);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Slot component - renders its child element with merged props.
|
|
53
|
+
* Used for the `asChild` pattern where parent props are passed to child.
|
|
54
|
+
* React 19 compatible - accesses ref from props instead of element.ref.
|
|
55
|
+
*/
|
|
56
|
+
const Slot = react.forwardRef((props, forwardedRef) => {
|
|
57
|
+
const { children, ...slotProps } = props;
|
|
58
|
+
if (isSlottable(children)) {
|
|
59
|
+
const childProps = children.props;
|
|
60
|
+
const childRef = childProps.ref;
|
|
61
|
+
return react.cloneElement(children, {
|
|
62
|
+
...mergeProps(slotProps, childProps),
|
|
63
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (react.Children.count(children) > 1) {
|
|
67
|
+
const childrenArray = react.Children.toArray(children);
|
|
68
|
+
const slottableChild = childrenArray.find((child) => react.isValidElement(child) && child.type === Slottable);
|
|
69
|
+
if (slottableChild) {
|
|
70
|
+
const newElement = slottableChild.props.children;
|
|
71
|
+
if (isSlottable(newElement)) {
|
|
72
|
+
const newElementProps = newElement.props;
|
|
73
|
+
const newChildren = childrenArray.map((child) => {
|
|
74
|
+
if (child === slottableChild) return react.Children.count(newElementProps.children) > 1 ? react.Children.only(null) : newElementProps.children;
|
|
75
|
+
return child;
|
|
76
|
+
});
|
|
77
|
+
const childRef = newElementProps.ref;
|
|
78
|
+
return react.cloneElement(newElement, {
|
|
79
|
+
...mergeProps(slotProps, newElementProps),
|
|
80
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
81
|
+
children: newChildren
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
87
|
+
});
|
|
88
|
+
Slot.displayName = "Slot";
|
|
89
|
+
/**
|
|
90
|
+
* Slottable component - marks content that should receive slot props.
|
|
91
|
+
* Used when Slot has multiple children and you want to specify which one receives props.
|
|
92
|
+
*/
|
|
93
|
+
function Slottable({ children }) {
|
|
94
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
Object.defineProperty(exports, 'Slot', {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return Slot;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, 'Slottable', {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () {
|
|
107
|
+
return Slottable;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, 'composeRefs', {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function () {
|
|
113
|
+
return composeRefs;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, 'mergeProps', {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () {
|
|
119
|
+
return mergeProps;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=slot-C-jEfihz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-C-jEfihz.cjs","names":["React"],"sources":["../src/lib/slot.tsx"],"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"],"mappings":";;;;;;;;;;;AAQA,SAAS,YAAe,GAAG,MAA0D;CACpF,QAAQ,SAAS;EAChB,KAAK,SAAS,QAAQ;GACrB,IAAI,OAAO,QAAQ,YAClB,IAAI,IAAI;QACF,IAAI,OAAO,MACjB,AAAC,IAAyC,UAAU;EAEtD,CAAC;CACF;AACD;;;;;AAMA,SAAS,WACR,WACA,YAC0B;CAC1B,MAAM,gBAAyC,EAAE,GAAG,WAAW;CAE/D,KAAK,MAAM,YAAY,YAAY;EAElC,IAAI,aAAa,OAAO;EAExB,MAAM,gBAAgB,UAAU;EAChC,MAAM,iBAAiB,WAAW;EAGlC,IAAI,WAAW,KAAK,QAAQ,KAAK,OAAO,kBAAkB,cAAc,OAAO,mBAAmB,YACjG,cAAc,aAAa,GAAG,SAAoB;GACjD,eAAe,GAAG,IAAI;GACtB,cAAc,GAAG,IAAI;EACtB;OAGI,IAAI,aAAa,eAAe,OAAO,kBAAkB,YAAY,OAAO,mBAAmB,UACnG,cAAc,YAAY,GAAG,cAAc,GAAG,iBAAiB,KAAK;OAGhE,IAAI,aAAa,WAAW,OAAO,kBAAkB,YAAY,OAAO,mBAAmB,UAC/F,cAAc,YAAY;GAAE,GAAG;GAAe,GAAG;EAAe;CAElE;CAEA,OAAO;EAAE,GAAG;EAAW,GAAG;CAAc;AACzC;;;;AAgCA,SAAS,YAAY,OAAqD;CACzE,OAAOA,MAAM,eAAe,KAAK;AAClC;;;;;;AAWA,MAAM,OAAOA,MAAM,YAAoC,OAAO,iBAAiB;CAC9E,MAAM,EAAE,UAAU,GAAG,cAAc;CAGnC,IAAI,YAAY,QAAQ,GAAG;EAC1B,MAAM,aAAa,SAAS;EAE5B,MAAM,WAAW,WAAW;EAE5B,OAAOA,MAAM,aAAa,UAAU;GACnC,GAAG,WAAW,WAAW,UAAU;GACnC,KAAK,eAAe,YAAY,cAAc,QAAQ,IAAI;EAC3D,CAAqB;CACtB;CAGA,IAAIA,MAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;EACvC,MAAM,gBAAgBA,MAAM,SAAS,QAAQ,QAAQ;EACrD,MAAM,iBAAiB,cAAc,MACnC,UAAUA,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS,SAC1D;EAEA,IAAI,gBAAgB;GACnB,MAAM,aAAa,eAAe,MAAM;GACxC,IAAI,YAAY,UAAU,GAAG;IAC5B,MAAM,kBAAkB,WAAW;IACnC,MAAM,cAAc,cAAc,KAAK,UAAU;KAChD,IAAI,UAAU,gBACb,OAAOA,MAAM,SAAS,MAAM,gBAAgB,QAAQ,IAAI,IACrDA,MAAM,SAAS,KAAK,IAAI,IACxB,gBAAgB;KAEpB,OAAO;IACR,CAAC;IAGD,MAAM,WAAW,gBAAgB;IAEjC,OAAOA,MAAM,aAAa,YAAY;KACrC,GAAG,WAAW,WAAW,eAAe;KACxC,KAAK,eAAe,YAAY,cAAc,QAAQ,IAAI;KAC1D,UAAU;IACX,CAAqB;GACtB;EACD;CACD;CAGA,OAAO,yEAAG,SAAW;AACtB,CAAC;AAED,KAAK,cAAc;;;;;AAMnB,SAAS,UAAU,EAAE,YAA2C;CAC/D,OAAO,yEAAG,SAAW;AACtB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/slot.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Merges refs into a single callback ref.
|
|
8
|
+
* React 19 compatible - handles refs as regular props.
|
|
9
|
+
*/
|
|
10
|
+
function composeRefs(...refs) {
|
|
11
|
+
return (node) => {
|
|
12
|
+
refs.forEach((ref) => {
|
|
13
|
+
if (typeof ref === "function") ref(node);
|
|
14
|
+
else if (ref != null) ref.current = node;
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Merges props, handling special cases for className, style, and event handlers.
|
|
20
|
+
* Excludes 'ref' from merging as it's handled separately.
|
|
21
|
+
*/
|
|
22
|
+
function mergeProps(slotProps, childProps) {
|
|
23
|
+
const overrideProps = { ...childProps };
|
|
24
|
+
for (const propName in childProps) {
|
|
25
|
+
if (propName === "ref") continue;
|
|
26
|
+
const slotPropValue = slotProps[propName];
|
|
27
|
+
const childPropValue = childProps[propName];
|
|
28
|
+
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") overrideProps[propName] = (...args) => {
|
|
29
|
+
childPropValue(...args);
|
|
30
|
+
slotPropValue(...args);
|
|
31
|
+
};
|
|
32
|
+
else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
33
|
+
else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") overrideProps[propName] = {
|
|
34
|
+
...slotPropValue,
|
|
35
|
+
...childPropValue
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...slotProps,
|
|
40
|
+
...overrideProps
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a value is a valid slottable child (single React element).
|
|
45
|
+
*/
|
|
46
|
+
function isSlottable(child) {
|
|
47
|
+
return React$1.isValidElement(child);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Slot component - renders its child element with merged props.
|
|
51
|
+
* Used for the `asChild` pattern where parent props are passed to child.
|
|
52
|
+
* React 19 compatible - accesses ref from props instead of element.ref.
|
|
53
|
+
*/
|
|
54
|
+
const Slot = React$1.forwardRef((props, forwardedRef) => {
|
|
55
|
+
const { children, ...slotProps } = props;
|
|
56
|
+
if (isSlottable(children)) {
|
|
57
|
+
const childProps = children.props;
|
|
58
|
+
const childRef = childProps.ref;
|
|
59
|
+
return React$1.cloneElement(children, {
|
|
60
|
+
...mergeProps(slotProps, childProps),
|
|
61
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (React$1.Children.count(children) > 1) {
|
|
65
|
+
const childrenArray = React$1.Children.toArray(children);
|
|
66
|
+
const slottableChild = childrenArray.find((child) => React$1.isValidElement(child) && child.type === Slottable);
|
|
67
|
+
if (slottableChild) {
|
|
68
|
+
const newElement = slottableChild.props.children;
|
|
69
|
+
if (isSlottable(newElement)) {
|
|
70
|
+
const newElementProps = newElement.props;
|
|
71
|
+
const newChildren = childrenArray.map((child) => {
|
|
72
|
+
if (child === slottableChild) return React$1.Children.count(newElementProps.children) > 1 ? React$1.Children.only(null) : newElementProps.children;
|
|
73
|
+
return child;
|
|
74
|
+
});
|
|
75
|
+
const childRef = newElementProps.ref;
|
|
76
|
+
return React$1.cloneElement(newElement, {
|
|
77
|
+
...mergeProps(slotProps, newElementProps),
|
|
78
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
79
|
+
children: newChildren
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
85
|
+
});
|
|
86
|
+
Slot.displayName = "Slot";
|
|
87
|
+
/**
|
|
88
|
+
* Slottable component - marks content that should receive slot props.
|
|
89
|
+
* Used when Slot has multiple children and you want to specify which one receives props.
|
|
90
|
+
*/
|
|
91
|
+
function Slottable({ children }) {
|
|
92
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { mergeProps as i, Slottable as n, composeRefs as r, Slot as t };
|
|
97
|
+
//# sourceMappingURL=slot-EL8zfLG0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-EL8zfLG0.js","names":["React"],"sources":["../src/lib/slot.tsx"],"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"],"mappings":";;;;;;;;;AAQA,SAAS,YAAe,GAAG,MAA0D;CACpF,QAAQ,SAAS;EAChB,KAAK,SAAS,QAAQ;GACrB,IAAI,OAAO,QAAQ,YAClB,IAAI,IAAI;QACF,IAAI,OAAO,MACjB,AAAC,IAAyC,UAAU;EAEtD,CAAC;CACF;AACD;;;;;AAMA,SAAS,WACR,WACA,YAC0B;CAC1B,MAAM,gBAAyC,EAAE,GAAG,WAAW;CAE/D,KAAK,MAAM,YAAY,YAAY;EAElC,IAAI,aAAa,OAAO;EAExB,MAAM,gBAAgB,UAAU;EAChC,MAAM,iBAAiB,WAAW;EAGlC,IAAI,WAAW,KAAK,QAAQ,KAAK,OAAO,kBAAkB,cAAc,OAAO,mBAAmB,YACjG,cAAc,aAAa,GAAG,SAAoB;GACjD,eAAe,GAAG,IAAI;GACtB,cAAc,GAAG,IAAI;EACtB;OAGI,IAAI,aAAa,eAAe,OAAO,kBAAkB,YAAY,OAAO,mBAAmB,UACnG,cAAc,YAAY,GAAG,cAAc,GAAG,iBAAiB,KAAK;OAGhE,IAAI,aAAa,WAAW,OAAO,kBAAkB,YAAY,OAAO,mBAAmB,UAC/F,cAAc,YAAY;GAAE,GAAG;GAAe,GAAG;EAAe;CAElE;CAEA,OAAO;EAAE,GAAG;EAAW,GAAG;CAAc;AACzC;;;;AAgCA,SAAS,YAAY,OAAqD;CACzE,OAAOA,QAAM,eAAe,KAAK;AAClC;;;;;;AAWA,MAAM,OAAOA,QAAM,YAAoC,OAAO,iBAAiB;CAC9E,MAAM,EAAE,UAAU,GAAG,cAAc;CAGnC,IAAI,YAAY,QAAQ,GAAG;EAC1B,MAAM,aAAa,SAAS;EAE5B,MAAM,WAAW,WAAW;EAE5B,OAAOA,QAAM,aAAa,UAAU;GACnC,GAAG,WAAW,WAAW,UAAU;GACnC,KAAK,eAAe,YAAY,cAAc,QAAQ,IAAI;EAC3D,CAAqB;CACtB;CAGA,IAAIA,QAAM,SAAS,MAAM,QAAQ,IAAI,GAAG;EACvC,MAAM,gBAAgBA,QAAM,SAAS,QAAQ,QAAQ;EACrD,MAAM,iBAAiB,cAAc,MACnC,UAAUA,QAAM,eAAe,KAAK,KAAK,MAAM,SAAS,SAC1D;EAEA,IAAI,gBAAgB;GACnB,MAAM,aAAa,eAAe,MAAM;GACxC,IAAI,YAAY,UAAU,GAAG;IAC5B,MAAM,kBAAkB,WAAW;IACnC,MAAM,cAAc,cAAc,KAAK,UAAU;KAChD,IAAI,UAAU,gBACb,OAAOA,QAAM,SAAS,MAAM,gBAAgB,QAAQ,IAAI,IACrDA,QAAM,SAAS,KAAK,IAAI,IACxB,gBAAgB;KAEpB,OAAO;IACR,CAAC;IAGD,MAAM,WAAW,gBAAgB;IAEjC,OAAOA,QAAM,aAAa,YAAY;KACrC,GAAG,WAAW,WAAW,eAAe;KACxC,KAAK,eAAe,YAAY,cAAc,QAAQ,IAAI;KAC1D,UAAU;IACX,CAAqB;GACtB;EACD;CACD;CAGA,OAAO,gCAAG,SAAW;AACtB,CAAC;AAED,KAAK,cAAc;;;;;AAMnB,SAAS,UAAU,EAAE,YAA2C;CAC/D,OAAO,gCAAG,SAAW;AACtB"}
|