hys-ui 0.4.0 → 0.6.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +3 -3
  3. package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +440 -119
  4. package/dist/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas.vue.js +7 -0
  5. package/dist/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas2.vue.js +166 -0
  6. package/dist/components/HysAnimatedNumber/NumberDigits/NumberDigits.vue.js +7 -0
  7. package/dist/components/HysAnimatedNumber/NumberDigits/NumberDigits2.vue.js +105 -0
  8. package/dist/components/HysAnimatedNumber/animation/digital.js +186 -0
  9. package/dist/components/HysAnimatedNumber/animation/morph.js +110 -0
  10. package/dist/components/HysAnimatedNumber/animation/paint.js +34 -0
  11. package/dist/components/HysAnimatedNumber/animation/particles.js +51 -0
  12. package/dist/components/HysAnimatedNumber/animation/paths.js +165 -0
  13. package/dist/components/HysAnimatedNumber/animation/physics.js +66 -0
  14. package/dist/components/HysAnimatedNumber/animation/render.js +89 -0
  15. package/dist/components/HysAnimatedNumber/animation/reveal.js +125 -0
  16. package/dist/components/HysAnimatedNumber/animation/rolling.js +66 -0
  17. package/dist/components/HysAnimatedNumber/animation/scenarios.js +217 -0
  18. package/dist/components/HysAnimatedNumber/animation/spatial.js +112 -0
  19. package/dist/components/HysAnimatedNumber/useNumberCountdown.js +58 -0
  20. package/dist/components/HysAnimatedNumber/useNumberVisuals.js +60 -0
  21. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  22. package/dist/components/HysDrawer/HysDrawer2.vue.js +2 -2
  23. package/dist/components/HysFormItem/HysFormItem.vue.js +1 -1
  24. package/dist/components/HysFormItem/HysFormItem2.vue.js +231 -229
  25. package/dist/components/HysInput/HysInput.vue.js +2 -2
  26. package/dist/components/HysInput/HysInput2.vue.js +327 -274
  27. package/dist/components/HysModal/HysModal.vue.js +2 -2
  28. package/dist/components/HysModal/HysModal2.vue.js +38 -38
  29. package/dist/components/HysSearch/HysSearch.vue.js +2 -2
  30. package/dist/components/HysSortableList/HysSortableList.vue.js +2 -2
  31. package/dist/components/HysSortableList/HysSortableList2.vue.js +498 -129
  32. package/dist/components/HysSortableList/SortableGhost/SortableGhost.vue.js +7 -0
  33. package/dist/components/HysSortableList/SortableGhost/SortableGhost2.vue.js +43 -0
  34. package/dist/components/HysSortableList/SortableGhost/useSortGhost.js +54 -0
  35. package/dist/components/HysSortableList/geometry.js +230 -0
  36. package/dist/components/HysSortableList/model.js +254 -0
  37. package/dist/components/HysSortableList/transactions.js +281 -0
  38. package/dist/components/HysSortableList/useSortDrag.js +270 -0
  39. package/dist/components/HysSortableList/useSortKeyboard.js +72 -0
  40. package/dist/components/HysSortableList/useSortWindow.js +144 -0
  41. package/dist/components/HysTextarea/HysTextarea.vue.js +56 -32
  42. package/dist/components/HysToast/HysToast.vue.js +3 -3
  43. package/dist/components/HysToast/HysToast2.vue.js +379 -107
  44. package/dist/components/HysToast/ToastViewport/ToastViewport.vue.js +7 -0
  45. package/dist/components/HysToast/ToastViewport/ToastViewport2.vue.js +211 -0
  46. package/dist/components/HysToast/ToastViewport/useToastStackDisclosure.js +71 -0
  47. package/dist/components/HysToast/toastPresentation.js +98 -0
  48. package/dist/components/HysToast/useToastActions.js +62 -0
  49. package/dist/components/HysToast/useToastSwipe.js +48 -0
  50. package/dist/components/HysToast/useToastTimer.js +90 -0
  51. package/dist/composables/animatedNumberDigits.js +106 -0
  52. package/dist/composables/animatedNumberFormat.js +222 -0
  53. package/dist/composables/animatedNumberTiming.js +66 -0
  54. package/dist/composables/numberAnimation.js +72 -0
  55. package/dist/composables/numberAnimationCatalog.js +301 -0
  56. package/dist/composables/numberAnimationSequence.js +45 -0
  57. package/dist/composables/popupReferenceBinding.js +41 -0
  58. package/dist/composables/textInput.js +23 -14
  59. package/dist/composables/toastEscape.js +18 -10
  60. package/dist/composables/toastQueue.js +276 -0
  61. package/dist/composables/toastQueueModel.js +86 -0
  62. package/dist/composables/toastTasks.js +58 -0
  63. package/dist/composables/useHysAnimatedNumber.js +264 -0
  64. package/dist/composables/useHysNumberAnimationGroup.js +23 -0
  65. package/dist/composables/useHysToast.js +117 -135
  66. package/dist/composables/usePopupSurface.js +190 -356
  67. package/dist/composables/usePopupSurfaceInteractions.js +172 -0
  68. package/dist/composables/useTextareaSize.js +62 -46
  69. package/dist/index.js +125 -111
  70. package/dist/style.css +1 -1
  71. package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +88 -49
  72. package/dist/types/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas.vue.d.ts +19 -0
  73. package/dist/types/components/HysAnimatedNumber/NumberDigits/NumberDigits.vue.d.ts +31 -0
  74. package/dist/types/components/HysAnimatedNumber/animation/digital.d.ts +3 -0
  75. package/dist/types/components/HysAnimatedNumber/animation/morph.d.ts +2 -0
  76. package/dist/types/components/HysAnimatedNumber/animation/paint.d.ts +44 -0
  77. package/dist/types/components/HysAnimatedNumber/animation/particles.d.ts +5 -0
  78. package/dist/types/components/HysAnimatedNumber/animation/paths.d.ts +12 -0
  79. package/dist/types/components/HysAnimatedNumber/animation/physics.d.ts +2 -0
  80. package/dist/types/components/HysAnimatedNumber/animation/render.d.ts +2 -0
  81. package/dist/types/components/HysAnimatedNumber/animation/reveal.d.ts +2 -0
  82. package/dist/types/components/HysAnimatedNumber/animation/rolling.d.ts +2 -0
  83. package/dist/types/components/HysAnimatedNumber/animation/scenarios.d.ts +4 -0
  84. package/dist/types/components/HysAnimatedNumber/animation/spatial.d.ts +2 -0
  85. package/dist/types/components/HysAnimatedNumber/useNumberCountdown.d.ts +8 -0
  86. package/dist/types/components/HysAnimatedNumber/useNumberVisuals.d.ts +12 -0
  87. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +11 -2
  88. package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +2 -2
  89. package/dist/types/components/HysCard/HysCard.vue.d.ts +1 -1
  90. package/dist/types/components/HysCascader/HysCascader.vue.d.ts +3 -3
  91. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
  92. package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +2 -2
  93. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +3 -3
  94. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +5 -5
  95. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +3 -3
  96. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -1
  97. package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +1 -1
  98. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +1 -1
  99. package/dist/types/components/HysInput/HysInput.vue.d.ts +13 -1
  100. package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
  101. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
  102. package/dist/types/components/HysPopover/HysPopover.vue.d.ts +1 -1
  103. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +1 -1
  104. package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +2 -2
  105. package/dist/types/components/HysSortableList/HysSortableList.vue.d.ts +48 -25
  106. package/dist/types/components/HysSortableList/SortableGhost/SortableGhost.vue.d.ts +31 -0
  107. package/dist/types/components/HysSortableList/SortableGhost/useSortGhost.d.ts +23 -0
  108. package/dist/types/components/HysSortableList/geometry.d.ts +35 -0
  109. package/dist/types/components/HysSortableList/model.d.ts +61 -0
  110. package/dist/types/components/HysSortableList/sortableList.d.ts +151 -0
  111. package/dist/types/components/HysSortableList/transactions.d.ts +10 -0
  112. package/dist/types/components/HysSortableList/useSortDrag.d.ts +25 -0
  113. package/dist/types/components/HysSortableList/useSortKeyboard.d.ts +17 -0
  114. package/dist/types/components/HysSortableList/useSortWindow.d.ts +16 -0
  115. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
  116. package/dist/types/components/HysTabs/HysTabs.vue.d.ts +1 -1
  117. package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +1 -1
  118. package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +13 -2
  119. package/dist/types/components/HysToast/HysToast.vue.d.ts +44 -46
  120. package/dist/types/components/HysToast/ToastViewport/ToastViewport.vue.d.ts +25 -0
  121. package/dist/types/components/HysToast/ToastViewport/useToastStackDisclosure.d.ts +16 -0
  122. package/dist/types/components/HysToast/toastPresentation.d.ts +8 -0
  123. package/dist/types/components/HysToast/toastTypes.d.ts +212 -0
  124. package/dist/types/components/HysToast/useToastActions.d.ts +18 -0
  125. package/dist/types/components/HysToast/useToastSwipe.d.ts +11 -0
  126. package/dist/types/components/HysToast/useToastTimer.d.ts +22 -0
  127. package/dist/types/components/HysTooltip/HysTooltip.vue.d.ts +1 -1
  128. package/dist/types/components/HysTour/HysTour.vue.d.ts +1 -1
  129. package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +3 -3
  130. package/dist/types/components/HysUpload/HysUpload.vue.d.ts +2 -2
  131. package/dist/types/composables/animatedNumber.d.ts +220 -0
  132. package/dist/types/composables/animatedNumberDigits.d.ts +32 -0
  133. package/dist/types/composables/animatedNumberFormat.d.ts +16 -0
  134. package/dist/types/composables/animatedNumberTiming.d.ts +21 -0
  135. package/dist/types/composables/drawer.d.ts +1 -1
  136. package/dist/types/composables/numberAnimation.d.ts +29 -0
  137. package/dist/types/composables/numberAnimationCatalog.d.ts +58 -0
  138. package/dist/types/composables/numberAnimationSequence.d.ts +13 -0
  139. package/dist/types/composables/popupReferenceBinding.d.ts +9 -0
  140. package/dist/types/composables/textInput.d.ts +39 -4
  141. package/dist/types/composables/toastEscape.d.ts +1 -1
  142. package/dist/types/composables/toastQueue.d.ts +121 -0
  143. package/dist/types/composables/toastQueueModel.d.ts +116 -0
  144. package/dist/types/composables/toastTasks.d.ts +2 -0
  145. package/dist/types/composables/useHysAnimatedNumber.d.ts +37 -0
  146. package/dist/types/composables/useHysNumberAnimationGroup.d.ts +4 -0
  147. package/dist/types/composables/useHysToast.d.ts +4 -48
  148. package/dist/types/composables/usePopupSurface.d.ts +20 -20
  149. package/dist/types/composables/usePopupSurfaceInteractions.d.ts +33 -0
  150. package/dist/types/composables/useTextareaSize.d.ts +5 -2
  151. package/dist/types/index.d.ts +15 -6
  152. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ import o from "./SortableGhost2.vue.js";
2
+ /* empty css */
3
+ import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-e5f0c51b"]]);
5
+ export {
6
+ f as default
7
+ };
@@ -0,0 +1,43 @@
1
+ import { defineComponent as r, openBlock as e, createElementBlock as n, mergeProps as o, createElementVNode as i, normalizeStyle as s, normalizeClass as d, renderSlot as c, createCommentVNode as u } from "vue";
2
+ const g = { key: 0 }, y = /* @__PURE__ */ r({
3
+ __name: "SortableGhost",
4
+ props: {
5
+ track: {},
6
+ appearance: {},
7
+ motion: { type: Boolean },
8
+ ghostClass: {},
9
+ ghostStyle: { type: [Boolean, null, String, Object, Array] }
10
+ },
11
+ setup(t) {
12
+ return (l, h) => {
13
+ var a;
14
+ return e(), n("div", o(t.appearance, {
15
+ class: ["hys-sort-ghost", {
16
+ "hys-sort-returning": t.motion && t.track.returning.value,
17
+ "hys-sort-landing": t.motion && t.track.landing.value
18
+ }],
19
+ style: {
20
+ transform: "translate3d(" + t.track.position.value.x + "px," + t.track.position.value.y + "px,0)",
21
+ width: t.track.width + "px",
22
+ "--hys-sort-landing-duration": t.track.landing.value ? t.track.landing.value.duration + "ms" : void 0,
23
+ "--hys-sort-landing-easing": (a = t.track.landing.value) == null ? void 0 : a.easing
24
+ },
25
+ "aria-hidden": "true"
26
+ }), [
27
+ i("div", {
28
+ class: d(["hys-sort-ghost-card", t.ghostClass]),
29
+ style: s(t.ghostStyle)
30
+ }, [
31
+ c(l.$slots, "default", {
32
+ drag: t.track.drag,
33
+ allowed: t.track.allowed.value
34
+ }, void 0, !0),
35
+ t.track.allowed.value ? u("", !0) : (e(), n("small", g, "不可放置"))
36
+ ], 6)
37
+ ], 16);
38
+ };
39
+ }
40
+ });
41
+ export {
42
+ y as default
43
+ };
@@ -0,0 +1,54 @@
1
+ import { shallowRef as y, watch as C, ref as d } from "vue";
2
+ let x = 0;
3
+ function L(o, c) {
4
+ const i = y(null);
5
+ let f, r, s;
6
+ function h(t, e, n) {
7
+ u(!1), r = e.getBoundingClientRect(), i.value = {
8
+ drag: t,
9
+ width: Math.max(96, Math.min(r.width || 200, 360)),
10
+ position: d(n),
11
+ returning: d(!1),
12
+ landing: d(null),
13
+ allowed: d(!0)
14
+ };
15
+ }
16
+ function u(t, e) {
17
+ clearTimeout(f), s == null || s(), s = void 0;
18
+ const n = i.value;
19
+ if (!t || !n || !r || !o()) {
20
+ i.value = null;
21
+ return;
22
+ }
23
+ const l = e != null && e.isConnected ? e.getBoundingClientRect() : r;
24
+ n.landing.value = null, n.returning.value = !0, n.position.value = { x: l.left, y: l.top }, f = setTimeout(() => {
25
+ i.value === n && (i.value = null);
26
+ }, 200);
27
+ }
28
+ function p(t) {
29
+ const e = i.value, { duration: n, easing: l } = c();
30
+ if (!e || !o() || !Number.isFinite(n) || n <= 0 || !(t != null && t.isConnected))
31
+ return u(!1);
32
+ const v = String(++x);
33
+ t.style.setProperty("--hys-sort-landing-duration", `${n}ms`), t.dataset.sortLanding = v, s = () => {
34
+ t.dataset.sortLanding === v && (delete t.dataset.sortLanding, t.style.removeProperty("--hys-sort-landing-duration"));
35
+ };
36
+ const a = t.getBoundingClientRect(), g = t.ownerDocument.defaultView;
37
+ if (!a.width || !a.height || !g || a.right <= 0 || a.bottom <= 0 || a.left >= g.innerWidth || a.top >= g.innerHeight)
38
+ return u(!1);
39
+ e.landing.value = { duration: n, easing: l }, e.position.value = { x: a.left, y: a.top }, f = setTimeout(() => u(!1), n);
40
+ }
41
+ function m(t, e) {
42
+ const n = i.value;
43
+ return !n || !o() || c().duration <= 0 ? (u(!1), t()) : t((l) => {
44
+ i.value === n && p(l);
45
+ }).then((l) => (!l && i.value === n && u(!0, e()), l));
46
+ }
47
+ return C(o, (t) => {
48
+ const e = i.value;
49
+ !t && (e != null && e.landing.value || e != null && e.returning.value) && u(!1);
50
+ }), { ghost: i, show: h, clear: u, release: m };
51
+ }
52
+ export {
53
+ L as useSortGhost
54
+ };
@@ -0,0 +1,230 @@
1
+ import { layoutOf as E, portAt as L, keyToken as O, linkedPorts as I } from "./model.js";
2
+ function X(t) {
3
+ return t.handle === !1 || t.showHandle === !1 && typeof t.handle != "string";
4
+ }
5
+ function j(t, e, n) {
6
+ var s;
7
+ const r = Array.from(t.childNodes).filter(
8
+ (i) => {
9
+ var c;
10
+ return i.nodeType === Node.TEXT_NODE && ((c = i.textContent) == null ? void 0 : c.trim());
11
+ }
12
+ );
13
+ if (!r.length || ((s = t.ownerDocument.defaultView) == null ? void 0 : s.getComputedStyle(t).userSelect) === "none")
14
+ return !1;
15
+ const o = t.ownerDocument.createRange();
16
+ return r.some((i) => {
17
+ var c;
18
+ return o.selectNodeContents(i), Array.from(((c = o.getClientRects) == null ? void 0 : c.call(o)) ?? []).some(
19
+ ({ left: a, right: l, top: d, bottom: h, width: f }) => f > 0 && e >= a && e <= l && n >= d && n <= h
20
+ );
21
+ });
22
+ }
23
+ function F(t, e, n, r) {
24
+ if (r && !("reason" in r)) {
25
+ if (r.source === t && t.props.livePreview !== !1 && !(t.props.virtual && n.source === "keyboard"))
26
+ return { key: n.keys[0], position: "before" };
27
+ const o = r.proposal.index;
28
+ if (o !== e.index) {
29
+ const s = t.data().items, i = s[o] ?? s.at(-1);
30
+ if (i)
31
+ return {
32
+ key: t.key(i),
33
+ position: o < s.length ? "before" : "after"
34
+ };
35
+ }
36
+ }
37
+ return { key: e.anchor, position: e.position };
38
+ }
39
+ const u = (t, e, n) => Math.max(e, Math.min(n, t)), S = (t) => Array.from(t.children).filter(
40
+ (e) => e instanceof HTMLElement && e.dataset.sortKey !== void 0
41
+ ), y = (t, e) => Math.hypot(
42
+ t.x - u(t.x, e.left, e.right),
43
+ t.y - u(t.y, e.top, e.bottom)
44
+ );
45
+ function Y(t, e, n) {
46
+ var d;
47
+ const { axis: r, bounds: o } = t.props, s = r === "y" ? n.x : e.x, i = r === "x" ? n.y : e.y, c = o === "list" ? t.root() : typeof o == "function" ? o() : typeof o == "object" ? o : void 0, a = c == null ? void 0 : c.getBoundingClientRect(), l = (d = t.root()) == null ? void 0 : d.ownerDocument.defaultView;
48
+ return a ? {
49
+ point: {
50
+ x: u(s, a.left, a.right),
51
+ y: u(i, a.top, a.bottom)
52
+ },
53
+ inside: y({ x: s, y: i }, a) === 0
54
+ } : l ? {
55
+ point: {
56
+ x: u(s, 0, l.innerWidth),
57
+ y: u(i, 0, l.innerHeight)
58
+ },
59
+ inside: s >= 0 && i >= 0 && s < l.innerWidth && i < l.innerHeight
60
+ } : { point: { x: s, y: i }, inside: !0 };
61
+ }
62
+ function W(t) {
63
+ var s;
64
+ if (!t) return 1;
65
+ const e = Number(t.dataset.sortColumns);
66
+ if (e > 0) return e;
67
+ const n = S(t), r = ((s = n[0]) == null ? void 0 : s.getBoundingClientRect().top) ?? 0, o = n.findIndex(
68
+ (i) => Math.abs(i.getBoundingClientRect().top - r) > 2
69
+ );
70
+ return o > 0 ? o : Math.max(1, n.length);
71
+ }
72
+ function A(t, e) {
73
+ const n = t.getBoundingClientRect();
74
+ if (!e.some((c) => t.classList.contains(c)))
75
+ return n;
76
+ const r = t.ownerDocument.defaultView;
77
+ if (!(r != null && r.DOMMatrixReadOnly)) return n;
78
+ const o = r.getComputedStyle(t).transform;
79
+ if (o === "none") return n;
80
+ const { m41: s, m42: i } = new r.DOMMatrixReadOnly(o);
81
+ return {
82
+ left: n.left - s,
83
+ right: n.right - s,
84
+ top: n.top - i,
85
+ bottom: n.bottom - i,
86
+ width: n.width,
87
+ height: n.height
88
+ };
89
+ }
90
+ function z(t, e, n) {
91
+ let r, o = 1 / 0;
92
+ for (const s of S(t)) {
93
+ const i = A(s, n), c = y(e, i);
94
+ if (c < o && (o = c, r = { row: s, box: i }, c === 0))
95
+ break;
96
+ }
97
+ return r;
98
+ }
99
+ function P(t, e) {
100
+ var o;
101
+ let n, r = 17;
102
+ for (const s of I(t)) {
103
+ if (!t.props.snap && !s.props.snap) continue;
104
+ const i = s.surface();
105
+ if (!i || i.ownerDocument !== ((o = t.root()) == null ? void 0 : o.ownerDocument) || !i.isConnected)
106
+ continue;
107
+ const c = y(e, i.getBoundingClientRect());
108
+ c < r && (r = c, n = s);
109
+ }
110
+ return n;
111
+ }
112
+ function U(t, e) {
113
+ var b, D;
114
+ const n = (b = t.root()) == null ? void 0 : b.ownerDocument, r = ((D = n == null ? void 0 : n.elementFromPoint) == null ? void 0 : D.call(n, e.x, e.y)) ?? null, o = L(r) ?? P(t, e), s = o == null ? void 0 : o.surface();
115
+ if (!o || !s) return { element: r };
116
+ const i = o.data();
117
+ if (!i.items.length)
118
+ return { element: r, candidate: { port: o, index: 0, position: "inside" } };
119
+ const c = (o.props.moveClass || "hys-sort-motion-move").split(/\s+/).filter(Boolean), a = r == null ? void 0 : r.closest("[data-sort-key]"), l = (a == null ? void 0 : a.parentElement) === s ? A(a, c) : void 0, d = a && l && y(e, l) === 0 ? { row: a, box: l } : z(s, e, c);
120
+ if (!d) return { element: r };
121
+ const { row: h, box: f } = d, g = Number(h.dataset.sortIndex);
122
+ if (!Number.isInteger(g) || g < 0 || g >= i.items.length)
123
+ return { element: r };
124
+ const x = E(o.props), m = x === "horizontal" || x === "grid" && f.width + 1 < s.clientWidth, T = m && getComputedStyle(s).direction === "rtl";
125
+ let w = m ? e.x >= f.left + f.width / 2 !== T : e.y >= f.top + f.height / 2;
126
+ e.y < f.top && (w = !1), e.y > f.bottom && (w = !0);
127
+ const C = t === o && o.props.mode === "swap", p = m ? e.x - f.left : e.y - f.top, M = m ? f.width : f.height, v = u(M * 0.12, 4, 10), B = Math.min(Math.abs(p), Math.abs(M - p)), H = x === "grid" ? Math.min(Math.abs(e.y - f.top), Math.abs(e.y - f.bottom)) : 1 / 0, N = i.items[g];
128
+ return {
129
+ element: r,
130
+ rowKey: h.dataset.sortKey,
131
+ nearCenter: !C && Math.abs(p - M / 2) <= v,
132
+ nearEdge: Math.min(B, H) <= v,
133
+ candidate: {
134
+ port: o,
135
+ index: g + (w && !C ? 1 : 0),
136
+ position: w ? "after" : "before",
137
+ anchor: o.key(N)
138
+ }
139
+ };
140
+ }
141
+ function _(t, e, n) {
142
+ if (!e || !(n != null && n.candidate) || e.port !== n.candidate.port)
143
+ return !1;
144
+ const r = n.candidate;
145
+ if (r.port === t && t.props.mode === "swap") return n.nearEdge;
146
+ const o = Math.abs(e.index - r.index);
147
+ return o === 0 ? n.nearEdge : o === 1 && n.nearCenter;
148
+ }
149
+ function V(t, e, n) {
150
+ const r = e.data().items, o = r.at(-1), s = r[n] ?? o;
151
+ return {
152
+ port: e,
153
+ index: n,
154
+ position: r.length ? n >= r.length && (t !== e || e.props.mode !== "swap") ? "after" : "before" : "inside",
155
+ anchor: s ? e.key(s) : void 0
156
+ };
157
+ }
158
+ function q(t, e, n) {
159
+ const r = t.data().keys.get(e);
160
+ if (r === void 0 || !Number.isInteger(n) || !n) return;
161
+ const o = r + n;
162
+ if (!(o < 0 || o >= t.data().items.length))
163
+ return V(
164
+ t,
165
+ t,
166
+ o + (t.props.mode !== "swap" && n > 0 ? 1 : 0)
167
+ );
168
+ }
169
+ function G(t, e) {
170
+ const n = E(t.props), r = n === "horizontal", o = n === "grid", s = t.surface();
171
+ if (e === "ArrowLeft" || e === "ArrowRight") {
172
+ if (!r && !o) return 0;
173
+ const i = s && getComputedStyle(s).direction === "rtl";
174
+ return e === "ArrowRight" !== i ? 1 : -1;
175
+ }
176
+ return e === "ArrowUp" || e === "ArrowDown" ? r ? 0 : (e === "ArrowDown" ? 1 : -1) * (o ? W(s) : 1) : 0;
177
+ }
178
+ function J(t, e) {
179
+ return (t == null ? void 0 : t.port) === (e == null ? void 0 : e.port) && (t == null ? void 0 : t.index) === (e == null ? void 0 : e.index) && (t == null ? void 0 : t.position) === (e == null ? void 0 : e.position) && (t == null ? void 0 : t.anchor) === (e == null ? void 0 : e.anchor);
180
+ }
181
+ const Q = O;
182
+ function k(t, e, n, r, o) {
183
+ if (t < e || t > n) return 0;
184
+ const s = Math.min(r, (n - e) / 2);
185
+ return s ? t < e + s ? -Math.ceil(o * (1 - (t - e) / s)) : t > n - s ? Math.ceil(o * (1 - (n - t) / s)) : 0 : 0;
186
+ }
187
+ function R(t, e, n, r, o, s) {
188
+ const i = t.ownerDocument.defaultView;
189
+ if (!i) return { x: !1, y: !1 };
190
+ const c = r ? { left: 0, top: 0, right: i.innerWidth, bottom: i.innerHeight } : t.getBoundingClientRect();
191
+ if (y(e, c) > 0) return { x: !1, y: !1 };
192
+ const a = getComputedStyle(t), l = u(n.threshold ?? 36, 1, 200), d = u(n.speed ?? 14, 1, 100), h = t.scrollLeft, f = t.scrollTop;
193
+ return !o && n.axis !== "y" && t.scrollWidth > t.clientWidth && (r || /auto|scroll|overlay/.test(a.overflowX)) && (t.scrollLeft += k(
194
+ e.x,
195
+ c.left,
196
+ c.right,
197
+ l,
198
+ d
199
+ )), !s && n.axis !== "x" && t.scrollHeight > t.clientHeight && (r || /auto|scroll|overlay/.test(a.overflowY)) && (t.scrollTop += k(e.y, c.top, c.bottom, l, d)), { x: t.scrollLeft !== h, y: t.scrollTop !== f };
200
+ }
201
+ function Z(t, e, n) {
202
+ if (n === !1 || !t) return !1;
203
+ const r = typeof n == "object" ? n : {}, o = t.ownerDocument.scrollingElement;
204
+ let s = !1, i = !1;
205
+ for (let c = t; c && !(s && i); c = c.parentElement) {
206
+ if (!(c instanceof HTMLElement) || c === o) continue;
207
+ const a = R(c, e, r, !1, s, i);
208
+ s || (s = a.x), i || (i = a.y);
209
+ }
210
+ if (r.window !== !1 && o instanceof HTMLElement && !(s && i)) {
211
+ const c = R(o, e, r, !0, s, i);
212
+ s || (s = c.x), i || (i = c.y);
213
+ }
214
+ return s || i;
215
+ }
216
+ export {
217
+ Z as autoScrollSort,
218
+ V as candidateAt,
219
+ F as dropMarkerFor,
220
+ U as findSortHit,
221
+ W as gridColumns,
222
+ j as hitsSelectableText,
223
+ _ as keepSortCandidate,
224
+ G as keyStep,
225
+ q as relativeCandidate,
226
+ J as sameCandidate,
227
+ Q as tokenOf,
228
+ X as wholeRowDrag,
229
+ Y as withinDragBounds
230
+ };
@@ -0,0 +1,254 @@
1
+ import { toRaw as b } from "vue";
2
+ const g = /* @__PURE__ */ new Map(), P = (t) => t;
3
+ function G(t, o) {
4
+ return g.set(t, o), () => {
5
+ g.delete(t);
6
+ };
7
+ }
8
+ const K = () => Array.from(g.values(), P);
9
+ function H(t) {
10
+ const o = t == null ? void 0 : t.closest("[data-sort-root]"), s = o && g.get(o);
11
+ return s ? P(s) : void 0;
12
+ }
13
+ const m = (t) => {
14
+ const o = t.props.group;
15
+ return typeof o == "string" ? { name: o } : o;
16
+ };
17
+ function J(t) {
18
+ var i;
19
+ const o = m(t);
20
+ if (!o) return [t];
21
+ const s = (i = t.root()) == null ? void 0 : i.ownerDocument;
22
+ return K().filter((e) => {
23
+ var r, c;
24
+ if (e === t) return !0;
25
+ const n = m(e);
26
+ return !n || ((r = e.root()) == null ? void 0 : r.ownerDocument) !== s || !((c = e.root()) != null && c.isConnected) ? !1 : n.name === o.name || n.put === !0 || typeof n.put == "function" || Array.isArray(n.put) && n.put.includes(o.name);
27
+ });
28
+ }
29
+ const x = (t) => {
30
+ var o;
31
+ return {
32
+ id: t.id(),
33
+ group: (o = m(t)) == null ? void 0 : o.name,
34
+ items: t.data().items
35
+ };
36
+ }, L = (t) => typeof t == "number" ? `n:${t}` : `s:${t}`, Q = (t) => t.listTag === "table" ? "vertical" : t.layout ?? "vertical", A = (t) => typeof t == "string" || typeof t == "number" && Number.isFinite(t);
37
+ function U(t, o, s) {
38
+ const i = /* @__PURE__ */ new Map(), e = [], n = Array.isArray(s) ? new Set(s) : void 0;
39
+ return t.forEach((r, c) => {
40
+ const a = o(r);
41
+ A(a) && i.set(a, c);
42
+ const u = typeof s == "function" ? s(r, c) : n == null ? void 0 : n.has(a);
43
+ u && e.push({ key: a, index: c, placement: u });
44
+ }), { keys: i, fixed: e, items: t, valid: i.size === t.length };
45
+ }
46
+ const N = {
47
+ cancelled: "已取消排序",
48
+ outside: "请放到可排序区域内",
49
+ disabled: "该项目或列表已禁用排序",
50
+ keys: "项目键缺失或重复",
51
+ group: "这两个列表不允许此操作",
52
+ capacity: "目标列表已满",
53
+ fixed: "不能改变固定项目的位置",
54
+ cycle: "不能将项目移动到自己的子列表",
55
+ noop: "顺序没有变化",
56
+ rule: "不符合排序规则",
57
+ conflict: "列表已更新,请重新操作",
58
+ save: "保存排序失败"
59
+ };
60
+ function f(t, o, s = N[t], i) {
61
+ return { reason: t, proposal: o, message: s, error: i };
62
+ }
63
+ const I = (t) => t === !1 || typeof t == "string";
64
+ function T(t, o, s) {
65
+ var r, c;
66
+ if (t.props.disabled) return f("disabled");
67
+ if (!t.data().valid) return f("keys");
68
+ const i = t.key(o), e = t.props.itemDisabled;
69
+ if (typeof e == "function" ? e(o, s) : e != null && e.includes(i))
70
+ return f("disabled");
71
+ if (t.data().fixed.some((a) => a.key === i))
72
+ return f("fixed");
73
+ const n = (c = (r = t.props).canDrag) == null ? void 0 : c.call(r, o, s);
74
+ if (I(n))
75
+ return f(
76
+ "rule",
77
+ void 0,
78
+ typeof n == "string" ? n : void 0
79
+ );
80
+ }
81
+ function V(t, o, s) {
82
+ const i = t.data();
83
+ if (!i.valid) return f("keys");
84
+ const e = Array.from(
85
+ new Set(o),
86
+ (n) => i.keys.get(n) ?? -1
87
+ ).sort((n, r) => n - r);
88
+ if (!e.length || e[0] < 0) return f("conflict");
89
+ for (const n of e) {
90
+ const r = T(t, i.items[n], n);
91
+ if (r) return r;
92
+ }
93
+ return {
94
+ source: s,
95
+ from: x(t),
96
+ indices: e,
97
+ items: e.map((n) => i.items[n]),
98
+ keys: e.map((n) => t.key(i.items[n]))
99
+ };
100
+ }
101
+ function _(t, o, s, i) {
102
+ if (t === o)
103
+ return i && i !== "move" ? f("group", s) : "move";
104
+ const e = m(t), n = m(o);
105
+ if (!(e != null && e.name) || !(n != null && n.name)) return f("group", s);
106
+ const r = typeof e.pull == "function" ? e.pull(s) : e.pull;
107
+ if (r === !1) return f("group", s);
108
+ const c = typeof r == "string" ? r : "move";
109
+ if (i && i !== c) return f("group", s);
110
+ const a = { ...s, operation: c };
111
+ if (typeof n.put == "function") {
112
+ const p = n.put(a);
113
+ return I(p) ? f(
114
+ "group",
115
+ a,
116
+ typeof p == "string" ? p : void 0
117
+ ) : c;
118
+ }
119
+ return (Array.isArray(n.put) ? n.put.includes(e.name) : n.put === !0 || n.put !== !1 && e.name === n.name) ? c : f("group", a);
120
+ }
121
+ function k(t, o) {
122
+ const s = t.data().fixed;
123
+ if (!s.length) return !0;
124
+ const i = new Map(o.map((r, c) => [t.key(r), c])), e = s.filter((r) => r.placement === "top"), n = s.filter((r) => r.placement === "bottom");
125
+ return e.every((r, c) => i.get(r.key) === c) && n.every(
126
+ (r, c) => i.get(r.key) === o.length - n.length + c
127
+ ) && s.every(
128
+ (r) => r.placement !== !0 || i.get(r.key) === r.index
129
+ );
130
+ }
131
+ const j = (t, o) => t.length === o.length && t.every((s, i) => b(s) === b(o[i]));
132
+ function F(t, o, s) {
133
+ const i = o.map((n, r) => s + r);
134
+ if (i.some(
135
+ (n) => n >= t.length || o.includes(n)
136
+ ))
137
+ return;
138
+ const e = t.slice();
139
+ return o.forEach((n, r) => {
140
+ e[n] = t[i[r]], e[i[r]] = t[n];
141
+ }), e;
142
+ }
143
+ let w = 0;
144
+ function R(t, o, s) {
145
+ const i = t.props.clone ?? o.props.clone, e = /* @__PURE__ */ new Set([
146
+ ...o.data().keys.keys(),
147
+ ...t.data().keys.keys()
148
+ ]), n = o.props.itemKey ?? "id";
149
+ return s.items.map((r) => {
150
+ let c;
151
+ if (i) c = i(r, s);
152
+ else {
153
+ if (typeof n == "function")
154
+ throw Error("函数形式的 itemKey 需要 clone 回调生成新键");
155
+ const u = b(r);
156
+ c = s.operation === "clone" ? structuredClone(u) : { ...u };
157
+ const p = o.key(r);
158
+ let y;
159
+ do
160
+ w++, y = typeof p == "number" ? -w : `${p}-copy-${w}`;
161
+ while (e.has(y));
162
+ Object.assign(c, { [n]: y });
163
+ }
164
+ const a = o.key(c);
165
+ if (!A(a) || e.has(a))
166
+ throw Error("复制项目必须提供新的唯一键");
167
+ return e.add(a), c;
168
+ });
169
+ }
170
+ function W(t, o, s, i = !1) {
171
+ var O, E, $, M;
172
+ const e = s.port, n = t.data().items, r = e.data().items, c = t === e, a = c ? e.props.mode ?? "insert" : "insert", u = {
173
+ ...o,
174
+ from: x(t),
175
+ to: x(e),
176
+ index: s.index,
177
+ position: s.position,
178
+ targetItem: s.anchor === void 0 ? void 0 : r[e.data().keys.get(s.anchor) ?? -1],
179
+ operation: s.operation ?? "move",
180
+ mode: a
181
+ };
182
+ if (e.props.disabled) return f("disabled", u);
183
+ if (!t.data().valid || !e.data().valid)
184
+ return f("keys", u);
185
+ if (!c && o.keys.some((l) => {
186
+ var d;
187
+ return (d = t.row(l)) == null ? void 0 : d.contains(e.root() ?? null);
188
+ }))
189
+ return f("cycle", u);
190
+ const p = _(
191
+ t,
192
+ e,
193
+ u,
194
+ s.operation
195
+ );
196
+ if (typeof p != "string") return p;
197
+ u.operation = p, u.index = ((E = (O = e.props).resolveIndex) == null ? void 0 : E.call(O, u)) ?? u.index;
198
+ const { index: y } = u;
199
+ if (!Number.isInteger(y) || y < 0 || y > r.length || a === "swap" && y === r.length)
200
+ return f("outside", u);
201
+ if (!c && r.length + o.items.length > (e.props.maxItems ?? 1 / 0))
202
+ return f("capacity", u);
203
+ const z = c ? [t] : [t, e];
204
+ for (const l of z) {
205
+ const d = (M = ($ = l.props).canDrop) == null ? void 0 : M.call($, u);
206
+ if (I(d))
207
+ return f(
208
+ "rule",
209
+ u,
210
+ typeof d == "string" ? d : void 0
211
+ );
212
+ }
213
+ const C = new Set(o.indices), v = n.filter((l, d) => !C.has(d));
214
+ if (c) {
215
+ const l = a === "swap" ? F(n, o.indices, y) : v;
216
+ return !l || (a === "insert" && l.splice(
217
+ y - o.indices.filter((d) => d < y).length,
218
+ 0,
219
+ ...o.items
220
+ ), j(n, l)) ? f("noop", u) : k(t, l) ? {
221
+ source: t,
222
+ target: e,
223
+ proposal: u,
224
+ changes: [{ port: t, previous: n, next: l }]
225
+ } : f("fixed", u);
226
+ }
227
+ const S = p === "move" || !i ? o.items : R(t, e, u);
228
+ if (p === "move" || i) {
229
+ const l = S.map(e.key);
230
+ if (new Set(l).size !== l.length || l.some((d) => !A(d) || e.data().keys.has(d)))
231
+ return f("keys", u);
232
+ }
233
+ const h = r.slice();
234
+ if (h.splice(y, 0, ...S), !k(e, h) || p === "move" && !k(t, v))
235
+ return f("fixed", u);
236
+ const D = [{ port: e, previous: r, next: h }];
237
+ return p === "move" && D.unshift({ port: t, previous: n, next: v }), { source: t, target: e, proposal: u, changes: D };
238
+ }
239
+ export {
240
+ U as buildSortIndex,
241
+ T as dragIssue,
242
+ f as feedback,
243
+ m as groupOf,
244
+ L as keyToken,
245
+ Q as layoutOf,
246
+ J as linkedPorts,
247
+ V as makeDrag,
248
+ H as portAt,
249
+ k as preserved,
250
+ W as proposeSort,
251
+ G as registerSortPort,
252
+ j as sameItems,
253
+ K as sortPorts
254
+ };