@gravity-ui/navigation 6.0.0-beta.0 → 6.0.0-beta.2
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/build/cjs/components/AsideHeader/AsideHeader.css +1 -1
- package/build/cjs/components/AsideHeader/AsideHeader.module.scss.js +1 -1
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js +52 -16
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.d.ts +20 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js +56 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.d.ts +7 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js +26 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.d.ts +1 -1
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.js +3 -3
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.d.ts +10 -1
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js +28 -6
- package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.css +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.d.ts +9 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.js +99 -28
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.module.scss.js +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js +27 -10
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.types.d.ts +8 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js +20 -7
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +6 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js +8 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.css +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.d.ts +12 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.js +24 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.module.scss.js +8 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.module.scss.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/index.d.ts +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +28 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +172 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/constants.d.ts +2 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/constants.js +3 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/constants.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.d.ts +27 -8
- package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.js +53 -24
- package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/utils.d.ts +14 -3
- package/build/cjs/components/AsideHeader/components/CompositeBar/utils.js +119 -35
- package/build/cjs/components/AsideHeader/components/CompositeBar/utils.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/FirstPanel.js +4 -3
- package/build/cjs/components/AsideHeader/components/FirstPanel.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/PageLayout/AsideFallback.css +1 -1
- package/build/cjs/components/AsideHeader/components/PageLayout/PageLayout.css +1 -1
- package/build/cjs/components/AsideHeader/components/PageLayout/PageLayoutAside.css +1 -1
- package/build/cjs/components/AsideHeader/types.d.ts +40 -0
- package/build/cjs/components/AsideHeader/types.js +4 -0
- package/build/cjs/components/AsideHeader/types.js.map +1 -1
- package/build/esm/components/AsideHeader/AsideHeader.css +1 -1
- package/build/esm/components/AsideHeader/AsideHeader.module.scss.js +1 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js +50 -14
- package/build/esm/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js.map +1 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.d.ts +20 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js +50 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js.map +1 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.d.ts +7 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js +23 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js.map +1 -0
- package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.d.ts +1 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.js +1 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.js.map +1 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.d.ts +10 -1
- package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js +28 -6
- package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.css +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.d.ts +9 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.js +102 -31
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.module.scss.js +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js +28 -11
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.types.d.ts +8 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js +20 -7
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +6 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js +6 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.css +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.d.ts +12 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.js +22 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.js.map +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.module.scss.js +4 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.module.scss.js.map +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/index.d.ts +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +28 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +170 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/constants.d.ts +2 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/constants.js +3 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/constants.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/grouping.d.ts +27 -8
- package/build/esm/components/AsideHeader/components/CompositeBar/grouping.js +52 -23
- package/build/esm/components/AsideHeader/components/CompositeBar/grouping.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/utils.d.ts +14 -3
- package/build/esm/components/AsideHeader/components/CompositeBar/utils.js +110 -29
- package/build/esm/components/AsideHeader/components/CompositeBar/utils.js.map +1 -1
- package/build/esm/components/AsideHeader/components/FirstPanel.js +4 -3
- package/build/esm/components/AsideHeader/components/FirstPanel.js.map +1 -1
- package/build/esm/components/AsideHeader/components/PageLayout/AsideFallback.css +1 -1
- package/build/esm/components/AsideHeader/components/PageLayout/PageLayout.css +1 -1
- package/build/esm/components/AsideHeader/components/PageLayout/PageLayoutAside.css +1 -1
- package/build/esm/components/AsideHeader/types.d.ts +40 -0
- package/build/esm/components/AsideHeader/types.js +3 -1
- package/build/esm/components/AsideHeader/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
type ScrollableWithScrollbarProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Extra dependencies that should trigger a recalculation of the bottom
|
|
7
|
+
* shadow and custom scrollbar thumb (e.g. when the rendered items change).
|
|
8
|
+
*/
|
|
9
|
+
recalcDeps?: React.DependencyList;
|
|
10
|
+
};
|
|
11
|
+
export declare const ScrollableWithScrollbar: FC<ScrollableWithScrollbarProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import './ScrollableWithScrollbar.css';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { createBlock } from '../../../../utils/cn.js';
|
|
4
|
+
import { useScrollableScrollbarSync } from './useScrollableScrollbarSync.js';
|
|
5
|
+
import styles from './ScrollableWithScrollbar.module.scss.js';
|
|
6
|
+
|
|
7
|
+
const b = createBlock('scrollable-with-scrollbar', styles);
|
|
8
|
+
const EMPTY_DEPS = [];
|
|
9
|
+
// Hides the native scrollbar and renders a custom thumb synced with the
|
|
10
|
+
// underlying scroll position. The scroll itself stays native (wheel / touch /
|
|
11
|
+
// keyboard) — only the visual indicator and drag handling are custom, so the
|
|
12
|
+
// reserved gutter width is identical across OS / browser scrollbar settings.
|
|
13
|
+
const ScrollableWithScrollbar = ({ children, className, recalcDeps = EMPTY_DEPS, }) => {
|
|
14
|
+
const { scrollRef, trackRef, thumbRef, hasContentBelow, overflows, thumb, scheduleUpdate, handleThumbPointerDown, handleTrackPointerDown, } = useScrollableScrollbarSync(recalcDeps);
|
|
15
|
+
return (React__default.createElement("div", { className: b({ 'bottom-shadow': hasContentBelow }, className) },
|
|
16
|
+
React__default.createElement("div", { ref: scrollRef, className: b('scrollable-inner'), onScroll: scheduleUpdate }, children),
|
|
17
|
+
overflows ? (React__default.createElement("div", { ref: trackRef, className: b('scrollbar-track'), onPointerDown: handleTrackPointerDown, "aria-hidden": "true" },
|
|
18
|
+
React__default.createElement("div", { ref: thumbRef, className: b('scrollbar-thumb'), style: { transform: `translateY(${thumb.top}px)`, height: thumb.height }, onPointerDown: handleThumbPointerDown }))) : null));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { ScrollableWithScrollbar };
|
|
22
|
+
//# sourceMappingURL=ScrollableWithScrollbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableWithScrollbar.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/ScrollableWithScrollbar.tsx"],"sourcesContent":["import React, {FC, ReactNode} from 'react';\n\nimport {createBlock} from '../../../../utils/cn';\n\nimport {useScrollableScrollbarSync} from './useScrollableScrollbarSync';\n\nimport styles from './ScrollableWithScrollbar.module.scss';\n\nconst b = createBlock('scrollable-with-scrollbar', styles);\n\nconst EMPTY_DEPS: React.DependencyList = [];\n\ntype ScrollableWithScrollbarProps = {\n children: ReactNode;\n className?: string;\n /**\n * Extra dependencies that should trigger a recalculation of the bottom\n * shadow and custom scrollbar thumb (e.g. when the rendered items change).\n */\n recalcDeps?: React.DependencyList;\n};\n\n// Hides the native scrollbar and renders a custom thumb synced with the\n// underlying scroll position. The scroll itself stays native (wheel / touch /\n// keyboard) — only the visual indicator and drag handling are custom, so the\n// reserved gutter width is identical across OS / browser scrollbar settings.\nexport const ScrollableWithScrollbar: FC<ScrollableWithScrollbarProps> = ({\n children,\n className,\n recalcDeps = EMPTY_DEPS,\n}) => {\n const {\n scrollRef,\n trackRef,\n thumbRef,\n hasContentBelow,\n overflows,\n thumb,\n scheduleUpdate,\n handleThumbPointerDown,\n handleTrackPointerDown,\n } = useScrollableScrollbarSync(recalcDeps);\n\n return (\n <div className={b({'bottom-shadow': hasContentBelow}, className)}>\n <div ref={scrollRef} className={b('scrollable-inner')} onScroll={scheduleUpdate}>\n {children}\n </div>\n\n {overflows ? (\n <div\n ref={trackRef}\n className={b('scrollbar-track')}\n onPointerDown={handleTrackPointerDown}\n aria-hidden=\"true\"\n >\n <div\n ref={thumbRef}\n className={b('scrollbar-thumb')}\n style={{transform: `translateY(${thumb.top}px)`, height: thumb.height}}\n onPointerDown={handleThumbPointerDown}\n />\n </div>\n ) : null}\n </div>\n );\n};\n"],"names":["React"],"mappings":";;;;;AAQA,MAAM,CAAC,GAAG,WAAW,CAAC,2BAA2B,EAAE,MAAM,CAAC;AAE1D,MAAM,UAAU,GAAyB,EAAE;AAY3C;AACA;AACA;AACA;AACO,MAAM,uBAAuB,GAAqC,CAAC,EACtE,QAAQ,EACR,SAAS,EACT,UAAU,GAAG,UAAU,GAC1B,KAAI;IACD,MAAM,EACF,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,SAAS,EACT,KAAK,EACL,cAAc,EACd,sBAAsB,EACtB,sBAAsB,GACzB,GAAG,0BAA0B,CAAC,UAAU,CAAC;AAE1C,IAAA,QACIA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,CAAC,CAAC,EAAC,eAAe,EAAE,eAAe,EAAC,EAAE,SAAS,CAAC,EAAA;AAC5D,QAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAA,EAC1E,QAAQ,CACP;QAEL,SAAS,IACNA,sCACI,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAC/B,aAAa,EAAE,sBAAsB,iBACzB,MAAM,EAAA;AAElB,YAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACI,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAC/B,KAAK,EAAE,EAAC,SAAS,EAAE,CAAA,WAAA,EAAc,KAAK,CAAC,GAAG,CAAK,GAAA,CAAA,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAC,EACtE,aAAa,EAAE,sBAAsB,EACvC,CAAA,CACA,IACN,IAAI,CACN;AAEd;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var styles = {"gn-scrollable-with-scrollbar":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar___S-GKS","gnScrollableWithScrollbar":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar___S-GKS","gn-scrollable-with-scrollbar_bottom-shadow":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar_bottom-shadow___YoCCZ","gnScrollableWithScrollbarBottomShadow":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar_bottom-shadow___YoCCZ","gn-scrollable-with-scrollbar__scrollable-inner":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollable-inner___yRIza","gnScrollableWithScrollbarScrollableInner":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollable-inner___yRIza","gn-scrollable-with-scrollbar__scrollbar-track":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollbar-track___u6MVN","gnScrollableWithScrollbarScrollbarTrack":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollbar-track___u6MVN","gn-scrollable-with-scrollbar__scrollbar-thumb":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollbar-thumb___bLf6h","gnScrollableWithScrollbarScrollbarThumb":"ScrollableWithScrollbar-module__gn-scrollable-with-scrollbar__scrollbar-thumb___bLf6h"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
4
|
+
//# sourceMappingURL=ScrollableWithScrollbar.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableWithScrollbar.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ScrollableWithScrollbar } from './ScrollableWithScrollbar';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ThumbGeometry = {
|
|
3
|
+
top: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
type UseScrollableScrollbarSyncResult = {
|
|
7
|
+
scrollRef: React.RefObject<HTMLDivElement>;
|
|
8
|
+
trackRef: React.RefObject<HTMLDivElement>;
|
|
9
|
+
thumbRef: React.RefObject<HTMLDivElement>;
|
|
10
|
+
hasContentBelow: boolean;
|
|
11
|
+
overflows: boolean;
|
|
12
|
+
thumb: ThumbGeometry;
|
|
13
|
+
scheduleUpdate: () => void;
|
|
14
|
+
handleThumbPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
15
|
+
handleTrackPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Keeps a custom scrollbar thumb and bottom shadow in sync with a native
|
|
19
|
+
* scroll layer. The scroll element handles touch/keyboard; wheel events on the
|
|
20
|
+
* overlay track are forwarded to it (the track sits above the scroller, so
|
|
21
|
+
* they would not scroll otherwise). Wheel, touch, and keyboard on the
|
|
22
|
+
* scrollable area itself are unchanged.
|
|
23
|
+
*
|
|
24
|
+
* @param recalcDeps - extra deps that should trigger thumb/shadow recalculation
|
|
25
|
+
* @returns refs, scroll state, thumb geometry, and pointer handlers for the UI
|
|
26
|
+
*/
|
|
27
|
+
export declare function useScrollableScrollbarSync(recalcDeps?: React.DependencyList): UseScrollableScrollbarSyncResult;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useRef, useState, useCallback, useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const EMPTY_DEPS = [];
|
|
4
|
+
const MIN_THUMB_HEIGHT = 24;
|
|
5
|
+
/**
|
|
6
|
+
* Keeps a custom scrollbar thumb and bottom shadow in sync with a native
|
|
7
|
+
* scroll layer. The scroll element handles touch/keyboard; wheel events on the
|
|
8
|
+
* overlay track are forwarded to it (the track sits above the scroller, so
|
|
9
|
+
* they would not scroll otherwise). Wheel, touch, and keyboard on the
|
|
10
|
+
* scrollable area itself are unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @param recalcDeps - extra deps that should trigger thumb/shadow recalculation
|
|
13
|
+
* @returns refs, scroll state, thumb geometry, and pointer handlers for the UI
|
|
14
|
+
*/
|
|
15
|
+
function useScrollableScrollbarSync(recalcDeps = EMPTY_DEPS) {
|
|
16
|
+
const scrollRef = useRef(null);
|
|
17
|
+
const trackRef = useRef(null);
|
|
18
|
+
const thumbRef = useRef(null);
|
|
19
|
+
const [hasContentBelow, setHasContentBelow] = useState(false);
|
|
20
|
+
const [overflows, setOverflows] = useState(false);
|
|
21
|
+
const [thumb, setThumb] = useState({ top: 0, height: 0 });
|
|
22
|
+
const rafIdRef = useRef(null);
|
|
23
|
+
const scheduleUpdate = useCallback(() => {
|
|
24
|
+
if (rafIdRef.current !== null) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
rafIdRef.current = requestAnimationFrame(() => {
|
|
28
|
+
rafIdRef.current = null;
|
|
29
|
+
const el = scrollRef.current;
|
|
30
|
+
if (!el) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { scrollTop, scrollHeight, clientHeight } = el;
|
|
34
|
+
const isOverflowing = scrollHeight > clientHeight;
|
|
35
|
+
// `-1` guards against subpixel rounding at the bottom.
|
|
36
|
+
const notAtBottom = scrollTop + clientHeight < scrollHeight - 1;
|
|
37
|
+
setOverflows(isOverflowing);
|
|
38
|
+
setHasContentBelow(isOverflowing && notAtBottom);
|
|
39
|
+
if (!isOverflowing) {
|
|
40
|
+
setThumb({ top: 0, height: 0 });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const ratio = clientHeight / scrollHeight;
|
|
44
|
+
const rawHeight = clientHeight * ratio;
|
|
45
|
+
const height = Math.max(rawHeight, MIN_THUMB_HEIGHT);
|
|
46
|
+
const maxTop = clientHeight - height;
|
|
47
|
+
const scrollRatio = scrollHeight - clientHeight > 0 ? scrollTop / (scrollHeight - clientHeight) : 0;
|
|
48
|
+
const top = maxTop * scrollRatio;
|
|
49
|
+
setThumb({ top, height });
|
|
50
|
+
});
|
|
51
|
+
}, []);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const el = scrollRef.current;
|
|
54
|
+
if (!el) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
scheduleUpdate();
|
|
58
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const observer = new ResizeObserver(scheduleUpdate);
|
|
62
|
+
observer.observe(el);
|
|
63
|
+
return () => observer.disconnect();
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [scheduleUpdate, ...recalcDeps]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
return () => {
|
|
68
|
+
if (rafIdRef.current !== null) {
|
|
69
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
70
|
+
rafIdRef.current = null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
// Wheel events do not reach the native scroll layer when the cursor is over
|
|
75
|
+
// the overlay track — forward them explicitly. `passive: false` is required
|
|
76
|
+
// so `preventDefault` works in all browsers.
|
|
77
|
+
useLayoutEffect(() => {
|
|
78
|
+
if (!overflows) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const track = trackRef.current;
|
|
82
|
+
const scrollEl = scrollRef.current;
|
|
83
|
+
if (!track || !scrollEl) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const onWheel = (e) => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
scrollEl.scrollTop += e.deltaY;
|
|
89
|
+
};
|
|
90
|
+
track.addEventListener('wheel', onWheel, { passive: false });
|
|
91
|
+
return () => track.removeEventListener('wheel', onWheel);
|
|
92
|
+
}, [overflows]);
|
|
93
|
+
const cancelProgrammaticSmoothScroll = useCallback((scrollEl) => {
|
|
94
|
+
const top = scrollEl.scrollTop;
|
|
95
|
+
scrollEl.scrollTo({ top, behavior: 'auto' });
|
|
96
|
+
}, []);
|
|
97
|
+
const handleThumbPointerDown = useCallback((event) => {
|
|
98
|
+
const scrollEl = scrollRef.current;
|
|
99
|
+
const thumbEl = thumbRef.current;
|
|
100
|
+
if (!scrollEl || !thumbEl || event.button !== 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
cancelProgrammaticSmoothScroll(scrollEl);
|
|
106
|
+
const startY = event.clientY;
|
|
107
|
+
const startScrollTop = scrollEl.scrollTop;
|
|
108
|
+
const { scrollHeight, clientHeight } = scrollEl;
|
|
109
|
+
const thumbHeight = thumbEl.getBoundingClientRect().height;
|
|
110
|
+
const trackHeight = clientHeight;
|
|
111
|
+
const maxThumbTop = trackHeight - thumbHeight;
|
|
112
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
113
|
+
if (maxThumbTop <= 0 || maxScrollTop <= 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const handlePointerMove = (moveEvent) => {
|
|
117
|
+
const deltaY = moveEvent.clientY - startY;
|
|
118
|
+
const deltaScroll = (deltaY / maxThumbTop) * maxScrollTop;
|
|
119
|
+
scrollEl.scrollTop = startScrollTop + deltaScroll;
|
|
120
|
+
};
|
|
121
|
+
const handlePointerUp = () => {
|
|
122
|
+
window.removeEventListener('pointermove', handlePointerMove);
|
|
123
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
124
|
+
window.removeEventListener('pointercancel', handlePointerUp);
|
|
125
|
+
};
|
|
126
|
+
window.addEventListener('pointermove', handlePointerMove);
|
|
127
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
128
|
+
window.addEventListener('pointercancel', handlePointerUp);
|
|
129
|
+
}, [cancelProgrammaticSmoothScroll]);
|
|
130
|
+
const handleTrackPointerDown = useCallback((event) => {
|
|
131
|
+
const scrollEl = scrollRef.current;
|
|
132
|
+
const thumbEl = thumbRef.current;
|
|
133
|
+
if (!scrollEl ||
|
|
134
|
+
!thumbEl ||
|
|
135
|
+
event.button !== 0 ||
|
|
136
|
+
event.target !== event.currentTarget) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
cancelProgrammaticSmoothScroll(scrollEl);
|
|
140
|
+
const trackRect = event.currentTarget.getBoundingClientRect();
|
|
141
|
+
const thumbHeight = thumbEl.getBoundingClientRect().height;
|
|
142
|
+
const clickY = event.clientY - trackRect.top;
|
|
143
|
+
const targetThumbTop = Math.max(0, Math.min(clickY - thumbHeight / 2, trackRect.height - thumbHeight));
|
|
144
|
+
const maxThumbTop = trackRect.height - thumbHeight;
|
|
145
|
+
const maxScrollTop = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
146
|
+
if (maxThumbTop <= 0 || maxScrollTop <= 0) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// `auto` avoids racing with a subsequent thumb drag (smooth scroll would
|
|
150
|
+
// still animate while pointer handlers update `scrollTop`).
|
|
151
|
+
scrollEl.scrollTo({
|
|
152
|
+
top: (targetThumbTop / maxThumbTop) * maxScrollTop,
|
|
153
|
+
behavior: 'auto',
|
|
154
|
+
});
|
|
155
|
+
}, [cancelProgrammaticSmoothScroll]);
|
|
156
|
+
return {
|
|
157
|
+
scrollRef,
|
|
158
|
+
trackRef,
|
|
159
|
+
thumbRef,
|
|
160
|
+
hasContentBelow,
|
|
161
|
+
overflows,
|
|
162
|
+
thumb,
|
|
163
|
+
scheduleUpdate,
|
|
164
|
+
handleThumbPointerDown,
|
|
165
|
+
handleTrackPointerDown,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export { useScrollableScrollbarSync };
|
|
170
|
+
//# sourceMappingURL=useScrollableScrollbarSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollableScrollbarSync.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.ts"],"sourcesContent":["import React, {useCallback, useEffect, useLayoutEffect, useRef, useState} from 'react';\n\nconst EMPTY_DEPS: React.DependencyList = [];\n\nconst MIN_THUMB_HEIGHT = 24;\n\ntype ThumbGeometry = {\n top: number;\n height: number;\n};\n\ntype UseScrollableScrollbarSyncResult = {\n scrollRef: React.RefObject<HTMLDivElement>;\n trackRef: React.RefObject<HTMLDivElement>;\n thumbRef: React.RefObject<HTMLDivElement>;\n hasContentBelow: boolean;\n overflows: boolean;\n thumb: ThumbGeometry;\n scheduleUpdate: () => void;\n handleThumbPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;\n handleTrackPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\n/**\n * Keeps a custom scrollbar thumb and bottom shadow in sync with a native\n * scroll layer. The scroll element handles touch/keyboard; wheel events on the\n * overlay track are forwarded to it (the track sits above the scroller, so\n * they would not scroll otherwise). Wheel, touch, and keyboard on the\n * scrollable area itself are unchanged.\n *\n * @param recalcDeps - extra deps that should trigger thumb/shadow recalculation\n * @returns refs, scroll state, thumb geometry, and pointer handlers for the UI\n */\nexport function useScrollableScrollbarSync(\n recalcDeps: React.DependencyList = EMPTY_DEPS,\n): UseScrollableScrollbarSyncResult {\n const scrollRef = useRef<HTMLDivElement>(null);\n const trackRef = useRef<HTMLDivElement>(null);\n const thumbRef = useRef<HTMLDivElement>(null);\n\n const [hasContentBelow, setHasContentBelow] = useState(false);\n const [overflows, setOverflows] = useState(false);\n const [thumb, setThumb] = useState<ThumbGeometry>({top: 0, height: 0});\n\n const rafIdRef = useRef<number | null>(null);\n const scheduleUpdate = useCallback(() => {\n if (rafIdRef.current !== null) {\n return;\n }\n\n rafIdRef.current = requestAnimationFrame(() => {\n rafIdRef.current = null;\n\n const el = scrollRef.current;\n\n if (!el) {\n return;\n }\n\n const {scrollTop, scrollHeight, clientHeight} = el;\n const isOverflowing = scrollHeight > clientHeight;\n // `-1` guards against subpixel rounding at the bottom.\n const notAtBottom = scrollTop + clientHeight < scrollHeight - 1;\n\n setOverflows(isOverflowing);\n setHasContentBelow(isOverflowing && notAtBottom);\n\n if (!isOverflowing) {\n setThumb({top: 0, height: 0});\n return;\n }\n\n const ratio = clientHeight / scrollHeight;\n const rawHeight = clientHeight * ratio;\n const height = Math.max(rawHeight, MIN_THUMB_HEIGHT);\n const maxTop = clientHeight - height;\n const scrollRatio =\n scrollHeight - clientHeight > 0 ? scrollTop / (scrollHeight - clientHeight) : 0;\n const top = maxTop * scrollRatio;\n\n setThumb({top, height});\n });\n }, []);\n\n useEffect(() => {\n const el = scrollRef.current;\n\n if (!el) {\n return undefined;\n }\n\n scheduleUpdate();\n\n if (typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const observer = new ResizeObserver(scheduleUpdate);\n observer.observe(el);\n return () => observer.disconnect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scheduleUpdate, ...recalcDeps]);\n\n useEffect(() => {\n return () => {\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n };\n }, []);\n\n // Wheel events do not reach the native scroll layer when the cursor is over\n // the overlay track — forward them explicitly. `passive: false` is required\n // so `preventDefault` works in all browsers.\n useLayoutEffect(() => {\n if (!overflows) {\n return undefined;\n }\n\n const track = trackRef.current;\n const scrollEl = scrollRef.current;\n\n if (!track || !scrollEl) {\n return undefined;\n }\n\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n scrollEl.scrollTop += e.deltaY;\n };\n\n track.addEventListener('wheel', onWheel, {passive: false});\n return () => track.removeEventListener('wheel', onWheel);\n }, [overflows]);\n\n const cancelProgrammaticSmoothScroll = useCallback((scrollEl: HTMLDivElement) => {\n const top = scrollEl.scrollTop;\n scrollEl.scrollTo({top, behavior: 'auto'});\n }, []);\n\n const handleThumbPointerDown = useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n const scrollEl = scrollRef.current;\n const thumbEl = thumbRef.current;\n\n if (!scrollEl || !thumbEl || event.button !== 0) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n cancelProgrammaticSmoothScroll(scrollEl);\n\n const startY = event.clientY;\n const startScrollTop = scrollEl.scrollTop;\n const {scrollHeight, clientHeight} = scrollEl;\n const thumbHeight = thumbEl.getBoundingClientRect().height;\n const trackHeight = clientHeight;\n const maxThumbTop = trackHeight - thumbHeight;\n const maxScrollTop = scrollHeight - clientHeight;\n\n if (maxThumbTop <= 0 || maxScrollTop <= 0) {\n return;\n }\n\n const handlePointerMove = (moveEvent: PointerEvent) => {\n const deltaY = moveEvent.clientY - startY;\n const deltaScroll = (deltaY / maxThumbTop) * maxScrollTop;\n scrollEl.scrollTop = startScrollTop + deltaScroll;\n };\n\n const handlePointerUp = () => {\n window.removeEventListener('pointermove', handlePointerMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('pointercancel', handlePointerUp);\n };\n\n window.addEventListener('pointermove', handlePointerMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('pointercancel', handlePointerUp);\n },\n [cancelProgrammaticSmoothScroll],\n );\n\n const handleTrackPointerDown = useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n const scrollEl = scrollRef.current;\n const thumbEl = thumbRef.current;\n\n if (\n !scrollEl ||\n !thumbEl ||\n event.button !== 0 ||\n event.target !== event.currentTarget\n ) {\n return;\n }\n\n cancelProgrammaticSmoothScroll(scrollEl);\n\n const trackRect = event.currentTarget.getBoundingClientRect();\n const thumbHeight = thumbEl.getBoundingClientRect().height;\n const clickY = event.clientY - trackRect.top;\n const targetThumbTop = Math.max(\n 0,\n Math.min(clickY - thumbHeight / 2, trackRect.height - thumbHeight),\n );\n const maxThumbTop = trackRect.height - thumbHeight;\n const maxScrollTop = scrollEl.scrollHeight - scrollEl.clientHeight;\n\n if (maxThumbTop <= 0 || maxScrollTop <= 0) {\n return;\n }\n\n // `auto` avoids racing with a subsequent thumb drag (smooth scroll would\n // still animate while pointer handlers update `scrollTop`).\n scrollEl.scrollTo({\n top: (targetThumbTop / maxThumbTop) * maxScrollTop,\n behavior: 'auto',\n });\n },\n [cancelProgrammaticSmoothScroll],\n );\n\n return {\n scrollRef,\n trackRef,\n thumbRef,\n hasContentBelow,\n overflows,\n thumb,\n scheduleUpdate,\n handleThumbPointerDown,\n handleTrackPointerDown,\n };\n}\n"],"names":[],"mappings":";;AAEA,MAAM,UAAU,GAAyB,EAAE;AAE3C,MAAM,gBAAgB,GAAG,EAAE;AAmB3B;;;;;;;;;AASG;AACa,SAAA,0BAA0B,CACtC,UAAA,GAAmC,UAAU,EAAA;AAE7C,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC;IAE7C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,EAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC;AAEtE,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAgB,IAAI,CAAC;AAC5C,IAAA,MAAM,cAAc,GAAG,WAAW,CAAC,MAAK;AACpC,QAAA,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE;YAC3B;;AAGJ,QAAA,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C,IAAI,YAAY,IAAI,CAAC,EAAE;YACvC;;;;QAKJ,QAAQ,CAAC,QAAQ,CAAC;AACd,YAAA,GAAG,EAAE,CAAC,cAAc,GAAG,WAAW,IAAI,YAAY;AAClD,YAAA,QAAQ,EAAE,MAAM;AACnB,SAAA,CAAC;AACN,KAAC,EACD,CAAC,8BAA8B,CAAC,CACnC;IAED,OAAO;QACH,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,eAAe;QACf,SAAS;QACT,KAAK;QACL,cAAc;QACd,sBAAsB;QACtB,sBAAsB;KACzB;AACL;;;;"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const ITEM_TYPE_REGULAR = "regular";
|
|
2
2
|
export declare const COLLAPSE_ITEM_ID = "collapse-item-id";
|
|
3
|
+
/** Prefix for synthetic CompositeBar row ids for grouped section headers ({@link makeGroupHeaderAsideItem}). */
|
|
4
|
+
export declare const COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX: "__gn-composite-bar__group-header__";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const ITEM_TYPE_REGULAR = 'regular';
|
|
2
2
|
const COLLAPSE_ITEM_ID = 'collapse-item-id';
|
|
3
|
+
/** Prefix for synthetic CompositeBar row ids for grouped section headers ({@link makeGroupHeaderAsideItem}). */
|
|
4
|
+
const COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX = '__gn-composite-bar__group-header__';
|
|
3
5
|
|
|
4
|
-
export { COLLAPSE_ITEM_ID, ITEM_TYPE_REGULAR };
|
|
6
|
+
export { COLLAPSE_ITEM_ID, COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX, ITEM_TYPE_REGULAR };
|
|
5
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../../../../src/components/AsideHeader/components/CompositeBar/constants.ts"],"sourcesContent":["export const ITEM_TYPE_REGULAR = 'regular';\nexport const COLLAPSE_ITEM_ID = 'collapse-item-id';\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB,GAAG;AAC1B,MAAM,gBAAgB,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../../../src/components/AsideHeader/components/CompositeBar/constants.ts"],"sourcesContent":["export const ITEM_TYPE_REGULAR = 'regular';\nexport const COLLAPSE_ITEM_ID = 'collapse-item-id';\n\n/** Prefix for synthetic CompositeBar row ids for grouped section headers ({@link makeGroupHeaderAsideItem}). */\nexport const COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX = '__gn-composite-bar__group-header__' as const;\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB,GAAG;AAC1B,MAAM,gBAAgB,GAAG;AAEhC;AACO,MAAM,oCAAoC,GAAG;;;;"}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { MenuGroup } from '../../../types';
|
|
2
2
|
import { AsideHeaderItem } from '../../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export type CompositeBarRow = {
|
|
4
|
+
kind: 'item';
|
|
5
|
+
item: AsideHeaderItem;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'group';
|
|
8
|
+
group: MenuGroup;
|
|
9
|
+
items: AsideHeaderItem[];
|
|
10
|
+
};
|
|
11
|
+
export declare function flattenCompositeBarRows(rows: CompositeBarRow[]): AsideHeaderItem[];
|
|
12
|
+
type BuildCompositeBarRowsOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* When true, items with `hidden: true` are still included (e.g. All pages edit list).
|
|
15
|
+
* @default false — hidden items are omitted from CompositeBar like today.
|
|
16
|
+
*/
|
|
17
|
+
includeHidden?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* When true, `MenuGroup` entries with `hidden: true` still form a group row (All pages edit).
|
|
20
|
+
* @default false — hidden groups are omitted; their items are not rendered in CompositeBar.
|
|
21
|
+
*/
|
|
22
|
+
includeHiddenGroups?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Builds ordered rows for CompositeBar: flat items and grouped sections.
|
|
26
|
+
* By default hidden items are omitted; pass `includeHidden` to keep them (All pages edit).
|
|
27
|
+
* Group rows are placed at the index of the first visible (or first included) child.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildCompositeBarRows(items: AsideHeaderItem[], groups: MenuGroup[] | undefined, options?: BuildCompositeBarRowsOptions): CompositeBarRow[];
|
|
11
30
|
export {};
|
|
@@ -1,14 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function flattenCompositeBarRows(rows) {
|
|
2
|
+
const out = [];
|
|
3
|
+
for (const row of rows) {
|
|
4
|
+
if (row.kind === 'item') {
|
|
5
|
+
out.push(row.item);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
out.push(...row.items);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
4
12
|
}
|
|
5
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Builds ordered rows for CompositeBar: flat items and grouped sections.
|
|
15
|
+
* By default hidden items are omitted; pass `includeHidden` to keep them (All pages edit).
|
|
16
|
+
* Group rows are placed at the index of the first visible (or first included) child.
|
|
17
|
+
*/
|
|
18
|
+
function buildCompositeBarRows(items, groups, options) {
|
|
19
|
+
var _a;
|
|
6
20
|
if (!groups || groups.length === 0) {
|
|
7
|
-
return items;
|
|
21
|
+
return items.map((item) => ({ kind: 'item', item }));
|
|
8
22
|
}
|
|
9
|
-
|
|
23
|
+
/** Full group metadata (needed to omit children when `MenuGroup.hidden` is true). */
|
|
24
|
+
const allGroupDefsById = new Map(groups.map((groupDefinition) => [groupDefinition.id, groupDefinition]));
|
|
25
|
+
const visibleGroups = (options === null || options === undefined ? undefined : options.includeHiddenGroups) ? groups : groups.filter((g) => !g.hidden);
|
|
26
|
+
/** No visible group definitions — only render rows that still belong on the bar */
|
|
10
27
|
if (visibleGroups.length === 0) {
|
|
11
|
-
return items
|
|
28
|
+
return items
|
|
29
|
+
.filter((item) => {
|
|
30
|
+
var _a;
|
|
31
|
+
if (!(options === null || options === undefined ? undefined : options.includeHidden) && item.hidden) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (item.groupId &&
|
|
35
|
+
!(options === null || options === undefined ? undefined : options.includeHiddenGroups) &&
|
|
36
|
+
((_a = allGroupDefsById.get(item.groupId)) === null || _a === undefined ? undefined : _a.hidden)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
})
|
|
41
|
+
.map((item) => ({ kind: 'item', item }));
|
|
12
42
|
}
|
|
13
43
|
const groupMap = new Map();
|
|
14
44
|
for (const group of visibleGroups) {
|
|
@@ -19,7 +49,7 @@ function getGroupedItems(items, groups) {
|
|
|
19
49
|
const groupFirstIndex = new Map();
|
|
20
50
|
for (let i = 0; i < items.length; i++) {
|
|
21
51
|
const item = items[i];
|
|
22
|
-
if (item.hidden) {
|
|
52
|
+
if (!(options === null || options === undefined ? undefined : options.includeHidden) && item.hidden) {
|
|
23
53
|
continue;
|
|
24
54
|
}
|
|
25
55
|
const groupId = item.groupId;
|
|
@@ -32,34 +62,33 @@ function getGroupedItems(items, groups) {
|
|
|
32
62
|
}
|
|
33
63
|
groupChildren.push(item);
|
|
34
64
|
}
|
|
65
|
+
else if (groupId &&
|
|
66
|
+
!(options === null || options === undefined ? undefined : options.includeHiddenGroups) &&
|
|
67
|
+
((_a = allGroupDefsById.get(groupId)) === null || _a === undefined ? undefined : _a.hidden)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
35
70
|
else {
|
|
36
|
-
ungroupedItems.push({ index: i, item });
|
|
71
|
+
ungroupedItems.push({ index: i, row: { kind: 'item', item } });
|
|
37
72
|
}
|
|
38
73
|
}
|
|
39
74
|
const result = [...ungroupedItems];
|
|
40
75
|
for (const [groupId, children] of groupChildrenMap.entries()) {
|
|
41
|
-
if (children.length === 0)
|
|
76
|
+
if (children.length === 0) {
|
|
42
77
|
continue;
|
|
78
|
+
}
|
|
43
79
|
const group = groupMap.get(groupId);
|
|
44
80
|
const firstIndex = groupFirstIndex.get(groupId);
|
|
45
81
|
if (!group || firstIndex === undefined) {
|
|
46
82
|
continue;
|
|
47
83
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
icon: group.icon,
|
|
53
|
-
current: hasCurrent,
|
|
54
|
-
isGroupHeader: true,
|
|
55
|
-
groupChildren: children,
|
|
56
|
-
groupPopupTitle: group.popupTitle,
|
|
57
|
-
};
|
|
58
|
-
result.push({ index: firstIndex, item: groupHeaderItem });
|
|
84
|
+
result.push({
|
|
85
|
+
index: firstIndex,
|
|
86
|
+
row: { kind: 'group', group, items: children },
|
|
87
|
+
});
|
|
59
88
|
}
|
|
60
89
|
result.sort((a, b) => a.index - b.index);
|
|
61
|
-
return result.map((r) => r.
|
|
90
|
+
return result.map((r) => r.row);
|
|
62
91
|
}
|
|
63
92
|
|
|
64
|
-
export {
|
|
93
|
+
export { buildCompositeBarRows, flattenCompositeBarRows };
|
|
65
94
|
//# sourceMappingURL=grouping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping.js","sources":["../../../../../../../src/components/AsideHeader/components/CompositeBar/grouping.ts"],"sourcesContent":["import {MenuGroup} from '../../../types';\nimport {AsideHeaderItem} from '../../types';\n\
|
|
1
|
+
{"version":3,"file":"grouping.js","sources":["../../../../../../../src/components/AsideHeader/components/CompositeBar/grouping.ts"],"sourcesContent":["import {MenuGroup} from '../../../types';\nimport {AsideHeaderItem} from '../../types';\n\nexport type CompositeBarRow =\n | {kind: 'item'; item: AsideHeaderItem}\n | {kind: 'group'; group: MenuGroup; items: AsideHeaderItem[]};\n\nexport function flattenCompositeBarRows(rows: CompositeBarRow[]): AsideHeaderItem[] {\n const out: AsideHeaderItem[] = [];\n for (const row of rows) {\n if (row.kind === 'item') {\n out.push(row.item);\n } else {\n out.push(...row.items);\n }\n }\n return out;\n}\n\ntype BuildCompositeBarRowsOptions = {\n /**\n * When true, items with `hidden: true` are still included (e.g. All pages edit list).\n * @default false — hidden items are omitted from CompositeBar like today.\n */\n includeHidden?: boolean;\n /**\n * When true, `MenuGroup` entries with `hidden: true` still form a group row (All pages edit).\n * @default false — hidden groups are omitted; their items are not rendered in CompositeBar.\n */\n includeHiddenGroups?: boolean;\n};\n\n/**\n * Builds ordered rows for CompositeBar: flat items and grouped sections.\n * By default hidden items are omitted; pass `includeHidden` to keep them (All pages edit).\n * Group rows are placed at the index of the first visible (or first included) child.\n */\nexport function buildCompositeBarRows(\n items: AsideHeaderItem[],\n groups: MenuGroup[] | undefined,\n options?: BuildCompositeBarRowsOptions,\n): CompositeBarRow[] {\n if (!groups || groups.length === 0) {\n return items.map((item) => ({kind: 'item' as const, item}));\n }\n\n /** Full group metadata (needed to omit children when `MenuGroup.hidden` is true). */\n const allGroupDefsById = new Map<string, MenuGroup>(\n groups.map((groupDefinition) => [groupDefinition.id, groupDefinition]),\n );\n\n const visibleGroups = options?.includeHiddenGroups ? groups : groups.filter((g) => !g.hidden);\n\n /** No visible group definitions — only render rows that still belong on the bar */\n if (visibleGroups.length === 0) {\n return items\n .filter((item) => {\n if (!options?.includeHidden && item.hidden) {\n return false;\n }\n if (\n item.groupId &&\n !options?.includeHiddenGroups &&\n allGroupDefsById.get(item.groupId)?.hidden\n ) {\n return false;\n }\n return true;\n })\n .map((item) => ({kind: 'item' as const, item}));\n }\n\n const groupMap = new Map<string, MenuGroup>();\n for (const group of visibleGroups) {\n groupMap.set(group.id, group);\n }\n\n const groupChildrenMap = new Map<string, AsideHeaderItem[]>();\n const ungroupedItems: Array<{index: number; row: CompositeBarRow}> = [];\n const groupFirstIndex = new Map<string, number>();\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n\n if (!options?.includeHidden && item.hidden) {\n continue;\n }\n\n const groupId = item.groupId;\n\n if (groupId && groupMap.has(groupId)) {\n let groupChildren = groupChildrenMap.get(groupId);\n\n if (!groupChildren) {\n groupChildren = [];\n groupChildrenMap.set(groupId, groupChildren);\n groupFirstIndex.set(groupId, i);\n }\n\n groupChildren.push(item);\n } else if (\n groupId &&\n !options?.includeHiddenGroups &&\n allGroupDefsById.get(groupId)?.hidden\n ) {\n continue;\n } else {\n ungroupedItems.push({index: i, row: {kind: 'item' as const, item}});\n }\n }\n\n const result: Array<{index: number; row: CompositeBarRow}> = [...ungroupedItems];\n\n for (const [groupId, children] of groupChildrenMap.entries()) {\n if (children.length === 0) {\n continue;\n }\n\n const group = groupMap.get(groupId);\n const firstIndex = groupFirstIndex.get(groupId);\n\n if (!group || firstIndex === undefined) {\n continue;\n }\n\n result.push({\n index: firstIndex,\n row: {kind: 'group' as const, group, items: children},\n });\n }\n\n result.sort((a, b) => a.index - b.index);\n return result.map((r) => r.row);\n}\n"],"names":[],"mappings":"AAOM,SAAU,uBAAuB,CAAC,IAAuB,EAAA;IAC3D,MAAM,GAAG,GAAsB,EAAE;AACjC,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACpB,QAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACrB,YAAA,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;;aACf;YACH,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;;;AAG9B,IAAA,OAAO,GAAG;AACd;AAeA;;;;AAIG;SACa,qBAAqB,CACjC,KAAwB,EACxB,MAA+B,EAC/B,OAAsC,EAAA;;IAEtC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,EAAC,IAAI,EAAE,MAAe,EAAE,IAAI,EAAC,CAAC,CAAC;;;IAI/D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CA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iD,CAAC,GAAG,cAAc,CAAC;AAEhF,IAAA,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,EAAE;AAC1D,QAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB;;QAGJ,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;QACnC,MAAM,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC;AAE/C,QAAA,IAAI,CAAC,KAAK,IAAI,UAAU,KAAK,SAAS,EAAE;YACpC;;QAGJ,MAAM,CAAC,IAAI,CAAC;AACR,YAAA,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,EAAC,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAC;AACxD,SAAA,CAAC;;AAGN,IAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AACxC,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AACnC;;;;"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
import { MenuGroup } from '../../../types';
|
|
1
2
|
import { AsideHeaderItem } from '../../types';
|
|
3
|
+
import type { CompositeBarRow } from './grouping';
|
|
2
4
|
export declare function getItemHeight(compositeItem: AsideHeaderItem): 40 | 50 | 15;
|
|
3
5
|
export declare function getPopupItemHeight(compositeItem: AsideHeaderItem): 32 | 50 | 15;
|
|
4
6
|
export declare function getItemsHeight<T extends AsideHeaderItem>(items: T[]): number;
|
|
5
7
|
export declare function getPopupItemsHeight<T extends AsideHeaderItem>(items: T[]): number;
|
|
6
8
|
export declare function getSelectedItemIndex(compositeItems: AsideHeaderItem[]): number | undefined;
|
|
7
|
-
export declare function getItemsMinHeight(compositeItems: AsideHeaderItem[]): number;
|
|
8
9
|
export declare function getMoreButtonItem(menuMoreTitle?: string): AsideHeaderItem;
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
10
|
+
export declare function makeGroupHeaderAsideItem(group: MenuGroup): AsideHeaderItem;
|
|
11
|
+
/**
|
|
12
|
+
* Moves rows whose item has `afterMoreButton` to the end (parity with scroll vs collapse DOM order).
|
|
13
|
+
*
|
|
14
|
+
* @param rows Composite bar rows before ordering.
|
|
15
|
+
* @returns Rows with `afterMoreButton` item rows last, or the same array reference when none.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getReorderedCompositeBarRows(rows: CompositeBarRow[]): CompositeBarRow[];
|
|
18
|
+
export declare function getCompositeBarRowsMinHeight(rows: CompositeBarRow[]): number;
|
|
19
|
+
export declare function getSelectedCompositeBarRowIndex(rows: CompositeBarRow[]): number | undefined;
|
|
20
|
+
export declare function getAutosizeCompositeBarRows(rows: CompositeBarRow[], height: number, collapseItem: AsideHeaderItem): {
|
|
21
|
+
listRows: CompositeBarRow[];
|
|
11
22
|
collapseItems: AsideHeaderItem[];
|
|
12
23
|
};
|