@snack-uikit/search 0.4.13-preview-85c5f47b.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +301 -0
  2. package/LICENSE +201 -0
  3. package/README.md +74 -0
  4. package/dist/components/Search/Search.d.ts +22 -0
  5. package/dist/components/Search/Search.js +28 -0
  6. package/dist/components/Search/index.d.ts +1 -0
  7. package/dist/components/Search/index.js +1 -0
  8. package/dist/components/SearchAutocomplete/SearchAutocomplete.d.ts +23 -0
  9. package/dist/components/SearchAutocomplete/SearchAutocomplete.js +53 -0
  10. package/dist/components/SearchAutocomplete/index.d.ts +1 -0
  11. package/dist/components/SearchAutocomplete/index.js +1 -0
  12. package/dist/components/SearchAutocomplete/styles.module.css +9 -0
  13. package/dist/components/SearchDecorator/SearchDecorator.d.ts +13 -0
  14. package/dist/components/SearchDecorator/SearchDecorator.js +21 -0
  15. package/dist/components/SearchDecorator/index.d.ts +1 -0
  16. package/dist/components/SearchDecorator/index.js +1 -0
  17. package/dist/components/SearchDecorator/styles.module.css +45 -0
  18. package/dist/components/SearchFieldText/SearchFieldText.d.ts +10 -0
  19. package/dist/components/SearchFieldText/SearchFieldText.js +20 -0
  20. package/dist/components/SearchFieldText/index.d.ts +1 -0
  21. package/dist/components/SearchFieldText/index.js +1 -0
  22. package/dist/components/SearchPrivate/SearchPrivate.d.ts +28 -0
  23. package/dist/components/SearchPrivate/SearchPrivate.js +63 -0
  24. package/dist/components/SearchPrivate/index.d.ts +1 -0
  25. package/dist/components/SearchPrivate/index.js +1 -0
  26. package/dist/components/SearchPrivate/styles.module.css +68 -0
  27. package/dist/components/index.d.ts +2 -0
  28. package/dist/components/index.js +2 -0
  29. package/dist/constants.d.ts +18 -0
  30. package/dist/constants.js +19 -0
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/package.json +48 -0
  34. package/src/components/Search/Search.tsx +75 -0
  35. package/src/components/Search/index.ts +1 -0
  36. package/src/components/SearchAutocomplete/SearchAutocomplete.tsx +128 -0
  37. package/src/components/SearchAutocomplete/index.ts +1 -0
  38. package/src/components/SearchAutocomplete/styles.module.scss +13 -0
  39. package/src/components/SearchDecorator/SearchDecorator.tsx +39 -0
  40. package/src/components/SearchDecorator/index.ts +1 -0
  41. package/src/components/SearchDecorator/styles.module.scss +41 -0
  42. package/src/components/SearchFieldText/SearchFieldText.tsx +32 -0
  43. package/src/components/SearchFieldText/index.ts +1 -0
  44. package/src/components/SearchPrivate/SearchPrivate.tsx +130 -0
  45. package/src/components/SearchPrivate/index.ts +1 -0
  46. package/src/components/SearchPrivate/styles.module.scss +43 -0
  47. package/src/components/index.ts +2 -0
  48. package/src/constants.ts +20 -0
  49. package/src/index.ts +1 -0
@@ -0,0 +1,53 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { createElement as _createElement } from "react";
14
+ import cn from 'classnames';
15
+ import mergeRefs from 'merge-refs';
16
+ import { forwardRef, useCallback, useRef, useState } from 'react';
17
+ import { Droplist } from '@snack-uikit/droplist';
18
+ import { PRIVATE_SEARCH_TEST_IDS, Size, TEST_IDS } from '../../constants';
19
+ import { SearchDecorator } from '../SearchDecorator';
20
+ import { SearchPrivate } from '../SearchPrivate';
21
+ import styles from './styles.module.css';
22
+ export const SearchAutocomplete = forwardRef(function SearchAutocomplete(_a, ref) {
23
+ var _b, _c;
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
+ const scrollRef = useRef(null);
26
+ const [isOpen, setIsOpen] = useState(false);
27
+ const { firstElementRefCallback, handleDroplistFocusLeave, handleDroplistItemClick, handleTriggerKeyDown, handleDroplistItemKeyDown, triggerElementRef, } = Droplist.useKeyboardNavigation({
28
+ setDroplistOpen: setIsOpen,
29
+ triggerType: Droplist.useKeyboardNavigation.triggerTypes.Input,
30
+ });
31
+ const handleOptionKeyDown = useCallback((event) => {
32
+ var _a, _b;
33
+ event.stopPropagation();
34
+ // ignoring special keys (tab, arrows, backspace and etc.)
35
+ if (event.key.length === 1) {
36
+ (_a = triggerElementRef.current) === null || _a === void 0 ? void 0 : _a.focus();
37
+ (_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scroll(0, 0);
38
+ }
39
+ }, [triggerElementRef, scrollRef]);
40
+ const onKeyDown = (e) => {
41
+ handleTriggerKeyDown(e);
42
+ if (e.key.length === 1) {
43
+ setIsOpen(true);
44
+ }
45
+ };
46
+ return (_jsx("div", Object.assign({ className: cn(styles.wrap, className) }, rest, { children: _jsx(Droplist, Object.assign({ open: Boolean((_b = triggerElementRef.current) === null || _b === void 0 ? void 0 : _b.value) && isOpen && options.length > 0, firstElementRefCallback: firstElementRefCallback, useScroll: true, size: size, onFocusLeave: handleDroplistFocusLeave, onOpenChange: setIsOpen, "data-test-id": TEST_IDS.droplist, triggerClassName: styles.triggerClassName, scrollRef: scrollRef, triggerRef: triggerElementRef, triggerElement: _jsx(SearchDecorator, Object.assign({ size: size, outline: outline || undefined, focused: (isOpen && Boolean((_c = triggerElementRef.current) === null || _c === void 0 ? void 0 : _c.value)) || undefined, "data-test-id": TEST_IDS.decorator }, { children: _jsx(SearchPrivate, { loading: loading, value: value, onChange: onChange, onSubmit: onSubmit, placeholder: placeholder, ref: mergeRefs(ref, triggerElementRef), onKeyDown: onKeyDown, onFocus: onFocus, size: size, "data-test-id": PRIVATE_SEARCH_TEST_IDS.field }) })) }, { children: options.map(item => (_createElement(Droplist.ItemSingle, Object.assign({}, item, { key: item.option, onClick: e => {
47
+ var _a;
48
+ handleDroplistItemClick(e);
49
+ onChange === null || onChange === void 0 ? void 0 : onChange(item.option);
50
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(item.option);
51
+ (_a = triggerElementRef.current) === null || _a === void 0 ? void 0 : _a.blur();
52
+ }, onKeyDown: e => handleDroplistItemKeyDown(e, handleOptionKeyDown), "data-test-id": TEST_IDS.option })))) })) })));
53
+ });
@@ -0,0 +1 @@
1
+ export * from './SearchAutocomplete';
@@ -0,0 +1 @@
1
+ export * from './SearchAutocomplete';
@@ -0,0 +1,9 @@
1
+ .triggerClassName{
2
+ --offset:var(--space-drop-list-drop-offset, 4px);
3
+ display:flex;
4
+ flex-grow:1;
5
+ }
6
+
7
+ .wrap{
8
+ display:flex;
9
+ }
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { Size } from '../../constants';
4
+ import { SearchProps } from '../Search';
5
+ export type SearchDecoratorProps = WithSupportProps<{
6
+ children: ReactNode;
7
+ focused?: boolean;
8
+ className?: string;
9
+ } & Pick<SearchProps, 'outline' | 'size'>>;
10
+ 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
+ }
@@ -0,0 +1,21 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import { extractSupportProps } from '@snack-uikit/utils';
15
+ import { Size } from '../../constants';
16
+ import styles from './styles.module.css';
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 })));
20
+ }
21
+ SearchDecorator.sizes = Size;
@@ -0,0 +1 @@
1
+ export * from './SearchDecorator';
@@ -0,0 +1 @@
1
+ export * from './SearchDecorator';
@@ -0,0 +1,45 @@
1
+ .decorator{
2
+ display:flex;
3
+ flex:1 0 auto;
4
+ align-items:center;
5
+ box-sizing:border-box;
6
+ background-color:var(--sys-neutral-background1-level, #f9f9f9);
7
+ border-color:transparent;
8
+ border-style:solid;
9
+ }
10
+ .decorator[data-size=s]{
11
+ height:var(--size-search-s, 32px);
12
+ border-radius:var(--radius-search-s, 12px);
13
+ border-width:var(--border-width-search-single, 2px);
14
+ padding-left:var(--space-search-container-s, 6px);
15
+ padding-right:var(--space-search-container-s, 6px);
16
+ }
17
+ .decorator[data-size=m]{
18
+ height:var(--size-search-m, 40px);
19
+ border-radius:var(--radius-search-m, 14px);
20
+ border-width:var(--border-width-search-single, 2px);
21
+ padding-left:var(--space-search-container-m, 8px);
22
+ padding-right:var(--space-search-container-m, 8px);
23
+ }
24
+ .decorator[data-size=l]{
25
+ height:var(--size-search-l, 48px);
26
+ border-radius:var(--radius-search-l, 16px);
27
+ border-width:var(--border-width-search-single, 2px);
28
+ padding-left:var(--space-search-container-l, 10px);
29
+ padding-right:var(--space-search-container-l, 10px);
30
+ }
31
+ .decorator[data-outline]{
32
+ border-color:var(--sys-neutral-decor-default, #dedede);
33
+ }
34
+ .decorator:hover{
35
+ background-color:var(--sys-neutral-background2-level, #fdfdfd);
36
+ border-color:var(--sys-primary-decor-hovered, #decdfb);
37
+ }
38
+ .decorator:focus-within, .decorator[data-focused]{
39
+ outline-width:var(--border-state-focus-m-border-width, 3px);
40
+ outline-style:var(--border-state-focus-m-border-style, solid);
41
+ outline-color:var(--border-state-focus-m-border-color, );
42
+ background-color:var(--sys-neutral-background2-level, #fdfdfd);
43
+ border-color:var(--sys-primary-accent-default, #794ed3);
44
+ outline-color:var(--sys-primary-decor-activated, #c5b2f1);
45
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { SearchPrivateProps } from '../SearchPrivate';
3
+ export type SearchTextFieldProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
4
+ /** Внешний бордер */
5
+ outline?: boolean;
6
+ };
7
+ export declare const SearchFieldText: import("react").ForwardRefExoticComponent<Omit<SearchPrivateProps, "onKeyDown"> & {
8
+ /** Внешний бордер */
9
+ outline?: boolean | undefined;
10
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,20 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { forwardRef } from 'react';
14
+ import { PRIVATE_SEARCH_TEST_IDS, Size } from '../../constants';
15
+ import { SearchDecorator } from '../SearchDecorator';
16
+ import { SearchPrivate } from '../SearchPrivate';
17
+ export const SearchFieldText = forwardRef(function SearchFieldText(_a, ref) {
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
+ 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
+ });
@@ -0,0 +1 @@
1
+ export * from './SearchFieldText';
@@ -0,0 +1 @@
1
+ export * from './SearchFieldText';
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import { InputPrivateProps } from '@snack-uikit/input-private';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ import { Size } from '../../constants';
5
+ export type SearchPrivateProps = WithSupportProps<{
6
+ /** Размер */
7
+ size?: Size;
8
+ /** Состояние загрузки */
9
+ loading?: boolean;
10
+ /** Колбек на подтверждение поиска по строке */
11
+ onSubmit?(value: string): void;
12
+ /** CSS-класс */
13
+ className?: string;
14
+ } & Pick<Partial<InputPrivateProps>, 'value' | 'onChange' | 'placeholder' | 'onFocus' | 'onBlur' | 'onKeyDown'>>;
15
+ export declare const SearchPrivate: import("react").ForwardRefExoticComponent<{
16
+ 'data-test-id'?: string | undefined;
17
+ } & import("react").AriaAttributes & {
18
+ /** Размер */
19
+ size?: Size | undefined;
20
+ /** Состояние загрузки */
21
+ loading?: boolean | undefined;
22
+ /** Колбек на подтверждение поиска по строке */
23
+ onSubmit?(value: string): void;
24
+ /** CSS-класс */
25
+ className?: string | undefined;
26
+ } & Pick<Partial<InputPrivateProps>, "value" | "onChange" | "placeholder" | "onFocus" | "onBlur" | "onKeyDown"> & import("react").RefAttributes<HTMLInputElement>> & {
27
+ sizes: typeof Size;
28
+ };
@@ -0,0 +1,63 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import mergeRefs from 'merge-refs';
15
+ import { forwardRef, useCallback, useMemo, useRef } from 'react';
16
+ import { useUncontrolledProp } from 'uncontrollable';
17
+ import { SearchSVG } from '@snack-uikit/icons';
18
+ import { InputPrivate, moveCursorToEnd, useButtonNavigation, useClearButton, } from '@snack-uikit/input-private';
19
+ import { Sun } from '@snack-uikit/loaders';
20
+ import { extractSupportProps } from '@snack-uikit/utils';
21
+ import { PRIVATE_SEARCH_TEST_IDS, Size } from '../../constants';
22
+ import styles from './styles.module.css';
23
+ const SearchPrivateComponent = 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
+ const [value, onValueChange] = useUncontrolledProp(valueProp, '', onChangeProp);
26
+ const localRef = useRef(null);
27
+ const clearButtonRef = useRef(null);
28
+ const showClearButton = Boolean(value);
29
+ const onClear = () => {
30
+ var _a;
31
+ onValueChange('');
32
+ (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus();
33
+ };
34
+ const clearButtonSettings = useClearButton({
35
+ clearButtonRef,
36
+ showClearButton,
37
+ size,
38
+ onClear,
39
+ });
40
+ const { buttons, inputTabIndex, onInputKeyDown } = useButtonNavigation({
41
+ inputRef: localRef,
42
+ buttons: useMemo(() => [clearButtonSettings], [clearButtonSettings]),
43
+ readonly: false,
44
+ submitKeys: ['Enter', 'Space'],
45
+ });
46
+ const handleKeyDown = useCallback((e) => {
47
+ var _a, _b;
48
+ onKeyDown && onKeyDown(e);
49
+ onInputKeyDown(e);
50
+ if (e.key === 'Enter' && ((_a = localRef.current) === null || _a === void 0 ? void 0 : _a.value)) {
51
+ onSubmit && onSubmit(localRef.current.value);
52
+ // TODO: think about remove blur behavior
53
+ (_b = localRef.current) === null || _b === void 0 ? void 0 : _b.blur();
54
+ }
55
+ }, [onInputKeyDown, onKeyDown, onSubmit]);
56
+ const handleOnFocus = useCallback((e) => {
57
+ onFocus && onFocus(e);
58
+ moveCursorToEnd(localRef.current);
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: InputPrivate.types.Text, "data-test-id": PRIVATE_SEARCH_TEST_IDS.input }), _jsx("span", Object.assign({ className: styles.postfix }, { children: buttons }))] })));
61
+ });
62
+ export const SearchPrivate = SearchPrivateComponent;
63
+ SearchPrivate.sizes = Size;
@@ -0,0 +1 @@
1
+ export * from './SearchPrivate';
@@ -0,0 +1 @@
1
+ export * from './SearchPrivate';
@@ -0,0 +1,68 @@
1
+ .container{
2
+ display:flex;
3
+ flex-grow:1;
4
+ align-items:center;
5
+ box-sizing:border-box;
6
+ }
7
+ .container[data-size=s]{
8
+ gap:var(--space-search-search-private-s, 4px);
9
+ }
10
+ .container[data-size=s] input{
11
+ font-family:var(--sans-body-s-font-family, SB Sans Interface);
12
+ font-weight:var(--sans-body-s-font-weight, Regular);
13
+ line-height:var(--sans-body-s-line-height, 16px);
14
+ font-size:var(--sans-body-s-font-size, 12px);
15
+ letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
16
+ paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
17
+ cursor:text;
18
+ }
19
+ .container[data-size=s] svg{
20
+ width:var(--dimension-3m, 24px) !important;
21
+ height:var(--dimension-3m, 24px) !important;
22
+ }
23
+ .container[data-size=m]{
24
+ gap:var(--space-search-search-private-m, 4px);
25
+ }
26
+ .container[data-size=m] input{
27
+ font-family:var(--sans-body-m-font-family, SB Sans Interface);
28
+ font-weight:var(--sans-body-m-font-weight, Regular);
29
+ line-height:var(--sans-body-m-line-height, 20px);
30
+ font-size:var(--sans-body-m-font-size, 14px);
31
+ letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
32
+ paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
33
+ cursor:text;
34
+ }
35
+ .container[data-size=m] svg{
36
+ width:var(--dimension-3m, 24px) !important;
37
+ height:var(--dimension-3m, 24px) !important;
38
+ }
39
+ .container[data-size=l]{
40
+ gap:var(--space-search-search-private-l, 8px);
41
+ }
42
+ .container[data-size=l] input{
43
+ font-family:var(--sans-body-l-font-family, SB Sans Interface);
44
+ font-weight:var(--sans-body-l-font-weight, Regular);
45
+ line-height:var(--sans-body-l-line-height, 24px);
46
+ font-size:var(--sans-body-l-font-size, 16px);
47
+ letter-spacing:var(--sans-body-l-letter-spacing, 0.1px);
48
+ paragraph-spacing:var(--sans-body-l-paragraph-spacing, 8.8px);
49
+ cursor:text;
50
+ }
51
+ .container[data-size=l] svg{
52
+ width:var(--dimension-3m, 24px) !important;
53
+ height:var(--dimension-3m, 24px) !important;
54
+ }
55
+
56
+ .prefix{
57
+ display:inline-flex;
58
+ flex-shrink:0;
59
+ align-items:center;
60
+ justify-content:center;
61
+ color:var(--sys-neutral-text-light, #898989);
62
+ }
63
+
64
+ .postfix{
65
+ display:inline-flex;
66
+ flex-shrink:0;
67
+ gap:var(--space-fields-postfix-gap, 4px);
68
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Search';
2
+ export * from './SearchPrivate';
@@ -0,0 +1,2 @@
1
+ export * from './Search';
2
+ export * from './SearchPrivate';
@@ -0,0 +1,18 @@
1
+ export declare enum Size {
2
+ S = "s",
3
+ M = "m",
4
+ L = "l"
5
+ }
6
+ export declare const TEST_IDS: {
7
+ main: string;
8
+ decorator: string;
9
+ droplist: string;
10
+ option: string;
11
+ };
12
+ export declare const PRIVATE_SEARCH_TEST_IDS: {
13
+ field: string;
14
+ input: string;
15
+ iconSun: string;
16
+ iconSearch: string;
17
+ buttonClearValue: string;
18
+ };
@@ -0,0 +1,19 @@
1
+ export var Size;
2
+ (function (Size) {
3
+ Size["S"] = "s";
4
+ Size["M"] = "m";
5
+ Size["L"] = "l";
6
+ })(Size || (Size = {}));
7
+ export const TEST_IDS = {
8
+ main: 'search',
9
+ decorator: 'search__decorator',
10
+ droplist: 'search__droplist',
11
+ option: 'search__option',
12
+ };
13
+ export const PRIVATE_SEARCH_TEST_IDS = {
14
+ field: 'search__field',
15
+ input: 'search__field-input',
16
+ iconSun: 'search__icon-sun',
17
+ iconSearch: 'search__icon-search',
18
+ buttonClearValue: 'button-clear-value',
19
+ };
@@ -0,0 +1 @@
1
+ export * from './components';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './components';
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@snack-uikit/search",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "title": "Search",
7
+ "version": "0.4.13-preview-85c5f47b.0",
8
+ "sideEffects": [
9
+ "*.css",
10
+ "*.woff",
11
+ "*.woff2"
12
+ ],
13
+ "description": "Search",
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.js",
16
+ "homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/search",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/cloud-ru-tech/snack-uikit.git",
20
+ "directory": "packages/search"
21
+ },
22
+ "author": "Nikita Ershov <niershov@cloud.ru>",
23
+ "contributors": [
24
+ "Nikita Ershov <niershov@cloud.ru>"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "src",
29
+ "./CHANGELOG.md",
30
+ "./LICENSE"
31
+ ],
32
+ "license": "Apache-2.0",
33
+ "scripts": {},
34
+ "dependencies": {
35
+ "@snack-uikit/droplist": "0.10.13-preview-85c5f47b.0",
36
+ "@snack-uikit/icons": "0.18.2-preview-85c5f47b.0",
37
+ "@snack-uikit/input-private": "1.5.14-preview-85c5f47b.0",
38
+ "@snack-uikit/loaders": "0.3.5-preview-85c5f47b.0",
39
+ "@snack-uikit/utils": "2.0.2-preview-85c5f47b.0",
40
+ "classnames": "2.3.2",
41
+ "merge-refs": "1.0.0",
42
+ "uncontrollable": "8.0.4"
43
+ },
44
+ "devDependencies": {
45
+ "@types/merge-refs": "1.0.0"
46
+ },
47
+ "gitHead": "6a7eef41d780d945f64f791448eaa72b9e0ae72d"
48
+ }
@@ -0,0 +1,75 @@
1
+ import { forwardRef } from 'react';
2
+
3
+ import { extractSupportProps } from '@snack-uikit/utils';
4
+
5
+ import { Size } from '../../constants';
6
+ import { SearchAutocomplete, SearchAutocompleteProps } from '../SearchAutocomplete';
7
+ import { SearchFieldText } from '../SearchFieldText';
8
+ import { SearchPrivateProps } from '../SearchPrivate';
9
+
10
+ export type SearchProps = Omit<SearchPrivateProps, 'onKeyDown'> & {
11
+ /** Внешний бордер */
12
+ outline?: boolean;
13
+ } & (
14
+ | (Pick<SearchAutocompleteProps, 'options'> & {
15
+ /**
16
+ * Работа в режиме Autocomplete в значении true
17
+ *
18
+ * Работа в режиме FieldText в значении false | undefined
19
+ */
20
+ autocomplete: true;
21
+ })
22
+ | {
23
+ autocomplete?: false;
24
+ /** В режиме FieldText options отсутсвуют */
25
+ options?: never;
26
+ }
27
+ );
28
+
29
+ const SearchComponent = forwardRef<HTMLInputElement, SearchProps>(function Search({ size = Size.S, ...props }, ref) {
30
+ const { value, onChange, onBlur, onFocus, outline, loading, placeholder, onSubmit, className, ...rest } = props;
31
+ const supportProps = extractSupportProps(rest);
32
+
33
+ if (props.autocomplete) {
34
+ return (
35
+ <SearchAutocomplete
36
+ value={value}
37
+ onChange={onChange}
38
+ options={props.options}
39
+ onBlur={onBlur}
40
+ onFocus={onFocus}
41
+ onSubmit={onSubmit}
42
+ size={size}
43
+ outline={outline}
44
+ loading={loading}
45
+ placeholder={placeholder}
46
+ className={className}
47
+ ref={ref}
48
+ {...supportProps}
49
+ />
50
+ );
51
+ }
52
+
53
+ return (
54
+ <SearchFieldText
55
+ value={value}
56
+ onChange={onChange}
57
+ onBlur={onBlur}
58
+ onFocus={onFocus}
59
+ onSubmit={onSubmit}
60
+ size={size}
61
+ outline={outline}
62
+ loading={loading}
63
+ placeholder={placeholder}
64
+ className={className}
65
+ ref={ref}
66
+ {...supportProps}
67
+ />
68
+ );
69
+ });
70
+
71
+ export const Search = SearchComponent as typeof SearchComponent & {
72
+ sizes: typeof Size;
73
+ };
74
+
75
+ Search.sizes = Size;
@@ -0,0 +1 @@
1
+ export * from './Search';