@etsoo/materialui 1.4.22 → 1.4.24

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 (93) hide show
  1. package/README.md +2 -1
  2. package/__tests__/ReactAppTests.tsx +6 -4
  3. package/babel.config.json +12 -12
  4. package/lib/AddresSelector.d.ts +8 -2
  5. package/lib/AddresSelector.js +1 -1
  6. package/lib/AuditDisplay.d.ts +1 -1
  7. package/lib/BackButton.d.ts +1 -1
  8. package/lib/BackButton.js +5 -5
  9. package/lib/CountryList.d.ts +5 -4
  10. package/lib/CountryList.js +3 -3
  11. package/lib/CustomFabProps.d.ts +3 -3
  12. package/lib/DataGridEx.js +3 -6
  13. package/lib/DataGridRenderers.d.ts +3 -3
  14. package/lib/DataGridRenderers.js +17 -17
  15. package/lib/DataTable.d.ts +1 -7
  16. package/lib/DataTable.js +3 -13
  17. package/lib/DialogButton.d.ts +2 -2
  18. package/lib/DialogButton.js +4 -4
  19. package/lib/EmailInput.d.ts +2 -2
  20. package/lib/EmailInput.js +2 -2
  21. package/lib/FlexBox.d.ts +3 -3
  22. package/lib/FlexBox.js +1 -1
  23. package/lib/GridDataFormat.d.ts +2 -2
  24. package/lib/GridDataFormat.js +7 -7
  25. package/lib/GridUtils.js +2 -1
  26. package/lib/ListItemRightIcon.d.ts +1 -1
  27. package/lib/ListItemRightIcon.js +2 -2
  28. package/lib/LoadingButton.d.ts +1 -1
  29. package/lib/LoadingButton.js +2 -2
  30. package/lib/MUGlobal.d.ts +6 -6
  31. package/lib/MUGlobal.js +20 -22
  32. package/lib/MobileListItemRenderer.d.ts +3 -3
  33. package/lib/MobileListItemRenderer.js +8 -10
  34. package/lib/PList.js +1 -1
  35. package/lib/ProgressCount.js +12 -12
  36. package/lib/RegionsRQ.d.ts +22 -0
  37. package/lib/RegionsRQ.js +1 -0
  38. package/lib/SearchField.d.ts +1 -1
  39. package/lib/SearchField.js +4 -4
  40. package/lib/SearchOptionGroup.d.ts +2 -2
  41. package/lib/SearchOptionGroup.js +3 -3
  42. package/lib/Switch.d.ts +3 -3
  43. package/lib/Switch.js +5 -5
  44. package/lib/TabBox.d.ts +5 -5
  45. package/lib/TabBox.js +5 -5
  46. package/lib/TableEx.js +4 -7
  47. package/lib/TooltipClick.d.ts +3 -3
  48. package/lib/TooltipClick.js +3 -3
  49. package/lib/TwoFieldInput.d.ts +2 -2
  50. package/lib/TwoFieldInput.js +13 -13
  51. package/lib/app/IServicePage.d.ts +1 -1
  52. package/lib/app/Labels.d.ts +1 -1
  53. package/lib/app/Labels.js +31 -31
  54. package/lib/index.d.ts +1 -0
  55. package/lib/index.js +1 -0
  56. package/lib/texts/MoneyText.d.ts +1 -1
  57. package/lib/texts/MoneyText.js +3 -3
  58. package/lib/texts/NumberText.d.ts +1 -1
  59. package/lib/texts/NumberText.js +3 -3
  60. package/package.json +20 -20
  61. package/src/AddresSelector.tsx +31 -4
  62. package/src/AuditDisplay.tsx +1 -1
  63. package/src/BackButton.tsx +39 -39
  64. package/src/CountryList.tsx +49 -48
  65. package/src/CustomFabProps.ts +19 -19
  66. package/src/DataGridEx.tsx +2 -7
  67. package/src/DataGridRenderers.tsx +119 -119
  68. package/src/DataTable.tsx +2 -31
  69. package/src/DialogButton.tsx +149 -151
  70. package/src/EmailInput.tsx +9 -11
  71. package/src/FlexBox.tsx +6 -6
  72. package/src/GridDataFormat.tsx +58 -58
  73. package/src/GridUtils.ts +2 -1
  74. package/src/ListItemRightIcon.tsx +3 -3
  75. package/src/LoadingButton.tsx +53 -53
  76. package/src/MUGlobal.ts +196 -203
  77. package/src/MobileListItemRenderer.tsx +63 -65
  78. package/src/NotifierPromptProps.ts +16 -16
  79. package/src/PList.tsx +14 -14
  80. package/src/ProgressCount.tsx +144 -148
  81. package/src/RegionsRQ.ts +26 -0
  82. package/src/SearchField.tsx +59 -59
  83. package/src/SearchOptionGroup.tsx +20 -20
  84. package/src/Switch.tsx +72 -72
  85. package/src/TabBox.tsx +87 -89
  86. package/src/TableEx.tsx +5 -8
  87. package/src/TooltipClick.tsx +62 -64
  88. package/src/TwoFieldInput.tsx +104 -104
  89. package/src/app/IServicePage.ts +1 -1
  90. package/src/app/Labels.ts +67 -67
  91. package/src/index.ts +1 -0
  92. package/src/texts/MoneyText.tsx +29 -35
  93. package/src/texts/NumberText.tsx +23 -23
package/src/MUGlobal.ts CHANGED
@@ -1,220 +1,213 @@
1
- import { NumberUtils } from '@etsoo/shared';
2
- import { Breakpoint, ListItemButtonProps, Theme } from '@mui/material';
3
- import { Link } from 'react-router-dom';
1
+ import { NumberUtils } from "@etsoo/shared";
2
+ import { Breakpoint, ListItemButtonProps, Theme } from "@mui/material";
3
+ import { Link } from "react-router-dom";
4
4
 
5
5
  /**
6
6
  * Mouse event handler with data
7
7
  */
8
8
  export type MouseEventWithDataHandler<T> = (
9
- event: React.MouseEvent<HTMLDivElement>,
10
- data: T
9
+ event: React.MouseEvent<HTMLDivElement>,
10
+ data: T
11
11
  ) => void;
12
12
 
13
13
  /**
14
14
  * MUGlobal for global configurations
15
15
  */
16
16
  export class MUGlobal {
17
- /**
18
- * Search field shrink
19
- */
20
- static searchFieldShrink: boolean = true;
21
-
22
- /**
23
- * Search field size
24
- */
25
- static searchFieldSize: 'small' | 'medium' = 'small';
26
-
27
- /**
28
- * Search field variant
29
- */
30
- static searchFieldVariant: 'standard' | 'filled' | 'outlined' = 'outlined';
31
-
32
- /**
33
- * Input field shrink
34
- */
35
- static inputFieldShrink: boolean = true;
36
-
37
- /**
38
- * Input field size
39
- */
40
- static inputFieldSize: 'small' | 'medium' = 'medium';
41
-
42
- /**
43
- * Input field variant
44
- */
45
- static inputFieldVariant: 'standard' | 'filled' | 'outlined' = 'outlined';
46
-
47
- /**
48
- * TextField variant
49
- */
50
- static textFieldVariant: 'standard' | 'filled' | 'outlined' = 'filled';
51
-
52
- /**
53
- * Page default paddings
54
- */
55
- static pagePaddings = { xs: 2, sm: 3 };
56
-
57
- /**
58
- * Get menu item props
59
- * @param path Current path
60
- * @param href Item's href
61
- * @returns Props
62
- */
63
- static getMenuItem(path: string, href: string) {
64
- let selected = false;
65
-
66
- if (path === href) {
67
- // Exact match, most common case
68
- selected = true;
69
- } else if (href.endsWith('*')) {
70
- href = href.slice(0, -1);
71
- selected = path.startsWith(href);
72
- } else if (href.endsWith('/all')) {
73
- selected = path.startsWith(href.slice(0, -3));
74
- }
75
-
76
- return {
77
- component: Link,
78
- selected,
79
- to: href,
80
- sx: {
81
- ...(selected && {
82
- '.MuiListItemIcon-root': {
83
- color: (theme) => theme.palette.primary.main
84
- }
85
- })
86
- }
87
- } as ListItemButtonProps;
88
- }
89
-
90
- /**
91
- * Update object number properties with half of it
92
- * @param input Input object
93
- * @returns Updated object
94
- */
95
- static half(input: object) {
96
- const newObj = { ...input };
97
- Object.entries(newObj).forEach(([key, value]) => {
98
- if (typeof value === 'number') {
99
- Reflect.set(newObj, key, value / 2.0);
100
- }
101
- });
102
- return newObj;
103
- }
104
-
105
- /**
106
- * Reverse object number properties, like 5 to -5
107
- * @param input Input object
108
- * @returns Updated object
109
- */
110
- static reverse(input: object) {
111
- const newObj = { ...input };
112
- Object.entries(newObj).forEach(([key, value]) => {
113
- if (typeof value === 'number') {
114
- Reflect.set(newObj, key, -value);
115
- }
116
- });
117
- return newObj;
118
- }
119
-
120
- /**
121
- * Update object number properties with adjustment
122
- * @param input Input object
123
- * @param adjust Adjust value or new size object
124
- * @param field Specific field
125
- * @returns Updated object
126
- */
127
- static increase(input: object, adjust: number | object, field?: string) {
128
- const newObj = { ...input };
129
- Object.entries(newObj).forEach(([key, value]) => {
130
- if (typeof value === 'number') {
131
- if (field == null || field === key) {
132
- const adjustValue =
133
- typeof adjust === 'number'
134
- ? adjust
135
- : Reflect.get(adjust, key);
136
- if (adjustValue == null || typeof adjustValue !== 'number')
137
- return;
138
-
139
- Reflect.set(newObj, key, value + adjustValue);
140
- }
141
- }
142
- });
143
- return newObj;
144
- }
145
-
146
- /**
147
- * Adjust size with theme update
148
- * @param size Base size
149
- * @param adjust Adjustment
150
- * @param updateFunc Theme update function
151
- * @returns Updated object
152
- */
153
- static adjustWithTheme(
154
- size: number,
155
- adjust: object,
156
- updateFunc: (value: number) => string
157
- ) {
158
- const newObj = { ...adjust };
159
- Object.entries(newObj).forEach(([key, value]) => {
160
- if (typeof value === 'number') {
161
- const newValue = NumberUtils.parseWithUnit(updateFunc(value));
162
- if (newValue != null) {
163
- Reflect.set(
164
- newObj,
165
- key,
166
- `${size - newValue[0]}${newValue[1]}`
167
- );
168
- }
169
- }
170
- });
171
- return newObj;
17
+ /**
18
+ * Search field shrink
19
+ */
20
+ static searchFieldShrink: boolean = true;
21
+
22
+ /**
23
+ * Search field size
24
+ */
25
+ static searchFieldSize: "small" | "medium" = "small";
26
+
27
+ /**
28
+ * Search field variant
29
+ */
30
+ static searchFieldVariant: "standard" | "filled" | "outlined" = "outlined";
31
+
32
+ /**
33
+ * Input field shrink
34
+ */
35
+ static inputFieldShrink: boolean = true;
36
+
37
+ /**
38
+ * Input field size
39
+ */
40
+ static inputFieldSize: "small" | "medium" = "medium";
41
+
42
+ /**
43
+ * Input field variant
44
+ */
45
+ static inputFieldVariant: "standard" | "filled" | "outlined" = "outlined";
46
+
47
+ /**
48
+ * TextField variant
49
+ */
50
+ static textFieldVariant: "standard" | "filled" | "outlined" = "filled";
51
+
52
+ /**
53
+ * Page default paddings
54
+ */
55
+ static pagePaddings = { xs: 2, sm: 3 };
56
+
57
+ /**
58
+ * Get menu item props
59
+ * @param path Current path
60
+ * @param href Item's href
61
+ * @returns Props
62
+ */
63
+ static getMenuItem(path: string, href: string) {
64
+ let selected = false;
65
+
66
+ if (path === href) {
67
+ // Exact match, most common case
68
+ selected = true;
69
+ } else if (href.endsWith("*")) {
70
+ href = href.slice(0, -1);
71
+ selected = path.startsWith(href);
72
+ } else if (href.endsWith("/all")) {
73
+ selected = path.startsWith(href.slice(0, -3));
172
74
  }
173
75
 
174
- /**
175
- * Break points defined
176
- */
177
- static breakpoints = ['xs', 'sm', 'md', 'lg', 'xl'] as const;
178
-
179
- /**
180
- * Get multple medias theme space
181
- * Responsive values and Breakpoints as an object
182
- * xs = theme.breakpoints.up('xs')
183
- * https://mui.com/system/basics/
184
- * @param spaces Spaces
185
- * @param theme Theme
186
- * @returns Result
187
- */
188
- static getSpace(spaces: object, theme: Theme) {
189
- const start = this.breakpoints.length - 1;
190
- for (let i = start; i >= 0; i--) {
191
- const key = this.breakpoints[i];
192
- const value = Reflect.get(spaces, key);
193
- if (typeof value === 'number') {
194
- const mediaRaw = theme.breakpoints.up(key as Breakpoint);
195
- const mediaQuery = mediaRaw.substring(mediaRaw.indexOf('('));
196
- if (window.matchMedia(mediaQuery).matches) {
197
- return parseInt(theme.spacing(value), 10);
198
- }
199
- }
76
+ return {
77
+ component: Link,
78
+ selected,
79
+ to: href,
80
+ sx: {
81
+ ...(selected && {
82
+ ".MuiListItemIcon-root": {
83
+ color: (theme) => theme.palette.primary.main
84
+ }
85
+ })
86
+ }
87
+ } as ListItemButtonProps;
88
+ }
89
+
90
+ /**
91
+ * Update object number properties with half of it
92
+ * @param input Input object
93
+ * @returns Updated object
94
+ */
95
+ static half(input: object) {
96
+ const newObj = { ...input };
97
+ Object.entries(newObj).forEach(([key, value]) => {
98
+ if (typeof value === "number") {
99
+ Reflect.set(newObj, key, value / 2.0);
100
+ }
101
+ });
102
+ return newObj;
103
+ }
104
+
105
+ /**
106
+ * Reverse object number properties, like 5 to -5
107
+ * @param input Input object
108
+ * @returns Updated object
109
+ */
110
+ static reverse(input: object) {
111
+ const newObj = { ...input };
112
+ Object.entries(newObj).forEach(([key, value]) => {
113
+ if (typeof value === "number") {
114
+ Reflect.set(newObj, key, -value);
115
+ }
116
+ });
117
+ return newObj;
118
+ }
119
+
120
+ /**
121
+ * Update object number properties with adjustment
122
+ * @param input Input object
123
+ * @param adjust Adjust value or new size object
124
+ * @param field Specific field
125
+ * @returns Updated object
126
+ */
127
+ static increase(input: object, adjust: number | object, field?: string) {
128
+ const newObj = { ...input };
129
+ Object.entries(newObj).forEach(([key, value]) => {
130
+ if (typeof value === "number") {
131
+ if (field == null || field === key) {
132
+ const adjustValue =
133
+ typeof adjust === "number" ? adjust : Reflect.get(adjust, key);
134
+ if (adjustValue == null || typeof adjustValue !== "number") return;
135
+
136
+ Reflect.set(newObj, key, value + adjustValue);
200
137
  }
201
-
202
- return 0;
138
+ }
139
+ });
140
+ return newObj;
141
+ }
142
+
143
+ /**
144
+ * Adjust size with theme update
145
+ * @param size Base size
146
+ * @param adjust Adjustment
147
+ * @param updateFunc Theme update function
148
+ * @returns Updated object
149
+ */
150
+ static adjustWithTheme(
151
+ size: number,
152
+ adjust: object,
153
+ updateFunc: (value: number) => string
154
+ ) {
155
+ const newObj = { ...adjust };
156
+ Object.entries(newObj).forEach(([key, value]) => {
157
+ if (typeof value === "number") {
158
+ const newValue = NumberUtils.parseWithUnit(updateFunc(value));
159
+ if (newValue != null) {
160
+ Reflect.set(newObj, key, `${size - newValue[0]}${newValue[1]}`);
161
+ }
162
+ }
163
+ });
164
+ return newObj;
165
+ }
166
+
167
+ /**
168
+ * Break points defined
169
+ */
170
+ static breakpoints = ["xs", "sm", "md", "lg", "xl"] as const;
171
+
172
+ /**
173
+ * Get multple medias theme space
174
+ * Responsive values and Breakpoints as an object
175
+ * xs = theme.breakpoints.up('xs')
176
+ * https://mui.com/system/basics/
177
+ * @param spaces Spaces
178
+ * @param theme Theme
179
+ * @returns Result
180
+ */
181
+ static getSpace(spaces: object, theme: Theme) {
182
+ const start = this.breakpoints.length - 1;
183
+ for (let i = start; i >= 0; i--) {
184
+ const key = this.breakpoints[i];
185
+ const value = Reflect.get(spaces, key);
186
+ if (typeof value === "number") {
187
+ const mediaRaw = theme.breakpoints.up(key as Breakpoint);
188
+ const mediaQuery = mediaRaw.substring(mediaRaw.indexOf("("));
189
+ if (window.matchMedia(mediaQuery).matches) {
190
+ return parseInt(theme.spacing(value), 10);
191
+ }
192
+ }
203
193
  }
204
194
 
205
- /**
206
- * Update object number properties with theme
207
- * @param input Input object
208
- * @param updateFunc Theme update function
209
- * @returns Updated object
210
- */
211
- static updateWithTheme(input: {}, updateFunc: (value: number) => string) {
212
- const newObj = { ...input };
213
- Object.entries(newObj).forEach(([key, value]) => {
214
- if (typeof value === 'number') {
215
- Reflect.set(newObj, key, updateFunc(value));
216
- }
217
- });
218
- return newObj;
219
- }
195
+ return 0;
196
+ }
197
+
198
+ /**
199
+ * Update object number properties with theme
200
+ * @param input Input object
201
+ * @param updateFunc Theme update function
202
+ * @returns Updated object
203
+ */
204
+ static updateWithTheme(input: {}, updateFunc: (value: number) => string) {
205
+ const newObj = { ...input };
206
+ Object.entries(newObj).forEach(([key, value]) => {
207
+ if (typeof value === "number") {
208
+ Reflect.set(newObj, key, updateFunc(value));
209
+ }
210
+ });
211
+ return newObj;
212
+ }
220
213
  }
@@ -1,8 +1,8 @@
1
- import { ListItemReact } from '@etsoo/react';
2
- import { Card, CardContent, CardHeader, LinearProgress } from '@mui/material';
3
- import React from 'react';
4
- import { MoreFab } from './MoreFab';
5
- import { ScrollerListExInnerItemRendererProps } from './ScrollerListEx';
1
+ import { ListItemReact } from "@etsoo/react";
2
+ import { Card, CardContent, CardHeader, LinearProgress } from "@mui/material";
3
+ import React from "react";
4
+ import { MoreFab } from "./MoreFab";
5
+ import { ScrollerListExInnerItemRendererProps } from "./ScrollerListEx";
6
6
 
7
7
  /**
8
8
  * Default mobile list item renderer
@@ -12,68 +12,66 @@ import { ScrollerListExInnerItemRendererProps } from './ScrollerListEx';
12
12
  * @returns Component
13
13
  */
14
14
  export function MobileListItemRenderer<T>(
15
- { data, itemHeight, margins }: ScrollerListExInnerItemRendererProps<T>,
16
- renderer: (
17
- data: T
18
- ) => [
19
- string,
20
- string | undefined,
21
- React.ReactNode | (ListItemReact | boolean)[],
22
- React.ReactNode,
23
- React.ReactNode?
24
- ]
15
+ { data, itemHeight, margins }: ScrollerListExInnerItemRendererProps<T>,
16
+ renderer: (
17
+ data: T
18
+ ) => [
19
+ string,
20
+ string | undefined,
21
+ React.ReactNode | (ListItemReact | boolean)[],
22
+ React.ReactNode,
23
+ React.ReactNode?
24
+ ]
25
25
  ) {
26
- // Loading
27
- if (data == null) return <LinearProgress />;
26
+ // Loading
27
+ if (data == null) return <LinearProgress />;
28
28
 
29
- // Elements
30
- const [title, subheader, actions, children, cardActions] = renderer(data);
29
+ // Elements
30
+ const [title, subheader, actions, children, cardActions] = renderer(data);
31
31
 
32
- return (
33
- <Card
34
- sx={{
35
- height: itemHeight,
36
- ...margins
37
- }}
38
- >
39
- <CardHeader
40
- sx={{ paddingBottom: 0.5 }}
41
- action={
42
- Array.isArray(actions) ? (
43
- <MoreFab
44
- iconButton
45
- size="small"
46
- anchorOrigin={{
47
- vertical: 'bottom',
48
- horizontal: 'right'
49
- }}
50
- transformOrigin={{
51
- vertical: 'top',
52
- horizontal: 'right'
53
- }}
54
- actions={actions}
55
- />
56
- ) : (
57
- actions
58
- )
59
- }
60
- title={title}
61
- titleTypographyProps={{ variant: 'body2' }}
62
- subheader={subheader}
63
- subheaderTypographyProps={{ variant: 'caption' }}
32
+ return (
33
+ <Card
34
+ sx={{
35
+ height: itemHeight,
36
+ ...margins
37
+ }}
38
+ >
39
+ <CardHeader
40
+ sx={{ paddingBottom: 0.5 }}
41
+ action={
42
+ Array.isArray(actions) ? (
43
+ <MoreFab
44
+ iconButton
45
+ size="small"
46
+ anchorOrigin={{
47
+ vertical: "bottom",
48
+ horizontal: "right"
49
+ }}
50
+ transformOrigin={{
51
+ vertical: "top",
52
+ horizontal: "right"
53
+ }}
54
+ actions={actions}
64
55
  />
65
- <CardContent
66
- sx={{
67
- paddingTop: 0,
68
- paddingBottom:
69
- cardActions == null
70
- ? Reflect.get(margins, 'marginBottom')
71
- : 0
72
- }}
73
- >
74
- {children}
75
- </CardContent>
76
- {cardActions}
77
- </Card>
78
- );
56
+ ) : (
57
+ actions
58
+ )
59
+ }
60
+ title={title}
61
+ titleTypographyProps={{ variant: "body2" }}
62
+ subheader={subheader}
63
+ subheaderTypographyProps={{ variant: "caption" }}
64
+ />
65
+ <CardContent
66
+ sx={{
67
+ paddingTop: 0,
68
+ paddingBottom:
69
+ cardActions == null ? Reflect.get(margins, "marginBottom") : 0
70
+ }}
71
+ >
72
+ {children}
73
+ </CardContent>
74
+ {cardActions}
75
+ </Card>
76
+ );
79
77
  }
@@ -2,23 +2,23 @@
2
2
  * Notifier prompt props
3
3
  */
4
4
  export type NotifierPromptProps = Record<string, any> & {
5
- /**
6
- * Cancel label
7
- */
8
- cancelLabel?: string;
5
+ /**
6
+ * Cancel label
7
+ */
8
+ cancelLabel?: string;
9
9
 
10
- /**
11
- * OK label
12
- */
13
- okLabel?: string;
10
+ /**
11
+ * OK label
12
+ */
13
+ okLabel?: string;
14
14
 
15
- /**
16
- * Multiple inputs
17
- */
18
- inputs: React.ReactNode;
15
+ /**
16
+ * Multiple inputs
17
+ */
18
+ inputs: React.ReactNode;
19
19
 
20
- /**
21
- * Single type
22
- */
23
- type?: string;
20
+ /**
21
+ * Single type
22
+ */
23
+ type?: string;
24
24
  };
package/src/PList.tsx CHANGED
@@ -1,13 +1,13 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
 
3
3
  /**
4
4
  * Paragraph items list props
5
5
  */
6
6
  export interface PListProps {
7
- /**
8
- * List items
9
- */
10
- items?: string[];
7
+ /**
8
+ * List items
9
+ */
10
+ items?: string[];
11
11
  }
12
12
 
13
13
  /**
@@ -15,13 +15,13 @@ export interface PListProps {
15
15
  * @param items Items
16
16
  */
17
17
  export function PList(props: PListProps) {
18
- const { items } = props;
19
- return (
20
- <React.Fragment>
21
- {items != null &&
22
- items.map((item, index) => {
23
- return <p key={index}>{item}</p>;
24
- })}
25
- </React.Fragment>
26
- );
18
+ const { items } = props;
19
+ return (
20
+ <React.Fragment>
21
+ {items != null &&
22
+ items.map((item, index) => {
23
+ return <p key={index}>{item}</p>;
24
+ })}
25
+ </React.Fragment>
26
+ );
27
27
  }