@snack-uikit/search 0.11.11-preview-4fa9564e.0 → 0.11.11
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 +9 -0
- package/dist/cjs/components/Search/Search.d.ts +6 -3
- package/dist/cjs/components/Search/Search.js +4 -7
- package/dist/cjs/components/SearchAutocomplete/SearchAutocomplete.d.ts +7 -6
- package/dist/cjs/components/SearchAutocomplete/SearchAutocomplete.js +2 -4
- package/dist/cjs/components/SearchDecorator/SearchDecorator.d.ts +3 -3
- package/dist/cjs/components/SearchDecorator/SearchDecorator.js +4 -5
- package/dist/cjs/components/SearchFieldText/SearchFieldText.d.ts +7 -4
- package/dist/cjs/types.d.ts +0 -8
- package/dist/esm/components/Search/Search.d.ts +6 -3
- package/dist/esm/components/Search/Search.js +3 -3
- package/dist/esm/components/SearchAutocomplete/SearchAutocomplete.d.ts +7 -6
- package/dist/esm/components/SearchAutocomplete/SearchAutocomplete.js +2 -2
- package/dist/esm/components/SearchDecorator/SearchDecorator.d.ts +3 -3
- package/dist/esm/components/SearchDecorator/SearchDecorator.js +3 -3
- package/dist/esm/components/SearchFieldText/SearchFieldText.d.ts +7 -4
- package/dist/esm/types.d.ts +0 -8
- package/package.json +3 -3
- package/src/components/Search/Search.tsx +8 -20
- package/src/components/SearchAutocomplete/SearchAutocomplete.tsx +4 -5
- package/src/components/SearchDecorator/SearchDecorator.tsx +2 -4
- package/src/components/SearchFieldText/SearchFieldText.tsx +5 -3
- package/src/types.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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.11.11 (2025-06-23)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/list@0.30.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## 0.11.10 (2025-06-19)
|
|
7
16
|
|
|
8
17
|
### Only dependencies have been changed
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
2
2
|
import { SearchAutocompleteProps } from '../SearchAutocomplete';
|
|
3
|
-
export type SearchProps =
|
|
3
|
+
export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
4
|
+
/** Внешний бордер */
|
|
5
|
+
outline?: boolean;
|
|
6
|
+
} & ((Pick<SearchAutocompleteProps, 'options'> & {
|
|
4
7
|
/**
|
|
5
8
|
* Работа в режиме Autocomplete в значении true
|
|
6
9
|
*
|
|
@@ -9,7 +12,7 @@ export type SearchProps = SearchBaseProps & ((Pick<SearchAutocompleteProps, 'opt
|
|
|
9
12
|
autocomplete: true;
|
|
10
13
|
}) | {
|
|
11
14
|
autocomplete?: false;
|
|
12
|
-
/** В режиме FieldText options
|
|
15
|
+
/** В режиме FieldText options отсутсвуют */
|
|
13
16
|
options?: never;
|
|
14
17
|
});
|
|
15
18
|
export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -33,10 +33,9 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
|
|
|
33
33
|
placeholder,
|
|
34
34
|
onSubmit,
|
|
35
35
|
className,
|
|
36
|
-
tabIndex
|
|
37
|
-
postfix
|
|
36
|
+
tabIndex
|
|
38
37
|
} = props,
|
|
39
|
-
rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex"
|
|
38
|
+
rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex"]);
|
|
40
39
|
const supportProps = (0, utils_1.extractSupportProps)(rest);
|
|
41
40
|
if (props.autocomplete) {
|
|
42
41
|
return (0, jsx_runtime_1.jsx)(SearchAutocomplete_1.SearchAutocomplete, Object.assign({
|
|
@@ -52,8 +51,7 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
|
|
|
52
51
|
placeholder: placeholder,
|
|
53
52
|
className: className,
|
|
54
53
|
ref: ref,
|
|
55
|
-
tabIndex: tabIndex
|
|
56
|
-
postfix: postfix
|
|
54
|
+
tabIndex: tabIndex
|
|
57
55
|
}, supportProps));
|
|
58
56
|
}
|
|
59
57
|
return (0, jsx_runtime_1.jsx)(SearchFieldText_1.SearchFieldText, Object.assign({
|
|
@@ -68,7 +66,6 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
|
|
|
68
66
|
placeholder: placeholder,
|
|
69
67
|
className: className,
|
|
70
68
|
ref: ref,
|
|
71
|
-
tabIndex: tabIndex
|
|
72
|
-
postfix: postfix
|
|
69
|
+
tabIndex: tabIndex
|
|
73
70
|
}, supportProps));
|
|
74
71
|
});
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
2
|
-
import {
|
|
3
|
-
export type SearchAutocompleteProps =
|
|
2
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
3
|
+
export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
4
4
|
/**
|
|
5
5
|
* Элементы выпадающие в Droplist в режиме Autocomplete.
|
|
6
6
|
*
|
|
7
7
|
* На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
|
|
8
8
|
*/
|
|
9
9
|
options: BaseItemProps[];
|
|
10
|
-
|
|
11
|
-
export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
|
|
10
|
+
/** Внешний бордер */
|
|
12
11
|
outline?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
};
|
|
13
|
+
export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
|
|
15
14
|
/**
|
|
16
15
|
* Элементы выпадающие в Droplist в режиме Autocomplete.
|
|
17
16
|
*
|
|
18
17
|
* На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
|
|
19
18
|
*/
|
|
20
19
|
options: BaseItemProps[];
|
|
20
|
+
/** Внешний бордер */
|
|
21
|
+
outline?: boolean;
|
|
21
22
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -38,10 +38,9 @@ exports.SearchAutocomplete = (0, react_1.forwardRef)(function SearchAutocomplete
|
|
|
38
38
|
onSubmit,
|
|
39
39
|
onFocus,
|
|
40
40
|
className,
|
|
41
|
-
tabIndex
|
|
42
|
-
postfix
|
|
41
|
+
tabIndex
|
|
43
42
|
} = _a,
|
|
44
|
-
rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex"
|
|
43
|
+
rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex"]);
|
|
45
44
|
const scrollRef = (0, react_1.useRef)(null);
|
|
46
45
|
const localRef = (0, react_1.useRef)(null);
|
|
47
46
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
@@ -122,7 +121,6 @@ exports.SearchAutocomplete = (0, react_1.forwardRef)(function SearchAutocomplete
|
|
|
122
121
|
outline: outline || undefined,
|
|
123
122
|
focused: isOpen && Boolean((_a = localRef.current) === null || _a === void 0 ? void 0 : _a.value) || undefined,
|
|
124
123
|
"data-test-id": constants_1.TEST_IDS.decorator,
|
|
125
|
-
postfix: postfix,
|
|
126
124
|
children: (0, jsx_runtime_1.jsx)(search_private_1.SearchPrivate, {
|
|
127
125
|
loading: loading,
|
|
128
126
|
value: value,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { SearchProps } from '../Search';
|
|
4
4
|
export type SearchDecoratorProps = WithSupportProps<{
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
focused?: boolean;
|
|
7
7
|
className?: string;
|
|
8
|
-
} & Pick<
|
|
9
|
-
export declare function SearchDecorator({ children, outline, size, focused, className,
|
|
8
|
+
} & Pick<SearchProps, 'outline' | 'size'>>;
|
|
9
|
+
export declare function SearchDecorator({ children, outline, size, focused, className, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,16 +28,15 @@ function SearchDecorator(_a) {
|
|
|
28
28
|
outline,
|
|
29
29
|
size = constants_1.SIZE.S,
|
|
30
30
|
focused,
|
|
31
|
-
className
|
|
32
|
-
postfix
|
|
31
|
+
className
|
|
33
32
|
} = _a,
|
|
34
|
-
rest = __rest(_a, ["children", "outline", "size", "focused", "className"
|
|
35
|
-
return (0, jsx_runtime_1.
|
|
33
|
+
rest = __rest(_a, ["children", "outline", "size", "focused", "className"]);
|
|
34
|
+
return (0, jsx_runtime_1.jsx)("div", Object.assign({
|
|
36
35
|
className: (0, classnames_1.default)(styles_module_scss_1.default.decorator, className),
|
|
37
36
|
"data-outline": outline || undefined,
|
|
38
37
|
"data-size": size,
|
|
39
38
|
"data-focused": focused || undefined
|
|
40
39
|
}, (0, utils_1.extractSupportProps)(rest), {
|
|
41
|
-
children:
|
|
40
|
+
children: children
|
|
42
41
|
}));
|
|
43
42
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type SearchTextFieldProps =
|
|
3
|
-
|
|
1
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
2
|
+
export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
3
|
+
/** Внешний бордер */
|
|
4
|
+
outline?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const SearchFieldText: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
|
|
7
|
+
/** Внешний бордер */
|
|
4
8
|
outline?: boolean;
|
|
5
|
-
postfix?: import("react").ReactNode;
|
|
6
9
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
3
1
|
import { ValueOf } from '@snack-uikit/utils';
|
|
4
2
|
import { SIZE } from './constants';
|
|
5
3
|
export type Size = ValueOf<typeof SIZE>;
|
|
6
|
-
export type SearchBaseProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
7
|
-
/** Внешний бордер */
|
|
8
|
-
outline?: boolean;
|
|
9
|
-
/** Произвольный постфикс для поля */
|
|
10
|
-
postfix?: ReactNode;
|
|
11
|
-
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
2
2
|
import { SearchAutocompleteProps } from '../SearchAutocomplete';
|
|
3
|
-
export type SearchProps =
|
|
3
|
+
export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
4
|
+
/** Внешний бордер */
|
|
5
|
+
outline?: boolean;
|
|
6
|
+
} & ((Pick<SearchAutocompleteProps, 'options'> & {
|
|
4
7
|
/**
|
|
5
8
|
* Работа в режиме Autocomplete в значении true
|
|
6
9
|
*
|
|
@@ -9,7 +12,7 @@ export type SearchProps = SearchBaseProps & ((Pick<SearchAutocompleteProps, 'opt
|
|
|
9
12
|
autocomplete: true;
|
|
10
13
|
}) | {
|
|
11
14
|
autocomplete?: false;
|
|
12
|
-
/** В режиме FieldText options
|
|
15
|
+
/** В режиме FieldText options отсутсвуют */
|
|
13
16
|
options?: never;
|
|
14
17
|
});
|
|
15
18
|
export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -17,10 +17,10 @@ import { SearchAutocomplete } from '../SearchAutocomplete';
|
|
|
17
17
|
import { SearchFieldText } from '../SearchFieldText';
|
|
18
18
|
export const Search = forwardRef(function Search(_a, ref) {
|
|
19
19
|
var { size = SIZE.S } = _a, props = __rest(_a, ["size"]);
|
|
20
|
-
const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, tabIndex
|
|
20
|
+
const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, tabIndex } = props, rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex"]);
|
|
21
21
|
const supportProps = extractSupportProps(rest);
|
|
22
22
|
if (props.autocomplete) {
|
|
23
|
-
return (_jsx(SearchAutocomplete, Object.assign({ value: value, onChange: onChange, options: props.options, onBlur: onBlur, onFocus: onFocus, onSubmit: onSubmit, size: size, outline: outline, loading: loading, placeholder: placeholder, className: className, ref: ref, tabIndex: tabIndex
|
|
23
|
+
return (_jsx(SearchAutocomplete, Object.assign({ value: value, onChange: onChange, options: props.options, onBlur: onBlur, onFocus: onFocus, onSubmit: onSubmit, size: size, outline: outline, loading: loading, placeholder: placeholder, className: className, ref: ref, tabIndex: tabIndex }, supportProps)));
|
|
24
24
|
}
|
|
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, tabIndex: tabIndex
|
|
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, tabIndex: tabIndex }, supportProps)));
|
|
26
26
|
});
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { BaseItemProps } from '@snack-uikit/list';
|
|
2
|
-
import {
|
|
3
|
-
export type SearchAutocompleteProps =
|
|
2
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
3
|
+
export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
4
4
|
/**
|
|
5
5
|
* Элементы выпадающие в Droplist в режиме Autocomplete.
|
|
6
6
|
*
|
|
7
7
|
* На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
|
|
8
8
|
*/
|
|
9
9
|
options: BaseItemProps[];
|
|
10
|
-
|
|
11
|
-
export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
|
|
10
|
+
/** Внешний бордер */
|
|
12
11
|
outline?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
};
|
|
13
|
+
export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
|
|
15
14
|
/**
|
|
16
15
|
* Элементы выпадающие в Droplist в режиме Autocomplete.
|
|
17
16
|
*
|
|
18
17
|
* На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
|
|
19
18
|
*/
|
|
20
19
|
options: BaseItemProps[];
|
|
20
|
+
/** Внешний бордер */
|
|
21
|
+
outline?: boolean;
|
|
21
22
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -19,7 +19,7 @@ import { PRIVATE_SEARCH_TEST_IDS, SIZE, TEST_IDS } from '../../constants';
|
|
|
19
19
|
import { SearchDecorator } from '../SearchDecorator';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export const SearchAutocomplete = forwardRef(function SearchAutocomplete(_a, ref) {
|
|
22
|
-
var { size = SIZE.S, value, onChange, placeholder, options = [], loading, outline, onSubmit, onFocus, className, tabIndex
|
|
22
|
+
var { size = SIZE.S, value, onChange, placeholder, options = [], loading, outline, onSubmit, onFocus, className, tabIndex } = _a, rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex"]);
|
|
23
23
|
const scrollRef = useRef(null);
|
|
24
24
|
const localRef = useRef(null);
|
|
25
25
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -73,6 +73,6 @@ export const SearchAutocomplete = forwardRef(function SearchAutocomplete(_a, ref
|
|
|
73
73
|
}), [handleOptionKeyDown, onChange, onSubmit, options]);
|
|
74
74
|
return (_jsx("div", Object.assign({ className: cn(styles.wrap, className) }, rest, { children: _jsx(Droplist, { open: isOpen && options.length > 0, scroll: true, size: size, onOpenChange: setIsOpen, "data-test-id": TEST_IDS.droplist, triggerClassName: styles.triggerClassName, scrollRef: scrollRef, triggerElemRef: localRef, items: items, loading: loading, children: ({ onKeyDown }) => {
|
|
75
75
|
var _a;
|
|
76
|
-
return (_jsx(SearchDecorator, { size: size, outline: outline || undefined, focused: (isOpen && Boolean((_a = localRef.current) === null || _a === void 0 ? void 0 : _a.value)) || undefined, "data-test-id": TEST_IDS.decorator,
|
|
76
|
+
return (_jsx(SearchDecorator, { size: size, outline: outline || undefined, focused: (isOpen && Boolean((_a = localRef.current) === null || _a === void 0 ? void 0 : _a.value)) || undefined, "data-test-id": TEST_IDS.decorator, children: _jsx(SearchPrivate, { loading: loading, value: value, onChange: onChange, onSubmit: onSubmit, placeholder: placeholder, ref: mergeRefs(ref, localRef), onKeyDown: handleKeyDown(onKeyDown), onFocus: onFocus, size: size, "data-test-id": PRIVATE_SEARCH_TEST_IDS.field, tabIndex: tabIndex }) }));
|
|
77
77
|
} }) })));
|
|
78
78
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { SearchProps } from '../Search';
|
|
4
4
|
export type SearchDecoratorProps = WithSupportProps<{
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
focused?: boolean;
|
|
7
7
|
className?: string;
|
|
8
|
-
} & Pick<
|
|
9
|
-
export declare function SearchDecorator({ children, outline, size, focused, className,
|
|
8
|
+
} & Pick<SearchProps, 'outline' | 'size'>>;
|
|
9
|
+
export declare function SearchDecorator({ children, outline, size, focused, className, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,12 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
15
15
|
import { SIZE } from '../../constants';
|
|
16
16
|
import styles from './styles.module.css';
|
|
17
17
|
export function SearchDecorator(_a) {
|
|
18
|
-
var { children, outline, size = SIZE.S, focused, className
|
|
19
|
-
return (
|
|
18
|
+
var { children, outline, size = SIZE.S, focused, className } = _a, rest = __rest(_a, ["children", "outline", "size", "focused", "className"]);
|
|
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
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type SearchTextFieldProps =
|
|
3
|
-
|
|
1
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
2
|
+
export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
3
|
+
/** Внешний бордер */
|
|
4
|
+
outline?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const SearchFieldText: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
|
|
7
|
+
/** Внешний бордер */
|
|
4
8
|
outline?: boolean;
|
|
5
|
-
postfix?: import("react").ReactNode;
|
|
6
9
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
3
1
|
import { ValueOf } from '@snack-uikit/utils';
|
|
4
2
|
import { SIZE } from './constants';
|
|
5
3
|
export type Size = ValueOf<typeof SIZE>;
|
|
6
|
-
export type SearchBaseProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
7
|
-
/** Внешний бордер */
|
|
8
|
-
outline?: boolean;
|
|
9
|
-
/** Произвольный постфикс для поля */
|
|
10
|
-
postfix?: ReactNode;
|
|
11
|
-
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Search",
|
|
7
|
-
"version": "0.11.11
|
|
7
|
+
"version": "0.11.11",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@snack-uikit/list": "0.
|
|
39
|
+
"@snack-uikit/list": "0.30.0",
|
|
40
40
|
"@snack-uikit/search-private": "0.4.21",
|
|
41
41
|
"@snack-uikit/utils": "3.8.2",
|
|
42
42
|
"classnames": "2.5.1",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/merge-refs": "1.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "cab80a84247484f1f7a06635d6d3d15ae7628aac"
|
|
49
49
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
+
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
3
4
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
4
5
|
|
|
5
6
|
import { SIZE } from '../../constants';
|
|
6
|
-
import { SearchBaseProps } from '../../types';
|
|
7
7
|
import { SearchAutocomplete, SearchAutocompleteProps } from '../SearchAutocomplete';
|
|
8
8
|
import { SearchFieldText } from '../SearchFieldText';
|
|
9
9
|
|
|
10
|
-
export type SearchProps =
|
|
11
|
-
|
|
10
|
+
export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
11
|
+
/** Внешний бордер */
|
|
12
|
+
outline?: boolean;
|
|
13
|
+
} & (
|
|
12
14
|
| (Pick<SearchAutocompleteProps, 'options'> & {
|
|
13
15
|
/**
|
|
14
16
|
* Работа в режиме Autocomplete в значении true
|
|
@@ -19,26 +21,14 @@ export type SearchProps = SearchBaseProps &
|
|
|
19
21
|
})
|
|
20
22
|
| {
|
|
21
23
|
autocomplete?: false;
|
|
22
|
-
/** В режиме FieldText options
|
|
24
|
+
/** В режиме FieldText options отсутсвуют */
|
|
23
25
|
options?: never;
|
|
24
26
|
}
|
|
25
27
|
);
|
|
26
28
|
|
|
27
29
|
export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search({ size = SIZE.S, ...props }, ref) {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
onChange,
|
|
31
|
-
onBlur,
|
|
32
|
-
onFocus,
|
|
33
|
-
outline,
|
|
34
|
-
loading,
|
|
35
|
-
placeholder,
|
|
36
|
-
onSubmit,
|
|
37
|
-
className,
|
|
38
|
-
tabIndex,
|
|
39
|
-
postfix,
|
|
40
|
-
...rest
|
|
41
|
-
} = props;
|
|
30
|
+
const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, tabIndex, ...rest } =
|
|
31
|
+
props;
|
|
42
32
|
const supportProps = extractSupportProps(rest);
|
|
43
33
|
|
|
44
34
|
if (props.autocomplete) {
|
|
@@ -57,7 +47,6 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(
|
|
|
57
47
|
className={className}
|
|
58
48
|
ref={ref}
|
|
59
49
|
tabIndex={tabIndex}
|
|
60
|
-
postfix={postfix}
|
|
61
50
|
{...supportProps}
|
|
62
51
|
/>
|
|
63
52
|
);
|
|
@@ -77,7 +66,6 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(
|
|
|
77
66
|
className={className}
|
|
78
67
|
ref={ref}
|
|
79
68
|
tabIndex={tabIndex}
|
|
80
|
-
postfix={postfix}
|
|
81
69
|
{...supportProps}
|
|
82
70
|
/>
|
|
83
71
|
);
|
|
@@ -12,20 +12,21 @@ import {
|
|
|
12
12
|
} from 'react';
|
|
13
13
|
|
|
14
14
|
import { BaseItemProps, Droplist } from '@snack-uikit/list';
|
|
15
|
-
import { SearchPrivate } from '@snack-uikit/search-private';
|
|
15
|
+
import { SearchPrivate, SearchPrivateProps } from '@snack-uikit/search-private';
|
|
16
16
|
|
|
17
17
|
import { PRIVATE_SEARCH_TEST_IDS, SIZE, TEST_IDS } from '../../constants';
|
|
18
|
-
import { SearchBaseProps } from '../../types';
|
|
19
18
|
import { SearchDecorator } from '../SearchDecorator';
|
|
20
19
|
import styles from './styles.module.scss';
|
|
21
20
|
|
|
22
|
-
export type SearchAutocompleteProps =
|
|
21
|
+
export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
23
22
|
/**
|
|
24
23
|
* Элементы выпадающие в Droplist в режиме Autocomplete.
|
|
25
24
|
*
|
|
26
25
|
* На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
|
|
27
26
|
*/
|
|
28
27
|
options: BaseItemProps[];
|
|
28
|
+
/** Внешний бордер */
|
|
29
|
+
outline?: boolean;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocompleteProps>(function SearchAutocomplete(
|
|
@@ -41,7 +42,6 @@ export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocomplet
|
|
|
41
42
|
onFocus,
|
|
42
43
|
className,
|
|
43
44
|
tabIndex,
|
|
44
|
-
postfix,
|
|
45
45
|
...rest
|
|
46
46
|
},
|
|
47
47
|
ref,
|
|
@@ -132,7 +132,6 @@ export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocomplet
|
|
|
132
132
|
outline={outline || undefined}
|
|
133
133
|
focused={(isOpen && Boolean(localRef.current?.value)) || undefined}
|
|
134
134
|
data-test-id={TEST_IDS.decorator}
|
|
135
|
-
postfix={postfix}
|
|
136
135
|
>
|
|
137
136
|
<SearchPrivate
|
|
138
137
|
loading={loading}
|
|
@@ -4,7 +4,7 @@ import { ReactNode } from 'react';
|
|
|
4
4
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
5
5
|
|
|
6
6
|
import { SIZE } from '../../constants';
|
|
7
|
-
import {
|
|
7
|
+
import { SearchProps } from '../Search';
|
|
8
8
|
import styles from './styles.module.scss';
|
|
9
9
|
|
|
10
10
|
export type SearchDecoratorProps = WithSupportProps<
|
|
@@ -12,7 +12,7 @@ export type SearchDecoratorProps = WithSupportProps<
|
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
focused?: boolean;
|
|
14
14
|
className?: string;
|
|
15
|
-
} & Pick<
|
|
15
|
+
} & Pick<SearchProps, 'outline' | 'size'>
|
|
16
16
|
>;
|
|
17
17
|
|
|
18
18
|
export function SearchDecorator({
|
|
@@ -21,7 +21,6 @@ export function SearchDecorator({
|
|
|
21
21
|
size = SIZE.S,
|
|
22
22
|
focused,
|
|
23
23
|
className,
|
|
24
|
-
postfix,
|
|
25
24
|
...rest
|
|
26
25
|
}: SearchDecoratorProps) {
|
|
27
26
|
return (
|
|
@@ -33,7 +32,6 @@ export function SearchDecorator({
|
|
|
33
32
|
{...extractSupportProps(rest)}
|
|
34
33
|
>
|
|
35
34
|
{children}
|
|
36
|
-
{postfix}
|
|
37
35
|
</div>
|
|
38
36
|
);
|
|
39
37
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { SearchPrivate } from '@snack-uikit/search-private';
|
|
3
|
+
import { SearchPrivate, SearchPrivateProps } from '@snack-uikit/search-private';
|
|
4
4
|
|
|
5
5
|
import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
|
|
6
|
-
import { SearchBaseProps } from '../../types';
|
|
7
6
|
import { SearchDecorator } from '../SearchDecorator';
|
|
8
7
|
|
|
9
|
-
export type SearchTextFieldProps =
|
|
8
|
+
export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
9
|
+
/** Внешний бордер */
|
|
10
|
+
outline?: boolean;
|
|
11
|
+
};
|
|
10
12
|
|
|
11
13
|
export const SearchFieldText = forwardRef<HTMLInputElement, SearchTextFieldProps>(function SearchFieldText(
|
|
12
14
|
{
|
package/src/types.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { SearchPrivateProps } from '@snack-uikit/search-private';
|
|
4
1
|
import { ValueOf } from '@snack-uikit/utils';
|
|
5
2
|
|
|
6
3
|
import { SIZE } from './constants';
|
|
7
4
|
|
|
8
5
|
export type Size = ValueOf<typeof SIZE>;
|
|
9
|
-
|
|
10
|
-
export type SearchBaseProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
|
|
11
|
-
/** Внешний бордер */
|
|
12
|
-
outline?: boolean;
|
|
13
|
-
/** Произвольный постфикс для поля */
|
|
14
|
-
postfix?: ReactNode;
|
|
15
|
-
};
|