@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,600 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React3 from 'react';
|
|
3
|
+
import { Dialog } from '@base-ui/react/dialog';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { X } from 'lucide-react';
|
|
6
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
7
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
import { clsx } from 'clsx';
|
|
9
|
+
import { twMerge } from 'tailwind-merge';
|
|
10
|
+
|
|
11
|
+
// src/lib/motion/motion-config.ts
|
|
12
|
+
var easings = {
|
|
13
|
+
/** Physical feel for exit animations */
|
|
14
|
+
physicalExit: [0.4, 0, 0.6, 1]
|
|
15
|
+
};
|
|
16
|
+
var durations = {
|
|
17
|
+
/** Quick transitions (tooltips, small elements) */
|
|
18
|
+
fast: 0.15,
|
|
19
|
+
/** Standard UI transitions (modals, panels) */
|
|
20
|
+
normal: 0.2};
|
|
21
|
+
var PORTAL_ROOT_ID = "portal-root";
|
|
22
|
+
var PortalContext = React3.createContext({
|
|
23
|
+
layer: "base",
|
|
24
|
+
depth: 0,
|
|
25
|
+
floatingPortalStrategy: "root",
|
|
26
|
+
floatingZIndex: "default"
|
|
27
|
+
});
|
|
28
|
+
function ModalPortalScope({
|
|
29
|
+
children,
|
|
30
|
+
floatingPortalStrategy = "nested",
|
|
31
|
+
floatingZIndex = "default"
|
|
32
|
+
}) {
|
|
33
|
+
const parentContext = React3.useContext(PortalContext);
|
|
34
|
+
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
35
|
+
const value = React3.useMemo(
|
|
36
|
+
() => ({
|
|
37
|
+
layer: "modal",
|
|
38
|
+
depth,
|
|
39
|
+
floatingPortalStrategy,
|
|
40
|
+
floatingZIndex
|
|
41
|
+
}),
|
|
42
|
+
[depth, floatingPortalStrategy, floatingZIndex]
|
|
43
|
+
);
|
|
44
|
+
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
45
|
+
}
|
|
46
|
+
function useRootPortalContainer() {
|
|
47
|
+
const [container, setContainer] = React3.useState(null);
|
|
48
|
+
React3.useLayoutEffect(() => {
|
|
49
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
50
|
+
setContainer(el);
|
|
51
|
+
}, []);
|
|
52
|
+
return container;
|
|
53
|
+
}
|
|
54
|
+
function composeRefs(...refs) {
|
|
55
|
+
return (node) => {
|
|
56
|
+
refs.forEach((ref) => {
|
|
57
|
+
if (typeof ref === "function") {
|
|
58
|
+
ref(node);
|
|
59
|
+
} else if (ref != null) {
|
|
60
|
+
ref.current = node;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function mergeProps(slotProps, childProps) {
|
|
66
|
+
const overrideProps = { ...childProps };
|
|
67
|
+
for (const propName in childProps) {
|
|
68
|
+
if (propName === "ref") continue;
|
|
69
|
+
const slotPropValue = slotProps[propName];
|
|
70
|
+
const childPropValue = childProps[propName];
|
|
71
|
+
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
|
|
72
|
+
overrideProps[propName] = (...args) => {
|
|
73
|
+
childPropValue(...args);
|
|
74
|
+
slotPropValue(...args);
|
|
75
|
+
};
|
|
76
|
+
} else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
|
|
77
|
+
overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
78
|
+
} else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
|
|
79
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { ...slotProps, ...overrideProps };
|
|
83
|
+
}
|
|
84
|
+
function mergePropsWithRef(parentProps, childElement) {
|
|
85
|
+
const childProps = childElement.props;
|
|
86
|
+
const parentRef = parentProps.ref;
|
|
87
|
+
const childRef = childProps.ref;
|
|
88
|
+
const mergedProps = mergeProps(parentProps, childProps);
|
|
89
|
+
if (parentRef || childRef) {
|
|
90
|
+
mergedProps.ref = composeRefs(parentRef, childRef);
|
|
91
|
+
}
|
|
92
|
+
return mergedProps;
|
|
93
|
+
}
|
|
94
|
+
function isSlottable(child) {
|
|
95
|
+
return React3.isValidElement(child);
|
|
96
|
+
}
|
|
97
|
+
var Slot = React3.forwardRef((props, forwardedRef) => {
|
|
98
|
+
const { children, ...slotProps } = props;
|
|
99
|
+
if (isSlottable(children)) {
|
|
100
|
+
const childProps = children.props;
|
|
101
|
+
const childRef = childProps.ref;
|
|
102
|
+
return React3.cloneElement(children, {
|
|
103
|
+
...mergeProps(slotProps, childProps),
|
|
104
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (React3.Children.count(children) > 1) {
|
|
108
|
+
const childrenArray = React3.Children.toArray(children);
|
|
109
|
+
const slottableChild = childrenArray.find(
|
|
110
|
+
(child) => React3.isValidElement(child) && child.type === Slottable
|
|
111
|
+
);
|
|
112
|
+
if (slottableChild) {
|
|
113
|
+
const newElement = slottableChild.props.children;
|
|
114
|
+
if (isSlottable(newElement)) {
|
|
115
|
+
const newElementProps = newElement.props;
|
|
116
|
+
const newChildren = childrenArray.map((child) => {
|
|
117
|
+
if (child === slottableChild) {
|
|
118
|
+
return React3.Children.count(newElementProps.children) > 1 ? React3.Children.only(null) : newElementProps.children;
|
|
119
|
+
}
|
|
120
|
+
return child;
|
|
121
|
+
});
|
|
122
|
+
const childRef = newElementProps.ref;
|
|
123
|
+
return React3.cloneElement(newElement, {
|
|
124
|
+
...mergeProps(slotProps, newElementProps),
|
|
125
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
126
|
+
children: newChildren
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
132
|
+
});
|
|
133
|
+
Slot.displayName = "Slot";
|
|
134
|
+
function Slottable({ children }) {
|
|
135
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
136
|
+
}
|
|
137
|
+
function cn(...inputs) {
|
|
138
|
+
return twMerge(clsx(inputs));
|
|
139
|
+
}
|
|
140
|
+
var SheetStackContext = React3.createContext(void 0);
|
|
141
|
+
var SHEET_INDENT = 24;
|
|
142
|
+
function SheetStackProvider({ children, stackMode = "cascade" }) {
|
|
143
|
+
const [sheets, setSheets] = React3.useState([]);
|
|
144
|
+
const [sheetSizes, setSheetSizes] = React3.useState({});
|
|
145
|
+
const sheetsRef = React3.useRef([]);
|
|
146
|
+
sheetsRef.current = sheets;
|
|
147
|
+
const registerSheet = React3.useCallback((info) => {
|
|
148
|
+
setSheets((prev) => {
|
|
149
|
+
if (prev.some((s) => s.id === info.id)) return prev;
|
|
150
|
+
const newSheets = [...prev, info];
|
|
151
|
+
newSheets.sort((a, b) => a.depth - b.depth);
|
|
152
|
+
return newSheets;
|
|
153
|
+
});
|
|
154
|
+
}, []);
|
|
155
|
+
const unregisterSheet = React3.useCallback((id) => {
|
|
156
|
+
setSheets((prev) => prev.filter((s) => s.id !== id));
|
|
157
|
+
setSheetSizes((prev) => {
|
|
158
|
+
if (!prev[id]) return prev;
|
|
159
|
+
const next = { ...prev };
|
|
160
|
+
delete next[id];
|
|
161
|
+
return next;
|
|
162
|
+
});
|
|
163
|
+
}, []);
|
|
164
|
+
const setSheetSize = React3.useCallback((id, size) => {
|
|
165
|
+
setSheetSizes((prev) => {
|
|
166
|
+
const current = prev[id];
|
|
167
|
+
if (current && current.width === size.width && current.height === size.height) return prev;
|
|
168
|
+
return { ...prev, [id]: size };
|
|
169
|
+
});
|
|
170
|
+
}, []);
|
|
171
|
+
const getSheetSize = React3.useCallback((id) => sheetSizes[id], [sheetSizes]);
|
|
172
|
+
const isTopSheet = React3.useCallback((id) => {
|
|
173
|
+
const currentSheets = sheetsRef.current;
|
|
174
|
+
if (currentSheets.length === 0) return false;
|
|
175
|
+
return currentSheets[currentSheets.length - 1]?.id === id;
|
|
176
|
+
}, []);
|
|
177
|
+
const getSheetsAbove = React3.useCallback((id) => {
|
|
178
|
+
const currentSheets = sheetsRef.current;
|
|
179
|
+
const index = currentSheets.findIndex((s) => s.id === id);
|
|
180
|
+
if (index === -1) return 0;
|
|
181
|
+
return currentSheets.length - index - 1;
|
|
182
|
+
}, []);
|
|
183
|
+
React3.useEffect(() => {
|
|
184
|
+
const handleGlobalEscape = (event) => {
|
|
185
|
+
const currentSheets = sheetsRef.current;
|
|
186
|
+
if (event.key === "Escape" && currentSheets.length > 0) {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
event.stopPropagation();
|
|
189
|
+
const topSheet = currentSheets[currentSheets.length - 1];
|
|
190
|
+
topSheet?.close();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
document.addEventListener("keydown", handleGlobalEscape, true);
|
|
194
|
+
return () => document.removeEventListener("keydown", handleGlobalEscape, true);
|
|
195
|
+
}, []);
|
|
196
|
+
const value = React3.useMemo(
|
|
197
|
+
() => ({
|
|
198
|
+
sheets,
|
|
199
|
+
sheetSizes,
|
|
200
|
+
stackMode,
|
|
201
|
+
registerSheet,
|
|
202
|
+
unregisterSheet,
|
|
203
|
+
setSheetSize,
|
|
204
|
+
getSheetSize,
|
|
205
|
+
isTopSheet,
|
|
206
|
+
getSheetsAbove
|
|
207
|
+
}),
|
|
208
|
+
[sheets, sheetSizes, stackMode, registerSheet, unregisterSheet, setSheetSize, getSheetSize, isTopSheet, getSheetsAbove]
|
|
209
|
+
);
|
|
210
|
+
return /* @__PURE__ */ jsx(SheetStackContext.Provider, { value, children });
|
|
211
|
+
}
|
|
212
|
+
var useSheetStack = () => {
|
|
213
|
+
return React3.useContext(SheetStackContext);
|
|
214
|
+
};
|
|
215
|
+
var SheetNestingContext = React3.createContext({
|
|
216
|
+
level: 0,
|
|
217
|
+
parentSheetId: null
|
|
218
|
+
});
|
|
219
|
+
var useSheetNesting = () => React3.useContext(SheetNestingContext);
|
|
220
|
+
var SheetContext = React3.createContext(void 0);
|
|
221
|
+
var useSheet = () => {
|
|
222
|
+
const context = React3.useContext(SheetContext);
|
|
223
|
+
if (!context) {
|
|
224
|
+
throw new Error("useSheet must be used within a Sheet");
|
|
225
|
+
}
|
|
226
|
+
return context;
|
|
227
|
+
};
|
|
228
|
+
var sheetIdCounter = 0;
|
|
229
|
+
function Sheet({ children, sheetId: providedId, ...props }) {
|
|
230
|
+
const [isOpen, setIsOpen] = React3.useState(props?.open ?? props?.defaultOpen ?? false);
|
|
231
|
+
const sheetStack = useSheetStack();
|
|
232
|
+
const nesting = useSheetNesting();
|
|
233
|
+
const sheetIdRef = React3.useRef(providedId ?? `sheet-${++sheetIdCounter}`);
|
|
234
|
+
const sheetId = sheetIdRef.current;
|
|
235
|
+
const depth = nesting.level;
|
|
236
|
+
const onOpenChangeRef = React3.useRef(props.onOpenChange);
|
|
237
|
+
onOpenChangeRef.current = props.onOpenChange;
|
|
238
|
+
const close = React3.useCallback(() => {
|
|
239
|
+
setIsOpen(false);
|
|
240
|
+
onOpenChangeRef.current?.(false);
|
|
241
|
+
}, []);
|
|
242
|
+
const registerSheetRef = React3.useRef(sheetStack?.registerSheet);
|
|
243
|
+
const unregisterSheetRef = React3.useRef(sheetStack?.unregisterSheet);
|
|
244
|
+
registerSheetRef.current = sheetStack?.registerSheet;
|
|
245
|
+
unregisterSheetRef.current = sheetStack?.unregisterSheet;
|
|
246
|
+
React3.useEffect(() => {
|
|
247
|
+
if (registerSheetRef.current && isOpen) {
|
|
248
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
249
|
+
document.activeElement.blur();
|
|
250
|
+
}
|
|
251
|
+
registerSheetRef.current({ id: sheetId, depth, close });
|
|
252
|
+
return () => unregisterSheetRef.current?.(sheetId);
|
|
253
|
+
}
|
|
254
|
+
}, [isOpen, sheetId, depth, close]);
|
|
255
|
+
React3.useEffect(() => {
|
|
256
|
+
if (props?.open !== void 0) setIsOpen(props.open);
|
|
257
|
+
}, [props?.open]);
|
|
258
|
+
const handleOpenChange = React3.useCallback((open, _eventDetails) => {
|
|
259
|
+
setIsOpen(open);
|
|
260
|
+
onOpenChangeRef.current?.(open);
|
|
261
|
+
}, []);
|
|
262
|
+
const sheetsAbove = sheetStack?.getSheetsAbove(sheetId) ?? 0;
|
|
263
|
+
const isTopSheet = sheetStack?.isTopSheet(sheetId) ?? true;
|
|
264
|
+
const isNested = depth > 0;
|
|
265
|
+
return /* @__PURE__ */ jsx(SheetNestingContext.Provider, { value: { level: depth + 1, parentSheetId: sheetId }, children: /* @__PURE__ */ jsx(SheetContext.Provider, { value: { isOpen, sheetId, depth, sheetsAbove, isTopSheet, close }, children: /* @__PURE__ */ jsx(
|
|
266
|
+
Dialog.Root,
|
|
267
|
+
{
|
|
268
|
+
"data-slot": "sheet",
|
|
269
|
+
...props,
|
|
270
|
+
open: isOpen,
|
|
271
|
+
modal: isNested ? false : props.modal,
|
|
272
|
+
onOpenChange: handleOpenChange,
|
|
273
|
+
children
|
|
274
|
+
}
|
|
275
|
+
) }) });
|
|
276
|
+
}
|
|
277
|
+
function SheetTrigger({ asChild, nativeButton, children, ...props }) {
|
|
278
|
+
if (asChild && React3.isValidElement(children)) {
|
|
279
|
+
return /* @__PURE__ */ jsx(
|
|
280
|
+
Dialog.Trigger,
|
|
281
|
+
{
|
|
282
|
+
"data-slot": "sheet-trigger",
|
|
283
|
+
nativeButton: nativeButton ?? true,
|
|
284
|
+
...props,
|
|
285
|
+
render: (triggerProps) => {
|
|
286
|
+
const { nativeButton: _, ...rest } = triggerProps;
|
|
287
|
+
return React3.cloneElement(
|
|
288
|
+
children,
|
|
289
|
+
mergePropsWithRef(rest, children)
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, { "data-slot": "sheet-trigger", nativeButton, ...props, children });
|
|
296
|
+
}
|
|
297
|
+
function SheetClose({ asChild, nativeButton, children, ...props }) {
|
|
298
|
+
if (asChild && React3.isValidElement(children)) {
|
|
299
|
+
return /* @__PURE__ */ jsx(
|
|
300
|
+
Dialog.Close,
|
|
301
|
+
{
|
|
302
|
+
"data-slot": "sheet-close",
|
|
303
|
+
nativeButton: nativeButton ?? true,
|
|
304
|
+
...props,
|
|
305
|
+
render: (closeProps) => {
|
|
306
|
+
const { nativeButton: _, ...rest } = closeProps;
|
|
307
|
+
return React3.cloneElement(
|
|
308
|
+
children,
|
|
309
|
+
mergePropsWithRef(rest, children)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
return /* @__PURE__ */ jsx(Dialog.Close, { "data-slot": "sheet-close", nativeButton, ...props, children });
|
|
316
|
+
}
|
|
317
|
+
function SheetPortal({ forceMount: _forceMount, ...props }) {
|
|
318
|
+
const container = useRootPortalContainer();
|
|
319
|
+
const style = {
|
|
320
|
+
...props.style ?? {},
|
|
321
|
+
["--z-layer-floating"]: "var(--z-layer-floating-elevated)"
|
|
322
|
+
};
|
|
323
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, { "data-slot": "sheet-portal", container, ...props, style });
|
|
324
|
+
}
|
|
325
|
+
function SheetOverlay({ className, asChild: _asChild, forceMount: _forceMount, ...props }) {
|
|
326
|
+
return /* @__PURE__ */ jsx(
|
|
327
|
+
Dialog.Backdrop,
|
|
328
|
+
{
|
|
329
|
+
"data-slot": "sheet-overlay",
|
|
330
|
+
className: cn("fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/80", className),
|
|
331
|
+
...props
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
var sheetVariants = cva("fixed flex flex-col gap-3 bg-background p-4 shadow-lg", {
|
|
336
|
+
variants: {
|
|
337
|
+
side: {
|
|
338
|
+
top: "inset-x-0 top-0 border-b",
|
|
339
|
+
bottom: "inset-x-0 bottom-0 border-t",
|
|
340
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
|
|
341
|
+
right: "inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
defaultVariants: {
|
|
345
|
+
side: "right"
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
var NESTED_SHEET_WIDTH = 448;
|
|
349
|
+
var SHEET_STACK_GAP = 0;
|
|
350
|
+
function getPushOffset(side, sheetsAbove, stackMode = "cascade", collapseBaseSize = NESTED_SHEET_WIDTH) {
|
|
351
|
+
if (sheetsAbove === 0) {
|
|
352
|
+
return { x: 0, y: 0 };
|
|
353
|
+
}
|
|
354
|
+
if (stackMode === "collapse") {
|
|
355
|
+
const baseOffset = collapseBaseSize + SHEET_STACK_GAP;
|
|
356
|
+
const offset2 = baseOffset + (sheetsAbove - 1) * SHEET_INDENT;
|
|
357
|
+
switch (side) {
|
|
358
|
+
case "right":
|
|
359
|
+
return { x: -offset2 };
|
|
360
|
+
case "left":
|
|
361
|
+
return { x: offset2 };
|
|
362
|
+
case "top":
|
|
363
|
+
return { y: offset2 };
|
|
364
|
+
case "bottom":
|
|
365
|
+
return { y: -offset2 };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const offset = sheetsAbove * SHEET_INDENT;
|
|
369
|
+
switch (side) {
|
|
370
|
+
case "right":
|
|
371
|
+
return { x: -offset };
|
|
372
|
+
case "left":
|
|
373
|
+
return { x: offset };
|
|
374
|
+
case "top":
|
|
375
|
+
return { y: offset };
|
|
376
|
+
case "bottom":
|
|
377
|
+
return { y: -offset };
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function getInitialPosition(side) {
|
|
381
|
+
switch (side) {
|
|
382
|
+
case "right":
|
|
383
|
+
return { x: "100%" };
|
|
384
|
+
case "left":
|
|
385
|
+
return { x: "-100%" };
|
|
386
|
+
case "top":
|
|
387
|
+
return { y: "-100%" };
|
|
388
|
+
case "bottom":
|
|
389
|
+
return { y: "100%" };
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function getExitPosition(side) {
|
|
393
|
+
switch (side) {
|
|
394
|
+
case "right":
|
|
395
|
+
return { x: "100%" };
|
|
396
|
+
case "left":
|
|
397
|
+
return { x: "-100%" };
|
|
398
|
+
case "top":
|
|
399
|
+
return { y: "-100%" };
|
|
400
|
+
case "bottom":
|
|
401
|
+
return { y: "100%" };
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
var defaultSheetTransition = {
|
|
405
|
+
type: "tween",
|
|
406
|
+
duration: durations.normal,
|
|
407
|
+
ease: [0.32, 0.72, 0, 1]
|
|
408
|
+
// Custom ease-out for snappy feel
|
|
409
|
+
};
|
|
410
|
+
function SheetContent({
|
|
411
|
+
side = "right",
|
|
412
|
+
className,
|
|
413
|
+
transition = defaultSheetTransition,
|
|
414
|
+
overlay = true,
|
|
415
|
+
showClose = true,
|
|
416
|
+
children,
|
|
417
|
+
forceMount: _forceMount,
|
|
418
|
+
onInteractOutside: _onInteractOutside,
|
|
419
|
+
onPointerDownOutside: _onPointerDownOutside,
|
|
420
|
+
onEscapeKeyDown: _onEscapeKeyDown,
|
|
421
|
+
onFocusOutside: _onFocusOutside,
|
|
422
|
+
...props
|
|
423
|
+
}) {
|
|
424
|
+
const { isOpen, depth, sheetId, close } = useSheet();
|
|
425
|
+
const sheetStack = useSheetStack();
|
|
426
|
+
const sheetsAbove = sheetStack?.getSheetsAbove(sheetId) ?? 0;
|
|
427
|
+
const stackMode = sheetStack?.stackMode ?? "cascade";
|
|
428
|
+
const resolvedSide = side ?? "right";
|
|
429
|
+
const zIndex = `calc(var(--z-layer-modal-content) + ${depth * 10})`;
|
|
430
|
+
const topSheetId = sheetStack?.sheets[sheetStack.sheets.length - 1]?.id;
|
|
431
|
+
const topSheetSize = topSheetId ? sheetStack?.getSheetSize(topSheetId) : void 0;
|
|
432
|
+
const collapseBaseSize = topSheetSize ? resolvedSide === "left" || resolvedSide === "right" ? topSheetSize.width : topSheetSize.height : void 0;
|
|
433
|
+
const pushOffset = getPushOffset(resolvedSide, sheetsAbove, stackMode, collapseBaseSize ?? NESTED_SHEET_WIDTH);
|
|
434
|
+
const contentRef = React3.useRef(null);
|
|
435
|
+
React3.useLayoutEffect(() => {
|
|
436
|
+
if (!isOpen) return;
|
|
437
|
+
if (!sheetStack) return;
|
|
438
|
+
const el = contentRef.current;
|
|
439
|
+
if (!el) return;
|
|
440
|
+
let rafId = 0;
|
|
441
|
+
const update = () => {
|
|
442
|
+
const rect = el.getBoundingClientRect();
|
|
443
|
+
sheetStack.setSheetSize(sheetId, { width: rect.width, height: rect.height });
|
|
444
|
+
};
|
|
445
|
+
update();
|
|
446
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
447
|
+
const ro = new ResizeObserver(() => {
|
|
448
|
+
cancelAnimationFrame(rafId);
|
|
449
|
+
rafId = requestAnimationFrame(update);
|
|
450
|
+
});
|
|
451
|
+
ro.observe(el);
|
|
452
|
+
return () => {
|
|
453
|
+
cancelAnimationFrame(rafId);
|
|
454
|
+
ro.disconnect();
|
|
455
|
+
};
|
|
456
|
+
}, [isOpen, sheetId, sheetStack]);
|
|
457
|
+
const animatePosition = {
|
|
458
|
+
x: pushOffset.x ?? 0,
|
|
459
|
+
y: pushOffset.y ?? 0
|
|
460
|
+
};
|
|
461
|
+
const exitTransition = {
|
|
462
|
+
type: "tween",
|
|
463
|
+
duration: durations.normal,
|
|
464
|
+
ease: easings.physicalExit
|
|
465
|
+
};
|
|
466
|
+
const isTargetInsideSheet = React3.useCallback((target) => {
|
|
467
|
+
if (!target || !(target instanceof HTMLElement)) return false;
|
|
468
|
+
return !!target.closest('[data-slot="sheet-content"]');
|
|
469
|
+
}, []);
|
|
470
|
+
const isTargetInsidePopup = React3.useCallback((target) => {
|
|
471
|
+
if (!target || !(target instanceof HTMLElement)) return false;
|
|
472
|
+
return !!target.closest(
|
|
473
|
+
[
|
|
474
|
+
'[data-slot="select-popup"]',
|
|
475
|
+
'[data-slot="autocomplete-popup"]',
|
|
476
|
+
'[data-slot="dropdown-menu-content"]',
|
|
477
|
+
'[data-slot="dropdown-menu-sub-content"]',
|
|
478
|
+
'[data-slot="popover-content"]',
|
|
479
|
+
'[data-slot="tooltip-content"]'
|
|
480
|
+
].join(", ")
|
|
481
|
+
);
|
|
482
|
+
}, []);
|
|
483
|
+
React3.useEffect(() => {
|
|
484
|
+
if (!isOpen) return;
|
|
485
|
+
const handlePointerDown = (event) => {
|
|
486
|
+
if (sheetsAbove > 0) return;
|
|
487
|
+
const target = event.target;
|
|
488
|
+
if (isTargetInsideSheet(target) || isTargetInsidePopup(target)) return;
|
|
489
|
+
close();
|
|
490
|
+
};
|
|
491
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
492
|
+
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
493
|
+
}, [isOpen, sheetsAbove, isTargetInsideSheet, isTargetInsidePopup, close]);
|
|
494
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxs(SheetPortal, { "data-slot": "sheet-portal", children: [
|
|
495
|
+
overlay && depth === 0 && /* @__PURE__ */ jsx(
|
|
496
|
+
motion.div,
|
|
497
|
+
{
|
|
498
|
+
"data-slot": "sheet-overlay",
|
|
499
|
+
className: "fixed inset-0 bg-black/80",
|
|
500
|
+
initial: { opacity: 0 },
|
|
501
|
+
animate: { opacity: 1 },
|
|
502
|
+
exit: { opacity: 0 },
|
|
503
|
+
transition: { duration: durations.fast, ease: "easeOut" },
|
|
504
|
+
style: { willChange: "opacity", zIndex: "var(--z-layer-modal-backdrop)" }
|
|
505
|
+
},
|
|
506
|
+
"sheet-overlay"
|
|
507
|
+
),
|
|
508
|
+
/* @__PURE__ */ jsxs(
|
|
509
|
+
Dialog.Popup,
|
|
510
|
+
{
|
|
511
|
+
"data-slot": "sheet-content",
|
|
512
|
+
"data-sheet-depth": depth,
|
|
513
|
+
"data-sheet-id": sheetId,
|
|
514
|
+
...props,
|
|
515
|
+
render: /* @__PURE__ */ jsx(
|
|
516
|
+
motion.div,
|
|
517
|
+
{
|
|
518
|
+
ref: contentRef,
|
|
519
|
+
variants: {
|
|
520
|
+
initial: getInitialPosition(resolvedSide),
|
|
521
|
+
animate: animatePosition,
|
|
522
|
+
exit: {
|
|
523
|
+
...getExitPosition(resolvedSide),
|
|
524
|
+
transition: exitTransition
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
initial: "initial",
|
|
528
|
+
animate: "animate",
|
|
529
|
+
exit: "exit",
|
|
530
|
+
transition,
|
|
531
|
+
style: {
|
|
532
|
+
zIndex,
|
|
533
|
+
willChange: "transform"
|
|
534
|
+
},
|
|
535
|
+
className: cn(sheetVariants({ side: resolvedSide }), className)
|
|
536
|
+
},
|
|
537
|
+
`sheet-content-${sheetId}`
|
|
538
|
+
),
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ jsx(ModalPortalScope, { children }),
|
|
541
|
+
showClose && /* @__PURE__ */ jsxs(
|
|
542
|
+
Dialog.Close,
|
|
543
|
+
{
|
|
544
|
+
"data-slot": "sheet-close",
|
|
545
|
+
className: "ring-offset-background focus:ring-ring data-[open]:bg-secondary absolute top-4 right-4\n rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2\n focus:outline-none disabled:pointer-events-none",
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
|
|
548
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
)
|
|
555
|
+
] }) });
|
|
556
|
+
}
|
|
557
|
+
function SheetHeader({ className, ...props }) {
|
|
558
|
+
return /* @__PURE__ */ jsx(
|
|
559
|
+
"div",
|
|
560
|
+
{
|
|
561
|
+
"data-slot": "sheet-header",
|
|
562
|
+
className: cn("flex flex-col space-y-2 pb-4 text-center sm:text-left", className),
|
|
563
|
+
...props
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
function SheetFooter({ className, ...props }) {
|
|
568
|
+
return /* @__PURE__ */ jsx(
|
|
569
|
+
"div",
|
|
570
|
+
{
|
|
571
|
+
"data-slot": "sheet-footer",
|
|
572
|
+
className: cn("flex flex-col-reverse pt-4 sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
573
|
+
...props
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
function SheetTitle({ className, ...props }) {
|
|
578
|
+
return /* @__PURE__ */ jsx(
|
|
579
|
+
Dialog.Title,
|
|
580
|
+
{
|
|
581
|
+
"data-slot": "sheet-title",
|
|
582
|
+
className: cn("text-foreground text-lg font-semibold", className),
|
|
583
|
+
...props
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
function SheetDescription({ className, ...props }) {
|
|
588
|
+
return /* @__PURE__ */ jsx(
|
|
589
|
+
Dialog.Description,
|
|
590
|
+
{
|
|
591
|
+
"data-slot": "sheet-description",
|
|
592
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
593
|
+
...props
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export { SHEET_INDENT, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetStackProvider, SheetTitle, SheetTrigger, useSheet, useSheetStack };
|
|
599
|
+
//# sourceMappingURL=sheet.js.map
|
|
600
|
+
//# sourceMappingURL=sheet.js.map
|