@justanarthur/modo-ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE.beui +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/LICENSE.motion-primitives +21 -0
- package/LICENSE.sileo +21 -0
- package/README.md +608 -2
- package/dist/base.css +994 -0
- package/dist/blocks/sidebar-app/index.d.ts +34 -0
- package/dist/blocks/sidebar-app/index.js +31 -0
- package/dist/components/badge/index.d.ts +59 -0
- package/dist/components/badge/index.js +16 -0
- package/dist/components/button/index.d.ts +59 -0
- package/dist/components/button/index.js +14 -0
- package/dist/components/card/index.d.ts +141 -0
- package/dist/components/card/index.js +42 -0
- package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
- package/dist/components/inputs/checkbox-group/index.js +21 -0
- package/dist/components/inputs/color-picker/index.d.ts +137 -0
- package/dist/components/inputs/color-picker/index.js +35 -0
- package/dist/components/inputs/combobox/index.d.ts +161 -0
- package/dist/components/inputs/combobox/index.js +38 -0
- package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
- package/dist/components/inputs/date-time/calendar/index.js +18 -0
- package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
- package/dist/components/inputs/date-time/date-picker/index.js +32 -0
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
- package/dist/components/inputs/date-time/date-range-picker/index.js +31 -0
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/duration-picker/index.js +31 -0
- package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/month-picker/index.js +30 -0
- package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
- package/dist/components/inputs/date-time/time-picker/index.js +31 -0
- package/dist/components/inputs/input/index.d.ts +84 -0
- package/dist/components/inputs/input/index.js +19 -0
- package/dist/components/inputs/input-copy/index.d.ts +44 -0
- package/dist/components/inputs/input-copy/index.js +16 -0
- package/dist/components/inputs/input-message/index.d.ts +125 -0
- package/dist/components/inputs/input-message/index.js +25 -0
- package/dist/components/inputs/radio-group/index.d.ts +58 -0
- package/dist/components/inputs/radio-group/index.js +20 -0
- package/dist/components/inputs/search/index.d.ts +83 -0
- package/dist/components/inputs/search/index.js +25 -0
- package/dist/components/inputs/select/index.d.ts +105 -0
- package/dist/components/inputs/select/index.js +34 -0
- package/dist/components/inputs/slider/index.d.ts +108 -0
- package/dist/components/inputs/slider/index.js +14 -0
- package/dist/components/inputs/switch/index.d.ts +43 -0
- package/dist/components/inputs/switch/index.js +14 -0
- package/dist/components/navigation/accordion/index.d.ts +117 -0
- package/dist/components/navigation/accordion/index.js +28 -0
- package/dist/components/navigation/sidebar/index.d.ts +388 -0
- package/dist/components/navigation/sidebar/index.js +99 -0
- package/dist/components/navigation/tabs/index.d.ts +70 -0
- package/dist/components/navigation/tabs/index.js +23 -0
- package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
- package/dist/components/navigation/tabs-subtle/index.js +21 -0
- package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
- package/dist/components/overlays/alert-dialog/index.js +22 -0
- package/dist/components/overlays/command/index.d.ts +121 -0
- package/dist/components/overlays/command/index.js +36 -0
- package/dist/components/overlays/context-menu/index.d.ts +97 -0
- package/dist/components/overlays/context-menu/index.js +29 -0
- package/dist/components/overlays/dialog/index.d.ts +130 -0
- package/dist/components/overlays/dialog/index.js +37 -0
- package/dist/components/overlays/dropdown/index.d.ts +222 -0
- package/dist/components/overlays/dropdown/index.js +44 -0
- package/dist/components/overlays/popover/index.d.ts +87 -0
- package/dist/components/overlays/popover/index.js +26 -0
- package/dist/components/overlays/preview-card/index.d.ts +75 -0
- package/dist/components/overlays/preview-card/index.js +19 -0
- package/dist/components/overlays/sheet/index.d.ts +67 -0
- package/dist/components/overlays/sheet/index.js +24 -0
- package/dist/components/overlays/toast/index.d.ts +107 -0
- package/dist/components/overlays/toast/index.js +21 -0
- package/dist/components/overlays/tooltip/index.d.ts +75 -0
- package/dist/components/overlays/tooltip/index.js +17 -0
- package/dist/components/table/index.d.ts +44 -0
- package/dist/components/table/index.js +26 -0
- package/dist/components/thinking-indicator/index.d.ts +32 -0
- package/dist/components/thinking-indicator/index.js +13 -0
- package/dist/index.d.ts +3926 -0
- package/dist/index.js +511 -0
- package/dist/preset.d.ts +104 -0
- package/dist/preset.js +124 -0
- package/dist/primitives/code/index.d.ts +23 -0
- package/dist/primitives/code/index.js +11 -0
- package/dist/primitives/craft/index.d.ts +31 -0
- package/dist/primitives/craft/index.js +11 -0
- package/dist/primitives/fluid-hover/index.d.ts +233 -0
- package/dist/primitives/fluid-hover/index.js +25 -0
- package/dist/primitives/morph/index.d.ts +127 -0
- package/dist/primitives/morph/index.js +19 -0
- package/dist/primitives/motion/index.d.ts +115 -0
- package/dist/primitives/motion/index.js +19 -0
- package/dist/primitives/scroll-area/index.d.ts +41 -0
- package/dist/primitives/scroll-area/index.js +12 -0
- package/dist/primitives/sizes/index.d.ts +128 -0
- package/dist/primitives/sizes/index.js +21 -0
- package/dist/primitives/surface/index.d.ts +69 -0
- package/dist/primitives/surface/index.js +17 -0
- package/dist/shared/components-0ke6xada.js +123 -0
- package/dist/shared/components-0q0sqfh4.js +146 -0
- package/dist/shared/components-0sn7ypjw.js +61 -0
- package/dist/shared/components-1j9791sn.js +345 -0
- package/dist/shared/components-1rfwbyyc.js +361 -0
- package/dist/shared/components-1v7rxytx.js +30 -0
- package/dist/shared/components-1xekx2hx.js +215 -0
- package/dist/shared/components-39jq9va1.js +86 -0
- package/dist/shared/components-3gae8nta.js +719 -0
- package/dist/shared/components-3k8xpnpq.js +1759 -0
- package/dist/shared/components-3ky44908.js +9 -0
- package/dist/shared/components-3mkepka5.js +111 -0
- package/dist/shared/components-3wk0w46f.js +667 -0
- package/dist/shared/components-4cnjmgex.js +124 -0
- package/dist/shared/components-59efxjd9.js +298 -0
- package/dist/shared/components-5xc2j8jz.js +159 -0
- package/dist/shared/components-62ybc7t2.js +496 -0
- package/dist/shared/components-66mv71kx.js +262 -0
- package/dist/shared/components-7ans7ce5.js +120 -0
- package/dist/shared/components-7btqt08d.js +270 -0
- package/dist/shared/components-7r3etddy.js +171 -0
- package/dist/shared/components-7x9kawxv.js +152 -0
- package/dist/shared/components-8fpr3s4p.js +292 -0
- package/dist/shared/components-9jvzzvt1.js +198 -0
- package/dist/shared/components-apdwtweq.js +484 -0
- package/dist/shared/components-asr5pg50.js +191 -0
- package/dist/shared/components-b2wyq2cq.js +232 -0
- package/dist/shared/components-c6s6b43g.js +15 -0
- package/dist/shared/components-ca2c898n.js +1828 -0
- package/dist/shared/components-cbxjn9p8.js +141 -0
- package/dist/shared/components-chacnk61.js +216 -0
- package/dist/shared/components-cv16mryv.js +62 -0
- package/dist/shared/components-ez65vtbq.js +110 -0
- package/dist/shared/components-ezxhrmer.js +17 -0
- package/dist/shared/components-gc5vtq2f.js +149 -0
- package/dist/shared/components-gf5s6ap9.js +42 -0
- package/dist/shared/components-gvr9w41t.js +193 -0
- package/dist/shared/components-h2dpcwgc.js +137 -0
- package/dist/shared/components-hawvy2qz.js +105 -0
- package/dist/shared/components-hqeq3w9q.js +375 -0
- package/dist/shared/components-jjw69c4c.js +28 -0
- package/dist/shared/components-jwst3vtj.js +346 -0
- package/dist/shared/components-kvr7f9hy.js +45 -0
- package/dist/shared/components-men63rwj.js +9 -0
- package/dist/shared/components-mhd39z7x.js +22 -0
- package/dist/shared/components-n7mjr357.js +26 -0
- package/dist/shared/components-ng72k97e.js +128 -0
- package/dist/shared/components-nh8tma1n.js +986 -0
- package/dist/shared/components-njzgqdwy.js +445 -0
- package/dist/shared/components-ny774h8p.js +293 -0
- package/dist/shared/components-q4daerx0.js +58 -0
- package/dist/shared/components-q5xj5c16.js +79 -0
- package/dist/shared/components-rr7a6ja9.js +160 -0
- package/dist/shared/components-s2bz1xpk.js +63 -0
- package/dist/shared/components-tqvarbfv.js +288 -0
- package/dist/shared/components-v6xp325t.js +304 -0
- package/dist/shared/components-v7wtz8hk.js +144 -0
- package/dist/shared/components-vc7vq5nz.js +32 -0
- package/dist/shared/components-vfbhxf5r.js +58 -0
- package/dist/shared/components-vynjtrk6.js +19 -0
- package/dist/shared/components-wvp1m52g.js +1200 -0
- package/dist/shared/components-yh3kwdhr.js +981 -0
- package/dist/shared/components-ytb2tefr.js +291 -0
- package/dist/shared/components-zfnmn5d4.js +220 -0
- package/dist/shared/components-zrkzcayz.js +141 -0
- package/dist/shared/components-zx6b6yby.js +42 -0
- package/dist/styles.css +1949 -0
- package/dist/tailwind.css +219 -0
- package/dist/tokens.css +345 -0
- package/package.json +103 -4
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultLocale,
|
|
3
|
+
fieldLabel,
|
|
4
|
+
dividedColumns,
|
|
5
|
+
ScrollColumn
|
|
6
|
+
} from "./components-9jvzzvt1.js";
|
|
7
|
+
import {
|
|
8
|
+
cn2
|
|
9
|
+
} from "./components-ezxhrmer.js";
|
|
10
|
+
import {
|
|
11
|
+
useShape
|
|
12
|
+
} from "./components-cv16mryv.js";
|
|
13
|
+
import {
|
|
14
|
+
useSize2
|
|
15
|
+
} from "./components-0sn7ypjw.js";
|
|
16
|
+
import {
|
|
17
|
+
SizeProvider2
|
|
18
|
+
} from "./components-jjw69c4c.js";
|
|
19
|
+
|
|
20
|
+
// components/inputs/date-time/calendar/index.tsx
|
|
21
|
+
import {
|
|
22
|
+
addDays,
|
|
23
|
+
addYears,
|
|
24
|
+
endOfYear,
|
|
25
|
+
format as format2,
|
|
26
|
+
isSameYear,
|
|
27
|
+
startOfMonth as startOfMonth2,
|
|
28
|
+
startOfWeek,
|
|
29
|
+
startOfYear
|
|
30
|
+
} from "date-fns";
|
|
31
|
+
import { useCallback as useCallback2, useEffect, useLayoutEffect as useLayoutEffect2, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
32
|
+
import { DayPicker } from "react-day-picker";
|
|
33
|
+
|
|
34
|
+
// components/inputs/date-time/calendar/use-month-window.ts
|
|
35
|
+
import { addMonths, differenceInCalendarMonths, format, startOfMonth } from "date-fns";
|
|
36
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
37
|
+
var WINDOW = 25;
|
|
38
|
+
var SHIFT = 12;
|
|
39
|
+
var monthKey = (date) => format(date, "yyyy-MM");
|
|
40
|
+
var findMonth = (scroller, key) => scroller.querySelector(`[data-calendar-month="${key}"]`);
|
|
41
|
+
function useMonthWindow(start, end, anchor) {
|
|
42
|
+
const total = differenceInCalendarMonths(end, start) + 1;
|
|
43
|
+
const count = Math.min(WINDOW, total);
|
|
44
|
+
const startTime = start.getTime();
|
|
45
|
+
const clamp = useCallback((first) => {
|
|
46
|
+
const from = new Date(startTime);
|
|
47
|
+
const last = addMonths(from, total - count);
|
|
48
|
+
return first < from ? from : first > last ? last : startOfMonth(first);
|
|
49
|
+
}, [startTime, total, count]);
|
|
50
|
+
const [first, setFirst] = useState(() => clamp(addMonths(startOfMonth(anchor), -Math.floor(WINDOW / 2))));
|
|
51
|
+
const [visible, setVisible] = useState([]);
|
|
52
|
+
const [current, setCurrent] = useState();
|
|
53
|
+
const scrollerRef = useRef(null);
|
|
54
|
+
const firstRef = useRef(first);
|
|
55
|
+
firstRef.current = first;
|
|
56
|
+
const pending = useRef({ day: anchor });
|
|
57
|
+
const settling = useRef(false);
|
|
58
|
+
const topMonth = useCallback(() => {
|
|
59
|
+
const scroller = scrollerRef.current;
|
|
60
|
+
if (!scroller)
|
|
61
|
+
return;
|
|
62
|
+
const top = scroller.scrollTop;
|
|
63
|
+
return [...scroller.querySelectorAll("[data-calendar-month]")].find((el) => el.offsetTop + el.offsetHeight > top);
|
|
64
|
+
}, []);
|
|
65
|
+
const moveWindow = useCallback((nextFirst, target) => {
|
|
66
|
+
const next = clamp(nextFirst);
|
|
67
|
+
if (next.getTime() === firstRef.current.getTime())
|
|
68
|
+
return;
|
|
69
|
+
const scroller = scrollerRef.current;
|
|
70
|
+
const top = topMonth();
|
|
71
|
+
pending.current = {
|
|
72
|
+
month: target,
|
|
73
|
+
keep: scroller && top ? { key: top.dataset.calendarMonth ?? "", delta: top.offsetTop - scroller.scrollTop } : undefined
|
|
74
|
+
};
|
|
75
|
+
setFirst(next);
|
|
76
|
+
}, [clamp, topMonth]);
|
|
77
|
+
const centreDay = useCallback((date) => {
|
|
78
|
+
const scroller = scrollerRef.current;
|
|
79
|
+
const day = scroller?.querySelector(`[data-day="${format(date, "yyyy-MM-dd")}"]`);
|
|
80
|
+
if (!scroller || !day)
|
|
81
|
+
return;
|
|
82
|
+
const s = scroller.getBoundingClientRect();
|
|
83
|
+
const d = day.getBoundingClientRect();
|
|
84
|
+
const scale = s.height / scroller.offsetHeight || 1;
|
|
85
|
+
scroller.scrollTop += (d.top - s.top) / scale - (scroller.clientHeight - day.offsetHeight) / 2;
|
|
86
|
+
}, []);
|
|
87
|
+
const measure = useCallback(() => {
|
|
88
|
+
const scroller = scrollerRef.current;
|
|
89
|
+
if (!scroller)
|
|
90
|
+
return;
|
|
91
|
+
const top = scroller.scrollTop;
|
|
92
|
+
const bottom = top + scroller.clientHeight;
|
|
93
|
+
const shown = [...scroller.querySelectorAll("[data-calendar-month]")].map((el) => ({
|
|
94
|
+
key: el.dataset.calendarMonth ?? "",
|
|
95
|
+
height: Math.min(bottom, el.offsetTop + el.offsetHeight) - Math.max(top, el.offsetTop)
|
|
96
|
+
})).filter((m) => m.height > 0);
|
|
97
|
+
const inView = shown.map((m) => m.key);
|
|
98
|
+
setVisible((prev) => prev.join() === inView.join() ? prev : inView);
|
|
99
|
+
setCurrent(shown.reduce((a, m) => a && a.height >= m.height ? a : m, undefined)?.key);
|
|
100
|
+
if (settling.current)
|
|
101
|
+
return;
|
|
102
|
+
const margin = scroller.clientHeight;
|
|
103
|
+
if (top < margin)
|
|
104
|
+
moveWindow(addMonths(firstRef.current, -SHIFT));
|
|
105
|
+
else if (scroller.scrollHeight - bottom < margin)
|
|
106
|
+
moveWindow(addMonths(firstRef.current, SHIFT));
|
|
107
|
+
}, [moveWindow]);
|
|
108
|
+
useLayoutEffect(() => {
|
|
109
|
+
const scroller = scrollerRef.current;
|
|
110
|
+
const p = pending.current;
|
|
111
|
+
pending.current = null;
|
|
112
|
+
if (!scroller || !p)
|
|
113
|
+
return;
|
|
114
|
+
const target = p.month && findMonth(scroller, p.month);
|
|
115
|
+
const kept = p.keep && findMonth(scroller, p.keep.key);
|
|
116
|
+
if (target)
|
|
117
|
+
scroller.scrollTop = target.offsetTop;
|
|
118
|
+
else if (kept && p.keep)
|
|
119
|
+
scroller.scrollTop = kept.offsetTop - p.keep.delta;
|
|
120
|
+
else if (p.day)
|
|
121
|
+
centreDay(p.day);
|
|
122
|
+
measure();
|
|
123
|
+
}, [first]);
|
|
124
|
+
const jumpTo = useCallback((month, behavior = "smooth") => {
|
|
125
|
+
const scroller = scrollerRef.current;
|
|
126
|
+
const key = monthKey(month);
|
|
127
|
+
const el = scroller && findMonth(scroller, key);
|
|
128
|
+
if (!scroller || !el) {
|
|
129
|
+
moveWindow(addMonths(startOfMonth(month), -Math.floor(WINDOW / 2)), key);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (behavior === "smooth") {
|
|
133
|
+
settling.current = true;
|
|
134
|
+
const done = () => {
|
|
135
|
+
settling.current = false;
|
|
136
|
+
scroller.removeEventListener("scrollend", done);
|
|
137
|
+
measure();
|
|
138
|
+
};
|
|
139
|
+
scroller.addEventListener("scrollend", done);
|
|
140
|
+
setTimeout(done, 600);
|
|
141
|
+
}
|
|
142
|
+
scroller.scrollTo({ top: el.offsetTop, behavior });
|
|
143
|
+
}, [measure, moveWindow]);
|
|
144
|
+
const recentre = useCallback((month) => moveWindow(addMonths(startOfMonth(month), -Math.floor(WINDOW / 2))), [moveWindow]);
|
|
145
|
+
return { first, count, visible, current, scrollerRef, measure, jumpTo, recentre, centreDay };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// components/inputs/date-time/calendar/index.tsx
|
|
149
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
150
|
+
var WEEKEND = { dayOfWeek: [0, 6] };
|
|
151
|
+
function pickedDate(props) {
|
|
152
|
+
if (props.mode === "single")
|
|
153
|
+
return props.selected;
|
|
154
|
+
if (props.mode === "range")
|
|
155
|
+
return props.selected?.from;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
function Month({ calendarMonth, displayIndex: _, ...props }) {
|
|
159
|
+
return /* @__PURE__ */ jsx("div", {
|
|
160
|
+
...props,
|
|
161
|
+
"data-calendar-month": monthKey(calendarMonth.date)
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function Day({ day: _, modifiers, className, ...props }) {
|
|
165
|
+
const start = modifiers.range_start && !modifiers.range_end;
|
|
166
|
+
const end = modifiers.range_end && !modifiers.range_start;
|
|
167
|
+
return /* @__PURE__ */ jsx("td", {
|
|
168
|
+
...props,
|
|
169
|
+
className: cn2("relative p-0", !modifiers.hidden && modifiers.range_middle && "bg-active", !modifiers.hidden && modifiers.preview && !modifiers.selected && "bg-hover", (start || end) && "before:absolute before:inset-y-0 before:bg-active", start && "before:start-1/2 before:end-0", end && "before:start-0 before:end-1/2", className)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function DayButton({ day: _, modifiers, className, ...props }) {
|
|
173
|
+
const ref = useRef2(null);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (modifiers.focused)
|
|
176
|
+
ref.current?.focus();
|
|
177
|
+
}, [modifiers.focused]);
|
|
178
|
+
const shape = useShape();
|
|
179
|
+
const sizeClasses = useSize2();
|
|
180
|
+
const pill = modifiers.selected && !modifiers.range_middle;
|
|
181
|
+
return /* @__PURE__ */ jsx("button", {
|
|
182
|
+
ref,
|
|
183
|
+
...props,
|
|
184
|
+
className: cn2("relative flex items-center justify-center tabular-nums outline-none cursor-pointer", "transition-[color,background-color] duration-fast focus-visible:ring-1 focus-visible:ring-focus-ring", "disabled:opacity-50 disabled:cursor-default", sizeClasses.variant === "compact" ? "size-7" : "size-9", sizeClasses.text, shape.item, modifiers.weekend && "text-muted-foreground", modifiers.today && "after:absolute after:bottom-1 after:left-1/2 after:size-1 after:-translate-x-1/2 after:rounded-full after:bg-current", pill ? "bg-foreground text-background weight-semibold hover:bg-foreground/90" : "enabled:hover:bg-hover", className)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function Calendar2({
|
|
188
|
+
locale = defaultLocale,
|
|
189
|
+
size,
|
|
190
|
+
columnsSide = "end",
|
|
191
|
+
extraColumns,
|
|
192
|
+
extraColumnsSide = "end",
|
|
193
|
+
className,
|
|
194
|
+
...props
|
|
195
|
+
}) {
|
|
196
|
+
const sizeClasses = useSize2(size);
|
|
197
|
+
const picked = pickedDate(props);
|
|
198
|
+
const today = useMemo(() => new Date, []);
|
|
199
|
+
const start = startOfMonth2(props.startMonth ?? startOfYear(addYears(today, -100)));
|
|
200
|
+
const end = startOfMonth2(props.endMonth ?? endOfYear(addYears(today, 50)));
|
|
201
|
+
const anchor = picked ?? props.month ?? props.defaultMonth ?? today;
|
|
202
|
+
const scroll = useMonthWindow(start, end, anchor);
|
|
203
|
+
const { jumpTo, visible } = scroll;
|
|
204
|
+
const currentKey = scroll.current ?? monthKey(anchor);
|
|
205
|
+
const yearInView = Number(currentKey.slice(0, 4));
|
|
206
|
+
const monthInView = Number(currentKey.slice(5, 7)) - 1;
|
|
207
|
+
const pickedTime = picked?.getTime();
|
|
208
|
+
const pickedRef = useRef2(pickedTime);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (pickedTime === pickedRef.current)
|
|
211
|
+
return;
|
|
212
|
+
pickedRef.current = pickedTime;
|
|
213
|
+
if (pickedTime !== undefined && !visible.includes(monthKey(new Date(pickedTime))))
|
|
214
|
+
jumpTo(new Date(pickedTime));
|
|
215
|
+
}, [pickedTime, jumpTo, visible]);
|
|
216
|
+
const rootRef = useRef2(null);
|
|
217
|
+
const [wide, setWide] = useState2(true);
|
|
218
|
+
const needed = useRef2(0);
|
|
219
|
+
useLayoutEffect2(() => {
|
|
220
|
+
const root = rootRef.current;
|
|
221
|
+
if (!root)
|
|
222
|
+
return;
|
|
223
|
+
const check = () => {
|
|
224
|
+
if (wide && root.scrollWidth > root.clientWidth + 1) {
|
|
225
|
+
needed.current = root.scrollWidth;
|
|
226
|
+
setWide(false);
|
|
227
|
+
} else if (!wide && root.clientWidth >= needed.current)
|
|
228
|
+
setWide(true);
|
|
229
|
+
};
|
|
230
|
+
check();
|
|
231
|
+
const observer = new ResizeObserver(check);
|
|
232
|
+
observer.observe(root);
|
|
233
|
+
return () => observer.disconnect();
|
|
234
|
+
}, [wide]);
|
|
235
|
+
const turned = useRef2(wide);
|
|
236
|
+
useLayoutEffect2(() => {
|
|
237
|
+
if (turned.current === wide)
|
|
238
|
+
return;
|
|
239
|
+
turned.current = wide;
|
|
240
|
+
scroll.centreDay(picked ?? today);
|
|
241
|
+
});
|
|
242
|
+
const [hovered, setHovered] = useState2();
|
|
243
|
+
const from = props.mode === "range" ? props.selected?.from : undefined;
|
|
244
|
+
const previewing = from && props.mode === "range" && !props.selected?.to && hovered;
|
|
245
|
+
const preview = previewing ? hovered < from ? { from: hovered, to: from } : { from, to: hovered } : false;
|
|
246
|
+
const weekStartsOn = props.weekStartsOn ?? locale.options?.weekStartsOn ?? 0;
|
|
247
|
+
const weekdays = useMemo(() => {
|
|
248
|
+
const first = startOfWeek(today, { weekStartsOn });
|
|
249
|
+
return Array.from({ length: 7 }, (_, i) => addDays(first, i));
|
|
250
|
+
}, [today, weekStartsOn]);
|
|
251
|
+
const months = useMemo(() => Array.from({ length: 12 }, (_, m) => ({
|
|
252
|
+
value: m,
|
|
253
|
+
label: format2(new Date(2000, m, 1), "LLL", { locale }),
|
|
254
|
+
disabled: new Date(yearInView, m, 1) < start || new Date(yearInView, m, 1) > end
|
|
255
|
+
})), [locale, yearInView, start.getTime(), end.getTime()]);
|
|
256
|
+
const years = useMemo(() => Array.from({ length: end.getFullYear() - start.getFullYear() + 1 }, (_, i) => {
|
|
257
|
+
const year = start.getFullYear() + i;
|
|
258
|
+
return { value: year, label: String(year) };
|
|
259
|
+
}), [start.getFullYear(), end.getFullYear()]);
|
|
260
|
+
const jumpToYear = useCallback2((year) => jumpTo(new Date(year, monthInView, 1)), [jumpTo, monthInView]);
|
|
261
|
+
const orientation = wide ? "vertical" : "horizontal";
|
|
262
|
+
const column = wide ? "w-16 shrink-0" : "w-full";
|
|
263
|
+
const monthColumn = /* @__PURE__ */ jsx(ScrollColumn, {
|
|
264
|
+
label: fieldLabel(locale, "month"),
|
|
265
|
+
options: months,
|
|
266
|
+
value: picked && isSameYear(picked, new Date(yearInView, 0, 1)) ? picked.getMonth() : null,
|
|
267
|
+
follow: monthInView,
|
|
268
|
+
inView: (m) => m === monthInView,
|
|
269
|
+
onValueChange: (m) => jumpTo(new Date(yearInView, m, 1)),
|
|
270
|
+
orientation,
|
|
271
|
+
className: column
|
|
272
|
+
}, "month");
|
|
273
|
+
const yearColumn = /* @__PURE__ */ jsx(ScrollColumn, {
|
|
274
|
+
label: fieldLabel(locale, "year"),
|
|
275
|
+
options: years,
|
|
276
|
+
value: picked?.getFullYear() ?? null,
|
|
277
|
+
follow: yearInView,
|
|
278
|
+
inView: (y) => y === yearInView,
|
|
279
|
+
onValueChange: jumpToYear,
|
|
280
|
+
orientation,
|
|
281
|
+
className: column
|
|
282
|
+
}, "year");
|
|
283
|
+
const extras = extraColumns?.(orientation);
|
|
284
|
+
const before = [extraColumnsSide === "start" && extras, columnsSide === "start" && [yearColumn, monthColumn]];
|
|
285
|
+
const after = [columnsSide === "end" && [monthColumn, yearColumn], extraColumnsSide === "end" && extras];
|
|
286
|
+
const side = (place) => wide ? cn2(dividedColumns, "h-full shrink-0 border-border", place === "start" ? "border-e" : "border-s") : "order-first flex w-full flex-col [&>*]:border-b [&>*]:border-border";
|
|
287
|
+
const grid = /* @__PURE__ */ jsxs("div", {
|
|
288
|
+
className: cn2("flex min-h-0 shrink-0 flex-col", wide ? "h-full" : "flex-1 self-center"),
|
|
289
|
+
children: [
|
|
290
|
+
/* @__PURE__ */ jsx("div", {
|
|
291
|
+
"aria-hidden": true,
|
|
292
|
+
className: "flex border-b border-border px-1 pb-1",
|
|
293
|
+
children: weekdays.map((day) => /* @__PURE__ */ jsx("span", {
|
|
294
|
+
className: cn2("flex items-center justify-center text-caption", sizeClasses.variant === "compact" ? "w-7" : "w-9", "text-muted-foreground"),
|
|
295
|
+
children: format2(day, "EEEEEE", { locale })
|
|
296
|
+
}, day.getDay()))
|
|
297
|
+
}),
|
|
298
|
+
/* @__PURE__ */ jsx("div", {
|
|
299
|
+
ref: scroll.scrollerRef,
|
|
300
|
+
onScroll: scroll.measure,
|
|
301
|
+
className: "relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1 scrollbar-hide scroll-fade [--scroll-fade-size:16px] [overflow-anchor:none]",
|
|
302
|
+
children: /* @__PURE__ */ jsx(DayPicker, {
|
|
303
|
+
...props,
|
|
304
|
+
locale,
|
|
305
|
+
month: scroll.first,
|
|
306
|
+
numberOfMonths: scroll.count,
|
|
307
|
+
startMonth: start,
|
|
308
|
+
endMonth: end,
|
|
309
|
+
onMonthChange: scroll.recentre,
|
|
310
|
+
hideNavigation: true,
|
|
311
|
+
hideWeekdays: true,
|
|
312
|
+
showOutsideDays: false,
|
|
313
|
+
modifiers: { weekend: WEEKEND, preview, ...props.modifiers },
|
|
314
|
+
onDayMouseEnter: (date, modifiers, e) => {
|
|
315
|
+
setHovered(date);
|
|
316
|
+
props.onDayMouseEnter?.(date, modifiers, e);
|
|
317
|
+
},
|
|
318
|
+
onDayMouseLeave: (date, modifiers, e) => {
|
|
319
|
+
setHovered(undefined);
|
|
320
|
+
props.onDayMouseLeave?.(date, modifiers, e);
|
|
321
|
+
},
|
|
322
|
+
formatters: {
|
|
323
|
+
formatCaption: (month) => format2(month, isSameYear(month, today) ? "LLLL" : "LLLL y", { locale }),
|
|
324
|
+
...props.formatters
|
|
325
|
+
},
|
|
326
|
+
components: { Month, Day, DayButton, ...props.components },
|
|
327
|
+
classNames: {
|
|
328
|
+
months: "flex flex-col",
|
|
329
|
+
month: "pb-2",
|
|
330
|
+
month_caption: cn2("px-2 pt-2 pb-1 text-subtitle weight-semibold", sizeClasses.variant === "compact" && "text-subtitle-compact"),
|
|
331
|
+
month_grid: "border-collapse",
|
|
332
|
+
...props.classNames
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
]
|
|
337
|
+
});
|
|
338
|
+
const content = /* @__PURE__ */ jsxs("div", {
|
|
339
|
+
ref: rootRef,
|
|
340
|
+
dir: props.dir,
|
|
341
|
+
className: cn2("flex w-max max-w-full overflow-hidden", wide ? "h-80 flex-row" : "h-[min(30rem,65dvh)] flex-col", className),
|
|
342
|
+
children: [
|
|
343
|
+
before.some(Boolean) ? /* @__PURE__ */ jsx("div", {
|
|
344
|
+
className: side("start"),
|
|
345
|
+
children: before
|
|
346
|
+
}) : null,
|
|
347
|
+
grid,
|
|
348
|
+
after.some(Boolean) ? /* @__PURE__ */ jsx("div", {
|
|
349
|
+
className: side("end"),
|
|
350
|
+
children: after
|
|
351
|
+
}) : null
|
|
352
|
+
]
|
|
353
|
+
});
|
|
354
|
+
return size ? /* @__PURE__ */ jsx(SizeProvider2, {
|
|
355
|
+
size,
|
|
356
|
+
children: content
|
|
357
|
+
}) : content;
|
|
358
|
+
}
|
|
359
|
+
var calendar_default = Calendar2;
|
|
360
|
+
|
|
361
|
+
export { Calendar2, calendar_default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// lib/springs.ts
|
|
2
|
+
var spring2 = {
|
|
3
|
+
fast: {
|
|
4
|
+
type: "spring",
|
|
5
|
+
duration: 0.08,
|
|
6
|
+
bounce: 0,
|
|
7
|
+
exit: { duration: 0.06 }
|
|
8
|
+
},
|
|
9
|
+
moderate: {
|
|
10
|
+
type: "spring",
|
|
11
|
+
duration: 0.16,
|
|
12
|
+
bounce: 0,
|
|
13
|
+
exit: { duration: 0.12 }
|
|
14
|
+
},
|
|
15
|
+
slow: {
|
|
16
|
+
type: "spring",
|
|
17
|
+
duration: 0.24,
|
|
18
|
+
bounce: 0.12,
|
|
19
|
+
exit: { duration: 0.16 }
|
|
20
|
+
},
|
|
21
|
+
goo: {
|
|
22
|
+
type: "spring",
|
|
23
|
+
visualDuration: 0.25,
|
|
24
|
+
bounce: 0.15,
|
|
25
|
+
exit: { type: "spring", visualDuration: 0.2, bounce: 0 }
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var exitFallbackMs2 = (tier) => Math.round(("duration" in tier.exit ? tier.exit.duration : tier.exit.visualDuration) * 1000) + 100;
|
|
29
|
+
|
|
30
|
+
export { spring2, exitFallbackMs2 };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMorphOrigin,
|
|
3
|
+
useMorph
|
|
4
|
+
} from "./components-hqeq3w9q.js";
|
|
5
|
+
import {
|
|
6
|
+
cn2
|
|
7
|
+
} from "./components-ezxhrmer.js";
|
|
8
|
+
import {
|
|
9
|
+
FluidHoverHighlight2
|
|
10
|
+
} from "./components-kvr7f9hy.js";
|
|
11
|
+
import {
|
|
12
|
+
MorphSurface
|
|
13
|
+
} from "./components-0q0sqfh4.js";
|
|
14
|
+
import {
|
|
15
|
+
shapeMap
|
|
16
|
+
} from "./components-cv16mryv.js";
|
|
17
|
+
import {
|
|
18
|
+
useSize2
|
|
19
|
+
} from "./components-0sn7ypjw.js";
|
|
20
|
+
import {
|
|
21
|
+
SURFACE_BG,
|
|
22
|
+
SURFACE_SHADOW,
|
|
23
|
+
useSurface2,
|
|
24
|
+
SurfaceProvider2
|
|
25
|
+
} from "./components-zx6b6yby.js";
|
|
26
|
+
import {
|
|
27
|
+
useControllableState
|
|
28
|
+
} from "./components-n7mjr357.js";
|
|
29
|
+
import {
|
|
30
|
+
useFluidHover2
|
|
31
|
+
} from "./components-59efxjd9.js";
|
|
32
|
+
import {
|
|
33
|
+
ScrollArea2
|
|
34
|
+
} from "./components-hawvy2qz.js";
|
|
35
|
+
import {
|
|
36
|
+
SizeProvider2
|
|
37
|
+
} from "./components-jjw69c4c.js";
|
|
38
|
+
import {
|
|
39
|
+
DropdownContext,
|
|
40
|
+
MenuItem2,
|
|
41
|
+
DropdownLabel2,
|
|
42
|
+
DropdownSeparator2
|
|
43
|
+
} from "./components-nh8tma1n.js";
|
|
44
|
+
import {
|
|
45
|
+
popupScrollAreaClass,
|
|
46
|
+
popupViewportClass,
|
|
47
|
+
isDisabledRow
|
|
48
|
+
} from "./components-vynjtrk6.js";
|
|
49
|
+
|
|
50
|
+
// components/overlays/context-menu/index.tsx
|
|
51
|
+
import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu";
|
|
52
|
+
import {
|
|
53
|
+
createContext,
|
|
54
|
+
forwardRef,
|
|
55
|
+
useContext,
|
|
56
|
+
useEffect,
|
|
57
|
+
useImperativeHandle,
|
|
58
|
+
useMemo,
|
|
59
|
+
useRef
|
|
60
|
+
} from "react";
|
|
61
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
62
|
+
var shape = shapeMap.rounded;
|
|
63
|
+
var ContextMenuContext = createContext({ open: false, origin: { current: {} } });
|
|
64
|
+
var ShortcutContext = createContext(undefined);
|
|
65
|
+
function RowShortcut() {
|
|
66
|
+
const shortcut = useContext(ShortcutContext);
|
|
67
|
+
const compact = useSize2().variant === "compact";
|
|
68
|
+
if (!shortcut)
|
|
69
|
+
return null;
|
|
70
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
71
|
+
className: cn2("shrink-0 pl-4 font-sans text-muted-foreground", compact ? "text-caption-compact" : "text-caption"),
|
|
72
|
+
children: shortcut
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function renderMenuItem({
|
|
76
|
+
radio,
|
|
77
|
+
checkbox,
|
|
78
|
+
checked,
|
|
79
|
+
disabled,
|
|
80
|
+
label,
|
|
81
|
+
closeOnClick,
|
|
82
|
+
onClick,
|
|
83
|
+
element,
|
|
84
|
+
children
|
|
85
|
+
}) {
|
|
86
|
+
return radio || checkbox ? /* @__PURE__ */ jsxs(ContextMenuPrimitive.CheckboxItem, {
|
|
87
|
+
checked,
|
|
88
|
+
disabled,
|
|
89
|
+
label,
|
|
90
|
+
closeOnClick,
|
|
91
|
+
onClick,
|
|
92
|
+
render: element,
|
|
93
|
+
children: [
|
|
94
|
+
children,
|
|
95
|
+
/* @__PURE__ */ jsx(RowShortcut, {})
|
|
96
|
+
]
|
|
97
|
+
}) : /* @__PURE__ */ jsxs(ContextMenuPrimitive.Item, {
|
|
98
|
+
disabled,
|
|
99
|
+
label,
|
|
100
|
+
closeOnClick,
|
|
101
|
+
onClick,
|
|
102
|
+
render: element,
|
|
103
|
+
children: [
|
|
104
|
+
children,
|
|
105
|
+
/* @__PURE__ */ jsx(RowShortcut, {})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
var ContextMenuItem2 = forwardRef(({ shortcut, ...props }, ref) => /* @__PURE__ */ jsx(ShortcutContext.Provider, {
|
|
110
|
+
value: shortcut,
|
|
111
|
+
children: /* @__PURE__ */ jsx(MenuItem2, {
|
|
112
|
+
ref,
|
|
113
|
+
...props
|
|
114
|
+
})
|
|
115
|
+
}));
|
|
116
|
+
ContextMenuItem2.displayName = "ContextMenuItem";
|
|
117
|
+
var ContextMenuContent2 = forwardRef(({ from = "pointer", effect, hideSource, tier = "moderate", container, className, children }, ref) => {
|
|
118
|
+
const { open, origin } = useContext(ContextMenuContext);
|
|
119
|
+
const morph = useMorph(open, origin, { from, effect, hideSource, tier });
|
|
120
|
+
useImperativeHandle(ref, () => morph.popup, [morph.popup]);
|
|
121
|
+
const level = Math.min(useSurface2() + 2, 8);
|
|
122
|
+
const containerRef = useRef(null);
|
|
123
|
+
const hover = useFluidHover2(containerRef, { isItemDisabled: isDisabledRow });
|
|
124
|
+
const { activeIndex, setActiveIndex, handlers, registerItem, remeasure } = hover;
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (open)
|
|
127
|
+
remeasure();
|
|
128
|
+
else
|
|
129
|
+
setActiveIndex(null);
|
|
130
|
+
}, [open, remeasure, setActiveIndex]);
|
|
131
|
+
const rows = useMemo(() => ({ registerItem, activeIndex, inMenu: true, renderMenuItem }), [registerItem, activeIndex]);
|
|
132
|
+
return /* @__PURE__ */ jsx(ContextMenuPrimitive.Portal, {
|
|
133
|
+
container: container ?? undefined,
|
|
134
|
+
children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Positioner, {
|
|
135
|
+
className: "z-50 outline-none",
|
|
136
|
+
children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Popup, {
|
|
137
|
+
ref: morph.popupRef,
|
|
138
|
+
onMouseEnter: handlers.onMouseEnter,
|
|
139
|
+
onMouseMove: handlers.onMouseMove,
|
|
140
|
+
onMouseLeave: handlers.onMouseLeave,
|
|
141
|
+
onClick: handlers.onClick,
|
|
142
|
+
onFocus: (e) => {
|
|
143
|
+
const index = e.target.closest("[data-fluid-hover-index]")?.getAttribute("data-fluid-hover-index");
|
|
144
|
+
if (index != null)
|
|
145
|
+
setActiveIndex(Number(index));
|
|
146
|
+
},
|
|
147
|
+
onBlur: (e) => {
|
|
148
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
149
|
+
setActiveIndex(null);
|
|
150
|
+
},
|
|
151
|
+
className: "relative select-none outline-none",
|
|
152
|
+
children: /* @__PURE__ */ jsx(SurfaceProvider2, {
|
|
153
|
+
value: level,
|
|
154
|
+
children: /* @__PURE__ */ jsx(MorphSurface, {
|
|
155
|
+
morph,
|
|
156
|
+
bg: SURFACE_BG[level],
|
|
157
|
+
shadow: SURFACE_SHADOW[3],
|
|
158
|
+
radius: shape.container,
|
|
159
|
+
className: cn2("flex w-56 max-h-[min(480px,var(--available-height))] flex-col overflow-hidden", shape.container, className),
|
|
160
|
+
children: /* @__PURE__ */ jsx(ScrollArea2, {
|
|
161
|
+
className: popupScrollAreaClass,
|
|
162
|
+
viewportClassName: cn2(popupViewportClass, "scroll-fade"),
|
|
163
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
164
|
+
ref: containerRef,
|
|
165
|
+
className: "relative flex flex-col p-1",
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx(FluidHoverHighlight2, {
|
|
168
|
+
hover,
|
|
169
|
+
hidden: !open,
|
|
170
|
+
className: shape.bg
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ jsx(DropdownContext.Provider, {
|
|
173
|
+
value: rows,
|
|
174
|
+
children
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
ContextMenuContent2.displayName = "ContextMenuContent";
|
|
186
|
+
function ContextMenu2({ open, defaultOpen = false, onOpenChange, disabled = false, size, children }) {
|
|
187
|
+
const [current, setCurrent] = useControllableState(open, defaultOpen, onOpenChange);
|
|
188
|
+
const { origin, capture } = useMorphOrigin();
|
|
189
|
+
const ctx = useMemo(() => ({ open: current, origin }), [current, origin]);
|
|
190
|
+
const root = /* @__PURE__ */ jsx(ContextMenuContext.Provider, {
|
|
191
|
+
value: ctx,
|
|
192
|
+
children: /* @__PURE__ */ jsx(ContextMenuPrimitive.Root, {
|
|
193
|
+
open: current,
|
|
194
|
+
disabled,
|
|
195
|
+
onOpenChange: (next, details) => {
|
|
196
|
+
if (next)
|
|
197
|
+
capture(details);
|
|
198
|
+
setCurrent(next);
|
|
199
|
+
},
|
|
200
|
+
children
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
return size ? /* @__PURE__ */ jsx(SizeProvider2, {
|
|
204
|
+
size,
|
|
205
|
+
children: root
|
|
206
|
+
}) : root;
|
|
207
|
+
}
|
|
208
|
+
ContextMenu2.Trigger = ContextMenuPrimitive.Trigger;
|
|
209
|
+
ContextMenu2.Content = ContextMenuContent2;
|
|
210
|
+
ContextMenu2.Item = ContextMenuItem2;
|
|
211
|
+
ContextMenu2.Label = DropdownLabel2;
|
|
212
|
+
ContextMenu2.Separator = DropdownSeparator2;
|
|
213
|
+
var context_menu_default = ContextMenu2;
|
|
214
|
+
|
|
215
|
+
export { ContextMenuItem2, ContextMenuContent2, ContextMenu2, context_menu_default };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useShape
|
|
3
|
+
} from "./components-cv16mryv.js";
|
|
4
|
+
import {
|
|
5
|
+
cn2
|
|
6
|
+
} from "./components-ezxhrmer.js";
|
|
7
|
+
import {
|
|
8
|
+
button_default
|
|
9
|
+
} from "./components-b2wyq2cq.js";
|
|
10
|
+
import {
|
|
11
|
+
MorphPart2,
|
|
12
|
+
MorphSurface
|
|
13
|
+
} from "./components-0q0sqfh4.js";
|
|
14
|
+
import {
|
|
15
|
+
opensInPlace,
|
|
16
|
+
useMorphOrigin,
|
|
17
|
+
useMorph
|
|
18
|
+
} from "./components-hqeq3w9q.js";
|
|
19
|
+
import {
|
|
20
|
+
SURFACE_BG,
|
|
21
|
+
SURFACE_SHADOW,
|
|
22
|
+
useSurface2,
|
|
23
|
+
SurfaceProvider2
|
|
24
|
+
} from "./components-zx6b6yby.js";
|
|
25
|
+
import {
|
|
26
|
+
useControllableState
|
|
27
|
+
} from "./components-n7mjr357.js";
|
|
28
|
+
|
|
29
|
+
// primitives/morph/index.tsx
|
|
30
|
+
import { useState } from "react";
|
|
31
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
+
function Morph2({
|
|
33
|
+
from = "trigger",
|
|
34
|
+
effect = "goo",
|
|
35
|
+
tier = "slow",
|
|
36
|
+
hideSource = false,
|
|
37
|
+
open,
|
|
38
|
+
defaultOpen = false,
|
|
39
|
+
onOpenChange,
|
|
40
|
+
label = "Open",
|
|
41
|
+
className,
|
|
42
|
+
children
|
|
43
|
+
}) {
|
|
44
|
+
const [shown, setShown] = useControllableState(open, defaultOpen, onOpenChange);
|
|
45
|
+
const [mounted, setMounted] = useState(shown);
|
|
46
|
+
if (shown && !mounted)
|
|
47
|
+
setMounted(true);
|
|
48
|
+
const { origin, capture } = useMorphOrigin();
|
|
49
|
+
const morph = useMorph(shown, origin, { from, effect, tier, hideSource }, () => setMounted(false));
|
|
50
|
+
const shape = useShape();
|
|
51
|
+
const level = Math.min(useSurface2() + 2, 8);
|
|
52
|
+
const inPlace = opensInPlace({ effect, hideSource });
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: cn2("relative inline-flex flex-col items-center", className),
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(button_default, {
|
|
57
|
+
variant: "secondary",
|
|
58
|
+
"aria-expanded": shown,
|
|
59
|
+
onClick: (event) => {
|
|
60
|
+
if (!shown)
|
|
61
|
+
capture({ trigger: event.currentTarget, event: event.nativeEvent });
|
|
62
|
+
setShown(!shown);
|
|
63
|
+
},
|
|
64
|
+
children: shown ? "Close" : label
|
|
65
|
+
}),
|
|
66
|
+
mounted && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
ref: morph.popupRef,
|
|
68
|
+
className: inPlace ? "absolute top-0 left-0 z-10" : "absolute top-full left-1/2 z-10 mt-3 -translate-x-1/2",
|
|
69
|
+
onClick: inPlace ? () => setShown(false) : undefined,
|
|
70
|
+
children: /* @__PURE__ */ jsx(SurfaceProvider2, {
|
|
71
|
+
value: level,
|
|
72
|
+
children: /* @__PURE__ */ jsx(MorphSurface, {
|
|
73
|
+
morph,
|
|
74
|
+
bg: SURFACE_BG[level],
|
|
75
|
+
shadow: SURFACE_SHADOW[level],
|
|
76
|
+
radius: shape.container,
|
|
77
|
+
className: "w-56 p-4",
|
|
78
|
+
children
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
Morph2.Part = MorphPart2;
|
|
86
|
+
export { Morph2 };
|