@selfcommunity/react-ui 0.11.0-alpha.114 → 0.11.0-alpha.115
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/cjs/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +1 -1
- package/lib/cjs/components/CategoryAutocomplete/CategoryAutocomplete.js +1 -3
- package/lib/cjs/components/TagAutocomplete/TagAutocomplete.js +5 -4
- package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +1 -1
- package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.js +1 -3
- package/lib/esm/components/TagAutocomplete/TagAutocomplete.js +5 -4
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutocompleteProps, TextFieldProps } from '@mui/material';
|
|
2
2
|
import { SCCategoryType } from '@selfcommunity/types';
|
|
3
|
-
export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCategoryType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCCategoryType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | '
|
|
3
|
+
export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCategoryType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCCategoryType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
|
|
4
4
|
/**
|
|
5
5
|
* The maximum number of categories that will be visible when not focused.
|
|
6
6
|
* @default 0
|
|
@@ -56,9 +56,6 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
56
56
|
// HOOKS
|
|
57
57
|
const { categories, isLoading } = (0, react_core_1.useSCFetchCategories)({ endpointQueryParams });
|
|
58
58
|
(0, react_1.useEffect)(() => {
|
|
59
|
-
if (value === null) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
59
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
63
60
|
}, [value]);
|
|
64
61
|
(0, react_1.useEffect)(() => {
|
|
@@ -83,6 +80,7 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
83
80
|
newValue = value;
|
|
84
81
|
}
|
|
85
82
|
setValue(newValue);
|
|
83
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
86
84
|
};
|
|
87
85
|
// Render
|
|
88
86
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root, multiple: multiple, open: open, onOpen: handleOpen, onClose: handleClose, filterSelectedOptions: !checkboxSelect, disableCloseOnSelect: checkboxSelect, options: categories || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryAutocomplete.empty", defaultMessage: "ui.categoryAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
@@ -81,9 +81,7 @@ const TagAutocomplete = (inProps) => {
|
|
|
81
81
|
}
|
|
82
82
|
}, [open, inputValue]);
|
|
83
83
|
(0, react_1.useEffect)(() => {
|
|
84
|
-
|
|
85
|
-
onChange && onChange(value);
|
|
86
|
-
}
|
|
84
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
87
85
|
}, [value]);
|
|
88
86
|
(0, react_1.useEffect)(() => {
|
|
89
87
|
const loadDefault = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -108,7 +106,10 @@ const TagAutocomplete = (inProps) => {
|
|
|
108
106
|
}
|
|
109
107
|
};
|
|
110
108
|
const handleClose = () => setOpen(false);
|
|
111
|
-
const handleChange = (_event, newValue) =>
|
|
109
|
+
const handleChange = (_event, newValue) => {
|
|
110
|
+
setValue(newValue);
|
|
111
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
112
|
+
};
|
|
112
113
|
const filterOptions = (0, react_1.useCallback)((options, state) => {
|
|
113
114
|
const search = state.inputValue.toLowerCase();
|
|
114
115
|
return options.filter((option) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutocompleteProps, TextFieldProps } from '@mui/material';
|
|
2
2
|
import { SCCategoryType } from '@selfcommunity/types';
|
|
3
|
-
export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCategoryType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCCategoryType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | '
|
|
3
|
+
export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCategoryType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCCategoryType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
|
|
4
4
|
/**
|
|
5
5
|
* The maximum number of categories that will be visible when not focused.
|
|
6
6
|
* @default 0
|
|
@@ -54,9 +54,6 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
54
54
|
// HOOKS
|
|
55
55
|
const { categories, isLoading } = useSCFetchCategories({ endpointQueryParams });
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
if (value === null) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
57
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
61
58
|
}, [value]);
|
|
62
59
|
useEffect(() => {
|
|
@@ -81,6 +78,7 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
81
78
|
newValue = value;
|
|
82
79
|
}
|
|
83
80
|
setValue(newValue);
|
|
81
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
84
82
|
};
|
|
85
83
|
// Render
|
|
86
84
|
return (_jsx(Root, Object.assign({ className: classes.root, multiple: multiple, open: open, onOpen: handleOpen, onClose: handleClose, filterSelectedOptions: !checkboxSelect, disableCloseOnSelect: checkboxSelect, options: categories || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: _jsx(FormattedMessage, { id: "ui.categoryAutocomplete.empty", defaultMessage: "ui.categoryAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
@@ -79,9 +79,7 @@ const TagAutocomplete = (inProps) => {
|
|
|
79
79
|
}
|
|
80
80
|
}, [open, inputValue]);
|
|
81
81
|
useEffect(() => {
|
|
82
|
-
|
|
83
|
-
onChange && onChange(value);
|
|
84
|
-
}
|
|
82
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
85
83
|
}, [value]);
|
|
86
84
|
useEffect(() => {
|
|
87
85
|
const loadDefault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -106,7 +104,10 @@ const TagAutocomplete = (inProps) => {
|
|
|
106
104
|
}
|
|
107
105
|
};
|
|
108
106
|
const handleClose = () => setOpen(false);
|
|
109
|
-
const handleChange = (_event, newValue) =>
|
|
107
|
+
const handleChange = (_event, newValue) => {
|
|
108
|
+
setValue(newValue);
|
|
109
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
110
|
+
};
|
|
110
111
|
const filterOptions = useCallback((options, state) => {
|
|
111
112
|
const search = state.inputValue.toLowerCase();
|
|
112
113
|
return options.filter((option) => {
|