@hh.ru/magritte-ui-modal 4.3.21 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Modal.d.ts CHANGED
@@ -1,10 +1,22 @@
1
1
  import { HTMLAttributes } from 'react';
2
- import { ModalProps } from '@hh.ru/magritte-ui-modal/types';
3
- export declare const Modal: import("react").ForwardRefExoticComponent<(ModalProps & Omit<HTMLAttributes<HTMLDivElement>, keyof {
4
- headerImage: string;
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;
5
13
  headerHeight?: number | undefined;
6
- } | keyof {
7
- title: import("react").ReactNode;
14
+ } & {
15
+ options?: import("react").ReactNode;
16
+ actions?: import("react").ReactNode | import("react").ReactNode[];
17
+ actionLink?: import("react").ReactNode;
18
+ } & Omit<HTMLAttributes<HTMLDivElement>, keyof {
19
+ title?: import("react").ReactNode;
8
20
  titleSize?: import("../title/src/types").TitleSizeOptions | undefined;
9
21
  titleAlignment?: "center" | "left" | undefined;
10
22
  titleMaxLines?: number | undefined;
@@ -13,8 +25,10 @@ export declare const Modal: import("react").ForwardRefExoticComponent<(ModalProp
13
25
  titleDescriptionMaxLines?: number | undefined;
14
26
  titleStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
15
27
  titleDescriptionStyle?: ("primary" | "secondary" | "tertiary" | "contrast" | "contrast-secondary") | undefined;
16
- } | "className" | keyof {
28
+ headerImage?: string | undefined;
29
+ headerHeight?: number | undefined;
30
+ } | keyof {
17
31
  options?: import("react").ReactNode;
18
32
  actions?: import("react").ReactNode | import("react").ReactNode[];
19
33
  actionLink?: import("react").ReactNode;
20
- } | keyof import("@hh.ru/magritte-ui-modal/types").ModalBaseProps | keyof import("@hh.ru/magritte-ui-modal/types").ModalFooterProps | "role" | "tabindex" | "aria-labeledby">) & import("react").RefAttributes<HTMLDivElement>>;
34
+ } | "className" | keyof import("@hh.ru/magritte-ui-modal/types").ModalBaseProps | "role" | "tabindex" | "aria-labeledby"> & import("react").RefAttributes<HTMLDivElement>>;
package/Modal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import './index.css';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useRef, useState, useId, useCallback, useEffect, useLayoutEffect } from 'react';
3
+ import { forwardRef, useRef, useState, useId, useCallback, useEffect, useLayoutEffect, cloneElement } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { CSSTransition } from 'react-transition-group';
6
6
  import classnames from 'classnames';
@@ -10,13 +10,12 @@ import { disableScroll } from '@hh.ru/magritte-common-modal-helper';
10
10
  import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
11
11
  import { useNoBubbling } from '@hh.ru/magritte-common-use-no-bubbling';
12
12
  import { InternalLayerName } from '@hh.ru/magritte-internal-layer-name';
13
+ import { isActionBarComponent } from '@hh.ru/magritte-ui-action-bar';
13
14
  import { Breakpoint, useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
14
15
  import { Layer } from '@hh.ru/magritte-ui-layer';
15
- import { ModalContentWithHeader } from './ModalContentWithHeader.js';
16
- import { ModalFooter } from './ModalFooter.js';
16
+ import { s as styles, M as ModalContentWithHeader } from './ModalContentWithHeader-BZMj-Rqc.js';
17
17
  import { useModalOrder } from './useModalOrder.js';
18
18
  import { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector';
19
- import { s as styles } from './modal-B9JKYUrQ.js';
20
19
  import '@hh.ru/magritte-common-func-utils';
21
20
  import '@hh.ru/magritte-ui-divider';
22
21
  import './ModalHeader.js';
@@ -29,7 +28,7 @@ const toNumber = (value) => {
29
28
  return Number.isInteger(result) ? result : 0;
30
29
  };
31
30
  const INVISIBLE_FOR_BREAKPOINTS = [Breakpoint.XS, Breakpoint.S];
32
- const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'left', titleSize = 'large', titleMaxLines, titleElement = 'h2', titleDescription, titleDescriptionMaxLines, titleStyle, titleDescriptionStyle, children, onClose = noop, leftButtons, rightButtons, headerImage, headerHeight, host, options, actions, actionLink, ...rest }, ref) => {
31
+ const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'left', titleSize = 'large', titleMaxLines, titleElement = 'h2', titleDescription, titleDescriptionMaxLines, titleStyle, titleDescriptionStyle, children, onClose = noop, headerImage, headerHeight, host, options, actions, actionLink, footer, disableVerticalPaddings = false, disableHorizontalPaddings = false, closeByClickOutside = true, ...rest }, ref) => {
33
32
  const isServerEnv = useServerEnv();
34
33
  const enableScrollRef = useRef();
35
34
  const [animationTimeout, setAnimationTimeout] = useState({
@@ -44,6 +43,9 @@ const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'l
44
43
  const modalRef = useRef(null);
45
44
  const overlayRef = useRef(null);
46
45
  const modalRefCallback = useMultipleRefs(ref, modalRef);
46
+ const isPaddingsDisableAllowed = !title && !headerImage && !titleDescription && !footer && !options && !actionLink && !actions;
47
+ const isVerticalPaddingsDisabled = disableVerticalPaddings && isPaddingsDisableAllowed;
48
+ const isHorizontalPaddingsDisabled = disableHorizontalPaddings && isPaddingsDisableAllowed;
47
49
  const onEntering = useCallback(() => {
48
50
  if (!enableScrollRef.current) {
49
51
  enableScrollRef.current = disableScroll();
@@ -88,12 +90,18 @@ const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'l
88
90
  });
89
91
  document.body.removeChild(animationTimeoutElement);
90
92
  }, [setAnimationTimeout]);
91
- const eventHandlers = useNoBubbling({
93
+ const overlayEventHandlers = useNoBubbling({
92
94
  onKeyDown: (event) => {
93
95
  if (keyboardMatch(event.nativeEvent, keyboardKeys.Escape)) {
94
96
  onClose(event);
95
97
  }
96
98
  },
99
+ onClick: (event) => {
100
+ if (!closeByClickOutside || modalRef.current?.contains(event.target)) {
101
+ return;
102
+ }
103
+ onClose(event);
104
+ },
97
105
  });
98
106
  if (INVISIBLE_FOR_BREAKPOINTS.includes(breakpoint) || isServerEnv) {
99
107
  return null;
@@ -114,7 +122,7 @@ const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'l
114
122
  actions,
115
123
  actionLink,
116
124
  };
117
- const isModalFullHeight = isValidTreeSelectorWrapper(children);
125
+ const isTreeSelectorChild = isValidTreeSelectorWrapper(children);
118
126
  return createPortal(jsx(CSSTransition, { appear: true, in: visible && !isServerEnv, nodeRef: overlayRef, onEntering: onEntering, onExited: onExited, classNames: {
119
127
  appear: styles.modalAnimationEnter,
120
128
  appearActive: styles.modalAnimationEnterActive,
@@ -122,10 +130,15 @@ const Modal = forwardRef(({ visible, size = 'medium', title, titleAlignment = 'l
122
130
  enterActive: styles.modalAnimationEnterActive,
123
131
  exit: styles.modalAnimationExit,
124
132
  exitActive: styles.modalAnimationExitActive,
125
- }, timeout: animationTimeout, unmountOnExit: true, children: jsx(Layer, { layer: InternalLayerName.Modal, children: jsx("div", { ...eventHandlers, ref: overlayRef, className: styles.modalOverlay, style: isOverlayHidden ? { backgroundColor: 'transparent' } : {}, "data-qa": "modal-overlay", children: jsxs("div", { ...rest, ...additionalProps, role: "dialog", className: classnames(styles.modal, {
126
- [styles.modalSmall]: size === 'small',
127
- [styles.modalFullHeight]: isModalFullHeight,
128
- }), ref: modalRefCallback, tabIndex: 0, children: [jsx(ModalContentWithHeader, { ...modalHeaderProps, labelId: labelId, children: children }), jsx(ModalFooter, { leftButtons: leftButtons, rightButtons: rightButtons })] }) }) }) }), host || document.body);
133
+ }, timeout: animationTimeout, unmountOnExit: true, children: jsx(Layer, { layer: InternalLayerName.Modal, children: jsx("div", { ...overlayEventHandlers, ref: overlayRef, className: styles.modalOverlay, style: isOverlayHidden ? { backgroundColor: 'transparent' } : {}, "data-qa": "modal-overlay", children: jsxs("div", { ...rest, ...additionalProps, role: "dialog", className: classnames(styles.modal, {
134
+ [styles.sizeSmall]: size === 'small',
135
+ [styles.sizeMedium]: size === 'medium',
136
+ [styles.modalFullHeight]: isTreeSelectorChild,
137
+ [styles.noVerticalPaddings]: isVerticalPaddingsDisabled,
138
+ [styles.noHorizontalPaddings]: isHorizontalPaddingsDisabled,
139
+ }), ref: modalRefCallback, tabIndex: 0, children: [jsx(ModalContentWithHeader, { ...modalHeaderProps, labelId: labelId, isTreeSelectorChild: isTreeSelectorChild, children: children }), !!footer && (jsx("div", { className: styles.modalFooter, "data-qa": "modal-footer", children: isActionBarComponent(footer)
140
+ ? cloneElement(footer, { type: footer.props.type || 'modal' })
141
+ : footer }))] }) }) }) }), host || document.body);
129
142
  });
130
143
  Modal.displayName = 'Modal';
131
144
 
package/Modal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../src/Modal.tsx"],"sourcesContent":["import { forwardRef, HTMLAttributes, useLayoutEffect, useRef, useState, useCallback, useId, useEffect } 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 { 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 { ModalFooter } from '@hh.ru/magritte-ui-modal/ModalFooter';\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 leftButtons,\n rightButtons,\n headerImage,\n headerHeight,\n host,\n options,\n actions,\n actionLink,\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 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 eventHandlers = useNoBubbling({\n onKeyDown: (event) => {\n if (keyboardMatch(event.nativeEvent as KeyboardEvent, keyboardKeys.Escape)) {\n onClose(event);\n }\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 isModalFullHeight = 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 {...eventHandlers}\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.modalSmall]: size === 'small',\n [styles.modalFullHeight]: isModalFullHeight,\n })}\n ref={modalRefCallback}\n tabIndex={0}\n >\n <ModalContentWithHeader {...modalHeaderProps} labelId={labelId}>\n {children}\n </ModalContentWithHeader>\n <ModalFooter leftButtons={leftButtons} rightButtons={rightButtons} />\n </div>\n </div>\n </Layer>\n </CSSTransition>,\n host || document.body\n );\n }\n);\n\nModal.displayName = 'Modal';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,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;AAEzD,MAAM,KAAK,GAAG,UAAU,CAK3B,CACI,EACI,OAAO,EACP,IAAI,GAAG,QAAQ,EACf,KAAK,EACL,cAAc,GAAG,MAAM,EAC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CACnE,GACJ,EACF,CAAA,EAAA,CACI,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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AC,QAAQ,EACb,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE;AAChC,wBAAA,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,KAAK,OAAO;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;;;;"}
@@ -0,0 +1,132 @@
1
+ import './index.css';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useRef, useCallback, useLayoutEffect } from 'react';
4
+ import classnames from 'classnames';
5
+ import { requestAnimation } from '@hh.ru/magritte-common-func-utils';
6
+ import { Divider } from '@hh.ru/magritte-ui-divider';
7
+ import { ModalHeader } from './ModalHeader.js';
8
+
9
+ var styles = {"modal-overlay":"magritte-modal-overlay___lK22l_5-0-0","modalOverlay":"magritte-modal-overlay___lK22l_5-0-0","modal":"magritte-modal___RAW6S_5-0-0","size-small":"magritte-size-small___2JTM2_5-0-0","sizeSmall":"magritte-size-small___2JTM2_5-0-0","size-medium":"magritte-size-medium___cWCe7_5-0-0","sizeMedium":"magritte-size-medium___cWCe7_5-0-0","no-vertical-paddings":"magritte-no-vertical-paddings___Z3-oM_5-0-0","noVerticalPaddings":"magritte-no-vertical-paddings___Z3-oM_5-0-0","no-horizontal-paddings":"magritte-no-horizontal-paddings___aT95Y_5-0-0","noHorizontalPaddings":"magritte-no-horizontal-paddings___aT95Y_5-0-0","modal-full-height":"magritte-modal-full-height___gIM4E_5-0-0","modalFullHeight":"magritte-modal-full-height___gIM4E_5-0-0","modal-content":"magritte-modal-content___46QFS_5-0-0","modalContent":"magritte-modal-content___46QFS_5-0-0","modal-content-wrapper":"magritte-modal-content-wrapper___23XFT_5-0-0","modalContentWrapper":"magritte-modal-content-wrapper___23XFT_5-0-0","modal-content-wrapper__one-line":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-0","modalContentWrapperOneLine":"magritte-modal-content-wrapper__one-line___tYg8d_5-0-0","divider-container":"magritte-divider-container___qP3VK_5-0-0","dividerContainer":"magritte-divider-container___qP3VK_5-0-0","divider-container-hidden":"magritte-divider-container-hidden___EIxB-_5-0-0","dividerContainerHidden":"magritte-divider-container-hidden___EIxB-_5-0-0","modal-footer":"magritte-modal-footer___8xPqQ_5-0-0","modalFooter":"magritte-modal-footer___8xPqQ_5-0-0","modal-buttons-container":"magritte-modal-buttons-container___1O1Nr_5-0-0","modalButtonsContainer":"magritte-modal-buttons-container___1O1Nr_5-0-0","animation-timeout":"magritte-animation-timeout___w-j7K_5-0-0","animationTimeout":"magritte-animation-timeout___w-j7K_5-0-0","modal-animation-enter-active":"magritte-modal-animation-enter-active___E8KLu_5-0-0","modalAnimationEnterActive":"magritte-modal-animation-enter-active___E8KLu_5-0-0","modal-animation-exit-active":"magritte-modal-animation-exit-active___ERjKa_5-0-0","modalAnimationExitActive":"magritte-modal-animation-exit-active___ERjKa_5-0-0","modal-animation-enter":"magritte-modal-animation-enter___kruLO_5-0-0","modalAnimationEnter":"magritte-modal-animation-enter___kruLO_5-0-0","modal-animation-exit":"magritte-modal-animation-exit___0jNgl_5-0-0","modalAnimationExit":"magritte-modal-animation-exit___0jNgl_5-0-0","content-scroll-preserver":"magritte-content-scroll-preserver___Tw5Px_5-0-0","contentScrollPreserver":"magritte-content-scroll-preserver___Tw5Px_5-0-0","content-sticky-container":"magritte-content-sticky-container___nqEXj_5-0-0","contentStickyContainer":"magritte-content-sticky-container___nqEXj_5-0-0"};
10
+
11
+ const checkIsScrolledToBottom = (el) => {
12
+ return Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1;
13
+ };
14
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
15
+ // Минимальная высота до которой может сжаться хедер
16
+ const HEADER_SHRINK_MIN_HEIGHT = 148;
17
+ // Минимальная высота отступа между хедером и контентом
18
+ const HEADER_MARGIN_MIN_HEIGHT = 12;
19
+ // Максимальная высота отступа между хедером и контентом
20
+ const HEADER_MARGIN_MAX_HEIGHT = 24;
21
+ const HEADER_MARGIN_HEIGHT_DELTA = HEADER_MARGIN_MAX_HEIGHT - HEADER_MARGIN_MIN_HEIGHT;
22
+ // Вычисляет минимальную высоту до которой может сжаться хедер с учетом высоты контента, чтобы не спровоцировать
23
+ // изменение размера модалки
24
+ const calcHeaderShrinkLimit = (headerHeight, headerMaxHeight, contentHeight, contentScrollHeight, marginHeight) => {
25
+ // Высота контента скрытого под скроллом когда хедер и марджин под ним имеет максимальную допустимую высоту
26
+ const contentScrollDelta = contentScrollHeight - // Высота контента скрытого под скроллом в текущем состоянии
27
+ contentHeight + // Высота контейнера содержащего контент
28
+ (HEADER_MARGIN_MAX_HEIGHT - marginHeight) + // Дельта между текущей высотой марджина и максимальной допустимой
29
+ (headerMaxHeight - headerHeight); // Дельта между текущей высотой хедера и максимальной допустимой
30
+ const headerShrinkMinHeight = headerMaxHeight - (contentScrollDelta - HEADER_MARGIN_HEIGHT_DELTA);
31
+ return Math.max(headerShrinkMinHeight, HEADER_SHRINK_MIN_HEIGHT);
32
+ };
33
+ const shrinkByDelta = (headerImageContainer, headerWrapper, headerMinHeight, headerMaxHeight, scrollDeltaY) => {
34
+ if (!headerImageContainer || !headerWrapper) {
35
+ return;
36
+ }
37
+ const marginHeight = clamp(HEADER_MARGIN_MAX_HEIGHT - scrollDeltaY, HEADER_MARGIN_MIN_HEIGHT, HEADER_MARGIN_MAX_HEIGHT);
38
+ headerWrapper.style.marginBottom = `${marginHeight}px`;
39
+ const headerHeight = clamp(
40
+ // Тут прибаляем дельту марджина потому что сначала должен сжаться отступ
41
+ Math.floor(headerMaxHeight - scrollDeltaY + HEADER_MARGIN_HEIGHT_DELTA), headerMinHeight, headerMaxHeight);
42
+ headerImageContainer.style.height = `${headerHeight}px`;
43
+ };
44
+ const ModalContentWithHeader = ({ labelId, children, headerHeight: _headerHeight = 0, isTreeSelectorChild, ...modalHeaderProps }) => {
45
+ const { title, headerImage, actions, actionLink, options } = modalHeaderProps;
46
+ const bottomDividerVisibleRef = useRef(false);
47
+ const contentContainerRef = useRef(null);
48
+ const headerImageContainerRef = useRef(null);
49
+ const headerWrapperRef = useRef(null);
50
+ const spacePreserverRef = useRef(null);
51
+ const stickyContainerRef = useRef(null);
52
+ const headerHeightRef = useRef(0);
53
+ const minHeaderHeightRef = useRef(0);
54
+ const headerImageRef = useRef(!!headerImage);
55
+ headerHeightRef.current = headerImage ? Math.max(_headerHeight, 200) : 0;
56
+ headerImageRef.current = !!headerImage;
57
+ const bottomDividerContainerRef = useRef(null);
58
+ const topDividerContainerRef = useRef(null);
59
+ const withoutHeader = !title && !headerImage && !actions && !actionLink && !options;
60
+ const onlyActions = !title && !headerImage && !options && (actions || actionLink);
61
+ const isTopDividerVisible = () => {
62
+ if (!contentContainerRef.current) {
63
+ return false;
64
+ }
65
+ const topDividerVisible = headerImageRef.current
66
+ ? contentContainerRef.current.scrollTop >
67
+ headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA
68
+ : contentContainerRef.current.scrollTop !== 0;
69
+ return topDividerVisible && (options || !headerImage) && !onlyActions && !withoutHeader;
70
+ };
71
+ const updateHeaderDimensions = useCallback(() => {
72
+ if (!headerImageContainerRef.current ||
73
+ !headerWrapperRef.current ||
74
+ !stickyContainerRef.current ||
75
+ !spacePreserverRef.current ||
76
+ !contentContainerRef.current) {
77
+ return;
78
+ }
79
+ if (!headerImageRef.current) {
80
+ spacePreserverRef.current.style.height = '0';
81
+ return;
82
+ }
83
+ minHeaderHeightRef.current = calcHeaderShrinkLimit(headerImageContainerRef.current.clientHeight, headerHeightRef.current, contentContainerRef.current.clientHeight, stickyContainerRef.current.scrollHeight, parseInt(headerWrapperRef.current.style.marginBottom || '0', 10));
84
+ shrinkByDelta(headerImageContainerRef.current, headerWrapperRef.current, minHeaderHeightRef.current, headerHeightRef.current, contentContainerRef.current.scrollTop);
85
+ const preserverSize = headerHeightRef.current - minHeaderHeightRef.current + HEADER_MARGIN_HEIGHT_DELTA;
86
+ spacePreserverRef.current.style.height = `${preserverSize}px`;
87
+ }, []);
88
+ useLayoutEffect(() => {
89
+ if (contentContainerRef.current) {
90
+ const observer = new ResizeObserver(requestAnimation(() => {
91
+ if (!contentContainerRef.current) {
92
+ return;
93
+ }
94
+ const isScrollable = contentContainerRef.current.scrollHeight > contentContainerRef.current.clientHeight;
95
+ const hasScroll = isScrollable && !checkIsScrolledToBottom(contentContainerRef.current);
96
+ bottomDividerVisibleRef.current = hasScroll;
97
+ bottomDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !bottomDividerVisibleRef.current);
98
+ updateHeaderDimensions();
99
+ }));
100
+ observer.observe(contentContainerRef.current);
101
+ return () => observer.disconnect();
102
+ }
103
+ return undefined;
104
+ }, [updateHeaderDimensions]);
105
+ useLayoutEffect(() => {
106
+ updateHeaderDimensions();
107
+ if (!options && headerImage) {
108
+ topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, true);
109
+ }
110
+ }, [headerImage, updateHeaderDimensions, options]);
111
+ const handleScroll = () => {
112
+ if (!contentContainerRef.current) {
113
+ return;
114
+ }
115
+ bottomDividerVisibleRef.current = !checkIsScrolledToBottom(contentContainerRef.current);
116
+ bottomDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !bottomDividerVisibleRef.current);
117
+ topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !isTopDividerVisible());
118
+ if (headerImageRef.current) {
119
+ shrinkByDelta(headerImageContainerRef.current, headerWrapperRef.current, minHeaderHeightRef.current, headerHeightRef.current, contentContainerRef.current.scrollTop);
120
+ }
121
+ };
122
+ return (jsxs(Fragment, { children: [jsxs("div", { className: classnames(styles.modalContentWrapper, {
123
+ [styles.modalContentWrapperOneLine]: onlyActions,
124
+ }), children: [jsx(ModalHeader, { ...modalHeaderProps, headerHeight: headerHeightRef.current, labelId: labelId, wrapperRef: headerWrapperRef, ref: headerImageContainerRef }), jsx("div", { className: classnames(styles.dividerContainer, {
125
+ [styles.dividerContainerHidden]: !isTopDividerVisible(),
126
+ }), ref: topDividerContainerRef, children: jsx(Divider, {}) }), jsx("div", { className: classnames(styles.modalContent), ref: contentContainerRef, onScroll: handleScroll, "data-qa": "modal-content-scroll-container", children: isTreeSelectorChild ? (children) : (jsxs(Fragment, { children: [jsx("div", { className: styles.contentStickyContainer, ref: stickyContainerRef, children: children }), jsx("div", { ref: spacePreserverRef })] })) })] }), jsx("div", { className: classnames(styles.dividerContainer, {
127
+ [styles.dividerContainerHidden]: !bottomDividerVisibleRef.current,
128
+ }), ref: bottomDividerContainerRef, children: jsx(Divider, {}) })] }));
129
+ };
130
+
131
+ export { ModalContentWithHeader as M, styles as s };
132
+ //# sourceMappingURL=ModalContentWithHeader-BZMj-Rqc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalContentWithHeader-BZMj-Rqc.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,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BAAsB,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;;;;"}
@@ -2,4 +2,5 @@ import { FC, PropsWithChildren } from 'react';
2
2
  import { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';
3
3
  export declare const ModalContentWithHeader: FC<PropsWithChildren<ModalHeaderProps & {
4
4
  labelId: string;
5
+ isTreeSelectorChild: boolean;
5
6
  }>>;
@@ -1,70 +1,10 @@
1
1
  import './index.css';
2
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
- import { useRef, useLayoutEffect } from 'react';
4
- import classnames from 'classnames';
5
- import { requestAnimation } from '@hh.ru/magritte-common-func-utils';
6
- import { Divider } from '@hh.ru/magritte-ui-divider';
7
- import { ModalHeader } from './ModalHeader.js';
8
- import { s as styles } from './modal-B9JKYUrQ.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import 'classnames';
5
+ import '@hh.ru/magritte-common-func-utils';
6
+ import '@hh.ru/magritte-ui-divider';
7
+ import './ModalHeader.js';
8
+ export { M as ModalContentWithHeader } from './ModalContentWithHeader-BZMj-Rqc.js';
9
9
  import '@hh.ru/magritte-ui-title';
10
-
11
- const checkIsScrolledToBottom = (el) => {
12
- return Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1;
13
- };
14
- const ModalContentWithHeader = ({ labelId, children, ...modalHeaderProps }) => {
15
- const { title, headerImage, actions, actionLink, options } = modalHeaderProps;
16
- const topDividerVisibleRef = useRef(false);
17
- const bottomDividerVisibleRef = useRef(false);
18
- const contentContainerRef = useRef(null);
19
- /*
20
- * Для управления отображением элементов и переключения стилизации используются рефы вместо стейта.
21
- * Так сделано потому, что при изменении стилей контент внутри модала смещается. При этом внутри модала могут быть
22
- * активаторы вызывающие показ дропов. Дропы обновляют свое позиционирование при скролле. Если обновлять стили
23
- * с помощью изменения стейта, то новые стили будут применяться асинхронно, после вычисления дропом новой позиции.
24
- * Это приведет к тому, что дропы будут позиционироваться не корректно в части случаев. Поэтому классы переключаются
25
- * синхронно, а состояние сохраняется в рефы чтобы при ререндере стили были актуальными.
26
- */
27
- const bottomDividerContainerRef = useRef(null);
28
- const topDividerContainerRef = useRef(null);
29
- const withoutHeader = !title && !headerImage && !actions && !actionLink && !options;
30
- const onlyActions = !title && !headerImage && !options && (actions || actionLink);
31
- const isTopDividerVisible = () => topDividerVisibleRef.current && (options || !headerImage) && !onlyActions && !withoutHeader;
32
- useLayoutEffect(() => {
33
- if (contentContainerRef.current) {
34
- const observer = new ResizeObserver(requestAnimation(() => {
35
- if (!contentContainerRef.current) {
36
- return;
37
- }
38
- const isScrollable = contentContainerRef.current.scrollHeight > contentContainerRef.current.clientHeight;
39
- const hasScroll = isScrollable && !checkIsScrolledToBottom(contentContainerRef.current);
40
- bottomDividerVisibleRef.current = hasScroll;
41
- bottomDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !bottomDividerVisibleRef.current);
42
- }));
43
- observer.observe(contentContainerRef.current);
44
- return () => observer.disconnect();
45
- }
46
- return undefined;
47
- }, []);
48
- const handleScroll = () => {
49
- if (!contentContainerRef.current) {
50
- return;
51
- }
52
- topDividerVisibleRef.current = contentContainerRef.current.scrollTop !== 0;
53
- bottomDividerVisibleRef.current = !checkIsScrolledToBottom(contentContainerRef.current);
54
- contentContainerRef.current.classList.toggle(styles.modalContentWithDivider, !!(topDividerVisibleRef.current && headerImage && !options));
55
- bottomDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !bottomDividerVisibleRef.current);
56
- topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !isTopDividerVisible());
57
- };
58
- return (jsxs(Fragment, { children: [jsxs("div", { className: classnames(styles.modalContentWrapper, {
59
- [styles.modalContentWrapperOneLine]: onlyActions,
60
- }), children: [jsx(ModalHeader, { ...modalHeaderProps, labelId: labelId }), jsx("div", { className: classnames(styles.dividerContainer, {
61
- [styles.dividerContainerHidden]: !isTopDividerVisible(),
62
- }), ref: topDividerContainerRef, children: jsx(Divider, {}) }), jsx("div", { className: classnames(styles.modalContent, {
63
- [styles.modalContentWithDivider]: topDividerVisibleRef.current && headerImage && !options,
64
- }), ref: contentContainerRef, onScroll: handleScroll, children: children })] }), jsx("div", { className: classnames(styles.dividerContainer, {
65
- [styles.dividerContainerHidden]: !bottomDividerVisibleRef.current,
66
- }), ref: bottomDividerContainerRef, children: jsx(Divider, {}) })] }));
67
- };
68
-
69
- export { ModalContentWithHeader };
70
10
  //# sourceMappingURL=ModalContentWithHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalContentWithHeader.js","sources":["../src/ModalContentWithHeader.tsx"],"sourcesContent":["import { FC, PropsWithChildren, 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\nexport const ModalContentWithHeader: FC<PropsWithChildren<ModalHeaderProps & { labelId: string }>> = ({\n labelId,\n children,\n ...modalHeaderProps\n}) => {\n const { title, headerImage, actions, actionLink, options } = modalHeaderProps;\n const topDividerVisibleRef = useRef(false);\n const bottomDividerVisibleRef = useRef(false);\n const contentContainerRef = useRef<HTMLDivElement>(null);\n\n /*\n * Для управления отображением элементов и переключения стилизации используются рефы вместо стейта.\n * Так сделано потому, что при изменении стилей контент внутри модала смещается. При этом внутри модала могут быть\n * активаторы вызывающие показ дропов. Дропы обновляют свое позиционирование при скролле. Если обновлять стили\n * с помощью изменения стейта, то новые стили будут применяться асинхронно, после вычисления дропом новой позиции.\n * Это приведет к тому, что дропы будут позиционироваться не корректно в части случаев. Поэтому классы переключаются\n * синхронно, а состояние сохраняется в рефы чтобы при ререндере стили были актуальными.\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 topDividerVisibleRef.current && (options || !headerImage) && !onlyActions && !withoutHeader;\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 })\n );\n observer.observe(contentContainerRef.current);\n return () => observer.disconnect();\n }\n\n return undefined;\n }, []);\n\n const handleScroll = () => {\n if (!contentContainerRef.current) {\n return;\n }\n topDividerVisibleRef.current = contentContainerRef.current.scrollTop !== 0;\n bottomDividerVisibleRef.current = !checkIsScrolledToBottom(contentContainerRef.current);\n contentContainerRef.current.classList.toggle(\n styles.modalContentWithDivider,\n !!(topDividerVisibleRef.current && headerImage && !options)\n );\n bottomDividerContainerRef.current?.classList.toggle(\n styles.dividerContainerHidden,\n !bottomDividerVisibleRef.current\n );\n topDividerContainerRef.current?.classList.toggle(styles.dividerContainerHidden, !isTopDividerVisible());\n };\n return (\n <>\n <div\n className={classnames(styles.modalContentWrapper, {\n [styles.modalContentWrapperOneLine]: onlyActions,\n })}\n >\n <ModalHeader {...modalHeaderProps} labelId={labelId} />\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 [styles.modalContentWithDivider]: topDividerVisibleRef.current && headerImage && !options,\n })}\n ref={contentContainerRef}\n onScroll={handleScroll}\n >\n {children}\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;AAEK,MAAM,sBAAsB,GAAkE,CAAC,EAClG,OAAO,EACP,QAAQ,EACR,GAAG,gBAAgB,EACtB,KAAI;AACD,IAAA,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;AAC9E,IAAA,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3C,IAAA,MAAM,uBAAuB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9C,IAAA,MAAM,mBAAmB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAEzD;;;;;;;AAOG;AACH,IAAA,MAAM,yBAAyB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAC/D,IAAA,MAAM,sBAAsB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAE5D,IAAA,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC;AACpF,IAAA,MAAM,WAAW,GAAG,CAAC,KAAK,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GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,YAAY,EAErB,QAAA,EAAA,QAAQ,GACP,CACJ,EAAA,CAAA,EACNA,aACI,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.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/ModalHeader.d.ts CHANGED
@@ -1,5 +1,21 @@
1
- import { FC } from 'react';
2
- import { ModalHeaderProps } from '@hh.ru/magritte-ui-modal/types';
3
- export declare const ModalHeader: FC<ModalHeaderProps & {
1
+ import { RefObject } from 'react';
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;
14
+ } & {
15
+ options?: import("react").ReactNode;
16
+ actions?: import("react").ReactNode | import("react").ReactNode[];
17
+ actionLink?: import("react").ReactNode;
18
+ } & {
4
19
  labelId: string;
5
- }>;
20
+ wrapperRef: RefObject<HTMLDivElement>;
21
+ } & import("react").RefAttributes<HTMLDivElement>>;
package/ModalHeader.js CHANGED
@@ -1,33 +1,32 @@
1
1
  import './index.css';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { forwardRef } from 'react';
3
4
  import classnames from 'classnames';
4
5
  import { Title } from '@hh.ru/magritte-ui-title';
5
6
 
6
- var styles = {"wrapper":"magritte-wrapper___zH8vB_4-3-21","content":"magritte-content___o6ktq_4-3-21","options":"magritte-options___qfErQ_4-3-21","content-with-image":"magritte-content-with-image___YarBO_4-3-21","contentWithImage":"magritte-content-with-image___YarBO_4-3-21","actions":"magritte-actions___nQILV_4-3-21","actions-with-link":"magritte-actions-with-link___hnDux_4-3-21","actionsWithLink":"magritte-actions-with-link___hnDux_4-3-21","actions-single":"magritte-actions-single___usfKu_4-3-21","actionsSingle":"magritte-actions-single___usfKu_4-3-21"};
7
+ var styles = {"content":"magritte-content___o6ktq_5-0-0","options":"magritte-options___qfErQ_5-0-0","actions":"magritte-actions___nQILV_5-0-0","actions-with-link":"magritte-actions-with-link___hnDux_5-0-0","actionsWithLink":"magritte-actions-with-link___hnDux_5-0-0","content-with-image":"magritte-content-with-image___YarBO_5-0-0","contentWithImage":"magritte-content-with-image___YarBO_5-0-0","actions-single":"magritte-actions-single___usfKu_5-0-0","actionsSingle":"magritte-actions-single___usfKu_5-0-0","image-container":"magritte-image-container___ioL3y_5-0-0","imageContainer":"magritte-image-container___ioL3y_5-0-0","title-wrapper":"magritte-title-wrapper___O--QR_5-0-0","titleWrapper":"magritte-title-wrapper___O--QR_5-0-0","wrapper":"magritte-wrapper___zH8vB_5-0-0"};
7
8
 
8
- const ModalHeader = ({ title, headerImage, headerHeight = 0, titleAlignment, titleElement, titleMaxLines, titleSize, titleDescription, titleDescriptionMaxLines, titleStyle, titleDescriptionStyle, options, actions: _actions, actionLink, labelId, }) => {
9
+ const ModalHeader = forwardRef(({ title, headerImage, headerHeight, titleAlignment, titleElement, titleMaxLines, titleSize, titleDescription, titleDescriptionMaxLines, titleStyle, titleDescriptionStyle, options, actions: _actions, actionLink, labelId, wrapperRef, }, ref) => {
9
10
  const actions = Array.isArray(_actions) ? _actions.slice(0, 5) : _actions;
10
11
  if (!title && !headerImage && !actions && !actionLink && !options) {
11
12
  return null;
12
13
  }
13
14
  const withTitle = title && titleElement;
14
15
  const withActions = !!actions || !!actionLink;
15
- const minHeight = headerImage ? Math.max(headerHeight, 200) : 0;
16
16
  const currentTitleStyle = titleStyle || (headerImage ? 'contrast' : 'primary');
17
17
  const currentTitleDescriptionStyle = titleDescriptionStyle || (headerImage ? 'contrast' : 'primary');
18
18
  const withContent = title || headerImage || actionLink || actions;
19
- return (jsxs("div", { "data-qa": "modal-header", className: styles.wrapper, children: [withContent && (jsxs("div", { className: classnames(styles.content, {
19
+ return (jsxs("div", { "data-qa": "modal-header", ref: wrapperRef, className: styles.wrapper, style: headerImage ? { marginBottom: 24 } : {}, children: [withContent && (jsxs("div", { className: classnames(styles.content, {
20
20
  [styles.contentWithImage]: !!headerImage,
21
- }), "data-qa": "modal-header-image", style: {
22
- backgroundImage: headerImage
23
- ? `${title ? 'var(--modal-header-gradient), ' : ''}url(${headerImage})`
24
- : 'none',
25
- minHeight,
26
- }, children: [withTitle && (jsx(Title, { id: labelId, Element: titleElement, alignment: titleAlignment, maxLines: titleMaxLines, size: titleSize, style: currentTitleStyle, description: titleDescription, descriptionMaxLines: titleDescriptionMaxLines, descriptionStyle: currentTitleDescriptionStyle, children: title })), withActions && (jsx("div", { className: classnames(styles.actions, {
21
+ }), style: headerImage ? { height: headerHeight } : {}, ref: ref, "data-qa": "modal-header-image", children: [headerImage && (jsx("div", { className: styles.imageContainer, style: {
22
+ backgroundImage: `${title ? 'var(--modal-header-gradient), ' : ''}url(${headerImage})`,
23
+ height: headerHeight,
24
+ } })), withTitle && (jsx("div", { className: styles.titleWrapper, children: jsx(Title, { id: labelId, Element: titleElement, alignment: titleAlignment, maxLines: titleMaxLines, size: titleSize, style: currentTitleStyle, description: titleDescription, descriptionMaxLines: titleDescriptionMaxLines, descriptionStyle: currentTitleDescriptionStyle, children: title }) })), withActions && (jsx("div", { className: classnames(styles.actions, {
27
25
  [styles.actionsWithLink]: !actions && !!actionLink,
28
26
  [styles.actionsSingle]: Array.isArray(actions) ? actions.length === 1 : !!actions,
29
27
  }), children: actions || actionLink }))] })), options && jsx("div", { className: styles.options, children: options })] }));
30
- };
28
+ });
29
+ ModalHeader.displayName = 'ModalHeader';
31
30
 
32
31
  export { ModalHeader };
33
32
  //# sourceMappingURL=ModalHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalHeader.js","sources":["../src/ModalHeader.tsx"],"sourcesContent":["import { FC } 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: FC<ModalHeaderProps & { labelId: string }> = ({\n title,\n headerImage,\n headerHeight = 0,\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}) => {\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 minHeight = headerImage ? Math.max(headerHeight, 200) : 0;\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 data-qa=\"modal-header\" className={styles.wrapper}>\n {withContent && (\n <div\n className={classnames(styles.content, {\n [styles.contentWithImage]: !!headerImage,\n })}\n data-qa=\"modal-header-image\"\n style={{\n backgroundImage: headerImage\n ? `${title ? 'var(--modal-header-gradient), ' : ''}url(${headerImage})`\n : 'none',\n minHeight,\n }}\n >\n {withTitle && (\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 )}\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"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAQa,MAAA,WAAW,GAA+C,CAAC,EACpE,KAAK,EACL,WAAW,EACX,YAAY,GAAG,CAAC,EAChB,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,GACV,KAAI;IACD,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;AACf,KAAA;AACD,IAAA,MAAM,SAAS,GAAG,KAAK,IAAI,YAAY,CAAC;IACxC,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC;AAC9C,IAAA,MAAM,SAAS,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAChE,IAAA,MAAM,iBAAiB,GAAG,UAAU,KAAK,WAAW,GAAG,UAA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M,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;;;;"}
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;AACf,KAAA;AACD,IAAA,MAAM,SAAS,GAAG,KAAK,IAAI,YAAY,CAAC;IACxC,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC;AAC9C,IAAA,MAAM,iB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,aAAa,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
@@ -4,59 +4,70 @@
4
4
  }
5
5
  :root{
6
6
  --magritte-static-border-radius-300-v19-0-0:12px;
7
- --magritte-static-border-radius-600-v19-0-0:24px;
7
+ --magritte-static-border-radius-400-v19-0-0:16px;
8
8
  }
9
9
  .magritte-night-theme{
10
10
  --magritte-color-component-modal-background-action-v19-0-0:#20262b99;
11
11
  --magritte-gradient-component-modal-background-fade-v19-0-0:linear-gradient(180deg, #00000000 0%, #0000007a 100%);
12
12
  }
13
- .magritte-wrapper___zH8vB_4-3-21{
14
- margin-bottom:32px;
15
- }
16
- .magritte-content___o6ktq_4-3-21{
13
+ .magritte-content___o6ktq_5-0-0{
17
14
  display:flex;
18
15
  align-items:flex-start;
19
16
  }
20
- .magritte-content___o6ktq_4-3-21 + .magritte-options___qfErQ_4-3-21{
17
+ .magritte-content___o6ktq_5-0-0 + .magritte-options___qfErQ_5-0-0{
21
18
  margin-top:24px;
22
19
  }
23
- .magritte-content___o6ktq_4-3-21.magritte-content-with-image___YarBO_4-3-21 + .magritte-options___qfErQ_4-3-21{
24
- margin-top:32px;
25
- }
26
- .magritte-actions___nQILV_4-3-21{
20
+ .magritte-actions___nQILV_5-0-0{
21
+ position:relative;
22
+ z-index:1;
27
23
  display:flex;
28
24
  padding-left:16px;
29
25
  gap:4px;
30
26
  margin-left:auto;
31
27
  --magritte-ui-link-padding-override:9px;
32
28
  }
33
- .magritte-actions-with-link___hnDux_4-3-21{
29
+ .magritte-actions-with-link___hnDux_5-0-0{
34
30
  padding:0 8px 0 28px;
35
31
  }
36
- .magritte-content-with-image___YarBO_4-3-21{
32
+ .magritte-content-with-image___YarBO_5-0-0{
33
+ position:relative;
37
34
  flex-direction:column;
38
35
  justify-content:flex-end;
39
- margin:-20px -20px 0;
40
- background-size:cover;
41
- --modal-header-gradient:var(--magritte-gradient-component-modal-background-fade-v19-0-0);
42
- border-radius:var(--magritte-static-border-radius-600-v19-0-0);
36
+ margin:-12px -12px 0;
37
+ border-radius:var(--magritte-static-border-radius-400-v19-0-0);
38
+ overflow:hidden;
43
39
  padding:12px 24px 24px;
44
40
  box-sizing:border-box;
45
41
  }
46
- .magritte-content-with-image___YarBO_4-3-21 .magritte-actions___nQILV_4-3-21{
42
+ .magritte-content-with-image___YarBO_5-0-0 .magritte-actions___nQILV_5-0-0{
47
43
  order:-1;
48
44
  gap:0;
49
- margin-right:-12px;
45
+ margin-right:-16px;
46
+ margin-top:-4px;
50
47
  margin-bottom:auto;
51
48
  }
52
- .magritte-content-with-image___YarBO_4-3-21 .magritte-actions___nQILV_4-3-21:not(.magritte-actions-with-link___hnDux_4-3-21){
49
+ .magritte-content-with-image___YarBO_5-0-0 .magritte-actions___nQILV_5-0-0:not(.magritte-actions-with-link___hnDux_5-0-0){
53
50
  padding:0 4px;
54
51
  background-color:var(--magritte-color-component-modal-background-action-v19-0-0);
55
52
  border-radius:var(--magritte-static-border-radius-300-v19-0-0);
56
53
  }
57
- .magritte-content-with-image___YarBO_4-3-21 .magritte-actions___nQILV_4-3-21.magritte-actions-single___usfKu_4-3-21:not(.magritte-actions-with-link___hnDux_4-3-21){
54
+ .magritte-content-with-image___YarBO_5-0-0 .magritte-actions___nQILV_5-0-0.magritte-actions-single___usfKu_5-0-0:not(.magritte-actions-with-link___hnDux_5-0-0){
58
55
  padding:0;
59
56
  }
57
+ .magritte-image-container___ioL3y_5-0-0{
58
+ position:absolute;
59
+ left:0;
60
+ bottom:0;
61
+ right:0;
62
+ background-size:cover;
63
+ --modal-header-gradient:var(--magritte-gradient-component-modal-background-fade-v19-0-0);
64
+ }
65
+ .magritte-title-wrapper___O--QR_5-0-0{
66
+ position:relative;
67
+ }
68
+ .magritte-wrapper___zH8vB_5-0-0{
69
+ margin-bottom:24px;
70
+ }
60
71
 
61
72
  :root{
62
73
  --magritte-color-background-overlay-v19-0-0:#20262b99;
@@ -67,13 +78,13 @@
67
78
  --magritte-semantic-animation-ease-in-out-200-duration-v19-0-0:200ms;
68
79
  --magritte-semantic-animation-ease-in-out-300-timing-function-v19-0-0:cubic-bezier(0.25, 0.1, 0.25, 1);
69
80
  --magritte-semantic-animation-ease-in-out-300-duration-v19-0-0:300ms;
70
- --magritte-static-border-radius-800-v19-0-0:32px;
81
+ --magritte-static-border-radius-600-v19-0-0:24px;
71
82
  }
72
83
  .magritte-night-theme{
73
84
  --magritte-color-background-overlay-v19-0-0:#20262b99;
74
85
  --magritte-color-component-modal-background-content-v19-0-0:#1B1B1B;
75
86
  }
76
- .magritte-modal-overlay___lK22l_4-3-21{
87
+ .magritte-modal-overlay___lK22l_5-0-0{
77
88
  position:fixed;
78
89
  top:0;
79
90
  right:0;
@@ -86,106 +97,122 @@
86
97
  z-index:1;
87
98
  user-select:text;
88
99
  }
89
- .magritte-modal___RAW6S_4-3-21{
100
+ .magritte-modal___RAW6S_5-0-0{
90
101
  display:flex;
91
102
  box-sizing:border-box;
92
- width:720px;
93
103
  margin:0 20px;
94
- padding:32px;
104
+ padding:24px;
95
105
  flex-direction:column;
96
- max-height:calc(100vh - 96px * 2);
106
+ max-height:calc(100vh - 24px * 2);
97
107
  position:relative;
98
108
  background-color:var(--magritte-color-component-modal-background-content-v19-0-0);
99
- border-radius:var(--magritte-static-border-radius-800-v19-0-0);
109
+ border-radius:var(--magritte-static-border-radius-600-v19-0-0);
100
110
  overflow:hidden;
111
+ width:800px;
101
112
  }
102
- .magritte-modal-small___MMQT4_4-3-21{
113
+ .magritte-modal___RAW6S_5-0-0.magritte-size-small___2JTM2_5-0-0{
103
114
  width:460px;
104
115
  }
105
- .magritte-modal-full-height___gIM4E_4-3-21{
116
+ .magritte-modal___RAW6S_5-0-0.magritte-size-medium___cWCe7_5-0-0{
117
+ width:600px;
118
+ }
119
+ .magritte-no-vertical-paddings___Z3-oM_5-0-0{
120
+ padding-top:0;
121
+ padding-bottom:0;
122
+ }
123
+ .magritte-no-horizontal-paddings___aT95Y_5-0-0{
124
+ padding-left:0;
125
+ padding-right:0;
126
+ }
127
+ .magritte-modal-full-height___gIM4E_5-0-0{
106
128
  height:100%;
107
129
  }
108
- .magritte-modal-content___46QFS_4-3-21{
130
+ .magritte-modal-content___46QFS_5-0-0{
109
131
  flex:1 1;
110
132
  overflow-y:auto;
111
133
  padding:0 5px;
112
134
  margin:0 -5px;
113
135
  overscroll-behavior:none;
114
136
  }
115
- .magritte-modal-content__with-divider___an3I5_4-3-21{
116
- margin-top:-16px;
117
- }
118
- .magritte-modal-content-wrapper___23XFT_4-3-21{
137
+ .magritte-modal-content-wrapper___23XFT_5-0-0{
119
138
  display:flex;
120
139
  flex-direction:column;
121
140
  min-height:0;
122
141
  flex:1 1;
123
142
  }
124
- .magritte-modal-content-wrapper__one-line___tYg8d_4-3-21{
143
+ .magritte-modal-content-wrapper__one-line___tYg8d_5-0-0{
125
144
  flex-direction:row-reverse;
126
145
  }
127
- .magritte-divider-container___qP3VK_4-3-21{
128
- margin:0 -32px;
146
+ .magritte-divider-container___qP3VK_5-0-0{
147
+ margin:0 -24px;
129
148
  }
130
- .magritte-divider-container___qP3VK_4-3-21.magritte-divider-container-hidden___EIxB-_4-3-21{
149
+ .magritte-divider-container___qP3VK_5-0-0.magritte-divider-container-hidden___EIxB-_5-0-0{
131
150
  display:none;
132
151
  }
133
- .magritte-modal-footer___8xPqQ_4-3-21{
134
- flex:0 0;
135
- padding-top:32px;
136
- display:flex;
137
- justify-content:space-between;
152
+ .magritte-modal-footer___8xPqQ_5-0-0{
153
+ margin:0 -24px -24px;
154
+ background-color:var(--magritte-color-component-modal-background-content-v19-0-0);
155
+ z-index:1;
138
156
  }
139
- .magritte-modal-buttons-container___1O1Nr_4-3-21{
157
+ .magritte-modal-buttons-container___1O1Nr_5-0-0{
140
158
  display:flex;
141
159
  gap:12px;
142
160
  }
143
- .magritte-animation-timeout___w-j7K_4-3-21,
144
- .magritte-modal-animation-enter-active___E8KLu_4-3-21,
145
- .magritte-modal-animation-exit-active___ERjKa_4-3-21{
161
+ .magritte-animation-timeout___w-j7K_5-0-0,
162
+ .magritte-modal-animation-enter-active___E8KLu_5-0-0,
163
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0{
146
164
  --enter-animation-duration:0;
147
165
  --exit-animation-duration:0;
148
166
  }
149
167
  @media (prefers-reduced-motion: no-preference){
150
- .magritte-animation-timeout___w-j7K_4-3-21,
151
- .magritte-modal-animation-enter-active___E8KLu_4-3-21,
152
- .magritte-modal-animation-exit-active___ERjKa_4-3-21{
168
+ .magritte-animation-timeout___w-j7K_5-0-0,
169
+ .magritte-modal-animation-enter-active___E8KLu_5-0-0,
170
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0{
153
171
  --enter-animation-duration:var(--magritte-semantic-animation-ease-in-out-300-duration-v19-0-0);
154
172
  --exit-animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-0-0);
155
173
  }
156
174
  }
157
- .magritte-modal-animation-enter___kruLO_4-3-21.magritte-modal-overlay___lK22l_4-3-21{
175
+ .magritte-modal-animation-enter___kruLO_5-0-0.magritte-modal-overlay___lK22l_5-0-0{
158
176
  opacity:0;
159
177
  }
160
- .magritte-modal-animation-enter___kruLO_4-3-21 .magritte-modal___RAW6S_4-3-21{
178
+ .magritte-modal-animation-enter___kruLO_5-0-0 .magritte-modal___RAW6S_5-0-0{
161
179
  opacity:0;
162
180
  transform:scale(0.96);
163
181
  }
164
- .magritte-modal-animation-enter-active___E8KLu_4-3-21 .magritte-modal___RAW6S_4-3-21,
165
- .magritte-modal-animation-enter-active___E8KLu_4-3-21.magritte-modal-overlay___lK22l_4-3-21{
182
+ .magritte-modal-animation-enter-active___E8KLu_5-0-0 .magritte-modal___RAW6S_5-0-0,
183
+ .magritte-modal-animation-enter-active___E8KLu_5-0-0.magritte-modal-overlay___lK22l_5-0-0{
166
184
  opacity:1;
167
185
  transform:scale(1);
168
186
  transition-property:opacity, transform;
169
187
  transition-duration:var(--enter-animation-duration);
170
188
  transition-timing-function:var(--magritte-semantic-animation-ease-in-out-300-timing-function-v19-0-0);
171
189
  }
172
- .magritte-modal-animation-exit___0jNgl_4-3-21.magritte-modal-overlay___lK22l_4-3-21{
190
+ .magritte-modal-animation-exit___0jNgl_5-0-0.magritte-modal-overlay___lK22l_5-0-0{
173
191
  opacity:1;
174
192
  }
175
- .magritte-modal-animation-exit___0jNgl_4-3-21 .magritte-modal___RAW6S_4-3-21{
193
+ .magritte-modal-animation-exit___0jNgl_5-0-0 .magritte-modal___RAW6S_5-0-0{
176
194
  opacity:1;
177
195
  transform:scale(1);
178
196
  }
179
- .magritte-modal-animation-exit-active___ERjKa_4-3-21.magritte-modal-overlay___lK22l_4-3-21{
197
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0.magritte-modal-overlay___lK22l_5-0-0{
180
198
  opacity:0;
181
199
  }
182
- .magritte-modal-animation-exit-active___ERjKa_4-3-21 .magritte-modal___RAW6S_4-3-21{
200
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0 .magritte-modal___RAW6S_5-0-0{
183
201
  opacity:0;
184
202
  transform:scale(0.96);
185
203
  }
186
- .magritte-modal-animation-exit-active___ERjKa_4-3-21 .magritte-modal___RAW6S_4-3-21,
187
- .magritte-modal-animation-exit-active___ERjKa_4-3-21.magritte-modal-overlay___lK22l_4-3-21{
204
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0 .magritte-modal___RAW6S_5-0-0,
205
+ .magritte-modal-animation-exit-active___ERjKa_5-0-0.magritte-modal-overlay___lK22l_5-0-0{
188
206
  transition-property:opacity, transform;
189
207
  transition-duration:var(--exit-animation-duration);
190
208
  transition-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0);
191
209
  }
210
+ .magritte-content-scroll-preserver___Tw5Px_5-0-0{
211
+ width:100%;
212
+ height:0;
213
+ }
214
+ .magritte-content-sticky-container___nqEXj_5-0-0{
215
+ position:sticky;
216
+ top:0;
217
+ min-height:100%;
218
+ }
package/index.js CHANGED
@@ -12,15 +12,14 @@ import '@hh.ru/magritte-common-modal-helper';
12
12
  import '@hh.ru/magritte-common-use-multiple-refs';
13
13
  import '@hh.ru/magritte-common-use-no-bubbling';
14
14
  import '@hh.ru/magritte-internal-layer-name';
15
+ import '@hh.ru/magritte-ui-action-bar';
15
16
  import '@hh.ru/magritte-ui-breakpoint';
16
17
  import '@hh.ru/magritte-ui-layer';
17
- import './ModalContentWithHeader.js';
18
+ import './ModalContentWithHeader-BZMj-Rqc.js';
18
19
  import '@hh.ru/magritte-common-func-utils';
19
20
  import '@hh.ru/magritte-ui-divider';
20
21
  import './ModalHeader.js';
21
22
  import '@hh.ru/magritte-ui-title';
22
- import './modal-B9JKYUrQ.js';
23
- import './ModalFooter.js';
24
23
  import './useModalOrder.js';
25
24
  import '@hh.ru/magritte-common-dom-storage';
26
25
  import '@hh.ru/magritte-ui-tree-selector';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hh.ru/magritte-ui-modal",
3
- "version": "4.3.21",
3
+ "version": "5.0.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -30,6 +30,7 @@
30
30
  "@hh.ru/magritte-design-tokens": "19.0.0",
31
31
  "@hh.ru/magritte-internal-layer-name": "2.2.0",
32
32
  "@hh.ru/magritte-ui-action": "4.4.8",
33
+ "@hh.ru/magritte-ui-action-bar": "2.2.0",
33
34
  "@hh.ru/magritte-ui-breakpoint": "4.0.3",
34
35
  "@hh.ru/magritte-ui-divider": "1.1.32",
35
36
  "@hh.ru/magritte-ui-icon": "7.8.1",
@@ -37,7 +38,7 @@
37
38
  "@hh.ru/magritte-ui-mock-component": "1.0.11",
38
39
  "@hh.ru/magritte-ui-theme-provider": "1.1.28",
39
40
  "@hh.ru/magritte-ui-title": "5.0.6",
40
- "@hh.ru/magritte-ui-tree-selector": "4.4.6"
41
+ "@hh.ru/magritte-ui-tree-selector": "4.4.7"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "classnames": ">=2.3.2",
@@ -48,5 +49,5 @@
48
49
  "publishConfig": {
49
50
  "access": "public"
50
51
  },
51
- "gitHead": "bf7f56dd64799c73041f10f1ddc88dd5658faa86"
52
+ "gitHead": "2366e6aabcfc1050b4cc1ae8bd16a3851db008db"
52
53
  }
package/types.d.ts CHANGED
@@ -1,17 +1,8 @@
1
1
  import { ReactNode, PropsWithChildren, SyntheticEvent } from 'react';
2
2
  import { TitleProps } from '@hh.ru/magritte-ui-title';
3
- type MakeNever<T> = {
4
- [key in keyof T]?: never;
5
- };
6
- type ModalHeaderWithImage = {
7
- /** URL изображение для фона заголовка */
8
- headerImage: string;
9
- /** Высота заголовка в пикселях, может указываться только если указан headerImage */
10
- headerHeight?: number;
11
- };
12
3
  type ModalHeaderBaseProps = {
13
4
  /** Текст заголовка */
14
- title: TitleProps['children'];
5
+ title?: TitleProps['children'];
15
6
  /** Размер заголовка */
16
7
  titleSize?: TitleProps['size'];
17
8
  /** Выравнивание заголовка */
@@ -27,6 +18,10 @@ type ModalHeaderBaseProps = {
27
18
  /** Цвет заголовка */
28
19
  titleStyle?: TitleProps['style'];
29
20
  titleDescriptionStyle?: TitleProps['descriptionStyle'];
21
+ /** URL изображение для фона заголовка */
22
+ headerImage?: string;
23
+ /** Высота заголовка в пикселях, если не переда проп headerImage этот проп игнорируется */
24
+ headerHeight?: number;
30
25
  };
31
26
  type ModalHeaderAdditionalProps = {
32
27
  /** Опциональный контент внизу хедера */
@@ -36,22 +31,24 @@ type ModalHeaderAdditionalProps = {
36
31
  /** Link внутри хедера */
37
32
  actionLink?: ReactNode;
38
33
  };
39
- export type ModalHeaderProps = (ModalHeaderBaseProps | MakeNever<ModalHeaderBaseProps>) & (ModalHeaderWithImage | MakeNever<ModalHeaderWithImage>) & ModalHeaderAdditionalProps;
40
- export interface ModalFooterProps {
41
- /** Кнопки отображаемые в левой части блока кнопок */
42
- leftButtons?: ReactNode;
43
- /** Кнопки отображаемые в правой части блока кнопок */
44
- rightButtons?: ReactNode;
45
- }
34
+ export type ModalHeaderProps = ModalHeaderBaseProps & ModalHeaderAdditionalProps;
46
35
  export interface ModalBaseProps extends PropsWithChildren {
47
36
  /** Обработчик нажатия на кнопку закрытия */
48
37
  onClose?: (event?: SyntheticEvent) => void;
49
38
  /** Флаг управляющий видимостью модала */
50
39
  visible?: boolean;
51
40
  /** Размер */
52
- size?: 'medium' | 'small';
41
+ size?: 'large' | 'medium' | 'small';
53
42
  /** Хост для отрисовки модала */
54
43
  host?: HTMLElement;
44
+ /** Содержимое футера, если нужно отрисовать кнопки, то должен использоваться ActionBar */
45
+ footer?: ReactNode;
46
+ /** Флаг отключающий верхний и нижний паддинги */
47
+ disableVerticalPaddings?: boolean;
48
+ /** Флаг отключающий левый и правый паддинги */
49
+ disableHorizontalPaddings?: boolean;
50
+ /** Флаг управляющий закрытием при клике вне Modal */
51
+ closeByClickOutside?: boolean;
55
52
  }
56
- export type ModalProps = ModalBaseProps & ModalHeaderProps & ModalFooterProps;
53
+ export type ModalProps = ModalBaseProps & ModalHeaderProps;
57
54
  export {};
package/ModalFooter.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { FC } from 'react';
2
- import { ModalFooterProps } from '@hh.ru/magritte-ui-modal/types';
3
- export declare const ModalFooter: FC<ModalFooterProps>;
package/ModalFooter.js DELETED
@@ -1,13 +0,0 @@
1
- import './index.css';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { s as styles } from './modal-B9JKYUrQ.js';
4
-
5
- const ModalFooter = ({ leftButtons, rightButtons }) => {
6
- if (!leftButtons && !rightButtons) {
7
- return null;
8
- }
9
- return (jsxs("div", { className: styles.modalFooter, children: [jsx("div", { className: styles.modalButtonsContainer, children: leftButtons || null }), jsx("div", { className: styles.modalButtonsContainer, children: rightButtons || null })] }));
10
- };
11
-
12
- export { ModalFooter };
13
- //# sourceMappingURL=ModalFooter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalFooter.js","sources":["../src/ModalFooter.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { ModalFooterProps } from '@hh.ru/magritte-ui-modal/types';\n\nimport styles from './modal.less';\n\nexport const ModalFooter: FC<ModalFooterProps> = ({ leftButtons, rightButtons }) => {\n if (!leftButtons && !rightButtons) {\n return null;\n }\n\n return (\n <div className={styles.modalFooter}>\n <div className={styles.modalButtonsContainer}>{leftButtons || null}</div>\n <div className={styles.modalButtonsContainer}>{rightButtons || null}</div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAMa,MAAA,WAAW,GAAyB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,KAAI;AAC/E,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE;AAC/B,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;AAED,IAAA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,WAAW,EAC9B,QAAA,EAAA,CAAAC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAG,QAAA,EAAA,WAAW,IAAI,IAAI,EAAO,CAAA,EACzEA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAA,QAAA,EAAG,YAAY,IAAI,IAAI,EAAO,CAAA,CAAA,EAAA,CACxE,EACR;AACN;;;;"}
package/modal-B9JKYUrQ.js DELETED
@@ -1,5 +0,0 @@
1
- import './index.css';
2
- var styles = {"modal-overlay":"magritte-modal-overlay___lK22l_4-3-21","modalOverlay":"magritte-modal-overlay___lK22l_4-3-21","modal":"magritte-modal___RAW6S_4-3-21","modal-small":"magritte-modal-small___MMQT4_4-3-21","modalSmall":"magritte-modal-small___MMQT4_4-3-21","modal-full-height":"magritte-modal-full-height___gIM4E_4-3-21","modalFullHeight":"magritte-modal-full-height___gIM4E_4-3-21","modal-content":"magritte-modal-content___46QFS_4-3-21","modalContent":"magritte-modal-content___46QFS_4-3-21","modal-content__with-divider":"magritte-modal-content__with-divider___an3I5_4-3-21","modalContentWithDivider":"magritte-modal-content__with-divider___an3I5_4-3-21","modal-content-wrapper":"magritte-modal-content-wrapper___23XFT_4-3-21","modalContentWrapper":"magritte-modal-content-wrapper___23XFT_4-3-21","modal-content-wrapper__one-line":"magritte-modal-content-wrapper__one-line___tYg8d_4-3-21","modalContentWrapperOneLine":"magritte-modal-content-wrapper__one-line___tYg8d_4-3-21","divider-container":"magritte-divider-container___qP3VK_4-3-21","dividerContainer":"magritte-divider-container___qP3VK_4-3-21","divider-container-hidden":"magritte-divider-container-hidden___EIxB-_4-3-21","dividerContainerHidden":"magritte-divider-container-hidden___EIxB-_4-3-21","modal-footer":"magritte-modal-footer___8xPqQ_4-3-21","modalFooter":"magritte-modal-footer___8xPqQ_4-3-21","modal-buttons-container":"magritte-modal-buttons-container___1O1Nr_4-3-21","modalButtonsContainer":"magritte-modal-buttons-container___1O1Nr_4-3-21","animation-timeout":"magritte-animation-timeout___w-j7K_4-3-21","animationTimeout":"magritte-animation-timeout___w-j7K_4-3-21","modal-animation-enter-active":"magritte-modal-animation-enter-active___E8KLu_4-3-21","modalAnimationEnterActive":"magritte-modal-animation-enter-active___E8KLu_4-3-21","modal-animation-exit-active":"magritte-modal-animation-exit-active___ERjKa_4-3-21","modalAnimationExitActive":"magritte-modal-animation-exit-active___ERjKa_4-3-21","modal-animation-enter":"magritte-modal-animation-enter___kruLO_4-3-21","modalAnimationEnter":"magritte-modal-animation-enter___kruLO_4-3-21","modal-animation-exit":"magritte-modal-animation-exit___0jNgl_4-3-21","modalAnimationExit":"magritte-modal-animation-exit___0jNgl_4-3-21"};
3
-
4
- export { styles as s };
5
- //# sourceMappingURL=modal-B9JKYUrQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modal-B9JKYUrQ.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}