@box-kite/react 2.2.7 → 2.2.9
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/BOX_AI_CONTEXT.md +76 -0
- package/BOX_KITE_AI_CONTEXT.md +76 -0
- package/analytics.cjs +1 -0
- package/analytics.d.ts +10 -0
- package/analytics.mjs +121 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +42 -38
- package/box.cjs +1 -1
- package/box.d.ts +9 -0
- package/box.mjs +17 -16
- package/catalog.cjs +1 -1
- package/catalog.mjs +8 -0
- package/client.cjs +1 -1
- package/client.mjs +120 -120
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +19 -10
- package/components/agent.cjs +1 -1
- package/components/agent.mjs +21 -8
- package/components/calendar.cjs +1 -1
- package/components/calendar.d.ts +3 -1
- package/components/calendar.mjs +154 -142
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +184 -174
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +183 -170
- package/components/dataGrid/models/columnModel.d.ts +1 -0
- package/components/dataGrid/models/gridModel.d.ts +18 -0
- package/components/dataGrid/models/rangeModel.d.ts +3 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +987 -896
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +160 -149
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +226 -206
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +38 -33
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.mjs +107 -93
- package/components/form.cjs +1 -1
- package/components/form.mjs +22 -18
- package/components/menu.cjs +1 -1
- package/components/menu.d.ts +2 -0
- package/components/menu.mjs +196 -175
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +7 -7
- package/components/popover.cjs +1 -1
- package/components/popover.mjs +4 -0
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +10 -5
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +84 -83
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +158 -150
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +92 -84
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +10 -5
- package/components/timeZoneSelect.cjs +1 -1
- package/components/timeZoneSelect.mjs +40 -35
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +151 -113
- package/dataGridDateParts.cjs +1 -1
- package/dataGridDateParts.mjs +56 -55
- package/dataGridList.cjs +1 -1
- package/dataGridList.mjs +430 -429
- package/effects.cjs +1 -1
- package/effects.mjs +1 -1
- package/interactionListening.cjs +1 -0
- package/interactionListening.mjs +117 -0
- package/interactions.cjs +1 -0
- package/interactions.mjs +25 -0
- package/layer.cjs +1 -1
- package/layer.mjs +68 -66
- package/package.json +132 -68
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +44 -25
- package/react/interactions/interactions.d.ts +30 -0
- package/react/popover/usePopoverLayer.d.ts +3 -0
- package/react/useStyles.d.ts +8 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +49 -48
- package/reporting.cjs +1 -0
- package/reporting.mjs +51 -0
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/supabase/functions/collect/index.d.ts +30 -0
- package/supabase/functions/collect/index.test.d.ts +1 -0
- package/utils/analytics/analytics.d.ts +72 -0
- package/utils/analytics/analyticsIdentity.d.ts +13 -0
- package/utils/interactions/componentAttribute.d.ts +6 -0
- package/utils/interactions/interactionChannel.d.ts +35 -0
- package/utils/interactions/interactionJson.d.ts +6 -0
- package/utils/interactions/interactionListening.d.ts +6 -0
- package/utils/interactions/interactionTypes.d.ts +224 -0
package/components/calendar.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { p as e } from "../platform.mjs";
|
|
3
3
|
import t from "../box.mjs";
|
|
4
4
|
import { a as n, i as r } from "../behavior.mjs";
|
|
5
5
|
import { t as i } from "../identity.mjs";
|
|
6
6
|
import { C as a, G as o, Q as s, S as c, U as l, V as ee, W as u, Z as te, f as d, q as f, t as p, w as m, x as ne } from "../dates.mjs";
|
|
7
7
|
import { N as re, x as ie } from "../date-math.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
8
|
+
import { a as ae, i as oe } from "../reporting.mjs";
|
|
9
|
+
import { Path as se, Svg as ce } from "./svg.mjs";
|
|
10
|
+
import { n as le } from "../date-environment.mjs";
|
|
11
|
+
import ue from "./visuallyHidden.mjs";
|
|
12
|
+
import { useEffect as de, useMemo as fe, useRef as pe, useState as h } from "react";
|
|
13
|
+
import { Fragment as me, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
14
|
//#region src/utils/date/calendarModel.ts
|
|
14
15
|
function v(e) {
|
|
15
16
|
let t = d(e);
|
|
@@ -21,7 +22,7 @@ function y(e) {
|
|
|
21
22
|
...ee
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function he(e, t, n) {
|
|
25
26
|
let r = {
|
|
26
27
|
year: e,
|
|
27
28
|
month: t,
|
|
@@ -42,7 +43,7 @@ function pe(e, t, n) {
|
|
|
42
43
|
};
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function ge(e, t, n, r) {
|
|
46
47
|
let i = r.rtl ? "ArrowLeft" : "ArrowRight", a = r.rtl ? "ArrowRight" : "ArrowLeft";
|
|
47
48
|
switch (t) {
|
|
48
49
|
case i: return l(e, 1);
|
|
@@ -56,7 +57,7 @@ function me(e, t, n, r) {
|
|
|
56
57
|
default: return null;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function _e(e, t) {
|
|
60
61
|
return t.min != null && f(e) < f(t.min) || t.max != null && f(e) > f(t.max);
|
|
61
62
|
}
|
|
62
63
|
function b(e, t) {
|
|
@@ -65,12 +66,12 @@ function b(e, t) {
|
|
|
65
66
|
function x(e, t) {
|
|
66
67
|
return f(e) <= f(t) ? [e, t] : [t, e];
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function ve(e, t, n) {
|
|
69
70
|
if (!t || !n) return t && f(e) === f(t) ? "start" : null;
|
|
70
71
|
let [r, i] = x(t, n), a = f(e);
|
|
71
72
|
return a === f(r) ? "start" : a === f(i) ? "end" : a > f(r) && a < f(i) ? "middle" : null;
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function ye(e, t, n) {
|
|
74
75
|
let [r, i] = x(e, t);
|
|
75
76
|
for (let e = f(r); e <= f(i); e++) if (n(y(l({
|
|
76
77
|
year: 1970,
|
|
@@ -81,87 +82,96 @@ function _e(e, t, n) {
|
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
83
84
|
//#region src/components/calendar.tsx
|
|
84
|
-
var
|
|
85
|
-
function
|
|
85
|
+
var be = "data-date", S = 12;
|
|
86
|
+
function C(e, t) {
|
|
86
87
|
return e !== null && t !== null && f(e) === f(t);
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
-
let { mode: s = "single", value: l, defaultValue: ee = null, onValueChange: te, min: d, max: f, isDateUnavailable: m, locale:
|
|
90
|
-
locale:
|
|
91
|
-
zone:
|
|
92
|
-
}), { locale:
|
|
89
|
+
function xe(o) {
|
|
90
|
+
let { mode: s = "single", value: l, defaultValue: ee = null, onValueChange: te, min: d, max: f, isDateUnavailable: m, locale: se, zone: ce, firstDayOfWeek: xe, months: T = 1, weekNumbers: D = !1, showOutsideDays: we = !0, focusedDate: Te, defaultFocusedDate: Ee, onFocusedDateChange: De, disabled: O = !1, readOnly: Oe = !1, autoFocus: ke = !1, label: Ae, previousLabel: je = "Previous", nextLabel: Me = "Next", props: Ne, ...Pe } = o, k = le({
|
|
91
|
+
locale: se,
|
|
92
|
+
zone: ce
|
|
93
|
+
}), { locale: A } = k, j = v(re(k.zone)), M = xe ?? c(A).firstDay, N = (e) => Se(A).format(e), P = s === "range", F = fe(() => ({
|
|
93
94
|
min: v(d),
|
|
94
95
|
max: v(f)
|
|
95
|
-
}), [d, f]), [
|
|
96
|
+
}), [d, f]), [I, Fe] = ae({
|
|
96
97
|
value: l,
|
|
97
98
|
defaultValue: ee,
|
|
98
99
|
onChange: (e, t) => {
|
|
99
|
-
te?.(e,
|
|
100
|
+
te?.(e, P ? t : {
|
|
100
101
|
...t,
|
|
101
|
-
...ie(e,
|
|
102
|
+
...ie(e, k.zone)
|
|
102
103
|
});
|
|
104
|
+
},
|
|
105
|
+
interaction: {
|
|
106
|
+
component: "calendar",
|
|
107
|
+
type: "valueChange",
|
|
108
|
+
content: ["value"]
|
|
103
109
|
}
|
|
104
|
-
}),
|
|
105
|
-
value:
|
|
106
|
-
defaultValue:
|
|
107
|
-
onChange:
|
|
108
|
-
}),
|
|
109
|
-
(
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
}), Ie = P ? null : v(I), L = P && I ? I : null, [R, z] = h(null), [Le, B] = h(null), Re = y(b(v(Ee) ?? Ie ?? v(L?.start) ?? j, F)), [ze, V] = r({
|
|
111
|
+
value: Te,
|
|
112
|
+
defaultValue: Re,
|
|
113
|
+
onChange: De
|
|
114
|
+
}), H = v(ze) ?? j, [U, Be] = h("day"), W = oe("calendar"), [G, Ve] = h(() => w(H)), K = G;
|
|
115
|
+
(w(H) < G || w(H) > G + T - 1) && (K = w(H) < G ? w(H) : w(H) - T + 1, Ve(K));
|
|
116
|
+
let He = pe(null), q = pe(ke), Ue = i("calendar");
|
|
117
|
+
de(() => {
|
|
118
|
+
q.current && (q.current = !1, He.current?.querySelector(`[${be}="${ze}"]`)?.focus());
|
|
113
119
|
});
|
|
114
|
-
let
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
if (
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
+
let We = (e) => _e(e, F), Ge = (e) => m?.(y(e)) ?? !1, J = (e, t, n) => {
|
|
121
|
+
q.current = n, V(y(b(e, F)), { reason: t });
|
|
122
|
+
}, Ke = (e, t) => {
|
|
123
|
+
if (O || Oe || We(e) || Ge(e)) return;
|
|
124
|
+
if (J(e, "select", !1), !P) {
|
|
125
|
+
Fe(y(e), {
|
|
120
126
|
reason: "select",
|
|
121
127
|
event: t
|
|
122
128
|
});
|
|
123
129
|
return;
|
|
124
130
|
}
|
|
125
|
-
if (!
|
|
126
|
-
|
|
131
|
+
if (!R) {
|
|
132
|
+
z(e), B(e);
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
129
|
-
let [n, r] = x(
|
|
130
|
-
|
|
135
|
+
let [n, r] = x(R, e);
|
|
136
|
+
z(null), B(null), !(m && ye(n, r, m)) && Fe({
|
|
131
137
|
start: y(n),
|
|
132
138
|
end: y(r)
|
|
133
139
|
}, {
|
|
134
140
|
reason: "select",
|
|
135
141
|
event: t
|
|
136
142
|
});
|
|
137
|
-
},
|
|
138
|
-
if (
|
|
143
|
+
}, qe = n((t) => {
|
|
144
|
+
if (O) return;
|
|
139
145
|
if (t.key === "Enter" || t.key === " ") {
|
|
140
|
-
t.preventDefault(),
|
|
146
|
+
t.preventDefault(), Ke(H, t);
|
|
141
147
|
return;
|
|
142
148
|
}
|
|
143
|
-
if (t.key === "Escape" &&
|
|
144
|
-
t.preventDefault(), t.stopPropagation(),
|
|
149
|
+
if (t.key === "Escape" && R) {
|
|
150
|
+
t.preventDefault(), t.stopPropagation(), z(null), B(null);
|
|
145
151
|
return;
|
|
146
152
|
}
|
|
147
|
-
let n =
|
|
153
|
+
let n = ge(H, t.key, t.shiftKey, {
|
|
148
154
|
rtl: e(t.currentTarget),
|
|
149
|
-
firstDay:
|
|
155
|
+
firstDay: M
|
|
156
|
+
});
|
|
157
|
+
n && (t.preventDefault(), J(n, "keyboard", !0), R && B(b(n, F)));
|
|
158
|
+
}), Je = (e) => {
|
|
159
|
+
let t = u(H, e * (U === "day" ? T : U === "month" ? 12 : 144));
|
|
160
|
+
U === "day" && Ve(K + e * T), J(t, "navigate", !1), W("pageChange", y(t), {
|
|
161
|
+
reason: e === 1 ? "next" : "previous",
|
|
162
|
+
content: ["value"]
|
|
150
163
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}, Z = Array.from({ length: D }, (e, t) => ({
|
|
155
|
-
year: Math.floor((J + t) / 12),
|
|
156
|
-
month: (J + t) % 12 + 1,
|
|
164
|
+
}, Y = Array.from({ length: T }, (e, t) => ({
|
|
165
|
+
year: Math.floor((K + t) / 12),
|
|
166
|
+
month: (K + t) % 12 + 1,
|
|
157
167
|
day: 1
|
|
158
|
-
})),
|
|
159
|
-
locale:
|
|
168
|
+
})), X = `${Ue}-title`, Ye = U === "day" && T > 1, Xe = U === "day" ? Y.map((e) => p(y(e), {
|
|
169
|
+
locale: A,
|
|
160
170
|
month: "long",
|
|
161
171
|
year: "numeric"
|
|
162
|
-
})).join(" – ") :
|
|
163
|
-
let n = v(e.date), r =
|
|
164
|
-
return e.outside && (!
|
|
172
|
+
})).join(" – ") : U === "month" ? N(H.year) : `${N(E(H.year))} – ${N(E(H.year) + S - 1)}`, Z = a(A, "short"), Ze = Z.some((e) => e.length > 4) ? a(A, "narrow") : Z, Qe = a(A, "long"), $e = Array.from({ length: 7 }, (e, t) => (M + t) % 7), et = R ? Le ?? R : null, Q = R ?? v(L?.start), $ = R ? et : v(L?.end), tt = (e) => {
|
|
173
|
+
let n = v(e.date), r = We(n), i = Ge(n), a = P ? ve(n, Q, $) : null, o = P ? a !== null : C(n, Ie), s = C(n, j), c = C(n, H);
|
|
174
|
+
return e.outside && (!we || T > 1) ? /* @__PURE__ */ g(t, {
|
|
165
175
|
tag: "td",
|
|
166
176
|
component: "calendar.cell",
|
|
167
177
|
display: "table-cell",
|
|
@@ -173,14 +183,14 @@ function T(o) {
|
|
|
173
183
|
p: 0,
|
|
174
184
|
py: .5,
|
|
175
185
|
variant: {
|
|
176
|
-
rangeStart: a === "start" && $ !== null && !
|
|
186
|
+
rangeStart: a === "start" && $ !== null && !C(Q, $),
|
|
177
187
|
rangeEnd: a === "end",
|
|
178
188
|
rangeMiddle: a === "middle"
|
|
179
189
|
},
|
|
180
190
|
props: {
|
|
181
191
|
role: "gridcell",
|
|
182
192
|
"aria-selected": o || void 0,
|
|
183
|
-
"aria-disabled": r ||
|
|
193
|
+
"aria-disabled": r || O || void 0,
|
|
184
194
|
"aria-current": s ? "date" : void 0
|
|
185
195
|
},
|
|
186
196
|
children: /* @__PURE__ */ g(t, {
|
|
@@ -198,23 +208,23 @@ function T(o) {
|
|
|
198
208
|
today: s,
|
|
199
209
|
selected: o && a !== "middle",
|
|
200
210
|
outside: e.outside,
|
|
201
|
-
blocked: r ||
|
|
211
|
+
blocked: r || O,
|
|
202
212
|
unavailable: i
|
|
203
213
|
},
|
|
204
214
|
props: {
|
|
205
|
-
[
|
|
206
|
-
tabIndex: c && !r && !
|
|
215
|
+
[be]: e.date,
|
|
216
|
+
tabIndex: c && !r && !O ? 0 : -1,
|
|
207
217
|
"aria-label": p(e.date, {
|
|
208
|
-
locale:
|
|
218
|
+
locale: A,
|
|
209
219
|
dateStyle: "full"
|
|
210
220
|
}),
|
|
211
|
-
onClick: (e) =>
|
|
212
|
-
onPointerEnter: () =>
|
|
221
|
+
onClick: (e) => Ke(n, e),
|
|
222
|
+
onPointerEnter: () => R && B(n)
|
|
213
223
|
},
|
|
214
|
-
children:
|
|
224
|
+
children: N(e.day)
|
|
215
225
|
})
|
|
216
226
|
}, e.date);
|
|
217
|
-
},
|
|
227
|
+
}, nt = (t, n, r, i, a, o) => {
|
|
218
228
|
let s = e(t.currentTarget), c = {
|
|
219
229
|
ArrowUp: -r,
|
|
220
230
|
ArrowDown: r,
|
|
@@ -222,34 +232,34 @@ function T(o) {
|
|
|
222
232
|
[s ? "ArrowLeft" : "ArrowRight"]: 1
|
|
223
233
|
};
|
|
224
234
|
t.key === "Enter" || t.key === " " ? (t.preventDefault(), i(o)) : t.key in c && (t.preventDefault(), a(Math.max(0, Math.min(n - 1, o + c[t.key])), t.currentTarget.parentElement));
|
|
225
|
-
},
|
|
226
|
-
let e = ne(
|
|
235
|
+
}, rt = () => {
|
|
236
|
+
let e = ne(A, "short"), n = E(H.year), r = U === "month" ? e.map((e, t) => ({
|
|
227
237
|
label: e,
|
|
228
|
-
active: t + 1 ===
|
|
229
|
-
current:
|
|
230
|
-
})) : Array.from({ length:
|
|
231
|
-
label:
|
|
232
|
-
active: n + t ===
|
|
233
|
-
current:
|
|
234
|
-
})), i = (e) =>
|
|
235
|
-
...
|
|
238
|
+
active: t + 1 === H.month,
|
|
239
|
+
current: j.year === H.year && j.month === t + 1
|
|
240
|
+
})) : Array.from({ length: S }, (e, t) => ({
|
|
241
|
+
label: N(n + t),
|
|
242
|
+
active: n + t === H.year,
|
|
243
|
+
current: j.year === n + t
|
|
244
|
+
})), i = (e) => U === "month" ? {
|
|
245
|
+
...H,
|
|
236
246
|
month: e + 1,
|
|
237
247
|
day: 1
|
|
238
248
|
} : {
|
|
239
|
-
...
|
|
249
|
+
...H,
|
|
240
250
|
year: n + e,
|
|
241
251
|
day: 1
|
|
242
252
|
}, a = (e) => {
|
|
243
253
|
let t = i(e);
|
|
244
|
-
|
|
254
|
+
q.current = !0, V(y(b({
|
|
245
255
|
...t,
|
|
246
|
-
day: Math.min(
|
|
247
|
-
},
|
|
256
|
+
day: Math.min(H.day, 28)
|
|
257
|
+
}, F)), { reason: "navigate" }), Be(U === "year" ? "month" : "day"), W("viewChange", U === "year" ? "month" : "day", { reason: "zoom-in" });
|
|
248
258
|
}, o = (e, t) => {
|
|
249
259
|
let n = i(e);
|
|
250
|
-
|
|
260
|
+
V(y({
|
|
251
261
|
...n,
|
|
252
|
-
day: Math.min(
|
|
262
|
+
day: Math.min(H.day, 28)
|
|
253
263
|
}), { reason: "keyboard" }), t?.querySelector(`[data-zoom="${e}"]`)?.focus();
|
|
254
264
|
};
|
|
255
265
|
return /* @__PURE__ */ g(t, {
|
|
@@ -258,7 +268,7 @@ function T(o) {
|
|
|
258
268
|
gap: 1,
|
|
259
269
|
props: {
|
|
260
270
|
role: "group",
|
|
261
|
-
"aria-labelledby":
|
|
271
|
+
"aria-labelledby": X
|
|
262
272
|
},
|
|
263
273
|
children: r.map((e, n) => /* @__PURE__ */ g(t, {
|
|
264
274
|
tag: "button",
|
|
@@ -269,21 +279,21 @@ function T(o) {
|
|
|
269
279
|
},
|
|
270
280
|
py: 2,
|
|
271
281
|
borderRadius: 2,
|
|
272
|
-
disabled:
|
|
282
|
+
disabled: O,
|
|
273
283
|
props: {
|
|
274
284
|
type: "button",
|
|
275
285
|
"data-zoom": n,
|
|
276
286
|
tabIndex: e.active ? 0 : -1,
|
|
277
287
|
"aria-pressed": e.active,
|
|
278
288
|
onClick: () => a(n),
|
|
279
|
-
onKeyDown: (e) =>
|
|
289
|
+
onKeyDown: (e) => nt(e, r.length, 3, a, o, n)
|
|
280
290
|
},
|
|
281
291
|
children: e.label
|
|
282
292
|
}, e.label))
|
|
283
293
|
});
|
|
284
|
-
},
|
|
285
|
-
let r =
|
|
286
|
-
locale:
|
|
294
|
+
}, it = (e, n) => {
|
|
295
|
+
let r = he(e.year, e.month, M), i = p(y(e), {
|
|
296
|
+
locale: A,
|
|
287
297
|
month: "long",
|
|
288
298
|
year: "numeric"
|
|
289
299
|
});
|
|
@@ -295,10 +305,10 @@ function T(o) {
|
|
|
295
305
|
},
|
|
296
306
|
props: {
|
|
297
307
|
role: "grid",
|
|
298
|
-
"aria-label":
|
|
299
|
-
"aria-labelledby":
|
|
300
|
-
"aria-readonly":
|
|
301
|
-
onKeyDown:
|
|
308
|
+
"aria-label": T > 1 ? i : void 0,
|
|
309
|
+
"aria-labelledby": T > 1 ? void 0 : X,
|
|
310
|
+
"aria-readonly": Oe || void 0,
|
|
311
|
+
onKeyDown: qe
|
|
302
312
|
},
|
|
303
313
|
children: [/* @__PURE__ */ g(t, {
|
|
304
314
|
tag: "thead",
|
|
@@ -306,12 +316,12 @@ function T(o) {
|
|
|
306
316
|
children: /* @__PURE__ */ _(t, {
|
|
307
317
|
tag: "tr",
|
|
308
318
|
display: "table-row",
|
|
309
|
-
children: [
|
|
319
|
+
children: [D && /* @__PURE__ */ g(t, {
|
|
310
320
|
tag: "th",
|
|
311
321
|
display: "table-cell",
|
|
312
322
|
component: "calendar.weekday",
|
|
313
323
|
props: { "aria-hidden": !0 }
|
|
314
|
-
}),
|
|
324
|
+
}), $e.map((e) => /* @__PURE__ */ g(t, {
|
|
315
325
|
tag: "th",
|
|
316
326
|
display: "table-cell",
|
|
317
327
|
component: "calendar.weekday",
|
|
@@ -319,9 +329,9 @@ function T(o) {
|
|
|
319
329
|
fontSize: 12,
|
|
320
330
|
props: {
|
|
321
331
|
scope: "col",
|
|
322
|
-
abbr:
|
|
332
|
+
abbr: Qe[e]
|
|
323
333
|
},
|
|
324
|
-
children:
|
|
334
|
+
children: Ze[e]
|
|
325
335
|
}, e))]
|
|
326
336
|
})
|
|
327
337
|
}), /* @__PURE__ */ g(t, {
|
|
@@ -330,30 +340,30 @@ function T(o) {
|
|
|
330
340
|
children: r.map((e) => /* @__PURE__ */ _(t, {
|
|
331
341
|
tag: "tr",
|
|
332
342
|
display: "table-row",
|
|
333
|
-
children: [
|
|
343
|
+
children: [D && /* @__PURE__ */ g(t, {
|
|
334
344
|
tag: "td",
|
|
335
345
|
display: "table-cell",
|
|
336
346
|
component: "calendar.weekNumber",
|
|
337
347
|
fontSize: 11,
|
|
338
348
|
textAlign: "center",
|
|
339
349
|
props: { role: "rowheader" },
|
|
340
|
-
children:
|
|
341
|
-
}), e.days.map(
|
|
350
|
+
children: N(e.week)
|
|
351
|
+
}), e.days.map(tt)]
|
|
342
352
|
}, e.days[0].date))
|
|
343
353
|
})]
|
|
344
354
|
}, n);
|
|
345
355
|
};
|
|
346
356
|
return /* @__PURE__ */ _(t, {
|
|
347
|
-
ref:
|
|
357
|
+
ref: He,
|
|
348
358
|
component: "calendar",
|
|
349
359
|
display: "inline-block",
|
|
350
|
-
...
|
|
351
|
-
variant: [
|
|
360
|
+
...Pe,
|
|
361
|
+
variant: [Pe.variant, { disabled: O }],
|
|
352
362
|
props: {
|
|
353
|
-
role:
|
|
354
|
-
"aria-label":
|
|
355
|
-
...
|
|
356
|
-
onPointerLeave: () =>
|
|
363
|
+
role: Ae ? "group" : void 0,
|
|
364
|
+
"aria-label": Ae,
|
|
365
|
+
...Ne,
|
|
366
|
+
onPointerLeave: () => R && B(R)
|
|
357
367
|
},
|
|
358
368
|
children: [/* @__PURE__ */ _(t, {
|
|
359
369
|
position: "relative",
|
|
@@ -372,18 +382,18 @@ function T(o) {
|
|
|
372
382
|
width: 8,
|
|
373
383
|
height: 8,
|
|
374
384
|
borderRadius: 2,
|
|
375
|
-
disabled:
|
|
385
|
+
disabled: O,
|
|
376
386
|
props: {
|
|
377
387
|
type: "button",
|
|
378
|
-
"aria-label":
|
|
379
|
-
onClick: () =>
|
|
388
|
+
"aria-label": je,
|
|
389
|
+
onClick: () => Je(-1)
|
|
380
390
|
},
|
|
381
|
-
children: /* @__PURE__ */ g(
|
|
391
|
+
children: /* @__PURE__ */ g(Ce, { direction: -1 })
|
|
382
392
|
}),
|
|
383
|
-
|
|
393
|
+
Ye ? /* @__PURE__ */ _(me, { children: [/* @__PURE__ */ g(t, {
|
|
384
394
|
display: "flex",
|
|
385
395
|
gap: 4,
|
|
386
|
-
children:
|
|
396
|
+
children: Y.map((e) => /* @__PURE__ */ g(t, {
|
|
387
397
|
flex1: !0,
|
|
388
398
|
textAlign: "center",
|
|
389
399
|
py: 1.5,
|
|
@@ -391,15 +401,15 @@ function T(o) {
|
|
|
391
401
|
fontWeight: 600,
|
|
392
402
|
props: { "aria-hidden": !0 },
|
|
393
403
|
children: p(y(e), {
|
|
394
|
-
locale:
|
|
404
|
+
locale: A,
|
|
395
405
|
month: "long",
|
|
396
406
|
year: "numeric"
|
|
397
407
|
})
|
|
398
408
|
}, y(e)))
|
|
399
|
-
}), /* @__PURE__ */ g(
|
|
400
|
-
id:
|
|
409
|
+
}), /* @__PURE__ */ g(ue, {
|
|
410
|
+
id: X,
|
|
401
411
|
props: { "aria-live": "polite" },
|
|
402
|
-
children:
|
|
412
|
+
children: Xe
|
|
403
413
|
})] }) : /* @__PURE__ */ g(t, {
|
|
404
414
|
display: "flex",
|
|
405
415
|
jc: "center",
|
|
@@ -411,14 +421,16 @@ function T(o) {
|
|
|
411
421
|
px: 3,
|
|
412
422
|
borderRadius: 2,
|
|
413
423
|
fontSize: 14,
|
|
414
|
-
id:
|
|
415
|
-
disabled:
|
|
424
|
+
id: X,
|
|
425
|
+
disabled: O || U === "year",
|
|
416
426
|
props: {
|
|
417
427
|
type: "button",
|
|
418
428
|
"aria-live": "polite",
|
|
419
|
-
onClick: () =>
|
|
429
|
+
onClick: () => {
|
|
430
|
+
Be(U === "day" ? "month" : "year"), W("viewChange", U === "day" ? "month" : "year", { reason: "zoom-out" });
|
|
431
|
+
}
|
|
420
432
|
},
|
|
421
|
-
children:
|
|
433
|
+
children: Xe
|
|
422
434
|
})
|
|
423
435
|
}),
|
|
424
436
|
/* @__PURE__ */ g(t, {
|
|
@@ -433,42 +445,42 @@ function T(o) {
|
|
|
433
445
|
width: 8,
|
|
434
446
|
height: 8,
|
|
435
447
|
borderRadius: 2,
|
|
436
|
-
disabled:
|
|
448
|
+
disabled: O,
|
|
437
449
|
props: {
|
|
438
450
|
type: "button",
|
|
439
|
-
"aria-label":
|
|
440
|
-
onClick: () =>
|
|
451
|
+
"aria-label": Me,
|
|
452
|
+
onClick: () => Je(1)
|
|
441
453
|
},
|
|
442
|
-
children: /* @__PURE__ */ g(
|
|
454
|
+
children: /* @__PURE__ */ g(Ce, { direction: 1 })
|
|
443
455
|
})
|
|
444
456
|
]
|
|
445
|
-
}),
|
|
457
|
+
}), U === "day" ? /* @__PURE__ */ g(t, {
|
|
446
458
|
display: "flex",
|
|
447
459
|
gap: 4,
|
|
448
460
|
ai: "start",
|
|
449
|
-
children:
|
|
450
|
-
}) :
|
|
461
|
+
children: Y.map(it)
|
|
462
|
+
}) : rt()]
|
|
451
463
|
});
|
|
452
464
|
}
|
|
453
|
-
function
|
|
465
|
+
function w(e) {
|
|
454
466
|
return e.year * 12 + e.month - 1;
|
|
455
467
|
}
|
|
456
|
-
var
|
|
457
|
-
function
|
|
458
|
-
let t =
|
|
459
|
-
return t || (t = new Intl.NumberFormat(e, { useGrouping: !1 }),
|
|
468
|
+
var T = /* @__PURE__ */ new Map();
|
|
469
|
+
function Se(e) {
|
|
470
|
+
let t = T.get(e);
|
|
471
|
+
return t || (t = new Intl.NumberFormat(e, { useGrouping: !1 }), T.set(e, t)), t;
|
|
460
472
|
}
|
|
461
|
-
function
|
|
462
|
-
return e - (e %
|
|
473
|
+
function E(e) {
|
|
474
|
+
return e - (e % S + S) % S;
|
|
463
475
|
}
|
|
464
|
-
function
|
|
465
|
-
return /* @__PURE__ */ g(
|
|
476
|
+
function Ce({ direction: e }) {
|
|
477
|
+
return /* @__PURE__ */ g(ce, {
|
|
466
478
|
viewBox: "0 0 16 16",
|
|
467
479
|
width: "1rem",
|
|
468
480
|
height: "1rem",
|
|
469
481
|
rtl: { flip: "xAxis" },
|
|
470
482
|
props: { fill: "none" },
|
|
471
|
-
children: /* @__PURE__ */ g(
|
|
483
|
+
children: /* @__PURE__ */ g(se, {
|
|
472
484
|
d: e === 1 ? "M6 3l5 5-5 5" : "M10 3L5 8l5 5",
|
|
473
485
|
stroke: "currentColor",
|
|
474
486
|
strokeWidth: 2,
|
|
@@ -477,7 +489,7 @@ function ye({ direction: e }) {
|
|
|
477
489
|
})
|
|
478
490
|
});
|
|
479
491
|
}
|
|
480
|
-
var
|
|
481
|
-
|
|
492
|
+
var D = xe;
|
|
493
|
+
D.displayName = "Calendar";
|
|
482
494
|
//#endregion
|
|
483
|
-
export {
|
|
495
|
+
export { D as default };
|
package/components/combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../effects.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("./svg.cjs"),a=require("./flex.cjs"),o=require("./overlay.cjs"),s=require("./presence.cjs");let c=require("react"),l=require("react/jsx-runtime");var u;(function(e){function t(e,t){return typeof e==`function`?e(t):t[e]}e.read=t;function n(e,n){let r=t(e.label,n);return r==null?``:String(r)}e.labelOf=n;function r(e,r){return e.key===void 0?n(e,r):t(e.key,r)}e.keyOf=r;function i(e,n){return e.disabled!==void 0&&t(e.disabled,n)===!0}e.isDisabled=i;let a=/\p{M}/gu;function o(e){return e.normalize(`NFD`).replace(a,``).toLowerCase()}e.normalize=o;function s(e,t){return o(e).includes(o(t))}e.matches=s;function c(e,t,n){return t===``?e:e.filter(e=>s(n(e),t))}e.filterRows=c;function l(e){return e==null?[]:Array.isArray(e)?e:[e]}e.toArray=l;function u(e,t,n){let r=n(t);return e.some(e=>n(e)===r)}e.isSelected=u;function d(e,t,n,r){return n?u(e,t,r)?e.filter(e=>r(e)!==r(t)):[...e,t]:[t]}e.toggle=d;function f(e){let{data:t,def:r,query:i,filter:a,typed:s,createRow:c}=e,l=e=>n(r,e),u=(!s||a===!1?t:a(t,i,l)).map(e=>({kind:`option`,row:e}));return c&&i!==``&&!t.some(e=>o(l(e))===o(i))&&c(i)!==null&&u.push({kind:`create`,query:i}),u}e.rowsFor=f;function p(e,t){return t.kind===`option`&&i(e,t.row)}e.isRowDisabled=p;function m(e,t,n,i=`first`){let a=e=>r(n,e),o=e.findIndex(e=>e.kind===`option`&&u(t,e.row,a));if(o!==-1&&!p(n,e[o]))return o;let s=e.map((e,t)=>p(n,e)?-1:t).filter(e=>e!==-1);return(i===`last`?s[s.length-1]:s[0])??-1}e.activeIndexFor=m})(u||={});var d=u;function f(e){let{selection:t,def:n,display:r,removeLabel:o,onRemove:s,disabled:c,variant:u}=e;return(0,l.jsx)(l.Fragment,{children:t.map(e=>{let t=d.labelOf(n,e);return(0,l.jsxs)(a.default,{component:`combobox.chip`,variant:u,ai:`center`,gap:1,children:[r?.(e)??t,!c&&(0,l.jsx)(a.default,{tag:`button`,component:`combobox.remove`,variant:u,ai:`center`,jc:`center`,props:{type:`button`,tabIndex:-1,"aria-label":o(t),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),s(e,t)}},children:(0,l.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`0.625rem`,props:{fill:`none`},children:(0,l.jsx)(i.Path,{d:`M6 6 18 18M18 6 6 18`,stroke:`currentColor`,strokeWidth:3,strokeLinecap:`round`})})})]},d.keyOf(n,e))})})}var p;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.DEFAULT_THRESHOLD=100;e.DEFAULT_ITEM_HEIGHT=36,e.DEFAULT_VIEW_HEIGHT=248;function r(e,t,n){return Math.min(Math.max(e,t),n)}function i(e,t,r=n){return t??e>r}e.shouldVirtualize=i;function a(e){let{count:n,itemHeight:i,viewHeight:a,scrollTop:o,overscan:s=t,activeIndex:c=-1}=e;if(n<=0||i<=0)return{startIndex:0,endIndex:Math.max(0,n),offsetY:0,totalHeight:0};let l=Math.max(1,Math.ceil(a/i)),u=Math.min(n,l+s*2),d=n-u,f=r(Math.floor(o/i)-s,0,d);return c>=0&&c<n&&(c<f?f=r(c-s,0,d):c>=f+u&&(f=r(c+1+s-u,0,d))),{startIndex:f,endIndex:f+u,offsetY:f*i,totalHeight:n*i}}e.windowFor=a})(p||={});var m=p;function h(t){let{count:r,scrollerRef:i,itemHeight:a,viewHeight:o,overscan:s,threshold:l,enabled:u,activeIndex:d}=t,[f,p]=(0,c.useState)({top:0,at:-1}),[h,g]=(0,c.useState)({itemHeight:0,viewHeight:0}),_=(0,c.useRef)(null),v=(0,c.useCallback)(e=>{_.current=e},[]),y=m.shouldVirtualize(r,u,l),b=n.a(()=>{let e=i.current,t=_.current;if(!e||!t)return;let n=t.children,r=n[0],a=n[1],o=a?a.offsetTop-r.offsetTop:r?.offsetHeight??0,s=e.clientHeight;g(e=>e.itemHeight===o&&e.viewHeight===s?e:{itemHeight:o,viewHeight:s})});e.n(()=>{if(!y||(b(),typeof ResizeObserver>`u`))return;let e=i.current;if(!e)return;let t=new ResizeObserver(b);return t.observe(e),()=>t.disconnect()},[y,r,b,i]);let x=n.a(e=>{p({top:e.currentTarget.scrollTop,at:d??-1})}),S=m.windowFor({count:r,itemHeight:a??(h.itemHeight>0?h.itemHeight:m.DEFAULT_ITEM_HEIGHT),viewHeight:o??(h.viewHeight>0?h.viewHeight:m.DEFAULT_VIEW_HEIGHT),scrollTop:f.top,overscan:s,activeIndex:d===f.at?-1:d});return y?{...S,virtualized:y,contentRef:v,onScroll:x}:{startIndex:0,endIndex:r,offsetY:0,totalHeight:0,virtualized:y,contentRef:v,onScroll:x}}function g(e,t,n,r){return e?{role:`listbox`,"aria-labelledby":r,...t?{"aria-multiselectable":!0}:{},...n?{"aria-busy":!0}:{}}:{role:`status`}}function _(e){let{presence:n,rows:r,def:i,display:s,selection:u,multiple:f,activeIndex:p,optionId:m,rowRef:_,onSelect:v}=e,{anchorRef:y,popupRef:b,listboxId:x,labelledBy:S,loading:C,loadingText:ee,emptyText:w,createLabel:te,variant:T,itemsProps:ne}=e,{virtualize:E}=e,{present:D,ref:O,props:re}=n,k=e=>d.keyOf(i,e),[A,ie]=(0,c.useState)(!1),ae=(0,c.useCallback)(e=>ie(e===`top`),[]),j=(0,c.useRef)(null),oe=(0,c.useCallback)(e=>{j.current=e,O(e)},[O]),M=typeof E==`object`?E:{},{virtualized:N,startIndex:P,endIndex:se,offsetY:F,totalHeight:I,contentRef:L,onScroll:R}=h({count:r.length,scrollerRef:j,enabled:typeof E==`boolean`?E:void 0,activeIndex:p,...M}),z=N?r.slice(P,se):r,B=(e,t)=>{let n=N?P+t:t,o=e.kind===`option`&&d.isSelected(u,e.row,k),c=d.isRowDisabled(i,e);return(0,l.jsx)(a.default,{ref:_(n),component:`combobox.item`,variant:[T,{create:e.kind===`create`,highlighted:n===p}],selected:o,ai:`center`,gap:2,id:m(n),props:{role:`option`,...N?{"aria-setsize":r.length,"aria-posinset":n+1}:{},...c?{"aria-disabled":!0}:{},onMouseDown:e=>e.preventDefault(),onClick:e=>!c&&v(n,e)},children:e.kind===`create`?te(e.query):s?.(e.row)??d.labelOf(i,e.row)},e.kind===`option`?k(e.row):`create`)};return(0,l.jsx)(o.default,{ref:b,anchor:y,side:`bottom`,align:`start`,offset:.5,matchWidth:!0,onSideChange:ae,children:(0,l.jsxs)(t.default,{ref:oe,component:`combobox.items`,...ne,variant:[T,{closed:!D&&!A,closedUp:!D&&A}],id:x,props:{...g(r.length>0,f,C===!0,S),...re,...N?{onScroll:R}:{}},children:[N?(0,l.jsx)(t.default,{ref:L,component:`combobox.window`,variant:T,style:{height:I,paddingTop:F},children:z.map(B)}):z.map(B),r.length===0&&(0,l.jsx)(t.default,{component:`combobox.message`,variant:T,children:C?ee:w})]})})}var v=new Set([` `,`Home`,`End`,`ArrowLeft`,`ArrowRight`]);function y(o,u){let{data:p,def:m,label:h,labelProps:g,placeholder:y,name:b,disabled:x,props:S,itemsProps:C,hideIcon:ee,filter:w=d.filterRows,loading:te,loadingText:T=`Loading...`,emptyText:ne=`No results`,createRow:E,createLabel:D=e=>`Create "${e}"`,removeLabel:O=e=>`Remove ${e}`,virtualize:re,query:k,defaultQuery:A,onQueryChange:ie,open:ae,defaultOpen:j,onOpenChange:oe,multiple:M=!1,value:N,defaultValue:P,onValueChange:se,...F}=o,I=r.t(`combobox`),L=F.id??`${I}-field`,R=`${I}-listbox`,z=`${I}-label`,B=h!=null&&h!==!1,ce=(0,c.useCallback)(e=>`${I}-option-${e}`,[I]),V=(0,c.useRef)(null),le=(0,c.useRef)(null),H=(0,c.useRef)(null),ue=(0,c.useCallback)(e=>{H.current=e,typeof u==`function`?u(e):u&&(u.current=e)},[u]),de=n.a((e,t)=>{se?.(M?e:e[0]??null,t)}),fe=(0,c.useMemo)(()=>N===void 0?void 0:d.toArray(N),[N]),[U,pe]=n.i({value:fe,defaultValue:()=>d.toArray(P),onChange:de}),[W,G]=n.i({value:ae,defaultValue:j??!1,onChange:oe}),[me,K]=n.i({value:k,defaultValue:A??``,onChange:ie}),[q,J]=(0,c.useState)(!1),Y=(0,c.useCallback)(e=>d.keyOf(m,e),[m]),he=M||U[0]===void 0?``:d.labelOf(m,U[0]),X=q||me!==``?me:he,Z=(0,c.useMemo)(()=>d.rowsFor({data:p,def:m,query:X,filter:w,typed:q,createRow:E}),[p,m,X,w,q,E]),ge=(0,c.useCallback)(e=>Z[e]?d.isRowDisabled(m,Z[e]):!1,[Z,m]),_e=n.a((e,t)=>{G(!1,{reason:e,event:t}),e!==`escape`&&(J(!1),K(``,{reason:`close`,event:t}))}),Q=n.a((e,t)=>{let n=Z[e];if(!n||ge(e))return;let r=n.kind===`create`?E?.(n.query):n.row;if(r==null)return;let i=d.isSelected(U,r,Y),a=n.kind===`create`?`create`:i&&M?`deselect`:`select`;pe(d.toggle(U,r,M,Y),{reason:a,event:t}),J(!1),K(``,{reason:`select`,event:t}),M||G(!1,{reason:`select`,event:t})}),ve=n.t({count:Z.length,focusItems:!1,defaultActiveIndex:-1,isDisabled:ge,onSelect:Q}),{activeIndex:$,setActiveIndex:ye,activeItem:be}=ve;n.r({enabled:W,inside:[V,le],onDismiss:(e,t)=>_e(e===`escape`?`escape`:`outside-pointer`,t)}),e.n(()=>{!W||$===-1||be()?.scrollIntoView?.({block:`nearest`})},[W,$,be]);let xe=(e,t,n)=>{G(!0,{reason:n,event:t});let r=e===`none`?-1:d.activeIndexFor(Z,U,m,e);ye(r,{reason:`programmatic`,event:t})},Se=n.a(e=>{J(!0),K(e.target.value,{reason:`input`,event:e}),W||G(!0,{reason:`input`,event:e}),ye(-1,{reason:`programmatic`,event:e})}),Ce=n.a((e,t)=>{pe(U.filter(t=>Y(t)!==Y(e)),{reason:`remove`,event:t})}),we=e=>{let{key:t}=e;if(t===`ArrowDown`||t===`ArrowUp`){e.preventDefault(),xe(t===`ArrowUp`?`last`:e.altKey?`none`:`first`,e,`trigger`);return}t===`Escape`&&X!==``&&(J(!0),K(``,{reason:`clear`,event:e}))},Te=n.a(e=>{if(S?.onKeyDown?.(e),!(e.defaultPrevented||x)){if(e.key===`Backspace`&&M&&X===``&&U.length>0){Ce(U[U.length-1],e);return}if(!W){we(e);return}if(e.key===`Tab`){$!==-1&&Q($,e),_e(`tab`,e);return}if(e.altKey&&e.key===`ArrowUp`){e.preventDefault(),$===-1?_e(`trigger`,e):Q($,e);return}if(v.has(e.key)){ye(-1,{reason:`programmatic`,event:e});return}ve.onKeyDown(e)}}),Ee=n.a(e=>{!x&&!W&&xe(`first`,e,`trigger`)}),De=n.a(e=>{x||e.target===H.current||(e.preventDefault(),H.current?.focus(),W||xe(`first`,e,`trigger`))}),Oe=Z.length>0||te===!0||ne!==null,ke=W&&$!==-1&&Z.length>0?ce($):void 0,Ae=(0,l.jsx)(t.default,{tag:`input`,component:`combobox.field`,ref:ue,id:L,disabled:x,props:{...S,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":W,"aria-controls":W&&Oe?R:void 0,"aria-activedescendant":ke,"aria-labelledby":B?z:S?.[`aria-labelledby`],autoComplete:`off`,spellCheck:!1,type:`text`,value:X,placeholder:y,onChange:Se,onKeyDown:Te,onClick:Ee}}),je=!ee&&(0,l.jsx)(a.default,{component:`combobox.icon`,rotate:W?180:0,props:{"aria-hidden":!0},children:(0,l.jsx)(i.Svg,{viewBox:`0 0 10 6`,width:`0.6rem`,props:{fill:`none`},children:(0,l.jsx)(i.Path,{d:`m1 1 4 4 4-4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})})}),Me=b===void 0?null:U.map(e=>(0,l.jsx)(t.default,{tag:`input`,props:{type:`hidden`,name:b,value:String(Y(e))}},Y(e))),Ne=Oe&&(0,l.jsx)(s.default,{present:W,children:e=>(0,l.jsx)(_,{presence:e,rows:Z,def:m,display:m.display,selection:U,multiple:M,activeIndex:$,optionId:ce,rowRef:e=>ve.itemProps(e).ref,onSelect:Q,anchorRef:V,popupRef:le,listboxId:R,labelledBy:B?z:L,loading:te,loadingText:T,emptyText:ne,createLabel:D,virtualize:re,variant:F.variant,itemsProps:C})}),Pe=(0,l.jsxs)(a.default,{ref:V,component:`combobox`,ai:`center`,gap:1,flexWrap:`wrap`,...F,props:{onPointerDown:De},children:[Me,M&&(0,l.jsx)(f,{selection:U,def:m,display:m.display,removeLabel:O,onRemove:Ce,disabled:x,variant:F.variant}),Ae,je]});return B?(0,l.jsxs)(a.default,{d:`column`,gap:1,width:`fit-content`,children:[(0,l.jsx)(t.default,{tag:`label`,component:`combobox.label`,id:z,...g,props:{htmlFor:L},children:h}),Pe,Ne]}):(0,l.jsxs)(l.Fragment,{children:[Pe,Ne]})}var b=(0,c.forwardRef)(y);b.displayName=`Combobox`,exports.ComboboxUtils=d,exports.default=b;
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../effects.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../identity.cjs"),i=require("../reporting.cjs"),a=require("./svg.cjs"),o=require("./flex.cjs"),s=require("./overlay.cjs"),c=require("./presence.cjs");let l=require("react"),u=require("react/jsx-runtime");var d;(function(e){function t(e,t){return typeof e==`function`?e(t):t[e]}e.read=t;function n(e,n){let r=t(e.label,n);return r==null?``:String(r)}e.labelOf=n;function r(e,r){return e.key===void 0?n(e,r):t(e.key,r)}e.keyOf=r;function i(e,n){return e.disabled!==void 0&&t(e.disabled,n)===!0}e.isDisabled=i;let a=/\p{M}/gu;function o(e){return e.normalize(`NFD`).replace(a,``).toLowerCase()}e.normalize=o;function s(e,t){return o(e).includes(o(t))}e.matches=s;function c(e,t,n){return t===``?e:e.filter(e=>s(n(e),t))}e.filterRows=c;function l(e){return e==null?[]:Array.isArray(e)?e:[e]}e.toArray=l;function u(e,t,n){let r=n(t);return e.some(e=>n(e)===r)}e.isSelected=u;function d(e,t,n,r){return n?u(e,t,r)?e.filter(e=>r(e)!==r(t)):[...e,t]:[t]}e.toggle=d;function f(e){let{data:t,def:r,query:i,filter:a,typed:s,createRow:c}=e,l=e=>n(r,e),u=(!s||a===!1?t:a(t,i,l)).map(e=>({kind:`option`,row:e}));return c&&i!==``&&!t.some(e=>o(l(e))===o(i))&&c(i)!==null&&u.push({kind:`create`,query:i}),u}e.rowsFor=f;function p(e,t){return t.kind===`option`&&i(e,t.row)}e.isRowDisabled=p;function m(e,t,n,i=`first`){let a=e=>r(n,e),o=e.findIndex(e=>e.kind===`option`&&u(t,e.row,a));if(o!==-1&&!p(n,e[o]))return o;let s=e.map((e,t)=>p(n,e)?-1:t).filter(e=>e!==-1);return(i===`last`?s[s.length-1]:s[0])??-1}e.activeIndexFor=m})(d||={});var f=d;function p(e){let{selection:t,def:n,display:r,removeLabel:i,onRemove:s,disabled:c,variant:l}=e;return(0,u.jsx)(u.Fragment,{children:t.map(e=>{let t=f.labelOf(n,e);return(0,u.jsxs)(o.default,{component:`combobox.chip`,variant:l,ai:`center`,gap:1,children:[r?.(e)??t,!c&&(0,u.jsx)(o.default,{tag:`button`,component:`combobox.remove`,variant:l,ai:`center`,jc:`center`,props:{type:`button`,tabIndex:-1,"aria-label":i(t),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),s(e,t)}},children:(0,u.jsx)(a.Svg,{viewBox:`0 0 24 24`,width:`0.625rem`,props:{fill:`none`},children:(0,u.jsx)(a.Path,{d:`M6 6 18 18M18 6 6 18`,stroke:`currentColor`,strokeWidth:3,strokeLinecap:`round`})})})]},f.keyOf(n,e))})})}var m;(function(e){let t=e.DEFAULT_OVERSCAN=4,n=e.DEFAULT_THRESHOLD=100;e.DEFAULT_ITEM_HEIGHT=36,e.DEFAULT_VIEW_HEIGHT=248;function r(e,t,n){return Math.min(Math.max(e,t),n)}function i(e,t,r=n){return t??e>r}e.shouldVirtualize=i;function a(e){let{count:n,itemHeight:i,viewHeight:a,scrollTop:o,overscan:s=t,activeIndex:c=-1}=e;if(n<=0||i<=0)return{startIndex:0,endIndex:Math.max(0,n),offsetY:0,totalHeight:0};let l=Math.max(1,Math.ceil(a/i)),u=Math.min(n,l+s*2),d=n-u,f=r(Math.floor(o/i)-s,0,d);return c>=0&&c<n&&(c<f?f=r(c-s,0,d):c>=f+u&&(f=r(c+1+s-u,0,d))),{startIndex:f,endIndex:f+u,offsetY:f*i,totalHeight:n*i}}e.windowFor=a})(m||={});var h=m;function g(t){let{count:r,scrollerRef:i,itemHeight:a,viewHeight:o,overscan:s,threshold:c,enabled:u,activeIndex:d}=t,[f,p]=(0,l.useState)({top:0,at:-1}),[m,g]=(0,l.useState)({itemHeight:0,viewHeight:0}),_=(0,l.useRef)(null),v=(0,l.useCallback)(e=>{_.current=e},[]),y=h.shouldVirtualize(r,u,c),b=n.a(()=>{let e=i.current,t=_.current;if(!e||!t)return;let n=t.children,r=n[0],a=n[1],o=a?a.offsetTop-r.offsetTop:r?.offsetHeight??0,s=e.clientHeight;g(e=>e.itemHeight===o&&e.viewHeight===s?e:{itemHeight:o,viewHeight:s})});e.n(()=>{if(!y||(b(),typeof ResizeObserver>`u`))return;let e=i.current;if(!e)return;let t=new ResizeObserver(b);return t.observe(e),()=>t.disconnect()},[y,r,b,i]);let x=n.a(e=>{p({top:e.currentTarget.scrollTop,at:d??-1})}),S=h.windowFor({count:r,itemHeight:a??(m.itemHeight>0?m.itemHeight:h.DEFAULT_ITEM_HEIGHT),viewHeight:o??(m.viewHeight>0?m.viewHeight:h.DEFAULT_VIEW_HEIGHT),scrollTop:f.top,overscan:s,activeIndex:d===f.at?-1:d});return y?{...S,virtualized:y,contentRef:v,onScroll:x}:{startIndex:0,endIndex:r,offsetY:0,totalHeight:0,virtualized:y,contentRef:v,onScroll:x}}function _(e,t,n,r){return e?{role:`listbox`,"aria-labelledby":r,...t?{"aria-multiselectable":!0}:{},...n?{"aria-busy":!0}:{}}:{role:`status`}}function v(e){let{presence:n,rows:r,def:i,display:a,selection:c,multiple:d,activeIndex:p,optionId:m,rowRef:h,onSelect:v}=e,{anchorRef:y,popupRef:b,listboxId:x,labelledBy:S,loading:C,loadingText:ee,emptyText:te,createLabel:w,variant:T,itemsProps:ne}=e,{virtualize:E}=e,{present:D,ref:O,props:re}=n,k=e=>f.keyOf(i,e),[A,ie]=(0,l.useState)(!1),ae=(0,l.useCallback)(e=>ie(e===`top`),[]),j=(0,l.useRef)(null),oe=(0,l.useCallback)(e=>{j.current=e,O(e)},[O]),se=typeof E==`object`?E:{},{virtualized:M,startIndex:N,endIndex:ce,offsetY:le,totalHeight:P,contentRef:F,onScroll:I}=g({count:r.length,scrollerRef:j,enabled:typeof E==`boolean`?E:void 0,activeIndex:p,...se}),L=M?r.slice(N,ce):r,R=(e,t)=>{let n=M?N+t:t,s=e.kind===`option`&&f.isSelected(c,e.row,k),l=f.isRowDisabled(i,e);return(0,u.jsx)(o.default,{ref:h(n),component:`combobox.item`,variant:[T,{create:e.kind===`create`,highlighted:n===p}],selected:s,ai:`center`,gap:2,id:m(n),props:{role:`option`,...M?{"aria-setsize":r.length,"aria-posinset":n+1}:{},...l?{"aria-disabled":!0}:{},onMouseDown:e=>e.preventDefault(),onClick:e=>!l&&v(n,e)},children:e.kind===`create`?w(e.query):a?.(e.row)??f.labelOf(i,e.row)},e.kind===`option`?k(e.row):`create`)};return(0,u.jsx)(s.default,{ref:b,anchor:y,side:`bottom`,align:`start`,offset:.5,matchWidth:!0,onSideChange:ae,children:(0,u.jsxs)(t.default,{ref:oe,component:`combobox.items`,...ne,variant:[T,{closed:!D&&!A,closedUp:!D&&A}],id:x,props:{..._(r.length>0,d,C===!0,S),...re,...M?{onScroll:I}:{}},children:[M?(0,u.jsx)(t.default,{ref:F,component:`combobox.window`,variant:T,style:{height:P,paddingTop:le},children:L.map(R)}):L.map(R),r.length===0&&(0,u.jsx)(t.default,{component:`combobox.message`,variant:T,children:C?ee:te})]})})}var y=new Set([` `,`Home`,`End`,`ArrowLeft`,`ArrowRight`]);function b(s,d){let{data:m,def:h,label:g,labelProps:_,placeholder:b,name:x,disabled:S,props:C,itemsProps:ee,hideIcon:te,filter:w=f.filterRows,loading:T,loadingText:ne=`Loading...`,emptyText:E=`No results`,createRow:D,createLabel:O=e=>`Create "${e}"`,removeLabel:re=e=>`Remove ${e}`,virtualize:k,query:A,defaultQuery:ie,onQueryChange:ae,open:j,defaultOpen:oe,onOpenChange:se,multiple:M=!1,value:N,defaultValue:ce,onValueChange:le,...P}=s,F=r.t(`combobox`),I=P.id??`${F}-field`,L=`${F}-listbox`,R=`${F}-label`,z=g!=null&&g!==!1,ue=(0,l.useCallback)(e=>`${F}-option-${e}`,[F]),B=(0,l.useRef)(null),de=(0,l.useRef)(null),V=(0,l.useRef)(null),fe=(0,l.useCallback)(e=>{V.current=e,typeof d==`function`?d(e):d&&(d.current=e)},[d]),pe=n.a((e,t)=>{le?.(M?e:e[0]??null,t)}),me=(0,l.useMemo)(()=>N===void 0?void 0:f.toArray(N),[N]),[H,he]=i.a({value:me,defaultValue:()=>f.toArray(ce),onChange:pe,interaction:{component:`combobox`,type:`valueChange`,content:[`value`]}}),[U,W]=i.a({value:j,defaultValue:oe??!1,onChange:se,interaction:{component:`combobox`,type:`openChange`}}),[ge,G]=n.i({value:A,defaultValue:ie??``,onChange:ae}),[K,q]=(0,l.useState)(!1),J=(0,l.useCallback)(e=>f.keyOf(h,e),[h]),_e=M||H[0]===void 0?``:f.labelOf(h,H[0]),Y=K||ge!==``?ge:_e,X=(0,l.useMemo)(()=>f.rowsFor({data:m,def:h,query:Y,filter:w,typed:K,createRow:D}),[m,h,Y,w,K,D]),ve=(0,l.useCallback)(e=>X[e]?f.isRowDisabled(h,X[e]):!1,[X,h]),Z=n.a((e,t)=>{W(!1,{reason:e,event:t}),e!==`escape`&&(q(!1),G(``,{reason:`close`,event:t}))}),Q=n.a((e,t)=>{let n=X[e];if(!n||ve(e))return;let r=n.kind===`create`?D?.(n.query):n.row;if(r==null)return;let i=f.isSelected(H,r,J),a=n.kind===`create`?`create`:i&&M?`deselect`:`select`;he(f.toggle(H,r,M,J),{reason:a,event:t}),q(!1),G(``,{reason:`select`,event:t}),M||W(!1,{reason:`select`,event:t})}),ye=n.t({count:X.length,focusItems:!1,defaultActiveIndex:-1,isDisabled:ve,onSelect:Q}),{activeIndex:$,setActiveIndex:be,activeItem:xe}=ye;n.r({enabled:U,inside:[B,de],onDismiss:(e,t)=>Z(e===`escape`?`escape`:`outside-pointer`,t)}),e.n(()=>{!U||$===-1||xe()?.scrollIntoView?.({block:`nearest`})},[U,$,xe]);let Se=(e,t,n)=>{W(!0,{reason:n,event:t});let r=e===`none`?-1:f.activeIndexFor(X,H,h,e);be(r,{reason:`programmatic`,event:t})},Ce=n.a(e=>{q(!0),G(e.target.value,{reason:`input`,event:e}),U||W(!0,{reason:`input`,event:e}),be(-1,{reason:`programmatic`,event:e})}),we=n.a((e,t)=>{he(H.filter(t=>J(t)!==J(e)),{reason:`remove`,event:t})}),Te=e=>{let{key:t}=e;if(t===`ArrowDown`||t===`ArrowUp`){e.preventDefault(),Se(t===`ArrowUp`?`last`:e.altKey?`none`:`first`,e,`trigger`);return}t===`Escape`&&Y!==``&&(q(!0),G(``,{reason:`clear`,event:e}))},Ee=n.a(e=>{if(C?.onKeyDown?.(e),!(e.defaultPrevented||S)){if(e.key===`Backspace`&&M&&Y===``&&H.length>0){we(H[H.length-1],e);return}if(!U){Te(e);return}if(e.key===`Tab`){$!==-1&&Q($,e),Z(`tab`,e);return}if(e.altKey&&e.key===`ArrowUp`){e.preventDefault(),$===-1?Z(`trigger`,e):Q($,e);return}if(y.has(e.key)){be(-1,{reason:`programmatic`,event:e});return}ye.onKeyDown(e)}}),De=n.a(e=>{!S&&!U&&Se(`first`,e,`trigger`)}),Oe=n.a(e=>{S||e.target===V.current||(e.preventDefault(),V.current?.focus(),U||Se(`first`,e,`trigger`))}),ke=X.length>0||T===!0||E!==null,Ae=U&&$!==-1&&X.length>0?ue($):void 0,je=(0,u.jsx)(t.default,{tag:`input`,component:`combobox.field`,ref:fe,id:I,disabled:S,props:{...C,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":U,"aria-controls":U&&ke?L:void 0,"aria-activedescendant":Ae,"aria-labelledby":z?R:C?.[`aria-labelledby`],autoComplete:`off`,spellCheck:!1,type:`text`,value:Y,placeholder:b,onChange:Ce,onKeyDown:Ee,onClick:De}}),Me=!te&&(0,u.jsx)(o.default,{component:`combobox.icon`,rotate:U?180:0,props:{"aria-hidden":!0},children:(0,u.jsx)(a.Svg,{viewBox:`0 0 10 6`,width:`0.6rem`,props:{fill:`none`},children:(0,u.jsx)(a.Path,{d:`m1 1 4 4 4-4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})})}),Ne=x===void 0?null:H.map(e=>(0,u.jsx)(t.default,{tag:`input`,props:{type:`hidden`,name:x,value:String(J(e))}},J(e))),Pe=ke&&(0,u.jsx)(c.default,{present:U,children:e=>(0,u.jsx)(v,{presence:e,rows:X,def:h,display:h.display,selection:H,multiple:M,activeIndex:$,optionId:ue,rowRef:e=>ye.itemProps(e).ref,onSelect:Q,anchorRef:B,popupRef:de,listboxId:L,labelledBy:z?R:I,loading:T,loadingText:ne,emptyText:E,createLabel:O,virtualize:k,variant:P.variant,itemsProps:ee})}),Fe=(0,u.jsxs)(o.default,{ref:B,component:`combobox`,ai:`center`,gap:1,flexWrap:`wrap`,...P,props:{onPointerDown:Oe},children:[Ne,M&&(0,u.jsx)(p,{selection:H,def:h,display:h.display,removeLabel:re,onRemove:we,disabled:S,variant:P.variant}),je,Me]});return z?(0,u.jsxs)(o.default,{d:`column`,gap:1,width:`fit-content`,children:[(0,u.jsx)(t.default,{tag:`label`,component:`combobox.label`,id:R,..._,props:{htmlFor:I},children:g}),Fe,Pe]}):(0,u.jsxs)(u.Fragment,{children:[Fe,Pe]})}var x=(0,l.forwardRef)(b);x.displayName=`Combobox`,exports.ComboboxUtils=f,exports.default=x;
|