@jetbrains/ring-ui 5.0.154 → 5.0.155

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.
@@ -85,6 +85,7 @@ export interface BaseSelectProps<T = unknown> {
85
85
  onReset: () => void;
86
86
  dir: 'ltr' | 'rtl';
87
87
  renderBottomToolbar?: () => ReactNode;
88
+ renderTopToolbar?: () => ReactNode;
88
89
  height?: ControlsHeight | undefined;
89
90
  targetElement?: HTMLElement | null | undefined;
90
91
  className?: string | null | undefined;
@@ -221,6 +222,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
221
222
  _hidePopup(tryFocusAnchor?: boolean): void;
222
223
  addHandler: () => void;
223
224
  getToolbar(): React.JSX.Element | null;
225
+ getTopbar(): React.ReactNode;
224
226
  getLowerCaseLabel: typeof getLowerCaseLabel;
225
227
  doesLabelMatch: typeof doesLabelMatch;
226
228
  getFilterFn(): FilterFn<T>;
@@ -433,7 +433,7 @@ export default class Select extends Component {
433
433
  else if (!shownData.length) {
434
434
  message = this.props.notFoundMessage ?? translate('noOptionsFound');
435
435
  }
436
- return (<SelectPopup data={_shownData} message={message} toolbar={showPopup && this.getToolbar()} loading={this.props.loading} activeIndex={this.state.selectedIndex} hidden={!showPopup} ref={this.popupRef} maxHeight={this.props.maxHeight} minWidth={this.props.minWidth} directions={this.props.directions} className={this.props.popupClassName} style={this.props.popupStyle} top={this.props.top} left={this.props.left} filter={this.isInputMode() ? false : this.props.filter} // disable popup filter in INPUT mode
436
+ return (<SelectPopup data={_shownData} message={message} toolbar={showPopup && this.getToolbar()} topbar={this.getTopbar()} loading={this.props.loading} activeIndex={this.state.selectedIndex} hidden={!showPopup} ref={this.popupRef} maxHeight={this.props.maxHeight} minWidth={this.props.minWidth} directions={this.props.directions} className={this.props.popupClassName} style={this.props.popupStyle} top={this.props.top} left={this.props.left} filter={this.isInputMode() ? false : this.props.filter} // disable popup filter in INPUT mode
437
437
  multiple={this.props.multiple} filterValue={this.state.filterValue} anchorElement={anchorElement} onCloseAttempt={this._onCloseAttempt} onOutsideClick={this.props.onOutsideClick} onSelect={this._listSelectHandler} onSelectAll={this._listSelectAllHandler} onFilter={this._filterChangeHandler} onClear={this.clearFilter} onLoadMore={this.props.onLoadMore} isInputMode={this.isInputMode()} selected={this.state.selected} tags={this.props.tags} compact={this.props.compact} renderOptimization={this.props.renderOptimization} ringPopupTarget={this.props.ringPopupTarget} disableMoveOverflow={this.props.disableMoveOverflow} disableScrollToActive={this.props.disableScrollToActive} dir={this.props.dir} onEmptyPopupEnter={this.onEmptyPopupEnter} listId={this.listId}/>);
438
438
  }}
439
439
  </I18nContext.Consumer>);
@@ -486,6 +486,9 @@ export default class Select extends Component {
486
486
  {hint && (<List.ListHint label={hint} data-test="ring-select-toolbar-hint"/>)}
487
487
  </div>);
488
488
  }
489
+ getTopbar() {
490
+ return this.props.renderTopToolbar?.();
491
+ }
489
492
  getLowerCaseLabel = getLowerCaseLabel;
490
493
  doesLabelMatch = doesLabelMatch;
491
494
  getFilterFn() {
@@ -38,6 +38,7 @@ export interface SelectPopupProps<T = unknown> {
38
38
  data: readonly ListDataItem<T>[];
39
39
  activeIndex: number | null;
40
40
  toolbar: ReactNode;
41
+ topbar: ReactNode;
41
42
  filter: boolean | Filter<T>;
42
43
  message: string | null;
43
44
  anchorElement: HTMLElement | null;
@@ -34,6 +34,7 @@ export default class SelectPopup extends PureComponent {
34
34
  data: [],
35
35
  activeIndex: null,
36
36
  toolbar: null,
37
+ topbar: null,
37
38
  filter: false,
38
39
  multiple: false,
39
40
  message: null,
@@ -314,7 +315,7 @@ export default class SelectPopup extends PureComponent {
314
315
  right: event => this.handleNavigation(event)
315
316
  };
316
317
  render() {
317
- const { toolbar, className, multiple, hidden, isInputMode, anchorElement, minWidth, onCloseAttempt, onOutsideClick, directions, top, left, style, dir, filter } = this.props;
318
+ const { toolbar, topbar, className, multiple, hidden, isInputMode, anchorElement, minWidth, onCloseAttempt, onOutsideClick, directions, top, left, style, dir, filter } = this.props;
318
319
  const classes = classNames(styles.popup, className);
319
320
  return (<PopupTargetContext.Consumer>
320
321
  {ringPopupTarget => {
@@ -323,11 +324,12 @@ export default class SelectPopup extends PureComponent {
323
324
  multiple.selectAll && this.getSelectAll();
324
325
  const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
325
326
  const bottomLine = this.getBottomLine();
326
- const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar;
327
+ const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
327
328
  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} onMouseDown={this.mouseDownHandler} target={this.props.ringPopupTarget} autoCorrectTopOverflow={false} style={style}>
328
329
  <div dir={dir}>
329
330
  {!hidden && filter &&
330
331
  (<Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>)}
332
+ {topbar}
331
333
  {/* Add empty div to prevent the change of List position in DOM*/}
332
334
  {hidden ? <div /> : filterWithTags}
333
335
  {selectAll}
@@ -383,5 +385,6 @@ SelectPopup.propTypes = {
383
385
  style: PropTypes.object,
384
386
  tags: PropTypes.object,
385
387
  toolbar: PropTypes.node,
388
+ topbar: PropTypes.node,
386
389
  top: PropTypes.number
387
390
  };
@@ -85,6 +85,7 @@ export interface BaseSelectProps<T = unknown> {
85
85
  onReset: () => void;
86
86
  dir: 'ltr' | 'rtl';
87
87
  renderBottomToolbar?: () => ReactNode;
88
+ renderTopToolbar?: () => ReactNode;
88
89
  height?: ControlsHeight | undefined;
89
90
  targetElement?: HTMLElement | null | undefined;
90
91
  className?: string | null | undefined;
@@ -221,6 +222,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
221
222
  _hidePopup(tryFocusAnchor?: boolean): void;
222
223
  addHandler: () => void;
223
224
  getToolbar(): React.JSX.Element | null;
225
+ getTopbar(): React.ReactNode;
224
226
  getLowerCaseLabel: typeof getLowerCaseLabel;
225
227
  doesLabelMatch: typeof doesLabelMatch;
226
228
  getFilterFn(): FilterFn<T>;
@@ -530,6 +530,7 @@ class Select extends Component {
530
530
  data: _shownData,
531
531
  message: message,
532
532
  toolbar: showPopup && this.getToolbar(),
533
+ topbar: this.getTopbar(),
533
534
  loading: this.props.loading,
534
535
  activeIndex: this.state.selectedIndex,
535
536
  hidden: !showPopup,
@@ -627,6 +628,9 @@ class Select extends Component {
627
628
  "data-test": "ring-select-toolbar-hint"
628
629
  }));
629
630
  }
631
+ getTopbar() {
632
+ return this.props.renderTopToolbar?.();
633
+ }
630
634
  getLowerCaseLabel = getLowerCaseLabel;
631
635
  doesLabelMatch = doesLabelMatch;
632
636
  getFilterFn() {
@@ -38,6 +38,7 @@ export interface SelectPopupProps<T = unknown> {
38
38
  data: readonly ListDataItem<T>[];
39
39
  activeIndex: number | null;
40
40
  toolbar: ReactNode;
41
+ topbar: ReactNode;
41
42
  filter: boolean | Filter<T>;
42
43
  message: string | null;
43
44
  anchorElement: HTMLElement | null;
@@ -81,6 +81,7 @@ class SelectPopup extends PureComponent {
81
81
  data: [],
82
82
  activeIndex: null,
83
83
  toolbar: null,
84
+ topbar: null,
84
85
  filter: false,
85
86
  multiple: false,
86
87
  message: null,
@@ -403,6 +404,7 @@ class SelectPopup extends PureComponent {
403
404
  render() {
404
405
  const {
405
406
  toolbar,
407
+ topbar,
406
408
  className,
407
409
  multiple,
408
410
  hidden,
@@ -424,7 +426,7 @@ class SelectPopup extends PureComponent {
424
426
  const selectAll = multiple && typeof multiple === 'object' && !multiple.limit && multiple.selectAll && this.getSelectAll();
425
427
  const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
426
428
  const bottomLine = this.getBottomLine();
427
- const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar;
429
+ const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
428
430
  return /*#__PURE__*/React.createElement(Popup, {
429
431
  trapFocus: false,
430
432
  ref: this.popupRef,
@@ -448,7 +450,7 @@ class SelectPopup extends PureComponent {
448
450
  }, !hidden && filter && /*#__PURE__*/React.createElement(Shortcuts, {
449
451
  map: this.shortcutsMap,
450
452
  scope: this.shortcutsScope
451
- }), hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
453
+ }), topbar, hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
452
454
  });
453
455
  }
454
456
  }
@@ -495,6 +497,7 @@ SelectPopup.propTypes = {
495
497
  style: PropTypes.object,
496
498
  tags: PropTypes.object,
497
499
  toolbar: PropTypes.node,
500
+ topbar: PropTypes.node,
498
501
  top: PropTypes.number
499
502
  };
500
503
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "5.0.154",
3
+ "version": "5.0.155",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",