@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/src/TextFieldEx.tsx
CHANGED
|
@@ -54,6 +54,11 @@ export type TextFieldExProps = TextFieldProps & {
|
|
|
54
54
|
* Show password button
|
|
55
55
|
*/
|
|
56
56
|
showPassword?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Methods
|
|
60
|
+
*/
|
|
61
|
+
mRef?: React.Ref<TextFieldExMethods>;
|
|
57
62
|
};
|
|
58
63
|
|
|
59
64
|
/**
|
|
@@ -67,10 +72,7 @@ export interface TextFieldExMethods {
|
|
|
67
72
|
setError(error: React.ReactNode): void;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
export
|
|
71
|
-
TextFieldExMethods,
|
|
72
|
-
TextFieldExProps
|
|
73
|
-
>((props, ref) => {
|
|
75
|
+
export function TextFieldEx(props: TextFieldExProps) {
|
|
74
76
|
// Global app
|
|
75
77
|
const app = useAppContext();
|
|
76
78
|
|
|
@@ -86,6 +88,7 @@ export const TextFieldEx = React.forwardRef<
|
|
|
86
88
|
helperText,
|
|
87
89
|
InputLabelProps = {},
|
|
88
90
|
InputProps = {},
|
|
91
|
+
slotProps,
|
|
89
92
|
onChange,
|
|
90
93
|
onClear,
|
|
91
94
|
onKeyDown,
|
|
@@ -97,9 +100,13 @@ export const TextFieldEx = React.forwardRef<
|
|
|
97
100
|
showPassword,
|
|
98
101
|
type,
|
|
99
102
|
variant = MUGlobal.textFieldVariant,
|
|
103
|
+
mRef,
|
|
100
104
|
...rest
|
|
101
105
|
} = props;
|
|
102
106
|
|
|
107
|
+
// Slot props
|
|
108
|
+
const { input, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
109
|
+
|
|
103
110
|
// Shrink
|
|
104
111
|
InputLabelProps.shrink ??= MUGlobal.searchFieldShrink;
|
|
105
112
|
|
|
@@ -120,19 +127,19 @@ export const TextFieldEx = React.forwardRef<
|
|
|
120
127
|
|
|
121
128
|
let typeEx = showPassword ? "password" : type;
|
|
122
129
|
|
|
123
|
-
let
|
|
130
|
+
let inputEle: HTMLInputElement | undefined;
|
|
124
131
|
const localRef = (ref: HTMLInputElement) => {
|
|
125
|
-
|
|
132
|
+
inputEle = ref;
|
|
126
133
|
|
|
127
|
-
if (
|
|
134
|
+
if (inputEle.value !== "") {
|
|
128
135
|
updateEmpty(false);
|
|
129
136
|
}
|
|
130
137
|
};
|
|
131
138
|
|
|
132
139
|
const doClear = () => {
|
|
133
|
-
if (
|
|
134
|
-
ReactUtils.triggerChange(
|
|
135
|
-
|
|
140
|
+
if (inputEle == null) return;
|
|
141
|
+
ReactUtils.triggerChange(inputEle, "", false);
|
|
142
|
+
inputEle.focus();
|
|
136
143
|
};
|
|
137
144
|
|
|
138
145
|
const clearClick = () => {
|
|
@@ -152,24 +159,24 @@ export const TextFieldEx = React.forwardRef<
|
|
|
152
159
|
|
|
153
160
|
const touchStart = async (e: React.TouchEvent | React.MouseEvent) => {
|
|
154
161
|
// Show the password
|
|
155
|
-
if (
|
|
162
|
+
if (inputEle) {
|
|
156
163
|
if (onVisibility) {
|
|
157
|
-
const result = await onVisibility(
|
|
164
|
+
const result = await onVisibility(inputEle);
|
|
158
165
|
if (result === false) return;
|
|
159
166
|
}
|
|
160
167
|
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
inputEle.blur();
|
|
169
|
+
inputEle.type = "text";
|
|
163
170
|
}
|
|
164
171
|
preventDefault(e);
|
|
165
172
|
};
|
|
166
173
|
|
|
167
174
|
const touchEnd = (e: React.TouchEvent | React.MouseEvent) => {
|
|
168
175
|
// Show the password
|
|
169
|
-
if (
|
|
176
|
+
if (inputEle) {
|
|
170
177
|
if (onVisibility) return;
|
|
171
178
|
|
|
172
|
-
|
|
179
|
+
inputEle.type = "password";
|
|
173
180
|
}
|
|
174
181
|
preventDefault(e);
|
|
175
182
|
};
|
|
@@ -218,7 +225,7 @@ export const TextFieldEx = React.forwardRef<
|
|
|
218
225
|
};
|
|
219
226
|
|
|
220
227
|
React.useImperativeHandle(
|
|
221
|
-
|
|
228
|
+
mRef,
|
|
222
229
|
() => ({
|
|
223
230
|
/**
|
|
224
231
|
* Set error
|
|
@@ -277,13 +284,19 @@ export const TextFieldEx = React.forwardRef<
|
|
|
277
284
|
fullWidth={fullWidth}
|
|
278
285
|
helperText={helperTextEx}
|
|
279
286
|
inputRef={useCombinedRefs(inputRef, localRef)}
|
|
280
|
-
InputProps={InputProps}
|
|
281
|
-
InputLabelProps={InputLabelProps}
|
|
282
287
|
onChange={onChangeEx}
|
|
283
288
|
onKeyDown={onKeyPressEx}
|
|
289
|
+
slotProps={{
|
|
290
|
+
input: { readOnly, ...input, ...InputProps },
|
|
291
|
+
inputLabel: {
|
|
292
|
+
shrink: MUGlobal.inputFieldShrink,
|
|
293
|
+
...inputLabel
|
|
294
|
+
},
|
|
295
|
+
...restSlotProps
|
|
296
|
+
}}
|
|
284
297
|
type={typeEx}
|
|
285
298
|
variant={variant}
|
|
286
299
|
{...rest}
|
|
287
300
|
/>
|
|
288
301
|
);
|
|
289
|
-
}
|
|
302
|
+
}
|