@wonderflow/react-components 2.34.0-next.5 → 2.34.0-next.9
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.d.ts +4 -1
- package/button/button.js +8 -4
- package/button/button.module.css +38 -1
- package/button/index.d.ts +2 -2
- package/button/index.js +1 -1
- package/core/typography.css +1 -1
- package/dropdown/dropdown-item.d.ts +2 -1
- package/dropdown/dropdown-item.js +3 -3
- package/dropdown/dropdown-item.module.css +2 -2
- package/dropdown/dropdown.d.ts +2 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/menu-button/index.d.ts +2 -0
- package/menu-button/index.js +1 -0
- package/menu-button/menu-button.d.ts +8 -0
- package/menu-button/menu-button.js +13 -0
- package/menu-button/menu-button.module.css +28 -0
- package/package.json +1 -1
- package/range/range.module.css +0 -5
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/themes.css +3 -3
package/button/button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MouseEvent } from 'react';
|
|
1
|
+
import React, { MouseEvent } from 'react';
|
|
2
2
|
import { IconNames } from '../icons/types';
|
|
3
3
|
import { Polymorphic } from '../';
|
|
4
4
|
export declare type ButtonProps = PropsWithClass & {
|
|
@@ -10,8 +10,11 @@ export declare type ButtonProps = PropsWithClass & {
|
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
type?: 'submit' | 'reset' | 'button';
|
|
12
12
|
loading?: boolean;
|
|
13
|
+
pressed?: boolean;
|
|
13
14
|
onClick?(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>): void;
|
|
14
15
|
};
|
|
15
16
|
declare type PolymorphicButton = Polymorphic.ForwardRefComponent<'button', ButtonProps>;
|
|
16
17
|
export declare const Button: PolymorphicButton;
|
|
18
|
+
export declare type ButtonsGroupProps = PropsWithClass & Pick<ButtonProps, 'dimension'>;
|
|
19
|
+
export declare const ButtonsGroup: React.FC<ButtonsGroupProps>;
|
|
17
20
|
export {};
|
package/button/button.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React, { forwardRef, useCallback } from 'react';
|
|
2
|
+
import React, { Children, cloneElement, forwardRef, useCallback } from 'react';
|
|
3
3
|
import { Icon, Spinner } from '../';
|
|
4
|
-
import { Button as ButtonClass, SpinnerIndicator } from './button.module.css';
|
|
5
|
-
export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', type = 'button', onClick, loading, as: Wrapper = 'button', ...props }, forwardedRef) => {
|
|
4
|
+
import { Button as ButtonClass, SpinnerIndicator, ButtonsGroup as ButtonsGroupClass } from './button.module.css';
|
|
5
|
+
export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', type = 'button', pressed = false, onClick, loading, as: Wrapper = 'button', ...props }, forwardedRef) => {
|
|
6
6
|
const handleClick = useCallback(() => (event) => {
|
|
7
7
|
if (!disabled && onClick)
|
|
8
8
|
onClick(event);
|
|
@@ -14,10 +14,14 @@ export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', cla
|
|
|
14
14
|
regular: 16,
|
|
15
15
|
small: 16
|
|
16
16
|
};
|
|
17
|
-
return (React.createElement(Wrapper, { ref: forwardedRef, type: Wrapper === 'button' ? type : undefined, className: clsx(ButtonClass, className), "data-button-icon-position": iconPosition, "data-button-dimension": dimension, "data-button-kind": kind, "data-button-fullwidth": fullWidth, "data-button-disabled": disabled, "data-button-is-loading": loading, "aria-disabled": disabled, "aria-busy": loading, "aria-live": loading ? 'polite' : undefined, onClick: handleClick(), ...props },
|
|
17
|
+
return (React.createElement(Wrapper, { ref: forwardedRef, type: Wrapper === 'button' ? type : undefined, className: clsx(ButtonClass, className), "data-button-icon-position": iconPosition, "data-button-dimension": dimension, "data-button-kind": kind, "data-button-fullwidth": fullWidth, "data-button-disabled": disabled, "data-button-is-loading": loading, "aria-disabled": disabled, "aria-busy": loading, "aria-pressed": pressed, "aria-live": loading ? 'polite' : undefined, onClick: handleClick(), ...props },
|
|
18
18
|
icon && (React.createElement(Icon, { name: icon, dimension: iconSize[dimension] })),
|
|
19
19
|
children && React.createElement("span", null, children),
|
|
20
20
|
loading && (React.createElement("span", { className: SpinnerIndicator },
|
|
21
21
|
React.createElement(Spinner, { dimension: dimension })))));
|
|
22
22
|
});
|
|
23
|
+
export const ButtonsGroup = ({ children, className, dimension = 'regular' }) => (React.createElement("div", { className: clsx(ButtonsGroupClass, className) }, Children.map(children, (child) => cloneElement(child, {
|
|
24
|
+
kind: 'secondary',
|
|
25
|
+
dimension: dimension
|
|
26
|
+
}))));
|
|
23
27
|
Button.displayName = 'Button';
|
package/button/button.module.css
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
border: 0;
|
|
15
15
|
appearance: none;
|
|
16
16
|
font-weight: 600;
|
|
17
|
-
line-height: 1;
|
|
18
17
|
position: relative;
|
|
19
18
|
overflow: hidden;
|
|
20
19
|
border-radius: env(--radius-4);
|
|
@@ -51,6 +50,12 @@
|
|
|
51
50
|
&:is(:active) {
|
|
52
51
|
background-color: var(--cta-dark);
|
|
53
52
|
}
|
|
53
|
+
|
|
54
|
+
&[aria-pressed='true'],
|
|
55
|
+
&[aria-pressed='true']:active {
|
|
56
|
+
background-color: hsl(env(--color-red-50));
|
|
57
|
+
color: hsl(env(--color-support-white));
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
&[data-button-kind='secondary'] {
|
|
@@ -61,6 +66,12 @@
|
|
|
61
66
|
&:is(:active) {
|
|
62
67
|
background-color: var(--global-vibrancy-background-hover);
|
|
63
68
|
}
|
|
69
|
+
|
|
70
|
+
&[aria-pressed='true'],
|
|
71
|
+
&[aria-pressed='true']:active {
|
|
72
|
+
background-color: var(--dimmed-7);
|
|
73
|
+
color: var(--dimmed-0);
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
&[data-button-kind='flat'] {
|
|
@@ -75,6 +86,11 @@
|
|
|
75
86
|
backdrop-filter: blur(32px);
|
|
76
87
|
background-color: var(--global-vibrancy-background);
|
|
77
88
|
}
|
|
89
|
+
|
|
90
|
+
&[aria-pressed='true'],
|
|
91
|
+
&[aria-pressed='true']:active {
|
|
92
|
+
background-color: var(--global-vibrancy-background-hover);
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
/* Styles */
|
|
@@ -106,3 +122,24 @@
|
|
|
106
122
|
display: grid;
|
|
107
123
|
place-content: center;
|
|
108
124
|
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
.ButtonsGroup {
|
|
128
|
+
display: inline-flex;
|
|
129
|
+
|
|
130
|
+
& > *:not(:first-child, :last-child) {
|
|
131
|
+
border-radius: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
& > *:first-child {
|
|
135
|
+
border-top-right-radius: 0;
|
|
136
|
+
border-bottom-right-radius: 0;
|
|
137
|
+
box-shadow: inset -1px 0 0 hsl(0deg 0% 40% / 10%);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
& > *:last-child {
|
|
141
|
+
border-top-left-radius: 0;
|
|
142
|
+
border-bottom-left-radius: 0;
|
|
143
|
+
box-shadow: inset 1px 0 0 hsl(0deg 0% 40% / 10%);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/button/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Button } from './button';
|
|
2
|
-
export type { ButtonProps } from './button';
|
|
1
|
+
export { Button, ButtonsGroup } from './button';
|
|
2
|
+
export type { ButtonProps, ButtonsGroupProps } from './button';
|
package/button/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Button } from './button';
|
|
1
|
+
export { Button, ButtonsGroup } from './button';
|
package/core/typography.css
CHANGED
|
@@ -6,9 +6,10 @@ export declare type DropdownItemProps = PropsWithClass & {
|
|
|
6
6
|
icon?: IconNames;
|
|
7
7
|
dimension?: 'small' | 'regular';
|
|
8
8
|
onClick?(): void;
|
|
9
|
-
iconPosition
|
|
9
|
+
iconPosition?: 'left' | 'right';
|
|
10
10
|
description?: ReactNode;
|
|
11
11
|
disabled?: boolean;
|
|
12
|
+
padding?: boolean;
|
|
12
13
|
};
|
|
13
14
|
declare type PolymorphicDropdownItem = Polymorphic.ForwardRefComponent<'button', DropdownItemProps>;
|
|
14
15
|
export declare const DropdownItem: PolymorphicDropdownItem;
|
|
@@ -3,7 +3,7 @@ import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
|
3
3
|
import { DropdownItem as DropdownItemClass, Icon as IconClass } from './dropdown-item.module.css';
|
|
4
4
|
import { Tooltip, Stack, Icon } from '../';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
export const DropdownItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, disabled = false, ...props }, forwardedRef) => {
|
|
6
|
+
export const DropdownItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, ...props }, forwardedRef) => {
|
|
7
7
|
const itemRef = useRef(forwardedRef);
|
|
8
8
|
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
|
|
9
9
|
const isIconRight = iconPosition === 'right';
|
|
@@ -14,9 +14,9 @@ export const DropdownItem = forwardRef(({ className, children, onClick, icon, di
|
|
|
14
14
|
onClick();
|
|
15
15
|
}
|
|
16
16
|
}, [handleClick, onClick]);
|
|
17
|
-
const InnerContent = useMemo(() => (React.createElement(Stack, { direction: "row", as: "span", fill: false, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-dropdown-icon-right": isIconRight, "data-dropdown-has-icon": Boolean(icon), style: { inlineSize: '100%' } },
|
|
17
|
+
const InnerContent = useMemo(() => (React.createElement(Stack, { direction: "row", as: "span", fill: false, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-dropdown-icon-right": isIconRight, "data-dropdown-has-icon": Boolean(icon), "data-dropdown-padding": padding, style: { inlineSize: '100%' } },
|
|
18
18
|
icon && (React.createElement(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 })),
|
|
19
|
-
children)), [children, dimension, icon, isIconRight]);
|
|
19
|
+
children)), [children, dimension, icon, isIconRight, padding]);
|
|
20
20
|
return (React.createElement(Wrapper, { ref: itemRef, role: "menuitem", className: clsx(DropdownItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-dropdown-item-dimension": dimension, ...props }, description
|
|
21
21
|
? (React.createElement(Tooltip, { fill: true, show: focused, placement: "right-start", trigger: InnerContent }, description))
|
|
22
22
|
: InnerContent));
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
cursor: not-allowed;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
&
|
|
51
|
+
& [data-dropdown-padding='true'][data-dropdown-has-icon='false'][data-dropdown-icon-right='false'] {
|
|
52
52
|
padding-left: env(--space-40);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
&
|
|
55
|
+
& [data-dropdown-padding='true'][data-dropdown-has-icon='false'][data-dropdown-icon-right='true'] {
|
|
56
56
|
padding-right: env(--space-40);
|
|
57
57
|
}
|
|
58
58
|
}
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -17,9 +17,10 @@ export declare const Dropdown: {
|
|
|
17
17
|
icon?: import("../icons/types").IconNames | undefined;
|
|
18
18
|
dimension?: "small" | "regular" | undefined;
|
|
19
19
|
onClick?(): void;
|
|
20
|
-
iconPosition
|
|
20
|
+
iconPosition?: "left" | "right" | undefined;
|
|
21
21
|
description?: React.ReactNode;
|
|
22
22
|
disabled?: boolean | undefined;
|
|
23
|
+
padding?: boolean | undefined;
|
|
23
24
|
} & {
|
|
24
25
|
checked?: boolean | undefined;
|
|
25
26
|
}>;
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { UIDReset as IdProvider } from 'react-uid';
|
|
|
2
2
|
export { AnimatePresence as Presence } from 'framer-motion';
|
|
3
3
|
export * as Polymorphic from './polymorphic';
|
|
4
4
|
export { Avatar, AvatarProps } from './avatar';
|
|
5
|
-
export { Button, ButtonProps } from './button';
|
|
5
|
+
export { Button, ButtonsGroup, ButtonProps, ButtonsGroupProps } from './button';
|
|
6
6
|
export { Card, CardProps } from './card';
|
|
7
7
|
export { Checkbox, CheckboxProps, Radio, RadioProps, Toggle, ToggleProps } from './selection-controls';
|
|
8
8
|
export { Chip, ChipProps } from './chip';
|
|
@@ -16,6 +16,7 @@ export { Icon, IconProps } from './icon';
|
|
|
16
16
|
export { IconButton, IconButtonProps } from './icon-button';
|
|
17
17
|
export { InfoState, InfoStateProps } from './info-state';
|
|
18
18
|
export { List, ListProps } from './list';
|
|
19
|
+
export { MenuButton, MenuButtonProps } from './menu-button';
|
|
19
20
|
export { Modal, ModalProps, useModalContext } from './modal';
|
|
20
21
|
export { LinearProgress, LinearProgressProps } from './linear-progress';
|
|
21
22
|
export { Prose, ProseProps } from './prose';
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { UIDReset as IdProvider } from 'react-uid';
|
|
|
2
2
|
export { AnimatePresence as Presence } from 'framer-motion';
|
|
3
3
|
export * as Polymorphic from './polymorphic';
|
|
4
4
|
export { Avatar } from './avatar';
|
|
5
|
-
export { Button } from './button';
|
|
5
|
+
export { Button, ButtonsGroup } from './button';
|
|
6
6
|
export { Card } from './card';
|
|
7
7
|
export { Checkbox, Radio, Toggle } from './selection-controls';
|
|
8
8
|
export { Chip } from './chip';
|
|
@@ -16,6 +16,7 @@ export { Icon } from './icon';
|
|
|
16
16
|
export { IconButton } from './icon-button';
|
|
17
17
|
export { InfoState } from './info-state';
|
|
18
18
|
export { List } from './list';
|
|
19
|
+
export { MenuButton } from './menu-button';
|
|
19
20
|
export { Modal, useModalContext } from './modal';
|
|
20
21
|
export { LinearProgress } from './linear-progress';
|
|
21
22
|
export { Prose } from './prose';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuButton } from './menu-button';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Except } from 'type-fest';
|
|
3
|
+
import { ButtonProps, DropdownProps } from '../';
|
|
4
|
+
export declare type MenuButtonProps = Except<ButtonProps, 'iconPosition' | 'pressed'> & Pick<DropdownProps, 'placement'> & {
|
|
5
|
+
label: string;
|
|
6
|
+
dropdownOffset?: DropdownProps['offset'];
|
|
7
|
+
};
|
|
8
|
+
export declare const MenuButton: React.FC<MenuButtonProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button, Dropdown, Stack } from '../';
|
|
4
|
+
import { MenuButton as MenuButtonClass } from './menu-button.module.css';
|
|
5
|
+
export const MenuButton = ({ className, label, icon = 'chevron-down', kind, dimension, fullWidth, disabled, loading, children, placement, dropdownOffset }) => {
|
|
6
|
+
const commonProps = {
|
|
7
|
+
kind,
|
|
8
|
+
dimension
|
|
9
|
+
};
|
|
10
|
+
return (React.createElement(Stack, { className: clsx(MenuButtonClass, className), direction: "row", columnGap: 0, inline: !fullWidth },
|
|
11
|
+
React.createElement(Button, { loading: loading, disabled: disabled, fullWidth: fullWidth, ...commonProps }, label),
|
|
12
|
+
React.createElement(Dropdown, { placement: placement, offset: dropdownOffset, trigger: React.createElement(Button, { icon: icon, ...commonProps }) }, children)));
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.MenuButton {
|
|
2
|
+
& > :nth-child(1) {
|
|
3
|
+
border-top-right-radius: 0;
|
|
4
|
+
border-bottom-right-radius: 0;
|
|
5
|
+
|
|
6
|
+
&[data-button-dimension='big'] {
|
|
7
|
+
padding-left: env(--space-16);
|
|
8
|
+
padding-right: env(--space-16);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& > * > button {
|
|
13
|
+
--separator-color: hsl(0deg 0% 40% / 40%);
|
|
14
|
+
|
|
15
|
+
border-top-left-radius: 0;
|
|
16
|
+
border-bottom-left-radius: 0;
|
|
17
|
+
box-shadow: inset 1px 0 0 0 var(--separator-color);
|
|
18
|
+
|
|
19
|
+
&[data-button-kind='primary'] {
|
|
20
|
+
--separator-color: hsl(0deg 0% 100% / 40%);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:is([data-button-dimension='big'], [data-button-dimension='regular']) {
|
|
24
|
+
padding-left: env(--space-8);
|
|
25
|
+
padding-right: env(--space-8);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
package/range/range.module.css
CHANGED
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 Thu, 04 Nov 2021 13:21: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 Thu, 04 Nov 2021 13:21: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 Thu, 04 Nov 2021 13:21:13 GMT
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
105
|
|