@constructive-io/ui 0.4.1 → 0.6.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/LICENSE +21 -0
- package/README.md +17 -22
- package/dist/components/alert-dialog.cjs +333 -0
- package/dist/components/alert-dialog.cjs.map +1 -0
- package/dist/components/alert-dialog.d.cts +32 -0
- package/dist/components/alert-dialog.d.ts +16 -15
- package/dist/components/alert-dialog.js +89 -102
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.cjs +119 -0
- package/dist/components/alert.cjs.map +1 -0
- package/dist/components/alert.d.cts +19 -0
- package/dist/components/alert.d.ts +10 -5
- package/dist/components/alert.js +62 -6
- package/dist/components/alert.js.map +1 -1
- package/dist/components/app-bar.cjs +367 -0
- package/dist/components/app-bar.cjs.map +1 -0
- package/dist/components/app-bar.d.cts +26 -0
- package/dist/components/app-bar.d.ts +26 -0
- package/dist/components/app-bar.js +344 -0
- package/dist/components/app-bar.js.map +1 -0
- package/dist/components/app-shell.cjs +1792 -0
- package/dist/components/app-shell.cjs.map +1 -0
- package/dist/components/app-shell.d.cts +106 -0
- package/dist/components/app-shell.d.ts +106 -0
- package/dist/components/app-shell.js +1771 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/autocomplete.cjs +418 -0
- package/dist/components/autocomplete.cjs.map +1 -0
- package/dist/components/autocomplete.d.cts +28 -0
- package/dist/components/autocomplete.d.ts +15 -15
- package/dist/components/autocomplete.js +9 -30
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.cjs +51 -0
- package/dist/components/avatar.cjs.map +1 -0
- package/dist/components/avatar.d.cts +12 -0
- package/dist/components/avatar.d.ts +3 -4
- package/dist/components/avatar.js +11 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.cjs +66 -0
- package/dist/components/badge.cjs.map +1 -0
- package/dist/components/badge.d.cts +15 -0
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/breadcrumb.cjs +118 -0
- package/dist/components/breadcrumb.cjs.map +1 -0
- package/dist/components/breadcrumb.d.cts +14 -0
- package/dist/components/breadcrumb.d.ts +9 -9
- package/dist/components/breadcrumb.js +19 -83
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.cjs +169 -0
- package/dist/components/button.cjs.map +1 -0
- package/dist/components/button.d.cts +20 -0
- package/dist/components/button.d.ts +3 -0
- package/dist/components/button.js +105 -21
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-rac.cjs +85 -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 +3 -3
- package/dist/components/card.cjs +99 -0
- package/dist/components/card.cjs.map +1 -0
- package/dist/components/card.d.cts +18 -0
- package/dist/components/card.d.ts +7 -8
- package/dist/components/card.js +23 -8
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +18 -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 +2 -2
- package/dist/components/checkbox.cjs +121 -0
- package/dist/components/checkbox.cjs.map +1 -0
- package/dist/components/checkbox.d.cts +8 -0
- package/dist/components/checkbox.d.ts +3 -3
- package/dist/components/checkbox.js +73 -41
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.cjs +127 -0
- package/dist/components/collapsible.cjs.map +1 -0
- package/dist/components/collapsible.d.cts +44 -0
- package/dist/components/collapsible.d.ts +8 -18
- package/dist/components/collapsible.js +7 -27
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.cjs +551 -0
- package/dist/components/combobox.cjs.map +1 -0
- package/dist/components/combobox.d.cts +43 -0
- package/dist/components/combobox.d.ts +17 -18
- package/dist/components/combobox.js +37 -48
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.cjs +236 -0
- package/dist/components/command.cjs.map +1 -0
- package/dist/components/command.d.cts +23 -0
- package/dist/components/command.d.ts +14 -15
- package/dist/components/command.js +5 -38
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.cjs +431 -0
- package/dist/components/dialog.cjs.map +1 -0
- package/dist/components/dialog.d.cts +30 -0
- package/dist/components/dialog.d.ts +13 -18
- package/dist/components/dialog.js +75 -119
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.cjs +121 -0
- package/dist/components/dock.cjs.map +1 -0
- package/dist/components/dock.d.cts +30 -0
- package/dist/components/dock.d.ts +1 -2
- package/dist/components/dock.js +7 -5
- package/dist/components/dock.js.map +1 -1
- package/dist/components/drawer.cjs +149 -0
- package/dist/components/drawer.cjs.map +1 -0
- package/dist/components/drawer.d.cts +15 -0
- package/dist/components/drawer.d.ts +10 -11
- package/dist/components/drawer.js +11 -40
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +292 -0
- package/dist/components/dropdown-menu.cjs.map +1 -0
- package/dist/components/dropdown-menu.d.cts +52 -0
- package/dist/components/dropdown-menu.d.ts +23 -21
- package/dist/components/dropdown-menu.js +67 -191
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty.cjs +106 -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 +99 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.cjs +295 -0
- package/dist/components/field.cjs.map +1 -0
- package/dist/components/field.d.cts +46 -0
- package/dist/components/field.d.ts +34 -39
- package/dist/components/field.js +220 -72
- package/dist/components/field.js.map +1 -1
- package/dist/components/flickering-grid.cjs +176 -0
- package/dist/components/flickering-grid.cjs.map +1 -0
- package/dist/components/flickering-grid.d.cts +15 -0
- package/dist/components/flickering-grid.js +25 -2
- package/dist/components/flickering-grid.js.map +1 -1
- package/dist/components/flow-zoom-panel.cjs +194 -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 +173 -0
- package/dist/components/flow-zoom-panel.js.map +1 -0
- package/dist/components/form-control.cjs +193 -0
- package/dist/components/form-control.cjs.map +1 -0
- package/dist/components/form-control.d.cts +14 -0
- package/dist/components/form-control.d.ts +1 -2
- package/dist/components/form-control.js +2 -4
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.cjs +208 -0
- package/dist/components/form.cjs.map +1 -0
- package/dist/components/form.d.cts +36 -0
- package/dist/components/form.d.ts +7 -8
- package/dist/components/input-group.cjs +184 -0
- package/dist/components/input-group.cjs.map +1 -0
- package/dist/components/input-group.d.cts +17 -0
- package/dist/components/input-group.d.ts +6 -7
- package/dist/components/input-group.js +3 -2
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +62 -0
- package/dist/components/input.cjs.map +1 -0
- package/dist/components/input.d.cts +10 -0
- package/dist/components/input.d.ts +1 -2
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.cjs +351 -0
- package/dist/components/json-input.cjs.map +1 -0
- package/dist/components/json-input.d.cts +25 -0
- package/dist/components/json-input.d.ts +3 -3
- package/dist/components/json-input.js +89 -112
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/label.cjs +29 -0
- package/dist/components/label.cjs.map +1 -0
- package/dist/components/label.d.cts +10 -0
- package/dist/components/label.d.ts +1 -2
- package/dist/components/motion-grid.cjs +108 -0
- package/dist/components/motion-grid.cjs.map +1 -0
- package/dist/components/motion-grid.d.cts +19 -0
- package/dist/components/motion-grid.d.ts +1 -2
- package/dist/components/motion-grid.js +9 -4
- package/dist/components/motion-grid.js.map +1 -1
- package/dist/components/multi-select.cjs +796 -0
- package/dist/components/multi-select.cjs.map +1 -0
- package/dist/components/multi-select.d.cts +198 -0
- package/dist/components/multi-select.js +54 -162
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/page-header.cjs +19 -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 +2 -2
- package/dist/components/pagination.cjs +295 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +18 -0
- package/dist/components/pagination.d.ts +7 -8
- package/dist/components/pagination.js +152 -29
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.cjs +140 -0
- package/dist/components/popover.cjs.map +1 -0
- package/dist/components/popover.d.cts +39 -0
- package/dist/components/popover.d.ts +13 -9
- package/dist/components/popover.js +56 -132
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.cjs +109 -0
- package/dist/components/portal.cjs.map +1 -0
- package/dist/components/portal.d.cts +117 -0
- package/dist/components/portal.d.ts +16 -7
- package/dist/components/portal.js +13 -8
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.cjs +31 -0
- package/dist/components/progress.cjs.map +1 -0
- package/dist/components/progress.d.cts +9 -0
- package/dist/components/progress.d.ts +1 -2
- package/dist/components/progress.js +1 -2
- package/dist/components/progress.js.map +1 -1
- package/dist/components/progressive-blur-scroll-container.cjs +144 -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 +2 -2
- package/dist/components/progressive-blur.cjs +70 -0
- package/dist/components/progressive-blur.cjs.map +1 -0
- package/dist/components/progressive-blur.d.cts +16 -0
- package/dist/components/progressive-blur.d.ts +2 -2
- package/dist/components/radio-group.cjs +52 -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 +3 -3
- package/dist/components/radio-group.js +21 -10
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/record-picker.cjs +420 -0
- package/dist/components/record-picker.cjs.map +1 -0
- package/dist/components/record-picker.d.cts +16 -0
- package/dist/components/record-picker.d.ts +2 -2
- package/dist/components/record-picker.js +76 -43
- package/dist/components/record-picker.js.map +1 -1
- package/dist/components/resizable.cjs +76 -0
- package/dist/components/resizable.cjs.map +1 -0
- package/dist/components/resizable.d.cts +10 -0
- package/dist/components/resizable.d.ts +3 -4
- package/dist/components/responsive-diagram.cjs +67 -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 +2 -2
- package/dist/components/scroll-area.cjs +92 -0
- package/dist/components/scroll-area.cjs.map +1 -0
- package/dist/components/scroll-area.d.cts +11 -0
- package/dist/components/scroll-area.d.ts +5 -6
- package/dist/components/select.cjs +329 -0
- package/dist/components/select.cjs.map +1 -0
- package/dist/components/select.d.cts +46 -0
- package/dist/components/select.d.ts +13 -14
- package/dist/components/select.js +76 -67
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +26 -0
- package/dist/components/separator.cjs.map +1 -0
- package/dist/components/separator.d.cts +10 -0
- package/dist/components/separator.d.ts +1 -2
- package/dist/components/sheet.cjs +489 -0
- package/dist/components/sheet.cjs.map +1 -0
- package/dist/components/sheet.d.cts +107 -0
- package/dist/components/sheet.d.ts +14 -19
- package/dist/components/sheet.js +119 -264
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.cjs +1300 -0
- package/dist/components/sidebar.cjs.map +1 -0
- package/dist/components/sidebar.d.cts +70 -0
- package/dist/components/sidebar.d.ts +32 -39
- package/dist/components/sidebar.js +401 -362
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton.cjs +36 -0
- package/dist/components/skeleton.cjs.map +1 -0
- package/dist/components/skeleton.d.cts +10 -0
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +19 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/sonner.cjs +25 -0
- package/dist/components/sonner.cjs.map +1 -0
- package/dist/components/sonner.d.cts +10 -0
- package/dist/components/sonner.d.ts +2 -2
- package/dist/components/stack/index.cjs +1516 -0
- package/dist/components/stack/index.cjs.map +1 -0
- package/dist/components/stack/index.d.cts +672 -0
- package/dist/components/stack/index.d.ts +36 -38
- package/dist/components/stack/index.js +42 -31
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/stepper.cjs +314 -0
- package/dist/components/stepper.cjs.map +1 -0
- package/dist/components/stepper.d.cts +31 -0
- package/dist/components/stepper.d.ts +9 -8
- package/dist/components/stepper.js +22 -15
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.cjs +46 -0
- package/dist/components/switch.cjs.map +1 -0
- package/dist/components/switch.d.cts +7 -0
- package/dist/components/switch.d.ts +1 -2
- package/dist/components/switch.js +9 -5
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +133 -0
- package/dist/components/table.cjs.map +1 -0
- package/dist/components/table.d.cts +22 -0
- package/dist/components/table.d.ts +19 -12
- package/dist/components/table.js +72 -13
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +53 -0
- package/dist/components/tabs.cjs.map +1 -0
- package/dist/components/tabs.d.cts +9 -0
- package/dist/components/tabs.d.ts +4 -5
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.cjs +451 -0
- package/dist/components/tags.cjs.map +1 -0
- package/dist/components/tags.d.cts +40 -0
- package/dist/components/tags.d.ts +10 -10
- package/dist/components/tags.js +129 -154
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.cjs +56 -0
- package/dist/components/textarea.cjs.map +1 -0
- package/dist/components/textarea.d.cts +9 -0
- package/dist/components/textarea.d.ts +1 -2
- package/dist/components/toast/index.cjs +612 -0
- package/dist/components/toast/index.cjs.map +1 -0
- package/dist/components/toast/index.d.cts +52 -0
- package/dist/components/toast/index.js +90 -127
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/tooltip.cjs +92 -0
- package/dist/components/tooltip.cjs.map +1 -0
- package/dist/components/tooltip.d.cts +28 -0
- package/dist/components/tooltip.d.ts +5 -6
- package/dist/components/tooltip.js +23 -130
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unlink-button.cjs +197 -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 +2 -2
- package/dist/components/unlink-button.js +105 -21
- package/dist/components/unlink-button.js.map +1 -1
- package/dist/index.cjs +2074 -2723
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +492 -904
- package/dist/index.d.ts +492 -904
- package/dist/index.js +1897 -2569
- package/dist/index.js.map +1 -1
- package/package.json +286 -45
- 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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
|
+
|
|
27
|
+
var PORTAL_ROOT_ID = "portal-root";
|
|
28
|
+
var PortalContext = React__namespace.createContext({
|
|
29
|
+
layer: "base",
|
|
30
|
+
depth: 0,
|
|
31
|
+
floatingPortalStrategy: "root",
|
|
32
|
+
floatingZIndex: "default"
|
|
33
|
+
});
|
|
34
|
+
function ModalPortalScope({
|
|
35
|
+
children,
|
|
36
|
+
floatingPortalStrategy = "nested",
|
|
37
|
+
floatingZIndex = "default",
|
|
38
|
+
floatingContainer
|
|
39
|
+
}) {
|
|
40
|
+
const parentContext = React__namespace.useContext(PortalContext);
|
|
41
|
+
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
42
|
+
const value = React__namespace.useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
layer: "modal",
|
|
45
|
+
depth,
|
|
46
|
+
floatingPortalStrategy,
|
|
47
|
+
floatingZIndex,
|
|
48
|
+
floatingContainer: floatingContainer ?? void 0
|
|
49
|
+
}),
|
|
50
|
+
[depth, floatingContainer, floatingPortalStrategy, floatingZIndex]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children });
|
|
53
|
+
}
|
|
54
|
+
function usePortalContext() {
|
|
55
|
+
return React__namespace.useContext(PortalContext);
|
|
56
|
+
}
|
|
57
|
+
function useInModalOverlay() {
|
|
58
|
+
return React__namespace.useContext(PortalContext).layer === "modal";
|
|
59
|
+
}
|
|
60
|
+
function getPortalRootElement() {
|
|
61
|
+
if (typeof document === "undefined") return null;
|
|
62
|
+
return document.getElementById(PORTAL_ROOT_ID);
|
|
63
|
+
}
|
|
64
|
+
function useRootPortalContainer() {
|
|
65
|
+
const [container, setContainer] = React__namespace.useState(getPortalRootElement);
|
|
66
|
+
React__namespace.useLayoutEffect(() => {
|
|
67
|
+
setContainer(getPortalRootElement());
|
|
68
|
+
}, []);
|
|
69
|
+
return container;
|
|
70
|
+
}
|
|
71
|
+
function useFloatingOverlayPortalProps() {
|
|
72
|
+
const rootContainer = useRootPortalContainer();
|
|
73
|
+
const { floatingContainer, floatingPortalStrategy, floatingZIndex } = React__namespace.useContext(PortalContext);
|
|
74
|
+
const container = floatingContainer ?? (floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? void 0);
|
|
75
|
+
const zIndexClass = floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]";
|
|
76
|
+
return { container, zIndexClass };
|
|
77
|
+
}
|
|
78
|
+
function PortalRoot() {
|
|
79
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
id: PORTAL_ROOT_ID,
|
|
83
|
+
"data-slot": "portal-root",
|
|
84
|
+
style: {
|
|
85
|
+
position: "fixed",
|
|
86
|
+
inset: 0,
|
|
87
|
+
zIndex: "var(--z-layer-portal-root)",
|
|
88
|
+
pointerEvents: "none"
|
|
89
|
+
// Children (portal contents) will have pointer-events: auto
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function usePortalContainer() {
|
|
95
|
+
if (typeof document === "undefined") return void 0;
|
|
96
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
97
|
+
return el instanceof HTMLElement ? el : void 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
exports.ModalPortalScope = ModalPortalScope;
|
|
101
|
+
exports.PORTAL_ROOT_ID = PORTAL_ROOT_ID;
|
|
102
|
+
exports.PortalRoot = PortalRoot;
|
|
103
|
+
exports.useFloatingOverlayPortalProps = useFloatingOverlayPortalProps;
|
|
104
|
+
exports.useInModalOverlay = useInModalOverlay;
|
|
105
|
+
exports.usePortalContainer = usePortalContainer;
|
|
106
|
+
exports.usePortalContext = usePortalContext;
|
|
107
|
+
exports.useRootPortalContainer = useRootPortalContainer;
|
|
108
|
+
//# sourceMappingURL=portal.cjs.map
|
|
109
|
+
//# sourceMappingURL=portal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portal.tsx"],"names":["React","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8CO,IAAM,cAAA,GAAiB;AAM9B,IAAM,gBAAsBA,gBAAA,CAAA,aAAA,CAAkC;AAAA,EAC7D,KAAA,EAAO,MAAA;AAAA,EACP,KAAA,EAAO,CAAA;AAAA,EACP,sBAAA,EAAwB,MAAA;AAAA,EACxB,cAAA,EAAgB;AACjB,CAAC,CAAA;AAuBM,SAAS,gBAAA,CAAiB;AAAA,EAChC,QAAA;AAAA,EACA,sBAAA,GAAyB,QAAA;AAAA,EACzB,cAAA,GAAiB,SAAA;AAAA,EACjB;AACD,CAAA,EAKG;AACF,EAAA,MAAM,aAAA,GAAsBA,4BAAW,aAAa,CAAA;AAGpD,EAAA,MAAM,QAAQ,aAAA,CAAc,KAAA,KAAU,OAAA,GAAU,aAAA,CAAc,QAAQ,CAAA,GAAI,CAAA;AAE1E,EAAA,MAAM,KAAA,GAAcA,gBAAA,CAAA,OAAA;AAAA,IACnB,OAAO;AAAA,MACN,KAAA,EAAO,OAAA;AAAA,MACP,KAAA;AAAA,MACA,sBAAA;AAAA,MACA,cAAA;AAAA,MACA,mBAAmB,iBAAA,IAAqB;AAAA,KACzC,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,iBAAA,EAAmB,sBAAA,EAAwB,cAAc;AAAA,GAClE;AAEA,EAAA,uBAAOC,cAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OAAe,QAAA,EAAS,CAAA;AACxD;AAUO,SAAS,gBAAA,GAAuC;AACtD,EAAA,OAAaD,4BAAW,aAAa,CAAA;AACtC;AAEO,SAAS,iBAAA,GAA6B;AAC5C,EAAA,OAAaA,gBAAA,CAAA,UAAA,CAAW,aAAa,CAAA,CAAE,KAAA,KAAU,OAAA;AAClD;AAEA,SAAS,oBAAA,GAA2C;AACnD,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,IAAA;AAC5C,EAAA,OAAO,QAAA,CAAS,eAAe,cAAc,CAAA;AAC9C;AAaO,SAAS,sBAAA,GAA6C;AAC5D,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAUA,0BAA6B,oBAAoB,CAAA;AAEzF,EAAMA,iCAAgB,MAAM;AAC3B,IAAA,YAAA,CAAa,sBAAsB,CAAA;AAAA,EACpC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,SAAA;AACR;AAWO,SAAS,6BAAA,GAGd;AACD,EAAA,MAAM,gBAAgB,sBAAA,EAAuB;AAC7C,EAAA,MAAM,EAAE,iBAAA,EAAmB,sBAAA,EAAwB,cAAA,EAAe,GAAUA,4BAAW,aAAa,CAAA;AAEpG,EAAA,MAAM,SAAA,GACL,iBAAA,KACC,sBAAA,KAA2B,QAAA,GAAW,SAAa,aAAA,IAAiB,MAAA,CAAA;AACtE,EAAA,MAAM,WAAA,GACL,cAAA,KAAmB,UAAA,GAChB,sCAAA,GACA,6BAAA;AAEJ,EAAA,OAAO,EAAE,WAAW,WAAA,EAAY;AACjC;AA0BO,SAAS,UAAA,GAAa;AAC5B,EAAA,uBACCC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACA,EAAA,EAAI,cAAA;AAAA,MACJ,WAAA,EAAU,aAAA;AAAA,MACV,KAAA,EAAO;AAAA,QACN,QAAA,EAAU,OAAA;AAAA,QACV,KAAA,EAAO,CAAA;AAAA,QACP,MAAA,EAAQ,4BAAA;AAAA,QACR,aAAA,EAAe;AAAA;AAAA;AAEhB;AAAA,GACD;AAEF;AAQO,SAAS,kBAAA,GAA8C;AAC7D,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,MAAA;AAC5C,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,cAAA,CAAe,cAAc,CAAA;AACjD,EAAA,OAAO,EAAA,YAAc,cAAc,EAAA,GAAK,MAAA;AACzC","file":"portal.cjs","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"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
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.ReactNode;
|
|
53
|
+
floatingPortalStrategy?: FloatingPortalStrategy;
|
|
54
|
+
floatingZIndex?: FloatingZIndex;
|
|
55
|
+
floatingContainer?: HTMLElement | null;
|
|
56
|
+
}): React.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.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
|
+
|
|
117
|
+
export { type FloatingPortalStrategy, type FloatingZIndex, ModalPortalScope, type OverlayLayer, PORTAL_ROOT_ID, PortalRoot, useFloatingOverlayPortalProps, useInModalOverlay, usePortalContainer, usePortalContext, useRootPortalContainer };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -28,6 +27,8 @@ interface PortalContextValue {
|
|
|
28
27
|
floatingPortalStrategy: FloatingPortalStrategy;
|
|
29
28
|
/** Z-index mode for floating overlays */
|
|
30
29
|
floatingZIndex: FloatingZIndex;
|
|
30
|
+
/** Explicit host for floating overlays when the modal primitive is not Base UI. */
|
|
31
|
+
floatingContainer?: HTMLElement;
|
|
31
32
|
}
|
|
32
33
|
declare const PORTAL_ROOT_ID = "portal-root";
|
|
33
34
|
/**
|
|
@@ -47,11 +48,12 @@ declare const PORTAL_ROOT_ID = "portal-root";
|
|
|
47
48
|
* </DialogPopup>
|
|
48
49
|
* ```
|
|
49
50
|
*/
|
|
50
|
-
declare function ModalPortalScope({ children, floatingPortalStrategy, floatingZIndex, }: {
|
|
51
|
+
declare function ModalPortalScope({ children, floatingPortalStrategy, floatingZIndex, floatingContainer, }: {
|
|
51
52
|
children: React.ReactNode;
|
|
52
53
|
floatingPortalStrategy?: FloatingPortalStrategy;
|
|
53
54
|
floatingZIndex?: FloatingZIndex;
|
|
54
|
-
|
|
55
|
+
floatingContainer?: HTMLElement | null;
|
|
56
|
+
}): React.JSX.Element;
|
|
55
57
|
/**
|
|
56
58
|
* Get the current portal context value.
|
|
57
59
|
* Used internally by other hooks.
|
|
@@ -62,7 +64,12 @@ declare function useInModalOverlay(): boolean;
|
|
|
62
64
|
* Get the root portal container element.
|
|
63
65
|
* Used by modal components (Dialog, Sheet, etc.) to render their portals.
|
|
64
66
|
*
|
|
65
|
-
*
|
|
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
|
|
66
73
|
*/
|
|
67
74
|
declare function useRootPortalContainer(): HTMLElement | null;
|
|
68
75
|
/**
|
|
@@ -71,9 +78,11 @@ declare function useRootPortalContainer(): HTMLElement | null;
|
|
|
71
78
|
* - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal
|
|
72
79
|
* into the nearest Base UI portal node (so dialog "inert" behavior includes it).
|
|
73
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.
|
|
74
83
|
*/
|
|
75
84
|
declare function useFloatingOverlayPortalProps(): {
|
|
76
|
-
container?: HTMLElement
|
|
85
|
+
container?: HTMLElement;
|
|
77
86
|
zIndexClass: string;
|
|
78
87
|
};
|
|
79
88
|
/**
|
|
@@ -82,7 +91,7 @@ declare function useFloatingOverlayPortalProps(): {
|
|
|
82
91
|
*
|
|
83
92
|
* Usage in layout.tsx:
|
|
84
93
|
* ```tsx
|
|
85
|
-
* import { PortalRoot } from '
|
|
94
|
+
* import { PortalRoot } from '@/components/ui/portal';
|
|
86
95
|
*
|
|
87
96
|
* export default function RootLayout({ children }) {
|
|
88
97
|
* return (
|
|
@@ -96,7 +105,7 @@ declare function useFloatingOverlayPortalProps(): {
|
|
|
96
105
|
* }
|
|
97
106
|
* ```
|
|
98
107
|
*/
|
|
99
|
-
declare function PortalRoot():
|
|
108
|
+
declare function PortalRoot(): React.JSX.Element;
|
|
100
109
|
/**
|
|
101
110
|
* Hook to get the portal container element for rendering floating UI elements.
|
|
102
111
|
* Returns the element with id="portal-root" if it exists in the DOM.
|
|
@@ -12,7 +12,8 @@ var PortalContext = React.createContext({
|
|
|
12
12
|
function ModalPortalScope({
|
|
13
13
|
children,
|
|
14
14
|
floatingPortalStrategy = "nested",
|
|
15
|
-
floatingZIndex = "default"
|
|
15
|
+
floatingZIndex = "default",
|
|
16
|
+
floatingContainer
|
|
16
17
|
}) {
|
|
17
18
|
const parentContext = React.useContext(PortalContext);
|
|
18
19
|
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
@@ -21,9 +22,10 @@ function ModalPortalScope({
|
|
|
21
22
|
layer: "modal",
|
|
22
23
|
depth,
|
|
23
24
|
floatingPortalStrategy,
|
|
24
|
-
floatingZIndex
|
|
25
|
+
floatingZIndex,
|
|
26
|
+
floatingContainer: floatingContainer ?? void 0
|
|
25
27
|
}),
|
|
26
|
-
[depth, floatingPortalStrategy, floatingZIndex]
|
|
28
|
+
[depth, floatingContainer, floatingPortalStrategy, floatingZIndex]
|
|
27
29
|
);
|
|
28
30
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
29
31
|
}
|
|
@@ -33,18 +35,21 @@ function usePortalContext() {
|
|
|
33
35
|
function useInModalOverlay() {
|
|
34
36
|
return React.useContext(PortalContext).layer === "modal";
|
|
35
37
|
}
|
|
38
|
+
function getPortalRootElement() {
|
|
39
|
+
if (typeof document === "undefined") return null;
|
|
40
|
+
return document.getElementById(PORTAL_ROOT_ID);
|
|
41
|
+
}
|
|
36
42
|
function useRootPortalContainer() {
|
|
37
|
-
const [container, setContainer] = React.useState(
|
|
43
|
+
const [container, setContainer] = React.useState(getPortalRootElement);
|
|
38
44
|
React.useLayoutEffect(() => {
|
|
39
|
-
|
|
40
|
-
setContainer(el);
|
|
45
|
+
setContainer(getPortalRootElement());
|
|
41
46
|
}, []);
|
|
42
47
|
return container;
|
|
43
48
|
}
|
|
44
49
|
function useFloatingOverlayPortalProps() {
|
|
45
50
|
const rootContainer = useRootPortalContainer();
|
|
46
|
-
const { floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);
|
|
47
|
-
const container = floatingPortalStrategy === "nested" ? void 0 : rootContainer ??
|
|
51
|
+
const { floatingContainer, floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);
|
|
52
|
+
const container = floatingContainer ?? (floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? void 0);
|
|
48
53
|
const zIndexClass = floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]";
|
|
49
54
|
return { container, zIndexClass };
|
|
50
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/portal.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/components/portal.tsx"],"names":[],"mappings":";;;AA8CO,IAAM,cAAA,GAAiB;AAM9B,IAAM,gBAAsB,KAAA,CAAA,aAAA,CAAkC;AAAA,EAC7D,KAAA,EAAO,MAAA;AAAA,EACP,KAAA,EAAO,CAAA;AAAA,EACP,sBAAA,EAAwB,MAAA;AAAA,EACxB,cAAA,EAAgB;AACjB,CAAC,CAAA;AAuBM,SAAS,gBAAA,CAAiB;AAAA,EAChC,QAAA;AAAA,EACA,sBAAA,GAAyB,QAAA;AAAA,EACzB,cAAA,GAAiB,SAAA;AAAA,EACjB;AACD,CAAA,EAKG;AACF,EAAA,MAAM,aAAA,GAAsB,iBAAW,aAAa,CAAA;AAGpD,EAAA,MAAM,QAAQ,aAAA,CAAc,KAAA,KAAU,OAAA,GAAU,aAAA,CAAc,QAAQ,CAAA,GAAI,CAAA;AAE1E,EAAA,MAAM,KAAA,GAAc,KAAA,CAAA,OAAA;AAAA,IACnB,OAAO;AAAA,MACN,KAAA,EAAO,OAAA;AAAA,MACP,KAAA;AAAA,MACA,sBAAA;AAAA,MACA,cAAA;AAAA,MACA,mBAAmB,iBAAA,IAAqB;AAAA,KACzC,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,iBAAA,EAAmB,sBAAA,EAAwB,cAAc;AAAA,GAClE;AAEA,EAAA,uBAAO,GAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OAAe,QAAA,EAAS,CAAA;AACxD;AAUO,SAAS,gBAAA,GAAuC;AACtD,EAAA,OAAa,iBAAW,aAAa,CAAA;AACtC;AAEO,SAAS,iBAAA,GAA6B;AAC5C,EAAA,OAAa,KAAA,CAAA,UAAA,CAAW,aAAa,CAAA,CAAE,KAAA,KAAU,OAAA;AAClD;AAEA,SAAS,oBAAA,GAA2C;AACnD,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,IAAA;AAC5C,EAAA,OAAO,QAAA,CAAS,eAAe,cAAc,CAAA;AAC9C;AAaO,SAAS,sBAAA,GAA6C;AAC5D,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAU,eAA6B,oBAAoB,CAAA;AAEzF,EAAM,sBAAgB,MAAM;AAC3B,IAAA,YAAA,CAAa,sBAAsB,CAAA;AAAA,EACpC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,SAAA;AACR;AAWO,SAAS,6BAAA,GAGd;AACD,EAAA,MAAM,gBAAgB,sBAAA,EAAuB;AAC7C,EAAA,MAAM,EAAE,iBAAA,EAAmB,sBAAA,EAAwB,cAAA,EAAe,GAAU,iBAAW,aAAa,CAAA;AAEpG,EAAA,MAAM,SAAA,GACL,iBAAA,KACC,sBAAA,KAA2B,QAAA,GAAW,SAAa,aAAA,IAAiB,MAAA,CAAA;AACtE,EAAA,MAAM,WAAA,GACL,cAAA,KAAmB,UAAA,GAChB,sCAAA,GACA,6BAAA;AAEJ,EAAA,OAAO,EAAE,WAAW,WAAA,EAAY;AACjC;AA0BO,SAAS,UAAA,GAAa;AAC5B,EAAA,uBACC,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACA,EAAA,EAAI,cAAA;AAAA,MACJ,WAAA,EAAU,aAAA;AAAA,MACV,KAAA,EAAO;AAAA,QACN,QAAA,EAAU,OAAA;AAAA,QACV,KAAA,EAAO,CAAA;AAAA,QACP,MAAA,EAAQ,4BAAA;AAAA,QACR,aAAA,EAAe;AAAA;AAAA;AAEhB;AAAA,GACD;AAEF;AAQO,SAAS,kBAAA,GAA8C;AAC7D,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,MAAA;AAC5C,EAAA,MAAM,EAAA,GAAK,QAAA,CAAS,cAAA,CAAe,cAAc,CAAA;AACjD,EAAA,OAAO,EAAA,YAAc,cAAc,EAAA,GAAK,MAAA;AACzC","file":"portal.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\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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var progress = require('@base-ui/react/progress');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var tailwindMerge = require('tailwind-merge');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
function Progress({ className, value, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsxRuntime.jsx(progress.Progress.Root, { "data-slot": "progress", value, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
14
|
+
progress.Progress.Track,
|
|
15
|
+
{
|
|
16
|
+
"data-slot": "progress-track",
|
|
17
|
+
className: cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full", className),
|
|
18
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
|
+
progress.Progress.Indicator,
|
|
20
|
+
{
|
|
21
|
+
"data-slot": "progress-indicator",
|
|
22
|
+
className: "bg-primary h-full transition-[width] duration-200 ease-out motion-reduce:transition-none"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
) });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.Progress = Progress;
|
|
30
|
+
//# sourceMappingURL=progress.cjs.map
|
|
31
|
+
//# sourceMappingURL=progress.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/components/progress.tsx"],"names":["twMerge","clsx","jsx","ProgressPrimitive"],"mappings":";;;;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACMA,SAAS,SAAS,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,OAAM,EAAkB;AAChE,EAAA,uBACCC,cAAA,CAACC,kBAAkB,IAAA,EAAlB,EAAuB,aAAU,UAAA,EAAW,KAAA,EAAe,GAAG,KAAA,EAC9D,QAAA,kBAAAD,cAAA;AAAA,IAACC,iBAAA,CAAkB,KAAA;AAAA,IAAlB;AAAA,MACA,WAAA,EAAU,gBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gEAAA,EAAkE,SAAS,CAAA;AAAA,MAEzF,QAAA,kBAAAD,cAAA;AAAA,QAACC,iBAAA,CAAkB,SAAA;AAAA,QAAlB;AAAA,UACA,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAU;AAAA;AAAA;AACX;AAAA,GACD,EACD,CAAA;AAEF","file":"progress.cjs","sourcesContent":["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 { Progress as ProgressPrimitive } from '@base-ui/react/progress';\n\nimport { cn } from '../lib/utils';\n\ntype ProgressProps = Omit<React.ComponentProps<typeof ProgressPrimitive.Root>, 'children'> & {\n\tclassName?: string;\n};\n\nfunction Progress({ className, value, ...props }: ProgressProps) {\n\treturn (\n\t\t<ProgressPrimitive.Root data-slot=\"progress\" value={value} {...props}>\n\t\t\t<ProgressPrimitive.Track\n\t\t\t\tdata-slot=\"progress-track\"\n\t\t\t\tclassName={cn('bg-primary/20 relative h-2 w-full overflow-hidden rounded-full', className)}\n\t\t\t>\n\t\t\t\t<ProgressPrimitive.Indicator\n\t\t\t\t\tdata-slot=\"progress-indicator\"\n\t\t\t\t\tclassName=\"bg-primary h-full transition-[width] duration-200 ease-out motion-reduce:transition-none\"\n\t\t\t\t/>\n\t\t\t</ProgressPrimitive.Track>\n\t\t</ProgressPrimitive.Root>\n\t);\n}\n\nexport { Progress };\nexport type { ProgressProps };\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
3
|
+
|
|
4
|
+
type ProgressProps = Omit<React.ComponentProps<typeof Progress$1.Root>, 'children'> & {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
declare function Progress({ className, value, ...props }: ProgressProps): React.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { Progress, type ProgressProps };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
4
3
|
|
|
5
4
|
type ProgressProps = Omit<React.ComponentProps<typeof Progress$1.Root>, 'children'> & {
|
|
6
5
|
className?: string;
|
|
7
6
|
};
|
|
8
|
-
declare function Progress({ className, value, ...props }: ProgressProps):
|
|
7
|
+
declare function Progress({ className, value, ...props }: ProgressProps): React.JSX.Element;
|
|
9
8
|
|
|
10
9
|
export { Progress, type ProgressProps };
|
|
@@ -17,8 +17,7 @@ function Progress({ className, value, ...props }) {
|
|
|
17
17
|
Progress$1.Indicator,
|
|
18
18
|
{
|
|
19
19
|
"data-slot": "progress-indicator",
|
|
20
|
-
className: "bg-primary h-full
|
|
21
|
-
style: { transform: `translateX(-${100 - (value || 0)}%)` }
|
|
20
|
+
className: "bg-primary h-full transition-[width] duration-200 ease-out motion-reduce:transition-none"
|
|
22
21
|
}
|
|
23
22
|
)
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts","../../src/components/progress.tsx"],"names":["ProgressPrimitive"],"mappings":";;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACMA,SAAS,SAAS,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,OAAM,EAAkB;AAChE,EAAA,uBACC,GAAA,CAACA,WAAkB,IAAA,EAAlB,EAAuB,aAAU,UAAA,EAAW,KAAA,EAAe,GAAG,KAAA,EAC9D,QAAA,kBAAA,GAAA;AAAA,IAACA,UAAA,CAAkB,KAAA;AAAA,IAAlB;AAAA,MACA,WAAA,EAAU,gBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gEAAA,EAAkE,SAAS,CAAA;AAAA,MAEzF,QAAA,kBAAA,GAAA;AAAA,QAACA,UAAA,CAAkB,SAAA;AAAA,QAAlB;AAAA,UACA,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAU
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/components/progress.tsx"],"names":["ProgressPrimitive"],"mappings":";;;;;AAGO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;ACMA,SAAS,SAAS,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,OAAM,EAAkB;AAChE,EAAA,uBACC,GAAA,CAACA,WAAkB,IAAA,EAAlB,EAAuB,aAAU,UAAA,EAAW,KAAA,EAAe,GAAG,KAAA,EAC9D,QAAA,kBAAA,GAAA;AAAA,IAACA,UAAA,CAAkB,KAAA;AAAA,IAAlB;AAAA,MACA,WAAA,EAAU,gBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gEAAA,EAAkE,SAAS,CAAA;AAAA,MAEzF,QAAA,kBAAA,GAAA;AAAA,QAACA,UAAA,CAAkB,SAAA;AAAA,QAAlB;AAAA,UACA,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAU;AAAA;AAAA;AACX;AAAA,GACD,EACD,CAAA;AAEF","file":"progress.js","sourcesContent":["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 { Progress as ProgressPrimitive } from '@base-ui/react/progress';\n\nimport { cn } from '../lib/utils';\n\ntype ProgressProps = Omit<React.ComponentProps<typeof ProgressPrimitive.Root>, 'children'> & {\n\tclassName?: string;\n};\n\nfunction Progress({ className, value, ...props }: ProgressProps) {\n\treturn (\n\t\t<ProgressPrimitive.Root data-slot=\"progress\" value={value} {...props}>\n\t\t\t<ProgressPrimitive.Track\n\t\t\t\tdata-slot=\"progress-track\"\n\t\t\t\tclassName={cn('bg-primary/20 relative h-2 w-full overflow-hidden rounded-full', className)}\n\t\t\t>\n\t\t\t\t<ProgressPrimitive.Indicator\n\t\t\t\t\tdata-slot=\"progress-indicator\"\n\t\t\t\t\tclassName=\"bg-primary h-full transition-[width] duration-200 ease-out motion-reduce:transition-none\"\n\t\t\t\t/>\n\t\t\t</ProgressPrimitive.Track>\n\t\t</ProgressPrimitive.Root>\n\t);\n}\n\nexport { Progress };\nexport type { ProgressProps };\n"]}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var tailwindMerge = require('tailwind-merge');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
function ProgressiveBlur({
|
|
13
|
+
className,
|
|
14
|
+
height = "24%",
|
|
15
|
+
position = "bottom",
|
|
16
|
+
blurPx = 8,
|
|
17
|
+
surface = "background",
|
|
18
|
+
intensity = 0.3,
|
|
19
|
+
insetX = "0"
|
|
20
|
+
}) {
|
|
21
|
+
const isBottom = position === "bottom";
|
|
22
|
+
const isTop = position === "top";
|
|
23
|
+
const clampedIntensity = Math.max(0, Math.min(1, intensity));
|
|
24
|
+
const surfaceVar = surface === "card" ? "--card" : surface === "sidebar" ? "--sidebar" : "--background";
|
|
25
|
+
const mask = isBottom ? "linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 75%, rgba(0,0,0,1) 100%)" : isTop ? "linear-gradient(to top, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 75%, rgba(0,0,0,1) 100%)" : "linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,1) 95%, rgba(0,0,0,0) 100%)";
|
|
26
|
+
const overlayMask = isBottom ? `linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,${clampedIntensity}) 55%, rgba(0,0,0,1) 85%, rgba(0,0,0,1) 100%)` : isTop ? `linear-gradient(to top, rgba(0,0,0,0) 0%, rgba(0,0,0,${clampedIntensity}) 55%, rgba(0,0,0,1) 85%, rgba(0,0,0,1) 100%)` : `linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,${clampedIntensity}) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,${clampedIntensity}) 75%, rgba(0,0,0,0) 100%)`;
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: cn(
|
|
31
|
+
"pointer-events-none absolute inset-x-0 z-10 overflow-hidden",
|
|
32
|
+
className,
|
|
33
|
+
isTop ? "top-0" : isBottom ? "bottom-0" : "inset-y-0"
|
|
34
|
+
),
|
|
35
|
+
style: {
|
|
36
|
+
height: position === "both" ? "100%" : height,
|
|
37
|
+
left: insetX,
|
|
38
|
+
right: insetX
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: "absolute inset-0",
|
|
45
|
+
style: {
|
|
46
|
+
backdropFilter: `blur(${blurPx}px)`,
|
|
47
|
+
WebkitBackdropFilter: `blur(${blurPx}px)`,
|
|
48
|
+
maskImage: mask,
|
|
49
|
+
WebkitMaskImage: mask
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: cn("absolute inset-0"),
|
|
57
|
+
style: {
|
|
58
|
+
backgroundColor: `var(${surfaceVar})`,
|
|
59
|
+
maskImage: overlayMask,
|
|
60
|
+
WebkitMaskImage: overlayMask
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function ProgressiveBlurScrollContainer({
|
|
69
|
+
children,
|
|
70
|
+
className,
|
|
71
|
+
scrollClassName,
|
|
72
|
+
minItemsForBlur = 0,
|
|
73
|
+
itemCount = 0,
|
|
74
|
+
blurProps,
|
|
75
|
+
showBlur = true
|
|
76
|
+
}) {
|
|
77
|
+
const [hasOverflow, setHasOverflow] = react.useState(false);
|
|
78
|
+
const [isScrolledFromTop, setIsScrolledFromTop] = react.useState(false);
|
|
79
|
+
const [isScrolledFromBottom, setIsScrolledFromBottom] = react.useState(true);
|
|
80
|
+
const scrollRef = react.useRef(null);
|
|
81
|
+
const checkScrollPosition = react.useCallback(() => {
|
|
82
|
+
if (scrollRef.current) {
|
|
83
|
+
const el = scrollRef.current;
|
|
84
|
+
const scrollTop = el.scrollTop;
|
|
85
|
+
const scrollHeight = el.scrollHeight;
|
|
86
|
+
const clientHeight = el.clientHeight;
|
|
87
|
+
setIsScrolledFromTop(scrollTop > 10);
|
|
88
|
+
setIsScrolledFromBottom(scrollTop + clientHeight < scrollHeight - 10);
|
|
89
|
+
}
|
|
90
|
+
}, []);
|
|
91
|
+
react.useEffect(() => {
|
|
92
|
+
const checkOverflow = () => {
|
|
93
|
+
if (scrollRef.current) {
|
|
94
|
+
const el = scrollRef.current;
|
|
95
|
+
setHasOverflow(el.scrollHeight > el.clientHeight);
|
|
96
|
+
checkScrollPosition();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
checkOverflow();
|
|
100
|
+
window.addEventListener("resize", checkOverflow);
|
|
101
|
+
return () => window.removeEventListener("resize", checkOverflow);
|
|
102
|
+
}, [children, checkScrollPosition]);
|
|
103
|
+
react.useEffect(() => {
|
|
104
|
+
const el = scrollRef.current;
|
|
105
|
+
if (!el) return;
|
|
106
|
+
el.addEventListener("scroll", checkScrollPosition, { passive: true });
|
|
107
|
+
return () => el.removeEventListener("scroll", checkScrollPosition);
|
|
108
|
+
}, [checkScrollPosition]);
|
|
109
|
+
const canShowBlur = showBlur && hasOverflow && (minItemsForBlur === 0 || itemCount > minItemsForBlur);
|
|
110
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative min-h-0 flex-1", className), children: [
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
ref: scrollRef,
|
|
115
|
+
className: cn("absolute inset-0 overflow-y-auto", scrollClassName),
|
|
116
|
+
children
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
canShowBlur && isScrolledFromTop && /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
+
ProgressiveBlur,
|
|
121
|
+
{
|
|
122
|
+
position: "top",
|
|
123
|
+
height: "48px",
|
|
124
|
+
surface: "background",
|
|
125
|
+
intensity: 0.2,
|
|
126
|
+
...blurProps
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
canShowBlur && isScrolledFromBottom && /* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
+
ProgressiveBlur,
|
|
131
|
+
{
|
|
132
|
+
position: "bottom",
|
|
133
|
+
height: "64px",
|
|
134
|
+
surface: "background",
|
|
135
|
+
intensity: 0.25,
|
|
136
|
+
...blurProps
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
exports.ProgressiveBlurScrollContainer = ProgressiveBlurScrollContainer;
|
|
143
|
+
//# sourceMappingURL=progressive-blur-scroll-container.cjs.map
|
|
144
|
+
//# sourceMappingURL=progressive-blur-scroll-container.cjs.map
|