@guoyg578/k-ui 0.1.5 → 0.1.6

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 (96) hide show
  1. package/dist/components/KAutoComplete.vue.d.ts +2 -0
  2. package/dist/components/KAutoComplete.vue.js +1 -1
  3. package/dist/components/KAutoComplete.vue_vue_type_script_setup_true_lang.js +89 -29
  4. package/dist/components/KCalendar.vue.js +1 -1
  5. package/dist/components/KCalendar.vue_vue_type_script_setup_true_lang.js +132 -39
  6. package/dist/components/KCascader.vue.d.ts +2 -0
  7. package/dist/components/KCascader.vue.js +1 -1
  8. package/dist/components/KCascader.vue_vue_type_script_setup_true_lang.js +19 -18
  9. package/dist/components/KCheckbox.vue.d.ts +6 -2
  10. package/dist/components/KCheckbox.vue.js +1 -1
  11. package/dist/components/KCheckbox.vue_vue_type_script_setup_true_lang.js +38 -18
  12. package/dist/components/KCheckboxGroup.vue.d.ts +2 -0
  13. package/dist/components/KCheckboxGroup.vue.js +1 -1
  14. package/dist/components/KCheckboxGroup.vue_vue_type_script_setup_true_lang.js +23 -15
  15. package/dist/components/KCollapse.vue.d.ts +3 -1
  16. package/dist/components/KCollapse.vue.js +1 -1
  17. package/dist/components/KCollapse.vue_vue_type_script_setup_true_lang.js +27 -16
  18. package/dist/components/KDataTable.vue.d.ts +48 -1
  19. package/dist/components/KDataTable.vue.js +1 -1
  20. package/dist/components/KDataTable.vue_vue_type_script_setup_true_lang.js +305 -74
  21. package/dist/components/KDatePicker.vue.d.ts +8 -0
  22. package/dist/components/KDatePicker.vue_vue_type_script_setup_true_lang.js +32 -22
  23. package/dist/components/KDialog.vue.d.ts +4 -4
  24. package/dist/components/KDialog.vue.js +1 -1
  25. package/dist/components/KDialog.vue_vue_type_script_setup_true_lang.js +80 -71
  26. package/dist/components/KDropdown.vue.d.ts +4 -3
  27. package/dist/components/KDropdown.vue_vue_type_script_setup_true_lang.js +45 -28
  28. package/dist/components/KDynamicInput.vue.d.ts +2 -0
  29. package/dist/components/KDynamicInput.vue.js +1 -1
  30. package/dist/components/KDynamicInput.vue_vue_type_script_setup_true_lang.js +17 -6
  31. package/dist/components/KDynamicTags.vue.d.ts +2 -0
  32. package/dist/components/KDynamicTags.vue.js +1 -1
  33. package/dist/components/KDynamicTags.vue_vue_type_script_setup_true_lang.js +11 -10
  34. package/dist/components/KForm.vue.d.ts +12 -0
  35. package/dist/components/KForm.vue.js +1 -1
  36. package/dist/components/KForm.vue_vue_type_script_setup_true_lang.js +26 -4
  37. package/dist/components/KFormField.vue.d.ts +3 -1
  38. package/dist/components/KFormField.vue.js +1 -1
  39. package/dist/components/KFormField.vue_vue_type_script_setup_true_lang.js +124 -61
  40. package/dist/components/KInputNumber.vue.js +1 -1
  41. package/dist/components/KInputNumber.vue_vue_type_script_setup_true_lang.js +35 -29
  42. package/dist/components/KMention.vue.d.ts +2 -0
  43. package/dist/components/KMention.vue.js +1 -1
  44. package/dist/components/KMention.vue_vue_type_script_setup_true_lang.js +34 -33
  45. package/dist/components/KMenu.vue.js +1 -1
  46. package/dist/components/KMenu.vue_vue_type_script_setup_true_lang.js +132 -51
  47. package/dist/components/KMenuItem.vue.js +1 -1
  48. package/dist/components/KMenuItem.vue_vue_type_script_setup_true_lang.js +21 -6
  49. package/dist/components/KMessage.d.ts +5 -0
  50. package/dist/components/KMessage.js +36 -23
  51. package/dist/components/KNotification.d.ts +8 -0
  52. package/dist/components/KNotification.js +45 -29
  53. package/dist/components/KNotificationProvider.vue.js +3 -8
  54. package/dist/components/KNotificationProvider.vue_vue_type_script_setup_true_lang.js +11 -0
  55. package/dist/components/KPagination.vue.d.ts +4 -1
  56. package/dist/components/KPagination.vue.js +1 -1
  57. package/dist/components/KPagination.vue_vue_type_script_setup_true_lang.js +36 -33
  58. package/dist/components/KRadio.vue.d.ts +1 -0
  59. package/dist/components/KRadio.vue.js +1 -1
  60. package/dist/components/KRadio.vue_vue_type_script_setup_true_lang.js +22 -14
  61. package/dist/components/KRadioGroup.vue.d.ts +4 -2
  62. package/dist/components/KRadioGroup.vue.js +1 -1
  63. package/dist/components/KRadioGroup.vue_vue_type_script_setup_true_lang.js +16 -4
  64. package/dist/components/KRate.vue.d.ts +5 -0
  65. package/dist/components/KRate.vue.js +1 -1
  66. package/dist/components/KRate.vue_vue_type_script_setup_true_lang.js +72 -24
  67. package/dist/components/KSelect.vue.d.ts +2 -2
  68. package/dist/components/KSelect.vue.js +1 -1
  69. package/dist/components/KSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  70. package/dist/components/KSlider.vue.d.ts +2 -0
  71. package/dist/components/KSlider.vue.js +1 -1
  72. package/dist/components/KSlider.vue_vue_type_script_setup_true_lang.js +17 -16
  73. package/dist/components/KTextarea.vue.d.ts +2 -0
  74. package/dist/components/KTextarea.vue.js +1 -1
  75. package/dist/components/KTextarea.vue_vue_type_script_setup_true_lang.js +10 -9
  76. package/dist/components/KTimePicker.vue.d.ts +2 -0
  77. package/dist/components/KTimePicker.vue.js +1 -1
  78. package/dist/components/KTimePicker.vue_vue_type_script_setup_true_lang.js +61 -48
  79. package/dist/components/KTransfer.vue.d.ts +2 -0
  80. package/dist/components/KTransfer.vue.js +1 -1
  81. package/dist/components/KTransfer.vue_vue_type_script_setup_true_lang.js +35 -34
  82. package/dist/components/KTreeSelect.vue.d.ts +2 -0
  83. package/dist/components/KTreeSelect.vue.js +1 -1
  84. package/dist/components/KTreeSelect.vue_vue_type_script_setup_true_lang.js +15 -14
  85. package/dist/components/KUpload.vue.d.ts +14 -0
  86. package/dist/components/KUpload.vue.js +1 -1
  87. package/dist/components/KUpload.vue_vue_type_script_setup_true_lang.js +159 -117
  88. package/dist/components/checkbox-context.d.ts +10 -0
  89. package/dist/components/checkbox-context.js +4 -0
  90. package/dist/components/form-context.d.ts +19 -2
  91. package/dist/components/form-context.js +31 -1
  92. package/dist/components/menu-context.d.ts +4 -0
  93. package/dist/components/radio-context.d.ts +6 -1
  94. package/dist/k-ui.css +1 -1
  95. package/dist/styles/tokens.css +40 -1
  96. package/package.json +1 -1
@@ -1,20 +1,21 @@
1
- import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, nextTick as o, openBlock as s, ref as c, renderList as l, toDisplayString as u, withModifiers as d } from "vue";
1
+ import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, nextTick as o, normalizeClass as s, openBlock as c, ref as l, renderList as u, toDisplayString as d, withModifiers as f } from "vue";
2
2
  //#region components/KMention.vue?vue&type=script&setup=true&lang.ts
3
- var f = { class: "k-mention" }, p = [
3
+ var p = { class: "k-mention" }, m = [
4
4
  "value",
5
5
  "rows",
6
6
  "placeholder",
7
7
  "disabled"
8
- ], m = {
8
+ ], h = {
9
9
  key: 0,
10
10
  class: "k-mention__list k-menu-surface"
11
- }, h = ["onMousedown"], g = /* @__PURE__ */ a({
11
+ }, g = ["onMousedown"], _ = /* @__PURE__ */ a({
12
12
  __name: "KMention",
13
13
  props: {
14
14
  modelValue: { default: "" },
15
15
  options: { default: () => [] },
16
16
  prefix: { default: "@" },
17
17
  placeholder: {},
18
+ size: { default: "md" },
18
19
  rows: { default: 3 },
19
20
  disabled: {
20
21
  type: Boolean,
@@ -22,52 +23,52 @@ var f = { class: "k-mention" }, p = [
22
23
  }
23
24
  },
24
25
  emits: ["update:modelValue", "mention"],
25
- setup(a, { emit: g }) {
26
- let _ = a, v = g, y = c(null), b = c(!1), x = c(""), S = -1;
27
- function C(e) {
28
- let t = e.selectionStart ?? 0, n = e.value.slice(0, t), r = _.prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.match(RegExp(`(?:^|\\s)${r}([^\\s${r}]*)$`));
29
- i ? (x.value = i[1], S = t - i[1].length - _.prefix.length, b.value = !0) : b.value = !1;
26
+ setup(a, { emit: _ }) {
27
+ let v = a, y = _, b = l(null), x = l(!1), S = l(""), C = -1, w = t(() => v.size === "tiny" || v.size === "xs" || v.size === "small" || v.size === "sm" ? "sm" : v.size === "large" || v.size === "lg" ? "lg" : "md");
28
+ function T(e) {
29
+ let t = e.selectionStart ?? 0, n = e.value.slice(0, t), r = v.prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.match(RegExp(`(?:^|\\s)${r}([^\\s${r}]*)$`));
30
+ i ? (S.value = i[1], C = t - i[1].length - v.prefix.length, x.value = !0) : x.value = !1;
30
31
  }
31
- function w(e) {
32
+ function E(e) {
32
33
  let t = e.target;
33
- v("update:modelValue", t.value), C(t);
34
+ y("update:modelValue", t.value), T(t);
34
35
  }
35
- let T = t(() => {
36
- let e = x.value.toLowerCase();
37
- return (_.options ?? []).filter((t) => t.label.toLowerCase().includes(e));
36
+ let D = t(() => {
37
+ let e = S.value.toLowerCase();
38
+ return (v.options ?? []).filter((t) => t.label.toLowerCase().includes(e));
38
39
  });
39
- async function E(e) {
40
- let t = y.value;
40
+ async function O(e) {
41
+ let t = b.value;
41
42
  if (!t) return;
42
- let n = t.selectionStart ?? 0, r = _.modelValue ?? "", i = `${_.prefix}${e.label} `;
43
- v("update:modelValue", r.slice(0, S) + i + r.slice(n)), v("mention", e), b.value = !1, await o(), t.focus();
44
- let a = S + i.length;
43
+ let n = t.selectionStart ?? 0, r = v.modelValue ?? "", i = `${v.prefix}${e.label} `;
44
+ y("update:modelValue", r.slice(0, C) + i + r.slice(n)), y("mention", e), x.value = !1, await o(), t.focus();
45
+ let a = C + i.length;
45
46
  t.setSelectionRange(a, a);
46
47
  }
47
- function D(e) {
48
- b.value && e.key === "Enter" && T.value.length ? (e.preventDefault(), E(T.value[0])) : e.key === "Escape" && (b.value = !1);
48
+ function k(e) {
49
+ x.value && e.key === "Enter" && D.value.length ? (e.preventDefault(), O(D.value[0])) : e.key === "Escape" && (x.value = !1);
49
50
  }
50
- function O() {
51
- setTimeout(() => b.value = !1, 120);
51
+ function A() {
52
+ setTimeout(() => x.value = !1, 120);
52
53
  }
53
- return (t, o) => (s(), r("div", f, [i("textarea", {
54
+ return (t, o) => (c(), r("div", p, [i("textarea", {
54
55
  ref_key: "ta",
55
- ref: y,
56
- class: "k-mention__input",
56
+ ref: b,
57
+ class: s(["k-mention__input", `k-mention__input--${w.value}`]),
57
58
  value: a.modelValue,
58
59
  rows: a.rows,
59
60
  placeholder: a.placeholder,
60
61
  disabled: a.disabled,
61
- onInput: w,
62
- onKeydown: D,
63
- onBlur: O
64
- }, null, 40, p), b.value && T.value.length ? (s(), r("div", m, [(s(!0), r(e, null, l(T.value, (e) => (s(), r("button", {
62
+ onInput: E,
63
+ onKeydown: k,
64
+ onBlur: A
65
+ }, null, 42, m), x.value && D.value.length ? (c(), r("div", h, [(c(!0), r(e, null, u(D.value, (e) => (c(), r("button", {
65
66
  key: e.value ?? e.label,
66
67
  type: "button",
67
68
  class: "k-mention__item",
68
- onMousedown: d((t) => E(e), ["prevent"])
69
- }, u(e.label), 41, h))), 128))])) : n("", !0)]));
69
+ onMousedown: f((t) => O(e), ["prevent"])
70
+ }, d(e.label), 41, g))), 128))])) : n("", !0)]));
70
71
  }
71
72
  });
72
73
  //#endregion
73
- export { g as default };
74
+ export { _ as default };
@@ -4,6 +4,6 @@ import t from "./KMenu.vue_vue_type_script_setup_true_lang.js";
4
4
  /* empty css */
5
5
  /* empty css */
6
6
  //#region components/KMenu.vue
7
- var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-c59150ee"]]);
7
+ var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-29b58dd2"]]);
8
8
  //#endregion
9
9
  export { n as default };
@@ -1,19 +1,19 @@
1
1
  import { MENU_KEY as e } from "./menu-context.js";
2
2
  import t from "./KMenuItem.vue.js";
3
- import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, normalizeClass as d, normalizeStyle as f, openBlock as p, provide as m, ref as h, renderList as g, resolveDynamicComponent as _, toDisplayString as v, unref as y, watch as b, withCtx as x } from "vue";
4
- import { HoverCardContent as S, HoverCardPortal as C, HoverCardRoot as w, HoverCardTrigger as T } from "reka-ui";
3
+ import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, nextTick as d, normalizeClass as f, normalizeStyle as p, openBlock as m, provide as h, ref as g, renderList as _, resolveDynamicComponent as v, toDisplayString as y, unref as b, watch as x, watchEffect as S, withCtx as C } from "vue";
4
+ import { HoverCardContent as w, HoverCardPortal as T, HoverCardRoot as E, HoverCardTrigger as D } from "reka-ui";
5
5
  //#region components/KMenu.vue?vue&type=script&setup=true&lang.ts
6
- var E = {
6
+ var O = ["role"], k = {
7
7
  key: 0,
8
8
  class: "k-menu-tree__divider"
9
- }, D = ["aria-label"], O = ["disabled", "onClick"], k = {
9
+ }, A = ["aria-label"], j = ["disabled", "onClick"], M = {
10
10
  key: 0,
11
11
  class: "k-menu-tree-flyout__icon"
12
- }, A = { class: "k-menu-tree-flyout__label" }, j = [
12
+ }, N = { class: "k-menu-tree-flyout__label" }, P = [
13
13
  "disabled",
14
14
  "aria-label",
15
15
  "onClick"
16
- ], M = /* @__PURE__ */ u({
16
+ ], F = /* @__PURE__ */ u({
17
17
  __name: "KMenu",
18
18
  props: {
19
19
  value: {},
@@ -31,104 +31,185 @@ var E = {
31
31
  }
32
32
  },
33
33
  emits: ["update:value", "select"],
34
- setup(u, { emit: M }) {
35
- let N = u, P = M, F = h(/* @__PURE__ */ new Set()), I = r(() => {
34
+ setup(u, { emit: F }) {
35
+ let I = u, L = F, R = g(/* @__PURE__ */ new Set()), z = r(() => {
36
36
  let e = [], t = (n, r) => {
37
37
  for (let i of n) if (i.type !== "divider") {
38
- if (i.key === N.value) return e.push(...r), !0;
38
+ if (i.key === I.value) return e.push(...r), !0;
39
39
  if (i.children?.length && t(i.children, [...r, i.key])) return !0;
40
40
  }
41
41
  return !1;
42
42
  };
43
- return t(N.options, []), e;
43
+ return t(I.options, []), e;
44
44
  });
45
- b(I, (e) => {
45
+ x(z, (e) => {
46
46
  if (!e.length) return;
47
- let t = new Set(F.value);
48
- e.forEach((e) => t.add(e)), F.value = t;
47
+ let t = new Set(R.value);
48
+ e.forEach((e) => t.add(e)), R.value = t;
49
49
  }, { immediate: !0 });
50
- let L = {
51
- isActive: (e) => e === N.value,
52
- inActiveTrail: (e) => I.value.includes(e),
53
- isExpanded: (e) => F.value.has(e),
50
+ let B = r(() => {
51
+ let e = [], t = (n, r) => {
52
+ for (let i of n) {
53
+ if (i.type === "divider" || !i.key) continue;
54
+ let n = !!i.children?.length, a = R.value.has(i.key);
55
+ e.push({
56
+ key: i.key,
57
+ option: i,
58
+ depth: r,
59
+ isParent: n,
60
+ expanded: a
61
+ }), n && a && t(i.children, r + 1);
62
+ }
63
+ };
64
+ return t(I.options, 0), e;
65
+ }), V = g(), H = g(null);
66
+ S(() => {
67
+ let e = B.value;
68
+ if (!e.length) {
69
+ H.value = null;
70
+ return;
71
+ }
72
+ (!H.value || !e.some((e) => e.key === H.value)) && (H.value = I.value && e.some((e) => e.key === I.value) ? I.value : e[0].key);
73
+ });
74
+ function U(e) {
75
+ d(() => {
76
+ let t = `[data-menu-key="${typeof CSS < "u" ? CSS.escape(e) : e}"]`;
77
+ V.value?.querySelector(t)?.focus();
78
+ });
79
+ }
80
+ function W(e, t) {
81
+ let n = B.value, r = e;
82
+ for (; r >= 0 && r < n.length && n[r].option.disabled;) r += t;
83
+ r < 0 || r >= n.length || (H.value = n[r].key, U(n[r].key));
84
+ }
85
+ function G(e) {
86
+ if (I.collapsed) return;
87
+ let t = B.value;
88
+ if (!t.length) return;
89
+ let n = t.findIndex((e) => e.key === H.value);
90
+ n < 0 && (n = 0);
91
+ let r = t[n];
92
+ switch (e.key) {
93
+ case "ArrowDown":
94
+ e.preventDefault(), W(n + 1, 1);
95
+ break;
96
+ case "ArrowUp":
97
+ e.preventDefault(), W(n - 1, -1);
98
+ break;
99
+ case "Home":
100
+ e.preventDefault(), W(0, 1);
101
+ break;
102
+ case "End":
103
+ e.preventDefault(), W(t.length - 1, -1);
104
+ break;
105
+ case "ArrowRight":
106
+ e.preventDefault(), r.isParent && !r.expanded ? K.toggle(r.key) : r.isParent && r.expanded && W(n + 1, 1);
107
+ break;
108
+ case "ArrowLeft":
109
+ if (e.preventDefault(), r.isParent && r.expanded) K.toggle(r.key);
110
+ else for (let e = n - 1; e >= 0; e--) if (t[e].depth < r.depth) {
111
+ H.value = t[e].key, U(t[e].key);
112
+ break;
113
+ }
114
+ break;
115
+ case "Enter":
116
+ case " ":
117
+ if (e.preventDefault(), r.option.disabled) break;
118
+ r.isParent ? K.toggle(r.key) : K.select(r.option);
119
+ break;
120
+ }
121
+ }
122
+ let K = {
123
+ isActive: (e) => e === I.value,
124
+ inActiveTrail: (e) => z.value.includes(e),
125
+ isExpanded: (e) => R.value.has(e),
54
126
  toggle: (e) => {
55
- let t = new Set(F.value);
56
- t.has(e) ? t.delete(e) : (N.accordion && t.clear(), t.add(e)), F.value = t;
127
+ let t = new Set(R.value);
128
+ t.has(e) ? t.delete(e) : (I.accordion && t.clear(), t.add(e)), R.value = t;
57
129
  },
58
130
  select: (e) => {
59
- P("update:value", e.key), P("select", e.key, e);
131
+ L("update:value", e.key), L("select", e.key, e);
132
+ },
133
+ isFocused: (e) => H.value === e,
134
+ setFocus: (e) => {
135
+ H.value = e;
60
136
  },
61
137
  get indent() {
62
- return N.indent;
138
+ return I.indent;
63
139
  },
64
140
  get rootIndent() {
65
- return N.rootIndent;
141
+ return I.rootIndent;
66
142
  }
67
143
  };
68
- m(e, L);
69
- let R = (e) => typeof e == "function";
70
- function z(e) {
71
- e.disabled || (P("update:value", e.key), P("select", e.key, e));
144
+ h(e, K);
145
+ let q = (e) => typeof e == "function";
146
+ function J(e) {
147
+ e.disabled || (L("update:value", e.key), L("select", e.key, e));
72
148
  }
73
- return (e, r) => (p(), o("nav", {
74
- class: d(["k-menu-tree", { "k-menu-tree--collapsed": u.collapsed }]),
75
- style: f(u.collapsed ? { width: `${u.collapsedWidth}px` } : void 0)
76
- }, [u.collapsed ? (p(!0), o(n, { key: 1 }, g(u.options, (e, t) => (p(), o(n, { key: e.key || `_div${t}` }, [e.type === "divider" ? (p(), o("div", E)) : e.children?.length ? (p(), i(y(w), {
149
+ return (e, r) => (m(), o("nav", {
150
+ ref_key: "navEl",
151
+ ref: V,
152
+ class: f(["k-menu-tree", { "k-menu-tree--collapsed": u.collapsed }]),
153
+ style: p(u.collapsed ? { width: `${u.collapsedWidth}px` } : void 0),
154
+ role: u.collapsed ? void 0 : "tree",
155
+ onKeydown: G
156
+ }, [u.collapsed ? (m(!0), o(n, { key: 1 }, _(u.options, (e, t) => (m(), o(n, { key: e.key || `_div${t}` }, [e.type === "divider" ? (m(), o("div", k)) : e.children?.length ? (m(), i(b(E), {
77
157
  key: 1,
78
158
  "open-delay": 0,
79
159
  "close-delay": 120
80
160
  }, {
81
- default: x(() => [l(y(T), { "as-child": "" }, {
82
- default: x(() => [s("button", {
161
+ default: C(() => [l(b(D), { "as-child": "" }, {
162
+ default: C(() => [s("button", {
83
163
  type: "button",
84
- class: d(["k-menu-tree__icon-btn", { "k-menu-tree__icon-btn--trail": L.inActiveTrail(e.key) }]),
85
- "aria-label": typeof e.label == "string" ? e.label : void 0
86
- }, [e.icon ? (p(), i(_(e.icon), {
164
+ class: f(["k-menu-tree__icon-btn", { "k-menu-tree__icon-btn--trail": K.inActiveTrail(e.key) }]),
165
+ "aria-label": typeof e.label == "string" ? e.label : void 0,
166
+ "aria-haspopup": "menu"
167
+ }, [e.icon ? (m(), i(v(e.icon), {
87
168
  key: 0,
88
169
  size: 20
89
- })) : a("", !0)], 10, D)]),
170
+ })) : a("", !0)], 10, A)]),
90
171
  _: 2
91
- }, 1024), l(y(C), null, {
92
- default: x(() => [l(y(S), {
172
+ }, 1024), l(b(T), null, {
173
+ default: C(() => [l(b(w), {
93
174
  class: "k-menu-surface k-menu-tree-flyout",
94
175
  side: "right",
95
176
  align: "start",
96
177
  "side-offset": 10
97
178
  }, {
98
- default: x(() => [(p(!0), o(n, null, g(e.children, (e) => (p(), o("button", {
179
+ default: C(() => [(m(!0), o(n, null, _(e.children, (e) => (m(), o("button", {
99
180
  key: e.key,
100
181
  type: "button",
101
- class: d(["k-menu-tree-flyout__item", {
102
- "k-menu-tree-flyout__item--active": L.isActive(e.key),
182
+ class: f(["k-menu-tree-flyout__item", {
183
+ "k-menu-tree-flyout__item--active": K.isActive(e.key),
103
184
  "k-menu-tree-flyout__item--disabled": e.disabled
104
185
  }]),
105
186
  disabled: e.disabled,
106
- onClick: (t) => z(e)
107
- }, [e.icon ? (p(), o("span", k, [(p(), i(_(e.icon), { size: 16 }))])) : a("", !0), s("span", A, [R(e.label) ? (p(), i(_(e.label), { key: 0 })) : (p(), o(n, { key: 1 }, [c(v(e.label), 1)], 64))])], 10, O))), 128))]),
187
+ onClick: (t) => J(e)
188
+ }, [e.icon ? (m(), o("span", M, [(m(), i(v(e.icon), { size: 16 }))])) : a("", !0), s("span", N, [q(e.label) ? (m(), i(v(e.label), { key: 0 })) : (m(), o(n, { key: 1 }, [c(y(e.label), 1)], 64))])], 10, j))), 128))]),
108
189
  _: 2
109
190
  }, 1024)]),
110
191
  _: 2
111
192
  }, 1024)]),
112
193
  _: 2
113
- }, 1024)) : (p(), o("button", {
194
+ }, 1024)) : (m(), o("button", {
114
195
  key: 2,
115
196
  type: "button",
116
- class: d(["k-menu-tree__icon-btn", {
117
- "k-menu-tree__icon-btn--active": L.isActive(e.key),
197
+ class: f(["k-menu-tree__icon-btn", {
198
+ "k-menu-tree__icon-btn--active": K.isActive(e.key),
118
199
  "k-menu-tree__icon-btn--disabled": e.disabled
119
200
  }]),
120
201
  disabled: e.disabled,
121
202
  "aria-label": typeof e.label == "string" ? e.label : void 0,
122
- onClick: (t) => z(e)
123
- }, [e.icon ? (p(), i(_(e.icon), {
203
+ onClick: (t) => J(e)
204
+ }, [e.icon ? (m(), i(v(e.icon), {
124
205
  key: 0,
125
206
  size: 20
126
- })) : a("", !0)], 10, j))], 64))), 128)) : (p(!0), o(n, { key: 0 }, g(u.options, (e, n) => (p(), i(t, {
207
+ })) : a("", !0)], 10, P))], 64))), 128)) : (m(!0), o(n, { key: 0 }, _(u.options, (e, n) => (m(), i(t, {
127
208
  key: e.key || `_div${n}`,
128
209
  option: e,
129
210
  depth: 0
130
- }, null, 8, ["option"]))), 128))], 6));
211
+ }, null, 8, ["option"]))), 128))], 46, O));
131
212
  }
132
213
  });
133
214
  //#endregion
134
- export { M as default };
215
+ export { F as default };
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./KMenuItem.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region components/KMenuItem.vue
5
- var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-7e1cc01a"]]);
5
+ var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-e9fa44e5"]]);
6
6
  //#endregion
7
7
  export { n as default };
@@ -4,16 +4,25 @@ import { ChevronDown as b } from "lucide-vue-next";
4
4
  //#region components/KMenuItem.vue?vue&type=script&setup=true&lang.ts
5
5
  var x = {
6
6
  key: 0,
7
- class: "k-menu-tree__divider"
7
+ class: "k-menu-tree__divider",
8
+ role: "separator"
8
9
  }, S = {
9
10
  key: 1,
10
- class: "k-menu-tree__node"
11
- }, C = ["disabled"], w = {
11
+ class: "k-menu-tree__node",
12
+ role: "none"
13
+ }, C = [
14
+ "data-menu-key",
15
+ "tabindex",
16
+ "aria-expanded",
17
+ "aria-current",
18
+ "disabled"
19
+ ], w = {
12
20
  key: 0,
13
21
  class: "k-menu-tree__icon"
14
22
  }, T = { class: "k-menu-tree__label" }, E = {
15
23
  key: 0,
16
- class: "k-menu-tree__children"
24
+ class: "k-menu-tree__children",
25
+ role: "group"
17
26
  }, D = /* @__PURE__ */ c({
18
27
  name: "KMenuItem",
19
28
  __name: "KMenuItem",
@@ -35,9 +44,15 @@ var x = {
35
44
  "k-menu-tree__item--trail": k.value && _(O).inActiveTrail(c.option.key),
36
45
  "k-menu-tree__item--disabled": c.option.disabled
37
46
  }]),
47
+ role: "treeitem",
48
+ "data-menu-key": c.option.key,
49
+ tabindex: _(O).isFocused(c.option.key) ? 0 : -1,
50
+ "aria-expanded": k.value ? _(O).isExpanded(c.option.key) : void 0,
51
+ "aria-current": !k.value && _(O).isActive(c.option.key) ? "page" : void 0,
38
52
  style: d({ paddingLeft: j.value }),
39
53
  disabled: c.option.disabled,
40
- onClick: M
54
+ onClick: M,
55
+ onFocus: n[0] ||= (e) => _(O).setFocus(c.option.key)
41
56
  }, [
42
57
  c.option.icon ? (f(), a("span", w, [(f(), r(h(c.option.icon), { size: 18 }))])) : i("", !0),
43
58
  o("span", T, [A(c.option.label) ? (f(), r(h(c.option.label), { key: 0 })) : (f(), a(t, { key: 1 }, [s(g(c.option.label), 1)], 64))]),
@@ -46,7 +61,7 @@ var x = {
46
61
  size: 14,
47
62
  class: u(["k-menu-tree__arrow", { "k-menu-tree__arrow--open": _(O).isExpanded(c.option.key) }])
48
63
  }, null, 8, ["class"])) : i("", !0)
49
- ], 14, C), k.value ? y((f(), a("div", E, [(f(!0), a(t, null, p(c.option.children, (e) => (f(), r(l, {
64
+ ], 46, C), k.value ? y((f(), a("div", E, [(f(!0), a(t, null, p(c.option.children, (e) => (f(), r(l, {
50
65
  key: e.key,
51
66
  option: e,
52
67
  depth: c.depth + 1
@@ -7,11 +7,16 @@ export interface MessageOptions {
7
7
  declare function open(opts: MessageOptions): number;
8
8
  declare function close(id: number): void;
9
9
  declare function closeAll(): void;
10
+ /** 全局配置, 目前支持 max(最大同时显示条数, 0=不限) */
11
+ declare function config(opts: {
12
+ max?: number;
13
+ }): void;
10
14
  type ShortHand = (content: string, opts?: Partial<MessageOptions>) => number;
11
15
  export declare const KMessage: {
12
16
  open: typeof open;
13
17
  close: typeof close;
14
18
  closeAll: typeof closeAll;
19
+ config: typeof config;
15
20
  success: ShortHand;
16
21
  error: ShortHand;
17
22
  warning: ShortHand;
@@ -1,55 +1,68 @@
1
1
  import e from "./KMessageContainer.vue.js";
2
2
  import { createApp as t, h as n, ref as r } from "vue";
3
3
  //#region components/KMessage.ts
4
- var i = null, a = null, o = null;
5
- function s() {
6
- i || (o = document.createElement("div"), document.body.appendChild(o), a = r([]), i = t({ setup() {
4
+ var i = null, a = null, o = null, s = /* @__PURE__ */ new Map(), c = 0;
5
+ function l(e) {
6
+ let t = s.get(e);
7
+ t && (clearTimeout(t), s.delete(e));
8
+ }
9
+ function u() {
10
+ i || typeof document > "u" || (o = document.createElement("div"), document.body.appendChild(o), a = r([]), i = t({ setup() {
7
11
  return () => n(e, {
8
12
  messages: a.value,
9
- onRemove: u
13
+ onRemove: p
10
14
  });
11
15
  } }), i.mount(o));
12
16
  }
13
- var c = 0;
14
- function l(e) {
15
- s();
16
- let t = ++c, n = e.duration ?? 3e3, r = {
17
+ var d = 0;
18
+ function f(e) {
19
+ if (typeof document > "u") return -1;
20
+ u();
21
+ let t = ++d, n = e.duration ?? 3e3, r = {
17
22
  id: t,
18
23
  ...e,
19
24
  duration: n
20
- };
21
- return a.value = [...a.value, r], n > 0 && setTimeout(() => u(t), n), t;
25
+ }, i = [...a.value, r];
26
+ if (c > 0 && i.length > c) {
27
+ for (let e of i.slice(0, i.length - c)) l(e.id);
28
+ i = i.slice(i.length - c);
29
+ }
30
+ return a.value = i, n > 0 && s.set(t, setTimeout(() => p(t), n)), t;
31
+ }
32
+ function p(e) {
33
+ l(e), a && (a.value = a.value.filter((t) => t.id !== e));
22
34
  }
23
- function u(e) {
24
- a && (a.value = a.value.filter((t) => t.id !== e));
35
+ function m() {
36
+ s.forEach((e) => clearTimeout(e)), s.clear(), a && (a.value = []);
25
37
  }
26
- function d() {
27
- a && (a.value = []);
38
+ function h(e) {
39
+ typeof e.max == "number" && (c = Math.max(0, e.max));
28
40
  }
29
- var f = {
30
- open: l,
31
- close: u,
32
- closeAll: d,
33
- success: (e, t = {}) => l({
41
+ var g = {
42
+ open: f,
43
+ close: p,
44
+ closeAll: m,
45
+ config: h,
46
+ success: (e, t = {}) => f({
34
47
  ...t,
35
48
  type: "success",
36
49
  content: e
37
50
  }),
38
- error: (e, t = {}) => l({
51
+ error: (e, t = {}) => f({
39
52
  ...t,
40
53
  type: "error",
41
54
  content: e
42
55
  }),
43
- warning: (e, t = {}) => l({
56
+ warning: (e, t = {}) => f({
44
57
  ...t,
45
58
  type: "warning",
46
59
  content: e
47
60
  }),
48
- info: (e, t = {}) => l({
61
+ info: (e, t = {}) => f({
49
62
  ...t,
50
63
  type: "info",
51
64
  content: e
52
65
  })
53
66
  };
54
67
  //#endregion
55
- export { f as KMessage };
68
+ export { g as KMessage };
@@ -14,11 +14,18 @@ export interface NotificationReactive {
14
14
  declare function create(options: NotificationOptions): NotificationReactive;
15
15
  declare function close(id: number): void;
16
16
  declare function closeAll(): void;
17
+ /** 全局配置, 目前支持 max(最大同时显示条数, 0=不限) */
18
+ declare function config(opts: {
19
+ max?: number;
20
+ }): void;
21
+ /** 预热通知容器 (供 KNotificationProvider 在挂载时调用, 消除首条通知的挂载延迟) */
22
+ export declare function ensureMounted(): void;
17
23
  type ShortHand = (options: Omit<NotificationOptions, 'type'> | string) => NotificationReactive;
18
24
  export declare const KNotification: {
19
25
  create: typeof create;
20
26
  close: typeof close;
21
27
  closeAll: typeof closeAll;
28
+ config: typeof config;
22
29
  success: ShortHand;
23
30
  error: ShortHand;
24
31
  warning: ShortHand;
@@ -28,6 +35,7 @@ export declare function useNotification(): {
28
35
  create: typeof create;
29
36
  close: typeof close;
30
37
  closeAll: typeof closeAll;
38
+ config: typeof config;
31
39
  success: ShortHand;
32
40
  error: ShortHand;
33
41
  warning: ShortHand;