@fluentui/priority-overflow 0.0.0-nightly-20230615-0416.1 → 0.0.0-nightly-20230619-0417.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/priority-overflow",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 15 Jun 2023 04:21:13 GMT",
6
- "tag": "@fluentui/priority-overflow_v0.0.0-nightly-20230615-0416.1",
7
- "version": "0.0.0-nightly-20230615-0416.1",
5
+ "date": "Mon, 19 Jun 2023 04:22:36 GMT",
6
+ "tag": "@fluentui/priority-overflow_v0.0.0-nightly-20230619-0417.1",
7
+ "version": "0.0.0-nightly-20230619-0417.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
package/CHANGELOG.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Change Log - @fluentui/priority-overflow
2
2
 
3
- This log was last generated on Thu, 15 Jun 2023 04:21:13 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 19 Jun 2023 04:22:36 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20230615-0416.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v0.0.0-nightly-20230615-0416.1)
7
+ ## [0.0.0-nightly-20230619-0417.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v0.0.0-nightly-20230619-0417.1)
8
8
 
9
- Thu, 15 Jun 2023 04:21:13 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.3..@fluentui/priority-overflow_v0.0.0-nightly-20230615-0416.1)
9
+ Mon, 19 Jun 2023 04:22:36 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.3..@fluentui/priority-overflow_v0.0.0-nightly-20230619-0417.1)
11
11
 
12
12
  ### Changes
13
13
 
package/dist/index.d.ts CHANGED
@@ -52,6 +52,14 @@ export declare type OverflowAxis = 'horizontal' | 'vertical';
52
52
 
53
53
  export declare type OverflowDirection = 'start' | 'end';
54
54
 
55
+ export declare interface OverflowDividerEntry {
56
+ /**
57
+ * HTML element that will be disappear when overflowed
58
+ */
59
+ element: HTMLElement;
60
+ groupId: string;
61
+ }
62
+
55
63
  /**
56
64
  * Payload of the custom DOM event for overflow updates
57
65
  */
@@ -113,6 +121,14 @@ export declare interface OverflowManager {
113
121
  * available space and check if additional items need to overflow
114
122
  */
115
123
  addOverflowMenu: (element: HTMLElement) => void;
124
+ /**
125
+ * Add overflow divider
126
+ */
127
+ addDivider: (divider: OverflowDividerEntry) => void;
128
+ /**
129
+ * Remove overflow divider
130
+ */
131
+ removeDivider: (groupId: string) => void;
116
132
  /**
117
133
  * Unsets the overflow menu element
118
134
  */
package/lib/consts.js ADDED
@@ -0,0 +1,2 @@
1
+ export const DATA_OVERFLOWING = 'data-overflowing';
2
+ export const DATA_OVERFLOW_GROUP = 'data-overflow-group';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["consts.ts"],"sourcesContent":["export const DATA_OVERFLOWING = 'data-overflowing';\nexport const DATA_OVERFLOW_GROUP = 'data-overflow-group';\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_GROUP"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,mBAAmB;AACnD,OAAO,MAAMC,sBAAsB,sBAAsB"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export { createOverflowManager } from './overflowManager';\nexport type {\n ObserveOptions,\n OnUpdateItemVisibility,\n OnUpdateItemVisibilityPayload,\n OnUpdateOverflow,\n OverflowAxis,\n OverflowDirection,\n OverflowEventPayload,\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n} from './types';\n"],"names":["createOverflowManager"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAoB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { createOverflowManager } from './overflowManager';\nexport type {\n ObserveOptions,\n OnUpdateItemVisibility,\n OnUpdateItemVisibilityPayload,\n OnUpdateOverflow,\n OverflowAxis,\n OverflowDirection,\n OverflowEventPayload,\n OverflowGroupState,\n OverflowItemEntry,\n OverflowDividerEntry,\n OverflowManager,\n} from './types';\n"],"names":["createOverflowManager"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAoB"}
@@ -1,3 +1,5 @@
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
  /**
@@ -20,13 +22,66 @@ import { createPriorityQueue } from './priorityQueue';
20
22
  onUpdateOverflow: ()=>undefined
21
23
  };
22
24
  const overflowItems = {};
23
- const overflowGroups = {};
25
+ const overflowDividers = {};
24
26
  const resizeObserver = new ResizeObserver((entries)=>{
25
27
  if (!entries[0] || !container) {
26
28
  return;
27
29
  }
28
30
  update();
29
31
  });
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();
30
85
  const invisibleItemQueue = createPriorityQueue((a, b)=>{
31
86
  const itemA = overflowItems[a];
32
87
  const itemB = overflowItems[b];
@@ -56,32 +111,38 @@ import { createPriorityQueue } from './priorityQueue';
56
111
  const getOffsetSize = (el)=>{
57
112
  return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
58
113
  };
59
- const makeItemVisible = ()=>{
60
- const nextVisible = invisibleItemQueue.dequeue();
61
- visibleItemQueue.enqueue(nextVisible);
62
- const item = overflowItems[nextVisible];
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;
117
+ }
118
+ const showItem = ()=>{
119
+ const item = getNextItem(invisibleItemQueue, visibleItemQueue);
63
120
  options.onUpdateItemVisibility({
64
121
  item,
65
122
  visible: true
66
123
  });
67
124
  if (item.groupId) {
68
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
69
- overflowGroups[item.groupId].visibleItemIds.add(item.id);
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
+ }
70
130
  }
71
- return getOffsetSize(item.element);
131
+ return computeSizeChange(item);
72
132
  };
73
- const makeItemInvisible = ()=>{
74
- const nextInvisible = visibleItemQueue.dequeue();
75
- invisibleItemQueue.enqueue(nextInvisible);
76
- const item = overflowItems[nextInvisible];
77
- const width = getOffsetSize(item.element);
133
+ const hideItem = ()=>{
134
+ const item = getNextItem(visibleItemQueue, invisibleItemQueue);
135
+ const width = computeSizeChange(item);
78
136
  options.onUpdateItemVisibility({
79
137
  item,
80
138
  visible: false
81
139
  });
82
140
  if (item.groupId) {
83
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
84
- overflowGroups[item.groupId].invisibleItemIds.add(item.id);
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);
85
146
  }
86
147
  return width;
87
148
  };
@@ -90,56 +151,32 @@ import { createPriorityQueue } from './priorityQueue';
90
151
  const invisibleItemIds = invisibleItemQueue.all();
91
152
  const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);
92
153
  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
- }
102
- });
103
154
  options.onUpdateOverflow({
104
155
  visibleItems,
105
156
  invisibleItems,
106
- groupVisibility
157
+ groupVisibility: groupManager.groupVisibility()
107
158
  });
108
159
  };
109
160
  const processOverflowItems = ()=>{
110
161
  if (!container) {
111
162
  return false;
112
163
  }
113
- const availableSize = getOffsetSize(container) - options.padding;
114
- const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
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);
115
166
  // Snapshot of the visible/invisible state to compare for updates
116
167
  const visibleTop = visibleItemQueue.peek();
117
168
  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);
169
+ let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
123
170
  // Add items until available width is filled - can result in overflow
124
171
  while(currentWidth < availableSize && invisibleItemQueue.size() > 0){
125
- currentWidth += makeItemVisible();
172
+ currentWidth += showItem();
126
173
  }
127
174
  // 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();
175
+ while(currentWidth > availableSize && visibleItemQueue.size() > options.minimumVisible){
176
+ currentWidth -= hideItem();
137
177
  }
138
178
  // 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;
179
+ return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
143
180
  };
144
181
  const forceUpdate = ()=>{
145
182
  if (processOverflowItems() || forceDispatch) {
@@ -173,22 +210,34 @@ import { createPriorityQueue } from './priorityQueue';
173
210
  visibleItemQueue.enqueue(item.id);
174
211
  }
175
212
  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);
213
+ groupManager.addItem(item.id, item.groupId);
214
+ item.element.setAttribute(DATA_OVERFLOW_GROUP, item.groupId);
183
215
  }
184
216
  update();
185
217
  };
186
218
  const addOverflowMenu = (el)=>{
187
219
  overflowMenu = el;
188
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
+ };
189
228
  const removeOverflowMenu = ()=>{
190
229
  overflowMenu = undefined;
191
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
+ };
192
241
  const removeItem = (itemId)=>{
193
242
  if (!overflowItems[itemId]) {
194
243
  return;
@@ -197,8 +246,8 @@ import { createPriorityQueue } from './priorityQueue';
197
246
  visibleItemQueue.remove(itemId);
198
247
  invisibleItemQueue.remove(itemId);
199
248
  if (item.groupId) {
200
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
201
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
249
+ groupManager.removeItem(item.id, item.groupId);
250
+ item.element.removeAttribute(DATA_OVERFLOW_GROUP);
202
251
  }
203
252
  delete overflowItems[itemId];
204
253
  update();
@@ -211,6 +260,8 @@ import { createPriorityQueue } from './priorityQueue';
211
260
  removeItem,
212
261
  update,
213
262
  addOverflowMenu,
214
- removeOverflowMenu
263
+ removeOverflowMenu,
264
+ addDivider,
265
+ removeDivider
215
266
  };
216
267
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["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 // 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 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"],"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"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,aAAa;AACtC,SAASC,mBAAmB,QAAQ,kBAAkB;AAGtD;;;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,iBAAiG,CAAC;IACxG,MAAMC,iBAAiB,IAAIC,eAAeC,CAAAA,UAAW;QACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,WAAW;YAC7B;QACF,CAAC;QAEDiB;IACF;IAEA,MAAMC,qBAAqBpB,oBAA4B,CAACqB,GAAGC,IAAM;QAC/D,MAAMC,QAAQT,aAAa,CAACO,EAAE;QAC9B,MAAMG,QAAQV,aAAa,CAACQ,EAAE;QAC9B,0CAA0C;QAC1C,MAAMG,WAAWD,MAAMC,QAAQ,GAAGF,MAAME,QAAQ;QAChD,IAAIA,aAAa,GAAG;YAClB,OAAOA;QACT,CAAC;QAED,MAAMC,oBACJpB,QAAQG,iBAAiB,KAAK,QAAQkB,KAAKC,2BAA2B,GA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AKE,OAAO,EAAE;YAChB5B,cAAc,CAAC0B,KAAKE,OAAO,CAAC,CAACI,cAAc,CAACF,MAAM,CAACJ,KAAKK,EAAE;YAC1D/B,cAAc,CAAC0B,KAAKE,OAAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,KAAKK,EAAE;QAC9D,CAAC;QAED,OAAOhC,aAAa,CAAC0C,OAAO;QAC5BrC;IACF;IAEA,OAAO;QACL8D;QACAD;QACAN;QACAC;QACAU;QACAlE;QACAgE;QACAC;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["overflowManager.ts"],"sourcesContent":["import { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { debounce } from './debounce';\nimport { createPriorityQueue, PriorityQueue } from './priorityQueue';\nimport type {\n OverflowGroupState,\n OverflowItemEntry,\n OverflowManager,\n ObserveOptions,\n OverflowDividerEntry,\n} from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n 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,eAAeG,OAAO;QACvCF,eAAeG,OAAO,CAACF;QACvB,OA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KAAKX,OAAO,CAACa,eAAe,CAACtE;QAC/B,CAAC;QAED,OAAOgB,aAAa,CAACqB,OAAO;QAC5BhB;IACF;IAEA,OAAO;QACLkB;QACA0D;QACAN;QACAC;QACAlD;QACArB;QACA6E;QACAG;QACAF;QACAG;IACF;AACF,CAAC"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"sourcesContent":["export type OverflowDirection = 'start' | 'end';\nexport type OverflowAxis = 'horizontal' | 'vertical';\nexport type OverflowGroupState = 'visible' | 'hidden' | 'overflow';\nexport interface OverflowItemEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n /**\n * Lower priority items are invisible first when the container is overflowed\n * @default 0\n */\n priority: number;\n /**\n * Specific id, used to track visibility and provide updates to consumers\n */\n id: string;\n\n groupId?: string;\n}\n\n/**\n * signature similar to standard event listeners, but typed to handle the custom event\n */\nexport type OnUpdateOverflow = (data: OverflowEventPayload) => void;\n\nexport type OnUpdateItemVisibility = (data: OnUpdateItemVisibilityPayload) => void;\n\n/**\n * Payload of the custom DOM event for overflow updates\n */\nexport interface OverflowEventPayload {\n visibleItems: OverflowItemEntry[];\n invisibleItems: OverflowItemEntry[];\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\nexport interface OnUpdateItemVisibilityPayload {\n item: OverflowItemEntry;\n visible: boolean;\n}\n\nexport interface ObserveOptions {\n /**\n * Padding (in px) at the end of the container before overflow occurs\n * Useful to account for extra elements (i.e. dropdown menu)\n * or to account for any kinds of margins between items which are hard to measure with JS\n * @default 10\n */\n padding?: number;\n /**\n * Direction where items are removed when overflow occurs\n * @default end\n */\n overflowDirection?: OverflowDirection;\n\n /**\n * Horizontal or vertical overflow\n * @default horizontal\n */\n overflowAxis?: OverflowAxis;\n\n /**\n * The minimum number of visible items\n */\n minimumVisible?: number;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateItemVisibility: OnUpdateItemVisibility;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateOverflow: OnUpdateOverflow;\n}\n\n/**\n * @internal\n */\nexport interface OverflowManager {\n /**\n * Starts observing the container and managing the overflow state\n */\n observe: (container: HTMLElement, options: ObserveOptions) => void;\n /**\n * Stops observing the container\n */\n disconnect: () => void;\n /**\n * Add overflow items\n */\n addItem: (items: OverflowItemEntry) => void;\n /**\n * Remove overflow item\n */\n removeItem: (itemId: string) => void;\n /**\n * Manually update the overflow, updates are batched and async\n */\n update: () => void;\n /**\n * Manually update the overflow sync\n */\n forceUpdate: () => void;\n\n /**\n * Adds an element that opens an overflow menu. This is used to calculate\n * available space and check if additional items need to overflow\n */\n addOverflowMenu: (element: HTMLElement) => void;\n\n /**\n * Unsets the overflow menu element\n */\n removeOverflowMenu: () => void;\n}\n"],"names":[],"mappings":"AAAA,WAqHC"}
1
+ {"version":3,"sources":["types.ts"],"sourcesContent":["export type OverflowDirection = 'start' | 'end';\nexport type OverflowAxis = 'horizontal' | 'vertical';\nexport type OverflowGroupState = 'visible' | 'hidden' | 'overflow';\nexport interface OverflowItemEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n /**\n * Lower priority items are invisible first when the container is overflowed\n * @default 0\n */\n priority: number;\n /**\n * Specific id, used to track visibility and provide updates to consumers\n */\n id: string;\n\n groupId?: string;\n}\n\nexport interface OverflowDividerEntry {\n /**\n * HTML element that will be disappear when overflowed\n */\n element: HTMLElement;\n\n groupId: string;\n}\n\n/**\n * signature similar to standard event listeners, but typed to handle the custom event\n */\nexport type OnUpdateOverflow = (data: OverflowEventPayload) => void;\n\nexport type OnUpdateItemVisibility = (data: OnUpdateItemVisibilityPayload) => void;\n\n/**\n * Payload of the custom DOM event for overflow updates\n */\nexport interface OverflowEventPayload {\n visibleItems: OverflowItemEntry[];\n invisibleItems: OverflowItemEntry[];\n groupVisibility: Record<string, OverflowGroupState>;\n}\n\nexport interface OnUpdateItemVisibilityPayload {\n item: OverflowItemEntry;\n visible: boolean;\n}\n\nexport interface ObserveOptions {\n /**\n * Padding (in px) at the end of the container before overflow occurs\n * Useful to account for extra elements (i.e. dropdown menu)\n * or to account for any kinds of margins between items which are hard to measure with JS\n * @default 10\n */\n padding?: number;\n /**\n * Direction where items are removed when overflow occurs\n * @default end\n */\n overflowDirection?: OverflowDirection;\n\n /**\n * Horizontal or vertical overflow\n * @default horizontal\n */\n overflowAxis?: OverflowAxis;\n\n /**\n * The minimum number of visible items\n */\n minimumVisible?: number;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateItemVisibility: OnUpdateItemVisibility;\n\n /**\n * Callback when item visibility is updated\n */\n onUpdateOverflow: OnUpdateOverflow;\n}\n\n/**\n * @internal\n */\nexport interface OverflowManager {\n /**\n * Starts observing the container and managing the overflow state\n */\n observe: (container: HTMLElement, options: ObserveOptions) => void;\n /**\n * Stops observing the container\n */\n disconnect: () => void;\n /**\n * Add overflow items\n */\n addItem: (items: OverflowItemEntry) => void;\n /**\n * Remove overflow item\n */\n removeItem: (itemId: string) => void;\n /**\n * Manually update the overflow, updates are batched and async\n */\n update: () => void;\n /**\n * Manually update the overflow sync\n */\n forceUpdate: () => void;\n\n /**\n * Adds an element that opens an overflow menu. This is used to calculate\n * available space and check if additional items need to overflow\n */\n addOverflowMenu: (element: HTMLElement) => void;\n\n /**\n * Add overflow divider\n */\n addDivider: (divider: OverflowDividerEntry) => void;\n\n /**\n * Remove overflow divider\n */\n removeDivider: (groupId: string) => void;\n\n /**\n * Unsets the overflow menu element\n */\n removeOverflowMenu: () => void;\n}\n"],"names":[],"mappings":"AAAA,WAwIC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ DATA_OVERFLOWING: ()=>DATA_OVERFLOWING,
13
+ DATA_OVERFLOW_GROUP: ()=>DATA_OVERFLOW_GROUP
14
+ });
15
+ const DATA_OVERFLOWING = 'data-overflowing';
16
+ const DATA_OVERFLOW_GROUP = 'data-overflow-group';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["consts.js"],"sourcesContent":["export const DATA_OVERFLOWING = 'data-overflowing';\nexport const DATA_OVERFLOW_GROUP = 'data-overflow-group';\n"],"names":["DATA_OVERFLOWING","DATA_OVERFLOW_GROUP"],"mappings":";;;;;;;;;;;IAAaA,gBAAgB,MAAhBA;IACAC,mBAAmB,MAAnBA;;AADN,MAAMD,mBAAmB;AACzB,MAAMC,sBAAsB"}
@@ -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 overflowGroups = {};
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
- const makeItemVisible = ()=>{
65
- const nextVisible = invisibleItemQueue.dequeue();
66
- visibleItemQueue.enqueue(nextVisible);
67
- const item = overflowItems[nextVisible];
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
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
74
- overflowGroups[item.groupId].visibleItemIds.add(item.id);
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 getOffsetSize(item.element);
136
+ return computeSizeChange(item);
77
137
  };
78
- const makeItemInvisible = ()=>{
79
- const nextInvisible = visibleItemQueue.dequeue();
80
- invisibleItemQueue.enqueue(nextInvisible);
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
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
89
- overflowGroups[item.groupId].invisibleItemIds.add(item.id);
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,32 @@ 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 availableSize = getOffsetSize(container) - options.padding;
119
- const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
169
+ const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);
170
+ const availableSize = getOffsetSize(container) - options.padding - totalDividersWidth - (overflowMenu ? getOffsetSize(overflowMenu) : 0);
120
171
  // Snapshot of the visible/invisible state to compare for updates
121
172
  const visibleTop = visibleItemQueue.peek();
122
173
  const invisibleTop = invisibleItemQueue.peek();
123
- const visibleItemIds = visibleItemQueue.all();
124
- let currentWidth = visibleItemIds.reduce((sum, visibleItemId)=>{
125
- const child = overflowItems[visibleItemId].element;
126
- return sum + getOffsetSize(child);
127
- }, 0);
174
+ let currentWidth = visibleItemQueue.all().map((id)=>overflowItems[id].element).map(getOffsetSize).reduce((prev, current)=>prev + current, 0);
128
175
  // Add items until available width is filled - can result in overflow
129
176
  while(currentWidth < availableSize && invisibleItemQueue.size() > 0){
130
- currentWidth += makeItemVisible();
177
+ currentWidth += showItem();
131
178
  }
132
179
  // Remove items until there's no more overflow
133
- while(currentWidth > availableSize && visibleItemQueue.size() > 0){
134
- if (visibleItemQueue.size() <= options.minimumVisible) {
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();
180
+ while(currentWidth > availableSize && visibleItemQueue.size() > options.minimumVisible){
181
+ currentWidth -= hideItem();
142
182
  }
143
183
  // only update when the state of visible/invisible items has changed
144
- if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {
145
- return true;
146
- }
147
- return false;
184
+ return visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop;
148
185
  };
149
186
  const forceUpdate = ()=>{
150
187
  if (processOverflowItems() || forceDispatch) {
@@ -178,22 +215,34 @@ function createOverflowManager() {
178
215
  visibleItemQueue.enqueue(item.id);
179
216
  }
180
217
  if (item.groupId) {
181
- if (!overflowGroups[item.groupId]) {
182
- overflowGroups[item.groupId] = {
183
- visibleItemIds: new Set(),
184
- invisibleItemIds: new Set()
185
- };
186
- }
187
- overflowGroups[item.groupId].visibleItemIds.add(item.id);
218
+ groupManager.addItem(item.id, item.groupId);
219
+ item.element.setAttribute(_consts.DATA_OVERFLOW_GROUP, item.groupId);
188
220
  }
189
221
  update();
190
222
  };
191
223
  const addOverflowMenu = (el)=>{
192
224
  overflowMenu = el;
193
225
  };
226
+ const addDivider = (divider)=>{
227
+ if (!divider.groupId || overflowDividers[divider.groupId]) {
228
+ return;
229
+ }
230
+ divider.element.setAttribute(_consts.DATA_OVERFLOW_GROUP, divider.groupId);
231
+ overflowDividers[divider.groupId] = divider;
232
+ };
194
233
  const removeOverflowMenu = ()=>{
195
234
  overflowMenu = undefined;
196
235
  };
236
+ const removeDivider = (groupId)=>{
237
+ if (!overflowDividers[groupId]) {
238
+ return;
239
+ }
240
+ const divider = overflowDividers[groupId];
241
+ if (divider.groupId) {
242
+ delete overflowDividers[groupId];
243
+ divider.element.removeAttribute(_consts.DATA_OVERFLOW_GROUP);
244
+ }
245
+ };
197
246
  const removeItem = (itemId)=>{
198
247
  if (!overflowItems[itemId]) {
199
248
  return;
@@ -202,8 +251,8 @@ function createOverflowManager() {
202
251
  visibleItemQueue.remove(itemId);
203
252
  invisibleItemQueue.remove(itemId);
204
253
  if (item.groupId) {
205
- overflowGroups[item.groupId].visibleItemIds.delete(item.id);
206
- overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
254
+ groupManager.removeItem(item.id, item.groupId);
255
+ item.element.removeAttribute(_consts.DATA_OVERFLOW_GROUP);
207
256
  }
208
257
  delete overflowItems[itemId];
209
258
  update();
@@ -216,6 +265,8 @@ function createOverflowManager() {
216
265
  removeItem,
217
266
  update,
218
267
  addOverflowMenu,
219
- removeOverflowMenu
268
+ removeOverflowMenu,
269
+ addDivider,
270
+ removeDivider
220
271
  };
221
272
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["overflowManager.js"],"sourcesContent":["import { 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 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"],"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":";;;;+BAKoBA;;aAAAA;;0BALK;+BACW;AAIzB,SAASA,wBAAwB;IACxC,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY,KAAK;IACrB,+FAA+F;IAC/F,kDAAkD;IAClD,IAAIC,gBAAgB,IAAI;IACxB,MAAMC,UAAU;QACZC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAIC;QAC5BC,kBAAkB,IAAID;IAC1B;IACA,MAAME,gBAAgB,CAAC;IACvB,MAAMC,iBAAiB,CAAC;IACxB,MAAMC,iBAAiB,IAAIC,eAAe,CAACC,UAAU;QACjD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,WAAW;YAC3B;QACJ,CAAC;QACDiB;IACJ;IACA,MAAMC,qBAAqBC,IAAAA,kCAAmB,EAAC,CAACC,GAAGC,IAAI;QACnD,MAAMC,QAAQV,aAAa,CAACQ,EAAE;QAC9B,MAAMG,QAAQX,aAAa,CAACS,EAAE;QAC9B,0CAA0C;QAC1C,MAAMG,WAAWD,MAAMC,QAAQ,GAAGF,MAAME,QAAQ;QAChD,IAAIA,aAAa,GAAG;YAChB,OAAOA;QACX,CAAC;QACD,MAAMC,oBAAoBrB,QAAQG,iBAAiB,KAAK,QAAQmB,KAAKC,2BAA2B,GAAGD,KAAKE,2BAA2B;QACnI,gCAAgC;QAChC,sCAAsC;QACtC,OAAON,MAAMO,OAAO,CAACC,uBAAuB,CAACP,MAAMM,OAAO,IAAIJ,oBAAoB,CAAC,IAAI,CAAC;IAC5F;IACA,MAAMM,mBAAmBZ,IAAAA,kCAAmB,EAAC,CAACC,GAAGC,IAAI;QACjD,MAAMC,QAAQV,aAAa,CAACQ,EAAE;QAC9B,MAAMG,QAAQX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U;QACApE;QACAkE;QACAC;IACJ;AACJ"}
1
+ {"version":3,"sources":["overflowManager.js"],"sourcesContent":["var _groups, _groupId;\nimport { DATA_OVERFLOWING, DATA_OVERFLOW_GROUP } from './consts';\nimport { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\n/**\n * @internal\n * @returns overflow manager instance\n */ export function createOverflowManager() {\n let container;\n let overflowMenu;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n // Initially true to force dispatch on first mount\n let forceDispatch = true;\n const options = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: ()=>undefined,\n onUpdateOverflow: ()=>undefined\n };\n const overflowItems = {};\n const overflowDividers = {};\n const resizeObserver = new ResizeObserver((entries)=>{\n if (!entries[0] || !container) {\n return;\n }\n update();\n });\n const getNextItem = (queueToDequeue, queueToEnqueue)=>{\n const nextItem = queueToDequeue.dequeue();\n queueToEnqueue.enqueue(nextItem);\n return overflowItems[nextItem];\n };\n const createGroupManager = ()=>{\n const groupVisibility = {};\n const groups = {};\n function updateGroupVisibility(groupId) {\n const group = groups[groupId];\n if (group.invisibleItemIds.size && group.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (group.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n }\n function isGroupVisible(groupId) {\n return groupVisibility[groupId] === 'visible' || groupVisibility[groupId] === 'overflow';\n }\n return {\n groupVisibility: ()=>groupVisibility,\n isSingleItemVisible (itemId, groupId) {\n return isGroupVisible(groupId) && groups[groupId].visibleItemIds.has(itemId) && groups[groupId].visibleItemIds.size === 1;\n },\n addItem (itemId, groupId) {\n var _;\n (_ = (_groups = groups)[_groupId = groupId]) !== null && _ !== void 0 ? _ : _groups[_groupId] = {\n visibleItemIds: new Set(),\n invisibleItemIds: new Set()\n };\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n removeItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n },\n showItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.delete(itemId);\n groups[groupId].visibleItemIds.add(itemId);\n updateGroupVisibility(groupId);\n },\n hideItem (itemId, groupId) {\n groups[groupId].invisibleItemIds.add(itemId);\n groups[groupId].visibleItemIds.delete(itemId);\n updateGroupVisibility(groupId);\n }\n };\n };\n const groupManager = createGroupManager();\n const invisibleItemQueue = createPriorityQueue((a, b)=>{\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const visibleItemQueue = createPriorityQueue((a, b)=>{\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const getOffsetSize = (el)=>{\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n function computeSizeChange(entry) {\n const dividerWidth = entry.groupId && groupManager.isSingleItemVisible(entry.id, entry.groupId) && overflowDividers[entry.groupId] ? getOffsetSize(overflowDividers[entry.groupId].element) : 0;\n return getOffsetSize(entry.element) + dividerWidth;\n }\n const showItem = ()=>{\n const item = getNextItem(invisibleItemQueue, visibleItemQueue);\n options.onUpdateItemVisibility({\n item,\n visible: true\n });\n if (item.groupId) {\n groupManager.showItem(item.id, item.groupId);\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.removeAttribute(DATA_OVERFLOWING);\n }\n }\n return computeSizeChange(item);\n };\n const hideItem = ()=>{\n const item = getNextItem(visibleItemQueue, invisibleItemQueue);\n const width = computeSizeChange(item);\n options.onUpdateItemVisibility({\n item,\n visible: false\n });\n if (item.groupId) {\n if (groupManager.isSingleItemVisible(item.id, item.groupId)) {\n var _overflowDividers_item_groupId;\n (_overflowDividers_item_groupId = overflowDividers[item.groupId]) === null || _overflowDividers_item_groupId === void 0 ? void 0 : _overflowDividers_item_groupId.element.setAttribute(DATA_OVERFLOWING, '');\n }\n groupManager.hideItem(item.id, item.groupId);\n }\n return width;\n };\n const dispatchOverflowUpdate = ()=>{\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n const visibleItems = visibleItemIds.map((itemId)=>overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map((itemId)=>overflowItems[itemId]);\n options.onUpdateOverflow({\n visibleItems,\n invisibleItems,\n groupVisibility: groupManager.groupVisibility()\n });\n };\n const processOverflowItems = ()=>{\n if (!container) {\n return false;\n }\n const totalDividersWidth = Object.values(overflowDividers).map((dvdr)=>dvdr.groupId ? getOffsetSize(dvdr.element) : 0).reduce((prev, current)=>prev + current, 0);\n const availableSize = getOffsetSize(container) - options.padding - totalDividersWidth - (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 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 < availableSize && invisibleItemQueue.size() > 0){\n currentWidth += showItem();\n }\n // Remove items until there's no more overflow\n while(currentWidth > 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","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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AI;QAC3BxG,eAAeS;IACnB;IACA,MAAMgG,gBAAgB,CAAC9E,UAAU;QAC7B,IAAI,CAACf,gBAAgB,CAACe,QAAQ,EAAE;YAC5B;QACJ,CAAC;QACD,MAAM4E,UAAU3F,gBAAgB,CAACe,QAAQ;QACzC,IAAI4E,QAAQ5E,OAAO,EAAE;YACjB,OAAOf,gBAAgB,CAACe,QAAQ;YAChC4E,QAAQ/C,OAAO,CAACc,eAAe,CAAC8B,2BAAmB;QACvD,CAAC;IACL;IACA,MAAM5D,aAAa,CAACN,SAAS;QACzB,IAAI,CAACvB,aAAa,CAACuB,OAAO,EAAE;YACxB;QACJ,CAAC;QACD,MAAMiC,OAAOxD,aAAa,CAACuB,OAAO;QAClCwB,iBAAiBgD,MAAM,CAACxE;QACxBW,mBAAmB6D,MAAM,CAACxE;QAC1B,IAAIiC,KAAKxC,OAAO,EAAE;YACdiB,aAAaJ,UAAU,CAAC2B,KAAKD,EAAE,EAAEC,KAAKxC,OAAO;YAC7CwC,KAAKX,OAAO,CAACc,eAAe,CAAC8B,2BAAmB;QACpD,CAAC;QACD,OAAOzF,aAAa,CAACuB,OAAO;QAC5BlB;IACJ;IACA,OAAO;QACHoB;QACA+D;QACAP;QACAE;QACAtD;QACAxB;QACAqF;QACAG;QACAF;QACAG;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/priority-overflow",
3
- "version": "0.0.0-nightly-20230615-0416.1",
3
+ "version": "0.0.0-nightly-20230619-0417.1",
4
4
  "description": "Vanilla JS utilities to implement overflow menus",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",