@alfalab/core-components-popup-sheet 1.0.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/Component-9211a437.d.ts +38 -0
- package/Component.d.ts +47 -0
- package/Component.desktop-2e2b2125.d.ts +6 -0
- package/Component.js +139 -0
- package/components/backdrop/Component.d.ts +14 -0
- package/components/backdrop/Component.js +22 -0
- package/components/backdrop/index.css +36 -0
- package/components/backdrop/index.d.ts +1 -0
- package/components/backdrop/index.js +12 -0
- package/cssm/Component-9211a437.d.ts +38 -0
- package/cssm/Component.d.ts +47 -0
- package/cssm/Component.desktop-2e2b2125.d.ts +6 -0
- package/cssm/Component.js +139 -0
- package/cssm/components/backdrop/Component.d.ts +14 -0
- package/cssm/components/backdrop/Component.js +21 -0
- package/cssm/components/backdrop/index.d.ts +1 -0
- package/cssm/components/backdrop/index.js +13 -0
- package/cssm/components/backdrop/index.module.css +35 -0
- package/cssm/desktop-2e2b2125.d.ts +2 -0
- package/cssm/index-ebda875c.d.ts +1 -0
- package/cssm/index.d.ts +1 -0
- package/cssm/index.js +20 -0
- package/cssm/index.module.css +52 -0
- package/cssm/typings-9211a437.d.ts +95 -0
- package/desktop-2e2b2125.d.ts +2 -0
- package/esm/Component-9211a437.d.ts +38 -0
- package/esm/Component.d.ts +47 -0
- package/esm/Component.desktop-2e2b2125.d.ts +6 -0
- package/esm/Component.js +130 -0
- package/esm/components/backdrop/Component.d.ts +14 -0
- package/esm/components/backdrop/Component.js +14 -0
- package/esm/components/backdrop/index.css +36 -0
- package/esm/components/backdrop/index.d.ts +1 -0
- package/esm/components/backdrop/index.js +4 -0
- package/esm/desktop-2e2b2125.d.ts +2 -0
- package/esm/index-ebda875c.d.ts +1 -0
- package/esm/index.css +53 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +10 -0
- package/esm/typings-9211a437.d.ts +95 -0
- package/index-ebda875c.d.ts +1 -0
- package/index.css +53 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/modern/Component-9211a437.d.ts +38 -0
- package/modern/Component.d.ts +47 -0
- package/modern/Component.desktop-2e2b2125.d.ts +6 -0
- package/modern/Component.js +136 -0
- package/modern/components/backdrop/Component.d.ts +14 -0
- package/modern/components/backdrop/Component.js +15 -0
- package/modern/components/backdrop/index.css +36 -0
- package/modern/components/backdrop/index.d.ts +1 -0
- package/modern/components/backdrop/index.js +3 -0
- package/modern/desktop-2e2b2125.d.ts +2 -0
- package/modern/index-ebda875c.d.ts +1 -0
- package/modern/index.css +53 -0
- package/modern/index.d.ts +1 -0
- package/modern/index.js +9 -0
- package/modern/typings-9211a437.d.ts +95 -0
- package/package.json +26 -0
- package/src/Component.tsx +229 -0
- package/src/components/backdrop/Component.tsx +35 -0
- package/src/components/backdrop/index.module.css +25 -0
- package/src/components/backdrop/index.tsx +1 -0
- package/src/index.module.css +56 -0
- package/src/index.ts +1 -0
- package/typings-9211a437.d.ts +95 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component-9211a437";
|
package/cssm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupSheet, PopupSheetProps } from "./Component";
|
package/cssm/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Component = require('./Component.js');
|
|
6
|
+
require('tslib');
|
|
7
|
+
require('react');
|
|
8
|
+
require('react-swipeable');
|
|
9
|
+
require('classnames');
|
|
10
|
+
require('@alfalab/core-components-base-modal/cssm');
|
|
11
|
+
require('@alfalab/core-components-navigation-bar/cssm/shared');
|
|
12
|
+
require('@alfalab/core-components-shared/cssm');
|
|
13
|
+
require('./components/backdrop/Component.js');
|
|
14
|
+
require('@alfalab/core-components-backdrop/cssm');
|
|
15
|
+
require('./components/backdrop/index.module.css');
|
|
16
|
+
require('./index.module.css');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.PopupSheet = Component.PopupSheet;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
} /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
4
|
+
} :root {
|
|
5
|
+
} :root {
|
|
6
|
+
|
|
7
|
+
/* Hard */
|
|
8
|
+
|
|
9
|
+
/* Up */
|
|
10
|
+
|
|
11
|
+
/* Hard up */
|
|
12
|
+
} :root {
|
|
13
|
+
} :root {
|
|
14
|
+
--gap-xs: 8px;
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
} .component {
|
|
18
|
+
position: fixed;
|
|
19
|
+
bottom: 0;
|
|
20
|
+
margin: auto var(--gap-xs) var(--gap-xs);
|
|
21
|
+
width: calc(100% - 2 * var(--gap-xs));
|
|
22
|
+
max-width: 600px;
|
|
23
|
+
border-radius: 36px;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
} .closer {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 8px;
|
|
28
|
+
right: 8px
|
|
29
|
+
} .closer > button {
|
|
30
|
+
-webkit-backdrop-filter: none;
|
|
31
|
+
backdrop-filter: none;
|
|
32
|
+
} .content {
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
} /* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */ .appear,
|
|
35
|
+
.enter {
|
|
36
|
+
transform: translateY(calc(100% + 100px));
|
|
37
|
+
} .appearActive,
|
|
38
|
+
.enterActive {
|
|
39
|
+
transform: translateY(0);
|
|
40
|
+
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
41
|
+
transition-delay: 50ms;
|
|
42
|
+
} .exit {
|
|
43
|
+
transform: translateY(0);
|
|
44
|
+
} .exitBySwipe {
|
|
45
|
+
transform: translateY(calc(100% + 100px));
|
|
46
|
+
} .exitActiveBySwipe {
|
|
47
|
+
transition: none;
|
|
48
|
+
} .exitActive,
|
|
49
|
+
.exitDone {
|
|
50
|
+
transform: translateY(calc(100% + 100px));
|
|
51
|
+
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
52
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
type StyleColors = {
|
|
3
|
+
default: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
inverted: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type ComponentProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Тип кнопки
|
|
13
|
+
* @default secondary
|
|
14
|
+
*/
|
|
15
|
+
view?: 'accent' | 'primary' | 'secondary' | 'tertiary' | 'outlined' | 'filled' | 'transparent' | 'link' | 'ghost';
|
|
16
|
+
/**
|
|
17
|
+
* Слот слева
|
|
18
|
+
*/
|
|
19
|
+
leftAddons?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Слот справа
|
|
22
|
+
*/
|
|
23
|
+
rightAddons?: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Размер компонента
|
|
26
|
+
* @default m
|
|
27
|
+
*/
|
|
28
|
+
size?: 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
29
|
+
/**
|
|
30
|
+
* Растягивает компонент на ширину контейнера
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
block?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Дополнительный класс
|
|
36
|
+
*/
|
|
37
|
+
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Дополнительный класс для спиннера
|
|
40
|
+
*/
|
|
41
|
+
spinnerClassName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Выводит ссылку в виде кнопки
|
|
44
|
+
*/
|
|
45
|
+
href?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Позволяет использовать кастомный компонент для кнопки (например Link из роутера)
|
|
48
|
+
*/
|
|
49
|
+
Component?: ElementType;
|
|
50
|
+
/**
|
|
51
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
52
|
+
*/
|
|
53
|
+
dataTestId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Показать лоадер
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Не переносить текст кнопки на новую строку
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
nowrap?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Набор цветов для компонента
|
|
66
|
+
*/
|
|
67
|
+
colors?: 'default' | 'inverted';
|
|
68
|
+
/**
|
|
69
|
+
* Дочерние элементы.
|
|
70
|
+
*/
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* Основные стили компонента.
|
|
74
|
+
*/
|
|
75
|
+
styles: {
|
|
76
|
+
[key: string]: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Стили компонента для default и inverted режима.
|
|
80
|
+
*/
|
|
81
|
+
colorStylesMap: StyleColors;
|
|
82
|
+
};
|
|
83
|
+
type AnchorBaseButtonProps = ComponentProps & AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
84
|
+
type NativeBaseButtonProps = ComponentProps & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
85
|
+
type BaseButtonProps = Partial<AnchorBaseButtonProps | NativeBaseButtonProps>;
|
|
86
|
+
type AnchorButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
87
|
+
type NativeButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
88
|
+
type ButtonProps = Partial<AnchorButtonProps | NativeButtonProps> & {
|
|
89
|
+
/**
|
|
90
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
91
|
+
* @default 1024
|
|
92
|
+
*/
|
|
93
|
+
breakpoint?: number;
|
|
94
|
+
};
|
|
95
|
+
export { StyleColors, ComponentProps, AnchorBaseButtonProps, NativeBaseButtonProps, BaseButtonProps, AnchorButtonProps, NativeButtonProps, ButtonProps };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FC } from "react";
|
|
4
|
+
import { BaseButtonProps } from "./typings-9211a437";
|
|
5
|
+
type SpinnerProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Управление видимостью компонента
|
|
8
|
+
*/
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Размер компонента
|
|
12
|
+
*/
|
|
13
|
+
size?: "xs" | "s" | "m";
|
|
14
|
+
/**
|
|
15
|
+
* Дополнительный класс
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Идентификатор компонента в DOM
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
24
|
+
*/
|
|
25
|
+
dataTestId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Палитра, в контексте которой используется спиннер
|
|
28
|
+
*/
|
|
29
|
+
colors?: "default" | "inverted";
|
|
30
|
+
};
|
|
31
|
+
declare const Spinner: FC<SpinnerProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Минимальное время отображения лоадера - 500мс,
|
|
34
|
+
* чтобы при быстрых ответах от сервера кнопка не «моргала».
|
|
35
|
+
*/
|
|
36
|
+
declare const LOADER_MIN_DISPLAY_INTERVAL = 500;
|
|
37
|
+
declare const BaseButton: React.ForwardRefExoticComponent<BaseButtonProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
38
|
+
export { SpinnerProps, Spinner, LOADER_MIN_DISPLAY_INTERVAL, BaseButton };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { KeyboardEvent, MouseEvent } from "react";
|
|
4
|
+
import { BaseModalProps } from "@alfalab/core-components-base-modal";
|
|
5
|
+
type PaddingType = number | string | {
|
|
6
|
+
top?: number;
|
|
7
|
+
right?: number;
|
|
8
|
+
bottom?: number;
|
|
9
|
+
left?: number;
|
|
10
|
+
};
|
|
11
|
+
type PopupSheetProps = Omit<BaseModalProps, 'onClose'> & {
|
|
12
|
+
/**
|
|
13
|
+
* Наличие кнопки закрытия
|
|
14
|
+
*/
|
|
15
|
+
hasCloser?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Будет ли свайпаться шторка
|
|
18
|
+
*/
|
|
19
|
+
swipeable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Отступы
|
|
22
|
+
*/
|
|
23
|
+
padding?: PaddingType;
|
|
24
|
+
/**
|
|
25
|
+
* Обработчик закрытия
|
|
26
|
+
*/
|
|
27
|
+
onClose?: (event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>, reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe') => void;
|
|
28
|
+
};
|
|
29
|
+
declare const PopupSheet: React.ForwardRefExoticComponent<Omit<BaseModalProps, "onClose"> & {
|
|
30
|
+
/**
|
|
31
|
+
* Наличие кнопки закрытия
|
|
32
|
+
*/
|
|
33
|
+
hasCloser?: boolean | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Будет ли свайпаться шторка
|
|
36
|
+
*/
|
|
37
|
+
swipeable?: boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Отступы
|
|
40
|
+
*/
|
|
41
|
+
padding?: PaddingType | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Обработчик закрытия
|
|
44
|
+
*/
|
|
45
|
+
onClose?: ((event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>, reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe') => void) | undefined;
|
|
46
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
47
|
+
export { PopupSheetProps, PopupSheet };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AnchorButtonProps, NativeButtonProps } from "./typings-9211a437";
|
|
4
|
+
type ButtonDesktopProps = Partial<AnchorButtonProps | NativeButtonProps>;
|
|
5
|
+
declare const ButtonDesktop: React.ForwardRefExoticComponent<ButtonDesktopProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
6
|
+
export { ButtonDesktopProps, ButtonDesktop };
|
package/esm/Component.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { forwardRef, useState, useRef } from 'react';
|
|
3
|
+
import { useSwipeable } from 'react-swipeable';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { BaseModal } from '@alfalab/core-components-base-modal/esm';
|
|
6
|
+
import { Closer } from '@alfalab/core-components-navigation-bar/esm/shared';
|
|
7
|
+
import { createPaddingStyle, getDataTestId, easingFns } from '@alfalab/core-components-shared/esm';
|
|
8
|
+
import { PopupBackdrop } from './components/backdrop/Component.js';
|
|
9
|
+
import '@alfalab/core-components-backdrop/esm';
|
|
10
|
+
|
|
11
|
+
var styles = {"component":"popup-sheet__component_18ukp","closer":"popup-sheet__closer_18ukp","content":"popup-sheet__content_18ukp","appear":"popup-sheet__appear_18ukp","enter":"popup-sheet__enter_18ukp","appearActive":"popup-sheet__appearActive_18ukp","enterActive":"popup-sheet__enterActive_18ukp","exit":"popup-sheet__exit_18ukp","exitBySwipe":"popup-sheet__exitBySwipe_18ukp","exitActiveBySwipe":"popup-sheet__exitActiveBySwipe_18ukp","exitActive":"popup-sheet__exitActive_18ukp","exitDone":"popup-sheet__exitDone_18ukp"};
|
|
12
|
+
require('./index.css')
|
|
13
|
+
|
|
14
|
+
var SWIPE_VELOCITY = 0.3;
|
|
15
|
+
var CLOSE_OFFSET = 0.3;
|
|
16
|
+
var ANIMATION_DURATION = 350;
|
|
17
|
+
var DEFAULT_PADDING = 32;
|
|
18
|
+
var PopupSheet = forwardRef(function (_a, ref) {
|
|
19
|
+
var children = _a.children, hasCloser = _a.hasCloser, className = _a.className, onClose = _a.onClose, transitionProps = _a.transitionProps, contentProps = _a.contentProps, swipeable = _a.swipeable, dataTestId = _a.dataTestId, backdropProps = _a.backdropProps, _b = _a.padding, padding = _b === void 0 ? DEFAULT_PADDING : _b, restProps = __rest(_a, ["children", "hasCloser", "className", "onClose", "transitionProps", "contentProps", "swipeable", "dataTestId", "backdropProps", "padding"]);
|
|
20
|
+
var _c = useState(0), sheetOffset = _c[0], setSheetOffset = _c[1];
|
|
21
|
+
var _d = useState(1), backdropOpacity = _d[0], setBackdropOpacity = _d[1];
|
|
22
|
+
var sheetHeight = useRef(0);
|
|
23
|
+
var sheetRef = useRef(null);
|
|
24
|
+
var bySwipeCloseAnimation = useRef(false);
|
|
25
|
+
var getSheetOffset = function (deltaY) { return Math.max(0, deltaY); };
|
|
26
|
+
var getBackdropOpacity = function (offset) {
|
|
27
|
+
return Math.max(0, 1 - offset / sheetHeight.current);
|
|
28
|
+
};
|
|
29
|
+
var getSwipeStyles = function () {
|
|
30
|
+
return sheetOffset ? { transform: "translateY(".concat(sheetOffset, "px)") } : {};
|
|
31
|
+
};
|
|
32
|
+
var handleSwiping = function (_a) {
|
|
33
|
+
var deltaY = _a.deltaY;
|
|
34
|
+
var offset = getSheetOffset(deltaY);
|
|
35
|
+
setSheetOffset(offset);
|
|
36
|
+
setBackdropOpacity(getBackdropOpacity(offset));
|
|
37
|
+
};
|
|
38
|
+
var handleSwiped = function (_a) {
|
|
39
|
+
var deltaY = _a.deltaY, velocity = _a.velocity, event = _a.event;
|
|
40
|
+
var shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;
|
|
41
|
+
var shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;
|
|
42
|
+
var offset = sheetOffset;
|
|
43
|
+
var animDuration = ANIMATION_DURATION / 2;
|
|
44
|
+
var start;
|
|
45
|
+
if (shouldCloseByVelocity || shouldCloseByOffset) {
|
|
46
|
+
bySwipeCloseAnimation.current = true;
|
|
47
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event, 'swipe');
|
|
48
|
+
var runLoop_1 = function (timeStamp) {
|
|
49
|
+
if (!start)
|
|
50
|
+
start = timeStamp;
|
|
51
|
+
var elapsedTime = timeStamp - start;
|
|
52
|
+
if (elapsedTime <= animDuration) {
|
|
53
|
+
var nextOffset = offset +
|
|
54
|
+
(sheetHeight.current - offset) *
|
|
55
|
+
easingFns.easeInOutQuad(elapsedTime / animDuration);
|
|
56
|
+
if (nextOffset > 0) {
|
|
57
|
+
setSheetOffset(nextOffset);
|
|
58
|
+
}
|
|
59
|
+
requestAnimationFrame(runLoop_1);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
setSheetOffset(0);
|
|
63
|
+
bySwipeCloseAnimation.current = false;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
requestAnimationFrame(runLoop_1);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
var runLoop_2 = function (timeStamp) {
|
|
70
|
+
if (!start)
|
|
71
|
+
start = timeStamp;
|
|
72
|
+
var elapsedTime = timeStamp - start;
|
|
73
|
+
if (elapsedTime <= animDuration) {
|
|
74
|
+
var nextOffset = offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);
|
|
75
|
+
if (nextOffset > 0) {
|
|
76
|
+
setSheetOffset(nextOffset);
|
|
77
|
+
setBackdropOpacity(getBackdropOpacity(nextOffset));
|
|
78
|
+
}
|
|
79
|
+
requestAnimationFrame(runLoop_2);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
setSheetOffset(0);
|
|
83
|
+
setBackdropOpacity(1);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
requestAnimationFrame(runLoop_2);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var handleEntered = function (node, isAppearing) {
|
|
90
|
+
bySwipeCloseAnimation.current = false;
|
|
91
|
+
if (sheetRef.current) {
|
|
92
|
+
sheetHeight.current = sheetRef.current.offsetHeight;
|
|
93
|
+
}
|
|
94
|
+
if (transitionProps === null || transitionProps === void 0 ? void 0 : transitionProps.onEntered) {
|
|
95
|
+
transitionProps.onEntered(node, isAppearing);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var handleExited = function (node) {
|
|
99
|
+
bySwipeCloseAnimation.current = false;
|
|
100
|
+
setSheetOffset(0);
|
|
101
|
+
setBackdropOpacity(1);
|
|
102
|
+
if (transitionProps === null || transitionProps === void 0 ? void 0 : transitionProps.onExited) {
|
|
103
|
+
transitionProps.onExited(node);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var sheetSwipeableHandlers = useSwipeable({
|
|
107
|
+
onSwiping: handleSwiping,
|
|
108
|
+
onSwiped: handleSwiped,
|
|
109
|
+
trackMouse: swipeable,
|
|
110
|
+
trackTouch: swipeable,
|
|
111
|
+
delta: 5,
|
|
112
|
+
});
|
|
113
|
+
return (React.createElement(BaseModal, __assign({}, restProps, { onClose: onClose, ref: ref, className: cn(styles.component, className), dataTestId: dataTestId, Backdrop: PopupBackdrop, backdropProps: __assign(__assign({}, backdropProps), { opacity: backdropOpacity }), transitionProps: __assign(__assign({ classNames: {
|
|
114
|
+
enter: styles.enter,
|
|
115
|
+
appear: styles.appear,
|
|
116
|
+
enterActive: styles.enterActive,
|
|
117
|
+
appearActive: styles.appearActive,
|
|
118
|
+
exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,
|
|
119
|
+
exitActive: bySwipeCloseAnimation.current
|
|
120
|
+
? styles.exitActiveBySwipe
|
|
121
|
+
: styles.exitActive,
|
|
122
|
+
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: {
|
|
123
|
+
ref: sheetRef,
|
|
124
|
+
style: getSwipeStyles(),
|
|
125
|
+
}, contentProps: __assign(__assign(__assign({ style: createPaddingStyle(padding) }, contentProps), sheetSwipeableHandlers), { className: cn(styles.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
126
|
+
hasCloser && (React.createElement(Closer, { view: 'mobile', className: styles.closer, onClick: onClose, dataTestId: getDataTestId(dataTestId, 'closer') })),
|
|
127
|
+
children));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export { PopupSheet };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BackdropProps } from "@alfalab/core-components-backdrop";
|
|
3
|
+
type PopupBackdropProps = BackdropProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Прозрачность бэкдропа
|
|
6
|
+
*/
|
|
7
|
+
opacity?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Время анимации opacity
|
|
10
|
+
*/
|
|
11
|
+
opacityTimeout?: number;
|
|
12
|
+
};
|
|
13
|
+
declare const PopupBackdrop: FC<BackdropProps>;
|
|
14
|
+
export { PopupBackdropProps, PopupBackdrop };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Backdrop } from '@alfalab/core-components-backdrop/esm';
|
|
4
|
+
|
|
5
|
+
var styles = {"appear":"popup-sheet__appear_1kdlf","enter":"popup-sheet__enter_1kdlf","appearActive":"popup-sheet__appearActive_1kdlf","enterActive":"popup-sheet__enterActive_1kdlf","appearDone":"popup-sheet__appearDone_1kdlf","enterDone":"popup-sheet__enterDone_1kdlf","exit":"popup-sheet__exit_1kdlf","exitActive":"popup-sheet__exitActive_1kdlf","exitDone":"popup-sheet__exitDone_1kdlf"};
|
|
6
|
+
require('./index.css')
|
|
7
|
+
|
|
8
|
+
var PopupBackdrop = function (_a) {
|
|
9
|
+
var opacity = _a.opacity, opacityTimeout = _a.opacityTimeout, style = _a.style, backdropProps = __rest(_a, ["opacity", "opacityTimeout", "style"]);
|
|
10
|
+
return (React.createElement("div", { style: __assign({ opacity: opacity, transition: opacity === 1 ? "opacity ".concat(opacityTimeout, "ms ease-in-out") : '', position: 'relative' }, style) },
|
|
11
|
+
React.createElement(Backdrop, __assign({ transitionClassNames: styles }, backdropProps))));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { PopupBackdrop };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* hash: 19vqu */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-bg-overlay: rgba(0, 0, 0, 0.6); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
5
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
|
+
} :root {
|
|
7
|
+
} :root {
|
|
8
|
+
|
|
9
|
+
/* Hard */
|
|
10
|
+
|
|
11
|
+
/* Up */
|
|
12
|
+
|
|
13
|
+
/* Hard up */
|
|
14
|
+
} :root {
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
} :root {
|
|
18
|
+
} :root {
|
|
19
|
+
--backdrop-visible-background: var(--color-light-bg-overlay);
|
|
20
|
+
--backdrop-hidden-background: transparent;
|
|
21
|
+
} .popup-sheet__appear_1kdlf,
|
|
22
|
+
.popup-sheet__enter_1kdlf {
|
|
23
|
+
background-color: var(--backdrop-hidden-background);
|
|
24
|
+
} .popup-sheet__appearActive_1kdlf,
|
|
25
|
+
.popup-sheet__enterActive_1kdlf,
|
|
26
|
+
.popup-sheet__appearDone_1kdlf,
|
|
27
|
+
.popup-sheet__enterDone_1kdlf {
|
|
28
|
+
background-color: var(--backdrop-visible-background);
|
|
29
|
+
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
30
|
+
} .popup-sheet__exit_1kdlf {
|
|
31
|
+
background-color: var(--backdrop-visible-background);
|
|
32
|
+
} .popup-sheet__exitActive_1kdlf,
|
|
33
|
+
.popup-sheet__exitDone_1kdlf {
|
|
34
|
+
background-color: var(--backdrop-hidden-background);
|
|
35
|
+
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupBackdrop } from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component-9211a437";
|
package/esm/index.css
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* hash: 1qn71 */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
4
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
5
|
+
} :root {
|
|
6
|
+
} :root {
|
|
7
|
+
|
|
8
|
+
/* Hard */
|
|
9
|
+
|
|
10
|
+
/* Up */
|
|
11
|
+
|
|
12
|
+
/* Hard up */
|
|
13
|
+
} :root {
|
|
14
|
+
} :root {
|
|
15
|
+
--gap-xs: 8px;
|
|
16
|
+
} :root {
|
|
17
|
+
} :root {
|
|
18
|
+
} .popup-sheet__component_18ukp {
|
|
19
|
+
position: fixed;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
margin: auto var(--gap-xs) var(--gap-xs);
|
|
22
|
+
width: calc(100% - 2 * var(--gap-xs));
|
|
23
|
+
max-width: 600px;
|
|
24
|
+
border-radius: 36px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
} .popup-sheet__closer_18ukp {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 8px;
|
|
29
|
+
right: 8px
|
|
30
|
+
} .popup-sheet__closer_18ukp > button {
|
|
31
|
+
-webkit-backdrop-filter: none;
|
|
32
|
+
backdrop-filter: none;
|
|
33
|
+
} .popup-sheet__content_18ukp {
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
} /* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */ .popup-sheet__appear_18ukp,
|
|
36
|
+
.popup-sheet__enter_18ukp {
|
|
37
|
+
transform: translateY(calc(100% + 100px));
|
|
38
|
+
} .popup-sheet__appearActive_18ukp,
|
|
39
|
+
.popup-sheet__enterActive_18ukp {
|
|
40
|
+
transform: translateY(0);
|
|
41
|
+
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
42
|
+
transition-delay: 50ms;
|
|
43
|
+
} .popup-sheet__exit_18ukp {
|
|
44
|
+
transform: translateY(0);
|
|
45
|
+
} .popup-sheet__exitBySwipe_18ukp {
|
|
46
|
+
transform: translateY(calc(100% + 100px));
|
|
47
|
+
} .popup-sheet__exitActiveBySwipe_18ukp {
|
|
48
|
+
transition: none;
|
|
49
|
+
} .popup-sheet__exitActive_18ukp,
|
|
50
|
+
.popup-sheet__exitDone_18ukp {
|
|
51
|
+
transform: translateY(calc(100% + 100px));
|
|
52
|
+
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
53
|
+
}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupSheet, PopupSheetProps } from "./Component";
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { PopupSheet } from './Component.js';
|
|
2
|
+
import 'tslib';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'react-swipeable';
|
|
5
|
+
import 'classnames';
|
|
6
|
+
import '@alfalab/core-components-base-modal/esm';
|
|
7
|
+
import '@alfalab/core-components-navigation-bar/esm/shared';
|
|
8
|
+
import '@alfalab/core-components-shared/esm';
|
|
9
|
+
import './components/backdrop/Component.js';
|
|
10
|
+
import '@alfalab/core-components-backdrop/esm';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
type StyleColors = {
|
|
3
|
+
default: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
inverted: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type ComponentProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Тип кнопки
|
|
13
|
+
* @default secondary
|
|
14
|
+
*/
|
|
15
|
+
view?: 'accent' | 'primary' | 'secondary' | 'tertiary' | 'outlined' | 'filled' | 'transparent' | 'link' | 'ghost';
|
|
16
|
+
/**
|
|
17
|
+
* Слот слева
|
|
18
|
+
*/
|
|
19
|
+
leftAddons?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Слот справа
|
|
22
|
+
*/
|
|
23
|
+
rightAddons?: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Размер компонента
|
|
26
|
+
* @default m
|
|
27
|
+
*/
|
|
28
|
+
size?: 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
29
|
+
/**
|
|
30
|
+
* Растягивает компонент на ширину контейнера
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
block?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Дополнительный класс
|
|
36
|
+
*/
|
|
37
|
+
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Дополнительный класс для спиннера
|
|
40
|
+
*/
|
|
41
|
+
spinnerClassName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Выводит ссылку в виде кнопки
|
|
44
|
+
*/
|
|
45
|
+
href?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Позволяет использовать кастомный компонент для кнопки (например Link из роутера)
|
|
48
|
+
*/
|
|
49
|
+
Component?: ElementType;
|
|
50
|
+
/**
|
|
51
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
52
|
+
*/
|
|
53
|
+
dataTestId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Показать лоадер
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Не переносить текст кнопки на новую строку
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
nowrap?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Набор цветов для компонента
|
|
66
|
+
*/
|
|
67
|
+
colors?: 'default' | 'inverted';
|
|
68
|
+
/**
|
|
69
|
+
* Дочерние элементы.
|
|
70
|
+
*/
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* Основные стили компонента.
|
|
74
|
+
*/
|
|
75
|
+
styles: {
|
|
76
|
+
[key: string]: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Стили компонента для default и inverted режима.
|
|
80
|
+
*/
|
|
81
|
+
colorStylesMap: StyleColors;
|
|
82
|
+
};
|
|
83
|
+
type AnchorBaseButtonProps = ComponentProps & AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
84
|
+
type NativeBaseButtonProps = ComponentProps & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
85
|
+
type BaseButtonProps = Partial<AnchorBaseButtonProps | NativeBaseButtonProps>;
|
|
86
|
+
type AnchorButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
87
|
+
type NativeButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
88
|
+
type ButtonProps = Partial<AnchorButtonProps | NativeButtonProps> & {
|
|
89
|
+
/**
|
|
90
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
91
|
+
* @default 1024
|
|
92
|
+
*/
|
|
93
|
+
breakpoint?: number;
|
|
94
|
+
};
|
|
95
|
+
export { StyleColors, ComponentProps, AnchorBaseButtonProps, NativeBaseButtonProps, BaseButtonProps, AnchorButtonProps, NativeButtonProps, ButtonProps };
|