@lablup/ui-common 0.2.0-alpha.16 → 0.2.0-alpha.18

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 (105) hide show
  1. package/README.md +1 -0
  2. package/astryx/components/Board.doc.mjs +122 -0
  3. package/astryx/components/Board.tsx +3 -0
  4. package/astryx/docs/ui-common.doc.mjs +1 -1
  5. package/dist/assets/components/Board/Board.css +2 -0
  6. package/dist/components/Board/Board.d.ts +102 -0
  7. package/dist/components/Board/Board.messages.d.ts +62 -0
  8. package/dist/components/Board/Board.messages.js +68 -0
  9. package/dist/components/Board/Board.messages.js.map +1 -0
  10. package/dist/components/Board/Board2.js +607 -0
  11. package/dist/components/Board/Board2.js.map +1 -0
  12. package/dist/components/Board/engine.d.ts +60 -0
  13. package/dist/components/Board/engine.js +397 -0
  14. package/dist/components/Board/engine.js.map +1 -0
  15. package/dist/components/Board/index.d.ts +4 -0
  16. package/dist/components/Board/index.js +3 -0
  17. package/dist/components/Board/layout.d.ts +81 -0
  18. package/dist/components/Board/layout.js +67 -0
  19. package/dist/components/Board/layout.js.map +1 -0
  20. package/dist/components/Board/scroll.d.ts +38 -0
  21. package/dist/components/Board/scroll.js +42 -0
  22. package/dist/components/Board/scroll.js.map +1 -0
  23. package/dist/components/DataGrid/DataGrid2.js +128 -128
  24. package/dist/components/DataGrid/DataGrid2.js.map +1 -1
  25. package/dist/components/Form/FormItem.d.ts +1 -1
  26. package/dist/components/Modal/modalStack.d.ts +9 -8
  27. package/dist/components/Modal/modalStack.js +29 -26
  28. package/dist/components/Modal/modalStack.js.map +1 -1
  29. package/dist/components/PageHeader/PageHeader2.js +4 -4
  30. package/dist/components/PagedSelector/PagedSelector2.js +37 -37
  31. package/dist/components/PagedSelector/PagedSelector2.js.map +1 -1
  32. package/dist/components/SelectionLabel/SelectionLabel.js +4 -4
  33. package/dist/forks/Drawer/Drawer.js +71 -53
  34. package/dist/forks/Drawer/Drawer.js.map +1 -1
  35. package/dist/forks/Drawer/useDrawerDialogPresence.d.ts +6 -6
  36. package/dist/forks/Drawer/useDrawerDialogPresence.js +19 -31
  37. package/dist/forks/Drawer/useDrawerDialogPresence.js.map +1 -1
  38. package/dist/i18n/catalog.js +27 -25
  39. package/dist/i18n/catalog.js.map +1 -1
  40. package/dist/i18n/locales/de-DE.js +60 -0
  41. package/dist/i18n/locales/de-DE.js.map +1 -1
  42. package/dist/i18n/locales/el-GR.js +60 -0
  43. package/dist/i18n/locales/el-GR.js.map +1 -1
  44. package/dist/i18n/locales/es-ES.js +60 -0
  45. package/dist/i18n/locales/es-ES.js.map +1 -1
  46. package/dist/i18n/locales/fi-FI.js +60 -0
  47. package/dist/i18n/locales/fi-FI.js.map +1 -1
  48. package/dist/i18n/locales/fr-FR.js +60 -0
  49. package/dist/i18n/locales/fr-FR.js.map +1 -1
  50. package/dist/i18n/locales/id-ID.js +60 -0
  51. package/dist/i18n/locales/id-ID.js.map +1 -1
  52. package/dist/i18n/locales/it-IT.js +60 -0
  53. package/dist/i18n/locales/it-IT.js.map +1 -1
  54. package/dist/i18n/locales/ja-JP.js +60 -0
  55. package/dist/i18n/locales/ja-JP.js.map +1 -1
  56. package/dist/i18n/locales/ko-KR.js +60 -0
  57. package/dist/i18n/locales/ko-KR.js.map +1 -1
  58. package/dist/i18n/locales/mn-MN.js +60 -0
  59. package/dist/i18n/locales/mn-MN.js.map +1 -1
  60. package/dist/i18n/locales/ms-MY.js +60 -0
  61. package/dist/i18n/locales/ms-MY.js.map +1 -1
  62. package/dist/i18n/locales/pl-PL.js +60 -0
  63. package/dist/i18n/locales/pl-PL.js.map +1 -1
  64. package/dist/i18n/locales/pt-BR.js +60 -0
  65. package/dist/i18n/locales/pt-BR.js.map +1 -1
  66. package/dist/i18n/locales/pt-PT.js +60 -0
  67. package/dist/i18n/locales/pt-PT.js.map +1 -1
  68. package/dist/i18n/locales/ru-RU.js +60 -0
  69. package/dist/i18n/locales/ru-RU.js.map +1 -1
  70. package/dist/i18n/locales/th-TH.js +60 -0
  71. package/dist/i18n/locales/th-TH.js.map +1 -1
  72. package/dist/i18n/locales/tr-TR.js +60 -0
  73. package/dist/i18n/locales/tr-TR.js.map +1 -1
  74. package/dist/i18n/locales/vi-VN.js +60 -0
  75. package/dist/i18n/locales/vi-VN.js.map +1 -1
  76. package/dist/i18n/locales/zh-CN.js +60 -0
  77. package/dist/i18n/locales/zh-CN.js.map +1 -1
  78. package/dist/i18n/locales/zh-TW.js +60 -0
  79. package/dist/i18n/locales/zh-TW.js.map +1 -1
  80. package/dist/index.d.ts +2 -0
  81. package/dist/index.js +61 -59
  82. package/dist/instance.js +1 -1
  83. package/dist/ui-common-locales/de-DE.json +60 -0
  84. package/dist/ui-common-locales/el-GR.json +60 -0
  85. package/dist/ui-common-locales/en.json +60 -0
  86. package/dist/ui-common-locales/es-ES.json +60 -0
  87. package/dist/ui-common-locales/fi-FI.json +60 -0
  88. package/dist/ui-common-locales/fr-FR.json +60 -0
  89. package/dist/ui-common-locales/id-ID.json +60 -0
  90. package/dist/ui-common-locales/it-IT.json +60 -0
  91. package/dist/ui-common-locales/ja-JP.json +60 -0
  92. package/dist/ui-common-locales/ko-KR.json +60 -0
  93. package/dist/ui-common-locales/mn-MN.json +60 -0
  94. package/dist/ui-common-locales/ms-MY.json +60 -0
  95. package/dist/ui-common-locales/pl-PL.json +60 -0
  96. package/dist/ui-common-locales/pt-BR.json +60 -0
  97. package/dist/ui-common-locales/pt-PT.json +60 -0
  98. package/dist/ui-common-locales/ru-RU.json +60 -0
  99. package/dist/ui-common-locales/th-TH.json +60 -0
  100. package/dist/ui-common-locales/tr-TR.json +60 -0
  101. package/dist/ui-common-locales/vi-VN.json +60 -0
  102. package/dist/ui-common-locales/zh-CN.json +60 -0
  103. package/dist/ui-common-locales/zh-TW.json +60 -0
  104. package/exports.customs.json +1 -0
  105. package/package.json +1 -1
@@ -0,0 +1,607 @@
1
+ import { useUicTranslator as e } from "../../i18n/useUicTranslator.js";
2
+ import { getMinColumnSpan as t, getMinRowSpan as n, interpretItems as r, transformItems as i } from "./layout.js";
3
+ import { LayoutEngine as a, appendPath as o, removeItem as s } from "./engine.js";
4
+ import { autoScrollStep as c, compensateForScroll as l, findScrollParent as u, scrollBounds as d } from "./scroll.js";
5
+ /* empty css */
6
+ import { useEffect as f, useRef as p, useState as m } from "react";
7
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import { IconButton as _ } from "@astryxdesign/core/IconButton";
9
+ import { VisuallyHidden as v } from "@astryxdesign/core/VisuallyHidden";
10
+ //#region src/components/Board/Board.tsx
11
+ var y = [
12
+ {
13
+ minWidth: 0,
14
+ columns: 1
15
+ },
16
+ {
17
+ minWidth: 688,
18
+ columns: 2
19
+ },
20
+ {
21
+ minWidth: 912,
22
+ columns: 4
23
+ },
24
+ {
25
+ minWidth: 2100,
26
+ columns: 6
27
+ }
28
+ ], b = (e) => {
29
+ let t = e?.getBoundingClientRect();
30
+ return {
31
+ x: t?.left ?? 0,
32
+ y: t?.top ?? 0
33
+ };
34
+ }, ee = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n));
35
+ function x(e, t) {
36
+ let n = 0;
37
+ for (let r of [...t].sort((e, t) => e.minWidth - t.minWidth)) r.minWidth <= e && (n = r.columns);
38
+ return n;
39
+ }
40
+ var S = (e, t) => Math.max(0, Math.min(e.right, t.right) - Math.max(e.left, t.left)) * Math.max(0, Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top));
41
+ function te(e, t, n, r) {
42
+ let i = r.cellWidth + r.gap, a = r.cellHeight + r.gap, o = (e, t, n) => Math.abs(t - n) < Math.abs(e - n) ? t : e, s = (e, t) => ({
43
+ left: e * i,
44
+ top: t * a,
45
+ right: e * i + r.cellWidth,
46
+ bottom: t * a + r.cellHeight
47
+ }), c = {
48
+ left: Infinity,
49
+ top: Infinity,
50
+ right: Infinity,
51
+ bottom: Infinity
52
+ };
53
+ for (let r = 0; r < n; r++) for (let n = 0; n < t; n++) {
54
+ let t = s(n, r);
55
+ S(t, e) > 0 && (c = {
56
+ left: o(c.left, t.left, e.left),
57
+ top: o(c.top, t.top, e.top),
58
+ right: o(c.right, t.right, e.right),
59
+ bottom: o(c.bottom, t.bottom, e.bottom)
60
+ });
61
+ }
62
+ let l = null;
63
+ for (let e = 0; e < n; e++) for (let n = 0; n < t; n++) {
64
+ let t = s(n, e);
65
+ if (t.top >= c.top && t.left >= c.left && t.right <= c.right && t.bottom <= c.bottom) if (!l) l = {
66
+ x: n,
67
+ y: e,
68
+ width: 1,
69
+ height: 1
70
+ };
71
+ else {
72
+ let t = Math.min(l.x, n), r = Math.min(l.y, e);
73
+ l = {
74
+ x: t,
75
+ y: r,
76
+ width: Math.max(l.x + l.width, n + 1) - t,
77
+ height: Math.max(l.y + l.height, e + 1) - r
78
+ };
79
+ }
80
+ }
81
+ return l;
82
+ }
83
+ function C() {
84
+ return /* @__PURE__ */ g("svg", {
85
+ width: "1em",
86
+ height: "1em",
87
+ viewBox: "0 0 16 16",
88
+ fill: "currentColor",
89
+ "aria-hidden": "true",
90
+ children: [
91
+ /* @__PURE__ */ h("circle", {
92
+ cx: "6",
93
+ cy: "3",
94
+ r: "1.5"
95
+ }),
96
+ /* @__PURE__ */ h("circle", {
97
+ cx: "10",
98
+ cy: "3",
99
+ r: "1.5"
100
+ }),
101
+ /* @__PURE__ */ h("circle", {
102
+ cx: "6",
103
+ cy: "8",
104
+ r: "1.5"
105
+ }),
106
+ /* @__PURE__ */ h("circle", {
107
+ cx: "10",
108
+ cy: "8",
109
+ r: "1.5"
110
+ }),
111
+ /* @__PURE__ */ h("circle", {
112
+ cx: "6",
113
+ cy: "13",
114
+ r: "1.5"
115
+ }),
116
+ /* @__PURE__ */ h("circle", {
117
+ cx: "10",
118
+ cy: "13",
119
+ r: "1.5"
120
+ })
121
+ ]
122
+ });
123
+ }
124
+ function ne() {
125
+ return /* @__PURE__ */ g("svg", {
126
+ width: "1em",
127
+ height: "1em",
128
+ viewBox: "0 0 16 16",
129
+ fill: "none",
130
+ stroke: "currentColor",
131
+ strokeWidth: "1.5",
132
+ strokeLinecap: "round",
133
+ "aria-hidden": "true",
134
+ children: [/* @__PURE__ */ h("path", { d: "M13 8 8 13" }), /* @__PURE__ */ h("path", { d: "M13 3 3 13" })]
135
+ });
136
+ }
137
+ var w = {
138
+ up: "M8 12V4M4 8l4-4 4 4",
139
+ down: "M8 4v8M4 8l4 4 4-4",
140
+ left: "M12 8H4M8 4 4 8l4 4",
141
+ right: "M4 8h8M8 4l4 4-4 4"
142
+ };
143
+ function re({ direction: e }) {
144
+ return /* @__PURE__ */ h("svg", {
145
+ width: "1em",
146
+ height: "1em",
147
+ viewBox: "0 0 16 16",
148
+ fill: "none",
149
+ stroke: "currentColor",
150
+ strokeWidth: "1.5",
151
+ strokeLinecap: "round",
152
+ strokeLinejoin: "round",
153
+ "aria-hidden": "true",
154
+ children: /* @__PURE__ */ h("path", { d: w[e] })
155
+ });
156
+ }
157
+ var ie = [
158
+ "up",
159
+ "down",
160
+ "left",
161
+ "right"
162
+ ], ae = {
163
+ up: "uic.Board.directionUp",
164
+ down: "uic.Board.directionDown",
165
+ left: "uic.Board.directionLeft",
166
+ right: "uic.Board.directionRight"
167
+ }, T = (...e) => e.filter(Boolean).join(" ");
168
+ function E({ items: S, renderItem: w, onItemsChange: E, isMovable: oe = !1, isResizable: se = !1, variant: ce = "plain", emptyContent: le, columnBreakpoints: ue = y, itemClassName: D, dragHandleIcon: de, resizeHandleIcon: fe, dragHandleLabel: pe, resizeHandleLabel: me, liveAnnouncementDndStarted: he, liveAnnouncementDndItemMoved: ge, liveAnnouncementDndItemResized: _e, liveAnnouncementDndCommitted: ve, liveAnnouncementDndDiscarded: ye, liveAnnouncementItemRemoved: be, className: xe, ...Se }) {
169
+ let O = e(), k = p(null), A = p(null), j = p(/* @__PURE__ */ new Map()), [M, N] = m(null), [P, Ce] = m(null), [we, F] = m(""), I = p(null), L = (e) => {
170
+ I.current = e, Ce(e);
171
+ }, R = p(S);
172
+ R.current = S;
173
+ let z = p(null);
174
+ f(() => {
175
+ let e = k.current;
176
+ if (!e) return;
177
+ if (typeof ResizeObserver > "u") {
178
+ N(e.clientWidth);
179
+ return;
180
+ }
181
+ let t = new ResizeObserver((t) => {
182
+ let n = t[0];
183
+ N(n ? n.contentRect.width : e.clientWidth);
184
+ });
185
+ return t.observe(e), () => t.disconnect();
186
+ }, []);
187
+ let Te = M === null ? 0 : x(M, ue), B = P ? P.base.columns : Te, Ee = r(S, B), De = (e) => F(he?.(e) ?? O(e === "resize" ? "uic.Board.resizeStarted" : "uic.Board.moveStarted")), Oe = (e, t) => {
188
+ let n = R.current.find((t) => t.id === e.itemId);
189
+ if (!n) return;
190
+ let r = {
191
+ item: n,
192
+ placement: { ...t }
193
+ };
194
+ F(e.operation === "resize" ? _e?.(r) ?? O("uic.Board.itemResized", {
195
+ columns: t.width,
196
+ rows: t.height
197
+ }) : ge?.(r) ?? O("uic.Board.itemMoved", {
198
+ column: t.x + 1,
199
+ row: t.y + 1
200
+ }));
201
+ }, V = (e, t) => F(t ? ve?.(e) ?? O(e === "resize" ? "uic.Board.resizeCommitted" : "uic.Board.moveCommitted") : ye?.(e) ?? O(e === "resize" ? "uic.Board.resizeDiscarded" : "uic.Board.moveDiscarded")), ke = (e, t, n) => {
202
+ let r = A.current;
203
+ if (!r) return {
204
+ cellWidth: 0,
205
+ cellHeight: 0,
206
+ gap: 0
207
+ };
208
+ let i = getComputedStyle(r), a = parseFloat(i.rowGap) || 0, o = j.current.get(t)?.getBoundingClientRect(), s = (e, t) => e === void 0 ? 0 : Math.max((e - a * (t - 1)) / t, 0), c = r.getBoundingClientRect().width;
209
+ return {
210
+ cellWidth: c > 0 && e > 0 ? Math.max((c - a * (e - 1)) / e, 0) : s(o?.width, n.width),
211
+ cellHeight: parseFloat(i.gridAutoRows) || s(o?.height, n.height),
212
+ gap: a
213
+ };
214
+ }, H = (e) => {
215
+ let t = (e.shift?.next ?? e.base).items.find((t) => t.id === e.itemId);
216
+ return t ? {
217
+ x: t.x,
218
+ y: t.y,
219
+ width: t.width,
220
+ height: t.height
221
+ } : e.origin;
222
+ }, Ae = (e) => {
223
+ let t = e.shift?.next ?? e.base, n = H(e);
224
+ return e.operation === "resize" ? Math.max(t.rows, n.y + n.height + 1) : Math.max(t.rows, e.base.rows + n.height);
225
+ }, U = (e, t, n, i) => {
226
+ let o = r(R.current, B), s = o.items.find((e) => e.id === n);
227
+ if (!s) return null;
228
+ let c = {
229
+ x: s.x,
230
+ y: s.y,
231
+ width: s.width,
232
+ height: s.height
233
+ }, l = {
234
+ operation: e,
235
+ interaction: t,
236
+ itemId: n,
237
+ base: o,
238
+ engine: new a(o),
239
+ origin: c,
240
+ path: t === "keyboard" ? [e === "resize" ? {
241
+ x: c.x + c.width,
242
+ y: c.y + c.height
243
+ } : {
244
+ x: c.x,
245
+ y: c.y
246
+ }] : [],
247
+ shift: null,
248
+ hovered: null,
249
+ metrics: ke(B, n, c),
250
+ pointer: i
251
+ };
252
+ return L(l), De(e), l;
253
+ }, je = (e, t) => {
254
+ let n = o(e.path, t);
255
+ try {
256
+ return {
257
+ path: n,
258
+ shift: e.operation === "resize" ? e.engine.resize(e.itemId, n) : e.engine.move(e.itemId, n)
259
+ };
260
+ } catch (e) {
261
+ if (e instanceof RangeError) return null;
262
+ throw e;
263
+ }
264
+ }, W = p(null), Me = () => {
265
+ let e = I.current;
266
+ if (!e) return null;
267
+ let t = j.current.get(e.itemId), n = typeof document > "u" ? null : document.activeElement;
268
+ return W.current = t && n instanceof HTMLElement && t.contains(n) ? {
269
+ itemId: e.itemId,
270
+ operation: e.operation
271
+ } : null, L(null), z.current = null, e;
272
+ };
273
+ f(() => {
274
+ let e = W.current;
275
+ if (!e || P) return;
276
+ W.current = null;
277
+ let t = j.current.get(e.itemId)?.querySelector(e.operation === "resize" ? ".uic-board-item__resize-handle" : ".uic-board-item__drag-handle");
278
+ t && document.activeElement !== t && t.focus({ preventScroll: !0 });
279
+ });
280
+ let G = () => {
281
+ let e = Me();
282
+ if (!e) return;
283
+ let { shift: t } = e;
284
+ if (t !== null && t.conflicts.length === 0 && t.moves.length > 0) {
285
+ let n = e.operation === "resize" ? e.itemId : void 0, r = i(R.current, t.next, n), a = r.find((t) => t.id === e.itemId);
286
+ E(e.operation === "resize" ? {
287
+ items: r,
288
+ resizedItem: a
289
+ } : {
290
+ items: r,
291
+ movedItem: a
292
+ });
293
+ }
294
+ let n = t === null ? e.interaction === "pointer" : t.conflicts.length > 0;
295
+ V(e.operation, !n);
296
+ }, K = () => {
297
+ let e = Me();
298
+ e && V(e.operation, !1);
299
+ }, Ne = p(K);
300
+ Ne.current = K;
301
+ let q = P?.pointer !== void 0;
302
+ f(() => {
303
+ if (!q) return;
304
+ let e = (e) => {
305
+ e.key === "Escape" && (e.preventDefault(), Ne.current());
306
+ };
307
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
308
+ }, [q]);
309
+ let Pe = (e) => {
310
+ let t = r(R.current, B), n = R.current.filter((t) => t.id !== e.id);
311
+ E({
312
+ items: i(n, s(t, e.id)),
313
+ removedItem: e
314
+ }), F(be?.({ item: e }) ?? O("uic.Board.itemRemoved"));
315
+ }, Fe = (e, r) => {
316
+ let i = r === "left" ? -1 : +(r === "right"), a = r === "up" ? -1 : +(r === "down"), o = e.path[e.path.length - 1];
317
+ if (!o) return;
318
+ if (e.operation === "resize") {
319
+ let r = R.current.find((t) => t.id === e.itemId), o = H(e), s = r ? t(r, e.base.columns) : 1, c = r ? n(r) : 1;
320
+ if (o.width + i < s || o.height + a < c) return;
321
+ }
322
+ let s = je(e, {
323
+ x: o.x + i,
324
+ y: o.y + a
325
+ });
326
+ if (!s) return;
327
+ let c = {
328
+ ...e,
329
+ ...s,
330
+ hovered: null
331
+ };
332
+ L(c), Oe(c, H(c));
333
+ }, Ie = (e, t) => (n) => {
334
+ n.button !== 0 || I.current?.pointer || (typeof n.currentTarget.setPointerCapture == "function" && n.currentTarget.setPointerCapture(n.pointerId), z.current = {
335
+ operation: e,
336
+ itemId: t,
337
+ pointerId: n.pointerId,
338
+ start: {
339
+ x: n.clientX,
340
+ y: n.clientY
341
+ }
342
+ });
343
+ }, Le = (e, t) => {
344
+ let n = j.current.get(e.itemId), r = b(A.current), i = n?.getBoundingClientRect(), a = i ? {
345
+ left: i.left - r.x,
346
+ top: i.top - r.y,
347
+ right: i.right - r.x,
348
+ bottom: i.bottom - r.y
349
+ } : {
350
+ left: 0,
351
+ top: 0,
352
+ right: 0,
353
+ bottom: 0
354
+ };
355
+ return I.current && L(null), U(e.operation, "pointer", e.itemId, {
356
+ id: e.pointerId,
357
+ start: e.start,
358
+ gridOrigin: r,
359
+ last: t,
360
+ itemBox: a,
361
+ dx: 0,
362
+ dy: 0
363
+ });
364
+ }, J = (e, r) => {
365
+ let i = e.pointer;
366
+ if (!i) return;
367
+ let a = l(r, i.start, i.gridOrigin, b(A.current)), { itemBox: o } = i, { cellWidth: s, cellHeight: c, gap: u } = e.metrics, d = (e, t) => Math.max(e * t + (e - 1) * u, 0), f = R.current.find((t) => t.id === e.itemId), p = e.base.columns, m = Ae(e), h, g = i.size;
368
+ if (e.operation === "resize") {
369
+ let r = d(f ? t(f, p) : 1, s), i = d(f ? n(f) : 1, c), l = d(p - e.origin.x, s);
370
+ g = {
371
+ width: ee(o.right - o.left + a.x, r, l),
372
+ height: Math.max(o.bottom - o.top + a.y, i)
373
+ }, h = {
374
+ left: o.left,
375
+ top: o.top,
376
+ right: o.left + g.width,
377
+ bottom: o.top + g.height
378
+ };
379
+ } else h = {
380
+ left: o.left + a.x,
381
+ top: o.top + a.y,
382
+ right: o.right + a.x,
383
+ bottom: o.bottom + a.y
384
+ };
385
+ let _ = te(h, p, m, e.metrics), v = H(e), y = _ !== null && (e.operation === "resize" || _.width * _.height >= v.width * v.height), { shift: x, path: S } = e;
386
+ if (!y) x = null;
387
+ else {
388
+ let t = e.operation === "resize" ? {
389
+ x: _.x + _.width,
390
+ y: _.y + _.height
391
+ } : {
392
+ x: _.x,
393
+ y: _.y
394
+ }, n = S[S.length - 1];
395
+ if (!n || n.x !== t.x || n.y !== t.y || x === null) {
396
+ let n = je(e, t);
397
+ n && ({shift: x, path: S} = n);
398
+ }
399
+ }
400
+ let C = {
401
+ ...e,
402
+ shift: x,
403
+ path: S,
404
+ hovered: y ? _ : null,
405
+ pointer: {
406
+ ...i,
407
+ last: r,
408
+ dx: a.x,
409
+ dy: a.y,
410
+ size: g
411
+ }
412
+ };
413
+ L(C);
414
+ }, Re = p(J);
415
+ Re.current = J;
416
+ let Y = (e) => {
417
+ let t = {
418
+ x: e.clientX,
419
+ y: e.clientY
420
+ }, n = z.current;
421
+ if (n && n.pointerId === e.pointerId) {
422
+ if (!(Math.abs(t.x - n.start.x) > 3 || Math.abs(t.y - n.start.y) > 3)) return;
423
+ z.current = null;
424
+ let e = Le(n, t);
425
+ e && J(e, t);
426
+ return;
427
+ }
428
+ let r = I.current;
429
+ !r?.pointer || r.pointer.id !== e.pointerId || J(r, t);
430
+ };
431
+ f(() => {
432
+ if (!q) return;
433
+ let e = () => {
434
+ let e = I.current;
435
+ e?.pointer && Re.current(e, e.pointer.last);
436
+ };
437
+ window.addEventListener("scroll", e, {
438
+ capture: !0,
439
+ passive: !0
440
+ });
441
+ let t = A.current, n = t ? u(t) : null, r = 0, i = () => {
442
+ let t = I.current;
443
+ if (t?.pointer && n) {
444
+ let r = c(t.pointer.last, d(n));
445
+ (r.x !== 0 || r.y !== 0) && typeof n.scrollBy == "function" && (n.scrollBy(r.x, r.y), e());
446
+ }
447
+ r = requestAnimationFrame(i);
448
+ };
449
+ return typeof requestAnimationFrame == "function" && (r = requestAnimationFrame(i)), () => {
450
+ window.removeEventListener("scroll", e, { capture: !0 }), r && cancelAnimationFrame(r);
451
+ };
452
+ }, [q]);
453
+ let ze = (e) => {
454
+ let t = z.current;
455
+ if (t && t.pointerId === e.pointerId) {
456
+ z.current = null;
457
+ let n = I.current;
458
+ n && G(), n && n.itemId === t.itemId && n.operation === t.operation || (e.currentTarget.focus({ preventScroll: !0 }), U(t.operation, "keyboard", t.itemId));
459
+ return;
460
+ }
461
+ let n = I.current;
462
+ !n?.pointer || n.pointer.id !== e.pointerId || G();
463
+ }, Be = (e) => {
464
+ z.current?.pointerId === e.pointerId && (z.current = null);
465
+ let t = I.current;
466
+ !t?.pointer || t.pointer.id !== e.pointerId || K();
467
+ }, Ve = (e, t) => (n) => {
468
+ let r = I.current;
469
+ if (!(r && (r.itemId !== t || r.operation !== e))) switch (n.key) {
470
+ case "ArrowUp":
471
+ case "ArrowDown":
472
+ case "ArrowLeft":
473
+ case "ArrowRight":
474
+ if (r?.interaction !== "keyboard") return;
475
+ n.preventDefault(), Fe(r, n.key.slice(5).toLowerCase());
476
+ return;
477
+ case "Enter":
478
+ case " ":
479
+ n.preventDefault(), r ? G() : U(e, "keyboard", t);
480
+ return;
481
+ case "Escape":
482
+ r && (n.preventDefault(), K());
483
+ return;
484
+ default: return;
485
+ }
486
+ }, He = () => {
487
+ I.current?.interaction === "keyboard" && G();
488
+ }, Ue = P ? P.shift?.next ?? P.base : null, We = new Map(Ue?.items.map((e) => [e.id, e]) ?? []), X = P ? H(P) : null, Z = P?.hovered ?? (P?.interaction === "keyboard" && P.shift ? X : null), Ge = [];
489
+ if (P) {
490
+ let e = Ae(P);
491
+ for (let t = 0; t < e; t++) for (let e = 0; e < B; e++) {
492
+ let n = Z !== null && e >= Z.x && e < Z.x + Z.width && t >= Z.y && t < Z.y + Z.height;
493
+ Ge.push(/* @__PURE__ */ h("div", {
494
+ className: T("uic-board__placeholder", "uic-board__placeholder--active", n && "uic-board__placeholder--hover"),
495
+ style: {
496
+ gridColumn: `${e + 1} / span 1`,
497
+ gridRow: `${t + 1} / span 1`
498
+ }
499
+ }, `placeholder-${t}-${e}`));
500
+ }
501
+ }
502
+ let Ke = new Map(S.map((e) => [e.id, e])), Q = (e, t) => e * (t + (P?.metrics.gap ?? 0)), $ = (e, t) => P === null || P.interaction !== "keyboard" || P.itemId !== t || P.operation !== e ? null : ie.map((e) => /* @__PURE__ */ h("button", {
503
+ type: "button",
504
+ tabIndex: -1,
505
+ className: T("uic-board__direction", `uic-board__direction--${e}`),
506
+ "aria-label": O(ae[e]),
507
+ "data-direction": e,
508
+ onPointerDown: (e) => e.preventDefault(),
509
+ onClick: () => {
510
+ let t = I.current;
511
+ t && Fe(t, e);
512
+ },
513
+ children: /* @__PURE__ */ h(re, { direction: e })
514
+ }, e));
515
+ return /* @__PURE__ */ g("div", {
516
+ ref: k,
517
+ className: T("uic-board", P && "uic-board--active", xe),
518
+ ...Se,
519
+ children: [B > 0 && S.length > 0 ? /* @__PURE__ */ g("div", {
520
+ ref: A,
521
+ className: "uic-board__grid",
522
+ style: { gridTemplateColumns: `repeat(${B}, minmax(0, 1fr))` },
523
+ children: [Ge, Ee.items.map((e) => {
524
+ let t = Ke.get(e.id);
525
+ if (!t) return null;
526
+ let n = P?.itemId === e.id, r = n ? P?.pointer : void 0, i = `${e.x + 1} / span ${e.width}`, a = `${e.y + 1} / span ${e.height}`, o, s, c;
527
+ if (P && n && X) if (P.operation === "resize") r?.size ? (s = r.size.width, c = r.size.height) : (i = `${e.x + 1} / span ${X.width}`, a = `${e.y + 1} / span ${X.height}`);
528
+ else if (r) o = `translate(${r.dx}px, ${r.dy}px)`;
529
+ else {
530
+ let { cellWidth: t, cellHeight: n } = P.metrics;
531
+ o = `translate(${Q(X.x - e.x, t)}px, ${Q(X.y - e.y, n)}px)`;
532
+ }
533
+ else if (P) {
534
+ let t = We.get(e.id);
535
+ if (t && (t.x !== e.x || t.y !== e.y)) {
536
+ let { cellWidth: n, cellHeight: r } = P.metrics;
537
+ o = `translate(${Q(t.x - e.x, n)}px, ${Q(t.y - e.y, r)}px)`;
538
+ }
539
+ }
540
+ let l = {
541
+ gridColumn: i,
542
+ gridRow: a,
543
+ transform: o,
544
+ width: s,
545
+ height: c
546
+ }, u = typeof D == "function" ? D(t) : D;
547
+ return /* @__PURE__ */ g("div", {
548
+ ref: (e) => {
549
+ e ? j.current.set(t.id, e) : j.current.delete(t.id);
550
+ },
551
+ className: T("uic-board-item", ce === "bordered" && "uic-board-item--bordered", n && "uic-board-item--active", P !== null && "uic-board-item--sliding", r && P?.operation === "move" && "uic-board-item--dragging", r && P?.operation === "resize" && "uic-board-item--resizing", u),
552
+ style: l,
553
+ "data-board-item-id": t.id,
554
+ children: [
555
+ oe ? /* @__PURE__ */ g("span", {
556
+ className: "uic-board-item__handle uic-board-item__handle--drag",
557
+ children: [/* @__PURE__ */ h(_, {
558
+ className: "uic-board-item__drag-handle",
559
+ variant: "ghost",
560
+ size: "sm",
561
+ label: pe ?? O("uic.Board.dragHandle"),
562
+ icon: de ?? /* @__PURE__ */ h(C, {}),
563
+ onPointerDown: Ie("move", t.id),
564
+ onPointerMove: Y,
565
+ onPointerUp: ze,
566
+ onPointerCancel: Be,
567
+ onKeyDown: Ve("move", t.id),
568
+ onBlur: He
569
+ }), $("move", t.id)]
570
+ }) : null,
571
+ /* @__PURE__ */ h("div", {
572
+ className: "uic-board-item__content",
573
+ children: w(t, { removeItem: () => Pe(t) })
574
+ }),
575
+ se ? /* @__PURE__ */ g("span", {
576
+ className: "uic-board-item__handle uic-board-item__handle--resize",
577
+ children: [/* @__PURE__ */ h(_, {
578
+ className: "uic-board-item__resize-handle",
579
+ variant: "ghost",
580
+ size: "sm",
581
+ label: me ?? O("uic.Board.resizeHandle"),
582
+ icon: fe ?? /* @__PURE__ */ h(ne, {}),
583
+ onPointerDown: Ie("resize", t.id),
584
+ onPointerMove: Y,
585
+ onPointerUp: ze,
586
+ onPointerCancel: Be,
587
+ onKeyDown: Ve("resize", t.id),
588
+ onBlur: He
589
+ }), $("resize", t.id)]
590
+ }) : null
591
+ ]
592
+ }, t.id);
593
+ })]
594
+ }) : S.length === 0 ? le : null, /* @__PURE__ */ h(v, {
595
+ as: "div",
596
+ "aria-live": "polite",
597
+ "aria-atomic": "true",
598
+ children: we
599
+ })]
600
+ });
601
+ }
602
+ E.displayName = "Board";
603
+ //#endregion
604
+ export { E as Board, y as DEFAULT_BOARD_COLUMN_BREAKPOINTS, x as columnsForWidth, te as hoveredCells };
605
+
606
+ //# sourceMappingURL=Board2.js.map
607
+ import "../../assets/components/Board/Board.css";