@zesty-io/material 0.2.3 → 0.2.5

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 (105) hide show
  1. package/{es → cjs}/ConfirmDialog/ConfirmDialog.stories.d.ts +0 -0
  2. package/cjs/ConfirmDialog/ConfirmDialog.stories.js +27 -0
  3. package/{es → cjs}/ConfirmDialog/index.d.ts +0 -0
  4. package/cjs/ConfirmDialog/index.js +13 -0
  5. package/{es → cjs}/CopyButton/CopyButton.stories.d.ts +0 -0
  6. package/cjs/CopyButton/CopyButton.stories.js +17 -0
  7. package/{es → cjs}/CopyButton/index.d.ts +0 -0
  8. package/cjs/CopyButton/index.js +28 -0
  9. package/{es → cjs}/FieldTypeColor/FieldTypeColor.stories.d.ts +0 -0
  10. package/cjs/FieldTypeColor/FieldTypeColor.stories.js +24 -0
  11. package/{es → cjs}/FieldTypeColor/index.d.ts +0 -0
  12. package/cjs/FieldTypeColor/index.js +18 -0
  13. package/{es → cjs}/FieldTypeDate/FieldTypeDate.stories.d.ts +0 -0
  14. package/cjs/FieldTypeDate/FieldTypeDate.stories.js +20 -0
  15. package/{es → cjs}/FieldTypeDate/index.d.ts +0 -0
  16. package/cjs/FieldTypeDate/index.js +12 -0
  17. package/{es → cjs}/FieldTypeDateTime/FieldTypeDateTime.stories.d.ts +0 -0
  18. package/cjs/FieldTypeDateTime/FieldTypeDateTime.stories.js +20 -0
  19. package/{es → cjs}/FieldTypeDateTime/index.d.ts +0 -0
  20. package/cjs/FieldTypeDateTime/index.js +12 -0
  21. package/{es → cjs}/FieldTypeNumber/FieldTypeNumber.stories.d.ts +0 -0
  22. package/cjs/FieldTypeNumber/FieldTypeNumber.stories.js +24 -0
  23. package/{es → cjs}/FieldTypeNumber/index.d.ts +0 -0
  24. package/cjs/FieldTypeNumber/index.js +9 -0
  25. package/{es → cjs}/FieldTypeOneToMany/FieldTypeOneToMany.stories.d.ts +0 -0
  26. package/cjs/FieldTypeOneToMany/FieldTypeOneToMany.stories.js +31 -0
  27. package/{es → cjs}/FieldTypeOneToMany/index.d.ts +0 -0
  28. package/cjs/FieldTypeOneToMany/index.js +31 -0
  29. package/{es → cjs}/FieldTypeOneToOne/FieldTypeOneToOne.stories.d.ts +0 -0
  30. package/cjs/FieldTypeOneToOne/FieldTypeOneToOne.stories.js +31 -0
  31. package/{es → cjs}/FieldTypeOneToOne/index.d.ts +0 -0
  32. package/cjs/FieldTypeOneToOne/index.js +35 -0
  33. package/{es → cjs}/FieldTypeSort/FieldTypeSort.stories.d.ts +0 -0
  34. package/cjs/FieldTypeSort/FieldTypeSort.stories.js +25 -0
  35. package/{es → cjs}/FieldTypeSort/index.d.ts +0 -0
  36. package/{es → cjs}/FieldTypeSort/index.js +13 -11
  37. package/{es → cjs}/FieldTypeText/FieldTypeText.stories.d.ts +0 -0
  38. package/cjs/FieldTypeText/FieldTypeText.stories.js +32 -0
  39. package/{es → cjs}/FieldTypeText/index.d.ts +0 -0
  40. package/cjs/FieldTypeText/index.js +9 -0
  41. package/{es → cjs}/FieldTypeUrl/FieldTypeUrl.stories.d.ts +0 -0
  42. package/cjs/FieldTypeUrl/FieldTypeUrl.stories.js +24 -0
  43. package/{es → cjs}/FieldTypeUrl/index.d.ts +0 -0
  44. package/cjs/FieldTypeUrl/index.js +16 -0
  45. package/{es → cjs}/LegacyTheme/index.d.ts +0 -0
  46. package/{es → cjs}/LegacyTheme/index.js +10 -8
  47. package/{es → cjs}/LegacyTheme/palette.d.ts +0 -0
  48. package/{es → cjs}/LegacyTheme/palette.js +3 -1
  49. package/{es → cjs}/LegacyTheme/typography.d.ts +0 -0
  50. package/cjs/LegacyTheme/typography.js +6 -0
  51. package/{es → cjs}/VitualizedAutocomplete/VirtualizedAutocomplete.stories.d.ts +0 -0
  52. package/cjs/VitualizedAutocomplete/VirtualizedAutocomplete.stories.js +30 -0
  53. package/{es → cjs}/VitualizedAutocomplete/index.d.ts +0 -0
  54. package/cjs/VitualizedAutocomplete/index.js +23 -0
  55. package/{es → cjs}/index.d.ts +0 -0
  56. package/cjs/index.js +31 -0
  57. package/{es/stories → cjs/theme}/Theme.stories.d.ts +0 -0
  58. package/cjs/theme/Theme.stories.js +13 -0
  59. package/{es → cjs}/theme/index.d.ts +0 -0
  60. package/{es → cjs}/theme/index.js +10 -8
  61. package/{es → cjs}/theme/palette.d.ts +0 -0
  62. package/{es → cjs}/theme/palette.js +3 -1
  63. package/{es → cjs}/theme/typography.d.ts +0 -0
  64. package/{es → cjs}/theme/typography.js +4 -2
  65. package/{es → cjs}/utils/virtualization.d.ts +0 -0
  66. package/cjs/utils/virtualization.js +66 -0
  67. package/package.json +5 -3
  68. package/src/theme/typography.ts +1 -1
  69. package/es/ConfirmDialog/ConfirmDialog.stories.js +0 -24
  70. package/es/ConfirmDialog/index.js +0 -11
  71. package/es/ConfirmModal/ConfirmModal.stories.d.ts +0 -6
  72. package/es/ConfirmModal/ConfirmModal.stories.js +0 -24
  73. package/es/ConfirmModal/index.d.ts +0 -18
  74. package/es/ConfirmModal/index.js +0 -11
  75. package/es/CopyButton/CopyButton.stories.js +0 -14
  76. package/es/CopyButton/index.js +0 -26
  77. package/es/FieldTypeColor/FieldTypeColor.stories.js +0 -21
  78. package/es/FieldTypeColor/index.js +0 -16
  79. package/es/FieldTypeDate/FieldTypeDate.stories.js +0 -17
  80. package/es/FieldTypeDate/index.js +0 -10
  81. package/es/FieldTypeDateTime/FieldTypeDateTime.stories.js +0 -17
  82. package/es/FieldTypeDateTime/index.js +0 -10
  83. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.d.ts +0 -5
  84. package/es/FieldTypeDropdown/FieldTypeDropwdon.stories.js +0 -35
  85. package/es/FieldTypeDropdown/index.d.ts +0 -11
  86. package/es/FieldTypeDropdown/index.js +0 -10
  87. package/es/FieldTypeNumber/FieldTypeNumber.stories.js +0 -21
  88. package/es/FieldTypeNumber/index.js +0 -7
  89. package/es/FieldTypeOneToMany/FieldTypeOneToMany.stories.js +0 -28
  90. package/es/FieldTypeOneToMany/index.js +0 -29
  91. package/es/FieldTypeOneToOne/FieldTypeOneToOne.stories.js +0 -28
  92. package/es/FieldTypeOneToOne/index.js +0 -33
  93. package/es/FieldTypeSort/FieldTypeSort.stories.js +0 -22
  94. package/es/FieldTypeText/FieldTypeText.stories.js +0 -29
  95. package/es/FieldTypeText/index.js +0 -7
  96. package/es/FieldTypeUrl/FieldTypeUrl.stories.js +0 -21
  97. package/es/FieldTypeUrl/index.js +0 -14
  98. package/es/LegacyTheme/typography.js +0 -4
  99. package/es/VitualizedAutocomplete/VirtualizedAutocomplete.stories.js +0 -27
  100. package/es/VitualizedAutocomplete/index.js +0 -21
  101. package/es/index.js +0 -14
  102. package/es/stories/Theme.stories.js +0 -10
  103. package/es/theme/Theme.stories.d.ts +0 -4
  104. package/es/theme/Theme.stories.js +0 -10
  105. package/es/utils/virtualization.js +0 -63
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const palette = {
2
4
  primary: {
3
5
  main: '#404759',
@@ -20,4 +22,4 @@ const palette = {
20
22
  contrastText: '#ffffff',
21
23
  },
22
24
  };
23
- export default palette;
25
+ exports.default = palette;
File without changes
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const typography = {
4
+ fontFamily: "'Mulish'",
5
+ };
6
+ exports.default = typography;
@@ -0,0 +1,30 @@
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: 'VirtualizedAutocomplete',
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
+ helperText: 'OneToOne helperText',
29
+ placeholder: 'OneToOne placeholder'
30
+ };
File without changes
@@ -0,0 +1,23 @@
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 Autocomplete_1 = require("@mui/material/Autocomplete");
6
+ const virtualization_1 = require("../utils/virtualization");
7
+ const VirtualizedAutocomplete = ({ helperText, placeholder, error, startAdornment, endAdornment, ...props }) => {
8
+ return ((0, jsx_runtime_1.jsx)(Autocomplete_1.default, { fullWidth: true, disableListWrap: 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: {
9
+ ...params.InputProps,
10
+ startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: 'end', children: startAdornment }),
11
+ 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 })] })
12
+ } })), getOptionLabel: (option) => option.inputLabel, renderOption: (props, option) => [props, option.component], ...props }));
13
+ };
14
+ exports.default = VirtualizedAutocomplete;
15
+ const StyledPopper = (0, material_1.styled)(material_1.Popper)({
16
+ [`& .${Autocomplete_1.autocompleteClasses.listbox}`]: {
17
+ boxSizing: 'border-box',
18
+ '& ul': {
19
+ padding: 0,
20
+ margin: 0,
21
+ },
22
+ },
23
+ });
File without changes
package/cjs/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VirtualizedAutocomplete = exports.ConfirmDialog = exports.CopyButton = exports.FieldTypeOneToMany = exports.FieldTypeOneToOne = exports.FieldTypeNumber = exports.FieldTypeColor = exports.FieldTypeDateTime = exports.FieldTypeDate = exports.FieldTypeUrl = exports.FieldTypeSort = exports.FieldTypeText = exports.theme = exports.legacyTheme = void 0;
4
+ var LegacyTheme_1 = require("./LegacyTheme");
5
+ Object.defineProperty(exports, "legacyTheme", { enumerable: true, get: function () { return LegacyTheme_1.default; } });
6
+ var theme_1 = require("./theme");
7
+ Object.defineProperty(exports, "theme", { enumerable: true, get: function () { return theme_1.default; } });
8
+ var FieldTypeText_1 = require("./FieldTypeText");
9
+ Object.defineProperty(exports, "FieldTypeText", { enumerable: true, get: function () { return FieldTypeText_1.default; } });
10
+ var FieldTypeSort_1 = require("./FieldTypeSort");
11
+ Object.defineProperty(exports, "FieldTypeSort", { enumerable: true, get: function () { return FieldTypeSort_1.default; } });
12
+ var FieldTypeUrl_1 = require("./FieldTypeUrl");
13
+ Object.defineProperty(exports, "FieldTypeUrl", { enumerable: true, get: function () { return FieldTypeUrl_1.default; } });
14
+ var FieldTypeDate_1 = require("./FieldTypeDate");
15
+ Object.defineProperty(exports, "FieldTypeDate", { enumerable: true, get: function () { return FieldTypeDate_1.default; } });
16
+ var FieldTypeDateTime_1 = require("./FieldTypeDateTime");
17
+ Object.defineProperty(exports, "FieldTypeDateTime", { enumerable: true, get: function () { return FieldTypeDateTime_1.default; } });
18
+ var FieldTypeColor_1 = require("./FieldTypeColor");
19
+ Object.defineProperty(exports, "FieldTypeColor", { enumerable: true, get: function () { return FieldTypeColor_1.default; } });
20
+ var FieldTypeNumber_1 = require("./FieldTypeNumber");
21
+ Object.defineProperty(exports, "FieldTypeNumber", { enumerable: true, get: function () { return FieldTypeNumber_1.default; } });
22
+ var FieldTypeOneToOne_1 = require("./FieldTypeOneToOne");
23
+ Object.defineProperty(exports, "FieldTypeOneToOne", { enumerable: true, get: function () { return FieldTypeOneToOne_1.default; } });
24
+ var FieldTypeOneToMany_1 = require("./FieldTypeOneToMany");
25
+ Object.defineProperty(exports, "FieldTypeOneToMany", { enumerable: true, get: function () { return FieldTypeOneToMany_1.default; } });
26
+ var CopyButton_1 = require("./CopyButton");
27
+ Object.defineProperty(exports, "CopyButton", { enumerable: true, get: function () { return CopyButton_1.default; } });
28
+ var ConfirmDialog_1 = require("./ConfirmDialog");
29
+ Object.defineProperty(exports, "ConfirmDialog", { enumerable: true, get: function () { return ConfirmDialog_1.default; } });
30
+ var VitualizedAutocomplete_1 = require("./VitualizedAutocomplete");
31
+ Object.defineProperty(exports, "VirtualizedAutocomplete", { enumerable: true, get: function () { return VitualizedAutocomplete_1.default; } });
File without changes
@@ -0,0 +1,13 @@
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_json_view_1 = require("react-json-view");
6
+ const _1 = require(".");
7
+ exports.default = {
8
+ title: 'Theme',
9
+ };
10
+ const Template = (args) => {
11
+ return ((0, jsx_runtime_1.jsx)(react_json_view_1.default, { src: _1.default }));
12
+ };
13
+ exports.Default = Template.bind({});
File without changes
@@ -1,11 +1,13 @@
1
- import palette from './palette';
2
- import typography from './typography';
3
- import { createTheme } from '@mui/material/styles';
4
- let theme = createTheme({
5
- palette,
6
- typography,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const palette_1 = require("./palette");
4
+ const typography_1 = require("./typography");
5
+ const styles_1 = require("@mui/material/styles");
6
+ let theme = (0, styles_1.createTheme)({
7
+ palette: palette_1.default,
8
+ typography: typography_1.default,
7
9
  });
8
- theme = createTheme(theme, {
10
+ theme = (0, styles_1.createTheme)(theme, {
9
11
  components: {
10
12
  MuiFormLabel: {
11
13
  styleOverrides: {
@@ -47,4 +49,4 @@ theme = createTheme(theme, {
47
49
  },
48
50
  },
49
51
  });
50
- export default theme;
52
+ exports.default = theme;
File without changes
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const palette = {
2
4
  primary: {
3
5
  main: "#FF5D03",
@@ -133,4 +135,4 @@ const palette = {
133
135
  focus: "rgba(16, 24, 40, 0.12)",
134
136
  }
135
137
  };
136
- export default palette;
138
+ exports.default = palette;
File without changes
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const typography = {
2
4
  fontFamily: "'Mulish'",
3
5
  h1: {
@@ -46,7 +48,7 @@ const typography = {
46
48
  lineHeight: "22px",
47
49
  },
48
50
  caption: {
49
- fontSize: '20px',
51
+ fontSize: '12px',
50
52
  lineHeight: "20px",
51
53
  },
52
54
  overline: {
@@ -54,4 +56,4 @@ const typography = {
54
56
  letterSpacing: "1px",
55
57
  },
56
58
  };
57
- export default typography;
59
+ exports.default = typography;
File without changes
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListboxComponent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const React = require("react");
6
+ const useMediaQuery_1 = require("@mui/material/useMediaQuery");
7
+ const ListSubheader_1 = require("@mui/material/ListSubheader");
8
+ const styles_1 = require("@mui/material/styles");
9
+ const react_window_1 = require("react-window");
10
+ const Typography_1 = require("@mui/material/Typography");
11
+ const LISTBOX_PADDING = 8; // px
12
+ function renderRow(props) {
13
+ const { data, index, style } = props;
14
+ const dataSet = data[index];
15
+ const inlineStyle = {
16
+ ...style,
17
+ top: style.top + LISTBOX_PADDING,
18
+ };
19
+ if (dataSet.hasOwnProperty('group')) {
20
+ return ((0, jsx_runtime_1.jsx)(ListSubheader_1.default, { component: "div", style: inlineStyle, children: dataSet.group }, dataSet.key));
21
+ }
22
+ return ((0, jsx_runtime_1.jsx)(Typography_1.default, { component: "li", ...dataSet[0], noWrap: true, style: inlineStyle, children: dataSet[1] }));
23
+ }
24
+ const OuterElementContext = React.createContext({});
25
+ const OuterElementType = React.forwardRef((props, ref) => {
26
+ const outerProps = React.useContext(OuterElementContext);
27
+ return (0, jsx_runtime_1.jsx)("div", { ref: ref, ...props, ...outerProps });
28
+ });
29
+ function useResetCache(data) {
30
+ const ref = React.useRef(null);
31
+ React.useEffect(() => {
32
+ if (ref.current != null) {
33
+ ref.current.resetAfterIndex(0, true);
34
+ }
35
+ }, [data]);
36
+ return ref;
37
+ }
38
+ // Adapter for react-window
39
+ exports.ListboxComponent = React.forwardRef(function ListboxComponent(props, ref) {
40
+ const { children, ...other } = props;
41
+ const itemData = [];
42
+ children.forEach((item) => {
43
+ itemData.push(item);
44
+ itemData.push(...(item.children || []));
45
+ });
46
+ const theme = (0, styles_1.useTheme)();
47
+ const smUp = (0, useMediaQuery_1.default)(theme.breakpoints.up('sm'), {
48
+ noSsr: true,
49
+ });
50
+ const itemCount = itemData.length;
51
+ const itemSize = smUp ? 36 : 48;
52
+ const getChildSize = (child) => {
53
+ if (child.hasOwnProperty('group')) {
54
+ return 48;
55
+ }
56
+ return itemSize;
57
+ };
58
+ const getHeight = () => {
59
+ if (itemCount > 8) {
60
+ return 8 * itemSize;
61
+ }
62
+ return itemData.map(getChildSize).reduce((a, b) => a + b, 0);
63
+ };
64
+ const gridRef = useResetCache(itemCount);
65
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsx)(OuterElementContext.Provider, { value: other, children: (0, jsx_runtime_1.jsx)(react_window_1.VariableSizeList, { itemData: itemData, height: getHeight() + 2 * LISTBOX_PADDING, width: "100%", ref: gridRef, outerElementType: OuterElementType, innerElementType: "ul", itemSize: (index) => getChildSize(itemData[index]), overscanCount: 5, itemCount: itemCount, children: renderRow }) }) }));
66
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zesty-io/material",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Contains custom components which are in addition to the @mui design-system",
5
5
  "author": "Zesty.io",
6
6
  "license": "MIT",
@@ -12,11 +12,13 @@
12
12
  "url": "https://github.com/zesty-io/material/issues"
13
13
  },
14
14
  "homepage": "https://zesty-io.github.io/material",
15
- "main": "es/index.js",
15
+ "main": "cjs/index.js",
16
16
  "module": "es/index.js",
17
17
  "types": "es/index.d.ts",
18
18
  "scripts": {
19
- "build": "npm ci && tsc",
19
+ "build": "npm run build:esm && npm run build:cjs",
20
+ "build:esm": "tsc",
21
+ "build:cjs": "tsc --module commonjs --outDir cjs",
20
22
  "prerelease": "npm test",
21
23
  "release": "npm run build && npm publish --access public",
22
24
  "release:alpha": "npm run build && npm publish --access public --tag alpha",
@@ -56,7 +56,7 @@ const typography: TypographyVariantsOptions = {
56
56
  lineHeight: "22px",
57
57
  },
58
58
  caption: {
59
- fontSize: '20px',
59
+ fontSize: '12px',
60
60
  lineHeight: "20px",
61
61
  },
62
62
  overline: {
@@ -1,24 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
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,6 +0,0 @@
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>;
@@ -1,24 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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;
@@ -1,11 +0,0 @@
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,14 +0,0 @@
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
- };
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useCallback, useState, useEffect } from 'react';
3
- import Button from '@mui/material/Button';
4
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
5
- import CheckIcon from '@mui/icons-material/Check';
6
- const CopyButton = ({ value, sx, ...props }) => {
7
- const [copied, setCopied] = useState(false);
8
- const copyValue = useCallback(() => {
9
- navigator?.clipboard.writeText(value);
10
- setCopied(true);
11
- }, [value]);
12
- useEffect(() => {
13
- const iconTimer = setTimeout(() => {
14
- setCopied(false);
15
- }, 500);
16
- return () => {
17
- clearTimeout(iconTimer);
18
- };
19
- }, [copied]);
20
- return (_jsx(Button, { variant: 'outlined', onClick: copyValue, size: "small", title: props.children ? `Copy ${props.children}` : `Copy ${value}`, sx: {
21
- textTransform: 'unset',
22
- // Spread sx prop at the end to allow sx prop overrides
23
- ...sx,
24
- }, startIcon: copied ? (_jsx(CheckIcon, { color: 'success', fontSize: 'small' })) : (_jsx(ContentCopyIcon, { fontSize: 'small' })), ...props, children: props.children ? props.children : value }));
25
- };
26
- export default CopyButton;
@@ -1,21 +0,0 @@
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
- };
@@ -1,16 +0,0 @@
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;
@@ -1,17 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
- import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
- import { DesktopDatePicker } from '@mui/x-date-pickers';
5
- import { FormControl, FormLabel, TextField } from '@mui/material';
6
- ;
7
- const FieldTypeDate = ({ label, helperText, error, required, ...props }) => {
8
- return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDatePicker, { "data-testid": "zds-date-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
9
- };
10
- export default FieldTypeDate;
@@ -1,17 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
3
- import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
4
- import { DesktopDateTimePicker } from '@mui/x-date-pickers';
5
- import { TextField, FormControl, FormLabel } from '@mui/material';
6
- ;
7
- const FieldTypeDateTime = ({ label, helperText, error, required, ...props }) => {
8
- return (_jsxs(FormControl, { fullWidth: true, required: required, children: [_jsx(FormLabel, { children: label }), _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: _jsx(DesktopDateTimePicker, { "data-testid": "zds-date-time-picker", renderInput: (params) => _jsx(TextField, { ...params, helperText: helperText, error: error, size: "small" }), ...props }) })] }));
9
- };
10
- export default FieldTypeDateTime;
@@ -1,5 +0,0 @@
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>;
@@ -1,35 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
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;
@@ -1,10 +0,0 @@
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;