@hh.ru/magritte-ui-drop 7.0.0 → 7.0.1
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/Drop.js +9 -4
- package/Drop.js.map +1 -1
- package/DropContainer-B2XMpR_h.js +58 -0
- package/DropContainer-B2XMpR_h.js.map +1 -0
- package/DropContainer.d.ts +5 -3
- package/DropContainer.js +2 -1
- package/DropContainer.js.map +1 -1
- package/index.css +37 -37
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/DropContainer-Y4wrsbBC.js +0 -55
- package/DropContainer-Y4wrsbBC.js.map +0 -1
package/Drop.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import { forwardRef, useState, useRef, useMemo, useEffect } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { DropBase } from '@hh.ru/magritte-internal-drop-base';
|
|
6
6
|
import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
|
|
7
7
|
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
8
|
-
import { s as styles, D as DropContainer } from './DropContainer-
|
|
8
|
+
import { s as styles, D as DropContainer } from './DropContainer-B2XMpR_h.js';
|
|
9
9
|
import { PureChildren } from './PureChildren.js';
|
|
10
10
|
import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
11
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
11
12
|
import '@hh.ru/magritte-ui-divider';
|
|
12
13
|
|
|
13
14
|
const PLACEMENTS_LIST = [
|
|
@@ -23,6 +24,7 @@ const PLACEMENTS_LIST = [
|
|
|
23
24
|
const DropComponent = ({ visible, activatorRef, onClose, maxWidth = 320, minHeight = 200, space = 600, children, footer, role = 'dialog', dividerState = 'show', widthEqualToActivator = false, allowShrinkHeightToFitIntoViewport = true, autoFocusWhenOpened, closeByClickOutside = true, 'data-qa': dataQA = 'drop', onAppear, onBeforeExit, onAfterExit, placement, forcePlacement, ...props }, ref) => {
|
|
24
25
|
const { isMobile } = useBreakpoint();
|
|
25
26
|
const [animationTimeout, setAnimationTimeout] = useState(200);
|
|
27
|
+
const forceUpdateDropMetricsRef = useRef();
|
|
26
28
|
const placementsList = useMemo(() => {
|
|
27
29
|
const placementsArray = Array.isArray(placement) ? placement : [placement];
|
|
28
30
|
return (forcePlacement
|
|
@@ -40,6 +42,9 @@ const DropComponent = ({ visible, activatorRef, onClose, maxWidth = 320, minHeig
|
|
|
40
42
|
}
|
|
41
43
|
document.body.removeChild(animationTimeoutElement);
|
|
42
44
|
}, []);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
forceUpdateDropMetricsRef.current?.();
|
|
47
|
+
}, [maxWidth, space, footer]);
|
|
43
48
|
if (isMobile) {
|
|
44
49
|
return null;
|
|
45
50
|
}
|
|
@@ -48,12 +53,12 @@ const DropComponent = ({ visible, activatorRef, onClose, maxWidth = 320, minHeig
|
|
|
48
53
|
enterActive: styles.dropEnterActive,
|
|
49
54
|
exit: styles.dropExit,
|
|
50
55
|
exitActive: styles.dropExitActive,
|
|
51
|
-
}, animationTimeout: animationTimeout, widthEqualToActivator: widthEqualToActivator, allowShrinkHeightToFitIntoViewport: allowShrinkHeightToFitIntoViewport, minHeight: minHeight, ref: ref, onAppear: onAppear, onBeforeExit: onBeforeExit, onAfterExit: onAfterExit, children: (resizeRefCallbackFactory) => (jsxs("div", { className: classnames(styles.drop, {
|
|
56
|
+
}, animationTimeout: animationTimeout, widthEqualToActivator: widthEqualToActivator, allowShrinkHeightToFitIntoViewport: allowShrinkHeightToFitIntoViewport, minHeight: minHeight, ref: ref, onAppear: onAppear, onBeforeExit: onBeforeExit, onAfterExit: onAfterExit, forceDropMetricsUpdate: forceUpdateDropMetricsRef, children: (resizeRefCallbackFactory) => (jsxs("div", { className: classnames(styles.drop, {
|
|
52
57
|
[styles.dropSpace300]: space === 300,
|
|
53
58
|
[styles.dropSpace400]: space === 400,
|
|
54
59
|
[styles.dropSpace600]: space === 600,
|
|
55
60
|
[styles.dropWithFooter]: !!footer,
|
|
56
|
-
}), style: { maxWidth }, "data-qa": dataQA,
|
|
61
|
+
}), style: widthEqualToActivator ? { width: '100%' } : { maxWidth }, "data-qa": dataQA, children: [jsx(DropContainer, { dividerState: !footer ? 'hide' : dividerState, ref: resizeRefCallbackFactory('scroll-container', false, true), children: jsx("div", { ref: resizeRefCallbackFactory('drop-content'), children: jsx(PureChildren, { children: children }) }) }, "drop-container"), footer && (jsx("div", { ref: resizeRefCallbackFactory('drop-footer'), className: styles.dropFooter, children: jsx(PureChildren, { children: footer }) }))] }, "drop-outer-container")) }) }));
|
|
57
62
|
};
|
|
58
63
|
const Drop = forwardRef(DropComponent);
|
|
59
64
|
|
package/Drop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drop.js","sources":["../src/Drop.tsx"],"sourcesContent":["import { useMemo, useEffect, useState, type ReactElement, ForwardedRef, forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { DropBase, type Placement } from '@hh.ru/magritte-internal-drop-base';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { DropContainer } from '@hh.ru/magritte-ui-drop/DropContainer';\nimport { PureChildren } from '@hh.ru/magritte-ui-drop/PureChildren';\nimport type { DropProps, DropPlacement } from '@hh.ru/magritte-ui-drop/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\n\nimport styles from './drop.less';\n\nconst PLACEMENTS_LIST: Placement[] = [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n];\n\nconst DropComponent = (\n {\n visible,\n activatorRef,\n onClose,\n maxWidth = 320,\n minHeight = 200,\n space = 600,\n children,\n footer,\n role = 'dialog',\n dividerState = 'show',\n widthEqualToActivator = false,\n allowShrinkHeightToFitIntoViewport = true,\n autoFocusWhenOpened,\n closeByClickOutside = true,\n 'data-qa': dataQA = 'drop',\n onAppear,\n onBeforeExit,\n onAfterExit,\n placement,\n forcePlacement,\n ...props\n }: DropProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement | null => {\n const { isMobile } = useBreakpoint();\n const [animationTimeout, setAnimationTimeout] = useState(200);\n\n const placementsList = useMemo(() => {\n const placementsArray: DropPlacement[] = Array.isArray(placement) ? placement : [placement];\n return (\n forcePlacement\n ? placementsArray\n : [...placementsArray, ...PLACEMENTS_LIST.filter((place) => !placement.includes(place))]\n ) as Placement[];\n }, [placement, forcePlacement]);\n\n useEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.dropAnimationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n document.body.removeChild(animationTimeoutElement);\n }, []);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <Layer layer={InternalLayerName.Drop}>\n <DropBase\n {...props}\n visible={visible}\n placement={placementsList}\n activatorRef={activatorRef}\n closeByClickOutside={closeByClickOutside}\n onClose={onClose}\n autoFocusWhenOpened={autoFocusWhenOpened ?? role !== 'status'}\n animationClassNames={{\n enter: styles.dropEnter,\n enterActive: styles.dropEnterActive,\n exit: styles.dropExit,\n exitActive: styles.dropExitActive,\n }}\n animationTimeout={animationTimeout}\n widthEqualToActivator={widthEqualToActivator}\n allowShrinkHeightToFitIntoViewport={allowShrinkHeightToFitIntoViewport}\n minHeight={minHeight}\n ref={ref}\n onAppear={onAppear}\n onBeforeExit={onBeforeExit}\n onAfterExit={onAfterExit}\n >\n {(resizeRefCallbackFactory) => (\n <div\n className={classnames(styles.drop, {\n [styles.dropSpace300]: space === 300,\n [styles.dropSpace400]: space === 400,\n [styles.dropSpace600]: space === 600,\n [styles.dropWithFooter]: !!footer,\n })}\n style={{ maxWidth }}\n data-qa={dataQA}\n
|
|
1
|
+
{"version":3,"file":"Drop.js","sources":["../src/Drop.tsx"],"sourcesContent":["import { useMemo, useEffect, useState, type ReactElement, ForwardedRef, forwardRef, useRef, RefObject } from 'react';\nimport classnames from 'classnames';\n\nimport { DropBase, type Placement } from '@hh.ru/magritte-internal-drop-base';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { DropContainer } from '@hh.ru/magritte-ui-drop/DropContainer';\nimport { PureChildren } from '@hh.ru/magritte-ui-drop/PureChildren';\nimport type { DropProps, DropPlacement } from '@hh.ru/magritte-ui-drop/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\n\nimport styles from './drop.less';\n\nconst PLACEMENTS_LIST: Placement[] = [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n];\n\nconst DropComponent = (\n {\n visible,\n activatorRef,\n onClose,\n maxWidth = 320,\n minHeight = 200,\n space = 600,\n children,\n footer,\n role = 'dialog',\n dividerState = 'show',\n widthEqualToActivator = false,\n allowShrinkHeightToFitIntoViewport = true,\n autoFocusWhenOpened,\n closeByClickOutside = true,\n 'data-qa': dataQA = 'drop',\n onAppear,\n onBeforeExit,\n onAfterExit,\n placement,\n forcePlacement,\n ...props\n }: DropProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement | null => {\n const { isMobile } = useBreakpoint();\n const [animationTimeout, setAnimationTimeout] = useState(200);\n const forceUpdateDropMetricsRef = useRef<VoidFunction>();\n\n const placementsList = useMemo(() => {\n const placementsArray: DropPlacement[] = Array.isArray(placement) ? placement : [placement];\n return (\n forcePlacement\n ? placementsArray\n : [...placementsArray, ...PLACEMENTS_LIST.filter((place) => !placement.includes(place))]\n ) as Placement[];\n }, [placement, forcePlacement]);\n\n useEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.dropAnimationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n document.body.removeChild(animationTimeoutElement);\n }, []);\n\n useEffect(() => {\n forceUpdateDropMetricsRef.current?.();\n }, [maxWidth, space, footer]);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <Layer layer={InternalLayerName.Drop}>\n <DropBase\n {...props}\n visible={visible}\n placement={placementsList}\n activatorRef={activatorRef}\n closeByClickOutside={closeByClickOutside}\n onClose={onClose}\n autoFocusWhenOpened={autoFocusWhenOpened ?? role !== 'status'}\n animationClassNames={{\n enter: styles.dropEnter,\n enterActive: styles.dropEnterActive,\n exit: styles.dropExit,\n exitActive: styles.dropExitActive,\n }}\n animationTimeout={animationTimeout}\n widthEqualToActivator={widthEqualToActivator}\n allowShrinkHeightToFitIntoViewport={allowShrinkHeightToFitIntoViewport}\n minHeight={minHeight}\n ref={ref}\n onAppear={onAppear}\n onBeforeExit={onBeforeExit}\n onAfterExit={onAfterExit}\n forceDropMetricsUpdate={forceUpdateDropMetricsRef as RefObject<VoidFunction>}\n >\n {(resizeRefCallbackFactory) => (\n <div\n className={classnames(styles.drop, {\n [styles.dropSpace300]: space === 300,\n [styles.dropSpace400]: space === 400,\n [styles.dropSpace600]: space === 600,\n [styles.dropWithFooter]: !!footer,\n })}\n style={widthEqualToActivator ? { width: '100%' } : { maxWidth }}\n data-qa={dataQA}\n key=\"drop-outer-container\"\n >\n <DropContainer\n key=\"drop-container\"\n dividerState={!footer ? 'hide' : dividerState}\n ref={resizeRefCallbackFactory('scroll-container', false, true)}\n >\n <div ref={resizeRefCallbackFactory('drop-content')}>\n <PureChildren>{children}</PureChildren>\n </div>\n </DropContainer>\n {footer && (\n <div ref={resizeRefCallbackFactory('drop-footer')} className={styles.dropFooter}>\n <PureChildren>{footer}</PureChildren>\n </div>\n )}\n </div>\n )}\n </DropBase>\n </Layer>\n );\n};\n\nconst Drop = forwardRef<HTMLElement, DropProps>(DropComponent);\nexport { Drop };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;AAaA,MAAM,eAAe,GAAgB;IACjC,UAAU;IACV,aAAa;IACb,WAAW;IACX,cAAc;IACd,UAAU;IACV,WAAW;IACX,aAAa;IACb,cAAc;CACjB,CAAC;AAEF,MAAM,aAAa,GAAG,CAClB,EACI,OAAO,EACP,YAAY,EACZ,OAAO,EACP,QAAQ,GAAG,GAAG,EACd,SAAS,GAAG,GAAG,EACf,KAAK,GAAG,GAAG,EACX,QAAQ,EACR,MAAM,EACN,IAAI,GAAG,QAAQ,EACf,YAAY,GAAG,MAAM,EACrB,qBAAqB,GAAG,KAAK,EAC7B,kCAAkC,GAAG,IAAI,EACzC,mBAAmB,EACnB,mBAAmB,GAAG,IAAI,EAC1B,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,cAAc,EACd,GAAG,KAAK,EACA,EACZ,GAA8B,KACT;AACrB,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IACrC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9D,IAAA,MAAM,yBAAyB,GAAG,MAAM,EAAgB,CAAC;AAEzD,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,MAAK;AAChC,QAAA,MAAM,eAAe,GAAoB,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;AAC5F,QAAA,QACI,cAAc;AACV,cAAE,eAAe;cACf,CAAC,G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AwB,CAAC,cAAc,CAAC,EAC9C,QAAA,EAAAA,GAAA,CAAC,YAAY,EAAE,EAAA,QAAA,EAAA,QAAQ,GAAgB,EACrC,CAAA,EAAA,EANF,gBAAgB,CAOR,EACf,MAAM,KACHA,GAAK,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,wBAAwB,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,EAC3E,QAAA,EAAAA,GAAA,CAAC,YAAY,EAAA,EAAA,QAAA,EAAE,MAAM,EAAgB,CAAA,EAAA,CACnC,CACT,CAfG,EAAA,EAAA,sBAAsB,CAgBxB,CACT,EAAA,CACM,EACP,CAAA,EACV;AACN,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,UAAU,CAAyB,aAAa;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
5
|
+
import { Divider } from '@hh.ru/magritte-ui-divider';
|
|
6
|
+
|
|
7
|
+
var styles = {"drop":"magritte-drop___Z10P4_7-0-1","drop-container":"magritte-drop-container___dbMt9_7-0-1","dropContainer":"magritte-drop-container___dbMt9_7-0-1","divider-container":"magritte-divider-container___ZCdDW_7-0-1","dividerContainer":"magritte-divider-container___ZCdDW_7-0-1","drop-footer":"magritte-drop-footer___v8ZEO_7-0-1","dropFooter":"magritte-drop-footer___v8ZEO_7-0-1","drop-space-300":"magritte-drop-space-300___41acH_7-0-1","dropSpace300":"magritte-drop-space-300___41acH_7-0-1","drop-space-400":"magritte-drop-space-400___XX1RM_7-0-1","dropSpace400":"magritte-drop-space-400___XX1RM_7-0-1","drop-padding":"magritte-drop-padding___xBiJO_7-0-1","dropPadding":"magritte-drop-padding___xBiJO_7-0-1","drop-space-600":"magritte-drop-space-600___6B1i0_7-0-1","dropSpace600":"magritte-drop-space-600___6B1i0_7-0-1","drop-with-footer":"magritte-drop-with-footer___CgBIV_7-0-1","dropWithFooter":"magritte-drop-with-footer___CgBIV_7-0-1","drop-enter":"magritte-drop-enter___4vEuH_7-0-1","dropEnter":"magritte-drop-enter___4vEuH_7-0-1","drop-exit":"magritte-drop-exit___brFjz_7-0-1","dropExit":"magritte-drop-exit___brFjz_7-0-1","drop-enter-active":"magritte-drop-enter-active___SQUog_7-0-1","dropEnterActive":"magritte-drop-enter-active___SQUog_7-0-1","drop-exit-active":"magritte-drop-exit-active___GB0ET_7-0-1","dropExitActive":"magritte-drop-exit-active___GB0ET_7-0-1","drop-animation-timeout":"magritte-drop-animation-timeout___uO7LF_7-0-1","dropAnimationTimeout":"magritte-drop-animation-timeout___uO7LF_7-0-1"};
|
|
8
|
+
|
|
9
|
+
const DropContainer = forwardRef(({ children, dividerState }, ref) => {
|
|
10
|
+
const dividerRef = useRef(null);
|
|
11
|
+
const showDividerRef = useRef(false);
|
|
12
|
+
showDividerRef.current = dividerState !== 'hide';
|
|
13
|
+
const contentContainerRef = useRef(null);
|
|
14
|
+
const contentContainerRefMulti = useMultipleRefs(contentContainerRef, ref);
|
|
15
|
+
const updateDividerVisibility = useCallback((showDivider) => {
|
|
16
|
+
if (!contentContainerRef.current || !dividerRef.current) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!showDivider) {
|
|
20
|
+
dividerRef.current.style.visibility = 'hidden';
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (contentContainerRef?.current !== null && dividerRef.current) {
|
|
24
|
+
const hasScroll = contentContainerRef.current.scrollHeight - contentContainerRef.current.clientHeight > 0;
|
|
25
|
+
dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';
|
|
26
|
+
}
|
|
27
|
+
}, [contentContainerRef, dividerRef]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const observer = new ResizeObserver(() => {
|
|
30
|
+
updateDividerVisibility(showDividerRef.current);
|
|
31
|
+
});
|
|
32
|
+
observer.observe(contentContainerRef.current);
|
|
33
|
+
return () => observer.disconnect();
|
|
34
|
+
}, [updateDividerVisibility]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
updateDividerVisibility(showDividerRef.current);
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
}, [updateDividerVisibility, showDividerRef.current]);
|
|
39
|
+
const props = showDividerRef.current
|
|
40
|
+
? {
|
|
41
|
+
onScroll: ({ target }) => {
|
|
42
|
+
const scrollableContainer = target;
|
|
43
|
+
if (dividerRef.current && dividerState !== 'showWhenFullyScrolled') {
|
|
44
|
+
const scrollEnded = scrollableContainer.scrollTop +
|
|
45
|
+
scrollableContainer.offsetHeight -
|
|
46
|
+
scrollableContainer.scrollHeight ===
|
|
47
|
+
0;
|
|
48
|
+
dividerRef.current.style.visibility = scrollEnded ? 'hidden' : 'visible';
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {};
|
|
53
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: contentContainerRefMulti, className: styles.dropContainer, ...props, children: children }), jsx("div", { ref: dividerRef, className: styles.dividerContainer, "data-qa": "drop-divider", children: jsx(Divider, {}) })] }));
|
|
54
|
+
});
|
|
55
|
+
DropContainer.displayName = 'DropContainer';
|
|
56
|
+
|
|
57
|
+
export { DropContainer as D, styles as s };
|
|
58
|
+
//# sourceMappingURL=DropContainer-B2XMpR_h.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropContainer-B2XMpR_h.js","sources":["../src/DropContainer.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren, useEffect, useCallback, forwardRef } from 'react';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { Divider } from '@hh.ru/magritte-ui-divider';\nimport type { DividerState } from '@hh.ru/magritte-ui-drop/types';\n\nimport styles from './drop.less';\n\nexport const DropContainer = forwardRef<\n HTMLDivElement,\n PropsWithChildren<{\n dividerState: DividerState;\n }>\n>(({ children, dividerState }, ref) => {\n const dividerRef = useRef<HTMLDivElement>(null);\n const showDividerRef = useRef(false);\n showDividerRef.current = dividerState !== 'hide';\n const contentContainerRef = useRef<HTMLDivElement>(null);\n const contentContainerRefMulti = useMultipleRefs(contentContainerRef, ref);\n\n const updateDividerVisibility = useCallback(\n (showDivider: boolean) => {\n if (!contentContainerRef.current || !dividerRef.current) {\n return;\n }\n if (!showDivider) {\n dividerRef.current.style.visibility = 'hidden';\n return;\n }\n if (contentContainerRef?.current !== null && dividerRef.current) {\n const hasScroll =\n contentContainerRef.current.scrollHeight - contentContainerRef.current.clientHeight > 0;\n dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';\n }\n },\n [contentContainerRef, dividerRef]\n );\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n updateDividerVisibility(showDividerRef.current);\n });\n observer.observe(contentContainerRef.current as Element);\n return () => observer.disconnect();\n }, [updateDividerVisibility]);\n\n useEffect(() => {\n updateDividerVisibility(showDividerRef.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [updateDividerVisibility, showDividerRef.current]);\n\n const props = showDividerRef.current\n ? {\n onScroll: ({ target }: { target: EventTarget }) => {\n const scrollableContainer = target as HTMLDivElement;\n\n if (dividerRef.current && dividerState !== 'showWhenFullyScrolled') {\n const scrollEnded =\n scrollableContainer.scrollTop +\n scrollableContainer.offsetHeight -\n scrollableContainer.scrollHeight ===\n 0;\n\n dividerRef.current.style.visibility = scrollEnded ? 'hidden' : 'visible';\n }\n },\n }\n : {};\n\n return (\n <>\n <div ref={contentContainerRefMulti} className={styles.dropContainer} {...props}>\n {children}\n </div>\n <div ref={dividerRef} className={styles.dividerContainer} data-qa=\"drop-divider\">\n <Divider />\n </div>\n </>\n );\n});\n\nDropContainer.displayName = 'DropContainer';\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;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EAAE;AAEH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
package/DropContainer.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { DividerState } from '@hh.ru/magritte-ui-drop/types';
|
|
3
|
-
export declare const DropContainer:
|
|
3
|
+
export declare const DropContainer: import("react").ForwardRefExoticComponent<{
|
|
4
4
|
dividerState: DividerState;
|
|
5
|
-
}
|
|
5
|
+
} & {
|
|
6
|
+
children?: import("react").ReactNode;
|
|
7
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/DropContainer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
4
5
|
import '@hh.ru/magritte-ui-divider';
|
|
5
|
-
export { D as DropContainer } from './DropContainer-
|
|
6
|
+
export { D as DropContainer } from './DropContainer-B2XMpR_h.js';
|
|
6
7
|
//# sourceMappingURL=DropContainer.js.map
|
package/DropContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropContainer.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DropContainer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/index.css
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
--magritte-shadow-level-2-blur-v18-3-0:16px;
|
|
24
24
|
--magritte-shadow-level-2-spread-v18-3-0:0px;
|
|
25
25
|
}
|
|
26
|
-
.magritte-drop___Z10P4_7-0-
|
|
26
|
+
.magritte-drop___Z10P4_7-0-1{
|
|
27
27
|
position:relative;
|
|
28
28
|
display:flex;
|
|
29
29
|
flex-direction:column;
|
|
@@ -34,97 +34,97 @@
|
|
|
34
34
|
height:100%;
|
|
35
35
|
overflow:hidden;
|
|
36
36
|
}
|
|
37
|
-
.magritte-drop-container___dbMt9_7-0-
|
|
37
|
+
.magritte-drop-container___dbMt9_7-0-1{
|
|
38
38
|
display:block;
|
|
39
39
|
overflow:auto;
|
|
40
40
|
}
|
|
41
|
-
.magritte-divider-container___ZCdDW_7-0-
|
|
41
|
+
.magritte-divider-container___ZCdDW_7-0-1{
|
|
42
42
|
visibility:hidden;
|
|
43
43
|
}
|
|
44
|
-
.magritte-drop-footer___v8ZEO_7-0-
|
|
44
|
+
.magritte-drop-footer___v8ZEO_7-0-1{
|
|
45
45
|
display:flex;
|
|
46
46
|
flex-flow:column;
|
|
47
47
|
gap:12px;
|
|
48
48
|
}
|
|
49
|
-
.magritte-drop-space-300___41acH_7-0-
|
|
50
|
-
.magritte-drop-space-300___41acH_7-0-
|
|
49
|
+
.magritte-drop-space-300___41acH_7-0-1 .magritte-drop-container___dbMt9_7-0-1,
|
|
50
|
+
.magritte-drop-space-300___41acH_7-0-1 .magritte-drop-footer___v8ZEO_7-0-1{
|
|
51
51
|
padding:var(--magritte-static-space-300-v18-3-0);
|
|
52
52
|
}
|
|
53
|
-
.magritte-drop-space-400___XX1RM_7-0-
|
|
54
|
-
.magritte-drop-space-400___XX1RM_7-0-
|
|
55
|
-
.magritte-drop-space-400___XX1RM_7-0-
|
|
53
|
+
.magritte-drop-space-400___XX1RM_7-0-1 .magritte-drop-padding___xBiJO_7-0-1,
|
|
54
|
+
.magritte-drop-space-400___XX1RM_7-0-1 .magritte-drop-container___dbMt9_7-0-1,
|
|
55
|
+
.magritte-drop-space-400___XX1RM_7-0-1 .magritte-drop-footer___v8ZEO_7-0-1{
|
|
56
56
|
padding:var(--magritte-static-space-400-v18-3-0);
|
|
57
57
|
}
|
|
58
|
-
.magritte-drop-space-600___6B1i0_7-0-
|
|
59
|
-
.magritte-drop-space-600___6B1i0_7-0-
|
|
60
|
-
.magritte-drop-space-600___6B1i0_7-0-
|
|
58
|
+
.magritte-drop-space-600___6B1i0_7-0-1 .magritte-drop-padding___xBiJO_7-0-1,
|
|
59
|
+
.magritte-drop-space-600___6B1i0_7-0-1 .magritte-drop-container___dbMt9_7-0-1,
|
|
60
|
+
.magritte-drop-space-600___6B1i0_7-0-1 .magritte-drop-footer___v8ZEO_7-0-1{
|
|
61
61
|
padding:var(--magritte-static-space-600-v18-3-0);
|
|
62
62
|
}
|
|
63
|
-
.magritte-drop-with-footer___CgBIV_7-0-
|
|
63
|
+
.magritte-drop-with-footer___CgBIV_7-0-1 .magritte-drop-container___dbMt9_7-0-1{
|
|
64
64
|
padding-bottom:0;
|
|
65
65
|
}
|
|
66
66
|
@media (prefers-reduced-motion: no-preference){
|
|
67
|
-
.magritte-drop-enter___4vEuH_7-0-
|
|
67
|
+
.magritte-drop-enter___4vEuH_7-0-1 .magritte-drop___Z10P4_7-0-1{
|
|
68
68
|
opacity:0;
|
|
69
69
|
}
|
|
70
|
-
.magritte-drop-exit___brFjz_7-0-
|
|
71
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
70
|
+
.magritte-drop-exit___brFjz_7-0-1 .magritte-drop___Z10P4_7-0-1,
|
|
71
|
+
.magritte-drop-enter-active___SQUog_7-0-1 .magritte-drop___Z10P4_7-0-1{
|
|
72
72
|
opacity:1;
|
|
73
73
|
}
|
|
74
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
74
|
+
.magritte-drop-exit-active___GB0ET_7-0-1 .magritte-drop___Z10P4_7-0-1{
|
|
75
75
|
opacity:0;
|
|
76
76
|
}
|
|
77
|
-
.magritte-drop-animation-timeout___uO7LF_7-0-
|
|
78
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
77
|
+
.magritte-drop-animation-timeout___uO7LF_7-0-1,
|
|
78
|
+
.magritte-drop-enter-active___SQUog_7-0-1 .magritte-drop___Z10P4_7-0-1{
|
|
79
79
|
transition-property:opacity, transform;
|
|
80
80
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0);
|
|
81
81
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0);
|
|
82
82
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0);
|
|
83
83
|
}
|
|
84
|
-
.magritte-drop-animation-timeout___uO7LF_7-0-
|
|
85
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
84
|
+
.magritte-drop-animation-timeout___uO7LF_7-0-1,
|
|
85
|
+
.magritte-drop-exit-active___GB0ET_7-0-1 .magritte-drop___Z10P4_7-0-1{
|
|
86
86
|
transition-property:opacity, transform;
|
|
87
87
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-100-duration-v18-3-0);
|
|
88
88
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0);
|
|
89
89
|
}
|
|
90
|
-
.magritte-drop-enter___4vEuH_7-0-
|
|
90
|
+
.magritte-drop-enter___4vEuH_7-0-1[data-magritte-drop-base-direction='top'] .magritte-drop___Z10P4_7-0-1{
|
|
91
91
|
transform:translateY(-4px);
|
|
92
92
|
}
|
|
93
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
93
|
+
.magritte-drop-exit-active___GB0ET_7-0-1[data-magritte-drop-base-direction='top'] .magritte-drop___Z10P4_7-0-1{
|
|
94
94
|
transform:translateY(-4px);
|
|
95
95
|
}
|
|
96
|
-
.magritte-drop-enter___4vEuH_7-0-
|
|
96
|
+
.magritte-drop-enter___4vEuH_7-0-1[data-magritte-drop-base-direction='bottom'] .magritte-drop___Z10P4_7-0-1{
|
|
97
97
|
transform:translateY(4px);
|
|
98
98
|
}
|
|
99
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
99
|
+
.magritte-drop-exit-active___GB0ET_7-0-1[data-magritte-drop-base-direction='bottom'] .magritte-drop___Z10P4_7-0-1{
|
|
100
100
|
transform:translateY(4px);
|
|
101
101
|
}
|
|
102
|
-
.magritte-drop-enter___4vEuH_7-0-
|
|
102
|
+
.magritte-drop-enter___4vEuH_7-0-1[data-magritte-drop-base-direction='left'] .magritte-drop___Z10P4_7-0-1{
|
|
103
103
|
transform:translateX(-4px);
|
|
104
104
|
}
|
|
105
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
105
|
+
.magritte-drop-exit-active___GB0ET_7-0-1[data-magritte-drop-base-direction='left'] .magritte-drop___Z10P4_7-0-1{
|
|
106
106
|
transform:translateX(4px);
|
|
107
107
|
}
|
|
108
|
-
.magritte-drop-enter___4vEuH_7-0-
|
|
108
|
+
.magritte-drop-enter___4vEuH_7-0-1[data-magritte-drop-base-direction='right'] .magritte-drop___Z10P4_7-0-1{
|
|
109
109
|
transform:translateX(4px);
|
|
110
110
|
}
|
|
111
|
-
.magritte-drop-exit-active___GB0ET_7-0-
|
|
111
|
+
.magritte-drop-exit-active___GB0ET_7-0-1[data-magritte-drop-base-direction='right'] .magritte-drop___Z10P4_7-0-1{
|
|
112
112
|
transform:translateX(4px);
|
|
113
113
|
}
|
|
114
|
-
.magritte-drop-exit___brFjz_7-0-
|
|
115
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
114
|
+
.magritte-drop-exit___brFjz_7-0-1[data-magritte-drop-base-direction='left'] .magritte-drop___Z10P4_7-0-1,
|
|
115
|
+
.magritte-drop-enter-active___SQUog_7-0-1[data-magritte-drop-base-direction='left'] .magritte-drop___Z10P4_7-0-1{
|
|
116
116
|
transform:translateX(0%);
|
|
117
117
|
}
|
|
118
|
-
.magritte-drop-exit___brFjz_7-0-
|
|
119
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
118
|
+
.magritte-drop-exit___brFjz_7-0-1[data-magritte-drop-base-direction='bottom'] .magritte-drop___Z10P4_7-0-1,
|
|
119
|
+
.magritte-drop-enter-active___SQUog_7-0-1[data-magritte-drop-base-direction='bottom'] .magritte-drop___Z10P4_7-0-1{
|
|
120
120
|
transform:translateY(0%);
|
|
121
121
|
}
|
|
122
|
-
.magritte-drop-exit___brFjz_7-0-
|
|
123
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
122
|
+
.magritte-drop-exit___brFjz_7-0-1[data-magritte-drop-base-direction='right'] .magritte-drop___Z10P4_7-0-1,
|
|
123
|
+
.magritte-drop-enter-active___SQUog_7-0-1[data-magritte-drop-base-direction='right'] .magritte-drop___Z10P4_7-0-1{
|
|
124
124
|
transform:translateX(0%);
|
|
125
125
|
}
|
|
126
|
-
.magritte-drop-exit___brFjz_7-0-
|
|
127
|
-
.magritte-drop-enter-active___SQUog_7-0-
|
|
126
|
+
.magritte-drop-exit___brFjz_7-0-1[data-magritte-drop-base-direction='top'] .magritte-drop___Z10P4_7-0-1,
|
|
127
|
+
.magritte-drop-enter-active___SQUog_7-0-1[data-magritte-drop-base-direction='top'] .magritte-drop___Z10P4_7-0-1{
|
|
128
128
|
transform:translateY(0%);
|
|
129
129
|
}
|
|
130
130
|
}
|
package/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import 'classnames';
|
|
|
7
7
|
import '@hh.ru/magritte-internal-drop-base';
|
|
8
8
|
import '@hh.ru/magritte-internal-layer-name';
|
|
9
9
|
import '@hh.ru/magritte-ui-breakpoint';
|
|
10
|
-
import './DropContainer-
|
|
10
|
+
import './DropContainer-B2XMpR_h.js';
|
|
11
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
11
12
|
import '@hh.ru/magritte-ui-divider';
|
|
12
13
|
import './PureChildren.js';
|
|
13
14
|
import '@hh.ru/magritte-ui-layer';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-drop",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@hh.ru/magritte-common-use-multiple-refs": "1.1.4",
|
|
24
24
|
"@hh.ru/magritte-design-tokens": "18.3.0",
|
|
25
|
-
"@hh.ru/magritte-internal-drop-base": "7.0.
|
|
25
|
+
"@hh.ru/magritte-internal-drop-base": "7.0.1",
|
|
26
26
|
"@hh.ru/magritte-internal-layer-name": "2.2.0",
|
|
27
27
|
"@hh.ru/magritte-ui-breakpoint": "4.0.3",
|
|
28
28
|
"@hh.ru/magritte-ui-divider": "1.1.30",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "7a5af0004d5897f0e840df5aa5e3ab0b39127ae5"
|
|
40
40
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useRef, useCallback, useEffect } from 'react';
|
|
4
|
-
import { Divider } from '@hh.ru/magritte-ui-divider';
|
|
5
|
-
|
|
6
|
-
var styles = {"drop":"magritte-drop___Z10P4_7-0-0","drop-container":"magritte-drop-container___dbMt9_7-0-0","dropContainer":"magritte-drop-container___dbMt9_7-0-0","divider-container":"magritte-divider-container___ZCdDW_7-0-0","dividerContainer":"magritte-divider-container___ZCdDW_7-0-0","drop-footer":"magritte-drop-footer___v8ZEO_7-0-0","dropFooter":"magritte-drop-footer___v8ZEO_7-0-0","drop-space-300":"magritte-drop-space-300___41acH_7-0-0","dropSpace300":"magritte-drop-space-300___41acH_7-0-0","drop-space-400":"magritte-drop-space-400___XX1RM_7-0-0","dropSpace400":"magritte-drop-space-400___XX1RM_7-0-0","drop-padding":"magritte-drop-padding___xBiJO_7-0-0","dropPadding":"magritte-drop-padding___xBiJO_7-0-0","drop-space-600":"magritte-drop-space-600___6B1i0_7-0-0","dropSpace600":"magritte-drop-space-600___6B1i0_7-0-0","drop-with-footer":"magritte-drop-with-footer___CgBIV_7-0-0","dropWithFooter":"magritte-drop-with-footer___CgBIV_7-0-0","drop-enter":"magritte-drop-enter___4vEuH_7-0-0","dropEnter":"magritte-drop-enter___4vEuH_7-0-0","drop-exit":"magritte-drop-exit___brFjz_7-0-0","dropExit":"magritte-drop-exit___brFjz_7-0-0","drop-enter-active":"magritte-drop-enter-active___SQUog_7-0-0","dropEnterActive":"magritte-drop-enter-active___SQUog_7-0-0","drop-exit-active":"magritte-drop-exit-active___GB0ET_7-0-0","dropExitActive":"magritte-drop-exit-active___GB0ET_7-0-0","drop-animation-timeout":"magritte-drop-animation-timeout___uO7LF_7-0-0","dropAnimationTimeout":"magritte-drop-animation-timeout___uO7LF_7-0-0"};
|
|
7
|
-
|
|
8
|
-
const DropContainer = ({ children, dividerState }) => {
|
|
9
|
-
const dividerRef = useRef(null);
|
|
10
|
-
const showDividerRef = useRef(false);
|
|
11
|
-
showDividerRef.current = dividerState !== 'hide';
|
|
12
|
-
const contentContainerRef = useRef(null);
|
|
13
|
-
const updateDividerVisibility = useCallback((showDivider) => {
|
|
14
|
-
if (!contentContainerRef.current || !dividerRef.current) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (!showDivider) {
|
|
18
|
-
dividerRef.current.style.visibility = 'hidden';
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const hasScroll = contentContainerRef.current.scrollHeight - contentContainerRef.current.clientHeight > 0;
|
|
22
|
-
dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';
|
|
23
|
-
}, [contentContainerRef, dividerRef]);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!contentContainerRef.current) {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
const observer = new ResizeObserver(() => {
|
|
29
|
-
updateDividerVisibility(showDividerRef.current);
|
|
30
|
-
});
|
|
31
|
-
observer.observe(contentContainerRef.current);
|
|
32
|
-
return () => observer.disconnect();
|
|
33
|
-
}, [updateDividerVisibility]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
updateDividerVisibility(showDividerRef.current);
|
|
36
|
-
}, [updateDividerVisibility, dividerState]);
|
|
37
|
-
const props = showDividerRef.current
|
|
38
|
-
? {
|
|
39
|
-
onScroll: ({ target }) => {
|
|
40
|
-
const scrollableContainer = target;
|
|
41
|
-
if (dividerRef.current && dividerState !== 'showWhenFullyScrolled') {
|
|
42
|
-
const scrollEnded = scrollableContainer.scrollTop +
|
|
43
|
-
scrollableContainer.offsetHeight -
|
|
44
|
-
scrollableContainer.scrollHeight ===
|
|
45
|
-
0;
|
|
46
|
-
dividerRef.current.style.visibility = scrollEnded ? 'hidden' : 'visible';
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
: {};
|
|
51
|
-
return (jsxs(Fragment, { children: [jsx("div", { ref: contentContainerRef, className: styles.dropContainer, ...props, children: children }), jsx("div", { ref: dividerRef, className: styles.dividerContainer, "data-qa": "drop-divider", children: jsx(Divider, {}) })] }));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { DropContainer as D, styles as s };
|
|
55
|
-
//# sourceMappingURL=DropContainer-Y4wrsbBC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropContainer-Y4wrsbBC.js","sources":["../src/DropContainer.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren, useEffect, type FC, useCallback } from 'react';\n\nimport { Divider } from '@hh.ru/magritte-ui-divider';\nimport type { DividerState } from '@hh.ru/magritte-ui-drop/types';\n\nimport styles from './drop.less';\n\nexport const DropContainer: FC<\n PropsWithChildren<{\n dividerState: DividerState;\n }>\n> = ({ children, dividerState }) => {\n const dividerRef = useRef<HTMLDivElement>(null);\n const showDividerRef = useRef(false);\n showDividerRef.current = dividerState !== 'hide';\n const contentContainerRef = useRef<HTMLDivElement>(null);\n const updateDividerVisibility = useCallback(\n (showDivider: boolean) => {\n if (!contentContainerRef.current || !dividerRef.current) {\n return;\n }\n if (!showDivider) {\n dividerRef.current.style.visibility = 'hidden';\n return;\n }\n const hasScroll = contentContainerRef.current.scrollHeight - contentContainerRef.current.clientHeight > 0;\n dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';\n },\n [contentContainerRef, dividerRef]\n );\n\n useEffect(() => {\n if (!contentContainerRef.current) {\n return void 0;\n }\n const observer = new ResizeObserver(() => {\n updateDividerVisibility(showDividerRef.current);\n });\n observer.observe(contentContainerRef.current);\n return () => observer.disconnect();\n }, [updateDividerVisibility]);\n\n useEffect(() => {\n updateDividerVisibility(showDividerRef.current);\n }, [updateDividerVisibility, dividerState]);\n\n const props = showDividerRef.current\n ? {\n onScroll: ({ target }: { target: EventTarget }) => {\n const scrollableContainer = target as HTMLDivElement;\n\n if (dividerRef.current && dividerState !== 'showWhenFullyScrolled') {\n const scrollEnded =\n scrollableContainer.scrollTop +\n scrollableContainer.offsetHeight -\n scrollableContainer.scrollHeight ===\n 0;\n\n dividerRef.current.style.visibility = scrollEnded ? 'hidden' : 'visible';\n }\n },\n }\n : {};\n\n return (\n <>\n <div ref={contentContainerRef} className={styles.dropContainer} {...props}>\n {children}\n </div>\n <div ref={dividerRef} className={styles.dividerContainer} data-qa=\"drop-divider\">\n <Divider />\n </div>\n </>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;AAOa,MAAA,aAAa,GAItB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAI;AAC/B,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,IAAA,cAAc,CAAC,OAAO,GAAG,YAAY,KAAK,MAAM,CAAC;AACjD,IAAA,MAAM,mBAAmB,GAAG,MAAM,C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