@junyiacademy/ui-test 1.4.0 → 1.5.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.
- package/declarations/libs/ui/src/interfaces/index.d.ts +3 -3
- package/declarations/libs/ui/src/lib/button/Button.d.ts +1 -1
- package/declarations/libs/ui/src/lib/button-group/ButtonGroup.d.ts +1 -1
- package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +2 -3
- package/declarations/libs/ui/src/lib/radio/Radio.d.ts +1 -1
- package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +1 -1
- package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +1 -1
- package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +1 -1
- package/dist/libs/ui/src/lib/button/Button.js +15 -24
- package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +10 -19
- package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +8 -16
- package/dist/libs/ui/src/lib/radio/Radio.js +15 -26
- package/dist/libs/ui/src/lib/select/OutlinedSelect.js +44 -84
- package/dist/libs/ui/src/lib/select/StandardSelect.js +38 -69
- package/dist/libs/ui/src/lib/text-field/TextField.js +26 -38
- package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +24 -25
- package/package.json +6 -3
- package/.eslintrc.json +0 -24
- package/.storybook/main.js +0 -9
- package/.storybook/preview.js +0 -10
- package/.storybook/tsconfig.json +0 -14
- package/.storybook/webpack.config.js +0 -84
- package/jest.config.js +0 -9
- package/src/index.ts +0 -7
- package/src/interfaces/index.tsx +0 -34
- package/src/lib/button/Button.stories.tsx +0 -50
- package/src/lib/button/Button.tsx +0 -85
- package/src/lib/button-group/ButtonGroup.stories.tsx +0 -59
- package/src/lib/button-group/ButtonGroup.tsx +0 -37
- package/src/lib/menu-item/SelectMenuItem.stories.tsx +0 -44
- package/src/lib/menu-item/SelectMenuItem.tsx +0 -48
- package/src/lib/radio/Radio.stories.tsx +0 -154
- package/src/lib/radio/Radio.tsx +0 -93
- package/src/lib/select/OutlinedSelect.tsx +0 -220
- package/src/lib/select/Select.stories.tsx +0 -306
- package/src/lib/select/Select.tsx +0 -13
- package/src/lib/select/StandardSelect.tsx +0 -178
- package/src/lib/text-field/TextField.stories.tsx +0 -160
- package/src/lib/text-field/TextField.tsx +0 -93
- package/src/lib/topic-filter/TopicFilter.stories.tsx +0 -83
- package/src/lib/topic-filter/TopicFilter.tsx +0 -209
- package/src/styles/theme.ts +0 -60
- package/src/utils/topicTree.ts +0 -197
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -22
- 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
|
|
7
|
-
const
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
[`&.${
|
|
18
|
+
[`&.${InputLabel_1.inputLabelClasses.disabled}`]: {
|
|
38
19
|
color: theme.palette.text.disabled,
|
|
39
20
|
},
|
|
40
21
|
},
|
|
41
|
-
[`& .${
|
|
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
|
-
[`& .${
|
|
26
|
+
[`& .${Input_1.inputClasses.underline}:not(.${Input_1.inputClasses.disabled})`]: {
|
|
46
27
|
[`&:hover:before`]: {
|
|
47
28
|
borderColor: theme.palette.primary.main,
|
|
48
29
|
},
|
|
49
|
-
[`&.${
|
|
30
|
+
[`&.${Input_1.inputClasses.colorSecondary}:hover:before`]: {
|
|
50
31
|
borderColor: theme.palette.secondary.main,
|
|
51
32
|
},
|
|
52
33
|
},
|
|
53
34
|
// For variant: outlined
|
|
54
|
-
[`& .${
|
|
35
|
+
[`& .${Input_1.inputClasses.disabled} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
55
36
|
borderStyle: 'dotted',
|
|
56
37
|
},
|
|
57
|
-
[`& .${
|
|
38
|
+
[`& .${Input_1.inputClasses.error}.${Input_1.inputClasses.focused} .${OutlinedInput_1.outlinedInputClasses.notchedOutline}`]: {
|
|
58
39
|
borderColor: theme.palette.error.main,
|
|
59
40
|
},
|
|
60
|
-
[
|
|
61
|
-
[`&:hover .${
|
|
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
|
-
[`&.${
|
|
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({
|
|
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,30 +3,18 @@ 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
|
|
7
|
-
const ArrowRightRounded_1 = tslib_1.__importDefault(require("@
|
|
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");
|
|
8
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
const theme = styles_1.useTheme();
|
|
30
18
|
const [selectedTopicIds, setSelectedTopicIds] = react_1.useState([]);
|
|
31
19
|
const [layeredTopicList, setLayeredTopicList] = react_1.useState([]);
|
|
32
20
|
const [isFocusedList, setIsFocusedList] = react_1.useState([]);
|
|
@@ -83,12 +71,19 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
|
|
|
83
71
|
setLayeredTopicList([topicTree]);
|
|
84
72
|
}, [topicTree]);
|
|
85
73
|
if (layeredTopicList.length === 0) {
|
|
86
|
-
return (react_1.default.createElement(
|
|
74
|
+
return (react_1.default.createElement(StyledSelect, { variant: 'outlined', size: 'small', placeholder: '\u8F09\u5165\u8CC7\u6599\u4E2D...', disabled: true }));
|
|
87
75
|
}
|
|
88
|
-
return (react_1.default.createElement(
|
|
76
|
+
return (react_1.default.createElement(material_1.Box, { sx: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
flexWrap: 'wrap',
|
|
80
|
+
} }, layeredTopicList.map((layeredTopic, layerNumber) => {
|
|
89
81
|
const hasLabel = isFocusedList[layerNumber] || !selectedTopicIds[layerNumber];
|
|
90
|
-
return (react_1.default.createElement(
|
|
91
|
-
|
|
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: {
|
|
92
87
|
'data-testid': `layered-topic-${layerNumber}`,
|
|
93
88
|
}, InputProps: {
|
|
94
89
|
inputProps: {
|
|
@@ -112,9 +107,13 @@ const TopicFilter = ({ topicTree, onTopicSelected, isLastLayer, hasArrow, initSe
|
|
|
112
107
|
});
|
|
113
108
|
},
|
|
114
109
|
} },
|
|
115
|
-
react_1.default.createElement(SelectMenuItem_1.default, {
|
|
116
|
-
layeredTopic.childTopics.map((childTopic) => (react_1.default.createElement(SelectMenuItem_1.default, {
|
|
117
|
-
hasArrow && layerNumber !== layeredTopicList.length - 1 && (react_1.default.createElement(
|
|
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' }))));
|
|
118
117
|
})));
|
|
119
118
|
};
|
|
120
119
|
exports.TopicFilter = TopicFilter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junyiacademy/ui-test",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
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",
|
|
22
25
|
"react": "17.0.2"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
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
|
-
}
|
package/.storybook/main.js
DELETED
|
@@ -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
|
package/.storybook/preview.js
DELETED
package/.storybook/tsconfig.json
DELETED
|
@@ -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/jest.config.js
DELETED
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'
|
package/src/interfaces/index.tsx
DELETED
|
@@ -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
|