@jetbrains/ring-ui 7.0.6 → 7.0.8
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/collapse/collapse-content.d.ts +1 -2
- package/components/collapse/collapse-content.js +20 -13
- package/components/collapse/collapse.d.ts +2 -0
- package/components/collapse/collapse.js +8 -7
- package/components/dialog/dialog.css +20 -5
- package/components/dialog/dialog.js +4 -1
- package/components/global/variables.css +1 -0
- package/components/island/island.css +1 -1
- package/components/list/list.css +6 -1
- package/components/list/list.d.ts +0 -6
- package/components/list/list.js +1 -37
- package/components/panel/panel.js +1 -1
- package/components/tabs/collapsible-more.d.ts +1 -1
- package/components/tabs/collapsible-more.js +9 -7
- package/components/tabs/collapsible-tab.js +1 -2
- package/components/tabs/collapsible-tabs.d.ts +1 -1
- package/components/tabs/dumb-tabs.d.ts +2 -5
- package/components/tabs/dumb-tabs.js +5 -8
- package/package.json +24 -24
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, useContext, useMemo } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useContext, useMemo } from 'react';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import dataTests from '../global/data-tests';
|
|
5
4
|
import { getRect } from '../global/dom';
|
|
@@ -20,19 +19,26 @@ export const CollapseContent = ({ children, minHeight = DEFAULT_HEIGHT, 'data-te
|
|
|
20
19
|
const contentRef = useRef(null);
|
|
21
20
|
const initialContentHeight = useRef(minHeight);
|
|
22
21
|
const contentHeight = useRef(DEFAULT_HEIGHT);
|
|
23
|
-
const [dimensions, setDimensions] = useState({
|
|
24
|
-
width: 0,
|
|
25
|
-
height: 0,
|
|
26
|
-
});
|
|
22
|
+
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
|
27
23
|
const [height, setHeight] = useState(toPx(minHeight));
|
|
28
|
-
const [showFade, setShowFade] = useState(
|
|
24
|
+
const [showFade, setShowFade] = useState(collapsed);
|
|
25
|
+
const [shouldHideContent, setShouldHideContent] = useState(collapsed && minHeight <= DEFAULT_HEIGHT);
|
|
29
26
|
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setShowFade(true);
|
|
27
|
+
function onTransitionEnd() {
|
|
28
|
+
if (initialContentHeight.current <= DEFAULT_HEIGHT) {
|
|
29
|
+
setShouldHideContent(collapsed);
|
|
30
|
+
}
|
|
35
31
|
}
|
|
32
|
+
const container = containerRef.current;
|
|
33
|
+
container?.addEventListener('transitionend', onTransitionEnd);
|
|
34
|
+
return () => {
|
|
35
|
+
container?.removeEventListener('transitionend', onTransitionEnd);
|
|
36
|
+
};
|
|
37
|
+
}, [collapsed]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setShowFade(collapsed);
|
|
40
|
+
if (!collapsed)
|
|
41
|
+
setShouldHideContent(false);
|
|
36
42
|
}, [collapsed]);
|
|
37
43
|
useEffect(() => {
|
|
38
44
|
if (contentRef.current) {
|
|
@@ -63,9 +69,10 @@ export const CollapseContent = ({ children, minHeight = DEFAULT_HEIGHT, 'data-te
|
|
|
63
69
|
};
|
|
64
70
|
}, [duration, height, collapsed, minHeight]);
|
|
65
71
|
const fadeShouldBeVisible = useMemo(() => Boolean(minHeight && showFade), [minHeight, showFade]);
|
|
72
|
+
const shouldRenderContent = disableAnimation ? !collapsed : !shouldHideContent;
|
|
66
73
|
return (<div ref={containerRef} id={`collapse-content-${id}`} data-test={dataTests(COLLAPSE_CONTENT_CONTAINER_TEST_ID)} className={classNames(styles.container, { [styles.transition]: !disableAnimation })} style={style}>
|
|
67
74
|
<div ref={contentRef} data-test={dataTests(COLLAPSE_CONTENT_TEST_ID, dataTest)}>
|
|
68
|
-
{children}
|
|
75
|
+
{shouldRenderContent ? children : null}
|
|
69
76
|
</div>
|
|
70
77
|
{fadeShouldBeVisible && <div className={styles.fade}/>}
|
|
71
78
|
</div>);
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { useCallback, useId, useState } from 'react';
|
|
1
|
+
import { useCallback, useId, useMemo, useState } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { CollapseContext } from './collapse-context';
|
|
4
4
|
import { BASE_ANIMATION_DURATION } from './consts';
|
|
5
5
|
/**
|
|
6
6
|
* @name Collapse
|
|
7
7
|
*/
|
|
8
|
-
export const Collapse = ({ children, duration = BASE_ANIMATION_DURATION, disableAnimation = false, className = '', onChange = () => { }, }) => {
|
|
9
|
-
const [
|
|
8
|
+
export const Collapse = ({ children, duration = BASE_ANIMATION_DURATION, disableAnimation = false, className = '', onChange = () => { }, defaultCollapsed = true, collapsed = null, }) => {
|
|
9
|
+
const [innerCollapsed, setInnerCollapsed] = useState(defaultCollapsed);
|
|
10
10
|
const id = useId();
|
|
11
|
+
const finalCollapsedValue = useMemo(() => collapsed ?? innerCollapsed, [innerCollapsed, collapsed]);
|
|
11
12
|
const setCollapsed = useCallback(() => {
|
|
12
|
-
|
|
13
|
-
onChange(!
|
|
14
|
-
}, [
|
|
13
|
+
setInnerCollapsed(!finalCollapsedValue);
|
|
14
|
+
onChange(!finalCollapsedValue);
|
|
15
|
+
}, [setInnerCollapsed, onChange, finalCollapsedValue]);
|
|
15
16
|
return (<div className={className}>
|
|
16
17
|
<CollapseContext.Provider value={{
|
|
17
|
-
collapsed,
|
|
18
|
+
collapsed: finalCollapsedValue,
|
|
18
19
|
setCollapsed,
|
|
19
20
|
duration,
|
|
20
21
|
disableAnimation,
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
padding: 0;
|
|
25
25
|
|
|
26
26
|
border: none;
|
|
27
|
+
background: transparent;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
.container,
|
|
@@ -81,14 +82,26 @@
|
|
|
81
82
|
cursor: pointer;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
.
|
|
85
|
+
.closeIconOutside.closeIconOutside {
|
|
85
86
|
color: var(--ring-icon-hover-color);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
.
|
|
89
|
+
.clickableOverlay:hover + * .closeIconInside {
|
|
89
90
|
color: var(--ring-icon-hover-color);
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
.clickableOverlay:hover + * .closeIconOutside {
|
|
94
|
+
color: var(--ring-main-hover-color);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.closeButton:hover .closeIconInside {
|
|
98
|
+
color: var(--ring-icon-hover-color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.closeButton:hover .closeIconOutside {
|
|
102
|
+
color: var(--ring-main-hover-color);
|
|
103
|
+
}
|
|
104
|
+
|
|
92
105
|
.clickableOverlay:active + * .closeIcon {
|
|
93
106
|
color: var(--ring-main-color);
|
|
94
107
|
}
|
|
@@ -99,16 +112,18 @@
|
|
|
99
112
|
|
|
100
113
|
.closeButton.closeButton {
|
|
101
114
|
position: absolute;
|
|
115
|
+
|
|
116
|
+
line-height: calc(var(--ring-unit) * 2);
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
.closeButtonOutside {
|
|
105
|
-
top:
|
|
120
|
+
top: var(--ring-unit);
|
|
106
121
|
right: calc(var(--ring-unit) * -3);
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
.closeButtonInside {
|
|
110
|
-
top: calc(var(--ring-unit) *
|
|
111
|
-
right: var(--ring-unit);
|
|
125
|
+
top: calc(var(--ring-unit) * 2);
|
|
126
|
+
right: calc(var(--ring-unit) * 2);
|
|
112
127
|
}
|
|
113
128
|
|
|
114
129
|
.documentWithoutScroll {
|
|
@@ -122,7 +122,10 @@ export default class Dialog extends PureComponent {
|
|
|
122
122
|
{showCloseButton && (<Button icon={closeIcon} data-test="ring-dialog-close-button" className={classNames(styles.closeButton, {
|
|
123
123
|
[styles.closeButtonOutside]: !closeButtonInside,
|
|
124
124
|
[styles.closeButtonInside]: closeButtonInside,
|
|
125
|
-
})} iconClassName={styles.closeIcon
|
|
125
|
+
})} iconClassName={classNames(styles.closeIcon, {
|
|
126
|
+
[styles.closeIconOutside]: !closeButtonInside,
|
|
127
|
+
[styles.closeIconInside]: closeButtonInside,
|
|
128
|
+
})} onClick={this.onCloseClick} title={closeButtonTitle} aria-label={closeButtonTitle || 'close dialog'}/>)}
|
|
126
129
|
</AdaptiveIsland>
|
|
127
130
|
</div>
|
|
128
131
|
</>);
|
|
@@ -152,6 +152,7 @@
|
|
|
152
152
|
--ring-code-deletion-color: rgb(var(--ring-code-deletion-components)); /* #DFE1E5 */
|
|
153
153
|
|
|
154
154
|
/* Metrics */
|
|
155
|
+
--ring-border-radius-large: var(--ring-unit);
|
|
155
156
|
--ring-border-radius: 4px;
|
|
156
157
|
--ring-border-radius-small: 2px;
|
|
157
158
|
--ring-font-size-larger: 16px;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
flex-direction: column;
|
|
9
9
|
|
|
10
10
|
border: 1px solid var(--ring-line-color);
|
|
11
|
-
border-radius: var(--ring-border-radius);
|
|
11
|
+
border-radius: var(--ring-border-radius-large);
|
|
12
12
|
|
|
13
13
|
background-color: var(--ring-content-background-color);
|
|
14
14
|
box-shadow: 0 1px 4px var(--ring-popup-shadow-color);
|
package/components/list/list.css
CHANGED
|
@@ -179,7 +179,12 @@
|
|
|
179
179
|
transition: none;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
.hover:not(.error) {
|
|
182
|
+
.item:hover:not(.error) {
|
|
183
|
+
background-color: var(--ring-hover-background-color);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* TODO rename .hover to .selected in 8.0 */
|
|
187
|
+
.item.hover:not(.error) {
|
|
183
188
|
background-color: var(--ring-selected-background-color);
|
|
184
189
|
}
|
|
185
190
|
|
|
@@ -67,7 +67,6 @@ export interface ListState<T = unknown> {
|
|
|
67
67
|
needScrollToActive: boolean;
|
|
68
68
|
scrolling: boolean;
|
|
69
69
|
hasOverflow: boolean;
|
|
70
|
-
disabledHover: boolean;
|
|
71
70
|
scrolledToBottom: boolean;
|
|
72
71
|
}
|
|
73
72
|
interface RenderVirtualizedInnerParams extends Partial<WindowScrollerChildProps> {
|
|
@@ -109,7 +108,6 @@ export default class List<T = unknown> extends Component<ListProps<T>, ListState
|
|
|
109
108
|
componentDidUpdate(prevProps: ListProps<T>): void;
|
|
110
109
|
componentWillUnmount(): void;
|
|
111
110
|
scheduleScrollListener: (cb: () => void) => void;
|
|
112
|
-
scheduleHoverListener: (cb: () => void) => void;
|
|
113
111
|
static isItemType: typeof isItemType;
|
|
114
112
|
static ListHint: typeof ListHint;
|
|
115
113
|
static ListProps: {
|
|
@@ -129,7 +127,6 @@ export default class List<T = unknown> extends Component<ListProps<T>, ListState
|
|
|
129
127
|
virtualizedList?: VirtualizedList | null;
|
|
130
128
|
unmounted?: boolean;
|
|
131
129
|
container?: HTMLElement | null;
|
|
132
|
-
hoverHandler: (arg: number) => () => void;
|
|
133
130
|
private _bufferSize;
|
|
134
131
|
sizeCacheKey: (index: number) => string | Type.ITEM | Type.MARGIN;
|
|
135
132
|
private _cache;
|
|
@@ -142,15 +139,12 @@ export default class List<T = unknown> extends Component<ListProps<T>, ListState
|
|
|
142
139
|
downHandler: (e: KeyboardEvent) => void;
|
|
143
140
|
homeHandler: (e: KeyboardEvent) => void;
|
|
144
141
|
endHandler: (e: KeyboardEvent) => void;
|
|
145
|
-
onDocumentMouseMove: () => void;
|
|
146
|
-
onDocumentKeyDown: (e: KeyboardEvent) => void;
|
|
147
142
|
moveHandler(index: number, retryCallback: (e: KeyboardEvent) => void, e: KeyboardEvent): void;
|
|
148
143
|
mouseHandler: () => void;
|
|
149
144
|
scrollHandler: () => void;
|
|
150
145
|
enterHandler: (event: KeyboardEvent, shortcut?: string) => boolean;
|
|
151
146
|
getFirst(): ListDataItem<T> | undefined;
|
|
152
147
|
getSelected(): ListDataItem<T> | null;
|
|
153
|
-
clearSelected: () => void;
|
|
154
148
|
defaultItemHeight(): number;
|
|
155
149
|
scrollEndHandler: () => void;
|
|
156
150
|
checkOverflow: () => void;
|
package/components/list/list.js
CHANGED
|
@@ -77,7 +77,6 @@ export default class List extends Component {
|
|
|
77
77
|
needScrollToActive: false,
|
|
78
78
|
scrolling: false,
|
|
79
79
|
hasOverflow: false,
|
|
80
|
-
disabledHover: false,
|
|
81
80
|
scrolledToBottom: false,
|
|
82
81
|
};
|
|
83
82
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
@@ -110,8 +109,6 @@ export default class List extends Component {
|
|
|
110
109
|
return nextState;
|
|
111
110
|
}
|
|
112
111
|
componentDidMount() {
|
|
113
|
-
document.addEventListener('mousemove', this.onDocumentMouseMove);
|
|
114
|
-
document.addEventListener('keydown', this.onDocumentKeyDown, true);
|
|
115
112
|
if (this.props.activeIndex == null && shouldActivateFirstItem(this.props)) {
|
|
116
113
|
this.activateFirst();
|
|
117
114
|
}
|
|
@@ -133,11 +130,8 @@ export default class List extends Component {
|
|
|
133
130
|
}
|
|
134
131
|
componentWillUnmount() {
|
|
135
132
|
this.unmounted = true;
|
|
136
|
-
document.removeEventListener('mousemove', this.onDocumentMouseMove);
|
|
137
|
-
document.removeEventListener('keydown', this.onDocumentKeyDown, true);
|
|
138
133
|
}
|
|
139
134
|
scheduleScrollListener = scheduleRAF();
|
|
140
|
-
scheduleHoverListener = scheduleRAF();
|
|
141
135
|
static isItemType = isItemType;
|
|
142
136
|
static ListHint = ListHint;
|
|
143
137
|
static ListProps = {
|
|
@@ -147,18 +141,6 @@ export default class List extends Component {
|
|
|
147
141
|
virtualizedList;
|
|
148
142
|
unmounted;
|
|
149
143
|
container;
|
|
150
|
-
hoverHandler = memoize((index) => () => this.scheduleHoverListener(() => {
|
|
151
|
-
if (this.state.disabledHover) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (this.container) {
|
|
155
|
-
this.setState({
|
|
156
|
-
activeIndex: index,
|
|
157
|
-
activeItem: this.props.data[index],
|
|
158
|
-
needScrollToActive: false,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}));
|
|
162
144
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
163
145
|
_bufferSize = 10; // keep X items above and below of the visible area
|
|
164
146
|
// reuse size cache for similar items
|
|
@@ -260,17 +242,6 @@ export default class List extends Component {
|
|
|
260
242
|
endHandler = (e) => {
|
|
261
243
|
this.moveHandler(this.props.data.length - 1, this.upHandler, e);
|
|
262
244
|
};
|
|
263
|
-
onDocumentMouseMove = () => {
|
|
264
|
-
if (this.state.disabledHover) {
|
|
265
|
-
this.setState({ disabledHover: false });
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
onDocumentKeyDown = (e) => {
|
|
269
|
-
const metaKeys = [16, 17, 18, 19, 20, 91]; // eslint-disable-line @typescript-eslint/no-magic-numbers
|
|
270
|
-
if (!this.state.disabledHover && !metaKeys.includes(e.keyCode)) {
|
|
271
|
-
this.setState({ disabledHover: true });
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
245
|
moveHandler(index, retryCallback, e) {
|
|
275
246
|
let correctedIndex;
|
|
276
247
|
if (this.props.data.length === 0 || !this.hasActivatableItems()) {
|
|
@@ -330,12 +301,6 @@ export default class List extends Component {
|
|
|
330
301
|
getSelected() {
|
|
331
302
|
return this.state.activeIndex != null ? this.props.data[this.state.activeIndex] : null;
|
|
332
303
|
}
|
|
333
|
-
clearSelected = () => {
|
|
334
|
-
this.setState({
|
|
335
|
-
activeIndex: null,
|
|
336
|
-
needScrollToActive: false,
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
304
|
defaultItemHeight() {
|
|
340
305
|
return this.props.compact ? Dimension.COMPACT_ITEM_HEIGHT : Dimension.ITEM_HEIGHT;
|
|
341
306
|
}
|
|
@@ -404,7 +369,6 @@ export default class List extends Component {
|
|
|
404
369
|
if (itemProps.hoverClassName != null && itemProps.hover) {
|
|
405
370
|
itemProps.className = classNames(itemProps.className, itemProps.hoverClassName);
|
|
406
371
|
}
|
|
407
|
-
itemProps.onMouseOver = this.hoverHandler(realIndex);
|
|
408
372
|
itemProps.tabIndex = -1;
|
|
409
373
|
itemProps.scrolling = isScrolling;
|
|
410
374
|
const selectHandler = this.selectHandler(realIndex);
|
|
@@ -528,7 +492,7 @@ export default class List extends Component {
|
|
|
528
492
|
const classes = classNames(styles.list, this.props.className);
|
|
529
493
|
return (<>
|
|
530
494
|
<ActiveItemContext.Updater value={this.getId(this.state.activeItem)} skipUpdate={this.props.hidden || !isActivatable(this.state.activeItem)}/>
|
|
531
|
-
<div id={this.props.id} ref={this.containerRef} className={classes} onMouseOut={this.props.onMouseOut} onBlur={this.props.onMouseOut}
|
|
495
|
+
<div id={this.props.id} ref={this.containerRef} className={classes} onMouseOut={this.props.onMouseOut} onBlur={this.props.onMouseOut} data-test="ring-list">
|
|
532
496
|
{this.props.shortcuts && (<Shortcuts map={this.props.shortcutsMap ? { ...this.shortcutsMap, ...this.props.shortcutsMap } : this.shortcutsMap} scope={this.shortcutsScope}/>)}
|
|
533
497
|
{this.props.renderOptimization
|
|
534
498
|
? this.renderVirtualized(maxHeight, rowCount)
|
|
@@ -8,7 +8,7 @@ export default class Panel extends PureComponent {
|
|
|
8
8
|
render() {
|
|
9
9
|
const { className, children, ...props } = this.props;
|
|
10
10
|
const classes = classNames(styles.panel, className);
|
|
11
|
-
return (<div {...props} className={classes}>
|
|
11
|
+
return (<div data-test="ring-panel" {...props} className={classes}>
|
|
12
12
|
{children}
|
|
13
13
|
</div>);
|
|
14
14
|
}
|
|
@@ -10,7 +10,7 @@ export declare const AnchorLink: ({ hasActiveChildren, moreClassName, moreActive
|
|
|
10
10
|
export interface MoreButtonProps {
|
|
11
11
|
items: ReactElement<TabProps>[];
|
|
12
12
|
selected?: string | undefined;
|
|
13
|
-
onSelect
|
|
13
|
+
onSelect?: ((key: string) => () => void) | null | undefined;
|
|
14
14
|
moreClassName?: string | null | undefined;
|
|
15
15
|
moreActiveClassName?: string | null | undefined;
|
|
16
16
|
morePopupClassName?: string | null | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo,
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Directions } from '../popup/popup.consts';
|
|
4
4
|
import PopupMenu, { ListProps } from '../popup-menu/popup-menu';
|
|
@@ -15,13 +15,15 @@ export const AnchorLink = ({ hasActiveChildren, moreClassName, moreActiveClassNa
|
|
|
15
15
|
};
|
|
16
16
|
const morePopupDirections = [Directions.BOTTOM_CENTER, Directions.BOTTOM_LEFT, Directions.BOTTOM_RIGHT];
|
|
17
17
|
export const MoreButton = memo(({ items, selected, onSelect, moreClassName, moreActiveClassName, morePopupClassName, morePopupItemClassName, morePopupBeforeEnd, }) => {
|
|
18
|
-
const onSelectHandler =
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const onSelectHandler = useMemo(() => onSelect != null
|
|
19
|
+
? (listItem) => {
|
|
20
|
+
if (listItem.disabled === true || listItem.custom === true) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const cb = onSelect(String(listItem.key));
|
|
24
|
+
cb();
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
cb();
|
|
24
|
-
}, [onSelect]);
|
|
26
|
+
: undefined, [onSelect]);
|
|
25
27
|
const hasActiveChild = useMemo(() => items.some(item => item.props.alwaysHidden && item.props.id === selected), [items, selected]);
|
|
26
28
|
const data = useMemo(() => {
|
|
27
29
|
const popupItems = getTabTitles({
|
|
@@ -3,8 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import styles from './tabs.css';
|
|
4
4
|
import TabLink from './tab-link';
|
|
5
5
|
import { CustomItem } from './custom-item';
|
|
6
|
-
function
|
|
7
|
-
const TabTitle = React.memo(function TabTitle({ selected, child, handleSelect = noop, collapsed = false, tabIndex, }) {
|
|
6
|
+
const TabTitle = React.memo(function TabTitle({ selected, child, handleSelect, collapsed = false, tabIndex, }) {
|
|
8
7
|
if (child == null || typeof child !== 'object' || child.type === CustomItem) {
|
|
9
8
|
return child;
|
|
10
9
|
}
|
|
@@ -3,7 +3,7 @@ import { TabProps } from './tab';
|
|
|
3
3
|
export interface CollapsibleTabsProps {
|
|
4
4
|
children: ReactElement<TabProps>[];
|
|
5
5
|
selected?: string | undefined;
|
|
6
|
-
onSelect
|
|
6
|
+
onSelect?: ((key: string) => () => void) | undefined;
|
|
7
7
|
moreClassName?: string | null | undefined;
|
|
8
8
|
moreActiveClassName?: string | null | undefined;
|
|
9
9
|
morePopupClassName?: string | null | undefined;
|
|
@@ -7,17 +7,14 @@ export { CustomItem };
|
|
|
7
7
|
export type Children = readonly (Children | null | boolean)[] | ReactElement<TabProps> | null | boolean;
|
|
8
8
|
export interface TabsProps extends Omit<CollapsibleTabsProps, 'onSelect' | 'children'> {
|
|
9
9
|
children: Children;
|
|
10
|
-
onSelect
|
|
10
|
+
onSelect?: ((key: string) => void) | null | undefined;
|
|
11
11
|
className?: string | null | undefined;
|
|
12
12
|
tabContainerClassName?: string | null | undefined;
|
|
13
13
|
autoCollapse?: boolean | null | undefined;
|
|
14
14
|
'data-test'?: string | null | undefined;
|
|
15
15
|
}
|
|
16
16
|
declare class Tabs extends PureComponent<TabsProps> {
|
|
17
|
-
|
|
18
|
-
onSelect(): void;
|
|
19
|
-
};
|
|
20
|
-
handleSelect: (arg: string) => () => void;
|
|
17
|
+
handleSelect: (arg: string) => () => void | undefined;
|
|
21
18
|
getTabTitle: (child: ReactElement<TabProps>, i: number) => React.JSX.Element;
|
|
22
19
|
render(): React.JSX.Element;
|
|
23
20
|
}
|
|
@@ -9,29 +9,26 @@ import CollapsibleTabs from './collapsible-tabs';
|
|
|
9
9
|
import { CustomItem } from './custom-item';
|
|
10
10
|
export { CustomItem };
|
|
11
11
|
class Tabs extends PureComponent {
|
|
12
|
-
|
|
13
|
-
onSelect() { },
|
|
14
|
-
};
|
|
15
|
-
handleSelect = memoize((key) => () => this.props.onSelect(key));
|
|
12
|
+
handleSelect = memoize((key) => () => this.props.onSelect?.(key));
|
|
16
13
|
getTabTitle = (child, i) => {
|
|
17
14
|
if (child == null || typeof child !== 'object' || child.type === CustomItem) {
|
|
18
15
|
return child;
|
|
19
16
|
}
|
|
20
|
-
const { selected } = this.props;
|
|
17
|
+
const { selected, onSelect } = this.props;
|
|
21
18
|
const { title, titleProps, id, disabled, href, className, activeClassName } = child.props;
|
|
22
19
|
const key = id || String(i);
|
|
23
20
|
const isSelected = key === selected;
|
|
24
21
|
const titleClasses = classNames(styles.title, className, isSelected && activeClassName, {
|
|
25
22
|
[styles.selected]: isSelected,
|
|
26
23
|
});
|
|
27
|
-
return (<TabLink title={title} isSelected={isSelected} key={key} href={href} className={titleClasses} disabled={disabled} onPlainLeftClick={this.handleSelect(key)} {...titleProps}/>);
|
|
24
|
+
return (<TabLink title={title} isSelected={isSelected} key={key} href={href} className={titleClasses} disabled={disabled} onPlainLeftClick={onSelect != null ? this.handleSelect(key) : undefined} {...titleProps}/>);
|
|
28
25
|
};
|
|
29
26
|
render() {
|
|
30
|
-
const { className, tabContainerClassName, children, selected, autoCollapse, 'data-test': dataTest, ...restProps } = this.props;
|
|
27
|
+
const { className, tabContainerClassName, children, selected, autoCollapse, 'data-test': dataTest, onSelect, ...restProps } = this.props;
|
|
31
28
|
const classes = classNames(styles.tabs, className);
|
|
32
29
|
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
33
30
|
return (<div className={classes} data-test={dataTests('ring-dumb-tabs', dataTest)}>
|
|
34
|
-
{autoCollapse === true ? (<CollapsibleTabs {...restProps} onSelect={this.handleSelect} selected={selected}>
|
|
31
|
+
{autoCollapse === true ? (<CollapsibleTabs {...restProps} onSelect={onSelect != null ? this.handleSelect : undefined} selected={selected}>
|
|
35
32
|
{childrenArray}
|
|
36
33
|
</CollapsibleTabs>) : (<div className={styles.titles}>{childrenArray.map(this.getTabTitle)}</div>)}
|
|
37
34
|
<div className={classNames(tabContainerClassName)}>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.8",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@csstools/css-parser-algorithms": "^3.0.4",
|
|
84
84
|
"@csstools/stylelint-no-at-nest-rule": "^4.0.0",
|
|
85
85
|
"@eslint/compat": "^1.2.3",
|
|
86
|
-
"@eslint/eslintrc": "^3.
|
|
87
|
-
"@eslint/js": "^9.
|
|
86
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
87
|
+
"@eslint/js": "^9.15.0",
|
|
88
88
|
"@jetbrains/eslint-config": "^6.0.4",
|
|
89
89
|
"@jetbrains/logos": "3.0.0-canary.734b213.0",
|
|
90
90
|
"@jetbrains/stylelint-config": "^4.0.2",
|
|
@@ -94,18 +94,18 @@
|
|
|
94
94
|
"@rollup/plugin-json": "^6.1.0",
|
|
95
95
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
96
96
|
"@rollup/plugin-replace": "^6.0.1",
|
|
97
|
-
"@storybook/addon-a11y": "8.4.
|
|
98
|
-
"@storybook/addon-docs": "8.4.
|
|
99
|
-
"@storybook/addon-essentials": "8.4.
|
|
100
|
-
"@storybook/addon-themes": "^8.4.
|
|
101
|
-
"@storybook/components": "8.4.
|
|
97
|
+
"@storybook/addon-a11y": "8.4.5",
|
|
98
|
+
"@storybook/addon-docs": "8.4.5",
|
|
99
|
+
"@storybook/addon-essentials": "8.4.5",
|
|
100
|
+
"@storybook/addon-themes": "^8.4.5",
|
|
101
|
+
"@storybook/components": "8.4.5",
|
|
102
102
|
"@storybook/csf": "^0.1.11",
|
|
103
|
-
"@storybook/manager-api": "8.4.
|
|
104
|
-
"@storybook/preview-api": "8.4.
|
|
105
|
-
"@storybook/react": "8.4.
|
|
106
|
-
"@storybook/react-webpack5": "8.4.
|
|
103
|
+
"@storybook/manager-api": "8.4.5",
|
|
104
|
+
"@storybook/preview-api": "8.4.5",
|
|
105
|
+
"@storybook/react": "8.4.5",
|
|
106
|
+
"@storybook/react-webpack5": "8.4.5",
|
|
107
107
|
"@storybook/test-runner": "^0.19.1",
|
|
108
|
-
"@storybook/theming": "8.4.
|
|
108
|
+
"@storybook/theming": "8.4.5",
|
|
109
109
|
"@testing-library/dom": "^10.4.0",
|
|
110
110
|
"@testing-library/react": "^16.0.1",
|
|
111
111
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -127,16 +127,16 @@
|
|
|
127
127
|
"acorn": "^8.14.0",
|
|
128
128
|
"axe-playwright": "^2.0.3",
|
|
129
129
|
"babel-plugin-require-context-hook": "^1.0.0",
|
|
130
|
-
"caniuse-lite": "^1.0.
|
|
130
|
+
"caniuse-lite": "^1.0.30001684",
|
|
131
131
|
"chai": "^5.1.2",
|
|
132
|
-
"chai-as-promised": "^8.0.
|
|
132
|
+
"chai-as-promised": "^8.0.1",
|
|
133
133
|
"chai-dom": "^1.10.0",
|
|
134
134
|
"chai-enzyme": "1.0.0-beta.1",
|
|
135
135
|
"cheerio": "^1.0.0-rc.12",
|
|
136
136
|
"core-js": "^3.39.0",
|
|
137
137
|
"cpy-cli": "^5.0.0",
|
|
138
138
|
"enzyme": "^3.11.0",
|
|
139
|
-
"eslint": "^9.
|
|
139
|
+
"eslint": "^9.15.0",
|
|
140
140
|
"eslint-config-prettier": "^9.1.0",
|
|
141
141
|
"eslint-formatter-jslint-xml": "^8.40.0",
|
|
142
142
|
"eslint-import-resolver-webpack": "^0.13.9",
|
|
@@ -145,13 +145,13 @@
|
|
|
145
145
|
"eslint-plugin-prettier": "^5.2.1",
|
|
146
146
|
"eslint-plugin-react": "^7.37.2",
|
|
147
147
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
148
|
-
"eslint-plugin-storybook": "^0.11.
|
|
148
|
+
"eslint-plugin-storybook": "^0.11.1",
|
|
149
149
|
"events": "^3.3.0",
|
|
150
150
|
"glob": "^11.0.0",
|
|
151
151
|
"globals": "^15.12.0",
|
|
152
152
|
"html-webpack-plugin": "^5.6.3",
|
|
153
153
|
"http-server": "^14.1.1",
|
|
154
|
-
"husky": "^9.1.
|
|
154
|
+
"husky": "^9.1.7",
|
|
155
155
|
"identity-obj-proxy": "^3.0.0",
|
|
156
156
|
"jest": "~29.7.0",
|
|
157
157
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -167,18 +167,18 @@
|
|
|
167
167
|
"react-test-renderer": "^18.3.1",
|
|
168
168
|
"regenerator-runtime": "^0.14.1",
|
|
169
169
|
"rimraf": "^6.0.1",
|
|
170
|
-
"rollup": "^4.
|
|
170
|
+
"rollup": "^4.27.4",
|
|
171
171
|
"rollup-plugin-clear": "^2.0.7",
|
|
172
172
|
"sinon": "^19.0.2",
|
|
173
173
|
"sinon-chai": "^4.0.0",
|
|
174
174
|
"storage-mock": "^2.1.0",
|
|
175
|
-
"storybook": "8.4.
|
|
175
|
+
"storybook": "8.4.5",
|
|
176
176
|
"stylelint": "^16.10.0",
|
|
177
177
|
"svg-inline-loader": "^0.8.2",
|
|
178
178
|
"teamcity-service-messages": "^0.1.14",
|
|
179
179
|
"terser-webpack-plugin": "^5.3.10",
|
|
180
180
|
"typescript": "~5.6.3",
|
|
181
|
-
"typescript-eslint": "^8.
|
|
181
|
+
"typescript-eslint": "^8.15.0",
|
|
182
182
|
"vitest": "^2.1.5",
|
|
183
183
|
"vitest-teamcity-reporter": "^0.3.1",
|
|
184
184
|
"wallaby-webpack": "^3.9.16",
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
"@jetbrains/postcss-require-hover": "^0.1.2",
|
|
214
214
|
"@types/combokeys": "^2.4.9",
|
|
215
215
|
"@types/element-resize-detector": "^1.1.6",
|
|
216
|
-
"@types/react-virtualized": "9.
|
|
216
|
+
"@types/react-virtualized": "9.22.0",
|
|
217
217
|
"@types/util-deprecate": "^1.0.4",
|
|
218
218
|
"babel-loader": "9.2.1",
|
|
219
219
|
"babel-plugin-transform-define": "^2.1.4",
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
"es6-error": "^4.1.1",
|
|
230
230
|
"fastdom": "^1.0.12",
|
|
231
231
|
"file-loader": "^6.2.0",
|
|
232
|
-
"focus-trap": "^7.6.
|
|
232
|
+
"focus-trap": "^7.6.2",
|
|
233
233
|
"highlight.js": "^10.7.2",
|
|
234
234
|
"just-debounce-it": "^3.2.0",
|
|
235
235
|
"memoize-one": "^6.0.0",
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"postcss-font-family-system-ui": "^5.0.0",
|
|
240
240
|
"postcss-loader": "^8.1.1",
|
|
241
241
|
"postcss-modules-values-replace": "^4.2.0",
|
|
242
|
-
"postcss-preset-env": "^10.1.
|
|
242
|
+
"postcss-preset-env": "^10.1.1",
|
|
243
243
|
"react-movable": "^3.3.1",
|
|
244
244
|
"react-virtualized": "^9.22.5",
|
|
245
245
|
"react-waypoint": "^10.3.0",
|