norma-library 0.4.1 → 0.4.3
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/dist/components/button/button.d.ts +3 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/{Button → button}/types.d.ts +18 -18
- package/dist/components/card/card-header.d.ts +3 -0
- package/dist/components/card/card.d.ts +3 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/styles.d.ts +811 -0
- package/dist/components/{Card → card}/types.d.ts +12 -12
- package/dist/components/checkbox/checkbox.d.ts +3 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/{Checkbox → checkbox}/types.d.ts +23 -23
- package/dist/components/icon/default.d.ts +210 -0
- package/dist/components/icon/defaultIcon.d.ts +5 -0
- package/dist/components/icon/icons-ia.d.ts +71 -0
- package/dist/components/icon/index.d.ts +234 -0
- package/dist/components/icon/norma.d.ts +30 -0
- package/dist/components/{Icon/NormaIcon.d.ts → icon/normaIcon.d.ts} +13 -13
- package/dist/components/icon/styles.d.ts +481 -0
- package/dist/components/{Icon → icon}/svg.d.ts +6 -6
- package/dist/components/{Icon → icon}/types.d.ts +12 -12
- package/dist/components/index.d.ts +8 -19
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/{Modal/Modal.d.ts → modal/modal.d.ts} +3 -4
- package/dist/components/modal/modalFooter.d.ts +3 -0
- package/dist/components/modal/modalHeader.d.ts +3 -0
- package/dist/components/modal/styles.d.ts +540 -0
- package/dist/components/{Modal → modal}/types.d.ts +27 -24
- package/dist/components/progress-bar/index.d.ts +1 -0
- package/dist/components/{ProgressBar/ProgressBar.d.ts → progress-bar/progress-bar.d.ts} +7 -8
- package/dist/components/progress-bar/styles.d.ts +272 -0
- package/dist/components/{ProgressBar → progress-bar}/types.d.ts +22 -22
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/radio.d.ts +3 -0
- package/dist/components/{Radio → radio}/types.d.ts +16 -16
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/{Tag/Tag.d.ts → tag/tag.d.ts} +3 -4
- package/dist/components/{Tag → tag}/types.d.ts +25 -25
- package/dist/components/textfield/index.d.ts +1 -0
- package/dist/components/textfield/textfield.d.ts +3 -0
- package/dist/components/{TextField → textfield}/types.d.ts +42 -42
- package/dist/helpers/clients.d.ts +5 -0
- package/dist/helpers/colors.d.ts +174 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/sizes.d.ts +6 -0
- package/dist/helpers/variants.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -0
- package/dist/norma-library.cjs.development.js +1286 -0
- package/dist/norma-library.cjs.development.js.map +1 -0
- package/dist/norma-library.cjs.production.min.js +2 -0
- package/dist/norma-library.cjs.production.min.js.map +1 -0
- package/dist/norma-library.esm.js +1274 -0
- package/dist/norma-library.esm.js.map +1 -0
- package/package.json +55 -86
- package/src/components/button/button.stories.tsx +44 -0
- package/src/components/button/button.tsx +18 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button/types.ts +48 -0
- package/src/components/card/card-header.tsx +8 -0
- package/src/components/card/card.stories.tsx +28 -0
- package/src/components/card/card.tsx +13 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/card/styles.tsx +29 -0
- package/src/components/card/types.ts +14 -0
- package/src/components/checkbox/checkbox.stories.tsx +66 -0
- package/src/components/checkbox/checkbox.tsx +13 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/types.ts +30 -0
- package/src/components/icon/default.tsx +1459 -0
- package/src/components/icon/defaultIcon.tsx +82 -0
- package/src/components/icon/icon.stories.tsx +44 -0
- package/src/components/icon/icons-ia.tsx +107 -0
- package/src/components/icon/index.ts +11 -0
- package/src/components/icon/norma.tsx +523 -0
- package/src/components/icon/normaIcon.tsx +94 -0
- package/src/components/icon/styles.ts +11 -0
- package/src/components/icon/svg.tsx +24 -0
- package/src/components/icon/types.ts +14 -0
- package/src/components/index.ts +8 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/modal/modal.stories.tsx +55 -0
- package/src/components/modal/modal.tsx +42 -0
- package/src/components/modal/modalFooter.tsx +32 -0
- package/src/components/modal/modalHeader.tsx +46 -0
- package/src/components/modal/styles.tsx +13 -0
- package/src/components/modal/types.ts +47 -0
- package/src/components/progress-bar/index.ts +1 -0
- package/src/components/progress-bar/progress-bar.stories.tsx +68 -0
- package/src/components/progress-bar/progress-bar.tsx +38 -0
- package/src/components/progress-bar/styles.tsx +27 -0
- package/src/components/progress-bar/types.ts +35 -0
- package/src/components/radio/index.ts +1 -0
- package/src/components/radio/radio.stories.tsx +150 -0
- package/src/components/radio/radio.tsx +13 -0
- package/src/components/radio/types.ts +27 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/tag.stories.tsx +80 -0
- package/src/components/tag/tag.tsx +13 -0
- package/src/components/tag/types.ts +47 -0
- package/src/components/textfield/index.ts +1 -0
- package/src/components/textfield/textfield.stories.tsx +376 -0
- package/src/components/textfield/textfield.tsx +23 -0
- package/src/components/textfield/types.ts +93 -0
- package/src/helpers/clients.ts +6 -0
- package/src/helpers/colors.ts +209 -0
- package/src/helpers/index.ts +3 -0
- package/src/helpers/sizes.ts +26 -0
- package/src/helpers/variants.ts +3 -0
- package/src/index.tsx +1 -0
- package/dist/components/Button/Button.d.ts +0 -4
- package/dist/components/Button/index.d.ts +0 -2
- package/dist/components/Card/Card.d.ts +0 -4
- package/dist/components/Card/CardHeader.d.ts +0 -4
- package/dist/components/Card/index.d.ts +0 -4
- package/dist/components/Card/styles.d.ts +0 -818
- package/dist/components/Checkbox/Checkbox.d.ts +0 -4
- package/dist/components/Checkbox/index.d.ts +0 -2
- package/dist/components/Icon/DefaultIcon.d.ts +0 -5
- package/dist/components/Icon/default.d.ts +0 -209
- package/dist/components/Icon/index.d.ts +0 -233
- package/dist/components/Icon/norma.d.ts +0 -29
- package/dist/components/Icon/styles.d.ts +0 -485
- package/dist/components/Modal/ModalFooter.d.ts +0 -4
- package/dist/components/Modal/ModalHeader.d.ts +0 -4
- package/dist/components/Modal/index.d.ts +0 -2
- package/dist/components/Modal/styles.d.ts +0 -274
- package/dist/components/ProgressBar/index.d.ts +0 -2
- package/dist/components/ProgressBar/styles.d.ts +0 -276
- package/dist/components/Radio/Radio.d.ts +0 -4
- package/dist/components/Radio/index.d.ts +0 -2
- package/dist/components/Tag/index.d.ts +0 -2
- package/dist/components/TextField/TextField.d.ts +0 -4
- package/dist/components/TextField/index.d.ts +0 -2
- package/dist/index.es.js +0 -15023
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -419
- package/dist/index.umd.js.map +0 -1
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { StoryDefault, Story } from '@ladle/react'
|
|
3
|
+
import { Tag } from './tag'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Data / Tag',
|
|
7
|
+
meta: {
|
|
8
|
+
key: 'tag',
|
|
9
|
+
},
|
|
10
|
+
} satisfies StoryDefault
|
|
11
|
+
|
|
12
|
+
export const TagBasic: Story = () => (
|
|
13
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
14
|
+
<Tag label="Tag Filled" />
|
|
15
|
+
<Tag label="Tag Outlined" variant="outlined" />
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
TagBasic.storyName = 'Tag Basic'
|
|
20
|
+
|
|
21
|
+
export const TagClickable: Story = () => {
|
|
22
|
+
const handleClick = () => {
|
|
23
|
+
console.info('You clicked the Chip.')
|
|
24
|
+
}
|
|
25
|
+
return (
|
|
26
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
27
|
+
<Tag label="Clickable" onClick={handleClick} />
|
|
28
|
+
<Tag label="Clickable" variant="outlined" onClick={handleClick} />
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
TagClickable.storyName = 'Tag Clickable'
|
|
34
|
+
|
|
35
|
+
export const TagDeletable: Story = () => {
|
|
36
|
+
const handleDelete = () => {
|
|
37
|
+
console.info('You clicked the delete icon.')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
42
|
+
<Tag label="Deletable" onDelete={handleDelete} />
|
|
43
|
+
<Tag label="Deletable" variant="outlined" onDelete={handleDelete} />
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
TagDeletable.storyName = 'Tag Deletable'
|
|
49
|
+
|
|
50
|
+
export const TagColor: Story = () => {
|
|
51
|
+
const handleDelete = () => {
|
|
52
|
+
console.info('You clicked the delete icon.')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
57
|
+
<Tag label="Deletable" onDelete={handleDelete} color="primary" />
|
|
58
|
+
<Tag label="Deletable" onDelete={handleDelete} color="success" />
|
|
59
|
+
<Tag label="Deletable" variant="outlined" onDelete={handleDelete} color="primary" />
|
|
60
|
+
<Tag label="Deletable" variant="outlined" onDelete={handleDelete} color="success" />
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
TagColor.storyName = 'Tag Color'
|
|
66
|
+
|
|
67
|
+
export const TagSize: Story = () => {
|
|
68
|
+
const handleDelete = () => {
|
|
69
|
+
console.info('You clicked the delete icon.')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
74
|
+
<Tag label="Small" onDelete={handleDelete} size="small" />
|
|
75
|
+
<Tag label="Small outlined" variant="outlined" onDelete={handleDelete} size="small" />
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
TagSize.storyName = 'Tag Size'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { themes } from '../../helpers/colors';
|
|
2
|
+
import { ThemeProvider } from '@mui/material';
|
|
3
|
+
import { Chip as MuiChip } from '@mui/material';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { TagBaseProps } from './types';
|
|
6
|
+
|
|
7
|
+
export const Tag: React.FC<TagBaseProps> = ({ ...rest }) => {
|
|
8
|
+
return (
|
|
9
|
+
<ThemeProvider theme={themes.light}>
|
|
10
|
+
<MuiChip {...rest} />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChipProps,
|
|
3
|
+
ChipPropsColorOverrides,
|
|
4
|
+
ChipPropsSizeOverrides,
|
|
5
|
+
ChipPropsVariantOverrides,
|
|
6
|
+
SxProps,
|
|
7
|
+
} from '@mui/material';
|
|
8
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
9
|
+
import { Theme } from '@emotion/react';
|
|
10
|
+
import Tag from './tag';
|
|
11
|
+
|
|
12
|
+
type MuiTagBaseProps = Pick<ChipProps, 'sx'>;
|
|
13
|
+
|
|
14
|
+
export interface TagBaseProps extends MuiTagBaseProps {
|
|
15
|
+
sx?: SxProps<Theme>;
|
|
16
|
+
avatar?: React.ReactElement;
|
|
17
|
+
children?: null;
|
|
18
|
+
clickable?: boolean;
|
|
19
|
+
deleteIcon?: React.ReactElement;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
icon?: React.ReactElement;
|
|
22
|
+
label?: React.ReactNode;
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
onDelete?: React.EventHandler<any>;
|
|
25
|
+
size?: OverridableStringUnion<'small' | 'medium', ChipPropsSizeOverrides>;
|
|
26
|
+
skipFocusWhenDisabled?: boolean;
|
|
27
|
+
tabIndex?: number;
|
|
28
|
+
variant?: OverridableStringUnion<
|
|
29
|
+
'filled' | 'outlined',
|
|
30
|
+
ChipPropsVariantOverrides
|
|
31
|
+
>;
|
|
32
|
+
onClick?: (
|
|
33
|
+
event: React.MouseEvent | React.KeyboardEvent | React.TouchEvent
|
|
34
|
+
) => void;
|
|
35
|
+
color?: OverridableStringUnion<
|
|
36
|
+
| 'default'
|
|
37
|
+
| 'primary'
|
|
38
|
+
| 'secondary'
|
|
39
|
+
| 'error'
|
|
40
|
+
| 'info'
|
|
41
|
+
| 'success'
|
|
42
|
+
| 'warning',
|
|
43
|
+
ChipPropsColorOverrides
|
|
44
|
+
>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type TagType = keyof typeof Tag;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textfield';
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { StoryDefault, Story } from '@ladle/react'
|
|
3
|
+
import { TextField } from './textfield'
|
|
4
|
+
import Box from '@mui/material/Box'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Form / TextField',
|
|
8
|
+
meta: {
|
|
9
|
+
key: 'button',
|
|
10
|
+
},
|
|
11
|
+
} satisfies StoryDefault
|
|
12
|
+
|
|
13
|
+
export const TextFieldVariant: Story = () => (
|
|
14
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
15
|
+
<TextField variant="standard" label="Variant text" />
|
|
16
|
+
<TextField variant="filled" label="Variant Contained" />
|
|
17
|
+
<TextField variant="outlined" label="Variant Outlined" />
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
TextFieldVariant.storyName = 'Textfield Variants'
|
|
22
|
+
|
|
23
|
+
export const TextFieldProps: Story = () => (
|
|
24
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
25
|
+
<Box
|
|
26
|
+
component="form"
|
|
27
|
+
sx={{
|
|
28
|
+
'& .MuiTextField-root': { m: 1, width: '100%' },
|
|
29
|
+
display: 'flex',
|
|
30
|
+
gap: '1rem',
|
|
31
|
+
margin: 15,
|
|
32
|
+
}}
|
|
33
|
+
noValidate
|
|
34
|
+
autoComplete="off"
|
|
35
|
+
>
|
|
36
|
+
<div>
|
|
37
|
+
<TextField required id="outlined-required" label="Required" defaultValue="Hello World" />
|
|
38
|
+
<TextField disabled id="outlined-disabled" label="Disabled" defaultValue="Hello World" />
|
|
39
|
+
<TextField
|
|
40
|
+
id="outlined-password-input"
|
|
41
|
+
label="Password"
|
|
42
|
+
type="password"
|
|
43
|
+
autoComplete="current-password"
|
|
44
|
+
/>
|
|
45
|
+
<TextField
|
|
46
|
+
id="outlined-read-only-input"
|
|
47
|
+
label="Read Only"
|
|
48
|
+
defaultValue="Hello World"
|
|
49
|
+
InputProps={{
|
|
50
|
+
readOnly: true,
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
<TextField
|
|
54
|
+
id="outlined-number"
|
|
55
|
+
label="Number"
|
|
56
|
+
type="number"
|
|
57
|
+
InputLabelProps={{
|
|
58
|
+
shrink: true,
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
<TextField id="outlined-search" label="Search field" type="search" />
|
|
62
|
+
<TextField
|
|
63
|
+
id="outlined-helperText"
|
|
64
|
+
label="Helper text"
|
|
65
|
+
defaultValue="Default Value"
|
|
66
|
+
helperText="Some important text"
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
<div>
|
|
70
|
+
<TextField
|
|
71
|
+
required
|
|
72
|
+
id="filled-required"
|
|
73
|
+
label="Required"
|
|
74
|
+
defaultValue="Hello World"
|
|
75
|
+
variant="filled"
|
|
76
|
+
/>
|
|
77
|
+
<TextField
|
|
78
|
+
disabled
|
|
79
|
+
id="filled-disabled"
|
|
80
|
+
label="Disabled"
|
|
81
|
+
defaultValue="Hello World"
|
|
82
|
+
variant="filled"
|
|
83
|
+
/>
|
|
84
|
+
<TextField
|
|
85
|
+
id="filled-password-input"
|
|
86
|
+
label="Password"
|
|
87
|
+
type="password"
|
|
88
|
+
autoComplete="current-password"
|
|
89
|
+
variant="filled"
|
|
90
|
+
/>
|
|
91
|
+
<TextField
|
|
92
|
+
id="filled-read-only-input"
|
|
93
|
+
label="Read Only"
|
|
94
|
+
defaultValue="Hello World"
|
|
95
|
+
InputProps={{
|
|
96
|
+
readOnly: true,
|
|
97
|
+
}}
|
|
98
|
+
variant="filled"
|
|
99
|
+
/>
|
|
100
|
+
<TextField
|
|
101
|
+
id="filled-number"
|
|
102
|
+
label="Number"
|
|
103
|
+
type="number"
|
|
104
|
+
InputLabelProps={{
|
|
105
|
+
shrink: true,
|
|
106
|
+
}}
|
|
107
|
+
variant="filled"
|
|
108
|
+
/>
|
|
109
|
+
<TextField id="filled-search" label="Search field" type="search" variant="filled" />
|
|
110
|
+
<TextField
|
|
111
|
+
id="filled-helperText"
|
|
112
|
+
label="Helper text"
|
|
113
|
+
defaultValue="Default Value"
|
|
114
|
+
helperText="Some important text"
|
|
115
|
+
variant="filled"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
<div>
|
|
119
|
+
<TextField
|
|
120
|
+
required
|
|
121
|
+
id="standard-required"
|
|
122
|
+
label="Required"
|
|
123
|
+
defaultValue="Hello World"
|
|
124
|
+
variant="standard"
|
|
125
|
+
/>
|
|
126
|
+
<TextField
|
|
127
|
+
disabled
|
|
128
|
+
id="standard-disabled"
|
|
129
|
+
label="Disabled"
|
|
130
|
+
defaultValue="Hello World"
|
|
131
|
+
variant="standard"
|
|
132
|
+
/>
|
|
133
|
+
<TextField
|
|
134
|
+
id="standard-password-input"
|
|
135
|
+
label="Password"
|
|
136
|
+
type="password"
|
|
137
|
+
autoComplete="current-password"
|
|
138
|
+
variant="standard"
|
|
139
|
+
/>
|
|
140
|
+
<TextField
|
|
141
|
+
id="standard-read-only-input"
|
|
142
|
+
label="Read Only"
|
|
143
|
+
defaultValue="Hello World"
|
|
144
|
+
InputProps={{
|
|
145
|
+
readOnly: true,
|
|
146
|
+
}}
|
|
147
|
+
variant="standard"
|
|
148
|
+
/>
|
|
149
|
+
<TextField
|
|
150
|
+
id="standard-number"
|
|
151
|
+
label="Number"
|
|
152
|
+
type="number"
|
|
153
|
+
InputLabelProps={{
|
|
154
|
+
shrink: true,
|
|
155
|
+
}}
|
|
156
|
+
variant="standard"
|
|
157
|
+
/>
|
|
158
|
+
<TextField id="standard-search" label="Search field" type="search" variant="standard" />
|
|
159
|
+
<TextField
|
|
160
|
+
id="standard-helperText"
|
|
161
|
+
label="Helper text"
|
|
162
|
+
defaultValue="Default Value"
|
|
163
|
+
helperText="Some important text"
|
|
164
|
+
variant="standard"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
</Box>
|
|
168
|
+
</div>
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
TextFieldProps.storyName = 'Textfield props'
|
|
172
|
+
|
|
173
|
+
export const TextFieldValidation: Story = () => (
|
|
174
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
175
|
+
<Box
|
|
176
|
+
component="form"
|
|
177
|
+
sx={{
|
|
178
|
+
'& .MuiTextField-root': { m: 1, width: '100%' },
|
|
179
|
+
}}
|
|
180
|
+
noValidate
|
|
181
|
+
autoComplete="off"
|
|
182
|
+
>
|
|
183
|
+
<div>
|
|
184
|
+
<TextField error id="outlined-error" label="Error" defaultValue="Hello World" />
|
|
185
|
+
<TextField
|
|
186
|
+
error
|
|
187
|
+
id="outlined-error-helper-text"
|
|
188
|
+
label="Error"
|
|
189
|
+
defaultValue="Hello World"
|
|
190
|
+
helperText="Incorrect entry."
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
<div>
|
|
194
|
+
<TextField
|
|
195
|
+
error
|
|
196
|
+
id="filled-error"
|
|
197
|
+
label="Error"
|
|
198
|
+
defaultValue="Hello World"
|
|
199
|
+
variant="filled"
|
|
200
|
+
/>
|
|
201
|
+
<TextField
|
|
202
|
+
error
|
|
203
|
+
id="filled-error-helper-text"
|
|
204
|
+
label="Error"
|
|
205
|
+
defaultValue="Hello World"
|
|
206
|
+
helperText="Incorrect entry."
|
|
207
|
+
variant="filled"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
<div>
|
|
211
|
+
<TextField
|
|
212
|
+
error
|
|
213
|
+
id="standard-error"
|
|
214
|
+
label="Error"
|
|
215
|
+
defaultValue="Hello World"
|
|
216
|
+
variant="standard"
|
|
217
|
+
/>
|
|
218
|
+
<TextField
|
|
219
|
+
error
|
|
220
|
+
id="standard-error-helper-text"
|
|
221
|
+
label="Error"
|
|
222
|
+
defaultValue="Hello World"
|
|
223
|
+
helperText="Incorrect entry."
|
|
224
|
+
variant="standard"
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
</Box>
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
TextFieldValidation.storyName = 'Textfield Validation'
|
|
232
|
+
|
|
233
|
+
export const TextFieldMultiline: Story = () => (
|
|
234
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
235
|
+
<Box
|
|
236
|
+
component="form"
|
|
237
|
+
sx={{
|
|
238
|
+
'& .MuiTextField-root': { m: 1, width: '100%' },
|
|
239
|
+
}}
|
|
240
|
+
noValidate
|
|
241
|
+
autoComplete="off"
|
|
242
|
+
>
|
|
243
|
+
<div>
|
|
244
|
+
<TextField id="outlined-multiline-flexible" label="Multiline" multiline maxRows={4} />
|
|
245
|
+
<TextField
|
|
246
|
+
id="outlined-textarea"
|
|
247
|
+
label="Multiline Placeholder"
|
|
248
|
+
placeholder="Placeholder"
|
|
249
|
+
multiline
|
|
250
|
+
/>
|
|
251
|
+
<TextField
|
|
252
|
+
id="outlined-multiline-static"
|
|
253
|
+
label="Multiline"
|
|
254
|
+
multiline
|
|
255
|
+
rows={4}
|
|
256
|
+
defaultValue="Default Value"
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
<div>
|
|
260
|
+
<TextField
|
|
261
|
+
id="filled-multiline-flexible"
|
|
262
|
+
label="Multiline"
|
|
263
|
+
multiline
|
|
264
|
+
maxRows={4}
|
|
265
|
+
variant="filled"
|
|
266
|
+
/>
|
|
267
|
+
<TextField
|
|
268
|
+
id="filled-textarea"
|
|
269
|
+
label="Multiline Placeholder"
|
|
270
|
+
placeholder="Placeholder"
|
|
271
|
+
multiline
|
|
272
|
+
variant="filled"
|
|
273
|
+
/>
|
|
274
|
+
<TextField
|
|
275
|
+
id="filled-multiline-static"
|
|
276
|
+
label="Multiline"
|
|
277
|
+
multiline
|
|
278
|
+
rows={4}
|
|
279
|
+
defaultValue="Default Value"
|
|
280
|
+
variant="filled"
|
|
281
|
+
/>
|
|
282
|
+
</div>
|
|
283
|
+
<div>
|
|
284
|
+
<TextField
|
|
285
|
+
id="standard-multiline-flexible"
|
|
286
|
+
label="Multiline"
|
|
287
|
+
multiline
|
|
288
|
+
maxRows={4}
|
|
289
|
+
variant="standard"
|
|
290
|
+
/>
|
|
291
|
+
<TextField
|
|
292
|
+
id="standard-textarea"
|
|
293
|
+
label="Multiline Placeholder"
|
|
294
|
+
placeholder="Placeholder"
|
|
295
|
+
multiline
|
|
296
|
+
variant="standard"
|
|
297
|
+
/>
|
|
298
|
+
<TextField
|
|
299
|
+
id="standard-multiline-static"
|
|
300
|
+
label="Multiline"
|
|
301
|
+
multiline
|
|
302
|
+
rows={4}
|
|
303
|
+
defaultValue="Default Value"
|
|
304
|
+
variant="standard"
|
|
305
|
+
/>
|
|
306
|
+
</div>
|
|
307
|
+
</Box>
|
|
308
|
+
</div>
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
TextFieldMultiline.storyName = 'Textfield Multiline'
|
|
312
|
+
|
|
313
|
+
export const TextFieldSizes: Story = () => (
|
|
314
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
315
|
+
<Box
|
|
316
|
+
component="form"
|
|
317
|
+
sx={{
|
|
318
|
+
'& .MuiTextField-root': { m: 1, width: '100%' },
|
|
319
|
+
}}
|
|
320
|
+
noValidate
|
|
321
|
+
autoComplete="off"
|
|
322
|
+
>
|
|
323
|
+
<div>
|
|
324
|
+
<TextField label="Size" id="outlined-size-small" defaultValue="Small" size="small" />
|
|
325
|
+
<TextField label="Size" id="outlined-size-normal" defaultValue="Normal" />
|
|
326
|
+
</div>
|
|
327
|
+
<div>
|
|
328
|
+
<TextField
|
|
329
|
+
label="Size"
|
|
330
|
+
id="filled-size-small"
|
|
331
|
+
defaultValue="Small"
|
|
332
|
+
variant="filled"
|
|
333
|
+
size="small"
|
|
334
|
+
/>
|
|
335
|
+
<TextField label="Size" id="filled-size-normal" defaultValue="Normal" variant="filled" />
|
|
336
|
+
</div>
|
|
337
|
+
<div>
|
|
338
|
+
<TextField
|
|
339
|
+
label="Size"
|
|
340
|
+
id="standard-size-small"
|
|
341
|
+
defaultValue="Small"
|
|
342
|
+
size="small"
|
|
343
|
+
variant="standard"
|
|
344
|
+
/>
|
|
345
|
+
<TextField
|
|
346
|
+
label="Size"
|
|
347
|
+
id="standard-size-normal"
|
|
348
|
+
defaultValue="Normal"
|
|
349
|
+
variant="standard"
|
|
350
|
+
/>
|
|
351
|
+
</div>
|
|
352
|
+
</Box>
|
|
353
|
+
</div>
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
TextFieldSizes.storyName = 'Textfield Sizes'
|
|
357
|
+
|
|
358
|
+
export const TextFieldColors: Story = () => (
|
|
359
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 15 }}>
|
|
360
|
+
<Box
|
|
361
|
+
component="form"
|
|
362
|
+
sx={{
|
|
363
|
+
'& > :not(style)': { m: 1, width: '100%' },
|
|
364
|
+
}}
|
|
365
|
+
noValidate
|
|
366
|
+
autoComplete="off"
|
|
367
|
+
>
|
|
368
|
+
<TextField label="Outlined Primary" color="primary" focused />
|
|
369
|
+
<TextField label="Outlined secondary" color="secondary" focused />
|
|
370
|
+
<TextField label="Filled success" variant="filled" color="success" focused />
|
|
371
|
+
<TextField label="Standard warning" variant="standard" color="warning" focused />
|
|
372
|
+
</Box>
|
|
373
|
+
</div>
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
TextFieldColors.storyName = 'Textfield Colors'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextFieldBaseProps } from './types';
|
|
3
|
+
import {
|
|
4
|
+
FormControl,
|
|
5
|
+
ThemeProvider,
|
|
6
|
+
TextField as MuiTextField,
|
|
7
|
+
} from '@mui/material';
|
|
8
|
+
import { themes } from '../../helpers/colors';
|
|
9
|
+
|
|
10
|
+
export const TextField: React.FC<TextFieldBaseProps> = ({
|
|
11
|
+
label,
|
|
12
|
+
disabled = false,
|
|
13
|
+
onChange,
|
|
14
|
+
...rest
|
|
15
|
+
}) => {
|
|
16
|
+
return (
|
|
17
|
+
<ThemeProvider theme={themes.light}>
|
|
18
|
+
<FormControl sx={{ width: '100%' }}>
|
|
19
|
+
<MuiTextField {...rest} label={label} disabled={disabled} />
|
|
20
|
+
</FormControl>
|
|
21
|
+
</ThemeProvider>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TextFieldProps as MuiTextFieldProps,
|
|
5
|
+
TextFieldPropsColorOverrides,
|
|
6
|
+
TextFieldPropsSizeOverrides,
|
|
7
|
+
} from '@mui/material/TextField'
|
|
8
|
+
import {
|
|
9
|
+
FormHelperTextProps,
|
|
10
|
+
InputBaseProps,
|
|
11
|
+
InputLabelProps,
|
|
12
|
+
OutlinedInputProps,
|
|
13
|
+
SelectProps,
|
|
14
|
+
} from '@mui/material'
|
|
15
|
+
import { InputProps as StandardInputProps } from '@mui/material/Input'
|
|
16
|
+
import { OverridableStringUnion } from '@mui/types'
|
|
17
|
+
import { TextField } from '@mui/material'
|
|
18
|
+
|
|
19
|
+
export type TextFieldValue = string | number
|
|
20
|
+
export type TextFieldVariant = 'standard' | 'outlined' | 'filled'
|
|
21
|
+
|
|
22
|
+
type MuiTextFieldBaseProps = Pick<
|
|
23
|
+
MuiTextFieldProps,
|
|
24
|
+
| 'onChange'
|
|
25
|
+
| 'onBlur'
|
|
26
|
+
| 'onFocus'
|
|
27
|
+
| 'defaultValue'
|
|
28
|
+
| 'size'
|
|
29
|
+
| 'value'
|
|
30
|
+
| 'id'
|
|
31
|
+
| 'fullWidth'
|
|
32
|
+
| 'helperText'
|
|
33
|
+
| 'type'
|
|
34
|
+
| 'InputProps'
|
|
35
|
+
| 'InputLabelProps'
|
|
36
|
+
| 'autoComplete'
|
|
37
|
+
| 'label'
|
|
38
|
+
| 'helperText'
|
|
39
|
+
| 'InputLabelProps'
|
|
40
|
+
| 'margin'
|
|
41
|
+
| 'maxRows'
|
|
42
|
+
| 'minRows'
|
|
43
|
+
| 'multiline'
|
|
44
|
+
| 'name'
|
|
45
|
+
| 'placeholder'
|
|
46
|
+
| 'rows'
|
|
47
|
+
| 'select'
|
|
48
|
+
| 'SelectProps'
|
|
49
|
+
| 'sx'
|
|
50
|
+
| 'autoFocus'
|
|
51
|
+
| 'error'
|
|
52
|
+
| 'classes'
|
|
53
|
+
| 'children'
|
|
54
|
+
| 'color'
|
|
55
|
+
| 'variant'
|
|
56
|
+
>
|
|
57
|
+
|
|
58
|
+
export interface TextFieldBaseProps extends MuiTextFieldBaseProps {
|
|
59
|
+
id?: string
|
|
60
|
+
name?: string
|
|
61
|
+
defaultValue?: string
|
|
62
|
+
disabled?: boolean
|
|
63
|
+
required?: boolean
|
|
64
|
+
type?: React.InputHTMLAttributes<unknown>['type']
|
|
65
|
+
hasError?: boolean
|
|
66
|
+
label?: ReactNode
|
|
67
|
+
children?: ReactNode
|
|
68
|
+
error?: boolean
|
|
69
|
+
variant?: TextFieldVariant
|
|
70
|
+
helperText?: React.ReactNode
|
|
71
|
+
InputLabelProps?: Partial<InputLabelProps>
|
|
72
|
+
InputProps?: Partial<OutlinedInputProps>
|
|
73
|
+
autoComplete?: string
|
|
74
|
+
placeholder?: string
|
|
75
|
+
multiline?: boolean
|
|
76
|
+
rows?: string | number
|
|
77
|
+
maxRows?: string | number
|
|
78
|
+
minRows?: string | number
|
|
79
|
+
select?: boolean
|
|
80
|
+
SelectProps?: Partial<SelectProps>
|
|
81
|
+
onClick?: InputBaseProps['onClick']
|
|
82
|
+
onBlur?: InputBaseProps['onBlur']
|
|
83
|
+
onFocus?: StandardInputProps['onFocus']
|
|
84
|
+
size?: OverridableStringUnion<'small' | 'medium', TextFieldPropsSizeOverrides>
|
|
85
|
+
FormHelperTextProps?: Partial<FormHelperTextProps>
|
|
86
|
+
color?: OverridableStringUnion<
|
|
87
|
+
'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
|
|
88
|
+
TextFieldPropsColorOverrides
|
|
89
|
+
>
|
|
90
|
+
value?: unknown
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type TextFieldType = keyof typeof TextField
|