@fluentui/priority-overflow 9.0.3 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +61 -1
- package/CHANGELOG.md +20 -2
- package/dist/index.d.ts +16 -0
- package/lib/consts.js +2 -0
- package/lib/consts.js.map +1 -0
- package/lib/debounce.js +13 -14
- package/lib/debounce.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/overflowManager.js +260 -208
- package/lib/overflowManager.js.map +1 -1
- package/lib/priorityQueue.js +85 -86
- package/lib/priorityQueue.js.map +1 -1
- package/lib/types.js +1 -2
- package/lib/types.js.map +1 -1
- package/lib-commonjs/consts.js +16 -0
- package/lib-commonjs/consts.js.map +1 -0
- package/lib-commonjs/debounce.js +1 -3
- package/lib-commonjs/debounce.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowManager.js +113 -61
- package/lib-commonjs/overflowManager.js.map +1 -1
- package/lib-commonjs/priorityQueue.js +1 -3
- package/lib-commonjs/priorityQueue.js.map +1 -1
- package/lib-commonjs/types.js +0 -3
- package/lib-commonjs/types.js.map +1 -1
- package/package.json +3 -2
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "createOverflowManager", {
|
|
6
6
|
enumerable: true,
|
7
7
|
get: ()=>createOverflowManager
|
8
8
|
});
|
9
|
+
const _consts = require("./consts");
|
9
10
|
const _debounce = require("./debounce");
|
10
11
|
const _priorityQueue = require("./priorityQueue");
|
12
|
+
var _groups, _groupId;
|
11
13
|
function createOverflowManager() {
|
12
14
|
let container;
|
13
15
|
let overflowMenu;
|
@@ -25,13 +27,66 @@ function createOverflowManager() {
|
|
25
27
|
onUpdateOverflow: ()=>undefined
|
26
28
|
};
|
27
29
|
const overflowItems = {};
|
28
|
-
const
|
30
|
+
const overflowDividers = {};
|
29
31
|
const resizeObserver = new ResizeObserver((entries)=>{
|
30
32
|
if (!entries[0] || !container) {
|
31
33
|
return;
|
32
34
|
}
|
33
35
|
update();
|
34
36
|
});
|
37
|
+
const getNextItem = (queueToDequeue, queueToEnqueue)=>{
|
38
|
+
const nextItem = queueToDequeue.dequeue();
|
39
|
+
queueToEnqueue.enqueue(nextItem);
|
40
|
+
return overflowItems[nextItem];
|
41
|
+
};
|
42
|
+
const createGroupManager = ()=>{
|
43
|
+
const groupVisibility = {};
|
44
|
+
const groups = {};
|
45
|
+
function updateGroupVisibility(groupId) {
|
46
|
+
const group = groups[groupId];
|
47
|
+
if (group.invisibleItemIds.size && group.visibleItemIds.size) {
|
48
|
+
groupVisibility[groupId] = 'overflow';
|
49
|
+
} else if (group.visibleItemIds.size === 0) {
|
50
|
+
groupVisibility[groupId] = 'hidden';
|
51
|
+
} else {
|
52
|
+
groupVisibility[groupId] = 'visible';
|
53
|
+
}
|
54
|
+
}
|
55
|
+
function isGroupVisible(groupId) {
|
56
|
+
return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';
|
57
|
+
}
|
58
|
+
return {
|
59
|
+
groupVisibility: ()=>groupVisibility,
|
60
|
+
isSingleItemVisible (itemId, groupId) {
|
61
|
+
return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;
|
62
|
+
},
|
63
|
+
addItem (itemId, groupId) {
|
64
|
+
var _;
|
65
|
+
(_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {
|
66
|
+
visibleItemIds: new Set(),
|
67
|
+
invisibleItemIds: new Set()
|
68
|
+
};
|
69
|
+
groups[groupId].visibleItemIds.add(itemId);
|
70
|
+
updateGroupVisibility(groupId);
|
71
|
+
},
|
72
|
+
removeItem (itemId, groupId) {
|
73
|
+
groups[groupId].invisibleItemIds.delete(itemId);
|
74
|
+
groups[groupId].visibleItemIds.delete(itemId);
|
75
|
+
updateGroupVisibility(groupId);
|
76
|
+
},
|
77
|
+
showItem (itemId, groupId) {
|
78
|
+
groups[groupId].invisibleItemIds.delete(itemId);
|
79
|
+
groups[groupId].visibleItemIds.add(itemId);
|
80
|
+
updateGroupVisibility(groupId);
|
81
|
+
},
|
82
|
+
hideItem (itemId, groupId) {
|
83
|
+
groups[groupId].invisibleItemIds.add(itemId);
|
84
|
+
groups[groupId].visibleItemIds.delete(itemId);
|
85
|
+
updateGroupVisibility(groupId);
|
86
|
+
}
|
87
|
+
};
|
88
|
+
};
|
89
|
+
const groupManager = createGroupManager();
|
35
90
|
const invisibleItemQueue = (0, _priorityQueue.createPriorityQueue)((a, b)=>{
|
36
91
|
const itemA = overflowItems[a];
|
37
92
|
const itemB = overflowItems[b];
|
@@ -61,32 +116,38 @@ function createOverflowManager() {
|
|
61
116
|
const getOffsetSize = (el)=>{
|
62
117
|
return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
|
63
118
|
};
|
64
|
-
|
65
|
-
const
|
66
|
-
|
67
|
-
|
119
|
+
function computeSizeChange(entry) {
|
120
|
+
const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;
|
121
|
+
return getOffsetSize(entry.element) + dividerWidth;
|
122
|
+
}
|
123
|
+
const showItem = ()=>{
|
124
|
+
const item = getNextItem(invisibleItemQueue, visibleItemQueue);
|
68
125
|
options.onUpdateItemVisibility({
|
69
126
|
item,
|
70
127
|
visible: true
|
71
128
|
});
|
72
129
|
if (item.groupId) {
|
73
|
-
|
74
|
-
|
130
|
+
groupManager.showItem(item.id, item.groupId);
|
131
|
+
if (groupManager.isSingleItemVisible(item.id, item.groupId)) {
|
132
|
+
var _overflowDividers_item_groupId;
|
133
|
+
(_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.removeAttribute(_consts.DATA_OVERFLOWING);
|
134
|
+
}
|
75
135
|
}
|
76
|
-
return
|
136
|
+
return computeSizeChange(item);
|
77
137
|
};
|
78
|
-
const
|
79
|
-
const
|
80
|
-
|
81
|
-
const item = overflowItems[nextInvisible];
|
82
|
-
const width = getOffsetSize(item.element);
|
138
|
+
const hideItem = ()=>{
|
139
|
+
const item = getNextItem(visibleItemQueue, invisibleItemQueue);
|
140
|
+
const width = computeSizeChange(item);
|
83
141
|
options.onUpdateItemVisibility({
|
84
142
|
item,
|
85
143
|
visible: false
|
86
144
|
});
|
87
145
|
if (item.groupId) {
|
88
|
-
|
89
|
-
|
146
|
+
if (groupManager.isSingleItemVisible(item.id, item.groupId)) {
|
147
|
+
var _overflowDividers_item_groupId;
|
148
|
+
(_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.setAttribute(_consts.DATA_OVERFLOWING, '');
|
149
|
+
}
|
150
|
+
groupManager.hideItem(item.id, item.groupId);
|
90
151
|
}
|
91
152
|
return width;
|
92
153
|
};
|
@@ -95,56 +156,35 @@ function createOverflowManager() {
|
|
95
156
|
const invisibleItemIds = invisibleItemQueue.all();
|
96
157
|
const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);
|
97
158
|
const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);
|
98
|
-
const groupVisibility = {};
|
99
|
-
Object.entries(overflowGroups).forEach(([groupId, groupState])=>{
|
100
|
-
if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
|
101
|
-
groupVisibility[groupId] = 'overflow';
|
102
|
-
} else if (groupState.visibleItemIds.size === 0) {
|
103
|
-
groupVisibility[groupId] = 'hidden';
|
104
|
-
} else {
|
105
|
-
groupVisibility[groupId] = 'visible';
|
106
|
-
}
|
107
|
-
});
|
108
159
|
options.onUpdateOverflow({
|
109
160
|
visibleItems,
|
110
161
|
invisibleItems,
|
111
|
-
groupVisibility
|
162
|
+
groupVisibility: groupManager.groupVisibility()
|
112
163
|
});
|
113
164
|
};
|
114
165
|
const processOverflowItems = ()=>{
|
115
166
|
if (!container) {
|
116
167
|
return false;
|
117
168
|
}
|
118
|
-
const
|
119
|
-
|
169
|
+
const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);
|
170
|
+
function overflowMenuSize() {
|
171
|
+
return invisibleItemQueue.size() > 0 && overflowMenu ? getOffsetSize(overflowMenu) : 0;
|
172
|
+
}
|
173
|
+
const availableSize = getOffsetSize(container) - totalDividersWidth - options.padding;
|
120
174
|
// Snapshot of the visible/invisible state to compare for updates
|
121
175
|
const visibleTop = visibleItemQueue.peek();
|
122
176
|
const invisibleTop = invisibleItemQueue.peek();
|
123
|
-
|
124
|
-
let currentWidth = visibleItemIds.reduce((sum, visibleItemId)=>{
|
125
|
-
const child = overflowItems[visibleItemId].element;
|
126
|
-
return sum + getOffsetSize(child);
|
127
|
-
}, 0);
|
177
|
+
let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
|
128
178
|
// Add items until available width is filled - can result in overflow
|
129
|
-
while(currentWidth < availableSize && invisibleItemQueue.size() > 0){
|
130
|
-
currentWidth +=
|
179
|
+
while(currentWidth + overflowMenuSize() < availableSize && invisibleItemQueue.size() > 0){
|
180
|
+
currentWidth += showItem();
|
131
181
|
}
|
132
182
|
// Remove items until there's no more overflow
|
133
|
-
while(currentWidth > availableSize && visibleItemQueue.size() >
|
134
|
-
|
135
|
-
break;
|
136
|
-
}
|
137
|
-
currentWidth -= makeItemInvisible();
|
138
|
-
}
|
139
|
-
// make sure the overflow menu can fit
|
140
|
-
if (visibleItemQueue.size() > options.minimumVisible && invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) {
|
141
|
-
makeItemInvisible();
|
183
|
+
while(currentWidth + overflowMenuSize() > availableSize && visibleItemQueue.size() > options.minimumVisible){
|
184
|
+
currentWidth -= hideItem();
|
142
185
|
}
|
143
186
|
// only update when the state of visible/invisible items has changed
|
144
|
-
|
145
|
-
return true;
|
146
|
-
}
|
147
|
-
return false;
|
187
|
+
return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
|
148
188
|
};
|
149
189
|
const forceUpdate = ()=>{
|
150
190
|
if (processOverflowItems() || forceDispatch) {
|
@@ -178,22 +218,34 @@ function createOverflowManager() {
|
|
178
218
|
visibleItemQueue.enqueue(item.id);
|
179
219
|
}
|
180
220
|
if (item.groupId) {
|
181
|
-
|
182
|
-
|
183
|
-
visibleItemIds: new Set(),
|
184
|
-
invisibleItemIds: new Set()
|
185
|
-
};
|
186
|
-
}
|
187
|
-
overflowGroups[item.groupId].visibleItemIds.add(item.id);
|
221
|
+
groupManager.addItem(item.id, item.groupId);
|
222
|
+
item.element.setAttribute(_consts.DATA_OVERFLOW_GROUP, item.groupId);
|
188
223
|
}
|
189
224
|
update();
|
190
225
|
};
|
191
226
|
const addOverflowMenu = (el)=>{
|
192
227
|
overflowMenu = el;
|
193
228
|
};
|
229
|
+
const addDivider = (divider)=>{
|
230
|
+
if (!divider.groupId || overflowDividers[divider.groupId]) {
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
divider.element.setAttribute(_consts.DATA_OVERFLOW_GROUP, divider.groupId);
|
234
|
+
overflowDividers[divider.groupId] = divider;
|
235
|
+
};
|
194
236
|
const removeOverflowMenu = ()=>{
|
195
237
|
overflowMenu = undefined;
|
196
238
|
};
|
239
|
+
const removeDivider = (groupId)=>{
|
240
|
+
if (!overflowDividers[groupId]) {
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
const divider = overflowDividers[groupId];
|
244
|
+
if (divider.groupId) {
|
245
|
+
delete overflowDividers[groupId];
|
246
|
+
divider.element.removeAttribute(_consts.DATA_OVERFLOW_GROUP);
|
247
|
+
}
|
248
|
+
};
|
197
249
|
const removeItem = (itemId)=>{
|
198
250
|
if (!overflowItems[itemId]) {
|
199
251
|
return;
|
@@ -202,8 +254,8 @@ function createOverflowManager() {
|
|
202
254
|
visibleItemQueue.remove(itemId);
|
203
255
|
invisibleItemQueue.remove(itemId);
|
204
256
|
if (item.groupId) {
|
205
|
-
|
206
|
-
|
257
|
+
groupManager.removeItem(item.id, item.groupId);
|
258
|
+
item.element.removeAttribute(_consts.DATA_OVERFLOW_GROUP);
|
207
259
|
}
|
208
260
|
delete overflowItems[itemId];
|
209
261
|
update();
|
@@ -216,8 +268,8 @@ function createOverflowManager() {
|
|
216
268
|
removeItem,
|
217
269
|
update,
|
218
270
|
addOverflowMenu,
|
219
|
-
removeOverflowMenu
|
271
|
+
removeOverflowMenu,
|
272
|
+
addDivider,
|
273
|
+
removeDivider
|
220
274
|
};
|
221
|
-
}
|
222
|
-
|
223
|
-
//# sourceMappingURL=overflowManager.js.map
|
275
|
+
}
|
@@ -1 +1 @@
|
|
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 // 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 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","removeOverflow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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,SAASC;AAOF,SAASF,wBAAwB;IACxC,IAAIG;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY,KAAK;IACrB,+FAA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,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 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["priorityQueue.js"],"sourcesContent":["/**\n * @param compare - comparison function for items\n * @returns Priority queue implemented with a min heap\n */ export function createPriorityQueue(compare) {\n const arr = [];\n let size = 0;\n const left = (i)=>{\n return 2 * i + 1;\n };\n const right = (i)=>{\n return 2 * i + 2;\n };\n const parent = (i)=>{\n return Math.floor((i - 1) / 2);\n };\n const swap = (a, b)=>{\n const tmp = arr[a];\n arr[a] = arr[b];\n arr[b] = tmp;\n };\n const heapify = (i)=>{\n let smallest = i;\n const l = left(i);\n const r = right(i);\n if (l < size && compare(arr[l], arr[smallest]) < 0) {\n smallest = l;\n }\n if (r < size && compare(arr[r], arr[smallest]) < 0) {\n smallest = r;\n }\n if (smallest !== i) {\n swap(smallest, i);\n heapify(smallest);\n }\n };\n const dequeue = ()=>{\n if (size === 0) {\n throw new Error('Priority queue empty');\n }\n const res = arr[0];\n arr[0] = arr[--size];\n heapify(0);\n return res;\n };\n const peek = ()=>{\n if (size === 0) {\n return null;\n }\n return arr[0];\n };\n const enqueue = (item)=>{\n arr[size++] = item;\n let i = size - 1;\n let p = parent(i);\n while(i > 0 && compare(arr[p], arr[i]) > 0){\n swap(p, i);\n i = p;\n p = parent(i);\n }\n };\n const contains = (item)=>{\n const index = arr.indexOf(item);\n return index >= 0 && index < size;\n };\n const remove = (item)=>{\n const i = arr.indexOf(item);\n if (i === -1 || i >= size) {\n return;\n }\n arr[i] = arr[--size];\n heapify(i);\n };\n const clear = ()=>{\n size = 0;\n };\n const all = ()=>{\n return arr.slice(0, size);\n };\n return {\n all,\n clear,\n contains,\n dequeue,\n enqueue,\n peek,\n remove,\n size: ()=>size\n };\n}\n"],"names":["createPriorityQueue","compare","arr","size","left","i","right","parent","Math","floor","swap","a","b","tmp","heapify","smallest","l","r","dequeue","Error","res","peek","enqueue","item","p","contains","index","indexOf","remove","clear","all","slice"],"mappings":"AAAA;;;CAGC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,oBAAoBC,OAAO,EAAE;IAC7C,MAAMC,MAAM,EAAE;IACd,IAAIC,OAAO;IACX,MAAMC,OAAO,CAACC,IAAI;QACd,OAAO,IAAIA,IAAI;IACnB;IACA,MAAMC,QAAQ,CAACD,IAAI;QACf,OAAO,IAAIA,IAAI;IACnB;IACA,MAAME,SAAS,CAACF,IAAI;QAChB,OAAOG,KAAKC,KAAK,CAAC,AAACJ,CAAAA,IAAI,CAAA,IAAK;IAChC;IACA,MAAMK,OAAO,CAACC,GAAGC,IAAI;QACjB,MAAMC,MAAM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,KAAKA,QAAQvB;IACjC;IACA,MAAMyB,SAAS,CAACL,OAAO;QACnB,MAAMlB,IAAIH,IAAIyB,OAAO,CAACJ;QACtB,IAAIlB,MAAM,CAAC,KAAKA,KAAKF,MAAM;YACvB;QACJ,CAAC;QACDD,GAAG,CAACG,EAAE,GAAGH,GAAG,CAAC,EAAEC,KAAK;QACpBW,QAAQT;IACZ;IACA,MAAMwB,QAAQ,IAAI;QACd1B,OAAO;IACX;IACA,MAAM2B,MAAM,IAAI;QACZ,OAAO5B,IAAI6B,KAAK,CAAC,GAAG5B;IACxB;IACA,OAAO;QACH2B;QACAD;QACAJ;QACAP;QACAI;QACAD;QACAO;QACAzB,MAAM,IAAIA;IACd;AACJ"}
|
package/lib-commonjs/types.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":[
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/priority-overflow",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.1.1",
|
4
4
|
"description": "Vanilla JS utilities to implement overflow menus",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -20,7 +20,8 @@
|
|
20
20
|
"lint": "just-scripts lint",
|
21
21
|
"test": "jest --passWithNoTests",
|
22
22
|
"type-check": "tsc -b tsconfig.json",
|
23
|
-
"generate-api": "just-scripts generate-api"
|
23
|
+
"generate-api": "just-scripts generate-api",
|
24
|
+
"test-ssr": "test-ssr \"./stories/**/*.stories.tsx\""
|
24
25
|
},
|
25
26
|
"devDependencies": {
|
26
27
|
"@fluentui/eslint-plugin": "*",
|