@junyiacademy/ui-test 1.5.15 → 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/dist/index.js +7 -0
- package/{declarations/libs/ui/src → dist}/interfaces/index.d.ts +4 -1
- package/dist/interfaces/index.js +1 -0
- package/{declarations/libs/ui/src → dist}/lib/button/Button.d.ts +0 -0
- package/dist/lib/button/Button.js +50 -0
- package/{declarations/libs/ui/src → dist}/lib/button-group/ButtonGroup.d.ts +0 -0
- package/dist/lib/button-group/ButtonGroup.js +29 -0
- package/{declarations/libs/ui/src → dist}/lib/menu-item/SelectMenuItem.d.ts +0 -0
- package/dist/lib/menu-item/SelectMenuItem.js +32 -0
- package/dist/lib/radio/Radio.d.ts +11 -0
- package/dist/lib/radio/Radio.js +47 -0
- package/dist/lib/select/OutlinedSelect.d.ts +3 -0
- package/dist/lib/select/OutlinedSelect.js +95 -0
- package/{declarations/libs/ui/src → dist}/lib/select/Select.d.ts +0 -0
- package/dist/lib/select/Select.js +22 -0
- package/dist/lib/select/StandardSelect.d.ts +3 -0
- package/dist/lib/select/StandardSelect.js +60 -0
- package/dist/lib/text-field/TextField.d.ts +3 -0
- package/dist/lib/text-field/TextField.js +78 -0
- package/{declarations/libs/ui/src → dist}/lib/topic-filter/TopicFilter.d.ts +0 -0
- package/dist/{libs/ui/src/lib → lib}/topic-filter/TopicFilter.js +21 -26
- package/dist/styles/theme.d.ts +24 -0
- package/dist/styles/theme.js +40 -0
- package/{declarations/libs/ui/src → dist}/utils/Capitalize.d.ts +0 -0
- package/dist/utils/Capitalize.js +3 -0
- package/dist/utils/topicTree.d.ts +2 -0
- package/dist/utils/topicTree.js +174 -0
- package/package.json +6 -6
- 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/utils/Capitalize.js +0 -6
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as TopicFilter } from './lib/topic-filter/TopicFilter';
|
|
2
|
+
export { default as SelectMenuItem } from './lib/menu-item/SelectMenuItem';
|
|
3
|
+
export { default as Button } from './lib/button/Button';
|
|
4
|
+
export { default as ButtonGroup } from './lib/button-group/ButtonGroup';
|
|
5
|
+
export { default as Radio } from './lib/radio/Radio';
|
|
6
|
+
export { default as TextField } from './lib/text-field/TextField';
|
|
7
|
+
export { default as Select } from './lib/select/Select';
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
14
|
+
import { Button as MuiButton, } from '@mui/material';
|
|
15
|
+
import { buttonClasses } from '@mui/material/Button';
|
|
16
|
+
// utils
|
|
17
|
+
import capitalize from '../../utils/Capitalize';
|
|
18
|
+
const StyledButton = styled(MuiButton, {
|
|
19
|
+
shouldForwardProp: (prop) => prop !== 'active',
|
|
20
|
+
})(({ active, color = 'primary', theme }) => ({
|
|
21
|
+
// For variant: outlined
|
|
22
|
+
[`&.${buttonClasses.outlined}${capitalize(color)}`]: {
|
|
23
|
+
backgroundColor: active
|
|
24
|
+
? theme.palette[color].main
|
|
25
|
+
: theme.palette.common.white,
|
|
26
|
+
color: active ? theme.palette.common.white : theme.palette[color].main,
|
|
27
|
+
borderColor: theme.palette[color].main,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
backgroundColor: active
|
|
30
|
+
? theme.palette[color].main
|
|
31
|
+
: alpha(theme.palette[color].main, 0.1),
|
|
32
|
+
},
|
|
33
|
+
[`&.${buttonClasses.disabled}`]: {
|
|
34
|
+
backgroundColor: theme.palette.common.white,
|
|
35
|
+
borderColor: theme.palette.action.disabledBackground,
|
|
36
|
+
color: theme.palette.action.disabled,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
// For variant: text
|
|
40
|
+
[`&.${buttonClasses.text}${capitalize(color)}`]: {
|
|
41
|
+
'&:hover': {
|
|
42
|
+
backgroundColor: alpha(theme.palette[color].main, 0.1),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
export const Button = (_a) => {
|
|
47
|
+
var { active, children } = _a, otherProps = __rest(_a, ["active", "children"]);
|
|
48
|
+
return (React.createElement(StyledButton, Object.assign({ active: active }, otherProps), children));
|
|
49
|
+
};
|
|
50
|
+
export default Button;
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
14
|
+
import { ButtonGroup as MuiButtonGroup, } from '@mui/material';
|
|
15
|
+
import { buttonGroupClasses } from '@mui/material/ButtonGroup';
|
|
16
|
+
// utils
|
|
17
|
+
import capitalize from '../../utils/Capitalize';
|
|
18
|
+
// self-defined-components
|
|
19
|
+
const StyledButtonGroup = styled(MuiButtonGroup)(({ color = 'primary', theme }) => ({
|
|
20
|
+
[`& .${buttonGroupClasses.groupedOutlined}${capitalize(color)}.${buttonGroupClasses.grouped}.${buttonGroupClasses.disabled}`]: {
|
|
21
|
+
borderColor: alpha(theme.palette[color].main, 0.5),
|
|
22
|
+
color: alpha(theme.palette[color].main, 0.5),
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
export const ButtonGroup = (_a) => {
|
|
26
|
+
var { children } = _a, otherProps = __rest(_a, ["children"]);
|
|
27
|
+
return (React.createElement(StyledButtonGroup, Object.assign({}, otherProps), children));
|
|
28
|
+
};
|
|
29
|
+
export default ButtonGroup;
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { MenuItem } from '@mui/material';
|
|
14
|
+
import { menuItemClasses } from '@mui/material/MenuItem';
|
|
15
|
+
const SelectMenuItem = (_a) => {
|
|
16
|
+
var { children, value = '' } = _a, otherProps = __rest(_a, ["children", "value"]);
|
|
17
|
+
const { sx: menuItemSx } = otherProps, otherMenuItemProps = __rest(otherProps, ["sx"]);
|
|
18
|
+
return (React.createElement(MenuItem, Object.assign({ sx: [
|
|
19
|
+
(theme) => ({
|
|
20
|
+
whiteSpace: 'unset',
|
|
21
|
+
color: theme.palette.text.primary,
|
|
22
|
+
[`&.${menuItemClasses.selected}`]: {
|
|
23
|
+
backgroundColor: theme.palette.grey[300],
|
|
24
|
+
'&:hover': {
|
|
25
|
+
backgroundColor: theme.palette.grey[200],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
...(Array.isArray(menuItemSx) ? menuItemSx : [menuItemSx]),
|
|
30
|
+
], value: value }, otherMenuItemProps), children));
|
|
31
|
+
};
|
|
32
|
+
export default SelectMenuItem;
|
|
@@ -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,47 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { Radio as MuiRadio, FormControlLabel, Typography, } from '@mui/material';
|
|
15
|
+
import { formControlLabelClasses } from '@mui/material/FormControlLabel';
|
|
16
|
+
import { radioClasses } from '@mui/material/Radio';
|
|
17
|
+
// self-defined-components
|
|
18
|
+
const StyledFormControlLabel = styled(FormControlLabel)(({ theme }) => ({
|
|
19
|
+
[`& .${formControlLabelClasses.label}`]: {
|
|
20
|
+
color: theme.palette.text.secondary,
|
|
21
|
+
[`&.${formControlLabelClasses.disabled}`]: {
|
|
22
|
+
color: theme.palette.text.disabled,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
[`& .${radioClasses.checked} + .${formControlLabelClasses.label}`]: {
|
|
26
|
+
color: theme.palette.text.primary,
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
export const Radio = ({ checked, disabled, label, labelPlacement, value, FormControlLabelProps = {}, RadioProps = {}, TypographyProps = {}, color = 'secondary', size = 'medium', caption = '', }) => {
|
|
30
|
+
const { sx: radioSx = [] } = RadioProps, otherRadioProps = __rest(RadioProps, ["sx"]);
|
|
31
|
+
const { sx: typographySx = [] } = TypographyProps, otherTypographyProps = __rest(TypographyProps, ["sx"]);
|
|
32
|
+
return (React.createElement(React.Fragment, null,
|
|
33
|
+
React.createElement(StyledFormControlLabel, Object.assign({ control: React.createElement(MuiRadio, Object.assign({ sx: [
|
|
34
|
+
(theme) => ({
|
|
35
|
+
color: theme.palette.text.primary,
|
|
36
|
+
}),
|
|
37
|
+
...(Array.isArray(radioSx) ? radioSx : [radioSx]),
|
|
38
|
+
], color: color, size: size }, otherRadioProps)), checked: checked, disabled: disabled, label: label, labelPlacement: labelPlacement, value: value }, FormControlLabelProps)),
|
|
39
|
+
caption && (React.createElement(Typography, Object.assign({ sx: [
|
|
40
|
+
(theme) => ({
|
|
41
|
+
color: theme.palette.text.disabled,
|
|
42
|
+
margin: '0 0 0 30px',
|
|
43
|
+
}),
|
|
44
|
+
...(Array.isArray(typographySx) ? typographySx : [typographySx]),
|
|
45
|
+
], variant: "body2" }, otherTypographyProps), caption))));
|
|
46
|
+
};
|
|
47
|
+
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;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { InputLabel, FormControl, Select, OutlinedInput, FormHelperText, } from '@mui/material';
|
|
15
|
+
import { formHelperTextClasses } from '@mui/material/FormHelperText';
|
|
16
|
+
import { inputLabelClasses } from '@mui/material/InputLabel';
|
|
17
|
+
import { outlinedInputClasses } from '@mui/material/OutlinedInput';
|
|
18
|
+
import { inputBaseClasses } from '@mui/material/InputBase';
|
|
19
|
+
const StyledInputLabel = styled(InputLabel, {
|
|
20
|
+
shouldForwardProp: (prop) => prop !== 'color',
|
|
21
|
+
})(({ color, theme }) => ({
|
|
22
|
+
color: theme.palette.text.secondary,
|
|
23
|
+
[`&.${inputLabelClasses.outlined}`]: {
|
|
24
|
+
[`&:not(.${inputLabelClasses.disabled}) .${inputLabelClasses.focused}`]: {
|
|
25
|
+
color: theme.palette.action.active,
|
|
26
|
+
},
|
|
27
|
+
[`&.${inputLabelClasses.sizeSmall}:not(.${inputLabelClasses.shrink})`]: {
|
|
28
|
+
transform: 'translate(12px, 12px) scale(1)',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
// eslint-disable-next-line
|
|
32
|
+
[`&.${inputLabelClasses.shrink}:not(.${inputLabelClasses.error}):not(.${inputLabelClasses.disabled}).${inputLabelClasses.focused}`]: {
|
|
33
|
+
color: theme.palette[color].main,
|
|
34
|
+
},
|
|
35
|
+
[`&.${inputLabelClasses.shrink}`]: {
|
|
36
|
+
backgroundColor: '#ffffff',
|
|
37
|
+
padding: '0 2px',
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
const StyledOutlinedInput = styled(OutlinedInput)(({ theme }) => ({
|
|
41
|
+
[`&.${outlinedInputClasses.root}`]: {
|
|
42
|
+
[`&.${outlinedInputClasses.error}.${outlinedInputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
|
|
43
|
+
borderColor: `${theme.palette.error.main}`,
|
|
44
|
+
},
|
|
45
|
+
[`& .${inputBaseClasses.inputSizeSmall}`]: {
|
|
46
|
+
padding: '12.5px 15px 12.5px 12px',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
[`& .${outlinedInputClasses.input}`]: {
|
|
50
|
+
color: theme.palette.text.primary,
|
|
51
|
+
'&:focus': {
|
|
52
|
+
background: 'rgba(0,0,0,0)',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
|
+
export const OutlinedSelect = ({ label, helperText, FormControlProps = {}, InputLabelProps = {}, InputProps = {}, SelectProps = {}, FormHelperTextProps = {}, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, value = '', disabled = false, }) => {
|
|
57
|
+
const hasHelperText = !!helperText;
|
|
58
|
+
const { sx: formControlSx = [] } = FormControlProps, otherFormControlProps = __rest(FormControlProps, ["sx"]);
|
|
59
|
+
const { sx: formHelperTextSx = [] } = FormHelperTextProps, otherFormHelperTextProps = __rest(FormHelperTextProps, ["sx"]);
|
|
60
|
+
return (React.createElement(FormControl, Object.assign({ sx: [
|
|
61
|
+
(theme) => ({
|
|
62
|
+
backgroundColor: 'white',
|
|
63
|
+
'&:hover': {
|
|
64
|
+
// eslint-disable-next-line
|
|
65
|
+
[`& :not(.${outlinedInputClasses.disabled}):not(.${outlinedInputClasses.error}) .${outlinedInputClasses.notchedOutline}`]: {
|
|
66
|
+
borderColor: theme.palette[color].main,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
...(Array.isArray(formControlSx) ? formControlSx : [formControlSx]),
|
|
71
|
+
], size: size, disabled: disabled, error: error, color: color, className: className }, otherFormControlProps),
|
|
72
|
+
hasLabel && (React.createElement(StyledInputLabel, Object.assign({ color: color, shrink: hasShrink ? true : undefined }, InputLabelProps), label)),
|
|
73
|
+
React.createElement(Select, Object.assign({ value: value, label: hasLabel ? label : undefined, MenuProps: {
|
|
74
|
+
PaperProps: {
|
|
75
|
+
sx: {
|
|
76
|
+
maxHeight: paperMaxHeight,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
disableAutoFocusItem: true,
|
|
80
|
+
anchorOrigin: {
|
|
81
|
+
vertical: 2,
|
|
82
|
+
horizontal: 'left',
|
|
83
|
+
},
|
|
84
|
+
transformOrigin: {
|
|
85
|
+
vertical: 'top',
|
|
86
|
+
horizontal: 'left',
|
|
87
|
+
},
|
|
88
|
+
}, input: React.createElement(StyledOutlinedInput, Object.assign({ color: color, label: hasLabel ? label : undefined, disabled: disabled }, InputProps)) }, SelectProps), children),
|
|
89
|
+
hasHelperText && (React.createElement(FormHelperText, Object.assign({ sx: Object.assign({ [`&.${formHelperTextClasses.root}`]: {
|
|
90
|
+
marginLeft: 0,
|
|
91
|
+
} }, (Array.isArray(formHelperTextSx)
|
|
92
|
+
? formHelperTextSx
|
|
93
|
+
: [formHelperTextSx])) }, otherFormHelperTextProps), helperText))));
|
|
94
|
+
};
|
|
95
|
+
export default OutlinedSelect;
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { OutlinedSelect } from './OutlinedSelect';
|
|
14
|
+
import { StandardSelect } from './StandardSelect';
|
|
15
|
+
export function Select(_a) {
|
|
16
|
+
var { variant } = _a, props = __rest(_a, ["variant"]);
|
|
17
|
+
if (variant === 'outlined') {
|
|
18
|
+
return React.createElement(OutlinedSelect, Object.assign({}, props));
|
|
19
|
+
}
|
|
20
|
+
return React.createElement(StandardSelect, Object.assign({}, props));
|
|
21
|
+
}
|
|
22
|
+
export default Select;
|
|
@@ -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;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { InputLabel, FormControl, Select, Input, FormHelperText, } from '@mui/material';
|
|
4
|
+
import { inputLabelClasses } from '@mui/material/InputLabel';
|
|
5
|
+
import { inputClasses } from '@mui/material/Input';
|
|
6
|
+
const StyledInputLabel = styled(InputLabel, {
|
|
7
|
+
shouldForwardProp: (prop) => prop !== 'color',
|
|
8
|
+
})(({ color, theme }) => ({
|
|
9
|
+
[`&.${inputLabelClasses.root}`]: {
|
|
10
|
+
color: theme.palette.text.disabled,
|
|
11
|
+
},
|
|
12
|
+
[`&.${inputLabelClasses.focused}`]: {
|
|
13
|
+
color: theme.palette[color].main,
|
|
14
|
+
},
|
|
15
|
+
[`&.${inputLabelClasses.error}`]: {
|
|
16
|
+
color: theme.palette.error.main,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
const StyledInput = styled(Input, {
|
|
20
|
+
shouldForwardProp: (prop) => prop !== 'color',
|
|
21
|
+
})(({ color, theme }) => ({
|
|
22
|
+
color: theme.palette.text.primary,
|
|
23
|
+
[`& .${inputClasses.input}`]: {
|
|
24
|
+
'&:focus': {
|
|
25
|
+
background: 'rgba(0,0,0,0)',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
[`&.${inputClasses.underline}:not(.${inputClasses.disabled}):not(.${inputClasses.error})`]: {
|
|
29
|
+
'&:after,&:hover:before': {
|
|
30
|
+
borderBottomColor: theme.palette[color].main,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
[`&.${inputClasses.underline}.${inputClasses.error}:not(.${inputClasses.disabled})`]: {
|
|
34
|
+
'&:after,&:hover:before': {
|
|
35
|
+
borderBottomColor: theme.palette.error.main,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
export function StandardSelect({ label, helperText, FormControlProps = {}, InputLabelProps = {}, InputProps = {}, SelectProps = {}, FormHelperTextProps = {}, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
|
|
40
|
+
const hasHelperText = !!helperText;
|
|
41
|
+
return (React.createElement(FormControl, Object.assign({ variant: "standard", color: color, size: size, disabled: disabled, error: error, className: className }, FormControlProps),
|
|
42
|
+
React.createElement(StyledInputLabel, Object.assign({ color: color, shrink: hasShrink ? true : undefined }, InputLabelProps), label),
|
|
43
|
+
React.createElement(Select, Object.assign({ label: label, value: value, MenuProps: {
|
|
44
|
+
PaperProps: {
|
|
45
|
+
sx: {
|
|
46
|
+
maxHeight: paperMaxHeight,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
anchorOrigin: {
|
|
50
|
+
vertical: 2,
|
|
51
|
+
horizontal: 'left',
|
|
52
|
+
},
|
|
53
|
+
transformOrigin: {
|
|
54
|
+
vertical: 'top',
|
|
55
|
+
horizontal: 'left',
|
|
56
|
+
},
|
|
57
|
+
}, input: React.createElement(StyledInput, Object.assign({ color: color }, InputProps)) }, SelectProps), children),
|
|
58
|
+
hasHelperText && (React.createElement(FormHelperText, Object.assign({}, FormHelperTextProps), helperText))));
|
|
59
|
+
}
|
|
60
|
+
export default StandardSelect;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import { TextField as MuiTextField, } from '@mui/material';
|
|
15
|
+
import { textFieldClasses } from '@mui/material/TextField';
|
|
16
|
+
import { inputClasses } from '@mui/material/Input';
|
|
17
|
+
import { inputLabelClasses } from '@mui/material/InputLabel';
|
|
18
|
+
import { outlinedInputClasses } from '@mui/material/OutlinedInput';
|
|
19
|
+
import { formHelperTextClasses } from '@mui/material/FormHelperText';
|
|
20
|
+
// utils
|
|
21
|
+
import capitalize from '../../utils/Capitalize';
|
|
22
|
+
// self-defined-components
|
|
23
|
+
const StyledTextField = styled(MuiTextField)(({ label, color = 'primary', theme }) => ({
|
|
24
|
+
[`& .${inputLabelClasses.error}`]: {
|
|
25
|
+
[`&:not(.${inputLabelClasses.shrink})`]: {
|
|
26
|
+
color: theme.palette.text.secondary,
|
|
27
|
+
},
|
|
28
|
+
[`&.${inputLabelClasses.disabled}`]: {
|
|
29
|
+
color: theme.palette.text.disabled,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
[`& .${inputLabelClasses.error}.${inputLabelClasses.focused}`]: {
|
|
33
|
+
color: theme.palette.error.main,
|
|
34
|
+
},
|
|
35
|
+
// For variant: standard | filled
|
|
36
|
+
[`& .${inputClasses.underline}:not(.${inputClasses.disabled})`]: {
|
|
37
|
+
[`&.MuiInputBase-color${capitalize(color)}:hover:before`]: {
|
|
38
|
+
borderColor: theme.palette[color].main,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
// For variant: outlined
|
|
42
|
+
[`& .${inputClasses.disabled} .${outlinedInputClasses.notchedOutline}`]: {
|
|
43
|
+
borderStyle: 'dotted',
|
|
44
|
+
},
|
|
45
|
+
[`& .${inputClasses.error}.${inputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
|
|
46
|
+
borderColor: theme.palette.error.main,
|
|
47
|
+
},
|
|
48
|
+
[`&.${textFieldClasses.root} :not(.${inputClasses.disabled}):not(.${inputClasses.error})`]: {
|
|
49
|
+
[`&.MuiInputBase-color${capitalize(color)}:hover .${outlinedInputClasses.notchedOutline}`]: {
|
|
50
|
+
borderColor: theme.palette[color].main,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
[`& .${outlinedInputClasses.notchedOutline}`]: {
|
|
54
|
+
'& > legend': {
|
|
55
|
+
maxWidth: label === '' && 0,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
export const TextField = (props) => {
|
|
60
|
+
var _a;
|
|
61
|
+
const hasEndAdornment = !!((_a = props === null || props === void 0 ? void 0 : props.InputProps) === null || _a === void 0 ? void 0 : _a.endAdornment);
|
|
62
|
+
const { InputLabelProps, InputProps, FormHelperTextProps = {} } = props, otherProps = __rest(props, ["InputLabelProps", "InputProps", "FormHelperTextProps"]);
|
|
63
|
+
const { sx: formHelperTextSx = [] } = FormHelperTextProps, otherFormHelperTextProps = __rest(FormHelperTextProps, ["sx"]);
|
|
64
|
+
return (React.createElement(StyledTextField, Object.assign({ InputLabelProps: Object.assign(Object.assign({}, InputLabelProps), { shrink: hasEndAdornment ? true : undefined }), FormHelperTextProps: Object.assign({ sx: [
|
|
65
|
+
(theme) => ({
|
|
66
|
+
[`&.${formHelperTextClasses.root}`]: {
|
|
67
|
+
marginLeft: 0,
|
|
68
|
+
[`&.${inputClasses.error}`]: {
|
|
69
|
+
color: theme.palette.error.main,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
...(Array.isArray(formHelperTextSx)
|
|
74
|
+
? formHelperTextSx
|
|
75
|
+
: [formHelperTextSx]),
|
|
76
|
+
] }, otherFormHelperTextProps), InputProps: Object.assign({}, InputProps) }, otherProps)));
|
|
77
|
+
};
|
|
78
|
+
export default TextField;
|
|
File without changes
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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"));
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import ArrowRightRoundedIcon from '@mui/icons-material/ArrowRightRounded';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
5
|
+
import Select from '../select/Select';
|
|
6
|
+
import SelectMenuItem from '../menu-item/SelectMenuItem';
|
|
11
7
|
// self-defined-configs
|
|
12
8
|
const LABEL = '請選擇';
|
|
13
|
-
const StyledSelect =
|
|
9
|
+
const StyledSelect = styled(Select)(({ theme }) => ({
|
|
14
10
|
width: 220,
|
|
15
11
|
margin: theme.spacing(1),
|
|
16
12
|
}));
|
|
17
|
-
const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
|
|
18
|
-
const [selectedTopicIds, setSelectedTopicIds] =
|
|
19
|
-
const [layeredTopicList, setLayeredTopicList] =
|
|
20
|
-
const [isFocusedList, setIsFocusedList] =
|
|
13
|
+
export const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
|
|
14
|
+
const [selectedTopicIds, setSelectedTopicIds] = useState([]);
|
|
15
|
+
const [layeredTopicList, setLayeredTopicList] = useState([]);
|
|
16
|
+
const [isFocusedList, setIsFocusedList] = useState([]);
|
|
21
17
|
const initSelectedLayers = () => {
|
|
22
18
|
const newLayeredTopicList = initSelectedTopicIds.reduce((topicListAccumulator, topicId, index) => {
|
|
23
19
|
var _a, _b;
|
|
@@ -60,7 +56,7 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
|
|
|
60
56
|
]);
|
|
61
57
|
}
|
|
62
58
|
};
|
|
63
|
-
|
|
59
|
+
useEffect(() => {
|
|
64
60
|
if (!topicTree || Object.keys(topicTree).length === 0) {
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
@@ -71,19 +67,19 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
|
|
|
71
67
|
setLayeredTopicList([topicTree]);
|
|
72
68
|
}, [topicTree]);
|
|
73
69
|
if (layeredTopicList.length === 0) {
|
|
74
|
-
return (
|
|
70
|
+
return (React.createElement(StyledSelect, { variant: "outlined", size: "small", label: "\u8F09\u5165\u8CC7\u6599\u4E2D...", disabled: true }));
|
|
75
71
|
}
|
|
76
|
-
return (
|
|
72
|
+
return (React.createElement(Box, { sx: {
|
|
77
73
|
display: 'flex',
|
|
78
74
|
alignItems: 'center',
|
|
79
75
|
flexWrap: 'wrap',
|
|
80
76
|
} }, layeredTopicList.map((layeredTopic, layerNumber) => {
|
|
81
77
|
const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
|
|
82
|
-
return (
|
|
78
|
+
return (React.createElement(Box, { sx: {
|
|
83
79
|
display: 'flex',
|
|
84
80
|
alignItems: 'center',
|
|
85
81
|
}, key: layeredTopic.id },
|
|
86
|
-
|
|
82
|
+
React.createElement(StyledSelect, { variant: "outlined", size: "small", label: LABEL, paperMaxHeight: 412, hasLabel: hasLabel, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
|
|
87
83
|
'data-testid': `layered-topic-${layerNumber}`,
|
|
88
84
|
}, InputProps: {
|
|
89
85
|
inputProps: {
|
|
@@ -107,14 +103,13 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
|
|
|
107
103
|
});
|
|
108
104
|
},
|
|
109
105
|
} },
|
|
110
|
-
|
|
111
|
-
layeredTopic.childTopics.map((childTopic) => (
|
|
112
|
-
hasArrow && layerNumber !== layeredTopicList.length - 1 && (
|
|
106
|
+
React.createElement(SelectMenuItem, { disabled: true, value: "" }, LABEL),
|
|
107
|
+
layeredTopic.childTopics.map((childTopic) => (React.createElement(SelectMenuItem, { key: childTopic.id, value: childTopic.id, "data-testid": `layered-menuitem-${layerNumber}`, "data-is-content-topic": childTopic.isContentTopic }, childTopic.title)))),
|
|
108
|
+
hasArrow && layerNumber !== layeredTopicList.length - 1 && (React.createElement(ArrowRightRoundedIcon, { sx: (theme) => ({
|
|
113
109
|
margin: theme.spacing(-1, -1.5),
|
|
114
110
|
fontSize: theme.spacing(7),
|
|
115
111
|
color: '#444',
|
|
116
|
-
}), fontSize:
|
|
112
|
+
}), fontSize: "large", "data-testid": "topic-filter-arrow" }))));
|
|
117
113
|
})));
|
|
118
114
|
};
|
|
119
|
-
|
|
120
|
-
exports.default = exports.TopicFilter;
|
|
115
|
+
export default TopicFilter;
|
|
@@ -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;
|