@box/blueprint-web 6.9.3 → 6.11.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.
Files changed (33) hide show
  1. package/lib-esm/index.css +117 -50
  2. package/lib-esm/index.d.ts +1 -0
  3. package/lib-esm/index.js +1 -0
  4. package/lib-esm/search-input/index.d.ts +2 -15
  5. package/lib-esm/search-input/index.js +3 -1
  6. package/lib-esm/search-input/search-input-controlled/index.d.ts +2 -0
  7. package/lib-esm/search-input/search-input-controlled/search-input-controlled.d.ts +3 -0
  8. package/lib-esm/search-input/search-input-controlled/search-input-controlled.js +79 -0
  9. package/lib-esm/search-input/search-input-controlled/types.d.ts +17 -0
  10. package/lib-esm/search-input/search-input.d.ts +4 -15
  11. package/lib-esm/search-input/search-input.js +4 -1
  12. package/lib-esm/search-input/types.d.ts +2 -3
  13. package/lib-esm/toolbar/index.d.ts +56 -0
  14. package/lib-esm/toolbar/index.js +65 -0
  15. package/lib-esm/toolbar/toolbar-button.d.ts +3 -0
  16. package/lib-esm/toolbar/toolbar-button.js +27 -0
  17. package/lib-esm/toolbar/toolbar-dropdown-indicator.d.ts +3 -0
  18. package/lib-esm/toolbar/toolbar-dropdown-indicator.js +25 -0
  19. package/lib-esm/toolbar/toolbar-icon.d.ts +3 -0
  20. package/lib-esm/toolbar/toolbar-icon.js +20 -0
  21. package/lib-esm/toolbar/toolbar-root.d.ts +3 -0
  22. package/lib-esm/toolbar/toolbar-root.js +21 -0
  23. package/lib-esm/toolbar/toolbar-separator.d.ts +3 -0
  24. package/lib-esm/toolbar/toolbar-separator.js +20 -0
  25. package/lib-esm/toolbar/toolbar-toggle-group.d.ts +3 -0
  26. package/lib-esm/toolbar/toolbar-toggle-group.js +21 -0
  27. package/lib-esm/toolbar/toolbar-toggle-item.d.ts +3 -0
  28. package/lib-esm/toolbar/toolbar-toggle-item.js +28 -0
  29. package/lib-esm/toolbar/toolbar-trigger-button.d.ts +3 -0
  30. package/lib-esm/toolbar/toolbar-trigger-button.js +29 -0
  31. package/lib-esm/toolbar/toolbar.module.js +4 -0
  32. package/lib-esm/toolbar/types.d.ts +39 -0
  33. package/package.json +3 -2
package/lib-esm/index.css CHANGED
@@ -4859,6 +4859,69 @@ table.inline_table_module_inlineTable--b023b tr:not(:last-child) td{
4859
4859
  .switch_module_option--f1dbf.switch_module_disabled--f1dbf .switch_module_switch--f1dbf{
4860
4860
  opacity:60%;
4861
4861
  }
4862
+
4863
+ .text_button_module_textButton--581e7{
4864
+ align-items:center;
4865
+ background:#0000;
4866
+ border:none;
4867
+ border-radius:calc(var(--radius-1)/2);
4868
+ color:var(--text-cta-link);
4869
+ cursor:pointer;
4870
+ display:inline-flex;
4871
+ font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
4872
+ font-size:.875rem;
4873
+ font-weight:700;
4874
+ letter-spacing:.01875rem;
4875
+ line-height:1.25rem;
4876
+ outline:0;
4877
+ padding:0;
4878
+ text-decoration:none;
4879
+ text-transform:none;
4880
+ -webkit-user-select:text;
4881
+ user-select:text;
4882
+ }
4883
+ .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7{
4884
+ border-radius:.125em;
4885
+ font:inherit;
4886
+ }
4887
+ .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7.text_button_module_isIconButton--581e7{
4888
+ gap:.25em;
4889
+ }
4890
+ .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7:not(:disabled)[data-focus-visible]{
4891
+ box-shadow:0 0 0 .125em var(--outline-focus-on-light);
4892
+ }
4893
+ .text_button_module_textButton--581e7 .text_button_module_scaleLoader--581e7 div{
4894
+ border-radius:.375em;
4895
+ height:.625em;
4896
+ width:.125em;
4897
+ }
4898
+ .text_button_module_textButton--581e7 .text_button_module_icon--581e7{
4899
+ align-items:center;
4900
+ display:flex;
4901
+ }
4902
+ .text_button_module_textButton--581e7 .text_button_module_hideTextContent--581e7{
4903
+ visibility:hidden;
4904
+ }
4905
+ .text_button_module_textButton--581e7.text_button_module_isIconButton--581e7{
4906
+ gap:var(--space-1);
4907
+ }
4908
+ .text_button_module_textButton--581e7.text_button_module_visuallyHidden--581e7{
4909
+ color:#0000;
4910
+ pointer-events:none;
4911
+ position:relative;
4912
+ }
4913
+ .text_button_module_textButton--581e7:disabled{
4914
+ opacity:.3;
4915
+ }
4916
+ .text_button_module_textButton--581e7:not(:disabled):hover,.text_button_module_textButton--581e7:not(:disabled)[data-focus-visible]{
4917
+ color:var(--text-cta-link-hover);
4918
+ }
4919
+ .text_button_module_textButton--581e7:not(:disabled)[data-focus-visible]{
4920
+ box-shadow:0 0 0 var(--border-2) var(--outline-focus-on-light);
4921
+ }
4922
+ .text_button_module_textButton--581e7:not(:disabled):active{
4923
+ color:var(--text-cta-link-pressed);
4924
+ }
4862
4925
  :root{
4863
4926
  --notification-default-paragraph-indent:0rem;
4864
4927
  --notification-default-paragraph-spacing:0;
@@ -5542,65 +5605,69 @@ table.inline_table_module_inlineTable--b023b tr:not(:last-child) td{
5542
5605
  --z-index-card-tooltip:2147483647;
5543
5606
  }
5544
5607
 
5545
- .text_button_module_textButton--581e7{
5546
- align-items:center;
5547
- background:#0000;
5548
- border:none;
5549
- border-radius:calc(var(--radius-1)/2);
5550
- color:var(--text-cta-link);
5551
- cursor:pointer;
5552
- display:inline-flex;
5553
- font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
5554
- font-size:.875rem;
5555
- font-weight:700;
5556
- letter-spacing:.01875rem;
5557
- line-height:1.25rem;
5558
- outline:0;
5559
- padding:0;
5560
- text-decoration:none;
5561
- text-transform:none;
5562
- -webkit-user-select:text;
5563
- user-select:text;
5564
- }
5565
- .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7{
5566
- border-radius:.125em;
5567
- font:inherit;
5568
- }
5569
- .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7.text_button_module_isIconButton--581e7{
5570
- gap:.25em;
5608
+ .toolbar_module_root--afeab{
5609
+ background:var(--surface-surface);
5610
+ border:var(--border-1) solid var(--border-card-border);
5611
+ border-radius:var(--radius-4);
5612
+ box-shadow:var(--dropshadow-3);
5613
+ display:flex;
5614
+ gap:var(--space-1);
5615
+ padding:var(--space-1);
5571
5616
  }
5572
- .text_button_module_textButton--581e7.text_button_module_isFontInherited--581e7:not(:disabled)[data-focus-visible]{
5573
- box-shadow:0 0 0 .125em var(--outline-focus-on-light);
5617
+
5618
+ .toolbar_module_separator--afeab{
5619
+ background-color:var(--border-divider-border);
5620
+ border-radius:var(--radius-2);
5621
+ width:1px;
5574
5622
  }
5575
- .text_button_module_textButton--581e7 .text_button_module_scaleLoader--581e7 div{
5576
- border-radius:.375em;
5577
- height:.625em;
5578
- width:.125em;
5623
+
5624
+ .toolbar_module_toggleGroup--afeab,.toolbar_module_toolbarItem--afeab{
5625
+ display:flex;
5626
+ gap:var(--space-1);
5579
5627
  }
5580
- .text_button_module_textButton--581e7 .text_button_module_icon--581e7{
5628
+
5629
+ .toolbar_module_toolbarItem--afeab{
5581
5630
  align-items:center;
5582
- display:flex;
5631
+ background:var(--toolbar-button-color, --surface-toggle-surface);
5632
+ border:var(--border-1) solid #0000;
5633
+ border-radius:var(--radius-2);
5634
+ cursor:pointer;
5635
+ justify-content:center;
5636
+ min-height:var(--size-8);
5637
+ min-width:var(--size-8);
5638
+ outline:none;
5639
+ padding:calc(var(--space-1) - var(--border-1));
5640
+ -webkit-user-select:none;
5641
+ user-select:none;
5583
5642
  }
5584
- .text_button_module_textButton--581e7 .text_button_module_hideTextContent--581e7{
5585
- visibility:hidden;
5643
+ .toolbar_module_toolbarItem--afeab[data-disabled]{
5644
+ background:var(--surface-toggle-surface);
5645
+ opacity:.3;
5646
+ pointer-events:none;
5586
5647
  }
5587
- .text_button_module_textButton--581e7.text_button_module_isIconButton--581e7{
5588
- gap:var(--space-1);
5648
+ .toolbar_module_toolbarItem--afeab:not([data-disabled]):focus{
5649
+ box-shadow:0 0 0 .0625rem #fff,0 0 0 .1875rem #2486fc;
5589
5650
  }
5590
- .text_button_module_textButton--581e7.text_button_module_visuallyHidden--581e7{
5591
- color:#0000;
5592
- pointer-events:none;
5593
- position:relative;
5651
+ .toolbar_module_toolbarItem--afeab:not([data-disabled]):hover{
5652
+ background:var(--toolbar-button-color, --surface-toggle-surface-hover);
5653
+ border:var(--border-1) solid var(--toolbar-button-color, --surface-toggle-surface-hover);
5594
5654
  }
5595
- .text_button_module_textButton--581e7:disabled{
5596
- opacity:.3;
5655
+
5656
+ .toolbar_module_toolbarToggle--afeab[data-state=on]{
5657
+ background:var(--surface-toggle-surface-pressed);
5597
5658
  }
5598
- .text_button_module_textButton--581e7:not(:disabled):hover,.text_button_module_textButton--581e7:not(:disabled)[data-focus-visible]{
5599
- color:var(--text-cta-link-hover);
5659
+ .toolbar_module_toolbarToggle--afeab[data-state=on] svg *{
5660
+ fill:var(--icon-icon-on-dark);
5600
5661
  }
5601
- .text_button_module_textButton--581e7:not(:disabled)[data-focus-visible]{
5602
- box-shadow:0 0 0 var(--border-2) var(--outline-focus-on-light);
5662
+ .toolbar_module_toolbarToggle--afeab[data-state=on]:not([data-disabled]):hover{
5663
+ background:var(--surface-toggle-surface-on-hover);
5664
+ border:var(--border-1) solid var(--surface-toggle-surface-on-hover);
5603
5665
  }
5604
- .text_button_module_textButton--581e7:not(:disabled):active{
5605
- color:var(--text-cta-link-pressed);
5666
+
5667
+ .toolbar_module_invertDropdownIndicator--afeab{
5668
+ transform:rotate(.5turn);
5669
+ }
5670
+
5671
+ .toolbar_module_triggerButtonSelectedWithColor--afeab[data-state=on]:hover{
5672
+ opacity:.7;
5606
5673
  }
@@ -50,6 +50,7 @@ export * from './switch';
50
50
  export * from './text';
51
51
  export * from './text-area';
52
52
  export * from './text-button';
53
+ export * from './toolbar';
53
54
  export * from './tooltip';
54
55
  export * from './trigger-button';
55
56
  export * from './util-components/scrollable-container/scrollable-container';
package/lib-esm/index.js CHANGED
@@ -62,6 +62,7 @@ export { Switch } from './switch/index.js';
62
62
  export { Text } from './text/text.js';
63
63
  export { TextArea } from './text-area/text-area.js';
64
64
  export { TextButton } from './text-button/text-button.js';
65
+ export { Toolbar } from './toolbar/index.js';
65
66
  export { Tooltip, TooltipProvider } from './tooltip/tooltip.js';
66
67
  export { TriggerButton } from './trigger-button/trigger-button.js';
67
68
  export { ScrollContext, ScrollableContainer, useScroll, useScrollContext } from './util-components/scrollable-container/scrollable-container.js';
@@ -1,22 +1,9 @@
1
1
  /// <reference types="react" />
2
- export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
3
- ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
4
- }, "disabled" | "type" | "onChange" | "defaultValue" | "className" | "onSubmit" | "onKeyDown" | "searchIconAriaLabel" | "searchInputAriaLabel" | "searchInputClearAriaLabel" | "variant"> & {
5
- className?: string | undefined;
6
- defaultValue?: string | undefined;
7
- disabled?: boolean | undefined;
8
- onChange?: ((searchInputValue: string) => void) | undefined;
9
- onKeyDown?: ((e: import("react").KeyboardEvent<HTMLInputElement>) => void) | undefined;
10
- onSubmit?: ((searchInputValue: string) => void) | undefined;
11
- searchIconAriaLabel: string;
12
- searchInputAriaLabel: string;
13
- searchInputClearAriaLabel: string;
14
- type?: "search" | undefined;
15
- variant?: "in-context" | "global" | undefined;
16
- }, "ref"> & import("react").RefAttributes<HTMLInputElement>> & {
2
+ export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<import("./types").SearchInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>> & {
17
3
  /**
18
4
  * Styled wrapper over an icon button.
19
5
  */
20
6
  ActionButton: import("react").ForwardRefExoticComponent<Omit<import("../..").IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
7
+ Controlled: import("react").ForwardRefExoticComponent<Omit<import("./search-input-controlled").SearchInputControlledProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
21
8
  };
22
9
  export type { SearchInputActionButtonProps, SearchInputProps } from './types';
@@ -1,11 +1,13 @@
1
1
  import { SearchInput as SearchInput$1 } from './search-input.js';
2
2
  import { SearchInputActionButton } from './search-input-action-button.js';
3
+ import { SearchInputControlled } from './search-input-controlled/search-input-controlled.js';
3
4
 
4
5
  const SearchInput = Object.assign(SearchInput$1, {
5
6
  /**
6
7
  * Styled wrapper over an icon button.
7
8
  */
8
- ActionButton: SearchInputActionButton
9
+ ActionButton: SearchInputActionButton,
10
+ Controlled: SearchInputControlled
9
11
  });
10
12
 
11
13
  export { SearchInput };
@@ -0,0 +1,2 @@
1
+ export * from './search-input-controlled';
2
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type SearchInputControlledProps } from './types';
3
+ export declare const SearchInputControlled: import("react").ForwardRefExoticComponent<Omit<SearchInputControlledProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,79 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Search } from '@box/blueprint-web-assets/icons/Fill';
3
+ import { IconIconOnLightSecondary, IconCtaIcon } from '@box/blueprint-web-assets/tokens/tokens';
4
+ import clsx from 'clsx';
5
+ import { forwardRef, Children } from 'react';
6
+ import { IconButton } from '../../primitives/icon-button/icon-button.js';
7
+ import { switchCase } from '../../utils/switchCase.js';
8
+ import { AccessibleXMarkGlobal, AccessibleXMark } from '../search-input.js';
9
+ import styles from '../search.module.js';
10
+
11
+ const SearchInputControlled = /*#__PURE__*/forwardRef((props, forwardedRef) => {
12
+ const {
13
+ children,
14
+ className,
15
+ disabled = false,
16
+ onChange,
17
+ onClearInput,
18
+ onKeyDown,
19
+ onSubmit,
20
+ placeholder = '',
21
+ searchIconAriaLabel,
22
+ searchInputAriaLabel,
23
+ searchInputClearAriaLabel,
24
+ value,
25
+ variant,
26
+ ...rest
27
+ } = props;
28
+ const onSearchInputKeyDown = e => {
29
+ if (disabled) {
30
+ return;
31
+ }
32
+ switchCase({
33
+ Enter: () => {
34
+ e.preventDefault();
35
+ onSubmit?.(value);
36
+ },
37
+ Escape: () => {
38
+ e.preventDefault();
39
+ onClearInput();
40
+ }
41
+ })(e.key)?.();
42
+ onKeyDown?.(e);
43
+ };
44
+ const isGlobal = variant === 'global';
45
+ const showActionButton = Children.count(children) > 0;
46
+ return jsxs("div", {
47
+ className: clsx(styles.search, className),
48
+ children: [jsx(Search, {
49
+ "aria-label": searchIconAriaLabel,
50
+ className: clsx(styles.searchIcon, isGlobal && styles.global),
51
+ color: IconIconOnLightSecondary
52
+ }), jsx("input", {
53
+ ...rest,
54
+ ref: forwardedRef,
55
+ "aria-label": searchInputAriaLabel,
56
+ className: clsx(styles.searchInput, isGlobal && styles.global, {
57
+ [styles.withoutActionButton]: isGlobal && !showActionButton
58
+ }),
59
+ disabled: disabled,
60
+ onChange: onChange,
61
+ onKeyDown: onSearchInputKeyDown,
62
+ onSubmit: e => {
63
+ onSubmit?.(value);
64
+ },
65
+ placeholder: placeholder,
66
+ type: "search",
67
+ value: value
68
+ }), !!value && jsx(IconButton, {
69
+ "aria-label": searchInputClearAriaLabel,
70
+ className: clsx(styles.clearSearchIcon, isGlobal && styles.global, isGlobal && !showActionButton && styles.withoutActionButton),
71
+ color: IconCtaIcon,
72
+ icon: isGlobal ? AccessibleXMarkGlobal : AccessibleXMark,
73
+ onClick: onClearInput,
74
+ size: "x-small"
75
+ }), isGlobal && showActionButton && children]
76
+ });
77
+ });
78
+
79
+ export { SearchInputControlled };
@@ -0,0 +1,17 @@
1
+ import { type ChangeEvent } from 'react';
2
+ import { type SearchInputProps } from '../types';
3
+ export interface SearchInputControlledProps extends Omit<SearchInputProps, 'defaultValue' | 'onChange'> {
4
+ /**
5
+ * Handler that is called when the search value is changed.
6
+ */
7
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
8
+ /**
9
+ * Handler that is called when clear button is clicked or escape key is pressed when input is focused
10
+ */
11
+ onClearInput: () => void;
12
+ /**
13
+ * Value for controlled search input.
14
+ *
15
+ */
16
+ value: string;
17
+ }
@@ -1,16 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
3
- ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
4
- }, "disabled" | "type" | "onChange" | "defaultValue" | "className" | "onSubmit" | "onKeyDown" | "searchIconAriaLabel" | "searchInputAriaLabel" | "searchInputClearAriaLabel" | "variant"> & {
5
- className?: string | undefined;
6
- defaultValue?: string | undefined;
7
- disabled?: boolean | undefined;
8
- onChange?: ((searchInputValue: string) => void) | undefined;
9
- onKeyDown?: ((e: import("react").KeyboardEvent<HTMLInputElement>) => void) | undefined;
10
- onSubmit?: ((searchInputValue: string) => void) | undefined;
11
- searchIconAriaLabel: string;
12
- searchInputAriaLabel: string;
13
- searchInputClearAriaLabel: string;
14
- type?: "search" | undefined;
15
- variant?: "in-context" | "global" | undefined;
16
- }, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
2
+ import { type SearchInputProps } from './types';
3
+ export declare const AccessibleXMark: () => JSX.Element;
4
+ export declare const AccessibleXMarkGlobal: () => JSX.Element;
5
+ export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<SearchInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -15,6 +15,9 @@ const AccessibleXMarkGlobal = () => jsx(XMark, {
15
15
  role: "presentation",
16
16
  width: "1.25rem"
17
17
  });
18
+ // WARNING: this uncontrolled version of SearchInput is deprecated
19
+ // The logic of SearchInput will be replaced with the logic that is currently in SearchInput.Controlled.
20
+ // This is planned by EO Q1. For more information, please contact the Home Web Team.
18
21
  const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
19
22
  const {
20
23
  children,
@@ -92,4 +95,4 @@ const SearchInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
92
95
  });
93
96
  });
94
97
 
95
- export { SearchInput };
98
+ export { AccessibleXMark, AccessibleXMarkGlobal, SearchInput };
@@ -1,7 +1,6 @@
1
1
  import type React from 'react';
2
2
  import { type IconButtonProps } from '../primitives/icon-button';
3
- import { type Modify } from '../types/modify';
4
- export type SearchInputProps = Modify<React.ComponentPropsWithRef<'input'>, {
3
+ export interface SearchInputProps extends Omit<React.ComponentPropsWithRef<'input'>, 'onChange' | 'onSubmit'> {
5
4
  className?: string;
6
5
  /**
7
6
  * Default value for search input.
@@ -49,5 +48,5 @@ export type SearchInputProps = Modify<React.ComponentPropsWithRef<'input'>, {
49
48
  * @default "in-context"
50
49
  */
51
50
  variant?: 'in-context' | 'global';
52
- }>;
51
+ }
53
52
  export type SearchInputActionButtonProps = IconButtonProps;
@@ -0,0 +1,56 @@
1
+ /// <reference types="react" />
2
+ export { type ToolbarButtonProps, type ToolbarIconProps, type ToolbarProps, type ToolbarSeparatorProps, type ToolbarToggleGroupProps, type ToolbarToggleItemProps, type ToolbarTriggerButtonProps, } from './types';
3
+ /**
4
+ * A container for grouping a set of controls, such as buttons, toggle groups or dropdowns.
5
+ * @example
6
+ * <Toolbar.Root>
7
+ * <Toolbar.ToggleGroup type="single">
8
+ * <Toolbar.ToggleItem aria-label="draw" icon={Pencil} value="pencil" />
9
+ * <Toolbar.ToggleItem aria-label="stop-drawing" icon={PencilCrossed} value="pencilCrossed" />
10
+ * </Toolbar.ToggleGroup>
11
+ * <Toolbar.Separator />
12
+ *
13
+ * <Toolbar.Button>
14
+ * share
15
+ * </Toolbar.Button>
16
+ * <Toolbar.Separator />
17
+ *
18
+ * <Toolbar.Button aria-label="delete" >
19
+ * Upload <Toolbar.DropdownIndicator direction="down" />
20
+ * </Toolbar.Button>
21
+ * </Toolbar.Root>
22
+ */
23
+ export declare const Toolbar: {
24
+ /**
25
+ * Contains all parts of the toolbar component.
26
+ */
27
+ Root: import("react").ForwardRefExoticComponent<import("@radix-ui/react-toolbar").ToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
28
+ /**
29
+ * Two-state button that can be toggled on or off.
30
+ */
31
+ ToggleItem: import("react").ForwardRefExoticComponent<import("./types").ToolbarToggleItemProps & import("react").RefAttributes<HTMLButtonElement>>;
32
+ /**
33
+ * Parent for a set of `Toolbar.ToggleItem` subcomponents.
34
+ */
35
+ ToggleGroup: import("react").ForwardRefExoticComponent<import("@radix-ui/react-toolbar").ToggleGroupProps & import("react").RefAttributes<HTMLDivElement>>;
36
+ /**
37
+ * A button that is used as a trigger for dropdown elements.
38
+ */
39
+ DropdownTriggerButton: import("react").ForwardRefExoticComponent<import("./types").ToolbarTriggerButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
40
+ /**
41
+ * SVG element used to render icon in buttons.
42
+ */
43
+ Icon: import("react").ForwardRefExoticComponent<import("./types").ToolbarIconProps & import("react").RefAttributes<SVGSVGElement>>;
44
+ /**
45
+ * A button item.
46
+ */
47
+ Button: import("react").ForwardRefExoticComponent<import("./types").ToolbarButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
48
+ /**
49
+ * Component used to visually separate options in the Toolbar.
50
+ */
51
+ Separator: import("react").ForwardRefExoticComponent<import("@radix-ui/react-toolbar").ToolbarSeparatorProps & import("react").RefAttributes<HTMLDivElement>>;
52
+ /**
53
+ * Caret icon indicating dropdown.
54
+ */
55
+ DropdownIndicator: import("react").ForwardRefExoticComponent<import("./types").ToolbarDropdownIndicatorProps & import("react").RefAttributes<SVGSVGElement>>;
56
+ };
@@ -0,0 +1,65 @@
1
+ import { ToolbarButton } from './toolbar-button.js';
2
+ import { ToolbarDropdownIndicator } from './toolbar-dropdown-indicator.js';
3
+ import { ToolbarIcon } from './toolbar-icon.js';
4
+ import { ToolbarRoot } from './toolbar-root.js';
5
+ import { ToolbarSeparator } from './toolbar-separator.js';
6
+ import { ToolbarToggleGroup } from './toolbar-toggle-group.js';
7
+ import { ToolbarToggleItem } from './toolbar-toggle-item.js';
8
+ import { ToolbarTriggerButton } from './toolbar-trigger-button.js';
9
+
10
+ /**
11
+ * A container for grouping a set of controls, such as buttons, toggle groups or dropdowns.
12
+ * @example
13
+ * <Toolbar.Root>
14
+ * <Toolbar.ToggleGroup type="single">
15
+ * <Toolbar.ToggleItem aria-label="draw" icon={Pencil} value="pencil" />
16
+ * <Toolbar.ToggleItem aria-label="stop-drawing" icon={PencilCrossed} value="pencilCrossed" />
17
+ * </Toolbar.ToggleGroup>
18
+ * <Toolbar.Separator />
19
+ *
20
+ * <Toolbar.Button>
21
+ * share
22
+ * </Toolbar.Button>
23
+ * <Toolbar.Separator />
24
+ *
25
+ * <Toolbar.Button aria-label="delete" >
26
+ * Upload <Toolbar.DropdownIndicator direction="down" />
27
+ * </Toolbar.Button>
28
+ * </Toolbar.Root>
29
+ */
30
+ const Toolbar = {
31
+ /**
32
+ * Contains all parts of the toolbar component.
33
+ */
34
+ Root: ToolbarRoot,
35
+ /**
36
+ * Two-state button that can be toggled on or off.
37
+ */
38
+ ToggleItem: ToolbarToggleItem,
39
+ /**
40
+ * Parent for a set of `Toolbar.ToggleItem` subcomponents.
41
+ */
42
+ ToggleGroup: ToolbarToggleGroup,
43
+ /**
44
+ * A button that is used as a trigger for dropdown elements.
45
+ */
46
+ DropdownTriggerButton: ToolbarTriggerButton,
47
+ /**
48
+ * SVG element used to render icon in buttons.
49
+ */
50
+ Icon: ToolbarIcon,
51
+ /**
52
+ * A button item.
53
+ */
54
+ Button: ToolbarButton,
55
+ /**
56
+ * Component used to visually separate options in the Toolbar.
57
+ */
58
+ Separator: ToolbarSeparator,
59
+ /**
60
+ * Caret icon indicating dropdown.
61
+ */
62
+ DropdownIndicator: ToolbarDropdownIndicator
63
+ };
64
+
65
+ export { Toolbar };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type ToolbarButtonProps } from './types';
3
+ export declare const ToolbarButton: import("react").ForwardRefExoticComponent<ToolbarButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,27 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ import clsx from 'clsx';
4
+ import { forwardRef } from 'react';
5
+ import styles from './toolbar.module.js';
6
+
7
+ const ToolbarButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ style,
11
+ backgroundColor,
12
+ className,
13
+ ...rest
14
+ } = props;
15
+ return jsx(ToolbarPrimitive.Button, {
16
+ ...rest,
17
+ ref: forwardedRef,
18
+ className: clsx(styles.toolbarItem, className),
19
+ style: {
20
+ '--toolbar-button-color': backgroundColor,
21
+ ...style
22
+ },
23
+ children: children
24
+ });
25
+ });
26
+
27
+ export { ToolbarButton };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type ToolbarDropdownIndicatorProps } from './types';
3
+ export declare const ToolbarDropdownIndicator: import("react").ForwardRefExoticComponent<ToolbarDropdownIndicatorProps & import("react").RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,25 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Caret } from '@box/blueprint-web-assets/icons/Fill';
3
+ import { Size3 } from '@box/blueprint-web-assets/tokens/tokens';
4
+ import clsx from 'clsx';
5
+ import { forwardRef } from 'react';
6
+ import styles from './toolbar.module.js';
7
+
8
+ const ToolbarDropdownIndicator = /*#__PURE__*/forwardRef(({
9
+ direction = 'down',
10
+ className,
11
+ color
12
+ }, forwardedRef) => {
13
+ return jsx(Caret, {
14
+ ref: forwardedRef,
15
+ className: clsx({
16
+ [styles.invertDropdownIndicator]: direction === 'up'
17
+ }, className),
18
+ color: color,
19
+ height: Size3,
20
+ role: "presentation",
21
+ width: Size3
22
+ });
23
+ });
24
+
25
+ export { ToolbarDropdownIndicator };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { type ToolbarIconProps } from './types';
3
+ export declare const ToolbarIcon: React.ForwardRefExoticComponent<ToolbarIconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,20 @@
1
+ import { Size5, IconIconOnLight } from '@box/blueprint-web-assets/tokens/tokens';
2
+ import React__default, { forwardRef } from 'react';
3
+
4
+ const ToolbarIcon = /*#__PURE__*/forwardRef((props, forwardedRef) => {
5
+ const {
6
+ icon,
7
+ className,
8
+ color = IconIconOnLight
9
+ } = props;
10
+ return /*#__PURE__*/React__default.createElement(icon, {
11
+ ref: forwardedRef,
12
+ width: Size5,
13
+ height: Size5,
14
+ role: 'presentation',
15
+ className,
16
+ color
17
+ });
18
+ });
19
+
20
+ export { ToolbarIcon };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ export declare const ToolbarRoot: import("react").ForwardRefExoticComponent<ToolbarPrimitive.ToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,21 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ import clsx from 'clsx';
4
+ import { forwardRef } from 'react';
5
+ import styles from './toolbar.module.js';
6
+
7
+ const ToolbarRoot = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ className,
11
+ ...rest
12
+ } = props;
13
+ return jsx(ToolbarPrimitive.Root, {
14
+ ...rest,
15
+ ref: forwardedRef,
16
+ className: clsx(styles.root, className),
17
+ children: children
18
+ });
19
+ });
20
+
21
+ export { ToolbarRoot };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ export declare const ToolbarSeparator: import("react").ForwardRefExoticComponent<ToolbarPrimitive.ToolbarSeparatorProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,20 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ import clsx from 'clsx';
4
+ import { forwardRef } from 'react';
5
+ import styles from './toolbar.module.js';
6
+
7
+ const ToolbarSeparator = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ className,
11
+ ...rest
12
+ } = props;
13
+ return jsx(ToolbarPrimitive.Separator, {
14
+ ...rest,
15
+ ref: forwardedRef,
16
+ className: clsx(styles.separator, className)
17
+ });
18
+ });
19
+
20
+ export { ToolbarSeparator };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ export declare const ToolbarToggleGroup: import("react").ForwardRefExoticComponent<ToolbarPrimitive.ToggleGroupProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,21 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
3
+ import clsx from 'clsx';
4
+ import { forwardRef } from 'react';
5
+ import styles from './toolbar.module.js';
6
+
7
+ const ToolbarToggleGroup = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ className,
11
+ ...rest
12
+ } = props;
13
+ return jsx(ToolbarPrimitive.ToggleGroup, {
14
+ ...rest,
15
+ ref: forwardedRef,
16
+ className: clsx(styles.toggleGroup, className),
17
+ children: children
18
+ });
19
+ });
20
+
21
+ export { ToolbarToggleGroup };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type ToolbarToggleItemProps } from './types';
3
+ export declare const ToolbarToggleItem: import("react").ForwardRefExoticComponent<ToolbarToggleItemProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,28 @@
1
+ import { jsxs } from 'react/jsx-runtime';
2
+ import { Size6, IconIconOnLight } from '@box/blueprint-web-assets/tokens/tokens';
3
+ import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
4
+ import clsx from 'clsx';
5
+ import { forwardRef, createElement } from 'react';
6
+ import styles from './toolbar.module.js';
7
+
8
+ const ToolbarToggleItem = /*#__PURE__*/forwardRef((props, forwardedRef) => {
9
+ const {
10
+ children,
11
+ icon,
12
+ color = IconIconOnLight,
13
+ ...rest
14
+ } = props;
15
+ return jsxs(ToolbarPrimitive.ToggleItem, {
16
+ ...rest,
17
+ ref: forwardedRef,
18
+ className: clsx(styles.toolbarItem, styles.toolbarToggle),
19
+ children: [children, /*#__PURE__*/createElement(icon, {
20
+ height: Size6,
21
+ width: Size6,
22
+ role: 'presentation',
23
+ color
24
+ })]
25
+ });
26
+ });
27
+
28
+ export { ToolbarToggleItem };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type ToolbarTriggerButtonProps } from './types';
3
+ export declare const ToolbarTriggerButton: import("react").ForwardRefExoticComponent<ToolbarTriggerButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,29 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import clsx from 'clsx';
3
+ import { forwardRef } from 'react';
4
+ import { ToolbarButton } from './toolbar-button.js';
5
+ import styles from './toolbar.module.js';
6
+
7
+ const ToolbarTriggerButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
8
+ const {
9
+ children,
10
+ selected = false,
11
+ className,
12
+ ...rest
13
+ } = props;
14
+ const selectionStateAttrs = {
15
+ 'data-state': selected ? 'on' : 'off',
16
+ 'aria-pressed': Boolean(selected)
17
+ };
18
+ return jsx(ToolbarButton, {
19
+ ...rest,
20
+ ...selectionStateAttrs,
21
+ ref: forwardedRef,
22
+ className: clsx(className, {
23
+ [styles.triggerButtonSelectedWithColor]: props.backgroundColor && selected
24
+ }),
25
+ children: children
26
+ });
27
+ });
28
+
29
+ export { ToolbarTriggerButton };
@@ -0,0 +1,4 @@
1
+ import '../index.css';
2
+ var styles = {"root":"toolbar_module_root--afeab","separator":"toolbar_module_separator--afeab","toggleGroup":"toolbar_module_toggleGroup--afeab","toolbarItem":"toolbar_module_toolbarItem--afeab","toolbarToggle":"toolbar_module_toolbarToggle--afeab","invertDropdownIndicator":"toolbar_module_invertDropdownIndicator--afeab","triggerButtonSelectedWithColor":"toolbar_module_triggerButtonSelectedWithColor--afeab"};
3
+
4
+ export { styles as default };
@@ -0,0 +1,39 @@
1
+ import { type ToggleGroupProps as ToolbarToggleGroupPrimitiveProps, type ToolbarButtonProps as ToolbarPrimitiveButtonProps, type ToolbarProps as ToolbarPrimitiveProps, type ToolbarSeparatorProps as ToolbarPrimitiveSeparatorProps, type ToolbarToggleItemProps as ToolbarPrimitiveToggleItemProps } from '@radix-ui/react-toolbar';
2
+ import { type CSSProperties, type FunctionComponent, type HTMLAttributes, type PropsWithChildren, type SVGProps } from 'react';
3
+ export type ToolbarProps = ToolbarPrimitiveProps;
4
+ export type ToolbarSeparatorProps = ToolbarPrimitiveSeparatorProps;
5
+ export type ToolbarToggleGroupProps = ToolbarToggleGroupPrimitiveProps;
6
+ interface ToolbarButtonCSS extends CSSProperties {
7
+ '--toolbar-button-color'?: string;
8
+ }
9
+ export interface ToolbarButtonProps extends Omit<ToolbarPrimitiveButtonProps, 'style'> {
10
+ /** Sets background color of button element. */
11
+ backgroundColor?: CSSProperties['backgroundColor'];
12
+ style?: ToolbarButtonCSS;
13
+ }
14
+ export interface ToolbarTriggerButtonProps extends ToolbarButtonProps {
15
+ /** Selection state of group opened with button.
16
+ * @default false
17
+ */
18
+ selected?: boolean;
19
+ }
20
+ export interface ToolbarToggleItemProps extends ToolbarPrimitiveToggleItemProps {
21
+ /** Icon rendered by the component. */
22
+ icon: FunctionComponent<PropsWithChildren<SVGProps<SVGSVGElement>>>;
23
+ 'aria-label': NonNullable<HTMLAttributes<HTMLButtonElement>['aria-label']>;
24
+ }
25
+ export type ToolbarIconProps = {
26
+ color?: React.SVGProps<SVGSVGElement>['color'];
27
+ className?: string;
28
+ /** Icon rendered by the component. */
29
+ icon: React.FunctionComponent<React.PropsWithChildren<React.SVGProps<SVGSVGElement>>>;
30
+ };
31
+ export type ToolbarDropdownIndicatorProps = {
32
+ /** Direction in which by indicator is pointing.
33
+ * @default 'down'
34
+ */
35
+ direction?: 'up' | 'down';
36
+ color?: React.SVGProps<SVGSVGElement>['color'];
37
+ className?: string;
38
+ };
39
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "6.9.3",
3
+ "version": "6.11.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -45,6 +45,7 @@
45
45
  "@radix-ui/react-switch": "^1.0.3",
46
46
  "@radix-ui/react-toast": "1.1.4",
47
47
  "@radix-ui/react-toggle-group": "^1.0.4",
48
+ "@radix-ui/react-toolbar": "^1.0.4",
48
49
  "@radix-ui/react-tooltip": "1.0.6",
49
50
  "@radix-ui/react-visually-hidden": "^1.0.3",
50
51
  "clsx": "^1.2.1",
@@ -56,7 +57,7 @@
56
57
  "devDependencies": {
57
58
  "@box/storybook-utils": "^0.0.3"
58
59
  },
59
- "gitHead": "a9179078ea86d2c0c0c983451cc6b64270f011ec",
60
+ "gitHead": "efa215e8d6bd57e23276f66c3f9b6ff60ed77271",
60
61
  "module": "lib-esm/index.js",
61
62
  "main": "lib-esm/index.js",
62
63
  "exports": {