@junyiacademy/ui-test 1.6.0 → 1.6.1
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/{declarations/libs/ui/src → dist}/index.d.ts +0 -0
- package/{declarations/libs/ui/src → dist}/interfaces/index.d.ts +4 -1
- package/{declarations/libs/ui/src → dist}/lib/button/Button.d.ts +0 -0
- package/{declarations/libs/ui/src → dist}/lib/button-group/ButtonGroup.d.ts +0 -0
- package/{declarations/libs/ui/src → dist}/lib/menu-item/SelectMenuItem.d.ts +0 -0
- package/dist/lib/radio/Radio.d.ts +11 -0
- package/dist/lib/select/OutlinedSelect.d.ts +3 -0
- package/{declarations/libs/ui/src → dist}/lib/select/Select.d.ts +0 -0
- package/dist/lib/select/StandardSelect.d.ts +3 -0
- package/dist/lib/text-field/TextField.d.ts +3 -0
- package/{declarations/libs/ui/src → dist}/lib/topic-filter/TopicFilter.d.ts +0 -0
- package/dist/styles/theme.d.ts +24 -0
- package/{declarations/libs/ui/src → dist}/utils/Capitalize.d.ts +0 -0
- package/dist/utils/topicTree.d.ts +2 -0
- package/package.json +2 -2
- package/declarations/libs/ui/src/lib/TopicFilter.d.ts +0 -13
- package/declarations/libs/ui/src/lib/radio/Radio.d.ts +0 -10
- package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +0 -3
- package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +0 -3
- package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +0 -3
- package/dist/libs/ui/src/index.js +0 -20
- package/dist/libs/ui/src/interfaces/index.js +0 -2
- package/dist/libs/ui/src/lib/TopicFilter.js +0 -120
- package/dist/libs/ui/src/lib/button/Button.js +0 -44
- package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +0 -23
- package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +0 -20
- package/dist/libs/ui/src/lib/radio/Radio.js +0 -33
- package/dist/libs/ui/src/lib/select/OutlinedSelect.js +0 -82
- package/dist/libs/ui/src/lib/select/Select.js +0 -16
- package/dist/libs/ui/src/lib/select/StandardSelect.js +0 -65
- package/dist/libs/ui/src/lib/text-field/TextField.js +0 -68
- package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +0 -120
- package/dist/libs/ui/src/utils/Capitalize.js +0 -6
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChangeEvent } from 'react';
|
|
2
|
-
import { SelectProps as MuiSelectProp, InputProps as MuiInputProps, OutlinedInputProps } from '@mui/material';
|
|
2
|
+
import { SelectProps as MuiSelectProp, InputProps as MuiInputProps, FormControlProps as MuiFormControlProps, InputLabelProps as MuiInputLabelProps, OutlinedInputProps, FormHelperTextProps as MuiFormHelperTextProps } from '@mui/material';
|
|
3
3
|
export interface ITopicTreeNode {
|
|
4
4
|
childTopics: ITopicTreeNode[];
|
|
5
5
|
id: string;
|
|
@@ -10,10 +10,13 @@ export interface ITopicTreeNode {
|
|
|
10
10
|
}
|
|
11
11
|
export interface SelectProps extends MuiSelectProp {
|
|
12
12
|
helperText?: string;
|
|
13
|
+
FormControlProps?: Partial<MuiFormControlProps>;
|
|
14
|
+
InputLabelProps?: Partial<MuiInputLabelProps>;
|
|
13
15
|
InputProps?: (Partial<OutlinedInputProps> & {
|
|
14
16
|
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
15
17
|
}) | (object & Partial<MuiInputProps>);
|
|
16
18
|
SelectProps?: object | Partial<MuiSelectProp>;
|
|
19
|
+
FormHelperTextProps?: Partial<MuiFormHelperTextProps>;
|
|
17
20
|
color?: 'primary' | 'secondary';
|
|
18
21
|
size?: 'medium' | 'small';
|
|
19
22
|
paperMaxHeight?: number | string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RadioProps as MuiRadioProps, FormControlLabelProps as MuiFormControlLabelProps, TypographyProps as MuiTypographyProps } from '@mui/material';
|
|
2
|
+
export interface RadioProps extends MuiFormControlLabelProps {
|
|
3
|
+
color?: 'primary' | 'secondary' | 'default';
|
|
4
|
+
size?: 'medium' | 'small';
|
|
5
|
+
caption?: string;
|
|
6
|
+
FormControlLabelProps?: Partial<MuiFormControlLabelProps>;
|
|
7
|
+
RadioProps?: Partial<MuiRadioProps>;
|
|
8
|
+
TypographyProps?: Partial<MuiTypographyProps>;
|
|
9
|
+
}
|
|
10
|
+
export declare const Radio: ({ checked, disabled, label, labelPlacement, value, FormControlLabelProps, RadioProps, TypographyProps, color, size, caption, }: RadioProps) => JSX.Element;
|
|
11
|
+
export default Radio;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SelectProps as ISelectProps } from '../../interfaces';
|
|
2
|
+
export declare const OutlinedSelect: ({ label, helperText, FormControlProps, InputLabelProps, InputProps, SelectProps, FormHelperTextProps, className, children, color, size, paperMaxHeight, error, hasLabel, hasShrink, value, disabled, }: ISelectProps) => JSX.Element;
|
|
3
|
+
export default OutlinedSelect;
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SelectProps as ISelectProps } from '../../interfaces';
|
|
2
|
+
export declare function StandardSelect({ label, helperText, FormControlProps, InputLabelProps, InputProps, SelectProps, FormHelperTextProps, className, children, color, size, paperMaxHeight, error, hasShrink, value, disabled, }: ISelectProps): JSX.Element;
|
|
3
|
+
export default StandardSelect;
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Junyi Academy.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
declare module '@mui/material/styles/createPalette' {
|
|
8
|
+
interface Palette {
|
|
9
|
+
green: {
|
|
10
|
+
primary: Palette['primary'];
|
|
11
|
+
blueGreen: Palette['primary'];
|
|
12
|
+
grassGreen: Palette['primary'];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface PaletteOptions {
|
|
16
|
+
green: {
|
|
17
|
+
primary: PaletteOptions['primary'];
|
|
18
|
+
blueGreen: PaletteOptions['primary'];
|
|
19
|
+
grassGreen: PaletteOptions['primary'];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
declare const theme: import("@mui/material/styles").Theme;
|
|
24
|
+
export default theme;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junyiacademy/ui-test",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "junyiacademy ui library",
|
|
5
5
|
"main": "./dist/libs/ui/src/index.js",
|
|
6
|
-
"typings": "./
|
|
6
|
+
"typings": "./dist/libs/ui/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"build": "tsc --build --clean && tsc --build"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ITopicTreeNode } from '../interfaces';
|
|
2
|
-
export interface TopicFilterProps {
|
|
3
|
-
topicTree: ITopicTreeNode;
|
|
4
|
-
onTopicSelected: (topic: ITopicTreeNode, selectedInfo: {
|
|
5
|
-
layerNumber: number;
|
|
6
|
-
selectedTopicIds: string[];
|
|
7
|
-
}) => void;
|
|
8
|
-
isLastLayer: (topic: ITopicTreeNode) => boolean;
|
|
9
|
-
hasArrow: boolean;
|
|
10
|
-
initSelectedTopicIds: string[];
|
|
11
|
-
}
|
|
12
|
-
export declare const TopicFilter: ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }: TopicFilterProps) => JSX.Element;
|
|
13
|
-
export default TopicFilter;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RadioProps as MuiRadioProps, FormControlLabelProps } from '@mui/material';
|
|
2
|
-
export interface RadioProps extends FormControlLabelProps {
|
|
3
|
-
color?: 'primary' | 'secondary' | 'default';
|
|
4
|
-
size?: 'medium' | 'small';
|
|
5
|
-
caption?: string;
|
|
6
|
-
formControlLabelProps?: Partial<FormControlLabelProps>;
|
|
7
|
-
radioProps?: Partial<MuiRadioProps>;
|
|
8
|
-
}
|
|
9
|
-
export declare const Radio: ({ checked, disabled, label, labelPlacement, value, formControlLabelProps, radioProps, color, size, caption, }: RadioProps) => JSX.Element;
|
|
10
|
-
export default Radio;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { SelectProps } from '../../interfaces';
|
|
2
|
-
export declare const OutlinedSelect: ({ label, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasLabel, hasShrink, value, disabled, }: SelectProps) => JSX.Element;
|
|
3
|
-
export default OutlinedSelect;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { SelectProps } from '../../interfaces';
|
|
2
|
-
export declare function StandardSelect({ label, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasShrink, value, disabled, }: SelectProps): JSX.Element;
|
|
3
|
-
export default StandardSelect;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Select = exports.TextField = exports.Radio = exports.ButtonGroup = exports.Button = exports.SelectMenuItem = exports.TopicFilter = void 0;
|
|
7
|
-
var TopicFilter_1 = require("./lib/topic-filter/TopicFilter");
|
|
8
|
-
Object.defineProperty(exports, "TopicFilter", { enumerable: true, get: function () { return __importDefault(TopicFilter_1).default; } });
|
|
9
|
-
var SelectMenuItem_1 = require("./lib/menu-item/SelectMenuItem");
|
|
10
|
-
Object.defineProperty(exports, "SelectMenuItem", { enumerable: true, get: function () { return __importDefault(SelectMenuItem_1).default; } });
|
|
11
|
-
var Button_1 = require("./lib/button/Button");
|
|
12
|
-
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
|
|
13
|
-
var ButtonGroup_1 = require("./lib/button-group/ButtonGroup");
|
|
14
|
-
Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return __importDefault(ButtonGroup_1).default; } });
|
|
15
|
-
var Radio_1 = require("./lib/radio/Radio");
|
|
16
|
-
Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
|
|
17
|
-
var TextField_1 = require("./lib/text-field/TextField");
|
|
18
|
-
Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return __importDefault(TextField_1).default; } });
|
|
19
|
-
var Select_1 = require("./lib/select/Select");
|
|
20
|
-
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TopicFilter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const styles_1 = require("@material-ui/core/styles");
|
|
7
|
-
const ArrowRightRounded_1 = tslib_1.__importDefault(require("@material-ui/icons/ArrowRightRounded"));
|
|
8
|
-
const OutlinedSelect_1 = tslib_1.__importDefault(require("./select/OutlinedSelect"));
|
|
9
|
-
const SelectMenuItem_1 = tslib_1.__importDefault(require("./menu-item/SelectMenuItem"));
|
|
10
|
-
// self-defined-configs
|
|
11
|
-
const PLACEHOLDER = '請選擇';
|
|
12
|
-
// self-defined-components
|
|
13
|
-
const PREFIX = 'JuiTopicFilter';
|
|
14
|
-
const FiltersWrapper = styles_1.styled('div')({
|
|
15
|
-
display: 'flex',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
flexWrap: 'wrap',
|
|
18
|
-
});
|
|
19
|
-
const SelectWrapper = styles_1.styled('div')({
|
|
20
|
-
display: 'flex',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
});
|
|
23
|
-
const StyledArrowRightRoundedIcon = styles_1.styled(ArrowRightRounded_1.default)(({ theme }) => ({
|
|
24
|
-
margin: theme.spacing(-1, -1.5),
|
|
25
|
-
fontSize: theme.spacing(7),
|
|
26
|
-
color: '#444',
|
|
27
|
-
}));
|
|
28
|
-
const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
|
|
29
|
-
const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
|
|
30
|
-
const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
|
|
31
|
-
const [isFocusedList, setIsFocusedList] = react_1.useState([]);
|
|
32
|
-
const initSelectedLayers = () => {
|
|
33
|
-
const newLayeredTopicList = initSelectedTopicIds.reduce((topicListAccumulator, topicId, index) => {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
const selectedTopic = (_b = (_a = topicListAccumulator[index]) === null || _a === void 0 ? void 0 : _a.childTopics) === null || _b === void 0 ? void 0 : _b.find((childTopic) => childTopic.id === topicId);
|
|
36
|
-
if (!selectedTopic) {
|
|
37
|
-
return topicListAccumulator;
|
|
38
|
-
}
|
|
39
|
-
if (isLastLayer(selectedTopic)) {
|
|
40
|
-
return topicListAccumulator;
|
|
41
|
-
}
|
|
42
|
-
return [...topicListAccumulator, selectedTopic];
|
|
43
|
-
}, [topicTree]);
|
|
44
|
-
setLayeredTopicList(newLayeredTopicList);
|
|
45
|
-
setSelectedTopicIds(initSelectedTopicIds.slice(0, newLayeredTopicList.length));
|
|
46
|
-
setIsFocusedList(Array(newLayeredTopicList.length).fill(false));
|
|
47
|
-
};
|
|
48
|
-
const handleChange = (e, layerNumber, layeredTopic) => {
|
|
49
|
-
const selectedTopic = layeredTopic.childTopics.find((childTopic) => childTopic.id === e.target.value);
|
|
50
|
-
const newSelectedTopicIds = [
|
|
51
|
-
...selectedTopicIds.slice(0, layerNumber),
|
|
52
|
-
selectedTopic.id,
|
|
53
|
-
];
|
|
54
|
-
setSelectedTopicIds(newSelectedTopicIds);
|
|
55
|
-
onTopicSelected(selectedTopic, {
|
|
56
|
-
layerNumber,
|
|
57
|
-
selectedTopicIds: newSelectedTopicIds,
|
|
58
|
-
});
|
|
59
|
-
if (isLastLayer(selectedTopic)) {
|
|
60
|
-
setLayeredTopicList((prevTopicList) => prevTopicList.slice(0, layerNumber + 1));
|
|
61
|
-
setIsFocusedList((prevList) => prevList.slice(0, layerNumber + 1));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
setLayeredTopicList((prevTopicList) => [
|
|
65
|
-
...prevTopicList.slice(0, layerNumber + 1),
|
|
66
|
-
selectedTopic,
|
|
67
|
-
]);
|
|
68
|
-
setIsFocusedList((prevList) => [
|
|
69
|
-
...prevList.slice(0, layerNumber + 1),
|
|
70
|
-
false,
|
|
71
|
-
]);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
react_1.useEffect(() => {
|
|
75
|
-
if (!topicTree || Object.keys(topicTree).length === 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (initSelectedTopicIds.length !== 0) {
|
|
79
|
-
initSelectedLayers();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
setLayeredTopicList([topicTree]);
|
|
83
|
-
}, [topicTree]);
|
|
84
|
-
if (layeredTopicList.length === 0) {
|
|
85
|
-
return (react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', width: 220, placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
|
|
86
|
-
}
|
|
87
|
-
return (react_1.default.createElement(FiltersWrapper, null, layeredTopicList.map((layeredTopic, layerNumber) => {
|
|
88
|
-
const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
|
|
89
|
-
return (react_1.default.createElement(SelectWrapper, { key: layeredTopic.id },
|
|
90
|
-
react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', width: 220, paperMaxHeight: 412, hasLabel: hasLabel, placeholder: PLACEHOLDER, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
|
|
91
|
-
'data-testid': `layered-topic-${layerNumber}`,
|
|
92
|
-
}, OutlinedInputProps: {
|
|
93
|
-
inputProps: {
|
|
94
|
-
'aria-label': `layered-topic-${layerNumber}`,
|
|
95
|
-
},
|
|
96
|
-
onChange: (e) => {
|
|
97
|
-
handleChange(e, layerNumber, layeredTopic);
|
|
98
|
-
},
|
|
99
|
-
onFocus: () => {
|
|
100
|
-
setIsFocusedList((prevList) => {
|
|
101
|
-
const newList = [...prevList];
|
|
102
|
-
newList[layerNumber] = true;
|
|
103
|
-
return newList;
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
onBlur: () => {
|
|
107
|
-
setIsFocusedList((prevList) => {
|
|
108
|
-
const newList = [...prevList];
|
|
109
|
-
newList[layerNumber] = false;
|
|
110
|
-
return newList;
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
} },
|
|
114
|
-
react_1.default.createElement(SelectMenuItem_1.default, { width: 220, disabled: true }, PLACEHOLDER),
|
|
115
|
-
layeredTopic.childTopics.map((childTopic) => (react_1.default.createElement(SelectMenuItem_1.default, { width: 220, key: childTopic.id, value: childTopic.id, "data-testid": `layered-menuitem-${layerNumber}`, "data-is-content-topic": childTopic.isContentTopic }, childTopic.title)))),
|
|
116
|
-
hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(StyledArrowRightRoundedIcon, { fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
|
|
117
|
-
})));
|
|
118
|
-
};
|
|
119
|
-
exports.TopicFilter = TopicFilter;
|
|
120
|
-
exports.default = exports.TopicFilter;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Button = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const Button_1 = require("@mui/material/Button");
|
|
9
|
-
//utils
|
|
10
|
-
const Capitalize_1 = tslib_1.__importDefault(require("../../utils/Capitalize"));
|
|
11
|
-
const StyledButton = styles_1.styled(material_1.Button, {
|
|
12
|
-
shouldForwardProp: (prop) => prop !== 'active',
|
|
13
|
-
})(({ active, color = 'primary', theme }) => ({
|
|
14
|
-
// For variant: outlined
|
|
15
|
-
[`&.${Button_1.buttonClasses.outlined}${Capitalize_1.default(color)}`]: {
|
|
16
|
-
backgroundColor: active
|
|
17
|
-
? theme.palette[color].main
|
|
18
|
-
: theme.palette.common.white,
|
|
19
|
-
color: active ? theme.palette.common.white : theme.palette[color].main,
|
|
20
|
-
borderColor: theme.palette[color].main,
|
|
21
|
-
'&:hover': {
|
|
22
|
-
backgroundColor: active
|
|
23
|
-
? theme.palette[color].main
|
|
24
|
-
: styles_1.alpha(theme.palette[color].main, 0.1),
|
|
25
|
-
},
|
|
26
|
-
[`&.${Button_1.buttonClasses.disabled}`]: {
|
|
27
|
-
backgroundColor: theme.palette.common.white,
|
|
28
|
-
borderColor: theme.palette.action.disabledBackground,
|
|
29
|
-
color: theme.palette.action.disabled,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
// For variant: text
|
|
33
|
-
[`&.${Button_1.buttonClasses.text}${Capitalize_1.default(color)}`]: {
|
|
34
|
-
'&:hover': {
|
|
35
|
-
backgroundColor: styles_1.alpha(theme.palette[color].main, 0.1),
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
const Button = (_a) => {
|
|
40
|
-
var { active, children } = _a, otherProps = tslib_1.__rest(_a, ["active", "children"]);
|
|
41
|
-
return (react_1.default.createElement(StyledButton, Object.assign({ active: active }, otherProps), children));
|
|
42
|
-
};
|
|
43
|
-
exports.Button = Button;
|
|
44
|
-
exports.default = exports.Button;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ButtonGroup = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const ButtonGroup_1 = require("@mui/material/ButtonGroup");
|
|
9
|
-
//utils
|
|
10
|
-
const Capitalize_1 = tslib_1.__importDefault(require("../../utils/Capitalize"));
|
|
11
|
-
// self-defined-components
|
|
12
|
-
const StyledButtonGroup = styles_1.styled(material_1.ButtonGroup)(({ color = 'primary', theme }) => ({
|
|
13
|
-
[`& .${ButtonGroup_1.buttonGroupClasses.groupedOutlined}${Capitalize_1.default(color)}.${ButtonGroup_1.buttonGroupClasses.grouped}.${ButtonGroup_1.buttonGroupClasses.disabled}`]: {
|
|
14
|
-
borderColor: styles_1.alpha(theme.palette[color].main, 0.5),
|
|
15
|
-
color: styles_1.alpha(theme.palette[color].main, 0.5),
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
const ButtonGroup = (_a) => {
|
|
19
|
-
var { children } = _a, otherProps = tslib_1.__rest(_a, ["children"]);
|
|
20
|
-
return (react_1.default.createElement(StyledButtonGroup, Object.assign({}, otherProps), children));
|
|
21
|
-
};
|
|
22
|
-
exports.ButtonGroup = ButtonGroup;
|
|
23
|
-
exports.default = exports.ButtonGroup;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const MenuItem_1 = require("@mui/material/MenuItem");
|
|
7
|
-
const SelectMenuItem = (_a) => {
|
|
8
|
-
var { children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["children", "value"]);
|
|
9
|
-
return (react_1.default.createElement(material_1.MenuItem, Object.assign({ sx: (theme) => ({
|
|
10
|
-
whiteSpace: 'unset',
|
|
11
|
-
color: theme.palette.text.primary,
|
|
12
|
-
[`&.${MenuItem_1.menuItemClasses.selected}`]: {
|
|
13
|
-
backgroundColor: theme.palette.grey[300],
|
|
14
|
-
'&:hover': {
|
|
15
|
-
backgroundColor: theme.palette.grey[200],
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
}), value: value }, otherProps), children));
|
|
19
|
-
};
|
|
20
|
-
exports.default = SelectMenuItem;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Radio = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const FormControlLabel_1 = require("@mui/material/FormControlLabel");
|
|
9
|
-
const Radio_1 = require("@mui/material/Radio");
|
|
10
|
-
// self-defined-components
|
|
11
|
-
const StyledFormControlLabel = styles_1.styled(material_1.FormControlLabel)(({ theme }) => ({
|
|
12
|
-
[`& .${FormControlLabel_1.formControlLabelClasses.label}`]: {
|
|
13
|
-
color: theme.palette.text.secondary,
|
|
14
|
-
[`&.${FormControlLabel_1.formControlLabelClasses.disabled}`]: {
|
|
15
|
-
color: theme.palette.text.disabled,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
[`& .${Radio_1.radioClasses.checked} + .${FormControlLabel_1.formControlLabelClasses.label}`]: {
|
|
19
|
-
color: theme.palette.text.primary,
|
|
20
|
-
},
|
|
21
|
-
}));
|
|
22
|
-
const Radio = ({ checked, disabled, label, labelPlacement, value, formControlLabelProps, radioProps, color = 'secondary', size = 'medium', caption = '', }) => {
|
|
23
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
24
|
-
react_1.default.createElement(StyledFormControlLabel, Object.assign({ control: react_1.default.createElement(material_1.Radio, Object.assign({ sx: (theme) => ({
|
|
25
|
-
color: theme.palette.text.primary,
|
|
26
|
-
}), color: color, size: size }, radioProps)), checked: checked, disabled: disabled, label: label, labelPlacement: labelPlacement, value: value }, formControlLabelProps)),
|
|
27
|
-
caption && (react_1.default.createElement(material_1.Typography, { sx: (theme) => ({
|
|
28
|
-
color: theme.palette.text.disabled,
|
|
29
|
-
margin: '0 0 0 30px',
|
|
30
|
-
}), variant: 'body2' }, caption))));
|
|
31
|
-
};
|
|
32
|
-
exports.Radio = Radio;
|
|
33
|
-
exports.default = exports.Radio;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OutlinedSelect = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const FormHelperText_1 = require("@mui/material/FormHelperText");
|
|
9
|
-
const InputLabel_1 = require("@mui/material/InputLabel");
|
|
10
|
-
const OutlinedInput_1 = require("@mui/material/OutlinedInput");
|
|
11
|
-
const InputBase_1 = require("@mui/material/InputBase");
|
|
12
|
-
const StyledInputLabel = styles_1.styled(material_1.InputLabel, {
|
|
13
|
-
shouldForwardProp: (prop) => prop !== 'color',
|
|
14
|
-
})(({ color, theme }) => ({
|
|
15
|
-
color: theme.palette.text.secondary,
|
|
16
|
-
[`&.${InputLabel_1.inputLabelClasses.outlined}`]: {
|
|
17
|
-
[`&:not(.${InputLabel_1.inputLabelClasses.disabled}) .${InputLabel_1.inputLabelClasses.focused}`]: {
|
|
18
|
-
color: theme.palette.action.active,
|
|
19
|
-
},
|
|
20
|
-
[`&.${InputLabel_1.inputLabelClasses.sizeSmall}:not(.${InputLabel_1.inputLabelClasses.shrink})`]: {
|
|
21
|
-
transform: 'translate(12px, 12px) scale(1)',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
[`&.${InputLabel_1.inputLabelClasses.shrink}:not(.${InputLabel_1.inputLabelClasses.error}):not(.${InputLabel_1.inputLabelClasses.disabled}).${InputLabel_1.inputLabelClasses.focused}`]: {
|
|
25
|
-
color: theme.palette[color].main,
|
|
26
|
-
},
|
|
27
|
-
[`&.${InputLabel_1.inputLabelClasses.shrink}`]: {
|
|
28
|
-
backgroundColor: '#ffffff',
|
|
29
|
-
padding: '0 2px',
|
|
30
|
-
},
|
|
31
|
-
}));
|
|
32
|
-
const StyledOutlinedInput = styles_1.styled(material_1.OutlinedInput)(({ theme }) => ({
|
|
33
|
-
[`&.${OutlinedInput_1.outlinedInputClasses.root}`]: {
|
|
34
|
-
[`&.${OutlinedInput_1.outlinedInputClasses.error}.${OutlinedInput_1.outlinedInputClasses.focused} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
35
|
-
borderColor: `${theme.palette.error.main}`,
|
|
36
|
-
},
|
|
37
|
-
[`& .${InputBase_1.inputBaseClasses.inputSizeSmall}`]: {
|
|
38
|
-
padding: '12.5px 15px 12.5px 12px',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
[`& .${OutlinedInput_1.outlinedInputClasses.input}`]: {
|
|
42
|
-
color: theme.palette.text.primary,
|
|
43
|
-
'&:focus': {
|
|
44
|
-
background: 'rgba(0,0,0,0)',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
}));
|
|
48
|
-
const OutlinedSelect = ({ label, helperText, InputProps, SelectProps, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, value = '', disabled = false, }) => {
|
|
49
|
-
const hasHelperText = !!helperText;
|
|
50
|
-
return (react_1.default.createElement(material_1.FormControl, { sx: (theme) => ({
|
|
51
|
-
backgroundColor: 'white',
|
|
52
|
-
'&:hover': {
|
|
53
|
-
[`& :not(.${OutlinedInput_1.outlinedInputClasses.disabled}):not(.${OutlinedInput_1.outlinedInputClasses.error}) .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
54
|
-
borderColor: theme.palette[color].main,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
}), size: size, disabled: disabled, error: error, color: color, className: className },
|
|
58
|
-
hasLabel && (react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, label)),
|
|
59
|
-
react_1.default.createElement(material_1.Select, Object.assign({ value: value, label: hasLabel ? label : undefined, MenuProps: {
|
|
60
|
-
PaperProps: {
|
|
61
|
-
sx: {
|
|
62
|
-
maxHeight: paperMaxHeight,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
disableAutoFocusItem: true,
|
|
66
|
-
anchorOrigin: {
|
|
67
|
-
vertical: 2,
|
|
68
|
-
horizontal: 'left',
|
|
69
|
-
},
|
|
70
|
-
transformOrigin: {
|
|
71
|
-
vertical: 'top',
|
|
72
|
-
horizontal: 'left',
|
|
73
|
-
},
|
|
74
|
-
}, input: react_1.default.createElement(StyledOutlinedInput, Object.assign({ color: color, label: hasLabel ? label : undefined, disabled: disabled }, InputProps)) }, SelectProps), children),
|
|
75
|
-
hasHelperText && (react_1.default.createElement(material_1.FormHelperText, { sx: {
|
|
76
|
-
[`&.${FormHelperText_1.formHelperTextClasses.root}`]: {
|
|
77
|
-
marginLeft: 0,
|
|
78
|
-
},
|
|
79
|
-
} }, helperText))));
|
|
80
|
-
};
|
|
81
|
-
exports.OutlinedSelect = OutlinedSelect;
|
|
82
|
-
exports.default = exports.OutlinedSelect;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Select = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const OutlinedSelect_1 = require("./OutlinedSelect");
|
|
7
|
-
const StandardSelect_1 = require("./StandardSelect");
|
|
8
|
-
function Select(_a) {
|
|
9
|
-
var { variant } = _a, props = tslib_1.__rest(_a, ["variant"]);
|
|
10
|
-
if (variant === 'outlined') {
|
|
11
|
-
return react_1.default.createElement(OutlinedSelect_1.OutlinedSelect, Object.assign({}, props));
|
|
12
|
-
}
|
|
13
|
-
return react_1.default.createElement(StandardSelect_1.StandardSelect, Object.assign({}, props));
|
|
14
|
-
}
|
|
15
|
-
exports.Select = Select;
|
|
16
|
-
exports.default = Select;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StandardSelect = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const InputLabel_1 = require("@mui/material/InputLabel");
|
|
9
|
-
const Input_1 = require("@mui/material/Input");
|
|
10
|
-
const StyledInputLabel = styles_1.styled(material_1.InputLabel, {
|
|
11
|
-
shouldForwardProp: (prop) => prop !== 'color',
|
|
12
|
-
})(({ color, theme }) => ({
|
|
13
|
-
[`&.${InputLabel_1.inputLabelClasses.root}`]: {
|
|
14
|
-
color: theme.palette.text.disabled,
|
|
15
|
-
},
|
|
16
|
-
[`&.${InputLabel_1.inputLabelClasses.focused}`]: {
|
|
17
|
-
color: theme.palette[color].main,
|
|
18
|
-
},
|
|
19
|
-
[`&.${InputLabel_1.inputLabelClasses.error}`]: {
|
|
20
|
-
color: theme.palette.error.main,
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
const StyledInput = styles_1.styled(material_1.Input, {
|
|
24
|
-
shouldForwardProp: (prop) => prop !== 'color',
|
|
25
|
-
})(({ color, theme }) => ({
|
|
26
|
-
color: theme.palette.text.primary,
|
|
27
|
-
[`& .${Input_1.inputClasses.input}`]: {
|
|
28
|
-
'&:focus': {
|
|
29
|
-
background: 'rgba(0,0,0,0)',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
[`&.${Input_1.inputClasses.underline}:not(.${Input_1.inputClasses.disabled}):not(.${Input_1.inputClasses.error})`]: {
|
|
33
|
-
'&:after,&:hover:before': {
|
|
34
|
-
borderBottomColor: theme.palette[color].main,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
[`&.${Input_1.inputClasses.underline}.${Input_1.inputClasses.error}:not(.${Input_1.inputClasses.disabled})`]: {
|
|
38
|
-
'&:after,&:hover:before': {
|
|
39
|
-
borderBottomColor: theme.palette.error.main,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
43
|
-
function StandardSelect({ label, helperText, InputProps, SelectProps, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
|
|
44
|
-
const hasHelperText = !!helperText;
|
|
45
|
-
return (react_1.default.createElement(material_1.FormControl, { variant: 'standard', color: color, size: size, disabled: disabled, error: error, className: className },
|
|
46
|
-
react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, label),
|
|
47
|
-
react_1.default.createElement(material_1.Select, Object.assign({ label: label, value: value, MenuProps: {
|
|
48
|
-
PaperProps: {
|
|
49
|
-
sx: {
|
|
50
|
-
maxHeight: paperMaxHeight,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
anchorOrigin: {
|
|
54
|
-
vertical: 2,
|
|
55
|
-
horizontal: 'left',
|
|
56
|
-
},
|
|
57
|
-
transformOrigin: {
|
|
58
|
-
vertical: 'top',
|
|
59
|
-
horizontal: 'left',
|
|
60
|
-
},
|
|
61
|
-
}, input: react_1.default.createElement(StyledInput, Object.assign({ color: color }, InputProps)) }, SelectProps), children),
|
|
62
|
-
hasHelperText && react_1.default.createElement(material_1.FormHelperText, null, helperText)));
|
|
63
|
-
}
|
|
64
|
-
exports.StandardSelect = StandardSelect;
|
|
65
|
-
exports.default = StandardSelect;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextField = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const TextField_1 = require("@mui/material/TextField");
|
|
9
|
-
const Input_1 = require("@mui/material/Input");
|
|
10
|
-
const InputLabel_1 = require("@mui/material/InputLabel");
|
|
11
|
-
const OutlinedInput_1 = require("@mui/material/OutlinedInput");
|
|
12
|
-
const FormHelperText_1 = require("@mui/material/FormHelperText");
|
|
13
|
-
//utils
|
|
14
|
-
const Capitalize_1 = tslib_1.__importDefault(require("../../utils/Capitalize"));
|
|
15
|
-
// self-defined-components
|
|
16
|
-
const StyledTextField = styles_1.styled(material_1.TextField)(({ label, color = 'primary', theme }) => ({
|
|
17
|
-
[`& .${InputLabel_1.inputLabelClasses.error}`]: {
|
|
18
|
-
[`&:not(.${InputLabel_1.inputLabelClasses.shrink})`]: {
|
|
19
|
-
color: theme.palette.text.secondary,
|
|
20
|
-
},
|
|
21
|
-
[`&.${InputLabel_1.inputLabelClasses.disabled}`]: {
|
|
22
|
-
color: theme.palette.text.disabled,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
[`& .${InputLabel_1.inputLabelClasses.error}.${InputLabel_1.inputLabelClasses.focused}`]: {
|
|
26
|
-
color: theme.palette.error.main,
|
|
27
|
-
},
|
|
28
|
-
// For variant: standard | filled
|
|
29
|
-
[`& .${Input_1.inputClasses.underline}:not(.${Input_1.inputClasses.disabled})`]: {
|
|
30
|
-
[`&.MuiInputBase-color${Capitalize_1.default(color)}:hover:before`]: {
|
|
31
|
-
borderColor: theme.palette[color].main,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
// For variant: outlined
|
|
35
|
-
[`& .${Input_1.inputClasses.disabled} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
36
|
-
borderStyle: 'dotted',
|
|
37
|
-
},
|
|
38
|
-
[`& .${Input_1.inputClasses.error}.${Input_1.inputClasses.focused} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
39
|
-
borderColor: theme.palette.error.main,
|
|
40
|
-
},
|
|
41
|
-
[`&.${TextField_1.textFieldClasses.root} :not(.${Input_1.inputClasses.disabled}):not(.${Input_1.inputClasses.error})`]: {
|
|
42
|
-
[`&.MuiInputBase-color${Capitalize_1.default(color)}:hover .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
43
|
-
borderColor: theme.palette[color].main,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
[`& .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
47
|
-
'& > legend': {
|
|
48
|
-
maxWidth: label === '' && 0,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}));
|
|
52
|
-
const TextField = (props) => {
|
|
53
|
-
var _a;
|
|
54
|
-
const hasEndAdornment = !!((_a = props === null || props === void 0 ? void 0 : props.InputProps) === null || _a === void 0 ? void 0 : _a.endAdornment);
|
|
55
|
-
const { InputLabelProps, InputProps } = props, otherProps = tslib_1.__rest(props, ["InputLabelProps", "InputProps"]);
|
|
56
|
-
return (react_1.default.createElement(StyledTextField, Object.assign({ InputLabelProps: Object.assign(Object.assign({}, InputLabelProps), { shrink: hasEndAdornment ? true : undefined }), FormHelperTextProps: {
|
|
57
|
-
sx: (theme) => ({
|
|
58
|
-
[`&.${FormHelperText_1.formHelperTextClasses.root}`]: {
|
|
59
|
-
marginLeft: 0,
|
|
60
|
-
[`&.${Input_1.inputClasses.error}`]: {
|
|
61
|
-
color: theme.palette.error.main,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
}, InputProps: Object.assign({}, InputProps) }, otherProps)));
|
|
66
|
-
};
|
|
67
|
-
exports.TextField = TextField;
|
|
68
|
-
exports.default = exports.TextField;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TopicFilter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const ArrowRightRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/ArrowRightRounded"));
|
|
8
|
-
const material_1 = require("@mui/material");
|
|
9
|
-
const Select_1 = tslib_1.__importDefault(require("../select/Select"));
|
|
10
|
-
const SelectMenuItem_1 = tslib_1.__importDefault(require("../menu-item/SelectMenuItem"));
|
|
11
|
-
// self-defined-configs
|
|
12
|
-
const LABEL = '請選擇';
|
|
13
|
-
const StyledSelect = styles_1.styled(Select_1.default)(({ theme }) => ({
|
|
14
|
-
width: 220,
|
|
15
|
-
margin: theme.spacing(1),
|
|
16
|
-
}));
|
|
17
|
-
const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
|
|
18
|
-
const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
|
|
19
|
-
const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
|
|
20
|
-
const [isFocusedList, setIsFocusedList] = react_1.useState([]);
|
|
21
|
-
const initSelectedLayers = () => {
|
|
22
|
-
const newLayeredTopicList = initSelectedTopicIds.reduce((topicListAccumulator, topicId, index) => {
|
|
23
|
-
var _a, _b;
|
|
24
|
-
const selectedTopic = (_b = (_a = topicListAccumulator[index]) === null || _a === void 0 ? void 0 : _a.childTopics) === null || _b === void 0 ? void 0 : _b.find((childTopic) => childTopic.id === topicId);
|
|
25
|
-
if (!selectedTopic) {
|
|
26
|
-
return topicListAccumulator;
|
|
27
|
-
}
|
|
28
|
-
if (isLastLayer(selectedTopic)) {
|
|
29
|
-
return topicListAccumulator;
|
|
30
|
-
}
|
|
31
|
-
return [...topicListAccumulator, selectedTopic];
|
|
32
|
-
}, [topicTree]);
|
|
33
|
-
setLayeredTopicList(newLayeredTopicList);
|
|
34
|
-
setSelectedTopicIds(initSelectedTopicIds.slice(0, newLayeredTopicList.length));
|
|
35
|
-
setIsFocusedList(Array(newLayeredTopicList.length).fill(false));
|
|
36
|
-
};
|
|
37
|
-
const handleChange = (e, layerNumber, layeredTopic) => {
|
|
38
|
-
const selectedTopic = layeredTopic.childTopics.find((childTopic) => childTopic.id === e.target.value);
|
|
39
|
-
const newSelectedTopicIds = [
|
|
40
|
-
...selectedTopicIds.slice(0, layerNumber),
|
|
41
|
-
selectedTopic.id,
|
|
42
|
-
];
|
|
43
|
-
setSelectedTopicIds(newSelectedTopicIds);
|
|
44
|
-
onTopicSelected(selectedTopic, {
|
|
45
|
-
layerNumber,
|
|
46
|
-
selectedTopicIds: newSelectedTopicIds,
|
|
47
|
-
});
|
|
48
|
-
if (isLastLayer(selectedTopic)) {
|
|
49
|
-
setLayeredTopicList((prevTopicList) => prevTopicList.slice(0, layerNumber + 1));
|
|
50
|
-
setIsFocusedList((prevList) => prevList.slice(0, layerNumber + 1));
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
setLayeredTopicList((prevTopicList) => [
|
|
54
|
-
...prevTopicList.slice(0, layerNumber + 1),
|
|
55
|
-
selectedTopic,
|
|
56
|
-
]);
|
|
57
|
-
setIsFocusedList((prevList) => [
|
|
58
|
-
...prevList.slice(0, layerNumber + 1),
|
|
59
|
-
false,
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
react_1.useEffect(() => {
|
|
64
|
-
if (!topicTree || Object.keys(topicTree).length === 0) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (initSelectedTopicIds.length !== 0) {
|
|
68
|
-
initSelectedLayers();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
setLayeredTopicList([topicTree]);
|
|
72
|
-
}, [topicTree]);
|
|
73
|
-
if (layeredTopicList.length === 0) {
|
|
74
|
-
return (react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', label: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
|
|
75
|
-
}
|
|
76
|
-
return (react_1.default.createElement(material_1.Box, { sx: {
|
|
77
|
-
display: 'flex',
|
|
78
|
-
alignItems: 'center',
|
|
79
|
-
flexWrap: 'wrap',
|
|
80
|
-
} }, layeredTopicList.map((layeredTopic, layerNumber) => {
|
|
81
|
-
const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
|
|
82
|
-
return (react_1.default.createElement(material_1.Box, { sx: {
|
|
83
|
-
display: 'flex',
|
|
84
|
-
alignItems: 'center',
|
|
85
|
-
}, key: layeredTopic.id },
|
|
86
|
-
react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', label: LABEL, paperMaxHeight: 412, hasLabel: hasLabel, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
|
|
87
|
-
'data-testid': `layered-topic-${layerNumber}`,
|
|
88
|
-
}, InputProps: {
|
|
89
|
-
inputProps: {
|
|
90
|
-
'aria-label': `layered-topic-${layerNumber}`,
|
|
91
|
-
},
|
|
92
|
-
onChange: (e) => {
|
|
93
|
-
handleChange(e, layerNumber, layeredTopic);
|
|
94
|
-
},
|
|
95
|
-
onFocus: () => {
|
|
96
|
-
setIsFocusedList((prevList) => {
|
|
97
|
-
const newList = [...prevList];
|
|
98
|
-
newList[layerNumber] = true;
|
|
99
|
-
return newList;
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
onBlur: () => {
|
|
103
|
-
setIsFocusedList((prevList) => {
|
|
104
|
-
const newList = [...prevList];
|
|
105
|
-
newList[layerNumber] = false;
|
|
106
|
-
return newList;
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
} },
|
|
110
|
-
react_1.default.createElement(SelectMenuItem_1.default, { disabled: true, value: '' }, LABEL),
|
|
111
|
-
layeredTopic.childTopics.map((childTopic) => (react_1.default.createElement(SelectMenuItem_1.default, { key: childTopic.id, value: childTopic.id, "data-testid": `layered-menuitem-${layerNumber}`, "data-is-content-topic": childTopic.isContentTopic }, childTopic.title)))),
|
|
112
|
-
hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(ArrowRightRounded_1.default, { sx: (theme) => ({
|
|
113
|
-
margin: theme.spacing(-1, -1.5),
|
|
114
|
-
fontSize: theme.spacing(7),
|
|
115
|
-
color: '#444',
|
|
116
|
-
}), fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
|
|
117
|
-
})));
|
|
118
|
-
};
|
|
119
|
-
exports.TopicFilter = TopicFilter;
|
|
120
|
-
exports.default = exports.TopicFilter;
|