@etsoo/materialui 1.1.50 → 1.1.51
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/TagList.js +6 -3
- package/package.json +1 -1
- package/src/TagList.tsx +9 -0
package/lib/TagList.js
CHANGED
|
@@ -12,7 +12,7 @@ export function TagList(props) {
|
|
|
12
12
|
// Destruct
|
|
13
13
|
const { renderOption = (props, option, { selected }) => (React.createElement("li", { ...props },
|
|
14
14
|
React.createElement(Checkbox, { icon: React.createElement(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: React.createElement(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }),
|
|
15
|
-
option)), renderTags = (value, getTagProps) => value.map((option, index) => (React.createElement(Chip, { variant: "outlined", label: option, ...getTagProps({ index }) }))), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, label, inputProps, ...rest } = props;
|
|
15
|
+
option)), renderTags = (value, getTagProps) => value.map((option, index) => (React.createElement(Chip, { variant: "outlined", label: option, ...getTagProps({ index }) }))), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, ...rest } = props;
|
|
16
16
|
const [open, setOpen] = React.useState(false);
|
|
17
17
|
const [options, setOptions] = React.useState([]);
|
|
18
18
|
const loading = open && options.length === 0;
|
|
@@ -24,14 +24,17 @@ export function TagList(props) {
|
|
|
24
24
|
}
|
|
25
25
|
setOptions(result);
|
|
26
26
|
};
|
|
27
|
-
return (React.createElement(Autocomplete, { multiple: true, freeSolo: true, open: open, onOpen: () => {
|
|
27
|
+
return (React.createElement(Autocomplete, { multiple: true, freeSolo: true, filterOptions: (options, _state) => options, open: open, onOpen: () => {
|
|
28
28
|
setOpen(true);
|
|
29
29
|
if (options.length === 0) {
|
|
30
30
|
loadDataLocal();
|
|
31
31
|
}
|
|
32
32
|
}, onClose: () => {
|
|
33
33
|
setOpen(false);
|
|
34
|
-
}, options: options, loading: loading, renderOption: renderOption, renderTags: renderTags, renderInput: (params) => (React.createElement(InputField, { label: label, changeDelay: 480, onChange: async (event) => {
|
|
34
|
+
}, options: options, loading: loading, disableCloseOnSelect: disableCloseOnSelect, openOnFocus: openOnFocus, renderOption: renderOption, renderTags: renderTags, renderInput: (params) => (React.createElement(InputField, { label: label, changeDelay: 480, onChange: async (event) => {
|
|
35
|
+
// Stop bubble
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
event.stopPropagation();
|
|
35
38
|
await loadDataLocal(event.target.value);
|
|
36
39
|
}, ...inputProps, ...params })), getOptionDisabled: (item) => {
|
|
37
40
|
return item === moreLabel;
|
package/package.json
CHANGED
package/src/TagList.tsx
CHANGED
|
@@ -66,6 +66,8 @@ export function TagList(props: TagListProps) {
|
|
|
66
66
|
openText = openDefault,
|
|
67
67
|
loadData,
|
|
68
68
|
maxItems = 16,
|
|
69
|
+
disableCloseOnSelect = true,
|
|
70
|
+
openOnFocus = true,
|
|
69
71
|
label,
|
|
70
72
|
inputProps,
|
|
71
73
|
...rest
|
|
@@ -87,6 +89,7 @@ export function TagList(props: TagListProps) {
|
|
|
87
89
|
<Autocomplete<string, true, false, true>
|
|
88
90
|
multiple
|
|
89
91
|
freeSolo
|
|
92
|
+
filterOptions={(options, _state) => options}
|
|
90
93
|
open={open}
|
|
91
94
|
onOpen={() => {
|
|
92
95
|
setOpen(true);
|
|
@@ -99,6 +102,8 @@ export function TagList(props: TagListProps) {
|
|
|
99
102
|
}}
|
|
100
103
|
options={options}
|
|
101
104
|
loading={loading}
|
|
105
|
+
disableCloseOnSelect={disableCloseOnSelect}
|
|
106
|
+
openOnFocus={openOnFocus}
|
|
102
107
|
renderOption={renderOption}
|
|
103
108
|
renderTags={renderTags}
|
|
104
109
|
renderInput={(params) => (
|
|
@@ -106,6 +111,10 @@ export function TagList(props: TagListProps) {
|
|
|
106
111
|
label={label}
|
|
107
112
|
changeDelay={480}
|
|
108
113
|
onChange={async (event) => {
|
|
114
|
+
// Stop bubble
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
event.stopPropagation();
|
|
117
|
+
|
|
109
118
|
await loadDataLocal(event.target.value);
|
|
110
119
|
}}
|
|
111
120
|
{...inputProps}
|