@etsoo/react 1.5.80 → 1.5.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +7 -2
  2. package/__tests__/ReactUtils.ts +6 -0
  3. package/lib/{mu → components}/DnDList.d.ts +1 -14
  4. package/lib/{mu → components}/DnDList.js +1 -24
  5. package/lib/components/GridMethodRef.d.ts +11 -0
  6. package/lib/{mu → components}/GridMethodRef.js +0 -0
  7. package/lib/components/ScrollerGrid.d.ts +3 -3
  8. package/lib/components/ScrollerList.d.ts +3 -3
  9. package/lib/index.d.ts +2 -74
  10. package/lib/index.js +2 -75
  11. package/lib/notifier/Notifier.d.ts +2 -3
  12. package/lib/states/UserState.d.ts +1 -1
  13. package/lib/uses/useWindowScroll.d.ts +10 -0
  14. package/lib/uses/useWindowScroll.js +46 -0
  15. package/lib/uses/useWindowSize.js +11 -5
  16. package/package.json +4 -16
  17. package/src/{mu → components}/DnDList.tsx +11 -34
  18. package/src/components/GridMethodRef.ts +12 -0
  19. package/src/components/ScrollerGrid.tsx +3 -3
  20. package/src/components/ScrollerList.tsx +5 -3
  21. package/src/index.ts +2 -78
  22. package/src/notifier/Notifier.ts +2 -3
  23. package/src/states/UserState.ts +7 -2
  24. package/src/uses/useWindowScroll.ts +60 -0
  25. package/src/uses/useWindowSize.ts +14 -5
  26. package/__tests__/mu/ComboBox.tsx +0 -30
  27. package/__tests__/mu/MUGlobalTests.tsx +0 -58
  28. package/__tests__/mu/NotifierMUTests.tsx +0 -213
  29. package/__tests__/mu/SelectEx.tsx +0 -26
  30. package/lib/app/CommonApp.d.ts +0 -39
  31. package/lib/app/CommonApp.js +0 -149
  32. package/lib/app/IServiceAppSettings.d.ts +0 -11
  33. package/lib/app/IServiceAppSettings.js +0 -1
  34. package/lib/app/IServicePage.d.ts +0 -6
  35. package/lib/app/IServicePage.js +0 -1
  36. package/lib/app/IServiceUser.d.ts +0 -14
  37. package/lib/app/IServiceUser.js +0 -1
  38. package/lib/app/ISmartERPUser.d.ts +0 -14
  39. package/lib/app/ISmartERPUser.js +0 -1
  40. package/lib/app/Labels.d.ts +0 -65
  41. package/lib/app/Labels.js +0 -62
  42. package/lib/app/ReactApp.d.ts +0 -194
  43. package/lib/app/ReactApp.js +0 -298
  44. package/lib/app/ServiceApp.d.ts +0 -78
  45. package/lib/app/ServiceApp.js +0 -244
  46. package/lib/components/ShowDataComparison.d.ts +0 -20
  47. package/lib/components/ShowDataComparison.js +0 -60
  48. package/lib/mu/AuditDisplay.d.ts +0 -33
  49. package/lib/mu/AuditDisplay.js +0 -52
  50. package/lib/mu/AutocompleteExtendedProps.d.ts +0 -64
  51. package/lib/mu/AutocompleteExtendedProps.js +0 -1
  52. package/lib/mu/BackButton.d.ts +0 -13
  53. package/lib/mu/BackButton.js +0 -33
  54. package/lib/mu/BridgeCloseButton.d.ts +0 -23
  55. package/lib/mu/BridgeCloseButton.js +0 -32
  56. package/lib/mu/ButtonLink.d.ts +0 -17
  57. package/lib/mu/ButtonLink.js +0 -19
  58. package/lib/mu/ComboBox.d.ts +0 -38
  59. package/lib/mu/ComboBox.js +0 -108
  60. package/lib/mu/CountdownButton.d.ts +0 -23
  61. package/lib/mu/CountdownButton.js +0 -81
  62. package/lib/mu/CustomFabProps.d.ts +0 -27
  63. package/lib/mu/CustomFabProps.js +0 -1
  64. package/lib/mu/DataGridEx.d.ts +0 -96
  65. package/lib/mu/DataGridEx.js +0 -331
  66. package/lib/mu/DataGridRenderers.d.ts +0 -22
  67. package/lib/mu/DataGridRenderers.js +0 -99
  68. package/lib/mu/DialogButton.d.ts +0 -54
  69. package/lib/mu/DialogButton.js +0 -45
  70. package/lib/mu/DraggablePaperComponent.d.ts +0 -8
  71. package/lib/mu/DraggablePaperComponent.js +0 -12
  72. package/lib/mu/EmailInput.d.ts +0 -11
  73. package/lib/mu/EmailInput.js +0 -15
  74. package/lib/mu/FabBox.d.ts +0 -21
  75. package/lib/mu/FabBox.js +0 -31
  76. package/lib/mu/FlexBox.d.ts +0 -14
  77. package/lib/mu/FlexBox.js +0 -18
  78. package/lib/mu/GridDataFormat.d.ts +0 -10
  79. package/lib/mu/GridDataFormat.js +0 -43
  80. package/lib/mu/GridMethodRef.d.ts +0 -11
  81. package/lib/mu/IconButtonLink.d.ts +0 -17
  82. package/lib/mu/IconButtonLink.js +0 -16
  83. package/lib/mu/InputField.d.ts +0 -21
  84. package/lib/mu/InputField.js +0 -39
  85. package/lib/mu/ItemList.d.ts +0 -56
  86. package/lib/mu/ItemList.js +0 -69
  87. package/lib/mu/ListItemRightIcon.d.ts +0 -4
  88. package/lib/mu/ListItemRightIcon.js +0 -8
  89. package/lib/mu/ListMoreDisplay.d.ts +0 -35
  90. package/lib/mu/ListMoreDisplay.js +0 -99
  91. package/lib/mu/LoadingButton.d.ts +0 -16
  92. package/lib/mu/LoadingButton.js +0 -41
  93. package/lib/mu/MUGlobal.d.ts +0 -102
  94. package/lib/mu/MUGlobal.js +0 -184
  95. package/lib/mu/MaskInput.d.ts +0 -34
  96. package/lib/mu/MaskInput.js +0 -43
  97. package/lib/mu/MobileListItemRenderer.d.ts +0 -17
  98. package/lib/mu/MobileListItemRenderer.js +0 -35
  99. package/lib/mu/MoreFab.d.ts +0 -45
  100. package/lib/mu/MoreFab.js +0 -95
  101. package/lib/mu/NotifierMU.d.ts +0 -47
  102. package/lib/mu/NotifierMU.js +0 -387
  103. package/lib/mu/NotifierPromptProps.d.ts +0 -22
  104. package/lib/mu/NotifierPromptProps.js +0 -1
  105. package/lib/mu/OptionGroup.d.ts +0 -58
  106. package/lib/mu/OptionGroup.js +0 -81
  107. package/lib/mu/PList.d.ts +0 -15
  108. package/lib/mu/PList.js +0 -12
  109. package/lib/mu/ProgressCount.d.ts +0 -44
  110. package/lib/mu/ProgressCount.js +0 -79
  111. package/lib/mu/PullToRefreshUI.d.ts +0 -9
  112. package/lib/mu/PullToRefreshUI.js +0 -18
  113. package/lib/mu/RLink.d.ts +0 -14
  114. package/lib/mu/RLink.js +0 -37
  115. package/lib/mu/ResponsibleContainer.d.ts +0 -89
  116. package/lib/mu/ResponsibleContainer.js +0 -159
  117. package/lib/mu/ScrollTopFab.d.ts +0 -7
  118. package/lib/mu/ScrollTopFab.js +0 -25
  119. package/lib/mu/ScrollerListEx.d.ts +0 -81
  120. package/lib/mu/ScrollerListEx.js +0 -167
  121. package/lib/mu/SearchBar.d.ts +0 -29
  122. package/lib/mu/SearchBar.js +0 -262
  123. package/lib/mu/SearchField.d.ts +0 -21
  124. package/lib/mu/SearchField.js +0 -39
  125. package/lib/mu/SearchOptionGroup.d.ts +0 -9
  126. package/lib/mu/SearchOptionGroup.js +0 -14
  127. package/lib/mu/SelectBool.d.ts +0 -13
  128. package/lib/mu/SelectBool.js +0 -22
  129. package/lib/mu/SelectEx.d.ts +0 -50
  130. package/lib/mu/SelectEx.js +0 -156
  131. package/lib/mu/Switch.d.ts +0 -29
  132. package/lib/mu/Switch.js +0 -34
  133. package/lib/mu/SwitchAnt.d.ts +0 -25
  134. package/lib/mu/SwitchAnt.js +0 -40
  135. package/lib/mu/TabBox.d.ts +0 -54
  136. package/lib/mu/TabBox.js +0 -31
  137. package/lib/mu/TableEx.d.ts +0 -66
  138. package/lib/mu/TableEx.js +0 -271
  139. package/lib/mu/TextFieldEx.d.ts +0 -101
  140. package/lib/mu/TextFieldEx.js +0 -127
  141. package/lib/mu/Tiplist.d.ts +0 -18
  142. package/lib/mu/Tiplist.js +0 -158
  143. package/lib/mu/TooltipClick.d.ts +0 -15
  144. package/lib/mu/TooltipClick.js +0 -40
  145. package/lib/mu/UserAvatar.d.ts +0 -24
  146. package/lib/mu/UserAvatar.js +0 -25
  147. package/lib/mu/UserAvatarEditor.d.ts +0 -53
  148. package/lib/mu/UserAvatarEditor.js +0 -129
  149. package/lib/mu/pages/CommonPage.d.ts +0 -11
  150. package/lib/mu/pages/CommonPage.js +0 -60
  151. package/lib/mu/pages/CommonPageProps.d.ts +0 -60
  152. package/lib/mu/pages/CommonPageProps.js +0 -1
  153. package/lib/mu/pages/DataGridPage.d.ts +0 -9
  154. package/lib/mu/pages/DataGridPage.js +0 -81
  155. package/lib/mu/pages/DataGridPageProps.d.ts +0 -17
  156. package/lib/mu/pages/DataGridPageProps.js +0 -1
  157. package/lib/mu/pages/EditPage.d.ts +0 -33
  158. package/lib/mu/pages/EditPage.js +0 -29
  159. package/lib/mu/pages/FixedListPage.d.ts +0 -15
  160. package/lib/mu/pages/FixedListPage.js +0 -72
  161. package/lib/mu/pages/ListPage.d.ts +0 -9
  162. package/lib/mu/pages/ListPage.js +0 -51
  163. package/lib/mu/pages/ListPageProps.d.ts +0 -7
  164. package/lib/mu/pages/ListPageProps.js +0 -1
  165. package/lib/mu/pages/ResponsivePage.d.ts +0 -9
  166. package/lib/mu/pages/ResponsivePage.js +0 -45
  167. package/lib/mu/pages/ResponsivePageProps.d.ts +0 -39
  168. package/lib/mu/pages/ResponsivePageProps.js +0 -1
  169. package/lib/mu/pages/SearchPageProps.d.ts +0 -30
  170. package/lib/mu/pages/SearchPageProps.js +0 -1
  171. package/lib/mu/pages/TablePage.d.ts +0 -9
  172. package/lib/mu/pages/TablePage.js +0 -71
  173. package/lib/mu/pages/TablePageProps.d.ts +0 -7
  174. package/lib/mu/pages/TablePageProps.js +0 -1
  175. package/lib/mu/pages/ViewPage.d.ts +0 -66
  176. package/lib/mu/pages/ViewPage.js +0 -105
  177. package/lib/mu/texts/DateText.d.ts +0 -34
  178. package/lib/mu/texts/DateText.js +0 -25
  179. package/lib/mu/texts/MoneyText.d.ts +0 -21
  180. package/lib/mu/texts/MoneyText.js +0 -14
  181. package/lib/mu/texts/NumberText.d.ts +0 -25
  182. package/lib/mu/texts/NumberText.js +0 -14
  183. package/src/app/CommonApp.ts +0 -225
  184. package/src/app/IServiceAppSettings.ts +0 -13
  185. package/src/app/IServicePage.ts +0 -6
  186. package/src/app/IServiceUser.ts +0 -17
  187. package/src/app/ISmartERPUser.ts +0 -16
  188. package/src/app/Labels.ts +0 -77
  189. package/src/app/ReactApp.ts +0 -500
  190. package/src/app/ServiceApp.ts +0 -353
  191. package/src/components/ShowDataComparison.tsx +0 -108
  192. package/src/mu/AuditDisplay.tsx +0 -117
  193. package/src/mu/AutocompleteExtendedProps.ts +0 -83
  194. package/src/mu/BackButton.tsx +0 -55
  195. package/src/mu/BridgeCloseButton.tsx +0 -69
  196. package/src/mu/ButtonLink.tsx +0 -32
  197. package/src/mu/ComboBox.tsx +0 -251
  198. package/src/mu/CountdownButton.tsx +0 -119
  199. package/src/mu/CustomFabProps.ts +0 -32
  200. package/src/mu/DataGridEx.tsx +0 -712
  201. package/src/mu/DataGridRenderers.tsx +0 -140
  202. package/src/mu/DialogButton.tsx +0 -163
  203. package/src/mu/DraggablePaperComponent.tsx +0 -19
  204. package/src/mu/EmailInput.tsx +0 -24
  205. package/src/mu/FabBox.tsx +0 -51
  206. package/src/mu/FlexBox.tsx +0 -20
  207. package/src/mu/GridDataFormat.tsx +0 -77
  208. package/src/mu/GridMethodRef.ts +0 -12
  209. package/src/mu/IconButtonLink.tsx +0 -29
  210. package/src/mu/InputField.tsx +0 -82
  211. package/src/mu/ItemList.tsx +0 -204
  212. package/src/mu/ListItemRightIcon.tsx +0 -9
  213. package/src/mu/ListMoreDisplay.tsx +0 -205
  214. package/src/mu/LoadingButton.tsx +0 -75
  215. package/src/mu/MUGlobal.ts +0 -220
  216. package/src/mu/MaskInput.tsx +0 -107
  217. package/src/mu/MobileListItemRenderer.tsx +0 -79
  218. package/src/mu/MoreFab.tsx +0 -211
  219. package/src/mu/NotifierMU.tsx +0 -654
  220. package/src/mu/NotifierPromptProps.ts +0 -26
  221. package/src/mu/OptionGroup.tsx +0 -223
  222. package/src/mu/PList.tsx +0 -27
  223. package/src/mu/ProgressCount.tsx +0 -166
  224. package/src/mu/PullToRefreshUI.tsx +0 -21
  225. package/src/mu/RLink.tsx +0 -64
  226. package/src/mu/ResponsibleContainer.tsx +0 -394
  227. package/src/mu/ScrollTopFab.tsx +0 -34
  228. package/src/mu/ScrollerListEx.tsx +0 -387
  229. package/src/mu/SearchBar.tsx +0 -398
  230. package/src/mu/SearchField.tsx +0 -82
  231. package/src/mu/SearchOptionGroup.tsx +0 -31
  232. package/src/mu/SelectBool.tsx +0 -33
  233. package/src/mu/SelectEx.tsx +0 -290
  234. package/src/mu/Switch.tsx +0 -94
  235. package/src/mu/SwitchAnt.tsx +0 -95
  236. package/src/mu/TabBox.tsx +0 -118
  237. package/src/mu/TableEx.tsx +0 -560
  238. package/src/mu/TextFieldEx.tsx +0 -250
  239. package/src/mu/Tiplist.tsx +0 -304
  240. package/src/mu/TooltipClick.tsx +0 -84
  241. package/src/mu/UserAvatar.tsx +0 -64
  242. package/src/mu/UserAvatarEditor.tsx +0 -287
  243. package/src/mu/pages/CommonPage.tsx +0 -128
  244. package/src/mu/pages/CommonPageProps.ts +0 -71
  245. package/src/mu/pages/DataGridPage.tsx +0 -137
  246. package/src/mu/pages/DataGridPageProps.ts +0 -24
  247. package/src/mu/pages/EditPage.tsx +0 -114
  248. package/src/mu/pages/FixedListPage.tsx +0 -135
  249. package/src/mu/pages/ListPage.tsx +0 -87
  250. package/src/mu/pages/ListPageProps.ts +0 -12
  251. package/src/mu/pages/ResponsivePage.tsx +0 -68
  252. package/src/mu/pages/ResponsivePageProps.ts +0 -57
  253. package/src/mu/pages/SearchPageProps.ts +0 -39
  254. package/src/mu/pages/TablePage.tsx +0 -120
  255. package/src/mu/pages/TablePageProps.ts +0 -12
  256. package/src/mu/pages/ViewPage.tsx +0 -285
  257. package/src/mu/texts/DateText.tsx +0 -74
  258. package/src/mu/texts/MoneyText.tsx +0 -49
  259. package/src/mu/texts/NumberText.tsx +0 -40
@@ -1,285 +0,0 @@
1
- import { DataTypes, Utils } from '@etsoo/shared';
2
- import {
3
- Grid,
4
- GridProps,
5
- LinearProgress,
6
- Stack,
7
- Typography
8
- } from '@mui/material';
9
- import React from 'react';
10
- import { Labels } from '../../app/Labels';
11
- import { globalApp } from '../../app/ReactApp';
12
- import {
13
- GridColumnRenderProps,
14
- GridDataType
15
- } from '../../components/GridColumn';
16
- import { GridDataFormat } from '../GridDataFormat';
17
- import { MUGlobal } from '../MUGlobal';
18
- import { PullToRefreshUI } from '../PullToRefreshUI';
19
- import { CommonPage } from './CommonPage';
20
- import { CommonPageProps } from './CommonPageProps';
21
-
22
- /**
23
- * View page display field
24
- */
25
- export interface ViewPageField<T extends object> extends GridProps {
26
- /**
27
- * Data field
28
- */
29
- data: (string & keyof T) | ((item: T) => React.ReactNode);
30
-
31
- /**
32
- * Data type
33
- */
34
- dataType?: GridDataType;
35
-
36
- /**
37
- * Label field
38
- */
39
- label?: string | (() => React.ReactNode);
40
-
41
- /**
42
- * Display as single row
43
- */
44
- singleRow?: boolean;
45
-
46
- /**
47
- * Render props
48
- */
49
- renderProps?: GridColumnRenderProps;
50
- }
51
-
52
- type ViewPageFieldType<T extends object> =
53
- | (string & keyof T)
54
- | [string & keyof T, GridDataType, GridColumnRenderProps?]
55
- | ViewPageField<T>;
56
-
57
- /**
58
- * View page props
59
- */
60
- export interface ViewPageProps<T extends DataTypes.StringRecord>
61
- extends Omit<CommonPageProps, 'children'> {
62
- /**
63
- * Actions
64
- */
65
- actions?:
66
- | React.ReactNode
67
- | ((data: T, refresh: () => PromiseLike<void>) => React.ReactNode);
68
-
69
- /**
70
- * Children
71
- */
72
- children?:
73
- | React.ReactNode
74
- | ((data: T, refresh: () => PromiseLike<void>) => React.ReactNode);
75
-
76
- /**
77
- * Fields to display
78
- */
79
- fields: ViewPageFieldType<T>[];
80
-
81
- /**
82
- * Load data
83
- */
84
- loadData: () => PromiseLike<T | undefined>;
85
-
86
- /**
87
- * Pull to refresh data
88
- */
89
- pullToRefresh?: boolean;
90
-
91
- /**
92
- * Support refresh
93
- */
94
- supportRefresh?: boolean;
95
- }
96
-
97
- function formatItemData(fieldData: unknown): string | undefined {
98
- if (fieldData == null) return undefined;
99
- if (typeof fieldData === 'string') return fieldData;
100
- if (fieldData instanceof Date) return globalApp.formatDate(fieldData, 'd');
101
- return `${fieldData}`;
102
- }
103
-
104
- function getItemField<T extends object>(
105
- field: ViewPageFieldType<T>,
106
- data: T
107
- ): [React.ReactNode, React.ReactNode, GridProps] {
108
- // Item data and label
109
- let itemData: React.ReactNode,
110
- itemLabel: React.ReactNode,
111
- gridProps: GridProps = {};
112
-
113
- let xs = 6;
114
-
115
- if (Array.isArray(field)) {
116
- const [fieldData, fieldType, renderProps] = field;
117
- itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
118
- itemLabel = globalApp.get<string>(fieldData) ?? fieldData;
119
- } else if (typeof field === 'object') {
120
- // Destruct
121
- const {
122
- data: fieldData,
123
- dataType,
124
- label: fieldLabel,
125
- renderProps,
126
- singleRow,
127
- ...rest
128
- } = field;
129
-
130
- gridProps = {
131
- ...rest,
132
- ...(singleRow && { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 })
133
- };
134
-
135
- if (singleRow === false) xs = 12;
136
-
137
- // Field data
138
- if (typeof fieldData === 'function') itemData = fieldData(data);
139
- else if (dataType == null) itemData = formatItemData(data[fieldData]);
140
- else itemData = GridDataFormat(data[fieldData], dataType, renderProps);
141
-
142
- // Field label
143
- itemLabel =
144
- typeof fieldLabel === 'function'
145
- ? fieldLabel()
146
- : globalApp.get<string>(
147
- fieldLabel ??
148
- (typeof fieldData === 'string' ? fieldData : 'noData')
149
- ) ?? fieldLabel;
150
- } else {
151
- itemData = formatItemData(data[field]);
152
- itemLabel = globalApp.get<string>(field) ?? field;
153
- }
154
-
155
- return [
156
- itemData,
157
- itemLabel,
158
- { xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
159
- ];
160
- }
161
-
162
- /**
163
- * View page
164
- * @param props Props
165
- */
166
- export function ViewPage<T extends DataTypes.StringRecord>(
167
- props: ViewPageProps<T>
168
- ) {
169
- // Destruct
170
- const {
171
- actions,
172
- children,
173
- fields,
174
- loadData,
175
- paddings = MUGlobal.pagePaddings,
176
- supportRefresh = true,
177
- fabColumnDirection = true,
178
- supportBack = true,
179
- pullToRefresh = true,
180
- ...rest
181
- } = props;
182
-
183
- // Data
184
- const [data, setData] = React.useState<T>();
185
-
186
- // Labels
187
- const labels = Labels.CommonPage;
188
-
189
- // Container
190
- const pullContainer = '#page-container';
191
-
192
- // Load data
193
- const refresh = async () => {
194
- const result = await loadData();
195
- if (result == null) return;
196
- setData(result);
197
- };
198
-
199
- return (
200
- <CommonPage
201
- paddings={paddings}
202
- onRefresh={supportRefresh ? refresh : undefined}
203
- onUpdate={supportRefresh ? undefined : refresh}
204
- {...rest}
205
- scrollContainer={globalThis}
206
- fabColumnDirection={fabColumnDirection}
207
- supportBack={supportBack}
208
- >
209
- {data == null ? (
210
- <LinearProgress />
211
- ) : (
212
- <React.Fragment>
213
- <Grid
214
- container
215
- justifyContent="left"
216
- spacing={paddings}
217
- className="ET-ViewPage"
218
- sx={{
219
- '.MuiTypography-subtitle2': {
220
- fontWeight: 'bold'
221
- }
222
- }}
223
- >
224
- {fields.map((field, index) => {
225
- // Get data
226
- const [itemData, itemLabel, gridProps] =
227
- getItemField(field, data);
228
-
229
- // Some callback function may return '' instead of undefined
230
- if (itemData == null || itemData === '')
231
- return undefined;
232
-
233
- // Layout
234
- return (
235
- <Grid item {...gridProps} key={index}>
236
- <Typography
237
- variant="caption"
238
- component="div"
239
- >
240
- {itemLabel}:
241
- </Typography>
242
- <Typography variant="subtitle2">
243
- {itemData}
244
- </Typography>
245
- </Grid>
246
- );
247
- })}
248
- </Grid>
249
- {actions != null && (
250
- <Stack
251
- className="ET-ViewPage-Actions"
252
- direction="row"
253
- width="100%"
254
- flexWrap="wrap"
255
- justifyContent="flex-end"
256
- paddingTop={paddings}
257
- paddingBottom={paddings}
258
- gap={paddings}
259
- >
260
- {Utils.getResult(actions, data, refresh)}
261
- </Stack>
262
- )}
263
- {Utils.getResult(children, data, refresh)}
264
- {pullToRefresh && (
265
- <PullToRefreshUI
266
- mainElement={pullContainer}
267
- triggerElement={pullContainer}
268
- instructionsPullToRefresh={labels.pullToRefresh}
269
- instructionsReleaseToRefresh={
270
- labels.releaseToRefresh
271
- }
272
- instructionsRefreshing={labels.refreshing}
273
- onRefresh={refresh}
274
- shouldPullToRefresh={() => {
275
- const container =
276
- document.querySelector(pullContainer);
277
- return !container?.scrollTop;
278
- }}
279
- />
280
- )}
281
- </React.Fragment>
282
- )}
283
- </CommonPage>
284
- );
285
- }
@@ -1,74 +0,0 @@
1
- import { DateUtils } from '@etsoo/shared';
2
- import { Typography, TypographyProps } from '@mui/material';
3
- import React from 'react';
4
-
5
- /**
6
- * Date text props
7
- */
8
- export interface DateTextProps extends TypographyProps {
9
- /**
10
- * Locale
11
- */
12
- locale?: string;
13
-
14
- /**
15
- * Near days to show in error color
16
- */
17
- nearDays?: number;
18
-
19
- /**
20
- * Options
21
- */
22
- options?: DateUtils.FormatOptions;
23
-
24
- /**
25
- * Time zone
26
- */
27
- timeZone?: string;
28
-
29
- /**
30
- * Value to display
31
- */
32
- value?: Date | string;
33
- }
34
-
35
- /**
36
- * Date text
37
- * @param props Props
38
- * @returns Component
39
- */
40
- export function DateText(props: DateTextProps) {
41
- // Destruct
42
- const {
43
- nearDays,
44
- locale = 'lookup',
45
- options,
46
- timeZone,
47
- value,
48
- ...rest
49
- } = props;
50
-
51
- // Format date
52
- const date = DateUtils.parse(value);
53
-
54
- // Formatted value
55
- const localValue =
56
- date == null
57
- ? undefined
58
- : DateUtils.format(value, locale, options, timeZone);
59
-
60
- if (
61
- nearDays != null &&
62
- date != null &&
63
- Math.abs(new Date().substract(date).totalDays) <= nearDays
64
- ) {
65
- rest.color = (theme) => theme.palette.error.main;
66
- }
67
-
68
- // Layout
69
- return (
70
- <Typography component="span" fontSize="inherit" {...rest}>
71
- {localValue}
72
- </Typography>
73
- );
74
- }
@@ -1,49 +0,0 @@
1
- import { NumberUtils } from '@etsoo/shared';
2
- import { Typography } from '@mui/material';
3
- import React from 'react';
4
- import { NumberTextProps } from './NumberText';
5
-
6
- /**
7
- * Money text props
8
- */
9
- export interface MoneyTextProps extends NumberTextProps {
10
- /**
11
- * Currency, USD for US dollar
12
- */
13
- currency?: string;
14
-
15
- /**
16
- * Is integer number
17
- */
18
- isInteger?: boolean;
19
- }
20
-
21
- /**
22
- * Money text
23
- * @param props Props
24
- * @returns Component
25
- */
26
- export function MoneyText(props: MoneyTextProps) {
27
- // Destruct
28
- const {
29
- currency,
30
- isInteger = false,
31
- locale,
32
- options = {},
33
- value,
34
- ...rest
35
- } = props;
36
-
37
- // Layout
38
- return (
39
- <Typography component="span" fontSize="inherit" {...rest}>
40
- {NumberUtils.formatMoney(
41
- value,
42
- currency,
43
- locale,
44
- isInteger,
45
- options
46
- )}
47
- </Typography>
48
- );
49
- }
@@ -1,40 +0,0 @@
1
- import { NumberUtils } from '@etsoo/shared';
2
- import { Typography, TypographyProps } from '@mui/material';
3
- import React from 'react';
4
-
5
- /**
6
- * Number text props
7
- */
8
- export interface NumberTextProps extends TypographyProps {
9
- /**
10
- * Locale
11
- */
12
- locale?: string | string[];
13
-
14
- /**
15
- * Options
16
- */
17
- options?: Intl.NumberFormatOptions;
18
-
19
- /**
20
- * Value
21
- */
22
- value?: number | bigint;
23
- }
24
-
25
- /**
26
- * Number text
27
- * @param props Props
28
- * @returns Component
29
- */
30
- export function NumberText(props: NumberTextProps) {
31
- // Destruct
32
- const { locale, options = {}, value, ...rest } = props;
33
-
34
- // Layout
35
- return (
36
- <Typography component="span" fontSize="inherit" {...rest}>
37
- {NumberUtils.format(value, locale, options)}
38
- </Typography>
39
- );
40
- }