@etsoo/react 1.5.80 → 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 (257) 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/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 +3 -15
  16. package/src/{mu → components}/DnDList.tsx +11 -34
  17. package/src/components/GridMethodRef.ts +12 -0
  18. package/src/components/ScrollerGrid.tsx +3 -3
  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/ComboBox.tsx +0 -30
  25. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  26. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  27. package/__tests__/mu/SelectEx.tsx +0 -26
  28. package/lib/app/CommonApp.d.ts +0 -39
  29. package/lib/app/CommonApp.js +0 -149
  30. package/lib/app/IServiceAppSettings.d.ts +0 -11
  31. package/lib/app/IServiceAppSettings.js +0 -1
  32. package/lib/app/IServicePage.d.ts +0 -6
  33. package/lib/app/IServicePage.js +0 -1
  34. package/lib/app/IServiceUser.d.ts +0 -14
  35. package/lib/app/IServiceUser.js +0 -1
  36. package/lib/app/ISmartERPUser.d.ts +0 -14
  37. package/lib/app/ISmartERPUser.js +0 -1
  38. package/lib/app/Labels.d.ts +0 -65
  39. package/lib/app/Labels.js +0 -62
  40. package/lib/app/ReactApp.d.ts +0 -194
  41. package/lib/app/ReactApp.js +0 -298
  42. package/lib/app/ServiceApp.d.ts +0 -78
  43. package/lib/app/ServiceApp.js +0 -244
  44. package/lib/components/ShowDataComparison.d.ts +0 -20
  45. package/lib/components/ShowDataComparison.js +0 -60
  46. package/lib/mu/AuditDisplay.d.ts +0 -33
  47. package/lib/mu/AuditDisplay.js +0 -52
  48. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
  49. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  50. package/lib/mu/BackButton.d.ts +0 -13
  51. package/lib/mu/BackButton.js +0 -33
  52. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  53. package/lib/mu/BridgeCloseButton.js +0 -32
  54. package/lib/mu/ButtonLink.d.ts +0 -17
  55. package/lib/mu/ButtonLink.js +0 -19
  56. package/lib/mu/ComboBox.d.ts +0 -38
  57. package/lib/mu/ComboBox.js +0 -108
  58. package/lib/mu/CountdownButton.d.ts +0 -23
  59. package/lib/mu/CountdownButton.js +0 -81
  60. package/lib/mu/CustomFabProps.d.ts +0 -27
  61. package/lib/mu/CustomFabProps.js +0 -1
  62. package/lib/mu/DataGridEx.d.ts +0 -96
  63. package/lib/mu/DataGridEx.js +0 -331
  64. package/lib/mu/DataGridRenderers.d.ts +0 -22
  65. package/lib/mu/DataGridRenderers.js +0 -99
  66. package/lib/mu/DialogButton.d.ts +0 -54
  67. package/lib/mu/DialogButton.js +0 -45
  68. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  69. package/lib/mu/DraggablePaperComponent.js +0 -12
  70. package/lib/mu/EmailInput.d.ts +0 -11
  71. package/lib/mu/EmailInput.js +0 -15
  72. package/lib/mu/FabBox.d.ts +0 -21
  73. package/lib/mu/FabBox.js +0 -31
  74. package/lib/mu/FlexBox.d.ts +0 -14
  75. package/lib/mu/FlexBox.js +0 -18
  76. package/lib/mu/GridDataFormat.d.ts +0 -10
  77. package/lib/mu/GridDataFormat.js +0 -43
  78. package/lib/mu/GridMethodRef.d.ts +0 -11
  79. package/lib/mu/IconButtonLink.d.ts +0 -17
  80. package/lib/mu/IconButtonLink.js +0 -16
  81. package/lib/mu/InputField.d.ts +0 -21
  82. package/lib/mu/InputField.js +0 -39
  83. package/lib/mu/ItemList.d.ts +0 -56
  84. package/lib/mu/ItemList.js +0 -69
  85. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  86. package/lib/mu/ListItemRightIcon.js +0 -8
  87. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  88. package/lib/mu/ListMoreDisplay.js +0 -99
  89. package/lib/mu/LoadingButton.d.ts +0 -16
  90. package/lib/mu/LoadingButton.js +0 -41
  91. package/lib/mu/MUGlobal.d.ts +0 -102
  92. package/lib/mu/MUGlobal.js +0 -184
  93. package/lib/mu/MaskInput.d.ts +0 -34
  94. package/lib/mu/MaskInput.js +0 -43
  95. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  96. package/lib/mu/MobileListItemRenderer.js +0 -35
  97. package/lib/mu/MoreFab.d.ts +0 -45
  98. package/lib/mu/MoreFab.js +0 -95
  99. package/lib/mu/NotifierMU.d.ts +0 -47
  100. package/lib/mu/NotifierMU.js +0 -387
  101. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  102. package/lib/mu/NotifierPromptProps.js +0 -1
  103. package/lib/mu/OptionGroup.d.ts +0 -58
  104. package/lib/mu/OptionGroup.js +0 -81
  105. package/lib/mu/PList.d.ts +0 -15
  106. package/lib/mu/PList.js +0 -12
  107. package/lib/mu/ProgressCount.d.ts +0 -44
  108. package/lib/mu/ProgressCount.js +0 -79
  109. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  110. package/lib/mu/PullToRefreshUI.js +0 -18
  111. package/lib/mu/RLink.d.ts +0 -14
  112. package/lib/mu/RLink.js +0 -37
  113. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  114. package/lib/mu/ResponsibleContainer.js +0 -159
  115. package/lib/mu/ScrollTopFab.d.ts +0 -7
  116. package/lib/mu/ScrollTopFab.js +0 -25
  117. package/lib/mu/ScrollerListEx.d.ts +0 -81
  118. package/lib/mu/ScrollerListEx.js +0 -167
  119. package/lib/mu/SearchBar.d.ts +0 -29
  120. package/lib/mu/SearchBar.js +0 -262
  121. package/lib/mu/SearchField.d.ts +0 -21
  122. package/lib/mu/SearchField.js +0 -39
  123. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  124. package/lib/mu/SearchOptionGroup.js +0 -14
  125. package/lib/mu/SelectBool.d.ts +0 -13
  126. package/lib/mu/SelectBool.js +0 -22
  127. package/lib/mu/SelectEx.d.ts +0 -50
  128. package/lib/mu/SelectEx.js +0 -156
  129. package/lib/mu/Switch.d.ts +0 -29
  130. package/lib/mu/Switch.js +0 -34
  131. package/lib/mu/SwitchAnt.d.ts +0 -25
  132. package/lib/mu/SwitchAnt.js +0 -40
  133. package/lib/mu/TabBox.d.ts +0 -54
  134. package/lib/mu/TabBox.js +0 -31
  135. package/lib/mu/TableEx.d.ts +0 -66
  136. package/lib/mu/TableEx.js +0 -271
  137. package/lib/mu/TextFieldEx.d.ts +0 -101
  138. package/lib/mu/TextFieldEx.js +0 -127
  139. package/lib/mu/Tiplist.d.ts +0 -18
  140. package/lib/mu/Tiplist.js +0 -158
  141. package/lib/mu/TooltipClick.d.ts +0 -15
  142. package/lib/mu/TooltipClick.js +0 -40
  143. package/lib/mu/UserAvatar.d.ts +0 -24
  144. package/lib/mu/UserAvatar.js +0 -25
  145. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  146. package/lib/mu/UserAvatarEditor.js +0 -129
  147. package/lib/mu/pages/CommonPage.d.ts +0 -11
  148. package/lib/mu/pages/CommonPage.js +0 -60
  149. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  150. package/lib/mu/pages/CommonPageProps.js +0 -1
  151. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  152. package/lib/mu/pages/DataGridPage.js +0 -81
  153. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  154. package/lib/mu/pages/DataGridPageProps.js +0 -1
  155. package/lib/mu/pages/EditPage.d.ts +0 -33
  156. package/lib/mu/pages/EditPage.js +0 -29
  157. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  158. package/lib/mu/pages/FixedListPage.js +0 -72
  159. package/lib/mu/pages/ListPage.d.ts +0 -9
  160. package/lib/mu/pages/ListPage.js +0 -51
  161. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  162. package/lib/mu/pages/ListPageProps.js +0 -1
  163. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  164. package/lib/mu/pages/ResponsivePage.js +0 -45
  165. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  166. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  167. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  168. package/lib/mu/pages/SearchPageProps.js +0 -1
  169. package/lib/mu/pages/TablePage.d.ts +0 -9
  170. package/lib/mu/pages/TablePage.js +0 -71
  171. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  172. package/lib/mu/pages/TablePageProps.js +0 -1
  173. package/lib/mu/pages/ViewPage.d.ts +0 -66
  174. package/lib/mu/pages/ViewPage.js +0 -105
  175. package/lib/mu/texts/DateText.d.ts +0 -34
  176. package/lib/mu/texts/DateText.js +0 -25
  177. package/lib/mu/texts/MoneyText.d.ts +0 -21
  178. package/lib/mu/texts/MoneyText.js +0 -14
  179. package/lib/mu/texts/NumberText.d.ts +0 -25
  180. package/lib/mu/texts/NumberText.js +0 -14
  181. package/src/app/CommonApp.ts +0 -225
  182. package/src/app/IServiceAppSettings.ts +0 -13
  183. package/src/app/IServicePage.ts +0 -6
  184. package/src/app/IServiceUser.ts +0 -17
  185. package/src/app/ISmartERPUser.ts +0 -16
  186. package/src/app/Labels.ts +0 -77
  187. package/src/app/ReactApp.ts +0 -500
  188. package/src/app/ServiceApp.ts +0 -353
  189. package/src/components/ShowDataComparison.tsx +0 -108
  190. package/src/mu/AuditDisplay.tsx +0 -117
  191. package/src/mu/AutocompleteExtendedProps.ts +0 -83
  192. package/src/mu/BackButton.tsx +0 -55
  193. package/src/mu/BridgeCloseButton.tsx +0 -69
  194. package/src/mu/ButtonLink.tsx +0 -32
  195. package/src/mu/ComboBox.tsx +0 -251
  196. package/src/mu/CountdownButton.tsx +0 -119
  197. package/src/mu/CustomFabProps.ts +0 -32
  198. package/src/mu/DataGridEx.tsx +0 -712
  199. package/src/mu/DataGridRenderers.tsx +0 -140
  200. package/src/mu/DialogButton.tsx +0 -163
  201. package/src/mu/DraggablePaperComponent.tsx +0 -19
  202. package/src/mu/EmailInput.tsx +0 -24
  203. package/src/mu/FabBox.tsx +0 -51
  204. package/src/mu/FlexBox.tsx +0 -20
  205. package/src/mu/GridDataFormat.tsx +0 -77
  206. package/src/mu/GridMethodRef.ts +0 -12
  207. package/src/mu/IconButtonLink.tsx +0 -29
  208. package/src/mu/InputField.tsx +0 -82
  209. package/src/mu/ItemList.tsx +0 -204
  210. package/src/mu/ListItemRightIcon.tsx +0 -9
  211. package/src/mu/ListMoreDisplay.tsx +0 -205
  212. package/src/mu/LoadingButton.tsx +0 -75
  213. package/src/mu/MUGlobal.ts +0 -220
  214. package/src/mu/MaskInput.tsx +0 -107
  215. package/src/mu/MobileListItemRenderer.tsx +0 -79
  216. package/src/mu/MoreFab.tsx +0 -211
  217. package/src/mu/NotifierMU.tsx +0 -654
  218. package/src/mu/NotifierPromptProps.ts +0 -26
  219. package/src/mu/OptionGroup.tsx +0 -223
  220. package/src/mu/PList.tsx +0 -27
  221. package/src/mu/ProgressCount.tsx +0 -166
  222. package/src/mu/PullToRefreshUI.tsx +0 -21
  223. package/src/mu/RLink.tsx +0 -64
  224. package/src/mu/ResponsibleContainer.tsx +0 -394
  225. package/src/mu/ScrollTopFab.tsx +0 -34
  226. package/src/mu/ScrollerListEx.tsx +0 -387
  227. package/src/mu/SearchBar.tsx +0 -398
  228. package/src/mu/SearchField.tsx +0 -82
  229. package/src/mu/SearchOptionGroup.tsx +0 -31
  230. package/src/mu/SelectBool.tsx +0 -33
  231. package/src/mu/SelectEx.tsx +0 -290
  232. package/src/mu/Switch.tsx +0 -94
  233. package/src/mu/SwitchAnt.tsx +0 -95
  234. package/src/mu/TabBox.tsx +0 -118
  235. package/src/mu/TableEx.tsx +0 -560
  236. package/src/mu/TextFieldEx.tsx +0 -250
  237. package/src/mu/Tiplist.tsx +0 -304
  238. package/src/mu/TooltipClick.tsx +0 -84
  239. package/src/mu/UserAvatar.tsx +0 -64
  240. package/src/mu/UserAvatarEditor.tsx +0 -287
  241. package/src/mu/pages/CommonPage.tsx +0 -128
  242. package/src/mu/pages/CommonPageProps.ts +0 -71
  243. package/src/mu/pages/DataGridPage.tsx +0 -137
  244. package/src/mu/pages/DataGridPageProps.ts +0 -24
  245. package/src/mu/pages/EditPage.tsx +0 -114
  246. package/src/mu/pages/FixedListPage.tsx +0 -135
  247. package/src/mu/pages/ListPage.tsx +0 -87
  248. package/src/mu/pages/ListPageProps.ts +0 -12
  249. package/src/mu/pages/ResponsivePage.tsx +0 -68
  250. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  251. package/src/mu/pages/SearchPageProps.ts +0 -39
  252. package/src/mu/pages/TablePage.tsx +0 -120
  253. package/src/mu/pages/TablePageProps.ts +0 -12
  254. package/src/mu/pages/ViewPage.tsx +0 -285
  255. package/src/mu/texts/DateText.tsx +0 -74
  256. package/src/mu/texts/MoneyText.tsx +0 -49
  257. package/src/mu/texts/NumberText.tsx +0 -40
@@ -1,17 +0,0 @@
1
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
- import { DataGridExProps } from '../DataGridEx';
3
- import { SearchPageProps } from './SearchPageProps';
4
- /**
5
- * DataGrid page props
6
- */
7
- export declare type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = SearchPageProps<T, F> & Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
8
- /**
9
- * Height will be deducted
10
- * @param height Current calcuated height
11
- */
12
- adjustHeight?: (height: number) => number;
13
- /**
14
- * Grid height
15
- */
16
- height?: number;
17
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import { FormEventHandler } from 'react';
2
- import { CommonPageProps } from './CommonPageProps';
3
- /**
4
- * Add / Edit page props
5
- */
6
- export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
7
- /**
8
- * Is editing
9
- */
10
- isEditing?: boolean;
11
- /**
12
- * On form submit
13
- */
14
- onSubmit?: FormEventHandler<HTMLFormElement>;
15
- /**
16
- * On delete callback
17
- */
18
- onDelete?: () => Promise<void> | void;
19
- /**
20
- * Submit button disabled or not
21
- */
22
- submitDisabled?: boolean;
23
- /**
24
- * Support back click
25
- * @default true
26
- */
27
- supportBack?: boolean;
28
- }
29
- /**
30
- * Add / Edit page
31
- * @param props Props
32
- */
33
- export declare function EditPage(props: EditPageProps): JSX.Element;
@@ -1,29 +0,0 @@
1
- import { Button, Grid } from '@mui/material';
2
- import React from 'react';
3
- import { Labels } from '../../app/Labels';
4
- import { MUGlobal } from '../MUGlobal';
5
- import { CommonPage, CommonPageScrollContainer } from './CommonPage';
6
- import SaveIcon from '@mui/icons-material/Save';
7
- import DeleteIcon from '@mui/icons-material/Delete';
8
- import { BackButton } from '../BackButton';
9
- /**
10
- * Add / Edit page
11
- * @param props Props
12
- */
13
- export function EditPage(props) {
14
- // Destruct
15
- const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, supportBack = true, submitDisabled = false, ...rest } = props;
16
- // Labels
17
- const labels = Labels.CommonPage;
18
- return (React.createElement(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest },
19
- React.createElement("form", { onSubmit: onSubmit },
20
- React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, paddingTop: 1 }, children),
21
- React.createElement(Grid, { container: true, position: "sticky", display: "flex", gap: paddings, sx: {
22
- top: 'auto',
23
- bottom: (theme) => MUGlobal.updateWithTheme(paddings, theme.spacing),
24
- paddingTop: paddings
25
- } },
26
- isEditing && onDelete && (React.createElement(Button, { color: "primary", variant: "outlined", onClick: () => onDelete(), startIcon: React.createElement(DeleteIcon, { color: "warning" }) }, labels.delete)),
27
- React.createElement(Button, { variant: "contained", type: "submit", startIcon: React.createElement(SaveIcon, null), sx: { flexGrow: 1 }, disabled: submitDisabled }, labels.save),
28
- supportBack && React.createElement(BackButton, { title: labels.back })))));
29
- }
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { ListPageProps } from './ListPageProps';
4
- /**
5
- * Fixed height list page
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export declare function FixedListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ListPageProps<T, F, D> & {
10
- /**
11
- * Height will be deducted
12
- * @param height Current calcuated height
13
- */
14
- adjustHeight?: (height: number) => number;
15
- }): JSX.Element;
@@ -1,72 +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 { MUGlobal } from '../MUGlobal';
7
- import { ScrollerListEx } from '../ScrollerListEx';
8
- import { SearchBar } from '../SearchBar';
9
- import { CommonPage } from './CommonPage';
10
- /**
11
- * Fixed height list page
12
- * @param props Props
13
- * @returns Component
14
- */
15
- export function FixedListPage(props) {
16
- var _a;
17
- // Destruct
18
- const { adjustHeight, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, ...rest } = props;
19
- (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
20
- // States
21
- const [states] = React.useState({});
22
- // Scroll container
23
- const [scrollContainer, updateScrollContainer] = React.useState();
24
- const refs = useCombinedRefs(mRef, (ref) => {
25
- if (ref == null)
26
- return;
27
- const first = states.ref == null;
28
- states.ref = ref;
29
- if (first)
30
- reset();
31
- });
32
- const reset = () => {
33
- if (states.data == null || states.ref == null)
34
- return;
35
- states.ref.reset({ data: states.data });
36
- };
37
- // On submit callback
38
- const onSubmit = (data, _reset) => {
39
- states.data = data;
40
- reset();
41
- };
42
- const localLoadData = (props) => {
43
- const data = GridDataGet(props, fieldTemplate);
44
- return loadData(data);
45
- };
46
- // Watch container
47
- const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
48
- const rect = dimensions[0][2];
49
- const list = React.useMemo(() => {
50
- if (rect != null && rect.height > 50) {
51
- let height = document.documentElement.clientHeight -
52
- Math.round(rect.top + rect.height + 1);
53
- if (adjustHeight != null) {
54
- height -= adjustHeight(height);
55
- }
56
- return (React.createElement(Box, { id: "list-container", sx: {
57
- height: height + 'px'
58
- } },
59
- React.createElement(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs, oRef: (element) => {
60
- if (element != null)
61
- updateScrollContainer(element);
62
- }, ...rest })));
63
- }
64
- }, [rect]);
65
- const { paddings, ...pageRest } = pageProps;
66
- // Layout
67
- return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer },
68
- React.createElement(Stack, null,
69
- React.createElement(Box, { ref: dimensions[0][0], sx: { padding: paddings } },
70
- React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
71
- list)));
72
- }
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { ListPageProps } from './ListPageProps';
4
- /**
5
- * List page
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export declare function ListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ListPageProps<T, F, D>): JSX.Element;
@@ -1,51 +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 { MUGlobal } from '../MUGlobal';
6
- import { ScrollerListEx } from '../ScrollerListEx';
7
- import { SearchBar } from '../SearchBar';
8
- import { CommonPage, CommonPageScrollContainer } from './CommonPage';
9
- /**
10
- * List page
11
- * @param props Props
12
- * @returns Component
13
- */
14
- export function ListPage(props) {
15
- var _a;
16
- // Destruct
17
- const { fields, fieldTemplate, loadData, mRef, pageProps = {}, ...rest } = props;
18
- (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
19
- // States
20
- const [states] = React.useState({});
21
- const refs = useCombinedRefs(mRef, (ref) => {
22
- if (ref == null)
23
- return;
24
- const first = states.ref == null;
25
- states.ref = ref;
26
- if (first)
27
- reset();
28
- });
29
- const reset = () => {
30
- if (states.data == null || states.ref == null)
31
- return;
32
- states.ref.reset({ data: states.data });
33
- };
34
- // On submit callback
35
- const onSubmit = (data, _reset) => {
36
- states.data = data;
37
- reset();
38
- };
39
- const localLoadData = (props) => {
40
- const data = GridDataGet(props, fieldTemplate);
41
- return loadData(data);
42
- };
43
- // Layout
44
- return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer },
45
- React.createElement(Stack, null,
46
- React.createElement(Box, { sx: {
47
- paddingBottom: pageProps.paddings
48
- } },
49
- React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
50
- React.createElement(ScrollerListEx, { autoLoad: false, loadData: localLoadData, mRef: refs, ...rest }))));
51
- }
@@ -1,7 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { ScrollerListExProps } from '../ScrollerListEx';
3
- import { SearchPageProps } from './SearchPageProps';
4
- /**
5
- * List page props
6
- */
7
- export declare type ListPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T, D>, 'loadData'>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { ResponsePageProps } from './ResponsivePageProps';
4
- /**
5
- * Fixed height list page
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export declare function ResponsivePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ResponsePageProps<T, F, D>): JSX.Element;
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { MUGlobal } from '../MUGlobal';
3
- import { ResponsibleContainer } from '../ResponsibleContainer';
4
- import { CommonPage } from './CommonPage';
5
- /**
6
- * Fixed height list page
7
- * @param props Props
8
- * @returns Component
9
- */
10
- export function ResponsivePage(props) {
11
- var _a;
12
- // Destruct
13
- const { pageProps = {}, ...rest } = props;
14
- (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
15
- const { paddings, fabColumnDirection, ...pageRest } = pageProps;
16
- // State
17
- const [scrollContainer, setScrollContainer] = React.useState();
18
- const [direction, setDirection] = React.useState(fabColumnDirection);
19
- // Layout
20
- return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, fabColumnDirection: direction },
21
- React.createElement(ResponsibleContainer, { paddings: paddings, containerBoxSx: (paddings, hasField, _dataGrid) => {
22
- // Half
23
- const half = MUGlobal.half(paddings);
24
- // .SearchBox keep the same to avoid flick when switching between DataGrid and List
25
- return {
26
- paddingTop: paddings,
27
- '& .SearchBox': {
28
- marginLeft: paddings,
29
- marginRight: paddings,
30
- marginBottom: hasField ? half : 0
31
- },
32
- '& .ListBox': {
33
- marginBottom: paddings
34
- },
35
- '& .DataGridBox': {
36
- marginLeft: paddings,
37
- marginRight: paddings,
38
- marginBottom: paddings
39
- }
40
- };
41
- }, elementReady: (element, isDataGrid) => {
42
- setDirection(!isDataGrid);
43
- setScrollContainer(element);
44
- }, ...rest })));
45
- }
@@ -1,39 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { ListChildComponentProps } from 'react-window';
4
- import { GridMethodRef } from '../GridMethodRef';
5
- import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from '../ScrollerListEx';
6
- import { DataGridPageProps } from './DataGridPageProps';
7
- /**
8
- * Response page props
9
- */
10
- export declare type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = Omit<DataGridPageProps<T, F, D>, 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'> & {
11
- /**
12
- * Min width to show Datagrid
13
- */
14
- dataGridMinWidth?: number;
15
- /**
16
- * Inner item renderer
17
- */
18
- innerItemRenderer: (props: ScrollerListExInnerItemRendererProps<T>) => React.ReactNode;
19
- /**
20
- * Item renderer
21
- */
22
- itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
23
- /**
24
- * Item size, a function indicates its a variable size list
25
- */
26
- itemSize: ScrollerListExItemSize;
27
- /**
28
- * Methods
29
- */
30
- mRef?: React.MutableRefObject<GridMethodRef | undefined>;
31
- /**
32
- * Pull to refresh data
33
- */
34
- pullToRefresh?: boolean;
35
- /**
36
- * Quick action for double click or click under mobile
37
- */
38
- quickAction?: (data: T) => void;
39
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes } from '@etsoo/shared';
3
- import { GridJsonData, GridLoader } from '../../components/GridLoader';
4
- import { CommonPageProps } from './CommonPageProps';
5
- /**
6
- * Search page props
7
- */
8
- export declare type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, 'loadData'> & {
9
- /**
10
- * Search fields
11
- */
12
- fields: React.ReactElement[];
13
- /**
14
- * Search field template
15
- */
16
- fieldTemplate?: F;
17
- /**
18
- * Load data callback
19
- */
20
- loadData: (data: GridJsonData & DataTypes.BasicTemplateType<F>) => PromiseLike<T[] | null | undefined>;
21
- /**
22
- * Page props
23
- */
24
- pageProps?: CommonPageProps;
25
- /**
26
- * Size ready to read miliseconds span
27
- * @default 100
28
- */
29
- sizeReadyMiliseconds?: number;
30
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { DataTypes, IdDefaultType } from '@etsoo/shared';
3
- import { TablePageProps } from './TablePageProps';
4
- /**
5
- * Table page
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export declare function TablePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TablePageProps<T, F, D>): JSX.Element;
@@ -1,71 +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 { MUGlobal } from '../MUGlobal';
7
- import { SearchBar } from '../SearchBar';
8
- import { TableEx, TableExMinWidth } from '../TableEx';
9
- import { CommonPage, CommonPageScrollContainer } from './CommonPage';
10
- /**
11
- * Table page
12
- * @param props Props
13
- * @returns Component
14
- */
15
- export function TablePage(props) {
16
- var _a;
17
- // Destruct
18
- const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, ...rest } = props;
19
- (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
20
- // States
21
- const [states] = React.useState({});
22
- const refs = useCombinedRefs(mRef, (ref) => {
23
- if (ref == null)
24
- return;
25
- const first = states.ref == null;
26
- states.ref = ref;
27
- if (first)
28
- reset();
29
- });
30
- const reset = () => {
31
- if (states.data == null || states.ref == null)
32
- return;
33
- states.ref.reset({ data: states.data });
34
- };
35
- // On submit callback
36
- const onSubmit = (data, _reset) => {
37
- states.data = data;
38
- reset();
39
- };
40
- const localLoadData = (props) => {
41
- const data = GridDataGet(props, fieldTemplate);
42
- return loadData(data);
43
- };
44
- // Total width
45
- const totalWidth = React.useMemo(() => columns.reduce((previousValue, { width, minWidth }) => {
46
- var _a;
47
- return previousValue + ((_a = width !== null && width !== void 0 ? width : minWidth) !== null && _a !== void 0 ? _a : TableExMinWidth);
48
- }, 0), [columns]);
49
- // Watch container
50
- const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
51
- const rect = dimensions[0][2];
52
- const list = React.useMemo(() => {
53
- if (rect != null && rect.height > 50 && rect.width >= totalWidth) {
54
- let maxHeight = document.documentElement.clientHeight -
55
- (rect.top + rect.height + 1);
56
- const style = window.getComputedStyle(dimensions[0][1]);
57
- const paddingBottom = parseFloat(style.paddingBottom);
58
- if (!isNaN(paddingBottom))
59
- maxHeight -= paddingBottom;
60
- return (React.createElement(TableEx, { autoLoad: false, columns: columns, loadData: localLoadData, maxHeight: maxHeight, mRef: refs, ...rest }));
61
- }
62
- }, [rect]);
63
- // Layout
64
- return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer },
65
- React.createElement(Stack, null,
66
- React.createElement(Box, { ref: dimensions[0][0], sx: {
67
- paddingBottom: pageProps.paddings
68
- } },
69
- React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
70
- list)));
71
- }
@@ -1,7 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { TableExProps } from '../TableEx';
3
- import { SearchPageProps } from './SearchPageProps';
4
- /**
5
- * Table page props
6
- */
7
- export declare type TablePageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<TableExProps<T, D>, 'loadData'>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { GridProps } from '@mui/material';
3
- import React from 'react';
4
- import { GridColumnRenderProps, GridDataType } from '../../components/GridColumn';
5
- import { CommonPageProps } from './CommonPageProps';
6
- /**
7
- * View page display field
8
- */
9
- export interface ViewPageField<T extends object> extends GridProps {
10
- /**
11
- * Data field
12
- */
13
- data: (string & keyof T) | ((item: T) => React.ReactNode);
14
- /**
15
- * Data type
16
- */
17
- dataType?: GridDataType;
18
- /**
19
- * Label field
20
- */
21
- label?: string | (() => React.ReactNode);
22
- /**
23
- * Display as single row
24
- */
25
- singleRow?: boolean;
26
- /**
27
- * Render props
28
- */
29
- renderProps?: GridColumnRenderProps;
30
- }
31
- declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
32
- /**
33
- * View page props
34
- */
35
- export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, 'children'> {
36
- /**
37
- * Actions
38
- */
39
- actions?: React.ReactNode | ((data: T, refresh: () => PromiseLike<void>) => React.ReactNode);
40
- /**
41
- * Children
42
- */
43
- children?: React.ReactNode | ((data: T, refresh: () => PromiseLike<void>) => React.ReactNode);
44
- /**
45
- * Fields to display
46
- */
47
- fields: ViewPageFieldType<T>[];
48
- /**
49
- * Load data
50
- */
51
- loadData: () => PromiseLike<T | undefined>;
52
- /**
53
- * Pull to refresh data
54
- */
55
- pullToRefresh?: boolean;
56
- /**
57
- * Support refresh
58
- */
59
- supportRefresh?: boolean;
60
- }
61
- /**
62
- * View page
63
- * @param props Props
64
- */
65
- export declare function ViewPage<T extends DataTypes.StringRecord>(props: ViewPageProps<T>): JSX.Element;
66
- export {};
@@ -1,105 +0,0 @@
1
- import { Utils } from '@etsoo/shared';
2
- import { Grid, LinearProgress, Stack, Typography } from '@mui/material';
3
- import React from 'react';
4
- import { Labels } from '../../app/Labels';
5
- import { globalApp } from '../../app/ReactApp';
6
- import { GridDataFormat } from '../GridDataFormat';
7
- import { MUGlobal } from '../MUGlobal';
8
- import { PullToRefreshUI } from '../PullToRefreshUI';
9
- import { CommonPage } from './CommonPage';
10
- function formatItemData(fieldData) {
11
- if (fieldData == null)
12
- return undefined;
13
- if (typeof fieldData === 'string')
14
- return fieldData;
15
- if (fieldData instanceof Date)
16
- return globalApp.formatDate(fieldData, 'd');
17
- return `${fieldData}`;
18
- }
19
- function getItemField(field, data) {
20
- var _a, _b, _c;
21
- // Item data and label
22
- let itemData, itemLabel, gridProps = {};
23
- let xs = 6;
24
- if (Array.isArray(field)) {
25
- const [fieldData, fieldType, renderProps] = field;
26
- itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
27
- itemLabel = (_a = globalApp.get(fieldData)) !== null && _a !== void 0 ? _a : fieldData;
28
- }
29
- else if (typeof field === 'object') {
30
- // Destruct
31
- const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow, ...rest } = field;
32
- gridProps = {
33
- ...rest,
34
- ...(singleRow && { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 })
35
- };
36
- if (singleRow === false)
37
- xs = 12;
38
- // Field data
39
- if (typeof fieldData === 'function')
40
- itemData = fieldData(data);
41
- else if (dataType == null)
42
- itemData = formatItemData(data[fieldData]);
43
- else
44
- itemData = GridDataFormat(data[fieldData], dataType, renderProps);
45
- // Field label
46
- itemLabel =
47
- typeof fieldLabel === 'function'
48
- ? fieldLabel()
49
- : (_b = globalApp.get(fieldLabel !== null && fieldLabel !== void 0 ? fieldLabel : (typeof fieldData === 'string' ? fieldData : 'noData'))) !== null && _b !== void 0 ? _b : fieldLabel;
50
- }
51
- else {
52
- itemData = formatItemData(data[field]);
53
- itemLabel = (_c = globalApp.get(field)) !== null && _c !== void 0 ? _c : field;
54
- }
55
- return [
56
- itemData,
57
- itemLabel,
58
- { xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
59
- ];
60
- }
61
- /**
62
- * View page
63
- * @param props Props
64
- */
65
- export function ViewPage(props) {
66
- // Destruct
67
- const { actions, children, fields, loadData, paddings = MUGlobal.pagePaddings, supportRefresh = true, fabColumnDirection = true, supportBack = true, pullToRefresh = true, ...rest } = props;
68
- // Data
69
- const [data, setData] = React.useState();
70
- // Labels
71
- const labels = Labels.CommonPage;
72
- // Container
73
- const pullContainer = '#page-container';
74
- // Load data
75
- const refresh = async () => {
76
- const result = await loadData();
77
- if (result == null)
78
- return;
79
- setData(result);
80
- };
81
- return (React.createElement(CommonPage, { paddings: paddings, onRefresh: supportRefresh ? refresh : undefined, onUpdate: supportRefresh ? undefined : refresh, ...rest, scrollContainer: globalThis, fabColumnDirection: fabColumnDirection, supportBack: supportBack }, data == null ? (React.createElement(LinearProgress, null)) : (React.createElement(React.Fragment, null,
82
- React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, className: "ET-ViewPage", sx: {
83
- '.MuiTypography-subtitle2': {
84
- fontWeight: 'bold'
85
- }
86
- } }, fields.map((field, index) => {
87
- // Get data
88
- const [itemData, itemLabel, gridProps] = getItemField(field, data);
89
- // Some callback function may return '' instead of undefined
90
- if (itemData == null || itemData === '')
91
- return undefined;
92
- // Layout
93
- return (React.createElement(Grid, { item: true, ...gridProps, key: index },
94
- React.createElement(Typography, { variant: "caption", component: "div" },
95
- itemLabel,
96
- ":"),
97
- React.createElement(Typography, { variant: "subtitle2" }, itemData)));
98
- })),
99
- actions != null && (React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", justifyContent: "flex-end", paddingTop: paddings, paddingBottom: paddings, gap: paddings }, Utils.getResult(actions, data, refresh))),
100
- Utils.getResult(children, data, refresh),
101
- pullToRefresh && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: refresh, shouldPullToRefresh: () => {
102
- const container = document.querySelector(pullContainer);
103
- return !(container === null || container === void 0 ? void 0 : container.scrollTop);
104
- } }))))));
105
- }