@fluentui/priority-overflow 0.0.0-nightly-20230223-2115.1 → 0.0.0-nightly-20230227-0424.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +3 -3
- package/CHANGELOG.md +4 -4
- package/lib/debounce.js +2 -1
- package/lib/debounce.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/overflowManager.js +1 -2
- package/lib/overflowManager.js.map +1 -1
- package/lib/priorityQueue.js +2 -1
- package/lib/priorityQueue.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib-commonjs/debounce.js +21 -22
- package/lib-commonjs/debounce.js.map +1 -1
- package/lib-commonjs/index.js +8 -6
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowManager.js +216 -215
- package/lib-commonjs/overflowManager.js.map +1 -1
- package/lib-commonjs/priorityQueue.js +93 -94
- package/lib-commonjs/priorityQueue.js.map +1 -1
- package/lib-commonjs/types.js +2 -3
- package/lib-commonjs/types.js.map +1 -1
- package/package.json +3 -3
- package/.swcrc +0 -33
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/priority-overflow",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/priority-overflow_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Mon, 27 Feb 2023 04:31:35 GMT",
|
6
|
+
"tag": "@fluentui/priority-overflow_v0.0.0-nightly-20230227-0424.1",
|
7
|
+
"version": "0.0.0-nightly-20230227-0424.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
|
3
|
+
This log was last generated on Mon, 27 Feb 2023 04:31:35 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230227-0424.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v0.0.0-nightly-20230227-0424.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.1..@fluentui/priority-overflow_v0.0.0-nightly-
|
9
|
+
Mon, 27 Feb 2023 04:31:35 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.1..@fluentui/priority-overflow_v0.0.0-nightly-20230227-0424.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
package/lib/debounce.js
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
|
4
4
|
* @param fn - Function to debounce
|
5
5
|
* @returns debounced function
|
6
|
-
*/
|
6
|
+
*/
|
7
|
+
export function debounce(fn) {
|
7
8
|
let pending;
|
8
9
|
return () => {
|
9
10
|
if (!pending) {
|
package/lib/debounce.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA
|
1
|
+
{"version":3,"mappings":"AAAA;;;;;;AAMA,OAAM,SAAUA,QAAQ,CAACC,EAAY;EACnC,IAAIC,OAAgB;EACpB,OAAO,MAAK;IACV,IAAI,CAACA,OAAO,EAAE;MACZA,OAAO,GAAG,IAAI;MACdC,cAAc,CAAC,MAAK;QAClB;QACA;QACAD,OAAO,GAAG,KAAK;QACfD,EAAE,EAAE;MACN,CAAC,CAAC;;EAEN,CAAC;AACH","names":["debounce","fn","pending","queueMicrotask"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/debounce.ts"],"sourcesContent":["/**\n * Microtask debouncer\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide\n * @param fn - Function to debounce\n * @returns debounced function\n */\nexport function debounce(fn: Function) {\n let pending: boolean;\n return () => {\n if (!pending) {\n pending = true;\n queueMicrotask(() => {\n // Need to set pending to `false` before the debounced function is run.\n // React can actually interrupt the function while it's running!\n pending = false;\n fn();\n });\n }\n };\n}\n"]}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC","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"]}
|
package/lib/overflowManager.js
CHANGED
@@ -91,8 +91,7 @@ export function createOverflowManager() {
|
|
91
91
|
const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);
|
92
92
|
const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);
|
93
93
|
const groupVisibility = {};
|
94
|
-
Object.entries(overflowGroups).forEach(
|
95
|
-
let [groupId, groupState] = param;
|
94
|
+
Object.entries(overflowGroups).forEach(([groupId, groupState]) => {
|
96
95
|
if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
|
97
96
|
groupVisibility[groupId] = 'overflow';
|
98
97
|
} else if (groupState.visibleItemIds.size === 0) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,SAASA,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AAGpC;;;;AAIA,OAAO,SAASC,wBAAyC;EACvD,IAAIC;EACJ,IAAIC;EACJ;EACA,IAAIC,YAAY,KAAK;EACrB;EACA,IAAIC,gBAAgB,KAAK;EACzB,MAAMC,UAAoC;IACxCC,SAAS;IACTC,cAAc;IACdC,mBAAmB;IACnBC,gBAAgB;IACh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mD,qBAA4D,MAAM;IACtElF,eAAeS;EACjB;EAEA,MAAM0E,aAA4C9B,UAAU;IAC1D,IAAI,CAAC1C,aAAa,CAAC0C,OAAO,EAAE;MAC1B;IACF;IAEA,MAAMf,OAAO3B,aAAa,CAAC0C,OAAO;IAClCxB,iBAAiBuD,MAAM,CAAC/B;IACxBpC,mBAAmBmE,MAAM,CAAC/B;IAE1B,IAAIf,KAAKE,OAAO,EAAE;MAChB5B,cAAc,CAAC0B,KAAKE,OAAO,CAAC,CAACI,cAAc,CAACF,MAAM,CAACJ,KAAKK,EAAE;MAC1D/B,cAAc,CAAC0B,KAAKE,OAAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,KAAKK,EAAE;IAC9D;IAEA,OAAOhC,aAAa,CAAC0C,OAAO;IAC5BrC;EACF;EAEA,OAAO;IACL+D;IACAD;IACAN;IACAC;IACAU;IACAnE;IACAiE;IACAC;EACF;AACF","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","param","groupState","size","processOverflowItems","availableSize","overflowMenuOffset","visibleTop","peek","invisibleTop","currentWidth","reduce","sum","visibleItemId","child","forceUpdate","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove"],"sources":["../src/overflowManager.ts"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\nimport type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n let forceDispatch = false;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowGroups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const visibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const getOffsetSize = (el: HTMLElement) => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n\n const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({ item, visible: true });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n return getOffsetSize(item.element);\n };\n\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({ item, visible: false });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\n }\n\n return width;\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n const groupVisibility: Record<string, OverflowGroupState> = {};\n Object.entries(overflowGroups).forEach(([groupId, groupState]) => {\n if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (groupState.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n });\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n const visibleItemIds = visibleItemQueue.all();\n let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {\n const child = overflowItems[visibleItemId].element;\n return sum + getOffsetSize(child);\n }, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > availableSize && visibleItemQueue.size() > 0) {\n if (visibleItemQueue.size() <= options.minimumVisible) {\n break;\n }\n currentWidth -= makeItemInvisible();\n }\n\n // make sure the overflow menu can fit\n if (\n visibleItemQueue.size() > options.minimumVisible &&\n invisibleItemQueue.size() > 0 &&\n currentWidth + overflowMenuOffset > availableSize\n ) {\n makeItemInvisible();\n }\n\n // only update when the state of visible/invisible items has changed\n if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {\n return true;\n }\n\n return false;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n resizeObserver.disconnect();\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n }\n\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n }\n\n delete overflowItems[itemId];\n update();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n };\n}\n"]}
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAASC,mBAAmB,QAAQ,iBAAiB;AAGrD;;;;AAIA,OAAM,SAAUC,qBAAqB;EACnC,IAAIC,SAAkC;EACtC,IAAIC,YAAqC;EACzC;EACA,IAAIC,SAAS,GAAG,KAAK;EACrB;EACA,IAAIC,aAAa,GAAG,KAAK;EACzB,MAAMC,OAAO,GAA6B;IACxCC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,YAAY;IAC1BC,iBAAiB,EAAE,KAAK;IACxBC,cAAc,EAAE,CAAC;IACjBC,sBAAsB,EAAE,MAAMC,SAAS;IACvCC,gBAAgB,EAAE,MAAMD;GACzB;EAED,MAAME,aAAa,GAAsC,EAAE;EAC3D,MAAMC,cAAc,GAAmF,EAAE;EACzG,MAAMC,cAAc,GAAG,IAAIC,cAAc,CAACC,OAAO,IAAG;IAClD,IAAI,CAACA,OAAO,CAAC,CAAC,CAAC,IAAI,CAAChB,SAAS,EAAE;MAC7B;;IAGFiB,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,MAAMC,kBAAkB,GAAGpB,mBAAmB,CAAS,CAACqB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D,EAAE,IAAG;IAC/D/B,YAAY,GAAG+B,EAAE;EACnB,CAAC;EAED,MAAMkD,kBAAkB,GAA0C,MAAK;IACrEjF,YAAY,GAAGS,SAAS;EAC1B,CAAC;EAED,MAAMyE,UAAU,GAAkC7B,MAAM,IAAG;IACzD,IAAI,CAAC1C,aAAa,CAAC0C,MAAM,CAAC,EAAE;MAC1B;;IAGF,MAAMf,IAAI,GAAG3B,aAAa,CAAC0C,MAAM,CAAC;IAClCxB,gBAAgB,CAACsD,MAAM,CAAC9B,MAAM,CAAC;IAC/BpC,kBAAkB,CAACkE,MAAM,CAAC9B,MAAM,CAAC;IAEjC,IAAIf,IAAI,CAACE,OAAO,EAAE;MAChB5B,cAAc,CAAC0B,IAAI,CAACE,OAAO,CAAC,CAACI,cAAc,CAACF,MAAM,CAACJ,IAAI,CAACK,EAAE,CAAC;MAC3D/B,cAAc,CAAC0B,IAAI,CAACE,OAAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,IAAI,CAACK,EAAE,CAAC;;IAG/D,OAAOhC,aAAa,CAAC0C,MAAM,CAAC;IAC5BrC,MAAM,EAAE;EACV,CAAC;EAED,OAAO;IACL8D,OAAO;IACPD,UAAU;IACVN,WAAW;IACXC,OAAO;IACPU,UAAU;IACVlE,MAAM;IACNgE,eAAe;IACfC;GACD;AACH","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"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/overflowManager.ts"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\nimport type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n let forceDispatch = false;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowGroups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const visibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const getOffsetSize = (el: HTMLElement) => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n\n const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({ item, visible: true });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n return getOffsetSize(item.element);\n };\n\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({ item, visible: false });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\n }\n\n return width;\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n const groupVisibility: Record<string, OverflowGroupState> = {};\n Object.entries(overflowGroups).forEach(([groupId, groupState]) => {\n if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (groupState.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n });\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n const visibleItemIds = visibleItemQueue.all();\n let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {\n const child = overflowItems[visibleItemId].element;\n return sum + getOffsetSize(child);\n }, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > availableSize && visibleItemQueue.size() > 0) {\n if (visibleItemQueue.size() <= options.minimumVisible) {\n break;\n }\n currentWidth -= makeItemInvisible();\n }\n\n // make sure the overflow menu can fit\n if (\n visibleItemQueue.size() > options.minimumVisible &&\n invisibleItemQueue.size() > 0 &&\n currentWidth + overflowMenuOffset > availableSize\n ) {\n makeItemInvisible();\n }\n\n // only update when the state of visible/invisible items has changed\n if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {\n return true;\n }\n\n return false;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n resizeObserver.disconnect();\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n }\n\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n }\n\n delete overflowItems[itemId];\n update();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n };\n}\n"]}
|
package/lib/priorityQueue.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
/**
|
2
2
|
* @param compare - comparison function for items
|
3
3
|
* @returns Priority queue implemented with a min heap
|
4
|
-
*/
|
4
|
+
*/
|
5
|
+
export function createPriorityQueue(compare) {
|
5
6
|
const arr = [];
|
6
7
|
let size = 0;
|
7
8
|
const left = i => {
|
package/lib/priorityQueue.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAaA
|
1
|
+
{"version":3,"mappings":"AAaA;;;;AAIA,OAAM,SAAUA,mBAAmB,CAAIC,OAAkC;EACvE,MAAMC,GAAG,GAAQ,EAAE;EACnB,IAAIC,IAAI,GAAG,CAAC;EAE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CAAC,EAAEC,IAAI,CAAC;IACpBW,OAAO,CAACT,CAAC,CAAC;EACZ,CAAC;EAED,MAAMwB,KAAK,GAAG,MAAK;IACjB1B,IAAI,GAAG,CAAC;EACV,CAAC;EAED,MAAM2B,GAAG,GAAG,MAAK;IACf,OAAO5B,GAAG,CAAC6B,KAAK,CAAC,CAAC,EAAE5B,IAAI,CAAC;EAC3B,CAAC;EAED,OAAO;IACL2B,GAAG;IACHD,KAAK;IACLJ,QAAQ;IACRP,OAAO;IACPI,OAAO;IACPD,IAAI;IACJO,MAAM;IACNzB,IAAI,EAAE,MAAMA;GACb;AACH","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"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/priorityQueue.ts"],"sourcesContent":["export type PriorityQueueCompareFn<T> = (a: T, b: T) => number;\n\nexport interface PriorityQueue<T> {\n all: () => T[];\n clear: () => void;\n contains: (item: T) => boolean;\n dequeue: () => T;\n enqueue: (item: T) => void;\n peek: () => T | null;\n remove: (item: T) => void;\n size: () => number;\n}\n\n/**\n * @param compare - comparison function for items\n * @returns Priority queue implemented with a min heap\n */\nexport function createPriorityQueue<T>(compare: PriorityQueueCompareFn<T>): PriorityQueue<T> {\n const arr: T[] = [];\n let size = 0;\n\n const left = (i: number) => {\n return 2 * i + 1;\n };\n\n const right = (i: number) => {\n return 2 * i + 2;\n };\n\n const parent = (i: number) => {\n return Math.floor((i - 1) / 2);\n };\n\n const swap = (a: number, b: number) => {\n const tmp = arr[a];\n arr[a] = arr[b];\n arr[b] = tmp;\n };\n\n const heapify = (i: number) => {\n let smallest = i;\n const l = left(i);\n const r = right(i);\n\n if (l < size && compare(arr[l], arr[smallest]) < 0) {\n smallest = l;\n }\n\n if (r < size && compare(arr[r], arr[smallest]) < 0) {\n smallest = r;\n }\n\n if (smallest !== i) {\n swap(smallest, i);\n heapify(smallest);\n }\n };\n\n const dequeue = () => {\n if (size === 0) {\n throw new Error('Priority queue empty');\n }\n\n const res = arr[0];\n arr[0] = arr[--size];\n heapify(0);\n\n return res;\n };\n\n const peek = () => {\n if (size === 0) {\n return null;\n }\n\n return arr[0];\n };\n\n const enqueue = (item: T) => {\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\n const contains = (item: T) => {\n const index = arr.indexOf(item);\n return index >= 0 && index < size;\n };\n\n const remove = (item: T) => {\n const i = arr.indexOf(item);\n\n if (i === -1 || i >= size) {\n return;\n }\n\n arr[i] = arr[--size];\n heapify(i);\n };\n\n const clear = () => {\n size = 0;\n };\n\n const all = () => {\n return arr.slice(0, size);\n };\n\n return {\n all,\n clear,\n contains,\n dequeue,\n enqueue,\n peek,\n remove,\n size: () => size,\n };\n}\n"]}
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/types.ts"],"names":[],"mappings":"","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"]}
|
package/lib-commonjs/debounce.js
CHANGED
@@ -1,29 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.debounce = void 0;
|
1
7
|
/**
|
2
8
|
* Microtask debouncer
|
3
9
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
|
4
10
|
* @param fn - Function to debounce
|
5
11
|
* @returns debounced function
|
6
|
-
*/
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
8
|
-
value: true
|
9
|
-
});
|
10
|
-
Object.defineProperty(exports, "debounce", {
|
11
|
-
enumerable: true,
|
12
|
-
get: ()=>debounce
|
13
|
-
});
|
12
|
+
*/
|
14
13
|
function debounce(fn) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
|
14
|
+
let pending;
|
15
|
+
return () => {
|
16
|
+
if (!pending) {
|
17
|
+
pending = true;
|
18
|
+
queueMicrotask(() => {
|
19
|
+
// Need to set pending to `false` before the debounced function is run.
|
20
|
+
// React can actually interrupt the function while it's running!
|
21
|
+
pending = false;
|
22
|
+
fn();
|
23
|
+
});
|
24
|
+
}
|
25
|
+
};
|
26
|
+
}
|
27
|
+
exports.debounce = debounce;
|
29
28
|
//# sourceMappingURL=debounce.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;;AAMA,SAAgBA,QAAQ,CAACC,EAAY;EACnC,IAAIC,OAAgB;EACpB,OAAO,MAAK;IACV,IAAI,CAACA,OAAO,EAAE;MACZA,OAAO,GAAG,IAAI;MACdC,cAAc,CAAC,MAAK;QAClB;QACA;QACAD,OAAO,GAAG,KAAK;QACfD,EAAE,EAAE;MACN,CAAC,CAAC;;EAEN,CAAC;AACH;AAbAG","names":["debounce","fn","pending","queueMicrotask","exports"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/debounce.ts"],"sourcesContent":["/**\n * Microtask debouncer\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide\n * @param fn - Function to debounce\n * @returns debounced function\n */\nexport function debounce(fn: Function) {\n let pending: boolean;\n return () => {\n if (!pending) {\n pending = true;\n queueMicrotask(() => {\n // Need to set pending to `false` before the debounced function is run.\n // React can actually interrupt the function while it's running!\n pending = false;\n fn();\n });\n }\n };\n}\n"]}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
6
|
+
exports.createOverflowManager = void 0;
|
7
|
+
var overflowManager_1 = /*#__PURE__*/require("./overflowManager");
|
5
8
|
Object.defineProperty(exports, "createOverflowManager", {
|
6
|
-
|
7
|
-
|
9
|
+
enumerable: true,
|
10
|
+
get: function () {
|
11
|
+
return overflowManager_1.createOverflowManager;
|
12
|
+
}
|
8
13
|
});
|
9
|
-
const _overflowManager = require("./overflowManager");
|
10
|
-
//# sourceMappingURL=index.js.map
|
11
|
-
|
12
14
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,8CAAqB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/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"]}
|
@@ -1,223 +1,224 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "createOverflowManager", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>createOverflowManager
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
6
|
+
exports.createOverflowManager = void 0;
|
7
|
+
const debounce_1 = /*#__PURE__*/require("./debounce");
|
8
|
+
const priorityQueue_1 = /*#__PURE__*/require("./priorityQueue");
|
9
|
+
/**
|
10
|
+
* @internal
|
11
|
+
* @returns overflow manager instance
|
12
|
+
*/
|
11
13
|
function createOverflowManager() {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
let container;
|
15
|
+
let overflowMenu;
|
16
|
+
// Set as true when resize observer is observing
|
17
|
+
let observing = false;
|
18
|
+
// If true, next update will dispatch to onUpdateOverflow even if queue top states don't change
|
19
|
+
let forceDispatch = false;
|
20
|
+
const options = {
|
21
|
+
padding: 10,
|
22
|
+
overflowAxis: 'horizontal',
|
23
|
+
overflowDirection: 'end',
|
24
|
+
minimumVisible: 0,
|
25
|
+
onUpdateItemVisibility: () => undefined,
|
26
|
+
onUpdateOverflow: () => undefined
|
27
|
+
};
|
28
|
+
const overflowItems = {};
|
29
|
+
const overflowGroups = {};
|
30
|
+
const resizeObserver = new ResizeObserver(entries => {
|
31
|
+
if (!entries[0] || !container) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
update();
|
35
|
+
});
|
36
|
+
const invisibleItemQueue = priorityQueue_1.createPriorityQueue((a, b) => {
|
37
|
+
const itemA = overflowItems[a];
|
38
|
+
const itemB = overflowItems[b];
|
39
|
+
// Higher priority at the top of the queue
|
40
|
+
const priority = itemB.priority - itemA.priority;
|
41
|
+
if (priority !== 0) {
|
42
|
+
return priority;
|
43
|
+
}
|
44
|
+
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
45
|
+
// equal priority, use DOM order
|
46
|
+
// eslint-disable-next-line no-bitwise
|
47
|
+
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
48
|
+
});
|
49
|
+
const visibleItemQueue = priorityQueue_1.createPriorityQueue((a, b) => {
|
50
|
+
const itemA = overflowItems[a];
|
51
|
+
const itemB = overflowItems[b];
|
52
|
+
// Lower priority at the top of the queue
|
53
|
+
const priority = itemA.priority - itemB.priority;
|
54
|
+
if (priority !== 0) {
|
55
|
+
return priority;
|
56
|
+
}
|
57
|
+
const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
|
58
|
+
// equal priority, use DOM order
|
59
|
+
// eslint-disable-next-line no-bitwise
|
60
|
+
return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;
|
61
|
+
});
|
62
|
+
const getOffsetSize = el => {
|
63
|
+
return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;
|
64
|
+
};
|
65
|
+
const makeItemVisible = () => {
|
66
|
+
const nextVisible = invisibleItemQueue.dequeue();
|
67
|
+
visibleItemQueue.enqueue(nextVisible);
|
68
|
+
const item = overflowItems[nextVisible];
|
69
|
+
options.onUpdateItemVisibility({
|
70
|
+
item,
|
71
|
+
visible: true
|
33
72
|
});
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
73
|
+
if (item.groupId) {
|
74
|
+
overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
|
75
|
+
overflowGroups[item.groupId].visibleItemIds.add(item.id);
|
76
|
+
}
|
77
|
+
return getOffsetSize(item.element);
|
78
|
+
};
|
79
|
+
const makeItemInvisible = () => {
|
80
|
+
const nextInvisible = visibleItemQueue.dequeue();
|
81
|
+
invisibleItemQueue.enqueue(nextInvisible);
|
82
|
+
const item = overflowItems[nextInvisible];
|
83
|
+
const width = getOffsetSize(item.element);
|
84
|
+
options.onUpdateItemVisibility({
|
85
|
+
item,
|
86
|
+
visible: false
|
46
87
|
});
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
88
|
+
if (item.groupId) {
|
89
|
+
overflowGroups[item.groupId].visibleItemIds.delete(item.id);
|
90
|
+
overflowGroups[item.groupId].invisibleItemIds.add(item.id);
|
91
|
+
}
|
92
|
+
return width;
|
93
|
+
};
|
94
|
+
const dispatchOverflowUpdate = () => {
|
95
|
+
const visibleItemIds = visibleItemQueue.all();
|
96
|
+
const invisibleItemIds = invisibleItemQueue.all();
|
97
|
+
const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);
|
98
|
+
const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);
|
99
|
+
const groupVisibility = {};
|
100
|
+
Object.entries(overflowGroups).forEach(([groupId, groupState]) => {
|
101
|
+
if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {
|
102
|
+
groupVisibility[groupId] = 'overflow';
|
103
|
+
} else if (groupState.visibleItemIds.size === 0) {
|
104
|
+
groupVisibility[groupId] = 'hidden';
|
105
|
+
} else {
|
106
|
+
groupVisibility[groupId] = 'visible';
|
107
|
+
}
|
59
108
|
});
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
// i.e. new element is enqueued but the top of the queue stays the same
|
176
|
-
// force a dispatch on the next batched update
|
177
|
-
forceDispatch = true;
|
178
|
-
visibleItemQueue.enqueue(item.id);
|
179
|
-
}
|
180
|
-
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);
|
188
|
-
}
|
189
|
-
update();
|
190
|
-
};
|
191
|
-
const addOverflowMenu = (el)=>{
|
192
|
-
overflowMenu = el;
|
193
|
-
};
|
194
|
-
const removeOverflowMenu = ()=>{
|
195
|
-
overflowMenu = undefined;
|
196
|
-
};
|
197
|
-
const removeItem = (itemId)=>{
|
198
|
-
if (!overflowItems[itemId]) {
|
199
|
-
return;
|
200
|
-
}
|
201
|
-
const item = overflowItems[itemId];
|
202
|
-
visibleItemQueue.remove(itemId);
|
203
|
-
invisibleItemQueue.remove(itemId);
|
204
|
-
if (item.groupId) {
|
205
|
-
overflowGroups[item.groupId].visibleItemIds.delete(item.id);
|
206
|
-
overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
|
207
|
-
}
|
208
|
-
delete overflowItems[itemId];
|
209
|
-
update();
|
210
|
-
};
|
211
|
-
return {
|
212
|
-
addItem,
|
213
|
-
disconnect,
|
214
|
-
forceUpdate,
|
215
|
-
observe,
|
216
|
-
removeItem,
|
217
|
-
update,
|
218
|
-
addOverflowMenu,
|
219
|
-
removeOverflowMenu
|
220
|
-
};
|
221
|
-
} //# sourceMappingURL=overflowManager.js.map
|
222
|
-
|
109
|
+
options.onUpdateOverflow({
|
110
|
+
visibleItems,
|
111
|
+
invisibleItems,
|
112
|
+
groupVisibility
|
113
|
+
});
|
114
|
+
};
|
115
|
+
const processOverflowItems = () => {
|
116
|
+
if (!container) {
|
117
|
+
return false;
|
118
|
+
}
|
119
|
+
const availableSize = getOffsetSize(container) - options.padding;
|
120
|
+
const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
|
121
|
+
// Snapshot of the visible/invisible state to compare for updates
|
122
|
+
const visibleTop = visibleItemQueue.peek();
|
123
|
+
const invisibleTop = invisibleItemQueue.peek();
|
124
|
+
const visibleItemIds = visibleItemQueue.all();
|
125
|
+
let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {
|
126
|
+
const child = overflowItems[visibleItemId].element;
|
127
|
+
return sum + getOffsetSize(child);
|
128
|
+
}, 0);
|
129
|
+
// Add items until available width is filled - can result in overflow
|
130
|
+
while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {
|
131
|
+
currentWidth += makeItemVisible();
|
132
|
+
}
|
133
|
+
// Remove items until there's no more overflow
|
134
|
+
while (currentWidth > availableSize && visibleItemQueue.size() > 0) {
|
135
|
+
if (visibleItemQueue.size() <= options.minimumVisible) {
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
currentWidth -= makeItemInvisible();
|
139
|
+
}
|
140
|
+
// make sure the overflow menu can fit
|
141
|
+
if (visibleItemQueue.size() > options.minimumVisible && invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) {
|
142
|
+
makeItemInvisible();
|
143
|
+
}
|
144
|
+
// only update when the state of visible/invisible items has changed
|
145
|
+
if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {
|
146
|
+
return true;
|
147
|
+
}
|
148
|
+
return false;
|
149
|
+
};
|
150
|
+
const forceUpdate = () => {
|
151
|
+
if (processOverflowItems() || forceDispatch) {
|
152
|
+
forceDispatch = false;
|
153
|
+
dispatchOverflowUpdate();
|
154
|
+
}
|
155
|
+
};
|
156
|
+
const update = debounce_1.debounce(forceUpdate);
|
157
|
+
const observe = (observedContainer, userOptions) => {
|
158
|
+
Object.assign(options, userOptions);
|
159
|
+
observing = true;
|
160
|
+
Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));
|
161
|
+
container = observedContainer;
|
162
|
+
resizeObserver.observe(container);
|
163
|
+
};
|
164
|
+
const disconnect = () => {
|
165
|
+
observing = false;
|
166
|
+
resizeObserver.disconnect();
|
167
|
+
};
|
168
|
+
const addItem = item => {
|
169
|
+
if (overflowItems[item.id]) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
overflowItems[item.id] = item;
|
173
|
+
// some options can affect priority which are only set on `observe`
|
174
|
+
if (observing) {
|
175
|
+
// Updates to elements might not change the queue tops
|
176
|
+
// i.e. new element is enqueued but the top of the queue stays the same
|
177
|
+
// force a dispatch on the next batched update
|
178
|
+
forceDispatch = true;
|
179
|
+
visibleItemQueue.enqueue(item.id);
|
180
|
+
}
|
181
|
+
if (item.groupId) {
|
182
|
+
if (!overflowGroups[item.groupId]) {
|
183
|
+
overflowGroups[item.groupId] = {
|
184
|
+
visibleItemIds: new Set(),
|
185
|
+
invisibleItemIds: new Set()
|
186
|
+
};
|
187
|
+
}
|
188
|
+
overflowGroups[item.groupId].visibleItemIds.add(item.id);
|
189
|
+
}
|
190
|
+
update();
|
191
|
+
};
|
192
|
+
const addOverflowMenu = el => {
|
193
|
+
overflowMenu = el;
|
194
|
+
};
|
195
|
+
const removeOverflowMenu = () => {
|
196
|
+
overflowMenu = undefined;
|
197
|
+
};
|
198
|
+
const removeItem = itemId => {
|
199
|
+
if (!overflowItems[itemId]) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
const item = overflowItems[itemId];
|
203
|
+
visibleItemQueue.remove(itemId);
|
204
|
+
invisibleItemQueue.remove(itemId);
|
205
|
+
if (item.groupId) {
|
206
|
+
overflowGroups[item.groupId].visibleItemIds.delete(item.id);
|
207
|
+
overflowGroups[item.groupId].invisibleItemIds.delete(item.id);
|
208
|
+
}
|
209
|
+
delete overflowItems[itemId];
|
210
|
+
update();
|
211
|
+
};
|
212
|
+
return {
|
213
|
+
addItem,
|
214
|
+
disconnect,
|
215
|
+
forceUpdate,
|
216
|
+
observe,
|
217
|
+
removeItem,
|
218
|
+
update,
|
219
|
+
addOverflowMenu,
|
220
|
+
removeOverflowMenu
|
221
|
+
};
|
222
|
+
}
|
223
|
+
exports.createOverflowManager = createOverflowManager;
|
223
224
|
//# sourceMappingURL=overflowManager.js.map
|
@@ -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 let forceDispatch = false;\n const options = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined\n };\n const overflowItems = {};\n const overflowGroups = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n update();\n });\n const invisibleItemQueue = createPriorityQueue((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const visibleItemQueue = createPriorityQueue((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n if (priority !== 0) {\n return priority;\n }\n const positionStatusBit = options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n const getOffsetSize = el => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({\n item,\n visible: true\n });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n return getOffsetSize(item.element);\n };\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({\n item,\n visible: false\n });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\n }\n return width;\n };\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n const groupVisibility = {};\n Object.entries(overflowGroups).forEach(param => {\n let [groupId, groupState] = param;\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","param","groupState","size","processOverflowItems","availableSize","overflowMenuOffset","visibleTop","peek","invisibleTop","currentWidth","reduce","sum","visibleItemId","child","forceUpdate","debounce","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove"],"mappings":";;;;+BAMgBA;;aAAAA;;0BANS;+BACW;AAK7B,SAASA,wBAAwB;IACtC,IAAIC;IACJ,IAAIC;IACJ,gDAAgD;IAChD,IAAIC,YAAY,KAAK;IACrB,+FAA+F;IAC/F,IAAIC,gBAAgB,KAAK;IACzB,MAAMC,UAAU;QACdC,SAAS;QACTC,cAAc;QACdC,mBAAmB;QACnBC,gBAAgB;QAChBC,wBAAwB,IAAMC;QAC9BC,kBAAkB,IAAMD;IAC1B;IACA,MAAME,gBAAgB,CAAC;IACvB,MAAMC,iBAAiB,CAAC;IACxB,MAAMC,iBAAiB,IAAIC,eAAeC,CAAAA,UAAW;QACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,WAAW;YAC7B;QACF,CAAC;QACDiB;IACF;IACA,MAAMC,qBAAqBC,IAAAA,kCAAmB,EAAC,CAACC,GAAGC,IAAM;QACvD,MAAMC,QAAQV,aAAa,CAACQ,EAAE;QAC9B,MAAMG,QAAQX,aAAa,CAACS,EAAE;QAC9B,0CAA0C;QAC1C,MAAMG,WAAWD,MAAMC,QAAQ,GAAGF,MAAME,QAAQ;QAChD,IAAIA,aAAa,GAAG;YAClB,OAAOA;QACT,CAAC;QACD,MAAMC,oBAAoBrB,QAAQG,iBAAiB,KAAK,QAAQm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2C,MAAM,CAAC,EAAE;MAC1B;;IAGF,MAAMf,IAAI,GAAG5B,aAAa,CAAC2C,MAAM,CAAC;IAClCxB,gBAAgB,CAACuD,MAAM,CAAC/B,MAAM,CAAC;IAC/BrC,kBAAkB,CAACoE,MAAM,CAAC/B,MAAM,CAAC;IAEjC,IAAIf,IAAI,CAACE,OAAO,EAAE;MAChB7B,cAAc,CAAC2B,IAAI,CAACE,OAAO,CAAC,CAACI,cAAc,CAACF,MAAM,CAACJ,IAAI,CAACK,EAAE,CAAC;MAC3DhC,cAAc,CAAC2B,IAAI,CAACE,OAAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,IAAI,CAACK,EAAE,CAAC;;IAG/D,OAAOjC,aAAa,CAAC2C,MAAM,CAAC;IAC5BtC,MAAM,EAAE;EACV,CAAC;EAED,OAAO;IACLgE,OAAO;IACPD,UAAU;IACVP,WAAW;IACXE,OAAO;IACPU,UAAU;IACVpE,MAAM;IACNkE,eAAe;IACfC;GACD;AACH;AA5PAG","names":["createOverflowManager","container","overflowMenu","observing","forceDispatch","options","padding","overflowAxis","overflowDirection","minimumVisible","onUpdateItemVisibility","undefined","onUpdateOverflow","overflowItems","overflowGroups","resizeObserver","ResizeObserver","entries","update","invisibleItemQueue","priorityQueue_1","a","b","itemA","itemB","priority","positionStatusBit","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","element","compareDocumentPosition","visibleItemQueue","getOffsetSize","el","offsetWidth","offsetHeight","makeItemVisible","nextVisible","dequeue","enqueue","item","visible","groupId","invisibleItemIds","delete","id","visibleItemIds","add","makeItemInvisible","nextInvisible","width","dispatchOverflowUpdate","all","visibleItems","map","itemId","invisibleItems","groupVisibility","Object","forEach","groupState","size","processOverflowItems","availableSize","overflowMenuOffset","visibleTop","peek","invisibleTop","currentWidth","reduce","sum","visibleItemId","child","forceUpdate","debounce_1","observe","observedContainer","userOptions","assign","values","disconnect","addItem","Set","addOverflowMenu","removeOverflowMenu","removeItem","remove","exports"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/overflowManager.ts"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\nimport type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n // Set as true when resize observer is observing\n let observing = false;\n // If true, next update will dispatch to onUpdateOverflow even if queue top states don't change\n let forceDispatch = false;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowGroups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const visibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const getOffsetSize = (el: HTMLElement) => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n\n const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({ item, visible: true });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n return getOffsetSize(item.element);\n };\n\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({ item, visible: false });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\n }\n\n return width;\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n const groupVisibility: Record<string, OverflowGroupState> = {};\n Object.entries(overflowGroups).forEach(([groupId, groupState]) => {\n if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (groupState.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n });\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility });\n };\n\n const processOverflowItems = (): boolean => {\n if (!container) {\n return false;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n const visibleItemIds = visibleItemQueue.all();\n let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {\n const child = overflowItems[visibleItemId].element;\n return sum + getOffsetSize(child);\n }, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > availableSize && visibleItemQueue.size() > 0) {\n if (visibleItemQueue.size() <= options.minimumVisible) {\n break;\n }\n currentWidth -= makeItemInvisible();\n }\n\n // make sure the overflow menu can fit\n if (\n visibleItemQueue.size() > options.minimumVisible &&\n invisibleItemQueue.size() > 0 &&\n currentWidth + overflowMenuOffset > availableSize\n ) {\n makeItemInvisible();\n }\n\n // only update when the state of visible/invisible items has changed\n if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {\n return true;\n }\n\n return false;\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (processOverflowItems() || forceDispatch) {\n forceDispatch = false;\n dispatchOverflowUpdate();\n }\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n resizeObserver.disconnect();\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n // Updates to elements might not change the queue tops\n // i.e. new element is enqueued but the top of the queue stays the same\n // force a dispatch on the next batched update\n forceDispatch = true;\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n }\n\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n }\n\n delete overflowItems[itemId];\n update();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n };\n}\n"]}
|
@@ -1,99 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createPriorityQueue = void 0;
|
1
7
|
/**
|
2
8
|
* @param compare - comparison function for items
|
3
9
|
* @returns Priority queue implemented with a min heap
|
4
|
-
*/
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
Object.defineProperty(exports, "createPriorityQueue", {
|
9
|
-
enumerable: true,
|
10
|
-
get: ()=>createPriorityQueue
|
11
|
-
});
|
10
|
+
*/
|
12
11
|
function createPriorityQueue(compare) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
|
12
|
+
const arr = [];
|
13
|
+
let size = 0;
|
14
|
+
const left = i => {
|
15
|
+
return 2 * i + 1;
|
16
|
+
};
|
17
|
+
const right = i => {
|
18
|
+
return 2 * i + 2;
|
19
|
+
};
|
20
|
+
const parent = i => {
|
21
|
+
return Math.floor((i - 1) / 2);
|
22
|
+
};
|
23
|
+
const swap = (a, b) => {
|
24
|
+
const tmp = arr[a];
|
25
|
+
arr[a] = arr[b];
|
26
|
+
arr[b] = tmp;
|
27
|
+
};
|
28
|
+
const heapify = i => {
|
29
|
+
let smallest = i;
|
30
|
+
const l = left(i);
|
31
|
+
const r = right(i);
|
32
|
+
if (l < size && compare(arr[l], arr[smallest]) < 0) {
|
33
|
+
smallest = l;
|
34
|
+
}
|
35
|
+
if (r < size && compare(arr[r], arr[smallest]) < 0) {
|
36
|
+
smallest = r;
|
37
|
+
}
|
38
|
+
if (smallest !== i) {
|
39
|
+
swap(smallest, i);
|
40
|
+
heapify(smallest);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const dequeue = () => {
|
44
|
+
if (size === 0) {
|
45
|
+
throw new Error('Priority queue empty');
|
46
|
+
}
|
47
|
+
const res = arr[0];
|
48
|
+
arr[0] = arr[--size];
|
49
|
+
heapify(0);
|
50
|
+
return res;
|
51
|
+
};
|
52
|
+
const peek = () => {
|
53
|
+
if (size === 0) {
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
return arr[0];
|
57
|
+
};
|
58
|
+
const enqueue = item => {
|
59
|
+
arr[size++] = item;
|
60
|
+
let i = size - 1;
|
61
|
+
let p = parent(i);
|
62
|
+
while (i > 0 && compare(arr[p], arr[i]) > 0) {
|
63
|
+
swap(p, i);
|
64
|
+
i = p;
|
65
|
+
p = parent(i);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
const contains = item => {
|
69
|
+
const index = arr.indexOf(item);
|
70
|
+
return index >= 0 && index < size;
|
71
|
+
};
|
72
|
+
const remove = item => {
|
73
|
+
const i = arr.indexOf(item);
|
74
|
+
if (i === -1 || i >= size) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
arr[i] = arr[--size];
|
78
|
+
heapify(i);
|
79
|
+
};
|
80
|
+
const clear = () => {
|
81
|
+
size = 0;
|
82
|
+
};
|
83
|
+
const all = () => {
|
84
|
+
return arr.slice(0, size);
|
85
|
+
};
|
86
|
+
return {
|
87
|
+
all,
|
88
|
+
clear,
|
89
|
+
contains,
|
90
|
+
dequeue,
|
91
|
+
enqueue,
|
92
|
+
peek,
|
93
|
+
remove,
|
94
|
+
size: () => size
|
95
|
+
};
|
96
|
+
}
|
97
|
+
exports.createPriorityQueue = createPriorityQueue;
|
99
98
|
//# sourceMappingURL=priorityQueue.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAaA;;;;AAIA,SAAgBA,mBAAmB,CAAIC,OAAkC;EACvE,MAAMC,GAAG,GAAQ,EAAE;EACnB,IAAIC,IAAI,GAAG,CA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,GAAG,CAAC,EAAEC,IAAI,CAAC;IACpBW,OAAO,CAACT,CAAC,CAAC;EACZ,CAAC;EAED,MAAMwB,KAAK,GAAG,MAAK;IACjB1B,IAAI,GAAG,CAAC;EACV,CAAC;EAED,MAAM2B,GAAG,GAAG,MAAK;IACf,OAAO5B,GAAG,CAAC6B,KAAK,CAAC,CAAC,EAAE5B,IAAI,CAAC;EAC3B,CAAC;EAED,OAAO;IACL2B,GAAG;IACHD,KAAK;IACLJ,QAAQ;IACRP,OAAO;IACPI,OAAO;IACPD,IAAI;IACJO,MAAM;IACNzB,IAAI,EAAE,MAAMA;GACb;AACH;AA1GA6B","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","exports"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/priorityQueue.ts"],"sourcesContent":["export type PriorityQueueCompareFn<T> = (a: T, b: T) => number;\n\nexport interface PriorityQueue<T> {\n all: () => T[];\n clear: () => void;\n contains: (item: T) => boolean;\n dequeue: () => T;\n enqueue: (item: T) => void;\n peek: () => T | null;\n remove: (item: T) => void;\n size: () => number;\n}\n\n/**\n * @param compare - comparison function for items\n * @returns Priority queue implemented with a min heap\n */\nexport function createPriorityQueue<T>(compare: PriorityQueueCompareFn<T>): PriorityQueue<T> {\n const arr: T[] = [];\n let size = 0;\n\n const left = (i: number) => {\n return 2 * i + 1;\n };\n\n const right = (i: number) => {\n return 2 * i + 2;\n };\n\n const parent = (i: number) => {\n return Math.floor((i - 1) / 2);\n };\n\n const swap = (a: number, b: number) => {\n const tmp = arr[a];\n arr[a] = arr[b];\n arr[b] = tmp;\n };\n\n const heapify = (i: number) => {\n let smallest = i;\n const l = left(i);\n const r = right(i);\n\n if (l < size && compare(arr[l], arr[smallest]) < 0) {\n smallest = l;\n }\n\n if (r < size && compare(arr[r], arr[smallest]) < 0) {\n smallest = r;\n }\n\n if (smallest !== i) {\n swap(smallest, i);\n heapify(smallest);\n }\n };\n\n const dequeue = () => {\n if (size === 0) {\n throw new Error('Priority queue empty');\n }\n\n const res = arr[0];\n arr[0] = arr[--size];\n heapify(0);\n\n return res;\n };\n\n const peek = () => {\n if (size === 0) {\n return null;\n }\n\n return arr[0];\n };\n\n const enqueue = (item: T) => {\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\n const contains = (item: T) => {\n const index = arr.indexOf(item);\n return index >= 0 && index < size;\n };\n\n const remove = (item: T) => {\n const i = arr.indexOf(item);\n\n if (i === -1 || i >= size) {\n return;\n }\n\n arr[i] = arr[--size];\n heapify(i);\n };\n\n const clear = () => {\n size = 0;\n };\n\n const all = () => {\n return arr.slice(0, size);\n };\n\n return {\n all,\n clear,\n contains,\n dequeue,\n enqueue,\n peek,\n remove,\n size: () => size,\n };\n}\n"]}
|
package/lib-commonjs/types.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/priority-overflow",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20230227-0424.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,7 @@
|
|
20
20
|
"lint": "just-scripts lint",
|
21
21
|
"test": "jest --passWithNoTests",
|
22
22
|
"type-check": "tsc -b tsconfig.json",
|
23
|
-
"generate-api": "just-scripts
|
23
|
+
"generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
|
24
24
|
},
|
25
25
|
"devDependencies": {
|
26
26
|
"@fluentui/eslint-plugin": "*",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"@fluentui/scripts-tasks": "*"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
|
-
"
|
31
|
+
"tslib": "^2.1.0"
|
32
32
|
},
|
33
33
|
"beachball": {},
|
34
34
|
"exports": {
|
package/.swcrc
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
-
"env": {
|
4
|
-
"targets": {
|
5
|
-
"chrome": "84",
|
6
|
-
"edge": "84",
|
7
|
-
"firefox": "75",
|
8
|
-
"opera": "73",
|
9
|
-
"safari": "14.1"
|
10
|
-
}
|
11
|
-
},
|
12
|
-
"exclude": [
|
13
|
-
"/testing",
|
14
|
-
"/**/*.cy.ts",
|
15
|
-
"/**/*.cy.tsx",
|
16
|
-
"/**/*.spec.ts",
|
17
|
-
"/**/*.spec.tsx",
|
18
|
-
"/**/*.test.ts",
|
19
|
-
"/**/*.test.tsx"
|
20
|
-
],
|
21
|
-
"jsc": {
|
22
|
-
"parser": {
|
23
|
-
"syntax": "typescript",
|
24
|
-
"tsx": true,
|
25
|
-
"decorators": false,
|
26
|
-
"dynamicImport": false
|
27
|
-
},
|
28
|
-
"target": "es2019",
|
29
|
-
"externalHelpers": true
|
30
|
-
},
|
31
|
-
"minify": false,
|
32
|
-
"sourceMaps": true
|
33
|
-
}
|