@etsoo/materialui 1.4.21 → 1.4.23

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 (92) hide show
  1. package/README.md +2 -1
  2. package/babel.config.json +12 -12
  3. package/lib/AddresSelector.d.ts +8 -2
  4. package/lib/AddresSelector.js +1 -1
  5. package/lib/AuditDisplay.d.ts +1 -1
  6. package/lib/BackButton.d.ts +1 -1
  7. package/lib/BackButton.js +5 -5
  8. package/lib/CountryList.d.ts +5 -4
  9. package/lib/CountryList.js +3 -3
  10. package/lib/CustomFabProps.d.ts +3 -3
  11. package/lib/DataGridEx.js +3 -6
  12. package/lib/DataGridRenderers.d.ts +3 -3
  13. package/lib/DataGridRenderers.js +17 -17
  14. package/lib/DataTable.d.ts +1 -7
  15. package/lib/DataTable.js +3 -13
  16. package/lib/DialogButton.d.ts +2 -2
  17. package/lib/DialogButton.js +4 -4
  18. package/lib/EmailInput.d.ts +2 -2
  19. package/lib/EmailInput.js +2 -2
  20. package/lib/FlexBox.d.ts +3 -3
  21. package/lib/FlexBox.js +1 -1
  22. package/lib/GridDataFormat.d.ts +2 -2
  23. package/lib/GridDataFormat.js +7 -7
  24. package/lib/GridUtils.js +2 -1
  25. package/lib/ListItemRightIcon.d.ts +1 -1
  26. package/lib/ListItemRightIcon.js +2 -2
  27. package/lib/LoadingButton.d.ts +1 -1
  28. package/lib/LoadingButton.js +2 -2
  29. package/lib/MUGlobal.d.ts +6 -6
  30. package/lib/MUGlobal.js +20 -22
  31. package/lib/MobileListItemRenderer.d.ts +3 -3
  32. package/lib/MobileListItemRenderer.js +8 -10
  33. package/lib/PList.js +1 -1
  34. package/lib/ProgressCount.js +12 -12
  35. package/lib/RegionsRQ.d.ts +22 -0
  36. package/lib/RegionsRQ.js +1 -0
  37. package/lib/SearchField.d.ts +1 -1
  38. package/lib/SearchField.js +4 -4
  39. package/lib/SearchOptionGroup.d.ts +2 -2
  40. package/lib/SearchOptionGroup.js +3 -3
  41. package/lib/Switch.d.ts +3 -3
  42. package/lib/Switch.js +5 -5
  43. package/lib/TabBox.d.ts +5 -5
  44. package/lib/TabBox.js +5 -5
  45. package/lib/TableEx.js +4 -7
  46. package/lib/TooltipClick.d.ts +3 -3
  47. package/lib/TooltipClick.js +3 -3
  48. package/lib/TwoFieldInput.d.ts +2 -2
  49. package/lib/TwoFieldInput.js +13 -13
  50. package/lib/app/IServicePage.d.ts +1 -1
  51. package/lib/app/Labels.d.ts +1 -1
  52. package/lib/app/Labels.js +31 -31
  53. package/lib/index.d.ts +1 -0
  54. package/lib/index.js +1 -0
  55. package/lib/texts/MoneyText.d.ts +1 -1
  56. package/lib/texts/MoneyText.js +3 -3
  57. package/lib/texts/NumberText.d.ts +1 -1
  58. package/lib/texts/NumberText.js +3 -3
  59. package/package.json +25 -25
  60. package/src/AddresSelector.tsx +31 -4
  61. package/src/AuditDisplay.tsx +1 -1
  62. package/src/BackButton.tsx +39 -39
  63. package/src/CountryList.tsx +49 -48
  64. package/src/CustomFabProps.ts +19 -19
  65. package/src/DataGridEx.tsx +2 -7
  66. package/src/DataGridRenderers.tsx +119 -119
  67. package/src/DataTable.tsx +2 -31
  68. package/src/DialogButton.tsx +149 -151
  69. package/src/EmailInput.tsx +9 -11
  70. package/src/FlexBox.tsx +6 -6
  71. package/src/GridDataFormat.tsx +58 -58
  72. package/src/GridUtils.ts +2 -1
  73. package/src/ListItemRightIcon.tsx +3 -3
  74. package/src/LoadingButton.tsx +53 -53
  75. package/src/MUGlobal.ts +196 -203
  76. package/src/MobileListItemRenderer.tsx +63 -65
  77. package/src/NotifierPromptProps.ts +16 -16
  78. package/src/PList.tsx +14 -14
  79. package/src/ProgressCount.tsx +144 -148
  80. package/src/RegionsRQ.ts +26 -0
  81. package/src/SearchField.tsx +59 -59
  82. package/src/SearchOptionGroup.tsx +20 -20
  83. package/src/Switch.tsx +72 -72
  84. package/src/TabBox.tsx +87 -89
  85. package/src/TableEx.tsx +5 -8
  86. package/src/TooltipClick.tsx +62 -64
  87. package/src/TwoFieldInput.tsx +104 -104
  88. package/src/app/IServicePage.ts +1 -1
  89. package/src/app/Labels.ts +67 -67
  90. package/src/index.ts +1 -0
  91. package/src/texts/MoneyText.tsx +29 -35
  92. package/src/texts/NumberText.tsx +23 -23
package/src/Switch.tsx CHANGED
@@ -1,31 +1,31 @@
1
- import React from 'react';
2
- import { FormControlLabel, FormControlLabelProps } from '@mui/material';
3
- import MuiCheckbox from '@mui/material/Checkbox';
4
- import MuiSwitch from '@mui/material/Switch';
1
+ import React from "react";
2
+ import { FormControlLabel, FormControlLabelProps } from "@mui/material";
3
+ import MuiCheckbox from "@mui/material/Checkbox";
4
+ import MuiSwitch from "@mui/material/Switch";
5
5
 
6
6
  /**
7
7
  * Switch props
8
8
  */
9
- export interface SwitchProps extends Omit<FormControlLabelProps, 'control'> {
10
- /**
11
- * Value, default 'on'
12
- */
13
- value?: string;
9
+ export interface SwitchProps extends Omit<FormControlLabelProps, "control"> {
10
+ /**
11
+ * Value, default 'on'
12
+ */
13
+ value?: string;
14
14
 
15
- /**
16
- * Is the field read only?
17
- */
18
- readOnly?: boolean;
15
+ /**
16
+ * Is the field read only?
17
+ */
18
+ readOnly?: boolean;
19
19
 
20
- /**
21
- * Size
22
- */
23
- size?: 'small' | 'medium';
20
+ /**
21
+ * Size
22
+ */
23
+ size?: "small" | "medium";
24
24
 
25
- /**
26
- * Display as Checkbox
27
- */
28
- checkbox?: boolean;
25
+ /**
26
+ * Display as Checkbox
27
+ */
28
+ checkbox?: boolean;
29
29
  }
30
30
 
31
31
  /**
@@ -34,61 +34,61 @@ export interface SwitchProps extends Omit<FormControlLabelProps, 'control'> {
34
34
  * @returns Component
35
35
  */
36
36
  export function Switch(props: SwitchProps) {
37
- // Destruct
38
- const {
39
- checked,
40
- defaultChecked,
41
- defaultValue,
42
- onChange,
43
- readOnly,
44
- size,
45
- checkbox = false,
46
- value = 'true',
47
- ...rest
48
- } = props;
37
+ // Destruct
38
+ const {
39
+ checked,
40
+ defaultChecked,
41
+ defaultValue,
42
+ onChange,
43
+ readOnly,
44
+ size,
45
+ checkbox = false,
46
+ value = "true",
47
+ ...rest
48
+ } = props;
49
49
 
50
- // Checked state
51
- const [controlChecked, setControlChecked] = React.useState(
52
- checked ?? defaultChecked ?? defaultValue == value
53
- );
50
+ // Checked state
51
+ const [controlChecked, setControlChecked] = React.useState(
52
+ checked ?? defaultChecked ?? defaultValue == value
53
+ );
54
54
 
55
- React.useEffect(() => {
56
- if (checked) setControlChecked(checked);
57
- }, [checked]);
55
+ React.useEffect(() => {
56
+ if (checked) setControlChecked(checked);
57
+ }, [checked]);
58
58
 
59
- // Handle change
60
- const handleChange = (
61
- event: React.ChangeEvent<HTMLInputElement>,
62
- checked: boolean
63
- ) => {
64
- if (onChange) onChange(event, checked);
65
- setControlChecked(checked);
66
- };
59
+ // Handle change
60
+ const handleChange = (
61
+ event: React.ChangeEvent<HTMLInputElement>,
62
+ checked: boolean
63
+ ) => {
64
+ if (onChange) onChange(event, checked);
65
+ setControlChecked(checked);
66
+ };
67
67
 
68
- // Control
69
- const control = checkbox ? (
70
- <MuiCheckbox
71
- readOnly={readOnly}
72
- checked={controlChecked}
73
- onChange={handleChange}
74
- size={size}
75
- value={value}
76
- />
77
- ) : (
78
- <MuiSwitch
79
- readOnly={readOnly}
80
- checked={controlChecked}
81
- onChange={handleChange}
82
- size={size}
83
- value={value}
84
- />
85
- );
68
+ // Control
69
+ const control = checkbox ? (
70
+ <MuiCheckbox
71
+ readOnly={readOnly}
72
+ checked={controlChecked}
73
+ onChange={handleChange}
74
+ size={size}
75
+ value={value}
76
+ />
77
+ ) : (
78
+ <MuiSwitch
79
+ readOnly={readOnly}
80
+ checked={controlChecked}
81
+ onChange={handleChange}
82
+ size={size}
83
+ value={value}
84
+ />
85
+ );
86
86
 
87
- // Default state
88
- React.useEffect(() => {
89
- setControlChecked(controlChecked);
90
- }, [controlChecked]);
87
+ // Default state
88
+ React.useEffect(() => {
89
+ setControlChecked(controlChecked);
90
+ }, [controlChecked]);
91
91
 
92
- // Layout
93
- return <FormControlLabel control={control} {...rest} />;
92
+ // Layout
93
+ return <FormControlLabel control={control} {...rest} />;
94
94
  }
package/src/TabBox.tsx CHANGED
@@ -1,61 +1,61 @@
1
- import { Utils } from '@etsoo/shared';
2
- import { Box, BoxProps, Tab, TabProps, Tabs, TabsProps } from '@mui/material';
3
- import React from 'react';
4
- import { Link } from 'react-router-dom';
1
+ import { Utils } from "@etsoo/shared";
2
+ import { Box, BoxProps, Tab, TabProps, Tabs, TabsProps } from "@mui/material";
3
+ import React from "react";
4
+ import { Link } from "react-router-dom";
5
5
 
6
6
  /**
7
7
  * Tab with box panel props
8
8
  */
9
- export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
10
- /**
11
- * Children
12
- */
13
- children?: ((visible: boolean) => React.ReactNode) | React.ReactNode;
9
+ export interface TabBoxPanel extends Omit<TabProps, "value" | "children"> {
10
+ /**
11
+ * Children
12
+ */
13
+ children?: ((visible: boolean) => React.ReactNode) | React.ReactNode;
14
14
 
15
- /**
16
- * Panel box props
17
- */
18
- panel?: Omit<BoxProps, 'hidden'>;
15
+ /**
16
+ * Panel box props
17
+ */
18
+ panel?: Omit<BoxProps, "hidden">;
19
19
 
20
- /**
21
- * To URL
22
- */
23
- to?: string;
20
+ /**
21
+ * To URL
22
+ */
23
+ to?: string;
24
24
  }
25
25
 
26
26
  /**
27
27
  * Tabs with box props
28
28
  */
29
29
  export interface TabBoxPros extends BoxProps {
30
- /**
31
- * Container props
32
- */
33
- container?: Omit<TabsProps, 'value'>;
30
+ /**
31
+ * Container props
32
+ */
33
+ container?: Omit<TabsProps, "value">;
34
34
 
35
- /**
36
- * Default selected index
37
- */
38
- defaultIndex?: number;
35
+ /**
36
+ * Default selected index
37
+ */
38
+ defaultIndex?: number;
39
39
 
40
- /**
41
- * Current index
42
- */
43
- index?: number;
40
+ /**
41
+ * Current index
42
+ */
43
+ index?: number;
44
44
 
45
- /**
46
- * Add a hidden input and its name
47
- */
48
- inputName?: string;
45
+ /**
46
+ * Add a hidden input and its name
47
+ */
48
+ inputName?: string;
49
49
 
50
- /**
51
- * Root props
52
- */
53
- root?: BoxProps;
50
+ /**
51
+ * Root props
52
+ */
53
+ root?: BoxProps;
54
54
 
55
- /**
56
- * Tabs
57
- */
58
- tabs: TabBoxPanel[];
55
+ /**
56
+ * Tabs
57
+ */
58
+ tabs: TabBoxPanel[];
59
59
  }
60
60
 
61
61
  /**
@@ -64,55 +64,53 @@ export interface TabBoxPros extends BoxProps {
64
64
  * @returns Component
65
65
  */
66
66
  export function TabBox(props: TabBoxPros) {
67
- // Destruct
68
- const {
69
- index,
70
- inputName,
71
- root,
72
- container = {},
73
- defaultIndex = 0,
74
- tabs
75
- } = props;
76
- const { onChange, ...rest } = container;
67
+ // Destruct
68
+ const {
69
+ index,
70
+ inputName,
71
+ root,
72
+ container = {},
73
+ defaultIndex = 0,
74
+ tabs
75
+ } = props;
76
+ const { onChange, ...rest } = container;
77
77
 
78
- // State
79
- const [value, setValue] = React.useState(defaultIndex);
78
+ // State
79
+ const [value, setValue] = React.useState(defaultIndex);
80
80
 
81
- React.useEffect(() => {
82
- if (index == null) return;
83
- setValue(index);
84
- }, [index]);
81
+ React.useEffect(() => {
82
+ if (index == null) return;
83
+ setValue(index);
84
+ }, [index]);
85
85
 
86
- // Layout
87
- return (
88
- <React.Fragment>
89
- {inputName && (
90
- <input type="hidden" name={inputName} value={value} />
91
- )}
92
- <Box {...root}>
93
- <Tabs
94
- value={value}
95
- onChange={(event, newValue) => {
96
- setValue(newValue);
97
- if (onChange) onChange(event, newValue);
98
- }}
99
- {...rest}
100
- >
101
- {tabs.map(({ children, panel, ...tabRest }, index) => (
102
- <Tab
103
- key={index}
104
- value={index}
105
- LinkComponent={tabRest.to ? Link : undefined}
106
- {...tabRest}
107
- />
108
- ))}
109
- </Tabs>
110
- </Box>
111
- {tabs.map(({ children, panel }, index) => (
112
- <Box key={index} hidden={value !== index} {...panel}>
113
- {Utils.getResult(children, value === index)}
114
- </Box>
115
- ))}
116
- </React.Fragment>
117
- );
86
+ // Layout
87
+ return (
88
+ <React.Fragment>
89
+ {inputName && <input type="hidden" name={inputName} value={value} />}
90
+ <Box {...root}>
91
+ <Tabs
92
+ value={value}
93
+ onChange={(event, newValue) => {
94
+ setValue(newValue);
95
+ if (onChange) onChange(event, newValue);
96
+ }}
97
+ {...rest}
98
+ >
99
+ {tabs.map(({ children, panel, ...tabRest }, index) => (
100
+ <Tab
101
+ key={index}
102
+ value={index}
103
+ LinkComponent={tabRest.to ? Link : undefined}
104
+ {...tabRest}
105
+ />
106
+ ))}
107
+ </Tabs>
108
+ </Box>
109
+ {tabs.map(({ children, panel }, index) => (
110
+ <Box key={index} hidden={value !== index} {...panel}>
111
+ {Utils.getResult(children, value === index)}
112
+ </Box>
113
+ ))}
114
+ </React.Fragment>
115
+ );
118
116
  }
package/src/TableEx.tsx CHANGED
@@ -149,16 +149,11 @@ export function TableEx<
149
149
  updateRows(rows);
150
150
  };
151
151
 
152
- var orderByAsc = defaultOrderBy
153
- ? columns.find((column) => column.field === defaultOrderBy)?.sortAsc
154
- : undefined;
155
-
156
152
  // States
157
153
  const stateRefs = React.useRef<GridLoaderStates<T>>({
158
154
  queryPaging: {
159
155
  currentPage: 0,
160
156
  orderBy: defaultOrderBy,
161
- orderByAsc,
162
157
  batchSize: rowsPerPageLocal
163
158
  },
164
159
  autoLoad,
@@ -311,7 +306,7 @@ export function TableEx<
311
306
 
312
307
  // New sort
313
308
  const handleSort = (field: string, asc?: boolean) => {
314
- reset({ queryPaging: { orderBy: field, orderByAsc: asc } });
309
+ reset({ queryPaging: { orderBy: { [field]: asc ?? true } } });
315
310
  };
316
311
 
317
312
  // Set items for rerenderer
@@ -330,7 +325,7 @@ export function TableEx<
330
325
  selectedItems
331
326
  } = state;
332
327
 
333
- const currentPage = queryPaging.currentPage;
328
+ const currentPage = queryPaging.currentPage ?? 0;
334
329
  const batchSize = queryPaging.batchSize;
335
330
 
336
331
  // Current page selected items
@@ -405,7 +400,9 @@ export function TableEx<
405
400
  // Sortable
406
401
  let sortLabel: React.ReactNode;
407
402
  if (sortable && field != null) {
408
- const active = queryPaging.orderBy === field;
403
+ const active =
404
+ queryPaging.orderBy != null &&
405
+ queryPaging.orderBy[field] != null;
409
406
 
410
407
  sortLabel = (
411
408
  <TableSortLabel
@@ -1,20 +1,20 @@
1
- import { useDelayedExecutor } from '@etsoo/react';
2
- import { ClickAwayListener, Tooltip, TooltipProps } from '@mui/material';
3
- import React from 'react';
1
+ import { useDelayedExecutor } from "@etsoo/react";
2
+ import { ClickAwayListener, Tooltip, TooltipProps } from "@mui/material";
3
+ import React from "react";
4
4
 
5
5
  /**
6
6
  * Tooltip with click visibility props
7
7
  */
8
8
  export interface TooltipClickProps
9
- extends Omit<
10
- TooltipProps,
11
- 'children' | 'open' | 'disableFocusListener' | 'disableTouchListener'
12
- > {
13
- children: (
14
- openTooltip: (newTitle?: string) => void
15
- ) => React.ReactElement<any, any>;
9
+ extends Omit<
10
+ TooltipProps,
11
+ "children" | "open" | "disableFocusListener" | "disableTouchListener"
12
+ > {
13
+ children: (
14
+ openTooltip: (newTitle?: string) => void
15
+ ) => React.ReactElement<any, any>;
16
16
 
17
- disableHoverListener?: boolean;
17
+ disableHoverListener?: boolean;
18
18
  }
19
19
 
20
20
  /**
@@ -23,62 +23,60 @@ export interface TooltipClickProps
23
23
  * @returns Component
24
24
  */
25
25
  export function TooltipClick(props: TooltipClickProps) {
26
- // Destruct
27
- // leaveDelay set to 5 seconds to hide the tooltip automatically
28
- const {
29
- children,
30
- disableHoverListener = true,
31
- leaveDelay = 5000,
32
- onClose,
33
- title,
34
- ...rest
35
- } = props;
26
+ // Destruct
27
+ // leaveDelay set to 5 seconds to hide the tooltip automatically
28
+ const {
29
+ children,
30
+ disableHoverListener = true,
31
+ leaveDelay = 5000,
32
+ onClose,
33
+ title,
34
+ ...rest
35
+ } = props;
36
36
 
37
- // State
38
- const [localTitle, setTitle] = React.useState(title);
39
- const [open, setOpen] = React.useState(false);
37
+ // State
38
+ const [localTitle, setTitle] = React.useState(title);
39
+ const [open, setOpen] = React.useState(false);
40
40
 
41
- const delayed =
42
- leaveDelay > 0
43
- ? useDelayedExecutor(() => setOpen(false), leaveDelay)
44
- : undefined;
41
+ const delayed =
42
+ leaveDelay > 0
43
+ ? useDelayedExecutor(() => setOpen(false), leaveDelay)
44
+ : undefined;
45
45
 
46
- // Callback for open the tooltip
47
- const openTooltip = (newTitle?: string) => {
48
- setOpen(true);
49
- if (newTitle) setTitle(newTitle);
50
- delayed?.call();
51
- };
46
+ // Callback for open the tooltip
47
+ const openTooltip = (newTitle?: string) => {
48
+ setOpen(true);
49
+ if (newTitle) setTitle(newTitle);
50
+ delayed?.call();
51
+ };
52
52
 
53
- React.useEffect(() => {
54
- return () => {
55
- delayed?.clear();
56
- };
57
- }, []);
53
+ React.useEffect(() => {
54
+ return () => {
55
+ delayed?.clear();
56
+ };
57
+ }, []);
58
58
 
59
- // Layout
60
- return (
61
- <ClickAwayListener onClickAway={() => setOpen(false)}>
62
- <Tooltip
63
- PopperProps={{
64
- disablePortal: true
65
- }}
66
- onClose={(event) => {
67
- setOpen(false);
68
- if (onClose) onClose(event);
69
- }}
70
- title={localTitle}
71
- open={open}
72
- disableFocusListener
73
- disableTouchListener
74
- disableHoverListener={disableHoverListener}
75
- onMouseOver={
76
- disableHoverListener ? undefined : () => setOpen(true)
77
- }
78
- {...rest}
79
- >
80
- {children(openTooltip)}
81
- </Tooltip>
82
- </ClickAwayListener>
83
- );
59
+ // Layout
60
+ return (
61
+ <ClickAwayListener onClickAway={() => setOpen(false)}>
62
+ <Tooltip
63
+ PopperProps={{
64
+ disablePortal: true
65
+ }}
66
+ onClose={(event) => {
67
+ setOpen(false);
68
+ if (onClose) onClose(event);
69
+ }}
70
+ title={localTitle}
71
+ open={open}
72
+ disableFocusListener
73
+ disableTouchListener
74
+ disableHoverListener={disableHoverListener}
75
+ onMouseOver={disableHoverListener ? undefined : () => setOpen(true)}
76
+ {...rest}
77
+ >
78
+ {children(openTooltip)}
79
+ </Tooltip>
80
+ </ClickAwayListener>
81
+ );
84
82
  }