@umriss-ui/dashboard 0.57.0 → 0.58.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/API.md +3 -2
- package/CHANGELOG.md +13 -0
- package/README.md +3 -0
- package/dist/dashboard.js +199 -196
- package/dist/index.d.ts +7 -2
- package/docs/llms-full.md +5 -4
- package/package.json +3 -3
package/API.md
CHANGED
|
@@ -14,7 +14,7 @@ Generated by the props step (`pnpm --filter @umriss-ui/dashboard props`); do not
|
|
|
14
14
|
## Types
|
|
15
15
|
|
|
16
16
|
- DashboardOptions — What `useDashboard` takes. [defaultView, initialView, allowEdit, onViewChange, onDraftChange]
|
|
17
|
-
- DashboardParts — What `useDashboard` hands back. [Dashboard, WidgetType, view, setView, editing, edit, done,
|
|
17
|
+
- DashboardParts — What `useDashboard` hands back. [Dashboard, WidgetType, view, setView, editing, edit, done, openCatalogue, cancel, undo, redo, reset, catalogue]
|
|
18
18
|
- DashboardProps — The props of `Dashboard`.
|
|
19
19
|
- DashboardView — The arrangement of a dashboard: which widgets, in what order, at which sizes, with which options. [widgets]
|
|
20
20
|
- DashboardWidget — One widget in a view. [id, type, size, options, locked]
|
|
@@ -62,11 +62,12 @@ Generated by the props step (`pnpm --filter @umriss-ui/dashboard props`); do not
|
|
|
62
62
|
- editing: boolean — Whether the editing mode is on.
|
|
63
63
|
- edit: () => void — Enters the editing mode.
|
|
64
64
|
- done: () => void — Leaves the mode, keeps the changes and reports them once if there are any.
|
|
65
|
-
-
|
|
65
|
+
- openCatalogue: () => void — Opens the catalogue.
|
|
66
66
|
- cancel: () => void — Leaves the mode and puts the arrangement back as it was before `edit`.
|
|
67
67
|
- undo: () => void — Goes one step back in the draft.
|
|
68
68
|
- redo: () => void — Goes one step forward again.
|
|
69
69
|
- reset: () => void — Steps to the `defaultView`; `undo` brings the arrangement back.
|
|
70
|
+
- catalogue: () => void — The old name of `openCatalogue`. (deprecated)
|
|
70
71
|
|
|
71
72
|
#### props of Dashboard (DashboardProps)
|
|
72
73
|
|
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,19 @@ one section before an upgrade reads that one.
|
|
|
13
13
|
|
|
14
14
|
The dashboard joins the other five packages' one number at its first version: they are released together, and a package without a change of its own still gets a heading for it.
|
|
15
15
|
|
|
16
|
+
## 0.58.0 – The candidate for 1.0: `openCatalogue()`, the stored view is promised (Nov. 2026)
|
|
17
|
+
|
|
18
|
+
This is the last minor before `1.0.0`, and the surface is frozen with it. Every old name below works for this minor, warns once in development, and is removed in `1.0.0`; nothing else will differ between the two.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **`DashboardView` is the supported storage format - an addition is a minor release**, renaming or removing `widgets`, `type` or `size` a major one.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **`catalogue()` in `useDashboard`'s return is `openCatalogue()`.**
|
|
27
|
+
- Migration: Call `openCatalogue()`; `catalogue()` works for this minor with a warning and is removed in 1.0.0. The prop `catalogue` of `Dashboard` stays.
|
|
28
|
+
|
|
16
29
|
## 0.57.0 – `API.md` lists the props of `Dashboard`; an example of the editing actions (Nov. 2026)
|
|
17
30
|
|
|
18
31
|
### Added
|
package/README.md
CHANGED
|
@@ -108,6 +108,9 @@ const { Dashboard, WidgetType } = useDashboard({
|
|
|
108
108
|
dashboard's boundary never sees the error, and it can reset the application's
|
|
109
109
|
data layer. Without one, a widget gets another try by itself when its size or
|
|
110
110
|
its options change.
|
|
111
|
+
- **`DashboardView` is the storage format.** What an application stores of it keeps
|
|
112
|
+
reading after an upgrade: an addition to it is a minor release, and renaming or
|
|
113
|
+
removing `widgets`, `type` or `size` is a major one.
|
|
111
114
|
- **The application's, not the library's:** where an arrangement is stored,
|
|
112
115
|
which default a role gets, several dashboards, sharing, and what stands in a
|
|
113
116
|
widget.
|
package/dist/dashboard.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./dashboard.css";
|
|
3
|
-
import { Component as Te, useState as Q, useRef as
|
|
4
|
-
import { useWording as pe, FormField as Fe, Input as
|
|
5
|
-
import { jsx as o, jsxs as
|
|
6
|
-
const He = (n, t) => n.widgets.some((r) => r.id === t && r.locked !== !0),
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
3
|
+
import { Component as Te, useState as Q, useRef as E, useLayoutEffect as ye, useMemo as fe, Children as Ie, isValidElement as _e, useEffect as Z, useId as Ae, Suspense as $e, useSyncExternalStore as ze, createElement as Pe } from "react";
|
|
4
|
+
import { useWording as pe, FormField as Fe, Input as je, Button as F, Text as ne, GripGlyph as xe, Heading as Be, Card as Ue, Skeleton as Ve, Drawer as We, ModalHeader as Ge, ModalBody as Ye, Popover as Ke, announce as P, Menu as Xe, MenuItem as j, MenuSeparator as oe, warnOnce as Je } from "@umriss-ui/core";
|
|
5
|
+
import { jsx as o, jsxs as R, Fragment as ae } from "react/jsx-runtime";
|
|
6
|
+
const He = (n, t) => n.widgets.some((r) => r.id === t && r.locked !== !0), qe = (n, t) => (r) => {
|
|
7
|
+
const d = r.widgets.findIndex((a) => a.id === n), M = Math.max(0, Math.min(r.widgets.length - 1, t));
|
|
8
|
+
if (d < 0 || d === M) return r;
|
|
9
9
|
const b = [...r.widgets];
|
|
10
|
-
return b.splice(M, 0, ...b.splice(
|
|
11
|
-
},
|
|
10
|
+
return b.splice(M, 0, ...b.splice(d, 1)), { ...r, widgets: b };
|
|
11
|
+
}, Qe = (n, t) => (r) => r.widgets.some((d) => d.id === n && d.locked !== !0 && d.size !== t) ? { ...r, widgets: r.widgets.map((d) => d.id === n ? { ...d, size: t } : d) } : r, Ze = (n) => (t) => He(t, n) ? { ...t, widgets: t.widgets.filter((r) => r.id !== n) } : t, et = (n, t) => {
|
|
12
12
|
let r = 1;
|
|
13
|
-
for (; n.widgets.some((
|
|
13
|
+
for (; n.widgets.some((d) => d.id === `${t}-${r}`); ) r++;
|
|
14
14
|
return `${t}-${r}`;
|
|
15
|
-
},
|
|
16
|
-
root:
|
|
17
|
-
bar:
|
|
18
|
-
mode:
|
|
19
|
-
head:
|
|
20
|
-
editingHead:
|
|
21
|
-
grip:
|
|
22
|
-
title:
|
|
23
|
-
size:
|
|
24
|
-
item:
|
|
25
|
-
placeholder:
|
|
26
|
-
grid:
|
|
27
|
-
headingRow:
|
|
28
|
-
headingHead:
|
|
29
|
-
heading:
|
|
30
|
-
body:
|
|
31
|
-
options:
|
|
32
|
-
catalogue:
|
|
33
|
-
entry:
|
|
34
|
-
footprint:
|
|
35
|
-
entryText:
|
|
15
|
+
}, tt = (n) => (t) => ({ ...t, widgets: [...t.widgets, n] }), nt = (n, t) => (r) => He(r, n) ? { ...r, widgets: r.widgets.map((d) => d.id === n ? { ...d, options: t } : d) } : r, st = "_root_1pgwl_17", rt = "_bar_1pgwl_36", ot = "_mode_1pgwl_46", at = "_head_1pgwl_61", it = "_editingHead_1pgwl_80", dt = "_grip_1pgwl_88", ct = "_title_1pgwl_93", lt = "_size_1pgwl_120", ut = "_item_1pgwl_128", ht = "_placeholder_1pgwl_138", ft = "_grid_1pgwl_144", pt = "_headingRow_1pgwl_161", gt = "_headingHead_1pgwl_76", mt = "_heading_1pgwl_76", bt = "_body_1pgwl_191", wt = "_options_1pgwl_219", yt = "_catalogue_1pgwl_224", _t = "_entry_1pgwl_232", zt = "_footprint_1pgwl_239", xt = "_entryText_1pgwl_251", x = {
|
|
16
|
+
root: st,
|
|
17
|
+
bar: rt,
|
|
18
|
+
mode: ot,
|
|
19
|
+
head: at,
|
|
20
|
+
editingHead: it,
|
|
21
|
+
grip: dt,
|
|
22
|
+
title: ct,
|
|
23
|
+
size: lt,
|
|
24
|
+
item: ut,
|
|
25
|
+
placeholder: ht,
|
|
26
|
+
grid: ft,
|
|
27
|
+
headingRow: pt,
|
|
28
|
+
headingHead: gt,
|
|
29
|
+
heading: mt,
|
|
30
|
+
body: bt,
|
|
31
|
+
options: wt,
|
|
32
|
+
catalogue: yt,
|
|
33
|
+
entry: _t,
|
|
34
|
+
footprint: zt,
|
|
35
|
+
entryText: xt
|
|
36
36
|
};
|
|
37
|
-
class
|
|
37
|
+
class Mt extends Te {
|
|
38
38
|
state = { failed: !1 };
|
|
39
39
|
static getDerivedStateFromError() {
|
|
40
40
|
return { failed: !0 };
|
|
@@ -46,64 +46,64 @@ class xt extends Te {
|
|
|
46
46
|
return this.state.failed ? this.props.fallback : this.props.children;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const ge = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Me = (n) => ge(n) && Array.isArray(n.widgets), me = (n) => n.widgets.filter((t) => ge(t) && typeof t.id == "string" && typeof t.type == "string"),
|
|
50
|
-
const r = new Set(t.widgets.map((
|
|
51
|
-
return me(n).filter((
|
|
52
|
-
},
|
|
49
|
+
const ge = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Me = (n) => ge(n) && Array.isArray(n.widgets), me = (n) => n.widgets.filter((t) => ge(t) && typeof t.id == "string" && typeof t.type == "string"), Ct = (n) => ({ ...n, widgets: me(n) }), kt = (n, t) => {
|
|
50
|
+
const r = new Set(t.widgets.map((d) => d.id));
|
|
51
|
+
return me(n).filter((d) => !r.has(d.id));
|
|
52
|
+
}, Ce = (n) => ge(n) && [Object.prototype, null].includes(Object.getPrototypeOf(n)), St = (n, t) => Ce(t) ? Ce(n) ? { ...t, ...n } : t : n === void 0 ? t : n;
|
|
53
53
|
function ve(n, t) {
|
|
54
54
|
const r = /* @__PURE__ */ new Set();
|
|
55
55
|
return {
|
|
56
56
|
...n,
|
|
57
|
-
widgets: me(n).flatMap((
|
|
58
|
-
const M = t.get(
|
|
59
|
-
return !M || r.has(
|
|
57
|
+
widgets: me(n).flatMap((d) => {
|
|
58
|
+
const M = t.get(d.type);
|
|
59
|
+
return !M || r.has(d.id) ? [] : (r.add(d.id), [{ ...d, size: Object.hasOwn(M.sizes, d.size) ? d.size : M.start, options: St(d.options, M.defaultOptions) }]);
|
|
60
60
|
})
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
function de(n, t) {
|
|
64
|
-
const r = /* @__PURE__ */ new Set(),
|
|
65
|
-
for (let
|
|
64
|
+
const r = /* @__PURE__ */ new Set(), d = (b, a, s, c) => {
|
|
65
|
+
for (let i = b; i < b + c; i++) for (let w = a; w < a + s; w++) if (r.has(i * t + w)) return !1;
|
|
66
66
|
return !0;
|
|
67
67
|
};
|
|
68
68
|
let M = 0;
|
|
69
69
|
return n.map((b) => {
|
|
70
70
|
const a = Math.min(b.columns, t);
|
|
71
71
|
for (let s = M; ; s++) {
|
|
72
|
-
const
|
|
73
|
-
if (!(
|
|
74
|
-
for (let w =
|
|
75
|
-
return M = s, { column:
|
|
72
|
+
const c = Math.floor(s / t), i = s % t;
|
|
73
|
+
if (!(i + a > t || !d(c, i, a, b.rows))) {
|
|
74
|
+
for (let w = c; w < c + b.rows; w++) for (let h = i; h < i + a; h++) r.add(w * t + h);
|
|
75
|
+
return M = s, { column: i, row: c, columns: a, rows: b.rows };
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
80
|
+
function Ot(n, t, r, d, M, { cell: b, unit: a, gap: s }) {
|
|
81
|
+
let c = r, i = 1 / 0;
|
|
82
82
|
for (let w = 0; w < n.length; w++) {
|
|
83
83
|
const h = [...n];
|
|
84
84
|
h.splice(w, 0, ...h.splice(r, 1));
|
|
85
|
-
const _ = de(h, t)[w],
|
|
86
|
-
|
|
85
|
+
const _ = de(h, t)[w], B = (_.column * (b + s) - d) ** 2 + (_.row * (a + s) - M) ** 2;
|
|
86
|
+
B < i && (i = B, c = w);
|
|
87
87
|
}
|
|
88
|
-
return
|
|
88
|
+
return c;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function Ht(n, t, r, d) {
|
|
91
91
|
const M = de(n, t)[r];
|
|
92
92
|
let b = r, a = 1 / 0, s = 1 / 0;
|
|
93
|
-
for (let
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const w = de(
|
|
93
|
+
for (let c = 0; c < n.length; c++) {
|
|
94
|
+
if (c === r) continue;
|
|
95
|
+
const i = [...n];
|
|
96
|
+
i.splice(c, 0, ...i.splice(r, 1));
|
|
97
|
+
const w = de(i, t)[c], h = (w.row - M.row) * d;
|
|
98
98
|
if (h <= 0) continue;
|
|
99
99
|
const _ = Math.abs(w.column - M.column);
|
|
100
|
-
(h < a || h === a && _ < s) && (b =
|
|
100
|
+
(h < a || h === a && _ < s) && (b = c, a = h, s = _);
|
|
101
101
|
}
|
|
102
102
|
return b;
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
106
|
-
const [b, a] = Q(null), s =
|
|
104
|
+
const vt = { 3: "¼", 4: "⅓", 6: "½", 8: "⅔", 9: "¾" }, Nt = ({ columns: n }) => n >= 12 ? "" : vt[n] ?? `${n}/12`;
|
|
105
|
+
function Dt({ grid: n, cards: t, shown: r, drop: d, cancelled: M }) {
|
|
106
|
+
const [b, a] = Q(null), s = E(null), c = E({}), i = E(/* @__PURE__ */ new Map()), w = E(null), h = E({ update: () => {
|
|
107
107
|
}, finish: () => {
|
|
108
108
|
} }), _ = () => {
|
|
109
109
|
const l = s.current, u = l && t.get(l.id);
|
|
@@ -113,31 +113,31 @@ function Nt({ grid: n, cards: t, shown: r, drop: i, cancelled: M }) {
|
|
|
113
113
|
};
|
|
114
114
|
ye(() => {
|
|
115
115
|
const l = /* @__PURE__ */ new Map(), u = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
116
|
-
for (const [g,
|
|
117
|
-
const p =
|
|
118
|
-
l.set(g, [
|
|
116
|
+
for (const [g, C] of t) {
|
|
117
|
+
const p = i.current.get(g);
|
|
118
|
+
l.set(g, [C.offsetLeft, C.offsetTop]), b && !u && p && g !== b.id && (p[0] !== C.offsetLeft || p[1] !== C.offsetTop) && C.animate([{ transform: `translate(${p[0] - C.offsetLeft}px, ${p[1] - C.offsetTop}px)` }, { transform: "none" }], { duration: 150, easing: "ease-out" });
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
i.current = l, b && _();
|
|
121
121
|
});
|
|
122
|
-
const
|
|
122
|
+
const B = () => {
|
|
123
123
|
const l = s.current, u = n.current, g = l && t.get(l.id);
|
|
124
124
|
if (!l || !u || !g) return;
|
|
125
|
-
const
|
|
125
|
+
const C = getComputedStyle(u), p = parseFloat(C.columnGap), S = C.gridTemplateColumns.split(" ").length, U = u.getBoundingClientRect(), V = r[l.from].span, W = { cell: (U.width - (S - 1) * p) / S, gap: p, unit: (g.offsetHeight - (V.rows - 1) * p) / V.rows }, L = Ot(r.map((T) => T.span), S, l.from, l.x - l.dx - U.left, l.y - l.dy - U.top, W);
|
|
126
126
|
if (L === l.target) return _();
|
|
127
127
|
l.target = L, a({ id: l.id, target: L });
|
|
128
128
|
}, ee = (l) => {
|
|
129
129
|
const u = s.current;
|
|
130
|
-
if (s.current = null, window.clearInterval(
|
|
130
|
+
if (s.current = null, window.clearInterval(c.current.timer), c.current.escape && document.removeEventListener("keydown", c.current.escape), u && t.get(u.id)?.style.removeProperty("transform"), a(null), !!u?.started) {
|
|
131
131
|
if (!l) return M(r[u.from].title);
|
|
132
|
-
|
|
132
|
+
d(u.id, r[u.target].id);
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
ye(() => {
|
|
136
|
-
h.current = { update:
|
|
136
|
+
h.current = { update: B, finish: ee };
|
|
137
137
|
});
|
|
138
138
|
const K = (l, u) => (g) => {
|
|
139
|
-
const
|
|
140
|
-
if (g.button > 0 ||
|
|
139
|
+
const C = g.target;
|
|
140
|
+
if (g.button > 0 || C.closest("button") || !g.currentTarget.contains(C)) return;
|
|
141
141
|
const p = t.get(l).getBoundingClientRect();
|
|
142
142
|
s.current = { id: l, from: u, x0: g.clientX, y0: g.clientY, x: g.clientX, y: g.clientY, dx: g.clientX - p.left, dy: g.clientY - p.top, started: !1, target: u }, g.currentTarget.setPointerCapture(g.pointerId);
|
|
143
143
|
}, A = (l) => {
|
|
@@ -145,9 +145,9 @@ function Nt({ grid: n, cards: t, shown: r, drop: i, cancelled: M }) {
|
|
|
145
145
|
if (u) {
|
|
146
146
|
if (u.x = l.clientX, u.y = l.clientY, !u.started) {
|
|
147
147
|
if (Math.hypot(u.x - u.x0, u.y - u.y0) <= 4) return;
|
|
148
|
-
u.started = !0, a({ id: u.id, target: u.from }),
|
|
149
|
-
const
|
|
150
|
-
p <= 0 || (window.scrollBy(0,
|
|
148
|
+
u.started = !0, a({ id: u.id, target: u.from }), c.current.escape = (g) => g.key === "Escape" && h.current.finish(!1), document.addEventListener("keydown", c.current.escape), c.current.timer = window.setInterval(() => {
|
|
149
|
+
const C = s.current?.y ?? window.innerHeight / 2, p = Math.ceil((64 - Math.min(C, window.innerHeight - C)) / 4);
|
|
150
|
+
p <= 0 || (window.scrollBy(0, C < window.innerHeight / 2 ? -p : p), h.current.update());
|
|
151
151
|
}, 16);
|
|
152
152
|
}
|
|
153
153
|
h.current.update();
|
|
@@ -173,11 +173,11 @@ function Et() {
|
|
|
173
173
|
return null;
|
|
174
174
|
}
|
|
175
175
|
const Rt = "heading", q = (n, t) => n.title?.(t) ?? n.label;
|
|
176
|
-
function
|
|
176
|
+
function Lt({ options: n, change: t }) {
|
|
177
177
|
const r = pe();
|
|
178
|
-
return /* @__PURE__ */ o(Fe, { label: r.dashboardHeadingField, children: /* @__PURE__ */ o(
|
|
178
|
+
return /* @__PURE__ */ o(Fe, { label: r.dashboardHeadingField, children: /* @__PURE__ */ o(je, { value: n.text, onChange: (d) => t({ text: d.target.value }) }) });
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function Tt(n) {
|
|
181
181
|
return {
|
|
182
182
|
name: Rt,
|
|
183
183
|
label: n.dashboardHeadingLabel,
|
|
@@ -186,48 +186,48 @@ function Lt(n) {
|
|
|
186
186
|
start: "full",
|
|
187
187
|
defaultOptions: { text: n.dashboardHeadingText },
|
|
188
188
|
title: (t) => t.text || n.dashboardHeadingLabel,
|
|
189
|
-
form:
|
|
189
|
+
form: Lt,
|
|
190
190
|
children: () => null
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
const se = (...n) => n.filter(Boolean).join(" "), he = 12;
|
|
194
|
-
function
|
|
194
|
+
function It({ render: n, ...t }) {
|
|
195
195
|
return n(t);
|
|
196
196
|
}
|
|
197
|
-
const
|
|
198
|
-
function
|
|
199
|
-
const
|
|
197
|
+
const ke = (n, t) => ({ "--_dashboard-column": n.column + 1, "--_dashboard-row": n.row + 1, "--_dashboard-columns": n.columns, "--_dashboard-rows": n.rows, "--_dashboard-order": t }), Se = (n) => n.columns * n.rows;
|
|
198
|
+
function At({ title: n, editing: t, children: r }) {
|
|
199
|
+
const d = E(null), [M, b] = Q(!1);
|
|
200
200
|
Z(() => {
|
|
201
|
-
const s =
|
|
201
|
+
const s = d.current;
|
|
202
202
|
if (!s) return;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
for (const _ of s.children)
|
|
206
|
-
|
|
203
|
+
const c = () => b(s.scrollHeight > s.clientHeight || s.scrollWidth > s.clientWidth), i = new ResizeObserver(c), w = () => {
|
|
204
|
+
i.disconnect(), i.observe(s);
|
|
205
|
+
for (const _ of s.children) i.observe(_);
|
|
206
|
+
c();
|
|
207
207
|
}, h = new MutationObserver(w);
|
|
208
208
|
return h.observe(s, { childList: !0 }), w(), () => {
|
|
209
|
-
|
|
209
|
+
i.disconnect(), h.disconnect();
|
|
210
210
|
};
|
|
211
211
|
}, []);
|
|
212
212
|
const a = M && !t;
|
|
213
|
-
return /* @__PURE__ */ o("div", { ref:
|
|
213
|
+
return /* @__PURE__ */ o("div", { ref: d, className: x.body, "data-widget-body": "", inert: t, ...a ? { role: "group", tabIndex: 0, "aria-label": n } : {}, children: r });
|
|
214
214
|
}
|
|
215
215
|
const ie = (n, t) => (r) => {
|
|
216
216
|
r ? n.set(t, r) : n.delete(t);
|
|
217
217
|
};
|
|
218
|
-
function
|
|
219
|
-
const s = pe(),
|
|
220
|
-
for (const e of Ie.toArray(
|
|
221
|
-
_e(e) && e.type === Ne ?
|
|
218
|
+
function $t({ view: n, editor: t, className: r, children: d, catalogue: M, headingLevel: b = 2, ...a }) {
|
|
219
|
+
const s = pe(), c = fe(() => Tt(s), [s]), i = /* @__PURE__ */ new Map();
|
|
220
|
+
for (const e of Ie.toArray(d))
|
|
221
|
+
_e(e) && e.type === Ne ? i.set(e.props.name, e.props) : _e(e) && e.type === Et && i.set(c.name, c);
|
|
222
222
|
const { register: w } = t;
|
|
223
|
-
Z(() => w(
|
|
224
|
-
const h = ve(n,
|
|
225
|
-
const f =
|
|
223
|
+
Z(() => w(i));
|
|
224
|
+
const h = ve(n, i), _ = h.widgets.flatMap((e) => {
|
|
225
|
+
const f = i.get(e.type), y = f?.sizes[e.size];
|
|
226
226
|
return f && y ? [{ widget: e, type: f, span: y }] : [];
|
|
227
|
-
}), ee = `h${Math.min(6, b + (_.some(({ type: e }) => e ===
|
|
228
|
-
const N = h.widgets.findIndex((H) => H.id === e), O = Math.max(0, Math.min(
|
|
229
|
-
N !== O && (t.step(
|
|
230
|
-
}, { drag: T, placeholder: z, handlers: m } =
|
|
227
|
+
}), ee = `h${Math.min(6, b + (_.some(({ type: e }) => e === c) ? 1 : 0))}`, K = E(null), [A] = Q(() => /* @__PURE__ */ new Map()), [l] = Q(() => /* @__PURE__ */ new Map()), [u] = Q(() => /* @__PURE__ */ new Map()), g = E(null), C = E(null), { editing: p } = t, S = h.widgets.length, U = _.map(({ widget: e, type: f }) => q(f, e.options)), V = Ae(), W = (e, f) => U.filter((y) => y === e).length > 1 ? s.dashboardHead(e, f + 1, S) : e, L = (e, f, y) => {
|
|
228
|
+
const N = h.widgets.findIndex((H) => H.id === e), O = Math.max(0, Math.min(S - 1, y));
|
|
229
|
+
N !== O && (t.step(qe(e, O)), P(s.dashboardMoved(f, N + 1, O + 1, S)));
|
|
230
|
+
}, { drag: T, placeholder: z, handlers: m } = Dt({
|
|
231
231
|
grid: K,
|
|
232
232
|
cards: A,
|
|
233
233
|
shown: _.map(({ widget: e, type: f, span: y }) => ({ id: e.id, span: y, title: q(f, e.options) })),
|
|
@@ -236,76 +236,76 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
236
236
|
L(e, q(y.type, y.widget.options), h.widgets.findIndex((N) => N.id === f));
|
|
237
237
|
},
|
|
238
238
|
cancelled: (e) => P(s.dashboardDragCancelled(e))
|
|
239
|
-
}),
|
|
240
|
-
|
|
241
|
-
const G = de(v.map((e) => _[e].span), he), X = _.map((e, f) => G[v.indexOf(f)]), [I, be] = Q(null), we =
|
|
239
|
+
}), k = T ? _.findIndex((e) => e.widget.id === T.id) : -1, v = _.map((e, f) => f);
|
|
240
|
+
k >= 0 && v.splice(T.target, 0, ...v.splice(k, 1));
|
|
241
|
+
const G = de(v.map((e) => _[e].span), he), X = _.map((e, f) => G[v.indexOf(f)]), [I, be] = Q(null), we = E(null), re = E(null);
|
|
242
242
|
Z(() => {
|
|
243
243
|
re.current && (A.get(re.current)?.scrollIntoView?.({ block: "nearest" }), re.current = null);
|
|
244
244
|
});
|
|
245
|
-
const te =
|
|
245
|
+
const te = E(!1);
|
|
246
246
|
Z(() => {
|
|
247
247
|
te.current !== !1 && ((te.current === null ? g.current : l.get(te.current))?.focus(), te.current = !1);
|
|
248
248
|
});
|
|
249
|
-
const J =
|
|
249
|
+
const J = E(null);
|
|
250
250
|
Z(() => {
|
|
251
251
|
const e = J.current;
|
|
252
|
-
J.current = null, (e === "add" ? g.current : e === "edit" ?
|
|
252
|
+
J.current = null, (e === "add" ? g.current : e === "edit" ? C.current : null)?.focus();
|
|
253
253
|
});
|
|
254
|
-
const
|
|
255
|
-
const f = { id:
|
|
256
|
-
re.current = f.id, t.step(
|
|
257
|
-
}, ce = I ?
|
|
254
|
+
const De = [...i.values()].filter((e) => !M || M.includes(e.name)), Ee = (e) => {
|
|
255
|
+
const f = { id: et(h, e.name), type: e.name, size: e.start, options: e.defaultOptions };
|
|
256
|
+
re.current = f.id, t.step(tt(f)), P(s.dashboardAdded(q(e, f.options), S + 1, S + 1));
|
|
257
|
+
}, ce = I ? i.get(h.widgets.find((e) => e.id === I)?.type ?? "") : void 0, le = h.widgets.find((e) => e.id === I), Re = (e, f, y, N, O) => p ? {
|
|
258
258
|
ref: ie(l, e.id),
|
|
259
259
|
className: se(x.head, x.editingHead),
|
|
260
260
|
...m(e.id, y),
|
|
261
261
|
role: "group",
|
|
262
262
|
tabIndex: 0,
|
|
263
|
-
"aria-label": (O ? s.dashboardHeadLocked : s.dashboardHead)(f, N + 1,
|
|
263
|
+
"aria-label": (O ? s.dashboardHeadLocked : s.dashboardHead)(f, N + 1, S),
|
|
264
264
|
"aria-describedby": V,
|
|
265
265
|
onKeyDown: (H) => {
|
|
266
266
|
if (H.target !== H.currentTarget) return;
|
|
267
|
-
const $ = { ArrowUp: -1, ArrowDown: 1 }[H.key],
|
|
268
|
-
|
|
267
|
+
const $ = { ArrowUp: -1, ArrowDown: 1 }[H.key], D = $ ? h.widgets.findIndex((Y) => Y.id === _[Ht(_.map((ue) => ue.span), he, y, $)]?.widget.id) : { ArrowLeft: N - 1, ArrowRight: N + 1, Home: 0, End: S - 1 }[H.key];
|
|
268
|
+
D !== void 0 && (H.preventDefault(), L(e.id, f, D));
|
|
269
269
|
}
|
|
270
270
|
} : { className: x.head }, Le = (e, f, y, N, O, H) => {
|
|
271
|
-
const $ = Object.entries(f.sizes).sort(([,
|
|
272
|
-
return /* @__PURE__ */
|
|
271
|
+
const $ = Object.entries(f.sizes).sort(([, D], [, Y]) => Se(D) - Se(Y));
|
|
272
|
+
return /* @__PURE__ */ R(
|
|
273
273
|
Xe,
|
|
274
274
|
{
|
|
275
275
|
align: "end",
|
|
276
276
|
trigger: /* @__PURE__ */ o(F, { ref: ie(u, e.id), size: "sm", variant: "ghost", "aria-label": s.dashboardMenu(W(y, O)), children: /* @__PURE__ */ o("svg", { viewBox: "0 0 10 10", width: "10", height: "10", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", children: /* @__PURE__ */ o("path", { d: "M1.5 5h.01M5 5h.01M8.5 5h.01" }) }) }),
|
|
277
277
|
children: [
|
|
278
|
-
/* @__PURE__ */ o(
|
|
279
|
-
/* @__PURE__ */ o(
|
|
280
|
-
/* @__PURE__ */ o(
|
|
281
|
-
/* @__PURE__ */ o(
|
|
282
|
-
/* @__PURE__ */ o(
|
|
283
|
-
H && /* @__PURE__ */
|
|
278
|
+
/* @__PURE__ */ o(j, { disabled: !0, children: s.dashboardPlace(O + 1, S) }),
|
|
279
|
+
/* @__PURE__ */ o(j, { disabled: O === 0, onSelect: () => L(e.id, y, 0), children: s.dashboardMoveStart }),
|
|
280
|
+
/* @__PURE__ */ o(j, { disabled: O === 0, onSelect: () => L(e.id, y, O - 1), children: s.dashboardMoveEarlier }),
|
|
281
|
+
/* @__PURE__ */ o(j, { disabled: O === S - 1, onSelect: () => L(e.id, y, O + 1), children: s.dashboardMoveLater }),
|
|
282
|
+
/* @__PURE__ */ o(j, { disabled: O === S - 1, onSelect: () => L(e.id, y, S - 1), children: s.dashboardMoveEnd }),
|
|
283
|
+
H && /* @__PURE__ */ R(ae, { children: [
|
|
284
284
|
/* @__PURE__ */ o(oe, {}),
|
|
285
|
-
/* @__PURE__ */ o(
|
|
285
|
+
/* @__PURE__ */ o(j, { disabled: !0, children: s.dashboardLockedLine })
|
|
286
286
|
] }),
|
|
287
|
-
!H && $.length > 1 && /* @__PURE__ */
|
|
287
|
+
!H && $.length > 1 && /* @__PURE__ */ R(ae, { children: [
|
|
288
288
|
/* @__PURE__ */ o(oe, {}),
|
|
289
|
-
$.map(([
|
|
290
|
-
|
|
289
|
+
$.map(([D, Y]) => /* @__PURE__ */ R(
|
|
290
|
+
j,
|
|
291
291
|
{
|
|
292
292
|
role: "menuitemradio",
|
|
293
|
-
"aria-checked":
|
|
293
|
+
"aria-checked": D === e.size,
|
|
294
294
|
onSelect: () => {
|
|
295
|
-
t.step(
|
|
295
|
+
t.step(Qe(e.id, D)), P(s.dashboardResized(y, s.dashboardSizes[D]));
|
|
296
296
|
},
|
|
297
297
|
children: [
|
|
298
|
-
/* @__PURE__ */ o("span", { "aria-hidden": "true", style: { display: "inline-block", width: "1.25em" }, children:
|
|
299
|
-
s.dashboardSizeEntry(s.dashboardSizes[
|
|
298
|
+
/* @__PURE__ */ o("span", { "aria-hidden": "true", style: { display: "inline-block", width: "1.25em" }, children: D === e.size ? "✓" : "" }),
|
|
299
|
+
s.dashboardSizeEntry(s.dashboardSizes[D], Nt(Y))
|
|
300
300
|
]
|
|
301
301
|
},
|
|
302
|
-
|
|
302
|
+
D
|
|
303
303
|
))
|
|
304
304
|
] }),
|
|
305
|
-
!H && f.form && /* @__PURE__ */
|
|
305
|
+
!H && f.form && /* @__PURE__ */ R(ae, { children: [
|
|
306
306
|
/* @__PURE__ */ o(oe, {}),
|
|
307
307
|
/* @__PURE__ */ o(
|
|
308
|
-
|
|
308
|
+
j,
|
|
309
309
|
{
|
|
310
310
|
onSelect: () => {
|
|
311
311
|
we.current = u.get(e.id) ?? null, be(e.id);
|
|
@@ -316,11 +316,11 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
316
316
|
] }),
|
|
317
317
|
!H && /* @__PURE__ */ o(oe, {}),
|
|
318
318
|
!H && /* @__PURE__ */ o(
|
|
319
|
-
|
|
319
|
+
j,
|
|
320
320
|
{
|
|
321
321
|
tone: "danger",
|
|
322
322
|
onSelect: () => {
|
|
323
|
-
te.current = (_[N + 1] ?? _[N - 1])?.widget.id ?? null, t.step(
|
|
323
|
+
te.current = (_[N + 1] ?? _[N - 1])?.widget.id ?? null, t.step(Ze(e.id)), P(s.dashboardRemoved(y));
|
|
324
324
|
},
|
|
325
325
|
children: s.dashboardRemove
|
|
326
326
|
}
|
|
@@ -329,7 +329,7 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
329
329
|
}
|
|
330
330
|
);
|
|
331
331
|
};
|
|
332
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ R(
|
|
333
333
|
"div",
|
|
334
334
|
{
|
|
335
335
|
role: "group",
|
|
@@ -340,7 +340,7 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
340
340
|
a.onKeyDown?.(e), !(e.key !== "Escape" || e.defaultPrevented || !p || T || t.catalogue || I || e.target.closest('[role="menu"], [role="dialog"]')) && (J.current = "edit", t.cancel());
|
|
341
341
|
},
|
|
342
342
|
children: [
|
|
343
|
-
t.allowed && /* @__PURE__ */ o("div", { className: x.bar, children: p ? /* @__PURE__ */
|
|
343
|
+
t.allowed && /* @__PURE__ */ o("div", { className: x.bar, children: p ? /* @__PURE__ */ R(ae, { children: [
|
|
344
344
|
/* @__PURE__ */ o("span", { className: x.mode, children: s.dashboardEditing }),
|
|
345
345
|
/* @__PURE__ */ o(F, { size: "sm", disabled: !t.canUndo, onClick: t.undo, children: s.dashboardUndo }),
|
|
346
346
|
/* @__PURE__ */ o(F, { size: "sm", disabled: !t.canRedo, onClick: t.redo, children: s.dashboardRedo }),
|
|
@@ -354,51 +354,51 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
354
354
|
/* @__PURE__ */ o(F, { size: "sm", variant: "primary", onClick: () => {
|
|
355
355
|
J.current = "edit", t.done();
|
|
356
356
|
}, children: s.dashboardDone })
|
|
357
|
-
] }) : /* @__PURE__ */ o(F, { ref:
|
|
357
|
+
] }) : /* @__PURE__ */ o(F, { ref: C, size: "sm", onClick: () => {
|
|
358
358
|
J.current = "add", t.edit();
|
|
359
359
|
}, children: s.dashboardEdit }) }),
|
|
360
360
|
p && /* @__PURE__ */ o("span", { id: V, hidden: !0, children: s.dashboardHeadHint }),
|
|
361
|
-
p &&
|
|
362
|
-
!p &&
|
|
363
|
-
/* @__PURE__ */
|
|
361
|
+
p && S === 0 && /* @__PURE__ */ o(ne, { children: s.dashboardEmptyEditing }),
|
|
362
|
+
!p && S === 0 && /* @__PURE__ */ o(ne, { children: s.dashboardEmpty }),
|
|
363
|
+
/* @__PURE__ */ R("div", { className: x.grid, ref: K, children: [
|
|
364
364
|
_.map(({ widget: e, type: f }, y) => {
|
|
365
|
-
const N =
|
|
366
|
-
return f ===
|
|
365
|
+
const N = ke(X[y], v.indexOf(y)), O = q(f, e.options), H = h.widgets.findIndex((ue) => ue.id === e.id), $ = e.locked === !0, D = Re(e, O, y, H, $), Y = p && Le(e, f, O, y, H, $);
|
|
366
|
+
return f === c ? /* @__PURE__ */ o("div", { ref: ie(A, e.id), className: se(x.item, x.headingRow), style: N, "data-widget": e.id, "data-editing": p || void 0, "data-dragging": T?.id === e.id || void 0, children: /* @__PURE__ */ R("div", { ...D, className: se(D.className, x.headingHead), children: [
|
|
367
367
|
p && /* @__PURE__ */ o(xe, { className: x.grip }),
|
|
368
|
-
/* @__PURE__ */ o(
|
|
368
|
+
/* @__PURE__ */ o(Be, { level: b, size: "lg", className: x.heading, children: e.options.text }),
|
|
369
369
|
p && $ && /* @__PURE__ */ o("span", { className: x.size, children: s.dashboardLocked }),
|
|
370
370
|
Y
|
|
371
|
-
] }) }, e.id) : /* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
371
|
+
] }) }, e.id) : /* @__PURE__ */ R(Ue, { ref: ie(A, e.id), className: x.item, style: N, "data-widget": e.id, "data-editing": p || void 0, "data-dragging": T?.id === e.id || void 0, "aria-label": W(O, H), children: [
|
|
372
|
+
/* @__PURE__ */ R("div", { ...D, children: [
|
|
373
373
|
p && /* @__PURE__ */ o(xe, { className: x.grip }),
|
|
374
374
|
/* @__PURE__ */ o(ee, { className: x.title, children: O }),
|
|
375
375
|
p && /* @__PURE__ */ o("span", { className: x.size, children: s.dashboardSizes[e.size] }),
|
|
376
376
|
p && $ && /* @__PURE__ */ o("span", { className: x.size, children: s.dashboardLocked }),
|
|
377
377
|
Y
|
|
378
378
|
] }),
|
|
379
|
-
/* @__PURE__ */ o(
|
|
379
|
+
/* @__PURE__ */ o(At, { title: W(O, H), editing: p, children: /* @__PURE__ */ o(Mt, { size: e.size, options: e.options, fallback: /* @__PURE__ */ o(ne, { tone: "secondary", children: s.dashboardFailed }), children: /* @__PURE__ */ o($e, { fallback: /* @__PURE__ */ o(Ve, { width: "100%", height: "100%" }), children: /* @__PURE__ */ o(It, { render: f.children, size: e.size, options: e.options }) }) }) })
|
|
380
380
|
] }, e.id);
|
|
381
381
|
}),
|
|
382
|
-
|
|
382
|
+
k >= 0 && /* @__PURE__ */ o("div", { ref: z, "aria-hidden": "true", "data-placeholder": !0, className: se(x.item, x.placeholder), style: ke(X[k], T.target) })
|
|
383
383
|
] }),
|
|
384
|
-
/* @__PURE__ */
|
|
384
|
+
/* @__PURE__ */ R(We, { open: t.catalogue, onClose: () => t.setCatalogue(!1), children: [
|
|
385
385
|
/* @__PURE__ */ o(Ge, { title: s.dashboardCatalogue, description: s.dashboardCatalogueSentence }),
|
|
386
|
-
/* @__PURE__ */ o(Ye, { children: /* @__PURE__ */ o("ul", { className: x.catalogue, children:
|
|
386
|
+
/* @__PURE__ */ o(Ye, { children: /* @__PURE__ */ o("ul", { className: x.catalogue, children: De.map((e) => {
|
|
387
387
|
const f = e.sizes[e.start];
|
|
388
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ R("li", { className: x.entry, children: [
|
|
389
389
|
/* @__PURE__ */ o("div", { className: x.footprint, role: "img", "aria-label": s.dashboardFootprint(f.columns, f.rows), children: /* @__PURE__ */ o("span", { style: { width: `${f.columns / he * 100}%`, height: `${Math.min(1, f.rows / 4) * 100}%` } }) }),
|
|
390
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ R("div", { className: x.entryText, children: [
|
|
391
391
|
/* @__PURE__ */ o(ne, { as: "strong", weight: "semibold", children: e.label }),
|
|
392
392
|
/* @__PURE__ */ o(ne, { as: "span", size: "sm", tone: "secondary", children: e.sentence })
|
|
393
393
|
] }),
|
|
394
|
-
/* @__PURE__ */ o(F, { size: "sm", "aria-label": s.dashboardAddType(e.label), onClick: () =>
|
|
394
|
+
/* @__PURE__ */ o(F, { size: "sm", "aria-label": s.dashboardAddType(e.label), onClick: () => Ee(e), children: s.dashboardAdd })
|
|
395
395
|
] }, e.name);
|
|
396
396
|
}) }) })
|
|
397
397
|
] }),
|
|
398
398
|
ce?.form && le && /* @__PURE__ */ o(Ke, { open: !0, anchorRef: we, align: "end", onOpenChange: () => be(null), role: "dialog", "aria-label": s.dashboardOptions, children: /* @__PURE__ */ o("div", { className: x.options, children: ce.form({
|
|
399
399
|
options: le.options,
|
|
400
400
|
change: (e) => {
|
|
401
|
-
t.step(
|
|
401
|
+
t.step(nt(le.id, e)), P(s.dashboardOptionsChanged(q(ce, e)));
|
|
402
402
|
}
|
|
403
403
|
}) }) })
|
|
404
404
|
]
|
|
@@ -406,97 +406,100 @@ function At({ view: n, editor: t, className: r, children: i, catalogue: M, headi
|
|
|
406
406
|
);
|
|
407
407
|
}
|
|
408
408
|
const Oe = (n, t) => JSON.stringify(n) === JSON.stringify(t);
|
|
409
|
-
function Bt({ defaultView: n, initialView: t, allowEdit: r = !0, onViewChange:
|
|
410
|
-
const b =
|
|
409
|
+
function Bt({ defaultView: n, initialView: t, allowEdit: r = !0, onViewChange: d, onDraftChange: M }) {
|
|
410
|
+
const b = E(null);
|
|
411
411
|
b.current ??= { state: { view: Me(t) ? t : n, draft: null, known: 0 }, listeners: /* @__PURE__ */ new Set(), types: /* @__PURE__ */ new Map(), signature: "" };
|
|
412
|
-
const a = b.current, s = pe(),
|
|
413
|
-
|
|
414
|
-
const
|
|
412
|
+
const a = b.current, s = pe(), c = E({ defaultView: n, allowEdit: r, onViewChange: d, onDraftChange: M, wording: s });
|
|
413
|
+
c.current = { defaultView: n, allowEdit: r, onViewChange: d, onDraftChange: M, wording: s };
|
|
414
|
+
const i = fe(() => {
|
|
415
415
|
const K = (z) => (a.listeners.add(z), () => void a.listeners.delete(z)), A = () => a.state, l = (z) => {
|
|
416
416
|
a.state = z, a.listeners.forEach((m) => m());
|
|
417
|
-
}, u = (z) => a.types.size ? ve(z, a.types) :
|
|
418
|
-
!
|
|
419
|
-
},
|
|
420
|
-
const { view: m, draft:
|
|
421
|
-
if (!
|
|
422
|
-
const v =
|
|
423
|
-
l({ ...a.state, view: G ? X : m, draft: null, catalogue: !1 }),
|
|
424
|
-
const { wording: I } =
|
|
425
|
-
P(z ? G ? I.dashboardKept : I.dashboardLeft : I.dashboardCancelled), G &&
|
|
417
|
+
}, u = (z) => a.types.size ? ve(z, a.types) : Ct(z), g = () => {
|
|
418
|
+
!c.current.allowEdit || a.state.draft || (l({ ...a.state, draft: { steps: [u(a.state.view)], at: 0 } }), c.current.onDraftChange?.(!0), P(c.current.wording.dashboardEditing));
|
|
419
|
+
}, C = (z) => {
|
|
420
|
+
const { view: m, draft: k } = a.state;
|
|
421
|
+
if (!k) return;
|
|
422
|
+
const v = k.steps[k.at], G = z && !Oe(v, u(m)), X = { ...v, widgets: [...v.widgets, ...kt(m, k.steps[0])] };
|
|
423
|
+
l({ ...a.state, view: G ? X : m, draft: null, catalogue: !1 }), c.current.onDraftChange?.(!1);
|
|
424
|
+
const { wording: I } = c.current;
|
|
425
|
+
P(z ? G ? I.dashboardKept : I.dashboardLeft : I.dashboardCancelled), G && c.current.onViewChange?.(X);
|
|
426
426
|
}, p = (z) => {
|
|
427
427
|
a.state.draft && l({ ...a.state, catalogue: z });
|
|
428
|
-
},
|
|
428
|
+
}, S = (z) => {
|
|
429
429
|
const { draft: m } = a.state;
|
|
430
430
|
if (!m) return;
|
|
431
|
-
const
|
|
432
|
-
v !==
|
|
431
|
+
const k = m.steps[m.at], v = z(k);
|
|
432
|
+
v !== k && l({ ...a.state, draft: { steps: [...m.steps.slice(0, m.at + 1), v], at: m.at + 1 } });
|
|
433
433
|
}, U = (z, m) => {
|
|
434
|
-
const { draft:
|
|
435
|
-
|
|
436
|
-
}, V = () => U(-1,
|
|
437
|
-
a.state.draft && (
|
|
438
|
-
}, T = (z, m,
|
|
434
|
+
const { draft: k } = a.state;
|
|
435
|
+
k?.steps[k.at + z] && (l({ ...a.state, draft: { ...k, at: k.at + z } }), P(m));
|
|
436
|
+
}, V = () => U(-1, c.current.wording.dashboardUndone), W = () => U(1, c.current.wording.dashboardRedone), L = () => {
|
|
437
|
+
a.state.draft && (S(() => u(c.current.defaultView)), P(c.current.wording.dashboardResetDone));
|
|
438
|
+
}, T = (z, m, k) => ({
|
|
439
439
|
allowed: z,
|
|
440
440
|
editing: m !== null,
|
|
441
441
|
edit: g,
|
|
442
|
-
done: () =>
|
|
443
|
-
cancel: () =>
|
|
444
|
-
catalogue:
|
|
442
|
+
done: () => C(!0),
|
|
443
|
+
cancel: () => C(!1),
|
|
444
|
+
catalogue: k,
|
|
445
445
|
setCatalogue: p,
|
|
446
446
|
register: (v) => {
|
|
447
447
|
a.types = v;
|
|
448
448
|
const G = [...v].map(([X, I]) => `${X}:${I.start}:${JSON.stringify(I.sizes)}`).join("|");
|
|
449
449
|
G !== a.signature && (a.signature = G, l({ ...a.state, known: a.state.known + 1 }));
|
|
450
450
|
},
|
|
451
|
-
step:
|
|
451
|
+
step: S,
|
|
452
452
|
undo: V,
|
|
453
453
|
redo: W,
|
|
454
454
|
reset: L,
|
|
455
455
|
canUndo: !!m && m.at > 0,
|
|
456
456
|
canRedo: !!m && m.at < m.steps.length - 1,
|
|
457
|
-
canReset: !!m && !Oe(m.steps[m.at], u(
|
|
457
|
+
canReset: !!m && !Oe(m.steps[m.at], u(c.current.defaultView))
|
|
458
458
|
});
|
|
459
459
|
return {
|
|
460
460
|
get: A,
|
|
461
461
|
subscribe: K,
|
|
462
462
|
edit: g,
|
|
463
|
-
done: () =>
|
|
464
|
-
cancel: () =>
|
|
463
|
+
done: () => C(!0),
|
|
464
|
+
cancel: () => C(!1),
|
|
465
465
|
undo: V,
|
|
466
466
|
redo: W,
|
|
467
467
|
reset: L,
|
|
468
|
-
|
|
468
|
+
openCatalogue: () => p(!0),
|
|
469
469
|
read: u,
|
|
470
470
|
setView: (z) => {
|
|
471
|
-
const m = Me(z) ? z :
|
|
471
|
+
const m = Me(z) ? z : c.current.defaultView;
|
|
472
472
|
l({ ...a.state, view: m, draft: a.state.draft ? { steps: [u(m)], at: 0 } : null });
|
|
473
473
|
},
|
|
474
474
|
Dashboard: (z) => {
|
|
475
|
-
const { view: m, draft:
|
|
476
|
-
return Pe(
|
|
475
|
+
const { view: m, draft: k, catalogue: v } = ze(K, A, A);
|
|
476
|
+
return Pe($t, { ...z, view: k ? k.steps[k.at] : m, editor: T(c.current.allowEdit, k, !!v) });
|
|
477
477
|
}
|
|
478
478
|
};
|
|
479
479
|
}, [a]);
|
|
480
480
|
Z(
|
|
481
481
|
() => () => {
|
|
482
|
-
b.current?.state.draft &&
|
|
482
|
+
b.current?.state.draft && c.current.onDraftChange?.(!1);
|
|
483
483
|
},
|
|
484
484
|
[]
|
|
485
485
|
);
|
|
486
|
-
const { view: w, draft: h, known: _ } = ze(
|
|
486
|
+
const { view: w, draft: h, known: _ } = ze(i.subscribe, i.get, i.get), B = h ? h.steps[h.at] : w, ee = fe(() => i.read(B), [i, B, _]);
|
|
487
487
|
return {
|
|
488
|
-
Dashboard:
|
|
488
|
+
Dashboard: i.Dashboard,
|
|
489
489
|
WidgetType: Ne,
|
|
490
490
|
view: ee,
|
|
491
|
-
setView:
|
|
491
|
+
setView: i.setView,
|
|
492
492
|
editing: h !== null,
|
|
493
|
-
edit:
|
|
494
|
-
done:
|
|
495
|
-
cancel:
|
|
496
|
-
|
|
497
|
-
undo:
|
|
498
|
-
redo:
|
|
499
|
-
reset:
|
|
493
|
+
edit: i.edit,
|
|
494
|
+
done: i.done,
|
|
495
|
+
cancel: i.cancel,
|
|
496
|
+
openCatalogue: i.openCatalogue,
|
|
497
|
+
undo: i.undo,
|
|
498
|
+
redo: i.redo,
|
|
499
|
+
reset: i.reset,
|
|
500
|
+
catalogue: () => {
|
|
501
|
+
Je("@umriss-ui/dashboard", "deprecated:useDashboard catalogue", "useDashboard's catalogue() is deprecated and goes in the next major release; use openCatalogue()."), i.openCatalogue();
|
|
502
|
+
}
|
|
500
503
|
};
|
|
501
504
|
}
|
|
502
505
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare interface DashboardParts {
|
|
|
37
37
|
/** Leaves the mode, keeps the changes and reports them once if there are any. */
|
|
38
38
|
done: () => void;
|
|
39
39
|
/** Opens the catalogue. Does nothing outside the editing mode. */
|
|
40
|
-
|
|
40
|
+
openCatalogue: () => void;
|
|
41
41
|
/** Leaves the mode and puts the arrangement back as it was before `edit`. */
|
|
42
42
|
cancel: () => void;
|
|
43
43
|
/** Goes one step back in the draft. Does nothing at the first. */
|
|
@@ -46,6 +46,9 @@ export declare interface DashboardParts {
|
|
|
46
46
|
redo: () => void;
|
|
47
47
|
/** Steps to the `defaultView`; `undo` brings the arrangement back. */
|
|
48
48
|
reset: () => void;
|
|
49
|
+
/** The old name of `openCatalogue`.
|
|
50
|
+
@deprecated since 0.58 - use openCatalogue. */
|
|
51
|
+
catalogue: () => void;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
/** The props of `Dashboard`. */
|
|
@@ -63,7 +66,9 @@ export declare interface DashboardProps extends HTMLAttributes<HTMLDivElement>,
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/** The arrangement of a dashboard: which widgets, in what order, at which
|
|
66
|
-
sizes, with which options. An object, so that more can join it later.
|
|
69
|
+
sizes, with which options. An object, so that more can join it later.
|
|
70
|
+
It is the supported storage format: an addition is a minor release, and renaming
|
|
71
|
+
or removing `widgets`, `type` or `size` is a major one. */
|
|
67
72
|
export declare interface DashboardView {
|
|
68
73
|
/** The widgets, in the order they are drawn and read. */
|
|
69
74
|
widgets: ReadonlyArray<DashboardWidget>;
|
package/docs/llms-full.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @umriss-ui/dashboard 0.
|
|
1
|
+
# @umriss-ui/dashboard 0.58.0
|
|
2
2
|
|
|
3
3
|
> React dashboard for data-dense applications - widgets a reader arranges, packed in order on twelve columns.
|
|
4
4
|
|
|
@@ -775,11 +775,12 @@ Every move, size, removal, addition, undo, redo, reset, "Done" and "Cancel" is a
|
|
|
775
775
|
| `editing` *required* | `boolean` | — | Whether the editing mode is on.<br>Shown in: [The editing actions in the application's own header](#dashboard), [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
776
776
|
| `edit` *required* | `() => void` | — | Enters the editing mode. Does nothing where editing is not allowed.<br>Shown in: [The editing actions in the application's own header](#dashboard), [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
777
777
|
| `done` *required* | `() => void` | — | Leaves the mode, keeps the changes and reports them once if there are any.<br>Shown in: [The editing actions in the application's own header](#dashboard), [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
778
|
-
| `
|
|
778
|
+
| `openCatalogue` *required* | `() => void` | — | Opens the catalogue. Does nothing outside the editing mode.<br>Shown in: [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
779
779
|
| `cancel` *required* | `() => void` | — | Leaves the mode and puts the arrangement back as it was before `edit`.<br>Shown in: [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
780
780
|
| `undo` *required* | `() => void` | — | Goes one step back in the draft. Does nothing at the first.<br>Shown in: [The editing actions in the application's own header](#dashboard), [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
781
781
|
| `redo` *required* | `() => void` | — | Goes one step forward again. Does nothing at the last.<br>Shown in: [The editing actions in the application's own header](#dashboard) |
|
|
782
782
|
| `reset` *required* | `() => void` | — | Steps to the `defaultView`; `undo` brings the arrangement back.<br>Shown in: [Arrange the start screen (Scenarios)](#arrange-the-start-screen) |
|
|
783
|
+
| `catalogue` *required* | `() => void` | — | *Deprecated* since 0.58 - use openCatalogue. The old name of `openCatalogue`. |
|
|
783
784
|
|
|
784
785
|
##### `DashboardProps`
|
|
785
786
|
|
|
@@ -860,7 +861,7 @@ Declares no props of its own.
|
|
|
860
861
|
- Never: stacks of widgets that share one place, coordinates and free placement, a layout per breakpoint, dense packing, dragging from the catalogue to a chosen place ([ADR-0064](https://github.com/romanhaendler/umriss-ui/blob/main/docs/adr/0064-a-dashboard-a-user-arranges-is-a-sequence-on-fixed-columns.md)).
|
|
861
862
|
- Where an arrangement is stored, which default a role gets, several dashboards and what stands in a widget are the application's.
|
|
862
863
|
|
|
863
|
-
What umriss deliberately does not build, and why: [ADR-0032](https://github.com/romanhaendler/umriss-ui/blob/dashboard-v0.
|
|
864
|
+
What umriss deliberately does not build, and why: [ADR-0032](https://github.com/romanhaendler/umriss-ui/blob/dashboard-v0.58.0/docs/adr/0032-what-umriss-is-not.md).
|
|
864
865
|
|
|
865
866
|
## API index
|
|
866
867
|
|
|
@@ -1217,7 +1218,7 @@ function Stage({ shown }: { shown: Case }) {
|
|
|
1217
1218
|
rearranging: [
|
|
1218
1219
|
<Button key="edit" onClick={edit} disabled={parts.editing}>Edit</Button>,
|
|
1219
1220
|
<Button key="undo" onClick={() => { parts.undo(); setSaid("One step back, not all of them."); }} disabled={!parts.editing}>Undo</Button>,
|
|
1220
|
-
<Button key="catalogue" onClick={() => { parts.
|
|
1221
|
+
<Button key="catalogue" onClick={() => { parts.openCatalogue(); setSaid("Every widget type with its name, a sentence and the room it takes. A new widget shows something at once and stands at the end."); }} disabled={!parts.editing}>Add a widget</Button>,
|
|
1221
1222
|
<Button key="done" onClick={() => { parts.done(); setSaid("Only now, and once, the application is told the whole arrangement."); }} disabled={!parts.editing}>Done</Button>,
|
|
1222
1223
|
],
|
|
1223
1224
|
wrong: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umriss-ui/dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "React dashboard for data-dense applications - widgets a reader arranges, packed in order on twelve columns.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Roman Händler",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"node": ">=22"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@umriss-ui/core": "^0.
|
|
61
|
+
"@umriss-ui/core": "^0.58.0",
|
|
62
62
|
"react": "^19",
|
|
63
63
|
"react-dom": "^19"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@fontsource/geist-mono": "^5.3.0",
|
|
67
67
|
"@fontsource/geist-sans": "^5.3.0",
|
|
68
|
-
"@umriss-ui/core": "0.
|
|
68
|
+
"@umriss-ui/core": "0.58.0",
|
|
69
69
|
"@umriss-ui/demo": "0.0.0",
|
|
70
70
|
"@types/node": "^22.20.2",
|
|
71
71
|
"@types/react": "^19.0.0",
|