@nice2dev/ui 1.4.14 → 1.4.16
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/CHANGELOG.md +80 -0
- package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
- package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
- package/dist/NiceForm-fmePSeA9.cjs +1 -0
- package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
- package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
- package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
- package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
- package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
- package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
- package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
- package/dist/backup/NiceBackupScheduler.mjs +171 -119
- package/dist/charts/NiceOrganizationChart.mjs +159 -59
- package/dist/charts/orgChartExport.mjs +71 -0
- package/dist/charts/tidyTree.mjs +43 -0
- package/dist/charts-C3Q3r8Yz.cjs +918 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +9 -0
- package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
- package/dist/data/NiceDataGrid.mjs +301 -320
- package/dist/data/NiceRowEditDialog.mjs +57 -0
- package/dist/data/NiceTreeGrid.mjs +478 -433
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +43 -2
- package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
- package/dist/devops.cjs +1 -1
- package/dist/editors/forms/NiceForm.mjs +216 -167
- package/dist/editors/inputs/NiceUpload.mjs +238 -238
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +13 -1
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +254 -254
- package/dist/index.d.ts +198 -5
- package/dist/index.mjs +928 -920
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +11 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceDataMapper.mjs +398 -361
- package/dist/no-code-CN_q6TcB.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +11 -1
- package/dist/style.css +1 -1
- package/dist/tools/NicePermissionMatrix.mjs +171 -138
- package/dist/tools/NiceRoleEditor.mjs +334 -297
- package/package.json +4 -4
- package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
- package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
- package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
- package/dist/NiceSavedQueryPanel-C1nxEmMu.cjs +0 -587
- package/dist/charts-BzlvCCg9.cjs +0 -768
- package/dist/no-code-B1jzfUF5.cjs +0 -331
|
@@ -1,533 +1,570 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { NiceButton as
|
|
5
|
-
import { NiceList as
|
|
6
|
-
import { NiceTreeGrid as
|
|
7
|
-
import { walkTreeNodes as
|
|
8
|
-
import { NiceSegmentedControl as
|
|
9
|
-
import { NiceSelect as
|
|
10
|
-
import { NiceTextInput as
|
|
11
|
-
import { permissionTree as
|
|
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
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
}, [
|
|
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:
|
|
20
|
+
ref: R,
|
|
21
21
|
type: "checkbox",
|
|
22
22
|
className: `nice-role-editor__check${w ? " nice-role-editor__check--inherited" : ""}`,
|
|
23
|
-
checked:
|
|
24
|
-
disabled:
|
|
25
|
-
"aria-label":
|
|
26
|
-
"aria-checked":
|
|
27
|
-
title:
|
|
28
|
-
onChange: (
|
|
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
|
-
},
|
|
32
|
-
permissions:
|
|
33
|
-
value:
|
|
34
|
-
defaultValue:
|
|
35
|
-
onChange:
|
|
36
|
-
users:
|
|
31
|
+
}, ko = ({
|
|
32
|
+
permissions: g = no,
|
|
33
|
+
value: k,
|
|
34
|
+
defaultValue: $,
|
|
35
|
+
onChange: j,
|
|
36
|
+
users: T,
|
|
37
37
|
defaultUsers: w,
|
|
38
|
-
onUsersChange:
|
|
39
|
-
selectedRoleId:
|
|
40
|
-
defaultSelectedRoleId:
|
|
41
|
-
onSelectedRoleChange:
|
|
42
|
-
view:
|
|
43
|
-
defaultView:
|
|
44
|
-
onViewChange:
|
|
45
|
-
inheritance:
|
|
46
|
-
groupPermission:
|
|
47
|
-
segmentLabel:
|
|
48
|
-
canEditRole:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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:
|
|
62
|
-
value:
|
|
63
|
-
defaultValue:
|
|
64
|
-
fallbackValue:
|
|
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
|
-
}), [_,
|
|
67
|
-
value:
|
|
68
|
+
}), [_, Fe] = M({
|
|
69
|
+
value: T,
|
|
68
70
|
defaultValue: w,
|
|
69
|
-
fallbackValue:
|
|
71
|
+
fallbackValue: co,
|
|
70
72
|
componentName: "NiceRoleEditor"
|
|
71
|
-
}),
|
|
72
|
-
value:
|
|
73
|
-
defaultValue:
|
|
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
|
-
}), [
|
|
77
|
-
value:
|
|
78
|
-
defaultValue:
|
|
78
|
+
}), [S, xe] = M({
|
|
79
|
+
value: ke,
|
|
80
|
+
defaultValue: Re,
|
|
79
81
|
fallbackValue: "role",
|
|
80
82
|
componentName: "NiceRoleEditor"
|
|
81
|
-
}), [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, [
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
),
|
|
103
|
-
}, [
|
|
116
|
+
), l;
|
|
117
|
+
}, [y, g.length]), Ke = oe(() => {
|
|
104
118
|
const e = /* @__PURE__ */ new Map();
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
(
|
|
108
|
-
|
|
109
|
-
const s = e.get(
|
|
110
|
-
s.push(
|
|
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
|
-
}, [
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
}), { own: a, inherited:
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
const { inherited: a } =
|
|
125
|
-
for (const s of
|
|
126
|
-
!s.startsWith("group:") && !a.has(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) &&
|
|
129
|
-
}),
|
|
130
|
-
},
|
|
131
|
-
const e =
|
|
132
|
-
|
|
133
|
-
},
|
|
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 =
|
|
137
|
-
|
|
138
|
-
},
|
|
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 =
|
|
142
|
-
|
|
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 (
|
|
158
|
+
if (q === "hidden")
|
|
145
159
|
return null;
|
|
146
|
-
const
|
|
160
|
+
const Ge = m.map((e) => ({
|
|
147
161
|
key: e.id,
|
|
148
162
|
text: e.label,
|
|
149
|
-
badge:
|
|
150
|
-
})),
|
|
151
|
-
const
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
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:
|
|
171
|
+
style: l?.color ? { background: l.color } : void 0,
|
|
158
172
|
"aria-hidden": "true"
|
|
159
173
|
}
|
|
160
174
|
),
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
|
|
163
|
-
e.badge !== void 0 && /* @__PURE__ */
|
|
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:
|
|
181
|
+
title: i("roleEditor.userCount", "Users with this role"),
|
|
168
182
|
children: e.badge
|
|
169
183
|
}
|
|
170
184
|
)
|
|
171
185
|
] });
|
|
172
|
-
},
|
|
173
|
-
|
|
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:
|
|
181
|
-
children: /* @__PURE__ */
|
|
194
|
+
onClick: c,
|
|
195
|
+
children: /* @__PURE__ */ r(E, { name: l, size: 16 })
|
|
182
196
|
}
|
|
183
|
-
),
|
|
197
|
+
), Ye = () => {
|
|
184
198
|
if (!t)
|
|
185
|
-
return /* @__PURE__ */
|
|
186
|
-
const e = G(t), { own:
|
|
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) &&
|
|
190
|
-
})),
|
|
205
|
+
disabled: !(t.inherits ?? []).includes(o.id) && ve(m, t.id, o.id)
|
|
206
|
+
})), N = [
|
|
191
207
|
{
|
|
192
208
|
field: "label",
|
|
193
|
-
header:
|
|
194
|
-
render: (o, n) => /* @__PURE__ */
|
|
195
|
-
/* @__PURE__ */
|
|
196
|
-
|
|
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
|
-
...
|
|
218
|
+
...K ? [
|
|
200
219
|
{
|
|
201
220
|
field: "code",
|
|
202
|
-
header:
|
|
221
|
+
header: i("roleEditor.from", "From"),
|
|
203
222
|
render: (o, n) => {
|
|
204
|
-
const h = n.code ?
|
|
205
|
-
return h ? /* @__PURE__ */
|
|
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__ */
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
|
|
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:
|
|
234
|
+
label: i("roleEditor.name", "Name"),
|
|
216
235
|
size: "sm",
|
|
217
236
|
value: t.label,
|
|
218
|
-
onChange: (o) =>
|
|
237
|
+
onChange: (o) => F(t.id, { label: o }),
|
|
219
238
|
readOnly: !e
|
|
220
239
|
}
|
|
221
240
|
),
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
|
|
241
|
+
/* @__PURE__ */ r(
|
|
242
|
+
ge,
|
|
224
243
|
{
|
|
225
|
-
label:
|
|
244
|
+
label: i("roleEditor.description", "Description"),
|
|
226
245
|
size: "sm",
|
|
227
246
|
value: t.description ?? "",
|
|
228
|
-
onChange: (o) =>
|
|
247
|
+
onChange: (o) => F(t.id, { description: o || void 0 }),
|
|
229
248
|
readOnly: !e
|
|
230
249
|
}
|
|
231
250
|
),
|
|
232
|
-
|
|
233
|
-
|
|
251
|
+
K && /* @__PURE__ */ r(
|
|
252
|
+
Ne,
|
|
234
253
|
{
|
|
235
|
-
label:
|
|
254
|
+
label: i("roleEditor.inherits", "Inherits from"),
|
|
236
255
|
size: "sm",
|
|
237
256
|
multiple: !0,
|
|
238
257
|
searchable: !0,
|
|
239
|
-
options:
|
|
258
|
+
options: b,
|
|
240
259
|
value: t.inherits ?? [],
|
|
241
|
-
placeholder:
|
|
242
|
-
onChange: (o) =>
|
|
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) => !
|
|
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__ */
|
|
251
|
-
/* @__PURE__ */
|
|
269
|
+
t.system && /* @__PURE__ */ f("p", { className: "nice-role-editor__hint", children: [
|
|
270
|
+
/* @__PURE__ */ r(E, { name: "lock", size: 12 }),
|
|
252
271
|
" ",
|
|
253
|
-
|
|
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
|
-
|
|
257
|
-
|
|
278
|
+
C && /* @__PURE__ */ r(
|
|
279
|
+
oo,
|
|
258
280
|
{
|
|
259
281
|
options: [
|
|
260
282
|
{
|
|
261
283
|
value: "permissions",
|
|
262
|
-
label:
|
|
284
|
+
label: i("roleEditor.permissions", "Permissions ({count})").replace(
|
|
263
285
|
"{count}",
|
|
264
|
-
String(
|
|
286
|
+
String(s.length)
|
|
265
287
|
)
|
|
266
288
|
},
|
|
267
289
|
{
|
|
268
290
|
value: "users",
|
|
269
|
-
label:
|
|
291
|
+
label: i("roleEditor.users", "Users ({count})").replace(
|
|
270
292
|
"{count}",
|
|
271
|
-
String(
|
|
293
|
+
String(u.length)
|
|
272
294
|
)
|
|
273
295
|
}
|
|
274
296
|
],
|
|
275
|
-
value:
|
|
276
|
-
onChange:
|
|
297
|
+
value: W,
|
|
298
|
+
onChange: $e,
|
|
277
299
|
size: "sm"
|
|
278
300
|
}
|
|
279
301
|
),
|
|
280
|
-
(!
|
|
281
|
-
|
|
302
|
+
(!C || W === "permissions") && /* @__PURE__ */ r("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ r(
|
|
303
|
+
be,
|
|
282
304
|
{
|
|
283
|
-
data:
|
|
305
|
+
data: y,
|
|
284
306
|
nested: !0,
|
|
285
307
|
keyField: "key",
|
|
286
|
-
columns:
|
|
308
|
+
columns: N,
|
|
287
309
|
checkable: !0,
|
|
288
310
|
checkStrategy: "leaves",
|
|
289
|
-
checkedKeys:
|
|
290
|
-
onCheckedChange: (o) =>
|
|
291
|
-
isRowDisabled: (o) => !!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:
|
|
315
|
+
defaultExpandedKeys: ue,
|
|
294
316
|
searchable: !0,
|
|
295
|
-
searchPlaceholder:
|
|
317
|
+
searchPlaceholder: i("roleEditor.searchPermissions", "Search permissions"),
|
|
296
318
|
searchFields: ["label", "code"],
|
|
297
319
|
toolbarActions: ["onlyChecked"],
|
|
298
320
|
showCheckedCount: !0,
|
|
299
|
-
size:
|
|
321
|
+
size: L,
|
|
300
322
|
compact: !0,
|
|
301
323
|
readOnly: !e,
|
|
302
|
-
emptyText:
|
|
324
|
+
emptyText: i("roleEditor.noPermissions", "No permissions to choose from")
|
|
303
325
|
},
|
|
304
326
|
t.id
|
|
305
327
|
) }),
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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: !
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
/* @__PURE__ */
|
|
333
|
-
o.email && /* @__PURE__ */
|
|
334
|
-
|
|
335
|
-
|
|
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:
|
|
376
|
+
ariaLabel: i("roleEditor.takeAway", "Take the role from {label}").replace(
|
|
340
377
|
"{label}",
|
|
341
378
|
o.label
|
|
342
379
|
),
|
|
343
|
-
title:
|
|
380
|
+
title: i("roleEditor.takeAway", "Take the role from {label}").replace(
|
|
344
381
|
"{label}",
|
|
345
382
|
o.label
|
|
346
383
|
),
|
|
347
|
-
onClick: () =>
|
|
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__ */
|
|
389
|
+
children: /* @__PURE__ */ r(E, { name: "close", size: 14 })
|
|
353
390
|
}
|
|
354
391
|
)
|
|
355
392
|
] }, o.id)) })
|
|
356
393
|
] })
|
|
357
394
|
] });
|
|
358
|
-
},
|
|
359
|
-
const e = new Map(
|
|
360
|
-
const
|
|
361
|
-
return !!
|
|
362
|
-
}, a = (s,
|
|
363
|
-
const
|
|
364
|
-
if (!
|
|
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
|
|
367
|
-
|
|
368
|
-
},
|
|
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:
|
|
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,
|
|
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
|
-
...
|
|
413
|
+
...m.map((s) => ({
|
|
377
414
|
field: `role:${s.id}`,
|
|
378
415
|
header: s.label,
|
|
379
416
|
align: "center",
|
|
380
|
-
render: (
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
return /* @__PURE__ */
|
|
385
|
-
|
|
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:
|
|
388
|
-
disabled: !
|
|
389
|
-
muted:
|
|
390
|
-
label: `${s.label}: ${
|
|
391
|
-
title:
|
|
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
|
-
(
|
|
430
|
+
(h ?? []).map(pe).join(", ")
|
|
394
431
|
) : void 0,
|
|
395
|
-
onChange: (
|
|
432
|
+
onChange: (Je) => a(s, [d.code], Je)
|
|
396
433
|
}
|
|
397
434
|
);
|
|
398
435
|
}
|
|
399
|
-
const
|
|
400
|
-
return /* @__PURE__ */
|
|
401
|
-
|
|
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:
|
|
404
|
-
mixed:
|
|
405
|
-
disabled: !
|
|
406
|
-
label: `${s.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
|
-
|
|
410
|
-
|
|
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__ */
|
|
418
|
-
|
|
454
|
+
return /* @__PURE__ */ r("div", { className: "nice-role-editor__grid", children: /* @__PURE__ */ r(
|
|
455
|
+
be,
|
|
419
456
|
{
|
|
420
|
-
data:
|
|
457
|
+
data: y,
|
|
421
458
|
nested: !0,
|
|
422
459
|
keyField: "key",
|
|
423
|
-
columns:
|
|
424
|
-
defaultExpandedKeys:
|
|
460
|
+
columns: c,
|
|
461
|
+
defaultExpandedKeys: ue,
|
|
425
462
|
searchable: !0,
|
|
426
|
-
searchPlaceholder:
|
|
463
|
+
searchPlaceholder: i("roleEditor.searchPermissions", "Search permissions"),
|
|
427
464
|
searchFields: ["label", "code"],
|
|
428
|
-
size:
|
|
465
|
+
size: L,
|
|
429
466
|
compact: !0,
|
|
430
|
-
emptyText:
|
|
467
|
+
emptyText: i("roleEditor.noPermissions", "No permissions to choose from")
|
|
431
468
|
}
|
|
432
469
|
) });
|
|
433
470
|
};
|
|
434
|
-
return /* @__PURE__ */
|
|
471
|
+
return /* @__PURE__ */ r(
|
|
435
472
|
"div",
|
|
436
473
|
{
|
|
437
|
-
id:
|
|
438
|
-
title:
|
|
439
|
-
"data-testid":
|
|
474
|
+
id: ce,
|
|
475
|
+
title: ze,
|
|
476
|
+
"data-testid": Oe,
|
|
440
477
|
className: [
|
|
441
478
|
"nice-role-editor",
|
|
442
|
-
|
|
443
|
-
|
|
479
|
+
D ? "nice-role-editor--disabled" : "",
|
|
480
|
+
Te ?? ""
|
|
444
481
|
].filter(Boolean).join(" "),
|
|
445
|
-
style: { ...
|
|
446
|
-
"aria-disabled":
|
|
447
|
-
children: /* @__PURE__ */
|
|
448
|
-
/* @__PURE__ */
|
|
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":
|
|
489
|
+
"aria-label": i("roleEditor.roles", "Roles"),
|
|
453
490
|
children: [
|
|
454
|
-
/* @__PURE__ */
|
|
455
|
-
/* @__PURE__ */
|
|
456
|
-
!
|
|
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":
|
|
498
|
+
"aria-label": i("roleEditor.tools", "Role tools"),
|
|
462
499
|
children: [
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
469
|
-
() =>
|
|
505
|
+
X(t),
|
|
506
|
+
() => Y(t?.id ?? null)
|
|
470
507
|
)
|
|
471
508
|
]
|
|
472
509
|
}
|
|
473
510
|
)
|
|
474
511
|
] }),
|
|
475
|
-
|
|
512
|
+
z && t && z === t.id && /* @__PURE__ */ f(
|
|
476
513
|
"div",
|
|
477
514
|
{
|
|
478
|
-
ref:
|
|
515
|
+
ref: de,
|
|
479
516
|
className: "nice-role-editor__confirm",
|
|
480
517
|
role: "group",
|
|
481
|
-
"aria-label":
|
|
518
|
+
"aria-label": i("roleEditor.removeRole", "Remove role"),
|
|
482
519
|
children: [
|
|
483
|
-
/* @__PURE__ */
|
|
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__ */
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
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__ */
|
|
495
|
-
|
|
531
|
+
/* @__PURE__ */ r("div", { className: "nice-role-editor__body", children: /* @__PURE__ */ r(
|
|
532
|
+
eo,
|
|
496
533
|
{
|
|
497
|
-
items:
|
|
534
|
+
items: Ge,
|
|
498
535
|
selectionMode: "single",
|
|
499
536
|
selectedKeys: t ? [t.id] : [],
|
|
500
537
|
onSelectionChange: (e) => {
|
|
501
|
-
e[0] && (
|
|
538
|
+
e[0] && (A(e[0]), Q("role"));
|
|
502
539
|
},
|
|
503
|
-
searchable:
|
|
504
|
-
searchPlaceholder:
|
|
505
|
-
renderItem:
|
|
506
|
-
size:
|
|
507
|
-
emptyText:
|
|
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__ */
|
|
511
|
-
|
|
547
|
+
/* @__PURE__ */ r("footer", { className: "nice-role-editor__foot", children: /* @__PURE__ */ r(
|
|
548
|
+
I,
|
|
512
549
|
{
|
|
513
550
|
size: "sm",
|
|
514
|
-
variant:
|
|
515
|
-
"aria-pressed":
|
|
516
|
-
leftIcon: /* @__PURE__ */
|
|
517
|
-
onClick: () =>
|
|
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:
|
|
556
|
+
children: i("roleEditor.compare", "Compare roles")
|
|
520
557
|
}
|
|
521
558
|
) })
|
|
522
559
|
]
|
|
523
560
|
}
|
|
524
561
|
),
|
|
525
|
-
/* @__PURE__ */
|
|
562
|
+
/* @__PURE__ */ r(
|
|
526
563
|
"section",
|
|
527
564
|
{
|
|
528
565
|
className: "nice-role-editor__column nice-role-editor__column--main",
|
|
529
|
-
"aria-label":
|
|
530
|
-
children: /* @__PURE__ */
|
|
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
|
-
|
|
575
|
+
ko as NiceRoleEditor
|
|
539
576
|
};
|