@nxgt/material 3.6.0 → 3.7.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +46 -1
  3. package/dist/components/components.css +2 -0
  4. package/dist/components/theme-tokens.css +9 -4
  5. package/dist/components/ui/widgets/drawing/drawing-animate.css +123 -0
  6. package/dist/components/ui/widgets/drawing/drawing.css +459 -0
  7. package/dist/{components-BCYZgeoV.js → components-BX4icy-g.js} +733 -733
  8. package/dist/components.js +16 -16
  9. package/dist/{dialog-JQT6iETD.js → dialog-DdJ1C4BR.js} +168 -168
  10. package/dist/dnd.js +1 -1
  11. package/dist/draw-animate.js +106 -0
  12. package/dist/draw-png.js +2 -0
  13. package/dist/draw-sketch.js +38 -0
  14. package/dist/draw.js +65 -0
  15. package/dist/drawing-B8VuG7nx.js +390 -0
  16. package/dist/drawing-context-CeKeZE6b.js +10 -0
  17. package/dist/editor.js +110 -110
  18. package/dist/{icon-badge-C30yKsAM.js → icon-badge-Bb5-73XP.js} +18 -18
  19. package/dist/{icon-button-BXlI3DJ_.js → icon-button-5A6Mrj6w.js} +60 -90
  20. package/dist/lib/components/ui/display/shape/use-shape-morph.d.ts +1 -0
  21. package/dist/lib/components/ui/widgets/drawing/drawing-a11y.d.ts +20 -0
  22. package/dist/lib/components/ui/widgets/drawing/drawing-context.d.ts +23 -0
  23. package/dist/lib/components/ui/widgets/drawing/drawing-types.d.ts +63 -0
  24. package/dist/lib/components/ui/widgets/drawing/drawing.d.ts +17 -0
  25. package/dist/lib/components/ui/widgets/drawing/index.d.ts +5 -0
  26. package/dist/lib/components/ui/widgets/drawing/partials/drawing-root.d.ts +17 -0
  27. package/dist/lib/components/ui/widgets/drawing/partials/interactive-node.d.ts +22 -0
  28. package/dist/lib/components/ui/widgets/drawing/partials/primitives/content.d.ts +20 -0
  29. package/dist/lib/components/ui/widgets/drawing/partials/primitives/path.d.ts +29 -0
  30. package/dist/lib/components/ui/widgets/drawing/partials/primitives/primitive.d.ts +19 -0
  31. package/dist/lib/components/ui/widgets/drawing/partials/primitives/shapes.d.ts +18 -0
  32. package/dist/lib/components/ui/widgets/drawing/partials/react-attrs.d.ts +5 -0
  33. package/dist/lib/components/ui/widgets/drawing/partials/ring.d.ts +9 -0
  34. package/dist/lib/components/ui/widgets/drawing/partials/svg-tree.d.ts +29 -0
  35. package/dist/lib/components/ui/widgets/drawing/use-exact-text.d.ts +16 -0
  36. package/dist/lib/draw/index.d.ts +32 -0
  37. package/dist/lib/draw-animate/index.d.ts +19 -0
  38. package/dist/lib/draw-animate/morph-drawing.d.ts +32 -0
  39. package/dist/lib/draw-animate/reduced-motion.d.ts +2 -0
  40. package/dist/lib/draw-animate/use-drawing-controls.d.ts +27 -0
  41. package/dist/lib/draw-animate/use-scene-morph.d.ts +15 -0
  42. package/dist/lib/draw-png/index.d.ts +11 -0
  43. package/dist/lib/draw-sketch/index.d.ts +17 -0
  44. package/dist/lib/draw-sketch/sketch.d.ts +19 -0
  45. package/dist/lib/print/components/print-drawing.d.ts +16 -0
  46. package/dist/lib/print/index.d.ts +2 -1
  47. package/dist/main.js +21 -21
  48. package/dist/map.js +63 -63
  49. package/dist/material.css +1 -1
  50. package/dist/pdf-reader.js +1 -1
  51. package/dist/print.js +123 -115
  52. package/dist/{public-Cde8_SN8.js → public-CBlV2XuA.js} +742 -742
  53. package/dist/{sortable-provider-DYlpq8lP.js → sortable-provider-BvD98s8Y.js} +19 -19
  54. package/dist/{use-chat-composer-BwpSgP_D.js → use-chat-composer-BhdPNmYm.js} +912 -911
  55. package/dist/use-shape-morph-BKA_R5P5.js +35 -0
  56. package/docs/README.md +1 -0
  57. package/docs/components/rich-widgets.md +196 -0
  58. package/docs/guides/drawing.md +499 -0
  59. package/docs/guides/printing.md +47 -0
  60. package/docs/guides/theming.md +2 -2
  61. package/docs/previews/rich-widgets-drawing.webp +0 -0
  62. package/docs/roadmap.md +17 -0
  63. package/docs/troubleshooting.md +136 -1
  64. package/lib/components/components.css +2 -0
  65. package/lib/components/theme-tokens.css +9 -4
  66. package/lib/components/ui/widgets/drawing/drawing-animate.css +123 -0
  67. package/lib/components/ui/widgets/drawing/drawing.css +459 -0
  68. package/package.json +22 -2
@@ -0,0 +1,106 @@
1
+ import { t as e } from "./use-shape-morph-BKA_R5P5.js";
2
+ import { t } from "./drawing-B8VuG7nx.js";
3
+ import { useEffect as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
4
+ import { jsx as s } from "react/jsx-runtime";
5
+ import { compileScene as c } from "@nxgt/material-core/draw";
6
+ import { MAX_STEP as l, appear as u, drawOn as d, morphScenes as f, morphScenes as p, staggerSteps as m } from "@nxgt/material-core/draw/animate";
7
+ //#region lib/draw-animate/reduced-motion.ts
8
+ var h = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
9
+ //#endregion
10
+ //#region lib/draw-animate/morph-drawing.tsx
11
+ function g(e, t = /* @__PURE__ */ new Map()) {
12
+ e.tag === "path" && e.node !== void 0 && "d" in e.attrs && t.set(e.node, String(e.attrs.d));
13
+ for (let n of e.children ?? []) typeof n != "string" && g(n, t);
14
+ return t;
15
+ }
16
+ var _ = (e, t, n) => g(c(p(e, t, n), { idPrefix: "mm" }));
17
+ function v({ from: n, to: i, active: o, ...c }) {
18
+ let l = a(null), u = a(+!!o);
19
+ return r(() => {
20
+ let t = l.current, r = +!!o, a = u.current;
21
+ if (!t || a === r) return;
22
+ let [s, c, d] = [
23
+ 0,
24
+ 1,
25
+ .5
26
+ ].map((e) => _(n, i, e)), f = new Set([...d].flatMap(([e, t]) => t !== s?.get(e) && t !== c?.get(e) ? [e] : [])), p = (e) => {
27
+ for (let [n, r] of e) {
28
+ if (!f.has(n)) continue;
29
+ let e = t.querySelector(`[data-id="${CSS.escape(n)}"]`);
30
+ e?.localName === "path" && e.setAttribute("d", r);
31
+ }
32
+ };
33
+ if (h()) {
34
+ u.current = r;
35
+ return;
36
+ }
37
+ let m = _(n, i, r), g = performance.now(), v = 0;
38
+ p(_(n, i, a));
39
+ let y = (t) => {
40
+ let o = t - g;
41
+ if (o >= 520) {
42
+ u.current = r, p(m);
43
+ return;
44
+ }
45
+ u.current = Math.min(1, Math.max(0, a + (r - a) * e(o))), p(_(n, i, u.current)), v = requestAnimationFrame(y);
46
+ };
47
+ return v = requestAnimationFrame(y), () => cancelAnimationFrame(v);
48
+ }, [
49
+ o,
50
+ n,
51
+ i
52
+ ]), /* @__PURE__ */ s(t, {
53
+ ...c,
54
+ ref: l,
55
+ scene: o ? i : n
56
+ });
57
+ }
58
+ //#endregion
59
+ //#region lib/draw-animate/use-drawing-controls.ts
60
+ var y = (e) => "animationName" in e && String(e.animationName).startsWith("nxgt-draw-");
61
+ function b(e) {
62
+ return i(() => {
63
+ let t = () => (e.current?.getAnimations?.({ subtree: !0 }) ?? []).filter(y);
64
+ return {
65
+ play: () => {
66
+ for (let e of t()) e.play();
67
+ },
68
+ pause: () => {
69
+ for (let e of t()) e.pause();
70
+ },
71
+ replay: () => {
72
+ for (let e of t()) e.currentTime = 0, e.play();
73
+ },
74
+ finish: () => {
75
+ for (let e of t()) e.finish();
76
+ },
77
+ finished: async () => {
78
+ await Promise.allSettled(t().map((e) => e.finished));
79
+ }
80
+ };
81
+ }, [e]);
82
+ }
83
+ //#endregion
84
+ //#region lib/draw-animate/use-scene-morph.ts
85
+ function x(t, r, s) {
86
+ let c = +!!s, [l, u] = o(c), d = a(c);
87
+ return n(() => {
88
+ let t = d.current;
89
+ if (t === c) return;
90
+ if (h()) {
91
+ d.current = c, u(c);
92
+ return;
93
+ }
94
+ let n = performance.now(), r = 0, i = (a) => {
95
+ let o = a - n;
96
+ d.current = o >= 520 ? c : Math.min(1, Math.max(0, t + (c - t) * e(o))), u(d.current), o < 520 && (r = requestAnimationFrame(i));
97
+ };
98
+ return r = requestAnimationFrame(i), () => cancelAnimationFrame(r);
99
+ }, [c]), i(() => p(t, r, l), [
100
+ t,
101
+ r,
102
+ l
103
+ ]);
104
+ }
105
+ //#endregion
106
+ export { l as MAX_STEP, v as MorphDrawing, u as appear, d as drawOn, f as morphScenes, m as staggerSteps, b as useDrawingControls, x as useSceneMorph };
@@ -0,0 +1,2 @@
1
+ import { downloadDrawingPng as e, drawingToPng as t } from "@nxgt/material-core/draw/png";
2
+ export { e as downloadDrawingPng, t as drawingToPng };
@@ -0,0 +1,38 @@
1
+ import { n as e, t } from "./drawing-context-CeKeZE6b.js";
2
+ import { useMemo as n } from "react";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ import { sketch as i, sketch as a } from "@nxgt/material-core/draw/sketch";
5
+ //#region lib/draw-sketch/sketch.tsx
6
+ function o({ children: i, seed: o, roughness: s, bowing: c, fill: l, hachureAngle: u, hachureGap: d, strokeWidth: f }) {
7
+ let p = e(), m = n(() => {
8
+ let e = {
9
+ seed: o,
10
+ roughness: s,
11
+ bowing: c,
12
+ fill: l,
13
+ hachureAngle: u,
14
+ hachureGap: d,
15
+ strokeWidth: f
16
+ };
17
+ return {
18
+ ...p,
19
+ transform: (t) => a(t, e),
20
+ transformScene: (t) => a(t, e)
21
+ };
22
+ }, [
23
+ p,
24
+ o,
25
+ s,
26
+ c,
27
+ l,
28
+ u,
29
+ d,
30
+ f
31
+ ]);
32
+ return /* @__PURE__ */ r(t.Provider, {
33
+ value: m,
34
+ children: i
35
+ });
36
+ }
37
+ //#endregion
38
+ export { o as Sketch, i as sketch };
package/dist/draw.js ADDED
@@ -0,0 +1,65 @@
1
+ import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./drawing-B8VuG7nx.js";
2
+ import { Children as c } from "react";
3
+ import { jsx as l } from "react/jsx-runtime";
4
+ import { DRAW_PALETTE as u, ROLES as d, ROLE_VARS as f, assertSafeDrawing as p, circle as m, compileNode as h, compileScene as g, drawIdPrefix as _, ellipse as v, estimateTextWidth as y, group as b, group as x, hatch as S, image as C, image as w, line as T, linear as E, parsePath as D, path as O, path as k, pattern as A, polygon as j, radial as M, rect as N, scene as P, text as F, text as I, toSVG as L, tone as R } from "@nxgt/material-core/draw";
5
+ import { align as z, bbox as B, distribute as V, grid as H, stack as U } from "@nxgt/material-core/draw/layout";
6
+ import { SHAPE_NAMES as W, morph as G, shape as K, toCubics as q } from "@nxgt/material-core/draw/shapes";
7
+ //#region lib/components/ui/widgets/drawing/partials/primitives/content.tsx
8
+ var J = (e) => c.toArray(e).filter((e) => typeof e == "string" || typeof e == "number").join("");
9
+ function Y(e) {
10
+ let [n, r] = t(e), { children: i, ...a } = r;
11
+ return /* @__PURE__ */ l(o, {
12
+ node: I(J(i), a),
13
+ events: n
14
+ });
15
+ }
16
+ function X(e) {
17
+ let [n, r] = t(e), { children: i, ...a } = r;
18
+ return /* @__PURE__ */ l(o, {
19
+ node: x(a, []),
20
+ events: n,
21
+ slot: i ?? null
22
+ });
23
+ }
24
+ function Z(e) {
25
+ let [n, r] = t(e);
26
+ return /* @__PURE__ */ l(o, {
27
+ node: w(r),
28
+ events: n
29
+ });
30
+ }
31
+ //#endregion
32
+ //#region lib/components/ui/widgets/drawing/partials/primitives/path.tsx
33
+ var Q = [
34
+ "id",
35
+ "label",
36
+ "interactive",
37
+ "fill",
38
+ "stroke",
39
+ "strokeWidth",
40
+ "opacity",
41
+ "transform",
42
+ "clip",
43
+ "mask",
44
+ "className",
45
+ "anim",
46
+ "meta",
47
+ "arrow"
48
+ ];
49
+ function $(e) {
50
+ let [n, r] = t(e), { d: i, build: a, node: s, ...c } = r, u;
51
+ if (s) {
52
+ let e = {};
53
+ for (let t of Q) c[t] !== void 0 && (e[t] = c[t]);
54
+ u = {
55
+ ...s,
56
+ ...e
57
+ };
58
+ } else u = k(i ?? a ?? ((e) => e), c);
59
+ return /* @__PURE__ */ l(o, {
60
+ node: u,
61
+ events: n
62
+ });
63
+ }
64
+ //#endregion
65
+ export { r as Circle, u as DRAW_PALETTE, s as Drawing, a as Ellipse, X as Group, Z as Image, n as Line, $ as Path, e as Polygon, d as ROLES, f as ROLE_VARS, i as Rect, W as SHAPE_NAMES, Y as Text, z as align, p as assertSafeDrawing, B as bbox, m as circle, h as compileNode, g as compileScene, V as distribute, _ as drawIdPrefix, v as ellipse, y as estimateTextWidth, H as grid, b as group, S as hatch, C as image, T as line, E as linear, G as morph, D as parsePath, O as path, A as pattern, j as polygon, M as radial, N as rect, P as scene, K as shape, U as stack, F as text, q as toCubics, L as toSVG, R as tone };
@@ -0,0 +1,390 @@
1
+ import { n as e, t } from "./drawing-context-CeKeZE6b.js";
2
+ import { createElement as n, useCallback as r, useId as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
3
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ import { circle as d, compileNode as f, compileScene as p, drawIdPrefix as m, ellipse as h, line as g, polygon as _, rect as v } from "@nxgt/material-core/draw";
5
+ //#region lib/components/ui/widgets/drawing/drawing-a11y.ts
6
+ function y(e) {
7
+ return e.decorative ? "none" : e.interactive ? "group" : "img";
8
+ }
9
+ function b(e, t) {
10
+ return e === "none" ? {
11
+ "aria-hidden": "true",
12
+ focusable: "false"
13
+ } : t === void 0 ? {} : {
14
+ role: e,
15
+ "aria-label": t
16
+ };
17
+ }
18
+ function x(e) {
19
+ return e.interactive ? {
20
+ role: e.clickable ? "button" : "img",
21
+ tabIndex: 0,
22
+ "aria-label": e.label
23
+ } : e.label !== void 0 && e.root === "group" ? {
24
+ role: "img",
25
+ "aria-label": e.label
26
+ } : {};
27
+ }
28
+ //#endregion
29
+ //#region lib/components/ui/widgets/drawing/partials/drawing-root.tsx
30
+ function S({ role: e, title: t, attrs: r, rest: i, children: a }) {
31
+ return n("svg", {
32
+ xmlns: "http://www.w3.org/2000/svg",
33
+ ...i,
34
+ ...r,
35
+ ...b(e, t),
36
+ "data-slot": "drawing"
37
+ }, a);
38
+ }
39
+ //#endregion
40
+ //#region lib/components/ui/widgets/drawing/use-exact-text.ts
41
+ var C = {
42
+ sans: "Inter Variable, Inter, system-ui, sans-serif",
43
+ serif: "Georgia, serif",
44
+ mono: "ui-monospace, monospace"
45
+ };
46
+ function w(e, t, n) {
47
+ let r = [];
48
+ for (let i of e.split("\n")) {
49
+ let e = "";
50
+ for (let a of i.split(" ")) {
51
+ let i = e ? `${e} ${a}` : a;
52
+ if (n(i) <= t) {
53
+ e = i;
54
+ continue;
55
+ }
56
+ e && r.push(e), e = "";
57
+ for (let i of a) e && n(e + i) > t && (r.push(e), e = ""), e += i;
58
+ }
59
+ r.push(e);
60
+ }
61
+ return r;
62
+ }
63
+ function T() {
64
+ try {
65
+ let e = document.createElement("canvas").getContext("2d");
66
+ return e ? (t) => (e.font = t, (t) => e.measureText(t).width) : void 0;
67
+ } catch {
68
+ return;
69
+ }
70
+ }
71
+ function E(e, t, n) {
72
+ if (e.type === "group") {
73
+ let r = e.children.map((e) => E(e, t, n));
74
+ return r.some((t, n) => t !== e.children[n]) ? {
75
+ ...e,
76
+ children: r
77
+ } : e;
78
+ }
79
+ if (e.type !== "text" || e.maxWidth === void 0) return e;
80
+ let r = e.size ?? t?.size ?? 14, i = `${e.italic ? "italic " : ""}${e.weight ?? 400} ${r}px ${C[t?.family ?? "sans"]}`, a = w(e.text, e.maxWidth, n(i)), { maxWidth: o, ...s } = e;
81
+ return {
82
+ ...s,
83
+ text: a.join("\n")
84
+ };
85
+ }
86
+ function D(e) {
87
+ return "version" in e || e.type === "group" ? e.children.some(D) : e.type === "text" && e.maxWidth !== void 0;
88
+ }
89
+ function O(e, t) {
90
+ let n = T();
91
+ if (!n) return e;
92
+ let r = (e) => n(e);
93
+ if ("version" in e) {
94
+ let t = e.children.map((t) => E(t, e.font, r));
95
+ return {
96
+ ...e,
97
+ children: t
98
+ };
99
+ }
100
+ return E(e, t, r);
101
+ }
102
+ function k(e, t, n) {
103
+ let r = s(e);
104
+ r.current = e;
105
+ let i = o(() => t && D(e) ? JSON.stringify([e, n]) : "", [
106
+ e,
107
+ t,
108
+ n
109
+ ]), [l, u] = c();
110
+ return a(() => {
111
+ if (!i) return;
112
+ let e = !0, t = () => {
113
+ let t = O(r.current, n);
114
+ e && t !== r.current && u({
115
+ signature: i,
116
+ value: t
117
+ });
118
+ };
119
+ return t(), document.fonts?.ready.then(t), () => {
120
+ e = !1;
121
+ };
122
+ }, [i, n]), l && l.signature === i ? l.value : e;
123
+ }
124
+ //#endregion
125
+ //#region lib/components/ui/widgets/drawing/partials/interactive-node.tsx
126
+ function A(e) {
127
+ let { id: t, handlers: r, onNodeClick: i, children: a } = e, o = r.onClick !== void 0 || i !== void 0 && t !== void 0;
128
+ return n("g", {
129
+ ...x({
130
+ interactive: !0,
131
+ clickable: o,
132
+ label: e.label,
133
+ root: e.root
134
+ }),
135
+ "data-id": t,
136
+ className: e.outline ? "nxgt-draw-i nxgt-draw-ig" : "nxgt-draw-i",
137
+ onClick: o ? (e) => {
138
+ r.onClick?.(e), t !== void 0 && i?.(t, e);
139
+ } : void 0,
140
+ onKeyDown: (e) => {
141
+ r.onKeyDown?.(e), !(!o || e.defaultPrevented) && e.target === e.currentTarget && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.currentTarget.dispatchEvent(new MouseEvent("click", {
142
+ bubbles: !0,
143
+ cancelable: !0
144
+ }))));
145
+ },
146
+ onPointerEnter: r.onPointerEnter,
147
+ onPointerLeave: r.onPointerLeave,
148
+ onPointerDown: r.onPointerDown,
149
+ onPointerUp: r.onPointerUp,
150
+ onFocus: r.onFocus,
151
+ onBlur: r.onBlur
152
+ }, a);
153
+ }
154
+ //#endregion
155
+ //#region lib/components/ui/widgets/drawing/partials/react-attrs.ts
156
+ var j = /^(aria|data)-/;
157
+ function M(e) {
158
+ return e === "class" ? "className" : j.test(e) ? e : e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
159
+ }
160
+ function N(e) {
161
+ let t = {};
162
+ for (let [n, r] of Object.entries(e)) t[M(n)] = r;
163
+ return t;
164
+ }
165
+ //#endregion
166
+ //#region lib/components/ui/widgets/drawing/partials/ring.ts
167
+ var P = new Set("x y dy width height cx cy rx ry x1 y1 x2 y2 d points transform pathLength font-family font-size font-weight font-style text-anchor".split(" "));
168
+ function F(e) {
169
+ if (e.tag === "defs" || e.tag === "text" || e.tag === "tspan" || e.attrs["data-m-sketch"] === "fill") return;
170
+ let t = {};
171
+ for (let [n, r] of Object.entries(e.attrs)) P.has(n) && (t[n] = r);
172
+ let n = e.children?.map((e) => typeof e == "string" ? e : F(e)).filter((e) => e !== void 0);
173
+ return e.tag === "g" ? n?.length ? {
174
+ tag: "g",
175
+ attrs: t,
176
+ children: n
177
+ } : void 0 : (t.class = "nxgt-draw-ring", e.tag === "image" ? {
178
+ tag: "rect",
179
+ attrs: t
180
+ } : {
181
+ tag: e.tag,
182
+ attrs: t,
183
+ children: n
184
+ });
185
+ }
186
+ //#endregion
187
+ //#region lib/components/ui/widgets/drawing/partials/svg-tree.tsx
188
+ var I = (e, t) => Object.keys(e).includes(t), L = {};
189
+ function R(e, t) {
190
+ let n = e.node !== void 0 && I(t.handlers ?? L, e.node) ? (t.handlers ?? L)[e.node] : void 0;
191
+ return n ? t.self && e.interactive ? {
192
+ ...t.self,
193
+ ...n
194
+ } : n : e.interactive ? t.self ?? {} : void 0;
195
+ }
196
+ function z(e, t = L) {
197
+ return e.interactive || e.node !== void 0 && I(t, e.node) ? !0 : (e.children ?? []).some((e) => typeof e != "string" && z(e, t));
198
+ }
199
+ var B = (e) => e.tag === "g" && !e.children?.length;
200
+ function V(e, t, r) {
201
+ let i = R(e, t), a = N(e.attrs);
202
+ if (e.node !== void 0 && !i && (a["data-id"] = e.node), !i) {
203
+ let n = x({
204
+ interactive: !1,
205
+ clickable: !1,
206
+ label: e.label,
207
+ root: t.root
208
+ });
209
+ Object.assign(a, n);
210
+ }
211
+ let o = (e.children ?? []).map((e, n) => typeof e == "string" ? e : V(e, t, `${r}.${n}`)), s = t.slot !== void 0 && B(e);
212
+ s && o.push(t.slot);
213
+ let c = e.node === void 0 ? `p:${r}` : `n:${e.node}`;
214
+ if (!i) return n(e.tag, {
215
+ ...a,
216
+ key: c
217
+ }, ...o);
218
+ let l = s ? void 0 : F(e);
219
+ return /* @__PURE__ */ u(A, {
220
+ id: e.node,
221
+ label: e.label,
222
+ handlers: i,
223
+ onNodeClick: t.onNodeClick,
224
+ root: t.root,
225
+ outline: s || !l,
226
+ children: [n(e.tag, a, ...o), l && V(l, t, `${r}.ring`)]
227
+ }, c);
228
+ }
229
+ function H({ el: e, ...t }) {
230
+ return V(e, t, "0");
231
+ }
232
+ function U({ el: e, ...t }) {
233
+ return (e.children ?? []).map((e, n) => typeof e == "string" ? e : V(e, t, `0.${n}`));
234
+ }
235
+ //#endregion
236
+ //#region lib/components/ui/widgets/drawing/partials/primitives/primitive.tsx
237
+ var W = [
238
+ "onClick",
239
+ "onPointerEnter",
240
+ "onPointerLeave",
241
+ "onPointerDown",
242
+ "onPointerUp",
243
+ "onFocus",
244
+ "onBlur",
245
+ "onKeyDown"
246
+ ];
247
+ function G(e) {
248
+ let t = {}, n = { ...e };
249
+ for (let r of W) e[r] !== void 0 && (t[r] = e[r]), delete n[r];
250
+ return [t, n];
251
+ }
252
+ function K({ node: t, events: n, slot: r }) {
253
+ let o = e(), s = m(i()), c = t.interactive === !0 || Object.keys(n).length > 0;
254
+ if (c && o.decorative) throw Error("A decorative drawing has an interactive node: give the Drawing a title instead");
255
+ let { register: u } = o;
256
+ a(() => c ? u() : void 0, [c, u]);
257
+ let d = k(t, o.exactText && t.type === "text"), p = c ? {
258
+ ...d,
259
+ interactive: !0
260
+ } : d;
261
+ return /* @__PURE__ */ l(H, {
262
+ el: f(o.transform?.(p) ?? p, {
263
+ idPrefix: s,
264
+ colors: "class"
265
+ }),
266
+ self: n,
267
+ root: o.root,
268
+ onNodeClick: o.onNodeClick,
269
+ slot: r
270
+ });
271
+ }
272
+ //#endregion
273
+ //#region lib/components/ui/widgets/drawing/partials/primitives/shapes.tsx
274
+ function q(e) {
275
+ let [t, n] = G(e);
276
+ return /* @__PURE__ */ l(K, {
277
+ node: v(n),
278
+ events: t
279
+ });
280
+ }
281
+ function J(e) {
282
+ let [t, n] = G(e);
283
+ return /* @__PURE__ */ l(K, {
284
+ node: h(n),
285
+ events: t
286
+ });
287
+ }
288
+ function Y(e) {
289
+ let [t, n] = G(e);
290
+ return /* @__PURE__ */ l(K, {
291
+ node: d(n),
292
+ events: t
293
+ });
294
+ }
295
+ function X(e) {
296
+ let [t, n] = G(e);
297
+ return /* @__PURE__ */ l(K, {
298
+ node: g(n),
299
+ events: t
300
+ });
301
+ }
302
+ function Z(e) {
303
+ let [t, n] = G(e);
304
+ return /* @__PURE__ */ l(K, {
305
+ node: _(n),
306
+ events: t
307
+ });
308
+ }
309
+ //#endregion
310
+ //#region lib/components/ui/widgets/drawing/drawing.tsx
311
+ var Q = "A decorative drawing has an interactive node: give the Drawing a title instead";
312
+ function $(t) {
313
+ let { scene: n, handlers: r, onNodeClick: a, title: s, decorative: c, exactText: u, ...d } = t, f = m(i()), { transformScene: h } = e(), g = k(n, u !== !1), _ = o(() => p(h?.(g) ?? g, {
314
+ idPrefix: f,
315
+ colors: "class"
316
+ }), [
317
+ g,
318
+ f,
319
+ h
320
+ ]), v = z(_, r);
321
+ if (c && v) throw Error(Q);
322
+ let b = y({
323
+ decorative: c,
324
+ interactive: v
325
+ });
326
+ return /* @__PURE__ */ l(S, {
327
+ role: b,
328
+ title: s,
329
+ attrs: _.attrs,
330
+ rest: d,
331
+ children: /* @__PURE__ */ l(U, {
332
+ el: _,
333
+ handlers: r,
334
+ onNodeClick: a,
335
+ root: b
336
+ })
337
+ });
338
+ }
339
+ function ee(n) {
340
+ let { w: i, h: a, viewBox: s, background: d, interactive: f = !1, onNodeClick: p, children: m, title: h, decorative: g, exactText: _, ...v } = n, { transform: b, transformScene: x } = e(), [C, w] = c(0), T = r(() => (w((e) => e + 1), () => w((e) => e - 1)), []), E = y({
341
+ decorative: g,
342
+ interactive: f || C > 0
343
+ }), D = o(() => ({
344
+ root: E,
345
+ decorative: g === !0,
346
+ exactText: _ !== !1,
347
+ onNodeClick: p,
348
+ register: T,
349
+ transform: b,
350
+ transformScene: x
351
+ }), [
352
+ E,
353
+ g,
354
+ _,
355
+ p,
356
+ T,
357
+ b,
358
+ x
359
+ ]), [O, k, A, j] = s ?? [
360
+ 0,
361
+ 0,
362
+ i,
363
+ a
364
+ ], M = null;
365
+ return d !== void 0 && (M = /* @__PURE__ */ l(q, {
366
+ x: O,
367
+ y: k,
368
+ w: A,
369
+ h: j,
370
+ fill: d
371
+ })), /* @__PURE__ */ l(S, {
372
+ role: E,
373
+ title: h,
374
+ attrs: {
375
+ width: i,
376
+ height: a,
377
+ viewBox: `${O} ${k} ${A} ${j}`
378
+ },
379
+ rest: v,
380
+ children: /* @__PURE__ */ u(t.Provider, {
381
+ value: D,
382
+ children: [M, m]
383
+ })
384
+ });
385
+ }
386
+ function te(e) {
387
+ return e.scene ? /* @__PURE__ */ l($, { ...e }) : /* @__PURE__ */ l(ee, { ...e });
388
+ }
389
+ //#endregion
390
+ export { Z as a, G as c, X as i, Y as n, q as o, J as r, K as s, te as t };
@@ -0,0 +1,10 @@
1
+ import { createContext as e, useContext as t } from "react";
2
+ //#region lib/components/ui/widgets/drawing/drawing-context.ts
3
+ var n = () => void 0, r = e({
4
+ root: "img",
5
+ decorative: !1,
6
+ exactText: !1,
7
+ register: () => n
8
+ }), i = () => t(r);
9
+ //#endregion
10
+ export { i as n, r as t };