@digital-ai/dot-components 3.21.0 → 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 +69 -15
- 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/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
|
@@ -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%"
|
|
@@ -11749,16 +11756,38 @@ function CloseButton({
|
|
|
11749
11756
|
onClick: () => onClose(dashboard)
|
|
11750
11757
|
}) : null;
|
|
11751
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
|
+
}
|
|
11752
11779
|
function DotDashboardActions({
|
|
11753
11780
|
applications,
|
|
11754
11781
|
dashboard,
|
|
11755
11782
|
isEdit = false,
|
|
11756
11783
|
canEdit = false,
|
|
11784
|
+
isFullscreen = false,
|
|
11757
11785
|
onClose,
|
|
11758
11786
|
onFavorite,
|
|
11759
11787
|
onStatusChanged,
|
|
11760
11788
|
onDeleted,
|
|
11761
11789
|
onDuplicated,
|
|
11790
|
+
onToggleFullscreen,
|
|
11762
11791
|
onViewMode
|
|
11763
11792
|
}) {
|
|
11764
11793
|
// NOTE: useState functions need to stay at the top of the file so that
|
|
@@ -11870,6 +11899,10 @@ function DotDashboardActions({
|
|
|
11870
11899
|
onStartDuplicate: handleStartDuplicateIfConfig,
|
|
11871
11900
|
onStartDelete: handleStartDeleteIfConfig,
|
|
11872
11901
|
onDetails: () => setOpenedDashboardDetails(dashboard)
|
|
11902
|
+
}), onToggleFullscreen && jsx(FullscreenButton, {
|
|
11903
|
+
dashboard: dashboard,
|
|
11904
|
+
isFullscreen: isFullscreen,
|
|
11905
|
+
onToggleFullscreen: onToggleFullscreen
|
|
11873
11906
|
}), onClose && jsx(CloseButton, {
|
|
11874
11907
|
dashboard: dashboard,
|
|
11875
11908
|
onClose: onClose
|
|
@@ -11894,6 +11927,16 @@ const StyledDashboardHeaderTitleSection = styled.div`
|
|
|
11894
11927
|
display: flex;
|
|
11895
11928
|
align-items: center;
|
|
11896
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
|
+
}
|
|
11897
11940
|
`}
|
|
11898
11941
|
`;
|
|
11899
11942
|
|
|
@@ -11902,11 +11945,14 @@ function DotDashboardHeader({
|
|
|
11902
11945
|
dashboard,
|
|
11903
11946
|
isEdit = false,
|
|
11904
11947
|
canEdit = false,
|
|
11948
|
+
isFullscreen = false,
|
|
11949
|
+
onBack,
|
|
11905
11950
|
onClose,
|
|
11906
11951
|
onFavorite,
|
|
11907
11952
|
onStatusChanged,
|
|
11908
11953
|
onDeleted,
|
|
11909
11954
|
onDuplicated,
|
|
11955
|
+
onToggleFullscreen,
|
|
11910
11956
|
onViewMode,
|
|
11911
11957
|
showStatus = false
|
|
11912
11958
|
}) {
|
|
@@ -11925,12 +11971,18 @@ function DotDashboardHeader({
|
|
|
11925
11971
|
useEffect(() => {
|
|
11926
11972
|
loadApplications(accountId);
|
|
11927
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
|
+
});
|
|
11928
11980
|
return jsxs(StyledDashboardHeader, {
|
|
11929
11981
|
children: [jsxs(StyledDashboardHeaderTitleSection, {
|
|
11930
|
-
children: [
|
|
11982
|
+
children: [jsxs(DotTypography, {
|
|
11931
11983
|
component: "h2",
|
|
11932
11984
|
variant: "h2",
|
|
11933
|
-
children: dashboard === null || dashboard === void 0 ? void 0 : dashboard.name
|
|
11985
|
+
children: [backButton, dashboard === null || dashboard === void 0 ? void 0 : dashboard.name]
|
|
11934
11986
|
}), showStatus && jsx(DotDashboardStatusPill, {
|
|
11935
11987
|
status: dashboard.lifecycle_state
|
|
11936
11988
|
})]
|
|
@@ -11939,11 +11991,13 @@ function DotDashboardHeader({
|
|
|
11939
11991
|
canEdit: canEdit,
|
|
11940
11992
|
dashboard: dashboard,
|
|
11941
11993
|
isEdit: isEdit,
|
|
11994
|
+
isFullscreen: isFullscreen,
|
|
11942
11995
|
onClose: onClose,
|
|
11943
11996
|
onFavorite: onFavorite,
|
|
11944
11997
|
onStatusChanged: onStatusChanged,
|
|
11945
11998
|
onDeleted: onDeleted,
|
|
11946
11999
|
onDuplicated: onDuplicated,
|
|
12000
|
+
onToggleFullscreen: onToggleFullscreen,
|
|
11947
12001
|
onViewMode: onViewMode
|
|
11948
12002
|
})]
|
|
11949
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 };
|
|
@@ -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;
|