@mantine-vue/hooks 1.1.3 → 2.0.0
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/cjs/index.cjs +33 -24
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +33 -24
- package/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/esm/index.mjs
CHANGED
|
@@ -1257,9 +1257,14 @@ function useResizeObserver(options) {
|
|
|
1257
1257
|
const elementRef = ref(null);
|
|
1258
1258
|
const rect = ref(defaultState);
|
|
1259
1259
|
let observer;
|
|
1260
|
+
let frameId = 0;
|
|
1260
1261
|
const disconnect = () => {
|
|
1261
1262
|
observer?.disconnect();
|
|
1262
1263
|
observer = void 0;
|
|
1264
|
+
if (frameId) {
|
|
1265
|
+
cancelAnimationFrame(frameId);
|
|
1266
|
+
frameId = 0;
|
|
1267
|
+
}
|
|
1263
1268
|
};
|
|
1264
1269
|
watch(elementRef, (node) => {
|
|
1265
1270
|
disconnect();
|
|
@@ -1267,18 +1272,21 @@ function useResizeObserver(options) {
|
|
|
1267
1272
|
observer = new ResizeObserver((entries) => {
|
|
1268
1273
|
const entry = entries[0];
|
|
1269
1274
|
if (entry) {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1275
|
+
cancelAnimationFrame(frameId);
|
|
1276
|
+
frameId = requestAnimationFrame(() => {
|
|
1277
|
+
const boxSize = entry.borderBoxSize?.[0] || entry.contentBoxSize?.[0];
|
|
1278
|
+
if (boxSize) rect.value = {
|
|
1279
|
+
width: boxSize.inlineSize,
|
|
1280
|
+
height: boxSize.blockSize,
|
|
1281
|
+
x: entry.contentRect.x,
|
|
1282
|
+
y: entry.contentRect.y,
|
|
1283
|
+
top: entry.contentRect.top,
|
|
1284
|
+
left: entry.contentRect.left,
|
|
1285
|
+
bottom: entry.contentRect.bottom,
|
|
1286
|
+
right: entry.contentRect.right
|
|
1287
|
+
};
|
|
1288
|
+
else rect.value = entry.contentRect;
|
|
1289
|
+
});
|
|
1282
1290
|
}
|
|
1283
1291
|
});
|
|
1284
1292
|
observer.observe(node, options);
|
|
@@ -3658,21 +3666,22 @@ function useMask(options) {
|
|
|
3658
3666
|
prevNode.removeEventListener("keydown", handleKeyDown);
|
|
3659
3667
|
prevNode.removeEventListener("paste", handlePaste);
|
|
3660
3668
|
}
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3669
|
+
const inputNode = newNode instanceof HTMLInputElement ? newNode : newNode?.querySelector("input");
|
|
3670
|
+
node = inputNode ?? null;
|
|
3671
|
+
if (inputNode) {
|
|
3672
|
+
inputNode.addEventListener("input", handleInput);
|
|
3673
|
+
inputNode.addEventListener("focus", handleFocus);
|
|
3674
|
+
inputNode.addEventListener("blur", handleBlur);
|
|
3675
|
+
inputNode.addEventListener("mousedown", handleMouseDown);
|
|
3676
|
+
inputNode.addEventListener("mouseup", handleMouseUp);
|
|
3677
|
+
inputNode.addEventListener("keydown", handleKeyDown);
|
|
3678
|
+
inputNode.addEventListener("paste", handlePaste);
|
|
3679
|
+
setAriaAttributes(inputNode);
|
|
3680
|
+
const hasInitialValue = initializeInputValue(inputNode);
|
|
3672
3681
|
if (options.alwaysShowMask && !hasInitialValue) {
|
|
3673
3682
|
const { slots, slotChar } = getResolvedOptions(options, "");
|
|
3674
3683
|
const displayValue = buildDisplayValue("", slots, slotChar, true);
|
|
3675
|
-
|
|
3684
|
+
inputNode.value = displayValue;
|
|
3676
3685
|
display = displayValue;
|
|
3677
3686
|
maskedValue.value = displayValue;
|
|
3678
3687
|
}
|