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