@etsoo/materialui 1.0.1

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 (250) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.json +38 -0
  3. package/.gitattributes +2 -0
  4. package/.github/workflows/main.yml +48 -0
  5. package/.prettierignore +5 -0
  6. package/.prettierrc +6 -0
  7. package/LICENSE +21 -0
  8. package/README.md +16 -0
  9. package/__tests__/ComboBox.tsx +30 -0
  10. package/__tests__/MUGlobalTests.tsx +58 -0
  11. package/__tests__/NotifierMUTests.tsx +217 -0
  12. package/__tests__/SelectEx.tsx +26 -0
  13. package/__tests__/tsconfig.json +19 -0
  14. package/babel.config.json +11 -0
  15. package/lib/AuditDisplay.d.ts +33 -0
  16. package/lib/AuditDisplay.js +52 -0
  17. package/lib/AutocompleteExtendedProps.d.ts +64 -0
  18. package/lib/AutocompleteExtendedProps.js +1 -0
  19. package/lib/BackButton.d.ts +13 -0
  20. package/lib/BackButton.js +33 -0
  21. package/lib/BridgeCloseButton.d.ts +23 -0
  22. package/lib/BridgeCloseButton.js +32 -0
  23. package/lib/ButtonLink.d.ts +17 -0
  24. package/lib/ButtonLink.js +19 -0
  25. package/lib/ComboBox.d.ts +38 -0
  26. package/lib/ComboBox.js +108 -0
  27. package/lib/CountdownButton.d.ts +23 -0
  28. package/lib/CountdownButton.js +81 -0
  29. package/lib/CustomFabProps.d.ts +27 -0
  30. package/lib/CustomFabProps.js +1 -0
  31. package/lib/DataGridEx.d.ts +94 -0
  32. package/lib/DataGridEx.js +329 -0
  33. package/lib/DataGridRenderers.d.ts +22 -0
  34. package/lib/DataGridRenderers.js +99 -0
  35. package/lib/DialogButton.d.ts +54 -0
  36. package/lib/DialogButton.js +45 -0
  37. package/lib/DnDList.d.ts +87 -0
  38. package/lib/DnDList.js +153 -0
  39. package/lib/DraggablePaperComponent.d.ts +8 -0
  40. package/lib/DraggablePaperComponent.js +12 -0
  41. package/lib/EmailInput.d.ts +11 -0
  42. package/lib/EmailInput.js +15 -0
  43. package/lib/FabBox.d.ts +21 -0
  44. package/lib/FabBox.js +31 -0
  45. package/lib/FlexBox.d.ts +14 -0
  46. package/lib/FlexBox.js +18 -0
  47. package/lib/GridDataFormat.d.ts +10 -0
  48. package/lib/GridDataFormat.js +43 -0
  49. package/lib/IconButtonLink.d.ts +17 -0
  50. package/lib/IconButtonLink.js +16 -0
  51. package/lib/InputField.d.ts +21 -0
  52. package/lib/InputField.js +39 -0
  53. package/lib/ItemList.d.ts +56 -0
  54. package/lib/ItemList.js +69 -0
  55. package/lib/ListItemRightIcon.d.ts +4 -0
  56. package/lib/ListItemRightIcon.js +8 -0
  57. package/lib/ListMoreDisplay.d.ts +35 -0
  58. package/lib/ListMoreDisplay.js +99 -0
  59. package/lib/LoadingButton.d.ts +16 -0
  60. package/lib/LoadingButton.js +41 -0
  61. package/lib/MUGlobal.d.ts +102 -0
  62. package/lib/MUGlobal.js +184 -0
  63. package/lib/MaskInput.d.ts +34 -0
  64. package/lib/MaskInput.js +43 -0
  65. package/lib/MobileListItemRenderer.d.ts +17 -0
  66. package/lib/MobileListItemRenderer.js +35 -0
  67. package/lib/MoreFab.d.ts +45 -0
  68. package/lib/MoreFab.js +95 -0
  69. package/lib/NotifierMU.d.ts +47 -0
  70. package/lib/NotifierMU.js +387 -0
  71. package/lib/NotifierPromptProps.d.ts +22 -0
  72. package/lib/NotifierPromptProps.js +1 -0
  73. package/lib/OptionGroup.d.ts +58 -0
  74. package/lib/OptionGroup.js +81 -0
  75. package/lib/PList.d.ts +15 -0
  76. package/lib/PList.js +12 -0
  77. package/lib/ProgressCount.d.ts +44 -0
  78. package/lib/ProgressCount.js +79 -0
  79. package/lib/PullToRefreshUI.d.ts +9 -0
  80. package/lib/PullToRefreshUI.js +18 -0
  81. package/lib/RLink.d.ts +14 -0
  82. package/lib/RLink.js +37 -0
  83. package/lib/ResponsibleContainer.d.ts +87 -0
  84. package/lib/ResponsibleContainer.js +156 -0
  85. package/lib/ScrollTopFab.d.ts +7 -0
  86. package/lib/ScrollTopFab.js +25 -0
  87. package/lib/ScrollerListEx.d.ts +81 -0
  88. package/lib/ScrollerListEx.js +167 -0
  89. package/lib/SearchBar.d.ts +29 -0
  90. package/lib/SearchBar.js +260 -0
  91. package/lib/SearchField.d.ts +21 -0
  92. package/lib/SearchField.js +39 -0
  93. package/lib/SearchOptionGroup.d.ts +9 -0
  94. package/lib/SearchOptionGroup.js +14 -0
  95. package/lib/SelectBool.d.ts +13 -0
  96. package/lib/SelectBool.js +22 -0
  97. package/lib/SelectEx.d.ts +50 -0
  98. package/lib/SelectEx.js +156 -0
  99. package/lib/ShowDataComparison.d.ts +20 -0
  100. package/lib/ShowDataComparison.js +58 -0
  101. package/lib/Switch.d.ts +29 -0
  102. package/lib/Switch.js +34 -0
  103. package/lib/SwitchAnt.d.ts +25 -0
  104. package/lib/SwitchAnt.js +40 -0
  105. package/lib/TabBox.d.ts +54 -0
  106. package/lib/TabBox.js +31 -0
  107. package/lib/TableEx.d.ts +65 -0
  108. package/lib/TableEx.js +270 -0
  109. package/lib/TextFieldEx.d.ts +101 -0
  110. package/lib/TextFieldEx.js +126 -0
  111. package/lib/Tiplist.d.ts +18 -0
  112. package/lib/Tiplist.js +157 -0
  113. package/lib/TooltipClick.d.ts +15 -0
  114. package/lib/TooltipClick.js +40 -0
  115. package/lib/UserAvatar.d.ts +24 -0
  116. package/lib/UserAvatar.js +25 -0
  117. package/lib/UserAvatarEditor.d.ts +53 -0
  118. package/lib/UserAvatarEditor.js +129 -0
  119. package/lib/app/CommonApp.d.ts +38 -0
  120. package/lib/app/CommonApp.js +149 -0
  121. package/lib/app/IServiceAppSettings.d.ts +11 -0
  122. package/lib/app/IServiceAppSettings.js +1 -0
  123. package/lib/app/IServicePage.d.ts +6 -0
  124. package/lib/app/IServicePage.js +1 -0
  125. package/lib/app/IServiceUser.d.ts +14 -0
  126. package/lib/app/IServiceUser.js +1 -0
  127. package/lib/app/ISmartERPUser.d.ts +14 -0
  128. package/lib/app/ISmartERPUser.js +1 -0
  129. package/lib/app/Labels.d.ts +65 -0
  130. package/lib/app/Labels.js +62 -0
  131. package/lib/app/ReactApp.d.ts +195 -0
  132. package/lib/app/ReactApp.js +296 -0
  133. package/lib/app/ServiceApp.d.ts +78 -0
  134. package/lib/app/ServiceApp.js +244 -0
  135. package/lib/index.d.ts +74 -0
  136. package/lib/index.js +74 -0
  137. package/lib/pages/CommonPage.d.ts +11 -0
  138. package/lib/pages/CommonPage.js +60 -0
  139. package/lib/pages/CommonPageProps.d.ts +59 -0
  140. package/lib/pages/CommonPageProps.js +1 -0
  141. package/lib/pages/DataGridPage.d.ts +9 -0
  142. package/lib/pages/DataGridPage.js +79 -0
  143. package/lib/pages/DataGridPageProps.d.ts +17 -0
  144. package/lib/pages/DataGridPageProps.js +1 -0
  145. package/lib/pages/EditPage.d.ts +33 -0
  146. package/lib/pages/EditPage.js +29 -0
  147. package/lib/pages/FixedListPage.d.ts +15 -0
  148. package/lib/pages/FixedListPage.js +70 -0
  149. package/lib/pages/ListPage.d.ts +9 -0
  150. package/lib/pages/ListPage.js +50 -0
  151. package/lib/pages/ListPageProps.d.ts +7 -0
  152. package/lib/pages/ListPageProps.js +1 -0
  153. package/lib/pages/ResponsivePage.d.ts +9 -0
  154. package/lib/pages/ResponsivePage.js +45 -0
  155. package/lib/pages/ResponsivePageProps.d.ts +39 -0
  156. package/lib/pages/ResponsivePageProps.js +1 -0
  157. package/lib/pages/SearchPageProps.d.ts +30 -0
  158. package/lib/pages/SearchPageProps.js +1 -0
  159. package/lib/pages/TablePage.d.ts +9 -0
  160. package/lib/pages/TablePage.js +69 -0
  161. package/lib/pages/TablePageProps.d.ts +7 -0
  162. package/lib/pages/TablePageProps.js +1 -0
  163. package/lib/pages/ViewPage.d.ts +66 -0
  164. package/lib/pages/ViewPage.js +105 -0
  165. package/lib/texts/DateText.d.ts +34 -0
  166. package/lib/texts/DateText.js +25 -0
  167. package/lib/texts/MoneyText.d.ts +21 -0
  168. package/lib/texts/MoneyText.js +14 -0
  169. package/lib/texts/NumberText.d.ts +25 -0
  170. package/lib/texts/NumberText.js +14 -0
  171. package/package.json +97 -0
  172. package/src/AuditDisplay.tsx +114 -0
  173. package/src/AutocompleteExtendedProps.ts +83 -0
  174. package/src/BackButton.tsx +55 -0
  175. package/src/BridgeCloseButton.tsx +69 -0
  176. package/src/ButtonLink.tsx +32 -0
  177. package/src/ComboBox.tsx +251 -0
  178. package/src/CountdownButton.tsx +119 -0
  179. package/src/CustomFabProps.ts +32 -0
  180. package/src/DataGridEx.tsx +713 -0
  181. package/src/DataGridRenderers.tsx +140 -0
  182. package/src/DialogButton.tsx +163 -0
  183. package/src/DnDList.tsx +344 -0
  184. package/src/DraggablePaperComponent.tsx +19 -0
  185. package/src/EmailInput.tsx +24 -0
  186. package/src/FabBox.tsx +51 -0
  187. package/src/FlexBox.tsx +20 -0
  188. package/src/GridDataFormat.tsx +77 -0
  189. package/src/IconButtonLink.tsx +29 -0
  190. package/src/InputField.tsx +82 -0
  191. package/src/ItemList.tsx +204 -0
  192. package/src/ListItemRightIcon.tsx +9 -0
  193. package/src/ListMoreDisplay.tsx +205 -0
  194. package/src/LoadingButton.tsx +75 -0
  195. package/src/MUGlobal.ts +220 -0
  196. package/src/MaskInput.tsx +107 -0
  197. package/src/MobileListItemRenderer.tsx +79 -0
  198. package/src/MoreFab.tsx +211 -0
  199. package/src/NotifierMU.tsx +654 -0
  200. package/src/NotifierPromptProps.ts +24 -0
  201. package/src/OptionGroup.tsx +223 -0
  202. package/src/PList.tsx +27 -0
  203. package/src/ProgressCount.tsx +166 -0
  204. package/src/PullToRefreshUI.tsx +21 -0
  205. package/src/RLink.tsx +64 -0
  206. package/src/ResponsibleContainer.tsx +394 -0
  207. package/src/ScrollTopFab.tsx +34 -0
  208. package/src/ScrollerListEx.tsx +387 -0
  209. package/src/SearchBar.tsx +396 -0
  210. package/src/SearchField.tsx +82 -0
  211. package/src/SearchOptionGroup.tsx +31 -0
  212. package/src/SelectBool.tsx +33 -0
  213. package/src/SelectEx.tsx +290 -0
  214. package/src/ShowDataComparison.tsx +106 -0
  215. package/src/Switch.tsx +94 -0
  216. package/src/SwitchAnt.tsx +95 -0
  217. package/src/TabBox.tsx +118 -0
  218. package/src/TableEx.tsx +558 -0
  219. package/src/TextFieldEx.tsx +249 -0
  220. package/src/Tiplist.tsx +303 -0
  221. package/src/TooltipClick.tsx +84 -0
  222. package/src/UserAvatar.tsx +64 -0
  223. package/src/UserAvatarEditor.tsx +287 -0
  224. package/src/app/CommonApp.ts +223 -0
  225. package/src/app/IServiceAppSettings.ts +13 -0
  226. package/src/app/IServicePage.ts +6 -0
  227. package/src/app/IServiceUser.ts +17 -0
  228. package/src/app/ISmartERPUser.ts +16 -0
  229. package/src/app/Labels.ts +77 -0
  230. package/src/app/ReactApp.ts +504 -0
  231. package/src/app/ServiceApp.ts +352 -0
  232. package/src/index.ts +77 -0
  233. package/src/pages/CommonPage.tsx +128 -0
  234. package/src/pages/CommonPageProps.ts +70 -0
  235. package/src/pages/DataGridPage.tsx +140 -0
  236. package/src/pages/DataGridPageProps.ts +24 -0
  237. package/src/pages/EditPage.tsx +114 -0
  238. package/src/pages/FixedListPage.tsx +141 -0
  239. package/src/pages/ListPage.tsx +90 -0
  240. package/src/pages/ListPageProps.ts +12 -0
  241. package/src/pages/ResponsivePage.tsx +68 -0
  242. package/src/pages/ResponsivePageProps.ts +57 -0
  243. package/src/pages/SearchPageProps.ts +39 -0
  244. package/src/pages/TablePage.tsx +126 -0
  245. package/src/pages/TablePageProps.ts +12 -0
  246. package/src/pages/ViewPage.tsx +282 -0
  247. package/src/texts/DateText.tsx +74 -0
  248. package/src/texts/MoneyText.tsx +49 -0
  249. package/src/texts/NumberText.tsx +40 -0
  250. package/tsconfig.json +19 -0
@@ -0,0 +1,33 @@
1
+ import { IconButton, useTheme } from '@mui/material';
2
+ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
3
+ import React from 'react';
4
+ import { useNavigate } from 'react-router-dom';
5
+ /**
6
+ * BackButton
7
+ * @param props Props
8
+ * @returns Component
9
+ */
10
+ export function BackButton(props) {
11
+ // Destruct
12
+ const { color = 'primary', size = 'small', onClick, ...rest } = props;
13
+ // Theme
14
+ const theme = useTheme();
15
+ // Navigate
16
+ const navigate = useNavigate();
17
+ // Color
18
+ const pColor = color != 'inherit' && color != 'default' && color in theme.palette
19
+ ? theme.palette[color]
20
+ : theme.palette.primary;
21
+ // Click handler
22
+ const onClickLocal = async (event) => {
23
+ if (onClick)
24
+ onClick(event);
25
+ // Navigate
26
+ navigate(-1);
27
+ };
28
+ return (React.createElement(IconButton, { "aria-label": "Back", color: color, size: size, onClick: onClickLocal, sx: {
29
+ backgroundColor: pColor.contrastText,
30
+ border: `1px solid ${pColor.light}`
31
+ }, ...rest },
32
+ React.createElement(ArrowBackIcon, null)));
33
+ }
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { IBridgeHost } from '@etsoo/appscript';
3
+ import { BoxProps, IconButtonProps } from '@mui/material';
4
+ /**
5
+ * Bridge close button props
6
+ */
7
+ export interface BridgeCloseButtonProps extends IconButtonProps {
8
+ /**
9
+ * Box props
10
+ */
11
+ boxProps?: BoxProps;
12
+ /**
13
+ * Validate the host
14
+ * @param host Host
15
+ */
16
+ validate?(host: IBridgeHost): boolean;
17
+ }
18
+ /**
19
+ * Bridge close button
20
+ * @param props Props
21
+ * @returns Component
22
+ */
23
+ export declare function BridgeCloseButton(props: BridgeCloseButtonProps): JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { BridgeUtils } from '@etsoo/appscript';
2
+ import CloseIcon from '@mui/icons-material/Close';
3
+ import { Box, IconButton } from '@mui/material';
4
+ import React from 'react';
5
+ import { globalApp } from './app/ReactApp';
6
+ /**
7
+ * Bridge close button
8
+ * @param props Props
9
+ * @returns Component
10
+ */
11
+ export function BridgeCloseButton(props) {
12
+ // Destruct
13
+ const { boxProps, onClick, title = typeof globalApp === 'undefined'
14
+ ? 'Close'
15
+ : globalApp.get('close'), validate, ...rest } = props;
16
+ // Host
17
+ const host = BridgeUtils.host;
18
+ if (host == null ||
19
+ !host.closable() ||
20
+ (validate && validate(host) === false)) {
21
+ return React.createElement(React.Fragment, null);
22
+ }
23
+ // Click handler
24
+ const onClickLocal = (event) => {
25
+ if (onClick)
26
+ onClick(event);
27
+ host.exit();
28
+ };
29
+ return (React.createElement(Box, { ...boxProps },
30
+ React.createElement(IconButton, { "aria-label": "close", onClick: onClickLocal, title: title, ...rest },
31
+ React.createElement(CloseIcon, null))));
32
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '@mui/material';
3
+ /**
4
+ * ButtonLink props
5
+ */
6
+ export declare type ButtonLinkProps = Omit<ButtonProps, 'href' | 'onClick'> & {
7
+ /**
8
+ * To href
9
+ */
10
+ href: string;
11
+ };
12
+ /**
13
+ * ButtonLink
14
+ * @param props Props
15
+ * @returns Component
16
+ */
17
+ export declare function ButtonLink(props: ButtonLinkProps): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { Button } from '@mui/material';
2
+ import React from 'react';
3
+ import { useNavigate } from 'react-router-dom';
4
+ /**
5
+ * ButtonLink
6
+ * @param props Props
7
+ * @returns Component
8
+ */
9
+ export function ButtonLink(props) {
10
+ // Destruct
11
+ const { href, ...rest } = props;
12
+ // Navigate
13
+ const navigate = useNavigate();
14
+ const onClick = href.includes('://')
15
+ ? () => window.open(href, '_blank')
16
+ : () => navigate(href);
17
+ // Layout
18
+ return React.createElement(Button, { ...rest, onClick: onClick });
19
+ }
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
3
+ import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
4
+ /**
5
+ * ComboBox props
6
+ */
7
+ export declare type ComboBoxProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> = AutocompleteExtendedProps<T, D> & {
8
+ /**
9
+ * Auto add blank item
10
+ */
11
+ autoAddBlankItem?: boolean;
12
+ /**
13
+ * Data readonly
14
+ */
15
+ dataReadonly?: boolean;
16
+ /**
17
+ * Label field
18
+ */
19
+ labelField?: L;
20
+ /**
21
+ * Load data callback
22
+ */
23
+ loadData?: () => PromiseLike<T[] | null | undefined>;
24
+ /**
25
+ * On load data handler
26
+ */
27
+ onLoadData?: (options: T[]) => void;
28
+ /**
29
+ * Array of options.
30
+ */
31
+ options?: ReadonlyArray<T>;
32
+ };
33
+ /**
34
+ * ComboBox
35
+ * @param props Props
36
+ * @returns Component
37
+ */
38
+ export declare function ComboBox<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: ComboBoxProps<T, D, L>): JSX.Element;
@@ -0,0 +1,108 @@
1
+ import { Keyboard } from '@etsoo/shared';
2
+ import { Autocomplete } from '@mui/material';
3
+ import React from 'react';
4
+ import { Utils as SharedUtils } from '@etsoo/shared';
5
+ import { InputField } from './InputField';
6
+ import { SearchField } from './SearchField';
7
+ import { ReactUtils } from '@etsoo/react';
8
+ /**
9
+ * ComboBox
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export function ComboBox(props) {
14
+ // Destruct
15
+ const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: '150px' }, ...rest } = props;
16
+ // Value input ref
17
+ const inputRef = React.createRef();
18
+ // Options state
19
+ const [localOptions, setOptions] = React.useState(options !== null && options !== void 0 ? options : []);
20
+ const isMounted = React.useRef(true);
21
+ // When options change
22
+ // [options] will cause infinite loop
23
+ const propertyWay = loadData == null;
24
+ React.useEffect(() => {
25
+ if (propertyWay && options != null)
26
+ setOptions(options);
27
+ }, [JSON.stringify(options), propertyWay]);
28
+ // Local default value
29
+ let localValue = idValue != null
30
+ ? localOptions.find((o) => o[idField] === idValue)
31
+ : defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
32
+ if (localValue === undefined)
33
+ localValue = null;
34
+ // State
35
+ // null for controlled
36
+ const [stateValue, setStateValue] = React.useState(null);
37
+ // Current id value
38
+ // One time calculation for input's default value (uncontrolled)
39
+ const localIdValue = stateValue && stateValue[idField];
40
+ React.useEffect(() => {
41
+ if (localValue != null)
42
+ setStateValue(localValue);
43
+ }, [localValue]);
44
+ // Add readOnly
45
+ const addReadOnly = (params) => {
46
+ if (readOnly != null) {
47
+ Object.assign(params, { readOnly });
48
+ if (readOnly) {
49
+ Object.assign(params.inputProps, { 'data-reset': true });
50
+ }
51
+ }
52
+ if (dataReadonly) {
53
+ params.inputProps.onKeyDown = (event) => {
54
+ if (Keyboard.isTypingContent(event.key)) {
55
+ event.preventDefault();
56
+ }
57
+ };
58
+ }
59
+ // https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
60
+ // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html
61
+ Object.assign(params.inputProps, { autoComplete: inputAutoComplete });
62
+ return params;
63
+ };
64
+ const setInputValue = (value) => {
65
+ // Set state
66
+ setStateValue(value);
67
+ // Input value
68
+ const input = inputRef.current;
69
+ if (input) {
70
+ // Update value
71
+ const newValue = value != null ? `${value[idField]}` : '';
72
+ if (newValue !== input.value) {
73
+ // Different value, trigger change event
74
+ ReactUtils.triggerChange(input, newValue, false);
75
+ }
76
+ }
77
+ };
78
+ // When value change
79
+ React.useEffect(() => {
80
+ if (loadData) {
81
+ loadData().then((result) => {
82
+ if (result == null || !isMounted.current)
83
+ return;
84
+ if (onLoadData)
85
+ onLoadData(result);
86
+ if (autoAddBlankItem) {
87
+ SharedUtils.addBlankItem(result, idField, labelField);
88
+ }
89
+ setOptions(result);
90
+ });
91
+ }
92
+ }, [localValue]);
93
+ React.useEffect(() => {
94
+ return () => {
95
+ isMounted.current = false;
96
+ };
97
+ }, []);
98
+ // Layout
99
+ return (React.createElement("div", null,
100
+ React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${localIdValue !== null && localIdValue !== void 0 ? localIdValue : ''}`, readOnly: true, onChange: inputOnChange }),
101
+ React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
102
+ // Set value
103
+ setInputValue(value);
104
+ // Custom
105
+ if (onChange != null)
106
+ onChange(event, value, reason, details);
107
+ }, openOnFocus: openOnFocus, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })), options: localOptions, ...rest })));
108
+ }
@@ -0,0 +1,23 @@
1
+ import { ButtonProps } from '@mui/material';
2
+ import React from 'react';
3
+ /**
4
+ * Countdown button action
5
+ */
6
+ export interface CountdownButtonAction {
7
+ (): Promise<number>;
8
+ }
9
+ /**
10
+ * Countdown button props
11
+ */
12
+ export declare type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabled'> & {
13
+ /**
14
+ * Action, required
15
+ */
16
+ onAction: CountdownButtonAction;
17
+ };
18
+ /**
19
+ * Countdown button
20
+ * @param props Props
21
+ * @returns Button
22
+ */
23
+ export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "form" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "type" | "size" | "name" | "href" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "fullWidth" | "startIcon" | "onAction"> & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,81 @@
1
+ import { Button, CircularProgress } from '@mui/material';
2
+ import React from 'react';
3
+ /**
4
+ * Countdown button
5
+ * @param props Props
6
+ * @returns Button
7
+ */
8
+ export const CountdownButton = React.forwardRef((props, ref) => {
9
+ // Destructure
10
+ const { onAction, onClick, ...rest } = props;
11
+ // State
12
+ // 0 - normal
13
+ // 1 - loading
14
+ // 2 - countdown
15
+ const [state, updateState] = React.useState(0);
16
+ // Ignore seconds
17
+ const seconds = 2;
18
+ // Countdown length
19
+ const [shared] = React.useState({ maxLength: 0 });
20
+ const isMounted = React.useRef(true);
21
+ // endIcon
22
+ let endIcon;
23
+ if (state === 0) {
24
+ endIcon = undefined;
25
+ }
26
+ else if (state === 1) {
27
+ endIcon = React.createElement(CircularProgress, { size: 12 });
28
+ }
29
+ else {
30
+ const countdown = (state - seconds)
31
+ .toString()
32
+ .padStart(shared.maxLength, '0');
33
+ endIcon = React.createElement("span", { style: { fontSize: 'smaller' } }, countdown);
34
+ }
35
+ // Disabled?
36
+ const disabled = state > 0;
37
+ // Action
38
+ const doAction = (result) => {
39
+ // Seconds to wait, 120
40
+ if (result > seconds) {
41
+ // Here 122
42
+ result += seconds;
43
+ updateState(result);
44
+ // Update max length
45
+ shared.maxLength = result.toString().length;
46
+ const seed = setInterval(() => {
47
+ // Mounted?
48
+ if (!isMounted.current)
49
+ return;
50
+ // Last 1 second and then complete
51
+ if (result > seconds + 1) {
52
+ result--;
53
+ updateState(result);
54
+ }
55
+ else {
56
+ clearInterval(seed);
57
+ updateState(0);
58
+ }
59
+ }, 1000);
60
+ }
61
+ else {
62
+ updateState(0);
63
+ }
64
+ };
65
+ // Local click
66
+ const localClick = (event) => {
67
+ // Show loading
68
+ updateState(1);
69
+ // Callback
70
+ if (onClick != null)
71
+ onClick(event);
72
+ // Return any countdown
73
+ onAction().then(doAction);
74
+ };
75
+ React.useEffect(() => {
76
+ return () => {
77
+ isMounted.current = false;
78
+ };
79
+ }, []);
80
+ return (React.createElement(Button, { disabled: disabled, endIcon: endIcon, onClick: localClick, ref: ref, ...rest }));
81
+ });
@@ -0,0 +1,27 @@
1
+ import { FabPropsColorOverrides, PropTypes } from '@mui/material';
2
+ import { OverridableStringUnion } from '@mui/types';
3
+ /**
4
+ * Custom fab size
5
+ */
6
+ export declare type CustomFabSize = 'small' | 'medium' | 'large';
7
+ /**
8
+ * Custom fab props
9
+ */
10
+ export interface CustomFabProps {
11
+ /**
12
+ * Color
13
+ */
14
+ color?: OverridableStringUnion<PropTypes.Color, FabPropsColorOverrides>;
15
+ /**
16
+ * Fab size
17
+ */
18
+ size?: CustomFabSize;
19
+ /**
20
+ * Scroll target
21
+ */
22
+ target?: any;
23
+ /**
24
+ * Fab title
25
+ */
26
+ title?: string;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
1
+ import { GridColumn, GridLoaderStates, ScrollerGridProps } from '@etsoo/react';
2
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
+ import React from 'react';
4
+ import { MouseEventWithDataHandler } from './MUGlobal';
5
+ /**
6
+ * Footer item renderer props
7
+ */
8
+ export declare type DataGridExFooterItemRendererProps<T extends object> = {
9
+ column: GridColumn<T>;
10
+ index: number;
11
+ states: GridLoaderStates<T>;
12
+ cellProps: any;
13
+ checkable: boolean;
14
+ };
15
+ /**
16
+ * Extended DataGrid with VariableSizeGrid props
17
+ */
18
+ export declare type DataGridExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> & {
19
+ /**
20
+ * Alternating colors for odd/even rows
21
+ */
22
+ alternatingColors?: [string?, string?];
23
+ /**
24
+ * Checkable to choose multiple items
25
+ * @default false
26
+ */
27
+ checkable?: boolean;
28
+ /**
29
+ * Rows count to have the bottom border
30
+ */
31
+ borderRowsCount?: number;
32
+ /**
33
+ * Bottom height
34
+ */
35
+ bottomHeight?: number;
36
+ /**
37
+ * Columns
38
+ */
39
+ columns: GridColumn<T>[];
40
+ /**
41
+ * Footer item renderer
42
+ */
43
+ footerItemRenderer?: (rows: T[], props: DataGridExFooterItemRendererProps<T>) => React.ReactNode;
44
+ /**
45
+ * Header height
46
+ * @default 56
47
+ */
48
+ headerHeight?: number;
49
+ /**
50
+ * Hide the footer
51
+ * @default false
52
+ */
53
+ hideFooter?: boolean;
54
+ /**
55
+ * Hover color
56
+ */
57
+ hoverColor?: string;
58
+ /**
59
+ * Double click handler
60
+ */
61
+ onDoubleClick?: MouseEventWithDataHandler<T>;
62
+ /**
63
+ * Click handler
64
+ */
65
+ onClick?: MouseEventWithDataHandler<T>;
66
+ /**
67
+ * Selectable to support hover over and out effect and row clickable
68
+ * @default true
69
+ */
70
+ selectable?: boolean;
71
+ /**
72
+ * Selected color
73
+ */
74
+ selectedColor?: string;
75
+ /**
76
+ * Width
77
+ */
78
+ width?: number;
79
+ };
80
+ /**
81
+ * Extended datagrid columns calculation
82
+ * @param columns
83
+ * @returns Total width and unset items
84
+ */
85
+ export declare function DataGridExCalColumns<T>(columns: GridColumn<T>[]): {
86
+ total: number;
87
+ unset: number;
88
+ };
89
+ /**
90
+ * Extended DataGrid with VariableSizeGrid
91
+ * @param props Props
92
+ * @returns Component
93
+ */
94
+ export declare function DataGridEx<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: DataGridExProps<T, D>): JSX.Element;