@junyiacademy/ui-test 0.0.8 → 0.0.12

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/declarations/libs/ui/src/index.d.ts +8 -0
  2. package/declarations/libs/ui/src/interfaces/index.d.ts +26 -0
  3. package/declarations/libs/ui/src/lib/TopicFilter.d.ts +13 -0
  4. package/declarations/libs/ui/src/lib/button/Button.d.ts +6 -0
  5. package/declarations/libs/ui/src/lib/button-group/ButtonGroup.d.ts +3 -0
  6. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +9 -0
  7. package/declarations/libs/ui/src/lib/radio/Radio.d.ts +10 -0
  8. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +3 -0
  9. package/declarations/libs/ui/src/lib/select/Select.d.ts +3 -0
  10. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +3 -0
  11. package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +3 -0
  12. package/declarations/libs/ui/src/lib/topic-filter/TopicFilter.d.ts +13 -0
  13. package/dist/libs/ui/src/index.js +22 -0
  14. package/dist/libs/ui/src/interfaces/index.js +2 -0
  15. package/dist/libs/ui/src/lib/TopicFilter.js +120 -0
  16. package/dist/libs/ui/src/lib/button/Button.js +71 -0
  17. package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +33 -0
  18. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +27 -0
  19. package/dist/libs/ui/src/lib/radio/Radio.js +43 -0
  20. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +124 -0
  21. package/dist/libs/ui/src/lib/select/Select.js +16 -0
  22. package/dist/libs/ui/src/lib/select/StandardSelect.js +103 -0
  23. package/dist/libs/ui/src/lib/text-field/TextField.js +75 -0
  24. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +120 -0
  25. package/package.json +1 -1
  26. package/src/index.ts +1 -1
  27. package/src/interfaces/index.tsx +25 -0
  28. package/src/lib/select/OutlinedSelect.tsx +37 -44
  29. package/src/lib/select/Select.stories.tsx +421 -0
  30. package/src/lib/select/Select.tsx +13 -0
  31. package/src/lib/select/StandardSelect.tsx +24 -33
  32. package/src/lib/{TopicFilter.stories.tsx → topic-filter/TopicFilter.stories.tsx} +10 -7
  33. package/src/lib/{TopicFilter.tsx → topic-filter/TopicFilter.tsx} +5 -5
  34. package/src/lib/TopicFilter.spec.tsx +0 -10
  35. package/src/lib/menu-item/SelectMenuItem.spec.tsx +0 -10
  36. package/src/lib/select/OutlinedSelect.spec.tsx +0 -10
  37. package/src/lib/select/OutlinedSelect.stories.tsx +0 -245
  38. package/src/lib/select/StandardSelect.stories.tsx +0 -221
@@ -0,0 +1,103 @@
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("@material-ui/core/styles");
7
+ const core_1 = require("@material-ui/core");
8
+ // self-defined-components
9
+ const PREFIX = 'JuiStandardSelect';
10
+ const classes = {
11
+ inputLabelFocused: `${PREFIX}-inputLabelFocused`,
12
+ inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
13
+ inputLabelError: `${PREFIX}-inputLabelError`,
14
+ inputRoot: `${PREFIX}-inputRoot`,
15
+ inputFocused: `${PREFIX}-inputFocused`,
16
+ inputInput: `${PREFIX}-input`,
17
+ inputUnderline: `${PREFIX}-inputUnderline`,
18
+ inputError: `${PREFIX}-inputError`,
19
+ inputDisabled: `${PREFIX}-inputDisabled`,
20
+ inputAdornmentRoot: `${PREFIX}-inputAdornmentRoot`,
21
+ selectPaper: `${PREFIX}-menuPaper`,
22
+ selectDisabled: `${PREFIX}-selectDisabled`,
23
+ };
24
+ const StyledFormControl = styles_1.styled((_a) => {
25
+ var { width: _width } = _a, props = tslib_1.__rest(_a, ["width"]);
26
+ return (react_1.default.createElement(core_1.FormControl, Object.assign({}, props)));
27
+ })(({ width, theme }) => ({
28
+ width,
29
+ margin: theme.spacing(0, 4, 4, 4),
30
+ }));
31
+ const StyledInputLabel = styles_1.styled((_a) => {
32
+ var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
33
+ return (react_1.default.createElement(core_1.InputLabel, Object.assign({ classes: {
34
+ focused: classes.inputLabelFocused,
35
+ error: classes.inputLabelError,
36
+ } }, props)));
37
+ })(({ color, theme }) => ({
38
+ color: theme.palette.text.disabled,
39
+ margin: theme.spacing(0, 10, 1.5, 0),
40
+ [`&.${classes.inputLabelFocused}`]: {
41
+ color: theme.palette[color].main,
42
+ },
43
+ [`&.${classes.inputLabelError}`]: {
44
+ color: theme.palette.error.main,
45
+ },
46
+ }));
47
+ const StyledSelect = styles_1.styled((_a) => {
48
+ var { paperMaxHeight: _selectPaperHeight, hasAdornment: _hasAdornment, className } = _a, props = tslib_1.__rest(_a, ["paperMaxHeight", "hasAdornment", "className"]);
49
+ return (react_1.default.createElement(core_1.Select, Object.assign({ MenuProps: {
50
+ classes: { paper: className },
51
+ transformOrigin: {
52
+ vertical: 'top',
53
+ horizontal: 'left',
54
+ },
55
+ getContentAnchorEl: null,
56
+ } }, props)));
57
+ })(({ hasAdornment, paperMaxHeight }) => ({
58
+ '&&': {
59
+ maxHeight: paperMaxHeight,
60
+ left: hasAdornment ? '48px !important' : '70px',
61
+ },
62
+ }));
63
+ const StyledInput = styles_1.styled((_a) => {
64
+ var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
65
+ return (react_1.default.createElement(core_1.Input, Object.assign({ classes: {
66
+ root: classes.inputRoot,
67
+ focused: classes.inputFocused,
68
+ input: classes.inputInput,
69
+ disabled: classes.inputDisabled,
70
+ underline: classes.inputUnderline,
71
+ error: classes.inputError,
72
+ } }, props)));
73
+ })(({ color, theme }) => ({
74
+ color: theme.palette.text.primary,
75
+ [`&.${classes.inputRoot}.${classes.inputFocused}`]: {
76
+ backgroundColor: theme.palette.action.selected,
77
+ },
78
+ [`& .${classes.inputInput}`]: {
79
+ ['&:focus']: {
80
+ background: 'rgba(0,0,0,0)',
81
+ },
82
+ },
83
+ [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
84
+ [`&:after,&:hover:before`]: {
85
+ borderBottomColor: theme.palette[color].main,
86
+ },
87
+ },
88
+ [`&.${classes.inputUnderline}.${classes.inputError}:not(.${classes.inputDisabled})`]: {
89
+ [`&:after,&:hover:before`]: {
90
+ borderBottomColor: theme.palette.error.main,
91
+ },
92
+ },
93
+ }));
94
+ function StandardSelect({ placeholder, helperText, InputProps, SelectProps, children, color = 'primary', size = 'medium', width = 'auto', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
95
+ const hasAdornment = !!(InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment);
96
+ const hasHelperText = !!helperText;
97
+ return (react_1.default.createElement(StyledFormControl, { color: color, size: size, width: width, disabled: disabled, error: error },
98
+ react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, placeholder),
99
+ react_1.default.createElement(StyledSelect, Object.assign({ value: value, paperMaxHeight: paperMaxHeight, hasAdornment: hasAdornment, input: react_1.default.createElement(StyledInput, Object.assign({ color: color }, InputProps)) }, SelectProps), children),
100
+ hasHelperText && react_1.default.createElement(core_1.FormHelperText, null, helperText)));
101
+ }
102
+ exports.StandardSelect = StandardSelect;
103
+ exports.default = StandardSelect;
@@ -0,0 +1,75 @@
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("@material-ui/core/styles");
7
+ const core_1 = require("@material-ui/core");
8
+ // self-defined-components
9
+ const PREFIX = 'JuiTextField';
10
+ const classes = {
11
+ inputLabelError: `${PREFIX}-inputLabel-error`,
12
+ inputLabelDisabled: `${PREFIX}-inputLabel-disabled`,
13
+ inputLabelShrink: `${PREFIX}-inputLabel-shrink`,
14
+ inputLabelFocused: `${PREFIX}-inputLabel-focused`,
15
+ inputNotchedOutline: `${PREFIX}-input-notchedOutline`,
16
+ inputUnderline: `${PREFIX}-input-underline`,
17
+ inputColorSecondary: `${PREFIX}-input-colorSecondary`,
18
+ inputDisabled: `${PREFIX}-input-disabled`,
19
+ inputError: `${PREFIX}-input-error`,
20
+ inputFocused: `${PREFIX}-input-focused`,
21
+ };
22
+ const StyledTextField = styles_1.styled((_a) => {
23
+ var { hasEndAdornment, InputLabelProps, InputProps } = _a, otherProps = tslib_1.__rest(_a, ["hasEndAdornment", "InputLabelProps", "InputProps"]);
24
+ return (react_1.default.createElement(core_1.TextField, Object.assign({ InputLabelProps: Object.assign(Object.assign({}, InputLabelProps), { classes: {
25
+ error: classes.inputLabelError,
26
+ disabled: classes.inputLabelDisabled,
27
+ shrink: classes.inputLabelShrink,
28
+ focused: classes.inputLabelFocused,
29
+ }, shrink: hasEndAdornment ? true : undefined }), InputProps: Object.assign(Object.assign({}, InputProps), { classes: Object.assign({ colorSecondary: classes.inputColorSecondary, disabled: classes.inputDisabled, error: classes.inputError, focused: classes.inputFocused }, ((otherProps === null || otherProps === void 0 ? void 0 : otherProps.variant) === 'outlined'
30
+ ? { notchedOutline: classes.inputNotchedOutline }
31
+ : { underline: classes.inputUnderline })) }) }, otherProps)));
32
+ })(({ theme }) => ({
33
+ [`& .${classes.inputLabelError}`]: {
34
+ [`&:not(.${classes.inputLabelShrink})`]: {
35
+ color: theme.palette.text.secondary,
36
+ },
37
+ [`&.${classes.inputLabelDisabled}`]: {
38
+ color: theme.palette.text.disabled,
39
+ },
40
+ },
41
+ [`& .${classes.inputLabelError}.${classes.inputLabelFocused}`]: {
42
+ color: theme.palette.error.main,
43
+ },
44
+ // For variant: standard | filled
45
+ [`& .${classes.inputUnderline}:not(.${classes.inputDisabled})`]: {
46
+ [`&:hover:before`]: {
47
+ borderColor: theme.palette.primary.main,
48
+ },
49
+ [`&.${classes.inputColorSecondary}:hover:before`]: {
50
+ borderColor: theme.palette.secondary.main,
51
+ },
52
+ },
53
+ // For variant: outlined
54
+ [`& .${classes.inputDisabled} .${classes.inputNotchedOutline}`]: {
55
+ borderStyle: 'dotted',
56
+ },
57
+ [`& .${classes.inputError}.${classes.inputFocused} .${classes.inputNotchedOutline}`]: {
58
+ borderColor: theme.palette.error.main,
59
+ },
60
+ [`& :not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
61
+ [`&:hover .${classes.inputNotchedOutline}`]: {
62
+ borderColor: theme.palette.primary.main,
63
+ },
64
+ [`&.${classes.inputColorSecondary}:hover .${classes.inputNotchedOutline}`]: {
65
+ borderColor: theme.palette.secondary.main,
66
+ },
67
+ },
68
+ }));
69
+ const TextField = (props) => {
70
+ var _a;
71
+ const hasEndAdornment = !!((_a = props === null || props === void 0 ? void 0 : props.InputProps) === null || _a === void 0 ? void 0 : _a.endAdornment);
72
+ return react_1.default.createElement(StyledTextField, Object.assign({ hasEndAdornment: hasEndAdornment }, props));
73
+ };
74
+ exports.TextField = TextField;
75
+ exports.default = exports.TextField;
@@ -0,0 +1,120 @@
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
+ }, InputProps: {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junyiacademy/ui-test",
3
- "version": "0.0.8",
3
+ "version": "0.0.12",
4
4
  "description": "junyiacademy ui library",
5
5
  "main": "./dist/libs/ui/src/index.js",
6
6
  "typings": "./declarations/libs/ui/src/index.d.ts",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default as TopicFilter } from './lib/TopicFilter'
1
+ export { default as TopicFilter } from './lib/topic-filter/TopicFilter'
2
2
  export { default as SelectMenuItem } from './lib/menu-item/SelectMenuItem'
3
3
  export { default as OutlinedSelect } from './lib/select/OutlinedSelect'
4
4
  export { default as Button } from './lib/button/Button'
@@ -1,3 +1,10 @@
1
+ import { ChangeEvent } from 'react'
2
+ import {
3
+ SelectProps as MuiSelectProp,
4
+ InputProps as MuiInputProps,
5
+ OutlinedInputProps,
6
+ } from '@material-ui/core'
7
+
1
8
  export interface ITopicTreeNode {
2
9
  childTopics: ITopicTreeNode[]
3
10
  id: string
@@ -6,3 +13,21 @@ export interface ITopicTreeNode {
6
13
  tags: string[]
7
14
  title: string
8
15
  }
16
+ export interface SelectProps extends MuiSelectProp {
17
+ placeholder: string
18
+ helperText?: string
19
+ InputProps?:
20
+ | (Partial<OutlinedInputProps> & {
21
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void
22
+ })
23
+ | (object & Partial<MuiInputProps>)
24
+ SelectProps?: object | Partial<MuiSelectProp>
25
+ color?: 'primary' | 'secondary'
26
+ size?: 'medium' | 'small'
27
+ width?: number | 'auto'
28
+ paperMaxHeight?: number | 'auto'
29
+ error?: boolean
30
+ hasLabel?: boolean
31
+ hasShrink?: boolean
32
+ disabled?: boolean
33
+ }
@@ -1,14 +1,13 @@
1
- import React, { ChangeEvent } from 'react'
1
+ import React from 'react'
2
2
  import { Theme, styled } from '@material-ui/core/styles'
3
3
  import {
4
4
  InputLabel,
5
5
  FormControl,
6
6
  Select,
7
7
  OutlinedInput,
8
- SelectProps,
9
- OutlinedInputProps,
10
8
  FormHelperText,
11
9
  } from '@material-ui/core'
10
+ import { SelectProps } from '../../interfaces'
12
11
 
13
12
  // self-defined-components
14
13
  const PREFIX = 'JuiOutlinedSelect'
@@ -21,10 +20,12 @@ const classes = {
21
20
  inputLabelError: `${PREFIX}-inputLabelError`,
22
21
  inputLabelDisabled: `${PREFIX}-inputLabelDisabled`,
23
22
  outlineInputInput: `${PREFIX}-input`,
23
+ outlineInputRoot: `${PREFIX}-inputRoot`,
24
24
  outlineInputInputMarginDense: `${PREFIX}-inputMarginDense`,
25
25
  outlineInputNotchedOutline: `${PREFIX}-notchedOutline`,
26
26
  outlineInputDisabled: `${PREFIX}-inputDisabled`,
27
27
  outlineInputError: `${PREFIX}-outlinedInputError`,
28
+ outlineInputFocused: `${PREFIX}-focused`,
28
29
  selectPaper: `${PREFIX}-menuPaper`,
29
30
  }
30
31
 
@@ -45,6 +46,9 @@ const StyledFormControl = styled(
45
46
  borderColor: theme.palette[color].main,
46
47
  },
47
48
  },
49
+ [`& .${classes.outlineInputError}.${classes.outlineInputFocused} .${classes.outlineInputNotchedOutline}`]: {
50
+ borderColor: `${theme.palette.error.main}`,
51
+ },
48
52
  }))
49
53
 
50
54
  interface StyledInputLabelProps {
@@ -90,6 +94,8 @@ interface StyledOutlinedInputProps {
90
94
  const StyledOutlinedInput = styled((props) => (
91
95
  <OutlinedInput
92
96
  classes={{
97
+ root: classes.outlineInputRoot,
98
+ focused: classes.outlineInputFocused,
93
99
  input: classes.outlineInputInput,
94
100
  inputMarginDense: classes.outlineInputInputMarginDense,
95
101
  notchedOutline: classes.outlineInputNotchedOutline,
@@ -99,8 +105,14 @@ const StyledOutlinedInput = styled((props) => (
99
105
  {...props}
100
106
  />
101
107
  ))(({ theme }: StyledOutlinedInputProps) => ({
108
+ [`&.${classes.outlineInputRoot}.${classes.outlineInputFocused}`]: {
109
+ backgroundColor: theme.palette.action.selected,
110
+ },
102
111
  [`& .${classes.outlineInputInput}`]: {
103
112
  color: theme.palette.text.primary,
113
+ ['&:focus']: {
114
+ background: 'rgba(0,0,0,0)',
115
+ },
104
116
  },
105
117
  [`& .${classes.outlineInputInputMarginDense}`]: {
106
118
  padding: '14.5px 15px 14.5px 12px',
@@ -131,38 +143,26 @@ const StyledSelect = styled(
131
143
  horizontal: 'left',
132
144
  },
133
145
  getContentAnchorEl: null,
134
- classes: { paper: className },
146
+ classes: {
147
+ paper: className,
148
+ },
135
149
  }}
136
150
  {...props}
137
151
  />
138
152
  )
139
153
  )(({ hasAdornment, paperMaxHeight }: StyledSelectProps) => ({
140
- '&&': {
154
+ '&': {
141
155
  maxHeight: paperMaxHeight,
142
156
  left: hasAdornment ? '24px !important' : '70px',
143
157
  },
144
158
  }))
145
159
 
146
- export interface OutlinedSelectProps {
147
- color?: 'primary' | 'secondary'
148
- size?: 'medium' | 'small'
149
- width?: number | 'auto'
150
- paperMaxHeight?: number | 'auto'
151
- error?: boolean
152
- hasLabel?: boolean
153
- hasShrink?: boolean
154
- placeholder: string
155
- helperText?: string
156
- value?: unknown
157
- disabled?: boolean
158
- SelectProps?: object | Partial<SelectProps>
159
- OutlinedInputProps?: Partial<OutlinedInputProps> & {
160
- onChange: (e: ChangeEvent<HTMLInputElement>) => void
161
- }
162
- children?: React.ReactNode
163
- }
164
-
165
- const OutlinedSelect = ({
160
+ export const OutlinedSelect = ({
161
+ placeholder,
162
+ helperText,
163
+ InputProps,
164
+ SelectProps,
165
+ children,
166
166
  color = 'primary',
167
167
  size = 'medium',
168
168
  width = 'auto',
@@ -170,15 +170,10 @@ const OutlinedSelect = ({
170
170
  error = false,
171
171
  hasLabel = true,
172
172
  hasShrink = false,
173
- placeholder,
174
- helperText = '',
175
173
  value = '',
176
174
  disabled = false,
177
- SelectProps,
178
- OutlinedInputProps,
179
- children,
180
- }: OutlinedSelectProps) => {
181
- const hasAdornment = !!OutlinedInputProps?.startAdornment
175
+ }: SelectProps) => {
176
+ const hasAdornment = !!InputProps?.startAdornment
182
177
  const hasHelperText = !!helperText
183
178
  return (
184
179
  <StyledFormControl
@@ -188,17 +183,15 @@ const OutlinedSelect = ({
188
183
  error={error}
189
184
  color={color}
190
185
  >
191
- {hasLabel ? (
192
- hasShrink ? (
193
- <StyledInputLabel color={color} variant='outlined' shrink>
194
- {placeholder}
195
- </StyledInputLabel>
196
- ) : (
197
- <StyledInputLabel color={color} variant='outlined'>
198
- {placeholder}
199
- </StyledInputLabel>
200
- )
201
- ) : null}
186
+ {hasLabel && (
187
+ <StyledInputLabel
188
+ color={color}
189
+ variant='outlined'
190
+ shrink={hasShrink ? true : undefined}
191
+ >
192
+ {placeholder}
193
+ </StyledInputLabel>
194
+ )}
202
195
  <StyledSelect
203
196
  value={value}
204
197
  paperMaxHeight={paperMaxHeight}
@@ -208,7 +201,7 @@ const OutlinedSelect = ({
208
201
  color={color}
209
202
  label={hasLabel ? placeholder : undefined}
210
203
  disabled={disabled}
211
- {...OutlinedInputProps}
204
+ {...InputProps}
212
205
  />
213
206
  }
214
207
  {...SelectProps}