@etsoo/materialui 1.1.72 → 1.1.74
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/ComboBoxPro.js +8 -3
- package/lib/TagList.js +5 -1
- package/lib/TagListPro.js +4 -0
- package/package.json +1 -1
- package/src/ComboBoxPro.tsx +14 -3
- package/src/TagList.tsx +4 -0
- package/src/TagListPro.tsx +4 -0
package/lib/ComboBoxPro.js
CHANGED
|
@@ -14,7 +14,7 @@ export function ComboBoxPro(props) {
|
|
|
14
14
|
const [localValue, setValue] = React.useState(null);
|
|
15
15
|
const [loading, setLoading] = React.useState(false);
|
|
16
16
|
React.useEffect(() => {
|
|
17
|
-
if (value
|
|
17
|
+
if (value === undefined)
|
|
18
18
|
return;
|
|
19
19
|
setValue(value);
|
|
20
20
|
}, [value]);
|
|
@@ -24,6 +24,8 @@ export function ComboBoxPro(props) {
|
|
|
24
24
|
const option = localOptions.find((option) => option.id === idValue);
|
|
25
25
|
if (option)
|
|
26
26
|
setValue(option);
|
|
27
|
+
else
|
|
28
|
+
setValue(null);
|
|
27
29
|
}, [localOptions]);
|
|
28
30
|
React.useEffect(() => {
|
|
29
31
|
if (typeof options === "function") {
|
|
@@ -38,11 +40,14 @@ export function ComboBoxPro(props) {
|
|
|
38
40
|
setOptions(options);
|
|
39
41
|
}
|
|
40
42
|
}, [options]);
|
|
41
|
-
return (React.createElement(Autocomplete, { id: name, value: localValue, open: open, freeSolo: true, onOpen: () => {
|
|
43
|
+
return (React.createElement(Autocomplete, { id: name, value: localValue == null ? "" : localValue, open: open, freeSolo: true, clearOnBlur: false, onOpen: () => {
|
|
42
44
|
setOpen(true);
|
|
43
45
|
}, onClose: () => {
|
|
44
46
|
setOpen(false);
|
|
45
|
-
}, options: localOptions, loading: loading, openOnFocus: openOnFocus, renderInput: (params) => (React.createElement(InputField, { ...inputProps, ...params, label: label, name: name
|
|
47
|
+
}, options: localOptions, loading: loading, openOnFocus: openOnFocus, renderInput: (params) => (React.createElement(InputField, { ...inputProps, ...params, label: label, name: name, onBlur: (event) => {
|
|
48
|
+
if (localValue == null && onChange)
|
|
49
|
+
onChange(event, event.target.value, "blur", undefined);
|
|
50
|
+
} })), getOptionLabel: (item) => typeof item === "object" ? getLabel(item) : item, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, onChange: (event, value, reason, details) => {
|
|
46
51
|
setValue(value);
|
|
47
52
|
if (onChange)
|
|
48
53
|
onChange(event, value, reason, details);
|
package/lib/TagList.js
CHANGED
|
@@ -30,6 +30,10 @@ export function TagList(props) {
|
|
|
30
30
|
if (len >= maxItems) {
|
|
31
31
|
result.push(moreLabel);
|
|
32
32
|
}
|
|
33
|
+
else if (len === 0) {
|
|
34
|
+
// When no result, hide the popup
|
|
35
|
+
setOpen(false);
|
|
36
|
+
}
|
|
33
37
|
setOptions(result);
|
|
34
38
|
setLoading(false);
|
|
35
39
|
};
|
|
@@ -40,7 +44,7 @@ export function TagList(props) {
|
|
|
40
44
|
}
|
|
41
45
|
}, onClose: () => {
|
|
42
46
|
setOpen(false);
|
|
43
|
-
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, openOnFocus: openOnFocus, renderOption: renderOption, renderTags: renderTags, renderInput: (params) => (React.createElement(InputField, { label: label, changeDelay: 480, onChange: async (event) => {
|
|
47
|
+
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, clearOnBlur: true, openOnFocus: openOnFocus, renderOption: renderOption, renderTags: renderTags, renderInput: (params) => (React.createElement(InputField, { label: label, changeDelay: 480, onChange: async (event) => {
|
|
44
48
|
// Stop bubble
|
|
45
49
|
event.preventDefault();
|
|
46
50
|
event.stopPropagation();
|
package/lib/TagListPro.js
CHANGED
package/package.json
CHANGED
package/src/ComboBoxPro.tsx
CHANGED
|
@@ -72,7 +72,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
72
72
|
const [loading, setLoading] = React.useState(false);
|
|
73
73
|
|
|
74
74
|
React.useEffect(() => {
|
|
75
|
-
if (value
|
|
75
|
+
if (value === undefined) return;
|
|
76
76
|
setValue(value);
|
|
77
77
|
}, [value]);
|
|
78
78
|
|
|
@@ -80,6 +80,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
80
80
|
if (idValue == null) return;
|
|
81
81
|
const option = localOptions.find((option) => option.id === idValue);
|
|
82
82
|
if (option) setValue(option);
|
|
83
|
+
else setValue(null);
|
|
83
84
|
}, [localOptions]);
|
|
84
85
|
|
|
85
86
|
React.useEffect(() => {
|
|
@@ -97,9 +98,10 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
97
98
|
return (
|
|
98
99
|
<Autocomplete<D, false, false, true>
|
|
99
100
|
id={name}
|
|
100
|
-
value={localValue}
|
|
101
|
+
value={localValue == null ? "" : localValue}
|
|
101
102
|
open={open}
|
|
102
103
|
freeSolo
|
|
104
|
+
clearOnBlur={false}
|
|
103
105
|
onOpen={() => {
|
|
104
106
|
setOpen(true);
|
|
105
107
|
}}
|
|
@@ -110,7 +112,16 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
110
112
|
loading={loading}
|
|
111
113
|
openOnFocus={openOnFocus}
|
|
112
114
|
renderInput={(params) => (
|
|
113
|
-
<InputField
|
|
115
|
+
<InputField
|
|
116
|
+
{...inputProps}
|
|
117
|
+
{...params}
|
|
118
|
+
label={label}
|
|
119
|
+
name={name}
|
|
120
|
+
onBlur={(event) => {
|
|
121
|
+
if (localValue == null && onChange)
|
|
122
|
+
onChange(event, event.target.value, "blur", undefined);
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
114
125
|
)}
|
|
115
126
|
getOptionLabel={(item) =>
|
|
116
127
|
typeof item === "object" ? getLabel(item) : item
|
package/src/TagList.tsx
CHANGED
|
@@ -94,6 +94,9 @@ export function TagList(props: TagListProps) {
|
|
|
94
94
|
|
|
95
95
|
if (len >= maxItems) {
|
|
96
96
|
result.push(moreLabel);
|
|
97
|
+
} else if (len === 0) {
|
|
98
|
+
// When no result, hide the popup
|
|
99
|
+
setOpen(false);
|
|
97
100
|
}
|
|
98
101
|
setOptions(result);
|
|
99
102
|
setLoading(false);
|
|
@@ -117,6 +120,7 @@ export function TagList(props: TagListProps) {
|
|
|
117
120
|
options={options}
|
|
118
121
|
loading={loading}
|
|
119
122
|
disableCloseOnSelect={disableCloseOnSelect}
|
|
123
|
+
clearOnBlur
|
|
120
124
|
openOnFocus={openOnFocus}
|
|
121
125
|
renderOption={renderOption}
|
|
122
126
|
renderTags={renderTags}
|
package/src/TagListPro.tsx
CHANGED
|
@@ -108,7 +108,11 @@ export function TagListPro<D extends DataType = DataType>(
|
|
|
108
108
|
|
|
109
109
|
if (len >= maxItems) {
|
|
110
110
|
result.push({ id: -1, name: moreLabel } as D);
|
|
111
|
+
} else if (len === 0) {
|
|
112
|
+
// When no result, hide the popup
|
|
113
|
+
setOpen(false);
|
|
111
114
|
}
|
|
115
|
+
|
|
112
116
|
setOptions(result);
|
|
113
117
|
setLoading(false);
|
|
114
118
|
};
|