@astral/ui 1.0.0-test.1671604949 → 1.0.0-test.1671661242
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.
|
@@ -24,16 +24,19 @@ const Checkbox_1 = require("../Checkbox");
|
|
|
24
24
|
const OverflowTypography_1 = require("../OverflowTypography");
|
|
25
25
|
const constants_1 = require("./constants");
|
|
26
26
|
const Autocomplete = (props) => {
|
|
27
|
-
const { multiple, placeholder, error, success, helperText, label, size = 'medium', getOptionLabel, renderOption: externalRenderOption, isOptionEqualToValue, overflowOption } = props, restProps = __rest(props, ["multiple", "placeholder", "error", "success", "helperText", "label", "size", "getOptionLabel", "renderOption", "isOptionEqualToValue", "overflowOption"]);
|
|
27
|
+
const { multiple, placeholder, error, success, helperText, label, size = 'medium', getOptionLabel, renderOption: externalRenderOption, isOptionEqualToValue: externalOptionEqualToValue, overflowOption } = props, restProps = __rest(props, ["multiple", "placeholder", "error", "success", "helperText", "label", "size", "getOptionLabel", "renderOption", "isOptionEqualToValue", "overflowOption"]);
|
|
28
28
|
const renderTags = (0, react_2.useCallback)((tags, getTagProps) => {
|
|
29
29
|
return tags.map((tag, index) => {
|
|
30
30
|
const title = (getOptionLabel && getOptionLabel(tag)) || '';
|
|
31
31
|
return ((0, jsx_runtime_1.jsx)(Tag_1.Tag, Object.assign({ deleteIcon: (0, jsx_runtime_1.jsx)(icons_1.CrossSmOutlineSm, {}), color: "grey", label: title }, getTagProps({ index }))));
|
|
32
32
|
});
|
|
33
33
|
}, [getOptionLabel]);
|
|
34
|
-
const
|
|
34
|
+
const isOptionEqualToValue = (0, react_2.useCallback)((option, value) => {
|
|
35
|
+
if (externalOptionEqualToValue) {
|
|
36
|
+
return externalOptionEqualToValue(option, value);
|
|
37
|
+
}
|
|
35
38
|
return JSON.stringify(option) === JSON.stringify(value);
|
|
36
|
-
}, []);
|
|
39
|
+
}, [externalOptionEqualToValue]);
|
|
37
40
|
const renderInput = (0, react_2.useCallback)((inputParams) => ((0, jsx_runtime_1.jsx)(TextField_1.TextField, Object.assign({}, inputParams, { placeholder: placeholder, label: label, success: success, error: error, helperText: helperText, size: size }))), [placeholder, label, success, error, helperText, size]);
|
|
38
41
|
const renderOption = (0, react_2.useCallback)((optionProps, option, optionState) => {
|
|
39
42
|
if (externalRenderOption) {
|
|
@@ -44,6 +47,6 @@ const Autocomplete = (props) => {
|
|
|
44
47
|
multiple && ((0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { role: "menuitemcheckbox", checked: selected }) })),
|
|
45
48
|
(0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, Object.assign({ rowsCount: constants_1.DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT }, overflowOption, { children: optionProps.key }))));
|
|
46
49
|
}, [multiple, externalRenderOption]);
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, Object.assign({}, restProps, { size: size, multiple: multiple, getOptionLabel: getOptionLabel, disableCloseOnSelect: multiple, renderTags: renderTags, renderInput: renderInput, renderOption: renderOption, popupIcon: (0, jsx_runtime_1.jsx)(icons_1.ChevronDOutlineMd, {}), clearIcon: (0, jsx_runtime_1.jsx)(icons_1.CrossSmOutlineSm, {}), isOptionEqualToValue: isOptionEqualToValue
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, Object.assign({}, restProps, { size: size, multiple: multiple, getOptionLabel: getOptionLabel, disableCloseOnSelect: multiple, renderTags: renderTags, renderInput: renderInput, renderOption: renderOption, popupIcon: (0, jsx_runtime_1.jsx)(icons_1.ChevronDOutlineMd, {}), clearIcon: (0, jsx_runtime_1.jsx)(icons_1.CrossSmOutlineSm, {}), isOptionEqualToValue: isOptionEqualToValue, componentsProps: { clearIndicator: { disableRipple: true } }, noOptionsText: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })));
|
|
48
51
|
};
|
|
49
52
|
exports.Autocomplete = Autocomplete;
|
|
@@ -21,16 +21,19 @@ import { Checkbox } from '../Checkbox';
|
|
|
21
21
|
import { OverflowTypography, } from '../OverflowTypography';
|
|
22
22
|
import { DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT } from './constants';
|
|
23
23
|
export const Autocomplete = (props) => {
|
|
24
|
-
const { multiple, placeholder, error, success, helperText, label, size = 'medium', getOptionLabel, renderOption: externalRenderOption, isOptionEqualToValue, overflowOption } = props, restProps = __rest(props, ["multiple", "placeholder", "error", "success", "helperText", "label", "size", "getOptionLabel", "renderOption", "isOptionEqualToValue", "overflowOption"]);
|
|
24
|
+
const { multiple, placeholder, error, success, helperText, label, size = 'medium', getOptionLabel, renderOption: externalRenderOption, isOptionEqualToValue: externalOptionEqualToValue, overflowOption } = props, restProps = __rest(props, ["multiple", "placeholder", "error", "success", "helperText", "label", "size", "getOptionLabel", "renderOption", "isOptionEqualToValue", "overflowOption"]);
|
|
25
25
|
const renderTags = useCallback((tags, getTagProps) => {
|
|
26
26
|
return tags.map((tag, index) => {
|
|
27
27
|
const title = (getOptionLabel && getOptionLabel(tag)) || '';
|
|
28
28
|
return (_jsx(Tag, Object.assign({ deleteIcon: _jsx(CrossSmOutlineSm, {}), color: "grey", label: title }, getTagProps({ index }))));
|
|
29
29
|
});
|
|
30
30
|
}, [getOptionLabel]);
|
|
31
|
-
const
|
|
31
|
+
const isOptionEqualToValue = useCallback((option, value) => {
|
|
32
|
+
if (externalOptionEqualToValue) {
|
|
33
|
+
return externalOptionEqualToValue(option, value);
|
|
34
|
+
}
|
|
32
35
|
return JSON.stringify(option) === JSON.stringify(value);
|
|
33
|
-
}, []);
|
|
36
|
+
}, [externalOptionEqualToValue]);
|
|
34
37
|
const renderInput = useCallback((inputParams) => (_jsx(TextField, Object.assign({}, inputParams, { placeholder: placeholder, label: label, success: success, error: error, helperText: helperText, size: size }))), [placeholder, label, success, error, helperText, size]);
|
|
35
38
|
const renderOption = useCallback((optionProps, option, optionState) => {
|
|
36
39
|
if (externalRenderOption) {
|
|
@@ -41,5 +44,5 @@ export const Autocomplete = (props) => {
|
|
|
41
44
|
multiple && (_jsx(ListItemIcon, { children: _jsx(Checkbox, { role: "menuitemcheckbox", checked: selected }) })),
|
|
42
45
|
_jsx(OverflowTypography, Object.assign({ rowsCount: DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT }, overflowOption, { children: optionProps.key }))));
|
|
43
46
|
}, [multiple, externalRenderOption]);
|
|
44
|
-
return (_jsx(MuiAutocomplete, Object.assign({}, restProps, { size: size, multiple: multiple, getOptionLabel: getOptionLabel, disableCloseOnSelect: multiple, renderTags: renderTags, renderInput: renderInput, renderOption: renderOption, popupIcon: _jsx(ChevronDOutlineMd, {}), clearIcon: _jsx(CrossSmOutlineSm, {}), isOptionEqualToValue: isOptionEqualToValue
|
|
47
|
+
return (_jsx(MuiAutocomplete, Object.assign({}, restProps, { size: size, multiple: multiple, getOptionLabel: getOptionLabel, disableCloseOnSelect: multiple, renderTags: renderTags, renderInput: renderInput, renderOption: renderOption, popupIcon: _jsx(ChevronDOutlineMd, {}), clearIcon: _jsx(CrossSmOutlineSm, {}), isOptionEqualToValue: isOptionEqualToValue, componentsProps: { clearIndicator: { disableRipple: true } }, noOptionsText: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })));
|
|
45
48
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astral/ui",
|
|
3
|
-
"version": "1.0.0-test.
|
|
3
|
+
"version": "1.0.0-test.1671661242",
|
|
4
4
|
"browser": "./esm/index.js",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@astral/icons": "^1.0.0-test.
|
|
7
|
+
"@astral/icons": "^1.0.0-test.1671661242",
|
|
8
8
|
"@emotion/cache": "11.7.1",
|
|
9
9
|
"@emotion/react": "11.9.0",
|
|
10
10
|
"@emotion/server": "11.4.0",
|