@snack-uikit/search 0.5.2 → 0.6.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/CHANGELOG.md +11 -0
- package/README.md +4 -4
- package/dist/components/Search/Search.d.ts +1 -4
- package/dist/components/Search/Search.js +3 -5
- package/dist/components/SearchAutocomplete/SearchAutocomplete.js +4 -4
- package/dist/components/SearchDecorator/SearchDecorator.d.ts +0 -4
- package/dist/components/SearchDecorator/SearchDecorator.js +2 -3
- package/dist/components/SearchFieldText/SearchFieldText.js +2 -2
- package/dist/components/SearchPrivate/SearchPrivate.d.ts +2 -4
- package/dist/components/SearchPrivate/SearchPrivate.js +4 -6
- package/dist/constants.d.ts +5 -5
- package/dist/constants.js +5 -6
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -0
- package/package.json +6 -6
- package/src/components/Search/Search.tsx +2 -8
- package/src/components/SearchAutocomplete/SearchAutocomplete.tsx +4 -4
- package/src/components/SearchDecorator/SearchDecorator.tsx +2 -4
- package/src/components/SearchFieldText/SearchFieldText.tsx +2 -2
- package/src/components/SearchPrivate/SearchPrivate.tsx +5 -10
- package/src/constants.ts +5 -5
- package/src/types.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.6.0 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.5.2 (2023-12-07)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ import { Search, SearchPrivate } from "@snack-uikit/search";
|
|
|
20
20
|
loading={loading}
|
|
21
21
|
options={options}
|
|
22
22
|
onSubmit={onSubmit}
|
|
23
|
-
size=
|
|
23
|
+
size='s'
|
|
24
24
|
autocomplete
|
|
25
25
|
/>
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ import { Search, SearchPrivate } from "@snack-uikit/search";
|
|
|
29
29
|
onChange={handleSearchChange}
|
|
30
30
|
loading={loading}
|
|
31
31
|
onSubmit={onSubmit}
|
|
32
|
-
size=
|
|
32
|
+
size='s'
|
|
33
33
|
/>
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -45,7 +45,7 @@ import { Search, SearchPrivate } from "@snack-uikit/search";
|
|
|
45
45
|
| onFocus | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки получения фокуса |
|
|
46
46
|
| onBlur | `FocusEventHandler<HTMLInputElement>` | - | Колбек обработки потери фокуса |
|
|
47
47
|
| className | `string` | - | CSS-класс |
|
|
48
|
-
| size | enum Size: `"s"`, `"m"`, `"l"` |
|
|
48
|
+
| size | enum Size: `"s"`, `"m"`, `"l"` | s | Размер |
|
|
49
49
|
| loading | `boolean` | - | Состояние загрузки |
|
|
50
50
|
| onSubmit | `(value: string) => void` | - | Колбек на подтверждение поиска по строке |
|
|
51
51
|
| outline | `boolean` | - | Внешний бордер |
|
|
@@ -57,7 +57,7 @@ import { Search, SearchPrivate } from "@snack-uikit/search";
|
|
|
57
57
|
### Props
|
|
58
58
|
| name | type | default value | description |
|
|
59
59
|
|------|------|---------------|-------------|
|
|
60
|
-
| size | enum Size: `"s"`, `"m"`, `"l"` |
|
|
60
|
+
| size | enum Size: `"s"`, `"m"`, `"l"` | s | Размер |
|
|
61
61
|
| loading | `boolean` | - | Состояние загрузки |
|
|
62
62
|
| onSubmit | `(value: string) => void` | - | Колбек на подтверждение поиска по строке |
|
|
63
63
|
| className | `string` | - | CSS-класс |
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Size } from '../../constants';
|
|
3
2
|
import { SearchAutocompleteProps } from '../SearchAutocomplete';
|
|
4
3
|
import { SearchPrivateProps } from '../SearchPrivate';
|
|
5
4
|
export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
@@ -17,6 +16,4 @@ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
|
17
16
|
/** В режиме FieldText options отсутсвуют */
|
|
18
17
|
options?: never;
|
|
19
18
|
});
|
|
20
|
-
export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement
|
|
21
|
-
sizes: typeof Size;
|
|
22
|
-
};
|
|
19
|
+
export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from 'react';
|
|
14
14
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
15
|
-
import {
|
|
15
|
+
import { SIZE } from '../../constants';
|
|
16
16
|
import { SearchAutocomplete } from '../SearchAutocomplete';
|
|
17
17
|
import { SearchFieldText } from '../SearchFieldText';
|
|
18
|
-
const
|
|
19
|
-
var { size =
|
|
18
|
+
export const Search = forwardRef(function Search(_a, ref) {
|
|
19
|
+
var { size = SIZE.S } = _a, props = __rest(_a, ["size"]);
|
|
20
20
|
const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className } = props, rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className"]);
|
|
21
21
|
const supportProps = extractSupportProps(rest);
|
|
22
22
|
if (props.autocomplete) {
|
|
@@ -24,5 +24,3 @@ const SearchComponent = forwardRef(function Search(_a, ref) {
|
|
|
24
24
|
}
|
|
25
25
|
return (_jsx(SearchFieldText, Object.assign({ value: value, onChange: onChange, onBlur: onBlur, onFocus: onFocus, onSubmit: onSubmit, size: size, outline: outline, loading: loading, placeholder: placeholder, className: className, ref: ref }, supportProps)));
|
|
26
26
|
});
|
|
27
|
-
export const Search = SearchComponent;
|
|
28
|
-
Search.sizes = Size;
|
|
@@ -15,23 +15,23 @@ import cn from 'classnames';
|
|
|
15
15
|
import mergeRefs from 'merge-refs';
|
|
16
16
|
import { forwardRef, useCallback, useRef, useState } from 'react';
|
|
17
17
|
import { Droplist } from '@snack-uikit/droplist';
|
|
18
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
18
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE, TEST_IDS } from '../../constants';
|
|
19
19
|
import { SearchDecorator } from '../SearchDecorator';
|
|
20
20
|
import { SearchPrivate } from '../SearchPrivate';
|
|
21
21
|
import styles from './styles.module.css';
|
|
22
22
|
export const SearchAutocomplete = forwardRef(function SearchAutocomplete(_a, ref) {
|
|
23
23
|
var _b, _c;
|
|
24
|
-
var { size =
|
|
24
|
+
var { size = SIZE.S, value, onChange, placeholder, options = [], loading, outline, onSubmit, onFocus, className } = _a, rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className"]);
|
|
25
25
|
const scrollRef = useRef(null);
|
|
26
26
|
const [isOpen, setIsOpen] = useState(false);
|
|
27
27
|
const { firstElementRefCallback, handleDroplistFocusLeave, handleDroplistItemClick, handleTriggerKeyDown, handleDroplistItemKeyDown, triggerElementRef, } = Droplist.useKeyboardNavigation({
|
|
28
28
|
setDroplistOpen: setIsOpen,
|
|
29
|
-
triggerType:
|
|
29
|
+
triggerType: 'input',
|
|
30
30
|
});
|
|
31
31
|
const handleOptionKeyDown = useCallback((event) => {
|
|
32
32
|
var _a, _b;
|
|
33
33
|
event.stopPropagation();
|
|
34
|
-
// ignoring special keys (tab, arrows, backspace
|
|
34
|
+
// ignoring special keys (tab, arrows, backspace, etc.)
|
|
35
35
|
if (event.key.length === 1) {
|
|
36
36
|
(_a = triggerElementRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
37
37
|
(_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scroll(0, 0);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import { Size } from '../../constants';
|
|
4
3
|
import { SearchProps } from '../Search';
|
|
5
4
|
export type SearchDecoratorProps = WithSupportProps<{
|
|
6
5
|
children: ReactNode;
|
|
@@ -8,6 +7,3 @@ export type SearchDecoratorProps = WithSupportProps<{
|
|
|
8
7
|
className?: string;
|
|
9
8
|
} & Pick<SearchProps, 'outline' | 'size'>>;
|
|
10
9
|
export declare function SearchDecorator({ children, outline, size, focused, className, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare namespace SearchDecorator {
|
|
12
|
-
var sizes: typeof Size;
|
|
13
|
-
}
|
|
@@ -12,10 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
15
|
-
import {
|
|
15
|
+
import { SIZE } from '../../constants';
|
|
16
16
|
import styles from './styles.module.css';
|
|
17
17
|
export function SearchDecorator(_a) {
|
|
18
|
-
var { children, outline, size =
|
|
18
|
+
var { children, outline, size = SIZE.S, focused, className } = _a, rest = __rest(_a, ["children", "outline", "size", "focused", "className"]);
|
|
19
19
|
return (_jsx("div", Object.assign({ className: cn(styles.decorator, className), "data-outline": outline || undefined, "data-size": size, "data-focused": focused || undefined }, extractSupportProps(rest), { children: children })));
|
|
20
20
|
}
|
|
21
|
-
SearchDecorator.sizes = Size;
|
|
@@ -11,10 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from 'react';
|
|
14
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
14
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
|
|
15
15
|
import { SearchDecorator } from '../SearchDecorator';
|
|
16
16
|
import { SearchPrivate } from '../SearchPrivate';
|
|
17
17
|
export const SearchFieldText = forwardRef(function SearchFieldText(_a, ref) {
|
|
18
|
-
var { value, onChange, onBlur, onFocus, size =
|
|
18
|
+
var { value, onChange, onBlur, onFocus, size = SIZE.S, outline, loading, placeholder, onSubmit, className } = _a, rest = __rest(_a, ["value", "onChange", "onBlur", "onFocus", "size", "outline", "loading", "placeholder", "onSubmit", "className"]);
|
|
19
19
|
return (_jsx(SearchDecorator, Object.assign({ outline: outline, size: size, className: className }, rest, { children: _jsx(SearchPrivate, { ref: ref, size: size, value: value, onChange: onChange, onBlur: onBlur, onFocus: onFocus, onSubmit: onSubmit, placeholder: placeholder, loading: loading, "data-test-id": PRIVATE_SEARCH_TEST_IDS.field }) })));
|
|
20
20
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputPrivateProps } from '@snack-uikit/input-private';
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
|
-
import { Size } from '../../
|
|
4
|
+
import { Size } from '../../types';
|
|
5
5
|
export type SearchPrivateProps = WithSupportProps<{
|
|
6
6
|
/** Размер */
|
|
7
7
|
size?: Size;
|
|
@@ -23,6 +23,4 @@ export declare const SearchPrivate: import("react").ForwardRefExoticComponent<{
|
|
|
23
23
|
onSubmit?(value: string): void;
|
|
24
24
|
/** CSS-класс */
|
|
25
25
|
className?: string | undefined;
|
|
26
|
-
} & Pick<Partial<InputPrivateProps>, "value" | "onChange" | "placeholder" | "onFocus" | "onBlur" | "onKeyDown"> & import("react").RefAttributes<HTMLInputElement
|
|
27
|
-
sizes: typeof Size;
|
|
28
|
-
};
|
|
26
|
+
} & Pick<Partial<InputPrivateProps>, "value" | "onChange" | "placeholder" | "onFocus" | "onBlur" | "onKeyDown"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -18,10 +18,10 @@ import { SearchSVG } from '@snack-uikit/icons';
|
|
|
18
18
|
import { InputPrivate, moveCursorToEnd, useButtonNavigation, useClearButton, } from '@snack-uikit/input-private';
|
|
19
19
|
import { Sun } from '@snack-uikit/loaders';
|
|
20
20
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
21
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
21
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
|
|
22
22
|
import styles from './styles.module.css';
|
|
23
|
-
const
|
|
24
|
-
var { size =
|
|
23
|
+
export const SearchPrivate = forwardRef(function SearchPrivate(_a, ref) {
|
|
24
|
+
var { size = SIZE.S, value: valueProp = '', onChange: onChangeProp, loading, placeholder, onKeyDown, onFocus, onBlur, onSubmit, className } = _a, rest = __rest(_a, ["size", "value", "onChange", "loading", "placeholder", "onKeyDown", "onFocus", "onBlur", "onSubmit", "className"]);
|
|
25
25
|
const [value, onValueChange] = useUncontrolledProp(valueProp, '', onChangeProp);
|
|
26
26
|
const localRef = useRef(null);
|
|
27
27
|
const clearButtonRef = useRef(null);
|
|
@@ -57,7 +57,5 @@ const SearchPrivateComponent = forwardRef(function SearchPrivate(_a, ref) {
|
|
|
57
57
|
onFocus && onFocus(e);
|
|
58
58
|
moveCursorToEnd(localRef.current);
|
|
59
59
|
}, [onFocus]);
|
|
60
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-size": size }, { children: [_jsx("span", Object.assign({ className: styles.prefix }, { children: loading ? (_jsx(Sun, { "data-test-id": PRIVATE_SEARCH_TEST_IDS.iconSun })) : (_jsx(SearchSVG, { "data-test-id": PRIVATE_SEARCH_TEST_IDS.iconSearch })) })), _jsx(InputPrivate, { value: value, onChange: onValueChange, onKeyDown: handleKeyDown, onFocus: handleOnFocus, onBlur: onBlur, tabIndex: inputTabIndex, ref: mergeRefs(ref, localRef), placeholder: placeholder, type:
|
|
60
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-size": size }, { children: [_jsx("span", Object.assign({ className: styles.prefix }, { children: loading ? (_jsx(Sun, { "data-test-id": PRIVATE_SEARCH_TEST_IDS.iconSun })) : (_jsx(SearchSVG, { "data-test-id": PRIVATE_SEARCH_TEST_IDS.iconSearch })) })), _jsx(InputPrivate, { value: value, onChange: onValueChange, onKeyDown: handleKeyDown, onFocus: handleOnFocus, onBlur: onBlur, tabIndex: inputTabIndex, ref: mergeRefs(ref, localRef), placeholder: placeholder, type: 'text', "data-test-id": PRIVATE_SEARCH_TEST_IDS.input }), _jsx("span", Object.assign({ className: styles.postfix }, { children: buttons }))] })));
|
|
61
61
|
});
|
|
62
|
-
export const SearchPrivate = SearchPrivateComponent;
|
|
63
|
-
SearchPrivate.sizes = Size;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})(Size || (Size = {}));
|
|
1
|
+
export const SIZE = {
|
|
2
|
+
S: 's',
|
|
3
|
+
M: 'm',
|
|
4
|
+
L: 'l',
|
|
5
|
+
};
|
|
7
6
|
export const TEST_IDS = {
|
|
8
7
|
main: 'search',
|
|
9
8
|
decorator: 'search__decorator',
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Search",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.6.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/droplist": "0.
|
|
35
|
+
"@snack-uikit/droplist": "0.12.0",
|
|
36
36
|
"@snack-uikit/icons": "0.19.0",
|
|
37
|
-
"@snack-uikit/input-private": "
|
|
38
|
-
"@snack-uikit/loaders": "0.
|
|
39
|
-
"@snack-uikit/utils": "3.
|
|
37
|
+
"@snack-uikit/input-private": "3.0.0",
|
|
38
|
+
"@snack-uikit/loaders": "0.5.0",
|
|
39
|
+
"@snack-uikit/utils": "3.2.0",
|
|
40
40
|
"classnames": "2.3.2",
|
|
41
41
|
"merge-refs": "1.0.0",
|
|
42
42
|
"uncontrollable": "8.0.4"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/merge-refs": "1.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
|
|
48
48
|
}
|
|
@@ -2,7 +2,7 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { SIZE } from '../../constants';
|
|
6
6
|
import { SearchAutocomplete, SearchAutocompleteProps } from '../SearchAutocomplete';
|
|
7
7
|
import { SearchFieldText } from '../SearchFieldText';
|
|
8
8
|
import { SearchPrivateProps } from '../SearchPrivate';
|
|
@@ -26,7 +26,7 @@ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search({ size = SIZE.S, ...props }, ref) {
|
|
30
30
|
const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, ...rest } = props;
|
|
31
31
|
const supportProps = extractSupportProps(rest);
|
|
32
32
|
|
|
@@ -67,9 +67,3 @@ const SearchComponent = forwardRef<HTMLInputElement, SearchProps>(function Searc
|
|
|
67
67
|
/>
|
|
68
68
|
);
|
|
69
69
|
});
|
|
70
|
-
|
|
71
|
-
export const Search = SearchComponent as typeof SearchComponent & {
|
|
72
|
-
sizes: typeof Size;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
Search.sizes = Size;
|
|
@@ -4,7 +4,7 @@ import { forwardRef, KeyboardEvent, useCallback, useRef, useState } from 'react'
|
|
|
4
4
|
|
|
5
5
|
import { Droplist, ItemSingleProps } from '@snack-uikit/droplist';
|
|
6
6
|
|
|
7
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
7
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE, TEST_IDS } from '../../constants';
|
|
8
8
|
import { SearchDecorator } from '../SearchDecorator';
|
|
9
9
|
import { SearchPrivate, SearchPrivateProps } from '../SearchPrivate';
|
|
10
10
|
import styles from './styles.module.scss';
|
|
@@ -22,7 +22,7 @@ export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
|
22
22
|
|
|
23
23
|
export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocompleteProps>(function SearchAutocomplete(
|
|
24
24
|
{
|
|
25
|
-
size =
|
|
25
|
+
size = SIZE.S,
|
|
26
26
|
value,
|
|
27
27
|
onChange,
|
|
28
28
|
placeholder,
|
|
@@ -49,14 +49,14 @@ export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocomplet
|
|
|
49
49
|
triggerElementRef,
|
|
50
50
|
} = Droplist.useKeyboardNavigation<HTMLInputElement>({
|
|
51
51
|
setDroplistOpen: setIsOpen,
|
|
52
|
-
triggerType:
|
|
52
|
+
triggerType: 'input',
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
const handleOptionKeyDown = useCallback(
|
|
56
56
|
(event: KeyboardEvent<HTMLButtonElement>) => {
|
|
57
57
|
event.stopPropagation();
|
|
58
58
|
|
|
59
|
-
// ignoring special keys (tab, arrows, backspace
|
|
59
|
+
// ignoring special keys (tab, arrows, backspace, etc.)
|
|
60
60
|
if (event.key.length === 1) {
|
|
61
61
|
triggerElementRef.current?.focus();
|
|
62
62
|
scrollRef.current?.scroll(0, 0);
|
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { SIZE } from '../../constants';
|
|
7
7
|
import { SearchProps } from '../Search';
|
|
8
8
|
import styles from './styles.module.scss';
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ export type SearchDecoratorProps = WithSupportProps<
|
|
|
18
18
|
export function SearchDecorator({
|
|
19
19
|
children,
|
|
20
20
|
outline,
|
|
21
|
-
size =
|
|
21
|
+
size = SIZE.S,
|
|
22
22
|
focused,
|
|
23
23
|
className,
|
|
24
24
|
...rest
|
|
@@ -35,5 +35,3 @@ export function SearchDecorator({
|
|
|
35
35
|
</div>
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
SearchDecorator.sizes = Size;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
3
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
|
|
4
4
|
import { SearchDecorator } from '../SearchDecorator';
|
|
5
5
|
import { SearchPrivate, SearchPrivateProps } from '../SearchPrivate';
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const SearchFieldText = forwardRef<HTMLInputElement, SearchTextFieldProps>(function SearchFieldText(
|
|
13
|
-
{ value, onChange, onBlur, onFocus, size =
|
|
13
|
+
{ value, onChange, onBlur, onFocus, size = SIZE.S, outline, loading, placeholder, onSubmit, className, ...rest },
|
|
14
14
|
ref,
|
|
15
15
|
) {
|
|
16
16
|
return (
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
import { Sun } from '@snack-uikit/loaders';
|
|
15
15
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
16
16
|
|
|
17
|
-
import { PRIVATE_SEARCH_TEST_IDS,
|
|
17
|
+
import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
|
|
18
|
+
import { Size } from '../../types';
|
|
18
19
|
import styles from './styles.module.scss';
|
|
19
20
|
|
|
20
21
|
export type SearchPrivateProps = WithSupportProps<
|
|
@@ -30,9 +31,9 @@ export type SearchPrivateProps = WithSupportProps<
|
|
|
30
31
|
} & Pick<Partial<InputPrivateProps>, 'value' | 'onChange' | 'placeholder' | 'onFocus' | 'onBlur' | 'onKeyDown'>
|
|
31
32
|
>;
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
+
export const SearchPrivate = forwardRef<HTMLInputElement, SearchPrivateProps>(function SearchPrivate(
|
|
34
35
|
{
|
|
35
|
-
size =
|
|
36
|
+
size = SIZE.S,
|
|
36
37
|
value: valueProp = '',
|
|
37
38
|
onChange: onChangeProp,
|
|
38
39
|
loading,
|
|
@@ -114,7 +115,7 @@ const SearchPrivateComponent = forwardRef<HTMLInputElement, SearchPrivateProps>(
|
|
|
114
115
|
tabIndex={inputTabIndex}
|
|
115
116
|
ref={mergeRefs(ref, localRef)}
|
|
116
117
|
placeholder={placeholder}
|
|
117
|
-
type=
|
|
118
|
+
type='text'
|
|
118
119
|
data-test-id={PRIVATE_SEARCH_TEST_IDS.input}
|
|
119
120
|
/>
|
|
120
121
|
|
|
@@ -122,9 +123,3 @@ const SearchPrivateComponent = forwardRef<HTMLInputElement, SearchPrivateProps>(
|
|
|
122
123
|
</div>
|
|
123
124
|
);
|
|
124
125
|
});
|
|
125
|
-
|
|
126
|
-
export const SearchPrivate = SearchPrivateComponent as typeof SearchPrivateComponent & {
|
|
127
|
-
sizes: typeof Size;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
SearchPrivate.sizes = Size;
|
package/src/constants.ts
CHANGED