@gravity-ui/navigation 6.0.0-beta.1 → 6.0.0-beta.3
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 +4 -0
- package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.js +89 -30
- 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.css +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js +15 -16
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.module.scss.js +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 +10 -2
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +2 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +2 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +2 -1
- package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -1
- 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 +11 -10
- package/build/cjs/components/AsideHeader/components/CompositeBar/utils.js +114 -48
- 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 +26 -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 +4 -0
- package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.js +92 -33
- 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.css +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js +16 -17
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.module.scss.js +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 +10 -2
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +2 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +2 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +2 -1
- package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -1
- 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 +11 -10
- package/build/esm/components/AsideHeader/components/CompositeBar/utils.js +105 -41
- 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 +26 -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
|
@@ -9,10 +9,18 @@ var ItemPopupNestContext = require('./ItemPopupNestContext.js');
|
|
|
9
9
|
var Item_module = require('./Item.module.scss.js');
|
|
10
10
|
|
|
11
11
|
const b = cn.createBlock('composite-bar-item', Item_module.default);
|
|
12
|
-
const
|
|
12
|
+
const POPUP_MAIN_AXIS_OFFSET = 14;
|
|
13
|
+
const POPUP_CROSS_AXIS_OFFSET_WITH_TITLE = -30;
|
|
14
|
+
const POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE = 0;
|
|
13
15
|
const DEFAULT_POPUP_DELAY = 100;
|
|
14
16
|
const ItemPopup = ({ items, itemClassName, title, open, disabled, type, collapsed = false, hideIcon = false, children, onItemClick, onOpenChange, }) => {
|
|
15
17
|
const nestedOpenCountRef = React.useRef(0);
|
|
18
|
+
const popoverOffset = React.useMemo(() => ({
|
|
19
|
+
mainAxis: POPUP_MAIN_AXIS_OFFSET,
|
|
20
|
+
crossAxis: title
|
|
21
|
+
? POPUP_CROSS_AXIS_OFFSET_WITH_TITLE
|
|
22
|
+
: POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE,
|
|
23
|
+
}), [title]);
|
|
16
24
|
const registerNestedOpen = React.useCallback((delta) => {
|
|
17
25
|
nestedOpenCountRef.current = Math.max(0, nestedOpenCountRef.current + delta);
|
|
18
26
|
}, []);
|
|
@@ -37,7 +45,7 @@ const ItemPopup = ({ items, itemClassName, title, open, disabled, type, collapse
|
|
|
37
45
|
if (nextOpen && disabled)
|
|
38
46
|
return;
|
|
39
47
|
wrappedOnOpenChange(nextOpen);
|
|
40
|
-
}, placement: "right-start", strategy: "fixed", openDelay: DEFAULT_POPUP_DELAY, closeDelay: DEFAULT_POPUP_DELAY, offset:
|
|
48
|
+
}, placement: "right-start", strategy: "fixed", openDelay: DEFAULT_POPUP_DELAY, closeDelay: DEFAULT_POPUP_DELAY, offset: popoverOffset, enableSafePolygon: true, className: b('icon-popover', { 'item-type': type }), content: content }, children));
|
|
41
49
|
};
|
|
42
50
|
ItemPopup.displayName = 'ItemPopup';
|
|
43
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemPopup.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/Item/ItemPopup.tsx"],"sourcesContent":["import React from 'react';\n\nimport {List, Popover, PopupProps} from '@gravity-ui/uikit';\n\nimport {createBlock} from '../../../../utils/cn';\nimport {AsideHeaderItem} from '../../../types';\nimport {getPopupItemHeight, getPopupItemsHeight, getSelectedItemIndex} from '../utils';\n\nimport {Item} from './Item';\nimport {ItemPopupNestContext} from './ItemPopupNestContext';\n\nimport styles from './Item.module.scss';\n\nconst b = createBlock('composite-bar-item', styles);\n\nconst
|
|
1
|
+
{"version":3,"file":"ItemPopup.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/Item/ItemPopup.tsx"],"sourcesContent":["import React from 'react';\n\nimport {List, Popover, PopupProps} from '@gravity-ui/uikit';\n\nimport {createBlock} from '../../../../utils/cn';\nimport {AsideHeaderItem} from '../../../types';\nimport {getPopupItemHeight, getPopupItemsHeight, getSelectedItemIndex} from '../utils';\n\nimport {Item} from './Item';\nimport {ItemPopupNestContext} from './ItemPopupNestContext';\n\nimport styles from './Item.module.scss';\n\nconst b = createBlock('composite-bar-item', styles);\n\nconst POPUP_MAIN_AXIS_OFFSET = 14;\nconst POPUP_CROSS_AXIS_OFFSET_WITH_TITLE = -30;\nconst POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE = 0;\n\nconst DEFAULT_POPUP_DELAY = 100;\n\ninterface Props {\n items: AsideHeaderItem[];\n /** Optional title rendered at the top of the popup. */\n title?: string;\n open?: boolean;\n disabled?: boolean;\n type?: string;\n collapsed?: boolean;\n hideIcon?: boolean;\n itemClassName?: string;\n children: React.ReactElement;\n onOpenChange?: (open: boolean) => void;\n onItemClick?: AsideHeaderItem['onItemClick'];\n}\n\nexport const ItemPopup: React.FC<Props> = ({\n items,\n itemClassName,\n title,\n open,\n disabled,\n type,\n collapsed = false,\n hideIcon = false,\n children,\n onItemClick,\n onOpenChange,\n}) => {\n const nestedOpenCountRef = React.useRef(0);\n\n const popoverOffset = React.useMemo<NonNullable<PopupProps['offset']>>(\n () => ({\n mainAxis: POPUP_MAIN_AXIS_OFFSET,\n crossAxis: title\n ? POPUP_CROSS_AXIS_OFFSET_WITH_TITLE\n : POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE,\n }),\n [title],\n );\n\n const registerNestedOpen = React.useCallback((delta: number) => {\n nestedOpenCountRef.current = Math.max(0, nestedOpenCountRef.current + delta);\n }, []);\n\n const nestContextValue = React.useMemo(() => ({registerNestedOpen}), [registerNestedOpen]);\n\n const wrappedOnOpenChange = React.useCallback(\n (next: boolean) => {\n if (!next && nestedOpenCountRef.current > 0) {\n return;\n }\n\n onOpenChange?.(next);\n },\n [onOpenChange],\n );\n\n if (!items.length) {\n return children;\n }\n\n const content = (\n <ItemPopupNestContext.Provider value={nestContextValue}>\n <div className={b('popup-content', {collapsed})}>\n {title && <div className={b('popup-title')}>{title}</div>}\n <List\n items={items}\n selectedItemIndex={getSelectedItemIndex(items)}\n itemHeight={getPopupItemHeight}\n itemsHeight={getPopupItemsHeight}\n itemClassName={b('root-menu-item', itemClassName)}\n virtualized={false}\n filterable={false}\n sortable={false}\n renderItem={(item) => (\n <Item\n {...item}\n qa={undefined}\n compact={false}\n className={b('popup-item')}\n hideIcon={hideIcon}\n stopClickPropagation\n enableTooltip={false}\n bringForward={false}\n popupVisible={false}\n renderPopupContent={undefined}\n onOpenChangePopup={undefined}\n popupRef={undefined}\n onItemClick={(_innerItem, _innerCollapsed, event) => {\n onOpenChange?.(false);\n onItemClick?.(item, collapsed, event);\n }}\n />\n )}\n />\n </div>\n </ItemPopupNestContext.Provider>\n );\n\n return (\n <Popover\n disabled={disabled}\n open={open}\n onOpenChange={(nextOpen) => {\n if (nextOpen && disabled) return;\n wrappedOnOpenChange(nextOpen);\n }}\n placement=\"right-start\"\n strategy=\"fixed\"\n openDelay={DEFAULT_POPUP_DELAY}\n closeDelay={DEFAULT_POPUP_DELAY}\n offset={popoverOffset}\n enableSafePolygon\n className={b('icon-popover', {'item-type': type})}\n content={content}\n >\n {children}\n </Popover>\n );\n};\n\nItemPopup.displayName = 'ItemPopup';\n"],"names":["createBlock","styles","ItemPopupNestContext","List","getSelectedItemIndex","getPopupItemHeight","getPopupItemsHeight","Item","Popover"],"mappings":";;;;;;;;;;AAaA,MAAM,CAAC,GAAGA,cAAW,CAAC,oBAAoB,EAAEC,mBAAM,CAAC;AAEnD,MAAM,sBAAsB,GAAG,EAAE;AACjC,MAAM,kCAAkC,GAAG,GAAG;AAC9C,MAAM,qCAAqC,GAAG,CAAC;AAE/C,MAAM,mBAAmB,GAAG,GAAG;AAiBxB,MAAM,SAAS,GAAoB,CAAC,EACvC,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,WAAW,EACX,YAAY,GACf,KAAI;IACD,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAC/B,OAAO;AACH,QAAA,QAAQ,EAAE,sBAAsB;AAChC,QAAA,SAAS,EAAE;AACP,cAAE;AACF,cAAE,qCAAqC;AAC9C,KAAA,CAAC,EACF,CAAC,KAAK,CAAC,CACV;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AAE,IAAI,EAAC,CAAC,EACjD,OAAO,EAAE,OAAO,IAEf,QAAQ,CACH;AAElB;AAEA,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
|
package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemPopupNestContext.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.tsx"],"sourcesContent":["import React from 'react';\n\
|
|
1
|
+
{"version":3,"file":"ItemPopupNestContext.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.tsx"],"sourcesContent":["import React from 'react';\n\ntype ItemPopupNestContextValue = {\n registerNestedOpen: (delta: number) => void;\n};\n\nexport const ItemPopupNestContext = React.createContext<ItemPopupNestContextValue | null>(null);\n"],"names":[],"mappings":";;;;AAMa,MAAA,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAAmC,IAAI;;;;"}
|
|
@@ -18,7 +18,8 @@ type UseScrollableScrollbarSyncResult = {
|
|
|
18
18
|
* Keeps a custom scrollbar thumb and bottom shadow in sync with a native
|
|
19
19
|
* scroll layer. The scroll element handles touch/keyboard; wheel events on the
|
|
20
20
|
* overlay track are forwarded to it (the track sits above the scroller, so
|
|
21
|
-
* they would not scroll otherwise).
|
|
21
|
+
* they would not scroll otherwise). Wheel, touch, and keyboard on the
|
|
22
|
+
* scrollable area itself are unchanged.
|
|
22
23
|
*
|
|
23
24
|
* @param recalcDeps - extra deps that should trigger thumb/shadow recalculation
|
|
24
25
|
* @returns refs, scroll state, thumb geometry, and pointer handlers for the UI
|
|
@@ -8,7 +8,8 @@ const MIN_THUMB_HEIGHT = 24;
|
|
|
8
8
|
* Keeps a custom scrollbar thumb and bottom shadow in sync with a native
|
|
9
9
|
* scroll layer. The scroll element handles touch/keyboard; wheel events on the
|
|
10
10
|
* overlay track are forwarded to it (the track sits above the scroller, so
|
|
11
|
-
* they would not scroll otherwise).
|
|
11
|
+
* they would not scroll otherwise). Wheel, touch, and keyboard on the
|
|
12
|
+
* scrollable area itself are unchanged.
|
|
12
13
|
*
|
|
13
14
|
* @param recalcDeps - extra deps that should trigger thumb/shadow recalculation
|
|
14
15
|
* @returns refs, scroll state, thumb geometry, and pointer handlers for the UI
|
|
@@ -1 +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).\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":["useRef","useState","useCallback","useEffect","useLayoutEffect"],"mappings":";;;;AAEA,MAAM,UAAU,GAAyB,EAAE;AAE3C,MAAM,gBAAgB,GAAG,EAAE;AAmB3B;;;;;;;;AAQG;AACa,SAAA,0BAA0B,CACtC,UAAA,GAAmC,UAAU,EAAA;AAE7C,IAAA,MAAM,SAAS,GAAGA,YAAM,CAAiB,IAAI,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAiB,IAAI,CAAC;IAE7C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAgB,EAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC;AAEtE,IAAA,MAAM,QAAQ,GAAGD,YAAM,CAAgB,IAAI,CAAC;AA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AAW,GAAG,SAAS,CAAC,MAAM,GAAG,WAAW;QAClD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY;QAElE,IAAI,WAAW,IAAI,CAAC,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
|
+
{"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":["useRef","useState","useCallback","useEffect","useLayoutEffect"],"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,GAAGA,YAAM,CAAiB,IAAI,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAiB,IAAI,CAAC;AAC7C,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAiB,IAAI,CAAC;IAE7C,MAAM,CAAC,eAAe,EAAE,kBAAkB,C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MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM;QAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,WAAW,CAAC,CACrE;AACD,QAAA,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,GAAG,WAAW;QAClD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY;QAElE,IAAI,WAAW,IAAI,CAAC,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__";
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const ITEM_TYPE_REGULAR = 'regular';
|
|
4
4
|
const COLLAPSE_ITEM_ID = 'collapse-item-id';
|
|
5
|
+
/** Prefix for synthetic CompositeBar row ids for grouped section headers ({@link makeGroupHeaderAsideItem}). */
|
|
6
|
+
const COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX = '__gn-composite-bar__group-header__';
|
|
5
7
|
|
|
6
8
|
exports.COLLAPSE_ITEM_ID = COLLAPSE_ITEM_ID;
|
|
9
|
+
exports.COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX = COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX;
|
|
7
10
|
exports.ITEM_TYPE_REGULAR = ITEM_TYPE_REGULAR;
|
|
8
11
|
//# 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,16 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function flattenCompositeBarRows(rows) {
|
|
4
|
+
const out = [];
|
|
5
|
+
for (const row of rows) {
|
|
6
|
+
if (row.kind === 'item') {
|
|
7
|
+
out.push(row.item);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
out.push(...row.items);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
6
14
|
}
|
|
7
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Builds ordered rows for CompositeBar: flat items and grouped sections.
|
|
17
|
+
* By default hidden items are omitted; pass `includeHidden` to keep them (All pages edit).
|
|
18
|
+
* Group rows are placed at the index of the first visible (or first included) child.
|
|
19
|
+
*/
|
|
20
|
+
function buildCompositeBarRows(items, groups, options) {
|
|
21
|
+
var _a;
|
|
8
22
|
if (!groups || groups.length === 0) {
|
|
9
|
-
return items;
|
|
23
|
+
return items.map((item) => ({ kind: 'item', item }));
|
|
10
24
|
}
|
|
11
|
-
|
|
25
|
+
/** Full group metadata (needed to omit children when `MenuGroup.hidden` is true). */
|
|
26
|
+
const allGroupDefsById = new Map(groups.map((groupDefinition) => [groupDefinition.id, groupDefinition]));
|
|
27
|
+
const visibleGroups = (options === null || options === undefined ? undefined : options.includeHiddenGroups) ? groups : groups.filter((g) => !g.hidden);
|
|
28
|
+
/** No visible group definitions — only render rows that still belong on the bar */
|
|
12
29
|
if (visibleGroups.length === 0) {
|
|
13
|
-
return items
|
|
30
|
+
return items
|
|
31
|
+
.filter((item) => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!(options === null || options === undefined ? undefined : options.includeHidden) && item.hidden) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (item.groupId &&
|
|
37
|
+
!(options === null || options === undefined ? undefined : options.includeHiddenGroups) &&
|
|
38
|
+
((_a = allGroupDefsById.get(item.groupId)) === null || _a === undefined ? undefined : _a.hidden)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
})
|
|
43
|
+
.map((item) => ({ kind: 'item', item }));
|
|
14
44
|
}
|
|
15
45
|
const groupMap = new Map();
|
|
16
46
|
for (const group of visibleGroups) {
|
|
@@ -21,7 +51,7 @@ function getGroupedItems(items, groups) {
|
|
|
21
51
|
const groupFirstIndex = new Map();
|
|
22
52
|
for (let i = 0; i < items.length; i++) {
|
|
23
53
|
const item = items[i];
|
|
24
|
-
if (item.hidden) {
|
|
54
|
+
if (!(options === null || options === undefined ? undefined : options.includeHidden) && item.hidden) {
|
|
25
55
|
continue;
|
|
26
56
|
}
|
|
27
57
|
const groupId = item.groupId;
|
|
@@ -34,35 +64,34 @@ function getGroupedItems(items, groups) {
|
|
|
34
64
|
}
|
|
35
65
|
groupChildren.push(item);
|
|
36
66
|
}
|
|
67
|
+
else if (groupId &&
|
|
68
|
+
!(options === null || options === undefined ? undefined : options.includeHiddenGroups) &&
|
|
69
|
+
((_a = allGroupDefsById.get(groupId)) === null || _a === undefined ? undefined : _a.hidden)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
37
72
|
else {
|
|
38
|
-
ungroupedItems.push({ index: i, item });
|
|
73
|
+
ungroupedItems.push({ index: i, row: { kind: 'item', item } });
|
|
39
74
|
}
|
|
40
75
|
}
|
|
41
76
|
const result = [...ungroupedItems];
|
|
42
77
|
for (const [groupId, children] of groupChildrenMap.entries()) {
|
|
43
|
-
if (children.length === 0)
|
|
78
|
+
if (children.length === 0) {
|
|
44
79
|
continue;
|
|
80
|
+
}
|
|
45
81
|
const group = groupMap.get(groupId);
|
|
46
82
|
const firstIndex = groupFirstIndex.get(groupId);
|
|
47
83
|
if (!group || firstIndex === undefined) {
|
|
48
84
|
continue;
|
|
49
85
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
icon: group.icon,
|
|
55
|
-
current: hasCurrent,
|
|
56
|
-
isGroupHeader: true,
|
|
57
|
-
groupChildren: children,
|
|
58
|
-
groupPopupTitle: group.popupTitle,
|
|
59
|
-
};
|
|
60
|
-
result.push({ index: firstIndex, item: groupHeaderItem });
|
|
86
|
+
result.push({
|
|
87
|
+
index: firstIndex,
|
|
88
|
+
row: { kind: 'group', group, items: children },
|
|
89
|
+
});
|
|
61
90
|
}
|
|
62
91
|
result.sort((a, b) => a.index - b.index);
|
|
63
|
-
return result.map((r) => r.
|
|
92
|
+
return result.map((r) => r.row);
|
|
64
93
|
}
|
|
65
94
|
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
95
|
+
exports.buildCompositeBarRows = buildCompositeBarRows;
|
|
96
|
+
exports.flattenCompositeBarRows = flattenCompositeBarRows;
|
|
68
97
|
//# 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,IAA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,GAAG,CAAC,CAAC,KAAK,CAAC;AACxC,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AACnC;;;;;"}
|
|
@@ -1,22 +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;
|
|
10
|
+
export declare function makeGroupHeaderAsideItem(group: MenuGroup): AsideHeaderItem;
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
* to the end. This keeps the DOM order consistent between `v1` (collapse
|
|
12
|
-
* into "More") and `v2` (scrollable) modes.
|
|
12
|
+
* Moves rows whose item has `afterMoreButton` to the end (parity with scroll vs collapse DOM order).
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
16
|
-
* same reference when no reordering is needed
|
|
14
|
+
* @param rows Composite bar rows before ordering.
|
|
15
|
+
* @returns Rows with `afterMoreButton` item rows last, or the same array reference when none.
|
|
17
16
|
*/
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
|
|
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[];
|
|
21
22
|
collapseItems: AsideHeaderItem[];
|
|
22
23
|
};
|