@blocklet/labels 2.2.30 → 2.2.31
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 +18 -19
- package/dist/index.umd.js +17 -18
- package/dist/label2/labels-context.d.ts +3 -0
- package/package.json +2 -2
- package/dist/label2/recent.d.ts +0 -4
package/dist/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import omit from "lodash/omit";
|
|
|
12
12
|
import Select, { components } from "react-select";
|
|
13
13
|
import { ClickAwayListener, Box as Box$1, Chip, IconButton, Button, getContrastRatio, alpha, ButtonBase, Popper, Autocomplete, InputBase, autocompleteClasses, TextField } from "@mui/material";
|
|
14
14
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
15
|
-
import { useReactive,
|
|
15
|
+
import { useReactive, useLocalStorageState, useRequest, useSize, useDeepCompareLayoutEffect } from "ahooks";
|
|
16
16
|
import { createContainer } from "unstated-next";
|
|
17
17
|
import { arrayToTree } from "performant-array-to-tree";
|
|
18
18
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
@@ -593,6 +593,11 @@ const useLabels = ({ loading, data, createLabel: createLabelAPI }) => {
|
|
|
593
593
|
const parseLabelsStr = useCallback((labelIdsStr) => {
|
|
594
594
|
return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
|
|
595
595
|
}, []);
|
|
596
|
+
const [recentLabels = [], setRecentLabels] = useLocalStorageState("recent-labels", { defaultValue: [] });
|
|
597
|
+
const addRecentLabel = (label) => {
|
|
598
|
+
if (!label || labelExists(label)) return;
|
|
599
|
+
setRecentLabels([label, ...recentLabels].slice(0, 10));
|
|
600
|
+
};
|
|
596
601
|
return {
|
|
597
602
|
...state,
|
|
598
603
|
flattenedLabels: flattened,
|
|
@@ -608,7 +613,10 @@ const useLabels = ({ loading, data, createLabel: createLabelAPI }) => {
|
|
|
608
613
|
updateLabelNode,
|
|
609
614
|
removeLabelNode,
|
|
610
615
|
getFullLabelName,
|
|
611
|
-
parseLabelsStr
|
|
616
|
+
parseLabelsStr,
|
|
617
|
+
recentLabels,
|
|
618
|
+
setRecentLabels,
|
|
619
|
+
addRecentLabel
|
|
612
620
|
};
|
|
613
621
|
};
|
|
614
622
|
const LabelsContainer = createContainer(useLabels);
|
|
@@ -776,21 +784,6 @@ const useSessionContext = () => {
|
|
|
776
784
|
}
|
|
777
785
|
};
|
|
778
786
|
};
|
|
779
|
-
const useRecentLabels = () => {
|
|
780
|
-
const { labelExists } = LabelsContainer.useContainer();
|
|
781
|
-
const [recentLabels = [], setRecentLabels] = useLocalStorageState("recent-labels", {
|
|
782
|
-
defaultValue: []
|
|
783
|
-
});
|
|
784
|
-
const validLabels = recentLabels.filter((x) => labelExists(x));
|
|
785
|
-
const addRecentLabel = (label) => {
|
|
786
|
-
if (!label || validLabels.includes(label)) {
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
const newLabels = [label, ...validLabels].slice(0, 10);
|
|
790
|
-
setRecentLabels(newLabels);
|
|
791
|
-
};
|
|
792
|
-
return { recentLabels: validLabels, addRecentLabel };
|
|
793
|
-
};
|
|
794
787
|
const getTextColor = (color) => {
|
|
795
788
|
return chroma(color).hex();
|
|
796
789
|
};
|
|
@@ -1033,7 +1026,14 @@ function GithubLabelPicker({
|
|
|
1033
1026
|
}) {
|
|
1034
1027
|
const { t, locale } = useLocaleContext();
|
|
1035
1028
|
const { isAdmin, hasAnyPassport } = useSessionContext();
|
|
1036
|
-
const {
|
|
1029
|
+
const {
|
|
1030
|
+
flattenedLabels: labels,
|
|
1031
|
+
getLabelsByIds,
|
|
1032
|
+
loading,
|
|
1033
|
+
createLabel,
|
|
1034
|
+
recentLabels,
|
|
1035
|
+
addRecentLabel
|
|
1036
|
+
} = LabelsContainer.useContainer();
|
|
1037
1037
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
1038
1038
|
const selectedLabelIds = value;
|
|
1039
1039
|
const selectedLabels = useMemo(() => getLabelsByIds(selectedLabelIds), [getLabelsByIds, selectedLabelIds]);
|
|
@@ -1046,7 +1046,6 @@ function GithubLabelPicker({
|
|
|
1046
1046
|
const excludesSet = new Set(excludes);
|
|
1047
1047
|
return labels.filter((x) => !excludesSet.has(x.data.id));
|
|
1048
1048
|
}, [labels]);
|
|
1049
|
-
const { recentLabels, addRecentLabel } = useRecentLabels();
|
|
1050
1049
|
const initialRecentLabels = useMemo(() => recentLabels, [anchorEl]);
|
|
1051
1050
|
const handleClick = (event) => {
|
|
1052
1051
|
if (disabled) {
|
package/dist/index.umd.js
CHANGED
|
@@ -580,6 +580,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
580
580
|
const parseLabelsStr = react.useCallback((labelIdsStr) => {
|
|
581
581
|
return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
|
|
582
582
|
}, []);
|
|
583
|
+
const [recentLabels = [], setRecentLabels] = ahooks.useLocalStorageState("recent-labels", { defaultValue: [] });
|
|
584
|
+
const addRecentLabel = (label) => {
|
|
585
|
+
if (!label || labelExists(label)) return;
|
|
586
|
+
setRecentLabels([label, ...recentLabels].slice(0, 10));
|
|
587
|
+
};
|
|
583
588
|
return {
|
|
584
589
|
...state,
|
|
585
590
|
flattenedLabels: flattened,
|
|
@@ -595,7 +600,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
595
600
|
updateLabelNode,
|
|
596
601
|
removeLabelNode,
|
|
597
602
|
getFullLabelName,
|
|
598
|
-
parseLabelsStr
|
|
603
|
+
parseLabelsStr,
|
|
604
|
+
recentLabels,
|
|
605
|
+
setRecentLabels,
|
|
606
|
+
addRecentLabel
|
|
599
607
|
};
|
|
600
608
|
};
|
|
601
609
|
const LabelsContainer = unstatedNext.createContainer(useLabels);
|
|
@@ -763,21 +771,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
763
771
|
}
|
|
764
772
|
};
|
|
765
773
|
};
|
|
766
|
-
const useRecentLabels = () => {
|
|
767
|
-
const { labelExists } = LabelsContainer.useContainer();
|
|
768
|
-
const [recentLabels = [], setRecentLabels] = ahooks.useLocalStorageState("recent-labels", {
|
|
769
|
-
defaultValue: []
|
|
770
|
-
});
|
|
771
|
-
const validLabels = recentLabels.filter((x) => labelExists(x));
|
|
772
|
-
const addRecentLabel = (label) => {
|
|
773
|
-
if (!label || validLabels.includes(label)) {
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
const newLabels = [label, ...validLabels].slice(0, 10);
|
|
777
|
-
setRecentLabels(newLabels);
|
|
778
|
-
};
|
|
779
|
-
return { recentLabels: validLabels, addRecentLabel };
|
|
780
|
-
};
|
|
781
774
|
const getTextColor = (color) => {
|
|
782
775
|
return chroma(color).hex();
|
|
783
776
|
};
|
|
@@ -1020,7 +1013,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1020
1013
|
}) {
|
|
1021
1014
|
const { t, locale } = context.useLocaleContext();
|
|
1022
1015
|
const { isAdmin, hasAnyPassport } = useSessionContext();
|
|
1023
|
-
const {
|
|
1016
|
+
const {
|
|
1017
|
+
flattenedLabels: labels,
|
|
1018
|
+
getLabelsByIds,
|
|
1019
|
+
loading,
|
|
1020
|
+
createLabel,
|
|
1021
|
+
recentLabels,
|
|
1022
|
+
addRecentLabel
|
|
1023
|
+
} = LabelsContainer.useContainer();
|
|
1024
1024
|
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
1025
1025
|
const selectedLabelIds = value;
|
|
1026
1026
|
const selectedLabels = react.useMemo(() => getLabelsByIds(selectedLabelIds), [getLabelsByIds, selectedLabelIds]);
|
|
@@ -1033,7 +1033,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1033
1033
|
const excludesSet = new Set(excludes);
|
|
1034
1034
|
return labels.filter((x) => !excludesSet.has(x.data.id));
|
|
1035
1035
|
}, [labels]);
|
|
1036
|
-
const { recentLabels, addRecentLabel } = useRecentLabels();
|
|
1037
1036
|
const initialRecentLabels = react.useMemo(() => recentLabels, [anchorEl]);
|
|
1038
1037
|
const handleClick = (event) => {
|
|
1039
1038
|
if (disabled) {
|
|
@@ -68,6 +68,9 @@ export declare const LabelsContainer: import('unstated-next').Container<{
|
|
|
68
68
|
removeLabelNode: (id: string) => void;
|
|
69
69
|
getFullLabelName: (id: string) => string;
|
|
70
70
|
parseLabelsStr: (labelIdsStr: string) => string[];
|
|
71
|
+
recentLabels: string[];
|
|
72
|
+
setRecentLabels: (value?: import('ahooks/lib/createUseStorageState').SetState<string[]> | undefined) => void;
|
|
73
|
+
addRecentLabel: (label?: string) => void;
|
|
71
74
|
loading: boolean;
|
|
72
75
|
tree: LabelTreeNode;
|
|
73
76
|
stats: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/labels",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.31",
|
|
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.2.
|
|
32
|
+
"@blocklet/translation-input": "^2.2.31"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@arcblock/did-connect": "^2.10.36",
|
package/dist/label2/recent.d.ts
DELETED