hys-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +16 -6
  3. package/dist/components/HysAlert/HysAlert.vue.js +14 -14
  4. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +23 -20
  5. package/dist/components/HysBadge/HysBadge.vue.js +1 -1
  6. package/dist/components/HysBadge/HysBadge2.vue.js +20 -19
  7. package/dist/components/HysCalendar/HysCalendar.vue.js +48 -40
  8. package/dist/components/HysCard/HysCard.vue.js +2 -2
  9. package/dist/components/HysCard/HysCard2.vue.js +9 -9
  10. package/dist/components/HysCascader/HysCascader.vue.js +88 -76
  11. package/dist/components/HysCheckbox/HysCheckbox.vue.js +5 -39
  12. package/dist/components/HysCheckbox/HysCheckbox2.vue.js +85 -2
  13. package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +52 -51
  14. package/dist/components/HysCommentEditor/HysCommentEditor.vue.js +17 -17
  15. package/dist/components/HysDataGrid/HysDataGrid2.vue.js +22 -22
  16. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  17. package/dist/components/HysDrawer/HysDrawer2.vue.js +55 -54
  18. package/dist/components/HysFileManager/HysFileManager.vue.js +5 -63
  19. package/dist/components/HysFileManager/HysFileManager2.vue.js +85 -2
  20. package/dist/components/HysForm/HysForm.vue.js +2 -2
  21. package/dist/components/HysForm/HysForm2.vue.js +66 -64
  22. package/dist/components/HysFormItem/HysFormItem.vue.js +53 -37
  23. package/dist/components/HysGantt/HysGantt.vue.js +5 -264
  24. package/dist/components/HysGantt/HysGantt2.vue.js +302 -2
  25. package/dist/components/HysInput/HysInput.vue.js +1 -1
  26. package/dist/components/HysInput/HysInput2.vue.js +42 -41
  27. package/dist/components/HysModal/HysModal.vue.js +2 -2
  28. package/dist/components/HysModal/HysModal2.vue.js +35 -35
  29. package/dist/components/HysNotificationCenter/HysNotificationCenter.vue.js +37 -36
  30. package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
  31. package/dist/components/HysNumberInput/HysNumberInput2.vue.js +49 -40
  32. package/dist/components/HysOrgTree/HysOrgTree.vue.js +34 -32
  33. package/dist/components/HysPagination/HysPagination.vue.js +2 -2
  34. package/dist/components/HysPagination/HysPagination2.vue.js +91 -91
  35. package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +5 -41
  36. package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +100 -2
  37. package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +5 -40
  38. package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +80 -2
  39. package/dist/components/HysResizablePanel/HysResizablePanel.vue.js +46 -28
  40. package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +2 -2
  41. package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +86 -67
  42. package/dist/components/HysSearch/HysSearch.vue.js +49 -38
  43. package/dist/components/HysSegmented/HysSegmented.vue.js +39 -34
  44. package/dist/components/HysSelect/HysSelect.vue.js +2 -2
  45. package/dist/components/HysSelect/HysSelect2.vue.js +130 -109
  46. package/dist/components/HysSlider/HysSlider.vue.js +2 -2
  47. package/dist/components/HysSlider/HysSlider2.vue.js +40 -40
  48. package/dist/components/HysSplitPane/HysSplitPane.vue.js +48 -42
  49. package/dist/components/HysSteps/HysSteps.vue.js +2 -2
  50. package/dist/components/HysSteps/HysSteps2.vue.js +15 -14
  51. package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
  52. package/dist/components/HysSwitch/HysSwitch2.vue.js +38 -27
  53. package/dist/components/HysTable/HysTable.vue.js +2 -2
  54. package/dist/components/HysTable/HysTable2.vue.js +42 -38
  55. package/dist/components/HysTabs/HysTabs.vue.js +1 -1
  56. package/dist/components/HysTabs/HysTabs2.vue.js +8 -6
  57. package/dist/components/HysTextarea/HysTextarea.vue.js +58 -48
  58. package/dist/components/HysToast/HysToast.vue.js +2 -2
  59. package/dist/components/HysToast/HysToast2.vue.js +121 -38
  60. package/dist/components/HysTour/HysTour.vue.js +47 -42
  61. package/dist/components/HysTransfer/HysTransfer.vue.js +159 -143
  62. package/dist/components/HysTree/HysTree.vue.js +2 -2
  63. package/dist/components/HysTree/HysTree2.vue.js +62 -61
  64. package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +64 -57
  65. package/dist/components/HysUpload/HysUpload.vue.js +2 -2
  66. package/dist/components/HysUpload/HysUpload2.vue.js +95 -77
  67. package/dist/composables/formContext.js +9 -3
  68. package/dist/composables/toastEscape.js +16 -0
  69. package/dist/composables/useDialog.js +16 -16
  70. package/dist/composables/useFloating.js +40 -40
  71. package/dist/composables/useHysToast.js +148 -0
  72. package/dist/config.js +18 -15
  73. package/dist/index.js +10 -7
  74. package/dist/style.css +1 -1
  75. package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +2 -0
  76. package/dist/types/components/HysCard/HysCard.vue.d.ts +5 -1
  77. package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +21 -4
  78. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -0
  79. package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +6 -2
  80. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +6 -0
  81. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -0
  82. package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +3 -1
  83. package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +8 -1
  84. package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +40 -17
  85. package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +6 -0
  86. package/dist/types/components/HysSelect/HysSelect.vue.d.ts +7 -1
  87. package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +6 -0
  88. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -0
  89. package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +1 -1
  90. package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +1 -1
  91. package/dist/types/components/HysToast/HysToast.vue.d.ts +55 -7
  92. package/dist/types/components/HysTour/HysTour.vue.d.ts +3 -1
  93. package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +11 -1
  94. package/dist/types/composables/formContext.d.ts +5 -0
  95. package/dist/types/composables/toastEscape.d.ts +1 -0
  96. package/dist/types/composables/useFloating.d.ts +1 -1
  97. package/dist/types/composables/useHysToast.d.ts +50 -0
  98. package/dist/types/index.d.ts +5 -0
  99. package/package.json +46 -11
@@ -1,7 +1,7 @@
1
- import { defineComponent as q, ref as w, provide as D, computed as H, openBlock as V, createElementBlock as $, mergeProps as z, unref as x, withModifiers as B, createElementVNode as P, renderSlot as S, toRaw as C, nextTick as I } from "vue";
2
- import { formKey as K } from "../../composables/formContext.js";
3
- import { useHysRootAttrs as N } from "../../config.js";
4
- const T = ["disabled", "inert"], G = { class: "hys-ui-ent-form-actions" }, U = /* @__PURE__ */ q({
1
+ import { defineComponent as V, ref as g, provide as $, computed as B, openBlock as z, createElementBlock as C, mergeProps as I, unref as P, withModifiers as S, createElementVNode as F, renderSlot as M, toRaw as K, nextTick as R } from "vue";
2
+ import { formKey as N, focusHysField as T } from "../../composables/formContext.js";
3
+ import { useHysRootAttrs as G } from "../../config.js";
4
+ const J = ["disabled", "inert"], L = { class: "hys-ui-ent-form-actions" }, Y = /* @__PURE__ */ V({
5
5
  __name: "HysForm",
6
6
  props: {
7
7
  model: {},
@@ -14,110 +14,112 @@ const T = ["disabled", "inert"], G = { class: "hys-ui-ent-form-actions" }, U = /
14
14
  labelWidth: { default: "100px" }
15
15
  },
16
16
  emits: ["submit", "invalid", "reset"],
17
- setup(l, { expose: M, emit: R }) {
18
- const r = l, g = R, E = N(), f = w({}), y = w(!1), k = w(), d = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
19
- function v(e, s = /* @__PURE__ */ new WeakMap()) {
20
- const t = C(x(e));
17
+ setup(n, { expose: E, emit: H }) {
18
+ const r = n, v = H, W = G(), f = g({}), m = g(!1), p = g(!1), A = g(), d = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
19
+ function b(e, i = /* @__PURE__ */ new WeakMap()) {
20
+ const t = K(P(e));
21
21
  if (!t || typeof t != "object") return t;
22
22
  if (t instanceof Date) return new Date(t);
23
- if (s.has(t)) return s.get(t);
23
+ if (i.has(t)) return i.get(t);
24
24
  if (!Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && Object.getPrototypeOf(t) !== null) return t;
25
- const n = Array.isArray(t) ? [] : {};
26
- s.set(t, n);
27
- for (const [o, a] of Object.entries(t)) n[o] = v(a, s);
28
- return n;
25
+ const l = Array.isArray(t) ? [] : {};
26
+ i.set(t, l);
27
+ for (const [o, a] of Object.entries(t)) l[o] = b(a, i);
28
+ return l;
29
29
  }
30
- const F = v(r.model || {});
31
- function A(e, s) {
32
- return s.split(".").reduce((t, n) => t == null ? void 0 : t[n], e);
30
+ const q = b(r.model || {});
31
+ function O(e, i) {
32
+ return i.split(".").reduce((t, l) => t == null ? void 0 : t[l], e);
33
33
  }
34
- async function p(e, s) {
34
+ async function h(e, i) {
35
35
  const t = (u.get(e) || 0) + 1;
36
36
  u.set(e, t);
37
- const n = [r.rules[e] || []].flat().filter((i) => !s || !i.trigger || [i.trigger].flat().includes(s)), o = A(r.model || {}, e);
37
+ const l = [r.rules[e] || []].flat().filter((s) => !i || !s.trigger || [s.trigger].flat().includes(i)), o = O(r.model || {}, e);
38
38
  let a = "";
39
- for (const i of n) {
40
- const h = o == null || o === "" || Array.isArray(o) && !o.length;
39
+ for (const s of l) {
40
+ const k = o == null || o === "" || Array.isArray(o) && !o.length;
41
41
  try {
42
- i.required && h && (a = i.message || "此项不能为空"), !h && i.pattern && (i.pattern.lastIndex = 0, i.pattern.test(String(o)) || (a = i.message || "格式不正确"));
42
+ s.required && k && (a = s.message || "此项不能为空"), !k && s.pattern && (s.pattern.lastIndex = 0, s.pattern.test(String(o)) || (a = s.message || "格式不正确"));
43
43
  const c = typeof o == "number" ? o : o == null ? void 0 : o.length;
44
- if (!h && c !== void 0 && (i.min !== void 0 && c < i.min || i.max !== void 0 && c > i.max) && (a = i.message || "超出允许范围"), !a && i.validator) {
45
- const m = await i.validator(o, r.model || {});
46
- (m === !1 || typeof m == "string") && (a = typeof m == "string" ? m : i.message || "校验未通过");
44
+ if (!k && c !== void 0 && (s.min !== void 0 && c < s.min || s.max !== void 0 && c > s.max) && (a = s.message || "超出允许范围"), !a && s.validator) {
45
+ const y = await s.validator(o, r.model || {});
46
+ (y === !1 || typeof y == "string") && (a = typeof y == "string" ? y : s.message || "校验未通过");
47
47
  }
48
48
  } catch (c) {
49
- a = c instanceof Error ? c.message : i.message || "校验失败";
49
+ a = c instanceof Error ? c.message : s.message || "校验失败";
50
50
  }
51
51
  if (a) break;
52
52
  }
53
53
  if (u.get(e) === t)
54
54
  if (a) f.value = { ...f.value, [e]: a };
55
55
  else {
56
- const i = { ...f.value };
57
- delete i[e], f.value = i;
56
+ const s = { ...f.value };
57
+ delete s[e], f.value = s;
58
58
  }
59
59
  return !a;
60
60
  }
61
- function O(e) {
62
- const s = e ? [e].flat() : [.../* @__PURE__ */ new Set([...Object.keys(f.value), ...u.keys()])];
63
- for (const t of s)
61
+ function j(e) {
62
+ const i = e ? [e].flat() : [.../* @__PURE__ */ new Set([...Object.keys(f.value), ...u.keys()])];
63
+ for (const t of i)
64
64
  u.set(t, (u.get(t) || 0) + 1), delete f.value[t];
65
65
  }
66
- async function j() {
67
- y.value = !0;
66
+ async function x() {
67
+ m.value = !0;
68
68
  try {
69
69
  const e = [.../* @__PURE__ */ new Set([...Object.keys(r.rules), ...d.keys()])];
70
- return (await Promise.all(e.map((t) => p(t)))).every(Boolean) && (!r.validate || await r.validate());
70
+ return (await Promise.all(e.map((t) => h(t)))).every(Boolean) && (!r.validate || await r.validate());
71
71
  } catch {
72
72
  return !1;
73
73
  } finally {
74
- y.value = !1;
74
+ m.value = !1;
75
75
  }
76
76
  }
77
- function b() {
78
- if (r.model)
77
+ function w() {
78
+ if (p.value = !0, r.model)
79
79
  for (const e of d.size ? d.keys() : Object.keys(r.model)) {
80
- const s = e.split("."), t = s.pop();
81
- let n = r.model;
82
- for (const o of s) n = n[o] ?? (n[o] = {});
83
- n[t] = v(A(F, e));
80
+ const i = e.split("."), t = i.pop();
81
+ let l = r.model;
82
+ for (const o of i) l = l[o] ?? (l[o] = {});
83
+ l[t] = b(O(q, e));
84
84
  }
85
- O(), g("reset");
85
+ j(), v("reset"), R(() => {
86
+ p.value = !1;
87
+ });
86
88
  }
87
- async function W() {
88
- var e, s;
89
- r.loading || r.disabled || y.value || (await j() ? g("submit") : (g("invalid"), await I(), (s = (e = k.value) == null ? void 0 : e.querySelector('[aria-invalid="true"]')) == null || s.focus()));
89
+ async function D() {
90
+ var e;
91
+ r.loading || r.disabled || m.value || (await x() ? v("submit") : (v("invalid"), await R(), T((e = A.value) == null ? void 0 : e.querySelector('[aria-invalid="true"]'))));
90
92
  }
91
- return D(K, { errors: f, rules: H(() => r.rules), validateField: p, register(e) {
93
+ return $(N, { model: B(() => r.model), resetting: p, errors: f, rules: B(() => r.rules), validateField: h, register(e) {
92
94
  return d.set(e, (d.get(e) || 0) + 1), () => {
93
- const s = (d.get(e) || 1) - 1;
94
- s ? d.set(e, s) : d.delete(e);
95
+ const i = (d.get(e) || 1) - 1;
96
+ i ? d.set(e, i) : d.delete(e);
95
97
  };
96
- } }), M({ validate: j, validateField: p, clearValidate: O, resetFields: b, errors: f, validating: y }), (e, s) => (V(), $("form", z({
98
+ } }), E({ validate: x, validateField: h, clearValidate: j, resetFields: w, errors: f, validating: m }), (e, i) => (z(), C("form", I({
97
99
  ref_key: "root",
98
- ref: k
99
- }, x(E), {
100
- class: ["hys-ui-ent-form", ["hys-ui-form-" + l.labelPosition, { "hys-ui-form-inline": l.inline }]],
101
- style: { "--hys-ui-form-label-width": l.labelWidth },
100
+ ref: A
101
+ }, P(W), {
102
+ class: ["hys-ui-ent-form", ["hys-ui-form-" + n.labelPosition, { "hys-ui-form-inline": n.inline }]],
103
+ style: { "--hys-ui-form-label-width": n.labelWidth },
102
104
  novalidate: "",
103
- onSubmit: B(W, ["prevent"]),
104
- onReset: B(b, ["prevent"])
105
+ onSubmit: S(D, ["prevent"]),
106
+ onReset: S(w, ["prevent"])
105
107
  }), [
106
- P("fieldset", {
107
- disabled: l.disabled || l.loading,
108
- inert: l.disabled || l.loading
108
+ F("fieldset", {
109
+ disabled: n.disabled || n.loading,
110
+ inert: n.disabled || n.loading
109
111
  }, [
110
- S(e.$slots, "default", {}, void 0, !0),
111
- P("div", G, [
112
- S(e.$slots, "actions", {
113
- validating: y.value,
114
- reset: b
112
+ M(e.$slots, "default", {}, void 0, !0),
113
+ F("div", L, [
114
+ M(e.$slots, "actions", {
115
+ validating: m.value,
116
+ reset: w
115
117
  }, void 0, !0)
116
118
  ])
117
- ], 8, T)
119
+ ], 8, J)
118
120
  ], 16));
119
121
  }
120
122
  });
121
123
  export {
122
- U as default
124
+ Y as default
123
125
  };
@@ -1,10 +1,10 @@
1
- import { defineComponent as S, inject as g, ref as q, useId as x, computed as f, provide as C, watch as I, onBeforeUnmount as w, onMounted as F, onUpdated as N, openBlock as d, createElementBlock as s, mergeProps as V, unref as $, createTextVNode as j, toDisplayString as y, createCommentVNode as b, createElementVNode as z, normalizeClass as E, renderSlot as H } from "vue";
2
- import { formKey as K, fieldKey as R } from "../../composables/formContext.js";
3
- import { useHysRootAttrs as U } from "../../config.js";
4
- const D = ["for"], M = {
1
+ import { defineComponent as E, inject as H, ref as B, useId as N, computed as d, provide as V, watch as C, onBeforeUnmount as $, onMounted as j, onUpdated as z, openBlock as u, createElementBlock as s, mergeProps as D, unref as I, createTextVNode as K, toDisplayString as h, createCommentVNode as g, createElementVNode as R, normalizeClass as U, renderSlot as M } from "vue";
2
+ import { formKey as P, fieldKey as T, focusHysField as G } from "../../composables/formContext.js";
3
+ import { useHysRootAttrs as J } from "../../config.js";
4
+ const L = ["for"], O = {
5
5
  key: 0,
6
6
  "aria-hidden": "true"
7
- }, P = { key: 2 }, L = /* @__PURE__ */ S({
7
+ }, Y = /* @__PURE__ */ E({
8
8
  __name: "HysFormItem",
9
9
  props: {
10
10
  label: {},
@@ -15,57 +15,73 @@ const D = ["for"], M = {
15
15
  for: {}
16
16
  },
17
17
  setup(l) {
18
- const r = l, B = U(), t = g(K, void 0), m = q(), h = x(), a = q(r.for || h), u = h + "-error", n = f(() => r.error || (r.prop ? t == null ? void 0 : t.errors.value[r.prop] : "")), c = f(() => !!n.value), p = f(() => !!(r.required || r.prop && [(t == null ? void 0 : t.rules.value[r.prop]) || []].flat().some((e) => e.required)));
19
- C(R, { id: a, error: n, errorId: u, required: p });
18
+ const r = l, S = J(), t = H(P, void 0), A = B(), v = N(), n = B(r.for || v), c = v + "-error", b = v + "-hint", a = d(() => r.error || (r.prop ? t == null ? void 0 : t.errors.value[r.prop] : "")), p = d(() => !!a.value), f = d(() => !!(r.required || r.prop && [(t == null ? void 0 : t.rules.value[r.prop]) || []].flat().some((e) => e.required))), y = d(() => p.value ? c : r.hint ? b : void 0);
19
+ V(T, { id: n, label: d(() => r.label), error: a, errorId: c, describedBy: y, required: f }), C(() => r.prop ? r.prop.split(".").reduce((e, o) => e == null ? void 0 : e[o], t == null ? void 0 : t.model.value) : void 0, () => {
20
+ t != null && t.model.value && !t.resetting.value && m("change");
21
+ }, { deep: !0 });
20
22
  let i;
21
- I(() => r.prop, (e) => {
23
+ C(() => r.prop, (e) => {
22
24
  i == null || i(), i = e ? t == null ? void 0 : t.register(e) : void 0;
23
- }, { immediate: !0 }), w(() => i == null ? void 0 : i());
25
+ }, { immediate: !0 }), $(() => i == null ? void 0 : i());
24
26
  function k() {
25
- var v;
26
- const e = (v = m.value) == null ? void 0 : v.querySelector('input:not([type="hidden"]),textarea,select,button[role="combobox"],button[role="switch"]');
27
- if (!e) return;
28
- e.id ? a.value = e.id : e.id = a.value, e.setAttribute("aria-invalid", String(c.value)), p.value && e.setAttribute("aria-required", "true");
27
+ var e;
28
+ return (r.for ? document.getElementById(r.for) : null) || ((e = A.value) == null ? void 0 : e.querySelector('input:not([type="hidden"]):not([hidden]),textarea,select,button[role="combobox"],button[role="switch"],[role="radiogroup"],[role="slider"],[role="button"],[contenteditable][role="textbox"]'));
29
+ }
30
+ function F(e) {
31
+ const o = k();
32
+ o && !o.matches("input,button,textarea,select") && (e.preventDefault(), G(o));
33
+ }
34
+ function q() {
35
+ const e = k();
36
+ if (!e || (e.id ? n.value = e.id : e.id = n.value, e.hasAttribute("data-hys-ui-field-managed"))) return;
37
+ e.setAttribute("aria-invalid", String(p.value)), f.value ? e.setAttribute("aria-required", "true") : e.removeAttribute("aria-required");
29
38
  const o = new Set((e.getAttribute("aria-describedby") || "").split(" ").filter(Boolean));
30
- c.value ? o.add(u) : o.delete(u), o.size ? e.setAttribute("aria-describedby", [...o].join(" ")) : e.removeAttribute("aria-describedby");
39
+ o.delete(c), o.delete(b), y.value && o.add(y.value), o.size ? e.setAttribute("aria-describedby", [...o].join(" ")) : e.removeAttribute("aria-describedby");
31
40
  }
32
- F(k), N(k);
33
- function A(e) {
34
- r.prop && (t == null || t.validateField(r.prop, e));
41
+ j(q), z(q);
42
+ function m(e) {
43
+ !(t != null && t.resetting.value) && r.prop && (t == null || t.validateField(r.prop, e));
35
44
  }
36
- return (e, o) => (d(), s("div", V({
45
+ return (e, o) => (u(), s("div", D({
37
46
  ref_key: "root",
38
- ref: m
39
- }, $(B), {
47
+ ref: A
48
+ }, I(S), {
40
49
  class: "hys-ui-ent-field",
41
- onChange: o[0] || (o[0] = (v) => A("change")),
42
- onFocusout: o[1] || (o[1] = (v) => A("blur"))
50
+ onChange: o[0] || (o[0] = (w) => {
51
+ var x;
52
+ return !((x = I(t)) != null && x.model.value) && m("change");
53
+ }),
54
+ onFocusout: o[1] || (o[1] = (w) => m("blur"))
43
55
  }), [
44
- l.label ? (d(), s("label", {
56
+ l.label ? (u(), s("label", {
45
57
  key: 0,
46
- for: a.value
58
+ for: n.value,
59
+ onClick: F
47
60
  }, [
48
- j(y(l.label) + " ", 1),
49
- p.value ? (d(), s("span", M, "*")) : b("", !0)
50
- ], 8, D)) : b("", !0),
51
- z("div", {
52
- class: E({ "hys-ui-ent-invalid": c.value })
61
+ K(h(l.label) + " ", 1),
62
+ f.value ? (u(), s("span", O, "*")) : g("", !0)
63
+ ], 8, L)) : g("", !0),
64
+ R("div", {
65
+ class: U({ "hys-ui-ent-invalid": p.value })
53
66
  }, [
54
- H(e.$slots, "default", {
55
- id: a.value,
56
- invalid: c.value,
57
- error: n.value
67
+ M(e.$slots, "default", {
68
+ id: n.value,
69
+ invalid: p.value,
70
+ error: a.value
58
71
  })
59
72
  ], 2),
60
- n.value ? (d(), s("small", {
73
+ a.value ? (u(), s("small", {
61
74
  key: 1,
62
- id: u,
75
+ id: c,
63
76
  role: "alert",
64
77
  class: "hys-ui-ent-error"
65
- }, y(n.value), 1)) : l.hint ? (d(), s("small", P, y(l.hint), 1)) : b("", !0)
78
+ }, h(a.value), 1)) : l.hint ? (u(), s("small", {
79
+ key: 2,
80
+ id: b
81
+ }, h(l.hint), 1)) : g("", !0)
66
82
  ], 16));
67
83
  }
68
84
  });
69
85
  export {
70
- L as default
86
+ Y as default
71
87
  };
@@ -1,266 +1,7 @@
1
- import { defineComponent as te, ref as A, watch as z, computed as m, nextTick as ne, openBlock as o, createElementBlock as r, mergeProps as le, unref as B, createElementVNode as s, Fragment as k, renderList as x, normalizeClass as T, toDisplayString as y, normalizeStyle as g, withKeys as D, withModifiers as $, createCommentVNode as H, createTextVNode as ae } from "vue";
2
- import { useHysRootAttrs as se } from "../../config.js";
3
- const ie = { class: "hys-ui-pg-toolbar" }, oe = {
4
- class: "hys-ui-pg-scale",
5
- role: "group",
6
- "aria-label": "时间刻度"
7
- }, re = ["aria-pressed", "onClick"], ue = { class: "hys-ui-pg-hint" }, de = { class: "hys-ui-pg-body" }, ce = ["onClick", "onKeydown"], he = ["title"], ve = {
8
- key: 0,
9
- class: "hys-ui-pg-empty"
10
- }, ye = { class: "hys-ui-pg-months" }, ge = { class: "hys-ui-pg-days" }, pe = ["aria-label", "title", "onClick", "onKeydown", "onPointerdown"], me = { class: "hys-ui-pg-bar-title" }, fe = ["onPointerdown"], we = ["onPointerdown"], be = ["width", "height"], ke = ["d"], xe = { class: "hys-ui-pg-footer" }, $e = { key: 0 }, j = 864e5, De = /* @__PURE__ */ te({
11
- __name: "HysGantt",
12
- props: {
13
- items: {},
14
- modelValue: {},
15
- scale: { default: "day" },
16
- editable: { type: Boolean, default: !1 },
17
- rowHeight: { default: 46 },
18
- labelWidth: { default: 270 }
19
- },
20
- emits: ["update:modelValue", "update:items", "change", "open"],
21
- setup(d, { emit: q }) {
22
- const J = se(), v = d, b = q, p = A(v.scale);
23
- z(() => v.scale, (t) => p.value = t);
24
- const P = A(v.modelValue ?? null);
25
- z(() => v.modelValue, (t) => P.value = t ?? null);
26
- const E = A(null), _ = /* @__PURE__ */ new Date();
27
- _.setHours(0, 0, 0, 0);
28
- function M(t) {
29
- if (!/^\d{4}-\d{2}-\d{2}$/.test(t)) return null;
30
- const [n, e, l] = t.split("-").map(Number), a = new Date(n, e - 1, l);
31
- return a.getFullYear() === n && a.getMonth() === e - 1 && a.getDate() === l ? a : null;
32
- }
33
- function c(t) {
34
- return Math.round((Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()) - Date.UTC(1970, 0, 1)) / j);
35
- }
36
- function S(t) {
37
- return new Date(t * j);
38
- }
39
- function V(t) {
40
- return S(t).toISOString().slice(0, 10);
41
- }
42
- const h = m(() => v.items.map((t) => {
43
- const n = M(t.start), e = M(t.end);
44
- return !n || !e || c(e) < c(n) ? null : { ...t, s: c(n), e: c(e), progress: Math.min(100, Math.max(0, t.progress ?? 0)) };
45
- }).filter((t) => t !== null)), u = m(() => p.value === "day" ? 36 : p.value === "week" ? 17 : p.value === "month" ? 7 : 36), f = m(() => {
46
- const t = h.value.flatMap((e) => [e.s, e.e]), n = c(_);
47
- return { start: Math.min(n - 7, ...t) - 7, end: Math.max(n + 21, ...t) + 14 };
48
- }), I = m(() => f.value.end - f.value.start + 1), L = m(() => I.value * u.value), U = m(() => Array.from({ length: I.value }, (t, n) => f.value.start + n)), Q = m(() => {
49
- const t = [];
50
- for (let n = 0; n < U.value.length; n++) {
51
- const e = S(U.value[n]), l = `${e.getUTCFullYear()}-${e.getUTCMonth()}`, a = t[t.length - 1];
52
- (a == null ? void 0 : a.key) === l ? a.width += u.value : t.push({ key: l, label: `${e.getUTCFullYear()}年${e.getUTCMonth() + 1}月`, left: n * u.value, width: u.value });
53
- }
54
- return t;
55
- }), R = m(() => new Map(h.value.map((t, n) => [String(t.id), { x: (t.s - f.value.start) * u.value, w: (t.e - t.s + 1) * u.value, y: n * v.rowHeight + v.rowHeight / 2 }]))), X = m(() => h.value.flatMap((t) => (t.dependencies ?? []).flatMap((n) => {
56
- const e = R.value.get(String(n)), l = R.value.get(String(t.id));
57
- return !e || !l || String(n) === String(t.id) ? [] : [{ id: `${n}-${t.id}`, path: `M ${e.x + e.w} ${e.y} H ${e.x + e.w + 9} V ${l.y} H ${l.x}` }];
58
- })));
59
- function F(t) {
60
- P.value = t.id, b("update:modelValue", t.id), b("open", t);
61
- }
62
- function G() {
63
- const t = E.value;
64
- t && (t.scrollLeft = Math.max(0, (c(_) - f.value.start) * u.value - t.clientWidth / 3));
65
- }
66
- z(p, () => ne(G));
67
- const w = A(null);
68
- function K(t, n, e) {
69
- !v.editable || n.disabled || t.button !== 0 || (t.preventDefault(), t.stopPropagation(), t.currentTarget.setPointerCapture(t.pointerId), w.value = { id: n.id, type: e, x: t.clientX, original: { ...n }, days: 0 }, P.value = n.id, b("update:modelValue", n.id));
70
- }
71
- function Y(t) {
72
- w.value && (w.value.days = Math.round((t.clientX - w.value.x) / u.value));
73
- }
74
- function C(t) {
75
- const n = w.value;
76
- if (!n || (w.value = null, t.type === "pointercancel" || !n.days)) return;
77
- const e = M(n.original.start), l = M(n.original.end);
78
- if (!e || !l) return;
79
- let a = c(e), i = c(l);
80
- n.type === "move" ? (a += n.days, i += n.days) : n.type === "start" ? a = Math.min(i, a + n.days) : i = Math.max(a, i + n.days);
81
- const N = { ...n.original, start: V(a), end: V(i) };
82
- b("update:items", v.items.map((O) => String(O.id) === String(N.id) ? N : O)), b("change", N);
83
- }
84
- function Z(t) {
85
- const n = w.value;
86
- if (!n || String(n.id) !== String(t.id)) return { s: t.s, e: t.e };
87
- const e = n.days;
88
- return n.type === "move" ? { s: t.s + e, e: t.e + e } : n.type === "start" ? { s: Math.min(t.e, t.s + e), e: t.e } : { s: t.s, e: Math.max(t.s, t.e + e) };
89
- }
90
- function ee(t) {
91
- const n = Z(t);
92
- return { left: `${(n.s - f.value.start) * u.value}px`, width: `${Math.max(u.value, (n.e - n.s + 1) * u.value)}px`, background: t.color || "var(--hys-ui-primary,var(--hys-ui-theme-primary, #4776ed))" };
93
- }
94
- function W(t, n) {
95
- if (!v.editable || t.disabled) return;
96
- const e = M(t.start), l = M(t.end);
97
- if (!e || !l) return;
98
- const a = { ...t, start: V(c(e) + n), end: V(c(l) + n) };
99
- b("update:items", v.items.map((i) => String(i.id) === String(t.id) ? a : i)), b("change", a);
100
- }
101
- return (t, n) => (o(), r("section", le(B(J), {
102
- class: "hys-ui-pg-gantt",
103
- "aria-label": "项目甘特图"
104
- }), [
105
- s("div", ie, [
106
- s("div", oe, [
107
- (o(), r(k, null, x(["day", "week", "month"], (e) => s("button", {
108
- key: e,
109
- type: "button",
110
- "aria-pressed": p.value === e,
111
- class: T({ "hys-ui-active": p.value === e }),
112
- onClick: (l) => p.value = e
113
- }, y(e === "day" ? "日" : e === "week" ? "周" : "月"), 11, re)), 64))
114
- ]),
115
- s("button", {
116
- class: "hys-ui-pg-today",
117
- type: "button",
118
- onClick: G
119
- }, "定位今天"),
120
- s("span", ue, y(d.editable ? "拖动任务条调整排期 · Alt + 左/右方向键微调日期" : "点击任务查看详情"), 1)
121
- ]),
122
- s("div", de, [
123
- s("div", {
124
- class: "hys-ui-pg-labels",
125
- style: g({ width: d.labelWidth + "px", minWidth: d.labelWidth + "px" })
126
- }, [
127
- n[0] || (n[0] = s("div", { class: "hys-ui-pg-label-head" }, "任务 / 负责人", -1)),
128
- (o(!0), r(k, null, x(h.value, (e) => (o(), r("button", {
129
- type: "button",
130
- key: e.id,
131
- class: T(["hys-ui-pg-task-label", { "hys-ui-selected": P.value === e.id }]),
132
- style: g({ height: d.rowHeight + "px" }),
133
- onClick: (l) => F(e),
134
- onKeydown: [
135
- D($((l) => W(e, -1), ["alt", "prevent"]), ["left"]),
136
- D($((l) => W(e, 1), ["alt", "prevent"]), ["right"])
137
- ]
138
- }, [
139
- s("strong", {
140
- title: e.title
141
- }, y(e.title), 9, he),
142
- s("small", null, y(e.owner || "未分配") + " · " + y(e.status || "待办"), 1)
143
- ], 46, ce))), 128)),
144
- h.value.length ? H("", !0) : (o(), r("div", ve, "暂无有效排期任务"))
145
- ], 4),
146
- s("div", {
147
- ref_key: "scroller",
148
- ref: E,
149
- class: "hys-ui-pg-scroll",
150
- tabindex: "0",
151
- "aria-label": "可横向滚动的甘特图时间轴"
152
- }, [
153
- s("div", {
154
- class: "hys-ui-pg-canvas",
155
- style: g({ width: L.value + "px" })
156
- }, [
157
- s("div", ye, [
158
- (o(!0), r(k, null, x(Q.value, (e) => (o(), r("span", {
159
- key: e.key,
160
- style: g({ left: e.left + "px", width: e.width + "px" })
161
- }, y(e.label), 5))), 128))
162
- ]),
163
- s("div", ge, [
164
- (o(!0), r(k, null, x(U.value, (e) => (o(), r("span", {
165
- key: e,
166
- class: T({ "hys-ui-weekend": [0, 6].includes(S(e).getUTCDay()), "hys-ui-today": e === c(B(_)) }),
167
- style: g({ width: u.value + "px" })
168
- }, y(p.value === "month" ? "" : S(e).getUTCDate()), 7))), 128))
169
- ]),
170
- s("div", {
171
- class: "hys-ui-pg-grid",
172
- style: g({ height: h.value.length * d.rowHeight + "px" })
173
- }, [
174
- (o(!0), r(k, null, x(U.value, (e) => (o(), r("div", {
175
- key: e,
176
- class: T(["hys-ui-pg-day-column", { "hys-ui-weekend": [0, 6].includes(S(e).getUTCDay()) }]),
177
- style: g({ left: (e - f.value.start) * u.value + "px", width: u.value + "px" })
178
- }, null, 6))), 128)),
179
- s("div", {
180
- class: "hys-ui-pg-today-line",
181
- style: g({ left: (c(B(_)) - f.value.start) * u.value + u.value / 2 + "px" })
182
- }, null, 4),
183
- (o(!0), r(k, null, x(h.value, (e, l) => {
184
- var a;
185
- return o(), r("div", {
186
- key: e.id,
187
- class: "hys-ui-pg-row",
188
- style: g({ top: l * d.rowHeight + "px", height: d.rowHeight + "px" })
189
- }, [
190
- s("div", {
191
- class: T(["hys-ui-pg-bar", { "hys-ui-selected": P.value === e.id, "hys-ui-dragging": ((a = w.value) == null ? void 0 : a.id) === e.id, "hys-ui-disabled": e.disabled }]),
192
- style: g(ee(e)),
193
- role: "button",
194
- tabindex: "0",
195
- "aria-label": `${e.title},${e.start} 至 ${e.end},完成 ${e.progress}%`,
196
- title: `${e.title}
197
- ${e.start} → ${e.end}
198
- 完成 ${e.progress}%`,
199
- onClick: (i) => F(e),
200
- onKeydown: [
201
- D((i) => F(e), ["enter"]),
202
- D($((i) => F(e), ["prevent"]), ["space"]),
203
- D($((i) => W(e, -1), ["alt", "prevent"]), ["left"]),
204
- D($((i) => W(e, 1), ["alt", "prevent"]), ["right"])
205
- ],
206
- onPointerdown: (i) => K(i, e, "move"),
207
- onPointermove: Y,
208
- onPointerup: C,
209
- onPointercancel: C
210
- }, [
211
- s("div", {
212
- class: "hys-ui-pg-progress",
213
- style: g({ width: e.progress + "%" })
214
- }, null, 4),
215
- s("span", me, y(e.progress) + "%", 1),
216
- d.editable && !e.disabled ? (o(), r("span", {
217
- key: 0,
218
- class: "hys-ui-pg-handle hys-ui-start",
219
- title: "调整开始日期",
220
- onPointerdown: $((i) => K(i, e, "start"), ["stop"]),
221
- onPointermove: Y,
222
- onPointerup: C,
223
- onPointercancel: C
224
- }, null, 40, fe)) : H("", !0),
225
- d.editable && !e.disabled ? (o(), r("span", {
226
- key: 1,
227
- class: "hys-ui-pg-handle hys-ui-end",
228
- title: "调整结束日期",
229
- onPointerdown: $((i) => K(i, e, "end"), ["stop"]),
230
- onPointermove: Y,
231
- onPointerup: C,
232
- onPointercancel: C
233
- }, null, 40, we)) : H("", !0)
234
- ], 46, pe)
235
- ], 4);
236
- }), 128)),
237
- X.value.length ? (o(), r("svg", {
238
- key: 0,
239
- class: "hys-ui-pg-dependencies",
240
- width: L.value,
241
- height: h.value.length * d.rowHeight,
242
- "aria-hidden": "true"
243
- }, [
244
- (o(!0), r(k, null, x(X.value, (e) => (o(), r("path", {
245
- key: e.id,
246
- d: e.path,
247
- fill: "none",
248
- stroke: "currentColor",
249
- "stroke-width": "1.5",
250
- "stroke-dasharray": "4 3"
251
- }, null, 8, ke))), 128))
252
- ], 8, be)) : H("", !0)
253
- ], 4)
254
- ], 4)
255
- ], 512)
256
- ]),
257
- s("div", xe, [
258
- ae(y(h.value.length) + " 项任务 · " + y(h.value.filter((e) => e.status === "已完成").length) + " 项已完成 ", 1),
259
- h.value.length !== d.items.length ? (o(), r("span", $e, "· " + y(d.items.length - h.value.length) + " 项日期无效已隐藏", 1)) : H("", !0)
260
- ])
261
- ], 16));
262
- }
263
- });
1
+ import t from "./HysGantt2.vue.js";
2
+ /* empty css */
3
+ import o from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const p = /* @__PURE__ */ o(t, [["__scopeId", "data-v-c534ea2b"]]);
264
5
  export {
265
- De as default
6
+ p as default
266
7
  };