@blocklet/labels 1.5.132 → 1.5.133
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/dist/components/label/LabelManager.stories.d.ts +8 -0
- package/dist/components/label/LabelPicker.stories.d.ts +5 -0
- package/dist/components/label/LabelTree.stories.d.ts +8 -0
- package/dist/components/label/context.d.ts +1 -1
- package/dist/components/label/label-delete-dialog.d.ts +1 -2
- package/dist/components/label/label-form-dialog.d.ts +1 -2
- package/dist/components/label/label-manager.d.ts +1 -2
- package/dist/components/label/label-picker.d.ts +1 -2
- package/dist/components/label/label-tree.d.ts +1 -1
- package/dist/components/label/labels.d.ts +1 -1
- package/dist/components/label/translation-input.d.ts +1 -2
- package/dist/components/label/types.d.ts +1 -1
- package/dist/index.es.js +345 -751
- package/dist/index.umd.js +3 -3
- package/dist/test/fixtures/index.d.ts +2 -0
- package/package.json +6 -6
- package/dist/global.d.ts +0 -9
- package/dist/vite-env.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { jsx as n, jsxs as C, Fragment as P } from "react/jsx-runtime";
|
|
1
2
|
import { createContext as q, useRef as D, useState as z, useCallback as k, useEffect as W, useMemo as T, useContext as H } from "react";
|
|
2
3
|
import { ExpandMore as R, Translate as X, Add as ee, EditOutlined as te, DeleteOutlineOutlined as ne, Edit as re, LabelOutlined as oe } from "@mui/icons-material";
|
|
3
4
|
import p from "@mui/material/Box";
|
|
4
5
|
import { styled as J } from "@mui/material/styles";
|
|
5
6
|
import { Tree as le } from "react-arborist";
|
|
6
7
|
import { Icon as ie } from "@iconify/react";
|
|
7
|
-
import { jsx as n, jsxs as C, Fragment as P } from "react/jsx-runtime";
|
|
8
8
|
import ae from "lodash/omit";
|
|
9
9
|
import se, { components as _ } from "react-select";
|
|
10
10
|
import ce from "@mui/material/Typography";
|
|
@@ -19,25 +19,7 @@ import pe from "@mui/material/Popover";
|
|
|
19
19
|
import { useLocaleContext as Q } from "@arcblock/ux/lib/Locale/context";
|
|
20
20
|
import fe from "@mui/material/Alert";
|
|
21
21
|
import me from "@mui/material/Chip";
|
|
22
|
-
const ge = (e) => /* @__PURE__ */ n("svg", {
|
|
23
|
-
viewBox: "0 0 24 24",
|
|
24
|
-
width: "1.2em",
|
|
25
|
-
height: "1.2em",
|
|
26
|
-
...e,
|
|
27
|
-
children: /* @__PURE__ */ n("path", {
|
|
28
|
-
fill: "currentColor",
|
|
29
|
-
d: "M5 19q-.825 0-1.413-.587Q3 17.825 3 17V7q0-.825.587-1.412Q4.175 5 5 5h10q.5 0 .938.225q.437.225.712.625l3.525 5q.375.525.375 1.15q0 .625-.375 1.15l-3.525 5q-.275.4-.712.625Q15.5 19 15 19Z"
|
|
30
|
-
})
|
|
31
|
-
}), xe = (e) => /* @__PURE__ */ n("svg", {
|
|
32
|
-
viewBox: "0 0 24 24",
|
|
33
|
-
width: "1.2em",
|
|
34
|
-
height: "1.2em",
|
|
35
|
-
...e,
|
|
36
|
-
children: /* @__PURE__ */ n("path", {
|
|
37
|
-
fill: "currentColor",
|
|
38
|
-
d: "m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z"
|
|
39
|
-
})
|
|
40
|
-
}), Y = q({});
|
|
22
|
+
const ge = (e) => /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...e, children: /* @__PURE__ */ n("path", { fill: "currentColor", d: "M5 19q-.825 0-1.413-.587Q3 17.825 3 17V7q0-.825.587-1.412Q4.175 5 5 5h10q.5 0 .938.225q.437.225.712.625l3.525 5q.375.525.375 1.15q0 .625-.375 1.15l-3.525 5q-.275.4-.712.625Q15.5 19 15 19Z" }) }), xe = (e) => /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...e, children: /* @__PURE__ */ n("path", { fill: "currentColor", d: "m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z" }) }), Y = q({});
|
|
41
23
|
function ye({
|
|
42
24
|
selectable: e = !1,
|
|
43
25
|
selected: t = [],
|
|
@@ -55,102 +37,45 @@ function ye({
|
|
|
55
37
|
select: i,
|
|
56
38
|
renderItem: o
|
|
57
39
|
}),
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
41
|
[t]
|
|
59
42
|
);
|
|
60
|
-
return /* @__PURE__ */ n(Y.Provider, {
|
|
61
|
-
value: s,
|
|
62
|
-
children: l
|
|
63
|
-
});
|
|
43
|
+
return /* @__PURE__ */ n(Y.Provider, { value: s, children: l });
|
|
64
44
|
}
|
|
65
45
|
const Ce = (e) => {
|
|
66
46
|
var t;
|
|
67
47
|
return e.isLeaf || !((t = e.data.children) != null && t.length);
|
|
68
48
|
};
|
|
69
|
-
function ve({
|
|
70
|
-
|
|
71
|
-
}) {
|
|
72
|
-
return Ce(e) ? /* @__PURE__ */ n("span", {}) : e.isOpen ? /* @__PURE__ */ n(R, {
|
|
73
|
-
style: {
|
|
74
|
-
fontSize: 20
|
|
75
|
-
}
|
|
76
|
-
}) : /* @__PURE__ */ n(R, {
|
|
77
|
-
style: {
|
|
78
|
-
fontSize: 20,
|
|
79
|
-
transform: "rotate(-90deg)"
|
|
80
|
-
}
|
|
81
|
-
});
|
|
49
|
+
function ve({ node: e }) {
|
|
50
|
+
return Ce(e) ? /* @__PURE__ */ n("span", {}) : e.isOpen ? /* @__PURE__ */ n(R, { style: { fontSize: 20 } }) : /* @__PURE__ */ n(R, { style: { fontSize: 20, transform: "rotate(-90deg)" } });
|
|
82
51
|
}
|
|
83
|
-
function be({
|
|
84
|
-
|
|
85
|
-
style: t,
|
|
86
|
-
dragHandle: a
|
|
87
|
-
}) {
|
|
88
|
-
const {
|
|
89
|
-
selectable: o,
|
|
90
|
-
select: l,
|
|
91
|
-
isSelected: r,
|
|
92
|
-
renderItem: i
|
|
93
|
-
} = H(Y), {
|
|
94
|
-
data: s
|
|
95
|
-
} = e, h = s.icon ? /* @__PURE__ */ n(ie, {
|
|
96
|
-
icon: s.icon,
|
|
97
|
-
style: {
|
|
98
|
-
fontSize: 18
|
|
99
|
-
}
|
|
100
|
-
}) : /* @__PURE__ */ n(ge, {
|
|
101
|
-
style: {
|
|
102
|
-
fontSize: 18,
|
|
103
|
-
color: s.color || "#ddd"
|
|
104
|
-
}
|
|
105
|
-
}), g = (d) => {
|
|
52
|
+
function be({ node: e, style: t, dragHandle: a }) {
|
|
53
|
+
const { selectable: o, select: l, isSelected: r, renderItem: i } = H(Y), { data: s } = e, h = s.icon ? /* @__PURE__ */ n(ie, { icon: s.icon, style: { fontSize: 18 } }) : /* @__PURE__ */ n(ge, { style: { fontSize: 18, color: s.color || "#ddd" } }), g = (d) => {
|
|
106
54
|
d.stopPropagation(), e.isInternal && e.toggle();
|
|
107
55
|
}, f = (d) => {
|
|
108
56
|
d.stopPropagation(), o && l(e.id);
|
|
109
|
-
}, x = /* @__PURE__ */ C(P, {
|
|
110
|
-
|
|
111
|
-
sx: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
children: h
|
|
133
|
-
}), /* @__PURE__ */ n(p, {
|
|
134
|
-
component: "span",
|
|
135
|
-
sx: {
|
|
136
|
-
color: "grey.700"
|
|
137
|
-
},
|
|
138
|
-
children: e.data.name
|
|
139
|
-
})]
|
|
140
|
-
}), o && r(e.id) && /* @__PURE__ */ n(xe, {})]
|
|
141
|
-
});
|
|
142
|
-
return /* @__PURE__ */ C(p, {
|
|
143
|
-
className: "label-tree-item",
|
|
144
|
-
style: t,
|
|
145
|
-
sx: {
|
|
146
|
-
display: "flex",
|
|
147
|
-
alignItems: "center",
|
|
148
|
-
justifyContent: "space-between"
|
|
149
|
-
},
|
|
150
|
-
ref: a,
|
|
151
|
-
onClick: f,
|
|
152
|
-
children: [!i && x, !!i && i(x, e.data)]
|
|
153
|
-
});
|
|
57
|
+
}, x = /* @__PURE__ */ C(P, { children: [
|
|
58
|
+
/* @__PURE__ */ C(p, { sx: { display: "flex", alignItems: "center", flex: 1 }, children: [
|
|
59
|
+
/* @__PURE__ */ n(p, { sx: { display: "flex", cursor: "pointer" }, onClick: g, children: /* @__PURE__ */ n(ve, { node: e }) }),
|
|
60
|
+
/* @__PURE__ */ n(p, { sx: { display: "flex", alignItems: "center", width: 22, height: 22 }, children: h }),
|
|
61
|
+
/* @__PURE__ */ n(p, { component: "span", sx: { color: "grey.700" }, children: e.data.name })
|
|
62
|
+
] }),
|
|
63
|
+
o && r(e.id) && /* @__PURE__ */ n(xe, {})
|
|
64
|
+
] });
|
|
65
|
+
return /* @__PURE__ */ C(
|
|
66
|
+
p,
|
|
67
|
+
{
|
|
68
|
+
className: "label-tree-item",
|
|
69
|
+
style: t,
|
|
70
|
+
sx: { display: "flex", alignItems: "center", justifyContent: "space-between" },
|
|
71
|
+
ref: a,
|
|
72
|
+
onClick: f,
|
|
73
|
+
children: [
|
|
74
|
+
!i && x,
|
|
75
|
+
!!i && i(x, e.data)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
154
79
|
}
|
|
155
80
|
const Se = J(p)`
|
|
156
81
|
> div,
|
|
@@ -182,27 +107,9 @@ function F({
|
|
|
182
107
|
}, [l]);
|
|
183
108
|
return W(() => {
|
|
184
109
|
d();
|
|
185
|
-
}, [e, d]), /* @__PURE__ */ n(ye, {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
onSelect: o,
|
|
189
|
-
renderItem: r,
|
|
190
|
-
children: /* @__PURE__ */ n(Se, {
|
|
191
|
-
...s,
|
|
192
|
-
sx: g,
|
|
193
|
-
children: /* @__PURE__ */ n(le, {
|
|
194
|
-
data: e,
|
|
195
|
-
rowHeight: l,
|
|
196
|
-
height: f,
|
|
197
|
-
indent: 32,
|
|
198
|
-
ref: h,
|
|
199
|
-
onToggle: () => {
|
|
200
|
-
setTimeout(d);
|
|
201
|
-
},
|
|
202
|
-
children: be
|
|
203
|
-
})
|
|
204
|
-
})
|
|
205
|
-
});
|
|
110
|
+
}, [e, d]), /* @__PURE__ */ n(ye, { selectable: t, selected: a, onSelect: o, renderItem: r, children: /* @__PURE__ */ n(Se, { ...s, sx: g, children: /* @__PURE__ */ n(le, { data: e, rowHeight: l, height: f, indent: 32, ref: h, onToggle: () => {
|
|
111
|
+
setTimeout(d);
|
|
112
|
+
}, children: be }) }) });
|
|
206
113
|
}
|
|
207
114
|
const O = (e) => e.reduce((t, a) => {
|
|
208
115
|
var o;
|
|
@@ -227,61 +134,45 @@ const O = (e) => e.reduce((t, a) => {
|
|
|
227
134
|
r.parent && o[r.parent] && (l.parent = o[r.parent]), r.children && (l.children = r.children.map((i) => o[i]));
|
|
228
135
|
}), a.filter((l) => !l.parent);
|
|
229
136
|
}, ze = (e) => {
|
|
230
|
-
const {
|
|
231
|
-
options: t,
|
|
232
|
-
getValue: a,
|
|
233
|
-
selectProps: o,
|
|
234
|
-
selectOption: l
|
|
235
|
-
} = e, r = a(), i = (s) => {
|
|
137
|
+
const { options: t, getValue: a, selectProps: o, selectOption: l } = e, r = a(), i = (s) => {
|
|
236
138
|
const h = t.find((g) => g.data.id === s);
|
|
237
139
|
h && l(h);
|
|
238
140
|
};
|
|
239
|
-
return /* @__PURE__ */ C(P, {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
141
|
+
return /* @__PURE__ */ C(P, { children: [
|
|
142
|
+
/* @__PURE__ */ n(_.MenuList, { ...ae(e, ["addon"]), children: /* @__PURE__ */ n(p, { sx: { px: 2, py: 1 }, children: /* @__PURE__ */ n(
|
|
143
|
+
F,
|
|
144
|
+
{
|
|
145
|
+
data: o.data,
|
|
146
|
+
selectable: !0,
|
|
147
|
+
onSelect: i,
|
|
148
|
+
selected: r.map((s) => s.data.id)
|
|
149
|
+
}
|
|
150
|
+
) }) }),
|
|
151
|
+
e.addon
|
|
152
|
+
] });
|
|
153
|
+
}, Te = ({ children: e, ...t }) => {
|
|
154
|
+
const [a, o] = e, l = Array.isArray(a) ? a.length : 0;
|
|
155
|
+
return /* @__PURE__ */ C(_.ValueContainer, { ...t, children: [
|
|
156
|
+
/* @__PURE__ */ n(p, { component: "span", sx: { fontSize: 13, fontWeight: "bold" }, children: l ? "Labels" : "Filter by labels" }),
|
|
157
|
+
!!l && /* @__PURE__ */ n(
|
|
158
|
+
p,
|
|
159
|
+
{
|
|
243
160
|
sx: {
|
|
244
|
-
|
|
245
|
-
|
|
161
|
+
display: "inline-flex",
|
|
162
|
+
justifyContent: "center",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
width: 22,
|
|
165
|
+
height: 22,
|
|
166
|
+
ml: 1,
|
|
167
|
+
borderRadius: "100%",
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
bgcolor: "grey.200"
|
|
246
170
|
},
|
|
247
|
-
children:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
}), e.addon]
|
|
255
|
-
});
|
|
256
|
-
}, Te = ({
|
|
257
|
-
children: e,
|
|
258
|
-
...t
|
|
259
|
-
}) => {
|
|
260
|
-
const [a, o] = e, l = Array.isArray(a) ? a.length : 0;
|
|
261
|
-
return /* @__PURE__ */ C(_.ValueContainer, {
|
|
262
|
-
...t,
|
|
263
|
-
children: [/* @__PURE__ */ n(p, {
|
|
264
|
-
component: "span",
|
|
265
|
-
sx: {
|
|
266
|
-
fontSize: 13,
|
|
267
|
-
fontWeight: "bold"
|
|
268
|
-
},
|
|
269
|
-
children: l ? "Labels" : "Filter by labels"
|
|
270
|
-
}), !!l && /* @__PURE__ */ n(p, {
|
|
271
|
-
sx: {
|
|
272
|
-
display: "inline-flex",
|
|
273
|
-
justifyContent: "center",
|
|
274
|
-
alignItems: "center",
|
|
275
|
-
width: 22,
|
|
276
|
-
height: 22,
|
|
277
|
-
ml: 1,
|
|
278
|
-
borderRadius: "100%",
|
|
279
|
-
fontSize: 12,
|
|
280
|
-
bgcolor: "grey.200"
|
|
281
|
-
},
|
|
282
|
-
children: l
|
|
283
|
-
}), o]
|
|
284
|
-
});
|
|
171
|
+
children: l
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
o
|
|
175
|
+
] });
|
|
285
176
|
}, ke = {
|
|
286
177
|
control: (e) => ({
|
|
287
178
|
...e,
|
|
@@ -311,14 +202,13 @@ function Ae({
|
|
|
311
202
|
maxHeight: s = 264,
|
|
312
203
|
...h
|
|
313
204
|
}) {
|
|
314
|
-
const g = D(null), f = T(
|
|
315
|
-
data: m,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}), {}), d = Array.isArray(t) ? t : [t], b = d.map((m) => x[m]), u = D({
|
|
205
|
+
const g = D(null), f = T(
|
|
206
|
+
() => O(e).map((m) => ({ data: m, label: m.name, value: m.id })),
|
|
207
|
+
[e]
|
|
208
|
+
), x = f.reduce(
|
|
209
|
+
(m, I) => ({ ...m, [I.data.id]: I }),
|
|
210
|
+
{}
|
|
211
|
+
), d = Array.isArray(t) ? t : [t], b = d.map((m) => x[m]), u = D({
|
|
322
212
|
prev: d.map((m) => {
|
|
323
213
|
var I;
|
|
324
214
|
return ((I = x[m]) == null ? void 0 : I.data) || "";
|
|
@@ -331,30 +221,25 @@ function Ae({
|
|
|
331
221
|
}, M = () => {
|
|
332
222
|
u.current.current && JSON.stringify(u.current.prev.map((I) => I.id)) !== JSON.stringify(u.current.current.map((I) => I.id)) && (l(u.current.current), u.current.prev = u.current.current);
|
|
333
223
|
};
|
|
334
|
-
return /* @__PURE__ */ n(p, {
|
|
335
|
-
|
|
336
|
-
|
|
224
|
+
return /* @__PURE__ */ n(p, { ...h, children: /* @__PURE__ */ n(
|
|
225
|
+
se,
|
|
226
|
+
{
|
|
337
227
|
ref: g,
|
|
338
228
|
defaultValue: b,
|
|
339
229
|
options: f,
|
|
340
230
|
onChange: v,
|
|
341
231
|
components: {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
...r && {
|
|
347
|
-
ValueContainer: Te
|
|
348
|
-
}
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
MenuList: (m) => /* @__PURE__ */ n(ze, { ...m, addon: o }),
|
|
234
|
+
// eslint-disable-line react/no-unstable-nested-components
|
|
235
|
+
...r && { ValueContainer: Te }
|
|
349
236
|
},
|
|
350
237
|
placeholder: "Select labels",
|
|
351
238
|
styles: {
|
|
352
239
|
...r && ke,
|
|
353
240
|
menu: (m) => ({
|
|
354
241
|
...m,
|
|
355
|
-
...a && {
|
|
356
|
-
paddingBottom: "36px"
|
|
357
|
-
},
|
|
242
|
+
...a && { paddingBottom: "36px" },
|
|
358
243
|
zIndex: 99
|
|
359
244
|
}),
|
|
360
245
|
menuList: (m) => ({
|
|
@@ -378,8 +263,8 @@ function Ae({
|
|
|
378
263
|
onMenuClose: M,
|
|
379
264
|
isClearable: !0,
|
|
380
265
|
data: e
|
|
381
|
-
}
|
|
382
|
-
});
|
|
266
|
+
}
|
|
267
|
+
) });
|
|
383
268
|
}
|
|
384
269
|
var L = function() {
|
|
385
270
|
return L = Object.assign || function(t) {
|
|
@@ -423,284 +308,172 @@ var Oe = function(e) {
|
|
|
423
308
|
return [a, l];
|
|
424
309
|
};
|
|
425
310
|
const Be = Pe;
|
|
426
|
-
function Ee({
|
|
427
|
-
|
|
428
|
-
...t
|
|
429
|
-
}) {
|
|
430
|
-
const {
|
|
431
|
-
languages: a
|
|
432
|
-
} = Q(), {
|
|
433
|
-
translation: o,
|
|
434
|
-
onChange: l
|
|
435
|
-
} = e, [r, i] = z(null), s = (f) => {
|
|
311
|
+
function Ee({ I18NProps: e, ...t }) {
|
|
312
|
+
const { languages: a } = Q(), { translation: o, onChange: l } = e, [r, i] = z(null), s = (f) => {
|
|
436
313
|
const x = f.currentTarget.closest(".MuiInputBase-root");
|
|
437
314
|
x && i(x);
|
|
438
315
|
}, h = () => {
|
|
439
316
|
i(null);
|
|
440
317
|
}, g = a.filter((f) => f.code !== "en");
|
|
441
|
-
return /* @__PURE__ */ n(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
edge: "end",
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
},
|
|
458
|
-
anchorOrigin: {
|
|
459
|
-
vertical: "bottom",
|
|
460
|
-
horizontal: "right"
|
|
461
|
-
},
|
|
462
|
-
PaperProps: {
|
|
463
|
-
sx: {
|
|
464
|
-
width: r == null ? void 0 : r.clientWidth,
|
|
465
|
-
maxHeight: 200,
|
|
466
|
-
overflowY: "auto",
|
|
467
|
-
bgcolor: "grey.50"
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
elevation: 1,
|
|
471
|
-
sx: {
|
|
472
|
-
mt: 2
|
|
473
|
-
},
|
|
474
|
-
children: /* @__PURE__ */ n(B, {
|
|
475
|
-
sx: {
|
|
476
|
-
p: 2
|
|
477
|
-
},
|
|
478
|
-
children: g.map(({
|
|
479
|
-
code: f,
|
|
480
|
-
name: x
|
|
481
|
-
}) => /* @__PURE__ */ C(B, {
|
|
482
|
-
sx: {
|
|
483
|
-
display: "flex",
|
|
484
|
-
alignItems: "center",
|
|
485
|
-
justifyContent: "space-between",
|
|
486
|
-
"& + &": {
|
|
487
|
-
mt: 1
|
|
488
|
-
}
|
|
318
|
+
return /* @__PURE__ */ n(
|
|
319
|
+
V,
|
|
320
|
+
{
|
|
321
|
+
...t,
|
|
322
|
+
InputProps: {
|
|
323
|
+
endAdornment: /* @__PURE__ */ C(ue, { position: "end", children: [
|
|
324
|
+
/* @__PURE__ */ n(he, { edge: "end", onClick: s, children: /* @__PURE__ */ n(X, {}) }),
|
|
325
|
+
/* @__PURE__ */ n(
|
|
326
|
+
pe,
|
|
327
|
+
{
|
|
328
|
+
open: !!r,
|
|
329
|
+
anchorEl: r,
|
|
330
|
+
onClose: h,
|
|
331
|
+
transformOrigin: {
|
|
332
|
+
vertical: "top",
|
|
333
|
+
horizontal: "right"
|
|
489
334
|
},
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
335
|
+
anchorOrigin: {
|
|
336
|
+
vertical: "bottom",
|
|
337
|
+
horizontal: "right"
|
|
338
|
+
},
|
|
339
|
+
PaperProps: {
|
|
340
|
+
sx: { width: r == null ? void 0 : r.clientWidth, maxHeight: 200, overflowY: "auto", bgcolor: "grey.50" }
|
|
341
|
+
},
|
|
342
|
+
elevation: 1,
|
|
343
|
+
sx: { mt: 2 },
|
|
344
|
+
children: /* @__PURE__ */ n(B, { sx: { p: 2 }, children: g.map(({ code: f, name: x }) => /* @__PURE__ */ C(
|
|
345
|
+
B,
|
|
346
|
+
{
|
|
502
347
|
sx: {
|
|
503
|
-
|
|
348
|
+
display: "flex",
|
|
349
|
+
alignItems: "center",
|
|
350
|
+
justifyContent: "space-between",
|
|
351
|
+
"& + &": { mt: 1 }
|
|
504
352
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ n(B, { sx: { flex: "0 0 120px" }, children: x }),
|
|
355
|
+
/* @__PURE__ */ n(B, { sx: { flex: 1 }, children: /* @__PURE__ */ n(
|
|
356
|
+
V,
|
|
357
|
+
{
|
|
358
|
+
value: o[f] || "",
|
|
359
|
+
size: "small",
|
|
360
|
+
sx: { width: 1 },
|
|
361
|
+
onChange: (d) => l({ ...o, [f]: d.target.value })
|
|
362
|
+
}
|
|
363
|
+
) })
|
|
364
|
+
]
|
|
365
|
+
},
|
|
366
|
+
f
|
|
367
|
+
)) })
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] })
|
|
371
|
+
}
|
|
515
372
|
}
|
|
516
|
-
|
|
373
|
+
);
|
|
517
374
|
}
|
|
518
|
-
function Le({
|
|
519
|
-
open: e,
|
|
520
|
-
initialLabel: t,
|
|
521
|
-
onSubmit: a,
|
|
522
|
-
onClose: o,
|
|
523
|
-
...l
|
|
524
|
-
}) {
|
|
375
|
+
function Le({ open: e, initialLabel: t, onSubmit: a, onClose: o, ...l }) {
|
|
525
376
|
const r = !(t != null && t.id), [i, s] = Be({
|
|
526
377
|
name: (t == null ? void 0 : t.name) || "",
|
|
527
378
|
color: (t == null ? void 0 : t.color) || "#ddd",
|
|
528
379
|
slug: (t == null ? void 0 : t.id) || "",
|
|
529
380
|
translation: (t == null ? void 0 : t.translation) || {}
|
|
530
381
|
}), h = (v) => /^#([0-9A-F]{3}){1,2}$/i.test(v), g = T(() => r ? i.name && i.color && i.slug && h(i.color) : i.name && i.color && h(i.color), [i, r]), [f, x] = z(!1), d = () => {
|
|
531
|
-
a({
|
|
532
|
-
...t,
|
|
533
|
-
name: i.name,
|
|
534
|
-
color: i.color,
|
|
535
|
-
id: i.slug,
|
|
536
|
-
translation: i.translation
|
|
537
|
-
});
|
|
382
|
+
a({ ...t, name: i.name, color: i.color, id: i.slug, translation: i.translation });
|
|
538
383
|
}, b = (v) => {
|
|
539
|
-
s({
|
|
540
|
-
color: v.hex
|
|
541
|
-
}), setTimeout(() => x(!1));
|
|
384
|
+
s({ color: v.hex }), setTimeout(() => x(!1));
|
|
542
385
|
}, u = (v) => {
|
|
543
|
-
s({
|
|
544
|
-
color: v.target.value
|
|
545
|
-
});
|
|
386
|
+
s({ color: v.target.value });
|
|
546
387
|
};
|
|
547
|
-
return /* @__PURE__ */ n(
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
variant: "contained",
|
|
556
|
-
size: "small",
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}),
|
|
597
|
-
sx: {
|
|
598
|
-
mt: 2
|
|
599
|
-
}
|
|
600
|
-
}), (t == null ? void 0 : t.parent) && /* @__PURE__ */ n(j, {
|
|
601
|
-
label: "Parent",
|
|
602
|
-
value: t.parent.name,
|
|
603
|
-
size: "small",
|
|
604
|
-
fullWidth: !0,
|
|
605
|
-
disabled: !0,
|
|
606
|
-
sx: {
|
|
607
|
-
mt: 2
|
|
608
|
-
}
|
|
609
|
-
}), /* @__PURE__ */ n($, {
|
|
610
|
-
onClickAway: () => x(!1),
|
|
611
|
-
children: /* @__PURE__ */ C(p, {
|
|
612
|
-
sx: {
|
|
613
|
-
position: "relative",
|
|
614
|
-
mt: 2
|
|
615
|
-
},
|
|
616
|
-
children: [/* @__PURE__ */ C(p, {
|
|
617
|
-
sx: {
|
|
618
|
-
display: "flex",
|
|
619
|
-
alignItems: "center",
|
|
620
|
-
gap: 1
|
|
621
|
-
},
|
|
622
|
-
children: [/* @__PURE__ */ n(p, {
|
|
623
|
-
sx: {
|
|
624
|
-
width: 30,
|
|
625
|
-
height: 30,
|
|
626
|
-
bgcolor: i.color,
|
|
627
|
-
borderRadius: 1
|
|
628
|
-
},
|
|
629
|
-
onClick: () => x(!0)
|
|
630
|
-
}), /* @__PURE__ */ n(j, {
|
|
631
|
-
label: "",
|
|
632
|
-
value: i.color,
|
|
633
|
-
size: "small",
|
|
634
|
-
onChange: u,
|
|
635
|
-
inputProps: {
|
|
636
|
-
maxLength: 7
|
|
637
|
-
},
|
|
638
|
-
sx: {
|
|
639
|
-
width: 100,
|
|
640
|
-
".MuiInputBase-root": {
|
|
641
|
-
height: 32
|
|
642
|
-
}
|
|
388
|
+
return /* @__PURE__ */ n(
|
|
389
|
+
K,
|
|
390
|
+
{
|
|
391
|
+
open: e,
|
|
392
|
+
showCloseButton: !0,
|
|
393
|
+
maxWidth: "lg",
|
|
394
|
+
title: r ? "Create label" : "Edit label",
|
|
395
|
+
actions: /* @__PURE__ */ C(P, { children: [
|
|
396
|
+
/* @__PURE__ */ n(A, { color: "inherit", variant: "contained", size: "small", onClick: o, children: "Cancel" }),
|
|
397
|
+
/* @__PURE__ */ n(A, { color: "primary", variant: "contained", size: "small", onClick: d, disabled: !g, children: r ? "Create" : "Save Changes" })
|
|
398
|
+
] }),
|
|
399
|
+
onClose: o,
|
|
400
|
+
...l,
|
|
401
|
+
children: /* @__PURE__ */ C(p, { width: 600, minHeight: 280, children: [
|
|
402
|
+
/* @__PURE__ */ n(
|
|
403
|
+
Ee,
|
|
404
|
+
{
|
|
405
|
+
label: "Name",
|
|
406
|
+
value: i.name,
|
|
407
|
+
placeholder: "New label",
|
|
408
|
+
size: "small",
|
|
409
|
+
fullWidth: !0,
|
|
410
|
+
onChange: (v) => s({ name: v.target.value }),
|
|
411
|
+
I18NProps: {
|
|
412
|
+
translation: i.translation,
|
|
413
|
+
onChange: (v) => s({ translation: v })
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
/* @__PURE__ */ n(
|
|
418
|
+
j,
|
|
419
|
+
{
|
|
420
|
+
label: "Slug",
|
|
421
|
+
value: i.slug,
|
|
422
|
+
size: "small",
|
|
423
|
+
fullWidth: !0,
|
|
424
|
+
disabled: !r,
|
|
425
|
+
onChange: (v) => s({ slug: v.target.value }),
|
|
426
|
+
sx: { mt: 2 }
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
(t == null ? void 0 : t.parent) && /* @__PURE__ */ n(j, { label: "Parent", value: t.parent.name, size: "small", fullWidth: !0, disabled: !0, sx: { mt: 2 } }),
|
|
430
|
+
/* @__PURE__ */ n($, { onClickAway: () => x(!1), children: /* @__PURE__ */ C(p, { sx: { position: "relative", mt: 2 }, children: [
|
|
431
|
+
/* @__PURE__ */ C(p, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
432
|
+
/* @__PURE__ */ n(
|
|
433
|
+
p,
|
|
434
|
+
{
|
|
435
|
+
sx: { width: 30, height: 30, bgcolor: i.color, borderRadius: 1 },
|
|
436
|
+
onClick: () => x(!0)
|
|
643
437
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
438
|
+
),
|
|
439
|
+
/* @__PURE__ */ n(
|
|
440
|
+
j,
|
|
441
|
+
{
|
|
442
|
+
label: "",
|
|
443
|
+
value: i.color,
|
|
444
|
+
size: "small",
|
|
445
|
+
onChange: u,
|
|
446
|
+
inputProps: { maxLength: 7 },
|
|
447
|
+
sx: { width: 100, ".MuiInputBase-root": { height: 32 } }
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
] }),
|
|
451
|
+
f && /* @__PURE__ */ n(p, { sx: { position: "absolute", top: 48, zIndex: 1 }, children: /* @__PURE__ */ n(de, { color: i.color, onChangeComplete: b }) })
|
|
452
|
+
] }) })
|
|
453
|
+
] })
|
|
454
|
+
}
|
|
455
|
+
);
|
|
660
456
|
}
|
|
661
|
-
function Me({
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
color: "primary",
|
|
682
|
-
variant: "contained",
|
|
683
|
-
size: "small",
|
|
684
|
-
onClick: a,
|
|
685
|
-
children: "Delete"
|
|
686
|
-
})]
|
|
687
|
-
}),
|
|
688
|
-
onClose: o,
|
|
689
|
-
...l,
|
|
690
|
-
children: /* @__PURE__ */ C(p, {
|
|
691
|
-
width: 600,
|
|
692
|
-
minHeight: 280,
|
|
693
|
-
children: [/* @__PURE__ */ n(fe, {
|
|
694
|
-
severity: "info",
|
|
695
|
-
sx: {
|
|
696
|
-
mb: 2
|
|
697
|
-
},
|
|
698
|
-
children: "Are you sure you want to delete these labels ?"
|
|
699
|
-
}), /* @__PURE__ */ n(F, {
|
|
700
|
-
data: [t]
|
|
701
|
-
})]
|
|
702
|
-
})
|
|
703
|
-
});
|
|
457
|
+
function Me({ open: e, label: t, onSubmit: a, onClose: o, ...l }) {
|
|
458
|
+
return /* @__PURE__ */ n(
|
|
459
|
+
K,
|
|
460
|
+
{
|
|
461
|
+
open: e,
|
|
462
|
+
showCloseButton: !0,
|
|
463
|
+
maxWidth: "md",
|
|
464
|
+
title: "Delete",
|
|
465
|
+
actions: /* @__PURE__ */ C(P, { children: [
|
|
466
|
+
/* @__PURE__ */ n(A, { color: "inherit", variant: "contained", size: "small", onClick: o, children: "Cancel" }),
|
|
467
|
+
/* @__PURE__ */ n(A, { color: "primary", variant: "contained", size: "small", onClick: a, children: "Delete" })
|
|
468
|
+
] }),
|
|
469
|
+
onClose: o,
|
|
470
|
+
...l,
|
|
471
|
+
children: /* @__PURE__ */ C(p, { width: 600, minHeight: 280, children: [
|
|
472
|
+
/* @__PURE__ */ n(fe, { severity: "info", sx: { mb: 2 }, children: "Are you sure you want to delete these labels ?" }),
|
|
473
|
+
/* @__PURE__ */ n(F, { data: [t] })
|
|
474
|
+
] })
|
|
475
|
+
}
|
|
476
|
+
);
|
|
704
477
|
}
|
|
705
478
|
const je = J(F)`
|
|
706
479
|
.label-tree-item {
|
|
@@ -723,52 +496,35 @@ const je = J(F)`
|
|
|
723
496
|
padding: 0 16px;
|
|
724
497
|
}
|
|
725
498
|
`;
|
|
726
|
-
function De({
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
return /* @__PURE__ */ C(p, {
|
|
731
|
-
sx: {
|
|
732
|
-
display: "flex",
|
|
733
|
-
alignItems: "center",
|
|
734
|
-
flex: "0 0 auto",
|
|
735
|
-
px: 1,
|
|
736
|
-
py: 0.25,
|
|
737
|
-
fontSize: 12,
|
|
738
|
-
bgcolor: "grey.300",
|
|
739
|
-
borderRadius: 2
|
|
740
|
-
},
|
|
741
|
-
className: "label-translation-tag",
|
|
742
|
-
children: [/* @__PURE__ */ n(p, {
|
|
499
|
+
function De({ locale: e, value: t }) {
|
|
500
|
+
return /* @__PURE__ */ C(
|
|
501
|
+
p,
|
|
502
|
+
{
|
|
743
503
|
sx: {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
504
|
+
display: "flex",
|
|
505
|
+
alignItems: "center",
|
|
506
|
+
flex: "0 0 auto",
|
|
507
|
+
px: 1,
|
|
508
|
+
py: 0.25,
|
|
509
|
+
fontSize: 12,
|
|
510
|
+
bgcolor: "grey.300",
|
|
511
|
+
borderRadius: 2
|
|
752
512
|
},
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
513
|
+
className: "label-translation-tag",
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ n(p, { sx: { pr: 0.5, borderRight: 1, borderColor: "grey.400" }, children: e }),
|
|
516
|
+
/* @__PURE__ */ n(p, { sx: { pl: 0.5 }, children: t })
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
);
|
|
756
520
|
}
|
|
757
|
-
function lt({
|
|
758
|
-
data: e,
|
|
759
|
-
api: t,
|
|
760
|
-
...a
|
|
761
|
-
}) {
|
|
521
|
+
function lt({ data: e, api: t, ...a }) {
|
|
762
522
|
const [o, l] = z(null), [r, i] = z(null), [s, h] = z(Z(e)), g = T(() => O(s), [s]), f = T(() => {
|
|
763
523
|
const c = (y, w) => y.map((S) => (w && (S.parent = w), S.children && (S.children = c(S.children, S)), S));
|
|
764
524
|
return c(s);
|
|
765
525
|
}, [s]), x = (c) => {
|
|
766
526
|
var y, w;
|
|
767
|
-
c.parent ? (c.parent.children = (w = (y = c.parent) == null ? void 0 : y.children) == null ? void 0 : w.map((S) => S.id === c.id ? {
|
|
768
|
-
...c
|
|
769
|
-
} : S), x(c.parent)) : h(s.map((S) => S.id === c.id ? {
|
|
770
|
-
...c
|
|
771
|
-
} : S));
|
|
527
|
+
c.parent ? (c.parent.children = (w = (y = c.parent) == null ? void 0 : y.children) == null ? void 0 : w.map((S) => S.id === c.id ? { ...c } : S), x(c.parent)) : h(s.map((S) => S.id === c.id ? { ...c } : S));
|
|
772
528
|
}, d = (c) => {
|
|
773
529
|
c.parent ? (c.parent.children = c.parent.children || [], c.parent.children.push(c), h([...s])) : h([...s, c]);
|
|
774
530
|
}, b = (c) => {
|
|
@@ -777,186 +533,83 @@ function lt({
|
|
|
777
533
|
}, u = (c) => {
|
|
778
534
|
if (o)
|
|
779
535
|
return;
|
|
780
|
-
l({
|
|
781
|
-
id: "",
|
|
782
|
-
name: "New label",
|
|
783
|
-
parent: c,
|
|
784
|
-
color: "#dddddd"
|
|
785
|
-
});
|
|
536
|
+
l({ id: "", name: "New label", parent: c, color: "#dddddd" });
|
|
786
537
|
}, v = (c) => {
|
|
787
538
|
o || l(c);
|
|
788
539
|
}, M = async (c) => {
|
|
789
540
|
if (!o)
|
|
790
541
|
return;
|
|
791
|
-
const {
|
|
792
|
-
|
|
793
|
-
children: w,
|
|
794
|
-
translation: S,
|
|
795
|
-
...N
|
|
796
|
-
} = c;
|
|
797
|
-
o.id ? (await t.updateLabel({
|
|
798
|
-
...N,
|
|
799
|
-
translation: JSON.stringify(S),
|
|
800
|
-
parentId: y == null ? void 0 : y.id
|
|
801
|
-
}), x(c)) : (await t.createLabel({
|
|
802
|
-
...N,
|
|
803
|
-
translation: JSON.stringify(S),
|
|
804
|
-
parentId: y == null ? void 0 : y.id
|
|
805
|
-
}), d(c)), l(null);
|
|
542
|
+
const { parent: y, children: w, translation: S, ...N } = c;
|
|
543
|
+
o.id ? (await t.updateLabel({ ...N, translation: JSON.stringify(S), parentId: y == null ? void 0 : y.id }), x(c)) : (await t.createLabel({ ...N, translation: JSON.stringify(S), parentId: y == null ? void 0 : y.id }), d(c)), l(null);
|
|
806
544
|
}, m = async () => {
|
|
807
|
-
|
|
808
|
-
}, I = (c, y) => /* @__PURE__ */ C(P, {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
})
|
|
854
|
-
}), /* @__PURE__ */ n(E, {
|
|
855
|
-
color: "inherit",
|
|
856
|
-
size: "small",
|
|
857
|
-
sx: {
|
|
858
|
-
color: "grey.500"
|
|
859
|
-
},
|
|
860
|
-
onClick: () => v(y),
|
|
861
|
-
children: /* @__PURE__ */ n(te, {
|
|
862
|
-
sx: {
|
|
863
|
-
fontSize: 18
|
|
864
|
-
}
|
|
865
|
-
})
|
|
866
|
-
}), /* @__PURE__ */ n(E, {
|
|
867
|
-
color: "inherit",
|
|
868
|
-
size: "small",
|
|
869
|
-
sx: {
|
|
870
|
-
color: "grey.500"
|
|
871
|
-
},
|
|
872
|
-
onClick: () => i(y),
|
|
873
|
-
children: /* @__PURE__ */ n(ne, {
|
|
874
|
-
sx: {
|
|
875
|
-
fontSize: 20
|
|
876
|
-
}
|
|
877
|
-
})
|
|
878
|
-
})]
|
|
879
|
-
})]
|
|
880
|
-
});
|
|
881
|
-
return /* @__PURE__ */ C(p, {
|
|
882
|
-
...a,
|
|
883
|
-
className: "label-container",
|
|
884
|
-
children: [/* @__PURE__ */ C(p, {
|
|
885
|
-
sx: {
|
|
886
|
-
display: "flex",
|
|
887
|
-
alignItems: "center",
|
|
888
|
-
justifyContent: "space-between"
|
|
545
|
+
r && (await t.deleteLabel(r.id), b(r), i(null));
|
|
546
|
+
}, I = (c, y) => /* @__PURE__ */ C(P, { children: [
|
|
547
|
+
/* @__PURE__ */ C(p, { sx: { display: "flex", alignItems: "center", flexWrap: "wrap" }, className: "label-name", children: [
|
|
548
|
+
/* @__PURE__ */ n(p, { children: c }),
|
|
549
|
+
y.translation && /* @__PURE__ */ n(p, { sx: { display: "flex", alignItems: "center", gap: 0.5, ml: 2 }, className: "label-translation", children: Object.keys(y.translation).map((w) => {
|
|
550
|
+
var N;
|
|
551
|
+
const S = (N = y.translation) == null ? void 0 : N[w];
|
|
552
|
+
return S ? /* @__PURE__ */ n(De, { locale: w, value: S }, w) : null;
|
|
553
|
+
}) })
|
|
554
|
+
] }),
|
|
555
|
+
/* @__PURE__ */ C(p, { sx: { display: "flex", gap: 1, flex: "0 0 auto" }, className: "label-action", children: [
|
|
556
|
+
/* @__PURE__ */ n(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => u(y), children: /* @__PURE__ */ n(ee, { sx: { fontSize: 20 } }) }),
|
|
557
|
+
/* @__PURE__ */ n(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => v(y), children: /* @__PURE__ */ n(te, { sx: { fontSize: 18 } }) }),
|
|
558
|
+
/* @__PURE__ */ n(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => i(y), children: /* @__PURE__ */ n(ne, { sx: { fontSize: 20 } }) })
|
|
559
|
+
] })
|
|
560
|
+
] });
|
|
561
|
+
return /* @__PURE__ */ C(p, { ...a, className: "label-container", children: [
|
|
562
|
+
/* @__PURE__ */ C(p, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
563
|
+
/* @__PURE__ */ n(ce, { component: "h2", variant: "h6", children: "Manage labels" }),
|
|
564
|
+
/* @__PURE__ */ n(
|
|
565
|
+
A,
|
|
566
|
+
{
|
|
567
|
+
color: "primary",
|
|
568
|
+
variant: "contained",
|
|
569
|
+
size: "small",
|
|
570
|
+
sx: { textTransform: "none" },
|
|
571
|
+
onClick: () => u(),
|
|
572
|
+
children: "New label"
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
] }),
|
|
576
|
+
/* @__PURE__ */ C(p, { sx: { mt: 2, border: 1, borderColor: "grey.300", borderRadius: 1, overflow: "hidden" }, children: [
|
|
577
|
+
/* @__PURE__ */ C(p, { sx: { p: 2, fontSize: 14, fontWeight: "bold", bgcolor: "grey.200" }, className: "label-header", children: [
|
|
578
|
+
g.length,
|
|
579
|
+
" labels"
|
|
580
|
+
] }),
|
|
581
|
+
/* @__PURE__ */ n(p, { sx: { pt: 0.5 }, children: /* @__PURE__ */ n(je, { data: f, selected: [], renderItem: I, rowHeight: 64 }) })
|
|
582
|
+
] }),
|
|
583
|
+
/* @__PURE__ */ n(
|
|
584
|
+
Le,
|
|
585
|
+
{
|
|
586
|
+
open: !!o,
|
|
587
|
+
onClose: () => l(null),
|
|
588
|
+
initialLabel: o,
|
|
589
|
+
onSubmit: M
|
|
889
590
|
},
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
textTransform: "none"
|
|
900
|
-
},
|
|
901
|
-
onClick: () => u(),
|
|
902
|
-
children: "New label"
|
|
903
|
-
})]
|
|
904
|
-
}), /* @__PURE__ */ C(p, {
|
|
905
|
-
sx: {
|
|
906
|
-
mt: 2,
|
|
907
|
-
border: 1,
|
|
908
|
-
borderColor: "grey.300",
|
|
909
|
-
borderRadius: 1,
|
|
910
|
-
overflow: "hidden"
|
|
591
|
+
o == null ? void 0 : o.id
|
|
592
|
+
),
|
|
593
|
+
/* @__PURE__ */ n(
|
|
594
|
+
Me,
|
|
595
|
+
{
|
|
596
|
+
open: !!r,
|
|
597
|
+
onClose: () => i(null),
|
|
598
|
+
label: r,
|
|
599
|
+
onSubmit: m
|
|
911
600
|
},
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
fontSize: 14,
|
|
916
|
-
fontWeight: "bold",
|
|
917
|
-
bgcolor: "grey.200"
|
|
918
|
-
},
|
|
919
|
-
className: "label-header",
|
|
920
|
-
children: [g.length, " labels"]
|
|
921
|
-
}), /* @__PURE__ */ n(p, {
|
|
922
|
-
sx: {
|
|
923
|
-
pt: 0.5
|
|
924
|
-
},
|
|
925
|
-
children: /* @__PURE__ */ n(je, {
|
|
926
|
-
data: f,
|
|
927
|
-
selected: [],
|
|
928
|
-
renderItem: I,
|
|
929
|
-
rowHeight: 64
|
|
930
|
-
})
|
|
931
|
-
})]
|
|
932
|
-
}), /* @__PURE__ */ n(Le, {
|
|
933
|
-
open: !!o,
|
|
934
|
-
onClose: () => l(null),
|
|
935
|
-
initialLabel: o,
|
|
936
|
-
onSubmit: M
|
|
937
|
-
}, o == null ? void 0 : o.id), /* @__PURE__ */ n(Me, {
|
|
938
|
-
open: !!r,
|
|
939
|
-
onClose: () => i(null),
|
|
940
|
-
label: r,
|
|
941
|
-
onSubmit: m
|
|
942
|
-
}, r == null ? void 0 : r.id)]
|
|
943
|
-
});
|
|
601
|
+
r == null ? void 0 : r.id
|
|
602
|
+
)
|
|
603
|
+
] });
|
|
944
604
|
}
|
|
945
605
|
const G = q({}), U = () => H(G), it = () => {
|
|
946
|
-
const {
|
|
947
|
-
updateLabels: e
|
|
948
|
-
} = U();
|
|
606
|
+
const { updateLabels: e } = U();
|
|
949
607
|
W(() => () => {
|
|
950
608
|
e();
|
|
951
609
|
}, []);
|
|
952
610
|
};
|
|
953
|
-
function at({
|
|
954
|
-
|
|
955
|
-
children: t
|
|
956
|
-
}) {
|
|
957
|
-
const {
|
|
958
|
-
locale: a
|
|
959
|
-
} = Q(), [o, l] = z({
|
|
611
|
+
function at({ fetchLabels: e, children: t }) {
|
|
612
|
+
const { locale: a } = Q(), [o, l] = z({
|
|
960
613
|
loading: !0,
|
|
961
614
|
labels: [],
|
|
962
615
|
updateCounter: 1
|
|
@@ -964,70 +617,46 @@ function at({
|
|
|
964
617
|
W(() => {
|
|
965
618
|
(async () => {
|
|
966
619
|
try {
|
|
967
|
-
l((u) => ({
|
|
968
|
-
...u,
|
|
969
|
-
loading: !0
|
|
970
|
-
}));
|
|
620
|
+
l((u) => ({ ...u, loading: !0 }));
|
|
971
621
|
const b = await e();
|
|
972
|
-
l((u) => ({
|
|
973
|
-
...u,
|
|
974
|
-
loading: !1,
|
|
975
|
-
labels: Ie(b)
|
|
976
|
-
}));
|
|
622
|
+
l((u) => ({ ...u, loading: !1, labels: Ie(b) }));
|
|
977
623
|
} catch (b) {
|
|
978
|
-
console.error(b), l((u) => ({
|
|
979
|
-
...u,
|
|
980
|
-
loading: !1,
|
|
981
|
-
labels: []
|
|
982
|
-
}));
|
|
624
|
+
console.error(b), l((u) => ({ ...u, loading: !1, labels: [] }));
|
|
983
625
|
}
|
|
984
626
|
})();
|
|
985
627
|
}, [o.updateCounter]);
|
|
986
628
|
const r = T(() => {
|
|
987
629
|
var b;
|
|
988
|
-
return (b = o.labels) != null && b.length ? O(o.labels).reduce((u, v) => ({
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
630
|
+
return (b = o.labels) != null && b.length ? O(o.labels).reduce((u, v) => ({ ...u, [v.id]: v }), {}) : {};
|
|
631
|
+
}, [o.labels]), i = k(
|
|
632
|
+
(d) => {
|
|
633
|
+
var b;
|
|
634
|
+
return {
|
|
635
|
+
...d,
|
|
636
|
+
name: ((b = d.translation) == null ? void 0 : b[a]) || d.name
|
|
637
|
+
};
|
|
638
|
+
},
|
|
639
|
+
[a]
|
|
640
|
+
), s = k(
|
|
641
|
+
(d) => d.filter(Boolean).map((b) => r[b]).map(i),
|
|
642
|
+
[r, i]
|
|
643
|
+
), h = k((d) => (d == null ? void 0 : d.split(",")) || [], []), g = k((d = []) => {
|
|
644
|
+
if (d != null && d.length)
|
|
1000
645
|
return d.join(",");
|
|
1001
646
|
}, []), f = T(() => o.labels.map(i), [o.labels, i]), x = T(() => ({
|
|
1002
647
|
loading: o.loading,
|
|
1003
648
|
labels: o.labels || [],
|
|
1004
|
-
updateLabels: () => l((d) => ({
|
|
1005
|
-
...d,
|
|
1006
|
-
updateCounter: ++o.updateCounter
|
|
1007
|
-
})),
|
|
649
|
+
updateLabels: () => l((d) => ({ ...d, updateCounter: ++o.updateCounter })),
|
|
1008
650
|
getLabelsById: s,
|
|
1009
651
|
parseLabelIds: h,
|
|
1010
652
|
stringifyLabelIds: g,
|
|
1011
653
|
localizedLabels: f,
|
|
1012
654
|
flattenedLabels: O(f || [])
|
|
1013
655
|
}), [o, s, h, g, f]);
|
|
1014
|
-
return /* @__PURE__ */ n(G.Provider, {
|
|
1015
|
-
value: x,
|
|
1016
|
-
children: t
|
|
1017
|
-
});
|
|
656
|
+
return /* @__PURE__ */ n(G.Provider, { value: x, children: t });
|
|
1018
657
|
}
|
|
1019
|
-
function st({
|
|
1020
|
-
labels:
|
|
1021
|
-
editable: t,
|
|
1022
|
-
onChange: a,
|
|
1023
|
-
sx: o,
|
|
1024
|
-
renderLabel: l
|
|
1025
|
-
}) {
|
|
1026
|
-
const r = !(e != null && e.length), {
|
|
1027
|
-
labels: i,
|
|
1028
|
-
loading: s,
|
|
1029
|
-
getLabelsById: h
|
|
1030
|
-
} = U(), [g, f] = z(!1);
|
|
658
|
+
function st({ labels: e, editable: t, onChange: a, sx: o, renderLabel: l }) {
|
|
659
|
+
const r = !(e != null && e.length), { labels: i, loading: s, getLabelsById: h } = U(), [g, f] = z(!1);
|
|
1031
660
|
if (s || !t && r)
|
|
1032
661
|
return null;
|
|
1033
662
|
const x = (u) => {
|
|
@@ -1036,51 +665,16 @@ function st({
|
|
|
1036
665
|
}, 300);
|
|
1037
666
|
};
|
|
1038
667
|
if (g)
|
|
1039
|
-
return /* @__PURE__ */ n($, {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
const d = h(e || []), b = [{
|
|
1050
|
-
display: "flex",
|
|
1051
|
-
gap: 1,
|
|
1052
|
-
alignItems: "center",
|
|
1053
|
-
flexWrap: "wrap"
|
|
1054
|
-
}, ...Array.isArray(o) ? o : [o]];
|
|
1055
|
-
return /* @__PURE__ */ C(p, {
|
|
1056
|
-
sx: b,
|
|
1057
|
-
children: [d.map((u) => u ? l ? l(u) : /* @__PURE__ */ n(me, {
|
|
1058
|
-
label: u.name,
|
|
1059
|
-
variant: "filled",
|
|
1060
|
-
size: "small",
|
|
1061
|
-
sx: {
|
|
1062
|
-
borderRadius: 1
|
|
1063
|
-
}
|
|
1064
|
-
}, u.id) : null), t && !r && /* @__PURE__ */ n(E, {
|
|
1065
|
-
color: "inherit",
|
|
1066
|
-
size: "small",
|
|
1067
|
-
onClick: () => f(!0),
|
|
1068
|
-
sx: {
|
|
1069
|
-
color: "grey.400"
|
|
1070
|
-
},
|
|
1071
|
-
children: /* @__PURE__ */ n(re, {
|
|
1072
|
-
sx: {
|
|
1073
|
-
fontSize: 20
|
|
1074
|
-
}
|
|
1075
|
-
})
|
|
1076
|
-
}), t && r && /* @__PURE__ */ n(A, {
|
|
1077
|
-
color: "inherit",
|
|
1078
|
-
variant: "outlined",
|
|
1079
|
-
startIcon: /* @__PURE__ */ n(oe, {}),
|
|
1080
|
-
onClick: () => f(!0),
|
|
1081
|
-
children: "Edit labels"
|
|
1082
|
-
})]
|
|
1083
|
-
});
|
|
668
|
+
return /* @__PURE__ */ n($, { onClickAway: () => g && f(!1), children: /* @__PURE__ */ n("div", { children: /* @__PURE__ */ n(Ae, { data: i, value: e || [], onChange: x }) }) });
|
|
669
|
+
const d = h(e || []), b = [
|
|
670
|
+
{ display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
|
|
671
|
+
...Array.isArray(o) ? o : [o]
|
|
672
|
+
];
|
|
673
|
+
return /* @__PURE__ */ C(p, { sx: b, children: [
|
|
674
|
+
d.map((u) => u ? l ? l(u) : /* @__PURE__ */ n(me, { label: u.name, variant: "filled", size: "small", sx: { borderRadius: 1 } }, u.id) : null),
|
|
675
|
+
t && !r && /* @__PURE__ */ n(E, { color: "inherit", size: "small", onClick: () => f(!0), sx: { color: "grey.400" }, children: /* @__PURE__ */ n(re, { sx: { fontSize: 20 } }) }),
|
|
676
|
+
t && r && /* @__PURE__ */ n(A, { color: "inherit", variant: "outlined", startIcon: /* @__PURE__ */ n(oe, {}), onClick: () => f(!0), children: "Edit labels" })
|
|
677
|
+
] });
|
|
1084
678
|
}
|
|
1085
679
|
export {
|
|
1086
680
|
lt as LabelManager,
|