@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
|
@@ -1,188 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React2 from 'react';
|
|
3
|
-
import { Popover as Popover$1 } from '@base-ui/react/popover';
|
|
4
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
|
-
import { twMerge } from 'tailwind-merge';
|
|
1
|
+
'use client';
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, []);
|
|
21
|
-
return container;
|
|
22
|
-
}
|
|
23
|
-
function useFloatingOverlayPortalProps() {
|
|
24
|
-
const rootContainer = useRootPortalContainer();
|
|
25
|
-
const { floatingPortalStrategy, floatingZIndex } = React2.useContext(PortalContext);
|
|
26
|
-
const container = floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? null;
|
|
27
|
-
const zIndexClass = floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]";
|
|
28
|
-
return { container, zIndexClass };
|
|
29
|
-
}
|
|
30
|
-
function composeRefs(...refs) {
|
|
31
|
-
return (node) => {
|
|
32
|
-
refs.forEach((ref) => {
|
|
33
|
-
if (typeof ref === "function") {
|
|
34
|
-
ref(node);
|
|
35
|
-
} else if (ref != null) {
|
|
36
|
-
ref.current = node;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function mergeProps(slotProps, childProps) {
|
|
42
|
-
const overrideProps = { ...childProps };
|
|
43
|
-
for (const propName in childProps) {
|
|
44
|
-
if (propName === "ref") continue;
|
|
45
|
-
const slotPropValue = slotProps[propName];
|
|
46
|
-
const childPropValue = childProps[propName];
|
|
47
|
-
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
|
|
48
|
-
overrideProps[propName] = (...args) => {
|
|
49
|
-
childPropValue(...args);
|
|
50
|
-
slotPropValue(...args);
|
|
51
|
-
};
|
|
52
|
-
} else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
|
|
53
|
-
overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
54
|
-
} else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
|
|
55
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return { ...slotProps, ...overrideProps };
|
|
59
|
-
}
|
|
60
|
-
function mergePropsWithRef(parentProps, childElement) {
|
|
61
|
-
const childProps = childElement.props;
|
|
62
|
-
const parentRef = parentProps.ref;
|
|
63
|
-
const childRef = childProps.ref;
|
|
64
|
-
const mergedProps = mergeProps(parentProps, childProps);
|
|
65
|
-
if (parentRef || childRef) {
|
|
66
|
-
mergedProps.ref = composeRefs(parentRef, childRef);
|
|
67
|
-
}
|
|
68
|
-
return mergedProps;
|
|
69
|
-
}
|
|
70
|
-
function isSlottable(child) {
|
|
71
|
-
return React2.isValidElement(child);
|
|
3
|
+
import { t as cn } from "../utils-BkMLyah9.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useFloatingOverlayPortalProps } from "@constructive-io/ui/portal";
|
|
7
|
+
import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
8
|
+
|
|
9
|
+
//#region src/components/popover.tsx
|
|
10
|
+
function Popover({ ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Popover$1.Root, {
|
|
12
|
+
"data-slot": "popover",
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
72
15
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
if (React2.Children.count(children) > 1) {
|
|
84
|
-
const childrenArray = React2.Children.toArray(children);
|
|
85
|
-
const slottableChild = childrenArray.find(
|
|
86
|
-
(child) => React2.isValidElement(child) && child.type === Slottable
|
|
87
|
-
);
|
|
88
|
-
if (slottableChild) {
|
|
89
|
-
const newElement = slottableChild.props.children;
|
|
90
|
-
if (isSlottable(newElement)) {
|
|
91
|
-
const newElementProps = newElement.props;
|
|
92
|
-
const newChildren = childrenArray.map((child) => {
|
|
93
|
-
if (child === slottableChild) {
|
|
94
|
-
return React2.Children.count(newElementProps.children) > 1 ? React2.Children.only(null) : newElementProps.children;
|
|
95
|
-
}
|
|
96
|
-
return child;
|
|
97
|
-
});
|
|
98
|
-
const childRef = newElementProps.ref;
|
|
99
|
-
return React2.cloneElement(newElement, {
|
|
100
|
-
...mergeProps(slotProps, newElementProps),
|
|
101
|
-
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
102
|
-
children: newChildren
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
108
|
-
});
|
|
109
|
-
Slot.displayName = "Slot";
|
|
110
|
-
function Slottable({ children }) {
|
|
111
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
16
|
+
function PopoverTrigger({ asChild, children, render, nativeButton, ...props }) {
|
|
17
|
+
const childRender = render === void 0 && asChild && React$1.isValidElement(children) ? children : void 0;
|
|
18
|
+
return /* @__PURE__ */ jsx(Popover$1.Trigger, {
|
|
19
|
+
"data-slot": "popover-trigger",
|
|
20
|
+
nativeButton: nativeButton ?? (childRender ? true : void 0),
|
|
21
|
+
render: render ?? childRender,
|
|
22
|
+
...props,
|
|
23
|
+
children: childRender ? void 0 : children
|
|
24
|
+
});
|
|
112
25
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
26
|
+
function PopoverClose({ asChild, children, render, nativeButton, ...props }) {
|
|
27
|
+
const childRender = render === void 0 && asChild && React$1.isValidElement(children) ? children : void 0;
|
|
28
|
+
return /* @__PURE__ */ jsx(Popover$1.Close, {
|
|
29
|
+
"data-slot": "popover-close",
|
|
30
|
+
nativeButton: nativeButton ?? (childRender ? true : void 0),
|
|
31
|
+
render: render ?? childRender,
|
|
32
|
+
...props,
|
|
33
|
+
children: childRender ? void 0 : children
|
|
34
|
+
});
|
|
115
35
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
36
|
+
function PopoverContent({ className, align = "center", sideOffset = 4, showArrow = false, side = "bottom", children, onOpenAutoFocus: _onOpenAutoFocus, onCloseAutoFocus: _onCloseAutoFocus, onFocusOutside: _onFocusOutside, onEscapeKeyDown: _onEscapeKeyDown, ...props }) {
|
|
37
|
+
const { container, zIndexClass } = useFloatingOverlayPortalProps();
|
|
38
|
+
return /* @__PURE__ */ jsx(Popover$1.Portal, {
|
|
39
|
+
container,
|
|
40
|
+
children: /* @__PURE__ */ jsx(Popover$1.Positioner, {
|
|
41
|
+
side,
|
|
42
|
+
align,
|
|
43
|
+
sideOffset,
|
|
44
|
+
className: zIndexClass,
|
|
45
|
+
children: /* @__PURE__ */ jsxs(Popover$1.Popup, {
|
|
46
|
+
"data-slot": "popover-content",
|
|
47
|
+
className: cn(`bg-popover text-popover-foreground origin-(--transform-origin) w-72 rounded-md border p-4 shadow-md outline-hidden
|
|
48
|
+
transition-[scale,opacity,translate] duration-150 ease-out data-starting-style:scale-95
|
|
49
|
+
data-ending-style:scale-95 data-starting-style:opacity-0 data-ending-style:opacity-0
|
|
50
|
+
data-[side=bottom]:data-starting-style:-translate-y-2
|
|
51
|
+
data-[side=left]:data-starting-style:translate-x-2
|
|
52
|
+
data-[side=right]:data-starting-style:-translate-x-2
|
|
53
|
+
data-[side=top]:data-starting-style:translate-y-2 motion-reduce:transition-none`, className),
|
|
54
|
+
...props,
|
|
55
|
+
children: [children, showArrow && /* @__PURE__ */ jsx(Popover$1.Arrow, { className: "fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]" })]
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
});
|
|
118
59
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return React2.cloneElement(
|
|
130
|
-
children,
|
|
131
|
-
mergePropsWithRef(rest, children)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
return /* @__PURE__ */ jsx(Popover$1.Trigger, { "data-slot": "popover-trigger", nativeButton, ...props, children });
|
|
60
|
+
/**
|
|
61
|
+
* PopoverAnchor - placeholder for positioning anchor.
|
|
62
|
+
* @deprecated Base UI Popover positions relative to Trigger by default.
|
|
63
|
+
* For custom anchoring, use Popover.Positioner with anchor prop.
|
|
64
|
+
*/
|
|
65
|
+
function PopoverAnchor({ ...props }) {
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
"data-slot": "popover-anchor",
|
|
68
|
+
...props
|
|
69
|
+
});
|
|
138
70
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
children,
|
|
146
|
-
onOpenAutoFocus: _onOpenAutoFocus,
|
|
147
|
-
onCloseAutoFocus: _onCloseAutoFocus,
|
|
148
|
-
onFocusOutside: _onFocusOutside,
|
|
149
|
-
onEscapeKeyDown: _onEscapeKeyDown,
|
|
150
|
-
...props
|
|
151
|
-
}) {
|
|
152
|
-
const { container, zIndexClass } = useFloatingOverlayPortalProps();
|
|
153
|
-
return /* @__PURE__ */ jsx(Popover$1.Portal, { container, children: /* @__PURE__ */ jsx(
|
|
154
|
-
Popover$1.Positioner,
|
|
155
|
-
{
|
|
156
|
-
side,
|
|
157
|
-
align,
|
|
158
|
-
sideOffset,
|
|
159
|
-
className: zIndexClass,
|
|
160
|
-
children: /* @__PURE__ */ jsxs(
|
|
161
|
-
Popover$1.Popup,
|
|
162
|
-
{
|
|
163
|
-
"data-slot": "popover-content",
|
|
164
|
-
className: cn(
|
|
165
|
-
`bg-popover text-popover-foreground data-[open]:animate-in data-[closed]:animate-out
|
|
166
|
-
data-[closed]:fade-out-0 data-[open]:fade-in-0 data-[closed]:zoom-out-95
|
|
167
|
-
data-[open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
|
|
168
|
-
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 w-72 rounded-md border p-4
|
|
169
|
-
shadow-md outline-hidden`,
|
|
170
|
-
className
|
|
171
|
-
),
|
|
172
|
-
...props,
|
|
173
|
-
children: [
|
|
174
|
-
children,
|
|
175
|
-
showArrow && /* @__PURE__ */ jsx(Popover$1.Arrow, { className: "fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]" })
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
) });
|
|
71
|
+
function PopoverTitle({ className, ...props }) {
|
|
72
|
+
return /* @__PURE__ */ jsx(Popover$1.Title, {
|
|
73
|
+
"data-slot": "popover-title",
|
|
74
|
+
className: cn("font-medium leading-none", className),
|
|
75
|
+
...props
|
|
76
|
+
});
|
|
181
77
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
78
|
+
function PopoverDescription({ className, ...props }) {
|
|
79
|
+
return /* @__PURE__ */ jsx(Popover$1.Description, {
|
|
80
|
+
"data-slot": "popover-description",
|
|
81
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
184
84
|
}
|
|
185
85
|
|
|
186
|
-
|
|
187
|
-
|
|
86
|
+
//#endregion
|
|
87
|
+
export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger };
|
|
188
88
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/portal.tsx","../../src/lib/slot.tsx","../../src/lib/utils.ts","../../src/components/popover.tsx"],"names":["React","jsx","PopoverPrimitive","React3"],"mappings":"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","file":"popover.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Overlay layer type:\n * - 'base': Root level (page content, base floating elements)\n * - 'modal': Inside a modal overlay (dialog, sheet, drawer)\n */\nexport type OverlayLayer = 'base' | 'modal';\n\n/**\n * Where floating overlays should portal:\n * - 'root': always portal into #portal-root\n * - 'nested': let Base UI nest portals into the nearest Base UI portal node\n */\nexport type FloatingPortalStrategy = 'root' | 'nested';\n\n/**\n * Z-index mode for floating overlays.\n * - 'default': --z-layer-floating\n * - 'elevated': --z-layer-floating-elevated\n */\nexport type FloatingZIndex = 'default' | 'elevated';\n\ninterface PortalContextValue {\n\t/** Current overlay layer */\n\tlayer: OverlayLayer;\n\t/** Modal nesting depth (0 for first modal, 1 for nested, etc.) */\n\tdepth: number;\n\t/** Strategy for where floating overlays should portal */\n\tfloatingPortalStrategy: FloatingPortalStrategy;\n\t/** Z-index mode for floating overlays */\n\tfloatingZIndex: FloatingZIndex;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nexport const PORTAL_ROOT_ID = 'portal-root';\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst PortalContext = React.createContext<PortalContextValue>({\n\tlayer: 'base',\n\tdepth: 0,\n\tfloatingPortalStrategy: 'root',\n\tfloatingZIndex: 'default',\n});\n\n// ============================================================================\n// Providers\n// ============================================================================\n\n/**\n * Provider for modal overlays (Dialog, Sheet, Drawer, etc.)\n *\n * Wraps modal content to:\n * 1. Create a scoped portal container for nested floating elements\n * 2. Track the overlay layer (so floating elements know to use elevated z-index)\n * 3. Track nesting depth for stacked modals\n *\n * Usage:\n * ```tsx\n * <DialogPopup>\n * <ModalPortalScope>\n * {children} // Popovers inside here will render in the scoped container\n * </ModalPortalScope>\n * </DialogPopup>\n * ```\n */\nexport function ModalPortalScope({\n\tchildren,\n\tfloatingPortalStrategy = 'nested',\n\tfloatingZIndex = 'default',\n}: {\n\tchildren: React.ReactNode;\n\tfloatingPortalStrategy?: FloatingPortalStrategy;\n\tfloatingZIndex?: FloatingZIndex;\n}) {\n\tconst parentContext = React.useContext(PortalContext);\n\n\t// Increment depth from parent if already in modal layer\n\tconst depth = parentContext.layer === 'modal' ? parentContext.depth + 1 : 0;\n\n\tconst value = React.useMemo<PortalContextValue>(\n\t\t() => ({\n\t\t\tlayer: 'modal',\n\t\t\tdepth,\n\t\t\tfloatingPortalStrategy,\n\t\t\tfloatingZIndex,\n\t\t}),\n\t\t[depth, floatingPortalStrategy, floatingZIndex],\n\t);\n\n\treturn <PortalContext.Provider value={value}>{children}</PortalContext.Provider>;\n}\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\n/**\n * Get the current portal context value.\n * Used internally by other hooks.\n */\nexport function usePortalContext(): PortalContextValue {\n\treturn React.useContext(PortalContext);\n}\n\nexport function useInModalOverlay(): boolean {\n\treturn React.useContext(PortalContext).layer === 'modal';\n}\n\n/**\n * Get the root portal container element.\n * Used by modal components (Dialog, Sheet, etc.) to render their portals.\n *\n * @returns The root portal container, or null during SSR/before mount\n */\nexport function useRootPortalContainer(): HTMLElement | null {\n\tconst [container, setContainer] = React.useState<HTMLElement | null>(null);\n\n\tReact.useLayoutEffect(() => {\n\t\tconst el = document.getElementById(PORTAL_ROOT_ID);\n\t\tsetContainer(el);\n\t}, []);\n\n\treturn container;\n}\n\n/**\n * Centralized portal + z-index policy for floating overlays.\n *\n * - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal\n * into the nearest Base UI portal node (so dialog \"inert\" behavior includes it).\n * - When it's 'root', we portal into #portal-root.\n */\nexport function useFloatingOverlayPortalProps(): {\n\tcontainer?: HTMLElement | null;\n\tzIndexClass: string;\n} {\n\tconst rootContainer = useRootPortalContainer();\n\tconst { floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);\n\n\tconst container = floatingPortalStrategy === 'nested' ? undefined : (rootContainer ?? null);\n\tconst zIndexClass =\n\t\tfloatingZIndex === 'elevated'\n\t\t\t? 'z-[var(--z-layer-floating-elevated)]'\n\t\t\t: 'z-[var(--z-layer-floating)]';\n\n\treturn { container, zIndexClass };\n}\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Portal root component to render in app layout.\n * All overlay components will render their portals inside this container.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { PortalRoot } from '@constructive-io/ui/portal';\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * {children}\n * <PortalRoot />\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function PortalRoot() {\n\treturn (\n\t\t<div\n\t\t\tid={PORTAL_ROOT_ID}\n\t\t\tdata-slot=\"portal-root\"\n\t\t\tstyle={{\n\t\t\t\tposition: 'fixed',\n\t\t\t\tinset: 0,\n\t\t\t\tzIndex: 'var(--z-layer-portal-root)',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\t// Children (portal contents) will have pointer-events: auto\n\t\t\t}}\n\t\t/>\n\t);\n}\n\n/**\n * Hook to get the portal container element for rendering floating UI elements.\n * Returns the element with id=\"portal-root\" if it exists in the DOM.\n *\n * @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead\n */\nexport function usePortalContainer(): HTMLElement | undefined {\n\tif (typeof document === 'undefined') return undefined;\n\tconst el = document.getElementById(PORTAL_ROOT_ID);\n\treturn el instanceof HTMLElement ? el : undefined;\n}\n","'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';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nimport { useFloatingOverlayPortalProps } from './portal';\nimport { mergePropsWithRef } from '../lib/slot';\nimport { cn } from '../lib/utils';\n\nfunction Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n\treturn <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\ntype PopoverTriggerProps = Omit<React.ComponentProps<typeof PopoverPrimitive.Trigger>, 'render' | 'nativeButton'> & {\n\t/** When true, merges props onto the child element instead of rendering a button */\n\tasChild?: boolean;\n\t/** Whether the child renders a native button. Defaults to true when asChild is used. */\n\tnativeButton?: boolean;\n};\n\nfunction PopoverTrigger({ asChild, nativeButton, children, ...props }: PopoverTriggerProps) {\n\tif (asChild && React.isValidElement(children)) {\n\t\treturn (\n\t\t\t<PopoverPrimitive.Trigger\n\t\t\t\tdata-slot=\"popover-trigger\"\n\t\t\t\tnativeButton={nativeButton ?? true}\n\t\t\t\t{...props}\n\t\t\trender={(triggerProps) => {\n\t\t\t\tconst { nativeButton: _, ...rest } = triggerProps as Record<string, unknown>;\n\t\t\t\treturn React.cloneElement(\n\t\t\t\t\tchildren as React.ReactElement<Record<string, unknown>>,\n\t\t\t\t\tmergePropsWithRef(rest, children as React.ReactElement),\n\t\t\t\t);\n\t\t\t}}\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<PopoverPrimitive.Trigger data-slot=\"popover-trigger\" nativeButton={nativeButton} {...props}>\n\t\t\t{children}\n\t\t</PopoverPrimitive.Trigger>\n\t);\n}\n\ntype PopoverContentProps = React.ComponentProps<typeof PopoverPrimitive.Popup> & {\n\talign?: 'start' | 'center' | 'end';\n\tsideOffset?: number;\n\tshowArrow?: boolean;\n\tside?: 'top' | 'bottom' | 'left' | 'right';\n\t/** @deprecated Base UI uses different focus management */\n\tonOpenAutoFocus?: (e: Event) => void;\n\t/** @deprecated Base UI uses different focus management */\n\tonCloseAutoFocus?: (e: Event) => void;\n\t/** @deprecated Use onOpenChange on Root instead */\n\tonFocusOutside?: (e: Event) => void;\n\t/** @deprecated Use onOpenChange on Root instead */\n\tonEscapeKeyDown?: () => void;\n};\n\nfunction PopoverContent({\n\tclassName,\n\talign = 'center',\n\tsideOffset = 4,\n\tshowArrow = false,\n\tside = 'bottom',\n\tchildren,\n\tonOpenAutoFocus: _onOpenAutoFocus,\n\tonCloseAutoFocus: _onCloseAutoFocus,\n\tonFocusOutside: _onFocusOutside,\n\tonEscapeKeyDown: _onEscapeKeyDown,\n\t...props\n}: PopoverContentProps) {\n\tconst { container, zIndexClass } = useFloatingOverlayPortalProps();\n\n\treturn (\n\t\t<PopoverPrimitive.Portal container={container}>\n\t\t\t<PopoverPrimitive.Positioner\n\t\t\t\tside={side}\n\t\t\t\talign={align}\n\t\t\t\tsideOffset={sideOffset}\n\t\t\t\tclassName={zIndexClass}\n\t\t\t>\n\t\t\t\t<PopoverPrimitive.Popup\n\t\t\t\t\tdata-slot=\"popover-content\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t`bg-popover text-popover-foreground data-[open]:animate-in data-[closed]:animate-out\n\t\t\t\t\t\tdata-[closed]:fade-out-0 data-[open]:fade-in-0 data-[closed]:zoom-out-95\n\t\t\t\t\t\tdata-[open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2\n\t\t\t\t\t\tdata-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 w-72 rounded-md border p-4\n\t\t\t\t\t\tshadow-md outline-hidden`,\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t\t{showArrow && (\n\t\t\t\t\t\t<PopoverPrimitive.Arrow className='fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]' />\n\t\t\t\t\t)}\n\t\t\t\t</PopoverPrimitive.Popup>\n\t\t\t</PopoverPrimitive.Positioner>\n\t\t</PopoverPrimitive.Portal>\n\t);\n}\n\n/**\n * PopoverAnchor - placeholder for positioning anchor.\n * @deprecated Base UI Popover positions relative to Trigger by default.\n * For custom anchoring, use Popover.Positioner with anchor prop.\n */\nfunction PopoverAnchor({ ...props }: React.HTMLAttributes<HTMLDivElement>) {\n\treturn <div data-slot=\"popover-anchor\" {...props} />;\n}\n\nexport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };\n"]}
|
|
1
|
+
{"version":3,"file":"popover.js","names":["PopoverPrimitive","React"],"sources":["../../src/components/popover.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover';\n\nimport { useFloatingOverlayPortalProps } from '@constructive-io/ui/portal';\nimport { cn } from '../lib/utils';\n\nfunction Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n\treturn <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\ntype PopoverTriggerProps = React.ComponentProps<typeof PopoverPrimitive.Trigger> & {\n\t/** When true, merges props onto the child element instead of rendering a button */\n\tasChild?: boolean;\n};\n\nfunction PopoverTrigger({ asChild, children, render, nativeButton, ...props }: PopoverTriggerProps) {\n\tconst childRender = render === undefined && asChild && React.isValidElement(children) ? children : undefined;\n\n\treturn (\n\t\t<PopoverPrimitive.Trigger\n\t\t\tdata-slot=\"popover-trigger\"\n\t\t\tnativeButton={nativeButton ?? (childRender ? true : undefined)}\n\t\t\trender={render ?? childRender}\n\t\t\t{...props}\n\t\t>\n\t\t\t{childRender ? undefined : children}\n\t\t</PopoverPrimitive.Trigger>\n\t);\n}\n\ntype PopoverCloseProps = React.ComponentProps<typeof PopoverPrimitive.Close> & {\n\t/** When true, merges props onto the child element instead of rendering a button */\n\tasChild?: boolean;\n};\n\nfunction PopoverClose({ asChild, children, render, nativeButton, ...props }: PopoverCloseProps) {\n\tconst childRender = render === undefined && asChild && React.isValidElement(children) ? children : undefined;\n\n\treturn (\n\t\t<PopoverPrimitive.Close\n\t\t\tdata-slot=\"popover-close\"\n\t\t\tnativeButton={nativeButton ?? (childRender ? true : undefined)}\n\t\t\trender={render ?? childRender}\n\t\t\t{...props}\n\t\t>\n\t\t\t{childRender ? undefined : children}\n\t\t</PopoverPrimitive.Close>\n\t);\n}\n\ntype PopoverContentProps = React.ComponentProps<typeof PopoverPrimitive.Popup> & {\n\talign?: 'start' | 'center' | 'end';\n\tsideOffset?: number;\n\tshowArrow?: boolean;\n\tside?: 'top' | 'bottom' | 'left' | 'right';\n\t/** @deprecated Base UI uses different focus management */\n\tonOpenAutoFocus?: (e: Event) => void;\n\t/** @deprecated Base UI uses different focus management */\n\tonCloseAutoFocus?: (e: Event) => void;\n\t/** @deprecated Use onOpenChange on Root instead */\n\tonFocusOutside?: (e: Event) => void;\n\t/** @deprecated Use onOpenChange on Root instead */\n\tonEscapeKeyDown?: () => void;\n};\n\nfunction PopoverContent({\n\tclassName,\n\talign = 'center',\n\tsideOffset = 4,\n\tshowArrow = false,\n\tside = 'bottom',\n\tchildren,\n\tonOpenAutoFocus: _onOpenAutoFocus,\n\tonCloseAutoFocus: _onCloseAutoFocus,\n\tonFocusOutside: _onFocusOutside,\n\tonEscapeKeyDown: _onEscapeKeyDown,\n\t...props\n}: PopoverContentProps) {\n\tconst { container, zIndexClass } = useFloatingOverlayPortalProps();\n\n\treturn (\n\t\t<PopoverPrimitive.Portal container={container}>\n\t\t\t<PopoverPrimitive.Positioner\n\t\t\t\tside={side}\n\t\t\t\talign={align}\n\t\t\t\tsideOffset={sideOffset}\n\t\t\t\tclassName={zIndexClass}\n\t\t\t>\n\t\t\t\t<PopoverPrimitive.Popup\n\t\t\t\t\tdata-slot=\"popover-content\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t`bg-popover text-popover-foreground origin-(--transform-origin) w-72 rounded-md border p-4 shadow-md outline-hidden\n\t\t\t\t\t\ttransition-[scale,opacity,translate] duration-150 ease-out data-starting-style:scale-95\n\t\t\t\t\t\tdata-ending-style:scale-95 data-starting-style:opacity-0 data-ending-style:opacity-0\n\t\t\t\t\t\tdata-[side=bottom]:data-starting-style:-translate-y-2\n\t\t\t\t\t\tdata-[side=left]:data-starting-style:translate-x-2\n\t\t\t\t\t\tdata-[side=right]:data-starting-style:-translate-x-2\n\t\t\t\t\t\tdata-[side=top]:data-starting-style:translate-y-2 motion-reduce:transition-none`,\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t\t{showArrow && (\n\t\t\t\t\t\t<PopoverPrimitive.Arrow className='fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]' />\n\t\t\t\t\t)}\n\t\t\t\t</PopoverPrimitive.Popup>\n\t\t\t</PopoverPrimitive.Positioner>\n\t\t</PopoverPrimitive.Portal>\n\t);\n}\n\n/**\n * PopoverAnchor - placeholder for positioning anchor.\n * @deprecated Base UI Popover positions relative to Trigger by default.\n * For custom anchoring, use Popover.Positioner with anchor prop.\n */\nfunction PopoverAnchor({ ...props }: React.HTMLAttributes<HTMLDivElement>) {\n\treturn <div data-slot=\"popover-anchor\" {...props} />;\n}\n\nfunction PopoverTitle({ className, ...props }: React.ComponentProps<typeof PopoverPrimitive.Title>) {\n\treturn (\n\t\t<PopoverPrimitive.Title\n\t\t\tdata-slot=\"popover-title\"\n\t\t\tclassName={cn('font-medium leading-none', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nfunction PopoverDescription({ className, ...props }: React.ComponentProps<typeof PopoverPrimitive.Description>) {\n\treturn (\n\t\t<PopoverPrimitive.Description\n\t\t\tdata-slot=\"popover-description\"\n\t\t\tclassName={cn('text-muted-foreground text-sm', className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport {\n\tPopover,\n\tPopoverAnchor,\n\tPopoverClose,\n\tPopoverContent,\n\tPopoverDescription,\n\tPopoverTitle,\n\tPopoverTrigger,\n};\n"],"mappings":";;;;;;;;;AAQA,SAAS,QAAQ,EAAE,GAAG,SAA6D;CAClF,OAAO,oBAACA,UAAiB,MAAlB;EAAuB,aAAU;EAAU,GAAI;CAAQ;AAC/D;AAOA,SAAS,eAAe,EAAE,SAAS,UAAU,QAAQ,cAAc,GAAG,SAA8B;CACnG,MAAM,cAAc,WAAW,UAAa,WAAWC,QAAM,eAAe,QAAQ,IAAI,WAAW;CAEnG,OACC,oBAACD,UAAiB,SAAlB;EACC,aAAU;EACV,cAAc,iBAAiB,cAAc,OAAO;EACpD,QAAQ,UAAU;EAClB,GAAI;YAEH,cAAc,SAAY;CACF;AAE5B;AAOA,SAAS,aAAa,EAAE,SAAS,UAAU,QAAQ,cAAc,GAAG,SAA4B;CAC/F,MAAM,cAAc,WAAW,UAAa,WAAWC,QAAM,eAAe,QAAQ,IAAI,WAAW;CAEnG,OACC,oBAACD,UAAiB,OAAlB;EACC,aAAU;EACV,cAAc,iBAAiB,cAAc,OAAO;EACpD,QAAQ,UAAU;EAClB,GAAI;YAEH,cAAc,SAAY;CACJ;AAE1B;AAiBA,SAAS,eAAe,EACvB,WACA,QAAQ,UACR,aAAa,GACb,YAAY,OACZ,OAAO,UACP,UACA,iBAAiB,kBACjB,kBAAkB,mBAClB,gBAAgB,iBAChB,iBAAiB,kBACjB,GAAG,SACoB;CACvB,MAAM,EAAE,WAAW,gBAAgB,8BAA8B;CAEjE,OACC,oBAACA,UAAiB,QAAlB;EAAoC;YACnC,oBAACA,UAAiB,YAAlB;GACO;GACC;GACK;GACZ,WAAW;aAEX,qBAACA,UAAiB,OAAlB;IACC,aAAU;IACV,WAAW,GACV;;;;;;wFAOA,SACD;IACA,GAAI;cAZL,CAcE,UACA,aACA,oBAACA,UAAiB,OAAlB,EAAwB,WAAU,0DAA2D,EAEvE;;EACI;CACL;AAE3B;;;;;;AAOA,SAAS,cAAc,EAAE,GAAG,SAA+C;CAC1E,OAAO,oBAAC,OAAD;EAAK,aAAU;EAAiB,GAAI;CAAQ;AACpD;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,SAA8D;CACnG,OACC,oBAACA,UAAiB,OAAlB;EACC,aAAU;EACV,WAAW,GAAG,4BAA4B,SAAS;EACnD,GAAI;CACJ;AAEH;AAEA,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAoE;CAC/G,OACC,oBAACA,UAAiB,aAAlB;EACC,aAAU;EACV,WAAW,GAAG,iCAAiC,SAAS;EACxD,GAAI;CACJ;AAEH"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_rolldown_runtime = require('../rolldown-runtime-D_qnwXdH.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react, 1);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
|
|
9
|
+
//#region src/components/portal.tsx
|
|
10
|
+
const PORTAL_ROOT_ID = "portal-root";
|
|
11
|
+
const PortalContext = react.createContext({
|
|
12
|
+
layer: "base",
|
|
13
|
+
depth: 0,
|
|
14
|
+
floatingPortalStrategy: "root",
|
|
15
|
+
floatingZIndex: "default"
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Provider for modal overlays (Dialog, Sheet, Drawer, etc.)
|
|
19
|
+
*
|
|
20
|
+
* Wraps modal content to:
|
|
21
|
+
* 1. Create a scoped portal container for nested floating elements
|
|
22
|
+
* 2. Track the overlay layer (so floating elements know to use elevated z-index)
|
|
23
|
+
* 3. Track nesting depth for stacked modals
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <DialogPopup>
|
|
28
|
+
* <ModalPortalScope>
|
|
29
|
+
* {children} // Popovers inside here will render in the scoped container
|
|
30
|
+
* </ModalPortalScope>
|
|
31
|
+
* </DialogPopup>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function ModalPortalScope({ children, floatingPortalStrategy = "nested", floatingZIndex = "default", floatingContainer }) {
|
|
35
|
+
const parentContext = react.useContext(PortalContext);
|
|
36
|
+
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
37
|
+
const value = react.useMemo(() => ({
|
|
38
|
+
layer: "modal",
|
|
39
|
+
depth,
|
|
40
|
+
floatingPortalStrategy,
|
|
41
|
+
floatingZIndex,
|
|
42
|
+
floatingContainer: floatingContainer ?? void 0
|
|
43
|
+
}), [
|
|
44
|
+
depth,
|
|
45
|
+
floatingContainer,
|
|
46
|
+
floatingPortalStrategy,
|
|
47
|
+
floatingZIndex
|
|
48
|
+
]);
|
|
49
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PortalContext.Provider, {
|
|
50
|
+
value,
|
|
51
|
+
children
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the current portal context value.
|
|
56
|
+
* Used internally by other hooks.
|
|
57
|
+
*/
|
|
58
|
+
function usePortalContext() {
|
|
59
|
+
return react.useContext(PortalContext);
|
|
60
|
+
}
|
|
61
|
+
function useInModalOverlay() {
|
|
62
|
+
return react.useContext(PortalContext).layer === "modal";
|
|
63
|
+
}
|
|
64
|
+
function getPortalRootElement() {
|
|
65
|
+
if (typeof document === "undefined") return null;
|
|
66
|
+
return document.getElementById(PORTAL_ROOT_ID);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the root portal container element.
|
|
70
|
+
* Used by modal components (Dialog, Sheet, etc.) to render their portals.
|
|
71
|
+
*
|
|
72
|
+
* Reads `#portal-root` synchronously on the client so mount-on-open overlays
|
|
73
|
+
* (menus, selects, popovers, tooltips) get a real container on their first
|
|
74
|
+
* paint. A null→element handoff after layout effect is too late for Base UI
|
|
75
|
+
* portals that only mount while open — they stay empty forever.
|
|
76
|
+
*
|
|
77
|
+
* @returns The root portal container, or null during SSR / when unmounted
|
|
78
|
+
*/
|
|
79
|
+
function useRootPortalContainer() {
|
|
80
|
+
const [container, setContainer] = react.useState(getPortalRootElement);
|
|
81
|
+
react.useLayoutEffect(() => {
|
|
82
|
+
setContainer(getPortalRootElement());
|
|
83
|
+
}, []);
|
|
84
|
+
return container;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Centralized portal + z-index policy for floating overlays.
|
|
88
|
+
*
|
|
89
|
+
* - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal
|
|
90
|
+
* into the nearest Base UI portal node (so dialog "inert" behavior includes it).
|
|
91
|
+
* - When it's 'root', we portal into #portal-root.
|
|
92
|
+
* - When the root is not ready yet, pass `undefined` (not `null`) so Base UI
|
|
93
|
+
* falls back to `document.body` instead of rendering into a dead portal.
|
|
94
|
+
*/
|
|
95
|
+
function useFloatingOverlayPortalProps() {
|
|
96
|
+
const rootContainer = useRootPortalContainer();
|
|
97
|
+
const { floatingContainer, floatingPortalStrategy, floatingZIndex } = react.useContext(PortalContext);
|
|
98
|
+
return {
|
|
99
|
+
container: floatingContainer ?? (floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? void 0),
|
|
100
|
+
zIndexClass: floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Portal root component to render in app layout.
|
|
105
|
+
* All overlay components will render their portals inside this container.
|
|
106
|
+
*
|
|
107
|
+
* Usage in layout.tsx:
|
|
108
|
+
* ```tsx
|
|
109
|
+
* import { PortalRoot } from '@/components/ui/portal';
|
|
110
|
+
*
|
|
111
|
+
* export default function RootLayout({ children }) {
|
|
112
|
+
* return (
|
|
113
|
+
* <html>
|
|
114
|
+
* <body>
|
|
115
|
+
* {children}
|
|
116
|
+
* <PortalRoot />
|
|
117
|
+
* </body>
|
|
118
|
+
* </html>
|
|
119
|
+
* );
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
function PortalRoot() {
|
|
124
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
125
|
+
id: PORTAL_ROOT_ID,
|
|
126
|
+
"data-slot": "portal-root",
|
|
127
|
+
style: {
|
|
128
|
+
position: "fixed",
|
|
129
|
+
inset: 0,
|
|
130
|
+
zIndex: "var(--z-layer-portal-root)",
|
|
131
|
+
pointerEvents: "none"
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Hook to get the portal container element for rendering floating UI elements.
|
|
137
|
+
* Returns the element with id="portal-root" if it exists in the DOM.
|
|
138
|
+
*
|
|
139
|
+
* @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead
|
|
140
|
+
*/
|
|
141
|
+
function usePortalContainer() {
|
|
142
|
+
if (typeof document === "undefined") return void 0;
|
|
143
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
144
|
+
return el instanceof HTMLElement ? el : void 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
exports.ModalPortalScope = ModalPortalScope;
|
|
149
|
+
exports.PORTAL_ROOT_ID = PORTAL_ROOT_ID;
|
|
150
|
+
exports.PortalRoot = PortalRoot;
|
|
151
|
+
exports.useFloatingOverlayPortalProps = useFloatingOverlayPortalProps;
|
|
152
|
+
exports.useInModalOverlay = useInModalOverlay;
|
|
153
|
+
exports.usePortalContainer = usePortalContainer;
|
|
154
|
+
exports.usePortalContext = usePortalContext;
|
|
155
|
+
exports.useRootPortalContainer = useRootPortalContainer;
|
|
156
|
+
//# sourceMappingURL=portal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.cjs","names":["React"],"sources":["../../src/components/portal.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Overlay layer type:\n * - 'base': Root level (page content, base floating elements)\n * - 'modal': Inside a modal overlay (dialog, sheet, drawer)\n */\nexport type OverlayLayer = 'base' | 'modal';\n\n/**\n * Where floating overlays should portal:\n * - 'root': always portal into #portal-root\n * - 'nested': let Base UI nest portals into the nearest Base UI portal node\n */\nexport type FloatingPortalStrategy = 'root' | 'nested';\n\n/**\n * Z-index mode for floating overlays.\n * - 'default': --z-layer-floating\n * - 'elevated': --z-layer-floating-elevated\n */\nexport type FloatingZIndex = 'default' | 'elevated';\n\ninterface PortalContextValue {\n\t/** Current overlay layer */\n\tlayer: OverlayLayer;\n\t/** Modal nesting depth (0 for first modal, 1 for nested, etc.) */\n\tdepth: number;\n\t/** Strategy for where floating overlays should portal */\n\tfloatingPortalStrategy: FloatingPortalStrategy;\n\t/** Z-index mode for floating overlays */\n\tfloatingZIndex: FloatingZIndex;\n\t/** Explicit host for floating overlays when the modal primitive is not Base UI. */\n\tfloatingContainer?: HTMLElement;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nexport const PORTAL_ROOT_ID = 'portal-root';\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst PortalContext = React.createContext<PortalContextValue>({\n\tlayer: 'base',\n\tdepth: 0,\n\tfloatingPortalStrategy: 'root',\n\tfloatingZIndex: 'default',\n});\n\n// ============================================================================\n// Providers\n// ============================================================================\n\n/**\n * Provider for modal overlays (Dialog, Sheet, Drawer, etc.)\n *\n * Wraps modal content to:\n * 1. Create a scoped portal container for nested floating elements\n * 2. Track the overlay layer (so floating elements know to use elevated z-index)\n * 3. Track nesting depth for stacked modals\n *\n * Usage:\n * ```tsx\n * <DialogPopup>\n * <ModalPortalScope>\n * {children} // Popovers inside here will render in the scoped container\n * </ModalPortalScope>\n * </DialogPopup>\n * ```\n */\nexport function ModalPortalScope({\n\tchildren,\n\tfloatingPortalStrategy = 'nested',\n\tfloatingZIndex = 'default',\n\tfloatingContainer,\n}: {\n\tchildren: React.ReactNode;\n\tfloatingPortalStrategy?: FloatingPortalStrategy;\n\tfloatingZIndex?: FloatingZIndex;\n\tfloatingContainer?: HTMLElement | null;\n}) {\n\tconst parentContext = React.useContext(PortalContext);\n\n\t// Increment depth from parent if already in modal layer\n\tconst depth = parentContext.layer === 'modal' ? parentContext.depth + 1 : 0;\n\n\tconst value = React.useMemo<PortalContextValue>(\n\t\t() => ({\n\t\t\tlayer: 'modal',\n\t\t\tdepth,\n\t\t\tfloatingPortalStrategy,\n\t\t\tfloatingZIndex,\n\t\t\tfloatingContainer: floatingContainer ?? undefined,\n\t\t}),\n\t\t[depth, floatingContainer, floatingPortalStrategy, floatingZIndex],\n\t);\n\n\treturn <PortalContext.Provider value={value}>{children}</PortalContext.Provider>;\n}\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\n/**\n * Get the current portal context value.\n * Used internally by other hooks.\n */\nexport function usePortalContext(): PortalContextValue {\n\treturn React.useContext(PortalContext);\n}\n\nexport function useInModalOverlay(): boolean {\n\treturn React.useContext(PortalContext).layer === 'modal';\n}\n\nfunction getPortalRootElement(): HTMLElement | null {\n\tif (typeof document === 'undefined') return null;\n\treturn document.getElementById(PORTAL_ROOT_ID);\n}\n\n/**\n * Get the root portal container element.\n * Used by modal components (Dialog, Sheet, etc.) to render their portals.\n *\n * Reads `#portal-root` synchronously on the client so mount-on-open overlays\n * (menus, selects, popovers, tooltips) get a real container on their first\n * paint. A null→element handoff after layout effect is too late for Base UI\n * portals that only mount while open — they stay empty forever.\n *\n * @returns The root portal container, or null during SSR / when unmounted\n */\nexport function useRootPortalContainer(): HTMLElement | null {\n\tconst [container, setContainer] = React.useState<HTMLElement | null>(getPortalRootElement);\n\n\tReact.useLayoutEffect(() => {\n\t\tsetContainer(getPortalRootElement());\n\t}, []);\n\n\treturn container;\n}\n\n/**\n * Centralized portal + z-index policy for floating overlays.\n *\n * - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal\n * into the nearest Base UI portal node (so dialog \"inert\" behavior includes it).\n * - When it's 'root', we portal into #portal-root.\n * - When the root is not ready yet, pass `undefined` (not `null`) so Base UI\n * falls back to `document.body` instead of rendering into a dead portal.\n */\nexport function useFloatingOverlayPortalProps(): {\n\tcontainer?: HTMLElement;\n\tzIndexClass: string;\n} {\n\tconst rootContainer = useRootPortalContainer();\n\tconst { floatingContainer, floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);\n\n\tconst container =\n\t\tfloatingContainer ??\n\t\t(floatingPortalStrategy === 'nested' ? undefined : (rootContainer ?? undefined));\n\tconst zIndexClass =\n\t\tfloatingZIndex === 'elevated'\n\t\t\t? 'z-[var(--z-layer-floating-elevated)]'\n\t\t\t: 'z-[var(--z-layer-floating)]';\n\n\treturn { container, zIndexClass };\n}\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Portal root component to render in app layout.\n * All overlay components will render their portals inside this container.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { PortalRoot } from '@/components/ui/portal';\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * {children}\n * <PortalRoot />\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function PortalRoot() {\n\treturn (\n\t\t<div\n\t\t\tid={PORTAL_ROOT_ID}\n\t\t\tdata-slot=\"portal-root\"\n\t\t\tstyle={{\n\t\t\t\tposition: 'fixed',\n\t\t\t\tinset: 0,\n\t\t\t\tzIndex: 'var(--z-layer-portal-root)',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\t// Children (portal contents) will have pointer-events: auto\n\t\t\t}}\n\t\t/>\n\t);\n}\n\n/**\n * Hook to get the portal container element for rendering floating UI elements.\n * Returns the element with id=\"portal-root\" if it exists in the DOM.\n *\n * @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead\n */\nexport function usePortalContainer(): HTMLElement | undefined {\n\tif (typeof document === 'undefined') return undefined;\n\tconst el = document.getElementById(PORTAL_ROOT_ID);\n\treturn el instanceof HTMLElement ? el : undefined;\n}\n"],"mappings":";;;;;;;;;AA8CA,MAAa,iBAAiB;AAM9B,MAAM,gBAAgBA,MAAM,cAAkC;CAC7D,OAAO;CACP,OAAO;CACP,wBAAwB;CACxB,gBAAgB;AACjB,CAAC;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,iBAAiB,EAChC,UACA,yBAAyB,UACzB,iBAAiB,WACjB,qBAME;CACF,MAAM,gBAAgBA,MAAM,WAAW,aAAa;CAGpD,MAAM,QAAQ,cAAc,UAAU,UAAU,cAAc,QAAQ,IAAI;CAE1E,MAAM,QAAQA,MAAM,eACZ;EACN,OAAO;EACP;EACA;EACA;EACA,mBAAmB,qBAAqB;CACzC,IACA;EAAC;EAAO;EAAmB;EAAwB;CAAc,CAClE;CAEA,OAAO,2CAAC,cAAc,UAAf;EAA+B;EAAQ;CAAiC;AAChF;;;;;AAUA,SAAgB,mBAAuC;CACtD,OAAOA,MAAM,WAAW,aAAa;AACtC;AAEA,SAAgB,oBAA6B;CAC5C,OAAOA,MAAM,WAAW,aAAa,CAAC,CAAC,UAAU;AAClD;AAEA,SAAS,uBAA2C;CACnD,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,OAAO,SAAS,eAAe,cAAc;AAC9C;;;;;;;;;;;;AAaA,SAAgB,yBAA6C;CAC5D,MAAM,CAAC,WAAW,gBAAgBA,MAAM,SAA6B,oBAAoB;CAEzF,MAAM,sBAAsB;EAC3B,aAAa,qBAAqB,CAAC;CACpC,GAAG,CAAC,CAAC;CAEL,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,gCAGd;CACD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,EAAE,mBAAmB,wBAAwB,mBAAmBA,MAAM,WAAW,aAAa;CAUpG,OAAO;EAAE,WAPR,sBACC,2BAA2B,WAAW,SAAa,iBAAiB;EAMlD,aAJnB,mBAAmB,aAChB,yCACA;CAE4B;AACjC;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aAAa;CAC5B,OACC,2CAAC,OAAD;EACC,IAAI;EACJ,aAAU;EACV,OAAO;GACN,UAAU;GACV,OAAO;GACP,QAAQ;GACR,eAAe;EAEhB;CACA;AAEH;;;;;;;AAQA,SAAgB,qBAA8C;CAC7D,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,MAAM,KAAK,SAAS,eAAe,cAAc;CACjD,OAAO,cAAc,cAAc,KAAK;AACzC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/components/portal.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Overlay layer type:
|
|
5
|
+
* - 'base': Root level (page content, base floating elements)
|
|
6
|
+
* - 'modal': Inside a modal overlay (dialog, sheet, drawer)
|
|
7
|
+
*/
|
|
8
|
+
type OverlayLayer = 'base' | 'modal';
|
|
9
|
+
/**
|
|
10
|
+
* Where floating overlays should portal:
|
|
11
|
+
* - 'root': always portal into #portal-root
|
|
12
|
+
* - 'nested': let Base UI nest portals into the nearest Base UI portal node
|
|
13
|
+
*/
|
|
14
|
+
type FloatingPortalStrategy = 'root' | 'nested';
|
|
15
|
+
/**
|
|
16
|
+
* Z-index mode for floating overlays.
|
|
17
|
+
* - 'default': --z-layer-floating
|
|
18
|
+
* - 'elevated': --z-layer-floating-elevated
|
|
19
|
+
*/
|
|
20
|
+
type FloatingZIndex = 'default' | 'elevated';
|
|
21
|
+
interface PortalContextValue {
|
|
22
|
+
/** Current overlay layer */
|
|
23
|
+
layer: OverlayLayer;
|
|
24
|
+
/** Modal nesting depth (0 for first modal, 1 for nested, etc.) */
|
|
25
|
+
depth: number;
|
|
26
|
+
/** Strategy for where floating overlays should portal */
|
|
27
|
+
floatingPortalStrategy: FloatingPortalStrategy;
|
|
28
|
+
/** Z-index mode for floating overlays */
|
|
29
|
+
floatingZIndex: FloatingZIndex;
|
|
30
|
+
/** Explicit host for floating overlays when the modal primitive is not Base UI. */
|
|
31
|
+
floatingContainer?: HTMLElement;
|
|
32
|
+
}
|
|
33
|
+
declare const PORTAL_ROOT_ID = "portal-root";
|
|
34
|
+
/**
|
|
35
|
+
* Provider for modal overlays (Dialog, Sheet, Drawer, etc.)
|
|
36
|
+
*
|
|
37
|
+
* Wraps modal content to:
|
|
38
|
+
* 1. Create a scoped portal container for nested floating elements
|
|
39
|
+
* 2. Track the overlay layer (so floating elements know to use elevated z-index)
|
|
40
|
+
* 3. Track nesting depth for stacked modals
|
|
41
|
+
*
|
|
42
|
+
* Usage:
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <DialogPopup>
|
|
45
|
+
* <ModalPortalScope>
|
|
46
|
+
* {children} // Popovers inside here will render in the scoped container
|
|
47
|
+
* </ModalPortalScope>
|
|
48
|
+
* </DialogPopup>
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function ModalPortalScope({ children, floatingPortalStrategy, floatingZIndex, floatingContainer }: {
|
|
52
|
+
children: React$1.ReactNode;
|
|
53
|
+
floatingPortalStrategy?: FloatingPortalStrategy;
|
|
54
|
+
floatingZIndex?: FloatingZIndex;
|
|
55
|
+
floatingContainer?: HTMLElement | null;
|
|
56
|
+
}): React$1.JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current portal context value.
|
|
59
|
+
* Used internally by other hooks.
|
|
60
|
+
*/
|
|
61
|
+
declare function usePortalContext(): PortalContextValue;
|
|
62
|
+
declare function useInModalOverlay(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Get the root portal container element.
|
|
65
|
+
* Used by modal components (Dialog, Sheet, etc.) to render their portals.
|
|
66
|
+
*
|
|
67
|
+
* Reads `#portal-root` synchronously on the client so mount-on-open overlays
|
|
68
|
+
* (menus, selects, popovers, tooltips) get a real container on their first
|
|
69
|
+
* paint. A null→element handoff after layout effect is too late for Base UI
|
|
70
|
+
* portals that only mount while open — they stay empty forever.
|
|
71
|
+
*
|
|
72
|
+
* @returns The root portal container, or null during SSR / when unmounted
|
|
73
|
+
*/
|
|
74
|
+
declare function useRootPortalContainer(): HTMLElement | null;
|
|
75
|
+
/**
|
|
76
|
+
* Centralized portal + z-index policy for floating overlays.
|
|
77
|
+
*
|
|
78
|
+
* - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal
|
|
79
|
+
* into the nearest Base UI portal node (so dialog "inert" behavior includes it).
|
|
80
|
+
* - When it's 'root', we portal into #portal-root.
|
|
81
|
+
* - When the root is not ready yet, pass `undefined` (not `null`) so Base UI
|
|
82
|
+
* falls back to `document.body` instead of rendering into a dead portal.
|
|
83
|
+
*/
|
|
84
|
+
declare function useFloatingOverlayPortalProps(): {
|
|
85
|
+
container?: HTMLElement;
|
|
86
|
+
zIndexClass: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Portal root component to render in app layout.
|
|
90
|
+
* All overlay components will render their portals inside this container.
|
|
91
|
+
*
|
|
92
|
+
* Usage in layout.tsx:
|
|
93
|
+
* ```tsx
|
|
94
|
+
* import { PortalRoot } from '@/components/ui/portal';
|
|
95
|
+
*
|
|
96
|
+
* export default function RootLayout({ children }) {
|
|
97
|
+
* return (
|
|
98
|
+
* <html>
|
|
99
|
+
* <body>
|
|
100
|
+
* {children}
|
|
101
|
+
* <PortalRoot />
|
|
102
|
+
* </body>
|
|
103
|
+
* </html>
|
|
104
|
+
* );
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare function PortalRoot(): React$1.JSX.Element;
|
|
109
|
+
/**
|
|
110
|
+
* Hook to get the portal container element for rendering floating UI elements.
|
|
111
|
+
* Returns the element with id="portal-root" if it exists in the DOM.
|
|
112
|
+
*
|
|
113
|
+
* @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead
|
|
114
|
+
*/
|
|
115
|
+
declare function usePortalContainer(): HTMLElement | undefined;
|
|
116
|
+
//#endregion
|
|
117
|
+
export { FloatingPortalStrategy, FloatingZIndex, ModalPortalScope, OverlayLayer, PORTAL_ROOT_ID, PortalRoot, useFloatingOverlayPortalProps, useInModalOverlay, usePortalContainer, usePortalContext, useRootPortalContainer };
|
|
118
|
+
//# sourceMappingURL=portal.d.cts.map
|