@nice2dev/ui 1.4.14 → 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 (51) hide show
  1. package/CHANGELOG.md +73 -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 +478 -433
  23. package/dist/data.cjs +1 -1
  24. package/dist/data.d.ts +43 -2
  25. package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
  26. package/dist/devops.cjs +1 -1
  27. package/dist/editors/forms/NiceForm.mjs +216 -167
  28. package/dist/editors/inputs/NiceUpload.mjs +238 -238
  29. package/dist/editors.cjs +1 -1
  30. package/dist/editors.d.ts +13 -1
  31. package/dist/feedback.cjs +1 -1
  32. package/dist/index.cjs +254 -254
  33. package/dist/index.d.ts +198 -5
  34. package/dist/index.mjs +928 -920
  35. package/dist/lazy.cjs +1 -1
  36. package/dist/lazy.d.ts +11 -1
  37. package/dist/navigation.cjs +1 -1
  38. package/dist/no-code/NiceDataMapper.mjs +398 -361
  39. package/dist/no-code-CN_q6TcB.cjs +331 -0
  40. package/dist/no-code.cjs +1 -1
  41. package/dist/no-code.d.ts +11 -1
  42. package/dist/style.css +1 -1
  43. package/dist/tools/NicePermissionMatrix.mjs +171 -138
  44. package/dist/tools/NiceRoleEditor.mjs +334 -297
  45. package/package.json +4 -4
  46. package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
  47. package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
  48. package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
  49. package/dist/NiceSavedQueryPanel-C1nxEmMu.cjs +0 -587
  50. package/dist/charts-BzlvCCg9.cjs +0 -768
  51. package/dist/no-code-B1jzfUF5.cjs +0 -331
@@ -1,533 +1,570 @@
1
- import { jsx as l, jsxs as u, Fragment as Ke } from "react/jsx-runtime";
2
- import { useNiceTranslation as Le, useNiceAccessMode as De, useControllableState as O, NiceIcon as v } from "@nice2dev/ui-core";
3
- import { useState as ne, useRef as ue, useEffect as fe, useMemo as H } from "react";
4
- import { NiceButton as C } from "../buttons/NiceButton.mjs";
5
- import { NiceList as Ge } from "../data/NiceList.mjs";
6
- import { NiceTreeGrid as ae } from "../data/NiceTreeGrid.mjs";
7
- import { walkTreeNodes as ce } from "../data/treeEdit.mjs";
8
- import { NiceSegmentedControl as We } from "../display/NiceSegmentedControl.mjs";
9
- import { NiceSelect as de } from "../editors/inputs/NiceSelect.mjs";
10
- import { NiceTextInput as me } from "../editors/inputs/NiceTextInput.mjs";
11
- import { permissionTree as Ye, createRoleId as qe, removeRole as He, wouldCreateRoleCycle as he, resolveRolePermissions as Je, duplicateRole as Qe } from "./roleModel.mjs";
1
+ import { jsx as r, jsxs as f, Fragment as Qe } from "react/jsx-runtime";
2
+ import { useNiceTranslation as Xe, useNiceAccessMode as Ze, useControllableState as M, NiceIcon as E } from "@nice2dev/ui-core";
3
+ import { useState as V, useRef as x, useEffect as re, useMemo as oe } from "react";
4
+ import { NiceButton as I } from "../buttons/NiceButton.mjs";
5
+ import { NiceList as eo } from "../data/NiceList.mjs";
6
+ import { NiceTreeGrid as be } from "../data/NiceTreeGrid.mjs";
7
+ import { walkTreeNodes as _e } from "../data/treeEdit.mjs";
8
+ import { NiceSegmentedControl as oo } from "../display/NiceSegmentedControl.mjs";
9
+ import { NiceSelect as Ne } from "../editors/inputs/NiceSelect.mjs";
10
+ import { NiceTextInput as ge } from "../editors/inputs/NiceTextInput.mjs";
11
+ import { permissionTree as ro, createRoleId as lo, removeRole as io, wouldCreateRoleCycle as ve, resolveRolePermissions as to, duplicateRole as so } from "./roleModel.mjs";
12
12
  /* empty css */
13
- const Xe = [], Ze = [], eo = [], pe = ({ checked: b, mixed: E = !1, disabled: M, label: V, title: S, muted: w, onChange: F }) => {
14
- const g = ue(null);
15
- return fe(() => {
16
- g.current && (g.current.indeterminate = E);
17
- }, [E]), /* @__PURE__ */ l(
13
+ const no = [], ao = [], co = [], ye = ({ checked: g, mixed: k = !1, disabled: $, label: j, title: T, muted: w, onChange: B }) => {
14
+ const R = x(null);
15
+ return re(() => {
16
+ R.current && (R.current.indeterminate = k);
17
+ }, [k]), /* @__PURE__ */ r(
18
18
  "input",
19
19
  {
20
- ref: g,
20
+ ref: R,
21
21
  type: "checkbox",
22
22
  className: `nice-role-editor__check${w ? " nice-role-editor__check--inherited" : ""}`,
23
- checked: b,
24
- disabled: M,
25
- "aria-label": V,
26
- "aria-checked": E ? "mixed" : b,
27
- title: S,
28
- onChange: (x) => F(x.target.checked)
23
+ checked: g,
24
+ disabled: $,
25
+ "aria-label": j,
26
+ "aria-checked": k ? "mixed" : g,
27
+ title: T,
28
+ onChange: (U) => B(U.target.checked)
29
29
  }
30
30
  );
31
- }, uo = ({
32
- permissions: b = Xe,
33
- value: E,
34
- defaultValue: M,
35
- onChange: V,
36
- users: S,
31
+ }, ko = ({
32
+ permissions: g = no,
33
+ value: k,
34
+ defaultValue: $,
35
+ onChange: j,
36
+ users: T,
37
37
  defaultUsers: w,
38
- onUsersChange: F,
39
- selectedRoleId: g,
40
- defaultSelectedRoleId: x,
41
- onSelectedRoleChange: be,
42
- view: _e,
43
- defaultView: Ne,
44
- onViewChange: ye,
45
- inheritance: A = !0,
46
- groupPermission: J,
47
- segmentLabel: Q,
48
- canEditRole: X,
49
- createRoleId: Z = qe,
50
- height: ee,
51
- size: U = "md",
52
- readOnly: ve = !1,
53
- disabled: Ee = !1,
54
- className: ge,
55
- style: ke,
56
- id: oe,
57
- title: Re,
58
- accessMode: Ce,
59
- "data-testid": Se
38
+ onUsersChange: B,
39
+ selectedRoleId: R,
40
+ defaultSelectedRoleId: U,
41
+ onSelectedRoleChange: Ee,
42
+ view: ke,
43
+ defaultView: Re,
44
+ onViewChange: Ce,
45
+ inheritance: K = !0,
46
+ groupPermission: le,
47
+ segmentLabel: ie,
48
+ canEditRole: te,
49
+ canAssignRole: se,
50
+ onSearchUsers: v,
51
+ createRoleId: ne = lo,
52
+ height: ae,
53
+ size: L = "md",
54
+ readOnly: Se = !1,
55
+ disabled: Ie = !1,
56
+ className: Te,
57
+ style: we,
58
+ id: ce,
59
+ title: ze,
60
+ accessMode: Pe,
61
+ "data-testid": Oe
60
62
  }) => {
61
- const { t: r } = Le(), $ = De(Ce, oe), j = Ee || $ === "disabled", le = ve || $ === "readOnly" || j, [c, we] = O({
62
- value: E,
63
- defaultValue: M,
64
- fallbackValue: Ze,
63
+ const { t: i } = Xe(), q = Ze(Pe, ce), D = Ie || q === "disabled", G = Se || q === "readOnly" || D, [m, Ae] = M({
64
+ value: k,
65
+ defaultValue: $,
66
+ fallbackValue: ao,
65
67
  componentName: "NiceRoleEditor"
66
- }), [_, Ie] = O({
67
- value: S,
68
+ }), [_, Fe] = M({
69
+ value: T,
68
70
  defaultValue: w,
69
- fallbackValue: eo,
71
+ fallbackValue: co,
70
72
  componentName: "NiceRoleEditor"
71
- }), k = S !== void 0 || w !== void 0, [ze, Pe] = O({
72
- value: g,
73
- defaultValue: x,
73
+ }), C = T !== void 0 || w !== void 0, [Me, Ve] = M({
74
+ value: R,
75
+ defaultValue: U,
74
76
  fallbackValue: null,
75
77
  componentName: "NiceRoleEditor"
76
- }), [R, Te] = O({
77
- value: _e,
78
- defaultValue: Ne,
78
+ }), [S, xe] = M({
79
+ value: ke,
80
+ defaultValue: Re,
79
81
  fallbackValue: "role",
80
82
  componentName: "NiceRoleEditor"
81
- }), [B, Oe] = ne("permissions"), [I, K] = ne(null), re = ue(null);
82
- fe(() => {
83
- I && re.current?.querySelector("button")?.focus();
84
- }, [I]);
85
- const z = (e) => {
86
- we(e), V?.(e);
87
- }, L = (e) => {
88
- Ie(e), F?.(e);
89
- }, P = (e) => {
90
- Pe(e), be?.(e), K(null);
91
- }, D = (e) => {
92
- Te(e), ye?.(e);
93
- }, t = c.find((e) => e.id === ze) ?? c[0], G = (e) => !!e && !le && (X ? X(e) : !e.system), N = H(
94
- () => Ye(b, { groupBy: J, segmentLabel: Q }),
95
- [b, J, Q]
96
- ), ie = H(() => {
97
- const e = b.length <= 300 ? 2 : 1, i = [];
98
- return ce(
99
- N,
100
- (a, d) => (a.children?.length && d.depth < e && i.push(a.key), d.depth < e ? void 0 : !1),
83
+ }), [W, $e] = V("permissions"), [z, Y] = V(null), de = x(null);
84
+ re(() => {
85
+ z && de.current?.querySelector("button")?.focus();
86
+ }, [z]);
87
+ const P = (e) => {
88
+ Ae(e), j?.(e);
89
+ }, O = (e) => {
90
+ Fe(e), B?.(e);
91
+ }, [me, je] = V([]), [Be, he] = V(!1), H = x(void 0), J = x(0);
92
+ re(() => () => clearTimeout(H.current), []);
93
+ const Ue = (e) => {
94
+ clearTimeout(H.current), v && (H.current = setTimeout(() => {
95
+ const l = ++J.current;
96
+ he(!0), v(e).then((a) => {
97
+ l === J.current && je(a);
98
+ }).catch(() => {
99
+ }).finally(() => {
100
+ l === J.current && he(!1);
101
+ });
102
+ }, 250));
103
+ }, A = (e) => {
104
+ Ve(e), Ee?.(e), Y(null);
105
+ }, Q = (e) => {
106
+ xe(e), Ce?.(e);
107
+ }, t = m.find((e) => e.id === Me) ?? m[0], X = (e) => !!e && !G && (te ? te(e) : !e.system), y = oe(
108
+ () => ro(g, { groupBy: le, segmentLabel: ie }),
109
+ [g, le, ie]
110
+ ), ue = oe(() => {
111
+ const e = g.length <= 300 ? 2 : 1, l = [];
112
+ return _e(
113
+ y,
114
+ (a, c) => (a.children?.length && c.depth < e && l.push(a.key), c.depth < e ? void 0 : !1),
101
115
  { keyField: "key" }
102
- ), i;
103
- }, [N, b.length]), Me = H(() => {
116
+ ), l;
117
+ }, [y, g.length]), Ke = oe(() => {
104
118
  const e = /* @__PURE__ */ new Map();
105
- return ce(
106
- N,
107
- (i, a) => {
108
- i.code && a.ancestors.forEach((d) => {
109
- const s = e.get(d.key) ?? [];
110
- s.push(i.code), e.set(d.key, s);
119
+ return _e(
120
+ y,
121
+ (l, a) => {
122
+ l.code && a.ancestors.forEach((c) => {
123
+ const s = e.get(c.key) ?? [];
124
+ s.push(l.code), e.set(c.key, s);
111
125
  });
112
126
  },
113
127
  { keyField: "key" }
114
128
  ), e;
115
- }, [N]), te = (e) => c.find((i) => i.id === e)?.label ?? e, W = (e) => {
116
- const i = Je(e.id, c, { inheritance: A }), a = new Set(e.permissions), d = /* @__PURE__ */ new Map();
117
- return i.forEach((s, p) => {
118
- const m = s.filter((f) => f !== e.id);
119
- m.length && d.set(p, m);
120
- }), { own: a, inherited: d };
121
- }, T = (e, i) => {
122
- z(c.map((a) => a.id === e ? { ...a, ...i } : a));
123
- }, se = (e, i) => {
124
- const { inherited: a } = W(e), d = /* @__PURE__ */ new Set();
125
- for (const s of i)
126
- !s.startsWith("group:") && !a.has(s) && d.add(s);
129
+ }, [y]), pe = (e) => m.find((l) => l.id === e)?.label ?? e, Z = (e) => {
130
+ const l = to(e.id, m, { inheritance: K }), a = new Set(e.permissions), c = /* @__PURE__ */ new Map();
131
+ return l.forEach((s, u) => {
132
+ const d = s.filter((b) => b !== e.id);
133
+ d.length && c.set(u, d);
134
+ }), { own: a, inherited: c };
135
+ }, F = (e, l) => {
136
+ P(m.map((a) => a.id === e ? { ...a, ...l } : a));
137
+ }, fe = (e, l) => {
138
+ const { inherited: a } = Z(e), c = /* @__PURE__ */ new Set();
139
+ for (const s of l)
140
+ !s.startsWith("group:") && !a.has(s) && c.add(s);
127
141
  e.permissions.forEach((s) => {
128
- a.has(s) && d.add(s);
129
- }), T(e.id, { permissions: [...d] });
130
- }, Ve = () => {
131
- const e = r("roleEditor.newRole", "New role"), i = Z(e, c);
132
- z([...c, { id: i, label: e, permissions: [] }]), P(i), D("role");
133
- }, Fe = () => {
142
+ a.has(s) && c.add(s);
143
+ }), F(e.id, { permissions: [...c] });
144
+ }, Le = () => {
145
+ const e = i("roleEditor.newRole", "New role"), l = ne(e, m);
146
+ P([...m, { id: l, label: e, permissions: [] }]), A(l), Q("role");
147
+ }, qe = () => {
134
148
  if (!t)
135
149
  return;
136
- const e = r("roleEditor.copyOf", "{label} (copy)").replace("{label}", t.label), i = Z(e, c);
137
- z(Qe(c, t.id, e, i)), P(i);
138
- }, xe = () => {
150
+ const e = i("roleEditor.copyOf", "{label} (copy)").replace("{label}", t.label), l = ne(e, m);
151
+ P(so(m, t.id, e, l)), A(l);
152
+ }, De = () => {
139
153
  if (!t)
140
154
  return;
141
- const e = c.findIndex((a) => a.id === t.id), i = He(c, _, t.id);
142
- z(i.roles), k && L(i.users), P(i.roles[Math.min(e, i.roles.length - 1)]?.id ?? null);
155
+ const e = m.findIndex((a) => a.id === t.id), l = io(m, _, t.id);
156
+ P(l.roles), C && O(l.users), A(l.roles[Math.min(e, l.roles.length - 1)]?.id ?? null);
143
157
  };
144
- if ($ === "hidden")
158
+ if (q === "hidden")
145
159
  return null;
146
- const Ae = c.map((e) => ({
160
+ const Ge = m.map((e) => ({
147
161
  key: e.id,
148
162
  text: e.label,
149
- badge: k ? _.filter((i) => i.roleIds.includes(e.id)).length : void 0
150
- })), Ue = (e) => {
151
- const i = c.find((a) => a.id === e.key);
152
- return /* @__PURE__ */ u("span", { className: "nice-role-editor__role", children: [
153
- /* @__PURE__ */ l(
163
+ badge: C ? _.filter((l) => l.roleIds.includes(e.id)).length : void 0
164
+ })), We = (e) => {
165
+ const l = m.find((a) => a.id === e.key);
166
+ return /* @__PURE__ */ f("span", { className: "nice-role-editor__role", children: [
167
+ /* @__PURE__ */ r(
154
168
  "span",
155
169
  {
156
170
  className: "nice-role-editor__dot",
157
- style: i?.color ? { background: i.color } : void 0,
171
+ style: l?.color ? { background: l.color } : void 0,
158
172
  "aria-hidden": "true"
159
173
  }
160
174
  ),
161
- /* @__PURE__ */ l("span", { className: "nice-role-editor__role-name", children: e.text }),
162
- i?.system && /* @__PURE__ */ l("span", { className: "nice-role-editor__lock", title: r("roleEditor.system", "Built-in role"), children: /* @__PURE__ */ l(v, { name: "lock", size: 12 }) }),
163
- e.badge !== void 0 && /* @__PURE__ */ l(
175
+ /* @__PURE__ */ r("span", { className: "nice-role-editor__role-name", children: e.text }),
176
+ l?.system && /* @__PURE__ */ r("span", { className: "nice-role-editor__lock", title: i("roleEditor.system", "Built-in role"), children: /* @__PURE__ */ r(E, { name: "lock", size: 12 }) }),
177
+ e.badge !== void 0 && /* @__PURE__ */ r(
164
178
  "span",
165
179
  {
166
180
  className: "nice-role-editor__count",
167
- title: r("roleEditor.userCount", "Users with this role"),
181
+ title: i("roleEditor.userCount", "Users with this role"),
168
182
  children: e.badge
169
183
  }
170
184
  )
171
185
  ] });
172
- }, Y = (e, i, a, d) => /* @__PURE__ */ l(
173
- C,
186
+ }, ee = (e, l, a, c) => /* @__PURE__ */ r(
187
+ I,
174
188
  {
175
189
  variant: "ghost",
176
190
  size: "sm",
177
191
  ariaLabel: e,
178
192
  title: e,
179
193
  disabled: !a,
180
- onClick: d,
181
- children: /* @__PURE__ */ l(v, { name: i, size: 16 })
194
+ onClick: c,
195
+ children: /* @__PURE__ */ r(E, { name: l, size: 16 })
182
196
  }
183
- ), $e = () => {
197
+ ), Ye = () => {
184
198
  if (!t)
185
- return /* @__PURE__ */ l("p", { className: "nice-role-editor__hint", children: r("roleEditor.noRoles", "No roles yet — add one on the left.") });
186
- const e = G(t), { own: i, inherited: a } = W(t), d = [.../* @__PURE__ */ new Set([...i, ...a.keys()])], s = _.filter((o) => o.roleIds.includes(t.id)), p = _.filter((o) => !o.roleIds.includes(t.id)), m = c.filter((o) => o.id !== t.id).map((o) => ({
199
+ return /* @__PURE__ */ r("p", { className: "nice-role-editor__hint", children: i("roleEditor.noRoles", "No roles yet — add one on the left.") });
200
+ const e = X(t), l = !G && (se ? se(t) : e), { own: a, inherited: c } = Z(t), s = [.../* @__PURE__ */ new Set([...a, ...c.keys()])], u = _.filter((o) => o.roleIds.includes(t.id)), d = v ? me.filter(
201
+ (o) => !(_.find((n) => n.id === o.id)?.roleIds ?? o.roleIds).includes(t.id)
202
+ ) : _.filter((o) => !o.roleIds.includes(t.id)), b = m.filter((o) => o.id !== t.id).map((o) => ({
187
203
  value: o.id,
188
204
  label: o.label,
189
- disabled: !(t.inherits ?? []).includes(o.id) && he(c, t.id, o.id)
190
- })), f = [
205
+ disabled: !(t.inherits ?? []).includes(o.id) && ve(m, t.id, o.id)
206
+ })), N = [
191
207
  {
192
208
  field: "label",
193
- header: r("roleEditor.permission", "Permission"),
194
- render: (o, n) => /* @__PURE__ */ u("span", { className: "nice-role-editor__perm", children: [
195
- /* @__PURE__ */ l("span", { children: n.label }),
196
- n.code && /* @__PURE__ */ l("code", { className: "nice-role-editor__code", children: n.code })
209
+ header: i("roleEditor.permission", "Permission"),
210
+ render: (o, n) => /* @__PURE__ */ f("span", { className: "nice-role-editor__perm", title: n.description, children: [
211
+ /* @__PURE__ */ f("span", { className: "nice-role-editor__perm-name", children: [
212
+ /* @__PURE__ */ r("span", { children: n.label }),
213
+ n.description && /* @__PURE__ */ r("span", { className: "nice-role-editor__perm-desc", children: n.description })
214
+ ] }),
215
+ n.code && /* @__PURE__ */ r("code", { className: "nice-role-editor__code", children: n.code })
197
216
  ] })
198
217
  },
199
- ...A ? [
218
+ ...K ? [
200
219
  {
201
220
  field: "code",
202
- header: r("roleEditor.from", "From"),
221
+ header: i("roleEditor.from", "From"),
203
222
  render: (o, n) => {
204
- const h = n.code ? a.get(n.code) : void 0;
205
- return h ? /* @__PURE__ */ l("span", { className: "nice-role-editor__from", children: h.map(te).join(", ") }) : null;
223
+ const h = n.code ? c.get(n.code) : void 0;
224
+ return h ? /* @__PURE__ */ r("span", { className: "nice-role-editor__from", children: h.map(pe).join(", ") }) : null;
206
225
  }
207
226
  }
208
227
  ] : []
209
228
  ];
210
- return /* @__PURE__ */ u(Ke, { children: [
211
- /* @__PURE__ */ u("div", { className: "nice-role-editor__fields", children: [
212
- /* @__PURE__ */ l(
213
- me,
229
+ return /* @__PURE__ */ f(Qe, { children: [
230
+ /* @__PURE__ */ f("div", { className: "nice-role-editor__fields", children: [
231
+ /* @__PURE__ */ r(
232
+ ge,
214
233
  {
215
- label: r("roleEditor.name", "Name"),
234
+ label: i("roleEditor.name", "Name"),
216
235
  size: "sm",
217
236
  value: t.label,
218
- onChange: (o) => T(t.id, { label: o }),
237
+ onChange: (o) => F(t.id, { label: o }),
219
238
  readOnly: !e
220
239
  }
221
240
  ),
222
- /* @__PURE__ */ l(
223
- me,
241
+ /* @__PURE__ */ r(
242
+ ge,
224
243
  {
225
- label: r("roleEditor.description", "Description"),
244
+ label: i("roleEditor.description", "Description"),
226
245
  size: "sm",
227
246
  value: t.description ?? "",
228
- onChange: (o) => T(t.id, { description: o || void 0 }),
247
+ onChange: (o) => F(t.id, { description: o || void 0 }),
229
248
  readOnly: !e
230
249
  }
231
250
  ),
232
- A && /* @__PURE__ */ l(
233
- de,
251
+ K && /* @__PURE__ */ r(
252
+ Ne,
234
253
  {
235
- label: r("roleEditor.inherits", "Inherits from"),
254
+ label: i("roleEditor.inherits", "Inherits from"),
236
255
  size: "sm",
237
256
  multiple: !0,
238
257
  searchable: !0,
239
- options: m,
258
+ options: b,
240
259
  value: t.inherits ?? [],
241
- placeholder: r("roleEditor.inheritsNone", "No other role"),
242
- onChange: (o) => T(t.id, {
260
+ placeholder: i("roleEditor.inheritsNone", "No other role"),
261
+ onChange: (o) => F(t.id, {
243
262
  inherits: (Array.isArray(o) ? o : [o]).filter(
244
- (n) => !he(c, t.id, n) || (t.inherits ?? []).includes(n)
263
+ (n) => !ve(m, t.id, n) || (t.inherits ?? []).includes(n)
245
264
  )
246
265
  }),
247
266
  disabled: !e
248
267
  }
249
268
  ),
250
- t.system && /* @__PURE__ */ u("p", { className: "nice-role-editor__hint", children: [
251
- /* @__PURE__ */ l(v, { name: "lock", size: 12 }),
269
+ t.system && /* @__PURE__ */ f("p", { className: "nice-role-editor__hint", children: [
270
+ /* @__PURE__ */ r(E, { name: "lock", size: 12 }),
252
271
  " ",
253
- r("roleEditor.systemHint", "A built-in role: it cannot be changed or removed.")
272
+ l && !e ? i(
273
+ "roleEditor.systemAssignHint",
274
+ "A built-in role: it cannot be changed or removed, but people can be given it."
275
+ ) : i("roleEditor.systemHint", "A built-in role: it cannot be changed or removed.")
254
276
  ] })
255
277
  ] }),
256
- k && /* @__PURE__ */ l(
257
- We,
278
+ C && /* @__PURE__ */ r(
279
+ oo,
258
280
  {
259
281
  options: [
260
282
  {
261
283
  value: "permissions",
262
- label: r("roleEditor.permissions", "Permissions ({count})").replace(
284
+ label: i("roleEditor.permissions", "Permissions ({count})").replace(
263
285
  "{count}",
264
- String(d.length)
286
+ String(s.length)
265
287
  )
266
288
  },
267
289
  {
268
290
  value: "users",
269
- label: r("roleEditor.users", "Users ({count})").replace(
291
+ label: i("roleEditor.users", "Users ({count})").replace(
270
292
  "{count}",
271
- String(s.length)
293
+ String(u.length)
272
294
  )
273
295
  }
274
296
  ],
275
- value: B,
276
- onChange: Oe,
297
+ value: W,
298
+ onChange: $e,
277
299
  size: "sm"
278
300
  }
279
301
  ),
280
- (!k || B === "permissions") && /* @__PURE__ */ l("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ l(
281
- ae,
302
+ (!C || W === "permissions") && /* @__PURE__ */ r("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ r(
303
+ be,
282
304
  {
283
- data: N,
305
+ data: y,
284
306
  nested: !0,
285
307
  keyField: "key",
286
- columns: f,
308
+ columns: N,
287
309
  checkable: !0,
288
310
  checkStrategy: "leaves",
289
- checkedKeys: d,
290
- onCheckedChange: (o) => se(t, o),
291
- isRowDisabled: (o) => !!o.code && a.has(o.code),
311
+ checkedKeys: s,
312
+ onCheckedChange: (o) => fe(t, o),
313
+ isRowDisabled: (o) => !!o.code && c.has(o.code),
292
314
  getRowLabel: (o) => o.label,
293
- defaultExpandedKeys: ie,
315
+ defaultExpandedKeys: ue,
294
316
  searchable: !0,
295
- searchPlaceholder: r("roleEditor.searchPermissions", "Search permissions"),
317
+ searchPlaceholder: i("roleEditor.searchPermissions", "Search permissions"),
296
318
  searchFields: ["label", "code"],
297
319
  toolbarActions: ["onlyChecked"],
298
320
  showCheckedCount: !0,
299
- size: U,
321
+ size: L,
300
322
  compact: !0,
301
323
  readOnly: !e,
302
- emptyText: r("roleEditor.noPermissions", "No permissions to choose from")
324
+ emptyText: i("roleEditor.noPermissions", "No permissions to choose from")
303
325
  },
304
326
  t.id
305
327
  ) }),
306
- k && B === "users" && /* @__PURE__ */ u("div", { className: "nice-role-editor__users", children: [
307
- e && p.length > 0 && /* @__PURE__ */ l(
308
- de,
328
+ C && W === "users" && /* @__PURE__ */ f("div", { className: "nice-role-editor__users", children: [
329
+ l && (d.length > 0 || !!v) && /* @__PURE__ */ r(
330
+ Ne,
309
331
  {
310
332
  size: "sm",
311
- searchable: !0,
312
- "aria-label": r("roleEditor.addUser", "Give this role to…"),
313
- placeholder: r("roleEditor.addUser", "Give this role to…"),
314
- options: p.map((o) => ({
333
+ searchable: !v,
334
+ onSearch: v ? Ue : void 0,
335
+ loading: Be,
336
+ "aria-label": i("roleEditor.addUser", "Give this role to…"),
337
+ placeholder: i("roleEditor.addUser", "Give this role to…"),
338
+ options: d.map((o) => ({
315
339
  value: o.id,
316
340
  label: o.email ? `${o.label} (${o.email})` : o.label
317
341
  })),
318
342
  value: "",
319
343
  onChange: (o) => {
320
344
  const n = Array.isArray(o) ? o[0] : o;
321
- n && L(
322
- _.map(
323
- (h) => h.id === n ? { ...h, roleIds: [...h.roleIds, t.id] } : h
324
- )
325
- );
345
+ if (!n)
346
+ return;
347
+ if (_.some((p) => p.id === n)) {
348
+ O(
349
+ _.map(
350
+ (p) => p.id === n ? { ...p, roleIds: [...p.roleIds, t.id] } : p
351
+ )
352
+ );
353
+ return;
354
+ }
355
+ const h = me.find((p) => p.id === n);
356
+ h && O([
357
+ ..._,
358
+ {
359
+ ...h,
360
+ roleIds: [...h.roleIds.filter((p) => p !== t.id), t.id]
361
+ }
362
+ ]);
326
363
  }
327
364
  }
328
365
  ),
329
- s.length === 0 && /* @__PURE__ */ l("p", { className: "nice-role-editor__hint", children: r("roleEditor.noUsers", "Nobody has this role yet.") }),
330
- /* @__PURE__ */ l("ul", { className: "nice-role-editor__user-list", children: s.map((o) => /* @__PURE__ */ u("li", { className: "nice-role-editor__user", children: [
331
- /* @__PURE__ */ l(v, { name: "user", size: 14 }),
332
- /* @__PURE__ */ l("span", { className: "nice-role-editor__user-name", children: o.label }),
333
- o.email && /* @__PURE__ */ l("span", { className: "nice-role-editor__code", children: o.email }),
334
- e && /* @__PURE__ */ l(
335
- C,
366
+ u.length === 0 && /* @__PURE__ */ r("p", { className: "nice-role-editor__hint", children: i("roleEditor.noUsers", "Nobody has this role yet.") }),
367
+ /* @__PURE__ */ r("ul", { className: "nice-role-editor__user-list", children: u.map((o) => /* @__PURE__ */ f("li", { className: "nice-role-editor__user", children: [
368
+ /* @__PURE__ */ r(E, { name: "user", size: 14 }),
369
+ /* @__PURE__ */ r("span", { className: "nice-role-editor__user-name", children: o.label }),
370
+ o.email && /* @__PURE__ */ r("span", { className: "nice-role-editor__code", children: o.email }),
371
+ l && /* @__PURE__ */ r(
372
+ I,
336
373
  {
337
374
  variant: "ghost",
338
375
  size: "sm",
339
- ariaLabel: r("roleEditor.takeAway", "Take the role from {label}").replace(
376
+ ariaLabel: i("roleEditor.takeAway", "Take the role from {label}").replace(
340
377
  "{label}",
341
378
  o.label
342
379
  ),
343
- title: r("roleEditor.takeAway", "Take the role from {label}").replace(
380
+ title: i("roleEditor.takeAway", "Take the role from {label}").replace(
344
381
  "{label}",
345
382
  o.label
346
383
  ),
347
- onClick: () => L(
384
+ onClick: () => O(
348
385
  _.map(
349
386
  (n) => n.id === o.id ? { ...n, roleIds: n.roleIds.filter((h) => h !== t.id) } : n
350
387
  )
351
388
  ),
352
- children: /* @__PURE__ */ l(v, { name: "close", size: 14 })
389
+ children: /* @__PURE__ */ r(E, { name: "close", size: 14 })
353
390
  }
354
391
  )
355
392
  ] }, o.id)) })
356
393
  ] })
357
394
  ] });
358
- }, je = () => {
359
- const e = new Map(c.map((s) => [s.id, W(s)])), i = (s, p) => {
360
- const m = e.get(s);
361
- return !!m && (m.own.has(p) || m.inherited.has(p));
362
- }, a = (s, p, m) => {
363
- const f = e.get(s.id);
364
- if (!f)
395
+ }, He = () => {
396
+ const e = new Map(m.map((s) => [s.id, Z(s)])), l = (s, u) => {
397
+ const d = e.get(s);
398
+ return !!d && (d.own.has(u) || d.inherited.has(u));
399
+ }, a = (s, u, d) => {
400
+ const b = e.get(s.id);
401
+ if (!b)
365
402
  return;
366
- const o = new Set(f.own);
367
- p.forEach((n) => m ? o.add(n) : o.delete(n)), se(s, o);
368
- }, d = [
403
+ const N = new Set(b.own);
404
+ u.forEach((o) => d ? N.add(o) : N.delete(o)), fe(s, N);
405
+ }, c = [
369
406
  {
370
407
  field: "label",
371
- header: r("roleEditor.permission", "Permission"),
408
+ header: i("roleEditor.permission", "Permission"),
372
409
  minWidth: 260,
373
410
  // narrow role columns leave no room for the code: it is the row's tooltip here
374
- render: (s, p) => /* @__PURE__ */ l("span", { className: "nice-role-editor__perm nice-role-editor__perm--line", title: p.code, children: p.label })
411
+ render: (s, u) => /* @__PURE__ */ r("span", { className: "nice-role-editor__perm nice-role-editor__perm--line", title: u.code, children: u.label })
375
412
  },
376
- ...c.map((s) => ({
413
+ ...m.map((s) => ({
377
414
  field: `role:${s.id}`,
378
415
  header: s.label,
379
416
  align: "center",
380
- render: (p, m) => {
381
- const f = e.get(s.id), o = G(s);
382
- if (m.code) {
383
- const y = f?.inherited.get(m.code), q = !!y && !f?.own.has(m.code);
384
- return /* @__PURE__ */ l(
385
- pe,
417
+ render: (u, d) => {
418
+ const b = e.get(s.id), N = X(s);
419
+ if (d.code) {
420
+ const h = b?.inherited.get(d.code), p = !!h && !b?.own.has(d.code);
421
+ return /* @__PURE__ */ r(
422
+ ye,
386
423
  {
387
- checked: i(s.id, m.code),
388
- disabled: !o || q,
389
- muted: q,
390
- label: `${s.label}: ${m.code}`,
391
- title: q ? r("roleEditor.inheritedFrom", "From {roles}").replace(
424
+ checked: l(s.id, d.code),
425
+ disabled: !N || p,
426
+ muted: p,
427
+ label: `${s.label}: ${d.code}`,
428
+ title: p ? i("roleEditor.inheritedFrom", "From {roles}").replace(
392
429
  "{roles}",
393
- (y ?? []).map(te).join(", ")
430
+ (h ?? []).map(pe).join(", ")
394
431
  ) : void 0,
395
- onChange: (Be) => a(s, [m.code], Be)
432
+ onChange: (Je) => a(s, [d.code], Je)
396
433
  }
397
434
  );
398
435
  }
399
- const n = Me.get(m.key) ?? [], h = n.filter((y) => i(s.id, y)).length;
400
- return /* @__PURE__ */ l(
401
- pe,
436
+ const o = Ke.get(d.key) ?? [], n = o.filter((h) => l(s.id, h)).length;
437
+ return /* @__PURE__ */ r(
438
+ ye,
402
439
  {
403
- checked: n.length > 0 && h === n.length,
404
- mixed: h > 0 && h < n.length,
405
- disabled: !o || n.length === 0,
406
- label: `${s.label}: ${m.label}`,
440
+ checked: o.length > 0 && n === o.length,
441
+ mixed: n > 0 && n < o.length,
442
+ disabled: !N || o.length === 0,
443
+ label: `${s.label}: ${d.label}`,
407
444
  onChange: () => a(
408
445
  s,
409
- n.filter((y) => !f?.inherited.has(y)),
410
- h < n.length
446
+ o.filter((h) => !b?.inherited.has(h)),
447
+ n < o.length
411
448
  )
412
449
  }
413
450
  );
414
451
  }
415
452
  }))
416
453
  ];
417
- return /* @__PURE__ */ l("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ l(
418
- ae,
454
+ return /* @__PURE__ */ r("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ r(
455
+ be,
419
456
  {
420
- data: N,
457
+ data: y,
421
458
  nested: !0,
422
459
  keyField: "key",
423
- columns: d,
424
- defaultExpandedKeys: ie,
460
+ columns: c,
461
+ defaultExpandedKeys: ue,
425
462
  searchable: !0,
426
- searchPlaceholder: r("roleEditor.searchPermissions", "Search permissions"),
463
+ searchPlaceholder: i("roleEditor.searchPermissions", "Search permissions"),
427
464
  searchFields: ["label", "code"],
428
- size: U,
465
+ size: L,
429
466
  compact: !0,
430
- emptyText: r("roleEditor.noPermissions", "No permissions to choose from")
467
+ emptyText: i("roleEditor.noPermissions", "No permissions to choose from")
431
468
  }
432
469
  ) });
433
470
  };
434
- return /* @__PURE__ */ l(
471
+ return /* @__PURE__ */ r(
435
472
  "div",
436
473
  {
437
- id: oe,
438
- title: Re,
439
- "data-testid": Se,
474
+ id: ce,
475
+ title: ze,
476
+ "data-testid": Oe,
440
477
  className: [
441
478
  "nice-role-editor",
442
- j ? "nice-role-editor--disabled" : "",
443
- ge ?? ""
479
+ D ? "nice-role-editor--disabled" : "",
480
+ Te ?? ""
444
481
  ].filter(Boolean).join(" "),
445
- style: { ...ee !== void 0 ? { height: ee } : {}, ...ke },
446
- "aria-disabled": j || void 0,
447
- children: /* @__PURE__ */ u("div", { className: "nice-role-editor__layout", children: [
448
- /* @__PURE__ */ u(
482
+ style: { ...ae !== void 0 ? { height: ae } : {}, ...we },
483
+ "aria-disabled": D || void 0,
484
+ children: /* @__PURE__ */ f("div", { className: "nice-role-editor__layout", children: [
485
+ /* @__PURE__ */ f(
449
486
  "section",
450
487
  {
451
488
  className: "nice-role-editor__column nice-role-editor__column--roles",
452
- "aria-label": r("roleEditor.roles", "Roles"),
489
+ "aria-label": i("roleEditor.roles", "Roles"),
453
490
  children: [
454
- /* @__PURE__ */ u("header", { className: "nice-role-editor__head", children: [
455
- /* @__PURE__ */ l("span", { className: "nice-role-editor__title", children: r("roleEditor.roles", "Roles") }),
456
- !le && /* @__PURE__ */ u(
491
+ /* @__PURE__ */ f("header", { className: "nice-role-editor__head", children: [
492
+ /* @__PURE__ */ r("span", { className: "nice-role-editor__title", children: i("roleEditor.roles", "Roles") }),
493
+ !G && /* @__PURE__ */ f(
457
494
  "span",
458
495
  {
459
496
  className: "nice-role-editor__tools",
460
497
  role: "group",
461
- "aria-label": r("roleEditor.tools", "Role tools"),
498
+ "aria-label": i("roleEditor.tools", "Role tools"),
462
499
  children: [
463
- Y(r("roleEditor.addRole", "New role"), "plus", !0, Ve),
464
- Y(r("roleEditor.copyRole", "Copy role"), "copy", !!t, Fe),
465
- Y(
466
- r("roleEditor.removeRole", "Remove role"),
500
+ ee(i("roleEditor.addRole", "New role"), "plus", !0, Le),
501
+ ee(i("roleEditor.copyRole", "Copy role"), "copy", !!t, qe),
502
+ ee(
503
+ i("roleEditor.removeRole", "Remove role"),
467
504
  "trash",
468
- G(t),
469
- () => K(t?.id ?? null)
505
+ X(t),
506
+ () => Y(t?.id ?? null)
470
507
  )
471
508
  ]
472
509
  }
473
510
  )
474
511
  ] }),
475
- I && t && I === t.id && /* @__PURE__ */ u(
512
+ z && t && z === t.id && /* @__PURE__ */ f(
476
513
  "div",
477
514
  {
478
- ref: re,
515
+ ref: de,
479
516
  className: "nice-role-editor__confirm",
480
517
  role: "group",
481
- "aria-label": r("roleEditor.removeRole", "Remove role"),
518
+ "aria-label": i("roleEditor.removeRole", "Remove role"),
482
519
  children: [
483
- /* @__PURE__ */ l("span", { children: r(
520
+ /* @__PURE__ */ r("span", { children: i(
484
521
  "roleEditor.confirmRemove",
485
522
  "Remove {label}? Users lose it and roles stop inheriting it."
486
523
  ).replace("{label}", t.label) }),
487
- /* @__PURE__ */ u("span", { className: "nice-role-editor__confirm-actions", children: [
488
- /* @__PURE__ */ l(C, { size: "sm", variant: "error", onClick: xe, children: r("roleEditor.remove", "Remove") }),
489
- /* @__PURE__ */ l(C, { size: "sm", variant: "ghost", onClick: () => K(null), children: r("roleEditor.cancel", "Cancel") })
524
+ /* @__PURE__ */ f("span", { className: "nice-role-editor__confirm-actions", children: [
525
+ /* @__PURE__ */ r(I, { size: "sm", variant: "error", onClick: De, children: i("roleEditor.remove", "Remove") }),
526
+ /* @__PURE__ */ r(I, { size: "sm", variant: "ghost", onClick: () => Y(null), children: i("roleEditor.cancel", "Cancel") })
490
527
  ] })
491
528
  ]
492
529
  }
493
530
  ),
494
- /* @__PURE__ */ l("div", { className: "nice-role-editor__body", children: /* @__PURE__ */ l(
495
- Ge,
531
+ /* @__PURE__ */ r("div", { className: "nice-role-editor__body", children: /* @__PURE__ */ r(
532
+ eo,
496
533
  {
497
- items: Ae,
534
+ items: Ge,
498
535
  selectionMode: "single",
499
536
  selectedKeys: t ? [t.id] : [],
500
537
  onSelectionChange: (e) => {
501
- e[0] && (P(e[0]), D("role"));
538
+ e[0] && (A(e[0]), Q("role"));
502
539
  },
503
- searchable: c.length > 8,
504
- searchPlaceholder: r("roleEditor.searchRoles", "Search roles"),
505
- renderItem: Ue,
506
- size: U,
507
- emptyText: r("roleEditor.noRolesShort", "No roles")
540
+ searchable: m.length > 8,
541
+ searchPlaceholder: i("roleEditor.searchRoles", "Search roles"),
542
+ renderItem: We,
543
+ size: L,
544
+ emptyText: i("roleEditor.noRolesShort", "No roles")
508
545
  }
509
546
  ) }),
510
- /* @__PURE__ */ l("footer", { className: "nice-role-editor__foot", children: /* @__PURE__ */ l(
511
- C,
547
+ /* @__PURE__ */ r("footer", { className: "nice-role-editor__foot", children: /* @__PURE__ */ r(
548
+ I,
512
549
  {
513
550
  size: "sm",
514
- variant: R === "compare" ? "primary" : "ghost",
515
- "aria-pressed": R === "compare",
516
- leftIcon: /* @__PURE__ */ l(v, { name: "columns", size: 14 }),
517
- onClick: () => D(R === "compare" ? "role" : "compare"),
551
+ variant: S === "compare" ? "primary" : "ghost",
552
+ "aria-pressed": S === "compare",
553
+ leftIcon: /* @__PURE__ */ r(E, { name: "columns", size: 14 }),
554
+ onClick: () => Q(S === "compare" ? "role" : "compare"),
518
555
  fullWidth: !0,
519
- children: r("roleEditor.compare", "Compare roles")
556
+ children: i("roleEditor.compare", "Compare roles")
520
557
  }
521
558
  ) })
522
559
  ]
523
560
  }
524
561
  ),
525
- /* @__PURE__ */ l(
562
+ /* @__PURE__ */ r(
526
563
  "section",
527
564
  {
528
565
  className: "nice-role-editor__column nice-role-editor__column--main",
529
- "aria-label": R === "compare" ? r("roleEditor.compare", "Compare roles") : t?.label ?? r("roleEditor.role", "Role"),
530
- children: /* @__PURE__ */ l("div", { className: "nice-role-editor__body nice-role-editor__main", children: R === "compare" ? je() : $e() })
566
+ "aria-label": S === "compare" ? i("roleEditor.compare", "Compare roles") : t?.label ?? i("roleEditor.role", "Role"),
567
+ children: /* @__PURE__ */ r("div", { className: "nice-role-editor__body nice-role-editor__main", children: S === "compare" ? He() : Ye() })
531
568
  }
532
569
  )
533
570
  ] })
@@ -535,5 +572,5 @@ const Xe = [], Ze = [], eo = [], pe = ({ checked: b, mixed: E = !1, disabled: M,
535
572
  );
536
573
  };
537
574
  export {
538
- uo as NiceRoleEditor
575
+ ko as NiceRoleEditor
539
576
  };