@fluentui/priority-overflow
Advanced tools
Comparing version 9.0.0-beta.2 to 9.0.0-beta.3
@@ -5,6 +5,48 @@ { | ||
{ | ||
"date": "Tue, 28 Jun 2022 15:09:21 GMT", | ||
"date": "Thu, 13 Oct 2022 10:59:18 GMT", | ||
"tag": "@fluentui/priority-overflow_v9.0.0-beta.3", | ||
"version": "9.0.0-beta.3", | ||
"comments": { | ||
"prerelease": [ | ||
{ | ||
"author": "lingfangao@hotmail.com", | ||
"package": "@fluentui/priority-overflow", | ||
"commit": "6440417cb5db157acfb33d9f2c93de9bf7493791", | ||
"comment": "feat: Adds API to register overflow menus for better available space calculation" | ||
}, | ||
{ | ||
"author": "lingfangao@hotmail.com", | ||
"package": "@fluentui/priority-overflow", | ||
"commit": "d59683655d4d2a3775df4a2b41a09504cddd72ad", | ||
"comment": "new overflow items should only be enqueued while observing" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Thu, 15 Sep 2022 09:49:45 GMT", | ||
"tag": "@fluentui/priority-overflow_v9.0.0-beta.2", | ||
"version": "9.0.0-beta.2", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"author": "martinhochel@microsoft.com", | ||
"package": "@fluentui/priority-overflow", | ||
"commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5", | ||
"comment": "chore: update package scaffold" | ||
}, | ||
{ | ||
"author": "martinhochel@microsoft.com", | ||
"package": "@fluentui/priority-overflow", | ||
"commit": "16aa65dcae8f75c6a221225fd0eb43800650ac66", | ||
"comment": "chore(priority-flow): re-generate api.md" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 28 Jun 2022 15:14:10 GMT", | ||
"tag": "@fluentui/priority-overflow_v9.0.0-beta.2", | ||
"version": "9.0.0-beta.2", | ||
"comments": { | ||
"prerelease": [ | ||
@@ -11,0 +53,0 @@ { |
# Change Log - @fluentui/priority-overflow | ||
This log was last generated on Tue, 28 Jun 2022 15:09:21 GMT and should not be manually modified. | ||
This log was last generated on Thu, 13 Oct 2022 10:59:18 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.0.0-beta.3) | ||
Thu, 13 Oct 2022 10:59:18 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.0-beta.2..@fluentui/priority-overflow_v9.0.0-beta.3) | ||
### Changes | ||
- feat: Adds API to register overflow menus for better available space calculation ([PR #25091](https://github.com/microsoft/fluentui/pull/25091) by lingfangao@hotmail.com) | ||
- new overflow items should only be enqueued while observing ([PR #25122](https://github.com/microsoft/fluentui/pull/25122) by lingfangao@hotmail.com) | ||
## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.0.0-beta.2) | ||
Tue, 28 Jun 2022 15:09:21 GMT | ||
Tue, 28 Jun 2022 15:14:10 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.0-beta.1..@fluentui/priority-overflow_v9.0.0-beta.2) | ||
@@ -11,0 +21,0 @@ |
@@ -111,4 +111,13 @@ /** | ||
forceUpdate: () => void; | ||
/** | ||
* Adds an element that opens an overflow menu. This is used to calculate | ||
* available space and check if additional items need to overflow | ||
*/ | ||
addOverflowMenu: (element: HTMLElement) => void; | ||
/** | ||
* Unsets the overflow menu element | ||
*/ | ||
removeOverflowMenu: () => void; | ||
} | ||
export { } |
@@ -19,2 +19,4 @@ "use strict"; | ||
let container; | ||
let overflowMenu; | ||
let observing = false; | ||
const options = { | ||
@@ -132,4 +134,5 @@ padding: 10, | ||
return; | ||
} // Snapshot of the visible/invisible state to compare for updates | ||
} | ||
const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0; // Snapshot of the visible/invisible state to compare for updates | ||
@@ -155,2 +158,6 @@ const visibleTop = visibleItemQueue.peek(); | ||
currentWidth -= makeItemInvisible(); | ||
} | ||
if (invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) { | ||
makeItemInvisible(); | ||
} // only update when the state of visible/invisible items has changed | ||
@@ -177,2 +184,4 @@ | ||
Object.assign(options, userOptions); | ||
observing = true; | ||
Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id)); | ||
container = observedContainer; | ||
@@ -183,2 +192,3 @@ resizeObserver.observe(container); | ||
const disconnect = () => { | ||
observing = false; | ||
resizeObserver.disconnect(); | ||
@@ -188,5 +198,12 @@ }; | ||
const addItem = item => { | ||
overflowItems[item.id] = item; | ||
visibleItemQueue.enqueue(item.id); | ||
if (overflowItems[item.id]) { | ||
return; | ||
} | ||
overflowItems[item.id] = item; // some options can affect priority which are only set on `observe` | ||
if (observing) { | ||
visibleItemQueue.enqueue(item.id); | ||
} | ||
if (item.groupId) { | ||
@@ -206,3 +223,15 @@ if (!overflowGroups[item.groupId]) { | ||
const addOverflowMenu = el => { | ||
overflowMenu = el; | ||
}; | ||
const removeOverflowMenu = () => { | ||
overflowMenu = undefined; | ||
}; | ||
const removeItem = itemId => { | ||
if (!overflowItems[itemId]) { | ||
return; | ||
} | ||
const item = overflowItems[itemId]; | ||
@@ -227,3 +256,5 @@ visibleItemQueue.remove(itemId); | ||
removeItem, | ||
update | ||
update, | ||
addOverflowMenu, | ||
removeOverflowMenu | ||
}; | ||
@@ -230,0 +261,0 @@ } |
@@ -85,3 +85,4 @@ "use strict"; | ||
const contains = item => { | ||
return arr.indexOf(item) >= 0; | ||
const index = arr.indexOf(item); | ||
return index >= 0 && index < size; | ||
}; | ||
@@ -92,3 +93,3 @@ | ||
if (i === -1) { | ||
if (i === -1 || i >= size) { | ||
return; | ||
@@ -95,0 +96,0 @@ } |
@@ -10,2 +10,4 @@ import { debounce } from './debounce'; | ||
let container; | ||
let overflowMenu; | ||
let observing = false; | ||
const options = { | ||
@@ -123,4 +125,5 @@ padding: 10, | ||
return; | ||
} // Snapshot of the visible/invisible state to compare for updates | ||
} | ||
const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0; // Snapshot of the visible/invisible state to compare for updates | ||
@@ -146,2 +149,6 @@ const visibleTop = visibleItemQueue.peek(); | ||
currentWidth -= makeItemInvisible(); | ||
} | ||
if (invisibleItemQueue.size() > 0 && currentWidth + overflowMenuOffset > availableSize) { | ||
makeItemInvisible(); | ||
} // only update when the state of visible/invisible items has changed | ||
@@ -168,2 +175,4 @@ | ||
Object.assign(options, userOptions); | ||
observing = true; | ||
Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id)); | ||
container = observedContainer; | ||
@@ -174,2 +183,3 @@ resizeObserver.observe(container); | ||
const disconnect = () => { | ||
observing = false; | ||
resizeObserver.disconnect(); | ||
@@ -179,5 +189,12 @@ }; | ||
const addItem = item => { | ||
overflowItems[item.id] = item; | ||
visibleItemQueue.enqueue(item.id); | ||
if (overflowItems[item.id]) { | ||
return; | ||
} | ||
overflowItems[item.id] = item; // some options can affect priority which are only set on `observe` | ||
if (observing) { | ||
visibleItemQueue.enqueue(item.id); | ||
} | ||
if (item.groupId) { | ||
@@ -197,3 +214,15 @@ if (!overflowGroups[item.groupId]) { | ||
const addOverflowMenu = el => { | ||
overflowMenu = el; | ||
}; | ||
const removeOverflowMenu = () => { | ||
overflowMenu = undefined; | ||
}; | ||
const removeItem = itemId => { | ||
if (!overflowItems[itemId]) { | ||
return; | ||
} | ||
const item = overflowItems[itemId]; | ||
@@ -218,5 +247,7 @@ visibleItemQueue.remove(itemId); | ||
removeItem, | ||
update | ||
update, | ||
addOverflowMenu, | ||
removeOverflowMenu | ||
}; | ||
} | ||
//# sourceMappingURL=overflowManager.js.map |
@@ -78,3 +78,4 @@ /** | ||
const contains = item => { | ||
return arr.indexOf(item) >= 0; | ||
const index = arr.indexOf(item); | ||
return index >= 0 && index < size; | ||
}; | ||
@@ -85,3 +86,3 @@ | ||
if (i === -1) { | ||
if (i === -1 || i >= size) { | ||
return; | ||
@@ -88,0 +89,0 @@ } |
{ | ||
"name": "@fluentui/priority-overflow", | ||
"version": "9.0.0-beta.2", | ||
"version": "9.0.0-beta.3", | ||
"description": "Vanilla JS utilities to implement overflow menus", | ||
@@ -23,3 +23,3 @@ "main": "lib-commonjs/index.js", | ||
"docs": "api-extractor run --config=config/api-extractor.local.json --local", | ||
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/priority-overflow/src && yarn docs", | ||
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/priority-overflow/src && yarn docs", | ||
"type-check": "tsc -b tsconfig.json" | ||
@@ -26,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74435
840
38
26