@junyiacademy/ui-test 0.0.6 → 0.0.10

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.
@@ -1,5 +1,8 @@
1
+ export { default as TopicFilter } from './lib/TopicFilter';
2
+ export { default as SelectMenuItem } from './lib/menu-item/SelectMenuItem';
3
+ export { default as OutlinedSelect } from './lib/select/OutlinedSelect';
1
4
  export { default as Button } from './lib/button/Button';
2
5
  export { default as ButtonGroup } from './lib/button-group/ButtonGroup';
3
6
  export { default as Radio } from './lib/radio/Radio';
4
7
  export { default as TextField } from './lib/text-field/TextField';
5
- export { default as SelectionItem } from './lib/selection-item/SelectionItem';
8
+ export { default as StandardSelect } from './lib/select/StandardSelect';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- export interface SelectMenuItemProps {
2
+ import { MenuItemProps } from '@material-ui/core';
3
+ export interface SelectMenuItemProps extends MenuItemProps {
4
+ width: number | 'auto';
3
5
  value?: any;
4
6
  disabled?: boolean;
5
7
  }
6
- declare const SelectMenuItem: React.ForwardRefExoticComponent<SelectMenuItemProps & {
7
- children?: React.ReactNode;
8
- } & React.RefAttributes<HTMLLIElement>>;
8
+ declare const SelectMenuItem: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<SelectMenuItemProps>, "button" | "slot" | "style" | "title" | "color" | "width" | "alignItems" | "translate" | "hidden" | "dense" | "disabled" | "classes" | "className" | "children" | "value" | "onChange" | "onKeyUp" | "onKeyDown" | "onBlur" | "onFocus" | "defaultValue" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "autoFocus" | "innerRef" | "key" | "selected" | "ContainerComponent" | "ContainerProps" | "disableGutters" | "divider" | "focusVisibleClassName"> & React.RefAttributes<HTMLLIElement>>;
9
9
  export default SelectMenuItem;
@@ -1,15 +1,20 @@
1
- import { PropsWithChildren, ChangeEvent } from 'react';
1
+ import { ChangeEvent } from 'react';
2
2
  import { SelectProps, OutlinedInputProps } from '@material-ui/core';
3
- export interface OutlinedSelectProps {
3
+ export interface OutlinedSelectProps extends SelectProps {
4
+ color?: 'primary' | 'secondary';
4
5
  size?: 'medium' | 'small';
6
+ width?: number | 'auto';
7
+ paperMaxHeight?: number | 'auto';
8
+ error?: boolean;
5
9
  hasLabel?: boolean;
6
- placeholder?: string;
7
- value?: unknown;
10
+ hasShrink?: boolean;
11
+ placeholder: string;
12
+ helperText?: string;
8
13
  disabled?: boolean;
9
- SelectProps?: Partial<SelectProps>;
14
+ SelectProps?: object | Partial<SelectProps>;
10
15
  OutlinedInputProps?: Partial<OutlinedInputProps> & {
11
16
  onChange: (e: ChangeEvent<HTMLInputElement>) => void;
12
17
  };
13
18
  }
14
- declare const OutlinedSelect: ({ size, hasLabel, placeholder, value, disabled, SelectProps, OutlinedInputProps, children, }: PropsWithChildren<OutlinedSelectProps>) => JSX.Element;
19
+ declare const OutlinedSelect: ({ placeholder, SelectProps, OutlinedInputProps, children, color, size, width, paperMaxHeight, error, hasLabel, hasShrink, helperText, value, disabled, }: OutlinedSelectProps) => JSX.Element;
15
20
  export default OutlinedSelect;
@@ -1,6 +1,5 @@
1
- import React from 'react';
2
1
  import { SelectProps, InputProps } from '@material-ui/core';
3
- export interface StandardSelectProps {
2
+ export interface StandardSelectProps extends SelectProps {
4
3
  color?: 'primary' | 'secondary';
5
4
  size?: 'medium' | 'small';
6
5
  width?: number | 'auto';
@@ -8,13 +7,10 @@ export interface StandardSelectProps {
8
7
  error?: boolean;
9
8
  hasShrink?: boolean;
10
9
  placeholder: string;
11
- hasHelperText?: boolean;
12
10
  helperText?: string;
13
11
  InputProps?: object & Partial<InputProps>;
14
- value?: unknown;
15
12
  disabled?: boolean;
16
13
  SelectProps?: object | Partial<SelectProps>;
17
- children?: React.ReactNode;
18
14
  }
19
- export declare function StandardSelect({ color, size, width, paperMaxHeight, error, hasShrink, placeholder, hasHelperText, helperText, InputProps, value, SelectProps, disabled, children, }: StandardSelectProps): JSX.Element;
15
+ export declare function StandardSelect({ placeholder, helperText, InputProps, SelectProps, children, color, size, width, paperMaxHeight, error, hasShrink, value, disabled, }: StandardSelectProps): JSX.Element;
20
16
  export default StandardSelect;
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SelectionItem = exports.TextField = exports.Radio = exports.ButtonGroup = exports.Button = void 0;
6
+ exports.StandardSelect = exports.TextField = exports.Radio = exports.ButtonGroup = exports.Button = exports.OutlinedSelect = exports.SelectMenuItem = exports.TopicFilter = void 0;
7
+ var TopicFilter_1 = require("./lib/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 OutlinedSelect_1 = require("./lib/select/OutlinedSelect");
12
+ Object.defineProperty(exports, "OutlinedSelect", { enumerable: true, get: function () { return __importDefault(OutlinedSelect_1).default; } });
7
13
  var Button_1 = require("./lib/button/Button");
8
14
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
9
15
  var ButtonGroup_1 = require("./lib/button-group/ButtonGroup");
@@ -12,5 +18,5 @@ var Radio_1 = require("./lib/radio/Radio");
12
18
  Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
13
19
  var TextField_1 = require("./lib/text-field/TextField");
14
20
  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; } });
21
+ var StandardSelect_1 = require("./lib/select/StandardSelect");
22
+ Object.defineProperty(exports, "StandardSelect", { enumerable: true, get: function () { return __importDefault(StandardSelect_1).default; } });
@@ -9,24 +9,22 @@ const SelectMenuItem_1 = tslib_1.__importDefault(require("./menu-item/SelectMenu
9
9
  // self-defined-configs
10
10
  const PLACEHOLDER = '請選擇';
11
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
- },
12
+ const PREFIX = 'JuiTopicFilter';
13
+ const FiltersWrapper = styles_1.styled('div')({
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ flexWrap: 'wrap',
17
+ });
18
+ const SelectWrapper = styles_1.styled('div')({
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ });
22
+ const StyledArrowRightRoundedIcon = styles_1.styled(ArrowRightRounded_1.default)(({ theme }) => ({
23
+ margin: theme.spacing(-1, -1.5),
24
+ fontSize: theme.spacing(7),
25
+ color: '#444',
27
26
  }));
28
27
  const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
29
- const classes = useStyles();
30
28
  const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
31
29
  const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
32
30
  const [isFocusedList, setIsFocusedList] = react_1.useState([]);
@@ -83,15 +81,13 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
83
81
  setLayeredTopicList([topicTree]);
84
82
  }, [topicTree]);
85
83
  if (layeredTopicList.length === 0) {
86
- return (react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
84
+ return (react_1.default.createElement(OutlinedSelect_1.default, { size: 'small', width: 220, placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
87
85
  }
88
- return (react_1.default.createElement("div", { className: classes.filtersWrapper }, layeredTopicList.map((layeredTopic, layerNumber) => {
86
+ return (react_1.default.createElement(FiltersWrapper, null, layeredTopicList.map((layeredTopic, layerNumber) => {
89
87
  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
- },
88
+ return (react_1.default.createElement(SelectWrapper, { key: layeredTopic.id },
89
+ 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: {
90
+ 'data-testid': `layered-topic-${layerNumber}`,
95
91
  }, OutlinedInputProps: {
96
92
  inputProps: {
97
93
  'aria-label': `layered-topic-${layerNumber}`,
@@ -114,9 +110,9 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
114
110
  });
115
111
  },
116
112
  } },
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' }))));
113
+ react_1.default.createElement(SelectMenuItem_1.default, { width: 220, disabled: true }, PLACEHOLDER),
114
+ 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)))),
115
+ hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(StyledArrowRightRoundedIcon, { fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
120
116
  })));
121
117
  };
122
118
  exports.default = TopicFilter;
@@ -5,20 +5,23 @@ const react_1 = tslib_1.__importDefault(require("react"));
5
5
  const styles_1 = require("@material-ui/core/styles");
6
6
  const core_1 = require("@material-ui/core");
7
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)',
8
+ const PREFIX = 'JuiSelectMenuItem';
9
+ const classes = {
10
+ menuItemSelected: `${PREFIX}-menuItemSelected`,
11
+ };
12
+ const StyledMenuItem = styles_1.styled((_a) => {
13
+ var { width: _width } = _a, props = tslib_1.__rest(_a, ["width"]);
14
+ return (react_1.default.createElement(core_1.MenuItem, Object.assign({ classes: { selected: classes.menuItemSelected } }, props)));
15
+ })(({ width, theme }) => ({
16
+ width: width,
17
+ whiteSpace: 'unset',
18
+ color: theme.palette.text.primary,
19
+ [`& .${classes.menuItemSelected}`]: {
20
+ backgroundColor: theme.palette.grey[300],
13
21
  },
14
- menuItemSelected: { backgroundColor: '#E0E0E0' },
15
22
  }));
16
23
  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));
24
+ var { width, children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["width", "children", "value"]);
25
+ return (react_1.default.createElement(StyledMenuItem, Object.assign({ width: width, innerRef: ref, value: value }, otherProps), children));
23
26
  });
24
27
  exports.default = SelectMenuItem;
@@ -5,61 +5,103 @@ const react_1 = tslib_1.__importDefault(require("react"));
5
5
  const styles_1 = require("@material-ui/core/styles");
6
6
  const core_1 = require("@material-ui/core");
7
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
- },
8
+ const PREFIX = 'JuiOutlinedSelect';
9
+ const classes = {
10
+ inputLabelFocused: `${PREFIX}-inputLabelFocused`,
11
+ inputLabelOutlined: `${PREFIX}-inputLabelOutlined`,
12
+ inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
13
+ inputLabelShrink: `${PREFIX}-inputLabelShrink`,
14
+ inputLabelError: `${PREFIX}-inputLabelError`,
15
+ inputLabelDisabled: `${PREFIX}-inputLabelDisabled`,
16
+ outlineInputInput: `${PREFIX}-input`,
17
+ outlineInputInputMarginDense: `${PREFIX}-inputMarginDense`,
18
+ outlineInputNotchedOutline: `${PREFIX}-notchedOutline`,
19
+ outlineInputDisabled: `${PREFIX}-inputDisabled`,
20
+ outlineInputError: `${PREFIX}-outlinedInputError`,
21
+ selectPaper: `${PREFIX}-menuPaper`,
22
+ };
23
+ const StyledFormControl = styles_1.styled((_a) => {
24
+ var { color: _color, width: _width } = _a, props = tslib_1.__rest(_a, ["color", "width"]);
25
+ return react_1.default.createElement(core_1.FormControl, Object.assign({}, props));
26
+ })(({ color, width, theme }) => ({
27
+ margin: theme.spacing(1),
28
+ width: width,
29
+ backgroundColor: 'white',
30
+ '&:hover': {
31
+ [`& :not(.${classes.outlineInputDisabled}):not(.${classes.outlineInputError}) .${classes.outlineInputNotchedOutline}`]: {
32
+ borderColor: theme.palette[color].main,
17
33
  },
18
34
  },
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)': {
35
+ }));
36
+ const StyledInputLabel = styles_1.styled((_a) => {
37
+ var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
38
+ return (react_1.default.createElement(core_1.InputLabel, Object.assign({ classes: {
39
+ outlined: classes.inputLabelOutlined,
40
+ marginDense: classes.inputLabelMarginDense,
41
+ shrink: classes.inputLabelShrink,
42
+ focused: classes.inputLabelFocused,
43
+ disabled: classes.inputLabelDisabled,
44
+ error: classes.inputLabelError,
45
+ } }, props)));
46
+ })(({ color, theme }) => ({
47
+ color: theme.palette.text.secondary,
48
+ [`&.${classes.inputLabelOutlined}`]: {
49
+ [`&:not(.${classes.inputLabelDisabled}) .${classes.inputLabelFocused}`]: {
50
+ color: theme.palette.action.active,
51
+ },
52
+ [`&.${classes.inputLabelMarginDense}:not(.${classes.inputLabelShrink})`]: {
28
53
  transform: 'translate(12px, 16px) scale(1)',
29
54
  },
30
55
  },
31
- inputDisabled: {},
32
- notchedOutline: {},
33
- inputLabelMarginDense: {},
34
- inputLabelShrink: {},
35
- menuPaper: { maxHeight: 412 },
56
+ [`&.${classes.inputLabelShrink}:not(.${classes.inputLabelError}):not(.${classes.inputLabelDisabled}).${classes.inputLabelFocused}`]: {
57
+ color: theme.palette[color].main,
58
+ },
59
+ [`&.${classes.inputLabelShrink}`]: {
60
+ backgroundColor: '#ffffff',
61
+ padding: '0 2px',
62
+ },
63
+ }));
64
+ const StyledOutlinedInput = styles_1.styled((props) => (react_1.default.createElement(core_1.OutlinedInput, Object.assign({ classes: {
65
+ input: classes.outlineInputInput,
66
+ inputMarginDense: classes.outlineInputInputMarginDense,
67
+ notchedOutline: classes.outlineInputNotchedOutline,
68
+ disabled: classes.outlineInputDisabled,
69
+ error: classes.outlineInputError,
70
+ } }, props))))(({ theme }) => ({
71
+ [`& .${classes.outlineInputInput}`]: {
72
+ color: theme.palette.text.primary,
73
+ },
74
+ [`& .${classes.outlineInputInputMarginDense}`]: {
75
+ padding: '14.5px 15px 14.5px 12px',
76
+ },
77
+ }));
78
+ const StyledSelect = styles_1.styled((_a) => {
79
+ var { paperMaxHeight: _paperMaxHeight, hasAdornment: _hasAdornment, className } = _a, props = tslib_1.__rest(_a, ["paperMaxHeight", "hasAdornment", "className"]);
80
+ return (react_1.default.createElement(core_1.Select, Object.assign({ MenuProps: {
81
+ disableAutoFocusItem: true,
82
+ anchorOrigin: {
83
+ vertical: 2,
84
+ horizontal: 'left',
85
+ },
86
+ transformOrigin: {
87
+ vertical: 'top',
88
+ horizontal: 'left',
89
+ },
90
+ getContentAnchorEl: null,
91
+ classes: { paper: className },
92
+ } }, props)));
93
+ })(({ hasAdornment, paperMaxHeight }) => ({
94
+ '&': {
95
+ maxHeight: paperMaxHeight,
96
+ left: hasAdornment ? '24px !important' : '70px',
97
+ },
36
98
  }));
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)));
99
+ const OutlinedSelect = ({ placeholder, SelectProps, OutlinedInputProps, children, color = 'primary', size = 'medium', width = 'auto', paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, helperText = '', value = '', disabled = false, }) => {
100
+ const hasAdornment = !!(OutlinedInputProps === null || OutlinedInputProps === void 0 ? void 0 : OutlinedInputProps.startAdornment);
101
+ const hasHelperText = !!helperText;
102
+ return (react_1.default.createElement(StyledFormControl, { size: size, width: width, disabled: disabled, error: error, color: color },
103
+ hasLabel && (react_1.default.createElement(StyledInputLabel, { color: color, variant: 'outlined', shrink: hasShrink ? true : undefined }, placeholder)),
104
+ react_1.default.createElement(StyledSelect, Object.assign({ value: value, paperMaxHeight: paperMaxHeight, hasAdornment: hasAdornment, input: react_1.default.createElement(StyledOutlinedInput, Object.assign({ color: color, label: hasLabel ? placeholder : undefined, disabled: disabled }, OutlinedInputProps)) }, SelectProps), children),
105
+ hasHelperText && react_1.default.createElement(core_1.FormHelperText, null, helperText)));
64
106
  };
65
107
  exports.default = OutlinedSelect;
@@ -8,11 +8,9 @@ const core_1 = require("@material-ui/core");
8
8
  // self-defined-components
9
9
  const PREFIX = 'JuiStandardSelect';
10
10
  const classes = {
11
- inputLabelRoot: `${PREFIX}-inputLabel`,
12
11
  inputLabelFocused: `${PREFIX}-inputLabelFocused`,
13
12
  inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
14
13
  inputLabelError: `${PREFIX}-inputLabelError`,
15
- inputRoot: `${PREFIX}-inputRoot`,
16
14
  inputUnderline: `${PREFIX}-inputUnderline`,
17
15
  inputError: `${PREFIX}-inputError`,
18
16
  inputDisabled: `${PREFIX}-inputDisabled`,
@@ -30,20 +28,17 @@ const StyledFormControl = styles_1.styled((_a) => {
30
28
  const StyledInputLabel = styles_1.styled((_a) => {
31
29
  var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
32
30
  return (react_1.default.createElement(core_1.InputLabel, Object.assign({ classes: {
33
- root: classes.inputLabelRoot,
34
31
  focused: classes.inputLabelFocused,
35
32
  error: classes.inputLabelError,
36
33
  } }, props)));
37
34
  })(({ color, theme }) => ({
38
- [`&.${classes.inputLabelRoot}`]: {
39
- color: theme.palette.text.disabled,
40
- margin: theme.spacing(0, 10, 1.5, 0),
41
- [`&.${classes.inputLabelFocused}`]: {
42
- color: theme.palette[color].main,
43
- },
44
- [`&.${classes.inputLabelError}`]: {
45
- color: theme.palette.error.main,
46
- },
35
+ color: theme.palette.text.disabled,
36
+ margin: theme.spacing(0, 10, 1.5, 0),
37
+ [`&.${classes.inputLabelFocused}`]: {
38
+ color: theme.palette[color].main,
39
+ },
40
+ [`&.${classes.inputLabelError}`]: {
41
+ color: theme.palette.error.main,
47
42
  },
48
43
  }));
49
44
  const StyledSelect = styles_1.styled((_a) => {
@@ -61,20 +56,16 @@ const StyledSelect = styles_1.styled((_a) => {
61
56
  maxHeight: paperMaxHeight,
62
57
  left: hasAdornment ? '48px !important' : '70px',
63
58
  },
64
- [`&.${classes.selectDisabled}`]: {},
65
59
  }));
66
60
  const StyledInput = styles_1.styled((_a) => {
67
61
  var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
68
62
  return (react_1.default.createElement(core_1.Input, Object.assign({ classes: {
69
63
  disabled: classes.inputDisabled,
70
- root: classes.inputRoot,
71
64
  underline: classes.inputUnderline,
72
65
  error: classes.inputError,
73
66
  } }, props)));
74
67
  })(({ color, theme }) => ({
75
- [`&.${classes.inputRoot}`]: {
76
- color: theme.palette.text.primary,
77
- },
68
+ color: theme.palette.text.primary,
78
69
  [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
79
70
  [`&:after,&:hover:before`]: {
80
71
  borderBottomColor: theme.palette[color].main,
@@ -86,10 +77,11 @@ const StyledInput = styles_1.styled((_a) => {
86
77
  },
87
78
  },
88
79
  }));
89
- function StandardSelect({ color = 'primary', size = 'medium', width = 'auto', paperMaxHeight = 'auto', error = false, hasShrink = false, placeholder, hasHelperText = false, helperText, InputProps, value = '', SelectProps, disabled = false, children, }) {
80
+ function StandardSelect({ placeholder, helperText, InputProps, SelectProps, children, color = 'primary', size = 'medium', width = 'auto', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
90
81
  const hasAdornment = !!(InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment);
82
+ const hasHelperText = !!helperText;
91
83
  return (react_1.default.createElement(StyledFormControl, { color: color, size: size, width: width, disabled: disabled, error: error },
92
- hasShrink ? (react_1.default.createElement(StyledInputLabel, { color: color, shrink: true }, placeholder)) : (react_1.default.createElement(StyledInputLabel, { color: color }, placeholder)),
84
+ react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, placeholder),
93
85
  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),
94
86
  hasHelperText && react_1.default.createElement(core_1.FormHelperText, null, helperText)));
95
87
  }
@@ -4,11 +4,12 @@ exports.SelectionItem = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const core_1 = require("@material-ui/core");
7
+ const Radio_1 = require("../radio/Radio");
7
8
  function SelectionItem({ handleInput, label1, value1, label2, value2, isError, }) {
8
9
  return (react_1.default.createElement(react_1.default.Fragment, null,
9
10
  react_1.default.createElement(core_1.RadioGroup, { onChange: handleInput },
10
- react_1.default.createElement(core_1.FormControlLabel, { label: label1, value: value1, control: react_1.default.createElement(core_1.Radio, null) }),
11
- react_1.default.createElement(core_1.FormControlLabel, { label: label2, value: value2, control: react_1.default.createElement(core_1.Radio, null) })),
11
+ react_1.default.createElement(Radio_1.Radio, { label: label1, value: value1 }),
12
+ react_1.default.createElement(Radio_1.Radio, { label: label2, value: value2 })),
12
13
  isError && react_1.default.createElement(core_1.FormHelperText, null, "\u8ACB\u9078\u64C7")));
13
14
  }
14
15
  exports.SelectionItem = SelectionItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junyiacademy/ui-test",
3
- "version": "0.0.6",
3
+ "version": "0.0.10",
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,5 +1,8 @@
1
+ export { default as TopicFilter } from './lib/TopicFilter'
2
+ export { default as SelectMenuItem } from './lib/menu-item/SelectMenuItem'
3
+ export { default as OutlinedSelect } from './lib/select/OutlinedSelect'
1
4
  export { default as Button } from './lib/button/Button'
2
5
  export { default as ButtonGroup } from './lib/button-group/ButtonGroup'
3
6
  export { default as Radio } from './lib/radio/Radio'
4
7
  export { default as TextField } from './lib/text-field/TextField'
5
- export { default as SelectionItem } from './lib/selection-item/SelectionItem'
8
+ export { default as StandardSelect } from './lib/select/StandardSelect'
@@ -0,0 +1,10 @@
1
+ import { render } from '@testing-library/react'
2
+
3
+ import TopicFilter from './TopicFilter'
4
+
5
+ describe('TopicFilter', () => {
6
+ it('should render successfully', () => {
7
+ const { baseElement } = render(<TopicFilter />)
8
+ expect(baseElement).toBeTruthy()
9
+ })
10
+ })
@@ -0,0 +1,82 @@
1
+ import React from 'react'
2
+ import { Story, Meta } from '@storybook/react'
3
+ import TopicFilter, { TopicFilterProps } from './TopicFilter'
4
+ import { topicTree } from '../utils/topicTree'
5
+
6
+ export default {
7
+ component: TopicFilter,
8
+ title: 'TopicFilter',
9
+ argTypes: {
10
+ topicTree: {
11
+ type: { name: 'object', required: false },
12
+ description: 'Topic tree data list',
13
+ table: {
14
+ type: { summary: 'object' },
15
+ defaultValue: { summary: topicTree },
16
+ },
17
+ control: { type: 'object' },
18
+ },
19
+ onTopicSelected: {
20
+ type: { name: 'function', required: false },
21
+ description: 'Callback fired when the topic selected.',
22
+ table: {
23
+ type: {
24
+ summary: `(
25
+ topic: Topic,
26
+ selectedInfo: { layerNumber: number; selectedTopicIds: string[] }
27
+ ) => void`,
28
+ },
29
+ defaultValue: { summary: () => {} },
30
+ },
31
+ control: { type: 'function' },
32
+ },
33
+ isLastLayer: {
34
+ type: { name: 'function', required: false },
35
+ description: 'Callback for checking selected topic is last layer or not.',
36
+ table: {
37
+ type: {
38
+ summary: `(topic: Topic) => boolean`,
39
+ },
40
+ defaultValue: { summary: () => false },
41
+ },
42
+ control: { type: 'function' },
43
+ },
44
+ hasArrow: {
45
+ type: { name: 'boolean', required: false },
46
+ description: 'Control the arrow display state.',
47
+ table: {
48
+ type: { summary: 'boolean' },
49
+ defaultValue: { summary: true },
50
+ },
51
+ control: { type: 'boolean' },
52
+ defaultValue: true,
53
+ },
54
+ initSelectedTopicIds: {
55
+ type: { name: 'array', required: false },
56
+ description: ``,
57
+ table: {
58
+ type: { summary: 'array' },
59
+ defaultValue: { summary: [] },
60
+ },
61
+ control: { type: 'array' },
62
+ },
63
+ },
64
+ } as Meta
65
+
66
+ const TopicFilterWithOutlinedSelectStory: Story<TopicFilterProps> = (args) => (
67
+ <TopicFilter {...args} />
68
+ )
69
+
70
+ export const TopicFilterWithOutlinedSelect = TopicFilterWithOutlinedSelectStory.bind(
71
+ {}
72
+ )
73
+
74
+ TopicFilterWithOutlinedSelect.args = {
75
+ topicTree: topicTree,
76
+ onTopicSelected: () => {},
77
+ isLastLayer: (selectedTopic) => {
78
+ return selectedTopic.isContentTopic
79
+ },
80
+ hasArrow: true,
81
+ initSelectedTopicIds: [],
82
+ }