@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.
@@ -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 { PlacesType } from 'react-tooltip';
2
- interface TooltipProps {
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, zIndex, place, ...rest }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
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;
@@ -4,3 +4,5 @@ declare const meta: Meta;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof Tooltip>;
6
6
  export declare const Default: Story;
7
+ export declare const TooltipWithWidth: Story;
8
+ export declare const TooltipWithMaxWidth: Story;
@@ -1,2 +1,2 @@
1
1
  import { TruncateProps } from './types';
2
- export declare const Truncate: ({ lineClamp, truncateString, hasTooltip, tooltipId, ...rest }: TruncateProps) => import("react/jsx-runtime").JSX.Element;
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 WithLineClamp: Story;
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
- lineClamp?: number;
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
- /** Whether to show the tooltip. If left blank, it will default to true. If set to false, the tooltip will not be shown. */
7
- hasTooltip?: boolean;
8
- /** The id of the tooltip. If an ID is not provided, it will generate one from uuid */
9
- tooltipId?: string;
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
- white-space: nowrap;
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-clip {
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
- overflow: hidden;
9182
- text-overflow: ellipsis;
9183
- width: 100%;
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, zIndex, place, ...rest }: TooltipProps) => react_jsx_runtime.JSX.Element;
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
- lineClamp?: number;
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
- /** Whether to show the tooltip. If left blank, it will default to true. If set to false, the tooltip will not be shown. */
1027
- hasTooltip?: boolean;
1028
- /** The id of the tooltip. If an ID is not provided, it will generate one from uuid */
1029
- tooltipId?: string;
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: ({ lineClamp, truncateString, hasTooltip, tooltipId, ...rest }: TruncateProps) => react_jsx_runtime.JSX.Element;
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
- white-space: nowrap;
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-clip {
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
- overflow: hidden;
9182
- text-overflow: ellipsis;
9183
- width: 100%;
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, zIndex = 1000, place = 'top' } = _a, rest = __rest(_a, ["id", "clickToShow", "delayShow", "delayHide", "children", "zIndex", "place"]);
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
- zIndex,
43100
- }, id: id, place: place, openOnClick: clickToShow, delayShow: delayShow, delayHide: delayHide }, rest, { children: children })));
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 { lineClamp = 0, truncateString, hasTooltip = true, tooltipId } = _a, rest = __rest(_a, ["lineClamp", "truncateString", "hasTooltip", "tooltipId"]);
43241
+ var { numLines = 1, truncateString, tooltipOptions = {} } = _a, rest = __rest(_a, ["numLines", "truncateString", "tooltipOptions"]);
43237
43242
  const [isTruncated, setIsTruncated] = useState(false);
43238
- const id = (tooltipId !== null && tooltipId !== void 0 ? tooltipId : v4()).replace(/[^a-zA-Z0-9-_]/g, '_');
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 = document.querySelector(`[data-tooltip-id="${id}"]`);
43242
- if (element) {
43243
- if (lineClamp === 0) {
43244
- setIsTruncated(element.scrollWidth > element.clientWidth);
43245
- }
43246
- else {
43247
- setIsTruncated(element.scrollHeight > element.clientHeight);
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, lineClamp]);
43260
+ }, [id, numLines]);
43255
43261
  const truncateStyle = {
43256
- '--line-clamp': lineClamp,
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, "data-tooltip-content": isTruncated ? truncateString : undefined, className: lineClamp > 0 ? 'truncate-clip' : 'truncate' }, rest, { children: truncateString })), isTruncated && truncateString && hasTooltip && (jsx(Tooltip, { "data-tooltip-delay-hide": 0, id: id, children: truncateString }))] }));
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}