@box/blueprint-web 12.131.0 → 12.132.1

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.
@@ -11366,7 +11366,7 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
11366
11366
  background-color:var(--switch-bg-on-hover);
11367
11367
  }
11368
11368
 
11369
- .bp_text_button_module_textButton--97dc1[data-modern=false]{
11369
+ .bp_text_button_module_textButton--d9331[data-modern=false]{
11370
11370
  --text-button-text-color:var(--text-cta-link);
11371
11371
  --text-button-radius:calc(var(--radius-1)/2);
11372
11372
  --text-button-padding:0;
@@ -11385,15 +11385,15 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
11385
11385
  text-decoration:var(--body-default-bold-text-decoration);
11386
11386
  text-transform:var(--body-default-bold-text-case);
11387
11387
  }
11388
- .bp_text_button_module_textButton--97dc1[data-modern=false].bp_text_button_module_isFontInherited--97dc1{
11388
+ .bp_text_button_module_textButton--d9331[data-modern=false].bp_text_button_module_isFontInherited--d9331{
11389
11389
  --text-button-radius-font-inherited:0.125em;
11390
11390
  --text-button-outline:var(--outline-focus-on-light);
11391
11391
  }
11392
- .bp_text_button_module_textButton--97dc1[data-modern=false].bp_text_button_module_isIconButton--97dc1{
11392
+ .bp_text_button_module_textButton--d9331[data-modern=false].bp_text_button_module_isIconButton--d9331{
11393
11393
  --text-button-gap:var(--space-1);
11394
11394
  }
11395
11395
 
11396
- .bp_text_button_module_textButton--97dc1[data-modern=true]{
11396
+ .bp_text_button_module_textButton--d9331[data-modern=true]{
11397
11397
  --text-button-text-color:var(--bp-text-cta-link);
11398
11398
  --text-button-radius:var(--bp-radius-04);
11399
11399
  --text-button-padding:0 var(--bp-space-010);
@@ -11410,15 +11410,15 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
11410
11410
  letter-spacing:var(--bp-font-letter-spacing-01);
11411
11411
  line-height:var(--bp-font-line-height-04);
11412
11412
  }
11413
- .bp_text_button_module_textButton--97dc1[data-modern=true].bp_text_button_module_isFontInherited--97dc1{
11413
+ .bp_text_button_module_textButton--d9331[data-modern=true].bp_text_button_module_isFontInherited--d9331{
11414
11414
  --text-button-radius-font-inherited:0.375em;
11415
11415
  --text-button-outline:var(--bp-outline-focus-on-light);
11416
11416
  }
11417
- .bp_text_button_module_textButton--97dc1[data-modern=true].bp_text_button_module_isIconButton--97dc1{
11417
+ .bp_text_button_module_textButton--d9331[data-modern=true].bp_text_button_module_isIconButton--d9331{
11418
11418
  --text-button-gap:var(--bp-space-010);
11419
11419
  }
11420
11420
 
11421
- .bp_text_button_module_textButton--97dc1{
11421
+ .bp_text_button_module_textButton--d9331{
11422
11422
  align-items:center;
11423
11423
  background:#0000;
11424
11424
  border:none;
@@ -11431,46 +11431,56 @@ div[data-radix-popper-content-wrapper]:has([role=menu]):has([data-state=open]):h
11431
11431
  -webkit-user-select:text;
11432
11432
  user-select:text;
11433
11433
  }
11434
- .bp_text_button_module_textButton--97dc1.bp_text_button_module_isFontInherited--97dc1{
11434
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isFontInherited--d9331{
11435
11435
  border-radius:var(--text-button-radius-font-inherited);
11436
11436
  font:inherit;
11437
11437
  }
11438
- .bp_text_button_module_textButton--97dc1.bp_text_button_module_isFontInherited--97dc1.bp_text_button_module_isIconButton--97dc1{
11438
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isFontInherited--d9331.bp_text_button_module_isIconButton--d9331{
11439
11439
  gap:.25em;
11440
11440
  }
11441
- .bp_text_button_module_textButton--97dc1.bp_text_button_module_isFontInherited--97dc1:not(:disabled)[data-focus-visible]{
11441
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isFontInherited--d9331:not(:disabled)[data-focus-visible]{
11442
11442
  box-shadow:0 0 0 .125em var(--text-button-outline);
11443
11443
  }
11444
- .bp_text_button_module_textButton--97dc1 .bp_text_button_module_scaleLoader--97dc1 div{
11444
+ .bp_text_button_module_textButton--d9331 .bp_text_button_module_scaleLoader--d9331 div{
11445
11445
  border-radius:var(--text-button-scale-loader-border-radius);
11446
11446
  height:var(--text-button-scale-loader-height);
11447
11447
  width:var(--text-button-scale-loader-width);
11448
11448
  }
11449
- .bp_text_button_module_textButton--97dc1 .bp_text_button_module_icon--97dc1{
11449
+ .bp_text_button_module_textButton--d9331 .bp_text_button_module_icon--d9331{
11450
11450
  align-items:center;
11451
11451
  display:flex;
11452
11452
  }
11453
- .bp_text_button_module_textButton--97dc1 .bp_text_button_module_hideTextContent--97dc1{
11453
+ .bp_text_button_module_textButton--d9331 .bp_text_button_module_hideTextContent--d9331{
11454
11454
  visibility:hidden;
11455
11455
  }
11456
- .bp_text_button_module_textButton--97dc1.bp_text_button_module_isIconButton--97dc1{
11456
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isEllipsized--d9331{
11457
+ max-width:100%;
11458
+ }
11459
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isEllipsized--d9331 .bp_text_button_module_text--d9331{
11460
+ display:block;
11461
+ min-width:0;
11462
+ overflow:hidden;
11463
+ text-overflow:ellipsis;
11464
+ white-space:nowrap;
11465
+ }
11466
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_isIconButton--d9331{
11457
11467
  gap:var(--text-button-gap);
11458
11468
  }
11459
- .bp_text_button_module_textButton--97dc1.bp_text_button_module_visuallyHidden--97dc1{
11469
+ .bp_text_button_module_textButton--d9331.bp_text_button_module_visuallyHidden--d9331{
11460
11470
  color:#0000;
11461
11471
  pointer-events:none;
11462
11472
  position:relative;
11463
11473
  }
11464
- .bp_text_button_module_textButton--97dc1:disabled{
11474
+ .bp_text_button_module_textButton--d9331:disabled{
11465
11475
  opacity:.3;
11466
11476
  }
11467
- .bp_text_button_module_textButton--97dc1:not(:disabled):hover,.bp_text_button_module_textButton--97dc1:not(:disabled)[data-focus-visible]{
11477
+ .bp_text_button_module_textButton--d9331:not(:disabled):hover,.bp_text_button_module_textButton--d9331:not(:disabled)[data-focus-visible]{
11468
11478
  color:var(--text-button-text-color-hover);
11469
11479
  }
11470
- .bp_text_button_module_textButton--97dc1:not(:disabled)[data-focus-visible]{
11480
+ .bp_text_button_module_textButton--d9331:not(:disabled)[data-focus-visible]{
11471
11481
  box-shadow:var(--text-button-focus-box-shadow);
11472
11482
  }
11473
- .bp_text_button_module_textButton--97dc1:not(:disabled):active{
11483
+ .bp_text_button_module_textButton--d9331:not(:disabled):active{
11474
11484
  color:var(--text-button-text-color-active);
11475
11485
  }
11476
11486
 
@@ -1,59 +1,85 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { Button } from '@ariakit/react';
3
3
  import clsx from 'clsx';
4
- import { forwardRef, createElement } from 'react';
5
- import { useBlueprintModernization } from '../blueprint-modernization-context/useBlueprintModernization.js';
4
+ import { forwardRef, useRef, createElement } from 'react';
6
5
  import { LoadingIndicator } from '../loading-indicator/loading-indicator.js';
6
+ import { Text } from '../text/text.js';
7
+ import { TooltipWrapper } from '../utils/TooltipWrapper.js';
8
+ import { useBlueprintModernization } from '../blueprint-modernization-context/useBlueprintModernization.js';
7
9
  import { getButtonOptions } from '../utils/getButtonOptions.js';
10
+ import { useIsEllipsized } from '../utils/useIsEllipsized.js';
8
11
  import styles from './text-button.module.js';
9
12
 
10
13
  const TextButton = /*#__PURE__*/forwardRef((props, ref) => {
11
14
  const {
12
15
  children,
16
+ color,
13
17
  loading,
14
18
  loadingAriaLabel,
15
19
  icon,
16
20
  inheritFont,
17
21
  className,
18
- textRef,
22
+ ellipsizable,
23
+ tooltipSide,
24
+ variant,
19
25
  ...rest
20
26
  } = getButtonOptions(props);
21
27
  const {
22
28
  enableModernizedComponents
23
29
  } = useBlueprintModernization();
30
+ const textRef = useRef(null);
31
+ const isEllipsized = useIsEllipsized(ellipsizable ? textRef : {
32
+ current: null
33
+ });
24
34
  const iconsSize = `0.875${inheritFont ? 'em' : 'rem'}`;
25
- return jsxs(Button, {
26
- ...rest,
27
- ref: ref,
28
- className: clsx(styles.textButton, {
29
- [styles.visuallyHidden]: loading,
30
- [styles.isIconButton]: Boolean(icon),
31
- [styles.isFontInherited]: inheritFont
32
- }, className),
33
- "data-modern": enableModernizedComponents ? 'true' : 'false',
34
- children: [jsx("span", {
35
- ref: textRef,
36
- className: clsx({
37
- [styles.hideTextContent]: loading
38
- }),
39
- children: children
40
- }), icon ? jsx("span", {
41
- className: clsx(styles.icon, {
42
- [styles.loading]: loading
43
- }),
44
- children: /*#__PURE__*/createElement(icon, {
45
- width: iconsSize,
46
- height: iconsSize,
47
- role: 'presentation',
48
- color: loading ? 'transparent' : 'currentColor'
49
- })
50
- }) : null, loading && loadingAriaLabel ? jsx(LoadingIndicator, {
51
- "aria-label": loadingAriaLabel,
52
- className: clsx({
53
- [styles.scaleLoader]: inheritFont
54
- }),
55
- variant: "default"
56
- }) : null]
35
+ const dataModernValue = enableModernizedComponents ? 'true' : 'false';
36
+ return jsx(TooltipWrapper, {
37
+ tooltipContent: children,
38
+ tooltipSide: tooltipSide,
39
+ withTooltip: isEllipsized,
40
+ children: jsxs(Button, {
41
+ ...rest,
42
+ ref: ref,
43
+ className: clsx(styles.textButton, {
44
+ [styles.visuallyHidden]: loading,
45
+ [styles.isIconButton]: Boolean(icon),
46
+ [styles.isFontInherited]: inheritFont,
47
+ [styles.isEllipsized]: ellipsizable
48
+ }, className),
49
+ "data-modern": dataModernValue,
50
+ children: [variant || color ? jsx(Text, {
51
+ ref: textRef,
52
+ as: "span",
53
+ className: clsx(styles.text, {
54
+ [styles.hideTextContent]: loading
55
+ }),
56
+ color: color,
57
+ variant: variant,
58
+ children: children
59
+ }) : jsx("span", {
60
+ ref: textRef,
61
+ className: clsx(styles.text, {
62
+ [styles.hideTextContent]: loading
63
+ }),
64
+ children: children
65
+ }), icon ? jsx("span", {
66
+ className: clsx(styles.icon, {
67
+ [styles.loading]: loading
68
+ }),
69
+ children: /*#__PURE__*/createElement(icon, {
70
+ width: iconsSize,
71
+ height: iconsSize,
72
+ role: 'presentation',
73
+ color: loading ? 'transparent' : 'currentColor'
74
+ })
75
+ }) : null, loading && loadingAriaLabel ? jsx(LoadingIndicator, {
76
+ "aria-label": loadingAriaLabel,
77
+ className: clsx({
78
+ [styles.scaleLoader]: inheritFont
79
+ }),
80
+ variant: "default"
81
+ }) : null]
82
+ })
57
83
  });
58
84
  });
59
85
  TextButton.displayName = 'TextButton';
@@ -1,4 +1,4 @@
1
1
  import '../index.css';
2
- var styles = {"textButton":"bp_text_button_module_textButton--97dc1","isFontInherited":"bp_text_button_module_isFontInherited--97dc1","isIconButton":"bp_text_button_module_isIconButton--97dc1","scaleLoader":"bp_text_button_module_scaleLoader--97dc1","icon":"bp_text_button_module_icon--97dc1","hideTextContent":"bp_text_button_module_hideTextContent--97dc1","visuallyHidden":"bp_text_button_module_visuallyHidden--97dc1"};
2
+ var styles = {"textButton":"bp_text_button_module_textButton--d9331","isFontInherited":"bp_text_button_module_isFontInherited--d9331","isIconButton":"bp_text_button_module_isIconButton--d9331","scaleLoader":"bp_text_button_module_scaleLoader--d9331","icon":"bp_text_button_module_icon--d9331","hideTextContent":"bp_text_button_module_hideTextContent--d9331","isEllipsized":"bp_text_button_module_isEllipsized--d9331","text":"bp_text_button_module_text--d9331","visuallyHidden":"bp_text_button_module_visuallyHidden--d9331"};
3
3
 
4
4
  export { styles as default };
@@ -1,6 +1,8 @@
1
1
  import { type ButtonProps as AriakitButtonProps } from '@ariakit/react';
2
- import { type FunctionComponent, type PropsWithChildren, type Ref, type SVGProps } from 'react';
2
+ import { type FunctionComponent, type PropsWithChildren, type SVGProps } from 'react';
3
3
  import { type RequireAllOrNone } from 'type-fest';
4
+ import { type TypographyColor, type TypographyVariant } from '../text/types';
5
+ import { type TooltipProps } from '../tooltip';
4
6
  export interface Loading {
5
7
  /** Whether the button is loading. */
6
8
  loading?: boolean;
@@ -10,6 +12,20 @@ export interface Loading {
10
12
  export interface TextButtonBase extends AriakitButtonProps {
11
13
  /** Text content to display in the button. */
12
14
  children: string | string[];
15
+ /**
16
+ * Use `TypographyColor` values to adjust color of text for the button.
17
+ *
18
+ * @default textOnLightDefault
19
+ */
20
+ color?: TypographyColor;
21
+ /**
22
+ * Whether the button text should be ellipsized when it overflows.
23
+ *
24
+ * When enabled, applies ellipsis styles and shows a tooltip with the full text when truncated.
25
+ *
26
+ * Only set this to `true` when the button has a width constraint (e.g., a parent with a fixed width).
27
+ */
28
+ ellipsizable?: boolean;
13
29
  /** Icon that will be placed after the children text. */
14
30
  icon?: FunctionComponent<PropsWithChildren<SVGProps<SVGSVGElement>>>;
15
31
  /**
@@ -18,13 +34,19 @@ export interface TextButtonBase extends AriakitButtonProps {
18
34
  * Useful when Button is within the block of the text, to apply the same style for whole content.
19
35
  *
20
36
  * When property is falsy, button uses default style.
21
- * */
37
+ */
22
38
  inheritFont?: boolean;
23
39
  /**
24
- * Ref to the inner span element that wraps the text content.
40
+ * The side of the button where the tooltip should appear when text is ellipsized.
41
+ *
42
+ * Only used when `ellipsizable` is true.
43
+ */
44
+ tooltipSide?: TooltipProps['side'];
45
+ /**
46
+ * Typographic style of text
25
47
  *
26
- * Useful for measuring text overflow with hooks like `useIsEllipsized`.
48
+ * @default bodyDefault
27
49
  */
28
- textRef?: Ref<HTMLSpanElement>;
50
+ variant?: TypographyVariant;
29
51
  }
30
52
  export type TextButtonProps = TextButtonBase & RequireAllOrNone<Loading, keyof Loading>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "12.131.0",
3
+ "version": "12.132.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@ariakit/react": "0.4.15",
49
49
  "@ariakit/react-core": "0.4.15",
50
- "@box/blueprint-web-assets": "^4.99.4",
50
+ "@box/blueprint-web-assets": "^4.99.6",
51
51
  "@internationalized/date": "^3.7.0",
52
52
  "@radix-ui/react-accordion": "1.1.2",
53
53
  "@radix-ui/react-checkbox": "1.0.4",
@@ -77,7 +77,7 @@
77
77
  "type-fest": "^3.2.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@box/storybook-utils": "^0.16.30",
80
+ "@box/storybook-utils": "^0.16.32",
81
81
  "@figma/code-connect": "1.3.12",
82
82
  "@types/react": "^18.0.0",
83
83
  "@types/react-dom": "^18.0.0",