@fluentui/priority-overflow 9.0.0 → 9.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +37 -1
- package/CHANGELOG.md +21 -2
- package/lib/debounce.js +1 -2
- package/lib/debounce.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/overflowManager.js +15 -7
- package/lib/overflowManager.js.map +1 -1
- package/lib/priorityQueue.js +1 -2
- package/lib/priorityQueue.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib-commonjs/debounce.js +22 -21
- package/lib-commonjs/debounce.js.map +1 -1
- package/lib-commonjs/index.js +6 -8
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowManager.js +214 -208
- package/lib-commonjs/overflowManager.js.map +1 -1
- package/lib-commonjs/priorityQueue.js +94 -93
- package/lib-commonjs/priorityQueue.js.map +1 -1
- package/lib-commonjs/types.js +3 -2
- package/lib-commonjs/types.js.map +1 -1
- package/package.json +4 -3
- package/lib-amd/debounce.js +0 -27
- package/lib-amd/debounce.js.map +0 -1
- package/lib-amd/index.js +0 -7
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/overflowManager.js +0 -208
- package/lib-amd/overflowManager.js.map +0 -1
- package/lib-amd/priorityQueue.js +0 -97
- package/lib-amd/priorityQueue.js.map +0 -1
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
@@ -1,216 +1,222 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "createOverflowManager", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>createOverflowManager
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const priorityQueue_1 = /*#__PURE__*/require("./priorityQueue");
|
9
|
-
/**
|
10
|
-
* @internal
|
11
|
-
* @returns overflow manager instance
|
12
|
-
*/
|
9
|
+
const _debounce = require("./debounce");
|
10
|
+
const _priorityQueue = require("./priorityQueue");
|
13
11
|
function createOverflowManager() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
const itemB = overflowItems[b];
|
36
|
-
// Higher priority at the top of the queue
|
37
|
-
const priority = itemB.priority - itemA.priority;
|
38
|
-
if (priority !== 0) {
|
39
|
-
return priority;
|
40
|
-
}
|
41
|
-
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
42
|
-
// equal priority, use DOM order
|
43
|
-
// eslint-disable-next-line no-bitwise
|
44
|
-
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
45
|
-
});
|
46
|
-
const visibleItemQueue = priorityQueue_1.createPriorityQueue((a, b) => {
|
47
|
-
const itemA = overflowItems[a];
|
48
|
-
const itemB = overflowItems[b];
|
49
|
-
// Lower priority at the top of the queue
|
50
|
-
const priority = itemA.priority - itemB.priority;
|
51
|
-
if (priority !== 0) {
|
52
|
-
return priority;
|
53
|
-
}
|
54
|
-
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
|
55
|
-
// equal priority, use DOM order
|
56
|
-
// eslint-disable-next-line no-bitwise
|
57
|
-
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
58
|
-
});
|
59
|
-
const getOffsetSize = el => {
|
60
|
-
return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
|
61
|
-
};
|
62
|
-
const makeItemVisible = () => {
|
63
|
-
const nextVisible = invisibleItemQueue.dequeue();
|
64
|
-
visibleItemQueue.enqueue(nextVisible);
|
65
|
-
const item = overflowItems[nextVisible];
|
66
|
-
options.onUpdateItemVisibility({
|
67
|
-
item,
|
68
|
-
visible: true
|
12
|
+
let container;
|
13
|
+
let overflowMenu;
|
14
|
+
// Set as true when resize observer is observing
|
15
|
+
let observing = false;
|
16
|
+
// If true, next update will dispatch to onUpdateOverflow even if queue top states don't change
|
17
|
+
let forceDispatch = false;
|
18
|
+
const options = {
|
19
|
+
padding: 10,
|
20
|
+
overflowAxis: 'horizontal',
|
21
|
+
overflowDirection: 'end',
|
22
|
+
minimumVisible: 0,
|
23
|
+
onUpdateItemVisibility: ()=>undefined,
|
24
|
+
onUpdateOverflow: ()=>undefined
|
25
|
+
};
|
26
|
+
const overflowItems = {};
|
27
|
+
const overflowGroups = {};
|
28
|
+
const resizeObserver = new ResizeObserver((entries)=>{
|
29
|
+
if (!entries[0] || !container) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
update();
|
69
33
|
});
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
item,
|
83
|
-
visible: false
|
34
|
+
const invisibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>{
|
35
|
+
const itemA = overflowItems[a];
|
36
|
+
const itemB = overflowItems[b];
|
37
|
+
// Higher priority at the top of the queue
|
38
|
+
const priority = itemB.priority - itemA.priority;
|
39
|
+
if (priority !== 0) {
|
40
|
+
return priority;
|
41
|
+
}
|
42
|
+
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
43
|
+
// equal priority, use DOM order
|
44
|
+
// eslint-disable-next-line no-bitwise
|
45
|
+
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
84
46
|
});
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
Object.entries(overflowGroups).forEach(([groupId, groupState]) => {
|
98
|
-
if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
|
99
|
-
groupVisibility[groupId] = 'overflow';
|
100
|
-
} else if (groupState.visibleItemIds.size === 0) {
|
101
|
-
groupVisibility[groupId] = 'hidden';
|
102
|
-
} else {
|
103
|
-
groupVisibility[groupId] = 'visible';
|
104
|
-
}
|
47
|
+
const visibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>{
|
48
|
+
const itemA = overflowItems[a];
|
49
|
+
const itemB = overflowItems[b];
|
50
|
+
// Lower priority at the top of the queue
|
51
|
+
const priority = itemA.priority - itemB.priority;
|
52
|
+
if (priority !== 0) {
|
53
|
+
return priority;
|
54
|
+
}
|
55
|
+
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
|
56
|
+
// equal priority, use DOM order
|
57
|
+
// eslint-disable-next-line no-bitwise
|
58
|
+
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
105
59
|
});
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
}
|
194
|
-
const
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
60
|
+
const getOffsetSize = (el)=>{
|
61
|
+
return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
|
62
|
+
};
|
63
|
+
const makeItemVisible = ()=>{
|
64
|
+
const nextVisible = invisibleItemQueue.dequeue();
|
65
|
+
visibleItemQueue.enqueue(nextVisible);
|
66
|
+
const item = overflowItems[nextVisible];
|
67
|
+
options.onUpdateItemVisibility({
|
68
|
+
item,
|
69
|
+
visible: true
|
70
|
+
});
|
71
|
+
if (item.groupId) {
|
72
|
+
overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
|
73
|
+
overflowGroups[item.groupId].visibleItemIds.add(item.id);
|
74
|
+
}
|
75
|
+
return getOffsetSize(item.element);
|
76
|
+
};
|
77
|
+
const makeItemInvisible = ()=>{
|
78
|
+
const nextInvisible = visibleItemQueue.dequeue();
|
79
|
+
invisibleItemQueue.enqueue(nextInvisible);
|
80
|
+
const item = overflowItems[nextInvisible];
|
81
|
+
const width = getOffsetSize(item.element);
|
82
|
+
options.onUpdateItemVisibility({
|
83
|
+
item,
|
84
|
+
visible: false
|
85
|
+
});
|
86
|
+
if (item.groupId) {
|
87
|
+
overflowGroups[item.groupId].visibleItemIds.delete(item.id);
|
88
|
+
overflowGroups[item.groupId].invisibleItemIds.add(item.id);
|
89
|
+
}
|
90
|
+
return width;
|
91
|
+
};
|
92
|
+
const dispatchOverflowUpdate = ()=>{
|
93
|
+
const visibleItemIds = visibleItemQueue.all();
|
94
|
+
const invisibleItemIds = invisibleItemQueue.all();
|
95
|
+
const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);
|
96
|
+
const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);
|
97
|
+
const groupVisibility = {};
|
98
|
+
Object.entries(overflowGroups).forEach(([groupId, groupState])=>{
|
99
|
+
if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
|
100
|
+
groupVisibility[groupId] = 'overflow';
|
101
|
+
} else if (groupState.visibleItemIds.size === 0) {
|
102
|
+
groupVisibility[groupId] = 'hidden';
|
103
|
+
} else {
|
104
|
+
groupVisibility[groupId] = 'visible';
|
105
|
+
}
|
106
|
+
});
|
107
|
+
options.onUpdateOverflow({
|
108
|
+
visibleItems,
|
109
|
+
invisibleItems,
|
110
|
+
groupVisibility
|
111
|
+
});
|
112
|
+
};
|
113
|
+
const processOverflowItems = ()=>{
|
114
|
+
if (!container) {
|
115
|
+
return false;
|
116
|
+
}
|
117
|
+
const availableSize = getOffsetSize(container) - options.padding;
|
118
|
+
const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
|
119
|
+
// Snapshot of the visible/invisible state to compare for updates
|
120
|
+
const visibleTop = visibleItemQueue.peek();
|
121
|
+
const invisibleTop = invisibleItemQueue.peek();
|
122
|
+
const visibleItemIds = visibleItemQueue.all();
|
123
|
+
let currentWidth = visibleItemIds.reduce((sum, visibleItemId)=>{
|
124
|
+
const child = overflowItems[visibleItemId].element;
|
125
|
+
return sum + getOffsetSize(child);
|
126
|
+
}, 0);
|
127
|
+
// Add items until available width is filled - can result in overflow
|
128
|
+
while(currentWidth < availableSize && invisibleItemQueue.size() > 0){
|
129
|
+
currentWidth += makeItemVisible();
|
130
|
+
}
|
131
|
+
// Remove items until there's no more overflow
|
132
|
+
while(currentWidth > availableSize && visibleItemQueue.size() > 0){
|
133
|
+
if (visibleItemQueue.size() <= options.minimumVisible) {
|
134
|
+
break;
|
135
|
+
}
|
136
|
+
currentWidth -= makeItemInvisible();
|
137
|
+
}
|
138
|
+
// make sure the overflow menu can fit
|
139
|
+
if (visibleItemQueue.size() > options.minimumVisible && invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) {
|
140
|
+
makeItemInvisible();
|
141
|
+
}
|
142
|
+
// only update when the state of visible/invisible items has changed
|
143
|
+
if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {
|
144
|
+
return true;
|
145
|
+
}
|
146
|
+
return false;
|
147
|
+
};
|
148
|
+
const forceUpdate = ()=>{
|
149
|
+
if (processOverflowItems() || forceDispatch) {
|
150
|
+
forceDispatch = false;
|
151
|
+
dispatchOverflowUpdate();
|
152
|
+
}
|
153
|
+
};
|
154
|
+
const update = (0, _debounce.debounce)(forceUpdate);
|
155
|
+
const observe = (observedContainer, userOptions)=>{
|
156
|
+
Object.assign(options, userOptions);
|
157
|
+
observing = true;
|
158
|
+
Object.values(overflowItems).forEach((item)=>visibleItemQueue.enqueue(item.id));
|
159
|
+
container = observedContainer;
|
160
|
+
resizeObserver.observe(container);
|
161
|
+
};
|
162
|
+
const disconnect = ()=>{
|
163
|
+
observing = false;
|
164
|
+
resizeObserver.disconnect();
|
165
|
+
};
|
166
|
+
const addItem = (item)=>{
|
167
|
+
if (overflowItems[item.id]) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
overflowItems[item.id] = item;
|
171
|
+
// some options can affect priority which are only set on `observe`
|
172
|
+
if (observing) {
|
173
|
+
// Updates to elements might not change the queue tops
|
174
|
+
// i.e. new element is enqueued but the top of the queue stays the same
|
175
|
+
// force a dispatch on the next batched update
|
176
|
+
forceDispatch = true;
|
177
|
+
visibleItemQueue.enqueue(item.id);
|
178
|
+
}
|
179
|
+
if (item.groupId) {
|
180
|
+
if (!overflowGroups[item.groupId]) {
|
181
|
+
overflowGroups[item.groupId] = {
|
182
|
+
visibleItemIds: new Set(),
|
183
|
+
invisibleItemIds: new Set()
|
184
|
+
};
|
185
|
+
}
|
186
|
+
overflowGroups[item.groupId].visibleItemIds.add(item.id);
|
187
|
+
}
|
188
|
+
update();
|
189
|
+
};
|
190
|
+
const addOverflowMenu = (el)=>{
|
191
|
+
overflowMenu = el;
|
192
|
+
};
|
193
|
+
const removeOverflowMenu = ()=>{
|
194
|
+
overflowMenu = undefined;
|
195
|
+
};
|
196
|
+
const removeItem = (itemId)=>{
|
197
|
+
if (!overflowItems[itemId]) {
|
198
|
+
return;
|
199
|
+
}
|
200
|
+
const item = overflowItems[itemId];
|
201
|
+
visibleItemQueue.remove(itemId);
|
202
|
+
invisibleItemQueue.remove(itemId);
|
203
|
+
if (item.groupId) {
|
204
|
+
overflowGroups[item.groupId].visibleItemIds.delete(item.id);
|
205
|
+
overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
|
206
|
+
}
|
207
|
+
delete overflowItems[itemId];
|
208
|
+
update();
|
209
|
+
};
|
210
|
+
return {
|
211
|
+
addItem,
|
212
|
+
disconnect,
|
213
|
+
forceUpdate,
|
214
|
+
observe,
|
215
|
+
removeItem,
|
216
|
+
update,
|
217
|
+
addOverflowMenu,
|
218
|
+
removeOverflowMenu
|
219
|
+
};
|
220
|
+
} //# sourceMappingURL=overflowManager.js.map
|
221
|
+
|
216
222
|
//# sourceMappingURL=overflowManager.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;;AAIA,SAAgBA,qBAAqB;EACnC,IAAIC,SAAkC;EACtC,IAAIC,YAAqC;EACzC,IAAIC,SAAS,GAAG,KAAK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G","names":["createOverflowManager","container","overflowMenu","observing","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowGroups","resizeObserver","ResizeObserver","entries","update","invisibleItemQueue","priorityQueue_1","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","debounce_1","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove","exports"],"sourceRoot":"../src/","sources":["packages/react-components/priority-overflow/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 let observing = 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 = (availableSize: number) => {\n if (!container) {\n return;\n }\n\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 dispatchOverflowUpdate();\n }\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (!container) {\n return;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n processOverflowItems(availableSize);\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 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"]}
|
1
|
+
{"version":3,"sources":["../lib/overflowManager.js"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport 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 let forceDispatch = false;\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 overflowGroups = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n update();\n });\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 const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({\n item,\n visible: true\n });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n return getOffsetSize(item.element);\n };\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({\n item,\n visible: false\n });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\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 const groupVisibility = {};\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 options.onUpdateOverflow({\n visibleItems,\n invisibleItems,\n groupVisibility\n });\n };\n const processOverflowItems = () => {\n if (!container) {\n return false;\n }\n const availableSize = getOffsetSize(container) - options.padding;\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\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 // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\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 // make sure the overflow menu can fit\n if (visibleItemQueue.size() > options.minimumVisible && invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) {\n makeItemInvisible();\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 return false;\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 if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set(),\n invisibleItemIds: new Set()\n };\n }\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n update();\n };\n const addOverflowMenu = el => {\n overflowMenu = el;\n };\n const removeOverflowMenu = () => {\n overflowMenu = undefined;\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 overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\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 };\n}\n//# sourceMappingURL=overflowManager.js.map"],"names":["createOverflowManager","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowGroups","resizeObserver","ResizeObserver","entries","update","invisibleItemQueue","createPriorityQueue","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","debounce","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove"],"mappings":";;;;+BAMgBA;;aAAAA;;0BANS;+BACW;AAK7B,SAASA,wBAAwB;IACtC,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY,KAAK;IACrB,+FAA+F;IAC/F,IAAIC,gBAAgB,KAAK;IACzB,MAAMC,UAAU;QACdC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAMC;QAC9BC,kBAAkB,IAAMD;IAC1B;IACA,MAAME,gBAAgB,CAAC;IACvB,MAAMC,iBAAiB,CAAC;IACxB,MAAMC,iBAAiB,IAAIC,eAAeC,CAAAA,UAAW;QACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,WAAW;YAC7B;QACF,CAAC;QACDiB;IACF;IACA,MAAMC,qBAAqBC,IAAAA,kCAAmB,EAAC,CAACC,GAAGC,IAAM;QACvD,MAAMC,QAAQV,aAAa,CAACQ,EAAE;QAC9B,MAAMG,QAAQX,aAAa,CAACS,EAAE;QAC9B,0CAA0C;QAC1C,MAAMG,WAAWD,MAAMC,QAAQ,GAAGF,MAAME,QAAQ;QAChD,IAAIA,aAAa,GA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