@etsoo/materialui 1.5.84 → 1.5.86
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.
- package/lib/cjs/CountdownButton.d.ts +1 -2
- package/lib/cjs/CountdownButton.js +4 -4
- package/lib/cjs/EmailInput.d.ts +2 -2
- package/lib/cjs/EmailInput.js +2 -5
- package/lib/cjs/InputField.d.ts +1 -52
- package/lib/cjs/InputField.js +5 -5
- package/lib/cjs/InputTipField.d.ts +40 -20
- package/lib/cjs/InputTipField.js +13 -2
- package/lib/cjs/IntInputField.d.ts +1 -1
- package/lib/cjs/IntInputField.js +9 -12
- package/lib/cjs/MobileInput.d.ts +2 -2
- package/lib/cjs/MobileInput.js +2 -5
- package/lib/cjs/MoneyInputField.d.ts +1 -2
- package/lib/cjs/MoneyInputField.js +4 -8
- package/lib/cjs/PhoneInput.d.ts +2 -2
- package/lib/cjs/PhoneInput.js +2 -5
- package/lib/cjs/TextFieldEx.d.ts +5 -106
- package/lib/cjs/TextFieldEx.js +27 -18
- package/lib/mjs/CountdownButton.d.ts +1 -2
- package/lib/mjs/CountdownButton.js +3 -3
- package/lib/mjs/EmailInput.d.ts +2 -2
- package/lib/mjs/EmailInput.js +2 -2
- package/lib/mjs/InputField.d.ts +1 -52
- package/lib/mjs/InputField.js +4 -4
- package/lib/mjs/InputTipField.d.ts +40 -20
- package/lib/mjs/InputTipField.js +13 -2
- package/lib/mjs/IntInputField.d.ts +1 -1
- package/lib/mjs/IntInputField.js +8 -11
- package/lib/mjs/MobileInput.d.ts +2 -2
- package/lib/mjs/MobileInput.js +2 -2
- package/lib/mjs/MoneyInputField.d.ts +1 -2
- package/lib/mjs/MoneyInputField.js +3 -4
- package/lib/mjs/PhoneInput.d.ts +2 -2
- package/lib/mjs/PhoneInput.js +2 -2
- package/lib/mjs/TextFieldEx.d.ts +5 -106
- package/lib/mjs/TextFieldEx.js +26 -17
- package/package.json +8 -8
- package/src/CountdownButton.tsx +2 -6
- package/src/EmailInput.tsx +3 -3
- package/src/InputField.tsx +69 -74
- package/src/InputTipField.tsx +49 -14
- package/src/IntInputField.tsx +14 -22
- package/src/MobileInput.tsx +3 -3
- package/src/MoneyInputField.tsx +3 -7
- package/src/PhoneInput.tsx +3 -3
- package/src/TextFieldEx.tsx +33 -20
package/lib/mjs/TextFieldEx.js
CHANGED
|
@@ -9,13 +9,15 @@ import { useAppContext } from "./app/ReactApp";
|
|
|
9
9
|
import TextField from "@mui/material/TextField";
|
|
10
10
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
11
11
|
import IconButton from "@mui/material/IconButton";
|
|
12
|
-
export
|
|
12
|
+
export function TextFieldEx(props) {
|
|
13
13
|
// Global app
|
|
14
14
|
const app = useAppContext();
|
|
15
15
|
// Labels
|
|
16
16
|
const { showIt, clearInput } = app?.getLabels("showIt", "clearInput") ?? {};
|
|
17
17
|
// Destructure
|
|
18
|
-
const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, ...rest } = props;
|
|
18
|
+
const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, slotProps, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, mRef, ...rest } = props;
|
|
19
|
+
// Slot props
|
|
20
|
+
const { input, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
19
21
|
// Shrink
|
|
20
22
|
InputLabelProps.shrink ??= MUGlobal.searchFieldShrink;
|
|
21
23
|
// State
|
|
@@ -32,18 +34,18 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
|
32
34
|
helperTextEx = errorText;
|
|
33
35
|
}
|
|
34
36
|
let typeEx = showPassword ? "password" : type;
|
|
35
|
-
let
|
|
37
|
+
let inputEle;
|
|
36
38
|
const localRef = (ref) => {
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
+
inputEle = ref;
|
|
40
|
+
if (inputEle.value !== "") {
|
|
39
41
|
updateEmpty(false);
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
const doClear = () => {
|
|
43
|
-
if (
|
|
45
|
+
if (inputEle == null)
|
|
44
46
|
return;
|
|
45
|
-
ReactUtils.triggerChange(
|
|
46
|
-
|
|
47
|
+
ReactUtils.triggerChange(inputEle, "", false);
|
|
48
|
+
inputEle.focus();
|
|
47
49
|
};
|
|
48
50
|
const clearClick = () => {
|
|
49
51
|
if (onClear) {
|
|
@@ -62,23 +64,23 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
|
62
64
|
};
|
|
63
65
|
const touchStart = async (e) => {
|
|
64
66
|
// Show the password
|
|
65
|
-
if (
|
|
67
|
+
if (inputEle) {
|
|
66
68
|
if (onVisibility) {
|
|
67
|
-
const result = await onVisibility(
|
|
69
|
+
const result = await onVisibility(inputEle);
|
|
68
70
|
if (result === false)
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
inputEle.blur();
|
|
74
|
+
inputEle.type = "text";
|
|
73
75
|
}
|
|
74
76
|
preventDefault(e);
|
|
75
77
|
};
|
|
76
78
|
const touchEnd = (e) => {
|
|
77
79
|
// Show the password
|
|
78
|
-
if (
|
|
80
|
+
if (inputEle) {
|
|
79
81
|
if (onVisibility)
|
|
80
82
|
return;
|
|
81
|
-
|
|
83
|
+
inputEle.type = "password";
|
|
82
84
|
}
|
|
83
85
|
preventDefault(e);
|
|
84
86
|
};
|
|
@@ -99,7 +101,7 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
|
99
101
|
onKeyDown(e);
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
|
-
React.useImperativeHandle(
|
|
104
|
+
React.useImperativeHandle(mRef, () => ({
|
|
103
105
|
/**
|
|
104
106
|
* Set error
|
|
105
107
|
* @param error Error
|
|
@@ -140,5 +142,12 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
|
|
|
140
142
|
};
|
|
141
143
|
}, []);
|
|
142
144
|
// Textfield
|
|
143
|
-
return (_jsx(TextField, { error: errorEx, fullWidth: fullWidth, helperText: helperTextEx, inputRef: useCombinedRefs(inputRef, localRef),
|
|
144
|
-
}
|
|
145
|
+
return (_jsx(TextField, { error: errorEx, fullWidth: fullWidth, helperText: helperTextEx, inputRef: useCombinedRefs(inputRef, localRef), onChange: onChangeEx, onKeyDown: onKeyPressEx, slotProps: {
|
|
146
|
+
input: { readOnly, ...input, ...InputProps },
|
|
147
|
+
inputLabel: {
|
|
148
|
+
shrink: MUGlobal.inputFieldShrink,
|
|
149
|
+
...inputLabel
|
|
150
|
+
},
|
|
151
|
+
...restSlotProps
|
|
152
|
+
}, type: typeEx, variant: variant, ...rest }));
|
|
153
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.86",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"@dnd-kit/sortable": "^10.0.0",
|
|
41
41
|
"@emotion/react": "^11.14.0",
|
|
42
42
|
"@emotion/styled": "^11.14.1",
|
|
43
|
-
"@etsoo/appscript": "^1.6.
|
|
43
|
+
"@etsoo/appscript": "^1.6.48",
|
|
44
44
|
"@etsoo/notificationbase": "^1.1.66",
|
|
45
45
|
"@etsoo/react": "^1.8.62",
|
|
46
46
|
"@etsoo/shared": "^1.2.79",
|
|
47
47
|
"@mui/icons-material": "^7.3.5",
|
|
48
48
|
"@mui/material": "^7.3.5",
|
|
49
|
-
"@mui/x-data-grid": "^8.
|
|
49
|
+
"@mui/x-data-grid": "^8.18.0",
|
|
50
50
|
"chart.js": "^4.5.1",
|
|
51
51
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
52
52
|
"dompurify": "^3.3.0",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"@testing-library/react": "^16.3.0",
|
|
77
77
|
"@types/pica": "^9.0.5",
|
|
78
78
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
79
|
-
"@types/react": "^19.2.
|
|
79
|
+
"@types/react": "^19.2.5",
|
|
80
80
|
"@types/react-avatar-editor": "^13.0.4",
|
|
81
|
-
"@types/react-dom": "^19.2.
|
|
81
|
+
"@types/react-dom": "^19.2.3",
|
|
82
82
|
"@types/react-input-mask": "^3.0.6",
|
|
83
|
-
"@vitejs/plugin-react": "^5.1.
|
|
84
|
-
"jsdom": "^27.
|
|
83
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
84
|
+
"jsdom": "^27.2.0",
|
|
85
85
|
"typescript": "^5.9.3",
|
|
86
|
-
"vitest": "^4.0.
|
|
86
|
+
"vitest": "^4.0.9"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/CountdownButton.tsx
CHANGED
|
@@ -29,10 +29,7 @@ export type CountdownButtonProps = Omit<ButtonProps, "endIcon" | "disabled"> & {
|
|
|
29
29
|
* @param props Props
|
|
30
30
|
* @returns Button
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
33
|
-
HTMLButtonElement,
|
|
34
|
-
CountdownButtonProps
|
|
35
|
-
>((props, ref) => {
|
|
32
|
+
export function CountdownButton(props: CountdownButtonProps) {
|
|
36
33
|
// Destructure
|
|
37
34
|
const { initState = 0, onAction, onClick, ...rest } = props;
|
|
38
35
|
|
|
@@ -121,8 +118,7 @@ export const CountdownButton = React.forwardRef<
|
|
|
121
118
|
disabled={disabled}
|
|
122
119
|
endIcon={endIcon}
|
|
123
120
|
onClick={localClick}
|
|
124
|
-
ref={ref}
|
|
125
121
|
{...rest}
|
|
126
122
|
/>
|
|
127
123
|
);
|
|
128
|
-
}
|
|
124
|
+
}
|
package/src/EmailInput.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import TextField, { TextFieldProps } from "@mui/material/TextField";
|
|
2
1
|
import { useAppContext } from "./app/ReactApp";
|
|
3
2
|
import { MUGlobal } from "./MUGlobal";
|
|
3
|
+
import { InputField, InputFieldProps } from "./InputField";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Email input props
|
|
7
7
|
*/
|
|
8
|
-
export type EmailInputProps = Omit<
|
|
8
|
+
export type EmailInputProps = Omit<InputFieldProps, "type"> & {};
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Email input
|
|
@@ -32,7 +32,7 @@ export function EmailInput(props: EmailInputProps) {
|
|
|
32
32
|
|
|
33
33
|
// Layout
|
|
34
34
|
return (
|
|
35
|
-
<
|
|
35
|
+
<InputField
|
|
36
36
|
type="email"
|
|
37
37
|
autoCapitalize={autoCapitalize}
|
|
38
38
|
autoCorrect={autoCorrect}
|
package/src/InputField.tsx
CHANGED
|
@@ -35,83 +35,78 @@ export type InputFieldProps = TextFieldProps & {
|
|
|
35
35
|
* @param props Props
|
|
36
36
|
* @returns Component
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} = props;
|
|
38
|
+
export function InputField(props: InputFieldProps) {
|
|
39
|
+
// Destruct
|
|
40
|
+
const {
|
|
41
|
+
InputProps = {},
|
|
42
|
+
inputProps = {},
|
|
43
|
+
slotProps,
|
|
44
|
+
changeDelay,
|
|
45
|
+
onChange,
|
|
46
|
+
onChangeDelay,
|
|
47
|
+
readOnly,
|
|
48
|
+
size = MUGlobal.inputFieldSize,
|
|
49
|
+
variant = MUGlobal.inputFieldVariant,
|
|
50
|
+
minChars = 0,
|
|
51
|
+
...rest
|
|
52
|
+
} = props;
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// Slot props
|
|
55
|
+
const { htmlInput, input, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const delayed = createDelayed();
|
|
57
|
+
const isMounted = React.useRef(true);
|
|
58
|
+
const createDelayed = () => {
|
|
59
|
+
if (changeDelay != null && changeDelay >= 1) {
|
|
60
|
+
const changeHandler = onChangeDelay ?? onChange;
|
|
61
|
+
if (changeHandler) return useDelayedExecutor(changeHandler, changeDelay);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
65
|
+
const delayed = createDelayed();
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
const onChangeEx = (
|
|
68
|
+
event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
|
69
|
+
) => {
|
|
70
|
+
// Min characters check
|
|
71
|
+
const len = event.target.value.length;
|
|
72
|
+
if (len > 0 && len < minChars) {
|
|
73
|
+
// Avoid to trigger the form change event
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
79
|
+
if (onChange && (delayed == null || onChangeDelay != null)) onChange(event);
|
|
80
|
+
delayed?.call(undefined, event);
|
|
81
|
+
};
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
return () => {
|
|
85
|
+
isMounted.current = false;
|
|
86
|
+
delayed?.clear();
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
92
89
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
);
|
|
90
|
+
// Layout
|
|
91
|
+
return (
|
|
92
|
+
<TextField
|
|
93
|
+
slotProps={{
|
|
94
|
+
htmlInput: {
|
|
95
|
+
["data-min-chars"]: minChars,
|
|
96
|
+
...htmlInput,
|
|
97
|
+
...inputProps
|
|
98
|
+
},
|
|
99
|
+
input: { readOnly, ...input, ...InputProps },
|
|
100
|
+
inputLabel: {
|
|
101
|
+
shrink: MUGlobal.inputFieldShrink,
|
|
102
|
+
...inputLabel
|
|
103
|
+
},
|
|
104
|
+
...restSlotProps
|
|
105
|
+
}}
|
|
106
|
+
onChange={onChangeEx}
|
|
107
|
+
size={size}
|
|
108
|
+
variant={variant}
|
|
109
|
+
{...rest}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
package/src/InputTipField.tsx
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import Typography, { TypographyProps } from "@mui/material/Typography";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { InputField
|
|
4
|
+
import { InputField } from "./InputField";
|
|
5
5
|
import { useAppContext } from "./app/ReactApp";
|
|
6
6
|
import ListItem from "@mui/material/ListItem";
|
|
7
7
|
import Popover from "@mui/material/Popover";
|
|
8
8
|
import List from "@mui/material/List";
|
|
9
9
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
10
|
+
import { EmailInput } from "./EmailInput";
|
|
11
|
+
import { MobileInput } from "./MobileInput";
|
|
12
|
+
import { PhoneInput } from "./PhoneInput";
|
|
10
13
|
|
|
11
14
|
type ItemType = DataTypes.IdLabelItem<string | number>;
|
|
12
15
|
|
|
16
|
+
const componentMap = {
|
|
17
|
+
input: InputField,
|
|
18
|
+
email: EmailInput,
|
|
19
|
+
phone: PhoneInput,
|
|
20
|
+
mobile: MobileInput
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type ComponentMap = typeof componentMap;
|
|
24
|
+
type ComponentKey = keyof ComponentMap;
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* InputField with tips properties
|
|
15
28
|
*/
|
|
16
|
-
export type InputTipFieldProps<
|
|
17
|
-
|
|
29
|
+
export type InputTipFieldProps<
|
|
30
|
+
T extends ItemType = ItemType,
|
|
31
|
+
K extends ComponentKey = "input"
|
|
32
|
+
> = Omit<React.ComponentProps<ComponentMap[K]>, "component"> & {
|
|
33
|
+
/**
|
|
34
|
+
* Component key
|
|
35
|
+
*/
|
|
36
|
+
component?: K;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Component properties
|
|
40
|
+
*/
|
|
41
|
+
componentProps: {
|
|
18
42
|
/**
|
|
19
43
|
* Load data
|
|
20
44
|
* @param value Duplicate test value
|
|
@@ -40,15 +64,17 @@ export type InputTipFieldProps<T extends ItemType = ItemType> =
|
|
|
40
64
|
*/
|
|
41
65
|
renderItem?: (item: T) => React.ReactNode;
|
|
42
66
|
};
|
|
67
|
+
};
|
|
43
68
|
|
|
44
69
|
/**
|
|
45
70
|
* InputField with tips
|
|
46
71
|
* @param props Props
|
|
47
72
|
* @returns Component
|
|
48
73
|
*/
|
|
49
|
-
export function InputTipField<
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
export function InputTipField<
|
|
75
|
+
T extends ItemType = ItemType,
|
|
76
|
+
K extends ComponentKey = "input"
|
|
77
|
+
>(props: InputTipFieldProps<T, K>) {
|
|
52
78
|
// Global app
|
|
53
79
|
const app = useAppContext();
|
|
54
80
|
|
|
@@ -58,22 +84,30 @@ export function InputTipField<T extends ItemType = ItemType>(
|
|
|
58
84
|
const [data, setData] = React.useState<T[]>();
|
|
59
85
|
|
|
60
86
|
// Destruct
|
|
87
|
+
const {
|
|
88
|
+
component = "input",
|
|
89
|
+
componentProps,
|
|
90
|
+
changeDelay = 480,
|
|
91
|
+
onChangeDelay,
|
|
92
|
+
fullWidth = true,
|
|
93
|
+
slotProps = {},
|
|
94
|
+
...rest
|
|
95
|
+
} = props;
|
|
96
|
+
|
|
61
97
|
const {
|
|
62
98
|
labelProps = {
|
|
63
99
|
title: app?.get("clickForDetails"),
|
|
64
100
|
sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
|
|
65
101
|
},
|
|
66
|
-
changeDelay = 480,
|
|
67
|
-
onChangeDelay,
|
|
68
102
|
loadData,
|
|
69
103
|
itemLabel = (item) => item.label,
|
|
70
|
-
renderItem = (item) => <ListItem key={item.id}>{itemLabel(item)}</ListItem
|
|
71
|
-
|
|
72
|
-
...rest
|
|
73
|
-
} = props;
|
|
104
|
+
renderItem = (item) => <ListItem key={item.id}>{itemLabel(item)}</ListItem>
|
|
105
|
+
} = componentProps;
|
|
74
106
|
|
|
75
107
|
const { input, ...slotRests } = slotProps;
|
|
76
108
|
|
|
109
|
+
const Component = componentMap[component];
|
|
110
|
+
|
|
77
111
|
const load = (value: string) => {
|
|
78
112
|
if (value.length < 2) {
|
|
79
113
|
setTitle(undefined);
|
|
@@ -99,8 +133,9 @@ export function InputTipField<T extends ItemType = ItemType>(
|
|
|
99
133
|
>
|
|
100
134
|
{data && <List>{data.map((item) => renderItem(item))}</List>}
|
|
101
135
|
</Popover>
|
|
102
|
-
<
|
|
136
|
+
<Component
|
|
103
137
|
changeDelay={changeDelay}
|
|
138
|
+
fullWidth={fullWidth}
|
|
104
139
|
onChangeDelay={(event) => {
|
|
105
140
|
load(event.target.value);
|
|
106
141
|
if (onChangeDelay) onChangeDelay(event);
|
|
@@ -123,7 +158,7 @@ export function InputTipField<T extends ItemType = ItemType>(
|
|
|
123
158
|
},
|
|
124
159
|
...slotRests
|
|
125
160
|
}}
|
|
126
|
-
{...rest}
|
|
161
|
+
{...(rest as any)}
|
|
127
162
|
/>
|
|
128
163
|
</React.Fragment>
|
|
129
164
|
);
|
package/src/IntInputField.tsx
CHANGED
|
@@ -75,10 +75,7 @@ export type IntInputFieldProps = Omit<
|
|
|
75
75
|
/**
|
|
76
76
|
* Integer input field (controlled)
|
|
77
77
|
*/
|
|
78
|
-
export
|
|
79
|
-
HTMLDivElement,
|
|
80
|
-
IntInputFieldProps
|
|
81
|
-
>((props, ref) => {
|
|
78
|
+
export function IntInputField(props: IntInputFieldProps) {
|
|
82
79
|
// Destruct
|
|
83
80
|
const {
|
|
84
81
|
min = 0,
|
|
@@ -130,25 +127,20 @@ export const IntInputField = React.forwardRef<
|
|
|
130
127
|
// Layout
|
|
131
128
|
const layout = (
|
|
132
129
|
<InputField
|
|
133
|
-
ref={ref}
|
|
134
130
|
type="number"
|
|
135
131
|
value={localValue == null ? (required ? min : "") : localValue}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
) : undefined,
|
|
149
|
-
endAdornment: endSymbol ? (
|
|
150
|
-
<InputAdornment position="end">{endSymbol}</InputAdornment>
|
|
151
|
-
) : undefined
|
|
132
|
+
slotProps={{
|
|
133
|
+
input: {
|
|
134
|
+
startAdornment: symbol ? (
|
|
135
|
+
<React.Fragment>
|
|
136
|
+
<InputAdornment position="start">{symbol}</InputAdornment>
|
|
137
|
+
</React.Fragment>
|
|
138
|
+
) : undefined,
|
|
139
|
+
endAdornment: endSymbol ? (
|
|
140
|
+
<InputAdornment position="end">{endSymbol}</InputAdornment>
|
|
141
|
+
) : undefined
|
|
142
|
+
},
|
|
143
|
+
htmlInput: { min, step, max, style: inputStyle, inputMode: "numeric" }
|
|
152
144
|
}}
|
|
153
145
|
sx={
|
|
154
146
|
buttons
|
|
@@ -234,4 +226,4 @@ export const IntInputField = React.forwardRef<
|
|
|
234
226
|
</Box>
|
|
235
227
|
);
|
|
236
228
|
else return layout;
|
|
237
|
-
}
|
|
229
|
+
}
|
package/src/MobileInput.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import TextField, { TextFieldProps } from "@mui/material/TextField";
|
|
2
1
|
import { useAppContext } from "./app/ReactApp";
|
|
3
2
|
import { MUGlobal } from "./MUGlobal";
|
|
3
|
+
import { InputField, InputFieldProps } from "./InputField";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Mobile input props
|
|
7
7
|
*/
|
|
8
|
-
export type MobileInputProps = Omit<
|
|
8
|
+
export type MobileInputProps = Omit<InputFieldProps, "type"> & {};
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Mobile input
|
|
@@ -32,7 +32,7 @@ export function MobileInput(props: MobileInputProps) {
|
|
|
32
32
|
|
|
33
33
|
// Layout
|
|
34
34
|
return (
|
|
35
|
-
<
|
|
35
|
+
<InputField
|
|
36
36
|
type="tel"
|
|
37
37
|
autoCapitalize={autoCapitalize}
|
|
38
38
|
autoCorrect={autoCorrect}
|
package/src/MoneyInputField.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { IntInputField, IntInputFieldProps } from "./IntInputField";
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -9,13 +8,10 @@ export type MoneyInputFieldProps = IntInputFieldProps & {};
|
|
|
9
8
|
/**
|
|
10
9
|
* Money input field (controlled)
|
|
11
10
|
*/
|
|
12
|
-
export
|
|
13
|
-
HTMLDivElement,
|
|
14
|
-
MoneyInputFieldProps
|
|
15
|
-
>((props, ref) => {
|
|
11
|
+
export function MoneyInputField(props: MoneyInputFieldProps) {
|
|
16
12
|
// Destruct
|
|
17
13
|
const { step = 0.01, ...rest } = props;
|
|
18
14
|
|
|
19
15
|
// Layout
|
|
20
|
-
return <IntInputField
|
|
21
|
-
}
|
|
16
|
+
return <IntInputField step={step} {...rest} />;
|
|
17
|
+
}
|
package/src/PhoneInput.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import TextField, { TextFieldProps } from "@mui/material/TextField";
|
|
2
1
|
import { useAppContext } from "./app/ReactApp";
|
|
3
2
|
import { MUGlobal } from "./MUGlobal";
|
|
3
|
+
import { InputField, InputFieldProps } from "./InputField";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Phone input props
|
|
7
7
|
*/
|
|
8
|
-
export type PhoneInputProps = Omit<
|
|
8
|
+
export type PhoneInputProps = Omit<InputFieldProps, "type"> & {};
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Phone input
|
|
@@ -32,7 +32,7 @@ export function PhoneInput(props: PhoneInputProps) {
|
|
|
32
32
|
|
|
33
33
|
// Layout
|
|
34
34
|
return (
|
|
35
|
-
<
|
|
35
|
+
<InputField
|
|
36
36
|
type="tel"
|
|
37
37
|
autoCapitalize={autoCapitalize}
|
|
38
38
|
autoCorrect={autoCorrect}
|