@digital-ai/dot-components 2.17.2 → 2.18.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/CHANGE_LOG.md +31 -17
- package/index.esm.js +297 -255
- package/index.umd.js +398 -353
- package/lib/components/list/List.d.ts +1 -3
- package/lib/components/list/ListDivider.d.ts +7 -0
- package/lib/components/list/ListItem.d.ts +2 -0
- package/lib/components/list/NestedList.d.ts +2 -0
- package/lib/components/list/utils/helpers.d.ts +1 -0
- package/lib/components/list/utils/models.d.ts +2 -0
- package/lib/components/sidebar/Sidebar.stories.data.d.ts +12 -1
- package/lib/components/table/Table.d.ts +4 -1
- package/lib/components/table/Table.stories.d.ts +1 -1
- package/lib/components/table/TableBody.d.ts +8 -5
- package/package.json +1 -1
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
3
|
import { useEffect, useState, useRef, useMemo, useContext, createContext, 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,
|
|
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, TableCell, TableRow, TableBody, TableSortLabel, TableHead, Table, Tabs, Tab, LinearProgress } 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, alpha, useTheme } from '@mui/material/styles';
|
|
@@ -1893,6 +1893,14 @@ const DotLink = ({
|
|
|
1893
1893
|
}), void 0);
|
|
1894
1894
|
};
|
|
1895
1895
|
|
|
1896
|
+
const CreateUUID = () => {
|
|
1897
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
1898
|
+
const r = Math.random() * 16 | 0,
|
|
1899
|
+
v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
1900
|
+
return v.toString(16);
|
|
1901
|
+
});
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1896
1904
|
const rootClassName$$ = 'dot-list';
|
|
1897
1905
|
const listItemRootClass = 'dot-list-item';
|
|
1898
1906
|
const nestedListClassName = 'dot-nested-list';
|
|
@@ -1902,7 +1910,7 @@ const StyledList = styled(List).withConfig({
|
|
|
1902
1910
|
componentId: "wxwqwr-0"
|
|
1903
1911
|
})(["", ""], ({
|
|
1904
1912
|
theme
|
|
1905
|
-
}) => css(["&.", "{background:", ";.dot-icon{color:", ";}&.", " .", "{padding-left:", ";}.", "
|
|
1913
|
+
}) => css(["&.", "{background:", ";.dot-icon{color:", ";}&.", " .", "{padding-left:", ";}.MuiCollapse-root{padding-top:", ";margin-bottom:", ";.MuiCollapse-wrapper{margin:", ";overflow:hidden;width:calc(100% - ", ");}.MuiListSubheader-root .MuiTypography-root{padding:", ";}}.MuiListSubheader-root{padding:0;.MuiTypography-root{padding:", ";}}}"], rootClassName$$, theme.palette.layer.n0, theme.palette.layer.n700, nestedListClassName, listItemRootClass, theme.spacing(4), theme.spacing(1), theme.spacing(-1), theme.spacing(0, 2), theme.spacing(4), theme.spacing(1, 0), theme.spacing(1)));
|
|
1906
1914
|
|
|
1907
1915
|
const getChevronIcon = (nestedListType, isOpened) => {
|
|
1908
1916
|
if (nestedListType !== 'expandable') {
|
|
@@ -1913,20 +1921,40 @@ const getChevronIcon = (nestedListType, isOpened) => {
|
|
|
1913
1921
|
}
|
|
1914
1922
|
return 'chevron-down';
|
|
1915
1923
|
};
|
|
1924
|
+
// Used in DotSidebar, DotList, DotListItem to determine
|
|
1925
|
+
// if the sidebar should be open or closed based on what target the user clicks
|
|
1926
|
+
const excludedClassNames = ['MuiPaper-root', 'MuiTypography-overline'];
|
|
1927
|
+
const shouldToggleOpen = classNames => {
|
|
1928
|
+
return !excludedClassNames.some(className => classNames.includes(className));
|
|
1929
|
+
};
|
|
1916
1930
|
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1931
|
+
const DEFAULT_TOOLTIP_PLACEMENT = 'top-start';
|
|
1932
|
+
|
|
1933
|
+
const DotListDivider = ({
|
|
1934
|
+
item,
|
|
1935
|
+
index
|
|
1936
|
+
}) => {
|
|
1937
|
+
if (item.text) {
|
|
1938
|
+
return jsx(ListSubheader, Object.assign({
|
|
1939
|
+
disableSticky: true
|
|
1940
|
+
}, {
|
|
1941
|
+
children: jsx(DotTypography, Object.assign({
|
|
1942
|
+
ariaRole: "heading",
|
|
1943
|
+
ariaLevel: 3,
|
|
1944
|
+
variant: "overline"
|
|
1945
|
+
}, {
|
|
1946
|
+
children: item.text
|
|
1947
|
+
}), void 0)
|
|
1948
|
+
}), void 0);
|
|
1949
|
+
}
|
|
1950
|
+
return jsx("li", {
|
|
1951
|
+
children: jsx(Divider, {
|
|
1952
|
+
"aria-hidden": true,
|
|
1953
|
+
"data-testid": `divider-${index}`,
|
|
1954
|
+
role: "separator"
|
|
1955
|
+
}, void 0)
|
|
1956
|
+
}, void 0);
|
|
1927
1957
|
};
|
|
1928
|
-
const StyledListItem = styledListItemElement(ListItem);
|
|
1929
|
-
const StyledListItemButton = styledListItemElement(ListItemButton);
|
|
1930
1958
|
|
|
1931
1959
|
const rootClassName$_ = 'dot-progress';
|
|
1932
1960
|
const StyledCircularProgress = styled(CircularProgress).withConfig({
|
|
@@ -2295,14 +2323,6 @@ const DotMenu = ({
|
|
|
2295
2323
|
}), void 0);
|
|
2296
2324
|
};
|
|
2297
2325
|
|
|
2298
|
-
const CreateUUID = () => {
|
|
2299
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
2300
|
-
const r = Math.random() * 16 | 0,
|
|
2301
|
-
v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
2302
|
-
return v.toString(16);
|
|
2303
|
-
});
|
|
2304
|
-
};
|
|
2305
|
-
|
|
2306
2326
|
const rootClassName$W = 'dot-drawer';
|
|
2307
2327
|
const StyledDrawer = styled(Drawer).withConfig({
|
|
2308
2328
|
displayName: "Drawerstyles__StyledDrawer",
|
|
@@ -2545,224 +2565,20 @@ const StyledDotDrawer = styled(DotDrawer).withConfig({
|
|
|
2545
2565
|
open
|
|
2546
2566
|
}) => css(["&.", "{.dot-drawer-paper{z-index:", ";animation:", ";}}"], nestedDrawerClassName, open ? levelFirst : levelBottom, open && css(["", " 0.2s cubic-bezier(1,0,1,.01);"], fadeIn)));
|
|
2547
2567
|
|
|
2548
|
-
const
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
ariaRole: "heading",
|
|
2559
|
-
ariaLevel: 3,
|
|
2560
|
-
variant: "overline"
|
|
2561
|
-
}, {
|
|
2562
|
-
children: item.text
|
|
2563
|
-
}), void 0)
|
|
2564
|
-
}), void 0);
|
|
2565
|
-
}
|
|
2566
|
-
return jsx("li", {
|
|
2567
|
-
children: jsx(Divider, {
|
|
2568
|
-
"aria-hidden": true,
|
|
2569
|
-
"data-testid": `divider-${index}`,
|
|
2570
|
-
role: "separator"
|
|
2571
|
-
}, void 0)
|
|
2572
|
-
}, void 0);
|
|
2573
|
-
};
|
|
2574
|
-
const DotList = ({
|
|
2575
|
-
ariaLabel,
|
|
2576
|
-
ariaRole: _ariaRole = 'list',
|
|
2577
|
-
children,
|
|
2578
|
-
className,
|
|
2579
|
-
component: _component = 'ul',
|
|
2580
|
-
'data-testid': dataTestId,
|
|
2581
|
-
dense: _dense = false,
|
|
2582
|
-
disablePadding: _disablePadding = false,
|
|
2583
|
-
items: _items = [],
|
|
2584
|
-
menuPlacement: _menuPlacement = 'right-start',
|
|
2585
|
-
nestedDrawerLeftSpacing: _nestedDrawerLeftSpacing = 240,
|
|
2586
|
-
nestedListType: _nestedListType = 'expandable',
|
|
2587
|
-
width: _width = 240
|
|
2588
|
-
}) => {
|
|
2589
|
-
const rootClasses = useStylesWithRootClass(rootClassName$$, className);
|
|
2590
|
-
const listWidth = typeof _width === 'number' ? `${_width}px` : _width;
|
|
2591
|
-
const listRef = useRef();
|
|
2592
|
-
const [listItemIndex, setListItemIndex] = useState(null);
|
|
2593
|
-
const updateSelectedListItem = currentIndex => {
|
|
2594
|
-
currentIndex === listItemIndex ? setListItemIndex(null) : setListItemIndex(currentIndex);
|
|
2595
|
-
};
|
|
2596
|
-
return jsxs(StyledList, Object.assign({
|
|
2597
|
-
"aria-label": ariaLabel,
|
|
2598
|
-
classes: {
|
|
2599
|
-
root: rootClasses
|
|
2600
|
-
},
|
|
2601
|
-
component: _component,
|
|
2602
|
-
"data-testid": dataTestId,
|
|
2603
|
-
dense: _dense,
|
|
2604
|
-
disablePadding: _disablePadding,
|
|
2605
|
-
ref: listRef,
|
|
2606
|
-
role: _ariaRole,
|
|
2607
|
-
style: {
|
|
2608
|
-
width: listWidth
|
|
2609
|
-
}
|
|
2610
|
-
}, {
|
|
2611
|
-
children: [_items.map((item, index) => {
|
|
2612
|
-
const handleListItemClick = e => {
|
|
2613
|
-
var _a;
|
|
2614
|
-
updateSelectedListItem(index);
|
|
2615
|
-
(_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, e);
|
|
2616
|
-
};
|
|
2617
|
-
const handleMenuLeave = event => {
|
|
2618
|
-
var _a, _b;
|
|
2619
|
-
// Remove index only if clicked element is not found within the list
|
|
2620
|
-
if (!((_a = listRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
|
|
2621
|
-
setListItemIndex(null);
|
|
2622
|
-
(_b = item.onMenuLeave) === null || _b === void 0 ? void 0 : _b.call(item, event);
|
|
2623
|
-
}
|
|
2624
|
-
};
|
|
2625
|
-
if (item.child) {
|
|
2626
|
-
return jsx("div", Object.assign({
|
|
2627
|
-
role: "listitem"
|
|
2628
|
-
}, {
|
|
2629
|
-
children: item.child
|
|
2630
|
-
}), `item-child-${index}`);
|
|
2631
|
-
}
|
|
2632
|
-
if (item.divider) {
|
|
2633
|
-
return jsx(DotListDivider, {
|
|
2634
|
-
index: index,
|
|
2635
|
-
item: item
|
|
2636
|
-
}, `divider-${index}`);
|
|
2637
|
-
}
|
|
2638
|
-
return jsx(DotListItem, {
|
|
2639
|
-
ariaLabel: item.text || item.primaryText,
|
|
2640
|
-
className: item.className,
|
|
2641
|
-
component: item.component,
|
|
2642
|
-
"data-testid": `${dataTestId}-item-${index}`,
|
|
2643
|
-
endIcon: item.endIcon,
|
|
2644
|
-
href: item.href,
|
|
2645
|
-
isOpened: listItemIndex === index,
|
|
2646
|
-
items: item.items,
|
|
2647
|
-
menuPlacement: _menuPlacement,
|
|
2648
|
-
nestedDrawerLeftSpacing: _nestedDrawerLeftSpacing,
|
|
2649
|
-
nestedListType: _nestedListType,
|
|
2650
|
-
onClick: item.href && !item.onClick ? null : handleListItemClick,
|
|
2651
|
-
onMenuLeave: handleMenuLeave,
|
|
2652
|
-
primaryText: item.primaryText,
|
|
2653
|
-
secondaryText: item.secondaryText,
|
|
2654
|
-
selected: item.selected,
|
|
2655
|
-
startIcon: item.startIcon,
|
|
2656
|
-
target: item.target,
|
|
2657
|
-
text: item.text,
|
|
2658
|
-
tooltip: item.tooltip,
|
|
2659
|
-
tooltipPlacement: item.tooltipPlacement || DEFAULT_TOOLTIP_PLACEMENT
|
|
2660
|
-
}, index);
|
|
2661
|
-
}), children]
|
|
2662
|
-
}), void 0);
|
|
2663
|
-
};
|
|
2664
|
-
const DotListItem = ({
|
|
2665
|
-
ariaLabel,
|
|
2666
|
-
ariaRole: _ariaRole2 = 'listitem',
|
|
2667
|
-
className,
|
|
2668
|
-
component: _component2 = 'li',
|
|
2669
|
-
'data-testid': dataTestId,
|
|
2670
|
-
divider: _divider = false,
|
|
2671
|
-
endIcon,
|
|
2672
|
-
href,
|
|
2673
|
-
isOpened,
|
|
2674
|
-
onClick,
|
|
2675
|
-
onMenuLeave,
|
|
2676
|
-
items: _items2 = [],
|
|
2677
|
-
menuPlacement,
|
|
2678
|
-
nestedDrawerLeftSpacing,
|
|
2679
|
-
nestedListType,
|
|
2680
|
-
primaryText,
|
|
2681
|
-
secondaryText,
|
|
2682
|
-
selected,
|
|
2683
|
-
startIcon,
|
|
2684
|
-
target,
|
|
2685
|
-
text,
|
|
2686
|
-
tooltip,
|
|
2687
|
-
tooltipPlacement: _tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT
|
|
2688
|
-
}) => {
|
|
2689
|
-
const hasChildren = _items2.length > 0;
|
|
2690
|
-
const isFlyout = nestedListType === 'menu' && hasChildren;
|
|
2691
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
2692
|
-
const showEndIcon = endIcon || hasChildren;
|
|
2693
|
-
const rootClasses = useStylesWithRootClass(listItemRootClass, className, nestedListType === 'expandable' && hasChildren ? 'expandable' : '', isOpened ? 'open' : '');
|
|
2694
|
-
const toggleOpen = event => setAnchorEl(event.currentTarget);
|
|
2695
|
-
const handleClick = event => {
|
|
2696
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
2697
|
-
toggleOpen(event);
|
|
2698
|
-
};
|
|
2699
|
-
const handleMenuLeave = event => onMenuLeave(event);
|
|
2700
|
-
const renderListItemText = () => primaryText && secondaryText ? jsx(ListItemText, {
|
|
2701
|
-
primary: primaryText,
|
|
2702
|
-
secondary: secondaryText
|
|
2703
|
-
}, void 0) : jsx(DotTypography, Object.assign({
|
|
2704
|
-
variant: "body1"
|
|
2705
|
-
}, {
|
|
2706
|
-
children: text
|
|
2707
|
-
}), void 0);
|
|
2708
|
-
const renderListItemEndIcon = () => {
|
|
2709
|
-
if (hasChildren || !endIcon) {
|
|
2710
|
-
return jsx(DotIcon, {
|
|
2711
|
-
iconId: hasChildren && getChevronIcon(nestedListType, isOpened)
|
|
2712
|
-
}, void 0);
|
|
2713
|
-
}
|
|
2714
|
-
return endIcon;
|
|
2715
|
-
};
|
|
2716
|
-
const renderListItemLink = jsxs(DotLink, Object.assign({
|
|
2717
|
-
className: listItemLinkClassName,
|
|
2718
|
-
href: href,
|
|
2719
|
-
target: target,
|
|
2720
|
-
underline: "none"
|
|
2721
|
-
}, {
|
|
2722
|
-
children: [startIcon && jsx(ListItemIcon, {
|
|
2723
|
-
children: startIcon
|
|
2724
|
-
}, void 0), renderListItemText(), showEndIcon && renderListItemEndIcon()]
|
|
2725
|
-
}), void 0);
|
|
2726
|
-
const ListItem = onClick || href ? StyledListItemButton : StyledListItem;
|
|
2727
|
-
return jsx(ListItem, Object.assign({
|
|
2728
|
-
"aria-label": ariaLabel || tooltip,
|
|
2729
|
-
classes: {
|
|
2730
|
-
root: rootClasses
|
|
2731
|
-
},
|
|
2732
|
-
component: _component2,
|
|
2733
|
-
"data-testid": dataTestId,
|
|
2734
|
-
divider: _divider,
|
|
2735
|
-
href: onClick ? null : href,
|
|
2736
|
-
onClick: onClick || !href ? handleClick : null,
|
|
2737
|
-
role: _ariaRole2,
|
|
2738
|
-
selected: isFlyout ? isOpened : selected,
|
|
2739
|
-
target: target
|
|
2740
|
-
}, {
|
|
2741
|
-
children: jsxs(Fragment, {
|
|
2742
|
-
children: [jsx(DotTooltip, Object.assign({
|
|
2743
|
-
"data-testid": `${dataTestId}-tooltip`,
|
|
2744
|
-
placement: _tooltipPlacement,
|
|
2745
|
-
title: tooltip
|
|
2746
|
-
}, {
|
|
2747
|
-
children: href && !onClick ? renderListItemLink : jsxs(Fragment, {
|
|
2748
|
-
children: [startIcon && jsx(ListItemIcon, {
|
|
2749
|
-
children: startIcon
|
|
2750
|
-
}, void 0), renderListItemText(), showEndIcon && renderListItemEndIcon()]
|
|
2751
|
-
}, void 0)
|
|
2752
|
-
}), void 0), hasChildren && jsx(NestedList, {
|
|
2753
|
-
anchorEl: anchorEl,
|
|
2754
|
-
ariaLabel: "nested list",
|
|
2755
|
-
"data-testid": "nestedList",
|
|
2756
|
-
items: _items2,
|
|
2757
|
-
menuPlacement: menuPlacement,
|
|
2758
|
-
nestedDrawerLeftSpacing: nestedDrawerLeftSpacing,
|
|
2759
|
-
onMenuLeave: handleMenuLeave,
|
|
2760
|
-
open: isOpened,
|
|
2761
|
-
type: nestedListType
|
|
2762
|
-
}, void 0)]
|
|
2763
|
-
}, void 0)
|
|
2764
|
-
}), void 0);
|
|
2568
|
+
const flyoutListItemClassName = 'dot-flyout-list-item';
|
|
2569
|
+
const flyoutItemLinkClassName = 'dot-flyout-item-link';
|
|
2570
|
+
const listItemLinkClassName = 'dot-list-item-link';
|
|
2571
|
+
const styledListItemElement = elementType => {
|
|
2572
|
+
return styled(elementType).withConfig({
|
|
2573
|
+
displayName: "ListItemstyles",
|
|
2574
|
+
componentId: "sc-1fawh8v-0"
|
|
2575
|
+
})(["", ""], ({
|
|
2576
|
+
theme
|
|
2577
|
+
}) => css(["&.", "{&.", "{padding:0;}.dot-tooltip{display:flex;width:100%;}p.MuiTypography-root{flex-grow:2;margin-bottom:0;}.", "{align-items:center;display:flex;flex-grow:2;}.", " .MuiIcon-root{margin-right:", ";}.dot-icon i:before{color:", ";}}"], listItemRootClass, flyoutListItemClassName, listItemLinkClassName, flyoutItemLinkClassName, theme.spacing(4), theme.palette.text.primary));
|
|
2765
2578
|
};
|
|
2579
|
+
const StyledListItem = styledListItemElement(ListItem);
|
|
2580
|
+
const StyledListItemButton = styledListItemElement(ListItemButton);
|
|
2581
|
+
|
|
2766
2582
|
const NestedList = ({
|
|
2767
2583
|
ariaLabel,
|
|
2768
2584
|
anchorEl,
|
|
@@ -2789,7 +2605,8 @@ const NestedList = ({
|
|
|
2789
2605
|
component: "div",
|
|
2790
2606
|
"data-testid": dataTestId,
|
|
2791
2607
|
disablePadding: true,
|
|
2792
|
-
items: items
|
|
2608
|
+
items: items,
|
|
2609
|
+
width: '100%'
|
|
2793
2610
|
}, parentItemIndex)
|
|
2794
2611
|
}), void 0);
|
|
2795
2612
|
}
|
|
@@ -2825,8 +2642,8 @@ const NestedList = ({
|
|
|
2825
2642
|
children: text
|
|
2826
2643
|
}), void 0)]
|
|
2827
2644
|
}), void 0)
|
|
2828
|
-
}), `${parentItemIndex}-${
|
|
2829
|
-
}), `${parentItemIndex}-${
|
|
2645
|
+
}), `${parentItemIndex}-${CreateUUID()}-tooltip`)
|
|
2646
|
+
}), `${parentItemIndex}-${CreateUUID()}`),
|
|
2830
2647
|
classes: '',
|
|
2831
2648
|
key: String(index)
|
|
2832
2649
|
};
|
|
@@ -2870,6 +2687,240 @@ const NestedList = ({
|
|
|
2870
2687
|
}
|
|
2871
2688
|
};
|
|
2872
2689
|
|
|
2690
|
+
const DotListItem = ({
|
|
2691
|
+
ariaLabel,
|
|
2692
|
+
ariaRole: _ariaRole = 'listitem',
|
|
2693
|
+
className,
|
|
2694
|
+
component: _component = 'li',
|
|
2695
|
+
'data-testid': dataTestId,
|
|
2696
|
+
divider: _divider = false,
|
|
2697
|
+
endIcon,
|
|
2698
|
+
href,
|
|
2699
|
+
isOpened: _isOpened = false,
|
|
2700
|
+
onClick,
|
|
2701
|
+
onMenuLeave,
|
|
2702
|
+
items: _items = [],
|
|
2703
|
+
menuPlacement,
|
|
2704
|
+
nestedDrawerLeftSpacing,
|
|
2705
|
+
nestedListType,
|
|
2706
|
+
primaryText,
|
|
2707
|
+
secondaryText,
|
|
2708
|
+
selected,
|
|
2709
|
+
startIcon,
|
|
2710
|
+
target,
|
|
2711
|
+
text,
|
|
2712
|
+
tooltip,
|
|
2713
|
+
tooltipPlacement: _tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT
|
|
2714
|
+
}) => {
|
|
2715
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
2716
|
+
const [navIsOpened, setNavIsOpened] = useState(_isOpened);
|
|
2717
|
+
const hasChildren = _items.length > 0;
|
|
2718
|
+
const isFlyout = nestedListType === 'menu' && hasChildren;
|
|
2719
|
+
const showEndIcon = endIcon || hasChildren;
|
|
2720
|
+
const rootClasses = useStylesWithRootClass(listItemRootClass, className, nestedListType === 'expandable' && hasChildren ? 'expandable' : '', navIsOpened ? 'open' : '');
|
|
2721
|
+
const toggleOpen = event => {
|
|
2722
|
+
setAnchorEl(event.currentTarget);
|
|
2723
|
+
setNavIsOpened(!navIsOpened);
|
|
2724
|
+
};
|
|
2725
|
+
const handleClick = event => {
|
|
2726
|
+
const eventTarget = event.target;
|
|
2727
|
+
event.stopPropagation();
|
|
2728
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
2729
|
+
// only toggle open if clicking on a link
|
|
2730
|
+
if (shouldToggleOpen(eventTarget.className)) {
|
|
2731
|
+
toggleOpen(event);
|
|
2732
|
+
}
|
|
2733
|
+
};
|
|
2734
|
+
const handleMenuLeave = event => {
|
|
2735
|
+
onMenuLeave(event);
|
|
2736
|
+
};
|
|
2737
|
+
const renderListItemText = () => primaryText && secondaryText ? jsx(ListItemText, {
|
|
2738
|
+
primary: primaryText,
|
|
2739
|
+
secondary: secondaryText
|
|
2740
|
+
}, void 0) : jsx(DotTypography, Object.assign({
|
|
2741
|
+
variant: "body1"
|
|
2742
|
+
}, {
|
|
2743
|
+
children: text
|
|
2744
|
+
}), void 0);
|
|
2745
|
+
const renderListItemEndIcon = () => {
|
|
2746
|
+
if (hasChildren || !endIcon) {
|
|
2747
|
+
return jsx(DotIcon, {
|
|
2748
|
+
iconId: hasChildren && getChevronIcon(nestedListType, navIsOpened)
|
|
2749
|
+
}, void 0);
|
|
2750
|
+
}
|
|
2751
|
+
return endIcon;
|
|
2752
|
+
};
|
|
2753
|
+
const renderListItemLink = jsxs(DotLink, Object.assign({
|
|
2754
|
+
ariaLabel: ariaLabel || tooltip,
|
|
2755
|
+
className: listItemLinkClassName,
|
|
2756
|
+
href: href,
|
|
2757
|
+
target: target,
|
|
2758
|
+
underline: "none"
|
|
2759
|
+
}, {
|
|
2760
|
+
children: [startIcon && jsx(ListItemIcon, {
|
|
2761
|
+
children: startIcon
|
|
2762
|
+
}, void 0), renderListItemText(), showEndIcon && renderListItemEndIcon()]
|
|
2763
|
+
}), void 0);
|
|
2764
|
+
const ListItem = onClick || href ? StyledListItemButton : StyledListItem;
|
|
2765
|
+
return jsxs(Fragment, {
|
|
2766
|
+
children: [jsx(ListItem, Object.assign({
|
|
2767
|
+
"aria-label": ariaLabel || tooltip,
|
|
2768
|
+
classes: {
|
|
2769
|
+
root: rootClasses
|
|
2770
|
+
},
|
|
2771
|
+
component: _component,
|
|
2772
|
+
"data-testid": dataTestId,
|
|
2773
|
+
divider: _divider,
|
|
2774
|
+
href: onClick ? null : href,
|
|
2775
|
+
onClick: onClick || !href ? handleClick : null,
|
|
2776
|
+
role: _ariaRole,
|
|
2777
|
+
selected: isFlyout ? navIsOpened : selected,
|
|
2778
|
+
target: target
|
|
2779
|
+
}, {
|
|
2780
|
+
children: jsx(DotTooltip, Object.assign({
|
|
2781
|
+
"data-testid": `${dataTestId}-tooltip`,
|
|
2782
|
+
placement: _tooltipPlacement,
|
|
2783
|
+
title: tooltip
|
|
2784
|
+
}, {
|
|
2785
|
+
children: href && !onClick ? renderListItemLink : jsxs(Fragment, {
|
|
2786
|
+
children: [startIcon && jsx(ListItemIcon, {
|
|
2787
|
+
children: startIcon
|
|
2788
|
+
}, void 0), renderListItemText(), showEndIcon && renderListItemEndIcon()]
|
|
2789
|
+
}, void 0)
|
|
2790
|
+
}), void 0)
|
|
2791
|
+
}), void 0), hasChildren && jsx(NestedList, {
|
|
2792
|
+
anchorEl: anchorEl,
|
|
2793
|
+
ariaLabel: "nested list",
|
|
2794
|
+
"data-testid": "nestedList",
|
|
2795
|
+
items: _items,
|
|
2796
|
+
menuPlacement: menuPlacement,
|
|
2797
|
+
nestedDrawerLeftSpacing: nestedDrawerLeftSpacing,
|
|
2798
|
+
onMenuLeave: handleMenuLeave,
|
|
2799
|
+
open: navIsOpened,
|
|
2800
|
+
type: nestedListType
|
|
2801
|
+
}, void 0)]
|
|
2802
|
+
}, void 0);
|
|
2803
|
+
};
|
|
2804
|
+
|
|
2805
|
+
const DotClickAwayListener = ({
|
|
2806
|
+
children,
|
|
2807
|
+
disableReactTree: _disableReactTree = false,
|
|
2808
|
+
onClickAway
|
|
2809
|
+
}) => {
|
|
2810
|
+
return jsx(ClickAwayListener, {
|
|
2811
|
+
children: children,
|
|
2812
|
+
disableReactTree: _disableReactTree,
|
|
2813
|
+
onClickAway: onClickAway
|
|
2814
|
+
}, void 0);
|
|
2815
|
+
};
|
|
2816
|
+
|
|
2817
|
+
const DotList = ({
|
|
2818
|
+
ariaLabel,
|
|
2819
|
+
ariaRole: _ariaRole = 'list',
|
|
2820
|
+
children,
|
|
2821
|
+
className,
|
|
2822
|
+
component: _component = 'ul',
|
|
2823
|
+
'data-testid': dataTestId,
|
|
2824
|
+
dense: _dense = false,
|
|
2825
|
+
disablePadding: _disablePadding = false,
|
|
2826
|
+
items: _items = [],
|
|
2827
|
+
menuPlacement: _menuPlacement = 'right-start',
|
|
2828
|
+
nestedDrawerLeftSpacing: _nestedDrawerLeftSpacing = 240,
|
|
2829
|
+
nestedListType: _nestedListType = 'expandable',
|
|
2830
|
+
width: _width = 240
|
|
2831
|
+
}) => {
|
|
2832
|
+
const rootClasses = useStylesWithRootClass(rootClassName$$, className);
|
|
2833
|
+
const listWidth = typeof _width === 'number' ? `${_width}px` : _width;
|
|
2834
|
+
const listRef = useRef();
|
|
2835
|
+
const [listItemIndex, setListItemIndex] = useState(null);
|
|
2836
|
+
const updateSelectedListItem = currentIndex => {
|
|
2837
|
+
currentIndex === listItemIndex ? setListItemIndex(null) : setListItemIndex(currentIndex);
|
|
2838
|
+
};
|
|
2839
|
+
const handleClickAway = () => {
|
|
2840
|
+
setListItemIndex(null);
|
|
2841
|
+
};
|
|
2842
|
+
return jsx(DotClickAwayListener, Object.assign({
|
|
2843
|
+
onClickAway: handleClickAway
|
|
2844
|
+
}, {
|
|
2845
|
+
children: jsxs(StyledList, Object.assign({
|
|
2846
|
+
"aria-label": ariaLabel,
|
|
2847
|
+
classes: {
|
|
2848
|
+
root: rootClasses
|
|
2849
|
+
},
|
|
2850
|
+
component: _component,
|
|
2851
|
+
"data-testid": dataTestId,
|
|
2852
|
+
dense: _dense,
|
|
2853
|
+
disablePadding: _disablePadding,
|
|
2854
|
+
ref: listRef,
|
|
2855
|
+
role: _ariaRole,
|
|
2856
|
+
style: {
|
|
2857
|
+
width: listWidth
|
|
2858
|
+
}
|
|
2859
|
+
}, {
|
|
2860
|
+
children: [_items.map((item, index) => {
|
|
2861
|
+
const handleListItemClick = e => {
|
|
2862
|
+
var _a;
|
|
2863
|
+
const target = e.target;
|
|
2864
|
+
e.stopPropagation();
|
|
2865
|
+
(_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, e);
|
|
2866
|
+
// If clicking on a nested list item, don't update the selected index
|
|
2867
|
+
// Do nothing if clicking on the drawer itself
|
|
2868
|
+
if (shouldToggleOpen(target.className)) {
|
|
2869
|
+
updateSelectedListItem(index);
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
const determineOnClick = item.href && !item.onClick ? null : handleListItemClick;
|
|
2873
|
+
const handleMenuLeave = event => {
|
|
2874
|
+
// TODO: Need to apply animation to open/close
|
|
2875
|
+
var _a, _b;
|
|
2876
|
+
// Remove index only if clicked element is not found within the list
|
|
2877
|
+
if (!((_a = listRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
|
|
2878
|
+
setListItemIndex(null);
|
|
2879
|
+
(_b = item.onMenuLeave) === null || _b === void 0 ? void 0 : _b.call(item, event);
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
if (item.child) {
|
|
2883
|
+
return jsx("div", Object.assign({
|
|
2884
|
+
onClick: item.onClick,
|
|
2885
|
+
role: "listitem"
|
|
2886
|
+
}, {
|
|
2887
|
+
children: item.child
|
|
2888
|
+
}), `item-child-${CreateUUID()}`);
|
|
2889
|
+
}
|
|
2890
|
+
if (item.divider) {
|
|
2891
|
+
return jsx(DotListDivider, {
|
|
2892
|
+
index: index,
|
|
2893
|
+
item: item
|
|
2894
|
+
}, `divider-${CreateUUID()}`);
|
|
2895
|
+
}
|
|
2896
|
+
return jsx(DotListItem, {
|
|
2897
|
+
ariaLabel: item.text || item.primaryText,
|
|
2898
|
+
className: item.className,
|
|
2899
|
+
component: item.component,
|
|
2900
|
+
"data-testid": `${dataTestId}-item-${index}`,
|
|
2901
|
+
endIcon: item.endIcon,
|
|
2902
|
+
href: item.href,
|
|
2903
|
+
isOpened: listItemIndex === index,
|
|
2904
|
+
items: item.items,
|
|
2905
|
+
menuPlacement: _menuPlacement,
|
|
2906
|
+
nestedDrawerLeftSpacing: _nestedDrawerLeftSpacing,
|
|
2907
|
+
nestedListType: _nestedListType,
|
|
2908
|
+
onClick: determineOnClick,
|
|
2909
|
+
onMenuLeave: handleMenuLeave,
|
|
2910
|
+
primaryText: item.primaryText,
|
|
2911
|
+
secondaryText: item.secondaryText,
|
|
2912
|
+
selected: item.selected,
|
|
2913
|
+
startIcon: item.startIcon,
|
|
2914
|
+
target: item.target,
|
|
2915
|
+
text: item.text,
|
|
2916
|
+
tooltip: item.tooltip,
|
|
2917
|
+
tooltipPlacement: item.tooltipPlacement || DEFAULT_TOOLTIP_PLACEMENT
|
|
2918
|
+
}, CreateUUID());
|
|
2919
|
+
}), children]
|
|
2920
|
+
}), void 0)
|
|
2921
|
+
}), void 0);
|
|
2922
|
+
};
|
|
2923
|
+
|
|
2873
2924
|
const DotInputLabel = ({
|
|
2874
2925
|
'data-testid': dataTestId,
|
|
2875
2926
|
disabled: _disabled = false,
|
|
@@ -8709,6 +8760,7 @@ const StyledTableBody = styled(TableBody).withConfig({
|
|
|
8709
8760
|
* to determine the functionality of the table.
|
|
8710
8761
|
*/
|
|
8711
8762
|
const DotTableBody = ({
|
|
8763
|
+
actionsMenuPlacement: _actionsMenuPlacement = 'bottom-end',
|
|
8712
8764
|
collapsibleTableBody,
|
|
8713
8765
|
columns,
|
|
8714
8766
|
data,
|
|
@@ -8762,7 +8814,7 @@ const DotTableBody = ({
|
|
|
8762
8814
|
disablePortal: true,
|
|
8763
8815
|
id: menuId,
|
|
8764
8816
|
menuItems: menuProps,
|
|
8765
|
-
menuPlacement:
|
|
8817
|
+
menuPlacement: _actionsMenuPlacement,
|
|
8766
8818
|
onLeave: onLeave,
|
|
8767
8819
|
open: open
|
|
8768
8820
|
}, void 0)]
|
|
@@ -9029,6 +9081,7 @@ function stableSort(array, comparator) {
|
|
|
9029
9081
|
* creating a common structure for tables in the system.
|
|
9030
9082
|
*/
|
|
9031
9083
|
const DotTable = ({
|
|
9084
|
+
actionsMenuPlacement: _actionsMenuPlacement = 'bottom-end',
|
|
9032
9085
|
ariaLabel,
|
|
9033
9086
|
bodyTypography: _bodyTypography = TABLE_TYPOGRAPHY_VARIANT,
|
|
9034
9087
|
className,
|
|
@@ -9210,6 +9263,7 @@ const DotTable = ({
|
|
|
9210
9263
|
sortable: _sortable,
|
|
9211
9264
|
typography: _headerTypography
|
|
9212
9265
|
}, void 0), jsx(DotTableBody, {
|
|
9266
|
+
actionsMenuPlacement: _actionsMenuPlacement,
|
|
9213
9267
|
collapsibleTableBody: collapsibleTableBody,
|
|
9214
9268
|
columns: columns,
|
|
9215
9269
|
data: tableData,
|
|
@@ -10581,16 +10635,4 @@ const DotTimePicker = ({
|
|
|
10581
10635
|
}), void 0);
|
|
10582
10636
|
};
|
|
10583
10637
|
|
|
10584
|
-
const DotClickAwayListener = ({
|
|
10585
|
-
children,
|
|
10586
|
-
disableReactTree: _disableReactTree = false,
|
|
10587
|
-
onClickAway
|
|
10588
|
-
}) => {
|
|
10589
|
-
return jsx(ClickAwayListener, {
|
|
10590
|
-
children: children,
|
|
10591
|
-
disableReactTree: _disableReactTree,
|
|
10592
|
-
onClickAway: onClickAway
|
|
10593
|
-
}, void 0);
|
|
10594
|
-
};
|
|
10595
|
-
|
|
10596
10638
|
export { Cell, CreateUUID, CssCell, CssGrid, CssGridDebug, DatePickerKeydownContext, Daytime, DotAccordion, DotActionToolbar, DotAlertBanner, DotAppLogo, DotAppSwitcher, DotAppToolbar, DotAutoComplete, DotAvatar, DotAvatarGroup, DotBadge, DotBreadcrumbs, DotButton, DotButtonToggle, DotCard, DotCardContent, DotCardFooter, DotCardHeader, DotCheckbox, DotCheckboxGroup, DotChip, DotClickAwayListener, DotConfirmationDialog, DotCopyButton, DotCoreApiProvider, DotDatePicker, DotDialog, DotDivider, DotDraggableList, DotDrawer, DotDynamicForm, DotEmptyState, DotFileListItem, DotFileUpload, DotForm, DotFormGroup, DotHeaderRow, DotIcon, DotIconButton, DotInlineEdit, DotInputSelect, DotInputText, DotLinearProgress, DotLink, DotList, DotMenu, DotNavigationRail, DotPill, DotPopper, DotProgress, DotProgressButton, DotRadioButton, DotRadioGroup, DotSidebar, DotSkeleton, DotSnackbar, DotSnackbarContainer, DotSnackbarProvider, DotSplitButton, DotStepper, DotSwitch, DotTable, DotTableAction, DotTableActions, DotTablePagination, DotTabs, DotThemeProvider, DotTimePicker, DotTooltip, DotTruncateWithTooltip, DotTypography, avatarColors, checkIfValidDate, lightThemeColors as lightColors, mockScrollIntoView, parseAutoCompleteValue, variables as themeVariables, typographyOptions, useDotCoreApiContext, useDotSnackbarContext };
|