@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
package/lib/MoreFab.js ADDED
@@ -0,0 +1,95 @@
1
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
2
+ import React from 'react';
3
+ import { Divider, Fab, IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
4
+ import { Link } from 'react-router-dom';
5
+ function getActions(input) {
6
+ // Actions
7
+ const actions = [];
8
+ input.forEach((action) => {
9
+ if (typeof action === 'boolean')
10
+ return;
11
+ actions.push(action);
12
+ });
13
+ return actions;
14
+ }
15
+ /**
16
+ * More fab
17
+ * @returns Component
18
+ */
19
+ export function MoreFab(props) {
20
+ // Destruct
21
+ const { actions, drawArrow = true, anchorOrigin = {
22
+ vertical: 'top',
23
+ horizontal: 'right'
24
+ }, color = 'primary', icon = React.createElement(MoreHorizIcon, null), iconButton = false, PaperProps = drawArrow
25
+ ? {
26
+ elevation: 0,
27
+ sx: {
28
+ overflow: 'visible',
29
+ filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
30
+ mt: -0.4,
31
+ '& .MuiAvatar-root': {
32
+ width: 32,
33
+ height: 32,
34
+ ml: -0.5,
35
+ mr: 1
36
+ },
37
+ '&:before': {
38
+ content: '""',
39
+ display: 'block',
40
+ position: 'absolute',
41
+ top: 0,
42
+ right: 14,
43
+ width: 10,
44
+ height: 10,
45
+ bgcolor: 'background.paper',
46
+ transform: 'translateY(-50%) rotate(45deg)',
47
+ zIndex: 0
48
+ }
49
+ }
50
+ }
51
+ : undefined, size, title, transformOrigin = {
52
+ vertical: 'bottom',
53
+ horizontal: 'right'
54
+ } } = props;
55
+ // State
56
+ const [anchorEl, setAnchorEl] = React.useState();
57
+ // Open state
58
+ const open = Boolean(anchorEl);
59
+ // Handle click
60
+ const handleClick = (event) => {
61
+ setAnchorEl(event.currentTarget);
62
+ };
63
+ // Handle close
64
+ const handleClose = () => {
65
+ setAnchorEl(undefined);
66
+ };
67
+ // No actions
68
+ if (actions == null || actions.length == 0)
69
+ return React.createElement(React.Fragment, null);
70
+ // Actions
71
+ const actionsLocal = getActions(actions);
72
+ // Has any icon
73
+ const hasIcon = actionsLocal.some((action) => action.icon != null);
74
+ // Main
75
+ const main = iconButton ? (React.createElement(IconButton, { color: color, size: size, title: title, onClick: handleClick }, icon)) : (React.createElement(Fab, { color: color, size: size, title: title, onClick: handleClick }, icon));
76
+ return (React.createElement(React.Fragment, null,
77
+ main,
78
+ React.createElement(Menu, { disableScrollLock: true, anchorEl: anchorEl, anchorOrigin: anchorOrigin, keepMounted: true, transformOrigin: transformOrigin, open: open, onClose: handleClose, PaperProps: PaperProps }, actionsLocal.map(({ label, icon, action }, index) => label === '-' ? (React.createElement(Divider, { key: index })) : (React.createElement(MenuItem, { key: label, ...(typeof action === 'string'
79
+ ? action.includes('://')
80
+ ? {
81
+ component: 'a',
82
+ href: action,
83
+ target: '_blank'
84
+ }
85
+ : { component: Link, to: action }
86
+ : {
87
+ onClick: () => {
88
+ handleClose();
89
+ if (typeof action === 'function')
90
+ action();
91
+ }
92
+ }) },
93
+ icon != null && (React.createElement(ListItemIcon, null, icon)),
94
+ React.createElement(ListItemText, { inset: icon == null && hasIcon }, label)))))));
95
+ }
@@ -0,0 +1,47 @@
1
+ import { NotificationAlign, NotificationRenderProps } from '@etsoo/notificationbase';
2
+ import React from 'react';
3
+ import { INotificationBaseReact, INotificationReact, NotificationReact, NotifierReact } from '@etsoo/react';
4
+ /**
5
+ * MU notification
6
+ */
7
+ export declare class NotificationMU extends NotificationReact {
8
+ private returnValue;
9
+ private createAlert;
10
+ private createConfirm;
11
+ private createMessageColor;
12
+ private createMessage;
13
+ private createPrompt;
14
+ private createLoading;
15
+ /**
16
+ * Render method
17
+ * @param props Props
18
+ * @param className Style class name
19
+ * @param classes Style classes
20
+ */
21
+ render(props: NotificationRenderProps, className: string): JSX.Element;
22
+ }
23
+ /**
24
+ * Antd notifier
25
+ */
26
+ export declare class NotifierMU extends NotifierReact {
27
+ /**
28
+ * Create state and return provider
29
+ * @param className Style class name
30
+ * @returns Provider
31
+ */
32
+ static setup(className?: string): React.FunctionComponent<React.PropsWithChildren<import("@etsoo/react").NotificationReactRenderProps>>;
33
+ private static getOrigin;
34
+ /**
35
+ * Create align container
36
+ * @param align Align
37
+ * @param children Children
38
+ * @param options Other options
39
+ */
40
+ protected createContainer: (align: NotificationAlign, children: React.ReactNode[]) => JSX.Element;
41
+ /**
42
+ * Add raw definition
43
+ * @param data Notification data definition
44
+ * @param modal Show as modal
45
+ */
46
+ protected addRaw(data: INotificationBaseReact, modal?: boolean): INotificationReact;
47
+ }
@@ -0,0 +1,387 @@
1
+ import { NotificationAlign, NotificationMessageType, NotificationType } from '@etsoo/notificationbase';
2
+ import { Alert, AlertTitle, Backdrop, Box, Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Fade, Slider, Snackbar, styled, Switch, TextField, Typography } from '@mui/material';
3
+ import { Error, Info, Help, Warning, Done } from '@mui/icons-material';
4
+ import React from 'react';
5
+ import { NotificationReact, NotifierReact } from '@etsoo/react';
6
+ import { DraggablePaperComponent } from './DraggablePaperComponent';
7
+ import { LoadingButton } from './LoadingButton';
8
+ import { Labels } from './app/Labels';
9
+ // Custom icon dialog title bar
10
+ const IconDialogTitle = styled(DialogTitle) `
11
+ ${({ theme }) => `
12
+ cursor: move;
13
+ display: flex;
14
+ align-items: center;
15
+ & .dialogTitle {
16
+ font-weight: bold;
17
+ font-size: 1.17em;
18
+ padding-left: ${theme.spacing(1)};
19
+ }
20
+ `}
21
+ `;
22
+ /**
23
+ * MU notification
24
+ */
25
+ export class NotificationMU extends NotificationReact {
26
+ // On return
27
+ // Dismiss first, then run callback
28
+ async returnValue(value) {
29
+ if (this.onReturn) {
30
+ const result = await this.onReturn(value);
31
+ if (result === false)
32
+ return;
33
+ }
34
+ this.dismiss();
35
+ }
36
+ // Create alert
37
+ createAlert(_props, className) {
38
+ var _a;
39
+ const labels = Labels.NotificationMU;
40
+ const { inputs, fullScreen, fullWidth = true, maxWidth, okLabel = labels.alertOK, primaryButton } = (_a = this.inputProps) !== null && _a !== void 0 ? _a : {};
41
+ let title = this.title;
42
+ let icon;
43
+ if (this.type === NotificationMessageType.Success) {
44
+ icon = React.createElement(Done, { color: "primary" });
45
+ title !== null && title !== void 0 ? title : (title = labels.success);
46
+ }
47
+ else if (this.type === NotificationMessageType.Info) {
48
+ icon = React.createElement(Info, null);
49
+ title !== null && title !== void 0 ? title : (title = labels.info);
50
+ }
51
+ else if (this.type === NotificationMessageType.Warning) {
52
+ icon = React.createElement(Warning, { color: "secondary" });
53
+ title !== null && title !== void 0 ? title : (title = labels.warning);
54
+ }
55
+ else {
56
+ icon = React.createElement(Error, { color: "error" });
57
+ title !== null && title !== void 0 ? title : (title = labels.alertTitle);
58
+ }
59
+ const setupProps = {
60
+ color: 'primary'
61
+ };
62
+ // Setup callback
63
+ if (this.renderSetup)
64
+ this.renderSetup(setupProps);
65
+ return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
66
+ React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
67
+ icon,
68
+ React.createElement("span", { className: "dialogTitle" }, title)),
69
+ React.createElement(DialogContent, null,
70
+ React.createElement(DialogContentText, null, this.content),
71
+ inputs),
72
+ React.createElement(DialogActions, null,
73
+ React.createElement(LoadingButton, { ...setupProps, onClick: async () => await this.returnValue(undefined), autoFocus: true, ...primaryButton }, okLabel))));
74
+ }
75
+ // Create confirm
76
+ createConfirm(_props, className) {
77
+ var _a, _b;
78
+ const labels = Labels.NotificationMU;
79
+ const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.confirmTitle;
80
+ const { okLabel = labels.confirmYes, cancelLabel = labels.confirmNo, cancelButton = true, inputs, fullScreen, fullWidth = true, maxWidth, primaryButton } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
81
+ return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
82
+ React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
83
+ React.createElement(Help, { color: "action" }),
84
+ React.createElement("span", { className: "dialogTitle" }, title)),
85
+ React.createElement(DialogContent, null,
86
+ React.createElement(DialogContentText, null, this.content),
87
+ inputs),
88
+ React.createElement(DialogActions, null,
89
+ cancelButton && (React.createElement(LoadingButton, { color: "secondary", onClick: async () => await this.returnValue(false) }, cancelLabel)),
90
+ React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(true), autoFocus: true, ...primaryButton }, okLabel))));
91
+ }
92
+ createMessageColor() {
93
+ if (this.type === NotificationMessageType.Danger)
94
+ return 'error';
95
+ if (this.type === NotificationMessageType.Success)
96
+ return 'success';
97
+ if (this.type === NotificationMessageType.Warning)
98
+ return 'warning';
99
+ return 'info';
100
+ }
101
+ // Create message
102
+ createMessage(_props, className) {
103
+ if (!this.open)
104
+ return React.createElement(React.Fragment, { key: this.id });
105
+ const setupProps = {
106
+ severity: this.createMessageColor(),
107
+ variant: 'filled'
108
+ };
109
+ // Setup callback
110
+ if (this.renderSetup)
111
+ this.renderSetup(setupProps);
112
+ return (React.createElement(Fade, { in: true, key: this.id },
113
+ React.createElement(Alert, { ...setupProps, onClose: () => this.dismiss(), className: className },
114
+ this.title && React.createElement(AlertTitle, null, this.title),
115
+ this.content)));
116
+ }
117
+ // Create prompt
118
+ createPrompt(_props, className) {
119
+ var _a, _b;
120
+ const labels = Labels.NotificationMU;
121
+ const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.promptTitle;
122
+ const { cancelLabel = labels.promptCancel, okLabel = labels.promptOK, cancelButton = true, inputs, type, fullScreen, fullWidth = true, maxWidth, primaryButton, ...rest } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
123
+ const inputRef = React.createRef();
124
+ const errorRef = React.createRef();
125
+ const setError = (error) => {
126
+ if (errorRef.current == null)
127
+ return;
128
+ errorRef.current.innerText = error !== null && error !== void 0 ? error : '';
129
+ };
130
+ const handleSubmit = async (event) => {
131
+ // Result
132
+ let result = undefined;
133
+ const input = inputRef.current;
134
+ if (this.onReturn) {
135
+ // Inputs case, no HTMLForm set to value, set the current form
136
+ if (inputs && value == null)
137
+ value = event.currentTarget.form;
138
+ if (input) {
139
+ if (type === 'date') {
140
+ const dateValue = input.valueAsDate;
141
+ if (dateValue == null && input.required) {
142
+ input.focus();
143
+ return;
144
+ }
145
+ result = this.onReturn(dateValue);
146
+ }
147
+ else if (type === 'number') {
148
+ const numberValue = input.valueAsNumber;
149
+ if (isNaN(numberValue) && input.required) {
150
+ input.focus();
151
+ return;
152
+ }
153
+ result = this.onReturn(numberValue);
154
+ }
155
+ else if (type === 'switch') {
156
+ const boolValue = input.value === 'true';
157
+ result = this.onReturn(boolValue);
158
+ }
159
+ else {
160
+ const textValue = input.value.trim();
161
+ if (textValue === '' && input.required) {
162
+ input.focus();
163
+ return;
164
+ }
165
+ result = this.onReturn(textValue);
166
+ }
167
+ }
168
+ else if (value != null) {
169
+ result = this.onReturn(value);
170
+ }
171
+ }
172
+ // Get the value
173
+ // returns false to prevent default dismiss
174
+ const v = await result;
175
+ if (v === false) {
176
+ input === null || input === void 0 ? void 0 : input.focus();
177
+ return;
178
+ }
179
+ if (typeof v === 'string') {
180
+ setError(v);
181
+ input === null || input === void 0 ? void 0 : input.focus();
182
+ return;
183
+ }
184
+ this.dismiss();
185
+ };
186
+ let localInputs;
187
+ let value = undefined;
188
+ if (inputs == null) {
189
+ if (type === 'switch') {
190
+ localInputs = (React.createElement(Switch, { inputRef: inputRef, ...rest, value: "true", autoFocus: true, required: true }));
191
+ }
192
+ else if (type === 'slider') {
193
+ localInputs = React.createElement(Slider, { onChange: (_e, v) => (value = v) });
194
+ }
195
+ else {
196
+ localInputs = (React.createElement(TextField, { inputRef: inputRef, onChange: () => setError(undefined), autoFocus: true, margin: "dense", fullWidth: true, type: type, required: true, ...rest }));
197
+ }
198
+ }
199
+ else {
200
+ localInputs = inputs;
201
+ }
202
+ return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
203
+ React.createElement("form", { onSubmit: (event) => {
204
+ var _a;
205
+ event.preventDefault();
206
+ (_a = event.currentTarget.elements.namedItem('okButton')) === null || _a === void 0 ? void 0 : _a.click();
207
+ return false;
208
+ } },
209
+ React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
210
+ React.createElement(Info, { color: "primary" }),
211
+ React.createElement("span", { className: "dialogTitle" }, title)),
212
+ React.createElement(DialogContent, null,
213
+ React.createElement(DialogContentText, null, this.content),
214
+ localInputs,
215
+ React.createElement(Typography, { variant: "caption", display: "block", ref: errorRef, color: (theme) => theme.palette.error.main })),
216
+ React.createElement(DialogActions, null,
217
+ cancelButton && (React.createElement(Button, { color: "secondary", onClick: () => {
218
+ if (this.onReturn)
219
+ this.onReturn(undefined);
220
+ this.dismiss();
221
+ } }, cancelLabel)),
222
+ React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButton }, okLabel)))));
223
+ }
224
+ // Create loading
225
+ createLoading(_props, className) {
226
+ var _a;
227
+ // Properties
228
+ const setupProps = { color: 'primary' };
229
+ const labels = Labels.NotificationMU;
230
+ // Input props
231
+ const { maxWidth = 'xs' } = (_a = this.inputProps) !== null && _a !== void 0 ? _a : {};
232
+ // Content
233
+ let content = this.content;
234
+ if (content === '@')
235
+ content = labels.loading.toString();
236
+ // Setup callback
237
+ if (this.renderSetup)
238
+ this.renderSetup(setupProps);
239
+ return (React.createElement(Backdrop, { key: this.id, className: className, sx: {
240
+ color: '#fff',
241
+ zIndex: (theme) => theme.zIndex.modal + 1
242
+ }, open: this.open },
243
+ React.createElement(Box, { display: "flex", flexDirection: "column", flexWrap: "nowrap", alignItems: "center", sx: {
244
+ '& > :not(style) + :not(style)': {
245
+ marginTop: (theme) => theme.spacing(1)
246
+ }
247
+ } },
248
+ React.createElement(CircularProgress, { ...setupProps }),
249
+ content && (React.createElement(Box, { maxWidth: maxWidth === false ? undefined : maxWidth }, content)))));
250
+ }
251
+ /**
252
+ * Render method
253
+ * @param props Props
254
+ * @param className Style class name
255
+ * @param classes Style classes
256
+ */
257
+ render(props, className) {
258
+ // Loading bar
259
+ if (this.type === NotificationType.Loading) {
260
+ return this.createLoading(props, className);
261
+ }
262
+ else if (this.type === NotificationType.Confirm) {
263
+ return this.createConfirm(props, className);
264
+ }
265
+ else if (this.type === NotificationType.Prompt) {
266
+ return this.createPrompt(props, className);
267
+ }
268
+ else if (this.type === NotificationType.Error ||
269
+ (this.modal && this.type in NotificationMessageType)) {
270
+ // Alert or modal message
271
+ return this.createAlert(props, className);
272
+ }
273
+ else {
274
+ return this.createMessage(props, className);
275
+ }
276
+ }
277
+ }
278
+ /**
279
+ * Antd notifier
280
+ */
281
+ export class NotifierMU extends NotifierReact {
282
+ constructor() {
283
+ super(...arguments);
284
+ /**
285
+ * Create align container
286
+ * @param align Align
287
+ * @param children Children
288
+ * @param options Other options
289
+ */
290
+ this.createContainer = (align, children) => {
291
+ // Each align group, class equal to something similar to 'align-topleft'
292
+ const alignText = NotificationAlign[align].toLowerCase();
293
+ let className = `align-${alignText}`;
294
+ if (children.length === 0) {
295
+ return React.createElement("div", { key: `empty-${alignText}`, className: className });
296
+ }
297
+ if (align === NotificationAlign.Unknown) {
298
+ // div container for style control
299
+ return (React.createElement("div", { key: `div-${alignText}`, className: className }, children));
300
+ }
301
+ // Use SnackBar for layout
302
+ return (React.createElement(Snackbar, { anchorOrigin: NotifierMU.getOrigin(align), className: className, key: `layout-${alignText}`, sx: align === NotificationAlign.Center
303
+ ? { position: 'fixed', top: '50%!important' }
304
+ : undefined, open: true },
305
+ React.createElement(Box, { display: "flex", flexDirection: "column", flexWrap: "nowrap", key: `box-${alignText}`, sx: {
306
+ '& > :not(style) + :not(style)': {
307
+ marginTop: (theme) => theme.spacing(1)
308
+ }
309
+ } }, children)));
310
+ };
311
+ }
312
+ /**
313
+ * Create state and return provider
314
+ * @param className Style class name
315
+ * @returns Provider
316
+ */
317
+ static setup(className = 'notifier-mu') {
318
+ // Create an instance
319
+ const instance = new NotifierMU();
320
+ const provider = instance.createProvider(className);
321
+ NotifierReact.updateInstance(instance);
322
+ return provider;
323
+ }
324
+ // Calculate origin from align property
325
+ static getOrigin(align) {
326
+ if (align === NotificationAlign.TopLeft) {
327
+ return {
328
+ horizontal: 'left',
329
+ vertical: 'top'
330
+ };
331
+ }
332
+ if (align === NotificationAlign.TopCenter) {
333
+ return {
334
+ horizontal: 'center',
335
+ vertical: 'top'
336
+ };
337
+ }
338
+ if (align === NotificationAlign.TopRight) {
339
+ return {
340
+ horizontal: 'right',
341
+ vertical: 'top'
342
+ };
343
+ }
344
+ if (align === NotificationAlign.BottomLeft) {
345
+ return {
346
+ horizontal: 'left',
347
+ vertical: 'bottom'
348
+ };
349
+ }
350
+ if (align === NotificationAlign.BottomCenter) {
351
+ return {
352
+ horizontal: 'center',
353
+ vertical: 'bottom'
354
+ };
355
+ }
356
+ if (align === NotificationAlign.BottomRight) {
357
+ return {
358
+ horizontal: 'right',
359
+ vertical: 'bottom'
360
+ };
361
+ }
362
+ return {
363
+ horizontal: 'center',
364
+ vertical: 'top'
365
+ };
366
+ }
367
+ /**
368
+ * Add raw definition
369
+ * @param data Notification data definition
370
+ * @param modal Show as modal
371
+ */
372
+ addRaw(data, modal) {
373
+ // Destruct
374
+ const { type, content, title, align, timespan = modal ? 0 : undefined, ...rest } = data;
375
+ // Setup
376
+ const n = new NotificationMU(type, content, title, align, timespan);
377
+ // Assign other properties
378
+ Object.assign(n, rest);
379
+ // Is modal
380
+ if (modal != null)
381
+ n.modal = modal;
382
+ // Add to the collection
383
+ this.add(n);
384
+ // Return
385
+ return n;
386
+ }
387
+ }
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Notifier prompt props
4
+ */
5
+ export declare type NotifierPromptProps = Record<string, any> & {
6
+ /**
7
+ * Cancel label
8
+ */
9
+ cancelLabel?: string;
10
+ /**
11
+ * OK label
12
+ */
13
+ okLabel?: string;
14
+ /**
15
+ * Multiple inputs
16
+ */
17
+ inputs: React.ReactNode;
18
+ /**
19
+ * Single type
20
+ */
21
+ type?: string;
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ /// <reference types="react" />
2
+ import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
3
+ import { FormControlProps } from '@mui/material';
4
+ /**
5
+ * OptionGroup props
6
+ */
7
+ export declare type OptionGroupProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
8
+ /**
9
+ * Default value
10
+ */
11
+ defaultValue?: T[D] | T[D][];
12
+ /**
13
+ * Get option label function
14
+ */
15
+ getOptionLabel?: (option: T) => string;
16
+ /**
17
+ * Id field
18
+ */
19
+ idField?: D;
20
+ /**
21
+ * Label
22
+ */
23
+ label?: string;
24
+ /**
25
+ * Label field
26
+ */
27
+ labelField?: L;
28
+ /**
29
+ * Multiple choose item
30
+ */
31
+ multiple?: boolean;
32
+ /**
33
+ * Field name
34
+ */
35
+ name: string;
36
+ /**
37
+ * On value change handler
38
+ */
39
+ onValueChange?: (value: T[D] | T[D][] | undefined) => void;
40
+ /**
41
+ * Array of options.
42
+ */
43
+ options: ReadonlyArray<T>;
44
+ /**
45
+ * Is the field read only?
46
+ */
47
+ readOnly?: boolean;
48
+ /**
49
+ * Display group of elements in a compact row
50
+ */
51
+ row?: boolean;
52
+ };
53
+ /**
54
+ * OptionGroup
55
+ * @param props Props
56
+ * @returns Component
57
+ */
58
+ export declare function OptionGroup<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: OptionGroupProps<T, D, L>): JSX.Element;