@alfadocs/ui-kit 1.60.0 → 1.61.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/dist/_chunks/dashboard-grid-DRnhIlT-.js +1404 -0
- package/dist/_chunks/{marketplace-app-shell-DK2pFMpf.js → marketplace-app-shell-p6hPgVwy.js} +2 -2
- package/dist/_chunks/{sidebar-DhePV1hE.js → sidebar-C9Zof0z1.js} +526 -518
- package/dist/agent-catalog.json +37 -2
- package/dist/agent-i18n/en.json +3 -1
- package/dist/components/dashboard-grid/dashboard-grid-engine.d.ts +16 -4
- package/dist/components/dashboard-grid/dashboard-grid.d.ts +42 -2
- package/dist/components/dashboard-grid/index.d.ts +1 -1
- package/dist/components/dashboard-grid/index.js +1 -1
- package/dist/components/sidebar/index.js +1 -1
- package/dist/components/sidebar/sidebar.d.ts +6 -0
- package/dist/i18n/locales/ar.d.ts +1 -0
- package/dist/i18n/locales/ar.js +1 -0
- package/dist/i18n/locales/de.d.ts +1 -0
- package/dist/i18n/locales/de.js +1 -0
- package/dist/i18n/locales/el.d.ts +1 -0
- package/dist/i18n/locales/el.js +1 -0
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.js +1 -0
- package/dist/i18n/locales/es.d.ts +1 -0
- package/dist/i18n/locales/es.js +1 -0
- package/dist/i18n/locales/fr.d.ts +1 -0
- package/dist/i18n/locales/fr.js +1 -0
- package/dist/i18n/locales/hi.d.ts +1 -0
- package/dist/i18n/locales/hi.js +1 -0
- package/dist/i18n/locales/it.d.ts +1 -0
- package/dist/i18n/locales/it.js +1 -0
- package/dist/i18n/locales/ja.d.ts +1 -0
- package/dist/i18n/locales/ja.js +1 -0
- package/dist/i18n/locales/nl.d.ts +1 -0
- package/dist/i18n/locales/nl.js +1 -0
- package/dist/i18n/locales/pl.d.ts +1 -0
- package/dist/i18n/locales/pl.js +1 -0
- package/dist/i18n/locales/pt.d.ts +1 -0
- package/dist/i18n/locales/pt.js +1 -0
- package/dist/i18n/locales/ro.d.ts +1 -0
- package/dist/i18n/locales/ro.js +1 -0
- package/dist/i18n/locales/ru.d.ts +1 -0
- package/dist/i18n/locales/ru.js +1 -0
- package/dist/i18n/locales/sq.d.ts +1 -0
- package/dist/i18n/locales/sq.js +1 -0
- package/dist/i18n/locales/sv.d.ts +1 -0
- package/dist/i18n/locales/sv.js +1 -0
- package/dist/i18n/locales/tr.d.ts +1 -0
- package/dist/i18n/locales/tr.js +1 -0
- package/dist/i18n/locales/zh.d.ts +1 -0
- package/dist/i18n/locales/zh.js +1 -0
- package/dist/index.js +3 -3
- package/dist/locales/ar.json +1 -0
- package/dist/locales/de.json +1 -0
- package/dist/locales/el.json +1 -0
- package/dist/locales/en.json +1 -0
- package/dist/locales/es.json +1 -0
- package/dist/locales/fr.json +1 -0
- package/dist/locales/hi.json +1 -0
- package/dist/locales/it.json +1 -0
- package/dist/locales/ja.json +1 -0
- package/dist/locales/nl.json +1 -0
- package/dist/locales/pl.json +1 -0
- package/dist/locales/pt.json +1 -0
- package/dist/locales/ro.json +1 -0
- package/dist/locales/ru.json +1 -0
- package/dist/locales/sq.json +1 -0
- package/dist/locales/sv.json +1 -0
- package/dist/locales/tr.json +1 -0
- package/dist/locales/zh.json +1 -0
- package/dist/patterns/marketplace-app-shell/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/dashboard-grid-DeNEltwI.js +0 -933
|
@@ -1,933 +0,0 @@
|
|
|
1
|
-
import { jsxs as Z, jsx as G } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Be, useRef as x, useState as L, useCallback as C, useMemo as j, useEffect as X, useImperativeHandle as Je, useContext as Qe, Children as Ze, isValidElement as et, Fragment as tt, createContext as rt, cloneElement as Le } from "react";
|
|
3
|
-
import { c as ce } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as We } from "react-i18next";
|
|
5
|
-
import { I as ge } from "./icon-button-dNE6ENLn.js";
|
|
6
|
-
import { T as nt } from "./tooltip-Cp-PLePW.js";
|
|
7
|
-
import { u as _ } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
|
|
8
|
-
import { u as st } from "./registry-DvAUVLHh.js";
|
|
9
|
-
import { P as it } from "./plus-DzMQ_c6b.js";
|
|
10
|
-
import { G as ot } from "./grip-vertical-onSb1JXO.js";
|
|
11
|
-
import { X as dt } from "./x-B5YnXwCz.js";
|
|
12
|
-
import { c as at } from "./createLucideIcon-DhHxpK9K.js";
|
|
13
|
-
/**
|
|
14
|
-
* @license lucide-react v1.22.0 - ISC
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the ISC license.
|
|
17
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/
|
|
19
|
-
const ct = [
|
|
20
|
-
["path", { d: "M19 13v6h-6", key: "1hxl6d" }],
|
|
21
|
-
["path", { d: "M5 11V5h6", key: "12e2xe" }],
|
|
22
|
-
["path", { d: "m5 5 14 14", key: "11anup" }]
|
|
23
|
-
], ut = at("move-diagonal-2", ct), lt = {
|
|
24
|
-
id: "dashboard-grid",
|
|
25
|
-
// The board's whole purpose is in-place rearrangement of its widgets.
|
|
26
|
-
capabilities: ["edit_inline"],
|
|
27
|
-
state: {
|
|
28
|
-
layout: {
|
|
29
|
-
type: "{ id: string, x: number, y: number, w: number, h: number }[]",
|
|
30
|
-
descriptionKey: "ui.agent.dashboardGrid.state.layout",
|
|
31
|
-
description: "Current widget geometry in cell units — ids and rectangles only, no widget content.",
|
|
32
|
-
read: (r) => r.getGridState().layout
|
|
33
|
-
},
|
|
34
|
-
cols: {
|
|
35
|
-
type: "number",
|
|
36
|
-
descriptionKey: "ui.agent.dashboardGrid.state.cols",
|
|
37
|
-
description: "Logical column count of the board.",
|
|
38
|
-
read: (r) => r.getGridState().cols
|
|
39
|
-
},
|
|
40
|
-
editing: {
|
|
41
|
-
type: "boolean",
|
|
42
|
-
descriptionKey: "ui.agent.dashboardGrid.state.editing",
|
|
43
|
-
description: "Whether edit mode is on. Move/resize actions are refused while it is off — the host app owns the toggle.",
|
|
44
|
-
read: (r) => r.getGridState().editing
|
|
45
|
-
},
|
|
46
|
-
stacked: {
|
|
47
|
-
type: "boolean",
|
|
48
|
-
descriptionKey: "ui.agent.dashboardGrid.state.stacked",
|
|
49
|
-
description: "Whether the board is narrower than its stackBelow width and shows its widgets as one read-only column. Move/resize actions are unavailable while it is true, even in edit mode; the saved layout is unchanged.",
|
|
50
|
-
read: (r) => r.getGridState().stacked
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
actions: {
|
|
54
|
-
move_widget: {
|
|
55
|
-
// Rearranging the board mutates user configuration — a write,
|
|
56
|
-
// reversible by moving back.
|
|
57
|
-
safety: "write",
|
|
58
|
-
argsType: "id, x, y",
|
|
59
|
-
argsSchema: {
|
|
60
|
-
type: "object",
|
|
61
|
-
properties: {
|
|
62
|
-
id: { type: "string", description: "Widget id (see layout state)." },
|
|
63
|
-
x: {
|
|
64
|
-
type: "integer",
|
|
65
|
-
minimum: 0,
|
|
66
|
-
description: "0-based logical column."
|
|
67
|
-
},
|
|
68
|
-
y: { type: "integer", minimum: 0, description: "0-based row." }
|
|
69
|
-
},
|
|
70
|
-
required: ["id", "x", "y"]
|
|
71
|
-
},
|
|
72
|
-
returns: "boolean (accepted)",
|
|
73
|
-
returnsSchema: {
|
|
74
|
-
type: "boolean",
|
|
75
|
-
description: "True when applied; false when edit mode is off, the board is stacked, or the id is unknown."
|
|
76
|
-
},
|
|
77
|
-
idempotent: !0,
|
|
78
|
-
errors: [
|
|
79
|
-
"Unavailable while the board is stacked (state stacked is true): returns false and changes nothing.",
|
|
80
|
-
"Unavailable while edit mode is off: returns false.",
|
|
81
|
-
"Unknown widget id: returns false."
|
|
82
|
-
],
|
|
83
|
-
descriptionKey: "ui.agent.dashboardGrid.actions.moveWidget",
|
|
84
|
-
description: "Move a widget to a cell. Out-of-bounds targets are clamped; colliding widgets are pushed down and the layout re-compacts. Refused while edit mode is off or the board is stacked.",
|
|
85
|
-
invoke: (r, o) => r.moveWidgetTo(o.id, o.x, o.y)
|
|
86
|
-
},
|
|
87
|
-
resize_widget: {
|
|
88
|
-
safety: "write",
|
|
89
|
-
argsType: "id, w, h",
|
|
90
|
-
argsSchema: {
|
|
91
|
-
type: "object",
|
|
92
|
-
properties: {
|
|
93
|
-
id: { type: "string", description: "Widget id (see layout state)." },
|
|
94
|
-
w: {
|
|
95
|
-
type: "integer",
|
|
96
|
-
minimum: 1,
|
|
97
|
-
description: "Column span (≥ 1)."
|
|
98
|
-
},
|
|
99
|
-
h: { type: "integer", minimum: 1, description: "Row span (≥ 1)." }
|
|
100
|
-
},
|
|
101
|
-
required: ["id", "w", "h"]
|
|
102
|
-
},
|
|
103
|
-
returns: "boolean (accepted)",
|
|
104
|
-
returnsSchema: {
|
|
105
|
-
type: "boolean",
|
|
106
|
-
description: "True when applied; false when edit mode is off, the board is stacked, or the id is unknown."
|
|
107
|
-
},
|
|
108
|
-
idempotent: !0,
|
|
109
|
-
errors: [
|
|
110
|
-
"Unavailable while the board is stacked (state stacked is true): returns false and changes nothing.",
|
|
111
|
-
"Unavailable while edit mode is off: returns false.",
|
|
112
|
-
"Unknown widget id: returns false."
|
|
113
|
-
],
|
|
114
|
-
descriptionKey: "ui.agent.dashboardGrid.actions.resizeWidget",
|
|
115
|
-
description: "Resize a widget to a span. Clamped to the grid and the widget’s min/max; colliding widgets are pushed down. Refused while edit mode is off or the board is stacked.",
|
|
116
|
-
invoke: (r, o) => r.resizeWidgetTo(o.id, o.w, o.h)
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
domHooks: {
|
|
120
|
-
root: {
|
|
121
|
-
attr: "data-component",
|
|
122
|
-
value: "dashboard-grid",
|
|
123
|
-
description: 'Also carries data-stacked="true" while the board shows one read-only column.'
|
|
124
|
-
},
|
|
125
|
-
instanceId: {
|
|
126
|
-
attr: "data-component-id",
|
|
127
|
-
sourceProp: "id",
|
|
128
|
-
description: "Sourced from the id prop."
|
|
129
|
-
},
|
|
130
|
-
item: {
|
|
131
|
-
attr: "data-widget-id",
|
|
132
|
-
description: "Each widget wrapper carries its layout id."
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
function q(r, o) {
|
|
137
|
-
return r.x < o.x + o.w && o.x < r.x + r.w && r.y < o.y + o.h && o.y < r.y + r.h;
|
|
138
|
-
}
|
|
139
|
-
function ue(r, o) {
|
|
140
|
-
const s = Math.max(1, r.minW ?? 1), u = Math.max(1, r.minH ?? 1), l = Math.min(o, r.maxW ?? o), b = r.maxH ?? Number.POSITIVE_INFINITY, a = Math.min(Math.max(r.w, s), l), h = Math.min(Math.max(r.h, u), b), i = Math.min(Math.max(0, r.x), o - a), m = Math.max(0, r.y);
|
|
141
|
-
return { ...r, x: i, y: m, w: a, h };
|
|
142
|
-
}
|
|
143
|
-
function H(r, o, s) {
|
|
144
|
-
const u = r.map((i) => ue(i, o)), l = [...u].sort((i, m) => i.id === s ? -1 : m.id === s ? 1 : i.y - m.y || i.x - m.x), b = [], a = s ? u.find((i) => i.id === s) : void 0;
|
|
145
|
-
for (const i of l) {
|
|
146
|
-
if (i.id !== s) {
|
|
147
|
-
if (a && q(a, i)) {
|
|
148
|
-
const m = { ...i, y: Math.max(0, a.y - i.h) };
|
|
149
|
-
!q(a, m) && !b.some((M) => M.id !== s && q(M, m)) && (i.y = m.y);
|
|
150
|
-
}
|
|
151
|
-
for (; b.some((m) => q(m, i)); )
|
|
152
|
-
i.y += 1;
|
|
153
|
-
for (; i.y > 0; ) {
|
|
154
|
-
const m = { ...i, y: i.y - 1 };
|
|
155
|
-
if (b.some((M) => q(M, m))) break;
|
|
156
|
-
i.y -= 1;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
b.push(i);
|
|
160
|
-
}
|
|
161
|
-
const h = new Map(b.map((i) => [i.id, i]));
|
|
162
|
-
return r.map((i) => h.get(i.id));
|
|
163
|
-
}
|
|
164
|
-
function be(r, o, s, u, l) {
|
|
165
|
-
const b = r.map(
|
|
166
|
-
(a) => a.id === o ? ue({ ...a, x: s, y: u }, l) : a
|
|
167
|
-
);
|
|
168
|
-
return H(b, l, o);
|
|
169
|
-
}
|
|
170
|
-
function he(r, o, s, u, l) {
|
|
171
|
-
const b = r.map(
|
|
172
|
-
(a) => a.id === o ? (
|
|
173
|
-
// Resizing never moves the widget: the width clamps to the space
|
|
174
|
-
// between its position and the grid edge (clampRect would slide it).
|
|
175
|
-
// minW wins over the edge clamp so clampRect cannot re-raise w and
|
|
176
|
-
// slide x as a side effect.
|
|
177
|
-
ue(
|
|
178
|
-
{
|
|
179
|
-
...a,
|
|
180
|
-
w: Math.max(a.minW ?? 1, Math.min(s, l - a.x)),
|
|
181
|
-
h: u
|
|
182
|
-
},
|
|
183
|
-
l
|
|
184
|
-
)
|
|
185
|
-
) : a
|
|
186
|
-
);
|
|
187
|
-
return H(b, l, o);
|
|
188
|
-
}
|
|
189
|
-
function $e(r, o, s, u) {
|
|
190
|
-
const l = Math.min(Math.max(1, s), o), b = r.reduce((a, h) => Math.max(a, h.y + h.h), 0);
|
|
191
|
-
for (let a = 0; a <= b; a += 1)
|
|
192
|
-
for (let h = 0; h <= o - l; h += 1) {
|
|
193
|
-
const i = {
|
|
194
|
-
x: h,
|
|
195
|
-
y: a,
|
|
196
|
-
w: l,
|
|
197
|
-
h: u
|
|
198
|
-
};
|
|
199
|
-
if (!r.some((m) => q(m, i)))
|
|
200
|
-
return { x: h, y: a };
|
|
201
|
-
}
|
|
202
|
-
return { x: 0, y: b };
|
|
203
|
-
}
|
|
204
|
-
function ft(r) {
|
|
205
|
-
return r.reduce((o, s) => Math.max(o, s.y + s.h), 0);
|
|
206
|
-
}
|
|
207
|
-
const pt = 24;
|
|
208
|
-
function Ae(r, o, s) {
|
|
209
|
-
return o === void 0 || !Number.isFinite(o) || o <= 0 ? !1 : !Number.isFinite(r) || r <= 0 ? s : s ? r < o + pt : r < o;
|
|
210
|
-
}
|
|
211
|
-
function mt(r, o) {
|
|
212
|
-
const s = new Map(o.map((u) => [u.id, u]));
|
|
213
|
-
return r.map((u, l) => ({ id: u, index: l, entry: s.get(u) })).sort((u, l) => !u.entry || !l.entry ? u.entry ? -1 : l.entry ? 1 : u.index - l.index : u.entry.y - l.entry.y || u.entry.x - l.entry.x || u.index - l.index).map(({ id: u }) => u);
|
|
214
|
-
}
|
|
215
|
-
const gt = ce(
|
|
216
|
-
[
|
|
217
|
-
"ds:grid ds:w-full",
|
|
218
|
-
"ds:gap-[var(--spacing-md)]",
|
|
219
|
-
// Edit-mode surface: tint the whole plane, draw faint cell lines, and
|
|
220
|
-
// reserve spare rows (--dg-min-block) so the AVAILABLE space reads at
|
|
221
|
-
// a glance instead of the board ending at the last occupied row.
|
|
222
|
-
"ds:data-[editing=true]:rounded-[var(--radius-lg)] ds:data-[editing=true]:bg-muted/10",
|
|
223
|
-
"ds:data-[editing=true]:[background-image:var(--dg-grid-lines)]",
|
|
224
|
-
"ds:data-[editing=true]:min-h-[var(--dg-min-block)]"
|
|
225
|
-
].join(" "),
|
|
226
|
-
{
|
|
227
|
-
variants: {
|
|
228
|
-
// Stacked: one full-width column; each row takes its widget's block
|
|
229
|
-
// size. Focus can fall back to the board here (see the focus effect),
|
|
230
|
-
// so it gets the kit's focus ring.
|
|
231
|
-
stacked: {
|
|
232
|
-
false: [
|
|
233
|
-
"ds:[grid-template-columns:repeat(var(--dg-cols),minmax(0,1fr))]",
|
|
234
|
-
"ds:[grid-auto-rows:var(--dg-row)]"
|
|
235
|
-
].join(" "),
|
|
236
|
-
true: [
|
|
237
|
-
"ds:grid-cols-1 ds:auto-rows-auto",
|
|
238
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]"
|
|
239
|
-
].join(" ")
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
defaultVariants: { stacked: !1 }
|
|
243
|
-
}
|
|
244
|
-
), bt = ce(
|
|
245
|
-
[
|
|
246
|
-
"ds:relative ds:min-h-0 ds:min-w-0 ds:overflow-hidden",
|
|
247
|
-
// Mirror of Card variant="elevated" so widgets read as kit cards.
|
|
248
|
-
"ds:rounded-[var(--radius-lg)] ds:bg-[var(--card)] ds:text-[var(--card-foreground)]",
|
|
249
|
-
"ds:[:where(&)]:border-[length:var(--surface-border-width,var(--border-width-sm))] ds:border-[color:var(--card-border)] ds:shadow-[var(--shadow-card)]",
|
|
250
|
-
// Grabbed feedback (keyboard or pointer drag in flight).
|
|
251
|
-
"ds:data-[grabbed=true]:ring-[length:var(--focus-ring-width)] ds:data-[grabbed=true]:ring-ring ds:data-[grabbed=true]:z-10",
|
|
252
|
-
// Only reachable when stacking removes the focused edit control: the
|
|
253
|
-
// widget then takes focus itself (tabindex -1, set at that moment).
|
|
254
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]"
|
|
255
|
-
].join(" "),
|
|
256
|
-
{
|
|
257
|
-
variants: {
|
|
258
|
-
stacked: {
|
|
259
|
-
false: [
|
|
260
|
-
"ds:[grid-column-start:var(--dg-x)] ds:[grid-column-end:span_var(--dg-w)]",
|
|
261
|
-
"ds:[grid-row-start:var(--dg-y)] ds:[grid-row-end:span_var(--dg-h)]"
|
|
262
|
-
].join(" "),
|
|
263
|
-
true: "ds:col-span-full ds:row-auto"
|
|
264
|
-
},
|
|
265
|
-
stackedHeight: { grid: "", content: "" }
|
|
266
|
-
},
|
|
267
|
-
compoundVariants: [
|
|
268
|
-
{ stacked: !1, class: "ds:flex ds:flex-col" },
|
|
269
|
-
// At least the block size the widget has in the grid (h rows plus the
|
|
270
|
-
// h - 1 gaps). A minimum, not a fixed size: at 200% zoom the widget
|
|
271
|
-
// grows instead of clipping its content (WCAG 1.4.4, 1.4.10).
|
|
272
|
-
{
|
|
273
|
-
stacked: !0,
|
|
274
|
-
stackedHeight: "grid",
|
|
275
|
-
class: [
|
|
276
|
-
"ds:flex ds:flex-col",
|
|
277
|
-
"ds:[min-block-size:calc(var(--dg-h)*var(--dg-row)_+_(var(--dg-h)_-_1)*var(--spacing-md))]"
|
|
278
|
-
].join(" ")
|
|
279
|
-
},
|
|
280
|
-
// As tall as the content, or minStackedHeight. A grid, not a flex
|
|
281
|
-
// column, so the body row is a definite box a 100% chart can fill.
|
|
282
|
-
{
|
|
283
|
-
stacked: !0,
|
|
284
|
-
stackedHeight: "content",
|
|
285
|
-
class: [
|
|
286
|
-
"ds:grid ds:grid-cols-[minmax(0,1fr)] ds:grid-rows-[auto_1fr]",
|
|
287
|
-
"ds:[min-block-size:var(--dg-min-stacked)]"
|
|
288
|
-
].join(" ")
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
defaultVariants: { stacked: !1, stackedHeight: "grid" }
|
|
292
|
-
}
|
|
293
|
-
), ht = ce(
|
|
294
|
-
"ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pb-[var(--spacing-md)] ds:pt-[var(--spacing-xs)]",
|
|
295
|
-
{
|
|
296
|
-
variants: {
|
|
297
|
-
// `box`: fill the widget's block size and clip to it. `content`: take
|
|
298
|
-
// the content's own height (the content-height stack), never a box.
|
|
299
|
-
fit: {
|
|
300
|
-
box: "ds:min-h-0 ds:flex-1 ds:overflow-hidden",
|
|
301
|
-
content: "ds:min-w-0"
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
defaultVariants: { fit: "box" }
|
|
305
|
-
}
|
|
306
|
-
), yt = ce(
|
|
307
|
-
[
|
|
308
|
-
"ds:m-0 ds:min-w-0 ds:flex-1 ds:truncate ds:text-sm ds:font-medium",
|
|
309
|
-
"ds:rounded-[var(--radius-sm)]",
|
|
310
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]"
|
|
311
|
-
].join(" ")
|
|
312
|
-
), Fe = rt(
|
|
313
|
-
null
|
|
314
|
-
);
|
|
315
|
-
function ae(r, o) {
|
|
316
|
-
Ze.forEach(r, (s) => {
|
|
317
|
-
if (et(s)) {
|
|
318
|
-
if (s.type === tt) {
|
|
319
|
-
ae(
|
|
320
|
-
s.props.children,
|
|
321
|
-
o
|
|
322
|
-
);
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
o(s);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
function je({
|
|
330
|
-
id: r,
|
|
331
|
-
title: o,
|
|
332
|
-
minStackedHeight: s,
|
|
333
|
-
actionsSlot: u,
|
|
334
|
-
children: l
|
|
335
|
-
}) {
|
|
336
|
-
var g, ne, P;
|
|
337
|
-
const { t: b } = We("ui"), a = Qe(Fe), h = x(null), i = a == null ? void 0 : a.layoutById.get(r), [m, M] = L(null), [$, ee] = L(!1), [te, E] = L(!1), [le, re] = L(!1);
|
|
338
|
-
if (X(() => {
|
|
339
|
-
if (!m) return;
|
|
340
|
-
const p = () => ee(m.scrollWidth > m.clientWidth);
|
|
341
|
-
p();
|
|
342
|
-
const N = typeof document < "u" ? document.fonts : void 0;
|
|
343
|
-
N == null || N.addEventListener("loadingdone", p);
|
|
344
|
-
const v = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(p);
|
|
345
|
-
return v == null || v.observe(m), () => {
|
|
346
|
-
N == null || N.removeEventListener("loadingdone", p), v == null || v.disconnect();
|
|
347
|
-
};
|
|
348
|
-
}, [m, o]), X(() => {
|
|
349
|
-
$ || re(!1);
|
|
350
|
-
}, [$]), _(() => {
|
|
351
|
-
const p = h.current;
|
|
352
|
-
!p || !i || (p.style.setProperty("--dg-x", String(i.x + 1)), p.style.setProperty("--dg-y", String(i.y + 1)), p.style.setProperty("--dg-w", String(i.w)), p.style.setProperty("--dg-h", String(i.h)), p.style.setProperty(
|
|
353
|
-
"--dg-min-stacked",
|
|
354
|
-
s !== void 0 && Number.isFinite(s) && s > 0 ? `${s}px` : "auto"
|
|
355
|
-
));
|
|
356
|
-
}, [i == null ? void 0 : i.x, i == null ? void 0 : i.y, i == null ? void 0 : i.w, i == null ? void 0 : i.h, i, s]), !a || !i) return null;
|
|
357
|
-
const y = ((g = a.grab) == null ? void 0 : g.id) === r, A = a.editing, R = a.headingLevel ? `h${a.headingLevel}` : "span";
|
|
358
|
-
return /* @__PURE__ */ Z(
|
|
359
|
-
"div",
|
|
360
|
-
{
|
|
361
|
-
ref: h,
|
|
362
|
-
role: "listitem",
|
|
363
|
-
"aria-label": o,
|
|
364
|
-
"data-component": "dashboard-grid-widget",
|
|
365
|
-
"data-widget-id": r,
|
|
366
|
-
"data-grabbed": y || void 0,
|
|
367
|
-
className: bt({
|
|
368
|
-
stacked: a.stacked,
|
|
369
|
-
stackedHeight: a.stackedHeight
|
|
370
|
-
}),
|
|
371
|
-
children: [
|
|
372
|
-
/* @__PURE__ */ Z("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)] ds:pt-[var(--spacing-sm)]", children: [
|
|
373
|
-
A ? /* @__PURE__ */ G(
|
|
374
|
-
ge,
|
|
375
|
-
{
|
|
376
|
-
size: "sm",
|
|
377
|
-
intent: "outline",
|
|
378
|
-
type: "button",
|
|
379
|
-
icon: /* @__PURE__ */ G(ot, {}),
|
|
380
|
-
"aria-label": b("dashboardGrid.move", { title: o }),
|
|
381
|
-
"aria-pressed": y && ((ne = a.grab) == null ? void 0 : ne.kind) === "move",
|
|
382
|
-
className: "ds:cursor-grab ds:touch-none ds:bg-[var(--card)]",
|
|
383
|
-
onPointerDown: (p) => a.startPointerGrab("move", r, p),
|
|
384
|
-
onKeyDown: (p) => a.keyboardStep(p, r),
|
|
385
|
-
onClick: () => a.startKeyboardGrab("move", r)
|
|
386
|
-
}
|
|
387
|
-
) : null,
|
|
388
|
-
/* @__PURE__ */ G(
|
|
389
|
-
nt,
|
|
390
|
-
{
|
|
391
|
-
label: o,
|
|
392
|
-
open: $ && le,
|
|
393
|
-
onOpenChange: (p) => re(p && $),
|
|
394
|
-
children: /* @__PURE__ */ G(
|
|
395
|
-
R,
|
|
396
|
-
{
|
|
397
|
-
ref: M,
|
|
398
|
-
tabIndex: $ || te ? 0 : void 0,
|
|
399
|
-
onFocus: () => E(!0),
|
|
400
|
-
onBlur: () => E(!1),
|
|
401
|
-
className: yt(),
|
|
402
|
-
children: o
|
|
403
|
-
}
|
|
404
|
-
)
|
|
405
|
-
}
|
|
406
|
-
),
|
|
407
|
-
u,
|
|
408
|
-
A && a.canRemove ? /* @__PURE__ */ G(
|
|
409
|
-
ge,
|
|
410
|
-
{
|
|
411
|
-
size: "sm",
|
|
412
|
-
intent: "outline",
|
|
413
|
-
type: "button",
|
|
414
|
-
icon: /* @__PURE__ */ G(dt, {}),
|
|
415
|
-
className: "ds:bg-[var(--card)]",
|
|
416
|
-
"aria-label": b("dashboardGrid.remove", { title: o }),
|
|
417
|
-
onClick: () => a.requestRemove(r)
|
|
418
|
-
}
|
|
419
|
-
) : null
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */ G(
|
|
422
|
-
"div",
|
|
423
|
-
{
|
|
424
|
-
className: ht({
|
|
425
|
-
fit: a.stacked && a.stackedHeight === "content" ? "content" : "box"
|
|
426
|
-
}),
|
|
427
|
-
children: l
|
|
428
|
-
}
|
|
429
|
-
),
|
|
430
|
-
A ? /* @__PURE__ */ G("span", { className: "ds:absolute ds:bottom-[var(--spacing-sm)] ds:end-[var(--spacing-sm)]", children: /* @__PURE__ */ G(
|
|
431
|
-
ge,
|
|
432
|
-
{
|
|
433
|
-
size: "sm",
|
|
434
|
-
intent: "outline",
|
|
435
|
-
type: "button",
|
|
436
|
-
icon: /* @__PURE__ */ G(ut, {}),
|
|
437
|
-
flipIconInRtl: !0,
|
|
438
|
-
"aria-label": b("dashboardGrid.resize", { title: o }),
|
|
439
|
-
"aria-pressed": y && ((P = a.grab) == null ? void 0 : P.kind) === "resize",
|
|
440
|
-
className: "ds:touch-none ds:bg-[var(--card)]",
|
|
441
|
-
onPointerDown: (p) => a.startPointerGrab("resize", r, p),
|
|
442
|
-
onKeyDown: (p) => a.keyboardStep(p, r),
|
|
443
|
-
onClick: () => a.startKeyboardGrab("resize", r)
|
|
444
|
-
}
|
|
445
|
-
) }) : null
|
|
446
|
-
]
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
je.displayName = "DashboardGrid.Widget";
|
|
451
|
-
const _e = Be(
|
|
452
|
-
({
|
|
453
|
-
"aria-label": r,
|
|
454
|
-
id: o,
|
|
455
|
-
cols: s = 12,
|
|
456
|
-
rowHeight: u = 96,
|
|
457
|
-
layout: l,
|
|
458
|
-
defaultLayout: b,
|
|
459
|
-
onLayoutChange: a,
|
|
460
|
-
editing: h = !1,
|
|
461
|
-
onRemoveWidget: i,
|
|
462
|
-
onRequestAdd: m,
|
|
463
|
-
stackBelow: M,
|
|
464
|
-
onStackedChange: $,
|
|
465
|
-
stackedHeight: ee = "grid",
|
|
466
|
-
widgetHeadingLevel: te,
|
|
467
|
-
children: E,
|
|
468
|
-
className: le
|
|
469
|
-
}, re) => {
|
|
470
|
-
const { t: y } = We("ui"), A = x(null), R = x(null), [g, ne] = L(!1), P = x(!1);
|
|
471
|
-
P.current = g;
|
|
472
|
-
const p = x(null), N = C((e) => {
|
|
473
|
-
var d;
|
|
474
|
-
if (e === P.current) return;
|
|
475
|
-
const t = A.current, n = typeof document < "u" ? document.activeElement : null;
|
|
476
|
-
p.current = t && n instanceof HTMLElement && t.contains(n) ? {
|
|
477
|
-
element: n,
|
|
478
|
-
widgetId: ((d = n.closest("[data-widget-id]")) == null ? void 0 : d.getAttribute("data-widget-id")) ?? null
|
|
479
|
-
} : null, P.current = e, ne(e);
|
|
480
|
-
}, []);
|
|
481
|
-
_(() => {
|
|
482
|
-
const e = A.current;
|
|
483
|
-
if (!e) return;
|
|
484
|
-
if (M === void 0) {
|
|
485
|
-
N(!1);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if (N(
|
|
489
|
-
Ae(e.offsetWidth, M, P.current)
|
|
490
|
-
), typeof ResizeObserver > "u") return;
|
|
491
|
-
const t = new ResizeObserver((n) => {
|
|
492
|
-
var f, w;
|
|
493
|
-
const d = n[n.length - 1];
|
|
494
|
-
if (!d) return;
|
|
495
|
-
const c = ((w = (f = d.borderBoxSize) == null ? void 0 : f[0]) == null ? void 0 : w.inlineSize) ?? d.contentRect.width;
|
|
496
|
-
N(Ae(c, M, P.current));
|
|
497
|
-
});
|
|
498
|
-
return t.observe(e), () => t.disconnect();
|
|
499
|
-
}, [M, N]);
|
|
500
|
-
const v = h && !g, ye = j(() => {
|
|
501
|
-
const e = [];
|
|
502
|
-
return ae(E, (t) => {
|
|
503
|
-
t.props.id && e.push(t.props.id);
|
|
504
|
-
}), e;
|
|
505
|
-
}, [E]), ve = j(() => {
|
|
506
|
-
const e = /* @__PURE__ */ new Map();
|
|
507
|
-
return ae(E, (t) => {
|
|
508
|
-
t.props.id && e.set(t.props.id, {
|
|
509
|
-
defaultW: t.props.defaultW ?? 4,
|
|
510
|
-
defaultH: t.props.defaultH ?? 2
|
|
511
|
-
});
|
|
512
|
-
}), e;
|
|
513
|
-
}, [E]), [Oe, Ke] = L(() => b ?? []), we = l ?? Oe, I = C(
|
|
514
|
-
(e) => {
|
|
515
|
-
l === void 0 && Ke(e), a == null || a(e);
|
|
516
|
-
},
|
|
517
|
-
[l, a]
|
|
518
|
-
), { resolved: k, autoPlaced: xe } = j(() => {
|
|
519
|
-
const e = we.map((d) => ue(d, s)), t = ye.filter(
|
|
520
|
-
(d) => !e.some((c) => c.id === d)
|
|
521
|
-
);
|
|
522
|
-
if (t.length === 0)
|
|
523
|
-
return { resolved: e, autoPlaced: !1 };
|
|
524
|
-
const n = [...e];
|
|
525
|
-
for (const d of t) {
|
|
526
|
-
const c = ve.get(d) ?? { defaultW: 4, defaultH: 2 }, f = Math.min(c.defaultW, s), w = $e(n, s, f, c.defaultH);
|
|
527
|
-
n.push({ id: d, x: w.x, y: w.y, w: f, h: c.defaultH });
|
|
528
|
-
}
|
|
529
|
-
return { resolved: H(n, s), autoPlaced: !0 };
|
|
530
|
-
}, [we, ye, ve, s]), ke = x("");
|
|
531
|
-
X(() => {
|
|
532
|
-
if (!xe) return;
|
|
533
|
-
const e = k.map(
|
|
534
|
-
(t) => `${t.id}:${t.x},${t.y},${t.w},${t.h}`
|
|
535
|
-
).join("|");
|
|
536
|
-
ke.current !== e && (ke.current = e, I(k));
|
|
537
|
-
}, [xe, k, I]);
|
|
538
|
-
const [Ve, He] = L(null), [z, Ge] = L(null), [Ue, O] = L(""), fe = x(null), W = x(null), B = x(null), se = x(!1), J = x(s);
|
|
539
|
-
J.current = s;
|
|
540
|
-
const U = x(k);
|
|
541
|
-
U.current = k;
|
|
542
|
-
const F = C((e) => {
|
|
543
|
-
fe.current = e, He(e);
|
|
544
|
-
}, []), ie = C(
|
|
545
|
-
(e, t, n) => {
|
|
546
|
-
const d = { kind: e, id: t, via: n };
|
|
547
|
-
W.current = { ...d, baseLayout: U.current }, Ge(d), F(U.current);
|
|
548
|
-
},
|
|
549
|
-
[F]
|
|
550
|
-
), Q = Ve ?? k, Me = j(
|
|
551
|
-
() => new Map(Q.map((e) => [e.id, e])),
|
|
552
|
-
[Q]
|
|
553
|
-
), Se = C(
|
|
554
|
-
(e, t) => {
|
|
555
|
-
O(
|
|
556
|
-
e === "move" ? y("dashboardGrid.movedTo", { col: t.x + 1, row: t.y + 1 }) : y("dashboardGrid.resizedTo", { cols: t.w, rows: t.h })
|
|
557
|
-
);
|
|
558
|
-
},
|
|
559
|
-
[y]
|
|
560
|
-
), S = C(
|
|
561
|
-
(e) => {
|
|
562
|
-
const t = fe.current, n = W.current;
|
|
563
|
-
if (W.current = null, B.current = null, Ge(null), F(null), !e || !t || !n) {
|
|
564
|
-
O(y("dashboardGrid.cancelled"));
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
const d = H(t, J.current), c = (w) => w.map((T) => `${T.id}:${T.x},${T.y},${T.w},${T.h}`).join("|");
|
|
568
|
-
if (c(d) === c(U.current)) {
|
|
569
|
-
O(y("dashboardGrid.cancelled"));
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
I(d);
|
|
573
|
-
const f = d.find((w) => w.id === n.id);
|
|
574
|
-
O(
|
|
575
|
-
f ? y("dashboardGrid.droppedAt", {
|
|
576
|
-
col: f.x + 1,
|
|
577
|
-
row: f.y + 1
|
|
578
|
-
}) : y("dashboardGrid.cancelled")
|
|
579
|
-
);
|
|
580
|
-
},
|
|
581
|
-
[F, I, y]
|
|
582
|
-
), Re = C(
|
|
583
|
-
(e, t) => {
|
|
584
|
-
if (!v) return;
|
|
585
|
-
if (se.current) {
|
|
586
|
-
se.current = !1;
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
const n = W.current;
|
|
590
|
-
if ((n == null ? void 0 : n.via) !== "pointer") {
|
|
591
|
-
if (n && n.id === t && n.kind === e) {
|
|
592
|
-
S(!0);
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
ie(e, t, "keyboard"), O(
|
|
596
|
-
y(e === "move" ? "dashboardGrid.grabbed" : "dashboardGrid.resizeGrabbed")
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
[v, ie, S, y]
|
|
601
|
-
), Ne = C(
|
|
602
|
-
(e, t) => {
|
|
603
|
-
const n = W.current;
|
|
604
|
-
if (!n || n.id !== t || n.via !== "keyboard")
|
|
605
|
-
return;
|
|
606
|
-
if (e.key === "Escape") {
|
|
607
|
-
e.preventDefault(), S(!1);
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(e.key)) return;
|
|
611
|
-
e.preventDefault();
|
|
612
|
-
const c = typeof window < "u" && R.current ? window.getComputedStyle(R.current).direction === "rtl" : !1, f = e.key === "ArrowRight" ? c ? -1 : 1 : e.key === "ArrowLeft" ? c ? 1 : -1 : 0, w = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0, D = (fe.current ?? n.baseLayout).find((Y) => Y.id === t);
|
|
613
|
-
if (!D) return;
|
|
614
|
-
const K = n.kind === "move" ? be(
|
|
615
|
-
n.baseLayout,
|
|
616
|
-
t,
|
|
617
|
-
D.x + f,
|
|
618
|
-
D.y + w,
|
|
619
|
-
s
|
|
620
|
-
) : he(
|
|
621
|
-
n.baseLayout,
|
|
622
|
-
t,
|
|
623
|
-
D.w + f,
|
|
624
|
-
D.h + w,
|
|
625
|
-
s
|
|
626
|
-
);
|
|
627
|
-
F(K);
|
|
628
|
-
const V = K.find((Y) => Y.id === t);
|
|
629
|
-
V && Se(n.kind, V);
|
|
630
|
-
},
|
|
631
|
-
[s, S, F, Se]
|
|
632
|
-
), Te = C(
|
|
633
|
-
(e, t, n) => {
|
|
634
|
-
var V, Y, Ce, Ie;
|
|
635
|
-
if (!v || W.current) return;
|
|
636
|
-
const d = R.current, c = U.current.find((Xe) => Xe.id === t);
|
|
637
|
-
if (!d || !c) return;
|
|
638
|
-
n.preventDefault(), (Y = (V = n.currentTarget).focus) == null || Y.call(V);
|
|
639
|
-
const f = d.getBoundingClientRect();
|
|
640
|
-
if (f.width <= 0) return;
|
|
641
|
-
const w = window.getComputedStyle(d), T = Number.parseFloat(w.columnGap) || 0, D = Number.parseFloat(w.rowGap) || 0, K = (f.width - T * (s - 1)) / s;
|
|
642
|
-
B.current = {
|
|
643
|
-
kind: e,
|
|
644
|
-
id: t,
|
|
645
|
-
pointerId: n.pointerId,
|
|
646
|
-
startClientX: n.clientX,
|
|
647
|
-
startClientY: n.clientY,
|
|
648
|
-
origin: c,
|
|
649
|
-
colStride: K + T,
|
|
650
|
-
rowStride: u + D,
|
|
651
|
-
isRtl: w.direction === "rtl"
|
|
652
|
-
};
|
|
653
|
-
try {
|
|
654
|
-
(Ie = (Ce = n.currentTarget).setPointerCapture) == null || Ie.call(Ce, n.pointerId);
|
|
655
|
-
} catch {
|
|
656
|
-
}
|
|
657
|
-
ie(e, t, "pointer");
|
|
658
|
-
},
|
|
659
|
-
[v, s, u, ie]
|
|
660
|
-
);
|
|
661
|
-
X(() => {
|
|
662
|
-
if (!z || z.via !== "pointer") return;
|
|
663
|
-
const e = (d) => {
|
|
664
|
-
const c = B.current, f = W.current;
|
|
665
|
-
if (!c || !f || d.pointerId !== c.pointerId)
|
|
666
|
-
return;
|
|
667
|
-
const w = d.clientX - c.startClientX, T = d.clientY - c.startClientY, D = Math.round(w / c.colStride) * (c.isRtl ? -1 : 1), K = Math.round(T / c.rowStride), V = c.kind === "move" ? be(
|
|
668
|
-
f.baseLayout,
|
|
669
|
-
c.id,
|
|
670
|
-
c.origin.x + D,
|
|
671
|
-
c.origin.y + K,
|
|
672
|
-
J.current
|
|
673
|
-
) : he(
|
|
674
|
-
f.baseLayout,
|
|
675
|
-
c.id,
|
|
676
|
-
c.origin.w + D,
|
|
677
|
-
c.origin.h + K,
|
|
678
|
-
J.current
|
|
679
|
-
);
|
|
680
|
-
F(V);
|
|
681
|
-
}, t = (d) => {
|
|
682
|
-
const c = B.current;
|
|
683
|
-
!c || d.pointerId !== c.pointerId || (se.current = !0, S(!0));
|
|
684
|
-
}, n = (d) => {
|
|
685
|
-
const c = B.current;
|
|
686
|
-
!c || d.pointerId !== c.pointerId || (se.current = !0, S(!1));
|
|
687
|
-
};
|
|
688
|
-
return window.addEventListener("pointermove", e), window.addEventListener("pointerup", t), window.addEventListener("pointercancel", n), () => {
|
|
689
|
-
window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t), window.removeEventListener("pointercancel", n);
|
|
690
|
-
};
|
|
691
|
-
}, [z, S, F]), X(() => {
|
|
692
|
-
if (!z) return;
|
|
693
|
-
const e = (t) => {
|
|
694
|
-
t.key === "Escape" && S(!1);
|
|
695
|
-
};
|
|
696
|
-
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
697
|
-
}, [z, S]), X(() => {
|
|
698
|
-
if (!z || z.via !== "keyboard") return;
|
|
699
|
-
const e = (n) => {
|
|
700
|
-
var c;
|
|
701
|
-
const d = n.relatedTarget;
|
|
702
|
-
(!d || !((c = R.current) != null && c.contains(d))) && S(!1);
|
|
703
|
-
}, t = R.current;
|
|
704
|
-
return t == null || t.addEventListener("focusout", e), () => t == null ? void 0 : t.removeEventListener("focusout", e);
|
|
705
|
-
}, [z, S]), _(() => {
|
|
706
|
-
g && (W.current && S(!1), h && O(y("dashboardGrid.stackedReadOnly")));
|
|
707
|
-
}, [g, h, S, y]), _(() => {
|
|
708
|
-
var c;
|
|
709
|
-
const e = p.current;
|
|
710
|
-
p.current = null;
|
|
711
|
-
const t = A.current;
|
|
712
|
-
if (!e || !t) return;
|
|
713
|
-
const n = document.activeElement;
|
|
714
|
-
if (n === e.element || n !== null && n !== document.body) return;
|
|
715
|
-
if (t.contains(e.element)) {
|
|
716
|
-
e.element.focus();
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
const d = e.widgetId ? Array.from(
|
|
720
|
-
t.querySelectorAll("[data-widget-id]")
|
|
721
|
-
).find(
|
|
722
|
-
(f) => f.getAttribute("data-widget-id") === e.widgetId
|
|
723
|
-
) : void 0;
|
|
724
|
-
if (d) {
|
|
725
|
-
d.setAttribute("tabindex", "-1"), d.focus();
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
(c = R.current) == null || c.focus();
|
|
729
|
-
}, [g]);
|
|
730
|
-
const oe = x($);
|
|
731
|
-
oe.current = $;
|
|
732
|
-
const Ee = x(!1);
|
|
733
|
-
_(() => {
|
|
734
|
-
var e;
|
|
735
|
-
Ee.current !== g && (Ee.current = g, (e = oe.current) == null || e.call(oe, g));
|
|
736
|
-
}, [g]), _(() => {
|
|
737
|
-
const e = R.current;
|
|
738
|
-
e && (e.style.setProperty("--dg-cols", String(s)), e.style.setProperty("--dg-row", `${u}px`));
|
|
739
|
-
}, [s, u]);
|
|
740
|
-
const Pe = ft(Q);
|
|
741
|
-
_(() => {
|
|
742
|
-
const e = R.current;
|
|
743
|
-
e && (e.style.setProperty(
|
|
744
|
-
"--dg-grid-lines",
|
|
745
|
-
`repeating-linear-gradient(to right, color-mix(in srgb, var(--border) 50%, transparent) 0 1px, transparent 1px calc((100% + var(--spacing-md)) / ${s})), repeating-linear-gradient(to bottom, color-mix(in srgb, var(--border) 50%, transparent) 0 1px, transparent 1px calc(${u}px + var(--spacing-md)))`
|
|
746
|
-
), e.style.setProperty(
|
|
747
|
-
"--dg-min-block",
|
|
748
|
-
`calc(${Pe + 2} * (${u}px + var(--spacing-md)) - var(--spacing-md))`
|
|
749
|
-
));
|
|
750
|
-
}, [s, u, Pe]);
|
|
751
|
-
const ze = x(null), pe = v && !!m, de = j(
|
|
752
|
-
() => pe ? $e(Q, s, 2, 2) : null,
|
|
753
|
-
[pe, Q, s]
|
|
754
|
-
);
|
|
755
|
-
_(() => {
|
|
756
|
-
const e = ze.current;
|
|
757
|
-
!e || !de || (e.style.setProperty("--dg-x", String(de.x + 1)), e.style.setProperty("--dg-y", String(de.y + 1)), e.style.setProperty("--dg-w", "2"), e.style.setProperty("--dg-h", "2"));
|
|
758
|
-
}, [de]);
|
|
759
|
-
const De = C(
|
|
760
|
-
(e) => {
|
|
761
|
-
I(
|
|
762
|
-
H(
|
|
763
|
-
U.current.filter((t) => t.id !== e),
|
|
764
|
-
J.current
|
|
765
|
-
)
|
|
766
|
-
), O(y("dashboardGrid.removed")), i == null || i(e), requestAnimationFrame(() => {
|
|
767
|
-
const t = R.current;
|
|
768
|
-
if (!t) return;
|
|
769
|
-
const n = t.querySelector("button");
|
|
770
|
-
n ? n.focus() : t.focus();
|
|
771
|
-
});
|
|
772
|
-
},
|
|
773
|
-
[I, i, y]
|
|
774
|
-
), me = j(
|
|
775
|
-
() => ({
|
|
776
|
-
moveWidgetTo(e, t, n) {
|
|
777
|
-
return !v || P.current || !Number.isFinite(t) || !Number.isFinite(n) || !k.some((d) => d.id === e) ? !1 : (I(
|
|
778
|
-
H(
|
|
779
|
-
be(k, e, Math.round(t), Math.round(n), s),
|
|
780
|
-
s
|
|
781
|
-
)
|
|
782
|
-
), !0);
|
|
783
|
-
},
|
|
784
|
-
resizeWidgetTo(e, t, n) {
|
|
785
|
-
return !v || P.current || !Number.isFinite(t) || !Number.isFinite(n) || !k.some((d) => d.id === e) ? !1 : (I(
|
|
786
|
-
H(
|
|
787
|
-
he(
|
|
788
|
-
k,
|
|
789
|
-
e,
|
|
790
|
-
Math.round(t),
|
|
791
|
-
Math.round(n),
|
|
792
|
-
s
|
|
793
|
-
),
|
|
794
|
-
s
|
|
795
|
-
)
|
|
796
|
-
), !0);
|
|
797
|
-
},
|
|
798
|
-
getGridState() {
|
|
799
|
-
return {
|
|
800
|
-
cols: s,
|
|
801
|
-
editing: h,
|
|
802
|
-
stacked: g,
|
|
803
|
-
layout: k.map((e) => ({ ...e }))
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
}),
|
|
807
|
-
[v, h, g, k, s, I]
|
|
808
|
-
);
|
|
809
|
-
Je(re, () => me, [me]), st(lt, me, o);
|
|
810
|
-
const Ye = j(
|
|
811
|
-
() => ({
|
|
812
|
-
editing: v,
|
|
813
|
-
stacked: g,
|
|
814
|
-
stackedHeight: ee,
|
|
815
|
-
headingLevel: te,
|
|
816
|
-
layoutById: Me,
|
|
817
|
-
grab: z,
|
|
818
|
-
canRemove: !!i,
|
|
819
|
-
requestRemove: De,
|
|
820
|
-
startKeyboardGrab: Re,
|
|
821
|
-
keyboardStep: Ne,
|
|
822
|
-
startPointerGrab: Te
|
|
823
|
-
}),
|
|
824
|
-
[
|
|
825
|
-
v,
|
|
826
|
-
g,
|
|
827
|
-
ee,
|
|
828
|
-
te,
|
|
829
|
-
Me,
|
|
830
|
-
z,
|
|
831
|
-
i,
|
|
832
|
-
De,
|
|
833
|
-
Re,
|
|
834
|
-
Ne,
|
|
835
|
-
Te
|
|
836
|
-
]
|
|
837
|
-
), qe = j(() => {
|
|
838
|
-
if (M === void 0) return E;
|
|
839
|
-
const e = [], t = /* @__PURE__ */ new Map(), n = [];
|
|
840
|
-
return ae(E, (d) => {
|
|
841
|
-
const c = d.props.id;
|
|
842
|
-
if (c && !t.has(c)) {
|
|
843
|
-
const f = Le(d, {
|
|
844
|
-
key: `widget:${c}:${d.key ?? ""}`
|
|
845
|
-
});
|
|
846
|
-
t.set(c, f), e.push(f);
|
|
847
|
-
} else {
|
|
848
|
-
const f = Le(d, {
|
|
849
|
-
key: d.key === null ? `child:at:${n.length}` : `child:key:${d.key}`
|
|
850
|
-
});
|
|
851
|
-
n.push(f), e.push(f);
|
|
852
|
-
}
|
|
853
|
-
}), g ? [
|
|
854
|
-
...mt([...t.keys()], k).map(
|
|
855
|
-
(d) => t.get(d)
|
|
856
|
-
),
|
|
857
|
-
...n
|
|
858
|
-
] : e;
|
|
859
|
-
}, [M, E, g, k]);
|
|
860
|
-
return /* @__PURE__ */ Z(
|
|
861
|
-
"div",
|
|
862
|
-
{
|
|
863
|
-
ref: A,
|
|
864
|
-
"data-component": "dashboard-grid",
|
|
865
|
-
"data-component-id": o,
|
|
866
|
-
"data-editing": v || void 0,
|
|
867
|
-
"data-stacked": g || void 0,
|
|
868
|
-
className: `ds:block ds:w-full ${le ?? ""}`.trim(),
|
|
869
|
-
children: [
|
|
870
|
-
/* @__PURE__ */ G("div", { role: "status", "aria-live": "polite", className: "ds:sr-only", children: Ue }),
|
|
871
|
-
/* @__PURE__ */ Z(
|
|
872
|
-
"div",
|
|
873
|
-
{
|
|
874
|
-
ref: R,
|
|
875
|
-
role: "list",
|
|
876
|
-
"aria-label": r,
|
|
877
|
-
tabIndex: -1,
|
|
878
|
-
"data-editing": v || void 0,
|
|
879
|
-
"data-stacked": g || void 0,
|
|
880
|
-
className: gt({ stacked: g }),
|
|
881
|
-
children: [
|
|
882
|
-
/* @__PURE__ */ G(Fe.Provider, { value: Ye, children: qe }),
|
|
883
|
-
pe ? (
|
|
884
|
-
// role="list" allows only listitem children — the tile wrapper
|
|
885
|
-
// carries the grid placement, the button fills it.
|
|
886
|
-
/* @__PURE__ */ G(
|
|
887
|
-
"div",
|
|
888
|
-
{
|
|
889
|
-
ref: ze,
|
|
890
|
-
role: "listitem",
|
|
891
|
-
className: [
|
|
892
|
-
"ds:flex",
|
|
893
|
-
"ds:[grid-column-start:var(--dg-x)] ds:[grid-column-end:span_var(--dg-w)]",
|
|
894
|
-
"ds:[grid-row-start:var(--dg-y)] ds:[grid-row-end:span_var(--dg-h)]"
|
|
895
|
-
].join(" "),
|
|
896
|
-
children: /* @__PURE__ */ Z(
|
|
897
|
-
"button",
|
|
898
|
-
{
|
|
899
|
-
type: "button",
|
|
900
|
-
onClick: m,
|
|
901
|
-
className: [
|
|
902
|
-
"ds:flex ds:flex-1 ds:items-center ds:justify-center ds:gap-[var(--spacing-xs)]",
|
|
903
|
-
"ds:rounded-[var(--radius-lg)] ds:border ds:border-dashed ds:border-border",
|
|
904
|
-
"ds:text-sm ds:text-muted-foreground ds:transition-colors",
|
|
905
|
-
"ds:hover:bg-muted/10 ds:hover:text-foreground",
|
|
906
|
-
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-ring"
|
|
907
|
-
].join(" "),
|
|
908
|
-
children: [
|
|
909
|
-
/* @__PURE__ */ G(it, { "aria-hidden": "true", className: "ds:size-4" }),
|
|
910
|
-
y("dashboardGrid.add")
|
|
911
|
-
]
|
|
912
|
-
}
|
|
913
|
-
)
|
|
914
|
-
}
|
|
915
|
-
)
|
|
916
|
-
) : null
|
|
917
|
-
]
|
|
918
|
-
}
|
|
919
|
-
)
|
|
920
|
-
]
|
|
921
|
-
}
|
|
922
|
-
);
|
|
923
|
-
}
|
|
924
|
-
);
|
|
925
|
-
_e.displayName = "DashboardGrid";
|
|
926
|
-
const zt = Object.assign(_e, {
|
|
927
|
-
Widget: je
|
|
928
|
-
});
|
|
929
|
-
export {
|
|
930
|
-
zt as D,
|
|
931
|
-
lt as d
|
|
932
|
-
};
|
|
933
|
-
//# sourceMappingURL=dashboard-grid-DeNEltwI.js.map
|