@gooddata/sdk-ui-dashboard 11.60.0-alpha.3 → 11.60.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/esm/__version.d.ts +1 -1
- package/esm/__version.d.ts.map +1 -1
- package/esm/__version.js +1 -1
- package/esm/internal.d.ts +3 -0
- package/esm/internal.d.ts.map +1 -1
- package/esm/internal.js +3 -0
- package/esm/presentation/automations/shared/automationFilters/useAutomationFilters.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/useAutomationFilters.js +4 -8
- package/esm/presentation/automations/shared/automationFilters/utils.d.ts +1 -1
- package/esm/presentation/automations/shared/automationFilters/utils.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/utils.js +6 -1
- package/esm/presentation/dashboard/DashboardSidebar/CreationPanel.d.ts.map +1 -1
- package/esm/presentation/dashboard/DashboardSidebar/CreationPanel.js +9 -6
- package/esm/presentation/dashboard/DashboardSidebar/DashboardSidebarChrome.d.ts +31 -0
- package/esm/presentation/dashboard/DashboardSidebar/DashboardSidebarChrome.d.ts.map +1 -0
- package/esm/presentation/dashboard/DashboardSidebar/DashboardSidebarChrome.js +26 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarCollapseToggle.d.ts +3 -2
- package/esm/presentation/dashboard/DashboardSidebar/SidebarCollapseToggle.d.ts.map +1 -1
- package/esm/presentation/dashboard/DashboardSidebar/SidebarCollapseToggle.js +4 -7
- package/esm/presentation/dashboard/DashboardSidebar/SidebarConfigurationPanel.d.ts.map +1 -1
- package/esm/presentation/dashboard/DashboardSidebar/SidebarConfigurationPanel.js +5 -13
- package/esm/presentation/dashboard/DashboardSidebar/SidebarExpandTrigger.d.ts +7 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarExpandTrigger.d.ts.map +1 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarExpandTrigger.js +15 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarHeaderToggle.d.ts +12 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarHeaderToggle.d.ts.map +1 -0
- package/esm/presentation/dashboard/DashboardSidebar/SidebarHeaderToggle.js +21 -0
- package/esm/presentation/dashboard/DashboardSidebar/useResizableSidebarState.d.ts +21 -0
- package/esm/presentation/dashboard/DashboardSidebar/useResizableSidebarState.d.ts.map +1 -0
- package/esm/presentation/dashboard/DashboardSidebar/useResizableSidebarState.js +75 -0
- package/esm/presentation/dashboard/components/DashboardInner.d.ts.map +1 -1
- package/esm/presentation/dashboard/components/DashboardInner.js +4 -4
- package/esm/presentation/filterBar/attributeFilter/AttributeFilterParentFilteringContext.d.ts +9 -0
- package/esm/presentation/filterBar/attributeFilter/AttributeFilterParentFilteringContext.d.ts.map +1 -1
- package/esm/presentation/filterBar/attributeFilter/AttributeFilterParentFilteringContext.js +3 -0
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/AttributeFilterConfiguration.d.ts.map +1 -1
- package/esm/presentation/filterBar/attributeFilter/dashboardDropdownBody/configuration/AttributeFilterConfiguration.js +3 -7
- package/esm/presentation/flexibleLayout/dragAndDrop/DragLayer.d.ts.map +1 -1
- package/esm/presentation/flexibleLayout/dragAndDrop/DragLayer.js +2 -1
- package/esm/presentation/localization/bundles/de-DE.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/de-DE.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/de-DE.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/en-AU.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/en-AU.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/en-AU.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/en-GB.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/en-GB.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/en-GB.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/en-US.localization-bundle.d.ts +6 -2
- package/esm/presentation/localization/bundles/en-US.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/en-US.localization-bundle.js +8 -4
- package/esm/presentation/localization/bundles/es-419.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/es-419.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/es-419.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/es-ES.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/es-ES.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/es-ES.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/fi-FI.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/fi-FI.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/fi-FI.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/fr-CA.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/fr-CA.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/fr-CA.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/fr-FR.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/fr-FR.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/fr-FR.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/id-ID.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/id-ID.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/id-ID.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/it-IT.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/it-IT.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/it-IT.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/ja-JP.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/ja-JP.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/ja-JP.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/ko-KR.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/ko-KR.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/ko-KR.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/nl-NL.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/nl-NL.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/nl-NL.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/pl-PL.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/pl-PL.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/pl-PL.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/pt-BR.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/pt-BR.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/pt-BR.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/pt-PT.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/pt-PT.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/pt-PT.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/ru-RU.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/ru-RU.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/ru-RU.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/sl-SI.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/sl-SI.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/sl-SI.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/th-TH.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/th-TH.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/th-TH.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/tr-TR.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/tr-TR.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/tr-TR.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/uk-UA.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/uk-UA.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/uk-UA.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/vi-VN.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/vi-VN.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/vi-VN.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/zh-HK.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/zh-HK.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/zh-HK.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/zh-Hans.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/zh-Hans.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/zh-Hans.localization-bundle.js +2 -1
- package/esm/presentation/localization/bundles/zh-Hant.localization-bundle.d.ts +2 -1
- package/esm/presentation/localization/bundles/zh-Hant.localization-bundle.d.ts.map +1 -1
- package/esm/presentation/localization/bundles/zh-Hant.localization-bundle.js +2 -1
- package/esm/presentation/topBar/topBar/DefaultTopBar.d.ts.map +1 -1
- package/esm/presentation/topBar/topBar/DefaultTopBar.js +2 -1
- package/package.json +21 -21
- package/styles/css/main.css +52 -121
- package/styles/css/main.css.map +1 -1
- package/styles/css/sidebar.css +52 -121
- package/styles/css/sidebar.css.map +1 -1
- package/styles/scss/sidebar.scss +89 -152
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeChrome.d.ts +0 -23
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeChrome.d.ts.map +0 -1
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeChrome.js +0 -95
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeContext.d.ts +0 -42
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeContext.d.ts.map +0 -1
- package/esm/presentation/dashboard/DashboardSidebar/SidebarResizeContext.js +0 -136
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// (C) 2026 GoodData Corporation
|
|
3
|
-
import { useRef, useState, } from "react";
|
|
4
|
-
import cx from "classnames";
|
|
5
|
-
import { clamp } from "lodash-es";
|
|
6
|
-
import { makeKeyboardNavigation, useCloseOnEscape } from "@gooddata/sdk-ui-kit";
|
|
7
|
-
import { useResizableSidebar } from "./SidebarResizeContext.js";
|
|
8
|
-
const KEYBOARD_STEP = 10;
|
|
9
|
-
const handleSeparatorKeyboardNavigation = makeKeyboardNavigation({
|
|
10
|
-
shrink: [{ code: "ArrowLeft" }],
|
|
11
|
-
grow: [{ code: "ArrowRight" }],
|
|
12
|
-
minimize: [{ code: "Home" }],
|
|
13
|
-
maximize: [{ code: "End" }],
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* Internal presentational wrapper that drives the dashboard sidebar drag-to-resize interaction.
|
|
17
|
-
*
|
|
18
|
-
* Owns only the live drag state (drag width — used for the dashed indicator transform — and drag
|
|
19
|
-
* phase). The committed width, min/max, and the editor-canvas constraint live in the shared
|
|
20
|
-
* {@link useResizableSidebar} state, so the same value also feeds the content area's width via the
|
|
21
|
-
* `--gd-dashboard-sidebar-width` custom property.
|
|
22
|
-
*
|
|
23
|
-
* Renders `.gd-sidebar-container` itself so the resize handle can be positioned absolutely inside
|
|
24
|
-
* it — that element is sticky+100vh, so the handle (and the grip centered inside it) tracks the
|
|
25
|
-
* visible viewport rather than the full dashboard-root height.
|
|
26
|
-
*
|
|
27
|
-
* Drag uses `setPointerCapture` on the handle button so pointer events keep flowing to it even
|
|
28
|
-
* when the cursor leaves the 6 px hit area. No DOM overlay or window-level listener is needed.
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export function SidebarResizeChrome({ onContainerClick, children, }) {
|
|
33
|
-
const [dragWidth, setDragWidth] = useState(null);
|
|
34
|
-
const dragOriginRef = useRef(null);
|
|
35
|
-
const { width, min, max, canResize, setWidth, isCollapsed } = useResizableSidebar();
|
|
36
|
-
const isDragging = dragWidth !== null;
|
|
37
|
-
// Tear down the drag without committing — used when the user presses Escape.
|
|
38
|
-
const endDrag = () => {
|
|
39
|
-
dragOriginRef.current = null;
|
|
40
|
-
setDragWidth(null);
|
|
41
|
-
};
|
|
42
|
-
useCloseOnEscape(isDragging, endDrag);
|
|
43
|
-
const handleKeyDown = handleSeparatorKeyboardNavigation({
|
|
44
|
-
shrink: () => setWidth(width - KEYBOARD_STEP),
|
|
45
|
-
grow: () => setWidth(width + KEYBOARD_STEP),
|
|
46
|
-
minimize: () => setWidth(min),
|
|
47
|
-
maximize: () => setWidth(max),
|
|
48
|
-
});
|
|
49
|
-
const handlePointerDown = (event) => {
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
52
|
-
dragOriginRef.current = {
|
|
53
|
-
clientX: event.clientX,
|
|
54
|
-
width,
|
|
55
|
-
pointerId: event.pointerId,
|
|
56
|
-
};
|
|
57
|
-
setDragWidth(width);
|
|
58
|
-
};
|
|
59
|
-
const handlePointerMove = (event) => {
|
|
60
|
-
if (event.pointerId !== dragOriginRef.current?.pointerId) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const nextWidth = widthFromClientX(event.clientX);
|
|
64
|
-
if (nextWidth !== null) {
|
|
65
|
-
setDragWidth(nextWidth);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
// Commit the last dragged width, then tear the drag down. onLostPointerCapture fires whenever the
|
|
69
|
-
// captured pointer is released for any reason — pointerup, pointercancel, or the pointer being
|
|
70
|
-
// lost (e.g. the mouse released outside the iframe/window) — so the final width is always
|
|
71
|
-
// persisted even if a plain pointerup never reaches us.
|
|
72
|
-
const handleLostPointerCapture = () => {
|
|
73
|
-
if (dragWidth !== null) {
|
|
74
|
-
setWidth(dragWidth);
|
|
75
|
-
}
|
|
76
|
-
endDrag();
|
|
77
|
-
};
|
|
78
|
-
const widthFromClientX = (clientX) => {
|
|
79
|
-
const origin = dragOriginRef.current;
|
|
80
|
-
if (!origin) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return clamp(origin.width + (clientX - origin.clientX), min, max);
|
|
84
|
-
};
|
|
85
|
-
return (_jsx("div", { className: cx("gd-resizable-sidebar", {
|
|
86
|
-
"gd-resizable-sidebar--resizable": canResize,
|
|
87
|
-
"gd-resizable-sidebar--dragging": isDragging,
|
|
88
|
-
}), style: { width }, children: _jsxs("div", { className: cx("col gd-flex-item gd-sidebar-container gd-sidebar-container--resizable", {
|
|
89
|
-
"gd-sidebar-container--collapsed": isCollapsed,
|
|
90
|
-
}), onClick: onContainerClick, children: [children, _jsx("button", { type: "button", style: {
|
|
91
|
-
"--drag-x": `${isDragging ? dragWidth : width}px`,
|
|
92
|
-
}, className: cx("gd-resizable-sidebar__handle", {
|
|
93
|
-
"gd-resizable-sidebar__handle--dragging": isDragging,
|
|
94
|
-
}), disabled: !canResize, role: "separator", "aria-orientation": "vertical", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": width, onPointerDown: canResize ? handlePointerDown : undefined, onPointerMove: handlePointerMove, onLostPointerCapture: handleLostPointerCapture, onKeyDown: isDragging ? undefined : handleKeyDown, children: _jsx("span", { className: "gd-resizable-sidebar__handle-grip", "aria-hidden": "true" }) })] }) }));
|
|
95
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
interface IResizableSidebar {
|
|
3
|
-
width: number;
|
|
4
|
-
expandedWidth: number;
|
|
5
|
-
min: number;
|
|
6
|
-
max: number;
|
|
7
|
-
canResize: boolean;
|
|
8
|
-
setWidth: (width: number) => void;
|
|
9
|
-
canCollapse: boolean;
|
|
10
|
-
isCollapsed: boolean;
|
|
11
|
-
setCollapsed: (collapsed: boolean) => void;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Computes the sidebar width state — both the drag-to-resize bounds and the collapsed/expanded
|
|
15
|
-
* state of the panel. When the sidebar is neither resizable nor collapsible (not edit mode, both
|
|
16
|
-
* features are off, or it is replaced by the enhanced insight picker) it returns the static
|
|
17
|
-
* {@link STATIC_SIDEBAR} — no window resize listener, no width math.
|
|
18
|
-
*
|
|
19
|
-
* Reads the config store, so it must be called below the dashboard loading gate where the config is
|
|
20
|
-
* initialized.
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export declare function useResizableSidebarState(): IResizableSidebar;
|
|
25
|
-
/**
|
|
26
|
-
* Shares the resize state produced by {@link useResizableSidebarState} with descendants such as the
|
|
27
|
-
* resize handle, so it stays a single source of truth.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export declare function ResizableSidebarProvider({ value, children, }: {
|
|
32
|
-
value: IResizableSidebar;
|
|
33
|
-
children: ReactNode;
|
|
34
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
35
|
-
/**
|
|
36
|
-
* Returns the sidebar resize state, or {@link NON_RESIZABLE_SIDEBAR} when the sidebar is not resizable.
|
|
37
|
-
*
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export declare function useResizableSidebar(): IResizableSidebar;
|
|
41
|
-
export {};
|
|
42
|
-
//# sourceMappingURL=SidebarResizeContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarResizeContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation/dashboard/DashboardSidebar/SidebarResizeContext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA2D,MAAM,OAAO,CAAC;AAwChG,UAAU,iBAAiB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAmBD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,IAAI,iBAAiB,CAwE5D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EACrC,KAAK,EACL,QAAQ,GACX,EAAE;IACC,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;CACvB,2CAEA;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAEvD"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// (C) 2026 GoodData Corporation
|
|
3
|
-
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { clamp } from "lodash-es";
|
|
5
|
-
import { useLocalStorage } from "@gooddata/sdk-ui";
|
|
6
|
-
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
|
|
7
|
-
import { selectIsAiMode, selectSettings } from "../../../model/store/config/configSelectors.js";
|
|
8
|
-
import { selectIsInEditMode } from "../../../model/store/renderMode/renderModeSelectors.js";
|
|
9
|
-
const SIDEBAR_MIN_WIDTH = 230;
|
|
10
|
-
const SIDEBAR_MAX_WIDTH = 500;
|
|
11
|
-
const SIDEBAR_COLLAPSED_WIDTH = 48;
|
|
12
|
-
const EDITOR_MIN_WIDTH = 960;
|
|
13
|
-
const WIDTH_STORAGE_KEY = "gd-dashboard-sidebar-width";
|
|
14
|
-
const COLLAPSED_STORAGE_KEY = "gd-dashboard-sidebar-collapsed";
|
|
15
|
-
/**
|
|
16
|
-
* Returns the current `window.innerWidth`, kept in sync with the `resize` event. Only attaches the
|
|
17
|
-
* listener while `active`, so a non-resizable sidebar triggers no resize-driven re-renders.
|
|
18
|
-
*/
|
|
19
|
-
function useWindowWidth(active) {
|
|
20
|
-
const [width, setWidth] = useState(() => window.innerWidth);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!active) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
setWidth(window.innerWidth);
|
|
26
|
-
const handleResize = () => setWidth(window.innerWidth);
|
|
27
|
-
window.addEventListener("resize", handleResize);
|
|
28
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
29
|
-
}, [active]);
|
|
30
|
-
return width;
|
|
31
|
-
}
|
|
32
|
-
// Stable value used whenever the sidebar is neither resizable nor collapsible: it is fixed at the
|
|
33
|
-
// minimum width and ignores writes — so consumers never have to null-check.
|
|
34
|
-
const STATIC_SIDEBAR = {
|
|
35
|
-
width: SIDEBAR_MIN_WIDTH,
|
|
36
|
-
expandedWidth: SIDEBAR_MIN_WIDTH,
|
|
37
|
-
min: SIDEBAR_MIN_WIDTH,
|
|
38
|
-
max: SIDEBAR_MIN_WIDTH,
|
|
39
|
-
canResize: false,
|
|
40
|
-
setWidth: () => { },
|
|
41
|
-
canCollapse: false,
|
|
42
|
-
isCollapsed: false,
|
|
43
|
-
setCollapsed: () => { },
|
|
44
|
-
};
|
|
45
|
-
const ResizableSidebarContext = createContext(STATIC_SIDEBAR);
|
|
46
|
-
ResizableSidebarContext.displayName = "ResizableSidebarContext";
|
|
47
|
-
/**
|
|
48
|
-
* Computes the sidebar width state — both the drag-to-resize bounds and the collapsed/expanded
|
|
49
|
-
* state of the panel. When the sidebar is neither resizable nor collapsible (not edit mode, both
|
|
50
|
-
* features are off, or it is replaced by the enhanced insight picker) it returns the static
|
|
51
|
-
* {@link STATIC_SIDEBAR} — no window resize listener, no width math.
|
|
52
|
-
*
|
|
53
|
-
* Reads the config store, so it must be called below the dashboard loading gate where the config is
|
|
54
|
-
* initialized.
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
export function useResizableSidebarState() {
|
|
59
|
-
const settings = useDashboardSelector(selectSettings);
|
|
60
|
-
const isEditMode = useDashboardSelector(selectIsInEditMode);
|
|
61
|
-
const isAiMode = useDashboardSelector(selectIsAiMode);
|
|
62
|
-
const isSidebarResizeEnabled = settings?.enableDashboardSidebarResize ?? false;
|
|
63
|
-
const enableEnhancedInsightPicker = settings?.enableEnhancedInsightPicker ?? false;
|
|
64
|
-
const isGenAiRightPanelEnabled = settings?.enableGenAiRightPanel ?? false;
|
|
65
|
-
const hasCreationPanel = isEditMode && !enableEnhancedInsightPicker;
|
|
66
|
-
const isResizable = hasCreationPanel && isSidebarResizeEnabled;
|
|
67
|
-
const canCollapse = hasCreationPanel && isGenAiRightPanelEnabled;
|
|
68
|
-
const containerWidth = useWindowWidth(isResizable);
|
|
69
|
-
const [persistedWidth, setPersistedWidth] = useLocalStorage(WIDTH_STORAGE_KEY, SIDEBAR_MIN_WIDTH);
|
|
70
|
-
const [persistedCollapsed, setPersistedCollapsed] = useLocalStorage(COLLAPSED_STORAGE_KEY, false);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (isAiMode) {
|
|
73
|
-
setPersistedCollapsed(true);
|
|
74
|
-
}
|
|
75
|
-
}, [isAiMode, setPersistedCollapsed]);
|
|
76
|
-
return useMemo(() => {
|
|
77
|
-
const max = clamp(containerWidth - EDITOR_MIN_WIDTH, SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH);
|
|
78
|
-
const expandedWidth = isResizable ? clamp(persistedWidth, SIDEBAR_MIN_WIDTH, max) : SIDEBAR_MIN_WIDTH;
|
|
79
|
-
if (canCollapse && persistedCollapsed) {
|
|
80
|
-
return {
|
|
81
|
-
width: SIDEBAR_COLLAPSED_WIDTH,
|
|
82
|
-
expandedWidth,
|
|
83
|
-
min: SIDEBAR_COLLAPSED_WIDTH,
|
|
84
|
-
max: SIDEBAR_COLLAPSED_WIDTH,
|
|
85
|
-
canResize: false,
|
|
86
|
-
setWidth: () => { },
|
|
87
|
-
canCollapse,
|
|
88
|
-
isCollapsed: true,
|
|
89
|
-
setCollapsed: setPersistedCollapsed,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
if (!isResizable) {
|
|
93
|
-
return canCollapse
|
|
94
|
-
? { ...STATIC_SIDEBAR, canCollapse, setCollapsed: setPersistedCollapsed }
|
|
95
|
-
: STATIC_SIDEBAR;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
width: expandedWidth,
|
|
99
|
-
expandedWidth,
|
|
100
|
-
min: SIDEBAR_MIN_WIDTH,
|
|
101
|
-
max,
|
|
102
|
-
canResize: max > SIDEBAR_MIN_WIDTH,
|
|
103
|
-
// Clamp every write to the current bounds, so callers can't persist an out-of-range width and
|
|
104
|
-
// a non-resizable sidebar (max === min) collapses any value back to the minimum.
|
|
105
|
-
setWidth: (next) => setPersistedWidth(clamp(next, SIDEBAR_MIN_WIDTH, max)),
|
|
106
|
-
canCollapse,
|
|
107
|
-
isCollapsed: false,
|
|
108
|
-
setCollapsed: setPersistedCollapsed,
|
|
109
|
-
};
|
|
110
|
-
}, [
|
|
111
|
-
canCollapse,
|
|
112
|
-
persistedCollapsed,
|
|
113
|
-
setPersistedCollapsed,
|
|
114
|
-
isResizable,
|
|
115
|
-
containerWidth,
|
|
116
|
-
persistedWidth,
|
|
117
|
-
setPersistedWidth,
|
|
118
|
-
]);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Shares the resize state produced by {@link useResizableSidebarState} with descendants such as the
|
|
122
|
-
* resize handle, so it stays a single source of truth.
|
|
123
|
-
*
|
|
124
|
-
* @internal
|
|
125
|
-
*/
|
|
126
|
-
export function ResizableSidebarProvider({ value, children, }) {
|
|
127
|
-
return _jsx(ResizableSidebarContext.Provider, { value: value, children: children });
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Returns the sidebar resize state, or {@link NON_RESIZABLE_SIDEBAR} when the sidebar is not resizable.
|
|
131
|
-
*
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export function useResizableSidebar() {
|
|
135
|
-
return useContext(ResizableSidebarContext);
|
|
136
|
-
}
|