@mantine-vue/hooks 1.1.4 → 2.0.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/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
- const boxSize = entry.borderBoxSize?.[0] || entry.contentBoxSize?.[0];
1271
- if (boxSize) rect.value = {
1272
- width: boxSize.inlineSize,
1273
- height: boxSize.blockSize,
1274
- x: entry.contentRect.x,
1275
- y: entry.contentRect.y,
1276
- top: entry.contentRect.top,
1277
- left: entry.contentRect.left,
1278
- bottom: entry.contentRect.bottom,
1279
- right: entry.contentRect.right
1280
- };
1281
- else rect.value = entry.contentRect;
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
- node = newNode;
3662
- if (newNode) {
3663
- newNode.addEventListener("input", handleInput);
3664
- newNode.addEventListener("focus", handleFocus);
3665
- newNode.addEventListener("blur", handleBlur);
3666
- newNode.addEventListener("mousedown", handleMouseDown);
3667
- newNode.addEventListener("mouseup", handleMouseUp);
3668
- newNode.addEventListener("keydown", handleKeyDown);
3669
- newNode.addEventListener("paste", handlePaste);
3670
- setAriaAttributes(newNode);
3671
- const hasInitialValue = initializeInputValue(newNode);
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
- newNode.value = displayValue;
3684
+ inputNode.value = displayValue;
3676
3685
  display = displayValue;
3677
3686
  maskedValue.value = displayValue;
3678
3687
  }