@jetbrains/ring-ui 7.0.87 → 7.0.88

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.
@@ -29,6 +29,8 @@
29
29
  top: unset;
30
30
  left: unset;
31
31
 
32
+ max-height: 100%;
33
+
32
34
  margin: 0;
33
35
  }
34
36
 
@@ -163,6 +163,7 @@ export default class Popup extends PureComponent {
163
163
  left: this.props.left,
164
164
  directions: this.props.directions,
165
165
  offset: this.props.offset,
166
+ maxHeight: this.props.maxHeight,
166
167
  });
167
168
  const { direction } = this.position();
168
169
  if (direction) {
@@ -9,6 +9,7 @@ interface SetCSSAnchorPositioningParams {
9
9
  left?: number;
10
10
  directions: readonly Directions[];
11
11
  offset?: number;
12
+ maxHeight?: number | 'screen' | null;
12
13
  }
13
- export declare const setCSSAnchorPositioning: ({ popup, anchor, uid, minWidth, top, left, directions, offset, }: SetCSSAnchorPositioningParams) => void;
14
+ export declare const setCSSAnchorPositioning: ({ popup, anchor, uid, minWidth, top, left, directions, offset, maxHeight, }: SetCSSAnchorPositioningParams) => void;
14
15
  export {};
@@ -1,6 +1,6 @@
1
1
  import { getRect } from '../global/dom';
2
- import { calculateMinWidth } from './position';
3
- import { Directions } from './popup.consts';
2
+ import { calculateMinWidth, MaxHeight } from './position';
3
+ import { Directions, Dimension } from './popup.consts';
4
4
  export const supportsCSSAnchorPositioning = () => CSS?.supports?.('anchor-name', 'none');
5
5
  const getPositionArea = (direction) => {
6
6
  switch (direction) {
@@ -36,7 +36,7 @@ const getPositionFallbacks = (directions) => directions
36
36
  .slice(1)
37
37
  .map(direction => getPositionArea(direction)[1])
38
38
  .join(', ');
39
- export const setCSSAnchorPositioning = ({ popup, anchor, uid, minWidth, top, left, directions, offset, }) => {
39
+ export const setCSSAnchorPositioning = ({ popup, anchor, uid, minWidth, top, left, directions, offset, maxHeight, }) => {
40
40
  const anchorName = anchor.style.getPropertyValue('anchor-name') || `--anchor-${uid}`;
41
41
  if (!anchor.style.getPropertyValue('anchor-name')) {
42
42
  anchor.style.setProperty('anchor-name', anchorName);
@@ -52,6 +52,20 @@ export const setCSSAnchorPositioning = ({ popup, anchor, uid, minWidth, top, lef
52
52
  if (left) {
53
53
  popup.style.left = `${left}px`;
54
54
  }
55
+ // When there is just 1 direction, the `max-height: 100%` from CSS should stay applied so popup doesn't overflow the anchor RG-2754
56
+ const SHOULD_AUTO_SHRINK = directions.length <= 1;
57
+ if (!SHOULD_AUTO_SHRINK) {
58
+ const screenWithMargin = `calc(100vh - ${Dimension.MARGIN * 2}px)`;
59
+ if (maxHeight === 'screen' || maxHeight === MaxHeight.SCREEN) {
60
+ popup.style.maxHeight = screenWithMargin;
61
+ }
62
+ else if (typeof maxHeight === 'number' && maxHeight > 0) {
63
+ popup.style.maxHeight = `min(${screenWithMargin}, ${maxHeight}px)`;
64
+ }
65
+ }
66
+ else {
67
+ popup.style.maxHeight = '';
68
+ }
55
69
  const [initialPositionStyle, initialPositionName] = getPositionArea(directions[0]);
56
70
  popup.style.setProperty('position-area', initialPositionStyle);
57
71
  if (offset) {
@@ -5,7 +5,8 @@ import debounce from 'just-debounce-it';
5
5
  import classNames from 'classnames';
6
6
  import { dequal } from 'dequal';
7
7
  import searchIcon from '@jetbrains/icons/search';
8
- import closeIcon from '@jetbrains/icons/close-12px';
8
+ import closeIcon from '@jetbrains/icons/close';
9
+ import close12pxIcon from '@jetbrains/icons/close-12px';
9
10
  import getUID from '../global/get-uid';
10
11
  import dataTests from '../global/data-tests';
11
12
  import { getRect, preventDefault } from '../global/dom';
@@ -679,7 +680,7 @@ export default class QueryAssist extends Component {
679
680
  const renderClear = this.props.clear && !!this.state.query;
680
681
  if (renderClear) {
681
682
  actions.push(<I18nContext.Consumer key={'clearAction'}>
682
- {({ translate }) => (<Button icon={closeIcon} className={classNames(styles.clear, this.props.clearIconClassName)} title={this.props.translations?.clearTitle ?? translate('clearTitle')} ref={this.clearRef} onClick={this.clearQuery} data-test='query-assist-clear-icon'/>)}
683
+ {({ translate }) => (<Button icon={this.props.huge ? closeIcon : close12pxIcon} className={classNames(styles.clear, this.props.clearIconClassName)} title={this.props.translations?.clearTitle ?? translate('clearTitle')} ref={this.clearRef} onClick={this.clearQuery} data-test='query-assist-clear-icon'/>)}
683
684
  </I18nContext.Consumer>);
684
685
  }
685
686
  return actions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.87",
3
+ "version": "7.0.88",
4
4
  "description": "JetBrains UI library",
5
5
  "author": {
6
6
  "name": "JetBrains"