@zesty-io/material 0.0.4 → 0.1.2

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.
Files changed (76) hide show
  1. package/es/ConfirmDialog/ConfirmDialog.stories.d.ts +6 -0
  2. package/es/ConfirmDialog/ConfirmDialog.stories.js +24 -0
  3. package/es/ConfirmDialog/index.d.ts +18 -0
  4. package/es/ConfirmDialog/index.js +11 -0
  5. package/es/ConfirmModal/ConfirmModal.stories.d.ts +6 -0
  6. package/es/ConfirmModal/ConfirmModal.stories.js +24 -0
  7. package/es/ConfirmModal/index.d.ts +18 -0
  8. package/es/ConfirmModal/index.js +11 -0
  9. package/es/CopyButton/index.js +3 -3
  10. package/es/FieldTypeColor/FieldTypeColor.stories.d.ts +5 -0
  11. package/es/FieldTypeColor/FieldTypeColor.stories.js +21 -0
  12. package/es/FieldTypeColor/index.d.ts +6 -0
  13. package/es/FieldTypeColor/index.js +16 -0
  14. package/es/FieldTypeDate/FieldTypeDate.stories.d.ts +5 -0
  15. package/es/FieldTypeDate/FieldTypeDate.stories.js +17 -0
  16. package/es/FieldTypeDate/index.d.ts +9 -0
  17. package/es/FieldTypeDate/index.js +10 -0
  18. package/es/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +5 -0
  19. package/es/FieldTypeDateTime/FieldTypeDateTime.stories.js +17 -0
  20. package/es/FieldTypeDateTime/index.d.ts +9 -0
  21. package/es/FieldTypeDateTime/index.js +10 -0
  22. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.d.ts +5 -0
  23. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.js +35 -0
  24. package/es/FieldTypeDropdown/index.d.ts +11 -0
  25. package/es/FieldTypeDropdown/index.js +10 -0
  26. package/es/FieldTypeNumber/FieldTypeNumber.stories.d.ts +5 -0
  27. package/es/FieldTypeNumber/FieldTypeNumber.stories.js +21 -0
  28. package/es/FieldTypeNumber/index.d.ts +6 -0
  29. package/es/FieldTypeNumber/index.js +7 -0
  30. package/es/FieldTypeOneToMany/FieldTypeOneToMany.stories.d.ts +5 -0
  31. package/es/FieldTypeOneToMany/FieldTypeOneToMany.stories.js +28 -0
  32. package/es/FieldTypeOneToMany/index.d.ts +32 -0
  33. package/es/FieldTypeOneToMany/index.js +29 -0
  34. package/es/FieldTypeOneToOne/FieldTypeOneToOne.stories.d.ts +5 -0
  35. package/es/FieldTypeOneToOne/FieldTypeOneToOne.stories.js +28 -0
  36. package/es/FieldTypeOneToOne/index.d.ts +34 -0
  37. package/es/FieldTypeOneToOne/index.js +33 -0
  38. package/es/FieldTypeSort/FieldTypeSort.stories.js +3 -1
  39. package/es/FieldTypeSort/index.d.ts +1 -1
  40. package/es/FieldTypeSort/index.js +17 -29
  41. package/es/FieldTypeText/FieldTypeText.stories.js +6 -6
  42. package/es/FieldTypeText/index.d.ts +1 -1
  43. package/es/FieldTypeText/index.js +4 -12
  44. package/es/FieldTypeUrl/index.d.ts +1 -1
  45. package/es/FieldTypeUrl/index.js +8 -16
  46. package/es/index.d.ts +11 -0
  47. package/es/index.js +11 -0
  48. package/es/theme/index.js +13 -2
  49. package/es/utils/virtualization.d.ts +2 -0
  50. package/es/utils/virtualization.js +63 -0
  51. package/package.json +7 -3
  52. package/src/ConfirmDialog/ConfirmDialog.stories.tsx +35 -0
  53. package/src/ConfirmDialog/index.tsx +50 -0
  54. package/src/CopyButton/index.tsx +6 -6
  55. package/src/FieldTypeColor/FieldTypeColor.stories.tsx +35 -0
  56. package/src/FieldTypeColor/index.tsx +43 -0
  57. package/src/FieldTypeDate/FieldTypeDate.stories.tsx +23 -0
  58. package/src/FieldTypeDate/index.tsx +34 -0
  59. package/src/FieldTypeDateTime/FieldTypeDateTime.stories.tsx +23 -0
  60. package/src/FieldTypeDateTime/index.tsx +35 -0
  61. package/src/FieldTypeDropdown/FieldTypeDropwdon.stories.tsx +52 -0
  62. package/src/FieldTypeDropdown/index.tsx +41 -0
  63. package/src/FieldTypeNumber/FieldTypeNumber.stories.tsx +35 -0
  64. package/src/FieldTypeNumber/index.tsx +22 -0
  65. package/src/FieldTypeOneToMany/FieldTypeOneToMany.stories.tsx +47 -0
  66. package/src/FieldTypeOneToMany/index.tsx +90 -0
  67. package/src/FieldTypeOneToOne/FieldTypeOneToOne.stories.tsx +46 -0
  68. package/src/FieldTypeOneToOne/index.tsx +96 -0
  69. package/src/FieldTypeSort/FieldTypeSort.stories.tsx +3 -2
  70. package/src/FieldTypeSort/index.tsx +15 -68
  71. package/src/FieldTypeText/FieldTypeText.stories.tsx +11 -9
  72. package/src/FieldTypeText/index.tsx +11 -19
  73. package/src/FieldTypeUrl/index.tsx +12 -19
  74. package/src/index.ts +11 -0
  75. package/src/theme/index.ts +15 -2
  76. package/src/utils/virtualization.tsx +107 -0
@@ -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;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useState, useEffect } from 'react';
3
3
  import Button from '@mui/material/Button';
4
4
  import ContentCopyIcon from '@mui/icons-material/ContentCopy';
@@ -17,10 +17,10 @@ const CopyButton = ({ value, sx, ...props }) => {
17
17
  clearTimeout(iconTimer);
18
18
  };
19
19
  }, [copied]);
20
- return (_jsxs(Button, { variant: 'outlined', onClick: copyValue, size: "small", title: props.children ? `Copy ${props.children}` : `Copy ${value}`, sx: {
20
+ return (_jsx(Button, { variant: 'outlined', onClick: copyValue, size: "small", title: props.children ? `Copy ${props.children}` : `Copy ${value}`, sx: {
21
21
  textTransform: 'unset',
22
22
  // Spread sx prop at the end to allow sx prop overrides
23
23
  ...sx,
24
- }, ...props, children: [copied ? (_jsx(CheckIcon, { color: 'success', fontSize: 'small' })) : (_jsx(ContentCopyIcon, { fontSize: 'small' })), props.children ? props.children : value] }));
24
+ }, startIcon: copied ? (_jsx(CheckIcon, { color: 'success', fontSize: 'small' })) : (_jsx(ContentCopyIcon, { fontSize: 'small' })), ...props, children: props.children ? props.children : value }));
25
25
  };
26
26
  export default CopyButton;
@@ -0,0 +1,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeColorProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeColorProps>;
@@ -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,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeDateProps } from '.';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeDateProps>;
@@ -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 { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
3
+ export interface FieldTypeDateProps extends Omit<DatePickerProps<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 { DatePicker } from '@mui/x-date-pickers/DatePicker';
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(DatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error }), ...props }) })] }));
9
+ };
10
+ export default FieldTypeDate;
@@ -0,0 +1,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeDateTimeProps } from '.';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeDateTimeProps>;
@@ -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 { DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';
3
+ export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<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 { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
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(DateTimePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error }), ...props }) })] }));
9
+ };
10
+ export default FieldTypeDateTime;
@@ -0,0 +1,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeDropdownProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeDropdownProps>;
@@ -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,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeNumberProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeNumberProps>;
@@ -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,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeOneToManyProps } from '.';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeOneToManyProps>;
@@ -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,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeOneToOneProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeOneToOneProps>;
@@ -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;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Popper, styled, TextField, FormLabel, FormControl, InputAdornment } from '@mui/material';
4
+ import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
5
+ import { ListboxComponent } from '../utils/virtualization';
6
+ const FieldTypeOneToOne = ({ label, helperText, placeholder, error, onOpen, options, required, startAdornment, endAdornment, ...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, disableListWrap: true, disableClearable: true, disablePortal: true, size: 'small', PopperComponent: StyledPopper, ListboxComponent: ListboxComponent, renderInput: (params) => (_jsx(TextField, { ...params, helperText: helperText, error: error, placeholder: placeholder, InputProps: {
19
+ ...params.InputProps,
20
+ startAdornment: _jsx(InputAdornment, { position: 'end', children: startAdornment }),
21
+ endAdornment: _jsxs(_Fragment, { children: [params.InputProps.endAdornment, _jsx(InputAdornment, { sx: { position: 'relative', right: '40px' }, position: 'end', children: endAdornment })] })
22
+ } })), options: loading ? [] : options, getOptionLabel: (option) => option.inputLabel, renderOption: (props, option) => [props, option.component], ...props })] }));
23
+ };
24
+ export default FieldTypeOneToOne;
25
+ const StyledPopper = styled(Popper)({
26
+ [`& .${autocompleteClasses.listbox}`]: {
27
+ boxSizing: 'border-box',
28
+ '& ul': {
29
+ padding: 0,
30
+ margin: 0,
31
+ },
32
+ },
33
+ });
@@ -16,5 +16,7 @@ const Template = (args) => {
16
16
  export const Default = Template.bind({});
17
17
  Default.args = {
18
18
  placeholder: 'Placeholder Text...',
19
- label: 'Some label',
19
+ label: 'Sort label',
20
+ helperText: 'Sort helper text',
21
+ error: false,
20
22
  };