@cloud-ru/ds-bottom-sheet 1.0.3-preview-fe0a44cc.0 → 1.0.3-preview-848e7fc1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,17 +18,6 @@ const helperComponents_1 = require("../../helperComponents");
18
18
  const constants_2 = require("./constants");
19
19
  const hooks_1 = require("./hooks");
20
20
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
21
- /** Резолв portal-target'а. Вызывается после `isMounted=true` (браузер), `document` доступен. */
22
- function resolveContainer(container, portalContextNode) {
23
- if (typeof container === 'string') {
24
- // eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi -- guarded by isMounted (browser only)
25
- return document.querySelector(container);
26
- }
27
- if (container instanceof HTMLElement)
28
- return container;
29
- // eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi -- guarded by isMounted (browser only)
30
- return portalContextNode ?? document.body;
31
- }
32
21
  /**
33
22
  * Низкоуровневая обёртка bottom-sheet'а: portal + backdrop + slide-up motion + focus-trap +
34
23
  * Pointer-Events swipe / snap-engine. Готовая анатомия — `BottomSheet`.
@@ -106,14 +95,14 @@ function BottomSheetCustom(props) {
106
95
  const densityClassName = (0, theme_1.useThemeClassnames)({ density: 'comfort' });
107
96
  if (!isMounted)
108
97
  return null;
109
- const targetNode = resolveContainer(container, portalContextRef.current);
98
+ const targetNode = (0, portal_context_1.resolvePortalContainer)(container, portalContextRef.current);
110
99
  if (!targetNode)
111
100
  return null;
112
101
  const supportProps = (0, utils_1.extractSupportProps)(rest);
113
102
  return (0, react_dom_1.createPortal)(
114
103
  // RemoveScroll лочит фон-скролл (refcount для вложенных sheet'ов); `enabled={lockScroll}` —
115
104
  // для non-modal фон остаётся прокручиваемым.
116
- (0, jsx_runtime_1.jsx)(react_remove_scroll_1.RemoveScroll, { enabled: lockScroll, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.root, rootClassName), "data-active": isActive || undefined, "data-disable-motions": disableMotions || undefined, children: [showBackdrop && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.backdrop, "data-test-id": constants_1.TEST_IDS.backdrop, onClick: handleBackdropClick, "aria-hidden": true })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentWrapper, "data-active": isActive || undefined, "data-full-height": isFullHeight || undefined, children: (0, jsx_runtime_1.jsxs)("div", { ref: mergeRefCb, className: (0, classnames_1.default)(styles_module_scss_1.default.content, densityClassName, className), role: 'dialog', "aria-modal": isModal ? 'true' : undefined, "data-test-id": constants_1.TEST_IDS.root, "data-safe-area": safeArea || undefined, "data-snap-index": activeSnapIndex, "data-snap-points": snapPoints && snapPoints.length > 0 ? snapPoints.length : undefined, "data-swipe-enabled": swipeEnabled || undefined, "data-dragging": isDragging || undefined, "data-full-height": isFullHeight || undefined, ...supportProps, ...(swipeEnabled ? dragHandlers : {}), children: [swipeEnabled && (0, jsx_runtime_1.jsx)(helperComponents_1.Handle, {}), (0, jsx_runtime_1.jsx)(popup_private_1.OverlaySurfaceProvider, { surface: popup_private_1.OVERLAY_SURFACE.Sheet, children: children })] }) })] }) }), targetNode);
105
+ (0, jsx_runtime_1.jsx)(react_remove_scroll_1.RemoveScroll, { enabled: lockScroll, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.root, portal_context_1.PORTAL_ROOT_CLASS_NAME, rootClassName), "data-active": isActive || undefined, "data-disable-motions": disableMotions || undefined, children: [showBackdrop && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.backdrop, "data-test-id": constants_1.TEST_IDS.backdrop, onClick: handleBackdropClick, "aria-hidden": true })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentWrapper, "data-active": isActive || undefined, "data-full-height": isFullHeight || undefined, children: (0, jsx_runtime_1.jsxs)("div", { ref: mergeRefCb, className: (0, classnames_1.default)(styles_module_scss_1.default.content, densityClassName, className), role: 'dialog', "aria-modal": isModal ? 'true' : undefined, "data-test-id": constants_1.TEST_IDS.root, "data-safe-area": safeArea || undefined, "data-snap-index": activeSnapIndex, "data-snap-points": snapPoints && snapPoints.length > 0 ? snapPoints.length : undefined, "data-swipe-enabled": swipeEnabled || undefined, "data-dragging": isDragging || undefined, "data-full-height": isFullHeight || undefined, ...supportProps, ...(swipeEnabled ? dragHandlers : {}), children: [swipeEnabled && (0, jsx_runtime_1.jsx)(helperComponents_1.Handle, {}), (0, jsx_runtime_1.jsx)(popup_private_1.OverlaySurfaceProvider, { surface: popup_private_1.OVERLAY_SURFACE.Sheet, children: children })] }) })] }) }), targetNode);
117
106
  }
118
107
  BottomSheetCustom.Header = popup_private_1.PopupHeader;
119
108
  BottomSheetCustom.Body = popup_private_1.PopupBody;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { OVERLAY_SURFACE, OverlaySurfaceProvider, PopupBody, PopupFooter, PopupHeader, PopupMedia, } from '@cloud-ru/ds-popup-private';
3
- import { usePortalContext } from '@cloud-ru/ds-portal-context';
3
+ import { PORTAL_ROOT_CLASS_NAME, resolvePortalContainer, usePortalContext } from '@cloud-ru/ds-portal-context';
4
4
  import { useThemeClassnames } from '@cloud-ru/ds-theme';
5
5
  import { extractSupportProps, isBrowser, useLayoutEffect, useModalOpenState } from '@cloud-ru/ds-utils';
6
6
  import cn from 'classnames';
@@ -12,17 +12,6 @@ import { Handle } from '../../helperComponents/index.js';
12
12
  import { CLOSING_TIMEOUT } from './constants.js';
13
13
  import { useDragEngine, useFocusTrap, useTransitionPhase } from './hooks/index.js';
14
14
  import styles from './styles.module.css';
15
- /** Резолв portal-target'а. Вызывается после `isMounted=true` (браузер), `document` доступен. */
16
- function resolveContainer(container, portalContextNode) {
17
- if (typeof container === 'string') {
18
- // eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi -- guarded by isMounted (browser only)
19
- return document.querySelector(container);
20
- }
21
- if (container instanceof HTMLElement)
22
- return container;
23
- // eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi -- guarded by isMounted (browser only)
24
- return portalContextNode ?? document.body;
25
- }
26
15
  /**
27
16
  * Низкоуровневая обёртка bottom-sheet'а: portal + backdrop + slide-up motion + focus-trap +
28
17
  * Pointer-Events swipe / snap-engine. Готовая анатомия — `BottomSheet`.
@@ -100,14 +89,14 @@ export function BottomSheetCustom(props) {
100
89
  const densityClassName = useThemeClassnames({ density: 'comfort' });
101
90
  if (!isMounted)
102
91
  return null;
103
- const targetNode = resolveContainer(container, portalContextRef.current);
92
+ const targetNode = resolvePortalContainer(container, portalContextRef.current);
104
93
  if (!targetNode)
105
94
  return null;
106
95
  const supportProps = extractSupportProps(rest);
107
96
  return createPortal(
108
97
  // RemoveScroll лочит фон-скролл (refcount для вложенных sheet'ов); `enabled={lockScroll}` —
109
98
  // для non-modal фон остаётся прокручиваемым.
110
- _jsx(RemoveScroll, { enabled: lockScroll, children: _jsxs("div", { className: cn(styles.root, rootClassName), "data-active": isActive || undefined, "data-disable-motions": disableMotions || undefined, children: [showBackdrop && (_jsx("div", { className: styles.backdrop, "data-test-id": TEST_IDS.backdrop, onClick: handleBackdropClick, "aria-hidden": true })), _jsx("div", { className: styles.contentWrapper, "data-active": isActive || undefined, "data-full-height": isFullHeight || undefined, children: _jsxs("div", { ref: mergeRefCb, className: cn(styles.content, densityClassName, className), role: 'dialog', "aria-modal": isModal ? 'true' : undefined, "data-test-id": TEST_IDS.root, "data-safe-area": safeArea || undefined, "data-snap-index": activeSnapIndex, "data-snap-points": snapPoints && snapPoints.length > 0 ? snapPoints.length : undefined, "data-swipe-enabled": swipeEnabled || undefined, "data-dragging": isDragging || undefined, "data-full-height": isFullHeight || undefined, ...supportProps, ...(swipeEnabled ? dragHandlers : {}), children: [swipeEnabled && _jsx(Handle, {}), _jsx(OverlaySurfaceProvider, { surface: OVERLAY_SURFACE.Sheet, children: children })] }) })] }) }), targetNode);
99
+ _jsx(RemoveScroll, { enabled: lockScroll, children: _jsxs("div", { className: cn(styles.root, PORTAL_ROOT_CLASS_NAME, rootClassName), "data-active": isActive || undefined, "data-disable-motions": disableMotions || undefined, children: [showBackdrop && (_jsx("div", { className: styles.backdrop, "data-test-id": TEST_IDS.backdrop, onClick: handleBackdropClick, "aria-hidden": true })), _jsx("div", { className: styles.contentWrapper, "data-active": isActive || undefined, "data-full-height": isFullHeight || undefined, children: _jsxs("div", { ref: mergeRefCb, className: cn(styles.content, densityClassName, className), role: 'dialog', "aria-modal": isModal ? 'true' : undefined, "data-test-id": TEST_IDS.root, "data-safe-area": safeArea || undefined, "data-snap-index": activeSnapIndex, "data-snap-points": snapPoints && snapPoints.length > 0 ? snapPoints.length : undefined, "data-swipe-enabled": swipeEnabled || undefined, "data-dragging": isDragging || undefined, "data-full-height": isFullHeight || undefined, ...supportProps, ...(swipeEnabled ? dragHandlers : {}), children: [swipeEnabled && _jsx(Handle, {}), _jsx(OverlaySurfaceProvider, { surface: OVERLAY_SURFACE.Sheet, children: children })] }) })] }) }), targetNode);
111
100
  }
112
101
  BottomSheetCustom.Header = PopupHeader;
113
102
  BottomSheetCustom.Body = PopupBody;