@box-kite/react 2.2.16 → 2.2.18
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/.claude/rules/box-kite-rules.md +3 -3
- package/.claude/skills/box-kite/SKILL.md +3 -3
- package/.claude/skills/box-kite/references/components.md +1 -1
- package/.claude/skills/box-kite/references/styling.md +1 -1
- package/.cursor/rules/box-kite.mdc +3 -3
- package/AGENTS.md +3 -3
- package/BOX_AI_CONTEXT.md +2 -2
- package/BOX_KITE_AI_CONTEXT.md +2 -2
- package/behavior.cjs +1 -1
- package/behavior.mjs +62 -62
- package/catalog.cjs +1 -1
- package/catalog.mjs +3 -3
- package/client.cjs +1 -1
- package/client.mjs +15 -15
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +1 -1
- package/components/calendar.cjs +1 -1
- package/components/calendar.mjs +1 -1
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +1 -1
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- package/components/dataGrid.cjs +2 -2
- package/components/dataGrid.mjs +11 -11
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +1 -1
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +198 -198
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +140 -132
- package/components/form.cjs +1 -1
- package/components/form.mjs +1 -1
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +120 -119
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +5 -4
- package/components/popover.cjs +1 -1
- package/components/popover.mjs +50 -49
- package/components/presence.cjs +1 -1
- package/components/presence.mjs +1 -1
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +1 -1
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +1 -1
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +1 -1
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +12 -12
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +2 -2
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +133 -115
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.mjs +1 -1
- package/components/virtualList.cjs +1 -1
- package/components/virtualList.mjs +1 -1
- package/docs/props.md +2 -2
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +17 -14
- package/motion.cjs +1 -1
- package/motion.mjs +30 -20
- package/package.json +40 -40
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +18 -11
- package/react/animation/useHeldContent.d.ts +6 -0
- package/react/animation/usePresence.d.ts +4 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/utils/dom/domUtils.d.ts +7 -0
package/components/toaster.mjs
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { f as e } from "../react-shared.mjs";
|
|
3
|
-
import { c as t,
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
6
|
-
import { t as
|
|
7
|
-
import
|
|
8
|
-
import { i as
|
|
9
|
-
import { n as
|
|
10
|
-
import {
|
|
11
|
-
import { useCallback as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { createPortal as
|
|
14
|
-
import { useSyncExternalStore as
|
|
3
|
+
import { c as t, d as n, l as r, t as i } from "../platform.mjs";
|
|
4
|
+
import { t as a } from "../client.mjs";
|
|
5
|
+
import { n as o } from "../effects.mjs";
|
|
6
|
+
import { t as s } from "../interactions.mjs";
|
|
7
|
+
import c from "../box.mjs";
|
|
8
|
+
import { i as l } from "../reporting.mjs";
|
|
9
|
+
import { n as u } from "../layer.mjs";
|
|
10
|
+
import { r as d } from "../motion.mjs";
|
|
11
|
+
import { useCallback as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal as _ } from "react-dom";
|
|
14
|
+
import { useSyncExternalStore as v } from "use-sync-external-store/shim";
|
|
15
15
|
//#region src/utils/toast/toastStore.ts
|
|
16
|
-
var
|
|
16
|
+
var y = ["value"], b = {
|
|
17
17
|
toasts: [],
|
|
18
18
|
overflow: 0
|
|
19
|
-
},
|
|
20
|
-
function
|
|
21
|
-
return
|
|
19
|
+
}, x = 0;
|
|
20
|
+
function S() {
|
|
21
|
+
return x += 1, `toast-${x}`;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
let t = [], n =
|
|
23
|
+
function C(e) {
|
|
24
|
+
let t = [], n = b, r = e?.limit ?? 3, i = e?.duration ?? 5e3, a = !1, o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = (e) => {
|
|
25
25
|
let t = c.get(e);
|
|
26
26
|
t?.handle && clearTimeout(t.handle), c.delete(e);
|
|
27
27
|
}, u = () => {
|
|
28
|
-
|
|
28
|
+
t = t.filter((e) => e.open || e.visible);
|
|
29
|
+
let e = t.filter((e) => !e.open).length, i = 0;
|
|
29
30
|
t = t.map((t) => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
if (!t.open) return t;
|
|
32
|
+
let n = e < r;
|
|
33
|
+
return n ? e++ : i++, t.visible === n ? t : {
|
|
32
34
|
...t,
|
|
33
35
|
visible: n
|
|
34
36
|
};
|
|
35
37
|
}), n = {
|
|
36
38
|
toasts: t,
|
|
37
|
-
overflow:
|
|
38
|
-
}, d(),
|
|
39
|
+
overflow: i
|
|
40
|
+
}, d(), o.forEach((e) => e());
|
|
39
41
|
};
|
|
40
42
|
function d() {
|
|
41
43
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -60,7 +62,7 @@ function x(e) {
|
|
|
60
62
|
...t,
|
|
61
63
|
open: !1
|
|
62
64
|
})), r.length && (u(), r.forEach((e) => {
|
|
63
|
-
e.onDismiss?.(n),
|
|
65
|
+
e.onDismiss?.(n), s({
|
|
64
66
|
component: "toaster",
|
|
65
67
|
type: "dismiss",
|
|
66
68
|
reason: n,
|
|
@@ -69,7 +71,7 @@ function x(e) {
|
|
|
69
71
|
id: e.id,
|
|
70
72
|
kind: e.kind
|
|
71
73
|
},
|
|
72
|
-
content:
|
|
74
|
+
content: y
|
|
73
75
|
});
|
|
74
76
|
}));
|
|
75
77
|
}
|
|
@@ -88,18 +90,18 @@ function x(e) {
|
|
|
88
90
|
duration: r?.duration ?? (r?.kind ? f(a) : t.duration),
|
|
89
91
|
open: !0
|
|
90
92
|
};
|
|
91
|
-
}), i && (u(),
|
|
93
|
+
}), i && (u(), s({
|
|
92
94
|
component: "toaster",
|
|
93
95
|
type: "update",
|
|
94
96
|
reason: r?.kind,
|
|
95
97
|
value: n,
|
|
96
98
|
details: { id: e },
|
|
97
99
|
source: "app",
|
|
98
|
-
content:
|
|
100
|
+
content: y
|
|
99
101
|
}));
|
|
100
102
|
}
|
|
101
103
|
function h(e, n) {
|
|
102
|
-
let r = n?.id ??
|
|
104
|
+
let r = n?.id ?? S();
|
|
103
105
|
if (n?.id && t.some((e) => e.id === r)) return m(r, e, n), r;
|
|
104
106
|
let i = n?.kind ?? "default";
|
|
105
107
|
return t = [...t, {
|
|
@@ -113,7 +115,7 @@ function x(e) {
|
|
|
113
115
|
onDismiss: n?.onDismiss,
|
|
114
116
|
open: !0,
|
|
115
117
|
visible: !1
|
|
116
|
-
}], u(),
|
|
118
|
+
}], u(), s({
|
|
117
119
|
component: "toaster",
|
|
118
120
|
type: "show",
|
|
119
121
|
reason: i,
|
|
@@ -123,15 +125,15 @@ function x(e) {
|
|
|
123
125
|
kind: i
|
|
124
126
|
},
|
|
125
127
|
source: "app",
|
|
126
|
-
content:
|
|
128
|
+
content: y
|
|
127
129
|
}), r;
|
|
128
130
|
}
|
|
129
131
|
return {
|
|
130
132
|
subscribe(e) {
|
|
131
|
-
return
|
|
133
|
+
return o.add(e), () => o.delete(e);
|
|
132
134
|
},
|
|
133
135
|
getSnapshot: () => n,
|
|
134
|
-
getServerSnapshot: () =>
|
|
136
|
+
getServerSnapshot: () => b,
|
|
135
137
|
add: h,
|
|
136
138
|
update: m,
|
|
137
139
|
dismiss: p,
|
|
@@ -156,32 +158,32 @@ function x(e) {
|
|
|
156
158
|
},
|
|
157
159
|
reset() {
|
|
158
160
|
for (let e of [...c.keys()]) l(e);
|
|
159
|
-
t = [], n =
|
|
161
|
+
t = [], n = b, o.forEach((e) => e());
|
|
160
162
|
}
|
|
161
163
|
};
|
|
162
164
|
}
|
|
163
165
|
//#endregion
|
|
164
166
|
//#region src/components/toaster.tsx
|
|
165
|
-
var
|
|
167
|
+
var w = C(), T = (e) => (t, n) => w.add(t, {
|
|
166
168
|
...n,
|
|
167
169
|
kind: e
|
|
168
|
-
}),
|
|
169
|
-
success:
|
|
170
|
-
error:
|
|
171
|
-
warning:
|
|
172
|
-
info:
|
|
173
|
-
loading:
|
|
174
|
-
update: (e, t, n) =>
|
|
175
|
-
dismiss: (e) =>
|
|
170
|
+
}), E = Object.assign((e, t) => w.add(e, t), {
|
|
171
|
+
success: T("success"),
|
|
172
|
+
error: T("error"),
|
|
173
|
+
warning: T("warning"),
|
|
174
|
+
info: T("info"),
|
|
175
|
+
loading: T("loading"),
|
|
176
|
+
update: (e, t, n) => w.update(e, t, n),
|
|
177
|
+
dismiss: (e) => w.dismiss(e, "imperative"),
|
|
176
178
|
promise(e, t, n) {
|
|
177
|
-
let r =
|
|
179
|
+
let r = w.add(t.loading, {
|
|
178
180
|
...n,
|
|
179
181
|
id: n?.id,
|
|
180
182
|
kind: "loading"
|
|
181
183
|
}), i = (e, t) => typeof e == "function" ? e(t) : e;
|
|
182
|
-
return e.then((e) =>
|
|
184
|
+
return e.then((e) => w.update(r, i(t.success, e), { kind: "success" }), (e) => w.update(r, i(t.error, e), { kind: "error" })), e;
|
|
183
185
|
}
|
|
184
|
-
}),
|
|
186
|
+
}), D = {
|
|
185
187
|
"top-start": "topStart",
|
|
186
188
|
"top-center": "topCenter",
|
|
187
189
|
"top-end": "topEnd",
|
|
@@ -189,29 +191,29 @@ var S = x(), C = (e) => (t, n) => S.add(t, {
|
|
|
189
191
|
"bottom-center": "bottomCenter",
|
|
190
192
|
"bottom-end": "bottomEnd"
|
|
191
193
|
};
|
|
192
|
-
function
|
|
194
|
+
function O(e, t) {
|
|
193
195
|
let n = t.toLowerCase().split("+"), r = n[n.length - 1], i = new Set(n.slice(0, -1));
|
|
194
196
|
return e.key.toLowerCase() === r && e.altKey === i.has("alt") && e.ctrlKey === i.has("ctrl") && e.shiftKey === i.has("shift") && e.metaKey === i.has("meta");
|
|
195
197
|
}
|
|
196
|
-
function
|
|
197
|
-
let { toast: t, store: n, fromTop: r, closeLabel: i } = e, { mounted:
|
|
198
|
-
if (
|
|
199
|
-
|
|
198
|
+
function k(e) {
|
|
199
|
+
let { toast: t, store: n, fromTop: r, closeLabel: i } = e, { mounted: a, ref: s, props: u } = d({ present: t.open }), f = l("toaster");
|
|
200
|
+
if (o(() => {
|
|
201
|
+
a || n.remove(t.id);
|
|
200
202
|
}, [
|
|
201
|
-
|
|
203
|
+
a,
|
|
202
204
|
n,
|
|
203
205
|
t.id
|
|
204
|
-
]), !
|
|
205
|
-
let
|
|
206
|
-
|
|
206
|
+
]), !a) return null;
|
|
207
|
+
let p = t.action, m = () => {
|
|
208
|
+
p?.onClick(), p?.closeOnClick === !1 ? f("action", t.message, {
|
|
207
209
|
reason: "action",
|
|
208
210
|
id: t.id,
|
|
209
211
|
kind: t.kind,
|
|
210
212
|
content: ["value"]
|
|
211
213
|
}) : n.dismiss(t.id, "action");
|
|
212
214
|
};
|
|
213
|
-
return /* @__PURE__ */
|
|
214
|
-
ref:
|
|
215
|
+
return /* @__PURE__ */ g(c, {
|
|
216
|
+
ref: s,
|
|
215
217
|
component: "toaster.toast",
|
|
216
218
|
variant: {
|
|
217
219
|
[t.kind]: t.kind !== "default",
|
|
@@ -220,27 +222,27 @@ function D(e) {
|
|
|
220
222
|
props: {
|
|
221
223
|
...t.kind === "error" ? { role: "alert" } : {},
|
|
222
224
|
"data-toast-id": t.id,
|
|
223
|
-
...
|
|
225
|
+
...u
|
|
224
226
|
},
|
|
225
227
|
children: [
|
|
226
|
-
/* @__PURE__ */
|
|
228
|
+
/* @__PURE__ */ h(c, {
|
|
227
229
|
component: "toaster.message",
|
|
228
230
|
children: t.message
|
|
229
231
|
}),
|
|
230
|
-
t.description !== void 0 && /* @__PURE__ */
|
|
232
|
+
t.description !== void 0 && /* @__PURE__ */ h(c, {
|
|
231
233
|
component: "toaster.description",
|
|
232
234
|
children: t.description
|
|
233
235
|
}),
|
|
234
|
-
|
|
236
|
+
p && /* @__PURE__ */ h(c, {
|
|
235
237
|
tag: "button",
|
|
236
238
|
component: "toaster.action",
|
|
237
239
|
props: {
|
|
238
240
|
type: "button",
|
|
239
|
-
onClick:
|
|
241
|
+
onClick: m
|
|
240
242
|
},
|
|
241
|
-
children:
|
|
243
|
+
children: p.label
|
|
242
244
|
}),
|
|
243
|
-
t.dismissible && /* @__PURE__ */
|
|
245
|
+
t.dismissible && /* @__PURE__ */ h(c, {
|
|
244
246
|
tag: "button",
|
|
245
247
|
component: "toaster.close",
|
|
246
248
|
props: {
|
|
@@ -252,83 +254,99 @@ function D(e) {
|
|
|
252
254
|
]
|
|
253
255
|
});
|
|
254
256
|
}
|
|
255
|
-
function
|
|
256
|
-
let { position:
|
|
257
|
-
|
|
258
|
-
}, [
|
|
257
|
+
function A(e, s) {
|
|
258
|
+
let { position: l = "bottom-end", limit: d = 3, duration: y = 5e3, label: b = "Notifications", closeLabel: x = "Close", overflowLabel: S = (e) => `+${e} more`, hotkey: C = "F6", store: T = w, props: E, ...A } = e, j = v(T.subscribe, T.getSnapshot, T.getServerSnapshot), M = u(), N = a(!M), P = p(null), F = f((e) => {
|
|
259
|
+
P.current = e, n(s, e);
|
|
260
|
+
}, [s]), I = p(null), [L, R] = m(null), z = p({
|
|
259
261
|
hovered: !1,
|
|
260
262
|
focused: !1,
|
|
261
263
|
hidden: !1
|
|
262
|
-
}),
|
|
263
|
-
let { hovered: e, focused: t, hidden: n } =
|
|
264
|
-
e || t || n ?
|
|
265
|
-
}, [
|
|
266
|
-
|
|
267
|
-
let e =
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
264
|
+
}), B = f(() => {
|
|
265
|
+
let { hovered: e, focused: t, hidden: n } = z.current;
|
|
266
|
+
e || t || n ? T.pause() : T.resume();
|
|
267
|
+
}, [T]);
|
|
268
|
+
o(() => T.setLimit(d), [T, d]), o(() => T.setDefaultDuration(y), [T, y]), o(() => {
|
|
269
|
+
let e = P.current;
|
|
270
|
+
e && (z.current.hovered = e.matches(":hover"), z.current.focused = e.contains(e.ownerDocument.activeElement), B());
|
|
271
|
+
}, [
|
|
272
|
+
j,
|
|
273
|
+
L,
|
|
274
|
+
B
|
|
275
|
+
]), o(() => {
|
|
276
|
+
let e = P.current;
|
|
277
|
+
!M || !t() || !e || !e.isConnected || e.matches(":popover-open") || e.showPopover();
|
|
278
|
+
}), o(() => {
|
|
279
|
+
let e = i();
|
|
280
|
+
if (!e) return;
|
|
281
|
+
let t = [], n = new AbortController();
|
|
282
|
+
return e.addEventListener(r, (e) => {
|
|
283
|
+
let { dialog: n, open: r } = e.detail, i = t.indexOf(n);
|
|
284
|
+
i >= 0 && t.splice(i, 1), r && t.push(n), R(t[t.length - 1] ?? null);
|
|
285
|
+
}, { signal: n.signal }), () => n.abort();
|
|
286
|
+
}, []), o(() => {
|
|
287
|
+
let e = i();
|
|
271
288
|
if (!e) return;
|
|
272
289
|
let t = new AbortController();
|
|
273
290
|
return e.addEventListener("visibilitychange", () => {
|
|
274
|
-
|
|
291
|
+
z.current.hidden = e.hidden, B();
|
|
275
292
|
}, { signal: t.signal }), () => t.abort();
|
|
276
|
-
}, [
|
|
277
|
-
let e =
|
|
278
|
-
if (!
|
|
293
|
+
}, [B]), o(() => {
|
|
294
|
+
let e = i();
|
|
295
|
+
if (!C || !e) return;
|
|
279
296
|
let t = new AbortController();
|
|
280
297
|
return e.addEventListener("keydown", (t) => {
|
|
281
|
-
!
|
|
298
|
+
!O(t, C) || !P.current || (t.preventDefault(), I.current = e.activeElement, P.current.focus());
|
|
282
299
|
}, { signal: t.signal }), () => t.abort();
|
|
283
|
-
}, [
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
},
|
|
300
|
+
}, [C]);
|
|
301
|
+
let V = (e) => !!e && !!P.current?.contains(e), H = () => {
|
|
302
|
+
z.current.hovered = !0, B();
|
|
303
|
+
}, U = (e) => {
|
|
304
|
+
V(e.relatedTarget) || (z.current.hovered = !1, B());
|
|
305
|
+
}, W = (e) => {
|
|
306
|
+
z.current.focused = !0, B(), V(e.relatedTarget) || (I.current = e.relatedTarget);
|
|
307
|
+
}, G = (e) => {
|
|
308
|
+
V(e.relatedTarget) || (z.current.focused = !1, B());
|
|
309
|
+
}, K = (e) => {
|
|
293
310
|
if (e.key !== "Escape") return;
|
|
311
|
+
L && e.preventDefault();
|
|
294
312
|
let t = (e.target.closest?.("[data-toast-id]"))?.getAttribute("data-toast-id");
|
|
295
|
-
t &&
|
|
296
|
-
},
|
|
313
|
+
t && T.dismiss(t, "close"), T.getSnapshot().toasts.some((e) => e.open) ? P.current?.focus() : I.current?.focus();
|
|
314
|
+
}, q = l.startsWith("top"), J = j.toasts.filter((e) => e.visible), Y = q ? [...J].reverse() : J, X = j.overflow > 0 && /* @__PURE__ */ h(c, {
|
|
297
315
|
component: "toaster.overflow",
|
|
298
|
-
children:
|
|
299
|
-
}),
|
|
316
|
+
children: S(j.overflow)
|
|
317
|
+
}), Z = /* @__PURE__ */ g(c, {
|
|
300
318
|
tag: "section",
|
|
301
|
-
ref:
|
|
319
|
+
ref: F,
|
|
302
320
|
component: "toaster",
|
|
303
|
-
...
|
|
304
|
-
variant: [
|
|
321
|
+
...A,
|
|
322
|
+
variant: [A.variant, { [D[l]]: !0 }],
|
|
305
323
|
props: {
|
|
306
|
-
...
|
|
324
|
+
...M ? { popover: "manual" } : {},
|
|
307
325
|
"aria-live": "polite",
|
|
308
326
|
"aria-atomic": "false",
|
|
309
327
|
"aria-relevant": "additions text",
|
|
310
|
-
"aria-label":
|
|
328
|
+
"aria-label": b,
|
|
311
329
|
tabIndex: -1,
|
|
312
|
-
...
|
|
313
|
-
onPointerOver:
|
|
314
|
-
onPointerOut:
|
|
315
|
-
onFocus:
|
|
316
|
-
onBlur:
|
|
317
|
-
onKeyDown:
|
|
330
|
+
...E,
|
|
331
|
+
onPointerOver: H,
|
|
332
|
+
onPointerOut: U,
|
|
333
|
+
onFocus: W,
|
|
334
|
+
onBlur: G,
|
|
335
|
+
onKeyDown: K
|
|
318
336
|
},
|
|
319
337
|
children: [
|
|
320
|
-
!
|
|
321
|
-
|
|
338
|
+
!q && X,
|
|
339
|
+
Y.map((e) => /* @__PURE__ */ h(k, {
|
|
322
340
|
toast: e,
|
|
323
|
-
store:
|
|
324
|
-
fromTop:
|
|
325
|
-
closeLabel:
|
|
341
|
+
store: T,
|
|
342
|
+
fromTop: q,
|
|
343
|
+
closeLabel: x
|
|
326
344
|
}, e.id)),
|
|
327
|
-
|
|
345
|
+
q && X
|
|
328
346
|
]
|
|
329
347
|
});
|
|
330
|
-
return
|
|
348
|
+
return L ? _(Z, L) : M ? Z : N ? _(Z, N) : null;
|
|
331
349
|
}
|
|
332
|
-
var
|
|
350
|
+
var j = e(A, "Toaster");
|
|
333
351
|
//#endregion
|
|
334
|
-
export {
|
|
352
|
+
export { C as createToastStore, j as default, w as defaultToastStore, E as toast };
|
package/components/tooltip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("./overlay.cjs"),a=require("./presence.cjs");let o=require("react"),s=require("react/jsx-runtime");function c(e,c){let{content:l,children:u,open:d,defaultOpen:f=!1,onOpenChange:p,openDelay:m=300,closeDelay:h=150,side:g=`bottom`,align:_=`center`,offset:v=1,flip:y=!0,props:b,...x}=e,S=r.t(`tooltip`),C=x.id??S,[w,T]=n.i({value:d,defaultValue:f,onChange:p}),[E,D]=(0,o.useState)(null),O=(0,o.useRef)(null),k=(0,o.useCallback)(e=>{O.current=e,t.
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("./overlay.cjs"),a=require("./presence.cjs");let o=require("react"),s=require("react/jsx-runtime");function c(e,c){let{content:l,children:u,open:d,defaultOpen:f=!1,onOpenChange:p,openDelay:m=300,closeDelay:h=150,side:g=`bottom`,align:_=`center`,offset:v=1,flip:y=!0,props:b,...x}=e,S=r.t(`tooltip`),C=x.id??S,[w,T]=n.i({value:d,defaultValue:f,onChange:p}),[E,D]=(0,o.useState)(null),O=(0,o.useRef)(null),k=(0,o.useCallback)(e=>{O.current=e,t.d(c,e)},[c]),A=(0,o.useRef)(void 0),j=(0,o.useRef)(!1),M=(0,o.useRef)(!1),N=(0,o.useRef)(!1),P=(0,o.useRef)(!1),F=(0,o.useCallback)(()=>{clearTimeout(A.current),A.current=void 0},[]),I=(0,o.useCallback)((e,t)=>{if(F(),e<=0){t();return}A.current=setTimeout(()=>{A.current=void 0,t()},e)},[F]),L=(0,o.useCallback)((e,t)=>{I(h,()=>{j.current||M.current||N.current||T(!1,{reason:e,event:t})})},[h,I,T]);n.r({enabled:w,outsidePointer:!1,inside:[O],onDismiss:(e,t)=>{F(),P.current=!0,T(!1,{reason:e,event:t})}}),(0,o.useEffect)(()=>F,[F]);let R=w&&l!=null,z=n.a(e=>{j.current=!0,!P.current&&I(m,()=>T(!0,{reason:`hover`,event:e}))}),B=n.a(e=>{j.current=!1,P.current=!1,L(`pointer-leave`,e)}),V=n.a(e=>{N.current=!0,F(),T(!0,{reason:`focus`,event:e})}),H=n.a(e=>{N.current=!1,P.current=!1,L(`blur`,e)}),U=n.a(()=>{M.current=!0,F()}),W=n.a(e=>{M.current=!1,L(`pointer-leave`,e)}),G=(0,o.useMemo)(()=>({ref:D,props:{"aria-describedby":R?C:void 0,onPointerEnter:z,onPointerLeave:B,onFocus:V,onBlur:H}}),[H,z,V,B,R,C]);return(0,s.jsxs)(s.Fragment,{children:[u(G),(0,s.jsx)(a.default,{present:R,children:e=>(0,s.jsx)(i.default,{ref:k,contentRef:e.ref,anchor:E,side:g,align:_,offset:v,flip:y,matchWidth:!1,component:`tooltip`,...x,variant:[x.variant,{closed:!e.present}],id:C,props:{role:`tooltip`,...e.props,...b,onPointerEnter:U,onPointerLeave:W},children:l})})]})}var l=e.f(c,`Tooltip`);exports.default=l;
|
package/components/tooltip.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { f as e } from "../react-shared.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { d as t } from "../platform.mjs";
|
|
4
4
|
import { a as n, i as r, r as i } from "../behavior.mjs";
|
|
5
5
|
import { t as a } from "../identity.mjs";
|
|
6
6
|
import o from "./overlay.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../behavior.cjs"),i=require("../scrolling.cjs"),a=require("./list.cjs");let o=require("react"),s=require("react/jsx-runtime");function c(e,t,n){return Math.min(Math.max(e,t),n)}var l;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.PIN_REACH=50;function r(e){let t=Array(e.length+1);t[0]=0;for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}e.offsetsOf=r;function a(e,t){let n=0,r=0;for(let t of e)n+=t,r++;return r?n/r:t}e.typicalSize=a;function o(e){let{offsets:r,viewStart:a,viewEnd:o,overscan:s=t,pin:l=-1}=e,u=r.length-1,d=r[u]??0;if(u<=0)return{startIndex:0,endIndex:0,offsetY:0,totalHeight:0};let f=c(i.n(r,a,u)-s,0,u-1),p=c(i.n(r,o-.5,u)+1+s,f+1,u);return l>=0&&l<u&&(l<f&&f-l<=n?f=l:l>=p&&l-p<n&&(p=l+1)),{startIndex:f,endIndex:p,offsetY:r[f],totalHeight:d}}e.measuredWindow=o})(l||={});var u=l;function d(e,t){for(let n of Array.from(e.children)){let e=n.getBoundingClientRect();if(e.bottom>t)return{element:n,top:e.top}}return null}var f=150;function p(e,c){let{items:l,itemKey:p,children:m,estimateSize:h=57,overscan:g=6,initialCount:_=20,onRangeChange:v,scrollerRef:y,vars:b,css:x,props:S,...C}=e,w=(0,o.useRef)(null),[T,E]=(0,o.useState)(()=>new Map),[,D]=(0,o.useState)(0),[O,k]=(0,o.useState)({startIndex:0,endIndex:Math.min(_,l.length)}),[A,j]=(0,o.useState)(-1),M=r.a(v),N=(0,o.useCallback)(e=>{w.current=e,t.
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../behavior.cjs"),i=require("../scrolling.cjs"),a=require("./list.cjs");let o=require("react"),s=require("react/jsx-runtime");function c(e,t,n){return Math.min(Math.max(e,t),n)}var l;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.PIN_REACH=50;function r(e){let t=Array(e.length+1);t[0]=0;for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}e.offsetsOf=r;function a(e,t){let n=0,r=0;for(let t of e)n+=t,r++;return r?n/r:t}e.typicalSize=a;function o(e){let{offsets:r,viewStart:a,viewEnd:o,overscan:s=t,pin:l=-1}=e,u=r.length-1,d=r[u]??0;if(u<=0)return{startIndex:0,endIndex:0,offsetY:0,totalHeight:0};let f=c(i.n(r,a,u)-s,0,u-1),p=c(i.n(r,o-.5,u)+1+s,f+1,u);return l>=0&&l<u&&(l<f&&f-l<=n?f=l:l>=p&&l-p<n&&(p=l+1)),{startIndex:f,endIndex:p,offsetY:r[f],totalHeight:d}}e.measuredWindow=o})(l||={});var u=l;function d(e,t){for(let n of Array.from(e.children)){let e=n.getBoundingClientRect();if(e.bottom>t)return{element:n,top:e.top}}return null}var f=150;function p(e,c){let{items:l,itemKey:p,children:m,estimateSize:h=57,overscan:g=6,initialCount:_=20,onRangeChange:v,scrollerRef:y,vars:b,css:x,props:S,...C}=e,w=(0,o.useRef)(null),[T,E]=(0,o.useState)(()=>new Map),[,D]=(0,o.useState)(0),[O,k]=(0,o.useState)({startIndex:0,endIndex:Math.min(_,l.length)}),[A,j]=(0,o.useState)(-1),M=r.a(v),N=(0,o.useCallback)(e=>{w.current=e,t.d(c,e)},[c]),[P,F]=(0,o.useState)(null),I=(0,o.useMemo)(()=>l.map((e,t)=>p(e,t)),[l,p]),L=(0,o.useMemo)(()=>u.typicalSize(T.values(),h),[T,h]),R=P?.count===l.length?P:null,z=R?R.estimate:L,B=(0,o.useMemo)(()=>u.offsetsOf(I.map(e=>T.get(e)??z)),[I,T,z]),V=B[l.length],H=r.o({offsets:B,pin:A,overscan:g,count:l.length,total:V,estimate:z}),U=(0,o.useRef)(null),W=Math.min(O.startIndex,Math.max(0,l.length-1)),G=Math.min(Math.max(O.endIndex,W),l.length),K=r.a(()=>{let e=w.current,{offsets:t,pin:n,overscan:r,count:a}=H.current;if(!e||a===0)return;let o=y?.current??i.t(e),s=e.ownerDocument.defaultView,c=o?o.getBoundingClientRect().top+o.clientTop:0,l=o?o.clientHeight:s?.innerHeight??0,d=e.getBoundingClientRect().top+e.clientTop,f=u.measuredWindow({offsets:t,viewStart:c-d,viewEnd:c-d+l,overscan:r,pin:n});k(e=>e.startIndex===f.startIndex&&e.endIndex===f.endIndex?e:{startIndex:f.startIndex,endIndex:f.endIndex})});n.n(()=>{let e=w.current;if(!e)return;let t=null,n=0,r=y?.current??i.t(e),a=r?r.getBoundingClientRect().top:0,o=parseFloat(getComputedStyle(e).rowGap)||0,s=U.current;if(U.current=null,s?.element.isConnected&&(n+=s.element.getBoundingClientRect().top-s.top),Array.from(e.children).forEach((e,r)=>{let i=W+r,s=I[i];if(s===void 0)return;e.setAttribute(`aria-setsize`,String(l.length)),e.setAttribute(`aria-posinset`,String(i+1));let c=e.getBoundingClientRect(),u=c.height+o,d=T.get(s)??z;c.height>0&&T.get(s)!==u&&(t??=new Map(T),t.set(s,u),c.bottom<=a&&(n+=u-d))}),n!==0){let t=r??e.ownerDocument.defaultView,i=r?r.scrollTop:t?.scrollY??0;t?.scrollTo({top:i+n,behavior:`instant`})}t?(U.current=d(e,a),E(t)):K()}),(0,o.useEffect)(()=>{let e=w.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>D(e=>e+1));return Array.from(e.children).forEach(e=>t.observe(e)),()=>t.disconnect()},[O,I]),(0,o.useEffect)(()=>{let e=w.current,t=e?.ownerDocument.defaultView;if(!e||!t)return;let n=y?.current??i.t(e),r=n??t,a=0,o=!1,s=0,c=()=>{a||=requestAnimationFrame(()=>(a=0,K()))},l=()=>{let{count:r,total:i,estimate:a}=H.current;F(e=>e??{count:r,total:i,estimate:a}),clearTimeout(s),s=t.setTimeout(()=>{o||(U.current=d(e,n?n.getBoundingClientRect().top:0),F(null))},f)},u=()=>{l(),c()},p=()=>{o=!0,l()},m=()=>{o&&(o=!1,l())};r.addEventListener(`scroll`,u,{passive:!0}),r.addEventListener(`pointerdown`,p,{capture:!0,passive:!0}),t.addEventListener(`pointerup`,m,!0),t.addEventListener(`pointercancel`,m,!0),t.addEventListener(`resize`,c);let h=typeof ResizeObserver>`u`?null:new ResizeObserver(c);return n&&h?.observe(n),()=>{cancelAnimationFrame(a),clearTimeout(s),r.removeEventListener(`scroll`,u),r.removeEventListener(`pointerdown`,p,!0),t.removeEventListener(`pointerup`,m,!0),t.removeEventListener(`pointercancel`,m,!0),t.removeEventListener(`resize`,c),h?.disconnect()}},[y,K,H]),(0,o.useEffect)(()=>{M({startIndex:O.startIndex,endIndex:O.endIndex})},[O,M]);let q=e=>{let t=w.current,n=Array.from(t?.children??[]).findIndex(t=>t.contains(e.target));n>=0&&j(W+n)},J=e=>{w.current?.contains(e.relatedTarget)||j(-1)},Y=[];for(let e=W;e<G;e++)Y.push((0,s.jsx)(o.Fragment,{children:m(l[e],e)},I[e]));return(0,s.jsx)(a.default,{ref:N,...C,vars:W>0?{...b,"list-first-divider":`block`}:b,css:{...x,overflowAnchor:`none`},transition:`none`,style:{paddingBlockStart:`${B[W]}px`,paddingBlockEnd:`${Math.max(0,(R&&G<l.length?R.total:V)-B[G])}px`},props:{...S,onFocus:q,onBlur:J},children:Y})}var m=e.f(p,`VirtualList`);exports.default=m;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { f as e } from "../react-shared.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { d as t } from "../platform.mjs";
|
|
4
4
|
import { n } from "../effects.mjs";
|
|
5
5
|
import { a as r, o as i } from "../behavior.mjs";
|
|
6
6
|
import { n as a, t as o } from "../scrolling.mjs";
|
package/docs/props.md
CHANGED
|
@@ -1050,10 +1050,10 @@ The margin CSS shorthand property sets the margin area on all four sides of an e
|
|
|
1050
1050
|
|
|
1051
1051
|
### `maskImage`
|
|
1052
1052
|
|
|
1053
|
-
What the element is masked by: the alpha channel of an image decides which of its pixels are painted. Takes the same gradient record `bgGradient` does — so a fade to `transparent` is the whole edge-fade recipe — or a `url(#id)`/`var(--name)` somebody else defined. One mask, not a stack.
|
|
1053
|
+
What the element is masked by: the alpha channel of an image decides which of its pixels are painted. Takes the same gradient record `bgGradient` does — so a fade to `transparent` is the whole edge-fade recipe — or a `url(#id)`/`var(--name)` somebody else defined. One mask, not a stack. `check`, `dash` and `dot` are the checkbox and radio marks, so the mark is painted by `bgColor` and follows the theme.
|
|
1054
1054
|
|
|
1055
1055
|
- Writes: `mask-image`
|
|
1056
|
-
- Values: `none`, anything else the types allow
|
|
1056
|
+
- Values: `none` · `check` · `dash` · `dot`, anything else the types allow
|
|
1057
1057
|
- Example: `maskImage={{ linear: 'b', colors: ['black', 'transparent'] }}` → `mask-image: linear-gradient(to bottom,var(--black,#000),var(--transparent,transparent))`
|
|
1058
1058
|
|
|
1059
1059
|
### `maxHeight`
|
package/interactionListening.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./platform.cjs");function t(e){let t=new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`object`||!n)return n;if(n instanceof Set)return Array.from(n);if(n instanceof Map)return Object.fromEntries(n);if(t.has(n))return;let r=Object.getPrototypeOf(n);if(!(!Array.isArray(n)&&(r!==Object.prototype&&r!==null||`$$typeof`in n)))return t.add(n),n});return n===void 0?void 0:JSON.parse(n)}var n=[`click`,`dblclick`,`keydown`,`pointerdown`,`pointerup`,`change`,`submit`,`copy`,`paste`,`focusout`],r=[`imperative`,`programmatic`,`timeout`],i=`a[href],button,input,select,textarea,summary,label,[tabindex],[role=option],[role=button]`;function a(e){let t=globalThis.scheduler;t?.postTask?t.postTask(e,{priority:`background`}):setTimeout(e,0)}function o(e){typeof reportError==`function`?reportError(e):setTimeout(()=>{throw e})}var s=e=>typeof Element<`u`&&e instanceof Element?e:void 0,c=e=>e?.closest(i)??void 0;function l({kind:e,input:n,event:i,handler:a,timeStamp:o,time:l,url:u},d){let f=d?[]:n.content??[],p=t(n.details&&Object.fromEntries(Object.entries(n.details).filter(([e])=>!f.includes(e)))),m=n.source??(n.reason&&r.includes(n.reason)?`app`:`user`);return{kind:e,component:n.component,type:n.type,reason:n.reason,value:f.includes(`value`)?void 0:t(n.value),details:p&&Object.keys(p).length>0?p:void 0,source:m,event:i,target:s(a)??c(s(i?.target))??n.target??s(i?.target),timeStamp:o,time:l,url:d?u:u.split(/[?#]/)[0]}}function u(t){let r=!1,i=()=>{r=!1;let e=t.queue.splice(0);if(t.listeners.size!==0)for(let n of e){if(n.kind===`dom`&&e.some(e=>e.kind!==`dom`&&e.event===n.event))continue;let r,i;t.listeners.forEach((e,t)=>{let a=e.content?r??=l(n,!0):i??=l(n,!1);try{t(a)}catch(e){o(e)}})}},u=()=>{r||(r=!0,a(i))};if(t.flush=i,t.schedule=u,t.queue.length>0&&u(),typeof addEventListener!=`function`)return;let d=n=>{let r=s(n.target);if(!r||t.listeners.size===0)return;if(!e.
|
|
1
|
+
const e=require("./platform.cjs");function t(e){let t=new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`object`||!n)return n;if(n instanceof Set)return Array.from(n);if(n instanceof Map)return Object.fromEntries(n);if(t.has(n))return;let r=Object.getPrototypeOf(n);if(!(!Array.isArray(n)&&(r!==Object.prototype&&r!==null||`$$typeof`in n)))return t.add(n),n});return n===void 0?void 0:JSON.parse(n)}var n=[`click`,`dblclick`,`keydown`,`pointerdown`,`pointerup`,`change`,`submit`,`copy`,`paste`,`focusout`],r=[`imperative`,`programmatic`,`timeout`],i=`a[href],button,input,select,textarea,summary,label,[tabindex],[role=option],[role=button]`;function a(e){let t=globalThis.scheduler;t?.postTask?t.postTask(e,{priority:`background`}):setTimeout(e,0)}function o(e){typeof reportError==`function`?reportError(e):setTimeout(()=>{throw e})}var s=e=>typeof Element<`u`&&e instanceof Element?e:void 0,c=e=>e?.closest(i)??void 0;function l({kind:e,input:n,event:i,handler:a,timeStamp:o,time:l,url:u},d){let f=d?[]:n.content??[],p=t(n.details&&Object.fromEntries(Object.entries(n.details).filter(([e])=>!f.includes(e)))),m=n.source??(n.reason&&r.includes(n.reason)?`app`:`user`);return{kind:e,component:n.component,type:n.type,reason:n.reason,value:f.includes(`value`)?void 0:t(n.value),details:p&&Object.keys(p).length>0?p:void 0,source:m,event:i,target:s(a)??c(s(i?.target))??n.target??s(i?.target),timeStamp:o,time:l,url:d?u:u.split(/[?#]/)[0]}}function u(t){let r=!1,i=()=>{r=!1;let e=t.queue.splice(0);if(t.listeners.size!==0)for(let n of e){if(n.kind===`dom`&&e.some(e=>e.kind!==`dom`&&e.event===n.event))continue;let r,i;t.listeners.forEach((e,t)=>{let a=e.content?r??=l(n,!0):i??=l(n,!1);try{t(a)}catch(e){o(e)}})}},u=()=>{r||(r=!0,a(i))};if(t.flush=i,t.schedule=u,t.queue.length>0&&u(),typeof addEventListener!=`function`)return;let d=n=>{let r=s(n.target);if(!r||t.listeners.size===0)return;if(!e._()){e.a()&&e.b()&&!t.warned&&(t.warned=!0,console.warn(`[box-kite] Box.onInteraction hears no clicks without data-bk: write Box.configure({ componentAttribute: true }).`));return}let i=c(r),a=(i??r).closest(`[data-bk]`);if(!a)return;let o=r instanceof HTMLInputElement&&(r.type===`checkbox`||r.type===`radio`);t.queue.push({kind:`dom`,input:{component:a.getAttribute(`data-bk`)??``,type:n.type,value:n.type===`change`&&o?r.checked:void 0,details:{interactive:i!==void 0},target:i??a,source:n.isTrusted?`user`:`app`},event:n,timeStamp:performance.now(),time:Date.now(),url:location.href}),u()},f=!1,p=e=>{t.dispatching=e,f||(f=!0,setTimeout(()=>{f=!1,t.dispatching=void 0},0)),(e.type===`click`||e.type===`change`)&&d(e)};n.forEach(e=>{document.addEventListener(e,p,!0),addEventListener(e,e=>{t.dispatching===e&&(t.dispatching=void 0)})}),addEventListener(`pagehide`,i)}exports.default=u;
|
package/interactionListening.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as e, a as t, b as n } from "./platform.mjs";
|
|
2
2
|
//#region src/utils/interactions/interactionJson.ts
|
|
3
3
|
function r(e) {
|
|
4
4
|
let t = /* @__PURE__ */ new WeakSet(), n = JSON.stringify(e, (e, n) => {
|
|
@@ -80,8 +80,8 @@ function f(r) {
|
|
|
80
80
|
let p = (i) => {
|
|
81
81
|
let a = l(i.target);
|
|
82
82
|
if (!a || r.listeners.size === 0) return;
|
|
83
|
-
if (!
|
|
84
|
-
|
|
83
|
+
if (!e()) {
|
|
84
|
+
t() && n() && !r.warned && (r.warned = !0, console.warn("[box-kite] Box.onInteraction hears no clicks without data-bk: write Box.configure({ componentAttribute: true })."));
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
let o = u(a), s = (o ?? a).closest("[data-bk]");
|
package/layer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./platform.cjs"),t=require("./effects.cjs"),n=require("./behavior.cjs"),r=require("./identity.cjs"),i=require("./reporting.cjs");let a=require("react");var o=()=>()=>{},s=()=>!0;function c(){return(0,a.useSyncExternalStore)(o,e.c,s)}function l(o){let{haspopup:s,id:l,idPrefix:u,open:d,defaultOpen:f=!1,onOpenChange:p,onOpened:m,onClosing:h,inside:g,interaction:_}=o,v=r.t(u),y=l??v,[b,x]=i.a({value:d,defaultValue:f,onChange:p,interaction:_}),[S,C]=(0,a.useState)(null),[w,T]=(0,a.useState)(null),E=c(),[D,O]=(0,a.useState)(!1),[k,A]=(0,a.useState)(),j=(0,a.useRef)(`imperative`),M=(0,a.useRef)(!1),N=n.a(m),
|
|
1
|
+
const e=require("./platform.cjs"),t=require("./effects.cjs"),n=require("./behavior.cjs"),r=require("./identity.cjs"),i=require("./reporting.cjs");let a=require("react");var o=()=>()=>{},s=()=>!0;function c(){return(0,a.useSyncExternalStore)(o,e.c,s)}function l(o){let{haspopup:s,id:l,idPrefix:u,open:d,defaultOpen:f=!1,onOpenChange:p,onOpened:m,onClosing:h,inside:g,interaction:_}=o,v=r.t(u),y=l??v,[b,x]=i.a({value:d,defaultValue:f,onChange:p,interaction:_}),[S,C]=(0,a.useState)(null),[w,T]=(0,a.useState)(null),E=c(),[D,O]=(0,a.useState)(!1),[k,A]=(0,a.useState)(),j=(0,a.useRef)(`imperative`),M=(0,a.useRef)(!1),N=(0,a.useRef)(null),P=n.a(m),F=n.a(h),I=n.a(e=>{let t=e.newState===`open`,n=e.currentTarget;if(t&&d===!1){e.preventDefault(),setTimeout(()=>x(!0,{reason:`trigger`,event:e}));return}let r=t?`trigger`:j.current;if(t){let e=document.activeElement;N.current=e instanceof HTMLElement&&e!==document.body?e:null}else M.current=n.contains(document.activeElement),F(M.current,S),r!==`outside-pointer`&&n.contains(document.activeElement)&&(N.current?.isConnected?N.current:S)?.focus({preventScroll:!0});O(t),j.current=`imperative`,x(t,{reason:r,event:e})}),L=n.a(e=>{let t=e.currentTarget;e.newState===`open`&&P(t)});t.n(()=>{if(!E||!w)return;let e=new AbortController;return w.addEventListener(`beforetoggle`,I,{signal:e.signal}),w.addEventListener(`toggle`,L,{signal:e.signal}),()=>e.abort()},[E,w,I,L]),t.n(()=>{!E||!e.c()||!w||b===D||(b?w.showPopover():w.hidePopover())},[b,D,w,E]),t.n(()=>{if(!E||!b)return;let t=new AbortController,n=(e,n)=>document.addEventListener(e,n,{signal:t.signal,capture:!0});return n(`keydown`,e=>{e.key===`Escape`&&(j.current=`escape`)}),n(`pointerdown`,t=>{let n=!!S&&e.h(t,[S]);j.current=n?`trigger`:`outside-pointer`}),()=>t.abort()},[E,b,S]),t.n(()=>{S&&(S.id||S.setAttribute(`id`,`${y}-trigger`),A(S.id))},[S,y]),t.n(()=>{if(!(!E||!S))return S.setAttribute(`popovertarget`,y),()=>S.removeAttribute(`popovertarget`)},[E,S,y]),t.n(()=>{E||!b||!w||P(w)},[E,b,w,P]),n.r({enabled:!E&&b,inside:[w,S,...g??[]],onDismiss:(e,t)=>x(!1,{reason:e,event:t})}),n.n({enabled:!E&&b,returnTo:S});let R=n.a(e=>{x(e=>!e,{reason:`trigger`,event:e})});return{platform:E,isOpen:b,setOpen:x,id:y,trigger:(0,a.useMemo)(()=>({ref:C,props:{"aria-expanded":b,"aria-haspopup":s,"aria-controls":b?y:void 0,...E?{}:{onClick:R}}}),[R,s,b,y,E]),triggerElement:S,triggerId:k,setPanel:T,panelElement:w}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
package/layer.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e,
|
|
1
|
+
import { c as e, h as t } from "./platform.mjs";
|
|
2
2
|
import { n } from "./effects.mjs";
|
|
3
3
|
import { a as r, n as i, r as a } from "./behavior.mjs";
|
|
4
4
|
import { t as o } from "./identity.mjs";
|
|
@@ -17,7 +17,7 @@ function h(d) {
|
|
|
17
17
|
defaultValue: _,
|
|
18
18
|
onChange: v,
|
|
19
19
|
interaction: S
|
|
20
|
-
}), [D, O] = u(null), [k, A] = u(null), j = m(), [M, N] = u(!1), [P, F] = u(), I = l("imperative"), L = l(!1), R = r(y),
|
|
20
|
+
}), [D, O] = u(null), [k, A] = u(null), j = m(), [M, N] = u(!1), [P, F] = u(), I = l("imperative"), L = l(!1), R = l(null), z = r(y), B = r(b), V = r((e) => {
|
|
21
21
|
let t = e.newState === "open", n = e.currentTarget;
|
|
22
22
|
if (t && g === !1) {
|
|
23
23
|
e.preventDefault(), setTimeout(() => E(!0, {
|
|
@@ -26,25 +26,28 @@ function h(d) {
|
|
|
26
26
|
}));
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
t || (L.current = n.contains(document.activeElement), z(L.current, D)), N(t);
|
|
30
29
|
let r = t ? "trigger" : I.current;
|
|
31
|
-
|
|
30
|
+
if (t) {
|
|
31
|
+
let e = document.activeElement;
|
|
32
|
+
R.current = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
33
|
+
} else L.current = n.contains(document.activeElement), B(L.current, D), r !== "outside-pointer" && n.contains(document.activeElement) && (R.current?.isConnected ? R.current : D)?.focus({ preventScroll: !0 });
|
|
34
|
+
N(t), I.current = "imperative", E(t, {
|
|
32
35
|
reason: r,
|
|
33
36
|
event: e
|
|
34
37
|
});
|
|
35
|
-
}),
|
|
38
|
+
}), H = r((e) => {
|
|
36
39
|
let t = e.currentTarget;
|
|
37
|
-
e.newState === "open" &&
|
|
40
|
+
e.newState === "open" && z(t);
|
|
38
41
|
});
|
|
39
42
|
n(() => {
|
|
40
43
|
if (!j || !k) return;
|
|
41
44
|
let e = new AbortController();
|
|
42
|
-
return k.addEventListener("beforetoggle",
|
|
45
|
+
return k.addEventListener("beforetoggle", V, { signal: e.signal }), k.addEventListener("toggle", H, { signal: e.signal }), () => e.abort();
|
|
43
46
|
}, [
|
|
44
47
|
j,
|
|
45
48
|
k,
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
V,
|
|
50
|
+
H
|
|
48
51
|
]), n(() => {
|
|
49
52
|
!j || !e() || !k || T === M || (T ? k.showPopover() : k.hidePopover());
|
|
50
53
|
}, [
|
|
@@ -77,12 +80,12 @@ function h(d) {
|
|
|
77
80
|
D,
|
|
78
81
|
w
|
|
79
82
|
]), n(() => {
|
|
80
|
-
j || !T || !k ||
|
|
83
|
+
j || !T || !k || z(k);
|
|
81
84
|
}, [
|
|
82
85
|
j,
|
|
83
86
|
T,
|
|
84
87
|
k,
|
|
85
|
-
|
|
88
|
+
z
|
|
86
89
|
]), a({
|
|
87
90
|
enabled: !j && T,
|
|
88
91
|
inside: [
|
|
@@ -98,7 +101,7 @@ function h(d) {
|
|
|
98
101
|
enabled: !j && T,
|
|
99
102
|
returnTo: D
|
|
100
103
|
});
|
|
101
|
-
let
|
|
104
|
+
let U = r((e) => {
|
|
102
105
|
E((e) => !e, {
|
|
103
106
|
reason: "trigger",
|
|
104
107
|
event: e
|
|
@@ -115,10 +118,10 @@ function h(d) {
|
|
|
115
118
|
"aria-expanded": T,
|
|
116
119
|
"aria-haspopup": f,
|
|
117
120
|
"aria-controls": T ? w : void 0,
|
|
118
|
-
...j ? {} : { onClick:
|
|
121
|
+
...j ? {} : { onClick: U }
|
|
119
122
|
}
|
|
120
123
|
}), [
|
|
121
|
-
|
|
124
|
+
U,
|
|
122
125
|
f,
|
|
123
126
|
T,
|
|
124
127
|
w,
|
package/motion.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./effects.cjs");let t=require("react");var n;(function(e){e.SETTLE_FRAME=16;function t(e){let t=parseFloat(e);return Number.isNaN(t)?0:e.endsWith(`ms`)?t:t*1e3}function n(e){return e.split(`,`).map(e=>e.trim())}function r(e,t){return e[t%e.length]}function i(e){return e===``?1:parseFloat(e)}function a(e){let i=n(e.transitionDuration),a=n(e.transitionDelay),o=0;for(let e=0;e<Math.max(i.length,a.length);e++)o=Math.max(o,t(r(i,e))+t(r(a,e)));return o}function o(e){let a=n(e.animationDuration),o=n(e.animationDelay),s=n(e.animationIterationCount);return n(e.animationName).reduce((e,n,c)=>{if(n===``||n===`none`)return e;let l=i(r(s,c));return Number.isFinite(l)?Math.max(e,t(r(a,c))*l+t(r(o,c))):e},0)}function s(e){return Math.max(a(e),o(e))}e.activeDuration=s})(n||={});var r=n;function i(
|
|
1
|
+
const e=require("./effects.cjs");let t=require("react");var n;(function(e){e.SETTLE_FRAME=16;function t(e){let t=parseFloat(e);return Number.isNaN(t)?0:e.endsWith(`ms`)?t:t*1e3}function n(e){return e.split(`,`).map(e=>e.trim())}function r(e,t){return e[t%e.length]}function i(e){return e===``?1:parseFloat(e)}function a(e){let i=n(e.transitionDuration),a=n(e.transitionDelay),o=0;for(let e=0;e<Math.max(i.length,a.length);e++)o=Math.max(o,t(r(i,e))+t(r(a,e)));return o}function o(e){let a=n(e.animationDuration),o=n(e.animationDelay),s=n(e.animationIterationCount);return n(e.animationName).reduce((e,n,c)=>{if(n===``||n===`none`)return e;let l=i(r(s,c));return Number.isFinite(l)?Math.max(e,t(r(a,c))*l+t(r(o,c))):e},0)}function s(e){return Math.max(a(e),o(e))}e.activeDuration=s})(n||={});var r=n;function i(e){let n=(0,t.useRef)(null),r=(0,t.useCallback)(e=>{n.current=e},[]),i=(0,t.useCallback)(()=>n.current,[]),o=a(e.present,i);return(0,t.useMemo)(()=>{let e=o===`open`?`open`:`closed`;return{mounted:o!==`closed`,present:o===`open`,state:e,ref:r,props:{"data-state":e}}},[o,r])}function a(n,i){let[a,o]=(0,t.useState)(n?`open`:`closed`),s=n?`open`:a===`closed`?`closed`:`leaving`;return s!==a&&o(s),e.n(()=>{if(s!==`leaving`)return;let e=i(),t=e?r.activeDuration(getComputedStyle(e)):0;if(t<=0){o(`closed`);return}let n=setTimeout(()=>o(`closed`),t+r.SETTLE_FRAME);return()=>clearTimeout(n)},[s,i]),s}function o(e,n,r){let i=a(n,(0,t.useCallback)(()=>r,[r])),[o,s]=(0,t.useState)(e);return n&&o!==e&&s(e),i===`leaving`?o:e}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|