@snack-uikit/search 0.11.11-preview-644edaa1.0 → 0.12.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 CHANGED
@@ -3,6 +3,26 @@
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.12.0 (2025-06-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * **FF-6848:** added postfix to search ([98ecfc4](https://github.com/cloud-ru-tech/snack-uikit/commit/98ecfc49ca2f731f4a30654eb127d7d1a8f31e3c))
12
+
13
+
14
+
15
+
16
+
17
+ ## 0.11.11 (2025-06-23)
18
+
19
+ ### Only dependencies have been changed
20
+ * [@snack-uikit/list@0.30.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
21
+
22
+
23
+
24
+
25
+
6
26
  ## 0.11.10 (2025-06-19)
7
27
 
8
28
  ### Only dependencies have been changed
@@ -1,9 +1,6 @@
1
- import { SearchPrivateProps } from '@snack-uikit/search-private';
1
+ import { SearchBaseProps } from '../../types';
2
2
  import { SearchAutocompleteProps } from '../SearchAutocomplete';
3
- export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
4
- /** Внешний бордер */
5
- outline?: boolean;
6
- } & ((Pick<SearchAutocompleteProps, 'options'> & {
3
+ export type SearchProps = SearchBaseProps & ((Pick<SearchAutocompleteProps, 'options'> & {
7
4
  /**
8
5
  * Работа в режиме Autocomplete в значении true
9
6
  *
@@ -12,7 +9,7 @@ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
12
9
  autocomplete: true;
13
10
  }) | {
14
11
  autocomplete?: false;
15
- /** В режиме FieldText options отсутсвуют */
12
+ /** В режиме FieldText options отсутствуют */
16
13
  options?: never;
17
14
  });
18
15
  export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -18,11 +18,7 @@ const utils_1 = require("@snack-uikit/utils");
18
18
  const constants_1 = require("../../constants");
19
19
  const SearchAutocomplete_1 = require("../SearchAutocomplete");
20
20
  const SearchFieldText_1 = require("../SearchFieldText");
21
- exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
22
- var {
23
- size = constants_1.SIZE.S
24
- } = _a,
25
- props = __rest(_a, ["size"]);
21
+ exports.Search = (0, react_1.forwardRef)(function Search(props, ref) {
26
22
  const {
27
23
  value,
28
24
  onChange,
@@ -33,9 +29,11 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
33
29
  placeholder,
34
30
  onSubmit,
35
31
  className,
36
- tabIndex
32
+ tabIndex,
33
+ postfix,
34
+ size = constants_1.SIZE.S
37
35
  } = props,
38
- rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex"]);
36
+ rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex", "postfix", "size"]);
39
37
  const supportProps = (0, utils_1.extractSupportProps)(rest);
40
38
  if (props.autocomplete) {
41
39
  return (0, jsx_runtime_1.jsx)(SearchAutocomplete_1.SearchAutocomplete, Object.assign({
@@ -51,7 +49,8 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
51
49
  placeholder: placeholder,
52
50
  className: className,
53
51
  ref: ref,
54
- tabIndex: tabIndex
52
+ tabIndex: tabIndex,
53
+ postfix: postfix
55
54
  }, supportProps));
56
55
  }
57
56
  return (0, jsx_runtime_1.jsx)(SearchFieldText_1.SearchFieldText, Object.assign({
@@ -66,6 +65,7 @@ exports.Search = (0, react_1.forwardRef)(function Search(_a, ref) {
66
65
  placeholder: placeholder,
67
66
  className: className,
68
67
  ref: ref,
69
- tabIndex: tabIndex
68
+ tabIndex: tabIndex,
69
+ postfix: postfix
70
70
  }, supportProps));
71
71
  });
@@ -1,22 +1,21 @@
1
1
  import { BaseItemProps } from '@snack-uikit/list';
2
- import { SearchPrivateProps } from '@snack-uikit/search-private';
3
- export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
2
+ import { SearchBaseProps } from '../../types';
3
+ export type SearchAutocompleteProps = SearchBaseProps & {
4
4
  /**
5
5
  * Элементы выпадающие в Droplist в режиме Autocomplete.
6
6
  *
7
7
  * На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
8
8
  */
9
9
  options: BaseItemProps[];
10
- /** Внешний бордер */
11
- outline?: boolean;
12
10
  };
13
- export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
11
+ export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
12
+ outline?: boolean;
13
+ postfix?: import("react").ReactNode;
14
+ } & {
14
15
  /**
15
16
  * Элементы выпадающие в Droplist в режиме Autocomplete.
16
17
  *
17
18
  * На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
18
19
  */
19
20
  options: BaseItemProps[];
20
- /** Внешний бордер */
21
- outline?: boolean;
22
21
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -38,9 +38,10 @@ exports.SearchAutocomplete = (0, react_1.forwardRef)(function SearchAutocomplete
38
38
  onSubmit,
39
39
  onFocus,
40
40
  className,
41
- tabIndex
41
+ tabIndex,
42
+ postfix
42
43
  } = _a,
43
- rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex"]);
44
+ rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex", "postfix"]);
44
45
  const scrollRef = (0, react_1.useRef)(null);
45
46
  const localRef = (0, react_1.useRef)(null);
46
47
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
@@ -121,6 +122,7 @@ exports.SearchAutocomplete = (0, react_1.forwardRef)(function SearchAutocomplete
121
122
  outline: outline || undefined,
122
123
  focused: isOpen && Boolean((_a = localRef.current) === null || _a === void 0 ? void 0 : _a.value) || undefined,
123
124
  "data-test-id": constants_1.TEST_IDS.decorator,
125
+ postfix: postfix,
124
126
  children: (0, jsx_runtime_1.jsx)(search_private_1.SearchPrivate, {
125
127
  loading: loading,
126
128
  value: value,
@@ -1,9 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
- import { SearchProps } from '../Search';
3
+ import { SearchBaseProps } from '../../types';
4
4
  export type SearchDecoratorProps = WithSupportProps<{
5
5
  children: ReactNode;
6
6
  focused?: boolean;
7
7
  className?: string;
8
- } & Pick<SearchProps, 'outline' | 'size'>>;
9
- export declare function SearchDecorator({ children, outline, size, focused, className, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
8
+ } & Pick<SearchBaseProps, 'outline' | 'size' | 'postfix'>>;
9
+ export declare function SearchDecorator({ children, outline, size, focused, className, postfix, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
@@ -28,15 +28,16 @@ function SearchDecorator(_a) {
28
28
  outline,
29
29
  size = constants_1.SIZE.S,
30
30
  focused,
31
- className
31
+ className,
32
+ postfix
32
33
  } = _a,
33
- rest = __rest(_a, ["children", "outline", "size", "focused", "className"]);
34
- return (0, jsx_runtime_1.jsx)("div", Object.assign({
34
+ rest = __rest(_a, ["children", "outline", "size", "focused", "className", "postfix"]);
35
+ return (0, jsx_runtime_1.jsxs)("div", Object.assign({
35
36
  className: (0, classnames_1.default)(styles_module_scss_1.default.decorator, className),
36
37
  "data-outline": outline || undefined,
37
38
  "data-size": size,
38
39
  "data-focused": focused || undefined
39
40
  }, (0, utils_1.extractSupportProps)(rest), {
40
- children: children
41
+ children: [children, postfix]
41
42
  }));
42
43
  }
@@ -1,9 +1,6 @@
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
- /** Внешний бордер */
1
+ import { SearchBaseProps } from '../../types';
2
+ export type SearchTextFieldProps = SearchBaseProps;
3
+ export declare const SearchFieldText: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
8
4
  outline?: boolean;
5
+ postfix?: import("react").ReactNode;
9
6
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,3 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { SearchPrivateProps } from '@snack-uikit/search-private';
1
3
  import { ValueOf } from '@snack-uikit/utils';
2
4
  import { SIZE } from './constants';
3
5
  export type Size = ValueOf<typeof SIZE>;
6
+ export type SearchBaseProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
7
+ /** Внешний бордер */
8
+ outline?: boolean;
9
+ /** Произвольный постфикс для поля */
10
+ postfix?: ReactNode;
11
+ };
@@ -1,9 +1,6 @@
1
- import { SearchPrivateProps } from '@snack-uikit/search-private';
1
+ import { SearchBaseProps } from '../../types';
2
2
  import { SearchAutocompleteProps } from '../SearchAutocomplete';
3
- export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
4
- /** Внешний бордер */
5
- outline?: boolean;
6
- } & ((Pick<SearchAutocompleteProps, 'options'> & {
3
+ export type SearchProps = SearchBaseProps & ((Pick<SearchAutocompleteProps, 'options'> & {
7
4
  /**
8
5
  * Работа в режиме Autocomplete в значении true
9
6
  *
@@ -12,7 +9,7 @@ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
12
9
  autocomplete: true;
13
10
  }) | {
14
11
  autocomplete?: false;
15
- /** В режиме FieldText options отсутсвуют */
12
+ /** В режиме FieldText options отсутствуют */
16
13
  options?: never;
17
14
  });
18
15
  export declare const Search: import("react").ForwardRefExoticComponent<SearchProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -15,12 +15,11 @@ import { extractSupportProps } from '@snack-uikit/utils';
15
15
  import { SIZE } from '../../constants';
16
16
  import { SearchAutocomplete } from '../SearchAutocomplete';
17
17
  import { SearchFieldText } from '../SearchFieldText';
18
- export const Search = forwardRef(function Search(_a, ref) {
19
- var { size = SIZE.S } = _a, props = __rest(_a, ["size"]);
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"]);
18
+ export const Search = forwardRef(function Search(props, ref) {
19
+ const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, tabIndex, postfix, size = SIZE.S } = props, rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "outline", "loading", "placeholder", "onSubmit", "className", "tabIndex", "postfix", "size"]);
21
20
  const supportProps = extractSupportProps(rest);
22
21
  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 }, supportProps)));
22
+ 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, postfix: postfix }, supportProps)));
24
23
  }
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)));
24
+ 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, postfix: postfix }, supportProps)));
26
25
  });
@@ -1,22 +1,21 @@
1
1
  import { BaseItemProps } from '@snack-uikit/list';
2
- import { SearchPrivateProps } from '@snack-uikit/search-private';
3
- export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
2
+ import { SearchBaseProps } from '../../types';
3
+ export type SearchAutocompleteProps = SearchBaseProps & {
4
4
  /**
5
5
  * Элементы выпадающие в Droplist в режиме Autocomplete.
6
6
  *
7
7
  * На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
8
8
  */
9
9
  options: BaseItemProps[];
10
- /** Внешний бордер */
11
- outline?: boolean;
12
10
  };
13
- export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
11
+ export declare const SearchAutocomplete: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
12
+ outline?: boolean;
13
+ postfix?: import("react").ReactNode;
14
+ } & {
14
15
  /**
15
16
  * Элементы выпадающие в Droplist в режиме Autocomplete.
16
17
  *
17
18
  * На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
18
19
  */
19
20
  options: BaseItemProps[];
20
- /** Внешний бордер */
21
- outline?: boolean;
22
21
  } & 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 } = _a, rest = __rest(_a, ["size", "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, postfix } = _a, rest = __rest(_a, ["size", "value", "onChange", "placeholder", "options", "loading", "outline", "onSubmit", "onFocus", "className", "tabIndex", "postfix"]);
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, 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 }) }));
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, postfix: postfix, 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 { SearchProps } from '../Search';
3
+ import { SearchBaseProps } from '../../types';
4
4
  export type SearchDecoratorProps = WithSupportProps<{
5
5
  children: ReactNode;
6
6
  focused?: boolean;
7
7
  className?: string;
8
- } & Pick<SearchProps, 'outline' | 'size'>>;
9
- export declare function SearchDecorator({ children, outline, size, focused, className, ...rest }: SearchDecoratorProps): import("react/jsx-runtime").JSX.Element;
8
+ } & Pick<SearchBaseProps, 'outline' | 'size' | 'postfix'>>;
9
+ export declare function SearchDecorator({ children, outline, size, focused, className, postfix, ...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 { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } 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 } = _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 })));
18
+ var { children, outline, size = SIZE.S, focused, className, postfix } = _a, rest = __rest(_a, ["children", "outline", "size", "focused", "className", "postfix"]);
19
+ return (_jsxs("div", Object.assign({ className: cn(styles.decorator, className), "data-outline": outline || undefined, "data-size": size, "data-focused": focused || undefined }, extractSupportProps(rest), { children: [children, postfix] })));
20
20
  }
@@ -1,9 +1,6 @@
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
- /** Внешний бордер */
1
+ import { SearchBaseProps } from '../../types';
2
+ export type SearchTextFieldProps = SearchBaseProps;
3
+ export declare const SearchFieldText: import("react").ForwardRefExoticComponent<Omit<import("@snack-uikit/search-private").SearchPrivateProps, "onKeyDown"> & {
8
4
  outline?: boolean;
5
+ postfix?: import("react").ReactNode;
9
6
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,3 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { SearchPrivateProps } from '@snack-uikit/search-private';
1
3
  import { ValueOf } from '@snack-uikit/utils';
2
4
  import { SIZE } from './constants';
3
5
  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-preview-644edaa1.0",
7
+ "version": "0.12.0",
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.29.7-preview-644edaa1.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": "3a8c0893412768a16a57ffad69934ffda7383e83"
48
+ "gitHead": "36797d7f773dfbc80567421efca8ad28714f9c83"
49
49
  }
@@ -1,16 +1,14 @@
1
1
  import { forwardRef } from 'react';
2
2
 
3
- import { SearchPrivateProps } from '@snack-uikit/search-private';
4
3
  import { extractSupportProps } from '@snack-uikit/utils';
5
4
 
6
5
  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 = Omit<SearchPrivateProps, 'onKeyDown'> & {
11
- /** Внешний бордер */
12
- outline?: boolean;
13
- } & (
10
+ export type SearchProps = SearchBaseProps &
11
+ (
14
12
  | (Pick<SearchAutocompleteProps, 'options'> & {
15
13
  /**
16
14
  * Работа в режиме Autocomplete в значении true
@@ -21,14 +19,27 @@ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
21
19
  })
22
20
  | {
23
21
  autocomplete?: false;
24
- /** В режиме FieldText options отсутсвуют */
22
+ /** В режиме FieldText options отсутствуют */
25
23
  options?: never;
26
24
  }
27
25
  );
28
26
 
29
- export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search({ size = SIZE.S, ...props }, ref) {
30
- const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, tabIndex, ...rest } =
31
- props;
27
+ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(props, ref) {
28
+ const {
29
+ value,
30
+ onChange,
31
+ onBlur,
32
+ onFocus,
33
+ outline,
34
+ loading,
35
+ placeholder,
36
+ onSubmit,
37
+ className,
38
+ tabIndex,
39
+ postfix,
40
+ size = SIZE.S,
41
+ ...rest
42
+ } = props;
32
43
  const supportProps = extractSupportProps(rest);
33
44
 
34
45
  if (props.autocomplete) {
@@ -47,6 +58,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(
47
58
  className={className}
48
59
  ref={ref}
49
60
  tabIndex={tabIndex}
61
+ postfix={postfix}
50
62
  {...supportProps}
51
63
  />
52
64
  );
@@ -66,6 +78,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(
66
78
  className={className}
67
79
  ref={ref}
68
80
  tabIndex={tabIndex}
81
+ postfix={postfix}
69
82
  {...supportProps}
70
83
  />
71
84
  );
@@ -12,21 +12,20 @@ import {
12
12
  } from 'react';
13
13
 
14
14
  import { BaseItemProps, Droplist } from '@snack-uikit/list';
15
- import { SearchPrivate, SearchPrivateProps } from '@snack-uikit/search-private';
15
+ import { SearchPrivate } from '@snack-uikit/search-private';
16
16
 
17
17
  import { PRIVATE_SEARCH_TEST_IDS, SIZE, TEST_IDS } from '../../constants';
18
+ import { SearchBaseProps } from '../../types';
18
19
  import { SearchDecorator } from '../SearchDecorator';
19
20
  import styles from './styles.module.scss';
20
21
 
21
- export type SearchAutocompleteProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
22
+ export type SearchAutocompleteProps = SearchBaseProps & {
22
23
  /**
23
24
  * Элементы выпадающие в Droplist в режиме Autocomplete.
24
25
  *
25
26
  * На нажатие 'Space', 'Enter' или клике по элементу будет вызываться onSubmit.
26
27
  */
27
28
  options: BaseItemProps[];
28
- /** Внешний бордер */
29
- outline?: boolean;
30
29
  };
31
30
 
32
31
  export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocompleteProps>(function SearchAutocomplete(
@@ -42,6 +41,7 @@ export const SearchAutocomplete = forwardRef<HTMLInputElement, SearchAutocomplet
42
41
  onFocus,
43
42
  className,
44
43
  tabIndex,
44
+ postfix,
45
45
  ...rest
46
46
  },
47
47
  ref,
@@ -132,6 +132,7 @@ 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}
135
136
  >
136
137
  <SearchPrivate
137
138
  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 { SearchProps } from '../Search';
7
+ import { SearchBaseProps } from '../../types';
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<SearchProps, 'outline' | 'size'>
15
+ } & Pick<SearchBaseProps, 'outline' | 'size' | 'postfix'>
16
16
  >;
17
17
 
18
18
  export function SearchDecorator({
@@ -21,6 +21,7 @@ export function SearchDecorator({
21
21
  size = SIZE.S,
22
22
  focused,
23
23
  className,
24
+ postfix,
24
25
  ...rest
25
26
  }: SearchDecoratorProps) {
26
27
  return (
@@ -32,6 +33,7 @@ export function SearchDecorator({
32
33
  {...extractSupportProps(rest)}
33
34
  >
34
35
  {children}
36
+ {postfix}
35
37
  </div>
36
38
  );
37
39
  }
@@ -1,14 +1,12 @@
1
1
  import { forwardRef } from 'react';
2
2
 
3
- import { SearchPrivate, SearchPrivateProps } from '@snack-uikit/search-private';
3
+ import { SearchPrivate } from '@snack-uikit/search-private';
4
4
 
5
5
  import { PRIVATE_SEARCH_TEST_IDS, SIZE } from '../../constants';
6
+ import { SearchBaseProps } from '../../types';
6
7
  import { SearchDecorator } from '../SearchDecorator';
7
8
 
8
- export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
9
- /** Внешний бордер */
10
- outline?: boolean;
11
- };
9
+ export type SearchTextFieldProps = SearchBaseProps;
12
10
 
13
11
  export const SearchFieldText = forwardRef<HTMLInputElement, SearchTextFieldProps>(function SearchFieldText(
14
12
  {
package/src/types.ts CHANGED
@@ -1,5 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { SearchPrivateProps } from '@snack-uikit/search-private';
1
4
  import { ValueOf } from '@snack-uikit/utils';
2
5
 
3
6
  import { SIZE } from './constants';
4
7
 
5
8
  export type Size = ValueOf<typeof SIZE>;
9
+
10
+ export type SearchBaseProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
11
+ /** Внешний бордер */
12
+ outline?: boolean;
13
+ /** Произвольный постфикс для поля */
14
+ postfix?: ReactNode;
15
+ };