@fluentui/priority-overflow 9.1.1 → 9.1.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,67 @@
2
2
  "name": "@fluentui/priority-overflow",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 26 Jun 2023 09:51:04 GMT",
5
+ "date": "Wed, 09 Aug 2023 13:11:29 GMT",
6
+ "tag": "@fluentui/priority-overflow_v9.1.3",
7
+ "version": "9.1.3",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "vkozlova@microsoft.com",
12
+ "package": "@fluentui/priority-overflow",
13
+ "commit": "6247214bde5df11e951247f0a6d1278cc98490ea",
14
+ "comment": "fix: inaccurate calculation of size"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Tue, 25 Jul 2023 13:29:15 GMT",
21
+ "tag": "@fluentui/priority-overflow_v9.1.2",
22
+ "version": "9.1.2",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "lingfan.gao@microsoft.com",
27
+ "package": "@fluentui/priority-overflow",
28
+ "commit": "d8493a92520cacac29e9fe341a17d3595bc48343",
29
+ "comment": "fix: Overflow update should run show/hide steps twice"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Thu, 20 Jul 2023 18:27:25 GMT",
36
+ "tag": "@fluentui/priority-overflow_v9.1.1",
37
+ "version": "9.1.1",
38
+ "comments": {
39
+ "none": [
40
+ {
41
+ "author": "olfedias@microsoft.com",
42
+ "package": "@fluentui/priority-overflow",
43
+ "commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6",
44
+ "comment": "chore: migrate to monosize"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Wed, 28 Jun 2023 11:12:22 GMT",
51
+ "tag": "@fluentui/priority-overflow_v9.1.1",
52
+ "version": "9.1.1",
53
+ "comments": {
54
+ "none": [
55
+ {
56
+ "author": "martinhochel@microsoft.com",
57
+ "package": "@fluentui/priority-overflow",
58
+ "commit": "fbe878e9c9785588197481f172c42c2c0a230292",
59
+ "comment": "fix: update .npmignore to unify v8 packages and exclude project.json"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "date": "Mon, 26 Jun 2023 09:53:53 GMT",
6
66
  "tag": "@fluentui/priority-overflow_v9.1.1",
7
67
  "version": "9.1.1",
8
68
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
1
  # Change Log - @fluentui/priority-overflow
2
2
 
3
- This log was last generated on Mon, 26 Jun 2023 09:51:04 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 09 Aug 2023 13:11:29 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.1.3](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.1.3)
8
+
9
+ Wed, 09 Aug 2023 13:11:29 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.1.2..@fluentui/priority-overflow_v9.1.3)
11
+
12
+ ### Patches
13
+
14
+ - fix: inaccurate calculation of size ([PR #28728](https://github.com/microsoft/fluentui/pull/28728) by vkozlova@microsoft.com)
15
+
16
+ ## [9.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.1.2)
17
+
18
+ Tue, 25 Jul 2023 13:29:15 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.1.1..@fluentui/priority-overflow_v9.1.2)
20
+
21
+ ### Patches
22
+
23
+ - fix: Overflow update should run show/hide steps twice ([PR #28628](https://github.com/microsoft/fluentui/pull/28628) by lingfan.gao@microsoft.com)
24
+
7
25
  ## [9.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.1.1)
8
26
 
9
- Mon, 26 Jun 2023 09:51:04 GMT
27
+ Mon, 26 Jun 2023 09:53:53 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.1.0..@fluentui/priority-overflow_v9.1.1)
11
29
 
12
30
  ### Patches
@@ -1,4 +1,3 @@
1
- var _groups, _groupId;
2
1
  import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';
3
2
  import { debounce } from './debounce';
4
3
  import { createPriorityQueue } from './priorityQueue';
@@ -6,6 +5,9 @@ import { createPriorityQueue } from './priorityQueue';
6
5
  * @internal
7
6
  * @returns overflow manager instance
8
7
  */ export function createOverflowManager() {
8
+ // calls to `offsetWidth or offsetHeight` can happen multiple times in an update
9
+ // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes
10
+ const sizeCache = new Map();
9
11
  let container;
10
12
  let overflowMenu;
11
13
  // Set as true when resize observer is observing
@@ -56,6 +58,7 @@ import { createPriorityQueue } from './priorityQueue';
56
58
  return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;
57
59
  },
58
60
  addItem (itemId, groupId) {
61
+ var _groups, _groupId;
59
62
  var _;
60
63
  (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {
61
64
  visibleItemIds: new Set(),
@@ -82,35 +85,29 @@ import { createPriorityQueue } from './priorityQueue';
82
85
  };
83
86
  };
84
87
  const groupManager = createGroupManager();
85
- const invisibleItemQueue = createPriorityQueue((a, b)=>{
86
- const itemA = overflowItems[a];
87
- const itemB = overflowItems[b];
88
- // Higher priority at the top of the queue
89
- const priority = itemB.priority - itemA.priority;
90
- if (priority !== 0) {
91
- return priority;
88
+ function compareItems(lt, rt) {
89
+ if (!lt || !rt) {
90
+ return 0;
91
+ }
92
+ const lte = overflowItems[lt];
93
+ const rte = overflowItems[rt];
94
+ if (lte.priority !== rte.priority) {
95
+ return lte.priority > rte.priority ? 1 : -1;
92
96
  }
93
97
  const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
94
- // equal priority, use DOM order
95
98
  // eslint-disable-next-line no-bitwise
96
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
97
- });
98
- const visibleItemQueue = createPriorityQueue((a, b)=>{
99
- const itemA = overflowItems[a];
100
- const itemB = overflowItems[b];
101
- // Lower priority at the top of the queue
102
- const priority = itemA.priority - itemB.priority;
103
- if (priority !== 0) {
104
- return priority;
99
+ return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;
100
+ }
101
+ function getElementAxisSize(horizontal, vertical, el) {
102
+ if (!sizeCache.has(el)) {
103
+ sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);
105
104
  }
106
- const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
107
- // equal priority, use DOM order
108
- // eslint-disable-next-line no-bitwise
109
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
110
- });
111
- const getOffsetSize = (el)=>{
112
- return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
113
- };
105
+ return sizeCache.get(el);
106
+ }
107
+ const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');
108
+ const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');
109
+ const invisibleItemQueue = createPriorityQueue((a, b)=>-1 * compareItems(a, b));
110
+ const visibleItemQueue = createPriorityQueue(compareItems);
114
111
  function computeSizeChange(entry) {
115
112
  const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;
116
113
  return getOffsetSize(entry.element) + dividerWidth;
@@ -161,22 +158,31 @@ import { createPriorityQueue } from './priorityQueue';
161
158
  if (!container) {
162
159
  return false;
163
160
  }
161
+ sizeCache.clear();
164
162
  const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);
165
163
  function overflowMenuSize() {
166
164
  return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;
167
165
  }
168
- const availableSize = getOffsetSize(container) - totalDividersWidth - options.padding;
166
+ const availableSize = getClientSize(container) - totalDividersWidth - options.padding;
169
167
  // Snapshot of the visible/invisible state to compare for updates
170
168
  const visibleTop = visibleItemQueue.peek();
171
169
  const invisibleTop = invisibleItemQueue.peek();
172
- let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
173
- // Add items until available width is filled - can result in overflow
174
- while(currentWidth + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0){
175
- currentWidth += showItem();
170
+ let currentSize = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
171
+ while(compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0){
172
+ currentSize -= hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one
176
173
  }
177
- // Remove items until there's no more overflow
178
- while(currentWidth + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
179
- currentWidth -= hideItem();
174
+ // Run the show/hide step twice - the first step might not be correct if
175
+ // it was triggered by a new item being added - new items are always visible by default.
176
+ for(let i = 0; i < 2; i++){
177
+ // Add items until available width is filled - can result in overflow
178
+ while(currentSize + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0 || invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size
179
+ ){
180
+ currentSize += showItem();
181
+ }
182
+ // Remove items until there's no more overflow
183
+ while(currentSize + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
184
+ currentSize -= hideItem();
185
+ }
180
186
  }
181
187
  // only update when the state of visible/invisible items has changed
182
188
  return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
@@ -197,6 +203,7 @@ import { createPriorityQueue } from './priorityQueue';
197
203
  };
198
204
  const disconnect = ()=>{
199
205
  observing = false;
206
+ sizeCache.clear();
200
207
  resizeObserver.disconnect();
201
208
  };
202
209
  const addItem = (item)=>{
@@ -252,6 +259,7 @@ import { createPriorityQueue } from './priorityQueue';
252
259
  groupManager.removeItem(item.id, item.groupId);
253
260
  item.element.removeAttribute(DATA_OVERFLOW_GROUP);
254
261
  }
262
+ sizeCache.delete(item.element);
255
263
  delete overflowItems[itemId];
256
264
  update();
257
265
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\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 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 };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\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 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\n const groupManager = createGroupManager();\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const visibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const getOffsetSize = (el: HTMLElement) => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n\n function computeSizeChange(entry: OverflowItemEntry) {\n const dividerWidth =\n entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId]\n ? getOffsetSize(overflowDividers[entry.groupId].element)\n : 0;\n\n return getOffsetSize(entry.element) + dividerWidth;\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 return computeSizeChange(item);\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n const width = computeSizeChange(item);\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 return width;\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 const totalDividersWidth = Object.values(overflowDividers)\n .map(dvdr => (dvdr.groupId ? getOffsetSize(dvdr.element) : 0))\n .reduce((prev, current) => prev + current, 0);\n\n function overflowMenuSize() {\n return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n }\n\n const availableSize = getOffsetSize(container) - totalDividersWidth - 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 let currentWidth = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += showItem();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n currentWidth -= hideItem();\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 resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n resizeObserver.disconnect();\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 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 delete overflowItems[itemId];\n update();\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"],"names":["groups","groupId","DATA_OVERFLOWING","DATA_OVERFLOW_GROUP","debounce","createPriorityQueue","createOverflowManager","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowDividers","resizeObserver","ResizeObserver","entries","update","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","createGroupManager","groupVisibility","updateGroupVisibility","group","invisibleItemIds","size","visibleItemIds","isGroupVisible","isSingleItemVisible","itemId","has","addItem","Set","add","removeItem","delete","showItem","hideItem","groupManager","invisibleItemQueue","a","b","itemA","itemB","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","visibleItemQueue","getOffsetSize","el","offsetWidth","offsetHeight","computeSizeChange","entry","dividerWidth","id","item","visible","removeAttribute","width","setAttribute","dispatchOverflowUpdate","all","visibleItems","map","invisibleItems","processOverflowItems","totalDividersWidth","Object","values","dvdr","reduce","prev","current","overflowMenuSize","availableSize","visibleTop","peek","invisibleTop","currentWidth","forceUpdate","observe","observedContainer","userOptions","assign","forEach","disconnect","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","remove"],"mappings":"IA0EQA,SAAOC;AA1Ef,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,WAAW;AACjE,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,mBAAmB,QAAuB,kBAAkB;AASrE;;;CAGC,GACD,OAAO,SAASC,wBAAyC;IACvD,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY,KAAK;IACrB,+FAA+F;IAC/F,kDAAkD;IAClD,IAAIC,gBAAgB,IAAI;IACxB,MAAMC,UAAoC;QACxCC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAMC;QAC9BC,kBAAkB,IAAMD;IAC1B;IAEA,MAAME,gBAAmD,CAAC;IAC1D,MAAMC,mBAAyD,CAAC;IAChE,MAAMC,iBAAiB,IAAIC,eAAeC,CAAAA,UAAW;QACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,WAAW;YAC7B;QACF,CAAC;QAEDiB;IACF;IAEA,MAAMC,cAAc,CAACC,gBAAuCC,i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,CAACnE;QACxBU,mBAAmByD,MAAM,CAACnE;QAE1B,IAAI+B,KAAKtE,OAAO,EAAE;YAChBgD,aAAaJ,UAAU,CAAC0B,KAAKD,EAAE,EAAEC,KAAKtE,OAAO;YAC7CsE,KAAKX,OAAO,CAACa,eAAe,CAACtE;QAC/B,CAAC;QAED,OAAOgB,aAAa,CAACqB,OAAO;QAC5BhB;IACF;IAEA,OAAO;QACLkB;QACA2D;QACAN;QACAC;QACAnD;QACArB;QACA8E;QACAG;QACAF;QACAG;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\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 };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowDividers: Record<string, OverflowDividerEntry> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\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 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\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 if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\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 computeSizeChange(entry: OverflowItemEntry) {\n const dividerWidth =\n entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId]\n ? getOffsetSize(overflowDividers[entry.groupId].element)\n : 0;\n\n return getOffsetSize(entry.element) + dividerWidth;\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 return computeSizeChange(item);\n };\n\n const hideItem = () => {\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n const width = computeSizeChange(item);\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 return width;\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 totalDividersWidth = Object.values(overflowDividers)\n .map(dvdr => (dvdr.groupId ? getOffsetSize(dvdr.element) : 0))\n .reduce((prev, current) => prev + current, 0);\n\n function overflowMenuSize() {\n return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n }\n\n const availableSize = getClientSize(container) - totalDividersWidth - 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 let currentSize = visibleItemQueue\n .all()\n .map(id => overflowItems[id].element)\n .map(getOffsetSize)\n .reduce((prev, current) => prev + current, 0);\n\n while (compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0) {\n currentSize -= 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 (currentSize + overflowMenuSize() < 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 currentSize += showItem();\n }\n\n // Remove items until there's no more overflow\n while (currentSize + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible) {\n currentSize -= 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 resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n sizeCache.clear();\n resizeObserver.disconnect();\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 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 return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n addDivider,\n removeDivider,\n };\n}\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_GROUP","debounce","createPriorityQueue","createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowDividers","resizeObserver","ResizeObserver","entries","update","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","createGroupManager","groupVisibility","groups","updateGroupVisibility","groupId","group","invisibleItemIds","size","visibleItemIds","isGroupVisible","isSingleItemVisible","itemId","has","addItem","Set","add","removeItem","delete","showItem","hideItem","groupManager","compareItems","lt","rt","lte","rte","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","a","b","visibleItemQueue","computeSizeChange","entry","dividerWidth","id","item","visible","removeAttribute","width","setAttribute","dispatchOverflowUpdate","all","visibleItems","map","invisibleItems","processOverflowItems","clear","totalDividersWidth","Object","values","dvdr","reduce","prev","current","overflowMenuSize","availableSize","visibleTop","peek","invisibleTop","currentSize","i","forceUpdate","observe","observedContainer","userOptions","assign","forEach","disconnect","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","remove"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,mBAAmB,QAAQ,WAAW;AACjE,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,mBAAmB,QAAuB,kBAAkB;AASrE;;;CAGC,GACD,OAAO,SAASC,wBAAyC;IACvD,gFAAgF;IAChF,2FAA2F;IAC3F,MAAMC,YAAY,IAAIC;IACtB,IAAIC;IACJ,IAAIC;IACJ,g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AgB,CAACgG,QAAQjF,OAAO,CAAC,EAAE;YACzD;QACF,CAAC;QAEDiF,QAAQtD,OAAO,CAACuB,YAAY,CAACpF,qBAAqBmH,QAAQjF,OAAO;QACjEf,gBAAgB,CAACgG,QAAQjF,OAAO,CAAC,GAAGiF;IACtC;IAEA,MAAMC,qBAA4D,IAAM;QACtE7G,eAAeS;IACjB;IAEA,MAAMqG,gBAAkDnF,CAAAA,UAAW;QACjE,IAAI,CAACf,gBAAgB,CAACe,QAAQ,EAAE;YAC9B;QACF,CAAC;QACD,MAAMiF,UAAUhG,gBAAgB,CAACe,QAAQ;QACzC,IAAIiF,QAAQjF,OAAO,EAAE;YACnB,OAAOf,gBAAgB,CAACe,QAAQ;YAChCiF,QAAQtD,OAAO,CAACqB,eAAe,CAAClF;QAClC,CAAC;IACH;IAEA,MAAM8C,aAA4CL,CAAAA,SAAU;QAC1D,IAAI,CAACvB,aAAa,CAACuB,OAAO,EAAE;YAC1B;QACF,CAAC;QAED,MAAMuC,OAAO9D,aAAa,CAACuB,OAAO;QAClCkC,iBAAiB2C,MAAM,CAAC7E;QACxB+B,mBAAmB8C,MAAM,CAAC7E;QAE1B,IAAIuC,KAAK9C,OAAO,EAAE;YAChBgB,aAAaJ,UAAU,CAACkC,KAAKD,EAAE,EAAEC,KAAK9C,OAAO;YAC7C8C,KAAKnB,OAAO,CAACqB,eAAe,CAAClF;QAC/B,CAAC;QAEDI,UAAU2C,MAAM,CAACiC,KAAKnB,OAAO;QAC7B,OAAO3C,aAAa,CAACuB,OAAO;QAC5BlB;IACF;IAEA,OAAO;QACLoB;QACAqE;QACAN;QACAC;QACA7D;QACAvB;QACA0F;QACAG;QACAF;QACAG;IACF;AACF,CAAC"}
@@ -9,8 +9,10 @@ Object.defineProperty(exports, "createOverflowManager", {
9
9
  const _consts = require("./consts");
10
10
  const _debounce = require("./debounce");
11
11
  const _priorityQueue = require("./priorityQueue");
12
- var _groups, _groupId;
13
12
  function createOverflowManager() {
13
+ // calls to `offsetWidth or offsetHeight` can happen multiple times in an update
14
+ // Use a cache to avoid causing too many recalcs and avoid scripting time to meausure sizes
15
+ const sizeCache = new Map();
14
16
  let container;
15
17
  let overflowMenu;
16
18
  // Set as true when resize observer is observing
@@ -61,6 +63,7 @@ function createOverflowManager() {
61
63
  return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;
62
64
  },
63
65
  addItem (itemId, groupId) {
66
+ var _groups, _groupId;
64
67
  var _;
65
68
  (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {
66
69
  visibleItemIds: new Set(),
@@ -87,35 +90,29 @@ function createOverflowManager() {
87
90
  };
88
91
  };
89
92
  const groupManager = createGroupManager();
90
- const invisibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>{
91
- const itemA = overflowItems[a];
92
- const itemB = overflowItems[b];
93
- // Higher priority at the top of the queue
94
- const priority = itemB.priority - itemA.priority;
95
- if (priority !== 0) {
96
- return priority;
93
+ function compareItems(lt, rt) {
94
+ if (!lt || !rt) {
95
+ return 0;
96
+ }
97
+ const lte = overflowItems[lt];
98
+ const rte = overflowItems[rt];
99
+ if (lte.priority !== rte.priority) {
100
+ return lte.priority > rte.priority ? 1 : -1;
97
101
  }
98
102
  const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
99
- // equal priority, use DOM order
100
103
  // eslint-disable-next-line no-bitwise
101
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
102
- });
103
- const visibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>{
104
- const itemA = overflowItems[a];
105
- const itemB = overflowItems[b];
106
- // Lower priority at the top of the queue
107
- const priority = itemA.priority - itemB.priority;
108
- if (priority !== 0) {
109
- return priority;
104
+ return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;
105
+ }
106
+ function getElementAxisSize(horizontal, vertical, el) {
107
+ if (!sizeCache.has(el)) {
108
+ sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);
110
109
  }
111
- const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
112
- // equal priority, use DOM order
113
- // eslint-disable-next-line no-bitwise
114
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
115
- });
116
- const getOffsetSize = (el)=>{
117
- return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
118
- };
110
+ return sizeCache.get(el);
111
+ }
112
+ const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');
113
+ const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');
114
+ const invisibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>-1 * compareItems(a, b));
115
+ const visibleItemQueue = (0, _priorityQueue.createPriorityQueue)(compareItems);
119
116
  function computeSizeChange(entry) {
120
117
  const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;
121
118
  return getOffsetSize(entry.element) + dividerWidth;
@@ -166,22 +163,31 @@ function createOverflowManager() {
166
163
  if (!container) {
167
164
  return false;
168
165
  }
166
+ sizeCache.clear();
169
167
  const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);
170
168
  function overflowMenuSize() {
171
169
  return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;
172
170
  }
173
- const availableSize = getOffsetSize(container) - totalDividersWidth - options.padding;
171
+ const availableSize = getClientSize(container) - totalDividersWidth - options.padding;
174
172
  // Snapshot of the visible/invisible state to compare for updates
175
173
  const visibleTop = visibleItemQueue.peek();
176
174
  const invisibleTop = invisibleItemQueue.peek();
177
- let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
178
- // Add items until available width is filled - can result in overflow
179
- while(currentWidth + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0){
180
- currentWidth += showItem();
175
+ let currentSize = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
176
+ while(compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0){
177
+ currentSize -= hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one
181
178
  }
182
- // Remove items until there's no more overflow
183
- while(currentWidth + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
184
- currentWidth -= hideItem();
179
+ // Run the show/hide step twice - the first step might not be correct if
180
+ // it was triggered by a new item being added - new items are always visible by default.
181
+ for(let i = 0; i < 2; i++){
182
+ // Add items until available width is filled - can result in overflow
183
+ while(currentSize + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0 || invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size
184
+ ){
185
+ currentSize += showItem();
186
+ }
187
+ // Remove items until there's no more overflow
188
+ while(currentSize + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
189
+ currentSize -= hideItem();
190
+ }
185
191
  }
186
192
  // only update when the state of visible/invisible items has changed
187
193
  return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
@@ -202,6 +208,7 @@ function createOverflowManager() {
202
208
  };
203
209
  const disconnect = ()=>{
204
210
  observing = false;
211
+ sizeCache.clear();
205
212
  resizeObserver.disconnect();
206
213
  };
207
214
  const addItem = (item)=>{
@@ -257,6 +264,7 @@ function createOverflowManager() {
257
264
  groupManager.removeItem(item.id, item.groupId);
258
265
  item.element.removeAttribute(_consts.DATA_OVERFLOW_GROUP);
259
266
  }
267
+ sizeCache.delete(item.element);
260
268
  delete overflowItems[itemId];
261
269
  update();
262
270
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["overflowManager.js"],"sourcesContent":["var _groups, _groupId;\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\n/**\n * @internal\n * @returns overflow manager instance\n */ export function createOverflowManager() {\n let container;\n let overflowMenu;\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 = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: ()=>undefined,\n onUpdateOverflow: ()=>undefined\n };\n const overflowItems = {};\n const overflowDividers = {};\n const resizeObserver = new ResizeObserver((entries)=>{\n if (!entries[0] || !container) {\n return;\n }\n update();\n });\n const getNextItem = (queueToDequeue, queueToEnqueue)=>{\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n const createGroupManager = ()=>{\n const groupVisibility = {};\n const groups = {};\n function updateGroupVisibility(groupId) {\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) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: ()=>groupVisibility,\n isSingleItemVisible (itemId, groupId) {\n return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;\n },\n addItem (itemId, groupId) {\n var _;\n (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {\n visibleItemIds: new Set(),\n invisibleItemIds: new Set()\n };\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n }\n };\n };\n const groupManager = createGroupManager();\n const invisibleItemQueue = createPriorityQueue((a, b)=>{\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const visibleItemQueue = createPriorityQueue((a, b)=>{\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const getOffsetSize = (el)=>{\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n function computeSizeChange(entry) {\n const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;\n return getOffsetSize(entry.element) + dividerWidth;\n }\n const showItem = ()=>{\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({\n item,\n visible: true\n });\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n return computeSizeChange(item);\n };\n const hideItem = ()=>{\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n const width = computeSizeChange(item);\n options.onUpdateItemVisibility({\n item,\n visible: false\n });\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.setAttribute(DATA_OVERFLOWING, '');\n }\n groupManager.hideItem(item.id, item.groupId);\n }\n return width;\n };\n const dispatchOverflowUpdate = ()=>{\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);\n options.onUpdateOverflow({\n visibleItems,\n invisibleItems,\n groupVisibility: groupManager.groupVisibility()\n });\n };\n const processOverflowItems = ()=>{\n if (!container) {\n return false;\n }\n const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);\n function overflowMenuSize() {\n return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n }\n const availableSize = getOffsetSize(container) - totalDividersWidth - options.padding;\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);\n // Add items until available width is filled - can result in overflow\n while(currentWidth + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0){\n currentWidth += showItem();\n }\n // Remove items until there's no more overflow\n while(currentWidth + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){\n currentWidth -= hideItem();\n }\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n const forceUpdate = ()=>{\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n const update = debounce(forceUpdate);\n const observe = (observedContainer, userOptions)=>{\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach((item)=>visibleItemQueue.enqueue(item.id));\n container = observedContainer;\n resizeObserver.observe(container);\n };\n const disconnect = ()=>{\n observing = false;\n resizeObserver.disconnect();\n };\n const addItem = (item)=>{\n if (overflowItems[item.id]) {\n return;\n }\n overflowItems[item.id] = item;\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 if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n update();\n };\n const addOverflowMenu = (el)=>{\n overflowMenu = el;\n };\n const addDivider = (divider)=>{\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n const removeOverflowMenu = ()=>{\n overflowMenu = undefined;\n };\n const 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 const removeItem = (itemId)=>{\n if (!overflowItems[itemId]) {\n return;\n }\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n delete overflowItems[itemId];\n update();\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"],"names":["createOverflowManager","_groups","_groupId","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowDividers","resizeObserver","ResizeObserver","entries","update","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","createGroupManager","groupVisibility","groups","updateGroupVisibility","groupId","group","invisibleItemIds","size","visibleItemIds","isGroupVisible","isSingleItemVisible","itemId","has","addItem","_","Set","add","removeItem","delete","showItem","hideItem","groupManager","invisibleItemQueue","createPriorityQueue","a","b","itemA","itemB","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","visibleItemQueue","getOffsetSize","el","offsetWidth","offsetHeight","computeSizeChange","entry","dividerWidth","id","item","visible","_overflowDividers_item_groupId","removeAttribute","DATA_OVERFLOWING","width","setAttribute","dispatchOverflowUpdate","all","visibleItems","map","invisibleItems","processOverflowItems","totalDividersWidth","Object","values","dvdr","reduce","prev","current","overflowMenuSize","availableSize","visibleTop","peek","invisibleTop","currentWidth","forceUpdate","debounce","observe","observedContainer","userOptions","assign","forEach","disconnect","DATA_OVERFLOW_GROUP","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","remove"],"mappings":";;;;+BAOoBA;;aAAAA;;wBANkC;0BAC7B;+BACW;AAHpC,IAAIC,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6E,QAAQhD,OAAO,CAACiB,YAAY,CAAC4B,2BAAmB,EAAEG,QAAQ7E,OAAO;QACjEf,gBAAgB,CAAC4F,QAAQ7E,OAAO,CAAC,GAAG6E;IACxC;IACA,MAAMC,qBAAqB,IAAI;QAC3BzG,eAAeS;IACnB;IACA,MAAMiG,gBAAgB,CAAC/E,UAAU;QAC7B,IAAI,CAACf,gBAAgB,CAACe,QAAQ,EAAE;YAC5B;QACJ,CAAC;QACD,MAAM6E,UAAU5F,gBAAgB,CAACe,QAAQ;QACzC,IAAI6E,QAAQ7E,OAAO,EAAE;YACjB,OAAOf,gBAAgB,CAACe,QAAQ;YAChC6E,QAAQhD,OAAO,CAACc,eAAe,CAAC+B,2BAAmB;QACvD,CAAC;IACL;IACA,MAAM7D,aAAa,CAACN,SAAS;QACzB,IAAI,CAACvB,aAAa,CAACuB,OAAO,EAAE;YACxB;QACJ,CAAC;QACD,MAAMiC,OAAOxD,aAAa,CAACuB,OAAO;QAClCwB,iBAAiBiD,MAAM,CAACzE;QACxBW,mBAAmB8D,MAAM,CAACzE;QAC1B,IAAIiC,KAAKxC,OAAO,EAAE;YACdiB,aAAaJ,UAAU,CAAC2B,KAAKD,EAAE,EAAEC,KAAKxC,OAAO;YAC7CwC,KAAKX,OAAO,CAACc,eAAe,CAAC+B,2BAAmB;QACpD,CAAC;QACD,OAAO1F,aAAa,CAACuB,OAAO;QAC5BlB;IACJ;IACA,OAAO;QACHoB;QACAgE;QACAP;QACAE;QACAvD;QACAxB;QACAsF;QACAG;QACAF;QACAG;IACJ;AACJ"}
1
+ {"version":3,"sources":["overflowManager.js"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\n/**\n * @internal\n * @returns overflow manager instance\n */ export function createOverflowManager() {\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();\n let container;\n let overflowMenu;\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 = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: ()=>undefined,\n onUpdateOverflow: ()=>undefined\n };\n const overflowItems = {};\n const overflowDividers = {};\n const resizeObserver = new ResizeObserver((entries)=>{\n if (!entries[0] || !container) {\n return;\n }\n update();\n });\n const getNextItem = (queueToDequeue, queueToEnqueue)=>{\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n const createGroupManager = ()=>{\n const groupVisibility = {};\n const groups = {};\n function updateGroupVisibility(groupId) {\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) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: ()=>groupVisibility,\n isSingleItemVisible (itemId, groupId) {\n return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;\n },\n addItem (itemId, groupId) {\n var _groups, _groupId;\n var _;\n (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {\n visibleItemIds: new Set(),\n invisibleItemIds: new Set()\n };\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n }\n };\n };\n const groupManager = createGroupManager();\n function compareItems(lt, rt) {\n if (!lt || !rt) {\n return 0;\n }\n const lte = overflowItems[lt];\n const rte = overflowItems[rt];\n if (lte.priority !== rte.priority) {\n return lte.priority > rte.priority ? 1 : -1;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n // eslint-disable-next-line no-bitwise\n return lte.element.compareDocumentPosition(rte.element) & positionStatusBit ? 1 : -1;\n }\n function getElementAxisSize(horizontal, vertical, el) {\n if (!sizeCache.has(el)) {\n sizeCache.set(el, options.overflowAxis === 'horizontal' ? el[horizontal] : el[vertical]);\n }\n return sizeCache.get(el);\n }\n const getOffsetSize = getElementAxisSize.bind(null, 'offsetWidth', 'offsetHeight');\n const getClientSize = getElementAxisSize.bind(null, 'clientWidth', 'clientHeight');\n const invisibleItemQueue = createPriorityQueue((a, b)=>-1 * compareItems(a, b));\n const visibleItemQueue = createPriorityQueue(compareItems);\n function computeSizeChange(entry) {\n const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;\n return getOffsetSize(entry.element) + dividerWidth;\n }\n const showItem = ()=>{\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({\n item,\n visible: true\n });\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n return computeSizeChange(item);\n };\n const hideItem = ()=>{\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n const width = computeSizeChange(item);\n options.onUpdateItemVisibility({\n item,\n visible: false\n });\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.setAttribute(DATA_OVERFLOWING, '');\n }\n groupManager.hideItem(item.id, item.groupId);\n }\n return width;\n };\n const dispatchOverflowUpdate = ()=>{\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);\n options.onUpdateOverflow({\n visibleItems,\n invisibleItems,\n groupVisibility: groupManager.groupVisibility()\n });\n };\n const processOverflowItems = ()=>{\n if (!container) {\n return false;\n }\n sizeCache.clear();\n const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);\n function overflowMenuSize() {\n return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;\n }\n const availableSize = getClientSize(container) - totalDividersWidth - options.padding;\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n let currentSize = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);\n while(compareItems(invisibleItemQueue.peek(), visibleItemQueue.peek()) > 0){\n currentSize -= hideItem(); // hide elements whose priority become smaller than the highest priority of the hidden one\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(currentSize + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0 || invisibleItemQueue.size() === 1 // attempt to show the last invisible item hoping it's size does not exceed overflow menu size\n ){\n currentSize += showItem();\n }\n // Remove items until there's no more overflow\n while(currentSize + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){\n currentSize -= hideItem();\n }\n }\n // only update when the state of visible/invisible items has changed\n return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;\n };\n const forceUpdate = ()=>{\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n const update = debounce(forceUpdate);\n const observe = (observedContainer, userOptions)=>{\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach((item)=>visibleItemQueue.enqueue(item.id));\n container = observedContainer;\n resizeObserver.observe(container);\n };\n const disconnect = ()=>{\n observing = false;\n sizeCache.clear();\n resizeObserver.disconnect();\n };\n const addItem = (item)=>{\n if (overflowItems[item.id]) {\n return;\n }\n overflowItems[item.id] = item;\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 if (item.groupId) {\n groupManager.addItem(item.id, item.groupId);\n item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);\n }\n update();\n };\n const addOverflowMenu = (el)=>{\n overflowMenu = el;\n };\n const addDivider = (divider)=>{\n if (!divider.groupId || overflowDividers[divider.groupId]) {\n return;\n }\n divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);\n overflowDividers[divider.groupId] = divider;\n };\n const removeOverflowMenu = ()=>{\n overflowMenu = undefined;\n };\n const 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 const removeItem = (itemId)=>{\n if (!overflowItems[itemId]) {\n return;\n }\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n if (item.groupId) {\n groupManager.removeItem(item.id, item.groupId);\n item.element.removeAttribute(DATA_OVERFLOW_GROUP);\n }\n sizeCache.delete(item.element);\n delete overflowItems[itemId];\n update();\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"],"names":["createOverflowManager","sizeCache","Map","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowDividers","resizeObserver","ResizeObserver","entries","update","getNextItem","queueToDequeue","queueToEnqueue","nextItem","dequeue","enqueue","createGroupManager","groupVisibility","groups","updateGroupVisibility","groupId","group","invisibleItemIds","size","visibleItemIds","isGroupVisible","isSingleItemVisible","itemId","has","addItem","_groups","_groupId","_","Set","add","removeItem","delete","showItem","hideItem","groupManager","compareItems","lt","rt","lte","rte","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","getElementAxisSize","horizontal","vertical","el","set","get","getOffsetSize","bind","getClientSize","invisibleItemQueue","createPriorityQueue","a","b","visibleItemQueue","computeSizeChange","entry","dividerWidth","id","item","visible","_overflowDividers_item_groupId","removeAttribute","DATA_OVERFLOWING","width","setAttribute","dispatchOverflowUpdate","all","visibleItems","map","invisibleItems","processOverflowItems","clear","totalDividersWidth","Object","values","dvdr","reduce","prev","current","overflowMenuSize","availableSize","visibleTop","peek","invisibleTop","currentSize","i","forceUpdate","debounce","observe","observedContainer","userOptions","assign","forEach","disconnect","DATA_OVERFLOW_GROUP","addOverflowMenu","addDivider","divider","removeOverflowMenu","removeDivider","remove"],"mappings":";;;;+BAMoBA;;aAAAA;;wBANkC;0BAC7B;+BACW;AAIzB,SAASA,wBA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A,OAAO;QACHoB;QACA4E;QACAP;QACAE;QACAjE;QACA1B;QACAkG;QACAG;QACAF;QACAG;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/priority-overflow",
3
- "version": "9.1.1",
3
+ "version": "9.1.3",
4
4
  "description": "Vanilla JS utilities to implement overflow menus",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -13,7 +13,7 @@
13
13
  "license": "MIT",
14
14
  "scripts": {
15
15
  "build": "just-scripts build",
16
- "bundle-size": "bundle-size measure",
16
+ "bundle-size": "monosize measure",
17
17
  "clean": "just-scripts clean",
18
18
  "code-style": "just-scripts code-style",
19
19
  "just": "just-scripts",