@zesty-io/material 0.0.2 → 0.1.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/.storybook/main.js +15 -2
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +14 -8
- package/es/ConfirmModal/ConfirmModal.stories.d.ts +6 -0
- package/es/ConfirmModal/ConfirmModal.stories.js +24 -0
- package/es/ConfirmModal/index.d.ts +18 -0
- package/es/ConfirmModal/index.js +11 -0
- package/es/CopyButton/CopyButton.stories.d.ts +5 -0
- package/es/CopyButton/CopyButton.stories.js +14 -0
- package/es/CopyButton/index.d.ts +10 -0
- package/es/CopyButton/index.js +26 -0
- package/es/FieldTypeColor/FieldTypeColor.stories.d.ts +5 -0
- package/es/FieldTypeColor/FieldTypeColor.stories.js +21 -0
- package/es/FieldTypeColor/index.d.ts +6 -0
- package/es/FieldTypeColor/index.js +20 -0
- package/es/FieldTypeDate/FieldTypeDate.stories.d.ts +5 -0
- package/es/FieldTypeDate/FieldTypeDate.stories.js +20 -0
- package/es/FieldTypeDate/index.d.ts +11 -0
- package/es/FieldTypeDate/index.js +14 -0
- package/es/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +5 -0
- package/es/FieldTypeDateTime/FieldTypeDateTime.stories.js +20 -0
- package/es/FieldTypeDateTime/index.d.ts +11 -0
- package/es/FieldTypeDateTime/index.js +14 -0
- package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.d.ts +5 -0
- package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.js +34 -0
- package/es/FieldTypeDropdown/index.d.ts +11 -0
- package/es/FieldTypeDropdown/index.js +15 -0
- package/es/FieldTypeNumber/FieldTypeNumber.stories.d.ts +5 -0
- package/es/FieldTypeNumber/FieldTypeNumber.stories.js +20 -0
- package/es/FieldTypeNumber/index.d.ts +6 -0
- package/es/FieldTypeNumber/index.js +10 -0
- package/es/FieldTypeSort/FieldTypeSort.stories.d.ts +5 -0
- package/es/FieldTypeSort/FieldTypeSort.stories.js +21 -0
- package/es/FieldTypeSort/index.d.ts +7 -0
- package/es/FieldTypeSort/index.js +32 -0
- package/es/FieldTypeText/FieldTypeText.stories.d.ts +6 -0
- package/es/FieldTypeText/FieldTypeText.stories.js +27 -0
- package/es/FieldTypeText/index.d.ts +12 -0
- package/es/FieldTypeText/index.js +15 -0
- package/es/FieldTypeUrl/FieldTypeUrl.stories.d.ts +5 -0
- package/es/FieldTypeUrl/FieldTypeUrl.stories.js +21 -0
- package/es/FieldTypeUrl/index.d.ts +12 -0
- package/es/FieldTypeUrl/index.js +21 -0
- package/es/index.d.ts +10 -0
- package/es/index.js +10 -0
- package/es/theme/Theme.stories.d.ts +4 -0
- package/es/theme/Theme.stories.js +10 -0
- package/es/theme/index.js +46 -12
- package/package.json +5 -2
- package/src/ConfirmModal/ConfirmModal.stories.tsx +35 -0
- package/src/ConfirmModal/index.tsx +50 -0
- package/src/CopyButton/CopyButton.stories.tsx +20 -0
- package/src/CopyButton/index.tsx +55 -0
- package/src/FieldTypeColor/FieldTypeColor.stories.tsx +35 -0
- package/src/FieldTypeColor/index.tsx +45 -0
- package/src/FieldTypeDate/FieldTypeDate.stories.tsx +26 -0
- package/src/FieldTypeDate/index.tsx +37 -0
- package/src/FieldTypeDateTime/FieldTypeDateTime.stories.tsx +26 -0
- package/src/FieldTypeDateTime/index.tsx +37 -0
- package/src/FieldTypeDropdown/FieldTypeDropwdon.stories.tsx +51 -0
- package/src/FieldTypeDropdown/index.tsx +43 -0
- package/src/FieldTypeNumber/FieldTypeNumber.stories.tsx +34 -0
- package/src/FieldTypeNumber/index.tsx +23 -0
- package/src/FieldTypeSort/FieldTypeSort.stories.tsx +35 -0
- package/src/FieldTypeSort/index.tsx +65 -0
- package/src/FieldTypeText/FieldTypeText.stories.tsx +41 -0
- package/src/FieldTypeText/index.tsx +42 -0
- package/src/FieldTypeUrl/FieldTypeUrl.stories.tsx +33 -0
- package/src/FieldTypeUrl/index.tsx +50 -0
- package/src/index.ts +10 -0
- package/src/{stories → theme}/Theme.stories.tsx +1 -1
- package/src/theme/index.ts +52 -13
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
|
|
3
|
+
export interface FieldTypeNumberProps extends Omit<OutlinedTextFieldProps, 'variant'> {}
|
|
4
|
+
|
|
5
|
+
const FieldTypeText = ({InputLabelProps, ...props }: FieldTypeNumberProps) => {
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<MuiTextField
|
|
9
|
+
size="small"
|
|
10
|
+
variant='outlined'
|
|
11
|
+
type='number'
|
|
12
|
+
InputLabelProps={{
|
|
13
|
+
shrink: true,
|
|
14
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
15
|
+
...InputLabelProps,
|
|
16
|
+
}}
|
|
17
|
+
// Spread props at the end to allow prop overrides
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default FieldTypeText;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeSort, { FieldTypeSortProps } from './';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeSort',
|
|
7
|
+
component: FieldTypeSort,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeSortProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('3');
|
|
13
|
+
|
|
14
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FieldTypeSort
|
|
20
|
+
{...args}
|
|
21
|
+
value={value}
|
|
22
|
+
onChange={handleOnChange}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
Default.args = {
|
|
29
|
+
placeholder: 'Placeholder Text...',
|
|
30
|
+
label: 'Sort label',
|
|
31
|
+
helperText: 'Sort helper text',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import { Button, InputAdornment } from '@mui/material';
|
|
3
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
+
import RemoveIcon from '@mui/icons-material/Remove';
|
|
5
|
+
|
|
6
|
+
export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const FieldTypeSort = ({value, InputProps, InputLabelProps, sx, ...props }: FieldTypeSortProps) => {
|
|
11
|
+
return (
|
|
12
|
+
<MuiTextField
|
|
13
|
+
size="small"
|
|
14
|
+
variant='outlined'
|
|
15
|
+
type='number'
|
|
16
|
+
value={value}
|
|
17
|
+
sx={{
|
|
18
|
+
width: 165,
|
|
19
|
+
// Spread props at the end to allow sx prop overrides
|
|
20
|
+
...sx
|
|
21
|
+
}}
|
|
22
|
+
InputProps={{
|
|
23
|
+
startAdornment: (
|
|
24
|
+
<InputAdornment position="start">
|
|
25
|
+
<Button
|
|
26
|
+
size="small"
|
|
27
|
+
variant="contained"
|
|
28
|
+
onClick={(e) => {
|
|
29
|
+
// References input via event in order to modify its value
|
|
30
|
+
const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1] as HTMLInputElement;
|
|
31
|
+
console.log('testing input', input)
|
|
32
|
+
input.value = String(+input.value + 1)
|
|
33
|
+
}}><AddIcon fontSize='small' />
|
|
34
|
+
</Button>
|
|
35
|
+
</InputAdornment>
|
|
36
|
+
),
|
|
37
|
+
endAdornment: (
|
|
38
|
+
<InputAdornment position="end">
|
|
39
|
+
<Button
|
|
40
|
+
size="small"
|
|
41
|
+
variant="contained"
|
|
42
|
+
onClick={(e) => {
|
|
43
|
+
// References input via event in order to modify its value
|
|
44
|
+
const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1] as HTMLInputElement;
|
|
45
|
+
console.log('testing input', input)
|
|
46
|
+
input.value = String(+input.value - 1)
|
|
47
|
+
}}><RemoveIcon fontSize='small' />
|
|
48
|
+
</Button>
|
|
49
|
+
</InputAdornment>
|
|
50
|
+
),
|
|
51
|
+
// Spread props at the end to allow Input prop overrides
|
|
52
|
+
...InputProps,
|
|
53
|
+
}}
|
|
54
|
+
InputLabelProps={{
|
|
55
|
+
shrink: true,
|
|
56
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
57
|
+
...InputLabelProps,
|
|
58
|
+
}}
|
|
59
|
+
// Spread props at the end to allow prop overrides
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default FieldTypeSort;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeText, { FieldTypeTextProps } from './';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeText',
|
|
7
|
+
component: FieldTypeText,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeTextProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('');
|
|
13
|
+
|
|
14
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FieldTypeText
|
|
20
|
+
{...args}
|
|
21
|
+
value={value}
|
|
22
|
+
onChange={handleOnChange}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
Default.args = {
|
|
29
|
+
placeholder: 'Placeholder Text...',
|
|
30
|
+
label: 'Text label',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const TextArea = Template.bind({});
|
|
34
|
+
TextArea.args = {
|
|
35
|
+
multiline: true,
|
|
36
|
+
rows: 4,
|
|
37
|
+
placeholder: 'Placeholder Text...',
|
|
38
|
+
label: 'Text Label',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import { InputAdornment } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
export interface FieldTypeTextProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
5
|
+
/**
|
|
6
|
+
* Max length of the field
|
|
7
|
+
* @default 150
|
|
8
|
+
*/
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FieldTypeText = ({maxLength = 150, value, helperText, InputProps, InputLabelProps, ...props }: FieldTypeTextProps) => {
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<MuiTextField
|
|
17
|
+
size="small"
|
|
18
|
+
variant='outlined'
|
|
19
|
+
value={value}
|
|
20
|
+
InputProps={{
|
|
21
|
+
endAdornment: (
|
|
22
|
+
<InputAdornment position="end">
|
|
23
|
+
<>{value.length}/{maxLength}</>
|
|
24
|
+
</InputAdornment>
|
|
25
|
+
),
|
|
26
|
+
// Spread props at the end to allow Input prop overrides
|
|
27
|
+
...InputProps,
|
|
28
|
+
}}
|
|
29
|
+
InputLabelProps={{
|
|
30
|
+
shrink: true,
|
|
31
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
32
|
+
...InputLabelProps,
|
|
33
|
+
}}
|
|
34
|
+
error={value.length > maxLength}
|
|
35
|
+
helperText={value.length > maxLength ? 'Your input is over the specified limit' : helperText}
|
|
36
|
+
// Spread props at the end to allow prop overrides
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default FieldTypeText;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeUrl, { FieldTypeUrlProps } from './';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeUrl',
|
|
7
|
+
component: FieldTypeUrl,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeUrlProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('');
|
|
13
|
+
|
|
14
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FieldTypeUrl
|
|
20
|
+
{...args}
|
|
21
|
+
value={value}
|
|
22
|
+
onChange={handleOnChange}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
Default.args = {
|
|
29
|
+
placeholder: 'Placeholder Text...',
|
|
30
|
+
label: 'Some label',
|
|
31
|
+
fullWidth: true,
|
|
32
|
+
};
|
|
33
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
import { InputAdornment } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
export interface FieldTypeUrlProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
6
|
+
/**
|
|
7
|
+
* Max length of the field
|
|
8
|
+
* @default 2000
|
|
9
|
+
*/
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const FieldTypeUrl = ({maxLength = 2000, value, helperText, InputProps, InputLabelProps, inputProps, ...props }: FieldTypeUrlProps) => {
|
|
15
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<MuiTextField
|
|
19
|
+
size="small"
|
|
20
|
+
type='url'
|
|
21
|
+
variant='outlined'
|
|
22
|
+
value={value}
|
|
23
|
+
InputProps={{
|
|
24
|
+
endAdornment: (
|
|
25
|
+
<InputAdornment position="end">
|
|
26
|
+
<>{value.length}/{maxLength}</>
|
|
27
|
+
</InputAdornment>
|
|
28
|
+
),
|
|
29
|
+
// Spread props at the end to allow Input prop overrides
|
|
30
|
+
...InputProps,
|
|
31
|
+
}}
|
|
32
|
+
InputLabelProps={{
|
|
33
|
+
shrink: true,
|
|
34
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
35
|
+
...InputLabelProps,
|
|
36
|
+
}}
|
|
37
|
+
inputProps={{
|
|
38
|
+
ref: inputRef,
|
|
39
|
+
// Spread props at the end to allow inputProps prop overrides
|
|
40
|
+
...inputProps,
|
|
41
|
+
}}
|
|
42
|
+
error={(value && !inputRef.current?.validity.valid) || value.length > maxLength}
|
|
43
|
+
helperText={value.length > maxLength ? 'Your input is over the specified limit' : (value && !inputRef.current?.validity.valid) ? 'Your input is not a valid url' : helperText}
|
|
44
|
+
// Spread props at the end to allow prop overrides
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default FieldTypeUrl;
|
package/src/index.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export { default as theme } from './theme';
|
|
2
|
+
export { default as FieldTypeText } from './FieldTypeText';
|
|
3
|
+
export { default as FieldTypeSort } from './FieldTypeSort';
|
|
4
|
+
export { default as FieldTypeUrl } from './FieldTypeUrl';
|
|
5
|
+
export { default as FieldTypeDate } from './FieldTypeDate';
|
|
6
|
+
export { default as FieldTypeDateTime } from './FieldTypeDateTime';
|
|
7
|
+
export { default as FieldTypeColor } from './FieldTypeColor';
|
|
8
|
+
export { default as FieldTypeNumber } from './FieldTypeNumber';
|
|
9
|
+
export { default as FieldTypeDropdown } from './FieldTypeDropdown';
|
|
10
|
+
export { default as CopyButton } from './CopyButton';
|
|
11
|
+
export { default as ConfirmModal } from './ConfirmModal';
|
package/src/theme/index.ts
CHANGED
|
@@ -8,18 +8,57 @@ let theme: Theme = createTheme({
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
theme = createTheme(theme, {
|
|
11
|
-
|
|
11
|
+
components: {
|
|
12
|
+
MuiButton: {
|
|
12
13
|
styleOverrides: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
root: {
|
|
15
|
+
minWidth: 'auto',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
MuiTooltip: {
|
|
20
|
+
styleOverrides: {
|
|
21
|
+
tooltip: {
|
|
22
|
+
color: theme.palette.primary.contrastText,
|
|
23
|
+
backgroundColor: theme.palette.primary.main,
|
|
24
|
+
fontSize: '14px',
|
|
25
|
+
lineHeight: '20px',
|
|
26
|
+
},
|
|
27
|
+
arrow: {
|
|
28
|
+
color: theme.palette.primary.main,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
MuiInputBase: {
|
|
33
|
+
styleOverrides: {
|
|
34
|
+
root: {
|
|
35
|
+
backgroundColor: theme.palette.primary.contrastText,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
MuiFormLabel: {
|
|
40
|
+
styleOverrides: {
|
|
41
|
+
root: {
|
|
42
|
+
color: theme.palette.primary.dark,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
MuiToggleButton: {
|
|
47
|
+
styleOverrides: {
|
|
48
|
+
root: ({ ownerState, theme }: any) => ({
|
|
49
|
+
backgroundColor: `${
|
|
50
|
+
theme.palette[ownerState.color].contrastText
|
|
51
|
+
} !important`,
|
|
52
|
+
...(ownerState.selected && {
|
|
53
|
+
color: `${theme.palette[ownerState.color].contrastText} !important`,
|
|
54
|
+
backgroundColor: `${
|
|
55
|
+
theme.palette[ownerState.color].main
|
|
56
|
+
} !important`,
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
25
64
|
export default theme;
|