@zesty-io/material 0.2.4 → 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/cjs/ConfirmDialog/ConfirmDialog.stories.d.ts +6 -0
- package/cjs/ConfirmDialog/ConfirmDialog.stories.js +27 -0
- package/cjs/ConfirmDialog/index.d.ts +18 -0
- package/cjs/ConfirmDialog/index.js +13 -0
- package/cjs/CopyButton/CopyButton.stories.d.ts +5 -0
- package/cjs/CopyButton/CopyButton.stories.js +17 -0
- package/cjs/CopyButton/index.d.ts +10 -0
- package/cjs/CopyButton/index.js +28 -0
- package/cjs/FieldTypeColor/FieldTypeColor.stories.d.ts +5 -0
- package/cjs/FieldTypeColor/FieldTypeColor.stories.js +24 -0
- package/cjs/FieldTypeColor/index.d.ts +6 -0
- package/cjs/FieldTypeColor/index.js +18 -0
- package/cjs/FieldTypeDate/FieldTypeDate.stories.d.ts +5 -0
- package/cjs/FieldTypeDate/FieldTypeDate.stories.js +20 -0
- package/cjs/FieldTypeDate/index.d.ts +9 -0
- package/cjs/FieldTypeDate/index.js +12 -0
- package/cjs/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +5 -0
- package/cjs/FieldTypeDateTime/FieldTypeDateTime.stories.js +20 -0
- package/cjs/FieldTypeDateTime/index.d.ts +9 -0
- package/cjs/FieldTypeDateTime/index.js +12 -0
- package/cjs/FieldTypeNumber/FieldTypeNumber.stories.d.ts +5 -0
- package/cjs/FieldTypeNumber/FieldTypeNumber.stories.js +24 -0
- package/cjs/FieldTypeNumber/index.d.ts +6 -0
- package/cjs/FieldTypeNumber/index.js +9 -0
- package/cjs/FieldTypeOneToMany/FieldTypeOneToMany.stories.d.ts +5 -0
- package/cjs/FieldTypeOneToMany/FieldTypeOneToMany.stories.js +31 -0
- package/cjs/FieldTypeOneToMany/index.d.ts +32 -0
- package/cjs/FieldTypeOneToMany/index.js +31 -0
- package/cjs/FieldTypeOneToOne/FieldTypeOneToOne.stories.d.ts +5 -0
- package/cjs/FieldTypeOneToOne/FieldTypeOneToOne.stories.js +31 -0
- package/cjs/FieldTypeOneToOne/index.d.ts +34 -0
- package/cjs/FieldTypeOneToOne/index.js +35 -0
- package/cjs/FieldTypeSort/FieldTypeSort.stories.d.ts +5 -0
- package/cjs/FieldTypeSort/FieldTypeSort.stories.js +25 -0
- package/cjs/FieldTypeSort/index.d.ts +7 -0
- package/cjs/FieldTypeSort/index.js +36 -0
- package/cjs/FieldTypeText/FieldTypeText.stories.d.ts +6 -0
- package/cjs/FieldTypeText/FieldTypeText.stories.js +32 -0
- package/cjs/FieldTypeText/index.d.ts +12 -0
- package/cjs/FieldTypeText/index.js +9 -0
- package/cjs/FieldTypeUrl/FieldTypeUrl.stories.d.ts +5 -0
- package/cjs/FieldTypeUrl/FieldTypeUrl.stories.js +24 -0
- package/cjs/FieldTypeUrl/index.d.ts +12 -0
- package/cjs/FieldTypeUrl/index.js +16 -0
- package/cjs/LegacyTheme/index.d.ts +3 -0
- package/cjs/LegacyTheme/index.js +83 -0
- package/cjs/LegacyTheme/palette.d.ts +3 -0
- package/cjs/LegacyTheme/palette.js +25 -0
- package/{src/LegacyTheme/typography.ts → cjs/LegacyTheme/typography.d.ts} +1 -5
- package/cjs/LegacyTheme/typography.js +6 -0
- package/cjs/VitualizedAutocomplete/VirtualizedAutocomplete.stories.d.ts +5 -0
- package/cjs/VitualizedAutocomplete/VirtualizedAutocomplete.stories.js +30 -0
- package/cjs/VitualizedAutocomplete/index.d.ts +28 -0
- package/cjs/VitualizedAutocomplete/index.js +23 -0
- package/{src/index.ts → cjs/index.d.ts} +3 -3
- package/cjs/index.js +31 -0
- package/cjs/theme/Theme.stories.d.ts +4 -0
- package/cjs/theme/Theme.stories.js +13 -0
- package/cjs/theme/index.d.ts +3 -0
- package/cjs/theme/index.js +52 -0
- package/cjs/theme/palette.d.ts +15 -0
- package/cjs/theme/palette.js +138 -0
- package/cjs/theme/typography.d.ts +9 -0
- package/cjs/theme/typography.js +59 -0
- package/cjs/utils/virtualization.d.ts +2 -0
- package/cjs/utils/virtualization.js +66 -0
- package/es/LegacyTheme/index.js +2 -0
- package/es/TextField.stories.d.ts +5 -0
- package/es/TextField.stories.js +18 -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/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/theme/index.d.ts +8 -0
- package/es/theme/index.js +95 -2
- package/es/theme/palette.d.ts +1 -0
- package/es/theme/palette.js +3 -1
- package/package.json +11 -7
- 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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomChildren = exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
exports.default = {
|
|
9
|
+
title: 'ConfirmDialog',
|
|
10
|
+
component: _1.default,
|
|
11
|
+
argType: {},
|
|
12
|
+
};
|
|
13
|
+
const Template = (args) => {
|
|
14
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => setOpen(true), children: "Click me to open" }), (0, jsx_runtime_1.jsx)(_1.default, { ...args, open: open, callback: (confirmed) => setOpen(false) })] }));
|
|
16
|
+
};
|
|
17
|
+
exports.Default = Template.bind({});
|
|
18
|
+
exports.Default.args = {
|
|
19
|
+
title: 'Confirm modal title',
|
|
20
|
+
content: 'Confirm modal content',
|
|
21
|
+
};
|
|
22
|
+
exports.CustomChildren = Template.bind({});
|
|
23
|
+
exports.CustomChildren.args = {
|
|
24
|
+
title: 'Confirm modal title',
|
|
25
|
+
content: 'Confirm modal content',
|
|
26
|
+
children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "error", variant: "contained", children: "Custom 1" }), (0, jsx_runtime_1.jsx)(material_1.Button, { color: "success", variant: "contained", children: "Custom 2" })] })
|
|
27
|
+
};
|
|
@@ -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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const Dialog_1 = require("@mui/material/Dialog");
|
|
5
|
+
const DialogActions_1 = require("@mui/material/DialogActions");
|
|
6
|
+
const DialogContent_1 = require("@mui/material/DialogContent");
|
|
7
|
+
const DialogContentText_1 = require("@mui/material/DialogContentText");
|
|
8
|
+
const DialogTitle_1 = require("@mui/material/DialogTitle");
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const ConfirmDialog = ({ title, content, onClose, children, callback, ...props }) => {
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { ...props, children: [(0, jsx_runtime_1.jsx)(DialogTitle_1.default, { children: title }), (0, jsx_runtime_1.jsx)(DialogContent_1.default, { children: (0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: content }) }), children ? (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: children }) : ((0, jsx_runtime_1.jsxs)(DialogActions_1.default, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => callback(false), children: "No" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => callback(true), autoFocus: true, children: "Yes" })] }))] }));
|
|
12
|
+
};
|
|
13
|
+
exports.default = ConfirmDialog;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
exports.default = {
|
|
7
|
+
title: 'CopyButton',
|
|
8
|
+
component: _1.default,
|
|
9
|
+
argType: {},
|
|
10
|
+
};
|
|
11
|
+
const Template = (args) => {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args }));
|
|
13
|
+
};
|
|
14
|
+
exports.Default = Template.bind({});
|
|
15
|
+
exports.Default.args = {
|
|
16
|
+
value: 'Copy Me!'
|
|
17
|
+
};
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Button_1 = require("@mui/material/Button");
|
|
6
|
+
const ContentCopy_1 = require("@mui/icons-material/ContentCopy");
|
|
7
|
+
const Check_1 = require("@mui/icons-material/Check");
|
|
8
|
+
const CopyButton = ({ value, sx, ...props }) => {
|
|
9
|
+
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
10
|
+
const copyValue = (0, react_1.useCallback)(() => {
|
|
11
|
+
navigator?.clipboard.writeText(value);
|
|
12
|
+
setCopied(true);
|
|
13
|
+
}, [value]);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const iconTimer = setTimeout(() => {
|
|
16
|
+
setCopied(false);
|
|
17
|
+
}, 500);
|
|
18
|
+
return () => {
|
|
19
|
+
clearTimeout(iconTimer);
|
|
20
|
+
};
|
|
21
|
+
}, [copied]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: 'outlined', onClick: copyValue, size: "small", title: props.children ? `Copy ${props.children}` : `Copy ${value}`, sx: {
|
|
23
|
+
textTransform: 'unset',
|
|
24
|
+
// Spread sx prop at the end to allow sx prop overrides
|
|
25
|
+
...sx,
|
|
26
|
+
}, startIcon: copied ? ((0, jsx_runtime_1.jsx)(Check_1.default, { color: 'success', fontSize: 'small' })) : ((0, jsx_runtime_1.jsx)(ContentCopy_1.default, { fontSize: 'small' })), ...props, children: props.children ? props.children : value }));
|
|
27
|
+
};
|
|
28
|
+
exports.default = CopyButton;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require("./");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeColor',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)('');
|
|
14
|
+
const handleOnChange = (e) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
};
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: handleOnChange }));
|
|
18
|
+
};
|
|
19
|
+
exports.Default = Template.bind({});
|
|
20
|
+
exports.Default.args = {
|
|
21
|
+
placeholder: 'Placeholder Text...',
|
|
22
|
+
label: 'Color label',
|
|
23
|
+
helperText: 'Color helper text',
|
|
24
|
+
};
|
|
@@ -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,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const TextField_1 = require("@mui/material/TextField");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const Brush_1 = require("@mui/icons-material/Brush");
|
|
7
|
+
const FieldTypeColor = ({ InputProps, label, required, ...props }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(TextField_1.default, { size: "small", variant: 'outlined', type: 'color', InputProps: {
|
|
9
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", onClick: (e) => {
|
|
10
|
+
// References color input via event in order to open color picker
|
|
11
|
+
const input = e.currentTarget?.parentElement?.parentElement?.firstElementChild;
|
|
12
|
+
input?.click();
|
|
13
|
+
}, children: (0, jsx_runtime_1.jsx)(Brush_1.default, { fontSize: 'small' }) }) })),
|
|
14
|
+
// Spread props at the end to allow Input prop overrides
|
|
15
|
+
...InputProps,
|
|
16
|
+
}, ...props })] }));
|
|
17
|
+
};
|
|
18
|
+
exports.default = FieldTypeColor;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require(".");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeDate',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)(null);
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: (value) => setValue(value) }));
|
|
15
|
+
};
|
|
16
|
+
exports.Default = Template.bind({});
|
|
17
|
+
exports.Default.args = {
|
|
18
|
+
label: 'Date label',
|
|
19
|
+
helperText: 'Date helper text',
|
|
20
|
+
};
|
|
@@ -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,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const AdapterDateFns_1 = require("@mui/x-date-pickers/AdapterDateFns");
|
|
5
|
+
const LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
6
|
+
const x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
;
|
|
9
|
+
const FieldTypeDate = ({ label, helperText, error, required, ...props }) => {
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDateFns_1.AdapterDateFns, children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DesktopDatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => (0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
|
|
11
|
+
};
|
|
12
|
+
exports.default = FieldTypeDate;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require(".");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeDateTime',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)(null);
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: (value) => setValue(value) }));
|
|
15
|
+
};
|
|
16
|
+
exports.Default = Template.bind({});
|
|
17
|
+
exports.Default.args = {
|
|
18
|
+
label: 'Date label',
|
|
19
|
+
helperText: 'Date helper text',
|
|
20
|
+
};
|
|
@@ -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,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const AdapterDateFns_1 = require("@mui/x-date-pickers/AdapterDateFns");
|
|
5
|
+
const LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
6
|
+
const x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
;
|
|
9
|
+
const FieldTypeDateTime = ({ label, helperText, error, required, ...props }) => {
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDateFns_1.AdapterDateFns, children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DesktopDateTimePicker, { "data-testid": "zds-date-time-picker", renderInput: (params) => (0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
|
|
11
|
+
};
|
|
12
|
+
exports.default = FieldTypeDateTime;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require("./");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeNumber',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)('0');
|
|
14
|
+
const handleOnChange = (e) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
};
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: handleOnChange }));
|
|
18
|
+
};
|
|
19
|
+
exports.Default = Template.bind({});
|
|
20
|
+
exports.Default.args = {
|
|
21
|
+
placeholder: 'Placeholder Text...',
|
|
22
|
+
label: 'Number label',
|
|
23
|
+
helperText: 'Number helper text',
|
|
24
|
+
};
|
|
@@ -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,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const TextField_1 = require("@mui/material/TextField");
|
|
6
|
+
const FieldTypeText = ({ label, required, ...props }) => {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(TextField_1.default, { size: "small", variant: 'outlined', type: 'number', ...props })] }));
|
|
8
|
+
};
|
|
9
|
+
exports.default = FieldTypeText;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require(".");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeOneToMany',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)([]);
|
|
14
|
+
const [options, setOptions] = (0, react_1.useState)([]);
|
|
15
|
+
const handleOnOpen = async () => {
|
|
16
|
+
const largeArr = new Array(1000).fill(null);
|
|
17
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
18
|
+
const data = largeArr.map((_, idx) => ({ component: (0, jsx_runtime_1.jsx)("div", { children: `Test ${idx}` }), value: String(Math.random()), inputLabel: `Test ${idx}` }));
|
|
19
|
+
setOptions(data);
|
|
20
|
+
};
|
|
21
|
+
const handleOnChange = (e, values) => {
|
|
22
|
+
setValue(values);
|
|
23
|
+
};
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: handleOnChange, options: options, onOpen: handleOnOpen }));
|
|
25
|
+
};
|
|
26
|
+
exports.Default = Template.bind({});
|
|
27
|
+
exports.Default.args = {
|
|
28
|
+
placeholder: 'Placeholder Text...',
|
|
29
|
+
label: 'OneToMany label',
|
|
30
|
+
helperText: 'OneToMany helperText',
|
|
31
|
+
};
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const Autocomplete_1 = require("@mui/material/Autocomplete");
|
|
7
|
+
const virtualization_1 = require("../utils/virtualization");
|
|
8
|
+
const FieldTypeOneToMany = ({ label, helperText, placeholder, error, onOpen, options, required, ...props }) => {
|
|
9
|
+
const [loaded, setLoaded] = (0, react_1.useState)(false);
|
|
10
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
11
|
+
const handleOpen = () => {
|
|
12
|
+
if (!loaded && onOpen) {
|
|
13
|
+
onOpen().then(() => {
|
|
14
|
+
setLoading(false);
|
|
15
|
+
});
|
|
16
|
+
setLoading(true);
|
|
17
|
+
setLoaded(true);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(Autocomplete_1.default, { onOpen: handleOpen, loading: loading, fullWidth: true, multiple: true, disableListWrap: true, disableClearable: true, disablePortal: true, size: 'small', PopperComponent: StyledPopper, ListboxComponent: virtualization_1.ListboxComponent, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, helperText: helperText, error: error, placeholder: placeholder })), options: loading ? [] : options, getOptionLabel: (option) => option.inputLabel, renderOption: (props, option) => [props, option.component], ...props })] }));
|
|
21
|
+
};
|
|
22
|
+
exports.default = FieldTypeOneToMany;
|
|
23
|
+
const StyledPopper = (0, material_1.styled)(material_1.Popper)({
|
|
24
|
+
[`& .${Autocomplete_1.autocompleteClasses.listbox}`]: {
|
|
25
|
+
boxSizing: 'border-box',
|
|
26
|
+
'& ul': {
|
|
27
|
+
padding: 0,
|
|
28
|
+
margin: 0,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require("./");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeOneToOne',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)({ component: '- None -', value: '0', inputLabel: '- None -' });
|
|
14
|
+
const [options, setOptions] = (0, react_1.useState)([]);
|
|
15
|
+
const handleOnOpen = async () => {
|
|
16
|
+
const largeArr = new Array(1000).fill(null);
|
|
17
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
18
|
+
const data = largeArr.map((_, idx) => ({ component: (0, jsx_runtime_1.jsx)("div", { children: `Test ${idx}` }), value: String(Math.random()), inputLabel: `Test ${idx}` }));
|
|
19
|
+
setOptions(data);
|
|
20
|
+
};
|
|
21
|
+
const handleOnChange = (e, option) => {
|
|
22
|
+
setValue(option);
|
|
23
|
+
};
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: handleOnChange, options: options, onOpen: handleOnOpen }));
|
|
25
|
+
};
|
|
26
|
+
exports.Default = Template.bind({});
|
|
27
|
+
exports.Default.args = {
|
|
28
|
+
label: 'OneToOne label',
|
|
29
|
+
helperText: 'OneToOne helperText',
|
|
30
|
+
placeholder: 'OneToOne placeholder'
|
|
31
|
+
};
|
|
@@ -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;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const Autocomplete_1 = require("@mui/material/Autocomplete");
|
|
7
|
+
const virtualization_1 = require("../utils/virtualization");
|
|
8
|
+
const FieldTypeOneToOne = ({ label, helperText, placeholder, error, onOpen, options, required, startAdornment, endAdornment, ...props }) => {
|
|
9
|
+
const [loaded, setLoaded] = (0, react_1.useState)(false);
|
|
10
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
11
|
+
const handleOpen = () => {
|
|
12
|
+
if (!loaded && onOpen) {
|
|
13
|
+
onOpen().then(() => {
|
|
14
|
+
setLoading(false);
|
|
15
|
+
});
|
|
16
|
+
setLoading(true);
|
|
17
|
+
setLoaded(true);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, required: required, children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsx)(Autocomplete_1.default, { onOpen: handleOpen, loading: loading, fullWidth: true, disableListWrap: true, disableClearable: true, disablePortal: true, size: 'small', PopperComponent: StyledPopper, ListboxComponent: virtualization_1.ListboxComponent, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, helperText: helperText, error: error, placeholder: placeholder, InputProps: {
|
|
21
|
+
...params.InputProps,
|
|
22
|
+
startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: 'end', children: startAdornment }),
|
|
23
|
+
endAdornment: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [params.InputProps.endAdornment, (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { sx: { position: 'relative', right: '40px' }, position: 'end', children: endAdornment })] })
|
|
24
|
+
} })), options: loading ? [] : options, getOptionLabel: (option) => option.inputLabel, renderOption: (props, option) => [props, option.component], ...props })] }));
|
|
25
|
+
};
|
|
26
|
+
exports.default = FieldTypeOneToOne;
|
|
27
|
+
const StyledPopper = (0, material_1.styled)(material_1.Popper)({
|
|
28
|
+
[`& .${Autocomplete_1.autocompleteClasses.listbox}`]: {
|
|
29
|
+
boxSizing: 'border-box',
|
|
30
|
+
'& ul': {
|
|
31
|
+
padding: 0,
|
|
32
|
+
margin: 0,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Default = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const _1 = require("./");
|
|
7
|
+
exports.default = {
|
|
8
|
+
title: 'FieldTypeSort',
|
|
9
|
+
component: _1.default,
|
|
10
|
+
argType: {},
|
|
11
|
+
};
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const [value, setValue] = (0, react_1.useState)('3');
|
|
14
|
+
const handleOnChange = (e) => {
|
|
15
|
+
setValue(e.target.value);
|
|
16
|
+
};
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(_1.default, { ...args, value: value, onChange: handleOnChange }));
|
|
18
|
+
};
|
|
19
|
+
exports.Default = Template.bind({});
|
|
20
|
+
exports.Default.args = {
|
|
21
|
+
placeholder: 'Placeholder Text...',
|
|
22
|
+
label: 'Sort label',
|
|
23
|
+
helperText: 'Sort helper text',
|
|
24
|
+
error: false,
|
|
25
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OutlinedTextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
export interface FieldTypeSortProps extends Omit<OutlinedTextFieldProps, 'variant'> {
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
declare const FieldTypeSort: ({ label, value, InputProps, required, onChange, ...props }: FieldTypeSortProps) => JSX.Element;
|
|
7
|
+
export default FieldTypeSort;
|