@digital-ai/dot-components 2.27.1 → 2.28.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/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import { useEffect, useState, useRef, createContext, useMemo, useContext, forwardRef, useCallback, createElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
3
+ import { useState, useRef, useEffect, createContext, useMemo, useContext, forwardRef, useCallback, createElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
4
  import { Tooltip, Icon, Typography, Accordion, AccordionSummary, AccordionDetails, AccordionActions, InputAdornment, InputLabel, TextField, Toolbar, Alert, Fade, StyledEngineProvider, Avatar, Button, Link, List, ListSubheader, Divider, CircularProgress, Popper, MenuList, MenuItem, Paper, ClickAwayListener, Drawer, IconButton, ListItem, ListItemButton, Collapse, ListItemIcon, ListItemText, Badge, useMediaQuery, Autocomplete, Chip, AvatarGroup, Breadcrumbs, ToggleButtonGroup, ToggleButton, Card, CardContent, CardHeader, FormControlLabel, Checkbox, FormControl, FormGroup, FormLabel, FormHelperText, Dialog, DialogContent, DialogActions, useTheme as useTheme$1, RadioGroup, Radio, Switch, Skeleton, Snackbar, ButtonGroup, Stepper, Step, StepLabel, StepContent, TablePagination, TableContainer, TableBody, TableCell, TableRow, TableSortLabel, TableHead, Table, Tabs, Tab, LinearProgress, Slide } from '@mui/material';
5
5
  import '@digital-ai/dot-icons';
6
6
  import styled, { css, createGlobalStyle, ThemeProvider as ThemeProvider$1, keyframes } from 'styled-components';
@@ -29,6 +29,18 @@ function useStylesWithRootClass(name, className, ...args) {
29
29
  return [name, ...(className ? [className] : [])].concat(args).join(' ').trim();
30
30
  }
31
31
 
32
+ const checkIfOverflowPresentInElementTree = element => {
33
+ if (element.scrollWidth > element.clientWidth) {
34
+ return true;
35
+ }
36
+ for (const child of Array.from(element.children)) {
37
+ if (checkIfOverflowPresentInElementTree(child)) {
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ };
43
+
32
44
  const DotTooltip = ({
33
45
  ariaLabel,
34
46
  ariaRole = 'tooltip',
@@ -36,6 +48,8 @@ const DotTooltip = ({
36
48
  children,
37
49
  className,
38
50
  'data-testid': dataTestId,
51
+ disablePortal = false,
52
+ hoverVisibility = 'always',
39
53
  leaveDelay,
40
54
  onClose,
41
55
  open,
@@ -43,19 +57,44 @@ const DotTooltip = ({
43
57
  title
44
58
  }) => {
45
59
  const rootClasses = useStylesWithRootClass('dot-tooltip', className);
60
+ const [hasTooltipOnHover, setHasTooltipOnHover] = useState(false);
61
+ const childrenWrapperRef = useRef();
62
+ useEffect(() => {
63
+ if (hoverVisibility !== 'overflow') return;
64
+ const resizeObserver = new ResizeObserver(checkIfTooltipShouldBeRendered);
65
+ if (childrenWrapperRef.current) {
66
+ resizeObserver.observe(childrenWrapperRef.current);
67
+ }
68
+ checkIfTooltipShouldBeRendered();
69
+ return () => {
70
+ if (childrenWrapperRef.current) {
71
+ resizeObserver.unobserve(childrenWrapperRef.current);
72
+ }
73
+ };
74
+ }, [childrenWrapperRef.current, children, hoverVisibility]);
75
+ const checkIfTooltipShouldBeRendered = () => {
76
+ if (!childrenWrapperRef || !childrenWrapperRef.current) return;
77
+ const isOverflowPresent = checkIfOverflowPresentInElementTree(childrenWrapperRef.current);
78
+ setHasTooltipOnHover(isOverflowPresent);
79
+ };
46
80
  return title ? jsx(Tooltip, {
47
81
  "aria-hidden": false,
48
82
  "aria-label": ariaLabel || title.toString(),
49
83
  arrow: arrow,
50
84
  className: rootClasses,
51
85
  "data-testid": dataTestId,
86
+ disableHoverListener: hoverVisibility === 'never' || hoverVisibility === 'overflow' && !hasTooltipOnHover,
52
87
  leaveDelay: leaveDelay,
53
88
  onClose: onClose,
54
89
  open: open,
55
90
  placement: placement,
91
+ PopperProps: {
92
+ disablePortal
93
+ },
56
94
  role: ariaRole,
57
95
  title: title,
58
96
  children: jsx("span", {
97
+ ref: childrenWrapperRef,
59
98
  tabIndex: -1,
60
99
  children: children
61
100
  })
@@ -2623,6 +2662,7 @@ const DotButton = forwardRef(({
2623
2662
  startIcon,
2624
2663
  tabIndex,
2625
2664
  tooltip,
2665
+ tooltipPlacement,
2626
2666
  type = 'primary'
2627
2667
  }, ref) => {
2628
2668
  const rootClasses = useStylesWithRootClass(rootClassName$12, className);
@@ -2647,6 +2687,7 @@ const DotButton = forwardRef(({
2647
2687
  break;
2648
2688
  }
2649
2689
  return jsx(DotTooltip, {
2690
+ placement: tooltipPlacement,
2650
2691
  title: tooltip,
2651
2692
  children: jsx(StyledButton, {
2652
2693
  "aria-label": ariaLabel,
@@ -2973,6 +3014,10 @@ const StyledPopper = styled(Popper)`
2973
3014
  max-height: ${getListMaxHeight($maxHeight)};
2974
3015
  `}
2975
3016
 
3017
+ li {
3018
+ word-break: break-word;
3019
+ }
3020
+
2976
3021
  .dot-li {
2977
3022
  min-height: auto;
2978
3023
  }
@@ -3423,19 +3468,21 @@ const DotIconButton = ({
3423
3468
  color = 'inherit',
3424
3469
  'data-pendoid': dataPendoId = rootClassName$V,
3425
3470
  'data-testid': dataTestId,
3426
- disabled = false,
3427
3471
  disableRipple = false,
3472
+ disabled = false,
3428
3473
  iconId,
3429
3474
  iconSize = 'small',
3430
3475
  onClick,
3431
- tooltip,
3432
3476
  shape = 'circle',
3433
- size = 'medium'
3477
+ size = 'medium',
3478
+ tooltip,
3479
+ tooltipPlacement
3434
3480
  }) => {
3435
3481
  const rippleClassName = disableRipple ? 'ripple-disabled' : '';
3436
3482
  const rootClasses = useStylesWithRootClass(rootClassName$V, rippleClassName, `shape-${shape}`, className);
3437
3483
  return jsx(DotTooltip, {
3438
3484
  "data-testid": "icon-button-tooltip",
3485
+ placement: tooltipPlacement,
3439
3486
  title: tooltip,
3440
3487
  children: jsx(StyledIconButton, {
3441
3488
  "aria-label": ariaLabel || tooltip || `${iconId} icon button`,
@@ -6126,14 +6173,14 @@ const StyledChip = styled(Chip)`
6126
6173
 
6127
6174
  &.Mui-disabled {
6128
6175
  background: ${theme.palette.figma.disabled.normal};
6129
- border-color: ${theme.palette.figma.border.default}
6176
+ border-color: ${theme.palette.figma.border.default};
6130
6177
  opacity: 1;
6131
6178
 
6132
- .dot-icon i {
6179
+ .dot-icon i,
6180
+ .MuiChip-deleteIcon {
6133
6181
  color: ${theme.palette.figma.icon.disabled};
6134
6182
  }
6135
6183
 
6136
- .MuiChip-deleteIcon,
6137
6184
  .MuiChip-label {
6138
6185
  color: ${theme.palette.figma.typography.disabled};
6139
6186
  }
@@ -9491,6 +9538,7 @@ const StyledInlineEdit = styled.div`
9491
9538
  position: relative;
9492
9539
 
9493
9540
  .dot-edit-icon {
9541
+ background-color: ${theme.palette.figma.neutral.elevated};
9494
9542
  border-radius: ${theme.spacing(0, 0.5, 0.5, 0)};
9495
9543
  display: none;
9496
9544
  height: 100%;
@@ -9521,6 +9569,7 @@ const StyledInlineEdit = styled.div`
9521
9569
  .dot-view-mode-typography {
9522
9570
  padding: ${theme.spacing(1.3125, 1)};
9523
9571
  margin-bottom: 0;
9572
+ word-break: break-word;
9524
9573
 
9525
9574
  &.${placeholderClassName} {
9526
9575
  color: ${theme.palette.figma.typography.gray};
@@ -10478,6 +10527,7 @@ const DotSplitButton = ({
10478
10527
  options = [],
10479
10528
  size = 'medium',
10480
10529
  tooltip,
10530
+ tooltipPlacement,
10481
10531
  type = 'primary'
10482
10532
  }) => {
10483
10533
  const rootClasses = useStylesWithRootClass(rootClassName$l, className, type, disabled ? 'disabled' : '');
@@ -10515,6 +10565,7 @@ const DotSplitButton = ({
10515
10565
  onClick: event => handleClick(event, null, mainOptionKey),
10516
10566
  size: size,
10517
10567
  tooltip: tooltip,
10568
+ tooltipPlacement: tooltipPlacement,
10518
10569
  type: type,
10519
10570
  children: mainOptionChildren
10520
10571
  }), jsx(DotButton, {
@@ -11713,6 +11764,7 @@ const DotHeaderRow = ({
11713
11764
  },
11714
11765
  children: [multiSelectHeader && renderMultiSelectCell(), collapsibleTableOptions && jsx(DotHeaderCell, {
11715
11766
  "aria-hidden": "true",
11767
+ sortable: false,
11716
11768
  typography: typography,
11717
11769
  uid: CreateUUID()
11718
11770
  }), columns.map(cell => {
@@ -13153,6 +13205,24 @@ const DotPopper = ({
13153
13205
  });
13154
13206
  };
13155
13207
 
13208
+ const getOrderedListItems = (layout, listItems) => {
13209
+ if (!listItems || !layout) return [];
13210
+ return [...listItems].sort((a, b) => layout.find(layoutItem => layoutItem.i === a.id).y - layout.find(layoutItem => layoutItem.i === b.id).y);
13211
+ };
13212
+ const checkIfEqual = (oldList, newList) => {
13213
+ if (oldList.length !== newList.length) return false;
13214
+ return oldList.every((oldListItem, index) => oldListItem.id === newList[index].id);
13215
+ };
13216
+ const getListItemLayout = listItems => {
13217
+ return listItems === null || listItems === void 0 ? void 0 : listItems.map((item, index) => ({
13218
+ i: item.id,
13219
+ x: 0,
13220
+ y: index,
13221
+ w: 1,
13222
+ h: 1
13223
+ }));
13224
+ };
13225
+
13156
13226
  const rootClassName$5 = 'dot-draggable-list';
13157
13227
  const listItemClassName = 'dot-draggable-list-item';
13158
13228
  const StyledDraggableList = styled.div`
@@ -13165,6 +13235,8 @@ const StyledDraggableList = styled.div`
13165
13235
  position: relative;
13166
13236
 
13167
13237
  .${listItemClassName} {
13238
+ width: 100% !important;
13239
+
13168
13240
  .dot-icon {
13169
13241
  color: ${theme.palette.layer.n700};
13170
13242
  }
@@ -13179,30 +13251,14 @@ const StyledDraggableList = styled.div`
13179
13251
 
13180
13252
  &.with-handle-grab-cursor ${draggableHandle} {
13181
13253
  cursor: grab;
13254
+ user-select: unset !important;
13255
+ -moz-user-select: unset !important;
13182
13256
  }
13183
13257
  }
13184
13258
  }
13185
13259
  `}
13186
13260
  `;
13187
13261
 
13188
- const getOrderedListItems = (layout, listItems) => {
13189
- if (!listItems || !layout) return [];
13190
- return [...listItems].sort((a, b) => layout.find(layoutItem => layoutItem.i === a.id).y - layout.find(layoutItem => layoutItem.i === b.id).y);
13191
- };
13192
- const checkIfEqual = (oldList, newList) => {
13193
- if (oldList.length !== newList.length) return false;
13194
- return oldList.every((oldListItem, index) => oldListItem.id === newList[index].id);
13195
- };
13196
- const getListItemLayout = listItems => {
13197
- return listItems === null || listItems === void 0 ? void 0 : listItems.map((item, index) => ({
13198
- i: item.id,
13199
- x: 0,
13200
- y: index,
13201
- w: 1,
13202
- h: 1
13203
- }));
13204
- };
13205
-
13206
13262
  const DEFAULT_LIST_WIDTH = '100%';
13207
13263
  const DEFAULT_LIST_ITEM_HEIGHT = 36;
13208
13264
  const ListGridLayout = WidthProvider(GridLayout);
@@ -13238,7 +13294,9 @@ const DotDraggableList = ({
13238
13294
  "data-pendoid": dataPendoId,
13239
13295
  "data-testid": dataTestId,
13240
13296
  draggableHandle: draggableHandle,
13241
- width: listWidth,
13297
+ style: {
13298
+ width: listWidth
13299
+ },
13242
13300
  children: jsx(ListGridLayout, {
13243
13301
  className: "layout",
13244
13302
  draggableHandle: draggableHandle,
@@ -13248,9 +13306,6 @@ const DotDraggableList = ({
13248
13306
  margin: [0, 0],
13249
13307
  onLayoutChange: onChange && handleLayoutChange(),
13250
13308
  rowHeight: rowHeight,
13251
- style: {
13252
- width: listWidth
13253
- },
13254
13309
  children: orderedItems.map(({
13255
13310
  id: itemId,
13256
13311
  children
@@ -13258,13 +13313,8 @@ const DotDraggableList = ({
13258
13313
  return jsx(ListItem, {
13259
13314
  "data-pendoid": dataPendoId && `${dataPendoId}-item`,
13260
13315
  "data-testid": dataTestId && `${dataTestId}-item`,
13261
- button: true,
13262
13316
  children: renderNodeOrTypography(children),
13263
- className: listItemClasses,
13264
- disableRipple: true,
13265
- style: {
13266
- width: listWidth
13267
- }
13317
+ className: listItemClasses
13268
13318
  }, itemId);
13269
13319
  })
13270
13320
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "2.27.1",
3
+ "version": "2.28.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [
@@ -1,5 +1,6 @@
1
1
  import { MouseEvent, KeyboardEvent } from 'react';
2
2
  import { CommonProps } from './CommonProps';
3
+ import { TooltipPlacement } from './tooltip';
3
4
  export type ButtonType = 'destructive' | 'primary' | 'outlined' | 'text';
4
5
  export type ButtonSize = 'small' | 'medium' | 'large';
5
6
  export interface BaseButtonProps extends CommonProps {
@@ -21,6 +22,8 @@ export interface BaseButtonProps extends CommonProps {
21
22
  tabIndex?: number;
22
23
  /** Help text to be displayed on hover */
23
24
  tooltip?: string;
25
+ /** If set, determines the placement of the tooltip */
26
+ tooltipPlacement?: TooltipPlacement;
24
27
  /** The type of button */
25
28
  type?: ButtonType;
26
29
  }
@@ -1,6 +1,7 @@
1
1
  import { MouseEvent } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
3
  import { IconFontSize } from '../icon/Icon';
4
+ import { TooltipPlacement } from '../tooltip';
4
5
  export type IconButtonColor = 'default' | 'inherit' | 'primary' | 'secondary';
5
6
  export type IconButtonSize = 'small' | 'medium';
6
7
  export type IconButtonShape = 'circle' | 'square';
@@ -21,9 +22,11 @@ export interface CommonIconButtonProps extends CommonProps {
21
22
  size?: IconButtonSize;
22
23
  /** Help text to be displayed on icon hover */
23
24
  tooltip?: string;
25
+ /** If set, determines the placement of the tooltip */
26
+ tooltipPlacement?: TooltipPlacement;
24
27
  }
25
28
  export interface IconButtonProps extends CommonIconButtonProps {
26
29
  /** The icon to display on the button */
27
30
  iconId: string;
28
31
  }
29
- export declare const DotIconButton: ({ ariaLabel, ariaRole, className, color, "data-pendoid": dataPendoId, "data-testid": dataTestId, disabled, disableRipple, iconId, iconSize, onClick, tooltip, shape, size, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const DotIconButton: ({ ariaLabel, ariaRole, className, color, "data-pendoid": dataPendoId, "data-testid": dataTestId, disableRipple, disabled, iconId, iconSize, onClick, shape, size, tooltip, tooltipPlacement, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,6 @@ export declare const rootClassName = "dot-draggable-list";
2
2
  export declare const listItemClassName = "dot-draggable-list-item";
3
3
  interface StyledDraggableListProps {
4
4
  draggableHandle?: string;
5
- width: string;
6
5
  }
7
6
  export declare const StyledDraggableList: import("styled-components").StyledComponent<"div", any, StyledDraggableListProps, never>;
8
7
  export {};
@@ -43,6 +43,7 @@ export type { ClickAwayListenerProps } from './click-away-listener';
43
43
  export type { StepProps } from './stepper/Stepper';
44
44
  export type { CarouselAnimationVariant, CarouselNavigationButtonDisplayOption, CarouselProps, } from './carousel/Carousel';
45
45
  export type { StickyWithBorderProps } from './sticky-with-border';
46
+ export type { TooltipProps, TooltipHoverVisibility, TooltipPlacement, } from './tooltip';
46
47
  export { DotAccordion } from './accordion/Accordion';
47
48
  export { DotActionToolbar } from './action-toolbar/ActionToolbar';
48
49
  export { DotAlertBanner } from './alert-banner/AlertBanner';
@@ -95,7 +96,7 @@ export { DotStepper } from './stepper/Stepper';
95
96
  export { DotProgressButton } from './progress-button/ProgressButton';
96
97
  export { DotSwitch } from './switch';
97
98
  export { DotHeaderRow, DotTable, DotTablePagination, DotTableActions, DotTableAction, } from './table';
98
- export { DotTooltip } from './tooltip/Tooltip';
99
+ export { DotTooltip } from './tooltip';
99
100
  export { DotTabs } from './tabs/Tabs';
100
101
  export { DotTypography } from './typography/Typography';
101
102
  export { DotFileUpload, DotFileListItem } from './file-upload';
@@ -2,7 +2,7 @@ import { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
2
2
  import { CommonProps } from '../../CommonProps';
3
3
  import { PopperPlacement } from '../../menu/Menu';
4
4
  import { LinkTarget } from '../../link/Link';
5
- import { tooltipPlacement } from '../../tooltip/Tooltip';
5
+ import { TooltipPlacement } from '../../tooltip/Tooltip';
6
6
  export declare const DEFAULT_TOOLTIP_PLACEMENT = "top-start";
7
7
  export type NestedListType = 'drawer' | 'expandable' | 'menu';
8
8
  export interface ListProps extends CommonProps {
@@ -65,7 +65,7 @@ export interface ListItemProps extends CommonProps {
65
65
  /** Tooltip text displayed on hover */
66
66
  tooltip?: string;
67
67
  /** Tooltip placement displayed on hover */
68
- tooltipPlacement?: tooltipPlacement;
68
+ tooltipPlacement?: TooltipPlacement;
69
69
  }
70
70
  export interface NestedListProps extends CommonProps {
71
71
  /** Element that menu is attached to */
@@ -12,4 +12,4 @@ export interface SplitButtonProps extends BaseButtonProps {
12
12
  /**The options within the button dropdown */
13
13
  options: Array<MenuItemProps>;
14
14
  }
15
- export declare const DotSplitButton: ({ autoFocus, ariaLabel, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, defaultMainOptionKey, disabled, disablePortal, disableRipple, fullWidth, isSubmit, onOptionClick, options, size, tooltip, type, }: SplitButtonProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const DotSplitButton: ({ autoFocus, ariaLabel, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, defaultMainOptionKey, disabled, disablePortal, disableRipple, fullWidth, isSubmit, onOptionClick, options, size, tooltip, tooltipPlacement, type, }: SplitButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,18 @@
1
1
  import { ReactNode, ReactElement, ChangeEvent } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
- export type tooltipPlacement = 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
3
+ export type TooltipHoverVisibility = 'always' | 'overflow' | 'never';
4
+ export type TooltipPlacement = 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
4
5
  export interface TooltipProps extends CommonProps {
5
6
  /** If true, adds an arrow to the tooltip indicating which element it refers to. */
6
7
  arrow?: boolean;
7
8
  children: ReactElement;
9
+ /** Disable the portal behavior. If true, children stay within parent DOM hierarchy. */
10
+ disablePortal?: boolean;
11
+ hoverVisibility?: TooltipHoverVisibility;
8
12
  leaveDelay?: number;
9
13
  onClose?: (event: ChangeEvent) => void;
10
14
  open?: boolean;
11
- placement?: tooltipPlacement;
15
+ placement?: TooltipPlacement;
12
16
  title?: ReactNode | string | number;
13
17
  }
14
- export declare const DotTooltip: ({ ariaLabel, ariaRole, arrow, children, className, "data-testid": dataTestId, leaveDelay, onClose, open, placement, title, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const DotTooltip: ({ ariaLabel, ariaRole, arrow, children, className, "data-testid": dataTestId, disablePortal, hoverVisibility, leaveDelay, onClose, open, placement, title, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { TooltipProps, TooltipHoverVisibility, TooltipPlacement, } from './Tooltip';
2
+ export { DotTooltip } from './Tooltip';
@@ -0,0 +1 @@
1
+ export declare const checkIfOverflowPresentInElementTree: (element: HTMLElement) => boolean;