@box-kite/react 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.claude/rules/box-kite-rules.md +8 -0
  2. package/.claude/skills/box-kite/SKILL.md +8 -0
  3. package/.claude/skills/box-kite/references/components.md +49 -3
  4. package/.cursor/rules/box-kite.mdc +8 -0
  5. package/AGENTS.md +8 -0
  6. package/BOX_AI_CONTEXT.md +276 -20
  7. package/BOX_KITE_AI_CONTEXT.md +276 -20
  8. package/behavior.cjs +1 -1
  9. package/behavior.mjs +57 -57
  10. package/box.cjs +1 -1
  11. package/box.d.ts +5 -0
  12. package/box.mjs +17 -17
  13. package/catalog.cjs +1 -1
  14. package/catalog.mjs +385 -0
  15. package/client.cjs +1 -1
  16. package/client.mjs +113 -87
  17. package/components/dashboard.cjs +1 -1
  18. package/components/dashboard.mjs +1 -1
  19. package/components/dataGrid/components/dataGridList.d.ts +12 -0
  20. package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
  21. package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
  22. package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
  23. package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
  24. package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
  25. package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
  26. package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
  27. package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
  28. package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
  29. package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
  30. package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
  31. package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
  32. package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
  33. package/components/dataGrid/contracts/dataGridContract.d.ts +32 -0
  34. package/components/dataGrid/models/gridModel.d.ts +3 -0
  35. package/components/dataGrid/models/listModel.d.ts +129 -0
  36. package/components/dataGrid/models/localeText.d.ts +32 -0
  37. package/components/dataGrid/models/viewportModel.d.ts +0 -2
  38. package/components/dataGrid/useListLayout.d.ts +13 -0
  39. package/components/dataGrid.cjs +3 -3
  40. package/components/dataGrid.mjs +1052 -788
  41. package/components/dialog.cjs +1 -1
  42. package/components/dialog.mjs +85 -97
  43. package/components/list/listItemParts.d.ts +9 -0
  44. package/components/list.cjs +1 -0
  45. package/components/list.d.ts +118 -0
  46. package/components/list.mjs +391 -0
  47. package/components/menu.cjs +1 -1
  48. package/components/menu.mjs +25 -25
  49. package/components/overlay.cjs +1 -1
  50. package/components/overlay.mjs +12 -12
  51. package/components/semantics.d.ts +29 -29
  52. package/components/slider.cjs +1 -1
  53. package/components/slider.mjs +1 -1
  54. package/components/sortableList.cjs +1 -0
  55. package/components/sortableList.d.ts +49 -0
  56. package/components/sortableList.mjs +384 -0
  57. package/components/swipeItem.cjs +1 -0
  58. package/components/swipeItem.d.ts +52 -0
  59. package/components/swipeItem.mjs +321 -0
  60. package/components/tabs.cjs +1 -1
  61. package/components/tabs.mjs +1 -1
  62. package/components/toaster.cjs +1 -1
  63. package/components/toaster.mjs +24 -24
  64. package/components/virtualList.cjs +1 -0
  65. package/components/virtualList.d.ts +32 -0
  66. package/components/virtualList.mjs +188 -0
  67. package/dataGridList.cjs +1 -0
  68. package/dataGridList.mjs +1351 -0
  69. package/docs/components.md +5 -1
  70. package/icons/closeIcon.d.ts +2 -0
  71. package/icons/filterIcon.d.ts +2 -0
  72. package/layer.cjs +1 -1
  73. package/layer.mjs +1 -1
  74. package/mcp/src/data.d.ts +2 -0
  75. package/package.json +86 -22
  76. package/placement.cjs +1 -1
  77. package/placement.mjs +10 -10
  78. package/platform.cjs +1 -1
  79. package/platform.mjs +4 -1
  80. package/react/a11y/useControllableState.d.ts +2 -1
  81. package/react/componentsContext.d.ts +4 -0
  82. package/react/componentsProvider.d.ts +10 -0
  83. package/react/resolveStyles.d.ts +2 -1
  84. package/react/theme/theme.d.ts +6 -1
  85. package/react-shared.cjs +1 -1
  86. package/react-shared.mjs +5 -5
  87. package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
  88. package/registry/designs/store/address-form.d.ts +11 -0
  89. package/registry/designs/store/cart-items.d.ts +10 -0
  90. package/registry/designs/store/cart-page.d.ts +4 -0
  91. package/registry/designs/store/checkout-page.d.ts +7 -0
  92. package/registry/designs/store/credit-card-form.d.ts +10 -0
  93. package/registry/designs/store/form-field.d.ts +19 -0
  94. package/registry/designs/store/order-summary.d.ts +18 -0
  95. package/registry/designs/store/product-art.d.ts +26 -0
  96. package/registry/designs/store/product-card.d.ts +11 -0
  97. package/registry/designs/store/product-gallery.d.ts +11 -0
  98. package/registry/designs/store/product-grid.d.ts +10 -0
  99. package/registry/designs/store/product-page.d.ts +5 -0
  100. package/registry/designs/store/quantity-stepper.d.ts +13 -0
  101. package/registry/designs/store/shipping-method.d.ts +14 -0
  102. package/registry/designs/store/store-data.d.ts +53 -0
  103. package/registry/designs/store/store-design.d.ts +63 -0
  104. package/registry/designs/store/store-shell.d.ts +12 -0
  105. package/registry/designs/store/storefront-page.d.ts +4 -0
  106. package/registry/designs/store/variant-picker.d.ts +15 -0
  107. package/rsc.cjs +1 -1
  108. package/rsc.d.ts +2 -0
  109. package/rsc.mjs +1 -1
  110. package/scrolling.cjs +1 -0
  111. package/scrolling.mjs +22 -0
  112. package/ssg.cjs +1 -1
  113. package/ssg.mjs +1 -1
  114. package/utils/scroll/scrollUtils.d.ts +6 -0
  115. package/utils/sortable/sortableUtils.d.ts +25 -0
  116. package/utils/swipe/swipeUtils.d.ts +53 -0
  117. package/utils/virtual/measuredWindow.d.ts +28 -0
  118. package/utils/virtual/rowSearch.d.ts +11 -0
package/client.mjs CHANGED
@@ -1,27 +1,45 @@
1
1
  import { l as e, u as t } from "./react-shared.mjs";
2
- import { l as n, t as r } from "./platform.mjs";
3
- import { t as i } from "./effects.mjs";
4
- import a from "./box.mjs";
5
- import o, { useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
6
- import { applyThemeToElement as m, clearStoredTheme as h, defaultThemeName as g, documentRoot as _, getDefaultEngine as v, getSystemTheme as y, pauseTransitions as b, prepareReveal as x, readStoredTheme as S, transitionTheme as C, watchSystemTheme as w, writeStoredTheme as T } from "@box-kite/core";
7
- import { flushSync as E } from "react-dom";
8
- import { jsx as D, jsxs as O } from "react/jsx-runtime";
2
+ import { n, t as r, u as i } from "./platform.mjs";
3
+ import { n as a, t as o } from "./effects.mjs";
4
+ import s from "./box.mjs";
5
+ import c, { useCallback as l, useContext as u, useEffect as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
6
+ import { applyThemeToElement as g, clearStoredTheme as _, defaultThemeName as v, documentRoot as y, getDefaultEngine as b, getSystemTheme as x, pauseTransitions as S, prepareReveal as C, readStoredTheme as w, transitionTheme as T, watchSystemTheme as E, writeStoredTheme as D } from "@box-kite/core";
7
+ import { jsx as O, jsxs as k } from "react/jsx-runtime";
8
+ import { flushSync as A } from "react-dom";
9
+ //#region src/react/clientRuntime.ts
10
+ var j = "[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19";
11
+ function M(e) {
12
+ if (typeof e.createContext != "function") throw Error(j);
13
+ }
14
+ //#endregion
15
+ //#region src/react/componentsContext.ts
16
+ M(c);
17
+ var N = c.createContext(void 0);
18
+ //#endregion
19
+ //#region src/react/componentsProvider.tsx
20
+ function P({ value: e, children: t }) {
21
+ return /* @__PURE__ */ O(N.Provider, {
22
+ value: e,
23
+ children: t
24
+ });
25
+ }
26
+ //#endregion
9
27
  //#region src/react/hooks/useVisibility.ts
10
- function k(e) {
11
- let { node: t = null, event: r = "click", hideOnScroll: i = !1, hideOnResize: a = !1, hideOnEscape: o = !0 } = e ?? {}, [s, c] = p(!1), u = f(null);
12
- return l(() => {
28
+ function F(e) {
29
+ let { node: t = null, event: n = "click", hideOnScroll: r = !1, hideOnResize: a = !1, hideOnEscape: o = !0 } = e ?? {}, [s, c] = h(!1), l = m(null);
30
+ return d(() => {
13
31
  function e(e) {
14
- let r = t ?? u.current;
15
- r && !n(e, [r]) && c(!1);
32
+ let n = t ?? l.current;
33
+ n && !i(e, [n]) && c(!1);
16
34
  }
17
- function l() {
35
+ function u() {
18
36
  c(!1);
19
37
  }
20
38
  function d(e) {
21
39
  e.key === "Escape" && c(!1);
22
40
  }
23
41
  let f = new AbortController();
24
- return s && (window.addEventListener(r, e, f), o && window.addEventListener("keydown", d, f), a && window.addEventListener("resize", l, f), i && window.addEventListener("scroll", e, {
42
+ return s && (window.addEventListener(n, e, f), o && window.addEventListener("keydown", d, f), a && window.addEventListener("resize", u, f), r && window.addEventListener("scroll", e, {
25
43
  signal: f.signal,
26
44
  capture: !0
27
45
  })), () => {
@@ -30,146 +48,142 @@ function k(e) {
30
48
  }, [
31
49
  t,
32
50
  s,
33
- r,
51
+ n,
34
52
  o,
35
53
  a,
36
- i
54
+ r
37
55
  ]), [
38
56
  s,
39
57
  c,
40
- u
58
+ l
41
59
  ];
42
60
  }
43
61
  //#endregion
44
62
  //#region src/react/useStyles.ts
45
- var A = i;
46
- function j(t, n) {
47
- let { classNames: r, signature: i, styleElements: a } = e(t, n);
48
- return A(() => {
49
- v().flushSync();
63
+ var I = o;
64
+ function L(t, n) {
65
+ let { classNames: r, signature: i, styleElements: a } = e(t, n, u(N));
66
+ return I(() => {
67
+ b().flushSync();
50
68
  }, [i ?? t]), {
51
69
  classNames: r,
52
70
  styleElements: a
53
71
  };
54
72
  }
55
- function M(e, n) {
56
- let r = e ? v().addGlobalStyles(e, n) : void 0;
57
- return A(() => {
58
- v().flushSync();
73
+ function R(e, n) {
74
+ let r = e ? b().addGlobalStyles(e, n) : void 0;
75
+ return I(() => {
76
+ b().flushSync();
59
77
  }, [e, n]), t(r);
60
78
  }
61
- var N;
79
+ var z;
80
+ //#endregion
81
+ //#region src/react/theme/themeContext.ts
62
82
  (function(e) {
63
83
  function t() {
64
- v().flushSync();
84
+ b().flushSync();
65
85
  }
66
86
  e.flushSync = t;
67
87
  function n() {
68
- v().clear();
88
+ b().clear();
69
89
  }
70
90
  e.clear = n;
71
91
  function r() {
72
- return v().getStyles();
92
+ return b().getStyles();
73
93
  }
74
94
  e.getStyles = r;
75
95
  function i() {
76
- return v().getStyleTag();
96
+ return b().getStyleTag();
77
97
  }
78
98
  e.getStyleTag = i;
79
99
  function a() {
80
- return v().styleElementId;
100
+ return b().styleElementId;
81
101
  }
82
102
  e.styleElementId = a;
83
103
  function o(e) {
84
- v().configure(e);
104
+ b().configure(e);
85
105
  }
86
106
  e.configure = o;
87
- })(N ||= {});
88
- //#endregion
89
- //#region src/react/clientRuntime.ts
90
- var P = "[box-kite] The client build was loaded into a React Server Component graph, where React has no createContext. Import '@box-kite/react' by its package name — the react-server condition resolves it to a Box that renders on the server — and import the components that hold state (Dropdown, Tooltip, DataGrid, Checkbox, Select, Form) from a 'use client' module. See https://github.com/box-kite/box-kite#react-server-components-react-19";
91
- function F(e) {
92
- if (typeof e.createContext != "function") throw Error(P);
93
- }
94
- //#endregion
95
- //#region src/react/theme/themeContext.ts
96
- F(o);
97
- var I = o.createContext({
107
+ })(z ||= {}), M(c);
108
+ var B = c.createContext({
98
109
  theme: "",
99
110
  setTheme: () => {}
100
111
  });
101
112
  //#endregion
102
113
  //#region src/react/theme/theme.tsx
103
- function L(e) {
104
- let { children: t, theme: n, use: r = "local", storageKey: o, globalStyles: c, viewTransition: d } = e, v = M(r === "global" ? c : void 0, "html"), [k, A] = p(n ?? g), [j, N] = p(n !== void 0), P = f(null), F = f(k), L = f(null), R = f(void 0), z = s((e) => {
114
+ function V(e) {
115
+ let { theme: t, use: n = "local", storageKey: r, globalStyles: i, viewTransition: a, components: c } = e, u = c ? /* @__PURE__ */ O(P, {
116
+ value: c,
117
+ children: e.children
118
+ }) : e.children, p = R(n === "global" ? i : void 0, "html"), [b, j] = h(t ?? v), [M, N] = h(t !== void 0), F = m(null), I = m(b), L = m(null), z = m(void 0), V = l((e) => {
105
119
  let t = () => {
106
- e === null ? (o && h(o), N(!1)) : (o && T(o, e), A(e), N(!0));
120
+ e === null ? (r && _(r), N(!1)) : (r && D(r, e), j(e), N(!0));
107
121
  };
108
- if (d) {
109
- let e = C(() => E(t), d === "reveal" ? "reveal" : "fade");
110
- R.current = e.finished, e.finished.then(() => R.current = void 0, () => R.current = void 0);
122
+ if (a) {
123
+ let e = T(() => A(t), a === "reveal" ? "reveal" : "fade");
124
+ z.current = e.finished, e.finished.then(() => z.current = void 0, () => z.current = void 0);
111
125
  } else t();
112
- }, [o, d]), B = d === "reveal";
113
- l(() => B ? x() : void 0, [B]);
114
- let [V, H] = p(n);
115
- return n !== V && (H(n), n === void 0 ? N(!1) : (A(n), N(!0))), u(() => {
116
- if (j) return;
117
- let e = o ? S(o) : null, t = e ?? y();
118
- if (t !== F.current && (P.current = t), A(t), e) {
126
+ }, [r, a]), H = a === "reveal";
127
+ d(() => H ? C() : void 0, [H]);
128
+ let [U, W] = h(t);
129
+ return t !== U && (W(t), t === void 0 ? N(!1) : (j(t), N(!0))), f(() => {
130
+ if (M) return;
131
+ let e = r ? w(r) : null, t = e ?? x();
132
+ if (t !== I.current && (F.current = t), j(t), e) {
119
133
  N(!0);
120
134
  return;
121
135
  }
122
- return w(A);
123
- }, [j, o]), i(() => {
124
- k !== F.current && (L.current ??= b());
125
- }, [k]), u(() => {
126
- if (F.current = k, P.current !== null && P.current !== k) return;
127
- P.current = null;
136
+ return E(j);
137
+ }, [M, r]), o(() => {
138
+ b !== I.current && (L.current ??= S());
139
+ }, [b]), f(() => {
140
+ if (I.current = b, F.current !== null && F.current !== b) return;
141
+ F.current = null;
128
142
  let e = L.current;
129
143
  L.current = null;
130
- let t = r === "global" ? _() : null, n = t ? m(t, k) : void 0;
131
- return e?.(R.current), n;
132
- }, [k, r]), r === "local" ? /* @__PURE__ */ O(I.Provider, {
144
+ let t = n === "global" ? y() : null, r = t ? g(t, b) : void 0;
145
+ return e?.(z.current), r;
146
+ }, [b, n]), n === "local" ? /* @__PURE__ */ k(B.Provider, {
133
147
  value: {
134
- theme: k,
135
- setTheme: z
148
+ theme: b,
149
+ setTheme: V
136
150
  },
137
- children: [v, /* @__PURE__ */ D(a, {
138
- className: k,
139
- props: { "data-theme": k },
140
- children: t
151
+ children: [p, /* @__PURE__ */ O(s, {
152
+ className: b,
153
+ props: { "data-theme": b },
154
+ children: u
141
155
  })]
142
- }) : /* @__PURE__ */ O(I.Provider, {
156
+ }) : /* @__PURE__ */ k(B.Provider, {
143
157
  value: {
144
- theme: k,
145
- setTheme: z
158
+ theme: b,
159
+ setTheme: V
146
160
  },
147
- children: [v, t]
161
+ children: [p, u]
148
162
  });
149
163
  }
150
164
  (function(e) {
151
165
  function t() {
152
- let { theme: e, setTheme: t } = c(I);
166
+ let { theme: e, setTheme: t } = u(B);
153
167
  return [e, t];
154
168
  }
155
169
  e.useTheme = t;
156
- })(L ||= {});
157
- var R = L, z = /* @__PURE__ */ new WeakMap();
158
- function B(e) {
159
- let t = z.get(e);
160
- return t || (t = /* @__PURE__ */ new Map(), z.set(e, t)), t;
170
+ })(V ||= {});
171
+ var H = V, U = /* @__PURE__ */ new WeakMap();
172
+ function W(e) {
173
+ let t = U.get(e);
174
+ return t || (t = /* @__PURE__ */ new Map(), U.set(e, t)), t;
161
175
  }
162
- function V(e = !0) {
163
- let [t] = R.useTheme(), n = d(() => {
176
+ function G(e = !0) {
177
+ let [t] = H.useTheme(), n = p(() => {
164
178
  if (!e) return null;
165
179
  let t = r();
166
180
  if (!t) return null;
167
181
  let n = "box-kite-portal", i = t.getElementById(n);
168
182
  return i || (i = document.createElement("div"), i.id = n, document.body.appendChild(i)), i;
169
183
  }, [e]);
170
- return u(() => {
184
+ return f(() => {
171
185
  if (!t || !n) return;
172
- let e = B(n), r = e.get(t) ?? 0;
186
+ let e = W(n), r = e.get(t) ?? 0;
173
187
  return e.set(t, r + 1), r === 0 && n.classList.add(t), () => {
174
188
  let r = (e.get(t) ?? 1) - 1;
175
189
  r <= 0 ? (e.delete(t), n.classList.remove(t)) : e.set(t, r);
@@ -177,4 +191,16 @@ function V(e = !0) {
177
191
  }, [n, t]), n;
178
192
  }
179
193
  //#endregion
180
- export { k as a, j as i, R as n, N as r, V as t };
194
+ //#region src/react/dialog/useScrollLock.ts
195
+ var K = 0;
196
+ function q(e) {
197
+ let { classNames: t, styleElements: r } = L({ overflow: "hidden" }, !1), i = t.slice(1).join(" ");
198
+ return a(() => {
199
+ let t = n();
200
+ if (!(!e || !t || !i)) return K += 1, t.classList.add(i), () => {
201
+ --K, K === 0 && t.classList.remove(i);
202
+ };
203
+ }, [e, i]), r;
204
+ }
205
+ //#endregion
206
+ export { L as a, z as i, G as n, F as o, H as r, P as s, q as t };
@@ -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;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { u as e } from "../platform.mjs";
2
+ import { d as e } from "../platform.mjs";
3
3
  import t from "../box.mjs";
4
4
  import { a as n, i as r, o as i } from "../behavior.mjs";
5
5
  import { t as a } from "../dashboardSchema.mjs";
@@ -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 {};
@@ -0,0 +1,13 @@
1
+ import { default as GroupRowModel } from '../models/groupRowModel';
2
+ interface Props<TRow> {
3
+ row: GroupRowModel<TRow>;
4
+ /** The row's version (`GridModel.rowVersion`). Not read: it is what tells the memo the row moved. */
5
+ version: string;
6
+ }
7
+ /**
8
+ * A group as a section header: the value, how many rows it holds, and their totals underneath. The toggle is
9
+ * the item's `List.Action`, so the whole header opens and closes the group.
10
+ */
11
+ declare function DataGridListGroupImpl<TRow>(props: Props<TRow>): import("react").JSX.Element;
12
+ declare const DataGridListGroup: typeof DataGridListGroupImpl;
13
+ export default DataGridListGroup;
@@ -0,0 +1,21 @@
1
+ import { default as RowModel } from '../models/rowModel';
2
+ interface Props<TRow> {
3
+ row: RowModel<TRow>;
4
+ /** Where the row sits in the grid's rows — what the record view opens at. */
5
+ index: number;
6
+ /** `aria-posinset`/`aria-setsize`: where the item is in the whole list, not in the part drawn. */
7
+ position?: number;
8
+ setSize?: number;
9
+ /** The row's version (`GridModel.rowVersion`). Not read: it is what tells the memo the row moved. */
10
+ version: string;
11
+ }
12
+ /**
13
+ * One row as a `List.Item`: a kicker, the title with one value opposite it, a subtitle, and a few labelled
14
+ * fields — the slots `ListModel.layout` hands out. The title is the item's `List.Action`: it opens the record
15
+ * view, and while the list is selecting it is the label of the row's checkbox, so a press anywhere on the
16
+ * item ticks it.
17
+ */
18
+ declare function DataGridListItemImpl<TRow>(props: Props<TRow>): import("react").JSX.Element;
19
+ /** Memoized on its props, so one row's selection or expansion redraws that item and not the list. */
20
+ declare const DataGridListItem: typeof DataGridListItemImpl;
21
+ export default DataGridListItem;
@@ -0,0 +1,20 @@
1
+ import { BoxStyles } from '../../../types';
2
+ /**
3
+ * The list layout's geometry, shared between its parts. The paint — colours, borders, states — is the
4
+ * `datagrid.list` style tree, which every engine entry carries; this is only ever in the DataGrid's chunk.
5
+ */
6
+ declare namespace DataGridListLayout {
7
+ /** A square control a thumb can hit: 44px, the Apple and WCAG target. */
8
+ const ICON_BUTTON: BoxStyles;
9
+ /** A pill in the toolbar: Sort, Filters, Select. */
10
+ const PILL: BoxStyles;
11
+ /** One line of text that ends in an ellipsis rather than a second line. */
12
+ const TRUNCATE: BoxStyles;
13
+ /** A full-width field in a sheet: 44px tall, and 16px type so a phone does not zoom in on focus. */
14
+ const INPUT: BoxStyles;
15
+ /** A labelled value: the label small and muted over the value. */
16
+ const LABEL: BoxStyles;
17
+ /** The sheet's big buttons, at the bottom where a thumb is. */
18
+ const SHEET_BUTTON: BoxStyles;
19
+ }
20
+ export default DataGridListLayout;
@@ -0,0 +1,11 @@
1
+ import { default as GridModel } from '../models/gridModel';
2
+ interface Props<TRow> {
3
+ grid: GridModel<TRow>;
4
+ }
5
+ /**
6
+ * One row at a time: every column of it, a label over each value, in a sheet with a pager — the drill-in a
7
+ * list item leads to. The pager follows the list's own order and filters, Left/Right and a sideways swipe
8
+ * step it, and an editable column is edited here, through the same `def.onCellEdit` a table cell goes through.
9
+ */
10
+ export default function DataGridListRecord<TRow>(props: Props<TRow>): import("react").JSX.Element;
11
+ 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 selection, pinned to the bottom of the screen while there is one: how many rows are ticked and the two
7
+ * ways to change that in bulk. At the bottom because that is where a thumb is, and where a phone's own
8
+ * contextual bars put what a selection is for.
9
+ */
10
+ export default function DataGridListSelectionBar<TRow>(props: Props<TRow>): import("react").JSX.Element | null;
11
+ export {};
@@ -0,0 +1,30 @@
1
+ import { DialogTrigger } from '../../dialog';
2
+ import { default as GridModel } from '../models/gridModel';
3
+ interface Props<TRow> {
4
+ grid: GridModel<TRow>;
5
+ open: boolean;
6
+ /** The trigger was pressed. */
7
+ onOpen?: () => void;
8
+ onClose: () => void;
9
+ title: React.ReactNode;
10
+ /** The button that opens it, so focus goes back there when it closes. */
11
+ trigger?: (trigger: DialogTrigger) => React.ReactNode;
12
+ /** Controls in the header between the title and the close button — the record view's pager. */
13
+ actions?: React.ReactNode;
14
+ footer?: React.ReactNode;
15
+ /** The record view: as tall as a long row needs. */
16
+ tall?: boolean;
17
+ /** Handlers for the scrolling body — the record view's swipe. */
18
+ bodyProps?: React.HTMLAttributes<HTMLDivElement>;
19
+ bodyRef?: React.Ref<HTMLDivElement>;
20
+ /** Keys anywhere in the sheet — the record view's pager. */
21
+ onKeyDown?: (event: React.KeyboardEvent) => void;
22
+ children: React.ReactNode;
23
+ }
24
+ /**
25
+ * A bottom sheet: a modal `<dialog>` docked to the bottom edge, which brings the top layer, the backdrop,
26
+ * Escape, focus containment and focus return with it. The header is a handle — pulled down far enough, the
27
+ * sheet closes, the way a sheet on a phone does.
28
+ */
29
+ export default function DataGridListSheet<TRow>(props: Props<TRow>): import("react").JSX.Element;
30
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as GridModel } from '../models/gridModel';
2
+ interface Props<TRow> {
3
+ grid: GridModel<TRow>;
4
+ }
5
+ /**
6
+ * The Sort button and the sheet it opens. A list has no headers to press, so the sort is a choice of column
7
+ * and a choice of direction — two radio groups, applied as they are picked, since a sort is one decision.
8
+ */
9
+ export default function DataGridListSortSheet<TRow>(props: Props<TRow>): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as GridModel } from '../models/gridModel';
2
+ interface Props<TRow> {
3
+ grid: GridModel<TRow>;
4
+ }
5
+ /**
6
+ * The list's toolbar: the title and how many rows there are, the search, and a row of pills — Sort, Filters,
7
+ * Select — followed by one chip per filter in force, each removable on its own.
8
+ */
9
+ export default function DataGridListToolbar<TRow>(props: Props<TRow>): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,12 @@
1
+ import { default as ColumnModel } from '../models/columnModel';
2
+ import { default as RowModel } from '../models/rowModel';
3
+ interface Props<TRow> {
4
+ row: RowModel<TRow>;
5
+ column: ColumnModel<TRow>;
6
+ }
7
+ /**
8
+ * One value of a row, drawn the way its column draws it in the table: through the column's own `Cell` where
9
+ * there is one — a badge, a sparkline, a link — so a list item and a table row never disagree.
10
+ */
11
+ export default function DataGridListValue<TRow>(props: Props<TRow>): import("react").JSX.Element | null;
12
+ export {};
@@ -466,6 +466,25 @@ export interface DataGridHandle {
466
466
  */
467
467
  clearEdits(): void;
468
468
  }
469
+ /**
470
+ * Where a column goes in a list item, when the grid draws itself as a list. `title` is the item's name,
471
+ * `kicker` a small line above it (an id, a date), `subtitle` a line under it, `end` the one value opposite
472
+ * the title (a total, a status), `field` a labelled value, `detail` only the record view, `hidden` nowhere.
473
+ */
474
+ export type ListRole = 'title' | 'kicker' | 'subtitle' | 'end' | 'field' | 'detail' | 'hidden';
475
+ /** How the grid draws itself: a table, a list, or whichever its own width suits. */
476
+ export type DataGridLayout = 'auto' | 'table' | 'list';
477
+ /** The list layout's settings. */
478
+ export interface ListConfig {
479
+ /** The grid's own width, in px, below which `layout: 'auto'` draws a list. Default: 576 (36rem). */
480
+ breakpoint?: number;
481
+ /** How many `field`s an item shows before the rest wait for the record view. Default: 4. */
482
+ fields?: number;
483
+ /** How many items one "Show more" adds. Default: 20. A paginated grid draws its page instead. */
484
+ batchSize?: number;
485
+ /** Whether pressing an item opens the record view, every column of one row with a pager. Default: true. */
486
+ recordView?: boolean;
487
+ }
469
488
  export interface ColumnType<TRow> {
470
489
  key: Key;
471
490
  header?: string;
@@ -522,6 +541,11 @@ export interface ColumnType<TRow> {
522
541
  flexible?: boolean;
523
542
  /** Control the header context menu. false hides it entirely. Object controls individual sections. Inherits from GridDefinition.contextMenu if undefined. */
524
543
  contextMenu?: boolean | ContextMenuConfig;
544
+ /**
545
+ * Where this column goes in a list item. Default: the first column is the title, the first end-aligned one
546
+ * sits opposite it, the next `def.list.fields` are fields and the rest wait for the record view.
547
+ */
548
+ list?: ListRole;
525
549
  }
526
550
  export interface GridDefinition<TRow> {
527
551
  rowKey?: KeysMatching<TRow, Key> | ((rowData: TRow) => Key);
@@ -553,6 +577,14 @@ export interface GridDefinition<TRow> {
553
577
  */
554
578
  rangeSelection?: boolean;
555
579
  rowHeight?: number;
580
+ /**
581
+ * How the grid draws itself. `'auto'` (default) is a table, and a list once the grid itself is narrower
582
+ * than `def.list.breakpoint` — its own width rather than the viewport's, so a grid in a narrow column of
583
+ * a wide page reads as a list too. `'table'` and `'list'` choose one for good.
584
+ */
585
+ layout?: DataGridLayout;
586
+ /** The list layout's settings: the breakpoint, how many fields an item shows, the record view. */
587
+ list?: ListConfig;
556
588
  /** Number of visible rows. Set to 'all' to render all rows without virtualization or vertical scrollbar. */
557
589
  visibleRowsCount?: number | 'all';
558
590
  topBar?: boolean;