@blocklet/labels 2.3.5 → 2.3.7
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 +49 -31
- package/dist/index.umd.js +48 -30
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Tree } from "react-arborist";
|
|
|
10
10
|
import { Icon } from "@iconify/react";
|
|
11
11
|
import omit from "lodash/omit";
|
|
12
12
|
import Select, { components } from "react-select";
|
|
13
|
-
import { ClickAwayListener, Box as Box$1, Chip, IconButton, Button, getContrastRatio, alpha, ButtonBase, Popper, Autocomplete, InputBase, autocompleteClasses, TextField } from "@mui/material";
|
|
13
|
+
import { ClickAwayListener, Box as Box$1, Chip, IconButton, Button, getContrastRatio, alpha, useTheme, ButtonBase, Popper, Autocomplete, InputBase, autocompleteClasses, TextField } from "@mui/material";
|
|
14
14
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
15
15
|
import { useReactive, useLocalStorageState, useRequest, useSize, useDeepCompareLayoutEffect } from "ahooks";
|
|
16
16
|
import { createContainer } from "unstated-next";
|
|
@@ -784,23 +784,39 @@ const useSessionContext = () => {
|
|
|
784
784
|
}
|
|
785
785
|
};
|
|
786
786
|
};
|
|
787
|
-
const getTextColor = (color) => {
|
|
788
|
-
|
|
787
|
+
const getTextColor = (color, mode) => {
|
|
788
|
+
const baseColor = chroma(color);
|
|
789
|
+
if (mode === "dark") {
|
|
790
|
+
return baseColor.luminance() > 0.5 ? baseColor.darken(3).hex() : baseColor.brighten(3).hex();
|
|
791
|
+
}
|
|
792
|
+
return baseColor.hex();
|
|
789
793
|
};
|
|
790
|
-
const getBorderColor = (color) => {
|
|
791
|
-
|
|
792
|
-
|
|
794
|
+
const getBorderColor = (color, mode) => {
|
|
795
|
+
const baseColor = chroma(color);
|
|
796
|
+
if (mode === "dark") {
|
|
797
|
+
return baseColor.brighten(2).alpha(0.4).hex();
|
|
798
|
+
}
|
|
799
|
+
if (baseColor.luminance() > 0.5) {
|
|
800
|
+
return baseColor.darken(3).hex();
|
|
793
801
|
}
|
|
794
|
-
return
|
|
802
|
+
return baseColor.brighten(0.5).alpha(0.25).hex();
|
|
795
803
|
};
|
|
796
|
-
const getBackgroundColor = (color) => {
|
|
797
|
-
|
|
798
|
-
|
|
804
|
+
const getBackgroundColor = (color, mode) => {
|
|
805
|
+
const baseColor = chroma(color);
|
|
806
|
+
if (mode === "dark") {
|
|
807
|
+
return baseColor.brighten(2).alpha(0.25).hex();
|
|
799
808
|
}
|
|
800
|
-
|
|
809
|
+
if (baseColor.luminance() > 0.5) {
|
|
810
|
+
return baseColor.darken(2.5).hex();
|
|
811
|
+
}
|
|
812
|
+
return baseColor.brighten(2.5).alpha(0.25).hex();
|
|
801
813
|
};
|
|
802
|
-
const getFilterStyle = (color) => {
|
|
803
|
-
|
|
814
|
+
const getFilterStyle = (color, mode) => {
|
|
815
|
+
const baseColor = chroma(color);
|
|
816
|
+
if (mode === "dark") {
|
|
817
|
+
return "brightness(1.3) contrast(1.2)";
|
|
818
|
+
}
|
|
819
|
+
if (baseColor.luminance() > 0.5) {
|
|
804
820
|
return "brightness(0.85) contrast(1.2)";
|
|
805
821
|
}
|
|
806
822
|
return "brightness(0.85) contrast(1.2)";
|
|
@@ -815,20 +831,21 @@ function LabelChip({
|
|
|
815
831
|
renderName = (name) => name
|
|
816
832
|
}) {
|
|
817
833
|
const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
|
|
834
|
+
const theme = useTheme();
|
|
835
|
+
const { mode } = theme.palette;
|
|
818
836
|
const mergedSx = [
|
|
819
837
|
{
|
|
820
838
|
height: 20,
|
|
821
839
|
borderRadius: 0.5,
|
|
822
840
|
fontSize: 12,
|
|
823
841
|
fontWeight: 500,
|
|
824
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
825
|
-
bgcolor: `${getBackgroundColor(label.data.color)} !important`,
|
|
842
|
+
color: `${getTextColor(label.data.color, mode)} !important`,
|
|
843
|
+
bgcolor: `${getBackgroundColor(label.data.color, mode)} !important`,
|
|
826
844
|
transition: "filter 0.2s",
|
|
827
|
-
borderColor: `${getBorderColor(label.data.color)} !important`,
|
|
828
|
-
|
|
829
|
-
WebkitTextFillColor: `${getTextColor(label.data.color)} !important`,
|
|
845
|
+
borderColor: `${getBorderColor(label.data.color, mode)} !important`,
|
|
846
|
+
WebkitTextFillColor: `${getTextColor(label.data.color, mode)} !important`,
|
|
830
847
|
".MuiChip-deleteIcon": {
|
|
831
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
848
|
+
color: `${getTextColor(label.data.color, mode)} !important`,
|
|
832
849
|
cursor: "pointer",
|
|
833
850
|
transition: "transform 0.3s",
|
|
834
851
|
"&:hover": {
|
|
@@ -842,7 +859,7 @@ function LabelChip({
|
|
|
842
859
|
...onClick && {
|
|
843
860
|
cursor: "pointer",
|
|
844
861
|
"&:hover": {
|
|
845
|
-
filter: getFilterStyle(label.data.color)
|
|
862
|
+
filter: getFilterStyle(label.data.color, mode)
|
|
846
863
|
}
|
|
847
864
|
}
|
|
848
865
|
},
|
|
@@ -997,7 +1014,7 @@ function PopperComponent({
|
|
|
997
1014
|
fontSize: 13
|
|
998
1015
|
},
|
|
999
1016
|
[`& .${autocompleteClasses.listbox}`]: {
|
|
1000
|
-
bgcolor: theme.palette.
|
|
1017
|
+
bgcolor: theme.palette.background.paper,
|
|
1001
1018
|
padding: 1,
|
|
1002
1019
|
[`& .${autocompleteClasses.option}`]: {
|
|
1003
1020
|
minHeight: "auto"
|
|
@@ -1191,7 +1208,7 @@ function GithubLabelPicker({
|
|
|
1191
1208
|
return null;
|
|
1192
1209
|
}
|
|
1193
1210
|
const label = option.data;
|
|
1194
|
-
return /* @__PURE__ */ createElement(Box$1, { component: "li", ...props, key: label.id, sx: { "&.MuiAutocomplete-option": { p: 0 } } }, /* @__PURE__ */ jsx(
|
|
1211
|
+
return /* @__PURE__ */ createElement(Box$1, { component: "li", ...props, key: label.id, sx: { "&.MuiAutocomplete-option": { p: "0 !important" } } }, /* @__PURE__ */ jsx(
|
|
1195
1212
|
LabelChip,
|
|
1196
1213
|
{
|
|
1197
1214
|
label: option,
|
|
@@ -1225,17 +1242,17 @@ function GithubLabelPicker({
|
|
|
1225
1242
|
sx: (theme) => ({
|
|
1226
1243
|
padding: 1,
|
|
1227
1244
|
width: "100%",
|
|
1228
|
-
bgcolor: "
|
|
1245
|
+
bgcolor: "background.paper",
|
|
1229
1246
|
"& input": {
|
|
1230
1247
|
borderRadius: 1,
|
|
1231
|
-
backgroundColor:
|
|
1248
|
+
backgroundColor: "background.paper",
|
|
1232
1249
|
padding: 1,
|
|
1233
1250
|
transition: theme.transitions.create(["border-color", "box-shadow"]),
|
|
1234
|
-
border: `1px solid ${theme.palette.
|
|
1251
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
1235
1252
|
fontSize: 14,
|
|
1236
1253
|
"&:focus": {
|
|
1237
|
-
boxShadow: `0px 0px 0px 3px ${
|
|
1238
|
-
borderColor: theme.palette.
|
|
1254
|
+
boxShadow: `0px 0px 0px 3px ${alpha(theme.palette.primary.light, 0.4)}`,
|
|
1255
|
+
borderColor: theme.palette.primary.light
|
|
1239
1256
|
}
|
|
1240
1257
|
}
|
|
1241
1258
|
})
|
|
@@ -1256,7 +1273,8 @@ function GithubLabelPicker({
|
|
|
1256
1273
|
width: "100%",
|
|
1257
1274
|
height: 36,
|
|
1258
1275
|
px: 2,
|
|
1259
|
-
borderTop: "1px solid
|
|
1276
|
+
borderTop: "1px solid",
|
|
1277
|
+
borderColor: "divider",
|
|
1260
1278
|
fontSize: 14,
|
|
1261
1279
|
color: "grey.600",
|
|
1262
1280
|
cursor: "pointer",
|
|
@@ -1311,15 +1329,15 @@ function GithubLabelPicker({
|
|
|
1311
1329
|
placement: "bottom-start",
|
|
1312
1330
|
disablePortal,
|
|
1313
1331
|
sx: (theme) => ({
|
|
1314
|
-
border: `1px solid ${theme.palette.
|
|
1332
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
1315
1333
|
boxShadow: `0 8px 24px ${theme.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
|
|
1316
1334
|
borderRadius: 1,
|
|
1317
1335
|
width: 360,
|
|
1318
1336
|
overflow: "hidden",
|
|
1319
1337
|
zIndex: theme.zIndex.modal,
|
|
1320
1338
|
fontSize: 13,
|
|
1321
|
-
color:
|
|
1322
|
-
backgroundColor:
|
|
1339
|
+
color: "text.secondary",
|
|
1340
|
+
backgroundColor: "background.paper"
|
|
1323
1341
|
}),
|
|
1324
1342
|
children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsxs(Box$1, { onClick: (e) => e.preventDefault(), children: [
|
|
1325
1343
|
renderAutocomplete(),
|
package/dist/index.umd.js
CHANGED
|
@@ -771,23 +771,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
771
771
|
}
|
|
772
772
|
};
|
|
773
773
|
};
|
|
774
|
-
const getTextColor = (color) => {
|
|
775
|
-
|
|
774
|
+
const getTextColor = (color, mode) => {
|
|
775
|
+
const baseColor = chroma(color);
|
|
776
|
+
if (mode === "dark") {
|
|
777
|
+
return baseColor.luminance() > 0.5 ? baseColor.darken(3).hex() : baseColor.brighten(3).hex();
|
|
778
|
+
}
|
|
779
|
+
return baseColor.hex();
|
|
776
780
|
};
|
|
777
|
-
const getBorderColor = (color) => {
|
|
778
|
-
|
|
779
|
-
|
|
781
|
+
const getBorderColor = (color, mode) => {
|
|
782
|
+
const baseColor = chroma(color);
|
|
783
|
+
if (mode === "dark") {
|
|
784
|
+
return baseColor.brighten(2).alpha(0.4).hex();
|
|
785
|
+
}
|
|
786
|
+
if (baseColor.luminance() > 0.5) {
|
|
787
|
+
return baseColor.darken(3).hex();
|
|
780
788
|
}
|
|
781
|
-
return
|
|
789
|
+
return baseColor.brighten(0.5).alpha(0.25).hex();
|
|
782
790
|
};
|
|
783
|
-
const getBackgroundColor = (color) => {
|
|
784
|
-
|
|
785
|
-
|
|
791
|
+
const getBackgroundColor = (color, mode) => {
|
|
792
|
+
const baseColor = chroma(color);
|
|
793
|
+
if (mode === "dark") {
|
|
794
|
+
return baseColor.brighten(2).alpha(0.25).hex();
|
|
786
795
|
}
|
|
787
|
-
|
|
796
|
+
if (baseColor.luminance() > 0.5) {
|
|
797
|
+
return baseColor.darken(2.5).hex();
|
|
798
|
+
}
|
|
799
|
+
return baseColor.brighten(2.5).alpha(0.25).hex();
|
|
788
800
|
};
|
|
789
|
-
const getFilterStyle = (color) => {
|
|
790
|
-
|
|
801
|
+
const getFilterStyle = (color, mode) => {
|
|
802
|
+
const baseColor = chroma(color);
|
|
803
|
+
if (mode === "dark") {
|
|
804
|
+
return "brightness(1.3) contrast(1.2)";
|
|
805
|
+
}
|
|
806
|
+
if (baseColor.luminance() > 0.5) {
|
|
791
807
|
return "brightness(0.85) contrast(1.2)";
|
|
792
808
|
}
|
|
793
809
|
return "brightness(0.85) contrast(1.2)";
|
|
@@ -802,20 +818,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
802
818
|
renderName = (name) => name
|
|
803
819
|
}) {
|
|
804
820
|
const { getFullLabelName, getLabelName } = LabelsContainer.useContainer();
|
|
821
|
+
const theme = material.useTheme();
|
|
822
|
+
const { mode } = theme.palette;
|
|
805
823
|
const mergedSx = [
|
|
806
824
|
{
|
|
807
825
|
height: 20,
|
|
808
826
|
borderRadius: 0.5,
|
|
809
827
|
fontSize: 12,
|
|
810
828
|
fontWeight: 500,
|
|
811
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
812
|
-
bgcolor: `${getBackgroundColor(label.data.color)} !important`,
|
|
829
|
+
color: `${getTextColor(label.data.color, mode)} !important`,
|
|
830
|
+
bgcolor: `${getBackgroundColor(label.data.color, mode)} !important`,
|
|
813
831
|
transition: "filter 0.2s",
|
|
814
|
-
borderColor: `${getBorderColor(label.data.color)} !important`,
|
|
815
|
-
|
|
816
|
-
WebkitTextFillColor: `${getTextColor(label.data.color)} !important`,
|
|
832
|
+
borderColor: `${getBorderColor(label.data.color, mode)} !important`,
|
|
833
|
+
WebkitTextFillColor: `${getTextColor(label.data.color, mode)} !important`,
|
|
817
834
|
".MuiChip-deleteIcon": {
|
|
818
|
-
color: `${getTextColor(label.data.color)} !important`,
|
|
835
|
+
color: `${getTextColor(label.data.color, mode)} !important`,
|
|
819
836
|
cursor: "pointer",
|
|
820
837
|
transition: "transform 0.3s",
|
|
821
838
|
"&:hover": {
|
|
@@ -829,7 +846,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
829
846
|
...onClick && {
|
|
830
847
|
cursor: "pointer",
|
|
831
848
|
"&:hover": {
|
|
832
|
-
filter: getFilterStyle(label.data.color)
|
|
849
|
+
filter: getFilterStyle(label.data.color, mode)
|
|
833
850
|
}
|
|
834
851
|
}
|
|
835
852
|
},
|
|
@@ -984,7 +1001,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
984
1001
|
fontSize: 13
|
|
985
1002
|
},
|
|
986
1003
|
[`& .${material.autocompleteClasses.listbox}`]: {
|
|
987
|
-
bgcolor: theme.palette.
|
|
1004
|
+
bgcolor: theme.palette.background.paper,
|
|
988
1005
|
padding: 1,
|
|
989
1006
|
[`& .${material.autocompleteClasses.option}`]: {
|
|
990
1007
|
minHeight: "auto"
|
|
@@ -1178,7 +1195,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1178
1195
|
return null;
|
|
1179
1196
|
}
|
|
1180
1197
|
const label = option.data;
|
|
1181
|
-
return /* @__PURE__ */ react.createElement(material.Box, { component: "li", ...props, key: label.id, sx: { "&.MuiAutocomplete-option": { p: 0 } } }, /* @__PURE__ */ jsxRuntime.jsx(
|
|
1198
|
+
return /* @__PURE__ */ react.createElement(material.Box, { component: "li", ...props, key: label.id, sx: { "&.MuiAutocomplete-option": { p: "0 !important" } } }, /* @__PURE__ */ jsxRuntime.jsx(
|
|
1182
1199
|
LabelChip,
|
|
1183
1200
|
{
|
|
1184
1201
|
label: option,
|
|
@@ -1212,17 +1229,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1212
1229
|
sx: (theme) => ({
|
|
1213
1230
|
padding: 1,
|
|
1214
1231
|
width: "100%",
|
|
1215
|
-
bgcolor: "
|
|
1232
|
+
bgcolor: "background.paper",
|
|
1216
1233
|
"& input": {
|
|
1217
1234
|
borderRadius: 1,
|
|
1218
|
-
backgroundColor:
|
|
1235
|
+
backgroundColor: "background.paper",
|
|
1219
1236
|
padding: 1,
|
|
1220
1237
|
transition: theme.transitions.create(["border-color", "box-shadow"]),
|
|
1221
|
-
border: `1px solid ${theme.palette.
|
|
1238
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
1222
1239
|
fontSize: 14,
|
|
1223
1240
|
"&:focus": {
|
|
1224
|
-
boxShadow: `0px 0px 0px 3px ${
|
|
1225
|
-
borderColor: theme.palette.
|
|
1241
|
+
boxShadow: `0px 0px 0px 3px ${material.alpha(theme.palette.primary.light, 0.4)}`,
|
|
1242
|
+
borderColor: theme.palette.primary.light
|
|
1226
1243
|
}
|
|
1227
1244
|
}
|
|
1228
1245
|
})
|
|
@@ -1243,7 +1260,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1243
1260
|
width: "100%",
|
|
1244
1261
|
height: 36,
|
|
1245
1262
|
px: 2,
|
|
1246
|
-
borderTop: "1px solid
|
|
1263
|
+
borderTop: "1px solid",
|
|
1264
|
+
borderColor: "divider",
|
|
1247
1265
|
fontSize: 14,
|
|
1248
1266
|
color: "grey.600",
|
|
1249
1267
|
cursor: "pointer",
|
|
@@ -1298,15 +1316,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1298
1316
|
placement: "bottom-start",
|
|
1299
1317
|
disablePortal,
|
|
1300
1318
|
sx: (theme) => ({
|
|
1301
|
-
border: `1px solid ${theme.palette.
|
|
1319
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
1302
1320
|
boxShadow: `0 8px 24px ${theme.palette.mode === "light" ? "rgba(149, 157, 165, 0.2)" : "rgb(1, 4, 9)"}`,
|
|
1303
1321
|
borderRadius: 1,
|
|
1304
1322
|
width: 360,
|
|
1305
1323
|
overflow: "hidden",
|
|
1306
1324
|
zIndex: theme.zIndex.modal,
|
|
1307
1325
|
fontSize: 13,
|
|
1308
|
-
color:
|
|
1309
|
-
backgroundColor:
|
|
1326
|
+
color: "text.secondary",
|
|
1327
|
+
backgroundColor: "background.paper"
|
|
1310
1328
|
}),
|
|
1311
1329
|
children: /* @__PURE__ */ jsxRuntime.jsx(material.ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { onClick: (e) => e.preventDefault(), children: [
|
|
1312
1330
|
renderAutocomplete(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/labels",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.7",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"react-color": "^2.19.3",
|
|
30
30
|
"react-select": "^5.8.1",
|
|
31
31
|
"unstated-next": "^1.1.0",
|
|
32
|
-
"@blocklet/translation-input": "^2.3.
|
|
32
|
+
"@blocklet/translation-input": "^2.3.7"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@arcblock/did-connect": "^2.10.36",
|