@etsoo/materialui 1.3.72 → 1.3.74

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.
@@ -1,5 +1,5 @@
1
- import { ButtonProps } from '@mui/material';
2
- import React from 'react';
1
+ import { ButtonProps } from "@mui/material";
2
+ import React from "react";
3
3
  /**
4
4
  * Countdown button action
5
5
  */
@@ -9,7 +9,11 @@ export interface CountdownButtonAction {
9
9
  /**
10
10
  * Countdown button props
11
11
  */
12
- export type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabled'> & {
12
+ export type CountdownButtonProps = Omit<ButtonProps, "endIcon" | "disabled"> & {
13
+ /**
14
+ * Initial state, default 0
15
+ */
16
+ initState?: number;
13
17
  /**
14
18
  * Action, required
15
19
  */
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Button, CircularProgress } from '@mui/material';
3
- import React from 'react';
2
+ import { Button, CircularProgress } from "@mui/material";
3
+ import React from "react";
4
4
  /**
5
5
  * Countdown button
6
6
  * @param props Props
@@ -8,12 +8,12 @@ import React from 'react';
8
8
  */
9
9
  export const CountdownButton = React.forwardRef((props, ref) => {
10
10
  // Destructure
11
- const { onAction, onClick, ...rest } = props;
11
+ const { initState = 0, onAction, onClick, ...rest } = props;
12
12
  // State
13
13
  // 0 - normal
14
14
  // 1 - loading
15
- // 2 - countdown
16
- const [state, updateState] = React.useState(0);
15
+ // >= 2 - countdown seconds
16
+ const [state, updateState] = React.useState(initState);
17
17
  // Ignore seconds
18
18
  const seconds = 2;
19
19
  // Countdown length
@@ -30,8 +30,8 @@ export const CountdownButton = React.forwardRef((props, ref) => {
30
30
  else {
31
31
  const countdown = (state - seconds)
32
32
  .toString()
33
- .padStart(shared.maxLength, '0');
34
- endIcon = _jsx("span", { style: { fontSize: 'smaller' }, children: countdown });
33
+ .padStart(shared.maxLength, "0");
34
+ endIcon = _jsx("span", { style: { fontSize: "smaller" }, children: countdown });
35
35
  }
36
36
  // Disabled?
37
37
  const disabled = state > 0;
@@ -26,39 +26,39 @@ export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@
26
26
  /**
27
27
  * Change delay (ms) to avoid repeatly dispatch onChange
28
28
  */
29
- changeDelay?: number | undefined;
29
+ changeDelay?: number;
30
30
  /**
31
31
  * Change delay handler, without it onChange will be applied
32
32
  */
33
- onChangeDelay?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
33
+ onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
34
34
  /**
35
35
  * Is the field read only?
36
36
  */
37
- readOnly?: boolean | undefined;
37
+ readOnly?: boolean;
38
38
  }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
39
39
  /**
40
40
  * Change delay (ms) to avoid repeatly dispatch onChange
41
41
  */
42
- changeDelay?: number | undefined;
42
+ changeDelay?: number;
43
43
  /**
44
44
  * Change delay handler, without it onChange will be applied
45
45
  */
46
- onChangeDelay?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
46
+ onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
47
47
  /**
48
48
  * Is the field read only?
49
49
  */
50
- readOnly?: boolean | undefined;
50
+ readOnly?: boolean;
51
51
  }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
52
52
  /**
53
53
  * Change delay (ms) to avoid repeatly dispatch onChange
54
54
  */
55
- changeDelay?: number | undefined;
55
+ changeDelay?: number;
56
56
  /**
57
57
  * Change delay handler, without it onChange will be applied
58
58
  */
59
- onChangeDelay?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
59
+ onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
60
60
  /**
61
61
  * Is the field read only?
62
62
  */
63
- readOnly?: boolean | undefined;
63
+ readOnly?: boolean;
64
64
  }, "ref">) & React.RefAttributes<HTMLDivElement>>;
package/lib/MUGlobal.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ListItemButtonProps, Theme } from '@mui/material';
3
2
  /**
4
3
  * Mouse event handler with data
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * Notifier prompt props
4
3
  */
package/lib/SelectEx.js CHANGED
@@ -32,11 +32,14 @@ export function SelectEx(props) {
32
32
  }
33
33
  onItemChange(option, userAction);
34
34
  };
35
- const setOptionsAdd = (options) => {
35
+ // Local value
36
+ const v = defaultValue ?? value;
37
+ const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
38
+ const setOptionsAdd = React.useCallback((options) => {
36
39
  setOptions(options);
37
40
  if (valueSource != null)
38
41
  doItemChange(options, valueSource, false);
39
- };
42
+ }, [valueSource]);
40
43
  // When options change
41
44
  // [options] will cause infinite loop
42
45
  const propertyWay = loadData == null;
@@ -44,10 +47,7 @@ export function SelectEx(props) {
44
47
  if (options == null || !propertyWay)
45
48
  return;
46
49
  setOptionsAdd(options);
47
- }, [options, propertyWay]);
48
- // Local value
49
- const v = defaultValue ?? value;
50
- const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
50
+ }, [options, propertyWay, setOptionsAdd]);
51
51
  // Value state
52
52
  const [valueState, setValueStateBase] = React.useState(valueSource);
53
53
  const valueRef = React.useRef();
@@ -45,81 +45,81 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
45
45
  /**
46
46
  * Change delay (ms) to avoid repeatly dispatch onChange
47
47
  */
48
- changeDelay?: number | undefined;
48
+ changeDelay?: number;
49
49
  /**
50
50
  * On enter click
51
51
  */
52
- onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
52
+ onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
53
53
  /**
54
54
  * On visibility
55
55
  * @param input HTML input
56
56
  * @returns Result
57
57
  */
58
- onVisibility?: ((input: HTMLInputElement) => void | boolean | Promise<boolean>) | undefined;
58
+ onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
59
59
  /**
60
60
  * Is the field read only?
61
61
  */
62
- readOnly?: boolean | undefined;
62
+ readOnly?: boolean;
63
63
  /**
64
64
  * Show clear button
65
65
  */
66
- showClear?: boolean | undefined;
66
+ showClear?: boolean;
67
67
  /**
68
68
  * Show password button
69
69
  */
70
- showPassword?: boolean | undefined;
70
+ showPassword?: boolean;
71
71
  }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
72
72
  /**
73
73
  * Change delay (ms) to avoid repeatly dispatch onChange
74
74
  */
75
- changeDelay?: number | undefined;
75
+ changeDelay?: number;
76
76
  /**
77
77
  * On enter click
78
78
  */
79
- onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
79
+ onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
80
80
  /**
81
81
  * On visibility
82
82
  * @param input HTML input
83
83
  * @returns Result
84
84
  */
85
- onVisibility?: ((input: HTMLInputElement) => void | boolean | Promise<boolean>) | undefined;
85
+ onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
86
86
  /**
87
87
  * Is the field read only?
88
88
  */
89
- readOnly?: boolean | undefined;
89
+ readOnly?: boolean;
90
90
  /**
91
91
  * Show clear button
92
92
  */
93
- showClear?: boolean | undefined;
93
+ showClear?: boolean;
94
94
  /**
95
95
  * Show password button
96
96
  */
97
- showPassword?: boolean | undefined;
97
+ showPassword?: boolean;
98
98
  }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
99
99
  /**
100
100
  * Change delay (ms) to avoid repeatly dispatch onChange
101
101
  */
102
- changeDelay?: number | undefined;
102
+ changeDelay?: number;
103
103
  /**
104
104
  * On enter click
105
105
  */
106
- onEnter?: React.KeyboardEventHandler<HTMLDivElement> | undefined;
106
+ onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
107
107
  /**
108
108
  * On visibility
109
109
  * @param input HTML input
110
110
  * @returns Result
111
111
  */
112
- onVisibility?: ((input: HTMLInputElement) => void | boolean | Promise<boolean>) | undefined;
112
+ onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
113
113
  /**
114
114
  * Is the field read only?
115
115
  */
116
- readOnly?: boolean | undefined;
116
+ readOnly?: boolean;
117
117
  /**
118
118
  * Show clear button
119
119
  */
120
- showClear?: boolean | undefined;
120
+ showClear?: boolean;
121
121
  /**
122
122
  * Show password button
123
123
  */
124
- showPassword?: boolean | undefined;
124
+ showPassword?: boolean;
125
125
  }, "ref">) & React.RefAttributes<TextFieldExMethods>>;
@@ -22,7 +22,7 @@ export declare let globalApp: ReactAppType | null;
22
22
  * @returns Component
23
23
  */
24
24
  export declare function ReactAppStateDetector(props: IStateProps): React.FunctionComponentElement<{
25
- children?: React.ReactNode;
25
+ children?: React.ReactNode | undefined;
26
26
  }>;
27
27
  /**
28
28
  * React implemented base
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * Common drawer header
4
3
  */
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { GridJsonData, GridLoader } from "@etsoo/react";
3
2
  import type { DataTypes } from "@etsoo/shared";
4
3
  import type { CommonPageProps } from "./CommonPage";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.72",
3
+ "version": "1.3.74",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -47,16 +47,16 @@
47
47
  "dependencies": {
48
48
  "@dnd-kit/core": "^6.1.0",
49
49
  "@dnd-kit/sortable": "^8.0.0",
50
- "@emotion/css": "^11.11.2",
51
- "@emotion/react": "^11.11.4",
52
- "@emotion/styled": "^11.11.5",
50
+ "@emotion/css": "^11.13.0",
51
+ "@emotion/react": "^11.13.0",
52
+ "@emotion/styled": "^11.13.0",
53
53
  "@etsoo/appscript": "^1.4.99",
54
- "@etsoo/notificationbase": "^1.1.43",
54
+ "@etsoo/notificationbase": "^1.1.44",
55
55
  "@etsoo/react": "^1.7.57",
56
- "@etsoo/shared": "^1.2.42",
57
- "@mui/icons-material": "^5.15.19",
58
- "@mui/material": "^5.15.19",
59
- "@mui/x-data-grid": "^7.6.2",
56
+ "@etsoo/shared": "^1.2.43",
57
+ "@mui/icons-material": "^5.16.5",
58
+ "@mui/material": "^5.16.5",
59
+ "@mui/x-data-grid": "^7.11.1",
60
60
  "chart.js": "^4.4.3",
61
61
  "chartjs-plugin-datalabels": "^2.2.0",
62
62
  "eventemitter3": "^5.0.1",
@@ -70,14 +70,14 @@
70
70
  "react-imask": "7.6.1"
71
71
  },
72
72
  "devDependencies": {
73
- "@babel/cli": "^7.24.7",
74
- "@babel/core": "^7.24.7",
73
+ "@babel/cli": "^7.24.8",
74
+ "@babel/core": "^7.24.9",
75
75
  "@babel/plugin-transform-runtime": "^7.24.7",
76
- "@babel/preset-env": "^7.24.7",
76
+ "@babel/preset-env": "^7.25.0",
77
77
  "@babel/preset-react": "^7.24.7",
78
78
  "@babel/preset-typescript": "^7.24.7",
79
- "@babel/runtime-corejs3": "^7.24.7",
80
- "@testing-library/jest-dom": "^6.4.6",
79
+ "@babel/runtime-corejs3": "^7.25.0",
80
+ "@testing-library/jest-dom": "^6.4.8",
81
81
  "@testing-library/react": "^16.0.0",
82
82
  "@types/jest": "^29.5.12",
83
83
  "@types/pica": "^9.0.4",
@@ -87,10 +87,10 @@
87
87
  "@types/react-dom": "^18.3.0",
88
88
  "@types/react-input-mask": "^3.0.5",
89
89
  "@types/react-window": "^1.8.8",
90
- "@typescript-eslint/eslint-plugin": "^7.13.0",
91
- "@typescript-eslint/parser": "^7.13.0",
90
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
91
+ "@typescript-eslint/parser": "^7.17.0",
92
92
  "jest": "^29.7.0",
93
93
  "jest-environment-jsdom": "^29.7.0",
94
- "typescript": "^5.4.5"
94
+ "typescript": "^5.5.4"
95
95
  }
96
96
  }
@@ -1,21 +1,26 @@
1
- import { Button, ButtonProps, CircularProgress } from '@mui/material';
2
- import React from 'react';
1
+ import { Button, ButtonProps, CircularProgress } from "@mui/material";
2
+ import React from "react";
3
3
 
4
4
  /**
5
5
  * Countdown button action
6
6
  */
7
7
  export interface CountdownButtonAction {
8
- (): Promise<number>;
8
+ (): Promise<number>;
9
9
  }
10
10
 
11
11
  /**
12
12
  * Countdown button props
13
13
  */
14
- export type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabled'> & {
15
- /**
16
- * Action, required
17
- */
18
- onAction: CountdownButtonAction;
14
+ export type CountdownButtonProps = Omit<ButtonProps, "endIcon" | "disabled"> & {
15
+ /**
16
+ * Initial state, default 0
17
+ */
18
+ initState?: number;
19
+
20
+ /**
21
+ * Action, required
22
+ */
23
+ onAction: CountdownButtonAction;
19
24
  };
20
25
 
21
26
  /**
@@ -24,96 +29,96 @@ export type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabled'> & {
24
29
  * @returns Button
25
30
  */
26
31
  export const CountdownButton = React.forwardRef<
27
- HTMLButtonElement,
28
- CountdownButtonProps
32
+ HTMLButtonElement,
33
+ CountdownButtonProps
29
34
  >((props, ref) => {
30
- // Destructure
31
- const { onAction, onClick, ...rest } = props;
32
-
33
- // State
34
- // 0 - normal
35
- // 1 - loading
36
- // 2 - countdown
37
- const [state, updateState] = React.useState(0);
38
-
39
- // Ignore seconds
40
- const seconds = 2;
41
-
42
- // Countdown length
43
- const [shared] = React.useState({ maxLength: 0 });
44
-
45
- const isMounted = React.useRef(true);
46
-
47
- // endIcon
48
- let endIcon: React.ReactNode;
49
- if (state === 0) {
50
- endIcon = undefined;
51
- } else if (state === 1) {
52
- endIcon = <CircularProgress size={12} />;
35
+ // Destructure
36
+ const { initState = 0, onAction, onClick, ...rest } = props;
37
+
38
+ // State
39
+ // 0 - normal
40
+ // 1 - loading
41
+ // >= 2 - countdown seconds
42
+ const [state, updateState] = React.useState(initState);
43
+
44
+ // Ignore seconds
45
+ const seconds = 2;
46
+
47
+ // Countdown length
48
+ const [shared] = React.useState({ maxLength: 0 });
49
+
50
+ const isMounted = React.useRef(true);
51
+
52
+ // endIcon
53
+ let endIcon: React.ReactNode;
54
+ if (state === 0) {
55
+ endIcon = undefined;
56
+ } else if (state === 1) {
57
+ endIcon = <CircularProgress size={12} />;
58
+ } else {
59
+ const countdown = (state - seconds)
60
+ .toString()
61
+ .padStart(shared.maxLength, "0");
62
+ endIcon = <span style={{ fontSize: "smaller" }}>{countdown}</span>;
63
+ }
64
+
65
+ // Disabled?
66
+ const disabled = state > 0;
67
+
68
+ // Action
69
+ const doAction = (result: number) => {
70
+ // Seconds to wait, 120
71
+ if (result > seconds) {
72
+ // Here 122
73
+ result += seconds;
74
+ updateState(result);
75
+
76
+ // Update max length
77
+ shared.maxLength = result.toString().length;
78
+
79
+ const seed = setInterval(() => {
80
+ // Mounted?
81
+ if (!isMounted.current) return;
82
+
83
+ // Last 1 second and then complete
84
+ if (result > seconds + 1) {
85
+ result--;
86
+ updateState(result);
87
+ } else {
88
+ clearInterval(seed);
89
+ updateState(0);
90
+ }
91
+ }, 1000);
53
92
  } else {
54
- const countdown = (state - seconds)
55
- .toString()
56
- .padStart(shared.maxLength, '0');
57
- endIcon = <span style={{ fontSize: 'smaller' }}>{countdown}</span>;
93
+ updateState(0);
58
94
  }
95
+ };
59
96
 
60
- // Disabled?
61
- const disabled = state > 0;
62
-
63
- // Action
64
- const doAction = (result: number) => {
65
- // Seconds to wait, 120
66
- if (result > seconds) {
67
- // Here 122
68
- result += seconds;
69
- updateState(result);
70
-
71
- // Update max length
72
- shared.maxLength = result.toString().length;
73
-
74
- const seed = setInterval(() => {
75
- // Mounted?
76
- if (!isMounted.current) return;
77
-
78
- // Last 1 second and then complete
79
- if (result > seconds + 1) {
80
- result--;
81
- updateState(result);
82
- } else {
83
- clearInterval(seed);
84
- updateState(0);
85
- }
86
- }, 1000);
87
- } else {
88
- updateState(0);
89
- }
90
- };
97
+ // Local click
98
+ const localClick = (event: React.MouseEvent<HTMLButtonElement>) => {
99
+ // Show loading
100
+ updateState(1);
91
101
 
92
- // Local click
93
- const localClick = (event: React.MouseEvent<HTMLButtonElement>) => {
94
- // Show loading
95
- updateState(1);
102
+ // Callback
103
+ if (onClick != null) onClick(event);
96
104
 
97
- // Callback
98
- if (onClick != null) onClick(event);
105
+ // Return any countdown
106
+ onAction().then(doAction);
107
+ };
99
108
 
100
- // Return any countdown
101
- onAction().then(doAction);
109
+ React.useEffect(() => {
110
+ return () => {
111
+ isMounted.current = false;
102
112
  };
103
-
104
- React.useEffect(() => {
105
- return () => {
106
- isMounted.current = false;
107
- };
108
- }, []);
109
-
110
- return (
111
- <Button
112
- disabled={disabled}
113
- endIcon={endIcon}
114
- onClick={localClick}
115
- ref={ref}
116
- {...rest}
117
- />
118
- );
113
+ }, []);
114
+
115
+ return (
116
+ <Button
117
+ disabled={disabled}
118
+ endIcon={endIcon}
119
+ onClick={localClick}
120
+ ref={ref}
121
+ {...rest}
122
+ />
123
+ );
119
124
  });
package/src/SelectEx.tsx CHANGED
@@ -171,10 +171,20 @@ export function SelectEx<
171
171
  onItemChange(option, userAction);
172
172
  };
173
173
 
174
- const setOptionsAdd = (options: readonly T[]) => {
175
- setOptions(options);
176
- if (valueSource != null) doItemChange(options, valueSource, false);
177
- };
174
+ // Local value
175
+ const v = defaultValue ?? value;
176
+ const valueSource = React.useMemo(
177
+ () => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""),
178
+ [multiple, v]
179
+ );
180
+
181
+ const setOptionsAdd = React.useCallback(
182
+ (options: readonly T[]) => {
183
+ setOptions(options);
184
+ if (valueSource != null) doItemChange(options, valueSource, false);
185
+ },
186
+ [valueSource]
187
+ );
178
188
 
179
189
  // When options change
180
190
  // [options] will cause infinite loop
@@ -182,14 +192,7 @@ export function SelectEx<
182
192
  React.useEffect(() => {
183
193
  if (options == null || !propertyWay) return;
184
194
  setOptionsAdd(options);
185
- }, [options, propertyWay]);
186
-
187
- // Local value
188
- const v = defaultValue ?? value;
189
- const valueSource = React.useMemo(
190
- () => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""),
191
- [multiple, v]
192
- );
195
+ }, [options, propertyWay, setOptionsAdd]);
193
196
 
194
197
  // Value state
195
198
  const [valueState, setValueStateBase] = React.useState<unknown>(valueSource);