@indico-data/design-system 2.58.1 → 2.58.2
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/index.esm.js +50 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +50 -21
- package/lib/index.js.map +1 -1
- package/package.json +1 -2
- package/src/components/truncate/Truncate.stories.tsx +1 -1
- package/src/components/truncate/Truncate.tsx +2 -3
- package/src/components/truncate/__tests__/Truncate.test.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indico-data/design-system",
|
|
3
|
-
"version": "2.58.
|
|
3
|
+
"version": "2.58.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"date-fns": "^3.6.0",
|
|
46
46
|
"focus-trap-react": "^10.2.3",
|
|
47
47
|
"html-webpack-plugin": "^5.6.0",
|
|
48
|
-
"nanoid": "^5.1.5",
|
|
49
48
|
"prop-types": "^15.8.1",
|
|
50
49
|
"react-aria-components": "^1.2.1",
|
|
51
50
|
"react-data-table-component": "^7.6.2",
|
|
@@ -34,7 +34,7 @@ const meta: Meta<typeof Truncate> = {
|
|
|
34
34
|
tooltipId: {
|
|
35
35
|
control: 'text',
|
|
36
36
|
description:
|
|
37
|
-
'The id of the tooltip. If an ID is not provided, it will generate one from
|
|
37
|
+
'The id of the tooltip. If an ID is not provided, it will generate one from uuid',
|
|
38
38
|
table: {
|
|
39
39
|
category: 'Props',
|
|
40
40
|
},
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { nanoid } from 'nanoid';
|
|
2
1
|
import { useState, useEffect, CSSProperties } from 'react';
|
|
3
2
|
import { Tooltip } from '../tooltip';
|
|
4
3
|
import { TruncateProps } from './types';
|
|
5
|
-
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
5
|
export const Truncate = ({
|
|
7
6
|
lineClamp = 0,
|
|
8
7
|
truncateString,
|
|
@@ -11,7 +10,7 @@ export const Truncate = ({
|
|
|
11
10
|
...rest
|
|
12
11
|
}: TruncateProps) => {
|
|
13
12
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
14
|
-
const id = (tooltipId ??
|
|
13
|
+
const id = (tooltipId ?? uuidv4()).replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
15
14
|
|
|
16
15
|
useEffect(() => {
|
|
17
16
|
const checkTruncation = () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import { Truncate } from '../Truncate';
|
|
3
3
|
|
|
4
|
-
// Mock
|
|
5
|
-
jest.mock('
|
|
6
|
-
|
|
4
|
+
// Mock uuid to return a predictable ID
|
|
5
|
+
jest.mock('uuid', () => ({
|
|
6
|
+
v4: () => 'test-id',
|
|
7
7
|
}));
|
|
8
8
|
|
|
9
9
|
describe('Truncate', () => {
|