@junyiacademy/ui-test 0.0.14 → 1.5.0

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 (50) hide show
  1. package/declarations/libs/ui/src/interfaces/index.d.ts +4 -3
  2. package/declarations/libs/ui/src/lib/button/Button.d.ts +1 -1
  3. package/declarations/libs/ui/src/lib/button-group/ButtonGroup.d.ts +1 -1
  4. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +2 -3
  5. package/declarations/libs/ui/src/lib/radio/Radio.d.ts +1 -1
  6. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +1 -1
  7. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +1 -1
  8. package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +1 -1
  9. package/dist/libs/ui/src/lib/button/Button.js +15 -24
  10. package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +10 -19
  11. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +10 -15
  12. package/dist/libs/ui/src/lib/radio/Radio.js +15 -26
  13. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +44 -84
  14. package/dist/libs/ui/src/lib/select/StandardSelect.js +38 -69
  15. package/dist/libs/ui/src/lib/text-field/TextField.js +26 -38
  16. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +25 -25
  17. package/package.json +7 -4
  18. package/.eslintrc.json +0 -24
  19. package/.storybook/main.js +0 -9
  20. package/.storybook/preview.js +0 -10
  21. package/.storybook/tsconfig.json +0 -14
  22. package/.storybook/webpack.config.js +0 -84
  23. package/declarations/libs/ui/src/lib/alert/Alert.d.ts +0 -13
  24. package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +0 -10
  25. package/dist/libs/ui/src/lib/alert/Alert.js +0 -72
  26. package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +0 -16
  27. package/jest.config.js +0 -9
  28. package/src/index.ts +0 -7
  29. package/src/interfaces/index.tsx +0 -33
  30. package/src/lib/button/Button.stories.tsx +0 -50
  31. package/src/lib/button/Button.tsx +0 -85
  32. package/src/lib/button-group/ButtonGroup.stories.tsx +0 -59
  33. package/src/lib/button-group/ButtonGroup.tsx +0 -37
  34. package/src/lib/menu-item/SelectMenuItem.stories.tsx +0 -44
  35. package/src/lib/menu-item/SelectMenuItem.tsx +0 -45
  36. package/src/lib/radio/Radio.stories.tsx +0 -154
  37. package/src/lib/radio/Radio.tsx +0 -93
  38. package/src/lib/select/OutlinedSelect.tsx +0 -215
  39. package/src/lib/select/Select.stories.tsx +0 -297
  40. package/src/lib/select/Select.tsx +0 -13
  41. package/src/lib/select/StandardSelect.tsx +0 -173
  42. package/src/lib/text-field/TextField.stories.tsx +0 -160
  43. package/src/lib/text-field/TextField.tsx +0 -93
  44. package/src/lib/topic-filter/TopicFilter.stories.tsx +0 -83
  45. package/src/lib/topic-filter/TopicFilter.tsx +0 -204
  46. package/src/styles/theme.ts +0 -60
  47. package/src/utils/topicTree.ts +0 -197
  48. package/tsconfig.json +0 -16
  49. package/tsconfig.lib.json +0 -22
  50. package/tsconfig.spec.json +0 -15
@@ -3,65 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TextField = void 0;
4
4
  const tslib_1 = require("tslib");
5
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");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const material_1 = require("@mui/material");
8
+ const TextField_1 = require("@mui/material/TextField");
9
+ const Input_1 = require("@mui/material/Input");
10
+ const InputLabel_1 = require("@mui/material/InputLabel");
11
+ const OutlinedInput_1 = require("@mui/material/OutlinedInput");
8
12
  // 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})`]: {
13
+ const StyledTextField = styles_1.styled(material_1.TextField)(({ theme }) => ({
14
+ [`& .${InputLabel_1.inputLabelClasses.error}`]: {
15
+ [`&:not(.${InputLabel_1.inputLabelClasses.shrink})`]: {
35
16
  color: theme.palette.text.secondary,
36
17
  },
37
- [`&.${classes.inputLabelDisabled}`]: {
18
+ [`&.${InputLabel_1.inputLabelClasses.disabled}`]: {
38
19
  color: theme.palette.text.disabled,
39
20
  },
40
21
  },
41
- [`& .${classes.inputLabelError}.${classes.inputLabelFocused}`]: {
22
+ [`& .${InputLabel_1.inputLabelClasses.error}.${InputLabel_1.inputLabelClasses.focused}`]: {
42
23
  color: theme.palette.error.main,
43
24
  },
44
25
  // For variant: standard | filled
45
- [`& .${classes.inputUnderline}:not(.${classes.inputDisabled})`]: {
26
+ [`& .${Input_1.inputClasses.underline}:not(.${Input_1.inputClasses.disabled})`]: {
46
27
  [`&:hover:before`]: {
47
28
  borderColor: theme.palette.primary.main,
48
29
  },
49
- [`&.${classes.inputColorSecondary}:hover:before`]: {
30
+ [`&.${Input_1.inputClasses.colorSecondary}:hover:before`]: {
50
31
  borderColor: theme.palette.secondary.main,
51
32
  },
52
33
  },
53
34
  // For variant: outlined
54
- [`& .${classes.inputDisabled} .${classes.inputNotchedOutline}`]: {
35
+ [`& .${Input_1.inputClasses.disabled} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
55
36
  borderStyle: 'dotted',
56
37
  },
57
- [`& .${classes.inputError}.${classes.inputFocused} .${classes.inputNotchedOutline}`]: {
38
+ [`& .${Input_1.inputClasses.error}.${Input_1.inputClasses.focused} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
58
39
  borderColor: theme.palette.error.main,
59
40
  },
60
- [`& :not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
61
- [`&:hover .${classes.inputNotchedOutline}`]: {
41
+ [`&.${TextField_1.textFieldClasses.root} :not(.${Input_1.inputClasses.disabled}):not(.${Input_1.inputClasses.error})`]: {
42
+ [`&:hover .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
62
43
  borderColor: theme.palette.primary.main,
63
44
  },
64
- [`&.${classes.inputColorSecondary}:hover .${classes.inputNotchedOutline}`]: {
45
+ [`&.${Input_1.inputClasses.colorSecondary}:hover .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
65
46
  borderColor: theme.palette.secondary.main,
66
47
  },
67
48
  },
@@ -69,7 +50,14 @@ const StyledTextField = styles_1.styled((_a) => {
69
50
  const TextField = (props) => {
70
51
  var _a;
71
52
  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));
53
+ return (react_1.default.createElement(StyledTextField, Object.assign({ InputLabelProps: Object.assign(Object.assign({}, props.InputLabelProps), { classes: {
54
+ error: InputLabel_1.inputLabelClasses.error,
55
+ disabled: InputLabel_1.inputLabelClasses.disabled,
56
+ shrink: InputLabel_1.inputLabelClasses.shrink,
57
+ focused: InputLabel_1.inputLabelClasses.focused,
58
+ }, shrink: hasEndAdornment ? true : undefined }), InputProps: Object.assign(Object.assign({}, props.InputProps), { classes: Object.assign({ colorSecondary: Input_1.inputClasses.colorSecondary, disabled: Input_1.inputClasses.disabled, error: Input_1.inputClasses.error, focused: Input_1.inputClasses.focused }, ((props === null || props === void 0 ? void 0 : props.variant) === 'outlined'
59
+ ? { notchedOutline: OutlinedInput_1.outlinedInputClasses.notchedOutline }
60
+ : { underline: Input_1.inputClasses.underline })) }) }, props)));
73
61
  };
74
62
  exports.TextField = TextField;
75
63
  exports.default = exports.TextField;
@@ -3,27 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TopicFilter = void 0;
4
4
  const tslib_1 = require("tslib");
5
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"));
6
+ const styles_1 = require("@mui/material/styles");
7
+ const ArrowRightRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/ArrowRightRounded"));
8
+ const material_1 = require("@mui/material");
9
+ const Select_1 = tslib_1.__importDefault(require("../select/Select"));
9
10
  const SelectMenuItem_1 = tslib_1.__importDefault(require("../menu-item/SelectMenuItem"));
10
11
  // self-defined-configs
11
12
  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',
13
+ const StyledSelect = styles_1.styled(Select_1.default)(({ theme }) => ({
14
+ width: 220,
15
+ margin: theme.spacing(1),
27
16
  }));
28
17
  const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSelectedTopicIds, }) => {
29
18
  const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
@@ -82,12 +71,19 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
82
71
  setLayeredTopicList([topicTree]);
83
72
  }, [topicTree]);
84
73
  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 }));
74
+ return (react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
86
75
  }
87
- return (react_1.default.createElement(FiltersWrapper, null, layeredTopicList.map((layeredTopic, layerNumber) => {
76
+ return (react_1.default.createElement(material_1.Box, { sx: {
77
+ display: 'flex',
78
+ alignItems: 'center',
79
+ flexWrap: 'wrap',
80
+ } }, layeredTopicList.map((layeredTopic, layerNumber) => {
88
81
  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: {
82
+ return (react_1.default.createElement(material_1.Box, { sx: {
83
+ display: 'flex',
84
+ alignItems: 'center',
85
+ }, key: layeredTopic.id },
86
+ 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: {
91
87
  'data-testid': `layered-topic-${layerNumber}`,
92
88
  }, InputProps: {
93
89
  inputProps: {
@@ -111,9 +107,13 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
111
107
  });
112
108
  },
113
109
  } },
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' }))));
110
+ react_1.default.createElement(SelectMenuItem_1.default, { disabled: true }, PLACEHOLDER),
111
+ 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)))),
112
+ hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(ArrowRightRounded_1.default, { sx: (theme) => ({
113
+ margin: theme.spacing(-1, -1.5),
114
+ fontSize: theme.spacing(7),
115
+ color: '#444',
116
+ }), fontSize: 'large', "data-testid": 'topic-filter-arrow' }))));
117
117
  })));
118
118
  };
119
119
  exports.TopicFilter = TopicFilter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junyiacademy/ui-test",
3
- "version": "0.0.14",
3
+ "version": "1.5.0",
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",
@@ -17,9 +17,12 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@material-ui/core": "4.9.10",
21
- "@material-ui/icons": "4.9.1",
22
- "react": "16.13.1"
20
+ "@emotion/react": "11.7.1",
21
+ "@emotion/styled": "11.6.0",
22
+ "@mui/icons-material": "5.2.5",
23
+ "@mui/material": "5.2.7",
24
+ "@mui/styles": "5.2.3",
25
+ "react": "17.0.2"
23
26
  },
24
27
  "devDependencies": {
25
28
  "typescript": "~4.1.4"
package/.eslintrc.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
- "parserOptions": {
8
- "project": [
9
- "libs/ui/tsconfig.*?.json",
10
- "libs/ui/.storybook/tsconfig.json"
11
- ]
12
- },
13
- "rules": {}
14
- },
15
- {
16
- "files": ["*.ts", "*.tsx"],
17
- "rules": {}
18
- },
19
- {
20
- "files": ["*.js", "*.jsx"],
21
- "rules": {}
22
- }
23
- ]
24
- }
@@ -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
- }
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { AlertProps as MuiAlertProps } from '@material-ui/lab';
3
- export interface AlertProps extends MuiAlertProps {
4
- severity?: 'success' | 'info' | 'warning' | 'error';
5
- action?: boolean;
6
- buttonLink?: string;
7
- isNewTab?: boolean;
8
- cross?: boolean;
9
- handleCrossClick?: () => void;
10
- children?: React.ReactNode;
11
- }
12
- export declare const JuiAlert: ({ severity, action, buttonLink, isNewTab, cross, handleCrossClick, children, ...otherProps }: AlertProps) => JSX.Element;
13
- export default JuiAlert;
@@ -1,10 +0,0 @@
1
- export interface SelectionItemProps {
2
- handleInput: () => {};
3
- label1: string;
4
- value1: string;
5
- label2: string;
6
- value2: string;
7
- isError: boolean;
8
- }
9
- export declare function SelectionItem({ handleInput, label1, value1, label2, value2, isError, }: SelectionItemProps): JSX.Element;
10
- export default SelectionItem;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JuiAlert = 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 Alert_1 = tslib_1.__importDefault(require("@material-ui/lab/Alert"));
8
- const Button_1 = require("../button/Button");
9
- const CheckCircleOutline_1 = tslib_1.__importDefault(require("@material-ui/icons/CheckCircleOutline"));
10
- // self-defined-components
11
- const PREFIX = 'JuiAlert';
12
- const alertClasses = {
13
- alertRoot: `${PREFIX}-alertRoot`,
14
- alertMessage: `${PREFIX}-alertMessage`,
15
- };
16
- const buttonClasses = {
17
- buttonRoot: `${PREFIX}-buttonRoot`,
18
- };
19
- const StyledAlert = styles_1.styled((_a) => {
20
- var props = tslib_1.__rest(_a, []);
21
- return (react_1.default.createElement(Alert_1.default, Object.assign({ classes: {
22
- root: alertClasses.alertRoot,
23
- message: alertClasses.alertMessage,
24
- } }, props)));
25
- })({
26
- [`&.${alertClasses.alertRoot}`]: {
27
- height: '48px',
28
- padding: '0 16px',
29
- alignItems: 'center',
30
- },
31
- [`& .${alertClasses.alertMessage}`]: {
32
- display: 'flex',
33
- width: '100%',
34
- justifyContent: 'space-between',
35
- alignItems: 'center',
36
- },
37
- });
38
- const StyledButton = styles_1.styled((_a) => {
39
- var { severity: _severity } = _a, props = tslib_1.__rest(_a, ["severity"]);
40
- return (react_1.default.createElement(Button_1.Button, Object.assign({ classes: { root: buttonClasses.buttonRoot } }, props)));
41
- })(({ severity }) => ({
42
- [`&.${buttonClasses.buttonRoot}`]: {
43
- padding: '4px 10px',
44
- margin: '0 0 0 20px',
45
- minWidth: '74px',
46
- color: severity === 'info'
47
- ? 'rgb(13, 60, 97)'
48
- : severity === 'error'
49
- ? 'rgb(97, 26, 21)'
50
- : severity === 'success'
51
- ? 'rgb(30, 70, 32)'
52
- : 'rgb(102, 60, 0)',
53
- fontWeight: '700',
54
- },
55
- }));
56
- const JuiAlert = (_a) => {
57
- var { severity = 'info', action = false, buttonLink = '', isNewTab = true, cross = false, handleCrossClick, children } = _a, otherProps = tslib_1.__rest(_a, ["severity", "action", "buttonLink", "isNewTab", "cross", "handleCrossClick", "children"]);
58
- const handleButtonClick = () => {
59
- window.open(buttonLink, `${isNewTab ? '_blank' : '_self'}`);
60
- };
61
- const AlertChildren = () => {
62
- return (react_1.default.createElement(react_1.default.Fragment, null,
63
- children,
64
- action && (react_1.default.createElement(StyledButton, { severity: severity, size: 'small', onClick: handleButtonClick }, "ACTION"))));
65
- };
66
- if (cross) {
67
- return (react_1.default.createElement(StyledAlert, Object.assign({ severity: severity, iconMapping: { success: react_1.default.createElement(CheckCircleOutline_1.default, { fontSize: 'inherit' }) }, onClose: handleCrossClick }, otherProps), AlertChildren()));
68
- }
69
- return (react_1.default.createElement(StyledAlert, Object.assign({ severity: severity, iconMapping: { success: react_1.default.createElement(CheckCircleOutline_1.default, { fontSize: 'inherit' }) } }, otherProps), AlertChildren()));
70
- };
71
- exports.JuiAlert = JuiAlert;
72
- exports.default = exports.JuiAlert;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SelectionItem = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
6
- const core_1 = require("@material-ui/core");
7
- const Radio_1 = require("../radio/Radio");
8
- function SelectionItem({ handleInput, label1, value1, label2, value2, isError, }) {
9
- return (react_1.default.createElement(react_1.default.Fragment, null,
10
- react_1.default.createElement(core_1.RadioGroup, { onChange: handleInput },
11
- react_1.default.createElement(Radio_1.Radio, { label: label1, value: value1 }),
12
- react_1.default.createElement(Radio_1.Radio, { label: label2, value: value2 })),
13
- isError && react_1.default.createElement(core_1.FormHelperText, null, "\u8ACB\u9078\u64C7")));
14
- }
15
- exports.SelectionItem = SelectionItem;
16
- exports.default = SelectionItem;
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- displayName: 'ui',
3
- preset: '../../jest.preset.js',
4
- transform: {
5
- '^.+\\.[tj]sx?$': 'babel-jest',
6
- },
7
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
8
- coverageDirectory: '../../coverage/libs/ui',
9
- }
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,33 +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 | 'auto'
28
- paperMaxHeight?: number | 'auto'
29
- error?: boolean
30
- hasLabel?: boolean
31
- hasShrink?: boolean
32
- disabled?: boolean
33
- }
@@ -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