@blocklet/labels 1.6.10 → 1.6.11
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 +66 -191
- package/dist/index.umd.js +66 -191
- package/dist/label2/labels-input.d.ts +2 -1
- package/dist/label2/labels2.d.ts +6 -2
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -732,7 +732,7 @@ function Labels({ labels, editable, onChange, sx, renderLabel }) {
|
|
|
732
732
|
] });
|
|
733
733
|
}
|
|
734
734
|
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" }) });
|
|
735
|
-
function PopperComponent
|
|
735
|
+
function PopperComponent({
|
|
736
736
|
disablePortal,
|
|
737
737
|
anchorEl,
|
|
738
738
|
open,
|
|
@@ -794,6 +794,7 @@ function GithubLabelPicker({
|
|
|
794
794
|
);
|
|
795
795
|
const theme = useTheme();
|
|
796
796
|
const handleClick = (event) => {
|
|
797
|
+
event.preventDefault();
|
|
797
798
|
setPendingValue(value);
|
|
798
799
|
setAnchorEl(event.currentTarget);
|
|
799
800
|
};
|
|
@@ -829,6 +830,7 @@ function GithubLabelPicker({
|
|
|
829
830
|
component: ButtonBase,
|
|
830
831
|
disableRipple: true,
|
|
831
832
|
"aria-describedby": id,
|
|
833
|
+
className: "label-picker-trigger",
|
|
832
834
|
sx: [
|
|
833
835
|
(t) => ({
|
|
834
836
|
width: "100%",
|
|
@@ -909,7 +911,7 @@ function GithubLabelPicker({
|
|
|
909
911
|
}
|
|
910
912
|
},
|
|
911
913
|
disableCloseOnSelect: true,
|
|
912
|
-
PopperComponent
|
|
914
|
+
PopperComponent,
|
|
913
915
|
renderTags: () => null,
|
|
914
916
|
noOptionsText: noLabelsText || "No labels",
|
|
915
917
|
renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxs("li", { ...props, children: [
|
|
@@ -1030,170 +1032,6 @@ function GithubLabelPicker({
|
|
|
1030
1032
|
)
|
|
1031
1033
|
] });
|
|
1032
1034
|
}
|
|
1033
|
-
function Tag(props) {
|
|
1034
|
-
const { label, onDelete, ...rest } = props;
|
|
1035
|
-
return /* @__PURE__ */ jsxs(
|
|
1036
|
-
Box$1,
|
|
1037
|
-
{
|
|
1038
|
-
...rest,
|
|
1039
|
-
sx: {
|
|
1040
|
-
boxSizing: "content-box",
|
|
1041
|
-
display: "flex",
|
|
1042
|
-
alignItems: "center",
|
|
1043
|
-
height: 24,
|
|
1044
|
-
margin: "2px",
|
|
1045
|
-
padding: "0 4px 0 10px",
|
|
1046
|
-
border: (theme) => `1px solid ${theme.palette.mode === "dark" ? "#303030" : "#e8e8e8"}`,
|
|
1047
|
-
overflow: "hidden",
|
|
1048
|
-
lineHeight: "22px",
|
|
1049
|
-
fontSize: 14,
|
|
1050
|
-
color: "grey.800",
|
|
1051
|
-
bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.08)" : "#fafafa",
|
|
1052
|
-
borderRadius: "2px",
|
|
1053
|
-
outline: 0,
|
|
1054
|
-
"&:focus": {
|
|
1055
|
-
borderColor: (theme) => `${theme.palette.mode === "dark" ? "#177ddc" : "#40a9ff"}`,
|
|
1056
|
-
bgcolor: (theme) => `${theme.palette.mode === "dark" ? "#003b57" : "#e6f7ff"}`
|
|
1057
|
-
},
|
|
1058
|
-
"& span": {
|
|
1059
|
-
overflow: "hidden",
|
|
1060
|
-
whiteSpace: "nowrap",
|
|
1061
|
-
textOverflow: "ellipsis"
|
|
1062
|
-
},
|
|
1063
|
-
"& svg": {
|
|
1064
|
-
ml: 0.5,
|
|
1065
|
-
p: "4px",
|
|
1066
|
-
fontSize: "12px",
|
|
1067
|
-
color: "grey.500",
|
|
1068
|
-
cursor: "pointer"
|
|
1069
|
-
}
|
|
1070
|
-
},
|
|
1071
|
-
children: [
|
|
1072
|
-
/* @__PURE__ */ jsx("span", { children: label }),
|
|
1073
|
-
/* @__PURE__ */ jsx(CloseIcon, { onClick: onDelete })
|
|
1074
|
-
]
|
|
1075
|
-
}
|
|
1076
|
-
);
|
|
1077
|
-
}
|
|
1078
|
-
function PopperComponent(props) {
|
|
1079
|
-
return /* @__PURE__ */ jsx(
|
|
1080
|
-
Popper,
|
|
1081
|
-
{
|
|
1082
|
-
...props,
|
|
1083
|
-
sx: (theme) => ({
|
|
1084
|
-
[`& .${autocompleteClasses.paper}`]: {
|
|
1085
|
-
border: `1px solid ${theme.palette.mode === "light" ? "#e1e4e8" : "#30363d"}`,
|
|
1086
|
-
boxShadow: `0 8px 24px ${theme.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
|
|
1087
|
-
borderRadius: "4px",
|
|
1088
|
-
color: "inherit",
|
|
1089
|
-
fontSize: 13
|
|
1090
|
-
},
|
|
1091
|
-
[`& .${autocompleteClasses.listbox}`]: {
|
|
1092
|
-
backgroundColor: theme.palette.mode === "light" ? "#fff" : "#1c2128",
|
|
1093
|
-
padding: 0,
|
|
1094
|
-
[`& .${autocompleteClasses.option}`]: {
|
|
1095
|
-
minHeight: "auto",
|
|
1096
|
-
alignItems: "flex-start",
|
|
1097
|
-
padding: 1,
|
|
1098
|
-
borderBottom: `1px solid ${theme.palette.mode === "light" ? " #eaecef" : "#30363d"}`,
|
|
1099
|
-
'&[aria-selected="true"]': {
|
|
1100
|
-
backgroundColor: "transparent"
|
|
1101
|
-
},
|
|
1102
|
-
[`&.${autocompleteClasses.focused}, &.${autocompleteClasses.focused}[aria-selected="true"]`]: {
|
|
1103
|
-
backgroundColor: theme.palette.action.hover
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
},
|
|
1107
|
-
[`&.${autocompleteClasses.popperDisablePortal}`]: {
|
|
1108
|
-
position: "relative"
|
|
1109
|
-
}
|
|
1110
|
-
})
|
|
1111
|
-
}
|
|
1112
|
-
);
|
|
1113
|
-
}
|
|
1114
|
-
function LabelsInput({ value = [], onChange, ...rest }) {
|
|
1115
|
-
const { locale } = useLocaleContext();
|
|
1116
|
-
const { flattenedLabels: labels, getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1117
|
-
const valueOptions = useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
|
|
1118
|
-
if (loading) {
|
|
1119
|
-
return null;
|
|
1120
|
-
}
|
|
1121
|
-
return /* @__PURE__ */ jsx(
|
|
1122
|
-
Autocomplete,
|
|
1123
|
-
{
|
|
1124
|
-
multiple: true,
|
|
1125
|
-
disableClearable: true,
|
|
1126
|
-
forcePopupIcon: false,
|
|
1127
|
-
size: "small",
|
|
1128
|
-
PopperComponent,
|
|
1129
|
-
value: valueOptions,
|
|
1130
|
-
onChange: (event, newValue) => {
|
|
1131
|
-
onChange(newValue.map((x) => x.data.id));
|
|
1132
|
-
},
|
|
1133
|
-
options: [...labels].sort((a, b) => {
|
|
1134
|
-
let ai = value.indexOf(a.data.id);
|
|
1135
|
-
ai = ai === -1 ? value.length + labels.indexOf(a) : ai;
|
|
1136
|
-
let bi = value.indexOf(b.data.id);
|
|
1137
|
-
bi = bi === -1 ? value.length + labels.indexOf(b) : bi;
|
|
1138
|
-
return ai - bi;
|
|
1139
|
-
}),
|
|
1140
|
-
getOptionLabel: (option) => option.data.getName(locale),
|
|
1141
|
-
renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxs("li", { ...props, children: [
|
|
1142
|
-
/* @__PURE__ */ jsx(
|
|
1143
|
-
Box$1,
|
|
1144
|
-
{
|
|
1145
|
-
component: DoneIcon,
|
|
1146
|
-
sx: { width: 17, height: 17, mr: "5px", ml: "-2px" },
|
|
1147
|
-
style: {
|
|
1148
|
-
visibility: selected ? "visible" : "hidden"
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
),
|
|
1152
|
-
/* @__PURE__ */ jsx(
|
|
1153
|
-
Box$1,
|
|
1154
|
-
{
|
|
1155
|
-
component: "span",
|
|
1156
|
-
sx: {
|
|
1157
|
-
width: 14,
|
|
1158
|
-
height: 14,
|
|
1159
|
-
flexShrink: 0,
|
|
1160
|
-
borderRadius: "3px",
|
|
1161
|
-
mr: 1,
|
|
1162
|
-
mt: "2px"
|
|
1163
|
-
},
|
|
1164
|
-
style: { backgroundColor: option.data.color || "#ddd" }
|
|
1165
|
-
}
|
|
1166
|
-
),
|
|
1167
|
-
/* @__PURE__ */ jsx(
|
|
1168
|
-
Box$1,
|
|
1169
|
-
{
|
|
1170
|
-
sx: {
|
|
1171
|
-
flexGrow: 1,
|
|
1172
|
-
"& span": {
|
|
1173
|
-
color: (theme) => theme.palette.mode === "light" ? "#586069" : "#8b949e"
|
|
1174
|
-
}
|
|
1175
|
-
},
|
|
1176
|
-
children: option.data.getName(locale)
|
|
1177
|
-
}
|
|
1178
|
-
),
|
|
1179
|
-
/* @__PURE__ */ jsx(
|
|
1180
|
-
Box$1,
|
|
1181
|
-
{
|
|
1182
|
-
component: CloseIcon,
|
|
1183
|
-
sx: { opacity: 0.6, width: 18, height: 18 },
|
|
1184
|
-
style: {
|
|
1185
|
-
visibility: selected ? "visible" : "hidden"
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
)
|
|
1189
|
-
] }),
|
|
1190
|
-
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ jsx(Tag, { label: option.data.getName(locale), ...getTagProps({ index }) })),
|
|
1191
|
-
style: { minWidth: 300 },
|
|
1192
|
-
renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, placeholder: "Labels" }),
|
|
1193
|
-
...rest
|
|
1194
|
-
}
|
|
1195
|
-
);
|
|
1196
|
-
}
|
|
1197
1035
|
const getContrastTextColor = (bgcolor) => {
|
|
1198
1036
|
try {
|
|
1199
1037
|
const ratio = getContrastRatio(bgcolor, "#fff");
|
|
@@ -1212,8 +1050,27 @@ const getAlphaColor = (color, alpha$1) => {
|
|
|
1212
1050
|
}
|
|
1213
1051
|
return color;
|
|
1214
1052
|
};
|
|
1215
|
-
function
|
|
1216
|
-
const {
|
|
1053
|
+
function LabelChip({ label }) {
|
|
1054
|
+
const { getFullLabelName } = LabelsContainer.useContainer();
|
|
1055
|
+
return /* @__PURE__ */ jsx(
|
|
1056
|
+
Chip,
|
|
1057
|
+
{
|
|
1058
|
+
label: getFullLabelName(label.data.id),
|
|
1059
|
+
variant: "filled",
|
|
1060
|
+
size: "small",
|
|
1061
|
+
sx: {
|
|
1062
|
+
height: 20,
|
|
1063
|
+
borderRadius: 1,
|
|
1064
|
+
fontSize: 12,
|
|
1065
|
+
bgcolor: getAlphaColor(label.data.color, 0.8),
|
|
1066
|
+
color: getContrastTextColor(label.data.color)
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
label.data.id
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
function Labels2({ labels, sx, renderLabel, prepend }) {
|
|
1073
|
+
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1217
1074
|
if (loading) {
|
|
1218
1075
|
return null;
|
|
1219
1076
|
}
|
|
@@ -1222,33 +1079,51 @@ function Labels2({ labels, sx, renderLabel }) {
|
|
|
1222
1079
|
{ display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
|
|
1223
1080
|
...Array.isArray(sx) ? sx : [sx]
|
|
1224
1081
|
];
|
|
1225
|
-
return /* @__PURE__ */
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
{
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1082
|
+
return /* @__PURE__ */ jsxs(Box$1, { sx: mergedSx, children: [
|
|
1083
|
+
prepend,
|
|
1084
|
+
labelNodes.map((item) => {
|
|
1085
|
+
if (!item) {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
if (renderLabel) {
|
|
1089
|
+
return renderLabel(item);
|
|
1090
|
+
}
|
|
1091
|
+
return /* @__PURE__ */ jsx(LabelChip, { label: item });
|
|
1092
|
+
})
|
|
1093
|
+
] });
|
|
1094
|
+
}
|
|
1095
|
+
function LabelsInput({ value = [], onChange, ...rest }) {
|
|
1096
|
+
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1097
|
+
const valueOptions = useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
|
|
1098
|
+
if (loading) {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
return /* @__PURE__ */ jsx(
|
|
1102
|
+
GithubLabelPicker,
|
|
1103
|
+
{
|
|
1104
|
+
value,
|
|
1105
|
+
onChange,
|
|
1106
|
+
trigger: /* @__PURE__ */ jsx(
|
|
1107
|
+
TextField,
|
|
1108
|
+
{
|
|
1109
|
+
...rest,
|
|
1110
|
+
InputProps: {
|
|
1111
|
+
autoComplete: "off",
|
|
1112
|
+
...rest.InputProps,
|
|
1113
|
+
startAdornment: valueOptions.map((x, index) => /* @__PURE__ */ jsx(LabelChip, { label: x }, index))
|
|
1114
|
+
},
|
|
1115
|
+
sx: {
|
|
1116
|
+
"& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, p: 1 },
|
|
1117
|
+
"& .MuiInputBase-input": { width: 20, p: 0 }
|
|
1118
|
+
}
|
|
1244
1119
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
}) });
|
|
1120
|
+
)
|
|
1121
|
+
}
|
|
1122
|
+
);
|
|
1249
1123
|
}
|
|
1250
1124
|
export {
|
|
1251
1125
|
GithubLabelPicker,
|
|
1126
|
+
LabelChip,
|
|
1252
1127
|
LabelPicker,
|
|
1253
1128
|
LabelTree,
|
|
1254
1129
|
LabelTreeNode,
|
package/dist/index.umd.js
CHANGED
|
@@ -720,7 +720,7 @@ var __publicField = (obj, key, value) => {
|
|
|
720
720
|
] });
|
|
721
721
|
}
|
|
722
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
|
|
723
|
+
function PopperComponent({
|
|
724
724
|
disablePortal,
|
|
725
725
|
anchorEl,
|
|
726
726
|
open,
|
|
@@ -782,6 +782,7 @@ var __publicField = (obj, key, value) => {
|
|
|
782
782
|
);
|
|
783
783
|
const theme = material.useTheme();
|
|
784
784
|
const handleClick = (event) => {
|
|
785
|
+
event.preventDefault();
|
|
785
786
|
setPendingValue(value);
|
|
786
787
|
setAnchorEl(event.currentTarget);
|
|
787
788
|
};
|
|
@@ -817,6 +818,7 @@ var __publicField = (obj, key, value) => {
|
|
|
817
818
|
component: material.ButtonBase,
|
|
818
819
|
disableRipple: true,
|
|
819
820
|
"aria-describedby": id,
|
|
821
|
+
className: "label-picker-trigger",
|
|
820
822
|
sx: [
|
|
821
823
|
(t) => ({
|
|
822
824
|
width: "100%",
|
|
@@ -897,7 +899,7 @@ var __publicField = (obj, key, value) => {
|
|
|
897
899
|
}
|
|
898
900
|
},
|
|
899
901
|
disableCloseOnSelect: true,
|
|
900
|
-
PopperComponent
|
|
902
|
+
PopperComponent,
|
|
901
903
|
renderTags: () => null,
|
|
902
904
|
noOptionsText: noLabelsText || "No labels",
|
|
903
905
|
renderOption: (props, option, { selected }) => /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, children: [
|
|
@@ -1018,170 +1020,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1018
1020
|
)
|
|
1019
1021
|
] });
|
|
1020
1022
|
}
|
|
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
1023
|
const getContrastTextColor = (bgcolor) => {
|
|
1186
1024
|
try {
|
|
1187
1025
|
const ratio = material.getContrastRatio(bgcolor, "#fff");
|
|
@@ -1200,8 +1038,27 @@ var __publicField = (obj, key, value) => {
|
|
|
1200
1038
|
}
|
|
1201
1039
|
return color;
|
|
1202
1040
|
};
|
|
1203
|
-
function
|
|
1204
|
-
const {
|
|
1041
|
+
function LabelChip({ label }) {
|
|
1042
|
+
const { getFullLabelName } = LabelsContainer.useContainer();
|
|
1043
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1044
|
+
material.Chip,
|
|
1045
|
+
{
|
|
1046
|
+
label: getFullLabelName(label.data.id),
|
|
1047
|
+
variant: "filled",
|
|
1048
|
+
size: "small",
|
|
1049
|
+
sx: {
|
|
1050
|
+
height: 20,
|
|
1051
|
+
borderRadius: 1,
|
|
1052
|
+
fontSize: 12,
|
|
1053
|
+
bgcolor: getAlphaColor(label.data.color, 0.8),
|
|
1054
|
+
color: getContrastTextColor(label.data.color)
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
label.data.id
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
function Labels2({ labels, sx, renderLabel, prepend }) {
|
|
1061
|
+
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1205
1062
|
if (loading) {
|
|
1206
1063
|
return null;
|
|
1207
1064
|
}
|
|
@@ -1210,32 +1067,50 @@ var __publicField = (obj, key, value) => {
|
|
|
1210
1067
|
{ display: "flex", gap: 1, alignItems: "center", flexWrap: "wrap" },
|
|
1211
1068
|
...Array.isArray(sx) ? sx : [sx]
|
|
1212
1069
|
];
|
|
1213
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
{
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1070
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, children: [
|
|
1071
|
+
prepend,
|
|
1072
|
+
labelNodes.map((item) => {
|
|
1073
|
+
if (!item) {
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
if (renderLabel) {
|
|
1077
|
+
return renderLabel(item);
|
|
1078
|
+
}
|
|
1079
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: item });
|
|
1080
|
+
})
|
|
1081
|
+
] });
|
|
1082
|
+
}
|
|
1083
|
+
function LabelsInput({ value = [], onChange, ...rest }) {
|
|
1084
|
+
const { getLabelsByIds, loading } = LabelsContainer.useContainer();
|
|
1085
|
+
const valueOptions = react.useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
|
|
1086
|
+
if (loading) {
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1090
|
+
GithubLabelPicker,
|
|
1091
|
+
{
|
|
1092
|
+
value,
|
|
1093
|
+
onChange,
|
|
1094
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1095
|
+
material.TextField,
|
|
1096
|
+
{
|
|
1097
|
+
...rest,
|
|
1098
|
+
InputProps: {
|
|
1099
|
+
autoComplete: "off",
|
|
1100
|
+
...rest.InputProps,
|
|
1101
|
+
startAdornment: valueOptions.map((x, index) => /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: x }, index))
|
|
1102
|
+
},
|
|
1103
|
+
sx: {
|
|
1104
|
+
"& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, p: 1 },
|
|
1105
|
+
"& .MuiInputBase-input": { width: 20, p: 0 }
|
|
1106
|
+
}
|
|
1232
1107
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
}) });
|
|
1108
|
+
)
|
|
1109
|
+
}
|
|
1110
|
+
);
|
|
1237
1111
|
}
|
|
1238
1112
|
exports2.GithubLabelPicker = GithubLabelPicker;
|
|
1113
|
+
exports2.LabelChip = LabelChip;
|
|
1239
1114
|
exports2.LabelPicker = LabelPicker;
|
|
1240
1115
|
exports2.LabelTree = LabelTree;
|
|
1241
1116
|
exports2.LabelTreeNode = LabelTreeNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
1
2
|
interface LabelsInputProps {
|
|
2
3
|
value: string[];
|
|
3
4
|
onChange: (value: string[]) => void;
|
|
4
5
|
}
|
|
5
|
-
export declare function LabelsInput({ value, onChange, ...rest }: LabelsInputProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare function LabelsInput({ value, onChange, ...rest }: LabelsInputProps & TextFieldProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
7
|
export {};
|
package/dist/label2/labels2.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type SxProps } from '@mui/material';
|
|
3
|
-
import { LabelTreeNode } from './tree';
|
|
3
|
+
import type { LabelTreeNode } from './tree';
|
|
4
4
|
interface LabelsProps {
|
|
5
5
|
labels: string[] | undefined | null;
|
|
6
6
|
sx?: SxProps;
|
|
7
7
|
renderLabel?: (label: LabelTreeNode) => JSX.Element;
|
|
8
|
+
prepend?: React.ReactNode;
|
|
8
9
|
}
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function LabelChip({ label }: {
|
|
11
|
+
label: LabelTreeNode;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function Labels2({ labels, sx, renderLabel, prepend }: LabelsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
14
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/labels",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.11",
|
|
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.11",
|
|
32
32
|
"@emotion/css": "^11.10.5",
|
|
33
33
|
"@emotion/react": "^11.10.5",
|
|
34
34
|
"@emotion/styled": "^11.10.5",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"resolutions": {
|
|
81
81
|
"react": "^18.2.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "49174f11c1511888bc40180c5b607b1d41e3ec76"
|
|
84
84
|
}
|