@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.
Files changed (46) hide show
  1. package/lib/cjs/CountdownButton.d.ts +1 -2
  2. package/lib/cjs/CountdownButton.js +4 -4
  3. package/lib/cjs/EmailInput.d.ts +2 -2
  4. package/lib/cjs/EmailInput.js +2 -5
  5. package/lib/cjs/InputField.d.ts +1 -52
  6. package/lib/cjs/InputField.js +5 -5
  7. package/lib/cjs/InputTipField.d.ts +22 -3
  8. package/lib/cjs/InputTipField.js +13 -2
  9. package/lib/cjs/IntInputField.d.ts +1 -1
  10. package/lib/cjs/IntInputField.js +9 -12
  11. package/lib/cjs/MobileInput.d.ts +2 -2
  12. package/lib/cjs/MobileInput.js +2 -5
  13. package/lib/cjs/MoneyInputField.d.ts +1 -2
  14. package/lib/cjs/MoneyInputField.js +4 -8
  15. package/lib/cjs/PhoneInput.d.ts +3 -3
  16. package/lib/cjs/PhoneInput.js +4 -7
  17. package/lib/cjs/TextFieldEx.d.ts +5 -106
  18. package/lib/cjs/TextFieldEx.js +27 -18
  19. package/lib/mjs/CountdownButton.d.ts +1 -2
  20. package/lib/mjs/CountdownButton.js +3 -3
  21. package/lib/mjs/EmailInput.d.ts +2 -2
  22. package/lib/mjs/EmailInput.js +2 -2
  23. package/lib/mjs/InputField.d.ts +1 -52
  24. package/lib/mjs/InputField.js +4 -4
  25. package/lib/mjs/InputTipField.d.ts +22 -3
  26. package/lib/mjs/InputTipField.js +13 -2
  27. package/lib/mjs/IntInputField.d.ts +1 -1
  28. package/lib/mjs/IntInputField.js +8 -11
  29. package/lib/mjs/MobileInput.d.ts +2 -2
  30. package/lib/mjs/MobileInput.js +2 -2
  31. package/lib/mjs/MoneyInputField.d.ts +1 -2
  32. package/lib/mjs/MoneyInputField.js +3 -4
  33. package/lib/mjs/PhoneInput.d.ts +3 -3
  34. package/lib/mjs/PhoneInput.js +3 -3
  35. package/lib/mjs/TextFieldEx.d.ts +5 -106
  36. package/lib/mjs/TextFieldEx.js +26 -17
  37. package/package.json +8 -8
  38. package/src/CountdownButton.tsx +2 -6
  39. package/src/EmailInput.tsx +3 -3
  40. package/src/InputField.tsx +69 -74
  41. package/src/InputTipField.tsx +63 -35
  42. package/src/IntInputField.tsx +14 -22
  43. package/src/MobileInput.tsx +3 -3
  44. package/src/MoneyInputField.tsx +3 -7
  45. package/src/PhoneInput.tsx +4 -4
  46. 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 const CountdownButton: React.ForwardRefExoticComponent<Omit<CountdownButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
26
+ export declare function CountdownButton(props: CountdownButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CountdownButton = void 0;
6
+ exports.CountdownButton = CountdownButton;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const Button_1 = __importDefault(require("@mui/material/Button"));
9
9
  const CircularProgress_1 = __importDefault(require("@mui/material/CircularProgress"));
@@ -13,7 +13,7 @@ const react_1 = __importDefault(require("react"));
13
13
  * @param props Props
14
14
  * @returns Button
15
15
  */
16
- exports.CountdownButton = react_1.default.forwardRef((props, ref) => {
16
+ function CountdownButton(props) {
17
17
  // Destructure
18
18
  const { initState = 0, onAction, onClick, ...rest } = props;
19
19
  // State
@@ -88,5 +88,5 @@ exports.CountdownButton = react_1.default.forwardRef((props, ref) => {
88
88
  react_1.default.useEffect(() => {
89
89
  setState(initState);
90
90
  }, [initState]);
91
- return ((0, jsx_runtime_1.jsx)(Button_1.default, { disabled: disabled, endIcon: endIcon, onClick: localClick, ref: ref, ...rest }));
92
- });
91
+ return ((0, jsx_runtime_1.jsx)(Button_1.default, { disabled: disabled, endIcon: endIcon, onClick: localClick, ...rest }));
92
+ }
@@ -1,8 +1,8 @@
1
- import { TextFieldProps } from "@mui/material/TextField";
1
+ import { InputFieldProps } from "./InputField";
2
2
  /**
3
3
  * Email input props
4
4
  */
5
- export type EmailInputProps = Omit<TextFieldProps, "type"> & {};
5
+ export type EmailInputProps = Omit<InputFieldProps, "type"> & {};
6
6
  /**
7
7
  * Email input
8
8
  * @param props Props
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.EmailInput = EmailInput;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const TextField_1 = __importDefault(require("@mui/material/TextField"));
9
5
  const ReactApp_1 = require("./app/ReactApp");
10
6
  const MUGlobal_1 = require("./MUGlobal");
7
+ const InputField_1 = require("./InputField");
11
8
  /**
12
9
  * Email input
13
10
  * @param props Props
@@ -20,7 +17,7 @@ function EmailInput(props) {
20
17
  // Slot props
21
18
  const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
22
19
  // Layout
23
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { type: "email", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
20
+ return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "email", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
24
21
  htmlInput: { inputMode: "email", maxLength: 128, ...htmlInput },
25
22
  inputLabel: { shrink: MUGlobal_1.MUGlobal.inputFieldShrink, ...inputLabel },
26
23
  ...restSlotProps
@@ -26,55 +26,4 @@ export type InputFieldProps = TextFieldProps & {
26
26
  * @param props Props
27
27
  * @returns Component
28
28
  */
29
- export declare const InputField: React.ForwardRefExoticComponent<(Omit<import("@mui/material/TextField").StandardTextFieldProps & {
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/TextField").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/TextField").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;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InputField = void 0;
6
+ exports.InputField = InputField;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("@etsoo/react");
9
9
  const react_2 = __importDefault(require("react"));
@@ -14,9 +14,9 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
14
14
  * @param props Props
15
15
  * @returns Component
16
16
  */
17
- exports.InputField = react_2.default.forwardRef((props, ref) => {
17
+ function InputField(props) {
18
18
  // Destruct
19
- const { InputProps = {}, inputProps = {}, changeDelay, slotProps, onChange, onChangeDelay, readOnly, size = MUGlobal_1.MUGlobal.inputFieldSize, variant = MUGlobal_1.MUGlobal.inputFieldVariant, minChars = 0, ...rest } = props;
19
+ const { InputProps = {}, inputProps = {}, slotProps, changeDelay, onChange, onChangeDelay, readOnly, size = MUGlobal_1.MUGlobal.inputFieldSize, variant = MUGlobal_1.MUGlobal.inputFieldVariant, minChars = 0, ...rest } = props;
20
20
  // Slot props
21
21
  const { htmlInput, input, inputLabel, ...restSlotProps } = slotProps ?? {};
22
22
  const isMounted = react_2.default.useRef(true);
@@ -49,7 +49,7 @@ exports.InputField = react_2.default.forwardRef((props, ref) => {
49
49
  };
50
50
  }, []);
51
51
  // Layout
52
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { ref: ref, slotProps: {
52
+ return ((0, jsx_runtime_1.jsx)(TextField_1.default, { slotProps: {
53
53
  htmlInput: {
54
54
  ["data-min-chars"]: minChars,
55
55
  ...htmlInput,
@@ -62,4 +62,4 @@ exports.InputField = react_2.default.forwardRef((props, ref) => {
62
62
  },
63
63
  ...restSlotProps
64
64
  }, onChange: onChangeEx, size: size, variant: variant, ...rest }));
65
- });
65
+ }
@@ -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 { InputFieldProps } from "./InputField";
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> = InputFieldProps & {
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 {};
@@ -13,6 +13,15 @@ const ListItem_1 = __importDefault(require("@mui/material/ListItem"));
13
13
  const Popover_1 = __importDefault(require("@mui/material/Popover"));
14
14
  const List_1 = __importDefault(require("@mui/material/List"));
15
15
  const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
16
+ const EmailInput_1 = require("./EmailInput");
17
+ const MobileInput_1 = require("./MobileInput");
18
+ const PhoneInput_1 = require("./PhoneInput");
19
+ const componentMap = {
20
+ input: InputField_1.InputField,
21
+ email: EmailInput_1.EmailInput,
22
+ phone: PhoneInput_1.PhoneInput,
23
+ mobile: MobileInput_1.MobileInput
24
+ };
16
25
  /**
17
26
  * InputField with tips
18
27
  * @param props Props
@@ -29,8 +38,10 @@ function InputTipField(props) {
29
38
  const { labelProps = {
30
39
  title: app?.get("clickForDetails"),
31
40
  sx: { color: (theme) => theme.palette.error.main, cursor: "pointer" }
32
- }, changeDelay = 480, onChangeDelay, loadData, itemLabel = (item) => item.label, renderItem = (item) => (0, jsx_runtime_1.jsx)(ListItem_1.default, { children: itemLabel(item) }, item.id), slotProps = {}, ...rest } = props;
41
+ }, loadData, itemLabel = (item) => item.label, renderItem = (item) => (0, jsx_runtime_1.jsx)(ListItem_1.default, { children: itemLabel(item) }, item.id), component = "input", componentProps = {}, ...rest } = props;
42
+ const { changeDelay = 480, onChangeDelay, slotProps = {} } = componentProps;
33
43
  const { input, ...slotRests } = slotProps;
44
+ const Component = componentMap[component];
34
45
  const load = (value) => {
35
46
  if (value.length < 2) {
36
47
  setTitle(undefined);
@@ -44,7 +55,7 @@ function InputTipField(props) {
44
55
  return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Popover_1.default, { open: anchorEl != null, anchorEl: anchorEl, onClose: () => setAnchorEl(undefined), anchorOrigin: {
45
56
  vertical: "bottom",
46
57
  horizontal: "left"
47
- }, children: data && (0, jsx_runtime_1.jsx)(List_1.default, { children: data.map((item) => renderItem(item)) }) }), (0, jsx_runtime_1.jsx)(InputField_1.InputField, { changeDelay: changeDelay, onChangeDelay: (event) => {
58
+ }, children: data && (0, jsx_runtime_1.jsx)(List_1.default, { children: data.map((item) => renderItem(item)) }) }), (0, jsx_runtime_1.jsx)(Component, { changeDelay: changeDelay, onChangeDelay: (event) => {
48
59
  load(event.target.value);
49
60
  if (onChangeDelay)
50
61
  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 const IntInputField: React.ForwardRefExoticComponent<Omit<IntInputFieldProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
55
+ export declare function IntInputField(props: IntInputFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntInputField = void 0;
6
+ exports.IntInputField = IntInputField;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const Add_1 = __importDefault(require("@mui/icons-material/Add"));
9
9
  const Remove_1 = __importDefault(require("@mui/icons-material/Remove"));
@@ -16,7 +16,7 @@ const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
16
16
  /**
17
17
  * Integer input field (controlled)
18
18
  */
19
- exports.IntInputField = react_1.default.forwardRef((props, ref) => {
19
+ function IntInputField(props) {
20
20
  // Destruct
21
21
  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;
22
22
  // State
@@ -43,15 +43,12 @@ exports.IntInputField = react_1.default.forwardRef((props, ref) => {
43
43
  setValue(value, undefined, true);
44
44
  }, [value]);
45
45
  // Layout
46
- const layout = ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { ref: ref, type: "number", value: localValue == null ? (required ? min : "") : localValue, inputProps: {
47
- min,
48
- step,
49
- max,
50
- style: inputStyle,
51
- inputMode: "numeric"
52
- }, InputProps: {
53
- startAdornment: symbol ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "start", children: symbol }) })) : undefined,
54
- endAdornment: endSymbol ? ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "end", children: endSymbol })) : undefined
46
+ const layout = ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "number", value: localValue == null ? (required ? min : "") : localValue, slotProps: {
47
+ input: {
48
+ startAdornment: symbol ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "start", children: symbol }) })) : undefined,
49
+ endAdornment: endSymbol ? ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "end", children: endSymbol })) : undefined
50
+ },
51
+ htmlInput: { min, step, max, style: inputStyle, inputMode: "numeric" }
55
52
  }, sx: buttons
56
53
  ? {
57
54
  "& input[type=number]::-webkit-inner-spin-button": {
@@ -115,4 +112,4 @@ exports.IntInputField = react_1.default.forwardRef((props, ref) => {
115
112
  }, children: (0, jsx_runtime_1.jsx)(Add_1.default, { color: localValue == null ? undefined : "primary" }) })] }));
116
113
  else
117
114
  return layout;
118
- });
115
+ }
@@ -1,8 +1,8 @@
1
- import { TextFieldProps } from "@mui/material/TextField";
1
+ import { InputFieldProps } from "./InputField";
2
2
  /**
3
3
  * Mobile input props
4
4
  */
5
- export type MobileInputProps = Omit<TextFieldProps, "type"> & {};
5
+ export type MobileInputProps = Omit<InputFieldProps, "type"> & {};
6
6
  /**
7
7
  * Mobile input
8
8
  * @param props Props
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MobileInput = MobileInput;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const TextField_1 = __importDefault(require("@mui/material/TextField"));
9
5
  const ReactApp_1 = require("./app/ReactApp");
10
6
  const MUGlobal_1 = require("./MUGlobal");
7
+ const InputField_1 = require("./InputField");
11
8
  /**
12
9
  * Mobile input
13
10
  * @param props Props
@@ -20,7 +17,7 @@ function MobileInput(props) {
20
17
  // Slot props
21
18
  const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
22
19
  // Layout
23
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
20
+ return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
24
21
  htmlInput: { inputMode: "tel", maxLength: 18, ...htmlInput },
25
22
  inputLabel: { shrink: MUGlobal_1.MUGlobal.inputFieldShrink, ...inputLabel },
26
23
  ...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 const MoneyInputField: React.ForwardRefExoticComponent<Omit<MoneyInputFieldProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ export declare function MoneyInputField(props: MoneyInputFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MoneyInputField = void 0;
3
+ exports.MoneyInputField = MoneyInputField;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = __importDefault(require("react"));
9
5
  const IntInputField_1 = require("./IntInputField");
10
6
  /**
11
7
  * Money input field (controlled)
12
8
  */
13
- exports.MoneyInputField = react_1.default.forwardRef((props, ref) => {
9
+ function MoneyInputField(props) {
14
10
  // Destruct
15
11
  const { step = 0.01, ...rest } = props;
16
12
  // Layout
17
- return (0, jsx_runtime_1.jsx)(IntInputField_1.IntInputField, { ref: ref, step: step, ...rest });
18
- });
13
+ return (0, jsx_runtime_1.jsx)(IntInputField_1.IntInputField, { step: step, ...rest });
14
+ }
@@ -1,10 +1,10 @@
1
- import { TextFieldProps } from "@mui/material/TextField";
1
+ import { InputFieldProps } from "./InputField";
2
2
  /**
3
3
  * Phone input props
4
4
  */
5
- export type PhoneInputProps = Omit<TextFieldProps, "type"> & {};
5
+ export type PhoneInputProps = Omit<InputFieldProps, "type"> & {};
6
6
  /**
7
7
  * Phone input
8
8
  * @param props Props
9
9
  */
10
- export declare function PhoInput(props: PhoneInputProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function PhoneInput(props: PhoneInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PhoInput = PhoInput;
3
+ exports.PhoneInput = PhoneInput;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const TextField_1 = __importDefault(require("@mui/material/TextField"));
9
5
  const ReactApp_1 = require("./app/ReactApp");
10
6
  const MUGlobal_1 = require("./MUGlobal");
7
+ const InputField_1 = require("./InputField");
11
8
  /**
12
9
  * Phone input
13
10
  * @param props Props
14
11
  */
15
- function PhoInput(props) {
12
+ function PhoneInput(props) {
16
13
  // Global app
17
14
  const app = (0, ReactApp_1.useAppContext)();
18
15
  // Destruct
@@ -20,7 +17,7 @@ function PhoInput(props) {
20
17
  // Slot props
21
18
  const { htmlInput, inputLabel, ...restSlotProps } = slotProps ?? {};
22
19
  // Layout
23
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
20
+ return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "tel", autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, autoComplete: autoComplete, fullWidth: fullWidth, label: label, name: name, slotProps: {
24
21
  htmlInput: { inputMode: "tel", maxLength: 18, ...htmlInput },
25
22
  inputLabel: { shrink: MUGlobal_1.MUGlobal.inputFieldShrink, ...inputLabel },
26
23
  ...restSlotProps
@@ -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 const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("@mui/material/TextField").StandardTextFieldProps & {
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/TextField").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/TextField").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;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TextFieldEx = void 0;
6
+ exports.TextFieldEx = TextFieldEx;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const MUGlobal_1 = require("./MUGlobal");
@@ -15,13 +15,15 @@ const ReactApp_1 = require("./app/ReactApp");
15
15
  const TextField_1 = __importDefault(require("@mui/material/TextField"));
16
16
  const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
17
17
  const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
18
- exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
18
+ function TextFieldEx(props) {
19
19
  // Global app
20
20
  const app = (0, ReactApp_1.useAppContext)();
21
21
  // Labels
22
22
  const { showIt, clearInput } = app?.getLabels("showIt", "clearInput") ?? {};
23
23
  // Destructure
24
- const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal_1.MUGlobal.textFieldVariant, ...rest } = props;
24
+ const { changeDelay, clearLabel = clearInput, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, slotProps, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal_1.MUGlobal.textFieldVariant, mRef, ...rest } = props;
25
+ // Slot props
26
+ const { input, inputLabel, ...restSlotProps } = slotProps ?? {};
25
27
  // Shrink
26
28
  InputLabelProps.shrink ??= MUGlobal_1.MUGlobal.searchFieldShrink;
27
29
  // State
@@ -38,18 +40,18 @@ exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
38
40
  helperTextEx = errorText;
39
41
  }
40
42
  let typeEx = showPassword ? "password" : type;
41
- let input;
43
+ let inputEle;
42
44
  const localRef = (ref) => {
43
- input = ref;
44
- if (input.value !== "") {
45
+ inputEle = ref;
46
+ if (inputEle.value !== "") {
45
47
  updateEmpty(false);
46
48
  }
47
49
  };
48
50
  const doClear = () => {
49
- if (input == null)
51
+ if (inputEle == null)
50
52
  return;
51
- react_2.ReactUtils.triggerChange(input, "", false);
52
- input.focus();
53
+ react_2.ReactUtils.triggerChange(inputEle, "", false);
54
+ inputEle.focus();
53
55
  };
54
56
  const clearClick = () => {
55
57
  if (onClear) {
@@ -68,23 +70,23 @@ exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
68
70
  };
69
71
  const touchStart = async (e) => {
70
72
  // Show the password
71
- if (input) {
73
+ if (inputEle) {
72
74
  if (onVisibility) {
73
- const result = await onVisibility(input);
75
+ const result = await onVisibility(inputEle);
74
76
  if (result === false)
75
77
  return;
76
78
  }
77
- input.blur();
78
- input.type = "text";
79
+ inputEle.blur();
80
+ inputEle.type = "text";
79
81
  }
80
82
  preventDefault(e);
81
83
  };
82
84
  const touchEnd = (e) => {
83
85
  // Show the password
84
- if (input) {
86
+ if (inputEle) {
85
87
  if (onVisibility)
86
88
  return;
87
- input.type = "password";
89
+ inputEle.type = "password";
88
90
  }
89
91
  preventDefault(e);
90
92
  };
@@ -105,7 +107,7 @@ exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
105
107
  onKeyDown(e);
106
108
  }
107
109
  };
108
- react_1.default.useImperativeHandle(ref, () => ({
110
+ react_1.default.useImperativeHandle(mRef, () => ({
109
111
  /**
110
112
  * Set error
111
113
  * @param error Error
@@ -146,5 +148,12 @@ exports.TextFieldEx = react_1.default.forwardRef((props, ref) => {
146
148
  };
147
149
  }, []);
148
150
  // Textfield
149
- return ((0, jsx_runtime_1.jsx)(TextField_1.default, { error: errorEx, fullWidth: fullWidth, helperText: helperTextEx, inputRef: (0, react_2.useCombinedRefs)(inputRef, localRef), InputProps: InputProps, InputLabelProps: InputLabelProps, onChange: onChangeEx, onKeyDown: onKeyPressEx, type: typeEx, variant: variant, ...rest }));
150
- });
151
+ return ((0, jsx_runtime_1.jsx)(TextField_1.default, { error: errorEx, fullWidth: fullWidth, helperText: helperTextEx, inputRef: (0, react_2.useCombinedRefs)(inputRef, localRef), onChange: onChangeEx, onKeyDown: onKeyPressEx, slotProps: {
152
+ input: { readOnly, ...input, ...InputProps },
153
+ inputLabel: {
154
+ shrink: MUGlobal_1.MUGlobal.inputFieldShrink,
155
+ ...inputLabel
156
+ },
157
+ ...restSlotProps
158
+ }, type: typeEx, variant: variant, ...rest }));
159
+ }