@fluentui/priority-overflow 9.0.1 → 9.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,97 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createPriorityQueue = void 0;
5
- /**
6
- * @param compare - comparison function for items
7
- * @returns Priority queue implemented with a min heap
8
- */
9
- function createPriorityQueue(compare) {
10
- var arr = [];
11
- var size = 0;
12
- var left = function (i) {
13
- return 2 * i + 1;
14
- };
15
- var right = function (i) {
16
- return 2 * i + 2;
17
- };
18
- var parent = function (i) {
19
- return Math.floor((i - 1) / 2);
20
- };
21
- var swap = function (a, b) {
22
- var tmp = arr[a];
23
- arr[a] = arr[b];
24
- arr[b] = tmp;
25
- };
26
- var heapify = function (i) {
27
- var smallest = i;
28
- var l = left(i);
29
- var r = right(i);
30
- if (l < size && compare(arr[l], arr[smallest]) < 0) {
31
- smallest = l;
32
- }
33
- if (r < size && compare(arr[r], arr[smallest]) < 0) {
34
- smallest = r;
35
- }
36
- if (smallest !== i) {
37
- swap(smallest, i);
38
- heapify(smallest);
39
- }
40
- };
41
- var dequeue = function () {
42
- if (size === 0) {
43
- throw new Error('Priority queue empty');
44
- }
45
- var res = arr[0];
46
- arr[0] = arr[--size];
47
- heapify(0);
48
- return res;
49
- };
50
- var peek = function () {
51
- if (size === 0) {
52
- return null;
53
- }
54
- return arr[0];
55
- };
56
- var enqueue = function (item) {
57
- arr[size++] = item;
58
- var i = size - 1;
59
- var p = parent(i);
60
- while (i > 0 && compare(arr[p], arr[i]) > 0) {
61
- swap(p, i);
62
- i = p;
63
- p = parent(i);
64
- }
65
- };
66
- var contains = function (item) {
67
- var index = arr.indexOf(item);
68
- return index >= 0 && index < size;
69
- };
70
- var remove = function (item) {
71
- var i = arr.indexOf(item);
72
- if (i === -1 || i >= size) {
73
- return;
74
- }
75
- arr[i] = arr[--size];
76
- heapify(i);
77
- };
78
- var clear = function () {
79
- size = 0;
80
- };
81
- var all = function () {
82
- return arr.slice(0, size);
83
- };
84
- return {
85
- all: all,
86
- clear: clear,
87
- contains: contains,
88
- dequeue: dequeue,
89
- enqueue: enqueue,
90
- peek: peek,
91
- remove: remove,
92
- size: function () { return size; },
93
- };
94
- }
95
- exports.createPriorityQueue = createPriorityQueue;
96
- });
97
- //# sourceMappingURL=priorityQueue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"priorityQueue.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/priority-overflow/src/priorityQueue.ts"],"names":[],"mappings":";;;;IAaA;;;OAGG;IACH,SAAgB,mBAAmB,CAAI,OAAkC;QACvE,IAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,IAAM,IAAI,GAAG,UAAC,CAAS;YACrB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,IAAM,KAAK,GAAG,UAAC,CAAS;YACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,IAAM,MAAM,GAAG,UAAC,CAAS;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC;QAEF,IAAM,IAAI,GAAG,UAAC,CAAS,EAAE,CAAS;YAChC,IAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAChB,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,IAAM,OAAO,GAAG,UAAC,CAAS;YACxB,IAAI,QAAQ,GAAG,CAAC,CAAC;YACjB,IAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAEnB,I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C,GAAG,CAAC,EAAE;gBAC3C,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACX,CAAC,GAAG,CAAC,CAAC;gBACN,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;aACf;QACH,CAAC,CAAC;QAEF,IAAM,QAAQ,GAAG,UAAC,IAAO;YACvB,IAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC;QACpC,CAAC,CAAC;QAEF,IAAM,MAAM,GAAG,UAAC,IAAO;YACrB,IAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAE5B,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;gBACzB,OAAO;aACR;YAED,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC;QAEF,IAAM,KAAK,GAAG;YACZ,IAAI,GAAG,CAAC,CAAC;QACX,CAAC,CAAC;QAEF,IAAM,GAAG,GAAG;YACV,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,OAAO;YACL,GAAG,KAAA;YACH,KAAK,OAAA;YACL,QAAQ,UAAA;YACR,OAAO,SAAA;YACP,OAAO,SAAA;YACP,IAAI,MAAA;YACJ,MAAM,QAAA;YACN,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;SACjB,CAAC;IACJ,CAAC;IA1GD,kDA0GC","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-amd/types.js DELETED
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
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"]}