@zesty-io/material 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.storybook/main.js +15 -2
  2. package/.storybook/preview-head.html +1 -0
  3. package/.storybook/preview.js +14 -8
  4. package/es/ConfirmModal/ConfirmModal.stories.d.ts +6 -0
  5. package/es/ConfirmModal/ConfirmModal.stories.js +24 -0
  6. package/es/ConfirmModal/index.d.ts +18 -0
  7. package/es/ConfirmModal/index.js +11 -0
  8. package/es/CopyButton/CopyButton.stories.d.ts +5 -0
  9. package/es/CopyButton/CopyButton.stories.js +14 -0
  10. package/es/CopyButton/index.d.ts +10 -0
  11. package/es/CopyButton/index.js +26 -0
  12. package/es/FieldTypeColor/FieldTypeColor.stories.d.ts +5 -0
  13. package/es/FieldTypeColor/FieldTypeColor.stories.js +21 -0
  14. package/es/FieldTypeColor/index.d.ts +6 -0
  15. package/es/FieldTypeColor/index.js +20 -0
  16. package/es/FieldTypeDate/FieldTypeDate.stories.d.ts +5 -0
  17. package/es/FieldTypeDate/FieldTypeDate.stories.js +20 -0
  18. package/es/FieldTypeDate/index.d.ts +11 -0
  19. package/es/FieldTypeDate/index.js +14 -0
  20. package/es/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +5 -0
  21. package/es/FieldTypeDateTime/FieldTypeDateTime.stories.js +20 -0
  22. package/es/FieldTypeDateTime/index.d.ts +11 -0
  23. package/es/FieldTypeDateTime/index.js +14 -0
  24. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.d.ts +5 -0
  25. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.js +34 -0
  26. package/es/FieldTypeDropdown/index.d.ts +11 -0
  27. package/es/FieldTypeDropdown/index.js +15 -0
  28. package/es/FieldTypeNumber/FieldTypeNumber.stories.d.ts +5 -0
  29. package/es/FieldTypeNumber/FieldTypeNumber.stories.js +20 -0
  30. package/es/FieldTypeNumber/index.d.ts +6 -0
  31. package/es/FieldTypeNumber/index.js +10 -0
  32. package/es/FieldTypeSort/FieldTypeSort.stories.d.ts +5 -0
  33. package/es/FieldTypeSort/FieldTypeSort.stories.js +21 -0
  34. package/es/FieldTypeSort/index.d.ts +7 -0
  35. package/es/FieldTypeSort/index.js +32 -0
  36. package/es/FieldTypeText/FieldTypeText.stories.d.ts +6 -0
  37. package/es/FieldTypeText/FieldTypeText.stories.js +27 -0
  38. package/es/FieldTypeText/index.d.ts +12 -0
  39. package/es/FieldTypeText/index.js +15 -0
  40. package/es/FieldTypeUrl/FieldTypeUrl.stories.d.ts +5 -0
  41. package/es/FieldTypeUrl/FieldTypeUrl.stories.js +21 -0
  42. package/es/FieldTypeUrl/index.d.ts +12 -0
  43. package/es/FieldTypeUrl/index.js +21 -0
  44. package/es/index.d.ts +10 -0
  45. package/es/index.js +10 -0
  46. package/es/theme/Theme.stories.d.ts +4 -0
  47. package/es/theme/Theme.stories.js +10 -0
  48. package/es/theme/index.js +46 -12
  49. package/package.json +5 -2
  50. package/src/ConfirmModal/ConfirmModal.stories.tsx +35 -0
  51. package/src/ConfirmModal/index.tsx +50 -0
  52. package/src/CopyButton/CopyButton.stories.tsx +20 -0
  53. package/src/CopyButton/index.tsx +55 -0
  54. package/src/FieldTypeColor/FieldTypeColor.stories.tsx +35 -0
  55. package/src/FieldTypeColor/index.tsx +45 -0
  56. package/src/FieldTypeDate/FieldTypeDate.stories.tsx +26 -0
  57. package/src/FieldTypeDate/index.tsx +37 -0
  58. package/src/FieldTypeDateTime/FieldTypeDateTime.stories.tsx +26 -0
  59. package/src/FieldTypeDateTime/index.tsx +37 -0
  60. package/src/FieldTypeDropdown/FieldTypeDropwdon.stories.tsx +51 -0
  61. package/src/FieldTypeDropdown/index.tsx +43 -0
  62. package/src/FieldTypeNumber/FieldTypeNumber.stories.tsx +34 -0
  63. package/src/FieldTypeNumber/index.tsx +23 -0
  64. package/src/FieldTypeSort/FieldTypeSort.stories.tsx +35 -0
  65. package/src/FieldTypeSort/index.tsx +65 -0
  66. package/src/FieldTypeText/FieldTypeText.stories.tsx +41 -0
  67. package/src/FieldTypeText/index.tsx +42 -0
  68. package/src/FieldTypeUrl/FieldTypeUrl.stories.tsx +33 -0
  69. package/src/FieldTypeUrl/index.tsx +50 -0
  70. package/src/index.ts +10 -0
  71. package/src/{stories → theme}/Theme.stories.tsx +1 -1
  72. package/src/theme/index.ts +52 -13
@@ -6,7 +6,20 @@ module.exports = {
6
6
  "addons": [
7
7
  "@storybook/addon-links",
8
8
  "@storybook/addon-essentials",
9
- "@storybook/addon-interactions"
10
9
  ],
11
- "framework": "@storybook/react"
10
+ "framework": "@storybook/react",
11
+ typescript: {
12
+ check: true,
13
+ reactDocgen: 'react-docgen-typescript',
14
+ reactDocgenTypescriptOptions: {
15
+ shouldExtractLiteralValuesFromEnum: true,
16
+ shouldRemoveUndefinedFromOptional: true,
17
+ propFilter: (prop) => {
18
+ return prop.parent
19
+ ? /@mui/.test(prop.parent.fileName) ||
20
+ !/node_modules/.test(prop.parent.fileName)
21
+ : true;
22
+ },
23
+ },
24
+ },
12
25
  }
@@ -0,0 +1 @@
1
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Mulish" />
@@ -1,9 +1,15 @@
1
+ import React from 'react';
2
+ import { ThemeProvider } from 'emotion-theming';
3
+ import { theme } from '../src/index.ts';
4
+
1
5
  export const parameters = {
2
- actions: { argTypesRegex: "^on[A-Z].*" },
3
- controls: {
4
- matchers: {
5
- color: /(background|color)$/i,
6
- date: /Date$/,
7
- },
8
- },
9
- }
6
+ actions: { argTypesRegex: '^on[A-Z].*' },
7
+ };
8
+
9
+ export const decorators = [
10
+ (Story) => (
11
+ <ThemeProvider theme={theme}>
12
+ <Story />
13
+ </ThemeProvider>
14
+ ),
15
+ ];
@@ -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,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { CopyButtonProps } from '.';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<CopyButtonProps>;
@@ -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, jsxs as _jsxs } 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 (_jsxs(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
+ }, ...props, children: [copied ? (_jsx(CheckIcon, { color: 'success', fontSize: 'small' })) : (_jsx(ContentCopyIcon, { fontSize: 'small' })), props.children ? props.children : value] }));
25
+ };
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, InputLabelProps, ...props }: FieldTypeColorProps) => JSX.Element;
6
+ export default FieldTypeColor;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import MuiTextField from '@mui/material/TextField';
3
+ import { Button, InputAdornment } from '@mui/material';
4
+ import BrushIcon from '@mui/icons-material/Brush';
5
+ const FieldTypeColor = ({ InputProps, InputLabelProps, ...props }) => {
6
+ return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'color', InputProps: {
7
+ endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
8
+ // References color input via event in order to open color picker
9
+ const input = e.currentTarget?.parentElement?.parentElement?.firstElementChild;
10
+ input?.click();
11
+ }, children: _jsx(BrushIcon, { fontSize: 'small' }) }) })),
12
+ // Spread props at the end to allow Input prop overrides
13
+ ...InputProps,
14
+ }, InputLabelProps: {
15
+ shrink: true,
16
+ // Spread props at the end to allow InputLabel prop overrides
17
+ ...InputLabelProps,
18
+ }, ...props }));
19
+ };
20
+ export default FieldTypeColor;
@@ -0,0 +1,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,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeDate from '.';
4
+ export default {
5
+ title: 'FieldTypeDate',
6
+ component: FieldTypeDate,
7
+ argType: {},
8
+ };
9
+ const Template = (args) => {
10
+ const [value, setValue] = useState(null);
11
+ return (_jsx(FieldTypeDate, { ...args, value: value, onChange: (value) => setValue(value) }));
12
+ };
13
+ export const Default = Template.bind({});
14
+ Default.args = {
15
+ label: 'Date label',
16
+ textFieldProps: {
17
+ helperText: 'Date helper text',
18
+ error: false,
19
+ }
20
+ };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
3
+ import { TextFieldProps } from '@mui/material';
4
+ export interface FieldTypeDateProps extends Omit<DatePickerProps<Date, Date>, 'renderInput'> {
5
+ /**
6
+ * Props passed to TextField component
7
+ */
8
+ textFieldProps?: TextFieldProps;
9
+ }
10
+ declare const FieldTypeDate: ({ textFieldProps, ...props }: FieldTypeDateProps) => JSX.Element;
11
+ export default FieldTypeDate;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
5
+ import { TextField } from '@mui/material';
6
+ ;
7
+ const FieldTypeDate = ({ textFieldProps, ...props }) => {
8
+ return (_jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { InputLabelProps: {
9
+ shrink: true,
10
+ // Spread props at the end to allow InputLabelProps overrides
11
+ ...textFieldProps?.InputLabelProps,
12
+ }, ...params, ...textFieldProps }), ...props }) }));
13
+ };
14
+ export default FieldTypeDate;
@@ -0,0 +1,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,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeDateTime from '.';
4
+ export default {
5
+ title: 'FieldTypeDateTime',
6
+ component: FieldTypeDateTime,
7
+ argType: {},
8
+ };
9
+ const Template = (args) => {
10
+ const [value, setValue] = useState(null);
11
+ return (_jsx(FieldTypeDateTime, { ...args, value: value, onChange: (value) => setValue(value) }));
12
+ };
13
+ export const Default = Template.bind({});
14
+ Default.args = {
15
+ label: 'Date label',
16
+ textFieldProps: {
17
+ helperText: 'Date helper text',
18
+ error: false,
19
+ }
20
+ };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { DateTimePickerProps } from '@mui/x-date-pickers/DateTimePicker';
3
+ import { TextFieldProps } from '@mui/material';
4
+ export interface FieldTypeDateTimeProps extends Omit<DateTimePickerProps<Date, Date>, 'renderInput'> {
5
+ /**
6
+ * Props passed to TextField component
7
+ */
8
+ textFieldProps?: TextFieldProps;
9
+ }
10
+ declare const FieldTypeDateTime: ({ textFieldProps, ...props }: FieldTypeDateTimeProps) => JSX.Element;
11
+ export default FieldTypeDateTime;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
+ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
5
+ import { TextField } from '@mui/material';
6
+ ;
7
+ const FieldTypeDateTime = ({ textFieldProps, ...props }) => {
8
+ return (_jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DateTimePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { InputLabelProps: {
9
+ shrink: true,
10
+ // Spread props at the end to allow InputLabelProps overrides
11
+ ...textFieldProps?.InputLabelProps,
12
+ }, ...params, ...textFieldProps }), ...props }) }));
13
+ };
14
+ export default FieldTypeDateTime;
@@ -0,0 +1,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,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeDropdown from './';
4
+ export default {
5
+ title: 'FieldTypeDropdown',
6
+ component: FieldTypeDropdown,
7
+ argType: {},
8
+ };
9
+ const options = [
10
+ {
11
+ value: 'option1',
12
+ label: 'Option 1',
13
+ },
14
+ {
15
+ value: 'option2',
16
+ label: 'Option 2',
17
+ },
18
+ {
19
+ value: 'option3',
20
+ label: 'Option 3',
21
+ },
22
+ ];
23
+ const Template = (args) => {
24
+ const [value, setValue] = useState('');
25
+ const handleOnChange = (e) => {
26
+ setValue(e.target.value);
27
+ };
28
+ return (_jsx(FieldTypeDropdown, { ...args, value: value, onChange: handleOnChange, options: options }));
29
+ };
30
+ export const Default = Template.bind({});
31
+ Default.args = {
32
+ placeholder: 'Placeholder Text...',
33
+ label: 'Number label',
34
+ };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { OutlinedTextFieldProps } from '@mui/material/TextField';
3
+ interface Option {
4
+ label: string;
5
+ value: any;
6
+ }
7
+ export interface FieldTypeDropdownProps extends Omit<OutlinedTextFieldProps, 'variant'> {
8
+ options: Option[];
9
+ }
10
+ declare const FieldTypeDropdown: ({ InputLabelProps, options, ...props }: FieldTypeDropdownProps) => JSX.Element;
11
+ export default FieldTypeDropdown;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MenuItem } from '@mui/material';
3
+ import MuiTextField from '@mui/material/TextField';
4
+ const FieldTypeDropdown = ({ InputLabelProps, options, ...props }) => {
5
+ return (_jsxs(MuiTextField, { size: "small", variant: 'outlined', select: true, InputLabelProps: {
6
+ shrink: true,
7
+ // Spread props at the end to allow InputLabel prop overrides
8
+ ...InputLabelProps,
9
+ },
10
+ // Spread props at the end to allow prop overrides
11
+ SelectProps: {
12
+ displayEmpty: true,
13
+ }, ...props, children: [_jsx(MenuItem, { value: '', children: "- None -" }, ''), options.map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.value)))] }));
14
+ };
15
+ export default FieldTypeDropdown;
@@ -0,0 +1,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,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeNumber from './';
4
+ export default {
5
+ title: 'FieldTypeNumber',
6
+ component: FieldTypeNumber,
7
+ argType: {},
8
+ };
9
+ const Template = (args) => {
10
+ const [value, setValue] = useState('0');
11
+ const handleOnChange = (e) => {
12
+ setValue(e.target.value);
13
+ };
14
+ return (_jsx(FieldTypeNumber, { ...args, value: value, onChange: handleOnChange }));
15
+ };
16
+ export const Default = Template.bind({});
17
+ Default.args = {
18
+ placeholder: 'Placeholder Text...',
19
+ label: 'Number label',
20
+ };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { OutlinedTextFieldProps } from '@mui/material/TextField';
3
+ export interface FieldTypeNumberProps extends Omit<OutlinedTextFieldProps, 'variant'> {
4
+ }
5
+ declare const FieldTypeText: ({ InputLabelProps, ...props }: FieldTypeNumberProps) => JSX.Element;
6
+ export default FieldTypeText;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import MuiTextField from '@mui/material/TextField';
3
+ const FieldTypeText = ({ InputLabelProps, ...props }) => {
4
+ return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', InputLabelProps: {
5
+ shrink: true,
6
+ // Spread props at the end to allow InputLabel prop overrides
7
+ ...InputLabelProps,
8
+ }, ...props }));
9
+ };
10
+ export default FieldTypeText;
@@ -0,0 +1,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeSortProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeSortProps>;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeSort from './';
4
+ export default {
5
+ title: 'FieldTypeSort',
6
+ component: FieldTypeSort,
7
+ argType: {},
8
+ };
9
+ const Template = (args) => {
10
+ const [value, setValue] = useState('3');
11
+ const handleOnChange = (e) => {
12
+ setValue(e.target.value);
13
+ };
14
+ return (_jsx(FieldTypeSort, { ...args, value: value, onChange: handleOnChange }));
15
+ };
16
+ export const Default = Template.bind({});
17
+ Default.args = {
18
+ placeholder: 'Placeholder Text...',
19
+ label: 'Sort label',
20
+ helperText: 'Sort helper text',
21
+ };
@@ -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: ({ value, InputProps, InputLabelProps, sx, ...props }: FieldTypeSortProps) => JSX.Element;
7
+ export default FieldTypeSort;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import MuiTextField from '@mui/material/TextField';
3
+ import { Button, InputAdornment } from '@mui/material';
4
+ import AddIcon from '@mui/icons-material/Add';
5
+ import RemoveIcon from '@mui/icons-material/Remove';
6
+ const FieldTypeSort = ({ value, InputProps, InputLabelProps, sx, ...props }) => {
7
+ return (_jsx(MuiTextField, { size: "small", variant: 'outlined', type: 'number', value: value, sx: {
8
+ width: 165,
9
+ // Spread props at the end to allow sx prop overrides
10
+ ...sx
11
+ }, InputProps: {
12
+ startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
13
+ // References input via event in order to modify its value
14
+ const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
15
+ console.log('testing input', input);
16
+ input.value = String(+input.value + 1);
17
+ }, children: _jsx(AddIcon, { fontSize: 'small' }) }) })),
18
+ endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(Button, { size: "small", variant: "contained", onClick: (e) => {
19
+ // References input via event in order to modify its value
20
+ const input = e.currentTarget?.parentElement?.parentElement?.childNodes?.[1];
21
+ console.log('testing input', input);
22
+ input.value = String(+input.value - 1);
23
+ }, children: _jsx(RemoveIcon, { fontSize: 'small' }) }) })),
24
+ // Spread props at the end to allow Input prop overrides
25
+ ...InputProps,
26
+ }, InputLabelProps: {
27
+ shrink: true,
28
+ // Spread props at the end to allow InputLabel prop overrides
29
+ ...InputLabelProps,
30
+ }, ...props }));
31
+ };
32
+ export default FieldTypeSort;
@@ -0,0 +1,6 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeTextProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeTextProps>;
6
+ export declare const TextArea: Story<FieldTypeTextProps>;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeText from './';
4
+ export default {
5
+ title: 'FieldTypeText',
6
+ component: FieldTypeText,
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(FieldTypeText, { ...args, value: value, onChange: handleOnChange }));
15
+ };
16
+ export const Default = Template.bind({});
17
+ Default.args = {
18
+ placeholder: 'Placeholder Text...',
19
+ label: 'Text label',
20
+ };
21
+ export const TextArea = Template.bind({});
22
+ TextArea.args = {
23
+ multiline: true,
24
+ rows: 4,
25
+ placeholder: 'Placeholder Text...',
26
+ label: 'Text Label',
27
+ };
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { OutlinedTextFieldProps } from '@mui/material/TextField';
3
+ export interface FieldTypeTextProps extends Omit<OutlinedTextFieldProps, 'variant'> {
4
+ /**
5
+ * Max length of the field
6
+ * @default 150
7
+ */
8
+ maxLength?: number;
9
+ value: string;
10
+ }
11
+ declare const FieldTypeText: ({ maxLength, value, helperText, InputProps, InputLabelProps, ...props }: FieldTypeTextProps) => JSX.Element;
12
+ export default FieldTypeText;
@@ -0,0 +1,15 @@
1
+ import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import MuiTextField from '@mui/material/TextField';
3
+ import { InputAdornment } from '@mui/material';
4
+ const FieldTypeText = ({ maxLength = 150, value, helperText, InputProps, InputLabelProps, ...props }) => {
5
+ return (_jsx(MuiTextField, { size: "small", variant: 'outlined', value: value, InputProps: {
6
+ endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsxs(_Fragment, { children: [value.length, "/", maxLength] }) })),
7
+ // Spread props at the end to allow Input prop overrides
8
+ ...InputProps,
9
+ }, InputLabelProps: {
10
+ shrink: true,
11
+ // Spread props at the end to allow InputLabel prop overrides
12
+ ...InputLabelProps,
13
+ }, error: value.length > maxLength, helperText: value.length > maxLength ? 'Your input is over the specified limit' : helperText, ...props }));
14
+ };
15
+ export default FieldTypeText;
@@ -0,0 +1,5 @@
1
+ import { Story, Meta } from '@storybook/react/types-6-0';
2
+ import { FieldTypeUrlProps } from './';
3
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
+ export default _default;
5
+ export declare const Default: Story<FieldTypeUrlProps>;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import FieldTypeUrl from './';
4
+ export default {
5
+ title: 'FieldTypeUrl',
6
+ component: FieldTypeUrl,
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(FieldTypeUrl, { ...args, value: value, onChange: handleOnChange }));
15
+ };
16
+ export const Default = Template.bind({});
17
+ Default.args = {
18
+ placeholder: 'Placeholder Text...',
19
+ label: 'Some label',
20
+ fullWidth: true,
21
+ };