directix 1.2.0 → 1.3.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * directix v1.2.0
2
+ * directix v1.3.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.2.0
60
+ * directix v1.3.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.
@@ -76,7 +76,7 @@ var __async = (__this, __arguments, generator) => {
76
76
  },
77
77
  inserted(el, binding, vnode) {
78
78
  if (hooks.mounted) {
79
- hooks.mounted(el, normalizeBinding(binding), vnode);
79
+ hooks.mounted(el, normalizeBinding$1(binding), vnode);
80
80
  }
81
81
  },
82
82
  update(el, binding, vnode, oldVnode) {
@@ -84,9 +84,9 @@ var __async = (__this, __arguments, generator) => {
84
84
  if (hooks.updated) {
85
85
  hooks.updated(
86
86
  el,
87
- normalizeBinding(binding),
87
+ normalizeBinding$1(binding),
88
88
  vnode,
89
- normalizeBinding(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
89
+ normalizeBinding$1(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
90
90
  oldVnode
91
91
  );
92
92
  }
@@ -99,7 +99,7 @@ var __async = (__this, __arguments, generator) => {
99
99
  },
100
100
  unbind(el, binding, vnode) {
101
101
  if (hooks.unmounted) {
102
- hooks.unmounted(el, normalizeBinding(binding), vnode);
102
+ hooks.unmounted(el, normalizeBinding$1(binding), vnode);
103
103
  }
104
104
  const state = el.__directix_state__;
105
105
  if (state == null ? void 0 : state.cleanup) {
@@ -110,7 +110,7 @@ var __async = (__this, __arguments, generator) => {
110
110
  };
111
111
  return directive;
112
112
  }
113
- function normalizeBinding(binding) {
113
+ function normalizeBinding$1(binding) {
114
114
  var _a;
115
115
  return {
116
116
  value: binding.value,
@@ -483,7 +483,7 @@ var __async = (__this, __arguments, generator) => {
483
483
  if (!word) return word;
484
484
  return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
485
485
  }
486
- function normalizeOptions$t(binding) {
486
+ function normalizeOptions$B(binding) {
487
487
  var _a, _b, _c;
488
488
  if (binding === void 0 || binding === true) {
489
489
  return { every: true, onInput: true };
@@ -501,7 +501,7 @@ var __async = (__this, __arguments, generator) => {
501
501
  name: "capitalcase",
502
502
  ssr: true,
503
503
  mounted(el, binding) {
504
- const options = normalizeOptions$t(binding.value);
504
+ const options = normalizeOptions$B(binding.value);
505
505
  if (isInputElement(el)) {
506
506
  const cleanup2 = setupTextTransformInput(el, options, (text) => capitalizeText(text, options));
507
507
  el.__capitalcaseCleanup = cleanup2;
@@ -510,7 +510,7 @@ var __async = (__this, __arguments, generator) => {
510
510
  }
511
511
  },
512
512
  updated(el, binding) {
513
- const options = normalizeOptions$t(binding.value);
513
+ const options = normalizeOptions$B(binding.value);
514
514
  if (isInputElement(el)) {
515
515
  if (options.onInput) {
516
516
  el.value = capitalizeText(el.value, options);
@@ -525,6 +525,134 @@ var __async = (__this, __arguments, generator) => {
525
525
  delete el.__capitalcaseCleanup;
526
526
  }
527
527
  });
528
+ const vClickDelay = defineDirective({
529
+ name: "click-delay",
530
+ ssr: true,
531
+ defaults: {
532
+ delay: 300,
533
+ disabled: false,
534
+ pendingClass: "v-click-delay--pending",
535
+ feedback: true
536
+ },
537
+ mounted(el, binding) {
538
+ const options = normalizeOptions$A(binding.value, binding);
539
+ if (options.disabled) return;
540
+ const state = {
541
+ options,
542
+ handler: createClickHandler(el, options),
543
+ isPending: false,
544
+ timeoutId: null
545
+ };
546
+ el.__clickDelay = state;
547
+ el.addEventListener("click", state.handler);
548
+ el.addEventListener("touchend", state.handler);
549
+ },
550
+ updated(el, binding) {
551
+ const state = el.__clickDelay;
552
+ if (!state) {
553
+ const options = normalizeOptions$A(binding.value, binding);
554
+ if (!options.disabled) {
555
+ const newState = {
556
+ options,
557
+ handler: createClickHandler(el, options),
558
+ isPending: false,
559
+ timeoutId: null
560
+ };
561
+ el.__clickDelay = newState;
562
+ el.addEventListener("click", newState.handler);
563
+ el.addEventListener("touchend", newState.handler);
564
+ }
565
+ return;
566
+ }
567
+ const newOptions = normalizeOptions$A(binding.value, binding);
568
+ if (newOptions.disabled && !state.options.disabled) {
569
+ el.removeEventListener("click", state.handler);
570
+ el.removeEventListener("touchend", state.handler);
571
+ if (state.timeoutId) {
572
+ clearTimeout(state.timeoutId);
573
+ }
574
+ removePendingClass(el, state.options);
575
+ delete el.__clickDelay;
576
+ } else if (!newOptions.disabled && state.options.disabled) {
577
+ state.handler = createClickHandler(el, newOptions);
578
+ state.isPending = false;
579
+ state.timeoutId = null;
580
+ el.addEventListener("click", state.handler);
581
+ el.addEventListener("touchend", state.handler);
582
+ }
583
+ state.options = newOptions;
584
+ },
585
+ unmounted(el) {
586
+ const state = el.__clickDelay;
587
+ if (!state) return;
588
+ el.removeEventListener("click", state.handler);
589
+ el.removeEventListener("touchend", state.handler);
590
+ if (state.timeoutId) {
591
+ clearTimeout(state.timeoutId);
592
+ }
593
+ removePendingClass(el, state.options);
594
+ delete el.__clickDelay;
595
+ }
596
+ });
597
+ function createClickHandler(el, options) {
598
+ return (event) => {
599
+ const state = el.__clickDelay;
600
+ if (!state || state.isPending) {
601
+ event.preventDefault();
602
+ event.stopPropagation();
603
+ return;
604
+ }
605
+ state.isPending = true;
606
+ if (options.feedback && options.pendingClass) {
607
+ el.classList.add(options.pendingClass);
608
+ }
609
+ options.handler(event);
610
+ state.timeoutId = setTimeout(() => {
611
+ state.isPending = false;
612
+ state.timeoutId = null;
613
+ removePendingClass(el, options);
614
+ }, options.delay);
615
+ };
616
+ }
617
+ function removePendingClass(el, options) {
618
+ if (options.feedback && options.pendingClass) {
619
+ el.classList.remove(options.pendingClass);
620
+ }
621
+ }
622
+ function parseTime$1(arg) {
623
+ if (!arg) return null;
624
+ if (arg.endsWith("ms")) {
625
+ return parseInt(arg, 10);
626
+ }
627
+ if (arg.endsWith("s")) {
628
+ return parseFloat(arg) * 1e3;
629
+ }
630
+ const num = parseInt(arg, 10);
631
+ return Number.isNaN(num) ? null : num;
632
+ }
633
+ function normalizeOptions$A(binding, directiveBinding) {
634
+ var _a, _b, _c, _d;
635
+ const delay = parseTime$1(directiveBinding.arg) || 300;
636
+ if (typeof binding === "function") {
637
+ return {
638
+ handler: binding,
639
+ delay,
640
+ disabled: false,
641
+ pendingClass: "v-click-delay--pending",
642
+ feedback: true
643
+ };
644
+ }
645
+ if (!binding) {
646
+ throw new Error("[Directix] v-click-delay: handler is required");
647
+ }
648
+ return {
649
+ handler: binding.handler,
650
+ delay: (_a = binding.delay) != null ? _a : delay,
651
+ disabled: (_b = binding.disabled) != null ? _b : false,
652
+ pendingClass: (_c = binding.pendingClass) != null ? _c : "v-click-delay--pending",
653
+ feedback: (_d = binding.feedback) != null ? _d : true
654
+ };
655
+ }
528
656
  function isElement(value) {
529
657
  return value instanceof Element;
530
658
  }
@@ -550,15 +678,15 @@ var __async = (__this, __arguments, generator) => {
550
678
  }
551
679
  function on(target, event, handler, options = false) {
552
680
  if (!isBrowser()) return;
553
- const opts = normalizeOptions$s(options);
681
+ const opts = normalizeOptions$z(options);
554
682
  target.addEventListener(event, handler, opts);
555
683
  }
556
684
  function off(target, event, handler, options = false) {
557
685
  if (!isBrowser()) return;
558
- const opts = normalizeOptions$s(options);
686
+ const opts = normalizeOptions$z(options);
559
687
  target.removeEventListener(event, handler, opts);
560
688
  }
561
- function normalizeOptions$s(options) {
689
+ function normalizeOptions$z(options) {
562
690
  if (typeof options === "boolean") {
563
691
  return options;
564
692
  }
@@ -781,7 +909,7 @@ var __async = (__this, __arguments, generator) => {
781
909
  prevent: false
782
910
  },
783
911
  mounted(el, binding) {
784
- const options = normalizeOptions$r(binding.value);
912
+ const options = normalizeOptions$y(binding.value);
785
913
  if (options.disabled) return;
786
914
  const state = {
787
915
  options,
@@ -816,7 +944,7 @@ var __async = (__this, __arguments, generator) => {
816
944
  const state = el.__clickOutside;
817
945
  if (!state) return;
818
946
  const oldOptions = state.options;
819
- const newOptions = normalizeOptions$r(binding.value);
947
+ const newOptions = normalizeOptions$y(binding.value);
820
948
  if (oldOptions.disabled !== newOptions.disabled) {
821
949
  if (newOptions.disabled) {
822
950
  state.handlers.forEach((handler, eventType) => {
@@ -853,7 +981,7 @@ var __async = (__this, __arguments, generator) => {
853
981
  delete el.__clickOutside;
854
982
  }
855
983
  });
856
- function normalizeOptions$r(binding) {
984
+ function normalizeOptions$y(binding) {
857
985
  var _a, _b, _c, _d, _e;
858
986
  if (typeof binding === "function") {
859
987
  return {
@@ -930,7 +1058,7 @@ var __async = (__this, __arguments, generator) => {
930
1058
  name: "copy",
931
1059
  ssr: false,
932
1060
  mounted(el, binding) {
933
- const options = normalizeOptions$q(binding.value);
1061
+ const options = normalizeOptions$x(binding.value);
934
1062
  if (options.disabled) return;
935
1063
  if (options.title) {
936
1064
  el.setAttribute("title", options.title);
@@ -966,7 +1094,7 @@ var __async = (__this, __arguments, generator) => {
966
1094
  updated(el, binding) {
967
1095
  const state = el.__copy;
968
1096
  if (!state) return;
969
- state.options = normalizeOptions$q(binding.value);
1097
+ state.options = normalizeOptions$x(binding.value);
970
1098
  if (state.options.title) {
971
1099
  el.setAttribute("title", state.options.title);
972
1100
  }
@@ -978,12 +1106,142 @@ var __async = (__this, __arguments, generator) => {
978
1106
  delete el.__copy;
979
1107
  }
980
1108
  });
981
- function normalizeOptions$q(binding) {
1109
+ function normalizeOptions$x(binding) {
982
1110
  if (typeof binding === "string") {
983
1111
  return { value: binding };
984
1112
  }
985
1113
  return binding;
986
1114
  }
1115
+ function parseTargetTime(target) {
1116
+ if (target instanceof Date) {
1117
+ return target.getTime();
1118
+ }
1119
+ if (typeof target === "number") {
1120
+ return target;
1121
+ }
1122
+ return new Date(target).getTime();
1123
+ }
1124
+ function calculateTime(remaining) {
1125
+ const total = Math.max(0, remaining);
1126
+ return {
1127
+ days: Math.floor(total / (1e3 * 60 * 60 * 24)),
1128
+ hours: Math.floor(total % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60)),
1129
+ minutes: Math.floor(total % (1e3 * 60 * 60) / (1e3 * 60)),
1130
+ seconds: Math.floor(total % (1e3 * 60) / 1e3),
1131
+ milliseconds: total % 1e3,
1132
+ total
1133
+ };
1134
+ }
1135
+ function formatTime(time, format) {
1136
+ if (typeof format === "function") {
1137
+ return format(time);
1138
+ }
1139
+ const pad = (n, len = 2) => String(n).padStart(len, "0");
1140
+ const result = format.replace(/dd/gi, pad(time.days)).replace(/hh/gi, pad(time.hours)).replace(/mm/gi, pad(time.minutes)).replace(/ss/gi, pad(time.seconds)).replace(/S{3}/gi, pad(time.milliseconds, 3)).replace(/SS/gi, pad(Math.floor(time.milliseconds / 10))).replace(/S/gi, String(Math.floor(time.milliseconds / 100)));
1141
+ return result;
1142
+ }
1143
+ function normalizeOptions$w(binding) {
1144
+ var _a, _b, _c, _d;
1145
+ if (typeof binding === "object" && binding !== null && "target" in binding) {
1146
+ return {
1147
+ target: binding.target,
1148
+ format: (_a = binding.format) != null ? _a : "hh:mm:ss",
1149
+ onComplete: binding.onComplete,
1150
+ onTick: binding.onTick,
1151
+ interval: (_b = binding.interval) != null ? _b : 1e3,
1152
+ showMilliseconds: (_c = binding.showMilliseconds) != null ? _c : false,
1153
+ autoStart: (_d = binding.autoStart) != null ? _d : true,
1154
+ labels: binding.labels
1155
+ };
1156
+ }
1157
+ return {
1158
+ target: binding,
1159
+ format: "hh:mm:ss",
1160
+ interval: 1e3,
1161
+ showMilliseconds: false,
1162
+ autoStart: true
1163
+ };
1164
+ }
1165
+ const vCountdown = defineDirective({
1166
+ name: "countdown",
1167
+ ssr: true,
1168
+ mounted(el, binding) {
1169
+ const options = normalizeOptions$w(binding.value);
1170
+ const targetTime = parseTargetTime(options.target);
1171
+ const state = {
1172
+ options,
1173
+ targetTime,
1174
+ intervalId: null,
1175
+ paused: false,
1176
+ remaining: 0
1177
+ };
1178
+ el.__countdown = state;
1179
+ if (options.autoStart !== false) {
1180
+ startCountdown(el, state);
1181
+ } else {
1182
+ updateDisplay(el, state);
1183
+ }
1184
+ },
1185
+ updated(el, binding) {
1186
+ const state = el.__countdown;
1187
+ const newOptions = normalizeOptions$w(binding.value);
1188
+ const newTargetTime = parseTargetTime(newOptions.target);
1189
+ if (newTargetTime !== state.targetTime) {
1190
+ state.targetTime = newTargetTime;
1191
+ state.options = newOptions;
1192
+ if (state.intervalId) {
1193
+ clearInterval(state.intervalId);
1194
+ state.intervalId = null;
1195
+ }
1196
+ if (!state.paused) {
1197
+ startCountdown(el, state);
1198
+ }
1199
+ } else {
1200
+ state.options = newOptions;
1201
+ }
1202
+ },
1203
+ unmounted(el) {
1204
+ const state = el.__countdown;
1205
+ if (state == null ? void 0 : state.intervalId) {
1206
+ clearInterval(state.intervalId);
1207
+ }
1208
+ delete el.__countdown;
1209
+ }
1210
+ });
1211
+ function startCountdown(el, state) {
1212
+ const tick = () => {
1213
+ const now = Date.now();
1214
+ state.remaining = state.targetTime - now;
1215
+ if (state.remaining <= 0) {
1216
+ state.remaining = 0;
1217
+ updateDisplay(el, state);
1218
+ stopCountdown(state);
1219
+ if (state.options.onComplete) {
1220
+ state.options.onComplete();
1221
+ }
1222
+ el.dispatchEvent(new CustomEvent("countdown:complete"));
1223
+ return;
1224
+ }
1225
+ updateDisplay(el, state);
1226
+ if (state.options.onTick) {
1227
+ const time = calculateTime(state.remaining);
1228
+ state.options.onTick(time);
1229
+ }
1230
+ };
1231
+ tick();
1232
+ state.intervalId = setInterval(tick, state.options.interval || 1e3);
1233
+ }
1234
+ function stopCountdown(state) {
1235
+ if (state.intervalId) {
1236
+ clearInterval(state.intervalId);
1237
+ state.intervalId = null;
1238
+ }
1239
+ }
1240
+ function updateDisplay(el, state) {
1241
+ const time = calculateTime(state.remaining);
1242
+ const display = formatTime(time, state.options.format || "hh:mm:ss");
1243
+ el.textContent = display;
1244
+ }
987
1245
  const EVENT_MODIFIERS = [
988
1246
  "click",
989
1247
  "input",
@@ -1019,7 +1277,7 @@ var __async = (__this, __arguments, generator) => {
1019
1277
  }
1020
1278
  return "click";
1021
1279
  }
1022
- function normalizeOptions$p(binding, directiveBinding) {
1280
+ function normalizeOptions$v(binding, directiveBinding) {
1023
1281
  const wait = parseTime(directiveBinding.arg) || 300;
1024
1282
  if (typeof binding === "function") {
1025
1283
  return { handler: binding, wait };
@@ -1036,7 +1294,7 @@ var __async = (__this, __arguments, generator) => {
1036
1294
  trailing: true
1037
1295
  },
1038
1296
  mounted(el, binding) {
1039
- const options = normalizeOptions$p(binding.value, binding);
1297
+ const options = normalizeOptions$v(binding.value, binding);
1040
1298
  const eventType = getEventTypeFromModifiers(binding.modifiers) || getDefaultEventType(el);
1041
1299
  const debouncedFn = debounce(options.handler, options.wait, {
1042
1300
  leading: options.leading,
@@ -1052,7 +1310,7 @@ var __async = (__this, __arguments, generator) => {
1052
1310
  updated(el, binding) {
1053
1311
  const state = el.__debounce;
1054
1312
  if (!state) return;
1055
- const newOptions = normalizeOptions$p(binding.value, binding);
1313
+ const newOptions = normalizeOptions$v(binding.value, binding);
1056
1314
  if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
1057
1315
  state.debouncedFn.cancel();
1058
1316
  const debouncedFn = debounce(newOptions.handler, newOptions.wait, {
@@ -1106,7 +1364,7 @@ var __async = (__this, __arguments, generator) => {
1106
1364
  }
1107
1365
  return { x: 0, y: 0 };
1108
1366
  }
1109
- function normalizeOptions$o(binding) {
1367
+ function normalizeOptions$u(binding) {
1110
1368
  var _a, _b, _c;
1111
1369
  if (binding === void 0 || binding === true) {
1112
1370
  return { axis: "both", constrain: false, disabled: false };
@@ -1130,7 +1388,7 @@ var __async = (__this, __arguments, generator) => {
1130
1388
  name: "draggable",
1131
1389
  ssr: false,
1132
1390
  mounted(el, binding) {
1133
- const options = normalizeOptions$o(binding.value);
1391
+ const options = normalizeOptions$u(binding.value);
1134
1392
  if (options.disabled) return;
1135
1393
  if (getComputedStyle(el).position === "static") {
1136
1394
  el.style.position = "absolute";
@@ -1236,7 +1494,7 @@ var __async = (__this, __arguments, generator) => {
1236
1494
  updated(el, binding) {
1237
1495
  const state = el.__draggable;
1238
1496
  if (!state) return;
1239
- state.options = normalizeOptions$o(binding.value);
1497
+ state.options = normalizeOptions$u(binding.value);
1240
1498
  if (state.options.handle) {
1241
1499
  state.handleEl = el.querySelector(state.options.handle);
1242
1500
  }
@@ -1255,6 +1513,150 @@ var __async = (__this, __arguments, generator) => {
1255
1513
  delete el.__draggable;
1256
1514
  }
1257
1515
  });
1516
+ const vEllipsis = defineDirective({
1517
+ name: "ellipsis",
1518
+ ssr: true,
1519
+ defaults: {
1520
+ lines: 1,
1521
+ ellipsis: "...",
1522
+ expandable: false,
1523
+ titleBehavior: "auto"
1524
+ },
1525
+ mounted(el, binding) {
1526
+ const options = normalizeOptions$t(binding.value);
1527
+ applyEllipsis(el, options);
1528
+ const state = {
1529
+ options,
1530
+ originalText: el.textContent || "",
1531
+ clickHandler: null,
1532
+ expanded: false
1533
+ };
1534
+ if (options.expandable) {
1535
+ const handler = () => {
1536
+ if (state.expanded) {
1537
+ applyEllipsis(el, options);
1538
+ state.expanded = false;
1539
+ } else {
1540
+ el.textContent = state.originalText;
1541
+ el.style.webkitLineClamp = "";
1542
+ el.style.display = "";
1543
+ el.style.overflow = "";
1544
+ el.style.cursor = "";
1545
+ state.expanded = true;
1546
+ }
1547
+ };
1548
+ el.addEventListener("click", handler);
1549
+ el.style.cursor = "pointer";
1550
+ state.clickHandler = handler;
1551
+ }
1552
+ if (options.titleBehavior === "always") {
1553
+ el.title = state.originalText;
1554
+ } else if (options.titleBehavior === "auto") {
1555
+ if (isTextTruncated(el)) {
1556
+ el.title = state.originalText;
1557
+ }
1558
+ }
1559
+ el.__ellipsis = state;
1560
+ },
1561
+ updated(el, binding) {
1562
+ const state = el.__ellipsis;
1563
+ if (!state) {
1564
+ const options = normalizeOptions$t(binding.value);
1565
+ applyEllipsis(el, options);
1566
+ return;
1567
+ }
1568
+ const newOptions = normalizeOptions$t(binding.value);
1569
+ const textChanged = el.textContent !== state.originalText;
1570
+ if (textChanged) {
1571
+ state.originalText = el.textContent || "";
1572
+ state.expanded = false;
1573
+ }
1574
+ if (state.options.expandable !== newOptions.expandable) {
1575
+ if (state.clickHandler) {
1576
+ el.removeEventListener("click", state.clickHandler);
1577
+ state.clickHandler = null;
1578
+ }
1579
+ if (newOptions.expandable) {
1580
+ const handler = () => {
1581
+ if (state.expanded) {
1582
+ applyEllipsis(el, newOptions);
1583
+ state.expanded = false;
1584
+ } else {
1585
+ el.textContent = state.originalText;
1586
+ el.style.webkitLineClamp = "";
1587
+ el.style.display = "";
1588
+ el.style.overflow = "";
1589
+ state.expanded = true;
1590
+ }
1591
+ };
1592
+ el.addEventListener("click", handler);
1593
+ el.style.cursor = "pointer";
1594
+ state.clickHandler = handler;
1595
+ } else {
1596
+ el.style.cursor = "";
1597
+ }
1598
+ }
1599
+ state.options = newOptions;
1600
+ if (!state.expanded) {
1601
+ applyEllipsis(el, newOptions);
1602
+ }
1603
+ if (newOptions.titleBehavior === "always") {
1604
+ el.title = state.originalText;
1605
+ } else if (newOptions.titleBehavior === "auto") {
1606
+ el.title = isTextTruncated(el) ? state.originalText : "";
1607
+ } else {
1608
+ el.removeAttribute("title");
1609
+ }
1610
+ },
1611
+ unmounted(el) {
1612
+ const state = el.__ellipsis;
1613
+ if (!state) return;
1614
+ if (state.clickHandler) {
1615
+ el.removeEventListener("click", state.clickHandler);
1616
+ }
1617
+ el.style.removeProperty("-webkit-line-clamp");
1618
+ el.style.removeProperty("-webkit-box-orient");
1619
+ el.style.removeProperty("display");
1620
+ el.style.removeProperty("overflow");
1621
+ el.style.removeProperty("text-overflow");
1622
+ el.style.removeProperty("white-space");
1623
+ el.style.removeProperty("cursor");
1624
+ delete el.__ellipsis;
1625
+ }
1626
+ });
1627
+ function applyEllipsis(el, options) {
1628
+ const lines = options.lines || 1;
1629
+ if (lines === 1) {
1630
+ el.style.overflow = "hidden";
1631
+ el.style.textOverflow = "ellipsis";
1632
+ el.style.whiteSpace = "nowrap";
1633
+ } else {
1634
+ el.style.display = "-webkit-box";
1635
+ el.style.overflow = "hidden";
1636
+ el.style.webkitBoxOrient = "vertical";
1637
+ el.style.webkitLineClamp = String(lines);
1638
+ }
1639
+ }
1640
+ function isTextTruncated(el) {
1641
+ return el.scrollWidth > el.clientWidth || el.scrollHeight > el.clientHeight;
1642
+ }
1643
+ function normalizeOptions$t(binding) {
1644
+ var _a, _b, _c, _d;
1645
+ if (typeof binding === "number") {
1646
+ return {
1647
+ lines: binding,
1648
+ ellipsis: "...",
1649
+ expandable: false,
1650
+ titleBehavior: "auto"
1651
+ };
1652
+ }
1653
+ return {
1654
+ lines: (_a = binding == null ? void 0 : binding.lines) != null ? _a : 1,
1655
+ ellipsis: (_b = binding == null ? void 0 : binding.ellipsis) != null ? _b : "...",
1656
+ expandable: (_c = binding == null ? void 0 : binding.expandable) != null ? _c : false,
1657
+ titleBehavior: (_d = binding == null ? void 0 : binding.titleBehavior) != null ? _d : "auto"
1658
+ };
1659
+ }
1258
1660
  const FOCUSABLE_TAGS = /* @__PURE__ */ new Set(["input", "textarea", "select", "button"]);
1259
1661
  function isEqual(a, b) {
1260
1662
  if (a === b) return true;
@@ -1276,7 +1678,7 @@ var __async = (__this, __arguments, generator) => {
1276
1678
  },
1277
1679
  mounted(el, binding) {
1278
1680
  if (!isBrowser()) return;
1279
- const options = normalizeOptions$n(binding.value);
1681
+ const options = normalizeOptions$s(binding.value);
1280
1682
  if (!options.focus || !isFocusable(el)) {
1281
1683
  if (options.focus) {
1282
1684
  console.warn("[Directix] v-focus: Element is not focusable");
@@ -1304,7 +1706,7 @@ var __async = (__this, __arguments, generator) => {
1304
1706
  updated(el, binding) {
1305
1707
  const state = el.__focus;
1306
1708
  if (!state) return;
1307
- const newOptions = normalizeOptions$n(binding.value);
1709
+ const newOptions = normalizeOptions$s(binding.value);
1308
1710
  if (newOptions.onFocus !== state.options.onFocus) {
1309
1711
  el.removeEventListener("focus", state.handleFocus);
1310
1712
  state.handleFocus = () => {
@@ -1336,7 +1738,7 @@ var __async = (__this, __arguments, generator) => {
1336
1738
  delete el.__focus;
1337
1739
  }
1338
1740
  });
1339
- function normalizeOptions$n(binding) {
1741
+ function normalizeOptions$s(binding) {
1340
1742
  if (typeof binding === "boolean") {
1341
1743
  return { focus: binding, refocus: false };
1342
1744
  }
@@ -1359,7 +1761,181 @@ var __async = (__this, __arguments, generator) => {
1359
1761
  }
1360
1762
  return false;
1361
1763
  }
1362
- function normalizeOptions$m(binding) {
1764
+ const KEY_ALIASES = {
1765
+ esc: "escape",
1766
+ space: " ",
1767
+ up: "arrowup",
1768
+ down: "arrowdown",
1769
+ left: "arrowleft",
1770
+ right: "arrowright",
1771
+ enter: "enter",
1772
+ tab: "tab",
1773
+ delete: "delete",
1774
+ backspace: "backspace",
1775
+ insert: "insert",
1776
+ home: "home",
1777
+ end: "end",
1778
+ pagedown: "pagedown",
1779
+ pageup: "pageup",
1780
+ f1: "f1",
1781
+ f2: "f2",
1782
+ f3: "f3",
1783
+ f4: "f4",
1784
+ f5: "f5",
1785
+ f6: "f6",
1786
+ f7: "f7",
1787
+ f8: "f8",
1788
+ f9: "f9",
1789
+ f10: "f10",
1790
+ f11: "f11",
1791
+ f12: "f12"
1792
+ };
1793
+ const MODIFIER_KEYS = /* @__PURE__ */ new Set(["ctrl", "alt", "shift", "meta"]);
1794
+ function normalizeKey(key) {
1795
+ const lowerKey = key.toLowerCase();
1796
+ return KEY_ALIASES[lowerKey] || lowerKey;
1797
+ }
1798
+ function parseHotkeyString(hotkey) {
1799
+ const parts = hotkey.toLowerCase().split(/[+.]/);
1800
+ const modifiers = [];
1801
+ let key = "";
1802
+ for (const part of parts) {
1803
+ if (MODIFIER_KEYS.has(part)) {
1804
+ modifiers.push(part);
1805
+ } else {
1806
+ key = normalizeKey(part);
1807
+ }
1808
+ }
1809
+ return { key, modifiers };
1810
+ }
1811
+ function matchesHotkey(event, entry) {
1812
+ if (normalizeKey(event.key) !== entry.key) return false;
1813
+ const eventModifiers = /* @__PURE__ */ new Set();
1814
+ if (event.ctrlKey) eventModifiers.add("ctrl");
1815
+ if (event.altKey) eventModifiers.add("alt");
1816
+ if (event.shiftKey) eventModifiers.add("shift");
1817
+ if (event.metaKey) eventModifiers.add("meta");
1818
+ if (eventModifiers.size !== entry.modifiers.size) return false;
1819
+ for (const mod of entry.modifiers) {
1820
+ if (!eventModifiers.has(mod)) return false;
1821
+ }
1822
+ return true;
1823
+ }
1824
+ function createEntry(key, modifiers, handler, options = {}) {
1825
+ var _a, _b, _c;
1826
+ return {
1827
+ key: normalizeKey(key),
1828
+ modifiers: new Set(modifiers),
1829
+ handler,
1830
+ prevent: (_a = options.prevent) != null ? _a : true,
1831
+ stop: (_b = options.stop) != null ? _b : true,
1832
+ disabled: (_c = options.disabled) != null ? _c : false
1833
+ };
1834
+ }
1835
+ function normalizeBinding(binding, arg, modifiers) {
1836
+ if (arg) {
1837
+ const argLower = arg.toLowerCase();
1838
+ const argIsModifier = MODIFIER_KEYS.has(argLower);
1839
+ let key;
1840
+ const parsedModifiers = [];
1841
+ if (argIsModifier) {
1842
+ parsedModifiers.push(argLower);
1843
+ for (const mod of Object.keys(modifiers)) {
1844
+ const modLower = mod.toLowerCase();
1845
+ if (MODIFIER_KEYS.has(modLower)) {
1846
+ parsedModifiers.push(modLower);
1847
+ } else {
1848
+ key = normalizeKey(mod);
1849
+ }
1850
+ }
1851
+ } else {
1852
+ const parsed = parseHotkeyString(arg);
1853
+ key = parsed.key;
1854
+ parsedModifiers.push(...parsed.modifiers);
1855
+ for (const mod of Object.keys(modifiers)) {
1856
+ const modLower = mod.toLowerCase();
1857
+ if (MODIFIER_KEYS.has(modLower)) {
1858
+ parsedModifiers.push(modLower);
1859
+ }
1860
+ }
1861
+ }
1862
+ const handler = typeof binding === "function" ? binding : binding.handler;
1863
+ return [createEntry(key, parsedModifiers, handler)];
1864
+ }
1865
+ if (typeof binding === "function") {
1866
+ console.warn('[Directix] v-hotkey: hotkey definition required (use v-hotkey:ctrl.s="handler")');
1867
+ return [];
1868
+ }
1869
+ if (Array.isArray(binding)) {
1870
+ return binding.map(
1871
+ (item) => createEntry(item.key, item.modifiers || [], item.handler, {
1872
+ prevent: item.prevent,
1873
+ stop: item.stop,
1874
+ disabled: item.disabled
1875
+ })
1876
+ );
1877
+ }
1878
+ if (typeof binding === "object" && binding !== null) {
1879
+ if ("handler" in binding && typeof binding.handler === "function") {
1880
+ const def = binding;
1881
+ return [createEntry(def.key, def.modifiers || [], def.handler, def)];
1882
+ }
1883
+ const entries = [];
1884
+ for (const [hotkeyStr, value] of Object.entries(binding)) {
1885
+ const { key, modifiers: parsedModifiers } = parseHotkeyString(hotkeyStr);
1886
+ const handler = typeof value === "function" ? value : value.handler;
1887
+ const options = typeof value === "object" ? value : {};
1888
+ entries.push(createEntry(key, parsedModifiers, handler, options));
1889
+ }
1890
+ return entries;
1891
+ }
1892
+ return [];
1893
+ }
1894
+ function createKeydownHandler(state) {
1895
+ return (event) => {
1896
+ for (const entry of state.entries) {
1897
+ if (entry.disabled) continue;
1898
+ if (!matchesHotkey(event, entry)) continue;
1899
+ if (entry.prevent) event.preventDefault();
1900
+ if (entry.stop) event.stopPropagation();
1901
+ entry.handler(event);
1902
+ return;
1903
+ }
1904
+ };
1905
+ }
1906
+ function setupState$1(el, entries) {
1907
+ if (entries.length === 0) return null;
1908
+ const state = { entries, handler: null };
1909
+ state.handler = createKeydownHandler(state);
1910
+ el.tabIndex = el.tabIndex || -1;
1911
+ el.addEventListener("keydown", state.handler);
1912
+ el.__hotkey = state;
1913
+ return state;
1914
+ }
1915
+ const vHotkey = defineDirective({
1916
+ name: "hotkey",
1917
+ ssr: true,
1918
+ mounted(el, binding) {
1919
+ const entries = normalizeBinding(binding.value, binding.arg, binding.modifiers);
1920
+ setupState$1(el, entries);
1921
+ },
1922
+ updated(el, binding) {
1923
+ const state = el.__hotkey;
1924
+ const newEntries = normalizeBinding(binding.value, binding.arg, binding.modifiers);
1925
+ if (state) {
1926
+ state.entries = newEntries;
1927
+ } else {
1928
+ setupState$1(el, newEntries);
1929
+ }
1930
+ },
1931
+ unmounted(el) {
1932
+ const state = el.__hotkey;
1933
+ if (!state) return;
1934
+ el.removeEventListener("keydown", state.handler);
1935
+ delete el.__hotkey;
1936
+ }
1937
+ });
1938
+ function normalizeOptions$r(binding) {
1363
1939
  if (typeof binding === "function") {
1364
1940
  return { handler: binding, class: "v-hover" };
1365
1941
  }
@@ -1380,7 +1956,7 @@ var __async = (__this, __arguments, generator) => {
1380
1956
  leaveDelay: 0
1381
1957
  },
1382
1958
  mounted(el, binding) {
1383
- const options = normalizeOptions$m(binding.value);
1959
+ const options = normalizeOptions$r(binding.value);
1384
1960
  if (options.disabled || !isBrowser()) return;
1385
1961
  const state = {
1386
1962
  options,
@@ -1433,7 +2009,7 @@ var __async = (__this, __arguments, generator) => {
1433
2009
  updated(el, binding) {
1434
2010
  const state = el.__hover;
1435
2011
  if (!state) return;
1436
- const newOptions = normalizeOptions$m(binding.value);
2012
+ const newOptions = normalizeOptions$r(binding.value);
1437
2013
  if (newOptions.disabled && !state.options.disabled) {
1438
2014
  el.classList.remove(state.options.class || "v-hover");
1439
2015
  } else if (!newOptions.disabled && state.options.disabled) ;
@@ -1746,7 +2322,7 @@ var __async = (__this, __arguments, generator) => {
1746
2322
  };
1747
2323
  return { handleTouchStart, handleTouchMove, handleTouchEnd, handleMouseDown, handleMouseMove, handleMouseUp, handleWheel };
1748
2324
  }
1749
- function normalizeOptions$l(binding, el) {
2325
+ function normalizeOptions$q(binding, el) {
1750
2326
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1751
2327
  const elSrc = el.tagName === "IMG" ? el.src : void 0;
1752
2328
  const elPreviewSrc = el.getAttribute("data-preview") || void 0;
@@ -1791,7 +2367,7 @@ var __async = (__this, __arguments, generator) => {
1791
2367
  name: "image-preview",
1792
2368
  ssr: false,
1793
2369
  mounted(el, binding) {
1794
- const options = normalizeOptions$l(binding.value, el);
2370
+ const options = normalizeOptions$q(binding.value, el);
1795
2371
  const state = {
1796
2372
  options,
1797
2373
  overlay: null,
@@ -1905,7 +2481,7 @@ var __async = (__this, __arguments, generator) => {
1905
2481
  updated(el, binding) {
1906
2482
  const state = el.__imagePreview;
1907
2483
  if (!state) return;
1908
- state.options = normalizeOptions$l(binding.value, el);
2484
+ state.options = normalizeOptions$q(binding.value, el);
1909
2485
  el.style.cursor = state.options.disabled ? "" : "zoom-in";
1910
2486
  },
1911
2487
  unmounted(el) {
@@ -1927,7 +2503,7 @@ var __async = (__this, __arguments, generator) => {
1927
2503
  delete el.__imagePreview;
1928
2504
  }
1929
2505
  });
1930
- function normalizeOptions$k(binding) {
2506
+ function normalizeOptions$p(binding) {
1931
2507
  if (typeof binding === "function") {
1932
2508
  return { handler: binding, distance: 0, throttle: 200, useIntersection: true };
1933
2509
  }
@@ -1953,7 +2529,7 @@ var __async = (__this, __arguments, generator) => {
1953
2529
  throttle: 200
1954
2530
  },
1955
2531
  mounted(el, binding) {
1956
- const options = normalizeOptions$k(binding.value);
2532
+ const options = normalizeOptions$p(binding.value);
1957
2533
  if (options.disabled || !isBrowser()) return;
1958
2534
  let container;
1959
2535
  if (options.container) {
@@ -1999,7 +2575,7 @@ var __async = (__this, __arguments, generator) => {
1999
2575
  updated(el, binding) {
2000
2576
  const state = el.__infiniteScroll;
2001
2577
  if (!state) return;
2002
- state.options = normalizeOptions$k(binding.value);
2578
+ state.options = normalizeOptions$p(binding.value);
2003
2579
  },
2004
2580
  unmounted(el) {
2005
2581
  const state = el.__infiniteScroll;
@@ -2076,7 +2652,7 @@ var __async = (__this, __arguments, generator) => {
2076
2652
  state.observer.observe(sentinel);
2077
2653
  }
2078
2654
  const STATE_KEY$3 = "__intersect";
2079
- function normalizeOptions$j(binding) {
2655
+ function normalizeOptions$o(binding) {
2080
2656
  const options = typeof binding === "function" ? { handler: binding } : __spreadValues({}, binding);
2081
2657
  if (options.root !== null && typeof options.root === "object" && "value" in options.root) {
2082
2658
  options.root = options.root.value;
@@ -2118,7 +2694,7 @@ var __async = (__this, __arguments, generator) => {
2118
2694
  threshold: 0
2119
2695
  },
2120
2696
  mounted(el, binding) {
2121
- const options = normalizeOptions$j(binding.value);
2697
+ const options = normalizeOptions$o(binding.value);
2122
2698
  if (options.disabled || !isBrowser() || !supportsIntersectionObserver()) {
2123
2699
  if (!supportsIntersectionObserver()) {
2124
2700
  console.warn("[Directix] v-intersect: IntersectionObserver not supported");
@@ -2138,7 +2714,7 @@ var __async = (__this, __arguments, generator) => {
2138
2714
  var _a, _b, _c;
2139
2715
  const state = el[STATE_KEY$3];
2140
2716
  if (!state) return;
2141
- const newOptions = normalizeOptions$j(binding.value);
2717
+ const newOptions = normalizeOptions$o(binding.value);
2142
2718
  const observerOptionsChanged = newOptions.root !== state.options.root || newOptions.rootMargin !== state.options.rootMargin || newOptions.threshold !== state.options.threshold;
2143
2719
  if (newOptions.disabled !== state.options.disabled) {
2144
2720
  if (newOptions.disabled) {
@@ -2252,7 +2828,7 @@ var __async = (__this, __arguments, generator) => {
2252
2828
  globalObserver.unobserve(el);
2253
2829
  }
2254
2830
  }
2255
- function normalizeOptions$i(binding) {
2831
+ function normalizeOptions$n(binding) {
2256
2832
  if (typeof binding === "string") {
2257
2833
  return { src: binding };
2258
2834
  }
@@ -2267,7 +2843,7 @@ var __async = (__this, __arguments, generator) => {
2267
2843
  disabled: false
2268
2844
  },
2269
2845
  mounted(el, binding) {
2270
- const options = normalizeOptions$i(binding.value);
2846
+ const options = normalizeOptions$n(binding.value);
2271
2847
  if (options.disabled) return;
2272
2848
  if (!options.src) {
2273
2849
  console.warn("[Directix] v-lazy: No source provided");
@@ -2288,7 +2864,7 @@ var __async = (__this, __arguments, generator) => {
2288
2864
  updated(el, binding) {
2289
2865
  const state = el.__lazy;
2290
2866
  if (!state) return;
2291
- const newOptions = normalizeOptions$i(binding.value);
2867
+ const newOptions = normalizeOptions$n(binding.value);
2292
2868
  if (newOptions.disabled) {
2293
2869
  unobserve(el);
2294
2870
  return;
@@ -2311,7 +2887,7 @@ var __async = (__this, __arguments, generator) => {
2311
2887
  delete el.__lazy;
2312
2888
  }
2313
2889
  });
2314
- function normalizeOptions$h(binding) {
2890
+ function normalizeOptions$m(binding) {
2315
2891
  if (typeof binding === "boolean") {
2316
2892
  return { value: binding };
2317
2893
  }
@@ -2374,7 +2950,7 @@ var __async = (__this, __arguments, generator) => {
2374
2950
  },
2375
2951
  mounted(el, binding) {
2376
2952
  if (!isBrowser()) return;
2377
- const options = normalizeOptions$h(binding.value);
2953
+ const options = normalizeOptions$m(binding.value);
2378
2954
  if (options.disabled) return;
2379
2955
  const computedStyle = getComputedStyle(el);
2380
2956
  const originalPosition = el.style.position;
@@ -2396,7 +2972,7 @@ var __async = (__this, __arguments, generator) => {
2396
2972
  updated(el, binding) {
2397
2973
  const state = el.__loading;
2398
2974
  if (!state) return;
2399
- const newOptions = normalizeOptions$h(binding.value);
2975
+ const newOptions = normalizeOptions$m(binding.value);
2400
2976
  if (newOptions.disabled) {
2401
2977
  hideLoading(el, state);
2402
2978
  return;
@@ -2441,7 +3017,7 @@ var __async = (__this, __arguments, generator) => {
2441
3017
  }
2442
3018
  el.classList.remove("v-loading--active");
2443
3019
  }
2444
- function normalizeOptions$g(binding) {
3020
+ function normalizeOptions$l(binding) {
2445
3021
  if (typeof binding === "function") {
2446
3022
  return { handler: binding, duration: 500, distance: 10 };
2447
3023
  }
@@ -2472,7 +3048,7 @@ var __async = (__this, __arguments, generator) => {
2472
3048
  tickInterval: 100
2473
3049
  },
2474
3050
  mounted(el, binding) {
2475
- const options = normalizeOptions$g(binding.value);
3051
+ const options = normalizeOptions$l(binding.value);
2476
3052
  if (options.disabled || !isBrowser()) return;
2477
3053
  const state = {
2478
3054
  options,
@@ -2572,13 +3148,13 @@ var __async = (__this, __arguments, generator) => {
2572
3148
  updated(el, binding) {
2573
3149
  const state = el.__longPress;
2574
3150
  if (!state) {
2575
- const options = normalizeOptions$g(binding.value);
3151
+ const options = normalizeOptions$l(binding.value);
2576
3152
  if (!options.disabled) {
2577
3153
  el.__longPress = null;
2578
3154
  }
2579
3155
  return;
2580
3156
  }
2581
- state.options = normalizeOptions$g(binding.value);
3157
+ state.options = normalizeOptions$l(binding.value);
2582
3158
  },
2583
3159
  unmounted(el) {
2584
3160
  const state = el.__longPress;
@@ -2607,7 +3183,7 @@ var __async = (__this, __arguments, generator) => {
2607
3183
  }
2608
3184
  return text.toLowerCase();
2609
3185
  }
2610
- function normalizeOptions$f(binding) {
3186
+ function normalizeOptions$k(binding) {
2611
3187
  var _a, _b;
2612
3188
  if (binding === void 0 || binding === true) {
2613
3189
  return { first: false, onInput: true };
@@ -2624,7 +3200,7 @@ var __async = (__this, __arguments, generator) => {
2624
3200
  name: "lowercase",
2625
3201
  ssr: true,
2626
3202
  mounted(el, binding) {
2627
- const options = normalizeOptions$f(binding.value);
3203
+ const options = normalizeOptions$k(binding.value);
2628
3204
  if (isInputElement(el)) {
2629
3205
  const cleanup2 = setupTextTransformInput(el, options, (text) => transformText$1(text, options));
2630
3206
  el.__lowercaseCleanup = cleanup2;
@@ -2633,7 +3209,7 @@ var __async = (__this, __arguments, generator) => {
2633
3209
  }
2634
3210
  },
2635
3211
  updated(el, binding) {
2636
- const options = normalizeOptions$f(binding.value);
3212
+ const options = normalizeOptions$k(binding.value);
2637
3213
  if (isInputElement(el)) {
2638
3214
  if (options.onInput) {
2639
3215
  el.value = transformText$1(el.value, options);
@@ -2661,7 +3237,7 @@ var __async = (__this, __arguments, generator) => {
2661
3237
  return pattern ? { pattern, placeholder, isLiteral: false } : { pattern: new RegExp(`\\${char}`), placeholder: char, isLiteral: true };
2662
3238
  });
2663
3239
  }
2664
- function normalizeOptions$e(binding) {
3240
+ function normalizeOptions$j(binding) {
2665
3241
  if (typeof binding === "string") return { mask: binding, placeholder: "_", showPlaceholder: true };
2666
3242
  if (!(binding == null ? void 0 : binding.mask)) throw new Error("[Directix] v-mask: mask is required");
2667
3243
  return __spreadValues({ placeholder: "_", showPlaceholder: true, showMaskOnBlur: false, clearIncomplete: false, disabled: false }, binding);
@@ -2726,7 +3302,7 @@ var __async = (__this, __arguments, generator) => {
2726
3302
  console.warn("[Directix] v-mask: directive must be used on input or textarea elements");
2727
3303
  return;
2728
3304
  }
2729
- const options = normalizeOptions$e(binding.value);
3305
+ const options = normalizeOptions$j(binding.value);
2730
3306
  if (options.disabled || !isBrowser()) return;
2731
3307
  const placeholder = options.placeholder || "_";
2732
3308
  const tokens = parseMask(options.mask, placeholder);
@@ -2768,7 +3344,7 @@ var __async = (__this, __arguments, generator) => {
2768
3344
  updated(el, binding) {
2769
3345
  const state = el[STATE_KEY$2];
2770
3346
  if (!state) return;
2771
- state.options = normalizeOptions$e(binding.value);
3347
+ state.options = normalizeOptions$j(binding.value);
2772
3348
  state.tokens = parseMask(state.options.mask, state.placeholder);
2773
3349
  },
2774
3350
  unmounted(el) {
@@ -2957,7 +3533,7 @@ var __async = (__this, __arguments, generator) => {
2957
3533
  delete el.__money;
2958
3534
  }
2959
3535
  });
2960
- function normalizeOptions$d(binding) {
3536
+ function normalizeOptions$i(binding) {
2961
3537
  if (typeof binding === "function") {
2962
3538
  return { handler: binding, childList: true };
2963
3539
  }
@@ -2987,7 +3563,7 @@ var __async = (__this, __arguments, generator) => {
2987
3563
  disabled: false
2988
3564
  },
2989
3565
  mounted(el, binding) {
2990
- const options = normalizeOptions$d(binding.value);
3566
+ const options = normalizeOptions$i(binding.value);
2991
3567
  if (options.disabled || !isBrowser()) return;
2992
3568
  if (!supportsMutationObserver()) {
2993
3569
  console.warn("[Directix] v-mutation: MutationObserver not supported");
@@ -3014,7 +3590,7 @@ var __async = (__this, __arguments, generator) => {
3014
3590
  updated(el, binding) {
3015
3591
  const state = el.__mutation;
3016
3592
  if (!state) return;
3017
- const newOptions = normalizeOptions$d(binding.value);
3593
+ const newOptions = normalizeOptions$i(binding.value);
3018
3594
  if (newOptions.disabled && !state.options.disabled) {
3019
3595
  if (state.observer) {
3020
3596
  state.observer.disconnect();
@@ -3130,7 +3706,7 @@ var __async = (__this, __arguments, generator) => {
3130
3706
  function getPermissionConfig() {
3131
3707
  return globalConfig;
3132
3708
  }
3133
- function normalizeOptions$c(binding) {
3709
+ function normalizeOptions$h(binding) {
3134
3710
  if (!binding) {
3135
3711
  throw new Error("[Directix] v-permission: permission value is required");
3136
3712
  }
@@ -3235,7 +3811,7 @@ var __async = (__this, __arguments, generator) => {
3235
3811
  function checkPermission(el, binding) {
3236
3812
  var _a, _b;
3237
3813
  const state = getState(el);
3238
- state.options = normalizeOptions$c(binding.value);
3814
+ state.options = normalizeOptions$h(binding.value);
3239
3815
  const granted = verifyPermission(state.options);
3240
3816
  (_b = (_a = state.options).onChange) == null ? void 0 : _b.call(_a, granted);
3241
3817
  const action = state.options.action || "remove";
@@ -3265,17 +3841,383 @@ var __async = (__this, __arguments, generator) => {
3265
3841
  cleanup(el);
3266
3842
  }
3267
3843
  });
3268
- function getResizeInfo(entry) {
3269
- return {
3270
- width: entry.contentRect.width,
3271
- height: entry.contentRect.height,
3272
- contentRect: entry.contentRect,
3273
- borderBoxSize: entry.borderBoxSize,
3844
+ const vPrint = defineDirective({
3845
+ name: "print",
3846
+ ssr: true,
3847
+ mounted(el, binding) {
3848
+ const options = normalizeOptions$g(binding.value);
3849
+ const state = {
3850
+ options,
3851
+ clickHandler: null
3852
+ };
3853
+ el.__print = state;
3854
+ if (options.immediate) {
3855
+ setTimeout(() => printElement(el, options), 100);
3856
+ return;
3857
+ }
3858
+ const clickHandler = () => {
3859
+ printElement(el, state.options);
3860
+ };
3861
+ el.addEventListener("click", clickHandler);
3862
+ state.clickHandler = clickHandler;
3863
+ el.style.cursor = "pointer";
3864
+ },
3865
+ updated(el, binding) {
3866
+ const state = el.__print;
3867
+ if (!state) return;
3868
+ const newOptions = normalizeOptions$g(binding.value);
3869
+ state.options = newOptions;
3870
+ },
3871
+ unmounted(el) {
3872
+ const state = el.__print;
3873
+ if (!state) return;
3874
+ if (state.clickHandler) {
3875
+ el.removeEventListener("click", state.clickHandler);
3876
+ }
3877
+ el.style.cursor = "";
3878
+ delete el.__print;
3879
+ }
3880
+ });
3881
+ function normalizeOptions$g(binding) {
3882
+ if (binding === true) {
3883
+ return { immediate: true };
3884
+ }
3885
+ if (binding === false) {
3886
+ return {};
3887
+ }
3888
+ return binding || {};
3889
+ }
3890
+ function printElement(triggerEl, options) {
3891
+ return __async(this, null, function* () {
3892
+ if (options.onBeforePrint) {
3893
+ const result = options.onBeforePrint();
3894
+ if (result === false) return;
3895
+ }
3896
+ const targetEl = options.target ? document.querySelector(options.target) : triggerEl;
3897
+ if (!targetEl) {
3898
+ console.warn("[Directix] v-print: Target element not found");
3899
+ return;
3900
+ }
3901
+ if (options.newWindow) {
3902
+ yield printInNewWindow(targetEl, options);
3903
+ } else {
3904
+ yield printInIframe(targetEl, options);
3905
+ }
3906
+ if (options.onAfterPrint) {
3907
+ options.onAfterPrint();
3908
+ }
3909
+ });
3910
+ }
3911
+ function printInIframe(el, options) {
3912
+ return __async(this, null, function* () {
3913
+ var _a, _b, _c;
3914
+ const iframe = document.createElement("iframe");
3915
+ iframe.style.cssText = "position: absolute; top: -10000px; left: -10000px; width: 0; height: 0; border: none;";
3916
+ document.body.appendChild(iframe);
3917
+ const iframeDoc = iframe.contentDocument || ((_a = iframe.contentWindow) == null ? void 0 : _a.document);
3918
+ if (!iframeDoc) {
3919
+ console.warn("[Directix] v-print: Could not access iframe document");
3920
+ document.body.removeChild(iframe);
3921
+ return;
3922
+ }
3923
+ const content = buildPrintContent(el, options);
3924
+ iframeDoc.open();
3925
+ iframeDoc.write(content);
3926
+ iframeDoc.close();
3927
+ yield waitForImages(iframeDoc);
3928
+ try {
3929
+ (_b = iframe.contentWindow) == null ? void 0 : _b.focus();
3930
+ (_c = iframe.contentWindow) == null ? void 0 : _c.print();
3931
+ } catch (err) {
3932
+ console.error("[Directix] v-print: Print failed", err);
3933
+ }
3934
+ setTimeout(() => {
3935
+ document.body.removeChild(iframe);
3936
+ }, 1e3);
3937
+ });
3938
+ }
3939
+ function printInNewWindow(el, options) {
3940
+ return __async(this, null, function* () {
3941
+ const printWindow = window.open("", "_blank");
3942
+ if (!printWindow) {
3943
+ console.warn("[Directix] v-print: Could not open print window");
3944
+ return;
3945
+ }
3946
+ const content = buildPrintContent(el, options);
3947
+ printWindow.document.open();
3948
+ printWindow.document.write(content);
3949
+ printWindow.document.close();
3950
+ yield waitForImages(printWindow.document);
3951
+ printWindow.focus();
3952
+ printWindow.print();
3953
+ setTimeout(() => {
3954
+ printWindow.close();
3955
+ }, 1e3);
3956
+ });
3957
+ }
3958
+ function buildPrintContent(el, options) {
3959
+ let styles = "";
3960
+ document.querySelectorAll('style, link[rel="stylesheet"]').forEach((styleEl) => {
3961
+ if (styleEl.tagName === "STYLE") {
3962
+ styles += `<style>${styleEl.textContent}</style>`;
3963
+ } else if (styleEl.tagName === "LINK") {
3964
+ const href = styleEl.href;
3965
+ styles += `<link rel="stylesheet" href="${href}">`;
3966
+ }
3967
+ });
3968
+ if (options.cssUrls) {
3969
+ options.cssUrls.forEach((url) => {
3970
+ styles += `<link rel="stylesheet" href="${url}">`;
3971
+ });
3972
+ }
3973
+ if (options.styles) {
3974
+ const customStyles = Array.isArray(options.styles) ? options.styles.join("\n") : options.styles;
3975
+ styles += `<style>${customStyles}</style>`;
3976
+ }
3977
+ styles += `
3978
+ <style>
3979
+ @media print {
3980
+ body { margin: 0; padding: 20px; }
3981
+ ${options.printClass ? `.${options.printClass} { page-break-inside: avoid; }` : ""}
3982
+ }
3983
+ </style>
3984
+ `;
3985
+ const title = options.title || document.title || "Print";
3986
+ const content = el.outerHTML;
3987
+ return `<!DOCTYPE html>
3988
+ <html>
3989
+ <head>
3990
+ <meta charset="utf-8">
3991
+ <title>${title}</title>
3992
+ ${styles}
3993
+ </head>
3994
+ <body>
3995
+ ${content}
3996
+ </body>
3997
+ </html>`;
3998
+ }
3999
+ function waitForImages(doc) {
4000
+ const images = doc.querySelectorAll("img");
4001
+ const promises = [];
4002
+ images.forEach((img) => {
4003
+ if (!img.complete) {
4004
+ promises.push(
4005
+ new Promise((resolve) => {
4006
+ img.onload = () => resolve();
4007
+ img.onerror = () => resolve();
4008
+ })
4009
+ );
4010
+ }
4011
+ });
4012
+ return Promise.all(promises);
4013
+ }
4014
+ const DEFAULT_DISTANCE = 60;
4015
+ const DEFAULT_MAX_DISTANCE = 100;
4016
+ const DEFAULT_SUCCESS_DURATION = 500;
4017
+ const DEFAULT_ERROR_DURATION = 1e3;
4018
+ const DEFAULT_INDICATORS = {
4019
+ idle: "↓",
4020
+ pulling: "↓ Pull",
4021
+ ready: "↓ Release",
4022
+ loading: "⟳ Loading...",
4023
+ success: "✓ Done",
4024
+ error: "✗ Failed"
4025
+ };
4026
+ function normalizeOptions$f(binding) {
4027
+ var _a, _b, _c, _d, _e;
4028
+ if (typeof binding === "function") return { handler: binding };
4029
+ return {
4030
+ handler: binding.handler,
4031
+ distance: (_a = binding.distance) != null ? _a : DEFAULT_DISTANCE,
4032
+ maxDistance: (_b = binding.maxDistance) != null ? _b : DEFAULT_MAX_DISTANCE,
4033
+ disabled: (_c = binding.disabled) != null ? _c : false,
4034
+ indicator: binding.indicator,
4035
+ successDuration: (_d = binding.successDuration) != null ? _d : DEFAULT_SUCCESS_DURATION,
4036
+ errorDuration: (_e = binding.errorDuration) != null ? _e : DEFAULT_ERROR_DURATION,
4037
+ onStateChange: binding.onStateChange
4038
+ };
4039
+ }
4040
+ function createIndicator() {
4041
+ const el = document.createElement("div");
4042
+ el.className = "v-pull-refresh__indicator";
4043
+ el.style.cssText = `
4044
+ position: absolute;
4045
+ top: 0;
4046
+ left: 0;
4047
+ right: 0;
4048
+ height: 60px;
4049
+ display: flex;
4050
+ align-items: center;
4051
+ justify-content: center;
4052
+ background: #f5f5f5;
4053
+ font-size: 14px;
4054
+ color: #666;
4055
+ z-index: 10;
4056
+ pointer-events: none;
4057
+ opacity: 0;
4058
+ transition: opacity 0.2s ease;
4059
+ `;
4060
+ return el;
4061
+ }
4062
+ function updateIndicator(el, state, options) {
4063
+ var _a;
4064
+ const customIndicator = (_a = options.indicator) == null ? void 0 : _a[state];
4065
+ el.textContent = customIndicator || DEFAULT_INDICATORS[state];
4066
+ }
4067
+ function setState(internal, newState) {
4068
+ var _a, _b;
4069
+ if (internal.state === newState) return;
4070
+ internal.state = newState;
4071
+ updateIndicator(internal.indicatorEl, newState, internal.options);
4072
+ (_b = (_a = internal.options).onStateChange) == null ? void 0 : _b.call(_a, newState);
4073
+ }
4074
+ function applyTransform(internal, distance, showIndicator) {
4075
+ internal.contentEl.style.transform = `translateY(${distance}px)`;
4076
+ internal.indicatorEl.style.opacity = "1";
4077
+ internal.indicatorEl.style.transform = `translateY(${distance}px)`;
4078
+ }
4079
+ function resetPosition(internal) {
4080
+ internal.contentEl.style.transform = "";
4081
+ internal.indicatorEl.style.opacity = "0";
4082
+ setState(internal, "idle");
4083
+ }
4084
+ function triggerRefresh(internal) {
4085
+ return __async(this, null, function* () {
4086
+ setState(internal, "loading");
4087
+ const distance = internal.options.distance;
4088
+ applyTransform(internal, distance);
4089
+ try {
4090
+ yield internal.options.handler();
4091
+ setState(internal, "success");
4092
+ yield sleep(internal.options.successDuration);
4093
+ } catch (e) {
4094
+ setState(internal, "error");
4095
+ yield sleep(internal.options.errorDuration);
4096
+ } finally {
4097
+ resetPosition(internal);
4098
+ }
4099
+ });
4100
+ }
4101
+ function sleep(ms) {
4102
+ return new Promise((resolve) => setTimeout(resolve, ms));
4103
+ }
4104
+ function createHandlers(internal) {
4105
+ const { contentEl, options } = internal;
4106
+ return {
4107
+ touchStart: (e) => {
4108
+ if (options.disabled || internal.state === "loading") return;
4109
+ if (contentEl.scrollTop > 0) return;
4110
+ internal.pulling = true;
4111
+ internal.startY = e.touches[0].clientY;
4112
+ internal.currentY = internal.startY;
4113
+ setState(internal, "idle");
4114
+ },
4115
+ touchMove: (e) => {
4116
+ if (!internal.pulling || options.disabled || internal.state === "loading") return;
4117
+ internal.currentY = e.touches[0].clientY;
4118
+ const diff = internal.currentY - internal.startY;
4119
+ if (diff <= 0) {
4120
+ if (contentEl.style.transform) {
4121
+ contentEl.style.transition = "";
4122
+ resetPosition(internal);
4123
+ }
4124
+ return;
4125
+ }
4126
+ e.preventDefault();
4127
+ const distance = Math.min(diff * 0.5, options.maxDistance);
4128
+ const progress = distance / options.distance;
4129
+ contentEl.style.transition = "none";
4130
+ applyTransform(internal, distance);
4131
+ setState(internal, progress >= 1 ? "ready" : "pulling");
4132
+ },
4133
+ touchEnd: () => {
4134
+ if (!internal.pulling || options.disabled) return;
4135
+ internal.pulling = false;
4136
+ const diff = internal.currentY - internal.startY;
4137
+ const distance = Math.min(diff * 0.5, options.maxDistance);
4138
+ contentEl.style.transition = "";
4139
+ if (internal.state === "ready" && distance >= options.distance) {
4140
+ triggerRefresh(internal);
4141
+ } else {
4142
+ resetPosition(internal);
4143
+ }
4144
+ }
4145
+ };
4146
+ }
4147
+ function bindEvents$1(el, handlers) {
4148
+ el.addEventListener("touchstart", handlers.touchStart, { passive: false });
4149
+ el.addEventListener("touchmove", handlers.touchMove, { passive: false });
4150
+ el.addEventListener("touchend", handlers.touchEnd, { passive: true });
4151
+ }
4152
+ function unbindEvents$1(el, handlers) {
4153
+ el.removeEventListener("touchstart", handlers.touchStart);
4154
+ el.removeEventListener("touchmove", handlers.touchMove);
4155
+ el.removeEventListener("touchend", handlers.touchEnd);
4156
+ }
4157
+ const vPullRefresh = defineDirective({
4158
+ name: "pull-refresh",
4159
+ ssr: false,
4160
+ mounted(el, binding) {
4161
+ const options = normalizeOptions$f(binding.value);
4162
+ el.style.position = "relative";
4163
+ el.style.overflow = "hidden";
4164
+ el.classList.add("v-pull-refresh");
4165
+ const contentEl = document.createElement("div");
4166
+ contentEl.className = "v-pull-refresh__content";
4167
+ contentEl.style.cssText = "position: relative; height: 100%; overflow-y: auto;";
4168
+ while (el.firstChild) {
4169
+ contentEl.appendChild(el.firstChild);
4170
+ }
4171
+ el.appendChild(contentEl);
4172
+ const indicatorEl = createIndicator();
4173
+ el.insertBefore(indicatorEl, contentEl);
4174
+ const internal = {
4175
+ options,
4176
+ state: "idle",
4177
+ startY: 0,
4178
+ currentY: 0,
4179
+ pulling: false,
4180
+ indicatorEl,
4181
+ contentEl,
4182
+ handlers: null
4183
+ };
4184
+ internal.handlers = createHandlers(internal);
4185
+ el.__pullRefresh = internal;
4186
+ if (!options.disabled) {
4187
+ bindEvents$1(el, internal.handlers);
4188
+ }
4189
+ updateIndicator(indicatorEl, "idle", options);
4190
+ },
4191
+ updated(el, binding) {
4192
+ const internal = el.__pullRefresh;
4193
+ if (!internal) return;
4194
+ const wasDisabled = internal.options.disabled;
4195
+ internal.options = normalizeOptions$f(binding.value);
4196
+ updateIndicator(internal.indicatorEl, internal.state, internal.options);
4197
+ if (internal.options.disabled && !wasDisabled) {
4198
+ unbindEvents$1(el, internal.handlers);
4199
+ } else if (!internal.options.disabled && wasDisabled) {
4200
+ bindEvents$1(el, internal.handlers);
4201
+ }
4202
+ },
4203
+ unmounted(el) {
4204
+ const internal = el.__pullRefresh;
4205
+ if (!internal) return;
4206
+ unbindEvents$1(el, internal.handlers);
4207
+ delete el.__pullRefresh;
4208
+ }
4209
+ });
4210
+ function getResizeInfo(entry) {
4211
+ return {
4212
+ width: entry.contentRect.width,
4213
+ height: entry.contentRect.height,
4214
+ contentRect: entry.contentRect,
4215
+ borderBoxSize: entry.borderBoxSize,
3274
4216
  contentBoxSize: entry.contentBoxSize,
3275
4217
  devicePixelContentBoxSize: entry.devicePixelContentBoxSize
3276
4218
  };
3277
4219
  }
3278
- function normalizeOptions$b(binding) {
4220
+ function normalizeOptions$e(binding) {
3279
4221
  if (typeof binding === "function") {
3280
4222
  return { handler: binding };
3281
4223
  }
@@ -3324,7 +4266,7 @@ var __async = (__this, __arguments, generator) => {
3324
4266
  debounce: 0
3325
4267
  },
3326
4268
  mounted(el, binding) {
3327
- const options = normalizeOptions$b(binding.value);
4269
+ const options = normalizeOptions$e(binding.value);
3328
4270
  if (options.disabled || !isBrowser()) return;
3329
4271
  const computedStyle = getComputedStyle(el);
3330
4272
  if (computedStyle.position === "static") {
@@ -3384,7 +4326,7 @@ var __async = (__this, __arguments, generator) => {
3384
4326
  updated(el, binding) {
3385
4327
  const state = el.__resize;
3386
4328
  if (!state) return;
3387
- state.options = normalizeOptions$b(binding.value);
4329
+ state.options = normalizeOptions$e(binding.value);
3388
4330
  },
3389
4331
  unmounted(el) {
3390
4332
  const state = el.__resize;
@@ -3403,7 +4345,7 @@ var __async = (__this, __arguments, generator) => {
3403
4345
  delete el.__resizeCleanup;
3404
4346
  }
3405
4347
  });
3406
- function normalizeOptions$a(binding) {
4348
+ function normalizeOptions$d(binding) {
3407
4349
  if (binding === false) {
3408
4350
  return { disabled: true, color: "currentColor", duration: 600 };
3409
4351
  }
@@ -3480,7 +4422,7 @@ var __async = (__this, __arguments, generator) => {
3480
4422
  finalScale: 2
3481
4423
  },
3482
4424
  mounted(el, binding) {
3483
- const options = normalizeOptions$a(binding.value);
4425
+ const options = normalizeOptions$d(binding.value);
3484
4426
  if (options.disabled || !isBrowser()) return;
3485
4427
  const computedStyle = getComputedStyle(el);
3486
4428
  if (computedStyle.position === "static") {
@@ -3508,7 +4450,7 @@ var __async = (__this, __arguments, generator) => {
3508
4450
  updated(el, binding) {
3509
4451
  const state = el.__ripple;
3510
4452
  if (!state) return;
3511
- state.options = normalizeOptions$a(binding.value);
4453
+ state.options = normalizeOptions$d(binding.value);
3512
4454
  },
3513
4455
  unmounted(el) {
3514
4456
  const state = el.__ripple;
@@ -3522,7 +4464,7 @@ var __async = (__this, __arguments, generator) => {
3522
4464
  const DEFAULT_ALLOWED_ATTRIBUTES = ["title", "alt", "href", "src"];
3523
4465
  const DANGEROUS_TAGS = ["script", "iframe", "object", "embed", "form", "input", "style", "link", "meta", "base"];
3524
4466
  const DANGEROUS_ATTRIBUTES = ["onclick", "onerror", "onload", "onmouseover", "onfocus", "onblur", "onchange", "onsubmit"];
3525
- function normalizeOptions$9(binding) {
4467
+ function normalizeOptions$c(binding) {
3526
4468
  if (binding === false) {
3527
4469
  return { disabled: true };
3528
4470
  }
@@ -3613,7 +4555,7 @@ var __async = (__this, __arguments, generator) => {
3613
4555
  },
3614
4556
  mounted(el, binding) {
3615
4557
  if (!isBrowser()) return;
3616
- const options = normalizeOptions$9(binding.value);
4558
+ const options = normalizeOptions$c(binding.value);
3617
4559
  if (options.disabled) return;
3618
4560
  el.__sanitize = { options };
3619
4561
  const content = el.innerHTML;
@@ -3624,7 +4566,7 @@ var __async = (__this, __arguments, generator) => {
3624
4566
  updated(el, binding) {
3625
4567
  const state = el.__sanitize;
3626
4568
  if (!state) return;
3627
- state.options = normalizeOptions$9(binding.value);
4569
+ state.options = normalizeOptions$c(binding.value);
3628
4570
  if (state.options.disabled || !state.options.sanitizeOnUpdate) return;
3629
4571
  const content = el.innerHTML;
3630
4572
  if (content) {
@@ -3665,7 +4607,7 @@ var __async = (__this, __arguments, generator) => {
3665
4607
  container
3666
4608
  };
3667
4609
  }
3668
- function normalizeOptions$8(binding) {
4610
+ function normalizeOptions$b(binding) {
3669
4611
  if (typeof binding === "function") {
3670
4612
  return { handler: binding, passive: true };
3671
4613
  }
@@ -3687,7 +4629,7 @@ var __async = (__this, __arguments, generator) => {
3687
4629
  disabled: false
3688
4630
  },
3689
4631
  mounted(el, binding) {
3690
- const options = normalizeOptions$8(binding.value);
4632
+ const options = normalizeOptions$b(binding.value);
3691
4633
  if (options.disabled || !isBrowser()) return;
3692
4634
  let container;
3693
4635
  if (options.container) {
@@ -3743,7 +4685,7 @@ var __async = (__this, __arguments, generator) => {
3743
4685
  updated(el, binding) {
3744
4686
  const state = el.__scroll;
3745
4687
  if (!state) return;
3746
- state.options = normalizeOptions$8(binding.value);
4688
+ state.options = normalizeOptions$b(binding.value);
3747
4689
  },
3748
4690
  unmounted(el) {
3749
4691
  const state = el.__scroll;
@@ -3756,7 +4698,7 @@ var __async = (__this, __arguments, generator) => {
3756
4698
  }
3757
4699
  });
3758
4700
  const STATE_KEY = "__sticky";
3759
- function normalizeOptions$7(binding) {
4701
+ function normalizeOptions$a(binding) {
3760
4702
  if (binding === false) return { disabled: true, top: 0, zIndex: 100 };
3761
4703
  if (typeof binding === "number") return { top: binding, zIndex: 100 };
3762
4704
  return __spreadValues({
@@ -3838,7 +4780,7 @@ var __async = (__this, __arguments, generator) => {
3838
4780
  ssr: false,
3839
4781
  defaults: { top: 0, zIndex: 100, stickyClass: "v-sticky--fixed", disabled: false },
3840
4782
  mounted(el, binding) {
3841
- const options = normalizeOptions$7(binding.value);
4783
+ const options = normalizeOptions$a(binding.value);
3842
4784
  if (options.disabled || !isBrowser()) return;
3843
4785
  const container = getScrollContainer(el, options.container);
3844
4786
  const state = {
@@ -3865,7 +4807,7 @@ var __async = (__this, __arguments, generator) => {
3865
4807
  updated(el, binding) {
3866
4808
  const state = el[STATE_KEY];
3867
4809
  if (!state) return;
3868
- state.options = normalizeOptions$7(binding.value);
4810
+ state.options = normalizeOptions$a(binding.value);
3869
4811
  checkSticky(el, state);
3870
4812
  },
3871
4813
  unmounted(el) {
@@ -3880,7 +4822,193 @@ var __async = (__this, __arguments, generator) => {
3880
4822
  delete el[STATE_KEY];
3881
4823
  }
3882
4824
  });
3883
- function normalizeOptions$6(binding, directiveBinding) {
4825
+ const DEFAULT_THRESHOLD = 30;
4826
+ const DEFAULT_MAX_TIME = 500;
4827
+ const DEFAULT_DIRECTIONS = ["left", "right", "up", "down"];
4828
+ function getSwipeDirection(deltaX, deltaY, allowedDirections) {
4829
+ const absX = Math.abs(deltaX);
4830
+ const absY = Math.abs(deltaY);
4831
+ if (absX > absY) {
4832
+ const direction = deltaX > 0 ? "right" : "left";
4833
+ return allowedDirections.includes(direction) ? direction : null;
4834
+ } else {
4835
+ const direction = deltaY > 0 ? "down" : "up";
4836
+ return allowedDirections.includes(direction) ? direction : null;
4837
+ }
4838
+ }
4839
+ function normalizeOptions$9(binding) {
4840
+ var _a, _b, _c, _d, _e, _f;
4841
+ if (typeof binding === "function") return { handler: binding };
4842
+ return {
4843
+ handler: binding.handler,
4844
+ threshold: (_a = binding.threshold) != null ? _a : DEFAULT_THRESHOLD,
4845
+ maxTime: (_b = binding.maxTime) != null ? _b : DEFAULT_MAX_TIME,
4846
+ directions: (_c = binding.directions) != null ? _c : [...DEFAULT_DIRECTIONS],
4847
+ preventScrollOnSwipe: (_d = binding.preventScrollOnSwipe) != null ? _d : true,
4848
+ disabled: (_e = binding.disabled) != null ? _e : false,
4849
+ mouse: (_f = binding.mouse) != null ? _f : true,
4850
+ onLeft: binding.onLeft,
4851
+ onRight: binding.onRight,
4852
+ onUp: binding.onUp,
4853
+ onDown: binding.onDown
4854
+ };
4855
+ }
4856
+ function triggerSwipe(state, deltaX, deltaY, deltaTime, event, el) {
4857
+ var _a, _b, _c, _d, _e;
4858
+ const { options } = state;
4859
+ if (deltaTime > ((_a = options.maxTime) != null ? _a : DEFAULT_MAX_TIME)) return;
4860
+ const distance = Math.max(Math.abs(deltaX), Math.abs(deltaY));
4861
+ if (distance < ((_b = options.threshold) != null ? _b : DEFAULT_THRESHOLD)) return;
4862
+ const direction = getSwipeDirection(deltaX, deltaY, (_c = options.directions) != null ? _c : DEFAULT_DIRECTIONS);
4863
+ if (!direction) return;
4864
+ if (options.preventScrollOnSwipe && event.cancelable) {
4865
+ event.preventDefault();
4866
+ }
4867
+ (_d = options.handler) == null ? void 0 : _d.call(options, direction, event);
4868
+ const callbacks = {
4869
+ left: options.onLeft,
4870
+ right: options.onRight,
4871
+ up: options.onUp,
4872
+ down: options.onDown
4873
+ };
4874
+ (_e = callbacks[direction]) == null ? void 0 : _e.call(callbacks);
4875
+ el.dispatchEvent(new CustomEvent("swipe", { detail: { direction, deltaX, deltaY, deltaTime } }));
4876
+ }
4877
+ function createSwipeHandler(el, state) {
4878
+ return (clientX, clientY, event) => {
4879
+ const deltaX = clientX - state.startX;
4880
+ const deltaY = clientY - state.startY;
4881
+ const deltaTime = Date.now() - state.startTime;
4882
+ triggerSwipe(state, deltaX, deltaY, deltaTime, event, el);
4883
+ };
4884
+ }
4885
+ function setupState(el, options) {
4886
+ if (options.disabled) return null;
4887
+ el.style.touchAction = "none";
4888
+ el.style.userSelect = "none";
4889
+ const state = {
4890
+ options,
4891
+ startX: 0,
4892
+ startY: 0,
4893
+ startTime: 0,
4894
+ isActive: false,
4895
+ handlers: null
4896
+ };
4897
+ const handleSwipe = createSwipeHandler(el, state);
4898
+ state.handlers = {
4899
+ touchStart: (e) => {
4900
+ if (state.options.disabled) return;
4901
+ state.startX = e.touches[0].clientX;
4902
+ state.startY = e.touches[0].clientY;
4903
+ state.startTime = Date.now();
4904
+ state.isActive = true;
4905
+ },
4906
+ touchMove: (e) => {
4907
+ if (!state.isActive || state.options.disabled) return;
4908
+ if (state.options.preventScrollOnSwipe) {
4909
+ e.preventDefault();
4910
+ }
4911
+ },
4912
+ touchEnd: (e) => {
4913
+ if (!state.isActive || state.options.disabled) return;
4914
+ state.isActive = false;
4915
+ const touch = e.changedTouches[0];
4916
+ handleSwipe(touch.clientX, touch.clientY, e);
4917
+ },
4918
+ mouseDown: (e) => {
4919
+ if (state.options.disabled) return;
4920
+ state.startX = e.clientX;
4921
+ state.startY = e.clientY;
4922
+ state.startTime = Date.now();
4923
+ state.isActive = true;
4924
+ },
4925
+ mouseUp: (e) => {
4926
+ if (!state.isActive || state.options.disabled) return;
4927
+ state.isActive = false;
4928
+ handleSwipe(e.clientX, e.clientY, e);
4929
+ }
4930
+ };
4931
+ return state;
4932
+ }
4933
+ function bindEvents(el, state) {
4934
+ var _a;
4935
+ const { handlers } = state;
4936
+ const enableMouse = (_a = state.options.mouse) != null ? _a : true;
4937
+ el.addEventListener("touchstart", handlers.touchStart, { passive: true });
4938
+ el.addEventListener("touchmove", handlers.touchMove, { passive: false });
4939
+ el.addEventListener("touchend", handlers.touchEnd);
4940
+ el.addEventListener("touchcancel", handlers.touchEnd);
4941
+ if (enableMouse) {
4942
+ el.addEventListener("mousedown", handlers.mouseDown);
4943
+ el.addEventListener("mouseup", handlers.mouseUp);
4944
+ el.addEventListener("mouseleave", handlers.mouseUp);
4945
+ }
4946
+ }
4947
+ function unbindEvents(el, state) {
4948
+ var _a;
4949
+ const { handlers } = state;
4950
+ const enableMouse = (_a = state.options.mouse) != null ? _a : true;
4951
+ el.removeEventListener("touchstart", handlers.touchStart);
4952
+ el.removeEventListener("touchmove", handlers.touchMove);
4953
+ el.removeEventListener("touchend", handlers.touchEnd);
4954
+ el.removeEventListener("touchcancel", handlers.touchEnd);
4955
+ if (enableMouse) {
4956
+ el.removeEventListener("mousedown", handlers.mouseDown);
4957
+ el.removeEventListener("mouseup", handlers.mouseUp);
4958
+ el.removeEventListener("mouseleave", handlers.mouseUp);
4959
+ }
4960
+ }
4961
+ const vSwipe = defineDirective({
4962
+ name: "swipe",
4963
+ ssr: false,
4964
+ mounted(el, binding) {
4965
+ const options = normalizeOptions$9(binding.value);
4966
+ const state = setupState(el, options);
4967
+ if (!state) return;
4968
+ el.__swipe = state;
4969
+ bindEvents(el, state);
4970
+ },
4971
+ updated(el, binding) {
4972
+ var _a, _b;
4973
+ const state = el.__swipe;
4974
+ const newOptions = normalizeOptions$9(binding.value);
4975
+ if (!state) {
4976
+ const newState = setupState(el, newOptions);
4977
+ if (newState) {
4978
+ el.__swipe = newState;
4979
+ bindEvents(el, newState);
4980
+ }
4981
+ return;
4982
+ }
4983
+ const wasDisabled = state.options.disabled;
4984
+ const wasMouseEnabled = (_a = state.options.mouse) != null ? _a : true;
4985
+ const nowMouseEnabled = (_b = newOptions.mouse) != null ? _b : true;
4986
+ state.options = newOptions;
4987
+ if (newOptions.disabled && !wasDisabled) {
4988
+ unbindEvents(el, state);
4989
+ } else if (!newOptions.disabled && wasDisabled) {
4990
+ bindEvents(el, state);
4991
+ } else if (wasMouseEnabled !== nowMouseEnabled) {
4992
+ if (wasMouseEnabled) {
4993
+ el.removeEventListener("mousedown", state.handlers.mouseDown);
4994
+ el.removeEventListener("mouseup", state.handlers.mouseUp);
4995
+ el.removeEventListener("mouseleave", state.handlers.mouseUp);
4996
+ }
4997
+ if (nowMouseEnabled) {
4998
+ el.addEventListener("mousedown", state.handlers.mouseDown);
4999
+ el.addEventListener("mouseup", state.handlers.mouseUp);
5000
+ el.addEventListener("mouseleave", state.handlers.mouseUp);
5001
+ }
5002
+ }
5003
+ },
5004
+ unmounted(el) {
5005
+ const state = el.__swipe;
5006
+ if (!state) return;
5007
+ unbindEvents(el, state);
5008
+ delete el.__swipe;
5009
+ }
5010
+ });
5011
+ function normalizeOptions$8(binding, directiveBinding) {
3884
5012
  const wait = parseTime(directiveBinding.arg) || 300;
3885
5013
  if (typeof binding === "function") {
3886
5014
  return { handler: binding, wait };
@@ -3897,7 +5025,7 @@ var __async = (__this, __arguments, generator) => {
3897
5025
  trailing: true
3898
5026
  },
3899
5027
  mounted(el, binding) {
3900
- const options = normalizeOptions$6(binding.value, binding);
5028
+ const options = normalizeOptions$8(binding.value, binding);
3901
5029
  const eventType = getEventTypeFromModifiers(binding.modifiers) || getDefaultEventType(el);
3902
5030
  const throttledFn = throttle(options.handler, options.wait, {
3903
5031
  leading: options.leading,
@@ -3913,7 +5041,7 @@ var __async = (__this, __arguments, generator) => {
3913
5041
  updated(el, binding) {
3914
5042
  const state = el.__throttle;
3915
5043
  if (!state) return;
3916
- const newOptions = normalizeOptions$6(binding.value, binding);
5044
+ const newOptions = normalizeOptions$8(binding.value, binding);
3917
5045
  if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
3918
5046
  state.throttledFn.cancel();
3919
5047
  const throttledFn = throttle(newOptions.handler, newOptions.wait, {
@@ -4134,7 +5262,7 @@ var __async = (__this, __arguments, generator) => {
4134
5262
  document.removeEventListener("click", docHide);
4135
5263
  }
4136
5264
  }
4137
- function normalizeOptions$5(binding) {
5265
+ function normalizeOptions$7(binding) {
4138
5266
  var _a, _b, _c, _d, _e, _f, _g, _h;
4139
5267
  if (typeof binding === "string") {
4140
5268
  return { content: binding, placement: "top", trigger: "hover" };
@@ -4172,7 +5300,7 @@ var __async = (__this, __arguments, generator) => {
4172
5300
  name: "tooltip",
4173
5301
  ssr: false,
4174
5302
  mounted(el, binding) {
4175
- const options = normalizeOptions$5(binding.value);
5303
+ const options = normalizeOptions$7(binding.value);
4176
5304
  if (options.disabled || !options.content) return;
4177
5305
  const state = createState(options);
4178
5306
  el.__tooltip = state;
@@ -4181,7 +5309,7 @@ var __async = (__this, __arguments, generator) => {
4181
5309
  },
4182
5310
  updated(el, binding) {
4183
5311
  const state = el.__tooltip;
4184
- const newOptions = normalizeOptions$5(binding.value);
5312
+ const newOptions = normalizeOptions$7(binding.value);
4185
5313
  if (!state) {
4186
5314
  if (!newOptions.disabled && newOptions.content) {
4187
5315
  const newState = createState(newOptions);
@@ -4227,7 +5355,7 @@ var __async = (__this, __arguments, generator) => {
4227
5355
  name: "touch",
4228
5356
  ssr: false,
4229
5357
  mounted(el, binding) {
4230
- const options = normalizeOptions$4(binding.value);
5358
+ const options = normalizeOptions$6(binding.value);
4231
5359
  const state = {
4232
5360
  options,
4233
5361
  startX: 0,
@@ -4388,7 +5516,7 @@ var __async = (__this, __arguments, generator) => {
4388
5516
  },
4389
5517
  updated(el, binding) {
4390
5518
  const state = el.__touch;
4391
- if (state) state.options = normalizeOptions$4(binding.value);
5519
+ if (state) state.options = normalizeOptions$6(binding.value);
4392
5520
  },
4393
5521
  unmounted(el) {
4394
5522
  const state = el.__touch;
@@ -4405,7 +5533,7 @@ var __async = (__this, __arguments, generator) => {
4405
5533
  delete el.__touch;
4406
5534
  }
4407
5535
  });
4408
- function normalizeOptions$4(binding) {
5536
+ function normalizeOptions$6(binding) {
4409
5537
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4410
5538
  return {
4411
5539
  swipeThreshold: (_a = binding == null ? void 0 : binding.swipeThreshold) != null ? _a : 30,
@@ -4454,7 +5582,7 @@ var __async = (__this, __arguments, generator) => {
4454
5582
  name: "trim",
4455
5583
  ssr: true,
4456
5584
  mounted(el, binding) {
4457
- const options = normalizeOptions$3(binding.value);
5585
+ const options = normalizeOptions$5(binding.value);
4458
5586
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
4459
5587
  setupInputElement(el, options);
4460
5588
  } else {
@@ -4463,7 +5591,7 @@ var __async = (__this, __arguments, generator) => {
4463
5591
  }
4464
5592
  },
4465
5593
  updated(el, binding) {
4466
- const options = normalizeOptions$3(binding.value);
5594
+ const options = normalizeOptions$5(binding.value);
4467
5595
  const state = el.__trim;
4468
5596
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
4469
5597
  if (state) {
@@ -4521,7 +5649,7 @@ var __async = (__this, __arguments, generator) => {
4521
5649
  performTrim();
4522
5650
  }
4523
5651
  }
4524
- function normalizeOptions$3(binding) {
5652
+ function normalizeOptions$5(binding) {
4525
5653
  var _a, _b, _c;
4526
5654
  if (binding === void 0 || binding === true) {
4527
5655
  return { position: "both", onInput: true, onBlur: true };
@@ -4561,7 +5689,7 @@ var __async = (__this, __arguments, generator) => {
4561
5689
  name: "truncate",
4562
5690
  ssr: true,
4563
5691
  mounted(el, binding) {
4564
- const options = normalizeOptions$2(binding.value);
5692
+ const options = normalizeOptions$4(binding.value);
4565
5693
  const text = el.textContent || "";
4566
5694
  const state = {
4567
5695
  originalText: text,
@@ -4572,7 +5700,7 @@ var __async = (__this, __arguments, generator) => {
4572
5700
  },
4573
5701
  updated(el, binding) {
4574
5702
  const state = el.__truncate;
4575
- const newOptions = normalizeOptions$2(binding.value);
5703
+ const newOptions = normalizeOptions$4(binding.value);
4576
5704
  if (state) {
4577
5705
  const originalText = state.originalText;
4578
5706
  if (JSON.stringify(newOptions) !== JSON.stringify(state.options)) {
@@ -4609,7 +5737,7 @@ var __async = (__this, __arguments, generator) => {
4609
5737
  }
4610
5738
  }
4611
5739
  }
4612
- function normalizeOptions$2(binding) {
5740
+ function normalizeOptions$4(binding) {
4613
5741
  var _a, _b, _c, _d, _e;
4614
5742
  if (typeof binding === "number") {
4615
5743
  return {
@@ -4635,7 +5763,7 @@ var __async = (__this, __arguments, generator) => {
4635
5763
  }
4636
5764
  return text.toUpperCase();
4637
5765
  }
4638
- function normalizeOptions$1(binding) {
5766
+ function normalizeOptions$3(binding) {
4639
5767
  var _a, _b;
4640
5768
  if (binding === void 0 || binding === true) {
4641
5769
  return { first: false, onInput: true };
@@ -4652,7 +5780,7 @@ var __async = (__this, __arguments, generator) => {
4652
5780
  name: "uppercase",
4653
5781
  ssr: true,
4654
5782
  mounted(el, binding) {
4655
- const options = normalizeOptions$1(binding.value);
5783
+ const options = normalizeOptions$3(binding.value);
4656
5784
  if (isInputElement(el)) {
4657
5785
  const cleanup2 = setupTextTransformInput(el, options, (text) => transformText(text, options));
4658
5786
  el.__uppercaseCleanup = cleanup2;
@@ -4661,7 +5789,7 @@ var __async = (__this, __arguments, generator) => {
4661
5789
  }
4662
5790
  },
4663
5791
  updated(el, binding) {
4664
- const options = normalizeOptions$1(binding.value);
5792
+ const options = normalizeOptions$3(binding.value);
4665
5793
  if (isInputElement(el)) {
4666
5794
  if (options.onInput) {
4667
5795
  el.value = transformText(el.value, options);
@@ -4676,7 +5804,212 @@ var __async = (__this, __arguments, generator) => {
4676
5804
  delete el.__uppercaseCleanup;
4677
5805
  }
4678
5806
  });
4679
- function normalizeOptions(binding) {
5807
+ function getItemSize(options, index) {
5808
+ if (typeof options.itemSize === "function") {
5809
+ return options.itemSize(index);
5810
+ }
5811
+ return options.itemSize || 50;
5812
+ }
5813
+ function calculateTotalHeight(options) {
5814
+ if (typeof options.itemSize === "function") {
5815
+ let total = 0;
5816
+ for (let i = 0; i < options.items.length; i++) {
5817
+ total += options.itemSize(i);
5818
+ }
5819
+ return total;
5820
+ }
5821
+ return (options.itemSize || 50) * options.items.length;
5822
+ }
5823
+ function calculateVisibleRange(scrollTop, containerHeight, options) {
5824
+ const items = options.items;
5825
+ const itemSize = options.itemSize || 50;
5826
+ const overscan = options.overscan || 3;
5827
+ let startIndex = 0, endIndex = 0, offsetY = 0;
5828
+ if (typeof itemSize === "function") {
5829
+ let currentOffset = 0;
5830
+ for (let i = 0; i < items.length; i++) {
5831
+ const size = itemSize(i);
5832
+ if (currentOffset + size > scrollTop) {
5833
+ startIndex = i;
5834
+ offsetY = currentOffset;
5835
+ break;
5836
+ }
5837
+ currentOffset += size;
5838
+ }
5839
+ endIndex = startIndex;
5840
+ currentOffset = offsetY;
5841
+ while (endIndex < items.length && currentOffset < scrollTop + containerHeight) {
5842
+ currentOffset += itemSize(endIndex);
5843
+ endIndex++;
5844
+ }
5845
+ startIndex = Math.max(0, startIndex - overscan);
5846
+ endIndex = Math.min(items.length, endIndex + overscan);
5847
+ currentOffset = 0;
5848
+ for (let i = 0; i < startIndex; i++) {
5849
+ currentOffset += itemSize(i);
5850
+ }
5851
+ offsetY = currentOffset;
5852
+ return { startIndex, endIndex, offsetY };
5853
+ }
5854
+ startIndex = Math.max(0, Math.floor(scrollTop / itemSize) - overscan);
5855
+ endIndex = Math.min(items.length, Math.ceil((scrollTop + containerHeight) / itemSize) + overscan);
5856
+ offsetY = startIndex * itemSize;
5857
+ return { startIndex, endIndex, offsetY };
5858
+ }
5859
+ function normalizeOptions$2(binding) {
5860
+ var _a, _b, _c, _d;
5861
+ if (Array.isArray(binding)) {
5862
+ return {
5863
+ items: binding,
5864
+ itemSize: 50,
5865
+ height: 400,
5866
+ overscan: 3,
5867
+ keyField: "id"
5868
+ };
5869
+ }
5870
+ return {
5871
+ items: binding.items,
5872
+ itemSize: (_a = binding.itemSize) != null ? _a : 50,
5873
+ height: (_b = binding.height) != null ? _b : 400,
5874
+ overscan: (_c = binding.overscan) != null ? _c : 3,
5875
+ render: binding.render,
5876
+ keyField: (_d = binding.keyField) != null ? _d : "id",
5877
+ onScroll: binding.onScroll,
5878
+ onVisibleChange: binding.onVisibleChange
5879
+ };
5880
+ }
5881
+ function createItemElement(item, index, options) {
5882
+ const el = document.createElement("div");
5883
+ el.className = "v-virtual-list__item";
5884
+ el.dataset.index = String(index);
5885
+ const keyField = options.keyField || "id";
5886
+ if (typeof item === "object" && item !== null && keyField in item) {
5887
+ el.dataset.key = String(item[keyField]);
5888
+ }
5889
+ const height = getItemSize(options, index);
5890
+ el.style.height = `${height}px`;
5891
+ el.style.boxSizing = "border-box";
5892
+ if (options.render) {
5893
+ el.innerHTML = options.render(item, index);
5894
+ } else {
5895
+ el.textContent = typeof item === "object" ? JSON.stringify(item) : String(item);
5896
+ }
5897
+ return el;
5898
+ }
5899
+ const vVirtualList = defineDirective({
5900
+ name: "virtual-list",
5901
+ ssr: false,
5902
+ mounted(el, binding) {
5903
+ const options = normalizeOptions$2(binding.value);
5904
+ el.classList.add("v-virtual-list");
5905
+ el.style.height = typeof options.height === "number" ? `${options.height}px` : options.height;
5906
+ el.style.overflow = "auto";
5907
+ el.style.position = "relative";
5908
+ const contentEl = document.createElement("div");
5909
+ contentEl.className = "v-virtual-list__content";
5910
+ contentEl.style.position = "relative";
5911
+ contentEl.style.height = `${calculateTotalHeight(options)}px`;
5912
+ el.appendChild(contentEl);
5913
+ const visibleEl = document.createElement("div");
5914
+ visibleEl.className = "v-virtual-list__visible";
5915
+ visibleEl.style.position = "absolute";
5916
+ visibleEl.style.top = "0";
5917
+ visibleEl.style.left = "0";
5918
+ visibleEl.style.right = "0";
5919
+ contentEl.appendChild(visibleEl);
5920
+ const state = {
5921
+ options,
5922
+ containerEl: el,
5923
+ contentEl,
5924
+ scrollHandler: null,
5925
+ resizeObserver: null,
5926
+ startIndex: 0,
5927
+ endIndex: 0,
5928
+ visibleItems: []
5929
+ };
5930
+ el.__virtualList = state;
5931
+ const scrollHandler = (_event) => {
5932
+ const scrollTop = el.scrollTop;
5933
+ const containerHeight = el.clientHeight;
5934
+ const { startIndex: startIndex2, endIndex: endIndex2, offsetY: offsetY2 } = calculateVisibleRange(
5935
+ scrollTop,
5936
+ containerHeight,
5937
+ state.options
5938
+ );
5939
+ if (startIndex2 !== state.startIndex || endIndex2 !== state.endIndex) {
5940
+ state.startIndex = startIndex2;
5941
+ state.endIndex = endIndex2;
5942
+ renderVisibleItems(visibleEl, state, offsetY2);
5943
+ if (state.options.onVisibleChange) {
5944
+ state.options.onVisibleChange(startIndex2, endIndex2);
5945
+ }
5946
+ }
5947
+ if (state.options.onScroll) {
5948
+ state.options.onScroll(scrollTop);
5949
+ }
5950
+ };
5951
+ state.scrollHandler = scrollHandler;
5952
+ el.addEventListener("scroll", scrollHandler, { passive: true });
5953
+ const { startIndex, endIndex, offsetY } = calculateVisibleRange(0, el.clientHeight, options);
5954
+ state.startIndex = startIndex;
5955
+ state.endIndex = endIndex;
5956
+ renderVisibleItems(visibleEl, state, offsetY);
5957
+ if (typeof ResizeObserver !== "undefined") {
5958
+ const resizeObserver = new ResizeObserver(() => {
5959
+ scrollHandler(new Event("scroll"));
5960
+ });
5961
+ resizeObserver.observe(el);
5962
+ state.resizeObserver = resizeObserver;
5963
+ }
5964
+ },
5965
+ updated(el, binding) {
5966
+ var _a;
5967
+ const state = el.__virtualList;
5968
+ if (!state) return;
5969
+ const newOptions = normalizeOptions$2(binding.value);
5970
+ state.options = newOptions;
5971
+ if (state.contentEl) {
5972
+ state.contentEl.style.height = `${calculateTotalHeight(newOptions)}px`;
5973
+ }
5974
+ const scrollTop = el.scrollTop;
5975
+ const containerHeight = el.clientHeight;
5976
+ const { startIndex, endIndex, offsetY } = calculateVisibleRange(
5977
+ scrollTop,
5978
+ containerHeight,
5979
+ newOptions
5980
+ );
5981
+ state.startIndex = startIndex;
5982
+ state.endIndex = endIndex;
5983
+ const visibleEl = (_a = state.contentEl) == null ? void 0 : _a.querySelector(".v-virtual-list__visible");
5984
+ if (visibleEl) {
5985
+ renderVisibleItems(visibleEl, state, offsetY);
5986
+ }
5987
+ },
5988
+ unmounted(el) {
5989
+ const state = el.__virtualList;
5990
+ if (!state) return;
5991
+ if (state.scrollHandler) {
5992
+ el.removeEventListener("scroll", state.scrollHandler);
5993
+ }
5994
+ if (state.resizeObserver) {
5995
+ state.resizeObserver.disconnect();
5996
+ }
5997
+ delete el.__virtualList;
5998
+ }
5999
+ });
6000
+ function renderVisibleItems(visibleEl, state, offsetY) {
6001
+ const { options, startIndex, endIndex } = state;
6002
+ visibleEl.style.transform = `translateY(${offsetY}px)`;
6003
+ visibleEl.innerHTML = "";
6004
+ for (let i = startIndex; i < endIndex; i++) {
6005
+ const item = options.items[i];
6006
+ if (item !== void 0) {
6007
+ const itemEl = createItemElement(item, i, options);
6008
+ visibleEl.appendChild(itemEl);
6009
+ }
6010
+ }
6011
+ }
6012
+ function normalizeOptions$1(binding) {
4680
6013
  if (typeof binding === "boolean") {
4681
6014
  return { initial: binding };
4682
6015
  }
@@ -4698,7 +6031,7 @@ var __async = (__this, __arguments, generator) => {
4698
6031
  mounted(el, binding) {
4699
6032
  var _a, _b;
4700
6033
  if (!isBrowser()) return;
4701
- const options = normalizeOptions(binding.value);
6034
+ const options = normalizeOptions$1(binding.value);
4702
6035
  const originalDisplay = el.style.display;
4703
6036
  const originalVisibility = el.style.visibility;
4704
6037
  const state = {
@@ -4722,7 +6055,7 @@ var __async = (__this, __arguments, generator) => {
4722
6055
  var _a;
4723
6056
  const state = el.__visible;
4724
6057
  if (!state) return;
4725
- const newOptions = normalizeOptions(binding.value);
6058
+ const newOptions = normalizeOptions$1(binding.value);
4726
6059
  let newVisibility;
4727
6060
  if (typeof binding.value === "boolean") {
4728
6061
  newVisibility = binding.value;
@@ -4783,12 +6116,178 @@ var __async = (__this, __arguments, generator) => {
4783
6116
  state.options.handler(isVisible);
4784
6117
  }
4785
6118
  }
6119
+ function createWatermarkCanvas(options) {
6120
+ var _a;
6121
+ const canvas = document.createElement("canvas");
6122
+ const ctx = canvas.getContext("2d");
6123
+ if (!ctx) {
6124
+ throw new Error("[Directix] v-watermark: Could not get canvas context");
6125
+ }
6126
+ const width = options.width || 300;
6127
+ const height = options.height || 200;
6128
+ const fontSize = options.fontSize || 16;
6129
+ const fontFamily = options.fontFamily || "sans-serif";
6130
+ const fontWeight = options.fontWeight || "normal";
6131
+ const color = options.color || "rgba(128, 128, 128, 0.15)";
6132
+ const rotate = (_a = options.rotate) != null ? _a : -22;
6133
+ canvas.width = width;
6134
+ canvas.height = height;
6135
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
6136
+ ctx.fillStyle = color;
6137
+ ctx.textAlign = "center";
6138
+ ctx.textBaseline = "middle";
6139
+ ctx.translate(width / 2, height / 2);
6140
+ ctx.rotate(rotate * Math.PI / 180);
6141
+ const content = Array.isArray(options.content) ? options.content : [options.content];
6142
+ const lineHeight = fontSize * 1.5;
6143
+ const startY = -((content.length - 1) * lineHeight) / 2;
6144
+ content.forEach((text, index) => {
6145
+ ctx.fillText(text, 0, startY + index * lineHeight);
6146
+ });
6147
+ return canvas;
6148
+ }
6149
+ function createWatermarkElement(canvas, options) {
6150
+ var _a;
6151
+ const gap = Array.isArray(options.gap) ? options.gap : [options.gap || 100, options.gap || 100];
6152
+ const zIndex = (_a = options.zIndex) != null ? _a : 9999;
6153
+ const el = document.createElement("div");
6154
+ el.className = "v-watermark";
6155
+ el.style.cssText = `
6156
+ position: absolute;
6157
+ top: 0;
6158
+ left: 0;
6159
+ width: 100%;
6160
+ height: 100%;
6161
+ pointer-events: none;
6162
+ z-index: ${zIndex};
6163
+ background-image: url("${canvas.toDataURL()}");
6164
+ background-repeat: repeat;
6165
+ background-position: ${gap[0] / 2}px ${gap[1] / 2}px;
6166
+ background-size: ${canvas.width + gap[0]}px ${canvas.height + gap[1]}px;
6167
+ `;
6168
+ return el;
6169
+ }
6170
+ function normalizeOptions(binding) {
6171
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
6172
+ if (typeof binding === "string") {
6173
+ return { content: binding };
6174
+ }
6175
+ return {
6176
+ content: binding.content,
6177
+ width: (_a = binding.width) != null ? _a : 300,
6178
+ height: (_b = binding.height) != null ? _b : 200,
6179
+ rotate: (_c = binding.rotate) != null ? _c : -22,
6180
+ fontSize: (_d = binding.fontSize) != null ? _d : 16,
6181
+ fontFamily: (_e = binding.fontFamily) != null ? _e : "sans-serif",
6182
+ fontWeight: (_f = binding.fontWeight) != null ? _f : "normal",
6183
+ color: (_g = binding.color) != null ? _g : "rgba(128, 128, 128, 0.15)",
6184
+ gap: (_h = binding.gap) != null ? _h : [100, 100],
6185
+ zIndex: (_i = binding.zIndex) != null ? _i : 9999,
6186
+ disabled: (_j = binding.disabled) != null ? _j : false,
6187
+ protect: (_k = binding.protect) != null ? _k : true
6188
+ };
6189
+ }
6190
+ const vWatermark = defineDirective({
6191
+ name: "watermark",
6192
+ ssr: true,
6193
+ mounted(el, binding) {
6194
+ const options = normalizeOptions(binding.value);
6195
+ const computedStyle = getComputedStyle(el);
6196
+ if (computedStyle.position === "static") {
6197
+ el.style.position = "relative";
6198
+ }
6199
+ const state = {
6200
+ options,
6201
+ watermarkEl: null,
6202
+ observer: null,
6203
+ canvas: null
6204
+ };
6205
+ el.__watermark = state;
6206
+ if (!options.disabled) {
6207
+ applyWatermark(el, state);
6208
+ }
6209
+ },
6210
+ updated(el, binding) {
6211
+ const state = el.__watermark;
6212
+ if (!state) return;
6213
+ const newOptions = normalizeOptions(binding.value);
6214
+ if (newOptions.disabled && !state.options.disabled) {
6215
+ removeWatermark(state);
6216
+ } else if (!newOptions.disabled && state.options.disabled) {
6217
+ state.options = newOptions;
6218
+ applyWatermark(el, state);
6219
+ } else if (!newOptions.disabled) {
6220
+ state.options = newOptions;
6221
+ removeWatermark(state);
6222
+ applyWatermark(el, state);
6223
+ }
6224
+ state.options = newOptions;
6225
+ },
6226
+ unmounted(el) {
6227
+ const state = el.__watermark;
6228
+ if (!state) return;
6229
+ removeWatermark(state);
6230
+ delete el.__watermark;
6231
+ }
6232
+ });
6233
+ function applyWatermark(el, state) {
6234
+ const options = state.options;
6235
+ state.canvas = createWatermarkCanvas(options);
6236
+ state.watermarkEl = createWatermarkElement(state.canvas, options);
6237
+ el.appendChild(state.watermarkEl);
6238
+ if (options.protect) {
6239
+ setupProtection(el, state);
6240
+ }
6241
+ }
6242
+ function removeWatermark(state) {
6243
+ if (state.observer) {
6244
+ state.observer.disconnect();
6245
+ state.observer = null;
6246
+ }
6247
+ if (state.watermarkEl && state.watermarkEl.parentNode) {
6248
+ state.watermarkEl.parentNode.removeChild(state.watermarkEl);
6249
+ }
6250
+ state.watermarkEl = null;
6251
+ state.canvas = null;
6252
+ }
6253
+ function setupProtection(el, state) {
6254
+ if (typeof MutationObserver === "undefined") return;
6255
+ state.observer = new MutationObserver((mutations) => {
6256
+ if (!state.watermarkEl || !el.contains(state.watermarkEl)) {
6257
+ if (!state.options.disabled) {
6258
+ state.canvas = createWatermarkCanvas(state.options);
6259
+ state.watermarkEl = createWatermarkElement(state.canvas, state.options);
6260
+ el.appendChild(state.watermarkEl);
6261
+ }
6262
+ }
6263
+ for (const mutation of mutations) {
6264
+ if (mutation.type === "attributes" && mutation.target === state.watermarkEl) {
6265
+ const gap = Array.isArray(state.options.gap) ? state.options.gap : [state.options.gap || 100, state.options.gap || 100];
6266
+ state.watermarkEl.style.display = "block";
6267
+ state.watermarkEl.style.visibility = "visible";
6268
+ state.watermarkEl.style.opacity = "1";
6269
+ if (state.canvas) {
6270
+ state.watermarkEl.style.backgroundImage = `url("${state.canvas.toDataURL()}")`;
6271
+ }
6272
+ state.watermarkEl.style.backgroundSize = `${state.canvas.width + gap[0]}px ${state.canvas.height + gap[1]}px`;
6273
+ }
6274
+ }
6275
+ });
6276
+ state.observer.observe(el, {
6277
+ childList: true,
6278
+ subtree: true,
6279
+ attributes: true,
6280
+ attributeFilter: ["style", "class", "hidden"]
6281
+ });
6282
+ }
4786
6283
  const allDirectives = {
4787
6284
  "click-outside": vClickOutside,
6285
+ "click-delay": vClickDelay,
4788
6286
  copy: vCopy,
4789
6287
  debounce: vDebounce,
4790
6288
  throttle: vThrottle,
4791
6289
  focus: vFocus,
6290
+ hotkey: vHotkey,
4792
6291
  lazy: vLazy,
4793
6292
  intersect: vIntersect,
4794
6293
  visible: vVisible,
@@ -4805,6 +6304,7 @@ var __async = (__this, __arguments, generator) => {
4805
6304
  resize: vResize,
4806
6305
  mutation: vMutation,
4807
6306
  truncate: vTruncate,
6307
+ ellipsis: vEllipsis,
4808
6308
  uppercase: vUppercase,
4809
6309
  lowercase: vLowercase,
4810
6310
  capitalcase: vCapitalcase,
@@ -4814,7 +6314,13 @@ var __async = (__this, __arguments, generator) => {
4814
6314
  tooltip: vTooltip,
4815
6315
  draggable: vDraggable,
4816
6316
  touch: vTouch,
4817
- "image-preview": vImagePreview
6317
+ swipe: vSwipe,
6318
+ "image-preview": vImagePreview,
6319
+ countdown: vCountdown,
6320
+ watermark: vWatermark,
6321
+ print: vPrint,
6322
+ "virtual-list": vVirtualList,
6323
+ "pull-refresh": vPullRefresh
4818
6324
  };
4819
6325
  const install = (app, options = {}) => {
4820
6326
  var _a, _b, _c, _d, _e, _f, _g;
@@ -4859,9 +6365,11 @@ var __async = (__this, __arguments, generator) => {
4859
6365
  exports.addCleanupVue2 = addCleanup$1;
4860
6366
  exports.addCleanupVue3 = addCleanup;
4861
6367
  exports.capitalcase = vCapitalcase;
6368
+ exports.clickDelay = vClickDelay;
4862
6369
  exports.clickOutside = vClickOutside;
4863
6370
  exports.configurePermission = configurePermission;
4864
6371
  exports.copy = vCopy;
6372
+ exports.countdown = vCountdown;
4865
6373
  exports.createVue2Directive = createVue2Directive;
4866
6374
  exports.createVue3Directive = createVue3Directive;
4867
6375
  exports.debounce = vDebounce;
@@ -4871,11 +6379,13 @@ var __async = (__this, __arguments, generator) => {
4871
6379
  exports.defineDirective = defineDirective;
4872
6380
  exports.defineDirectiveGroup = defineDirectiveGroup;
4873
6381
  exports.draggable = vDraggable;
6382
+ exports.ellipsis = vEllipsis;
4874
6383
  exports.focus = vFocus;
4875
6384
  exports.generateId = generateId;
4876
6385
  exports.get = get;
4877
6386
  exports.getPermissionConfig = getPermissionConfig;
4878
6387
  exports.getVueVersion = getVueVersion;
6388
+ exports.hotkey = vHotkey;
4879
6389
  exports.hover = vHover;
4880
6390
  exports.imagePreview = vImagePreview;
4881
6391
  exports.infiniteScroll = vInfiniteScroll;
@@ -4903,6 +6413,8 @@ var __async = (__this, __arguments, generator) => {
4903
6413
  exports.number = vNumber;
4904
6414
  exports.parseTime = parseTime;
4905
6415
  exports.permission = vPermission;
6416
+ exports.print = vPrint;
6417
+ exports.pullRefresh = vPullRefresh;
4906
6418
  exports.resetVueVersion = resetVueVersion;
4907
6419
  exports.resize = vResize;
4908
6420
  exports.ripple = vRipple;
@@ -4916,6 +6428,7 @@ var __async = (__this, __arguments, generator) => {
4916
6428
  exports.supportsMutationObserver = supportsMutationObserver;
4917
6429
  exports.supportsPassive = supportsPassive;
4918
6430
  exports.supportsResizeObserver = supportsResizeObserver;
6431
+ exports.swipe = vSwipe;
4919
6432
  exports.throttle = vThrottle;
4920
6433
  exports.throttleFn = throttle;
4921
6434
  exports.tooltip = vTooltip;
@@ -4924,11 +6437,15 @@ var __async = (__this, __arguments, generator) => {
4924
6437
  exports.truncate = vTruncate;
4925
6438
  exports.uppercase = vUppercase;
4926
6439
  exports.vCapitalcase = vCapitalcase;
6440
+ exports.vClickDelay = vClickDelay;
4927
6441
  exports.vClickOutside = vClickOutside;
4928
6442
  exports.vCopy = vCopy;
6443
+ exports.vCountdown = vCountdown;
4929
6444
  exports.vDebounce = vDebounce;
4930
6445
  exports.vDraggable = vDraggable;
6446
+ exports.vEllipsis = vEllipsis;
4931
6447
  exports.vFocus = vFocus;
6448
+ exports.vHotkey = vHotkey;
4932
6449
  exports.vHover = vHover;
4933
6450
  exports.vImagePreview = vImagePreview;
4934
6451
  exports.vInfiniteScroll = vInfiniteScroll;
@@ -4942,19 +6459,26 @@ var __async = (__this, __arguments, generator) => {
4942
6459
  exports.vMutation = vMutation;
4943
6460
  exports.vNumber = vNumber;
4944
6461
  exports.vPermission = vPermission;
6462
+ exports.vPrint = vPrint;
6463
+ exports.vPullRefresh = vPullRefresh;
4945
6464
  exports.vResize = vResize;
4946
6465
  exports.vRipple = vRipple;
4947
6466
  exports.vSanitize = vSanitize;
4948
6467
  exports.vScroll = vScroll;
4949
6468
  exports.vSticky = vSticky;
6469
+ exports.vSwipe = vSwipe;
4950
6470
  exports.vThrottle = vThrottle;
4951
6471
  exports.vTooltip = vTooltip;
4952
6472
  exports.vTouch = vTouch;
4953
6473
  exports.vTrim = vTrim;
4954
6474
  exports.vTruncate = vTruncate;
4955
6475
  exports.vUppercase = vUppercase;
6476
+ exports.vVirtualList = vVirtualList;
4956
6477
  exports.vVisible = vVisible;
6478
+ exports.vWatermark = vWatermark;
6479
+ exports.virtualList = vVirtualList;
4957
6480
  exports.visible = vVisible;
6481
+ exports.watermark = vWatermark;
4958
6482
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4959
6483
  })(this.Directix = this.Directix || {});
4960
6484
  //# sourceMappingURL=index.iife.js.map