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
@@ -1,145 +1,514 @@
1
- import { defineComponent as B, ref as b, onDeactivated as E, openBlock as m, createElementBlock as D, mergeProps as N, unref as p, createVNode as g, TransitionGroup as H, withCtx as K, Fragment as L, renderList as R, normalizeClass as U, createElementVNode as c, withModifiers as k, renderSlot as $, createTextVNode as G, toDisplayString as w, nextTick as q } from "vue";
2
- import { useHysRootAttrs as F } from "../../config.js";
3
- import { GripVertical as M, ChevronUp as O, ChevronDown as P } from "lucide-vue-next";
4
- const Y = ["data-sort-id", "aria-label", "onKeydown", "onDragover"], j = ["draggable", "disabled", "aria-label", "onDragstart"], J = { class: "hys-ui-pf-sort-label" }, Q = { class: "hys-ui-v4-sort-actions" }, W = ["disabled", "aria-label", "onClick"], X = ["disabled", "aria-label", "onClick"], Z = {
5
- class: "hys-ui-pf-sort-status",
1
+ import { defineComponent as _e, useId as Fe, useTemplateRef as X, shallowRef as O, computed as n, onMounted as Ue, onActivated as We, onDeactivated as qe, onBeforeUnmount as Je, watch as Se, openBlock as r, createElementBlock as T, mergeProps as P, unref as o, createElementVNode as V, normalizeStyle as Y, normalizeClass as R, createBlock as d, resolveDynamicComponent as v, withCtx as f, renderSlot as $, createCommentVNode as y, createVNode as Z, TransitionGroup as Qe, Fragment as Ce, renderList as Xe, withModifiers as De, createTextVNode as j, toDisplayString as L, Teleport as Ye, normalizeProps as Ze, guardReactiveProps as et, nextTick as tt } from "vue";
2
+ import { GripVertical as at, ChevronLeft as lt, ChevronUp as ot, ChevronRight as st, ChevronDown as nt } from "lucide-vue-next";
3
+ import { useHysRootAttrs as rt } from "../../config.js";
4
+ import { useMotion as it } from "../../motion/useMotion.js";
5
+ import { wholeRowDrag as ut, candidateAt as dt } from "./geometry.js";
6
+ import { buildSortIndex as ct, keyToken as ee, sortPorts as vt, registerSortPort as ft, feedback as yt } from "./model.js";
7
+ import { restoreStoredSort as ht, discardSortHistory as mt, resetSort as bt, navigateHistory as xe, keysArray as gt } from "./transactions.js";
8
+ import { useSortDrag as pt } from "./useSortDrag.js";
9
+ import { useSortWindow as kt } from "./useSortWindow.js";
10
+ import St from "./SortableGhost/SortableGhost.vue.js";
11
+ const Ct = ["data-drop-state", "aria-busy"], Dt = ["colspan"], xt = ["checked", "disabled", "aria-label", "onClick"], Bt = ["disabled", "aria-label"], Kt = { class: "hys-sort-actions" }, Tt = ["disabled", "aria-label", "onClick"], $t = ["disabled", "aria-label", "onClick"], wt = ["colspan"], zt = {
12
+ class: "hys-sort-sr",
6
13
  role: "status"
7
- }, le = /* @__PURE__ */ B({
14
+ }, Rt = /* @__PURE__ */ _e({
8
15
  __name: "HysSortableList",
9
16
  props: {
10
17
  modelValue: {},
11
- disabled: { type: Boolean }
18
+ defaultItems: {},
19
+ itemKey: {},
20
+ itemLabel: {},
21
+ listId: {},
22
+ ariaLabel: { default: "可排序列表" },
23
+ layout: { default: "vertical" },
24
+ mode: { default: "insert" },
25
+ disabled: { type: Boolean },
26
+ itemDisabled: {},
27
+ fixed: {},
28
+ handle: { type: [Boolean, String], default: !0 },
29
+ showButtons: { type: Boolean, default: !0 },
30
+ keyboard: { type: Boolean, default: !0 },
31
+ dragDelay: { default: 0 },
32
+ touchDelay: { default: 180 },
33
+ dragThreshold: { default: 5 },
34
+ axis: { default: "both" },
35
+ bounds: {},
36
+ snap: { type: Boolean },
37
+ livePreview: { type: Boolean, default: !0 },
38
+ group: {},
39
+ maxItems: {},
40
+ selectable: { type: Boolean },
41
+ selectedKeys: {},
42
+ defaultSelectedKeys: {},
43
+ clone: {},
44
+ canDrag: {},
45
+ canDrop: {},
46
+ resolveIndex: {},
47
+ beforeDrop: {},
48
+ save: {},
49
+ history: { type: [Boolean, Number], default: !0 },
50
+ storageKey: {},
51
+ autoScroll: { type: [Boolean, Object], default: !0 },
52
+ virtual: { type: [Boolean, Object] },
53
+ listTag: { default: "div" },
54
+ tableColumns: {},
55
+ motion: { type: Boolean, default: !0 },
56
+ animationDuration: { default: 180 },
57
+ animationEasing: { default: "ease" },
58
+ moveClass: {},
59
+ ghostClass: {},
60
+ ghostStyle: { type: [Boolean, null, String, Object, Array] },
61
+ showHandle: { type: Boolean, default: !0 }
12
62
  },
13
- emits: ["update:modelValue"],
14
- setup(u, { emit: T }) {
15
- const A = F(), n = u, C = T, h = b(), i = b(null), r = b(null), v = b("");
16
- async function f(e, t) {
17
- var s, o;
18
- if (n.disabled || e === t || e < 0 || e >= n.modelValue.length || t < 0 || t >= n.modelValue.length) return;
19
- const a = [...n.modelValue], l = a.splice(e, 1)[0];
20
- a.splice(t, 0, l), C("update:modelValue", a), v.value = l.label + "已移至第 " + (t + 1) + " 项", await q(), (o = Array.from(((s = h.value) == null ? void 0 : s.querySelectorAll("[data-sort-id]")) || []).find((d) => d.dataset.sortId === l.id)) == null || o.focus({ preventScroll: !0 });
21
- }
22
- function _(e, t) {
23
- e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown") && (e.preventDefault(), f(t, t + (e.key === "ArrowUp" ? -1 : 1)));
24
- }
25
- function I(e, t) {
26
- if (n.disabled || !e.dataTransfer) {
27
- e.preventDefault();
28
- return;
29
- }
30
- i.value = t.id;
31
- const a = e.currentTarget.closest("[data-sort-id]");
32
- a && e.dataTransfer.setDragImage(a, 24, a.offsetHeight / 2), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", t.id), v.value = "正在拖动" + t.label;
33
- }
34
- function V(e, t) {
35
- const a = n.modelValue.findIndex((o) => o.id === i.value), l = n.modelValue.findIndex((o) => o.id === e);
36
- if (a < 0 || l < 0) return -1;
37
- const s = l + (t === "after" ? 1 : 0);
38
- return s - (a < s ? 1 : 0);
39
- }
40
- function S(e, t) {
41
- if (!i.value) return;
42
- e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move");
43
- const a = e.currentTarget.getBoundingClientRect(), l = e.clientY < a.top + a.height / 2 ? "before" : "after", s = n.modelValue.findIndex((o) => o.id === i.value);
44
- r.value = V(t.id, l) === s ? null : { id: t.id, position: l };
45
- }
46
- function y() {
47
- i.value = null, r.value = null;
48
- }
49
- function x(e) {
50
- var t;
51
- e.relatedTarget instanceof Node && ((t = h.value) != null && t.contains(e.relatedTarget)) || (r.value = null);
63
+ emits: ["update:modelValue", "update:selectedKeys", "start", "preview", "change", "cancel", "invalid", "conflict", "save-error"],
64
+ setup(c, { expose: Be, emit: Ke }) {
65
+ const l = c, k = Ke, te = rt(), { effectiveMotion: Te } = it(), ae = Fe(), le = `${ae}-sort-help`, D = X("root"), oe = X("viewport"), A = X("surface"), G = O(
66
+ l.modelValue ?? l.defaultItems ?? []
67
+ ), $e = G.value.slice(), se = O(
68
+ l.defaultSelectedKeys ?? []
69
+ ), x = O(!1), _ = O(""), B = n(() => l.modelValue ?? G.value), M = n(() => l.motion && Te.value !== "off"), i = n(() => l.listTag === "table"), H = n(
70
+ () => i.value ? "tr" : l.listTag === "ul" || l.listTag === "ol" ? "li" : "div"
71
+ ), I = n(() => i.value ? "td" : "div"), ne = n(() => l.showHandle !== !1), re = n(() => ne.value || l.selectable), F = n(
72
+ () => l.tableColumns ?? 1 + Number(re.value) + Number(l.showButtons)
73
+ ), K = n(
74
+ () => l.layout === "horizontal" && !i.value
75
+ ), U = n(() => l.layout === "grid" && !i.value);
76
+ function S(e) {
77
+ return typeof l.itemKey == "function" ? l.itemKey(e) : e[l.itemKey ?? "id"];
78
+ }
79
+ function C(e) {
80
+ const a = typeof l.itemLabel == "function" ? l.itemLabel(e) : e[l.itemLabel ?? "label"];
81
+ return String(a ?? S(e) ?? "");
82
+ }
83
+ const m = n(() => ct(B.value, S, l.fixed)), ie = n(
84
+ () => new Map(m.value.fixed.map((e) => [e.key, e.placement]))
85
+ ), we = n(
86
+ () => new Set(typeof l.itemDisabled == "function" ? [] : l.itemDisabled)
87
+ ), N = n(
88
+ () => new Set(
89
+ (l.selectedKeys ?? se.value).filter(
90
+ (e) => m.value.keys.has(e)
91
+ )
92
+ )
93
+ );
94
+ let W;
95
+ function ze(e) {
96
+ l.modelValue === void 0 && (G.value = e), k("update:modelValue", e);
97
+ }
98
+ function ue(e) {
99
+ if (!l.selectable) return;
100
+ const a = Array.from(new Set(e)).filter(
101
+ (t) => m.value.keys.has(t)
102
+ );
103
+ l.selectedKeys === void 0 && (se.value = a), k("update:selectedKeys", a);
52
104
  }
53
- function z(e) {
54
- if (i.value) {
55
- if (e.preventDefault(), r.value) {
56
- const t = n.modelValue.findIndex((a) => a.id === i.value);
57
- f(t, V(r.value.id, r.value.position));
105
+ function Ve(e, a) {
106
+ if (!l.selectable || l.disabled || x.value) return;
107
+ const t = new Set(N.value), s = W === void 0 ? void 0 : m.value.keys.get(W), u = m.value.keys.get(e);
108
+ if (a != null && a.shiftKey && s !== void 0 && u !== void 0)
109
+ for (let p = Math.min(s, u); p <= Math.max(s, u); p++) {
110
+ const h = B.value[p];
111
+ me(h, p) || t.add(S(h));
58
112
  }
59
- y();
113
+ else
114
+ t.has(e) ? t.delete(e) : t.add(e), W = e;
115
+ ue([...t]);
116
+ }
117
+ function q(e) {
118
+ var t;
119
+ const a = ee(e);
120
+ return Array.from(((t = A.value) == null ? void 0 : t.children) ?? []).find(
121
+ (s) => s instanceof HTMLElement && s.dataset.sortKey === a
122
+ );
123
+ }
124
+ function de(e) {
125
+ _.value = e.message, e.reason === "cancelled" ? k("cancel", e) : e.reason === "save" ? k("save-error", e) : e.reason === "conflict" ? k("conflict", e) : k("invalid", e);
126
+ }
127
+ const b = {
128
+ id: () => l.listId ?? ae,
129
+ props: l,
130
+ key: S,
131
+ label: C,
132
+ row: q,
133
+ apply: ze,
134
+ focus: be,
135
+ scroll: Q,
136
+ reject: de,
137
+ root: () => D.value ?? void 0,
138
+ surface: () => A.value ?? void 0,
139
+ data: () => m.value,
140
+ lock: (e) => {
141
+ x.value = e;
142
+ },
143
+ start: (e) => k("start", e),
144
+ preview: (e) => k("preview", e),
145
+ change: (e) => k("change", e),
146
+ announce: (e) => {
147
+ _.value = e;
60
148
  }
149
+ }, g = pt(
150
+ b,
151
+ (e) => N.value.has(e) ? [...N.value] : [e],
152
+ () => M.value
153
+ ), { own: E, over: Ie, ghost: ce, anchorForDisplay: Pe } = g, J = n(() => {
154
+ const e = E.value, a = e == null ? void 0 : e.result;
155
+ return l.livePreview && !(l.virtual && (e == null ? void 0 : e.drag.source) === "keyboard") && a && !("reason" in a) && a.target === b ? a.changes[0].next : B.value;
156
+ }), { visibleItems: Le, range: w, length: Ae, columns: ve, reveal: Me, syncPosition: fe } = kt(l, J, oe, A, S), He = n(() => {
157
+ var e;
158
+ return new Set(((e = E.value) == null ? void 0 : e.drag.keys) ?? []);
159
+ }), ye = n(() => {
160
+ var a;
161
+ const e = (a = Ie.value) == null ? void 0 : a.result;
162
+ return e ? "reason" in e ? e.reason === "noop" ? void 0 : "invalid" : "allowed" : void 0;
163
+ }), he = n(
164
+ () => ye.value === "allowed" ? Pe.value : void 0
165
+ ), Ne = n(() => ({
166
+ "--hys-sort-duration": `${Math.max(0, l.animationDuration)}ms`,
167
+ "--hys-sort-easing": l.animationEasing,
168
+ "--hys-sort-virtual-columns": ve.value
169
+ })), Ee = n(() => {
170
+ if (l.disabled) return "排序已禁用。";
171
+ if (!l.keyboard) return "拖动项目调整顺序。";
172
+ const e = K.value ? "左右方向键" : U.value ? "方向键" : "上下方向键";
173
+ return `按空格拾起或放置,用${e}移动,Escape 取消。也可按 Alt 加${e}直接排序。${l.group ? "拾起后按 Ctrl 加方向键切换列表。" : ""}`;
174
+ });
175
+ function me(e, a) {
176
+ var s;
177
+ if (l.disabled || !m.value.valid || ie.value.has(S(e)) || (typeof l.itemDisabled == "function" ? l.itemDisabled(e, a) : we.value.has(S(e))))
178
+ return !0;
179
+ const t = (s = l.canDrag) == null ? void 0 : s.call(l, e, a);
180
+ return t === !1 || typeof t == "string";
181
+ }
182
+ const Oe = n(
183
+ () => Le.value.map((e, a) => {
184
+ const t = S(e), s = m.value.keys.get(t) ?? a + w.value.start;
185
+ return {
186
+ item: e,
187
+ key: t,
188
+ index: s,
189
+ selected: N.value.has(t),
190
+ dragging: He.value.has(t),
191
+ disabled: me(e, s),
192
+ fixed: ie.value.get(t) ?? !1,
193
+ toggle: (u) => Ve(t, u),
194
+ move: (u) => g.relative(t, u, "button")
195
+ };
196
+ })
197
+ );
198
+ async function Q(e) {
199
+ var s;
200
+ const a = J.value === B.value ? m.value.keys.get(e) : J.value.findIndex((u) => S(u) === e);
201
+ if (a === void 0 || a < 0) return !1;
202
+ await Me(a), await tt();
203
+ const t = q(e);
204
+ return (s = t == null ? void 0 : t.scrollIntoView) == null || s.call(t, { block: "nearest", inline: "nearest" }), !!t;
61
205
  }
62
- return E(y), (e, t) => (m(), D("div", N(p(A), {
206
+ async function be(e) {
207
+ if (!await Q(e)) return !1;
208
+ const a = q(e);
209
+ return a == null || a.focus({ preventScroll: !0 }), !!a;
210
+ }
211
+ function Re(e, a) {
212
+ const t = a.to === void 0 || a.to === b.id() ? b : vt().find(
213
+ (s) => {
214
+ var u, p;
215
+ return s.id() === a.to && ((u = s.root()) == null ? void 0 : u.ownerDocument) === ((p = D.value) == null ? void 0 : p.ownerDocument);
216
+ }
217
+ );
218
+ return t ? g.move(
219
+ gt(e),
220
+ {
221
+ ...dt(b, t, a.index),
222
+ operation: a.operation
223
+ },
224
+ "api"
225
+ ) : (de(yt("outside")), Promise.resolve(!1));
226
+ }
227
+ function je(e, a) {
228
+ if (a.disabled || !(e.ctrlKey || e.metaKey || e.shiftKey))
229
+ return;
230
+ const t = e.target;
231
+ t instanceof Element && t.closest("[data-sort-root]") === D.value && !t.closest(
232
+ "button,input,select,textarea,a[href],label,[contenteditable],[data-sort-ignore]"
233
+ ) && a.toggle(e);
234
+ }
235
+ function Ge(e) {
236
+ var a, t;
237
+ ((a = E.value) == null ? void 0 : a.drag.source) === "keyboard" && e.relatedTarget instanceof Node && !((t = D.value) != null && t.contains(e.relatedTarget)) && g.cancel();
238
+ }
239
+ function ge(e) {
240
+ return K.value ? { inlineSize: `${e}px` } : { blockSize: `${e}px` };
241
+ }
242
+ let z;
243
+ function pe() {
244
+ !z && D.value && (z = ft(D.value, b));
245
+ }
246
+ function ke() {
247
+ z == null || z(), z = void 0, g.detach();
248
+ }
249
+ return Ue(() => {
250
+ pe(), ht(b);
251
+ }), We(pe), qe(ke), Je(() => {
252
+ ke(), mt(b);
253
+ }), Se(m, () => g.dataChanged(), { flush: "post" }), Se(
254
+ () => l.disabled,
255
+ (e) => {
256
+ e && g.cancel();
257
+ }
258
+ ), Be({
259
+ move: Re,
260
+ select: ue,
261
+ scrollTo: Q,
262
+ focus: be,
263
+ undo: () => xe(b, "undo"),
264
+ redo: () => xe(b, "redo"),
265
+ reset: () => bt(b, $e),
266
+ cancel: () => g.cancel()
267
+ }), (e, a) => (r(), T("div", P({
63
268
  ref_key: "root",
64
- ref: h,
65
- class: ["hys-ui-pf-sortable", { "hys-ui-is-sorting": i.value }],
66
- onDragleave: x,
67
- onDrop: z
269
+ ref: D
270
+ }, o(te), {
271
+ "data-sort-root": "",
272
+ class: ["hys-sort", { "hys-sort-moving": !!o(E), "hys-sort-no-motion": !M.value }],
273
+ "data-drop-state": ye.value,
274
+ "aria-busy": x.value || void 0,
275
+ style: Ne.value,
276
+ onFocusout: Ge
68
277
  }), [
69
- g(H, {
70
- name: "hys-ui-sort-motion",
71
- tag: "div",
72
- class: "hys-ui-v4-sort",
73
- role: "list",
74
- "aria-label": "可排序列表"
75
- }, {
76
- default: K(() => [
77
- (m(!0), D(L, null, R(u.modelValue, (a, l) => {
78
- var s, o;
79
- return m(), D("div", {
80
- key: a.id,
81
- class: U(["hys-ui-v4-sort-row", { "hys-ui-is-dragging": i.value === a.id, "hys-ui-is-drop-before": ((s = r.value) == null ? void 0 : s.id) === a.id && r.value.position === "before", "hys-ui-is-drop-after": ((o = r.value) == null ? void 0 : o.id) === a.id && r.value.position === "after" }]),
82
- role: "listitem",
83
- tabindex: "0",
84
- "data-sort-id": a.id,
85
- "aria-label": a.label + ",按 Alt 加上下方向键调整顺序",
86
- onKeydown: (d) => _(d, l),
87
- onDragover: (d) => S(d, a)
88
- }, [
89
- c("button", {
90
- type: "button",
91
- class: "hys-ui-pf-sort-handle",
92
- draggable: !u.disabled,
93
- disabled: u.disabled,
94
- "aria-label": "拖动排序" + a.label,
95
- title: "拖动排序,也可按 Alt 加上下方向键",
96
- onDragstart: k((d) => I(d, a), ["stop"]),
97
- onDragend: k(y, ["stop"])
98
- }, [
99
- g(p(M), {
100
- class: "hys-ui-pf-sort-grip",
101
- size: 16,
102
- "aria-hidden": "true"
103
- })
104
- ], 40, j),
105
- c("span", J, [
106
- $(e.$slots, "item", { item: a }, () => [
107
- G(w(a.label), 1)
108
- ], !0)
278
+ V("div", {
279
+ ref_key: "viewport",
280
+ ref: oe,
281
+ class: R(["hys-sort-viewport", { "hys-sort-virtual": c.virtual }]),
282
+ style: Y({ maxBlockSize: o(Ae) }),
283
+ onScrollPassive: a[1] || (a[1] = //@ts-ignore
284
+ (...t) => o(fe) && o(fe)(...t))
285
+ }, [
286
+ (r(), d(v(i.value ? "table" : "div"), {
287
+ class: R(i.value ? "hys-sort-table" : void 0),
288
+ "aria-label": i.value ? c.ariaLabel : void 0
289
+ }, {
290
+ default: f(() => [
291
+ i.value ? $(e.$slots, "header", {}, void 0, !0, 0) : y("", !0),
292
+ (r(), d(v(i.value ? "tbody" : c.listTag), {
293
+ ref_key: "surface",
294
+ ref: A,
295
+ "data-sort-surface": "",
296
+ class: R(["hys-sort-list", {
297
+ "hys-sort-horizontal": K.value,
298
+ "hys-sort-grid": U.value
299
+ }]),
300
+ role: i.value ? void 0 : "list",
301
+ "aria-label": i.value ? void 0 : c.ariaLabel,
302
+ "aria-describedby": le,
303
+ "data-sort-columns": U.value && c.virtual ? o(ve) : void 0
304
+ }, {
305
+ default: f(() => [
306
+ Z(Qe, {
307
+ name: "hys-sort-motion",
308
+ css: !1,
309
+ "move-class": M.value && !c.virtual ? c.moveClass : "hys-sort-static-move"
310
+ }, {
311
+ default: f(() => [
312
+ o(w).before ? (r(), d(v(H.value), {
313
+ key: "before-spacer",
314
+ class: "hys-sort-spacer",
315
+ style: Y(ge(o(w).before)),
316
+ "aria-hidden": "true"
317
+ }, {
318
+ default: f(() => [
319
+ i.value ? (r(), T("td", {
320
+ key: 0,
321
+ colspan: F.value
322
+ }, null, 8, Dt)) : y("", !0)
323
+ ]),
324
+ _: 1
325
+ }, 8, ["style"])) : y("", !0),
326
+ (r(!0), T(Ce, null, Xe(Oe.value, (t, s) => {
327
+ var u, p;
328
+ return r(), d(v(H.value), {
329
+ key: m.value.valid ? "row:" + o(ee)(t.key) : "invalid:" + s,
330
+ class: R(["hys-sort-row", {
331
+ "hys-sort-picked": t.dragging,
332
+ "hys-sort-selected": t.selected,
333
+ "hys-sort-whole": o(ut)(l) && !t.disabled
334
+ }]),
335
+ role: i.value ? void 0 : "listitem",
336
+ tabindex: c.keyboard ? 0 : void 0,
337
+ "data-sort-id": t.key,
338
+ "data-sort-key": o(ee)(t.key),
339
+ "data-sort-index": o(w).start + s,
340
+ "data-drop-position": ((u = he.value) == null ? void 0 : u.key) === t.key ? (p = he.value) == null ? void 0 : p.position : void 0,
341
+ "aria-posinset": i.value ? void 0 : t.index + 1,
342
+ "aria-setsize": i.value ? void 0 : B.value.length,
343
+ "aria-label": C(t.item),
344
+ "aria-disabled": t.disabled || void 0,
345
+ onPointerdown: (h) => o(g).pointerDown(h, t.key, t.disabled),
346
+ onKeydown: (h) => o(g).keyboard(h, t.key, t.disabled),
347
+ onClick: (h) => je(h, t),
348
+ onDragstart: a[0] || (a[0] = De(() => {
349
+ }, ["prevent"]))
350
+ }, {
351
+ default: f(() => [
352
+ re.value ? (r(), d(v(I.value), {
353
+ key: 0,
354
+ class: "hys-sort-grip-cell"
355
+ }, {
356
+ default: f(() => [
357
+ c.selectable ? (r(), T("input", {
358
+ key: 0,
359
+ type: "checkbox",
360
+ checked: t.selected,
361
+ disabled: t.disabled || x.value,
362
+ "aria-label": "选择" + C(t.item),
363
+ onClick: De((h) => t.toggle(h), ["prevent"])
364
+ }, null, 8, xt)) : y("", !0),
365
+ ne.value ? (r(), T("button", {
366
+ key: 1,
367
+ type: "button",
368
+ "data-sort-handle": "",
369
+ class: "hys-sort-handle",
370
+ disabled: t.disabled || x.value,
371
+ "aria-label": "拖动排序" + C(t.item)
372
+ }, [
373
+ $(e.$slots, "handle", P({ ref_for: !0 }, t), () => [
374
+ Z(o(at), {
375
+ size: 16,
376
+ "aria-hidden": "true"
377
+ })
378
+ ], !0)
379
+ ], 8, Bt)) : y("", !0)
380
+ ]),
381
+ _: 2
382
+ }, 1024)) : y("", !0),
383
+ i.value && e.$slots.cells ? $(e.$slots, "cells", P({ ref_for: !0 }, t), void 0, !0, 1) : (r(), d(v(I.value), {
384
+ key: 2,
385
+ class: "hys-sort-content"
386
+ }, {
387
+ default: f(() => [
388
+ $(e.$slots, "item", P({ ref_for: !0 }, t), () => [
389
+ j(L(C(t.item)), 1)
390
+ ], !0)
391
+ ]),
392
+ _: 2
393
+ }, 1024)),
394
+ c.showButtons ? (r(), d(v(I.value), {
395
+ key: 3,
396
+ class: "hys-sort-actions-cell"
397
+ }, {
398
+ default: f(() => [
399
+ V("div", Kt, [
400
+ V("button", {
401
+ type: "button",
402
+ disabled: t.disabled || x.value || t.index === 0,
403
+ "aria-label": (K.value ? "前移" : "上移") + C(t.item),
404
+ onClick: (h) => t.move(-1)
405
+ }, [
406
+ (r(), d(v(K.value ? o(lt) : o(ot)), {
407
+ size: 15,
408
+ "aria-hidden": "true"
409
+ }))
410
+ ], 8, Tt),
411
+ V("button", {
412
+ type: "button",
413
+ disabled: t.disabled || x.value || t.index === B.value.length - 1,
414
+ "aria-label": (K.value ? "后移" : "下移") + C(t.item),
415
+ onClick: (h) => t.move(1)
416
+ }, [
417
+ (r(), d(v(K.value ? o(st) : o(nt)), {
418
+ size: 15,
419
+ "aria-hidden": "true"
420
+ }))
421
+ ], 8, $t)
422
+ ])
423
+ ]),
424
+ _: 2
425
+ }, 1024)) : y("", !0),
426
+ t.dragging && e.$slots.placeholder ? (r(), d(v(I.value), {
427
+ key: 4,
428
+ class: "hys-sort-placeholder",
429
+ "aria-hidden": "true"
430
+ }, {
431
+ default: f(() => [
432
+ $(e.$slots, "placeholder", P({ ref_for: !0 }, t), void 0, !0)
433
+ ]),
434
+ _: 2
435
+ }, 1024)) : y("", !0)
436
+ ]),
437
+ _: 2
438
+ }, 1064, ["class", "role", "tabindex", "data-sort-id", "data-sort-key", "data-sort-index", "data-drop-position", "aria-posinset", "aria-setsize", "aria-label", "aria-disabled", "onPointerdown", "onKeydown", "onClick"]);
439
+ }), 128)),
440
+ o(w).after ? (r(), d(v(H.value), {
441
+ key: "after-spacer",
442
+ class: "hys-sort-spacer",
443
+ style: Y(ge(o(w).after)),
444
+ "aria-hidden": "true"
445
+ }, {
446
+ default: f(() => [
447
+ i.value ? (r(), T("td", {
448
+ key: 0,
449
+ colspan: F.value
450
+ }, null, 8, wt)) : y("", !0)
451
+ ]),
452
+ _: 1
453
+ }, 8, ["style"])) : y("", !0)
454
+ ]),
455
+ _: 3
456
+ }, 8, ["move-class"]),
457
+ B.value.length ? y("", !0) : (r(), d(v(H.value), {
458
+ key: 0,
459
+ class: "hys-sort-empty"
460
+ }, {
461
+ default: f(() => [
462
+ (r(), d(v(I.value), {
463
+ colspan: i.value ? F.value : void 0
464
+ }, {
465
+ default: f(() => [
466
+ $(e.$slots, "empty", {}, () => [
467
+ a[2] || (a[2] = j("暂无项目", -1))
468
+ ], !0)
469
+ ]),
470
+ _: 3
471
+ }, 8, ["colspan"]))
472
+ ]),
473
+ _: 3
474
+ }))
109
475
  ]),
110
- c("div", Q, [
111
- c("button", {
112
- type: "button",
113
- disabled: u.disabled || l === 0,
114
- "aria-label": "上移" + a.label,
115
- onClick: (d) => f(l, l - 1)
116
- }, [
117
- g(p(O), {
118
- size: 15,
119
- "aria-hidden": "true"
120
- })
121
- ], 8, W),
122
- c("button", {
123
- type: "button",
124
- disabled: u.disabled || l === u.modelValue.length - 1,
125
- "aria-label": "下移" + a.label,
126
- onClick: (d) => f(l, l + 1)
127
- }, [
128
- g(p(P), {
129
- size: 15,
130
- "aria-hidden": "true"
131
- })
132
- ], 8, X)
133
- ])
134
- ], 42, Y);
135
- }), 128))
136
- ]),
137
- _: 3
138
- }),
139
- c("span", Z, w(v.value), 1)
140
- ], 16));
476
+ _: 3
477
+ }, 8, ["class", "role", "aria-label", "data-sort-columns"]))
478
+ ]),
479
+ _: 3
480
+ }, 8, ["class", "aria-label"]))
481
+ ], 38),
482
+ V("span", {
483
+ id: le,
484
+ class: "hys-sort-sr"
485
+ }, L(Ee.value), 1),
486
+ V("span", zt, L(_.value), 1),
487
+ o(ce) ? (r(), d(Ye, {
488
+ key: 0,
489
+ to: "body"
490
+ }, [
491
+ Z(St, {
492
+ track: o(ce),
493
+ appearance: o(te),
494
+ "ghost-class": c.ghostClass,
495
+ "ghost-style": c.ghostStyle,
496
+ motion: M.value
497
+ }, {
498
+ default: f((t) => [
499
+ $(e.$slots, "preview", Ze(et(t)), () => [
500
+ j(L(C(t.drag.items[0])), 1),
501
+ t.drag.items.length > 1 ? (r(), T(Ce, { key: 0 }, [
502
+ j(" 等 " + L(t.drag.items.length) + " 项", 1)
503
+ ], 64)) : y("", !0)
504
+ ], !0)
505
+ ]),
506
+ _: 3
507
+ }, 8, ["track", "appearance", "ghost-class", "ghost-style", "motion"])
508
+ ])) : y("", !0)
509
+ ], 16, Ct));
141
510
  }
142
511
  });
143
512
  export {
144
- le as default
513
+ Rt as default
145
514
  };