@blocklet/labels 1.5.214 → 1.6.0

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.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(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("ahooks"), 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"), require("unstated-next"), require("performant-array-to-tree")) : 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", "ahooks", "@mui/material/TextField", "@mui/material/ClickAwayListener", "react-color", "@arcblock/ux/lib/Dialog", "@mui/material/Alert", "@mui/material", "@arcblock/ux/lib/Locale/context", "unstated-next", "performant-array-to-tree"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.BlockletLabels = {}, global.jsxRuntime, global.react, global.iconsMaterial, global.Box, global.styles, global.reactArborist, global.react$1, global.omit, global.Select, global.Typography, global.Button, global.IconButton, global.translationInput, global.ahooks, global.TextField, global.ClickAwayListener, global.reactColor, global.Dialog, global.Alert, global.material, global.context, global.unstatedNext, global.performantArrayToTree));
3
- })(this, function(exports2, jsxRuntime, react, iconsMaterial, Box, styles, reactArborist, react$1, omit, Select, Typography, Button, IconButton, translationInput, ahooks, TextField, ClickAwayListener, reactColor, Dialog, Alert, material, context, unstatedNext, performantArrayToTree) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(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"), require("@arcblock/ux/lib/Locale/context"), require("ahooks"), require("unstated-next"), require("performant-array-to-tree"), require("@mui/icons-material/Close"), require("@mui/icons-material/Done")) : 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", "@arcblock/ux/lib/Locale/context", "ahooks", "unstated-next", "performant-array-to-tree", "@mui/icons-material/Close", "@mui/icons-material/Done"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.BlockletLabels = {}, global.jsxRuntime, global.react, global.iconsMaterial, global.Box, global.styles, global.reactArborist, global.react$1, global.omit, global.Select, global.material, global.context, global.ahooks, global.unstatedNext, global.performantArrayToTree, global.CloseIcon, global.DoneIcon));
3
+ })(this, function(exports2, jsxRuntime, react, iconsMaterial, Box, styles, reactArborist, react$1, omit, Select, material, context, ahooks, unstatedNext, performantArrayToTree, CloseIcon, DoneIcon) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -133,15 +133,6 @@ var __publicField = (obj, key, value) => {
133
133
  return acc;
134
134
  }, []);
135
135
  };
136
- const copyTree = (data) => {
137
- return data.map((item) => {
138
- var _a;
139
- if ((_a = item.children) == null ? void 0 : _a.length) {
140
- item.children = copyTree(item.children);
141
- }
142
- return item;
143
- });
144
- };
145
136
  const safeParseJSON = (json, defaultValue = null) => {
146
137
  try {
147
138
  return JSON.parse(json);
@@ -337,287 +328,6 @@ var __publicField = (obj, key, value) => {
337
328
  }
338
329
  ) });
339
330
  }
340
- function LabelFormDialog({ open, initialLabel, onSubmit, onClose, ...rest }) {
341
- const isNew = !(initialLabel == null ? void 0 : initialLabel.id);
342
- const [state, setState] = ahooks.useSetState({
343
- name: (initialLabel == null ? void 0 : initialLabel.name) || "",
344
- color: (initialLabel == null ? void 0 : initialLabel.color) || "#ddd",
345
- slug: (initialLabel == null ? void 0 : initialLabel.id) || "",
346
- translation: (initialLabel == null ? void 0 : initialLabel.translation) || {}
347
- });
348
- const isValidColor = (color) => /^#([0-9A-F]{3}){1,2}$/i.test(color);
349
- const canSubmit = react.useMemo(() => {
350
- if (isNew) {
351
- return state.name && state.color && state.slug && isValidColor(state.color);
352
- }
353
- return state.name && state.color && isValidColor(state.color);
354
- }, [state, isNew]);
355
- const [colorPickerVisible, setColorPickerVisible] = react.useState(false);
356
- const handleSubmit = () => {
357
- onSubmit({ ...initialLabel, name: state.name, color: state.color, id: state.slug, translation: state.translation });
358
- };
359
- const handleColorChange = (color) => {
360
- setState({ color: color.hex });
361
- setTimeout(() => setColorPickerVisible(false));
362
- };
363
- const handleColorTextChange = (e) => {
364
- setState({ color: e.target.value });
365
- };
366
- return /* @__PURE__ */ jsxRuntime.jsx(
367
- Dialog,
368
- {
369
- open,
370
- showCloseButton: true,
371
- maxWidth: "lg",
372
- title: isNew ? "Create label" : "Edit label",
373
- actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
374
- /* @__PURE__ */ jsxRuntime.jsx(Button, { color: "inherit", variant: "contained", size: "small", onClick: onClose, children: "Cancel" }),
375
- /* @__PURE__ */ jsxRuntime.jsx(Button, { color: "primary", variant: "contained", size: "small", onClick: handleSubmit, disabled: !canSubmit, children: isNew ? "Create" : "Save Changes" })
376
- ] }),
377
- onClose,
378
- ...rest,
379
- children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { width: 600, minHeight: 320, children: [
380
- /* @__PURE__ */ jsxRuntime.jsx(
381
- translationInput.TranslationTextField,
382
- {
383
- label: "Name",
384
- value: state.name,
385
- placeholder: "New label",
386
- size: "small",
387
- fullWidth: true,
388
- onChange: (e) => setState({ name: e.target.value }),
389
- translationInputProps: {
390
- value: state.translation,
391
- onChange: (v) => setState({ translation: v })
392
- }
393
- }
394
- ),
395
- /* @__PURE__ */ jsxRuntime.jsx(
396
- TextField,
397
- {
398
- label: "Slug",
399
- value: state.slug,
400
- size: "small",
401
- fullWidth: true,
402
- disabled: !isNew,
403
- onChange: (e) => setState({ slug: e.target.value }),
404
- sx: { mt: 2 }
405
- }
406
- ),
407
- (initialLabel == null ? void 0 : initialLabel.parent) && /* @__PURE__ */ jsxRuntime.jsx(TextField, { label: "Parent", value: initialLabel.parent.name, size: "small", fullWidth: true, disabled: true, sx: { mt: 2 } }),
408
- /* @__PURE__ */ jsxRuntime.jsx(ClickAwayListener, { onClickAway: () => setColorPickerVisible(false), children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { position: "relative", mt: 2 }, children: [
409
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
410
- /* @__PURE__ */ jsxRuntime.jsx(
411
- Box,
412
- {
413
- sx: { width: 30, height: 30, bgcolor: state.color, borderRadius: 1 },
414
- onClick: () => setColorPickerVisible(true)
415
- }
416
- ),
417
- /* @__PURE__ */ jsxRuntime.jsx(
418
- TextField,
419
- {
420
- label: "",
421
- value: state.color,
422
- size: "small",
423
- onChange: handleColorTextChange,
424
- inputProps: { maxLength: 7 },
425
- sx: { width: 100, ".MuiInputBase-root": { height: 32 } }
426
- }
427
- )
428
- ] }),
429
- colorPickerVisible && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { position: "absolute", top: 48, zIndex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactColor.GithubPicker, { color: state.color, onChangeComplete: handleColorChange }) })
430
- ] }) })
431
- ] })
432
- }
433
- );
434
- }
435
- function LabelDeleteDialog({ open, label, onSubmit, onClose, ...rest }) {
436
- return /* @__PURE__ */ jsxRuntime.jsx(
437
- Dialog,
438
- {
439
- open,
440
- showCloseButton: true,
441
- maxWidth: "md",
442
- title: "Delete",
443
- actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
444
- /* @__PURE__ */ jsxRuntime.jsx(Button, { color: "inherit", variant: "contained", size: "small", onClick: onClose, children: "Cancel" }),
445
- /* @__PURE__ */ jsxRuntime.jsx(Button, { color: "primary", variant: "contained", size: "small", onClick: onSubmit, children: "Delete" })
446
- ] }),
447
- onClose,
448
- ...rest,
449
- children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { width: 600, minHeight: 280, children: [
450
- /* @__PURE__ */ jsxRuntime.jsx(Alert, { severity: "info", sx: { mb: 2 }, children: "Are you sure you want to delete these labels ?" }),
451
- /* @__PURE__ */ jsxRuntime.jsx(LabelTree, { data: [label] })
452
- ] })
453
- }
454
- );
455
- }
456
- const StyledLabelTree = styles.styled(LabelTree)`
457
- .label-tree-item {
458
- &:before {
459
- content: '';
460
- position: absolute;
461
- top: 0;
462
- left: 0;
463
- right: 0;
464
- border-top: 1px solid #ddd;
465
- }
466
- }
467
- & [role='treeitem']:first-of-type > .label-tree-item {
468
- &:before {
469
- display: none;
470
- }
471
- }
472
- [role='treeitem'] {
473
- box-sizing: border-box;
474
- padding: 0 16px;
475
- }
476
- `;
477
- function LabelManager({ data, api, ...rest }) {
478
- const [editingLabel, setEditingLabel] = react.useState(null);
479
- const [deletingLabel, setDeletingLabel] = react.useState(null);
480
- const [copy, setCopy] = react.useState(copyTree(data));
481
- const flattened = react.useMemo(() => flatten(copy), [copy]);
482
- const treeData = react.useMemo(() => {
483
- const format = (nodes, parent) => {
484
- return nodes.map((node) => {
485
- if (parent) {
486
- node.parent = parent;
487
- }
488
- if (node.children) {
489
- node.children = format(node.children, node);
490
- }
491
- return node;
492
- });
493
- };
494
- return format(copy);
495
- }, [copy]);
496
- const updateNode = (label) => {
497
- var _a, _b;
498
- if (!label.parent) {
499
- setCopy(copy.map((item) => item.id === label.id ? { ...label } : item));
500
- } else {
501
- label.parent.children = (_b = (_a = label.parent) == null ? void 0 : _a.children) == null ? void 0 : _b.map((item) => item.id === label.id ? { ...label } : item);
502
- updateNode(label.parent);
503
- }
504
- };
505
- const addNode = (label) => {
506
- if (label.parent) {
507
- label.parent.children = label.parent.children || [];
508
- label.parent.children.push(label);
509
- setCopy([...copy]);
510
- } else {
511
- setCopy([...copy, label]);
512
- }
513
- };
514
- const deleteNode = (label) => {
515
- var _a;
516
- if (label.parent) {
517
- label.parent.children = (_a = label.parent.children) == null ? void 0 : _a.filter((item) => item.id !== label.id);
518
- } else {
519
- setCopy(copy.filter((item) => item.id !== label.id));
520
- }
521
- };
522
- const handleAdd = (parent) => {
523
- if (editingLabel) {
524
- return;
525
- }
526
- const newLabel = { id: "", name: "New label", parent, color: "#dddddd" };
527
- setEditingLabel(newLabel);
528
- };
529
- const handleEdit = (label) => {
530
- if (editingLabel) {
531
- return;
532
- }
533
- setEditingLabel(label);
534
- };
535
- const handleSubmit = async (payload) => {
536
- if (!editingLabel) {
537
- return;
538
- }
539
- const { parent, children, translation, ...submitData } = payload;
540
- if (!editingLabel.id) {
541
- await api.createLabel({ ...submitData, translation: JSON.stringify(translation), parentId: parent == null ? void 0 : parent.id });
542
- addNode(payload);
543
- } else {
544
- await api.updateLabel({ ...submitData, translation: JSON.stringify(translation), parentId: parent == null ? void 0 : parent.id });
545
- updateNode(payload);
546
- }
547
- setEditingLabel(null);
548
- };
549
- const handleDelete = async () => {
550
- if (!deletingLabel) {
551
- return;
552
- }
553
- await api.deleteLabel(deletingLabel.id);
554
- deleteNode(deletingLabel);
555
- setDeletingLabel(null);
556
- };
557
- const renderItem = (children, label) => {
558
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
559
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center", flexWrap: "wrap" }, className: "label-name", children: [
560
- /* @__PURE__ */ jsxRuntime.jsx(Box, { children }),
561
- label.translation && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5, ml: 2 }, className: "label-translation", children: Object.keys(label.translation).map((key) => {
562
- var _a;
563
- const value = (_a = label.translation) == null ? void 0 : _a[key];
564
- if (value) {
565
- return /* @__PURE__ */ jsxRuntime.jsx(translationInput.TranslationTag, { locale: key, value }, key);
566
- }
567
- return null;
568
- }) })
569
- ] }),
570
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", gap: 1, flex: "0 0 auto" }, className: "label-action", children: [
571
- /* @__PURE__ */ jsxRuntime.jsx(IconButton, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => handleAdd(label), children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Add, { sx: { fontSize: 20 } }) }),
572
- /* @__PURE__ */ jsxRuntime.jsx(IconButton, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => handleEdit(label), children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.EditOutlined, { sx: { fontSize: 18 } }) }),
573
- /* @__PURE__ */ jsxRuntime.jsx(IconButton, { color: "inherit", size: "small", sx: { color: "grey.500" }, onClick: () => setDeletingLabel(label), children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.DeleteOutlineOutlined, { sx: { fontSize: 20 } }) })
574
- ] })
575
- ] });
576
- };
577
- return /* @__PURE__ */ jsxRuntime.jsxs(Box, { ...rest, className: "label-container", children: [
578
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
579
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { component: "h2", variant: "h6", children: "Manage labels" }),
580
- /* @__PURE__ */ jsxRuntime.jsx(
581
- Button,
582
- {
583
- color: "primary",
584
- variant: "contained",
585
- size: "small",
586
- sx: { textTransform: "none" },
587
- onClick: () => handleAdd(),
588
- children: "New label"
589
- }
590
- )
591
- ] }),
592
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { mt: 2, border: 1, borderColor: "grey.300", borderRadius: 1, overflow: "hidden" }, children: [
593
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { p: 2, fontSize: 14, fontWeight: "bold", bgcolor: "grey.200" }, className: "label-header", children: [
594
- flattened.length,
595
- " labels"
596
- ] }),
597
- /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { pt: 0.5 }, children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabelTree, { data: treeData, selected: [], renderItem, rowHeight: 64 }) })
598
- ] }),
599
- /* @__PURE__ */ jsxRuntime.jsx(
600
- LabelFormDialog,
601
- {
602
- open: !!editingLabel,
603
- onClose: () => setEditingLabel(null),
604
- initialLabel: editingLabel,
605
- onSubmit: handleSubmit
606
- },
607
- editingLabel == null ? void 0 : editingLabel.id
608
- ),
609
- /* @__PURE__ */ jsxRuntime.jsx(
610
- LabelDeleteDialog,
611
- {
612
- open: !!deletingLabel,
613
- onClose: () => setDeletingLabel(null),
614
- label: deletingLabel,
615
- onSubmit: handleDelete
616
- },
617
- deletingLabel == null ? void 0 : deletingLabel.id
618
- )
619
- ] });
620
- }
621
331
  class TreeNode {
622
332
  constructor({ data, parent, children }) {
623
333
  __publicField(this, "data");
@@ -634,6 +344,10 @@ var __publicField = (obj, key, value) => {
634
344
  this.children.push(...nodes);
635
345
  nodes.forEach((node) => node.setParent(this));
636
346
  }
347
+ removeChild(node) {
348
+ this.children = this.children.filter((x) => x !== node);
349
+ node.setParent(void 0);
350
+ }
637
351
  isLeaf(node) {
638
352
  var _a;
639
353
  return !((_a = node.children) == null ? void 0 : _a.length);
@@ -667,6 +381,11 @@ var __publicField = (obj, key, value) => {
667
381
  }
668
382
  return nodes;
669
383
  }
384
+ clone() {
385
+ const cloned = new TreeNode({ data: this.data });
386
+ cloned.add(...this.children);
387
+ return cloned;
388
+ }
670
389
  }
671
390
  class Label {
672
391
  constructor(data) {
@@ -678,7 +397,7 @@ var __publicField = (obj, key, value) => {
678
397
  this.id = data.id;
679
398
  this.name = data.name;
680
399
  this.icon = data.icon;
681
- this.color = data.color;
400
+ this.color = data.color || "#ddd";
682
401
  this.translation = this._normalizeTranslation(data.translation);
683
402
  }
684
403
  _normalizeTranslation(translation) {
@@ -700,7 +419,22 @@ var __publicField = (obj, key, value) => {
700
419
  }
701
420
  }
702
421
  class LabelTreeNode extends TreeNode {
422
+ getName(locale) {
423
+ return this.data.getName(locale);
424
+ }
425
+ isSystemLabel() {
426
+ return this.data.id.startsWith("system:");
427
+ }
428
+ getFullName(locale) {
429
+ const parents = this.getAllParents();
430
+ parents.shift();
431
+ if (locale) {
432
+ return parents.map((item) => item.getName(locale)).join(" / ");
433
+ }
434
+ return parents.map((item) => item.data.name).join(" / ");
435
+ }
703
436
  }
437
+ __publicField(LabelTreeNode, "Label", Label);
704
438
  const mapToTree = (items, parent) => {
705
439
  return items.map((item) => {
706
440
  const node = new LabelTreeNode({ data: new Label(item.data), parent });
@@ -711,13 +445,14 @@ var __publicField = (obj, key, value) => {
711
445
  };
712
446
  const initLabelTree = (data) => {
713
447
  const treeData = performantArrayToTree.arrayToTree(data);
714
- const root = new LabelTreeNode({ data: {}, children: mapToTree(treeData) });
448
+ const root = new LabelTreeNode({ data: {} });
449
+ root.add(...mapToTree(treeData));
715
450
  return root;
716
451
  };
717
452
  const createEmptyLabelTree = () => {
718
453
  return new LabelTreeNode({ data: {}, children: [] });
719
454
  };
720
- const useLabels = ({ loading, data }) => {
455
+ const useLabels = ({ loading, data, createLabel: createLabelAPI }) => {
721
456
  const { locale } = context.useLocaleContext();
722
457
  const state = ahooks.useReactive({
723
458
  loading: true,
@@ -750,16 +485,19 @@ var __publicField = (obj, key, value) => {
750
485
  () => state.stats.slice(0, 12).map((x) => nodesKeyById[x.id]),
751
486
  [nodesKeyById, state.stats]
752
487
  );
753
- const getLabelsByIds = (ids) => {
754
- return ids.map((id) => nodesKeyById[id]).filter(Boolean);
755
- };
488
+ const getLabelsByIds = react.useCallback(
489
+ (ids) => {
490
+ return ids.map((id) => nodesKeyById[id]).filter(Boolean);
491
+ },
492
+ [nodesKeyById]
493
+ );
756
494
  const getLabelName = (id) => {
757
495
  var _a;
758
496
  return (_a = nodesKeyById[id]) == null ? void 0 : _a.data.getName(locale);
759
497
  };
760
498
  const getRelatedLabels = (id) => {
761
499
  const node = nodesKeyById[id];
762
- if (!node) {
500
+ if (!node || node.parent === state.tree) {
763
501
  return [];
764
502
  }
765
503
  const siblings = node.getAllSiblings();
@@ -768,9 +506,70 @@ var __publicField = (obj, key, value) => {
768
506
  const getRecommended = (id) => {
769
507
  const related = getRelatedLabels(id);
770
508
  const set = /* @__PURE__ */ new Set([...related.map((x) => x.data.id), id]);
771
- return [...related, ...popularLabels.filter((x) => !set.has(x.data.id))];
509
+ return [...related, ...popularLabels.filter((x) => !set.has(x.data.id))].filter((x) => !!counts[x.data.id]);
510
+ };
511
+ const createLabel = async (name) => {
512
+ const saved = await createLabelAPI({ name });
513
+ const node = new LabelTreeNode({ data: new LabelTreeNode.Label(saved) });
514
+ state.tree.add(node);
515
+ state.tree = state.tree.clone();
516
+ return node.data;
517
+ };
518
+ const addLabelNode = (payload) => {
519
+ const parent = payload.parentId ? nodesKeyById[payload.parentId] : state.tree;
520
+ const node = new LabelTreeNode({ data: new LabelTreeNode.Label(payload) });
521
+ parent.add(node);
522
+ state.tree = state.tree.clone();
523
+ };
524
+ const updateLabelNode = (id, payload) => {
525
+ const existing = nodesKeyById[id];
526
+ if (existing && existing.parent) {
527
+ const node = new LabelTreeNode({ data: new LabelTreeNode.Label(payload) });
528
+ node.add(...existing.children);
529
+ if (existing.parent.data.id == payload.parentId) {
530
+ existing.parent.children = existing.parent.children.map((x) => {
531
+ if (x.data.id === id) {
532
+ node.setParent(existing.parent);
533
+ return node;
534
+ }
535
+ return x;
536
+ });
537
+ } else {
538
+ const parent = nodesKeyById[payload.parentId];
539
+ if (parent) {
540
+ existing.parent.children = existing.parent.children.filter((x) => x.data.id !== id);
541
+ parent.add(node);
542
+ }
543
+ }
544
+ state.tree = state.tree.clone();
545
+ }
546
+ };
547
+ const removeLabelNode = (id) => {
548
+ const node = nodesKeyById[id];
549
+ if (node == null ? void 0 : node.parent) {
550
+ node.parent.removeChild(node);
551
+ state.tree = state.tree.clone();
552
+ }
553
+ };
554
+ const getFullLabelName = (id) => {
555
+ var _a;
556
+ return ((_a = nodesKeyById[id]) == null ? void 0 : _a.getFullName(locale)) ?? id;
557
+ };
558
+ return {
559
+ ...state,
560
+ flattenedLabels: flattened,
561
+ popularLabels,
562
+ counts,
563
+ getLabelsByIds,
564
+ getLabelName,
565
+ getRelatedLabels,
566
+ getRecommended,
567
+ createLabel,
568
+ addLabelNode,
569
+ updateLabelNode,
570
+ removeLabelNode,
571
+ getFullLabelName
772
572
  };
773
- return { ...state, popularLabels, counts, getLabelsByIds, getLabelName, getRelatedLabels, getRecommended };
774
573
  };
775
574
  const LabelsContainer = unstatedNext.createContainer(useLabels);
776
575
  const LabelsContext = react.createContext({});
@@ -783,7 +582,7 @@ var __publicField = (obj, key, value) => {
783
582
  };
784
583
  }, []);
785
584
  };
786
- function LabelsProvider({ fetchLabels, children }) {
585
+ function LabelsProvider({ fetchLabels, createLabel, children }) {
787
586
  const { locale } = context.useLocaleContext();
788
587
  const [updateCounter, setUpdateCounter] = react.useState(1);
789
588
  const { loading, data } = ahooks.useRequest(fetchLabels, {
@@ -850,9 +649,9 @@ var __publicField = (obj, key, value) => {
850
649
  getFullLabelName
851
650
  };
852
651
  }, [loading, labels, getLabelsById, parseLabelIds, stringifyLabelIds, localizedLabels, getFullLabelName]);
853
- return /* @__PURE__ */ jsxRuntime.jsx(LabelsContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(LabelsContainer.Provider, { initialState: { loading, data }, children }) });
652
+ return /* @__PURE__ */ jsxRuntime.jsx(LabelsContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(LabelsContainer.Provider, { initialState: { loading, data, createLabel }, children }) });
854
653
  }
855
- const getContrastTextColor = (bgcolor) => {
654
+ const getContrastTextColor$1 = (bgcolor) => {
856
655
  try {
857
656
  const ratio = material.getContrastRatio(bgcolor, "#fff");
858
657
  return ratio > 3.5 ? "#fff" : "#111";
@@ -860,7 +659,7 @@ var __publicField = (obj, key, value) => {
860
659
  return "#111";
861
660
  }
862
661
  };
863
- const getAlphaColor = (color, alpha) => {
662
+ const getAlphaColor$1 = (color, alpha) => {
864
663
  try {
865
664
  if (color) {
866
665
  return material.alpha(color, alpha);
@@ -909,8 +708,8 @@ var __publicField = (obj, key, value) => {
909
708
  height: 20,
910
709
  borderRadius: 1,
911
710
  fontSize: 12,
912
- bgcolor: getAlphaColor(item.color, 0.8),
913
- color: getContrastTextColor(item.color)
711
+ bgcolor: getAlphaColor$1(item.color || "#ddd", 0.8),
712
+ color: getContrastTextColor$1(item.color || "#ddd")
914
713
  }
915
714
  },
916
715
  item.id
@@ -920,11 +719,530 @@ var __publicField = (obj, key, value) => {
920
719
  editable && isEmpty && /* @__PURE__ */ jsxRuntime.jsx(material.Button, { color: "inherit", variant: "outlined", startIcon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.LabelOutlined, {}), onClick: () => setEditing(true), children: "Edit labels" })
921
720
  ] });
922
721
  }
923
- exports2.LabelManager = LabelManager;
722
+ const mdiTagPlusOutline = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxRuntime.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" }) });
723
+ function PopperComponent$1({
724
+ disablePortal,
725
+ anchorEl,
726
+ open,
727
+ ...other
728
+ }) {
729
+ return /* @__PURE__ */ jsxRuntime.jsx(
730
+ material.Box,
731
+ {
732
+ ...other,
733
+ sx: (theme) => ({
734
+ [`& .${material.autocompleteClasses.paper}`]: {
735
+ boxShadow: "none",
736
+ margin: 0,
737
+ color: "inherit",
738
+ fontSize: 13
739
+ },
740
+ [`& .${material.autocompleteClasses.listbox}`]: {
741
+ backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128",
742
+ padding: 0,
743
+ [`& .${material.autocompleteClasses.option}`]: {
744
+ minHeight: "auto",
745
+ alignItems: "flex-start",
746
+ padding: 1,
747
+ borderBottom: `1px solid ${theme.palette.mode === "light" ? " #eaecef" : "#30363d"}`,
748
+ '&[aria-selected="true"]': {
749
+ backgroundColor: "transparent"
750
+ },
751
+ [`&.${material.autocompleteClasses.focused}, &.${material.autocompleteClasses.focused}[aria-selected="true"]`]: {
752
+ backgroundColor: theme.palette.action.hover
753
+ }
754
+ }
755
+ },
756
+ [`&.${material.autocompleteClasses.popperDisablePortal}`]: {
757
+ position: "relative"
758
+ }
759
+ })
760
+ }
761
+ );
762
+ }
763
+ function GithubLabelPicker({
764
+ value = [],
765
+ onChange,
766
+ title,
767
+ noLabelsText,
768
+ buttonSx,
769
+ actions,
770
+ trigger,
771
+ multiple = true
772
+ }) {
773
+ const { locale } = context.useLocaleContext();
774
+ const { flattenedLabels: labels, getLabelsByIds, loading, createLabel } = LabelsContainer.useContainer();
775
+ const [anchorEl, setAnchorEl] = react.useState(null);
776
+ const [pendingValue, setPendingValue] = react.useState([]);
777
+ const pendingOptions = react.useMemo(() => getLabelsByIds(pendingValue), [getLabelsByIds, pendingValue]);
778
+ const [inputValue, setInputValue] = react.useState("");
779
+ const exists = react.useMemo(
780
+ () => labels.some((x) => x.data.getName(locale).toLowerCase() === inputValue.toLowerCase()),
781
+ [inputValue, labels, locale]
782
+ );
783
+ const theme = material.useTheme();
784
+ const handleClick = (event) => {
785
+ setPendingValue(value);
786
+ setAnchorEl(event.currentTarget);
787
+ };
788
+ const handleClose = () => {
789
+ onChange == null ? void 0 : onChange(pendingValue);
790
+ setInputValue("");
791
+ if (anchorEl) {
792
+ anchorEl.focus();
793
+ }
794
+ setAnchorEl(null);
795
+ };
796
+ const handleCreate = async () => {
797
+ const { id: id2 } = await createLabel(inputValue);
798
+ setPendingValue([...pendingValue, id2]);
799
+ };
800
+ const open = Boolean(anchorEl);
801
+ const id = open ? "github-label-picker" : void 0;
802
+ if (loading) {
803
+ return null;
804
+ }
805
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
806
+ /* @__PURE__ */ jsxRuntime.jsx(
807
+ material.Box,
808
+ {
809
+ onClick: handleClick,
810
+ sx: {
811
+ display: "flex",
812
+ alignItems: "center"
813
+ },
814
+ children: trigger || /* @__PURE__ */ jsxRuntime.jsx(
815
+ material.Box,
816
+ {
817
+ component: material.ButtonBase,
818
+ disableRipple: true,
819
+ "aria-describedby": id,
820
+ sx: [
821
+ (t) => ({
822
+ width: "100%",
823
+ fontSize: 13,
824
+ color: t.palette.mode === "light" ? "#586069" : "#8b949e",
825
+ fontWeight: 600,
826
+ "&:hover": {
827
+ color: t.palette.mode === "light" ? "primary.main" : "#58a6ff"
828
+ },
829
+ "& svg": {
830
+ width: 22,
831
+ height: 22
832
+ }
833
+ }),
834
+ ...Array.isArray(buttonSx) ? buttonSx : [buttonSx]
835
+ ],
836
+ children: /* @__PURE__ */ jsxRuntime.jsx(mdiTagPlusOutline, {})
837
+ }
838
+ )
839
+ }
840
+ ),
841
+ /* @__PURE__ */ jsxRuntime.jsx(
842
+ material.Box,
843
+ {
844
+ component: material.Popper,
845
+ id,
846
+ open,
847
+ anchorEl,
848
+ placement: "bottom-start",
849
+ sx: (t) => ({
850
+ border: `1px solid ${t.palette.mode === "light" ? "#e1e4e8" : "#30363d"}`,
851
+ boxShadow: `0 8px 24px ${t.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
852
+ borderRadius: "4px",
853
+ width: 300,
854
+ zIndex: t.zIndex.modal,
855
+ fontSize: 13,
856
+ color: t.palette.mode === "light" ? "#24292e" : "#c9d1d9",
857
+ backgroundColor: t.palette.mode === "light" ? "#fff" : "#1c2128"
858
+ }),
859
+ children: /* @__PURE__ */ jsxRuntime.jsx(material.ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
860
+ title && /* @__PURE__ */ jsxRuntime.jsx(
861
+ material.Box,
862
+ {
863
+ sx: {
864
+ borderBottom: `1px solid ${theme.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
865
+ padding: "8px 10px",
866
+ fontWeight: 600
867
+ },
868
+ children: title
869
+ }
870
+ ),
871
+ /* @__PURE__ */ jsxRuntime.jsx(
872
+ material.Autocomplete,
873
+ {
874
+ open: true,
875
+ multiple: true,
876
+ inputValue,
877
+ onInputChange: (event, newInputValue, reason) => {
878
+ if (reason === "reset") {
879
+ return;
880
+ }
881
+ setInputValue(newInputValue);
882
+ },
883
+ onClose: (event, reason) => {
884
+ if (reason === "escape") {
885
+ handleClose();
886
+ }
887
+ },
888
+ value: pendingOptions,
889
+ onChange: (event, newValue, reason) => {
890
+ if (event.type === "keydown" && event.key === "Backspace" && reason === "removeOption") {
891
+ return;
892
+ }
893
+ setPendingValue(newValue.map((x) => x.data.id));
894
+ if (!multiple) {
895
+ onChange == null ? void 0 : onChange(newValue.length ? [newValue[newValue.length - 1].data.id] : []);
896
+ setAnchorEl(null);
897
+ }
898
+ },
899
+ disableCloseOnSelect: true,
900
+ PopperComponent: PopperComponent$1,
901
+ renderTags: () => null,
902
+ noOptionsText: noLabelsText || "No labels",
903
+ renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, children: [
904
+ /* @__PURE__ */ jsxRuntime.jsx(
905
+ material.Box,
906
+ {
907
+ component: DoneIcon,
908
+ sx: { width: 17, height: 17, mr: "5px", ml: "-2px" },
909
+ style: {
910
+ visibility: selected ? "visible" : "hidden"
911
+ }
912
+ }
913
+ ),
914
+ /* @__PURE__ */ jsxRuntime.jsx(
915
+ material.Box,
916
+ {
917
+ component: "span",
918
+ sx: {
919
+ width: 14,
920
+ height: 14,
921
+ flexShrink: 0,
922
+ borderRadius: "3px",
923
+ mr: 1,
924
+ mt: "2px"
925
+ },
926
+ style: { backgroundColor: option.data.color || "#ddd" }
927
+ }
928
+ ),
929
+ /* @__PURE__ */ jsxRuntime.jsx(
930
+ material.Box,
931
+ {
932
+ sx: {
933
+ flexGrow: 1,
934
+ "& span": {
935
+ color: theme.palette.mode === "light" ? "#586069" : "#8b949e"
936
+ }
937
+ },
938
+ children: option.data.getName(locale)
939
+ }
940
+ ),
941
+ /* @__PURE__ */ jsxRuntime.jsx(
942
+ material.Box,
943
+ {
944
+ component: CloseIcon,
945
+ sx: { opacity: 0.6, width: 18, height: 18 },
946
+ style: {
947
+ visibility: selected ? "visible" : "hidden"
948
+ }
949
+ }
950
+ )
951
+ ] }),
952
+ options: [...labels].sort((a, b) => {
953
+ let ai = value.indexOf(a.data.id);
954
+ ai = ai === -1 ? value.length + labels.indexOf(a) : ai;
955
+ let bi = value.indexOf(b.data.id);
956
+ bi = bi === -1 ? value.length + labels.indexOf(b) : bi;
957
+ return ai - bi;
958
+ }),
959
+ getOptionLabel: (option) => option.data.getName(locale),
960
+ renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(
961
+ material.Box,
962
+ {
963
+ component: material.InputBase,
964
+ ref: params.InputProps.ref,
965
+ inputProps: params.inputProps,
966
+ autoFocus: true,
967
+ placeholder: "Filter labels",
968
+ sx: (t) => ({
969
+ padding: 1,
970
+ width: "100%",
971
+ borderBottom: `1px solid ${t.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
972
+ "& input": {
973
+ borderRadius: "4px",
974
+ backgroundColor: t.palette.mode === "light" ? "#fff" : "#0d1117",
975
+ padding: 1,
976
+ transition: t.transitions.create(["border-color", "box-shadow"]),
977
+ border: `1px solid ${t.palette.mode === "light" ? "#eaecef" : "#30363d"}`,
978
+ fontSize: 14,
979
+ "&:focus": {
980
+ boxShadow: `0px 0px 0px 3px ${t.palette.mode === "light" ? material.alpha(t.palette.primary.light, 0.4) : "rgb(12, 45, 107)"}`,
981
+ borderColor: t.palette.mode === "light" ? t.palette.primary.light : "#388bfd"
982
+ }
983
+ }
984
+ })
985
+ }
986
+ )
987
+ }
988
+ ),
989
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
990
+ inputValue && !exists && /* @__PURE__ */ jsxRuntime.jsx(
991
+ material.Box,
992
+ {
993
+ sx: {
994
+ display: "flex",
995
+ alignItems: "center",
996
+ gap: 1,
997
+ width: "100%",
998
+ height: 36,
999
+ px: 2,
1000
+ borderTop: "1px solid #eee",
1001
+ fontSize: 14,
1002
+ color: "grey.600",
1003
+ cursor: "pointer",
1004
+ textDecoration: "none"
1005
+ },
1006
+ onClick: handleCreate,
1007
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1008
+ 'Create new label "',
1009
+ inputValue,
1010
+ '"'
1011
+ ] })
1012
+ }
1013
+ ),
1014
+ actions
1015
+ ] })
1016
+ ] }) })
1017
+ }
1018
+ )
1019
+ ] });
1020
+ }
1021
+ function Tag(props) {
1022
+ const { label, onDelete, ...rest } = props;
1023
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1024
+ material.Box,
1025
+ {
1026
+ ...rest,
1027
+ sx: {
1028
+ boxSizing: "content-box",
1029
+ display: "flex",
1030
+ alignItems: "center",
1031
+ height: 24,
1032
+ margin: "2px",
1033
+ padding: "0 4px 0 10px",
1034
+ border: (theme) => `1px solid ${theme.palette.mode === "dark" ? "#303030" : "#e8e8e8"}`,
1035
+ overflow: "hidden",
1036
+ lineHeight: "22px",
1037
+ fontSize: 14,
1038
+ color: "grey.800",
1039
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.08)" : "#fafafa",
1040
+ borderRadius: "2px",
1041
+ outline: 0,
1042
+ "&:focus": {
1043
+ borderColor: (theme) => `${theme.palette.mode === "dark" ? "#177ddc" : "#40a9ff"}`,
1044
+ bgcolor: (theme) => `${theme.palette.mode === "dark" ? "#003b57" : "#e6f7ff"}`
1045
+ },
1046
+ "& span": {
1047
+ overflow: "hidden",
1048
+ whiteSpace: "nowrap",
1049
+ textOverflow: "ellipsis"
1050
+ },
1051
+ "& svg": {
1052
+ ml: 0.5,
1053
+ p: "4px",
1054
+ fontSize: "12px",
1055
+ color: "grey.500",
1056
+ cursor: "pointer"
1057
+ }
1058
+ },
1059
+ children: [
1060
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
1061
+ /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { onClick: onDelete })
1062
+ ]
1063
+ }
1064
+ );
1065
+ }
1066
+ function PopperComponent(props) {
1067
+ return /* @__PURE__ */ jsxRuntime.jsx(
1068
+ material.Popper,
1069
+ {
1070
+ ...props,
1071
+ sx: (theme) => ({
1072
+ [`& .${material.autocompleteClasses.paper}`]: {
1073
+ border: `1px solid ${theme.palette.mode === "light" ? "#e1e4e8" : "#30363d"}`,
1074
+ boxShadow: `0 8px 24px ${theme.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
1075
+ borderRadius: "4px",
1076
+ color: "inherit",
1077
+ fontSize: 13
1078
+ },
1079
+ [`& .${material.autocompleteClasses.listbox}`]: {
1080
+ backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128",
1081
+ padding: 0,
1082
+ [`& .${material.autocompleteClasses.option}`]: {
1083
+ minHeight: "auto",
1084
+ alignItems: "flex-start",
1085
+ padding: 1,
1086
+ borderBottom: `1px solid ${theme.palette.mode === "light" ? " #eaecef" : "#30363d"}`,
1087
+ '&[aria-selected="true"]': {
1088
+ backgroundColor: "transparent"
1089
+ },
1090
+ [`&.${material.autocompleteClasses.focused}, &.${material.autocompleteClasses.focused}[aria-selected="true"]`]: {
1091
+ backgroundColor: theme.palette.action.hover
1092
+ }
1093
+ }
1094
+ },
1095
+ [`&.${material.autocompleteClasses.popperDisablePortal}`]: {
1096
+ position: "relative"
1097
+ }
1098
+ })
1099
+ }
1100
+ );
1101
+ }
1102
+ function LabelsInput({ value = [], onChange, ...rest }) {
1103
+ const { locale } = context.useLocaleContext();
1104
+ const { flattenedLabels: labels, getLabelsByIds, loading } = LabelsContainer.useContainer();
1105
+ const valueOptions = react.useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
1106
+ if (loading) {
1107
+ return null;
1108
+ }
1109
+ return /* @__PURE__ */ jsxRuntime.jsx(
1110
+ material.Autocomplete,
1111
+ {
1112
+ multiple: true,
1113
+ disableClearable: true,
1114
+ forcePopupIcon: false,
1115
+ size: "small",
1116
+ PopperComponent,
1117
+ value: valueOptions,
1118
+ onChange: (event, newValue) => {
1119
+ onChange(newValue.map((x) => x.data.id));
1120
+ },
1121
+ options: [...labels].sort((a, b) => {
1122
+ let ai = value.indexOf(a.data.id);
1123
+ ai = ai === -1 ? value.length + labels.indexOf(a) : ai;
1124
+ let bi = value.indexOf(b.data.id);
1125
+ bi = bi === -1 ? value.length + labels.indexOf(b) : bi;
1126
+ return ai - bi;
1127
+ }),
1128
+ getOptionLabel: (option) => option.data.getName(locale),
1129
+ renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, children: [
1130
+ /* @__PURE__ */ jsxRuntime.jsx(
1131
+ material.Box,
1132
+ {
1133
+ component: DoneIcon,
1134
+ sx: { width: 17, height: 17, mr: "5px", ml: "-2px" },
1135
+ style: {
1136
+ visibility: selected ? "visible" : "hidden"
1137
+ }
1138
+ }
1139
+ ),
1140
+ /* @__PURE__ */ jsxRuntime.jsx(
1141
+ material.Box,
1142
+ {
1143
+ component: "span",
1144
+ sx: {
1145
+ width: 14,
1146
+ height: 14,
1147
+ flexShrink: 0,
1148
+ borderRadius: "3px",
1149
+ mr: 1,
1150
+ mt: "2px"
1151
+ },
1152
+ style: { backgroundColor: option.data.color || "#ddd" }
1153
+ }
1154
+ ),
1155
+ /* @__PURE__ */ jsxRuntime.jsx(
1156
+ material.Box,
1157
+ {
1158
+ sx: {
1159
+ flexGrow: 1,
1160
+ "& span": {
1161
+ color: (theme) => theme.palette.mode === "light" ? "#586069" : "#8b949e"
1162
+ }
1163
+ },
1164
+ children: option.data.getName(locale)
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ jsxRuntime.jsx(
1168
+ material.Box,
1169
+ {
1170
+ component: CloseIcon,
1171
+ sx: { opacity: 0.6, width: 18, height: 18 },
1172
+ style: {
1173
+ visibility: selected ? "visible" : "hidden"
1174
+ }
1175
+ }
1176
+ )
1177
+ ] }),
1178
+ renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(Tag, { label: option.data.getName(locale), ...getTagProps({ index }) })),
1179
+ style: { minWidth: 300 },
1180
+ renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsx(material.TextField, { ...params, placeholder: "Labels" }),
1181
+ ...rest
1182
+ }
1183
+ );
1184
+ }
1185
+ const getContrastTextColor = (bgcolor) => {
1186
+ try {
1187
+ const ratio = material.getContrastRatio(bgcolor, "#fff");
1188
+ return ratio > 3.5 ? "#fff" : "#111";
1189
+ } catch {
1190
+ return "#111";
1191
+ }
1192
+ };
1193
+ const getAlphaColor = (color, alpha) => {
1194
+ try {
1195
+ if (color) {
1196
+ return material.alpha(color, alpha);
1197
+ }
1198
+ } catch {
1199
+ return color;
1200
+ }
1201
+ return color;
1202
+ };
1203
+ function Labels2({ labels, sx, renderLabel }) {
1204
+ const { getLabelsByIds, loading, getFullLabelName } = LabelsContainer.useContainer();
1205
+ if (loading) {
1206
+ return null;
1207
+ }
1208
+ const labelNodes = getLabelsByIds(labels || []).filter((x) => !x.data.id.startsWith("system:"));
1209
+ const mergedSx = [
1210
+ { display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
1211
+ ...Array.isArray(sx) ? sx : [sx]
1212
+ ];
1213
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: mergedSx, children: labelNodes.map((item) => {
1214
+ if (!item) {
1215
+ return null;
1216
+ }
1217
+ if (renderLabel) {
1218
+ return renderLabel(item);
1219
+ }
1220
+ return /* @__PURE__ */ jsxRuntime.jsx(
1221
+ material.Chip,
1222
+ {
1223
+ label: getFullLabelName(item.data.id),
1224
+ variant: "filled",
1225
+ size: "small",
1226
+ sx: {
1227
+ height: 20,
1228
+ borderRadius: 1,
1229
+ fontSize: 12,
1230
+ bgcolor: getAlphaColor(item.data.color, 0.8),
1231
+ color: getContrastTextColor(item.data.color)
1232
+ }
1233
+ },
1234
+ item.data.id
1235
+ );
1236
+ }) });
1237
+ }
1238
+ exports2.GithubLabelPicker = GithubLabelPicker;
924
1239
  exports2.LabelPicker = LabelPicker;
925
1240
  exports2.LabelTree = LabelTree;
1241
+ exports2.LabelTreeNode = LabelTreeNode;
926
1242
  exports2.Labels = Labels;
1243
+ exports2.Labels2 = Labels2;
927
1244
  exports2.LabelsContainer = LabelsContainer;
1245
+ exports2.LabelsInput = LabelsInput;
928
1246
  exports2.LabelsProvider = LabelsProvider;
929
1247
  exports2.useLabelsContext = useLabelsContext;
930
1248
  exports2.useLabelsUpdateOnDestroy = useLabelsUpdateOnDestroy;