@blocklet/labels 1.5.147 → 1.5.149

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/index.es.js CHANGED
@@ -1,74 +1,74 @@
1
- import { jsx as n, jsxs as b, Fragment as L } from "react/jsx-runtime";
2
- import { createContext as $, useRef as D, useState as A, useCallback as k, useEffect as F, useMemo as N, useContext as q } from "react";
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";
1
+ import { jsx as r, jsxs as C, Fragment as L } from "react/jsx-runtime";
2
+ import { createContext as V, useRef as D, useState as A, useCallback as k, useEffect as M, useMemo as N, useContext as q } from "react";
3
+ import { ExpandMore as W, Add as Z, EditOutlined as G, DeleteOutlineOutlined as U, Edit as Y, LabelOutlined as X } from "@mui/icons-material";
4
4
  import f from "@mui/material/Box";
5
- import { styled as H } from "@mui/material/styles";
6
- import { Tree as le } from "react-arborist";
7
- import { Icon as ae } from "@iconify/react";
8
- import ie from "lodash/omit";
9
- import se, { components as J } from "react-select";
10
- import ce from "@mui/material/Typography";
11
- import B from "@mui/material/Button";
12
- import j from "@mui/material/IconButton";
13
- import M from "@mui/material/TextField";
14
- import de from "@mui/material/ClickAwayListener";
15
- import { GithubPicker as ue } from "react-color";
16
- import _ from "@arcblock/ux/lib/Dialog";
17
- import { TextField as V, InputAdornment as he, IconButton as K, Box as O, ClickAwayListener as pe, Chip as fe, Button as me, getContrastRatio as ge, alpha as xe } from "@mui/material";
18
- import ye from "@mui/material/Popover";
19
- import { useLocaleContext as Q } from "@arcblock/ux/lib/Locale/context";
20
- import Ce from "@mui/material/Alert";
21
- const be = (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" }) }), ve = (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 = $({});
22
- function we({
5
+ import { styled as R } from "@mui/material/styles";
6
+ import { Tree as ee } from "react-arborist";
7
+ import { Icon as te } from "@iconify/react";
8
+ import ne from "lodash/omit";
9
+ import re, { components as $ } from "react-select";
10
+ import oe from "@mui/material/Typography";
11
+ import O from "@mui/material/Button";
12
+ import E from "@mui/material/IconButton";
13
+ import { TranslationTextField as le, TranslationTag as ae } from "@blocklet/translation-input";
14
+ import j from "@mui/material/TextField";
15
+ import se from "@mui/material/ClickAwayListener";
16
+ import { GithubPicker as ie } from "react-color";
17
+ import J from "@arcblock/ux/lib/Dialog";
18
+ import ce from "@mui/material/Alert";
19
+ import { ClickAwayListener as de, Box as ue, Chip as he, IconButton as pe, Button as fe, getContrastRatio as me, alpha as ge } from "@mui/material";
20
+ import { useLocaleContext as ye } from "@arcblock/ux/lib/Locale/context";
21
+ const xe = (e) => /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...e, children: /* @__PURE__ */ r("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" }) }), Ce = (e) => /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...e, children: /* @__PURE__ */ r("path", { fill: "currentColor", d: "m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z" }) }), _ = V({});
22
+ function ve({
23
23
  selectable: e = !1,
24
24
  selected: t = [],
25
- onSelect: i,
26
- renderItem: o,
27
- children: l
25
+ onSelect: s,
26
+ renderItem: l,
27
+ children: o
28
28
  }) {
29
- const r = (h) => t.indexOf(h) !== -1, a = (h) => {
30
- Array.from(new Set(t).add(h)), i == null || i(h);
31
- }, d = N(
29
+ const n = (p) => t.indexOf(p) !== -1, a = (p) => {
30
+ Array.from(new Set(t).add(p)), s == null || s(p);
31
+ }, u = N(
32
32
  () => ({
33
33
  selectable: e,
34
34
  selected: t,
35
- isSelected: r,
35
+ isSelected: n,
36
36
  select: a,
37
- renderItem: o
37
+ renderItem: l
38
38
  }),
39
39
  // eslint-disable-next-line react-hooks/exhaustive-deps
40
40
  [t]
41
41
  );
42
- return /* @__PURE__ */ n(Y.Provider, { value: d, children: l });
42
+ return /* @__PURE__ */ r(_.Provider, { value: u, children: o });
43
43
  }
44
- const Se = (e) => {
44
+ const be = (e) => {
45
45
  var t;
46
46
  return e.isLeaf || !((t = e.data.children) != null && t.length);
47
47
  };
48
- function Ie({ node: e }) {
49
- return Se(e) ? /* @__PURE__ */ n("span", {}) : e.isOpen ? /* @__PURE__ */ n(R, { style: { fontSize: 20 } }) : /* @__PURE__ */ n(R, { style: { fontSize: 20, transform: "rotate(-90deg)" } });
48
+ function Se({ node: e }) {
49
+ return be(e) ? /* @__PURE__ */ r("span", {}) : e.isOpen ? /* @__PURE__ */ r(W, { style: { fontSize: 20 } }) : /* @__PURE__ */ r(W, { style: { fontSize: 20, transform: "rotate(-90deg)" } });
50
50
  }
51
- function ze({ node: e, style: t, dragHandle: i }) {
52
- const { selectable: o, select: l, isSelected: r, renderItem: a } = q(Y), { data: d } = e, h = d.icon ? /* @__PURE__ */ n(ae, { icon: d.icon, style: { fontSize: 18 } }) : /* @__PURE__ */ n(be, { style: { fontSize: 18, color: d.color || "#ddd" } }), x = (y) => {
53
- y.stopPropagation(), e.isInternal && e.toggle();
54
- }, g = (y) => {
55
- y.stopPropagation(), o && l(e.id);
56
- }, m = /* @__PURE__ */ b(L, { children: [
57
- /* @__PURE__ */ b(f, { sx: { display: "flex", alignItems: "center", flex: 1 }, children: [
58
- /* @__PURE__ */ n(f, { sx: { display: "flex", cursor: "pointer" }, onClick: x, children: /* @__PURE__ */ n(Ie, { node: e }) }),
59
- /* @__PURE__ */ n(f, { sx: { display: "flex", alignItems: "center", width: 22, height: 22 }, children: h }),
60
- /* @__PURE__ */ n(f, { component: "span", sx: { color: "grey.700" }, children: e.data.name })
51
+ function we({ node: e, style: t, dragHandle: s }) {
52
+ const { selectable: l, select: o, isSelected: n, renderItem: a } = q(_), { data: u } = e, p = u.icon ? /* @__PURE__ */ r(te, { icon: u.icon, style: { fontSize: 18 } }) : /* @__PURE__ */ r(xe, { style: { fontSize: 18, color: u.color || "#ddd" } }), y = (x) => {
53
+ x.stopPropagation(), e.isInternal && e.toggle();
54
+ }, b = (x) => {
55
+ x.stopPropagation(), l && o(e.id);
56
+ }, m = /* @__PURE__ */ C(L, { children: [
57
+ /* @__PURE__ */ C(f, { sx: { display: "flex", alignItems: "center", flex: 1 }, children: [
58
+ /* @__PURE__ */ r(f, { sx: { display: "flex", cursor: "pointer" }, onClick: y, children: /* @__PURE__ */ r(Se, { node: e }) }),
59
+ /* @__PURE__ */ r(f, { sx: { display: "flex", alignItems: "center", width: 22, height: 22 }, children: p }),
60
+ /* @__PURE__ */ r(f, { component: "span", sx: { color: "grey.700" }, children: e.data.name })
61
61
  ] }),
62
- o && r(e.id) && /* @__PURE__ */ n(ve, {})
62
+ l && n(e.id) && /* @__PURE__ */ r(Ce, {})
63
63
  ] });
64
- return /* @__PURE__ */ b(
64
+ return /* @__PURE__ */ C(
65
65
  f,
66
66
  {
67
67
  className: "label-tree-item",
68
68
  style: t,
69
69
  sx: { display: "flex", alignItems: "center", justifyContent: "space-between" },
70
- ref: i,
71
- onClick: g,
70
+ ref: s,
71
+ onClick: b,
72
72
  children: [
73
73
  !a && m,
74
74
  !!a && a(m, e.data)
@@ -76,7 +76,7 @@ function ze({ node: e, style: t, dragHandle: i }) {
76
76
  }
77
77
  );
78
78
  }
79
- const Ae = H(f)`
79
+ const Ie = R(f)`
80
80
  > div,
81
81
  > div > div,
82
82
  > div > div > div {
@@ -90,70 +90,70 @@ const Ae = H(f)`
90
90
  width: 100%;
91
91
  }
92
92
  `;
93
- function W({
93
+ function F({
94
94
  data: e,
95
95
  selectable: t,
96
- selected: i = [],
97
- onSelect: o,
98
- rowHeight: l = 28,
99
- renderItem: r,
96
+ selected: s = [],
97
+ onSelect: l,
98
+ rowHeight: o = 28,
99
+ renderItem: n,
100
100
  sx: a,
101
- ...d
101
+ ...u
102
102
  }) {
103
- const h = D(), x = [...Array.isArray(a) ? a : [a]], [g, m] = A(0), y = k(() => {
104
- var c, s;
105
- m((((s = (c = h.current) == null ? void 0 : c.visibleNodes) == null ? void 0 : s.length) || 0) * l);
106
- }, [l]);
107
- return F(() => {
108
- y();
109
- }, [e, y]), /* @__PURE__ */ n(we, { selectable: t, selected: i, onSelect: o, renderItem: r, children: /* @__PURE__ */ n(Ae, { ...d, sx: x, children: /* @__PURE__ */ n(le, { data: e, rowHeight: l, height: g, indent: 32, ref: h, onToggle: () => {
110
- setTimeout(y);
111
- }, children: ze }) }) });
103
+ const p = D(), y = [...Array.isArray(a) ? a : [a]], [b, m] = A(0), x = k(() => {
104
+ var c, i;
105
+ m((((i = (c = p.current) == null ? void 0 : c.visibleNodes) == null ? void 0 : i.length) || 0) * o);
106
+ }, [o]);
107
+ return M(() => {
108
+ x();
109
+ }, [e, x]), /* @__PURE__ */ r(ve, { selectable: t, selected: s, onSelect: l, renderItem: n, children: /* @__PURE__ */ r(Ie, { ...u, sx: y, children: /* @__PURE__ */ r(ee, { data: e, rowHeight: o, height: b, indent: 32, ref: p, onToggle: () => {
110
+ setTimeout(x);
111
+ }, children: we }) }) });
112
112
  }
113
- const P = (e) => e.reduce((t, i) => {
114
- var o;
115
- return t.push(i), (o = i.children) != null && o.length && t.push(...P(i.children)), t;
116
- }, []), Z = (e) => e.map((t) => {
117
- var i;
118
- return (i = t.children) != null && i.length && (t.children = Z(t.children)), t;
119
- }), ke = (e, t = null) => {
113
+ const B = (e) => e.reduce((t, s) => {
114
+ var l;
115
+ return t.push(s), (l = s.children) != null && l.length && t.push(...B(s.children)), t;
116
+ }, []), H = (e) => e.map((t) => {
117
+ var s;
118
+ return (s = t.children) != null && s.length && (t.children = H(t.children)), t;
119
+ }), ze = (e, t = null) => {
120
120
  try {
121
121
  return JSON.parse(e);
122
122
  } catch {
123
123
  return t;
124
124
  }
125
- }, Ne = (e) => {
126
- const t = e.reduce((l, r) => (l[r.id] = l[r.id] || {}, r.parentId && (l[r.id].parent = r.parentId, l[r.parentId] = l[r.parentId] || {}, l[r.parentId].children = l[r.parentId].children || [], l[r.parentId].children.push(r.id)), l), {}), i = e.map(({ parentId: l, translation: r, ...a }) => ({
125
+ }, ke = (e) => {
126
+ const t = e.reduce((o, n) => (o[n.id] = o[n.id] || {}, n.parentId && (o[n.id].parent = n.parentId, o[n.parentId] = o[n.parentId] || {}, o[n.parentId].children = o[n.parentId].children || [], o[n.parentId].children.push(n.id)), o), {}), s = e.map(({ parentId: o, translation: n, ...a }) => ({
127
127
  ...a,
128
- translation: ke(r),
128
+ translation: ze(n),
129
129
  children: []
130
- })), o = i.reduce((l, r) => ({ ...l, [r.id]: r }), {});
131
- return i.forEach((l) => {
132
- const r = t[l.id];
133
- r.parent && o[r.parent] && (l.parent = o[r.parent]), r.children && (l.children = r.children.map((a) => o[a]));
134
- }), i.filter((l) => !l.parent);
135
- }, Te = (e) => {
136
- const { options: t, getValue: i, selectProps: o, selectOption: l } = e, r = i(), a = (d) => {
137
- const h = t.find((x) => x.data.id === d);
138
- h && l(h);
130
+ })), l = s.reduce((o, n) => ({ ...o, [n.id]: n }), {});
131
+ return s.forEach((o) => {
132
+ const n = t[o.id];
133
+ n.parent && l[n.parent] && (o.parent = l[n.parent]), n.children && (o.children = n.children.map((a) => l[a]));
134
+ }), s.filter((o) => !o.parent);
135
+ }, Ae = (e) => {
136
+ const { options: t, getValue: s, selectProps: l, selectOption: o } = e, n = s(), a = (u) => {
137
+ const p = t.find((y) => y.data.id === u);
138
+ p && o(p);
139
139
  };
140
- return /* @__PURE__ */ b(L, { children: [
141
- /* @__PURE__ */ n(J.MenuList, { ...ie(e, ["addon"]), children: /* @__PURE__ */ n(f, { sx: { px: 2, py: 1 }, children: /* @__PURE__ */ n(
142
- W,
140
+ return /* @__PURE__ */ C(L, { children: [
141
+ /* @__PURE__ */ r($.MenuList, { ...ne(e, ["addon"]), children: /* @__PURE__ */ r(f, { sx: { px: 2, py: 1 }, children: /* @__PURE__ */ r(
142
+ F,
143
143
  {
144
- data: o.data,
144
+ data: l.data,
145
145
  selectable: !0,
146
146
  onSelect: a,
147
- selected: r.map((d) => d.data.id)
147
+ selected: n.map((u) => u.data.id)
148
148
  }
149
149
  ) }) }),
150
150
  e.addon
151
151
  ] });
152
- }, Oe = ({ children: e, ...t }) => {
153
- const [i, o] = e, l = Array.isArray(i) ? i.length : 0;
154
- return /* @__PURE__ */ b(J.ValueContainer, { ...t, children: [
155
- /* @__PURE__ */ n(f, { component: "span", sx: { fontSize: 13, fontWeight: "bold" }, children: l ? "Labels" : "Filter by labels" }),
156
- !!l && /* @__PURE__ */ n(
152
+ }, Ne = ({ children: e, ...t }) => {
153
+ const [s, l] = e, o = Array.isArray(s) ? s.length : 0;
154
+ return /* @__PURE__ */ C($.ValueContainer, { ...t, children: [
155
+ /* @__PURE__ */ r(f, { component: "span", sx: { fontSize: 13, fontWeight: "bold" }, children: o ? "Labels" : "Filter by labels" }),
156
+ !!o && /* @__PURE__ */ r(
157
157
  f,
158
158
  {
159
159
  sx: {
@@ -167,12 +167,12 @@ const P = (e) => e.reduce((t, i) => {
167
167
  fontSize: 12,
168
168
  bgcolor: "grey.200"
169
169
  },
170
- children: l
170
+ children: o
171
171
  }
172
172
  ),
173
- o
173
+ l
174
174
  ] });
175
- }, Be = {
175
+ }, Te = {
176
176
  control: (e) => ({
177
177
  ...e,
178
178
  minHeight: 31
@@ -190,67 +190,67 @@ const P = (e) => e.reduce((t, i) => {
190
190
  padding: "4px"
191
191
  })
192
192
  };
193
- function Pe({
193
+ function Oe({
194
194
  data: e,
195
195
  value: t = [],
196
- editable: i = !1,
197
- addon: o,
198
- onChange: l,
199
- compact: r,
196
+ editable: s = !1,
197
+ addon: l,
198
+ onChange: o,
199
+ compact: n,
200
200
  isMulti: a = !0,
201
- maxHeight: d = 264,
202
- ...h
201
+ maxHeight: u = 264,
202
+ ...p
203
203
  }) {
204
- const x = D(null), g = N(
205
- () => P(e).map((p) => ({ data: p, label: p.name, value: p.id })),
204
+ const y = D(null), b = N(
205
+ () => B(e).map((h) => ({ data: h, label: h.name, value: h.id })),
206
206
  [e]
207
- ), m = g.reduce(
208
- (p, I) => ({ ...p, [I.data.id]: I }),
207
+ ), m = b.reduce(
208
+ (h, I) => ({ ...h, [I.data.id]: I }),
209
209
  {}
210
- ), y = Array.isArray(t) ? t : [t], z = y.map((p) => m[p]), c = D({
211
- prev: y.map((p) => {
210
+ ), x = Array.isArray(t) ? t : [t], z = x.map((h) => m[h]), c = D({
211
+ prev: x.map((h) => {
212
212
  var I;
213
- return ((I = m[p]) == null ? void 0 : I.data) || "";
213
+ return ((I = m[h]) == null ? void 0 : I.data) || "";
214
214
  })
215
- }), s = (p, I) => {
216
- !a || !Array.isArray(p) ? l(p ? [p.data] : []) : c.current.current = p.map((u) => u.data), ["clear", "remove-value"].includes(I.action) && x.current && setTimeout(() => {
217
- var u;
218
- return (u = x == null ? void 0 : x.current) == null ? void 0 : u.blur();
215
+ }), i = (h, I) => {
216
+ !a || !Array.isArray(h) ? o(h ? [h.data] : []) : c.current.current = h.map((d) => d.data), ["clear", "remove-value"].includes(I.action) && y.current && setTimeout(() => {
217
+ var d;
218
+ return (d = y == null ? void 0 : y.current) == null ? void 0 : d.blur();
219
219
  }, 1);
220
- }, w = () => {
221
- c.current.current && JSON.stringify(c.current.prev.map((I) => I.id)) !== JSON.stringify(c.current.current.map((I) => I.id)) && (l(c.current.current), c.current.prev = c.current.current);
220
+ }, S = () => {
221
+ c.current.current && JSON.stringify(c.current.prev.map((I) => I.id)) !== JSON.stringify(c.current.current.map((I) => I.id)) && (o(c.current.current), c.current.prev = c.current.current);
222
222
  };
223
- return /* @__PURE__ */ n(f, { ...h, children: /* @__PURE__ */ n(
224
- se,
223
+ return /* @__PURE__ */ r(f, { ...p, children: /* @__PURE__ */ r(
224
+ re,
225
225
  {
226
- ref: x,
226
+ ref: y,
227
227
  defaultValue: z,
228
- options: g,
229
- onChange: s,
228
+ options: b,
229
+ onChange: i,
230
230
  components: {
231
231
  // @ts-ignore
232
- MenuList: (p) => /* @__PURE__ */ n(Te, { ...p, addon: o }),
232
+ MenuList: (h) => /* @__PURE__ */ r(Ae, { ...h, addon: l }),
233
233
  // eslint-disable-line react/no-unstable-nested-components
234
- ...r && { ValueContainer: Oe }
234
+ ...n && { ValueContainer: Ne }
235
235
  },
236
236
  placeholder: "Select labels",
237
237
  styles: {
238
- ...r && Be,
239
- menu: (p) => ({
240
- ...p,
241
- ...i && { paddingBottom: "36px" },
238
+ ...n && Te,
239
+ menu: (h) => ({
240
+ ...h,
241
+ ...s && { paddingBottom: "36px" },
242
242
  zIndex: 99
243
243
  }),
244
- menuList: (p) => ({
245
- ...p,
244
+ menuList: (h) => ({
245
+ ...h,
246
246
  overflowY: "auto",
247
- maxHeight: `${d}px`
247
+ maxHeight: `${u}px`
248
248
  })
249
249
  },
250
- theme: (p) => ({
251
- ...p,
250
+ theme: (h) => ({
251
+ ...h,
252
252
  colors: {
253
- ...p.colors,
253
+ ...h.colors,
254
254
  primary25: "#ddd",
255
255
  primary50: "#ddd",
256
256
  primary: "#ddd"
@@ -259,184 +259,120 @@ function Pe({
259
259
  isSearchable: !1,
260
260
  isMulti: a,
261
261
  closeMenuOnSelect: !a,
262
- onMenuClose: w,
262
+ onMenuClose: S,
263
263
  isClearable: !0,
264
264
  data: e
265
265
  }
266
266
  ) });
267
267
  }
268
- var E = function() {
269
- return E = Object.assign || function(t) {
270
- for (var i, o = 1, l = arguments.length; o < l; o++) {
271
- i = arguments[o];
272
- for (var r in i)
273
- Object.prototype.hasOwnProperty.call(i, r) && (t[r] = i[r]);
268
+ var P = function() {
269
+ return P = Object.assign || function(t) {
270
+ for (var s, l = 1, o = arguments.length; l < o; l++) {
271
+ s = arguments[l];
272
+ for (var n in s)
273
+ Object.prototype.hasOwnProperty.call(s, n) && (t[n] = s[n]);
274
274
  }
275
275
  return t;
276
- }, E.apply(this, arguments);
276
+ }, P.apply(this, arguments);
277
277
  };
278
- function Le(e, t) {
279
- var i = typeof Symbol == "function" && e[Symbol.iterator];
280
- if (!i)
278
+ function Be(e, t) {
279
+ var s = typeof Symbol == "function" && e[Symbol.iterator];
280
+ if (!s)
281
281
  return e;
282
- var o = i.call(e), l, r = [], a;
282
+ var l = s.call(e), o, n = [], a;
283
283
  try {
284
- for (; (t === void 0 || t-- > 0) && !(l = o.next()).done; )
285
- r.push(l.value);
286
- } catch (d) {
287
- a = { error: d };
284
+ for (; (t === void 0 || t-- > 0) && !(o = l.next()).done; )
285
+ n.push(o.value);
286
+ } catch (u) {
287
+ a = { error: u };
288
288
  } finally {
289
289
  try {
290
- l && !l.done && (i = o.return) && i.call(o);
290
+ o && !o.done && (s = l.return) && s.call(l);
291
291
  } finally {
292
292
  if (a)
293
293
  throw a.error;
294
294
  }
295
295
  }
296
- return r;
296
+ return n;
297
297
  }
298
- var Ee = function(e) {
298
+ var Le = function(e) {
299
299
  return typeof e == "function";
300
- }, je = function(e) {
301
- var t = Le(A(e), 2), i = t[0], o = t[1], l = k(function(r) {
302
- o(function(a) {
303
- var d = Ee(r) ? r(a) : r;
304
- return d ? E(E({}, a), d) : a;
300
+ }, Pe = function(e) {
301
+ var t = Be(A(e), 2), s = t[0], l = t[1], o = k(function(n) {
302
+ l(function(a) {
303
+ var u = Le(n) ? n(a) : n;
304
+ return u ? P(P({}, a), u) : a;
305
305
  });
306
306
  }, []);
307
- return [i, l];
307
+ return [s, o];
308
308
  };
309
- const Me = je;
310
- function De({ I18NProps: e, ...t }) {
311
- const { languages: i } = Q(), { translation: o, onChange: l } = e, [r, a] = A(null), d = (g) => {
312
- const m = g.currentTarget.closest(".MuiInputBase-root");
313
- m && a(m);
314
- }, h = () => {
315
- a(null);
316
- }, x = i.filter((g) => g.code !== "en");
317
- return /* @__PURE__ */ n(
318
- V,
319
- {
320
- ...t,
321
- InputProps: {
322
- endAdornment: /* @__PURE__ */ b(he, { position: "end", children: [
323
- /* @__PURE__ */ n(K, { edge: "end", onClick: d, children: /* @__PURE__ */ n(X, {}) }),
324
- /* @__PURE__ */ n(
325
- ye,
326
- {
327
- open: !!r,
328
- anchorEl: r,
329
- onClose: h,
330
- transformOrigin: {
331
- vertical: "top",
332
- horizontal: "right"
333
- },
334
- anchorOrigin: {
335
- vertical: "bottom",
336
- horizontal: "right"
337
- },
338
- PaperProps: {
339
- sx: { width: r == null ? void 0 : r.clientWidth, maxHeight: 200, overflowY: "auto", bgcolor: "grey.50" }
340
- },
341
- elevation: 1,
342
- sx: { mt: 2 },
343
- children: /* @__PURE__ */ n(O, { sx: { p: 2 }, children: x.map(({ code: g, name: m }) => /* @__PURE__ */ b(
344
- O,
345
- {
346
- sx: {
347
- display: "flex",
348
- alignItems: "center",
349
- justifyContent: "space-between",
350
- "& + &": { mt: 1 }
351
- },
352
- children: [
353
- /* @__PURE__ */ n(O, { sx: { flex: "0 0 120px" }, children: m }),
354
- /* @__PURE__ */ n(O, { sx: { flex: 1 }, children: /* @__PURE__ */ n(
355
- V,
356
- {
357
- value: o[g] || "",
358
- size: "small",
359
- sx: { width: 1 },
360
- onChange: (y) => l({ ...o, [g]: y.target.value })
361
- }
362
- ) })
363
- ]
364
- },
365
- g
366
- )) })
367
- }
368
- )
369
- ] })
370
- }
371
- }
372
- );
373
- }
374
- function Fe({ open: e, initialLabel: t, onSubmit: i, onClose: o, ...l }) {
375
- const r = !(t != null && t.id), [a, d] = Me({
309
+ const Ee = Pe;
310
+ function je({ open: e, initialLabel: t, onSubmit: s, onClose: l, ...o }) {
311
+ const n = !(t != null && t.id), [a, u] = Ee({
376
312
  name: (t == null ? void 0 : t.name) || "",
377
313
  color: (t == null ? void 0 : t.color) || "#ddd",
378
314
  slug: (t == null ? void 0 : t.id) || "",
379
315
  translation: (t == null ? void 0 : t.translation) || {}
380
- }), h = (s) => /^#([0-9A-F]{3}){1,2}$/i.test(s), x = N(() => r ? a.name && a.color && a.slug && h(a.color) : a.name && a.color && h(a.color), [a, r]), [g, m] = A(!1), y = () => {
381
- i({ ...t, name: a.name, color: a.color, id: a.slug, translation: a.translation });
382
- }, z = (s) => {
383
- d({ color: s.hex }), setTimeout(() => m(!1));
384
- }, c = (s) => {
385
- d({ color: s.target.value });
316
+ }), p = (i) => /^#([0-9A-F]{3}){1,2}$/i.test(i), y = N(() => n ? a.name && a.color && a.slug && p(a.color) : a.name && a.color && p(a.color), [a, n]), [b, m] = A(!1), x = () => {
317
+ s({ ...t, name: a.name, color: a.color, id: a.slug, translation: a.translation });
318
+ }, z = (i) => {
319
+ u({ color: i.hex }), setTimeout(() => m(!1));
320
+ }, c = (i) => {
321
+ u({ color: i.target.value });
386
322
  };
387
- return /* @__PURE__ */ n(
388
- _,
323
+ return /* @__PURE__ */ r(
324
+ J,
389
325
  {
390
326
  open: e,
391
327
  showCloseButton: !0,
392
328
  maxWidth: "lg",
393
- title: r ? "Create label" : "Edit label",
394
- actions: /* @__PURE__ */ b(L, { children: [
395
- /* @__PURE__ */ n(B, { color: "inherit", variant: "contained", size: "small", onClick: o, children: "Cancel" }),
396
- /* @__PURE__ */ n(B, { color: "primary", variant: "contained", size: "small", onClick: y, disabled: !x, children: r ? "Create" : "Save Changes" })
329
+ title: n ? "Create label" : "Edit label",
330
+ actions: /* @__PURE__ */ C(L, { children: [
331
+ /* @__PURE__ */ r(O, { color: "inherit", variant: "contained", size: "small", onClick: l, children: "Cancel" }),
332
+ /* @__PURE__ */ r(O, { color: "primary", variant: "contained", size: "small", onClick: x, disabled: !y, children: n ? "Create" : "Save Changes" })
397
333
  ] }),
398
- onClose: o,
399
- ...l,
400
- children: /* @__PURE__ */ b(f, { width: 600, minHeight: 280, children: [
401
- /* @__PURE__ */ n(
402
- De,
334
+ onClose: l,
335
+ ...o,
336
+ children: /* @__PURE__ */ C(f, { width: 600, minHeight: 320, children: [
337
+ /* @__PURE__ */ r(
338
+ le,
403
339
  {
404
340
  label: "Name",
405
341
  value: a.name,
406
342
  placeholder: "New label",
407
343
  size: "small",
408
344
  fullWidth: !0,
409
- onChange: (s) => d({ name: s.target.value }),
410
- I18NProps: {
411
- translation: a.translation,
412
- onChange: (s) => d({ translation: s })
345
+ onChange: (i) => u({ name: i.target.value }),
346
+ translationInputProps: {
347
+ value: a.translation,
348
+ onChange: (i) => u({ translation: i })
413
349
  }
414
350
  }
415
351
  ),
416
- /* @__PURE__ */ n(
417
- M,
352
+ /* @__PURE__ */ r(
353
+ j,
418
354
  {
419
355
  label: "Slug",
420
356
  value: a.slug,
421
357
  size: "small",
422
358
  fullWidth: !0,
423
- disabled: !r,
424
- onChange: (s) => d({ slug: s.target.value }),
359
+ disabled: !n,
360
+ onChange: (i) => u({ slug: i.target.value }),
425
361
  sx: { mt: 2 }
426
362
  }
427
363
  ),
428
- (t == null ? void 0 : t.parent) && /* @__PURE__ */ n(M, { label: "Parent", value: t.parent.name, size: "small", fullWidth: !0, disabled: !0, sx: { mt: 2 } }),
429
- /* @__PURE__ */ n(de, { onClickAway: () => m(!1), children: /* @__PURE__ */ b(f, { sx: { position: "relative", mt: 2 }, children: [
430
- /* @__PURE__ */ b(f, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
431
- /* @__PURE__ */ n(
364
+ (t == null ? void 0 : t.parent) && /* @__PURE__ */ r(j, { label: "Parent", value: t.parent.name, size: "small", fullWidth: !0, disabled: !0, sx: { mt: 2 } }),
365
+ /* @__PURE__ */ r(se, { onClickAway: () => m(!1), children: /* @__PURE__ */ C(f, { sx: { position: "relative", mt: 2 }, children: [
366
+ /* @__PURE__ */ C(f, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
367
+ /* @__PURE__ */ r(
432
368
  f,
433
369
  {
434
370
  sx: { width: 30, height: 30, bgcolor: a.color, borderRadius: 1 },
435
371
  onClick: () => m(!0)
436
372
  }
437
373
  ),
438
- /* @__PURE__ */ n(
439
- M,
374
+ /* @__PURE__ */ r(
375
+ j,
440
376
  {
441
377
  label: "",
442
378
  value: a.color,
@@ -447,34 +383,34 @@ function Fe({ open: e, initialLabel: t, onSubmit: i, onClose: o, ...l }) {
447
383
  }
448
384
  )
449
385
  ] }),
450
- g && /* @__PURE__ */ n(f, { sx: { position: "absolute", top: 48, zIndex: 1 }, children: /* @__PURE__ */ n(ue, { color: a.color, onChangeComplete: z }) })
386
+ b && /* @__PURE__ */ r(f, { sx: { position: "absolute", top: 48, zIndex: 1 }, children: /* @__PURE__ */ r(ie, { color: a.color, onChangeComplete: z }) })
451
387
  ] }) })
452
388
  ] })
453
389
  }
454
390
  );
455
391
  }
456
- function We({ open: e, label: t, onSubmit: i, onClose: o, ...l }) {
457
- return /* @__PURE__ */ n(
458
- _,
392
+ function De({ open: e, label: t, onSubmit: s, onClose: l, ...o }) {
393
+ return /* @__PURE__ */ r(
394
+ J,
459
395
  {
460
396
  open: e,
461
397
  showCloseButton: !0,
462
398
  maxWidth: "md",
463
399
  title: "Delete",
464
- actions: /* @__PURE__ */ b(L, { children: [
465
- /* @__PURE__ */ n(B, { color: "inherit", variant: "contained", size: "small", onClick: o, children: "Cancel" }),
466
- /* @__PURE__ */ n(B, { color: "primary", variant: "contained", size: "small", onClick: i, children: "Delete" })
400
+ actions: /* @__PURE__ */ C(L, { children: [
401
+ /* @__PURE__ */ r(O, { color: "inherit", variant: "contained", size: "small", onClick: l, children: "Cancel" }),
402
+ /* @__PURE__ */ r(O, { color: "primary", variant: "contained", size: "small", onClick: s, children: "Delete" })
467
403
  ] }),
468
- onClose: o,
469
- ...l,
470
- children: /* @__PURE__ */ b(f, { width: 600, minHeight: 280, children: [
471
- /* @__PURE__ */ n(Ce, { severity: "info", sx: { mb: 2 }, children: "Are you sure you want to delete these labels ?" }),
472
- /* @__PURE__ */ n(W, { data: [t] })
404
+ onClose: l,
405
+ ...o,
406
+ children: /* @__PURE__ */ C(f, { width: 600, minHeight: 280, children: [
407
+ /* @__PURE__ */ r(ce, { severity: "info", sx: { mb: 2 }, children: "Are you sure you want to delete these labels ?" }),
408
+ /* @__PURE__ */ r(F, { data: [t] })
473
409
  ] })
474
410
  }
475
411
  );
476
412
  }
477
- const Re = H(W)`
413
+ const Me = R(F)`
478
414
  .label-tree-item {
479
415
  &:before {
480
416
  content: '';
@@ -495,73 +431,51 @@ const Re = H(W)`
495
431
  padding: 0 16px;
496
432
  }
497
433
  `;
498
- function Ve({ locale: e, value: t }) {
499
- return /* @__PURE__ */ b(
500
- f,
501
- {
502
- sx: {
503
- display: "flex",
504
- alignItems: "center",
505
- flex: "0 0 auto",
506
- px: 1,
507
- py: 0.25,
508
- fontSize: 12,
509
- bgcolor: "grey.300",
510
- borderRadius: 2
511
- },
512
- className: "label-translation-tag",
513
- children: [
514
- /* @__PURE__ */ n(f, { sx: { pr: 0.5, borderRight: 1, borderColor: "grey.400" }, children: e }),
515
- /* @__PURE__ */ n(f, { sx: { pl: 0.5 }, children: t })
516
- ]
517
- }
518
- );
519
- }
520
- function dt({ data: e, api: t, ...i }) {
521
- const [o, l] = A(null), [r, a] = A(null), [d, h] = A(Z(e)), x = N(() => P(d), [d]), g = N(() => {
522
- const u = (C, S) => C.map((v) => (S && (v.parent = S), v.children && (v.children = u(v.children, v)), v));
523
- return u(d);
524
- }, [d]), m = (u) => {
525
- var C, S;
526
- u.parent ? (u.parent.children = (S = (C = u.parent) == null ? void 0 : C.children) == null ? void 0 : S.map((v) => v.id === u.id ? { ...u } : v), m(u.parent)) : h(d.map((v) => v.id === u.id ? { ...u } : v));
527
- }, y = (u) => {
528
- u.parent ? (u.parent.children = u.parent.children || [], u.parent.children.push(u), h([...d])) : h([...d, u]);
529
- }, z = (u) => {
530
- var C;
531
- u.parent ? u.parent.children = (C = u.parent.children) == null ? void 0 : C.filter((S) => S.id !== u.id) : h(d.filter((S) => S.id !== u.id));
532
- }, c = (u) => {
533
- if (o)
434
+ function at({ data: e, api: t, ...s }) {
435
+ const [l, o] = A(null), [n, a] = A(null), [u, p] = A(H(e)), y = N(() => B(u), [u]), b = N(() => {
436
+ const d = (g, w) => g.map((v) => (w && (v.parent = w), v.children && (v.children = d(v.children, v)), v));
437
+ return d(u);
438
+ }, [u]), m = (d) => {
439
+ var g, w;
440
+ d.parent ? (d.parent.children = (w = (g = d.parent) == null ? void 0 : g.children) == null ? void 0 : w.map((v) => v.id === d.id ? { ...d } : v), m(d.parent)) : p(u.map((v) => v.id === d.id ? { ...d } : v));
441
+ }, x = (d) => {
442
+ d.parent ? (d.parent.children = d.parent.children || [], d.parent.children.push(d), p([...u])) : p([...u, d]);
443
+ }, z = (d) => {
444
+ var g;
445
+ d.parent ? d.parent.children = (g = d.parent.children) == null ? void 0 : g.filter((w) => w.id !== d.id) : p(u.filter((w) => w.id !== d.id));
446
+ }, c = (d) => {
447
+ if (l)
534
448
  return;
535
- l({ id: "", name: "New label", parent: u, color: "#dddddd" });
536
- }, s = (u) => {
537
- o || l(u);
538
- }, w = async (u) => {
539
- if (!o)
449
+ o({ id: "", name: "New label", parent: d, color: "#dddddd" });
450
+ }, i = (d) => {
451
+ l || o(d);
452
+ }, S = async (d) => {
453
+ if (!l)
540
454
  return;
541
- const { parent: C, children: S, translation: v, ...T } = u;
542
- o.id ? (await t.updateLabel({ ...T, translation: JSON.stringify(v), parentId: C == null ? void 0 : C.id }), m(u)) : (await t.createLabel({ ...T, translation: JSON.stringify(v), parentId: C == null ? void 0 : C.id }), y(u)), l(null);
543
- }, p = async () => {
544
- r && (await t.deleteLabel(r.id), z(r), a(null));
545
- }, I = (u, C) => /* @__PURE__ */ b(L, { children: [
546
- /* @__PURE__ */ b(f, { sx: { display: "flex", alignItems: "center", flexWrap: "wrap" }, className: "label-name", children: [
547
- /* @__PURE__ */ n(f, { children: u }),
548
- C.translation && /* @__PURE__ */ n(f, { sx: { display: "flex", alignItems: "center", gap: 0.5, ml: 2 }, className: "label-translation", children: Object.keys(C.translation).map((S) => {
455
+ const { parent: g, children: w, translation: v, ...T } = d;
456
+ l.id ? (await t.updateLabel({ ...T, translation: JSON.stringify(v), parentId: g == null ? void 0 : g.id }), m(d)) : (await t.createLabel({ ...T, translation: JSON.stringify(v), parentId: g == null ? void 0 : g.id }), x(d)), o(null);
457
+ }, h = async () => {
458
+ n && (await t.deleteLabel(n.id), z(n), a(null));
459
+ }, I = (d, g) => /* @__PURE__ */ C(L, { children: [
460
+ /* @__PURE__ */ C(f, { sx: { display: "flex", alignItems: "center", flexWrap: "wrap" }, className: "label-name", children: [
461
+ /* @__PURE__ */ r(f, { children: d }),
462
+ g.translation && /* @__PURE__ */ r(f, { sx: { display: "flex", alignItems: "center", gap: 0.5, ml: 2 }, className: "label-translation", children: Object.keys(g.translation).map((w) => {
549
463
  var T;
550
- const v = (T = C.translation) == null ? void 0 : T[S];
551
- return v ? /* @__PURE__ */ n(Ve, { locale: S, value: v }, S) : null;
464
+ const v = (T = g.translation) == null ? void 0 : T[w];
465
+ return v ? /* @__PURE__ */ r(ae, { locale: w, value: v }, w) : null;
552
466
  }) })
553
467
  ] }),
554
- /* @__PURE__ */ b(f, { sx: { display: "flex", gap: 1, flex: "0 0 auto" }, className: "label-action", children: [
555
- /* @__PURE__ */ n(j, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => c(C), children: /* @__PURE__ */ n(ee, { sx: { fontSize: 20 } }) }),
556
- /* @__PURE__ */ n(j, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => s(C), children: /* @__PURE__ */ n(te, { sx: { fontSize: 18 } }) }),
557
- /* @__PURE__ */ n(j, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => a(C), children: /* @__PURE__ */ n(ne, { sx: { fontSize: 20 } }) })
468
+ /* @__PURE__ */ C(f, { sx: { display: "flex", gap: 1, flex: "0 0 auto" }, className: "label-action", children: [
469
+ /* @__PURE__ */ r(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => c(g), children: /* @__PURE__ */ r(Z, { sx: { fontSize: 20 } }) }),
470
+ /* @__PURE__ */ r(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => i(g), children: /* @__PURE__ */ r(G, { sx: { fontSize: 18 } }) }),
471
+ /* @__PURE__ */ r(E, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => a(g), children: /* @__PURE__ */ r(U, { sx: { fontSize: 20 } }) })
558
472
  ] })
559
473
  ] });
560
- return /* @__PURE__ */ b(f, { ...i, className: "label-container", children: [
561
- /* @__PURE__ */ b(f, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
562
- /* @__PURE__ */ n(ce, { component: "h2", variant: "h6", children: "Manage labels" }),
563
- /* @__PURE__ */ n(
564
- B,
474
+ return /* @__PURE__ */ C(f, { ...s, className: "label-container", children: [
475
+ /* @__PURE__ */ C(f, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
476
+ /* @__PURE__ */ r(oe, { component: "h2", variant: "h6", children: "Manage labels" }),
477
+ /* @__PURE__ */ r(
478
+ O,
565
479
  {
566
480
  color: "primary",
567
481
  variant: "contained",
@@ -572,155 +486,155 @@ function dt({ data: e, api: t, ...i }) {
572
486
  }
573
487
  )
574
488
  ] }),
575
- /* @__PURE__ */ b(f, { sx: { mt: 2, border: 1, borderColor: "grey.300", borderRadius: 1, overflow: "hidden" }, children: [
576
- /* @__PURE__ */ b(f, { sx: { p: 2, fontSize: 14, fontWeight: "bold", bgcolor: "grey.200" }, className: "label-header", children: [
577
- x.length,
489
+ /* @__PURE__ */ C(f, { sx: { mt: 2, border: 1, borderColor: "grey.300", borderRadius: 1, overflow: "hidden" }, children: [
490
+ /* @__PURE__ */ C(f, { sx: { p: 2, fontSize: 14, fontWeight: "bold", bgcolor: "grey.200" }, className: "label-header", children: [
491
+ y.length,
578
492
  " labels"
579
493
  ] }),
580
- /* @__PURE__ */ n(f, { sx: { pt: 0.5 }, children: /* @__PURE__ */ n(Re, { data: g, selected: [], renderItem: I, rowHeight: 64 }) })
494
+ /* @__PURE__ */ r(f, { sx: { pt: 0.5 }, children: /* @__PURE__ */ r(Me, { data: b, selected: [], renderItem: I, rowHeight: 64 }) })
581
495
  ] }),
582
- /* @__PURE__ */ n(
583
- Fe,
496
+ /* @__PURE__ */ r(
497
+ je,
584
498
  {
585
- open: !!o,
586
- onClose: () => l(null),
587
- initialLabel: o,
588
- onSubmit: w
499
+ open: !!l,
500
+ onClose: () => o(null),
501
+ initialLabel: l,
502
+ onSubmit: S
589
503
  },
590
- o == null ? void 0 : o.id
504
+ l == null ? void 0 : l.id
591
505
  ),
592
- /* @__PURE__ */ n(
593
- We,
506
+ /* @__PURE__ */ r(
507
+ De,
594
508
  {
595
- open: !!r,
509
+ open: !!n,
596
510
  onClose: () => a(null),
597
- label: r,
598
- onSubmit: p
511
+ label: n,
512
+ onSubmit: h
599
513
  },
600
- r == null ? void 0 : r.id
514
+ n == null ? void 0 : n.id
601
515
  )
602
516
  ] });
603
517
  }
604
- const G = $({}), U = () => q(G), ut = () => {
605
- const { updateLabels: e } = U();
606
- F(() => () => {
518
+ const K = V({}), Q = () => q(K), st = () => {
519
+ const { updateLabels: e } = Q();
520
+ M(() => () => {
607
521
  e();
608
522
  }, []);
609
523
  };
610
- function ht({ fetchLabels: e, children: t }) {
611
- const { locale: i } = Q(), [o, l] = A({
524
+ function it({ fetchLabels: e, children: t }) {
525
+ const { locale: s } = ye(), [l, o] = A({
612
526
  loading: !0,
613
527
  labels: [],
614
528
  updateCounter: 1
615
529
  });
616
- F(() => {
530
+ M(() => {
617
531
  (async () => {
618
532
  try {
619
- l((w) => ({ ...w, loading: !0 }));
620
- const s = await e();
621
- l((w) => ({ ...w, loading: !1, labels: Ne(s) }));
622
- } catch (s) {
623
- console.error(s), l((w) => ({ ...w, loading: !1, labels: [] }));
533
+ o((S) => ({ ...S, loading: !0 }));
534
+ const i = await e();
535
+ o((S) => ({ ...S, loading: !1, labels: ke(i) }));
536
+ } catch (i) {
537
+ console.error(i), o((S) => ({ ...S, loading: !1, labels: [] }));
624
538
  }
625
539
  })();
626
- }, [o.updateCounter]);
627
- const r = N(() => {
628
- var s;
629
- return (s = o.labels) != null && s.length ? P(o.labels).reduce((w, p) => ({ ...w, [p.id]: p }), {}) : {};
630
- }, [o.labels]), a = k(
540
+ }, [l.updateCounter]);
541
+ const n = N(() => {
542
+ var i;
543
+ return (i = l.labels) != null && i.length ? B(l.labels).reduce((S, h) => ({ ...S, [h.id]: h }), {}) : {};
544
+ }, [l.labels]), a = k(
631
545
  (c) => {
632
- var s;
546
+ var i;
633
547
  return {
634
548
  ...c,
635
- name: ((s = c.translation) == null ? void 0 : s[i]) || c.name
549
+ name: ((i = c.translation) == null ? void 0 : i[s]) || c.name
636
550
  };
637
551
  },
638
- [i]
639
- ), d = k(
640
- (c) => c.filter(Boolean).map((s) => r[s]).map(a),
641
- [r, a]
642
- ), h = k((c) => {
643
- let { parent: s } = c;
644
- const w = [];
645
- for (; s; )
646
- w.unshift(s), s = s.parent;
647
- return w;
648
- }, []), x = k(
649
- (c) => [...h(c), c].map(a).map((w) => w.name).join(" / "),
650
- [a, h]
651
- ), g = k((c) => (c == null ? void 0 : c.split(",")) || [], []), m = k((c = []) => {
552
+ [s]
553
+ ), u = k(
554
+ (c) => c.filter(Boolean).map((i) => n[i]).map(a),
555
+ [n, a]
556
+ ), p = k((c) => {
557
+ let { parent: i } = c;
558
+ const S = [];
559
+ for (; i; )
560
+ S.unshift(i), i = i.parent;
561
+ return S;
562
+ }, []), y = k(
563
+ (c) => [...p(c), c].map(a).map((S) => S.name).join(" / "),
564
+ [a, p]
565
+ ), b = k((c) => (c == null ? void 0 : c.split(",")) || [], []), m = k((c = []) => {
652
566
  if (c != null && c.length)
653
567
  return c.join(",");
654
- }, []), y = N(() => o.labels.map(a), [o.labels, a]), z = N(() => ({
655
- loading: o.loading,
656
- labels: o.labels || [],
657
- updateLabels: () => l((c) => ({ ...c, updateCounter: ++o.updateCounter })),
658
- getLabelsById: d,
659
- parseLabelIds: g,
568
+ }, []), x = N(() => l.labels.map(a), [l.labels, a]), z = N(() => ({
569
+ loading: l.loading,
570
+ labels: l.labels || [],
571
+ updateLabels: () => o((c) => ({ ...c, updateCounter: ++l.updateCounter })),
572
+ getLabelsById: u,
573
+ parseLabelIds: b,
660
574
  stringifyLabelIds: m,
661
- localizedLabels: y,
662
- flattenedLabels: P(y || []),
663
- getFullLabelName: x
664
- }), [o, d, g, m, y, x]);
665
- return /* @__PURE__ */ n(G.Provider, { value: z, children: t });
575
+ localizedLabels: x,
576
+ flattenedLabels: B(x || []),
577
+ getFullLabelName: y
578
+ }), [l, u, b, m, x, y]);
579
+ return /* @__PURE__ */ r(K.Provider, { value: z, children: t });
666
580
  }
667
- const $e = (e) => {
581
+ const Fe = (e) => {
668
582
  try {
669
- return ge(e, "#fff") > 3.5 ? "#fff" : "#111";
583
+ return me(e, "#fff") > 3.5 ? "#fff" : "#111";
670
584
  } catch {
671
585
  return "#111";
672
586
  }
673
- }, qe = (e, t) => {
587
+ }, We = (e, t) => {
674
588
  try {
675
589
  if (e)
676
- return xe(e, t);
590
+ return ge(e, t);
677
591
  } catch {
678
592
  return e;
679
593
  }
680
594
  };
681
- function pt({ labels: e, editable: t, onChange: i, sx: o, renderLabel: l }) {
682
- const r = !(e != null && e.length), { labels: a, loading: d, getLabelsById: h, getFullLabelName: x } = U(), [g, m] = A(!1);
683
- if (d || !t && r)
595
+ function ct({ labels: e, editable: t, onChange: s, sx: l, renderLabel: o }) {
596
+ const n = !(e != null && e.length), { labels: a, loading: u, getLabelsById: p, getFullLabelName: y } = Q(), [b, m] = A(!1);
597
+ if (u || !t && n)
684
598
  return null;
685
- const y = (s) => {
686
- i == null || i(s), setTimeout(() => {
599
+ const x = (i) => {
600
+ s == null || s(i), setTimeout(() => {
687
601
  m(!1);
688
602
  }, 300);
689
603
  };
690
- if (g)
691
- return /* @__PURE__ */ n(pe, { onClickAway: () => g && m(!1), children: /* @__PURE__ */ n("div", { children: /* @__PURE__ */ n(Pe, { data: a, value: e || [], onChange: y }) }) });
692
- const z = h(e || []), c = [
604
+ if (b)
605
+ return /* @__PURE__ */ r(de, { onClickAway: () => b && m(!1), children: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(Oe, { data: a, value: e || [], onChange: x }) }) });
606
+ const z = p(e || []), c = [
693
607
  { display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
694
- ...Array.isArray(o) ? o : [o]
608
+ ...Array.isArray(l) ? l : [l]
695
609
  ];
696
- return /* @__PURE__ */ b(O, { sx: c, children: [
697
- z.map((s) => s ? l ? l(s) : /* @__PURE__ */ n(
698
- fe,
610
+ return /* @__PURE__ */ C(ue, { sx: c, children: [
611
+ z.map((i) => i ? o ? o(i) : /* @__PURE__ */ r(
612
+ he,
699
613
  {
700
- label: x(s),
614
+ label: y(i),
701
615
  variant: "filled",
702
616
  size: "small",
703
617
  sx: {
704
618
  height: 20,
705
619
  borderRadius: 1,
706
620
  fontSize: 12,
707
- bgcolor: qe(s.color, 0.8),
708
- color: $e(s.color)
621
+ bgcolor: We(i.color, 0.8),
622
+ color: Fe(i.color)
709
623
  }
710
624
  },
711
- s.id
625
+ i.id
712
626
  ) : null),
713
- t && !r && /* @__PURE__ */ n(K, { color: "inherit", size: "small", onClick: () => m(!0), sx: { color: "grey.400" }, children: /* @__PURE__ */ n(re, { sx: { fontSize: 20 } }) }),
714
- t && r && /* @__PURE__ */ n(me, { color: "inherit", variant: "outlined", startIcon: /* @__PURE__ */ n(oe, {}), onClick: () => m(!0), children: "Edit labels" })
627
+ t && !n && /* @__PURE__ */ r(pe, { color: "inherit", size: "small", onClick: () => m(!0), sx: { color: "grey.400" }, children: /* @__PURE__ */ r(Y, { sx: { fontSize: 20 } }) }),
628
+ t && n && /* @__PURE__ */ r(fe, { color: "inherit", variant: "outlined", startIcon: /* @__PURE__ */ r(X, {}), onClick: () => m(!0), children: "Edit labels" })
715
629
  ] });
716
630
  }
717
631
  export {
718
- dt as LabelManager,
719
- Pe as LabelPicker,
720
- W as LabelTree,
721
- pt as Labels,
722
- ht as LabelsProvider,
723
- Ne as transformLabels,
724
- U as useLabelsContext,
725
- ut as useLabelsUpdateOnDestroy
632
+ at as LabelManager,
633
+ Oe as LabelPicker,
634
+ F as LabelTree,
635
+ ct as Labels,
636
+ it as LabelsProvider,
637
+ ke as transformLabels,
638
+ Q as useLabelsContext,
639
+ st as useLabelsUpdateOnDestroy
726
640
  };
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(p,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("@mui/icons-material"),require("@mui/material/Box"),require("@mui/material/styles"),require("react-arborist"),require("@iconify/react"),require("lodash/omit"),require("react-select"),require("@mui/material/Typography"),require("@mui/material/Button"),require("@mui/material/IconButton"),require("@mui/material/TextField"),require("@mui/material/ClickAwayListener"),require("react-color"),require("@arcblock/ux/lib/Dialog"),require("@mui/material"),require("@mui/material/Popover"),require("@arcblock/ux/lib/Locale/context"),require("@mui/material/Alert")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@mui/icons-material","@mui/material/Box","@mui/material/styles","react-arborist","@iconify/react","lodash/omit","react-select","@mui/material/Typography","@mui/material/Button","@mui/material/IconButton","@mui/material/TextField","@mui/material/ClickAwayListener","react-color","@arcblock/ux/lib/Dialog","@mui/material","@mui/material/Popover","@arcblock/ux/lib/Locale/context","@mui/material/Alert"],e):(p=typeof globalThis<"u"?globalThis:p||self,e(p.DiscussKitComponents={},p.jsxRuntime,p.React,p.iconsMaterial,p.Box,p.styles,p.reactArborist,p.react$1,p.omit,p.Select,p.Typography,p.Button,p.IconButton,p.TextField,p.ClickAwayListener,p.reactColor,p.Dialog,p.material,p.Popover,p.context,p.Alert))})(this,function(p,e,h,A,y,j,Q,U,Y,E,Z,L,M,F,G,X,W,k,B,V,R){"use strict";const ee=r=>e.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:e.jsx("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"})}),re=r=>e.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:e.jsx("path",{fill:"currentColor",d:"m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z"})}),H=h.createContext({});function te({selectable:r=!1,selected:t=[],onSelect:a,renderItem:o,children:s}){const n=f=>t.indexOf(f)!==-1,l=f=>{Array.from(new Set(t).add(f)),a==null||a(f)},d=h.useMemo(()=>({selectable:r,selected:t,isSelected:n,select:l,renderItem:o}),[t]);return e.jsx(H.Provider,{value:d,children:s})}const ne=r=>{var t;return r.isLeaf||!((t=r.data.children)!=null&&t.length)};function oe({node:r}){return ne(r)?e.jsx("span",{}):r.isOpen?e.jsx(A.ExpandMore,{style:{fontSize:20}}):e.jsx(A.ExpandMore,{style:{fontSize:20,transform:"rotate(-90deg)"}})}function se({node:r,style:t,dragHandle:a}){const{selectable:o,select:s,isSelected:n,renderItem:l}=h.useContext(H),{data:d}=r,f=d.icon?e.jsx(U.Icon,{icon:d.icon,style:{fontSize:18}}):e.jsx(ee,{style:{fontSize:18,color:d.color||"#ddd"}}),x=b=>{b.stopPropagation(),r.isInternal&&r.toggle()},C=b=>{b.stopPropagation(),o&&s(r.id)},m=e.jsxs(e.Fragment,{children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",flex:1},children:[e.jsx(y,{sx:{display:"flex",cursor:"pointer"},onClick:x,children:e.jsx(oe,{node:r})}),e.jsx(y,{sx:{display:"flex",alignItems:"center",width:22,height:22},children:f}),e.jsx(y,{component:"span",sx:{color:"grey.700"},children:r.data.name})]}),o&&n(r.id)&&e.jsx(re,{})]});return e.jsxs(y,{className:"label-tree-item",style:t,sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},ref:a,onClick:C,children:[!l&&m,!!l&&l(m,r.data)]})}const le=j.styled(y)`
1
+ (function(f,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("@mui/icons-material"),require("@mui/material/Box"),require("@mui/material/styles"),require("react-arborist"),require("@iconify/react"),require("lodash/omit"),require("react-select"),require("@mui/material/Typography"),require("@mui/material/Button"),require("@mui/material/IconButton"),require("@blocklet/translation-input"),require("@mui/material/TextField"),require("@mui/material/ClickAwayListener"),require("react-color"),require("@arcblock/ux/lib/Dialog"),require("@mui/material/Alert"),require("@mui/material"),require("@arcblock/ux/lib/Locale/context")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@mui/icons-material","@mui/material/Box","@mui/material/styles","react-arborist","@iconify/react","lodash/omit","react-select","@mui/material/Typography","@mui/material/Button","@mui/material/IconButton","@blocklet/translation-input","@mui/material/TextField","@mui/material/ClickAwayListener","react-color","@arcblock/ux/lib/Dialog","@mui/material/Alert","@mui/material","@arcblock/ux/lib/Locale/context"],e):(f=typeof globalThis<"u"?globalThis:f||self,e(f.DiscussKitComponents={},f.jsxRuntime,f.React,f.iconsMaterial,f.Box,f.styles,f.reactArborist,f.react$1,f.omit,f.Select,f.Typography,f.Button,f.IconButton,f.translationInput,f.TextField,f.ClickAwayListener,f.reactColor,f.Dialog,f.Alert,f.material,f.context))})(this,function(f,e,h,T,y,j,Q,U,Z,E,G,L,M,W,D,Y,X,V,B,A,R){"use strict";const ee=r=>e.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:e.jsx("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"})}),re=r=>e.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:e.jsx("path",{fill:"currentColor",d:"m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z"})}),J=h.createContext({});function te({selectable:r=!1,selected:t=[],onSelect:a,renderItem:s,children:o}){const n=g=>t.indexOf(g)!==-1,l=g=>{Array.from(new Set(t).add(g)),a==null||a(g)},u=h.useMemo(()=>({selectable:r,selected:t,isSelected:n,select:l,renderItem:s}),[t]);return e.jsx(J.Provider,{value:u,children:o})}const ne=r=>{var t;return r.isLeaf||!((t=r.data.children)!=null&&t.length)};function se({node:r}){return ne(r)?e.jsx("span",{}):r.isOpen?e.jsx(T.ExpandMore,{style:{fontSize:20}}):e.jsx(T.ExpandMore,{style:{fontSize:20,transform:"rotate(-90deg)"}})}function oe({node:r,style:t,dragHandle:a}){const{selectable:s,select:o,isSelected:n,renderItem:l}=h.useContext(J),{data:u}=r,g=u.icon?e.jsx(U.Icon,{icon:u.icon,style:{fontSize:18}}):e.jsx(ee,{style:{fontSize:18,color:u.color||"#ddd"}}),b=x=>{x.stopPropagation(),r.isInternal&&r.toggle()},S=x=>{x.stopPropagation(),s&&o(r.id)},m=e.jsxs(e.Fragment,{children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",flex:1},children:[e.jsx(y,{sx:{display:"flex",cursor:"pointer"},onClick:b,children:e.jsx(se,{node:r})}),e.jsx(y,{sx:{display:"flex",alignItems:"center",width:22,height:22},children:g}),e.jsx(y,{component:"span",sx:{color:"grey.700"},children:r.data.name})]}),s&&n(r.id)&&e.jsx(re,{})]});return e.jsxs(y,{className:"label-tree-item",style:t,sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},ref:a,onClick:S,children:[!l&&m,!!l&&l(m,r.data)]})}const le=j.styled(y)`
2
2
  > div,
3
3
  > div > div,
4
4
  > div > div > div {
@@ -11,7 +11,7 @@
11
11
  .label-tree-item {
12
12
  width: 100%;
13
13
  }
14
- `;function O({data:r,selectable:t,selected:a=[],onSelect:o,rowHeight:s=28,renderItem:n,sx:l,...d}){const f=h.useRef(),x=[...Array.isArray(l)?l:[l]],[C,m]=h.useState(0),b=h.useCallback(()=>{var c,i;m((((i=(c=f.current)==null?void 0:c.visibleNodes)==null?void 0:i.length)||0)*s)},[s]);h.useEffect(()=>{b()},[r,b]);const T=()=>{setTimeout(b)};return e.jsx(te,{selectable:t,selected:a,onSelect:o,renderItem:n,children:e.jsx(le,{...d,sx:x,children:e.jsx(Q.Tree,{data:r,rowHeight:s,height:C,indent:32,ref:f,onToggle:T,children:se})})})}const q=r=>r.reduce((t,a)=>{var o;return t.push(a),(o=a.children)!=null&&o.length&&t.push(...q(a.children)),t},[]),J=r=>r.map(t=>{var a;return(a=t.children)!=null&&a.length&&(t.children=J(t.children)),t}),ae=(r,t=null)=>{try{return JSON.parse(r)}catch{return t}},_=r=>{const t=r.reduce((s,n)=>(s[n.id]=s[n.id]||{},n.parentId&&(s[n.id].parent=n.parentId,s[n.parentId]=s[n.parentId]||{},s[n.parentId].children=s[n.parentId].children||[],s[n.parentId].children.push(n.id)),s),{}),a=r.map(({parentId:s,translation:n,...l})=>({...l,translation:ae(n),children:[]})),o=a.reduce((s,n)=>({...s,[n.id]:n}),{});return a.forEach(s=>{const n=t[s.id];n.parent&&o[n.parent]&&(s.parent=o[n.parent]),n.children&&(s.children=n.children.map(l=>o[l]))}),a.filter(s=>!s.parent)},ie=r=>{const{options:t,getValue:a,selectProps:o,selectOption:s}=r,n=a(),l=d=>{const f=t.find(x=>x.data.id===d);f&&s(f)};return e.jsxs(e.Fragment,{children:[e.jsx(E.components.MenuList,{...Y(r,["addon"]),children:e.jsx(y,{sx:{px:2,py:1},children:e.jsx(O,{data:o.data,selectable:!0,onSelect:l,selected:n.map(d=>d.data.id)})})}),r.addon]})},ce=({children:r,...t})=>{const[a,o]=r,s=Array.isArray(a)?a.length:0;return e.jsxs(E.components.ValueContainer,{...t,children:[e.jsx(y,{component:"span",sx:{fontSize:13,fontWeight:"bold"},children:s?"Labels":"Filter by labels"}),!!s&&e.jsx(y,{sx:{display:"inline-flex",justifyContent:"center",alignItems:"center",width:22,height:22,ml:1,borderRadius:"100%",fontSize:12,bgcolor:"grey.200"},children:s}),o]})},de={control:r=>({...r,minHeight:31}),valueContainer:r=>({...r,display:"flex"}),dropdownIndicator:r=>({...r,padding:"0 4px"}),clearIndicator:r=>({...r,padding:"4px"})};function K({data:r,value:t=[],editable:a=!1,addon:o,onChange:s,compact:n,isMulti:l=!0,maxHeight:d=264,...f}){const x=h.useRef(null),C=h.useMemo(()=>q(r).map(g=>({data:g,label:g.name,value:g.id})),[r]),m=C.reduce((g,z)=>({...g,[z.data.id]:z}),{}),b=Array.isArray(t)?t:[t],T=b.map(g=>m[g]),c=h.useRef({prev:b.map(g=>{var z;return((z=m[g])==null?void 0:z.data)||""})}),i=(g,z)=>{!l||!Array.isArray(g)?s(g?[g.data]:[]):c.current.current=g.map(u=>u.data),["clear","remove-value"].includes(z.action)&&x.current&&setTimeout(()=>{var u;return(u=x==null?void 0:x.current)==null?void 0:u.blur()},1)},w=()=>{c.current.current&&JSON.stringify(c.current.prev.map(z=>z.id))!==JSON.stringify(c.current.current.map(z=>z.id))&&(s(c.current.current),c.current.prev=c.current.current)};return e.jsx(y,{...f,children:e.jsx(E,{ref:x,defaultValue:T,options:C,onChange:i,components:{MenuList:g=>e.jsx(ie,{...g,addon:o}),...n&&{ValueContainer:ce}},placeholder:"Select labels",styles:{...n&&de,menu:g=>({...g,...a&&{paddingBottom:"36px"},zIndex:99}),menuList:g=>({...g,overflowY:"auto",maxHeight:`${d}px`})},theme:g=>({...g,colors:{...g.colors,primary25:"#ddd",primary50:"#ddd",primary:"#ddd"}}),isSearchable:!1,isMulti:l,closeMenuOnSelect:!l,onMenuClose:w,isClearable:!0,data:r})})}var P=function(){return P=Object.assign||function(t){for(var a,o=1,s=arguments.length;o<s;o++){a=arguments[o];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},P.apply(this,arguments)};function ue(r,t){var a=typeof Symbol=="function"&&r[Symbol.iterator];if(!a)return r;var o=a.call(r),s,n=[],l;try{for(;(t===void 0||t-- >0)&&!(s=o.next()).done;)n.push(s.value)}catch(d){l={error:d}}finally{try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(l)throw l.error}}return n}typeof SuppressedError=="function"&&SuppressedError;var he=function(r){return typeof r=="function"},pe=function(r){var t=ue(h.useState(r),2),a=t[0],o=t[1],s=h.useCallback(function(n){o(function(l){var d=he(n)?n(l):n;return d?P(P({},l),d):l})},[]);return[a,s]};const fe=pe;function ge({I18NProps:r,...t}){const{languages:a}=V.useLocaleContext(),{translation:o,onChange:s}=r,[n,l]=h.useState(null),d=C=>{const m=C.currentTarget.closest(".MuiInputBase-root");m&&l(m)},f=()=>{l(null)},x=a.filter(C=>C.code!=="en");return e.jsx(k.TextField,{...t,InputProps:{endAdornment:e.jsxs(k.InputAdornment,{position:"end",children:[e.jsx(k.IconButton,{edge:"end",onClick:d,children:e.jsx(A.Translate,{})}),e.jsx(B,{open:!!n,anchorEl:n,onClose:f,transformOrigin:{vertical:"top",horizontal:"right"},anchorOrigin:{vertical:"bottom",horizontal:"right"},PaperProps:{sx:{width:n==null?void 0:n.clientWidth,maxHeight:200,overflowY:"auto",bgcolor:"grey.50"}},elevation:1,sx:{mt:2},children:e.jsx(k.Box,{sx:{p:2},children:x.map(({code:C,name:m})=>e.jsxs(k.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between","& + &":{mt:1}},children:[e.jsx(k.Box,{sx:{flex:"0 0 120px"},children:m}),e.jsx(k.Box,{sx:{flex:1},children:e.jsx(k.TextField,{value:o[C]||"",size:"small",sx:{width:1},onChange:b=>s({...o,[C]:b.target.value})})})]},C))})})]})}})}function ye({open:r,initialLabel:t,onSubmit:a,onClose:o,...s}){const n=!(t!=null&&t.id),[l,d]=fe({name:(t==null?void 0:t.name)||"",color:(t==null?void 0:t.color)||"#ddd",slug:(t==null?void 0:t.id)||"",translation:(t==null?void 0:t.translation)||{}}),f=i=>/^#([0-9A-F]{3}){1,2}$/i.test(i),x=h.useMemo(()=>n?l.name&&l.color&&l.slug&&f(l.color):l.name&&l.color&&f(l.color),[l,n]),[C,m]=h.useState(!1),b=()=>{a({...t,name:l.name,color:l.color,id:l.slug,translation:l.translation})},T=i=>{d({color:i.hex}),setTimeout(()=>m(!1))},c=i=>{d({color:i.target.value})};return e.jsx(W,{open:r,showCloseButton:!0,maxWidth:"lg",title:n?"Create label":"Edit label",actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{color:"inherit",variant:"contained",size:"small",onClick:o,children:"Cancel"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",onClick:b,disabled:!x,children:n?"Create":"Save Changes"})]}),onClose:o,...s,children:e.jsxs(y,{width:600,minHeight:280,children:[e.jsx(ge,{label:"Name",value:l.name,placeholder:"New label",size:"small",fullWidth:!0,onChange:i=>d({name:i.target.value}),I18NProps:{translation:l.translation,onChange:i=>d({translation:i})}}),e.jsx(F,{label:"Slug",value:l.slug,size:"small",fullWidth:!0,disabled:!n,onChange:i=>d({slug:i.target.value}),sx:{mt:2}}),(t==null?void 0:t.parent)&&e.jsx(F,{label:"Parent",value:t.parent.name,size:"small",fullWidth:!0,disabled:!0,sx:{mt:2}}),e.jsx(G,{onClickAway:()=>m(!1),children:e.jsxs(y,{sx:{position:"relative",mt:2},children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(y,{sx:{width:30,height:30,bgcolor:l.color,borderRadius:1},onClick:()=>m(!0)}),e.jsx(F,{label:"",value:l.color,size:"small",onChange:c,inputProps:{maxLength:7},sx:{width:100,".MuiInputBase-root":{height:32}}})]}),C&&e.jsx(y,{sx:{position:"absolute",top:48,zIndex:1},children:e.jsx(X.GithubPicker,{color:l.color,onChangeComplete:T})})]})})]})})}function me({open:r,label:t,onSubmit:a,onClose:o,...s}){return e.jsx(W,{open:r,showCloseButton:!0,maxWidth:"md",title:"Delete",actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{color:"inherit",variant:"contained",size:"small",onClick:o,children:"Cancel"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",onClick:a,children:"Delete"})]}),onClose:o,...s,children:e.jsxs(y,{width:600,minHeight:280,children:[e.jsx(R,{severity:"info",sx:{mb:2},children:"Are you sure you want to delete these labels ?"}),e.jsx(O,{data:[t]})]})})}const Ce=j.styled(O)`
14
+ `;function O({data:r,selectable:t,selected:a=[],onSelect:s,rowHeight:o=28,renderItem:n,sx:l,...u}){const g=h.useRef(),b=[...Array.isArray(l)?l:[l]],[S,m]=h.useState(0),x=h.useCallback(()=>{var c,i;m((((i=(c=g.current)==null?void 0:c.visibleNodes)==null?void 0:i.length)||0)*o)},[o]);h.useEffect(()=>{x()},[r,x]);const I=()=>{setTimeout(x)};return e.jsx(te,{selectable:t,selected:a,onSelect:s,renderItem:n,children:e.jsx(le,{...u,sx:b,children:e.jsx(Q.Tree,{data:r,rowHeight:o,height:S,indent:32,ref:g,onToggle:I,children:oe})})})}const q=r=>r.reduce((t,a)=>{var s;return t.push(a),(s=a.children)!=null&&s.length&&t.push(...q(a.children)),t},[]),_=r=>r.map(t=>{var a;return(a=t.children)!=null&&a.length&&(t.children=_(t.children)),t}),ae=(r,t=null)=>{try{return JSON.parse(r)}catch{return t}},H=r=>{const t=r.reduce((o,n)=>(o[n.id]=o[n.id]||{},n.parentId&&(o[n.id].parent=n.parentId,o[n.parentId]=o[n.parentId]||{},o[n.parentId].children=o[n.parentId].children||[],o[n.parentId].children.push(n.id)),o),{}),a=r.map(({parentId:o,translation:n,...l})=>({...l,translation:ae(n),children:[]})),s=a.reduce((o,n)=>({...o,[n.id]:n}),{});return a.forEach(o=>{const n=t[o.id];n.parent&&s[n.parent]&&(o.parent=s[n.parent]),n.children&&(o.children=n.children.map(l=>s[l]))}),a.filter(o=>!o.parent)},ie=r=>{const{options:t,getValue:a,selectProps:s,selectOption:o}=r,n=a(),l=u=>{const g=t.find(b=>b.data.id===u);g&&o(g)};return e.jsxs(e.Fragment,{children:[e.jsx(E.components.MenuList,{...Z(r,["addon"]),children:e.jsx(y,{sx:{px:2,py:1},children:e.jsx(O,{data:s.data,selectable:!0,onSelect:l,selected:n.map(u=>u.data.id)})})}),r.addon]})},ce=({children:r,...t})=>{const[a,s]=r,o=Array.isArray(a)?a.length:0;return e.jsxs(E.components.ValueContainer,{...t,children:[e.jsx(y,{component:"span",sx:{fontSize:13,fontWeight:"bold"},children:o?"Labels":"Filter by labels"}),!!o&&e.jsx(y,{sx:{display:"inline-flex",justifyContent:"center",alignItems:"center",width:22,height:22,ml:1,borderRadius:"100%",fontSize:12,bgcolor:"grey.200"},children:o}),s]})},de={control:r=>({...r,minHeight:31}),valueContainer:r=>({...r,display:"flex"}),dropdownIndicator:r=>({...r,padding:"0 4px"}),clearIndicator:r=>({...r,padding:"4px"})};function K({data:r,value:t=[],editable:a=!1,addon:s,onChange:o,compact:n,isMulti:l=!0,maxHeight:u=264,...g}){const b=h.useRef(null),S=h.useMemo(()=>q(r).map(p=>({data:p,label:p.name,value:p.id})),[r]),m=S.reduce((p,z)=>({...p,[z.data.id]:z}),{}),x=Array.isArray(t)?t:[t],I=x.map(p=>m[p]),c=h.useRef({prev:x.map(p=>{var z;return((z=m[p])==null?void 0:z.data)||""})}),i=(p,z)=>{!l||!Array.isArray(p)?o(p?[p.data]:[]):c.current.current=p.map(d=>d.data),["clear","remove-value"].includes(z.action)&&b.current&&setTimeout(()=>{var d;return(d=b==null?void 0:b.current)==null?void 0:d.blur()},1)},w=()=>{c.current.current&&JSON.stringify(c.current.prev.map(z=>z.id))!==JSON.stringify(c.current.current.map(z=>z.id))&&(o(c.current.current),c.current.prev=c.current.current)};return e.jsx(y,{...g,children:e.jsx(E,{ref:b,defaultValue:I,options:S,onChange:i,components:{MenuList:p=>e.jsx(ie,{...p,addon:s}),...n&&{ValueContainer:ce}},placeholder:"Select labels",styles:{...n&&de,menu:p=>({...p,...a&&{paddingBottom:"36px"},zIndex:99}),menuList:p=>({...p,overflowY:"auto",maxHeight:`${u}px`})},theme:p=>({...p,colors:{...p.colors,primary25:"#ddd",primary50:"#ddd",primary:"#ddd"}}),isSearchable:!1,isMulti:l,closeMenuOnSelect:!l,onMenuClose:w,isClearable:!0,data:r})})}var P=function(){return P=Object.assign||function(t){for(var a,s=1,o=arguments.length;s<o;s++){a=arguments[s];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},P.apply(this,arguments)};function ue(r,t){var a=typeof Symbol=="function"&&r[Symbol.iterator];if(!a)return r;var s=a.call(r),o,n=[],l;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(u){l={error:u}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(l)throw l.error}}return n}typeof SuppressedError=="function"&&SuppressedError;var he=function(r){return typeof r=="function"},fe=function(r){var t=ue(h.useState(r),2),a=t[0],s=t[1],o=h.useCallback(function(n){s(function(l){var u=he(n)?n(l):n;return u?P(P({},l),u):l})},[]);return[a,o]};const pe=fe;function ge({open:r,initialLabel:t,onSubmit:a,onClose:s,...o}){const n=!(t!=null&&t.id),[l,u]=pe({name:(t==null?void 0:t.name)||"",color:(t==null?void 0:t.color)||"#ddd",slug:(t==null?void 0:t.id)||"",translation:(t==null?void 0:t.translation)||{}}),g=i=>/^#([0-9A-F]{3}){1,2}$/i.test(i),b=h.useMemo(()=>n?l.name&&l.color&&l.slug&&g(l.color):l.name&&l.color&&g(l.color),[l,n]),[S,m]=h.useState(!1),x=()=>{a({...t,name:l.name,color:l.color,id:l.slug,translation:l.translation})},I=i=>{u({color:i.hex}),setTimeout(()=>m(!1))},c=i=>{u({color:i.target.value})};return e.jsx(V,{open:r,showCloseButton:!0,maxWidth:"lg",title:n?"Create label":"Edit label",actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{color:"inherit",variant:"contained",size:"small",onClick:s,children:"Cancel"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",onClick:x,disabled:!b,children:n?"Create":"Save Changes"})]}),onClose:s,...o,children:e.jsxs(y,{width:600,minHeight:320,children:[e.jsx(W.TranslationTextField,{label:"Name",value:l.name,placeholder:"New label",size:"small",fullWidth:!0,onChange:i=>u({name:i.target.value}),translationInputProps:{value:l.translation,onChange:i=>u({translation:i})}}),e.jsx(D,{label:"Slug",value:l.slug,size:"small",fullWidth:!0,disabled:!n,onChange:i=>u({slug:i.target.value}),sx:{mt:2}}),(t==null?void 0:t.parent)&&e.jsx(D,{label:"Parent",value:t.parent.name,size:"small",fullWidth:!0,disabled:!0,sx:{mt:2}}),e.jsx(Y,{onClickAway:()=>m(!1),children:e.jsxs(y,{sx:{position:"relative",mt:2},children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(y,{sx:{width:30,height:30,bgcolor:l.color,borderRadius:1},onClick:()=>m(!0)}),e.jsx(D,{label:"",value:l.color,size:"small",onChange:c,inputProps:{maxLength:7},sx:{width:100,".MuiInputBase-root":{height:32}}})]}),S&&e.jsx(y,{sx:{position:"absolute",top:48,zIndex:1},children:e.jsx(X.GithubPicker,{color:l.color,onChangeComplete:I})})]})})]})})}function ye({open:r,label:t,onSubmit:a,onClose:s,...o}){return e.jsx(V,{open:r,showCloseButton:!0,maxWidth:"md",title:"Delete",actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{color:"inherit",variant:"contained",size:"small",onClick:s,children:"Cancel"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",onClick:a,children:"Delete"})]}),onClose:s,...o,children:e.jsxs(y,{width:600,minHeight:280,children:[e.jsx(B,{severity:"info",sx:{mb:2},children:"Are you sure you want to delete these labels ?"}),e.jsx(O,{data:[t]})]})})}const me=j.styled(O)`
15
15
  .label-tree-item {
16
16
  &:before {
17
17
  content: '';
@@ -31,4 +31,4 @@
31
31
  box-sizing: border-box;
32
32
  padding: 0 16px;
33
33
  }
34
- `;function xe({locale:r,value:t}){return e.jsxs(y,{sx:{display:"flex",alignItems:"center",flex:"0 0 auto",px:1,py:.25,fontSize:12,bgcolor:"grey.300",borderRadius:2},className:"label-translation-tag",children:[e.jsx(y,{sx:{pr:.5,borderRight:1,borderColor:"grey.400"},children:r}),e.jsx(y,{sx:{pl:.5},children:t})]})}function be({data:r,api:t,...a}){const[o,s]=h.useState(null),[n,l]=h.useState(null),[d,f]=h.useState(J(r)),x=h.useMemo(()=>q(d),[d]),C=h.useMemo(()=>{const u=(v,I)=>v.map(S=>(I&&(S.parent=I),S.children&&(S.children=u(S.children,S)),S));return u(d)},[d]),m=u=>{var v,I;u.parent?(u.parent.children=(I=(v=u.parent)==null?void 0:v.children)==null?void 0:I.map(S=>S.id===u.id?{...u}:S),m(u.parent)):f(d.map(S=>S.id===u.id?{...u}:S))},b=u=>{u.parent?(u.parent.children=u.parent.children||[],u.parent.children.push(u),f([...d])):f([...d,u])},T=u=>{var v;u.parent?u.parent.children=(v=u.parent.children)==null?void 0:v.filter(I=>I.id!==u.id):f(d.filter(I=>I.id!==u.id))},c=u=>{if(o)return;s({id:"",name:"New label",parent:u,color:"#dddddd"})},i=u=>{o||s(u)},w=async u=>{if(!o)return;const{parent:v,children:I,translation:S,...N}=u;o.id?(await t.updateLabel({...N,translation:JSON.stringify(S),parentId:v==null?void 0:v.id}),m(u)):(await t.createLabel({...N,translation:JSON.stringify(S),parentId:v==null?void 0:v.id}),b(u)),s(null)},g=async()=>{n&&(await t.deleteLabel(n.id),T(n),l(null))},z=(u,v)=>e.jsxs(e.Fragment,{children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap"},className:"label-name",children:[e.jsx(y,{children:u}),v.translation&&e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:.5,ml:2},className:"label-translation",children:Object.keys(v.translation).map(I=>{var N;const S=(N=v.translation)==null?void 0:N[I];return S?e.jsx(xe,{locale:I,value:S},I):null})})]}),e.jsxs(y,{sx:{display:"flex",gap:1,flex:"0 0 auto"},className:"label-action",children:[e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>c(v),children:e.jsx(A.Add,{sx:{fontSize:20}})}),e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>i(v),children:e.jsx(A.EditOutlined,{sx:{fontSize:18}})}),e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>l(v),children:e.jsx(A.DeleteOutlineOutlined,{sx:{fontSize:20}})})]})]});return e.jsxs(y,{...a,className:"label-container",children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(Z,{component:"h2",variant:"h6",children:"Manage labels"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",sx:{textTransform:"none"},onClick:()=>c(),children:"New label"})]}),e.jsxs(y,{sx:{mt:2,border:1,borderColor:"grey.300",borderRadius:1,overflow:"hidden"},children:[e.jsxs(y,{sx:{p:2,fontSize:14,fontWeight:"bold",bgcolor:"grey.200"},className:"label-header",children:[x.length," labels"]}),e.jsx(y,{sx:{pt:.5},children:e.jsx(Ce,{data:C,selected:[],renderItem:z,rowHeight:64})})]}),e.jsx(ye,{open:!!o,onClose:()=>s(null),initialLabel:o,onSubmit:w},o==null?void 0:o.id),e.jsx(me,{open:!!n,onClose:()=>l(null),label:n,onSubmit:g},n==null?void 0:n.id)]})}const $=h.createContext({}),D=()=>h.useContext($),ve=()=>{const{updateLabels:r}=D();h.useEffect(()=>()=>{r()},[])};function Se({fetchLabels:r,children:t}){const{locale:a}=V.useLocaleContext(),[o,s]=h.useState({loading:!0,labels:[],updateCounter:1});h.useEffect(()=>{(async()=>{try{s(w=>({...w,loading:!0}));const i=await r();s(w=>({...w,loading:!1,labels:_(i)}))}catch(i){console.error(i),s(w=>({...w,loading:!1,labels:[]}))}})()},[o.updateCounter]);const n=h.useMemo(()=>{var i;return(i=o.labels)!=null&&i.length?q(o.labels).reduce((w,g)=>({...w,[g.id]:g}),{}):{}},[o.labels]),l=h.useCallback(c=>{var i;return{...c,name:((i=c.translation)==null?void 0:i[a])||c.name}},[a]),d=h.useCallback(c=>c.filter(Boolean).map(i=>n[i]).map(l),[n,l]),f=h.useCallback(c=>{let{parent:i}=c;const w=[];for(;i;)w.unshift(i),i=i.parent;return w},[]),x=h.useCallback(c=>[...f(c),c].map(l).map(w=>w.name).join(" / "),[l,f]),C=h.useCallback(c=>(c==null?void 0:c.split(","))||[],[]),m=h.useCallback((c=[])=>{if(c!=null&&c.length)return c.join(",")},[]),b=h.useMemo(()=>o.labels.map(l),[o.labels,l]),T=h.useMemo(()=>({loading:o.loading,labels:o.labels||[],updateLabels:()=>s(c=>({...c,updateCounter:++o.updateCounter})),getLabelsById:d,parseLabelIds:C,stringifyLabelIds:m,localizedLabels:b,flattenedLabels:q(b||[]),getFullLabelName:x}),[o,d,C,m,b,x]);return e.jsx($.Provider,{value:T,children:t})}const we=r=>{try{return k.getContrastRatio(r,"#fff")>3.5?"#fff":"#111"}catch{return"#111"}},ke=(r,t)=>{try{if(r)return k.alpha(r,t)}catch{return r}};function Ie({labels:r,editable:t,onChange:a,sx:o,renderLabel:s}){const n=!(r!=null&&r.length),{labels:l,loading:d,getLabelsById:f,getFullLabelName:x}=D(),[C,m]=h.useState(!1);if(d||!t&&n)return null;const b=i=>{a==null||a(i),setTimeout(()=>{m(!1)},300)};if(C)return e.jsx(k.ClickAwayListener,{onClickAway:()=>C&&m(!1),children:e.jsx("div",{children:e.jsx(K,{data:l,value:r||[],onChange:b})})});const T=f(r||[]),c=[{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},...Array.isArray(o)?o:[o]];return e.jsxs(k.Box,{sx:c,children:[T.map(i=>i?s?s(i):e.jsx(k.Chip,{label:x(i),variant:"filled",size:"small",sx:{height:20,borderRadius:1,fontSize:12,bgcolor:ke(i.color,.8),color:we(i.color)}},i.id):null),t&&!n&&e.jsx(k.IconButton,{color:"inherit",size:"small",onClick:()=>m(!0),sx:{color:"grey.400"},children:e.jsx(A.Edit,{sx:{fontSize:20}})}),t&&n&&e.jsx(k.Button,{color:"inherit",variant:"outlined",startIcon:e.jsx(A.LabelOutlined,{}),onClick:()=>m(!0),children:"Edit labels"})]})}p.LabelManager=be,p.LabelPicker=K,p.LabelTree=O,p.Labels=Ie,p.LabelsProvider=Se,p.transformLabels=_,p.useLabelsContext=D,p.useLabelsUpdateOnDestroy=ve,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
34
+ `;function Ce({data:r,api:t,...a}){const[s,o]=h.useState(null),[n,l]=h.useState(null),[u,g]=h.useState(_(r)),b=h.useMemo(()=>q(u),[u]),S=h.useMemo(()=>{const d=(C,k)=>C.map(v=>(k&&(v.parent=k),v.children&&(v.children=d(v.children,v)),v));return d(u)},[u]),m=d=>{var C,k;d.parent?(d.parent.children=(k=(C=d.parent)==null?void 0:C.children)==null?void 0:k.map(v=>v.id===d.id?{...d}:v),m(d.parent)):g(u.map(v=>v.id===d.id?{...d}:v))},x=d=>{d.parent?(d.parent.children=d.parent.children||[],d.parent.children.push(d),g([...u])):g([...u,d])},I=d=>{var C;d.parent?d.parent.children=(C=d.parent.children)==null?void 0:C.filter(k=>k.id!==d.id):g(u.filter(k=>k.id!==d.id))},c=d=>{if(s)return;o({id:"",name:"New label",parent:d,color:"#dddddd"})},i=d=>{s||o(d)},w=async d=>{if(!s)return;const{parent:C,children:k,translation:v,...N}=d;s.id?(await t.updateLabel({...N,translation:JSON.stringify(v),parentId:C==null?void 0:C.id}),m(d)):(await t.createLabel({...N,translation:JSON.stringify(v),parentId:C==null?void 0:C.id}),x(d)),o(null)},p=async()=>{n&&(await t.deleteLabel(n.id),I(n),l(null))},z=(d,C)=>e.jsxs(e.Fragment,{children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap"},className:"label-name",children:[e.jsx(y,{children:d}),C.translation&&e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:.5,ml:2},className:"label-translation",children:Object.keys(C.translation).map(k=>{var N;const v=(N=C.translation)==null?void 0:N[k];return v?e.jsx(W.TranslationTag,{locale:k,value:v},k):null})})]}),e.jsxs(y,{sx:{display:"flex",gap:1,flex:"0 0 auto"},className:"label-action",children:[e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>c(C),children:e.jsx(T.Add,{sx:{fontSize:20}})}),e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>i(C),children:e.jsx(T.EditOutlined,{sx:{fontSize:18}})}),e.jsx(M,{color:"inherit",size:"small",sx:{color:"grey.500"},onClick:()=>l(C),children:e.jsx(T.DeleteOutlineOutlined,{sx:{fontSize:20}})})]})]});return e.jsxs(y,{...a,className:"label-container",children:[e.jsxs(y,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(G,{component:"h2",variant:"h6",children:"Manage labels"}),e.jsx(L,{color:"primary",variant:"contained",size:"small",sx:{textTransform:"none"},onClick:()=>c(),children:"New label"})]}),e.jsxs(y,{sx:{mt:2,border:1,borderColor:"grey.300",borderRadius:1,overflow:"hidden"},children:[e.jsxs(y,{sx:{p:2,fontSize:14,fontWeight:"bold",bgcolor:"grey.200"},className:"label-header",children:[b.length," labels"]}),e.jsx(y,{sx:{pt:.5},children:e.jsx(me,{data:S,selected:[],renderItem:z,rowHeight:64})})]}),e.jsx(ge,{open:!!s,onClose:()=>o(null),initialLabel:s,onSubmit:w},s==null?void 0:s.id),e.jsx(ye,{open:!!n,onClose:()=>l(null),label:n,onSubmit:p},n==null?void 0:n.id)]})}const $=h.createContext({}),F=()=>h.useContext($),be=()=>{const{updateLabels:r}=F();h.useEffect(()=>()=>{r()},[])};function xe({fetchLabels:r,children:t}){const{locale:a}=R.useLocaleContext(),[s,o]=h.useState({loading:!0,labels:[],updateCounter:1});h.useEffect(()=>{(async()=>{try{o(w=>({...w,loading:!0}));const i=await r();o(w=>({...w,loading:!1,labels:H(i)}))}catch(i){console.error(i),o(w=>({...w,loading:!1,labels:[]}))}})()},[s.updateCounter]);const n=h.useMemo(()=>{var i;return(i=s.labels)!=null&&i.length?q(s.labels).reduce((w,p)=>({...w,[p.id]:p}),{}):{}},[s.labels]),l=h.useCallback(c=>{var i;return{...c,name:((i=c.translation)==null?void 0:i[a])||c.name}},[a]),u=h.useCallback(c=>c.filter(Boolean).map(i=>n[i]).map(l),[n,l]),g=h.useCallback(c=>{let{parent:i}=c;const w=[];for(;i;)w.unshift(i),i=i.parent;return w},[]),b=h.useCallback(c=>[...g(c),c].map(l).map(w=>w.name).join(" / "),[l,g]),S=h.useCallback(c=>(c==null?void 0:c.split(","))||[],[]),m=h.useCallback((c=[])=>{if(c!=null&&c.length)return c.join(",")},[]),x=h.useMemo(()=>s.labels.map(l),[s.labels,l]),I=h.useMemo(()=>({loading:s.loading,labels:s.labels||[],updateLabels:()=>o(c=>({...c,updateCounter:++s.updateCounter})),getLabelsById:u,parseLabelIds:S,stringifyLabelIds:m,localizedLabels:x,flattenedLabels:q(x||[]),getFullLabelName:b}),[s,u,S,m,x,b]);return e.jsx($.Provider,{value:I,children:t})}const ve=r=>{try{return A.getContrastRatio(r,"#fff")>3.5?"#fff":"#111"}catch{return"#111"}},Se=(r,t)=>{try{if(r)return A.alpha(r,t)}catch{return r}};function we({labels:r,editable:t,onChange:a,sx:s,renderLabel:o}){const n=!(r!=null&&r.length),{labels:l,loading:u,getLabelsById:g,getFullLabelName:b}=F(),[S,m]=h.useState(!1);if(u||!t&&n)return null;const x=i=>{a==null||a(i),setTimeout(()=>{m(!1)},300)};if(S)return e.jsx(A.ClickAwayListener,{onClickAway:()=>S&&m(!1),children:e.jsx("div",{children:e.jsx(K,{data:l,value:r||[],onChange:x})})});const I=g(r||[]),c=[{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},...Array.isArray(s)?s:[s]];return e.jsxs(A.Box,{sx:c,children:[I.map(i=>i?o?o(i):e.jsx(A.Chip,{label:b(i),variant:"filled",size:"small",sx:{height:20,borderRadius:1,fontSize:12,bgcolor:Se(i.color,.8),color:ve(i.color)}},i.id):null),t&&!n&&e.jsx(A.IconButton,{color:"inherit",size:"small",onClick:()=>m(!0),sx:{color:"grey.400"},children:e.jsx(T.Edit,{sx:{fontSize:20}})}),t&&n&&e.jsx(A.Button,{color:"inherit",variant:"outlined",startIcon:e.jsx(T.LabelOutlined,{}),onClick:()=>m(!0),children:"Edit labels"})]})}f.LabelManager=Ce,f.LabelPicker=K,f.LabelTree=O,f.Labels=we,f.LabelsProvider=xe,f.transformLabels=H,f.useLabelsContext=F,f.useLabelsUpdateOnDestroy=be,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/labels",
3
- "version": "1.5.147",
3
+ "version": "1.5.149",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -28,6 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
+ "@blocklet/translation-input": "1.5.149",
31
32
  "@emotion/css": "^11.10.5",
32
33
  "@emotion/react": "^11.10.5",
33
34
  "@emotion/styled": "^11.10.5",
@@ -75,5 +76,5 @@
75
76
  "resolutions": {
76
77
  "react": "^18.2.0"
77
78
  },
78
- "gitHead": "66b3d76d483e0887d338af824d94a0c2ec84018e"
79
+ "gitHead": "9b13303126c6633a7c668c524dd82f79f4704401"
79
80
  }
@@ -1,10 +0,0 @@
1
- import type { TextFieldProps } from '@mui/material';
2
- import type { Translation } from './types';
3
- interface Props {
4
- I18NProps: {
5
- translation: Translation;
6
- onChange: (translation: Translation) => void;
7
- };
8
- }
9
- export default function TranslationInput({ I18NProps, ...rest }: TextFieldProps & Props): import("react/jsx-runtime").JSX.Element;
10
- export {};