@scality/core-ui 0.160.0 → 0.161.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constrainedtext.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/constrainedtext/Constrainedtext.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"Constrainedtext.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/constrainedtext/Constrainedtext.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGrE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACpD,YAAY,CAAC,EAAE,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC3D,gBAAgB,CAAC,EAAE,aAAa,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAiDF,iBAAS,eAAe,CAAC,EACvB,IAAI,EACJ,YAAY,EACZ,gBAAgB,EAChB,SAAa,GACd,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA2BrB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
5
|
+
import { Text } from '../text/Text.component';
|
|
5
6
|
// for lineClamp cf https://css-tricks.com/almanac/properties/l/line-clamp/
|
|
6
7
|
// it should work on all major navigator, despite the --webkit prefix
|
|
7
8
|
// just in case if we don't use line clamp we can just use the classic way
|
|
@@ -41,6 +42,6 @@ function ConstrainedText({ text, tooltipStyle, tooltipPlacement, lineClamp = 1,
|
|
|
41
42
|
const constrainedTextRef = useCallback((element) => {
|
|
42
43
|
element && text && setDisplayToolTip(isEllipsisActive(element));
|
|
43
44
|
}, [text]);
|
|
44
|
-
return (_jsx(BlockTooltip, { children: displayToolTip ? (_jsx(Tooltip, { overlay: text, overlayStyle: tooltipStyle, placement: tooltipPlacement, children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text) })) : (getConstrainedTextContainer(constrainedTextRef, lineClamp, text)) }));
|
|
45
|
+
return (_jsx(BlockTooltip, { children: displayToolTip ? (_jsx(Tooltip, { overlay: text, overlayStyle: tooltipStyle, placement: tooltipPlacement, children: _jsx(Text, { children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text) }) })) : (_jsx(Text, { children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text) })) }));
|
|
45
46
|
}
|
|
46
47
|
export { ConstrainedText };
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import styled from 'styled-components';
|
|
|
5
5
|
|
|
6
6
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
7
7
|
import { Props as TooltipProps } from '../tooltip/Tooltip.component';
|
|
8
|
+
import { Text } from '../text/Text.component';
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
text: string | number | JSX.Element | JSX.Element[];
|
|
@@ -81,10 +82,14 @@ function ConstrainedText({
|
|
|
81
82
|
overlayStyle={tooltipStyle}
|
|
82
83
|
placement={tooltipPlacement}
|
|
83
84
|
>
|
|
84
|
-
|
|
85
|
+
<Text>
|
|
86
|
+
{getConstrainedTextContainer(constrainedTextRef, lineClamp, text)}
|
|
87
|
+
</Text>
|
|
85
88
|
</Tooltip>
|
|
86
89
|
) : (
|
|
87
|
-
|
|
90
|
+
<Text>
|
|
91
|
+
{getConstrainedTextContainer(constrainedTextRef, lineClamp, text)}
|
|
92
|
+
</Text>
|
|
88
93
|
)}
|
|
89
94
|
</BlockTooltip>
|
|
90
95
|
);
|