@blocklet/labels 1.6.182 → 1.6.183

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,1323 +1,72 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
- import { createContext, useRef, useState, useCallback, useEffect, useMemo, useContext, createElement } from "react";
9
- import { ExpandMore, Edit, LabelOutlined } from "@mui/icons-material";
10
- import Box from "@mui/material/Box";
11
- import { styled } from "@mui/material/styles";
12
- import { Tree } from "react-arborist";
13
- import { Icon } from "@iconify/react";
14
- import omit from "lodash/omit";
15
- import Select, { components } from "react-select";
16
- import { ClickAwayListener, Box as Box$1, Chip, IconButton, Button, getContrastRatio, alpha, useTheme, ButtonBase, Popper, Autocomplete, InputBase, autocompleteClasses, TextField } from "@mui/material";
17
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
18
- import { useReactive, useRequest, useSize, useDeepCompareLayoutEffect } from "ahooks";
19
- import { createContainer } from "unstated-next";
20
- import { arrayToTree } from "performant-array-to-tree";
21
- import CloseOutlineIcon from "@mui/icons-material/Close";
22
- import DoneIcon from "@mui/icons-material/Done";
23
- import chroma from "chroma-js";
24
- const materialSymbolsLabelRounded = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ 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" }) });
25
- const materialSymbolsCheckSmall = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "m10 16.4l-4-4L7.4 11l2.6 2.6L16.6 7L18 8.4Z" }) });
26
- const LabelTreeContext = createContext({});
27
- function LabelTreeProvider({
28
- selectable = false,
29
- selected = [],
30
- onSelect,
31
- renderItem,
32
- children
33
- }) {
34
- const isSelected = (id) => selected.indexOf(id) !== -1;
35
- const select = (id) => {
36
- Array.from(new Set(selected).add(id));
37
- onSelect == null ? void 0 : onSelect(id);
38
- };
39
- const value = useMemo(
40
- () => ({
41
- selectable,
42
- selected,
43
- isSelected,
44
- select,
45
- renderItem
46
- }),
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
- [selected]
49
- );
50
- return /* @__PURE__ */ jsx(LabelTreeContext.Provider, { value, children });
51
- }
52
- const isLeaf = (node) => {
53
- var _a;
54
- return node.isLeaf || !((_a = node.data.children) == null ? void 0 : _a.length);
55
- };
56
- function FolderArrow({ node }) {
57
- if (isLeaf(node))
58
- return /* @__PURE__ */ jsx("span", {});
59
- return node.isOpen ? /* @__PURE__ */ jsx(ExpandMore, { style: { fontSize: 20 } }) : /* @__PURE__ */ jsx(ExpandMore, { style: { fontSize: 20, transform: "rotate(-90deg)" } });
60
- }
61
- function Node({ node, style, dragHandle }) {
62
- const { selectable, select, isSelected, renderItem } = useContext(LabelTreeContext);
63
- const { data } = node;
64
- const icon = data.icon ? /* @__PURE__ */ jsx(Icon, { icon: data.icon, style: { fontSize: 18 } }) : /* @__PURE__ */ jsx(materialSymbolsLabelRounded, { style: { fontSize: 18, color: data.color || "#ddd" } });
65
- const handleToggle = (e) => {
66
- e.stopPropagation();
67
- if (node.isInternal) {
68
- node.toggle();
69
- }
70
- };
71
- const handleClick = (e) => {
72
- e.stopPropagation();
73
- if (selectable) {
74
- select(node.id);
75
- }
76
- };
77
- const children = /* @__PURE__ */ jsxs(Fragment, { children: [
78
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", flex: 1 }, children: [
79
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", cursor: "pointer" }, onClick: handleToggle, children: /* @__PURE__ */ jsx(FolderArrow, { node }) }),
80
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", alignItems: "center", width: 22, height: 22 }, children: icon }),
81
- /* @__PURE__ */ jsx(Box, { component: "span", sx: { color: "grey.700" }, children: node.data.name })
82
- ] }),
83
- selectable && isSelected(node.id) && /* @__PURE__ */ jsx(materialSymbolsCheckSmall, {})
84
- ] });
85
- return /* @__PURE__ */ jsxs(
86
- Box,
87
- {
88
- className: "label-tree-item",
89
- style,
90
- sx: {
91
- display: "flex",
92
- alignItems: "center",
93
- justifyContent: "space-between",
94
- color: (theme) => theme.palette.mode === "dark" ? "grey.800" : "text.primary"
95
- },
96
- ref: dragHandle,
97
- onClick: handleClick,
98
- children: [
99
- !renderItem && children,
100
- !!renderItem && renderItem(children, node.data)
101
- ]
102
- }
103
- );
104
- }
105
- const Root = styled(Box)`
106
- > div,
107
- > div > div,
108
- > div > div > div {
109
- width: auto !important;
110
- }
111
- [role='treeitem'] {
112
- display: flex;
113
- align-items: stretch;
114
- }
115
- .label-tree-item {
116
- width: 100%;
117
- }
118
- `;
119
- function LabelTree({
120
- data,
121
- selectable,
122
- selected = [],
123
- onSelect,
124
- rowHeight = 28,
125
- renderItem,
126
- sx,
127
- ...rest
128
- }) {
129
- const tree = useRef();
130
- const mergedSx = [...Array.isArray(sx) ? sx : [sx]];
131
- const [height, setHeight] = useState(0);
132
- const updateHeight = useCallback(() => {
133
- var _a, _b;
134
- setHeight((((_b = (_a = tree.current) == null ? void 0 : _a.visibleNodes) == null ? void 0 : _b.length) || 0) * rowHeight);
135
- }, [rowHeight]);
136
- useEffect(() => {
137
- updateHeight();
138
- }, [data, updateHeight]);
139
- const handleToggle = () => {
140
- setTimeout(updateHeight);
141
- };
142
- return /* @__PURE__ */ jsx(LabelTreeProvider, { selectable, selected, onSelect, renderItem, children: /* @__PURE__ */ jsx(Root, { ...rest, sx: mergedSx, children: /* @__PURE__ */ jsx(Tree, { data, rowHeight, height, indent: 32, ref: tree, onToggle: handleToggle, children: Node }) }) });
143
- }
144
- const flatten = (data) => {
145
- return data.reduce((acc, cur) => {
146
- var _a;
147
- acc.push(cur);
148
- if ((_a = cur.children) == null ? void 0 : _a.length) {
149
- acc.push(...flatten(cur.children));
150
- }
151
- return acc;
152
- }, []);
153
- };
154
- const safeParseJSON = (json, defaultValue = null) => {
155
- try {
156
- return JSON.parse(json);
157
- } catch {
158
- return defaultValue;
159
- }
160
- };
161
- const transformLabels = (labelDtos) => {
162
- const relations = labelDtos.reduce((acc, cur) => {
163
- acc[cur.id] = acc[cur.id] || {};
164
- if (cur.parentId) {
165
- acc[cur.id].parent = cur.parentId;
166
- acc[cur.parentId] = acc[cur.parentId] || {};
167
- acc[cur.parentId].children = acc[cur.parentId].children || [];
168
- acc[cur.parentId].children.push(cur.id);
169
- }
170
- return acc;
171
- }, {});
172
- const labels = labelDtos.map(({ parentId, translation, ...rest }) => ({
173
- ...rest,
174
- translation: safeParseJSON(translation),
175
- children: []
176
- }));
177
- const labelsKeyById = labels.reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {});
178
- labels.forEach((item) => {
179
- const relation = relations[item.id];
180
- if (relation.parent && labelsKeyById[relation.parent]) {
181
- item.parent = labelsKeyById[relation.parent];
182
- }
183
- if (relation.children) {
184
- item.children = relation.children.map((childId) => labelsKeyById[childId]);
185
- }
186
- });
187
- return labels.filter((item) => !item.parent);
188
- };
189
- const LabelMenuList = (props) => {
190
- const { options, getValue, selectProps, selectOption } = props;
191
- const value = getValue();
192
- const handleSelect = (id) => {
193
- const option = options.find((item) => item.data.id === id);
194
- if (option) {
195
- selectOption(option);
196
- }
197
- };
198
- return /* @__PURE__ */ jsxs(Fragment, { children: [
199
- /* @__PURE__ */ jsx(components.MenuList, { ...omit(props, ["addon"]), children: /* @__PURE__ */ jsx(Box, { sx: { px: 2, py: 1 }, children: /* @__PURE__ */ jsx(
200
- LabelTree,
201
- {
202
- data: selectProps.data,
203
- selectable: true,
204
- onSelect: handleSelect,
205
- selected: value.map((item) => item.data.id)
206
- }
207
- ) }) }),
208
- props.addon
209
- ] });
210
- };
211
- const ValueContainer = ({ children, ...props }) => {
212
- const [values, input] = children;
213
- const count = Array.isArray(values) ? values.length : 0;
214
- return /* @__PURE__ */ jsxs(components.ValueContainer, { ...props, children: [
215
- /* @__PURE__ */ jsx(
216
- Box,
217
- {
218
- component: "span",
219
- sx: {
220
- fontSize: 13,
221
- fontWeight: "bold",
222
- color: (theme) => theme.palette.mode === "dark" ? "grey.800" : "text.primary"
223
- },
224
- children: count ? "Labels" : "Filter by labels"
225
- }
226
- ),
227
- !!count && /* @__PURE__ */ jsx(
228
- Box,
229
- {
230
- sx: {
231
- display: "inline-flex",
232
- justifyContent: "center",
233
- alignItems: "center",
234
- width: 22,
235
- height: 22,
236
- ml: 1,
237
- borderRadius: "100%",
238
- fontSize: 12,
239
- color: (theme) => theme.palette.mode === "dark" ? "grey.800" : "text.primary",
240
- bgcolor: "grey.200"
241
- },
242
- children: count
243
- }
244
- ),
245
- input
246
- ] });
247
- };
248
- const compactSelectStyles = {
249
- control: (provided) => ({
250
- ...provided,
251
- minHeight: 31
252
- }),
253
- valueContainer: (provided) => ({
254
- ...provided,
255
- display: "flex"
256
- }),
257
- dropdownIndicator: (provided) => ({
258
- ...provided,
259
- padding: "0 4px"
260
- }),
261
- clearIndicator: (provided) => ({
262
- ...provided,
263
- padding: "4px"
264
- })
265
- };
266
- function LabelPicker({
267
- data,
268
- value = [],
269
- editable = false,
270
- addon,
271
- onChange,
272
- compact,
273
- isMulti = true,
274
- maxHeight = 264,
275
- ...rest
276
- }) {
277
- const selectRef = useRef(null);
278
- const options = useMemo(
279
- () => flatten(data).map((item) => ({ data: item, label: item.name, value: item.id })),
280
- [data]
281
- );
282
- const optionsKeyById = options.reduce(
283
- (acc, cur) => ({ ...acc, [cur.data.id]: cur }),
284
- {}
285
- );
286
- const valueArr = Array.isArray(value) ? value : [value];
287
- const selectedOptions = valueArr.map((item) => optionsKeyById[item]);
288
- const changes = useRef({
289
- prev: valueArr.map((item) => {
290
- var _a;
291
- return ((_a = optionsKeyById[item]) == null ? void 0 : _a.data) || "";
292
- })
293
- });
294
- const handleChange = (v, actionMeta) => {
295
- if (!isMulti || !Array.isArray(v)) {
296
- onChange(v ? [v.data] : []);
297
- } else {
298
- changes.current.current = v.map((item) => item.data);
299
- }
300
- if (["clear", "remove-value"].includes(actionMeta.action) && selectRef.current) {
301
- setTimeout(() => {
302
- var _a;
303
- return (_a = selectRef == null ? void 0 : selectRef.current) == null ? void 0 : _a.blur();
304
- }, 1);
305
- }
306
- };
307
- const handleMenuClose = () => {
308
- if (changes.current.current) {
309
- const changed = JSON.stringify(changes.current.prev.map((item) => item.id)) !== JSON.stringify(changes.current.current.map((item) => item.id));
310
- if (changed) {
311
- onChange(changes.current.current);
312
- changes.current.prev = changes.current.current;
313
- }
314
- }
315
- };
316
- return /* @__PURE__ */ jsx(Box, { ...rest, children: /* @__PURE__ */ jsx(
317
- Select,
318
- {
319
- ref: selectRef,
320
- defaultValue: selectedOptions,
321
- options,
322
- onChange: handleChange,
323
- components: {
324
- // @ts-ignore
325
- MenuList: (props) => /* @__PURE__ */ jsx(LabelMenuList, { ...props, addon }),
326
- // eslint-disable-line react/no-unstable-nested-components
327
- ...compact && { ValueContainer }
328
- },
329
- placeholder: "Select labels",
330
- styles: {
331
- ...compact && compactSelectStyles,
332
- menu: (css) => ({
333
- ...css,
334
- ...editable && { paddingBottom: "36px" },
335
- zIndex: 99
336
- }),
337
- menuList: (css) => ({
338
- ...css,
339
- overflowY: "auto",
340
- maxHeight: `${maxHeight}px`
341
- })
342
- },
343
- theme: (_theme) => ({
344
- ..._theme,
345
- colors: {
346
- ..._theme.colors,
347
- primary25: "#ddd",
348
- primary50: "#ddd",
349
- primary: "#ddd"
350
- }
351
- }),
352
- isSearchable: false,
353
- isMulti,
354
- closeMenuOnSelect: !isMulti,
355
- onMenuClose: handleMenuClose,
356
- isClearable: true,
357
- data
358
- }
359
- ) });
360
- }
361
- class TreeNode {
362
- constructor({ data, parent, children }) {
363
- __publicField(this, "data");
364
- __publicField(this, "parent");
365
- __publicField(this, "children");
366
- this.data = data;
367
- this.parent = parent;
368
- this.children = children || [];
369
- }
370
- setParent(node) {
371
- this.parent = node;
372
- }
373
- add(...nodes) {
374
- this.children.push(...nodes);
375
- nodes.forEach((node) => node.setParent(this));
376
- }
377
- removeChild(node) {
378
- this.children = this.children.filter((x) => x !== node);
379
- node.setParent(void 0);
380
- }
381
- isLeaf(node) {
382
- var _a;
383
- return !((_a = node.children) == null ? void 0 : _a.length);
384
- }
385
- getAllParents(includeSelf = true) {
386
- const parents = [];
387
- if (includeSelf) {
388
- parents.unshift(this);
389
- }
390
- let { parent } = this;
391
- while (parent) {
392
- parents.unshift(parent);
393
- parent = parent.parent;
394
- }
395
- return parents;
396
- }
397
- getAllSiblings() {
398
- var _a;
399
- const siblings = ((_a = this.parent) == null ? void 0 : _a.children.filter((node) => node !== this)) || [];
400
- return siblings;
401
- }
402
- flatten(includeRoot) {
403
- const nodes = [];
404
- const traverse = (node) => {
405
- nodes.push(node);
406
- node.children.forEach(traverse);
407
- };
408
- traverse(this);
409
- if (!includeRoot) {
410
- nodes.shift();
411
- }
412
- return nodes;
413
- }
414
- clone() {
415
- const cloned = new TreeNode({ data: this.data });
416
- cloned.add(...this.children);
417
- return cloned;
418
- }
419
- }
420
- class Label {
421
- constructor(data) {
422
- __publicField(this, "id");
423
- __publicField(this, "name");
424
- __publicField(this, "icon");
425
- __publicField(this, "color");
426
- __publicField(this, "translation");
427
- this.id = data.id;
428
- this.name = data.name;
429
- this.icon = data.icon;
430
- this.color = data.color || "#ddd";
431
- this.translation = this._normalizeTranslation(data.translation);
432
- }
433
- _normalizeTranslation(translation) {
434
- if (typeof translation === "object") {
435
- return translation;
436
- }
437
- try {
438
- return JSON.parse(translation);
439
- } catch {
440
- return {};
441
- }
442
- }
443
- getName(locale) {
444
- var _a;
445
- if (!locale) {
446
- return this.name;
447
- }
448
- return ((_a = this == null ? void 0 : this.translation) == null ? void 0 : _a[locale]) || (this == null ? void 0 : this.name);
449
- }
450
- }
451
- class LabelTreeNode extends TreeNode {
452
- getName(locale) {
453
- return this.data.getName(locale);
454
- }
455
- isSystemLabel() {
456
- return this.data.id.startsWith("system:");
457
- }
458
- getFullName(locale) {
459
- const parents = this.getAllParents();
460
- parents.shift();
461
- if (locale) {
462
- return parents.map((item) => item.getName(locale)).join(" / ");
463
- }
464
- return parents.map((item) => item.data.name).join(" / ");
465
- }
466
- }
467
- __publicField(LabelTreeNode, "Label", Label);
468
- const mapToTree = (items, parent) => {
469
- return items.map((item) => {
470
- const node = new LabelTreeNode({ data: new Label(item.data), parent });
471
- const children = mapToTree(item.children || [], node);
472
- node.add(...children);
473
- return node;
474
- });
475
- };
476
- const initLabelTree = (data) => {
477
- const treeData = arrayToTree(data);
478
- const root = new LabelTreeNode({ data: {} });
479
- root.add(...mapToTree(treeData));
480
- return root;
481
- };
482
- const createEmptyLabelTree = () => {
483
- return new LabelTreeNode({ data: {}, children: [] });
484
- };
485
- const useLabels = ({ loading, data, createLabel: createLabelAPI }) => {
486
- const { locale } = useLocaleContext();
487
- const state = useReactive({
488
- loading: true,
489
- tree: createEmptyLabelTree(),
490
- stats: []
491
- });
492
- useEffect(() => {
493
- try {
494
- if (data && !loading) {
495
- const { labels, stats } = data;
496
- const tree = initLabelTree(labels || []);
497
- state.loading = false;
498
- state.tree = tree;
499
- state.stats = stats.sort((a, b) => b.count - a.count);
500
- }
501
- } catch (e) {
502
- console.error(e);
503
- state.loading = false;
504
- }
505
- }, [data, loading]);
506
- const flattened = useMemo(() => state.tree.flatten(), [state.tree]);
507
- const counts = useMemo(
508
- () => state.stats.reduce((acc, cur) => ({ ...acc, [cur.id]: cur.count }), {}),
509
- [state.stats]
510
- );
511
- const nodesKeyById = useMemo(() => {
512
- return flattened.reduce((acc, cur) => ({ ...acc, [cur.data.id]: cur }), {});
513
- }, [flattened]);
514
- const popularLabels = useMemo(
515
- () => state.stats.slice(0, 12).map((x) => nodesKeyById[x.id]),
516
- [nodesKeyById, state.stats]
517
- );
518
- const getLabelsByIds = useCallback(
519
- (ids) => {
520
- return ids.map((id) => nodesKeyById[id]).filter(Boolean);
521
- },
522
- [nodesKeyById]
523
- );
524
- const labelExists = useCallback((id) => !!nodesKeyById[id], [nodesKeyById]);
525
- const getLabelName = (id) => {
526
- var _a;
527
- return (_a = nodesKeyById[id]) == null ? void 0 : _a.data.getName(locale);
528
- };
529
- const getRelatedLabels = (id) => {
530
- const node = nodesKeyById[id];
531
- if (!node || node.parent === state.tree) {
532
- return [];
533
- }
534
- const siblings = node.getAllSiblings();
535
- return siblings;
536
- };
537
- const getRecommended = (id) => {
538
- const related = getRelatedLabels(id);
539
- const set = /* @__PURE__ */ new Set([...related.map((x) => x.data.id), id]);
540
- return [...related, ...popularLabels.filter((x) => !set.has(x.data.id))].filter((x) => !!counts[x.data.id]);
541
- };
542
- const createLabel = async (name) => {
543
- const saved = await createLabelAPI({ name });
544
- const node = new LabelTreeNode({ data: new LabelTreeNode.Label(saved) });
545
- state.tree.add(node);
546
- state.tree = state.tree.clone();
547
- return node.data;
548
- };
549
- const addLabelNode = (payload) => {
550
- const parent = payload.parentId ? nodesKeyById[payload.parentId] : state.tree;
551
- const node = new LabelTreeNode({ data: new LabelTreeNode.Label(payload) });
552
- parent.add(node);
553
- state.tree = state.tree.clone();
554
- };
555
- const updateLabelNode = (id, payload) => {
556
- const existing = nodesKeyById[id];
557
- if (existing && existing.parent) {
558
- const node = new LabelTreeNode({ data: new LabelTreeNode.Label(payload) });
559
- node.add(...existing.children);
560
- if (existing.parent.data.id == payload.parentId) {
561
- existing.parent.children = existing.parent.children.map((x) => {
562
- if (x.data.id === id) {
563
- node.setParent(existing.parent);
564
- return node;
565
- }
566
- return x;
567
- });
568
- } else {
569
- const parent = nodesKeyById[payload.parentId];
570
- if (parent) {
571
- existing.parent.children = existing.parent.children.filter((x) => x.data.id !== id);
572
- parent.add(node);
573
- }
574
- }
575
- state.tree = state.tree.clone();
576
- }
577
- };
578
- const removeLabelNode = (id) => {
579
- const node = nodesKeyById[id];
580
- if (node == null ? void 0 : node.parent) {
581
- node.parent.removeChild(node);
582
- state.tree = state.tree.clone();
583
- }
584
- };
585
- const getFullLabelName = (id) => {
586
- var _a;
587
- return ((_a = nodesKeyById[id]) == null ? void 0 : _a.getFullName(locale)) ?? id;
588
- };
589
- const parseLabelsStr = useCallback((labelIdsStr) => {
590
- return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
591
- }, []);
592
- return {
593
- ...state,
594
- flattenedLabels: flattened,
595
- popularLabels,
596
- counts,
597
- getLabelsByIds,
598
- labelExists,
599
- getLabelName,
600
- getRelatedLabels,
601
- getRecommended,
602
- createLabel,
603
- addLabelNode,
604
- updateLabelNode,
605
- removeLabelNode,
606
- getFullLabelName,
607
- parseLabelsStr
608
- };
609
- };
610
- const LabelsContainer = createContainer(useLabels);
611
- const LabelsContext = createContext({});
612
- const useLabelsContext = () => useContext(LabelsContext);
613
- const useLabelsUpdateOnDestroy = () => {
614
- const { updateLabels } = useLabelsContext();
615
- useEffect(() => {
616
- return () => {
617
- updateLabels();
618
- };
619
- }, []);
620
- };
621
- function LabelsProvider({ fetchLabels, createLabel, children }) {
622
- const { locale } = useLocaleContext();
623
- const [updateCounter, setUpdateCounter] = useState(1);
624
- const { loading, data } = useRequest(fetchLabels, {
625
- refreshDeps: [updateCounter]
626
- });
627
- const labels = useMemo(() => transformLabels((data == null ? void 0 : data.labels) || []), [data]);
628
- const labelsKeyById = useMemo(() => {
629
- if (!(labels == null ? void 0 : labels.length)) {
630
- return {};
631
- }
632
- const flattened = flatten(labels);
633
- return flattened.reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {});
634
- }, [labels]);
635
- const localeTransformer = useCallback(
636
- (label) => {
637
- var _a;
638
- return {
639
- ...label,
640
- name: ((_a = label.translation) == null ? void 0 : _a[locale]) || label.name
641
- };
642
- },
643
- [locale]
644
- );
645
- const getLabelsById = useCallback(
646
- (ids) => ids.filter(Boolean).map((item) => labelsKeyById[item]).map(localeTransformer),
647
- [labelsKeyById, localeTransformer]
648
- );
649
- const getParents = useCallback((label) => {
650
- let { parent } = label;
651
- const parents = [];
652
- while (parent) {
653
- parents.unshift(parent);
654
- parent = parent.parent;
655
- }
656
- return parents;
657
- }, []);
658
- const getFullLabelName = useCallback(
659
- (label) => {
660
- const parents = [...getParents(label), label].map(localeTransformer);
661
- return parents.map((item) => item.name).join(" / ");
662
- },
663
- [localeTransformer, getParents]
664
- );
665
- const parseLabelIds = useCallback((labelIdsStr) => {
666
- return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
667
- }, []);
668
- const stringifyLabelIds = useCallback((labelIds = []) => {
669
- if (!(labelIds == null ? void 0 : labelIds.length)) {
670
- return void 0;
671
- }
672
- return labelIds.join(",");
673
- }, []);
674
- const localizedLabels = useMemo(() => labels.map(localeTransformer), [labels, localeTransformer]);
675
- const value = useMemo(() => {
676
- return {
677
- loading,
678
- labels: labels || [],
679
- updateLabels: () => setUpdateCounter((prev) => prev + 1),
680
- getLabelsById,
681
- parseLabelIds,
682
- stringifyLabelIds,
683
- localizedLabels,
684
- flattenedLabels: flatten(localizedLabels || []),
685
- getFullLabelName
686
- };
687
- }, [loading, labels, getLabelsById, parseLabelIds, stringifyLabelIds, localizedLabels, getFullLabelName]);
688
- return /* @__PURE__ */ jsx(LabelsContext.Provider, { value, children: /* @__PURE__ */ jsx(LabelsContainer.Provider, { initialState: { loading, data, createLabel }, children }) });
689
- }
690
- const getContrastTextColor = (bgcolor) => {
691
- try {
692
- const ratio = getContrastRatio(bgcolor, "#fff");
693
- return ratio > 2.7 ? "#fff" : "#111";
694
- } catch {
695
- return "#111";
696
- }
697
- };
698
- const getAlphaColor = (color, alpha$1) => {
699
- try {
700
- if (color) {
701
- return alpha(color, alpha$1);
702
- }
703
- } catch {
704
- return color;
705
- }
706
- return color;
707
- };
708
- function Labels({ labels, editable, onChange, sx, renderLabel }) {
709
- const isEmpty = !(labels == null ? void 0 : labels.length);
710
- const { labels: allLabels, loading, getLabelsById, getFullLabelName } = useLabelsContext();
711
- const [editing, setEditing] = useState(false);
712
- if (loading || !editable && isEmpty) {
713
- return null;
714
- }
715
- const handleOnChange = (v) => {
716
- onChange == null ? void 0 : onChange(v);
717
- setTimeout(() => {
718
- setEditing(false);
719
- }, 300);
720
- };
721
- if (editing) {
722
- return /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => editing && setEditing(false), children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(LabelPicker, { data: allLabels, value: labels || [], onChange: handleOnChange }) }) });
723
- }
724
- const labelObjects = getLabelsById(labels || []).filter((x) => !x.id.startsWith("system:"));
725
- const mergedSx = [
726
- { display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
727
- ...Array.isArray(sx) ? sx : [sx]
728
- ];
729
- return /* @__PURE__ */ jsxs(Box$1, { sx: mergedSx, children: [
730
- labelObjects.map((item) => {
731
- if (!item) {
732
- return null;
733
- }
734
- if (renderLabel) {
735
- return renderLabel(item);
736
- }
737
- return /* @__PURE__ */ jsx(
738
- Chip,
739
- {
740
- label: getFullLabelName(item),
741
- variant: "filled",
742
- size: "small",
743
- sx: {
744
- height: 20,
745
- borderRadius: 1,
746
- fontSize: 12,
747
- bgcolor: getAlphaColor(item.color || "#ddd", 0.8),
748
- color: getContrastTextColor(item.color || "#ddd")
749
- }
750
- },
751
- item.id
752
- );
753
- }),
754
- editable && !isEmpty && /* @__PURE__ */ jsx(IconButton, { color: "inherit", size: "small", onClick: () => setEditing(true), sx: { color: "grey.400" }, children: /* @__PURE__ */ jsx(Edit, { sx: { fontSize: 20 } }) }),
755
- editable && isEmpty && /* @__PURE__ */ jsx(Button, { color: "inherit", variant: "outlined", startIcon: /* @__PURE__ */ jsx(LabelOutlined, {}), onClick: () => setEditing(true), children: "Edit labels" })
756
- ] });
757
- }
758
- const mdiTagPlusOutline = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M6.5 5A1.5 1.5 0 1 0 8 6.5A1.5 1.5 0 0 0 6.5 5m0 0A1.5 1.5 0 1 0 8 6.5A1.5 1.5 0 0 0 6.5 5m14.91 6.58l-9-9A2 2 0 0 0 11 2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 .59 1.42l.41.4a5.62 5.62 0 0 1 2.08-.74L4 11V4h7l9 9l-7 7l-1.08-1.08a5.57 5.57 0 0 1-.74 2.08l.41.41A2 2 0 0 0 13 22a2 2 0 0 0 1.41-.59l7-7A2 2 0 0 0 22 13a2 2 0 0 0-.59-1.42M6.5 5A1.5 1.5 0 1 0 8 6.5A1.5 1.5 0 0 0 6.5 5M10 19H7v3H5v-3H2v-2h3v-3h2v3h3Z" }) });
759
- const getTextColor = (color) => {
760
- return chroma(color).hex();
761
- };
762
- const getBorderColor = (color) => {
763
- if (chroma(color).luminance() > 0.5) {
764
- return chroma(color).darken(3).hex();
765
- }
766
- return chroma(color).brighten(0.5).alpha(0.25).hex();
767
- };
768
- const getBackgroundColor = (color) => {
769
- if (chroma(color).luminance() > 0.5) {
770
- return chroma(color).darken(2.5).hex();
771
- }
772
- return chroma(color).brighten(2.5).alpha(0.25).hex();
773
- };
774
- const getFilterStyle = (color) => {
775
- if (chroma(color).luminance() > 0.5) {
776
- return "brightness(0.85) contrast(1.2)";
777
- }
778
- return "brightness(0.85) contrast(1.2)";
779
- };
780
- function LabelChip({
781
- label,
782
- onDelete,
783
- sx,
784
- fullName = true,
785
- onClick,
786
- disabled = false
787
- }) {
788
- const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
789
- const mergedSx = [
790
- {
791
- height: 20,
792
- borderRadius: 0.5,
793
- fontSize: 12,
794
- fontWeight: 500,
795
- color: `${getTextColor(label.data.color)} !important`,
796
- bgcolor: `${getBackgroundColor(label.data.color)} !important`,
797
- transition: "filter 0.2s",
798
- borderColor: `${getBorderColor(label.data.color)} !important`,
799
- // -webkit-text-fill-color
800
- WebkitTextFillColor: `${getTextColor(label.data.color)} !important`,
801
- ".MuiChip-deleteIcon": {
802
- color: `${getTextColor(label.data.color)} !important`,
803
- cursor: "pointer",
804
- transition: "transform 0.3s",
805
- "&:hover": {
806
- transform: "rotate(90deg)"
807
- }
808
- },
809
- ".MuiChip-label": {
810
- px: 0.5,
811
- maxHeight: 20
812
- },
813
- ...onClick && {
814
- cursor: "pointer",
815
- "&:hover": {
816
- filter: getFilterStyle(label.data.color)
817
- }
818
- }
819
- },
820
- ...Array.isArray(sx) ? sx : [sx]
821
- ];
822
- const hasDelete = !disabled && !!onDelete;
823
- const hasOnClick = !disabled && !!onClick;
824
- return (
825
- // @ts-ignore
826
- /* @__PURE__ */ jsx(
827
- Chip,
828
- {
829
- label: fullName ? getFullLabelName(label.data.id) : getLabelName(label.data.id),
830
- variant: "outlined",
831
- size: "small",
832
- ...hasDelete && {
833
- onDelete: (e) => {
834
- e.stopPropagation();
835
- e.preventDefault();
836
- onDelete(label);
837
- },
838
- deleteIcon: /* @__PURE__ */ jsx(CloseOutlineIcon, {})
839
- },
840
- ...hasOnClick && {
841
- onClick: (e) => {
842
- e.stopPropagation();
843
- e.preventDefault();
844
- onClick(label);
845
- }
846
- },
847
- sx: mergedSx
848
- },
849
- label.data.id
850
- )
851
- );
852
- }
853
- function Labels2({
854
- compact = true,
855
- labels,
856
- sx,
857
- renderLabel,
858
- prepend,
859
- displaySystemLabels = true,
860
- onItemClick
861
- }) {
862
- const { getLabelsByIds, loading } = LabelsContainer.useContainer();
863
- const labelsWrapperRef = useRef(null);
864
- const [overflowIndex, setOverflowIndex] = useState(99999);
865
- let labelNodes = getLabelsByIds(labels || []);
866
- const size = useSize(labelsWrapperRef);
867
- useDeepCompareLayoutEffect(() => {
868
- if (compact) {
869
- if (labelsWrapperRef.current) {
870
- const { right } = labelsWrapperRef.current.getBoundingClientRect();
871
- const labelElements = labelsWrapperRef.current.querySelectorAll(".MuiChip-root");
872
- if ((labelElements == null ? void 0 : labelElements.length) > 0) {
873
- Array.from(labelElements).some((x, i) => {
874
- const rect = x.getBoundingClientRect();
875
- if (rect.right > right - 36) {
876
- setOverflowIndex(i);
877
- return true;
878
- }
879
- return false;
880
- });
881
- }
882
- }
883
- } else {
884
- setOverflowIndex(99999);
885
- }
886
- }, [size, compact]);
887
- if (loading) {
888
- return null;
889
- }
890
- if (!displaySystemLabels) {
891
- labelNodes = labelNodes.filter((x) => !x.data.id.startsWith("system:"));
892
- }
893
- const mergedSx = [
894
- {
895
- display: "flex",
896
- gap: 1,
897
- width: "100%",
898
- alignItems: "center",
899
- overflow: "hidden",
900
- flexWrap: compact ? "no-wrap" : "wrap"
901
- },
902
- ...Array.isArray(sx) ? sx : [sx]
903
- ];
904
- return /* @__PURE__ */ jsxs(Box$1, { sx: mergedSx, ref: labelsWrapperRef, children: [
905
- prepend,
906
- labelNodes.map((item, index) => {
907
- if (!item) {
908
- return null;
909
- }
910
- const visible = index < overflowIndex;
911
- let extra = null;
912
- if (index === overflowIndex) {
913
- extra = /* @__PURE__ */ jsx(
914
- Box$1,
915
- {
916
- sx: {
917
- display: "inline-flex",
918
- ...compact && { height: 20, lineHeight: "20px" },
919
- color: "text.secondary",
920
- fontWeight: "bold",
921
- fontSize: 14
922
- },
923
- children: `+${labelNodes.length - overflowIndex}`
924
- },
925
- "overflow-label"
926
- );
927
- }
928
- let labelChip = /* @__PURE__ */ jsx(
929
- LabelChip,
930
- {
931
- label: item,
932
- onClick: onItemClick,
933
- sx: {
934
- visibility: visible ? "visible" : "hidden",
935
- pointerEvents: visible ? "auto" : "none"
936
- }
937
- },
938
- item.data.id
939
- );
940
- if (renderLabel) {
941
- labelChip = renderLabel(item, labelChip);
942
- }
943
- if (extra) {
944
- return [extra, labelChip];
945
- }
946
- return labelChip;
947
- })
948
- ] });
949
- }
950
- function PopperComponent({
951
- disablePortal,
952
- anchorEl,
953
- open,
954
- ...other
955
- }) {
956
- return /* @__PURE__ */ jsx(
957
- Box$1,
958
- {
959
- ...other,
960
- sx: (theme) => ({
961
- [`& .${autocompleteClasses.paper}`]: {
962
- boxShadow: "none",
963
- margin: 0,
964
- color: "inherit",
965
- fontSize: 13
966
- },
967
- [`& .${autocompleteClasses.listbox}`]: {
968
- backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128",
969
- padding: 0,
970
- [`& .${autocompleteClasses.option}`]: {
971
- minHeight: "auto",
972
- alignItems: "flex-start",
973
- padding: 1,
974
- borderBottom: `1px solid ${theme.palette.mode === "light" ? " #eaecef" : "#30363d"}`,
975
- '&[aria-selected="true"]': {
976
- backgroundColor: "transparent"
977
- },
978
- [`&.${autocompleteClasses.focused}, &.${autocompleteClasses.focused}[aria-selected="true"]`]: {
979
- backgroundColor: theme.palette.action.hover
980
- }
981
- }
982
- },
983
- [`&.${autocompleteClasses.popperDisablePortal}`]: {
984
- position: "relative"
985
- }
986
- })
987
- }
988
- );
989
- }
990
- function GithubLabelPicker({
991
- value = [],
992
- onChange,
993
- title,
994
- noLabelsText,
995
- buttonSx,
996
- actions,
997
- trigger,
998
- multiple = true,
999
- updateImmediately = true,
1000
- excludes = [],
1001
- disabled = false
1002
- }) {
1003
- const { locale } = useLocaleContext();
1004
- const { flattenedLabels: labels, getLabelsByIds, loading, createLabel } = LabelsContainer.useContainer();
1005
- const [anchorEl, setAnchorEl] = useState(null);
1006
- const [pendingValue, setPendingValue] = useState([]);
1007
- const pendingOptions = useMemo(() => getLabelsByIds(pendingValue), [getLabelsByIds, pendingValue]);
1008
- const [inputValue, setInputValue] = useState("");
1009
- const exists = useMemo(
1010
- () => labels.some((x) => x.data.getName(locale).toLowerCase() === inputValue.toLowerCase()),
1011
- [inputValue, labels, locale]
1012
- );
1013
- const filteredLabels = useMemo(() => {
1014
- const excludesSet = new Set(excludes);
1015
- return labels.filter((x) => !excludesSet.has(x.data.id));
1016
- }, [labels]);
1017
- const theme = useTheme();
1018
- const handleClick = (event) => {
1019
- if (disabled) {
1020
- return;
1021
- }
1022
- event.preventDefault();
1023
- setPendingValue(value);
1024
- setAnchorEl(event.currentTarget);
1025
- };
1026
- const handleClose = () => {
1027
- if (!updateImmediately) {
1028
- onChange == null ? void 0 : onChange(pendingValue);
1029
- }
1030
- setInputValue("");
1031
- if (anchorEl) {
1032
- anchorEl.focus();
1033
- }
1034
- setAnchorEl(null);
1035
- };
1036
- const handleCreate = async () => {
1037
- const { id: id2 } = await createLabel(inputValue);
1038
- setPendingValue([...pendingValue, id2]);
1039
- };
1040
- const open = Boolean(anchorEl);
1041
- const id = open ? "github-label-picker" : void 0;
1042
- if (loading) {
1043
- return null;
1044
- }
1045
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1046
- /* @__PURE__ */ jsx(
1047
- Box$1,
1048
- {
1049
- onClick: handleClick,
1050
- sx: {
1051
- display: "flex",
1052
- alignItems: "center"
1053
- },
1054
- children: trigger || /* @__PURE__ */ jsx(
1055
- Box$1,
1056
- {
1057
- component: ButtonBase,
1058
- disableRipple: true,
1059
- "aria-describedby": id,
1060
- className: "label-picker-trigger",
1061
- sx: [
1062
- (t) => ({
1063
- width: "100%",
1064
- fontSize: 13,
1065
- color: t.palette.mode === "light" ? "#586069" : "#8b949e",
1066
- fontWeight: 600,
1067
- "&:hover": {
1068
- color: t.palette.mode === "light" ? "primary.main" : "#58a6ff"
1069
- },
1070
- "& svg": {
1071
- width: 22,
1072
- height: 22
1073
- }
1074
- }),
1075
- ...Array.isArray(buttonSx) ? buttonSx : [buttonSx]
1076
- ],
1077
- children: /* @__PURE__ */ jsx(mdiTagPlusOutline, {})
1078
- }
1079
- )
1080
- }
1081
- ),
1082
- /* @__PURE__ */ jsx(
1083
- Box$1,
1084
- {
1085
- component: Popper,
1086
- id,
1087
- open,
1088
- anchorEl,
1089
- placement: "bottom-start",
1090
- sx: (t) => ({
1091
- border: `1px solid ${t.palette.mode === "light" ? "#e1e4e8" : "#30363d"}`,
1092
- boxShadow: `0 8px 24px ${t.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
1093
- borderRadius: "4px",
1094
- width: 300,
1095
- zIndex: t.zIndex.modal,
1096
- fontSize: 13,
1097
- color: t.palette.mode === "light" ? "#24292e" : "#c9d1d9",
1098
- backgroundColor: t.palette.mode === "light" ? "#fff" : "#1c2128"
1099
- }),
1100
- children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsxs(Box$1, { onClick: (e) => e.preventDefault(), children: [
1101
- title && /* @__PURE__ */ jsx(
1102
- Box$1,
1103
- {
1104
- sx: {
1105
- borderBottom: `1px solid ${theme.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
1106
- padding: "8px 10px",
1107
- fontWeight: 600
1108
- },
1109
- children: title
1110
- }
1111
- ),
1112
- /* @__PURE__ */ jsx(
1113
- Autocomplete,
1114
- {
1115
- open: true,
1116
- multiple: true,
1117
- inputValue,
1118
- onInputChange: (event, newInputValue, reason) => {
1119
- if (reason === "reset") {
1120
- return;
1121
- }
1122
- setInputValue(newInputValue);
1123
- },
1124
- onClose: (event, reason) => {
1125
- if (reason === "escape") {
1126
- handleClose();
1127
- }
1128
- },
1129
- value: pendingOptions,
1130
- onChange: (event, newValue, reason) => {
1131
- event.preventDefault();
1132
- if (event.type === "keydown" && event.key === "Backspace" && reason === "removeOption") {
1133
- return;
1134
- }
1135
- setPendingValue(newValue.map((x) => x.data.id));
1136
- if (!multiple) {
1137
- onChange == null ? void 0 : onChange(newValue.length ? [newValue[newValue.length - 1].data.id] : []);
1138
- setAnchorEl(null);
1139
- } else if (updateImmediately) {
1140
- onChange(newValue.map((x) => x.data.id));
1141
- }
1142
- },
1143
- disableCloseOnSelect: true,
1144
- PopperComponent,
1145
- renderTags: () => null,
1146
- noOptionsText: noLabelsText || "No labels",
1147
- renderOption: (props, option, { selected }) => /* @__PURE__ */ createElement("li", { ...props, key: option.data.id }, /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", alignItems: "center", width: 1 }, children: [
1148
- /* @__PURE__ */ jsx(
1149
- Box$1,
1150
- {
1151
- component: DoneIcon,
1152
- sx: { width: 17, height: 17, mr: "5px", ml: "-2px" },
1153
- style: {
1154
- visibility: selected ? "visible" : "hidden"
1155
- }
1156
- }
1157
- ),
1158
- /* @__PURE__ */ jsx(
1159
- Box$1,
1160
- {
1161
- component: "span",
1162
- sx: {
1163
- width: 16,
1164
- height: 16,
1165
- flexShrink: 0,
1166
- borderRadius: "3px",
1167
- mr: 1
1168
- },
1169
- style: { backgroundColor: option.data.color || "#ddd" }
1170
- }
1171
- ),
1172
- /* @__PURE__ */ jsx(
1173
- Box$1,
1174
- {
1175
- sx: {
1176
- flexGrow: 1,
1177
- alignItems: "center",
1178
- display: "flex"
1179
- },
1180
- children: /* @__PURE__ */ jsx(LabelChip, { label: option, disabled })
1181
- }
1182
- ),
1183
- /* @__PURE__ */ jsx(
1184
- Box$1,
1185
- {
1186
- component: CloseOutlineIcon,
1187
- sx: { opacity: 0.6, width: 18, height: 18 },
1188
- style: {
1189
- visibility: selected ? "visible" : "hidden"
1190
- }
1191
- }
1192
- )
1193
- ] })),
1194
- options: [...filteredLabels].sort((a, b) => {
1195
- let ai = value.indexOf(a.data.id);
1196
- ai = ai === -1 ? value.length + filteredLabels.indexOf(a) : ai;
1197
- let bi = value.indexOf(b.data.id);
1198
- bi = bi === -1 ? value.length + filteredLabels.indexOf(b) : bi;
1199
- return ai - bi;
1200
- }),
1201
- getOptionLabel: (option) => option.data.getName(locale),
1202
- renderInput: (params) => /* @__PURE__ */ jsx(
1203
- Box$1,
1204
- {
1205
- component: InputBase,
1206
- ref: params.InputProps.ref,
1207
- inputProps: params.inputProps,
1208
- autoFocus: true,
1209
- placeholder: "Filter labels",
1210
- sx: (t) => ({
1211
- padding: 1,
1212
- width: "100%",
1213
- borderBottom: `1px solid ${t.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
1214
- "& input": {
1215
- borderRadius: "4px",
1216
- backgroundColor: t.palette.mode === "light" ? "#fff" : "#0d1117",
1217
- padding: 1,
1218
- transition: t.transitions.create(["border-color", "box-shadow"]),
1219
- border: `1px solid ${t.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
1220
- fontSize: 14,
1221
- "&:focus": {
1222
- boxShadow: `0px 0px 0px 3px ${t.palette.mode === "light" ? alpha(t.palette.primary.light, 0.4) : "rgb(12, 45, 107)"}`,
1223
- borderColor: t.palette.mode === "light" ? t.palette.primary.light : "#388bfd"
1224
- }
1225
- }
1226
- })
1227
- }
1228
- )
1229
- }
1230
- ),
1231
- /* @__PURE__ */ jsxs(Box$1, { children: [
1232
- inputValue && !exists && /* @__PURE__ */ jsx(
1233
- Box$1,
1234
- {
1235
- sx: {
1236
- display: "flex",
1237
- alignItems: "center",
1238
- gap: 1,
1239
- width: "100%",
1240
- height: 36,
1241
- px: 2,
1242
- borderTop: "1px solid #eee",
1243
- fontSize: 14,
1244
- color: "grey.600",
1245
- cursor: "pointer",
1246
- textDecoration: "none"
1247
- },
1248
- onClick: handleCreate,
1249
- children: /* @__PURE__ */ jsxs("span", { children: [
1250
- 'Create new label "',
1251
- inputValue,
1252
- '"'
1253
- ] })
1254
- }
1255
- ),
1256
- actions
1257
- ] })
1258
- ] }) })
1259
- }
1260
- )
1261
- ] });
1262
- }
1263
- function LabelsInput({
1264
- value = [],
1265
- onChange,
1266
- LabelPickerProps,
1267
- sx,
1268
- ...rest
1269
- }) {
1270
- var _a;
1271
- const { getLabelsByIds, loading } = LabelsContainer.useContainer();
1272
- const valueOptions = useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
1273
- const mergedSx = [
1274
- {
1275
- "& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, py: 0.75 },
1276
- "& .MuiInputBase-input": { width: !(value == null ? void 0 : value.length) ? "initial" : "20px", p: 0 }
1277
- },
1278
- ...Array.isArray(sx) ? sx : [sx]
1279
- ];
1280
- const placeholder = !(value == null ? void 0 : value.length) ? rest.placeholder || "Select labels" : "";
1281
- if (loading) {
1282
- return null;
1283
- }
1284
- return /* @__PURE__ */ jsx(
1285
- GithubLabelPicker,
1286
- {
1287
- value,
1288
- onChange,
1289
- trigger: /* @__PURE__ */ jsx(
1290
- TextField,
1291
- {
1292
- ...rest,
1293
- placeholder,
1294
- fullWidth: true,
1295
- InputProps: {
1296
- autoComplete: "off",
1297
- ...rest.InputProps,
1298
- startAdornment: [
1299
- (_a = rest.InputProps) == null ? void 0 : _a.startAdornment,
1300
- ...valueOptions.map((x, index) => /* @__PURE__ */ jsx(LabelChip, { label: x }, index))
1301
- ].filter(Boolean)
1302
- },
1303
- sx: mergedSx
1304
- }
1305
- ),
1306
- ...LabelPickerProps
1307
- }
1308
- );
1309
- }
1
+ import { G, j, b, a, L, d, k, h, i, f, u, e } from "./index-LED75_5N.mjs";
2
+ import "react/jsx-runtime";
3
+ import "react";
4
+ import "@mui/icons-material";
5
+ import "@mui/material/Box";
6
+ import "@mui/material/styles";
7
+ import "react-arborist";
8
+ import "@iconify/react";
9
+ import "lodash/omit";
10
+ import "react-select";
11
+ import "@mui/material";
12
+ import "@arcblock/ux/lib/Locale/context";
13
+ import "ahooks";
14
+ import "unstated-next";
15
+ import "performant-array-to-tree";
16
+ import "@mui/icons-material/Close";
17
+ import "@mui/icons-material/Done";
18
+ import "chroma-js";
19
+ import "lodash/pick";
20
+ import "lodash/cloneDeep";
21
+ import "lodash/isFunction";
22
+ import "lodash/isUndefined";
23
+ import "lodash/defaultsDeep";
24
+ import "@arcblock/ux/lib/Util";
25
+ import "@arcblock/ux/lib/Toast";
26
+ import "@arcblock/ux/lib/Center";
27
+ import "@arcblock/ux/lib/Colors";
28
+ import "@arcblock/ux/lib/Dialog/use-confirm";
29
+ import "@arcblock/ux/lib/DID";
30
+ import "@arcblock/ux/lib/Avatar";
31
+ import "@arcblock/ux/lib/SessionUser/libs/utils";
32
+ import "@arcblock/ux/lib/Locale/util";
33
+ import "node:crypto";
34
+ import "@arcblock/ux/lib/Util/wallet";
35
+ import "@arcblock/ux/lib/Dialog";
36
+ import "@arcblock/ux/lib/Button";
37
+ import "@arcblock/ux/lib/Empty";
38
+ import "lodash/noop";
39
+ import "@arcblock/ux/lib/CardSelector";
40
+ import "node:buffer";
41
+ import "@arcblock/ux/lib/Util/federated";
42
+ import "react-dom";
43
+ import "@arcblock/ux/lib/WebWalletSWKeeper";
44
+ import "@arcblock/ux/lib/BlockletContext";
45
+ import "lodash";
46
+ import "@arcblock/ux/lib/RelativeTime";
47
+ import "@arcblock/ux/lib/WalletOSIcon";
48
+ import "@arcblock/ux/lib/LoadingMask";
49
+ import "@arcblock/ux/lib/Success";
50
+ import "lodash/intersection";
51
+ import "@arcblock/ux/lib/QRCode";
52
+ import "lodash/get";
53
+ import "lodash/omitBy";
54
+ import "lodash/isNil";
55
+ import "lodash/unionBy";
56
+ import "lodash/sortBy";
57
+ import "@arcblock/ux/lib/Address";
58
+ import "@arcblock/ux/lib/Img";
1310
59
  export {
1311
- GithubLabelPicker,
1312
- LabelChip,
1313
- LabelPicker,
1314
- LabelTree,
1315
- LabelTreeNode,
1316
- Labels,
1317
- Labels2,
1318
- LabelsContainer,
1319
- LabelsInput,
1320
- LabelsProvider,
1321
- useLabelsContext,
1322
- useLabelsUpdateOnDestroy
60
+ G as GithubLabelPicker,
61
+ j as LabelChip,
62
+ b as LabelPicker,
63
+ a as LabelTree,
64
+ L as LabelTreeNode,
65
+ d as Labels,
66
+ k as Labels2,
67
+ h as LabelsContainer,
68
+ i as LabelsInput,
69
+ f as LabelsProvider,
70
+ u as useLabelsContext,
71
+ e as useLabelsUpdateOnDestroy
1323
72
  };