@basic-ui/material 1.0.0-alpha.49 → 1.0.0-alpha.50

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.
@@ -1,241 +1,240 @@
1
- import { useState } from 'react';
2
-
3
- import { Box } from '../Box';
4
- import { CheckBox } from '../CheckBox';
5
- import { Select, SelectItem } from '../';
6
- import { Button } from '../Button';
7
- import { alpha } from '../color';
8
- import { TextField } from './';
9
-
10
- export default {
11
- title: 'components/TextField',
12
- };
13
-
14
- const SearchIcon = (props) => (
15
- <svg
16
- xmlns="http://www.w3.org/2000/svg"
17
- height={24}
18
- width={24}
19
- viewBox="0 0 48 48"
20
- fill="currentColor"
21
- {...props}
22
- >
23
- <path d="M39.8 41.95 26.65 28.8q-1.5 1.3-3.5 2.025-2 .725-4.25.725-5.4 0-9.15-3.75T6 18.75q0-5.3 3.75-9.05 3.75-3.75 9.1-3.75 5.3 0 9.025 3.75 3.725 3.75 3.725 9.05 0 2.15-.7 4.15-.7 2-2.1 3.75L42 39.75Zm-20.95-13.4q4.05 0 6.9-2.875Q28.6 22.8 28.6 18.75t-2.85-6.925Q22.9 8.95 18.85 8.95q-4.1 0-6.975 2.875T9 18.75q0 4.05 2.875 6.925t6.975 2.875Z" />
24
- </svg>
25
- );
26
-
27
- const Example = ({ variant }) => {
28
- const [error, setError] = useState<boolean | string>(false);
29
- const [color, setColor] = useState<'primary' | 'secondary'>('primary');
30
-
31
- return (
32
- <Box p={3}>
33
- <CheckBox
34
- checked={Boolean(error)}
35
- onChange={(e) =>
36
- setError(e.target.checked ? 'This field is required' : false)
37
- }
38
- >
39
- Has Error
40
- </CheckBox>
41
- <Box width={230} display="inline-block">
42
- <Select
43
- value={color}
44
- onChange={(e, value: 'primary' | 'secondary') => setColor(value)}
45
- label="Color"
46
- >
47
- <SelectItem value="primary">Primary</SelectItem>
48
- <SelectItem value="secondary">Secondary</SelectItem>
49
- </Select>
50
- </Box>
51
- <Box
52
- py={3}
53
- backgroundColor="surface"
54
- display="inline-flex"
55
- flexWrap="wrap"
56
- >
57
- <Box m={2} width={230} display="inline-block">
58
- <TextField
59
- variant={variant}
60
- label="Standard"
61
- error={error}
62
- color={color}
63
- />
64
- </Box>
65
- <Box m={2} width={230} display="inline-block">
66
- <TextField
67
- variant={variant}
68
- label="Standard"
69
- helperText="Helper text"
70
- error={error}
71
- color={color}
72
- />
73
- </Box>
74
- <Box m={2} width={230} display="inline-block">
75
- <TextField
76
- variant={variant}
77
- label="Standard"
78
- defaultValue="Hello world"
79
- helperText="Helper text"
80
- error={error}
81
- color={color}
82
- />
83
- </Box>
84
- <Box m={2} width={230} display="inline-block">
85
- <TextField
86
- variant={variant}
87
- label="Standard with placeholder"
88
- placeholder="Placeholder"
89
- helperText="Helper text"
90
- error={error}
91
- color={color}
92
- />
93
- </Box>
94
- <Box m={2} width={230} display="inline-block">
95
- <TextField
96
- variant={variant}
97
- label="Disabled"
98
- helperText="Helper text"
99
- error={error}
100
- color={color}
101
- disabled
102
- />
103
- </Box>
104
- <Box m={2} width={230} display="inline-block">
105
- <TextField
106
- variant={variant}
107
- label=""
108
- helperText="Helper text"
109
- error={error}
110
- color={color}
111
- />
112
- </Box>
113
- <Box m={2} width={230} display="inline-block">
114
- <TextField
115
- variant={variant}
116
- label="Standard"
117
- maxLength={20}
118
- error={error}
119
- color={color}
120
- />
121
- </Box>
122
- <Box m={2} width={230} display="inline-block">
123
- <TextField
124
- variant={variant}
125
- label="Standard"
126
- helperText="Helper text"
127
- multiline
128
- error={error}
129
- color={color}
130
- />
131
- </Box>
132
- <Box m={2} width={230} display="inline-block">
133
- <TextField
134
- variant={variant}
135
- label="Standard"
136
- helperText="Helper text"
137
- multiline
138
- maxLength={512}
139
- error={error}
140
- color={color}
141
- />
142
- </Box>
143
- <Box m={2} width={230} display="inline-block">
144
- <TextField
145
- variant={variant}
146
- helperText="Helper text"
147
- multiline
148
- error={error}
149
- color={color}
150
- />
151
- </Box>
152
- <Box m={2} width={230} display="inline-block">
153
- <TextField
154
- variant={variant}
155
- helperText="Helper text"
156
- multiline
157
- maxLength={512}
158
- error={error}
159
- color={color}
160
- />
161
- </Box>
162
- <Box m={2} width={'100%'} display="inline-block">
163
- <TextField
164
- variant={variant}
165
- label="Standard"
166
- error={error}
167
- color={color}
168
- />
169
- </Box>
170
- <Box m={2} width={230} display="inline-block">
171
- <TextField
172
- variant={variant}
173
- label="With icon"
174
- error={error}
175
- color={color}
176
- leadingIcon={<SearchIcon />}
177
- />
178
- </Box>
179
- <Box m={2} width={230} display="inline-block">
180
- <TextField
181
- variant={variant}
182
- label="With icon"
183
- error={error}
184
- color={color}
185
- trailingIcon={
186
- <Button
187
- variant="icon"
188
- sx={{
189
- pointerEvents: 'all',
190
- mr: '-8px',
191
- width: 40,
192
- height: 40,
193
- }}
194
- >
195
- <Box
196
- as="svg"
197
- sx={{ color: alpha('on.surface', 0.54) }}
198
- viewBox="0 0 24 24"
199
- minWidth="24px"
200
- minHeight="24px"
201
- >
202
- <path fill="currentColor" d="M7 10l5 5 5-5z" />
203
- </Box>
204
- </Button>
205
- }
206
- />
207
- </Box>
208
- <Box m={2} width={230} display="inline-block">
209
- <TextField
210
- variant={variant}
211
- label="Numeric"
212
- error={error}
213
- color={color}
214
- type="number"
215
- />
216
- </Box>
217
- <Box m={2} width={230} display="inline-block">
218
- <TextField
219
- variant={variant}
220
- label="Numeric with hidden arrows"
221
- error={error}
222
- color={color}
223
- type="number"
224
- sx={{
225
- '&::-webkit-outer-spin-button,&::-webkit-inner-spin-button': {
226
- WebkitAppearance: 'none',
227
- margin: 0,
228
- },
229
- '&[type=number]': {
230
- '-moz-appearance': 'textfield',
231
- },
232
- }}
233
- />
234
- </Box>
235
- </Box>
236
- </Box>
237
- );
238
- };
239
-
240
- export const Filled = () => <Example variant="filled" />;
241
- export const Outlined = () => <Example variant="outlined" />;
1
+ import { useState } from 'react';
2
+
3
+ import { Box } from '../Box';
4
+ import { CheckBox } from '../CheckBox';
5
+ import { Select, SelectItem } from '../';
6
+ import { Button } from '../Button';
7
+ import { alpha } from '../color';
8
+ import { TextField } from './';
9
+
10
+ export default {
11
+ title: 'components/TextField',
12
+ };
13
+
14
+ const SearchIcon = () => (
15
+ <svg
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ height={24}
18
+ width={24}
19
+ viewBox="0 0 48 48"
20
+ fill="currentColor"
21
+ >
22
+ <path d="M39.8 41.95 26.65 28.8q-1.5 1.3-3.5 2.025-2 .725-4.25.725-5.4 0-9.15-3.75T6 18.75q0-5.3 3.75-9.05 3.75-3.75 9.1-3.75 5.3 0 9.025 3.75 3.725 3.75 3.725 9.05 0 2.15-.7 4.15-.7 2-2.1 3.75L42 39.75Zm-20.95-13.4q4.05 0 6.9-2.875Q28.6 22.8 28.6 18.75t-2.85-6.925Q22.9 8.95 18.85 8.95q-4.1 0-6.975 2.875T9 18.75q0 4.05 2.875 6.925t6.975 2.875Z" />
23
+ </svg>
24
+ );
25
+
26
+ const Example = ({ variant }: { variant: 'filled' | 'outlined' }) => {
27
+ const [error, setError] = useState<boolean | string>(false);
28
+ const [color, setColor] = useState<'primary' | 'secondary'>('primary');
29
+
30
+ return (
31
+ <Box p={3}>
32
+ <CheckBox
33
+ checked={Boolean(error)}
34
+ onChange={(e) =>
35
+ setError(e.target.checked ? 'This field is required' : false)
36
+ }
37
+ >
38
+ Has Error
39
+ </CheckBox>
40
+ <Box width={230} display="inline-block">
41
+ <Select
42
+ value={color}
43
+ onChange={(e, value: 'primary' | 'secondary') => setColor(value)}
44
+ label="Color"
45
+ >
46
+ <SelectItem value="primary">Primary</SelectItem>
47
+ <SelectItem value="secondary">Secondary</SelectItem>
48
+ </Select>
49
+ </Box>
50
+ <Box
51
+ py={3}
52
+ backgroundColor="surface"
53
+ display="inline-flex"
54
+ flexWrap="wrap"
55
+ >
56
+ <Box m={2} width={230} display="inline-block">
57
+ <TextField
58
+ variant={variant}
59
+ label="Standard"
60
+ error={error}
61
+ color={color}
62
+ />
63
+ </Box>
64
+ <Box m={2} width={230} display="inline-block">
65
+ <TextField
66
+ variant={variant}
67
+ label="Standard"
68
+ helperText="Helper text"
69
+ error={error}
70
+ color={color}
71
+ />
72
+ </Box>
73
+ <Box m={2} width={230} display="inline-block">
74
+ <TextField
75
+ variant={variant}
76
+ label="Standard"
77
+ defaultValue="Hello world"
78
+ helperText="Helper text"
79
+ error={error}
80
+ color={color}
81
+ />
82
+ </Box>
83
+ <Box m={2} width={230} display="inline-block">
84
+ <TextField
85
+ variant={variant}
86
+ label="Standard with placeholder"
87
+ placeholder="Placeholder"
88
+ helperText="Helper text"
89
+ error={error}
90
+ color={color}
91
+ />
92
+ </Box>
93
+ <Box m={2} width={230} display="inline-block">
94
+ <TextField
95
+ variant={variant}
96
+ label="Disabled"
97
+ helperText="Helper text"
98
+ error={error}
99
+ color={color}
100
+ disabled
101
+ />
102
+ </Box>
103
+ <Box m={2} width={230} display="inline-block">
104
+ <TextField
105
+ variant={variant}
106
+ label=""
107
+ helperText="Helper text"
108
+ error={error}
109
+ color={color}
110
+ />
111
+ </Box>
112
+ <Box m={2} width={230} display="inline-block">
113
+ <TextField
114
+ variant={variant}
115
+ label="Standard"
116
+ maxLength={20}
117
+ error={error}
118
+ color={color}
119
+ />
120
+ </Box>
121
+ <Box m={2} width={230} display="inline-block">
122
+ <TextField
123
+ variant={variant}
124
+ label="Standard"
125
+ helperText="Helper text"
126
+ multiline
127
+ error={error}
128
+ color={color}
129
+ />
130
+ </Box>
131
+ <Box m={2} width={230} display="inline-block">
132
+ <TextField
133
+ variant={variant}
134
+ label="Standard"
135
+ helperText="Helper text"
136
+ multiline
137
+ maxLength={512}
138
+ error={error}
139
+ color={color}
140
+ />
141
+ </Box>
142
+ <Box m={2} width={230} display="inline-block">
143
+ <TextField
144
+ variant={variant}
145
+ helperText="Helper text"
146
+ multiline
147
+ error={error}
148
+ color={color}
149
+ />
150
+ </Box>
151
+ <Box m={2} width={230} display="inline-block">
152
+ <TextField
153
+ variant={variant}
154
+ helperText="Helper text"
155
+ multiline
156
+ maxLength={512}
157
+ error={error}
158
+ color={color}
159
+ />
160
+ </Box>
161
+ <Box m={2} width={'100%'} display="inline-block">
162
+ <TextField
163
+ variant={variant}
164
+ label="Standard"
165
+ error={error}
166
+ color={color}
167
+ />
168
+ </Box>
169
+ <Box m={2} width={230} display="inline-block">
170
+ <TextField
171
+ variant={variant}
172
+ label="With icon"
173
+ error={error}
174
+ color={color}
175
+ leadingIcon={<SearchIcon />}
176
+ />
177
+ </Box>
178
+ <Box m={2} width={230} display="inline-block">
179
+ <TextField
180
+ variant={variant}
181
+ label="With icon"
182
+ error={error}
183
+ color={color}
184
+ trailingIcon={
185
+ <Button
186
+ variant="icon"
187
+ sx={{
188
+ pointerEvents: 'all',
189
+ mr: '-8px',
190
+ width: 40,
191
+ height: 40,
192
+ }}
193
+ >
194
+ <Box
195
+ as="svg"
196
+ sx={{ color: alpha('on.surface', 0.54) }}
197
+ viewBox="0 0 24 24"
198
+ minWidth="24px"
199
+ minHeight="24px"
200
+ >
201
+ <path fill="currentColor" d="M7 10l5 5 5-5z" />
202
+ </Box>
203
+ </Button>
204
+ }
205
+ />
206
+ </Box>
207
+ <Box m={2} width={230} display="inline-block">
208
+ <TextField
209
+ variant={variant}
210
+ label="Numeric"
211
+ error={error}
212
+ color={color}
213
+ type="number"
214
+ />
215
+ </Box>
216
+ <Box m={2} width={230} display="inline-block">
217
+ <TextField
218
+ variant={variant}
219
+ label="Numeric with hidden arrows"
220
+ error={error}
221
+ color={color}
222
+ type="number"
223
+ sx={{
224
+ '&::-webkit-outer-spin-button,&::-webkit-inner-spin-button': {
225
+ WebkitAppearance: 'none',
226
+ margin: 0,
227
+ },
228
+ '&[type=number]': {
229
+ '-moz-appearance': 'textfield',
230
+ },
231
+ }}
232
+ />
233
+ </Box>
234
+ </Box>
235
+ </Box>
236
+ );
237
+ };
238
+
239
+ export const Filled = () => <Example variant="filled" />;
240
+ export const Outlined = () => <Example variant="outlined" />;
package/src/index.ts CHANGED
@@ -1,41 +1,42 @@
1
- export * from './AppBar';
2
- export * from './Alert';
3
- export * from './Badge';
4
- export * from './BaseLine';
5
- export * from './BottomSheet';
6
- export * from './Box';
7
- export * from './Button';
8
- export * from './Combobox';
9
- export * from './CheckBox';
10
- export * from './Chip';
11
- export * from './Divider';
12
- export * from './Dialog';
13
- export * from './FloatingLabel';
14
- export * from './LineRipple';
15
- export * from './Link';
16
- export * from './List';
17
- export * from './ListItem';
18
- export * from './Menu';
19
- export * from './NavRail';
20
- export * from './NotchedOutline';
21
- export * from './Paper';
22
- export * from './Popover';
23
- export * from './ProgressSpinner';
24
- export * from './RadioButton';
25
- export * from './Ripple';
26
- export * from './Select';
27
- export * from './SelectItem';
28
- export * from './Skeleton';
29
- export * from './Slider';
30
- export * from './Snackbar';
31
- export * from './Switch';
32
- export * from './Tab';
33
- export * from './TabIndicator';
34
- export * from './Table';
35
- export * from './Text';
36
- export * from './TextField';
37
- export * from './Tooltip';
38
- export * from './motion';
39
- export * from './theme';
40
- export * from './color';
41
- export * from './hooks/useAnimation';
1
+ export * from './AppBar';
2
+ export * from './Alert';
3
+ export * from './Badge';
4
+ export * from './BaseLine';
5
+ export * from './BottomSheet';
6
+ export * from './Box';
7
+ export * from './Button';
8
+ export * from './Combobox';
9
+ export * from './CheckBox';
10
+ export * from './Chip';
11
+ export * from './Divider';
12
+ export * from './Dialog';
13
+ export * from './FloatingLabel';
14
+ export * from './LineRipple';
15
+ export * from './Link';
16
+ export * from './List';
17
+ export * from './ListItem';
18
+ export * from './Menu';
19
+ export * from './NavRail';
20
+ export * from './NotchedOutline';
21
+ export * from './Paper';
22
+ export * from './Popover';
23
+ export * from './ProgressSpinner';
24
+ export * from './RadioButton';
25
+ export * from './Ripple';
26
+ export * from './SearchBar';
27
+ export * from './Select';
28
+ export * from './SelectItem';
29
+ export * from './Skeleton';
30
+ export * from './Slider';
31
+ export * from './Snackbar';
32
+ export * from './Switch';
33
+ export * from './Tab';
34
+ export * from './TabIndicator';
35
+ export * from './Table';
36
+ export * from './Text';
37
+ export * from './TextField';
38
+ export * from './Tooltip';
39
+ export * from './motion';
40
+ export * from './theme';
41
+ export * from './color';
42
+ export * from './hooks/useAnimation';