@alfalab/core-components-popup-sheet 2.0.1 → 2.0.3
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.js +5 -4
- package/Component.js.map +1 -1
- package/components/backdrop/index.css +9 -9
- package/components/backdrop/index.module.css.js +1 -1
- package/components/backdrop/index.module.css.js.map +1 -1
- package/cssm/Component.js +5 -4
- package/cssm/Component.js.map +1 -1
- package/cssm/index.module.css +2 -2
- package/esm/Component.js +4 -4
- package/esm/Component.js.map +1 -1
- package/esm/components/backdrop/index.css +9 -9
- package/esm/components/backdrop/index.module.css.js +1 -1
- package/esm/components/backdrop/index.module.css.js.map +1 -1
- package/esm/index.css +14 -14
- package/esm/index.module.css.js +1 -1
- package/esm/index.module.css.js.map +1 -1
- package/index.css +14 -14
- package/index.module.css.js +1 -1
- package/index.module.css.js.map +1 -1
- package/modern/Component.js +5 -2
- package/modern/Component.js.map +1 -1
- package/modern/components/backdrop/index.css +9 -9
- package/modern/components/backdrop/index.module.css.js +1 -1
- package/modern/components/backdrop/index.module.css.js.map +1 -1
- package/modern/index.css +14 -14
- package/modern/index.module.css.js +1 -1
- package/modern/index.module.css.js.map +1 -1
- package/moderncssm/Component.js +5 -2
- package/moderncssm/Component.js.map +1 -1
- package/moderncssm/components/backdrop/index.module.css +6 -0
- package/moderncssm/index.module.css +4 -2
- package/package.json +3 -2
- package/src/Component.tsx +6 -2
- package/src/components/backdrop/index.module.css +1 -1
- package/src/index.module.css +2 -2
package/Component.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var mergeRefs = require('react-merge-refs');
|
|
7
8
|
var reactSwipeable = require('react-swipeable');
|
|
8
9
|
var cn = require('classnames');
|
|
9
10
|
var coreComponentsBaseModal = require('@alfalab/core-components-base-modal');
|
|
@@ -15,6 +16,7 @@ var index_module = require('./index.module.css.js');
|
|
|
15
16
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
17
|
|
|
17
18
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
18
20
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
21
|
|
|
20
22
|
var SWIPE_VELOCITY = 0.3;
|
|
@@ -116,6 +118,8 @@ var PopupSheet = React.forwardRef(function (_a, ref) {
|
|
|
116
118
|
trackTouch: swipeable,
|
|
117
119
|
delta: 5,
|
|
118
120
|
});
|
|
121
|
+
var swipeRef = sheetSwipeableHandlers.ref, swipeHandlers = tslib.__rest(sheetSwipeableHandlers, ["ref"]);
|
|
122
|
+
var componentRef = mergeRefs__default.default([sheetRef, swipeRef]);
|
|
119
123
|
return (React__default.default.createElement(coreComponentsBaseModal.BaseModal, tslib.__assign({}, restProps, { onClose: onClose, ref: ref, className: cn__default.default(index_module.component, className), dataTestId: dataTestId, Backdrop: Component.PopupBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { opacity: backdropOpacity }), transitionProps: tslib.__assign(tslib.__assign({ classNames: {
|
|
120
124
|
enter: index_module.enter,
|
|
121
125
|
appear: index_module.appear,
|
|
@@ -125,10 +129,7 @@ var PopupSheet = React.forwardRef(function (_a, ref) {
|
|
|
125
129
|
exitActive: bySwipeCloseAnimation.current
|
|
126
130
|
? index_module.exitActiveBySwipe
|
|
127
131
|
: index_module.exitActive,
|
|
128
|
-
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: {
|
|
129
|
-
ref: sheetRef,
|
|
130
|
-
style: getSwipeStyles(),
|
|
131
|
-
}, contentProps: tslib.__assign(tslib.__assign(tslib.__assign({ style: coreComponentsShared.createPaddingStyle(padding) }, contentProps), sheetSwipeableHandlers), { className: cn__default.default(index_module.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
132
|
+
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: tslib.__assign({ ref: componentRef, style: getSwipeStyles() }, (swipeable ? swipeHandlers : {})), contentProps: tslib.__assign(tslib.__assign({ style: coreComponentsShared.createPaddingStyle(padding) }, contentProps), { className: cn__default.default(index_module.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
132
133
|
hasCloser && (React__default.default.createElement(shared.Closer, tslib.__assign({ view: 'mobile', onClick: onClose, dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'closer') }, closerProps, { className: cn__default.default(index_module.closer, closerProps === null || closerProps === void 0 ? void 0 : closerProps.className) }))),
|
|
133
134
|
children));
|
|
134
135
|
});
|
package/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: sheetRef,\n style: getSwipeStyles(),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n ...sheetSwipeableHandlers,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":["forwardRef","__rest","useState","useRef","easingFns","useSwipeable","React","BaseModal","__assign","cn","styles","PopupBackdrop","createPaddingStyle","Closer","getDataTestId"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAGA,gBAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,GAAA,EAAA,EACb,SAAS,GAAAC,YAAA,CAAA,EAAA,EAZhB,0JAaC,CADe;IAIV,IAAA,EAAA,GAAgCC,cAAQ,CAAC,CAAC,CAAC,EAA1C,WAA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MAAA,GAAA,MAAA,GAAA,YAAY,CAAE,SAAS,CAAC,EAAA,CAAA,EAAA,CAAA;AAGzD,QAAA,SAAS,KACNJ,sBAAA,CAAA,aAAA,CAACO,aAAM,EACHL,cAAA,CAAA,EAAA,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAEM,kCAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAEL,mBAAE,CAACC,YAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;\n const componentRef = mergeRefs([sheetRef, swipeRef]);\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: componentRef,\n style: getSwipeStyles(),\n ...(swipeable ? swipeHandlers : {}),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":["forwardRef","__rest","useState","useRef","easingFns","useSwipeable","mergeRefs","React","BaseModal","__assign","cn","styles","PopupBackdrop","createPaddingStyle","Closer","getDataTestId"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAGA,gBAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,GAAA,EAAA,EACb,SAAS,GAAAC,YAAA,CAAA,EAAA,EAZhB,0JAaC,CADe;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c,EAAE,EACpB,GAAC,SAAS,GAAG,aAAa,GAAG,EAAE,EAAC,EAEvC,YAAY,EAAAA,cAAA,CAAAA,cAAA,CAAA,EACR,KAAK,EAAEI,uCAAkB,CAAC,OAAO,CAAC,IAC/B,YAAY,CAAA,EAAA,EACf,SAAS,EAAEH,mBAAE,CAACC,YAAM,CAAC,OAAO,EAAE,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,SAAS,CAAC,EAAA,CAAA,EAAA,CAAA;AAGzD,QAAA,SAAS,KACNJ,sBAAA,CAAA,aAAA,CAACO,aAAM,EACHL,cAAA,CAAA,EAAA,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAEM,kCAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAEL,mBAAE,CAACC,YAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
} :root {
|
|
4
4
|
--backdrop-visible-background: var(--color-light-overlay-default);
|
|
5
5
|
--backdrop-hidden-background: transparent;
|
|
6
|
-
} .popup-
|
|
7
|
-
.popup-
|
|
6
|
+
} .popup-sheet__appear_7036h,
|
|
7
|
+
.popup-sheet__enter_7036h {
|
|
8
8
|
background-color: var(--backdrop-hidden-background);
|
|
9
|
-
} .popup-
|
|
10
|
-
.popup-
|
|
11
|
-
.popup-
|
|
12
|
-
.popup-
|
|
9
|
+
} .popup-sheet__appearActive_7036h,
|
|
10
|
+
.popup-sheet__enterActive_7036h,
|
|
11
|
+
.popup-sheet__appearDone_7036h,
|
|
12
|
+
.popup-sheet__enterDone_7036h {
|
|
13
13
|
background-color: var(--backdrop-visible-background);
|
|
14
14
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__exit_7036h {
|
|
16
16
|
background-color: var(--backdrop-visible-background);
|
|
17
|
-
} .popup-
|
|
18
|
-
.popup-
|
|
17
|
+
} .popup-sheet__exitActive_7036h,
|
|
18
|
+
.popup-sheet__exitDone_7036h {
|
|
19
19
|
background-color: var(--backdrop-hidden-background);
|
|
20
20
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
21
21
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"appear":"popup-
|
|
5
|
+
var styles = {"appear":"popup-sheet__appear_7036h","enter":"popup-sheet__enter_7036h","appearActive":"popup-sheet__appearActive_7036h","enterActive":"popup-sheet__enterActive_7036h","appearDone":"popup-sheet__appearDone_7036h","enterDone":"popup-sheet__enterDone_7036h","exit":"popup-sheet__exit_7036h","exitActive":"popup-sheet__exitActive_7036h","exitDone":"popup-sheet__exitDone_7036h"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
package/cssm/Component.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var mergeRefs = require('react-merge-refs');
|
|
7
8
|
var reactSwipeable = require('react-swipeable');
|
|
8
9
|
var cn = require('classnames');
|
|
9
10
|
var cssm = require('@alfalab/core-components-base-modal/cssm');
|
|
@@ -15,6 +16,7 @@ var styles = require('./index.module.css');
|
|
|
15
16
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
17
|
|
|
17
18
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
18
20
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
21
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
20
22
|
|
|
@@ -117,6 +119,8 @@ var PopupSheet = React.forwardRef(function (_a, ref) {
|
|
|
117
119
|
trackTouch: swipeable,
|
|
118
120
|
delta: 5,
|
|
119
121
|
});
|
|
122
|
+
var swipeRef = sheetSwipeableHandlers.ref, swipeHandlers = tslib.__rest(sheetSwipeableHandlers, ["ref"]);
|
|
123
|
+
var componentRef = mergeRefs__default.default([sheetRef, swipeRef]);
|
|
120
124
|
return (React__default.default.createElement(cssm.BaseModal, tslib.__assign({}, restProps, { onClose: onClose, ref: ref, className: cn__default.default(styles__default.default.component, className), dataTestId: dataTestId, Backdrop: Component.PopupBackdrop, backdropProps: tslib.__assign(tslib.__assign({}, backdropProps), { opacity: backdropOpacity }), transitionProps: tslib.__assign(tslib.__assign({ classNames: {
|
|
121
125
|
enter: styles__default.default.enter,
|
|
122
126
|
appear: styles__default.default.appear,
|
|
@@ -126,10 +130,7 @@ var PopupSheet = React.forwardRef(function (_a, ref) {
|
|
|
126
130
|
exitActive: bySwipeCloseAnimation.current
|
|
127
131
|
? styles__default.default.exitActiveBySwipe
|
|
128
132
|
: styles__default.default.exitActive,
|
|
129
|
-
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: {
|
|
130
|
-
ref: sheetRef,
|
|
131
|
-
style: getSwipeStyles(),
|
|
132
|
-
}, contentProps: tslib.__assign(tslib.__assign(tslib.__assign({ style: cssm$1.createPaddingStyle(padding) }, contentProps), sheetSwipeableHandlers), { className: cn__default.default(styles__default.default.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
133
|
+
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: tslib.__assign({ ref: componentRef, style: getSwipeStyles() }, (swipeable ? swipeHandlers : {})), contentProps: tslib.__assign(tslib.__assign({ style: cssm$1.createPaddingStyle(padding) }, contentProps), { className: cn__default.default(styles__default.default.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
133
134
|
hasCloser && (React__default.default.createElement(shared.Closer, tslib.__assign({ view: 'mobile', onClick: onClose, dataTestId: cssm$1.getDataTestId(dataTestId, 'closer') }, closerProps, { className: cn__default.default(styles__default.default.closer, closerProps === null || closerProps === void 0 ? void 0 : closerProps.className) }))),
|
|
134
135
|
children));
|
|
135
136
|
});
|
package/cssm/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: sheetRef,\n style: getSwipeStyles(),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n ...sheetSwipeableHandlers,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":["forwardRef","__rest","useState","useRef","easingFns","useSwipeable","React","BaseModal","__assign","cn","styles","PopupBackdrop","createPaddingStyle","Closer","getDataTestId"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAGA,gBAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,GAAA,EAAA,EACb,SAAS,GAAAC,YAAA,CAAA,EAAA,EAZhB,0JAaC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H,mBAAE,CAACC,uBAAM,CAAC,OAAO,EAAE,YAAY,KAAZ,IAAA,IAAA,YAAY,KAAZ,MAAA,GAAA,MAAA,GAAA,YAAY,CAAE,SAAS,CAAC,EAAA,CAAA,EAAA,CAAA;AAGzD,QAAA,SAAS,KACNJ,sBAAA,CAAA,aAAA,CAACO,aAAM,EACHL,cAAA,CAAA,EAAA,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAEM,oBAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAEL,mBAAE,CAACC,uBAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;\n const componentRef = mergeRefs([sheetRef, swipeRef]);\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: componentRef,\n style: getSwipeStyles(),\n ...(swipeable ? swipeHandlers : {}),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":["forwardRef","__rest","useState","useRef","easingFns","useSwipeable","mergeRefs","React","BaseModal","__assign","cn","styles","PopupBackdrop","createPaddingStyle","Closer","getDataTestId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAGA,gBAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAA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,EAAA,CAAA,EAE1B,iBAAiB,EAAAF,cAAA,CAAA,EACb,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,cAAc,EAAE,EACpB,GAAC,SAAS,GAAG,aAAa,GAAG,EAAE,EAAC,EAEvC,YAAY,EAAAA,cAAA,CAAAA,cAAA,CAAA,EACR,KAAK,EAAEI,yBAAkB,CAAC,OAAO,CAAC,IAC/B,YAAY,CAAA,EAAA,EACf,SAAS,EAAEH,mBAAE,CAACC,uBAAM,CAAC,OAAO,EAAE,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,CAAE,SAAS,CAAC,EAAA,CAAA,EAAA,CAAA;AAGzD,QAAA,SAAS,KACNJ,sBAAA,CAAA,aAAA,CAACO,aAAM,EACHL,cAAA,CAAA,EAAA,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAEM,oBAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAEL,mBAAE,CAACC,uBAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
package/cssm/index.module.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
--gap-xs: 8px;
|
|
5
5
|
--gap-0: 0px;
|
|
6
6
|
--gap-8: var(--gap-xs);
|
|
7
|
-
} .component {
|
|
7
|
+
} .component.component {
|
|
8
8
|
position: fixed;
|
|
9
9
|
bottom: var(--gap-0);
|
|
10
10
|
margin: auto var(--gap-8) var(--gap-8);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
} .closer {
|
|
16
16
|
position: absolute;
|
|
17
17
|
top: var(--gap-8);
|
|
18
|
-
right: var(--gap-8)
|
|
18
|
+
right: var(--gap-8);
|
|
19
19
|
} .closer > button {
|
|
20
20
|
-webkit-backdrop-filter: none;
|
|
21
21
|
backdrop-filter: none;
|
package/esm/Component.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
2
|
import React, { forwardRef, useState, useRef } from 'react';
|
|
3
|
+
import mergeRefs from 'react-merge-refs';
|
|
3
4
|
import { useSwipeable } from 'react-swipeable';
|
|
4
5
|
import cn from 'classnames';
|
|
5
6
|
import { BaseModal } from '@alfalab/core-components-base-modal/esm';
|
|
@@ -107,6 +108,8 @@ var PopupSheet = forwardRef(function (_a, ref) {
|
|
|
107
108
|
trackTouch: swipeable,
|
|
108
109
|
delta: 5,
|
|
109
110
|
});
|
|
111
|
+
var swipeRef = sheetSwipeableHandlers.ref, swipeHandlers = __rest(sheetSwipeableHandlers, ["ref"]);
|
|
112
|
+
var componentRef = mergeRefs([sheetRef, swipeRef]);
|
|
110
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: {
|
|
111
114
|
enter: styles.enter,
|
|
112
115
|
appear: styles.appear,
|
|
@@ -116,10 +119,7 @@ var PopupSheet = forwardRef(function (_a, ref) {
|
|
|
116
119
|
exitActive: bySwipeCloseAnimation.current
|
|
117
120
|
? styles.exitActiveBySwipe
|
|
118
121
|
: styles.exitActive,
|
|
119
|
-
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: {
|
|
120
|
-
ref: sheetRef,
|
|
121
|
-
style: getSwipeStyles(),
|
|
122
|
-
}, contentProps: __assign(__assign(__assign({ style: createPaddingStyle(padding) }, contentProps), sheetSwipeableHandlers), { className: cn(styles.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
122
|
+
}, timeout: ANIMATION_DURATION }, transitionProps), { onEntered: handleEntered, onExited: handleExited }), componentDivProps: __assign({ ref: componentRef, style: getSwipeStyles() }, (swipeable ? swipeHandlers : {})), contentProps: __assign(__assign({ style: createPaddingStyle(padding) }, contentProps), { className: cn(styles.content, contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }) }),
|
|
123
123
|
hasCloser && (React.createElement(Closer, __assign({ view: 'mobile', onClick: onClose, dataTestId: getDataTestId(dataTestId, 'closer') }, closerProps, { className: cn(styles.closer, closerProps === null || closerProps === void 0 ? void 0 : closerProps.className) }))),
|
|
124
124
|
children));
|
|
125
125
|
});
|
package/esm/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: sheetRef,\n style: getSwipeStyles(),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n ...sheetSwipeableHandlers,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;;AAoBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAG,UAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,GAAA,EAAA,EACb,SAAS,GAAA,MAAA,CAAA,EAAA,EAZhB,0JAaC,CADe;IAIV,IAAA,EAAA,GAAgC,QAAQ,CAAC,CAAC,CAAC,EAA1C,WAAW,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,cAAc,GAAA,EAAA,CAAA,CAAA,CAAe;IAC3C,IAAA,EAAA,GAAwC,QAAQ,CAAC,CAAC,CAAC,EAAlD,eAAe,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,kBAAkB,GAAA,EAAA,CAAA,CAA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,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;\n const componentRef = mergeRefs([sheetRef, swipeRef]);\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: componentRef,\n style: getSwipeStyles(),\n ...(swipeable ? swipeHandlers : {}),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;;;AAqBA,IAAM,cAAc,GAAG,GAAG;AAC1B,IAAM,YAAY,GAAG,GAAG;AACxB,IAAM,kBAAkB,GAAG,GAAG;AAsC9B,IAAM,eAAe,GAAG,EAAE;IAEb,UAAU,GAAG,UAAU,CAChC,UACI,EAaC,EACD,GAAG,EAAA;IAbC,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,SAAS,eAAA,EACT,OAAO,aAAA,EACP,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,EAAA,GAAA,EAAA,CAAA,OAAyB,EAAzB,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,eAAe,GAAA,EAAA,EACzB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,GAAA,EAAA,EACb,SAAS,GAAA,MAAA,CAAA,EAAA,EAZhB,0JAaC,CADe;IAIV,IAAA,EAAA,GAAgC,QAAQ,CAAC,CAAC,CAAC,EAA1C,WAAW,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,cAAc,GAAA,EAAA,CAAA,CAAA,CAAe;IAC3C,IAAA,EAAA,GAAwC,QAAQ,CAAC,CAAC,CAAC,EAAlD,eAAe,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,kBAAkB,GAAA,EAAA,CAAA,CAAA,CAAe;AAEzD,IAAA,IAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,IAAA,IAAM,QAAQ,GAAG,MAAM,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IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAA,EAC3C,WAAW,EACf,EAAA,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,KAAA,IAAA,IAAX,WAAW,KAAX,MAAA,GAAA,MAAA,GAAA,WAAW,CAAE,SAAS,CAAC,IACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
} :root {
|
|
4
4
|
--backdrop-visible-background: var(--color-light-overlay-default);
|
|
5
5
|
--backdrop-hidden-background: transparent;
|
|
6
|
-
} .popup-
|
|
7
|
-
.popup-
|
|
6
|
+
} .popup-sheet__appear_7036h,
|
|
7
|
+
.popup-sheet__enter_7036h {
|
|
8
8
|
background-color: var(--backdrop-hidden-background);
|
|
9
|
-
} .popup-
|
|
10
|
-
.popup-
|
|
11
|
-
.popup-
|
|
12
|
-
.popup-
|
|
9
|
+
} .popup-sheet__appearActive_7036h,
|
|
10
|
+
.popup-sheet__enterActive_7036h,
|
|
11
|
+
.popup-sheet__appearDone_7036h,
|
|
12
|
+
.popup-sheet__enterDone_7036h {
|
|
13
13
|
background-color: var(--backdrop-visible-background);
|
|
14
14
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__exit_7036h {
|
|
16
16
|
background-color: var(--backdrop-visible-background);
|
|
17
|
-
} .popup-
|
|
18
|
-
.popup-
|
|
17
|
+
} .popup-sheet__exitActive_7036h,
|
|
18
|
+
.popup-sheet__exitDone_7036h {
|
|
19
19
|
background-color: var(--backdrop-hidden-background);
|
|
20
20
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
var styles = {"appear":"popup-
|
|
3
|
+
var styles = {"appear":"popup-sheet__appear_7036h","enter":"popup-sheet__enter_7036h","appearActive":"popup-sheet__appearActive_7036h","enterActive":"popup-sheet__enterActive_7036h","appearDone":"popup-sheet__appearDone_7036h","enterDone":"popup-sheet__enterDone_7036h","exit":"popup-sheet__exit_7036h","exitActive":"popup-sheet__exitActive_7036h","exitDone":"popup-sheet__exitDone_7036h"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
package/esm/index.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
--gap-xs: 8px;
|
|
5
5
|
--gap-0: 0px;
|
|
6
6
|
--gap-8: var(--gap-xs);
|
|
7
|
-
} .popup-
|
|
7
|
+
} .popup-sheet__component_12dl2.popup-sheet__component_12dl2 {
|
|
8
8
|
position: fixed;
|
|
9
9
|
bottom: var(--gap-0);
|
|
10
10
|
margin: auto var(--gap-8) var(--gap-8);
|
|
@@ -12,31 +12,31 @@
|
|
|
12
12
|
max-width: 600px;
|
|
13
13
|
border-radius: var(--border-radius-36);
|
|
14
14
|
overflow: hidden;
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__closer_12dl2 {
|
|
16
16
|
position: absolute;
|
|
17
17
|
top: var(--gap-8);
|
|
18
|
-
right: var(--gap-8)
|
|
19
|
-
} .popup-
|
|
18
|
+
right: var(--gap-8);
|
|
19
|
+
} .popup-sheet__closer_12dl2 > button {
|
|
20
20
|
-webkit-backdrop-filter: none;
|
|
21
21
|
backdrop-filter: none;
|
|
22
|
-
} .popup-
|
|
22
|
+
} .popup-sheet__content_12dl2 {
|
|
23
23
|
box-sizing: border-box;
|
|
24
|
-
} .popup-
|
|
25
|
-
.popup-
|
|
24
|
+
} .popup-sheet__appear_12dl2,
|
|
25
|
+
.popup-sheet__enter_12dl2 {
|
|
26
26
|
transform: translateY(calc(100% + 100px));
|
|
27
|
-
} .popup-
|
|
28
|
-
.popup-
|
|
27
|
+
} .popup-sheet__appearActive_12dl2,
|
|
28
|
+
.popup-sheet__enterActive_12dl2 {
|
|
29
29
|
transform: translateY(0);
|
|
30
30
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
31
31
|
transition-delay: 50ms;
|
|
32
|
-
} .popup-
|
|
32
|
+
} .popup-sheet__exit_12dl2 {
|
|
33
33
|
transform: translateY(0);
|
|
34
|
-
} .popup-
|
|
34
|
+
} .popup-sheet__exitBySwipe_12dl2 {
|
|
35
35
|
transform: translateY(calc(100% + 100px));
|
|
36
|
-
} .popup-
|
|
36
|
+
} .popup-sheet__exitActiveBySwipe_12dl2 {
|
|
37
37
|
transition: none;
|
|
38
|
-
} .popup-
|
|
39
|
-
.popup-
|
|
38
|
+
} .popup-sheet__exitActive_12dl2,
|
|
39
|
+
.popup-sheet__exitDone_12dl2 {
|
|
40
40
|
transform: translateY(calc(100% + 100px));
|
|
41
41
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
42
42
|
}
|
package/esm/index.module.css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
var styles = {"component":"popup-
|
|
3
|
+
var styles = {"component":"popup-sheet__component_12dl2","closer":"popup-sheet__closer_12dl2","content":"popup-sheet__content_12dl2","appear":"popup-sheet__appear_12dl2","enter":"popup-sheet__enter_12dl2","appearActive":"popup-sheet__appearActive_12dl2","enterActive":"popup-sheet__enterActive_12dl2","exit":"popup-sheet__exit_12dl2","exitBySwipe":"popup-sheet__exitBySwipe_12dl2","exitActiveBySwipe":"popup-sheet__exitActiveBySwipe_12dl2","exitActive":"popup-sheet__exitActive_12dl2"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.component.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
package/index.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
--gap-xs: 8px;
|
|
5
5
|
--gap-0: 0px;
|
|
6
6
|
--gap-8: var(--gap-xs);
|
|
7
|
-
} .popup-
|
|
7
|
+
} .popup-sheet__component_12dl2.popup-sheet__component_12dl2 {
|
|
8
8
|
position: fixed;
|
|
9
9
|
bottom: var(--gap-0);
|
|
10
10
|
margin: auto var(--gap-8) var(--gap-8);
|
|
@@ -12,31 +12,31 @@
|
|
|
12
12
|
max-width: 600px;
|
|
13
13
|
border-radius: var(--border-radius-36);
|
|
14
14
|
overflow: hidden;
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__closer_12dl2 {
|
|
16
16
|
position: absolute;
|
|
17
17
|
top: var(--gap-8);
|
|
18
|
-
right: var(--gap-8)
|
|
19
|
-
} .popup-
|
|
18
|
+
right: var(--gap-8);
|
|
19
|
+
} .popup-sheet__closer_12dl2 > button {
|
|
20
20
|
-webkit-backdrop-filter: none;
|
|
21
21
|
backdrop-filter: none;
|
|
22
|
-
} .popup-
|
|
22
|
+
} .popup-sheet__content_12dl2 {
|
|
23
23
|
box-sizing: border-box;
|
|
24
|
-
} .popup-
|
|
25
|
-
.popup-
|
|
24
|
+
} .popup-sheet__appear_12dl2,
|
|
25
|
+
.popup-sheet__enter_12dl2 {
|
|
26
26
|
transform: translateY(calc(100% + 100px));
|
|
27
|
-
} .popup-
|
|
28
|
-
.popup-
|
|
27
|
+
} .popup-sheet__appearActive_12dl2,
|
|
28
|
+
.popup-sheet__enterActive_12dl2 {
|
|
29
29
|
transform: translateY(0);
|
|
30
30
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
31
31
|
transition-delay: 50ms;
|
|
32
|
-
} .popup-
|
|
32
|
+
} .popup-sheet__exit_12dl2 {
|
|
33
33
|
transform: translateY(0);
|
|
34
|
-
} .popup-
|
|
34
|
+
} .popup-sheet__exitBySwipe_12dl2 {
|
|
35
35
|
transform: translateY(calc(100% + 100px));
|
|
36
|
-
} .popup-
|
|
36
|
+
} .popup-sheet__exitActiveBySwipe_12dl2 {
|
|
37
37
|
transition: none;
|
|
38
|
-
} .popup-
|
|
39
|
-
.popup-
|
|
38
|
+
} .popup-sheet__exitActive_12dl2,
|
|
39
|
+
.popup-sheet__exitDone_12dl2 {
|
|
40
40
|
transform: translateY(calc(100% + 100px));
|
|
41
41
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
42
42
|
}
|
package/index.module.css.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"component":"popup-
|
|
5
|
+
var styles = {"component":"popup-sheet__component_12dl2","closer":"popup-sheet__closer_12dl2","content":"popup-sheet__content_12dl2","appear":"popup-sheet__appear_12dl2","enter":"popup-sheet__enter_12dl2","appearActive":"popup-sheet__appearActive_12dl2","enterActive":"popup-sheet__enterActive_12dl2","exit":"popup-sheet__exit_12dl2","exitBySwipe":"popup-sheet__exitBySwipe_12dl2","exitActiveBySwipe":"popup-sheet__exitActiveBySwipe_12dl2","exitActive":"popup-sheet__exitActive_12dl2"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
package/index.module.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.component.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
package/modern/Component.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useState, useRef } from 'react';
|
|
2
|
+
import mergeRefs from 'react-merge-refs';
|
|
2
3
|
import { useSwipeable } from 'react-swipeable';
|
|
3
4
|
import cn from 'classnames';
|
|
4
5
|
import { BaseModal } from '@alfalab/core-components-base-modal/modern';
|
|
@@ -99,6 +100,8 @@ const PopupSheet = forwardRef(({ children, hasCloser, className, onClose, transi
|
|
|
99
100
|
trackTouch: swipeable,
|
|
100
101
|
delta: 5,
|
|
101
102
|
});
|
|
103
|
+
const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;
|
|
104
|
+
const componentRef = mergeRefs([sheetRef, swipeRef]);
|
|
102
105
|
return (React.createElement(BaseModal, { ...restProps, onClose: onClose, ref: ref, className: cn(styles.component, className), dataTestId: dataTestId, Backdrop: PopupBackdrop, backdropProps: {
|
|
103
106
|
...backdropProps,
|
|
104
107
|
opacity: backdropOpacity,
|
|
@@ -118,12 +121,12 @@ const PopupSheet = forwardRef(({ children, hasCloser, className, onClose, transi
|
|
|
118
121
|
onEntered: handleEntered,
|
|
119
122
|
onExited: handleExited,
|
|
120
123
|
}, componentDivProps: {
|
|
121
|
-
ref:
|
|
124
|
+
ref: componentRef,
|
|
122
125
|
style: getSwipeStyles(),
|
|
126
|
+
...(swipeable ? swipeHandlers : {}),
|
|
123
127
|
}, contentProps: {
|
|
124
128
|
style: createPaddingStyle(padding),
|
|
125
129
|
...contentProps,
|
|
126
|
-
...sheetSwipeableHandlers,
|
|
127
130
|
className: cn(styles.content, contentProps?.className),
|
|
128
131
|
} },
|
|
129
132
|
hasCloser && (React.createElement(Closer, { view: 'mobile', onClick: onClose, dataTestId: getDataTestId(dataTestId, 'closer'), ...closerProps, className: cn(styles.closer, closerProps?.className) })),
|
package/modern/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: sheetRef,\n style: getSwipeStyles(),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n ...sheetSwipeableHandlers,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,cAAc,GAAG,GAAG;AAC1B,MAAM,YAAY,GAAG,GAAG;AACxB,MAAM,kBAAkB,GAAG,GAAG;AAsC9B,MAAM,eAAe,GAAG,EAAE;AAEb,MAAA,UAAU,GAAG,UAAU,CAChC,CACI,EACI,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,eAAe,EACf,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,GAAG,eAAe,EACzB,WAAW,GAAG,EAAE,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;IACA,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEzD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,CAAC,MAAc,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC;IAEtE,MAAM,kBAAkB,GAAG,CAAC,MAAc,KACtC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC;IAEjD,MAAM,cAAc,GAAG,MACnB,WAAW,GAAG,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,WAAW,CAAK,GAAA,CAAA,EAAE,GAAG,EAAE;AAEpE,IAAA,MAAM,aAAa,GA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zB,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC;AACzD,SAAA,EAAA;AAEA,QAAA,SAAS,KACN,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACH,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC3C,GAAA,WAAW,EACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,GACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;\n const componentRef = mergeRefs([sheetRef, swipeRef]);\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: componentRef,\n style: getSwipeStyles(),\n ...(swipeable ? swipeHandlers : {}),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;;AAqBA,MAAM,cAAc,GAAG,GAAG;AAC1B,MAAM,YAAY,GAAG,GAAG;AACxB,MAAM,kBAAkB,GAAG,GAAG;AAsC9B,MAAM,eAAe,GAAG,EAAE;AAEb,MAAA,UAAU,GAAG,UAAU,CAChC,CACI,EACI,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,eAAe,EACf,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,GAAG,eAAe,EACzB,WAAW,GAAG,EAAE,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;IACA,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEzD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,CAAC,MAAc,KAAa,IAAI,CAAC,GAAG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,WAAW,GAAG,MAAM,CAAC,IAAI;gBACtE,UAAU,EAAE,qBAAqB,CAAC;sBAC5B,MAAM,CAAC;sBACP,MAAM,CAAC,UAAU;AAC1B,aAAA;AACD,YAAA,OAAO,EAAE,kBAAkB;AAC3B,YAAA,GAAG,eAAe;AAClB,YAAA,SAAS,EAAE,aAAa;AACxB,YAAA,QAAQ,EAAE,YAAY;AACzB,SAAA,EACD,iBAAiB,EAAE;AACf,YAAA,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,cAAc,EAAE;YACvB,IAAI,SAAS,GAAG,aAAa,GAAG,EAAE,CAAC;AACtC,SAAA,EACD,YAAY,EAAE;AACV,YAAA,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC;AAClC,YAAA,GAAG,YAAY;YACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC;AACzD,SAAA,EAAA;AAEA,QAAA,SAAS,KACN,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACH,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC3C,GAAA,WAAW,EACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,GACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
} :root {
|
|
4
4
|
--backdrop-visible-background: var(--color-light-overlay-default);
|
|
5
5
|
--backdrop-hidden-background: transparent;
|
|
6
|
-
} .popup-
|
|
7
|
-
.popup-
|
|
6
|
+
} .popup-sheet__appear_7036h,
|
|
7
|
+
.popup-sheet__enter_7036h {
|
|
8
8
|
background-color: var(--backdrop-hidden-background);
|
|
9
|
-
} .popup-
|
|
10
|
-
.popup-
|
|
11
|
-
.popup-
|
|
12
|
-
.popup-
|
|
9
|
+
} .popup-sheet__appearActive_7036h,
|
|
10
|
+
.popup-sheet__enterActive_7036h,
|
|
11
|
+
.popup-sheet__appearDone_7036h,
|
|
12
|
+
.popup-sheet__enterDone_7036h {
|
|
13
13
|
background-color: var(--backdrop-visible-background);
|
|
14
14
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__exit_7036h {
|
|
16
16
|
background-color: var(--backdrop-visible-background);
|
|
17
|
-
} .popup-
|
|
18
|
-
.popup-
|
|
17
|
+
} .popup-sheet__exitActive_7036h,
|
|
18
|
+
.popup-sheet__exitDone_7036h {
|
|
19
19
|
background-color: var(--backdrop-hidden-background);
|
|
20
20
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
const styles = {"appear":"popup-
|
|
3
|
+
const styles = {"appear":"popup-sheet__appear_7036h","enter":"popup-sheet__enter_7036h","appearActive":"popup-sheet__appearActive_7036h","enterActive":"popup-sheet__enterActive_7036h","appearDone":"popup-sheet__appearDone_7036h","enterDone":"popup-sheet__enterDone_7036h","exit":"popup-sheet__exit_7036h","exitActive":"popup-sheet__exitActive_7036h","exitDone":"popup-sheet__exitDone_7036h"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/backdrop/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n@import '../../../../backdrop/src/vars.css';\n\n.appear,\n.enter {\n background-color: var(--backdrop-hidden-background);\n}\n\n.appearActive,\n.enterActive,\n.appearDone,\n.enterDone {\n background-color: var(--backdrop-visible-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n\n.exit {\n background-color: var(--backdrop-visible-background);\n}\n\n.exitActive,\n.exitDone {\n background-color: var(--backdrop-hidden-background);\n transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,YAAY,CAAC,+BAA+B,CAAC,WAAW,CAAC,8BAA8B,CAAC,MAAM,CAAC,yBAAyB,CAAC,YAAY,CAAC,+BAA+B,CAAC,UAAU,CAAC,6BAA6B,CAAC;;;;"}
|
package/modern/index.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
--gap-xs: 8px;
|
|
5
5
|
--gap-0: 0px;
|
|
6
6
|
--gap-8: var(--gap-xs);
|
|
7
|
-
} .popup-
|
|
7
|
+
} .popup-sheet__component_12dl2.popup-sheet__component_12dl2 {
|
|
8
8
|
position: fixed;
|
|
9
9
|
bottom: var(--gap-0);
|
|
10
10
|
margin: auto var(--gap-8) var(--gap-8);
|
|
@@ -12,31 +12,31 @@
|
|
|
12
12
|
max-width: 600px;
|
|
13
13
|
border-radius: var(--border-radius-36);
|
|
14
14
|
overflow: hidden;
|
|
15
|
-
} .popup-
|
|
15
|
+
} .popup-sheet__closer_12dl2 {
|
|
16
16
|
position: absolute;
|
|
17
17
|
top: var(--gap-8);
|
|
18
|
-
right: var(--gap-8)
|
|
19
|
-
} .popup-
|
|
18
|
+
right: var(--gap-8);
|
|
19
|
+
} .popup-sheet__closer_12dl2 > button {
|
|
20
20
|
-webkit-backdrop-filter: none;
|
|
21
21
|
backdrop-filter: none;
|
|
22
|
-
} .popup-
|
|
22
|
+
} .popup-sheet__content_12dl2 {
|
|
23
23
|
box-sizing: border-box;
|
|
24
|
-
} .popup-
|
|
25
|
-
.popup-
|
|
24
|
+
} .popup-sheet__appear_12dl2,
|
|
25
|
+
.popup-sheet__enter_12dl2 {
|
|
26
26
|
transform: translateY(calc(100% + 100px));
|
|
27
|
-
} .popup-
|
|
28
|
-
.popup-
|
|
27
|
+
} .popup-sheet__appearActive_12dl2,
|
|
28
|
+
.popup-sheet__enterActive_12dl2 {
|
|
29
29
|
transform: translateY(0);
|
|
30
30
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
31
31
|
transition-delay: 50ms;
|
|
32
|
-
} .popup-
|
|
32
|
+
} .popup-sheet__exit_12dl2 {
|
|
33
33
|
transform: translateY(0);
|
|
34
|
-
} .popup-
|
|
34
|
+
} .popup-sheet__exitBySwipe_12dl2 {
|
|
35
35
|
transform: translateY(calc(100% + 100px));
|
|
36
|
-
} .popup-
|
|
36
|
+
} .popup-sheet__exitActiveBySwipe_12dl2 {
|
|
37
37
|
transition: none;
|
|
38
|
-
} .popup-
|
|
39
|
-
.popup-
|
|
38
|
+
} .popup-sheet__exitActive_12dl2,
|
|
39
|
+
.popup-sheet__exitDone_12dl2 {
|
|
40
40
|
transform: translateY(calc(100% + 100px));
|
|
41
41
|
transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
const styles = {"component":"popup-
|
|
3
|
+
const styles = {"component":"popup-sheet__component_12dl2","closer":"popup-sheet__closer_12dl2","content":"popup-sheet__content_12dl2","appear":"popup-sheet__appear_12dl2","enter":"popup-sheet__enter_12dl2","appearActive":"popup-sheet__appearActive_12dl2","enterActive":"popup-sheet__enterActive_12dl2","exit":"popup-sheet__exit_12dl2","exitBySwipe":"popup-sheet__exitBySwipe_12dl2","exitActiveBySwipe":"popup-sheet__exitActiveBySwipe_12dl2","exitActive":"popup-sheet__exitActive_12dl2"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.component.component {\n position: fixed;\n bottom: var(--gap-0);\n margin: auto var(--gap-8) var(--gap-8);\n width: calc(100% - 2 * var(--gap-8));\n max-width: 600px;\n border-radius: var(--border-radius-36);\n overflow: hidden;\n}\n\n.closer {\n position: absolute;\n top: var(--gap-8);\n right: var(--gap-8);\n\n & > button {\n backdrop-filter: none;\n }\n}\n\n.content {\n box-sizing: border-box;\n}\n\n/* 100px нужны для того, чтобы фон успевал немного затемниться перед тем, как начнет выезжать шторка */\n.appear,\n.enter {\n transform: translateY(calc(100% + 100px));\n}\n\n.appearActive,\n.enterActive {\n transform: translateY(0);\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n transition-delay: 50ms;\n}\n\n.exit {\n transform: translateY(0);\n}\n\n.exitBySwipe {\n transform: translateY(calc(100% + 100px));\n}\n\n.exitActiveBySwipe {\n transition: none;\n}\n\n.exitActive,\n.exitDone {\n transform: translateY(calc(100% + 100px));\n transition: transform 300ms cubic-bezier(0.65, 0, 0.35, 1);\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,WAAW,CAAC,8BAA8B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,2BAA2B,CAAC,OAAO,CAAC,0BAA0B,CAAC,cAAc,CAAC,iCAAiC,CAAC,aAAa,CAAC,gCAAgC,CAAC,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,sCAAsC,CAAC,YAAY,CAAC,+BAAwE,CAAC;;;;"}
|
package/moderncssm/Component.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useState, useRef } from 'react';
|
|
2
|
+
import mergeRefs from 'react-merge-refs';
|
|
2
3
|
import { useSwipeable } from 'react-swipeable';
|
|
3
4
|
import cn from 'classnames';
|
|
4
5
|
import { BaseModal } from '@alfalab/core-components-base-modal/moderncssm';
|
|
@@ -99,6 +100,8 @@ const PopupSheet = forwardRef(({ children, hasCloser, className, onClose, transi
|
|
|
99
100
|
trackTouch: swipeable,
|
|
100
101
|
delta: 5,
|
|
101
102
|
});
|
|
103
|
+
const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;
|
|
104
|
+
const componentRef = mergeRefs([sheetRef, swipeRef]);
|
|
102
105
|
return (React.createElement(BaseModal, { ...restProps, onClose: onClose, ref: ref, className: cn(styles.component, className), dataTestId: dataTestId, Backdrop: PopupBackdrop, backdropProps: {
|
|
103
106
|
...backdropProps,
|
|
104
107
|
opacity: backdropOpacity,
|
|
@@ -118,12 +121,12 @@ const PopupSheet = forwardRef(({ children, hasCloser, className, onClose, transi
|
|
|
118
121
|
onEntered: handleEntered,
|
|
119
122
|
onExited: handleExited,
|
|
120
123
|
}, componentDivProps: {
|
|
121
|
-
ref:
|
|
124
|
+
ref: componentRef,
|
|
122
125
|
style: getSwipeStyles(),
|
|
126
|
+
...(swipeable ? swipeHandlers : {}),
|
|
123
127
|
}, contentProps: {
|
|
124
128
|
style: createPaddingStyle(padding),
|
|
125
129
|
...contentProps,
|
|
126
|
-
...sheetSwipeableHandlers,
|
|
127
130
|
className: cn(styles.content, contentProps?.className),
|
|
128
131
|
} },
|
|
129
132
|
hasCloser && (React.createElement(Closer, { view: 'mobile', onClick: onClose, dataTestId: getDataTestId(dataTestId, 'closer'), ...closerProps, className: cn(styles.closer, closerProps?.className) })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: sheetRef,\n style: getSwipeStyles(),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n ...sheetSwipeableHandlers,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,cAAc,GAAG,GAAG;AAC1B,MAAM,YAAY,GAAG,GAAG;AACxB,MAAM,kBAAkB,GAAG,GAAG;AAsC9B,MAAM,eAAe,GAAG,EAAE;AAEb,MAAA,UAAU,GAAG,UAAU,CAChC,CACI,EACI,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,eAAe,EACf,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,GAAG,eAAe,EACzB,WAAW,GAAG,EAAE,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;IACA,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEzD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,CAAC,MAAc,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC;IAEtE,MAAM,kBAAkB,GAAG,CAAC,MAAc,KACtC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC;IAEjD,MAAM,cAAc,GAAG,MACnB,WAAW,GAAG,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,WAAW,CAAK,GAAA,CAAA,EAAE,GAAG,EAAE;AA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f,YAAA,GAAG,sBAAsB;YACzB,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC;AACzD,SAAA,EAAA;AAEA,QAAA,SAAS,KACN,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACH,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC3C,GAAA,WAAW,EACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,GACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEvent,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport { SwipeCallback, useSwipeable } from 'react-swipeable';\nimport cn from 'classnames';\n\nimport { BaseModal, BaseModalProps } from '@alfalab/core-components-base-modal';\nimport { Closer, CloserProps } from '@alfalab/core-components-navigation-bar-private/shared';\nimport { createPaddingStyle, easingFns, getDataTestId } from '@alfalab/core-components-shared';\nimport type { PaddingType } from '@alfalab/core-components-types';\n\nimport { PopupBackdrop } from './components/backdrop';\n\nimport styles from './index.module.css';\n\nconst SWIPE_VELOCITY = 0.3;\nconst CLOSE_OFFSET = 0.3;\nconst ANIMATION_DURATION = 350;\n\nexport type PopupSheetProps = Omit<BaseModalProps, 'onClose' | 'dataTestId'> & {\n /**\n * Наличие кнопки закрытия\n */\n hasCloser?: boolean;\n\n /**\n * Будет ли свайпаться шторка\n */\n swipeable?: boolean;\n\n /**\n * Отступы\n */\n padding?: PaddingType;\n\n /**\n * Обработчик закрытия\n */\n onClose?: (\n event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,\n reason?: 'backdropClick' | 'escapeKeyDown' | 'closerClick' | 'swipe',\n ) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования.\n * Для кнопки закрытия используется модификатор -closer\n */\n dataTestId?: string;\n\n /**\n * Дополнительные пропсы для компонента Closer.\n */\n closerProps?: Omit<CloserProps, 'view' | 'onClose'>;\n};\n\nconst DEFAULT_PADDING = 32;\n\nexport const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(\n (\n {\n children,\n hasCloser,\n className,\n onClose,\n transitionProps,\n contentProps,\n swipeable,\n dataTestId,\n backdropProps,\n padding = DEFAULT_PADDING,\n closerProps = {},\n ...restProps\n },\n ref,\n ) => {\n const [sheetOffset, setSheetOffset] = useState(0);\n const [backdropOpacity, setBackdropOpacity] = useState(1);\n\n const sheetHeight = useRef(0);\n const sheetRef = useRef<HTMLDivElement>(null);\n const bySwipeCloseAnimation = useRef(false);\n\n const getSheetOffset = (deltaY: number): number => Math.max(0, deltaY);\n\n const getBackdropOpacity = (offset: number): number =>\n Math.max(0, 1 - offset / sheetHeight.current);\n\n const getSwipeStyles = (): CSSProperties =>\n sheetOffset ? { transform: `translateY(${sheetOffset}px)` } : {};\n\n const handleSwiping: SwipeCallback = ({ deltaY }) => {\n const offset = getSheetOffset(deltaY);\n\n setSheetOffset(offset);\n setBackdropOpacity(getBackdropOpacity(offset));\n };\n\n const handleSwiped: SwipeCallback = ({ deltaY, velocity, event }) => {\n const shouldCloseByVelocity = deltaY >= 0 && velocity >= SWIPE_VELOCITY;\n const shouldCloseByOffset = deltaY >= sheetHeight.current * CLOSE_OFFSET;\n\n const offset = sheetOffset;\n const animDuration = ANIMATION_DURATION / 2;\n let start: number;\n\n if (shouldCloseByVelocity || shouldCloseByOffset) {\n bySwipeCloseAnimation.current = true;\n onClose?.(event as MouseEvent<HTMLElement>, 'swipe');\n\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset +\n (sheetHeight.current - offset) *\n easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n bySwipeCloseAnimation.current = false;\n }\n };\n\n requestAnimationFrame(runLoop);\n } else {\n const runLoop = (timeStamp: number) => {\n if (!start) start = timeStamp;\n const elapsedTime = timeStamp - start;\n\n if (elapsedTime <= animDuration) {\n const nextOffset =\n offset - offset * easingFns.easeInOutQuad(elapsedTime / animDuration);\n\n if (nextOffset > 0) {\n setSheetOffset(nextOffset);\n setBackdropOpacity(getBackdropOpacity(nextOffset));\n }\n requestAnimationFrame(runLoop);\n } else {\n setSheetOffset(0);\n setBackdropOpacity(1);\n }\n };\n\n requestAnimationFrame(runLoop);\n }\n };\n\n const handleEntered = (node: HTMLElement, isAppearing: boolean) => {\n bySwipeCloseAnimation.current = false;\n if (sheetRef.current) {\n sheetHeight.current = sheetRef.current.offsetHeight;\n }\n\n if (transitionProps?.onEntered) {\n transitionProps.onEntered(node, isAppearing);\n }\n };\n\n const handleExited = (node: HTMLElement) => {\n bySwipeCloseAnimation.current = false;\n setSheetOffset(0);\n setBackdropOpacity(1);\n\n if (transitionProps?.onExited) {\n transitionProps.onExited(node);\n }\n };\n\n const sheetSwipeableHandlers = useSwipeable({\n onSwiping: handleSwiping,\n onSwiped: handleSwiped,\n trackMouse: swipeable,\n trackTouch: swipeable,\n delta: 5,\n });\n\n const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;\n const componentRef = mergeRefs([sheetRef, swipeRef]);\n\n return (\n <BaseModal\n {...restProps}\n onClose={onClose}\n ref={ref}\n className={cn(styles.component, className)}\n dataTestId={dataTestId}\n Backdrop={PopupBackdrop}\n backdropProps={{\n ...backdropProps,\n opacity: backdropOpacity,\n }}\n transitionProps={{\n classNames: {\n enter: styles.enter,\n appear: styles.appear,\n enterActive: styles.enterActive,\n appearActive: styles.appearActive,\n exit: bySwipeCloseAnimation.current ? styles.exitBySwipe : styles.exit,\n exitActive: bySwipeCloseAnimation.current\n ? styles.exitActiveBySwipe\n : styles.exitActive,\n },\n timeout: ANIMATION_DURATION,\n ...transitionProps,\n onEntered: handleEntered,\n onExited: handleExited,\n }}\n componentDivProps={{\n ref: componentRef,\n style: getSwipeStyles(),\n ...(swipeable ? swipeHandlers : {}),\n }}\n contentProps={{\n style: createPaddingStyle(padding),\n ...contentProps,\n className: cn(styles.content, contentProps?.className),\n }}\n >\n {hasCloser && (\n <Closer\n view='mobile'\n onClick={onClose}\n dataTestId={getDataTestId(dataTestId, 'closer')}\n {...closerProps}\n className={cn(styles.closer, closerProps?.className)}\n />\n )}\n {children}\n </BaseModal>\n );\n },\n);\n\nPopupSheet.displayName = 'PopupSheet';\n"],"names":[],"mappings":";;;;;;;;;;AAqBA,MAAM,cAAc,GAAG,GAAG;AAC1B,MAAM,YAAY,GAAG,GAAG;AACxB,MAAM,kBAAkB,GAAG,GAAG;AAsC9B,MAAM,eAAe,GAAG,EAAE;AAEb,MAAA,UAAU,GAAG,UAAU,CAChC,CACI,EACI,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,eAAe,EACf,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,GAAG,eAAe,EACzB,WAAW,GAAG,EAAE,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;IACA,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEzD,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,cAAc,GAAG,CAAC,MAA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C,OAAO,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI;gBACtE,UAAU,EAAE,qBAAqB,CAAC;sBAC5B,MAAM,CAAC;sBACP,MAAM,CAAC,UAAU;AAC1B,aAAA;AACD,YAAA,OAAO,EAAE,kBAAkB;AAC3B,YAAA,GAAG,eAAe;AAClB,YAAA,SAAS,EAAE,aAAa;AACxB,YAAA,QAAQ,EAAE,YAAY;AACzB,SAAA,EACD,iBAAiB,EAAE;AACf,YAAA,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,cAAc,EAAE;YACvB,IAAI,SAAS,GAAG,aAAa,GAAG,EAAE,CAAC;AACtC,SAAA,EACD,YAAY,EAAE;AACV,YAAA,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC;AAClC,YAAA,GAAG,YAAY;YACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC;AACzD,SAAA,EAAA;AAEA,QAAA,SAAS,KACN,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACH,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC3C,GAAA,WAAW,EACf,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,GACtD,CACL;QACA,QAAQ,CACD;AAEpB,CAAC;AAGL,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
:root {
|
|
2
4
|
--backdrop-visible-background: var(--color-light-overlay-default);
|
|
3
5
|
--backdrop-hidden-background: transparent;
|
|
4
6
|
}
|
|
7
|
+
|
|
5
8
|
.appear,
|
|
6
9
|
.enter {
|
|
7
10
|
background-color: var(--backdrop-hidden-background);
|
|
8
11
|
}
|
|
12
|
+
|
|
9
13
|
.appearActive,
|
|
10
14
|
.enterActive,
|
|
11
15
|
.appearDone,
|
|
@@ -13,9 +17,11 @@
|
|
|
13
17
|
background-color: var(--backdrop-visible-background);
|
|
14
18
|
transition: background-color 300ms cubic-bezier(0.65, 0, 0.35, 1);
|
|
15
19
|
}
|
|
20
|
+
|
|
16
21
|
.exit {
|
|
17
22
|
background-color: var(--backdrop-visible-background);
|
|
18
23
|
}
|
|
24
|
+
|
|
19
25
|
.exitActive,
|
|
20
26
|
.exitDone {
|
|
21
27
|
background-color: var(--backdrop-hidden-background);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
.component.component {
|
|
2
4
|
position: fixed;
|
|
3
5
|
bottom: var(--gap-0);
|
|
4
6
|
margin: auto var(--gap-8) var(--gap-8);
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
.closer {
|
|
12
14
|
position: absolute;
|
|
13
15
|
top: var(--gap-8);
|
|
14
|
-
right: var(--gap-8)
|
|
16
|
+
right: var(--gap-8);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.closer > button {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-popup-sheet",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Popup sheet mobile component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@alfalab/core-components-types": "^1.0.0",
|
|
18
18
|
"classnames": "^2.5.1",
|
|
19
19
|
"react-swipeable": "^7.0.0",
|
|
20
|
+
"react-merge-refs": "^1.1.0",
|
|
20
21
|
"tslib": "^2.4.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
@@ -27,6 +28,6 @@
|
|
|
27
28
|
"access": "public",
|
|
28
29
|
"directory": "dist"
|
|
29
30
|
},
|
|
30
|
-
"themesVersion": "14.1.
|
|
31
|
+
"themesVersion": "14.1.2",
|
|
31
32
|
"varsVersion": "10.1.0"
|
|
32
33
|
}
|
package/src/Component.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import React, {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
8
|
} from 'react';
|
|
9
|
+
import mergeRefs from 'react-merge-refs';
|
|
9
10
|
import { SwipeCallback, useSwipeable } from 'react-swipeable';
|
|
10
11
|
import cn from 'classnames';
|
|
11
12
|
|
|
@@ -186,6 +187,9 @@ export const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(
|
|
|
186
187
|
delta: 5,
|
|
187
188
|
});
|
|
188
189
|
|
|
190
|
+
const { ref: swipeRef, ...swipeHandlers } = sheetSwipeableHandlers;
|
|
191
|
+
const componentRef = mergeRefs([sheetRef, swipeRef]);
|
|
192
|
+
|
|
189
193
|
return (
|
|
190
194
|
<BaseModal
|
|
191
195
|
{...restProps}
|
|
@@ -215,13 +219,13 @@ export const PopupSheet = forwardRef<HTMLDivElement, PopupSheetProps>(
|
|
|
215
219
|
onExited: handleExited,
|
|
216
220
|
}}
|
|
217
221
|
componentDivProps={{
|
|
218
|
-
ref:
|
|
222
|
+
ref: componentRef,
|
|
219
223
|
style: getSwipeStyles(),
|
|
224
|
+
...(swipeable ? swipeHandlers : {}),
|
|
220
225
|
}}
|
|
221
226
|
contentProps={{
|
|
222
227
|
style: createPaddingStyle(padding),
|
|
223
228
|
...contentProps,
|
|
224
|
-
...sheetSwipeableHandlers,
|
|
225
229
|
className: cn(styles.content, contentProps?.className),
|
|
226
230
|
}}
|
|
227
231
|
>
|
package/src/index.module.css
CHANGED