@stevederico/skateboard-ui 3.0.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.jsx +13 -13
- package/CHANGELOG.md +64 -0
- package/README.md +59 -65
- package/components/AuthOverlay.jsx +4 -4
- package/components/ProtectedRoute.jsx +1 -1
- package/components/ThemeToggle.jsx +1 -1
- package/components/UpgradeSheet.jsx +2 -2
- package/{core → components/core}/DynamicIcon.jsx +1 -1
- package/{layout → components/layout}/Header.jsx +4 -4
- package/{layout → components/layout}/Layout.jsx +1 -1
- package/{layout → components/layout}/Sidebar.jsx +2 -2
- package/{layout → components/layout}/TabBar.jsx +1 -1
- package/{views → components/views}/LandingView.jsx +5 -5
- package/{views → components/views}/NotFound.jsx +2 -2
- package/{views → components/views}/PaymentView.jsx +1 -1
- package/{views → components/views}/SettingsView.jsx +6 -6
- package/{views → components/views}/SignInView.jsx +6 -6
- package/{views → components/views}/SignOutView.jsx +1 -1
- package/{views → components/views}/SignUpView.jsx +6 -6
- package/{views → components/views}/TextView.jsx +3 -3
- package/hooks/useAuthGate.js +1 -1
- package/index.js +1 -1
- package/package.json +32 -50
- package/shadcn/lib/base-ui/LICENSE +21 -0
- package/shadcn/lib/base-ui/_chunk-01rqe37g.js +70 -0
- package/shadcn/lib/base-ui/_chunk-0h5sskyw.js +347 -0
- package/shadcn/lib/base-ui/_chunk-0xhx4g7r.js +57 -0
- package/shadcn/lib/base-ui/_chunk-1e6khrvm.js +218 -0
- package/shadcn/lib/base-ui/_chunk-1s41sngz.js +302 -0
- package/shadcn/lib/base-ui/_chunk-20rtfsz9.js +23 -0
- package/shadcn/lib/base-ui/_chunk-2tyt8f8r.js +6034 -0
- package/shadcn/lib/base-ui/_chunk-3f31ka8n.js +11 -0
- package/shadcn/lib/base-ui/_chunk-3h6zpchb.js +89 -0
- package/shadcn/lib/base-ui/_chunk-4s0k3h7t.js +114 -0
- package/shadcn/lib/base-ui/_chunk-502wngfc.js +598 -0
- package/shadcn/lib/base-ui/_chunk-536jvgeq.js +68 -0
- package/shadcn/lib/base-ui/_chunk-611pz5sm.js +10 -0
- package/shadcn/lib/base-ui/_chunk-65zw5gs2.js +15 -0
- package/shadcn/lib/base-ui/_chunk-6b17g8t7.js +34 -0
- package/shadcn/lib/base-ui/_chunk-6xevjepc.js +15 -0
- package/shadcn/lib/base-ui/_chunk-71zm6zgv.js +16 -0
- package/shadcn/lib/base-ui/_chunk-7fmjymvh.js +32 -0
- package/shadcn/lib/base-ui/_chunk-7jjzay8b.js +176 -0
- package/shadcn/lib/base-ui/_chunk-7v1t86x1.js +43 -0
- package/shadcn/lib/base-ui/_chunk-85vrgzwr.js +227 -0
- package/shadcn/lib/base-ui/_chunk-8jz3hb7q.js +9 -0
- package/shadcn/lib/base-ui/_chunk-8kh3xk78.js +35 -0
- package/shadcn/lib/base-ui/_chunk-97tas84n.js +67 -0
- package/shadcn/lib/base-ui/_chunk-9nyxkvte.js +13 -0
- package/shadcn/lib/base-ui/_chunk-a8fwg9d0.js +52 -0
- package/shadcn/lib/base-ui/_chunk-agc6ew3g.js +29 -0
- package/shadcn/lib/base-ui/_chunk-aqwsk46c.js +64 -0
- package/shadcn/lib/base-ui/_chunk-atd5kq5q.js +803 -0
- package/shadcn/lib/base-ui/_chunk-atnkefgd.js +104 -0
- package/shadcn/lib/base-ui/_chunk-b40erthe.js +7 -0
- package/shadcn/lib/base-ui/_chunk-b5jsqt97.js +50 -0
- package/shadcn/lib/base-ui/_chunk-bk7n9s9e.js +15 -0
- package/shadcn/lib/base-ui/_chunk-c3572b5x.js +19 -0
- package/shadcn/lib/base-ui/_chunk-cwr896nf.js +25 -0
- package/shadcn/lib/base-ui/_chunk-drfb9kp2.js +27 -0
- package/shadcn/lib/base-ui/_chunk-ds8fnpjj.js +0 -0
- package/shadcn/lib/base-ui/_chunk-ek863ta9.js +82 -0
- package/shadcn/lib/base-ui/_chunk-f09cp81f.js +12 -0
- package/shadcn/lib/base-ui/_chunk-f5d01bp9.js +0 -0
- package/shadcn/lib/base-ui/_chunk-f9tgee1q.js +21 -0
- package/shadcn/lib/base-ui/_chunk-fch5cba8.js +84 -0
- package/shadcn/lib/base-ui/_chunk-gfce3j3z.js +18 -0
- package/shadcn/lib/base-ui/_chunk-ha06w2pp.js +2391 -0
- package/shadcn/lib/base-ui/_chunk-hzgetm70.js +23 -0
- package/shadcn/lib/base-ui/_chunk-j0eqdjta.js +39 -0
- package/shadcn/lib/base-ui/_chunk-k1e5fvcj.js +48 -0
- package/shadcn/lib/base-ui/_chunk-k4mc2kan.js +81 -0
- package/shadcn/lib/base-ui/_chunk-kfz96xv1.js +128 -0
- package/shadcn/lib/base-ui/_chunk-m45547cc.js +15 -0
- package/shadcn/lib/base-ui/_chunk-mbn76q14.js +184 -0
- package/shadcn/lib/base-ui/_chunk-mvv30fkv.js +9 -0
- package/shadcn/lib/base-ui/_chunk-mznt6ktj.js +33 -0
- package/shadcn/lib/base-ui/_chunk-n7dnqnbw.js +7 -0
- package/shadcn/lib/base-ui/_chunk-nya71ccw.js +546 -0
- package/shadcn/lib/base-ui/_chunk-p6qynd6r.js +146 -0
- package/shadcn/lib/base-ui/_chunk-q3nee19r.js +323 -0
- package/shadcn/lib/base-ui/_chunk-q7yw9mz4.js +385 -0
- package/shadcn/lib/base-ui/_chunk-qce0xt57.js +107 -0
- package/shadcn/lib/base-ui/_chunk-qgzhcjsj.js +14 -0
- package/shadcn/lib/base-ui/_chunk-qt6r015s.js +38 -0
- package/shadcn/lib/base-ui/_chunk-r0vsdknk.js +4 -0
- package/shadcn/lib/base-ui/_chunk-sx6vkz01.js +150 -0
- package/shadcn/lib/base-ui/_chunk-szcr6mhk.js +6 -0
- package/shadcn/lib/base-ui/_chunk-t7j3rbpv.js +67 -0
- package/shadcn/lib/base-ui/_chunk-tmfmrzwe.js +39 -0
- package/shadcn/lib/base-ui/_chunk-v92ycsfj.js +9 -0
- package/shadcn/lib/base-ui/_chunk-vdc01ss3.js +6 -0
- package/shadcn/lib/base-ui/_chunk-vjbnhhg1.js +26 -0
- package/shadcn/lib/base-ui/_chunk-w68yxg9d.js +21 -0
- package/shadcn/lib/base-ui/_chunk-wana68v3.js +477 -0
- package/shadcn/lib/base-ui/_chunk-wtw745qd.js +12 -0
- package/shadcn/lib/base-ui/_chunk-xb7ph1ka.js +6 -0
- package/shadcn/lib/base-ui/_chunk-xfagb0fq.js +28 -0
- package/shadcn/lib/base-ui/_chunk-xxhqanfd.js +16 -0
- package/shadcn/lib/base-ui/_chunk-y887e46p.js +15 -0
- package/shadcn/lib/base-ui/_chunk-ymj1dpqg.js +14 -0
- package/shadcn/lib/base-ui/accordion.js +650 -0
- package/shadcn/lib/base-ui/alert-dialog.js +138 -0
- package/shadcn/lib/base-ui/avatar.js +235 -0
- package/shadcn/lib/base-ui/button.js +52 -0
- package/shadcn/lib/base-ui/checkbox.js +454 -0
- package/shadcn/lib/base-ui/collapsible.js +283 -0
- package/shadcn/lib/base-ui/context-menu.js +324 -0
- package/shadcn/lib/base-ui/dialog.js +71 -0
- package/shadcn/lib/base-ui/input.js +1028 -0
- package/shadcn/lib/base-ui/menu.js +61 -0
- package/shadcn/lib/base-ui/menubar.js +157 -0
- package/shadcn/lib/base-ui/merge-props.js +15 -0
- package/shadcn/lib/base-ui/navigation-menu.js +1854 -0
- package/shadcn/lib/base-ui/popover.js +1090 -0
- package/shadcn/lib/base-ui/preview-card.js +709 -0
- package/shadcn/lib/base-ui/progress.js +278 -0
- package/shadcn/lib/base-ui/radio-group.js +247 -0
- package/shadcn/lib/base-ui/radio.js +382 -0
- package/shadcn/lib/base-ui/scroll-area.js +1061 -0
- package/shadcn/lib/base-ui/select.js +2438 -0
- package/shadcn/lib/base-ui/separator.js +11 -0
- package/shadcn/lib/base-ui/slider.js +1595 -0
- package/shadcn/lib/base-ui/switch.js +333 -0
- package/shadcn/lib/base-ui/tabs.js +892 -0
- package/shadcn/lib/base-ui/toggle-group.js +152 -0
- package/shadcn/lib/base-ui/toggle.js +133 -0
- package/shadcn/lib/base-ui/tooltip.js +791 -0
- package/shadcn/lib/base-ui/use-render.js +15 -0
- package/shadcn/lib/tailwind-merge.js +3312 -0
- package/shadcn/lib/utils.js +1 -1
- package/shadcn/ui/accordion.jsx +1 -1
- package/shadcn/ui/alert-dialog.jsx +1 -1
- package/shadcn/ui/avatar.jsx +1 -1
- package/shadcn/ui/badge.jsx +2 -2
- package/shadcn/ui/breadcrumb.jsx +2 -2
- package/shadcn/ui/button-group.jsx +2 -2
- package/shadcn/ui/button.jsx +1 -1
- package/shadcn/ui/calendar.jsx +1 -1
- package/shadcn/ui/checkbox.jsx +1 -1
- package/shadcn/ui/collapsible.jsx +1 -1
- package/shadcn/ui/command.jsx +1 -1
- package/shadcn/ui/context-menu.jsx +1 -1
- package/shadcn/ui/dialog.jsx +1 -1
- package/shadcn/ui/drawer.jsx +176 -74
- package/shadcn/ui/dropdown-menu.jsx +1 -1
- package/shadcn/ui/hover-card.jsx +1 -1
- package/shadcn/ui/input.jsx +1 -1
- package/shadcn/ui/item.jsx +2 -2
- package/shadcn/ui/menubar.jsx +2 -2
- package/shadcn/ui/navigation-menu.jsx +1 -1
- package/shadcn/ui/popover.jsx +1 -1
- package/shadcn/ui/progress.jsx +1 -1
- package/shadcn/ui/radio-group.jsx +2 -2
- package/shadcn/ui/scroll-area.jsx +1 -1
- package/shadcn/ui/select.jsx +1 -1
- package/shadcn/ui/separator.jsx +1 -1
- package/shadcn/ui/sheet.jsx +1 -1
- package/shadcn/ui/sidebar.jsx +3 -3
- package/shadcn/ui/slider.jsx +1 -1
- package/shadcn/ui/switch.jsx +1 -1
- package/shadcn/ui/tabs.jsx +1 -1
- package/shadcn/ui/toggle-group.jsx +2 -2
- package/shadcn/ui/toggle.jsx +1 -1
- package/shadcn/ui/tooltip.jsx +1 -1
- package/styles.css +31 -0
- package/MIGRATION.md +0 -230
- package/shadcn/ui/carousel.jsx +0 -195
- package/shadcn/ui/chart.jsx +0 -312
- package/shadcn/ui/resizable.jsx +0 -47
- /package/{core → components/core}/Calendar.jsx +0 -0
- /package/{core → components/core}/Command.jsx +0 -0
- /package/{core → components/core}/Context.jsx +0 -0
- /package/{core → components/core}/ThemeProvider.jsx +0 -0
- /package/{core → components/core}/Utilities.js +0 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ownerDocument
|
|
3
|
+
} from "./_chunk-xb7ph1ka.js";
|
|
4
|
+
import {
|
|
5
|
+
isIOS,
|
|
6
|
+
isWebKit
|
|
7
|
+
} from "./_chunk-t7j3rbpv.js";
|
|
8
|
+
import {
|
|
9
|
+
Timeout
|
|
10
|
+
} from "./_chunk-7v1t86x1.js";
|
|
11
|
+
import {
|
|
12
|
+
useValueChanged
|
|
13
|
+
} from "./_chunk-cwr896nf.js";
|
|
14
|
+
import {
|
|
15
|
+
addEventListener
|
|
16
|
+
} from "./_chunk-mvv30fkv.js";
|
|
17
|
+
import {
|
|
18
|
+
AnimationFrame
|
|
19
|
+
} from "./_chunk-3h6zpchb.js";
|
|
20
|
+
import {
|
|
21
|
+
getWindow,
|
|
22
|
+
isOverflowElement
|
|
23
|
+
} from "./_chunk-sx6vkz01.js";
|
|
24
|
+
import {
|
|
25
|
+
useStableCallback
|
|
26
|
+
} from "./_chunk-mznt6ktj.js";
|
|
27
|
+
import {
|
|
28
|
+
useIsoLayoutEffect
|
|
29
|
+
} from "./_chunk-b40erthe.js";
|
|
30
|
+
import {
|
|
31
|
+
NOOP
|
|
32
|
+
} from "./_chunk-1s41sngz.js";
|
|
33
|
+
|
|
34
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
|
|
35
|
+
import * as React2 from "react";
|
|
36
|
+
|
|
37
|
+
// node_modules/.deno/@base-ui+utils@0.2.8/node_modules/@base-ui/utils/esm/useEnhancedClickHandler.js
|
|
38
|
+
import * as React from "react";
|
|
39
|
+
"use client";
|
|
40
|
+
function useEnhancedClickHandler(handler) {
|
|
41
|
+
const lastClickInteractionTypeRef = React.useRef("");
|
|
42
|
+
const handlePointerDown = React.useCallback((event) => {
|
|
43
|
+
if (event.defaultPrevented) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
lastClickInteractionTypeRef.current = event.pointerType;
|
|
47
|
+
handler(event, event.pointerType);
|
|
48
|
+
}, [handler]);
|
|
49
|
+
const handleClick = React.useCallback((event) => {
|
|
50
|
+
if (event.detail === 0) {
|
|
51
|
+
handler(event, "keyboard");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if ("pointerType" in event) {
|
|
55
|
+
handler(event, event.pointerType);
|
|
56
|
+
} else {
|
|
57
|
+
handler(event, lastClickInteractionTypeRef.current);
|
|
58
|
+
}
|
|
59
|
+
lastClickInteractionTypeRef.current = "";
|
|
60
|
+
}, [handler]);
|
|
61
|
+
return {
|
|
62
|
+
onClick: handleClick,
|
|
63
|
+
onPointerDown: handlePointerDown
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
|
|
68
|
+
"use client";
|
|
69
|
+
function useOpenInteractionType(open) {
|
|
70
|
+
const [openMethod, setOpenMethod] = React2.useState(null);
|
|
71
|
+
const handleTriggerClick = useStableCallback((_, interactionType) => {
|
|
72
|
+
if (!open) {
|
|
73
|
+
setOpenMethod(interactionType || (isIOS ? "touch" : ""));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
useValueChanged(open, (previousOpen) => {
|
|
77
|
+
if (previousOpen && !open) {
|
|
78
|
+
setOpenMethod(null);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const {
|
|
82
|
+
onClick,
|
|
83
|
+
onPointerDown
|
|
84
|
+
} = useEnhancedClickHandler(handleTriggerClick);
|
|
85
|
+
return React2.useMemo(() => ({
|
|
86
|
+
openMethod,
|
|
87
|
+
triggerProps: {
|
|
88
|
+
onClick,
|
|
89
|
+
onPointerDown
|
|
90
|
+
}
|
|
91
|
+
}), [openMethod, onClick, onPointerDown]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/InternalBackdrop.js
|
|
95
|
+
import * as React3 from "react";
|
|
96
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
97
|
+
var InternalBackdrop = /* @__PURE__ */ React3.forwardRef(function InternalBackdrop2(props, ref) {
|
|
98
|
+
const {
|
|
99
|
+
cutout,
|
|
100
|
+
...otherProps
|
|
101
|
+
} = props;
|
|
102
|
+
let clipPath;
|
|
103
|
+
if (cutout) {
|
|
104
|
+
const rect = cutout.getBoundingClientRect();
|
|
105
|
+
clipPath = `polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${rect.left}px ${rect.top}px,${rect.left}px ${rect.bottom}px,${rect.right}px ${rect.bottom}px,${rect.right}px ${rect.top}px,${rect.left}px ${rect.top}px)`;
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
108
|
+
ref,
|
|
109
|
+
role: "presentation",
|
|
110
|
+
"data-base-ui-inert": "",
|
|
111
|
+
...otherProps,
|
|
112
|
+
style: {
|
|
113
|
+
position: "fixed",
|
|
114
|
+
inset: 0,
|
|
115
|
+
userSelect: "none",
|
|
116
|
+
WebkitUserSelect: "none",
|
|
117
|
+
clipPath
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
if (true)
|
|
122
|
+
InternalBackdrop.displayName = "InternalBackdrop";
|
|
123
|
+
|
|
124
|
+
// node_modules/.deno/@base-ui+utils@0.2.8/node_modules/@base-ui/utils/esm/useScrollLock.js
|
|
125
|
+
"use client";
|
|
126
|
+
var originalHtmlStyles = {};
|
|
127
|
+
var originalBodyStyles = {};
|
|
128
|
+
var originalHtmlScrollBehavior = "";
|
|
129
|
+
function hasInsetScrollbars(referenceElement) {
|
|
130
|
+
if (typeof document === "undefined") {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const doc = ownerDocument(referenceElement);
|
|
134
|
+
const win = getWindow(doc);
|
|
135
|
+
return win.innerWidth - doc.documentElement.clientWidth > 0;
|
|
136
|
+
}
|
|
137
|
+
function supportsStableScrollbarGutter(referenceElement) {
|
|
138
|
+
const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
|
|
139
|
+
if (!supported || typeof document === "undefined") {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const doc = ownerDocument(referenceElement);
|
|
143
|
+
const html = doc.documentElement;
|
|
144
|
+
const body = doc.body;
|
|
145
|
+
const scrollContainer = isOverflowElement(html) ? html : body;
|
|
146
|
+
const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
|
|
147
|
+
const originalHtmlStyleGutter = html.style.scrollbarGutter;
|
|
148
|
+
html.style.scrollbarGutter = "stable";
|
|
149
|
+
scrollContainer.style.overflowY = "scroll";
|
|
150
|
+
const before = scrollContainer.offsetWidth;
|
|
151
|
+
scrollContainer.style.overflowY = "hidden";
|
|
152
|
+
const after = scrollContainer.offsetWidth;
|
|
153
|
+
scrollContainer.style.overflowY = originalScrollContainerOverflowY;
|
|
154
|
+
html.style.scrollbarGutter = originalHtmlStyleGutter;
|
|
155
|
+
return before === after;
|
|
156
|
+
}
|
|
157
|
+
function preventScrollOverlayScrollbars(referenceElement) {
|
|
158
|
+
const doc = ownerDocument(referenceElement);
|
|
159
|
+
const html = doc.documentElement;
|
|
160
|
+
const body = doc.body;
|
|
161
|
+
const elementToLock = isOverflowElement(html) ? html : body;
|
|
162
|
+
const originalElementToLockStyles = {
|
|
163
|
+
overflowY: elementToLock.style.overflowY,
|
|
164
|
+
overflowX: elementToLock.style.overflowX
|
|
165
|
+
};
|
|
166
|
+
Object.assign(elementToLock.style, {
|
|
167
|
+
overflowY: "hidden",
|
|
168
|
+
overflowX: "hidden"
|
|
169
|
+
});
|
|
170
|
+
return () => {
|
|
171
|
+
Object.assign(elementToLock.style, originalElementToLockStyles);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function preventScrollInsetScrollbars(referenceElement) {
|
|
175
|
+
const doc = ownerDocument(referenceElement);
|
|
176
|
+
const html = doc.documentElement;
|
|
177
|
+
const body = doc.body;
|
|
178
|
+
const win = getWindow(html);
|
|
179
|
+
let scrollTop = 0;
|
|
180
|
+
let scrollLeft = 0;
|
|
181
|
+
let updateGutterOnly = false;
|
|
182
|
+
const resizeFrame = AnimationFrame.create();
|
|
183
|
+
if (isWebKit && (win.visualViewport?.scale ?? 1) !== 1) {
|
|
184
|
+
return () => {};
|
|
185
|
+
}
|
|
186
|
+
function lockScroll() {
|
|
187
|
+
const htmlStyles = win.getComputedStyle(html);
|
|
188
|
+
const bodyStyles = win.getComputedStyle(body);
|
|
189
|
+
const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
|
|
190
|
+
const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
|
|
191
|
+
const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
|
|
192
|
+
scrollTop = html.scrollTop;
|
|
193
|
+
scrollLeft = html.scrollLeft;
|
|
194
|
+
originalHtmlStyles = {
|
|
195
|
+
scrollbarGutter: html.style.scrollbarGutter,
|
|
196
|
+
overflowY: html.style.overflowY,
|
|
197
|
+
overflowX: html.style.overflowX
|
|
198
|
+
};
|
|
199
|
+
originalHtmlScrollBehavior = html.style.scrollBehavior;
|
|
200
|
+
originalBodyStyles = {
|
|
201
|
+
position: body.style.position,
|
|
202
|
+
height: body.style.height,
|
|
203
|
+
width: body.style.width,
|
|
204
|
+
boxSizing: body.style.boxSizing,
|
|
205
|
+
overflowY: body.style.overflowY,
|
|
206
|
+
overflowX: body.style.overflowX,
|
|
207
|
+
scrollBehavior: body.style.scrollBehavior
|
|
208
|
+
};
|
|
209
|
+
const isScrollableY = html.scrollHeight > html.clientHeight;
|
|
210
|
+
const isScrollableX = html.scrollWidth > html.clientWidth;
|
|
211
|
+
const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
|
|
212
|
+
const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
|
|
213
|
+
const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
|
|
214
|
+
const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
|
|
215
|
+
const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
|
|
216
|
+
const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
|
|
217
|
+
const elementToLock = isOverflowElement(html) ? html : body;
|
|
218
|
+
updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
|
|
219
|
+
if (updateGutterOnly) {
|
|
220
|
+
html.style.scrollbarGutter = scrollbarGutterValue;
|
|
221
|
+
elementToLock.style.overflowY = "hidden";
|
|
222
|
+
elementToLock.style.overflowX = "hidden";
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
Object.assign(html.style, {
|
|
226
|
+
scrollbarGutter: scrollbarGutterValue,
|
|
227
|
+
overflowY: "hidden",
|
|
228
|
+
overflowX: "hidden"
|
|
229
|
+
});
|
|
230
|
+
if (isScrollableY || hasConstantOverflowY) {
|
|
231
|
+
html.style.overflowY = "scroll";
|
|
232
|
+
}
|
|
233
|
+
if (isScrollableX || hasConstantOverflowX) {
|
|
234
|
+
html.style.overflowX = "scroll";
|
|
235
|
+
}
|
|
236
|
+
Object.assign(body.style, {
|
|
237
|
+
position: "relative",
|
|
238
|
+
height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
|
|
239
|
+
width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
|
|
240
|
+
boxSizing: "border-box",
|
|
241
|
+
overflow: "hidden",
|
|
242
|
+
scrollBehavior: "unset"
|
|
243
|
+
});
|
|
244
|
+
body.scrollTop = scrollTop;
|
|
245
|
+
body.scrollLeft = scrollLeft;
|
|
246
|
+
html.setAttribute("data-base-ui-scroll-locked", "");
|
|
247
|
+
html.style.scrollBehavior = "unset";
|
|
248
|
+
}
|
|
249
|
+
function cleanup() {
|
|
250
|
+
Object.assign(html.style, originalHtmlStyles);
|
|
251
|
+
Object.assign(body.style, originalBodyStyles);
|
|
252
|
+
if (!updateGutterOnly) {
|
|
253
|
+
html.scrollTop = scrollTop;
|
|
254
|
+
html.scrollLeft = scrollLeft;
|
|
255
|
+
html.removeAttribute("data-base-ui-scroll-locked");
|
|
256
|
+
html.style.scrollBehavior = originalHtmlScrollBehavior;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function handleResize() {
|
|
260
|
+
cleanup();
|
|
261
|
+
resizeFrame.request(lockScroll);
|
|
262
|
+
}
|
|
263
|
+
lockScroll();
|
|
264
|
+
const unsubscribeResize = addEventListener(win, "resize", handleResize);
|
|
265
|
+
return () => {
|
|
266
|
+
resizeFrame.cancel();
|
|
267
|
+
cleanup();
|
|
268
|
+
if (typeof win.removeEventListener === "function") {
|
|
269
|
+
unsubscribeResize();
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
class ScrollLocker {
|
|
275
|
+
lockCount = 0;
|
|
276
|
+
restore = null;
|
|
277
|
+
timeoutLock = Timeout.create();
|
|
278
|
+
timeoutUnlock = Timeout.create();
|
|
279
|
+
acquire(referenceElement) {
|
|
280
|
+
this.lockCount += 1;
|
|
281
|
+
if (this.lockCount === 1 && this.restore === null) {
|
|
282
|
+
this.timeoutLock.start(0, () => this.lock(referenceElement));
|
|
283
|
+
}
|
|
284
|
+
return this.release;
|
|
285
|
+
}
|
|
286
|
+
release = () => {
|
|
287
|
+
this.lockCount -= 1;
|
|
288
|
+
if (this.lockCount === 0 && this.restore) {
|
|
289
|
+
this.timeoutUnlock.start(0, this.unlock);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
unlock = () => {
|
|
293
|
+
if (this.lockCount === 0 && this.restore) {
|
|
294
|
+
this.restore?.();
|
|
295
|
+
this.restore = null;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
lock(referenceElement) {
|
|
299
|
+
if (this.lockCount === 0 || this.restore !== null) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const doc = ownerDocument(referenceElement);
|
|
303
|
+
const html = doc.documentElement;
|
|
304
|
+
const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
|
|
305
|
+
if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
|
|
306
|
+
this.restore = NOOP;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
|
|
310
|
+
this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
var SCROLL_LOCKER = new ScrollLocker;
|
|
314
|
+
function useScrollLock(enabled = true, referenceElement = null) {
|
|
315
|
+
useIsoLayoutEffect(() => {
|
|
316
|
+
if (!enabled) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
return SCROLL_LOCKER.acquire(referenceElement);
|
|
320
|
+
}, [enabled, referenceElement]);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { useScrollLock, useOpenInteractionType, InternalBackdrop };
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import {
|
|
2
|
+
usePreviousValue
|
|
3
|
+
} from "./_chunk-gfce3j3z.js";
|
|
4
|
+
import {
|
|
5
|
+
getCssDimensions
|
|
6
|
+
} from "./_chunk-xfagb0fq.js";
|
|
7
|
+
import {
|
|
8
|
+
useDirection
|
|
9
|
+
} from "./_chunk-wtw745qd.js";
|
|
10
|
+
import {
|
|
11
|
+
inertValue
|
|
12
|
+
} from "./_chunk-9nyxkvte.js";
|
|
13
|
+
import {
|
|
14
|
+
ownerDocument
|
|
15
|
+
} from "./_chunk-xb7ph1ka.js";
|
|
16
|
+
import {
|
|
17
|
+
useAnimationsFinished
|
|
18
|
+
} from "./_chunk-mbn76q14.js";
|
|
19
|
+
import {
|
|
20
|
+
useAnimationFrame
|
|
21
|
+
} from "./_chunk-3h6zpchb.js";
|
|
22
|
+
import {
|
|
23
|
+
useStableCallback
|
|
24
|
+
} from "./_chunk-mznt6ktj.js";
|
|
25
|
+
import {
|
|
26
|
+
useIsoLayoutEffect
|
|
27
|
+
} from "./_chunk-b40erthe.js";
|
|
28
|
+
import {
|
|
29
|
+
EMPTY_OBJECT,
|
|
30
|
+
NOOP
|
|
31
|
+
} from "./_chunk-1s41sngz.js";
|
|
32
|
+
|
|
33
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/usePopupViewport.js
|
|
34
|
+
import * as React2 from "react";
|
|
35
|
+
import * as ReactDOM from "react-dom";
|
|
36
|
+
|
|
37
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
|
|
38
|
+
import * as React from "react";
|
|
39
|
+
"use client";
|
|
40
|
+
var DEFAULT_ENABLED = () => true;
|
|
41
|
+
function usePopupAutoResize(parameters) {
|
|
42
|
+
const {
|
|
43
|
+
popupElement,
|
|
44
|
+
positionerElement,
|
|
45
|
+
content,
|
|
46
|
+
mounted,
|
|
47
|
+
enabled = DEFAULT_ENABLED,
|
|
48
|
+
onMeasureLayout: onMeasureLayoutParam,
|
|
49
|
+
onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
|
|
50
|
+
side,
|
|
51
|
+
direction
|
|
52
|
+
} = parameters;
|
|
53
|
+
const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
|
|
54
|
+
const animationFrame = useAnimationFrame();
|
|
55
|
+
const committedDimensionsRef = React.useRef(null);
|
|
56
|
+
const liveDimensionsRef = React.useRef(null);
|
|
57
|
+
const isInitialRenderRef = React.useRef(true);
|
|
58
|
+
const restoreAnchoringStylesRef = React.useRef(NOOP);
|
|
59
|
+
const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
|
|
60
|
+
const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
|
|
61
|
+
const anchoringStyles = React.useMemo(() => {
|
|
62
|
+
let isOriginSide = side === "top";
|
|
63
|
+
let isPhysicalLeft = side === "left";
|
|
64
|
+
if (direction === "rtl") {
|
|
65
|
+
isOriginSide = isOriginSide || side === "inline-end";
|
|
66
|
+
isPhysicalLeft = isPhysicalLeft || side === "inline-end";
|
|
67
|
+
} else {
|
|
68
|
+
isOriginSide = isOriginSide || side === "inline-start";
|
|
69
|
+
isPhysicalLeft = isPhysicalLeft || side === "inline-start";
|
|
70
|
+
}
|
|
71
|
+
return isOriginSide ? {
|
|
72
|
+
position: "absolute",
|
|
73
|
+
[side === "top" ? "bottom" : "top"]: "0",
|
|
74
|
+
[isPhysicalLeft ? "right" : "left"]: "0"
|
|
75
|
+
} : EMPTY_OBJECT;
|
|
76
|
+
}, [side, direction]);
|
|
77
|
+
useIsoLayoutEffect(() => {
|
|
78
|
+
if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
|
|
79
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
80
|
+
isInitialRenderRef.current = true;
|
|
81
|
+
committedDimensionsRef.current = null;
|
|
82
|
+
liveDimensionsRef.current = null;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!popupElement || !positionerElement) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
|
|
89
|
+
const observer = new ResizeObserver((entries) => {
|
|
90
|
+
const entry = entries[0];
|
|
91
|
+
if (entry) {
|
|
92
|
+
liveDimensionsRef.current = {
|
|
93
|
+
width: Math.ceil(entry.borderBoxSize[0].inlineSize),
|
|
94
|
+
height: Math.ceil(entry.borderBoxSize[0].blockSize)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
observer.observe(popupElement);
|
|
99
|
+
setPopupCssSize(popupElement, "auto");
|
|
100
|
+
const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
|
|
101
|
+
const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
|
|
102
|
+
const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
|
|
103
|
+
const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
|
|
104
|
+
"--available-width": "max-content",
|
|
105
|
+
"--available-height": "max-content"
|
|
106
|
+
});
|
|
107
|
+
function restoreMeasurementOverrides() {
|
|
108
|
+
restorePopupPosition();
|
|
109
|
+
restorePopupTransform();
|
|
110
|
+
restorePositionerAvailableSize();
|
|
111
|
+
}
|
|
112
|
+
function restoreMeasurementOverridesIncludingScale() {
|
|
113
|
+
restoreMeasurementOverrides();
|
|
114
|
+
restorePopupScale();
|
|
115
|
+
}
|
|
116
|
+
onMeasureLayout?.();
|
|
117
|
+
if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
|
|
118
|
+
setPositionerCssSize(positionerElement, "max-content");
|
|
119
|
+
const dimensions = getCssDimensions(popupElement);
|
|
120
|
+
committedDimensionsRef.current = dimensions;
|
|
121
|
+
setPositionerCssSize(positionerElement, dimensions);
|
|
122
|
+
restoreMeasurementOverridesIncludingScale();
|
|
123
|
+
onMeasureLayoutComplete?.(null, dimensions);
|
|
124
|
+
isInitialRenderRef.current = false;
|
|
125
|
+
return () => {
|
|
126
|
+
observer.disconnect();
|
|
127
|
+
restoreAnchoringStylesRef.current();
|
|
128
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
setPopupCssSize(popupElement, "auto");
|
|
132
|
+
setPositionerCssSize(positionerElement, "max-content");
|
|
133
|
+
const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
|
|
134
|
+
const newDimensions = getCssDimensions(popupElement);
|
|
135
|
+
committedDimensionsRef.current = newDimensions;
|
|
136
|
+
if (!previousDimensions) {
|
|
137
|
+
setPositionerCssSize(positionerElement, newDimensions);
|
|
138
|
+
restoreMeasurementOverridesIncludingScale();
|
|
139
|
+
onMeasureLayoutComplete?.(null, newDimensions);
|
|
140
|
+
return () => {
|
|
141
|
+
observer.disconnect();
|
|
142
|
+
animationFrame.cancel();
|
|
143
|
+
restoreAnchoringStylesRef.current();
|
|
144
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
setPopupCssSize(popupElement, previousDimensions);
|
|
148
|
+
restoreMeasurementOverridesIncludingScale();
|
|
149
|
+
onMeasureLayoutComplete?.(previousDimensions, newDimensions);
|
|
150
|
+
setPositionerCssSize(positionerElement, newDimensions);
|
|
151
|
+
const abortController = new AbortController;
|
|
152
|
+
animationFrame.request(() => {
|
|
153
|
+
setPopupCssSize(popupElement, newDimensions);
|
|
154
|
+
runOnceAnimationsFinish(() => {
|
|
155
|
+
popupElement.style.setProperty("--popup-width", "auto");
|
|
156
|
+
popupElement.style.setProperty("--popup-height", "auto");
|
|
157
|
+
}, abortController.signal);
|
|
158
|
+
});
|
|
159
|
+
return () => {
|
|
160
|
+
observer.disconnect();
|
|
161
|
+
abortController.abort();
|
|
162
|
+
animationFrame.cancel();
|
|
163
|
+
restoreAnchoringStylesRef.current();
|
|
164
|
+
restoreAnchoringStylesRef.current = NOOP;
|
|
165
|
+
};
|
|
166
|
+
}, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
|
|
167
|
+
}
|
|
168
|
+
function overrideElementStyle(element, property, value) {
|
|
169
|
+
const originalValue = element.style.getPropertyValue(property);
|
|
170
|
+
element.style.setProperty(property, value);
|
|
171
|
+
return () => {
|
|
172
|
+
element.style.setProperty(property, originalValue);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function applyElementStyles(element, styles) {
|
|
176
|
+
const restorers = [];
|
|
177
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
178
|
+
restorers.push(overrideElementStyle(element, key, value));
|
|
179
|
+
}
|
|
180
|
+
return restorers.length ? () => {
|
|
181
|
+
restorers.forEach((restore) => restore());
|
|
182
|
+
} : NOOP;
|
|
183
|
+
}
|
|
184
|
+
function setPopupCssSize(popupElement, size) {
|
|
185
|
+
const width = size === "auto" ? "auto" : `${size.width}px`;
|
|
186
|
+
const height = size === "auto" ? "auto" : `${size.height}px`;
|
|
187
|
+
popupElement.style.setProperty("--popup-width", width);
|
|
188
|
+
popupElement.style.setProperty("--popup-height", height);
|
|
189
|
+
}
|
|
190
|
+
function setPositionerCssSize(positionerElement, size) {
|
|
191
|
+
const width = size === "max-content" ? "max-content" : `${size.width}px`;
|
|
192
|
+
const height = size === "max-content" ? "max-content" : `${size.height}px`;
|
|
193
|
+
positionerElement.style.setProperty("--positioner-width", width);
|
|
194
|
+
positionerElement.style.setProperty("--positioner-height", height);
|
|
195
|
+
}
|
|
196
|
+
// node_modules/.deno/@base-ui+react@1.4.1/node_modules/@base-ui/react/esm/utils/usePopupViewport.js
|
|
197
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
198
|
+
"use client";
|
|
199
|
+
function usePopupViewport(parameters) {
|
|
200
|
+
const {
|
|
201
|
+
store,
|
|
202
|
+
side,
|
|
203
|
+
cssVars,
|
|
204
|
+
children
|
|
205
|
+
} = parameters;
|
|
206
|
+
const direction = useDirection();
|
|
207
|
+
const activeTrigger = store.useState("activeTriggerElement");
|
|
208
|
+
const activeTriggerId = store.useState("activeTriggerId");
|
|
209
|
+
const open = store.useState("open");
|
|
210
|
+
const payload = store.useState("payload");
|
|
211
|
+
const mounted = store.useState("mounted");
|
|
212
|
+
const popupElement = store.useState("popupElement");
|
|
213
|
+
const positionerElement = store.useState("positionerElement");
|
|
214
|
+
const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
|
|
215
|
+
const currentContentKey = usePopupContentKey(activeTriggerId, payload);
|
|
216
|
+
const capturedNodeRef = React2.useRef(null);
|
|
217
|
+
const [previousContentNode, setPreviousContentNode] = React2.useState(null);
|
|
218
|
+
const [newTriggerOffset, setNewTriggerOffset] = React2.useState(null);
|
|
219
|
+
const currentContainerRef = React2.useRef(null);
|
|
220
|
+
const previousContainerRef = React2.useRef(null);
|
|
221
|
+
const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
|
|
222
|
+
const cleanupFrame = useAnimationFrame();
|
|
223
|
+
const [previousContentDimensions, setPreviousContentDimensions] = React2.useState(null);
|
|
224
|
+
const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React2.useState(false);
|
|
225
|
+
useIsoLayoutEffect(() => {
|
|
226
|
+
store.set("hasViewport", true);
|
|
227
|
+
return () => {
|
|
228
|
+
store.set("hasViewport", false);
|
|
229
|
+
};
|
|
230
|
+
}, [store]);
|
|
231
|
+
const handleMeasureLayout = useStableCallback(() => {
|
|
232
|
+
currentContainerRef.current?.style.setProperty("animation", "none");
|
|
233
|
+
currentContainerRef.current?.style.setProperty("transition", "none");
|
|
234
|
+
previousContainerRef.current?.style.setProperty("display", "none");
|
|
235
|
+
});
|
|
236
|
+
const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
|
|
237
|
+
currentContainerRef.current?.style.removeProperty("animation");
|
|
238
|
+
currentContainerRef.current?.style.removeProperty("transition");
|
|
239
|
+
previousContainerRef.current?.style.removeProperty("display");
|
|
240
|
+
if (previousDimensions) {
|
|
241
|
+
setPreviousContentDimensions(previousDimensions);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
const lastHandledTriggerRef = React2.useRef(null);
|
|
245
|
+
useIsoLayoutEffect(() => {
|
|
246
|
+
if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
|
|
247
|
+
setPreviousContentNode(capturedNodeRef.current);
|
|
248
|
+
setShowStartingStyleAttribute(true);
|
|
249
|
+
const offset = calculateRelativePosition(previousActiveTrigger, activeTrigger);
|
|
250
|
+
setNewTriggerOffset(offset);
|
|
251
|
+
cleanupFrame.request(() => {
|
|
252
|
+
ReactDOM.flushSync(() => {
|
|
253
|
+
setShowStartingStyleAttribute(false);
|
|
254
|
+
});
|
|
255
|
+
onAnimationsFinished(() => {
|
|
256
|
+
setPreviousContentNode(null);
|
|
257
|
+
setPreviousContentDimensions(null);
|
|
258
|
+
capturedNodeRef.current = null;
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
lastHandledTriggerRef.current = activeTrigger;
|
|
262
|
+
}
|
|
263
|
+
}, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
|
|
264
|
+
useIsoLayoutEffect(() => {
|
|
265
|
+
const source = currentContainerRef.current;
|
|
266
|
+
if (!source) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const wrapper = ownerDocument(source).createElement("div");
|
|
270
|
+
for (const child of Array.from(source.childNodes)) {
|
|
271
|
+
wrapper.appendChild(child.cloneNode(true));
|
|
272
|
+
}
|
|
273
|
+
capturedNodeRef.current = wrapper;
|
|
274
|
+
});
|
|
275
|
+
const isTransitioning = previousContentNode != null;
|
|
276
|
+
let childrenToRender;
|
|
277
|
+
if (!isTransitioning) {
|
|
278
|
+
childrenToRender = /* @__PURE__ */ _jsx("div", {
|
|
279
|
+
"data-current": true,
|
|
280
|
+
ref: currentContainerRef,
|
|
281
|
+
children
|
|
282
|
+
}, currentContentKey);
|
|
283
|
+
} else {
|
|
284
|
+
childrenToRender = /* @__PURE__ */ _jsxs(React2.Fragment, {
|
|
285
|
+
children: [/* @__PURE__ */ _jsx("div", {
|
|
286
|
+
"data-previous": true,
|
|
287
|
+
inert: inertValue(true),
|
|
288
|
+
ref: previousContainerRef,
|
|
289
|
+
style: {
|
|
290
|
+
...previousContentDimensions ? {
|
|
291
|
+
[cssVars.popupWidth]: `${previousContentDimensions.width}px`,
|
|
292
|
+
[cssVars.popupHeight]: `${previousContentDimensions.height}px`
|
|
293
|
+
} : null,
|
|
294
|
+
position: "absolute"
|
|
295
|
+
},
|
|
296
|
+
"data-ending-style": showStartingStyleAttribute ? undefined : ""
|
|
297
|
+
}, "previous"), /* @__PURE__ */ _jsx("div", {
|
|
298
|
+
"data-current": true,
|
|
299
|
+
ref: currentContainerRef,
|
|
300
|
+
"data-starting-style": showStartingStyleAttribute ? "" : undefined,
|
|
301
|
+
children
|
|
302
|
+
}, currentContentKey)]
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
useIsoLayoutEffect(() => {
|
|
306
|
+
const container = previousContainerRef.current;
|
|
307
|
+
if (!container || !previousContentNode) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
container.replaceChildren(...Array.from(previousContentNode.childNodes));
|
|
311
|
+
}, [previousContentNode]);
|
|
312
|
+
usePopupAutoResize({
|
|
313
|
+
popupElement,
|
|
314
|
+
positionerElement,
|
|
315
|
+
mounted,
|
|
316
|
+
content: payload,
|
|
317
|
+
onMeasureLayout: handleMeasureLayout,
|
|
318
|
+
onMeasureLayoutComplete: handleMeasureLayoutComplete,
|
|
319
|
+
side,
|
|
320
|
+
direction
|
|
321
|
+
});
|
|
322
|
+
const state = {
|
|
323
|
+
activationDirection: getActivationDirection(newTriggerOffset),
|
|
324
|
+
transitioning: isTransitioning
|
|
325
|
+
};
|
|
326
|
+
return {
|
|
327
|
+
children: childrenToRender,
|
|
328
|
+
state
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function getActivationDirection(offset) {
|
|
332
|
+
if (!offset) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
return `${getValueWithTolerance(offset.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset.vertical, 5, "down", "up")}`;
|
|
336
|
+
}
|
|
337
|
+
function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
|
|
338
|
+
if (value > tolerance) {
|
|
339
|
+
return positiveLabel;
|
|
340
|
+
}
|
|
341
|
+
if (value < -tolerance) {
|
|
342
|
+
return negativeLabel;
|
|
343
|
+
}
|
|
344
|
+
return "";
|
|
345
|
+
}
|
|
346
|
+
function calculateRelativePosition(from, to) {
|
|
347
|
+
const fromRect = from.getBoundingClientRect();
|
|
348
|
+
const toRect = to.getBoundingClientRect();
|
|
349
|
+
const fromCenter = {
|
|
350
|
+
x: fromRect.left + fromRect.width / 2,
|
|
351
|
+
y: fromRect.top + fromRect.height / 2
|
|
352
|
+
};
|
|
353
|
+
const toCenter = {
|
|
354
|
+
x: toRect.left + toRect.width / 2,
|
|
355
|
+
y: toRect.top + toRect.height / 2
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
horizontal: toCenter.x - fromCenter.x,
|
|
359
|
+
vertical: toCenter.y - fromCenter.y
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function usePopupContentKey(activeTriggerId, payload) {
|
|
363
|
+
const [contentKey, setContentKey] = React2.useState(0);
|
|
364
|
+
const previousActiveTriggerIdRef = React2.useRef(activeTriggerId);
|
|
365
|
+
const previousPayloadRef = React2.useRef(payload);
|
|
366
|
+
const pendingPayloadUpdateRef = React2.useRef(false);
|
|
367
|
+
useIsoLayoutEffect(() => {
|
|
368
|
+
const previousActiveTriggerId = previousActiveTriggerIdRef.current;
|
|
369
|
+
const previousPayload = previousPayloadRef.current;
|
|
370
|
+
const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
|
|
371
|
+
const payloadChanged = payload !== previousPayload;
|
|
372
|
+
if (triggerIdChanged) {
|
|
373
|
+
setContentKey((value) => value + 1);
|
|
374
|
+
pendingPayloadUpdateRef.current = !payloadChanged;
|
|
375
|
+
} else if (pendingPayloadUpdateRef.current && payloadChanged) {
|
|
376
|
+
setContentKey((value) => value + 1);
|
|
377
|
+
pendingPayloadUpdateRef.current = false;
|
|
378
|
+
}
|
|
379
|
+
previousActiveTriggerIdRef.current = activeTriggerId;
|
|
380
|
+
previousPayloadRef.current = payload;
|
|
381
|
+
}, [activeTriggerId, payload]);
|
|
382
|
+
return `${activeTriggerId ?? "current"}-${contentKey}`;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export { usePopupViewport };
|