@junyiacademy/ui-test 0.0.7 → 0.0.8

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +4 -1
  3. package/src/lib/TopicFilter.spec.tsx +10 -0
  4. package/src/lib/TopicFilter.stories.tsx +80 -0
  5. package/src/lib/TopicFilter.tsx +204 -0
  6. package/src/lib/menu-item/SelectMenuItem.spec.tsx +10 -0
  7. package/src/lib/menu-item/SelectMenuItem.stories.tsx +44 -0
  8. package/src/lib/menu-item/SelectMenuItem.tsx +45 -0
  9. package/src/lib/radio/Radio.stories.tsx +3 -2
  10. package/src/lib/radio/Radio.tsx +1 -1
  11. package/src/lib/select/OutlinedSelect.spec.tsx +10 -0
  12. package/src/lib/select/OutlinedSelect.stories.tsx +245 -0
  13. package/src/lib/select/OutlinedSelect.tsx +223 -0
  14. package/src/lib/select/StandardSelect.stories.tsx +221 -0
  15. package/src/lib/select/StandardSelect.tsx +188 -0
  16. package/src/lib/text-field/TextField.stories.tsx +35 -1
  17. package/src/utils/topicTree.ts +91 -1
  18. package/declarations/libs/ui/src/index.d.ts +0 -5
  19. package/declarations/libs/ui/src/interfaces/index.d.ts +0 -8
  20. package/declarations/libs/ui/src/lib/TopicFilter.d.ts +0 -13
  21. package/declarations/libs/ui/src/lib/button/Button.d.ts +0 -6
  22. package/declarations/libs/ui/src/lib/button-group/ButtonGroup.d.ts +0 -3
  23. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +0 -9
  24. package/declarations/libs/ui/src/lib/radio/Radio.d.ts +0 -10
  25. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +0 -15
  26. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +0 -20
  27. package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +0 -3
  28. package/dist/libs/ui/src/index.js +0 -16
  29. package/dist/libs/ui/src/interfaces/index.js +0 -2
  30. package/dist/libs/ui/src/lib/TopicFilter.js +0 -122
  31. package/dist/libs/ui/src/lib/button/Button.js +0 -71
  32. package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +0 -33
  33. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +0 -24
  34. package/dist/libs/ui/src/lib/radio/Radio.js +0 -43
  35. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +0 -65
  36. package/dist/libs/ui/src/lib/select/StandardSelect.js +0 -97
  37. package/dist/libs/ui/src/lib/text-field/TextField.js +0 -75
  38. package/src/lib/selection-item/SelectionItem.tsx +0 -33
@@ -24,7 +24,97 @@ export const topicTree: ITopicTreeNode = {
24
24
  key:
25
25
  'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
26
26
  tags: [],
27
- title: '【一上】比長短',
27
+ title: '【一上】比長短1',
28
+ },
29
+ {
30
+ childTopics: [],
31
+ id: 'j-m1ach3',
32
+ isContentTopic: true,
33
+ key:
34
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
35
+ tags: [],
36
+ title: '【一上】比長短2',
37
+ },
38
+ {
39
+ childTopics: [],
40
+ id: 'j-m1ach4',
41
+ isContentTopic: true,
42
+ key:
43
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
44
+ tags: [],
45
+ title: '【一上】比長短3',
46
+ },
47
+ {
48
+ childTopics: [],
49
+ id: 'j-m1ach5',
50
+ isContentTopic: true,
51
+ key:
52
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
53
+ tags: [],
54
+ title: '【一上】比長短4',
55
+ },
56
+ {
57
+ childTopics: [],
58
+ id: 'j-m1ach6',
59
+ isContentTopic: true,
60
+ key:
61
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
62
+ tags: [],
63
+ title: '【一上】比長短5',
64
+ },
65
+ {
66
+ childTopics: [],
67
+ id: 'j-m1ach7',
68
+ isContentTopic: true,
69
+ key:
70
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
71
+ tags: [],
72
+ title: '【一上】比長短6',
73
+ },
74
+ {
75
+ childTopics: [],
76
+ id: 'j-m1ach8',
77
+ isContentTopic: true,
78
+ key:
79
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
80
+ tags: [],
81
+ title: '【一上】比長短7',
82
+ },
83
+ {
84
+ childTopics: [],
85
+ id: 'j-m1ach9',
86
+ isContentTopic: true,
87
+ key:
88
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
89
+ tags: [],
90
+ title: '【一上】比長短8',
91
+ },
92
+ {
93
+ childTopics: [],
94
+ id: 'j-m1ach10',
95
+ isContentTopic: true,
96
+ key:
97
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
98
+ tags: [],
99
+ title: '【一上】比長短9',
100
+ },
101
+ {
102
+ childTopics: [],
103
+ id: 'j-m1ach11',
104
+ isContentTopic: true,
105
+ key:
106
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
107
+ tags: [],
108
+ title: '【一上】比長短10',
109
+ },
110
+ {
111
+ childTopics: [],
112
+ id: 'j-m1ach12',
113
+ isContentTopic: true,
114
+ key:
115
+ 'ag5zfmp1bnlpYWNhZGVteXJmCxIFVG9waWMiKHpWQ01BOGpXQTU5SW1zSi1sdWJSQTJlV0QzbHpuZUZiY1BwMUZWOVoMCxIFVG9waWMiKHRXZlVrTHNpSjRYcHlMTGFDa2QtVTRDWkRjcjMwZ3JSTGtSUUNNazgM',
116
+ tags: [],
117
+ title: '【一上】比長短11',
28
118
  },
29
119
  ],
30
120
  id: 'math-grade-1-a',
@@ -1,5 +0,0 @@
1
- export { default as Button } from './lib/button/Button';
2
- export { default as ButtonGroup } from './lib/button-group/ButtonGroup';
3
- export { default as Radio } from './lib/radio/Radio';
4
- export { default as TextField } from './lib/text-field/TextField';
5
- export { default as SelectionItem } from './lib/selection-item/SelectionItem';
@@ -1,8 +0,0 @@
1
- export interface ITopicTreeNode {
2
- childTopics: ITopicTreeNode[];
3
- id: string;
4
- isContentTopic: boolean;
5
- key: string;
6
- tags: string[];
7
- title: string;
8
- }
@@ -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
- declare const TopicFilter: ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }: TopicFilterProps) => JSX.Element;
13
- export default TopicFilter;
@@ -1,6 +0,0 @@
1
- import { ButtonProps as MuiButtonProps } from '@material-ui/core';
2
- export interface ButtonProps extends MuiButtonProps {
3
- active?: boolean;
4
- }
5
- export declare const Button: ({ active, children, ...otherProps }: ButtonProps) => JSX.Element;
6
- export default Button;
@@ -1,3 +0,0 @@
1
- import { ButtonGroupProps as MuiButtonGroupProps } from '@material-ui/core';
2
- export declare const ButtonGroup: ({ children, ...otherProps }: MuiButtonGroupProps) => JSX.Element;
3
- export default ButtonGroup;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- export interface SelectMenuItemProps {
3
- value?: any;
4
- disabled?: boolean;
5
- }
6
- declare const SelectMenuItem: React.ForwardRefExoticComponent<SelectMenuItemProps & {
7
- children?: React.ReactNode;
8
- } & React.RefAttributes<HTMLLIElement>>;
9
- export default SelectMenuItem;
@@ -1,10 +0,0 @@
1
- import { RadioProps as MuiRadioProps, FormControlLabelProps } from '@material-ui/core';
2
- export interface RadioProps extends Omit<FormControlLabelProps, 'control'> {
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,15 +0,0 @@
1
- import { PropsWithChildren, ChangeEvent } from 'react';
2
- import { SelectProps, OutlinedInputProps } from '@material-ui/core';
3
- export interface OutlinedSelectProps {
4
- size?: 'medium' | 'small';
5
- hasLabel?: boolean;
6
- placeholder?: string;
7
- value?: unknown;
8
- disabled?: boolean;
9
- SelectProps?: Partial<SelectProps>;
10
- OutlinedInputProps?: Partial<OutlinedInputProps> & {
11
- onChange: (e: ChangeEvent<HTMLInputElement>) => void;
12
- };
13
- }
14
- declare const OutlinedSelect: ({ size, hasLabel, placeholder, value, disabled, SelectProps, OutlinedInputProps, children, }: PropsWithChildren<OutlinedSelectProps>) => JSX.Element;
15
- export default OutlinedSelect;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { SelectProps, InputProps } from '@material-ui/core';
3
- export interface StandardSelectProps {
4
- color?: 'primary' | 'secondary';
5
- size?: 'medium' | 'small';
6
- width?: number | 'auto';
7
- paperMaxHeight?: number | 'auto';
8
- error?: boolean;
9
- hasShrink?: boolean;
10
- placeholder: string;
11
- hasHelperText?: boolean;
12
- helperText?: string;
13
- InputProps?: object & Partial<InputProps>;
14
- value?: unknown;
15
- disabled?: boolean;
16
- SelectProps?: object | Partial<SelectProps>;
17
- children?: React.ReactNode;
18
- }
19
- export declare function StandardSelect({ color, size, width, paperMaxHeight, error, hasShrink, placeholder, hasHelperText, helperText, InputProps, value, SelectProps, disabled, children, }: StandardSelectProps): JSX.Element;
20
- export default StandardSelect;
@@ -1,3 +0,0 @@
1
- import { TextFieldProps } from '@material-ui/core';
2
- export declare const TextField: (props: TextFieldProps) => JSX.Element;
3
- export default TextField;
@@ -1,16 +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.SelectionItem = exports.TextField = exports.Radio = exports.ButtonGroup = exports.Button = void 0;
7
- var Button_1 = require("./lib/button/Button");
8
- Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
9
- var ButtonGroup_1 = require("./lib/button-group/ButtonGroup");
10
- Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return __importDefault(ButtonGroup_1).default; } });
11
- var Radio_1 = require("./lib/radio/Radio");
12
- Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
13
- var TextField_1 = require("./lib/text-field/TextField");
14
- Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return __importDefault(TextField_1).default; } });
15
- var SelectionItem_1 = require("./lib/selection-item/SelectionItem");
16
- Object.defineProperty(exports, "SelectionItem", { enumerable: true, get: function () { return __importDefault(SelectionItem_1).default; } });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importStar(require("react"));
5
- const styles_1 = require("@material-ui/core/styles");
6
- const ArrowRightRounded_1 = tslib_1.__importDefault(require("@material-ui/icons/ArrowRightRounded"));
7
- const OutlinedSelect_1 = tslib_1.__importDefault(require("./select/OutlinedSelect"));
8
- const SelectMenuItem_1 = tslib_1.__importDefault(require("./menu-item/SelectMenuItem"));
9
- // self-defined-configs
10
- const PLACEHOLDER = '請選擇';
11
- // self-defined-components
12
- const useStyles = styles_1.makeStyles((theme) => ({
13
- filtersWrapper: {
14
- display: 'flex',
15
- alignItems: 'center',
16
- flexWrap: 'wrap',
17
- },
18
- selectWrapper: {
19
- display: 'flex',
20
- alignItems: 'center',
21
- },
22
- arrowIcon: {
23
- margin: theme.spacing(-1, -1.5),
24
- fontSize: theme.spacing(7),
25
- color: '#444',
26
- },
27
- }));
28
- const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
29
- const classes = useStyles();
30
- const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
31
- const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
32
- const [isFocusedList, setIsFocusedList] = react_1.useState([]);
33
- const initSelectedLayers = () => {
34
- const newLayeredTopicList = initSelectedTopicIds.reduce((topicListAccumulator, topicId, index) => {
35
- var _a, _b;
36
- 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);
37
- if (!selectedTopic) {
38
- return topicListAccumulator;
39
- }
40
- if (isLastLayer(selectedTopic)) {
41
- return topicListAccumulator;
42
- }
43
- return [...topicListAccumulator, selectedTopic];
44
- }, [topicTree]);
45
- setLayeredTopicList(newLayeredTopicList);
46
- setSelectedTopicIds(initSelectedTopicIds.slice(0, newLayeredTopicList.length));
47
- setIsFocusedList(Array(newLayeredTopicList.length).fill(false));
48
- };
49
- const handleChange = (e, layerNumber, layeredTopic) => {
50
- const selectedTopic = layeredTopic.childTopics.find((childTopic) => childTopic.id === e.target.value);
51
- const newSelectedTopicIds = [
52
- ...selectedTopicIds.slice(0, layerNumber),
53
- selectedTopic.id,
54
- ];
55
- setSelectedTopicIds(newSelectedTopicIds);
56
- onTopicSelected(selectedTopic, {
57
- layerNumber,
58
- selectedTopicIds: newSelectedTopicIds,
59
- });
60
- if (isLastLayer(selectedTopic)) {
61
- setLayeredTopicList((prevTopicList) => prevTopicList.slice(0, layerNumber + 1));
62
- setIsFocusedList((prevList) => prevList.slice(0, layerNumber + 1));
63
- }
64
- else {
65
- setLayeredTopicList((prevTopicList) => [
66
- ...prevTopicList.slice(0, layerNumber + 1),
67
- selectedTopic,
68
- ]);
69
- setIsFocusedList((prevList) => [
70
- ...prevList.slice(0, layerNumber + 1),
71
- false,
72
- ]);
73
- }
74
- };
75
- react_1.useEffect(() => {
76
- if (!topicTree || Object.keys(topicTree).length === 0) {
77
- return;
78
- }
79
- if (initSelectedTopicIds.length !== 0) {
80
- initSelectedLayers();
81
- return;
82
- }
83
- setLayeredTopicList([topicTree]);
84
- }, [topicTree]);
85
- if (layeredTopicList.length === 0) {
86
- return (react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
87
- }
88
- return (react_1.default.createElement("div", { className: classes.filtersWrapper }, layeredTopicList.map((layeredTopic, layerNumber) => {
89
- const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
90
- return (react_1.default.createElement("div", { key: layeredTopic.id, className: classes.selectWrapper },
91
- react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', hasLabel: hasLabel, placeholder: PLACEHOLDER, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
92
- inputProps: {
93
- 'data-testid': `layered-topic-${layerNumber}`,
94
- },
95
- }, OutlinedInputProps: {
96
- inputProps: {
97
- 'aria-label': `layered-topic-${layerNumber}`,
98
- },
99
- onChange: (e) => {
100
- handleChange(e, layerNumber, layeredTopic);
101
- },
102
- onFocus: () => {
103
- setIsFocusedList((prevList) => {
104
- const newList = [...prevList];
105
- newList[layerNumber] = true;
106
- return newList;
107
- });
108
- },
109
- onBlur: () => {
110
- setIsFocusedList((prevList) => {
111
- const newList = [...prevList];
112
- newList[layerNumber] = false;
113
- return newList;
114
- });
115
- },
116
- } },
117
- react_1.default.createElement(SelectMenuItem_1.default, { disabled: true }, PLACEHOLDER),
118
- 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)))),
119
- hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(ArrowRightRounded_1.default, { fontSize: 'large', classes: { root: classes.arrowIcon }, "data-testid": 'topic-filter-arrow' }))));
120
- })));
121
- };
122
- exports.default = TopicFilter;
@@ -1,71 +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("@material-ui/core/styles");
7
- const core_1 = require("@material-ui/core");
8
- // self-defined-components
9
- const PREFIX = 'JuiButton';
10
- const classes = {
11
- outlinedPrimary: `${PREFIX}-outlinedPrimary`,
12
- outlinedSecondary: `${PREFIX}-outlinedSecondary`,
13
- textPrimary: `${PREFIX}-textPrimary`,
14
- textSecondary: `${PREFIX}-textSecondary`,
15
- disabled: `${PREFIX}-disabled`,
16
- };
17
- const StyledButton = styles_1.styled((_a) => {
18
- var { active: _active } = _a, other = tslib_1.__rest(_a, ["active"]);
19
- return (react_1.default.createElement(core_1.Button, Object.assign({ classes: classes }, other)));
20
- })(({ active, theme }) => ({
21
- [`&.${classes.outlinedPrimary}`]: {
22
- backgroundColor: active
23
- ? theme.palette.primary.main
24
- : theme.palette.common.white,
25
- color: active ? theme.palette.common.white : theme.palette.primary.main,
26
- borderColor: theme.palette.primary.main,
27
- '&:hover': {
28
- backgroundColor: active
29
- ? theme.palette.primary.main
30
- : styles_1.fade(theme.palette.primary.main, 0.1),
31
- },
32
- [`&.${classes.disabled}`]: {
33
- backgroundColor: theme.palette.common.white,
34
- borderColor: theme.palette.action.disabledBackground,
35
- color: theme.palette.action.disabled,
36
- },
37
- },
38
- [`&.${classes.outlinedSecondary}`]: {
39
- backgroundColor: active
40
- ? theme.palette.secondary.main
41
- : theme.palette.common.white,
42
- color: active ? theme.palette.common.white : theme.palette.secondary.main,
43
- borderColor: theme.palette.secondary.main,
44
- '&:hover': {
45
- backgroundColor: active
46
- ? theme.palette.secondary.main
47
- : styles_1.fade(theme.palette.secondary.main, 0.1),
48
- },
49
- [`&.${classes.disabled}`]: {
50
- backgroundColor: theme.palette.common.white,
51
- borderColor: theme.palette.action.disabledBackground,
52
- color: theme.palette.action.disabled,
53
- },
54
- },
55
- [`&.${classes.textPrimary}`]: {
56
- '&:hover': {
57
- backgroundColor: styles_1.fade(theme.palette.primary.main, 0.1),
58
- },
59
- },
60
- [`&.${classes.textSecondary}`]: {
61
- '&:hover': {
62
- backgroundColor: styles_1.fade(theme.palette.secondary.main, 0.1),
63
- },
64
- },
65
- }));
66
- const Button = (_a) => {
67
- var { active, children } = _a, otherProps = tslib_1.__rest(_a, ["active", "children"]);
68
- return (react_1.default.createElement(StyledButton, Object.assign({ active: active }, otherProps), children));
69
- };
70
- exports.Button = Button;
71
- exports.default = exports.Button;
@@ -1,33 +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("@material-ui/core/styles");
7
- const core_1 = require("@material-ui/core");
8
- const PREFIX = 'JuiButtonGroup';
9
- const classes = {
10
- grouped: `${PREFIX}-grouped`,
11
- groupedOutlinedPrimary: `${PREFIX}-groupedOutlinedPrimary`,
12
- groupedOutlinedSecondary: `${PREFIX}-groupedOutlinedSecondary`,
13
- disabled: `${PREFIX}-disabled`,
14
- };
15
- const StyledButtonGroup = styles_1.styled((_a) => {
16
- var props = tslib_1.__rest(_a, []);
17
- return (react_1.default.createElement(core_1.ButtonGroup, Object.assign({ classes: classes }, props)));
18
- })(({ theme }) => ({
19
- [`& .${classes.groupedOutlinedPrimary}.${classes.grouped}.${classes.disabled}`]: {
20
- borderColor: styles_1.fade(theme.palette.primary.main, 0.5),
21
- color: styles_1.fade(theme.palette.primary.main, 0.5),
22
- },
23
- [`& .${classes.groupedOutlinedSecondary}.${classes.grouped}.${classes.disabled}`]: {
24
- borderColor: styles_1.fade(theme.palette.secondary.main, 0.5),
25
- color: styles_1.fade(theme.palette.secondary.main, 0.5),
26
- },
27
- }));
28
- const ButtonGroup = (_a) => {
29
- var { children } = _a, otherProps = tslib_1.__rest(_a, ["children"]);
30
- return (react_1.default.createElement(StyledButtonGroup, Object.assign({}, otherProps), children));
31
- };
32
- exports.ButtonGroup = ButtonGroup;
33
- exports.default = exports.ButtonGroup;
@@ -1,24 +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 styles_1 = require("@material-ui/core/styles");
6
- const core_1 = require("@material-ui/core");
7
- // self-defined-components
8
- const useStyles = styles_1.makeStyles((theme) => ({
9
- menuItem: {
10
- width: theme.spacing(27.5),
11
- whiteSpace: 'unset',
12
- color: 'rgba(0, 0, 0, 0.87)',
13
- },
14
- menuItemSelected: { backgroundColor: '#E0E0E0' },
15
- }));
16
- const SelectMenuItem = react_1.default.forwardRef((_a, ref) => {
17
- var { children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["children", "value"]);
18
- const classes = useStyles();
19
- return (react_1.default.createElement(core_1.MenuItem, Object.assign({ ref: ref, classes: {
20
- root: classes.menuItem,
21
- selected: classes.menuItemSelected,
22
- }, value: value }, otherProps), children));
23
- });
24
- exports.default = SelectMenuItem;
@@ -1,43 +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("@material-ui/core/styles");
7
- const core_1 = require("@material-ui/core");
8
- const PREFIX = 'JuiRadio';
9
- const classes = {
10
- formControlLabel: `${PREFIX}-formControl-label`,
11
- formControlDisabled: `${PREFIX}-formControl-disabled`,
12
- radioChecked: `${PREFIX}-radio-checked`,
13
- };
14
- const StyledFormControlLabel = styles_1.styled((props) => (react_1.default.createElement(core_1.FormControlLabel, Object.assign({ classes: {
15
- label: classes.formControlLabel,
16
- disabled: classes.formControlDisabled,
17
- } }, props))))(({ theme }) => ({
18
- [`& .${classes.formControlLabel}`]: {
19
- color: theme.palette.text.secondary,
20
- [`&.${classes.formControlDisabled}`]: {
21
- color: theme.palette.text.disabled,
22
- },
23
- },
24
- [`& .${classes.radioChecked} + .${classes.formControlLabel}`]: {
25
- color: theme.palette.text.primary,
26
- },
27
- }));
28
- const StyledRadio = styles_1.styled((props) => (react_1.default.createElement(core_1.Radio, Object.assign({ classes: {
29
- checked: classes.radioChecked,
30
- } }, props))))(({ theme }) => ({
31
- color: theme.palette.text.primary,
32
- }));
33
- const StyledTypography = styles_1.styled(core_1.Typography)(({ theme }) => ({
34
- color: theme.palette.text.disabled,
35
- margin: '0 0 0 30px',
36
- }));
37
- const Radio = ({ checked, disabled, label, labelPlacement, value, formControlLabelProps, radioProps, color = 'secondary', size = 'medium', caption = '', }) => {
38
- return (react_1.default.createElement(react_1.default.Fragment, null,
39
- react_1.default.createElement(StyledFormControlLabel, Object.assign({ control: react_1.default.createElement(StyledRadio, Object.assign({ color: color, size: size }, radioProps)), checked: checked, disabled: disabled, label: label, labelPlacement: labelPlacement, value: value }, formControlLabelProps)),
40
- caption && (react_1.default.createElement(StyledTypography, { variant: 'body2' }, caption))));
41
- };
42
- exports.Radio = Radio;
43
- exports.default = exports.Radio;
@@ -1,65 +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 styles_1 = require("@material-ui/core/styles");
6
- const core_1 = require("@material-ui/core");
7
- // self-defined-components
8
- const useStyles = styles_1.makeStyles((theme) => ({
9
- formControl: {
10
- margin: theme.spacing(1),
11
- width: theme.spacing(27.5),
12
- backgroundColor: 'white',
13
- '&:hover': {
14
- '& :not($inputDisabled) $notchedOutline': {
15
- borderColor: theme.palette.primary.main,
16
- },
17
- },
18
- },
19
- input: {
20
- color: 'rgba(0, 0, 0, 0.87)',
21
- },
22
- inputMarginDense: { padding: '14.5px 12px 14.5px' },
23
- inputLabel: {
24
- color: theme.palette.text.secondary,
25
- },
26
- inputLabelOutlined: {
27
- '&$inputLabelMarginDense:not($inputLabelShrink)': {
28
- transform: 'translate(12px, 16px) scale(1)',
29
- },
30
- },
31
- inputDisabled: {},
32
- notchedOutline: {},
33
- inputLabelMarginDense: {},
34
- inputLabelShrink: {},
35
- menuPaper: { maxHeight: 412 },
36
- }));
37
- const OutlinedSelect = ({ size = 'medium', hasLabel = true, placeholder, value = '', disabled = false, SelectProps, OutlinedInputProps, children, }) => {
38
- const classes = useStyles();
39
- return (react_1.default.createElement(core_1.FormControl, { className: classes.formControl, size: size, disabled: disabled },
40
- hasLabel && (react_1.default.createElement(core_1.InputLabel, { variant: 'outlined', classes: {
41
- root: classes.inputLabel,
42
- outlined: classes.inputLabelOutlined,
43
- marginDense: classes.inputLabelMarginDense,
44
- shrink: classes.inputLabelShrink,
45
- } }, placeholder)),
46
- react_1.default.createElement(core_1.Select, Object.assign({ value: value, input: react_1.default.createElement(core_1.OutlinedInput, Object.assign({ label: hasLabel ? placeholder : undefined, classes: {
47
- input: classes.input,
48
- inputMarginDense: classes.inputMarginDense,
49
- notchedOutline: classes.notchedOutline,
50
- disabled: classes.inputDisabled,
51
- }, disabled: disabled }, OutlinedInputProps)), MenuProps: {
52
- disableAutoFocusItem: true,
53
- anchorOrigin: {
54
- vertical: 2,
55
- horizontal: 'left',
56
- },
57
- transformOrigin: {
58
- vertical: 'top',
59
- horizontal: 'left',
60
- },
61
- getContentAnchorEl: null,
62
- classes: { paper: classes.menuPaper },
63
- } }, SelectProps), children)));
64
- };
65
- exports.default = OutlinedSelect;