@box/blueprint-web 11.1.1 → 11.2.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.
@@ -0,0 +1,3 @@
1
+ import { type ElementTypes } from '../text/types';
2
+ import { type EllipsizableTextProps } from './types';
3
+ export declare const EllipsizableText: import("react").ForwardRefExoticComponent<EllipsizableTextProps & import("react").RefAttributes<ElementTypes>>;
@@ -0,0 +1,50 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef, createRef } from 'react';
3
+ import { Focusable } from '../focusable/focusable.js';
4
+ import { Text } from '../text/text.js';
5
+ import { Tooltip } from '../tooltip/tooltip.js';
6
+ import { useForkRef } from '../utils/useForkRef.js';
7
+ import { useIsEllipsized } from '../utils/useIsEllipsized.js';
8
+
9
+ const Wrapper = ({
10
+ children,
11
+ withTooltip,
12
+ tooltipContent
13
+ }) => {
14
+ if (withTooltip) {
15
+ return jsx(Tooltip, {
16
+ content: tooltipContent,
17
+ children: jsx(Focusable, {
18
+ children: children
19
+ })
20
+ });
21
+ }
22
+ return children;
23
+ };
24
+ const EllipsizableText = /*#__PURE__*/forwardRef(({
25
+ children,
26
+ lineClamp,
27
+ style,
28
+ ...rest
29
+ }, forwardedRef) => {
30
+ const textRef = /*#__PURE__*/createRef();
31
+ const isEllipsized = useIsEllipsized(textRef);
32
+ return jsx(Wrapper, {
33
+ tooltipContent: children,
34
+ withTooltip: isEllipsized,
35
+ children: jsx(Text, {
36
+ ref: useForkRef(textRef, forwardedRef),
37
+ ...rest,
38
+ style: {
39
+ ...style,
40
+ display: '-webkit-box',
41
+ overflow: 'hidden',
42
+ WebkitBoxOrient: 'vertical',
43
+ WebkitLineClamp: lineClamp.toString()
44
+ },
45
+ children: children
46
+ })
47
+ });
48
+ });
49
+
50
+ export { EllipsizableText };
@@ -0,0 +1,2 @@
1
+ export * from './ellipsizable-text';
2
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ import { type TextProps } from '../text';
2
+ export type EllipsizableTextProps = TextProps & {
3
+ /** Number if lines to show before the text is ellipsized. Note lineClamp must be a positive integer. */
4
+ lineClamp: number;
5
+ };
@@ -17,6 +17,7 @@ export * from './content-field';
17
17
  export * from './data-table/data-table';
18
18
  export * from './date-picker';
19
19
  export * from './divider';
20
+ export * from './ellipsizable-text';
20
21
  export * from './empty-state';
21
22
  export * from './focusable';
22
23
  export * from './ghost';
@@ -21,6 +21,7 @@ export { ContentField } from './content-field/content-field.js';
21
21
  export { DataTableWrapper, StickyCell } from './data-table/data-table.js';
22
22
  export { DatePicker } from './date-picker/date-picker.js';
23
23
  export { Divider } from './divider/divider.js';
24
+ export { EllipsizableText } from './ellipsizable-text/ellipsizable-text.js';
24
25
  export { EmptyState } from './empty-state/empty-state.js';
25
26
  export { Focusable } from './focusable/focusable.js';
26
27
  export { Ghost } from './ghost/ghost.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "11.1.1",
3
+ "version": "11.2.0",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {