@etsoo/materialui 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.json +38 -0
  3. package/.gitattributes +2 -0
  4. package/.github/workflows/main.yml +48 -0
  5. package/.prettierignore +5 -0
  6. package/.prettierrc +6 -0
  7. package/LICENSE +21 -0
  8. package/README.md +16 -0
  9. package/__tests__/ComboBox.tsx +30 -0
  10. package/__tests__/MUGlobalTests.tsx +58 -0
  11. package/__tests__/NotifierMUTests.tsx +217 -0
  12. package/__tests__/SelectEx.tsx +26 -0
  13. package/__tests__/tsconfig.json +19 -0
  14. package/babel.config.json +11 -0
  15. package/lib/AuditDisplay.d.ts +33 -0
  16. package/lib/AuditDisplay.js +52 -0
  17. package/lib/AutocompleteExtendedProps.d.ts +64 -0
  18. package/lib/AutocompleteExtendedProps.js +1 -0
  19. package/lib/BackButton.d.ts +13 -0
  20. package/lib/BackButton.js +33 -0
  21. package/lib/BridgeCloseButton.d.ts +23 -0
  22. package/lib/BridgeCloseButton.js +32 -0
  23. package/lib/ButtonLink.d.ts +17 -0
  24. package/lib/ButtonLink.js +19 -0
  25. package/lib/ComboBox.d.ts +38 -0
  26. package/lib/ComboBox.js +108 -0
  27. package/lib/CountdownButton.d.ts +23 -0
  28. package/lib/CountdownButton.js +81 -0
  29. package/lib/CustomFabProps.d.ts +27 -0
  30. package/lib/CustomFabProps.js +1 -0
  31. package/lib/DataGridEx.d.ts +94 -0
  32. package/lib/DataGridEx.js +329 -0
  33. package/lib/DataGridRenderers.d.ts +22 -0
  34. package/lib/DataGridRenderers.js +99 -0
  35. package/lib/DialogButton.d.ts +54 -0
  36. package/lib/DialogButton.js +45 -0
  37. package/lib/DnDList.d.ts +87 -0
  38. package/lib/DnDList.js +153 -0
  39. package/lib/DraggablePaperComponent.d.ts +8 -0
  40. package/lib/DraggablePaperComponent.js +12 -0
  41. package/lib/EmailInput.d.ts +11 -0
  42. package/lib/EmailInput.js +15 -0
  43. package/lib/FabBox.d.ts +21 -0
  44. package/lib/FabBox.js +31 -0
  45. package/lib/FlexBox.d.ts +14 -0
  46. package/lib/FlexBox.js +18 -0
  47. package/lib/GridDataFormat.d.ts +10 -0
  48. package/lib/GridDataFormat.js +43 -0
  49. package/lib/IconButtonLink.d.ts +17 -0
  50. package/lib/IconButtonLink.js +16 -0
  51. package/lib/InputField.d.ts +21 -0
  52. package/lib/InputField.js +39 -0
  53. package/lib/ItemList.d.ts +56 -0
  54. package/lib/ItemList.js +69 -0
  55. package/lib/ListItemRightIcon.d.ts +4 -0
  56. package/lib/ListItemRightIcon.js +8 -0
  57. package/lib/ListMoreDisplay.d.ts +35 -0
  58. package/lib/ListMoreDisplay.js +99 -0
  59. package/lib/LoadingButton.d.ts +16 -0
  60. package/lib/LoadingButton.js +41 -0
  61. package/lib/MUGlobal.d.ts +102 -0
  62. package/lib/MUGlobal.js +184 -0
  63. package/lib/MaskInput.d.ts +34 -0
  64. package/lib/MaskInput.js +43 -0
  65. package/lib/MobileListItemRenderer.d.ts +17 -0
  66. package/lib/MobileListItemRenderer.js +35 -0
  67. package/lib/MoreFab.d.ts +45 -0
  68. package/lib/MoreFab.js +95 -0
  69. package/lib/NotifierMU.d.ts +47 -0
  70. package/lib/NotifierMU.js +387 -0
  71. package/lib/NotifierPromptProps.d.ts +22 -0
  72. package/lib/NotifierPromptProps.js +1 -0
  73. package/lib/OptionGroup.d.ts +58 -0
  74. package/lib/OptionGroup.js +81 -0
  75. package/lib/PList.d.ts +15 -0
  76. package/lib/PList.js +12 -0
  77. package/lib/ProgressCount.d.ts +44 -0
  78. package/lib/ProgressCount.js +79 -0
  79. package/lib/PullToRefreshUI.d.ts +9 -0
  80. package/lib/PullToRefreshUI.js +18 -0
  81. package/lib/RLink.d.ts +14 -0
  82. package/lib/RLink.js +37 -0
  83. package/lib/ResponsibleContainer.d.ts +87 -0
  84. package/lib/ResponsibleContainer.js +156 -0
  85. package/lib/ScrollTopFab.d.ts +7 -0
  86. package/lib/ScrollTopFab.js +25 -0
  87. package/lib/ScrollerListEx.d.ts +81 -0
  88. package/lib/ScrollerListEx.js +167 -0
  89. package/lib/SearchBar.d.ts +29 -0
  90. package/lib/SearchBar.js +260 -0
  91. package/lib/SearchField.d.ts +21 -0
  92. package/lib/SearchField.js +39 -0
  93. package/lib/SearchOptionGroup.d.ts +9 -0
  94. package/lib/SearchOptionGroup.js +14 -0
  95. package/lib/SelectBool.d.ts +13 -0
  96. package/lib/SelectBool.js +22 -0
  97. package/lib/SelectEx.d.ts +50 -0
  98. package/lib/SelectEx.js +156 -0
  99. package/lib/ShowDataComparison.d.ts +20 -0
  100. package/lib/ShowDataComparison.js +58 -0
  101. package/lib/Switch.d.ts +29 -0
  102. package/lib/Switch.js +34 -0
  103. package/lib/SwitchAnt.d.ts +25 -0
  104. package/lib/SwitchAnt.js +40 -0
  105. package/lib/TabBox.d.ts +54 -0
  106. package/lib/TabBox.js +31 -0
  107. package/lib/TableEx.d.ts +65 -0
  108. package/lib/TableEx.js +270 -0
  109. package/lib/TextFieldEx.d.ts +101 -0
  110. package/lib/TextFieldEx.js +126 -0
  111. package/lib/Tiplist.d.ts +18 -0
  112. package/lib/Tiplist.js +157 -0
  113. package/lib/TooltipClick.d.ts +15 -0
  114. package/lib/TooltipClick.js +40 -0
  115. package/lib/UserAvatar.d.ts +24 -0
  116. package/lib/UserAvatar.js +25 -0
  117. package/lib/UserAvatarEditor.d.ts +53 -0
  118. package/lib/UserAvatarEditor.js +129 -0
  119. package/lib/app/CommonApp.d.ts +38 -0
  120. package/lib/app/CommonApp.js +149 -0
  121. package/lib/app/IServiceAppSettings.d.ts +11 -0
  122. package/lib/app/IServiceAppSettings.js +1 -0
  123. package/lib/app/IServicePage.d.ts +6 -0
  124. package/lib/app/IServicePage.js +1 -0
  125. package/lib/app/IServiceUser.d.ts +14 -0
  126. package/lib/app/IServiceUser.js +1 -0
  127. package/lib/app/ISmartERPUser.d.ts +14 -0
  128. package/lib/app/ISmartERPUser.js +1 -0
  129. package/lib/app/Labels.d.ts +65 -0
  130. package/lib/app/Labels.js +62 -0
  131. package/lib/app/ReactApp.d.ts +195 -0
  132. package/lib/app/ReactApp.js +296 -0
  133. package/lib/app/ServiceApp.d.ts +78 -0
  134. package/lib/app/ServiceApp.js +244 -0
  135. package/lib/index.d.ts +74 -0
  136. package/lib/index.js +74 -0
  137. package/lib/pages/CommonPage.d.ts +11 -0
  138. package/lib/pages/CommonPage.js +60 -0
  139. package/lib/pages/CommonPageProps.d.ts +59 -0
  140. package/lib/pages/CommonPageProps.js +1 -0
  141. package/lib/pages/DataGridPage.d.ts +9 -0
  142. package/lib/pages/DataGridPage.js +79 -0
  143. package/lib/pages/DataGridPageProps.d.ts +17 -0
  144. package/lib/pages/DataGridPageProps.js +1 -0
  145. package/lib/pages/EditPage.d.ts +33 -0
  146. package/lib/pages/EditPage.js +29 -0
  147. package/lib/pages/FixedListPage.d.ts +15 -0
  148. package/lib/pages/FixedListPage.js +70 -0
  149. package/lib/pages/ListPage.d.ts +9 -0
  150. package/lib/pages/ListPage.js +50 -0
  151. package/lib/pages/ListPageProps.d.ts +7 -0
  152. package/lib/pages/ListPageProps.js +1 -0
  153. package/lib/pages/ResponsivePage.d.ts +9 -0
  154. package/lib/pages/ResponsivePage.js +45 -0
  155. package/lib/pages/ResponsivePageProps.d.ts +39 -0
  156. package/lib/pages/ResponsivePageProps.js +1 -0
  157. package/lib/pages/SearchPageProps.d.ts +30 -0
  158. package/lib/pages/SearchPageProps.js +1 -0
  159. package/lib/pages/TablePage.d.ts +9 -0
  160. package/lib/pages/TablePage.js +69 -0
  161. package/lib/pages/TablePageProps.d.ts +7 -0
  162. package/lib/pages/TablePageProps.js +1 -0
  163. package/lib/pages/ViewPage.d.ts +66 -0
  164. package/lib/pages/ViewPage.js +105 -0
  165. package/lib/texts/DateText.d.ts +34 -0
  166. package/lib/texts/DateText.js +25 -0
  167. package/lib/texts/MoneyText.d.ts +21 -0
  168. package/lib/texts/MoneyText.js +14 -0
  169. package/lib/texts/NumberText.d.ts +25 -0
  170. package/lib/texts/NumberText.js +14 -0
  171. package/package.json +97 -0
  172. package/src/AuditDisplay.tsx +114 -0
  173. package/src/AutocompleteExtendedProps.ts +83 -0
  174. package/src/BackButton.tsx +55 -0
  175. package/src/BridgeCloseButton.tsx +69 -0
  176. package/src/ButtonLink.tsx +32 -0
  177. package/src/ComboBox.tsx +251 -0
  178. package/src/CountdownButton.tsx +119 -0
  179. package/src/CustomFabProps.ts +32 -0
  180. package/src/DataGridEx.tsx +713 -0
  181. package/src/DataGridRenderers.tsx +140 -0
  182. package/src/DialogButton.tsx +163 -0
  183. package/src/DnDList.tsx +344 -0
  184. package/src/DraggablePaperComponent.tsx +19 -0
  185. package/src/EmailInput.tsx +24 -0
  186. package/src/FabBox.tsx +51 -0
  187. package/src/FlexBox.tsx +20 -0
  188. package/src/GridDataFormat.tsx +77 -0
  189. package/src/IconButtonLink.tsx +29 -0
  190. package/src/InputField.tsx +82 -0
  191. package/src/ItemList.tsx +204 -0
  192. package/src/ListItemRightIcon.tsx +9 -0
  193. package/src/ListMoreDisplay.tsx +205 -0
  194. package/src/LoadingButton.tsx +75 -0
  195. package/src/MUGlobal.ts +220 -0
  196. package/src/MaskInput.tsx +107 -0
  197. package/src/MobileListItemRenderer.tsx +79 -0
  198. package/src/MoreFab.tsx +211 -0
  199. package/src/NotifierMU.tsx +654 -0
  200. package/src/NotifierPromptProps.ts +24 -0
  201. package/src/OptionGroup.tsx +223 -0
  202. package/src/PList.tsx +27 -0
  203. package/src/ProgressCount.tsx +166 -0
  204. package/src/PullToRefreshUI.tsx +21 -0
  205. package/src/RLink.tsx +64 -0
  206. package/src/ResponsibleContainer.tsx +394 -0
  207. package/src/ScrollTopFab.tsx +34 -0
  208. package/src/ScrollerListEx.tsx +387 -0
  209. package/src/SearchBar.tsx +396 -0
  210. package/src/SearchField.tsx +82 -0
  211. package/src/SearchOptionGroup.tsx +31 -0
  212. package/src/SelectBool.tsx +33 -0
  213. package/src/SelectEx.tsx +290 -0
  214. package/src/ShowDataComparison.tsx +106 -0
  215. package/src/Switch.tsx +94 -0
  216. package/src/SwitchAnt.tsx +95 -0
  217. package/src/TabBox.tsx +118 -0
  218. package/src/TableEx.tsx +558 -0
  219. package/src/TextFieldEx.tsx +249 -0
  220. package/src/Tiplist.tsx +303 -0
  221. package/src/TooltipClick.tsx +84 -0
  222. package/src/UserAvatar.tsx +64 -0
  223. package/src/UserAvatarEditor.tsx +287 -0
  224. package/src/app/CommonApp.ts +223 -0
  225. package/src/app/IServiceAppSettings.ts +13 -0
  226. package/src/app/IServicePage.ts +6 -0
  227. package/src/app/IServiceUser.ts +17 -0
  228. package/src/app/ISmartERPUser.ts +16 -0
  229. package/src/app/Labels.ts +77 -0
  230. package/src/app/ReactApp.ts +504 -0
  231. package/src/app/ServiceApp.ts +352 -0
  232. package/src/index.ts +77 -0
  233. package/src/pages/CommonPage.tsx +128 -0
  234. package/src/pages/CommonPageProps.ts +70 -0
  235. package/src/pages/DataGridPage.tsx +140 -0
  236. package/src/pages/DataGridPageProps.ts +24 -0
  237. package/src/pages/EditPage.tsx +114 -0
  238. package/src/pages/FixedListPage.tsx +141 -0
  239. package/src/pages/ListPage.tsx +90 -0
  240. package/src/pages/ListPageProps.ts +12 -0
  241. package/src/pages/ResponsivePage.tsx +68 -0
  242. package/src/pages/ResponsivePageProps.ts +57 -0
  243. package/src/pages/SearchPageProps.ts +39 -0
  244. package/src/pages/TablePage.tsx +126 -0
  245. package/src/pages/TablePageProps.ts +12 -0
  246. package/src/pages/ViewPage.tsx +282 -0
  247. package/src/texts/DateText.tsx +74 -0
  248. package/src/texts/MoneyText.tsx +49 -0
  249. package/src/texts/NumberText.tsx +40 -0
  250. package/tsconfig.json +19 -0
@@ -0,0 +1,79 @@
1
+ import { GridDataGet, useCombinedRefs, useDimensions } from '@etsoo/react';
2
+ import { Box, Stack } from '@mui/material';
3
+ import React from 'react';
4
+ import { DataGridEx } from '../DataGridEx';
5
+ import { MUGlobal } from '../MUGlobal';
6
+ import { SearchBar } from '../SearchBar';
7
+ import { CommonPage } from './CommonPage';
8
+ /**
9
+ * DataGrid page
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export function DataGridPage(props) {
14
+ var _a;
15
+ // Destruct
16
+ const { adjustHeight, fields, fieldTemplate, height, loadData, mRef, sizeReadyMiliseconds = 100, pageProps = {}, ...rest } = props;
17
+ (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
18
+ // States
19
+ const [states, setStates] = React.useReducer((currentState, newState) => {
20
+ return { ...currentState, ...newState };
21
+ }, {
22
+ height
23
+ });
24
+ const refs = useCombinedRefs(mRef, (ref) => {
25
+ if (ref == null)
26
+ return;
27
+ states.ref = ref;
28
+ //setStates({ ref });
29
+ });
30
+ // On submit callback
31
+ const onSubmit = (data, _reset) => {
32
+ setStates({ data });
33
+ };
34
+ const localLoadData = (props) => {
35
+ const data = GridDataGet(props, fieldTemplate);
36
+ return loadData(data);
37
+ };
38
+ // Watch container
39
+ const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
40
+ const rect = dimensions[0][2];
41
+ React.useEffect(() => {
42
+ if (rect != null && rect.height > 50 && height == null) {
43
+ let gridHeight = document.documentElement.clientHeight -
44
+ Math.round(rect.top + rect.height + 1);
45
+ const style = window.getComputedStyle(dimensions[0][1]);
46
+ const paddingBottom = parseFloat(style.paddingBottom);
47
+ if (!isNaN(paddingBottom))
48
+ gridHeight -= paddingBottom;
49
+ if (adjustHeight != null) {
50
+ gridHeight -= adjustHeight(gridHeight);
51
+ }
52
+ if (gridHeight !== states.height)
53
+ setStates({ height: gridHeight });
54
+ }
55
+ }, [rect]);
56
+ const list = React.useMemo(() => {
57
+ const gridHeight = states.height;
58
+ if (gridHeight == null)
59
+ return;
60
+ return (React.createElement(DataGridEx, { autoLoad: false, height: gridHeight, loadData: localLoadData, mRef: refs, outerRef: (element) => {
61
+ if (element != null)
62
+ setStates({ element });
63
+ }, ...rest }));
64
+ }, [states.height]);
65
+ const { ref, data } = states;
66
+ React.useEffect(() => {
67
+ if (ref == null || data == null)
68
+ return;
69
+ ref.reset({ data });
70
+ }, [ref, data]);
71
+ // Layout
72
+ return (React.createElement(CommonPage, { ...pageProps, scrollContainer: states.element },
73
+ React.createElement(Stack, null,
74
+ React.createElement(Box, { ref: dimensions[0][0], sx: {
75
+ paddingBottom: pageProps.paddings
76
+ } },
77
+ React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
78
+ list)));
79
+ }
@@ -0,0 +1,17 @@
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
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;
@@ -0,0 +1,29 @@
1
+ import { Button, Grid } from '@mui/material';
2
+ import React from 'react';
3
+ import { MUGlobal } from '../MUGlobal';
4
+ import { CommonPage, CommonPageScrollContainer } from './CommonPage';
5
+ import SaveIcon from '@mui/icons-material/Save';
6
+ import DeleteIcon from '@mui/icons-material/Delete';
7
+ import { BackButton } from '../BackButton';
8
+ import { Labels } from '../app/Labels';
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
+ }
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1,70 @@
1
+ import { GridDataGet, useCombinedRefs, useDimensions } from '@etsoo/react';
2
+ import { Box, Stack } from '@mui/material';
3
+ import React from 'react';
4
+ import { MUGlobal } from '../MUGlobal';
5
+ import { ScrollerListEx } from '../ScrollerListEx';
6
+ import { SearchBar } from '../SearchBar';
7
+ import { CommonPage } from './CommonPage';
8
+ /**
9
+ * Fixed height list page
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export function FixedListPage(props) {
14
+ var _a;
15
+ // Destruct
16
+ const { adjustHeight, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, ...rest } = props;
17
+ (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
18
+ // States
19
+ const [states] = React.useState({});
20
+ // Scroll container
21
+ const [scrollContainer, updateScrollContainer] = 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
+ // Watch container
45
+ const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
46
+ const rect = dimensions[0][2];
47
+ const list = React.useMemo(() => {
48
+ if (rect != null && rect.height > 50) {
49
+ let height = document.documentElement.clientHeight -
50
+ Math.round(rect.top + rect.height + 1);
51
+ if (adjustHeight != null) {
52
+ height -= adjustHeight(height);
53
+ }
54
+ return (React.createElement(Box, { id: "list-container", sx: {
55
+ height: height + 'px'
56
+ } },
57
+ React.createElement(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs, oRef: (element) => {
58
+ if (element != null)
59
+ updateScrollContainer(element);
60
+ }, ...rest })));
61
+ }
62
+ }, [rect]);
63
+ const { paddings, ...pageRest } = pageProps;
64
+ // Layout
65
+ return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer },
66
+ React.createElement(Stack, null,
67
+ React.createElement(Box, { ref: dimensions[0][0], sx: { padding: paddings } },
68
+ React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
69
+ list)));
70
+ }
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,50 @@
1
+ import { GridDataGet, useCombinedRefs } from '@etsoo/react';
2
+ import { Box, Stack } from '@mui/material';
3
+ import React from 'react';
4
+ import { MUGlobal } from '../MUGlobal';
5
+ import { ScrollerListEx } from '../ScrollerListEx';
6
+ import { SearchBar } from '../SearchBar';
7
+ import { CommonPage, CommonPageScrollContainer } from './CommonPage';
8
+ /**
9
+ * List page
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export function ListPage(props) {
14
+ var _a;
15
+ // Destruct
16
+ const { fields, fieldTemplate, loadData, mRef, pageProps = {}, ...rest } = props;
17
+ (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
18
+ // States
19
+ const [states] = React.useState({});
20
+ const refs = useCombinedRefs(mRef, (ref) => {
21
+ if (ref == null)
22
+ return;
23
+ const first = states.ref == null;
24
+ states.ref = ref;
25
+ if (first)
26
+ reset();
27
+ });
28
+ const reset = () => {
29
+ if (states.data == null || states.ref == null)
30
+ return;
31
+ states.ref.reset({ data: states.data });
32
+ };
33
+ // On submit callback
34
+ const onSubmit = (data, _reset) => {
35
+ states.data = data;
36
+ reset();
37
+ };
38
+ const localLoadData = (props) => {
39
+ const data = GridDataGet(props, fieldTemplate);
40
+ return loadData(data);
41
+ };
42
+ // Layout
43
+ return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer },
44
+ React.createElement(Stack, null,
45
+ React.createElement(Box, { sx: {
46
+ paddingBottom: pageProps.paddings
47
+ } },
48
+ React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
49
+ React.createElement(ScrollerListEx, { autoLoad: false, loadData: localLoadData, mRef: refs, ...rest }))));
50
+ }
@@ -0,0 +1,7 @@
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'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,45 @@
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
+ }
@@ -0,0 +1,39 @@
1
+ /// <reference types="react" />
2
+ import { GridMethodRef } from '@etsoo/react';
3
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
4
+ import { ListChildComponentProps } from 'react-window';
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<T> | 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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { GridJsonData, GridLoader } from '@etsoo/react';
3
+ import { DataTypes } from '@etsoo/shared';
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,69 @@
1
+ import { GridDataGet, useCombinedRefs, useDimensions } from '@etsoo/react';
2
+ import { Box, Stack } from '@mui/material';
3
+ import React from 'react';
4
+ import { MUGlobal } from '../MUGlobal';
5
+ import { SearchBar } from '../SearchBar';
6
+ import { TableEx, TableExMinWidth } from '../TableEx';
7
+ import { CommonPage, CommonPageScrollContainer } from './CommonPage';
8
+ /**
9
+ * Table page
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export function TablePage(props) {
14
+ var _a;
15
+ // Destruct
16
+ const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, ...rest } = props;
17
+ (_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
18
+ // States
19
+ const [states] = React.useState({});
20
+ const refs = useCombinedRefs(mRef, (ref) => {
21
+ if (ref == null)
22
+ return;
23
+ const first = states.ref == null;
24
+ states.ref = ref;
25
+ if (first)
26
+ reset();
27
+ });
28
+ const reset = () => {
29
+ if (states.data == null || states.ref == null)
30
+ return;
31
+ states.ref.reset({ data: states.data });
32
+ };
33
+ // On submit callback
34
+ const onSubmit = (data, _reset) => {
35
+ states.data = data;
36
+ reset();
37
+ };
38
+ const localLoadData = (props) => {
39
+ const data = GridDataGet(props, fieldTemplate);
40
+ return loadData(data);
41
+ };
42
+ // Total width
43
+ const totalWidth = React.useMemo(() => columns.reduce((previousValue, { width, minWidth }) => {
44
+ var _a;
45
+ return previousValue + ((_a = width !== null && width !== void 0 ? width : minWidth) !== null && _a !== void 0 ? _a : TableExMinWidth);
46
+ }, 0), [columns]);
47
+ // Watch container
48
+ const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
49
+ const rect = dimensions[0][2];
50
+ const list = React.useMemo(() => {
51
+ if (rect != null && rect.height > 50 && rect.width >= totalWidth) {
52
+ let maxHeight = document.documentElement.clientHeight -
53
+ (rect.top + rect.height + 1);
54
+ const style = window.getComputedStyle(dimensions[0][1]);
55
+ const paddingBottom = parseFloat(style.paddingBottom);
56
+ if (!isNaN(paddingBottom))
57
+ maxHeight -= paddingBottom;
58
+ return (React.createElement(TableEx, { autoLoad: false, columns: columns, loadData: localLoadData, maxHeight: maxHeight, mRef: refs, ...rest }));
59
+ }
60
+ }, [rect]);
61
+ // Layout
62
+ return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer },
63
+ React.createElement(Stack, null,
64
+ React.createElement(Box, { ref: dimensions[0][0], sx: {
65
+ paddingBottom: pageProps.paddings
66
+ } },
67
+ React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
68
+ list)));
69
+ }
@@ -0,0 +1,7 @@
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'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
1
+ import { GridColumnRenderProps, GridDataType } from '@etsoo/react';
2
+ import { DataTypes } from '@etsoo/shared';
3
+ import { GridProps } from '@mui/material';
4
+ import React from 'react';
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 {};