@hh.ru/magritte-ui-drop 5.0.8
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.d.ts +11 -0
- package/Drop.js +51 -0
- package/Drop.js.map +1 -0
- package/DropContainer-931ee089.js +36 -0
- package/DropContainer-931ee089.js.map +1 -0
- package/DropContainer.d.ts +9 -0
- package/DropContainer.js +6 -0
- package/DropContainer.js.map +1 -0
- package/PureChildren.d.ts +3 -0
- package/PureChildren.js +9 -0
- package/PureChildren.js.map +1 -0
- package/index.css +126 -0
- package/index.d.ts +3 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/package.json +38 -0
- package/types.d.ts +26 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
package/Drop.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactElement, ForwardedRef } from 'react';
|
|
2
|
+
import { type DropBaseHorizontalPositionWithoutCenter, type DropBaseVerticalPositionWithoutCenter } from '@hh.ru/magritte-internal-drop-base';
|
|
3
|
+
import type { DropProps } from './types';
|
|
4
|
+
declare const Drop: (<T extends DropBaseHorizontalPositionWithoutCenter | DropBaseVerticalPositionWithoutCenter>(props: Omit<import("@hh.ru/magritte-internal-drop-base").DropBasePermanentProps, "arrowGuardDistance" | "children" | "animationTimeout" | "animationClassNames" | "role" | "autoFocusWhenOpened" | "guardDistance" | "occupyAllAvailableViewportHeight"> & T & import("./types").DropPropsOnly & {
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
} & {
|
|
7
|
+
ref?: ForwardedRef<HTMLElement> | undefined;
|
|
8
|
+
}) => ReactElement | null) & {
|
|
9
|
+
displayName?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export { Drop };
|
package/Drop.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { DropBase, INITIAL_HEIGHT_VALUE } from '@hh.ru/magritte-internal-drop-base';
|
|
6
|
+
import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
|
|
7
|
+
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
8
|
+
import { s as styles, D as DropContainer } from './DropContainer-931ee089.js';
|
|
9
|
+
import { PureChildren } from './PureChildren.js';
|
|
10
|
+
import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
11
|
+
import '@hh.ru/magritte-ui-divider';
|
|
12
|
+
|
|
13
|
+
const DropComponent = ({ direction, alignment, visible, host, activatorRef, onClose, maxWidth = 320, minHeightForContent = 300, space = 600, children, footer, role = 'dialog', dividerState = 'show', widthEqualToActivator = false, closeByClickOutside = true, 'data-qa': dataQA = 'drop', ...props }, ref) => {
|
|
14
|
+
const { isMobile } = useBreakpoint();
|
|
15
|
+
const footerRef = useRef(null);
|
|
16
|
+
const [animationTimeout, setAnimationTimeout] = useState(200);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const animationTimeoutElement = document.createElement('div');
|
|
19
|
+
animationTimeoutElement.classList.add(styles.dropAnimationTimeout);
|
|
20
|
+
document.body.appendChild(animationTimeoutElement);
|
|
21
|
+
const style = window.getComputedStyle(animationTimeoutElement);
|
|
22
|
+
const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);
|
|
23
|
+
if (Number.isInteger(animationTimeout)) {
|
|
24
|
+
setAnimationTimeout(animationTimeout);
|
|
25
|
+
}
|
|
26
|
+
document.body.removeChild(animationTimeoutElement);
|
|
27
|
+
}, []);
|
|
28
|
+
if (isMobile) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const position = { direction, alignment };
|
|
32
|
+
return (jsx(Layer, { layer: InternalLayerName.Drop, children: jsx(DropBase, { ...props, ...position, visible: visible, host: host, activatorRef: activatorRef, closeByClickOutside: closeByClickOutside, onClose: onClose, autoFocusWhenOpened: role !== 'status', occupyAllAvailableViewportHeight: true, animationClassNames: {
|
|
33
|
+
enter: styles.dropEnter,
|
|
34
|
+
enterActive: styles.dropEnterActive,
|
|
35
|
+
exit: styles.dropExit,
|
|
36
|
+
exitActive: styles.dropExitActive,
|
|
37
|
+
}, animationTimeout: animationTimeout, widthEqualToActivator: widthEqualToActivator, ref: ref, children: ({ direction }, { metrics, dropScrollableContainerRef }) => (jsxs("div", { className: classnames(`${styles.drop} ${styles[`drop-direction-${direction}`]}`, {
|
|
38
|
+
[styles.dropSpace300]: space === 300,
|
|
39
|
+
[styles.dropSpace400]: space === 400,
|
|
40
|
+
[styles.dropSpace600]: space === 600,
|
|
41
|
+
[styles.dropWithFooter]: !!footer,
|
|
42
|
+
}), style: {
|
|
43
|
+
maxWidth: widthEqualToActivator ? 'none' : maxWidth,
|
|
44
|
+
maxHeight: metrics.height === INITIAL_HEIGHT_VALUE ? 'auto' : `${metrics.height}px`,
|
|
45
|
+
}, "data-qa": dataQA, children: [jsx(DropContainer, { height: metrics.height === INITIAL_HEIGHT_VALUE ? undefined : metrics.height, dividerState: !footer ? 'hide' : dividerState, ref: dropScrollableContainerRef, minHeightForContent: minHeightForContent, children: jsx(PureChildren, { children: children }) }), footer && (jsx("div", { ref: footerRef, className: styles.dropFooter, children: jsx(PureChildren, { children: footer }) }))] })) }) }));
|
|
46
|
+
};
|
|
47
|
+
const Drop = forwardRef(DropComponent);
|
|
48
|
+
Drop.displayName = 'Drop';
|
|
49
|
+
|
|
50
|
+
export { Drop };
|
|
51
|
+
//# sourceMappingURL=Drop.js.map
|
package/Drop.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drop.js","sources":["../src/Drop.tsx"],"sourcesContent":["import { useRef, useEffect, useState, type ReactElement, ForwardedRef, forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport {\n DropBase,\n INITIAL_HEIGHT_VALUE,\n type DropBaseHorizontalPositionWithoutCenter,\n type DropBaseVerticalPositionWithoutCenter,\n} 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 } from '@hh.ru/magritte-ui-drop/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\n\nimport styles from './drop.less';\n\nconst DropComponent = <T extends DropBaseHorizontalPositionWithoutCenter | DropBaseVerticalPositionWithoutCenter>(\n {\n direction,\n alignment,\n visible,\n host,\n activatorRef,\n onClose,\n maxWidth = 320,\n minHeightForContent = 300,\n space = 600,\n children,\n footer,\n role = 'dialog',\n dividerState = 'show',\n widthEqualToActivator = false,\n closeByClickOutside = true,\n 'data-qa': dataQA = 'drop',\n ...props\n }: DropProps<T>,\n ref: ForwardedRef<HTMLElement>\n): ReactElement | null => {\n const { isMobile } = useBreakpoint();\n const footerRef = useRef<HTMLDivElement>(null);\n const [animationTimeout, setAnimationTimeout] = useState(200);\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 const position = { direction, alignment } as\n | DropBaseVerticalPositionWithoutCenter\n | DropBaseHorizontalPositionWithoutCenter;\n\n return (\n <Layer layer={InternalLayerName.Drop}>\n <DropBase\n {...props}\n {...position}\n visible={visible}\n host={host}\n activatorRef={activatorRef}\n closeByClickOutside={closeByClickOutside}\n onClose={onClose}\n autoFocusWhenOpened={role !== 'status'}\n occupyAllAvailableViewportHeight\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 ref={ref}\n >\n {({ direction }, { metrics, dropScrollableContainerRef }) => (\n <div\n className={classnames(`${styles.drop} ${styles[`drop-direction-${direction}`]}`, {\n [styles.dropSpace300]: space === 300,\n [styles.dropSpace400]: space === 400,\n [styles.dropSpace600]: space === 600,\n [styles.dropWithFooter]: !!footer,\n })}\n style={{\n maxWidth: widthEqualToActivator ? 'none' : maxWidth,\n maxHeight: metrics.height === INITIAL_HEIGHT_VALUE ? 'auto' : `${metrics.height}px`,\n }}\n data-qa={dataQA}\n >\n <DropContainer\n height={metrics.height === INITIAL_HEIGHT_VALUE ? undefined : metrics.height}\n dividerState={!footer ? 'hide' : dividerState}\n ref={dropScrollableContainerRef}\n minHeightForContent={minHeightForContent}\n >\n <PureChildren>{children}</PureChildren>\n </DropContainer>\n {footer && (\n <div ref={footerRef} className={styles.dropFooter}>\n <PureChildren>{footer}</PureChildren>\n </div>\n )}\n </div>\n )}\n </DropBase>\n </Layer>\n );\n};\n\nconst Drop = forwardRef(DropComponent) as (<\n T extends DropBaseHorizontalPositionWithoutCenter | DropBaseVerticalPositionWithoutCenter\n>(\n props: DropProps<T> & { ref?: ForwardedRef<HTMLElement> }\n) => ReactElement | null) & { displayName?: string };\n\nDrop.displayName = 'Drop';\n\nexport { Drop };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAkBA,MAAM,aAAa,GAAG,CAClB,EACI,SAAS,EACT,SAAS,EACT,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,QAAQ,GAAG,GAAG,EACd,mBAAmB,GAAG,GAAG,EACzB,KAAK,GAAG,GAAG,EACX,QAAQ,EACR,MAAM,EACN,IAAI,GAAG,QAAQ,EACf,YAAY,GAAG,MAAM,EACrB,qBAAqB,GAAG,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A,CAAAD,GAAA,CAAC,aAAa,EAAA,EACV,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,EAC5E,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,YAAY,EAC7C,GAAG,EAAE,0BAA0B,EAC/B,mBAAmB,EAAE,mBAAmB,EAExC,QAAA,EAAAA,GAAA,CAAC,YAAY,EAAE,EAAA,QAAA,EAAA,QAAQ,EAAgB,CAAA,EAAA,CAC3B,EACf,MAAM,KACHA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,EAAA,QAAA,EAC7CA,IAAC,YAAY,EAAA,EAAA,QAAA,EAAE,MAAM,EAAA,CAAgB,GACnC,CACT,CAAA,EAAA,CACC,CACT,EACM,CAAA,EAAA,CACP,EACV;AACN,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,UAAU,CAAC,aAAa,EAIgB;AAErD,IAAI,CAAC,WAAW,GAAG,MAAM;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useRef, useEffect } from 'react';
|
|
4
|
+
import { Divider } from '@hh.ru/magritte-ui-divider';
|
|
5
|
+
|
|
6
|
+
var styles = {"drop":"magritte-drop___Z10P4_5-0-8","drop-container":"magritte-drop-container___dbMt9_5-0-8","dropContainer":"magritte-drop-container___dbMt9_5-0-8","drop-footer":"magritte-drop-footer___v8ZEO_5-0-8","dropFooter":"magritte-drop-footer___v8ZEO_5-0-8","drop-space-300":"magritte-drop-space-300___41acH_5-0-8","dropSpace300":"magritte-drop-space-300___41acH_5-0-8","drop-space-400":"magritte-drop-space-400___XX1RM_5-0-8","dropSpace400":"magritte-drop-space-400___XX1RM_5-0-8","drop-padding":"magritte-drop-padding___xBiJO_5-0-8","dropPadding":"magritte-drop-padding___xBiJO_5-0-8","drop-space-600":"magritte-drop-space-600___6B1i0_5-0-8","dropSpace600":"magritte-drop-space-600___6B1i0_5-0-8","drop-with-footer":"magritte-drop-with-footer___CgBIV_5-0-8","dropWithFooter":"magritte-drop-with-footer___CgBIV_5-0-8","drop-enter":"magritte-drop-enter___4vEuH_5-0-8","dropEnter":"magritte-drop-enter___4vEuH_5-0-8","drop-exit":"magritte-drop-exit___brFjz_5-0-8","dropExit":"magritte-drop-exit___brFjz_5-0-8","drop-enter-active":"magritte-drop-enter-active___SQUog_5-0-8","dropEnterActive":"magritte-drop-enter-active___SQUog_5-0-8","drop-exit-active":"magritte-drop-exit-active___GB0ET_5-0-8","dropExitActive":"magritte-drop-exit-active___GB0ET_5-0-8","drop-animation-timeout":"magritte-drop-animation-timeout___uO7LF_5-0-8","dropAnimationTimeout":"magritte-drop-animation-timeout___uO7LF_5-0-8","drop-direction-top":"magritte-drop-direction-top___3CelS_5-0-8","dropDirectionTop":"magritte-drop-direction-top___3CelS_5-0-8","drop-direction-bottom":"magritte-drop-direction-bottom___719rs_5-0-8","dropDirectionBottom":"magritte-drop-direction-bottom___719rs_5-0-8","drop-direction-left":"magritte-drop-direction-left___2PTob_5-0-8","dropDirectionLeft":"magritte-drop-direction-left___2PTob_5-0-8","drop-direction-right":"magritte-drop-direction-right___SPOr1_5-0-8","dropDirectionRight":"magritte-drop-direction-right___SPOr1_5-0-8"};
|
|
7
|
+
|
|
8
|
+
const DropContainer = forwardRef(({ children, height, dividerState, minHeightForContent }, ref) => {
|
|
9
|
+
const dividerRef = useRef(null);
|
|
10
|
+
const showDivider = dividerState !== 'hide';
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (showDivider && ref && 'current' in ref && ref?.current !== null && dividerRef.current && !!height) {
|
|
13
|
+
const hasScroll = ref.current.scrollHeight - ref.current.clientHeight > 0;
|
|
14
|
+
dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';
|
|
15
|
+
}
|
|
16
|
+
}, [ref, dividerRef, height, showDivider]);
|
|
17
|
+
const props = showDivider
|
|
18
|
+
? {
|
|
19
|
+
onScroll: ({ target }) => {
|
|
20
|
+
const scrollableContainer = target;
|
|
21
|
+
if (dividerRef.current && dividerState !== 'showWhenFullyScrolled') {
|
|
22
|
+
const scrollEnded = scrollableContainer.scrollTop +
|
|
23
|
+
scrollableContainer.offsetHeight -
|
|
24
|
+
scrollableContainer.scrollHeight ===
|
|
25
|
+
0;
|
|
26
|
+
dividerRef.current.style.visibility = scrollEnded ? 'hidden' : 'visible';
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
: {};
|
|
31
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: ref, className: styles.dropContainer, style: { height: height === undefined ? `${minHeightForContent}px` : 'auto' }, ...props, children: children }), showDivider && (jsx("div", { ref: dividerRef, "data-qa": "drop-divider", children: jsx(Divider, {}) }))] }));
|
|
32
|
+
});
|
|
33
|
+
DropContainer.displayName = 'DropContainer';
|
|
34
|
+
|
|
35
|
+
export { DropContainer as D, styles as s };
|
|
36
|
+
//# sourceMappingURL=DropContainer-931ee089.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropContainer-931ee089.js","sources":["../src/DropContainer.tsx"],"sourcesContent":["import { useRef, PropsWithChildren, useEffect, forwardRef } 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 = forwardRef<\n HTMLDivElement,\n PropsWithChildren<{\n height?: number | string;\n dividerState: DividerState;\n minHeightForContent: number;\n }>\n>(({ children, height, dividerState, minHeightForContent }, ref) => {\n const dividerRef = useRef<HTMLDivElement>(null);\n const showDivider = dividerState !== 'hide';\n\n useEffect(() => {\n if (showDivider && ref && 'current' in ref && ref?.current !== null && dividerRef.current && !!height) {\n const hasScroll = ref.current.scrollHeight - ref.current.clientHeight > 0;\n dividerRef.current.style.visibility = hasScroll ? 'visible' : 'hidden';\n }\n }, [ref, dividerRef, height, showDivider]);\n\n const props = showDivider\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\n ref={ref}\n className={styles.dropContainer}\n style={{ height: height === undefined ? `${minHeightForContent}px` : 'auto' }}\n {...props}\n >\n {children}\n </div>\n {showDivider && (\n <div ref={dividerRef} data-qa=\"drop-divider\">\n <Divider />\n </div>\n )}\n </>\n );\n});\n\nDropContainer.displayName = 'DropContainer';\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;AAOa,MAAA,aAAa,GAAG,UAAU,CAOrC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,EAAE,GAAG,KAAI;AAC/D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,WAAW,GAAG,YAAY,KAAK,MAAM,CAAC;IAE5C,SAAS,CAAC,MAAK;QACX,IAAI,WAAW,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,GAAG,EAAE,OAAO,KAAK,IAAI,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,EAAE;AACnG,YAAA,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;AAC1E,YAAA,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC1E,SAAA;KACJ,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAE3C,MAAM,KAAK,GAAG,WAAW;AACrB,UAAE;AACI,YAAA,QAAQ,EAAE,CAAC,EAAE,MAAM,EAA2B,KAAI;gBAC9C,MAAM,mBAAmB,GAAG,MAAwB,CAAC;AAErD,gBAAA,IAAI,UAAU,CAAC,OAAO,IAAI,YAAY,KAAK,uBAAuB,EAAE;AAChE,oBAAA,MAAM,WAAW,GACb,mBAAmB,CAAC,SAAS;AACzB,wBAAA,mBAAmB,CAAC,YAAY;AAChC,wBAAA,mBAAmB,CAAC,YAAY;AACpC,wBAAA,CAAC,CAAC;AAEN,oBAAA,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5E,iBAAA;aACJ;AACJ,SAAA;UACD,EAAE,CAAC;IAET,QACIA,IACI,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAA,KAAA,EAAA,EACI,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,MAAM,CAAC,aAAa,EAC/B,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS,GAAG,CAAA,EAAG,mBAAmB,CAAA,EAAA,CAAI,GAAG,MAAM,EAAE,EACzE,GAAA,KAAK,EAER,QAAA,EAAA,QAAQ,EACP,CAAA,EACL,WAAW,KACRA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,UAAU,EAAU,SAAA,EAAA,cAAc,EACxC,QAAA,EAAAA,GAAA,CAAC,OAAO,EAAA,EAAA,CAAG,EACT,CAAA,CACT,CACF,EAAA,CAAA,EACL;AACN,CAAC,EAAE;AAEH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DividerState } from './types';
|
|
3
|
+
export declare const DropContainer: import("react").ForwardRefExoticComponent<{
|
|
4
|
+
height?: string | number | undefined;
|
|
5
|
+
dividerState: DividerState;
|
|
6
|
+
minHeightForContent: number;
|
|
7
|
+
} & {
|
|
8
|
+
children?: import("react").ReactNode;
|
|
9
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/DropContainer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropContainer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/PureChildren.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
|
|
5
|
+
const PureChildren = memo(({ children }) => jsx(Fragment, { children: children }));
|
|
6
|
+
PureChildren.displayName = 'PureChildren';
|
|
7
|
+
|
|
8
|
+
export { PureChildren };
|
|
9
|
+
//# sourceMappingURL=PureChildren.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PureChildren.js","sources":["../src/PureChildren.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, memo } from 'react';\n\nconst PureChildren: FC<PropsWithChildren> = memo(({ children }) => <>{children}</>);\n\nPureChildren.displayName = 'PureChildren';\n\nexport { PureChildren };\n"],"names":["_jsx","_Fragment"],"mappings":";;;AAEA,MAAM,YAAY,GAA0B,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAKA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI,EAAE;AAEpF,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
package/index.css
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
:root{
|
|
2
|
+
--magritte-color-component-drop-background-content-v18-1-1:#ffffff;
|
|
3
|
+
--magritte-shadow-level-2-color-v18-1-1:#7090b03d;
|
|
4
|
+
--magritte-shadow-level-2-x-v18-1-1:0px;
|
|
5
|
+
--magritte-shadow-level-2-y-v18-1-1:8px;
|
|
6
|
+
--magritte-shadow-level-2-blur-v18-1-1:16px;
|
|
7
|
+
--magritte-shadow-level-2-spread-v18-1-1:0px;
|
|
8
|
+
}
|
|
9
|
+
:root{
|
|
10
|
+
--magritte-semantic-animation-ease-in-out-100-duration-v18-1-1:100ms;
|
|
11
|
+
--magritte-semantic-animation-ease-in-out-200-timing-function-v18-1-1:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
12
|
+
--magritte-semantic-animation-ease-in-out-200-duration-v18-1-1:200ms;
|
|
13
|
+
--magritte-static-space-300-v18-1-1:12px;
|
|
14
|
+
--magritte-static-space-400-v18-1-1:16px;
|
|
15
|
+
--magritte-static-space-600-v18-1-1:24px;
|
|
16
|
+
--magritte-static-border-radius-600-v18-1-1:24px;
|
|
17
|
+
}
|
|
18
|
+
.magritte-night-theme{
|
|
19
|
+
--magritte-color-component-drop-background-content-v18-1-1:#1B1B1B;
|
|
20
|
+
--magritte-shadow-level-2-color-v18-1-1:#0000003d;
|
|
21
|
+
--magritte-shadow-level-2-x-v18-1-1:0px;
|
|
22
|
+
--magritte-shadow-level-2-y-v18-1-1:8px;
|
|
23
|
+
--magritte-shadow-level-2-blur-v18-1-1:16px;
|
|
24
|
+
--magritte-shadow-level-2-spread-v18-1-1:0px;
|
|
25
|
+
}
|
|
26
|
+
.magritte-drop___Z10P4_5-0-8{
|
|
27
|
+
position:relative;
|
|
28
|
+
display:flex;
|
|
29
|
+
flex-direction:column;
|
|
30
|
+
background:var(--magritte-color-component-drop-background-content-v18-1-1);
|
|
31
|
+
border-radius:var(--magritte-static-border-radius-600-v18-1-1);
|
|
32
|
+
box-shadow:var(--magritte-shadow-level-2-x-v18-1-1) var(--magritte-shadow-level-2-y-v18-1-1) var(--magritte-shadow-level-2-blur-v18-1-1) var(--magritte-shadow-level-2-spread-v18-1-1) var(--magritte-shadow-level-2-color-v18-1-1);
|
|
33
|
+
box-sizing:border-box;
|
|
34
|
+
overflow:hidden;
|
|
35
|
+
}
|
|
36
|
+
.magritte-drop-container___dbMt9_5-0-8{
|
|
37
|
+
display:block;
|
|
38
|
+
overflow:auto;
|
|
39
|
+
}
|
|
40
|
+
.magritte-drop-footer___v8ZEO_5-0-8{
|
|
41
|
+
display:flex;
|
|
42
|
+
flex-flow:column;
|
|
43
|
+
gap:12px;
|
|
44
|
+
}
|
|
45
|
+
.magritte-drop-space-300___41acH_5-0-8 .magritte-drop-container___dbMt9_5-0-8,
|
|
46
|
+
.magritte-drop-space-300___41acH_5-0-8 .magritte-drop-footer___v8ZEO_5-0-8{
|
|
47
|
+
padding:var(--magritte-static-space-300-v18-1-1);
|
|
48
|
+
}
|
|
49
|
+
.magritte-drop-space-400___XX1RM_5-0-8 .magritte-drop-padding___xBiJO_5-0-8,
|
|
50
|
+
.magritte-drop-space-400___XX1RM_5-0-8 .magritte-drop-container___dbMt9_5-0-8,
|
|
51
|
+
.magritte-drop-space-400___XX1RM_5-0-8 .magritte-drop-footer___v8ZEO_5-0-8{
|
|
52
|
+
padding:var(--magritte-static-space-400-v18-1-1);
|
|
53
|
+
}
|
|
54
|
+
.magritte-drop-space-600___6B1i0_5-0-8 .magritte-drop-padding___xBiJO_5-0-8,
|
|
55
|
+
.magritte-drop-space-600___6B1i0_5-0-8 .magritte-drop-container___dbMt9_5-0-8,
|
|
56
|
+
.magritte-drop-space-600___6B1i0_5-0-8 .magritte-drop-footer___v8ZEO_5-0-8{
|
|
57
|
+
padding:var(--magritte-static-space-600-v18-1-1);
|
|
58
|
+
}
|
|
59
|
+
.magritte-drop-with-footer___CgBIV_5-0-8 .magritte-drop-container___dbMt9_5-0-8{
|
|
60
|
+
padding-bottom:0;
|
|
61
|
+
}
|
|
62
|
+
@media (prefers-reduced-motion: no-preference){
|
|
63
|
+
.magritte-drop-enter___4vEuH_5-0-8 .magritte-drop___Z10P4_5-0-8{
|
|
64
|
+
opacity:0;
|
|
65
|
+
}
|
|
66
|
+
.magritte-drop-exit___brFjz_5-0-8 .magritte-drop___Z10P4_5-0-8,
|
|
67
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop___Z10P4_5-0-8{
|
|
68
|
+
opacity:1;
|
|
69
|
+
}
|
|
70
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop___Z10P4_5-0-8{
|
|
71
|
+
opacity:0;
|
|
72
|
+
}
|
|
73
|
+
.magritte-drop-animation-timeout___uO7LF_5-0-8,
|
|
74
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop___Z10P4_5-0-8{
|
|
75
|
+
transition-property:opacity, transform;
|
|
76
|
+
transition-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-1-1);
|
|
77
|
+
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-1-1);
|
|
78
|
+
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-1-1);
|
|
79
|
+
}
|
|
80
|
+
.magritte-drop-animation-timeout___uO7LF_5-0-8,
|
|
81
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop___Z10P4_5-0-8{
|
|
82
|
+
transition-property:opacity, transform;
|
|
83
|
+
transition-duration:var(--magritte-semantic-animation-ease-in-out-100-duration-v18-1-1);
|
|
84
|
+
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-1-1);
|
|
85
|
+
}
|
|
86
|
+
.magritte-drop-enter___4vEuH_5-0-8 .magritte-drop-direction-top___3CelS_5-0-8{
|
|
87
|
+
transform:translateY(-4px);
|
|
88
|
+
}
|
|
89
|
+
.magritte-drop-exit___brFjz_5-0-8 .magritte-drop-direction-top___3CelS_5-0-8,
|
|
90
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop-direction-top___3CelS_5-0-8{
|
|
91
|
+
transform:translateY(0%);
|
|
92
|
+
}
|
|
93
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop-direction-top___3CelS_5-0-8{
|
|
94
|
+
transform:translateY(-4px);
|
|
95
|
+
}
|
|
96
|
+
.magritte-drop-enter___4vEuH_5-0-8 .magritte-drop-direction-bottom___719rs_5-0-8{
|
|
97
|
+
transform:translateY(4px);
|
|
98
|
+
}
|
|
99
|
+
.magritte-drop-exit___brFjz_5-0-8 .magritte-drop-direction-bottom___719rs_5-0-8,
|
|
100
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop-direction-bottom___719rs_5-0-8{
|
|
101
|
+
transform:translateY(0%);
|
|
102
|
+
}
|
|
103
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop-direction-bottom___719rs_5-0-8{
|
|
104
|
+
transform:translateY(4px);
|
|
105
|
+
}
|
|
106
|
+
.magritte-drop-enter___4vEuH_5-0-8 .magritte-drop-direction-left___2PTob_5-0-8{
|
|
107
|
+
transform:translateX(-4px);
|
|
108
|
+
}
|
|
109
|
+
.magritte-drop-exit___brFjz_5-0-8 .magritte-drop-direction-left___2PTob_5-0-8,
|
|
110
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop-direction-left___2PTob_5-0-8{
|
|
111
|
+
transform:translateX(0%);
|
|
112
|
+
}
|
|
113
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop-direction-left___2PTob_5-0-8{
|
|
114
|
+
transform:translateX(4px);
|
|
115
|
+
}
|
|
116
|
+
.magritte-drop-enter___4vEuH_5-0-8 .magritte-drop-direction-right___SPOr1_5-0-8{
|
|
117
|
+
transform:translateX(4px);
|
|
118
|
+
}
|
|
119
|
+
.magritte-drop-exit___brFjz_5-0-8 .magritte-drop-direction-right___SPOr1_5-0-8,
|
|
120
|
+
.magritte-drop-enter-active___SQUog_5-0-8 .magritte-drop-direction-right___SPOr1_5-0-8{
|
|
121
|
+
transform:translateX(0%);
|
|
122
|
+
}
|
|
123
|
+
.magritte-drop-exit-active___GB0ET_5-0-8 .magritte-drop-direction-right___SPOr1_5-0-8{
|
|
124
|
+
transform:translateX(4px);
|
|
125
|
+
}
|
|
126
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
export * from '@hh.ru/magritte-ui-theme-provider';
|
|
3
|
+
export { Drop } from './Drop.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'classnames';
|
|
7
|
+
import '@hh.ru/magritte-internal-drop-base';
|
|
8
|
+
import '@hh.ru/magritte-internal-layer-name';
|
|
9
|
+
import '@hh.ru/magritte-ui-breakpoint';
|
|
10
|
+
import './DropContainer-931ee089.js';
|
|
11
|
+
import '@hh.ru/magritte-ui-divider';
|
|
12
|
+
import './PureChildren.js';
|
|
13
|
+
import '@hh.ru/magritte-ui-layer';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hh.ru/magritte-ui-drop",
|
|
3
|
+
"version": "5.0.8",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"index.css"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "yarn root:build $(pwd)",
|
|
11
|
+
"build-test-branch": "yarn root:build-test-branch $(pwd)",
|
|
12
|
+
"changelog": "yarn root:changelog $(pwd)",
|
|
13
|
+
"prepack": "yarn root:prepack $(pwd)",
|
|
14
|
+
"postpublish": "yarn root:postpublish $(pwd)",
|
|
15
|
+
"stylelint-test": "yarn root:stylelint-test $(pwd)",
|
|
16
|
+
"eslint-test": "yarn root:eslint-test $(pwd)",
|
|
17
|
+
"ts-config": "yarn root:ts-config $(pwd)",
|
|
18
|
+
"ts-check": "yarn root:ts-check $(pwd)",
|
|
19
|
+
"test": "yarn root:test $(pwd)"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@hh.ru/magritte-design-tokens": "18.1.1",
|
|
23
|
+
"@hh.ru/magritte-internal-drop-base": "5.0.4",
|
|
24
|
+
"@hh.ru/magritte-internal-layer-name": "2.1.1",
|
|
25
|
+
"@hh.ru/magritte-ui-breakpoint": "4.0.1",
|
|
26
|
+
"@hh.ru/magritte-ui-divider": "1.1.24",
|
|
27
|
+
"@hh.ru/magritte-ui-layer": "2.0.3",
|
|
28
|
+
"@hh.ru/magritte-ui-theme-provider": "1.1.21"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"classnames": "2.3.2",
|
|
32
|
+
"react": ">=18.2.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "b660dd64fca3eaad5ec44ea9a73f92bb0d9694aa"
|
|
38
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode, PropsWithChildren } from 'react';
|
|
2
|
+
import { type DropBasePermanentProps, type DropBaseHorizontalPositionWithoutCenter, type DropBaseVerticalPositionWithoutCenter } from '@hh.ru/magritte-internal-drop-base';
|
|
3
|
+
export type DividerState = 'show' | 'hide' | 'showWhenFullyScrolled';
|
|
4
|
+
export interface DropPropsOnly {
|
|
5
|
+
/** Cостояние divider, позволяет упровлять его логикой показа
|
|
6
|
+
* show - показывать если не доскролили до конца блока
|
|
7
|
+
* showWhenFullyScrolled - показывать даже если доскролили до конца блока
|
|
8
|
+
* hide - скрыть
|
|
9
|
+
* */
|
|
10
|
+
dividerState?: DividerState;
|
|
11
|
+
/** Максимальная ширина Drop */
|
|
12
|
+
maxWidth?: number;
|
|
13
|
+
/** Минимальная высота содержимого первого контейнера Drop */
|
|
14
|
+
minHeightForContent?: number;
|
|
15
|
+
/** Роли для доступности */
|
|
16
|
+
role?: 'alertdialog' | 'dialog' | 'listbox' | 'status';
|
|
17
|
+
/** Содержимое нижнего контейнера */
|
|
18
|
+
footer?: ReactNode;
|
|
19
|
+
/** Размеры отступов внутри Drop */
|
|
20
|
+
space?: 0 | 300 | 400 | 600;
|
|
21
|
+
/** QA атрибут */
|
|
22
|
+
'data-qa'?: string;
|
|
23
|
+
/** Ширина дропа равна ширине активатора, при установке флага значение пропа maxWidth игнорируется */
|
|
24
|
+
widthEqualToActivator?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type DropProps<T extends DropBaseHorizontalPositionWithoutCenter | DropBaseVerticalPositionWithoutCenter> = Omit<DropBasePermanentProps, 'arrowGuardDistance' | 'children' | 'animationTimeout' | 'animationClassNames' | 'role' | 'autoFocusWhenOpened' | 'guardDistance' | 'occupyAllAvailableViewportHeight'> & T & PropsWithChildren<DropPropsOnly>;
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|