@jetbrains/ring-ui 5.0.153 → 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.
- package/components/select/select.d.ts +4 -0
- package/components/select/select.js +7 -2
- package/components/select/select__popup.d.ts +2 -0
- package/components/select/select__popup.js +8 -3
- package/dist/select/select.d.ts +4 -0
- package/dist/select/select.js +7 -0
- package/dist/select/select__popup.d.ts +2 -0
- package/dist/select/select__popup.js +9 -2
- package/package.json +1 -1
|
@@ -79,11 +79,13 @@ export interface BaseSelectProps<T = unknown> {
|
|
|
79
79
|
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
80
80
|
onSelect: (selected: SelectItem<T> | null, event?: Event | SyntheticEvent) => void;
|
|
81
81
|
onDeselect: (selected: SelectItem<T> | null) => void;
|
|
82
|
+
onOutsideClick: (e: PointerEvent) => void;
|
|
82
83
|
onAdd: (value: string) => void;
|
|
83
84
|
onDone: () => void;
|
|
84
85
|
onReset: () => void;
|
|
85
86
|
dir: 'ltr' | 'rtl';
|
|
86
87
|
renderBottomToolbar?: () => ReactNode;
|
|
88
|
+
renderTopToolbar?: () => ReactNode;
|
|
87
89
|
height?: ControlsHeight | undefined;
|
|
88
90
|
targetElement?: HTMLElement | null | undefined;
|
|
89
91
|
className?: string | null | undefined;
|
|
@@ -183,6 +185,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
|
|
|
183
185
|
onKeyDown: typeof noop;
|
|
184
186
|
onSelect: typeof noop;
|
|
185
187
|
onDeselect: typeof noop;
|
|
188
|
+
onOutsideClick: typeof noop;
|
|
186
189
|
onChange: typeof noop;
|
|
187
190
|
onAdd: typeof noop;
|
|
188
191
|
onDone: typeof noop;
|
|
@@ -219,6 +222,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
|
|
|
219
222
|
_hidePopup(tryFocusAnchor?: boolean): void;
|
|
220
223
|
addHandler: () => void;
|
|
221
224
|
getToolbar(): React.JSX.Element | null;
|
|
225
|
+
getTopbar(): React.ReactNode;
|
|
222
226
|
getLowerCaseLabel: typeof getLowerCaseLabel;
|
|
223
227
|
doesLabelMatch: typeof doesLabelMatch;
|
|
224
228
|
getFilterFn(): FilterFn<T>;
|
|
@@ -214,6 +214,7 @@ export default class Select extends Component {
|
|
|
214
214
|
onKeyDown: noop,
|
|
215
215
|
onSelect: noop,
|
|
216
216
|
onDeselect: noop,
|
|
217
|
+
onOutsideClick: noop,
|
|
217
218
|
onChange: noop,
|
|
218
219
|
onAdd: noop,
|
|
219
220
|
onDone: noop,
|
|
@@ -432,8 +433,8 @@ export default class Select extends Component {
|
|
|
432
433
|
else if (!shownData.length) {
|
|
433
434
|
message = this.props.notFoundMessage ?? translate('noOptionsFound');
|
|
434
435
|
}
|
|
435
|
-
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
|
-
multiple={this.props.multiple} filterValue={this.state.filterValue} anchorElement={anchorElement} onCloseAttempt={this._onCloseAttempt} 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}/>);
|
|
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
|
+
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}/>);
|
|
437
438
|
}}
|
|
438
439
|
</I18nContext.Consumer>);
|
|
439
440
|
}
|
|
@@ -485,6 +486,9 @@ export default class Select extends Component {
|
|
|
485
486
|
{hint && (<List.ListHint label={hint} data-test="ring-select-toolbar-hint"/>)}
|
|
486
487
|
</div>);
|
|
487
488
|
}
|
|
489
|
+
getTopbar() {
|
|
490
|
+
return this.props.renderTopToolbar?.();
|
|
491
|
+
}
|
|
488
492
|
getLowerCaseLabel = getLowerCaseLabel;
|
|
489
493
|
doesLabelMatch = doesLabelMatch;
|
|
490
494
|
getFilterFn() {
|
|
@@ -893,6 +897,7 @@ Select.propTypes = {
|
|
|
893
897
|
onBeforeOpen: PropTypes.func,
|
|
894
898
|
onSelect: PropTypes.func,
|
|
895
899
|
onDeselect: PropTypes.func,
|
|
900
|
+
onOutsideClick: PropTypes.func,
|
|
896
901
|
onFocus: PropTypes.func,
|
|
897
902
|
onBlur: PropTypes.func,
|
|
898
903
|
onKeyDown: PropTypes.func,
|
|
@@ -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;
|
|
@@ -46,6 +47,7 @@ export interface SelectPopupProps<T = unknown> {
|
|
|
46
47
|
loading: boolean;
|
|
47
48
|
onSelect: (item: ListDataItem<T>, event: Event, params?: SelectHandlerParams) => void;
|
|
48
49
|
onCloseAttempt: (e?: Event | SyntheticEvent, isEsc?: boolean | undefined) => void;
|
|
50
|
+
onOutsideClick: (e: PointerEvent) => void;
|
|
49
51
|
onFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
50
52
|
onClear: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
51
53
|
onLoadMore: () => void;
|
|
@@ -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,
|
|
@@ -43,6 +44,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
43
44
|
loading: false,
|
|
44
45
|
onSelect: noop,
|
|
45
46
|
onCloseAttempt: noop,
|
|
47
|
+
onOutsideClick: noop,
|
|
46
48
|
onFilter: noop,
|
|
47
49
|
onClear: noop,
|
|
48
50
|
onLoadMore: noop,
|
|
@@ -313,7 +315,7 @@ export default class SelectPopup extends PureComponent {
|
|
|
313
315
|
right: event => this.handleNavigation(event)
|
|
314
316
|
};
|
|
315
317
|
render() {
|
|
316
|
-
const { toolbar, className, multiple, hidden, isInputMode, anchorElement, minWidth, onCloseAttempt, 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;
|
|
317
319
|
const classes = classNames(styles.popup, className);
|
|
318
320
|
return (<PopupTargetContext.Consumer>
|
|
319
321
|
{ringPopupTarget => {
|
|
@@ -322,11 +324,12 @@ export default class SelectPopup extends PureComponent {
|
|
|
322
324
|
multiple.selectAll && this.getSelectAll();
|
|
323
325
|
const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
|
|
324
326
|
const bottomLine = this.getBottomLine();
|
|
325
|
-
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar;
|
|
326
|
-
return (<Popup trapFocus={false} ref={this.popupRef} hidden={hidden || !hasContent} attached={isInputMode} className={classes} dontCloseOnAnchorClick anchorElement={anchorElement} minWidth={minWidth} onCloseAttempt={onCloseAttempt} directions={directions} top={top} left={left} onMouseDown={this.mouseDownHandler} target={this.props.ringPopupTarget} autoCorrectTopOverflow={false} style={style}>
|
|
327
|
+
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
|
|
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}>
|
|
327
329
|
<div dir={dir}>
|
|
328
330
|
{!hidden && filter &&
|
|
329
331
|
(<Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>)}
|
|
332
|
+
{topbar}
|
|
330
333
|
{/* Add empty div to prevent the change of List position in DOM*/}
|
|
331
334
|
{hidden ? <div /> : filterWithTags}
|
|
332
335
|
{selectAll}
|
|
@@ -370,6 +373,7 @@ SelectPopup.propTypes = {
|
|
|
370
373
|
loading: PropTypes.bool,
|
|
371
374
|
onClear: PropTypes.func,
|
|
372
375
|
onCloseAttempt: PropTypes.func,
|
|
376
|
+
onOutsideClick: PropTypes.func,
|
|
373
377
|
onEmptyPopupEnter: PropTypes.func,
|
|
374
378
|
onFilter: PropTypes.func,
|
|
375
379
|
onLoadMore: PropTypes.func,
|
|
@@ -381,5 +385,6 @@ SelectPopup.propTypes = {
|
|
|
381
385
|
style: PropTypes.object,
|
|
382
386
|
tags: PropTypes.object,
|
|
383
387
|
toolbar: PropTypes.node,
|
|
388
|
+
topbar: PropTypes.node,
|
|
384
389
|
top: PropTypes.number
|
|
385
390
|
};
|
package/dist/select/select.d.ts
CHANGED
|
@@ -79,11 +79,13 @@ export interface BaseSelectProps<T = unknown> {
|
|
|
79
79
|
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
80
80
|
onSelect: (selected: SelectItem<T> | null, event?: Event | SyntheticEvent) => void;
|
|
81
81
|
onDeselect: (selected: SelectItem<T> | null) => void;
|
|
82
|
+
onOutsideClick: (e: PointerEvent) => void;
|
|
82
83
|
onAdd: (value: string) => void;
|
|
83
84
|
onDone: () => void;
|
|
84
85
|
onReset: () => void;
|
|
85
86
|
dir: 'ltr' | 'rtl';
|
|
86
87
|
renderBottomToolbar?: () => ReactNode;
|
|
88
|
+
renderTopToolbar?: () => ReactNode;
|
|
87
89
|
height?: ControlsHeight | undefined;
|
|
88
90
|
targetElement?: HTMLElement | null | undefined;
|
|
89
91
|
className?: string | null | undefined;
|
|
@@ -183,6 +185,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
|
|
|
183
185
|
onKeyDown: typeof noop;
|
|
184
186
|
onSelect: typeof noop;
|
|
185
187
|
onDeselect: typeof noop;
|
|
188
|
+
onOutsideClick: typeof noop;
|
|
186
189
|
onChange: typeof noop;
|
|
187
190
|
onAdd: typeof noop;
|
|
188
191
|
onDone: typeof noop;
|
|
@@ -219,6 +222,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
|
|
|
219
222
|
_hidePopup(tryFocusAnchor?: boolean): void;
|
|
220
223
|
addHandler: () => void;
|
|
221
224
|
getToolbar(): React.JSX.Element | null;
|
|
225
|
+
getTopbar(): React.ReactNode;
|
|
222
226
|
getLowerCaseLabel: typeof getLowerCaseLabel;
|
|
223
227
|
doesLabelMatch: typeof doesLabelMatch;
|
|
224
228
|
getFilterFn(): FilterFn<T>;
|
package/dist/select/select.js
CHANGED
|
@@ -266,6 +266,7 @@ class Select extends Component {
|
|
|
266
266
|
onKeyDown: noop,
|
|
267
267
|
onSelect: noop,
|
|
268
268
|
onDeselect: noop,
|
|
269
|
+
onOutsideClick: noop,
|
|
269
270
|
onChange: noop,
|
|
270
271
|
onAdd: noop,
|
|
271
272
|
onDone: noop,
|
|
@@ -529,6 +530,7 @@ class Select extends Component {
|
|
|
529
530
|
data: _shownData,
|
|
530
531
|
message: message,
|
|
531
532
|
toolbar: showPopup && this.getToolbar(),
|
|
533
|
+
topbar: this.getTopbar(),
|
|
532
534
|
loading: this.props.loading,
|
|
533
535
|
activeIndex: this.state.selectedIndex,
|
|
534
536
|
hidden: !showPopup,
|
|
@@ -546,6 +548,7 @@ class Select extends Component {
|
|
|
546
548
|
filterValue: this.state.filterValue,
|
|
547
549
|
anchorElement: anchorElement,
|
|
548
550
|
onCloseAttempt: this._onCloseAttempt,
|
|
551
|
+
onOutsideClick: this.props.onOutsideClick,
|
|
549
552
|
onSelect: this._listSelectHandler,
|
|
550
553
|
onSelectAll: this._listSelectAllHandler,
|
|
551
554
|
onFilter: this._filterChangeHandler,
|
|
@@ -625,6 +628,9 @@ class Select extends Component {
|
|
|
625
628
|
"data-test": "ring-select-toolbar-hint"
|
|
626
629
|
}));
|
|
627
630
|
}
|
|
631
|
+
getTopbar() {
|
|
632
|
+
return this.props.renderTopToolbar?.();
|
|
633
|
+
}
|
|
628
634
|
getLowerCaseLabel = getLowerCaseLabel;
|
|
629
635
|
doesLabelMatch = doesLabelMatch;
|
|
630
636
|
getFilterFn() {
|
|
@@ -1122,6 +1128,7 @@ Select.propTypes = {
|
|
|
1122
1128
|
onBeforeOpen: PropTypes.func,
|
|
1123
1129
|
onSelect: PropTypes.func,
|
|
1124
1130
|
onDeselect: PropTypes.func,
|
|
1131
|
+
onOutsideClick: PropTypes.func,
|
|
1125
1132
|
onFocus: PropTypes.func,
|
|
1126
1133
|
onBlur: PropTypes.func,
|
|
1127
1134
|
onKeyDown: PropTypes.func,
|
|
@@ -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;
|
|
@@ -46,6 +47,7 @@ export interface SelectPopupProps<T = unknown> {
|
|
|
46
47
|
loading: boolean;
|
|
47
48
|
onSelect: (item: ListDataItem<T>, event: Event, params?: SelectHandlerParams) => void;
|
|
48
49
|
onCloseAttempt: (e?: Event | SyntheticEvent, isEsc?: boolean | undefined) => void;
|
|
50
|
+
onOutsideClick: (e: PointerEvent) => void;
|
|
49
51
|
onFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
50
52
|
onClear: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
51
53
|
onLoadMore: () => void;
|
|
@@ -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,
|
|
@@ -90,6 +91,7 @@ class SelectPopup extends PureComponent {
|
|
|
90
91
|
loading: false,
|
|
91
92
|
onSelect: noop,
|
|
92
93
|
onCloseAttempt: noop,
|
|
94
|
+
onOutsideClick: noop,
|
|
93
95
|
onFilter: noop,
|
|
94
96
|
onClear: noop,
|
|
95
97
|
onLoadMore: noop,
|
|
@@ -402,6 +404,7 @@ class SelectPopup extends PureComponent {
|
|
|
402
404
|
render() {
|
|
403
405
|
const {
|
|
404
406
|
toolbar,
|
|
407
|
+
topbar,
|
|
405
408
|
className,
|
|
406
409
|
multiple,
|
|
407
410
|
hidden,
|
|
@@ -409,6 +412,7 @@ class SelectPopup extends PureComponent {
|
|
|
409
412
|
anchorElement,
|
|
410
413
|
minWidth,
|
|
411
414
|
onCloseAttempt,
|
|
415
|
+
onOutsideClick,
|
|
412
416
|
directions,
|
|
413
417
|
top,
|
|
414
418
|
left,
|
|
@@ -422,7 +426,7 @@ class SelectPopup extends PureComponent {
|
|
|
422
426
|
const selectAll = multiple && typeof multiple === 'object' && !multiple.limit && multiple.selectAll && this.getSelectAll();
|
|
423
427
|
const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
|
|
424
428
|
const bottomLine = this.getBottomLine();
|
|
425
|
-
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar;
|
|
429
|
+
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
|
|
426
430
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
427
431
|
trapFocus: false,
|
|
428
432
|
ref: this.popupRef,
|
|
@@ -433,6 +437,7 @@ class SelectPopup extends PureComponent {
|
|
|
433
437
|
anchorElement: anchorElement,
|
|
434
438
|
minWidth: minWidth,
|
|
435
439
|
onCloseAttempt: onCloseAttempt,
|
|
440
|
+
onOutsideClick: onOutsideClick,
|
|
436
441
|
directions: directions,
|
|
437
442
|
top: top,
|
|
438
443
|
left: left,
|
|
@@ -445,7 +450,7 @@ class SelectPopup extends PureComponent {
|
|
|
445
450
|
}, !hidden && filter && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
446
451
|
map: this.shortcutsMap,
|
|
447
452
|
scope: this.shortcutsScope
|
|
448
|
-
}), hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
|
|
453
|
+
}), topbar, hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
|
|
449
454
|
});
|
|
450
455
|
}
|
|
451
456
|
}
|
|
@@ -480,6 +485,7 @@ SelectPopup.propTypes = {
|
|
|
480
485
|
loading: PropTypes.bool,
|
|
481
486
|
onClear: PropTypes.func,
|
|
482
487
|
onCloseAttempt: PropTypes.func,
|
|
488
|
+
onOutsideClick: PropTypes.func,
|
|
483
489
|
onEmptyPopupEnter: PropTypes.func,
|
|
484
490
|
onFilter: PropTypes.func,
|
|
485
491
|
onLoadMore: PropTypes.func,
|
|
@@ -491,6 +497,7 @@ SelectPopup.propTypes = {
|
|
|
491
497
|
style: PropTypes.object,
|
|
492
498
|
tags: PropTypes.object,
|
|
493
499
|
toolbar: PropTypes.node,
|
|
500
|
+
topbar: PropTypes.node,
|
|
494
501
|
top: PropTypes.number
|
|
495
502
|
};
|
|
496
503
|
|