@hh.ru/magritte-ui-modal 5.0.7 → 5.0.9

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/Modal.d.ts CHANGED
@@ -1,32 +1,32 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  export declare const Modal: import("react").ForwardRefExoticComponent<import("@hh.ru/magritte-ui-modal/types").ModalBaseProps & {
3
- title?: import("react").ReactNode;
4
- titleSize?: import("../title/src/types").TitleSizeOptions | undefined;
5
- titleAlignment?: "center" | "left" | undefined;
6
- titleMaxLines?: number | undefined;
7
- titleElement?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
8
- titleDescription?: import("react").ReactNode;
9
- titleDescriptionMaxLines?: number | undefined;
10
- titleStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
11
- titleDescriptionStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
12
- headerImage?: string | undefined;
13
- headerHeight?: number | undefined;
3
+ title?: import("../../title/src").TitleProps["children"];
4
+ titleSize?: import("../../title/src").TitleProps["size"];
5
+ titleAlignment?: import("../../title/src").TitleProps["alignment"];
6
+ titleMaxLines?: import("../../title/src").TitleProps["maxLines"];
7
+ titleElement?: import("../../title/src").TitleProps["Element"];
8
+ titleDescription?: import("../../title/src").TitleProps["description"];
9
+ titleDescriptionMaxLines?: import("../../title/src").TitleProps["descriptionMaxLines"];
10
+ titleStyle?: import("../../title/src").TitleProps["style"];
11
+ titleDescriptionStyle?: import("../../title/src").TitleProps["descriptionStyle"];
12
+ headerImage?: string;
13
+ headerHeight?: number;
14
14
  } & {
15
15
  options?: import("react").ReactNode;
16
16
  actions?: import("react").ReactNode | import("react").ReactNode[];
17
17
  actionLink?: import("react").ReactNode;
18
18
  } & Omit<HTMLAttributes<HTMLDivElement>, keyof {
19
- title?: import("react").ReactNode;
20
- titleSize?: import("../title/src/types").TitleSizeOptions | undefined;
21
- titleAlignment?: "center" | "left" | undefined;
22
- titleMaxLines?: number | undefined;
23
- titleElement?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
24
- titleDescription?: import("react").ReactNode;
25
- titleDescriptionMaxLines?: number | undefined;
26
- titleStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
27
- titleDescriptionStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
28
- headerImage?: string | undefined;
29
- headerHeight?: number | undefined;
19
+ title?: import("../../title/src").TitleProps["children"];
20
+ titleSize?: import("../../title/src").TitleProps["size"];
21
+ titleAlignment?: import("../../title/src").TitleProps["alignment"];
22
+ titleMaxLines?: import("../../title/src").TitleProps["maxLines"];
23
+ titleElement?: import("../../title/src").TitleProps["Element"];
24
+ titleDescription?: import("../../title/src").TitleProps["description"];
25
+ titleDescriptionMaxLines?: import("../../title/src").TitleProps["descriptionMaxLines"];
26
+ titleStyle?: import("../../title/src").TitleProps["style"];
27
+ titleDescriptionStyle?: import("../../title/src").TitleProps["descriptionStyle"];
28
+ headerImage?: string;
29
+ headerHeight?: number;
30
30
  } | keyof {
31
31
  options?: import("react").ReactNode;
32
32
  actions?: import("react").ReactNode | import("react").ReactNode[];
package/Modal.js CHANGED
@@ -13,7 +13,7 @@ import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
13
13
  import { isActionBarComponent } from '@hh.ru/magritte-ui-action-bar';
14
14
  import { Breakpoint, useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
15
15
  import { Layer } from '@hh.ru/magritte-ui-layer';
16
- import { s as styles, M as ModalContentWithHeader } from './ModalContentWithHeader-Bz5cYjdl.js';
16
+ import { s as styles, M as ModalContentWithHeader } from './ModalContentWithHeader-4iviLjKS.js';
17
17
  import { useModalOrder } from './useModalOrder.js';
18
18
  import { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector';
19
19
  import '@hh.ru/magritte-common-func-utils';
package/Modal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../src/Modal.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n useLayoutEffect,\n useRef,\n useState,\n useCallback,\n useId,\n useEffect,\n cloneElement,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport { keyboardMatch, keyboardKeys } from '@hh.ru/magritte-common-keyboard';\nimport { disableScroll } from '@hh.ru/magritte-common-modal-helper';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useNoBubbling } from '@hh.ru/magritte-common-use-no-bubbling';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { isActionBarComponent } from '@hh.ru/magritte-ui-action-bar';\nimport { useBreakpoint, Breakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { ModalContentWithHeader } from '@hh.ru/magritte-ui-modal/ModalContentWithHeader';\nimport { ModalHeaderProps, ModalProps } from '@hh.ru/magritte-ui-modal/types';\nimport { useModalOrder } from '@hh.ru/magritte-ui-modal/useModalOrder';\nimport { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector';\n\nimport styles from './modal.less';\n\nconst noop = () => undefined;\n\nconst toNumber = (value: string) => {\n const result = parseInt(value, 10);\n return Number.isInteger(result) ? result : 0;\n};\n\nconst INVISIBLE_FOR_BREAKPOINTS = [Breakpoint.XS, Breakpoint.S];\n\nexport const Modal = forwardRef<\n HTMLDivElement,\n ModalProps &\n Omit<HTMLAttributes<HTMLDivElement>, keyof ModalProps | 'role' | 'tabindex' | 'className' | 'aria-labeledby'>\n>(\n (\n {\n visible,\n size = 'medium',\n title,\n titleAlignment = 'left',\n titleSize = 'large',\n titleMaxLines,\n titleElement = 'h2',\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n children,\n onClose = noop,\n headerImage,\n headerHeight,\n host,\n options,\n actions,\n actionLink,\n footer,\n disableVerticalPaddings = false,\n disableHorizontalPaddings = false,\n closeByClickOutside = true,\n ...rest\n },\n ref\n ) => {\n const isServerEnv = useServerEnv();\n const enableScrollRef = useRef<() => void>();\n const [animationTimeout, setAnimationTimeout] = useState<{ enter: number; exit: number }>({\n enter: 0,\n exit: 0,\n });\n const labelId = useId();\n const additionalProps: { 'aria-labelledby'?: string } = {};\n if (title) {\n additionalProps['aria-labelledby'] = labelId;\n }\n const modalRef = useRef<HTMLDivElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const modalRefCallback = useMultipleRefs(ref, modalRef);\n\n const isPaddingsDisableAllowed =\n !title && !headerImage && !titleDescription && !footer && !options && !actionLink && !actions;\n const isVerticalPaddingsDisabled = disableVerticalPaddings && isPaddingsDisableAllowed;\n const isHorizontalPaddingsDisabled = disableHorizontalPaddings && isPaddingsDisableAllowed;\n\n const onEntering = useCallback(() => {\n if (!enableScrollRef.current) {\n enableScrollRef.current = disableScroll();\n }\n if (modalRef.current && !modalRef.current.contains(document.activeElement)) {\n modalRef.current.focus();\n }\n }, []);\n const onExited = useCallback(() => {\n enableScrollRef.current?.();\n enableScrollRef.current = undefined;\n }, []);\n\n const [position, count] = useModalOrder(!!visible && !isServerEnv, modalRef);\n const isOverlayHidden = (position === 0 && count > 0) || (count > 1 && position > 1);\n\n const { breakpoint } = useBreakpoint();\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const currentBreakpointVisible = !INVISIBLE_FOR_BREAKPOINTS.includes(breakpoint);\n if (!currentBreakpointVisible) {\n onExited();\n return;\n }\n\n onEntering();\n // visible не должно быть в зависимостях, т.к. этот эффект обрабатывает только изменение брейкпоинта\n // visible обрабатывается CSSTransition\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [breakpoint, onEntering, onExited]);\n\n useEffect(\n () => () => {\n enableScrollRef.current?.();\n enableScrollRef.current = undefined;\n },\n [visible]\n );\n\n useLayoutEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.animationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n setAnimationTimeout({\n enter: toNumber(style.getPropertyValue('--enter-animation-duration')),\n exit: toNumber(style.getPropertyValue('--exit-animation-duration')),\n });\n document.body.removeChild(animationTimeoutElement);\n }, [setAnimationTimeout]);\n\n const overlayEventHandlers = useNoBubbling({\n onKeyDown: (event) => {\n if (keyboardMatch(event.nativeEvent as KeyboardEvent, keyboardKeys.Escape)) {\n onClose(event);\n }\n },\n onClick: (event) => {\n if (!closeByClickOutside || modalRef.current?.contains(event.target as HTMLElement)) {\n return;\n }\n onClose(event);\n },\n });\n\n if (INVISIBLE_FOR_BREAKPOINTS.includes(breakpoint) || isServerEnv) {\n return null;\n }\n\n const modalHeaderProps = {\n title,\n titleElement,\n titleAlignment,\n titleSize,\n titleMaxLines,\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n headerImage,\n headerHeight,\n options,\n actions,\n actionLink,\n } as ModalHeaderProps;\n\n const isTreeSelectorChild = isValidTreeSelectorWrapper(children);\n\n return createPortal(\n <CSSTransition\n appear\n in={visible && !isServerEnv}\n nodeRef={overlayRef}\n onEntering={onEntering}\n onExited={onExited}\n classNames={{\n appear: styles.modalAnimationEnter,\n appearActive: styles.modalAnimationEnterActive,\n enter: styles.modalAnimationEnter,\n enterActive: styles.modalAnimationEnterActive,\n exit: styles.modalAnimationExit,\n exitActive: styles.modalAnimationExitActive,\n }}\n timeout={animationTimeout}\n unmountOnExit\n >\n <Layer layer={InternalLayerName.Modal}>\n <div\n {...overlayEventHandlers}\n ref={overlayRef}\n className={styles.modalOverlay}\n style={isOverlayHidden ? { backgroundColor: 'transparent' } : {}}\n data-qa=\"modal-overlay\"\n >\n <div\n {...rest}\n {...additionalProps}\n role=\"dialog\"\n className={classnames(styles.modal, {\n [styles.sizeSmall]: size === 'small',\n [styles.sizeMedium]: size === 'medium',\n [styles.modalFullHeight]: isTreeSelectorChild,\n [styles.noVerticalPaddings]: isVerticalPaddingsDisabled,\n [styles.noHorizontalPaddings]: isHorizontalPaddingsDisabled,\n })}\n ref={modalRefCallback}\n tabIndex={0}\n >\n <ModalContentWithHeader\n {...modalHeaderProps}\n labelId={labelId}\n isTreeSelectorChild={isTreeSelectorChild}\n >\n {children}\n </ModalContentWithHeader>\n {!!footer && (\n <div className={styles.modalFooter} data-qa=\"modal-footer\">\n {isActionBarComponent(footer)\n ? cloneElement(footer, { type: footer.props.type || 'modal' })\n : footer}\n </div>\n )}\n </div>\n </div>\n </Layer>\n </CSSTransition>,\n host || document.body\n );\n }\n);\n\nModal.displayName = 'Modal';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAI;IAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACnC,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAA,KAAK,GAAG,UAAU,CAK3B,CACI,EACI,OAAO,EACP,IAAI,GAAG,QAAQ,EACf,KAAK,EACL,cAAc,GAAG,MAAM,EACvB,SAAS,GAAG,OAAO,EACnB,aAAa,EACb,YAAY,GAAG,IAAI,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,M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;AACpC,wBAAA,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,KAAK,QAAQ;AACtC,wBAAA,CAAC,MAAM,CAAC,eAAe,GAAG,mBAAmB;AAC7C,wBAAA,CAAC,MAAM,CAAC,kBAAkB,GAAG,0BAA0B;AACvD,wBAAA,CAAC,MAAM,CAAC,oBAAoB,GAAG,4BAA4B;AAC9D,qBAAA,CAAC,EACF,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,CAAC,EAAA,QAAA,EAAA,CAEXD,IAAC,sBAAsB,EAAA,EAAA,GACf,gBAAgB,EACpB,OAAO,EAAE,OAAO,EAChB,mBAAmB,EAAE,mBAAmB,EAEvC,QAAA,EAAA,QAAQ,GACY,EACxB,CAAC,CAAC,MAAM,KACLA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,WAAW,EAAU,SAAA,EAAA,cAAc,YACrD,oBAAoB,CAAC,MAAM,CAAC;AACzB,kCAAE,YAAY,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;AAC9D,kCAAE,MAAM,EACV,CAAA,CACT,IACC,EACJ,CAAA,EAAA,CACF,EACI,CAAA,EAChB,IAAI,IAAI,QAAQ,CAAC,IAAI,CACxB,CAAC;AACN,CAAC,EACH;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO;;;;"}
1
+ {"version":3,"file":"Modal.js","sources":["../src/Modal.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n useLayoutEffect,\n useRef,\n useState,\n useCallback,\n useId,\n useEffect,\n cloneElement,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport { keyboardMatch, keyboardKeys } from '@hh.ru/magritte-common-keyboard';\nimport { disableScroll } from '@hh.ru/magritte-common-modal-helper';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useNoBubbling } from '@hh.ru/magritte-common-use-no-bubbling';\nimport { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';\nimport { isActionBarComponent } from '@hh.ru/magritte-ui-action-bar';\nimport { useBreakpoint, Breakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { ModalContentWithHeader } from '@hh.ru/magritte-ui-modal/ModalContentWithHeader';\nimport { ModalHeaderProps, ModalProps } from '@hh.ru/magritte-ui-modal/types';\nimport { useModalOrder } from '@hh.ru/magritte-ui-modal/useModalOrder';\nimport { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector';\n\nimport styles from './modal.less';\n\nconst noop = () => undefined;\n\nconst toNumber = (value: string) => {\n const result = parseInt(value, 10);\n return Number.isInteger(result) ? result : 0;\n};\n\nconst INVISIBLE_FOR_BREAKPOINTS = [Breakpoint.XS, Breakpoint.S];\n\nexport const Modal = forwardRef<\n HTMLDivElement,\n ModalProps &\n Omit<HTMLAttributes<HTMLDivElement>, keyof ModalProps | 'role' | 'tabindex' | 'className' | 'aria-labeledby'>\n>(\n (\n {\n visible,\n size = 'medium',\n title,\n titleAlignment = 'left',\n titleSize = 'large',\n titleMaxLines,\n titleElement = 'h2',\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n children,\n onClose = noop,\n headerImage,\n headerHeight,\n host,\n options,\n actions,\n actionLink,\n footer,\n disableVerticalPaddings = false,\n disableHorizontalPaddings = false,\n closeByClickOutside = true,\n ...rest\n },\n ref\n ) => {\n const isServerEnv = useServerEnv();\n const enableScrollRef = useRef<() => void>();\n const [animationTimeout, setAnimationTimeout] = useState<{ enter: number; exit: number }>({\n enter: 0,\n exit: 0,\n });\n const labelId = useId();\n const additionalProps: { 'aria-labelledby'?: string } = {};\n if (title) {\n additionalProps['aria-labelledby'] = labelId;\n }\n const modalRef = useRef<HTMLDivElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const modalRefCallback = useMultipleRefs(ref, modalRef);\n\n const isPaddingsDisableAllowed =\n !title && !headerImage && !titleDescription && !footer && !options && !actionLink && !actions;\n const isVerticalPaddingsDisabled = disableVerticalPaddings && isPaddingsDisableAllowed;\n const isHorizontalPaddingsDisabled = disableHorizontalPaddings && isPaddingsDisableAllowed;\n\n const onEntering = useCallback(() => {\n if (!enableScrollRef.current) {\n enableScrollRef.current = disableScroll();\n }\n if (modalRef.current && !modalRef.current.contains(document.activeElement)) {\n modalRef.current.focus();\n }\n }, []);\n const onExited = useCallback(() => {\n enableScrollRef.current?.();\n enableScrollRef.current = undefined;\n }, []);\n\n const [position, count] = useModalOrder(!!visible && !isServerEnv, modalRef);\n const isOverlayHidden = (position === 0 && count > 0) || (count > 1 && position > 1);\n\n const { breakpoint } = useBreakpoint();\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const currentBreakpointVisible = !INVISIBLE_FOR_BREAKPOINTS.includes(breakpoint);\n if (!currentBreakpointVisible) {\n onExited();\n return;\n }\n\n onEntering();\n // visible не должно быть в зависимостях, т.к. этот эффект обрабатывает только изменение брейкпоинта\n // visible обрабатывается CSSTransition\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [breakpoint, onEntering, onExited]);\n\n useEffect(\n () => () => {\n enableScrollRef.current?.();\n enableScrollRef.current = undefined;\n },\n [visible]\n );\n\n useLayoutEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.animationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n setAnimationTimeout({\n enter: toNumber(style.getPropertyValue('--enter-animation-duration')),\n exit: toNumber(style.getPropertyValue('--exit-animation-duration')),\n });\n document.body.removeChild(animationTimeoutElement);\n }, [setAnimationTimeout]);\n\n const overlayEventHandlers = useNoBubbling({\n onKeyDown: (event) => {\n if (keyboardMatch(event.nativeEvent as KeyboardEvent, keyboardKeys.Escape)) {\n onClose(event);\n }\n },\n onClick: (event) => {\n if (!closeByClickOutside || modalRef.current?.contains(event.target as HTMLElement)) {\n return;\n }\n onClose(event);\n },\n });\n\n if (INVISIBLE_FOR_BREAKPOINTS.includes(breakpoint) || isServerEnv) {\n return null;\n }\n\n const modalHeaderProps = {\n title,\n titleElement,\n titleAlignment,\n titleSize,\n titleMaxLines,\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n headerImage,\n headerHeight,\n options,\n actions,\n actionLink,\n } as ModalHeaderProps;\n\n const isTreeSelectorChild = isValidTreeSelectorWrapper(children);\n\n return createPortal(\n <CSSTransition\n appear\n in={visible && !isServerEnv}\n nodeRef={overlayRef}\n onEntering={onEntering}\n onExited={onExited}\n classNames={{\n appear: styles.modalAnimationEnter,\n appearActive: styles.modalAnimationEnterActive,\n enter: styles.modalAnimationEnter,\n enterActive: styles.modalAnimationEnterActive,\n exit: styles.modalAnimationExit,\n exitActive: styles.modalAnimationExitActive,\n }}\n timeout={animationTimeout}\n unmountOnExit\n >\n <Layer layer={InternalLayerName.Modal}>\n <div\n {...overlayEventHandlers}\n ref={overlayRef}\n className={styles.modalOverlay}\n style={isOverlayHidden ? { backgroundColor: 'transparent' } : {}}\n data-qa=\"modal-overlay\"\n >\n <div\n {...rest}\n {...additionalProps}\n role=\"dialog\"\n className={classnames(styles.modal, {\n [styles.sizeSmall]: size === 'small',\n [styles.sizeMedium]: size === 'medium',\n [styles.modalFullHeight]: isTreeSelectorChild,\n [styles.noVerticalPaddings]: isVerticalPaddingsDisabled,\n [styles.noHorizontalPaddings]: isHorizontalPaddingsDisabled,\n })}\n ref={modalRefCallback}\n tabIndex={0}\n >\n <ModalContentWithHeader\n {...modalHeaderProps}\n labelId={labelId}\n isTreeSelectorChild={isTreeSelectorChild}\n >\n {children}\n </ModalContentWithHeader>\n {!!footer && (\n <div className={styles.modalFooter} data-qa=\"modal-footer\">\n {isActionBarComponent(footer)\n ? cloneElement(footer, { type: footer.props.type || 'modal' })\n : footer}\n </div>\n )}\n </div>\n </div>\n </Layer>\n </CSSTransition>,\n host || document.body\n );\n }\n);\n\nModal.displayName = 'Modal';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAI;IAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACnC,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAA,KAAK,GAAG,UAAU,CAK3B,CACI,EACI,OAAO,EACP,IAAI,GAAG,QAAQ,EACf,KAAK,EACL,cAAc,GAAG,MAAM,EACvB,SAAS,GAAG,OAAO,EACnB,aAAa,EACb,YAAY,GAAG,IAAI,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,MAAM,EACN,uBAAuB,GAAG,KAAK,EAC/B,yBAAyB,GAAG,KAAK,EACjC,mBAAmB,GAAG,IAAI,EAC1B,GAAG,IAAI,EACV,EACD,GAAG,KACH;AACA,IAAA,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;AACnC,IAAA,MAAM,eAAe,GAAG,MAAM,EAAc,CAAC;AAC7C,IAAA,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAkC;AACtF,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,IAAI,EAAE,CAAC;AACV,KAAA,CA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,QAAA,EAAA,QAAQ,GACY,EACxB,CAAC,CAAC,MAAM,KACLA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,WAAW,EAAU,SAAA,EAAA,cAAc,YACrD,oBAAoB,CAAC,MAAM,CAAC;AACzB,kCAAE,YAAY,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;AAC9D,kCAAE,MAAM,EACV,CAAA,CACT,IACC,EACJ,CAAA,EAAA,CACF,EACI,CAAA,EAChB,IAAI,IAAI,QAAQ,CAAC,IAAI,CACxB,CAAC;AACN,CAAC,EACH;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO;;;;"}
@@ -6,7 +6,7 @@ import { requestAnimation } from '@hh.ru/magritte-common-func-utils';
6
6
  import { Divider } from '@hh.ru/magritte-ui-divider';
7
7
  import { ModalHeader } from './ModalHeader.js';
8
8
 
9
- var styles = {"modal-overlay":"magritte-modal-overlay___lK22l_5-0-7","modalOverlay":"magritte-modal-overlay___lK22l_5-0-7","modal":"magritte-modal___RAW6S_5-0-7","size-small":"magritte-size-small___2JTM2_5-0-7","sizeSmall":"magritte-size-small___2JTM2_5-0-7","size-medium":"magritte-size-medium___cWCe7_5-0-7","sizeMedium":"magritte-size-medium___cWCe7_5-0-7","no-vertical-paddings":"magritte-no-vertical-paddings___Z3-oM_5-0-7","noVerticalPaddings":"magritte-no-vertical-paddings___Z3-oM_5-0-7","no-horizontal-paddings":"magritte-no-horizontal-paddings___aT95Y_5-0-7","noHorizontalPaddings":"magritte-no-horizontal-paddings___aT95Y_5-0-7","modal-full-height":"magritte-modal-full-height___gIM4E_5-0-7","modalFullHeight":"magritte-modal-full-height___gIM4E_5-0-7","modal-content":"magritte-modal-content___46QFS_5-0-7","modalContent":"magritte-modal-content___46QFS_5-0-7","modal-content-wrapper":"magritte-modal-content-wrapper___23XFT_5-0-7","modalContentWrapper":"magritte-modal-content-wrapper___23XFT_5-0-7","modal-content-wrapper__one-line":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-7","modalContentWrapperOneLine":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-7","divider-container":"magritte-divider-container___qP3VK_5-0-7","dividerContainer":"magritte-divider-container___qP3VK_5-0-7","divider-container-hidden":"magritte-divider-container-hidden___EIxB-_5-0-7","dividerContainerHidden":"magritte-divider-container-hidden___EIxB-_5-0-7","modal-footer":"magritte-modal-footer___8xPqQ_5-0-7","modalFooter":"magritte-modal-footer___8xPqQ_5-0-7","modal-buttons-container":"magritte-modal-buttons-container___1O1Nr_5-0-7","modalButtonsContainer":"magritte-modal-buttons-container___1O1Nr_5-0-7","animation-timeout":"magritte-animation-timeout___w-j7K_5-0-7","animationTimeout":"magritte-animation-timeout___w-j7K_5-0-7","modal-animation-enter-active":"magritte-modal-animation-enter-active___E8KLu_5-0-7","modalAnimationEnterActive":"magritte-modal-animation-enter-active___E8KLu_5-0-7","modal-animation-exit-active":"magritte-modal-animation-exit-active___ERjKa_5-0-7","modalAnimationExitActive":"magritte-modal-animation-exit-active___ERjKa_5-0-7","modal-animation-enter":"magritte-modal-animation-enter___kruLO_5-0-7","modalAnimationEnter":"magritte-modal-animation-enter___kruLO_5-0-7","modal-animation-exit":"magritte-modal-animation-exit___0jNgl_5-0-7","modalAnimationExit":"magritte-modal-animation-exit___0jNgl_5-0-7","content-scroll-preserver":"magritte-content-scroll-preserver___Tw5Px_5-0-7","contentScrollPreserver":"magritte-content-scroll-preserver___Tw5Px_5-0-7","content-sticky-container":"magritte-content-sticky-container___nqEXj_5-0-7","contentStickyContainer":"magritte-content-sticky-container___nqEXj_5-0-7"};
9
+ var styles = {"modal-overlay":"magritte-modal-overlay___lK22l_5-0-9","modalOverlay":"magritte-modal-overlay___lK22l_5-0-9","modal":"magritte-modal___RAW6S_5-0-9","size-small":"magritte-size-small___2JTM2_5-0-9","sizeSmall":"magritte-size-small___2JTM2_5-0-9","size-medium":"magritte-size-medium___cWCe7_5-0-9","sizeMedium":"magritte-size-medium___cWCe7_5-0-9","no-vertical-paddings":"magritte-no-vertical-paddings___Z3-oM_5-0-9","noVerticalPaddings":"magritte-no-vertical-paddings___Z3-oM_5-0-9","no-horizontal-paddings":"magritte-no-horizontal-paddings___aT95Y_5-0-9","noHorizontalPaddings":"magritte-no-horizontal-paddings___aT95Y_5-0-9","modal-full-height":"magritte-modal-full-height___gIM4E_5-0-9","modalFullHeight":"magritte-modal-full-height___gIM4E_5-0-9","modal-content":"magritte-modal-content___46QFS_5-0-9","modalContent":"magritte-modal-content___46QFS_5-0-9","modal-content-wrapper":"magritte-modal-content-wrapper___23XFT_5-0-9","modalContentWrapper":"magritte-modal-content-wrapper___23XFT_5-0-9","modal-content-wrapper__one-line":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-9","modalContentWrapperOneLine":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-9","divider-container":"magritte-divider-container___qP3VK_5-0-9","dividerContainer":"magritte-divider-container___qP3VK_5-0-9","divider-container-hidden":"magritte-divider-container-hidden___EIxB-_5-0-9","dividerContainerHidden":"magritte-divider-container-hidden___EIxB-_5-0-9","modal-footer":"magritte-modal-footer___8xPqQ_5-0-9","modalFooter":"magritte-modal-footer___8xPqQ_5-0-9","modal-buttons-container":"magritte-modal-buttons-container___1O1Nr_5-0-9","modalButtonsContainer":"magritte-modal-buttons-container___1O1Nr_5-0-9","animation-timeout":"magritte-animation-timeout___w-j7K_5-0-9","animationTimeout":"magritte-animation-timeout___w-j7K_5-0-9","modal-animation-enter-active":"magritte-modal-animation-enter-active___E8KLu_5-0-9","modalAnimationEnterActive":"magritte-modal-animation-enter-active___E8KLu_5-0-9","modal-animation-exit-active":"magritte-modal-animation-exit-active___ERjKa_5-0-9","modalAnimationExitActive":"magritte-modal-animation-exit-active___ERjKa_5-0-9","modal-animation-enter":"magritte-modal-animation-enter___kruLO_5-0-9","modalAnimationEnter":"magritte-modal-animation-enter___kruLO_5-0-9","modal-animation-exit":"magritte-modal-animation-exit___0jNgl_5-0-9","modalAnimationExit":"magritte-modal-animation-exit___0jNgl_5-0-9","content-scroll-preserver":"magritte-content-scroll-preserver___Tw5Px_5-0-9","contentScrollPreserver":"magritte-content-scroll-preserver___Tw5Px_5-0-9","content-sticky-container":"magritte-content-sticky-container___nqEXj_5-0-9","contentStickyContainer":"magritte-content-sticky-container___nqEXj_5-0-9"};
10
10
 
11
11
  const checkIsScrolledToBottom = (el) => {
12
12
  return Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1;
@@ -129,4 +129,4 @@ const ModalContentWithHeader = ({ labelId, children, headerHeight: _headerHeight
129
129
  };
130
130
 
131
131
  export { ModalContentWithHeader as M, styles as s };
132
- //# sourceMappingURL=ModalContentWithHeader-Bz5cYjdl.js.map
132
+ //# sourceMappingURL=ModalContentWithHeader-4iviLjKS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalContentWithHeader-Bz5cYjdl.js","sources":["../src/ModalContentWithHeader.tsx"],"sourcesContent":["import { FC, PropsWithChildren, useCallback, useLayoutEffect, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { requestAnimation } from '@hh.ru/magritte-common-func-utils';\nimport { Divider } from '@hh.ru/magritte-ui-divider';\nimport { ModalHeader } from '@hh.ru/magritte-ui-modal/ModalHeader';\nimport { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';\n\nimport styles from './modal.less';\n\nconst checkIsScrolledToBottom = (el: HTMLElement) => {\n return Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1;\n};\n\nconst clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max);\n\n// Минимальная высота до которой может сжаться хедер\nconst HEADER_SHRINK_MIN_HEIGHT = 148;\n// Минимальная высота отступа между хедером и контентом\nconst HEADER_MARGIN_MIN_HEIGHT = 12;\n// Максимальная высота отступа между хедером и контентом\nconst HEADER_MARGIN_MAX_HEIGHT = 24;\nconst HEADER_MARGIN_HEIGHT_DELTA = HEADER_MARGIN_MAX_HEIGHT - HEADER_MARGIN_MIN_HEIGHT;\n\n// Вычисляет минимальную высоту до которой может сжаться хедер с учетом высоты контента, чтобы не спровоцировать\n// изменение размера модалки\nconst calcHeaderShrinkLimit = (\n headerHeight: number,\n headerMaxHeight: number,\n contentHeight: number,\n contentScrollHeight: number,\n marginHeight: number\n) => {\n // Высота контента скрытого под скроллом когда хедер и марджин под ним имеет максимальную допустимую высоту\n const contentScrollDelta =\n contentScrollHeight - // Высота контента скрытого под скроллом в текущем состоянии\n contentHeight + // Высота контейнера содержащего контент\n (HEADER_MARGIN_MAX_HEIGHT - marginHeight) + // Дельта между текущей высотой марджина и максимальной допустимой\n (headerMaxHeight - headerHeight); // Дельта между текущей высотой хедера и максимальной допустимой\n\n const headerShrinkMinHeight = headerMaxHeight - (contentScrollDelta - HEADER_MARGIN_HEIGHT_DELTA);\n\n return Math.max(headerShrinkMinHeight, HEADER_SHRINK_MIN_HEIGHT);\n};\n\nconst shrinkByDelta = (\n headerImageContainer: HTMLDivElement | null,\n headerWrapper: HTMLDivElement | null,\n headerMinHeight: number,\n headerMaxHeight: number,\n scrollDeltaY: number\n) => {\n if (!headerImageContainer || !headerWrapper) {\n return;\n }\n\n const marginHeight = clamp(\n HEADER_MARGIN_MAX_HEIGHT - scrollDeltaY,\n HEADER_MARGIN_MIN_HEIGHT,\n HEADER_MARGIN_MAX_HEIGHT\n );\n headerWrapper.style.marginBottom = `${marginHeight}px`;\n\n const headerHeight = clamp(\n // Тут прибаляем дельту марджина потому что сначала должен сжаться отступ\n Math.floor(headerMaxHeight - scrollDeltaY + HEADER_MARGIN_HEIGHT_DELTA),\n headerMinHeight,\n headerMaxHeight\n );\n headerImageContainer.style.height = `${headerHeight}px`;\n};\n\nexport const ModalContentWithHeader: FC<\n PropsWithChildren<ModalHeaderProps & { labelId: string; isTreeSelectorChild: boolean }>\n> = ({ labelId, children, headerHeight: _headerHeight = 0, isTreeSelectorChild, ...modalHeaderProps }) => {\n const { title, headerImage, actions, actionLink, options } = modalHeaderProps;\n\n const bottomDividerVisibleRef = useRef(false);\n const contentContainerRef = useRef<HTMLDivElement>(null);\n const headerImageContainerRef = useRef<HTMLDivElement>(null);\n const headerWrapperRef = useRef<HTMLDivElement>(null);\n const spacePreserverRef = useRef<HTMLDivElement>(null);\n const stickyContainerRef = useRef<HTMLDivElement>(null);\n const headerHeightRef = useRef(0);\n const minHeaderHeightRef = useRef(0);\n const headerImageRef = useRef(!!headerImage);\n headerHeightRef.current = headerImage ? Math.max(_headerHeight, 200) : 0;\n headerImageRef.current = !!headerImage;\n\n const bottomDividerContainerRef = useRef<HTMLDivElement>(null);\n const topDividerContainerRef = useRef<HTMLDivElement>(null);\n\n const withoutHeader = !title && !headerImage && !actions && !actionLink && !options;\n const onlyActions = !title && !headerImage && !options && (actions || actionLink);\n\n const isTopDividerVisible = () => {\n if (!contentContainerRef.current) {\n return false;\n }\n\n const topDividerVisible = headerImageRef.current\n ? contentContainerRef.current.scrollTop >\n headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA\n : contentContainerRef.current.scrollTop !== 0;\n\n return topDividerVisible && (options || !headerImage) && !onlyActions && !withoutHeader;\n };\n\n const updateHeaderDimensions = useCallback(() => {\n if (\n !headerImageContainerRef.current ||\n !headerWrapperRef.current ||\n !stickyContainerRef.current ||\n !spacePreserverRef.current ||\n !contentContainerRef.current\n ) {\n return;\n }\n\n if (!headerImageRef.current) {\n spacePreserverRef.current.style.height = '0';\n return;\n }\n\n minHeaderHeightRef.current = calcHeaderShrinkLimit(\n headerImageContainerRef.current.clientHeight,\n headerHeightRef.current,\n contentContainerRef.current.clientHeight,\n stickyContainerRef.current.scrollHeight,\n parseInt(headerWrapperRef.current.style.marginBottom || '0', 10)\n );\n\n shrinkByDelta(\n headerImageContainerRef.current,\n headerWrapperRef.current,\n minHeaderHeightRef.current,\n headerHeightRef.current,\n contentContainerRef.current.scrollTop\n );\n const preserverSize = headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA;\n spacePreserverRef.current.style.height = `${preserverSize}px`;\n }, []);\n\n useLayoutEffect(() => {\n if (contentContainerRef.current) {\n const observer = new ResizeObserver(\n requestAnimation(() => {\n if (!contentContainerRef.current) {\n return;\n }\n const isScrollable =\n contentContainerRef.current.scrollHeight > contentContainerRef.current.clientHeight;\n const hasScroll = isScrollable && !checkIsScrolledToBottom(contentContainerRef.current);\n bottomDividerVisibleRef.current = hasScroll;\n bottomDividerContainerRef.current?.classList.toggle(\n styles.dividerContainerHidden,\n !bottomDividerVisibleRef.current\n );\n updateHeaderDimensions();\n })\n );\n observer.observe(contentContainerRef.current);\n return () => observer.disconnect();\n }\n\n return undefined;\n }, [updateHeaderDimensions]);\n\n useLayoutEffect(() => {\n updateHeaderDimensions();\n if (!options && headerImage) {\n topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, true);\n }\n }, [headerImage, updateHeaderDimensions, options]);\n\n const handleScroll = () => {\n if (!contentContainerRef.current) {\n return;\n }\n\n bottomDividerVisibleRef.current = !checkIsScrolledToBottom(contentContainerRef.current);\n bottomDividerContainerRef.current?.classList.toggle(\n styles.dividerContainerHidden,\n !bottomDividerVisibleRef.current\n );\n topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !isTopDividerVisible());\n if (headerImageRef.current) {\n shrinkByDelta(\n headerImageContainerRef.current,\n headerWrapperRef.current,\n minHeaderHeightRef.current,\n headerHeightRef.current,\n contentContainerRef.current.scrollTop\n );\n }\n };\n\n return (\n <>\n <div\n className={classnames(styles.modalContentWrapper, {\n [styles.modalContentWrapperOneLine]: onlyActions,\n })}\n >\n <ModalHeader\n {...modalHeaderProps}\n headerHeight={headerHeightRef.current}\n labelId={labelId}\n wrapperRef={headerWrapperRef}\n ref={headerImageContainerRef}\n />\n <div\n className={classnames(styles.dividerContainer, {\n [styles.dividerContainerHidden]: !isTopDividerVisible(),\n })}\n ref={topDividerContainerRef}\n >\n <Divider />\n </div>\n <div\n className={classnames(styles.modalContent)}\n ref={contentContainerRef}\n onScroll={handleScroll}\n data-qa=\"modal-content-scroll-container\"\n >\n {isTreeSelectorChild ? (\n children\n ) : (\n <>\n <div className={styles.contentStickyContainer} ref={stickyContainerRef}>\n {children}\n </div>\n <div ref={spacePreserverRef} />\n </>\n )}\n </div>\n </div>\n <div\n className={classnames(styles.dividerContainer, {\n [styles.dividerContainerHidden]: !bottomDividerVisibleRef.current,\n })}\n ref={bottomDividerContainerRef}\n >\n <Divider />\n </div>\n </>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;AAUA,MAAM,uBAAuB,GAAG,CAAC,EAAe,KAAI;AAChD,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAE/F;AACA,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC;AACA,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC;AACA,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,0BAA0B,GAAG,wBAAwB,GAAG,wBAAwB,CAAC;AAEvF;AACA;AACA,MAAM,qBAAqB,GAAG,CAC1B,YAAoB,EACpB,eAAuB,EACvB,aAAqB,EACrB,mBAA2B,EAC3B,YAAoB,KACpB;;AAEA,IAAA,MAAM,kBAAkB,GACpB,mBAAmB;AACnB,QAAA,aAAa;AACb,SAAC,wBAAwB,GAAG,YAAY,CAAC;AACzC,SAAC,eAAe,GAAG,YAAY,CAAC,CAAC;IAErC,MAAM,qBAAqB,GAAG,eAAe,IAAI,kBAAkB,G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YAAY,CAAC,EAC1C,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,YAAY,EACd,SAAA,EAAA,gCAAgC,YAEvC,mBAAmB,IAChB,QAAQ,KAERF,IACI,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,sBAAsB,EAAE,GAAG,EAAE,kBAAkB,EAAA,QAAA,EACjE,QAAQ,EACP,CAAA,EACNA,GAAK,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,iBAAiB,EAAA,CAAI,CAChC,EAAA,CAAA,CACN,GACC,CACJ,EAAA,CAAA,EACNA,GACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB,EAAE;oBAC3C,CAAC,MAAM,CAAC,sBAAsB,GAAG,CAAC,uBAAuB,CAAC,OAAO;iBACpE,CAAC,EACF,GAAG,EAAE,yBAAyB,EAAA,QAAA,EAE9BA,GAAC,CAAA,OAAO,EAAG,EAAA,CAAA,EAAA,CACT,CACP,EAAA,CAAA,EACL;AACN;;;;"}
1
+ {"version":3,"file":"ModalContentWithHeader-4iviLjKS.js","sources":["../src/ModalContentWithHeader.tsx"],"sourcesContent":["import { FC, PropsWithChildren, useCallback, useLayoutEffect, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { requestAnimation } from '@hh.ru/magritte-common-func-utils';\nimport { Divider } from '@hh.ru/magritte-ui-divider';\nimport { ModalHeader } from '@hh.ru/magritte-ui-modal/ModalHeader';\nimport { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';\n\nimport styles from './modal.less';\n\nconst checkIsScrolledToBottom = (el: HTMLElement) => {\n return Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1;\n};\n\nconst clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max);\n\n// Минимальная высота до которой может сжаться хедер\nconst HEADER_SHRINK_MIN_HEIGHT = 148;\n// Минимальная высота отступа между хедером и контентом\nconst HEADER_MARGIN_MIN_HEIGHT = 12;\n// Максимальная высота отступа между хедером и контентом\nconst HEADER_MARGIN_MAX_HEIGHT = 24;\nconst HEADER_MARGIN_HEIGHT_DELTA = HEADER_MARGIN_MAX_HEIGHT - HEADER_MARGIN_MIN_HEIGHT;\n\n// Вычисляет минимальную высоту до которой может сжаться хедер с учетом высоты контента, чтобы не спровоцировать\n// изменение размера модалки\nconst calcHeaderShrinkLimit = (\n headerHeight: number,\n headerMaxHeight: number,\n contentHeight: number,\n contentScrollHeight: number,\n marginHeight: number\n) => {\n // Высота контента скрытого под скроллом когда хедер и марджин под ним имеет максимальную допустимую высоту\n const contentScrollDelta =\n contentScrollHeight - // Высота контента скрытого под скроллом в текущем состоянии\n contentHeight + // Высота контейнера содержащего контент\n (HEADER_MARGIN_MAX_HEIGHT - marginHeight) + // Дельта между текущей высотой марджина и максимальной допустимой\n (headerMaxHeight - headerHeight); // Дельта между текущей высотой хедера и максимальной допустимой\n\n const headerShrinkMinHeight = headerMaxHeight - (contentScrollDelta - HEADER_MARGIN_HEIGHT_DELTA);\n\n return Math.max(headerShrinkMinHeight, HEADER_SHRINK_MIN_HEIGHT);\n};\n\nconst shrinkByDelta = (\n headerImageContainer: HTMLDivElement | null,\n headerWrapper: HTMLDivElement | null,\n headerMinHeight: number,\n headerMaxHeight: number,\n scrollDeltaY: number\n) => {\n if (!headerImageContainer || !headerWrapper) {\n return;\n }\n\n const marginHeight = clamp(\n HEADER_MARGIN_MAX_HEIGHT - scrollDeltaY,\n HEADER_MARGIN_MIN_HEIGHT,\n HEADER_MARGIN_MAX_HEIGHT\n );\n headerWrapper.style.marginBottom = `${marginHeight}px`;\n\n const headerHeight = clamp(\n // Тут прибаляем дельту марджина потому что сначала должен сжаться отступ\n Math.floor(headerMaxHeight - scrollDeltaY + HEADER_MARGIN_HEIGHT_DELTA),\n headerMinHeight,\n headerMaxHeight\n );\n headerImageContainer.style.height = `${headerHeight}px`;\n};\n\nexport const ModalContentWithHeader: FC<\n PropsWithChildren<ModalHeaderProps & { labelId: string; isTreeSelectorChild: boolean }>\n> = ({ labelId, children, headerHeight: _headerHeight = 0, isTreeSelectorChild, ...modalHeaderProps }) => {\n const { title, headerImage, actions, actionLink, options } = modalHeaderProps;\n\n const bottomDividerVisibleRef = useRef(false);\n const contentContainerRef = useRef<HTMLDivElement>(null);\n const headerImageContainerRef = useRef<HTMLDivElement>(null);\n const headerWrapperRef = useRef<HTMLDivElement>(null);\n const spacePreserverRef = useRef<HTMLDivElement>(null);\n const stickyContainerRef = useRef<HTMLDivElement>(null);\n const headerHeightRef = useRef(0);\n const minHeaderHeightRef = useRef(0);\n const headerImageRef = useRef(!!headerImage);\n headerHeightRef.current = headerImage ? Math.max(_headerHeight, 200) : 0;\n headerImageRef.current = !!headerImage;\n\n const bottomDividerContainerRef = useRef<HTMLDivElement>(null);\n const topDividerContainerRef = useRef<HTMLDivElement>(null);\n\n const withoutHeader = !title && !headerImage && !actions && !actionLink && !options;\n const onlyActions = !title && !headerImage && !options && (actions || actionLink);\n\n const isTopDividerVisible = () => {\n if (!contentContainerRef.current) {\n return false;\n }\n\n const topDividerVisible = headerImageRef.current\n ? contentContainerRef.current.scrollTop >\n headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA\n : contentContainerRef.current.scrollTop !== 0;\n\n return topDividerVisible && (options || !headerImage) && !onlyActions && !withoutHeader;\n };\n\n const updateHeaderDimensions = useCallback(() => {\n if (\n !headerImageContainerRef.current ||\n !headerWrapperRef.current ||\n !stickyContainerRef.current ||\n !spacePreserverRef.current ||\n !contentContainerRef.current\n ) {\n return;\n }\n\n if (!headerImageRef.current) {\n spacePreserverRef.current.style.height = '0';\n return;\n }\n\n minHeaderHeightRef.current = calcHeaderShrinkLimit(\n headerImageContainerRef.current.clientHeight,\n headerHeightRef.current,\n contentContainerRef.current.clientHeight,\n stickyContainerRef.current.scrollHeight,\n parseInt(headerWrapperRef.current.style.marginBottom || '0', 10)\n );\n\n shrinkByDelta(\n headerImageContainerRef.current,\n headerWrapperRef.current,\n minHeaderHeightRef.current,\n headerHeightRef.current,\n contentContainerRef.current.scrollTop\n );\n const preserverSize = headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA;\n spacePreserverRef.current.style.height = `${preserverSize}px`;\n }, []);\n\n useLayoutEffect(() => {\n if (contentContainerRef.current) {\n const observer = new ResizeObserver(\n requestAnimation(() => {\n if (!contentContainerRef.current) {\n return;\n }\n const isScrollable =\n contentContainerRef.current.scrollHeight > contentContainerRef.current.clientHeight;\n const hasScroll = isScrollable && !checkIsScrolledToBottom(contentContainerRef.current);\n bottomDividerVisibleRef.current = hasScroll;\n bottomDividerContainerRef.current?.classList.toggle(\n styles.dividerContainerHidden,\n !bottomDividerVisibleRef.current\n );\n updateHeaderDimensions();\n })\n );\n observer.observe(contentContainerRef.current);\n return () => observer.disconnect();\n }\n\n return undefined;\n }, [updateHeaderDimensions]);\n\n useLayoutEffect(() => {\n updateHeaderDimensions();\n if (!options && headerImage) {\n topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, true);\n }\n }, [headerImage, updateHeaderDimensions, options]);\n\n const handleScroll = () => {\n if (!contentContainerRef.current) {\n return;\n }\n\n bottomDividerVisibleRef.current = !checkIsScrolledToBottom(contentContainerRef.current);\n bottomDividerContainerRef.current?.classList.toggle(\n styles.dividerContainerHidden,\n !bottomDividerVisibleRef.current\n );\n topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !isTopDividerVisible());\n if (headerImageRef.current) {\n shrinkByDelta(\n headerImageContainerRef.current,\n headerWrapperRef.current,\n minHeaderHeightRef.current,\n headerHeightRef.current,\n contentContainerRef.current.scrollTop\n );\n }\n };\n\n return (\n <>\n <div\n className={classnames(styles.modalContentWrapper, {\n [styles.modalContentWrapperOneLine]: onlyActions,\n })}\n >\n <ModalHeader\n {...modalHeaderProps}\n headerHeight={headerHeightRef.current}\n labelId={labelId}\n wrapperRef={headerWrapperRef}\n ref={headerImageContainerRef}\n />\n <div\n className={classnames(styles.dividerContainer, {\n [styles.dividerContainerHidden]: !isTopDividerVisible(),\n })}\n ref={topDividerContainerRef}\n >\n <Divider />\n </div>\n <div\n className={classnames(styles.modalContent)}\n ref={contentContainerRef}\n onScroll={handleScroll}\n data-qa=\"modal-content-scroll-container\"\n >\n {isTreeSelectorChild ? (\n children\n ) : (\n <>\n <div className={styles.contentStickyContainer} ref={stickyContainerRef}>\n {children}\n </div>\n <div ref={spacePreserverRef} />\n </>\n )}\n </div>\n </div>\n <div\n className={classnames(styles.dividerContainer, {\n [styles.dividerContainerHidden]: !bottomDividerVisibleRef.current,\n })}\n ref={bottomDividerContainerRef}\n >\n <Divider />\n </div>\n </>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;AAUA,MAAM,uBAAuB,GAAG,CAAC,EAAe,KAAI;AAChD,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAE/F;AACA,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC;AACA,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC;AACA,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,0BAA0B,GAAG,wBAAwB,GAAG,wBAAwB,CAAC;AAEvF;AACA;AACA,MAAM,qBAAqB,GAAG,CAC1B,YAAoB,EACpB,eAAuB,EACvB,aAAqB,EACrB,mBAA2B,EAC3B,YAAoB,KACpB;;AAEA,IAAA,MAAM,kBAAkB,GACpB,mBA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C,CAAA,OAAO,EAAG,EAAA,CAAA,EAAA,CACT,EACNA,GACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,EAC1C,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,YAAY,EACd,SAAA,EAAA,gCAAgC,YAEvC,mBAAmB,IAChB,QAAQ,KAERF,IACI,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,sBAAsB,EAAE,GAAG,EAAE,kBAAkB,EAAA,QAAA,EACjE,QAAQ,EACP,CAAA,EACNA,GAAK,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,iBAAiB,EAAA,CAAI,CAChC,EAAA,CAAA,CACN,GACC,CACJ,EAAA,CAAA,EACNA,GACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB,EAAE;oBAC3C,CAAC,MAAM,CAAC,sBAAsB,GAAG,CAAC,uBAAuB,CAAC,OAAO;iBACpE,CAAC,EACF,GAAG,EAAE,yBAAyB,EAAA,QAAA,EAE9BA,GAAC,CAAA,OAAO,EAAG,EAAA,CAAA,EAAA,CACT,CACP,EAAA,CAAA,EACL;AACN;;;;"}
@@ -5,6 +5,6 @@ import 'classnames';
5
5
  import '@hh.ru/magritte-common-func-utils';
6
6
  import '@hh.ru/magritte-ui-divider';
7
7
  import './ModalHeader.js';
8
- export { M as ModalContentWithHeader } from './ModalContentWithHeader-Bz5cYjdl.js';
8
+ export { M as ModalContentWithHeader } from './ModalContentWithHeader-4iviLjKS.js';
9
9
  import '@hh.ru/magritte-ui-title';
10
10
  //# sourceMappingURL=ModalContentWithHeader.js.map
package/ModalHeader.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { RefObject } from 'react';
2
2
  export declare const ModalHeader: import("react").ForwardRefExoticComponent<{
3
- title?: import("react").ReactNode;
4
- titleSize?: import("../title/src/types").TitleSizeOptions | undefined;
5
- titleAlignment?: "center" | "left" | undefined;
6
- titleMaxLines?: number | undefined;
7
- titleElement?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
8
- titleDescription?: import("react").ReactNode;
9
- titleDescriptionMaxLines?: number | undefined;
10
- titleStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
11
- titleDescriptionStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
12
- headerImage?: string | undefined;
13
- headerHeight?: number | undefined;
3
+ title?: import("@hh.ru/magritte-ui-title").TitleProps["children"];
4
+ titleSize?: import("@hh.ru/magritte-ui-title").TitleProps["size"];
5
+ titleAlignment?: import("@hh.ru/magritte-ui-title").TitleProps["alignment"];
6
+ titleMaxLines?: import("@hh.ru/magritte-ui-title").TitleProps["maxLines"];
7
+ titleElement?: import("@hh.ru/magritte-ui-title").TitleProps["Element"];
8
+ titleDescription?: import("@hh.ru/magritte-ui-title").TitleProps["description"];
9
+ titleDescriptionMaxLines?: import("@hh.ru/magritte-ui-title").TitleProps["descriptionMaxLines"];
10
+ titleStyle?: import("@hh.ru/magritte-ui-title").TitleProps["style"];
11
+ titleDescriptionStyle?: import("@hh.ru/magritte-ui-title").TitleProps["descriptionStyle"];
12
+ headerImage?: string;
13
+ headerHeight?: number;
14
14
  } & {
15
15
  options?: import("react").ReactNode;
16
16
  actions?: import("react").ReactNode | import("react").ReactNode[];
package/ModalHeader.js CHANGED
@@ -4,7 +4,7 @@ import { forwardRef } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { Title } from '@hh.ru/magritte-ui-title';
6
6
 
7
- var styles = {"content":"magritte-content___o6ktq_5-0-7","options":"magritte-options___qfErQ_5-0-7","actions":"magritte-actions___nQILV_5-0-7","actions-with-link":"magritte-actions-with-link___hnDux_5-0-7","actionsWithLink":"magritte-actions-with-link___hnDux_5-0-7","content-with-image":"magritte-content-with-image___YarBO_5-0-7","contentWithImage":"magritte-content-with-image___YarBO_5-0-7","actions-single":"magritte-actions-single___usfKu_5-0-7","actionsSingle":"magritte-actions-single___usfKu_5-0-7","image-container":"magritte-image-container___ioL3y_5-0-7","imageContainer":"magritte-image-container___ioL3y_5-0-7","title-wrapper":"magritte-title-wrapper___O--QR_5-0-7","titleWrapper":"magritte-title-wrapper___O--QR_5-0-7","wrapper":"magritte-wrapper___zH8vB_5-0-7"};
7
+ var styles = {"content":"magritte-content___o6ktq_5-0-9","options":"magritte-options___qfErQ_5-0-9","actions":"magritte-actions___nQILV_5-0-9","actions-with-link":"magritte-actions-with-link___hnDux_5-0-9","actionsWithLink":"magritte-actions-with-link___hnDux_5-0-9","content-with-image":"magritte-content-with-image___YarBO_5-0-9","contentWithImage":"magritte-content-with-image___YarBO_5-0-9","actions-single":"magritte-actions-single___usfKu_5-0-9","actionsSingle":"magritte-actions-single___usfKu_5-0-9","image-container":"magritte-image-container___ioL3y_5-0-9","imageContainer":"magritte-image-container___ioL3y_5-0-9","title-wrapper":"magritte-title-wrapper___O--QR_5-0-9","titleWrapper":"magritte-title-wrapper___O--QR_5-0-9","wrapper":"magritte-wrapper___zH8vB_5-0-9"};
8
8
 
9
9
  const ModalHeader = forwardRef(({ title, headerImage, headerHeight, titleAlignment, titleElement, titleMaxLines, titleSize, titleDescription, titleDescriptionMaxLines, titleStyle, titleDescriptionStyle, options, actions: _actions, actionLink, labelId, wrapperRef, }, ref) => {
10
10
  const actions = Array.isArray(_actions) ? _actions.slice(0, 5) : _actions;
@@ -1 +1 @@
1
- {"version":3,"file":"ModalHeader.js","sources":["../src/ModalHeader.tsx"],"sourcesContent":["import { forwardRef, RefObject } from 'react';\nimport classnames from 'classnames';\n\nimport { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';\nimport { Title } from '@hh.ru/magritte-ui-title';\n\nimport styles from './modal-header.less';\n\nexport const ModalHeader = forwardRef<\n HTMLDivElement,\n ModalHeaderProps & { labelId: string; wrapperRef: RefObject<HTMLDivElement> }\n>(\n (\n {\n title,\n headerImage,\n headerHeight,\n titleAlignment,\n titleElement,\n titleMaxLines,\n titleSize,\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n options,\n actions: _actions,\n actionLink,\n labelId,\n wrapperRef,\n },\n ref\n ) => {\n const actions = Array.isArray(_actions) ? _actions.slice(0, 5) : _actions;\n if (!title && !headerImage && !actions && !actionLink && !options) {\n return null;\n }\n const withTitle = title && titleElement;\n const withActions = !!actions || !!actionLink;\n const currentTitleStyle = titleStyle || (headerImage ? 'contrast' : 'primary');\n const currentTitleDescriptionStyle = titleDescriptionStyle || (headerImage ? 'contrast' : 'primary');\n const withContent = title || headerImage || actionLink || actions;\n\n return (\n <div\n data-qa=\"modal-header\"\n ref={wrapperRef}\n className={styles.wrapper}\n style={headerImage ? { marginBottom: 24 } : {}}\n >\n {withContent && (\n <div\n className={classnames(styles.content, {\n [styles.contentWithImage]: !!headerImage,\n })}\n style={headerImage ? { height: headerHeight } : {}}\n ref={ref}\n data-qa=\"modal-header-image\"\n >\n {headerImage && (\n <div\n className={styles.imageContainer}\n style={{\n backgroundImage: `${\n title ? 'var(--modal-header-gradient), ' : ''\n }url(${headerImage})`,\n height: headerHeight,\n }}\n />\n )}\n {withTitle && (\n <div className={styles.titleWrapper}>\n <Title\n id={labelId}\n Element={titleElement}\n alignment={titleAlignment}\n maxLines={titleMaxLines}\n size={titleSize}\n style={currentTitleStyle}\n description={titleDescription}\n descriptionMaxLines={titleDescriptionMaxLines}\n descriptionStyle={currentTitleDescriptionStyle}\n >\n {title}\n </Title>\n </div>\n )}\n {withActions && (\n <div\n className={classnames(styles.actions, {\n [styles.actionsWithLink]: !actions && !!actionLink,\n [styles.actionsSingle]: Array.isArray(actions) ? actions.length === 1 : !!actions,\n })}\n >\n {actions || actionLink}\n </div>\n )}\n </div>\n )}\n {options && <div className={styles.options}>{options}</div>}\n </div>\n );\n }\n);\n\nModalHeader.displayName = 'ModalHeader';\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AAC,EAAA,QAAA,EAED,OAAO,IAAI,UAAU,GACpB,CACT,CAAA,EAAA,CACC,CACT,EACA,OAAO,IAAIA,aAAK,SAAS,EAAE,MAAM,CAAC,OAAO,YAAG,OAAO,EAAA,CAAO,CACzD,EAAA,CAAA,EACR;AACN,CAAC,EACH;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa;;;;"}
1
+ {"version":3,"file":"ModalHeader.js","sources":["../src/ModalHeader.tsx"],"sourcesContent":["import { forwardRef, RefObject } from 'react';\nimport classnames from 'classnames';\n\nimport { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';\nimport { Title } from '@hh.ru/magritte-ui-title';\n\nimport styles from './modal-header.less';\n\nexport const ModalHeader = forwardRef<\n HTMLDivElement,\n ModalHeaderProps & { labelId: string; wrapperRef: RefObject<HTMLDivElement> }\n>(\n (\n {\n title,\n headerImage,\n headerHeight,\n titleAlignment,\n titleElement,\n titleMaxLines,\n titleSize,\n titleDescription,\n titleDescriptionMaxLines,\n titleStyle,\n titleDescriptionStyle,\n options,\n actions: _actions,\n actionLink,\n labelId,\n wrapperRef,\n },\n ref\n ) => {\n const actions = Array.isArray(_actions) ? _actions.slice(0, 5) : _actions;\n if (!title && !headerImage && !actions && !actionLink && !options) {\n return null;\n }\n const withTitle = title && titleElement;\n const withActions = !!actions || !!actionLink;\n const currentTitleStyle = titleStyle || (headerImage ? 'contrast' : 'primary');\n const currentTitleDescriptionStyle = titleDescriptionStyle || (headerImage ? 'contrast' : 'primary');\n const withContent = title || headerImage || actionLink || actions;\n\n return (\n <div\n data-qa=\"modal-header\"\n ref={wrapperRef}\n className={styles.wrapper}\n style={headerImage ? { marginBottom: 24 } : {}}\n >\n {withContent && (\n <div\n className={classnames(styles.content, {\n [styles.contentWithImage]: !!headerImage,\n })}\n style={headerImage ? { height: headerHeight } : {}}\n ref={ref}\n data-qa=\"modal-header-image\"\n >\n {headerImage && (\n <div\n className={styles.imageContainer}\n style={{\n backgroundImage: `${\n title ? 'var(--modal-header-gradient), ' : ''\n }url(${headerImage})`,\n height: headerHeight,\n }}\n />\n )}\n {withTitle && (\n <div className={styles.titleWrapper}>\n <Title\n id={labelId}\n Element={titleElement}\n alignment={titleAlignment}\n maxLines={titleMaxLines}\n size={titleSize}\n style={currentTitleStyle}\n description={titleDescription}\n descriptionMaxLines={titleDescriptionMaxLines}\n descriptionStyle={currentTitleDescriptionStyle}\n >\n {title}\n </Title>\n </div>\n )}\n {withActions && (\n <div\n className={classnames(styles.actions, {\n [styles.actionsWithLink]: !actions && !!actionLink,\n [styles.actionsSingle]: Array.isArray(actions) ? actions.length === 1 : !!actions,\n })}\n >\n {actions || actionLink}\n </div>\n )}\n </div>\n )}\n {options && <div className={styles.options}>{options}</div>}\n </div>\n );\n }\n);\n\nModalHeader.displayName = 'ModalHeader';\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;MAQa,WAAW,GAAG,UAAU,CAIjC,CACI,EACI,KAAK,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACV,qBAAqB,EACrB,OAAO,EACP,OAAO,EAAE,QAAQ,EACjB,UAAU,EACV,OAAO,EACP,UAAU,GACb,EACD,GAAG,KACH;IACA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;AAC1E,IAAA,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE;AAC/D,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,MAAM,SAAS,GAAG,KAAK,IAAI,YAAY,CAAC;IACxC,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC;AAC9C,IAAA,MAAM,iBAAiB,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,EACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,iBAAiB,EACxB,WAAW,EAAE,gBAAgB,EAC7B,mBAAmB,EAAE,wBAAwB,EAC7C,gBAAgB,EAAE,4BAA4B,EAAA,QAAA,EAE7C,KAAK,EAAA,CACF,EACN,CAAA,CACT,EACA,WAAW,KACRA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE;4BAClC,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU;4BAClD,CAAC,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO;yBACpF,CAAC,EAAA,QAAA,EAED,OAAO,IAAI,UAAU,GACpB,CACT,CAAA,EAAA,CACC,CACT,EACA,OAAO,IAAIA,aAAK,SAAS,EAAE,MAAM,CAAC,OAAO,YAAG,OAAO,EAAA,CAAO,CACzD,EAAA,CAAA,EACR;AACN,CAAC,EACH;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa;;;;"}
package/index.css CHANGED
@@ -1,23 +1,23 @@
1
1
  :root{
2
- --magritte-color-component-modal-background-action-v19-1-1:#20262b99;
3
- --magritte-gradient-component-modal-background-fade-v19-1-1:linear-gradient(180deg, #00000000 0%, #0000007a 100%);
2
+ --magritte-color-component-modal-background-action-v19-1-2:#20262b99;
3
+ --magritte-gradient-component-modal-background-fade-v19-1-2:linear-gradient(180deg, #00000000 0%, #0000007a 100%);
4
4
  }
5
5
  :root{
6
- --magritte-static-border-radius-300-v19-1-1:12px;
7
- --magritte-static-border-radius-400-v19-1-1:16px;
6
+ --magritte-static-border-radius-300-v19-1-2:12px;
7
+ --magritte-static-border-radius-400-v19-1-2:16px;
8
8
  }
9
9
  .magritte-night-theme{
10
- --magritte-color-component-modal-background-action-v19-1-1:#20262b99;
11
- --magritte-gradient-component-modal-background-fade-v19-1-1:linear-gradient(180deg, #00000000 0%, #0000007a 100%);
10
+ --magritte-color-component-modal-background-action-v19-1-2:#20262b99;
11
+ --magritte-gradient-component-modal-background-fade-v19-1-2:linear-gradient(180deg, #00000000 0%, #0000007a 100%);
12
12
  }
13
- .magritte-content___o6ktq_5-0-7{
13
+ .magritte-content___o6ktq_5-0-9{
14
14
  display:flex;
15
15
  align-items:flex-start;
16
16
  }
17
- .magritte-content___o6ktq_5-0-7 + .magritte-options___qfErQ_5-0-7{
17
+ .magritte-content___o6ktq_5-0-9 + .magritte-options___qfErQ_5-0-9{
18
18
  margin-top:24px;
19
19
  }
20
- .magritte-actions___nQILV_5-0-7{
20
+ .magritte-actions___nQILV_5-0-9{
21
21
  position:relative;
22
22
  z-index:1;
23
23
  display:flex;
@@ -26,65 +26,65 @@
26
26
  margin-left:auto;
27
27
  --magritte-ui-link-padding-override:9px;
28
28
  }
29
- .magritte-actions-with-link___hnDux_5-0-7{
29
+ .magritte-actions-with-link___hnDux_5-0-9{
30
30
  padding:0 8px 0 28px;
31
31
  }
32
- .magritte-content-with-image___YarBO_5-0-7{
32
+ .magritte-content-with-image___YarBO_5-0-9{
33
33
  position:relative;
34
34
  flex-direction:column;
35
35
  justify-content:flex-end;
36
36
  margin:-12px -12px 0;
37
- border-radius:var(--magritte-static-border-radius-400-v19-1-1);
37
+ border-radius:var(--magritte-static-border-radius-400-v19-1-2);
38
38
  overflow:hidden;
39
39
  padding:12px 24px 24px;
40
40
  box-sizing:border-box;
41
41
  }
42
- .magritte-content-with-image___YarBO_5-0-7 .magritte-actions___nQILV_5-0-7{
42
+ .magritte-content-with-image___YarBO_5-0-9 .magritte-actions___nQILV_5-0-9{
43
43
  order:-1;
44
44
  gap:0;
45
45
  margin-right:-16px;
46
46
  margin-top:-4px;
47
47
  margin-bottom:auto;
48
48
  }
49
- .magritte-content-with-image___YarBO_5-0-7 .magritte-actions___nQILV_5-0-7:not(.magritte-actions-with-link___hnDux_5-0-7){
49
+ .magritte-content-with-image___YarBO_5-0-9 .magritte-actions___nQILV_5-0-9:not(.magritte-actions-with-link___hnDux_5-0-9){
50
50
  padding:0 4px;
51
- background-color:var(--magritte-color-component-modal-background-action-v19-1-1);
52
- border-radius:var(--magritte-static-border-radius-300-v19-1-1);
51
+ background-color:var(--magritte-color-component-modal-background-action-v19-1-2);
52
+ border-radius:var(--magritte-static-border-radius-300-v19-1-2);
53
53
  }
54
- .magritte-content-with-image___YarBO_5-0-7 .magritte-actions___nQILV_5-0-7.magritte-actions-single___usfKu_5-0-7:not(.magritte-actions-with-link___hnDux_5-0-7){
54
+ .magritte-content-with-image___YarBO_5-0-9 .magritte-actions___nQILV_5-0-9.magritte-actions-single___usfKu_5-0-9:not(.magritte-actions-with-link___hnDux_5-0-9){
55
55
  padding:0;
56
56
  }
57
- .magritte-image-container___ioL3y_5-0-7{
57
+ .magritte-image-container___ioL3y_5-0-9{
58
58
  position:absolute;
59
59
  left:0;
60
60
  bottom:0;
61
61
  right:0;
62
62
  background-size:cover;
63
- --modal-header-gradient:var(--magritte-gradient-component-modal-background-fade-v19-1-1);
63
+ --modal-header-gradient:var(--magritte-gradient-component-modal-background-fade-v19-1-2);
64
64
  }
65
- .magritte-title-wrapper___O--QR_5-0-7{
65
+ .magritte-title-wrapper___O--QR_5-0-9{
66
66
  position:relative;
67
67
  }
68
- .magritte-wrapper___zH8vB_5-0-7{
68
+ .magritte-wrapper___zH8vB_5-0-9{
69
69
  margin-bottom:24px;
70
70
  }
71
71
 
72
72
  :root{
73
- --magritte-color-background-overlay-v19-1-1:#20262b99;
74
- --magritte-color-component-modal-background-content-v19-1-1:#ffffff;
73
+ --magritte-color-background-overlay-v19-1-2:#20262b99;
74
+ --magritte-color-component-modal-background-content-v19-1-2:#ffffff;
75
75
  }
76
76
  :root{
77
- --magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-1:cubic-bezier(0.25, 0.1, 0.25, 1);
78
- --magritte-semantic-animation-ease-in-out-200-duration-v19-1-1:200ms;
79
- --magritte-semantic-animation-ease-in-out-300-timing-function-v19-1-1:cubic-bezier(0.25, 0.1, 0.25, 1);
80
- --magritte-semantic-animation-ease-in-out-300-duration-v19-1-1:300ms;
81
- --magritte-static-border-radius-600-v19-1-1:24px;
77
+ --magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-2:cubic-bezier(0.25, 0.1, 0.25, 1);
78
+ --magritte-semantic-animation-ease-in-out-200-duration-v19-1-2:200ms;
79
+ --magritte-semantic-animation-ease-in-out-300-timing-function-v19-1-2:cubic-bezier(0.25, 0.1, 0.25, 1);
80
+ --magritte-semantic-animation-ease-in-out-300-duration-v19-1-2:300ms;
81
+ --magritte-static-border-radius-600-v19-1-2:24px;
82
82
  }
83
83
  .magritte-night-theme{
84
- --magritte-color-background-overlay-v19-1-1:#20262b99;
85
- --magritte-color-component-modal-background-content-v19-1-1:#1B1B1B;
84
+ --magritte-color-background-overlay-v19-1-2:#20262b99;
85
+ --magritte-color-component-modal-background-content-v19-1-2:#1B1B1B;
86
86
  }
87
- .magritte-modal-overlay___lK22l_5-0-7{
87
+ .magritte-modal-overlay___lK22l_5-0-9{
88
88
  position:fixed;
89
89
  top:0;
90
90
  right:0;
@@ -93,11 +93,11 @@
93
93
  display:flex;
94
94
  align-items:center;
95
95
  justify-content:center;
96
- background-color:var(--magritte-color-background-overlay-v19-1-1);
96
+ background-color:var(--magritte-color-background-overlay-v19-1-2);
97
97
  z-index:1;
98
98
  user-select:text;
99
99
  }
100
- .magritte-modal___RAW6S_5-0-7{
100
+ .magritte-modal___RAW6S_5-0-9{
101
101
  display:flex;
102
102
  box-sizing:border-box;
103
103
  margin:0 20px;
@@ -105,113 +105,113 @@
105
105
  flex-direction:column;
106
106
  max-height:calc(100vh - 24px * 2);
107
107
  position:relative;
108
- background-color:var(--magritte-color-component-modal-background-content-v19-1-1);
109
- border-radius:var(--magritte-static-border-radius-600-v19-1-1);
108
+ background-color:var(--magritte-color-component-modal-background-content-v19-1-2);
109
+ border-radius:var(--magritte-static-border-radius-600-v19-1-2);
110
110
  overflow:hidden;
111
111
  width:800px;
112
112
  }
113
- .magritte-modal___RAW6S_5-0-7.magritte-size-small___2JTM2_5-0-7{
113
+ .magritte-modal___RAW6S_5-0-9.magritte-size-small___2JTM2_5-0-9{
114
114
  width:460px;
115
115
  }
116
- .magritte-modal___RAW6S_5-0-7.magritte-size-medium___cWCe7_5-0-7{
116
+ .magritte-modal___RAW6S_5-0-9.magritte-size-medium___cWCe7_5-0-9{
117
117
  width:600px;
118
118
  }
119
- .magritte-no-vertical-paddings___Z3-oM_5-0-7{
119
+ .magritte-no-vertical-paddings___Z3-oM_5-0-9{
120
120
  padding-top:0;
121
121
  padding-bottom:0;
122
122
  }
123
- .magritte-no-horizontal-paddings___aT95Y_5-0-7{
123
+ .magritte-no-horizontal-paddings___aT95Y_5-0-9{
124
124
  padding-left:0;
125
125
  padding-right:0;
126
126
  }
127
- .magritte-modal-full-height___gIM4E_5-0-7{
127
+ .magritte-modal-full-height___gIM4E_5-0-9{
128
128
  height:100%;
129
129
  }
130
- .magritte-modal-content___46QFS_5-0-7{
130
+ .magritte-modal-content___46QFS_5-0-9{
131
131
  flex:1 1;
132
132
  overflow-y:auto;
133
133
  padding:0 5px;
134
134
  margin:0 -5px;
135
135
  overscroll-behavior:none;
136
136
  }
137
- .magritte-modal-content-wrapper___23XFT_5-0-7{
137
+ .magritte-modal-content-wrapper___23XFT_5-0-9{
138
138
  display:flex;
139
139
  flex-direction:column;
140
140
  min-height:0;
141
141
  flex:1 1;
142
142
  }
143
- .magritte-modal-content-wrapper__one-line___tYg8d_5-0-7{
143
+ .magritte-modal-content-wrapper__one-line___tYg8d_5-0-9{
144
144
  flex-direction:row-reverse;
145
145
  }
146
- .magritte-divider-container___qP3VK_5-0-7{
146
+ .magritte-divider-container___qP3VK_5-0-9{
147
147
  margin:0 -24px;
148
148
  }
149
- .magritte-divider-container___qP3VK_5-0-7.magritte-divider-container-hidden___EIxB-_5-0-7{
149
+ .magritte-divider-container___qP3VK_5-0-9.magritte-divider-container-hidden___EIxB-_5-0-9{
150
150
  display:none;
151
151
  }
152
- .magritte-modal-footer___8xPqQ_5-0-7{
152
+ .magritte-modal-footer___8xPqQ_5-0-9{
153
153
  margin:0 -24px -24px;
154
- background-color:var(--magritte-color-component-modal-background-content-v19-1-1);
154
+ background-color:var(--magritte-color-component-modal-background-content-v19-1-2);
155
155
  z-index:1;
156
156
  }
157
- .magritte-modal-buttons-container___1O1Nr_5-0-7{
157
+ .magritte-modal-buttons-container___1O1Nr_5-0-9{
158
158
  display:flex;
159
159
  gap:12px;
160
160
  }
161
- .magritte-animation-timeout___w-j7K_5-0-7,
162
- .magritte-modal-animation-enter-active___E8KLu_5-0-7,
163
- .magritte-modal-animation-exit-active___ERjKa_5-0-7{
161
+ .magritte-animation-timeout___w-j7K_5-0-9,
162
+ .magritte-modal-animation-enter-active___E8KLu_5-0-9,
163
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9{
164
164
  --enter-animation-duration:0;
165
165
  --exit-animation-duration:0;
166
166
  }
167
167
  @media (prefers-reduced-motion: no-preference){
168
- .magritte-animation-timeout___w-j7K_5-0-7,
169
- .magritte-modal-animation-enter-active___E8KLu_5-0-7,
170
- .magritte-modal-animation-exit-active___ERjKa_5-0-7{
171
- --enter-animation-duration:var(--magritte-semantic-animation-ease-in-out-300-duration-v19-1-1);
172
- --exit-animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-1);
168
+ .magritte-animation-timeout___w-j7K_5-0-9,
169
+ .magritte-modal-animation-enter-active___E8KLu_5-0-9,
170
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9{
171
+ --enter-animation-duration:var(--magritte-semantic-animation-ease-in-out-300-duration-v19-1-2);
172
+ --exit-animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-1-2);
173
173
  }
174
174
  }
175
- .magritte-modal-animation-enter___kruLO_5-0-7.magritte-modal-overlay___lK22l_5-0-7{
175
+ .magritte-modal-animation-enter___kruLO_5-0-9.magritte-modal-overlay___lK22l_5-0-9{
176
176
  opacity:0;
177
177
  }
178
- .magritte-modal-animation-enter___kruLO_5-0-7 .magritte-modal___RAW6S_5-0-7{
178
+ .magritte-modal-animation-enter___kruLO_5-0-9 .magritte-modal___RAW6S_5-0-9{
179
179
  opacity:0;
180
180
  transform:scale(0.96);
181
181
  }
182
- .magritte-modal-animation-enter-active___E8KLu_5-0-7 .magritte-modal___RAW6S_5-0-7,
183
- .magritte-modal-animation-enter-active___E8KLu_5-0-7.magritte-modal-overlay___lK22l_5-0-7{
182
+ .magritte-modal-animation-enter-active___E8KLu_5-0-9 .magritte-modal___RAW6S_5-0-9,
183
+ .magritte-modal-animation-enter-active___E8KLu_5-0-9.magritte-modal-overlay___lK22l_5-0-9{
184
184
  opacity:1;
185
185
  transform:scale(1);
186
186
  transition-property:opacity, transform;
187
187
  transition-duration:var(--enter-animation-duration);
188
- transition-timing-function:var(--magritte-semantic-animation-ease-in-out-300-timing-function-v19-1-1);
188
+ transition-timing-function:var(--magritte-semantic-animation-ease-in-out-300-timing-function-v19-1-2);
189
189
  }
190
- .magritte-modal-animation-exit___0jNgl_5-0-7.magritte-modal-overlay___lK22l_5-0-7{
190
+ .magritte-modal-animation-exit___0jNgl_5-0-9.magritte-modal-overlay___lK22l_5-0-9{
191
191
  opacity:1;
192
192
  }
193
- .magritte-modal-animation-exit___0jNgl_5-0-7 .magritte-modal___RAW6S_5-0-7{
193
+ .magritte-modal-animation-exit___0jNgl_5-0-9 .magritte-modal___RAW6S_5-0-9{
194
194
  opacity:1;
195
195
  transform:scale(1);
196
196
  }
197
- .magritte-modal-animation-exit-active___ERjKa_5-0-7.magritte-modal-overlay___lK22l_5-0-7{
197
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9.magritte-modal-overlay___lK22l_5-0-9{
198
198
  opacity:0;
199
199
  }
200
- .magritte-modal-animation-exit-active___ERjKa_5-0-7 .magritte-modal___RAW6S_5-0-7{
200
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9 .magritte-modal___RAW6S_5-0-9{
201
201
  opacity:0;
202
202
  transform:scale(0.96);
203
203
  }
204
- .magritte-modal-animation-exit-active___ERjKa_5-0-7 .magritte-modal___RAW6S_5-0-7,
205
- .magritte-modal-animation-exit-active___ERjKa_5-0-7.magritte-modal-overlay___lK22l_5-0-7{
204
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9 .magritte-modal___RAW6S_5-0-9,
205
+ .magritte-modal-animation-exit-active___ERjKa_5-0-9.magritte-modal-overlay___lK22l_5-0-9{
206
206
  transition-property:opacity, transform;
207
207
  transition-duration:var(--exit-animation-duration);
208
- transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-1);
208
+ transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-1-2);
209
209
  }
210
- .magritte-content-scroll-preserver___Tw5Px_5-0-7{
210
+ .magritte-content-scroll-preserver___Tw5Px_5-0-9{
211
211
  width:100%;
212
212
  height:0;
213
213
  }
214
- .magritte-content-sticky-container___nqEXj_5-0-7{
214
+ .magritte-content-sticky-container___nqEXj_5-0-9{
215
215
  position:sticky;
216
216
  top:0;
217
217
  min-height:100%;
package/index.js CHANGED
@@ -15,7 +15,7 @@ import '@hh.ru/magritte-internal-layer-name';
15
15
  import '@hh.ru/magritte-ui-action-bar';
16
16
  import '@hh.ru/magritte-ui-breakpoint';
17
17
  import '@hh.ru/magritte-ui-layer';
18
- import './ModalContentWithHeader-Bz5cYjdl.js';
18
+ import './ModalContentWithHeader-4iviLjKS.js';
19
19
  import '@hh.ru/magritte-common-func-utils';
20
20
  import '@hh.ru/magritte-ui-divider';
21
21
  import './ModalHeader.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hh.ru/magritte-ui-modal",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -21,24 +21,24 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@hh.ru/magritte-common-dom-storage": "1.0.6",
24
- "@hh.ru/magritte-common-func-utils": "1.3.7",
24
+ "@hh.ru/magritte-common-func-utils": "1.3.8",
25
25
  "@hh.ru/magritte-common-is-server-env": "1.0.5",
26
26
  "@hh.ru/magritte-common-keyboard": "4.0.2",
27
27
  "@hh.ru/magritte-common-modal-helper": "1.2.7",
28
28
  "@hh.ru/magritte-common-use-multiple-refs": "1.1.4",
29
29
  "@hh.ru/magritte-common-use-no-bubbling": "1.0.1",
30
- "@hh.ru/magritte-design-tokens": "19.1.1",
30
+ "@hh.ru/magritte-design-tokens": "19.1.2",
31
31
  "@hh.ru/magritte-internal-layer-name": "2.2.0",
32
- "@hh.ru/magritte-ui-action": "4.4.11",
33
- "@hh.ru/magritte-ui-action-bar": "2.2.4",
34
- "@hh.ru/magritte-ui-breakpoint": "4.0.3",
35
- "@hh.ru/magritte-ui-divider": "1.1.34",
36
- "@hh.ru/magritte-ui-icon": "7.9.1",
32
+ "@hh.ru/magritte-ui-action": "4.4.12",
33
+ "@hh.ru/magritte-ui-action-bar": "2.2.5",
34
+ "@hh.ru/magritte-ui-breakpoint": "4.0.4",
35
+ "@hh.ru/magritte-ui-divider": "1.1.35",
36
+ "@hh.ru/magritte-ui-icon": "7.9.2",
37
37
  "@hh.ru/magritte-ui-layer": "2.1.0",
38
38
  "@hh.ru/magritte-ui-mock-component": "1.0.11",
39
- "@hh.ru/magritte-ui-theme-provider": "1.1.30",
40
- "@hh.ru/magritte-ui-title": "5.0.8",
41
- "@hh.ru/magritte-ui-tree-selector": "4.4.13"
39
+ "@hh.ru/magritte-ui-theme-provider": "1.1.31",
40
+ "@hh.ru/magritte-ui-title": "5.0.9",
41
+ "@hh.ru/magritte-ui-tree-selector": "4.4.15"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "classnames": ">=2.3.2",
@@ -49,5 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "2ee7f130aea18b7b405420707fe3f42f3540f22c"
52
+ "gitHead": "1ac30fb3b6ed8df5e0683e4551925b6ab8bf08d9"
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useModalOrder.js","sources":["../src/useModalOrder.ts"],"sourcesContent":["import { RefObject, useEffect, useLayoutEffect, useState } from 'react';\n\nimport { storeValueInDom, getValueFromDom, useDomStoredUniqueId } from '@hh.ru/magritte-common-dom-storage';\n\ntype NotifyCallbackArg = { position: number; count: number };\n\ntype Subscribers = Record<string, (position: NotifyCallbackArg) => void>;\ntype VisibilityMap = Record<string, boolean>;\ntype PositionMap = Record<string, number>;\n\ntype ModalCounterState = {\n prevVisiblility: VisibilityMap;\n positions: PositionMap;\n subscribers: Subscribers;\n count: number;\n};\n\nconst STORAGE_NAME = '_MAGRITTE_MODAL_COUNTER_';\n\nconst getState = (): ModalCounterState => {\n const state = getValueFromDom<ModalCounterState>(STORAGE_NAME);\n if (state === undefined) {\n return {\n prevVisiblility: {},\n positions: {},\n subscribers: {},\n count: 0,\n };\n }\n return state;\n};\n\nconst storeState = (state: ModalCounterState): void => {\n storeValueInDom(STORAGE_NAME, state);\n};\n\nconst counterFactory = () => {\n return {\n updateVisiblility: (id: string, visible: boolean) => {\n // eslint-disable-next-line prefer-const\n const state = getState();\n const prevVisible = !!state.prevVisiblility[id];\n if (visible === prevVisible) {\n return;\n }\n state.prevVisiblility[id] = visible;\n if (visible) {\n state.count += 1;\n state.positions[id] = state.count;\n } else {\n state.count -= 1;\n const currentPosition = state.positions[id];\n state.positions[id] = 0;\n Object.entries(state.positions).forEach(([key, value]) => {\n state.positions[key] = value > currentPosition ? value - 1 : value;\n });\n }\n storeState(state);\n },\n subscribe: (id: string, callback: (position: NotifyCallbackArg) => void) => {\n const state = getState();\n state.subscribers[id] = callback;\n storeState(state);\n },\n unsubscribe: (id: string) => {\n const state = getState();\n delete state.subscribers[id];\n storeState(state);\n },\n notifyAll: () => {\n const { subscribers, count, positions } = getState();\n Object.entries(subscribers).forEach(([id, callback]) => callback({ position: positions[id], count }));\n },\n };\n};\n\nconst counter = counterFactory();\n\nexport const useModalOrder = (visible: boolean, modalRef: RefObject<HTMLDivElement>): [number, number] => {\n const [position, setPosition] = useState<{ position: number; count: number }>({ position: 0, count: 0 });\n const id = useDomStoredUniqueId();\n\n useLayoutEffect(() => {\n counter.updateVisiblility(id, visible);\n counter.notifyAll();\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [visible]);\n\n useEffect(() => {\n counter.subscribe(id, setPosition);\n counter.updateVisiblility(id, visible);\n return () => {\n counter.unsubscribe(id);\n counter.updateVisiblility(id, false);\n counter.notifyAll();\n };\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [id]);\n\n useLayoutEffect(() => {\n // Если это самый \"верхний\" модал передаем туда фокус\n if (position.position === position.count && position.count > 0) {\n modalRef.current?.focus();\n }\n }, [position, modalRef]);\n\n return [position.position, position.count];\n};\n"],"names":[],"mappings":";;;AAiBA,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,MAAM,QAAQ,GAAG,MAAwB;AACrC,IAAA,MAAM,KAAK,GAAG,eAAe,CAAoB,YAAY,CAAC,CAAC;IAC/D,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO;AACH,YAAA,eAAe,EAAE,EAAE;AACnB,YAAA,SAAS,EAAE,EAAE;AACb,YAAA,WAAW,EAAE,EAAE;AACf,YAAA,KAAK,EAAE,CAAC;SACX,CAAC;AACL,KAAA;AACD,IAAA,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAAwB,KAAU;AAClD,IAAA,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAK;IACxB,OAAO;AACH,QAAA,iBAAiB,EAAE,CAAC,EAAU,EAAE,OAAgB,KAAI;;AAEhD,YA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;AACxB,SAAC,CAAC;;AAEN,KAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAET,eAAe,CAAC,MAAK;;AAEjB,QAAA,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,EAAE;AAC5D,YAAA,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;AAC7B,SAAA;AACL,KAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/C;;;;"}
1
+ {"version":3,"file":"useModalOrder.js","sources":["../src/useModalOrder.ts"],"sourcesContent":["import { RefObject, useEffect, useLayoutEffect, useState } from 'react';\n\nimport { storeValueInDom, getValueFromDom, useDomStoredUniqueId } from '@hh.ru/magritte-common-dom-storage';\n\ntype NotifyCallbackArg = { position: number; count: number };\n\ntype Subscribers = Record<string, (position: NotifyCallbackArg) => void>;\ntype VisibilityMap = Record<string, boolean>;\ntype PositionMap = Record<string, number>;\n\ntype ModalCounterState = {\n prevVisiblility: VisibilityMap;\n positions: PositionMap;\n subscribers: Subscribers;\n count: number;\n};\n\nconst STORAGE_NAME = '_MAGRITTE_MODAL_COUNTER_';\n\nconst getState = (): ModalCounterState => {\n const state = getValueFromDom<ModalCounterState>(STORAGE_NAME);\n if (state === undefined) {\n return {\n prevVisiblility: {},\n positions: {},\n subscribers: {},\n count: 0,\n };\n }\n return state;\n};\n\nconst storeState = (state: ModalCounterState): void => {\n storeValueInDom(STORAGE_NAME, state);\n};\n\nconst counterFactory = () => {\n return {\n updateVisiblility: (id: string, visible: boolean) => {\n // eslint-disable-next-line prefer-const\n const state = getState();\n const prevVisible = !!state.prevVisiblility[id];\n if (visible === prevVisible) {\n return;\n }\n state.prevVisiblility[id] = visible;\n if (visible) {\n state.count += 1;\n state.positions[id] = state.count;\n } else {\n state.count -= 1;\n const currentPosition = state.positions[id];\n state.positions[id] = 0;\n Object.entries(state.positions).forEach(([key, value]) => {\n state.positions[key] = value > currentPosition ? value - 1 : value;\n });\n }\n storeState(state);\n },\n subscribe: (id: string, callback: (position: NotifyCallbackArg) => void) => {\n const state = getState();\n state.subscribers[id] = callback;\n storeState(state);\n },\n unsubscribe: (id: string) => {\n const state = getState();\n delete state.subscribers[id];\n storeState(state);\n },\n notifyAll: () => {\n const { subscribers, count, positions } = getState();\n Object.entries(subscribers).forEach(([id, callback]) => callback({ position: positions[id], count }));\n },\n };\n};\n\nconst counter = counterFactory();\n\nexport const useModalOrder = (visible: boolean, modalRef: RefObject<HTMLDivElement>): [number, number] => {\n const [position, setPosition] = useState<{ position: number; count: number }>({ position: 0, count: 0 });\n const id = useDomStoredUniqueId();\n\n useLayoutEffect(() => {\n counter.updateVisiblility(id, visible);\n counter.notifyAll();\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [visible]);\n\n useEffect(() => {\n counter.subscribe(id, setPosition);\n counter.updateVisiblility(id, visible);\n return () => {\n counter.unsubscribe(id);\n counter.updateVisiblility(id, false);\n counter.notifyAll();\n };\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [id]);\n\n useLayoutEffect(() => {\n // Если это самый \"верхний\" модал передаем туда фокус\n if (position.position === position.count && position.count > 0) {\n modalRef.current?.focus();\n }\n }, [position, modalRef]);\n\n return [position.position, position.count];\n};\n"],"names":[],"mappings":";;;AAiBA,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,MAAM,QAAQ,GAAG,MAAwB;AACrC,IAAA,MAAM,KAAK,GAAG,eAAe,CAAoB,YAAY,CAAC,CAAC;AAC/D,IAAA,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO;AACH,YAAA,eAAe,EAAE,EAAE;AACnB,YAAA,SAAS,EAAE,EAAE;AACb,YAAA,WAAW,EAAE,EAAE;AACf,YAAA,KAAK,EAAE,C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