@etsoo/materialui 1.3.81 → 1.3.83

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.
@@ -8,6 +8,10 @@ export type TextFieldExProps = TextFieldProps & {
8
8
  * Change delay (ms) to avoid repeatly dispatch onChange
9
9
  */
10
10
  changeDelay?: number;
11
+ /**
12
+ * Click clear button callback
13
+ */
14
+ onClear?: (doClear: () => void) => void;
11
15
  /**
12
16
  * On enter click
13
17
  */
@@ -46,6 +50,10 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
46
50
  * Change delay (ms) to avoid repeatly dispatch onChange
47
51
  */
48
52
  changeDelay?: number;
53
+ /**
54
+ * Click clear button callback
55
+ */
56
+ onClear?: (doClear: () => void) => void;
49
57
  /**
50
58
  * On enter click
51
59
  */
@@ -73,6 +81,10 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
73
81
  * Change delay (ms) to avoid repeatly dispatch onChange
74
82
  */
75
83
  changeDelay?: number;
84
+ /**
85
+ * Click clear button callback
86
+ */
87
+ onClear?: (doClear: () => void) => void;
76
88
  /**
77
89
  * On enter click
78
90
  */
@@ -100,6 +112,10 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Omit<import("
100
112
  * Change delay (ms) to avoid repeatly dispatch onChange
101
113
  */
102
114
  changeDelay?: number;
115
+ /**
116
+ * Click clear button callback
117
+ */
118
+ onClear?: (doClear: () => void) => void;
103
119
  /**
104
120
  * On enter click
105
121
  */
@@ -7,7 +7,7 @@ import { Keyboard } from "@etsoo/shared";
7
7
  import { ReactUtils, useCombinedRefs, useDelayedExecutor } from "@etsoo/react";
8
8
  export const TextFieldEx = React.forwardRef((props, ref) => {
9
9
  // Destructure
10
- const { changeDelay, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, ...rest } = props;
10
+ const { changeDelay, error, fullWidth = true, helperText, InputLabelProps = {}, InputProps = {}, onChange, onClear, onKeyDown, onEnter, onVisibility, inputRef, readOnly, showClear, showPassword, type, variant = MUGlobal.textFieldVariant, ...rest } = props;
11
11
  // Shrink
12
12
  InputLabelProps.shrink ?? (InputLabelProps.shrink = MUGlobal.searchFieldShrink);
13
13
  // State
@@ -31,10 +31,18 @@ export const TextFieldEx = React.forwardRef((props, ref) => {
31
31
  updateEmpty(false);
32
32
  }
33
33
  };
34
+ const doClear = () => {
35
+ if (input == null)
36
+ return;
37
+ ReactUtils.triggerChange(input, "", false);
38
+ input.focus();
39
+ };
34
40
  const clearClick = () => {
35
- if (input != null) {
36
- ReactUtils.triggerChange(input, "", false);
37
- input.focus();
41
+ if (onClear) {
42
+ onClear(doClear);
43
+ }
44
+ else {
45
+ doClear();
38
46
  }
39
47
  };
40
48
  const preventDefault = (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.81",
3
+ "version": "1.3.83",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -19,6 +19,11 @@ export type TextFieldExProps = TextFieldProps & {
19
19
  */
20
20
  changeDelay?: number;
21
21
 
22
+ /**
23
+ * Click clear button callback
24
+ */
25
+ onClear?: (doClear: () => void) => void;
26
+
22
27
  /**
23
28
  * On enter click
24
29
  */
@@ -71,6 +76,7 @@ export const TextFieldEx = React.forwardRef<
71
76
  InputLabelProps = {},
72
77
  InputProps = {},
73
78
  onChange,
79
+ onClear,
74
80
  onKeyDown,
75
81
  onEnter,
76
82
  onVisibility,
@@ -112,10 +118,17 @@ export const TextFieldEx = React.forwardRef<
112
118
  }
113
119
  };
114
120
 
121
+ const doClear = () => {
122
+ if (input == null) return;
123
+ ReactUtils.triggerChange(input, "", false);
124
+ input.focus();
125
+ };
126
+
115
127
  const clearClick = () => {
116
- if (input != null) {
117
- ReactUtils.triggerChange(input, "", false);
118
- input.focus();
128
+ if (onClear) {
129
+ onClear(doClear);
130
+ } else {
131
+ doClear();
119
132
  }
120
133
  };
121
134