@fluentui/priority-overflow 9.0.2 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,217 +1,267 @@
1
+ var _groups, _groupId;
2
+ import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';
1
3
  import { debounce } from './debounce';
2
4
  import { createPriorityQueue } from './priorityQueue';
3
5
  /**
4
6
  * @internal
5
7
  * @returns overflow manager instance
6
- */
7
- export function createOverflowManager() {
8
- let container;
9
- let overflowMenu;
10
- // Set as true when resize observer is observing
11
- let observing = false;
12
- // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change
13
- let forceDispatch = false;
14
- const options = {
15
- padding: 10,
16
- overflowAxis: 'horizontal',
17
- overflowDirection: 'end',
18
- minimumVisible: 0,
19
- onUpdateItemVisibility: () => undefined,
20
- onUpdateOverflow: () => undefined
21
- };
22
- const overflowItems = {};
23
- const overflowGroups = {};
24
- const resizeObserver = new ResizeObserver(entries => {
25
- if (!entries[0] || !container) {
26
- return;
27
- }
28
- update();
29
- });
30
- const invisibleItemQueue = createPriorityQueue((a, b) => {
31
- const itemA = overflowItems[a];
32
- const itemB = overflowItems[b];
33
- // Higher priority at the top of the queue
34
- const priority = itemB.priority - itemA.priority;
35
- if (priority !== 0) {
36
- return priority;
37
- }
38
- const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
39
- // equal priority, use DOM order
40
- // eslint-disable-next-line no-bitwise
41
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
42
- });
43
- const visibleItemQueue = createPriorityQueue((a, b) => {
44
- const itemA = overflowItems[a];
45
- const itemB = overflowItems[b];
46
- // Lower priority at the top of the queue
47
- const priority = itemA.priority - itemB.priority;
48
- if (priority !== 0) {
49
- return priority;
50
- }
51
- const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
52
- // equal priority, use DOM order
53
- // eslint-disable-next-line no-bitwise
54
- return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
55
- });
56
- const getOffsetSize = el => {
57
- return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
58
- };
59
- const makeItemVisible = () => {
60
- const nextVisible = invisibleItemQueue.dequeue();
61
- visibleItemQueue.enqueue(nextVisible);
62
- const item = overflowItems[nextVisible];
63
- options.onUpdateItemVisibility({
64
- item,
65
- visible: true
66
- });
67
- if (item.groupId) {
68
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
69
- overflowGroups[item.groupId].visibleItemIds.add(item.id);
70
- }
71
- return getOffsetSize(item.element);
72
- };
73
- const makeItemInvisible = () => {
74
- const nextInvisible = visibleItemQueue.dequeue();
75
- invisibleItemQueue.enqueue(nextInvisible);
76
- const item = overflowItems[nextInvisible];
77
- const width = getOffsetSize(item.element);
78
- options.onUpdateItemVisibility({
79
- item,
80
- visible: false
8
+ */ export function createOverflowManager() {
9
+ let container;
10
+ let overflowMenu;
11
+ // Set as true when resize observer is observing
12
+ let observing = false;
13
+ // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change
14
+ // Initially true to force dispatch on first mount
15
+ let forceDispatch = true;
16
+ const options = {
17
+ padding: 10,
18
+ overflowAxis: 'horizontal',
19
+ overflowDirection: 'end',
20
+ minimumVisible: 0,
21
+ onUpdateItemVisibility: ()=>undefined,
22
+ onUpdateOverflow: ()=>undefined
23
+ };
24
+ const overflowItems = {};
25
+ const overflowDividers = {};
26
+ const resizeObserver = new ResizeObserver((entries)=>{
27
+ if (!entries[0] || !container) {
28
+ return;
29
+ }
30
+ update();
81
31
  });
82
- if (item.groupId) {
83
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
84
- overflowGroups[item.groupId].invisibleItemIds.add(item.id);
85
- }
86
- return width;
87
- };
88
- const dispatchOverflowUpdate = () => {
89
- const visibleItemIds = visibleItemQueue.all();
90
- const invisibleItemIds = invisibleItemQueue.all();
91
- const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);
92
- const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);
93
- const groupVisibility = {};
94
- Object.entries(overflowGroups).forEach(([groupId, groupState]) => {
95
- if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
96
- groupVisibility[groupId] = 'overflow';
97
- } else if (groupState.visibleItemIds.size === 0) {
98
- groupVisibility[groupId] = 'hidden';
99
- } else {
100
- groupVisibility[groupId] = 'visible';
101
- }
32
+ const getNextItem = (queueToDequeue, queueToEnqueue)=>{
33
+ const nextItem = queueToDequeue.dequeue();
34
+ queueToEnqueue.enqueue(nextItem);
35
+ return overflowItems[nextItem];
36
+ };
37
+ const createGroupManager = ()=>{
38
+ const groupVisibility = {};
39
+ const groups = {};
40
+ function updateGroupVisibility(groupId) {
41
+ const group = groups[groupId];
42
+ if (group.invisibleItemIds.size && group.visibleItemIds.size) {
43
+ groupVisibility[groupId] = 'overflow';
44
+ } else if (group.visibleItemIds.size === 0) {
45
+ groupVisibility[groupId] = 'hidden';
46
+ } else {
47
+ groupVisibility[groupId] = 'visible';
48
+ }
49
+ }
50
+ function isGroupVisible(groupId) {
51
+ return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';
52
+ }
53
+ return {
54
+ groupVisibility: ()=>groupVisibility,
55
+ isSingleItemVisible (itemId, groupId) {
56
+ return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;
57
+ },
58
+ addItem (itemId, groupId) {
59
+ var _;
60
+ (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {
61
+ visibleItemIds: new Set(),
62
+ invisibleItemIds: new Set()
63
+ };
64
+ groups[groupId].visibleItemIds.add(itemId);
65
+ updateGroupVisibility(groupId);
66
+ },
67
+ removeItem (itemId, groupId) {
68
+ groups[groupId].invisibleItemIds.delete(itemId);
69
+ groups[groupId].visibleItemIds.delete(itemId);
70
+ updateGroupVisibility(groupId);
71
+ },
72
+ showItem (itemId, groupId) {
73
+ groups[groupId].invisibleItemIds.delete(itemId);
74
+ groups[groupId].visibleItemIds.add(itemId);
75
+ updateGroupVisibility(groupId);
76
+ },
77
+ hideItem (itemId, groupId) {
78
+ groups[groupId].invisibleItemIds.add(itemId);
79
+ groups[groupId].visibleItemIds.delete(itemId);
80
+ updateGroupVisibility(groupId);
81
+ }
82
+ };
83
+ };
84
+ 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;
92
+ }
93
+ const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
94
+ // equal priority, use DOM order
95
+ // eslint-disable-next-line no-bitwise
96
+ return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
102
97
  });
103
- options.onUpdateOverflow({
104
- visibleItems,
105
- invisibleItems,
106
- groupVisibility
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;
105
+ }
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;
107
110
  });
108
- };
109
- const processOverflowItems = () => {
110
- if (!container) {
111
- return false;
112
- }
113
- const availableSize = getOffsetSize(container) - options.padding;
114
- const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
115
- // Snapshot of the visible/invisible state to compare for updates
116
- const visibleTop = visibleItemQueue.peek();
117
- const invisibleTop = invisibleItemQueue.peek();
118
- const visibleItemIds = visibleItemQueue.all();
119
- let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {
120
- const child = overflowItems[visibleItemId].element;
121
- return sum + getOffsetSize(child);
122
- }, 0);
123
- // Add items until available width is filled - can result in overflow
124
- while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {
125
- currentWidth += makeItemVisible();
126
- }
127
- // Remove items until there's no more overflow
128
- while (currentWidth > availableSize && visibleItemQueue.size() > 0) {
129
- if (visibleItemQueue.size() <= options.minimumVisible) {
130
- break;
131
- }
132
- currentWidth -= makeItemInvisible();
133
- }
134
- // make sure the overflow menu can fit
135
- if (visibleItemQueue.size() > options.minimumVisible && invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) {
136
- makeItemInvisible();
137
- }
138
- // only update when the state of visible/invisible items has changed
139
- if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {
140
- return true;
141
- }
142
- return false;
143
- };
144
- const forceUpdate = () => {
145
- if (processOverflowItems() || forceDispatch) {
146
- forceDispatch = false;
147
- dispatchOverflowUpdate();
148
- }
149
- };
150
- const update = debounce(forceUpdate);
151
- const observe = (observedContainer, userOptions) => {
152
- Object.assign(options, userOptions);
153
- observing = true;
154
- Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));
155
- container = observedContainer;
156
- resizeObserver.observe(container);
157
- };
158
- const disconnect = () => {
159
- observing = false;
160
- resizeObserver.disconnect();
161
- };
162
- const addItem = item => {
163
- if (overflowItems[item.id]) {
164
- return;
165
- }
166
- overflowItems[item.id] = item;
167
- // some options can affect priority which are only set on `observe`
168
- if (observing) {
169
- // Updates to elements might not change the queue tops
170
- // i.e. new element is enqueued but the top of the queue stays the same
171
- // force a dispatch on the next batched update
172
- forceDispatch = true;
173
- visibleItemQueue.enqueue(item.id);
174
- }
175
- if (item.groupId) {
176
- if (!overflowGroups[item.groupId]) {
177
- overflowGroups[item.groupId] = {
178
- visibleItemIds: new Set(),
179
- invisibleItemIds: new Set()
180
- };
181
- }
182
- overflowGroups[item.groupId].visibleItemIds.add(item.id);
183
- }
184
- update();
185
- };
186
- const addOverflowMenu = el => {
187
- overflowMenu = el;
188
- };
189
- const removeOverflowMenu = () => {
190
- overflowMenu = undefined;
191
- };
192
- const removeItem = itemId => {
193
- if (!overflowItems[itemId]) {
194
- return;
195
- }
196
- const item = overflowItems[itemId];
197
- visibleItemQueue.remove(itemId);
198
- invisibleItemQueue.remove(itemId);
199
- if (item.groupId) {
200
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
201
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
111
+ const getOffsetSize = (el)=>{
112
+ return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
113
+ };
114
+ function computeSizeChange(entry) {
115
+ const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;
116
+ return getOffsetSize(entry.element) + dividerWidth;
202
117
  }
203
- delete overflowItems[itemId];
204
- update();
205
- };
206
- return {
207
- addItem,
208
- disconnect,
209
- forceUpdate,
210
- observe,
211
- removeItem,
212
- update,
213
- addOverflowMenu,
214
- removeOverflowMenu
215
- };
118
+ const showItem = ()=>{
119
+ const item = getNextItem(invisibleItemQueue, visibleItemQueue);
120
+ options.onUpdateItemVisibility({
121
+ item,
122
+ visible: true
123
+ });
124
+ if (item.groupId) {
125
+ groupManager.showItem(item.id, item.groupId);
126
+ if (groupManager.isSingleItemVisible(item.id, item.groupId)) {
127
+ var _overflowDividers_item_groupId;
128
+ (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.removeAttribute(DATA_OVERFLOWING);
129
+ }
130
+ }
131
+ return computeSizeChange(item);
132
+ };
133
+ const hideItem = ()=>{
134
+ const item = getNextItem(visibleItemQueue, invisibleItemQueue);
135
+ const width = computeSizeChange(item);
136
+ options.onUpdateItemVisibility({
137
+ item,
138
+ visible: false
139
+ });
140
+ if (item.groupId) {
141
+ if (groupManager.isSingleItemVisible(item.id, item.groupId)) {
142
+ var _overflowDividers_item_groupId;
143
+ (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.setAttribute(DATA_OVERFLOWING, '');
144
+ }
145
+ groupManager.hideItem(item.id, item.groupId);
146
+ }
147
+ return width;
148
+ };
149
+ const dispatchOverflowUpdate = ()=>{
150
+ const visibleItemIds = visibleItemQueue.all();
151
+ const invisibleItemIds = invisibleItemQueue.all();
152
+ const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);
153
+ const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);
154
+ options.onUpdateOverflow({
155
+ visibleItems,
156
+ invisibleItems,
157
+ groupVisibility: groupManager.groupVisibility()
158
+ });
159
+ };
160
+ const processOverflowItems = ()=>{
161
+ if (!container) {
162
+ return false;
163
+ }
164
+ const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);
165
+ const availableSize = getOffsetSize(container) - options.padding - totalDividersWidth - (overflowMenu ? getOffsetSize(overflowMenu) : 0);
166
+ // Snapshot of the visible/invisible state to compare for updates
167
+ const visibleTop = visibleItemQueue.peek();
168
+ const invisibleTop = invisibleItemQueue.peek();
169
+ let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
170
+ // Add items until available width is filled - can result in overflow
171
+ while(currentWidth < availableSize && invisibleItemQueue.size() > 0){
172
+ currentWidth += showItem();
173
+ }
174
+ // Remove items until there's no more overflow
175
+ while(currentWidth > availableSize && visibleItemQueue.size() > options.minimumVisible){
176
+ currentWidth -= hideItem();
177
+ }
178
+ // only update when the state of visible/invisible items has changed
179
+ return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
180
+ };
181
+ const forceUpdate = ()=>{
182
+ if (processOverflowItems() || forceDispatch) {
183
+ forceDispatch = false;
184
+ dispatchOverflowUpdate();
185
+ }
186
+ };
187
+ const update = debounce(forceUpdate);
188
+ const observe = (observedContainer, userOptions)=>{
189
+ Object.assign(options, userOptions);
190
+ observing = true;
191
+ Object.values(overflowItems).forEach((item)=>visibleItemQueue.enqueue(item.id));
192
+ container = observedContainer;
193
+ resizeObserver.observe(container);
194
+ };
195
+ const disconnect = ()=>{
196
+ observing = false;
197
+ resizeObserver.disconnect();
198
+ };
199
+ const addItem = (item)=>{
200
+ if (overflowItems[item.id]) {
201
+ return;
202
+ }
203
+ overflowItems[item.id] = item;
204
+ // some options can affect priority which are only set on `observe`
205
+ if (observing) {
206
+ // Updates to elements might not change the queue tops
207
+ // i.e. new element is enqueued but the top of the queue stays the same
208
+ // force a dispatch on the next batched update
209
+ forceDispatch = true;
210
+ visibleItemQueue.enqueue(item.id);
211
+ }
212
+ if (item.groupId) {
213
+ groupManager.addItem(item.id, item.groupId);
214
+ item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);
215
+ }
216
+ update();
217
+ };
218
+ const addOverflowMenu = (el)=>{
219
+ overflowMenu = el;
220
+ };
221
+ const addDivider = (divider)=>{
222
+ if (!divider.groupId || overflowDividers[divider.groupId]) {
223
+ return;
224
+ }
225
+ divider.element.setAttribute(DATA_OVERFLOW_GROUP, divider.groupId);
226
+ overflowDividers[divider.groupId] = divider;
227
+ };
228
+ const removeOverflowMenu = ()=>{
229
+ overflowMenu = undefined;
230
+ };
231
+ const removeDivider = (groupId)=>{
232
+ if (!overflowDividers[groupId]) {
233
+ return;
234
+ }
235
+ const divider = overflowDividers[groupId];
236
+ if (divider.groupId) {
237
+ delete overflowDividers[groupId];
238
+ divider.element.removeAttribute(DATA_OVERFLOW_GROUP);
239
+ }
240
+ };
241
+ const removeItem = (itemId)=>{
242
+ if (!overflowItems[itemId]) {
243
+ return;
244
+ }
245
+ const item = overflowItems[itemId];
246
+ visibleItemQueue.remove(itemId);
247
+ invisibleItemQueue.remove(itemId);
248
+ if (item.groupId) {
249
+ groupManager.removeItem(item.id, item.groupId);
250
+ item.element.removeAttribute(DATA_OVERFLOW_GROUP);
251
+ }
252
+ delete overflowItems[itemId];
253
+ update();
254
+ };
255
+ return {
256
+ addItem,
257
+ disconnect,
258
+ forceUpdate,
259
+ observe,
260
+ removeItem,
261
+ update,
262
+ addOverflowMenu,
263
+ removeOverflowMenu,
264
+ addDivider,
265
+ removeDivider
266
+ };
216
267
  }
217
- //# sourceMappingURL=overflowManager.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["debounce","createPriorityQueue","createOverflowManager","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowGroups","resizeObserver","ResizeObserver","entries","update","invisibleItemQueue","a","b","itemA","itemB","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","visibleItemQueue","getOffsetSize","el","offsetWidth","offsetHeight","makeItemVisible","nextVisible","dequeue","enqueue","item","visible","groupId","invisibleItemIds","delete","id","visibleItemIds","add","makeItemInvisible","nextInvisible","width","dispatchOverflowUpdate","all","visibleItems","map","itemId","invisibleItems","groupVisibility","Object","forEach","groupState","size","processOverflowItems","availableSize","overflowMenuOffset","visibleTop","peek","invisibleTop","currentWidth","reduce","sum","visibleItemId","child","forceUpdate","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove"],"sources":["../src/overflowManager.ts"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\nimport type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } 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 let forceDispatch = false;\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 overflowGroups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\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 const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({ item, visible: true });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n return getOffsetSize(item.element);\n };\n\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({ item, visible: false });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\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 const groupVisibility: Record<string, OverflowGroupState> = {};\n Object.entries(overflowGroups).forEach(([groupId, groupState]) => {\n if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (groupState.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n });\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n const visibleItemIds = visibleItemQueue.all();\n let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {\n const child = overflowItems[visibleItemId].element;\n return sum + getOffsetSize(child);\n }, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > availableSize && visibleItemQueue.size() > 0) {\n if (visibleItemQueue.size() <= options.minimumVisible) {\n break;\n }\n currentWidth -= makeItemInvisible();\n }\n\n // make sure the overflow menu can fit\n if (\n visibleItemQueue.size() > options.minimumVisible &&\n invisibleItemQueue.size() > 0 &&\n currentWidth + overflowMenuOffset > availableSize\n ) {\n makeItemInvisible();\n }\n\n // only update when the state of visible/invisible items has changed\n if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {\n return true;\n }\n\n return false;\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 if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n }\n\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\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 overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\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 };\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AAGpC;;;;AAIA,OAAO,SAASC,sBAAA,EAAyC;EACvD,IAAIC,SAAA;EACJ,IAAIC,YAAA;EACJ;EACA,IAAIC,SAAA,GAAY,KAAK;EACrB;EACA,IAAIC,aAAA,GAAgB,KAAK;EACzB,MAAMC,OAAA,GAAoC;IACxCC,OAAA,EAAS;IACTC,YAAA,EAAc;IACdC,iBAAA,EAAmB;IACnBC,cAAA,EAAgB;IAChBC,sBAAA,EAAwBA,CAAA,KAAMC,SAAA;IAC9BC,gBAAA,EAAkBA,CAAA,KAAMD;EAC1B;EAEA,MAAME,aAAA,GAAmD,CAAC;EAC1D,MAAMC,cAAA,GAAiG,CAAC;EACxG,MAAMC,cAAA,GAAiB,IAAIC,cAAA,CAAeC,OAAA,IAAW;IACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,SAAA,EAAW;MAC7B;IACF;IAEAiB,MAAA;EACF;EAEA,MAAMC,kBAAA,GAAqBpB,mBAAA,CAA4B,CAACqB,CAAA,EAAGC,CAAA,KAAM;IAC/D,MAAMC,KAAA,GAAQT,aAAa,CAACO,CAAA,CAAE;IAC9B,MAAMG,KAAA,GAAQV,aAAa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B5B,cAAc,CAAC0B,IAAA,CAAKE,OAAO,CAAC,CAACI,cAAc,CAACF,MAAM,CAACJ,IAAA,CAAKK,EAAE;MAC1D/B,cAAc,CAAC0B,IAAA,CAAKE,OAAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,IAAA,CAAKK,EAAE;IAC9D;IAEA,OAAOhC,aAAa,CAAC0C,MAAA,CAAO;IAC5BrC,MAAA;EACF;EAEA,OAAO;IACL8D,OAAA;IACAD,UAAA;IACAN,WAAA;IACAC,OAAA;IACAU,UAAA;IACAlE,MAAA;IACAgE,eAAA;IACAC;EACF;AACF"}
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 const availableSize =\n getOffsetSize(container) -\n options.padding -\n totalDividersWidth -\n (overflowMenu ? getOffsetSize(overflowMenu) : 0);\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 < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += showItem();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > 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","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,iBAA0C;QACpG,MAAMC,WAAWF,e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