@junyiacademy/ui-test 1.4.0 → 1.4.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.
Files changed (33) hide show
  1. package/declarations/libs/ui/src/interfaces/index.d.ts +1 -2
  2. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +1 -2
  3. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +1 -1
  4. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +1 -1
  5. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +4 -8
  6. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +4 -6
  7. package/dist/libs/ui/src/lib/select/StandardSelect.js +5 -12
  8. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +8 -5
  9. package/package.json +2 -2
  10. package/.storybook/main.js +0 -9
  11. package/.storybook/preview.js +0 -10
  12. package/.storybook/tsconfig.json +0 -14
  13. package/.storybook/webpack.config.js +0 -84
  14. package/src/index.ts +0 -7
  15. package/src/interfaces/index.tsx +0 -34
  16. package/src/lib/button/Button.stories.tsx +0 -50
  17. package/src/lib/button/Button.tsx +0 -85
  18. package/src/lib/button-group/ButtonGroup.stories.tsx +0 -59
  19. package/src/lib/button-group/ButtonGroup.tsx +0 -37
  20. package/src/lib/menu-item/SelectMenuItem.stories.tsx +0 -44
  21. package/src/lib/menu-item/SelectMenuItem.tsx +0 -48
  22. package/src/lib/radio/Radio.stories.tsx +0 -154
  23. package/src/lib/radio/Radio.tsx +0 -93
  24. package/src/lib/select/OutlinedSelect.tsx +0 -220
  25. package/src/lib/select/Select.stories.tsx +0 -306
  26. package/src/lib/select/Select.tsx +0 -13
  27. package/src/lib/select/StandardSelect.tsx +0 -178
  28. package/src/lib/text-field/TextField.stories.tsx +0 -160
  29. package/src/lib/text-field/TextField.tsx +0 -93
  30. package/src/lib/topic-filter/TopicFilter.stories.tsx +0 -83
  31. package/src/lib/topic-filter/TopicFilter.tsx +0 -209
  32. package/src/styles/theme.ts +0 -60
  33. package/src/utils/topicTree.ts +0 -197
@@ -17,11 +17,10 @@ export interface SelectProps extends MuiSelectProp {
17
17
  SelectProps?: object | Partial<MuiSelectProp>;
18
18
  color?: 'primary' | 'secondary';
19
19
  size?: 'medium' | 'small';
20
- width?: number | string;
21
- selectMargin?: number | string;
22
20
  paperMaxHeight?: number | string;
23
21
  error?: boolean;
24
22
  hasLabel?: boolean;
25
23
  hasShrink?: boolean;
26
24
  disabled?: boolean;
25
+ className?: string;
27
26
  }
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import { MenuItemProps } from '@material-ui/core';
3
3
  export interface SelectMenuItemProps extends MenuItemProps {
4
- width: number | string;
5
4
  value?: any;
6
5
  disabled?: boolean;
7
6
  }
8
- declare const SelectMenuItem: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<SelectMenuItemProps>, "classes" | "disabled" | "value" | "onChange" | "children" | "onKeyUp" | "onKeyDown" | "onBlur" | "onFocus" | "defaultValue" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "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" | "button" | "width" | "alignItems" | "dense" | "key" | "selected" | "ContainerComponent" | "ContainerProps" | "disableGutters" | "divider" | "focusVisibleClassName"> & React.RefAttributes<HTMLLIElement>>;
7
+ declare const SelectMenuItem: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<SelectMenuItemProps>, "classes" | "disabled" | "value" | "onChange" | "children" | "onKeyUp" | "onKeyDown" | "onBlur" | "onFocus" | "defaultValue" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "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" | "button" | "alignItems" | "dense" | "key" | "selected" | "ContainerComponent" | "ContainerProps" | "disableGutters" | "divider" | "focusVisibleClassName"> & React.RefAttributes<HTMLLIElement>>;
9
8
  export default SelectMenuItem;
@@ -1,3 +1,3 @@
1
1
  import { SelectProps } from '../../interfaces';
2
- export declare const OutlinedSelect: ({ placeholder, helperText, InputProps, SelectProps, children, color, size, width, selectMargin, paperMaxHeight, error, hasLabel, hasShrink, value, disabled, }: SelectProps) => JSX.Element;
2
+ export declare const OutlinedSelect: ({ placeholder, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasLabel, hasShrink, value, disabled, }: SelectProps) => JSX.Element;
3
3
  export default OutlinedSelect;
@@ -1,3 +1,3 @@
1
1
  import { SelectProps } from '../../interfaces';
2
- export declare function StandardSelect({ placeholder, helperText, InputProps, SelectProps, children, color, size, width, selectMargin, paperMaxHeight, error, hasShrink, value, disabled, }: SelectProps): JSX.Element;
2
+ export declare function StandardSelect({ placeholder, helperText, InputProps, SelectProps, className, children, color, size, paperMaxHeight, error, hasShrink, value, disabled, }: SelectProps): JSX.Element;
3
3
  export default StandardSelect;
@@ -9,22 +9,18 @@ const PREFIX = 'JuiSelectMenuItem';
9
9
  const classes = {
10
10
  menuItemSelected: `${PREFIX}-menuItemSelected`,
11
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,
12
+ const StyledMenuItem = styles_1.styled((props) => (react_1.default.createElement(core_1.MenuItem, Object.assign({ classes: { selected: classes.menuItemSelected } }, props))))(({ theme }) => ({
17
13
  whiteSpace: 'unset',
18
14
  color: theme.palette.text.primary,
19
15
  [`&.${classes.menuItemSelected}`]: {
20
16
  backgroundColor: theme.palette.grey[300],
21
- ['&:hover']: {
17
+ '&:hover': {
22
18
  backgroundColor: theme.palette.grey[200],
23
19
  },
24
20
  },
25
21
  }));
26
22
  const SelectMenuItem = react_1.default.forwardRef((_a, ref) => {
27
- var { width, children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["width", "children", "value"]);
28
- return (react_1.default.createElement(StyledMenuItem, Object.assign({ width: width, innerRef: ref, value: value }, otherProps), children));
23
+ var { children, value = '' } = _a, otherProps = tslib_1.__rest(_a, ["children", "value"]);
24
+ return (react_1.default.createElement(StyledMenuItem, Object.assign({ innerRef: ref, value: value }, otherProps), children));
29
25
  });
30
26
  exports.default = SelectMenuItem;
@@ -24,11 +24,9 @@ const classes = {
24
24
  selectPaper: `${PREFIX}-menuPaper`,
25
25
  };
26
26
  const StyledFormControl = styles_1.styled((_a) => {
27
- var { color: _color, width: _width, selectMargin: _selectMargin } = _a, props = tslib_1.__rest(_a, ["color", "width", "selectMargin"]);
27
+ var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
28
28
  return (react_1.default.createElement(core_1.FormControl, Object.assign({}, props)));
29
- })(({ color, width, selectMargin, theme }) => ({
30
- width,
31
- margin: selectMargin,
29
+ })(({ color, theme }) => ({
32
30
  backgroundColor: 'white',
33
31
  '&:hover': {
34
32
  [`& :not(.${classes.outlineInputDisabled}):not(.${classes.outlineInputError}) .${classes.outlineInputNotchedOutline}`]: {
@@ -111,10 +109,10 @@ const StyledSelect = styles_1.styled((_a) => {
111
109
  left: hasAdornment ? '24px !important' : '70px',
112
110
  },
113
111
  }));
114
- const OutlinedSelect = ({ placeholder, helperText, InputProps, SelectProps, children, color = 'primary', size = 'small', width = 'auto', selectMargin = 0, paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, value = '', disabled = false, }) => {
112
+ const OutlinedSelect = ({ placeholder, helperText, InputProps, SelectProps, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasLabel = true, hasShrink = false, value = '', disabled = false, }) => {
115
113
  const hasAdornment = !!(InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment);
116
114
  const hasHelperText = !!helperText;
117
- return (react_1.default.createElement(StyledFormControl, { size: size, width: width, selectMargin: selectMargin, disabled: disabled, error: error, color: color },
115
+ return (react_1.default.createElement(StyledFormControl, { size: size, disabled: disabled, error: error, color: color, className: className },
118
116
  hasLabel && (react_1.default.createElement(StyledInputLabel, { color: color, variant: 'outlined', shrink: hasShrink ? true : undefined }, placeholder)),
119
117
  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 }, InputProps)) }, SelectProps), children),
120
118
  hasHelperText && react_1.default.createElement(core_1.FormHelperText, null, helperText)));
@@ -20,13 +20,6 @@ const classes = {
20
20
  selectPaper: `${PREFIX}-menuPaper`,
21
21
  selectDisabled: `${PREFIX}-selectDisabled`,
22
22
  };
23
- const StyledFormControl = styles_1.styled((_a) => {
24
- var { width: _width, selectMargin: _selectMargin } = _a, props = tslib_1.__rest(_a, ["width", "selectMargin"]);
25
- return (react_1.default.createElement(core_1.FormControl, Object.assign({}, props)));
26
- })(({ width, selectMargin, theme }) => ({
27
- width,
28
- margin: selectMargin,
29
- }));
30
23
  const StyledInputLabel = styles_1.styled((_a) => {
31
24
  var { color: _color } = _a, props = tslib_1.__rest(_a, ["color"]);
32
25
  return (react_1.default.createElement(core_1.InputLabel, Object.assign({ classes: {
@@ -70,25 +63,25 @@ const StyledInput = styles_1.styled((_a) => {
70
63
  })(({ color, theme }) => ({
71
64
  color: theme.palette.text.primary,
72
65
  [`& .${classes.inputInput}`]: {
73
- ['&:focus']: {
66
+ '&:focus': {
74
67
  background: 'rgba(0,0,0,0)',
75
68
  },
76
69
  },
77
70
  [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
78
- [`&:after,&:hover:before`]: {
71
+ '&:after,&:hover:before': {
79
72
  borderBottomColor: theme.palette[color].main,
80
73
  },
81
74
  },
82
75
  [`&.${classes.inputUnderline}.${classes.inputError}:not(.${classes.inputDisabled})`]: {
83
- [`&:after,&:hover:before`]: {
76
+ '&:after,&:hover:before': {
84
77
  borderBottomColor: theme.palette.error.main,
85
78
  },
86
79
  },
87
80
  }));
88
- function StandardSelect({ placeholder, helperText, InputProps, SelectProps, children, color = 'primary', size = 'small', width = 'auto', selectMargin = '0', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
81
+ function StandardSelect({ placeholder, helperText, InputProps, SelectProps, className, children, color = 'primary', size = 'small', paperMaxHeight = 'auto', error = false, hasShrink = false, value = '', disabled = false, }) {
89
82
  const hasAdornment = !!(InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment);
90
83
  const hasHelperText = !!helperText;
91
- return (react_1.default.createElement(StyledFormControl, { color: color, size: size, width: width, selectMargin: selectMargin, disabled: disabled, error: error },
84
+ return (react_1.default.createElement(core_1.FormControl, { color: color, size: size, disabled: disabled, error: error, className: className },
92
85
  react_1.default.createElement(StyledInputLabel, { color: color, shrink: hasShrink ? true : undefined }, placeholder),
93
86
  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
87
  hasHelperText && react_1.default.createElement(core_1.FormHelperText, null, helperText)));
@@ -20,13 +20,16 @@ const SelectWrapper = styles_1.styled('div')({
20
20
  display: 'flex',
21
21
  alignItems: 'center',
22
22
  });
23
+ const StyledSelect = styles_1.styled(Select_1.default)(({ theme }) => ({
24
+ width: 220,
25
+ margin: theme.spacing(1),
26
+ }));
23
27
  const StyledArrowRightRoundedIcon = styles_1.styled(ArrowRightRounded_1.default)(({ theme }) => ({
24
28
  margin: theme.spacing(-1, -1.5),
25
29
  fontSize: theme.spacing(7),
26
30
  color: '#444',
27
31
  }));
28
32
  const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
29
- const theme = styles_1.useTheme();
30
33
  const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
31
34
  const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
32
35
  const [isFocusedList, setIsFocusedList] = react_1.useState([]);
@@ -83,12 +86,12 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
83
86
  setLayeredTopicList([topicTree]);
84
87
  }, [topicTree]);
85
88
  if (layeredTopicList.length === 0) {
86
- return (react_1.default.createElement(Select_1.default, { variant: 'outlined', size: 'small', width: 220, selectMargin: theme.spacing(1), placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
89
+ return (react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
87
90
  }
88
91
  return (react_1.default.createElement(FiltersWrapper, null, layeredTopicList.map((layeredTopic, layerNumber) => {
89
92
  const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
90
93
  return (react_1.default.createElement(SelectWrapper, { key: layeredTopic.id },
91
- react_1.default.createElement(Select_1.default, { variant: 'outlined', size: 'small', width: 220, selectMargin: theme.spacing(1), paperMaxHeight: 412, hasLabel: hasLabel, placeholder: PLACEHOLDER, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
94
+ react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', paperMaxHeight: 412, hasLabel: hasLabel, placeholder: PLACEHOLDER, value: (selectedTopicIds === null || selectedTopicIds === void 0 ? void 0 : selectedTopicIds[layerNumber]) || '', SelectProps: {
92
95
  'data-testid': `layered-topic-${layerNumber}`,
93
96
  }, InputProps: {
94
97
  inputProps: {
@@ -112,8 +115,8 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
112
115
  });
113
116
  },
114
117
  } },
115
- react_1.default.createElement(SelectMenuItem_1.default, { width: 220, disabled: true }, PLACEHOLDER),
116
- 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)))),
118
+ react_1.default.createElement(SelectMenuItem_1.default, { disabled: true }, PLACEHOLDER),
119
+ 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)))),
117
120
  hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(StyledArrowRightRoundedIcon, { fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
118
121
  })));
119
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junyiacademy/ui-test",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
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",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@material-ui/core": "4.9.10",
21
21
  "@material-ui/icons": "4.9.1",
22
- "react": "17.0.2"
22
+ "react": "16.13.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "~4.1.4"
@@ -1,9 +0,0 @@
1
- const rootMain = require('../../../.storybook/main')
2
-
3
- // Use the following syntax to add addons!
4
- // rootMain.addons.push('');
5
- rootMain.stories.push(
6
- ...['../src/lib/**/*.stories.mdx', '../src/lib/**/*.stories.@(js|jsx|ts|tsx)']
7
- )
8
-
9
- module.exports = rootMain
@@ -1,10 +0,0 @@
1
- import { ThemeProvider } from '@material-ui/core/styles'
2
- import theme from '../src/styles/theme'
3
-
4
- export const decorators = [
5
- (Story) => (
6
- <ThemeProvider theme={theme}>
7
- <Story />
8
- </ThemeProvider>
9
- ),
10
- ]
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "emitDecoratorMetadata": true,
5
- "outDir": ""
6
- },
7
- "exclude": [
8
- "../**/*.spec.ts",
9
- "../**/*.spec.js",
10
- "../**/*.spec.tsx",
11
- "../**/*.spec.jsx"
12
- ],
13
- "include": ["../src/**/*", "*.js"]
14
- }
@@ -1,84 +0,0 @@
1
- const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
2
- const rootWebpackConfig = require('../../../.storybook/webpack.config')
3
- /**
4
- * Export a function. Accept the base config as the only param.
5
- *
6
- * @param {Parameters<typeof rootWebpackConfig>[0]} options
7
- */
8
- module.exports = async ({ config, mode }) => {
9
- config = await rootWebpackConfig({ config, mode })
10
-
11
- const tsPaths = new TsconfigPathsPlugin({
12
- configFile: './tsconfig.base.json',
13
- })
14
-
15
- config.resolve.plugins
16
- ? config.resolve.plugins.push(tsPaths)
17
- : (config.resolve.plugins = [tsPaths])
18
-
19
- // Found this here: https://github.com/nrwl/nx/issues/2859
20
- // And copied the part of the solution that made it work
21
-
22
- const svgRuleIndex = config.module.rules.findIndex((rule) => {
23
- const { test } = rule
24
-
25
- return test.toString().startsWith('/\\.(svg|ico')
26
- })
27
- config.module.rules[
28
- svgRuleIndex
29
- ].test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/
30
-
31
- config.module.rules.push(
32
- {
33
- test: /\.(png|jpe?g|gif|webp)$/,
34
- loader: require.resolve('url-loader'),
35
- options: {
36
- limit: 10000, // 10kB
37
- name: '[name].[hash:7].[ext]',
38
- },
39
- },
40
- {
41
- test: /\.svg$/,
42
- oneOf: [
43
- // If coming from JS/TS file, then transform into React component using SVGR.
44
- {
45
- issuer: {
46
- test: /\.[jt]sx?$/,
47
- },
48
- use: [
49
- {
50
- loader: require.resolve('@svgr/webpack'),
51
- options: {
52
- svgo: false,
53
- titleProp: true,
54
- ref: true,
55
- },
56
- },
57
- {
58
- loader: require.resolve('url-loader'),
59
- options: {
60
- limit: 10000, // 10kB
61
- name: '[name].[hash:7].[ext]',
62
- esModule: false,
63
- },
64
- },
65
- ],
66
- },
67
- // Fallback to plain URL loader.
68
- {
69
- use: [
70
- {
71
- loader: require.resolve('url-loader'),
72
- options: {
73
- limit: 10000, // 10kB
74
- name: '[name].[hash:7].[ext]',
75
- },
76
- },
77
- ],
78
- },
79
- ],
80
- }
81
- )
82
-
83
- return config
84
- }
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
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,34 +0,0 @@
1
- import { ChangeEvent } from 'react'
2
- import {
3
- SelectProps as MuiSelectProp,
4
- InputProps as MuiInputProps,
5
- OutlinedInputProps,
6
- } from '@material-ui/core'
7
-
8
- export interface ITopicTreeNode {
9
- childTopics: ITopicTreeNode[]
10
- id: string
11
- isContentTopic: boolean
12
- key: string
13
- tags: string[]
14
- title: string
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 | string
28
- selectMargin?: number | string
29
- paperMaxHeight?: number | string
30
- error?: boolean
31
- hasLabel?: boolean
32
- hasShrink?: boolean
33
- disabled?: boolean
34
- }
@@ -1,50 +0,0 @@
1
- import React from 'react'
2
- import { Story, Meta } from '@storybook/react'
3
- import { Button, ButtonProps } from './Button'
4
-
5
- export default {
6
- component: Button,
7
- title: 'Button',
8
- argTypes: {
9
- active: {
10
- description: 'The Button is active or not.',
11
- table: {
12
- defaultValue: { summary: false },
13
- },
14
- },
15
- variant: {
16
- table: {
17
- defaultValue: { summary: 'contained' },
18
- },
19
- },
20
- color: {
21
- table: {
22
- defaultValue: { summary: 'default' },
23
- },
24
- },
25
- disabled: {
26
- table: {
27
- defaultValue: { summary: false },
28
- },
29
- },
30
- size: {
31
- table: {
32
- defaultValue: { summary: 'medium' },
33
- },
34
- },
35
- },
36
- } as Meta
37
-
38
- const Template: Story<ButtonProps> = (args) => (
39
- <Button {...args}>I'm a Button</Button>
40
- )
41
-
42
- export const TextOnly = Template.bind({})
43
-
44
- TextOnly.args = {
45
- active: false,
46
- variant: 'contained',
47
- color: 'default',
48
- disabled: false,
49
- size: 'medium',
50
- }
@@ -1,85 +0,0 @@
1
- import React from 'react'
2
- import { styled, fade, Theme } from '@material-ui/core/styles'
3
- import {
4
- Button as MuiButton,
5
- ButtonProps as MuiButtonProps,
6
- } from '@material-ui/core'
7
-
8
- // self-defined-components
9
- const PREFIX = 'JuiButton'
10
-
11
- const classes = {
12
- outlinedPrimary: `${PREFIX}-outlinedPrimary`,
13
- outlinedSecondary: `${PREFIX}-outlinedSecondary`,
14
- textPrimary: `${PREFIX}-textPrimary`,
15
- textSecondary: `${PREFIX}-textSecondary`,
16
- disabled: `${PREFIX}-disabled`,
17
- }
18
-
19
- interface StyleFuncProps {
20
- active?: boolean
21
- theme?: Theme
22
- }
23
-
24
- const StyledButton = styled(({ active: _active, ...other }) => (
25
- <MuiButton classes={classes} {...other} />
26
- ))(({ active, theme }: StyleFuncProps) => ({
27
- [`&.${classes.outlinedPrimary}`]: {
28
- backgroundColor: active
29
- ? theme.palette.primary.main
30
- : theme.palette.common.white,
31
- color: active ? theme.palette.common.white : theme.palette.primary.main,
32
- borderColor: theme.palette.primary.main,
33
- '&:hover': {
34
- backgroundColor: active
35
- ? theme.palette.primary.main
36
- : fade(theme.palette.primary.main, 0.1),
37
- },
38
- [`&.${classes.disabled}`]: {
39
- backgroundColor: theme.palette.common.white,
40
- borderColor: theme.palette.action.disabledBackground,
41
- color: theme.palette.action.disabled,
42
- },
43
- },
44
- [`&.${classes.outlinedSecondary}`]: {
45
- backgroundColor: active
46
- ? theme.palette.secondary.main
47
- : theme.palette.common.white,
48
- color: active ? theme.palette.common.white : theme.palette.secondary.main,
49
- borderColor: theme.palette.secondary.main,
50
- '&:hover': {
51
- backgroundColor: active
52
- ? theme.palette.secondary.main
53
- : fade(theme.palette.secondary.main, 0.1),
54
- },
55
- [`&.${classes.disabled}`]: {
56
- backgroundColor: theme.palette.common.white,
57
- borderColor: theme.palette.action.disabledBackground,
58
- color: theme.palette.action.disabled,
59
- },
60
- },
61
- [`&.${classes.textPrimary}`]: {
62
- '&:hover': {
63
- backgroundColor: fade(theme.palette.primary.main, 0.1),
64
- },
65
- },
66
- [`&.${classes.textSecondary}`]: {
67
- '&:hover': {
68
- backgroundColor: fade(theme.palette.secondary.main, 0.1),
69
- },
70
- },
71
- }))
72
-
73
- export interface ButtonProps extends MuiButtonProps {
74
- active?: boolean
75
- }
76
-
77
- export const Button = ({ active, children, ...otherProps }: ButtonProps) => {
78
- return (
79
- <StyledButton active={active} {...otherProps}>
80
- {children}
81
- </StyledButton>
82
- )
83
- }
84
-
85
- export default Button
@@ -1,59 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { Story, Meta } from '@storybook/react'
3
- import { ButtonGroupProps as MuiButtonGroupProps } from '@material-ui/core'
4
- import { ButtonGroup } from './ButtonGroup'
5
- import { Button } from '../button/Button'
6
-
7
- const ButtonGroupWithState = (props: MuiButtonGroupProps) => {
8
- const [activeId, setActiveId] = useState(null)
9
-
10
- const buttons = ['JUI', 'MUI', 'Unstyled UI']
11
-
12
- return (
13
- <ButtonGroup {...props}>
14
- {buttons.map((id) => (
15
- <Button
16
- key={id}
17
- onClick={() => setActiveId(id)}
18
- active={id === activeId}
19
- >
20
- {id}
21
- </Button>
22
- ))}
23
- </ButtonGroup>
24
- )
25
- }
26
-
27
- export default {
28
- component: ButtonGroup,
29
- title: 'ButtonGroup',
30
- argTypes: {
31
- variant: {
32
- table: {
33
- defaultValue: { summary: 'contained' },
34
- },
35
- },
36
- color: {
37
- table: {
38
- defaultValue: { summary: 'default' },
39
- },
40
- },
41
- disabled: {
42
- table: {
43
- defaultValue: { summary: false },
44
- },
45
- },
46
- },
47
- } as Meta
48
-
49
- const Template: Story<MuiButtonGroupProps> = (args) => (
50
- <ButtonGroupWithState {...args} />
51
- )
52
-
53
- export const Basic = Template.bind({})
54
-
55
- Basic.args = {
56
- variant: 'contained',
57
- color: 'default',
58
- disabled: false,
59
- }
@@ -1,37 +0,0 @@
1
- import React from 'react'
2
- import { styled, fade } from '@material-ui/core/styles'
3
- import {
4
- ButtonGroup as MuiButtonGroup,
5
- ButtonGroupProps as MuiButtonGroupProps,
6
- } from '@material-ui/core'
7
-
8
- const PREFIX = 'JuiButtonGroup'
9
-
10
- const classes = {
11
- grouped: `${PREFIX}-grouped`,
12
- groupedOutlinedPrimary: `${PREFIX}-groupedOutlinedPrimary`,
13
- groupedOutlinedSecondary: `${PREFIX}-groupedOutlinedSecondary`,
14
- disabled: `${PREFIX}-disabled`,
15
- }
16
-
17
- const StyledButtonGroup = styled(({ ...props }) => (
18
- <MuiButtonGroup classes={classes} {...props} />
19
- ))(({ theme }) => ({
20
- [`& .${classes.groupedOutlinedPrimary}.${classes.grouped}.${classes.disabled}`]: {
21
- borderColor: fade(theme.palette.primary.main, 0.5),
22
- color: fade(theme.palette.primary.main, 0.5),
23
- },
24
- [`& .${classes.groupedOutlinedSecondary}.${classes.grouped}.${classes.disabled}`]: {
25
- borderColor: fade(theme.palette.secondary.main, 0.5),
26
- color: fade(theme.palette.secondary.main, 0.5),
27
- },
28
- }))
29
-
30
- export const ButtonGroup = ({
31
- children,
32
- ...otherProps
33
- }: MuiButtonGroupProps) => (
34
- <StyledButtonGroup {...otherProps}>{children}</StyledButtonGroup>
35
- )
36
-
37
- export default ButtonGroup