@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/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/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupSheet, PopupSheetProps } from "./Component";
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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');
|
|
11
|
+
require('@alfalab/core-components-navigation-bar/shared');
|
|
12
|
+
require('@alfalab/core-components-shared');
|
|
13
|
+
require('./components/backdrop/Component.js');
|
|
14
|
+
require('@alfalab/core-components-backdrop');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.PopupSheet = Component.PopupSheet;
|
|
@@ -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 };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef } from 'react';
|
|
2
|
+
import { useSwipeable } from 'react-swipeable';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { BaseModal } from '@alfalab/core-components-base-modal/modern';
|
|
5
|
+
import { Closer } from '@alfalab/core-components-navigation-bar/modern/shared';
|
|
6
|
+
import { createPaddingStyle, getDataTestId, easingFns } from '@alfalab/core-components-shared/modern';
|
|
7
|
+
import { PopupBackdrop } from './components/backdrop/Component.js';
|
|
8
|
+
import '@alfalab/core-components-backdrop/modern';
|
|
9
|
+
|
|
10
|
+
const 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"};
|
|
11
|
+
require('./index.css')
|
|
12
|
+
|
|
13
|
+
const SWIPE_VELOCITY = 0.3;
|
|
14
|
+
const CLOSE_OFFSET = 0.3;
|
|
15
|
+
const ANIMATION_DURATION = 350;
|
|
16
|
+
const DEFAULT_PADDING = 32;
|
|
17
|
+
const PopupSheet = forwardRef(({ children, hasCloser, className, onClose, transitionProps, contentProps, swipeable, dataTestId, backdropProps, padding = DEFAULT_PADDING, ...restProps }, ref) => {
|
|
18
|
+
const [sheetOffset, setSheetOffset] = useState(0);
|
|
19
|
+
const [backdropOpacity, setBackdropOpacity] = useState(1);
|
|
20
|
+
const sheetHeight = useRef(0);
|
|
21
|
+
const sheetRef = useRef(null);
|
|
22
|
+
const bySwipeCloseAnimation = useRef(false);
|
|
23
|
+
const getSheetOffset = (deltaY) => Math.max(0, deltaY);
|
|
24
|
+
const getBackdropOpacity = (offset) => Math.max(0, 1 - offset / sheetHeight.current);
|
|
25
|
+
const getSwipeStyles = () => sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};
|
|
26
|
+
const handleSwiping = ({ deltaY }) => {
|
|
27
|
+
const offset = getSheetOffset(deltaY);
|
|
28
|
+
setSheetOffset(offset);
|
|
29
|
+
setBackdropOpacity(getBackdropOpacity(offset));
|
|
30
|
+
};
|
|
31
|
+
const handleSwiped = ({ deltaY, velocity, event }) => {
|
|
32
|
+
const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;
|
|
33
|
+
const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;
|
|
34
|
+
const offset = sheetOffset;
|
|
35
|
+
const animDuration = ANIMATION_DURATION / 2;
|
|
36
|
+
let start;
|
|
37
|
+
if (shouldCloseByVelocity || shouldCloseByOffset) {
|
|
38
|
+
bySwipeCloseAnimation.current = true;
|
|
39
|
+
onClose?.(event, 'swipe');
|
|
40
|
+
const runLoop = (timeStamp) => {
|
|
41
|
+
if (!start)
|
|
42
|
+
start = timeStamp;
|
|
43
|
+
const elapsedTime = timeStamp - start;
|
|
44
|
+
if (elapsedTime <= animDuration) {
|
|
45
|
+
const nextOffset = offset +
|
|
46
|
+
(sheetHeight.current - offset) *
|
|
47
|
+
easingFns.easeInOutQuad(elapsedTime / animDuration);
|
|
48
|
+
if (nextOffset > 0) {
|
|
49
|
+
setSheetOffset(nextOffset);
|
|
50
|
+
}
|
|
51
|
+
requestAnimationFrame(runLoop);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setSheetOffset(0);
|
|
55
|
+
bySwipeCloseAnimation.current = false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
requestAnimationFrame(runLoop);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const runLoop = (timeStamp) => {
|
|
62
|
+
if (!start)
|
|
63
|
+
start = timeStamp;
|
|
64
|
+
const elapsedTime = timeStamp - start;
|
|
65
|
+
if (elapsedTime <= animDuration) {
|
|
66
|
+
const nextOffset = offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);
|
|
67
|
+
if (nextOffset > 0) {
|
|
68
|
+
setSheetOffset(nextOffset);
|
|
69
|
+
setBackdropOpacity(getBackdropOpacity(nextOffset));
|
|
70
|
+
}
|
|
71
|
+
requestAnimationFrame(runLoop);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
setSheetOffset(0);
|
|
75
|
+
setBackdropOpacity(1);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
requestAnimationFrame(runLoop);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const handleEntered = (node, isAppearing) => {
|
|
82
|
+
bySwipeCloseAnimation.current = false;
|
|
83
|
+
if (sheetRef.current) {
|
|
84
|
+
sheetHeight.current = sheetRef.current.offsetHeight;
|
|
85
|
+
}
|
|
86
|
+
if (transitionProps?.onEntered) {
|
|
87
|
+
transitionProps.onEntered(node, isAppearing);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleExited = (node) => {
|
|
91
|
+
bySwipeCloseAnimation.current = false;
|
|
92
|
+
setSheetOffset(0);
|
|
93
|
+
setBackdropOpacity(1);
|
|
94
|
+
if (transitionProps?.onExited) {
|
|
95
|
+
transitionProps.onExited(node);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const sheetSwipeableHandlers = useSwipeable({
|
|
99
|
+
onSwiping: handleSwiping,
|
|
100
|
+
onSwiped: handleSwiped,
|
|
101
|
+
trackMouse: swipeable,
|
|
102
|
+
trackTouch: swipeable,
|
|
103
|
+
delta: 5,
|
|
104
|
+
});
|
|
105
|
+
return (React.createElement(BaseModal, { ...restProps, onClose: onClose, ref: ref, className: cn(styles.component, className), dataTestId: dataTestId, Backdrop: PopupBackdrop, backdropProps: {
|
|
106
|
+
...backdropProps,
|
|
107
|
+
opacity: backdropOpacity,
|
|
108
|
+
}, transitionProps: {
|
|
109
|
+
classNames: {
|
|
110
|
+
enter: styles.enter,
|
|
111
|
+
appear: styles.appear,
|
|
112
|
+
enterActive: styles.enterActive,
|
|
113
|
+
appearActive: styles.appearActive,
|
|
114
|
+
exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,
|
|
115
|
+
exitActive: bySwipeCloseAnimation.current
|
|
116
|
+
? styles.exitActiveBySwipe
|
|
117
|
+
: styles.exitActive,
|
|
118
|
+
},
|
|
119
|
+
timeout: ANIMATION_DURATION,
|
|
120
|
+
...transitionProps,
|
|
121
|
+
onEntered: handleEntered,
|
|
122
|
+
onExited: handleExited,
|
|
123
|
+
}, componentDivProps: {
|
|
124
|
+
ref: sheetRef,
|
|
125
|
+
style: getSwipeStyles(),
|
|
126
|
+
}, contentProps: {
|
|
127
|
+
style: createPaddingStyle(padding),
|
|
128
|
+
...contentProps,
|
|
129
|
+
...sheetSwipeableHandlers,
|
|
130
|
+
className: cn(styles.content, contentProps?.className),
|
|
131
|
+
} },
|
|
132
|
+
hasCloser && (React.createElement(Closer, { view: 'mobile', className: styles.closer, onClick: onClose, dataTestId: getDataTestId(dataTestId, 'closer') })),
|
|
133
|
+
children));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
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,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Backdrop } from '@alfalab/core-components-backdrop/modern';
|
|
3
|
+
|
|
4
|
+
const 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"};
|
|
5
|
+
require('./index.css')
|
|
6
|
+
|
|
7
|
+
const PopupBackdrop = ({ opacity, opacityTimeout, style, ...backdropProps }) => (React.createElement("div", { style: {
|
|
8
|
+
opacity,
|
|
9
|
+
transition: opacity === 1 ? `opacity ${opacityTimeout}ms ease-in-out` : '',
|
|
10
|
+
position: 'relative',
|
|
11
|
+
...style,
|
|
12
|
+
} },
|
|
13
|
+
React.createElement(Backdrop, { transitionClassNames: styles, ...backdropProps })));
|
|
14
|
+
|
|
15
|
+
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/modern/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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopupSheet, PopupSheetProps } from "./Component";
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { PopupSheet } from './Component.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'react-swipeable';
|
|
4
|
+
import 'classnames';
|
|
5
|
+
import '@alfalab/core-components-base-modal/modern';
|
|
6
|
+
import '@alfalab/core-components-navigation-bar/modern/shared';
|
|
7
|
+
import '@alfalab/core-components-shared/modern';
|
|
8
|
+
import './components/backdrop/Component.js';
|
|
9
|
+
import '@alfalab/core-components-backdrop/modern';
|
|
@@ -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 };
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfalab/core-components-popup-sheet",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Popup sheet mobile component",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "./esm/index.js",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"directory": "dist"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"react": "^16.9.0 || ^17.0.1 || ^18.0.0",
|
|
15
|
+
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@alfalab/core-components-base-modal": "^5.4.0",
|
|
19
|
+
"@alfalab/core-components-backdrop": "^3.1.0",
|
|
20
|
+
"@alfalab/core-components-shared": "^0.2.0",
|
|
21
|
+
"@alfalab/core-components-navigation-bar": "^0.5.0",
|
|
22
|
+
"react-swipeable": "^7.0.0",
|
|
23
|
+
"classnames": "^2.3.1",
|
|
24
|
+
"tslib": "^2.4.0"
|
|
25
|
+
}
|
|
26
|
+
}
|