@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/.vscode/settings.json
CHANGED
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
"eslint.nodePath": ".yarn/sdks",
|
|
7
7
|
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
|
|
8
8
|
"typescript.tsdk": ".yarn/sdks/typescript/lib",
|
|
9
|
-
"typescript.enablePromptUseWorkspaceTsdk": true
|
|
9
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
10
|
+
"testing.automaticallyOpenTestResults": "neverOpen"
|
|
10
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { PlacesType, PositionStrategy } from 'react-tooltip';
|
|
3
|
+
export interface TooltipProps {
|
|
3
4
|
id: string;
|
|
4
5
|
/** Whether the tooltip should be shown on click */
|
|
5
6
|
clickToShow?: boolean;
|
|
@@ -7,13 +8,16 @@ interface TooltipProps {
|
|
|
7
8
|
delayShow?: number;
|
|
8
9
|
/** The delay in milliseconds before the tooltip is hidden */
|
|
9
10
|
delayHide?: number;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
/** This is an override for the z-index of the tooltip */
|
|
12
|
-
zIndex?: number;
|
|
13
11
|
/** The placement of the tooltip */
|
|
14
12
|
place?: PlacesType;
|
|
13
|
+
/** The width of the tooltip */
|
|
14
|
+
width?: CSSProperties['width'];
|
|
15
|
+
/** The max width of the tooltip */
|
|
16
|
+
maxWidth?: CSSProperties['maxWidth'];
|
|
17
|
+
/** The position strategy of the tooltip */
|
|
18
|
+
positionStrategy?: PositionStrategy;
|
|
15
19
|
/** The content of the tooltip */
|
|
20
|
+
children: React.ReactNode;
|
|
16
21
|
[key: string]: any;
|
|
17
22
|
}
|
|
18
|
-
export declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children,
|
|
19
|
-
export {};
|
|
23
|
+
export declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, place, width, maxWidth, opacity, positionStrategy, ...rest }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TruncateProps } from './types';
|
|
2
|
-
export declare const Truncate: ({
|
|
2
|
+
export declare const Truncate: ({ numLines, truncateString, tooltipOptions, ...rest }: TruncateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,5 +5,8 @@ declare const meta: Meta<typeof Truncate>;
|
|
|
5
5
|
export default meta;
|
|
6
6
|
type Story = StoryObj<TruncateProps>;
|
|
7
7
|
export declare const Default: Story;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const NoTruncate: Story;
|
|
9
|
+
export declare const WithNumLines: Story;
|
|
10
|
+
export declare const WithTooltipOptions: Story;
|
|
9
11
|
export declare const NoTooltip: Story;
|
|
12
|
+
export declare const TruncateWithTooltipWidth: Story;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { TooltipProps } from '../tooltip/Tooltip';
|
|
1
2
|
export interface TruncateProps {
|
|
2
3
|
/** The number of lines to truncate the text to. If left blank, it will default to 1 line. */
|
|
3
|
-
|
|
4
|
+
numLines?: number;
|
|
4
5
|
/** The string to truncate. This value will also be displayed in the tooltip when the text is truncated. */
|
|
5
6
|
truncateString: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/** 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`. */
|
|
8
|
+
tooltipOptions?: Partial<TooltipProps> & {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
}
|
package/lib/index.css
CHANGED
|
@@ -4486,14 +4486,6 @@ a:hover,
|
|
|
4486
4486
|
background-color: var(--pf-semantic-background-primary);
|
|
4487
4487
|
}
|
|
4488
4488
|
|
|
4489
|
-
.react-tooltip {
|
|
4490
|
-
z-index: 5;
|
|
4491
|
-
background-color: var(--pf-semantic-background-inverted);
|
|
4492
|
-
color: var(--pf-semantic-font-inverted);
|
|
4493
|
-
opacity: 1 !important;
|
|
4494
|
-
text-wrap: wrap;
|
|
4495
|
-
}
|
|
4496
|
-
|
|
4497
4489
|
:root,
|
|
4498
4490
|
:root [data-theme=light],
|
|
4499
4491
|
:root [data-theme=dark] {
|
|
@@ -9167,20 +9159,19 @@ body div[class*=select__single-value] {
|
|
|
9167
9159
|
color: inherit;
|
|
9168
9160
|
}
|
|
9169
9161
|
.truncate-wrapper .truncate {
|
|
9170
|
-
|
|
9162
|
+
width: 100%;
|
|
9171
9163
|
overflow: hidden;
|
|
9172
9164
|
text-overflow: ellipsis;
|
|
9173
|
-
width: 100%;
|
|
9174
|
-
display: inline-block;
|
|
9175
9165
|
}
|
|
9176
|
-
.truncate-wrapper .truncate-
|
|
9166
|
+
.truncate-wrapper .truncate--multi-line {
|
|
9177
9167
|
display: -webkit-box;
|
|
9178
9168
|
-webkit-box-orient: vertical;
|
|
9179
9169
|
-webkit-line-clamp: var(--line-clamp);
|
|
9180
9170
|
line-clamp: var(--line-clamp);
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9171
|
+
}
|
|
9172
|
+
.truncate-wrapper .truncate--single-line {
|
|
9173
|
+
display: inline-block;
|
|
9174
|
+
white-space: nowrap;
|
|
9184
9175
|
}
|
|
9185
9176
|
|
|
9186
9177
|
.Toastify__toast-theme--colored.Toastify__toast--default {
|
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { DateRange, OnSelectHandler, Mode, CustomComponents, Matcher, Formatters
|
|
|
11
11
|
export { DateRange } from 'react-day-picker';
|
|
12
12
|
import { ColumnDef, Row as Row$1, SortingState } from '@tanstack/react-table';
|
|
13
13
|
export { ColumnDef, SortingFn, SortingState, Column as TanstackTableColumnType, Row as TanstackTableRowType, Table as TanstackTableType, flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
|
14
|
-
import { PlacesType } from 'react-tooltip';
|
|
14
|
+
import { PlacesType, PositionStrategy } from 'react-tooltip';
|
|
15
15
|
export { ToastContainer, toast } from 'react-toastify';
|
|
16
16
|
|
|
17
17
|
declare const registerFontAwesomeIcons: (...icons: IconDefinition[]) => void;
|
|
@@ -943,15 +943,19 @@ interface TooltipProps {
|
|
|
943
943
|
delayShow?: number;
|
|
944
944
|
/** The delay in milliseconds before the tooltip is hidden */
|
|
945
945
|
delayHide?: number;
|
|
946
|
-
children: React.ReactNode;
|
|
947
|
-
/** This is an override for the z-index of the tooltip */
|
|
948
|
-
zIndex?: number;
|
|
949
946
|
/** The placement of the tooltip */
|
|
950
947
|
place?: PlacesType;
|
|
948
|
+
/** The width of the tooltip */
|
|
949
|
+
width?: CSSProperties['width'];
|
|
950
|
+
/** The max width of the tooltip */
|
|
951
|
+
maxWidth?: CSSProperties['maxWidth'];
|
|
952
|
+
/** The position strategy of the tooltip */
|
|
953
|
+
positionStrategy?: PositionStrategy;
|
|
951
954
|
/** The content of the tooltip */
|
|
955
|
+
children: React.ReactNode;
|
|
952
956
|
[key: string]: any;
|
|
953
957
|
}
|
|
954
|
-
declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children,
|
|
958
|
+
declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, place, width, maxWidth, opacity, positionStrategy, ...rest }: TooltipProps) => react_jsx_runtime.JSX.Element;
|
|
955
959
|
|
|
956
960
|
interface PaginationProps {
|
|
957
961
|
/** The total number of pages to be displayed */
|
|
@@ -1020,16 +1024,16 @@ declare const Stepper: ({ currentStep: externalCurrentStep, legendHeader, legend
|
|
|
1020
1024
|
|
|
1021
1025
|
interface TruncateProps {
|
|
1022
1026
|
/** The number of lines to truncate the text to. If left blank, it will default to 1 line. */
|
|
1023
|
-
|
|
1027
|
+
numLines?: number;
|
|
1024
1028
|
/** The string to truncate. This value will also be displayed in the tooltip when the text is truncated. */
|
|
1025
1029
|
truncateString: string;
|
|
1026
|
-
/**
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
+
/** 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`. */
|
|
1031
|
+
tooltipOptions?: Partial<TooltipProps> & {
|
|
1032
|
+
disabled?: boolean;
|
|
1033
|
+
};
|
|
1030
1034
|
[key: string]: any;
|
|
1031
1035
|
}
|
|
1032
1036
|
|
|
1033
|
-
declare const Truncate: ({
|
|
1037
|
+
declare const Truncate: ({ numLines, truncateString, tooltipOptions, ...rest }: TruncateProps) => react_jsx_runtime.JSX.Element;
|
|
1034
1038
|
|
|
1035
1039
|
export { Badge, BarSpinner, Button, Card, Checkbox, CirclePulse, Col, ConfirmationModal, Container, DatePicker, FloatUI, Form, Icon, IconTriggerDatePicker, LabeledInput as Input, InputDateRangePicker, Menu, Modal, Pagination, LabeledPasswordInput as PasswordInput, Pill, Radio as RadioInput, Row, LabeledSelect as SelectInput, type SelectOption, SingleInputDatePicker, SingleInputDateTimePicker, Skeleton, Stepper, Table, TanstackTable, LabeledTextarea as Textarea, TimePicker, Toggle as ToggleInput, Tooltip, Truncate, registerFontAwesomeIcons };
|
package/lib/index.esm.css
CHANGED
|
@@ -4486,14 +4486,6 @@ a:hover,
|
|
|
4486
4486
|
background-color: var(--pf-semantic-background-primary);
|
|
4487
4487
|
}
|
|
4488
4488
|
|
|
4489
|
-
.react-tooltip {
|
|
4490
|
-
z-index: 5;
|
|
4491
|
-
background-color: var(--pf-semantic-background-inverted);
|
|
4492
|
-
color: var(--pf-semantic-font-inverted);
|
|
4493
|
-
opacity: 1 !important;
|
|
4494
|
-
text-wrap: wrap;
|
|
4495
|
-
}
|
|
4496
|
-
|
|
4497
4489
|
:root,
|
|
4498
4490
|
:root [data-theme=light],
|
|
4499
4491
|
:root [data-theme=dark] {
|
|
@@ -9167,20 +9159,19 @@ body div[class*=select__single-value] {
|
|
|
9167
9159
|
color: inherit;
|
|
9168
9160
|
}
|
|
9169
9161
|
.truncate-wrapper .truncate {
|
|
9170
|
-
|
|
9162
|
+
width: 100%;
|
|
9171
9163
|
overflow: hidden;
|
|
9172
9164
|
text-overflow: ellipsis;
|
|
9173
|
-
width: 100%;
|
|
9174
|
-
display: inline-block;
|
|
9175
9165
|
}
|
|
9176
|
-
.truncate-wrapper .truncate-
|
|
9166
|
+
.truncate-wrapper .truncate--multi-line {
|
|
9177
9167
|
display: -webkit-box;
|
|
9178
9168
|
-webkit-box-orient: vertical;
|
|
9179
9169
|
-webkit-line-clamp: var(--line-clamp);
|
|
9180
9170
|
line-clamp: var(--line-clamp);
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9171
|
+
}
|
|
9172
|
+
.truncate-wrapper .truncate--single-line {
|
|
9173
|
+
display: inline-block;
|
|
9174
|
+
white-space: nowrap;
|
|
9184
9175
|
}
|
|
9185
9176
|
|
|
9186
9177
|
.Toastify__toast-theme--colored.Toastify__toast--default {
|
package/lib/index.esm.js
CHANGED
|
@@ -43092,12 +43092,17 @@ const h="react-tooltip-core-styles",w="react-tooltip-base-styles",b={core:!1,bas
|
|
|
43092
43092
|
.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"});}));
|
|
43093
43093
|
|
|
43094
43094
|
const Tooltip = (_a) => {
|
|
43095
|
-
var { id, clickToShow, delayShow, delayHide, children,
|
|
43095
|
+
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"]);
|
|
43096
43096
|
return (jsx(M, Object.assign({ style: {
|
|
43097
43097
|
backgroundColor: 'var(--pf-semantic-background-inverted)',
|
|
43098
43098
|
color: 'var(--pf-semantic-font-inverted)',
|
|
43099
|
-
|
|
43100
|
-
|
|
43099
|
+
width,
|
|
43100
|
+
maxWidth,
|
|
43101
|
+
boxSizing: 'border-box',
|
|
43102
|
+
textWrap: 'wrap',
|
|
43103
|
+
wordWrap: 'break-word',
|
|
43104
|
+
zIndex: 1000,
|
|
43105
|
+
}, className: "tooltip", id: id, place: place, openOnClick: clickToShow, delayShow: delayShow, delayHide: delayHide, opacity: opacity, positionStrategy: positionStrategy }, rest, { children: children })));
|
|
43101
43106
|
};
|
|
43102
43107
|
|
|
43103
43108
|
function BarSpinner(_a) {
|
|
@@ -43233,29 +43238,33 @@ function v4(options, buf, offset) {
|
|
|
43233
43238
|
}
|
|
43234
43239
|
|
|
43235
43240
|
const Truncate = (_a) => {
|
|
43236
|
-
var {
|
|
43241
|
+
var { numLines = 1, truncateString, tooltipOptions = {} } = _a, rest = __rest(_a, ["numLines", "truncateString", "tooltipOptions"]);
|
|
43237
43242
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
43238
|
-
const id = (
|
|
43243
|
+
const id = useMemo(() => v4().replace(/[^a-zA-Z0-9-_]/g, '_'), []);
|
|
43244
|
+
const ref = useRef(null);
|
|
43239
43245
|
useEffect(() => {
|
|
43240
43246
|
const checkTruncation = () => {
|
|
43241
|
-
const element =
|
|
43242
|
-
if (element)
|
|
43243
|
-
|
|
43244
|
-
|
|
43245
|
-
|
|
43246
|
-
|
|
43247
|
-
|
|
43248
|
-
|
|
43247
|
+
const element = ref.current;
|
|
43248
|
+
if (!element)
|
|
43249
|
+
return;
|
|
43250
|
+
if (numLines === 1) {
|
|
43251
|
+
setIsTruncated(element.scrollWidth > element.clientWidth);
|
|
43252
|
+
}
|
|
43253
|
+
else {
|
|
43254
|
+
setIsTruncated(element.scrollHeight > element.clientHeight);
|
|
43249
43255
|
}
|
|
43250
43256
|
};
|
|
43251
43257
|
checkTruncation();
|
|
43252
43258
|
window.addEventListener('resize', checkTruncation);
|
|
43253
43259
|
return () => window.removeEventListener('resize', checkTruncation);
|
|
43254
|
-
}, [id,
|
|
43260
|
+
}, [id, numLines]);
|
|
43255
43261
|
const truncateStyle = {
|
|
43256
|
-
'--line-clamp':
|
|
43262
|
+
'--line-clamp': numLines,
|
|
43257
43263
|
};
|
|
43258
|
-
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,
|
|
43264
|
+
return (jsxs("div", { className: "truncate-wrapper", style: truncateStyle, children: [jsx("span", Object.assign({ ref: ref, "data-testid": `truncate-${id}-${isTruncated ? 'truncated' : 'not-truncated'}`, "data-tooltip-id": id, className: classNames('truncate', {
|
|
43265
|
+
'truncate--multi-line': numLines > 1,
|
|
43266
|
+
'truncate--single-line': numLines === 1,
|
|
43267
|
+
}) }, rest, { children: truncateString })), isTruncated && truncateString && !tooltipOptions.disabled && (jsx(Tooltip, Object.assign({}, tooltipOptions, { id: id, children: truncateString })))] }));
|
|
43259
43268
|
};
|
|
43260
43269
|
|
|
43261
43270
|
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}
|