@vuu-ui/vuu-utils 3.3.17 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.
|
|
2
|
+
"version": "3.4.1",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@dnd-kit/react": "^0.1.21",
|
|
18
|
-
"@vuu-ui/vuu-data-types": "3.
|
|
19
|
-
"@vuu-ui/vuu-table-types": "3.
|
|
20
|
-
"@vuu-ui/vuu-filter-types": "3.
|
|
21
|
-
"@vuu-ui/vuu-protocol-types": "3.
|
|
18
|
+
"@vuu-ui/vuu-data-types": "3.4.1",
|
|
19
|
+
"@vuu-ui/vuu-table-types": "3.4.1",
|
|
20
|
+
"@vuu-ui/vuu-filter-types": "3.4.1",
|
|
21
|
+
"@vuu-ui/vuu-protocol-types": "3.4.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@internationalized/date": "^3.0.0",
|
|
25
|
-
"@vuu-ui/vuu-filter-parser": "3.
|
|
25
|
+
"@vuu-ui/vuu-filter-parser": "3.4.1",
|
|
26
26
|
"clsx": "^2.0.0",
|
|
27
27
|
"react": "^19.2.3",
|
|
28
28
|
"react-dom": "^19.2.3"
|
package/src/html-utils.js
CHANGED
|
@@ -81,6 +81,40 @@ function getScrollbarSize() {
|
|
|
81
81
|
}
|
|
82
82
|
return size;
|
|
83
83
|
}
|
|
84
|
+
const DEFAULT_MAX_SCROLL_HEIGHT = 33000000;
|
|
85
|
+
const MAX_PROBE_HEIGHT = 2 ** 26;
|
|
86
|
+
const maxScrollHeightByDevicePixelRatio = new Map();
|
|
87
|
+
function getMaxScrollHeight(doc = globalThis.document) {
|
|
88
|
+
if (doc?.body === void 0 || null === doc.body) return DEFAULT_MAX_SCROLL_HEIGHT;
|
|
89
|
+
const devicePixelRatio = doc.defaultView?.devicePixelRatio ?? 1;
|
|
90
|
+
const cachedValue = maxScrollHeightByDevicePixelRatio.get(devicePixelRatio);
|
|
91
|
+
if (void 0 !== cachedValue) return cachedValue;
|
|
92
|
+
const outer = doc.createElement("div");
|
|
93
|
+
outer.style.cssText = "position:absolute;top:-200px;left:-200px;width:50px;height:50px;overflow:scroll;visibility:hidden;";
|
|
94
|
+
const inner = doc.createElement("div");
|
|
95
|
+
inner.style.width = "1px";
|
|
96
|
+
outer.appendChild(inner);
|
|
97
|
+
doc.body.appendChild(outer);
|
|
98
|
+
const isHonoured = (height)=>{
|
|
99
|
+
inner.style.height = `${height}px`;
|
|
100
|
+
return outer.scrollHeight >= height - 1;
|
|
101
|
+
};
|
|
102
|
+
let lo = 0;
|
|
103
|
+
let hi = MAX_PROBE_HEIGHT;
|
|
104
|
+
while(hi - lo > 1){
|
|
105
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
106
|
+
if (isHonoured(mid)) lo = mid;
|
|
107
|
+
else hi = mid;
|
|
108
|
+
}
|
|
109
|
+
inner.style.height = `${lo}px`;
|
|
110
|
+
const maxScrollHeight = Math.min(lo, outer.scrollHeight);
|
|
111
|
+
outer.remove();
|
|
112
|
+
if (maxScrollHeight > 0) {
|
|
113
|
+
maxScrollHeightByDevicePixelRatio.set(devicePixelRatio, maxScrollHeight);
|
|
114
|
+
return maxScrollHeight;
|
|
115
|
+
}
|
|
116
|
+
return DEFAULT_MAX_SCROLL_HEIGHT;
|
|
117
|
+
}
|
|
84
118
|
const dispatchMouseEvent = (el, type)=>{
|
|
85
119
|
const evt = new MouseEvent(type, {
|
|
86
120
|
view: window,
|
|
@@ -105,4 +139,4 @@ const dispatchCustomEvent = (el, type)=>{
|
|
|
105
139
|
});
|
|
106
140
|
el.dispatchEvent(evt);
|
|
107
141
|
};
|
|
108
|
-
export { createEl, dispatchCustomEvent, dispatchKeyboardEvent, dispatchMouseEvent, focusFirstFocusableElement, getClosest, getClosestIndexItem, getElementByDataIndex, getElementDataIndex, getFocusableElement, getScrollbarSize, hasOpenOptionList, isDateInput, isInputElement, isSelectableElement, queryClosest };
|
|
142
|
+
export { DEFAULT_MAX_SCROLL_HEIGHT, createEl, dispatchCustomEvent, dispatchKeyboardEvent, dispatchMouseEvent, focusFirstFocusableElement, getClosest, getClosestIndexItem, getElementByDataIndex, getElementDataIndex, getFocusableElement, getMaxScrollHeight, getScrollbarSize, hasOpenOptionList, isDateInput, isInputElement, isSelectableElement, queryClosest };
|
package/src/useResizeObserver.js
CHANGED
|
@@ -29,7 +29,7 @@ const getTargetSize = (element, size, dimension)=>{
|
|
|
29
29
|
return 0;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
const resizeObserver = new ResizeObserver((entries)=>{
|
|
32
|
+
const resizeObserver = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver((entries)=>{
|
|
33
33
|
for (const entry of entries){
|
|
34
34
|
const { target, borderBoxSize, contentBoxSize } = entry;
|
|
35
35
|
const observedTarget = observedMap.get(target);
|
|
@@ -81,7 +81,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
81
81
|
if (observedTarget) {
|
|
82
82
|
const measurements = measure(target);
|
|
83
83
|
observedTarget.measurements = measurements;
|
|
84
|
-
resizeObserver
|
|
84
|
+
resizeObserver?.observe(target);
|
|
85
85
|
if (reportInitialSize) onResize(measurements);
|
|
86
86
|
} else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation", "font-weight:bold; color:red;");
|
|
87
87
|
}
|
|
@@ -93,7 +93,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
93
93
|
}
|
|
94
94
|
return ()=>{
|
|
95
95
|
if (target && observedMap.has(target)) {
|
|
96
|
-
resizeObserver
|
|
96
|
+
resizeObserver?.unobserve(target);
|
|
97
97
|
observedMap.delete(target);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
@@ -51,7 +51,8 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
|
|
|
51
51
|
allowColumnHeaderMenu?: false;
|
|
52
52
|
colHeaderContentRenderer?: string;
|
|
53
53
|
colHeaderLabelRenderer?: string;
|
|
54
|
-
|
|
54
|
+
exportable?: boolean;
|
|
55
|
+
exportFormatter?: (value: unknown, row: import("@vuu-ui/vuu-table-types").RowAccessor) => string;
|
|
55
56
|
getIcon?: (row: import("@vuu-ui/vuu-table-types").DataRow) => string | undefined;
|
|
56
57
|
groupable?: boolean;
|
|
57
58
|
hidden?: boolean;
|
package/types/html-utils.d.ts
CHANGED
|
@@ -13,6 +13,22 @@ export declare const isInputElement: (el: HTMLElement | EventTarget | null) => e
|
|
|
13
13
|
export declare const isDateInput: (el: HTMLElement | EventTarget | null) => el is HTMLInputElement;
|
|
14
14
|
export declare const hasOpenOptionList: (el: HTMLElement | EventTarget | null) => boolean | undefined;
|
|
15
15
|
export declare function getScrollbarSize(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Used when the max scroll height cannot be measured, e.g. outside a browser.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_MAX_SCROLL_HEIGHT = 33000000;
|
|
20
|
+
/**
|
|
21
|
+
* Measure the largest scrollHeight (in CSS pixels) the browser supports for a
|
|
22
|
+
* scrollable element. Engines have an internal layout limit, which shrinks in
|
|
23
|
+
* CSS pixels as browser zoom increases, e.g.
|
|
24
|
+
* Chromium/WebKit: ~33.5M at 100%, ~11.18M at 300%
|
|
25
|
+
* Firefox: ~17.9M at 100%, ~5.97M at 300%
|
|
26
|
+
* Chromium/WebKit clamp heights above the limit, Firefox ignores them entirely,
|
|
27
|
+
* so a single oversized probe cannot be used. Instead we binary search for the
|
|
28
|
+
* largest height that is honoured. Browser zoom changes devicePixelRatio, so
|
|
29
|
+
* results are cached per ratio.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getMaxScrollHeight(doc?: Document | undefined): number;
|
|
16
32
|
export type MouseEventTypes = "dblclick" | "click";
|
|
17
33
|
export type KeyboardEventTypes = "keydown" | "keypress" | "keyup";
|
|
18
34
|
export declare const dispatchMouseEvent: (el: HTMLElement, type: MouseEventTypes) => void;
|