@jetbrains/ring-ui 6.0.56 → 6.0.58

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.
@@ -1,4 +1,4 @@
1
- import { PureComponent } from 'react';
1
+ import { PureComponent, ButtonHTMLAttributes } from 'react';
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import type { Locale } from 'date-fns';
@@ -29,6 +29,7 @@ export type DatePickerProps = Omit<DatePopupProps, 'translations' | 'parseDateIn
29
29
  disabled?: boolean | null | undefined;
30
30
  parseDateInput: (input: string | null | undefined) => Date | null;
31
31
  size?: Size;
32
+ buttonAttributes?: Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'>;
32
33
  };
33
34
  /**
34
35
  * @name Date Picker
@@ -61,6 +62,7 @@ export default class DatePicker extends PureComponent<DatePickerProps> {
61
62
  translations: PropTypes.Requireable<object>;
62
63
  locale: PropTypes.Requireable<object>;
63
64
  size: PropTypes.Requireable<Size>;
65
+ buttonAttributes: PropTypes.Requireable<object>;
64
66
  };
65
67
  static defaultProps: DatePickerProps;
66
68
  static contextType: React.Context<import("../i18n/i18n-context").I18nContextProps>;
@@ -69,7 +69,8 @@ export default class DatePicker extends PureComponent {
69
69
  maxDate: dateType,
70
70
  translations: PropTypes.object,
71
71
  locale: PropTypes.object,
72
- size: PropTypes.oneOf(Object.values(Size))
72
+ size: PropTypes.oneOf(Object.values(Size)),
73
+ buttonAttributes: PropTypes.object
73
74
  };
74
75
  static defaultProps = {
75
76
  className: '',
@@ -204,7 +205,7 @@ export default class DatePicker extends PureComponent {
204
205
  ? (<Link data-test-ring-dropdown-anchor className={styles.anchor} disabled={this.props.disabled ?? false} pseudo>
205
206
  {this.getAnchorText()}
206
207
  </Link>)
207
- : (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false} disabled={this.props.disabled ?? false}>
208
+ : (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false} disabled={this.props.disabled ?? false} {...this.props.buttonAttributes}>
208
209
  {anchorContent}
209
210
  </Button>)} {...dropdownProps}>
210
211
  <PopupComponent className={popupClassName} popupRef={this.popupRef} onClear={clear ? this.clear : null} datePopupProps={{
@@ -21,6 +21,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
21
21
  dense?: boolean | null | undefined;
22
22
  native?: boolean;
23
23
  modal?: boolean;
24
+ preventBodyScroll?: boolean;
24
25
  }
25
26
  export default class Dialog extends PureComponent<DialogProps> {
26
27
  static propTypes: {
@@ -41,6 +42,7 @@ export default class Dialog extends PureComponent<DialogProps> {
41
42
  portalTarget: PropTypes.Requireable<HTMLElement>;
42
43
  autoFocusFirst: PropTypes.Requireable<boolean>;
43
44
  'data-test': PropTypes.Requireable<string>;
45
+ preventBodyScroll: PropTypes.Requireable<boolean>;
44
46
  };
45
47
  static defaultProps: Partial<DialogProps>;
46
48
  state: {
@@ -41,7 +41,8 @@ export default class Dialog extends PureComponent {
41
41
  trapFocus: PropTypes.bool,
42
42
  portalTarget: PropTypes.instanceOf(HTMLElement),
43
43
  autoFocusFirst: PropTypes.bool,
44
- 'data-test': PropTypes.string
44
+ 'data-test': PropTypes.string,
45
+ preventBodyScroll: PropTypes.bool
45
46
  };
46
47
  static defaultProps = {
47
48
  label: 'Dialog',
@@ -54,7 +55,8 @@ export default class Dialog extends PureComponent {
54
55
  shortcutOptions: { modal: false },
55
56
  trapFocus: false,
56
57
  autoFocusFirst: true,
57
- modal: true
58
+ modal: true,
59
+ preventBodyScroll: true
58
60
  };
59
61
  state = {
60
62
  shortcutsScope: getUID('ring-dialog-')
@@ -93,6 +95,9 @@ export default class Dialog extends PureComponent {
93
95
  }
94
96
  }
95
97
  toggleScrollPreventer() {
98
+ if (!this.props.preventBodyScroll) {
99
+ return;
100
+ }
96
101
  if (this.props.show) {
97
102
  this.scrollPreventer.prevent();
98
103
  }
@@ -125,7 +130,7 @@ export default class Dialog extends PureComponent {
125
130
  };
126
131
  nativeDialog = createRef();
127
132
  render() {
128
- const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, dense, shortcutOptions, native, modal, ...restProps } = this.props;
133
+ const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, dense, shortcutOptions, native, modal, preventBodyScroll, ...restProps } = this.props;
129
134
  const classes = classNames(styles.container, className);
130
135
  const shortcutsMap = this.getShortcutsMap();
131
136
  const content = (<>
@@ -213,6 +213,9 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
213
213
  shortcutsScope: string;
214
214
  listId: string;
215
215
  private _focusHandler;
216
+ isClickingSelect: boolean;
217
+ mouseDownHandler: () => void;
218
+ mouseUpHandler: () => void;
216
219
  private _blurHandler;
217
220
  node?: HTMLElement | null;
218
221
  nodeRef: (el: HTMLElement | null) => void;
@@ -315,9 +315,17 @@ export default class Select extends Component {
315
315
  focused: true
316
316
  });
317
317
  };
318
+ isClickingSelect = false;
319
+ mouseDownHandler = () => {
320
+ this.isClickingSelect = true;
321
+ };
322
+ mouseUpHandler = () => {
323
+ this.isClickingSelect = false;
324
+ };
318
325
  _blurHandler = () => {
319
326
  this.props.onBlur();
320
- if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup) {
327
+ if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup &&
328
+ !this.isClickingSelect) {
321
329
  window.setTimeout(() => {
322
330
  this.setState({ showPopup: false });
323
331
  });
@@ -822,7 +830,8 @@ export default class Select extends Component {
822
830
  switch (this.props.type) {
823
831
  case Type.INPUT_WITHOUT_CONTROLS:
824
832
  case Type.INPUT: return (<>
825
- <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)}>
833
+ <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)} role="presentation" // has interactive elements inside
834
+ onMouseDown={this.mouseDownHandler} onMouseUp={this.mouseUpHandler}>
826
835
  {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
827
836
  <Input {...ariaProps} height={this.props.height} autoComplete="off" id={this.props.id} onClick={this._clickHandler} inputRef={this.composedFilterRef(this.filterRef, this.props.filterRef)} disabled={this.props.disabled} value={this.state.filterValue} borderless={this.props.type === Type.INPUT_WITHOUT_CONTROLS} style={style} size={Size.FULL} onChange={this._filterChangeHandler} onFocus={this._focusHandler} onBlur={this._blurHandler}
828
837
  // Input with error style without description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "6.0.56",
3
+ "version": "6.0.58",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",