@sima-land/moleculas 14.1.0 → 14.2.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.
|
@@ -8,34 +8,32 @@ export interface ButtonProps {
|
|
|
8
8
|
iconColor?: Token;
|
|
9
9
|
}
|
|
10
10
|
export interface SearchBarProps {
|
|
11
|
-
|
|
11
|
+
/** Поисковый Запрос. */
|
|
12
12
|
value?: string;
|
|
13
|
+
/** Вызовется при изменении поискового запроса. */
|
|
13
14
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
15
|
+
/** Тип клавиатуры. */
|
|
16
|
+
inputMode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
17
|
+
/** Подсказка. */
|
|
14
18
|
placeholder?: string;
|
|
19
|
+
/** Вызовется при нажатии на кнопку очистки. */
|
|
15
20
|
onClear?: React.MouseEventHandler;
|
|
16
|
-
|
|
17
|
-
onButtonClick?: (...args: any[]) => any;
|
|
21
|
+
/** Кнопки(а) после поля. */
|
|
18
22
|
endButtons?: any[];
|
|
23
|
+
/** Кнопки(а) до поля. */
|
|
19
24
|
startButtons?: any[];
|
|
25
|
+
/** Признак наличия иконки поиска слева. */
|
|
20
26
|
withSearchIcon?: boolean;
|
|
27
|
+
/** Признак авто-фокуса. */
|
|
21
28
|
autoFocus?: boolean;
|
|
29
|
+
/** Описание в поле ввода. */
|
|
22
30
|
description?: string;
|
|
31
|
+
/** Ref для элемента текстового поля. */
|
|
32
|
+
inputRef?: React.MutableRefObject<HTMLInputElement | null>;
|
|
23
33
|
}
|
|
24
34
|
/**
|
|
25
35
|
* Компонент поисковой строки.
|
|
26
|
-
* @param props
|
|
27
|
-
* @param props.value Поисковый Запрос.
|
|
28
|
-
* @param props.onChange Вызовется при изменении поискового запроса.
|
|
29
|
-
* @param props.inputMode Тип клавиатуры.
|
|
30
|
-
* @param props.placeholder Подсказка.
|
|
31
|
-
* @param props.onClear Вызовется при нажатии на кнопку очистки.
|
|
32
|
-
* @param props.buttonText Текст кнопки.
|
|
33
|
-
* @param props.onButtonClick Обработчик нажатия на кнопку.
|
|
34
|
-
* @param props.endButtons Кнопки(а) после поля.
|
|
35
|
-
* @param props.startButtons Кнопки(а) до поля.
|
|
36
|
-
* @param props.withSearchIcon Признак наличия иконки поиска слева.
|
|
37
|
-
* @param props.autoFocus Признак автофокуса.
|
|
38
|
-
* @param props.description Описание в поле ввода.
|
|
36
|
+
* @param props Свойства.
|
|
39
37
|
* @return Элемент.
|
|
40
38
|
*/
|
|
41
|
-
export declare const SearchBar: ({
|
|
39
|
+
export declare const SearchBar: ({ value, onChange, inputMode, placeholder, onClear, endButtons, startButtons, withSearchIcon, autoFocus, description, inputRef: inputRefProp, }: SearchBarProps) => JSX.Element;
|
|
@@ -39,27 +39,16 @@ const more_vert_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Fi
|
|
|
39
39
|
exports.cx = bind_1.default.bind(search_bar_module_scss_1.default);
|
|
40
40
|
/**
|
|
41
41
|
* Компонент поисковой строки.
|
|
42
|
-
* @param props
|
|
43
|
-
* @param props.value Поисковый Запрос.
|
|
44
|
-
* @param props.onChange Вызовется при изменении поискового запроса.
|
|
45
|
-
* @param props.inputMode Тип клавиатуры.
|
|
46
|
-
* @param props.placeholder Подсказка.
|
|
47
|
-
* @param props.onClear Вызовется при нажатии на кнопку очистки.
|
|
48
|
-
* @param props.buttonText Текст кнопки.
|
|
49
|
-
* @param props.onButtonClick Обработчик нажатия на кнопку.
|
|
50
|
-
* @param props.endButtons Кнопки(а) после поля.
|
|
51
|
-
* @param props.startButtons Кнопки(а) до поля.
|
|
52
|
-
* @param props.withSearchIcon Признак наличия иконки поиска слева.
|
|
53
|
-
* @param props.autoFocus Признак автофокуса.
|
|
54
|
-
* @param props.description Описание в поле ввода.
|
|
42
|
+
* @param props Свойства.
|
|
55
43
|
* @return Элемент.
|
|
56
44
|
*/
|
|
57
|
-
const SearchBar = ({
|
|
45
|
+
const SearchBar = ({ value, onChange, inputMode, placeholder = 'Поиск', onClear, endButtons = [], startButtons = [], withSearchIcon = true, autoFocus = true, description, inputRef: inputRefProp, }) => {
|
|
58
46
|
const [shownDropdown, toggleDropdown] = (0, react_1.useState)(false);
|
|
59
47
|
const inputRef = (0, react_1.useRef)(null);
|
|
60
48
|
const dropDownRef = (0, react_1.useRef)(null);
|
|
61
49
|
const dropDownOpenerRef = (0, react_1.useRef)(null);
|
|
62
50
|
const needHideEndButtons = endButtons.length > 1;
|
|
51
|
+
(0, react_1.useImperativeHandle)(inputRefProp, () => inputRef.current);
|
|
63
52
|
(0, hooks_1.useOutsideClick)(dropDownRef, e => {
|
|
64
53
|
!dropDownOpenerRef.current.contains(e.target) &&
|
|
65
54
|
toggleDropdown(false);
|