@fluentui/priority-overflow 9.2.1 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui/priority-overflow
2
2
 
3
- This log was last generated on Fri, 31 Oct 2025 16:17:34 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 12 Feb 2026 10:42:45 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.3.0](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.3.0)
8
+
9
+ Thu, 12 Feb 2026 10:42:45 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.2.1..@fluentui/priority-overflow_v9.3.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: add support for pinned items ([PR #35712](https://github.com/microsoft/fluentui/pull/35712) by olfedias@microsoft.com)
15
+
7
16
  ## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.2.1)
8
17
 
9
- Fri, 31 Oct 2025 16:17:34 GMT
18
+ Fri, 31 Oct 2025 16:22:02 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.2.0..@fluentui/priority-overflow_v9.2.1)
11
20
 
12
21
  ### Patches
package/dist/index.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare type OverflowDirection = 'start' | 'end';
59
59
 
60
60
  export declare interface OverflowDividerEntry {
61
61
  /**
62
- * HTML element that will be disappear when overflowed
62
+ * HTML element that will disappear when overflowed
63
63
  */
64
64
  element: HTMLElement;
65
65
  groupId: string;
@@ -91,6 +91,12 @@ export declare interface OverflowItemEntry {
91
91
  */
92
92
  id: string;
93
93
  groupId?: string;
94
+ /**
95
+ * If true, the item will never overflow and will always be visible.
96
+ * Pinned items are excluded from the overflow count.
97
+ * @default false
98
+ */
99
+ pinned?: boolean;
94
100
  }
95
101
 
96
102
  /**
@@ -45,6 +45,10 @@ import { createPriorityQueue } from './priorityQueue';
45
45
  if (!lte || !rte) {
46
46
  return lte ? 1 : -1;
47
47
  }
48
+ // Pinned items have "infinite" priority - they should never be hidden
49
+ if (lte.pinned !== rte.pinned) {
50
+ return lte.pinned ? 1 : -1;
51
+ }
48
52
  if (lte.priority !== rte.priority) {
49
53
  return lte.priority > rte.priority ? 1 : -1;
50
54
  }
@@ -130,6 +134,12 @@ import { createPriorityQueue } from './priorityQueue';
130
134
  }
131
135
  // Remove items until there's no more overflow
132
136
  while(occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
137
+ var _overflowItems_nextItemId;
138
+ const nextItemId = visibleItemQueue.peek();
139
+ // Never hide pinned items - they should always remain visible
140
+ if (nextItemId && ((_overflowItems_nextItemId = overflowItems[nextItemId]) === null || _overflowItems_nextItemId === void 0 ? void 0 : _overflowItems_nextItemId.pinned)) {
141
+ break;
142
+ }
133
143
  hideItem();
134
144
  }
135
145
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { observeResize } from './createResizeObserver';\nimport { debounce } from './debounce';\nimport { createPriorityQueue, PriorityQueue } from './priorityQueue';\nimport type {\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n OverflowDividerEntry,\n} from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n // calls to `offsetWidth or offsetHeight` can happen multiple times in an update\n // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes\n const sizeCache = new Map<HTMLElement, number>();\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n // Initially true to force dispatch on first mount\n let forceDispatch = true;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n hasHiddenItems: false,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n let disposeResizeObserver: () => void = () => null;\n\n const getNextItem = (queueToDequeue: PriorityQueue<string>, queueToEnqueue: PriorityQueue<string>) => {\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n\n const groupManager = createGroupManager();\n\n function compareItems(lt: string | null, rt: string | null): number {\n if (!lt || !rt) {\n return 0;\n }\n\n const lte = overflowItems[lt];\n const rte = overflowItems[rt];\n\n // TODO this should not happen but there have been reports of one of these items being undefined\n // Try to find a consistent repro for this\n if (!lte || !rte) {\n return lte ? 1 : -1;\n }\n\n if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n\n // Node.DOCUMENT_POSITION_FOLLOWING = 4, Node.DOCUMENT_POSITION_PRECEDING = 2\n const positionStatusBit = options.overflowDirection === 'end' ? 4 : 2;\n\n // eslint-disable-next-line no-bitwise\n return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;\n }\n\n function getElementAxisSize(\n horizontal: 'clientWidth' | 'offsetWidth',\n vertical: 'clientHeight' | 'offsetHeight',\n el: HTMLElement,\n ): number {\n if (!sizeCache.has(el)) {\n sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);\n }\n\n return sizeCache.get(el)!;\n }\n\n const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');\n const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => -1 * compareItems(a, b));\n\n const visibleItemQueue = createPriorityQueue<string>(compareItems);\n\n function occupiedSize(): number {\n const totalItemSize = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n const totalDividerSize = Object.entries(groupManager.groupVisibility()).reduce(\n (acc, [id, state]) =>\n acc + (state !== 'hidden' && overflowDividers[id] ? getOffsetSize(overflowDividers[id].element) : 0),\n 0,\n );\n\n const overflowMenuSize =\n (invisibleItemQueue.size() > 0 || options.hasHiddenItems) && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n return totalItemSize + totalDividerSize + overflowMenuSize;\n }\n\n const showItem = () => {\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: true });\n\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: false });\n\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.setAttribute(DATA_OVERFLOWING, '');\n }\n\n groupManager.hideItem(item.id, item.groupId);\n }\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility: groupManager.groupVisibility() });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n sizeCache.clear();\n\n const availableSize = getClientSize(container) - options.padding;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n while (compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0) {\n hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one\n }\n\n // Run the show/hide step twice - the first step might not be correct if\n // it was triggered by a new item being added - new items are always visible by default.\n for (let i = 0; i < 2; i++) {\n // Add items until available width is filled - can result in overflow\n while (\n (occupiedSize() < availableSize && invisibleItemQueue.size() > 0) ||\n invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size\n ) {\n showItem();\n }\n\n // Remove items until there's no more overflow\n while (occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n hideItem();\n }\n }\n\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n disposeResizeObserver = observeResize(container, entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const addDivider: OverflowManager['addDivider'] = divider => {\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeDivider: OverflowManager['removeDivider'] = groupId => {\n if (!overflowDividers[groupId]) {\n return;\n }\n const divider = overflowDividers[groupId];\n if (divider.groupId) {\n delete overflowDividers[groupId];\n divider.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n if (observing) {\n // We might be removing an item in an overflow which would not affect the tops,\n // but we need to update anyway to update the overflow menu state\n forceDispatch = true;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n\n sizeCache.delete(item.element);\n delete overflowItems[itemId];\n update();\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n disposeResizeObserver();\n\n // reset flags\n container = undefined;\n observing = false;\n forceDispatch = true;\n\n // clear all entries\n Object.keys(overflowItems).forEach(itemId => removeItem(itemId));\n Object.keys(overflowDividers).forEach(dividerId => removeDivider(dividerId));\n removeOverflowMenu();\n sizeCache.clear();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n addDivider,\n removeDivider,\n };\n}\n\nconst createGroupManager = () => {\n const groupVisibility: Record<string, OverflowGroupState> = {};\n const groups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n function updateGroupVisibility(groupId: string) {\n const group = groups[groupId];\n if (group.invisibleItemIds.size && group.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (group.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n }\n function isGroupVisible(groupId: string) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: () => groupVisibility,\n isSingleItemVisible(itemId: string, groupId: string) {\n return (\n isGroupVisible(groupId) &&\n groups[groupId].visibleItemIds.has(itemId) &&\n groups[groupId].visibleItemIds.size === 1\n );\n },\n addItem(itemId: string, groupId: string) {\n groups[groupId] ??= {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n };\n};\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_GROUP","observeResize","debounce","createPriorityQueue","createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","hasHiddenItems","overflowItems","overflowDividers","disposeResizeObserver","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","groupManager","createGroupManager","compareItems","lt","rt","lte","rte","priority","positionStatusBit","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","has","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","a","b","visibleItemQueue","occupiedSize","totalItemSize","all","map","id","reduce","prev","current","totalDividerSize","Object","entries","groupVisibility","acc","state","overflowMenuSize","size","showItem","item","visible","groupId","isSingleItemVisible","removeAttribute","hideItem","setAttribute","dispatchOverflowUpdate","visibleItemIds","invisibleItemIds","visibleItems","itemId","invisibleItems","processOverflowItems","clear","availableSize","visibleTop","peek","invisibleTop","i","forceUpdate","update","observe","observedContainer","userOptions","assign","values","forEach","addItem","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","removeItem","remove","delete","disconnect","keys","dividerId","groups","updateGroupVisibility","group","isGroupVisible","Set","add"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,mBAAmB,QAAQ,WAAW;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,mBAAmB,QAAuB,kBAAkB;AASrE;;;CAGC,GACD,OAAO,SAASC;IACd,gFAAgF;IAChF,2FAA2F;IAC3F,MAAMC,YAAY,IAAIC;IACtB,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY;IAChB,+FAA+F;IAC/F,kDAAkD;IAClD,IAAIC,gBAAgB;IACpB,MAAMC,UAAoC;QACxCC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAMC;QAC9BC,kBAAkB,IAAMD;QACxBE,gBAAgB;IAClB;IAEA,MAAMC,gBAAmD,CAAC;IAC1D,MAAMC,mBAAyD,CAAC;IAChE,IAAIC,wBAAoC,IAAM;IAE9C,MAAMC,cAAc,CAACC,gBAAuCC;QAC1D,MAAMC,WAAWF,eAAeG,OAAO;QACvCF,eAAeG,OAAO,CAACF;QACvB,OAAON,aAAa,CAACM,SAAS;IAChC;IAEA,MAAMG,eAAeC;IAErB,SAASC,aAAaC,EAAiB,EAAEC,EAAiB;QACxD,IAAI,CAACD,MAAM,CAACC,IAAI;YACd,OAAO;QACT;QAEA,MAAMC,MAAMd,aAAa,CAACY,GAAG;QAC7B,MAAMG,MAAMf,aAAa,CAACa,GAAG;QAE7B,gGAAgG;QAChG,0CAA0C;QAC1C,IAAI,CAACC,OAAO,CAACC,KAAK;YAChB,OAAOD,MAAM,IAAI,CAAC;QACpB;QAEA,IAAIA,IA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
+ {"version":3,"sources":["../src/overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { observeResize } from './createResizeObserver';\nimport { debounce } from './debounce';\nimport { createPriorityQueue, PriorityQueue } from './priorityQueue';\nimport type {\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n OverflowDividerEntry,\n} from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n // calls to `offsetWidth or offsetHeight` can happen multiple times in an update\n // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes\n const sizeCache = new Map<HTMLElement, number>();\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n // Initially true to force dispatch on first mount\n let forceDispatch = true;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n hasHiddenItems: false,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n let disposeResizeObserver: () => void = () => null;\n\n const getNextItem = (queueToDequeue: PriorityQueue<string>, queueToEnqueue: PriorityQueue<string>) => {\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n\n const groupManager = createGroupManager();\n\n function compareItems(lt: string | null, rt: string | null): number {\n if (!lt || !rt) {\n return 0;\n }\n\n const lte = overflowItems[lt];\n const rte = overflowItems[rt];\n\n // TODO this should not happen but there have been reports of one of these items being undefined\n // Try to find a consistent repro for this\n if (!lte || !rte) {\n return lte ? 1 : -1;\n }\n\n // Pinned items have \"infinite\" priority - they should never be hidden\n if (lte.pinned !== rte.pinned) {\n return lte.pinned ? 1 : -1;\n }\n\n if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n\n // Node.DOCUMENT_POSITION_FOLLOWING = 4, Node.DOCUMENT_POSITION_PRECEDING = 2\n const positionStatusBit = options.overflowDirection === 'end' ? 4 : 2;\n\n // eslint-disable-next-line no-bitwise\n return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;\n }\n\n function getElementAxisSize(\n horizontal: 'clientWidth' | 'offsetWidth',\n vertical: 'clientHeight' | 'offsetHeight',\n el: HTMLElement,\n ): number {\n if (!sizeCache.has(el)) {\n sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);\n }\n\n return sizeCache.get(el)!;\n }\n\n const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');\n const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => -1 * compareItems(a, b));\n\n const visibleItemQueue = createPriorityQueue<string>(compareItems);\n\n function occupiedSize(): number {\n const totalItemSize = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n const totalDividerSize = Object.entries(groupManager.groupVisibility()).reduce(\n (acc, [id, state]) =>\n acc + (state !== 'hidden' && overflowDividers[id] ? getOffsetSize(overflowDividers[id].element) : 0),\n 0,\n );\n\n const overflowMenuSize =\n (invisibleItemQueue.size() > 0 || options.hasHiddenItems) && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n return totalItemSize + totalDividerSize + overflowMenuSize;\n }\n\n const showItem = () => {\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: true });\n\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: false });\n\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.setAttribute(DATA_OVERFLOWING, '');\n }\n\n groupManager.hideItem(item.id, item.groupId);\n }\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility: groupManager.groupVisibility() });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n sizeCache.clear();\n\n const availableSize = getClientSize(container) - options.padding;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n while (compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0) {\n hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one\n }\n\n // Run the show/hide step twice - the first step might not be correct if\n // it was triggered by a new item being added - new items are always visible by default.\n for (let i = 0; i < 2; i++) {\n // Add items until available width is filled - can result in overflow\n while (\n (occupiedSize() < availableSize && invisibleItemQueue.size() > 0) ||\n invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size\n ) {\n showItem();\n }\n\n // Remove items until there's no more overflow\n while (occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n const nextItemId = visibleItemQueue.peek();\n\n // Never hide pinned items - they should always remain visible\n if (nextItemId && overflowItems[nextItemId]?.pinned) {\n break;\n }\n\n hideItem();\n }\n }\n\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n disposeResizeObserver = observeResize(container, entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const addDivider: OverflowManager['addDivider'] = divider => {\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeDivider: OverflowManager['removeDivider'] = groupId => {\n if (!overflowDividers[groupId]) {\n return;\n }\n const divider = overflowDividers[groupId];\n if (divider.groupId) {\n delete overflowDividers[groupId];\n divider.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n if (observing) {\n // We might be removing an item in an overflow which would not affect the tops,\n // but we need to update anyway to update the overflow menu state\n forceDispatch = true;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n\n sizeCache.delete(item.element);\n delete overflowItems[itemId];\n update();\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n disposeResizeObserver();\n\n // reset flags\n container = undefined;\n observing = false;\n forceDispatch = true;\n\n // clear all entries\n Object.keys(overflowItems).forEach(itemId => removeItem(itemId));\n Object.keys(overflowDividers).forEach(dividerId => removeDivider(dividerId));\n removeOverflowMenu();\n sizeCache.clear();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n addDivider,\n removeDivider,\n };\n}\n\nconst createGroupManager = () => {\n const groupVisibility: Record<string, OverflowGroupState> = {};\n const groups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n function updateGroupVisibility(groupId: string) {\n const group = groups[groupId];\n if (group.invisibleItemIds.size && group.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (group.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n }\n function isGroupVisible(groupId: string) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: () => groupVisibility,\n isSingleItemVisible(itemId: string, groupId: string) {\n return (\n isGroupVisible(groupId) &&\n groups[groupId].visibleItemIds.has(itemId) &&\n groups[groupId].visibleItemIds.size === 1\n );\n },\n addItem(itemId: string, groupId: string) {\n groups[groupId] ??= {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n };\n};\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_GROUP","observeResize","debounce","createPriorityQueue","createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","hasHiddenItems","overflowItems","overflowDividers","disposeResizeObserver","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","groupManager","createGroupManager","compareItems","lt","rt","lte","rte","pinned","priority","positionStatusBit","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","has","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","a","b","visibleItemQueue","occupiedSize","totalItemSize","all","map","id","reduce","prev","current","totalDividerSize","Object","entries","groupVisibility","acc","state","overflowMenuSize","size","showItem","item","visible","groupId","isSingleItemVisible","removeAttribute","hideItem","setAttribute","dispatchOverflowUpdate","visibleItemIds","invisibleItemIds","visibleItems","itemId","invisibleItems","processOverflowItems","clear","availableSize","visibleTop","peek","invisibleTop","i","nextItemId","forceUpdate","update","observe","observedContainer","userOptions","assign","values","forEach","addItem","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","removeItem","remove","delete","disconnect","keys","dividerId","groups","updateGroupVisibility","group","isGroupVisible","Set","add"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,mBAAmB,QAAQ,WAAW;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,mBAAmB,QAAuB,kBAAkB;AASrE;;;CAGC,GACD,OAAO,SAASC;IACd,gFAAgF;IAChF,2FAA2F;IAC3F,MAAMC,YAAY,IAAIC;IACtB,IAAIC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AK;IAChF;IACA,OAAO;QACLR,iBAAiB,IAAMA;QACvBS,qBAAoBQ,MAAc,EAAET,OAAe;YACjD,OACE0C,eAAe1C,YACfuC,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAACnC,GAAG,CAACsC,WACnC8B,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAACV,IAAI,KAAK;QAE5C;QACA+B,SAAQlB,MAAc,EAAET,OAAe;gBACrCuC,SAAOvC;;YAAPuC,MAAAA,UAAAA,OAAM,CAACvC,WAAAA,QAAQ,iCAAfuC,OAAM,CAACvC,SAAQ,GAAK;gBAClBM,gBAAgB,IAAIqC;gBACpBpC,kBAAkB,IAAIoC;YACxB;YAEAJ,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAACsC,GAAG,CAACnC;YACnC+B,sBAAsBxC;QACxB;QACAiC,YAAWxB,MAAc,EAAET,OAAe;YACxCuC,MAAM,CAACvC,QAAQ,CAACO,gBAAgB,CAAC4B,MAAM,CAAC1B;YACxC8B,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAAC6B,MAAM,CAAC1B;YACtC+B,sBAAsBxC;QACxB;QACAH,UAASY,MAAc,EAAET,OAAe;YACtCuC,MAAM,CAACvC,QAAQ,CAACO,gBAAgB,CAAC4B,MAAM,CAAC1B;YACxC8B,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAACsC,GAAG,CAACnC;YACnC+B,sBAAsBxC;QACxB;QACAG,UAASM,MAAc,EAAET,OAAe;YACtCuC,MAAM,CAACvC,QAAQ,CAACO,gBAAgB,CAACqC,GAAG,CAACnC;YACrC8B,MAAM,CAACvC,QAAQ,CAACM,cAAc,CAAC6B,MAAM,CAAC1B;YACtC+B,sBAAsBxC;QACxB;IACF;AACF"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export type OverflowDirection = 'start' | 'end';\nexport type OverflowAxis = 'horizontal' | 'vertical';\nexport type OverflowGroupState = 'visible' | 'hidden' | 'overflow';\nexport interface OverflowItemEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n /**\n * Lower priority items are invisible first when the container is overflowed\n * @default 0\n */\n priority: number;\n /**\n * Specific id, used to track visibility and provide updates to consumers\n */\n id: string;\n\n groupId?: string;\n}\n\nexport interface OverflowDividerEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n\n groupId: string;\n}\n\n/**\n * signature similar to standard event listeners, but typed to handle the custom event\n */\nexport type OnUpdateOverflow = (data: OverflowEventPayload) => void;\n\nexport type OnUpdateItemVisibility = (data: OnUpdateItemVisibilityPayload) => void;\n\n/**\n * Payload of the custom DOM event for overflow updates\n */\nexport interface OverflowEventPayload {\n visibleItems: OverflowItemEntry[];\n invisibleItems: OverflowItemEntry[];\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\nexport interface OnUpdateItemVisibilityPayload {\n item: OverflowItemEntry;\n visible: boolean;\n}\n\nexport interface ObserveOptions {\n /**\n * Padding (in px) at the end of the container before overflow occurs\n * Useful to account for extra elements (i.e. dropdown menu)\n * or to account for any kinds of margins between items which are hard to measure with JS\n * @default 10\n */\n padding?: number;\n /**\n * Direction where items are removed when overflow occurs\n * @default end\n */\n overflowDirection?: OverflowDirection;\n\n /**\n * Horizontal or vertical overflow\n * @default horizontal\n */\n overflowAxis?: OverflowAxis;\n\n /**\n * The minimum number of visible items\n */\n minimumVisible?: number;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateItemVisibility: OnUpdateItemVisibility;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateOverflow: OnUpdateOverflow;\n\n /**\n * When true, the overflow menu has default hidden items\n * @default false\n */\n hasHiddenItems?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface OverflowManager {\n /**\n * Starts observing the container and managing the overflow state\n */\n observe: (container: HTMLElement, options: ObserveOptions) => void;\n /**\n * Stops observing the container\n */\n disconnect: () => void;\n /**\n * Add overflow items\n */\n addItem: (items: OverflowItemEntry) => void;\n /**\n * Remove overflow item\n */\n removeItem: (itemId: string) => void;\n /**\n * Manually update the overflow, updates are batched and async\n */\n update: () => void;\n /**\n * Manually update the overflow sync\n */\n forceUpdate: () => void;\n\n /**\n * Adds an element that opens an overflow menu. This is used to calculate\n * available space and check if additional items need to overflow\n */\n addOverflowMenu: (element: HTMLElement) => void;\n\n /**\n * Add overflow divider\n */\n addDivider: (divider: OverflowDividerEntry) => void;\n\n /**\n * Remove overflow divider\n */\n removeDivider: (groupId: string) => void;\n\n /**\n * Unsets the overflow menu element\n */\n removeOverflowMenu: () => void;\n}\n"],"names":[],"mappings":"AA6FA;;CAEC,GACD,WA8CC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export type OverflowDirection = 'start' | 'end';\nexport type OverflowAxis = 'horizontal' | 'vertical';\nexport type OverflowGroupState = 'visible' | 'hidden' | 'overflow';\nexport interface OverflowItemEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n /**\n * Lower priority items are invisible first when the container is overflowed\n * @default 0\n */\n priority: number;\n /**\n * Specific id, used to track visibility and provide updates to consumers\n */\n id: string;\n\n groupId?: string;\n\n /**\n * If true, the item will never overflow and will always be visible.\n * Pinned items are excluded from the overflow count.\n * @default false\n */\n pinned?: boolean;\n}\n\nexport interface OverflowDividerEntry {\n /**\n * HTML element that will disappear when overflowed\n */\n element: HTMLElement;\n\n groupId: string;\n}\n\n/**\n * signature similar to standard event listeners, but typed to handle the custom event\n */\nexport type OnUpdateOverflow = (data: OverflowEventPayload) => void;\n\nexport type OnUpdateItemVisibility = (data: OnUpdateItemVisibilityPayload) => void;\n\n/**\n * Payload of the custom DOM event for overflow updates\n */\nexport interface OverflowEventPayload {\n visibleItems: OverflowItemEntry[];\n invisibleItems: OverflowItemEntry[];\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\nexport interface OnUpdateItemVisibilityPayload {\n item: OverflowItemEntry;\n visible: boolean;\n}\n\nexport interface ObserveOptions {\n /**\n * Padding (in px) at the end of the container before overflow occurs\n * Useful to account for extra elements (i.e. dropdown menu)\n * or to account for any kinds of margins between items which are hard to measure with JS\n * @default 10\n */\n padding?: number;\n /**\n * Direction where items are removed when overflow occurs\n * @default end\n */\n overflowDirection?: OverflowDirection;\n\n /**\n * Horizontal or vertical overflow\n * @default horizontal\n */\n overflowAxis?: OverflowAxis;\n\n /**\n * The minimum number of visible items\n */\n minimumVisible?: number;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateItemVisibility: OnUpdateItemVisibility;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateOverflow: OnUpdateOverflow;\n\n /**\n * When true, the overflow menu has default hidden items\n * @default false\n */\n hasHiddenItems?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface OverflowManager {\n /**\n * Starts observing the container and managing the overflow state\n */\n observe: (container: HTMLElement, options: ObserveOptions) => void;\n /**\n * Stops observing the container\n */\n disconnect: () => void;\n /**\n * Add overflow items\n */\n addItem: (items: OverflowItemEntry) => void;\n /**\n * Remove overflow item\n */\n removeItem: (itemId: string) => void;\n /**\n * Manually update the overflow, updates are batched and async\n */\n update: () => void;\n /**\n * Manually update the overflow sync\n */\n forceUpdate: () => void;\n\n /**\n * Adds an element that opens an overflow menu. This is used to calculate\n * available space and check if additional items need to overflow\n */\n addOverflowMenu: (element: HTMLElement) => void;\n\n /**\n * Add overflow divider\n */\n addDivider: (divider: OverflowDividerEntry) => void;\n\n /**\n * Remove overflow divider\n */\n removeDivider: (groupId: string) => void;\n\n /**\n * Unsets the overflow menu element\n */\n removeOverflowMenu: () => void;\n}\n"],"names":[],"mappings":"AAoGA;;CAEC,GACD,WA8CC"}
@@ -52,6 +52,10 @@ function createOverflowManager() {
52
52
  if (!lte || !rte) {
53
53
  return lte ? 1 : -1;
54
54
  }
55
+ // Pinned items have "infinite" priority - they should never be hidden
56
+ if (lte.pinned !== rte.pinned) {
57
+ return lte.pinned ? 1 : -1;
58
+ }
55
59
  if (lte.priority !== rte.priority) {
56
60
  return lte.priority > rte.priority ? 1 : -1;
57
61
  }
@@ -137,6 +141,12 @@ function createOverflowManager() {
137
141
  }
138
142
  // Remove items until there's no more overflow
139
143
  while(occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
144
+ var _overflowItems_nextItemId;
145
+ const nextItemId = visibleItemQueue.peek();
146
+ // Never hide pinned items - they should always remain visible
147
+ if (nextItemId && ((_overflowItems_nextItemId = overflowItems[nextItemId]) === null || _overflowItems_nextItemId === void 0 ? void 0 : _overflowItems_nextItemId.pinned)) {
148
+ break;
149
+ }
140
150
  hideItem();
141
151
  }
142
152
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { observeResize } from './createResizeObserver';\nimport { debounce } from './debounce';\nimport { createPriorityQueue, PriorityQueue } from './priorityQueue';\nimport type {\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n OverflowDividerEntry,\n} from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n // calls to `offsetWidth or offsetHeight` can happen multiple times in an update\n // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes\n const sizeCache = new Map<HTMLElement, number>();\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n // Initially true to force dispatch on first mount\n let forceDispatch = true;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n hasHiddenItems: false,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n let disposeResizeObserver: () => void = () => null;\n\n const getNextItem = (queueToDequeue: PriorityQueue<string>, queueToEnqueue: PriorityQueue<string>) => {\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n\n const groupManager = createGroupManager();\n\n function compareItems(lt: string | null, rt: string | null): number {\n if (!lt || !rt) {\n return 0;\n }\n\n const lte = overflowItems[lt];\n const rte = overflowItems[rt];\n\n // TODO this should not happen but there have been reports of one of these items being undefined\n // Try to find a consistent repro for this\n if (!lte || !rte) {\n return lte ? 1 : -1;\n }\n\n if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n\n // Node.DOCUMENT_POSITION_FOLLOWING = 4, Node.DOCUMENT_POSITION_PRECEDING = 2\n const positionStatusBit = options.overflowDirection === 'end' ? 4 : 2;\n\n // eslint-disable-next-line no-bitwise\n return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;\n }\n\n function getElementAxisSize(\n horizontal: 'clientWidth' | 'offsetWidth',\n vertical: 'clientHeight' | 'offsetHeight',\n el: HTMLElement,\n ): number {\n if (!sizeCache.has(el)) {\n sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);\n }\n\n return sizeCache.get(el)!;\n }\n\n const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');\n const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => -1 * compareItems(a, b));\n\n const visibleItemQueue = createPriorityQueue<string>(compareItems);\n\n function occupiedSize(): number {\n const totalItemSize = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n const totalDividerSize = Object.entries(groupManager.groupVisibility()).reduce(\n (acc, [id, state]) =>\n acc + (state !== 'hidden' && overflowDividers[id] ? getOffsetSize(overflowDividers[id].element) : 0),\n 0,\n );\n\n const overflowMenuSize =\n (invisibleItemQueue.size() > 0 || options.hasHiddenItems) && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n return totalItemSize + totalDividerSize + overflowMenuSize;\n }\n\n const showItem = () => {\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: true });\n\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: false });\n\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.setAttribute(DATA_OVERFLOWING, '');\n }\n\n groupManager.hideItem(item.id, item.groupId);\n }\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility: groupManager.groupVisibility() });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n sizeCache.clear();\n\n const availableSize = getClientSize(container) - options.padding;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n while (compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0) {\n hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one\n }\n\n // Run the show/hide step twice - the first step might not be correct if\n // it was triggered by a new item being added - new items are always visible by default.\n for (let i = 0; i < 2; i++) {\n // Add items until available width is filled - can result in overflow\n while (\n (occupiedSize() < availableSize && invisibleItemQueue.size() > 0) ||\n invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size\n ) {\n showItem();\n }\n\n // Remove items until there's no more overflow\n while (occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n hideItem();\n }\n }\n\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n disposeResizeObserver = observeResize(container, entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const addDivider: OverflowManager['addDivider'] = divider => {\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeDivider: OverflowManager['removeDivider'] = groupId => {\n if (!overflowDividers[groupId]) {\n return;\n }\n const divider = overflowDividers[groupId];\n if (divider.groupId) {\n delete overflowDividers[groupId];\n divider.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n if (observing) {\n // We might be removing an item in an overflow which would not affect the tops,\n // but we need to update anyway to update the overflow menu state\n forceDispatch = true;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n\n sizeCache.delete(item.element);\n delete overflowItems[itemId];\n update();\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n disposeResizeObserver();\n\n // reset flags\n container = undefined;\n observing = false;\n forceDispatch = true;\n\n // clear all entries\n Object.keys(overflowItems).forEach(itemId => removeItem(itemId));\n Object.keys(overflowDividers).forEach(dividerId => removeDivider(dividerId));\n removeOverflowMenu();\n sizeCache.clear();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n addDivider,\n removeDivider,\n };\n}\n\nconst createGroupManager = () => {\n const groupVisibility: Record<string, OverflowGroupState> = {};\n const groups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n function updateGroupVisibility(groupId: string) {\n const group = groups[groupId];\n if (group.invisibleItemIds.size && group.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (group.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n }\n function isGroupVisible(groupId: string) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: () => groupVisibility,\n isSingleItemVisible(itemId: string, groupId: string) {\n return (\n isGroupVisible(groupId) &&\n groups[groupId].visibleItemIds.has(itemId) &&\n groups[groupId].visibleItemIds.size === 1\n );\n },\n addItem(itemId: string, groupId: string) {\n groups[groupId] ??= {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n };\n};\n"],"names":["createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","hasHiddenItems","overflowItems","overflowDividers","disposeResizeObserver","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","groupManager","createGroupManager","compareItems","lt","rt","lte","rte","priority","positionStatusBit","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","has","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","createPriorityQueue","a","b","visibleItemQueue","occupiedSize","totalItemSize","all","map","id","reduce","prev","current","totalDividerSize","Object","entries","groupVisibility","acc","state","overflowMenuSize","size","showItem","item","visible","groupId","isSingleItemVisible","removeAttribute","DATA_OVERFLOWING","hideItem","setAttribute","dispatchOverflowUpdate","visibleItemIds","invisibleItemIds","visibleItems","itemId","invisibleItems","processOverflowItems","clear","availableSize","visibleTop","peek","invisibleTop","i","forceUpdate","update","debounce","observe","observedContainer","userOptions","assign","values","forEach","observeResize","addItem","DATA_OVERFLOW_GROUP","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","removeItem","remove","delete","disconnect","keys","dividerId","groups","updateGroupVisibility","group","isGroupVisible","Set","add"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;wBAhBsC;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,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAACrC,GAAG,CAACwC,WACnCgC,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAACX,IAAI,KAAK;QAE5C;QACAiC,SAAQnB,MAAc,EAAEV,OAAe;gBACrC0C,SAAO1C;;YAAP0C,MAAAA,UAAAA,OAAM,CAAC1C,WAAAA,QAAQ,iCAAf0C,OAAM,CAAC1C,SAAQ,GAAK;gBAClBO,gBAAgB,IAAIuC;gBACpBtC,kBAAkB,IAAIsC;YACxB;YAEAJ,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAACwC,GAAG,CAACrC;YACnCiC,sBAAsB3C;QACxB;QACAoC,YAAW1B,MAAc,EAAEV,OAAe;YACxC0C,MAAM,CAAC1C,QAAQ,CAACQ,gBAAgB,CAAC8B,MAAM,CAAC5B;YACxCgC,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAAC+B,MAAM,CAAC5B;YACtCiC,sBAAsB3C;QACxB;QACAH,UAASa,MAAc,EAAEV,OAAe;YACtC0C,MAAM,CAAC1C,QAAQ,CAACQ,gBAAgB,CAAC8B,MAAM,CAAC5B;YACxCgC,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAACwC,GAAG,CAACrC;YACnCiC,sBAAsB3C;QACxB;QACAI,UAASM,MAAc,EAAEV,OAAe;YACtC0C,MAAM,CAAC1C,QAAQ,CAACQ,gBAAgB,CAACuC,GAAG,CAACrC;YACrCgC,MAAM,CAAC1C,QAAQ,CAACO,cAAc,CAAC+B,MAAM,CAAC5B;YACtCiC,sBAAsB3C;QACxB;IACF;AACF"}
1
+ {"version":3,"sources":["../src/overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { observeResize } from './createResizeObserver';\nimport { debounce } from './debounce';\nimport { createPriorityQueue, PriorityQueue } from './priorityQueue';\nimport type {\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n OverflowDividerEntry,\n} from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n // calls to `offsetWidth or offsetHeight` can happen multiple times in an update\n // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes\n const sizeCache = new Map<HTMLElement, number>();\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n // Initially true to force dispatch on first mount\n let forceDispatch = true;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n hasHiddenItems: false,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n let disposeResizeObserver: () => void = () => null;\n\n const getNextItem = (queueToDequeue: PriorityQueue<string>, queueToEnqueue: PriorityQueue<string>) => {\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n\n const groupManager = createGroupManager();\n\n function compareItems(lt: string | null, rt: string | null): number {\n if (!lt || !rt) {\n return 0;\n }\n\n const lte = overflowItems[lt];\n const rte = overflowItems[rt];\n\n // TODO this should not happen but there have been reports of one of these items being undefined\n // Try to find a consistent repro for this\n if (!lte || !rte) {\n return lte ? 1 : -1;\n }\n\n // Pinned items have \"infinite\" priority - they should never be hidden\n if (lte.pinned !== rte.pinned) {\n return lte.pinned ? 1 : -1;\n }\n\n if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n\n // Node.DOCUMENT_POSITION_FOLLOWING = 4, Node.DOCUMENT_POSITION_PRECEDING = 2\n const positionStatusBit = options.overflowDirection === 'end' ? 4 : 2;\n\n // eslint-disable-next-line no-bitwise\n return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;\n }\n\n function getElementAxisSize(\n horizontal: 'clientWidth' | 'offsetWidth',\n vertical: 'clientHeight' | 'offsetHeight',\n el: HTMLElement,\n ): number {\n if (!sizeCache.has(el)) {\n sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);\n }\n\n return sizeCache.get(el)!;\n }\n\n const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');\n const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => -1 * compareItems(a, b));\n\n const visibleItemQueue = createPriorityQueue<string>(compareItems);\n\n function occupiedSize(): number {\n const totalItemSize = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n const totalDividerSize = Object.entries(groupManager.groupVisibility()).reduce(\n (acc, [id, state]) =>\n acc + (state !== 'hidden' && overflowDividers[id] ? getOffsetSize(overflowDividers[id].element) : 0),\n 0,\n );\n\n const overflowMenuSize =\n (invisibleItemQueue.size() > 0 || options.hasHiddenItems) && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n return totalItemSize + totalDividerSize + overflowMenuSize;\n }\n\n const showItem = () => {\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: true });\n\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n options.onUpdateItemVisibility({ item, visible: false });\n\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n overflowDividers[item.groupId]?.element.setAttribute(DATA_OVERFLOWING, '');\n }\n\n groupManager.hideItem(item.id, item.groupId);\n }\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility: groupManager.groupVisibility() });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n sizeCache.clear();\n\n const availableSize = getClientSize(container) - options.padding;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n while (compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0) {\n hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one\n }\n\n // Run the show/hide step twice - the first step might not be correct if\n // it was triggered by a new item being added - new items are always visible by default.\n for (let i = 0; i < 2; i++) {\n // Add items until available width is filled - can result in overflow\n while (\n (occupiedSize() < availableSize && invisibleItemQueue.size() > 0) ||\n invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size\n ) {\n showItem();\n }\n\n // Remove items until there's no more overflow\n while (occupiedSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n const nextItemId = visibleItemQueue.peek();\n\n // Never hide pinned items - they should always remain visible\n if (nextItemId && overflowItems[nextItemId]?.pinned) {\n break;\n }\n\n hideItem();\n }\n }\n\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n disposeResizeObserver = observeResize(container, entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const addDivider: OverflowManager['addDivider'] = divider => {\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeDivider: OverflowManager['removeDivider'] = groupId => {\n if (!overflowDividers[groupId]) {\n return;\n }\n const divider = overflowDividers[groupId];\n if (divider.groupId) {\n delete overflowDividers[groupId];\n divider.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n if (observing) {\n // We might be removing an item in an overflow which would not affect the tops,\n // but we need to update anyway to update the overflow menu state\n forceDispatch = true;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n\n sizeCache.delete(item.element);\n delete overflowItems[itemId];\n update();\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n disposeResizeObserver();\n\n // reset flags\n container = undefined;\n observing = false;\n forceDispatch = true;\n\n // clear all entries\n Object.keys(overflowItems).forEach(itemId => removeItem(itemId));\n Object.keys(overflowDividers).forEach(dividerId => removeDivider(dividerId));\n removeOverflowMenu();\n sizeCache.clear();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n addDivider,\n removeDivider,\n };\n}\n\nconst createGroupManager = () => {\n const groupVisibility: Record<string, OverflowGroupState> = {};\n const groups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n function updateGroupVisibility(groupId: string) {\n const group = groups[groupId];\n if (group.invisibleItemIds.size && group.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (group.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n }\n function isGroupVisible(groupId: string) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: () => groupVisibility,\n isSingleItemVisible(itemId: string, groupId: string) {\n return (\n isGroupVisible(groupId) &&\n groups[groupId].visibleItemIds.has(itemId) &&\n groups[groupId].visibleItemIds.size === 1\n );\n },\n addItem(itemId: string, groupId: string) {\n groups[groupId] ??= {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem(itemId: string, groupId: string) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n };\n};\n"],"names":["createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","hasHiddenItems","overflowItems","overflowDividers","disposeResizeObserver","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","groupManager","createGroupManager","compareItems","lt","rt","lte","rte","pinned","priority","positionStatusBit","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","has","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","createPriorityQueue","a","b","visibleItemQueue","occupiedSize","totalItemSize","all","map","id","reduce","prev","current","totalDividerSize","Object","entries","groupVisibility","acc","state","overflowMenuSize","size","showItem","item","visible","groupId","isSingleItemVisible","removeAttribute","DATA_OVERFLOWING","hideItem","setAttribute","dispatchOverflowUpdate","visibleItemIds","invisibleItemIds","visibleItems","itemId","invisibleItems","processOverflowItems","clear","availableSize","visibleTop","peek","invisibleTop","i","nextItemId","forceUpdate","update","debounce","observe","observedContainer","userOptions","assign","values","forEach","observeResize","addItem","DATA_OVERFLOW_GROUP","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","removeItem","remove","delete","disconnect","keys","dividerId","groups","updateGroupVisibility","group","isGroupVisible","Set","add"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;wBAhBsC;sCACxB;0BACL;+BAC0B;AAa5C,SAASA;IACd,gFAAgF;IAChF,2FAA2F;IAC3F,MAAMC,YAAY,IAAIC;IACtB,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY;IAChB,+FAA+F;IAC/F,kDAAkD;IAClD,IAAIC,gBAAgB;IACpB,MAAMC,UAAoC;QACxCC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAMC;QAC9BC,kBAAkB,IAAMD;QACxBE,gBAAgB;IAClB;IAEA,MAAMC,gBAAmD,CAAC;IAC1D,MAAMC,mBAAyD,CAAC;IAChE,IAAIC,wBAAoC,IAAM;IAE9C,MAAMC,cAAc,C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,SAAO3C;;YAAP2C,MAAAA,UAAAA,OAAM,CAAC3C,WAAAA,QAAQ,iCAAf2C,OAAM,CAAC3C,SAAQ,GAAK;gBAClBO,gBAAgB,IAAIwC;gBACpBvC,kBAAkB,IAAIuC;YACxB;YAEAJ,MAAM,CAAC3C,QAAQ,CAACO,cAAc,CAACyC,GAAG,CAACtC;YACnCkC,sBAAsB5C;QACxB;QACAqC,YAAW3B,MAAc,EAAEV,OAAe;YACxC2C,MAAM,CAAC3C,QAAQ,CAACQ,gBAAgB,CAAC+B,MAAM,CAAC7B;YACxCiC,MAAM,CAAC3C,QAAQ,CAACO,cAAc,CAACgC,MAAM,CAAC7B;YACtCkC,sBAAsB5C;QACxB;QACAH,UAASa,MAAc,EAAEV,OAAe;YACtC2C,MAAM,CAAC3C,QAAQ,CAACQ,gBAAgB,CAAC+B,MAAM,CAAC7B;YACxCiC,MAAM,CAAC3C,QAAQ,CAACO,cAAc,CAACyC,GAAG,CAACtC;YACnCkC,sBAAsB5C;QACxB;QACAI,UAASM,MAAc,EAAEV,OAAe;YACtC2C,MAAM,CAAC3C,QAAQ,CAACQ,gBAAgB,CAACwC,GAAG,CAACtC;YACrCiC,MAAM,CAAC3C,QAAQ,CAACO,cAAc,CAACgC,MAAM,CAAC7B;YACtCkC,sBAAsB5C;QACxB;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/priority-overflow",
3
- "version": "9.2.1",
3
+ "version": "9.3.0",
4
4
  "description": "Vanilla JS utilities to implement overflow menus",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -11,10 +11,6 @@
11
11
  "url": "https://github.com/microsoft/fluentui"
12
12
  },
13
13
  "license": "MIT",
14
- "devDependencies": {
15
- "@fluentui/eslint-plugin": "*",
16
- "@fluentui/scripts-api-extractor": "*"
17
- },
18
14
  "dependencies": {
19
15
  "@swc/helpers": "^0.5.1"
20
16
  },