@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,15 +0,0 @@
1
- import { TextField } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Email input
5
- * @param props Props
6
- */
7
- export function EmailInput(props) {
8
- var _a;
9
- // Destruct
10
- const { inputProps = {}, ...rest } = props;
11
- // Default max length
12
- (_a = inputProps.maxLength) !== null && _a !== void 0 ? _a : (inputProps.maxLength = 128);
13
- // Layout
14
- return (React.createElement(TextField, { type: "email", fullWidth: true, inputProps: inputProps, ...rest }));
15
- }
@@ -1,21 +0,0 @@
1
- /// <reference types="react" />
2
- import { BoxProps } from '@mui/material';
3
- /**
4
- * Fabs container box props
5
- */
6
- export declare type FabBoxProps = BoxProps & {
7
- /**
8
- * Item gap
9
- */
10
- itemGap?: number;
11
- /**
12
- * Flex direction, row or column
13
- */
14
- columnDirection?: boolean;
15
- };
16
- /**
17
- * Fabs container box
18
- * @param props Props
19
- * @returns Component
20
- */
21
- export declare function FabBox(props: FabBoxProps): JSX.Element;
package/lib/mu/FabBox.js DELETED
@@ -1,31 +0,0 @@
1
- import { Box, useTheme } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Fabs container box
5
- * @param props Props
6
- * @returns Component
7
- */
8
- export function FabBox(props) {
9
- // Destruct
10
- const { columnDirection, itemGap = 1, sx = {}, ...rest } = props;
11
- // Theme
12
- const theme = useTheme();
13
- const spaceGap = theme.spacing(itemGap);
14
- if (columnDirection == null)
15
- return React.createElement(React.Fragment, null);
16
- // margin
17
- const margin = columnDirection
18
- ? { marginTop: spaceGap }
19
- : { marginLeft: spaceGap };
20
- // Default style
21
- if (typeof sx === 'object') {
22
- Object.assign(sx, {
23
- position: 'fixed',
24
- display: 'flex',
25
- alignItems: 'center',
26
- flexDirection: columnDirection ? 'column' : 'row',
27
- '& > :not(style) + :not(style)': margin
28
- });
29
- }
30
- return React.createElement(Box, { sx: sx, ...rest });
31
- }
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- import { StackProps } from '@mui/material';
3
- /**
4
- * Horizonal box
5
- * @param props Props
6
- * @returns Component
7
- */
8
- export declare function HBox(props: Omit<StackProps, 'ref'>): JSX.Element;
9
- /**
10
- * Vertial box
11
- * @param props Props
12
- * @returns Component
13
- */
14
- export declare function VBox(props: Omit<StackProps, 'ref'>): JSX.Element;
package/lib/mu/FlexBox.js DELETED
@@ -1,18 +0,0 @@
1
- import { Stack } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Horizonal box
5
- * @param props Props
6
- * @returns Component
7
- */
8
- export function HBox(props) {
9
- return React.createElement(Stack, { direction: "row", width: "100%", ...props });
10
- }
11
- /**
12
- * Vertial box
13
- * @param props Props
14
- * @returns Component
15
- */
16
- export function VBox(props) {
17
- return React.createElement(Stack, { direction: "column", ...props });
18
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { GridColumnRenderProps, GridDataType } from '../components/GridColumn';
3
- /**
4
- * Grid data format
5
- * @param data Input data
6
- * @param type Data type
7
- * @param renderProps Render props
8
- * @returns Result
9
- */
10
- export declare function GridDataFormat(data: unknown, type: GridDataType, renderProps?: GridColumnRenderProps): React.ReactNode;
@@ -1,43 +0,0 @@
1
- import { DateUtils, NumberUtils } from '@etsoo/shared';
2
- import React from 'react';
3
- import { DateText } from './texts/DateText';
4
- import { GridDataType } from '../components/GridColumn';
5
- /**
6
- * Grid data format
7
- * @param data Input data
8
- * @param type Data type
9
- * @param renderProps Render props
10
- * @returns Result
11
- */
12
- export function GridDataFormat(data, type, renderProps) {
13
- // Null
14
- if (data == null)
15
- return undefined;
16
- // For date time
17
- // Conversion if necessary
18
- if (type === GridDataType.Date || type === GridDataType.DateTime) {
19
- const dateValue = data instanceof Date
20
- ? data
21
- : typeof data === 'number' || typeof data === 'string'
22
- ? new Date(data)
23
- : undefined;
24
- if (dateValue == null)
25
- return undefined;
26
- const option = type === GridDataType.DateTime ? 'ds' : 'd';
27
- const nearDays = renderProps === null || renderProps === void 0 ? void 0 : renderProps.nearDays;
28
- if (nearDays != null) {
29
- return (React.createElement(DateText, { value: dateValue, locale: renderProps === null || renderProps === void 0 ? void 0 : renderProps.culture, timeZone: renderProps === null || renderProps === void 0 ? void 0 : renderProps.timeZone, options: option, nearDays: nearDays }));
30
- }
31
- return DateUtils.format(dateValue, renderProps === null || renderProps === void 0 ? void 0 : renderProps.culture, option, renderProps === null || renderProps === void 0 ? void 0 : renderProps.timeZone);
32
- }
33
- // For numbers
34
- if (typeof data === 'number') {
35
- if (type === GridDataType.Money || type === GridDataType.IntMoney)
36
- return NumberUtils.formatMoney(data, renderProps === null || renderProps === void 0 ? void 0 : renderProps.currency, renderProps === null || renderProps === void 0 ? void 0 : renderProps.culture, type === GridDataType.IntMoney, renderProps === null || renderProps === void 0 ? void 0 : renderProps.numberFormatOptions);
37
- else
38
- return NumberUtils.format(data, renderProps === null || renderProps === void 0 ? void 0 : renderProps.culture, renderProps === null || renderProps === void 0 ? void 0 : renderProps.numberFormatOptions);
39
- }
40
- if (typeof data === 'string')
41
- return data;
42
- return `${data}`;
43
- }
@@ -1,11 +0,0 @@
1
- import { GridLoaderStates } from '../components/GridLoader';
2
- /**
3
- * Grid method ref
4
- */
5
- export interface GridMethodRef {
6
- /**
7
- * Reset
8
- * @param add Additional data
9
- */
10
- reset(add?: Partial<GridLoaderStates<unknown>>): void;
11
- }
@@ -1,17 +0,0 @@
1
- /// <reference types="react" />
2
- import { IconButtonProps } from '@mui/material';
3
- /**
4
- * IconButtonLink props
5
- */
6
- export declare type IconButtonLinkProps = Omit<IconButtonProps, 'href' | 'onClick'> & {
7
- /**
8
- * To href
9
- */
10
- href: string;
11
- };
12
- /**
13
- * IconButtonLink
14
- * @param props Props
15
- * @returns Component
16
- */
17
- export declare function IconButtonLink(props: IconButtonLinkProps): JSX.Element;
@@ -1,16 +0,0 @@
1
- import { IconButton } from '@mui/material';
2
- import React from 'react';
3
- import { useNavigate } from 'react-router-dom';
4
- /**
5
- * IconButtonLink
6
- * @param props Props
7
- * @returns Component
8
- */
9
- export function IconButtonLink(props) {
10
- // Destruct
11
- const { href, ...rest } = props;
12
- // Navigate
13
- const navigate = useNavigate();
14
- // Layout
15
- return React.createElement(IconButton, { ...rest, onClick: () => navigate(href) });
16
- }
@@ -1,21 +0,0 @@
1
- /// <reference types="react" />
2
- import { TextFieldProps } from '@mui/material';
3
- /**
4
- * Input field props
5
- */
6
- export declare type InputFieldProps = TextFieldProps & {
7
- /**
8
- * Change delay (ms) to avoid repeatly dispatch onChange
9
- */
10
- changeDelay?: number;
11
- /**
12
- * Is the field read only?
13
- */
14
- readOnly?: boolean;
15
- };
16
- /**
17
- * Input field
18
- * @param props Props
19
- * @returns Component
20
- */
21
- export declare function InputField(props: InputFieldProps): JSX.Element;
@@ -1,39 +0,0 @@
1
- import { TextField } from '@mui/material';
2
- import React from 'react';
3
- import { useDelayedExecutor } from '../uses/useDelayedExecutor';
4
- import { MUGlobal } from './MUGlobal';
5
- /**
6
- * Input field
7
- * @param props Props
8
- * @returns Component
9
- */
10
- export function InputField(props) {
11
- // Destruct
12
- const { changeDelay, InputLabelProps = {}, InputProps = {}, onChange, readOnly, size = MUGlobal.inputFieldSize, variant = MUGlobal.inputFieldVariant, ...rest } = props;
13
- // Shrink
14
- InputLabelProps.shrink = MUGlobal.searchFieldShrink;
15
- // Read only
16
- if (readOnly != null)
17
- InputProps.readOnly = readOnly;
18
- const isMounted = React.useRef(true);
19
- const delayed = onChange != null && changeDelay != null && changeDelay >= 1
20
- ? useDelayedExecutor(onChange, changeDelay)
21
- : undefined;
22
- const onChangeEx = (event) => {
23
- if (onChange == null)
24
- return;
25
- if (changeDelay == null || changeDelay < 1) {
26
- onChange(event);
27
- return;
28
- }
29
- delayed === null || delayed === void 0 ? void 0 : delayed.call(undefined, event);
30
- };
31
- React.useEffect(() => {
32
- return () => {
33
- isMounted.current = false;
34
- delayed === null || delayed === void 0 ? void 0 : delayed.clear();
35
- };
36
- }, []);
37
- // Layout
38
- return (React.createElement(TextField, { InputLabelProps: InputLabelProps, InputProps: InputProps, onChange: onChangeEx, size: size, variant: variant, ...rest }));
39
- }
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
3
- /**
4
- * Item list properties
5
- */
6
- export interface ItemListProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> {
7
- /**
8
- * Style class name
9
- */
10
- className?: string;
11
- /**
12
- * Id field name
13
- */
14
- idField?: D;
15
- /**
16
- * Label field name or callback
17
- */
18
- labelField?: L | ((item: T) => string);
19
- /**
20
- * Button icon
21
- */
22
- icon?: React.ReactNode;
23
- /**
24
- * Button color
25
- */
26
- color?: 'inherit' | 'primary' | 'secondary';
27
- /**
28
- * Close event
29
- */
30
- onClose?(item: T, changed: boolean): void;
31
- /**
32
- * Current selected language
33
- */
34
- selectedValue?: T[D];
35
- /**
36
- * Button size
37
- */
38
- size?: 'small' | 'medium' | 'large';
39
- /**
40
- * Title
41
- */
42
- title?: string;
43
- /**
44
- * Items
45
- */
46
- items: T[];
47
- /**
48
- * Button variant
49
- */
50
- variant?: 'text' | 'outlined' | 'contained';
51
- }
52
- /**
53
- * Item list component
54
- * @param props Properties
55
- */
56
- export declare function ItemList<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: ItemListProps<T, D, L>): JSX.Element;
@@ -1,69 +0,0 @@
1
- import React from 'react';
2
- import { Dialog, DialogTitle, List, ListItemText, DialogContent, Button, ListItemButton } from '@mui/material';
3
- import { DataTypes } from '@etsoo/shared';
4
- /**
5
- * Item list component
6
- * @param props Properties
7
- */
8
- export function ItemList(props) {
9
- var _a;
10
- // properties destructure
11
- const { className, color = 'primary', items, idField = 'id', labelField = 'label', icon, onClose, selectedValue, size = 'medium', title, variant = 'outlined' } = props;
12
- // Get label
13
- const getLabel = (item) => {
14
- var _a;
15
- if (typeof labelField === 'function') {
16
- return labelField(item);
17
- }
18
- else {
19
- return (_a = DataTypes.convert(item[labelField], 'string')) !== null && _a !== void 0 ? _a : '';
20
- }
21
- };
22
- // Dialog open or not state
23
- const [open, setOpen] = React.useState(false);
24
- // Default state
25
- const defaultItem = (_a = items.find((item) => item[idField] === selectedValue)) !== null && _a !== void 0 ? _a : items[0];
26
- // Current item
27
- const [currentItem, setCurrentItem] = React.useState(defaultItem);
28
- // Click handler
29
- const clickHandler = () => {
30
- // More than one language
31
- if (items.length < 2) {
32
- return;
33
- }
34
- // Open the dialog
35
- setOpen(true);
36
- };
37
- // Close handler
38
- const closeHandler = () => {
39
- if (!open)
40
- return;
41
- // Close the dialog
42
- setOpen(false);
43
- // Emit close event
44
- if (onClose) {
45
- onClose(currentItem, false);
46
- }
47
- };
48
- // Close item handler
49
- const closeItemHandler = (item) => {
50
- // Update the current item
51
- setCurrentItem(item);
52
- // Close the dialog
53
- setOpen(false);
54
- // Emit close event
55
- if (onClose) {
56
- onClose(item, true);
57
- }
58
- };
59
- return (React.createElement(React.Fragment, null,
60
- React.createElement(Button, { className: className, variant: variant, startIcon: icon, color: color, size: size, onClick: clickHandler }, getLabel(currentItem)),
61
- React.createElement(Dialog, { "aria-labelledby": "dialog-title", open: open, onClose: closeHandler },
62
- React.createElement(DialogTitle, { sx: { minWidth: '200px' }, id: "dialog-title" }, title || ''),
63
- React.createElement(DialogContent, null,
64
- React.createElement(List, null, items.map((item) => {
65
- const id = item[idField];
66
- return (React.createElement(ListItemButton, { key: id, disabled: id === currentItem[idField], onClick: () => closeItemHandler(item) },
67
- React.createElement(ListItemText, null, getLabel(item))));
68
- }))))));
69
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * List item right icon component
3
- */
4
- export declare const ListItemRightIcon: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemIconProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,8 +0,0 @@
1
- import { ListItemIcon, styled } from '@mui/material';
2
- /**
3
- * List item right icon component
4
- */
5
- export const ListItemRightIcon = styled(ListItemIcon)(({ theme }) => ({
6
- minWidth: '20px!important',
7
- paddingLeft: theme.spacing(2)
8
- }));
@@ -1,35 +0,0 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { CardProps } from '@mui/material';
3
- import React from 'react';
4
- import { GridData, GridLoader } from '../components/GridLoader';
5
- /**
6
- * ListMoreDisplay props
7
- */
8
- export interface ListMoreDisplayProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, 'children'>, GridLoader<T> {
9
- /**
10
- * Children to display the list
11
- */
12
- children: (data: T, index: number) => React.ReactNode;
13
- /**
14
- * Search field template
15
- */
16
- fieldTemplate?: F;
17
- /**
18
- * Header renderer
19
- */
20
- headerRenderer?: (reset: (data?: GridData) => void) => React.ReactNode;
21
- /**
22
- * Header title
23
- */
24
- headerTitle?: React.ReactNode;
25
- /**
26
- * More button label
27
- */
28
- moreLabel?: string;
29
- }
30
- /**
31
- * ListMoreDisplay
32
- * @param props Props
33
- * @returns Component
34
- */
35
- export declare function ListMoreDisplay<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListMoreDisplayProps<T, F>): JSX.Element;
@@ -1,99 +0,0 @@
1
- import { Card, CardActions, CardContent, CardHeader, CircularProgress } from '@mui/material';
2
- import React from 'react';
3
- import { globalApp } from '../app/ReactApp';
4
- import { GridDataGet } from '../components/GridLoader';
5
- import { LoadingButton } from './LoadingButton';
6
- /**
7
- * ListMoreDisplay
8
- * @param props Props
9
- * @returns Component
10
- */
11
- export function ListMoreDisplay(props) {
12
- // Destruct
13
- const { children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = typeof globalApp === 'undefined'
14
- ? undefined
15
- : globalApp.get('more') + '...', fieldTemplate, threshold, ...rest } = props;
16
- // Refs
17
- const refs = React.useRef({
18
- autoLoad,
19
- currentPage: 0,
20
- hasNextPage: true,
21
- isNextPageLoading: false,
22
- orderBy: defaultOrderBy,
23
- batchSize: 10,
24
- loadedItems: 0,
25
- selectedItems: []
26
- });
27
- const ref = refs.current;
28
- // States
29
- const [states, setStates] = React.useReducer((currentStates, newStates) => {
30
- return { ...currentStates, ...newStates };
31
- }, { completed: false });
32
- // Load data
33
- const loadDataLocal = async (reset = false) => {
34
- // Prevent multiple loadings
35
- if (!ref.hasNextPage || ref.isNextPageLoading)
36
- return;
37
- // Update state
38
- ref.isNextPageLoading = true;
39
- // Parameters
40
- const { currentPage, batchSize, orderBy, orderByAsc, data } = ref;
41
- const loadProps = {
42
- currentPage,
43
- batchSize,
44
- orderBy,
45
- orderByAsc,
46
- data
47
- };
48
- const mergedData = GridDataGet(loadProps, fieldTemplate);
49
- const items = await loadData(mergedData);
50
- if (items == null || ref.isMounted === false) {
51
- return;
52
- }
53
- ref.isMounted = true;
54
- const newItems = items.length;
55
- const hasNextPage = newItems >= batchSize;
56
- ref.lastLoadedItems = newItems;
57
- ref.isNextPageLoading = false;
58
- ref.hasNextPage = hasNextPage;
59
- // Next page
60
- ref.currentPage = currentPage + 1;
61
- // Update rows
62
- if (states.items == null || reset)
63
- setStates({ items, completed: !hasNextPage });
64
- else
65
- setStates({
66
- items: [...states.items, ...items],
67
- completed: !hasNextPage
68
- });
69
- };
70
- const reset = (data) => {
71
- // Update the form data
72
- ref.data = data;
73
- // Reset page number
74
- ref.isNextPageLoading = false;
75
- ref.currentPage = 0;
76
- ref.hasNextPage = true;
77
- // Load data
78
- loadDataLocal(true);
79
- };
80
- React.useEffect(() => {
81
- if (autoLoad)
82
- loadDataLocal();
83
- }, [autoLoad]);
84
- React.useEffect(() => {
85
- return () => {
86
- ref.isMounted = false;
87
- };
88
- }, []);
89
- return (React.createElement(React.Fragment, null,
90
- headerRenderer && headerRenderer(reset),
91
- React.createElement(Card, { ...rest },
92
- React.createElement(CardHeader, { title: headerTitle }),
93
- React.createElement(CardContent, { sx: {
94
- paddingTop: 0,
95
- paddingBottom: states.completed ? 0 : 'inherit'
96
- } }, states.items == null ? (React.createElement(CircularProgress, { size: 20 })) : (states.items.map((item, index) => children(item, index)))),
97
- !states.completed && (React.createElement(CardActions, { sx: { justifyContent: 'flex-end' } },
98
- React.createElement(LoadingButton, { onClick: async () => await loadDataLocal() }, moreLabel))))));
99
- }
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import { ButtonProps, CircularProgressProps } from '@mui/material';
3
- /**
4
- * Loading button props
5
- */
6
- export declare type LoadingButtonProps = ButtonProps & {
7
- /**
8
- * Loading icon props
9
- */
10
- loadingIconProps?: CircularProgressProps;
11
- };
12
- /**
13
- * Loading button
14
- * @param props Props
15
- */
16
- export declare function LoadingButton(props: LoadingButtonProps): JSX.Element;
@@ -1,41 +0,0 @@
1
- import { Button, CircularProgress } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Loading button
5
- * @param props Props
6
- */
7
- export function LoadingButton(props) {
8
- var _a;
9
- // Destruct
10
- const { endIcon, loadingIconProps = {}, onClick, ...rest } = props;
11
- // Default size
12
- (_a = loadingIconProps.size) !== null && _a !== void 0 ? _a : (loadingIconProps.size = 12);
13
- // State
14
- // https://stackoverflow.com/questions/55265255/react-usestate-hook-event-handler-using-initial-state
15
- const [loading, setLoading] = React.useState(false);
16
- // Icon
17
- const localEndIcon = loading ? (React.createElement(CircularProgress, { ...loadingIconProps })) : (endIcon);
18
- // Check if the component is mounted
19
- const isMounted = React.useRef(true);
20
- React.useEffect(() => {
21
- return () => {
22
- isMounted.current = false;
23
- };
24
- }, []);
25
- // Layout
26
- return (React.createElement(Button, { disabled: loading, endIcon: localEndIcon, onClick: async (event) => {
27
- if (onClick) {
28
- // Update state
29
- setLoading(true);
30
- // https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async
31
- // const AsyncFunction = (async () => {}).constructor;
32
- // onClick instanceof AsyncFunction
33
- await onClick(event);
34
- // Warning: Can't perform a React state update on an unmounted component
35
- // It's necessary to check the component is mounted now
36
- if (isMounted.current) {
37
- setLoading(false);
38
- }
39
- }
40
- }, ...rest }));
41
- }