@digital-ai/dot-components 2.27.1 → 3.0.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,7 +1,7 @@
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';
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';
3
+ import { useState, useRef, useEffect, createContext, useMemo, useContext, forwardRef, useCallback, createElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
+ import { Tooltip, Icon, Typography, Accordion, AccordionSummary, AccordionDetails, AccordionActions, InputAdornment, InputLabel, TextField, Toolbar, Fade, StyledEngineProvider, Alert, 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';
7
7
  import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
@@ -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
  })
@@ -563,73 +602,6 @@ const DotActionToolbar = ({
563
602
  });
564
603
  };
565
604
 
566
- const rootClassName$14 = 'dot-alert-banner';
567
- const StyledAlertBanner = styled(Alert)`
568
- ${({
569
- theme
570
- }) => css`
571
- &.${rootClassName$14} {
572
- align-items: center;
573
- border-radius: 8px;
574
- box-sizing: border-box;
575
- display: flex;
576
- min-height: 48px;
577
- overflow: hidden;
578
- padding: ${theme.spacing(0.75, 2)};
579
-
580
- svg,
581
- .dot-typography {
582
- color: ${theme.palette.figma.overlay.alerts.text.black};
583
- }
584
-
585
- .dot-icon,
586
- .MuiAlert-icon,
587
- .MuiAlert-message {
588
- padding: 0;
589
- .dot-typography {
590
- margin-bottom: 0;
591
- }
592
- }
593
-
594
- &.MuiAlert-standardSuccess {
595
- background: ${theme.palette.figma.overlay.alerts.success.background};
596
-
597
- .dot-icon,
598
- .MuiAlert-icon {
599
- color: ${theme.palette.figma.overlay.alerts.success.icon};
600
- }
601
- }
602
-
603
- &.MuiAlert-standardInfo {
604
- background: ${theme.palette.figma.overlay.alerts.info.background};
605
-
606
- .dot-icon,
607
- .MuiAlert-icon {
608
- color: ${theme.palette.figma.overlay.alerts.info.icon};
609
- }
610
- }
611
-
612
- &.MuiAlert-standardWarning {
613
- background: ${theme.palette.figma.overlay.alerts.warning.background};
614
-
615
- .dot-icon,
616
- .MuiAlert-icon {
617
- color: ${theme.palette.figma.overlay.alerts.warning.icon};
618
- }
619
- }
620
-
621
- &.MuiAlert-standardError {
622
- background: ${theme.palette.figma.overlay.alerts.error.background};
623
-
624
- .dot-icon,
625
- .MuiAlert-icon {
626
- color: ${theme.palette.figma.overlay.alerts.error.icon};
627
- }
628
- }
629
- }
630
- `}
631
- `;
632
-
633
605
  //Primary blue
634
606
  //https://zeroheight.com/4a9ac476a/p/22005a-color/t/6288e9
635
607
  const b50 = '#e8edf3';
@@ -1688,6 +1660,35 @@ const renderNodeOrTypography = (content, typographyVariant = 'body1') => {
1688
1660
  const checkIfArrowUpPressed = event => event.key === 'ArrowUp';
1689
1661
  const checkIfArrowDownPressed = event => event.key === 'ArrowDown';
1690
1662
 
1663
+ const rootClassName$14 = 'dot-alert-banner';
1664
+ const StyledAlertBanner = styled(Alert)`
1665
+ ${({
1666
+ theme
1667
+ }) => css`
1668
+ &.${rootClassName$14} {
1669
+ box-sizing: border-box;
1670
+ min-height: 48px;
1671
+ overflow: hidden;
1672
+
1673
+ &.MuiAlert-standardSuccess {
1674
+ background: ${theme.palette.figma.overlay.alerts.success.background};
1675
+ }
1676
+
1677
+ &.MuiAlert-standardInfo {
1678
+ background: ${theme.palette.figma.overlay.alerts.info.background};
1679
+ }
1680
+
1681
+ &.MuiAlert-standardWarning {
1682
+ background: ${theme.palette.figma.overlay.alerts.warning.background};
1683
+ }
1684
+
1685
+ &.MuiAlert-standardError {
1686
+ background: ${theme.palette.figma.overlay.alerts.error.background};
1687
+ }
1688
+ }
1689
+ `}
1690
+ `;
1691
+
1691
1692
  const DotAlertBanner = ({
1692
1693
  action,
1693
1694
  ariaLabel,
@@ -1698,19 +1699,9 @@ const DotAlertBanner = ({
1698
1699
  onClose,
1699
1700
  roundedCorners = true,
1700
1701
  severity,
1701
- textVariant = 'body1'
1702
+ textVariant = 'body1',
1703
+ width
1702
1704
  }) => {
1703
- const AlertBannerIcon = iconId => {
1704
- return jsx(DotIcon, {
1705
- iconId: iconId
1706
- });
1707
- };
1708
- const AlertBannerIconMapping = {
1709
- error: AlertBannerIcon('error-solid'),
1710
- info: AlertBannerIcon('info-solid'),
1711
- success: AlertBannerIcon('check-solid'),
1712
- warning: AlertBannerIcon('warning-solid')
1713
- };
1714
1705
  const rootClasses = useStylesWithRootClass(rootClassName$14, severity, className);
1715
1706
  /* For simple string use default component, for everything else use 'div' */
1716
1707
  const typographyComponent = isString$1(children) ? undefined : 'div';
@@ -1722,11 +1713,11 @@ const DotAlertBanner = ({
1722
1713
  },
1723
1714
  "data-pendoid": dataPendoId,
1724
1715
  "data-testid": dataTestId,
1725
- iconMapping: AlertBannerIconMapping,
1726
1716
  onClose: onClose,
1727
1717
  severity: severity,
1728
1718
  style: {
1729
- borderRadius: roundedCorners ? '8px' : undefined
1719
+ borderRadius: roundedCorners ? '8px' : undefined,
1720
+ width
1730
1721
  },
1731
1722
  children: jsx(DotTypography, {
1732
1723
  variant: textVariant,
@@ -2623,6 +2614,7 @@ const DotButton = forwardRef(({
2623
2614
  startIcon,
2624
2615
  tabIndex,
2625
2616
  tooltip,
2617
+ tooltipPlacement,
2626
2618
  type = 'primary'
2627
2619
  }, ref) => {
2628
2620
  const rootClasses = useStylesWithRootClass(rootClassName$12, className);
@@ -2647,6 +2639,7 @@ const DotButton = forwardRef(({
2647
2639
  break;
2648
2640
  }
2649
2641
  return jsx(DotTooltip, {
2642
+ placement: tooltipPlacement,
2650
2643
  title: tooltip,
2651
2644
  children: jsx(StyledButton, {
2652
2645
  "aria-label": ariaLabel,
@@ -2973,6 +2966,10 @@ const StyledPopper = styled(Popper)`
2973
2966
  max-height: ${getListMaxHeight($maxHeight)};
2974
2967
  `}
2975
2968
 
2969
+ li {
2970
+ word-break: break-word;
2971
+ }
2972
+
2976
2973
  .dot-li {
2977
2974
  min-height: auto;
2978
2975
  }
@@ -3423,19 +3420,21 @@ const DotIconButton = ({
3423
3420
  color = 'inherit',
3424
3421
  'data-pendoid': dataPendoId = rootClassName$V,
3425
3422
  'data-testid': dataTestId,
3426
- disabled = false,
3427
3423
  disableRipple = false,
3424
+ disabled = false,
3428
3425
  iconId,
3429
3426
  iconSize = 'small',
3430
3427
  onClick,
3431
- tooltip,
3432
3428
  shape = 'circle',
3433
- size = 'medium'
3429
+ size = 'medium',
3430
+ tooltip,
3431
+ tooltipPlacement
3434
3432
  }) => {
3435
3433
  const rippleClassName = disableRipple ? 'ripple-disabled' : '';
3436
3434
  const rootClasses = useStylesWithRootClass(rootClassName$V, rippleClassName, `shape-${shape}`, className);
3437
3435
  return jsx(DotTooltip, {
3438
3436
  "data-testid": "icon-button-tooltip",
3437
+ placement: tooltipPlacement,
3439
3438
  title: tooltip,
3440
3439
  children: jsx(StyledIconButton, {
3441
3440
  "aria-label": ariaLabel || tooltip || `${iconId} icon button`,
@@ -6126,14 +6125,14 @@ const StyledChip = styled(Chip)`
6126
6125
 
6127
6126
  &.Mui-disabled {
6128
6127
  background: ${theme.palette.figma.disabled.normal};
6129
- border-color: ${theme.palette.figma.border.default}
6128
+ border-color: ${theme.palette.figma.border.default};
6130
6129
  opacity: 1;
6131
6130
 
6132
- .dot-icon i {
6131
+ .dot-icon i,
6132
+ .MuiChip-deleteIcon {
6133
6133
  color: ${theme.palette.figma.icon.disabled};
6134
6134
  }
6135
6135
 
6136
- .MuiChip-deleteIcon,
6137
6136
  .MuiChip-label {
6138
6137
  color: ${theme.palette.figma.typography.disabled};
6139
6138
  }
@@ -9491,6 +9490,7 @@ const StyledInlineEdit = styled.div`
9491
9490
  position: relative;
9492
9491
 
9493
9492
  .dot-edit-icon {
9493
+ background-color: ${theme.palette.figma.neutral.elevated};
9494
9494
  border-radius: ${theme.spacing(0, 0.5, 0.5, 0)};
9495
9495
  display: none;
9496
9496
  height: 100%;
@@ -9521,6 +9521,7 @@ const StyledInlineEdit = styled.div`
9521
9521
  .dot-view-mode-typography {
9522
9522
  padding: ${theme.spacing(1.3125, 1)};
9523
9523
  margin-bottom: 0;
9524
+ word-break: break-word;
9524
9525
 
9525
9526
  &.${placeholderClassName} {
9526
9527
  color: ${theme.palette.figma.typography.gray};
@@ -10173,83 +10174,71 @@ const DotSkeleton = ({
10173
10174
  });
10174
10175
  };
10175
10176
 
10177
+ function addAutoHideDuration(severity) {
10178
+ return severity === 'error' ? null : 10000;
10179
+ }
10180
+
10181
+ const getSnackbarTitleFromSeverity = severity => {
10182
+ switch (severity) {
10183
+ case 'success':
10184
+ return 'Success';
10185
+ case 'warning':
10186
+ return 'Warning';
10187
+ case 'error':
10188
+ return 'Error';
10189
+ case 'info':
10190
+ return 'Info';
10191
+ default:
10192
+ return 'Success';
10193
+ }
10194
+ };
10195
+
10176
10196
  const rootClassName$n = 'dot-snackbar';
10177
10197
  const StyledSnackbar = styled(Snackbar)`
10178
10198
  ${({
10179
- theme
10199
+ theme,
10200
+ width,
10201
+ $anchorOriginTop
10180
10202
  }) => css`
10181
- &.${rootClassName$n} {
10182
- .dot-icon-btn .dot-icon {
10183
- color: ${theme.palette.figma.icon.white};
10184
- }
10185
-
10186
- .dot-icon-btn:hover {
10187
- background: ${n900_20};
10188
- }
10203
+ &.${rootClassName$n} {
10204
+ .MuiAlert-message {
10205
+ word-break: break-word;
10206
+ }
10189
10207
 
10190
- .MuiAlert-icon {
10191
- color: ${theme.palette.figma.icon.white};
10192
- padding: 11px 0px;
10193
- }
10194
- .MuiAlert-message {
10195
- padding: 13px 0px;
10196
- word-break: break-word;
10197
- }
10198
- &.MuiSnackbar-anchorOriginTopRight{
10199
- top: 0px;
10200
- z-index: ${levelFourth};
10201
- }
10208
+ &.MuiSnackbar-anchorOriginTopLeft,
10209
+ &.MuiSnackbar-anchorOriginTopCenter,
10210
+ &.MuiSnackbar-anchorOriginTopRight {
10211
+ top: ${$anchorOriginTop}px;
10212
+ z-index: ${levelFourth};
10213
+ }
10202
10214
 
10203
- .MuiAlert-root {
10204
- color: ${theme.palette.figma.typography.white};
10205
- position: relative;
10206
- margin-top: 108px;
10207
- max-width: 500px;
10208
- min-width: 344px;
10209
- z-index: ${levelFourth};
10215
+ .dot-snackbar-actions {
10216
+ display: flex;
10217
+ align-items: center;
10218
+ margin-top: ${theme.spacing(1)};
10219
+ gap: ${theme.spacing(2)};
10210
10220
 
10211
- @media (min-width: 720px) {
10212
- .MuiAlert-root {
10213
- top: 112px;
10214
- position: relative;
10221
+ .primary-action-btn {
10222
+ background-color: transparent;
10215
10223
  }
10216
10224
  }
10217
10225
 
10218
- &.MuiAlert-standardSuccess {
10219
- background: ${theme.palette.figma.success.normal};
10220
- }
10221
- &.MuiAlert-standardInfo {
10222
- background: ${theme.palette.figma.inProgress.normal};
10223
- }
10224
- &.MuiAlert-standardWarning {
10225
- background: ${theme.palette.figma.warning.normal};
10226
- }
10227
- &.MuiAlert-standardError {
10228
- background: ${theme.palette.figma.destructive.normal};
10226
+ .MuiAlert-root {
10227
+ max-width: ${width ? 'unset' : '500px'};
10228
+ min-width: ${width ? 'unset' : '344px'};
10229
+ z-index: ${levelFourth};
10229
10230
  }
10230
10231
  }
10231
10232
  `}
10232
10233
  `;
10233
10234
 
10234
- function addAutoHideDuration(severity) {
10235
- return severity === 'error' ? null : 10000;
10236
- }
10237
-
10238
- function checkForConflictingEventHandlers({
10239
- action,
10240
- onClose
10241
- }) {
10242
- if (action && onClose) {
10243
- console.error('You have passed two event handlers for action buttons. Please pick one.');
10244
- }
10245
- }
10246
10235
  const DEFAULT_ANCHOR_ORIGIN = {
10247
10236
  vertical: 'top',
10248
10237
  horizontal: 'right'
10249
10238
  };
10250
10239
  const DotSnackbar = ({
10251
- action,
10252
10240
  anchorOrigin = DEFAULT_ANCHOR_ORIGIN,
10241
+ anchorOriginTop = 108,
10253
10242
  ariaLabel,
10254
10243
  autoHideDuration,
10255
10244
  children,
@@ -10258,22 +10247,22 @@ const DotSnackbar = ({
10258
10247
  hideOnClickAway = true,
10259
10248
  onClose,
10260
10249
  open,
10250
+ primaryAction,
10251
+ secondaryAction,
10261
10252
  severity,
10262
10253
  width
10263
10254
  }) => {
10255
+ const hasActions = !!(primaryAction || secondaryAction);
10264
10256
  const calculatedAutoHideDuration = autoHideDuration === null || autoHideDuration > 0 ? autoHideDuration : addAutoHideDuration(severity);
10265
- checkForConflictingEventHandlers({
10266
- onClose,
10267
- action
10268
- });
10269
10257
  const rootClasses = useStylesWithRootClass(rootClassName$n, className);
10270
10258
  const handleSnackbarClose = reason => {
10271
- if (hideOnClickAway || !hideOnClickAway && reason !== 'clickaway') {
10259
+ if (!reason || hideOnClickAway || !hideOnClickAway && reason !== 'clickaway') {
10272
10260
  onClose();
10273
10261
  }
10274
10262
  };
10275
10263
  return jsx(StyledSnackbar, {
10276
10264
  anchorOrigin: anchorOrigin,
10265
+ "$anchorOriginTop": anchorOriginTop,
10277
10266
  "aria-label": ariaLabel,
10278
10267
  autoHideDuration: calculatedAutoHideDuration,
10279
10268
  classes: {
@@ -10283,16 +10272,41 @@ const DotSnackbar = ({
10283
10272
  onClose: (_e, r) => handleSnackbarClose(r),
10284
10273
  open: open,
10285
10274
  severity: severity,
10286
- children: jsx(Alert, {
10287
- action: action,
10288
- onClose: onClose,
10289
- severity: severity,
10290
- style: {
10291
- width: width
10292
- },
10293
- children: jsx("span", {
10294
- "aria-label": severity,
10295
- children: children
10275
+ width: width,
10276
+ children: jsx("div", {
10277
+ children: jsx(DotAlertBanner, {
10278
+ severity: severity,
10279
+ width: width,
10280
+ onClose: _e => handleSnackbarClose(),
10281
+ children: jsxs("div", {
10282
+ children: [jsx(DotTypography, {
10283
+ variant: "subtitle2",
10284
+ noMarginBottom: false,
10285
+ children: getSnackbarTitleFromSeverity(severity)
10286
+ }), isString$1(children) ? jsx(DotTypography, {
10287
+ ariaLabel: severity,
10288
+ variant: "body1",
10289
+ children: children
10290
+ }) : jsx("span", {
10291
+ "aria-label": severity,
10292
+ children: children
10293
+ }), hasActions && jsxs("div", {
10294
+ className: "dot-snackbar-actions",
10295
+ children: [primaryAction && jsx(DotButton, {
10296
+ className: "primary-action-btn",
10297
+ "data-testid": "primary-action-btn",
10298
+ onClick: primaryAction.onClick,
10299
+ size: "small",
10300
+ type: "outlined",
10301
+ children: primaryAction.label
10302
+ }), secondaryAction && jsx(DotLink, {
10303
+ "data-testid": "secondary-action-link",
10304
+ href: secondaryAction.href,
10305
+ color: "inherit",
10306
+ children: secondaryAction.label
10307
+ })]
10308
+ })]
10309
+ })
10296
10310
  })
10297
10311
  })
10298
10312
  });
@@ -10478,6 +10492,7 @@ const DotSplitButton = ({
10478
10492
  options = [],
10479
10493
  size = 'medium',
10480
10494
  tooltip,
10495
+ tooltipPlacement,
10481
10496
  type = 'primary'
10482
10497
  }) => {
10483
10498
  const rootClasses = useStylesWithRootClass(rootClassName$l, className, type, disabled ? 'disabled' : '');
@@ -10515,6 +10530,7 @@ const DotSplitButton = ({
10515
10530
  onClick: event => handleClick(event, null, mainOptionKey),
10516
10531
  size: size,
10517
10532
  tooltip: tooltip,
10533
+ tooltipPlacement: tooltipPlacement,
10518
10534
  type: type,
10519
10535
  children: mainOptionChildren
10520
10536
  }), jsx(DotButton, {
@@ -11713,6 +11729,7 @@ const DotHeaderRow = ({
11713
11729
  },
11714
11730
  children: [multiSelectHeader && renderMultiSelectCell(), collapsibleTableOptions && jsx(DotHeaderCell, {
11715
11731
  "aria-hidden": "true",
11732
+ sortable: false,
11716
11733
  typography: typography,
11717
11734
  uid: CreateUUID()
11718
11735
  }), columns.map(cell => {
@@ -13153,6 +13170,24 @@ const DotPopper = ({
13153
13170
  });
13154
13171
  };
13155
13172
 
13173
+ const getOrderedListItems = (layout, listItems) => {
13174
+ if (!listItems || !layout) return [];
13175
+ return [...listItems].sort((a, b) => layout.find(layoutItem => layoutItem.i === a.id).y - layout.find(layoutItem => layoutItem.i === b.id).y);
13176
+ };
13177
+ const checkIfEqual = (oldList, newList) => {
13178
+ if (oldList.length !== newList.length) return false;
13179
+ return oldList.every((oldListItem, index) => oldListItem.id === newList[index].id);
13180
+ };
13181
+ const getListItemLayout = listItems => {
13182
+ return listItems === null || listItems === void 0 ? void 0 : listItems.map((item, index) => ({
13183
+ i: item.id,
13184
+ x: 0,
13185
+ y: index,
13186
+ w: 1,
13187
+ h: 1
13188
+ }));
13189
+ };
13190
+
13156
13191
  const rootClassName$5 = 'dot-draggable-list';
13157
13192
  const listItemClassName = 'dot-draggable-list-item';
13158
13193
  const StyledDraggableList = styled.div`
@@ -13165,6 +13200,8 @@ const StyledDraggableList = styled.div`
13165
13200
  position: relative;
13166
13201
 
13167
13202
  .${listItemClassName} {
13203
+ width: 100% !important;
13204
+
13168
13205
  .dot-icon {
13169
13206
  color: ${theme.palette.layer.n700};
13170
13207
  }
@@ -13179,30 +13216,14 @@ const StyledDraggableList = styled.div`
13179
13216
 
13180
13217
  &.with-handle-grab-cursor ${draggableHandle} {
13181
13218
  cursor: grab;
13219
+ user-select: unset !important;
13220
+ -moz-user-select: unset !important;
13182
13221
  }
13183
13222
  }
13184
13223
  }
13185
13224
  `}
13186
13225
  `;
13187
13226
 
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
13227
  const DEFAULT_LIST_WIDTH = '100%';
13207
13228
  const DEFAULT_LIST_ITEM_HEIGHT = 36;
13208
13229
  const ListGridLayout = WidthProvider(GridLayout);
@@ -13238,7 +13259,9 @@ const DotDraggableList = ({
13238
13259
  "data-pendoid": dataPendoId,
13239
13260
  "data-testid": dataTestId,
13240
13261
  draggableHandle: draggableHandle,
13241
- width: listWidth,
13262
+ style: {
13263
+ width: listWidth
13264
+ },
13242
13265
  children: jsx(ListGridLayout, {
13243
13266
  className: "layout",
13244
13267
  draggableHandle: draggableHandle,
@@ -13248,9 +13271,6 @@ const DotDraggableList = ({
13248
13271
  margin: [0, 0],
13249
13272
  onLayoutChange: onChange && handleLayoutChange(),
13250
13273
  rowHeight: rowHeight,
13251
- style: {
13252
- width: listWidth
13253
- },
13254
13274
  children: orderedItems.map(({
13255
13275
  id: itemId,
13256
13276
  children
@@ -13258,13 +13278,8 @@ const DotDraggableList = ({
13258
13278
  return jsx(ListItem, {
13259
13279
  "data-pendoid": dataPendoId && `${dataPendoId}-item`,
13260
13280
  "data-testid": dataTestId && `${dataTestId}-item`,
13261
- button: true,
13262
13281
  children: renderNodeOrTypography(children),
13263
- className: listItemClasses,
13264
- disableRipple: true,
13265
- style: {
13266
- width: listWidth
13267
- }
13282
+ className: listItemClasses
13268
13283
  }, itemId);
13269
13284
  })
13270
13285
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "2.27.1",
3
+ "version": "3.0.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
  }
@@ -15,5 +15,7 @@ export interface AlertBannerProps extends CommonProps {
15
15
  severity: AlertBannerSeverity;
16
16
  /** when specified, will control the text that is used inside the alert banner */
17
17
  textVariant?: TypographyVariant;
18
+ /** when specified, will control the width of the encapsulated Alert component */
19
+ width?: string;
18
20
  }
19
- export declare const DotAlertBanner: ({ action, ariaLabel, children, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, onClose, roundedCorners, severity, textVariant, }: AlertBannerProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const DotAlertBanner: ({ action, ariaLabel, children, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, onClose, roundedCorners, severity, textVariant, width, }: AlertBannerProps) => import("react/jsx-runtime").JSX.Element;
@@ -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 {};
@@ -32,7 +32,7 @@ export type { DividerOrientation, DividerProps, DividerVariant, } from './divide
32
32
  export type { BadgeProps, BadgeOverlap, BadgeVariant } from './badge';
33
33
  export type { TruncateWithTooltipProps } from './truncate-with-tooltip';
34
34
  export type { DraggableItem, DraggableListChangeHandler, } from './draggable-list';
35
- export type { SnackbarProps, SnackbarSeverity, SnackbarOrigin, } from './snackbar';
35
+ export type { SnackbarProps, SnackbarSeverity, SnackbarOrigin, SnackbarPrimaryAction, SnackbarSecondaryAction, } from './snackbar';
36
36
  export type { CharactersLimit, InlineEditProps } from './inline-edit';
37
37
  export type { progressColorOptions, progressVariantOptions, ProgressProps, } from './progress';
38
38
  export type { FileItemProps, FileUploadError, FileUploadProps, ListItemFile, MappedFile, MappedListItemFile, } from './file-upload';
@@ -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 */
@@ -2,11 +2,19 @@ import { ReactNode } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
3
  import { SnackbarOrigin } from './';
4
4
  export type SnackbarSeverity = 'error' | 'warning' | 'info' | 'success';
5
+ export interface SnackbarPrimaryAction {
6
+ label: string;
7
+ onClick: () => void;
8
+ }
9
+ export interface SnackbarSecondaryAction {
10
+ href: string;
11
+ label: string;
12
+ }
5
13
  export interface SnackbarProps extends CommonProps {
6
- /** Property used for creating a custom action button. */
7
- action?: ReactNode;
8
14
  /** The anchor of the Snackbar. On smaller screens, the component grows to occupy all the available width, the horizontal alignment is ignored. */
9
15
  anchorOrigin?: SnackbarOrigin;
16
+ /** When specified, will set `top` property (in pixels) only for the vertical top origins */
17
+ anchorOriginTop?: number;
10
18
  /** The number of milliseconds to wait before automatically closing the snackbar. If null is passed, then the snackbar never automatically closes. If the prop is not passed at all, then snackbars close after 10 seconds (except error snackbar which never closes automatically). */
11
19
  autoHideDuration?: number | null;
12
20
  /** The message the user sees once the alert displays. */
@@ -14,12 +22,16 @@ export interface SnackbarProps extends CommonProps {
14
22
  /** If false, then snackbar does not close when clicking away. True by default. */
15
23
  hideOnClickAway?: boolean;
16
24
  /** A callback to handle closing the alert. */
17
- onClose?: () => void;
25
+ onClose: () => void;
18
26
  /** Boolean value to switch between opening and closing the alert. */
19
27
  open: boolean;
28
+ /** When specified, will render button underneath snackbar message */
29
+ primaryAction?: SnackbarPrimaryAction;
30
+ /** When specified, will render link next to primary action button */
31
+ secondaryAction?: SnackbarSecondaryAction;
20
32
  /** An alert level, indicating the importance of the message. */
21
33
  severity: SnackbarSeverity;
22
34
  /** Width of the encapsulated Alert component. */
23
35
  width?: string;
24
36
  }
25
- export declare const DotSnackbar: ({ action, anchorOrigin, ariaLabel, autoHideDuration, children, className, "data-testid": dataTestId, hideOnClickAway, onClose, open, severity, width, }: SnackbarProps) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const DotSnackbar: ({ anchorOrigin, anchorOriginTop, ariaLabel, autoHideDuration, children, className, "data-testid": dataTestId, hideOnClickAway, onClose, open, primaryAction, secondaryAction, severity, width, }: SnackbarProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,9 @@ import { Snackbar } from '@mui/material';
2
2
  import { SnackbarSeverity } from './Snackbar';
3
3
  export declare const rootClassName = "dot-snackbar";
4
4
  interface StyledProps {
5
+ $anchorOriginTop?: number;
5
6
  severity: SnackbarSeverity;
7
+ width?: string;
6
8
  }
7
9
  export declare const StyledSnackbar: import("styled-components").StyledComponent<typeof Snackbar, any, StyledProps, never>;
8
10
  export {};
@@ -1,4 +1,4 @@
1
1
  export type { SnackbarOrigin } from '@mui/material';
2
- export type { SnackbarProps, SnackbarSeverity } from './Snackbar';
2
+ export type { SnackbarProps, SnackbarSeverity, SnackbarPrimaryAction, SnackbarSecondaryAction, } from './Snackbar';
3
3
  export { DotSnackbar } from './Snackbar';
4
4
  export { DotSnackbarContainer, DotSnackbarProvider, useDotSnackbarContext, } from './SnackbarProvider';
@@ -0,0 +1,2 @@
1
+ import { SnackbarSeverity } from '../Snackbar';
2
+ export declare const getSnackbarTitleFromSeverity: (severity: SnackbarSeverity) => "Success" | "Warning" | "Error" | "Info";
@@ -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;