@indico-data/design-system 2.56.0 → 2.57.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.
- package/lib/components/index.d.ts +1 -0
- package/lib/components/truncate/Truncate.d.ts +2 -0
- package/lib/components/truncate/Truncate.stories.d.ts +9 -0
- package/lib/components/truncate/__tests__/Truncate.test.d.ts +1 -0
- package/lib/components/truncate/index.d.ts +1 -0
- package/lib/components/truncate/types.d.ts +7 -0
- package/lib/index.css +21 -0
- package/lib/index.d.ts +11 -1
- package/lib/index.esm.css +21 -0
- package/lib/index.esm.js +53 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +53 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/index.ts +1 -0
- package/src/components/truncate/Truncate.mdx +34 -0
- package/src/components/truncate/Truncate.stories.tsx +86 -0
- package/src/components/truncate/Truncate.tsx +55 -0
- package/src/components/truncate/__tests__/Truncate.test.tsx +61 -0
- package/src/components/truncate/index.ts +1 -0
- package/src/components/truncate/styles/Truncate.scss +22 -0
- package/src/components/truncate/types.ts +7 -0
- package/src/index.ts +1 -1
- package/src/styles/index.scss +1 -0
|
@@ -25,3 +25,4 @@ export { TanstackTable } from './tanstackTable';
|
|
|
25
25
|
export { Tooltip } from './tooltip';
|
|
26
26
|
export { BarSpinner } from './loading-indicators/BarSpinner/BarSpinner';
|
|
27
27
|
export { CirclePulse } from './loading-indicators/CirclePulse/CirclePulse';
|
|
28
|
+
export { Truncate } from './truncate';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Truncate } from './Truncate';
|
|
3
|
+
import { TruncateProps } from './types';
|
|
4
|
+
declare const meta: Meta<typeof Truncate>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<TruncateProps>;
|
|
7
|
+
export declare const Default: Story;
|
|
8
|
+
export declare const WithLineClamp: Story;
|
|
9
|
+
export declare const NoTooltip: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Truncate } from './Truncate';
|
package/lib/index.css
CHANGED
|
@@ -2637,6 +2637,27 @@ form {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
2639
|
|
|
2640
|
+
.truncate-wrapper {
|
|
2641
|
+
width: 100%;
|
|
2642
|
+
display: block;
|
|
2643
|
+
}
|
|
2644
|
+
.truncate-wrapper .truncate {
|
|
2645
|
+
white-space: nowrap;
|
|
2646
|
+
overflow: hidden;
|
|
2647
|
+
text-overflow: ellipsis;
|
|
2648
|
+
width: 100%;
|
|
2649
|
+
display: inline-block;
|
|
2650
|
+
}
|
|
2651
|
+
.truncate-wrapper .truncate-clip {
|
|
2652
|
+
display: -webkit-box;
|
|
2653
|
+
-webkit-box-orient: vertical;
|
|
2654
|
+
-webkit-line-clamp: var(--line-clamp);
|
|
2655
|
+
line-clamp: var(--line-clamp);
|
|
2656
|
+
overflow: hidden;
|
|
2657
|
+
text-overflow: ellipsis;
|
|
2658
|
+
width: 100%;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2640
2661
|
:root [data-theme=light] {
|
|
2641
2662
|
--sheets-background-color: var(--pf-gray-color-100);
|
|
2642
2663
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -617,4 +617,14 @@ declare function BarSpinner({ width, id, height, className, ...rest }: {
|
|
|
617
617
|
[key: string]: any;
|
|
618
618
|
}): react_jsx_runtime.JSX.Element;
|
|
619
619
|
|
|
620
|
-
|
|
620
|
+
interface TruncateProps {
|
|
621
|
+
lineClamp?: number;
|
|
622
|
+
truncateString: string;
|
|
623
|
+
hasTooltip?: boolean;
|
|
624
|
+
tooltipId?: string;
|
|
625
|
+
[key: string]: any;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
declare const Truncate: ({ lineClamp, truncateString, hasTooltip, tooltipId, ...rest }: TruncateProps) => react_jsx_runtime.JSX.Element;
|
|
629
|
+
|
|
630
|
+
export { Badge, BarSpinner, Button, Card, Checkbox, CirclePulse, Col, Container, DatePicker, FloatUI, Form, Icon, IconTriggerDatePicker, LabeledInput as Input, Menu, Modal, Pagination, LabeledPasswordInput as PasswordInput, Pill, Radio as RadioInput, Row, Select as SelectInput, SingleInputDatePicker, Skeleton, Table, TanstackTable, LabeledTextarea as Textarea, TimePicker, Toggle as ToggleInput, Tooltip, Truncate, registerFontAwesomeIcons };
|
package/lib/index.esm.css
CHANGED
|
@@ -2637,6 +2637,27 @@ form {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
2639
|
|
|
2640
|
+
.truncate-wrapper {
|
|
2641
|
+
width: 100%;
|
|
2642
|
+
display: block;
|
|
2643
|
+
}
|
|
2644
|
+
.truncate-wrapper .truncate {
|
|
2645
|
+
white-space: nowrap;
|
|
2646
|
+
overflow: hidden;
|
|
2647
|
+
text-overflow: ellipsis;
|
|
2648
|
+
width: 100%;
|
|
2649
|
+
display: inline-block;
|
|
2650
|
+
}
|
|
2651
|
+
.truncate-wrapper .truncate-clip {
|
|
2652
|
+
display: -webkit-box;
|
|
2653
|
+
-webkit-box-orient: vertical;
|
|
2654
|
+
-webkit-line-clamp: var(--line-clamp);
|
|
2655
|
+
line-clamp: var(--line-clamp);
|
|
2656
|
+
overflow: hidden;
|
|
2657
|
+
text-overflow: ellipsis;
|
|
2658
|
+
width: 100%;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2640
2661
|
:root [data-theme=light] {
|
|
2641
2662
|
--sheets-background-color: var(--pf-gray-color-100);
|
|
2642
2663
|
}
|
package/lib/index.esm.js
CHANGED
|
@@ -8,6 +8,7 @@ import ReactDOM__default from 'react-dom';
|
|
|
8
8
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
9
9
|
import n, { css, ThemeProvider } from 'styled-components';
|
|
10
10
|
import ReactSelect, { components as components$1 } from 'react-select';
|
|
11
|
+
import { webcrypto } from 'node:crypto';
|
|
11
12
|
|
|
12
13
|
const indicons = {
|
|
13
14
|
'indico-o-white': (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 100 100", children: jsx("path", { d: "M100 50c0 27.6-22.4 50-50 50S0 77.6 0 50 22.4 0 50 0s50 22.4 50 50zM50 19.4c-16.9 0-30.6 13.7-30.6 30.6S33.1 80.6 50 80.6 80.6 66.9 80.6 50 66.9 19.4 50 19.4zm0 21.7c-4.9 0-8.9 4-8.9 8.9s4 8.9 8.9 8.9 8.9-4 8.9-8.9-4-8.9-8.9-8.9z" }) })),
|
|
@@ -42874,5 +42875,56 @@ function BarSpinner(_a) {
|
|
|
42874
42875
|
return (jsx("div", Object.assign({ className: `bar-spinner ${className}`, id: id, style: style }, rest, { children: jsx("span", {}) })));
|
|
42875
42876
|
}
|
|
42876
42877
|
|
|
42877
|
-
|
|
42878
|
+
const urlAlphabet =
|
|
42879
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
42880
|
+
|
|
42881
|
+
const POOL_SIZE_MULTIPLIER = 128;
|
|
42882
|
+
let pool, poolOffset;
|
|
42883
|
+
function fillPool(bytes) {
|
|
42884
|
+
if (!pool || pool.length < bytes) {
|
|
42885
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
42886
|
+
webcrypto.getRandomValues(pool);
|
|
42887
|
+
poolOffset = 0;
|
|
42888
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
42889
|
+
webcrypto.getRandomValues(pool);
|
|
42890
|
+
poolOffset = 0;
|
|
42891
|
+
}
|
|
42892
|
+
poolOffset += bytes;
|
|
42893
|
+
}
|
|
42894
|
+
function nanoid(size = 21) {
|
|
42895
|
+
fillPool((size |= 0));
|
|
42896
|
+
let id = '';
|
|
42897
|
+
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
42898
|
+
id += urlAlphabet[pool[i] & 63];
|
|
42899
|
+
}
|
|
42900
|
+
return id
|
|
42901
|
+
}
|
|
42902
|
+
|
|
42903
|
+
const Truncate = (_a) => {
|
|
42904
|
+
var { lineClamp = 0, truncateString, hasTooltip = true, tooltipId } = _a, rest = __rest(_a, ["lineClamp", "truncateString", "hasTooltip", "tooltipId"]);
|
|
42905
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
42906
|
+
const id = (tooltipId !== null && tooltipId !== void 0 ? tooltipId : nanoid()).replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
42907
|
+
useEffect(() => {
|
|
42908
|
+
const checkTruncation = () => {
|
|
42909
|
+
const element = document.querySelector(`[data-tooltip-id="${id}"]`);
|
|
42910
|
+
if (element) {
|
|
42911
|
+
if (lineClamp === 0) {
|
|
42912
|
+
setIsTruncated(element.scrollWidth > element.clientWidth);
|
|
42913
|
+
}
|
|
42914
|
+
else {
|
|
42915
|
+
setIsTruncated(element.scrollHeight > element.clientHeight);
|
|
42916
|
+
}
|
|
42917
|
+
}
|
|
42918
|
+
};
|
|
42919
|
+
checkTruncation();
|
|
42920
|
+
window.addEventListener('resize', checkTruncation);
|
|
42921
|
+
return () => window.removeEventListener('resize', checkTruncation);
|
|
42922
|
+
}, [id, lineClamp]);
|
|
42923
|
+
const truncateStyle = {
|
|
42924
|
+
'--line-clamp': lineClamp,
|
|
42925
|
+
};
|
|
42926
|
+
return (jsxs("div", { className: "truncate-wrapper", style: truncateStyle, children: [jsx("span", Object.assign({ "data-testid": `truncate-${id}-${isTruncated ? 'truncated' : 'not-truncated'}`, "data-tooltip-id": id, "data-tooltip-content": isTruncated ? truncateString : undefined, className: lineClamp > 0 ? 'truncate-clip' : 'truncate' }, rest, { children: truncateString })), isTruncated && truncateString && hasTooltip && (jsx(Tooltip, { "data-tooltip-delay-hide": 100, id: id, border: "solid 1px var(--pf-border-color)", children: truncateString }))] }));
|
|
42927
|
+
};
|
|
42928
|
+
|
|
42929
|
+
export { Badge, BarSpinner, Button$1 as Button, Card, Checkbox, CirclePulse, Col, Container, DatePicker, FloatUI, Form, Icon, IconTriggerDatePicker, LabeledInput as Input, Menu, Modal, Pagination, LabeledPasswordInput as PasswordInput, Pill, Radio as RadioInput, Row, Select$1 as SelectInput, SingleInputDatePicker, Skeleton, Table, TanstackTable, LabeledTextarea as Textarea, TimePicker, Toggle as ToggleInput, Tooltip, Truncate, arrow$2 as arrow, autoPlacement, autoUpdate$1 as autoUpdate, computePosition$2 as computePosition, detectOverflow$1 as detectOverflow, flip$2 as flip, getOverflowAncestors$1 as getOverflowAncestors, hide$1 as hide, inline, limitShift, offset$2 as offset, platform$1 as platform, registerFontAwesomeIcons, shift$2 as shift, size, useFloating$1 as useFloating };
|
|
42878
42930
|
//# sourceMappingURL=index.esm.js.map
|