@wonderflow/react-components 2.38.0-next.9 → 2.39.0-next.2
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/button/button.module.css +15 -8
- package/card/card.d.ts +1 -1
- package/card/card.js +3 -3
- package/card/card.module.css +7 -2
- package/core/vibrancy.css +2 -3
- package/dropdown/dropdown.d.ts +9 -19
- package/dropdown/dropdown.js +5 -4
- package/grid/grid-item.d.ts +5 -1
- package/grid/grid-item.js +5 -4
- package/grid/grid.d.ts +5 -21
- package/grid/grid.js +1 -1
- package/grid/index.d.ts +1 -1
- package/grid/index.js +1 -1
- package/modal/modal.d.ts +5 -7
- package/modal/modal.js +5 -6
- package/package.json +1 -1
- package/tab/index.d.ts +1 -1
- package/tab/tab-item.d.ts +8 -0
- package/tab/tab-item.js +20 -0
- package/tab/tab-list.d.ts +3 -0
- package/tab/tab-list.js +7 -0
- package/tab/tab-panel.d.ts +10 -0
- package/tab/tab-panel.js +10 -0
- package/tab/tab.d.ts +11 -14
- package/tab/tab.js +11 -38
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/themes.css +3 -3
- package/toggle-button/toggle-button.js +1 -1
- package/toggle-button/toggle-button.module.css +1 -2
package/button/button.module.css
CHANGED
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
/* Types */
|
|
47
47
|
|
|
48
48
|
&[data-button-kind='primary'] {
|
|
49
|
-
background
|
|
49
|
+
background: var(--cta-default);
|
|
50
50
|
color: var(--cta-foreground);
|
|
51
51
|
|
|
52
52
|
&:is(:active) {
|
|
53
|
-
background
|
|
53
|
+
background: var(--cta-dark);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
&[aria-pressed='true'],
|
|
57
57
|
&[aria-pressed='true']:active {
|
|
58
|
-
background
|
|
58
|
+
background: hsl(env(--color-red-50));
|
|
59
59
|
color: hsl(env(--color-support-white));
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -64,34 +64,41 @@
|
|
|
64
64
|
|
|
65
65
|
@mixin vibrancy;
|
|
66
66
|
|
|
67
|
+
color: var(--global-vibrancy-foreground);
|
|
68
|
+
|
|
67
69
|
&:is(:active) {
|
|
68
70
|
|
|
69
71
|
@mixin vibrancy-hover;
|
|
72
|
+
|
|
73
|
+
color: var(--global-vibrancy-foreground);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
&[aria-pressed='true'],
|
|
73
77
|
&[aria-pressed='true']:active {
|
|
74
|
-
background-color: var(--dimmed-7);
|
|
75
78
|
color: var(--dimmed-0);
|
|
79
|
+
background: var(--dimmed-7);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
&[data-button-kind='flat'] {
|
|
80
|
-
color: var(--global-foreground);
|
|
84
|
+
color: var(--global-vibrancy-foreground);
|
|
81
85
|
|
|
82
86
|
&:is(:active) {
|
|
83
87
|
|
|
84
88
|
@mixin vibrancy-hover;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
&:is(:hover, :focus)
|
|
91
|
+
&:not([aria-pressed='true']):is(:hover, :focus) {
|
|
88
92
|
|
|
89
93
|
@mixin vibrancy;
|
|
94
|
+
|
|
95
|
+
color: var(--global-vibrancy-foreground);
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
&[aria-pressed='true'],
|
|
93
|
-
&[aria-pressed='true']:active {
|
|
94
|
-
|
|
99
|
+
&[aria-pressed='true']:is(:active, :focus) {
|
|
100
|
+
color: var(--dimmed-0);
|
|
101
|
+
background: var(--dimmed-7);
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
104
|
|
package/card/card.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare type CardProps = PropsWithClass & Pick<StackProps, 'wrap' | 'colu
|
|
|
9
9
|
radius?: false | TokensTypes['radius'];
|
|
10
10
|
dimmed?: 1 | 2 | 3;
|
|
11
11
|
vibrant?: boolean;
|
|
12
|
-
|
|
12
|
+
highlightOnHover?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare type PolymorphicCard = Polymorphic.ForwardRefComponent<'div', CardProps>;
|
|
15
15
|
export declare const Card: PolymorphicCard;
|
package/card/card.js
CHANGED
|
@@ -3,14 +3,14 @@ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
|
|
|
3
3
|
import { Stack } from '../';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { Card as CardClass, Left, Content, Right } from './card.module.css';
|
|
6
|
-
export const Card = forwardRef(({ as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, bordered, columnGap = 24, rowGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', vibrant = false,
|
|
6
|
+
export const Card = forwardRef(({ as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, bordered, columnGap = 24, rowGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', vibrant = false, highlightOnHover = false, wrap, style, ...props }, forwardedRef) => {
|
|
7
7
|
const dynamicStyle = {
|
|
8
8
|
'--padding': padding && tkns.space[padding],
|
|
9
9
|
'--radius': radius && tkns.radius[radius]
|
|
10
10
|
};
|
|
11
|
-
return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(CardClass, className), style: { ...dynamicStyle, ...style }, "data-card-dimmed": dimmed, "data-card-bordered": bordered, "data-card-vibrant": vibrant, "data-card-
|
|
11
|
+
return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(CardClass, className), style: { ...dynamicStyle, ...style }, "data-card-dimmed": dimmed, "data-card-bordered": bordered, "data-card-vibrant": vibrant, "data-card-highlight-hover": highlightOnHover, ...props },
|
|
12
12
|
React.createElement(Stack, { direction: "row", fill: false, verticalAlign: verticalAlign, horizontalAlign: horizontalAlign, columnGap: columnGap, rowGap: rowGap, wrap: wrap },
|
|
13
13
|
left && React.createElement("div", { className: Left }, left),
|
|
14
|
-
children && (React.createElement(
|
|
14
|
+
children && (React.createElement("div", { className: Content }, children)),
|
|
15
15
|
right && (React.createElement(Stack, { className: Right }, right)))));
|
|
16
16
|
});
|
package/card/card.module.css
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
&[data-card-dimmed='2'] {
|
|
14
|
-
background: var(--dimmed-
|
|
14
|
+
background: var(--dimmed-1);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&[data-card-dimmed='3'] {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
@mixin vibrancy;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
&[data-card-
|
|
26
|
+
&[data-card-highlight-hover='true'][data-card-vibrant='true']:hover,
|
|
27
|
+
&[data-card-highlight-hover='true'][data-card-vibrant='true']:focus-visible {
|
|
27
28
|
|
|
28
29
|
@mixin vibrancy-hover;
|
|
29
30
|
}
|
|
@@ -31,6 +32,10 @@
|
|
|
31
32
|
&[data-card-bordered='true'] {
|
|
32
33
|
border: solid 1px var(--dimmed-1);
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
&[data-card-vibrant='true'][data-card-bordered='true'] {
|
|
37
|
+
border: solid 1px var(--dimmed-2);
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
.Left {
|
package/core/vibrancy.css
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
@define-mixin vibrancy {
|
|
2
|
-
|
|
3
|
-
backdrop-filter: saturate(180%) blur(62);
|
|
2
|
+
backdrop-filter: saturate(180%) blur(62px);
|
|
4
3
|
background:
|
|
5
4
|
linear-gradient(
|
|
6
5
|
to bottom,
|
|
@@ -18,7 +17,7 @@
|
|
|
18
17
|
}
|
|
19
18
|
@define-mixin vibrancy-disabled {
|
|
20
19
|
color: var(--global-disabled-foreground);
|
|
21
|
-
backdrop-filter: saturate(180%) blur(
|
|
20
|
+
backdrop-filter: saturate(180%) blur(62px);
|
|
22
21
|
background:
|
|
23
22
|
linear-gradient(
|
|
24
23
|
to bottom,
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode, ForwardRefExoticComponent } from 'react';
|
|
2
|
+
import { DropdownMenuProps } from './dropdown-menu';
|
|
3
|
+
import { DropdownItemProps, DropdownItemCheckboxProps } from './dropdown-item';
|
|
2
4
|
import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core';
|
|
3
5
|
export declare type DropdownProps = PropsWithClass & {
|
|
4
6
|
children: ReactNode;
|
|
@@ -6,22 +8,10 @@ export declare type DropdownProps = PropsWithClass & {
|
|
|
6
8
|
offset?: number;
|
|
7
9
|
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} & React.RefAttributes<HTMLUListElement>>;
|
|
14
|
-
Item: import("../polymorphic/polymorphic").ForwardRefComponent<"button", import("./dropdown-item").DropdownItemProps>;
|
|
15
|
-
ItemCheckbox: import("../polymorphic/polymorphic").ForwardRefComponent<"button", PropsWithClass & {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
icon?: import("../icons/types").IconNames | undefined;
|
|
18
|
-
dimension?: "small" | "regular" | undefined;
|
|
19
|
-
onClick?(): void;
|
|
20
|
-
iconPosition?: "left" | "right" | undefined;
|
|
21
|
-
description?: React.ReactNode;
|
|
22
|
-
disabled?: boolean | undefined;
|
|
23
|
-
padding?: boolean | undefined;
|
|
24
|
-
} & {
|
|
25
|
-
checked?: boolean | undefined;
|
|
26
|
-
}>;
|
|
11
|
+
declare type DropdownComponent = ForwardRefExoticComponent<DropdownProps> & {
|
|
12
|
+
Menu: ForwardRefExoticComponent<DropdownMenuProps>;
|
|
13
|
+
Item: ForwardRefExoticComponent<DropdownItemProps>;
|
|
14
|
+
ItemCheckbox: ForwardRefExoticComponent<DropdownItemCheckboxProps>;
|
|
27
15
|
};
|
|
16
|
+
export declare const Dropdown: DropdownComponent;
|
|
17
|
+
export {};
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React, { useState, Children, cloneElement, useRef } from 'react';
|
|
2
|
+
import React, { useState, Children, cloneElement, useRef, forwardRef } from 'react';
|
|
3
3
|
import { useKey, useClickAway } from 'react-use';
|
|
4
4
|
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
5
5
|
import { useUIDSeed } from 'react-uid';
|
|
@@ -8,9 +8,9 @@ import { DropdownMenu } from './dropdown-menu';
|
|
|
8
8
|
import { DropdownItem, DropdownItemCheckbox } from './dropdown-item';
|
|
9
9
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
10
10
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
11
|
-
export const Dropdown = ({ className, children, trigger, offset = 8, placement = 'auto-start' }) => {
|
|
11
|
+
export const Dropdown = forwardRef(({ className, children, trigger, offset = 8, placement = 'auto-start' }, forwardedRef) => {
|
|
12
12
|
const seedID = useUIDSeed();
|
|
13
|
-
const popupRef = useRef(
|
|
13
|
+
const popupRef = useRef(forwardedRef);
|
|
14
14
|
const [isOpen, setIsOpen] = useState(false);
|
|
15
15
|
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
16
16
|
delayShow: 0,
|
|
@@ -45,7 +45,8 @@ export const Dropdown = ({ className, children, trigger, offset = 8, placement =
|
|
|
45
45
|
id: seedID('dropdown-menu'),
|
|
46
46
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
47
47
|
}))))))));
|
|
48
|
-
};
|
|
48
|
+
});
|
|
49
|
+
Dropdown.displayName = 'Dropdown';
|
|
49
50
|
Dropdown.Menu = DropdownMenu;
|
|
50
51
|
Dropdown.Item = DropdownItem;
|
|
51
52
|
Dropdown.ItemCheckbox = DropdownItemCheckbox;
|
package/grid/grid-item.d.ts
CHANGED
|
@@ -4,4 +4,8 @@ export declare type GridItemProps = PropsWithClass & {
|
|
|
4
4
|
column?: string;
|
|
5
5
|
row?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const GridItem: React.
|
|
7
|
+
export declare const GridItem: React.ForwardRefExoticComponent<PropsWithClass & {
|
|
8
|
+
fullWidth?: boolean | undefined;
|
|
9
|
+
column?: string | undefined;
|
|
10
|
+
row?: string | undefined;
|
|
11
|
+
} & React.RefAttributes<HTMLLIElement>>;
|
package/grid/grid-item.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { GridItem as GridItemClass } from './grid.module.css';
|
|
4
|
-
export const GridItem = ({ children, style, className, fullWidth = false, column, row, ...props }) => {
|
|
4
|
+
export const GridItem = forwardRef(({ children, style, className, fullWidth = false, column, row, ...props }, forwardedRef) => {
|
|
5
5
|
const dynamicStyle = {
|
|
6
6
|
'--column': column,
|
|
7
7
|
'--row': row
|
|
8
8
|
};
|
|
9
|
-
return (React.createElement("li", { className: clsx(GridItemClass, className), style: { ...dynamicStyle, ...style }, "data-grid-item-fullwidth": fullWidth, ...props }, children));
|
|
10
|
-
};
|
|
9
|
+
return (React.createElement("li", { ref: forwardedRef, className: clsx(GridItemClass, className), style: { ...dynamicStyle, ...style }, "data-grid-item-fullwidth": fullWidth, ...props }, children));
|
|
10
|
+
});
|
|
11
|
+
GridItem.displayName = 'Grid.Item';
|
package/grid/grid.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
|
|
3
|
+
import { GridItemProps } from './grid-item';
|
|
3
4
|
export declare type GridProps = PropsWithClass & {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
columns?: number;
|
|
@@ -10,25 +11,8 @@ export declare type GridProps = PropsWithClass & {
|
|
|
10
11
|
colMinWidth?: string;
|
|
11
12
|
rowMinHeight?: string;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
columns?: number | undefined;
|
|
16
|
-
rows?: number | undefined;
|
|
17
|
-
rowGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
|
|
18
|
-
columnGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
|
|
19
|
-
filling?: false | "fill" | "fit" | undefined;
|
|
20
|
-
colMinWidth?: string | undefined;
|
|
21
|
-
rowMinHeight?: string | undefined;
|
|
22
|
-
} & React.RefAttributes<HTMLUListElement>>;
|
|
23
|
-
export declare const GridRoot: React.ForwardRefExoticComponent<PropsWithClass & {
|
|
24
|
-
children: ReactNode;
|
|
25
|
-
columns?: number | undefined;
|
|
26
|
-
rows?: number | undefined;
|
|
27
|
-
rowGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
|
|
28
|
-
columnGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
|
|
29
|
-
filling?: false | "fill" | "fit" | undefined;
|
|
30
|
-
colMinWidth?: string | undefined;
|
|
31
|
-
rowMinHeight?: string | undefined;
|
|
32
|
-
} & React.RefAttributes<HTMLUListElement>> & {
|
|
33
|
-
Item: React.FC<import("./grid-item").GridItemProps>;
|
|
14
|
+
declare type GridComponent = React.ForwardRefExoticComponent<GridProps> & {
|
|
15
|
+
Item: React.ForwardRefExoticComponent<GridItemProps>;
|
|
34
16
|
};
|
|
17
|
+
export declare const Grid: GridComponent;
|
|
18
|
+
export {};
|
package/grid/grid.js
CHANGED
|
@@ -15,4 +15,4 @@ export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8
|
|
|
15
15
|
return (React.createElement("ul", { className: clsx(GridClass, className), style: { ...computedStyle, ...style }, "data-grid-filling-type": filling, ref: forwardedRef, ...props }, children));
|
|
16
16
|
});
|
|
17
17
|
Grid.displayName = 'Grid';
|
|
18
|
-
|
|
18
|
+
Grid.Item = GridItem;
|
package/grid/index.d.ts
CHANGED
package/grid/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Grid } from './grid';
|
package/modal/modal.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { ModalContentProps } from './modal-content';
|
|
2
3
|
export declare type ModalProps = PropsWithChildren<PropsWithClass> & {
|
|
3
4
|
visible?: boolean;
|
|
4
5
|
overlayColor?: 'light' | 'dark' | 'auto';
|
|
5
6
|
closeOnClickOutside?: boolean;
|
|
6
7
|
onClose(): void;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Root: React.FC<ModalProps>;
|
|
11
|
-
Content: React.ForwardRefExoticComponent<PropsWithClass & {
|
|
12
|
-
title: React.ReactNode;
|
|
13
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
-
displayName: string;
|
|
9
|
+
declare type ModalComponent = React.ForwardRefExoticComponent<ModalProps> & {
|
|
10
|
+
Content: React.ForwardRefExoticComponent<ModalContentProps>;
|
|
15
11
|
};
|
|
12
|
+
export declare const Modal: ModalComponent;
|
|
13
|
+
export {};
|
package/modal/modal.js
CHANGED
|
@@ -20,13 +20,12 @@ const ModalElement = forwardRef(({ children, className, overlayColor = 'dark', c
|
|
|
20
20
|
React.createElement(FocusOn, { onClickOutside: () => closeOnClickOutside && ctx.onClose(), onEscapeKey: ctx.onClose },
|
|
21
21
|
React.createElement(m.div, { key: seedID('modal-container'), className: Container, initial: { scale: 0.98, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.98, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, children))))))));
|
|
22
22
|
});
|
|
23
|
-
export const Modal = ({ visible, ...props }) => {
|
|
23
|
+
export const Modal = forwardRef(({ visible, ...props }, forwardedRef) => {
|
|
24
24
|
if (typeof visible === 'boolean') {
|
|
25
|
-
return (React.createElement(Presence, { exitBeforeEnter: true }, visible ? React.createElement(ModalElement, { ...props }) : null));
|
|
25
|
+
return (React.createElement(Presence, { exitBeforeEnter: true }, visible ? React.createElement(ModalElement, { ref: forwardedRef, ...props }) : null));
|
|
26
26
|
}
|
|
27
|
-
return (React.createElement(ModalElement, { ...props }));
|
|
28
|
-
};
|
|
29
|
-
Modal.Root = ModalElement;
|
|
27
|
+
return (React.createElement(ModalElement, { ref: forwardedRef, ...props }));
|
|
28
|
+
});
|
|
30
29
|
Modal.Content = ModalContent;
|
|
31
30
|
Modal.displayName = 'Modal';
|
|
32
|
-
ModalElement.displayName = 'Modal.
|
|
31
|
+
ModalElement.displayName = 'Modal.Content';
|
package/package.json
CHANGED
package/tab/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Tab } from './tab';
|
|
2
|
-
export type { TabProps
|
|
2
|
+
export type { TabProps } from './tab';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { IconNames } from '../icons/types';
|
|
3
|
+
export declare type TabItemProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
4
|
+
icon?: IconNames;
|
|
5
|
+
};
|
|
6
|
+
export declare const TabItem: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
7
|
+
icon?: IconNames | undefined;
|
|
8
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
package/tab/tab-item.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useCallback, useRef, forwardRef } from 'react';
|
|
2
|
+
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Stack, Icon } from '../';
|
|
5
|
+
import { useTabState } from './primitive-tab';
|
|
6
|
+
import { TabItem as TabItemClass } from './tab.module.css';
|
|
7
|
+
export const TabItem = forwardRef(({ children, className, icon, ...props }, forwardedRef) => {
|
|
8
|
+
const { onClick, isActive } = useTabState(children);
|
|
9
|
+
const internalRef = useRef(forwardedRef);
|
|
10
|
+
const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
|
|
11
|
+
useFocusEffect(focused, internalRef);
|
|
12
|
+
const fireClick = useCallback(() => {
|
|
13
|
+
onClick();
|
|
14
|
+
handleClick();
|
|
15
|
+
}, [handleClick, onClick]);
|
|
16
|
+
return (React.createElement(Stack, { as: "button", direction: "row", verticalAlign: "center", horizontalAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(TabItemClass, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, ...props },
|
|
17
|
+
icon && React.createElement(Icon, { name: icon, dimension: 16 }),
|
|
18
|
+
children));
|
|
19
|
+
});
|
|
20
|
+
TabItem.displayName = 'Tab.Item';
|
package/tab/tab-list.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { TabList as TabListClass } from './tab.module.css';
|
|
5
|
+
export const TabList = forwardRef(({ children, className, ...props }, forwardedRef) => (React.createElement("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(TabListClass, className), ...props },
|
|
6
|
+
React.createElement(RovingTabIndexProvider, null, children))));
|
|
7
|
+
TabList.displayName = 'Tab.List';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { IconNames } from '../icons/types';
|
|
3
|
+
export declare type TabPanelProps = PropsWithClass & {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
icon?: IconNames;
|
|
6
|
+
};
|
|
7
|
+
export declare const TabPanel: React.ForwardRefExoticComponent<PropsWithClass & {
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
icon?: IconNames | undefined;
|
|
10
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
package/tab/tab-panel.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { usePanelState } from './primitive-tab';
|
|
4
|
+
import { TabPanel as TabPanelClass } from './tab.module.css';
|
|
5
|
+
export const TabPanel = forwardRef(({ children, className, ...props }, forwardedRef) => {
|
|
6
|
+
const isActive = usePanelState(children);
|
|
7
|
+
return isActive
|
|
8
|
+
? (React.createElement("div", { ref: forwardedRef, tabIndex: 0, className: clsx(TabPanelClass, className), ...props }, children))
|
|
9
|
+
: null;
|
|
10
|
+
});
|
package/tab/tab.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import React, { ReactNode
|
|
2
|
-
import {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { TabItem } from './tab-item';
|
|
3
|
+
import { TabListProps } from './tab-list';
|
|
4
|
+
import { TabPanelProps } from './tab-panel';
|
|
5
|
+
import { Polymorphic } from '../';
|
|
3
6
|
export declare type TabProps = PropsWithClass & {
|
|
4
7
|
children: ReactNode;
|
|
5
8
|
state?: [number, React.Dispatch<React.SetStateAction<number>>];
|
|
6
9
|
onChange?(index: number): void;
|
|
7
10
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare type TabItemProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
13
|
-
icon?: IconNames;
|
|
14
|
-
};
|
|
15
|
-
export declare const Tab: {
|
|
16
|
-
Root: React.FC<TabProps>;
|
|
17
|
-
List: React.FC<PropsWithClass>;
|
|
18
|
-
Item: React.FC<TabItemProps>;
|
|
19
|
-
Panel: React.FC<TabPanelProps>;
|
|
11
|
+
declare type TabComponent = React.ForwardRefExoticComponent<TabProps> & {
|
|
12
|
+
Panel: React.ForwardRefExoticComponent<TabPanelProps>;
|
|
13
|
+
Item: React.ForwardRefExoticComponent<Polymorphic.OwnProps<typeof TabItem>>;
|
|
14
|
+
List: React.ForwardRefExoticComponent<TabListProps>;
|
|
20
15
|
};
|
|
16
|
+
export declare const Tab: TabComponent;
|
|
17
|
+
export {};
|
package/tab/tab.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { useRovingTabIndex, useFocusEffect, RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
1
|
+
import React, { useEffect, useState, forwardRef, Children, cloneElement } from 'react';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
3
|
import { useUIDSeed } from 'react-uid';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
4
|
+
import { TabItem } from './tab-item';
|
|
5
|
+
import { TabList } from './tab-list';
|
|
6
|
+
import { TabPanel } from './tab-panel';
|
|
7
|
+
import { Tabs as TabsWrapper } from './primitive-tab';
|
|
8
|
+
import { Tab as TabClass } from './tab.module.css';
|
|
9
|
+
export const Tab = forwardRef(({ children, className, state, onChange, ...props }, forwardedRef) => {
|
|
9
10
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
10
11
|
const innerState = useState(0);
|
|
11
12
|
const tabState = state || innerState;
|
|
@@ -18,40 +19,12 @@ const TabRoot = forwardRef(({ children, className, state, onChange, ...props },
|
|
|
18
19
|
}, [currentTab, onChange]);
|
|
19
20
|
return (React.createElement("div", { ref: forwardedRef, className: clsx(TabClass, className), ...props },
|
|
20
21
|
React.createElement(TabsWrapper, { state: tabState },
|
|
21
|
-
React.createElement(TabList, null, Children.map(renderedChildren, (child, index) => (React.createElement(
|
|
22
|
+
React.createElement(TabList, null, Children.map(renderedChildren, (child, index) => (React.createElement(TabItem, { id: seedID(`tab-item-${index}`), "aria-controls": seedID(`tab-panel-${index}`), icon: child.props.icon }, child.props.label)))),
|
|
22
23
|
Children.map(renderedChildren, (child, index) => cloneElement(child, {
|
|
23
24
|
id: seedID(`tab-panel-${index}`),
|
|
24
25
|
'aria-labelledby': seedID(`tab-item-${index}`)
|
|
25
26
|
})))));
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const isActive = usePanelState(children);
|
|
31
|
-
return isActive
|
|
32
|
-
? (React.createElement("div", { ref: forwardedRef, tabIndex: 0, className: clsx(TabPanelClass, className), ...props }, children))
|
|
33
|
-
: null;
|
|
34
|
-
});
|
|
35
|
-
const TabItem = ({ children, className, icon, ...props }) => {
|
|
36
|
-
const { onClick, isActive } = useTabState(children);
|
|
37
|
-
const internalRef = useRef(null);
|
|
38
|
-
const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
|
|
39
|
-
useFocusEffect(focused, internalRef);
|
|
40
|
-
const fireClick = useCallback(() => {
|
|
41
|
-
onClick();
|
|
42
|
-
handleClick();
|
|
43
|
-
}, [handleClick, onClick]);
|
|
44
|
-
return (React.createElement(Stack, { as: "button", direction: "row", verticalAlign: "center", horizontalAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(TabItemClass, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, ...props },
|
|
45
|
-
icon && React.createElement(Icon, { name: icon, dimension: 16 }),
|
|
46
|
-
children));
|
|
47
|
-
};
|
|
48
|
-
export const Tab = {
|
|
49
|
-
Root: TabRoot,
|
|
50
|
-
List: TabList,
|
|
51
|
-
Item: TabItem,
|
|
52
|
-
Panel: TabPanel
|
|
53
|
-
};
|
|
54
|
-
Tab.Root.displayName = 'Tab.Root';
|
|
55
|
-
Tab.List.displayName = 'Tab.List';
|
|
56
|
-
Tab.Panel.displayName = 'Tab.Panel';
|
|
57
|
-
Tab.Item.displayName = 'Tab.Item';
|
|
28
|
+
Tab.Panel = TabPanel;
|
|
29
|
+
Tab.Item = TabItem;
|
|
30
|
+
Tab.List = TabList;
|
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/themes.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
color: var(--global-foreground);
|
|
5
5
|
/**
|
|
6
6
|
* Do not edit directly
|
|
7
|
-
* Generated on
|
|
7
|
+
* Generated on Mon, 29 Nov 2021 14:49:13 GMT
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
color: var(--global-foreground);
|
|
52
52
|
/**
|
|
53
53
|
* Do not edit directly
|
|
54
|
-
* Generated on
|
|
54
|
+
* Generated on Mon, 29 Nov 2021 14:49:13 GMT
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
color: var(--global-foreground);
|
|
100
100
|
/**
|
|
101
101
|
* Do not edit directly
|
|
102
|
-
* Generated on
|
|
102
|
+
* Generated on Mon, 29 Nov 2021 14:49:13 GMT
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
105
|
|
|
@@ -21,7 +21,7 @@ const scaleAnimation = {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
export const ToggleButton = forwardRef(({ className, restingIcon, pressedIcon, dimension, kind, disabled, pressed = false, onClick, ...props }, forwardedRef) => {
|
|
24
|
+
export const ToggleButton = forwardRef(({ className, restingIcon, pressedIcon, dimension, kind, disabled, iconColor, pressed = false, onClick, ...props }, forwardedRef) => {
|
|
25
25
|
const [isPressed, setIsPressed] = useState(pressed);
|
|
26
26
|
const [firstRender, setFirstRender] = useState(true);
|
|
27
27
|
useEffect(() => {
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
&[aria-pressed='true'] {
|
|
8
8
|
box-shadow:
|
|
9
9
|
0 0 0 var(--border-width) var(--border-color),
|
|
10
|
-
0 0 0 var(--border-width) var(--border-color)
|
|
11
|
-
inset 0 0 0 calc(var(--border-width) / 2) hsl(0deg 0% 0% / 20%);
|
|
10
|
+
0 0 0 var(--border-width) var(--border-color);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
&[data-button-kind='primary'] {
|