@zesty-io/material 0.0.4 → 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/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/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.js +2 -1
- package/es/FieldTypeSort/index.d.ts +1 -1
- package/es/FieldTypeSort/index.js +11 -13
- package/es/FieldTypeText/FieldTypeText.stories.js +2 -4
- package/es/index.d.ts +9 -0
- package/es/index.js +9 -0
- package/es/theme/index.js +10 -2
- package/package.json +4 -2
- package/src/ConfirmModal/ConfirmModal.stories.tsx +35 -0
- package/src/ConfirmModal/index.tsx +50 -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 +2 -2
- package/src/FieldTypeSort/index.tsx +11 -55
- package/src/FieldTypeText/FieldTypeText.stories.tsx +2 -4
- package/src/FieldTypeText/index.tsx +1 -2
- package/src/FieldTypeUrl/index.tsx +1 -1
- package/src/index.ts +9 -0
- package/src/theme/index.ts +12 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
2
|
+
import { ConfirmDialogProps } from '.';
|
|
3
|
+
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: Story<ConfirmDialogProps>;
|
|
6
|
+
export declare const CustomChildren: Story<ConfirmDialogProps>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Button } from '@mui/material';
|
|
4
|
+
import ConfirmDialog from '.';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'ConfirmDialog',
|
|
7
|
+
component: ConfirmDialog,
|
|
8
|
+
argType: {},
|
|
9
|
+
};
|
|
10
|
+
const Template = (args) => {
|
|
11
|
+
const [open, setOpen] = useState(false);
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "contained", onClick: () => setOpen(true), children: "Click me to open" }), _jsx(ConfirmDialog, { ...args, open: open, callback: (confirmed) => setOpen(false) })] }));
|
|
13
|
+
};
|
|
14
|
+
export const Default = Template.bind({});
|
|
15
|
+
Default.args = {
|
|
16
|
+
title: 'Confirm modal title',
|
|
17
|
+
content: 'Confirm modal content',
|
|
18
|
+
};
|
|
19
|
+
export const CustomChildren = Template.bind({});
|
|
20
|
+
CustomChildren.args = {
|
|
21
|
+
title: 'Confirm modal title',
|
|
22
|
+
content: 'Confirm modal content',
|
|
23
|
+
children: _jsxs(_Fragment, { children: [_jsx(Button, { color: "error", variant: "contained", children: "Custom 1" }), _jsx(Button, { color: "success", variant: "contained", children: "Custom 2" })] })
|
|
24
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DialogProps } from '@mui/material/Dialog';
|
|
3
|
+
export interface ConfirmDialogProps extends Omit<DialogProps, 'title'> {
|
|
4
|
+
/**
|
|
5
|
+
* Title of confirm dialog
|
|
6
|
+
*/
|
|
7
|
+
title: string | ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Content of confirm dialog
|
|
10
|
+
*/
|
|
11
|
+
content: string | ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Callback of confirm dialog
|
|
14
|
+
*/
|
|
15
|
+
callback: (confirmed: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const ConfirmDialog: ({ title, content, onClose, children, callback, ...props }: ConfirmDialogProps) => JSX.Element;
|
|
18
|
+
export default ConfirmDialog;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Dialog from '@mui/material/Dialog';
|
|
3
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
4
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
5
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
6
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
7
|
+
import { Button } from '@mui/material';
|
|
8
|
+
const ConfirmDialog = ({ title, content, onClose, children, callback, ...props }) => {
|
|
9
|
+
return (_jsxs(Dialog, { ...props, children: [_jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: content }) }), children ? _jsx(DialogActions, { children: children }) : (_jsxs(DialogActions, { children: [_jsx(Button, { variant: "contained", onClick: () => callback(false), children: "No" }), _jsx(Button, { variant: "contained", onClick: () => callback(true), autoFocus: true, children: "Yes" })] }))] }));
|
|
10
|
+
};
|
|
11
|
+
export default ConfirmDialog;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeColor from './';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeColor',
|
|
6
|
+
component: FieldTypeColor,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState('');
|
|
11
|
+
const handleOnChange = (e) => {
|
|
12
|
+
setValue(e.target.value);
|
|
13
|
+
};
|
|
14
|
+
return (_jsx(FieldTypeColor, { ...args, value: value, onChange: handleOnChange }));
|
|
15
|
+
};
|
|
16
|
+
export const Default = Template.bind({});
|
|
17
|
+
Default.args = {
|
|
18
|
+
placeholder: 'Placeholder Text...',
|
|
19
|
+
label: 'Color label',
|
|
20
|
+
helperText: 'Color helper text',
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
export interface FieldTypeColorProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
4
|
+
}
|
|
5
|
+
declare const FieldTypeColor: ({ InputProps, InputLabelProps, ...props }: FieldTypeColorProps) => JSX.Element;
|
|
6
|
+
export default FieldTypeColor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import MuiTextField from '@mui/material/TextField';
|
|
3
|
+
import { Button, InputAdornment } from '@mui/material';
|
|
4
|
+
import BrushIcon from '@mui/icons-material/Brush';
|
|
5
|
+
const FieldTypeColor = ({ InputProps, InputLabelProps, ...props }) => {
|
|
6
|
+
return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'color', InputProps: {
|
|
7
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
|
|
8
|
+
// References color input via event in order to open color picker
|
|
9
|
+
const input = e.currentTarget?.parentElement?.parentElement?.firstElementChild;
|
|
10
|
+
input?.click();
|
|
11
|
+
}, children: _jsx(BrushIcon, { fontSize: 'small' }) }) })),
|
|
12
|
+
// Spread props at the end to allow Input prop overrides
|
|
13
|
+
...InputProps,
|
|
14
|
+
}, InputLabelProps: {
|
|
15
|
+
shrink: true,
|
|
16
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
17
|
+
...InputLabelProps,
|
|
18
|
+
}, ...props }));
|
|
19
|
+
};
|
|
20
|
+
export default FieldTypeColor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeDate from '.';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeDate',
|
|
6
|
+
component: FieldTypeDate,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState(null);
|
|
11
|
+
return (_jsx(FieldTypeDate, { ...args, value: value, onChange: (value) => setValue(value) }));
|
|
12
|
+
};
|
|
13
|
+
export const Default = Template.bind({});
|
|
14
|
+
Default.args = {
|
|
15
|
+
label: 'Date label',
|
|
16
|
+
textFieldProps: {
|
|
17
|
+
helperText: 'Date helper text',
|
|
18
|
+
error: false,
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
|
+
import { TextFieldProps } from '@mui/material';
|
|
4
|
+
export interface FieldTypeDateProps extends Omit<DatePickerProps<Date, Date>, 'renderInput'> {
|
|
5
|
+
/**
|
|
6
|
+
* Props passed to TextField component
|
|
7
|
+
*/
|
|
8
|
+
textFieldProps?: TextFieldProps;
|
|
9
|
+
}
|
|
10
|
+
declare const FieldTypeDate: ({ textFieldProps, ...props }: FieldTypeDateProps) => JSX.Element;
|
|
11
|
+
export default FieldTypeDate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
4
|
+
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
5
|
+
import { TextField } from '@mui/material';
|
|
6
|
+
;
|
|
7
|
+
const FieldTypeDate = ({ textFieldProps, ...props }) => {
|
|
8
|
+
return (_jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { InputLabelProps: {
|
|
9
|
+
shrink: true,
|
|
10
|
+
// Spread props at the end to allow InputLabelProps overrides
|
|
11
|
+
...textFieldProps?.InputLabelProps,
|
|
12
|
+
}, ...params, ...textFieldProps }), ...props }) }));
|
|
13
|
+
};
|
|
14
|
+
export default FieldTypeDate;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeDateTime from '.';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeDateTime',
|
|
6
|
+
component: FieldTypeDateTime,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState(null);
|
|
11
|
+
return (_jsx(FieldTypeDateTime, { ...args, value: value, onChange: (value) => setValue(value) }));
|
|
12
|
+
};
|
|
13
|
+
export const Default = Template.bind({});
|
|
14
|
+
Default.args = {
|
|
15
|
+
label: 'Date label',
|
|
16
|
+
textFieldProps: {
|
|
17
|
+
helperText: 'Date helper text',
|
|
18
|
+
error: false,
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';
|
|
3
|
+
import { TextFieldProps } from '@mui/material';
|
|
4
|
+
export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<Date, Date>, 'renderInput'> {
|
|
5
|
+
/**
|
|
6
|
+
* Props passed to TextField component
|
|
7
|
+
*/
|
|
8
|
+
textFieldProps?: TextFieldProps;
|
|
9
|
+
}
|
|
10
|
+
declare const FieldTypeDateTime: ({ textFieldProps, ...props }: FieldTypeDateTimeProps) => JSX.Element;
|
|
11
|
+
export default FieldTypeDateTime;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
4
|
+
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
|
5
|
+
import { TextField } from '@mui/material';
|
|
6
|
+
;
|
|
7
|
+
const FieldTypeDateTime = ({ textFieldProps, ...props }) => {
|
|
8
|
+
return (_jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DateTimePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { InputLabelProps: {
|
|
9
|
+
shrink: true,
|
|
10
|
+
// Spread props at the end to allow InputLabelProps overrides
|
|
11
|
+
...textFieldProps?.InputLabelProps,
|
|
12
|
+
}, ...params, ...textFieldProps }), ...props }) }));
|
|
13
|
+
};
|
|
14
|
+
export default FieldTypeDateTime;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeDropdown from './';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeDropdown',
|
|
6
|
+
component: FieldTypeDropdown,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const options = [
|
|
10
|
+
{
|
|
11
|
+
value: 'option1',
|
|
12
|
+
label: 'Option 1',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: 'option2',
|
|
16
|
+
label: 'Option 2',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 'option3',
|
|
20
|
+
label: 'Option 3',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
const Template = (args) => {
|
|
24
|
+
const [value, setValue] = useState('');
|
|
25
|
+
const handleOnChange = (e) => {
|
|
26
|
+
setValue(e.target.value);
|
|
27
|
+
};
|
|
28
|
+
return (_jsx(FieldTypeDropdown, { ...args, value: value, onChange: handleOnChange, options: options }));
|
|
29
|
+
};
|
|
30
|
+
export const Default = Template.bind({});
|
|
31
|
+
Default.args = {
|
|
32
|
+
placeholder: 'Placeholder Text...',
|
|
33
|
+
label: 'Number label',
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
interface Option {
|
|
4
|
+
label: string;
|
|
5
|
+
value: any;
|
|
6
|
+
}
|
|
7
|
+
export interface FieldTypeDropdownProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
8
|
+
options: Option[];
|
|
9
|
+
}
|
|
10
|
+
declare const FieldTypeDropdown: ({ InputLabelProps, options, ...props }: FieldTypeDropdownProps) => JSX.Element;
|
|
11
|
+
export default FieldTypeDropdown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItem } from '@mui/material';
|
|
3
|
+
import MuiTextField from '@mui/material/TextField';
|
|
4
|
+
const FieldTypeDropdown = ({ InputLabelProps, options, ...props }) => {
|
|
5
|
+
return (_jsxs(MuiTextField, { size: "small", variant: 'outlined', select: true, InputLabelProps: {
|
|
6
|
+
shrink: true,
|
|
7
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
8
|
+
...InputLabelProps,
|
|
9
|
+
},
|
|
10
|
+
// Spread props at the end to allow prop overrides
|
|
11
|
+
SelectProps: {
|
|
12
|
+
displayEmpty: true,
|
|
13
|
+
}, ...props, children: [_jsx(MenuItem, { value: '', children: "- None -" }, ''), options.map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.value)))] }));
|
|
14
|
+
};
|
|
15
|
+
export default FieldTypeDropdown;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeNumber from './';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeNumber',
|
|
6
|
+
component: FieldTypeNumber,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState('0');
|
|
11
|
+
const handleOnChange = (e) => {
|
|
12
|
+
setValue(e.target.value);
|
|
13
|
+
};
|
|
14
|
+
return (_jsx(FieldTypeNumber, { ...args, value: value, onChange: handleOnChange }));
|
|
15
|
+
};
|
|
16
|
+
export const Default = Template.bind({});
|
|
17
|
+
Default.args = {
|
|
18
|
+
placeholder: 'Placeholder Text...',
|
|
19
|
+
label: 'Number label',
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
export interface FieldTypeNumberProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
4
|
+
}
|
|
5
|
+
declare const FieldTypeText: ({ InputLabelProps, ...props }: FieldTypeNumberProps) => JSX.Element;
|
|
6
|
+
export default FieldTypeText;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import MuiTextField from '@mui/material/TextField';
|
|
3
|
+
const FieldTypeText = ({ InputLabelProps, ...props }) => {
|
|
4
|
+
return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', InputLabelProps: {
|
|
5
|
+
shrink: true,
|
|
6
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
7
|
+
...InputLabelProps,
|
|
8
|
+
}, ...props }));
|
|
9
|
+
};
|
|
10
|
+
export default FieldTypeText;
|
|
@@ -3,5 +3,5 @@ import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
4
4
|
value: string;
|
|
5
5
|
}
|
|
6
|
-
declare const FieldTypeSort: ({ value, InputProps, InputLabelProps,
|
|
6
|
+
declare const FieldTypeSort: ({ value, InputProps, InputLabelProps, sx, ...props }: FieldTypeSortProps) => JSX.Element;
|
|
7
7
|
export default FieldTypeSort;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from 'react';
|
|
3
2
|
import MuiTextField from '@mui/material/TextField';
|
|
4
3
|
import { Button, InputAdornment } from '@mui/material';
|
|
5
4
|
import AddIcon from '@mui/icons-material/Add';
|
|
6
5
|
import RemoveIcon from '@mui/icons-material/Remove';
|
|
7
|
-
const FieldTypeSort = ({ value, InputProps, InputLabelProps,
|
|
8
|
-
const inputRef = useRef(null);
|
|
6
|
+
const FieldTypeSort = ({ value, InputProps, InputLabelProps, sx, ...props }) => {
|
|
9
7
|
return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', value: value, sx: {
|
|
10
8
|
width: 165,
|
|
11
9
|
// Spread props at the end to allow sx prop overrides
|
|
12
10
|
...sx
|
|
13
11
|
}, InputProps: {
|
|
14
|
-
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(Button, { size: "small", variant: "contained", onClick: () => {
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
|
|
13
|
+
// References input via event in order to modify its value
|
|
14
|
+
const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
|
|
15
|
+
console.log('testing input', input);
|
|
16
|
+
input.value = String(+input.value + 1);
|
|
17
17
|
}, children: _jsx(AddIcon, { fontSize: 'small' }) }) })),
|
|
18
|
-
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: () => {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
|
|
19
|
+
// References input via event in order to modify its value
|
|
20
|
+
const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
|
|
21
|
+
console.log('testing input', input);
|
|
22
|
+
input.value = String(+input.value - 1);
|
|
21
23
|
}, children: _jsx(RemoveIcon, { fontSize: 'small' }) }) })),
|
|
22
24
|
// Spread props at the end to allow Input prop overrides
|
|
23
25
|
...InputProps,
|
|
@@ -25,10 +27,6 @@ const FieldTypeSort = ({ value, InputProps, InputLabelProps, inputProps, sx, ...
|
|
|
25
27
|
shrink: true,
|
|
26
28
|
// Spread props at the end to allow InputLabel prop overrides
|
|
27
29
|
...InputLabelProps,
|
|
28
|
-
}, inputProps: {
|
|
29
|
-
ref: inputRef,
|
|
30
|
-
// Spread props at the end to allow inputProps prop overrides
|
|
31
|
-
...inputProps,
|
|
32
30
|
}, ...props }));
|
|
33
31
|
};
|
|
34
32
|
export default FieldTypeSort;
|
|
@@ -16,14 +16,12 @@ const Template = (args) => {
|
|
|
16
16
|
export const Default = Template.bind({});
|
|
17
17
|
Default.args = {
|
|
18
18
|
placeholder: 'Placeholder Text...',
|
|
19
|
-
label: '
|
|
20
|
-
fullWidth: true,
|
|
19
|
+
label: 'Text label',
|
|
21
20
|
};
|
|
22
21
|
export const TextArea = Template.bind({});
|
|
23
22
|
TextArea.args = {
|
|
24
23
|
multiline: true,
|
|
25
24
|
rows: 4,
|
|
26
25
|
placeholder: 'Placeholder Text...',
|
|
27
|
-
label: '
|
|
28
|
-
fullWidth: true,
|
|
26
|
+
label: 'Text Label',
|
|
29
27
|
};
|
package/es/index.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export { default as theme } from './theme';
|
|
2
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/es/index.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export { default as theme } from './theme';
|
|
2
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/es/theme/index.js
CHANGED
|
@@ -11,8 +11,8 @@ theme = createTheme(theme, {
|
|
|
11
11
|
styleOverrides: {
|
|
12
12
|
root: {
|
|
13
13
|
minWidth: 'auto',
|
|
14
|
-
}
|
|
15
|
-
}
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
16
|
},
|
|
17
17
|
MuiTooltip: {
|
|
18
18
|
styleOverrides: {
|
|
@@ -34,9 +34,17 @@ theme = createTheme(theme, {
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
+
MuiFormLabel: {
|
|
38
|
+
styleOverrides: {
|
|
39
|
+
root: {
|
|
40
|
+
color: theme.palette.primary.dark,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
37
44
|
MuiToggleButton: {
|
|
38
45
|
styleOverrides: {
|
|
39
46
|
root: ({ ownerState, theme }) => ({
|
|
47
|
+
backgroundColor: `${theme.palette[ownerState.color].contrastText} !important`,
|
|
40
48
|
...(ownerState.selected && {
|
|
41
49
|
color: `${theme.palette[ownerState.color].contrastText} !important`,
|
|
42
50
|
backgroundColor: `${theme.palette[ownerState.color].main} !important`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zesty-io/material",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Contains custom components which are in addition to the @mui design-system",
|
|
5
5
|
"author": "Zesty.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"@emotion/react": "^11.9.0",
|
|
31
31
|
"@emotion/styled": "^11.8.1",
|
|
32
32
|
"@mui/icons-material": "^5.6.2",
|
|
33
|
-
"@mui/material": "^5.6.4"
|
|
33
|
+
"@mui/material": "^5.6.4",
|
|
34
|
+
"@mui/x-date-pickers": "^5.0.0-alpha.5",
|
|
35
|
+
"date-fns": "^2.28.0"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@babel/core": "^7.17.10",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import { Button, Stack } from '@mui/material';
|
|
4
|
+
import ConfirmDialog, { ConfirmDialogProps } from '.';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'ConfirmDialog',
|
|
8
|
+
component: ConfirmDialog,
|
|
9
|
+
argType: {},
|
|
10
|
+
} as Meta;
|
|
11
|
+
|
|
12
|
+
const Template: Story<ConfirmDialogProps> = (args) => {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Button variant="contained" onClick={() => setOpen(true)}>Click me to open</Button>
|
|
18
|
+
<ConfirmDialog {...args} open={open} callback={(confirmed) => setOpen(false) } />
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Default = Template.bind({});
|
|
24
|
+
Default.args = {
|
|
25
|
+
title: 'Confirm modal title',
|
|
26
|
+
content: 'Confirm modal content',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const CustomChildren = Template.bind({});
|
|
30
|
+
CustomChildren.args = {
|
|
31
|
+
title: 'Confirm modal title',
|
|
32
|
+
content: 'Confirm modal content',
|
|
33
|
+
children: <><Button color="error" variant="contained">Custom 1</Button><Button color="success" variant="contained">Custom 2</Button></>
|
|
34
|
+
};
|
|
35
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import Dialog, { DialogProps } from '@mui/material/Dialog';
|
|
3
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
4
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
5
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
6
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
7
|
+
import { Button } from '@mui/material';
|
|
8
|
+
|
|
9
|
+
export interface ConfirmDialogProps extends Omit<DialogProps, 'title'> {
|
|
10
|
+
/**
|
|
11
|
+
* Title of confirm dialog
|
|
12
|
+
*/
|
|
13
|
+
title: string | ReactNode ;
|
|
14
|
+
/**
|
|
15
|
+
* Content of confirm dialog
|
|
16
|
+
*/
|
|
17
|
+
content: string | ReactNode ;
|
|
18
|
+
/**
|
|
19
|
+
* Callback of confirm dialog
|
|
20
|
+
*/
|
|
21
|
+
callback: (confirmed: boolean) => void ;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ConfirmDialog = ({title, content, onClose, children, callback, ...props }: ConfirmDialogProps) => {
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Dialog
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
<DialogTitle>
|
|
31
|
+
{title}
|
|
32
|
+
</DialogTitle>
|
|
33
|
+
<DialogContent>
|
|
34
|
+
<DialogContentText>
|
|
35
|
+
{content}
|
|
36
|
+
</DialogContentText>
|
|
37
|
+
</DialogContent>
|
|
38
|
+
{children ? <DialogActions>{children}</DialogActions> : (
|
|
39
|
+
<DialogActions>
|
|
40
|
+
<Button variant="contained" onClick={() => callback(false)}>No</Button>
|
|
41
|
+
<Button variant="contained" onClick={() => callback(true)} autoFocus>
|
|
42
|
+
Yes
|
|
43
|
+
</Button>
|
|
44
|
+
</DialogActions>
|
|
45
|
+
)}
|
|
46
|
+
</Dialog>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default ConfirmDialog;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeColor, { FieldTypeColorProps } from './';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeColor',
|
|
7
|
+
component: FieldTypeColor,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeColorProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('');
|
|
13
|
+
|
|
14
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FieldTypeColor
|
|
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: 'Color label',
|
|
31
|
+
helperText: 'Color helper text',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
import { Button, InputAdornment } from '@mui/material';
|
|
4
|
+
import BrushIcon from '@mui/icons-material/Brush';
|
|
5
|
+
|
|
6
|
+
export interface FieldTypeColorProps extends Omit<OutlinedTextFieldProps, 'variant'> {}
|
|
7
|
+
|
|
8
|
+
const FieldTypeColor = ({InputProps, InputLabelProps, ...props }: FieldTypeColorProps) => {
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<MuiTextField
|
|
12
|
+
size="small"
|
|
13
|
+
variant='outlined'
|
|
14
|
+
type='color'
|
|
15
|
+
InputProps={{
|
|
16
|
+
endAdornment: (
|
|
17
|
+
<InputAdornment position="end">
|
|
18
|
+
<Button
|
|
19
|
+
size="small"
|
|
20
|
+
variant="contained"
|
|
21
|
+
onClick={(e) => {
|
|
22
|
+
// References color input via event in order to open color picker
|
|
23
|
+
const input = e.currentTarget?.parentElement?.parentElement?.firstElementChild as HTMLInputElement;
|
|
24
|
+
input?.click()
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<BrushIcon fontSize='small' />
|
|
28
|
+
</Button>
|
|
29
|
+
</InputAdornment>
|
|
30
|
+
),
|
|
31
|
+
// Spread props at the end to allow Input prop overrides
|
|
32
|
+
...InputProps,
|
|
33
|
+
}}
|
|
34
|
+
InputLabelProps={{
|
|
35
|
+
shrink: true,
|
|
36
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
37
|
+
...InputLabelProps,
|
|
38
|
+
}}
|
|
39
|
+
// Spread props at the end to allow prop overrides
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default FieldTypeColor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {useState} from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeDate, { FieldTypeDateProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeDate',
|
|
7
|
+
component: FieldTypeDate,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeDateProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<FieldTypeDate {...args} value={value} onChange={(value) => setValue(value)}/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Default = Template.bind({});
|
|
20
|
+
Default.args = {
|
|
21
|
+
label: 'Date label',
|
|
22
|
+
textFieldProps: {
|
|
23
|
+
helperText: 'Date helper text',
|
|
24
|
+
error: false,
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
2
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
3
|
+
import { DatePicker, DatePickerProps} from '@mui/x-date-pickers/DatePicker';
|
|
4
|
+
import { TextField, TextFieldProps } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
export interface FieldTypeDateProps extends Omit<DatePickerProps<Date, Date>, 'renderInput'> {
|
|
7
|
+
/**
|
|
8
|
+
* Props passed to TextField component
|
|
9
|
+
*/
|
|
10
|
+
textFieldProps?: TextFieldProps;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const FieldTypeDate = ({textFieldProps, ...props}: FieldTypeDateProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
16
|
+
<DatePicker
|
|
17
|
+
data-testid="zds-date-picker"
|
|
18
|
+
renderInput={(params) =>
|
|
19
|
+
<TextField
|
|
20
|
+
InputLabelProps={{
|
|
21
|
+
shrink: true,
|
|
22
|
+
// Spread props at the end to allow InputLabelProps overrides
|
|
23
|
+
...textFieldProps?.InputLabelProps,
|
|
24
|
+
}}
|
|
25
|
+
{...params}
|
|
26
|
+
// Spread props at the end to allow textFieldProps overrides
|
|
27
|
+
{...textFieldProps}
|
|
28
|
+
/>
|
|
29
|
+
}
|
|
30
|
+
// Spread props at the end to allow prop overrides
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
</LocalizationProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default FieldTypeDate;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {useState} from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeDateTime, { FieldTypeDateTimeProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeDateTime',
|
|
7
|
+
component: FieldTypeDateTime,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeDateTimeProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<FieldTypeDateTime {...args} value={value} onChange={(value) => setValue(value)}/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Default = Template.bind({});
|
|
20
|
+
Default.args = {
|
|
21
|
+
label: 'Date label',
|
|
22
|
+
textFieldProps: {
|
|
23
|
+
helperText: 'Date helper text',
|
|
24
|
+
error: false,
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
2
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
3
|
+
import { DateTimePicker, DateTimePickerProps} from '@mui/x-date-pickers/DateTimePicker';
|
|
4
|
+
import { TextField, TextFieldProps } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<Date, Date>, 'renderInput'> {
|
|
7
|
+
/**
|
|
8
|
+
* Props passed to TextField component
|
|
9
|
+
*/
|
|
10
|
+
textFieldProps?: TextFieldProps;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const FieldTypeDateTime = ({textFieldProps, ...props}: FieldTypeDateTimeProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
16
|
+
<DateTimePicker
|
|
17
|
+
data-testid="zds-date-picker"
|
|
18
|
+
renderInput={(params) =>
|
|
19
|
+
<TextField
|
|
20
|
+
InputLabelProps={{
|
|
21
|
+
shrink: true,
|
|
22
|
+
// Spread props at the end to allow InputLabelProps overrides
|
|
23
|
+
...textFieldProps?.InputLabelProps,
|
|
24
|
+
}}
|
|
25
|
+
{...params}
|
|
26
|
+
// Spread props at the end to allow textFieldProps overrides
|
|
27
|
+
{...textFieldProps}
|
|
28
|
+
/>
|
|
29
|
+
}
|
|
30
|
+
// Spread props at the end to allow prop overrides
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
</LocalizationProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default FieldTypeDateTime;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeDropdown, { FieldTypeDropdownProps } from './';
|
|
4
|
+
import { MenuItem } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'FieldTypeDropdown',
|
|
8
|
+
component: FieldTypeDropdown,
|
|
9
|
+
argType: {},
|
|
10
|
+
} as Meta;
|
|
11
|
+
|
|
12
|
+
const options = [
|
|
13
|
+
{
|
|
14
|
+
value: 'option1',
|
|
15
|
+
label: 'Option 1',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: 'option2',
|
|
19
|
+
label: 'Option 2',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: 'option3',
|
|
23
|
+
label: 'Option 3',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const Template: Story<FieldTypeDropdownProps> = (args) => {
|
|
28
|
+
const [value, setValue] = useState('');
|
|
29
|
+
|
|
30
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
31
|
+
setValue(e.target.value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<FieldTypeDropdown
|
|
36
|
+
{...args}
|
|
37
|
+
value={value}
|
|
38
|
+
onChange={handleOnChange}
|
|
39
|
+
options={options}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Default = Template.bind({});
|
|
45
|
+
Default.args = {
|
|
46
|
+
placeholder: 'Placeholder Text...',
|
|
47
|
+
label: 'Number label',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MenuItem } from '@mui/material';
|
|
2
|
+
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
|
|
4
|
+
interface Option {
|
|
5
|
+
label: string;
|
|
6
|
+
value: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FieldTypeDropdownProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
10
|
+
options: Option[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FieldTypeDropdown = ({InputLabelProps, options, ...props }: FieldTypeDropdownProps) => {
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<MuiTextField
|
|
17
|
+
size="small"
|
|
18
|
+
variant='outlined'
|
|
19
|
+
select
|
|
20
|
+
InputLabelProps={{
|
|
21
|
+
shrink: true,
|
|
22
|
+
// Spread props at the end to allow InputLabel prop overrides
|
|
23
|
+
...InputLabelProps,
|
|
24
|
+
}}
|
|
25
|
+
// Spread props at the end to allow prop overrides
|
|
26
|
+
SelectProps={{
|
|
27
|
+
displayEmpty: true,
|
|
28
|
+
}}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
<MenuItem key={''} value={''}>
|
|
32
|
+
- None -
|
|
33
|
+
</MenuItem>
|
|
34
|
+
{options.map((option) => (
|
|
35
|
+
<MenuItem key={option.value} value={option.value}>
|
|
36
|
+
{option.label}
|
|
37
|
+
</MenuItem>
|
|
38
|
+
))}
|
|
39
|
+
</MuiTextField>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default FieldTypeDropdown;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
import FieldTypeNumber, { FieldTypeNumberProps } from './';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FieldTypeNumber',
|
|
7
|
+
component: FieldTypeNumber,
|
|
8
|
+
argType: {},
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<FieldTypeNumberProps> = (args) => {
|
|
12
|
+
const [value, setValue] = useState('0');
|
|
13
|
+
|
|
14
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FieldTypeNumber
|
|
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: 'Number label',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
@@ -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;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ChangeEvent, useState } from 'react';
|
|
2
2
|
import { Story, Meta } from '@storybook/react/types-6-0';
|
|
3
|
-
import { TextFieldProps } from '@mui/material';
|
|
4
3
|
import FieldTypeSort, { FieldTypeSortProps } from './';
|
|
5
4
|
|
|
6
5
|
export default {
|
|
@@ -28,7 +27,8 @@ const Template: Story<FieldTypeSortProps> = (args) => {
|
|
|
28
27
|
export const Default = Template.bind({});
|
|
29
28
|
Default.args = {
|
|
30
29
|
placeholder: 'Placeholder Text...',
|
|
31
|
-
label: '
|
|
30
|
+
label: 'Sort label',
|
|
31
|
+
helperText: 'Sort helper text',
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React, { ChangeEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
1
|
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
2
|
import { Button, InputAdornment } from '@mui/material';
|
|
4
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
@@ -8,9 +7,7 @@ export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'varian
|
|
|
8
7
|
value: string;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
const FieldTypeSort = ({value, InputProps, InputLabelProps,
|
|
12
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
13
|
-
|
|
10
|
+
const FieldTypeSort = ({value, InputProps, InputLabelProps, sx, ...props }: FieldTypeSortProps) => {
|
|
14
11
|
return (
|
|
15
12
|
<MuiTextField
|
|
16
13
|
size="small"
|
|
@@ -28,8 +25,11 @@ const FieldTypeSort = ({value, InputProps, InputLabelProps, inputProps, sx, ...p
|
|
|
28
25
|
<Button
|
|
29
26
|
size="small"
|
|
30
27
|
variant="contained"
|
|
31
|
-
onClick={() => {
|
|
32
|
-
|
|
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
33
|
}}><AddIcon fontSize='small' />
|
|
34
34
|
</Button>
|
|
35
35
|
</InputAdornment>
|
|
@@ -39,8 +39,11 @@ const FieldTypeSort = ({value, InputProps, InputLabelProps, inputProps, sx, ...p
|
|
|
39
39
|
<Button
|
|
40
40
|
size="small"
|
|
41
41
|
variant="contained"
|
|
42
|
-
onClick={() => {
|
|
43
|
-
|
|
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)
|
|
44
47
|
}}><RemoveIcon fontSize='small' />
|
|
45
48
|
</Button>
|
|
46
49
|
</InputAdornment>
|
|
@@ -53,11 +56,6 @@ const FieldTypeSort = ({value, InputProps, InputLabelProps, inputProps, sx, ...p
|
|
|
53
56
|
// Spread props at the end to allow InputLabel prop overrides
|
|
54
57
|
...InputLabelProps,
|
|
55
58
|
}}
|
|
56
|
-
inputProps={{
|
|
57
|
-
ref: inputRef,
|
|
58
|
-
// Spread props at the end to allow inputProps prop overrides
|
|
59
|
-
...inputProps,
|
|
60
|
-
}}
|
|
61
59
|
// Spread props at the end to allow prop overrides
|
|
62
60
|
{...props}
|
|
63
61
|
/>
|
|
@@ -65,45 +63,3 @@ const FieldTypeSort = ({value, InputProps, InputLabelProps, inputProps, sx, ...p
|
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
export default FieldTypeSort;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// const FieldTypeSort = ({InputProps, InputLabelProps, ...props }: FieldTypeSortProps) => {
|
|
71
|
-
|
|
72
|
-
// return (
|
|
73
|
-
// <MuiTextField
|
|
74
|
-
// variant='outlined'
|
|
75
|
-
// type='number'
|
|
76
|
-
// InputProps={{
|
|
77
|
-
// startAdornment: (
|
|
78
|
-
// <InputAdornment position="start">
|
|
79
|
-
// <Button
|
|
80
|
-
// variant="contained"
|
|
81
|
-
// onClick={() => {
|
|
82
|
-
// callback(props.value + 1)
|
|
83
|
-
// }}>+</Button>
|
|
84
|
-
// </InputAdornment>
|
|
85
|
-
// ),
|
|
86
|
-
// endAdornment: (
|
|
87
|
-
// <InputAdornment position="end">
|
|
88
|
-
// <Button
|
|
89
|
-
// variant="contained"
|
|
90
|
-
// onClick={() => {
|
|
91
|
-
// callback(props.value - 1)
|
|
92
|
-
// }}>-</Button>
|
|
93
|
-
// </InputAdornment>
|
|
94
|
-
// ),
|
|
95
|
-
// // Spread props at the end to allow Input prop overrides
|
|
96
|
-
// ...InputProps,
|
|
97
|
-
// }}
|
|
98
|
-
// InputLabelProps={{
|
|
99
|
-
// shrink: true,
|
|
100
|
-
// // Spread props at the end to allow InputLabel prop overrides
|
|
101
|
-
// ...InputLabelProps,
|
|
102
|
-
// }}
|
|
103
|
-
// // Spread props at the end to allow prop overrides
|
|
104
|
-
// {...props}
|
|
105
|
-
// />
|
|
106
|
-
// );
|
|
107
|
-
// };
|
|
108
|
-
|
|
109
|
-
// export default FieldTypeSort;
|
|
@@ -27,8 +27,7 @@ const Template: Story<FieldTypeTextProps> = (args) => {
|
|
|
27
27
|
export const Default = Template.bind({});
|
|
28
28
|
Default.args = {
|
|
29
29
|
placeholder: 'Placeholder Text...',
|
|
30
|
-
label: '
|
|
31
|
-
fullWidth: true,
|
|
30
|
+
label: 'Text label',
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
export const TextArea = Template.bind({});
|
|
@@ -36,8 +35,7 @@ TextArea.args = {
|
|
|
36
35
|
multiline: true,
|
|
37
36
|
rows: 4,
|
|
38
37
|
placeholder: 'Placeholder Text...',
|
|
39
|
-
label: '
|
|
40
|
-
fullWidth: true,
|
|
38
|
+
label: 'Text Label',
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { ChangeEvent, ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
1
|
import MuiTextField, { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
-
import {
|
|
2
|
+
import { InputAdornment } from '@mui/material';
|
|
4
3
|
|
|
5
4
|
export interface FieldTypeTextProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
6
5
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export { default as theme } from './theme';
|
|
2
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
|
@@ -13,8 +13,8 @@ theme = createTheme(theme, {
|
|
|
13
13
|
styleOverrides: {
|
|
14
14
|
root: {
|
|
15
15
|
minWidth: 'auto',
|
|
16
|
-
}
|
|
17
|
-
}
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
18
|
},
|
|
19
19
|
MuiTooltip: {
|
|
20
20
|
styleOverrides: {
|
|
@@ -36,9 +36,19 @@ theme = createTheme(theme, {
|
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
|
+
MuiFormLabel: {
|
|
40
|
+
styleOverrides: {
|
|
41
|
+
root: {
|
|
42
|
+
color: theme.palette.primary.dark,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
39
46
|
MuiToggleButton: {
|
|
40
47
|
styleOverrides: {
|
|
41
48
|
root: ({ ownerState, theme }: any) => ({
|
|
49
|
+
backgroundColor: `${
|
|
50
|
+
theme.palette[ownerState.color].contrastText
|
|
51
|
+
} !important`,
|
|
42
52
|
...(ownerState.selected && {
|
|
43
53
|
color: `${theme.palette[ownerState.color].contrastText} !important`,
|
|
44
54
|
backgroundColor: `${
|