@box-kite/react 2.2.3 → 2.2.5
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 +8 -0
- package/.claude/skills/box-kite/SKILL.md +8 -0
- package/.claude/skills/box-kite/references/components.md +49 -3
- package/.cursor/rules/box-kite.mdc +8 -0
- package/AGENTS.md +8 -0
- package/BOX_AI_CONTEXT.md +276 -20
- package/BOX_KITE_AI_CONTEXT.md +276 -20
- package/behavior.cjs +1 -1
- package/behavior.mjs +57 -57
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +17 -17
- package/catalog.cjs +1 -1
- package/catalog.mjs +385 -0
- package/client.cjs +1 -1
- package/client.mjs +113 -87
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- package/components/dataGrid/components/dataGridList.d.ts +12 -0
- package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
- package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
- package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
- package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
- package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
- package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
- package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
- package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
- package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +32 -0
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/listModel.d.ts +129 -0
- package/components/dataGrid/models/localeText.d.ts +32 -0
- package/components/dataGrid/models/viewportModel.d.ts +0 -2
- package/components/dataGrid/useListLayout.d.ts +13 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +1052 -788
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +85 -97
- package/components/list/listItemParts.d.ts +9 -0
- package/components/list.cjs +1 -0
- package/components/list.d.ts +118 -0
- package/components/list.mjs +391 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +25 -25
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +12 -12
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +1 -1
- package/components/sortableList.cjs +1 -0
- package/components/sortableList.d.ts +49 -0
- package/components/sortableList.mjs +384 -0
- package/components/swipeItem.cjs +1 -0
- package/components/swipeItem.d.ts +52 -0
- package/components/swipeItem.mjs +321 -0
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +1 -1
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +24 -24
- package/components/virtualList.cjs +1 -0
- package/components/virtualList.d.ts +32 -0
- package/components/virtualList.mjs +188 -0
- package/dataGridList.cjs +1 -0
- package/dataGridList.mjs +1351 -0
- package/docs/components.md +5 -1
- package/icons/closeIcon.d.ts +2 -0
- package/icons/filterIcon.d.ts +2 -0
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/mcp/src/data.d.ts +2 -0
- package/package.json +86 -22
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +4 -1
- package/react/a11y/useControllableState.d.ts +2 -1
- package/react/componentsContext.d.ts +4 -0
- package/react/componentsProvider.d.ts +10 -0
- package/react/resolveStyles.d.ts +2 -1
- package/react/theme/theme.d.ts +6 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +40 -29
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
- package/registry/designs/store/address-form.d.ts +11 -0
- package/registry/designs/store/cart-items.d.ts +10 -0
- package/registry/designs/store/cart-page.d.ts +4 -0
- package/registry/designs/store/checkout-page.d.ts +7 -0
- package/registry/designs/store/credit-card-form.d.ts +10 -0
- package/registry/designs/store/form-field.d.ts +19 -0
- package/registry/designs/store/order-summary.d.ts +18 -0
- package/registry/designs/store/product-art.d.ts +26 -0
- package/registry/designs/store/product-card.d.ts +11 -0
- package/registry/designs/store/product-gallery.d.ts +11 -0
- package/registry/designs/store/product-grid.d.ts +10 -0
- package/registry/designs/store/product-page.d.ts +5 -0
- package/registry/designs/store/quantity-stepper.d.ts +13 -0
- package/registry/designs/store/shipping-method.d.ts +14 -0
- package/registry/designs/store/store-data.d.ts +53 -0
- package/registry/designs/store/store-design.d.ts +63 -0
- package/registry/designs/store/store-shell.d.ts +12 -0
- package/registry/designs/store/storefront-page.d.ts +4 -0
- package/registry/designs/store/variant-picker.d.ts +15 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +2 -0
- package/rsc.mjs +1 -1
- package/scrolling.cjs +1 -0
- package/scrolling.mjs +22 -0
- package/ssg.cjs +1 -1
- package/ssg.mjs +1 -1
- package/utils/scroll/scrollUtils.d.ts +6 -0
- package/utils/sortable/sortableUtils.d.ts +25 -0
- package/utils/swipe/swipeUtils.d.ts +53 -0
- package/utils/virtual/measuredWindow.d.ts +28 -0
- package/utils/virtual/rowSearch.d.ts +11 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { d as t, s as n, t as r, u as i } from "../platform.mjs";
|
|
4
|
+
import { n as a } from "../effects.mjs";
|
|
5
|
+
import { useBoxElement as o } from "../box.mjs";
|
|
6
|
+
import { a as s, i as c, o as l } from "../behavior.mjs";
|
|
7
|
+
import { n as u } from "../motion.mjs";
|
|
8
|
+
import d, { i as f, n as p, r as m, t as h } from "./list.mjs";
|
|
9
|
+
import { createContext as g, useCallback as ee, useContext as _, useEffect as v, useRef as y, useState as b } from "react";
|
|
10
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
11
|
+
//#region src/utils/swipe/swipeUtils.ts
|
|
12
|
+
var w;
|
|
13
|
+
(function(e) {
|
|
14
|
+
let t = e.SLOP = 8, n = e.FLICK = .4, r = e.FULL_RATIO = .6;
|
|
15
|
+
function i(e, n) {
|
|
16
|
+
return Math.max(Math.abs(e), Math.abs(n)) < t ? null : Math.abs(e) > Math.abs(n) ? "swipe" : "scroll";
|
|
17
|
+
}
|
|
18
|
+
e.intent = i;
|
|
19
|
+
function a(e, t) {
|
|
20
|
+
return (1 - 1 / (e * .55 / t + 1)) * t;
|
|
21
|
+
}
|
|
22
|
+
function o(e, t, n, r, i) {
|
|
23
|
+
let o = e + t, s = o < 0 ? -1 : 1, c = o < 0 ? n.end : n.start, l = Math.abs(o);
|
|
24
|
+
return c === 0 ? 0 : l <= c ? o : i ? s * Math.min(l, r) : s * (c + a(l - c, Math.max(r, 1)));
|
|
25
|
+
}
|
|
26
|
+
e.offsetFor = o;
|
|
27
|
+
function s(e, n, i, a) {
|
|
28
|
+
if (!a || e === 0) return null;
|
|
29
|
+
let o = e > 0 ? "start" : "end", s = n[o];
|
|
30
|
+
return s === 0 ? null : Math.abs(e) >= Math.max(s + t * 4, i * r) ? o : null;
|
|
31
|
+
}
|
|
32
|
+
e.armed = s;
|
|
33
|
+
function c(e, t, r, i, a) {
|
|
34
|
+
let o = s(e, r, i, a);
|
|
35
|
+
if (o) return {
|
|
36
|
+
open: null,
|
|
37
|
+
full: o
|
|
38
|
+
};
|
|
39
|
+
if (e === 0) return {
|
|
40
|
+
open: null,
|
|
41
|
+
full: null
|
|
42
|
+
};
|
|
43
|
+
let c = e > 0 ? "start" : "end", l = r[c];
|
|
44
|
+
return l === 0 ? {
|
|
45
|
+
open: null,
|
|
46
|
+
full: null
|
|
47
|
+
} : Math.abs(t) >= n ? {
|
|
48
|
+
open: Math.sign(t) === Math.sign(e) ? c : null,
|
|
49
|
+
full: null
|
|
50
|
+
} : {
|
|
51
|
+
open: Math.abs(e) >= l / 2 ? c : null,
|
|
52
|
+
full: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
e.settle = c;
|
|
56
|
+
let l = e.VELOCITY_WINDOW = 100;
|
|
57
|
+
function u(e, t) {
|
|
58
|
+
return [...e.filter((e) => t.t - e.t <= l), t];
|
|
59
|
+
}
|
|
60
|
+
e.track = u;
|
|
61
|
+
function d(e) {
|
|
62
|
+
let t = e[0], n = e[e.length - 1];
|
|
63
|
+
return !t || !n || n.t - t.t < 16 ? 0 : (n.x - t.x) / (n.t - t.t);
|
|
64
|
+
}
|
|
65
|
+
e.velocity = d;
|
|
66
|
+
function f(e, t) {
|
|
67
|
+
return e === "start" ? t.start : e === "end" ? -t.end : 0;
|
|
68
|
+
}
|
|
69
|
+
e.restOffset = f;
|
|
70
|
+
})(w ||= {});
|
|
71
|
+
var T = w, E = g(null), te = {
|
|
72
|
+
start: 0,
|
|
73
|
+
end: 0
|
|
74
|
+
};
|
|
75
|
+
function D(e, p) {
|
|
76
|
+
let { size: m = "md", wrap: g = !1, selected: _ = !1, chevron: w = !1, startActions: D, endActions: O, fullSwipe: k = !1, open: A, defaultOpen: ie = null, onOpenChange: ae, variant: oe, children: se, props: ce, ...le } = e, j = y(null), M = y(null), N = y(null), P = y(null), F = y(!1), [I, L] = c({
|
|
77
|
+
value: A,
|
|
78
|
+
defaultValue: ie,
|
|
79
|
+
onChange: ae
|
|
80
|
+
}), [R, z] = b(null), [B, V] = b(null), [H, U] = b({
|
|
81
|
+
trays: te,
|
|
82
|
+
width: 0,
|
|
83
|
+
rtl: !1
|
|
84
|
+
}), W = l(H), ue = ee((e) => {
|
|
85
|
+
j.current = e, typeof p == "function" ? p(e) : p && (p.current = e);
|
|
86
|
+
}, [p]), G = s(() => {
|
|
87
|
+
let e = (e) => e?.firstElementChild?.offsetWidth ?? 0, n = {
|
|
88
|
+
trays: {
|
|
89
|
+
start: D ? e(M.current) : 0,
|
|
90
|
+
end: O ? e(N.current) : 0
|
|
91
|
+
},
|
|
92
|
+
width: j.current?.offsetWidth ?? 0,
|
|
93
|
+
rtl: t(j.current)
|
|
94
|
+
}, r = W.current;
|
|
95
|
+
return (r.trays.start !== n.trays.start || r.trays.end !== n.trays.end || r.width !== n.width || r.rtl !== n.rtl) && U(n), n;
|
|
96
|
+
});
|
|
97
|
+
a(() => {
|
|
98
|
+
I && G();
|
|
99
|
+
}, [I, G]);
|
|
100
|
+
let K = s((e) => L(null, e));
|
|
101
|
+
v(() => {
|
|
102
|
+
let e = r();
|
|
103
|
+
if (!I || !e) return;
|
|
104
|
+
let t = (e) => {
|
|
105
|
+
i(e, [j]) || K({
|
|
106
|
+
reason: "outside-pointer",
|
|
107
|
+
event: e
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
return e.addEventListener("pointerdown", t, !0), () => e.removeEventListener("pointerdown", t, !0);
|
|
111
|
+
}, [I, K]), v(() => {
|
|
112
|
+
if (!B) return;
|
|
113
|
+
let e = (B === "start" ? M : N).current, t = j.current?.firstElementChild, n = t && typeof getComputedStyle == "function" ? u.activeDuration(getComputedStyle(t)) : 0, r = setTimeout(() => {
|
|
114
|
+
V(null), e?.querySelector("[data-swipe-action]")?.click();
|
|
115
|
+
}, n + u.SETTLE_FRAME);
|
|
116
|
+
return () => clearTimeout(r);
|
|
117
|
+
}, [B]);
|
|
118
|
+
let de = s((e) => {
|
|
119
|
+
if (F.current = !1, e.button !== 0 || B || !D && !O) return;
|
|
120
|
+
let { trays: t } = G();
|
|
121
|
+
P.current = {
|
|
122
|
+
pointerId: e.pointerId,
|
|
123
|
+
x: e.clientX,
|
|
124
|
+
y: e.clientY,
|
|
125
|
+
rest: T.restOffset(I, t),
|
|
126
|
+
intent: null,
|
|
127
|
+
samples: [{
|
|
128
|
+
t: e.timeStamp,
|
|
129
|
+
x: e.clientX
|
|
130
|
+
}]
|
|
131
|
+
};
|
|
132
|
+
}), fe = s((e) => {
|
|
133
|
+
let t = P.current;
|
|
134
|
+
if (!t || t.pointerId !== e.pointerId || t.intent === "scroll") return;
|
|
135
|
+
let r = e.clientX - t.x;
|
|
136
|
+
if (!t.intent) {
|
|
137
|
+
if (t.intent = T.intent(r, e.clientY - t.y), t.intent !== "swipe") return;
|
|
138
|
+
e.currentTarget.setPointerCapture?.(e.pointerId), n(e.currentTarget);
|
|
139
|
+
}
|
|
140
|
+
let { trays: i, width: a, rtl: o } = W.current;
|
|
141
|
+
t.samples = T.track(t.samples, {
|
|
142
|
+
t: e.timeStamp,
|
|
143
|
+
x: e.clientX
|
|
144
|
+
}), z(T.offsetFor(t.rest, o ? -r : r, i, a, k));
|
|
145
|
+
}), q = s((e) => {
|
|
146
|
+
let t = P.current;
|
|
147
|
+
if (!t || t.pointerId !== e.pointerId || (P.current = null, t.intent !== "swipe" || R === null)) return;
|
|
148
|
+
e.currentTarget.releasePointerCapture?.(e.pointerId), F.current = !0;
|
|
149
|
+
let { trays: n, width: r, rtl: i } = W.current, a = T.velocity(t.samples) * (i ? -1 : 1), o = e.type === "pointercancel" ? {
|
|
150
|
+
open: I,
|
|
151
|
+
full: null
|
|
152
|
+
} : T.settle(R, a, n, r, k);
|
|
153
|
+
z(null), o.full ? (V(o.full), L(null, {
|
|
154
|
+
reason: "swipe",
|
|
155
|
+
event: e
|
|
156
|
+
})) : L(o.open, {
|
|
157
|
+
reason: "swipe",
|
|
158
|
+
event: e
|
|
159
|
+
});
|
|
160
|
+
}), pe = s((e) => {
|
|
161
|
+
if (F.current) {
|
|
162
|
+
F.current = !1, e.preventDefault(), e.stopPropagation();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
I && (e.preventDefault(), e.stopPropagation(), K({
|
|
166
|
+
reason: "outside-pointer",
|
|
167
|
+
event: e
|
|
168
|
+
}));
|
|
169
|
+
}), me = s((e) => {
|
|
170
|
+
let t = M.current?.contains(e.target) ? "start" : N.current?.contains(e.target) ? "end" : null;
|
|
171
|
+
t && t !== I && (G(), L(t, {
|
|
172
|
+
reason: "focus",
|
|
173
|
+
event: e
|
|
174
|
+
}));
|
|
175
|
+
}), he = s((e) => {
|
|
176
|
+
let t = e.relatedTarget;
|
|
177
|
+
I && (!t || !j.current?.contains(t)) && K({
|
|
178
|
+
reason: "focus",
|
|
179
|
+
event: e
|
|
180
|
+
});
|
|
181
|
+
}), ge = s((e) => {
|
|
182
|
+
e.key !== "Escape" || !I || e.defaultPrevented || (e.preventDefault(), K({
|
|
183
|
+
reason: "escape",
|
|
184
|
+
event: e
|
|
185
|
+
}), j.current?.querySelector("[data-list-action]")?.focus());
|
|
186
|
+
}), { trays: J, width: Y, rtl: X } = H, Z = R ?? (B ? B === "start" ? Y : -Y : T.restOffset(I, J)), _e = R === null ? B : T.armed(R, J, Y, k), Q = R !== null, $ = (e, t) => /* @__PURE__ */ S(re, {
|
|
187
|
+
side: e,
|
|
188
|
+
trayRef: e === "start" ? M : N,
|
|
189
|
+
width: e === "start" ? Math.max(0, Z) : Math.max(0, -Z),
|
|
190
|
+
dragging: Q,
|
|
191
|
+
children: /* @__PURE__ */ S(E.Provider, {
|
|
192
|
+
value: {
|
|
193
|
+
side: e,
|
|
194
|
+
armed: _e === e,
|
|
195
|
+
close: K
|
|
196
|
+
},
|
|
197
|
+
children: t
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
return o({
|
|
201
|
+
tag: "li",
|
|
202
|
+
component: "list.item",
|
|
203
|
+
...f({
|
|
204
|
+
...h,
|
|
205
|
+
css: {
|
|
206
|
+
...h.css,
|
|
207
|
+
overflow: "clip"
|
|
208
|
+
}
|
|
209
|
+
}, le),
|
|
210
|
+
variant: [oe, { selected: _ }],
|
|
211
|
+
props: {
|
|
212
|
+
...ce,
|
|
213
|
+
onFocus: me,
|
|
214
|
+
onBlur: he,
|
|
215
|
+
onKeyDown: ge
|
|
216
|
+
},
|
|
217
|
+
children: /* @__PURE__ */ C(x, { children: [
|
|
218
|
+
/* @__PURE__ */ C(ne, {
|
|
219
|
+
size: m,
|
|
220
|
+
wrap: g,
|
|
221
|
+
dragging: Q,
|
|
222
|
+
translate: Z === 0 ? void 0 : `${Math.round(X ? -Z : Z)}px`,
|
|
223
|
+
handlers: {
|
|
224
|
+
onPointerDown: de,
|
|
225
|
+
onPointerMove: fe,
|
|
226
|
+
onPointerUp: q,
|
|
227
|
+
onPointerCancel: q,
|
|
228
|
+
onClickCapture: pe,
|
|
229
|
+
onDragStart: (e) => e.preventDefault()
|
|
230
|
+
},
|
|
231
|
+
children: [se, w && /* @__PURE__ */ S(d.Chevron, {})]
|
|
232
|
+
}),
|
|
233
|
+
D ? $("start", D) : null,
|
|
234
|
+
O ? $("end", O) : null
|
|
235
|
+
] })
|
|
236
|
+
}, ue);
|
|
237
|
+
}
|
|
238
|
+
function ne({ size: e, wrap: t, dragging: n, translate: r, handlers: i, children: a }) {
|
|
239
|
+
return o({
|
|
240
|
+
component: "swipeItem.row",
|
|
241
|
+
...p,
|
|
242
|
+
...m[e],
|
|
243
|
+
...t ? { flexWrap: "wrap" } : {},
|
|
244
|
+
position: "relative",
|
|
245
|
+
css: { touchAction: "pan-y" },
|
|
246
|
+
variant: { dragging: n },
|
|
247
|
+
style: r ? { translate: r } : void 0,
|
|
248
|
+
props: i,
|
|
249
|
+
children: a
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function re({ side: e, trayRef: t, width: n, dragging: r, children: i }) {
|
|
253
|
+
let a = o({
|
|
254
|
+
display: "flex",
|
|
255
|
+
d: e === "end" ? "row-reverse" : "row",
|
|
256
|
+
position: "absolute",
|
|
257
|
+
top: 0,
|
|
258
|
+
bottom: 0,
|
|
259
|
+
...e === "start" ? { insetStart: 0 } : { insetEnd: 0 },
|
|
260
|
+
minWidth: "fit",
|
|
261
|
+
css: { width: "max-content" },
|
|
262
|
+
children: i
|
|
263
|
+
});
|
|
264
|
+
return o({
|
|
265
|
+
component: "swipeItem.tray",
|
|
266
|
+
position: "absolute",
|
|
267
|
+
top: 0,
|
|
268
|
+
bottom: 0,
|
|
269
|
+
...e === "start" ? { insetStart: 0 } : { insetEnd: 0 },
|
|
270
|
+
overflow: "hidden",
|
|
271
|
+
variant: { dragging: r },
|
|
272
|
+
style: { width: `${Math.round(n)}px` },
|
|
273
|
+
children: a
|
|
274
|
+
}, t);
|
|
275
|
+
}
|
|
276
|
+
function O(e, t) {
|
|
277
|
+
let { icon: n, onClick: r, closeOnSelect: i = !0, variant: a, children: s, props: c, ...l } = e, u = _(E), d = (e) => {
|
|
278
|
+
r?.(e), i && !e.defaultPrevented && u?.close({
|
|
279
|
+
reason: "action",
|
|
280
|
+
event: e
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
return o({
|
|
284
|
+
tag: "button",
|
|
285
|
+
component: "swipeItem.action",
|
|
286
|
+
display: "flex",
|
|
287
|
+
d: "column",
|
|
288
|
+
ai: "center",
|
|
289
|
+
jc: "center",
|
|
290
|
+
gap: 1,
|
|
291
|
+
px: 4,
|
|
292
|
+
minWidth: 18,
|
|
293
|
+
flexGrow: 1,
|
|
294
|
+
flexShrink: 0,
|
|
295
|
+
fontSize: 14,
|
|
296
|
+
lineHeight: 18,
|
|
297
|
+
fontWeight: 500,
|
|
298
|
+
cursor: "pointer",
|
|
299
|
+
...l,
|
|
300
|
+
variant: [a, { armed: u?.armed ?? !1 }],
|
|
301
|
+
props: {
|
|
302
|
+
type: "button",
|
|
303
|
+
"data-swipe-action": "",
|
|
304
|
+
...c,
|
|
305
|
+
onClick: d
|
|
306
|
+
},
|
|
307
|
+
children: n ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(k, { children: n }), s] }) : s
|
|
308
|
+
}, t);
|
|
309
|
+
}
|
|
310
|
+
function k({ children: e }) {
|
|
311
|
+
return o({
|
|
312
|
+
tag: "span",
|
|
313
|
+
display: "flex",
|
|
314
|
+
props: { "aria-hidden": !0 },
|
|
315
|
+
children: e
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
var A = e(D, "SwipeItem");
|
|
319
|
+
A.Action = e(O, "SwipeItem.Action");
|
|
320
|
+
//#endregion
|
|
321
|
+
export { T as SwipeUtils, A as default };
|
package/components/tabs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../effects.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.TAB_SELECTOR=`[role="tab"]`,n=e.LIST_SELECTOR=`[role="tablist"]`,r=e.PANEL_SELECTOR=`[role="tabpanel"]`;function i(e,t){return t instanceof Element&&t.closest(n)===e}e.owns=i;function a(e){return e?[...e.querySelectorAll(t)].filter(t=>i(e,t)):[]}e.tabs=a;function o(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=o;function s(e){return e.dataset.value}e.valueOf=s;function c(e){return e.replace(/[^A-Za-z0-9-]/g,e=>`_${e.codePointAt(0).toString(36)}_`)}e.token=c;function l(e,t,n,r){let i=e.length;if(i===0)return;let a=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(a+=n,a<0||a>=i){if(!r)return;a=(a%i+i)%i}if(!o(e[a]))return e[a]}}e.step=l;function u(e,t){return l(e,t===1?-1:e.length,t,!1)}e.edge=u;function d(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=d;function f(e,t,n=!1){if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1};let r=t===`vertical`,i=r?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`,a=r?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`;if(e===i)return{kind:`step`,delta:1};if(e===a)return{kind:`step`,delta:-1}}e.moveFor=f;function p(e,t,n,r){return n.kind===`edge`?u(e,n.delta):l(e,t,n.delta,r)}e.target=p;function m(e){if(e)return a(e).find(e=>e.getAttribute(`aria-selected`)===`true`)}e.selectedTab=m;function h(e,t,n){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();return n===`vertical`?{start:i.top-r.top+e.scrollTop,size:i.height}:{start:i.left-r.left+e.scrollLeft,size:i.width}}e.bounds=h;function g(e,t){return!e||!t?e===t:e.start===t.start&&e.size===t.size}e.sameBounds=g;function _(e){if(e)return[...e.querySelectorAll(r)].find(e=>!e.hasAttribute(`hidden`))}e.visiblePanel=_})(c||={});var l=c,u=(0,o.createContext)(null);function d(e){let t=(0,o.useContext)(u);if(!t)throw Error(`<${e}> has to be rendered inside a <Tabs>.`);return t}function f(e){let{children:a,value:c,defaultValue:d,onValueChange:f,orientation:p=`horizontal`,activation:m=`automatic`,loop:h=!0,keepMounted:g=!1,indicator:_=`static`,props:v,...y}=e,b=i.t(`tabs`),[x,S]=r.i({value:c,defaultValue:d,onChange:f}),[C,w]=(0,o.useState)(),[T,E]=(0,o.useState)(!1);t.n(()=>{x!==void 0&&w(x)},[x]);let D=(0,o.useMemo)(()=>({identifier:b,value:x,orientation:p,activation:m,loop:h,keepMounted:g,indicator:_,indicatorLive:T,setIndicatorLive:E,tabStop:C??x,setTabStop:w,select:S,tabId:e=>`${b}-tab-${l.token(e)}`,panelId:e=>`${b}-panel-${l.token(e)}`}),[b,x,p,m,h,g,_,T,C,S]);return(0,s.jsx)(u.Provider,{value:D,children:(0,s.jsx)(n.default,{component:`tabs`,...y,variant:[y.variant,{vertical:p===`vertical`}],props:v,children:a})})}function p(i){let{children:a,label:c,labelledBy:u,props:f,...p}=i,{value:m,orientation:h,activation:g,loop:_,indicator:v,tabStop:y,setTabStop:b,setIndicatorLive:x,select:S}=d(`Tabs.List`),C=(0,o.useRef)(null),[w,T]=(0,o.useState)(),E=v===`sliding`;t.n(()=>{let e=C.current;if(!E||!e)return;let t=()=>{let t=l.selectedTab(e),n=t&&l.bounds(e,t,h);T(e=>l.sameBounds(e,n)?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of l.tabs(e))n.observe(t);return()=>n.disconnect()},[E,h,m]);let D=E&&w&&w.size>0?w:void 0;t.n(()=>{x(D!==void 0)},[D,x]),t.n(()=>{if(y!==void 0)return;let e=l.edge(l.tabs(C.current),1),t=e&&l.valueOf(e);t!==void 0&&b(t)},[y,b]);let O=r.a(t=>{let n=C.current;if(!n||t.defaultPrevented||!l.owns(n,t.target))return;let r=l.tabs(n),i=l.indexOf(r,t.target);if(i===-1)return;if(g===`manual`&&(t.key===`Enter`||t.key===` `)){let e=l.valueOf(r[i]);if(e===void 0)return;t.preventDefault(),S(e,{reason:`keyboard`,event:t});return}let a=l.moveFor(t.key,h,e.
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../effects.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.TAB_SELECTOR=`[role="tab"]`,n=e.LIST_SELECTOR=`[role="tablist"]`,r=e.PANEL_SELECTOR=`[role="tabpanel"]`;function i(e,t){return t instanceof Element&&t.closest(n)===e}e.owns=i;function a(e){return e?[...e.querySelectorAll(t)].filter(t=>i(e,t)):[]}e.tabs=a;function o(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=o;function s(e){return e.dataset.value}e.valueOf=s;function c(e){return e.replace(/[^A-Za-z0-9-]/g,e=>`_${e.codePointAt(0).toString(36)}_`)}e.token=c;function l(e,t,n,r){let i=e.length;if(i===0)return;let a=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(a+=n,a<0||a>=i){if(!r)return;a=(a%i+i)%i}if(!o(e[a]))return e[a]}}e.step=l;function u(e,t){return l(e,t===1?-1:e.length,t,!1)}e.edge=u;function d(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=d;function f(e,t,n=!1){if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1};let r=t===`vertical`,i=r?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`,a=r?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`;if(e===i)return{kind:`step`,delta:1};if(e===a)return{kind:`step`,delta:-1}}e.moveFor=f;function p(e,t,n,r){return n.kind===`edge`?u(e,n.delta):l(e,t,n.delta,r)}e.target=p;function m(e){if(e)return a(e).find(e=>e.getAttribute(`aria-selected`)===`true`)}e.selectedTab=m;function h(e,t,n){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();return n===`vertical`?{start:i.top-r.top+e.scrollTop,size:i.height}:{start:i.left-r.left+e.scrollLeft,size:i.width}}e.bounds=h;function g(e,t){return!e||!t?e===t:e.start===t.start&&e.size===t.size}e.sameBounds=g;function _(e){if(e)return[...e.querySelectorAll(r)].find(e=>!e.hasAttribute(`hidden`))}e.visiblePanel=_})(c||={});var l=c,u=(0,o.createContext)(null);function d(e){let t=(0,o.useContext)(u);if(!t)throw Error(`<${e}> has to be rendered inside a <Tabs>.`);return t}function f(e){let{children:a,value:c,defaultValue:d,onValueChange:f,orientation:p=`horizontal`,activation:m=`automatic`,loop:h=!0,keepMounted:g=!1,indicator:_=`static`,props:v,...y}=e,b=i.t(`tabs`),[x,S]=r.i({value:c,defaultValue:d,onChange:f}),[C,w]=(0,o.useState)(),[T,E]=(0,o.useState)(!1);t.n(()=>{x!==void 0&&w(x)},[x]);let D=(0,o.useMemo)(()=>({identifier:b,value:x,orientation:p,activation:m,loop:h,keepMounted:g,indicator:_,indicatorLive:T,setIndicatorLive:E,tabStop:C??x,setTabStop:w,select:S,tabId:e=>`${b}-tab-${l.token(e)}`,panelId:e=>`${b}-panel-${l.token(e)}`}),[b,x,p,m,h,g,_,T,C,S]);return(0,s.jsx)(u.Provider,{value:D,children:(0,s.jsx)(n.default,{component:`tabs`,...y,variant:[y.variant,{vertical:p===`vertical`}],props:v,children:a})})}function p(i){let{children:a,label:c,labelledBy:u,props:f,...p}=i,{value:m,orientation:h,activation:g,loop:_,indicator:v,tabStop:y,setTabStop:b,setIndicatorLive:x,select:S}=d(`Tabs.List`),C=(0,o.useRef)(null),[w,T]=(0,o.useState)(),E=v===`sliding`;t.n(()=>{let e=C.current;if(!E||!e)return;let t=()=>{let t=l.selectedTab(e),n=t&&l.bounds(e,t,h);T(e=>l.sameBounds(e,n)?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of l.tabs(e))n.observe(t);return()=>n.disconnect()},[E,h,m]);let D=E&&w&&w.size>0?w:void 0;t.n(()=>{x(D!==void 0)},[D,x]),t.n(()=>{if(y!==void 0)return;let e=l.edge(l.tabs(C.current),1),t=e&&l.valueOf(e);t!==void 0&&b(t)},[y,b]);let O=r.a(t=>{let n=C.current;if(!n||t.defaultPrevented||!l.owns(n,t.target))return;let r=l.tabs(n),i=l.indexOf(r,t.target);if(i===-1)return;if(g===`manual`&&(t.key===`Enter`||t.key===` `)){let e=l.valueOf(r[i]);if(e===void 0)return;t.preventDefault(),S(e,{reason:`keyboard`,event:t});return}let a=l.moveFor(t.key,h,e.d(n));if(!a)return;let o=l.target(r,i,a,_);if(!o)return;t.preventDefault(),o.focus();let s=l.valueOf(o);g===`automatic`&&s!==void 0&&S(s,{reason:`keyboard`,event:t})});return(0,s.jsxs)(n.default,{ref:C,component:`tabs.list`,...p,variant:[p.variant,{vertical:h===`vertical`,sliding:E}],props:{role:`tablist`,"aria-label":c,"aria-labelledby":u,"aria-orientation":h,...f,onKeyDown:O},children:[a,D&&(0,s.jsx)(n.default,{tag:`span`,component:`tabs.indicator`,variant:{vertical:h===`vertical`},style:h===`vertical`?{top:`${D.start}px`,height:`${D.size}px`}:{left:`${D.start}px`,width:`${D.size}px`},props:{"aria-hidden":!0}})]})}p.displayName=`Tabs.List`;function m(e){let{value:t,children:i,disabled:a,props:o,...c}=e,{value:l,orientation:u,keepMounted:f,indicatorLive:p,tabStop:m,setTabStop:h,select:g,tabId:_,panelId:v}=d(`Tabs.Tab`),y=l===t,b=r.a(e=>g(t,{reason:`click`,event:e})),x=r.a(()=>h(t));return(0,s.jsx)(n.default,{tag:`button`,component:`tabs.tab`,...c,variant:[c.variant,{vertical:u===`vertical`,underline:!p}],disabled:a,id:_(t),props:{type:`button`,role:`tab`,"aria-selected":y,"aria-controls":y||f?v(t):void 0,tabIndex:m===t?0:-1,"data-value":t,...o,onClick:b,onFocus:x},children:i})}m.displayName=`Tabs.Tab`;function h(e){let{children:i,props:c,...u}=e,{value:f}=d(`Tabs.Panels`),p=(0,o.useRef)(null),[m,h]=(0,o.useState)(),[g,_]=(0,o.useState)(!1),v=r.a(()=>{let e=p.current;if(!e)return;let t=l.visiblePanel(e)?.offsetHeight;t!==m&&(m!==void 0&&t!==void 0&&_(!0),h(t))});return t.n(()=>{let e=p.current;if(!e||(v(),typeof ResizeObserver>`u`))return;let t=l.visiblePanel(e);if(!t)return;let n=new ResizeObserver(v);return n.observe(t),()=>n.disconnect()},[f,v]),t.n(()=>{let e=p.current;if(!e||!g)return;let t=setTimeout(()=>_(!1),a.n.activeDuration(getComputedStyle(e))+a.n.SETTLE_FRAME);return()=>clearTimeout(t)},[g,m]),(0,s.jsx)(n.default,{ref:p,component:`tabs.panels`,...u,variant:[u.variant,{resizing:g}],style:{height:m===void 0?void 0:`${m}px`,...u.style},props:c,children:i})}h.displayName=`Tabs.Panels`;function g(e){let{value:t,children:r,props:i,...a}=e,{value:o,keepMounted:c,tabId:l,panelId:u}=d(`Tabs.Panel`),f=o===t;return!f&&!c?null:(0,s.jsx)(n.default,{component:`tabs.panel`,...a,variant:[a.variant,{hidden:!f}],id:u(t),props:{role:`tabpanel`,"aria-labelledby":l(t),hidden:!f||void 0,tabIndex:0,...i},children:r})}g.displayName=`Tabs.Panel`;var _=f;_.List=p,_.Tab=m,_.Panels=h,_.Panel=g,_.displayName=`Tabs`,exports.default=_;
|
package/components/tabs.mjs
CHANGED
package/components/toaster.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../client.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../layer.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime"),c=require("react-dom"),l=require("use-sync-external-store/shim");var u={toasts:[],overflow:0},d=0;function f(){return d+=1,`toast-${d}`}function p(e){let t=[],n=u,r=e?.limit??3,i=e?.duration??5e3,a=!1,o=new Set,s=new Map,c=e=>{let t=s.get(e);t?.handle&&clearTimeout(t.handle),s.delete(e)},l=()=>{let e=0;t=t.map(t=>{let n=!t.open||e++<r;return t.visible===n?t:{...t,visible:n}}),n={toasts:t,overflow:Math.max(0,e-r)},d(),o.forEach(e=>e())};function d(){let e=new Set;for(let n of t){if(!n.open||!n.visible||!Number.isFinite(n.duration))continue;e.add(n.id);let t=s.get(n.id)??{handle:null,remaining:n.duration,startedAt:0};s.set(n.id,t),!(a||t.handle)&&(t.startedAt=Date.now(),t.handle=setTimeout(()=>{s.delete(n.id),m(n.id,`timeout`)},t.remaining))}for(let t of[...s.keys()])e.has(t)||c(t)}let p=(e,t)=>t??(e===`loading`?1/0:i);function m(e,n=`imperative`){let r=[];t=t.map(t=>!t.open||e!==void 0&&t.id!==e?t:(r.push(t),c(t.id),{...t,open:!1})),r.length&&(l(),r.forEach(e=>e.onDismiss?.(n)))}function h(e,n,r){let i=!1;t=t.map(t=>{if(t.id!==e)return t;i=!0,c(e);let a=r?.kind??t.kind;return{...t,...r,id:e,message:n,kind:a,duration:r?.duration??(r?.kind?p(a):t.duration),open:!0}}),i&&l()}function g(e,n){let r=n?.id??f();if(n?.id&&t.some(e=>e.id===r))return h(r,e,n),r;let i=n?.kind??`default`;return t=[...t,{id:r,kind:i,message:e,description:n?.description,duration:p(i,n?.duration),action:n?.action,dismissible:n?.dismissible??!0,onDismiss:n?.onDismiss,open:!0,visible:!1}],l(),r}return{subscribe(e){return o.add(e),()=>o.delete(e)},getSnapshot:()=>n,getServerSnapshot:()=>u,add:g,update:h,dismiss:m,remove(e){let n=t.filter(t=>t.id!==e);n.length!==t.length&&(c(e),t=n,l())},setLimit(e){e!==r&&(r=e,l())},setDefaultDuration(e){i=e},pause(){if(!a){a=!0;for(let e of s.values())e.handle&&(clearTimeout(e.handle),e.handle=null,e.remaining=Math.max(0,e.remaining-(Date.now()-e.startedAt)))}},resume(){a&&(a=!1,d())},reset(){for(let e of[...s.keys()])c(e);t=[],n=u,o.forEach(e=>e())}}}var m=p(),h=e=>(t,n)=>m.add(t,{...n,kind:e}),g=Object.assign((e,t)=>m.add(e,t),{success:h(`success`),error:h(`error`),warning:h(`warning`),info:h(`info`),loading:h(`loading`),update:(e,t,n)=>m.update(e,t,n),dismiss:e=>m.dismiss(e,`imperative`),promise(e,t,n){let r=m.add(t.loading,{...n,id:n?.id,kind:`loading`}),i=(e,t)=>typeof e==`function`?e(t):e;return e.then(e=>m.update(r,i(t.success,e),{kind:`success`}),e=>m.update(r,i(t.error,e),{kind:`error`})),e}}),_={"top-start":`topStart`,"top-center":`topCenter`,"top-end":`topEnd`,"bottom-start":`bottomStart`,"bottom-center":`bottomCenter`,"bottom-end":`bottomEnd`};function v(e,t){let n=t.toLowerCase().split(`+`),r=n[n.length-1],i=new Set(n.slice(0,-1));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`)}function y(e){let{toast:t,store:i,fromTop:o,closeLabel:c}=e,{mounted:l,ref:u,props:d}=a.t({present:t.open});if(n.n(()=>{l||i.remove(t.id)},[l,i,t.id]),!l)return null;let f=t.action,p=()=>{f?.onClick(),f?.closeOnClick!==!1&&i.dismiss(t.id,`action`)};return(0,s.jsxs)(r.default,{ref:u,component:`toaster.toast`,variant:{[t.kind]:t.kind!=="default",fromTop:o},props:{...t.kind===`error`?{role:`alert`}:{},"data-toast-id":t.id,...d},children:[(0,s.jsx)(r.default,{component:`toaster.message`,children:t.message}),t.description!==void 0&&(0,s.jsx)(r.default,{component:`toaster.description`,children:t.description}),f&&(0,s.jsx)(r.default,{tag:`button`,component:`toaster.action`,props:{type:`button`,onClick:p},children:f.label}),t.dismissible&&(0,s.jsx)(r.default,{tag:`button`,component:`toaster.close`,props:{type:`button`,"aria-label":c,onClick:()=>i.dismiss(t.id,`close`)}})]})}function b(a){let{position:u=`bottom-end`,limit:d=3,duration:f=5e3,label:p=`Notifications`,closeLabel:h=`Close`,overflowLabel:g=e=>`+${e} more`,hotkey:b=`F6`,store:x=m,props:S,...C}=a,w=(0,l.useSyncExternalStore)(x.subscribe,x.getSnapshot,x.getServerSnapshot),T=i.n(),E=e.n(!T),D=(0,o.useRef)(null),O=(0,o.useRef)(null),k=(0,o.useRef)({hovered:!1,focused:!1,hidden:!1}),A=(0,o.useCallback)(()=>{let{hovered:e,focused:t,hidden:n}=k.current;e||t||n?x.pause():x.resume()},[x]);n.n(()=>x.setLimit(d),[x,d]),n.n(()=>x.setDefaultDuration(f),[x,f]),n.n(()=>{let e=D.current;!T||!t.o()||!e||!e.isConnected||e.matches(`:popover-open`)||e.showPopover()}),n.n(()=>{let e=t.t();if(!e)return;let n=new AbortController;return e.addEventListener(`visibilitychange`,()=>{k.current.hidden=e.hidden,A()},{signal:n.signal}),()=>n.abort()},[A]),n.n(()=>{let e=t.t();if(!b||!e)return;let n=new AbortController;return e.addEventListener(`keydown`,t=>{!v(t,b)||!D.current||(t.preventDefault(),O.current=e.activeElement,D.current.focus())},{signal:n.signal}),()=>n.abort()},[b]);let j=e=>!!e&&!!D.current?.contains(e),M=()=>{k.current.hovered=!0,A()},N=e=>{j(e.relatedTarget)||(k.current.hovered=!1,A())},P=e=>{k.current.focused=!0,A(),j(e.relatedTarget)||(O.current=e.relatedTarget)},F=e=>{j(e.relatedTarget)||(k.current.focused=!1,A())},I=e=>{if(e.key!==`Escape`)return;let t=(e.target.closest?.(`[data-toast-id]`))?.getAttribute(`data-toast-id`);t&&x.dismiss(t,`close`),x.getSnapshot().toasts.some(e=>e.open)?D.current?.focus():O.current?.focus()},L=u.startsWith(`top`),R=w.toasts.filter(e=>e.visible),z=L?[...R].reverse():R,B=w.overflow>0&&(0,s.jsx)(r.default,{component:`toaster.overflow`,children:g(w.overflow)}),V=(0,s.jsxs)(r.default,{tag:`section`,ref:D,component:`toaster`,...C,variant:[C.variant,{[_[u]]:!0}],props:{...T?{popover:`manual`}:{},"aria-live":`polite`,"aria-atomic":`false`,"aria-relevant":`additions text`,"aria-label":p,tabIndex:-1,...S,onPointerOver:M,onPointerOut:N,onFocus:P,onBlur:F,onKeyDown:I},children:[!L&&B,z.map(e=>(0,s.jsx)(y,{toast:e,store:x,fromTop:L,closeLabel:h},e.id)),L&&B]});return T?V:E?(0,c.createPortal)(V,E):null}var x=b;x.displayName=`Toaster`,exports.createToastStore=p,exports.default=x,exports.defaultToastStore=m,exports.toast=g;
|
package/components/toaster.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { t as n } from "../
|
|
2
|
+
import { n as e } from "../client.mjs";
|
|
3
|
+
import { o as t, t as n } from "../platform.mjs";
|
|
4
4
|
import { n as r } from "../effects.mjs";
|
|
5
5
|
import i from "../box.mjs";
|
|
6
6
|
import { n as a } from "../layer.mjs";
|
|
7
7
|
import { t as o } from "../motion.mjs";
|
|
8
8
|
import { useCallback as s, useRef as c } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal as d } from "react-dom";
|
|
11
11
|
import { useSyncExternalStore as f } from "use-sync-external-store/shim";
|
|
12
12
|
//#region src/utils/toast/toastStore.ts
|
|
13
13
|
var p = {
|
|
@@ -160,7 +160,7 @@ function x(e, t) {
|
|
|
160
160
|
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");
|
|
161
161
|
}
|
|
162
162
|
function S(e) {
|
|
163
|
-
let { toast: t, store: n, fromTop: a, closeLabel: s } = e, { mounted: c, ref:
|
|
163
|
+
let { toast: t, store: n, fromTop: a, closeLabel: s } = e, { mounted: c, ref: d, props: f } = o({ present: t.open });
|
|
164
164
|
if (r(() => {
|
|
165
165
|
c || n.remove(t.id);
|
|
166
166
|
}, [
|
|
@@ -171,8 +171,8 @@ function S(e) {
|
|
|
171
171
|
let p = t.action, m = () => {
|
|
172
172
|
p?.onClick(), p?.closeOnClick !== !1 && n.dismiss(t.id, "action");
|
|
173
173
|
};
|
|
174
|
-
return /* @__PURE__ */
|
|
175
|
-
ref:
|
|
174
|
+
return /* @__PURE__ */ u(i, {
|
|
175
|
+
ref: d,
|
|
176
176
|
component: "toaster.toast",
|
|
177
177
|
variant: {
|
|
178
178
|
[t.kind]: t.kind !== "default",
|
|
@@ -184,15 +184,15 @@ function S(e) {
|
|
|
184
184
|
...f
|
|
185
185
|
},
|
|
186
186
|
children: [
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ l(i, {
|
|
188
188
|
component: "toaster.message",
|
|
189
189
|
children: t.message
|
|
190
190
|
}),
|
|
191
|
-
t.description !== void 0 && /* @__PURE__ */
|
|
191
|
+
t.description !== void 0 && /* @__PURE__ */ l(i, {
|
|
192
192
|
component: "toaster.description",
|
|
193
193
|
children: t.description
|
|
194
194
|
}),
|
|
195
|
-
p && /* @__PURE__ */
|
|
195
|
+
p && /* @__PURE__ */ l(i, {
|
|
196
196
|
tag: "button",
|
|
197
197
|
component: "toaster.action",
|
|
198
198
|
props: {
|
|
@@ -201,7 +201,7 @@ function S(e) {
|
|
|
201
201
|
},
|
|
202
202
|
children: p.label
|
|
203
203
|
}),
|
|
204
|
-
t.dismissible && /* @__PURE__ */
|
|
204
|
+
t.dismissible && /* @__PURE__ */ l(i, {
|
|
205
205
|
tag: "button",
|
|
206
206
|
component: "toaster.close",
|
|
207
207
|
props: {
|
|
@@ -214,7 +214,7 @@ function S(e) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
function C(o) {
|
|
217
|
-
let { position: p = "bottom-end", limit: m = 3, duration: h = 5e3, label: g = "Notifications", closeLabel: v = "Close", overflowLabel: y = (e) => `+${e} more`, hotkey: C = "F6", store: w = _, props: T, ...E } = o, D = f(w.subscribe, w.getSnapshot, w.getServerSnapshot), O = a(), k =
|
|
217
|
+
let { position: p = "bottom-end", limit: m = 3, duration: h = 5e3, label: g = "Notifications", closeLabel: v = "Close", overflowLabel: y = (e) => `+${e} more`, hotkey: C = "F6", store: w = _, props: T, ...E } = o, D = f(w.subscribe, w.getSnapshot, w.getServerSnapshot), O = a(), k = e(!O), A = c(null), j = c(null), M = c({
|
|
218
218
|
hovered: !1,
|
|
219
219
|
focused: !1,
|
|
220
220
|
hidden: !1
|
|
@@ -223,22 +223,22 @@ function C(o) {
|
|
|
223
223
|
e || t || n ? w.pause() : w.resume();
|
|
224
224
|
}, [w]);
|
|
225
225
|
r(() => w.setLimit(m), [w, m]), r(() => w.setDefaultDuration(h), [w, h]), r(() => {
|
|
226
|
-
let
|
|
227
|
-
!O || !
|
|
226
|
+
let e = A.current;
|
|
227
|
+
!O || !t() || !e || !e.isConnected || e.matches(":popover-open") || e.showPopover();
|
|
228
228
|
}), r(() => {
|
|
229
|
-
let e =
|
|
229
|
+
let e = n();
|
|
230
230
|
if (!e) return;
|
|
231
|
-
let
|
|
231
|
+
let t = new AbortController();
|
|
232
232
|
return e.addEventListener("visibilitychange", () => {
|
|
233
233
|
M.current.hidden = e.hidden, N();
|
|
234
|
-
}, { signal:
|
|
234
|
+
}, { signal: t.signal }), () => t.abort();
|
|
235
235
|
}, [N]), r(() => {
|
|
236
|
-
let e =
|
|
236
|
+
let e = n();
|
|
237
237
|
if (!C || !e) return;
|
|
238
|
-
let
|
|
238
|
+
let t = new AbortController();
|
|
239
239
|
return e.addEventListener("keydown", (t) => {
|
|
240
240
|
!x(t, C) || !A.current || (t.preventDefault(), j.current = e.activeElement, A.current.focus());
|
|
241
|
-
}, { signal:
|
|
241
|
+
}, { signal: t.signal }), () => t.abort();
|
|
242
242
|
}, [C]);
|
|
243
243
|
let P = (e) => !!e && !!A.current?.contains(e), F = () => {
|
|
244
244
|
M.current.hovered = !0, N();
|
|
@@ -252,10 +252,10 @@ function C(o) {
|
|
|
252
252
|
if (e.key !== "Escape") return;
|
|
253
253
|
let t = (e.target.closest?.("[data-toast-id]"))?.getAttribute("data-toast-id");
|
|
254
254
|
t && w.dismiss(t, "close"), w.getSnapshot().toasts.some((e) => e.open) ? A.current?.focus() : j.current?.focus();
|
|
255
|
-
}, B = p.startsWith("top"), V = D.toasts.filter((e) => e.visible), H = B ? [...V].reverse() : V, U = D.overflow > 0 && /* @__PURE__ */
|
|
255
|
+
}, B = p.startsWith("top"), V = D.toasts.filter((e) => e.visible), H = B ? [...V].reverse() : V, U = D.overflow > 0 && /* @__PURE__ */ l(i, {
|
|
256
256
|
component: "toaster.overflow",
|
|
257
257
|
children: y(D.overflow)
|
|
258
|
-
}), W = /* @__PURE__ */
|
|
258
|
+
}), W = /* @__PURE__ */ u(i, {
|
|
259
259
|
tag: "section",
|
|
260
260
|
ref: A,
|
|
261
261
|
component: "toaster",
|
|
@@ -277,7 +277,7 @@ function C(o) {
|
|
|
277
277
|
},
|
|
278
278
|
children: [
|
|
279
279
|
!B && U,
|
|
280
|
-
H.map((e) => /* @__PURE__ */
|
|
280
|
+
H.map((e) => /* @__PURE__ */ l(S, {
|
|
281
281
|
toast: e,
|
|
282
282
|
store: w,
|
|
283
283
|
fromTop: B,
|
|
@@ -286,7 +286,7 @@ function C(o) {
|
|
|
286
286
|
B && U
|
|
287
287
|
]
|
|
288
288
|
});
|
|
289
|
-
return O ? W : k ?
|
|
289
|
+
return O ? W : k ? d(W, k) : null;
|
|
290
290
|
}
|
|
291
291
|
var w = C;
|
|
292
292
|
w.displayName = "Toaster";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../effects.cjs"),n=require("../behavior.cjs"),r=require("../scrolling.cjs"),i=require("./list.cjs");let a=require("react"),o=require("react/jsx-runtime");function s(e,t,n){return Math.min(Math.max(e,t),n)}var c;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.PIN_REACH=50;function i(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=i;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:i,viewStart:a,viewEnd:o,overscan:c=t,pin:l=-1}=e,u=i.length-1,d=i[u]??0;if(u<=0)return{startIndex:0,endIndex:0,offsetY:0,totalHeight:0};let f=s(r.n(i,a,u)-c,0,u-1),p=s(r.n(i,o-.5,u)+1+c,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:i[f],totalHeight:d}}e.measuredWindow=o})(c||={});var l=c;function u(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 d=150;function f(e,s){let{items:c,itemKey:f,children:p,estimateSize:m=57,overscan:h=6,initialCount:g=20,onRangeChange:_,scrollerRef:v,vars:y,css:b,props:x,...S}=e,C=(0,a.useRef)(null),[w,T]=(0,a.useState)(()=>new Map),[,E]=(0,a.useState)(0),[D,O]=(0,a.useState)({startIndex:0,endIndex:Math.min(g,c.length)}),[k,A]=(0,a.useState)(-1),j=n.a(_),M=(0,a.useCallback)(e=>{C.current=e,typeof s==`function`?s(e):s&&(s.current=e)},[s]),[N,P]=(0,a.useState)(null),F=(0,a.useMemo)(()=>c.map((e,t)=>f(e,t)),[c,f]),I=(0,a.useMemo)(()=>l.typicalSize(w.values(),m),[w,m]),L=N?.count===c.length?N:null,R=L?L.estimate:I,z=(0,a.useMemo)(()=>l.offsetsOf(F.map(e=>w.get(e)??R)),[F,w,R]),B=z[c.length],V=n.o({offsets:z,pin:k,overscan:h,count:c.length,total:B,estimate:R}),H=(0,a.useRef)(null),U=Math.min(D.startIndex,Math.max(0,c.length-1)),W=Math.min(Math.max(D.endIndex,U),c.length),G=n.a(()=>{let e=C.current,{offsets:t,pin:n,overscan:i,count:a}=V.current;if(!e||a===0)return;let o=v?.current??r.t(e),s=e.ownerDocument.defaultView,c=o?o.getBoundingClientRect().top+o.clientTop:0,u=o?o.clientHeight:s?.innerHeight??0,d=e.getBoundingClientRect().top+e.clientTop,f=l.measuredWindow({offsets:t,viewStart:c-d,viewEnd:c-d+u,overscan:i,pin:n});O(e=>e.startIndex===f.startIndex&&e.endIndex===f.endIndex?e:{startIndex:f.startIndex,endIndex:f.endIndex})});t.n(()=>{let e=C.current;if(!e)return;let t=null,n=0,i=v?.current??r.t(e),a=i?i.getBoundingClientRect().top:0,o=parseFloat(getComputedStyle(e).rowGap)||0,s=H.current;if(H.current=null,s?.element.isConnected&&(n+=s.element.getBoundingClientRect().top-s.top),Array.from(e.children).forEach((e,r)=>{let i=U+r,s=F[i];if(s===void 0)return;e.setAttribute(`aria-setsize`,String(c.length)),e.setAttribute(`aria-posinset`,String(i+1));let l=e.getBoundingClientRect(),u=l.height+o,d=w.get(s)??R;l.height>0&&w.get(s)!==u&&(t??=new Map(w),t.set(s,u),l.bottom<=a&&(n+=u-d))}),n!==0){let t=i??e.ownerDocument.defaultView,r=i?i.scrollTop:t?.scrollY??0;t?.scrollTo({top:r+n,behavior:`instant`})}t?(H.current=u(e,a),T(t)):G()}),(0,a.useEffect)(()=>{let e=C.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>E(e=>e+1));return Array.from(e.children).forEach(e=>t.observe(e)),()=>t.disconnect()},[D,F]),(0,a.useEffect)(()=>{let e=C.current,t=e?.ownerDocument.defaultView;if(!e||!t)return;let n=v?.current??r.t(e),i=n??t,a=0,o=!1,s=0,c=()=>{a||=requestAnimationFrame(()=>(a=0,G()))},l=()=>{let{count:r,total:i,estimate:a}=V.current;P(e=>e??{count:r,total:i,estimate:a}),clearTimeout(s),s=t.setTimeout(()=>{o||(H.current=u(e,n?n.getBoundingClientRect().top:0),P(null))},d)},f=()=>{l(),c()},p=()=>{o=!0,l()},m=()=>{o&&(o=!1,l())};i.addEventListener(`scroll`,f,{passive:!0}),i.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),i.removeEventListener(`scroll`,f),i.removeEventListener(`pointerdown`,p,!0),t.removeEventListener(`pointerup`,m,!0),t.removeEventListener(`pointercancel`,m,!0),t.removeEventListener(`resize`,c),h?.disconnect()}},[v,G,V]),(0,a.useEffect)(()=>{j({startIndex:D.startIndex,endIndex:D.endIndex})},[D,j]);let K=e=>{let t=C.current,n=Array.from(t?.children??[]).findIndex(t=>t.contains(e.target));n>=0&&A(U+n)},q=e=>{C.current?.contains(e.relatedTarget)||A(-1)},J=[];for(let e=U;e<W;e++)J.push((0,o.jsx)(a.Fragment,{children:p(c[e],e)},F[e]));return(0,o.jsx)(i.default,{ref:M,...S,vars:U>0?{...y,"list-first-divider":`block`}:y,css:{...b,overflowAnchor:`none`},transition:`none`,style:{paddingBlockStart:`${z[U]}px`,paddingBlockEnd:`${Math.max(0,(L&&W<c.length?L.total:B)-z[W])}px`},props:{...x,onFocus:K,onBlur:q},children:J})}var p=e.f(f,`VirtualList`);exports.default=p;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Key, RefAttributes } from 'react';
|
|
2
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
3
|
+
import { ListProps } from './list';
|
|
4
|
+
export interface VirtualListRange {
|
|
5
|
+
/** The first item rendered. */
|
|
6
|
+
startIndex: number;
|
|
7
|
+
/** One past the last item rendered. */
|
|
8
|
+
endIndex: number;
|
|
9
|
+
}
|
|
10
|
+
export interface VirtualListProps<TItem, TKey extends keyof ComponentsAndVariants = 'list'> extends Omit<ListProps<TKey>, 'children'> {
|
|
11
|
+
/** Every item, however many — only the ones near the screen are rendered. */
|
|
12
|
+
items: readonly TItem[];
|
|
13
|
+
/** Who an item is: stable across renders, since an item's measured height is kept under it. */
|
|
14
|
+
itemKey: (item: TItem, index: number) => Key;
|
|
15
|
+
/** Draws one item: a `List.Item`, a `SwipeItem` — one `<li>` per item, and nothing around it. */
|
|
16
|
+
children: (item: TItem, index: number) => React.ReactNode;
|
|
17
|
+
/** What an item counts as until one has been drawn, in px — then the mean of those drawn. Default 57, a `md` item. */
|
|
18
|
+
estimateSize?: number;
|
|
19
|
+
/** Items kept either side of what is on screen, so a fast scroll has something to show. Default 6. */
|
|
20
|
+
overscan?: number;
|
|
21
|
+
/** How many items render before anything is measured — on a server, and in the first frame. Default 20. */
|
|
22
|
+
initialCount?: number;
|
|
23
|
+
/** Fires when the rendered range moves. The way to fetch more: load the next page when `endIndex` nears the end. */
|
|
24
|
+
onRangeChange?: (range: VirtualListRange) => void;
|
|
25
|
+
/** What scrolls the list, when it is not the nearest scrolling ancestor — or, with none, the page. */
|
|
26
|
+
scrollerRef?: React.RefObject<HTMLElement | null>;
|
|
27
|
+
}
|
|
28
|
+
type VirtualListType = (<TItem, TKey extends keyof ComponentsAndVariants = 'list'>(props: VirtualListProps<TItem, TKey> & RefAttributes<HTMLUListElement>) => React.ReactNode) & {
|
|
29
|
+
displayName?: string;
|
|
30
|
+
};
|
|
31
|
+
declare const VirtualList: VirtualListType;
|
|
32
|
+
export default VirtualList;
|