@fluentui/priority-overflow 9.0.0 → 9.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +37 -1
- package/CHANGELOG.md +21 -2
- package/lib/debounce.js +1 -2
- package/lib/debounce.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/overflowManager.js +15 -7
- package/lib/overflowManager.js.map +1 -1
- package/lib/priorityQueue.js +1 -2
- package/lib/priorityQueue.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib-commonjs/debounce.js +22 -21
- package/lib-commonjs/debounce.js.map +1 -1
- package/lib-commonjs/index.js +6 -8
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/overflowManager.js +214 -208
- package/lib-commonjs/overflowManager.js.map +1 -1
- package/lib-commonjs/priorityQueue.js +94 -93
- package/lib-commonjs/priorityQueue.js.map +1 -1
- package/lib-commonjs/types.js +3 -2
- package/lib-commonjs/types.js.map +1 -1
- package/package.json +4 -3
- package/lib-amd/debounce.js +0 -27
- package/lib-amd/debounce.js.map +0 -1
- package/lib-amd/index.js +0 -7
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/overflowManager.js +0 -208
- package/lib-amd/overflowManager.js.map +0 -1
- package/lib-amd/priorityQueue.js +0 -97
- package/lib-amd/priorityQueue.js.map +0 -1
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
package/.swcrc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
+
"exclude": [
|
4
|
+
"/testing",
|
5
|
+
"/**/*.cy.ts",
|
6
|
+
"/**/*.cy.tsx",
|
7
|
+
"/**/*.spec.ts",
|
8
|
+
"/**/*.spec.tsx",
|
9
|
+
"/**/*.test.ts",
|
10
|
+
"/**/*.test.tsx"
|
11
|
+
],
|
12
|
+
"jsc": {
|
13
|
+
"parser": {
|
14
|
+
"syntax": "typescript",
|
15
|
+
"tsx": true,
|
16
|
+
"decorators": false,
|
17
|
+
"dynamicImport": false
|
18
|
+
},
|
19
|
+
"externalHelpers": true,
|
20
|
+
"transform": {
|
21
|
+
"react": {
|
22
|
+
"runtime": "classic",
|
23
|
+
"useSpread": true
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
27
|
+
},
|
28
|
+
"minify": false,
|
29
|
+
"sourceMaps": true
|
30
|
+
}
|
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,43 @@
|
|
2
2
|
"name": "@fluentui/priority-overflow",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 21 Mar 2023 21:18:32 GMT",
|
6
|
+
"tag": "@fluentui/priority-overflow_v9.0.2",
|
7
|
+
"version": "9.0.2",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "tristan.watanabe@gmail.com",
|
12
|
+
"package": "@fluentui/priority-overflow",
|
13
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
14
|
+
"comment": "fix: add node field to package.json exports map."
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "tristan.watanabe@gmail.com",
|
18
|
+
"package": "@fluentui/priority-overflow",
|
19
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
20
|
+
"comment": "chore: migrate to swc transpilation approach."
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"date": "Tue, 07 Feb 2023 14:13:08 GMT",
|
27
|
+
"tag": "@fluentui/priority-overflow_v9.0.1",
|
28
|
+
"version": "9.0.1",
|
29
|
+
"comments": {
|
30
|
+
"patch": [
|
31
|
+
{
|
32
|
+
"author": "lingfangao@hotmail.com",
|
33
|
+
"package": "@fluentui/priority-overflow",
|
34
|
+
"commit": "7274228423cc06749b72ab6a8a112db6f18f5378",
|
35
|
+
"comment": "fix: New overflow items all always dispatch updates to subscriber"
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"date": "Wed, 18 Jan 2023 16:32:53 GMT",
|
6
42
|
"tag": "@fluentui/priority-overflow_v9.0.0",
|
7
43
|
"version": "9.0.0",
|
8
44
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
# Change Log - @fluentui/priority-overflow
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 21 Mar 2023 21:18:32 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.0.2](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.0.2)
|
8
|
+
|
9
|
+
Tue, 21 Mar 2023 21:18:32 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.1..@fluentui/priority-overflow_v9.0.2)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
15
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
16
|
+
|
17
|
+
## [9.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.0.1)
|
18
|
+
|
19
|
+
Tue, 07 Feb 2023 14:13:08 GMT
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.0..@fluentui/priority-overflow_v9.0.1)
|
21
|
+
|
22
|
+
### Patches
|
23
|
+
|
24
|
+
- fix: New overflow items all always dispatch updates to subscriber ([PR #26565](https://github.com/microsoft/fluentui/pull/26565) by lingfangao@hotmail.com)
|
25
|
+
|
7
26
|
## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/priority-overflow_v9.0.0)
|
8
27
|
|
9
|
-
Wed, 18 Jan 2023 16:
|
28
|
+
Wed, 18 Jan 2023 16:32:53 GMT
|
10
29
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/priority-overflow_v9.0.0-rc.2..@fluentui/priority-overflow_v9.0.0)
|
11
30
|
|
12
31
|
### Patches
|
package/lib/debounce.js
CHANGED
@@ -3,8 +3,7 @@
|
|
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
|
-
*/
|
7
|
-
export function debounce(fn) {
|
6
|
+
*/export function debounce(fn) {
|
8
7
|
let pending;
|
9
8
|
return () => {
|
10
9
|
if (!pending) {
|
package/lib/debounce.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["debounce","fn","pending","queueMicrotask"],"sources":["../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"],"mappings":"AAAA;;;;;GAMA,OAAO,SAASA,SAASC,EAAY,EAAE;EACrC,IAAIC,OAAA;EACJ,OAAO,MAAM;IACX,IAAI,CAACA,OAAA,EAAS;MACZA,OAAA,GAAU,IAAI;MACdC,cAAA,CAAe,MAAM;QACnB;QACA;QACAD,OAAA,GAAU,KAAK;QACfD,EAAA;MACF;IACF;EACF;AACF"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["createOverflowManager"],"sources":["../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"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ"}
|
package/lib/overflowManager.js
CHANGED
@@ -7,7 +7,10 @@ import { createPriorityQueue } from './priorityQueue';
|
|
7
7
|
export function createOverflowManager() {
|
8
8
|
let container;
|
9
9
|
let overflowMenu;
|
10
|
+
// Set as true when resize observer is observing
|
10
11
|
let observing = false;
|
12
|
+
// If true, next update will dispatch to onUpdateOverflow even if queue top states don't change
|
13
|
+
let forceDispatch = false;
|
11
14
|
const options = {
|
12
15
|
padding: 10,
|
13
16
|
overflowAxis: 'horizontal',
|
@@ -103,10 +106,11 @@ export function createOverflowManager() {
|
|
103
106
|
groupVisibility
|
104
107
|
});
|
105
108
|
};
|
106
|
-
const processOverflowItems =
|
109
|
+
const processOverflowItems = () => {
|
107
110
|
if (!container) {
|
108
|
-
return;
|
111
|
+
return false;
|
109
112
|
}
|
113
|
+
const availableSize = getOffsetSize(container) - options.padding;
|
110
114
|
const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;
|
111
115
|
// Snapshot of the visible/invisible state to compare for updates
|
112
116
|
const visibleTop = visibleItemQueue.peek();
|
@@ -133,15 +137,15 @@ export function createOverflowManager() {
|
|
133
137
|
}
|
134
138
|
// only update when the state of visible/invisible items has changed
|
135
139
|
if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {
|
136
|
-
|
140
|
+
return true;
|
137
141
|
}
|
142
|
+
return false;
|
138
143
|
};
|
139
144
|
const forceUpdate = () => {
|
140
|
-
if (
|
141
|
-
|
145
|
+
if (processOverflowItems() || forceDispatch) {
|
146
|
+
forceDispatch = false;
|
147
|
+
dispatchOverflowUpdate();
|
142
148
|
}
|
143
|
-
const availableSize = getOffsetSize(container) - options.padding;
|
144
|
-
processOverflowItems(availableSize);
|
145
149
|
};
|
146
150
|
const update = debounce(forceUpdate);
|
147
151
|
const observe = (observedContainer, userOptions) => {
|
@@ -162,6 +166,10 @@ export function createOverflowManager() {
|
|
162
166
|
overflowItems[item.id] = item;
|
163
167
|
// some options can affect priority which are only set on `observe`
|
164
168
|
if (observing) {
|
169
|
+
// Updates to elements might not change the queue tops
|
170
|
+
// i.e. new element is enqueued but the top of the queue stays the same
|
171
|
+
// force a dispatch on the next batched update
|
172
|
+
forceDispatch = true;
|
165
173
|
visibleItemQueue.enqueue(item.id);
|
166
174
|
}
|
167
175
|
if (item.groupId) {
|
@@ -1 +1 @@
|
|
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,IAAIC,SAAS,GAAG,KAAK;EACrB,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,CAACf,SAAS,EAAE;MAC7B;;IAGFgB,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,MAAMC,kBAAkB,GAAGnB,mBAAmB,CAAS,CAACoB,CAAC,EAAEC,CAAC,KAAI;IAC9D,MAAMC,KAAK,GAAGT,aAAa,CAACO,CAAC,CAAC;IAC9B,MAAMG,KAAK,GAAGV,aAAa,CAACQ,CAAC,CAAC;IAC9B;IACA,MAAMG,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1B;;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","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":"../src/","sources":["packages/react-components/priority-overflow/src/overflowManager.ts"],"sourcesContent":["import { debounce } from './debounce';\nimport { createPriorityQueue } from './priorityQueue';\nimport type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } from './types';\n\n/**\n * @internal\n * @returns overflow manager instance\n */\nexport function createOverflowManager(): OverflowManager {\n let container: HTMLElement | undefined;\n let overflowMenu: HTMLElement | undefined;\n let observing = false;\n const options: Required<ObserveOptions> = {\n padding: 10,\n overflowAxis: 'horizontal',\n overflowDirection: 'end',\n minimumVisible: 0,\n onUpdateItemVisibility: () => undefined,\n onUpdateOverflow: () => undefined,\n };\n\n const overflowItems: Record<string, OverflowItemEntry> = {};\n const overflowGroups: Record<string, { visibleItemIds: Set<string>; invisibleItemIds: Set<string> }> = {};\n const resizeObserver = new ResizeObserver(entries => {\n if (!entries[0] || !container) {\n return;\n }\n\n update();\n });\n\n const invisibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Higher priority at the top of the queue\n const priority = itemB.priority - itemA.priority;\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const visibleItemQueue = createPriorityQueue<string>((a, b) => {\n const itemA = overflowItems[a];\n const itemB = overflowItems[b];\n // Lower priority at the top of the queue\n const priority = itemA.priority - itemB.priority;\n\n if (priority !== 0) {\n return priority;\n }\n\n const positionStatusBit =\n options.overflowDirection === 'end' ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;\n\n // equal priority, use DOM order\n // eslint-disable-next-line no-bitwise\n return itemA.element.compareDocumentPosition(itemB.element) & positionStatusBit ? -1 : 1;\n });\n\n const getOffsetSize = (el: HTMLElement) => {\n return options.overflowAxis === 'horizontal' ? el.offsetWidth : el.offsetHeight;\n };\n\n const makeItemVisible = () => {\n const nextVisible = invisibleItemQueue.dequeue();\n visibleItemQueue.enqueue(nextVisible);\n\n const item = overflowItems[nextVisible];\n options.onUpdateItemVisibility({ item, visible: true });\n if (item.groupId) {\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n return getOffsetSize(item.element);\n };\n\n const makeItemInvisible = () => {\n const nextInvisible = visibleItemQueue.dequeue();\n invisibleItemQueue.enqueue(nextInvisible);\n\n const item = overflowItems[nextInvisible];\n const width = getOffsetSize(item.element);\n options.onUpdateItemVisibility({ item, visible: false });\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.add(item.id);\n }\n\n return width;\n };\n\n const dispatchOverflowUpdate = () => {\n const visibleItemIds = visibleItemQueue.all();\n const invisibleItemIds = invisibleItemQueue.all();\n\n const visibleItems = visibleItemIds.map(itemId => overflowItems[itemId]);\n const invisibleItems = invisibleItemIds.map(itemId => overflowItems[itemId]);\n\n const groupVisibility: Record<string, OverflowGroupState> = {};\n Object.entries(overflowGroups).forEach(([groupId, groupState]) => {\n if (groupState.invisibleItemIds.size && groupState.visibleItemIds.size) {\n groupVisibility[groupId] = 'overflow';\n } else if (groupState.visibleItemIds.size === 0) {\n groupVisibility[groupId] = 'hidden';\n } else {\n groupVisibility[groupId] = 'visible';\n }\n });\n\n options.onUpdateOverflow({ visibleItems, invisibleItems, groupVisibility });\n };\n\n const processOverflowItems = (availableSize: number) => {\n if (!container) {\n return;\n }\n\n const overflowMenuOffset = overflowMenu ? getOffsetSize(overflowMenu) : 0;\n\n // Snapshot of the visible/invisible state to compare for updates\n const visibleTop = visibleItemQueue.peek();\n const invisibleTop = invisibleItemQueue.peek();\n\n const visibleItemIds = visibleItemQueue.all();\n let currentWidth = visibleItemIds.reduce((sum, visibleItemId) => {\n const child = overflowItems[visibleItemId].element;\n return sum + getOffsetSize(child);\n }, 0);\n\n // Add items until available width is filled - can result in overflow\n while (currentWidth < availableSize && invisibleItemQueue.size() > 0) {\n currentWidth += makeItemVisible();\n }\n\n // Remove items until there's no more overflow\n while (currentWidth > availableSize && visibleItemQueue.size() > 0) {\n if (visibleItemQueue.size() <= options.minimumVisible) {\n break;\n }\n currentWidth -= makeItemInvisible();\n }\n\n // make sure the overflow menu can fit\n if (\n visibleItemQueue.size() > options.minimumVisible &&\n invisibleItemQueue.size() > 0 &&\n currentWidth + overflowMenuOffset > availableSize\n ) {\n makeItemInvisible();\n }\n\n // only update when the state of visible/invisible items has changed\n if (visibleItemQueue.peek() !== visibleTop || invisibleItemQueue.peek() !== invisibleTop) {\n dispatchOverflowUpdate();\n }\n };\n\n const forceUpdate: OverflowManager['forceUpdate'] = () => {\n if (!container) {\n return;\n }\n\n const availableSize = getOffsetSize(container) - options.padding;\n processOverflowItems(availableSize);\n };\n\n const update: OverflowManager['update'] = debounce(forceUpdate);\n\n const observe: OverflowManager['observe'] = (observedContainer, userOptions) => {\n Object.assign(options, userOptions);\n observing = true;\n Object.values(overflowItems).forEach(item => visibleItemQueue.enqueue(item.id));\n\n container = observedContainer;\n resizeObserver.observe(container);\n };\n\n const disconnect: OverflowManager['disconnect'] = () => {\n observing = false;\n resizeObserver.disconnect();\n };\n\n const addItem: OverflowManager['addItem'] = item => {\n if (overflowItems[item.id]) {\n return;\n }\n\n overflowItems[item.id] = item;\n\n // some options can affect priority which are only set on `observe`\n if (observing) {\n visibleItemQueue.enqueue(item.id);\n }\n\n if (item.groupId) {\n if (!overflowGroups[item.groupId]) {\n overflowGroups[item.groupId] = {\n visibleItemIds: new Set<string>(),\n invisibleItemIds: new Set<string>(),\n };\n }\n\n overflowGroups[item.groupId].visibleItemIds.add(item.id);\n }\n\n update();\n };\n\n const addOverflowMenu: OverflowManager['addOverflowMenu'] = el => {\n overflowMenu = el;\n };\n\n const removeOverflowMenu: OverflowManager['removeOverflowMenu'] = () => {\n overflowMenu = undefined;\n };\n\n const removeItem: OverflowManager['removeItem'] = itemId => {\n if (!overflowItems[itemId]) {\n return;\n }\n\n const item = overflowItems[itemId];\n visibleItemQueue.remove(itemId);\n invisibleItemQueue.remove(itemId);\n\n if (item.groupId) {\n overflowGroups[item.groupId].visibleItemIds.delete(item.id);\n overflowGroups[item.groupId].invisibleItemIds.delete(item.id);\n }\n\n delete overflowItems[itemId];\n update();\n };\n\n return {\n addItem,\n disconnect,\n forceUpdate,\n observe,\n removeItem,\n update,\n addOverflowMenu,\n removeOverflowMenu,\n };\n}\n"]}
|
1
|
+
{"version":3,"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"],"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"],"mappings":"AAAA,SAASA,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AAGpC;;;;AAIA,OAAO,SAASC,sBAAA,EAAyC;EACvD,IAAIC,SAAA;EACJ,IAAIC,YAAA;EACJ;EACA,IAAIC,SAAA,GAAY,KAAK;EACrB;EACA,IAAIC,aAAA,GAAgB,KAAK;EACzB,MAAMC,OAAA,GAAoC;IACxCC,OAAA,EAAS;IACTC,YAAA,EAAc;IACdC,iBAAA,EAAmB;IACnBC,cAAA,EAAgB;IAChBC,sBAAA,EAAwBA,CAAA,KAAMC,SAAA;IAC9BC,gBAAA,EAAkBA,CAAA,KAAMD;EAC1B;EAEA,MAAME,aAAA,GAAmD,CAAC;EAC1D,MAAMC,cAAA,GAAiG,CAAC;EACxG,MAAMC,cAAA,GAAiB,IAAIC,cAAA,CAAeC,OAAA,IAAW;IACnD,IAAI,CAACA,OAAO,CAAC,EAAE,IAAI,CAAChB,SAAA,EAAW;MAC7B;IACF;IAEAiB,MAAA;EACF;EAEA,MAAMC,kBAAA,GAAqBpB,mBAAA,CAA4B,CAACqB,CAAA,EAAGC,CAAA,KAAM;IAC/D,MAAMC,KAAA,GAAQT,aAAa,CAACO,CAAA,CAAE;IAC9B,MAAMG,KAAA,GAAQV,aAAa,CAACQ,CAAA,CAAE;IAC9B;IACA,MAAMG,QAAA,GAAWD,KAAA,CAAMC,QAAQ,GAAGF,KAAA,CAAME,QAAQ;IAChD,IAAIA,QAAA,KAAa,GAAG;MA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AAO,CAAC,CAACC,gBAAgB,CAACC,MAAM,CAACJ,IAAA,CAAKK,EAAE;IAC9D;IAEA,OAAOhC,aAAa,CAAC0C,MAAA,CAAO;IAC5BrC,MAAA;EACF;EAEA,OAAO;IACL8D,OAAA;IACAD,UAAA;IACAN,WAAA;IACAC,OAAA;IACAU,UAAA;IACAlE,MAAA;IACAgE,eAAA;IACAC;EACF;AACF"}
|
package/lib/priorityQueue.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @param compare - comparison function for items
|
3
3
|
* @returns Priority queue implemented with a min heap
|
4
|
-
*/
|
5
|
-
export function createPriorityQueue(compare) {
|
4
|
+
*/export function createPriorityQueue(compare) {
|
6
5
|
const arr = [];
|
7
6
|
let size = 0;
|
8
7
|
const left = i => {
|
package/lib/priorityQueue.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"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"],"sources":["../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"],"mappings":"AAaA;;;GAIA,OAAO,SAASA,oBAAuBC,OAAkC,EAAoB;EAC3F,MAAMC,GAAA,GAAW,EAAE;EACnB,IAAIC,IAAA,GAAO;EAEX,MAAMC,IAAA,GAAQC,CAAA,IAAc;IAC1B,OAAO,IAAIA,CAAA,GAAI;EACjB;EAEA,MAAMC,KAAA,GAASD,CAAA,IAAc;IAC3B,OAAO,IAAIA,CAAA,GAAI;EACjB;EAEA,MAAME,MAAA,GAAUF,CAAA,IAAc;IAC5B,OAAOG,IAAA,CAAKC,KAAK,CAAC,CAACJ,CAAA,GAAI,KAAK;EAC9B;EAEA,MAAMK,IAAA,GAAOA,CAACC,CAAA,EAAWC,CAAA,KAAc;IACrC,MAAMC,GAAA,GAAMX,GAAG,CA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,CAAA,GAAIjB,MAAA,CAAOF,CAAA;IACf,OAAOA,CAAA,GAAI,KAAKJ,OAAA,CAAQC,GAAG,CAACsB,CAAA,CAAE,EAAEtB,GAAG,CAACG,CAAA,CAAE,IAAI,GAAG;MAC3CK,IAAA,CAAKc,CAAA,EAAGnB,CAAA;MACRA,CAAA,GAAImB,CAAA;MACJA,CAAA,GAAIjB,MAAA,CAAOF,CAAA;IACb;EACF;EAEA,MAAMoB,QAAA,GAAYF,IAAA,IAAY;IAC5B,MAAMG,KAAA,GAAQxB,GAAA,CAAIyB,OAAO,CAACJ,IAAA;IAC1B,OAAOG,KAAA,IAAS,KAAKA,KAAA,GAAQvB,IAAA;EAC/B;EAEA,MAAMyB,MAAA,GAAUL,IAAA,IAAY;IAC1B,MAAMlB,CAAA,GAAIH,GAAA,CAAIyB,OAAO,CAACJ,IAAA;IAEtB,IAAIlB,CAAA,KAAM,CAAC,KAAKA,CAAA,IAAKF,IAAA,EAAM;MACzB;IACF;IAEAD,GAAG,CAACG,CAAA,CAAE,GAAGH,GAAG,CAAC,EAAEC,IAAA,CAAK;IACpBW,OAAA,CAAQT,CAAA;EACV;EAEA,MAAMwB,KAAA,GAAQA,CAAA,KAAM;IAClB1B,IAAA,GAAO;EACT;EAEA,MAAM2B,GAAA,GAAMA,CAAA,KAAM;IAChB,OAAO5B,GAAA,CAAI6B,KAAK,CAAC,GAAG5B,IAAA;EACtB;EAEA,OAAO;IACL2B,GAAA;IACAD,KAAA;IACAJ,QAAA;IACAP,OAAA;IACAI,OAAA;IACAD,IAAA;IACAO,MAAA;IACAzB,IAAA,EAAMA,CAAA,KAAMA;EACd;AACF"}
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/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"],"mappings":"AAAA"}
|
package/lib-commonjs/debounce.js
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.debounce = void 0;
|
7
1
|
/**
|
8
2
|
* Microtask debouncer
|
9
3
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
|
10
4
|
* @param fn - Function to debounce
|
11
5
|
* @returns debounced function
|
12
|
-
*/
|
6
|
+
*/ "use strict";
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
Object.defineProperty(exports, "debounce", {
|
11
|
+
enumerable: true,
|
12
|
+
get: ()=>debounce
|
13
|
+
});
|
13
14
|
function debounce(fn) {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
15
|
+
let pending;
|
16
|
+
return ()=>{
|
17
|
+
if (!pending) {
|
18
|
+
pending = true;
|
19
|
+
queueMicrotask(()=>{
|
20
|
+
// Need to set pending to `false` before the debounced function is run.
|
21
|
+
// React can actually interrupt the function while it's running!
|
22
|
+
pending = false;
|
23
|
+
fn();
|
24
|
+
});
|
25
|
+
}
|
26
|
+
};
|
27
|
+
} //# sourceMappingURL=debounce.js.map
|
28
|
+
|
28
29
|
//# sourceMappingURL=debounce.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/debounce.js"],"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 */export function debounce(fn) {\n let pending;\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//# sourceMappingURL=debounce.js.map"],"names":["debounce","fn","pending","queueMicrotask"],"mappings":"AAAA;;;;;CAKC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,SAASC,EAAE,EAAE;IAC9B,IAAIC;IACJ,OAAO,IAAM;QACX,IAAI,CAACA,SAAS;YACZA,UAAU,IAAI;YACdC,eAAe,IAAM;gBACnB,uEAAuE;gBACvE,gEAAgE;gBAChED,UAAU,KAAK;gBACfD;YACF;QACF,CAAC;IACH;AACF,EACA,oCAAoC"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
exports.createOverflowManager = void 0;
|
7
|
-
var overflowManager_1 = /*#__PURE__*/require("./overflowManager");
|
8
5
|
Object.defineProperty(exports, "createOverflowManager", {
|
9
|
-
|
10
|
-
|
11
|
-
return overflowManager_1.createOverflowManager;
|
12
|
-
}
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>_overflowManager.createOverflowManager
|
13
8
|
});
|
9
|
+
const _overflowManager = require("./overflowManager");
|
10
|
+
//# sourceMappingURL=index.js.map
|
11
|
+
|
14
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { createOverflowManager } from './overflowManager';\n//# sourceMappingURL=index.js.map"],"names":["createOverflowManager"],"mappings":";;;;+BAASA;;aAAAA,sCAAqB;;iCAAQ;CACtC,iCAAiC"}
|