@zesty-io/material 0.2.5 → 0.3.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/ConfirmDialog/ConfirmDialog.stories.d.ts +6 -0
- package/es/ConfirmDialog/ConfirmDialog.stories.js +24 -0
- package/es/ConfirmDialog/index.d.ts +18 -0
- package/es/ConfirmDialog/index.js +11 -0
- 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 +16 -0
- package/es/FieldTypeDate/FieldTypeDate.stories.d.ts +5 -0
- package/es/FieldTypeDate/FieldTypeDate.stories.js +17 -0
- package/es/FieldTypeDate/index.d.ts +9 -0
- package/es/FieldTypeDate/index.js +10 -0
- package/es/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +5 -0
- package/es/FieldTypeDateTime/FieldTypeDateTime.stories.js +17 -0
- package/es/FieldTypeDateTime/index.d.ts +9 -0
- package/es/FieldTypeDateTime/index.js +10 -0
- package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.d.ts +5 -0
- package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.js +35 -0
- package/es/FieldTypeDropdown/index.d.ts +11 -0
- package/es/FieldTypeDropdown/index.js +10 -0
- package/es/FieldTypeNumber/FieldTypeNumber.stories.d.ts +5 -0
- package/es/FieldTypeNumber/FieldTypeNumber.stories.js +21 -0
- package/es/FieldTypeNumber/index.d.ts +6 -0
- package/es/FieldTypeNumber/index.js +7 -0
- package/es/FieldTypeOneToMany/FieldTypeOneToMany.stories.d.ts +5 -0
- package/es/FieldTypeOneToMany/FieldTypeOneToMany.stories.js +28 -0
- package/es/FieldTypeOneToMany/index.d.ts +32 -0
- package/es/FieldTypeOneToMany/index.js +29 -0
- package/es/FieldTypeOneToOne/FieldTypeOneToOne.stories.d.ts +5 -0
- package/es/FieldTypeOneToOne/FieldTypeOneToOne.stories.js +28 -0
- package/es/FieldTypeOneToOne/index.d.ts +34 -0
- package/es/FieldTypeOneToOne/index.js +33 -0
- package/es/FieldTypeSort/FieldTypeSort.stories.d.ts +5 -0
- package/es/FieldTypeSort/FieldTypeSort.stories.js +22 -0
- package/es/FieldTypeSort/index.d.ts +7 -0
- package/es/FieldTypeSort/index.js +34 -0
- package/es/FieldTypeText/FieldTypeText.stories.d.ts +6 -0
- package/es/FieldTypeText/FieldTypeText.stories.js +29 -0
- package/es/FieldTypeText/index.d.ts +12 -0
- package/es/FieldTypeText/index.js +7 -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 +14 -0
- package/es/LegacyTheme/index.d.ts +3 -0
- package/es/LegacyTheme/index.js +83 -0
- package/es/LegacyTheme/palette.d.ts +3 -0
- package/es/LegacyTheme/palette.js +23 -0
- package/{src/LegacyTheme/typography.ts → es/LegacyTheme/typography.d.ts} +1 -5
- package/es/LegacyTheme/typography.js +4 -0
- package/es/TextField.stories.d.ts +5 -0
- package/es/TextField.stories.js +18 -0
- package/es/VitualizedAutocomplete/VirtualizedAutocomplete.stories.d.ts +5 -0
- package/es/VitualizedAutocomplete/VirtualizedAutocomplete.stories.js +27 -0
- package/es/VitualizedAutocomplete/index.d.ts +28 -0
- package/es/VitualizedAutocomplete/index.js +21 -0
- package/es/icons/FolderGlobal.d.ts +3 -0
- package/es/icons/FolderGlobal.js +3 -0
- package/es/icons/index.d.ts +1 -0
- package/es/icons/index.js +1 -0
- package/{src/index.ts → es/index.d.ts} +4 -3
- package/es/index.js +15 -0
- package/es/stories/Theme.stories.d.ts +4 -0
- package/es/stories/Theme.stories.js +10 -0
- package/es/theme/Theme.stories.d.ts +4 -0
- package/es/theme/Theme.stories.js +10 -0
- package/es/theme/index.d.ts +11 -0
- package/es/theme/index.js +143 -0
- package/es/theme/palette.d.ts +16 -0
- package/es/theme/palette.js +138 -0
- package/es/theme/typography.d.ts +9 -0
- package/es/theme/typography.js +57 -0
- package/es/utils/virtualization.d.ts +2 -0
- package/es/utils/virtualization.js +63 -0
- package/package.json +12 -10
- package/.storybook/main.js +0 -25
- package/.storybook/preview-head.html +0 -1
- package/.storybook/preview.js +0 -15
- package/src/ConfirmDialog/ConfirmDialog.stories.tsx +0 -35
- package/src/ConfirmDialog/index.tsx +0 -50
- package/src/CopyButton/CopyButton.stories.tsx +0 -20
- package/src/CopyButton/index.tsx +0 -55
- package/src/FieldTypeColor/FieldTypeColor.stories.tsx +0 -35
- package/src/FieldTypeColor/index.tsx +0 -43
- package/src/FieldTypeDate/FieldTypeDate.stories.tsx +0 -23
- package/src/FieldTypeDate/index.tsx +0 -35
- package/src/FieldTypeDateTime/FieldTypeDateTime.stories.tsx +0 -23
- package/src/FieldTypeDateTime/index.tsx +0 -36
- package/src/FieldTypeNumber/FieldTypeNumber.stories.tsx +0 -35
- package/src/FieldTypeNumber/index.tsx +0 -22
- package/src/FieldTypeOneToMany/FieldTypeOneToMany.stories.tsx +0 -47
- package/src/FieldTypeOneToMany/index.tsx +0 -90
- package/src/FieldTypeOneToOne/FieldTypeOneToOne.stories.tsx +0 -46
- package/src/FieldTypeOneToOne/index.tsx +0 -96
- package/src/FieldTypeSort/FieldTypeSort.stories.tsx +0 -36
- package/src/FieldTypeSort/index.tsx +0 -70
- package/src/FieldTypeText/FieldTypeText.stories.tsx +0 -45
- package/src/FieldTypeText/index.tsx +0 -35
- package/src/FieldTypeUrl/FieldTypeUrl.stories.tsx +0 -33
- package/src/FieldTypeUrl/index.tsx +0 -44
- package/src/LegacyTheme/index.ts +0 -88
- package/src/LegacyTheme/palette.ts +0 -25
- package/src/VitualizedAutocomplete/VirtualizedAutocomplete.stories.tsx +0 -45
- package/src/VitualizedAutocomplete/index.tsx +0 -69
- package/src/theme/Theme.stories.tsx +0 -16
- package/src/theme/index.ts +0 -53
- package/src/theme/palette.ts +0 -153
- package/src/theme/typography.ts +0 -69
- package/src/utils/virtualization.tsx +0 -107
- package/tsconfig.json +0 -22
|
@@ -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,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,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CopyButton from '.';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'CopyButton',
|
|
5
|
+
component: CopyButton,
|
|
6
|
+
argType: {},
|
|
7
|
+
};
|
|
8
|
+
const Template = (args) => {
|
|
9
|
+
return (_jsx(CopyButton, { ...args }));
|
|
10
|
+
};
|
|
11
|
+
export const Default = Template.bind({});
|
|
12
|
+
Default.args = {
|
|
13
|
+
value: 'Copy Me!'
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from '@mui/material/Button';
|
|
3
|
+
export interface CopyButtonProps extends ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Value to be copied to clipboard
|
|
6
|
+
*/
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
declare const CopyButton: ({ value, sx, ...props }: CopyButtonProps) => JSX.Element;
|
|
10
|
+
export default CopyButton;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
3
|
+
import Button from '@mui/material/Button';
|
|
4
|
+
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
5
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
6
|
+
const CopyButton = ({ value, sx, ...props }) => {
|
|
7
|
+
const [copied, setCopied] = useState(false);
|
|
8
|
+
const copyValue = useCallback(() => {
|
|
9
|
+
navigator?.clipboard.writeText(value);
|
|
10
|
+
setCopied(true);
|
|
11
|
+
}, [value]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const iconTimer = setTimeout(() => {
|
|
14
|
+
setCopied(false);
|
|
15
|
+
}, 500);
|
|
16
|
+
return () => {
|
|
17
|
+
clearTimeout(iconTimer);
|
|
18
|
+
};
|
|
19
|
+
}, [copied]);
|
|
20
|
+
return (_jsx(Button, { variant: 'outlined', onClick: copyValue, size: "small", title: props.children ? `Copy ${props.children}` : `Copy ${value}`, sx: {
|
|
21
|
+
textTransform: 'unset',
|
|
22
|
+
// Spread sx prop at the end to allow sx prop overrides
|
|
23
|
+
...sx,
|
|
24
|
+
}, startIcon: copied ? (_jsx(CheckIcon, { color: 'success', fontSize: 'small' })) : (_jsx(ContentCopyIcon, { fontSize: 'small' })), ...props, children: props.children ? props.children : value }));
|
|
25
|
+
};
|
|
26
|
+
export default CopyButton;
|
|
@@ -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, label, required, ...props }: FieldTypeColorProps) => JSX.Element;
|
|
6
|
+
export default FieldTypeColor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import MuiTextField from '@mui/material/TextField';
|
|
3
|
+
import { Button, FormControl, FormLabel, InputAdornment } from '@mui/material';
|
|
4
|
+
import BrushIcon from '@mui/icons-material/Brush';
|
|
5
|
+
const FieldTypeColor = ({ InputProps, label, required, ...props }) => {
|
|
6
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _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
|
+
}, ...props })] }));
|
|
15
|
+
};
|
|
16
|
+
export default FieldTypeColor;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
helperText: 'Date helper text',
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DesktopDatePickerProps } from '@mui/x-date-pickers';
|
|
3
|
+
export interface FieldTypeDateProps extends Omit<DesktopDatePickerProps<Date, Date>, 'renderInput'> {
|
|
4
|
+
helperText?: string;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const FieldTypeDate: ({ label, helperText, error, required, ...props }: FieldTypeDateProps) => JSX.Element;
|
|
9
|
+
export default FieldTypeDate;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
4
|
+
import { DesktopDatePicker } from '@mui/x-date-pickers';
|
|
5
|
+
import { FormControl, FormLabel, TextField } from '@mui/material';
|
|
6
|
+
;
|
|
7
|
+
const FieldTypeDate = ({ label, helperText, error, required, ...props }) => {
|
|
8
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
|
|
9
|
+
};
|
|
10
|
+
export default FieldTypeDate;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
helperText: 'Date helper text',
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DesktopDateTimePickerProps } from '@mui/x-date-pickers';
|
|
3
|
+
export interface FieldTypeDateTimeProps extends Omit<DesktopDateTimePickerProps<Date, Date>, 'renderInput'> {
|
|
4
|
+
helperText?: string;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const FieldTypeDateTime: ({ label, helperText, error, required, ...props }: FieldTypeDateTimeProps) => JSX.Element;
|
|
9
|
+
export default FieldTypeDateTime;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
4
|
+
import { DesktopDateTimePicker } from '@mui/x-date-pickers';
|
|
5
|
+
import { TextField, FormControl, FormLabel } from '@mui/material';
|
|
6
|
+
;
|
|
7
|
+
const FieldTypeDateTime = ({ label, helperText, error, required, ...props }) => {
|
|
8
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDateTimePicker, { "data-testid": "zds-date-time-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
|
|
9
|
+
};
|
|
10
|
+
export default FieldTypeDateTime;
|
|
@@ -0,0 +1,35 @@
|
|
|
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: 'Dropdown label',
|
|
34
|
+
helperText: 'Dropdown helper text',
|
|
35
|
+
};
|
|
@@ -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: ({ label, options, required, ...props }: FieldTypeDropdownProps) => JSX.Element;
|
|
11
|
+
export default FieldTypeDropdown;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import { FormControl, FormLabel } from '@mui/material';
|
|
5
|
+
const FieldTypeDropdown = ({ label, options, required, ...props }) => {
|
|
6
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsxs(MuiTextField, { size: "small", variant: 'outlined', select: true, SelectProps: {
|
|
7
|
+
displayEmpty: true,
|
|
8
|
+
}, ...props, children: [_jsx(MenuItem, { value: '', children: "- None -" }, ''), options.map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.value)))] })] }));
|
|
9
|
+
};
|
|
10
|
+
export default FieldTypeDropdown;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
helperText: 'Number helper text',
|
|
21
|
+
};
|
|
@@ -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: ({ label, required, ...props }: FieldTypeNumberProps) => JSX.Element;
|
|
6
|
+
export default FieldTypeText;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormControl, FormLabel } from '@mui/material';
|
|
3
|
+
import MuiTextField from '@mui/material/TextField';
|
|
4
|
+
const FieldTypeText = ({ label, required, ...props }) => {
|
|
5
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', ...props })] }));
|
|
6
|
+
};
|
|
7
|
+
export default FieldTypeText;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeOneToMany from '.';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeOneToMany',
|
|
6
|
+
component: FieldTypeOneToMany,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState([]);
|
|
11
|
+
const [options, setOptions] = useState([]);
|
|
12
|
+
const handleOnOpen = async () => {
|
|
13
|
+
const largeArr = new Array(1000).fill(null);
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
15
|
+
const data = largeArr.map((_, idx) => ({ component: _jsx("div", { children: `Test ${idx}` }), value: String(Math.random()), inputLabel: `Test ${idx}` }));
|
|
16
|
+
setOptions(data);
|
|
17
|
+
};
|
|
18
|
+
const handleOnChange = (e, values) => {
|
|
19
|
+
setValue(values);
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(FieldTypeOneToMany, { ...args, value: value, onChange: handleOnChange, options: options, onOpen: handleOnOpen }));
|
|
22
|
+
};
|
|
23
|
+
export const Default = Template.bind({});
|
|
24
|
+
Default.args = {
|
|
25
|
+
placeholder: 'Placeholder Text...',
|
|
26
|
+
label: 'OneToMany label',
|
|
27
|
+
helperText: 'OneToMany helperText',
|
|
28
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
export interface FieldTypeOneToManyProps extends Omit<AutocompleteProps<any, false, false, false>, 'onOpen' | 'renderInput'> {
|
|
4
|
+
label?: string;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Callback to be fired upon opening the dropdown
|
|
11
|
+
*/
|
|
12
|
+
onOpen: () => Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Structure for option
|
|
15
|
+
*/
|
|
16
|
+
options: {
|
|
17
|
+
/**
|
|
18
|
+
* Component to be rendered in the dropdown
|
|
19
|
+
*/
|
|
20
|
+
component: ReactNode | string;
|
|
21
|
+
/**
|
|
22
|
+
* Value of option
|
|
23
|
+
*/
|
|
24
|
+
value: string;
|
|
25
|
+
/**
|
|
26
|
+
* Label that should display in the input when selected
|
|
27
|
+
*/
|
|
28
|
+
inputLabel: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
declare const FieldTypeOneToMany: ({ label, helperText, placeholder, error, onOpen, options, required, ...props }: FieldTypeOneToManyProps) => JSX.Element;
|
|
32
|
+
export default FieldTypeOneToMany;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { FormControl, FormLabel, Popper, styled, TextField } from '@mui/material';
|
|
4
|
+
import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
5
|
+
import { ListboxComponent } from '../utils/virtualization';
|
|
6
|
+
const FieldTypeOneToMany = ({ label, helperText, placeholder, error, onOpen, options, required, ...props }) => {
|
|
7
|
+
const [loaded, setLoaded] = useState(false);
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const handleOpen = () => {
|
|
10
|
+
if (!loaded && onOpen) {
|
|
11
|
+
onOpen().then(() => {
|
|
12
|
+
setLoading(false);
|
|
13
|
+
});
|
|
14
|
+
setLoading(true);
|
|
15
|
+
setLoaded(true);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(Autocomplete, { onOpen: handleOpen, loading: loading, fullWidth: true, multiple: true, disableListWrap: true, disableClearable: true, disablePortal: true, size: 'small', PopperComponent: StyledPopper, ListboxComponent: ListboxComponent, renderInput: (params) => (_jsx(TextField, { ...params, helperText: helperText, error: error, placeholder: placeholder })), options: loading ? [] : options, getOptionLabel: (option) => option.inputLabel, renderOption: (props, option) => [props, option.component], ...props })] }));
|
|
19
|
+
};
|
|
20
|
+
export default FieldTypeOneToMany;
|
|
21
|
+
const StyledPopper = styled(Popper)({
|
|
22
|
+
[`& .${autocompleteClasses.listbox}`]: {
|
|
23
|
+
boxSizing: 'border-box',
|
|
24
|
+
'& ul': {
|
|
25
|
+
padding: 0,
|
|
26
|
+
margin: 0,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FieldTypeOneToOne from './';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldTypeOneToOne',
|
|
6
|
+
component: FieldTypeOneToOne,
|
|
7
|
+
argType: {},
|
|
8
|
+
};
|
|
9
|
+
const Template = (args) => {
|
|
10
|
+
const [value, setValue] = useState({ component: '- None -', value: '0', inputLabel: '- None -' });
|
|
11
|
+
const [options, setOptions] = useState([]);
|
|
12
|
+
const handleOnOpen = async () => {
|
|
13
|
+
const largeArr = new Array(1000).fill(null);
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
15
|
+
const data = largeArr.map((_, idx) => ({ component: _jsx("div", { children: `Test ${idx}` }), value: String(Math.random()), inputLabel: `Test ${idx}` }));
|
|
16
|
+
setOptions(data);
|
|
17
|
+
};
|
|
18
|
+
const handleOnChange = (e, option) => {
|
|
19
|
+
setValue(option);
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(FieldTypeOneToOne, { ...args, value: value, onChange: handleOnChange, options: options, onOpen: handleOnOpen }));
|
|
22
|
+
};
|
|
23
|
+
export const Default = Template.bind({});
|
|
24
|
+
Default.args = {
|
|
25
|
+
label: 'OneToOne label',
|
|
26
|
+
helperText: 'OneToOne helperText',
|
|
27
|
+
placeholder: 'OneToOne placeholder'
|
|
28
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
export interface FieldTypeOneToOneProps extends Omit<AutocompleteProps<any, false, false, false>, 'onOpen' | 'renderInput'> {
|
|
4
|
+
label?: string;
|
|
5
|
+
helperText?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
startAdornment?: ReactNode;
|
|
10
|
+
endAdornment?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Callback to be fired upon opening the dropdown
|
|
13
|
+
*/
|
|
14
|
+
onOpen?: () => Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Structure for option
|
|
17
|
+
*/
|
|
18
|
+
options: {
|
|
19
|
+
/**
|
|
20
|
+
* Component to be rendered in the dropdown
|
|
21
|
+
*/
|
|
22
|
+
component: ReactNode | string;
|
|
23
|
+
/**
|
|
24
|
+
* Value of option
|
|
25
|
+
*/
|
|
26
|
+
value: string;
|
|
27
|
+
/**
|
|
28
|
+
* Label that should display in the input when selected
|
|
29
|
+
*/
|
|
30
|
+
inputLabel: string;
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
declare const FieldTypeOneToOne: ({ label, helperText, placeholder, error, onOpen, options, required, startAdornment, endAdornment, ...props }: FieldTypeOneToOneProps) => JSX.Element;
|
|
34
|
+
export default FieldTypeOneToOne;
|