@nice2dev/ui 1.4.13 → 1.4.15

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 (53) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
  3. package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
  4. package/dist/NiceForm-fmePSeA9.cjs +1 -0
  5. package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
  6. package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
  7. package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
  8. package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
  9. package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
  10. package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
  11. package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
  12. package/dist/backup/NiceBackupScheduler.mjs +171 -119
  13. package/dist/charts/NiceOrganizationChart.mjs +159 -59
  14. package/dist/charts/orgChartExport.mjs +71 -0
  15. package/dist/charts/tidyTree.mjs +43 -0
  16. package/dist/charts-C3Q3r8Yz.cjs +918 -0
  17. package/dist/charts.cjs +1 -1
  18. package/dist/charts.d.ts +9 -0
  19. package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
  20. package/dist/data/NiceDataGrid.mjs +301 -320
  21. package/dist/data/NiceRowEditDialog.mjs +57 -0
  22. package/dist/data/NiceTreeGrid.mjs +670 -551
  23. package/dist/data/NiceTreeView.mjs +222 -180
  24. package/dist/data/treeRowDrop.mjs +130 -0
  25. package/dist/data.cjs +1 -1
  26. package/dist/data.d.ts +68 -5
  27. package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
  28. package/dist/devops.cjs +1 -1
  29. package/dist/editors/forms/NiceForm.mjs +216 -167
  30. package/dist/editors/inputs/NiceUpload.mjs +238 -238
  31. package/dist/editors.cjs +1 -1
  32. package/dist/editors.d.ts +13 -1
  33. package/dist/feedback.cjs +1 -1
  34. package/dist/index.cjs +254 -254
  35. package/dist/index.d.ts +293 -8
  36. package/dist/index.mjs +980 -966
  37. package/dist/lazy.cjs +1 -1
  38. package/dist/lazy.d.ts +11 -1
  39. package/dist/navigation.cjs +1 -1
  40. package/dist/no-code/NiceDataMapper.mjs +398 -361
  41. package/dist/no-code-CN_q6TcB.cjs +331 -0
  42. package/dist/no-code.cjs +1 -1
  43. package/dist/no-code.d.ts +11 -1
  44. package/dist/style.css +1 -1
  45. package/dist/tools/NicePermissionMatrix.mjs +171 -138
  46. package/dist/tools/NiceRoleEditor.mjs +334 -297
  47. package/package.json +4 -4
  48. package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
  49. package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
  50. package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
  51. package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +0 -587
  52. package/dist/charts-BzlvCCg9.cjs +0 -768
  53. package/dist/no-code-B1jzfUF5.cjs +0 -331
@@ -1,84 +1,184 @@
1
- import { jsxs as C, jsx as n } from "react/jsx-runtime";
2
- import { useNiceTranslation as j, useControlId as I, clickOnActivationKey as S, NiceIcon as $ } from "@nice2dev/ui-core";
3
- import { forwardRef as b, useState as A, useCallback as s } from "react";
4
- const K = /* @__PURE__ */ Object.assign(
5
- /* @__PURE__ */ b(
1
+ import { jsxs as r, jsx as n, Fragment as D } from "react/jsx-runtime";
2
+ import { useNiceTranslation as K, useControlId as q, useRovingFocus as G, clickOnActivationKey as J, NiceIcon as l } from "@nice2dev/ui-core";
3
+ import { forwardRef as L, useState as Z, useRef as C, useCallback as f } from "react";
4
+ import { downloadBlob as B } from "../tools/NiceExport.mjs";
5
+ import { orgChartToSvg as Q, orgChartToPng as V } from "./orgChartExport.mjs";
6
+ const at = /* @__PURE__ */ Object.assign(
7
+ /* @__PURE__ */ L(
6
8
  ({
7
- data: _,
8
- renderNode: c,
9
- selectable: i,
10
- selectedKey: l,
11
- onSelect: h,
12
- direction: N = "top-down",
13
- collapsible: d = !0,
14
- className: f,
15
- style: k,
16
- id: x,
17
- testId: v,
18
- "data-testid": y
19
- }, w) => {
20
- const { t: e } = j(), z = I(x), [g, O] = A(/* @__PURE__ */ new Set()), p = s((a) => {
21
- O((r) => {
22
- const t = new Set(r);
23
- return t.has(a) ? t.delete(a) : t.add(a), t;
9
+ data: g,
10
+ renderNode: m,
11
+ selectable: c,
12
+ selectedKey: z,
13
+ onSelect: _,
14
+ direction: v = "top-down",
15
+ collapsible: N = !0,
16
+ zoomable: d = !1,
17
+ exportable: u = !1,
18
+ onExport: h,
19
+ className: F,
20
+ style: S,
21
+ id: $,
22
+ testId: j,
23
+ "data-testid": T
24
+ }, A) => {
25
+ const { t: i } = K(), H = q($), [w, P] = Z(/* @__PURE__ */ new Set()), [s, y] = Z(1), b = C(null), k = C(null), x = C(null);
26
+ G(x, { orientation: "horizontal" });
27
+ const M = (t) => y((o) => Math.min(2, Math.max(0.2, Math.round(o * t * 100) / 100))), U = () => {
28
+ const t = b.current, o = k.current;
29
+ if (!t || !o)
30
+ return;
31
+ const a = o.scrollWidth / s, e = o.scrollHeight / s;
32
+ a > 0 && e > 0 && y(Math.max(0.2, Math.min(1, t.clientWidth / a, t.clientHeight / e)));
33
+ }, p = u === !0 ? ["svg", "png"] : u === !1 ? [] : u, W = async (t) => {
34
+ const o = { direction: v };
35
+ if (t === "svg") {
36
+ const e = Q(g, o);
37
+ h ? h("svg", e) : B(new Blob([e], { type: "image/svg+xml" }), "organization-chart.svg");
38
+ return;
39
+ }
40
+ const a = await V(g, o);
41
+ h ? h("png", a) : B(a, "organization-chart.png");
42
+ }, O = f((t) => {
43
+ P((o) => {
44
+ const a = new Set(o);
45
+ return a.has(t) ? a.delete(t) : a.add(t), a;
24
46
  });
25
- }, []), m = s(
26
- (a) => {
27
- i && h?.(a);
47
+ }, []), R = f(
48
+ (t) => {
49
+ c && _?.(t);
28
50
  },
29
- [i, h]
30
- ), u = s(
31
- (a) => {
32
- const r = g.has(a.key), t = a.children && a.children.length > 0;
33
- return /* @__PURE__ */ C("li", { className: "nice-org-chart__item", children: [
34
- /* @__PURE__ */ C(
51
+ [c, _]
52
+ ), I = f(
53
+ (t) => {
54
+ const o = w.has(t.key), a = t.children && t.children.length > 0;
55
+ return /* @__PURE__ */ r("li", { className: "nice-org-chart__item", children: [
56
+ /* @__PURE__ */ r(
35
57
  "div",
36
58
  {
37
- tabIndex: i ? 0 : void 0,
38
- onKeyDown: i ? S : void 0,
39
- className: `nice-org-chart__node${l === a.key ? " nice-org-chart__node--selected" : ""}`,
40
- onClick: () => m(a.key),
41
- role: i ? "button" : void 0,
59
+ tabIndex: c ? 0 : void 0,
60
+ onKeyDown: c ? J : void 0,
61
+ className: `nice-org-chart__node${z === t.key ? " nice-org-chart__node--selected" : ""}`,
62
+ onClick: () => R(t.key),
63
+ role: c ? "button" : void 0,
42
64
  children: [
43
- c ? c(a) : /* @__PURE__ */ n("span", { children: a.label }),
44
- d && t && /* @__PURE__ */ n(
65
+ m ? m(t) : /* @__PURE__ */ n("span", { children: t.label }),
66
+ N && a && /* @__PURE__ */ n(
45
67
  "button",
46
68
  {
47
69
  type: "button",
48
70
  className: "nice-org-chart__toggle",
49
- onClick: (o) => {
50
- o.stopPropagation(), p(a.key);
71
+ onClick: (e) => {
72
+ e.stopPropagation(), O(t.key);
51
73
  },
52
- "aria-label": r ? e("organizationChart.expand", "Expand") : e("organizationChart.collapse", "Collapse"),
53
- children: /* @__PURE__ */ n($, { name: r ? "plus" : "minus", size: 14 })
74
+ "aria-label": o ? i("organizationChart.expand", "Expand") : i("organizationChart.collapse", "Collapse"),
75
+ children: /* @__PURE__ */ n(l, { name: o ? "plus" : "minus", size: 14 })
54
76
  }
55
77
  )
56
78
  ]
57
79
  }
58
80
  ),
59
- t && !r && /* @__PURE__ */ n("ul", { className: "nice-org-chart__children", children: a.children.map((o) => u(o)) })
60
- ] }, a.key);
81
+ a && !o && /* @__PURE__ */ n("ul", { className: "nice-org-chart__children", children: t.children.map((e) => I(e)) })
82
+ ] }, t.key);
61
83
  },
62
84
  [
63
- g,
64
- l,
65
- c,
66
- i,
67
- d,
85
+ w,
86
+ z,
68
87
  m,
69
- p,
70
- e
88
+ c,
89
+ N,
90
+ R,
91
+ O,
92
+ i
71
93
  ]
72
94
  );
73
- return /* @__PURE__ */ n(
95
+ return /* @__PURE__ */ r(
74
96
  "div",
75
97
  {
76
- ref: w,
77
- id: z,
78
- className: `nice-org-chart nice-org-chart--${N} ${f || ""}`,
79
- style: k,
80
- "data-testid": y ?? v,
81
- children: /* @__PURE__ */ n("ul", { className: "nice-org-chart__root", children: u(_) })
98
+ ref: A,
99
+ id: H,
100
+ className: `nice-org-chart nice-org-chart--${v}${d || p.length ? " nice-org-chart--tools" : ""} ${F || ""}`,
101
+ style: S,
102
+ "data-testid": T ?? j,
103
+ children: [
104
+ (d || p.length > 0) && /* @__PURE__ */ r(
105
+ "div",
106
+ {
107
+ ref: x,
108
+ className: "nice-org-chart__tools",
109
+ role: "toolbar",
110
+ "aria-label": i("organizationChart.tools", "Chart tools"),
111
+ children: [
112
+ d && /* @__PURE__ */ r(D, { children: [
113
+ /* @__PURE__ */ n(
114
+ "button",
115
+ {
116
+ type: "button",
117
+ className: "nice-org-chart__tool",
118
+ onClick: () => M(1 / 1.2),
119
+ "aria-label": i("organizationChart.zoomOut", "Zoom out"),
120
+ title: i("organizationChart.zoomOut", "Zoom out"),
121
+ children: /* @__PURE__ */ n(l, { name: "zoom-out", size: 14 })
122
+ }
123
+ ),
124
+ /* @__PURE__ */ r("span", { className: "nice-org-chart__zoom", "aria-live": "polite", children: [
125
+ Math.round(s * 100),
126
+ "%"
127
+ ] }),
128
+ /* @__PURE__ */ n(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ className: "nice-org-chart__tool",
133
+ onClick: () => M(1.2),
134
+ "aria-label": i("organizationChart.zoomIn", "Zoom in"),
135
+ title: i("organizationChart.zoomIn", "Zoom in"),
136
+ children: /* @__PURE__ */ n(l, { name: "zoom-in", size: 14 })
137
+ }
138
+ ),
139
+ /* @__PURE__ */ n(
140
+ "button",
141
+ {
142
+ type: "button",
143
+ className: "nice-org-chart__tool",
144
+ onClick: U,
145
+ "aria-label": i("organizationChart.fit", "Fit to view"),
146
+ title: i("organizationChart.fit", "Fit to view"),
147
+ children: /* @__PURE__ */ n(l, { name: "expand", size: 14 })
148
+ }
149
+ )
150
+ ] }),
151
+ p.map((t) => /* @__PURE__ */ r(
152
+ "button",
153
+ {
154
+ type: "button",
155
+ className: "nice-org-chart__tool",
156
+ onClick: () => void W(t),
157
+ title: i("organizationChart.export", "Export as {format}").replace(
158
+ "{format}",
159
+ t.toUpperCase()
160
+ ),
161
+ children: [
162
+ /* @__PURE__ */ n(l, { name: "download", size: 14 }),
163
+ " ",
164
+ t.toUpperCase()
165
+ ]
166
+ },
167
+ t
168
+ ))
169
+ ]
170
+ }
171
+ ),
172
+ /* @__PURE__ */ n("div", { ref: b, className: "nice-org-chart__view", children: /* @__PURE__ */ n(
173
+ "ul",
174
+ {
175
+ ref: k,
176
+ className: "nice-org-chart__root",
177
+ style: s !== 1 ? { zoom: s } : void 0,
178
+ children: I(g)
179
+ }
180
+ ) })
181
+ ]
82
182
  }
83
183
  );
84
184
  }
@@ -86,5 +186,5 @@ const K = /* @__PURE__ */ Object.assign(
86
186
  { displayName: "NiceOrganizationChart" }
87
187
  );
88
188
  export {
89
- K as NiceOrganizationChart
189
+ at as NiceOrganizationChart
90
190
  };
@@ -0,0 +1,71 @@
1
+ import { tidyTreeLayout as C } from "./tidyTree.mjs";
2
+ const T = (r) => r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3
+ function E(r, n = {}) {
4
+ const d = n.fontSize ?? 13, l = n.nodeHeight ?? 40, x = n.minNodeWidth ?? 120, m = n.direction === "left-right", e = 16, f = (o) => ({
5
+ id: o.key,
6
+ width: Math.max(x, Math.round(o.label.length * d * 0.6) + 32),
7
+ height: l,
8
+ children: (o.children ?? []).map(f)
9
+ }), c = C([f(r)], {
10
+ direction: m ? "LR" : "TB",
11
+ siblingGap: 16,
12
+ levelGap: 32
13
+ });
14
+ let i = 0, h = 0;
15
+ for (const o of c.values())
16
+ i = Math.max(i, o.x + o.width), h = Math.max(h, o.y + o.height);
17
+ const g = n.lineColor ?? "#9ca3af", s = [], w = (o) => {
18
+ const t = c.get(o.key);
19
+ if (t)
20
+ for (const N of o.children ?? []) {
21
+ const a = c.get(N.key);
22
+ if (a) {
23
+ if (m) {
24
+ const $ = t.x + t.width + e, y = t.y + t.height / 2 + e, u = a.x + e, b = a.y + a.height / 2 + e, v = ($ + u) / 2;
25
+ s.push(
26
+ `<path d="M${$} ${y}H${v}V${b}H${u}" fill="none" stroke="${g}" stroke-width="1.5"/>`
27
+ );
28
+ } else {
29
+ const $ = t.x + t.width / 2 + e, y = t.y + t.height + e, u = a.x + a.width / 2 + e, b = a.y + e, v = (y + b) / 2;
30
+ s.push(
31
+ `<path d="M${$} ${y}V${v}H${u}V${b}" fill="none" stroke="${g}" stroke-width="1.5"/>`
32
+ );
33
+ }
34
+ w(N);
35
+ }
36
+ }
37
+ };
38
+ w(r);
39
+ const k = [], p = (o) => {
40
+ const t = c.get(o.key);
41
+ t && k.push(
42
+ `<g><rect x="${t.x + e}" y="${t.y + e}" width="${t.width}" height="${t.height}" rx="6" fill="${n.boxFill ?? "#ffffff"}" stroke="${n.boxStroke ?? "#d1d5db"}"/><text x="${t.x + e + t.width / 2}" y="${t.y + e + t.height / 2}" text-anchor="middle" dominant-baseline="central" font-size="${d}" fill="${n.textColor ?? "#111827"}">${T(o.label)}</text></g>`
43
+ ), (o.children ?? []).forEach(p);
44
+ };
45
+ p(r);
46
+ const M = i + e * 2, L = h + e * 2;
47
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${M}" height="${L}" viewBox="0 0 ${M} ${L}" font-family="${T(n.fontFamily ?? "system-ui, sans-serif")}"><rect width="100%" height="100%" fill="${n.background ?? "#ffffff"}"/>` + s.join("") + k.join("") + "</svg>";
48
+ }
49
+ async function S(r, n = {}) {
50
+ const d = E(r, n), l = n.scale ?? 2, x = /width="([\d.]+)" height="([\d.]+)"/.exec(d), m = Number(x?.[1] ?? 0), e = Number(x?.[2] ?? 0), f = URL.createObjectURL(new Blob([d], { type: "image/svg+xml" }));
51
+ try {
52
+ const c = new Image();
53
+ await new Promise((g, s) => {
54
+ c.onload = () => g(), c.onerror = () => s(new Error("The chart image could not be drawn.")), c.src = f;
55
+ });
56
+ const i = document.createElement("canvas");
57
+ i.width = Math.ceil(m * l), i.height = Math.ceil(e * l);
58
+ const h = i.getContext("2d");
59
+ if (!h)
60
+ throw new Error("No 2D canvas.");
61
+ return h.scale(l, l), h.drawImage(c, 0, 0), await new Promise(
62
+ (g, s) => i.toBlob((w) => w ? g(w) : s(new Error("No PNG.")), "image/png")
63
+ );
64
+ } finally {
65
+ URL.revokeObjectURL(f);
66
+ }
67
+ }
68
+ export {
69
+ S as orgChartToPng,
70
+ E as orgChartToSvg
71
+ };
@@ -0,0 +1,43 @@
1
+ function _(W, n = {}) {
2
+ const w = n.nodeWidth ?? 160, M = n.nodeHeight ?? 56, r = n.siblingGap ?? 24, z = n.levelGap ?? 48, l = n.direction === "LR", s = (t) => l ? t.height ?? M : t.width ?? w, O = (t) => l ? t.width ?? w : t.height ?? M, g = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), f = [], S = (t, e) => {
3
+ g.add(t.id), f[e] = Math.max(f[e] ?? 0, O(t));
4
+ const o = (t.children ?? []).filter((c) => !g.has(c.id));
5
+ o.forEach((c) => g.add(c.id)), x.set(t.id, o);
6
+ const d = o.reduce(
7
+ (c, p, i) => c + S(p, e + 1) + (i > 0 ? r : 0),
8
+ 0
9
+ ), a = Math.max(s(t), d);
10
+ return u.set(t.id, a), a;
11
+ }, v = [], G = [];
12
+ for (const t of W)
13
+ g.has(t.id) || (v.push(t), G.push(S(t, 0)));
14
+ const m = [];
15
+ f.forEach((t, e) => {
16
+ m[e] = e === 0 ? 0 : m[e - 1] + f[e - 1] + z;
17
+ });
18
+ const y = /* @__PURE__ */ new Map(), E = (t, e, o) => {
19
+ const d = u.get(t.id) ?? s(t), a = x.get(t.id) ?? [], c = a.reduce(
20
+ (h, L, T) => h + (u.get(L.id) ?? s(L)) + (T > 0 ? r : 0),
21
+ 0
22
+ );
23
+ let p = e + (d - c) / 2;
24
+ const i = [];
25
+ for (const h of a)
26
+ i.push(E(h, p, o + 1)), p += (u.get(h.id) ?? s(h)) + r;
27
+ const R = i.length ? (i[0] + i[i.length - 1]) / 2 : e + d / 2, k = Math.min(Math.max(R - s(t) / 2, e), e + d - s(t)), H = m[o];
28
+ return y.set(t.id, {
29
+ x: l ? H : k,
30
+ y: l ? k : H,
31
+ width: t.width ?? w,
32
+ height: t.height ?? M,
33
+ depth: o
34
+ }), k + s(t) / 2;
35
+ };
36
+ let b = 0;
37
+ return v.forEach((t, e) => {
38
+ E(t, b, 0), b += G[e] + r;
39
+ }), y;
40
+ }
41
+ export {
42
+ _ as tidyTreeLayout
43
+ };