@junyiacademy/ui-test 0.0.13 → 1.4.2

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 (45) hide show
  1. package/declarations/libs/ui/src/interfaces/index.d.ts +2 -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/.DS_Store +0 -0
  6. package/dist/libs/ui/.DS_Store +0 -0
  7. package/dist/libs/ui/src/.DS_Store +0 -0
  8. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +7 -8
  9. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +13 -16
  10. package/dist/libs/ui/src/lib/select/StandardSelect.js +5 -18
  11. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +9 -5
  12. package/package.json +2 -2
  13. package/.eslintrc.json +0 -24
  14. package/.storybook/main.js +0 -9
  15. package/.storybook/preview.js +0 -10
  16. package/.storybook/tsconfig.json +0 -14
  17. package/.storybook/webpack.config.js +0 -84
  18. package/declarations/libs/ui/src/lib/alert/Alert.d.ts +0 -13
  19. package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +0 -10
  20. package/dist/libs/ui/src/lib/alert/Alert.js +0 -72
  21. package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +0 -16
  22. package/jest.config.js +0 -9
  23. package/src/index.ts +0 -7
  24. package/src/interfaces/index.tsx +0 -33
  25. package/src/lib/button/Button.stories.tsx +0 -50
  26. package/src/lib/button/Button.tsx +0 -85
  27. package/src/lib/button-group/ButtonGroup.stories.tsx +0 -59
  28. package/src/lib/button-group/ButtonGroup.tsx +0 -37
  29. package/src/lib/menu-item/SelectMenuItem.stories.tsx +0 -44
  30. package/src/lib/menu-item/SelectMenuItem.tsx +0 -45
  31. package/src/lib/radio/Radio.stories.tsx +0 -154
  32. package/src/lib/radio/Radio.tsx +0 -93
  33. package/src/lib/select/OutlinedSelect.tsx +0 -216
  34. package/src/lib/select/Select.stories.tsx +0 -421
  35. package/src/lib/select/Select.tsx +0 -13
  36. package/src/lib/select/StandardSelect.tsx +0 -179
  37. package/src/lib/text-field/TextField.stories.tsx +0 -160
  38. package/src/lib/text-field/TextField.tsx +0 -93
  39. package/src/lib/topic-filter/TopicFilter.stories.tsx +0 -83
  40. package/src/lib/topic-filter/TopicFilter.tsx +0 -204
  41. package/src/styles/theme.ts +0 -60
  42. package/src/utils/topicTree.ts +0 -197
  43. package/tsconfig.json +0 -16
  44. package/tsconfig.lib.json +0 -22
  45. package/tsconfig.spec.json +0 -15
@@ -1,179 +0,0 @@
1
- import React from 'react'
2
- import { Theme, styled } from '@material-ui/core/styles'
3
- import {
4
- InputLabel,
5
- FormControl,
6
- Select,
7
- Input,
8
- FormHelperText,
9
- } from '@material-ui/core'
10
- import { SelectProps } from '../../interfaces'
11
-
12
- // self-defined-components
13
- const PREFIX = 'JuiStandardSelect'
14
-
15
- const classes = {
16
- inputLabelFocused: `${PREFIX}-inputLabelFocused`,
17
- inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
18
- inputLabelError: `${PREFIX}-inputLabelError`,
19
- inputRoot: `${PREFIX}-inputRoot`,
20
- inputFocused: `${PREFIX}-inputFocused`,
21
- inputInput: `${PREFIX}-input`,
22
- inputUnderline: `${PREFIX}-inputUnderline`,
23
- inputError: `${PREFIX}-inputError`,
24
- inputDisabled: `${PREFIX}-inputDisabled`,
25
- inputAdornmentRoot: `${PREFIX}-inputAdornmentRoot`,
26
- selectPaper: `${PREFIX}-menuPaper`,
27
- selectDisabled: `${PREFIX}-selectDisabled`,
28
- }
29
-
30
- interface StyledFormControlProps {
31
- color: 'primary' | 'secondary'
32
- width: number | 'auto'
33
- theme?: Theme
34
- }
35
-
36
- const StyledFormControl = styled(({ width: _width, ...props }) => (
37
- <FormControl {...props} />
38
- ))(({ width, theme }: StyledFormControlProps) => ({
39
- width,
40
- margin: theme.spacing(0, 4, 4, 4),
41
- }))
42
-
43
- interface StyledInputLabelProps {
44
- color: 'primary' | 'secondary'
45
- theme?: Theme
46
- }
47
-
48
- const StyledInputLabel = styled(({ color: _color, ...props }) => (
49
- <InputLabel
50
- classes={{
51
- focused: classes.inputLabelFocused,
52
- error: classes.inputLabelError,
53
- }}
54
- {...props}
55
- />
56
- ))(({ color, theme }: StyledInputLabelProps) => ({
57
- color: theme.palette.text.disabled,
58
- margin: theme.spacing(0, 10, 1.5, 0),
59
- [`&.${classes.inputLabelFocused}`]: {
60
- color: theme.palette[color].main,
61
- },
62
- [`&.${classes.inputLabelError}`]: {
63
- color: theme.palette.error.main,
64
- },
65
- }))
66
-
67
- interface StyledSelectProps {
68
- paperMaxHeight: number | 'auto'
69
- hasAdornment: boolean
70
- }
71
-
72
- const StyledSelect = styled(
73
- ({
74
- paperMaxHeight: _selectPaperHeight,
75
- hasAdornment: _hasAdornment,
76
- className,
77
- ...props
78
- }) => (
79
- <Select
80
- MenuProps={{
81
- classes: { paper: className },
82
- transformOrigin: {
83
- vertical: 'top',
84
- horizontal: 'left',
85
- },
86
- getContentAnchorEl: null,
87
- }}
88
- {...props}
89
- />
90
- )
91
- )(({ hasAdornment, paperMaxHeight }: StyledSelectProps) => ({
92
- '&&': {
93
- maxHeight: paperMaxHeight,
94
- left: hasAdornment ? '48px !important' : '70px',
95
- },
96
- }))
97
-
98
- interface StyledInputProps {
99
- color: 'primary' | 'secondary'
100
- theme: Theme
101
- }
102
-
103
- const StyledInput = styled(({ color: _color, ...props }) => (
104
- <Input
105
- classes={{
106
- root: classes.inputRoot,
107
- focused: classes.inputFocused,
108
- input: classes.inputInput,
109
- disabled: classes.inputDisabled,
110
- underline: classes.inputUnderline,
111
- error: classes.inputError,
112
- }}
113
- {...props}
114
- />
115
- ))(({ color, theme }: StyledInputProps) => ({
116
- color: theme.palette.text.primary,
117
- [`&.${classes.inputRoot}.${classes.inputFocused}`]: {
118
- backgroundColor: theme.palette.action.selected,
119
- },
120
- [`& .${classes.inputInput}`]: {
121
- ['&:focus']: {
122
- background: 'rgba(0,0,0,0)',
123
- },
124
- },
125
- [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
126
- [`&:after,&:hover:before`]: {
127
- borderBottomColor: theme.palette[color].main,
128
- },
129
- },
130
- [`&.${classes.inputUnderline}.${classes.inputError}:not(.${classes.inputDisabled})`]: {
131
- [`&:after,&:hover:before`]: {
132
- borderBottomColor: theme.palette.error.main,
133
- },
134
- },
135
- }))
136
-
137
- export function StandardSelect({
138
- placeholder,
139
- helperText,
140
- InputProps,
141
- SelectProps,
142
- children,
143
- color = 'primary',
144
- size = 'medium',
145
- width = 'auto',
146
- paperMaxHeight = 'auto',
147
- error = false,
148
- hasShrink = false,
149
- value = '',
150
- disabled = false,
151
- }: SelectProps) {
152
- const hasAdornment = !!InputProps?.startAdornment
153
- const hasHelperText = !!helperText
154
- return (
155
- <StyledFormControl
156
- color={color}
157
- size={size}
158
- width={width}
159
- disabled={disabled}
160
- error={error}
161
- >
162
- <StyledInputLabel color={color} shrink={hasShrink ? true : undefined}>
163
- {placeholder}
164
- </StyledInputLabel>
165
- <StyledSelect
166
- value={value}
167
- paperMaxHeight={paperMaxHeight}
168
- hasAdornment={hasAdornment}
169
- input={<StyledInput color={color} {...InputProps} />}
170
- {...SelectProps}
171
- >
172
- {children}
173
- </StyledSelect>
174
- {hasHelperText && <FormHelperText>{helperText}</FormHelperText>}
175
- </StyledFormControl>
176
- )
177
- }
178
-
179
- export default StandardSelect
@@ -1,160 +0,0 @@
1
- import React, { useEffect } from 'react'
2
- import { Story, Meta } from '@storybook/react'
3
- import { InputAdornment, TextFieldProps } from '@material-ui/core'
4
- import { Visibility } from '@material-ui/icons'
5
- import { TextField } from './TextField'
6
-
7
- export default {
8
- component: TextField,
9
- title: 'TextFiled',
10
- argTypes: {
11
- color: {
12
- type: { name: 'string', required: false },
13
- description:
14
- 'The color of the component. It supports those theme colors that make sense for this component.',
15
- table: {
16
- type: { summary: 'primary | secondary' },
17
- defaultValue: { summary: 'primary' },
18
- },
19
- options: ['primary', 'secondary'],
20
- control: { type: 'radio' },
21
- },
22
- variant: {
23
- type: { name: 'string', required: false },
24
- description: 'The variant to use.',
25
- table: {
26
- type: { summary: 'standard | filled | outlined' },
27
- defaultValue: { summary: 'standard' },
28
- },
29
- options: ['standard', 'filled', 'outlined'],
30
- control: { type: 'radio' },
31
- },
32
- size: {
33
- type: { name: 'string', required: false },
34
- description: 'The size of the text field.',
35
- table: {
36
- type: { summary: 'small | medium' },
37
- defaultValue: { summary: 'small' },
38
- },
39
- options: ['small', 'medium'],
40
- control: { type: 'radio' },
41
- },
42
- disabled: {
43
- type: { name: 'boolean', required: false },
44
- description: 'If true, the input element will be disabled.',
45
- table: {
46
- type: { summary: 'boolean' },
47
- defaultValue: { summary: false },
48
- },
49
- control: { type: 'boolean' },
50
- },
51
- error: {
52
- type: { name: 'boolean', required: false },
53
- description: 'If true, the label will be displayed in an error state.',
54
- table: {
55
- type: { summary: 'boolean' },
56
- defaultValue: { summary: false },
57
- },
58
- control: { type: 'boolean' },
59
- },
60
- label: {
61
- type: { name: 'string', required: false },
62
- description: 'The label content.',
63
- },
64
- },
65
- } as Meta
66
-
67
- const ValueOnlyStory: Story<TextFieldProps> = (args) => <TextField {...args} />
68
-
69
- export const ValueOnly = ValueOnlyStory.bind({})
70
-
71
- ValueOnly.args = {
72
- variant: 'standard',
73
- color: 'primary',
74
- disabled: false,
75
- error: false,
76
- size: 'small',
77
- label: 'Which UI?',
78
- }
79
-
80
- const TextFieldWithError = (props: TextFieldProps) => {
81
- const [value, setValue] = React.useState('')
82
- const [isError, setIsError] = React.useState(false)
83
-
84
- const handleChange = (event) => {
85
- setValue(event.target.value)
86
- }
87
-
88
- useEffect(() => {
89
- if (value.length > 3) {
90
- setIsError(true)
91
- return
92
- }
93
- setIsError(false)
94
- return
95
- }, [value])
96
-
97
- return <TextField error={isError} onChange={handleChange} {...props} />
98
- }
99
-
100
- const WithErrorStory: Story<TextFieldProps> = (args) => (
101
- <TextFieldWithError {...args} />
102
- )
103
-
104
- export const WithError = WithErrorStory.bind({})
105
-
106
- WithError.args = {
107
- variant: 'standard',
108
- color: 'primary',
109
- disabled: false,
110
- size: 'small',
111
- label: 'No more than 3 words',
112
- }
113
-
114
- const WithSuffixStory: Story<TextFieldProps> = (args) => (
115
- <TextField
116
- {...args}
117
- InputProps={{
118
- endAdornment: (
119
- <InputAdornment position='end'>
120
- <Visibility />
121
- </InputAdornment>
122
- ),
123
- }}
124
- />
125
- )
126
-
127
- export const WithSuffix = WithSuffixStory.bind({})
128
-
129
- WithSuffix.args = {
130
- variant: 'standard',
131
- color: 'primary',
132
- disabled: false,
133
- error: false,
134
- size: 'small',
135
- label: 'Which UI?',
136
- }
137
-
138
- const WithPrefixStory: Story<TextFieldProps> = (args) => (
139
- <TextField
140
- {...args}
141
- InputProps={{
142
- startAdornment: (
143
- <InputAdornment disableTypography position='start'>
144
- Kg
145
- </InputAdornment>
146
- ),
147
- }}
148
- />
149
- )
150
-
151
- export const WithPrefix = WithPrefixStory.bind({})
152
-
153
- WithPrefix.args = {
154
- variant: 'standard',
155
- color: 'primary',
156
- disabled: false,
157
- error: false,
158
- size: 'small',
159
- label: 'Which UI?',
160
- }
@@ -1,93 +0,0 @@
1
- import React from 'react'
2
- import { styled } from '@material-ui/core/styles'
3
- import { TextField as MuiTextField, TextFieldProps } from '@material-ui/core'
4
-
5
- // self-defined-components
6
- const PREFIX = 'JuiTextField'
7
-
8
- const classes = {
9
- inputLabelError: `${PREFIX}-inputLabel-error`,
10
- inputLabelDisabled: `${PREFIX}-inputLabel-disabled`,
11
- inputLabelShrink: `${PREFIX}-inputLabel-shrink`,
12
- inputLabelFocused: `${PREFIX}-inputLabel-focused`,
13
- inputNotchedOutline: `${PREFIX}-input-notchedOutline`,
14
- inputUnderline: `${PREFIX}-input-underline`,
15
- inputColorSecondary: `${PREFIX}-input-colorSecondary`,
16
- inputDisabled: `${PREFIX}-input-disabled`,
17
- inputError: `${PREFIX}-input-error`,
18
- inputFocused: `${PREFIX}-input-focused`,
19
- }
20
-
21
- const StyledTextField = styled(
22
- ({ hasEndAdornment, InputLabelProps, InputProps, ...otherProps }) => (
23
- <MuiTextField
24
- InputLabelProps={{
25
- ...InputLabelProps,
26
- classes: {
27
- error: classes.inputLabelError,
28
- disabled: classes.inputLabelDisabled,
29
- shrink: classes.inputLabelShrink,
30
- focused: classes.inputLabelFocused,
31
- },
32
- shrink: hasEndAdornment ? true : undefined,
33
- }}
34
- InputProps={{
35
- ...InputProps,
36
- classes: {
37
- colorSecondary: classes.inputColorSecondary,
38
- disabled: classes.inputDisabled,
39
- error: classes.inputError,
40
- focused: classes.inputFocused,
41
- ...(otherProps?.variant === 'outlined'
42
- ? { notchedOutline: classes.inputNotchedOutline }
43
- : { underline: classes.inputUnderline }),
44
- },
45
- }}
46
- {...otherProps}
47
- />
48
- )
49
- )(({ theme }) => ({
50
- [`& .${classes.inputLabelError}`]: {
51
- [`&:not(.${classes.inputLabelShrink})`]: {
52
- color: theme.palette.text.secondary,
53
- },
54
- [`&.${classes.inputLabelDisabled}`]: {
55
- color: theme.palette.text.disabled,
56
- },
57
- },
58
- [`& .${classes.inputLabelError}.${classes.inputLabelFocused}`]: {
59
- color: theme.palette.error.main,
60
- },
61
- // For variant: standard | filled
62
- [`& .${classes.inputUnderline}:not(.${classes.inputDisabled})`]: {
63
- [`&:hover:before`]: {
64
- borderColor: theme.palette.primary.main,
65
- },
66
- [`&.${classes.inputColorSecondary}:hover:before`]: {
67
- borderColor: theme.palette.secondary.main,
68
- },
69
- },
70
- // For variant: outlined
71
- [`& .${classes.inputDisabled} .${classes.inputNotchedOutline}`]: {
72
- borderStyle: 'dotted',
73
- },
74
- [`& .${classes.inputError}.${classes.inputFocused} .${classes.inputNotchedOutline}`]: {
75
- borderColor: theme.palette.error.main,
76
- },
77
- [`& :not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
78
- [`&:hover .${classes.inputNotchedOutline}`]: {
79
- borderColor: theme.palette.primary.main,
80
- },
81
- [`&.${classes.inputColorSecondary}:hover .${classes.inputNotchedOutline}`]: {
82
- borderColor: theme.palette.secondary.main,
83
- },
84
- },
85
- }))
86
-
87
- export const TextField = (props: TextFieldProps) => {
88
- const hasEndAdornment = !!props?.InputProps?.endAdornment
89
-
90
- return <StyledTextField hasEndAdornment={hasEndAdornment} {...props} />
91
- }
92
-
93
- export default TextField
@@ -1,83 +0,0 @@
1
- import React from 'react'
2
- import { Story, Meta } from '@storybook/react'
3
- import {
4
- TopicFilter as JuiTopicFilter,
5
- TopicFilterProps as JuiTopicFilterProps,
6
- } from './TopicFilter'
7
- import { topicTree } from '../../utils/topicTree'
8
-
9
- export default {
10
- component: JuiTopicFilter,
11
- title: 'TopicFilter',
12
- argTypes: {
13
- topicTree: {
14
- type: { name: 'object', required: false },
15
- description: 'Topic tree data list',
16
- table: {
17
- type: { summary: 'object' },
18
- defaultValue: { summary: topicTree },
19
- },
20
- control: { type: 'object' },
21
- },
22
- onTopicSelected: {
23
- type: { name: 'function', required: false },
24
- description: 'Callback fired when the topic selected.',
25
- table: {
26
- type: {
27
- summary: `(
28
- topic: Topic,
29
- selectedInfo: { layerNumber: number; selectedTopicIds: string[] }
30
- ) => void`,
31
- },
32
- defaultValue: { summary: () => {} },
33
- },
34
- control: { type: 'function' },
35
- },
36
- isLastLayer: {
37
- type: { name: 'function', required: false },
38
- description: 'Callback for checking selected topic is last layer or not.',
39
- table: {
40
- type: {
41
- summary: `(topic: Topic) => boolean`,
42
- },
43
- defaultValue: { summary: () => false },
44
- },
45
- control: { type: 'function' },
46
- },
47
- hasArrow: {
48
- type: { name: 'boolean', required: false },
49
- description: 'Control the arrow display state.',
50
- table: {
51
- type: { summary: 'boolean' },
52
- defaultValue: { summary: true },
53
- },
54
- control: { type: 'boolean' },
55
- defaultValue: true,
56
- },
57
- initSelectedTopicIds: {
58
- type: { name: 'array', required: false },
59
- description: ``,
60
- table: {
61
- type: { summary: 'array' },
62
- defaultValue: { summary: [] },
63
- },
64
- control: { type: 'array' },
65
- },
66
- },
67
- } as Meta
68
-
69
- const TopicFilterStory: Story<JuiTopicFilterProps> = (args) => (
70
- <JuiTopicFilter {...args} />
71
- )
72
-
73
- export const TopicFilter = TopicFilterStory.bind({})
74
-
75
- TopicFilter.args = {
76
- topicTree: topicTree,
77
- onTopicSelected: () => {},
78
- isLastLayer: (selectedTopic) => {
79
- return selectedTopic.isContentTopic
80
- },
81
- hasArrow: true,
82
- initSelectedTopicIds: [],
83
- }