ish-ui 1.3.9 → 1.4.0
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/dist/model/Fields.d.ts
CHANGED
|
@@ -32,9 +32,9 @@ export interface MenuTag<T> {
|
|
|
32
32
|
queryPrefix?: string;
|
|
33
33
|
indeterminate?: boolean;
|
|
34
34
|
}
|
|
35
|
-
export interface FieldInputProps {
|
|
35
|
+
export interface FieldInputProps<T = any> {
|
|
36
36
|
checked?: boolean | undefined;
|
|
37
|
-
value:
|
|
37
|
+
value: T;
|
|
38
38
|
name: string;
|
|
39
39
|
onBlur: EventOrValueHandler<FocusEvent<any>>;
|
|
40
40
|
onChange: EventOrValueHandler<ChangeEvent<any>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldInputProps, FieldMetaProps, TagLike, TagsFieldProps } from '../model';
|
|
3
|
-
declare function TagInputList<T extends TagLike, IP extends FieldInputProps
|
|
3
|
+
declare function TagInputList<T extends TagLike, IP extends FieldInputProps<TagLike['id'][]>, MP extends FieldMetaProps>({ input, tags, placeholder, labelAdornment, meta, label, disabled, className, warning, allowParentSelect, fieldClasses, editIcon, variant, hideColor, trackCarretPosition }: TagsFieldProps<T, IP, MP>): React.JSX.Element;
|
|
4
4
|
export default TagInputList;
|
|
@@ -110,8 +110,9 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
110
110
|
const tagMenuNode = useRef(undefined);
|
|
111
111
|
const menuTags = useMemo(() => (tags && input.value ? getMenuTags(tags.filter(t => allowParentSelect || t.childrenCount > 0), input.value) : []), [tags, input.value, allowParentSelect]);
|
|
112
112
|
const allMenuTags = useMemo(() => getAllMenuTags(menuTags), [menuTags]);
|
|
113
|
+
const normalizedValue = useMemo(() => { var _a; return ((_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.filter(id => allMenuTags.some(t => t.tagBody.id === id))) || []; }, [input.value, allMenuTags]);
|
|
113
114
|
const onTagAdd = (tag) => {
|
|
114
|
-
const updated = [...
|
|
115
|
+
const updated = [...normalizedValue];
|
|
115
116
|
const index = updated.findIndex(id => id === tag.tagBody.id);
|
|
116
117
|
if (index !== -1) {
|
|
117
118
|
updated.splice(index, 1);
|
|
@@ -189,7 +190,7 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
189
190
|
return (React.createElement("div", { className: className, id: input.name },
|
|
190
191
|
React.createElement("div", { className: cx('relative', {
|
|
191
192
|
'pointer-events-none': disabled
|
|
192
|
-
}) }, React.createElement(Autocomplete, { value:
|
|
193
|
+
}) }, React.createElement(Autocomplete, { value: normalizedValue, multiple: true, open: menuIsOpen, options: filteredOptions, onBlur: exit, onChange: handleChange, renderOption: renderOption, filterOptions: filterOptionsInner, getOptionLabel: getOptionLabel, slots: {
|
|
193
194
|
popper: inputValue || !trackCarretPosition ? undefined : popperAdapter,
|
|
194
195
|
listbox: inputValue ? undefined : listboxAdapter
|
|
195
196
|
}, classes: {
|
|
@@ -224,12 +225,15 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
224
225
|
color: textColors.dark
|
|
225
226
|
}
|
|
226
227
|
} })));
|
|
227
|
-
}), renderInput: (_a) => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
}), renderInput: (_a) => {
|
|
229
|
+
var { slotProps: { input: InputProps, htmlInput: inputProps } } = _a, params = __rest(_a, ["slotProps"]);
|
|
230
|
+
return (React.createElement(EditInPlaceFieldBase, Object.assign({}, params, { value: inputValue, variant: variant, name: input.name, error: meta.error, invalid: meta === null || meta === void 0 ? void 0 : meta.invalid, label: label, warning: warning, disabled: disabled, fieldClasses: fieldClasses, shrink: Boolean(label || input.value), labelAdornment: labelAdornment, placeholder: normalizedValue.length ? '' : placeholder, editIcon: editIcon === undefined ? React.createElement(Edit, { className: classes.expandIcon }) : editIcon, InputProps: Object.assign(Object.assign({}, InputProps), { endAdornment: null, onChange: handleInputChange, onFocus, classes: {
|
|
231
|
+
underline: fieldClasses.underline,
|
|
232
|
+
input: cx(disabled && classes.readonly, fieldClasses.text),
|
|
233
|
+
}, inputProps: Object.assign(Object.assign({}, inputProps), { ref: ref => {
|
|
234
|
+
inputProps.ref.current = ref;
|
|
235
|
+
inputNode.current = ref;
|
|
236
|
+
}, className: cx(inputProps.className, fieldClasses.text, 'mr-auto') }) }) })));
|
|
237
|
+
}, popupIcon: stubComponent(), disableListWrap: true, openOnFocus: true }))));
|
|
234
238
|
}
|
|
235
239
|
export default TagInputList;
|