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