@box-kite/react 2.2.5 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/rules/box-kite-rules.md +3 -1
- package/.claude/skills/box-kite/SKILL.md +3 -1
- package/.claude/skills/box-kite/references/components.md +34 -0
- package/.cursor/rules/box-kite.mdc +3 -1
- package/AGENTS.md +3 -1
- package/BOX_AI_CONTEXT.md +95 -5
- package/BOX_KITE_AI_CONTEXT.md +95 -5
- package/box.cjs +1 -1
- package/box.mjs +7 -7
- package/catalog.cjs +1 -1
- package/catalog.mjs +521 -0
- package/client.cjs +1 -1
- package/client.mjs +94 -106
- package/components/calendar.cjs +1 -0
- package/components/calendar.d.ts +77 -0
- package/components/calendar.mjs +483 -0
- package/components/dataGrid/components/dataGridBooleanValue.d.ts +11 -0
- package/components/dataGrid/components/dataGridDateParts.d.ts +40 -0
- package/components/dataGrid/components/dataGridDateValue.d.ts +14 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +38 -11
- package/components/dataGrid/models/columnModel.d.ts +3 -1
- package/components/dataGrid/models/editModel.d.ts +3 -1
- package/components/dataGrid/models/localeText.d.ts +4 -0
- package/components/dataGrid/useDateParts.d.ts +17 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +797 -664
- package/components/dateField.cjs +1 -0
- package/components/dateField.d.ts +78 -0
- package/components/dateField.mjs +313 -0
- package/components/datePicker.cjs +1 -0
- package/components/datePicker.d.ts +120 -0
- package/components/datePicker.mjs +529 -0
- package/components/dateTime.cjs +1 -0
- package/components/dateTime.d.ts +23 -0
- package/components/dateTime.mjs +34 -0
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +87 -75
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +1 -1
- package/components/semantics.d.ts +29 -29
- package/components/timeZoneSelect.cjs +1 -0
- package/components/timeZoneSelect.d.ts +52 -0
- package/components/timeZoneSelect.mjs +74 -0
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +1 -1
- package/dataGridDateParts.cjs +1 -0
- package/dataGridDateParts.mjs +223 -0
- package/dataGridList.cjs +1 -1
- package/dataGridList.mjs +328 -365
- package/dataGridListLayout.cjs +1 -0
- package/dataGridListLayout.mjs +49 -0
- package/date-environment.cjs +1 -0
- package/date-environment.mjs +29 -0
- package/date-input.cjs +1 -0
- package/date-input.mjs +346 -0
- package/date-math.cjs +1 -0
- package/date-math.mjs +317 -0
- package/date.cjs +1 -0
- package/date.d.ts +40 -0
- package/date.mjs +4 -0
- package/dates.cjs +1 -0
- package/dates.mjs +689 -0
- package/docs/components.md +6 -1
- package/package.json +118 -26
- package/react/boxComponent.d.ts +1 -1
- package/react/date/dateChange.d.ts +18 -0
- package/react/date/dateEnvironment.d.ts +34 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/ssg.cjs +1 -1
- package/ssg.mjs +1 -1
- package/utils/date/calendar.d.ts +44 -0
- package/utils/date/calendarModel.d.ts +46 -0
- package/utils/date/dateTime.d.ts +144 -0
- package/utils/date/fieldModel.d.ts +74 -0
- package/utils/date/format.d.ts +39 -0
- package/utils/date/iso.d.ts +40 -0
- package/utils/date/locale.d.ts +17 -0
- package/utils/date/parse.d.ts +20 -0
- package/utils/date/settings.d.ts +26 -0
- package/utils/date/value.d.ts +43 -0
- package/utils/date/zoneOptions.d.ts +19 -0
- package/utils/date/zones.d.ts +32 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { d as e } from "../platform.mjs";
|
|
3
|
+
import t from "../box.mjs";
|
|
4
|
+
import { a as n, i as r } from "../behavior.mjs";
|
|
5
|
+
import { t as i } from "../identity.mjs";
|
|
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
|
+
import { N as re, x as ie } from "../date-math.mjs";
|
|
8
|
+
import { Path as ae, Svg as oe } from "./svg.mjs";
|
|
9
|
+
import { n as se } from "../date-environment.mjs";
|
|
10
|
+
import ce from "./visuallyHidden.mjs";
|
|
11
|
+
import { useEffect as le, useMemo as ue, useRef as de, useState as h } from "react";
|
|
12
|
+
import { Fragment as fe, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
|
+
//#region src/utils/date/calendarModel.ts
|
|
14
|
+
function v(e) {
|
|
15
|
+
let t = d(e);
|
|
16
|
+
return t && t.kind === "date" ? t.fields : null;
|
|
17
|
+
}
|
|
18
|
+
function y(e) {
|
|
19
|
+
return m({
|
|
20
|
+
...e,
|
|
21
|
+
...ee
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function pe(e, t, n) {
|
|
25
|
+
let r = {
|
|
26
|
+
year: e,
|
|
27
|
+
month: t,
|
|
28
|
+
day: 1
|
|
29
|
+
}, i = l(r, -s(o(r) - n, 7));
|
|
30
|
+
return Array.from({ length: 6 }, (e, r) => {
|
|
31
|
+
let a = Array.from({ length: 7 }, (e, n) => {
|
|
32
|
+
let a = l(i, r * 7 + n);
|
|
33
|
+
return {
|
|
34
|
+
date: y(a),
|
|
35
|
+
day: a.day,
|
|
36
|
+
outside: a.month !== t
|
|
37
|
+
};
|
|
38
|
+
}), o = l(i, r * 7 + s(4 - n, 7));
|
|
39
|
+
return {
|
|
40
|
+
week: te(o).week,
|
|
41
|
+
days: a
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function me(e, t, n, r) {
|
|
46
|
+
let i = r.rtl ? "ArrowLeft" : "ArrowRight", a = r.rtl ? "ArrowRight" : "ArrowLeft";
|
|
47
|
+
switch (t) {
|
|
48
|
+
case i: return l(e, 1);
|
|
49
|
+
case a: return l(e, -1);
|
|
50
|
+
case "ArrowDown": return l(e, 7);
|
|
51
|
+
case "ArrowUp": return l(e, -7);
|
|
52
|
+
case "Home": return l(e, -s(o(e) - r.firstDay, 7));
|
|
53
|
+
case "End": return l(e, 6 - s(o(e) - r.firstDay, 7));
|
|
54
|
+
case "PageUp": return u(e, n ? -12 : -1);
|
|
55
|
+
case "PageDown": return u(e, n ? 12 : 1);
|
|
56
|
+
default: return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function he(e, t) {
|
|
60
|
+
return t.min != null && f(e) < f(t.min) || t.max != null && f(e) > f(t.max);
|
|
61
|
+
}
|
|
62
|
+
function b(e, t) {
|
|
63
|
+
return t.min && f(e) < f(t.min) ? t.min : t.max && f(e) > f(t.max) ? t.max : e;
|
|
64
|
+
}
|
|
65
|
+
function x(e, t) {
|
|
66
|
+
return f(e) <= f(t) ? [e, t] : [t, e];
|
|
67
|
+
}
|
|
68
|
+
function ge(e, t, n) {
|
|
69
|
+
if (!t || !n) return t && f(e) === f(t) ? "start" : null;
|
|
70
|
+
let [r, i] = x(t, n), a = f(e);
|
|
71
|
+
return a === f(r) ? "start" : a === f(i) ? "end" : a > f(r) && a < f(i) ? "middle" : null;
|
|
72
|
+
}
|
|
73
|
+
function _e(e, t, n) {
|
|
74
|
+
let [r, i] = x(e, t);
|
|
75
|
+
for (let e = f(r); e <= f(i); e++) if (n(y(l({
|
|
76
|
+
year: 1970,
|
|
77
|
+
month: 1,
|
|
78
|
+
day: 1
|
|
79
|
+
}, e)))) return !0;
|
|
80
|
+
return !1;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/components/calendar.tsx
|
|
84
|
+
var S = "data-date", C = 12;
|
|
85
|
+
function w(e, t) {
|
|
86
|
+
return e !== null && t !== null && f(e) === f(t);
|
|
87
|
+
}
|
|
88
|
+
function T(o) {
|
|
89
|
+
let { mode: s = "single", value: l, defaultValue: ee = null, onValueChange: te, min: d, max: f, isDateUnavailable: m, locale: ae, zone: oe, firstDayOfWeek: T, months: D = 1, weekNumbers: k = !1, showOutsideDays: be = !0, focusedDate: xe, defaultFocusedDate: Se, onFocusedDateChange: Ce, disabled: A = !1, readOnly: we = !1, autoFocus: Te = !1, label: j, previousLabel: Ee = "Previous", nextLabel: De = "Next", props: Oe, ...ke } = o, M = se({
|
|
90
|
+
locale: ae,
|
|
91
|
+
zone: oe
|
|
92
|
+
}), { locale: N } = M, P = v(re(M.zone)), F = T ?? c(N).firstDay, I = (e) => ve(N).format(e), L = s === "range", R = ue(() => ({
|
|
93
|
+
min: v(d),
|
|
94
|
+
max: v(f)
|
|
95
|
+
}), [d, f]), [z, Ae] = r({
|
|
96
|
+
value: l,
|
|
97
|
+
defaultValue: ee,
|
|
98
|
+
onChange: (e, t) => {
|
|
99
|
+
te?.(e, L ? t : {
|
|
100
|
+
...t,
|
|
101
|
+
...ie(e, M.zone)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}), je = L ? null : v(z), B = L && z ? z : null, [V, H] = h(null), [Me, U] = h(null), Ne = y(b(v(Se) ?? je ?? v(B?.start) ?? P, R)), [Pe, W] = r({
|
|
105
|
+
value: xe,
|
|
106
|
+
defaultValue: Ne,
|
|
107
|
+
onChange: Ce
|
|
108
|
+
}), G = v(Pe) ?? P, [K, Fe] = h("day"), [q, Ie] = h(() => E(G)), J = q;
|
|
109
|
+
(E(G) < q || E(G) > q + D - 1) && (J = E(G) < q ? E(G) : E(G) - D + 1, Ie(J));
|
|
110
|
+
let Le = de(null), Y = de(Te), Re = i("calendar");
|
|
111
|
+
le(() => {
|
|
112
|
+
Y.current && (Y.current = !1, Le.current?.querySelector(`[${S}="${Pe}"]`)?.focus());
|
|
113
|
+
});
|
|
114
|
+
let ze = (e) => he(e, R), Be = (e) => m?.(y(e)) ?? !1, X = (e, t, n) => {
|
|
115
|
+
Y.current = n, W(y(b(e, R)), { reason: t });
|
|
116
|
+
}, Ve = (e, t) => {
|
|
117
|
+
if (A || we || ze(e) || Be(e)) return;
|
|
118
|
+
if (X(e, "keyboard", !1), !L) {
|
|
119
|
+
Ae(y(e), {
|
|
120
|
+
reason: "select",
|
|
121
|
+
event: t
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!V) {
|
|
126
|
+
H(e), U(e);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let [n, r] = x(V, e);
|
|
130
|
+
H(null), U(null), !(m && _e(n, r, m)) && Ae({
|
|
131
|
+
start: y(n),
|
|
132
|
+
end: y(r)
|
|
133
|
+
}, {
|
|
134
|
+
reason: "select",
|
|
135
|
+
event: t
|
|
136
|
+
});
|
|
137
|
+
}, He = n((t) => {
|
|
138
|
+
if (A) return;
|
|
139
|
+
if (t.key === "Enter" || t.key === " ") {
|
|
140
|
+
t.preventDefault(), Ve(G, t);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (t.key === "Escape" && V) {
|
|
144
|
+
t.preventDefault(), t.stopPropagation(), H(null), U(null);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
let n = me(G, t.key, t.shiftKey, {
|
|
148
|
+
rtl: e(t.currentTarget),
|
|
149
|
+
firstDay: F
|
|
150
|
+
});
|
|
151
|
+
n && (t.preventDefault(), X(n, "keyboard", !0), V && U(b(n, R)));
|
|
152
|
+
}), Ue = (e) => {
|
|
153
|
+
K === "day" ? (Ie(J + e * D), X(u(G, e * D), "navigate", !1)) : X(u(G, e * (K === "month" ? 12 : 144)), "navigate", !1);
|
|
154
|
+
}, Z = Array.from({ length: D }, (e, t) => ({
|
|
155
|
+
year: Math.floor((J + t) / 12),
|
|
156
|
+
month: (J + t) % 12 + 1,
|
|
157
|
+
day: 1
|
|
158
|
+
})), Q = `${Re}-title`, We = K === "day" && D > 1, Ge = K === "day" ? Z.map((e) => p(y(e), {
|
|
159
|
+
locale: N,
|
|
160
|
+
month: "long",
|
|
161
|
+
year: "numeric"
|
|
162
|
+
})).join(" – ") : K === "month" ? I(G.year) : `${I(O(G.year))} – ${I(O(G.year) + C - 1)}`, Ke = a(N, "short"), qe = Ke.some((e) => e.length > 4) ? a(N, "narrow") : Ke, Je = a(N, "long"), Ye = Array.from({ length: 7 }, (e, t) => (F + t) % 7), Xe = V ? Me ?? V : null, Ze = V ?? v(B?.start), $ = V ? Xe : v(B?.end), Qe = (e) => {
|
|
163
|
+
let n = v(e.date), r = ze(n), i = Be(n), a = L ? ge(n, Ze, $) : null, o = L ? a !== null : w(n, je), s = w(n, P), c = w(n, G);
|
|
164
|
+
return e.outside && (!be || D > 1) ? /* @__PURE__ */ g(t, {
|
|
165
|
+
tag: "td",
|
|
166
|
+
component: "calendar.cell",
|
|
167
|
+
display: "table-cell",
|
|
168
|
+
props: { role: "gridcell" }
|
|
169
|
+
}, e.date) : /* @__PURE__ */ g(t, {
|
|
170
|
+
tag: "td",
|
|
171
|
+
component: "calendar.cell",
|
|
172
|
+
display: "table-cell",
|
|
173
|
+
p: 0,
|
|
174
|
+
py: .5,
|
|
175
|
+
variant: {
|
|
176
|
+
rangeStart: a === "start" && $ !== null && !w(Ze, $),
|
|
177
|
+
rangeEnd: a === "end",
|
|
178
|
+
rangeMiddle: a === "middle"
|
|
179
|
+
},
|
|
180
|
+
props: {
|
|
181
|
+
role: "gridcell",
|
|
182
|
+
"aria-selected": o || void 0,
|
|
183
|
+
"aria-disabled": r || A || void 0,
|
|
184
|
+
"aria-current": s ? "date" : void 0
|
|
185
|
+
},
|
|
186
|
+
children: /* @__PURE__ */ g(t, {
|
|
187
|
+
component: "calendar.day",
|
|
188
|
+
display: "flex",
|
|
189
|
+
ai: "center",
|
|
190
|
+
jc: "center",
|
|
191
|
+
width: 9,
|
|
192
|
+
height: 9,
|
|
193
|
+
mx: "auto",
|
|
194
|
+
borderRadius: 999,
|
|
195
|
+
fontSize: 14,
|
|
196
|
+
css: { fontVariantNumeric: "tabular-nums" },
|
|
197
|
+
variant: {
|
|
198
|
+
today: s,
|
|
199
|
+
selected: o && a !== "middle",
|
|
200
|
+
outside: e.outside,
|
|
201
|
+
blocked: r || A,
|
|
202
|
+
unavailable: i
|
|
203
|
+
},
|
|
204
|
+
props: {
|
|
205
|
+
[S]: e.date,
|
|
206
|
+
tabIndex: c && !r && !A ? 0 : -1,
|
|
207
|
+
"aria-label": p(e.date, {
|
|
208
|
+
locale: N,
|
|
209
|
+
dateStyle: "full"
|
|
210
|
+
}),
|
|
211
|
+
onClick: (e) => Ve(n, e),
|
|
212
|
+
onPointerEnter: () => V && U(n)
|
|
213
|
+
},
|
|
214
|
+
children: I(e.day)
|
|
215
|
+
})
|
|
216
|
+
}, e.date);
|
|
217
|
+
}, $e = (t, n, r, i, a, o) => {
|
|
218
|
+
let s = e(t.currentTarget), c = {
|
|
219
|
+
ArrowUp: -r,
|
|
220
|
+
ArrowDown: r,
|
|
221
|
+
[s ? "ArrowRight" : "ArrowLeft"]: -1,
|
|
222
|
+
[s ? "ArrowLeft" : "ArrowRight"]: 1
|
|
223
|
+
};
|
|
224
|
+
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
|
+
}, et = () => {
|
|
226
|
+
let e = ne(N, "short"), n = O(G.year), r = K === "month" ? e.map((e, t) => ({
|
|
227
|
+
label: e,
|
|
228
|
+
active: t + 1 === G.month,
|
|
229
|
+
current: P.year === G.year && P.month === t + 1
|
|
230
|
+
})) : Array.from({ length: C }, (e, t) => ({
|
|
231
|
+
label: I(n + t),
|
|
232
|
+
active: n + t === G.year,
|
|
233
|
+
current: P.year === n + t
|
|
234
|
+
})), i = (e) => K === "month" ? {
|
|
235
|
+
...G,
|
|
236
|
+
month: e + 1,
|
|
237
|
+
day: 1
|
|
238
|
+
} : {
|
|
239
|
+
...G,
|
|
240
|
+
year: n + e,
|
|
241
|
+
day: 1
|
|
242
|
+
}, a = (e) => {
|
|
243
|
+
let t = i(e);
|
|
244
|
+
Y.current = !0, W(y(b({
|
|
245
|
+
...t,
|
|
246
|
+
day: Math.min(G.day, 28)
|
|
247
|
+
}, R)), { reason: "navigate" }), Fe(K === "year" ? "month" : "day");
|
|
248
|
+
}, o = (e, t) => {
|
|
249
|
+
let n = i(e);
|
|
250
|
+
W(y({
|
|
251
|
+
...n,
|
|
252
|
+
day: Math.min(G.day, 28)
|
|
253
|
+
}), { reason: "keyboard" }), t?.querySelector(`[data-zoom="${e}"]`)?.focus();
|
|
254
|
+
};
|
|
255
|
+
return /* @__PURE__ */ g(t, {
|
|
256
|
+
display: "grid",
|
|
257
|
+
gridTemplateColumns: 3,
|
|
258
|
+
gap: 1,
|
|
259
|
+
props: {
|
|
260
|
+
role: "group",
|
|
261
|
+
"aria-labelledby": Q
|
|
262
|
+
},
|
|
263
|
+
children: r.map((e, n) => /* @__PURE__ */ g(t, {
|
|
264
|
+
tag: "button",
|
|
265
|
+
component: "calendar.zoomItem",
|
|
266
|
+
variant: {
|
|
267
|
+
selected: e.active,
|
|
268
|
+
today: e.current
|
|
269
|
+
},
|
|
270
|
+
py: 2,
|
|
271
|
+
borderRadius: 2,
|
|
272
|
+
disabled: A,
|
|
273
|
+
props: {
|
|
274
|
+
type: "button",
|
|
275
|
+
"data-zoom": n,
|
|
276
|
+
tabIndex: e.active ? 0 : -1,
|
|
277
|
+
"aria-pressed": e.active,
|
|
278
|
+
onClick: () => a(n),
|
|
279
|
+
onKeyDown: (e) => $e(e, r.length, 3, a, o, n)
|
|
280
|
+
},
|
|
281
|
+
children: e.label
|
|
282
|
+
}, e.label))
|
|
283
|
+
});
|
|
284
|
+
}, tt = (e, n) => {
|
|
285
|
+
let r = pe(e.year, e.month, F), i = p(y(e), {
|
|
286
|
+
locale: N,
|
|
287
|
+
month: "long",
|
|
288
|
+
year: "numeric"
|
|
289
|
+
});
|
|
290
|
+
return /* @__PURE__ */ _(t, {
|
|
291
|
+
tag: "table",
|
|
292
|
+
css: {
|
|
293
|
+
borderCollapse: "collapse",
|
|
294
|
+
tableLayout: "fixed"
|
|
295
|
+
},
|
|
296
|
+
props: {
|
|
297
|
+
role: "grid",
|
|
298
|
+
"aria-label": D > 1 ? i : void 0,
|
|
299
|
+
"aria-labelledby": D > 1 ? void 0 : Q,
|
|
300
|
+
"aria-readonly": we || void 0,
|
|
301
|
+
onKeyDown: He
|
|
302
|
+
},
|
|
303
|
+
children: [/* @__PURE__ */ g(t, {
|
|
304
|
+
tag: "thead",
|
|
305
|
+
display: "table-header-group",
|
|
306
|
+
children: /* @__PURE__ */ _(t, {
|
|
307
|
+
tag: "tr",
|
|
308
|
+
display: "table-row",
|
|
309
|
+
children: [k && /* @__PURE__ */ g(t, {
|
|
310
|
+
tag: "th",
|
|
311
|
+
display: "table-cell",
|
|
312
|
+
component: "calendar.weekday",
|
|
313
|
+
props: { "aria-hidden": !0 }
|
|
314
|
+
}), Ye.map((e) => /* @__PURE__ */ g(t, {
|
|
315
|
+
tag: "th",
|
|
316
|
+
display: "table-cell",
|
|
317
|
+
component: "calendar.weekday",
|
|
318
|
+
pb: 1,
|
|
319
|
+
fontSize: 12,
|
|
320
|
+
props: {
|
|
321
|
+
scope: "col",
|
|
322
|
+
abbr: Je[e]
|
|
323
|
+
},
|
|
324
|
+
children: qe[e]
|
|
325
|
+
}, e))]
|
|
326
|
+
})
|
|
327
|
+
}), /* @__PURE__ */ g(t, {
|
|
328
|
+
tag: "tbody",
|
|
329
|
+
display: "table-row-group",
|
|
330
|
+
children: r.map((e) => /* @__PURE__ */ _(t, {
|
|
331
|
+
tag: "tr",
|
|
332
|
+
display: "table-row",
|
|
333
|
+
children: [k && /* @__PURE__ */ g(t, {
|
|
334
|
+
tag: "td",
|
|
335
|
+
display: "table-cell",
|
|
336
|
+
component: "calendar.weekNumber",
|
|
337
|
+
fontSize: 11,
|
|
338
|
+
textAlign: "center",
|
|
339
|
+
props: { role: "rowheader" },
|
|
340
|
+
children: I(e.week)
|
|
341
|
+
}), e.days.map(Qe)]
|
|
342
|
+
}, e.days[0].date))
|
|
343
|
+
})]
|
|
344
|
+
}, n);
|
|
345
|
+
};
|
|
346
|
+
return /* @__PURE__ */ _(t, {
|
|
347
|
+
ref: Le,
|
|
348
|
+
component: "calendar",
|
|
349
|
+
display: "inline-block",
|
|
350
|
+
...ke,
|
|
351
|
+
variant: [ke.variant, { disabled: A }],
|
|
352
|
+
props: {
|
|
353
|
+
role: j ? "group" : void 0,
|
|
354
|
+
"aria-label": j,
|
|
355
|
+
...Oe,
|
|
356
|
+
onPointerLeave: () => V && U(V)
|
|
357
|
+
},
|
|
358
|
+
children: [/* @__PURE__ */ _(t, {
|
|
359
|
+
position: "relative",
|
|
360
|
+
minHeight: 8,
|
|
361
|
+
mb: 2,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ g(t, {
|
|
364
|
+
tag: "button",
|
|
365
|
+
component: "calendar.nav",
|
|
366
|
+
position: "absolute",
|
|
367
|
+
top: 0,
|
|
368
|
+
insetStart: 0,
|
|
369
|
+
display: "inline-flex",
|
|
370
|
+
ai: "center",
|
|
371
|
+
jc: "center",
|
|
372
|
+
width: 8,
|
|
373
|
+
height: 8,
|
|
374
|
+
borderRadius: 2,
|
|
375
|
+
disabled: A,
|
|
376
|
+
props: {
|
|
377
|
+
type: "button",
|
|
378
|
+
"aria-label": Ee,
|
|
379
|
+
onClick: () => Ue(-1)
|
|
380
|
+
},
|
|
381
|
+
children: /* @__PURE__ */ g(ye, { direction: -1 })
|
|
382
|
+
}),
|
|
383
|
+
We ? /* @__PURE__ */ _(fe, { children: [/* @__PURE__ */ g(t, {
|
|
384
|
+
display: "flex",
|
|
385
|
+
gap: 4,
|
|
386
|
+
children: Z.map((e) => /* @__PURE__ */ g(t, {
|
|
387
|
+
flex1: !0,
|
|
388
|
+
textAlign: "center",
|
|
389
|
+
py: 1.5,
|
|
390
|
+
fontSize: 14,
|
|
391
|
+
fontWeight: 600,
|
|
392
|
+
props: { "aria-hidden": !0 },
|
|
393
|
+
children: p(y(e), {
|
|
394
|
+
locale: N,
|
|
395
|
+
month: "long",
|
|
396
|
+
year: "numeric"
|
|
397
|
+
})
|
|
398
|
+
}, y(e)))
|
|
399
|
+
}), /* @__PURE__ */ g(ce, {
|
|
400
|
+
id: Q,
|
|
401
|
+
props: { "aria-live": "polite" },
|
|
402
|
+
children: Ge
|
|
403
|
+
})] }) : /* @__PURE__ */ g(t, {
|
|
404
|
+
display: "flex",
|
|
405
|
+
jc: "center",
|
|
406
|
+
px: 9,
|
|
407
|
+
children: /* @__PURE__ */ g(t, {
|
|
408
|
+
tag: "button",
|
|
409
|
+
component: "calendar.title",
|
|
410
|
+
py: 1.5,
|
|
411
|
+
px: 3,
|
|
412
|
+
borderRadius: 2,
|
|
413
|
+
fontSize: 14,
|
|
414
|
+
id: Q,
|
|
415
|
+
disabled: A || K === "year",
|
|
416
|
+
props: {
|
|
417
|
+
type: "button",
|
|
418
|
+
"aria-live": "polite",
|
|
419
|
+
onClick: () => Fe(K === "day" ? "month" : "year")
|
|
420
|
+
},
|
|
421
|
+
children: Ge
|
|
422
|
+
})
|
|
423
|
+
}),
|
|
424
|
+
/* @__PURE__ */ g(t, {
|
|
425
|
+
tag: "button",
|
|
426
|
+
component: "calendar.nav",
|
|
427
|
+
position: "absolute",
|
|
428
|
+
top: 0,
|
|
429
|
+
insetEnd: 0,
|
|
430
|
+
display: "inline-flex",
|
|
431
|
+
ai: "center",
|
|
432
|
+
jc: "center",
|
|
433
|
+
width: 8,
|
|
434
|
+
height: 8,
|
|
435
|
+
borderRadius: 2,
|
|
436
|
+
disabled: A,
|
|
437
|
+
props: {
|
|
438
|
+
type: "button",
|
|
439
|
+
"aria-label": De,
|
|
440
|
+
onClick: () => Ue(1)
|
|
441
|
+
},
|
|
442
|
+
children: /* @__PURE__ */ g(ye, { direction: 1 })
|
|
443
|
+
})
|
|
444
|
+
]
|
|
445
|
+
}), K === "day" ? /* @__PURE__ */ g(t, {
|
|
446
|
+
display: "flex",
|
|
447
|
+
gap: 4,
|
|
448
|
+
ai: "start",
|
|
449
|
+
children: Z.map(tt)
|
|
450
|
+
}) : et()]
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function E(e) {
|
|
454
|
+
return e.year * 12 + e.month - 1;
|
|
455
|
+
}
|
|
456
|
+
var D = /* @__PURE__ */ new Map();
|
|
457
|
+
function ve(e) {
|
|
458
|
+
let t = D.get(e);
|
|
459
|
+
return t || (t = new Intl.NumberFormat(e, { useGrouping: !1 }), D.set(e, t)), t;
|
|
460
|
+
}
|
|
461
|
+
function O(e) {
|
|
462
|
+
return e - (e % C + C) % C;
|
|
463
|
+
}
|
|
464
|
+
function ye({ direction: e }) {
|
|
465
|
+
return /* @__PURE__ */ g(oe, {
|
|
466
|
+
viewBox: "0 0 16 16",
|
|
467
|
+
width: "1rem",
|
|
468
|
+
height: "1rem",
|
|
469
|
+
rtl: { flip: "xAxis" },
|
|
470
|
+
props: { fill: "none" },
|
|
471
|
+
children: /* @__PURE__ */ g(ae, {
|
|
472
|
+
d: e === 1 ? "M6 3l5 5-5 5" : "M10 3L5 8l5 5",
|
|
473
|
+
stroke: "currentColor",
|
|
474
|
+
strokeWidth: 2,
|
|
475
|
+
strokeLinecap: "round",
|
|
476
|
+
strokeLinejoin: "round"
|
|
477
|
+
})
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
var k = T;
|
|
481
|
+
k.displayName = "Calendar";
|
|
482
|
+
//#endregion
|
|
483
|
+
export { k as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
value: boolean;
|
|
3
|
+
/** The words for the two, out of the grid's `localeText`. */
|
|
4
|
+
text: {
|
|
5
|
+
booleanTrue: string;
|
|
6
|
+
booleanFalse: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/** A boolean cell: a check or a muted cross, with the word a screen reader reads, since React writes `true` as nothing. */
|
|
10
|
+
export default function DataGridBooleanValue(props: Props): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CellEditorConfig, ColumnDateFormat } from '../contracts/dataGridContract';
|
|
2
|
+
import { default as CellModel } from '../models/cellModel';
|
|
3
|
+
import { default as ColumnModel } from '../models/columnModel';
|
|
4
|
+
/** A cell's date in the reader's language and zone — the hook `<DateTime>` reads, so a server render hydrates. */
|
|
5
|
+
declare function DateValue(props: {
|
|
6
|
+
value: unknown;
|
|
7
|
+
format: ColumnDateFormat;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
interface EditorProps<TRow> {
|
|
10
|
+
cell: CellModel<TRow>;
|
|
11
|
+
label: string;
|
|
12
|
+
errorId?: string;
|
|
13
|
+
onBlur: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** The `date`/`time`/`datetime` editor: a compact `DateField` bound to the cell's draft. */
|
|
16
|
+
declare function DateEditor<TRow>(props: EditorProps<TRow>): import("react").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* The filter row's date filter: a comparison and a day, or two for a span, each a `DatePicker` — typed or picked.
|
|
19
|
+
* A day is only ever whole or absent, so each one commits as it completes rather than after a pause.
|
|
20
|
+
*/
|
|
21
|
+
declare function DateFilter<TRow>(props: {
|
|
22
|
+
column: ColumnModel<TRow>;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/** The list layout's date filter: a `DatePicker` per end, and the platform's own picker for the comparison. */
|
|
25
|
+
declare function ListDateFilter<TRow>(props: {
|
|
26
|
+
column: ColumnModel<TRow>;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
28
|
+
/** A pasted field read the way a date editor reads a paste: ISO, or the reader's own order. */
|
|
29
|
+
declare function parsePasted<TRow>(editor: CellEditorConfig<TRow>, text: string): string | null;
|
|
30
|
+
/** A date filter's value as the list's chip writes it. */
|
|
31
|
+
declare function describeDay(value: string, valueTo?: string): string;
|
|
32
|
+
declare const DataGridDateParts: {
|
|
33
|
+
DateValue: typeof DateValue;
|
|
34
|
+
DateEditor: typeof DateEditor;
|
|
35
|
+
DateFilter: typeof DateFilter;
|
|
36
|
+
ListDateFilter: typeof ListDateFilter;
|
|
37
|
+
parsePasted: typeof parsePasted;
|
|
38
|
+
describeDay: typeof describeDay;
|
|
39
|
+
};
|
|
40
|
+
export default DataGridDateParts;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnDateFormat } from '../contracts/dataGridContract';
|
|
2
|
+
import { default as ColumnModel } from '../models/columnModel';
|
|
3
|
+
/**
|
|
4
|
+
* How a column's value is written as a date, or `null` when it is not one: the column says so, a date editor
|
|
5
|
+
* says so, or a `Date` does — which could not be rendered as it stands.
|
|
6
|
+
*/
|
|
7
|
+
export declare function dateFormatOf<TRow>(column: ColumnModel<TRow>, value: unknown): ColumnDateFormat | null;
|
|
8
|
+
interface Props {
|
|
9
|
+
value: unknown;
|
|
10
|
+
format: ColumnDateFormat;
|
|
11
|
+
}
|
|
12
|
+
/** A cell's date, once the date parts have arrived — and until then the value as it stands, which a server writes too. */
|
|
13
|
+
export default function DataGridDateValue(props: Props): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -2,6 +2,8 @@ import { BoxProps } from '../../../box';
|
|
|
2
2
|
import { ChangeHandler } from '../../../react/a11y/useControllableState';
|
|
3
3
|
import { ComponentsAndVariants } from '../../../types';
|
|
4
4
|
import { SortDirection } from '../../../utils/array/arrayUtils';
|
|
5
|
+
import { FormatOptions } from '../../../utils/date/format';
|
|
6
|
+
import { ZoneInput } from '../../../utils/date/zones';
|
|
5
7
|
import { default as AggregateCellModel } from '../models/aggregateCellModel';
|
|
6
8
|
import { default as CellModel } from '../models/cellModel';
|
|
7
9
|
import { DataGridLocaleText } from '../models/localeText';
|
|
@@ -163,7 +165,7 @@ export interface DataGridPagination {
|
|
|
163
165
|
pageSize: number;
|
|
164
166
|
}
|
|
165
167
|
/** Filter type for column-level filtering */
|
|
166
|
-
export type ColumnFilterType = 'text' | 'number' | 'multiselect';
|
|
168
|
+
export type ColumnFilterType = 'text' | 'number' | 'multiselect' | 'date';
|
|
167
169
|
/** Text filter configuration (fuzzy search) */
|
|
168
170
|
export interface TextFilterValue {
|
|
169
171
|
type: 'text';
|
|
@@ -181,8 +183,19 @@ export interface MultiselectFilterValue {
|
|
|
181
183
|
type: 'multiselect';
|
|
182
184
|
values: (string | number | boolean | null)[];
|
|
183
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Date filter: one day, before or after one, or a span of days, each `YYYY-MM-DD` — compared on the reader's
|
|
188
|
+
* calendar, so an instant late on the 19th in their zone is on the 19th whatever UTC says.
|
|
189
|
+
*/
|
|
190
|
+
export interface DateFilterValue {
|
|
191
|
+
type: 'date';
|
|
192
|
+
operator: 'on' | 'before' | 'after' | 'between';
|
|
193
|
+
value: string;
|
|
194
|
+
/** For 'between': the last day, included. */
|
|
195
|
+
valueTo?: string;
|
|
196
|
+
}
|
|
184
197
|
/** Union type for all filter values */
|
|
185
|
-
export type FilterValue = TextFilterValue | NumberFilterValue | MultiselectFilterValue;
|
|
198
|
+
export type FilterValue = TextFilterValue | NumberFilterValue | MultiselectFilterValue | DateFilterValue;
|
|
186
199
|
/** Column filters record - maps column key to filter value */
|
|
187
200
|
export type ColumnFilters<TRow> = Partial<Record<keyof TRow | Key, FilterValue>>;
|
|
188
201
|
/** Filter configuration for a column */
|
|
@@ -197,10 +210,10 @@ export interface ColumnFilterConfig {
|
|
|
197
210
|
}[];
|
|
198
211
|
/** For number: step value for input */
|
|
199
212
|
step?: number;
|
|
200
|
-
/** For number: min value */
|
|
201
|
-
min?: number;
|
|
202
|
-
/** For number: max value */
|
|
203
|
-
max?: number;
|
|
213
|
+
/** For number: min value. For date: the earliest day, `YYYY-MM-DD`. */
|
|
214
|
+
min?: number | string;
|
|
215
|
+
/** For number: max value. For date: the latest day. */
|
|
216
|
+
max?: number | string;
|
|
204
217
|
}
|
|
205
218
|
/** Configuration for expandable row detail panel */
|
|
206
219
|
export interface RowDetailConfig<TRow> {
|
|
@@ -270,10 +283,11 @@ export interface TreeDataConfig<TRow> {
|
|
|
270
283
|
selection?: 'self' | 'cascade';
|
|
271
284
|
}
|
|
272
285
|
/**
|
|
273
|
-
* The
|
|
274
|
-
* a lookup against a table — declares `EditCell` instead and renders it,
|
|
286
|
+
* The editors the grid draws for itself — `date`, `time` and `datetime` are a `DateField` in the cell. A column
|
|
287
|
+
* wanting anything else — a colour, a lookup against a table — declares `EditCell` instead and renders it,
|
|
288
|
+
* driven by the same model.
|
|
275
289
|
*/
|
|
276
|
-
export type CellEditorType = 'text' | 'number' | 'checkbox' | 'select';
|
|
290
|
+
export type CellEditorType = 'text' | 'number' | 'checkbox' | 'select' | 'date' | 'time' | 'datetime';
|
|
277
291
|
/** One option of a `select` editor. `value` is what the cell holds; `label` is what the list shows. */
|
|
278
292
|
export interface CellEditorOption {
|
|
279
293
|
value: string | number | boolean | null;
|
|
@@ -288,9 +302,17 @@ export interface CellEditorConfig<TRow> {
|
|
|
288
302
|
placeholder?: string;
|
|
289
303
|
/** `number` only, handed to the input as it stands. */
|
|
290
304
|
step?: number;
|
|
291
|
-
|
|
292
|
-
|
|
305
|
+
/** A number for `number`; an ISO string for the date editors, whose value outside it is marked invalid. */
|
|
306
|
+
min?: number | string;
|
|
307
|
+
max?: number | string;
|
|
308
|
+
/** `datetime` only: whose wall clock it is typed on. Default the reader's; `'none'` for no zone. */
|
|
309
|
+
zone?: ZoneInput | 'none';
|
|
293
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* How a column writes a date: `'date'`, `'time'`, `'datetime'`, `'relative'` (`3 days ago`), or `Intl` options
|
|
313
|
+
* with a `zone`. In the reader's language and on their wall clock, like `<DateTime>`.
|
|
314
|
+
*/
|
|
315
|
+
export type ColumnDateFormat = 'date' | 'time' | 'datetime' | 'relative' | Omit<FormatOptions, 'locale'>;
|
|
294
316
|
/** Whether a column can be edited: every row of it, or the rows a predicate says. */
|
|
295
317
|
export type ColumnEditable<TRow> = boolean | ((row: TRow) => boolean);
|
|
296
318
|
/**
|
|
@@ -523,6 +545,11 @@ export interface ColumnType<TRow> {
|
|
|
523
545
|
* numbers gets a numeric keypad without being told.
|
|
524
546
|
*/
|
|
525
547
|
editor?: CellEditorType | CellEditorConfig<TRow>;
|
|
548
|
+
/**
|
|
549
|
+
* Writes the column's values as dates, in the reader's language and zone — an ISO string or a `Date`. A `Date`
|
|
550
|
+
* is written as a date-time without being told, since it cannot be rendered as it stands.
|
|
551
|
+
*/
|
|
552
|
+
dateFormat?: ColumnDateFormat;
|
|
526
553
|
/**
|
|
527
554
|
* An editor of your own, for what the four built-in ones do not cover. It is handed the cell, and the
|
|
528
555
|
* cell carries the draft value and the two ways out (`commitEdit`, `cancelEdit`) — so a custom editor
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnAggregate, ColumnEditable, ColumnFilterConfig, ColumnType, ContextMenuConfig, FilterValue, Key, NumberFilterValue, PinPosition, PinPositionInput, SortDirection } from '../contracts/dataGridContract';
|
|
1
|
+
import { ColumnAggregate, ColumnEditable, ColumnFilterConfig, ColumnType, ContextMenuConfig, DateFilterValue, FilterValue, Key, NumberFilterValue, PinPosition, PinPositionInput, SortDirection } from '../contracts/dataGridContract';
|
|
2
2
|
import { default as GridModel } from './gridModel';
|
|
3
3
|
import { default as HeaderCellModel } from './headerCellModel';
|
|
4
4
|
/** Discriminates the structural role of a column — replaces scattered `key === *_CELL_KEY` checks. */
|
|
@@ -80,6 +80,8 @@ export default class ColumnModel<TRow> {
|
|
|
80
80
|
}[];
|
|
81
81
|
setTextFilter(value: string): void;
|
|
82
82
|
setNumberFilter(operator: NumberFilterValue['operator'], value: string | number, valueTo?: string | number): void;
|
|
83
|
+
/** A day, before or after one, or a span — `null` for a value still being typed, which is no filter yet. */
|
|
84
|
+
setDateFilter(operator: DateFilterValue['operator'], value: string | null, valueTo?: string | null): void;
|
|
83
85
|
setMultiselectFilter(values: (string | number | boolean | null)[]): void;
|
|
84
86
|
clearFilter(): void;
|
|
85
87
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CellEdit, CellEditorConfig, Key } from '../contracts/dataGridContract';
|
|
1
|
+
import { CellEdit, CellEditorConfig, CellEditorType, Key } from '../contracts/dataGridContract';
|
|
2
2
|
import { default as ColumnModel } from './columnModel';
|
|
3
3
|
import { default as GridModel } from './gridModel';
|
|
4
4
|
import { RangeBounds } from './rangeModel';
|
|
5
5
|
import { default as RowModel } from './rowModel';
|
|
6
|
+
/** Whether an editor is a `DateField`. */
|
|
7
|
+
export declare function isDateEditor(type: CellEditorType): boolean;
|
|
6
8
|
/** A key that starts an edit by replacing the value: one printable character, unmodified. */
|
|
7
9
|
export declare function isTypingKey(event: React.KeyboardEvent): boolean;
|
|
8
10
|
/**
|
|
@@ -60,6 +60,10 @@ export interface DataGridLocaleText {
|
|
|
60
60
|
filterSelectAll: string;
|
|
61
61
|
/** How a multiselect filter lists a `null` value. */
|
|
62
62
|
filterEmptyValue: string;
|
|
63
|
+
/** What a `true` cell is read out and listed as; it is drawn as a check. */
|
|
64
|
+
booleanTrue: string;
|
|
65
|
+
/** What a `false` cell is read out and listed as; it is drawn as a cross. */
|
|
66
|
+
booleanFalse: string;
|
|
63
67
|
/** What an empty grid shows when there is no `noDataComponent`. */
|
|
64
68
|
noRows: string;
|
|
65
69
|
loadingRows: string;
|