@etsoo/react 1.5.78 → 1.5.81

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 (255) 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 +6 -6
  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/uses/useWindowScroll.d.ts +10 -0
  13. package/lib/uses/useWindowScroll.js +46 -0
  14. package/lib/uses/useWindowSize.js +11 -5
  15. package/package.json +9 -21
  16. package/src/{mu → components}/DnDList.tsx +11 -34
  17. package/src/components/GridMethodRef.ts +12 -0
  18. package/src/components/ScrollerGrid.tsx +6 -6
  19. package/src/components/ScrollerList.tsx +5 -3
  20. package/src/index.ts +2 -78
  21. package/src/notifier/Notifier.ts +2 -3
  22. package/src/uses/useWindowScroll.ts +60 -0
  23. package/src/uses/useWindowSize.ts +14 -5
  24. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  25. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  26. package/lib/app/CommonApp.d.ts +0 -39
  27. package/lib/app/CommonApp.js +0 -149
  28. package/lib/app/IServiceAppSettings.d.ts +0 -11
  29. package/lib/app/IServiceAppSettings.js +0 -1
  30. package/lib/app/IServicePage.d.ts +0 -6
  31. package/lib/app/IServicePage.js +0 -1
  32. package/lib/app/IServiceUser.d.ts +0 -14
  33. package/lib/app/IServiceUser.js +0 -1
  34. package/lib/app/ISmartERPUser.d.ts +0 -14
  35. package/lib/app/ISmartERPUser.js +0 -1
  36. package/lib/app/Labels.d.ts +0 -65
  37. package/lib/app/Labels.js +0 -62
  38. package/lib/app/ReactApp.d.ts +0 -194
  39. package/lib/app/ReactApp.js +0 -298
  40. package/lib/app/ServiceApp.d.ts +0 -78
  41. package/lib/app/ServiceApp.js +0 -244
  42. package/lib/components/ShowDataComparison.d.ts +0 -20
  43. package/lib/components/ShowDataComparison.js +0 -60
  44. package/lib/mu/AuditDisplay.d.ts +0 -33
  45. package/lib/mu/AuditDisplay.js +0 -52
  46. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -66
  47. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  48. package/lib/mu/BackButton.d.ts +0 -13
  49. package/lib/mu/BackButton.js +0 -33
  50. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  51. package/lib/mu/BridgeCloseButton.js +0 -32
  52. package/lib/mu/ButtonLink.d.ts +0 -17
  53. package/lib/mu/ButtonLink.js +0 -19
  54. package/lib/mu/ComboBox.d.ts +0 -40
  55. package/lib/mu/ComboBox.js +0 -108
  56. package/lib/mu/CountdownButton.d.ts +0 -23
  57. package/lib/mu/CountdownButton.js +0 -81
  58. package/lib/mu/CustomFabProps.d.ts +0 -27
  59. package/lib/mu/CustomFabProps.js +0 -1
  60. package/lib/mu/DataGridEx.d.ts +0 -96
  61. package/lib/mu/DataGridEx.js +0 -331
  62. package/lib/mu/DataGridRenderers.d.ts +0 -22
  63. package/lib/mu/DataGridRenderers.js +0 -99
  64. package/lib/mu/DialogButton.d.ts +0 -54
  65. package/lib/mu/DialogButton.js +0 -45
  66. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  67. package/lib/mu/DraggablePaperComponent.js +0 -12
  68. package/lib/mu/EmailInput.d.ts +0 -11
  69. package/lib/mu/EmailInput.js +0 -15
  70. package/lib/mu/FabBox.d.ts +0 -21
  71. package/lib/mu/FabBox.js +0 -31
  72. package/lib/mu/FlexBox.d.ts +0 -14
  73. package/lib/mu/FlexBox.js +0 -18
  74. package/lib/mu/GridDataFormat.d.ts +0 -10
  75. package/lib/mu/GridDataFormat.js +0 -43
  76. package/lib/mu/GridMethodRef.d.ts +0 -11
  77. package/lib/mu/IconButtonLink.d.ts +0 -17
  78. package/lib/mu/IconButtonLink.js +0 -16
  79. package/lib/mu/InputField.d.ts +0 -21
  80. package/lib/mu/InputField.js +0 -39
  81. package/lib/mu/ItemList.d.ts +0 -55
  82. package/lib/mu/ItemList.js +0 -77
  83. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  84. package/lib/mu/ListItemRightIcon.js +0 -8
  85. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  86. package/lib/mu/ListMoreDisplay.js +0 -99
  87. package/lib/mu/LoadingButton.d.ts +0 -16
  88. package/lib/mu/LoadingButton.js +0 -41
  89. package/lib/mu/MUGlobal.d.ts +0 -102
  90. package/lib/mu/MUGlobal.js +0 -184
  91. package/lib/mu/MaskInput.d.ts +0 -34
  92. package/lib/mu/MaskInput.js +0 -43
  93. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  94. package/lib/mu/MobileListItemRenderer.js +0 -35
  95. package/lib/mu/MoreFab.d.ts +0 -45
  96. package/lib/mu/MoreFab.js +0 -95
  97. package/lib/mu/NotifierMU.d.ts +0 -47
  98. package/lib/mu/NotifierMU.js +0 -387
  99. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  100. package/lib/mu/NotifierPromptProps.js +0 -1
  101. package/lib/mu/OptionGroup.d.ts +0 -62
  102. package/lib/mu/OptionGroup.js +0 -81
  103. package/lib/mu/PList.d.ts +0 -15
  104. package/lib/mu/PList.js +0 -12
  105. package/lib/mu/ProgressCount.d.ts +0 -44
  106. package/lib/mu/ProgressCount.js +0 -79
  107. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  108. package/lib/mu/PullToRefreshUI.js +0 -18
  109. package/lib/mu/RLink.d.ts +0 -14
  110. package/lib/mu/RLink.js +0 -37
  111. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  112. package/lib/mu/ResponsibleContainer.js +0 -159
  113. package/lib/mu/ScrollTopFab.d.ts +0 -7
  114. package/lib/mu/ScrollTopFab.js +0 -25
  115. package/lib/mu/ScrollerListEx.d.ts +0 -81
  116. package/lib/mu/ScrollerListEx.js +0 -167
  117. package/lib/mu/SearchBar.d.ts +0 -29
  118. package/lib/mu/SearchBar.js +0 -262
  119. package/lib/mu/SearchField.d.ts +0 -21
  120. package/lib/mu/SearchField.js +0 -39
  121. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  122. package/lib/mu/SearchOptionGroup.js +0 -14
  123. package/lib/mu/SelectBool.d.ts +0 -14
  124. package/lib/mu/SelectBool.js +0 -22
  125. package/lib/mu/SelectEx.d.ts +0 -54
  126. package/lib/mu/SelectEx.js +0 -156
  127. package/lib/mu/Switch.d.ts +0 -29
  128. package/lib/mu/Switch.js +0 -34
  129. package/lib/mu/SwitchAnt.d.ts +0 -25
  130. package/lib/mu/SwitchAnt.js +0 -40
  131. package/lib/mu/TabBox.d.ts +0 -54
  132. package/lib/mu/TabBox.js +0 -31
  133. package/lib/mu/TableEx.d.ts +0 -68
  134. package/lib/mu/TableEx.js +0 -271
  135. package/lib/mu/TextFieldEx.d.ts +0 -101
  136. package/lib/mu/TextFieldEx.js +0 -127
  137. package/lib/mu/Tiplist.d.ts +0 -18
  138. package/lib/mu/Tiplist.js +0 -158
  139. package/lib/mu/TooltipClick.d.ts +0 -15
  140. package/lib/mu/TooltipClick.js +0 -40
  141. package/lib/mu/UserAvatar.d.ts +0 -24
  142. package/lib/mu/UserAvatar.js +0 -25
  143. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  144. package/lib/mu/UserAvatarEditor.js +0 -129
  145. package/lib/mu/pages/CommonPage.d.ts +0 -11
  146. package/lib/mu/pages/CommonPage.js +0 -60
  147. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  148. package/lib/mu/pages/CommonPageProps.js +0 -1
  149. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  150. package/lib/mu/pages/DataGridPage.js +0 -81
  151. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  152. package/lib/mu/pages/DataGridPageProps.js +0 -1
  153. package/lib/mu/pages/EditPage.d.ts +0 -33
  154. package/lib/mu/pages/EditPage.js +0 -29
  155. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  156. package/lib/mu/pages/FixedListPage.js +0 -72
  157. package/lib/mu/pages/ListPage.d.ts +0 -9
  158. package/lib/mu/pages/ListPage.js +0 -51
  159. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  160. package/lib/mu/pages/ListPageProps.js +0 -1
  161. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  162. package/lib/mu/pages/ResponsivePage.js +0 -45
  163. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  164. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  165. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  166. package/lib/mu/pages/SearchPageProps.js +0 -1
  167. package/lib/mu/pages/TablePage.d.ts +0 -9
  168. package/lib/mu/pages/TablePage.js +0 -71
  169. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  170. package/lib/mu/pages/TablePageProps.js +0 -1
  171. package/lib/mu/pages/ViewPage.d.ts +0 -66
  172. package/lib/mu/pages/ViewPage.js +0 -105
  173. package/lib/mu/texts/DateText.d.ts +0 -34
  174. package/lib/mu/texts/DateText.js +0 -25
  175. package/lib/mu/texts/MoneyText.d.ts +0 -21
  176. package/lib/mu/texts/MoneyText.js +0 -14
  177. package/lib/mu/texts/NumberText.d.ts +0 -25
  178. package/lib/mu/texts/NumberText.js +0 -14
  179. package/src/app/CommonApp.ts +0 -225
  180. package/src/app/IServiceAppSettings.ts +0 -13
  181. package/src/app/IServicePage.ts +0 -6
  182. package/src/app/IServiceUser.ts +0 -17
  183. package/src/app/ISmartERPUser.ts +0 -16
  184. package/src/app/Labels.ts +0 -77
  185. package/src/app/ReactApp.ts +0 -500
  186. package/src/app/ServiceApp.ts +0 -353
  187. package/src/components/ShowDataComparison.tsx +0 -108
  188. package/src/mu/AuditDisplay.tsx +0 -117
  189. package/src/mu/AutocompleteExtendedProps.ts +0 -84
  190. package/src/mu/BackButton.tsx +0 -55
  191. package/src/mu/BridgeCloseButton.tsx +0 -69
  192. package/src/mu/ButtonLink.tsx +0 -32
  193. package/src/mu/ComboBox.tsx +0 -244
  194. package/src/mu/CountdownButton.tsx +0 -119
  195. package/src/mu/CustomFabProps.ts +0 -32
  196. package/src/mu/DataGridEx.tsx +0 -712
  197. package/src/mu/DataGridRenderers.tsx +0 -140
  198. package/src/mu/DialogButton.tsx +0 -163
  199. package/src/mu/DraggablePaperComponent.tsx +0 -19
  200. package/src/mu/EmailInput.tsx +0 -24
  201. package/src/mu/FabBox.tsx +0 -51
  202. package/src/mu/FlexBox.tsx +0 -20
  203. package/src/mu/GridDataFormat.tsx +0 -77
  204. package/src/mu/GridMethodRef.ts +0 -12
  205. package/src/mu/IconButtonLink.tsx +0 -29
  206. package/src/mu/InputField.tsx +0 -82
  207. package/src/mu/ItemList.tsx +0 -201
  208. package/src/mu/ListItemRightIcon.tsx +0 -9
  209. package/src/mu/ListMoreDisplay.tsx +0 -205
  210. package/src/mu/LoadingButton.tsx +0 -75
  211. package/src/mu/MUGlobal.ts +0 -220
  212. package/src/mu/MaskInput.tsx +0 -107
  213. package/src/mu/MobileListItemRenderer.tsx +0 -79
  214. package/src/mu/MoreFab.tsx +0 -211
  215. package/src/mu/NotifierMU.tsx +0 -654
  216. package/src/mu/NotifierPromptProps.ts +0 -26
  217. package/src/mu/OptionGroup.tsx +0 -218
  218. package/src/mu/PList.tsx +0 -27
  219. package/src/mu/ProgressCount.tsx +0 -166
  220. package/src/mu/PullToRefreshUI.tsx +0 -21
  221. package/src/mu/RLink.tsx +0 -64
  222. package/src/mu/ResponsibleContainer.tsx +0 -394
  223. package/src/mu/ScrollTopFab.tsx +0 -34
  224. package/src/mu/ScrollerListEx.tsx +0 -387
  225. package/src/mu/SearchBar.tsx +0 -398
  226. package/src/mu/SearchField.tsx +0 -82
  227. package/src/mu/SearchOptionGroup.tsx +0 -25
  228. package/src/mu/SelectBool.tsx +0 -40
  229. package/src/mu/SelectEx.tsx +0 -285
  230. package/src/mu/Switch.tsx +0 -94
  231. package/src/mu/SwitchAnt.tsx +0 -95
  232. package/src/mu/TabBox.tsx +0 -118
  233. package/src/mu/TableEx.tsx +0 -561
  234. package/src/mu/TextFieldEx.tsx +0 -250
  235. package/src/mu/Tiplist.tsx +0 -304
  236. package/src/mu/TooltipClick.tsx +0 -84
  237. package/src/mu/UserAvatar.tsx +0 -64
  238. package/src/mu/UserAvatarEditor.tsx +0 -287
  239. package/src/mu/pages/CommonPage.tsx +0 -128
  240. package/src/mu/pages/CommonPageProps.ts +0 -71
  241. package/src/mu/pages/DataGridPage.tsx +0 -137
  242. package/src/mu/pages/DataGridPageProps.ts +0 -24
  243. package/src/mu/pages/EditPage.tsx +0 -114
  244. package/src/mu/pages/FixedListPage.tsx +0 -134
  245. package/src/mu/pages/ListPage.tsx +0 -86
  246. package/src/mu/pages/ListPageProps.ts +0 -11
  247. package/src/mu/pages/ResponsivePage.tsx +0 -68
  248. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  249. package/src/mu/pages/SearchPageProps.ts +0 -39
  250. package/src/mu/pages/TablePage.tsx +0 -119
  251. package/src/mu/pages/TablePageProps.ts +0 -11
  252. package/src/mu/pages/ViewPage.tsx +0 -285
  253. package/src/mu/texts/DateText.tsx +0 -74
  254. package/src/mu/texts/MoneyText.tsx +0 -49
  255. package/src/mu/texts/NumberText.tsx +0 -40
package/lib/mu/Tiplist.js DELETED
@@ -1,158 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { Autocomplete } from '@mui/material';
3
- import React from 'react';
4
- import { ReactUtils } from '../app/ReactUtils';
5
- import { useDelayedExecutor } from '../uses/useDelayedExecutor';
6
- import { InputField } from './InputField';
7
- import { SearchField } from './SearchField';
8
- /**
9
- * Tiplist
10
- * @param props Props
11
- * @returns Component
12
- */
13
- export function Tiplist(props) {
14
- // Destruct
15
- const { search = false, idField = 'id', idValue, inputAutoComplete = 'off', inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: '180px' }, ...rest } = props;
16
- // Value input ref
17
- const inputRef = React.createRef();
18
- // Local value
19
- let localValue = value !== null && value !== void 0 ? value : defaultValue;
20
- // One time calculation for input's default value (uncontrolled)
21
- const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField);
22
- // Changable states
23
- const [states, stateUpdate] = React.useReducer((currentState, newState) => {
24
- return { ...currentState, ...newState };
25
- }, {
26
- // Loading unknown
27
- open: false,
28
- options: [],
29
- value: null
30
- });
31
- // Input value
32
- const inputValue = React.useMemo(() => states.value && states.value[idField], [states.value]);
33
- React.useEffect(() => {
34
- if (localValue != null)
35
- stateUpdate({ value: localValue });
36
- }, [localValue]);
37
- // State
38
- const [state] = React.useState({});
39
- const isMounted = React.useRef(true);
40
- // Add readOnly
41
- const addReadOnly = (params) => {
42
- if (readOnly != null) {
43
- Object.assign(params, { readOnly });
44
- }
45
- // https://stackoverflow.com/questions/15738259/disabling-chrome-autofill
46
- // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html
47
- Object.assign(params.inputProps, { autoComplete: inputAutoComplete });
48
- return params;
49
- };
50
- // Change handler
51
- const changeHandle = (event) => {
52
- // Stop processing with auto trigger event
53
- if (event.nativeEvent.cancelable && !event.nativeEvent.composed) {
54
- stateUpdate({ options: [] });
55
- return;
56
- }
57
- // Stop bubble
58
- event.stopPropagation();
59
- // Call with delay
60
- delayed.call(undefined, event.currentTarget.value);
61
- };
62
- // Directly load data
63
- const loadDataDirect = (keyword, id) => {
64
- // Reset options
65
- // setOptions([]);
66
- if (id == null) {
67
- // Reset real value
68
- const input = inputRef.current;
69
- if (input && input.value !== '') {
70
- // Different value, trigger change event
71
- ReactUtils.triggerChange(input, '', false);
72
- }
73
- if (states.options.length > 0) {
74
- // Reset options
75
- stateUpdate({ options: [] });
76
- }
77
- }
78
- // Loading indicator
79
- if (!states.loading)
80
- stateUpdate({ loading: true });
81
- // Load list
82
- loadData(keyword, id).then((options) => {
83
- if (!isMounted.current)
84
- return;
85
- // Indicates loading completed
86
- stateUpdate({
87
- loading: false,
88
- ...(options != null && { options })
89
- });
90
- });
91
- };
92
- const delayed = useDelayedExecutor(loadDataDirect, 480);
93
- const setInputValue = (value) => {
94
- var _a;
95
- stateUpdate({ value });
96
- // Input value
97
- const input = inputRef.current;
98
- if (input) {
99
- // Update value
100
- const newValue = (_a = DataTypes.getStringValue(value, idField)) !== null && _a !== void 0 ? _a : '';
101
- if (newValue !== input.value) {
102
- // Different value, trigger change event
103
- ReactUtils.triggerChange(input, newValue, false);
104
- }
105
- }
106
- };
107
- if (localIdValue != null && localIdValue !== '') {
108
- if (state.idLoaded) {
109
- // Set default
110
- if (!state.idSet && states.options.length == 1) {
111
- stateUpdate({ value: states.options[0] });
112
- state.idSet = true;
113
- }
114
- }
115
- else {
116
- // Load id data
117
- loadDataDirect(undefined, localIdValue);
118
- state.idLoaded = true;
119
- }
120
- }
121
- React.useEffect(() => {
122
- return () => {
123
- isMounted.current = false;
124
- delayed.clear();
125
- };
126
- }, []);
127
- // Layout
128
- return (React.createElement("div", null,
129
- React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${inputValue !== null && inputValue !== void 0 ? inputValue : ''}`, readOnly: true, onChange: inputOnChange }),
130
- React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
131
- // Set value
132
- setInputValue(value);
133
- // Custom
134
- if (onChange != null)
135
- onChange(event, value, reason, details);
136
- // For clear case
137
- if (reason === 'clear') {
138
- stateUpdate({ options: [] });
139
- loadDataDirect();
140
- }
141
- }, open: states.open, openOnFocus: openOnFocus, onOpen: () => {
142
- // Should load
143
- const loading = states.loading
144
- ? true
145
- : states.options.length === 0;
146
- stateUpdate({ open: true, loading });
147
- // If not loading
148
- if (loading)
149
- loadDataDirect(undefined, states.value == null
150
- ? undefined
151
- : states.value[idField]);
152
- }, onClose: () => {
153
- stateUpdate({
154
- open: false,
155
- ...(!states.value && { options: [] })
156
- });
157
- }, loading: states.loading, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { onChange: changeHandle, ...params, readOnly: readOnly, label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { onChange: changeHandle, ...addReadOnly(params), label: label, name: name + 'Input', margin: inputMargin, variant: inputVariant, required: inputRequired, autoComplete: inputAutoComplete, error: inputError, helperText: inputHelperText })), isOptionEqualToValue: (option, value) => option[idField] === value[idField], ...rest })));
158
- }
@@ -1,15 +0,0 @@
1
- import { TooltipProps } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Tooltip with click visibility props
5
- */
6
- export interface TooltipClickProps extends Omit<TooltipProps, 'children' | 'open' | 'disableFocusListener' | 'disableTouchListener'> {
7
- children: (openTooltip: (newTitle?: string) => void) => React.ReactElement<any, any>;
8
- disableHoverListener?: boolean;
9
- }
10
- /**
11
- * Tooltip with click visibility
12
- * @param props Props
13
- * @returns Component
14
- */
15
- export declare function TooltipClick(props: TooltipClickProps): JSX.Element;
@@ -1,40 +0,0 @@
1
- import { ClickAwayListener, Tooltip } from '@mui/material';
2
- import React from 'react';
3
- import { useDelayedExecutor } from '../uses/useDelayedExecutor';
4
- /**
5
- * Tooltip with click visibility
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export function TooltipClick(props) {
10
- // Destruct
11
- // leaveDelay set to 5 seconds to hide the tooltip automatically
12
- const { children, disableHoverListener = true, leaveDelay = 5000, onClose, title, ...rest } = props;
13
- // State
14
- const [localTitle, setTitle] = React.useState(title);
15
- const [open, setOpen] = React.useState(false);
16
- const delayed = leaveDelay > 0
17
- ? useDelayedExecutor(() => setOpen(false), leaveDelay)
18
- : undefined;
19
- // Callback for open the tooltip
20
- const openTooltip = (newTitle) => {
21
- setOpen(true);
22
- if (newTitle)
23
- setTitle(newTitle);
24
- delayed === null || delayed === void 0 ? void 0 : delayed.call();
25
- };
26
- React.useEffect(() => {
27
- return () => {
28
- delayed === null || delayed === void 0 ? void 0 : delayed.clear();
29
- };
30
- }, []);
31
- // Layout
32
- return (React.createElement(ClickAwayListener, { onClickAway: () => setOpen(false) },
33
- React.createElement(Tooltip, { PopperProps: {
34
- disablePortal: true
35
- }, onClose: (event) => {
36
- setOpen(false);
37
- if (onClose)
38
- onClose(event);
39
- }, title: localTitle, open: open, disableFocusListener: true, disableTouchListener: true, disableHoverListener: disableHoverListener, onMouseOver: disableHoverListener ? undefined : () => setOpen(true), ...rest }, children(openTooltip))));
40
- }
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * User avatar props
4
- */
5
- export interface UserAvatarProps {
6
- /**
7
- * Photo src
8
- */
9
- src?: string;
10
- /**
11
- * Format title
12
- */
13
- formatTitle?: (title?: string) => string;
14
- /**
15
- * Title of the user
16
- */
17
- title?: string;
18
- }
19
- /**
20
- * User avatar
21
- * @param props Props
22
- * @returns Component
23
- */
24
- export declare function UserAvatar(props: UserAvatarProps): JSX.Element;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { Avatar } from '@mui/material';
3
- import { BusinessUtils } from '@etsoo/appscript';
4
- import { globalApp } from '../app/ReactApp';
5
- /**
6
- * User avatar
7
- * @param props Props
8
- * @returns Component
9
- */
10
- export function UserAvatar(props) {
11
- // Destruct
12
- const { src, title, formatTitle = (title) => {
13
- return BusinessUtils.formatAvatarTitle(title, 3, typeof globalApp === 'undefined'
14
- ? 'ME'
15
- : globalApp.get('me'));
16
- } } = props;
17
- // Format
18
- const fTitle = formatTitle(title);
19
- const count = fTitle.length;
20
- return (React.createElement(Avatar, { title: title, src: src, sx: {
21
- width: 48,
22
- height: 32,
23
- fontSize: count <= 2 ? '15px' : '12px'
24
- } }, fTitle));
25
- }
@@ -1,53 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * User avatar editor to Blob helper
4
- */
5
- export interface UserAvatarEditorToBlob {
6
- (canvas: HTMLCanvasElement, mimeType?: string, quality?: number): Promise<Blob>;
7
- }
8
- /**
9
- * User avatar editor on done handler
10
- */
11
- export interface UserAvatarEditorOnDoneHandler {
12
- (canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob): void;
13
- }
14
- /**
15
- * User avatar editor props
16
- */
17
- export interface UserAvatarEditorProps {
18
- /**
19
- * Cropping border size
20
- */
21
- border?: number;
22
- /**
23
- * Image source
24
- */
25
- image?: string | File;
26
- /**
27
- * Max width to save
28
- */
29
- maxWidth?: number;
30
- /**
31
- * On done handler
32
- */
33
- onDone: UserAvatarEditorOnDoneHandler;
34
- /**
35
- * Return scaled result?
36
- */
37
- scaledResult?: boolean;
38
- /**
39
- * Width of the editor
40
- */
41
- width?: number;
42
- /**
43
- * Height of the editor
44
- */
45
- height?: number;
46
- }
47
- /**
48
- * User avatar editor
49
- * https://github.com/mosch/react-avatar-editor
50
- * @param props Props
51
- * @returns Component
52
- */
53
- export declare function UserAvatarEditor(props: UserAvatarEditorProps): JSX.Element;
@@ -1,129 +0,0 @@
1
- import { Button, ButtonGroup, Slider, Stack } from '@mui/material';
2
- import React from 'react';
3
- import AvatarEditor from 'react-avatar-editor';
4
- import RotateLeftIcon from '@mui/icons-material/RotateLeft';
5
- import RotateRightIcon from '@mui/icons-material/RotateRight';
6
- import ClearAllIcon from '@mui/icons-material/ClearAll';
7
- import ComputerIcon from '@mui/icons-material/Computer';
8
- import DoneIcon from '@mui/icons-material/Done';
9
- import pica from 'pica';
10
- import { Labels } from '../app/Labels';
11
- const defaultState = {
12
- scale: 1,
13
- rotate: 0
14
- };
15
- /**
16
- * User avatar editor
17
- * https://github.com/mosch/react-avatar-editor
18
- * @param props Props
19
- * @returns Component
20
- */
21
- export function UserAvatarEditor(props) {
22
- // Destruct
23
- const { border = 30, image, maxWidth, onDone, scaledResult = false, width = 200, height = 200 } = props;
24
- // Container width
25
- const containerWidth = width + 2 * border + 44 + 4;
26
- // Calculated max width
27
- const maxWidthCalculated = maxWidth == null || maxWidth < 200 ? 3 * width : maxWidth;
28
- // Labels
29
- const labels = Labels.UserAvatarEditor;
30
- // Ref
31
- const ref = React.createRef();
32
- // Button ref
33
- const buttonRef = React.createRef();
34
- // Preview image state
35
- const [previewImage, setPreviewImage] = React.useState(image);
36
- // Is ready state
37
- const [ready, setReady] = React.useState(false);
38
- // Editor states
39
- const [editorState, setEditorState] = React.useState(defaultState);
40
- // Handle zoom
41
- const handleZoom = (_event, value, _activeThumb) => {
42
- const scale = typeof value === 'number' ? value : value[0];
43
- const newState = { ...editorState, scale };
44
- setEditorState(newState);
45
- };
46
- // Handle image load
47
- const handleLoad = () => {
48
- setReady(true);
49
- };
50
- // Handle file change
51
- const handleFileChange = (event) => {
52
- var _a;
53
- const files = event.target.files;
54
- if (files == null || files.length == 0)
55
- return;
56
- // Reset all settings
57
- handleReset();
58
- // Set new preview image
59
- setPreviewImage(files[0]);
60
- // Set ready state
61
- setReady(false);
62
- // Make the submit button visible
63
- (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView(false);
64
- };
65
- // Handle reset
66
- const handleReset = () => {
67
- setEditorState({ ...defaultState });
68
- };
69
- // Handle rotate
70
- const handleRotate = (r) => {
71
- let rotate = editorState.rotate + r;
72
- if (rotate >= 360 || rotate <= -360)
73
- rotate = 0;
74
- const newState = { ...editorState, rotate };
75
- setEditorState(newState);
76
- };
77
- // Handle done
78
- const handleDone = () => {
79
- var _a, _b;
80
- // Data
81
- var data = scaledResult
82
- ? (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getImageScaledToCanvas()
83
- : (_b = ref.current) === null || _b === void 0 ? void 0 : _b.getImage();
84
- if (data == null)
85
- return;
86
- // pica
87
- const picaInstance = pica();
88
- // toBlob helper
89
- // Convenience method, similar to canvas.toBlob(), but with promise interface & polyfill for old browsers.
90
- const toBlob = (canvas, mimeType = 'image/jpeg', quality = 1) => {
91
- return picaInstance.toBlob(canvas, mimeType, quality);
92
- };
93
- if (data.width > maxWidthCalculated) {
94
- // Target height
95
- const heightCalculated = (height * maxWidthCalculated) / width;
96
- // Target
97
- const to = document.createElement('canvas');
98
- to.width = maxWidthCalculated;
99
- to.height = heightCalculated;
100
- // Large photo, resize it
101
- // https://github.com/nodeca/pica
102
- picaInstance
103
- .resize(data, to, {
104
- unsharpAmount: 160,
105
- unsharpRadius: 0.6,
106
- unsharpThreshold: 1
107
- })
108
- .then((result) => onDone(result, toBlob));
109
- }
110
- else {
111
- onDone(data, toBlob);
112
- }
113
- };
114
- return (React.createElement(Stack, { direction: "column", spacing: 0.5, width: containerWidth },
115
- React.createElement(Button, { variant: "outlined", size: "medium", component: "label", startIcon: React.createElement(ComputerIcon, null), fullWidth: true },
116
- labels.upload,
117
- React.createElement("input", { id: "fileInput", type: "file", accept: "image/png, image/jpeg", multiple: false, hidden: true, onChange: handleFileChange })),
118
- React.createElement(Stack, { direction: "row", spacing: 0.5 },
119
- React.createElement(AvatarEditor, { ref: ref, border: border, width: width, height: height, onLoadSuccess: handleLoad, image: previewImage !== null && previewImage !== void 0 ? previewImage : '', scale: editorState.scale, rotate: editorState.rotate }),
120
- React.createElement(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready },
121
- React.createElement(Button, { onClick: () => handleRotate(90), title: labels.rotateRight },
122
- React.createElement(RotateRightIcon, null)),
123
- React.createElement(Button, { onClick: () => handleRotate(-90), title: labels.rotateLeft },
124
- React.createElement(RotateLeftIcon, null)),
125
- React.createElement(Button, { onClick: handleReset, title: labels.reset },
126
- React.createElement(ClearAllIcon, null)))),
127
- React.createElement(Slider, { title: labels.zoom, disabled: !ready, min: 1, max: 5, step: 0.01, value: editorState.scale, onChange: handleZoom }),
128
- React.createElement(Button, { ref: buttonRef, variant: "contained", startIcon: React.createElement(DoneIcon, null), disabled: !ready, onClick: handleDone }, labels.done)));
129
- }
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- import { CommonPageProps } from './CommonPageProps';
3
- /**
4
- * Default scroll container
5
- */
6
- export declare const CommonPageScrollContainer: typeof globalThis;
7
- /**
8
- * Common page
9
- * @param props Props
10
- */
11
- export declare function CommonPage(props: CommonPageProps): JSX.Element;
@@ -1,60 +0,0 @@
1
- import React from 'react';
2
- import { FabBox } from '../FabBox';
3
- import { ScrollTopFab } from '../ScrollTopFab';
4
- import { Labels } from '../../app/Labels';
5
- import { MUGlobal } from '../MUGlobal';
6
- import { MoreFab } from '../MoreFab';
7
- import { ReactAppStateDetector } from '../../app/ReactApp';
8
- import { Container, Fab } from '@mui/material';
9
- import RefreshIcon from '@mui/icons-material/Refresh';
10
- import { BackButton } from '../BackButton';
11
- /**
12
- * Default scroll container
13
- */
14
- export const CommonPageScrollContainer = global;
15
- /**
16
- * Common page
17
- * @param props Props
18
- */
19
- export function CommonPage(props) {
20
- // Destruct
21
- const { children, disableGutters = true, fabButtons, fabColumnDirection, fabPaddingAdjust = 1.5, fabSize = 'small', maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, supportBack = false, targetFields, sx = {}, ...rest } = props;
22
- // Fab padding
23
- const fabPadding = MUGlobal.increase(MUGlobal.pagePaddings, fabPaddingAdjust);
24
- if (typeof sx === 'object' && sx != null && !Reflect.has(sx, 'padding')) {
25
- // Set default padding
26
- Reflect.set(sx, 'padding', paddings);
27
- }
28
- // Labels
29
- const labels = Labels.CommonPage;
30
- // Update
31
- const update = onUpdateAll
32
- ? onUpdateAll
33
- : onUpdate
34
- ? (authorized) => {
35
- if (authorized == null || authorized)
36
- onUpdate();
37
- }
38
- : onRefresh
39
- ? (authorized) => {
40
- if (authorized)
41
- onRefresh();
42
- }
43
- : undefined;
44
- // Return the UI
45
- return (React.createElement(React.Fragment, null,
46
- update && (React.createElement(ReactAppStateDetector, { targetFields: targetFields, update: update })),
47
- React.createElement(Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest },
48
- React.createElement(FabBox, { sx: {
49
- zIndex: 1,
50
- bottom: (theme) => MUGlobal.updateWithTheme(fabPadding, theme.spacing),
51
- right: (theme) => MUGlobal.updateWithTheme(fabPadding, theme.spacing)
52
- }, columnDirection: fabColumnDirection },
53
- scrollContainer && (React.createElement(ScrollTopFab, { size: fabSize, target: scrollContainer, title: labels.scrollTop })),
54
- fabButtons,
55
- onRefresh != null && (React.createElement(Fab, { title: labels.refresh, size: fabSize, onClick: onRefresh, sx: { display: { xs: 'none', md: 'inherit' } } },
56
- React.createElement(RefreshIcon, null))),
57
- React.createElement(MoreFab, { size: fabSize, title: labels.more, actions: moreActions }),
58
- supportBack && (React.createElement(BackButton, { title: labels.back, size: fabSize }))),
59
- children)));
60
- }
@@ -1,60 +0,0 @@
1
- /// <reference types="react" />
2
- import { UserKey } from '@etsoo/appscript';
3
- import { ContainerProps } from '@mui/material';
4
- import { ListItemReact } from '../../components/ListItemReact';
5
- import { IStateUpdate } from '../../states/IState';
6
- import { CustomFabSize } from '../CustomFabProps';
7
- /**
8
- * Common page props
9
- * Default container id is 'pageContainer'
10
- */
11
- export interface CommonPageProps extends Omit<ContainerProps, 'id'> {
12
- /**
13
- * Fab buttons
14
- */
15
- fabButtons?: React.ReactNode;
16
- /**
17
- * Fab size
18
- */
19
- fabSize?: CustomFabSize;
20
- /**
21
- * Fab flex column direction, undefined to hide it
22
- */
23
- fabColumnDirection?: boolean;
24
- /**
25
- * Fab padding adjust
26
- */
27
- fabPaddingAdjust?: number;
28
- /**
29
- * More actions
30
- */
31
- moreActions?: ListItemReact[];
32
- /**
33
- * On refresh callback, only when authorized = true
34
- */
35
- onRefresh?: () => void | PromiseLike<void>;
36
- /**
37
- * On page update, when authorized = null or true case, may uses onRefresh
38
- */
39
- onUpdate?: () => void | PromiseLike<void>;
40
- /**
41
- * On page update, all cases with authorized
42
- */
43
- onUpdateAll?: IStateUpdate;
44
- /**
45
- * Paddings
46
- */
47
- paddings?: Record<string, string | number>;
48
- /**
49
- * Scroll container
50
- */
51
- scrollContainer?: HTMLElement | object;
52
- /**
53
- * Support back click
54
- */
55
- supportBack?: boolean;
56
- /**
57
- * State last changed fields
58
- */
59
- targetFields?: UserKey[];
60
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes } from '@etsoo/shared';
3
- import { DataGridPageProps } from './DataGridPageProps';
4
- /**
5
- * DataGrid page
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export declare function DataGridPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: DataGridPageProps<T, F, D>): JSX.Element;
@@ -1,81 +0,0 @@
1
- import { Box, Stack } from '@mui/material';
2
- import React from 'react';
3
- import { GridDataGet } from '../../components/GridLoader';
4
- import useCombinedRefs from '../../uses/useCombinedRefs';
5
- import { useDimensions } from '../../uses/useDimensions';
6
- import { DataGridEx } from '../DataGridEx';
7
- import { MUGlobal } from '../MUGlobal';
8
- import { SearchBar } from '../SearchBar';
9
- import { CommonPage } from './CommonPage';
10
- /**
11
- * DataGrid page
12
- * @param props Props
13
- * @returns Component
14
- */
15
- export function DataGridPage(props) {
16
- var _a;
17
- // Destruct
18
- const { adjustHeight, fields, fieldTemplate, height, loadData, mRef, sizeReadyMiliseconds = 100, pageProps = {}, ...rest } = props;
19
- (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
20
- // States
21
- const [states, setStates] = React.useReducer((currentState, newState) => {
22
- return { ...currentState, ...newState };
23
- }, {
24
- height
25
- });
26
- const refs = useCombinedRefs(mRef, (ref) => {
27
- if (ref == null)
28
- return;
29
- states.ref = ref;
30
- //setStates({ ref });
31
- });
32
- // On submit callback
33
- const onSubmit = (data, _reset) => {
34
- setStates({ data });
35
- };
36
- const localLoadData = (props) => {
37
- const data = GridDataGet(props, fieldTemplate);
38
- return loadData(data);
39
- };
40
- // Watch container
41
- const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
42
- const rect = dimensions[0][2];
43
- React.useEffect(() => {
44
- if (rect != null && rect.height > 50 && height == null) {
45
- let gridHeight = document.documentElement.clientHeight -
46
- Math.round(rect.top + rect.height + 1);
47
- const style = window.getComputedStyle(dimensions[0][1]);
48
- const paddingBottom = parseFloat(style.paddingBottom);
49
- if (!isNaN(paddingBottom))
50
- gridHeight -= paddingBottom;
51
- if (adjustHeight != null) {
52
- gridHeight -= adjustHeight(gridHeight);
53
- }
54
- if (gridHeight !== states.height)
55
- setStates({ height: gridHeight });
56
- }
57
- }, [rect]);
58
- const list = React.useMemo(() => {
59
- const gridHeight = states.height;
60
- if (gridHeight == null)
61
- return;
62
- return (React.createElement(DataGridEx, { autoLoad: false, height: gridHeight, loadData: localLoadData, mRef: refs, outerRef: (element) => {
63
- if (element != null)
64
- setStates({ element });
65
- }, ...rest }));
66
- }, [states.height]);
67
- const { ref, data } = states;
68
- React.useEffect(() => {
69
- if (ref == null || data == null)
70
- return;
71
- ref.reset({ data });
72
- }, [ref, data]);
73
- // Layout
74
- return (React.createElement(CommonPage, { ...pageProps, scrollContainer: states.element },
75
- React.createElement(Stack, null,
76
- React.createElement(Box, { ref: dimensions[0][0], sx: {
77
- paddingBottom: pageProps.paddings
78
- } },
79
- React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
80
- list)));
81
- }