@blocklet/labels 1.6.179 → 1.6.180
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 +203 -187
- package/dist/index.umd.js +204 -188
- package/dist/label2/github-label-picker.d.ts +2 -1
- package/dist/label2/labels2.d.ts +2 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
|
18
18
|
import { useReactive, useRequest, useSize, useDeepCompareLayoutEffect } from "ahooks";
|
|
19
19
|
import { createContainer } from "unstated-next";
|
|
20
20
|
import { arrayToTree } from "performant-array-to-tree";
|
|
21
|
-
import
|
|
21
|
+
import CloseOutlineIcon from "@mui/icons-material/Close";
|
|
22
22
|
import DoneIcon from "@mui/icons-material/Done";
|
|
23
23
|
import chroma from "chroma-js";
|
|
24
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" }) });
|
|
@@ -756,6 +756,197 @@ function Labels({ labels, editable, onChange, sx, renderLabel }) {
|
|
|
756
756
|
] });
|
|
757
757
|
}
|
|
758
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
|
+
}
|
|
759
950
|
function PopperComponent({
|
|
760
951
|
disablePortal,
|
|
761
952
|
anchorEl,
|
|
@@ -806,7 +997,8 @@ function GithubLabelPicker({
|
|
|
806
997
|
trigger,
|
|
807
998
|
multiple = true,
|
|
808
999
|
updateImmediately = true,
|
|
809
|
-
excludes = []
|
|
1000
|
+
excludes = [],
|
|
1001
|
+
disabled = false
|
|
810
1002
|
}) {
|
|
811
1003
|
const { locale } = useLocaleContext();
|
|
812
1004
|
const { flattenedLabels: labels, getLabelsByIds, loading, createLabel } = LabelsContainer.useContainer();
|
|
@@ -824,6 +1016,9 @@ function GithubLabelPicker({
|
|
|
824
1016
|
}, [labels]);
|
|
825
1017
|
const theme = useTheme();
|
|
826
1018
|
const handleClick = (event) => {
|
|
1019
|
+
if (disabled) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
827
1022
|
event.preventDefault();
|
|
828
1023
|
setPendingValue(value);
|
|
829
1024
|
setAnchorEl(event.currentTarget);
|
|
@@ -965,8 +1160,8 @@ function GithubLabelPicker({
|
|
|
965
1160
|
{
|
|
966
1161
|
component: "span",
|
|
967
1162
|
sx: {
|
|
968
|
-
width:
|
|
969
|
-
height:
|
|
1163
|
+
width: 16,
|
|
1164
|
+
height: 16,
|
|
970
1165
|
flexShrink: 0,
|
|
971
1166
|
borderRadius: "3px",
|
|
972
1167
|
mr: 1
|
|
@@ -979,17 +1174,16 @@ function GithubLabelPicker({
|
|
|
979
1174
|
{
|
|
980
1175
|
sx: {
|
|
981
1176
|
flexGrow: 1,
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
1177
|
+
alignItems: "center",
|
|
1178
|
+
display: "flex"
|
|
985
1179
|
},
|
|
986
|
-
children: option
|
|
1180
|
+
children: /* @__PURE__ */ jsx(LabelChip, { label: option, disabled })
|
|
987
1181
|
}
|
|
988
1182
|
),
|
|
989
1183
|
/* @__PURE__ */ jsx(
|
|
990
1184
|
Box$1,
|
|
991
1185
|
{
|
|
992
|
-
component:
|
|
1186
|
+
component: CloseOutlineIcon,
|
|
993
1187
|
sx: { opacity: 0.6, width: 18, height: 18 },
|
|
994
1188
|
style: {
|
|
995
1189
|
visibility: selected ? "visible" : "hidden"
|
|
@@ -1066,184 +1260,6 @@ function GithubLabelPicker({
|
|
|
1066
1260
|
)
|
|
1067
1261
|
] });
|
|
1068
1262
|
}
|
|
1069
|
-
const getTextColor = (color) => {
|
|
1070
|
-
return chroma(color).hex();
|
|
1071
|
-
};
|
|
1072
|
-
const getBorderColor = (color) => {
|
|
1073
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1074
|
-
return chroma(color).darken(3).hex();
|
|
1075
|
-
}
|
|
1076
|
-
return chroma(color).brighten(0.5).alpha(0.25).hex();
|
|
1077
|
-
};
|
|
1078
|
-
const getBackgroundColor = (color) => {
|
|
1079
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1080
|
-
return chroma(color).darken(2.5).hex();
|
|
1081
|
-
}
|
|
1082
|
-
return chroma(color).brighten(2.5).alpha(0.25).hex();
|
|
1083
|
-
};
|
|
1084
|
-
const getFilterStyle = (color) => {
|
|
1085
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1086
|
-
return "brightness(0.85) contrast(1.2)";
|
|
1087
|
-
}
|
|
1088
|
-
return "brightness(0.85) contrast(1.2)";
|
|
1089
|
-
};
|
|
1090
|
-
function LabelChip({
|
|
1091
|
-
label,
|
|
1092
|
-
onDelete,
|
|
1093
|
-
sx,
|
|
1094
|
-
fullName = true,
|
|
1095
|
-
onClick
|
|
1096
|
-
}) {
|
|
1097
|
-
const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
|
|
1098
|
-
const mergedSx = [
|
|
1099
|
-
{
|
|
1100
|
-
height: 20,
|
|
1101
|
-
borderRadius: 0.5,
|
|
1102
|
-
fontSize: 12,
|
|
1103
|
-
fontWeight: 500,
|
|
1104
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
1105
|
-
bgcolor: `${getBackgroundColor(label.data.color)} !important`,
|
|
1106
|
-
transition: "filter 0.2s",
|
|
1107
|
-
borderColor: `${getBorderColor(label.data.color)} !important`,
|
|
1108
|
-
".MuiChip-label": {
|
|
1109
|
-
p: 0.5
|
|
1110
|
-
},
|
|
1111
|
-
span: {},
|
|
1112
|
-
...onClick && {
|
|
1113
|
-
cursor: "pointer",
|
|
1114
|
-
"&:hover": {
|
|
1115
|
-
filter: getFilterStyle(label.data.color)
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
},
|
|
1119
|
-
...Array.isArray(sx) ? sx : [sx]
|
|
1120
|
-
];
|
|
1121
|
-
return (
|
|
1122
|
-
// @ts-ignore
|
|
1123
|
-
/* @__PURE__ */ jsx(
|
|
1124
|
-
Chip,
|
|
1125
|
-
{
|
|
1126
|
-
label: fullName ? getFullLabelName(label.data.id) : getLabelName(label.data.id),
|
|
1127
|
-
variant: "outlined",
|
|
1128
|
-
size: "small",
|
|
1129
|
-
...onDelete && {
|
|
1130
|
-
onDelete: (e) => {
|
|
1131
|
-
e.stopPropagation();
|
|
1132
|
-
e.preventDefault();
|
|
1133
|
-
onDelete(label);
|
|
1134
|
-
},
|
|
1135
|
-
deleteIcon: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
1136
|
-
},
|
|
1137
|
-
...onClick && {
|
|
1138
|
-
onClick: (e) => {
|
|
1139
|
-
e.stopPropagation();
|
|
1140
|
-
e.preventDefault();
|
|
1141
|
-
onClick(label);
|
|
1142
|
-
}
|
|
1143
|
-
},
|
|
1144
|
-
sx: mergedSx
|
|
1145
|
-
},
|
|
1146
|
-
label.data.id
|
|
1147
|
-
)
|
|
1148
|
-
);
|
|
1149
|
-
}
|
|
1150
|
-
function Labels2({
|
|
1151
|
-
compact = true,
|
|
1152
|
-
labels,
|
|
1153
|
-
sx,
|
|
1154
|
-
renderLabel,
|
|
1155
|
-
prepend,
|
|
1156
|
-
displaySystemLabels = true,
|
|
1157
|
-
onItemClick
|
|
1158
|
-
}) {
|
|
1159
|
-
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1160
|
-
const labelsWrapperRef = useRef(null);
|
|
1161
|
-
const [overflowIndex, setOverflowIndex] = useState(99999);
|
|
1162
|
-
let labelNodes = getLabelsByIds(labels || []);
|
|
1163
|
-
const size = useSize(labelsWrapperRef);
|
|
1164
|
-
useDeepCompareLayoutEffect(() => {
|
|
1165
|
-
if (compact) {
|
|
1166
|
-
if (labelsWrapperRef.current) {
|
|
1167
|
-
const { right } = labelsWrapperRef.current.getBoundingClientRect();
|
|
1168
|
-
const labelElements = labelsWrapperRef.current.querySelectorAll(".MuiChip-root");
|
|
1169
|
-
if ((labelElements == null ? void 0 : labelElements.length) > 0) {
|
|
1170
|
-
Array.from(labelElements).some((x, i) => {
|
|
1171
|
-
const rect = x.getBoundingClientRect();
|
|
1172
|
-
if (rect.right > right - 36) {
|
|
1173
|
-
setOverflowIndex(i);
|
|
1174
|
-
return true;
|
|
1175
|
-
}
|
|
1176
|
-
return false;
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
} else {
|
|
1181
|
-
setOverflowIndex(99999);
|
|
1182
|
-
}
|
|
1183
|
-
}, [size, compact]);
|
|
1184
|
-
if (loading) {
|
|
1185
|
-
return null;
|
|
1186
|
-
}
|
|
1187
|
-
if (!displaySystemLabels) {
|
|
1188
|
-
labelNodes = labelNodes.filter((x) => !x.data.id.startsWith("system:"));
|
|
1189
|
-
}
|
|
1190
|
-
const mergedSx = [
|
|
1191
|
-
{
|
|
1192
|
-
display: "flex",
|
|
1193
|
-
gap: 1,
|
|
1194
|
-
width: "100%",
|
|
1195
|
-
alignItems: "center",
|
|
1196
|
-
overflow: "hidden",
|
|
1197
|
-
flexWrap: compact ? "no-wrap" : "wrap"
|
|
1198
|
-
},
|
|
1199
|
-
...Array.isArray(sx) ? sx : [sx]
|
|
1200
|
-
];
|
|
1201
|
-
return /* @__PURE__ */ jsxs(Box$1, { sx: mergedSx, ref: labelsWrapperRef, children: [
|
|
1202
|
-
prepend,
|
|
1203
|
-
labelNodes.map((item, index) => {
|
|
1204
|
-
if (!item) {
|
|
1205
|
-
return null;
|
|
1206
|
-
}
|
|
1207
|
-
const visible = index < overflowIndex;
|
|
1208
|
-
let extra = null;
|
|
1209
|
-
if (index === overflowIndex) {
|
|
1210
|
-
extra = /* @__PURE__ */ jsx(
|
|
1211
|
-
Box$1,
|
|
1212
|
-
{
|
|
1213
|
-
sx: {
|
|
1214
|
-
display: "inline-flex",
|
|
1215
|
-
...compact && { height: 20, lineHeight: "20px" },
|
|
1216
|
-
color: "text.secondary",
|
|
1217
|
-
fontWeight: "bold",
|
|
1218
|
-
fontSize: 14
|
|
1219
|
-
},
|
|
1220
|
-
children: `+${labelNodes.length - overflowIndex}`
|
|
1221
|
-
},
|
|
1222
|
-
"overflow-label"
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
let labelChip = /* @__PURE__ */ jsx(
|
|
1226
|
-
LabelChip,
|
|
1227
|
-
{
|
|
1228
|
-
label: item,
|
|
1229
|
-
onClick: onItemClick,
|
|
1230
|
-
sx: {
|
|
1231
|
-
visibility: visible ? "visible" : "hidden",
|
|
1232
|
-
pointerEvents: visible ? "auto" : "none"
|
|
1233
|
-
}
|
|
1234
|
-
},
|
|
1235
|
-
item.data.id
|
|
1236
|
-
);
|
|
1237
|
-
if (renderLabel) {
|
|
1238
|
-
labelChip = renderLabel(item, labelChip);
|
|
1239
|
-
}
|
|
1240
|
-
if (extra) {
|
|
1241
|
-
return [extra, labelChip];
|
|
1242
|
-
}
|
|
1243
|
-
return labelChip;
|
|
1244
|
-
})
|
|
1245
|
-
] });
|
|
1246
|
-
}
|
|
1247
1263
|
function LabelsInput({
|
|
1248
1264
|
value = [],
|
|
1249
1265
|
onChange,
|
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"), 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"), require("chroma-js")) : 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", "chroma-js"], 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.
|
|
3
|
-
})(this, function(exports2, jsxRuntime, react, iconsMaterial, Box, styles, reactArborist, react$1, omit, Select, material, context, ahooks, 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"), require("chroma-js")) : 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", "chroma-js"], 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.CloseOutlineIcon, global.DoneIcon, global.chroma));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, react, iconsMaterial, Box, styles, reactArborist, react$1, omit, Select, material, context, ahooks, unstatedNext, performantArrayToTree, CloseOutlineIcon, DoneIcon, chroma) {
|
|
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) => {
|
|
@@ -743,6 +743,197 @@ var __publicField = (obj, key, value) => {
|
|
|
743
743
|
] });
|
|
744
744
|
}
|
|
745
745
|
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" }) });
|
|
746
|
+
const getTextColor = (color) => {
|
|
747
|
+
return chroma(color).hex();
|
|
748
|
+
};
|
|
749
|
+
const getBorderColor = (color) => {
|
|
750
|
+
if (chroma(color).luminance() > 0.5) {
|
|
751
|
+
return chroma(color).darken(3).hex();
|
|
752
|
+
}
|
|
753
|
+
return chroma(color).brighten(0.5).alpha(0.25).hex();
|
|
754
|
+
};
|
|
755
|
+
const getBackgroundColor = (color) => {
|
|
756
|
+
if (chroma(color).luminance() > 0.5) {
|
|
757
|
+
return chroma(color).darken(2.5).hex();
|
|
758
|
+
}
|
|
759
|
+
return chroma(color).brighten(2.5).alpha(0.25).hex();
|
|
760
|
+
};
|
|
761
|
+
const getFilterStyle = (color) => {
|
|
762
|
+
if (chroma(color).luminance() > 0.5) {
|
|
763
|
+
return "brightness(0.85) contrast(1.2)";
|
|
764
|
+
}
|
|
765
|
+
return "brightness(0.85) contrast(1.2)";
|
|
766
|
+
};
|
|
767
|
+
function LabelChip({
|
|
768
|
+
label,
|
|
769
|
+
onDelete,
|
|
770
|
+
sx,
|
|
771
|
+
fullName = true,
|
|
772
|
+
onClick,
|
|
773
|
+
disabled = false
|
|
774
|
+
}) {
|
|
775
|
+
const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
|
|
776
|
+
const mergedSx = [
|
|
777
|
+
{
|
|
778
|
+
height: 20,
|
|
779
|
+
borderRadius: 0.5,
|
|
780
|
+
fontSize: 12,
|
|
781
|
+
fontWeight: 500,
|
|
782
|
+
color: `${getTextColor(label.data.color)} !important`,
|
|
783
|
+
bgcolor: `${getBackgroundColor(label.data.color)} !important`,
|
|
784
|
+
transition: "filter 0.2s",
|
|
785
|
+
borderColor: `${getBorderColor(label.data.color)} !important`,
|
|
786
|
+
// -webkit-text-fill-color
|
|
787
|
+
WebkitTextFillColor: `${getTextColor(label.data.color)} !important`,
|
|
788
|
+
".MuiChip-deleteIcon": {
|
|
789
|
+
color: `${getTextColor(label.data.color)} !important`,
|
|
790
|
+
cursor: "pointer",
|
|
791
|
+
transition: "transform 0.3s",
|
|
792
|
+
"&:hover": {
|
|
793
|
+
transform: "rotate(90deg)"
|
|
794
|
+
}
|
|
795
|
+
},
|
|
796
|
+
".MuiChip-label": {
|
|
797
|
+
px: 0.5,
|
|
798
|
+
maxHeight: 20
|
|
799
|
+
},
|
|
800
|
+
...onClick && {
|
|
801
|
+
cursor: "pointer",
|
|
802
|
+
"&:hover": {
|
|
803
|
+
filter: getFilterStyle(label.data.color)
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
808
|
+
];
|
|
809
|
+
const hasDelete = !disabled && !!onDelete;
|
|
810
|
+
const hasOnClick = !disabled && !!onClick;
|
|
811
|
+
return (
|
|
812
|
+
// @ts-ignore
|
|
813
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
814
|
+
material.Chip,
|
|
815
|
+
{
|
|
816
|
+
label: fullName ? getFullLabelName(label.data.id) : getLabelName(label.data.id),
|
|
817
|
+
variant: "outlined",
|
|
818
|
+
size: "small",
|
|
819
|
+
...hasDelete && {
|
|
820
|
+
onDelete: (e) => {
|
|
821
|
+
e.stopPropagation();
|
|
822
|
+
e.preventDefault();
|
|
823
|
+
onDelete(label);
|
|
824
|
+
},
|
|
825
|
+
deleteIcon: /* @__PURE__ */ jsxRuntime.jsx(CloseOutlineIcon, {})
|
|
826
|
+
},
|
|
827
|
+
...hasOnClick && {
|
|
828
|
+
onClick: (e) => {
|
|
829
|
+
e.stopPropagation();
|
|
830
|
+
e.preventDefault();
|
|
831
|
+
onClick(label);
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
sx: mergedSx
|
|
835
|
+
},
|
|
836
|
+
label.data.id
|
|
837
|
+
)
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
function Labels2({
|
|
841
|
+
compact = true,
|
|
842
|
+
labels,
|
|
843
|
+
sx,
|
|
844
|
+
renderLabel,
|
|
845
|
+
prepend,
|
|
846
|
+
displaySystemLabels = true,
|
|
847
|
+
onItemClick
|
|
848
|
+
}) {
|
|
849
|
+
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
850
|
+
const labelsWrapperRef = react.useRef(null);
|
|
851
|
+
const [overflowIndex, setOverflowIndex] = react.useState(99999);
|
|
852
|
+
let labelNodes = getLabelsByIds(labels || []);
|
|
853
|
+
const size = ahooks.useSize(labelsWrapperRef);
|
|
854
|
+
ahooks.useDeepCompareLayoutEffect(() => {
|
|
855
|
+
if (compact) {
|
|
856
|
+
if (labelsWrapperRef.current) {
|
|
857
|
+
const { right } = labelsWrapperRef.current.getBoundingClientRect();
|
|
858
|
+
const labelElements = labelsWrapperRef.current.querySelectorAll(".MuiChip-root");
|
|
859
|
+
if ((labelElements == null ? void 0 : labelElements.length) > 0) {
|
|
860
|
+
Array.from(labelElements).some((x, i) => {
|
|
861
|
+
const rect = x.getBoundingClientRect();
|
|
862
|
+
if (rect.right > right - 36) {
|
|
863
|
+
setOverflowIndex(i);
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
return false;
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
} else {
|
|
871
|
+
setOverflowIndex(99999);
|
|
872
|
+
}
|
|
873
|
+
}, [size, compact]);
|
|
874
|
+
if (loading) {
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
if (!displaySystemLabels) {
|
|
878
|
+
labelNodes = labelNodes.filter((x) => !x.data.id.startsWith("system:"));
|
|
879
|
+
}
|
|
880
|
+
const mergedSx = [
|
|
881
|
+
{
|
|
882
|
+
display: "flex",
|
|
883
|
+
gap: 1,
|
|
884
|
+
width: "100%",
|
|
885
|
+
alignItems: "center",
|
|
886
|
+
overflow: "hidden",
|
|
887
|
+
flexWrap: compact ? "no-wrap" : "wrap"
|
|
888
|
+
},
|
|
889
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
890
|
+
];
|
|
891
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, ref: labelsWrapperRef, children: [
|
|
892
|
+
prepend,
|
|
893
|
+
labelNodes.map((item, index) => {
|
|
894
|
+
if (!item) {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
const visible = index < overflowIndex;
|
|
898
|
+
let extra = null;
|
|
899
|
+
if (index === overflowIndex) {
|
|
900
|
+
extra = /* @__PURE__ */ jsxRuntime.jsx(
|
|
901
|
+
material.Box,
|
|
902
|
+
{
|
|
903
|
+
sx: {
|
|
904
|
+
display: "inline-flex",
|
|
905
|
+
...compact && { height: 20, lineHeight: "20px" },
|
|
906
|
+
color: "text.secondary",
|
|
907
|
+
fontWeight: "bold",
|
|
908
|
+
fontSize: 14
|
|
909
|
+
},
|
|
910
|
+
children: `+${labelNodes.length - overflowIndex}`
|
|
911
|
+
},
|
|
912
|
+
"overflow-label"
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
let labelChip = /* @__PURE__ */ jsxRuntime.jsx(
|
|
916
|
+
LabelChip,
|
|
917
|
+
{
|
|
918
|
+
label: item,
|
|
919
|
+
onClick: onItemClick,
|
|
920
|
+
sx: {
|
|
921
|
+
visibility: visible ? "visible" : "hidden",
|
|
922
|
+
pointerEvents: visible ? "auto" : "none"
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
item.data.id
|
|
926
|
+
);
|
|
927
|
+
if (renderLabel) {
|
|
928
|
+
labelChip = renderLabel(item, labelChip);
|
|
929
|
+
}
|
|
930
|
+
if (extra) {
|
|
931
|
+
return [extra, labelChip];
|
|
932
|
+
}
|
|
933
|
+
return labelChip;
|
|
934
|
+
})
|
|
935
|
+
] });
|
|
936
|
+
}
|
|
746
937
|
function PopperComponent({
|
|
747
938
|
disablePortal,
|
|
748
939
|
anchorEl,
|
|
@@ -793,7 +984,8 @@ var __publicField = (obj, key, value) => {
|
|
|
793
984
|
trigger,
|
|
794
985
|
multiple = true,
|
|
795
986
|
updateImmediately = true,
|
|
796
|
-
excludes = []
|
|
987
|
+
excludes = [],
|
|
988
|
+
disabled = false
|
|
797
989
|
}) {
|
|
798
990
|
const { locale } = context.useLocaleContext();
|
|
799
991
|
const { flattenedLabels: labels, getLabelsByIds, loading, createLabel } = LabelsContainer.useContainer();
|
|
@@ -811,6 +1003,9 @@ var __publicField = (obj, key, value) => {
|
|
|
811
1003
|
}, [labels]);
|
|
812
1004
|
const theme = material.useTheme();
|
|
813
1005
|
const handleClick = (event) => {
|
|
1006
|
+
if (disabled) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
814
1009
|
event.preventDefault();
|
|
815
1010
|
setPendingValue(value);
|
|
816
1011
|
setAnchorEl(event.currentTarget);
|
|
@@ -952,8 +1147,8 @@ var __publicField = (obj, key, value) => {
|
|
|
952
1147
|
{
|
|
953
1148
|
component: "span",
|
|
954
1149
|
sx: {
|
|
955
|
-
width:
|
|
956
|
-
height:
|
|
1150
|
+
width: 16,
|
|
1151
|
+
height: 16,
|
|
957
1152
|
flexShrink: 0,
|
|
958
1153
|
borderRadius: "3px",
|
|
959
1154
|
mr: 1
|
|
@@ -966,17 +1161,16 @@ var __publicField = (obj, key, value) => {
|
|
|
966
1161
|
{
|
|
967
1162
|
sx: {
|
|
968
1163
|
flexGrow: 1,
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
1164
|
+
alignItems: "center",
|
|
1165
|
+
display: "flex"
|
|
972
1166
|
},
|
|
973
|
-
children:
|
|
1167
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: option, disabled })
|
|
974
1168
|
}
|
|
975
1169
|
),
|
|
976
1170
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
977
1171
|
material.Box,
|
|
978
1172
|
{
|
|
979
|
-
component:
|
|
1173
|
+
component: CloseOutlineIcon,
|
|
980
1174
|
sx: { opacity: 0.6, width: 18, height: 18 },
|
|
981
1175
|
style: {
|
|
982
1176
|
visibility: selected ? "visible" : "hidden"
|
|
@@ -1053,184 +1247,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1053
1247
|
)
|
|
1054
1248
|
] });
|
|
1055
1249
|
}
|
|
1056
|
-
const getTextColor = (color) => {
|
|
1057
|
-
return chroma(color).hex();
|
|
1058
|
-
};
|
|
1059
|
-
const getBorderColor = (color) => {
|
|
1060
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1061
|
-
return chroma(color).darken(3).hex();
|
|
1062
|
-
}
|
|
1063
|
-
return chroma(color).brighten(0.5).alpha(0.25).hex();
|
|
1064
|
-
};
|
|
1065
|
-
const getBackgroundColor = (color) => {
|
|
1066
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1067
|
-
return chroma(color).darken(2.5).hex();
|
|
1068
|
-
}
|
|
1069
|
-
return chroma(color).brighten(2.5).alpha(0.25).hex();
|
|
1070
|
-
};
|
|
1071
|
-
const getFilterStyle = (color) => {
|
|
1072
|
-
if (chroma(color).luminance() > 0.5) {
|
|
1073
|
-
return "brightness(0.85) contrast(1.2)";
|
|
1074
|
-
}
|
|
1075
|
-
return "brightness(0.85) contrast(1.2)";
|
|
1076
|
-
};
|
|
1077
|
-
function LabelChip({
|
|
1078
|
-
label,
|
|
1079
|
-
onDelete,
|
|
1080
|
-
sx,
|
|
1081
|
-
fullName = true,
|
|
1082
|
-
onClick
|
|
1083
|
-
}) {
|
|
1084
|
-
const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
|
|
1085
|
-
const mergedSx = [
|
|
1086
|
-
{
|
|
1087
|
-
height: 20,
|
|
1088
|
-
borderRadius: 0.5,
|
|
1089
|
-
fontSize: 12,
|
|
1090
|
-
fontWeight: 500,
|
|
1091
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
1092
|
-
bgcolor: `${getBackgroundColor(label.data.color)} !important`,
|
|
1093
|
-
transition: "filter 0.2s",
|
|
1094
|
-
borderColor: `${getBorderColor(label.data.color)} !important`,
|
|
1095
|
-
".MuiChip-label": {
|
|
1096
|
-
p: 0.5
|
|
1097
|
-
},
|
|
1098
|
-
span: {},
|
|
1099
|
-
...onClick && {
|
|
1100
|
-
cursor: "pointer",
|
|
1101
|
-
"&:hover": {
|
|
1102
|
-
filter: getFilterStyle(label.data.color)
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
},
|
|
1106
|
-
...Array.isArray(sx) ? sx : [sx]
|
|
1107
|
-
];
|
|
1108
|
-
return (
|
|
1109
|
-
// @ts-ignore
|
|
1110
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1111
|
-
material.Chip,
|
|
1112
|
-
{
|
|
1113
|
-
label: fullName ? getFullLabelName(label.data.id) : getLabelName(label.data.id),
|
|
1114
|
-
variant: "outlined",
|
|
1115
|
-
size: "small",
|
|
1116
|
-
...onDelete && {
|
|
1117
|
-
onDelete: (e) => {
|
|
1118
|
-
e.stopPropagation();
|
|
1119
|
-
e.preventDefault();
|
|
1120
|
-
onDelete(label);
|
|
1121
|
-
},
|
|
1122
|
-
deleteIcon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
1123
|
-
},
|
|
1124
|
-
...onClick && {
|
|
1125
|
-
onClick: (e) => {
|
|
1126
|
-
e.stopPropagation();
|
|
1127
|
-
e.preventDefault();
|
|
1128
|
-
onClick(label);
|
|
1129
|
-
}
|
|
1130
|
-
},
|
|
1131
|
-
sx: mergedSx
|
|
1132
|
-
},
|
|
1133
|
-
label.data.id
|
|
1134
|
-
)
|
|
1135
|
-
);
|
|
1136
|
-
}
|
|
1137
|
-
function Labels2({
|
|
1138
|
-
compact = true,
|
|
1139
|
-
labels,
|
|
1140
|
-
sx,
|
|
1141
|
-
renderLabel,
|
|
1142
|
-
prepend,
|
|
1143
|
-
displaySystemLabels = true,
|
|
1144
|
-
onItemClick
|
|
1145
|
-
}) {
|
|
1146
|
-
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1147
|
-
const labelsWrapperRef = react.useRef(null);
|
|
1148
|
-
const [overflowIndex, setOverflowIndex] = react.useState(99999);
|
|
1149
|
-
let labelNodes = getLabelsByIds(labels || []);
|
|
1150
|
-
const size = ahooks.useSize(labelsWrapperRef);
|
|
1151
|
-
ahooks.useDeepCompareLayoutEffect(() => {
|
|
1152
|
-
if (compact) {
|
|
1153
|
-
if (labelsWrapperRef.current) {
|
|
1154
|
-
const { right } = labelsWrapperRef.current.getBoundingClientRect();
|
|
1155
|
-
const labelElements = labelsWrapperRef.current.querySelectorAll(".MuiChip-root");
|
|
1156
|
-
if ((labelElements == null ? void 0 : labelElements.length) > 0) {
|
|
1157
|
-
Array.from(labelElements).some((x, i) => {
|
|
1158
|
-
const rect = x.getBoundingClientRect();
|
|
1159
|
-
if (rect.right > right - 36) {
|
|
1160
|
-
setOverflowIndex(i);
|
|
1161
|
-
return true;
|
|
1162
|
-
}
|
|
1163
|
-
return false;
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
} else {
|
|
1168
|
-
setOverflowIndex(99999);
|
|
1169
|
-
}
|
|
1170
|
-
}, [size, compact]);
|
|
1171
|
-
if (loading) {
|
|
1172
|
-
return null;
|
|
1173
|
-
}
|
|
1174
|
-
if (!displaySystemLabels) {
|
|
1175
|
-
labelNodes = labelNodes.filter((x) => !x.data.id.startsWith("system:"));
|
|
1176
|
-
}
|
|
1177
|
-
const mergedSx = [
|
|
1178
|
-
{
|
|
1179
|
-
display: "flex",
|
|
1180
|
-
gap: 1,
|
|
1181
|
-
width: "100%",
|
|
1182
|
-
alignItems: "center",
|
|
1183
|
-
overflow: "hidden",
|
|
1184
|
-
flexWrap: compact ? "no-wrap" : "wrap"
|
|
1185
|
-
},
|
|
1186
|
-
...Array.isArray(sx) ? sx : [sx]
|
|
1187
|
-
];
|
|
1188
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, ref: labelsWrapperRef, children: [
|
|
1189
|
-
prepend,
|
|
1190
|
-
labelNodes.map((item, index) => {
|
|
1191
|
-
if (!item) {
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
const visible = index < overflowIndex;
|
|
1195
|
-
let extra = null;
|
|
1196
|
-
if (index === overflowIndex) {
|
|
1197
|
-
extra = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1198
|
-
material.Box,
|
|
1199
|
-
{
|
|
1200
|
-
sx: {
|
|
1201
|
-
display: "inline-flex",
|
|
1202
|
-
...compact && { height: 20, lineHeight: "20px" },
|
|
1203
|
-
color: "text.secondary",
|
|
1204
|
-
fontWeight: "bold",
|
|
1205
|
-
fontSize: 14
|
|
1206
|
-
},
|
|
1207
|
-
children: `+${labelNodes.length - overflowIndex}`
|
|
1208
|
-
},
|
|
1209
|
-
"overflow-label"
|
|
1210
|
-
);
|
|
1211
|
-
}
|
|
1212
|
-
let labelChip = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1213
|
-
LabelChip,
|
|
1214
|
-
{
|
|
1215
|
-
label: item,
|
|
1216
|
-
onClick: onItemClick,
|
|
1217
|
-
sx: {
|
|
1218
|
-
visibility: visible ? "visible" : "hidden",
|
|
1219
|
-
pointerEvents: visible ? "auto" : "none"
|
|
1220
|
-
}
|
|
1221
|
-
},
|
|
1222
|
-
item.data.id
|
|
1223
|
-
);
|
|
1224
|
-
if (renderLabel) {
|
|
1225
|
-
labelChip = renderLabel(item, labelChip);
|
|
1226
|
-
}
|
|
1227
|
-
if (extra) {
|
|
1228
|
-
return [extra, labelChip];
|
|
1229
|
-
}
|
|
1230
|
-
return labelChip;
|
|
1231
|
-
})
|
|
1232
|
-
] });
|
|
1233
|
-
}
|
|
1234
1250
|
function LabelsInput({
|
|
1235
1251
|
value = [],
|
|
1236
1252
|
onChange,
|
|
@@ -11,5 +11,6 @@ export interface GithubLabelPickerProps {
|
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
updateImmediately?: boolean;
|
|
13
13
|
excludes?: string[];
|
|
14
|
+
disabled?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare function GithubLabelPicker({ value, onChange, title, noLabelsText, buttonSx, actions, trigger, multiple, updateImmediately, excludes, }: GithubLabelPickerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export declare function GithubLabelPicker({ value, onChange, title, noLabelsText, buttonSx, actions, trigger, multiple, updateImmediately, excludes, disabled, }: GithubLabelPickerProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/label2/labels2.d.ts
CHANGED
|
@@ -10,12 +10,13 @@ interface LabelsProps {
|
|
|
10
10
|
onItemClick?: (label: LabelTreeNode) => void;
|
|
11
11
|
compact?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare function LabelChip({ label, onDelete, sx, fullName, onClick, }: {
|
|
13
|
+
export declare function LabelChip({ label, onDelete, sx, fullName, onClick, disabled, }: {
|
|
14
14
|
label: LabelTreeNode;
|
|
15
15
|
onDelete?: (label: LabelTreeNode) => void;
|
|
16
16
|
sx?: SxProps;
|
|
17
17
|
fullName?: boolean;
|
|
18
18
|
onClick?: (label: LabelTreeNode) => void;
|
|
19
|
+
disabled?: boolean;
|
|
19
20
|
}): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export declare function Labels2({ compact, labels, sx, renderLabel, prepend, displaySystemLabels, onItemClick, }: LabelsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
21
22
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/labels",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.180",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@blocklet/translation-input": "1.6.
|
|
31
|
+
"@blocklet/translation-input": "1.6.180",
|
|
32
32
|
"@emotion/css": "^11.10.5",
|
|
33
33
|
"@emotion/react": "^11.10.5",
|
|
34
34
|
"@emotion/styled": "^11.10.5",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"resolutions": {
|
|
83
83
|
"react": "^18.2.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "87889daed2a12027c6d43c52ca59c1bdbacc764c"
|
|
86
86
|
}
|