@indico-data/design-system 3.6.1 → 3.6.3
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/.vscode/settings.json +2 -1
- package/lib/components/tooltip/Tooltip.d.ts +11 -7
- package/lib/components/tooltip/Tooltip.stories.d.ts +2 -0
- package/lib/components/truncate/Truncate.d.ts +1 -1
- package/lib/components/truncate/Truncate.stories.d.ts +4 -1
- package/lib/components/truncate/types.d.ts +6 -5
- package/lib/index.css +6 -15
- package/lib/index.d.ts +15 -11
- package/lib/index.esm.css +6 -15
- package/lib/index.esm.js +25 -16
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +25 -16
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +76 -8
- package/src/components/tooltip/Tooltip.tsx +23 -7
- package/src/components/truncate/Truncate.mdx +16 -8
- package/src/components/truncate/Truncate.stories.tsx +44 -22
- package/src/components/truncate/Truncate.tsx +23 -18
- package/src/components/truncate/__tests__/Truncate.test.tsx +0 -11
- package/src/components/truncate/styles/Truncate.scss +12 -12
- package/src/components/truncate/types.ts +5 -5
- package/src/styles/globals.scss +0 -9
package/lib/index.js
CHANGED
|
@@ -43117,12 +43117,17 @@ const h="react-tooltip-core-styles",w="react-tooltip-base-styles",b={core:!1,bas
|
|
|
43117
43117
|
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"});}));
|
|
43118
43118
|
|
|
43119
43119
|
const Tooltip = (_a) => {
|
|
43120
|
-
var { id, clickToShow, delayShow, delayHide, children,
|
|
43120
|
+
var { id, clickToShow, delayShow, delayHide, children, place = 'top', width = 'max-content', maxWidth, opacity = 1, positionStrategy = 'absolute' } = _a, rest = __rest(_a, ["id", "clickToShow", "delayShow", "delayHide", "children", "place", "width", "maxWidth", "opacity", "positionStrategy"]);
|
|
43121
43121
|
return (jsxRuntime.jsx(M, Object.assign({ style: {
|
|
43122
43122
|
backgroundColor: 'var(--pf-semantic-background-inverted)',
|
|
43123
43123
|
color: 'var(--pf-semantic-font-inverted)',
|
|
43124
|
-
|
|
43125
|
-
|
|
43124
|
+
width,
|
|
43125
|
+
maxWidth,
|
|
43126
|
+
boxSizing: 'border-box',
|
|
43127
|
+
textWrap: 'wrap',
|
|
43128
|
+
wordWrap: 'break-word',
|
|
43129
|
+
zIndex: 1000,
|
|
43130
|
+
}, className: "tooltip", id: id, place: place, openOnClick: clickToShow, delayShow: delayShow, delayHide: delayHide, opacity: opacity, positionStrategy: positionStrategy }, rest, { children: children })));
|
|
43126
43131
|
};
|
|
43127
43132
|
|
|
43128
43133
|
function BarSpinner(_a) {
|
|
@@ -43258,29 +43263,33 @@ function v4(options, buf, offset) {
|
|
|
43258
43263
|
}
|
|
43259
43264
|
|
|
43260
43265
|
const Truncate = (_a) => {
|
|
43261
|
-
var {
|
|
43266
|
+
var { numLines = 1, truncateString, tooltipOptions = {} } = _a, rest = __rest(_a, ["numLines", "truncateString", "tooltipOptions"]);
|
|
43262
43267
|
const [isTruncated, setIsTruncated] = React.useState(false);
|
|
43263
|
-
const id = (
|
|
43268
|
+
const id = React.useMemo(() => v4().replace(/[^a-zA-Z0-9-_]/g, '_'), []);
|
|
43269
|
+
const ref = React.useRef(null);
|
|
43264
43270
|
React.useEffect(() => {
|
|
43265
43271
|
const checkTruncation = () => {
|
|
43266
|
-
const element =
|
|
43267
|
-
if (element)
|
|
43268
|
-
|
|
43269
|
-
|
|
43270
|
-
|
|
43271
|
-
|
|
43272
|
-
|
|
43273
|
-
|
|
43272
|
+
const element = ref.current;
|
|
43273
|
+
if (!element)
|
|
43274
|
+
return;
|
|
43275
|
+
if (numLines === 1) {
|
|
43276
|
+
setIsTruncated(element.scrollWidth > element.clientWidth);
|
|
43277
|
+
}
|
|
43278
|
+
else {
|
|
43279
|
+
setIsTruncated(element.scrollHeight > element.clientHeight);
|
|
43274
43280
|
}
|
|
43275
43281
|
};
|
|
43276
43282
|
checkTruncation();
|
|
43277
43283
|
window.addEventListener('resize', checkTruncation);
|
|
43278
43284
|
return () => window.removeEventListener('resize', checkTruncation);
|
|
43279
|
-
}, [id,
|
|
43285
|
+
}, [id, numLines]);
|
|
43280
43286
|
const truncateStyle = {
|
|
43281
|
-
'--line-clamp':
|
|
43287
|
+
'--line-clamp': numLines,
|
|
43282
43288
|
};
|
|
43283
|
-
return (jsxRuntime.jsxs("div", { className: "truncate-wrapper", style: truncateStyle, children: [jsxRuntime.jsx("span", Object.assign({ "data-testid": `truncate-${id}-${isTruncated ? 'truncated' : 'not-truncated'}`, "data-tooltip-id": id,
|
|
43289
|
+
return (jsxRuntime.jsxs("div", { className: "truncate-wrapper", style: truncateStyle, children: [jsxRuntime.jsx("span", Object.assign({ ref: ref, "data-testid": `truncate-${id}-${isTruncated ? 'truncated' : 'not-truncated'}`, "data-tooltip-id": id, className: classNames('truncate', {
|
|
43290
|
+
'truncate--multi-line': numLines > 1,
|
|
43291
|
+
'truncate--single-line': numLines === 1,
|
|
43292
|
+
}) }, rest, { children: truncateString })), isTruncated && truncateString && !tooltipOptions.disabled && (jsxRuntime.jsx(Tooltip, Object.assign({}, tooltipOptions, { id: id, children: truncateString })))] }));
|
|
43284
43293
|
};
|
|
43285
43294
|
|
|
43286
43295
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|