@etsoo/react 1.5.80 → 1.5.83

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 (259) hide show
  1. package/README.md +7 -2
  2. package/__tests__/ReactUtils.ts +6 -0
  3. package/lib/{mu → components}/DnDList.d.ts +1 -14
  4. package/lib/{mu → components}/DnDList.js +1 -24
  5. package/lib/components/GridMethodRef.d.ts +11 -0
  6. package/lib/{mu → components}/GridMethodRef.js +0 -0
  7. package/lib/components/ScrollerGrid.d.ts +3 -3
  8. package/lib/components/ScrollerList.d.ts +3 -3
  9. package/lib/index.d.ts +2 -74
  10. package/lib/index.js +2 -75
  11. package/lib/notifier/Notifier.d.ts +2 -3
  12. package/lib/states/UserState.d.ts +1 -1
  13. package/lib/uses/useWindowScroll.d.ts +10 -0
  14. package/lib/uses/useWindowScroll.js +46 -0
  15. package/lib/uses/useWindowSize.js +11 -5
  16. package/package.json +4 -16
  17. package/src/{mu → components}/DnDList.tsx +11 -34
  18. package/src/components/GridMethodRef.ts +12 -0
  19. package/src/components/ScrollerGrid.tsx +3 -3
  20. package/src/components/ScrollerList.tsx +5 -3
  21. package/src/index.ts +2 -78
  22. package/src/notifier/Notifier.ts +2 -3
  23. package/src/states/UserState.ts +7 -2
  24. package/src/uses/useWindowScroll.ts +60 -0
  25. package/src/uses/useWindowSize.ts +14 -5
  26. package/__tests__/mu/ComboBox.tsx +0 -30
  27. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  28. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  29. package/__tests__/mu/SelectEx.tsx +0 -26
  30. package/lib/app/CommonApp.d.ts +0 -39
  31. package/lib/app/CommonApp.js +0 -149
  32. package/lib/app/IServiceAppSettings.d.ts +0 -11
  33. package/lib/app/IServiceAppSettings.js +0 -1
  34. package/lib/app/IServicePage.d.ts +0 -6
  35. package/lib/app/IServicePage.js +0 -1
  36. package/lib/app/IServiceUser.d.ts +0 -14
  37. package/lib/app/IServiceUser.js +0 -1
  38. package/lib/app/ISmartERPUser.d.ts +0 -14
  39. package/lib/app/ISmartERPUser.js +0 -1
  40. package/lib/app/Labels.d.ts +0 -65
  41. package/lib/app/Labels.js +0 -62
  42. package/lib/app/ReactApp.d.ts +0 -194
  43. package/lib/app/ReactApp.js +0 -298
  44. package/lib/app/ServiceApp.d.ts +0 -78
  45. package/lib/app/ServiceApp.js +0 -244
  46. package/lib/components/ShowDataComparison.d.ts +0 -20
  47. package/lib/components/ShowDataComparison.js +0 -60
  48. package/lib/mu/AuditDisplay.d.ts +0 -33
  49. package/lib/mu/AuditDisplay.js +0 -52
  50. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
  51. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  52. package/lib/mu/BackButton.d.ts +0 -13
  53. package/lib/mu/BackButton.js +0 -33
  54. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  55. package/lib/mu/BridgeCloseButton.js +0 -32
  56. package/lib/mu/ButtonLink.d.ts +0 -17
  57. package/lib/mu/ButtonLink.js +0 -19
  58. package/lib/mu/ComboBox.d.ts +0 -38
  59. package/lib/mu/ComboBox.js +0 -108
  60. package/lib/mu/CountdownButton.d.ts +0 -23
  61. package/lib/mu/CountdownButton.js +0 -81
  62. package/lib/mu/CustomFabProps.d.ts +0 -27
  63. package/lib/mu/CustomFabProps.js +0 -1
  64. package/lib/mu/DataGridEx.d.ts +0 -96
  65. package/lib/mu/DataGridEx.js +0 -331
  66. package/lib/mu/DataGridRenderers.d.ts +0 -22
  67. package/lib/mu/DataGridRenderers.js +0 -99
  68. package/lib/mu/DialogButton.d.ts +0 -54
  69. package/lib/mu/DialogButton.js +0 -45
  70. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  71. package/lib/mu/DraggablePaperComponent.js +0 -12
  72. package/lib/mu/EmailInput.d.ts +0 -11
  73. package/lib/mu/EmailInput.js +0 -15
  74. package/lib/mu/FabBox.d.ts +0 -21
  75. package/lib/mu/FabBox.js +0 -31
  76. package/lib/mu/FlexBox.d.ts +0 -14
  77. package/lib/mu/FlexBox.js +0 -18
  78. package/lib/mu/GridDataFormat.d.ts +0 -10
  79. package/lib/mu/GridDataFormat.js +0 -43
  80. package/lib/mu/GridMethodRef.d.ts +0 -11
  81. package/lib/mu/IconButtonLink.d.ts +0 -17
  82. package/lib/mu/IconButtonLink.js +0 -16
  83. package/lib/mu/InputField.d.ts +0 -21
  84. package/lib/mu/InputField.js +0 -39
  85. package/lib/mu/ItemList.d.ts +0 -56
  86. package/lib/mu/ItemList.js +0 -69
  87. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  88. package/lib/mu/ListItemRightIcon.js +0 -8
  89. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  90. package/lib/mu/ListMoreDisplay.js +0 -99
  91. package/lib/mu/LoadingButton.d.ts +0 -16
  92. package/lib/mu/LoadingButton.js +0 -41
  93. package/lib/mu/MUGlobal.d.ts +0 -102
  94. package/lib/mu/MUGlobal.js +0 -184
  95. package/lib/mu/MaskInput.d.ts +0 -34
  96. package/lib/mu/MaskInput.js +0 -43
  97. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  98. package/lib/mu/MobileListItemRenderer.js +0 -35
  99. package/lib/mu/MoreFab.d.ts +0 -45
  100. package/lib/mu/MoreFab.js +0 -95
  101. package/lib/mu/NotifierMU.d.ts +0 -47
  102. package/lib/mu/NotifierMU.js +0 -387
  103. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  104. package/lib/mu/NotifierPromptProps.js +0 -1
  105. package/lib/mu/OptionGroup.d.ts +0 -58
  106. package/lib/mu/OptionGroup.js +0 -81
  107. package/lib/mu/PList.d.ts +0 -15
  108. package/lib/mu/PList.js +0 -12
  109. package/lib/mu/ProgressCount.d.ts +0 -44
  110. package/lib/mu/ProgressCount.js +0 -79
  111. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  112. package/lib/mu/PullToRefreshUI.js +0 -18
  113. package/lib/mu/RLink.d.ts +0 -14
  114. package/lib/mu/RLink.js +0 -37
  115. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  116. package/lib/mu/ResponsibleContainer.js +0 -159
  117. package/lib/mu/ScrollTopFab.d.ts +0 -7
  118. package/lib/mu/ScrollTopFab.js +0 -25
  119. package/lib/mu/ScrollerListEx.d.ts +0 -81
  120. package/lib/mu/ScrollerListEx.js +0 -167
  121. package/lib/mu/SearchBar.d.ts +0 -29
  122. package/lib/mu/SearchBar.js +0 -262
  123. package/lib/mu/SearchField.d.ts +0 -21
  124. package/lib/mu/SearchField.js +0 -39
  125. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  126. package/lib/mu/SearchOptionGroup.js +0 -14
  127. package/lib/mu/SelectBool.d.ts +0 -13
  128. package/lib/mu/SelectBool.js +0 -22
  129. package/lib/mu/SelectEx.d.ts +0 -50
  130. package/lib/mu/SelectEx.js +0 -156
  131. package/lib/mu/Switch.d.ts +0 -29
  132. package/lib/mu/Switch.js +0 -34
  133. package/lib/mu/SwitchAnt.d.ts +0 -25
  134. package/lib/mu/SwitchAnt.js +0 -40
  135. package/lib/mu/TabBox.d.ts +0 -54
  136. package/lib/mu/TabBox.js +0 -31
  137. package/lib/mu/TableEx.d.ts +0 -66
  138. package/lib/mu/TableEx.js +0 -271
  139. package/lib/mu/TextFieldEx.d.ts +0 -101
  140. package/lib/mu/TextFieldEx.js +0 -127
  141. package/lib/mu/Tiplist.d.ts +0 -18
  142. package/lib/mu/Tiplist.js +0 -158
  143. package/lib/mu/TooltipClick.d.ts +0 -15
  144. package/lib/mu/TooltipClick.js +0 -40
  145. package/lib/mu/UserAvatar.d.ts +0 -24
  146. package/lib/mu/UserAvatar.js +0 -25
  147. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  148. package/lib/mu/UserAvatarEditor.js +0 -129
  149. package/lib/mu/pages/CommonPage.d.ts +0 -11
  150. package/lib/mu/pages/CommonPage.js +0 -60
  151. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  152. package/lib/mu/pages/CommonPageProps.js +0 -1
  153. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  154. package/lib/mu/pages/DataGridPage.js +0 -81
  155. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  156. package/lib/mu/pages/DataGridPageProps.js +0 -1
  157. package/lib/mu/pages/EditPage.d.ts +0 -33
  158. package/lib/mu/pages/EditPage.js +0 -29
  159. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  160. package/lib/mu/pages/FixedListPage.js +0 -72
  161. package/lib/mu/pages/ListPage.d.ts +0 -9
  162. package/lib/mu/pages/ListPage.js +0 -51
  163. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  164. package/lib/mu/pages/ListPageProps.js +0 -1
  165. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  166. package/lib/mu/pages/ResponsivePage.js +0 -45
  167. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  168. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  169. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  170. package/lib/mu/pages/SearchPageProps.js +0 -1
  171. package/lib/mu/pages/TablePage.d.ts +0 -9
  172. package/lib/mu/pages/TablePage.js +0 -71
  173. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  174. package/lib/mu/pages/TablePageProps.js +0 -1
  175. package/lib/mu/pages/ViewPage.d.ts +0 -66
  176. package/lib/mu/pages/ViewPage.js +0 -105
  177. package/lib/mu/texts/DateText.d.ts +0 -34
  178. package/lib/mu/texts/DateText.js +0 -25
  179. package/lib/mu/texts/MoneyText.d.ts +0 -21
  180. package/lib/mu/texts/MoneyText.js +0 -14
  181. package/lib/mu/texts/NumberText.d.ts +0 -25
  182. package/lib/mu/texts/NumberText.js +0 -14
  183. package/src/app/CommonApp.ts +0 -225
  184. package/src/app/IServiceAppSettings.ts +0 -13
  185. package/src/app/IServicePage.ts +0 -6
  186. package/src/app/IServiceUser.ts +0 -17
  187. package/src/app/ISmartERPUser.ts +0 -16
  188. package/src/app/Labels.ts +0 -77
  189. package/src/app/ReactApp.ts +0 -500
  190. package/src/app/ServiceApp.ts +0 -353
  191. package/src/components/ShowDataComparison.tsx +0 -108
  192. package/src/mu/AuditDisplay.tsx +0 -117
  193. package/src/mu/AutocompleteExtendedProps.ts +0 -83
  194. package/src/mu/BackButton.tsx +0 -55
  195. package/src/mu/BridgeCloseButton.tsx +0 -69
  196. package/src/mu/ButtonLink.tsx +0 -32
  197. package/src/mu/ComboBox.tsx +0 -251
  198. package/src/mu/CountdownButton.tsx +0 -119
  199. package/src/mu/CustomFabProps.ts +0 -32
  200. package/src/mu/DataGridEx.tsx +0 -712
  201. package/src/mu/DataGridRenderers.tsx +0 -140
  202. package/src/mu/DialogButton.tsx +0 -163
  203. package/src/mu/DraggablePaperComponent.tsx +0 -19
  204. package/src/mu/EmailInput.tsx +0 -24
  205. package/src/mu/FabBox.tsx +0 -51
  206. package/src/mu/FlexBox.tsx +0 -20
  207. package/src/mu/GridDataFormat.tsx +0 -77
  208. package/src/mu/GridMethodRef.ts +0 -12
  209. package/src/mu/IconButtonLink.tsx +0 -29
  210. package/src/mu/InputField.tsx +0 -82
  211. package/src/mu/ItemList.tsx +0 -204
  212. package/src/mu/ListItemRightIcon.tsx +0 -9
  213. package/src/mu/ListMoreDisplay.tsx +0 -205
  214. package/src/mu/LoadingButton.tsx +0 -75
  215. package/src/mu/MUGlobal.ts +0 -220
  216. package/src/mu/MaskInput.tsx +0 -107
  217. package/src/mu/MobileListItemRenderer.tsx +0 -79
  218. package/src/mu/MoreFab.tsx +0 -211
  219. package/src/mu/NotifierMU.tsx +0 -654
  220. package/src/mu/NotifierPromptProps.ts +0 -26
  221. package/src/mu/OptionGroup.tsx +0 -223
  222. package/src/mu/PList.tsx +0 -27
  223. package/src/mu/ProgressCount.tsx +0 -166
  224. package/src/mu/PullToRefreshUI.tsx +0 -21
  225. package/src/mu/RLink.tsx +0 -64
  226. package/src/mu/ResponsibleContainer.tsx +0 -394
  227. package/src/mu/ScrollTopFab.tsx +0 -34
  228. package/src/mu/ScrollerListEx.tsx +0 -387
  229. package/src/mu/SearchBar.tsx +0 -398
  230. package/src/mu/SearchField.tsx +0 -82
  231. package/src/mu/SearchOptionGroup.tsx +0 -31
  232. package/src/mu/SelectBool.tsx +0 -33
  233. package/src/mu/SelectEx.tsx +0 -290
  234. package/src/mu/Switch.tsx +0 -94
  235. package/src/mu/SwitchAnt.tsx +0 -95
  236. package/src/mu/TabBox.tsx +0 -118
  237. package/src/mu/TableEx.tsx +0 -560
  238. package/src/mu/TextFieldEx.tsx +0 -250
  239. package/src/mu/Tiplist.tsx +0 -304
  240. package/src/mu/TooltipClick.tsx +0 -84
  241. package/src/mu/UserAvatar.tsx +0 -64
  242. package/src/mu/UserAvatarEditor.tsx +0 -287
  243. package/src/mu/pages/CommonPage.tsx +0 -128
  244. package/src/mu/pages/CommonPageProps.ts +0 -71
  245. package/src/mu/pages/DataGridPage.tsx +0 -137
  246. package/src/mu/pages/DataGridPageProps.ts +0 -24
  247. package/src/mu/pages/EditPage.tsx +0 -114
  248. package/src/mu/pages/FixedListPage.tsx +0 -135
  249. package/src/mu/pages/ListPage.tsx +0 -87
  250. package/src/mu/pages/ListPageProps.ts +0 -12
  251. package/src/mu/pages/ResponsivePage.tsx +0 -68
  252. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  253. package/src/mu/pages/SearchPageProps.ts +0 -39
  254. package/src/mu/pages/TablePage.tsx +0 -120
  255. package/src/mu/pages/TablePageProps.ts +0 -12
  256. package/src/mu/pages/ViewPage.tsx +0 -285
  257. package/src/mu/texts/DateText.tsx +0 -74
  258. package/src/mu/texts/MoneyText.tsx +0 -49
  259. package/src/mu/texts/NumberText.tsx +0 -40
@@ -1,387 +0,0 @@
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 { Labels } from '../app/Labels';
6
- import { NotificationReact, NotifierReact } from '../notifier/Notifier';
7
- import { DraggablePaperComponent } from './DraggablePaperComponent';
8
- import { LoadingButton } from './LoadingButton';
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
- }
@@ -1,22 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,58 +0,0 @@
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;
@@ -1,81 +0,0 @@
1
- import { DataTypes, Utils } from '@etsoo/shared';
2
- import { Checkbox, FormControl, FormControlLabel, FormGroup, FormLabel, Radio, RadioGroup } from '@mui/material';
3
- import React from 'react';
4
- /**
5
- * OptionGroup
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export function OptionGroup(props) {
10
- // Destruct
11
- const { getOptionLabel, defaultValue, idField = 'id', label, labelField = 'label', multiple = false, name, onValueChange, options, readOnly, row, size, ...rest } = props;
12
- // Get option value
13
- // D type should be the source id type
14
- const getOptionValue = (option) => {
15
- const value = DataTypes.getValue(option, idField);
16
- if (value == null)
17
- return null;
18
- return value;
19
- };
20
- // Checkbox values
21
- const [values, setValues] = React.useState(defaultValue == null
22
- ? []
23
- : Array.isArray(defaultValue)
24
- ? defaultValue
25
- : [defaultValue]);
26
- // Item checked
27
- const itemChecked = (option) => {
28
- // Value
29
- const value = getOptionValue(option);
30
- if (value == null)
31
- return false;
32
- return values.includes(value);
33
- };
34
- // First item value
35
- const firstOptionValue = getOptionValue(options[0]);
36
- // Items
37
- const list = options.map((option) => {
38
- // Control
39
- const control = multiple ? (React.createElement(Checkbox, { name: name, readOnly: readOnly, size: size, checked: itemChecked(option), onChange: (event) => {
40
- if (firstOptionValue == null)
41
- return;
42
- const typeValue = Utils.parseString(event.target.value, firstOptionValue);
43
- const changedValues = [...values];
44
- if (event.target.checked) {
45
- if (changedValues.includes(typeValue))
46
- return;
47
- changedValues.push(typeValue);
48
- }
49
- else {
50
- const index = changedValues.findIndex((v) => v === typeValue);
51
- if (index === -1)
52
- return;
53
- changedValues.splice(index, 1);
54
- }
55
- if (onValueChange)
56
- onValueChange(changedValues);
57
- setValues(changedValues);
58
- } })) : (React.createElement(Radio, { size: size, readOnly: readOnly }));
59
- // Label
60
- const label = getOptionLabel == null
61
- ? `${option[labelField]}`
62
- : getOptionLabel(option);
63
- // Value, convert to string
64
- // Will fail when type is number
65
- const value = getOptionValue(option);
66
- return (React.createElement(FormControlLabel, { key: value, control: control, value: value, label: label }));
67
- });
68
- // Group
69
- const group = multiple ? (React.createElement(FormGroup, { row: row }, list)) : (React.createElement(RadioGroup, { row: row, name: name, value: values[0], onChange: (_event, value) => {
70
- if (firstOptionValue == null)
71
- return;
72
- const typeValue = Utils.parseString(value, firstOptionValue);
73
- if (onValueChange)
74
- onValueChange(typeValue);
75
- setValues([typeValue]);
76
- } }, list));
77
- // Layout
78
- return (React.createElement(FormControl, { component: "fieldset", ...rest },
79
- label && React.createElement(FormLabel, { component: "legend" }, label),
80
- group));
81
- }
package/lib/mu/PList.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Paragraph items list props
4
- */
5
- export interface PListProps {
6
- /**
7
- * List items
8
- */
9
- items?: string[];
10
- }
11
- /**
12
- * Paragraph items list
13
- * @param items Items
14
- */
15
- export declare function PList(props: PListProps): JSX.Element;
package/lib/mu/PList.js DELETED
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Paragraph items list
4
- * @param items Items
5
- */
6
- export function PList(props) {
7
- const { items } = props;
8
- return (React.createElement(React.Fragment, null, items != null &&
9
- items.map((item, index) => {
10
- return React.createElement("p", { key: index }, item);
11
- })));
12
- }
@@ -1,44 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Process count props
4
- */
5
- export interface ProgressCountProps {
6
- /**
7
- * Is countdown or opposite
8
- * @default 'true'
9
- */
10
- countdown?: boolean;
11
- /**
12
- * Is linear or circular
13
- * @default 'true'
14
- */
15
- linear?: boolean;
16
- /**
17
- * Min width
18
- * @default 36
19
- */
20
- minWidth?: number;
21
- /**
22
- * On complete callback, return false will stop it
23
- */
24
- onComplete?: () => boolean;
25
- /**
26
- * On progress callback
27
- */
28
- onProgress?: (value: number) => void;
29
- /**
30
- * Seconds for count
31
- */
32
- seconds: number;
33
- /**
34
- * Value unit, like 's' or '%'
35
- * @default ''
36
- */
37
- valueUnit?: string;
38
- }
39
- /**
40
- * Progress count
41
- * @param props Props
42
- * @returns Component
43
- */
44
- export declare function ProgressCount(props: ProgressCountProps): JSX.Element;