@box/blueprint-web 7.22.0 → 7.24.0
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/lib-esm/badge/icon-badge.d.ts +2 -2
- package/lib-esm/badge/icon-badge.js +7 -2
- package/lib-esm/icon-toggle-button/icon-toggle-button.d.ts +4 -0
- package/lib-esm/icon-toggle-button/icon-toggle-button.js +34 -0
- package/lib-esm/icon-toggle-button/icon-toggle-button.module.js +4 -0
- package/lib-esm/icon-toggle-button/index.d.ts +2 -0
- package/lib-esm/icon-toggle-button/types.d.ts +28 -0
- package/lib-esm/index.css +69 -0
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/primitives/icon-button/icon-button.d.ts +1 -1
- package/lib-esm/primitives/icon-button/icon-button.js +2 -4
- package/lib-esm/text-toggle-button/text-toggle-button.js +3 -24
- package/lib-esm/text-toggle-button/types.d.ts +2 -16
- package/lib-esm/util-components/base-toggle-button/base-toggle-button.d.ts +3 -0
- package/lib-esm/util-components/base-toggle-button/base-toggle-button.js +36 -0
- package/lib-esm/util-components/base-toggle-button/types.d.ts +17 -0
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BadgeProps } from './types';
|
|
2
2
|
export interface IconBadgeProps extends BadgeProps {
|
|
3
3
|
/** The variant of the icon badge. */
|
|
4
|
-
variant: 'file-pdf' | 'file-docs' | 'file-sheets' | 'file-image' | 'file-canvas' | 'file-pages' | 'file-keynote' | 'file-boxnote' | 'file-video' | 'folder-external' | 'folder-shared' | 'action-relay' | 'action-mention' | 'action-task' | 'action-taskapproval' | 'action-annotation' | 'action-performed-completed' | 'action-performed-rejected' | 'collaborator-external' | 'collaborator-admin' | 'collaborator-coadmin' | 'content-pin' | 'content-collection' | 'content-offline' | 'content-progress';
|
|
4
|
+
variant: 'file-pdf' | 'file-docs' | 'file-sheets' | 'file-image' | 'file-canvas' | 'file-pages' | 'file-keynote' | 'file-boxnote' | 'file-video' | 'folder-external' | 'folder-shared' | 'action-relay' | 'action-mention' | 'action-task' | 'action-taskapproval' | 'action-annotation' | 'action-performed-completed' | 'action-performed-rejected' | 'collaborator-external' | 'collaborator-admin' | 'collaborator-coadmin' | 'content-pin' | 'content-collection' | 'content-offline' | 'content-progress' | 'alert-error';
|
|
5
5
|
}
|
|
6
|
-
export declare const IconBadgeVariants: ("file-pdf" | "file-docs" | "file-sheets" | "file-image" | "file-canvas" | "file-pages" | "file-keynote" | "file-boxnote" | "file-video" | "folder-external" | "folder-shared" | "action-relay" | "action-mention" | "action-task" | "action-taskapproval" | "action-annotation" | "action-performed-completed" | "action-performed-rejected" | "collaborator-external" | "collaborator-admin" | "collaborator-coadmin" | "content-pin" | "content-collection" | "content-offline" | "content-progress")[];
|
|
6
|
+
export declare const IconBadgeVariants: ("file-pdf" | "file-docs" | "file-sheets" | "file-image" | "file-canvas" | "file-pages" | "file-keynote" | "file-boxnote" | "file-video" | "folder-external" | "folder-shared" | "action-relay" | "action-mention" | "action-task" | "action-taskapproval" | "action-annotation" | "action-performed-completed" | "action-performed-rejected" | "collaborator-external" | "collaborator-admin" | "collaborator-coadmin" | "content-pin" | "content-collection" | "content-offline" | "content-progress" | "alert-error")[];
|
|
7
7
|
export declare const IconBadge: (props: IconBadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { FilePdf, FileDocs, FileSheets, FileImage, FileCanvas, FilePages, FileKeynote, FileBoxNote, FileVideo, FolderExternal, FolderShared, Relay, EllipsisBubble, Task, ApprovalTask, Annotation, Checkmark, XMark, GlobeBadge, Star, Pin, Arrow, CheckmarkUnderline, Loader } from '@box/blueprint-web-assets/icons/Fill';
|
|
3
|
-
import { SurfaceBadgePdfSurface, GrayWhite, SurfaceBadgeDocsSurface, SurfaceBadgeSheetsSurface, SurfaceBadgeImageSurface, SurfaceBadgeCanvasSurface, SurfaceBadgePagesSurface, SurfaceBadgeKeynoteSurface, SurfaceBadgeBoxnoteSurface, Gray100, SurfaceBadgeVideoSurface, SurfaceBadgeFolderexternalSurface, SurfaceBadgeFoldersharedSurface, SurfaceBadgeRelaySurface, SurfaceBadgeMentionSurface, SurfaceBadgeTaskSurface, SurfaceBadgeTaskapprovalSurface, SurfaceBadgeAnnotationSurface, SurfaceBadgeCompletedSurface, SurfaceBadgeRejectedSurface, SurfaceBadgeExternalSurface, SurfaceBadgeAdminSurface, SurfaceBadgeCoadminSurface, SurfaceBadgePinSurface, Gray80, SurfaceBadgeCollectionSurface, SurfaceBadgeOfflineSurface, SurfaceBadgeProgressSurface } from '@box/blueprint-web-assets/tokens/tokens';
|
|
2
|
+
import { FilePdf, FileDocs, FileSheets, FileImage, FileCanvas, FilePages, FileKeynote, FileBoxNote, FileVideo, FolderExternal, FolderShared, Relay, EllipsisBubble, Task, ApprovalTask, Annotation, Checkmark, XMark, GlobeBadge, Star, Pin, Arrow, CheckmarkUnderline, Loader, Alert } from '@box/blueprint-web-assets/icons/Fill';
|
|
3
|
+
import { SurfaceBadgePdfSurface, GrayWhite, SurfaceBadgeDocsSurface, SurfaceBadgeSheetsSurface, SurfaceBadgeImageSurface, SurfaceBadgeCanvasSurface, SurfaceBadgePagesSurface, SurfaceBadgeKeynoteSurface, SurfaceBadgeBoxnoteSurface, Gray100, SurfaceBadgeVideoSurface, SurfaceBadgeFolderexternalSurface, SurfaceBadgeFoldersharedSurface, SurfaceBadgeRelaySurface, SurfaceBadgeMentionSurface, SurfaceBadgeTaskSurface, SurfaceBadgeTaskapprovalSurface, SurfaceBadgeAnnotationSurface, SurfaceBadgeCompletedSurface, SurfaceBadgeRejectedSurface, SurfaceBadgeExternalSurface, SurfaceBadgeAdminSurface, SurfaceBadgeCoadminSurface, SurfaceBadgePinSurface, Gray80, SurfaceBadgeCollectionSurface, SurfaceBadgeOfflineSurface, SurfaceBadgeProgressSurface, SurfaceBadgeErrorSurface } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
4
|
import { createElement } from 'react';
|
|
5
5
|
import { BaseBadge } from './base-badge.js';
|
|
6
6
|
import styles from './base-badge.module.js';
|
|
@@ -134,6 +134,11 @@ const badgeVariantToIconProps = {
|
|
|
134
134
|
backgroundColor: SurfaceBadgeProgressSurface,
|
|
135
135
|
icon: Loader,
|
|
136
136
|
iconColor: GrayWhite
|
|
137
|
+
},
|
|
138
|
+
'alert-error': {
|
|
139
|
+
backgroundColor: SurfaceBadgeErrorSurface,
|
|
140
|
+
icon: Alert,
|
|
141
|
+
iconColor: GrayWhite
|
|
137
142
|
}
|
|
138
143
|
};
|
|
139
144
|
const badgeSizeToIconSize = {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type IconToggleButtonProps } from './types';
|
|
3
|
+
export declare const iconSizeMap: Record<NonNullable<IconToggleButtonProps['size']>, string>;
|
|
4
|
+
export declare const IconToggleButton: import("react").ForwardRefExoticComponent<Omit<IconToggleButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Size4, Size5, Size6 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { forwardRef, createElement } from 'react';
|
|
5
|
+
import { BaseToggleButton } from '../util-components/base-toggle-button/base-toggle-button.js';
|
|
6
|
+
import styles from './icon-toggle-button.module.js';
|
|
7
|
+
|
|
8
|
+
const iconSizeMap = {
|
|
9
|
+
'x-small': Size4,
|
|
10
|
+
small: Size5,
|
|
11
|
+
medium: Size6
|
|
12
|
+
};
|
|
13
|
+
const IconToggleButton = /*#__PURE__*/forwardRef(({
|
|
14
|
+
className,
|
|
15
|
+
icon,
|
|
16
|
+
variant = 'default',
|
|
17
|
+
size = 'medium',
|
|
18
|
+
...rest
|
|
19
|
+
}, ref) => {
|
|
20
|
+
return jsx(BaseToggleButton, {
|
|
21
|
+
...rest,
|
|
22
|
+
ref: ref,
|
|
23
|
+
className: clsx(styles.iconToggleButton, styles[variant], styles[size], className),
|
|
24
|
+
children: /*#__PURE__*/createElement(icon, {
|
|
25
|
+
className: styles.icon,
|
|
26
|
+
height: iconSizeMap[size],
|
|
27
|
+
width: iconSizeMap[size],
|
|
28
|
+
role: 'presentation'
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
IconToggleButton.displayName = 'IconToggleButton';
|
|
33
|
+
|
|
34
|
+
export { IconToggleButton, iconSizeMap };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import '../index.css';
|
|
2
|
+
var styles = {"iconToggleButton":"bp_icon_toggle_button_module_iconToggleButton--bf96b","high-contrast":"bp_icon_toggle_button_module_high-contrast--bf96b","icon":"bp_icon_toggle_button_module_icon--bf96b","default":"bp_icon_toggle_button_module_default--bf96b","medium":"bp_icon_toggle_button_module_medium--bf96b","small":"bp_icon_toggle_button_module_small--bf96b","x-small":"bp_icon_toggle_button_module_x-small--bf96b"};
|
|
3
|
+
|
|
4
|
+
export { styles as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FunctionComponent, type PropsWithChildren, type SVGProps } from 'react';
|
|
2
|
+
import { type BaseToggleButtonProps } from '../util-components/base-toggle-button/types';
|
|
3
|
+
export declare const IconToggleButtonSizes: readonly ["x-small", "small", "medium"];
|
|
4
|
+
export declare const IconButtonVariants: readonly ["default", "high-contrast"];
|
|
5
|
+
export type IconToggleButtonSize = (typeof IconToggleButtonSizes)[number];
|
|
6
|
+
export type IconButtonVariant = (typeof IconButtonVariants)[number];
|
|
7
|
+
export interface IconToggleButtonProps extends Omit<BaseToggleButtonProps, 'children'> {
|
|
8
|
+
/**
|
|
9
|
+
* Size of the button.
|
|
10
|
+
*
|
|
11
|
+
* @default 'medium'
|
|
12
|
+
*/
|
|
13
|
+
size?: IconToggleButtonSize;
|
|
14
|
+
/**
|
|
15
|
+
* The variant of the button.
|
|
16
|
+
*
|
|
17
|
+
* @default 'default'
|
|
18
|
+
*/
|
|
19
|
+
variant?: IconButtonVariant;
|
|
20
|
+
/**
|
|
21
|
+
* Accessible label for the button.
|
|
22
|
+
*/
|
|
23
|
+
'aria-label': NonNullable<BaseToggleButtonProps['aria-label']>;
|
|
24
|
+
/**
|
|
25
|
+
* Icon that will be rendered.
|
|
26
|
+
*/
|
|
27
|
+
icon: FunctionComponent<PropsWithChildren<SVGProps<SVGSVGElement>>>;
|
|
28
|
+
}
|
package/lib-esm/index.css
CHANGED
|
@@ -3464,6 +3464,75 @@
|
|
|
3464
3464
|
height:var(--size-8);
|
|
3465
3465
|
width:var(--size-8);
|
|
3466
3466
|
}
|
|
3467
|
+
|
|
3468
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b{
|
|
3469
|
+
align-items:center;
|
|
3470
|
+
background:#0000;
|
|
3471
|
+
border:none;
|
|
3472
|
+
border-radius:var(--radius-2);
|
|
3473
|
+
color:var(--text-text-on-light);
|
|
3474
|
+
cursor:pointer;
|
|
3475
|
+
display:flex;
|
|
3476
|
+
font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
|
|
3477
|
+
font-size:.875rem;
|
|
3478
|
+
font-weight:400;
|
|
3479
|
+
justify-content:center;
|
|
3480
|
+
letter-spacing:.01875rem;
|
|
3481
|
+
line-height:1.25rem;
|
|
3482
|
+
outline:0;
|
|
3483
|
+
padding-inline:0;
|
|
3484
|
+
text-decoration:none;
|
|
3485
|
+
text-transform:none;
|
|
3486
|
+
}
|
|
3487
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b:disabled{
|
|
3488
|
+
opacity:.3;
|
|
3489
|
+
pointer-events:none;
|
|
3490
|
+
}
|
|
3491
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b:hover{
|
|
3492
|
+
background-color:var(--surface-toggle-surface-off-hover);
|
|
3493
|
+
}
|
|
3494
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[data-focus-visible]{
|
|
3495
|
+
outline:var(--border-2) solid var(--outline-focus-on-light);
|
|
3496
|
+
}
|
|
3497
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b:active{
|
|
3498
|
+
background-color:var(--surface-toggle-surface-off-pressed);
|
|
3499
|
+
}
|
|
3500
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b.bp_icon_toggle_button_module_high-contrast--bf96b .bp_icon_toggle_button_module_icon--bf96b *{
|
|
3501
|
+
fill:var(--icon-icon-on-light);
|
|
3502
|
+
}
|
|
3503
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b.bp_icon_toggle_button_module_default--bf96b .bp_icon_toggle_button_module_icon--bf96b *{
|
|
3504
|
+
fill:var(--icon-icon-on-light-secondary);
|
|
3505
|
+
}
|
|
3506
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[aria-pressed=true]{
|
|
3507
|
+
background:var(--surface-toggle-surface-on);
|
|
3508
|
+
border:var(--border-1) solid var(--border-toggle-border-on);
|
|
3509
|
+
color:var(--text-text-on-dark);
|
|
3510
|
+
}
|
|
3511
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[aria-pressed=true] .bp_icon_toggle_button_module_icon--bf96b *{
|
|
3512
|
+
fill:var(--icon-icon-blue);
|
|
3513
|
+
}
|
|
3514
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[aria-pressed=true]:hover{
|
|
3515
|
+
background-color:var(--surface-toggle-surface-on-hover);
|
|
3516
|
+
}
|
|
3517
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[aria-pressed=true][data-focus-visible]{
|
|
3518
|
+
border:var(--border-1) solid #fff;
|
|
3519
|
+
outline:var(--border-2) solid var(--outline-focus-on-light);
|
|
3520
|
+
}
|
|
3521
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b[aria-pressed=true]:active{
|
|
3522
|
+
background-color:var(--surface-toggle-surface-on-pressed);
|
|
3523
|
+
}
|
|
3524
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b.bp_icon_toggle_button_module_medium--bf96b{
|
|
3525
|
+
height:var(--size-10);
|
|
3526
|
+
width:var(--size-10);
|
|
3527
|
+
}
|
|
3528
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b.bp_icon_toggle_button_module_small--bf96b{
|
|
3529
|
+
height:var(--size-8);
|
|
3530
|
+
width:var(--size-8);
|
|
3531
|
+
}
|
|
3532
|
+
.bp_icon_toggle_button_module_iconToggleButton--bf96b.bp_icon_toggle_button_module_x-small--bf96b{
|
|
3533
|
+
height:var(--size-6);
|
|
3534
|
+
width:var(--size-6);
|
|
3535
|
+
}
|
|
3467
3536
|
table.bp_inline_table_module_inlineTable--b023b{
|
|
3468
3537
|
background:var(--gray-white);
|
|
3469
3538
|
border:var(--border-1) solid var(--gray-10);
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './ghost';
|
|
|
19
19
|
export * from './grid-list-item';
|
|
20
20
|
export * from './guided-tooltip';
|
|
21
21
|
export * from './icon-dual-state-button';
|
|
22
|
+
export * from './icon-toggle-button';
|
|
22
23
|
export * from './inline-notice/inline-notice';
|
|
23
24
|
export * from './inline-table/inline-table';
|
|
24
25
|
export * from './input-chip';
|
package/lib-esm/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { GridList } from './grid-list-item/index.js';
|
|
|
23
23
|
export { GuidedTooltip } from './guided-tooltip/guided-tooltip.js';
|
|
24
24
|
export { GuidedTooltipContext } from './guided-tooltip/utils/guided-tooltip-context.js';
|
|
25
25
|
export { IconDualStateButton } from './icon-dual-state-button/icon-dual-state-button.js';
|
|
26
|
+
export { IconToggleButton } from './icon-toggle-button/icon-toggle-button.js';
|
|
26
27
|
export { InlineNotice } from './inline-notice/inline-notice.js';
|
|
27
28
|
export { InlineTable } from './inline-table/inline-table.js';
|
|
28
29
|
export { InputChip } from './input-chip/input-chip.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit<import("./types").IconButtonVariantsProps, "ref"> | Omit<import("./types").IconButtonSmallUtilityVariantProps, "ref">) & import("react").RefAttributes<
|
|
2
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit<import("./types").IconButtonVariantsProps, "ref"> | Omit<import("./types").IconButtonSmallUtilityVariantProps, "ref">) & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Button } from '@ariakit/react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { forwardRef,
|
|
5
|
-
import { useForkRef } from '../../utils/useForkRef.js';
|
|
4
|
+
import { forwardRef, createElement } from 'react';
|
|
6
5
|
import styles from './icon-button.module.js';
|
|
7
6
|
import { iconSizeMap } from './utils.js';
|
|
8
7
|
|
|
@@ -13,10 +12,9 @@ const IconButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
13
12
|
icon,
|
|
14
13
|
...rest
|
|
15
14
|
} = props;
|
|
16
|
-
const ref = useRef(null);
|
|
17
15
|
return jsx(Button, {
|
|
18
16
|
...rest,
|
|
19
|
-
ref:
|
|
17
|
+
ref: forwardedRef,
|
|
20
18
|
className: clsx(styles.iconButton, styles[variant], styles[size], props.className),
|
|
21
19
|
children: /*#__PURE__*/createElement(icon, {
|
|
22
20
|
className: styles.icon,
|
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Button } from '@ariakit/react';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
3
|
import { forwardRef } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import { useControllableState } from '../utils/useControllableState.js';
|
|
4
|
+
import { BaseToggleButton } from '../util-components/base-toggle-button/base-toggle-button.js';
|
|
7
5
|
import styles from './text-toggle-button.module.js';
|
|
8
6
|
|
|
9
7
|
const TextToggleButton = /*#__PURE__*/forwardRef(({
|
|
10
|
-
pressed: pressedProp,
|
|
11
|
-
defaultPressed = false,
|
|
12
|
-
onPressedChange,
|
|
13
|
-
disabled,
|
|
14
|
-
onClick,
|
|
15
8
|
className,
|
|
16
9
|
...rest
|
|
17
10
|
}, ref) => {
|
|
18
|
-
|
|
19
|
-
prop: pressedProp,
|
|
20
|
-
onChange: onPressedChange,
|
|
21
|
-
defaultProp: defaultPressed
|
|
22
|
-
});
|
|
23
|
-
return jsx(Button, {
|
|
24
|
-
"aria-pressed": pressed,
|
|
25
|
-
"data-disabled": disabled ? '' : undefined,
|
|
26
|
-
"data-state": pressed ? 'on' : 'off',
|
|
11
|
+
return jsx(BaseToggleButton, {
|
|
27
12
|
...rest,
|
|
28
13
|
ref: ref,
|
|
29
|
-
className: clsx(styles.textToggleButton, className)
|
|
30
|
-
disabled: disabled,
|
|
31
|
-
onClick: composeEventHandlers(onClick, () => {
|
|
32
|
-
if (!disabled) {
|
|
33
|
-
setPressed(!pressed);
|
|
34
|
-
}
|
|
35
|
-
})
|
|
14
|
+
className: clsx(styles.textToggleButton, className)
|
|
36
15
|
});
|
|
37
16
|
});
|
|
38
17
|
TextToggleButton.displayName = 'TextToggleButton';
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export interface TextToggleButtonProps extends
|
|
1
|
+
import { type BaseToggleButtonProps } from '../util-components/base-toggle-button/types';
|
|
2
|
+
export interface TextToggleButtonProps extends BaseToggleButtonProps {
|
|
3
3
|
/**
|
|
4
4
|
* The text content of the button.
|
|
5
5
|
*/
|
|
6
6
|
children: string;
|
|
7
|
-
/**
|
|
8
|
-
* The controlled state of the toggle.
|
|
9
|
-
*/
|
|
10
|
-
pressed?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* The state of the toggle when initially rendered. Use `defaultPressed`
|
|
13
|
-
* if you do not need to control the state of the toggle.
|
|
14
|
-
* @defaultValue false
|
|
15
|
-
*/
|
|
16
|
-
defaultPressed?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* The callback that fires when the state of the toggle changes.
|
|
19
|
-
*/
|
|
20
|
-
onPressedChange?(pressed: boolean): void;
|
|
21
7
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Button } from '@ariakit/react';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { composeEventHandlers } from '../../utils/composeEventHandlers.js';
|
|
5
|
+
import { useControllableState } from '../../utils/useControllableState.js';
|
|
6
|
+
|
|
7
|
+
const BaseToggleButton = /*#__PURE__*/forwardRef(({
|
|
8
|
+
pressed: pressedProp,
|
|
9
|
+
defaultPressed = false,
|
|
10
|
+
onPressedChange,
|
|
11
|
+
disabled,
|
|
12
|
+
onClick,
|
|
13
|
+
...rest
|
|
14
|
+
}, ref) => {
|
|
15
|
+
const [pressed = false, setPressed] = useControllableState({
|
|
16
|
+
prop: pressedProp,
|
|
17
|
+
onChange: onPressedChange,
|
|
18
|
+
defaultProp: defaultPressed
|
|
19
|
+
});
|
|
20
|
+
return jsx(Button, {
|
|
21
|
+
...rest,
|
|
22
|
+
ref: ref,
|
|
23
|
+
"aria-pressed": pressed,
|
|
24
|
+
"data-disabled": disabled ? '' : undefined,
|
|
25
|
+
"data-state": pressed ? 'on' : 'off',
|
|
26
|
+
disabled: disabled,
|
|
27
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
28
|
+
if (!disabled) {
|
|
29
|
+
setPressed(!pressed);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
BaseToggleButton.displayName = 'BaseToggleButton';
|
|
35
|
+
|
|
36
|
+
export { BaseToggleButton };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ButtonProps as AriakitButtonProps } from '@ariakit/react';
|
|
2
|
+
export interface BaseToggleButtonProps extends AriakitButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* The controlled state of the toggle.
|
|
5
|
+
*/
|
|
6
|
+
pressed?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The state of the toggle when initially rendered. Use `defaultPressed`
|
|
9
|
+
* if you do not need to control the state of the toggle.
|
|
10
|
+
* @defaultValue false
|
|
11
|
+
*/
|
|
12
|
+
defaultPressed?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The callback that fires when the state of the toggle changes.
|
|
15
|
+
*/
|
|
16
|
+
onPressedChange?(pressed: boolean): void;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ariakit/react": "0.4.5",
|
|
26
26
|
"@ariakit/react-core": "0.4.5",
|
|
27
|
-
"@box/blueprint-web-assets": "^4.21.
|
|
27
|
+
"@box/blueprint-web-assets": "^4.21.4",
|
|
28
28
|
"@internationalized/date": "^3.5.4",
|
|
29
29
|
"@radix-ui/react-accordion": "1.1.2",
|
|
30
30
|
"@radix-ui/react-checkbox": "1.0.4",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"type-fest": "^3.2.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@box/storybook-utils": "^0.
|
|
58
|
+
"@box/storybook-utils": "^0.6.0",
|
|
59
59
|
"@types/react": "^18.0.0",
|
|
60
60
|
"@types/react-dom": "^18.0.0",
|
|
61
61
|
"react": "^18.3.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"react-stately": "^3.31.1",
|
|
64
64
|
"tsx": "^4.16.5"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c45d13964d3b60b860c3606a0eb55fb86bc2e057",
|
|
67
67
|
"module": "lib-esm/index.js",
|
|
68
68
|
"main": "lib-esm/index.js",
|
|
69
69
|
"exports": {
|