@jetbrains/ring-ui 7.0.81 → 7.0.82
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.
|
@@ -9,7 +9,7 @@ import dataTests from '../global/data-tests';
|
|
|
9
9
|
import Shortcuts from '../shortcuts/shortcuts';
|
|
10
10
|
import TabTrap from '../tab-trap/tab-trap';
|
|
11
11
|
import Button from '../button/button';
|
|
12
|
-
import { PopupTarget, PopupTargetContext } from '../popup/popup.target';
|
|
12
|
+
import { normalizePopupTarget, PopupTarget, PopupTargetContext } from '../popup/popup.target';
|
|
13
13
|
import { getPopupContainer } from '../popup/popup';
|
|
14
14
|
import { preventerFactory as scrollPreventerFactory } from './dialog-body-scroll-preventer';
|
|
15
15
|
import styles from './dialog.css';
|
|
@@ -144,12 +144,13 @@ export default class Dialog extends PureComponent {
|
|
|
144
144
|
}
|
|
145
145
|
return (show && (<PopupTargetContext.Consumer>
|
|
146
146
|
{contextTarget => {
|
|
147
|
+
const normalizedContextTarget = normalizePopupTarget(contextTarget);
|
|
147
148
|
let targetElement = document.body;
|
|
148
149
|
if (portalTarget instanceof HTMLElement) {
|
|
149
150
|
targetElement = portalTarget;
|
|
150
151
|
}
|
|
151
|
-
else if (
|
|
152
|
-
const container = getPopupContainer(
|
|
152
|
+
else if (normalizedContextTarget !== undefined) {
|
|
153
|
+
const container = getPopupContainer(normalizedContextTarget);
|
|
153
154
|
if (container) {
|
|
154
155
|
targetElement = container;
|
|
155
156
|
}
|
|
@@ -94,6 +94,7 @@ export default class Popup<P extends BasePopupProps = PopupProps> extends PureCo
|
|
|
94
94
|
parent?: HTMLElement | null;
|
|
95
95
|
container?: HTMLElement | null;
|
|
96
96
|
ringPopupTarget?: string | Element;
|
|
97
|
+
private cssPositioningFromContext;
|
|
97
98
|
clickStartedInsidePopup: boolean;
|
|
98
99
|
shouldUseShortcuts(): boolean;
|
|
99
100
|
listeners: Listeners;
|
|
@@ -15,7 +15,7 @@ import TabTrap from '../tab-trap/tab-trap';
|
|
|
15
15
|
import { getConfiguration } from '../global/configuration';
|
|
16
16
|
import position from './position';
|
|
17
17
|
import { DEFAULT_DIRECTIONS, Dimension, Directions, Display, MaxHeight, MinWidth } from './popup.consts';
|
|
18
|
-
import { PopupTargetContext, PopupTarget } from './popup.target';
|
|
18
|
+
import { PopupTargetContext, PopupTarget, normalizePopupTarget } from './popup.target';
|
|
19
19
|
import { setCSSAnchorPositioning, supportsCSSAnchorPositioning } from './position-css';
|
|
20
20
|
import { ThemeContext, WithThemeClasses } from '../global/theme';
|
|
21
21
|
import styles from './popup.css';
|
|
@@ -79,6 +79,7 @@ export default class Popup extends PureComponent {
|
|
|
79
79
|
parent;
|
|
80
80
|
container;
|
|
81
81
|
ringPopupTarget;
|
|
82
|
+
cssPositioningFromContext;
|
|
82
83
|
clickStartedInsidePopup = false;
|
|
83
84
|
shouldUseShortcuts() {
|
|
84
85
|
const { shortcuts, hidden } = this.props;
|
|
@@ -145,9 +146,7 @@ export default class Popup extends PureComponent {
|
|
|
145
146
|
if (!supportsCSSAnchorPositioning()) {
|
|
146
147
|
return false;
|
|
147
148
|
}
|
|
148
|
-
return this.props.cssPositioning
|
|
149
|
-
? this.props.cssPositioning
|
|
150
|
-
: getConfiguration().popupsCssPositioning;
|
|
149
|
+
return this.props.cssPositioning ?? this.cssPositioningFromContext ?? getConfiguration().popupsCssPositioning;
|
|
151
150
|
}
|
|
152
151
|
_updatePosition = () => {
|
|
153
152
|
const popup = this.popup;
|
|
@@ -285,7 +284,10 @@ export default class Popup extends PureComponent {
|
|
|
285
284
|
{theme => (<WithThemeClasses theme={theme.theme}>
|
|
286
285
|
{themeClasses => (<PopupTargetContext.Consumer>
|
|
287
286
|
{value => {
|
|
288
|
-
this.ringPopupTarget = value;
|
|
287
|
+
this.ringPopupTarget = normalizePopupTarget(value);
|
|
288
|
+
if (!(typeof value === 'string' || value instanceof Element)) {
|
|
289
|
+
this.cssPositioningFromContext = value?.cssPositioning;
|
|
290
|
+
}
|
|
289
291
|
const classes = classNames(className, theme.passToPopups ? themeClasses : null, styles.popup, {
|
|
290
292
|
[styles.cssAnchoredPopup]: this.shouldUseCssPositioning(),
|
|
291
293
|
[styles.attached]: attached,
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface ComplexConfig {
|
|
3
|
+
target: string | Element | undefined;
|
|
4
|
+
cssPositioning?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const PopupTargetContext: import("react").Context<string | Element | ComplexConfig | undefined>;
|
|
3
7
|
export interface PopupTargetProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
4
8
|
id: string;
|
|
5
9
|
children: ReactNode | ((target: ReactNode) => ReactNode);
|
|
6
10
|
}
|
|
11
|
+
export declare function normalizePopupTarget(value: string | Element | undefined | ComplexConfig): string | Element | undefined;
|
|
7
12
|
export declare const PopupTarget: import("react").ForwardRefExoticComponent<PopupTargetProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createContext, forwardRef } from 'react';
|
|
2
2
|
export const PopupTargetContext = createContext(undefined);
|
|
3
|
+
export function normalizePopupTarget(value) {
|
|
4
|
+
return typeof value === 'string' || value instanceof Element ? value : value?.target;
|
|
5
|
+
}
|
|
3
6
|
export const PopupTarget = forwardRef(function PopupTarget({ id, children, ...restProps }, ref) {
|
|
4
7
|
const target = (<div {...restProps} data-portaltarget={id} ref={ref}>
|
|
5
8
|
{typeof children !== 'function' && children}
|
|
@@ -10,7 +10,7 @@ import memoizeOne from 'memoize-one';
|
|
|
10
10
|
import Icon from '../icon/icon';
|
|
11
11
|
import Popup, { getPopupContainer } from '../popup/popup';
|
|
12
12
|
import { maxHeightForDirection } from '../popup/position';
|
|
13
|
-
import { PopupTargetContext } from '../popup/popup.target';
|
|
13
|
+
import { normalizePopupTarget, PopupTargetContext } from '../popup/popup.target';
|
|
14
14
|
import List from '../list/list';
|
|
15
15
|
import LoaderInline from '../loader-inline/loader-inline';
|
|
16
16
|
import shortcutsHOC from '../shortcuts/shortcuts-hoc';
|
|
@@ -329,7 +329,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
329
329
|
{ringPopupTarget => {
|
|
330
330
|
const filterWithTags = this.getFilterWithTags();
|
|
331
331
|
const selectAll = multiple && typeof multiple === 'object' && !multiple.limit && multiple.selectAll && this.getSelectAll();
|
|
332
|
-
const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
|
|
332
|
+
const list = this.getList(this.props.ringPopupTarget || normalizePopupTarget(ringPopupTarget));
|
|
333
333
|
const bottomLine = this.getBottomLine();
|
|
334
334
|
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
|
|
335
335
|
return (<Popup trapFocus={false} ref={this.popupRef} hidden={hidden || !hasContent} attached={isInputMode} className={classes} dontCloseOnAnchorClick anchorElement={anchorElement} minWidth={minWidth} onCloseAttempt={onCloseAttempt} onOutsideClick={onOutsideClick} directions={directions} top={top} left={left} offset={offset} onMouseDown={this.mouseDownHandler} target={this.props.ringPopupTarget} autoCorrectTopOverflow={false} style={style} largeBorderRadius>
|