directix 1.6.0 → 1.8.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/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * directix v1.6.0
2
+ * directix v1.8.0
3
3
  * A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
4
4
  * (c) 2021-present saqqdy <https://github.com/saqqdy>
5
5
  * Released under the MIT License.
@@ -57,7 +57,7 @@ var __async = (__this, __arguments, generator) => {
57
57
  });
58
58
  };
59
59
  /*!
60
- * directix v1.6.0
60
+ * directix v1.8.0
61
61
  * A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
62
62
  * (c) 2021-present saqqdy <https://github.com/saqqdy>
63
63
  * Released under the MIT License.
@@ -2506,14 +2506,16 @@ const vFade = defineDirective({
2506
2506
  el.style.opacity = String(options.minOpacity || 0);
2507
2507
  el.style.display = "";
2508
2508
  String(el.offsetHeight);
2509
- requestAnimationFrame(() => {
2509
+ state.animationFrame = requestAnimationFrame(() => {
2510
+ state.animationFrame = null;
2510
2511
  el.style.opacity = String(options.maxOpacity || 1);
2511
2512
  state.currentOpacity = options.maxOpacity || 1;
2512
2513
  });
2513
2514
  } else if (options.direction === "out") {
2514
2515
  el.style.opacity = String(options.maxOpacity || 1);
2515
2516
  el.style.display = "";
2516
- requestAnimationFrame(() => {
2517
+ state.animationFrame = requestAnimationFrame(() => {
2518
+ state.animationFrame = null;
2517
2519
  el.style.opacity = String(options.minOpacity || 0);
2518
2520
  setTimeout(() => {
2519
2521
  el.style.display = "none";
@@ -6657,8 +6659,8 @@ const vSanitize = defineDirective({
6657
6659
  mounted(el, binding) {
6658
6660
  if (!isBrowser()) return;
6659
6661
  const options = normalizeOptions$e(binding.value);
6660
- if (options.disabled) return;
6661
6662
  el.__sanitize = { options };
6663
+ if (options.disabled) return;
6662
6664
  const content = el.innerHTML;
6663
6665
  if (content) {
6664
6666
  el.innerHTML = sanitizeHtml(content, options);
@@ -6667,8 +6669,17 @@ const vSanitize = defineDirective({
6667
6669
  updated(el, binding) {
6668
6670
  const state = el.__sanitize;
6669
6671
  if (!state) return;
6672
+ const prevDisabled = state.options.disabled;
6670
6673
  state.options = normalizeOptions$e(binding.value);
6671
- if (state.options.disabled || !state.options.sanitizeOnUpdate) return;
6674
+ if (state.options.disabled || !state.options.sanitizeOnUpdate) {
6675
+ if (prevDisabled && !state.options.disabled) {
6676
+ const content2 = el.innerHTML;
6677
+ if (content2) {
6678
+ el.innerHTML = sanitizeHtml(content2, state.options);
6679
+ }
6680
+ }
6681
+ return;
6682
+ }
6672
6683
  const content = el.innerHTML;
6673
6684
  if (content) {
6674
6685
  el.innerHTML = sanitizeHtml(content, state.options);
@@ -7317,12 +7328,13 @@ const TOOLTIP_STYLES = {
7317
7328
  };
7318
7329
  let tooltipContainer = null;
7319
7330
  function getTooltipContainer() {
7320
- if (!tooltipContainer && typeof document !== "undefined") {
7321
- tooltipContainer = document.createElement("div");
7322
- tooltipContainer.id = "directix-tooltip-container";
7323
- tooltipContainer.style.cssText = "position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999;";
7324
- document.body.appendChild(tooltipContainer);
7331
+ if (tooltipContainer && document.body.contains(tooltipContainer)) {
7332
+ return tooltipContainer;
7325
7333
  }
7334
+ tooltipContainer = document.createElement("div");
7335
+ tooltipContainer.id = "directix-tooltip-container";
7336
+ tooltipContainer.style.cssText = "position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999;";
7337
+ document.body.appendChild(tooltipContainer);
7326
7338
  return tooltipContainer;
7327
7339
  }
7328
7340
  function createTooltip(options) {
@@ -7552,6 +7564,7 @@ const vTooltip = defineDirective({
7552
7564
  const newState = createState(newOptions);
7553
7565
  el.__tooltip = newState;
7554
7566
  setupTriggerHandlers(el, newState);
7567
+ el.setAttribute("aria-describedby", "v-tooltip");
7555
7568
  if (newOptions.trigger === "manual") {
7556
7569
  showTooltip(el, newState);
7557
7570
  }
@@ -9692,7 +9705,7 @@ function useDraggable(options = {}) {
9692
9705
  if (!isDragging.value || unref(disabled)) return;
9693
9706
  e.preventDefault();
9694
9707
  const { clientX, clientY } = getClientCoords(e);
9695
- let deltaX = clientX - startX, deltaY = clientY - startY, newX = offsetX + deltaX, newY = offsetY + deltaY;
9708
+ let deltaX = clientX - startX, deltaY = clientY - startY;
9696
9709
  const currentAxis = unref(axis);
9697
9710
  if (currentAxis === "x") {
9698
9711
  deltaY = 0;
@@ -9704,6 +9717,7 @@ function useDraggable(options = {}) {
9704
9717
  deltaX = Math.round(deltaX / currentGrid[0]) * currentGrid[0];
9705
9718
  deltaY = Math.round(deltaY / currentGrid[1]) * currentGrid[1];
9706
9719
  }
9720
+ let newX = offsetX + deltaX, newY = offsetY + deltaY;
9707
9721
  if (unref(constrain) || boundary) {
9708
9722
  const newLeft = initialLeft + deltaX;
9709
9723
  const newTop = initialTop + deltaY;
@@ -12190,6 +12204,7 @@ function getDistance(touches) {
12190
12204
  return Math.sqrt(dx * dx + dy * dy);
12191
12205
  }
12192
12206
  function getCenter$1(touches) {
12207
+ if (touches.length === 0) return { x: 0, y: 0 };
12193
12208
  if (touches.length < 2) return { x: touches[0].clientX, y: touches[0].clientY };
12194
12209
  return {
12195
12210
  x: (touches[0].clientX + touches[1].clientX) / 2,
@@ -12967,6 +12982,7 @@ function getAngle(touches) {
12967
12982
  return Math.atan2(dy, dx) * (180 / Math.PI);
12968
12983
  }
12969
12984
  function getCenter(touches) {
12985
+ if (touches.length === 0) return { x: 0, y: 0 };
12970
12986
  if (touches.length < 2) return { x: touches[0].clientX, y: touches[0].clientY };
12971
12987
  return {
12972
12988
  x: (touches[0].clientX + touches[1].clientX) / 2,