@indico-data/design-system 3.6.2 → 3.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "3.6.2",
3
+ "version": "3.6.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -71,6 +71,16 @@ const meta: Meta = {
71
71
  },
72
72
  },
73
73
  },
74
+ positionStrategy: {
75
+ control: 'select',
76
+ options: ['absolute', 'fixed'],
77
+ table: {
78
+ category: 'Props',
79
+ type: {
80
+ summary: 'absolute | fixed',
81
+ },
82
+ },
83
+ },
74
84
  children: {
75
85
  control: false,
76
86
  table: {
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties } from 'react';
2
- import { PlacesType, Tooltip as ReactTooltip } from 'react-tooltip';
2
+ import { PlacesType, Tooltip as ReactTooltip, PositionStrategy } from 'react-tooltip';
3
3
 
4
4
  export interface TooltipProps {
5
5
  id: string;
@@ -9,14 +9,16 @@ export interface TooltipProps {
9
9
  delayShow?: number;
10
10
  /** The delay in milliseconds before the tooltip is hidden */
11
11
  delayHide?: number;
12
- children: React.ReactNode;
13
12
  /** The placement of the tooltip */
14
13
  place?: PlacesType;
15
14
  /** The width of the tooltip */
16
15
  width?: CSSProperties['width'];
17
16
  /** The max width of the tooltip */
18
17
  maxWidth?: CSSProperties['maxWidth'];
18
+ /** The position strategy of the tooltip */
19
+ positionStrategy?: PositionStrategy;
19
20
  /** The content of the tooltip */
21
+ children: React.ReactNode;
20
22
  [key: string]: any;
21
23
  }
22
24
 
@@ -30,6 +32,7 @@ export const Tooltip = ({
30
32
  width = 'max-content',
31
33
  maxWidth,
32
34
  opacity = 1,
35
+ positionStrategy = 'absolute',
33
36
  ...rest
34
37
  }: TooltipProps) => {
35
38
  return (
@@ -51,6 +54,7 @@ export const Tooltip = ({
51
54
  delayShow={delayShow}
52
55
  delayHide={delayHide}
53
56
  opacity={opacity}
57
+ positionStrategy={positionStrategy}
54
58
  {...rest}
55
59
  >
56
60
  {children}
@@ -13,7 +13,7 @@ const meta: Meta<typeof Truncate> = {
13
13
  ),
14
14
  ],
15
15
  argTypes: {
16
- truncateString: {
16
+ children: {
17
17
  required: true,
18
18
  control: 'text',
19
19
  table: {
@@ -43,7 +43,7 @@ type Story = StoryObj<TruncateProps>;
43
43
  export const Default: Story = {
44
44
  args: {
45
45
  numLines: 1,
46
- truncateString: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
46
+ children: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
47
47
  },
48
48
  render: (args) => <Truncate {...args} />,
49
49
  };
@@ -51,7 +51,7 @@ export const Default: Story = {
51
51
  export const NoTruncate: Story = {
52
52
  args: {
53
53
  numLines: 1,
54
- truncateString: 'No truncate',
54
+ children: 'No truncate',
55
55
  },
56
56
  render: (args) => <Truncate {...args} />,
57
57
  };
@@ -59,7 +59,7 @@ export const NoTruncate: Story = {
59
59
  export const WithNumLines: Story = {
60
60
  args: {
61
61
  numLines: 2,
62
- truncateString: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
62
+ children: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
63
63
  },
64
64
  render: (args) => <Truncate {...args} />,
65
65
  };
@@ -71,7 +71,7 @@ export const WithTooltipOptions: Story = {
71
71
  place: 'right',
72
72
  width: '150px',
73
73
  },
74
- truncateString: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
74
+ children: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
75
75
  },
76
76
  render: (args) => <Truncate {...args} />,
77
77
  };
@@ -82,7 +82,7 @@ export const NoTooltip: Story = {
82
82
  tooltipOptions: {
83
83
  disabled: true,
84
84
  },
85
- truncateString: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
85
+ children: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
86
86
  },
87
87
  render: (args) => <Truncate {...args} />,
88
88
  };
@@ -93,7 +93,7 @@ export const TruncateWithTooltipWidth: Story = {
93
93
  tooltipOptions: {
94
94
  width: 'calc(100% - 40px)',
95
95
  },
96
- truncateString:
96
+ children:
97
97
  'Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.',
98
98
  },
99
99
  render: (args) => <Truncate {...args} />,
@@ -6,8 +6,8 @@ import classNames from 'classnames';
6
6
 
7
7
  export const Truncate = ({
8
8
  numLines = 1,
9
- truncateString,
10
9
  tooltipOptions = {},
10
+ children,
11
11
  ...rest
12
12
  }: TruncateProps) => {
13
13
  const [isTruncated, setIsTruncated] = useState(false);
@@ -47,11 +47,11 @@ export const Truncate = ({
47
47
  })}
48
48
  {...rest}
49
49
  >
50
- {truncateString}
50
+ {children}
51
51
  </span>
52
- {isTruncated && truncateString && !tooltipOptions.disabled && (
52
+ {isTruncated && children && !tooltipOptions.disabled && (
53
53
  <Tooltip {...tooltipOptions} id={id}>
54
- {truncateString}
54
+ {children}
55
55
  </Tooltip>
56
56
  )}
57
57
  </div>
@@ -25,7 +25,7 @@ describe('Truncate', () => {
25
25
 
26
26
  // Only way to test is by checking testid, validated this works in app
27
27
  it('shows truncated state when content overflows', () => {
28
- render(<Truncate truncateString="This is a very long text that should be truncated" />);
28
+ render(<Truncate>This is a very long text that should be truncated</Truncate>);
29
29
 
30
30
  // Now we can use exact IDs instead of regex
31
31
  expect(screen.getByTestId('truncate-test-id-truncated')).toBeInTheDocument();
@@ -42,7 +42,7 @@ describe('Truncate', () => {
42
42
  value: 200,
43
43
  });
44
44
 
45
- render(<Truncate truncateString="Short text" />);
45
+ render(<Truncate>Short text</Truncate>);
46
46
 
47
47
  // Now we can use exact IDs
48
48
  expect(screen.getByTestId('truncate-test-id-not-truncated')).toBeInTheDocument();
@@ -3,9 +3,8 @@ import { TooltipProps } from '../tooltip/Tooltip';
3
3
  export interface TruncateProps {
4
4
  /** The number of lines to truncate the text to. If left blank, it will default to 1 line. */
5
5
  numLines?: number;
6
- /** The string to truncate. This value will also be displayed in the tooltip when the text is truncated. */
7
- truncateString: string;
8
6
  /** The options for the tooltip. If `disabled` is `true`, the tooltip will not be shown. If left blank, the tooltip will be shown by default. This is particularly useful if you want to set the width of the tooltip to something other than the default `max-content`. */
9
7
  tooltipOptions?: Partial<TooltipProps> & { disabled?: boolean };
10
- [key: string]: any;
8
+ /** The children to display. This will be displayed in the truncate component. */
9
+ children: React.ReactNode;
11
10
  }