@indico-data/design-system 3.6.0 → 3.6.2

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 { CSSProperties } from 'react';
1
2
  import { PlacesType } from 'react-tooltip';
2
- interface TooltipProps {
3
+ export interface TooltipProps {
3
4
  id: string;
4
5
  /** Whether the tooltip should be shown on click */
5
6
  clickToShow?: boolean;
@@ -8,12 +9,13 @@ interface TooltipProps {
8
9
  /** The delay in milliseconds before the tooltip is hidden */
9
10
  delayHide?: number;
10
11
  children: React.ReactNode;
11
- /** This is an override for the z-index of the tooltip */
12
- zIndex?: number;
13
12
  /** The placement of the tooltip */
14
13
  place?: PlacesType;
14
+ /** The width of the tooltip */
15
+ width?: CSSProperties['width'];
16
+ /** The max width of the tooltip */
17
+ maxWidth?: CSSProperties['maxWidth'];
15
18
  /** The content of the tooltip */
16
19
  [key: string]: any;
17
20
  }
18
- export declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, zIndex, place, ...rest }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
19
- export {};
21
+ export declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, place, width, maxWidth, opacity, ...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
@@ -405,6 +405,7 @@
405
405
  --pf-font-size-10xl: 6rem; /* 96px */
406
406
  }
407
407
 
408
+ :root,
408
409
  :root [data-theme=light] {
409
410
  --pf-semantic-utility-info-default: var(--pf-secondary-color-450);
410
411
  --pf-semantic-utility-info-light: var(--pf-secondary-color-400);
@@ -4485,14 +4486,6 @@ a:hover,
4485
4486
  background-color: var(--pf-semantic-background-primary);
4486
4487
  }
4487
4488
 
4488
- .react-tooltip {
4489
- z-index: 5;
4490
- background-color: var(--pf-semantic-background-inverted);
4491
- color: var(--pf-semantic-font-inverted);
4492
- opacity: 1 !important;
4493
- text-wrap: wrap;
4494
- }
4495
-
4496
4489
  :root,
4497
4490
  :root [data-theme=light],
4498
4491
  :root [data-theme=dark] {
@@ -6139,7 +6132,7 @@ body div[class*=select__single-value] {
6139
6132
  background: var(--pf-semantic-background-accent) !important;
6140
6133
  }
6141
6134
  .tanstack-table__tbody__tr.show-hover:hover td {
6142
- background-color: var(--pf-semantic-border-hover) !important;
6135
+ background-color: var(--pf-semantic-background-tertiary) !important;
6143
6136
  cursor: pointer;
6144
6137
  }
6145
6138
  .tanstack-table__tbody__tr.is-clicked td {
@@ -9166,20 +9159,19 @@ body div[class*=select__single-value] {
9166
9159
  color: inherit;
9167
9160
  }
9168
9161
  .truncate-wrapper .truncate {
9169
- white-space: nowrap;
9162
+ width: 100%;
9170
9163
  overflow: hidden;
9171
9164
  text-overflow: ellipsis;
9172
- width: 100%;
9173
- display: inline-block;
9174
9165
  }
9175
- .truncate-wrapper .truncate-clip {
9166
+ .truncate-wrapper .truncate--multi-line {
9176
9167
  display: -webkit-box;
9177
9168
  -webkit-box-orient: vertical;
9178
9169
  -webkit-line-clamp: var(--line-clamp);
9179
9170
  line-clamp: var(--line-clamp);
9180
- overflow: hidden;
9181
- text-overflow: ellipsis;
9182
- width: 100%;
9171
+ }
9172
+ .truncate-wrapper .truncate--single-line {
9173
+ display: inline-block;
9174
+ white-space: nowrap;
9183
9175
  }
9184
9176
 
9185
9177
  .Toastify__toast-theme--colored.Toastify__toast--default {
package/lib/index.d.ts CHANGED
@@ -944,14 +944,16 @@ interface TooltipProps {
944
944
  /** The delay in milliseconds before the tooltip is hidden */
945
945
  delayHide?: number;
946
946
  children: React.ReactNode;
947
- /** This is an override for the z-index of the tooltip */
948
- zIndex?: number;
949
947
  /** The placement of the tooltip */
950
948
  place?: PlacesType;
949
+ /** The width of the tooltip */
950
+ width?: CSSProperties['width'];
951
+ /** The max width of the tooltip */
952
+ maxWidth?: CSSProperties['maxWidth'];
951
953
  /** The content of the tooltip */
952
954
  [key: string]: any;
953
955
  }
954
- declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, zIndex, place, ...rest }: TooltipProps) => react_jsx_runtime.JSX.Element;
956
+ declare const Tooltip: ({ id, clickToShow, delayShow, delayHide, children, place, width, maxWidth, opacity, ...rest }: TooltipProps) => react_jsx_runtime.JSX.Element;
955
957
 
956
958
  interface PaginationProps {
957
959
  /** The total number of pages to be displayed */
@@ -1020,16 +1022,16 @@ declare const Stepper: ({ currentStep: externalCurrentStep, legendHeader, legend
1020
1022
 
1021
1023
  interface TruncateProps {
1022
1024
  /** The number of lines to truncate the text to. If left blank, it will default to 1 line. */
1023
- lineClamp?: number;
1025
+ numLines?: number;
1024
1026
  /** The string to truncate. This value will also be displayed in the tooltip when the text is truncated. */
1025
1027
  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;
1028
+ /** 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`. */
1029
+ tooltipOptions?: Partial<TooltipProps> & {
1030
+ disabled?: boolean;
1031
+ };
1030
1032
  [key: string]: any;
1031
1033
  }
1032
1034
 
1033
- declare const Truncate: ({ lineClamp, truncateString, hasTooltip, tooltipId, ...rest }: TruncateProps) => react_jsx_runtime.JSX.Element;
1035
+ declare const Truncate: ({ numLines, truncateString, tooltipOptions, ...rest }: TruncateProps) => react_jsx_runtime.JSX.Element;
1034
1036
 
1035
1037
  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
@@ -405,6 +405,7 @@
405
405
  --pf-font-size-10xl: 6rem; /* 96px */
406
406
  }
407
407
 
408
+ :root,
408
409
  :root [data-theme=light] {
409
410
  --pf-semantic-utility-info-default: var(--pf-secondary-color-450);
410
411
  --pf-semantic-utility-info-light: var(--pf-secondary-color-400);
@@ -4485,14 +4486,6 @@ a:hover,
4485
4486
  background-color: var(--pf-semantic-background-primary);
4486
4487
  }
4487
4488
 
4488
- .react-tooltip {
4489
- z-index: 5;
4490
- background-color: var(--pf-semantic-background-inverted);
4491
- color: var(--pf-semantic-font-inverted);
4492
- opacity: 1 !important;
4493
- text-wrap: wrap;
4494
- }
4495
-
4496
4489
  :root,
4497
4490
  :root [data-theme=light],
4498
4491
  :root [data-theme=dark] {
@@ -6139,7 +6132,7 @@ body div[class*=select__single-value] {
6139
6132
  background: var(--pf-semantic-background-accent) !important;
6140
6133
  }
6141
6134
  .tanstack-table__tbody__tr.show-hover:hover td {
6142
- background-color: var(--pf-semantic-border-hover) !important;
6135
+ background-color: var(--pf-semantic-background-tertiary) !important;
6143
6136
  cursor: pointer;
6144
6137
  }
6145
6138
  .tanstack-table__tbody__tr.is-clicked td {
@@ -9166,20 +9159,19 @@ body div[class*=select__single-value] {
9166
9159
  color: inherit;
9167
9160
  }
9168
9161
  .truncate-wrapper .truncate {
9169
- white-space: nowrap;
9162
+ width: 100%;
9170
9163
  overflow: hidden;
9171
9164
  text-overflow: ellipsis;
9172
- width: 100%;
9173
- display: inline-block;
9174
9165
  }
9175
- .truncate-wrapper .truncate-clip {
9166
+ .truncate-wrapper .truncate--multi-line {
9176
9167
  display: -webkit-box;
9177
9168
  -webkit-box-orient: vertical;
9178
9169
  -webkit-line-clamp: var(--line-clamp);
9179
9170
  line-clamp: var(--line-clamp);
9180
- overflow: hidden;
9181
- text-overflow: ellipsis;
9182
- width: 100%;
9171
+ }
9172
+ .truncate-wrapper .truncate--single-line {
9173
+ display: inline-block;
9174
+ white-space: nowrap;
9183
9175
  }
9184
9176
 
9185
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 } = _a, rest = __rest(_a, ["id", "clickToShow", "delayShow", "delayHide", "children", "place", "width", "maxWidth", "opacity"]);
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 }, 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}