@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.
Files changed (101) hide show
  1. package/build/cjs/components/AsideHeader/AsideHeader.css +1 -1
  2. package/build/cjs/components/AsideHeader/AsideHeader.module.scss.js +1 -1
  3. package/build/cjs/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js +52 -16
  4. package/build/cjs/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js.map +1 -1
  5. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.d.ts +20 -0
  6. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js +56 -0
  7. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js.map +1 -0
  8. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.d.ts +7 -0
  9. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js +26 -0
  10. package/build/cjs/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js.map +1 -0
  11. package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.d.ts +1 -1
  12. package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.js +3 -3
  13. package/build/cjs/components/AsideHeader/components/AllPagesPanel/constants.js.map +1 -1
  14. package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.d.ts +10 -1
  15. package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js +28 -6
  16. package/build/cjs/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js.map +1 -1
  17. package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.css +1 -1
  18. package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.d.ts +4 -0
  19. package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.js +89 -30
  20. package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.js.map +1 -1
  21. package/build/cjs/components/AsideHeader/components/CompositeBar/CompositeBar.module.scss.js +1 -1
  22. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.css +1 -1
  23. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js +15 -16
  24. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
  25. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.module.scss.js +1 -1
  26. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/Item.types.d.ts +8 -0
  27. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js +10 -2
  28. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
  29. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +2 -1
  30. package/build/cjs/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -1
  31. package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +2 -1
  32. package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +2 -1
  33. package/build/cjs/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -1
  34. package/build/cjs/components/AsideHeader/components/CompositeBar/constants.d.ts +2 -0
  35. package/build/cjs/components/AsideHeader/components/CompositeBar/constants.js +3 -0
  36. package/build/cjs/components/AsideHeader/components/CompositeBar/constants.js.map +1 -1
  37. package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.d.ts +27 -8
  38. package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.js +53 -24
  39. package/build/cjs/components/AsideHeader/components/CompositeBar/grouping.js.map +1 -1
  40. package/build/cjs/components/AsideHeader/components/CompositeBar/utils.d.ts +11 -10
  41. package/build/cjs/components/AsideHeader/components/CompositeBar/utils.js +114 -48
  42. package/build/cjs/components/AsideHeader/components/CompositeBar/utils.js.map +1 -1
  43. package/build/cjs/components/AsideHeader/components/FirstPanel.js +4 -3
  44. package/build/cjs/components/AsideHeader/components/FirstPanel.js.map +1 -1
  45. package/build/cjs/components/AsideHeader/components/PageLayout/AsideFallback.css +1 -1
  46. package/build/cjs/components/AsideHeader/components/PageLayout/PageLayout.css +1 -1
  47. package/build/cjs/components/AsideHeader/components/PageLayout/PageLayoutAside.css +1 -1
  48. package/build/cjs/components/AsideHeader/types.d.ts +26 -0
  49. package/build/cjs/components/AsideHeader/types.js +4 -0
  50. package/build/cjs/components/AsideHeader/types.js.map +1 -1
  51. package/build/esm/components/AsideHeader/AsideHeader.css +1 -1
  52. package/build/esm/components/AsideHeader/AsideHeader.module.scss.js +1 -1
  53. package/build/esm/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js +50 -14
  54. package/build/esm/components/AsideHeader/components/AllPagesPanel/AllPagesPanel.js.map +1 -1
  55. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.d.ts +20 -0
  56. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js +50 -0
  57. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesEditDisplay.js.map +1 -0
  58. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.d.ts +7 -0
  59. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js +23 -0
  60. package/build/esm/components/AsideHeader/components/AllPagesPanel/allPagesSortable.js.map +1 -0
  61. package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.d.ts +1 -1
  62. package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.js +1 -1
  63. package/build/esm/components/AsideHeader/components/AllPagesPanel/constants.js.map +1 -1
  64. package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.d.ts +10 -1
  65. package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js +28 -6
  66. package/build/esm/components/AsideHeader/components/AllPagesPanel/useGroupedMenuItems.js.map +1 -1
  67. package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.css +1 -1
  68. package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.d.ts +4 -0
  69. package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.js +92 -33
  70. package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.js.map +1 -1
  71. package/build/esm/components/AsideHeader/components/CompositeBar/CompositeBar.module.scss.js +1 -1
  72. package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.css +1 -1
  73. package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js +16 -17
  74. package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.js.map +1 -1
  75. package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.module.scss.js +1 -1
  76. package/build/esm/components/AsideHeader/components/CompositeBar/Item/Item.types.d.ts +8 -0
  77. package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js +10 -2
  78. package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopup.js.map +1 -1
  79. package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.d.ts +2 -1
  80. package/build/esm/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.js.map +1 -1
  81. package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.d.ts +2 -1
  82. package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js +2 -1
  83. package/build/esm/components/AsideHeader/components/CompositeBar/ScrollableWithScrollbar/useScrollableScrollbarSync.js.map +1 -1
  84. package/build/esm/components/AsideHeader/components/CompositeBar/constants.d.ts +2 -0
  85. package/build/esm/components/AsideHeader/components/CompositeBar/constants.js +3 -1
  86. package/build/esm/components/AsideHeader/components/CompositeBar/constants.js.map +1 -1
  87. package/build/esm/components/AsideHeader/components/CompositeBar/grouping.d.ts +27 -8
  88. package/build/esm/components/AsideHeader/components/CompositeBar/grouping.js +52 -23
  89. package/build/esm/components/AsideHeader/components/CompositeBar/grouping.js.map +1 -1
  90. package/build/esm/components/AsideHeader/components/CompositeBar/utils.d.ts +11 -10
  91. package/build/esm/components/AsideHeader/components/CompositeBar/utils.js +105 -41
  92. package/build/esm/components/AsideHeader/components/CompositeBar/utils.js.map +1 -1
  93. package/build/esm/components/AsideHeader/components/FirstPanel.js +4 -3
  94. package/build/esm/components/AsideHeader/components/FirstPanel.js.map +1 -1
  95. package/build/esm/components/AsideHeader/components/PageLayout/AsideFallback.css +1 -1
  96. package/build/esm/components/AsideHeader/components/PageLayout/PageLayout.css +1 -1
  97. package/build/esm/components/AsideHeader/components/PageLayout/PageLayoutAside.css +1 -1
  98. package/build/esm/components/AsideHeader/types.d.ts +26 -0
  99. package/build/esm/components/AsideHeader/types.js +3 -1
  100. package/build/esm/components/AsideHeader/types.js.map +1 -1
  101. package/package.json +1 -1
@@ -7,10 +7,18 @@ import { ItemPopupNestContext } from './ItemPopupNestContext.js';
7
7
  import styles from './Item.module.scss.js';
8
8
 
9
9
  const b = createBlock('composite-bar-item', styles);
10
- const defaultPopupOffset = { mainAxis: 14 };
10
+ const POPUP_MAIN_AXIS_OFFSET = 14;
11
+ const POPUP_CROSS_AXIS_OFFSET_WITH_TITLE = -30;
12
+ const POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE = 0;
11
13
  const DEFAULT_POPUP_DELAY = 100;
12
14
  const ItemPopup = ({ items, itemClassName, title, open, disabled, type, collapsed = false, hideIcon = false, children, onItemClick, onOpenChange, }) => {
13
15
  const nestedOpenCountRef = React__default.useRef(0);
16
+ const popoverOffset = React__default.useMemo(() => ({
17
+ mainAxis: POPUP_MAIN_AXIS_OFFSET,
18
+ crossAxis: title
19
+ ? POPUP_CROSS_AXIS_OFFSET_WITH_TITLE
20
+ : POPUP_CROSS_AXIS_OFFSET_WITHOUT_TITLE,
21
+ }), [title]);
14
22
  const registerNestedOpen = React__default.useCallback((delta) => {
15
23
  nestedOpenCountRef.current = Math.max(0, nestedOpenCountRef.current + delta);
16
24
  }, []);
@@ -35,7 +43,7 @@ const ItemPopup = ({ items, itemClassName, title, open, disabled, type, collapse
35
43
  if (nextOpen && disabled)
36
44
  return;
37
45
  wrappedOnOpenChange(nextOpen);
38
- }, placement: "right-start", strategy: "fixed", openDelay: DEFAULT_POPUP_DELAY, closeDelay: DEFAULT_POPUP_DELAY, offset: defaultPopupOffset, enableSafePolygon: true, className: b('icon-popover', { 'item-type': type }), content: content }, children));
46
+ }, 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));
39
47
  };
40
48
  ItemPopup.displayName = 'ItemPopup';
41
49
 
@@ -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 defaultPopupOffset: NonNullable<PopupProps['offset']> = {mainAxis: 14};\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 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={defaultPopupOffset}\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":["React"],"mappings":";;;;;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QACIA,cAAC,CAAA,aAAA,CAAA,OAAO,EACJ,EAAA,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,QAAQ,KAAI;YACvB,IAAI,QAAQ,IAAI,QAAQ;gBAAE;YAC1B,mBAAmB,CAAC,QAAQ,CAAC;AACjC,SAAC,EACD,SAAS,EAAC,aAAa,EACvB,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,kBAAkB,EAC1B,iBAAiB,EACjB,IAAA,EAAA,SAAS,EAAE,CAAC,CAAC,cAAc,EAAE,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,EACjD,OAAO,EAAE,OAAO,IAEf,QAAQ,CACH;AAElB;AAEA,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
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":["React"],"mappings":";;;;;;;;AAaA,MAAM,CAAC,GAAG,WAAW,CAAC,oBAAoB,EAAE,MAAM,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,GAAGA,cAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAGA,cAAK,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;IAED,MAAM,kBAAkB,GAAGA,cAAK,CAAC,WAAW,CAAC,CAAC,KAAa,KAAI;AAC3D,QAAA,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;KAC/E,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,gBAAgB,GAAGA,cAAK,CAAC,OAAO,CAAC,OAAO,EAAC,kBAAk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CAAC,EAC1B,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,QACpB,aAAa,EAAE,KAAK,EACpB,YAAY,EAAE,KAAK,EACnB,YAAY,EAAE,KAAK,EACnB,kBAAkB,EAAE,SAAS,EAC7B,iBAAiB,EAAE,SAAS,EAC5B,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,KAAK,KAAI;AAChD,wBAAA,YAAY,aAAZ,YAAY,KAAA,SAAA,GAAA,SAAA,GAAZ,YAAY,CAAG,KAAK,CAAC;wBACrB,WAAW,KAAA,IAAA,IAAX,WAAW,KAAA,SAAA,GAAA,SAAA,GAAX,WAAW,CAAG,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC;AACzC,qBAAC,IACH,CACL,EAAA,CACH,CACA,CACsB,CACnC;AAED,IAAA,QACIA,cAAC,CAAA,aAAA,CAAA,OAAO,EACJ,EAAA,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,QAAQ,KAAI;YACvB,IAAI,QAAQ,IAAI,QAAQ;gBAAE;YAC1B,mBAAmB,CAAC,QAAQ,CAAC;AACjC,SAAC,EACD,SAAS,EAAC,aAAa,EACvB,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,aAAa,EACrB,iBAAiB,EACjB,IAAA,EAAA,SAAS,EAAE,CAAC,CAAC,cAAc,EAAE,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,EACjD,OAAO,EAAE,OAAO,IAEf,QAAQ,CACH;AAElB;AAEA,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- export type ItemPopupNestContextValue = {
2
+ type ItemPopupNestContextValue = {
3
3
  registerNestedOpen: (delta: number) => void;
4
4
  };
5
5
  export declare const ItemPopupNestContext: React.Context<ItemPopupNestContextValue | null>;
6
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ItemPopupNestContext.js","sources":["../../../../../../../../src/components/AsideHeader/components/CompositeBar/Item/ItemPopupNestContext.tsx"],"sourcesContent":["import React from 'react';\n\nexport type ItemPopupNestContextValue = {\n registerNestedOpen: (delta: number) => void;\n};\n\nexport const ItemPopupNestContext = React.createContext<ItemPopupNestContextValue | null>(null);\n"],"names":["React"],"mappings":";;AAMa,MAAA,oBAAoB,GAAGA,cAAK,CAAC,aAAa,CAAmC,IAAI;;;;"}
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":["React"],"mappings":";;AAMa,MAAA,oBAAoB,GAAGA,cAAK,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
@@ -6,7 +6,8 @@ const MIN_THUMB_HEIGHT = 24;
6
6
  * Keeps a custom scrollbar thumb and bottom shadow in sync with a native
7
7
  * scroll layer. The scroll element handles touch/keyboard; wheel events on the
8
8
  * overlay track are forwarded to it (the track sits above the scroller, so
9
- * they would not scroll otherwise).
9
+ * they would not scroll otherwise). Wheel, touch, and keyboard on the
10
+ * scrollable area itself are unchanged.
10
11
  *
11
12
  * @param recalcDeps - extra deps that should trigger thumb/shadow recalculation
12
13
  * @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":[],"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,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,QAAQ,CAAC,OAAO,GAAG,qBAAqB,CAAC,MAAK;AAC1C,YAAA,QAA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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":[],"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;AAE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,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__";
@@ -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
- interface GroupHeaderItem extends AsideHeaderItem {
4
- isGroupHeader: true;
5
- groupChildren: AsideHeaderItem[];
6
- /** Optional title shown at the top of the compact popup listing group children. */
7
- groupPopupTitle?: string;
8
- }
9
- export declare function isGroupHeaderItem(item: AsideHeaderItem | GroupHeaderItem): item is GroupHeaderItem;
10
- export declare function getGroupedItems(items: AsideHeaderItem[], groups: MenuGroup[] | undefined): AsideHeaderItem[];
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
- const GROUP_HEADER_ITEM_PREFIX = '__gn-composite-bar__group-header__';
2
- function isGroupHeaderItem(item) {
3
- return 'isGroupHeader' in item && item.isGroupHeader;
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
- function getGroupedItems(items, groups) {
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
- const visibleGroups = groups.filter((g) => !g.hidden);
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
- const hasCurrent = children.some((child) => child.current);
49
- const groupHeaderItem = {
50
- id: `${GROUP_HEADER_ITEM_PREFIX}${groupId}`,
51
- title: group.title,
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.item);
90
+ return result.map((r) => r.row);
62
91
  }
63
92
 
64
- export { getGroupedItems, isGroupHeaderItem };
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\nconst GROUP_HEADER_ITEM_PREFIX = '__gn-composite-bar__group-header__';\n\ninterface GroupHeaderItem extends AsideHeaderItem {\n isGroupHeader: true;\n groupChildren: AsideHeaderItem[];\n /** Optional title shown at the top of the compact popup listing group children. */\n groupPopupTitle?: string;\n}\n\nexport function isGroupHeaderItem(\n item: AsideHeaderItem | GroupHeaderItem,\n): item is GroupHeaderItem {\n return 'isGroupHeader' in item && item.isGroupHeader;\n}\n\nexport function getGroupedItems(\n items: AsideHeaderItem[],\n groups: MenuGroup[] | undefined,\n): AsideHeaderItem[] {\n if (!groups || groups.length === 0) {\n return items;\n }\n\n const visibleGroups = groups.filter((g) => !g.hidden);\n if (visibleGroups.length === 0) {\n return items;\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; item: AsideHeaderItem}> = [];\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 (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\n groupChildrenMap.set(groupId, groupChildren);\n groupFirstIndex.set(groupId, i);\n }\n\n groupChildren.push(item);\n } else {\n ungroupedItems.push({index: i, item});\n }\n }\n\n const result: Array<{index: number; item: AsideHeaderItem}> = [...ungroupedItems];\n\n for (const [groupId, children] of groupChildrenMap.entries()) {\n if (children.length === 0) continue;\n\n const group = groupMap.get(groupId);\n const firstIndex = groupFirstIndex.get(groupId);\n\n if (!group || firstIndex === undefined) {\n continue;\n }\n\n const hasCurrent = children.some((child) => child.current);\n\n const groupHeaderItem: GroupHeaderItem = {\n id: `${GROUP_HEADER_ITEM_PREFIX}${groupId}`,\n title: group.title,\n icon: group.icon,\n current: hasCurrent,\n isGroupHeader: true,\n groupChildren: children,\n groupPopupTitle: group.popupTitle,\n };\n\n result.push({index: firstIndex, item: groupHeaderItem});\n }\n\n result.sort((a, b) => a.index - b.index);\n return result.map((r) => r.item);\n}\n"],"names":[],"mappings":"AAGA,MAAM,wBAAwB,GAAG,oCAAoC;AAS/D,SAAU,iBAAiB,CAC7B,IAAuC,EAAA;AAEvC,IAAA,OAAO,eAAe,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa;AACxD;AAEgB,SAAA,eAAe,CAC3B,KAAwB,EACxB,MAA+B,EAAA;IAE/B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,QAAA,OAAO,KAAK;;AAGhB,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACrD,IAAA,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;AAC5B,QAAA,OAAO,KAAK;;AAGhB,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAqB;AAC7C,IAAA,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE;QAC/B,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC;;AAGjC,IAAA,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA6B;IAC7D,MAAM,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AAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC;AAE1D,QAAA,MAAM,eAAe,GAAoB;AACrC,YAAA,EAAE,EAAE,CAAA,EAAG,wBAAwB,CAAA,EAAG,OAAO,CAAE,CAAA;YAC3C,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,KAAK,CAAC,IAAI;AAChB,YAAA,OAAO,EAAE,UAAU;AACnB,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,aAAa,EAAE,QAAQ;YACvB,eAAe,EAAE,KAAK,CAAC,UAAU;SACpC;AAED,QAAA,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC;;AAG3D,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,IAAI,CAAC;AACpC;;;;"}
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,CAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,KAAK,CAAC,eAAe,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CACzE;AAED,IAAA,MAAM,aAAa,GAAG,CAAA,OAAO,KAAP,IAAA,IAAA,OAAO,KAAP,SAAA,GAAA,SAAA,GAAA,OAAO,CAAE,mBAAmB,IAAG,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,C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,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,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
- * Reorders items so that entries flagged with `afterMoreButton` are pushed
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 compositeItems items to reorder
15
- * @returns new array with `afterMoreButton` items moved to the end, or the
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 getReorderedItems(compositeItems: AsideHeaderItem[]): AsideHeaderItem[];
19
- export declare function getAutosizeListItems(compositeItems: AsideHeaderItem[], height: number, collapseItem: AsideHeaderItem): {
20
- listItems: AsideHeaderItem[];
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
  };
@@ -1,6 +1,6 @@
1
1
  import { Ellipsis } from '@gravity-ui/icons';
2
2
  import { ITEM_HEIGHT, POPUP_REGULAR_ITEM_HEIGHT } from '../../../constants.js';
3
- import { COLLAPSE_ITEM_ID } from './constants.js';
3
+ import { COLLAPSE_ITEM_ID, COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX } from './constants.js';
4
4
 
5
5
  function getItemHeight(compositeItem) {
6
6
  switch (compositeItem.type) {
@@ -61,64 +61,128 @@ function getMoreButtonItem(menuMoreTitle) {
61
61
  iconSize: 18,
62
62
  };
63
63
  }
64
+ function makeGroupHeaderAsideItem(group) {
65
+ return {
66
+ id: `${COMPOSITE_BAR_GROUP_HEADER_ID_PREFIX}${group.id}`,
67
+ title: group.title,
68
+ icon: group.icon,
69
+ // Do not set `current` from children: only nested items should show selection;
70
+ // otherwise the group header and root List row highlight the whole group block.
71
+ };
72
+ }
73
+ function makeOverflowGroupAsideItem(group, children) {
74
+ return {
75
+ id: `__gn-composite-bar__group-overflow__${group.id}`,
76
+ title: group.title,
77
+ icon: group.icon,
78
+ compositeBarMenuPopupItems: children,
79
+ compositeBarMenuPopupTitle: group.popupTitle,
80
+ };
81
+ }
82
+ function getCompositeBarRowLayoutHeight(row) {
83
+ if (row.kind === 'item') {
84
+ return getItemHeight(row.item);
85
+ }
86
+ return getItemHeight(makeGroupHeaderAsideItem(row.group));
87
+ }
64
88
  /**
65
- * Reorders items so that entries flagged with `afterMoreButton` are pushed
66
- * to the end. This keeps the DOM order consistent between `v1` (collapse
67
- * into "More") and `v2` (scrollable) modes.
89
+ * Moves rows whose item has `afterMoreButton` to the end (parity with scroll vs collapse DOM order).
68
90
  *
69
- * @param compositeItems items to reorder
70
- * @returns new array with `afterMoreButton` items moved to the end, or the
71
- * same reference when no reordering is needed
91
+ * @param rows Composite bar rows before ordering.
92
+ * @returns Rows with `afterMoreButton` item rows last, or the same array reference when none.
72
93
  */
73
- function getReorderedItems(compositeItems) {
74
- const afterMoreButtonItems = compositeItems.filter(({ afterMoreButton }) => afterMoreButton);
75
- if (afterMoreButtonItems.length === 0) {
76
- return compositeItems;
94
+ function getReorderedCompositeBarRows(rows) {
95
+ const afterMoreRows = rows.filter((r) => r.kind === 'item' && r.item.afterMoreButton);
96
+ if (afterMoreRows.length === 0) {
97
+ return rows;
77
98
  }
78
- const regularItems = compositeItems.filter(({ afterMoreButton }) => !afterMoreButton);
79
- return [...regularItems, ...afterMoreButtonItems];
99
+ const regularRows = rows.filter((r) => !(r.kind === 'item' && r.item.afterMoreButton));
100
+ return [...regularRows, ...afterMoreRows];
80
101
  }
81
- function getAutosizeListItems(compositeItems, height, collapseItem) {
82
- var _a, _b, _c;
83
- const afterMoreButtonItems = compositeItems.filter(({ afterMoreButton }) => afterMoreButton);
84
- const regularItems = compositeItems.filter(({ afterMoreButton }) => !afterMoreButton);
85
- const listItems = [...regularItems, ...afterMoreButtonItems];
86
- const allItemsHeight = getItemsHeight(listItems);
87
- if (allItemsHeight <= height) {
88
- return { listItems, collapseItems: [] };
102
+ function compositeBarRowsToFlatForMinHeight(rows) {
103
+ const out = [];
104
+ for (const row of rows) {
105
+ if (row.kind === 'item') {
106
+ out.push(row.item);
107
+ }
108
+ else {
109
+ out.push(makeGroupHeaderAsideItem(row.group));
110
+ }
111
+ }
112
+ return out;
113
+ }
114
+ function getCompositeBarRowsMinHeight(rows) {
115
+ return getItemsMinHeight(compositeBarRowsToFlatForMinHeight(rows));
116
+ }
117
+ function getSelectedCompositeBarRowIndex(rows) {
118
+ const index = rows.findIndex((row) => {
119
+ if (row.kind === 'item') {
120
+ return Boolean(row.item.current);
121
+ }
122
+ // Group rows embed their own List; selection is on nested items, not this root row.
123
+ return false;
124
+ });
125
+ return index === -1 ? undefined : index;
126
+ }
127
+ function getAutosizeCompositeBarRows(rows, height, collapseItem) {
128
+ const ordered = getReorderedCompositeBarRows(rows);
129
+ const afterMoreRows = ordered.filter((r) => r.kind === 'item' && r.item.afterMoreButton);
130
+ const regularRows = ordered.filter((r) => !(r.kind === 'item' && r.item.afterMoreButton));
131
+ const listRows = [...regularRows, ...afterMoreRows];
132
+ const allRowsHeight = listRows.reduce((sum, row) => sum + getCompositeBarRowLayoutHeight(row), 0);
133
+ if (allRowsHeight <= height) {
134
+ return { listRows, collapseItems: [] };
89
135
  }
90
136
  const collapseItemHeight = getItemHeight(collapseItem);
91
- listItems.splice(regularItems.length, 0, collapseItem);
137
+ listRows.splice(regularRows.length, 0, { kind: 'item', item: collapseItem });
92
138
  const collapseItems = [];
93
- let listHeight = allItemsHeight + collapseItemHeight;
94
- let index = listItems.length;
139
+ let listHeight = allRowsHeight + collapseItemHeight;
140
+ let index = listRows.length;
95
141
  while (listHeight > height) {
96
142
  if (index === 0) {
97
143
  break;
98
144
  }
99
145
  index--;
100
- const compositeItem = listItems[index];
101
- if (compositeItem.pinned ||
102
- compositeItem.id === COLLAPSE_ITEM_ID ||
103
- compositeItem.afterMoreButton) {
104
- continue;
146
+ const row = listRows[index];
147
+ if (row.kind === 'item') {
148
+ const compositeItem = row.item;
149
+ if (compositeItem.pinned ||
150
+ compositeItem.id === COLLAPSE_ITEM_ID ||
151
+ compositeItem.afterMoreButton) {
152
+ continue;
153
+ }
154
+ if (compositeItem.type === 'divider') {
155
+ const nextRow = listRows[index + 1];
156
+ if (index + 1 < listRows.length &&
157
+ (nextRow === null || nextRow === undefined ? undefined : nextRow.kind) === 'item' &&
158
+ nextRow.item.type === 'divider') {
159
+ listHeight -= getItemHeight(compositeItem);
160
+ listRows.splice(index, 1);
161
+ }
162
+ continue;
163
+ }
164
+ listHeight -= getItemHeight(compositeItem);
165
+ collapseItems.unshift(...listRows
166
+ .splice(index, 1)
167
+ .map((r) => r.item));
105
168
  }
106
- if (compositeItem.type === 'divider') {
107
- if (index + 1 < listItems.length && ((_a = listItems[index + 1]) === null || _a === undefined ? undefined : _a.type) === 'divider') {
108
- listHeight -= getItemHeight(compositeItem);
109
- listItems.splice(index, 1);
169
+ else {
170
+ listHeight -= getCompositeBarRowLayoutHeight(row);
171
+ const [removed] = listRows.splice(index, 1);
172
+ if ((removed === null || removed === undefined ? undefined : removed.kind) === 'group') {
173
+ collapseItems.unshift(makeOverflowGroupAsideItem(removed.group, removed.items));
110
174
  }
111
- continue;
112
175
  }
113
- listHeight -= getItemHeight(compositeItem);
114
- collapseItems.unshift(...listItems.splice(index, 1));
115
176
  }
116
- if (((_b = listItems[index]) === null || _b === undefined ? undefined : _b.type) === 'divider' &&
117
- (index === 0 || ((_c = listItems[index - 1]) === null || _c === undefined ? undefined : _c.type) === 'divider')) {
118
- listItems.splice(index, 1);
177
+ const at = listRows[index];
178
+ const prev = listRows[index - 1];
179
+ if ((at === null || at === undefined ? undefined : at.kind) === 'item' &&
180
+ at.item.type === 'divider' &&
181
+ (index === 0 || ((prev === null || prev === undefined ? undefined : prev.kind) === 'item' && prev.item.type === 'divider'))) {
182
+ listRows.splice(index, 1);
119
183
  }
120
- return { listItems, collapseItems };
184
+ return { listRows, collapseItems };
121
185
  }
122
186
 
123
- export { getAutosizeListItems, getItemHeight, getItemsHeight, getItemsMinHeight, getMoreButtonItem, getPopupItemHeight, getPopupItemsHeight, getReorderedItems, getSelectedItemIndex };
187
+ export { getAutosizeCompositeBarRows, getCompositeBarRowsMinHeight, getItemHeight, getItemsHeight, getMoreButtonItem, getPopupItemHeight, getPopupItemsHeight, getReorderedCompositeBarRows, getSelectedCompositeBarRowIndex, getSelectedItemIndex, makeGroupHeaderAsideItem };
124
188
  //# sourceMappingURL=utils.js.map