@itwin/itwinui-react 3.0.0-dev.12 → 3.0.0-dev.14
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/CHANGELOG.md +43 -0
- package/cjs/core/Carousel/Carousel.d.ts +12 -5
- package/cjs/core/Carousel/Carousel.js +9 -39
- package/cjs/core/Carousel/CarouselContext.d.ts +0 -4
- package/cjs/core/Carousel/CarouselDot.js +1 -1
- package/cjs/core/Carousel/CarouselDotsList.js +26 -2
- package/cjs/core/Carousel/CarouselNavigation.d.ts +1 -1
- package/cjs/core/Carousel/CarouselNavigation.js +4 -17
- package/cjs/core/Carousel/CarouselSlide.d.ts +1 -1
- package/cjs/core/Carousel/CarouselSlide.js +12 -2
- package/cjs/core/Carousel/CarouselSlider.d.ts +1 -1
- package/cjs/core/Carousel/CarouselSlider.js +2 -2
- package/cjs/core/ColorPicker/ColorBuilder.js +2 -0
- package/cjs/core/ColorPicker/ColorInputPanel.js +24 -4
- package/cjs/core/ColorPicker/ColorPalette.js +2 -80
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ColorPicker/ColorSwatch.js +25 -15
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +1 -1
- package/cjs/core/LabeledSelect/LabeledSelect.js +3 -3
- package/cjs/core/Select/Select.d.ts +1 -1
- package/cjs/core/Select/Select.js +6 -4
- package/cjs/core/Slider/Slider.d.ts +2 -6
- package/cjs/core/Slider/Slider.js +8 -22
- package/cjs/core/Slider/Thumb.d.ts +1 -2
- package/cjs/core/Slider/Thumb.js +1 -5
- package/cjs/core/Tabs/Tabs.d.ts +222 -52
- package/cjs/core/Tabs/Tabs.js +429 -375
- package/cjs/core/ThemeProvider/ThemeProvider.js +3 -1
- package/cjs/core/Tile/Tile.js +11 -10
- package/cjs/core/utils/hooks/useOverflow.js +3 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +1 -2
- package/cjs/styles.js +10 -10
- package/esm/core/Carousel/Carousel.d.ts +12 -5
- package/esm/core/Carousel/Carousel.js +9 -39
- package/esm/core/Carousel/CarouselContext.d.ts +0 -4
- package/esm/core/Carousel/CarouselDot.js +1 -1
- package/esm/core/Carousel/CarouselDotsList.js +26 -2
- package/esm/core/Carousel/CarouselNavigation.d.ts +1 -1
- package/esm/core/Carousel/CarouselNavigation.js +5 -22
- package/esm/core/Carousel/CarouselSlide.d.ts +1 -1
- package/esm/core/Carousel/CarouselSlide.js +15 -3
- package/esm/core/Carousel/CarouselSlider.d.ts +1 -1
- package/esm/core/Carousel/CarouselSlider.js +2 -2
- package/esm/core/ColorPicker/ColorBuilder.js +2 -0
- package/esm/core/ColorPicker/ColorInputPanel.js +25 -5
- package/esm/core/ColorPicker/ColorPalette.js +3 -83
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ColorPicker/ColorSwatch.js +18 -12
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +1 -1
- package/esm/core/LabeledSelect/LabeledSelect.js +3 -2
- package/esm/core/Select/Select.d.ts +1 -1
- package/esm/core/Select/Select.js +3 -3
- package/esm/core/Slider/Slider.d.ts +2 -6
- package/esm/core/Slider/Slider.js +8 -19
- package/esm/core/Slider/Thumb.d.ts +1 -2
- package/esm/core/Slider/Thumb.js +1 -5
- package/esm/core/Tabs/Tabs.d.ts +222 -52
- package/esm/core/Tabs/Tabs.js +424 -368
- package/esm/core/ThemeProvider/ThemeProvider.js +3 -1
- package/esm/core/Tile/Tile.js +11 -10
- package/esm/core/utils/hooks/useOverflow.js +3 -1
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/styles.js +10 -10
- package/package.json +2 -2
- package/styles.css +33 -47
- package/cjs/core/Tabs/Tab.d.ts +0 -40
- package/cjs/core/Tabs/Tab.js +0 -65
- package/esm/core/Tabs/Tab.d.ts +0 -40
- package/esm/core/Tabs/Tab.js +0 -57
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import {
|
|
8
|
-
ColorValue,
|
|
9
|
-
getFocusableElements,
|
|
10
|
-
useMergedRefs,
|
|
11
|
-
Box,
|
|
12
|
-
} from '../utils/index.js';
|
|
7
|
+
import { ColorValue, Box } from '../utils/index.js';
|
|
13
8
|
import { getColorValue } from './ColorPicker.js';
|
|
14
9
|
import { ColorSwatch } from './ColorSwatch.js';
|
|
15
10
|
import { useColorPickerContext } from './ColorPickerContext.js';
|
|
@@ -28,76 +23,6 @@ export const ColorPalette = React.forwardRef((props, ref) => {
|
|
|
28
23
|
const { colors, label, className, children, ...rest } = props;
|
|
29
24
|
const { activeColor, setActiveColor, onChangeComplete } =
|
|
30
25
|
useColorPickerContext();
|
|
31
|
-
const [focusedIndex, setFocusedIndex] = React.useState();
|
|
32
|
-
// callback ref to set tabindex=0 on first child if none of the swatches are tabbable
|
|
33
|
-
const setDefaultTabIndex = (el) => {
|
|
34
|
-
if (el && !el.querySelector('[tabindex="0"]')) {
|
|
35
|
-
el.firstElementChild?.setAttribute('tabindex', '0');
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const paletteRef = React.useRef(null);
|
|
39
|
-
const paletteRefs = useMergedRefs(paletteRef, setDefaultTabIndex);
|
|
40
|
-
// Color palette arrow key navigation
|
|
41
|
-
const handleKeyDown = (event) => {
|
|
42
|
-
if (event.altKey) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const swatches = getFocusableElements(paletteRef.current);
|
|
46
|
-
if (!swatches.length) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const currentIndex = swatches.findIndex(
|
|
50
|
-
(swatch) => swatch === paletteRef.current?.ownerDocument.activeElement,
|
|
51
|
-
);
|
|
52
|
-
if (currentIndex < 0) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
let newIndex = -1;
|
|
56
|
-
switch (event.key) {
|
|
57
|
-
case 'ArrowDown': {
|
|
58
|
-
// Look for next ColorSwatch with same offsetLeft value
|
|
59
|
-
newIndex = swatches.findIndex(
|
|
60
|
-
(swatch, index) =>
|
|
61
|
-
index > currentIndex &&
|
|
62
|
-
swatch.offsetLeft === swatches[currentIndex].offsetLeft,
|
|
63
|
-
);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case 'ArrowUp': {
|
|
67
|
-
// Look backwards for next ColorSwatch with same offsetLeft value
|
|
68
|
-
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
69
|
-
if (swatches[i].offsetLeft === swatches[currentIndex].offsetLeft) {
|
|
70
|
-
newIndex = i;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'ArrowLeft':
|
|
77
|
-
newIndex = Math.max(currentIndex - 1, 0);
|
|
78
|
-
break;
|
|
79
|
-
case 'ArrowRight':
|
|
80
|
-
newIndex = Math.min(currentIndex + 1, swatches.length - 1);
|
|
81
|
-
break;
|
|
82
|
-
case 'Enter':
|
|
83
|
-
case ' ':
|
|
84
|
-
case 'Spacebar':
|
|
85
|
-
swatches[currentIndex].click();
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (newIndex >= 0 && newIndex < swatches.length) {
|
|
90
|
-
setFocusedIndex(newIndex);
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
// call focus() when focusedIndex changes
|
|
95
|
-
React.useEffect(() => {
|
|
96
|
-
if (focusedIndex != null) {
|
|
97
|
-
const swatches = getFocusableElements(paletteRef.current);
|
|
98
|
-
swatches[focusedIndex]?.focus();
|
|
99
|
-
}
|
|
100
|
-
}, [focusedIndex]);
|
|
101
26
|
return React.createElement(
|
|
102
27
|
Box,
|
|
103
28
|
{
|
|
@@ -113,11 +38,7 @@ export const ColorPalette = React.forwardRef((props, ref) => {
|
|
|
113
38
|
),
|
|
114
39
|
React.createElement(
|
|
115
40
|
Box,
|
|
116
|
-
{
|
|
117
|
-
className: 'iui-color-palette',
|
|
118
|
-
onKeyDown: handleKeyDown,
|
|
119
|
-
ref: paletteRefs,
|
|
120
|
-
},
|
|
41
|
+
{ className: 'iui-color-palette' },
|
|
121
42
|
children,
|
|
122
43
|
colors &&
|
|
123
44
|
colors.map((_color, index) => {
|
|
@@ -125,8 +46,7 @@ export const ColorPalette = React.forwardRef((props, ref) => {
|
|
|
125
46
|
return React.createElement(ColorSwatch, {
|
|
126
47
|
key: index,
|
|
127
48
|
color: color,
|
|
128
|
-
onClick: (
|
|
129
|
-
event.preventDefault();
|
|
49
|
+
onClick: () => {
|
|
130
50
|
onChangeComplete?.(color);
|
|
131
51
|
setActiveColor(color);
|
|
132
52
|
},
|
|
@@ -16,5 +16,5 @@ type ColorSwatchProps = {
|
|
|
16
16
|
* <ColorSwatch color='#23450b' onClick={onClick}/>
|
|
17
17
|
* <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
|
|
18
18
|
*/
|
|
19
|
-
export declare const ColorSwatch: PolymorphicForwardRefComponent<"
|
|
19
|
+
export declare const ColorSwatch: PolymorphicForwardRefComponent<"button", ColorSwatchProps>;
|
|
20
20
|
export default ColorSwatch;
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { ColorValue, Box } from '../utils/index.js';
|
|
7
|
+
import { ColorValue, Box, ButtonBase } from '../utils/index.js';
|
|
8
8
|
import { getColorValue } from './ColorPicker.js';
|
|
9
|
+
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.js';
|
|
9
10
|
/**
|
|
10
11
|
* ColorSwatch component to display within a color palette.
|
|
11
12
|
* @example
|
|
@@ -21,17 +22,22 @@ export const ColorSwatch = React.forwardRef((props, ref) => {
|
|
|
21
22
|
: getColorValue(color).toHslString(true),
|
|
22
23
|
[color],
|
|
23
24
|
);
|
|
24
|
-
return React.createElement(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'
|
|
28
|
-
|
|
25
|
+
return React.createElement(
|
|
26
|
+
Box,
|
|
27
|
+
{
|
|
28
|
+
as: !!onClick ? ButtonBase : 'span',
|
|
29
|
+
className: cx('iui-color-swatch', { 'iui-active': isActive }, className),
|
|
30
|
+
style: {
|
|
31
|
+
'--iui-color-swatch-background': colorString,
|
|
32
|
+
...style,
|
|
33
|
+
},
|
|
34
|
+
onClick: onClick,
|
|
35
|
+
'aria-pressed': !!onClick && isActive ? 'true' : undefined,
|
|
36
|
+
ref: ref,
|
|
37
|
+
...rest,
|
|
29
38
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ref: ref,
|
|
34
|
-
...rest,
|
|
35
|
-
});
|
|
39
|
+
props.children ??
|
|
40
|
+
React.createElement(VisuallyHidden, null, colorString.toUpperCase()),
|
|
41
|
+
);
|
|
36
42
|
});
|
|
37
43
|
export default ColorSwatch;
|
|
@@ -76,5 +76,5 @@ export type LabeledSelectProps<T> = {
|
|
|
76
76
|
* svgIcon={<SvgCamera />}
|
|
77
77
|
* />
|
|
78
78
|
*/
|
|
79
|
-
export declare const LabeledSelect: <
|
|
79
|
+
export declare const LabeledSelect: React.ForwardRefExoticComponent<LabeledSelectProps<unknown> & React.RefAttributes<HTMLElement>>;
|
|
80
80
|
export default LabeledSelect;
|
|
@@ -42,7 +42,7 @@ import { Icon } from '../Icon/Icon.js';
|
|
|
42
42
|
* svgIcon={<SvgCamera />}
|
|
43
43
|
* />
|
|
44
44
|
*/
|
|
45
|
-
export const LabeledSelect = (props) => {
|
|
45
|
+
export const LabeledSelect = React.forwardRef((props, forwardedRef) => {
|
|
46
46
|
const {
|
|
47
47
|
className,
|
|
48
48
|
disabled = false,
|
|
@@ -91,6 +91,7 @@ export const LabeledSelect = (props) => {
|
|
|
91
91
|
style: style,
|
|
92
92
|
status: status,
|
|
93
93
|
...rest,
|
|
94
|
+
ref: forwardedRef,
|
|
94
95
|
triggerProps: {
|
|
95
96
|
'aria-labelledby': labelId,
|
|
96
97
|
...triggerProps,
|
|
@@ -109,5 +110,5 @@ export const LabeledSelect = (props) => {
|
|
|
109
110
|
)
|
|
110
111
|
: message,
|
|
111
112
|
);
|
|
112
|
-
};
|
|
113
|
+
});
|
|
113
114
|
export default LabeledSelect;
|
|
@@ -168,5 +168,5 @@ export type SelectProps<T> = {
|
|
|
168
168
|
* )}
|
|
169
169
|
* />
|
|
170
170
|
*/
|
|
171
|
-
export declare const Select: <
|
|
171
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps<unknown> & React.RefAttributes<HTMLElement>>;
|
|
172
172
|
export default Select;
|
|
@@ -75,7 +75,7 @@ const isSingleOnChange = (onChange, multiple) => {
|
|
|
75
75
|
* )}
|
|
76
76
|
* />
|
|
77
77
|
*/
|
|
78
|
-
export const Select = (props) => {
|
|
78
|
+
export const Select = React.forwardRef((props, forwardedRef) => {
|
|
79
79
|
const uid = useId();
|
|
80
80
|
const {
|
|
81
81
|
options,
|
|
@@ -194,7 +194,7 @@ export const Select = (props) => {
|
|
|
194
194
|
className: cx('iui-input-with-icon', className),
|
|
195
195
|
style: style,
|
|
196
196
|
...rest,
|
|
197
|
-
ref: popover.refs.setPositionReference,
|
|
197
|
+
ref: useMergedRefs(popover.refs.setPositionReference, forwardedRef),
|
|
198
198
|
},
|
|
199
199
|
React.createElement(
|
|
200
200
|
Box,
|
|
@@ -281,7 +281,7 @@ export const Select = (props) => {
|
|
|
281
281
|
),
|
|
282
282
|
),
|
|
283
283
|
);
|
|
284
|
-
};
|
|
284
|
+
});
|
|
285
285
|
const SingleSelectButton = ({ selectedItem, selectedItemRenderer }) => {
|
|
286
286
|
const startIcon = selectedItem?.startIcon ?? selectedItem?.icon;
|
|
287
287
|
return React.createElement(
|
|
@@ -65,9 +65,9 @@ export type SliderProps = {
|
|
|
65
65
|
*/
|
|
66
66
|
maxLabel?: React.ReactNode;
|
|
67
67
|
/**
|
|
68
|
-
* Additional props for container `<div>` that hold the slider
|
|
68
|
+
* Additional props for container `<div>` that hold the slider thumbs, and tracks.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
trackContainerProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
71
71
|
/**
|
|
72
72
|
* Allows props to be passed for slider-min
|
|
73
73
|
*/
|
|
@@ -76,10 +76,6 @@ export type SliderProps = {
|
|
|
76
76
|
* Allows props to be passed for slider-max
|
|
77
77
|
*/
|
|
78
78
|
maxProps?: React.ComponentProps<'span'>;
|
|
79
|
-
/**
|
|
80
|
-
* Allows props to be passed for slider-rail
|
|
81
|
-
*/
|
|
82
|
-
railProps?: React.ComponentProps<'div'>;
|
|
83
79
|
/**
|
|
84
80
|
* Allows props to be passed for slider-track
|
|
85
81
|
*/
|
|
@@ -78,10 +78,9 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
78
78
|
onUpdate,
|
|
79
79
|
thumbProps,
|
|
80
80
|
className,
|
|
81
|
-
|
|
81
|
+
trackContainerProps,
|
|
82
82
|
minProps,
|
|
83
83
|
maxProps,
|
|
84
|
-
railProps,
|
|
85
84
|
trackProps,
|
|
86
85
|
tickProps,
|
|
87
86
|
ticksProps,
|
|
@@ -306,12 +305,9 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
306
305
|
Box,
|
|
307
306
|
{
|
|
308
307
|
ref: ref,
|
|
309
|
-
className: cx(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
{ 'iui-disabled': disabled },
|
|
313
|
-
className,
|
|
314
|
-
),
|
|
308
|
+
className: cx('iui-slider-container', className),
|
|
309
|
+
'data-iui-orientation': orientation,
|
|
310
|
+
'data-iui-disabled': disabled ? 'true' : undefined,
|
|
315
311
|
...rest,
|
|
316
312
|
},
|
|
317
313
|
minValueLabel &&
|
|
@@ -327,23 +323,17 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
327
323
|
React.createElement(
|
|
328
324
|
Box,
|
|
329
325
|
{
|
|
330
|
-
as: 'div',
|
|
331
326
|
ref: containerRef,
|
|
332
|
-
...
|
|
327
|
+
...trackContainerProps,
|
|
333
328
|
className: cx(
|
|
334
|
-
'iui-slider
|
|
329
|
+
'iui-slider',
|
|
335
330
|
{
|
|
336
331
|
'iui-grabbing': undefined !== activeThumbIndex,
|
|
337
332
|
},
|
|
338
|
-
|
|
333
|
+
trackContainerProps?.className,
|
|
339
334
|
),
|
|
340
335
|
onPointerDown: handlePointerDownOnSlider,
|
|
341
336
|
},
|
|
342
|
-
React.createElement(Box, {
|
|
343
|
-
as: 'div',
|
|
344
|
-
...railProps,
|
|
345
|
-
className: cx('iui-slider-rail', railProps?.className),
|
|
346
|
-
}),
|
|
347
337
|
currentValues.map((thumbValue, index) => {
|
|
348
338
|
const [minVal, maxVal] = getAllowableThumbRange(index);
|
|
349
339
|
const thisThumbProps = thumbProps?.(index);
|
|
@@ -362,7 +352,6 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
362
352
|
step: step,
|
|
363
353
|
sliderMin: min,
|
|
364
354
|
sliderMax: max,
|
|
365
|
-
orientation: orientation,
|
|
366
355
|
});
|
|
367
356
|
}),
|
|
368
357
|
React.createElement(Track, {
|
|
@@ -373,8 +362,8 @@ export const Slider = React.forwardRef((props, ref) => {
|
|
|
373
362
|
orientation: orientation,
|
|
374
363
|
...trackProps,
|
|
375
364
|
}),
|
|
376
|
-
tickMarkArea,
|
|
377
365
|
),
|
|
366
|
+
tickMarkArea,
|
|
378
367
|
maxValueLabel &&
|
|
379
368
|
React.createElement(
|
|
380
369
|
Box,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
3
|
-
import type { SliderProps } from './Slider.js';
|
|
4
3
|
type ThumbProps = {
|
|
5
4
|
/**
|
|
6
5
|
* Thumb value.
|
|
@@ -54,7 +53,7 @@ type ThumbProps = {
|
|
|
54
53
|
* Additional props for Thumb.
|
|
55
54
|
*/
|
|
56
55
|
thumbProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
57
|
-
}
|
|
56
|
+
};
|
|
58
57
|
/**
|
|
59
58
|
* Thumb is a local component used to show and modify the values maintained by the Slider.
|
|
60
59
|
* Only one Thumb can be active at a time. A Thumb is made active when the user selects
|
package/esm/core/Slider/Thumb.js
CHANGED
|
@@ -26,7 +26,6 @@ export const Thumb = (props) => {
|
|
|
26
26
|
tooltipProps,
|
|
27
27
|
thumbProps,
|
|
28
28
|
disabled,
|
|
29
|
-
orientation,
|
|
30
29
|
} = props;
|
|
31
30
|
const thumbRef = React.useRef(null);
|
|
32
31
|
const handleOnKeyboardEvent = React.useCallback(
|
|
@@ -93,13 +92,10 @@ export const Thumb = (props) => {
|
|
|
93
92
|
},
|
|
94
93
|
React.createElement(Box, {
|
|
95
94
|
...rest,
|
|
96
|
-
'data-index': index,
|
|
97
95
|
ref: thumbRef,
|
|
98
96
|
style: {
|
|
99
97
|
...style,
|
|
100
|
-
|
|
101
|
-
? { insetInlineStart: `${lowPercent}%` }
|
|
102
|
-
: { insetBlockEnd: `${lowPercent}%` }),
|
|
98
|
+
'--iui-slider-thumb-position': `${lowPercent}%`,
|
|
103
99
|
},
|
|
104
100
|
className: cx('iui-slider-thumb', { 'iui-active': isActive }, className),
|
|
105
101
|
role: 'slider',
|
package/esm/core/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Whether to allow tabs list to scroll when there is overflow,
|
|
5
|
-
* i.e. when there is not enough space to fit all the tabs.
|
|
6
|
-
*
|
|
7
|
-
* Not applicable to types `pill` and `borderless`.
|
|
8
|
-
*/
|
|
9
|
-
useOverflow?: boolean;
|
|
10
|
-
};
|
|
11
|
-
type TabsOverflowProps = {
|
|
12
|
-
/**
|
|
13
|
-
* Options that can be specified to deal with tabs overflowing the allotted space.
|
|
14
|
-
*/
|
|
15
|
-
overflowOptions?: OverflowOptions;
|
|
16
|
-
/**
|
|
17
|
-
* Type of the tabs.
|
|
18
|
-
*
|
|
19
|
-
* If `orientation = 'vertical'`, `pill` is not applicable.
|
|
20
|
-
* @default 'default'
|
|
21
|
-
*/
|
|
22
|
-
type?: 'default';
|
|
23
|
-
} | {
|
|
24
|
-
type: 'pill' | 'borderless';
|
|
25
|
-
};
|
|
2
|
+
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
26
3
|
type TabsOrientationProps = {
|
|
27
4
|
/**
|
|
28
5
|
* Orientation of the tabs.
|
|
@@ -40,24 +17,85 @@ type TabsOrientationProps = {
|
|
|
40
17
|
orientation: 'vertical';
|
|
41
18
|
type?: 'default' | 'borderless';
|
|
42
19
|
};
|
|
43
|
-
type
|
|
20
|
+
type TabsWrapperOwnProps = {
|
|
44
21
|
/**
|
|
45
|
-
*
|
|
22
|
+
* Color of the bar on the active tab.
|
|
23
|
+
* @default 'blue'
|
|
24
|
+
*/
|
|
25
|
+
color?: 'blue' | 'green';
|
|
26
|
+
/**
|
|
27
|
+
* Control whether focusing tabs (using arrow keys) should automatically select them.
|
|
28
|
+
* Use 'manual' if tab panel content is not preloaded.
|
|
29
|
+
* @default 'auto'
|
|
30
|
+
*/
|
|
31
|
+
focusActivationMode?: 'auto' | 'manual';
|
|
32
|
+
/**
|
|
33
|
+
* Value of the tab that should be active on initial render.
|
|
46
34
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
35
|
+
* Should be used for uncontrolled state (when no `value` passed).
|
|
36
|
+
*
|
|
37
|
+
* If not specified, then first tab will be active by default.
|
|
49
38
|
*/
|
|
50
|
-
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Value of the active tab for controlled state.
|
|
42
|
+
*/
|
|
43
|
+
value?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Function that gets called when active tab is changed.
|
|
46
|
+
*
|
|
47
|
+
* Should be used alongside `value` prop.
|
|
48
|
+
*/
|
|
49
|
+
onValueChange?: (value: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Do not use.
|
|
52
|
+
*/
|
|
53
|
+
defaultChecked?: never;
|
|
54
|
+
} & TabsOrientationProps;
|
|
55
|
+
type TabListOwnProps = {
|
|
56
|
+
/**
|
|
57
|
+
* Tab items.
|
|
58
|
+
*/
|
|
59
|
+
children: React.ReactNode[];
|
|
60
|
+
};
|
|
61
|
+
type TabOwnProps = {
|
|
62
|
+
/**
|
|
63
|
+
* Value used to associate the tab with a given panel.
|
|
64
|
+
*/
|
|
65
|
+
value: string;
|
|
66
|
+
/**
|
|
67
|
+
* Tab label used for simple Tab construction.
|
|
68
|
+
* Cannot be used with tabs that have icons or descriptions.
|
|
69
|
+
*/
|
|
70
|
+
label?: string | React.ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Don't pass `id`, as it will be automatically set.
|
|
73
|
+
*/
|
|
74
|
+
id?: string;
|
|
75
|
+
};
|
|
76
|
+
type TabsActionsOwnProps = {
|
|
77
|
+
/**
|
|
78
|
+
* Passes props to the wrapper component for the actions
|
|
79
|
+
*/
|
|
80
|
+
wrapperProps?: React.ComponentPropsWithRef<'div'>;
|
|
81
|
+
};
|
|
82
|
+
type TabsPanelOwnProps = {
|
|
83
|
+
/**
|
|
84
|
+
* Value used to associate the panel with a given tab.
|
|
85
|
+
*/
|
|
86
|
+
value: string;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Don't pass `id`, as it will be automatically set.
|
|
89
|
+
*/
|
|
90
|
+
id?: string;
|
|
91
|
+
};
|
|
92
|
+
type TabsLegacyProps = {
|
|
51
93
|
/**
|
|
52
94
|
* Content displayed to the right/bottom of the horizontal/vertical tabs
|
|
53
95
|
*
|
|
54
96
|
* If `type = 'pill'`, `actions` is not applicable.
|
|
55
97
|
*/
|
|
56
98
|
actions?: React.ReactNode[];
|
|
57
|
-
} | {
|
|
58
|
-
type: 'pill';
|
|
59
|
-
};
|
|
60
|
-
export type TabsProps = {
|
|
61
99
|
/**
|
|
62
100
|
* Elements shown for each tab.
|
|
63
101
|
* Recommended to pass an array of `Tab` components.
|
|
@@ -98,33 +136,165 @@ export type TabsProps = {
|
|
|
98
136
|
* Content inside the tab panel.
|
|
99
137
|
*/
|
|
100
138
|
children?: React.ReactNode;
|
|
101
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Tabs will now overflow by default, so this prop does nothing.
|
|
141
|
+
*/
|
|
142
|
+
overflowOptions?: {
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Tabs will now overflow by default, so this prop does nothing.
|
|
145
|
+
*/
|
|
146
|
+
useOverflow?: boolean;
|
|
147
|
+
};
|
|
148
|
+
defaultValue?: never;
|
|
149
|
+
defaultChecked?: never;
|
|
150
|
+
} & TabsOrientationProps;
|
|
151
|
+
type TabLegacyProps = {
|
|
152
|
+
/**
|
|
153
|
+
* The main label shown in the tab.
|
|
154
|
+
*/
|
|
155
|
+
label?: React.ReactNode;
|
|
156
|
+
/**
|
|
157
|
+
* Secondary label shown below the main label.
|
|
158
|
+
*/
|
|
159
|
+
sublabel?: React.ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* Svg icon shown before the labels.
|
|
162
|
+
*/
|
|
163
|
+
startIcon?: JSX.Element;
|
|
164
|
+
/**
|
|
165
|
+
* Control whether the tab is disabled.
|
|
166
|
+
*/
|
|
167
|
+
disabled?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Custom content appended to the tab.
|
|
170
|
+
*/
|
|
171
|
+
children?: React.ReactNode;
|
|
172
|
+
/**
|
|
173
|
+
* `value` of the tab.
|
|
174
|
+
*
|
|
175
|
+
* Will be set by parent `Tabs` component.
|
|
176
|
+
*/
|
|
177
|
+
value?: string;
|
|
178
|
+
};
|
|
102
179
|
/**
|
|
103
|
-
*
|
|
180
|
+
* Legacy Tab component.
|
|
181
|
+
* For full functionality use composition API.
|
|
182
|
+
*
|
|
183
|
+
* Individual tab component to be used in the `labels` prop of `Tabs`.
|
|
104
184
|
* @example
|
|
105
185
|
* const tabs = [
|
|
106
|
-
* <Tab label='Label 1' />,
|
|
107
|
-
* <Tab label='Label 2' />,
|
|
108
|
-
* <Tab label='Label 3' />,
|
|
186
|
+
* <Tab label='Label 1' sublabel='Description 1' />,
|
|
187
|
+
* <Tab label='Label 2' startIcon={<SvgPlaceholder />} />,
|
|
109
188
|
* ];
|
|
110
|
-
|
|
111
|
-
|
|
189
|
+
*/
|
|
190
|
+
declare const LegacyTab: PolymorphicForwardRefComponent<"button", TabLegacyProps>;
|
|
191
|
+
export { LegacyTab as Tab };
|
|
192
|
+
/**
|
|
193
|
+
* Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy.
|
|
194
|
+
* `Tabs.Tab` and `Tabs.Panel` can be associated with each other by passing them the same `value`.
|
|
112
195
|
* @example
|
|
113
|
-
* <Tabs
|
|
196
|
+
* <Tabs.Wrapper>
|
|
197
|
+
* <Tabs.TabList>
|
|
198
|
+
* <Tabs.Tab value='tab1' label='Label 1' />
|
|
199
|
+
* <Tabs.Tab value='tab2' label='Label 2' />
|
|
200
|
+
* <Tabs.Tab value='tab3' label='Label 3' />
|
|
201
|
+
* </Tabs.TabList>
|
|
202
|
+
* <Tabs.ActionsWrapper>
|
|
203
|
+
* <Tabs.Actions>
|
|
204
|
+
* <Button>Sample Button</Button>
|
|
205
|
+
* </Tabs.Actions>
|
|
206
|
+
* </Tabs.ActionsWrapper>
|
|
207
|
+
* <Tabs.Panel value='tab1'>Content 1</Tabs.Panel>
|
|
208
|
+
* <Tabs.Panel value='tab2'>Content 2</Tabs.Panel>
|
|
209
|
+
* <Tabs.Panel value='tab3'>Content 3</Tabs.Panel>
|
|
210
|
+
* </Tabs.Wrapper>
|
|
114
211
|
*
|
|
115
212
|
* @example
|
|
116
|
-
*
|
|
117
|
-
* <Tab label='Label 1' sublabel='First tab' />,
|
|
118
|
-
* <Tab label='Label 2' sublabel='Active tab' />,
|
|
119
|
-
* ];
|
|
120
|
-
* <Tabs labels={tabsWithSublabels} activeIndex={1} />
|
|
213
|
+
* <Tabs orientation='vertical'/>
|
|
121
214
|
*
|
|
122
215
|
* @example
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* <
|
|
126
|
-
*
|
|
127
|
-
*
|
|
216
|
+
* <Tabs.Wrapper focusActivationMode='manual'>
|
|
217
|
+
* <Tabs.Tab value='sample'>
|
|
218
|
+
* <Tabs.TabIcon>
|
|
219
|
+
* <SvgPlaceholder />
|
|
220
|
+
* </Tabs.TabIcon>
|
|
221
|
+
* <Tabs.TabLabel>Sample Label</Tabs.TabLabel>
|
|
222
|
+
* <Tabs.TabDescription>Sample Description</Tabs.TabDescription>
|
|
223
|
+
* </Tabs.Tab>
|
|
224
|
+
* </Tabs.Wrapper>
|
|
128
225
|
*/
|
|
129
|
-
export declare const Tabs:
|
|
226
|
+
export declare const Tabs: PolymorphicForwardRefComponent<"div", TabsLegacyProps> & {
|
|
227
|
+
/**
|
|
228
|
+
* A wrapper component for Tabs
|
|
229
|
+
*/
|
|
230
|
+
Wrapper: PolymorphicForwardRefComponent<"div", TabsWrapperOwnProps>;
|
|
231
|
+
/**
|
|
232
|
+
* Tablist subcomponent which contains all of the tab subcomponents.
|
|
233
|
+
* @example
|
|
234
|
+
* <Tabs.TabList>
|
|
235
|
+
* <Tabs.Tab value='tab1' label='Label 1' />
|
|
236
|
+
* <Tabs.Tab value='tab2' label='Label 2' />
|
|
237
|
+
* <Tabs.Tab value='tab3' label='Label 3' />
|
|
238
|
+
* </Tabs.TabList>
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* <Tabs.TabList>
|
|
242
|
+
* <Tabs.Tab value='tab1' label='Green Tab' />
|
|
243
|
+
* </Tabs.TabList>
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* <Tabs.TabList focusActivationMode='manual'>
|
|
247
|
+
* <Tabs.Tab value='tab1' label='Manual Focus Tab' />
|
|
248
|
+
* </Tabs.TabList>
|
|
249
|
+
*/
|
|
250
|
+
TabList: PolymorphicForwardRefComponent<"div", TabListOwnProps>;
|
|
251
|
+
/**
|
|
252
|
+
* Tab subcomponent which is used for each of the tabs.
|
|
253
|
+
* @example
|
|
254
|
+
* <Tabs.Tab value='tab1' label='Label 1' />
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* <Tabs.Tab value='sample'>
|
|
258
|
+
* <Tabs.TabIcon>
|
|
259
|
+
* <SvgPlaceholder />
|
|
260
|
+
* </Tabs.TabIcon>
|
|
261
|
+
* <Tabs.TabLabel>Sample Label</Tabs.TabLabel>
|
|
262
|
+
* <Tabs.TabDescription>Sample Description</Tabs.TabDescription>
|
|
263
|
+
* </Tabs.Tab>
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
266
|
+
Tab: PolymorphicForwardRefComponent<"button", TabOwnProps>;
|
|
267
|
+
/**
|
|
268
|
+
* Tab icon subcomponent which places an icon on the left side of the tab.
|
|
269
|
+
*/
|
|
270
|
+
TabIcon: PolymorphicForwardRefComponent<"span", Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
271
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
272
|
+
}, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement> | "padded"> & {
|
|
273
|
+
size?: "small" | "auto" | "medium" | "large" | import("../utils/types.js").AnyString | undefined;
|
|
274
|
+
fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
|
|
275
|
+
padded?: boolean | undefined;
|
|
276
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
277
|
+
as?: "span" | undefined;
|
|
278
|
+
}>;
|
|
279
|
+
/**
|
|
280
|
+
* Tab label subcomponent which holds the tab's label.
|
|
281
|
+
*/
|
|
282
|
+
TabLabel: PolymorphicForwardRefComponent<"span", {}>;
|
|
283
|
+
/**
|
|
284
|
+
* Tab description subcomponent which places a description under the tab label.
|
|
285
|
+
*/
|
|
286
|
+
TabDescription: PolymorphicForwardRefComponent<"span", {}>;
|
|
287
|
+
/**
|
|
288
|
+
* Tab actions subcomponent which contains action buttons that are placed at the end of the tabs.
|
|
289
|
+
*/
|
|
290
|
+
Actions: PolymorphicForwardRefComponent<"div", TabsActionsOwnProps>;
|
|
291
|
+
/**
|
|
292
|
+
* Tab panel subcomponent which contains the tab's content.
|
|
293
|
+
* @example
|
|
294
|
+
* <Tabs.Panel value='tab1'>
|
|
295
|
+
* Sample Panel
|
|
296
|
+
* </Tabs.Panel>
|
|
297
|
+
*/
|
|
298
|
+
Panel: PolymorphicForwardRefComponent<"div", TabsPanelOwnProps>;
|
|
299
|
+
};
|
|
130
300
|
export default Tabs;
|