@ozen-ui/kit 0.32.2 → 0.34.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/Autocomplete/package.json +5 -0
- package/__inner__/cjs/components/Autocomplete/Autocomplete.css +46 -0
- package/__inner__/cjs/components/Autocomplete/Autocomplete.d.ts +4 -0
- package/__inner__/cjs/components/Autocomplete/Autocomplete.js +202 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteLoading/AutocompleteLoading.d.ts +6 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteLoading/AutocompleteLoading.js +23 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteLoading/index.d.ts +1 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteLoading/index.js +4 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteNoOptions/AutocompleteNoOptions.d.ts +6 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteNoOptions/AutocompleteNoOptions.js +17 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteNoOptions/index.d.ts +1 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteNoOptions/index.js +4 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteRenderRight/AutocompleteRenderRight.d.ts +10 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteRenderRight/AutocompleteRenderRight.js +26 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteRenderRight/index.d.ts +1 -0
- package/__inner__/cjs/components/Autocomplete/components/AutocompleteRenderRight/index.js +4 -0
- package/__inner__/cjs/components/Autocomplete/components/index.d.ts +3 -0
- package/__inner__/cjs/components/Autocomplete/components/index.js +6 -0
- package/__inner__/cjs/components/Autocomplete/constants.d.ts +10 -0
- package/__inner__/cjs/components/Autocomplete/constants.js +13 -0
- package/__inner__/cjs/components/Autocomplete/helper.d.ts +166 -0
- package/__inner__/cjs/components/Autocomplete/helper.js +14 -0
- package/__inner__/cjs/components/Autocomplete/index.d.ts +2 -0
- package/__inner__/cjs/components/Autocomplete/index.js +5 -0
- package/__inner__/cjs/components/Autocomplete/types.d.ts +105 -0
- package/__inner__/cjs/components/Autocomplete/types.js +2 -0
- package/__inner__/cjs/components/DataList/DataList.js +1 -1
- package/__inner__/cjs/components/DataList/components/DataListOption/DataListOption.css +10 -2
- package/__inner__/cjs/components/DataList/helpers/useDataListNavigation.js +4 -12
- package/__inner__/cjs/components/List/List.css +5 -0
- package/__inner__/cjs/components/List/List.js +2 -2
- package/__inner__/cjs/components/List/constants.d.ts +1 -0
- package/__inner__/cjs/components/List/constants.js +2 -1
- package/__inner__/cjs/components/List/types.d.ts +2 -0
- package/__inner__/cjs/components/Popover/Popover.js +8 -7
- package/__inner__/cjs/components/Popover/constants.d.ts +2 -0
- package/__inner__/cjs/components/Popover/constants.js +3 -1
- package/__inner__/cjs/components/Popover/types.d.ts +6 -0
- package/__inner__/cjs/components/Popover/types.js +2 -1
- package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/cjs/components/Tooltip/Tooltip.js +1 -1
- package/__inner__/cjs/hooks/useEventListener/useEventListener.js +2 -4
- package/__inner__/cjs/hooks/useHover/useHover.d.ts +2 -2
- package/__inner__/cjs/hooks/useHover/useHover.js +2 -2
- package/__inner__/cjs/hooks/useMutableRef/index.d.ts +1 -0
- package/__inner__/cjs/hooks/useMutableRef/index.js +4 -0
- package/__inner__/cjs/hooks/useMutableRef/useMutableRef.d.ts +2 -0
- package/__inner__/cjs/hooks/useMutableRef/useMutableRef.js +10 -0
- package/__inner__/cjs/locale/locale.js +21 -0
- package/__inner__/esm/components/Autocomplete/Autocomplete.css +46 -0
- package/__inner__/esm/components/Autocomplete/Autocomplete.d.ts +4 -0
- package/__inner__/esm/components/Autocomplete/Autocomplete.js +199 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteLoading/AutocompleteLoading.d.ts +6 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteLoading/AutocompleteLoading.js +18 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteLoading/index.d.ts +1 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteLoading/index.js +1 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteNoOptions/AutocompleteNoOptions.d.ts +6 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteNoOptions/AutocompleteNoOptions.js +12 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteNoOptions/index.d.ts +1 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteNoOptions/index.js +1 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteRenderRight/AutocompleteRenderRight.d.ts +10 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteRenderRight/AutocompleteRenderRight.js +22 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteRenderRight/index.d.ts +1 -0
- package/__inner__/esm/components/Autocomplete/components/AutocompleteRenderRight/index.js +1 -0
- package/__inner__/esm/components/Autocomplete/components/index.d.ts +3 -0
- package/__inner__/esm/components/Autocomplete/components/index.js +3 -0
- package/__inner__/esm/components/Autocomplete/constants.d.ts +10 -0
- package/__inner__/esm/components/Autocomplete/constants.js +10 -0
- package/__inner__/esm/components/Autocomplete/helper.d.ts +166 -0
- package/__inner__/esm/components/Autocomplete/helper.js +7 -0
- package/__inner__/esm/components/Autocomplete/index.d.ts +2 -0
- package/__inner__/esm/components/Autocomplete/index.js +2 -0
- package/__inner__/esm/components/Autocomplete/types.d.ts +105 -0
- package/__inner__/esm/components/Autocomplete/types.js +1 -0
- package/__inner__/esm/components/DataList/DataList.js +1 -1
- package/__inner__/esm/components/DataList/components/DataListOption/DataListOption.css +10 -2
- package/__inner__/esm/components/DataList/helpers/useDataListNavigation.js +5 -13
- package/__inner__/esm/components/List/List.css +5 -0
- package/__inner__/esm/components/List/List.js +3 -3
- package/__inner__/esm/components/List/constants.d.ts +1 -0
- package/__inner__/esm/components/List/constants.js +1 -0
- package/__inner__/esm/components/List/types.d.ts +2 -0
- package/__inner__/esm/components/Popover/Popover.js +9 -8
- package/__inner__/esm/components/Popover/constants.d.ts +2 -0
- package/__inner__/esm/components/Popover/constants.js +2 -0
- package/__inner__/esm/components/Popover/types.d.ts +6 -0
- package/__inner__/esm/components/Popover/types.js +1 -0
- package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/esm/components/Tooltip/Tooltip.js +1 -1
- package/__inner__/esm/hooks/useEventListener/useEventListener.js +3 -5
- package/__inner__/esm/hooks/useHover/useHover.d.ts +2 -2
- package/__inner__/esm/hooks/useHover/useHover.js +2 -2
- package/__inner__/esm/hooks/useMutableRef/index.d.ts +1 -0
- package/__inner__/esm/hooks/useMutableRef/index.js +1 -0
- package/__inner__/esm/hooks/useMutableRef/useMutableRef.d.ts +2 -0
- package/__inner__/esm/hooks/useMutableRef/useMutableRef.js +6 -0
- package/__inner__/esm/locale/locale.js +21 -0
- package/package.json +1 -1
- package/useMutableRef/package.json +5 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.Autocomplete {
|
|
2
|
+
--autocomplete-gutter-x: 0 var(--textfield-gutter-x);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.Autocomplete_hasChevron.Autocomplete_size_2xs {
|
|
6
|
+
--autocomplete-gutter-x: 0 var(--control-padding-2xs) 0
|
|
7
|
+
var(--control-padding-xs);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.Autocomplete_hasChevron.Autocomplete_size_xs {
|
|
11
|
+
--autocomplete-gutter-x: 0 var(--control-padding-2xs) 0
|
|
12
|
+
var(--control-padding-xs);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.Autocomplete_hasChevron.Autocomplete_size_s {
|
|
16
|
+
--autocomplete-gutter-x: 0 var(--control-padding-2xs) 0
|
|
17
|
+
var(--control-padding-s);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.Autocomplete_hasChevron.Autocomplete_size_m {
|
|
21
|
+
--autocomplete-gutter-x: 0 var(--control-padding-2xs) 0
|
|
22
|
+
var(--control-padding-m);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.Autocomplete_hasChevron.Autocomplete_size_l {
|
|
26
|
+
--autocomplete-gutter-x: 0 var(--control-padding-2xs) 0
|
|
27
|
+
var(--control-padding-l);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.Autocomplete-RenderRight {
|
|
31
|
+
display: flex;
|
|
32
|
+
gap: var(--spacing-2xs);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.Autocomplete-ClearButton {
|
|
36
|
+
visibility: hidden;
|
|
37
|
+
transition: visibility var(--transition-default);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.Autocomplete-ClearButton_visibility {
|
|
41
|
+
visibility: visible;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.Autocomplete .Input-Body {
|
|
45
|
+
padding: var(--autocomplete-gutter-x);
|
|
46
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Autocomplete = exports.cnAutocomplete = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
require("./Autocomplete.css");
|
|
6
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
var useControlled_1 = require("../../hooks/useControlled");
|
|
8
|
+
var useMutableRef_1 = require("../../hooks/useMutableRef");
|
|
9
|
+
var useThemeProps_1 = require("../../hooks/useThemeProps");
|
|
10
|
+
var classname_1 = require("../../utils/classname");
|
|
11
|
+
var isKeys_1 = require("../../utils/isKeys");
|
|
12
|
+
var DataList_1 = require("../DataList");
|
|
13
|
+
var Input_1 = require("../Input");
|
|
14
|
+
var components_1 = require("./components");
|
|
15
|
+
var constants_1 = require("./constants");
|
|
16
|
+
var helper_1 = require("./helper");
|
|
17
|
+
exports.cnAutocomplete = (0, classname_1.cn)('Autocomplete');
|
|
18
|
+
function AutocompleteRender(inProps, ref) {
|
|
19
|
+
var props = (0, useThemeProps_1.useThemeProps)({
|
|
20
|
+
props: inProps,
|
|
21
|
+
name: 'Autocomplete',
|
|
22
|
+
});
|
|
23
|
+
var _a = (0, helper_1.withDefaultGetters)(props), _b = _a.disabled, disabled = _b === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_DISABLED : _b, _c = _a.required, required = _c === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_REQUIRED : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_AUTOFOCUS : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_FULLWIDTH : _e, _f = _a.size, size = _f === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_SIZE : _f, _g = _a.allowCustomValue, allowCustomValue = _g === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE : _g, _h = _a.disableShowChevron, disableShowChevron = _h === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON : _h, _j = _a.disableClearButton, disableClearButton = _j === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON : _j, _k = _a.disableShowEmptyOptionsList, disableShowEmptyOptionsList = _k === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST : _k, _l = _a.disableCloseOnSelect, disableCloseOnSelect = _l === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT : _l, _m = _a.renderInput, renderInput = _m === void 0 ? function (props) { return react_1.default.createElement(Input_1.Input, tslib_1.__assign({}, props, { ref: ref })); } : _m, searchFunctionProp = _a.searchFunction, renderOptionProp = _a.renderOption, inputValueProp = _a.inputValue, className = _a.className, valueProp = _a.value, options = _a.options, defaultValue = _a.defaultValue, error = _a.error, onChange = _a.onChange, onInputChange = _a.onInputChange, label = _a.label, placeholder = _a.placeholder, renderLeft = _a.renderLeft, hint = _a.hint, getOptionKey = _a.getOptionKey, getOptionLabel = _a.getOptionLabel, getOptionDisabled = _a.getOptionDisabled, dataListProps = _a.dataListProps, onCloseProp = _a.onClose, onOpenProp = _a.onOpen, openProp = _a.open, defaultOpen = _a.defaultOpen, loading = _a.loading, inputProps = _a.inputProps, onKeyDown = _a.onKeyDown, noOptionsText = _a.noOptionsText, clearText = _a.clearText, openText = _a.openText, loadingText = _a.loadingText, closeText = _a.closeText, other = tslib_1.__rest(_a, ["disabled", "required", "autoFocus", "fullWidth", "size", "allowCustomValue", "disableShowChevron", "disableClearButton", "disableShowEmptyOptionsList", "disableCloseOnSelect", "renderInput", "searchFunction", "renderOption", "inputValue", "className", "value", "options", "defaultValue", "error", "onChange", "onInputChange", "label", "placeholder", "renderLeft", "hint", "getOptionKey", "getOptionLabel", "getOptionDisabled", "dataListProps", "onClose", "onOpen", "open", "defaultOpen", "loading", "inputProps", "onKeyDown", "noOptionsText", "clearText", "openText", "loadingText", "closeText"]);
|
|
24
|
+
var anchorRef = (0, react_1.useRef)(null);
|
|
25
|
+
var _o = tslib_1.__read((0, useControlled_1.useControlled)({
|
|
26
|
+
value: inputValueProp,
|
|
27
|
+
defaultValue: '',
|
|
28
|
+
name: 'Autocomplete',
|
|
29
|
+
state: 'inputValue',
|
|
30
|
+
}), 2), inputValue = _o[0], setInputValue = _o[1];
|
|
31
|
+
var _p = tslib_1.__read((0, useControlled_1.useControlled)({
|
|
32
|
+
value: valueProp,
|
|
33
|
+
defaultValue: defaultValue,
|
|
34
|
+
name: 'Autocomplete',
|
|
35
|
+
state: 'value',
|
|
36
|
+
}), 2), valueState = _p[0], setValueState = _p[1];
|
|
37
|
+
var _q = tslib_1.__read((0, useControlled_1.useControlled)({
|
|
38
|
+
value: openProp,
|
|
39
|
+
defaultValue: defaultOpen,
|
|
40
|
+
name: 'Autocomplete',
|
|
41
|
+
state: 'open',
|
|
42
|
+
}), 2), open = _q[0], setOpen = _q[1];
|
|
43
|
+
var searchFunctionDefault = function (options, searchValue) {
|
|
44
|
+
return options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
45
|
+
return getOptionLabel(option).toLowerCase().includes(searchValue.toLowerCase());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var savedOnInputChange = (0, useMutableRef_1.useMutableRef)(onInputChange);
|
|
49
|
+
var savedGetOptionLabel = (0, useMutableRef_1.useMutableRef)(getOptionLabel);
|
|
50
|
+
var _r = tslib_1.__read((0, react_1.useState)(tslib_1.__spreadArray([], tslib_1.__read(options), false)), 2), filteredOptions = _r[0], setFilteredOptions = _r[1];
|
|
51
|
+
var searchFunction = searchFunctionProp || searchFunctionDefault;
|
|
52
|
+
var dataListValue = valueState ? getOptionLabel(valueState) : '';
|
|
53
|
+
var hasOptions = !!(filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length);
|
|
54
|
+
var showNoOptions = !hasOptions && !loading;
|
|
55
|
+
var showLoading = !hasOptions && !!loading;
|
|
56
|
+
var _s = tslib_1.__read((0, react_1.useState)(undefined), 2), search = _s[0], setSearch = _s[1];
|
|
57
|
+
/** Эффект – фильтрация списка */
|
|
58
|
+
(0, react_1.useEffect)(function () {
|
|
59
|
+
if (!open) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
setFilteredOptions(search ? search(options) : tslib_1.__spreadArray([], tslib_1.__read(options), false));
|
|
63
|
+
}, [search, options, open, searchFunctionProp]);
|
|
64
|
+
/** Эффект – синхронизируем значение текстового поля со значением в списке */
|
|
65
|
+
(0, react_1.useEffect)(function () {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
var value = valueState ? (_a = savedGetOptionLabel.current) === null || _a === void 0 ? void 0 : _a.call(savedGetOptionLabel, valueState) : '';
|
|
68
|
+
if (allowCustomValue) {
|
|
69
|
+
value = inputValue || '';
|
|
70
|
+
}
|
|
71
|
+
if (value !== inputValue) {
|
|
72
|
+
setInputValue(value);
|
|
73
|
+
(_b = savedOnInputChange.current) === null || _b === void 0 ? void 0 : _b.call(savedOnInputChange, null, value);
|
|
74
|
+
}
|
|
75
|
+
}, [valueState]);
|
|
76
|
+
/** Эффект – автофокусировка в текстовом поле */
|
|
77
|
+
(0, react_1.useEffect)(function () {
|
|
78
|
+
var _a;
|
|
79
|
+
if (autoFocus) {
|
|
80
|
+
(_a = anchorRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
81
|
+
}
|
|
82
|
+
}, [autoFocus]);
|
|
83
|
+
/** Актуализация значения текстового поля после его покидания */
|
|
84
|
+
var onBlur = function (e) {
|
|
85
|
+
var _a;
|
|
86
|
+
if (allowCustomValue) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
var value = valueState ? getOptionLabel(valueState) : '';
|
|
90
|
+
if (inputValue !== value) {
|
|
91
|
+
setInputValue(value);
|
|
92
|
+
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, value);
|
|
93
|
+
}
|
|
94
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
95
|
+
};
|
|
96
|
+
/** Ждем выполнения анимации на закрытие и делаем сброс */
|
|
97
|
+
var onExited = function () {
|
|
98
|
+
var _a;
|
|
99
|
+
setSearch(undefined);
|
|
100
|
+
(_a = dataListProps === null || dataListProps === void 0 ? void 0 : dataListProps.onExited) === null || _a === void 0 ? void 0 : _a.call(dataListProps);
|
|
101
|
+
};
|
|
102
|
+
/** Закрытие */
|
|
103
|
+
var handleClose = function () {
|
|
104
|
+
setOpen(false);
|
|
105
|
+
onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
|
|
106
|
+
};
|
|
107
|
+
/** Открытие */
|
|
108
|
+
var handleOpen = function () {
|
|
109
|
+
setOpen(true);
|
|
110
|
+
onOpenProp === null || onOpenProp === void 0 ? void 0 : onOpenProp();
|
|
111
|
+
};
|
|
112
|
+
/** Переключатель открытия и закрытия */
|
|
113
|
+
var handleToggle = function () {
|
|
114
|
+
if (disabled)
|
|
115
|
+
return;
|
|
116
|
+
if (open) {
|
|
117
|
+
handleClose();
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
handleOpen();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/** Очистка поля */
|
|
124
|
+
var onClear = function (e) {
|
|
125
|
+
setValueState(null);
|
|
126
|
+
setInputValue('');
|
|
127
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e, null);
|
|
128
|
+
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, '');
|
|
129
|
+
setSearch(undefined);
|
|
130
|
+
};
|
|
131
|
+
/** Открытие списка по клику на текстовом поле */
|
|
132
|
+
var handleClickOnInput = function (e) {
|
|
133
|
+
var _a;
|
|
134
|
+
handleToggle();
|
|
135
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onClick) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
136
|
+
};
|
|
137
|
+
/** Управление элементом контроля через клавиатуру */
|
|
138
|
+
var handleKeyDown = function (event) {
|
|
139
|
+
if ((0, isKeys_1.isKeys)(event, ['ArrowDown', 'ArrowUp']) && !open) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
handleToggle();
|
|
142
|
+
}
|
|
143
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
144
|
+
};
|
|
145
|
+
/** Событие ввода значения в текстовом поле */
|
|
146
|
+
var handleChangeInput = function (e) {
|
|
147
|
+
var value = e.target.value;
|
|
148
|
+
// Открываем список при вводе первого символа (при условии, что список еще не открыт)
|
|
149
|
+
if (value.length && !open) {
|
|
150
|
+
handleOpen();
|
|
151
|
+
}
|
|
152
|
+
// Делаем сброс при пустом значении в текстовом поле
|
|
153
|
+
if (!value) {
|
|
154
|
+
setValueState(null);
|
|
155
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e, null);
|
|
156
|
+
}
|
|
157
|
+
// Назначаем значение
|
|
158
|
+
setInputValue(value);
|
|
159
|
+
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(e, value);
|
|
160
|
+
// Задаем функцию фильтрации
|
|
161
|
+
setSearch(function () { return function (options) { return searchFunction(tslib_1.__spreadArray([], tslib_1.__read(options), false), value); }; });
|
|
162
|
+
};
|
|
163
|
+
/** Событие выбора значения из раскрывающегося списка */
|
|
164
|
+
var handleChangeDataList = function (event, _a) {
|
|
165
|
+
var value = _a.value;
|
|
166
|
+
var selectedOption = filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.find(function (option) { return (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) === value; });
|
|
167
|
+
if (selectedOption) {
|
|
168
|
+
var newInputValue = getOptionLabel(selectedOption);
|
|
169
|
+
setValueState(selectedOption);
|
|
170
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, selectedOption);
|
|
171
|
+
setInputValue(newInputValue);
|
|
172
|
+
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, newInputValue);
|
|
173
|
+
}
|
|
174
|
+
// Закрываем список после выбора
|
|
175
|
+
if (!disableCloseOnSelect) {
|
|
176
|
+
handleClose();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
/** Отображение текстового поля */
|
|
180
|
+
var input = renderInput(tslib_1.__assign(tslib_1.__assign({ size: size, hint: hint, disabled: disabled, label: label, required: required, error: error, fullWidth: fullWidth, placeholder: placeholder, renderLeft: renderLeft }, other), { renderRight: (react_1.default.createElement(components_1.AutocompleteRenderRight, { open: open, size: size, disabled: disabled, clearText: clearText, closeText: closeText, openText: openText, hasValue: !!inputValue, onClear: onClear, onOpen: handleToggle, disableShowChevron: disableShowChevron, disableClearButton: disableClearButton })), onChange: handleChangeInput, onKeyDown: handleKeyDown, value: inputValue || '', inputProps: tslib_1.__assign(tslib_1.__assign({}, inputProps), { onBlur: onBlur, onClick: handleClickOnInput }), bodyProps: { ref: anchorRef, 'aria-expanded': open }, className: (0, exports.cnAutocomplete)({ size: size, hasChevron: !disableShowChevron }, [
|
|
181
|
+
className,
|
|
182
|
+
]), ref: ref }));
|
|
183
|
+
/** Отображение опций */
|
|
184
|
+
var renderOptions = filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map(function (option) {
|
|
185
|
+
var selected = valueState
|
|
186
|
+
? getOptionLabel(valueState) === getOptionLabel(option)
|
|
187
|
+
: false;
|
|
188
|
+
var renderOptionDefault = function (_a) {
|
|
189
|
+
var option = _a.option, selected = _a.selected;
|
|
190
|
+
return (react_1.default.createElement(DataList_1.DataListOption, { key: getOptionKey === null || getOptionKey === void 0 ? void 0 : getOptionKey(option), label: getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option), value: getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option), disabled: getOptionDisabled === null || getOptionDisabled === void 0 ? void 0 : getOptionDisabled(option), selected: selected }));
|
|
191
|
+
};
|
|
192
|
+
var renderOption = renderOptionProp || renderOptionDefault;
|
|
193
|
+
return renderOption({ option: option, selected: selected });
|
|
194
|
+
});
|
|
195
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
196
|
+
input,
|
|
197
|
+
react_1.default.createElement(DataList_1.DataList, tslib_1.__assign({ size: size, equalAnchorWidth: true, offset: [0, 4], placement: "bottom-start" }, dataListProps, { open: open, onExited: onExited, onClose: handleClose, anchorRef: anchorRef, selected: dataListValue, onSelect: handleChangeDataList, listProps: tslib_1.__assign({ role: 'listbox' }, dataListProps === null || dataListProps === void 0 ? void 0 : dataListProps.listProps) }),
|
|
198
|
+
renderOptions,
|
|
199
|
+
!disableShowEmptyOptionsList && (react_1.default.createElement(components_1.AutocompleteNoOptions, { showNoOptions: showNoOptions, noOptionsText: noOptionsText })),
|
|
200
|
+
react_1.default.createElement(components_1.AutocompleteLoading, { showLoading: showLoading, loadingText: loadingText, size: size }))));
|
|
201
|
+
}
|
|
202
|
+
exports.Autocomplete = (0, react_1.forwardRef)(AutocompleteRender);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { AutocompleteProps } from '../../index';
|
|
3
|
+
export type AutocompleteLoadingProps = Pick<AutocompleteProps, 'loadingText' | 'size'> & {
|
|
4
|
+
showLoading: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const AutocompleteLoading: FC<AutocompleteLoadingProps>;
|
package/__inner__/cjs/components/Autocomplete/components/AutocompleteLoading/AutocompleteLoading.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutocompleteLoading = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
var getIconSizeToFormElement_1 = require("../../../../utils/getIconSizeToFormElement");
|
|
7
|
+
var isNumber_1 = require("../../../../utils/isNumber");
|
|
8
|
+
var isString_1 = require("../../../../utils/isString");
|
|
9
|
+
var List_1 = require("../../../List");
|
|
10
|
+
var Loader_1 = require("../../../Loader");
|
|
11
|
+
var constants_1 = require("../../constants");
|
|
12
|
+
var AutocompleteLoading = function (_a) {
|
|
13
|
+
var _b = _a.size, sizeProp = _b === void 0 ? constants_1.AUTOCOMPLETE_DEFAULT_SIZE : _b, showLoading = _a.showLoading, loadingText = _a.loadingText;
|
|
14
|
+
if (!showLoading) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
var size = (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(sizeProp);
|
|
18
|
+
return (0, isString_1.isString)(loadingText) || (0, isNumber_1.isNumber)(loadingText) ? (react_1.default.createElement(List_1.ListItem, null,
|
|
19
|
+
react_1.default.createElement(List_1.ListItemIcon, null,
|
|
20
|
+
react_1.default.createElement(Loader_1.Loader, { size: size })),
|
|
21
|
+
react_1.default.createElement(List_1.ListItemText, { primary: loadingText }))) : (loadingText);
|
|
22
|
+
};
|
|
23
|
+
exports.AutocompleteLoading = AutocompleteLoading;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutocompleteLoading';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { AutocompleteProps } from '../../index';
|
|
3
|
+
export type AutocompleteNoOptionsProps = Pick<AutocompleteProps, 'noOptionsText'> & {
|
|
4
|
+
showNoOptions: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const AutocompleteNoOptions: FC<AutocompleteNoOptionsProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutocompleteNoOptions = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
var isNumber_1 = require("../../../../utils/isNumber");
|
|
7
|
+
var isString_1 = require("../../../../utils/isString");
|
|
8
|
+
var List_1 = require("../../../List");
|
|
9
|
+
var AutocompleteNoOptions = function (_a) {
|
|
10
|
+
var showNoOptions = _a.showNoOptions, noOptionsText = _a.noOptionsText;
|
|
11
|
+
if (!showNoOptions) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return (0, isString_1.isString)(noOptionsText) || (0, isNumber_1.isNumber)(noOptionsText) ? (react_1.default.createElement(List_1.ListItem, null,
|
|
15
|
+
react_1.default.createElement(List_1.ListItemText, { primary: noOptionsText }))) : (noOptionsText);
|
|
16
|
+
};
|
|
17
|
+
exports.AutocompleteNoOptions = AutocompleteNoOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutocompleteNoOptions';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { AutocompleteProps } from '../../index';
|
|
4
|
+
type AutocompleteRenderRightProps = {
|
|
5
|
+
onOpen: () => void;
|
|
6
|
+
onClear: (e: React.MouseEvent<HTMLElement>) => void;
|
|
7
|
+
hasValue: boolean;
|
|
8
|
+
} & Pick<AutocompleteProps, 'clearText' | 'closeText' | 'openText' | 'size' | 'disabled' | 'open' | 'disableClearButton' | 'disableShowChevron'>;
|
|
9
|
+
export declare const AutocompleteRenderRight: FC<AutocompleteRenderRightProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutocompleteRenderRight = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
var icons_1 = require("@ozen-ui/icons");
|
|
7
|
+
var FieldControl_1 = require("../../../FieldControl");
|
|
8
|
+
var IconButton_1 = require("../../../IconButton");
|
|
9
|
+
var index_1 = require("../../index");
|
|
10
|
+
var AutocompleteRenderRight = function (_a) {
|
|
11
|
+
var disableClearButton = _a.disableClearButton, disableShowChevron = _a.disableShowChevron, clearText = _a.clearText, closeText = _a.closeText, openText = _a.openText, disabled = _a.disabled, hasValue = _a.hasValue, onClear = _a.onClear, onOpen = _a.onOpen, open = _a.open, size = _a.size;
|
|
12
|
+
var _b = tslib_1.__read((0, FieldControl_1.useFieldControl)(), 1), _c = _b[0], focused = _c.focused, hovered = _c.hovered;
|
|
13
|
+
var isVisibleClearButton = !!(hovered || open || focused) && hasValue;
|
|
14
|
+
return (react_1.default.createElement("div", { className: (0, index_1.cnAutocomplete)('RenderRight') },
|
|
15
|
+
!disableClearButton && (react_1.default.createElement(IconButton_1.IconButton, { type: "button", variant: "function", tabIndex: -1, onClick: function (e) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
onClear === null || onClear === void 0 ? void 0 : onClear(e);
|
|
18
|
+
}, className: (0, index_1.cnAutocomplete)('ClearButton', {
|
|
19
|
+
visibility: isVisibleClearButton,
|
|
20
|
+
}), title: clearText, "aria-label": clearText, size: size, icon: icons_1.CloseIcon, compressed: true })),
|
|
21
|
+
!disableShowChevron && (react_1.default.createElement(IconButton_1.IconButton, { type: "button", variant: "ghost", tabIndex: -1, onClick: function (e) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
onOpen();
|
|
24
|
+
}, disabled: disabled, title: open ? closeText : openText, "aria-label": open ? closeText : openText, size: size, icon: open ? icons_1.ChevronUpIcon : icons_1.ChevronDownIcon, compressed: true }))));
|
|
25
|
+
};
|
|
26
|
+
exports.AutocompleteRenderRight = AutocompleteRenderRight;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutocompleteRenderRight';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./AutocompleteRenderRight"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./AutocompleteNoOptions"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./AutocompleteLoading"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const AUTOCOMPLETE_DEFAULT_DISABLED = false;
|
|
2
|
+
export declare const AUTOCOMPLETE_DEFAULT_REQUIRED = false;
|
|
3
|
+
export declare const AUTOCOMPLETE_DEFAULT_AUTOFOCUS = false;
|
|
4
|
+
export declare const AUTOCOMPLETE_DEFAULT_FULLWIDTH = false;
|
|
5
|
+
export declare const AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE = false;
|
|
6
|
+
export declare const AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON = false;
|
|
7
|
+
export declare const AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST = false;
|
|
8
|
+
export declare const AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT = false;
|
|
9
|
+
export declare const AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON = false;
|
|
10
|
+
export declare const AUTOCOMPLETE_DEFAULT_SIZE = "m";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTOCOMPLETE_DEFAULT_SIZE = exports.AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON = exports.AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT = exports.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST = exports.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON = exports.AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE = exports.AUTOCOMPLETE_DEFAULT_FULLWIDTH = exports.AUTOCOMPLETE_DEFAULT_AUTOFOCUS = exports.AUTOCOMPLETE_DEFAULT_REQUIRED = exports.AUTOCOMPLETE_DEFAULT_DISABLED = void 0;
|
|
4
|
+
exports.AUTOCOMPLETE_DEFAULT_DISABLED = false;
|
|
5
|
+
exports.AUTOCOMPLETE_DEFAULT_REQUIRED = false;
|
|
6
|
+
exports.AUTOCOMPLETE_DEFAULT_AUTOFOCUS = false;
|
|
7
|
+
exports.AUTOCOMPLETE_DEFAULT_FULLWIDTH = false;
|
|
8
|
+
exports.AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE = false;
|
|
9
|
+
exports.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON = false;
|
|
10
|
+
exports.AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST = false;
|
|
11
|
+
exports.AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT = false;
|
|
12
|
+
exports.AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON = false;
|
|
13
|
+
exports.AUTOCOMPLETE_DEFAULT_SIZE = 'm';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { AutocompleteDefaultOption, AutocompletePropGetOptionDisabled, AutocompletePropGetOptionKey, AutocompletePropGetOptionLabel, AutocompleteProps } from './types';
|
|
3
|
+
export declare const defaultGetOptionKey: AutocompletePropGetOptionKey<AutocompleteDefaultOption>;
|
|
4
|
+
export declare const defaultGetOptionLabel: AutocompletePropGetOptionLabel<AutocompleteDefaultOption>;
|
|
5
|
+
export declare const defaultGetOptionDisabled: AutocompletePropGetOptionDisabled<AutocompleteDefaultOption>;
|
|
6
|
+
export declare function withDefaultGetters<OPTION>(props: AutocompleteProps<OPTION>): ({
|
|
7
|
+
options: OPTION[];
|
|
8
|
+
size?: "s" | "m" | "l" | "2xs" | "xs" | undefined;
|
|
9
|
+
value?: import("./types").AutocompletePropValue<OPTION>;
|
|
10
|
+
defaultValue?: import("./types").AutocompletePropValue<OPTION>;
|
|
11
|
+
onChange?: ((e: KeyboardEvent | import("react").SyntheticEvent<Element, Event>, value: OPTION | null) => void) | undefined;
|
|
12
|
+
inputValue?: string | undefined;
|
|
13
|
+
onInputChange?: ((e: import("react").ChangeEvent<HTMLInputElement> | null, value: string) => void) | undefined;
|
|
14
|
+
renderInput?: import("./types").AutocompleteRenderInput | undefined;
|
|
15
|
+
renderOption?: import("./types").AutocompletePropRenderOption<OPTION> | undefined;
|
|
16
|
+
getOptionLabel?: AutocompletePropGetOptionLabel<OPTION> | undefined;
|
|
17
|
+
getOptionKey?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
18
|
+
getOptionDisabled?: AutocompletePropGetOptionDisabled<OPTION> | undefined;
|
|
19
|
+
disableCloseOnSelect?: boolean | undefined;
|
|
20
|
+
allowCustomValue?: boolean | undefined;
|
|
21
|
+
loading?: boolean | undefined;
|
|
22
|
+
noOptionsText?: import("react").ReactNode;
|
|
23
|
+
clearText?: string | undefined;
|
|
24
|
+
openText?: string | undefined;
|
|
25
|
+
closeText?: string | undefined;
|
|
26
|
+
loadingText?: import("react").ReactNode;
|
|
27
|
+
onClose?: (() => void) | undefined;
|
|
28
|
+
onOpen?: (() => void) | undefined;
|
|
29
|
+
disableClearButton?: boolean | undefined;
|
|
30
|
+
searchFunction?: import("./types").AutocompleteSearchFunction<OPTION> | undefined;
|
|
31
|
+
disableShowEmptyOptionsList?: boolean | undefined;
|
|
32
|
+
disableShowChevron?: boolean | undefined;
|
|
33
|
+
dataListProps?: Partial<Omit<import("../DataList").DataListBaseProps, "onSelect" | "open" | "onClose" | "multiple" | "selected" | "anchorRef">> | undefined;
|
|
34
|
+
} & {
|
|
35
|
+
label?: string | undefined;
|
|
36
|
+
style?: import("react").CSSProperties | undefined;
|
|
37
|
+
className?: string | undefined;
|
|
38
|
+
onKeyDown?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
39
|
+
autoFocus?: boolean | undefined;
|
|
40
|
+
placeholder?: string | undefined;
|
|
41
|
+
disabled?: boolean | undefined;
|
|
42
|
+
required?: boolean | undefined;
|
|
43
|
+
error?: boolean | undefined;
|
|
44
|
+
fullWidth?: boolean | undefined;
|
|
45
|
+
hint?: string | null | undefined;
|
|
46
|
+
renderLeft?: string | number | import("react").FC<import("react").SVGProps<SVGSVGElement> & {
|
|
47
|
+
color?: string | undefined;
|
|
48
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
49
|
+
} & {
|
|
50
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
51
|
+
}> | import("react").ReactElement<import("react").SVGProps<SVGSVGElement> & {
|
|
52
|
+
color?: string | undefined;
|
|
53
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
54
|
+
} & {
|
|
55
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
56
|
+
}, string | import("react").JSXElementConstructor<any>> | (() => import("react").ReactElement<import("react").SVGProps<SVGSVGElement> & {
|
|
57
|
+
color?: string | undefined;
|
|
58
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
59
|
+
} & {
|
|
60
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
61
|
+
}, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
62
|
+
inputProps?: (Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
|
|
63
|
+
ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
|
|
64
|
+
} & {
|
|
65
|
+
'data-testid'?: string | undefined;
|
|
66
|
+
}) | undefined;
|
|
67
|
+
} & {
|
|
68
|
+
open?: boolean | undefined;
|
|
69
|
+
defaultOpen?: undefined;
|
|
70
|
+
} & (OPTION extends {
|
|
71
|
+
label: string;
|
|
72
|
+
} ? Record<string, unknown> : {
|
|
73
|
+
getOptionLabel?: AutocompletePropGetOptionLabel<OPTION> | undefined;
|
|
74
|
+
}) & (OPTION extends {
|
|
75
|
+
id: string | number;
|
|
76
|
+
} ? Record<string, unknown> : {
|
|
77
|
+
getOptionKey?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
78
|
+
}) & (OPTION extends {
|
|
79
|
+
id: boolean | undefined;
|
|
80
|
+
} ? Record<string, unknown> : {
|
|
81
|
+
getOptionDisabled?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
82
|
+
}) & {
|
|
83
|
+
getOptionLabel: AutocompletePropGetOptionLabel<AutocompleteDefaultOption> | AutocompletePropGetOptionLabel<OPTION>;
|
|
84
|
+
getOptionKey: AutocompletePropGetOptionKey<AutocompleteDefaultOption> | AutocompletePropGetOptionKey<OPTION>;
|
|
85
|
+
getOptionDisabled: AutocompletePropGetOptionDisabled<AutocompleteDefaultOption> | AutocompletePropGetOptionDisabled<OPTION>;
|
|
86
|
+
}) | ({
|
|
87
|
+
options: OPTION[];
|
|
88
|
+
size?: "s" | "m" | "l" | "2xs" | "xs" | undefined;
|
|
89
|
+
value?: import("./types").AutocompletePropValue<OPTION>;
|
|
90
|
+
defaultValue?: import("./types").AutocompletePropValue<OPTION>;
|
|
91
|
+
onChange?: ((e: KeyboardEvent | import("react").SyntheticEvent<Element, Event>, value: OPTION | null) => void) | undefined;
|
|
92
|
+
inputValue?: string | undefined;
|
|
93
|
+
onInputChange?: ((e: import("react").ChangeEvent<HTMLInputElement> | null, value: string) => void) | undefined;
|
|
94
|
+
renderInput?: import("./types").AutocompleteRenderInput | undefined;
|
|
95
|
+
renderOption?: import("./types").AutocompletePropRenderOption<OPTION> | undefined;
|
|
96
|
+
getOptionLabel?: AutocompletePropGetOptionLabel<OPTION> | undefined;
|
|
97
|
+
getOptionKey?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
98
|
+
getOptionDisabled?: AutocompletePropGetOptionDisabled<OPTION> | undefined;
|
|
99
|
+
disableCloseOnSelect?: boolean | undefined;
|
|
100
|
+
allowCustomValue?: boolean | undefined;
|
|
101
|
+
loading?: boolean | undefined;
|
|
102
|
+
noOptionsText?: import("react").ReactNode;
|
|
103
|
+
clearText?: string | undefined;
|
|
104
|
+
openText?: string | undefined;
|
|
105
|
+
closeText?: string | undefined;
|
|
106
|
+
loadingText?: import("react").ReactNode;
|
|
107
|
+
onClose?: (() => void) | undefined;
|
|
108
|
+
onOpen?: (() => void) | undefined;
|
|
109
|
+
disableClearButton?: boolean | undefined;
|
|
110
|
+
searchFunction?: import("./types").AutocompleteSearchFunction<OPTION> | undefined;
|
|
111
|
+
disableShowEmptyOptionsList?: boolean | undefined;
|
|
112
|
+
disableShowChevron?: boolean | undefined;
|
|
113
|
+
dataListProps?: Partial<Omit<import("../DataList").DataListBaseProps, "onSelect" | "open" | "onClose" | "multiple" | "selected" | "anchorRef">> | undefined;
|
|
114
|
+
} & {
|
|
115
|
+
label?: string | undefined;
|
|
116
|
+
style?: import("react").CSSProperties | undefined;
|
|
117
|
+
className?: string | undefined;
|
|
118
|
+
onKeyDown?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
|
|
119
|
+
autoFocus?: boolean | undefined;
|
|
120
|
+
placeholder?: string | undefined;
|
|
121
|
+
disabled?: boolean | undefined;
|
|
122
|
+
required?: boolean | undefined;
|
|
123
|
+
error?: boolean | undefined;
|
|
124
|
+
fullWidth?: boolean | undefined;
|
|
125
|
+
hint?: string | null | undefined;
|
|
126
|
+
renderLeft?: string | number | import("react").FC<import("react").SVGProps<SVGSVGElement> & {
|
|
127
|
+
color?: string | undefined;
|
|
128
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
129
|
+
} & {
|
|
130
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
131
|
+
}> | import("react").ReactElement<import("react").SVGProps<SVGSVGElement> & {
|
|
132
|
+
color?: string | undefined;
|
|
133
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
134
|
+
} & {
|
|
135
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
136
|
+
}, string | import("react").JSXElementConstructor<any>> | (() => import("react").ReactElement<import("react").SVGProps<SVGSVGElement> & {
|
|
137
|
+
color?: string | undefined;
|
|
138
|
+
ref?: import("react").Ref<SVGSVGElement> | undefined;
|
|
139
|
+
} & {
|
|
140
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
141
|
+
}, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
142
|
+
inputProps?: (Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
|
|
143
|
+
ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
|
|
144
|
+
} & {
|
|
145
|
+
'data-testid'?: string | undefined;
|
|
146
|
+
}) | undefined;
|
|
147
|
+
} & {
|
|
148
|
+
open?: undefined;
|
|
149
|
+
defaultOpen?: boolean | undefined;
|
|
150
|
+
} & (OPTION extends {
|
|
151
|
+
label: string;
|
|
152
|
+
} ? Record<string, unknown> : {
|
|
153
|
+
getOptionLabel?: AutocompletePropGetOptionLabel<OPTION> | undefined;
|
|
154
|
+
}) & (OPTION extends {
|
|
155
|
+
id: string | number;
|
|
156
|
+
} ? Record<string, unknown> : {
|
|
157
|
+
getOptionKey?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
158
|
+
}) & (OPTION extends {
|
|
159
|
+
id: boolean | undefined;
|
|
160
|
+
} ? Record<string, unknown> : {
|
|
161
|
+
getOptionDisabled?: AutocompletePropGetOptionKey<OPTION> | undefined;
|
|
162
|
+
}) & {
|
|
163
|
+
getOptionLabel: AutocompletePropGetOptionLabel<AutocompleteDefaultOption> | AutocompletePropGetOptionLabel<OPTION>;
|
|
164
|
+
getOptionKey: AutocompletePropGetOptionKey<AutocompleteDefaultOption> | AutocompletePropGetOptionKey<OPTION>;
|
|
165
|
+
getOptionDisabled: AutocompletePropGetOptionDisabled<AutocompleteDefaultOption> | AutocompletePropGetOptionDisabled<OPTION>;
|
|
166
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withDefaultGetters = exports.defaultGetOptionDisabled = exports.defaultGetOptionLabel = exports.defaultGetOptionKey = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var defaultGetOptionKey = function (option) { var _a; return (_a = option.id) !== null && _a !== void 0 ? _a : option; };
|
|
6
|
+
exports.defaultGetOptionKey = defaultGetOptionKey;
|
|
7
|
+
var defaultGetOptionLabel = function (option) { var _a; return (_a = option.label) !== null && _a !== void 0 ? _a : option; };
|
|
8
|
+
exports.defaultGetOptionLabel = defaultGetOptionLabel;
|
|
9
|
+
var defaultGetOptionDisabled = function (option) { var _a; return (_a = option.disabled) !== null && _a !== void 0 ? _a : false; };
|
|
10
|
+
exports.defaultGetOptionDisabled = defaultGetOptionDisabled;
|
|
11
|
+
function withDefaultGetters(props) {
|
|
12
|
+
return tslib_1.__assign(tslib_1.__assign({}, props), { getOptionLabel: props.getOptionLabel || exports.defaultGetOptionLabel, getOptionKey: props.getOptionKey || exports.defaultGetOptionKey, getOptionDisabled: props.getOptionDisabled || exports.defaultGetOptionDisabled });
|
|
13
|
+
}
|
|
14
|
+
exports.withDefaultGetters = withDefaultGetters;
|