@junyiacademy/ui-test 0.0.11 → 1.4.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.
- package/declarations/libs/ui/src/index.d.ts +2 -3
- package/declarations/libs/ui/src/interfaces/index.d.ts +19 -0
- package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +2 -2
- package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +2 -19
- package/declarations/libs/ui/src/lib/select/Select.d.ts +3 -0
- package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +2 -15
- package/declarations/libs/ui/src/lib/topic-filter/TopicFilter.d.ts +13 -0
- package/dist/libs/ui/src/index.js +4 -6
- package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +4 -1
- package/dist/libs/ui/src/lib/select/OutlinedSelect.js +30 -14
- package/dist/libs/ui/src/lib/select/Select.js +16 -0
- package/dist/libs/ui/src/lib/select/StandardSelect.js +13 -5
- package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +121 -0
- package/package.json +2 -2
- package/src/index.ts +2 -3
- package/src/interfaces/index.tsx +26 -0
- package/src/lib/menu-item/SelectMenuItem.tsx +6 -3
- package/src/lib/select/OutlinedSelect.tsx +38 -37
- package/src/lib/select/{StandardSelect.stories.tsx → Select.stories.tsx} +119 -34
- package/src/lib/select/Select.tsx +13 -0
- package/src/lib/select/StandardSelect.tsx +22 -25
- package/src/lib/{TopicFilter.stories.tsx → topic-filter/TopicFilter.stories.tsx} +1 -1
- package/src/lib/{TopicFilter.tsx → topic-filter/TopicFilter.tsx} +14 -9
- package/declarations/libs/ui/src/lib/alert/Alert.d.ts +0 -13
- package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +0 -10
- package/dist/libs/ui/src/lib/alert/Alert.js +0 -72
- package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +0 -16
- package/src/lib/TopicFilter.spec.tsx +0 -10
- package/src/lib/menu-item/SelectMenuItem.spec.tsx +0 -10
- package/src/lib/select/OutlinedSelect.spec.tsx +0 -10
- package/src/lib/select/OutlinedSelect.stories.tsx +0 -238
|
@@ -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;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
|
|
3
|
-
import TopicFilter from './TopicFilter'
|
|
4
|
-
|
|
5
|
-
describe('TopicFilter', () => {
|
|
6
|
-
it('should render successfully', () => {
|
|
7
|
-
const { baseElement } = render(<TopicFilter />)
|
|
8
|
-
expect(baseElement).toBeTruthy()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
|
|
3
|
-
import SelectMenuItem from './SelectMenuItem'
|
|
4
|
-
|
|
5
|
-
describe('SelectMenuItem', () => {
|
|
6
|
-
it('should render successfully', () => {
|
|
7
|
-
const { baseElement } = render(<SelectMenuItem />)
|
|
8
|
-
expect(baseElement).toBeTruthy()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
|
|
3
|
-
import OutlinedSelect from './OutlinedSelect'
|
|
4
|
-
|
|
5
|
-
describe('OutlinedSelect', () => {
|
|
6
|
-
it('should render successfully', () => {
|
|
7
|
-
const { baseElement } = render(<OutlinedSelect />)
|
|
8
|
-
expect(baseElement).toBeTruthy()
|
|
9
|
-
})
|
|
10
|
-
})
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { Story, Meta } from '@storybook/react'
|
|
3
|
-
import { Theme, styled } from '@material-ui/core/styles'
|
|
4
|
-
import { InputAdornment, OutlinedInputProps } from '@material-ui/core'
|
|
5
|
-
import { Visibility } from '@material-ui/icons'
|
|
6
|
-
import OutlinedSelect, { OutlinedSelectProps } from './OutlinedSelect'
|
|
7
|
-
import SelectMenuItem from '../menu-item/SelectMenuItem'
|
|
8
|
-
|
|
9
|
-
const PLACEHOLDER = '請選擇'
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
component: OutlinedSelect,
|
|
13
|
-
title: 'OutlinedSelect',
|
|
14
|
-
argTypes: {
|
|
15
|
-
color: {
|
|
16
|
-
type: { name: 'string', required: false },
|
|
17
|
-
description:
|
|
18
|
-
'The color of the component. It supports those theme colors that make sense for this component.',
|
|
19
|
-
table: {
|
|
20
|
-
type: { summary: 'primary | secondary' },
|
|
21
|
-
defaultValue: { summary: 'primary' },
|
|
22
|
-
},
|
|
23
|
-
options: ['primary', 'secondary'],
|
|
24
|
-
control: { type: 'radio' },
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
type: { name: 'string', required: false },
|
|
28
|
-
description: `Adjust size`,
|
|
29
|
-
table: {
|
|
30
|
-
type: { summary: 'medium | small' },
|
|
31
|
-
defaultValue: { summary: 'medium' },
|
|
32
|
-
},
|
|
33
|
-
options: ['small', 'medium'],
|
|
34
|
-
control: { type: 'radio' },
|
|
35
|
-
},
|
|
36
|
-
width: {
|
|
37
|
-
type: { name: 'number', required: false },
|
|
38
|
-
description: `Adjust width`,
|
|
39
|
-
table: {
|
|
40
|
-
type: { summary: 'number' },
|
|
41
|
-
defaultValue: { summary: 'auto' },
|
|
42
|
-
},
|
|
43
|
-
control: { type: 'number' },
|
|
44
|
-
},
|
|
45
|
-
paperMaxHeight: {
|
|
46
|
-
type: { name: 'number', required: false },
|
|
47
|
-
description: `Adjust select menu paper max height.`,
|
|
48
|
-
table: {
|
|
49
|
-
type: { summary: 'number' },
|
|
50
|
-
defaultValue: { summary: 'auto' },
|
|
51
|
-
},
|
|
52
|
-
control: { type: 'number' },
|
|
53
|
-
},
|
|
54
|
-
hasLabel: {
|
|
55
|
-
type: { name: 'boolean', required: false },
|
|
56
|
-
description: 'If true, the label is displayed.',
|
|
57
|
-
table: {
|
|
58
|
-
type: { summary: 'boolean' },
|
|
59
|
-
defaultValue: { summary: true },
|
|
60
|
-
},
|
|
61
|
-
control: { type: 'boolean' },
|
|
62
|
-
},
|
|
63
|
-
hasShrink: {
|
|
64
|
-
type: { name: 'boolean', required: false },
|
|
65
|
-
description: 'If true, the label is displayed and shrunk.',
|
|
66
|
-
table: {
|
|
67
|
-
type: { summary: 'boolean' },
|
|
68
|
-
defaultValue: { summary: false },
|
|
69
|
-
},
|
|
70
|
-
control: { type: 'boolean' },
|
|
71
|
-
},
|
|
72
|
-
placeholder: {
|
|
73
|
-
type: { name: 'string', required: true },
|
|
74
|
-
description: `The label title`,
|
|
75
|
-
table: {
|
|
76
|
-
type: { summary: 'string' },
|
|
77
|
-
defaultValue: { summary: '請選擇' },
|
|
78
|
-
},
|
|
79
|
-
control: { type: 'text' },
|
|
80
|
-
},
|
|
81
|
-
value: {
|
|
82
|
-
type: { name: 'any', required: false },
|
|
83
|
-
description: `The input value. Providing an empty string will select no options. This prop is required when the native prop is false (default). Set to an empty string '' if you don't want any of the available options to be selected.
|
|
84
|
-
If the value is an object it must have reference equality with the option in order to be selected. If the value is not an object, the string representation must match with the string representation of the option in order to be selected.`,
|
|
85
|
-
table: {
|
|
86
|
-
type: { summary: 'any' },
|
|
87
|
-
defaultValue: { summary: '' },
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
disabled: {
|
|
91
|
-
type: { name: 'boolean', required: false },
|
|
92
|
-
description: 'If true, the input element will be disabled.',
|
|
93
|
-
table: {
|
|
94
|
-
type: { summary: 'boolean' },
|
|
95
|
-
defaultValue: { summary: false },
|
|
96
|
-
},
|
|
97
|
-
control: { type: 'boolean' },
|
|
98
|
-
},
|
|
99
|
-
error: {
|
|
100
|
-
type: { name: 'boolean', required: false },
|
|
101
|
-
description: 'If true, the label will be displayed in an error state.',
|
|
102
|
-
table: {
|
|
103
|
-
type: { summary: 'boolean' },
|
|
104
|
-
defaultValue: { summary: false },
|
|
105
|
-
},
|
|
106
|
-
control: { type: 'boolean' },
|
|
107
|
-
},
|
|
108
|
-
helperText: {
|
|
109
|
-
type: { name: 'string', required: true },
|
|
110
|
-
description: `Display the helper text.`,
|
|
111
|
-
table: {
|
|
112
|
-
type: { summary: 'string' },
|
|
113
|
-
defaultValue: { summary: '' },
|
|
114
|
-
},
|
|
115
|
-
control: { type: 'text' },
|
|
116
|
-
},
|
|
117
|
-
SelectProps: {
|
|
118
|
-
type: { name: 'any', required: false },
|
|
119
|
-
description: 'Attributes applied to inner Select element.',
|
|
120
|
-
table: {
|
|
121
|
-
type: { summary: 'any' },
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
OutlinedInputProps: {
|
|
125
|
-
type: { name: 'any', required: false },
|
|
126
|
-
description: 'Attributes applied to to inner OutlinedInput element.',
|
|
127
|
-
table: {
|
|
128
|
-
type: { summary: 'any' },
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
} as Meta
|
|
133
|
-
|
|
134
|
-
const PREFIX = 'JuiOutlinedSelect'
|
|
135
|
-
|
|
136
|
-
const classes = {
|
|
137
|
-
outlineInputAdornmentRoot: `${PREFIX}-outlineInputAdornmentRoot`,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface StyledInputAdornmentProps {
|
|
141
|
-
disabled: boolean
|
|
142
|
-
theme?: Theme
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
|
|
146
|
-
<InputAdornment
|
|
147
|
-
classes={{
|
|
148
|
-
root: classes.outlineInputAdornmentRoot,
|
|
149
|
-
}}
|
|
150
|
-
{...props}
|
|
151
|
-
/>
|
|
152
|
-
))(({ disabled, theme }: StyledInputAdornmentProps) => ({
|
|
153
|
-
[`&.${classes.outlineInputAdornmentRoot}`]: {
|
|
154
|
-
color: disabled
|
|
155
|
-
? theme.palette.action.disabled
|
|
156
|
-
: theme.palette.action.active,
|
|
157
|
-
},
|
|
158
|
-
}))
|
|
159
|
-
|
|
160
|
-
interface OutlinedSelectWithMenuProps {
|
|
161
|
-
startAdornment?: React.ReactNode
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const OutlinedSelectWithMenu = ({
|
|
165
|
-
startAdornment,
|
|
166
|
-
...props
|
|
167
|
-
}: OutlinedSelectProps & OutlinedSelectWithMenuProps) => {
|
|
168
|
-
const [item, setItem] = useState<string>('')
|
|
169
|
-
|
|
170
|
-
const handleChange = (event) => {
|
|
171
|
-
setItem(event.target.value)
|
|
172
|
-
}
|
|
173
|
-
return (
|
|
174
|
-
<OutlinedSelect
|
|
175
|
-
OutlinedInputProps={{
|
|
176
|
-
onChange: (e) => {
|
|
177
|
-
handleChange(e)
|
|
178
|
-
},
|
|
179
|
-
startAdornment,
|
|
180
|
-
}}
|
|
181
|
-
value={item}
|
|
182
|
-
{...props}
|
|
183
|
-
>
|
|
184
|
-
<SelectMenuItem width={220} value='' disabled>
|
|
185
|
-
{PLACEHOLDER}
|
|
186
|
-
</SelectMenuItem>
|
|
187
|
-
<SelectMenuItem width={220} value='Test'>
|
|
188
|
-
This is a select menu item
|
|
189
|
-
</SelectMenuItem>
|
|
190
|
-
<SelectMenuItem width={220} value='Example'>
|
|
191
|
-
Example
|
|
192
|
-
</SelectMenuItem>
|
|
193
|
-
</OutlinedSelect>
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const ValueOnlyStory: Story<OutlinedSelectProps> = (args) => (
|
|
198
|
-
<OutlinedSelectWithMenu {...args} />
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
export const ValueOnly = ValueOnlyStory.bind({})
|
|
202
|
-
|
|
203
|
-
ValueOnly.args = {
|
|
204
|
-
color: 'primary',
|
|
205
|
-
size: 'medium',
|
|
206
|
-
width: 220,
|
|
207
|
-
paperMaxHeight: 412,
|
|
208
|
-
hasLabel: true,
|
|
209
|
-
placeholder: PLACEHOLDER,
|
|
210
|
-
helperText: 'test',
|
|
211
|
-
disabled: false,
|
|
212
|
-
SelectProps: {},
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const WithPrefixStory: Story<OutlinedSelectProps> = (args) => (
|
|
216
|
-
<OutlinedSelectWithMenu
|
|
217
|
-
startAdornment={
|
|
218
|
-
<StyledInputAdornment position='start' disabled={args.disabled}>
|
|
219
|
-
<Visibility />
|
|
220
|
-
</StyledInputAdornment>
|
|
221
|
-
}
|
|
222
|
-
{...args}
|
|
223
|
-
/>
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
export const WithPrefix = WithPrefixStory.bind({})
|
|
227
|
-
|
|
228
|
-
WithPrefix.args = {
|
|
229
|
-
color: 'primary',
|
|
230
|
-
size: 'medium',
|
|
231
|
-
width: 220,
|
|
232
|
-
paperMaxHeight: 412,
|
|
233
|
-
hasLabel: true,
|
|
234
|
-
placeholder: PLACEHOLDER,
|
|
235
|
-
helperText: 'test',
|
|
236
|
-
disabled: false,
|
|
237
|
-
SelectProps: {},
|
|
238
|
-
}
|