@digital-ai/dot-components 3.20.3 → 3.22.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 +83 -18
- package/package.json +1 -1
- package/src/lib/components/analytics/dashboard-actions/DashboardActions.d.ts +3 -1
- package/src/lib/components/analytics/dashboard-header/DashboardHeader.d.ts +2 -1
- package/src/lib/components/card/CardHeader.d.ts +3 -1
- package/src/lib/components/card/CardHeader.styles.d.ts +5 -1
- package/src/lib/components/list/List.d.ts +1 -1
- package/src/lib/components/list/utils/models.d.ts +2 -0
- package/src/lib/hooks/useKeyPress.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -31,7 +31,7 @@ function useStylesWithRootClass(name, className, ...args) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const checkIfOverflowPresentInElementTree = element => {
|
|
34
|
-
if (element.scrollWidth > element.clientWidth) {
|
|
34
|
+
if (element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight) {
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
for (const child of Array.from(element.children)) {
|
|
@@ -4221,6 +4221,22 @@ const DotClickAwayListener = ({
|
|
|
4221
4221
|
});
|
|
4222
4222
|
};
|
|
4223
4223
|
|
|
4224
|
+
const useKeyPress = (key, callback, dependencies) => {
|
|
4225
|
+
useEffect(() => {
|
|
4226
|
+
if (!key) return;
|
|
4227
|
+
const handleKeyPress = event => {
|
|
4228
|
+
const element = event.target;
|
|
4229
|
+
if (event.key === key && !['INPUT', 'TEXTAREA'].includes(element.nodeName) && !element.isContentEditable) {
|
|
4230
|
+
callback();
|
|
4231
|
+
}
|
|
4232
|
+
};
|
|
4233
|
+
window.addEventListener('keydown', handleKeyPress);
|
|
4234
|
+
return () => {
|
|
4235
|
+
window.removeEventListener('keydown', handleKeyPress);
|
|
4236
|
+
};
|
|
4237
|
+
}, [key, ...dependencies]);
|
|
4238
|
+
};
|
|
4239
|
+
|
|
4224
4240
|
const DotList = ({
|
|
4225
4241
|
ariaLabel,
|
|
4226
4242
|
ariaRole = 'list',
|
|
@@ -4231,6 +4247,7 @@ const DotList = ({
|
|
|
4231
4247
|
dense = false,
|
|
4232
4248
|
disablePadding = false,
|
|
4233
4249
|
items = [],
|
|
4250
|
+
keyForNestedReset,
|
|
4234
4251
|
menuPlacement = 'right-start',
|
|
4235
4252
|
nestedDrawerLeftSpacing = 240,
|
|
4236
4253
|
nestedListCloseOnClickAway = true,
|
|
@@ -4251,6 +4268,7 @@ const DotList = ({
|
|
|
4251
4268
|
const handleHrefClick = index => () => {
|
|
4252
4269
|
updateSelectedListItem(index);
|
|
4253
4270
|
};
|
|
4271
|
+
useKeyPress(keyForNestedReset, handleClickAway, []);
|
|
4254
4272
|
const list = jsxs(StyledList, {
|
|
4255
4273
|
"aria-label": ariaLabel,
|
|
4256
4274
|
classes: {
|
|
@@ -5902,19 +5920,7 @@ const DotSidebar = ({
|
|
|
5902
5920
|
onCollapseChange && onCollapseChange(isOpen);
|
|
5903
5921
|
setIsOpen(!isOpen);
|
|
5904
5922
|
};
|
|
5905
|
-
|
|
5906
|
-
if (!collapsable) return;
|
|
5907
|
-
const handleKeyPress = event => {
|
|
5908
|
-
const element = event.target;
|
|
5909
|
-
if (event.key === collapseKey && !['INPUT', 'TEXTAREA'].includes(element.nodeName) && !element.isContentEditable) {
|
|
5910
|
-
toggleNavCollapseState();
|
|
5911
|
-
}
|
|
5912
|
-
};
|
|
5913
|
-
window.addEventListener('keydown', handleKeyPress);
|
|
5914
|
-
return () => {
|
|
5915
|
-
window.removeEventListener('keydown', handleKeyPress);
|
|
5916
|
-
};
|
|
5917
|
-
}, [isOpen, collapsable]);
|
|
5923
|
+
useKeyPress(collapsable && collapseKey, toggleNavCollapseState, [isOpen, collapsable]);
|
|
5918
5924
|
const sidebarClasses = useStylesWithRootClass('side-nav', openClass);
|
|
5919
5925
|
const rootClasses = useStylesWithRootClass(rootClassName$$, openClass, className);
|
|
5920
5926
|
return jsxs(StyledSidebar, {
|
|
@@ -5958,6 +5964,7 @@ const DotSidebar = ({
|
|
|
5958
5964
|
dense: true,
|
|
5959
5965
|
disablePadding: true,
|
|
5960
5966
|
items: navItems,
|
|
5967
|
+
keyForNestedReset: collapseKey,
|
|
5961
5968
|
nestedDrawerLeftSpacing: sidebarWidth,
|
|
5962
5969
|
nestedListType: nestedListType,
|
|
5963
5970
|
width: "100%"
|
|
@@ -7654,7 +7661,8 @@ const DotCardFooter = ({
|
|
|
7654
7661
|
const rootClassName$Q = 'dot-card-header';
|
|
7655
7662
|
const StyledCardHeader = styled(CardHeader)`
|
|
7656
7663
|
${({
|
|
7657
|
-
theme
|
|
7664
|
+
theme,
|
|
7665
|
+
$maxTitleLines
|
|
7658
7666
|
}) => css`
|
|
7659
7667
|
&.${rootClassName$Q} {
|
|
7660
7668
|
.MuiCardHeader-content {
|
|
@@ -7663,6 +7671,14 @@ const StyledCardHeader = styled(CardHeader)`
|
|
|
7663
7671
|
.dot-card-subheader {
|
|
7664
7672
|
color: ${theme.palette.figma.typography.gray};
|
|
7665
7673
|
}
|
|
7674
|
+
|
|
7675
|
+
.dot-card-header-title {
|
|
7676
|
+
display: -webkit-box;
|
|
7677
|
+
-webkit-line-clamp: ${$maxTitleLines};
|
|
7678
|
+
-webkit-box-orient: vertical;
|
|
7679
|
+
white-space: normal;
|
|
7680
|
+
overflow-wrap: break-word;
|
|
7681
|
+
}
|
|
7666
7682
|
}
|
|
7667
7683
|
}
|
|
7668
7684
|
`}
|
|
@@ -7677,6 +7693,7 @@ const DotCardHeader = ({
|
|
|
7677
7693
|
subheader,
|
|
7678
7694
|
subheaderSize = 'large',
|
|
7679
7695
|
title,
|
|
7696
|
+
titleMaxLines = 1,
|
|
7680
7697
|
titleSize = 'large'
|
|
7681
7698
|
}) => {
|
|
7682
7699
|
const rootClasses = useStylesWithRootClass(rootClassName$Q, className);
|
|
@@ -7710,7 +7727,8 @@ const DotCardHeader = ({
|
|
|
7710
7727
|
noWrap: true,
|
|
7711
7728
|
variant: titleVariant
|
|
7712
7729
|
})
|
|
7713
|
-
})
|
|
7730
|
+
}),
|
|
7731
|
+
"$maxTitleLines": titleMaxLines
|
|
7714
7732
|
});
|
|
7715
7733
|
};
|
|
7716
7734
|
|
|
@@ -11738,16 +11756,38 @@ function CloseButton({
|
|
|
11738
11756
|
onClick: () => onClose(dashboard)
|
|
11739
11757
|
}) : null;
|
|
11740
11758
|
}
|
|
11759
|
+
function FullscreenButton({
|
|
11760
|
+
dashboard,
|
|
11761
|
+
isFullscreen = false,
|
|
11762
|
+
onToggleFullscreen
|
|
11763
|
+
}) {
|
|
11764
|
+
if (!onToggleFullscreen) {
|
|
11765
|
+
return null;
|
|
11766
|
+
}
|
|
11767
|
+
return isFullscreen ? jsx(DotIconButton, {
|
|
11768
|
+
iconId: "fullscreen-exit",
|
|
11769
|
+
"data-testid": 'dashboard-exit-fullscreen-button',
|
|
11770
|
+
tooltip: "Exit fullscreen mode",
|
|
11771
|
+
onClick: () => onToggleFullscreen(false)
|
|
11772
|
+
}) : jsx(DotIconButton, {
|
|
11773
|
+
iconId: "fullscreen-enter",
|
|
11774
|
+
"data-testid": 'dashboard-enter-fullscreen-button',
|
|
11775
|
+
tooltip: "Show dashboard in fullscreen mode",
|
|
11776
|
+
onClick: () => onToggleFullscreen(true)
|
|
11777
|
+
});
|
|
11778
|
+
}
|
|
11741
11779
|
function DotDashboardActions({
|
|
11742
11780
|
applications,
|
|
11743
11781
|
dashboard,
|
|
11744
11782
|
isEdit = false,
|
|
11745
11783
|
canEdit = false,
|
|
11784
|
+
isFullscreen = false,
|
|
11746
11785
|
onClose,
|
|
11747
11786
|
onFavorite,
|
|
11748
11787
|
onStatusChanged,
|
|
11749
11788
|
onDeleted,
|
|
11750
11789
|
onDuplicated,
|
|
11790
|
+
onToggleFullscreen,
|
|
11751
11791
|
onViewMode
|
|
11752
11792
|
}) {
|
|
11753
11793
|
// NOTE: useState functions need to stay at the top of the file so that
|
|
@@ -11859,6 +11899,10 @@ function DotDashboardActions({
|
|
|
11859
11899
|
onStartDuplicate: handleStartDuplicateIfConfig,
|
|
11860
11900
|
onStartDelete: handleStartDeleteIfConfig,
|
|
11861
11901
|
onDetails: () => setOpenedDashboardDetails(dashboard)
|
|
11902
|
+
}), onToggleFullscreen && jsx(FullscreenButton, {
|
|
11903
|
+
dashboard: dashboard,
|
|
11904
|
+
isFullscreen: isFullscreen,
|
|
11905
|
+
onToggleFullscreen: onToggleFullscreen
|
|
11862
11906
|
}), onClose && jsx(CloseButton, {
|
|
11863
11907
|
dashboard: dashboard,
|
|
11864
11908
|
onClose: onClose
|
|
@@ -11883,6 +11927,16 @@ const StyledDashboardHeaderTitleSection = styled.div`
|
|
|
11883
11927
|
display: flex;
|
|
11884
11928
|
align-items: center;
|
|
11885
11929
|
gap: ${theme.spacing(2)};
|
|
11930
|
+
|
|
11931
|
+
h2 {
|
|
11932
|
+
display: flex;
|
|
11933
|
+
align-items: center;
|
|
11934
|
+
gap: ${theme.spacing(0.5)};
|
|
11935
|
+
}
|
|
11936
|
+
|
|
11937
|
+
.dashboard-header-back-button .dot-icon {
|
|
11938
|
+
font-size: 20px;
|
|
11939
|
+
}
|
|
11886
11940
|
`}
|
|
11887
11941
|
`;
|
|
11888
11942
|
|
|
@@ -11891,11 +11945,14 @@ function DotDashboardHeader({
|
|
|
11891
11945
|
dashboard,
|
|
11892
11946
|
isEdit = false,
|
|
11893
11947
|
canEdit = false,
|
|
11948
|
+
isFullscreen = false,
|
|
11949
|
+
onBack,
|
|
11894
11950
|
onClose,
|
|
11895
11951
|
onFavorite,
|
|
11896
11952
|
onStatusChanged,
|
|
11897
11953
|
onDeleted,
|
|
11898
11954
|
onDuplicated,
|
|
11955
|
+
onToggleFullscreen,
|
|
11899
11956
|
onViewMode,
|
|
11900
11957
|
showStatus = false
|
|
11901
11958
|
}) {
|
|
@@ -11914,12 +11971,18 @@ function DotDashboardHeader({
|
|
|
11914
11971
|
useEffect(() => {
|
|
11915
11972
|
loadApplications(accountId);
|
|
11916
11973
|
}, []);
|
|
11974
|
+
const backButton = onBack && jsx(DotIconButton, {
|
|
11975
|
+
className: "dashboard-header-back-button",
|
|
11976
|
+
"data-testid": "dashboard-header-back-button",
|
|
11977
|
+
iconId: "back-solid",
|
|
11978
|
+
onClick: () => onBack(dashboard.id)
|
|
11979
|
+
});
|
|
11917
11980
|
return jsxs(StyledDashboardHeader, {
|
|
11918
11981
|
children: [jsxs(StyledDashboardHeaderTitleSection, {
|
|
11919
|
-
children: [
|
|
11982
|
+
children: [jsxs(DotTypography, {
|
|
11920
11983
|
component: "h2",
|
|
11921
11984
|
variant: "h2",
|
|
11922
|
-
children: dashboard === null || dashboard === void 0 ? void 0 : dashboard.name
|
|
11985
|
+
children: [backButton, dashboard === null || dashboard === void 0 ? void 0 : dashboard.name]
|
|
11923
11986
|
}), showStatus && jsx(DotDashboardStatusPill, {
|
|
11924
11987
|
status: dashboard.lifecycle_state
|
|
11925
11988
|
})]
|
|
@@ -11928,11 +11991,13 @@ function DotDashboardHeader({
|
|
|
11928
11991
|
canEdit: canEdit,
|
|
11929
11992
|
dashboard: dashboard,
|
|
11930
11993
|
isEdit: isEdit,
|
|
11994
|
+
isFullscreen: isFullscreen,
|
|
11931
11995
|
onClose: onClose,
|
|
11932
11996
|
onFavorite: onFavorite,
|
|
11933
11997
|
onStatusChanged: onStatusChanged,
|
|
11934
11998
|
onDeleted: onDeleted,
|
|
11935
11999
|
onDuplicated: onDuplicated,
|
|
12000
|
+
onToggleFullscreen: onToggleFullscreen,
|
|
11936
12001
|
onViewMode: onViewMode
|
|
11937
12002
|
})]
|
|
11938
12003
|
});
|
package/package.json
CHANGED
|
@@ -4,15 +4,17 @@ interface DashboardActionsCommonProps {
|
|
|
4
4
|
canEdit?: boolean;
|
|
5
5
|
dashboard: DashboardView;
|
|
6
6
|
isEdit?: boolean;
|
|
7
|
+
isFullscreen?: boolean;
|
|
7
8
|
onClose?: (dashboard: DashboardView) => void;
|
|
8
9
|
onDeleted?: (id: string, result: boolean) => void;
|
|
9
10
|
onDuplicated?: (dashboard: DashboardView, isDone?: boolean) => void;
|
|
10
11
|
onFavorite?: (id: string, value: boolean) => void;
|
|
11
12
|
onStatusChanged?: (dashboard: DashboardView) => void;
|
|
13
|
+
onToggleFullscreen?: (newValue: boolean) => void;
|
|
12
14
|
onViewMode?: (dashboard: DashboardView, mode: string) => void;
|
|
13
15
|
}
|
|
14
16
|
interface DashboardActionsProps extends DashboardActionsCommonProps {
|
|
15
17
|
applications: ApplicationModel[];
|
|
16
18
|
}
|
|
17
|
-
declare function DotDashboardActions({ applications, dashboard, isEdit, canEdit, onClose, onFavorite, onStatusChanged, onDeleted, onDuplicated, onViewMode, }: DashboardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare function DotDashboardActions({ applications, dashboard, isEdit, canEdit, isFullscreen, onClose, onFavorite, onStatusChanged, onDeleted, onDuplicated, onToggleFullscreen, onViewMode, }: DashboardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
export { DashboardActionsCommonProps, DotDashboardActions };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DashboardActionsCommonProps } from '../dashboard-actions/DashboardActions';
|
|
2
2
|
interface DashboardHeaderProps extends DashboardActionsCommonProps {
|
|
3
3
|
accountId?: string;
|
|
4
|
+
onBack?: (dashboardId?: string) => void;
|
|
4
5
|
showStatus?: boolean;
|
|
5
6
|
}
|
|
6
|
-
declare function DotDashboardHeader({ accountId, dashboard, isEdit, canEdit, onClose, onFavorite, onStatusChanged, onDeleted, onDuplicated, onViewMode, showStatus, }: DashboardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function DotDashboardHeader({ accountId, dashboard, isEdit, canEdit, isFullscreen, onBack, onClose, onFavorite, onStatusChanged, onDeleted, onDuplicated, onToggleFullscreen, onViewMode, showStatus, }: DashboardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export { DashboardHeaderProps, DotDashboardHeader };
|
|
@@ -13,7 +13,9 @@ export interface CardHeaderProps extends CommonProps {
|
|
|
13
13
|
subheaderSize?: SubheaderSize;
|
|
14
14
|
/** Card title */
|
|
15
15
|
title?: string;
|
|
16
|
+
/** Card title maximum number of lines (default is 1) */
|
|
17
|
+
titleMaxLines?: number;
|
|
16
18
|
/** Card title size */
|
|
17
19
|
titleSize?: TitleSize;
|
|
18
20
|
}
|
|
19
|
-
export declare const DotCardHeader: ({ action, ariaLabel, avatar, className, "data-testid": dataTestId, subheader, subheaderSize, title, titleSize, }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const DotCardHeader: ({ action, ariaLabel, avatar, className, "data-testid": dataTestId, subheader, subheaderSize, title, titleMaxLines, titleSize, }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare const rootClassName = "dot-card-header";
|
|
2
|
-
|
|
2
|
+
interface StyledCardHeaderProps {
|
|
3
|
+
$maxTitleLines: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const StyledCardHeader: import("styled-components").StyledComponent<import("@mui/material").OverridableCardHeader, any, StyledCardHeaderProps, never>;
|
|
6
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ListProps } from './utils/models';
|
|
2
|
-
export declare const DotList: ({ ariaLabel, ariaRole, children, className, component, "data-testid": dataTestId, dense, disablePadding, items, menuPlacement, nestedDrawerLeftSpacing, nestedListCloseOnClickAway, nestedListType, width, }: ListProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DotList: ({ ariaLabel, ariaRole, children, className, component, "data-testid": dataTestId, dense, disablePadding, items, keyForNestedReset, menuPlacement, nestedDrawerLeftSpacing, nestedListCloseOnClickAway, nestedListType, width, }: ListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,6 +17,8 @@ export interface ListProps extends CommonProps {
|
|
|
17
17
|
disablePadding?: boolean;
|
|
18
18
|
/** Array of list items displayed */
|
|
19
19
|
items?: Array<ListItemProps>;
|
|
20
|
+
/** If defined, list selection will reset when key is pressed */
|
|
21
|
+
keyForNestedReset?: string;
|
|
20
22
|
/** If nested list type is 'menu', determines the placement of the menu */
|
|
21
23
|
menuPlacement?: PopperPlacement;
|
|
22
24
|
/** If nested type is 'drawer', determines the width of the left spacing */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useKeyPress: (key: string, callback: () => void, dependencies: unknown[]) => void;
|