@etsoo/materialui 1.5.83 → 1.5.85
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 +22 -3
- 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 +3 -3
- package/lib/cjs/PhoneInput.js +4 -7
- 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 +22 -3
- 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 +3 -3
- package/lib/mjs/PhoneInput.js +3 -3
- 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 +63 -35
- package/src/IntInputField.tsx +14 -22
- package/src/MobileInput.tsx +3 -3
- package/src/MoneyInputField.tsx +3 -7
- package/src/PhoneInput.tsx +4 -4
- package/src/TextFieldEx.tsx +33 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ButtonProps } from "@mui/material/Button";
|
|
2
|
-
import React from "react";
|
|
3
2
|
/**
|
|
4
3
|
* Countdown button action
|
|
5
4
|
*/
|
|
@@ -24,4 +23,4 @@ export type CountdownButtonProps = Omit<ButtonProps, "endIcon" | "disabled"> & {
|
|
|
24
23
|
* @param props Props
|
|
25
24
|
* @returns Button
|
|
26
25
|
*/
|
|
27
|
-
export declare
|
|
26
|
+
export declare function CountdownButton(props: CountdownButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ import React from "react";
|
|
|
7
7
|
* @param props Props
|
|
8
8
|
* @returns Button
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export function CountdownButton(props) {
|
|
11
11
|
// Destructure
|
|
12
12
|
const { initState = 0, onAction, onClick, ...rest } = props;
|
|
13
13
|
// State
|
|
@@ -82,5 +82,5 @@ export const CountdownButton = React.forwardRef((props, ref) => {
|
|
|
82
82
|
React.useEffect(() => {
|
|
83
83
|
setState(initState);
|
|
84
84
|
}, [initState]);
|
|
85
|
-
return (_jsx(Button, { disabled: disabled, endIcon: endIcon, onClick: localClick,
|
|
86
|
-
}
|
|
85
|
+
return (_jsx(Button, { disabled: disabled, endIcon: endIcon, onClick: localClick, ...rest }));
|
|
86
|
+
}
|
package/lib/mjs/EmailInput.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputFieldProps } from "./InputField";
|
|
2
2
|
/**
|
|
3
3
|
* Email input props
|
|
4
4
|
*/
|
|
5
|
-
export type EmailInputProps = Omit<
|
|
5
|
+
export type EmailInputProps = Omit<InputFieldProps, "type"> & {};
|
|
6
6
|
/**
|
|
7
7
|
* Email input
|
|
8
8
|
* @param props Props
|
package/lib/mjs/EmailInput.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import TextField from "@mui/material/TextField";
|
|
3
2
|
import { useAppContext } from "./app/ReactApp";
|
|
4
3
|
import { MUGlobal } from "./MUGlobal";
|
|
4
|
+
import { InputField } from "./InputField";
|
|
5
5
|
/**
|
|
6
6
|
* Email input
|
|
7
7
|
* @param props Props
|
|
@@ -14,7 +14,7 @@ export function EmailInput(props) {
|
|
|
14
14
|
// Slot props
|
|
15
15
|
const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
16
16
|
// Layout
|
|
17
|
-
return (_jsx(
|
|
17
|
+
return (_jsx(InputField, { type: "email", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
|
|
18
18
|
htmlInput: { inputMode: "email", maxLength: 128, ...htmlInput },
|
|
19
19
|
inputLabel: { shrink: MUGlobal.inputFieldShrink, ...inputLabel },
|
|
20
20
|
...restSlotProps
|
package/lib/mjs/InputField.d.ts
CHANGED
|
@@ -26,55 +26,4 @@ export type InputFieldProps = TextFieldProps & {
|
|
|
26
26
|
* @param props Props
|
|
27
27
|
* @returns Component
|
|
28
28
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
/**
|
|
31
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
32
|
-
*/
|
|
33
|
-
changeDelay?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Change delay handler, without it onChange will be applied
|
|
36
|
-
*/
|
|
37
|
-
onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
38
|
-
/**
|
|
39
|
-
* Is the field read only?
|
|
40
|
-
*/
|
|
41
|
-
readOnly?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Minimum characters to trigger the change event
|
|
44
|
-
*/
|
|
45
|
-
minChars?: number;
|
|
46
|
-
}, "ref"> | Omit<import("@mui/material").OutlinedTextFieldProps & {
|
|
47
|
-
/**
|
|
48
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
49
|
-
*/
|
|
50
|
-
changeDelay?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Change delay handler, without it onChange will be applied
|
|
53
|
-
*/
|
|
54
|
-
onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
55
|
-
/**
|
|
56
|
-
* Is the field read only?
|
|
57
|
-
*/
|
|
58
|
-
readOnly?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Minimum characters to trigger the change event
|
|
61
|
-
*/
|
|
62
|
-
minChars?: number;
|
|
63
|
-
}, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
|
|
64
|
-
/**
|
|
65
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
66
|
-
*/
|
|
67
|
-
changeDelay?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Change delay handler, without it onChange will be applied
|
|
70
|
-
*/
|
|
71
|
-
onChangeDelay?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
72
|
-
/**
|
|
73
|
-
* Is the field read only?
|
|
74
|
-
*/
|
|
75
|
-
readOnly?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Minimum characters to trigger the change event
|
|
78
|
-
*/
|
|
79
|
-
minChars?: number;
|
|
80
|
-
}, "ref">) & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
export declare function InputField(props: InputFieldProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/mjs/InputField.js
CHANGED
|
@@ -8,9 +8,9 @@ import TextField from "@mui/material/TextField";
|
|
|
8
8
|
* @param props Props
|
|
9
9
|
* @returns Component
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export function InputField(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { InputProps = {}, inputProps = {},
|
|
13
|
+
const { InputProps = {}, inputProps = {}, slotProps, changeDelay, onChange, onChangeDelay, readOnly, size = MUGlobal.inputFieldSize, variant = MUGlobal.inputFieldVariant, minChars = 0, ...rest } = props;
|
|
14
14
|
// Slot props
|
|
15
15
|
const { htmlInput, input, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
16
16
|
const isMounted = React.useRef(true);
|
|
@@ -43,7 +43,7 @@ export const InputField = React.forwardRef((props, ref) => {
|
|
|
43
43
|
};
|
|
44
44
|
}, []);
|
|
45
45
|
// Layout
|
|
46
|
-
return (_jsx(TextField, {
|
|
46
|
+
return (_jsx(TextField, { slotProps: {
|
|
47
47
|
htmlInput: {
|
|
48
48
|
["data-min-chars"]: minChars,
|
|
49
49
|
...htmlInput,
|
|
@@ -56,4 +56,4 @@ export const InputField = React.forwardRef((props, ref) => {
|
|
|
56
56
|
},
|
|
57
57
|
...restSlotProps
|
|
58
58
|
}, onChange: onChangeEx, size: size, variant: variant, ...rest }));
|
|
59
|
-
}
|
|
59
|
+
}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { DataTypes } from "@etsoo/shared";
|
|
2
2
|
import { TypographyProps } from "@mui/material/Typography";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { InputField } from "./InputField";
|
|
5
|
+
import { EmailInput } from "./EmailInput";
|
|
6
|
+
import { MobileInput } from "./MobileInput";
|
|
7
|
+
import { PhoneInput } from "./PhoneInput";
|
|
5
8
|
type ItemType = DataTypes.IdLabelItem<string | number>;
|
|
9
|
+
declare const componentMap: {
|
|
10
|
+
input: typeof InputField;
|
|
11
|
+
email: typeof EmailInput;
|
|
12
|
+
phone: typeof PhoneInput;
|
|
13
|
+
mobile: typeof MobileInput;
|
|
14
|
+
};
|
|
15
|
+
type ComponentMap = typeof componentMap;
|
|
16
|
+
type ComponentKey = keyof ComponentMap;
|
|
6
17
|
/**
|
|
7
18
|
* InputField with tips properties
|
|
8
19
|
*/
|
|
9
|
-
export type InputTipFieldProps<T extends ItemType = ItemType
|
|
20
|
+
export type InputTipFieldProps<T extends ItemType = ItemType, K extends ComponentKey = "input"> = {
|
|
21
|
+
/**
|
|
22
|
+
* Component key
|
|
23
|
+
*/
|
|
24
|
+
component?: K;
|
|
25
|
+
/**
|
|
26
|
+
* Component props
|
|
27
|
+
*/
|
|
28
|
+
componentProps?: React.ComponentProps<ComponentMap[K]>;
|
|
10
29
|
/**
|
|
11
30
|
* Load data
|
|
12
31
|
* @param value Duplicate test value
|
|
@@ -34,5 +53,5 @@ export type InputTipFieldProps<T extends ItemType = ItemType> = InputFieldProps
|
|
|
34
53
|
* @param props Props
|
|
35
54
|
* @returns Component
|
|
36
55
|
*/
|
|
37
|
-
export declare function InputTipField<T extends ItemType = ItemType>(props: InputTipFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare function InputTipField<T extends ItemType = ItemType, K extends ComponentKey = "input">(props: InputTipFieldProps<T, K>): import("react/jsx-runtime").JSX.Element;
|
|
38
57
|
export {};
|
package/lib/mjs/InputTipField.js
CHANGED
|
@@ -7,6 +7,15 @@ 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";
|
|
13
|
+
const componentMap = {
|
|
14
|
+
input: InputField,
|
|
15
|
+
email: EmailInput,
|
|
16
|
+
phone: PhoneInput,
|
|
17
|
+
mobile: MobileInput
|
|
18
|
+
};
|
|
10
19
|
/**
|
|
11
20
|
* InputField with tips
|
|
12
21
|
* @param props Props
|
|
@@ -23,8 +32,10 @@ export function InputTipField(props) {
|
|
|
23
32
|
const { labelProps = {
|
|
24
33
|
title: app?.get("clickForDetails"),
|
|
25
34
|
sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
|
|
26
|
-
},
|
|
35
|
+
}, loadData, itemLabel = (item) => item.label, renderItem = (item) => _jsx(ListItem, { children: itemLabel(item) }, item.id), component = "input", componentProps = {}, ...rest } = props;
|
|
36
|
+
const { changeDelay = 480, onChangeDelay, slotProps = {} } = componentProps;
|
|
27
37
|
const { input, ...slotRests } = slotProps;
|
|
38
|
+
const Component = componentMap[component];
|
|
28
39
|
const load = (value) => {
|
|
29
40
|
if (value.length < 2) {
|
|
30
41
|
setTitle(undefined);
|
|
@@ -38,7 +49,7 @@ export function InputTipField(props) {
|
|
|
38
49
|
return (_jsxs(React.Fragment, { children: [_jsx(Popover, { open: anchorEl != null, anchorEl: anchorEl, onClose: () => setAnchorEl(undefined), anchorOrigin: {
|
|
39
50
|
vertical: "bottom",
|
|
40
51
|
horizontal: "left"
|
|
41
|
-
}, children: data && _jsx(List, { children: data.map((item) => renderItem(item)) }) }), _jsx(
|
|
52
|
+
}, children: data && _jsx(List, { children: data.map((item) => renderItem(item)) }) }), _jsx(Component, { changeDelay: changeDelay, onChangeDelay: (event) => {
|
|
42
53
|
load(event.target.value);
|
|
43
54
|
if (onChangeDelay)
|
|
44
55
|
onChangeDelay(event);
|
|
@@ -52,4 +52,4 @@ export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "
|
|
|
52
52
|
/**
|
|
53
53
|
* Integer input field (controlled)
|
|
54
54
|
*/
|
|
55
|
-
export declare
|
|
55
|
+
export declare function IntInputField(props: IntInputFieldProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/mjs/IntInputField.js
CHANGED
|
@@ -10,7 +10,7 @@ import IconButton from "@mui/material/IconButton";
|
|
|
10
10
|
/**
|
|
11
11
|
* Integer input field (controlled)
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export function IntInputField(props) {
|
|
14
14
|
// Destruct
|
|
15
15
|
const { min = 0, step = 1, max = 9999999, inputStyle = { textAlign: "right" }, boxProps, buttons, endSymbol, symbol, value, changeDelay = 600, onChangeDelay, onChange, onFocus = (event) => event.currentTarget.select(), onValueChange, required, ...rest } = props;
|
|
16
16
|
// State
|
|
@@ -37,15 +37,12 @@ export const IntInputField = React.forwardRef((props, ref) => {
|
|
|
37
37
|
setValue(value, undefined, true);
|
|
38
38
|
}, [value]);
|
|
39
39
|
// Layout
|
|
40
|
-
const layout = (_jsx(InputField, {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
inputMode: "numeric"
|
|
46
|
-
}, InputProps: {
|
|
47
|
-
startAdornment: symbol ? (_jsx(React.Fragment, { children: _jsx(InputAdornment, { position: "start", children: symbol }) })) : undefined,
|
|
48
|
-
endAdornment: endSymbol ? (_jsx(InputAdornment, { position: "end", children: endSymbol })) : undefined
|
|
40
|
+
const layout = (_jsx(InputField, { type: "number", value: localValue == null ? (required ? min : "") : localValue, slotProps: {
|
|
41
|
+
input: {
|
|
42
|
+
startAdornment: symbol ? (_jsx(React.Fragment, { children: _jsx(InputAdornment, { position: "start", children: symbol }) })) : undefined,
|
|
43
|
+
endAdornment: endSymbol ? (_jsx(InputAdornment, { position: "end", children: endSymbol })) : undefined
|
|
44
|
+
},
|
|
45
|
+
htmlInput: { min, step, max, style: inputStyle, inputMode: "numeric" }
|
|
49
46
|
}, sx: buttons
|
|
50
47
|
? {
|
|
51
48
|
"& input[type=number]::-webkit-inner-spin-button": {
|
|
@@ -109,4 +106,4 @@ export const IntInputField = React.forwardRef((props, ref) => {
|
|
|
109
106
|
}, children: _jsx(AddIcon, { color: localValue == null ? undefined : "primary" }) })] }));
|
|
110
107
|
else
|
|
111
108
|
return layout;
|
|
112
|
-
}
|
|
109
|
+
}
|
package/lib/mjs/MobileInput.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputFieldProps } from "./InputField";
|
|
2
2
|
/**
|
|
3
3
|
* Mobile input props
|
|
4
4
|
*/
|
|
5
|
-
export type MobileInputProps = Omit<
|
|
5
|
+
export type MobileInputProps = Omit<InputFieldProps, "type"> & {};
|
|
6
6
|
/**
|
|
7
7
|
* Mobile input
|
|
8
8
|
* @param props Props
|
package/lib/mjs/MobileInput.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import TextField from "@mui/material/TextField";
|
|
3
2
|
import { useAppContext } from "./app/ReactApp";
|
|
4
3
|
import { MUGlobal } from "./MUGlobal";
|
|
4
|
+
import { InputField } from "./InputField";
|
|
5
5
|
/**
|
|
6
6
|
* Mobile input
|
|
7
7
|
* @param props Props
|
|
@@ -14,7 +14,7 @@ export function MobileInput(props) {
|
|
|
14
14
|
// Slot props
|
|
15
15
|
const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
16
16
|
// Layout
|
|
17
|
-
return (_jsx(
|
|
17
|
+
return (_jsx(InputField, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
|
|
18
18
|
htmlInput: { inputMode: "tel", maxLength: 18, ...htmlInput },
|
|
19
19
|
inputLabel: { shrink: MUGlobal.inputFieldShrink, ...inputLabel },
|
|
20
20
|
...restSlotProps
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { IntInputFieldProps } from "./IntInputField";
|
|
3
2
|
/**
|
|
4
3
|
* Money input field props
|
|
@@ -7,4 +6,4 @@ export type MoneyInputFieldProps = IntInputFieldProps & {};
|
|
|
7
6
|
/**
|
|
8
7
|
* Money input field (controlled)
|
|
9
8
|
*/
|
|
10
|
-
export declare
|
|
9
|
+
export declare function MoneyInputField(props: MoneyInputFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import { IntInputField } from "./IntInputField";
|
|
4
3
|
/**
|
|
5
4
|
* Money input field (controlled)
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
6
|
+
export function MoneyInputField(props) {
|
|
8
7
|
// Destruct
|
|
9
8
|
const { step = 0.01, ...rest } = props;
|
|
10
9
|
// Layout
|
|
11
|
-
return _jsx(IntInputField, {
|
|
12
|
-
}
|
|
10
|
+
return _jsx(IntInputField, { step: step, ...rest });
|
|
11
|
+
}
|
package/lib/mjs/PhoneInput.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputFieldProps } from "./InputField";
|
|
2
2
|
/**
|
|
3
3
|
* Phone input props
|
|
4
4
|
*/
|
|
5
|
-
export type PhoneInputProps = Omit<
|
|
5
|
+
export type PhoneInputProps = Omit<InputFieldProps, "type"> & {};
|
|
6
6
|
/**
|
|
7
7
|
* Phone input
|
|
8
8
|
* @param props Props
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function PhoneInput(props: PhoneInputProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/mjs/PhoneInput.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import TextField from "@mui/material/TextField";
|
|
3
2
|
import { useAppContext } from "./app/ReactApp";
|
|
4
3
|
import { MUGlobal } from "./MUGlobal";
|
|
4
|
+
import { InputField } from "./InputField";
|
|
5
5
|
/**
|
|
6
6
|
* Phone input
|
|
7
7
|
* @param props Props
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function PhoneInput(props) {
|
|
10
10
|
// Global app
|
|
11
11
|
const app = useAppContext();
|
|
12
12
|
// Destruct
|
|
@@ -14,7 +14,7 @@ export function PhoInput(props) {
|
|
|
14
14
|
// Slot props
|
|
15
15
|
const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
|
|
16
16
|
// Layout
|
|
17
|
-
return (_jsx(
|
|
17
|
+
return (_jsx(InputField, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
|
|
18
18
|
htmlInput: { inputMode: "tel", maxLength: 18, ...htmlInput },
|
|
19
19
|
inputLabel: { shrink: MUGlobal.inputFieldShrink, ...inputLabel },
|
|
20
20
|
...restSlotProps
|
package/lib/mjs/TextFieldEx.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export type TextFieldExProps = TextFieldProps & {
|
|
|
38
38
|
* Show password button
|
|
39
39
|
*/
|
|
40
40
|
showPassword?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Methods
|
|
43
|
+
*/
|
|
44
|
+
mRef?: React.Ref<TextFieldExMethods>;
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
43
47
|
* Extended text field methods
|
|
@@ -49,109 +53,4 @@ export interface TextFieldExMethods {
|
|
|
49
53
|
*/
|
|
50
54
|
setError(error: React.ReactNode): void;
|
|
51
55
|
}
|
|
52
|
-
export declare
|
|
53
|
-
/**
|
|
54
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
55
|
-
*/
|
|
56
|
-
changeDelay?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Clear button label
|
|
59
|
-
*/
|
|
60
|
-
clearLabel?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Click clear button callback
|
|
63
|
-
*/
|
|
64
|
-
onClear?: (doClear: () => void) => void;
|
|
65
|
-
/**
|
|
66
|
-
* On enter click
|
|
67
|
-
*/
|
|
68
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
69
|
-
/**
|
|
70
|
-
* On visibility
|
|
71
|
-
* @param input HTML input
|
|
72
|
-
* @returns Result
|
|
73
|
-
*/
|
|
74
|
-
onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
|
|
75
|
-
/**
|
|
76
|
-
* Is the field read only?
|
|
77
|
-
*/
|
|
78
|
-
readOnly?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Show clear button
|
|
81
|
-
*/
|
|
82
|
-
showClear?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Show password button
|
|
85
|
-
*/
|
|
86
|
-
showPassword?: boolean;
|
|
87
|
-
}, "ref"> | Omit<import("@mui/material").OutlinedTextFieldProps & {
|
|
88
|
-
/**
|
|
89
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
90
|
-
*/
|
|
91
|
-
changeDelay?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Clear button label
|
|
94
|
-
*/
|
|
95
|
-
clearLabel?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Click clear button callback
|
|
98
|
-
*/
|
|
99
|
-
onClear?: (doClear: () => void) => void;
|
|
100
|
-
/**
|
|
101
|
-
* On enter click
|
|
102
|
-
*/
|
|
103
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
104
|
-
/**
|
|
105
|
-
* On visibility
|
|
106
|
-
* @param input HTML input
|
|
107
|
-
* @returns Result
|
|
108
|
-
*/
|
|
109
|
-
onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
|
|
110
|
-
/**
|
|
111
|
-
* Is the field read only?
|
|
112
|
-
*/
|
|
113
|
-
readOnly?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Show clear button
|
|
116
|
-
*/
|
|
117
|
-
showClear?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Show password button
|
|
120
|
-
*/
|
|
121
|
-
showPassword?: boolean;
|
|
122
|
-
}, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
|
|
123
|
-
/**
|
|
124
|
-
* Change delay (ms) to avoid repeatly dispatch onChange
|
|
125
|
-
*/
|
|
126
|
-
changeDelay?: number;
|
|
127
|
-
/**
|
|
128
|
-
* Clear button label
|
|
129
|
-
*/
|
|
130
|
-
clearLabel?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Click clear button callback
|
|
133
|
-
*/
|
|
134
|
-
onClear?: (doClear: () => void) => void;
|
|
135
|
-
/**
|
|
136
|
-
* On enter click
|
|
137
|
-
*/
|
|
138
|
-
onEnter?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
139
|
-
/**
|
|
140
|
-
* On visibility
|
|
141
|
-
* @param input HTML input
|
|
142
|
-
* @returns Result
|
|
143
|
-
*/
|
|
144
|
-
onVisibility?: (input: HTMLInputElement) => void | boolean | Promise<boolean>;
|
|
145
|
-
/**
|
|
146
|
-
* Is the field read only?
|
|
147
|
-
*/
|
|
148
|
-
readOnly?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Show clear button
|
|
151
|
-
*/
|
|
152
|
-
showClear?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Show password button
|
|
155
|
-
*/
|
|
156
|
-
showPassword?: boolean;
|
|
157
|
-
}, "ref">) & React.RefAttributes<TextFieldExMethods>>;
|
|
56
|
+
export declare function TextFieldEx(props: TextFieldExProps): import("react/jsx-runtime").JSX.Element;
|
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.85",
|
|
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.4",
|
|
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.8"
|
|
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
|
+
}
|