@box-kite/react 2.0.0 → 2.1.0
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 +16 -0
- package/.claude/skills/box-kite/SKILL.md +16 -0
- package/.claude/skills/box-kite/references/components.md +8 -3
- package/.claude/skills/box-kite/references/patterns.md +23 -0
- package/.cursor/rules/box-kite.mdc +16 -0
- package/AGENTS.md +19 -0
- package/BOX_AI_CONTEXT.md +562 -1
- package/BOX_KITE_AI_CONTEXT.md +562 -1
- package/README.md +39 -7
- package/catalog.cjs +1 -0
- package/catalog.d.ts +8 -0
- package/catalog.mjs +2333 -0
- package/client.cjs +1 -1
- package/client.mjs +40 -42
- package/components/agent.cjs +1 -0
- package/components/agent.d.ts +215 -0
- package/components/agent.mjs +405 -0
- package/components/chart.d.ts +1 -0
- package/components/dashboard.cjs +1 -0
- package/components/dashboard.d.ts +121 -0
- package/components/dashboard.mjs +690 -0
- package/components/dataGrid/components/dataGridBody.d.ts +2 -1
- package/components/dataGrid/components/dataGridDetailRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridGroupRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridRow.d.ts +13 -2
- package/components/dataGrid/contracts/dataGridContract.d.ts +66 -2
- package/components/dataGrid/models/cellModel.d.ts +3 -0
- package/components/dataGrid/models/editModel.d.ts +27 -0
- package/components/dataGrid/models/exportModel.d.ts +2 -1
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/rangeModel.d.ts +119 -0
- package/components/dataGrid/models/viewportModel.d.ts +23 -2
- package/components/dataGrid/useGridNavigation.d.ts +10 -2
- package/components/dataGrid.cjs +4 -1
- package/components/dataGrid.d.ts +3 -0
- package/components/dataGrid.mjs +1056 -765
- package/components/markdown.cjs +1 -0
- package/components/markdown.d.ts +55 -0
- package/components/markdown.mjs +179 -0
- package/components/semantics.d.ts +29 -29
- package/components/skeleton.cjs +1 -0
- package/components/skeleton.d.ts +34 -0
- package/components/skeleton.mjs +25 -0
- package/dashboardSchema.cjs +1 -0
- package/dashboardSchema.mjs +78 -0
- package/docs/a11y.md +2 -3
- package/docs/catalog.md +451 -0
- package/docs/components.md +4 -0
- package/docs/index.md +3 -0
- package/docs/interop.md +237 -0
- package/docs/mcp.md +69 -0
- package/docs/props.md +3 -3
- package/interop.cjs +1 -0
- package/interop.d.ts +51 -0
- package/interop.mjs +454 -0
- package/mcp/src/data.d.ts +88 -0
- package/mcp/src/data.test.d.ts +1 -0
- package/mcp/src/engine.d.ts +23 -0
- package/mcp/src/index.d.ts +1 -0
- package/mcp/src/search.d.ts +26 -0
- package/mcp/src/search.test.d.ts +1 -0
- package/mcp/src/server.d.ts +18 -0
- package/mcp/src/server.test.d.ts +1 -0
- package/mcp/src/styles.d.ts +27 -0
- package/mcp/src/styles.test.d.ts +1 -0
- package/mcp/src/tools.d.ts +18 -0
- package/mcp/src/vocabulary.d.ts +41 -0
- package/package.json +124 -17
- package/react/spec/renderSpec.d.ts +51 -0
- package/react/spec/specBoundary.d.ts +25 -0
- package/react/spec/specRegistry.d.ts +42 -0
- package/react/spec/specRenderer.d.ts +10 -0
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +22 -0
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +13 -0
- package/registry/blocks/data-grid/invoice-rows.d.ts +15 -0
- package/registry/blocks/data-grid/invoices-grid.d.ts +1 -0
- package/registry/blocks/settings-form/settings-form.d.ts +17 -0
- package/spec.cjs +2 -0
- package/spec.d.ts +12 -0
- package/spec.mjs +382 -0
- package/specData.cjs +1 -0
- package/specData.mjs +69 -0
- package/specDefs.cjs +1 -0
- package/specDefs.mjs +33 -0
- package/specSchema.cjs +1 -0
- package/specSchema.mjs +88 -0
- package/utils/agent/agentUtils.d.ts +81 -0
- package/utils/catalog/catalogContracts.d.ts +19 -0
- package/utils/catalog/catalogManifest.d.ts +8 -0
- package/utils/dashboard/dashboardSchema.d.ts +18 -0
- package/utils/dashboard/dashboardUtils.d.ts +97 -0
- package/utils/interop/a2uiInterop.d.ts +82 -0
- package/utils/interop/assistantUiInterop.d.ts +34 -0
- package/utils/interop/toolInterop.d.ts +30 -0
- package/utils/spec/specData.d.ts +19 -0
- package/utils/spec/specDefs.d.ts +11 -0
- package/utils/spec/specProps.d.ts +15 -0
- package/utils/spec/specSchema.d.ts +23 -0
- package/utils/spec/specTypes.d.ts +71 -0
- package/utils/spec/specValidate.d.ts +10 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { u as e } from "../platform.mjs";
|
|
3
|
+
import t from "../box.mjs";
|
|
4
|
+
import { a as n, i as r, o as i } from "../behavior.mjs";
|
|
5
|
+
import { t as a } from "../dashboardSchema.mjs";
|
|
6
|
+
import { Circle as o, Path as s, Svg as c } from "./svg.mjs";
|
|
7
|
+
import l from "./visuallyHidden.mjs";
|
|
8
|
+
import { createContext as u, useContext as d, useId as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
9
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
10
|
+
//#region src/utils/dashboard/dashboardUtils.ts
|
|
11
|
+
var v;
|
|
12
|
+
(function(e) {
|
|
13
|
+
let t = e.VERSION = 1, n = e.MIN_COLUMNS = 1, r = e.MAX_COLUMNS = 24;
|
|
14
|
+
function i(e, t, n) {
|
|
15
|
+
return Math.min(Math.max(e, t), n);
|
|
16
|
+
}
|
|
17
|
+
function o(e, t) {
|
|
18
|
+
return typeof e == "number" && Number.isFinite(e) ? Math.round(e) : t;
|
|
19
|
+
}
|
|
20
|
+
function s(e, t) {
|
|
21
|
+
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;
|
|
22
|
+
}
|
|
23
|
+
e.overlaps = s;
|
|
24
|
+
function c(e, t) {
|
|
25
|
+
return e.find((e) => e.id !== t.id && s(e, t));
|
|
26
|
+
}
|
|
27
|
+
function l(e, t) {
|
|
28
|
+
let n = Math.min(e.maxW ?? t, t), r = i(o(e.w, 1), Math.max(1, Math.min(e.minW ?? 1, n)), Math.max(1, n)), a = i(o(e.h, 1), Math.max(1, e.minH ?? 1), Math.max(1, e.maxH ?? 2 ** 53 - 1));
|
|
29
|
+
return {
|
|
30
|
+
...e,
|
|
31
|
+
w: r,
|
|
32
|
+
h: a,
|
|
33
|
+
x: i(o(e.x, 0), 0, t - r),
|
|
34
|
+
y: Math.max(o(e.y, 0), 0)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function u(e, t) {
|
|
38
|
+
return e.y - t.y || e.x - t.x;
|
|
39
|
+
}
|
|
40
|
+
function d(e, t) {
|
|
41
|
+
let a = i(o(t, 12), n, r), s = e.map((e) => l(e, a)), d = (e) => +!e.fixed, f = [...s].sort((e, t) => d(e) - d(t) || u(e, t)), p = [];
|
|
42
|
+
for (let e of f) {
|
|
43
|
+
if (e.fixed) {
|
|
44
|
+
p.push(e);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
let t = { ...e };
|
|
48
|
+
for (; t.y > 0 && !c(p, {
|
|
49
|
+
...t,
|
|
50
|
+
y: t.y - 1
|
|
51
|
+
});) t.y--;
|
|
52
|
+
let n = c(p, t);
|
|
53
|
+
for (; n;) t.y = n.y + n.h, n = c(p, t);
|
|
54
|
+
p.push(t);
|
|
55
|
+
}
|
|
56
|
+
return p.sort(u);
|
|
57
|
+
}
|
|
58
|
+
e.resolve = d;
|
|
59
|
+
function f(e) {
|
|
60
|
+
let a = i(o(e.columns, 12), n, r);
|
|
61
|
+
return {
|
|
62
|
+
version: t,
|
|
63
|
+
columns: a,
|
|
64
|
+
items: d(e.items, a)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
e.normalize = f;
|
|
68
|
+
function p(e, t) {
|
|
69
|
+
return e.items.find((e) => e.id === t);
|
|
70
|
+
}
|
|
71
|
+
e.itemOf = p;
|
|
72
|
+
function m(e) {
|
|
73
|
+
return new Map(e.items.map((e, t) => [e.id, t]));
|
|
74
|
+
}
|
|
75
|
+
e.ranks = m;
|
|
76
|
+
function h(e, t) {
|
|
77
|
+
let n = (n) => !s(t, n) && !e.some((e) => e.id !== n.id && e.id !== t.id && s(e, n));
|
|
78
|
+
return e.map((e) => {
|
|
79
|
+
if (e.id === t.id) return t;
|
|
80
|
+
if (e.fixed === !0 || !s(e, t)) return e;
|
|
81
|
+
let r = {
|
|
82
|
+
...e,
|
|
83
|
+
y: Math.max(t.y - e.h, 0)
|
|
84
|
+
};
|
|
85
|
+
return n(r) ? r : {
|
|
86
|
+
...e,
|
|
87
|
+
y: t.y + t.h
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function g(e, t, a, s) {
|
|
92
|
+
let c = p(e, t);
|
|
93
|
+
if (!c || c.fixed) return e;
|
|
94
|
+
let u = l({
|
|
95
|
+
...c,
|
|
96
|
+
x: a,
|
|
97
|
+
y: s
|
|
98
|
+
}, i(o(e.columns, 12), n, r));
|
|
99
|
+
return f({
|
|
100
|
+
...e,
|
|
101
|
+
items: h(e.items, u)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
e.moveTo = g;
|
|
105
|
+
function _(e, t, n, r) {
|
|
106
|
+
let i = p(e, t);
|
|
107
|
+
if (!i || i.fixed) return e;
|
|
108
|
+
let a = e.items.map((e) => e.id === t ? {
|
|
109
|
+
...e,
|
|
110
|
+
w: n,
|
|
111
|
+
h: r
|
|
112
|
+
} : e);
|
|
113
|
+
return f({
|
|
114
|
+
...e,
|
|
115
|
+
items: a
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
e.resizeTo = _;
|
|
119
|
+
function v(e, t) {
|
|
120
|
+
let n = e.items.reduce((e, t) => Math.max(e, t.y + t.h), 0);
|
|
121
|
+
return f({
|
|
122
|
+
...e,
|
|
123
|
+
items: [...e.items, {
|
|
124
|
+
x: 0,
|
|
125
|
+
y: n,
|
|
126
|
+
...t
|
|
127
|
+
}]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
e.add = v;
|
|
131
|
+
function y(e, t) {
|
|
132
|
+
return f({
|
|
133
|
+
...e,
|
|
134
|
+
items: e.items.filter((e) => e.id !== t)
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
e.remove = y;
|
|
138
|
+
function b(e, a) {
|
|
139
|
+
let s = i(o(a, 12), n, r);
|
|
140
|
+
if (s === e.columns) return f(e);
|
|
141
|
+
let c = s / e.columns, l = (e) => e === void 0 ? void 0 : i(Math.max(1, Math.round(e * c)), 1, s), u = e.items.map((e) => {
|
|
142
|
+
let t = i(Math.max(1, Math.round(e.w * c)), 1, s);
|
|
143
|
+
return {
|
|
144
|
+
...e,
|
|
145
|
+
w: t,
|
|
146
|
+
x: i(Math.floor(e.x * c), 0, s - t),
|
|
147
|
+
minW: l(e.minW),
|
|
148
|
+
maxW: l(e.maxW)
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
return f({
|
|
152
|
+
version: t,
|
|
153
|
+
columns: s,
|
|
154
|
+
items: u
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
e.project = b;
|
|
158
|
+
function x(e, t) {
|
|
159
|
+
return e === t ? !0 : e.columns !== t.columns || e.items.length !== t.items.length ? !1 : e.items.every((e, n) => {
|
|
160
|
+
let r = t.items[n];
|
|
161
|
+
return e.id === r.id && e.x === r.x && e.y === r.y && e.w === r.w && e.h === r.h;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
e.same = x;
|
|
165
|
+
function S(e, t, n) {
|
|
166
|
+
return {
|
|
167
|
+
columns: n.x > 0 ? Math.round(e / n.x) : 0,
|
|
168
|
+
rows: n.y > 0 ? Math.round(t / n.y) : 0
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
e.cellsMoved = S;
|
|
172
|
+
function C(e) {
|
|
173
|
+
return typeof e == "string" && e.length > 0;
|
|
174
|
+
}
|
|
175
|
+
function w(e) {
|
|
176
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
177
|
+
}
|
|
178
|
+
function T(e, t, n) {
|
|
179
|
+
if (typeof e != "object" || !e || Array.isArray(e)) {
|
|
180
|
+
n.push({
|
|
181
|
+
code: "invalid-item",
|
|
182
|
+
path: t,
|
|
183
|
+
message: "A layout item has to be an object."
|
|
184
|
+
});
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
let r = e;
|
|
188
|
+
if (!C(r.id)) {
|
|
189
|
+
n.push({
|
|
190
|
+
code: "invalid-item",
|
|
191
|
+
path: `${t}.id`,
|
|
192
|
+
message: "A layout item needs an id naming the widget it places."
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (!w(r.x) || !w(r.y) || !w(r.w) || !w(r.h)) {
|
|
197
|
+
n.push({
|
|
198
|
+
code: "invalid-item",
|
|
199
|
+
path: t,
|
|
200
|
+
message: `Item "${r.id}" needs numeric x, y, w and h.`
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let i = [
|
|
205
|
+
"minW",
|
|
206
|
+
"minH",
|
|
207
|
+
"maxW",
|
|
208
|
+
"maxH"
|
|
209
|
+
].reduce((e, t) => (w(r[t]) && (e[t] = Math.round(r[t])), e), {});
|
|
210
|
+
return {
|
|
211
|
+
id: r.id,
|
|
212
|
+
x: Math.round(r.x),
|
|
213
|
+
y: Math.round(r.y),
|
|
214
|
+
w: Math.round(r.w),
|
|
215
|
+
h: Math.round(r.h),
|
|
216
|
+
...i,
|
|
217
|
+
...r.fixed === !0 ? { fixed: !0 } : {}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function E(e, a = 12) {
|
|
221
|
+
let o = [], s = {
|
|
222
|
+
version: t,
|
|
223
|
+
columns: a,
|
|
224
|
+
items: []
|
|
225
|
+
};
|
|
226
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return o.push({
|
|
227
|
+
code: "not-an-object",
|
|
228
|
+
path: "",
|
|
229
|
+
message: "A layout has to be an object."
|
|
230
|
+
}), {
|
|
231
|
+
layout: f(s),
|
|
232
|
+
issues: o
|
|
233
|
+
};
|
|
234
|
+
let c = e;
|
|
235
|
+
c.version !== t && o.push({
|
|
236
|
+
code: "version",
|
|
237
|
+
path: "version",
|
|
238
|
+
message: `Layout version ${String(c.version)} was read as version ${t}.`
|
|
239
|
+
});
|
|
240
|
+
let l = w(c.columns) ? i(Math.round(c.columns), n, r) : a;
|
|
241
|
+
if (w(c.columns) || o.push({
|
|
242
|
+
code: "columns",
|
|
243
|
+
path: "columns",
|
|
244
|
+
message: `No column count, so the layout was read in ${a}.`
|
|
245
|
+
}), !Array.isArray(c.items)) return o.push({
|
|
246
|
+
code: "items",
|
|
247
|
+
path: "items",
|
|
248
|
+
message: "A layout needs an items array."
|
|
249
|
+
}), {
|
|
250
|
+
layout: f({
|
|
251
|
+
...s,
|
|
252
|
+
columns: l
|
|
253
|
+
}),
|
|
254
|
+
issues: o
|
|
255
|
+
};
|
|
256
|
+
let u = /* @__PURE__ */ new Set(), d = c.items.reduce((e, t, n) => {
|
|
257
|
+
let r = T(t, `items.${n}`, o);
|
|
258
|
+
return r ? u.has(r.id) ? (o.push({
|
|
259
|
+
code: "duplicate-id",
|
|
260
|
+
path: `items.${n}.id`,
|
|
261
|
+
message: `Two items are called "${r.id}"; the second was dropped.`
|
|
262
|
+
}), e) : (u.add(r.id), e.push(r), e) : e;
|
|
263
|
+
}, []);
|
|
264
|
+
return {
|
|
265
|
+
layout: f({
|
|
266
|
+
version: t,
|
|
267
|
+
columns: l,
|
|
268
|
+
items: d
|
|
269
|
+
}),
|
|
270
|
+
issues: o
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
e.parse = E, e.SCHEMA = a;
|
|
274
|
+
})(v ||= {});
|
|
275
|
+
var y = v, b = [
|
|
276
|
+
"xs",
|
|
277
|
+
"sm",
|
|
278
|
+
"md",
|
|
279
|
+
"lg",
|
|
280
|
+
"xl",
|
|
281
|
+
"xxl"
|
|
282
|
+
], x = [
|
|
283
|
+
"h1",
|
|
284
|
+
"h2",
|
|
285
|
+
"h3",
|
|
286
|
+
"h4",
|
|
287
|
+
"h5",
|
|
288
|
+
"h6"
|
|
289
|
+
], S = u(null);
|
|
290
|
+
function C(e, t, n) {
|
|
291
|
+
return Math.min(Math.max(e, t), n);
|
|
292
|
+
}
|
|
293
|
+
function w(e) {
|
|
294
|
+
if (typeof e == "number") return [{ count: C(Math.round(e), y.MIN_COLUMNS, y.MAX_COLUMNS) }];
|
|
295
|
+
let t = b.filter((t) => typeof e[t] == "number").map((t) => ({
|
|
296
|
+
size: t,
|
|
297
|
+
count: C(Math.round(e[t]), y.MIN_COLUMNS, y.MAX_COLUMNS)
|
|
298
|
+
}));
|
|
299
|
+
return t.length > 0 ? t : [{ count: 12 }];
|
|
300
|
+
}
|
|
301
|
+
function T(e) {
|
|
302
|
+
return {
|
|
303
|
+
gridColumnStart: e.x + 1,
|
|
304
|
+
gridColumnEnd: e.x + 1 + e.w,
|
|
305
|
+
gridRowStart: e.y + 1,
|
|
306
|
+
gridRowEnd: e.y + 1 + e.h
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function E(e) {
|
|
310
|
+
return `max${e[0].toUpperCase()}${e.slice(1)}`;
|
|
311
|
+
}
|
|
312
|
+
function D(e, t) {
|
|
313
|
+
let n = t ? -1 : 1;
|
|
314
|
+
if (e === "ArrowLeft") return {
|
|
315
|
+
x: -n,
|
|
316
|
+
y: 0
|
|
317
|
+
};
|
|
318
|
+
if (e === "ArrowRight") return {
|
|
319
|
+
x: n,
|
|
320
|
+
y: 0
|
|
321
|
+
};
|
|
322
|
+
if (e === "ArrowUp") return {
|
|
323
|
+
x: 0,
|
|
324
|
+
y: -1
|
|
325
|
+
};
|
|
326
|
+
if (e === "ArrowDown") return {
|
|
327
|
+
x: 0,
|
|
328
|
+
y: 1
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function O(e) {
|
|
332
|
+
return `column ${e.x + 1}, row ${e.y + 1}`;
|
|
333
|
+
}
|
|
334
|
+
function k(e) {
|
|
335
|
+
return `${e.w} ${e.w === 1 ? "column" : "columns"} by ${e.h} ${e.h === 1 ? "row" : "rows"}`;
|
|
336
|
+
}
|
|
337
|
+
function A(a) {
|
|
338
|
+
let { children: o, layout: s, defaultLayout: c, onLayoutChange: u, onLayoutCommit: d, columns: v = {
|
|
339
|
+
xs: 1,
|
|
340
|
+
md: 6,
|
|
341
|
+
xxl: 12
|
|
342
|
+
}, rowHeight: x = 24, editable: C = !1, label: A, labelledBy: j, props: M, ...N } = a, P = m(null), [F, I] = h(null), [L, R] = h(null), [ee, z] = h(""), B = `${f()}-dashboard`, [V, te] = r({
|
|
343
|
+
value: s,
|
|
344
|
+
defaultValue: c ?? {
|
|
345
|
+
version: y.VERSION,
|
|
346
|
+
columns: 12,
|
|
347
|
+
items: []
|
|
348
|
+
},
|
|
349
|
+
onChange: u
|
|
350
|
+
}), H = p(() => y.normalize(V), [V]), U = i(H), W = n(d), ne = typeof v == "number" ? String(v) : b.map((e) => v[e] ?? "").join(), G = p(() => w(v), [ne]), K = G[G.length - 1], q = p(() => {
|
|
351
|
+
let e = y.ranks(H), t = /* @__PURE__ */ new Map();
|
|
352
|
+
for (let n of G) {
|
|
353
|
+
let r = n.count === K.count ? H : y.project(H, n.count), i = K.count / n.count;
|
|
354
|
+
for (let a of r.items) {
|
|
355
|
+
let r = t.get(a.id) ?? {
|
|
356
|
+
order: e.get(a.id) ?? 0,
|
|
357
|
+
fixed: a.fixed === !0
|
|
358
|
+
}, o = T({
|
|
359
|
+
...a,
|
|
360
|
+
x: Math.round(a.x * i),
|
|
361
|
+
w: Math.round((a.x + a.w) * i) - Math.round(a.x * i)
|
|
362
|
+
});
|
|
363
|
+
n === G[0] ? r.placement = o : r.query = {
|
|
364
|
+
...r.query,
|
|
365
|
+
[n.size]: o
|
|
366
|
+
}, t.set(a.id, r);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return t;
|
|
370
|
+
}, [
|
|
371
|
+
H,
|
|
372
|
+
G,
|
|
373
|
+
K.count
|
|
374
|
+
]), J = n((e, t) => {
|
|
375
|
+
y.same(e, U.current) || te(e, t);
|
|
376
|
+
}), re = (e, t) => {
|
|
377
|
+
let n = e.getBoundingClientRect(), r = P.current, i = r && typeof getComputedStyle == "function" ? getComputedStyle(r) : void 0, a = Number.parseFloat(i?.columnGap ?? "") || 0, o = Number.parseFloat(i?.rowGap ?? "") || 0;
|
|
378
|
+
return {
|
|
379
|
+
x: (n.width + a) / t.w,
|
|
380
|
+
y: (n.height + o) / t.h
|
|
381
|
+
};
|
|
382
|
+
}, ie = (e) => e instanceof Element ? e.closest("[data-widget-id]") : null, Y = (e, t, n, r) => {
|
|
383
|
+
let i = e.kind === "move" ? y.moveTo(U.current, e.id, t, n) : y.resizeTo(U.current, e.id, t, n);
|
|
384
|
+
return J(i, {
|
|
385
|
+
reason: e.kind,
|
|
386
|
+
event: r
|
|
387
|
+
}), i;
|
|
388
|
+
}, X = n((t, n, r, i) => {
|
|
389
|
+
let a = y.itemOf(U.current, n), o = ie(t.currentTarget);
|
|
390
|
+
!C || t.button !== 0 || t.defaultPrevented || !a || a.fixed || !o || (t.preventDefault(), t.currentTarget.setPointerCapture?.(t.pointerId), t.currentTarget.focus(), I({
|
|
391
|
+
id: n,
|
|
392
|
+
kind: i,
|
|
393
|
+
name: r,
|
|
394
|
+
origin: a,
|
|
395
|
+
before: U.current,
|
|
396
|
+
pointer: {
|
|
397
|
+
id: t.pointerId,
|
|
398
|
+
x: t.clientX,
|
|
399
|
+
y: t.clientY,
|
|
400
|
+
step: re(o, a),
|
|
401
|
+
rtl: e(o)
|
|
402
|
+
}
|
|
403
|
+
}));
|
|
404
|
+
}), Z = n((e, t) => {
|
|
405
|
+
if (!F?.pointer || F.id !== t) return;
|
|
406
|
+
let { x: n, y: r, step: i, rtl: a } = F.pointer, o = {
|
|
407
|
+
x: e.clientX - n,
|
|
408
|
+
y: e.clientY - r
|
|
409
|
+
}, s = y.cellsMoved(a ? -o.x : o.x, o.y, i), c = F.origin, l = F.kind === "move" ? Y(F, c.x + s.columns, c.y + s.rows, e) : Y(F, c.w + s.columns, c.h + s.rows, e), u = y.itemOf(l, t);
|
|
410
|
+
if (F.kind !== "move" || !u) return;
|
|
411
|
+
let d = {
|
|
412
|
+
x: (u.x - c.x) * i.x * (a ? -1 : 1),
|
|
413
|
+
y: (u.y - c.y) * i.y
|
|
414
|
+
};
|
|
415
|
+
R({ translate: `${Math.round(o.x - d.x)}px ${Math.round(o.y - d.y)}px` });
|
|
416
|
+
}), Q = n((e, t) => {
|
|
417
|
+
if (!F?.pointer || F.id !== t) return;
|
|
418
|
+
let n = y.itemOf(U.current, t);
|
|
419
|
+
e.currentTarget.releasePointerCapture?.(F.pointer.id), I(null), R(null), W(U.current, {
|
|
420
|
+
reason: F.kind,
|
|
421
|
+
event: e
|
|
422
|
+
}), n && z(F.kind === "move" ? `${F.name} moved to ${O(n)}.` : `${F.name} resized to ${k(n)}.`);
|
|
423
|
+
}), ae = n((e, t) => {
|
|
424
|
+
J(e.before, {
|
|
425
|
+
reason: e.kind,
|
|
426
|
+
event: t
|
|
427
|
+
}), I(null), z(`${e.name} put back at ${O(e.origin)}.`);
|
|
428
|
+
}), oe = n((t, n, r, i) => {
|
|
429
|
+
if (!C || t.defaultPrevented) return;
|
|
430
|
+
let a = F && F.id === n && F.kind === i && !F.pointer ? F : void 0, o = y.itemOf(U.current, n);
|
|
431
|
+
if (!o) return;
|
|
432
|
+
if (!a) {
|
|
433
|
+
if (t.key !== "Enter" && t.key !== " " || o.fixed) return;
|
|
434
|
+
t.preventDefault(), I({
|
|
435
|
+
id: n,
|
|
436
|
+
kind: i,
|
|
437
|
+
name: r,
|
|
438
|
+
origin: o,
|
|
439
|
+
before: U.current
|
|
440
|
+
}), z(i === "move" ? `${r} picked up at ${O(o)}. Use the arrow keys to move it.` : `${r} held for resizing at ${k(o)}. Use the arrow keys to resize it.`);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (t.key === "Escape") {
|
|
444
|
+
t.preventDefault(), ae(a, t);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (t.key === "Enter" || t.key === " ") {
|
|
448
|
+
t.preventDefault(), I(null), W(U.current, {
|
|
449
|
+
reason: i,
|
|
450
|
+
event: t
|
|
451
|
+
}), z(i === "move" ? `${r} dropped at ${O(o)}.` : `${r} resized to ${k(o)}.`);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
let s = D(t.key, e(t.currentTarget));
|
|
455
|
+
if (!s) return;
|
|
456
|
+
t.preventDefault();
|
|
457
|
+
let c = i === "move" ? Y(a, o.x + s.x, o.y + s.y, t) : Y(a, o.w + s.x, o.h + s.y, t), l = y.itemOf(c, n);
|
|
458
|
+
l && z(i === "move" ? `${r}, ${O(l)}.` : `${r}, ${k(l)}.`);
|
|
459
|
+
}), se = n((e, t, n) => {
|
|
460
|
+
F && F.id === t && F.kind === n && !F.pointer && ae(F, e);
|
|
461
|
+
}), ce = p(() => ({
|
|
462
|
+
editable: C,
|
|
463
|
+
placementOf: (e) => q.get(e),
|
|
464
|
+
heldOf: (e) => F && F.id === e ? F : void 0,
|
|
465
|
+
offsetOf: (e) => F && F.id === e && L ? L : void 0,
|
|
466
|
+
outsideAuthoring: K.size ? { [E(K.size)]: { display: "none" } } : void 0,
|
|
467
|
+
instructionsId: B,
|
|
468
|
+
handleProps: (e, t, n) => ({
|
|
469
|
+
type: "button",
|
|
470
|
+
"aria-label": n === "move" ? `Move ${t}` : `Resize ${t}`,
|
|
471
|
+
"aria-pressed": !!(F && F.id === e && F.kind === n),
|
|
472
|
+
"aria-describedby": B,
|
|
473
|
+
onPointerDown: (r) => X(r, e, t, n),
|
|
474
|
+
onPointerMove: (t) => Z(t, e),
|
|
475
|
+
onPointerUp: (t) => Q(t, e),
|
|
476
|
+
onPointerCancel: (t) => Q(t, e),
|
|
477
|
+
onKeyDown: (r) => oe(r, e, t, n),
|
|
478
|
+
onBlur: (t) => se(t, e, n)
|
|
479
|
+
})
|
|
480
|
+
}), [
|
|
481
|
+
C,
|
|
482
|
+
q,
|
|
483
|
+
F,
|
|
484
|
+
L,
|
|
485
|
+
K.size,
|
|
486
|
+
B,
|
|
487
|
+
X,
|
|
488
|
+
Z,
|
|
489
|
+
Q,
|
|
490
|
+
oe,
|
|
491
|
+
se
|
|
492
|
+
]), $ = F ? q.get(F.id) : void 0;
|
|
493
|
+
return /* @__PURE__ */ _(S.Provider, {
|
|
494
|
+
value: ce,
|
|
495
|
+
children: [
|
|
496
|
+
/* @__PURE__ */ _(t, {
|
|
497
|
+
ref: P,
|
|
498
|
+
component: "dashboard",
|
|
499
|
+
...N,
|
|
500
|
+
variant: [N.variant, { dragging: F !== null }],
|
|
501
|
+
vars: { "dashboard-row": `${x / 4}rem` },
|
|
502
|
+
gridTemplateColumns: K.count,
|
|
503
|
+
props: {
|
|
504
|
+
role: "list",
|
|
505
|
+
"aria-label": A,
|
|
506
|
+
"aria-labelledby": j,
|
|
507
|
+
...M
|
|
508
|
+
},
|
|
509
|
+
children: [o, $ && /* @__PURE__ */ g(t, {
|
|
510
|
+
component: "dashboard.placeholder",
|
|
511
|
+
order: $.order,
|
|
512
|
+
cq: $.query,
|
|
513
|
+
...$.placement,
|
|
514
|
+
props: {
|
|
515
|
+
role: "presentation",
|
|
516
|
+
"aria-hidden": !0
|
|
517
|
+
}
|
|
518
|
+
})]
|
|
519
|
+
}),
|
|
520
|
+
/* @__PURE__ */ g(l, {
|
|
521
|
+
props: { role: "status" },
|
|
522
|
+
children: ee
|
|
523
|
+
}),
|
|
524
|
+
/* @__PURE__ */ g(l, {
|
|
525
|
+
id: B,
|
|
526
|
+
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."
|
|
527
|
+
})
|
|
528
|
+
]
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
function j({ kind: e }) {
|
|
532
|
+
return e === "resize" ? /* @__PURE__ */ g(c, {
|
|
533
|
+
viewBox: "0 0 24 24",
|
|
534
|
+
width: "1rem",
|
|
535
|
+
height: "1rem",
|
|
536
|
+
rtl: { flip: "xAxis" },
|
|
537
|
+
props: { fill: "none" },
|
|
538
|
+
children: /* @__PURE__ */ g(s, {
|
|
539
|
+
d: "M20 10 10 20M20 16l-4 4",
|
|
540
|
+
stroke: "currentColor",
|
|
541
|
+
strokeWidth: 2,
|
|
542
|
+
strokeLinecap: "round"
|
|
543
|
+
})
|
|
544
|
+
}) : /* @__PURE__ */ _(c, {
|
|
545
|
+
viewBox: "0 0 24 24",
|
|
546
|
+
width: "1rem",
|
|
547
|
+
height: "1rem",
|
|
548
|
+
children: [[
|
|
549
|
+
8,
|
|
550
|
+
12,
|
|
551
|
+
16
|
|
552
|
+
].map((e) => /* @__PURE__ */ g(o, {
|
|
553
|
+
cx: 9,
|
|
554
|
+
cy: e,
|
|
555
|
+
r: 1.4,
|
|
556
|
+
fill: "currentColor"
|
|
557
|
+
}, e)), [
|
|
558
|
+
8,
|
|
559
|
+
12,
|
|
560
|
+
16
|
|
561
|
+
].map((e) => /* @__PURE__ */ g(o, {
|
|
562
|
+
cx: 15,
|
|
563
|
+
cy: e,
|
|
564
|
+
r: 1.4,
|
|
565
|
+
fill: "currentColor"
|
|
566
|
+
}, e))]
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function M() {
|
|
570
|
+
return /* @__PURE__ */ g(c, {
|
|
571
|
+
viewBox: "0 0 24 24",
|
|
572
|
+
width: "1rem",
|
|
573
|
+
height: "1rem",
|
|
574
|
+
props: { fill: "none" },
|
|
575
|
+
children: /* @__PURE__ */ g(s, {
|
|
576
|
+
d: "M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4",
|
|
577
|
+
stroke: "currentColor",
|
|
578
|
+
strokeWidth: 2,
|
|
579
|
+
strokeLinecap: "round",
|
|
580
|
+
strokeLinejoin: "round"
|
|
581
|
+
})
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
function N(e) {
|
|
585
|
+
let { id: n, children: r, title: i, name: a, description: o, actions: s, level: c = 3, loading: l = !1, error: u, empty: f, onRefresh: p, refreshLabel: m, props: h, ...v } = e, y = d(S), b = n === void 0 ? void 0 : y?.placementOf(n), C = n === void 0 ? void 0 : y?.heldOf(n), w = a ?? (typeof i == "string" ? i : void 0) ?? n ?? "Widget", T = y?.editable === !0 && b !== void 0 && !b.fixed, E = (e) => T && n !== void 0 ? /* @__PURE__ */ g(t, {
|
|
586
|
+
component: "widget.handle",
|
|
587
|
+
tag: "button",
|
|
588
|
+
variant: {
|
|
589
|
+
editable: !0,
|
|
590
|
+
grabbed: C?.kind === e,
|
|
591
|
+
corner: e === "resize"
|
|
592
|
+
},
|
|
593
|
+
cq: y?.outsideAuthoring,
|
|
594
|
+
props: y?.handleProps(n, w, e),
|
|
595
|
+
children: /* @__PURE__ */ g(j, { kind: e })
|
|
596
|
+
}) : null, D = () => l ? /* @__PURE__ */ g(t, {
|
|
597
|
+
component: "widget.skeleton",
|
|
598
|
+
props: { "aria-hidden": !0 },
|
|
599
|
+
children: [
|
|
600
|
+
80,
|
|
601
|
+
100,
|
|
602
|
+
60
|
|
603
|
+
].map((e) => /* @__PURE__ */ g(t, {
|
|
604
|
+
component: "widget.skeleton.bar",
|
|
605
|
+
width: `${e}%`
|
|
606
|
+
}, e))
|
|
607
|
+
}) : u ? /* @__PURE__ */ _(t, {
|
|
608
|
+
component: "widget.message",
|
|
609
|
+
variant: { error: !0 },
|
|
610
|
+
props: { role: "status" },
|
|
611
|
+
children: [u, p && /* @__PURE__ */ g(t, {
|
|
612
|
+
tag: "button",
|
|
613
|
+
component: "widget.retry",
|
|
614
|
+
props: {
|
|
615
|
+
type: "button",
|
|
616
|
+
onClick: p
|
|
617
|
+
},
|
|
618
|
+
children: "Try again"
|
|
619
|
+
})]
|
|
620
|
+
}) : f ? /* @__PURE__ */ g(t, {
|
|
621
|
+
component: "widget.message",
|
|
622
|
+
children: f === !0 ? "Nothing to show yet." : f
|
|
623
|
+
}) : r, O = i !== void 0 || o !== void 0 || s !== void 0 || p !== void 0 || T;
|
|
624
|
+
return /* @__PURE__ */ _(t, {
|
|
625
|
+
component: "widget",
|
|
626
|
+
...v,
|
|
627
|
+
variant: [v.variant, {
|
|
628
|
+
dragging: C?.pointer !== void 0,
|
|
629
|
+
grabbed: C !== void 0 && C.pointer === void 0
|
|
630
|
+
}],
|
|
631
|
+
order: b?.order,
|
|
632
|
+
cq: b?.query,
|
|
633
|
+
...b?.placement,
|
|
634
|
+
style: {
|
|
635
|
+
...n === void 0 ? void 0 : y?.offsetOf(n),
|
|
636
|
+
...v.style
|
|
637
|
+
},
|
|
638
|
+
props: {
|
|
639
|
+
role: b ? "listitem" : void 0,
|
|
640
|
+
"aria-busy": l || void 0,
|
|
641
|
+
"data-widget-id": n,
|
|
642
|
+
...h
|
|
643
|
+
},
|
|
644
|
+
children: [
|
|
645
|
+
O && /* @__PURE__ */ _(t, {
|
|
646
|
+
component: "widget.header",
|
|
647
|
+
children: [
|
|
648
|
+
E("move"),
|
|
649
|
+
/* @__PURE__ */ _(t, {
|
|
650
|
+
component: "widget.label",
|
|
651
|
+
children: [i !== void 0 && /* @__PURE__ */ g(t, {
|
|
652
|
+
component: "widget.title",
|
|
653
|
+
tag: x[c - 1],
|
|
654
|
+
children: i
|
|
655
|
+
}), o !== void 0 && /* @__PURE__ */ g(t, {
|
|
656
|
+
component: "widget.description",
|
|
657
|
+
children: o
|
|
658
|
+
})]
|
|
659
|
+
}),
|
|
660
|
+
p && /* @__PURE__ */ g(t, {
|
|
661
|
+
component: "widget.handle",
|
|
662
|
+
tag: "button",
|
|
663
|
+
variant: { editable: !0 },
|
|
664
|
+
props: {
|
|
665
|
+
type: "button",
|
|
666
|
+
"aria-label": m ?? `Refresh ${w}`,
|
|
667
|
+
onClick: p
|
|
668
|
+
},
|
|
669
|
+
children: /* @__PURE__ */ g(M, {})
|
|
670
|
+
}),
|
|
671
|
+
s !== void 0 && /* @__PURE__ */ g(t, {
|
|
672
|
+
component: "widget.actions",
|
|
673
|
+
children: s
|
|
674
|
+
})
|
|
675
|
+
]
|
|
676
|
+
}),
|
|
677
|
+
/* @__PURE__ */ g(t, {
|
|
678
|
+
component: "widget.body",
|
|
679
|
+
children: D()
|
|
680
|
+
}),
|
|
681
|
+
E("resize")
|
|
682
|
+
]
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
var P = A;
|
|
686
|
+
P.displayName = "DashboardGrid";
|
|
687
|
+
var F = N;
|
|
688
|
+
F.displayName = "Widget";
|
|
689
|
+
//#endregion
|
|
690
|
+
export { y as DashboardUtils, F as Widget, P as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { default as GridModel } from '../models/gridModel';
|
|
2
|
+
import { ScrollPosition } from '../models/viewportModel';
|
|
2
3
|
interface Props<TRow> {
|
|
3
4
|
grid: GridModel<TRow>;
|
|
4
|
-
|
|
5
|
+
scroll: ScrollPosition;
|
|
5
6
|
}
|
|
6
7
|
export default function DataGridBody<TRow>(props: Props<TRow>): import("react").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -3,6 +3,17 @@ interface Props<TRow> {
|
|
|
3
3
|
row: DetailRowModel<TRow>;
|
|
4
4
|
/** Position in the whole row list, not in the rendered window. */
|
|
5
5
|
index: number;
|
|
6
|
+
/**
|
|
7
|
+
* The grid's store version. Not read: it is what tells the memo below that something the row draws
|
|
8
|
+
* from the model has moved, since every other prop it takes holds still while the window slides.
|
|
9
|
+
*/
|
|
10
|
+
version: number;
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
declare function DataGridDetailRowImpl<TRow>(props: Props<TRow>): import("react").JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Memoized on its props, which is what makes a scroll cost one row rather than a window of them: the
|
|
15
|
+
* rows either side of the new one are handed the same model and the same index, so they bail out.
|
|
16
|
+
* `memo` loses the type parameter, and the cast is what hands it back.
|
|
17
|
+
*/
|
|
18
|
+
declare const DataGridDetailRow: typeof DataGridDetailRowImpl;
|
|
19
|
+
export default DataGridDetailRow;
|