@box-kite/react 2.2.4 → 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 +11 -1
- package/.claude/skills/box-kite/SKILL.md +11 -1
- package/.claude/skills/box-kite/references/components.md +83 -3
- package/.cursor/rules/box-kite.mdc +11 -1
- package/AGENTS.md +11 -1
- package/BOX_AI_CONTEXT.md +371 -25
- package/BOX_KITE_AI_CONTEXT.md +371 -25
- package/behavior.cjs +1 -1
- package/behavior.mjs +57 -57
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +15 -15
- package/catalog.cjs +1 -1
- package/catalog.mjs +906 -0
- package/client.cjs +1 -1
- package/client.mjs +94 -80
- package/components/calendar.cjs +1 -0
- package/components/calendar.d.ts +77 -0
- package/components/calendar.mjs +483 -0
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- 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/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 +70 -11
- package/components/dataGrid/models/columnModel.d.ts +3 -1
- package/components/dataGrid/models/editModel.d.ts +3 -1
- 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 +36 -0
- package/components/dataGrid/models/viewportModel.d.ts +0 -2
- package/components/dataGrid/useDateParts.d.ts +17 -0
- package/components/dataGrid/useListLayout.d.ts +13 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +1251 -854
- 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 +29 -29
- 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/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 +24 -24
- package/components/virtualList.cjs +1 -0
- package/components/virtualList.d.ts +32 -0
- package/components/virtualList.mjs +188 -0
- package/dataGridDateParts.cjs +1 -0
- package/dataGridDateParts.mjs +223 -0
- package/dataGridList.cjs +1 -0
- package/dataGridList.mjs +1314 -0
- 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 +10 -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 +178 -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/boxComponent.d.ts +1 -1
- package/react/componentsContext.d.ts +4 -0
- package/react/componentsProvider.d.ts +10 -0
- package/react/date/dateChange.d.ts +18 -0
- package/react/date/dateEnvironment.d.ts +34 -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 +6 -6
- 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/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
- 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,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 };
|
package/components/dashboard.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../dashboardSchema.cjs"),i=require("./svg.cjs"),a=require("./visuallyHidden.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.VERSION=1,n=e.MIN_COLUMNS=1,i=e.MAX_COLUMNS=24;function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e,t){return typeof e==`number`&&Number.isFinite(e)?Math.round(e):t}function s(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}e.overlaps=s;function c(e,t){return e.find(e=>e.id!==t.id&&s(e,t))}function l(e,t){let n=Math.min(e.maxW??t,t),r=a(o(e.w,1),Math.max(1,Math.min(e.minW??1,n)),Math.max(1,n)),i=a(o(e.h,1),Math.max(1,e.minH??1),Math.max(1,e.maxH??2**53-1));return{...e,w:r,h:i,x:a(o(e.x,0),0,t-r),y:Math.max(o(e.y,0),0)}}function u(e,t){return e.y-t.y||e.x-t.x}function d(e,t){let r=a(o(t,12),n,i),s=e.map(e=>l(e,r)),d=e=>+!e.fixed,f=[...s].sort((e,t)=>d(e)-d(t)||u(e,t)),p=[];for(let e of f){if(e.fixed){p.push(e);continue}let t={...e};for(;t.y>0&&!c(p,{...t,y:t.y-1});)t.y--;let n=c(p,t);for(;n;)t.y=n.y+n.h,n=c(p,t);p.push(t)}return p.sort(u)}e.resolve=d;function f(e){let r=a(o(e.columns,12),n,i);return{version:t,columns:r,items:d(e.items,r)}}e.normalize=f;function p(e,t){return e.items.find(e=>e.id===t)}e.itemOf=p;function m(e){return new Map(e.items.map((e,t)=>[e.id,t]))}e.ranks=m;function h(e,t){let n=n=>!s(t,n)&&!e.some(e=>e.id!==n.id&&e.id!==t.id&&s(e,n));return e.map(e=>{if(e.id===t.id)return t;if(e.fixed===!0||!s(e,t))return e;let r={...e,y:Math.max(t.y-e.h,0)};return n(r)?r:{...e,y:t.y+t.h}})}function g(e,t,r,s){let c=p(e,t);if(!c||c.fixed)return e;let u=l({...c,x:r,y:s},a(o(e.columns,12),n,i));return f({...e,items:h(e.items,u)})}e.moveTo=g;function _(e,t,n,r){let i=p(e,t);if(!i||i.fixed)return e;let a=e.items.map(e=>e.id===t?{...e,w:n,h:r}:e);return f({...e,items:a})}e.resizeTo=_;function v(e,t){let n=e.items.reduce((e,t)=>Math.max(e,t.y+t.h),0);return f({...e,items:[...e.items,{x:0,y:n,...t}]})}e.add=v;function y(e,t){return f({...e,items:e.items.filter(e=>e.id!==t)})}e.remove=y;function b(e,r){let s=a(o(r,12),n,i);if(s===e.columns)return f(e);let c=s/e.columns,l=e=>e===void 0?void 0:a(Math.max(1,Math.round(e*c)),1,s),u=e.items.map(e=>{let t=a(Math.max(1,Math.round(e.w*c)),1,s);return{...e,w:t,x:a(Math.floor(e.x*c),0,s-t),minW:l(e.minW),maxW:l(e.maxW)}});return f({version:t,columns:s,items:u})}e.project=b;function x(e,t){return e===t?!0:e.columns!==t.columns||e.items.length!==t.items.length?!1:e.items.every((e,n)=>{let r=t.items[n];return e.id===r.id&&e.x===r.x&&e.y===r.y&&e.w===r.w&&e.h===r.h})}e.same=x;function S(e,t,n){return{columns:n.x>0?Math.round(e/n.x):0,rows:n.y>0?Math.round(t/n.y):0}}e.cellsMoved=S;function C(e){return typeof e==`string`&&e.length>0}function w(e){return typeof e==`number`&&Number.isFinite(e)}function T(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e)){n.push({code:`invalid-item`,path:t,message:`A layout item has to be an object.`});return}let r=e;if(!C(r.id)){n.push({code:`invalid-item`,path:`${t}.id`,message:`A layout item needs an id naming the widget it places.`});return}if(!w(r.x)||!w(r.y)||!w(r.w)||!w(r.h)){n.push({code:`invalid-item`,path:t,message:`Item "${r.id}" needs numeric x, y, w and h.`});return}let i=[`minW`,`minH`,`maxW`,`maxH`].reduce((e,t)=>(w(r[t])&&(e[t]=Math.round(r[t])),e),{});return{id:r.id,x:Math.round(r.x),y:Math.round(r.y),w:Math.round(r.w),h:Math.round(r.h),...i,...r.fixed===!0?{fixed:!0}:{}}}function E(e,r=12){let o=[],s={version:t,columns:r,items:[]};if(typeof e!=`object`||!e||Array.isArray(e))return o.push({code:`not-an-object`,path:``,message:`A layout has to be an object.`}),{layout:f(s),issues:o};let c=e;c.version!==t&&o.push({code:`version`,path:`version`,message:`Layout version ${String(c.version)} was read as version ${t}.`});let l=w(c.columns)?a(Math.round(c.columns),n,i):r;if(w(c.columns)||o.push({code:`columns`,path:`columns`,message:`No column count, so the layout was read in ${r}.`}),!Array.isArray(c.items))return o.push({code:`items`,path:`items`,message:`A layout needs an items array.`}),{layout:f({...s,columns:l}),issues:o};let u=new Set,d=c.items.reduce((e,t,n)=>{let r=T(t,`items.${n}`,o);return r?u.has(r.id)?(o.push({code:`duplicate-id`,path:`items.${n}.id`,message:`Two items are called "${r.id}"; the second was dropped.`}),e):(u.add(r.id),e.push(r),e):e},[]);return{layout:f({version:t,columns:l,items:d}),issues:o}}e.parse=E,e.SCHEMA=r.t})(c||={});var l=c,u=[`xs`,`sm`,`md`,`lg`,`xl`,`xxl`],d=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],f=(0,o.createContext)(null);function p(e,t,n){return Math.min(Math.max(e,t),n)}function m(e){if(typeof e==`number`)return[{count:p(Math.round(e),l.MIN_COLUMNS,l.MAX_COLUMNS)}];let t=u.filter(t=>typeof e[t]==`number`).map(t=>({size:t,count:p(Math.round(e[t]),l.MIN_COLUMNS,l.MAX_COLUMNS)}));return t.length>0?t:[{count:12}]}function h(e){return{gridColumnStart:e.x+1,gridColumnEnd:e.x+1+e.w,gridRowStart:e.y+1,gridRowEnd:e.y+1+e.h}}function g(e){return`max${e[0].toUpperCase()}${e.slice(1)}`}function _(e,t){let n=t?-1:1;if(e===`ArrowLeft`)return{x:-n,y:0};if(e===`ArrowRight`)return{x:n,y:0};if(e===`ArrowUp`)return{x:0,y:-1};if(e===`ArrowDown`)return{x:0,y:1}}function v(e){return`column ${e.x+1}, row ${e.y+1}`}function y(e){return`${e.w} ${e.w===1?`column`:`columns`} by ${e.h} ${e.h===1?`row`:`rows`}`}function b(r){let{children:i,layout:c,defaultLayout:d,onLayoutChange:p,onLayoutCommit:b,columns:x={xs:1,md:6,xxl:12},rowHeight:S=24,editable:C=!1,label:w,labelledBy:T,props:E,...D}=r,O=(0,o.useRef)(null),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(``),F=`${(0,o.useId)()}-dashboard`,[I,L]=n.i({value:c,defaultValue:d??{version:l.VERSION,columns:12,items:[]},onChange:p}),R=(0,o.useMemo)(()=>l.normalize(I),[I]),z=n.o(R),B=n.a(b),V=typeof x==`number`?String(x):u.map(e=>x[e]??``).join(),H=(0,o.useMemo)(()=>m(x),[V]),U=H[H.length-1],W=(0,o.useMemo)(()=>{let e=l.ranks(R),t=new Map;for(let n of H){let r=n.count===U.count?R:l.project(R,n.count),i=U.count/n.count;for(let a of r.items){let r=t.get(a.id)??{order:e.get(a.id)??0,fixed:a.fixed===!0},o=h({...a,x:Math.round(a.x*i),w:Math.round((a.x+a.w)*i)-Math.round(a.x*i)});n===H[0]?r.placement=o:r.query={...r.query,[n.size]:o},t.set(a.id,r)}}return t},[R,H,U.count]),G=n.a((e,t)=>{l.same(e,z.current)||L(e,t)}),ee=(e,t)=>{let n=e.getBoundingClientRect(),r=O.current,i=r&&typeof getComputedStyle==`function`?getComputedStyle(r):void 0,a=Number.parseFloat(i?.columnGap??``)||0,o=Number.parseFloat(i?.rowGap??``)||0;return{x:(n.width+a)/t.w,y:(n.height+o)/t.h}},te=e=>e instanceof Element?e.closest(`[data-widget-id]`):null,K=(e,t,n,r)=>{let i=e.kind===`move`?l.moveTo(z.current,e.id,t,n):l.resizeTo(z.current,e.id,t,n);return G(i,{reason:e.kind,event:r}),i},q=n.a((t,n,r,i)=>{let a=l.itemOf(z.current,n),o=te(t.currentTarget);!C||t.button!==0||t.defaultPrevented||!a||a.fixed||!o||(t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId),t.currentTarget.focus(),A({id:n,kind:i,name:r,origin:a,before:z.current,pointer:{id:t.pointerId,x:t.clientX,y:t.clientY,step:ee(o,a),rtl:e.u(o)}}))}),J=n.a((e,t)=>{if(!k?.pointer||k.id!==t)return;let{x:n,y:r,step:i,rtl:a}=k.pointer,o={x:e.clientX-n,y:e.clientY-r},s=l.cellsMoved(a?-o.x:o.x,o.y,i),c=k.origin,u=k.kind===`move`?K(k,c.x+s.columns,c.y+s.rows,e):K(k,c.w+s.columns,c.h+s.rows,e),d=l.itemOf(u,t);if(k.kind!==`move`||!d)return;let f={x:(d.x-c.x)*i.x*(a?-1:1),y:(d.y-c.y)*i.y};M({translate:`${Math.round(o.x-f.x)}px ${Math.round(o.y-f.y)}px`})}),Y=n.a((e,t)=>{if(!k?.pointer||k.id!==t)return;let n=l.itemOf(z.current,t);e.currentTarget.releasePointerCapture?.(k.pointer.id),A(null),M(null),B(z.current,{reason:k.kind,event:e}),n&&P(k.kind===`move`?`${k.name} moved to ${v(n)}.`:`${k.name} resized to ${y(n)}.`)}),X=n.a((e,t)=>{G(e.before,{reason:e.kind,event:t}),A(null),P(`${e.name} put back at ${v(e.origin)}.`)}),Z=n.a((t,n,r,i)=>{if(!C||t.defaultPrevented)return;let a=k&&k.id===n&&k.kind===i&&!k.pointer?k:void 0,o=l.itemOf(z.current,n);if(!o)return;if(!a){if(t.key!==`Enter`&&t.key!==` `||o.fixed)return;t.preventDefault(),A({id:n,kind:i,name:r,origin:o,before:z.current}),P(i===`move`?`${r} picked up at ${v(o)}. Use the arrow keys to move it.`:`${r} held for resizing at ${y(o)}. Use the arrow keys to resize it.`);return}if(t.key===`Escape`){t.preventDefault(),X(a,t);return}if(t.key===`Enter`||t.key===` `){t.preventDefault(),A(null),B(z.current,{reason:i,event:t}),P(i===`move`?`${r} dropped at ${v(o)}.`:`${r} resized to ${y(o)}.`);return}let s=_(t.key,e.u(t.currentTarget));if(!s)return;t.preventDefault();let c=i===`move`?K(a,o.x+s.x,o.y+s.y,t):K(a,o.w+s.x,o.h+s.y,t),u=l.itemOf(c,n);u&&P(i===`move`?`${r}, ${v(u)}.`:`${r}, ${y(u)}.`)}),Q=n.a((e,t,n)=>{k&&k.id===t&&k.kind===n&&!k.pointer&&X(k,e)}),ne=(0,o.useMemo)(()=>({editable:C,placementOf:e=>W.get(e),heldOf:e=>k&&k.id===e?k:void 0,offsetOf:e=>k&&k.id===e&&j?j:void 0,outsideAuthoring:U.size?{[g(U.size)]:{display:`none`}}:void 0,instructionsId:F,handleProps:(e,t,n)=>({type:`button`,"aria-label":n===`move`?`Move ${t}`:`Resize ${t}`,"aria-pressed":!!(k&&k.id===e&&k.kind===n),"aria-describedby":F,onPointerDown:r=>q(r,e,t,n),onPointerMove:t=>J(t,e),onPointerUp:t=>Y(t,e),onPointerCancel:t=>Y(t,e),onKeyDown:r=>Z(r,e,t,n),onBlur:t=>Q(t,e,n)})}),[C,W,k,j,U.size,F,q,J,Y,Z,Q]),$=k?W.get(k.id):void 0;return(0,s.jsxs)(f.Provider,{value:ne,children:[(0,s.jsxs)(t.default,{ref:O,component:`dashboard`,...D,variant:[D.variant,{dragging:k!==null}],vars:{"dashboard-row":`${S/4}rem`},gridTemplateColumns:U.count,props:{role:`list`,"aria-label":w,"aria-labelledby":T,...E},children:[i,$&&(0,s.jsx)(t.default,{component:`dashboard.placeholder`,order:$.order,cq:$.query,...$.placement,props:{role:`presentation`,"aria-hidden":!0}})]}),(0,s.jsx)(a.default,{props:{role:`status`},children:N}),(0,s.jsx)(a.default,{id:F,children:`Press Enter or Space to pick the widget up, the arrow keys to move or resize it, Enter to drop it and Escape to put it back.`})]})}function x({kind:e}){return e===`resize`?(0,s.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,rtl:{flip:`xAxis`},props:{fill:`none`},children:(0,s.jsx)(i.Path,{d:`M20 10 10 20M20 16l-4 4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})}):(0,s.jsxs)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,children:[[8,12,16].map(e=>(0,s.jsx)(i.Circle,{cx:9,cy:e,r:1.4,fill:`currentColor`},e)),[8,12,16].map(e=>(0,s.jsx)(i.Circle,{cx:15,cy:e,r:1.4,fill:`currentColor`},e))]})}function S(){return(0,s.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,props:{fill:`none`},children:(0,s.jsx)(i.Path,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})})}function C(e){let{id:n,children:r,title:i,name:a,description:c,actions:l,level:u=3,loading:p=!1,error:m,empty:h,onRefresh:g,refreshLabel:_,props:v,...y}=e,b=(0,o.useContext)(f),C=n===void 0?void 0:b?.placementOf(n),w=n===void 0?void 0:b?.heldOf(n),T=a??(typeof i==`string`?i:void 0)??n??`Widget`,E=b?.editable===!0&&C!==void 0&&!C.fixed,D=e=>E&&n!==void 0?(0,s.jsx)(t.default,{component:`widget.handle`,tag:`button`,variant:{editable:!0,grabbed:w?.kind===e,corner:e===`resize`},cq:b?.outsideAuthoring,props:b?.handleProps(n,T,e),children:(0,s.jsx)(x,{kind:e})}):null,O=()=>p?(0,s.jsx)(t.default,{component:`widget.skeleton`,props:{"aria-hidden":!0},children:[80,100,60].map(e=>(0,s.jsx)(t.default,{component:`widget.skeleton.bar`,width:`${e}%`},e))}):m?(0,s.jsxs)(t.default,{component:`widget.message`,variant:{error:!0},props:{role:`status`},children:[m,g&&(0,s.jsx)(t.default,{tag:`button`,component:`widget.retry`,props:{type:`button`,onClick:g},children:`Try again`})]}):h?(0,s.jsx)(t.default,{component:`widget.message`,children:h===!0?`Nothing to show yet.`:h}):r,k=i!==void 0||c!==void 0||l!==void 0||g!==void 0||E;return(0,s.jsxs)(t.default,{component:`widget`,...y,variant:[y.variant,{dragging:w?.pointer!==void 0,grabbed:w!==void 0&&w.pointer===void 0}],order:C?.order,cq:C?.query,...C?.placement,style:{...n===void 0?void 0:b?.offsetOf(n),...y.style},props:{role:C?`listitem`:void 0,"aria-busy":p||void 0,"data-widget-id":n,...v},children:[k&&(0,s.jsxs)(t.default,{component:`widget.header`,children:[D(`move`),(0,s.jsxs)(t.default,{component:`widget.label`,children:[i!==void 0&&(0,s.jsx)(t.default,{component:`widget.title`,tag:d[u-1],children:i}),c!==void 0&&(0,s.jsx)(t.default,{component:`widget.description`,children:c})]}),g&&(0,s.jsx)(t.default,{component:`widget.handle`,tag:`button`,variant:{editable:!0},props:{type:`button`,"aria-label":_??`Refresh ${T}`,onClick:g},children:(0,s.jsx)(S,{})}),l!==void 0&&(0,s.jsx)(t.default,{component:`widget.actions`,children:l})]}),(0,s.jsx)(t.default,{component:`widget.body`,children:O()}),D(`resize`)]})}var w=b;w.displayName=`DashboardGrid`;var T=C;T.displayName=`Widget`,exports.DashboardUtils=l,exports.Widget=T,exports.default=w;
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../box.cjs"),n=require("../behavior.cjs"),r=require("../dashboardSchema.cjs"),i=require("./svg.cjs"),a=require("./visuallyHidden.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.VERSION=1,n=e.MIN_COLUMNS=1,i=e.MAX_COLUMNS=24;function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e,t){return typeof e==`number`&&Number.isFinite(e)?Math.round(e):t}function s(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}e.overlaps=s;function c(e,t){return e.find(e=>e.id!==t.id&&s(e,t))}function l(e,t){let n=Math.min(e.maxW??t,t),r=a(o(e.w,1),Math.max(1,Math.min(e.minW??1,n)),Math.max(1,n)),i=a(o(e.h,1),Math.max(1,e.minH??1),Math.max(1,e.maxH??2**53-1));return{...e,w:r,h:i,x:a(o(e.x,0),0,t-r),y:Math.max(o(e.y,0),0)}}function u(e,t){return e.y-t.y||e.x-t.x}function d(e,t){let r=a(o(t,12),n,i),s=e.map(e=>l(e,r)),d=e=>+!e.fixed,f=[...s].sort((e,t)=>d(e)-d(t)||u(e,t)),p=[];for(let e of f){if(e.fixed){p.push(e);continue}let t={...e};for(;t.y>0&&!c(p,{...t,y:t.y-1});)t.y--;let n=c(p,t);for(;n;)t.y=n.y+n.h,n=c(p,t);p.push(t)}return p.sort(u)}e.resolve=d;function f(e){let r=a(o(e.columns,12),n,i);return{version:t,columns:r,items:d(e.items,r)}}e.normalize=f;function p(e,t){return e.items.find(e=>e.id===t)}e.itemOf=p;function m(e){return new Map(e.items.map((e,t)=>[e.id,t]))}e.ranks=m;function h(e,t){let n=n=>!s(t,n)&&!e.some(e=>e.id!==n.id&&e.id!==t.id&&s(e,n));return e.map(e=>{if(e.id===t.id)return t;if(e.fixed===!0||!s(e,t))return e;let r={...e,y:Math.max(t.y-e.h,0)};return n(r)?r:{...e,y:t.y+t.h}})}function g(e,t,r,s){let c=p(e,t);if(!c||c.fixed)return e;let u=l({...c,x:r,y:s},a(o(e.columns,12),n,i));return f({...e,items:h(e.items,u)})}e.moveTo=g;function _(e,t,n,r){let i=p(e,t);if(!i||i.fixed)return e;let a=e.items.map(e=>e.id===t?{...e,w:n,h:r}:e);return f({...e,items:a})}e.resizeTo=_;function v(e,t){let n=e.items.reduce((e,t)=>Math.max(e,t.y+t.h),0);return f({...e,items:[...e.items,{x:0,y:n,...t}]})}e.add=v;function y(e,t){return f({...e,items:e.items.filter(e=>e.id!==t)})}e.remove=y;function b(e,r){let s=a(o(r,12),n,i);if(s===e.columns)return f(e);let c=s/e.columns,l=e=>e===void 0?void 0:a(Math.max(1,Math.round(e*c)),1,s),u=e.items.map(e=>{let t=a(Math.max(1,Math.round(e.w*c)),1,s);return{...e,w:t,x:a(Math.floor(e.x*c),0,s-t),minW:l(e.minW),maxW:l(e.maxW)}});return f({version:t,columns:s,items:u})}e.project=b;function x(e,t){return e===t?!0:e.columns!==t.columns||e.items.length!==t.items.length?!1:e.items.every((e,n)=>{let r=t.items[n];return e.id===r.id&&e.x===r.x&&e.y===r.y&&e.w===r.w&&e.h===r.h})}e.same=x;function S(e,t,n){return{columns:n.x>0?Math.round(e/n.x):0,rows:n.y>0?Math.round(t/n.y):0}}e.cellsMoved=S;function C(e){return typeof e==`string`&&e.length>0}function w(e){return typeof e==`number`&&Number.isFinite(e)}function T(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e)){n.push({code:`invalid-item`,path:t,message:`A layout item has to be an object.`});return}let r=e;if(!C(r.id)){n.push({code:`invalid-item`,path:`${t}.id`,message:`A layout item needs an id naming the widget it places.`});return}if(!w(r.x)||!w(r.y)||!w(r.w)||!w(r.h)){n.push({code:`invalid-item`,path:t,message:`Item "${r.id}" needs numeric x, y, w and h.`});return}let i=[`minW`,`minH`,`maxW`,`maxH`].reduce((e,t)=>(w(r[t])&&(e[t]=Math.round(r[t])),e),{});return{id:r.id,x:Math.round(r.x),y:Math.round(r.y),w:Math.round(r.w),h:Math.round(r.h),...i,...r.fixed===!0?{fixed:!0}:{}}}function E(e,r=12){let o=[],s={version:t,columns:r,items:[]};if(typeof e!=`object`||!e||Array.isArray(e))return o.push({code:`not-an-object`,path:``,message:`A layout has to be an object.`}),{layout:f(s),issues:o};let c=e;c.version!==t&&o.push({code:`version`,path:`version`,message:`Layout version ${String(c.version)} was read as version ${t}.`});let l=w(c.columns)?a(Math.round(c.columns),n,i):r;if(w(c.columns)||o.push({code:`columns`,path:`columns`,message:`No column count, so the layout was read in ${r}.`}),!Array.isArray(c.items))return o.push({code:`items`,path:`items`,message:`A layout needs an items array.`}),{layout:f({...s,columns:l}),issues:o};let u=new Set,d=c.items.reduce((e,t,n)=>{let r=T(t,`items.${n}`,o);return r?u.has(r.id)?(o.push({code:`duplicate-id`,path:`items.${n}.id`,message:`Two items are called "${r.id}"; the second was dropped.`}),e):(u.add(r.id),e.push(r),e):e},[]);return{layout:f({version:t,columns:l,items:d}),issues:o}}e.parse=E,e.SCHEMA=r.t})(c||={});var l=c,u=[`xs`,`sm`,`md`,`lg`,`xl`,`xxl`],d=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],f=(0,o.createContext)(null);function p(e,t,n){return Math.min(Math.max(e,t),n)}function m(e){if(typeof e==`number`)return[{count:p(Math.round(e),l.MIN_COLUMNS,l.MAX_COLUMNS)}];let t=u.filter(t=>typeof e[t]==`number`).map(t=>({size:t,count:p(Math.round(e[t]),l.MIN_COLUMNS,l.MAX_COLUMNS)}));return t.length>0?t:[{count:12}]}function h(e){return{gridColumnStart:e.x+1,gridColumnEnd:e.x+1+e.w,gridRowStart:e.y+1,gridRowEnd:e.y+1+e.h}}function g(e){return`max${e[0].toUpperCase()}${e.slice(1)}`}function _(e,t){let n=t?-1:1;if(e===`ArrowLeft`)return{x:-n,y:0};if(e===`ArrowRight`)return{x:n,y:0};if(e===`ArrowUp`)return{x:0,y:-1};if(e===`ArrowDown`)return{x:0,y:1}}function v(e){return`column ${e.x+1}, row ${e.y+1}`}function y(e){return`${e.w} ${e.w===1?`column`:`columns`} by ${e.h} ${e.h===1?`row`:`rows`}`}function b(r){let{children:i,layout:c,defaultLayout:d,onLayoutChange:p,onLayoutCommit:b,columns:x={xs:1,md:6,xxl:12},rowHeight:S=24,editable:C=!1,label:w,labelledBy:T,props:E,...D}=r,O=(0,o.useRef)(null),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(``),F=`${(0,o.useId)()}-dashboard`,[I,L]=n.i({value:c,defaultValue:d??{version:l.VERSION,columns:12,items:[]},onChange:p}),R=(0,o.useMemo)(()=>l.normalize(I),[I]),z=n.o(R),B=n.a(b),V=typeof x==`number`?String(x):u.map(e=>x[e]??``).join(),H=(0,o.useMemo)(()=>m(x),[V]),U=H[H.length-1],W=(0,o.useMemo)(()=>{let e=l.ranks(R),t=new Map;for(let n of H){let r=n.count===U.count?R:l.project(R,n.count),i=U.count/n.count;for(let a of r.items){let r=t.get(a.id)??{order:e.get(a.id)??0,fixed:a.fixed===!0},o=h({...a,x:Math.round(a.x*i),w:Math.round((a.x+a.w)*i)-Math.round(a.x*i)});n===H[0]?r.placement=o:r.query={...r.query,[n.size]:o},t.set(a.id,r)}}return t},[R,H,U.count]),G=n.a((e,t)=>{l.same(e,z.current)||L(e,t)}),ee=(e,t)=>{let n=e.getBoundingClientRect(),r=O.current,i=r&&typeof getComputedStyle==`function`?getComputedStyle(r):void 0,a=Number.parseFloat(i?.columnGap??``)||0,o=Number.parseFloat(i?.rowGap??``)||0;return{x:(n.width+a)/t.w,y:(n.height+o)/t.h}},te=e=>e instanceof Element?e.closest(`[data-widget-id]`):null,K=(e,t,n,r)=>{let i=e.kind===`move`?l.moveTo(z.current,e.id,t,n):l.resizeTo(z.current,e.id,t,n);return G(i,{reason:e.kind,event:r}),i},q=n.a((t,n,r,i)=>{let a=l.itemOf(z.current,n),o=te(t.currentTarget);!C||t.button!==0||t.defaultPrevented||!a||a.fixed||!o||(t.preventDefault(),t.currentTarget.setPointerCapture?.(t.pointerId),t.currentTarget.focus(),A({id:n,kind:i,name:r,origin:a,before:z.current,pointer:{id:t.pointerId,x:t.clientX,y:t.clientY,step:ee(o,a),rtl:e.d(o)}}))}),J=n.a((e,t)=>{if(!k?.pointer||k.id!==t)return;let{x:n,y:r,step:i,rtl:a}=k.pointer,o={x:e.clientX-n,y:e.clientY-r},s=l.cellsMoved(a?-o.x:o.x,o.y,i),c=k.origin,u=k.kind===`move`?K(k,c.x+s.columns,c.y+s.rows,e):K(k,c.w+s.columns,c.h+s.rows,e),d=l.itemOf(u,t);if(k.kind!==`move`||!d)return;let f={x:(d.x-c.x)*i.x*(a?-1:1),y:(d.y-c.y)*i.y};M({translate:`${Math.round(o.x-f.x)}px ${Math.round(o.y-f.y)}px`})}),Y=n.a((e,t)=>{if(!k?.pointer||k.id!==t)return;let n=l.itemOf(z.current,t);e.currentTarget.releasePointerCapture?.(k.pointer.id),A(null),M(null),B(z.current,{reason:k.kind,event:e}),n&&P(k.kind===`move`?`${k.name} moved to ${v(n)}.`:`${k.name} resized to ${y(n)}.`)}),X=n.a((e,t)=>{G(e.before,{reason:e.kind,event:t}),A(null),P(`${e.name} put back at ${v(e.origin)}.`)}),Z=n.a((t,n,r,i)=>{if(!C||t.defaultPrevented)return;let a=k&&k.id===n&&k.kind===i&&!k.pointer?k:void 0,o=l.itemOf(z.current,n);if(!o)return;if(!a){if(t.key!==`Enter`&&t.key!==` `||o.fixed)return;t.preventDefault(),A({id:n,kind:i,name:r,origin:o,before:z.current}),P(i===`move`?`${r} picked up at ${v(o)}. Use the arrow keys to move it.`:`${r} held for resizing at ${y(o)}. Use the arrow keys to resize it.`);return}if(t.key===`Escape`){t.preventDefault(),X(a,t);return}if(t.key===`Enter`||t.key===` `){t.preventDefault(),A(null),B(z.current,{reason:i,event:t}),P(i===`move`?`${r} dropped at ${v(o)}.`:`${r} resized to ${y(o)}.`);return}let s=_(t.key,e.d(t.currentTarget));if(!s)return;t.preventDefault();let c=i===`move`?K(a,o.x+s.x,o.y+s.y,t):K(a,o.w+s.x,o.h+s.y,t),u=l.itemOf(c,n);u&&P(i===`move`?`${r}, ${v(u)}.`:`${r}, ${y(u)}.`)}),Q=n.a((e,t,n)=>{k&&k.id===t&&k.kind===n&&!k.pointer&&X(k,e)}),ne=(0,o.useMemo)(()=>({editable:C,placementOf:e=>W.get(e),heldOf:e=>k&&k.id===e?k:void 0,offsetOf:e=>k&&k.id===e&&j?j:void 0,outsideAuthoring:U.size?{[g(U.size)]:{display:`none`}}:void 0,instructionsId:F,handleProps:(e,t,n)=>({type:`button`,"aria-label":n===`move`?`Move ${t}`:`Resize ${t}`,"aria-pressed":!!(k&&k.id===e&&k.kind===n),"aria-describedby":F,onPointerDown:r=>q(r,e,t,n),onPointerMove:t=>J(t,e),onPointerUp:t=>Y(t,e),onPointerCancel:t=>Y(t,e),onKeyDown:r=>Z(r,e,t,n),onBlur:t=>Q(t,e,n)})}),[C,W,k,j,U.size,F,q,J,Y,Z,Q]),$=k?W.get(k.id):void 0;return(0,s.jsxs)(f.Provider,{value:ne,children:[(0,s.jsxs)(t.default,{ref:O,component:`dashboard`,...D,variant:[D.variant,{dragging:k!==null}],vars:{"dashboard-row":`${S/4}rem`},gridTemplateColumns:U.count,props:{role:`list`,"aria-label":w,"aria-labelledby":T,...E},children:[i,$&&(0,s.jsx)(t.default,{component:`dashboard.placeholder`,order:$.order,cq:$.query,...$.placement,props:{role:`presentation`,"aria-hidden":!0}})]}),(0,s.jsx)(a.default,{props:{role:`status`},children:N}),(0,s.jsx)(a.default,{id:F,children:`Press Enter or Space to pick the widget up, the arrow keys to move or resize it, Enter to drop it and Escape to put it back.`})]})}function x({kind:e}){return e===`resize`?(0,s.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,rtl:{flip:`xAxis`},props:{fill:`none`},children:(0,s.jsx)(i.Path,{d:`M20 10 10 20M20 16l-4 4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})}):(0,s.jsxs)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,children:[[8,12,16].map(e=>(0,s.jsx)(i.Circle,{cx:9,cy:e,r:1.4,fill:`currentColor`},e)),[8,12,16].map(e=>(0,s.jsx)(i.Circle,{cx:15,cy:e,r:1.4,fill:`currentColor`},e))]})}function S(){return(0,s.jsx)(i.Svg,{viewBox:`0 0 24 24`,width:`1rem`,height:`1rem`,props:{fill:`none`},children:(0,s.jsx)(i.Path,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})})}function C(e){let{id:n,children:r,title:i,name:a,description:c,actions:l,level:u=3,loading:p=!1,error:m,empty:h,onRefresh:g,refreshLabel:_,props:v,...y}=e,b=(0,o.useContext)(f),C=n===void 0?void 0:b?.placementOf(n),w=n===void 0?void 0:b?.heldOf(n),T=a??(typeof i==`string`?i:void 0)??n??`Widget`,E=b?.editable===!0&&C!==void 0&&!C.fixed,D=e=>E&&n!==void 0?(0,s.jsx)(t.default,{component:`widget.handle`,tag:`button`,variant:{editable:!0,grabbed:w?.kind===e,corner:e===`resize`},cq:b?.outsideAuthoring,props:b?.handleProps(n,T,e),children:(0,s.jsx)(x,{kind:e})}):null,O=()=>p?(0,s.jsx)(t.default,{component:`widget.skeleton`,props:{"aria-hidden":!0},children:[80,100,60].map(e=>(0,s.jsx)(t.default,{component:`widget.skeleton.bar`,width:`${e}%`},e))}):m?(0,s.jsxs)(t.default,{component:`widget.message`,variant:{error:!0},props:{role:`status`},children:[m,g&&(0,s.jsx)(t.default,{tag:`button`,component:`widget.retry`,props:{type:`button`,onClick:g},children:`Try again`})]}):h?(0,s.jsx)(t.default,{component:`widget.message`,children:h===!0?`Nothing to show yet.`:h}):r,k=i!==void 0||c!==void 0||l!==void 0||g!==void 0||E;return(0,s.jsxs)(t.default,{component:`widget`,...y,variant:[y.variant,{dragging:w?.pointer!==void 0,grabbed:w!==void 0&&w.pointer===void 0}],order:C?.order,cq:C?.query,...C?.placement,style:{...n===void 0?void 0:b?.offsetOf(n),...y.style},props:{role:C?`listitem`:void 0,"aria-busy":p||void 0,"data-widget-id":n,...v},children:[k&&(0,s.jsxs)(t.default,{component:`widget.header`,children:[D(`move`),(0,s.jsxs)(t.default,{component:`widget.label`,children:[i!==void 0&&(0,s.jsx)(t.default,{component:`widget.title`,tag:d[u-1],children:i}),c!==void 0&&(0,s.jsx)(t.default,{component:`widget.description`,children:c})]}),g&&(0,s.jsx)(t.default,{component:`widget.handle`,tag:`button`,variant:{editable:!0},props:{type:`button`,"aria-label":_??`Refresh ${T}`,onClick:g},children:(0,s.jsx)(S,{})}),l!==void 0&&(0,s.jsx)(t.default,{component:`widget.actions`,children:l})]}),(0,s.jsx)(t.default,{component:`widget.body`,children:O()}),D(`resize`)]})}var w=b;w.displayName=`DashboardGrid`;var T=C;T.displayName=`Widget`,exports.DashboardUtils=l,exports.Widget=T,exports.default=w;
|
package/components/dashboard.mjs
CHANGED
|
@@ -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 {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as GridModel } from '../models/gridModel';
|
|
2
|
+
interface Props<TRow> {
|
|
3
|
+
grid: GridModel<TRow>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The grid drawn for a phone. A `<ul>` of items rather than a restyled `role="grid"`: a grid promises the
|
|
7
|
+
* arrow-key movement of a two-dimensional widget, and a list of items with a button in each is a list — so
|
|
8
|
+
* every value keeps its label in a `<dl>`, and each item says where it is in the whole with
|
|
9
|
+
* `aria-posinset`/`aria-setsize`.
|
|
10
|
+
*/
|
|
11
|
+
export default function DataGridList<TRow>(props: Props<TRow>): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as AggregateCellModel } from '../models/aggregateCellModel';
|
|
2
|
+
interface Props<TRow> {
|
|
3
|
+
cell: AggregateCellModel<TRow>;
|
|
4
|
+
}
|
|
5
|
+
/** An aggregate inside a line of text: the column's `AggregateCell` where it has one, the value otherwise. */
|
|
6
|
+
export default function DataGridListAggregate<TRow>(props: Props<TRow>): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as ColumnModel } from '../models/columnModel';
|
|
2
|
+
interface Props<TRow> {
|
|
3
|
+
column: ColumnModel<TRow>;
|
|
4
|
+
}
|
|
5
|
+
/** One column's filter, drawn for a finger: a full-width field, a native picker, chips or a checklist. */
|
|
6
|
+
export default function DataGridListFilter<TRow>(props: Props<TRow>): import("react").JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as GridModel } from '../models/gridModel';
|
|
2
|
+
interface Props<TRow> {
|
|
3
|
+
grid: GridModel<TRow>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The Filters button and the sheet it opens: every filterable column, one section each. A filter applies as
|
|
7
|
+
* it is set, so the list behind the sheet is already the answer, and the main button says how many rows that
|
|
8
|
+
* is — "Show 42 rows" tells a reader what closing the sheet will show before they close it.
|
|
9
|
+
*/
|
|
10
|
+
export default function DataGridListFilterSheet<TRow>(props: Props<TRow>): import("react").JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as GridModel } from '../models/gridModel';
|
|
2
|
+
interface Props<TRow> {
|
|
3
|
+
grid: GridModel<TRow>;
|
|
4
|
+
/** How many rows are drawn — left out where groups or a tree make "of how many" a different question. */
|
|
5
|
+
shown?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Under the items: the grand totals as one more summary block, then either the pager — when the host pages —
|
|
9
|
+
* or "Show more". A button rather than an endless scroll, so the totals and whatever follows the grid on the
|
|
10
|
+
* page stay reachable (NN/g), and a keyboard is never trapped above content that keeps arriving.
|
|
11
|
+
*/
|
|
12
|
+
export default function DataGridListFooter<TRow>(props: Props<TRow>): import("react").JSX.Element;
|
|
13
|
+
export {};
|