@constructive-io/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert-dialog.d.ts +31 -0
- package/dist/components/alert-dialog.js +314 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +14 -0
- package/dist/components/alert.js +38 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/autocomplete.d.ts +28 -0
- package/dist/components/autocomplete.js +395 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/avatar.d.ts +13 -0
- package/dist/components/avatar.js +37 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +15 -0
- package/dist/components/badge.js +43 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +14 -0
- package/dist/components/breadcrumb.js +154 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +62 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar-rac.d.ts +13 -0
- package/dist/components/calendar-rac.js +82 -0
- package/dist/components/calendar-rac.js.map +1 -0
- package/dist/components/card.d.ts +19 -0
- package/dist/components/card.js +75 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +7 -0
- package/dist/components/checkbox-group.js +16 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.js +67 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/collapsible.d.ts +54 -0
- package/dist/components/collapsible.js +121 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/combobox.d.ts +44 -0
- package/dist/components/combobox.js +486 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +43 -0
- package/dist/components/command.js +690 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/dialog.d.ts +35 -0
- package/dist/components/dialog.js +440 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dock.d.ts +31 -0
- package/dist/components/dock.js +111 -0
- package/dist/components/dock.js.map +1 -0
- package/dist/components/drawer.d.ts +16 -0
- package/dist/components/drawer.js +147 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +50 -0
- package/dist/components/dropdown-menu.js +380 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/field.d.ts +51 -0
- package/dist/components/field.js +115 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/flickering-grid.d.ts +15 -0
- package/dist/components/flickering-grid.js +147 -0
- package/dist/components/flickering-grid.js.map +1 -0
- package/dist/components/form-control.d.ts +15 -0
- package/dist/components/form-control.js +173 -0
- package/dist/components/form-control.js.map +1 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/components/form.js +179 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/input-group.d.ts +18 -0
- package/dist/components/input-group.js +177 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +11 -0
- package/dist/components/input.js +60 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/json-input.d.ts +25 -0
- package/dist/components/json-input.js +351 -0
- package/dist/components/json-input.js.map +1 -0
- package/dist/components/label.d.ts +11 -0
- package/dist/components/label.js +27 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/motion-grid.d.ts +20 -0
- package/dist/components/motion-grid.js +81 -0
- package/dist/components/motion-grid.js.map +1 -0
- package/dist/components/multi-select.d.ts +198 -0
- package/dist/components/multi-select.js +882 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/page-header.d.ts +17 -0
- package/dist/components/page-header.js +17 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/pagination.d.ts +19 -0
- package/dist/components/pagination.js +144 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +35 -0
- package/dist/components/popover.js +188 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/portal.d.ts +108 -0
- package/dist/components/portal.js +75 -0
- package/dist/components/portal.js.map +1 -0
- package/dist/components/progress.d.ts +10 -0
- package/dist/components/progress.js +30 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/progressive-blur-scroll-container.d.ts +25 -0
- package/dist/components/progressive-blur-scroll-container.js +142 -0
- package/dist/components/progressive-blur-scroll-container.js.map +1 -0
- package/dist/components/progressive-blur.d.ts +16 -0
- package/dist/components/progressive-blur.js +68 -0
- package/dist/components/progressive-blur.js.map +1 -0
- package/dist/components/radio-group.d.ts +10 -0
- package/dist/components/radio-group.js +37 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/record-picker.d.ts +16 -0
- package/dist/components/record-picker.js +366 -0
- package/dist/components/record-picker.js.map +1 -0
- package/dist/components/resizable.d.ts +11 -0
- package/dist/components/resizable.js +52 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/responsive-diagram.d.ts +10 -0
- package/dist/components/responsive-diagram.js +63 -0
- package/dist/components/responsive-diagram.js.map +1 -0
- package/dist/components/scroll-area.d.ts +12 -0
- package/dist/components/scroll-area.js +69 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.d.ts +47 -0
- package/dist/components/select.js +287 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +11 -0
- package/dist/components/separator.js +24 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +112 -0
- package/dist/components/sheet.js +600 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +77 -0
- package/dist/components/sidebar.js +1217 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.d.ts +7 -0
- package/dist/components/skeleton.js +16 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/sonner.d.ts +10 -0
- package/dist/components/sonner.js +23 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/stack/index.d.ts +663 -0
- package/dist/components/stack/index.js +1418 -0
- package/dist/components/stack/index.js.map +1 -0
- package/dist/components/stepper.d.ts +30 -0
- package/dist/components/stepper.js +280 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +40 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +15 -0
- package/dist/components/table.js +65 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +10 -0
- package/dist/components/tabs.js +48 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tags.d.ts +42 -0
- package/dist/components/tags.js +728 -0
- package/dist/components/tags.js.map +1 -0
- package/dist/components/textarea.d.ts +10 -0
- package/dist/components/textarea.js +54 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast/index.d.ts +52 -0
- package/dist/components/toast/index.js +221 -0
- package/dist/components/toast/index.js.map +1 -0
- package/dist/components/tooltip.d.ts +29 -0
- package/dist/components/tooltip.js +174 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/unlink-button.d.ts +14 -0
- package/dist/components/unlink-button.js +91 -0
- package/dist/components/unlink-button.js.map +1 -0
- package/dist/index.cjs +7692 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2157 -0
- package/dist/index.d.ts +2157 -0
- package/dist/index.js +7375 -0
- package/dist/index.js.map +1 -0
- package/package.json +490 -0
- package/src/styles/globals.css +397 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
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';
|
|
7
|
+
|
|
8
|
+
var PORTAL_ROOT_ID = "portal-root";
|
|
9
|
+
var PortalContext = React2.createContext({
|
|
10
|
+
layer: "base",
|
|
11
|
+
depth: 0,
|
|
12
|
+
floatingPortalStrategy: "root",
|
|
13
|
+
floatingZIndex: "default"
|
|
14
|
+
});
|
|
15
|
+
function useRootPortalContainer() {
|
|
16
|
+
const [container, setContainer] = React2.useState(null);
|
|
17
|
+
React2.useLayoutEffect(() => {
|
|
18
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
19
|
+
setContainer(el);
|
|
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);
|
|
72
|
+
}
|
|
73
|
+
var Slot = React2.forwardRef((props, forwardedRef) => {
|
|
74
|
+
const { children, ...slotProps } = props;
|
|
75
|
+
if (isSlottable(children)) {
|
|
76
|
+
const childProps = children.props;
|
|
77
|
+
const childRef = childProps.ref;
|
|
78
|
+
return React2.cloneElement(children, {
|
|
79
|
+
...mergeProps(slotProps, childProps),
|
|
80
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
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 });
|
|
112
|
+
}
|
|
113
|
+
function cn(...inputs) {
|
|
114
|
+
return twMerge(clsx(inputs));
|
|
115
|
+
}
|
|
116
|
+
function Popover({ ...props }) {
|
|
117
|
+
return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
|
|
118
|
+
}
|
|
119
|
+
function PopoverTrigger({ asChild, nativeButton, children, ...props }) {
|
|
120
|
+
if (asChild && React2.isValidElement(children)) {
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
Popover$1.Trigger,
|
|
123
|
+
{
|
|
124
|
+
"data-slot": "popover-trigger",
|
|
125
|
+
nativeButton: nativeButton ?? true,
|
|
126
|
+
...props,
|
|
127
|
+
render: (triggerProps) => {
|
|
128
|
+
const { nativeButton: _, ...rest } = triggerProps;
|
|
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 });
|
|
138
|
+
}
|
|
139
|
+
function PopoverContent({
|
|
140
|
+
className,
|
|
141
|
+
align = "center",
|
|
142
|
+
sideOffset = 4,
|
|
143
|
+
showArrow = false,
|
|
144
|
+
side = "bottom",
|
|
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
|
+
) });
|
|
181
|
+
}
|
|
182
|
+
function PopoverAnchor({ ...props }) {
|
|
183
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "popover-anchor", ...props });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
|
|
187
|
+
//# sourceMappingURL=popover.js.map
|
|
188
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +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":";;;;;;AA4CO,IAAM,cAAA,GAAiB,aAAA;AAM9B,IAAM,gBAAsBA,MAAA,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;AAwEM,SAAS,sBAAA,GAA6C;AAC5D,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAUA,gBAA6B,IAAI,CAAA;AAEzE,EAAMA,uBAAgB,MAAM;AAC3B,IAAA,MAAM,EAAA,GAAK,QAAA,CAAS,cAAA,CAAe,cAAc,CAAA;AACjD,IAAA,YAAA,CAAa,EAAE,CAAA;AAAA,EAChB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,SAAA;AACR;AASO,SAAS,6BAAA,GAGd;AACD,EAAA,MAAM,gBAAgB,sBAAA,EAAuB;AAC7C,EAAA,MAAM,EAAE,sBAAA,EAAwB,cAAA,EAAe,GAAUA,kBAAW,aAAa,CAAA;AAEjF,EAAA,MAAM,SAAA,GAAY,sBAAA,KAA2B,QAAA,GAAW,MAAA,GAAa,aAAA,IAAiB,IAAA;AACtF,EAAA,MAAM,WAAA,GACL,cAAA,KAAmB,UAAA,GAChB,sCAAA,GACA,6BAAA;AAEJ,EAAA,OAAO,EAAE,WAAW,WAAA,EAAY;AACjC;ACvJA,SAAS,eAAkB,IAAA,EAA0D;AACpF,EAAA,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,EAAgB,eAAA;AAAA,EAChB,eAAA,EAAiB,gBAAA;AAAA,EACjB,GAAG;AACJ,CAAA,EAAwB;AACvB,EAAA,MAAM,EAAE,SAAA,EAAW,WAAA,EAAY,GAAI,6BAAA,EAA8B;AAEjE,EAAA,uBACCD,GAAAA,CAACC,SAAA,CAAiB,MAAA,EAAjB,EAAwB,WACxB,QAAA,kBAAAD,GAAAA;AAAA,IAACC,SAAA,CAAiB,UAAA;AAAA,IAAjB;AAAA,MACA,IAAA;AAAA,MACA,KAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA,EAAW,WAAA;AAAA,MAEX,QAAA,kBAAA,IAAA;AAAA,QAACA,SAAA,CAAiB,KAAA;AAAA,QAAjB;AAAA,UACA,WAAA,EAAU,iBAAA;AAAA,UACV,SAAA,EAAW,EAAA;AAAA,YACV,CAAA;AAAA;AAAA;AAAA;AAAA,8BAAA,CAAA;AAAA,YAKA;AAAA,WACD;AAAA,UACC,GAAG,KAAA;AAAA,UAEH,QAAA,EAAA;AAAA,YAAA,QAAA;AAAA,YACA,6BACAD,GAAAA,CAACC,UAAiB,KAAA,EAAjB,EAAuB,WAAU,yDAAA,EAA0D;AAAA;AAAA;AAAA;AAE9F;AAAA,GACD,EACD,CAAA;AAEF;AAOA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAyC;AAC1E,EAAA,uBAAOD,GAAAA,CAAC,KAAA,EAAA,EAAI,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACnD","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"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Overlay layer type:
|
|
6
|
+
* - 'base': Root level (page content, base floating elements)
|
|
7
|
+
* - 'modal': Inside a modal overlay (dialog, sheet, drawer)
|
|
8
|
+
*/
|
|
9
|
+
type OverlayLayer = 'base' | 'modal';
|
|
10
|
+
/**
|
|
11
|
+
* Where floating overlays should portal:
|
|
12
|
+
* - 'root': always portal into #portal-root
|
|
13
|
+
* - 'nested': let Base UI nest portals into the nearest Base UI portal node
|
|
14
|
+
*/
|
|
15
|
+
type FloatingPortalStrategy = 'root' | 'nested';
|
|
16
|
+
/**
|
|
17
|
+
* Z-index mode for floating overlays.
|
|
18
|
+
* - 'default': --z-layer-floating
|
|
19
|
+
* - 'elevated': --z-layer-floating-elevated
|
|
20
|
+
*/
|
|
21
|
+
type FloatingZIndex = 'default' | 'elevated';
|
|
22
|
+
interface PortalContextValue {
|
|
23
|
+
/** Current overlay layer */
|
|
24
|
+
layer: OverlayLayer;
|
|
25
|
+
/** Modal nesting depth (0 for first modal, 1 for nested, etc.) */
|
|
26
|
+
depth: number;
|
|
27
|
+
/** Strategy for where floating overlays should portal */
|
|
28
|
+
floatingPortalStrategy: FloatingPortalStrategy;
|
|
29
|
+
/** Z-index mode for floating overlays */
|
|
30
|
+
floatingZIndex: FloatingZIndex;
|
|
31
|
+
}
|
|
32
|
+
declare const PORTAL_ROOT_ID = "portal-root";
|
|
33
|
+
/**
|
|
34
|
+
* Provider for modal overlays (Dialog, Sheet, Drawer, etc.)
|
|
35
|
+
*
|
|
36
|
+
* Wraps modal content to:
|
|
37
|
+
* 1. Create a scoped portal container for nested floating elements
|
|
38
|
+
* 2. Track the overlay layer (so floating elements know to use elevated z-index)
|
|
39
|
+
* 3. Track nesting depth for stacked modals
|
|
40
|
+
*
|
|
41
|
+
* Usage:
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <DialogPopup>
|
|
44
|
+
* <ModalPortalScope>
|
|
45
|
+
* {children} // Popovers inside here will render in the scoped container
|
|
46
|
+
* </ModalPortalScope>
|
|
47
|
+
* </DialogPopup>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function ModalPortalScope({ children, floatingPortalStrategy, floatingZIndex, }: {
|
|
51
|
+
children: React.ReactNode;
|
|
52
|
+
floatingPortalStrategy?: FloatingPortalStrategy;
|
|
53
|
+
floatingZIndex?: FloatingZIndex;
|
|
54
|
+
}): react_jsx_runtime.JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Get the current portal context value.
|
|
57
|
+
* Used internally by other hooks.
|
|
58
|
+
*/
|
|
59
|
+
declare function usePortalContext(): PortalContextValue;
|
|
60
|
+
declare function useInModalOverlay(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get the root portal container element.
|
|
63
|
+
* Used by modal components (Dialog, Sheet, etc.) to render their portals.
|
|
64
|
+
*
|
|
65
|
+
* @returns The root portal container, or null during SSR/before mount
|
|
66
|
+
*/
|
|
67
|
+
declare function useRootPortalContainer(): HTMLElement | null;
|
|
68
|
+
/**
|
|
69
|
+
* Centralized portal + z-index policy for floating overlays.
|
|
70
|
+
*
|
|
71
|
+
* - When `floatingPortalStrategy` is 'nested', Base UI will automatically portal
|
|
72
|
+
* into the nearest Base UI portal node (so dialog "inert" behavior includes it).
|
|
73
|
+
* - When it's 'root', we portal into #portal-root.
|
|
74
|
+
*/
|
|
75
|
+
declare function useFloatingOverlayPortalProps(): {
|
|
76
|
+
container?: HTMLElement | null;
|
|
77
|
+
zIndexClass: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Portal root component to render in app layout.
|
|
81
|
+
* All overlay components will render their portals inside this container.
|
|
82
|
+
*
|
|
83
|
+
* Usage in layout.tsx:
|
|
84
|
+
* ```tsx
|
|
85
|
+
* import { PortalRoot } from '@constructive-io/ui/portal';
|
|
86
|
+
*
|
|
87
|
+
* export default function RootLayout({ children }) {
|
|
88
|
+
* return (
|
|
89
|
+
* <html>
|
|
90
|
+
* <body>
|
|
91
|
+
* {children}
|
|
92
|
+
* <PortalRoot />
|
|
93
|
+
* </body>
|
|
94
|
+
* </html>
|
|
95
|
+
* );
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function PortalRoot(): react_jsx_runtime.JSX.Element;
|
|
100
|
+
/**
|
|
101
|
+
* Hook to get the portal container element for rendering floating UI elements.
|
|
102
|
+
* Returns the element with id="portal-root" if it exists in the DOM.
|
|
103
|
+
*
|
|
104
|
+
* @deprecated Use useRootPortalContainer or useFloatingOverlayPortalProps instead
|
|
105
|
+
*/
|
|
106
|
+
declare function usePortalContainer(): HTMLElement | undefined;
|
|
107
|
+
|
|
108
|
+
export { type FloatingPortalStrategy, type FloatingZIndex, ModalPortalScope, type OverlayLayer, PORTAL_ROOT_ID, PortalRoot, useFloatingOverlayPortalProps, useInModalOverlay, usePortalContainer, usePortalContext, useRootPortalContainer };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var PORTAL_ROOT_ID = "portal-root";
|
|
6
|
+
var PortalContext = React.createContext({
|
|
7
|
+
layer: "base",
|
|
8
|
+
depth: 0,
|
|
9
|
+
floatingPortalStrategy: "root",
|
|
10
|
+
floatingZIndex: "default"
|
|
11
|
+
});
|
|
12
|
+
function ModalPortalScope({
|
|
13
|
+
children,
|
|
14
|
+
floatingPortalStrategy = "nested",
|
|
15
|
+
floatingZIndex = "default"
|
|
16
|
+
}) {
|
|
17
|
+
const parentContext = React.useContext(PortalContext);
|
|
18
|
+
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
19
|
+
const value = React.useMemo(
|
|
20
|
+
() => ({
|
|
21
|
+
layer: "modal",
|
|
22
|
+
depth,
|
|
23
|
+
floatingPortalStrategy,
|
|
24
|
+
floatingZIndex
|
|
25
|
+
}),
|
|
26
|
+
[depth, floatingPortalStrategy, floatingZIndex]
|
|
27
|
+
);
|
|
28
|
+
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
29
|
+
}
|
|
30
|
+
function usePortalContext() {
|
|
31
|
+
return React.useContext(PortalContext);
|
|
32
|
+
}
|
|
33
|
+
function useInModalOverlay() {
|
|
34
|
+
return React.useContext(PortalContext).layer === "modal";
|
|
35
|
+
}
|
|
36
|
+
function useRootPortalContainer() {
|
|
37
|
+
const [container, setContainer] = React.useState(null);
|
|
38
|
+
React.useLayoutEffect(() => {
|
|
39
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
40
|
+
setContainer(el);
|
|
41
|
+
}, []);
|
|
42
|
+
return container;
|
|
43
|
+
}
|
|
44
|
+
function useFloatingOverlayPortalProps() {
|
|
45
|
+
const rootContainer = useRootPortalContainer();
|
|
46
|
+
const { floatingPortalStrategy, floatingZIndex } = React.useContext(PortalContext);
|
|
47
|
+
const container = floatingPortalStrategy === "nested" ? void 0 : rootContainer ?? null;
|
|
48
|
+
const zIndexClass = floatingZIndex === "elevated" ? "z-[var(--z-layer-floating-elevated)]" : "z-[var(--z-layer-floating)]";
|
|
49
|
+
return { container, zIndexClass };
|
|
50
|
+
}
|
|
51
|
+
function PortalRoot() {
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
id: PORTAL_ROOT_ID,
|
|
56
|
+
"data-slot": "portal-root",
|
|
57
|
+
style: {
|
|
58
|
+
position: "fixed",
|
|
59
|
+
inset: 0,
|
|
60
|
+
zIndex: "var(--z-layer-portal-root)",
|
|
61
|
+
pointerEvents: "none"
|
|
62
|
+
// Children (portal contents) will have pointer-events: auto
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function usePortalContainer() {
|
|
68
|
+
if (typeof document === "undefined") return void 0;
|
|
69
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
70
|
+
return el instanceof HTMLElement ? el : void 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { ModalPortalScope, PORTAL_ROOT_ID, PortalRoot, useFloatingOverlayPortalProps, useInModalOverlay, usePortalContainer, usePortalContext, useRootPortalContainer };
|
|
74
|
+
//# sourceMappingURL=portal.js.map
|
|
75
|
+
//# sourceMappingURL=portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portal.tsx"],"names":[],"mappings":";;;AA4CO,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;AAClB,CAAA,EAIG;AACF,EAAA,MAAM,aAAA,GAAsB,i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,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}\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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
4
|
+
|
|
5
|
+
type ProgressProps = Omit<React.ComponentProps<typeof Progress$1.Root>, 'children'> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function Progress({ className, value, ...props }: ProgressProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { Progress, type ProgressProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
function Progress({ className, value, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Progress$1.Root, { "data-slot": "progress", value, ...props, children: /* @__PURE__ */ jsx(
|
|
12
|
+
Progress$1.Track,
|
|
13
|
+
{
|
|
14
|
+
"data-slot": "progress-track",
|
|
15
|
+
className: cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full", className),
|
|
16
|
+
children: /* @__PURE__ */ jsx(
|
|
17
|
+
Progress$1.Indicator,
|
|
18
|
+
{
|
|
19
|
+
"data-slot": "progress-indicator",
|
|
20
|
+
className: "bg-primary h-full w-full flex-1 transition-all",
|
|
21
|
+
style: { transform: `translateX(-${100 - (value || 0)}%)` }
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
) });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Progress };
|
|
29
|
+
//# sourceMappingURL=progress.js.map
|
|
30
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +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,gDAAA;AAAA,UACV,OAAO,EAAE,SAAA,EAAW,eAAe,GAAA,IAAO,KAAA,IAAS,EAAE,CAAA,EAAA,CAAA;AAAK;AAAA;AAC3D;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 w-full flex-1 transition-all\"\n\t\t\t\t\tstyle={{ transform: `translateX(-${100 - (value || 0)}%)` }}\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,25 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ProgressiveBlurProps } from './progressive-blur.js';
|
|
4
|
+
|
|
5
|
+
interface ProgressiveBlurScrollContainerProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Class name for the scrollable inner div */
|
|
9
|
+
scrollClassName?: string;
|
|
10
|
+
/** Minimum number of items to show blur (prevents blur on sparse content) */
|
|
11
|
+
minItemsForBlur?: number;
|
|
12
|
+
/** Current item count for minItemsForBlur check */
|
|
13
|
+
itemCount?: number;
|
|
14
|
+
/** Props to pass to ProgressiveBlur */
|
|
15
|
+
blurProps?: Partial<ProgressiveBlurProps>;
|
|
16
|
+
/** Whether to show blur (in addition to overflow check) */
|
|
17
|
+
showBlur?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A scrollable container that shows progressive blur effects at the top and bottom
|
|
21
|
+
* when content overflows. Top blur appears when scrolled, bottom blur when more content below.
|
|
22
|
+
*/
|
|
23
|
+
declare function ProgressiveBlurScrollContainer({ children, className, scrollClassName, minItemsForBlur, itemCount, blurProps, showBlur, }: ProgressiveBlurScrollContainerProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
25
|
+
export { ProgressiveBlurScrollContainer, type ProgressiveBlurScrollContainerProps };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
function ProgressiveBlur({
|
|
11
|
+
className,
|
|
12
|
+
height = "24%",
|
|
13
|
+
position = "bottom",
|
|
14
|
+
blurPx = 8,
|
|
15
|
+
surface = "background",
|
|
16
|
+
intensity = 0.3,
|
|
17
|
+
insetX = "0"
|
|
18
|
+
}) {
|
|
19
|
+
const isBottom = position === "bottom";
|
|
20
|
+
const isTop = position === "top";
|
|
21
|
+
const clampedIntensity = Math.max(0, Math.min(1, intensity));
|
|
22
|
+
const surfaceVar = surface === "card" ? "--card" : surface === "sidebar" ? "--sidebar" : "--background";
|
|
23
|
+
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%)";
|
|
24
|
+
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%)`;
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: cn(
|
|
29
|
+
"pointer-events-none absolute inset-x-0 z-10 overflow-hidden",
|
|
30
|
+
className,
|
|
31
|
+
isTop ? "top-0" : isBottom ? "bottom-0" : "inset-y-0"
|
|
32
|
+
),
|
|
33
|
+
style: {
|
|
34
|
+
height: position === "both" ? "100%" : height,
|
|
35
|
+
left: insetX,
|
|
36
|
+
right: insetX
|
|
37
|
+
},
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: "absolute inset-0",
|
|
43
|
+
style: {
|
|
44
|
+
backdropFilter: `blur(${blurPx}px)`,
|
|
45
|
+
WebkitBackdropFilter: `blur(${blurPx}px)`,
|
|
46
|
+
maskImage: mask,
|
|
47
|
+
WebkitMaskImage: mask
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
className: cn("absolute inset-0"),
|
|
55
|
+
style: {
|
|
56
|
+
backgroundColor: `var(${surfaceVar})`,
|
|
57
|
+
maskImage: overlayMask,
|
|
58
|
+
WebkitMaskImage: overlayMask
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function ProgressiveBlurScrollContainer({
|
|
67
|
+
children,
|
|
68
|
+
className,
|
|
69
|
+
scrollClassName,
|
|
70
|
+
minItemsForBlur = 0,
|
|
71
|
+
itemCount = 0,
|
|
72
|
+
blurProps,
|
|
73
|
+
showBlur = true
|
|
74
|
+
}) {
|
|
75
|
+
const [hasOverflow, setHasOverflow] = useState(false);
|
|
76
|
+
const [isScrolledFromTop, setIsScrolledFromTop] = useState(false);
|
|
77
|
+
const [isScrolledFromBottom, setIsScrolledFromBottom] = useState(true);
|
|
78
|
+
const scrollRef = useRef(null);
|
|
79
|
+
const checkScrollPosition = useCallback(() => {
|
|
80
|
+
if (scrollRef.current) {
|
|
81
|
+
const el = scrollRef.current;
|
|
82
|
+
const scrollTop = el.scrollTop;
|
|
83
|
+
const scrollHeight = el.scrollHeight;
|
|
84
|
+
const clientHeight = el.clientHeight;
|
|
85
|
+
setIsScrolledFromTop(scrollTop > 10);
|
|
86
|
+
setIsScrolledFromBottom(scrollTop + clientHeight < scrollHeight - 10);
|
|
87
|
+
}
|
|
88
|
+
}, []);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const checkOverflow = () => {
|
|
91
|
+
if (scrollRef.current) {
|
|
92
|
+
const el = scrollRef.current;
|
|
93
|
+
setHasOverflow(el.scrollHeight > el.clientHeight);
|
|
94
|
+
checkScrollPosition();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
checkOverflow();
|
|
98
|
+
window.addEventListener("resize", checkOverflow);
|
|
99
|
+
return () => window.removeEventListener("resize", checkOverflow);
|
|
100
|
+
}, [children, checkScrollPosition]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const el = scrollRef.current;
|
|
103
|
+
if (!el) return;
|
|
104
|
+
el.addEventListener("scroll", checkScrollPosition, { passive: true });
|
|
105
|
+
return () => el.removeEventListener("scroll", checkScrollPosition);
|
|
106
|
+
}, [checkScrollPosition]);
|
|
107
|
+
const canShowBlur = showBlur && hasOverflow && (minItemsForBlur === 0 || itemCount > minItemsForBlur);
|
|
108
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative min-h-0 flex-1", className), children: [
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
ref: scrollRef,
|
|
113
|
+
className: cn("absolute inset-0 overflow-y-auto", scrollClassName),
|
|
114
|
+
children
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
canShowBlur && isScrolledFromTop && /* @__PURE__ */ jsx(
|
|
118
|
+
ProgressiveBlur,
|
|
119
|
+
{
|
|
120
|
+
position: "top",
|
|
121
|
+
height: "48px",
|
|
122
|
+
surface: "background",
|
|
123
|
+
intensity: 0.2,
|
|
124
|
+
...blurProps
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
canShowBlur && isScrolledFromBottom && /* @__PURE__ */ jsx(
|
|
128
|
+
ProgressiveBlur,
|
|
129
|
+
{
|
|
130
|
+
position: "bottom",
|
|
131
|
+
height: "64px",
|
|
132
|
+
surface: "background",
|
|
133
|
+
intensity: 0.25,
|
|
134
|
+
...blurProps
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { ProgressiveBlurScrollContainer };
|
|
141
|
+
//# sourceMappingURL=progressive-blur-scroll-container.js.map
|
|
142
|
+
//# sourceMappingURL=progressive-blur-scroll-container.js.map
|