@sima-land/ui-nucleons 45.0.0-alpha.39 → 45.0.0-alpha.40

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sima-land/ui-nucleons",
3
3
  "type": "commonjs",
4
- "version": "45.0.0-alpha.39",
4
+ "version": "45.0.0-alpha.40",
5
5
  "repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
6
6
  "author": "www.sima-land.ru team",
7
7
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@babel/preset-env": "^7.16.11",
43
43
  "@babel/preset-react": "^7.16.7",
44
44
  "@babel/preset-typescript": "^7.16.7",
45
- "@playwright/test": "^1.46.1",
45
+ "@playwright/test": "1.46.1",
46
46
  "@sima-land/linters": "^5.0.0",
47
47
  "@testing-library/react": "^14.0.0",
48
48
  "@testing-library/user-event": "^14.4.3",
@@ -138,6 +138,7 @@
138
138
  "./side-page": "./side-page/index.js",
139
139
  "./side-page/side-page-util.scss": "./side-page/side-page-util.scss",
140
140
  "./skeleton": "./skeleton/index.js",
141
+ "./snackbar": "./snackbar/index.js",
141
142
  "./spinner": "./spinner/index.js",
142
143
  "./stepper": "./stepper/index.js",
143
144
  "./stroked-svg": "./stroked-svg/index.js",
@@ -0,0 +1,17 @@
1
+ import { Dispatch, ReactNode, SetStateAction } from 'react';
2
+ /**
3
+ * Провайдер контекста для вывода нескольких снекбаров.
4
+ * @param props Параметры.
5
+ * @return Элемент.
6
+ */
7
+ export declare function SnackbarContextProvider({ children }: {
8
+ children?: ReactNode;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export declare const SnackbarContext: import("react").Context<ContextProps>;
11
+ interface ContextProps {
12
+ closePrevious?: VoidFunction;
13
+ setClose?: Dispatch<SetStateAction<{
14
+ closePrevious?: VoidFunction;
15
+ }>>;
16
+ }
17
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnackbarContext = void 0;
4
+ exports.SnackbarContextProvider = SnackbarContextProvider;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ /**
8
+ * Провайдер контекста для вывода нескольких снекбаров.
9
+ * @param props Параметры.
10
+ * @return Элемент.
11
+ */
12
+ function SnackbarContextProvider({ children }) {
13
+ const [value, setClose] = (0, react_1.useState)({});
14
+ return ((0, jsx_runtime_1.jsx)(exports.SnackbarContext.Provider, { value: { ...value, setClose }, children: children }));
15
+ }
16
+ exports.SnackbarContext = (0, react_1.createContext)({});
17
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/snack-bar/context.tsx"],"names":[],"mappings":";;;AAOA,0DAMC;;AAbD,iCAAqF;AAErF;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,EAAE,QAAQ,EAA4B;IAC5E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAmC,EAAE,CAAC,CAAC;IAEzE,OAAO,CACL,uBAAC,uBAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,YAAG,QAAQ,GAA4B,CAC/F,CAAC;AACJ,CAAC;AAEY,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAe,EAAE,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { SnackBarImage, SnackBarStartIcon, SnackBarEndIcon, SnackBarTitle, SnackBarSubtitle, } from './slots';
2
+ export { SnackBar } from './snack-bar';
3
+ export { useSnackBarPositioning } from './utils';
4
+ export { SnackbarContextProvider } from './context';
5
+ export type { SnackBarProps } from './types';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnackbarContextProvider = exports.useSnackBarPositioning = exports.SnackBar = exports.SnackBarSubtitle = exports.SnackBarTitle = exports.SnackBarEndIcon = exports.SnackBarStartIcon = exports.SnackBarImage = void 0;
4
+ var slots_1 = require("./slots");
5
+ Object.defineProperty(exports, "SnackBarImage", { enumerable: true, get: function () { return slots_1.SnackBarImage; } });
6
+ Object.defineProperty(exports, "SnackBarStartIcon", { enumerable: true, get: function () { return slots_1.SnackBarStartIcon; } });
7
+ Object.defineProperty(exports, "SnackBarEndIcon", { enumerable: true, get: function () { return slots_1.SnackBarEndIcon; } });
8
+ Object.defineProperty(exports, "SnackBarTitle", { enumerable: true, get: function () { return slots_1.SnackBarTitle; } });
9
+ Object.defineProperty(exports, "SnackBarSubtitle", { enumerable: true, get: function () { return slots_1.SnackBarSubtitle; } });
10
+ var snack_bar_1 = require("./snack-bar");
11
+ Object.defineProperty(exports, "SnackBar", { enumerable: true, get: function () { return snack_bar_1.SnackBar; } });
12
+ var utils_1 = require("./utils");
13
+ Object.defineProperty(exports, "useSnackBarPositioning", { enumerable: true, get: function () { return utils_1.useSnackBarPositioning; } });
14
+ var context_1 = require("./context");
15
+ Object.defineProperty(exports, "SnackbarContextProvider", { enumerable: true, get: function () { return context_1.SnackbarContextProvider; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/snack-bar/index.tsx"],"names":[],"mappings":";;;AAAA,iCAMiB;AALf,sGAAA,aAAa,OAAA;AACb,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AACf,sGAAA,aAAa,OAAA;AACb,yGAAA,gBAAgB,OAAA;AAElB,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,iCAAiD;AAAxC,+GAAA,sBAAsB,OAAA;AAC/B,qCAAoD;AAA3C,kHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,32 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { SnackBarIconProps, SnackBarImageProps } from './types';
3
+ /**
4
+ * Компонент для вывода изображения в Snackbar.
5
+ * @param props Параметры.
6
+ * @return Элемент.
7
+ */
8
+ export declare function SnackBarImage(props: SnackBarImageProps): import("react/jsx-runtime").JSX.Element;
9
+ /**
10
+ * Компонент для вывода иконки в начале контента Snackbar.
11
+ * @param props Параметры.
12
+ * @return Элемент.
13
+ */
14
+ export declare const SnackBarStartIcon: (props: SnackBarIconProps) => import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ * Компонент для вывода иконки в конце контента Snackbar.
17
+ * @param props Параметры.
18
+ * @return Элемент.
19
+ */
20
+ export declare const SnackBarEndIcon: (props: SnackBarIconProps) => import("react/jsx-runtime").JSX.Element;
21
+ /**
22
+ * Компонент для вывода заголовка в Snackbar.
23
+ * @param props Параметры.
24
+ * @return Элемент.
25
+ */
26
+ export declare function SnackBarTitle({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
27
+ /**
28
+ * Компонент для вывода подзаголовка в Snackbar.
29
+ * @param props Параметры.
30
+ * @return Элемент.
31
+ */
32
+ export declare function SnackBarSubtitle({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SnackBarEndIcon = exports.SnackBarStartIcon = void 0;
7
+ exports.SnackBarImage = SnackBarImage;
8
+ exports.SnackBarTitle = SnackBarTitle;
9
+ exports.SnackBarSubtitle = SnackBarSubtitle;
10
+ const jsx_runtime_1 = require("react/jsx-runtime");
11
+ const snack_bar_m_scss_1 = __importDefault(require("./snack-bar.m.scss"));
12
+ const classnames_1 = __importDefault(require("classnames"));
13
+ /**
14
+ * Компонент для вывода изображения в Snackbar.
15
+ * @param props Параметры.
16
+ * @return Элемент.
17
+ */
18
+ function SnackBarImage(props) {
19
+ return ((0, jsx_runtime_1.jsx)("div", { className: snack_bar_m_scss_1.default.image, children: (0, jsx_runtime_1.jsx)("img", { ...props }) }));
20
+ }
21
+ /**
22
+ * Компонент для вывода иконки в Snackbar.
23
+ * @param props Параметры.
24
+ * @return Элемент.
25
+ */
26
+ function Icon({ icon, onClick, className, ...props }) {
27
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(snack_bar_m_scss_1.default.icon, className), onClick: onClick
28
+ ? event => {
29
+ event.stopPropagation();
30
+ onClick(event);
31
+ }
32
+ : undefined, ...props, children: icon }));
33
+ }
34
+ /**
35
+ * Компонент для вывода иконки в начале контента Snackbar.
36
+ * @param props Параметры.
37
+ * @return Элемент.
38
+ */
39
+ const SnackBarStartIcon = (props) => (0, jsx_runtime_1.jsx)(Icon, { ...props });
40
+ exports.SnackBarStartIcon = SnackBarStartIcon;
41
+ /**
42
+ * Компонент для вывода иконки в конце контента Snackbar.
43
+ * @param props Параметры.
44
+ * @return Элемент.
45
+ */
46
+ const SnackBarEndIcon = (props) => (0, jsx_runtime_1.jsx)(Icon, { ...props });
47
+ exports.SnackBarEndIcon = SnackBarEndIcon;
48
+ /**
49
+ * Компонент для вывода заголовка в Snackbar.
50
+ * @param props Параметры.
51
+ * @return Элемент.
52
+ */
53
+ function SnackBarTitle({ children, className, ...props }) {
54
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(snack_bar_m_scss_1.default.title, className), ...props, children: children }));
55
+ }
56
+ /**
57
+ * Компонент для вывода подзаголовка в Snackbar.
58
+ * @param props Параметры.
59
+ * @return Элемент.
60
+ */
61
+ function SnackBarSubtitle({ children, className, ...props }) {
62
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(snack_bar_m_scss_1.default.subtitle, className), ...props, children: children }));
63
+ }
64
+ //# sourceMappingURL=slots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slots.js","sourceRoot":"","sources":["../../src/snack-bar/slots.tsx"],"names":[],"mappings":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AAK,EACuB;IAC/B,OAAO,CACL,gCAAK,SAAS,EAAE,IAAA,oBAAE,EAAC,0BAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAM,KAAK,YACtD,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { SnackBarProps } from './types';
2
+ /**
3
+ * Компонент Snackbar.
4
+ * @param props Параметры.
5
+ * @return Элемент.
6
+ */
7
+ export declare function SnackBar({ onClick, children, className, onMount, ...props }: SnackBarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SnackBar = SnackBar;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const button_1 = require("../button");
9
+ const helpers_1 = require("../helpers");
10
+ const text_button_1 = require("../text-button");
11
+ const snack_bar_m_scss_1 = __importDefault(require("./snack-bar.m.scss"));
12
+ const slots_1 = require("./slots");
13
+ const react_1 = require("react");
14
+ const classnames_1 = __importDefault(require("classnames"));
15
+ /**
16
+ * Компонент Snackbar.
17
+ * @param props Параметры.
18
+ * @return Элемент.
19
+ */
20
+ function SnackBar({ onClick, children, className, onMount, ...props }) {
21
+ const ref = (0, react_1.useRef)(null);
22
+ const { image, title, subtitle, startIcon, button, textButton, endIcon } = (0, helpers_1.defineSlots)(children, {
23
+ image: slots_1.SnackBarImage,
24
+ startIcon: slots_1.SnackBarStartIcon,
25
+ title: slots_1.SnackBarTitle,
26
+ subtitle: slots_1.SnackBarSubtitle,
27
+ button: button_1.Button,
28
+ textButton: text_button_1.TextButton,
29
+ endIcon: slots_1.SnackBarEndIcon,
30
+ });
31
+ (0, react_1.useEffect)(() => {
32
+ onMount?.();
33
+ }, []);
34
+ const asButtonProps = { tabIndex: props.tabIndex || 0, role: props.role || 'button' };
35
+ const hasButton = Boolean(button || textButton);
36
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(snack_bar_m_scss_1.default.root, snack_bar_m_scss_1.default.shown, className), onClick: !hasButton ? onClick : undefined, ref: ref, ...(!hasButton && asButtonProps), ...props, children: [image || startIcon, title && ((0, jsx_runtime_1.jsxs)("div", { className: snack_bar_m_scss_1.default.content, children: [title, subtitle] })), hasButton && ((0, jsx_runtime_1.jsx)("div", { onClick: onClick, className: snack_bar_m_scss_1.default.button, ...asButtonProps, children: button || textButton })), endIcon] }));
37
+ }
38
+ //# sourceMappingURL=snack-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snack-bar.js","sourceRoot":"","sources":["../../src/snack-bar/snack-bar.tsx"],"names":[],"mappings":";;;;;AAoBA,4BA2CC;;AA/DD,sCAAmC;AACnC,wCAAyC;AACzC,gDAA4C;AAE5C,0EAAwC;AACxC,mCAMiB;AACjB,iCAA0C;AAC1C,4DAA4B;AAE5B;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,EAAiB;IACzF,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAA,qBAAW,EAAC,QAAQ,EAAE;QAC/F,KAAK,EAAE,qBAAa;QACpB,SAAS,EAAE,yBAAiB;QAC5B,KAAK,EAAE,qBAAa;QACpB,QAAQ,EAAE,wBAAgB;QAC1B,MAAM,EAAE,eAAM;QACd,UAAU,EAAE,wBAAU;QACtB,OAAO,EAAE,uBAAe;KACzB,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,EAAE,EAAE,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;IAEtF,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,CAAC;IAEhD,OAAO,CACL,iCACE,SAAS,EAAE,IAAA,oBAAE,EAAC,0BAAM,CAAC,IAAI,EAAE,0BAAM,CAAC,KAAK,EAAE,SAAS,CAAC,EACnD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACzC,GAAG,EAAE,GAAG,KACJ,CAAC,CAAC,SAAS,IAAI,aAAa,CAAC,KAC7B,KAAK,aAER,KAAK,IAAI,SAAS,EAClB,KAAK,IAAI,CACR,iCAAK,SAAS,EAAE,0BAAM,CAAC,OAAO,aAC3B,KAAK,EACL,QAAQ,IACL,CACP,EACA,SAAS,IAAI,CACZ,gCAAK,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,0BAAM,CAAC,MAAM,KAAM,aAAa,YAC/D,MAAM,IAAI,UAAU,GACjB,CACP,EACA,OAAO,IACJ,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,102 @@
1
+ @use '../colors';
2
+ @use '../breakpoints.scss';
3
+
4
+ .root {
5
+ --max-width: 464px;
6
+ --snackbar-bottom-gap: 12px;
7
+ background: colors.$basic-gray76;
8
+ border-radius: 10px;
9
+ padding: 12px;
10
+ display: flex;
11
+ width: fit-content;
12
+ max-width: var(--max-width);
13
+ position: fixed;
14
+ bottom: var(--snackbar-bottom-gap);
15
+ // частично иммитируем поведение layout
16
+ margin: 0 auto;
17
+ @include breakpoints.up('xs') {
18
+ --snackbar-bottom-gap: 40px;
19
+ }
20
+ @include breakpoints.down('ms') {
21
+ left: var(--snackbar-position-left, 8px);
22
+ margin-right: 8px;
23
+ }
24
+ @include breakpoints.up('ms') {
25
+ @include breakpoints.down('xs') {
26
+ left: var(--snackbar-position-left, 50%);
27
+ margin-left: calc(-1 * (var(--max-width) / 2));
28
+ }
29
+ }
30
+ @include breakpoints.up('xs') {
31
+ @include breakpoints.down('l') {
32
+ left: var(--snackbar-position-left, 56px);
33
+ }
34
+ }
35
+ @include breakpoints.up('l') {
36
+ @include breakpoints.down('xl') {
37
+ // 1472 - максимальная ширина контейнера Layout на данном разрешении.
38
+ left: var(--snackbar-position-left, calc(((100% - 1472px) / 2) - 8px));
39
+ }
40
+ }
41
+ @include breakpoints.up('xl') {
42
+ // 1504 - максимальная ширина контейнера Layout на данном разрешении.
43
+ left: var(--snackbar-position-left, calc(((100% - 1504px) / 2) - 8px));
44
+ }
45
+ .icon:last-child,
46
+ .button:last-child {
47
+ padding-left: 12px;
48
+ padding-right: 12px;
49
+ margin-right: -12px;
50
+ }
51
+ .button {
52
+ padding-left: 12px;
53
+ }
54
+ }
55
+
56
+ .image + .content,
57
+ .icon + .content {
58
+ margin-left: 8px;
59
+ }
60
+
61
+ .content {
62
+ .title,
63
+ .subtitle {
64
+ display: -webkit-box;
65
+ line-clamp: 2;
66
+ -webkit-line-clamp: 2;
67
+ -webkit-box-orient: vertical;
68
+ overflow: hidden;
69
+ font-size: 14px;
70
+ line-height: 20px;
71
+ }
72
+ }
73
+
74
+ .button {
75
+ display: flex;
76
+ align-items: center;
77
+ margin-top: -12px;
78
+ margin-bottom: -12px;
79
+ }
80
+
81
+ .image {
82
+ display: flex;
83
+ align-items: center;
84
+ img {
85
+ height: 40px;
86
+ }
87
+ }
88
+
89
+ .icon {
90
+ display: flex;
91
+ align-items: center;
92
+ margin-top: -12px;
93
+ margin-bottom: -12px;
94
+ }
95
+
96
+ .title {
97
+ color: colors.$basic-white;
98
+ }
99
+
100
+ .subtitle {
101
+ color: colors.$basic-gray38;
102
+ }
@@ -0,0 +1,12 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { WithTestId } from '../types';
3
+ export interface SnackBarProps extends HTMLAttributes<HTMLDivElement>, WithTestId {
4
+ /** Будет вызван при мoнтировании. */
5
+ onMount?: VoidFunction;
6
+ }
7
+ export interface SnackBarImageProps extends HTMLAttributes<HTMLImageElement> {
8
+ src: string;
9
+ }
10
+ export interface SnackBarIconProps extends HTMLAttributes<HTMLDivElement> {
11
+ icon: ReactNode;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/snack-bar/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,302 @@
1
+ import { SnackBarProps } from './types';
2
+ import { CSSProperties, RefObject, TouchEvent } from 'react';
3
+ type CSSPosition = CSSProperties & {
4
+ '--snackbar-position-bottom'?: string;
5
+ '--snackbar-position-left'?: string;
6
+ '--snackbar-transition-duration'?: string;
7
+ };
8
+ /**
9
+ * Хук для управления позиционированием (анимированным появлением/исчезанием) SnackBar.
10
+ * @param config Конфиг.
11
+ * @param config.props Свойства SnackBar.
12
+ * Неиспользуемые свойства будут выведены в результат без изменений.
13
+ * @return Состояние перехода и Свойства SnackBar.
14
+ */
15
+ export declare function useSnackBarPositioning({ shown, onClose, relatedRef, timeout, duration, props, }: {
16
+ shown: boolean;
17
+ onClose: VoidFunction;
18
+ relatedRef?: RefObject<HTMLElement>;
19
+ timeout?: number;
20
+ duration?: number;
21
+ props?: SnackBarProps;
22
+ }): {
23
+ state: Readonly<{
24
+ status: import("react-transition-state").TransitionStatus;
25
+ isMounted: boolean;
26
+ isEnter: boolean;
27
+ isResolved: boolean;
28
+ }>;
29
+ snackBarProps: {
30
+ className: string;
31
+ style: CSSPosition;
32
+ onMount: (() => void) | undefined;
33
+ onTouchStart: (event: TouchEvent<HTMLElement>) => void;
34
+ onTouchEnd: (event: TouchEvent<HTMLElement>) => void;
35
+ defaultChecked?: boolean | undefined;
36
+ defaultValue?: string | number | ReadonlyArray<string> | undefined;
37
+ suppressContentEditableWarning?: boolean | undefined;
38
+ suppressHydrationWarning?: boolean | undefined;
39
+ accessKey?: string | undefined;
40
+ autoFocus?: boolean | undefined;
41
+ contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
42
+ contextMenu?: string | undefined;
43
+ dir?: string | undefined;
44
+ draggable?: (boolean | "true" | "false") | undefined;
45
+ hidden?: boolean | undefined;
46
+ id?: string | undefined;
47
+ lang?: string | undefined;
48
+ nonce?: string | undefined;
49
+ placeholder?: string | undefined;
50
+ slot?: string | undefined;
51
+ spellCheck?: (boolean | "true" | "false") | undefined;
52
+ tabIndex?: number | undefined;
53
+ title?: string | undefined;
54
+ translate?: "yes" | "no" | undefined;
55
+ radioGroup?: string | undefined;
56
+ role?: import("react").AriaRole | undefined;
57
+ about?: string | undefined;
58
+ content?: string | undefined;
59
+ datatype?: string | undefined;
60
+ inlist?: any;
61
+ prefix?: string | undefined;
62
+ property?: string | undefined;
63
+ rel?: string | undefined;
64
+ resource?: string | undefined;
65
+ rev?: string | undefined;
66
+ typeof?: string | undefined;
67
+ vocab?: string | undefined;
68
+ autoCapitalize?: string | undefined;
69
+ autoCorrect?: string | undefined;
70
+ autoSave?: string | undefined;
71
+ color?: string | undefined;
72
+ itemProp?: string | undefined;
73
+ itemScope?: boolean | undefined;
74
+ itemType?: string | undefined;
75
+ itemID?: string | undefined;
76
+ itemRef?: string | undefined;
77
+ results?: number | undefined;
78
+ security?: string | undefined;
79
+ unselectable?: "on" | "off" | undefined;
80
+ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
81
+ is?: string | undefined;
82
+ 'aria-activedescendant'?: string | undefined;
83
+ 'aria-atomic'?: (boolean | "true" | "false") | undefined;
84
+ 'aria-autocomplete'?: "none" | "inline" | "list" | "both" | undefined;
85
+ 'aria-braillelabel'?: string | undefined;
86
+ 'aria-brailleroledescription'?: string | undefined;
87
+ 'aria-busy'?: (boolean | "true" | "false") | undefined;
88
+ 'aria-checked'?: boolean | "false" | "mixed" | "true" | undefined;
89
+ 'aria-colcount'?: number | undefined;
90
+ 'aria-colindex'?: number | undefined;
91
+ 'aria-colindextext'?: string | undefined;
92
+ 'aria-colspan'?: number | undefined;
93
+ 'aria-controls'?: string | undefined;
94
+ 'aria-current'?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
95
+ 'aria-describedby'?: string | undefined;
96
+ 'aria-description'?: string | undefined;
97
+ 'aria-details'?: string | undefined;
98
+ 'aria-disabled'?: (boolean | "true" | "false") | undefined;
99
+ 'aria-dropeffect'?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
100
+ 'aria-errormessage'?: string | undefined;
101
+ 'aria-expanded'?: (boolean | "true" | "false") | undefined;
102
+ 'aria-flowto'?: string | undefined;
103
+ 'aria-grabbed'?: (boolean | "true" | "false") | undefined;
104
+ 'aria-haspopup'?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
105
+ 'aria-hidden'?: (boolean | "true" | "false") | undefined;
106
+ 'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
107
+ 'aria-keyshortcuts'?: string | undefined;
108
+ 'aria-label'?: string | undefined;
109
+ 'aria-labelledby'?: string | undefined;
110
+ 'aria-level'?: number | undefined;
111
+ 'aria-live'?: "off" | "assertive" | "polite" | undefined;
112
+ 'aria-modal'?: (boolean | "true" | "false") | undefined;
113
+ 'aria-multiline'?: (boolean | "true" | "false") | undefined;
114
+ 'aria-multiselectable'?: (boolean | "true" | "false") | undefined;
115
+ 'aria-orientation'?: "horizontal" | "vertical" | undefined;
116
+ 'aria-owns'?: string | undefined;
117
+ 'aria-placeholder'?: string | undefined;
118
+ 'aria-posinset'?: number | undefined;
119
+ 'aria-pressed'?: boolean | "false" | "mixed" | "true" | undefined;
120
+ 'aria-readonly'?: (boolean | "true" | "false") | undefined;
121
+ 'aria-relevant'?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
122
+ 'aria-required'?: (boolean | "true" | "false") | undefined;
123
+ 'aria-roledescription'?: string | undefined;
124
+ 'aria-rowcount'?: number | undefined;
125
+ 'aria-rowindex'?: number | undefined;
126
+ 'aria-rowindextext'?: string | undefined;
127
+ 'aria-rowspan'?: number | undefined;
128
+ 'aria-selected'?: (boolean | "true" | "false") | undefined;
129
+ 'aria-setsize'?: number | undefined;
130
+ 'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
131
+ 'aria-valuemax'?: number | undefined;
132
+ 'aria-valuemin'?: number | undefined;
133
+ 'aria-valuenow'?: number | undefined;
134
+ 'aria-valuetext'?: string | undefined;
135
+ children?: import("react").ReactNode | undefined;
136
+ dangerouslySetInnerHTML?: {
137
+ __html: string | TrustedHTML;
138
+ } | undefined;
139
+ onCopy?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
140
+ onCopyCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
141
+ onCut?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
142
+ onCutCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
143
+ onPaste?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
144
+ onPasteCapture?: import("react").ClipboardEventHandler<HTMLDivElement> | undefined;
145
+ onCompositionEnd?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
146
+ onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
147
+ onCompositionStart?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
148
+ onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
149
+ onCompositionUpdate?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
150
+ onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLDivElement> | undefined;
151
+ onFocus?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
152
+ onFocusCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
153
+ onBlur?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
154
+ onBlurCapture?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
155
+ onChange?: import("react").FormEventHandler<HTMLDivElement> | undefined;
156
+ onChangeCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
157
+ onBeforeInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
158
+ onBeforeInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
159
+ onInput?: import("react").FormEventHandler<HTMLDivElement> | undefined;
160
+ onInputCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
161
+ onReset?: import("react").FormEventHandler<HTMLDivElement> | undefined;
162
+ onResetCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
163
+ onSubmit?: import("react").FormEventHandler<HTMLDivElement> | undefined;
164
+ onSubmitCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
165
+ onInvalid?: import("react").FormEventHandler<HTMLDivElement> | undefined;
166
+ onInvalidCapture?: import("react").FormEventHandler<HTMLDivElement> | undefined;
167
+ onLoad?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
168
+ onLoadCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
169
+ onError?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
170
+ onErrorCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
171
+ onKeyDown?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
172
+ onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
173
+ onKeyPress?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
174
+ onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
175
+ onKeyUp?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
176
+ onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLDivElement> | undefined;
177
+ onAbort?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
178
+ onAbortCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
179
+ onCanPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
180
+ onCanPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
181
+ onCanPlayThrough?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
182
+ onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
183
+ onDurationChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
184
+ onDurationChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
185
+ onEmptied?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
186
+ onEmptiedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
187
+ onEncrypted?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
188
+ onEncryptedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
189
+ onEnded?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
190
+ onEndedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
191
+ onLoadedData?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
192
+ onLoadedDataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
193
+ onLoadedMetadata?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
194
+ onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
195
+ onLoadStart?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
196
+ onLoadStartCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
197
+ onPause?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
198
+ onPauseCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
199
+ onPlay?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
200
+ onPlayCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
201
+ onPlaying?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
202
+ onPlayingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
203
+ onProgress?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
204
+ onProgressCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
205
+ onRateChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
206
+ onRateChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
207
+ onResize?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
208
+ onResizeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
209
+ onSeeked?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
210
+ onSeekedCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
211
+ onSeeking?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
212
+ onSeekingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
213
+ onStalled?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
214
+ onStalledCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
215
+ onSuspend?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
216
+ onSuspendCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
217
+ onTimeUpdate?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
218
+ onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
219
+ onVolumeChange?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
220
+ onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
221
+ onWaiting?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
222
+ onWaitingCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
223
+ onAuxClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
224
+ onAuxClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
225
+ onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
226
+ onClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
227
+ onContextMenu?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
228
+ onContextMenuCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
229
+ onDoubleClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
230
+ onDoubleClickCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
231
+ onDrag?: import("react").DragEventHandler<HTMLDivElement> | undefined;
232
+ onDragCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
233
+ onDragEnd?: import("react").DragEventHandler<HTMLDivElement> | undefined;
234
+ onDragEndCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
235
+ onDragEnter?: import("react").DragEventHandler<HTMLDivElement> | undefined;
236
+ onDragEnterCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
237
+ onDragExit?: import("react").DragEventHandler<HTMLDivElement> | undefined;
238
+ onDragExitCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
239
+ onDragLeave?: import("react").DragEventHandler<HTMLDivElement> | undefined;
240
+ onDragLeaveCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
241
+ onDragOver?: import("react").DragEventHandler<HTMLDivElement> | undefined;
242
+ onDragOverCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
243
+ onDragStart?: import("react").DragEventHandler<HTMLDivElement> | undefined;
244
+ onDragStartCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
245
+ onDrop?: import("react").DragEventHandler<HTMLDivElement> | undefined;
246
+ onDropCapture?: import("react").DragEventHandler<HTMLDivElement> | undefined;
247
+ onMouseDown?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
248
+ onMouseDownCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
249
+ onMouseEnter?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
250
+ onMouseLeave?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
251
+ onMouseMove?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
252
+ onMouseMoveCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
253
+ onMouseOut?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
254
+ onMouseOutCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
255
+ onMouseOver?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
256
+ onMouseOverCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
257
+ onMouseUp?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
258
+ onMouseUpCapture?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
259
+ onSelect?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
260
+ onSelectCapture?: import("react").ReactEventHandler<HTMLDivElement> | undefined;
261
+ onTouchCancel?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
262
+ onTouchCancelCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
263
+ onTouchEndCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
264
+ onTouchMove?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
265
+ onTouchMoveCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
266
+ onTouchStartCapture?: import("react").TouchEventHandler<HTMLDivElement> | undefined;
267
+ onPointerDown?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
268
+ onPointerDownCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
269
+ onPointerMove?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
270
+ onPointerMoveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
271
+ onPointerUp?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
272
+ onPointerUpCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
273
+ onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
274
+ onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
275
+ onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
276
+ onPointerEnterCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
277
+ onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
278
+ onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
279
+ onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
280
+ onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
281
+ onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
282
+ onPointerOutCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
283
+ onGotPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
284
+ onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
285
+ onLostPointerCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
286
+ onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
287
+ onScroll?: import("react").UIEventHandler<HTMLDivElement> | undefined;
288
+ onScrollCapture?: import("react").UIEventHandler<HTMLDivElement> | undefined;
289
+ onWheel?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
290
+ onWheelCapture?: import("react").WheelEventHandler<HTMLDivElement> | undefined;
291
+ onAnimationStart?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
292
+ onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
293
+ onAnimationEnd?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
294
+ onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
295
+ onAnimationIteration?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
296
+ onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLDivElement> | undefined;
297
+ onTransitionEnd?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
298
+ onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
299
+ 'data-testid'?: string;
300
+ };
301
+ };
302
+ export {};
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useSnackBarPositioning = useSnackBarPositioning;
7
+ const classnames_1 = __importDefault(require("classnames"));
8
+ const hooks_1 = require("../hooks");
9
+ const react_transition_state_1 = require("react-transition-state");
10
+ const react_1 = require("react");
11
+ const utils_m_scss_1 = __importDefault(require("./utils.m.scss"));
12
+ const bounds_of_1 = require("../helpers/bounds-of");
13
+ const context_1 = require("./context");
14
+ const SWIPE_THRESHOLD = 50;
15
+ /**
16
+ * Хук для управления позиционированием (анимированным появлением/исчезанием) SnackBar.
17
+ * @param config Конфиг.
18
+ * @param config.props Свойства SnackBar.
19
+ * Неиспользуемые свойства будут выведены в результат без изменений.
20
+ * @return Состояние перехода и Свойства SnackBar.
21
+ */
22
+ function useSnackBarPositioning({ shown, onClose, relatedRef, timeout = 300, duration = 4000, props, }) {
23
+ const timeoutId = (0, react_1.useRef)();
24
+ const hideStyle = (0, react_1.useRef)({});
25
+ const touchStart = (0, react_1.useRef)({ x: 0, y: 0 });
26
+ const closeRef = (0, react_1.useRef)();
27
+ const { closePrevious, setClose } = (0, react_1.useContext)(context_1.SnackbarContext);
28
+ const [state, toggle] = (0, react_transition_state_1.useTransition)({
29
+ initialEntered: shown,
30
+ preEnter: true,
31
+ mountOnEnter: true,
32
+ unmountOnExit: true,
33
+ timeout,
34
+ });
35
+ let style = { ...props?.style, ['--snackbar-transition-duration']: `${timeout}ms` };
36
+ const onPreEnter = (0, react_1.useCallback)(() => {
37
+ if (!closePrevious || closePrevious !== closeRef.current) {
38
+ closePrevious?.();
39
+ closeRef.current = () => {
40
+ hideStyle.current = {
41
+ ...getEnteredStyle(relatedRef?.current),
42
+ opacity: 0,
43
+ };
44
+ onClose();
45
+ };
46
+ }
47
+ setClose?.({ closePrevious: closeRef.current });
48
+ }, [closePrevious, setClose, closeRef]);
49
+ if (state.status === 'entering' || state.status === 'entered') {
50
+ style = { ...style, ...getEnteredStyle(relatedRef?.current) };
51
+ }
52
+ if (state.status === 'entered') {
53
+ clearTimeout(timeoutId.current);
54
+ timeoutId.current = setTimeout(onClose, duration);
55
+ }
56
+ else if (state.status === 'exiting') {
57
+ clearTimeout(timeoutId.current);
58
+ style = { ...style, ...hideStyle.current };
59
+ }
60
+ else if (state.status === 'unmounted') {
61
+ hideStyle.current = {};
62
+ }
63
+ (0, hooks_1.useIsomorphicLayoutEffect)(() => {
64
+ toggle(shown);
65
+ }, [shown]);
66
+ return {
67
+ state,
68
+ snackBarProps: {
69
+ ...props,
70
+ className: (0, classnames_1.default)(props?.className, utils_m_scss_1.default.animated),
71
+ style,
72
+ onMount: state.status === 'preEnter' ? onPreEnter : undefined,
73
+ // ТО DO вынести логику определения свайпа в отдельный хук.
74
+ onTouchStart: (0, react_1.useCallback)((event) => {
75
+ event.stopPropagation();
76
+ touchStart.current = {
77
+ x: event.changedTouches[0].clientX,
78
+ y: event.changedTouches[0].clientY,
79
+ };
80
+ }, [touchStart]),
81
+ onTouchEnd: (0, react_1.useCallback)((event) => {
82
+ event.stopPropagation();
83
+ const direction = getSwipeDirection(touchStart.current, {
84
+ x: event.changedTouches[0].clientX,
85
+ y: event.changedTouches[0].clientY,
86
+ });
87
+ const distance = Math.sqrt(Math.pow(event.changedTouches[0].clientX - touchStart.current.x, 2) +
88
+ Math.pow(event.changedTouches[0].clientY - touchStart.current.y, 2));
89
+ if (distance >= SWIPE_THRESHOLD) {
90
+ hideStyle.current = getSwipeCloseStyle(event.currentTarget, direction);
91
+ onClose();
92
+ }
93
+ }, [touchStart, hideStyle]),
94
+ },
95
+ };
96
+ }
97
+ /**
98
+ * Определяет направление свайпа.
99
+ * @param start Начальная точка касания.
100
+ * @param end Конечная точка касания.
101
+ * @return Направление свайпа.
102
+ */
103
+ function getSwipeDirection(start, end) {
104
+ const xDistance = start.x - end.x;
105
+ const yDistance = start.y - end.y;
106
+ if (Math.abs(xDistance) > Math.abs(yDistance)) {
107
+ return xDistance > 0 ? 'left' : 'right';
108
+ }
109
+ return yDistance > 0 ? 'up' : 'down';
110
+ }
111
+ /**
112
+ * Формирует стили для запуска анимации скрытия элемент на свайп по нему.
113
+ * @param target Элемент для которого произошло событие свайпа.
114
+ * @param direction Направление свайпа.
115
+ * @return Набор CSS-переменных для анимированного изменения положения элемента.
116
+ */
117
+ function getSwipeCloseStyle(target, direction) {
118
+ const { height, width, left } = (0, bounds_of_1.boundsOf)(target);
119
+ const position = {
120
+ '--snackbar-position-bottom': target.style.getPropertyValue('--snackbar-position-bottom'),
121
+ };
122
+ if (direction === 'left') {
123
+ position['--snackbar-position-left'] = '-100%';
124
+ position.width = `${width}px`;
125
+ }
126
+ else if (direction === 'right') {
127
+ position['--snackbar-position-left'] = `calc(100vw - ${left}px + 100%)`;
128
+ position.width = `${width}px`;
129
+ }
130
+ else if (direction === 'up') {
131
+ position['--snackbar-position-bottom'] =
132
+ `calc(100vh - ${position['--snackbar-position-bottom']} + ${height}px)`;
133
+ }
134
+ else {
135
+ position['--snackbar-position-bottom'] = undefined;
136
+ }
137
+ return position;
138
+ }
139
+ /**
140
+ * Формирует стили для анимированного появления элемента.
141
+ * @param relative Элемент относительно которого ведётся расчёт.
142
+ * @return Набор CSS-переменных для анимированного изменения положения элемента.
143
+ */
144
+ function getEnteredStyle(relative) {
145
+ const relativeBottom = relative ? getRelativeBottom(relative) : 0;
146
+ return {
147
+ ['--snackbar-position-bottom']: `calc(${relativeBottom}px + var(--snackbar-bottom-gap, 12px))`,
148
+ };
149
+ }
150
+ /**
151
+ * Вычисляет расстояние от нижней границы экрана для элемента SnackBar, относительно переданного элемента в соответствии с дизайн-гайдами.
152
+ * @param relative Элемент на основе положения которого ведётся расчёт.
153
+ * @return Расстояние от нижней границы экрана в пикселях.
154
+ */
155
+ function getRelativeBottom(relative) {
156
+ const bottom = Number(getComputedStyle(relative)?.bottom.replace('px', ''));
157
+ const { height, bottom: rectBottom } = (0, bounds_of_1.boundsOf)(relative);
158
+ // Определяем зафиксирован ли внизу экрана элемент относительно которого ведётся расчёт.
159
+ if (rectBottom === window.innerHeight - bottom) {
160
+ return bottom + height;
161
+ }
162
+ return 0;
163
+ }
164
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/snack-bar/utils.tsx"],"names":[],"mappings":";;;;;AA4BA,wDA0GC;AAtID,4DAAoC;AACpC,oCAAqD;AAErD,mEAAuD;AACvD,iCAA8F;AAC9F,kEAAoC;AACpC,oDAAgD;AAChD,uCAA4C;AAY5C,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,OAAO,EACP,UAAU,EACV,OAAO,GAAG,GAAG,EACb,QAAQ,GAAG,IAAI,EACf,KAAK,GAQN;IACC,MAAM,SAAS,GAAG,IAAA,cAAM,GAAiC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAA,cAAM,EAAc,EAAE,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,IAAA,cAAM,EAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAA,cAAM,GAAgB,CAAC;IAExC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,IAAA,kBAAU,EAAC,yBAAe,CAAC,CAAC;IAEhE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAA,sCAAa,EAAC;QACpC,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,IAAI;QACnB,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,KAAK,GAAgB,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,gCAAgC,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAEjG,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAClC,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,Q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;QACjC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,gBAAgB,IAAI,YAAY,CAAC;QACxE,QAAQ,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC;IAChC,CAAC;SAAM,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QAC9B,QAAQ,CAAC,4BAA4B,CAAC;YACpC,gBAAgB,QAAQ,CAAC,4BAA4B,CAAC,MAAM,MAAM,KAAK,CAAC;IAC5E,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,4BAA4B,CAAC,GAAG,SAAS,CAAC;IACrD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,QAA6B;IACpD,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,OAAO;QACL,CAAC,4BAA4B,CAAC,EAAE,QAAQ,cAAc,wCAAwC;KAC/F,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,QAAqB;IAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,oBAAQ,EAAC,QAAQ,CAAC,CAAC;IAC1D,wFAAwF;IACxF,IAAI,UAAU,KAAK,MAAM,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC;QAC/C,OAAO,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,7 @@
1
+ .animated {
2
+ transition:
3
+ bottom var(--snackbar-transition-duration, 300ms) ease-out,
4
+ left var(--snackbar-transition-duration, 300ms) ease-out,
5
+ opacity var(--snackbar-transition-duration, 300ms) ease-out;
6
+ bottom: var(--snackbar-position-bottom, -110px);
7
+ }