@kernel4632/kima 0.0.0-stage → 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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -2
  3. package/dist/THIRD_PARTY_NOTICES.txt +2676 -0
  4. package/dist/kima-elements-core.js +53209 -0
  5. package/dist/kima-elements.js +126371 -0
  6. package/dist/kima-theme.js +1583 -0
  7. package/dist/kima.js +141 -0
  8. package/dist/style.css +2 -0
  9. package/dist/vue/_virtual/_plugin-vue_export-helper.js +7 -0
  10. package/dist/vue/components/advanced-input/calendar.ce.js +216 -0
  11. package/dist/vue/components/advanced-input/date-range-picker.ce.js +224 -0
  12. package/dist/vue/components/advanced-input/editable.ce.js +160 -0
  13. package/dist/vue/components/advanced-input/mention.ce.js +181 -0
  14. package/dist/vue/components/advanced-input/range-slider.ce.js +111 -0
  15. package/dist/vue/components/advanced-input/time-range-picker.ce.js +120 -0
  16. package/dist/vue/components/advanced-input/transfer.ce.js +192 -0
  17. package/dist/vue/components/content/chart.ce.js +282 -0
  18. package/dist/vue/components/content/code-editor.ce.js +309 -0
  19. package/dist/vue/components/content/equation.ce.js +69 -0
  20. package/dist/vue/components/content/heatmap.ce.js +148 -0
  21. package/dist/vue/components/content/rich-text-editor.ce.js +319 -0
  22. package/dist/vue/components/core/badge.ce.js +66 -0
  23. package/dist/vue/components/core/button-group.ce.js +142 -0
  24. package/dist/vue/components/core/button.ce.js +73 -0
  25. package/dist/vue/components/core/card.ce.js +73 -0
  26. package/dist/vue/components/core/cascader.ce.js +329 -0
  27. package/dist/vue/components/core/checkbox.ce.js +116 -0
  28. package/dist/vue/components/core/code-block.ce.js +108 -0
  29. package/dist/vue/components/core/combobox.ce.js +354 -0
  30. package/dist/vue/components/core/date-picker.ce.js +433 -0
  31. package/dist/vue/components/core/dialog.ce.js +118 -0
  32. package/dist/vue/components/core/divider.ce.js +49 -0
  33. package/dist/vue/components/core/drawer.ce.js +235 -0
  34. package/dist/vue/components/core/empty-state.ce.js +58 -0
  35. package/dist/vue/components/core/icon-button.ce.js +93 -0
  36. package/dist/vue/components/core/icon.ce.js +42 -0
  37. package/dist/vue/components/core/layout.ce.js +68 -0
  38. package/dist/vue/components/core/menu.ce.js +178 -0
  39. package/dist/vue/components/core/notification.ce.js +158 -0
  40. package/dist/vue/components/core/pagination.ce.js +158 -0
  41. package/dist/vue/components/core/progress.ce.js +49 -0
  42. package/dist/vue/components/core/select.ce.js +325 -0
  43. package/dist/vue/components/core/slider.ce.js +116 -0
  44. package/dist/vue/components/core/switch.ce.js +100 -0
  45. package/dist/vue/components/core/tabs.ce.js +193 -0
  46. package/dist/vue/components/core/text-field.ce.js +194 -0
  47. package/dist/vue/components/core/time-picker.ce.js +486 -0
  48. package/dist/vue/components/core/tooltip.ce.js +125 -0
  49. package/dist/vue/components/core/tree.ce.js +248 -0
  50. package/dist/vue/components/core/virtual-scroll.ce.js +176 -0
  51. package/dist/vue/components/data/copy-button.ce.js +75 -0
  52. package/dist/vue/components/data/image-preview.ce.js +226 -0
  53. package/dist/vue/components/data/infinite-scroll.ce.js +126 -0
  54. package/dist/vue/components/data/long-text.ce.js +70 -0
  55. package/dist/vue/components/data/relative-time.ce.js +77 -0
  56. package/dist/vue/components/data/ring-progress.ce.js +87 -0
  57. package/dist/vue/components/data/table.ce.js +491 -0
  58. package/dist/vue/components/data/virtual-table.ce.js +178 -0
  59. package/dist/vue/components/data/virtual-tree.ce.js +213 -0
  60. package/dist/vue/components/display/alert.ce.js +101 -0
  61. package/dist/vue/components/display/avatar-group.ce.js +65 -0
  62. package/dist/vue/components/display/avatar.ce.js +84 -0
  63. package/dist/vue/components/display/blockquote.ce.js +44 -0
  64. package/dist/vue/components/display/countdown.ce.js +77 -0
  65. package/dist/vue/components/display/descriptions.ce.js +43 -0
  66. package/dist/vue/components/display/highlight.ce.js +48 -0
  67. package/dist/vue/components/display/image.ce.js +146 -0
  68. package/dist/vue/components/display/list.ce.js +68 -0
  69. package/dist/vue/components/display/result.ce.js +57 -0
  70. package/dist/vue/components/display/skeleton.ce.js +67 -0
  71. package/dist/vue/components/display/spinner.ce.js +42 -0
  72. package/dist/vue/components/display/statistic.ce.js +71 -0
  73. package/dist/vue/components/display/timeline.ce.js +59 -0
  74. package/dist/vue/components/form-completion/angle-slider.ce.js +103 -0
  75. package/dist/vue/components/form-completion/color-picker.ce.js +286 -0
  76. package/dist/vue/components/form-completion/date-field.ce.js +131 -0
  77. package/dist/vue/components/form-completion/dynamic-input.ce.js +158 -0
  78. package/dist/vue/components/form-completion/form.ce.js +248 -0
  79. package/dist/vue/components/form-completion/json-input.ce.js +114 -0
  80. package/dist/vue/components/form-completion/masked-input.ce.js +88 -0
  81. package/dist/vue/components/form-completion/period-picker.ce.js +147 -0
  82. package/dist/vue/components/form-completion/time-field.ce.js +120 -0
  83. package/dist/vue/components/form-completion/upload-manager.ce.js +223 -0
  84. package/dist/vue/components/foundation/banner.ce.js +106 -0
  85. package/dist/vue/components/foundation/error-state.ce.js +108 -0
  86. package/dist/vue/components/foundation/field-group.ce.js +146 -0
  87. package/dist/vue/components/foundation/flex.ce.js +60 -0
  88. package/dist/vue/components/foundation/grid.ce.js +52 -0
  89. package/dist/vue/components/foundation/input-group.ce.js +34 -0
  90. package/dist/vue/components/foundation/page-header.ce.js +55 -0
  91. package/dist/vue/components/foundation/time-display.ce.js +129 -0
  92. package/dist/vue/components/foundation/typography.ce.js +71 -0
  93. package/dist/vue/components/input/checkbox-group.ce.js +93 -0
  94. package/dist/vue/components/input/field.ce.js +74 -0
  95. package/dist/vue/components/input/file-upload.ce.js +142 -0
  96. package/dist/vue/components/input/number-field.ce.js +103 -0
  97. package/dist/vue/components/input/pin-input.ce.js +112 -0
  98. package/dist/vue/components/input/radio-group.ce.js +96 -0
  99. package/dist/vue/components/input/rating.ce.js +115 -0
  100. package/dist/vue/components/input/tags-input.ce.js +153 -0
  101. package/dist/vue/components/input/textarea.ce.js +180 -0
  102. package/dist/vue/components/input/toggle.ce.js +58 -0
  103. package/dist/vue/components/interaction/chip.ce.js +95 -0
  104. package/dist/vue/components/interaction/command.ce.js +161 -0
  105. package/dist/vue/components/interaction/context-menu.ce.js +113 -0
  106. package/dist/vue/components/interaction/hover-card.ce.js +92 -0
  107. package/dist/vue/components/interaction/loading-overlay.ce.js +70 -0
  108. package/dist/vue/components/interaction/menubar.ce.js +134 -0
  109. package/dist/vue/components/interaction/multi-select.ce.js +264 -0
  110. package/dist/vue/components/interaction/popconfirm.ce.js +95 -0
  111. package/dist/vue/components/interaction/popover.ce.js +83 -0
  112. package/dist/vue/components/interaction/tree-select.ce.js +195 -0
  113. package/dist/vue/components/navigation/accordion.ce.js +114 -0
  114. package/dist/vue/components/navigation/anchor.ce.js +125 -0
  115. package/dist/vue/components/navigation/back-top.ce.js +67 -0
  116. package/dist/vue/components/navigation/breadcrumb.ce.js +48 -0
  117. package/dist/vue/components/navigation/carousel.ce.js +114 -0
  118. package/dist/vue/components/navigation/collapsible.ce.js +57 -0
  119. package/dist/vue/components/navigation/link.ce.js +62 -0
  120. package/dist/vue/components/navigation/navigation-menu.ce.js +91 -0
  121. package/dist/vue/components/navigation/overflow-list.ce.js +67 -0
  122. package/dist/vue/components/navigation/scroll-area.ce.js +47 -0
  123. package/dist/vue/components/navigation/splitter.ce.js +131 -0
  124. package/dist/vue/components/navigation/stepper.ce.js +74 -0
  125. package/dist/vue/components/navigation/toolbar.ce.js +93 -0
  126. package/dist/vue/components/navigation/visually-hidden.ce.js +16 -0
  127. package/dist/vue/components/shell/app-shell.ce.js +87 -0
  128. package/dist/vue/components/shell/config-provider.ce.js +110 -0
  129. package/dist/vue/components/shell/marquee.ce.js +92 -0
  130. package/dist/vue/components/shell/masonry.ce.js +50 -0
  131. package/dist/vue/components/shell/sidebar.ce.js +125 -0
  132. package/dist/vue/components/utility/affix.ce.js +64 -0
  133. package/dist/vue/components/utility/alert-dialog.ce.js +124 -0
  134. package/dist/vue/components/utility/animated-number.ce.js +66 -0
  135. package/dist/vue/components/utility/float-button.ce.js +104 -0
  136. package/dist/vue/components/utility/listbox.ce.js +81 -0
  137. package/dist/vue/components/utility/loading-bar.ce.js +85 -0
  138. package/dist/vue/components/utility/log-viewer.ce.js +124 -0
  139. package/dist/vue/components/utility/notification-queue.ce.js +109 -0
  140. package/dist/vue/components/utility/progress-group.ce.js +59 -0
  141. package/dist/vue/components/utility/qr-code.ce.js +62 -0
  142. package/dist/vue/components/utility/tag-group.ce.js +124 -0
  143. package/dist/vue/components/utility/tour.ce.js +214 -0
  144. package/dist/vue/components/utility/virtual-select.ce.js +207 -0
  145. package/dist/vue/components/utility/watermark.ce.js +44 -0
  146. package/dist/vue/internal/menu-items.js +184 -0
  147. package/dist/vue/internal/navigation-items.js +110 -0
  148. package/dist/vue/utils/code-highlight.js +142 -0
  149. package/dist/vue/utils/config.js +47 -0
  150. package/dist/vue/utils/content-motion.js +37 -0
  151. package/dist/vue/utils/content.js +83 -0
  152. package/dist/vue/utils/display-status.js +31 -0
  153. package/dist/vue/utils/foundation.js +65 -0
  154. package/dist/vue/utils/input-state.js +38 -0
  155. package/dist/vue/utils/interaction.js +103 -0
  156. package/dist/vue/utils/local-date.js +48 -0
  157. package/dist/vue/utils/motion.js +80 -0
  158. package/dist/vue/utils/native-slots.js +30 -0
  159. package/dist/vue/utils/navigation.js +44 -0
  160. package/dist/vue/utils/notifications.js +60 -0
  161. package/dist/vue/utils/qr.js +20 -0
  162. package/dist/vue/utils/remote-options.js +65 -0
  163. package/dist/vue/utils/ripple.js +20 -0
  164. package/dist/vue/utils/scoped-slots.js +22 -0
  165. package/dist/vue/utils/shell.js +43 -0
  166. package/dist/vue/utils/theme.js +50 -0
  167. package/dist/vue/utils/utility-choice.js +56 -0
  168. package/package.json +99 -4
@@ -0,0 +1,109 @@
1
+ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import { presenceTransition as t } from "../../utils/motion.js";
3
+ import n from "../core/notification.ce.js";
4
+ import { createNotifications as r } from "../../utils/notifications.js";
5
+ /* empty css */
6
+ import { Fragment as i, TransitionGroup as a, computed as o, createElementBlock as s, createVNode as c, getCurrentInstance as l, mergeProps as u, onBeforeUnmount as d, openBlock as f, ref as p, renderList as m, unref as h, useAttrs as g, useHost as _, watch as v, withCtx as y } from "vue";
7
+ var b = /*#__PURE__*/ e(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
8
+ __name: "notification-queue.ce",
9
+ props: {
10
+ items: {
11
+ type: Array,
12
+ default: () => []
13
+ },
14
+ service: {
15
+ type: Object,
16
+ default: null
17
+ },
18
+ capacity: {
19
+ type: Number,
20
+ default: 3
21
+ },
22
+ dedupeKey: {
23
+ type: String,
24
+ default: "id"
25
+ },
26
+ position: {
27
+ type: String,
28
+ default: "top-right"
29
+ }
30
+ },
31
+ emits: [
32
+ "update:items",
33
+ "dismiss",
34
+ "close"
35
+ ],
36
+ setup(e, { expose: b, emit: x }) {
37
+ let S = e, C = x, w = g(), T = l()?.ce ? _() : null, E = p([]), D = r({ capacity: S.capacity }), O = p(!1);
38
+ function k() {
39
+ return S.service ? S.service : (O.value || (O.value = !0, N?.(), N = D.subscribe((e) => {
40
+ E.value = M(e);
41
+ })), D);
42
+ }
43
+ b({
44
+ push: (e) => k().push(e),
45
+ update: (e, t) => k().update(e, t),
46
+ dismiss: (e) => k().dismiss(e),
47
+ clear: () => k().clear()
48
+ });
49
+ let A = o(() => T ? {
50
+ ...w,
51
+ id: void 0
52
+ } : w);
53
+ function j(e, t) {
54
+ return e?.[S.dedupeKey] ?? e?.id ?? e?.key ?? t;
55
+ }
56
+ function M(e) {
57
+ let t = Math.max(0, Math.floor(Number(S.capacity) || 0));
58
+ if (!t) return [];
59
+ let n = /* @__PURE__ */ new Set();
60
+ return e.filter((e, t) => {
61
+ let r = j(e, t);
62
+ return !n.has(r) && (n.add(r), e && e.open !== !1);
63
+ }).slice(-t);
64
+ }
65
+ let N;
66
+ v(() => S.service, (e) => {
67
+ N?.();
68
+ let t = e || (O.value ? D : null);
69
+ N = t?.subscribe?.((e) => {
70
+ E.value = M(e);
71
+ }), t || (E.value = M(S.items));
72
+ }, { immediate: !0 }), v(() => [S.items, S.capacity], () => {
73
+ D.setCapacity(S.capacity), E.value = M(S.service?.snapshot?.() || (O.value ? D.snapshot() : S.items));
74
+ }, {
75
+ immediate: !0,
76
+ deep: !0
77
+ }), d(() => N?.());
78
+ let P = o(() => E.value);
79
+ function F(e, t = "close") {
80
+ let n = j(e, 0);
81
+ (S.service || (O.value ? D : null))?.dismiss?.(e.id);
82
+ let r = E.value.filter((e, t) => j(e, t) !== n);
83
+ E.value = r, C("update:items", r), C("dismiss", e, t), C("close", e, t);
84
+ }
85
+ function I(e) {
86
+ let { id: t, key: n, open: r, ...i } = e || {};
87
+ return {
88
+ ...i,
89
+ position: S.position,
90
+ open: !0
91
+ };
92
+ }
93
+ return (r, o) => (f(), s("div", u(A.value, {
94
+ class: ["kima-notification-queue", `kima-notification-queue--${e.position}`],
95
+ "aria-live": "polite"
96
+ }), [c(a, u({
97
+ name: "kima-popup",
98
+ tag: "div",
99
+ class: "kima-notification-queue__stack"
100
+ }, h(t)), {
101
+ default: y(() => [(f(!0), s(i, null, m(P.value, (e, t) => (f(), s("div", {
102
+ key: j(e, t),
103
+ class: "kima-notification-queue__item"
104
+ }, [c(n, u({ ref_for: !0 }, I(e), { onClose: (t) => F(e, t) }), null, 16, ["onClose"])]))), 128))]),
105
+ _: 1
106
+ }, 16)], 16));
107
+ }
108
+ }), [["__scopeId", "data-v-577f9716"]]);
109
+ export { b as default };
@@ -0,0 +1,59 @@
1
+ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import { presenceTransition as t } from "../../utils/motion.js";
3
+ import { useInteractionRoot as n } from "../../utils/interaction.js";
4
+ import r from "../core/progress.ce.js";
5
+ /* empty css */
6
+ import { Fragment as i, TransitionGroup as a, computed as o, createElementBlock as s, createElementVNode as c, createVNode as l, mergeProps as u, openBlock as d, renderList as f, toDisplayString as p, unref as m, watch as h, withCtx as g } from "vue";
7
+ // src/components/utility/progress-group.ce.vue
8
+ var _ = ["aria-label"], v = /*#__PURE__*/ e(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
9
+ __name: "progress-group.ce",
10
+ props: {
11
+ tasks: {
12
+ type: Array,
13
+ default: () => []
14
+ },
15
+ label: {
16
+ type: String,
17
+ default: "任务总进度"
18
+ }
19
+ },
20
+ emits: ["change"],
21
+ setup(e, { expose: v, emit: y }) {
22
+ let b = e, x = y, { root: S, forwardedAttrs: C } = n(), w = o(() => b.tasks.map((e, t) => {
23
+ let n = Number(e.max ?? 100), r = Number(e.value) || 0, i = Number(e.weight ?? 1);
24
+ return {
25
+ ...e,
26
+ id: e.id ?? t,
27
+ weight: Number.isFinite(i) ? Math.max(0, i) : 0,
28
+ percent: n > 0 ? Math.min(100, Math.max(0, r / n * 100)) : 0
29
+ };
30
+ })), T = o(() => {
31
+ let e = w.value.reduce((e, t) => e + t.weight, 0);
32
+ return e ? w.value.reduce((e, t) => e + t.percent * t.weight, 0) / e : 0;
33
+ });
34
+ return h(T, (e) => x("change", e)), v({ aggregate: T }), (n, o) => (d(), s("section", u({
35
+ ref_key: "root",
36
+ ref: S
37
+ }, m(C), {
38
+ class: "kima-progress-group",
39
+ "aria-label": e.label
40
+ }), [
41
+ l(r, {
42
+ value: T.value,
43
+ label: e.label
44
+ }, null, 8, ["value", "label"]),
45
+ c("p", null, p(e.label) + " · " + p(Math.round(T.value)) + "%", 1),
46
+ l(a, u({
47
+ tag: "ul",
48
+ name: "kima-list"
49
+ }, m(t)), {
50
+ default: g(() => [(d(!0), s(i, null, f(w.value, (e) => (d(), s("li", { key: e.id }, [c("span", null, p(e.label), 1), l(r, {
51
+ value: e.percent,
52
+ label: e.label || "任务"
53
+ }, null, 8, ["value", "label"])]))), 128))]),
54
+ _: 1
55
+ }, 16)
56
+ ], 16, _));
57
+ }
58
+ }), [["__scopeId", "data-v-681cf67d"]]);
59
+ export { v as default };
@@ -0,0 +1,62 @@
1
+ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import { useInteractionRoot as t } from "../../utils/interaction.js";
3
+ import { encodeQR as n } from "../../utils/qr.js";
4
+ /* empty css */
5
+ import { computed as r, createElementBlock as i, createElementVNode as a, mergeProps as o, openBlock as s, toDisplayString as c, unref as l, watch as u } from "vue";
6
+ // src/components/utility/qr-code.ce.vue
7
+ var d = [
8
+ "aria-label",
9
+ "width",
10
+ "height",
11
+ "viewBox"
12
+ ], f = ["d"], p = {
13
+ key: 1,
14
+ role: "alert"
15
+ }, m = /*#__PURE__*/ e(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
16
+ __name: "qr-code.ce",
17
+ props: {
18
+ value: {
19
+ type: String,
20
+ default: ""
21
+ },
22
+ level: {
23
+ type: String,
24
+ default: "M"
25
+ },
26
+ size: {
27
+ type: Number,
28
+ default: 200
29
+ },
30
+ label: {
31
+ type: String,
32
+ default: "二维码"
33
+ }
34
+ },
35
+ emits: ["error", "change"],
36
+ setup(e, { emit: m }) {
37
+ let h = e, g = m, { root: _, forwardedAttrs: v } = t(), y = r(() => {
38
+ try {
39
+ return { qr: n(h.value, h.level) };
40
+ } catch (e) {
41
+ return { error: String(e?.message || e) };
42
+ }
43
+ });
44
+ return u(y, (e) => e.error ? g("error", e.error) : g("change", { modules: e.qr.size }), { immediate: !0 }), (t, n) => (s(), i("div", o({
45
+ ref_key: "root",
46
+ ref: _
47
+ }, l(v), { class: "kima-qr-code" }), [y.value.qr ? (s(), i("svg", {
48
+ key: 0,
49
+ role: "img",
50
+ "aria-label": e.label,
51
+ width: Math.max(40, e.size),
52
+ height: Math.max(40, e.size),
53
+ viewBox: y.value.qr.viewBox,
54
+ "shape-rendering": "crispEdges"
55
+ }, [n[0] ||= a("rect", {
56
+ width: "100%",
57
+ height: "100%",
58
+ class: "kima-qr-code__paper"
59
+ }, null, -1), a("path", { d: y.value.qr.path }, null, 8, f)], 8, d)) : (s(), i("p", p, "无法生成二维码:" + c(y.value.error), 1))], 16));
60
+ }
61
+ }), [["__scopeId", "data-v-3ef776fe"]]);
62
+ export { m as default };
@@ -0,0 +1,124 @@
1
+ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import { presenceTransition as t } from "../../utils/motion.js";
3
+ import { useInteractionModel as n, useInteractionReset as r, useInteractionRoot as i } from "../../utils/interaction.js";
4
+ import a from "../interaction/chip.ce.js";
5
+ /* empty css */
6
+ import { Fragment as o, TransitionGroup as s, computed as c, createBlock as l, createElementBlock as u, createVNode as d, mergeProps as f, nextTick as p, onMounted as m, openBlock as h, ref as g, renderList as _, unref as v, watch as y, withCtx as b } from "vue";
7
+ // src/components/utility/tag-group.ce.vue
8
+ var x = ["aria-label"], S = [
9
+ "name",
10
+ "value",
11
+ "disabled"
12
+ ], C = /*#__PURE__*/ e(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
13
+ __name: "tag-group.ce",
14
+ props: {
15
+ items: {
16
+ type: Array,
17
+ default: () => []
18
+ },
19
+ modelValue: {
20
+ type: Array,
21
+ default: () => []
22
+ },
23
+ selectable: Boolean,
24
+ removable: Boolean,
25
+ disabled: Boolean,
26
+ name: String,
27
+ label: {
28
+ type: String,
29
+ default: "标签集合"
30
+ }
31
+ },
32
+ emits: [
33
+ "update:items",
34
+ "update:modelValue",
35
+ "change",
36
+ "remove"
37
+ ],
38
+ setup(e, { emit: C }) {
39
+ let w = e, T = C, { root: E, forwardedAttrs: D } = i(), [O, k] = n(w, "items", T), [A, j] = n(w, "modelValue", T), M = g(0), N = c(() => O.value.map((e) => typeof e == "object" ? e : {
40
+ value: e,
41
+ label: String(e)
42
+ })), P = (e) => A.value.includes(e.value);
43
+ function F(e) {
44
+ w.disabled || e.disabled || (j(P(e) ? A.value.filter((t) => t !== e.value) : [...A.value, e.value]), T("change", A.value));
45
+ }
46
+ function I() {
47
+ return [...E.value?.querySelectorAll("button:not(:disabled)") || []].filter((e) => !e.closest("[inert]"));
48
+ }
49
+ async function L(e = !1) {
50
+ await p();
51
+ let t = I();
52
+ M.value = Math.max(0, Math.min(M.value, t.length - 1)), t.forEach((e, t) => {
53
+ e.tabIndex = t === M.value ? 0 : -1;
54
+ }), e && t[M.value]?.focus();
55
+ }
56
+ function R(e) {
57
+ w.disabled || e.disabled || (k(O.value.filter((t) => (typeof t == "object" ? t.value : t) !== e.value)), j(A.value.filter((t) => t !== e.value)), T("remove", e), L(!0));
58
+ }
59
+ function z(e) {
60
+ let t = I(), n = t.indexOf(e.target);
61
+ if (!(n < 0) && ([
62
+ "ArrowRight",
63
+ "ArrowLeft",
64
+ "Home",
65
+ "End"
66
+ ].includes(e.key) && (e.preventDefault(), M.value = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : (n + (e.key === "ArrowLeft" ? -1 : 1) + t.length) % t.length, L(!0)), ["Delete", "Backspace"].includes(e.key) && w.removable)) {
67
+ let t = e.target.closest("[data-tag-index]")?.dataset.tagIndex;
68
+ t != null && (e.preventDefault(), R(N.value[Number(t)]));
69
+ }
70
+ }
71
+ return y([
72
+ N,
73
+ () => w.disabled,
74
+ () => w.selectable,
75
+ () => w.removable
76
+ ], () => L(), {
77
+ immediate: !0,
78
+ flush: "post"
79
+ }), m(() => L()), r(E, A, j), r(E, O, k), (n, r) => (h(), u("div", f({
80
+ ref_key: "root",
81
+ ref: E
82
+ }, v(D), {
83
+ class: "kima-tag-group",
84
+ role: "group",
85
+ "aria-label": e.label,
86
+ onKeydown: z
87
+ }), [d(s, f({
88
+ name: "kima-list",
89
+ tag: "div",
90
+ class: "kima-tag-group__items"
91
+ }, v(t)), {
92
+ default: b(() => [(h(!0), u(o, null, _(N.value, (t, n) => (h(), l(a, {
93
+ key: t.value,
94
+ "data-tag-index": n,
95
+ label: t.label,
96
+ value: t.value,
97
+ selectable: e.selectable,
98
+ removable: e.removable,
99
+ disabled: e.disabled || t.disabled,
100
+ "model-value": P(t),
101
+ onChange: (e) => F(t),
102
+ onRemove: (e) => R(t)
103
+ }, null, 8, [
104
+ "data-tag-index",
105
+ "label",
106
+ "value",
107
+ "selectable",
108
+ "removable",
109
+ "disabled",
110
+ "model-value",
111
+ "onChange",
112
+ "onRemove"
113
+ ]))), 128))]),
114
+ _: 1
115
+ }, 16), (h(!0), u(o, null, _(v(A), (t) => (h(), u("input", {
116
+ key: t,
117
+ type: "hidden",
118
+ name: e.name,
119
+ value: t,
120
+ disabled: e.disabled
121
+ }, null, 8, S))), 128))], 16, x));
122
+ }
123
+ }), [["__scopeId", "data-v-3d44ac1c"]]);
124
+ export { C as default };
@@ -0,0 +1,214 @@
1
+ import e from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import t from "../core/button.ce.js";
3
+ import { prefersReducedMotion as n } from "../../utils/motion.js";
4
+ import { useInteractionModel as r, useInteractionRoot as ee } from "../../utils/interaction.js";
5
+ /* empty css */
6
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, mergeProps as f, nextTick as p, normalizeStyle as m, onBeforeUnmount as te, onMounted as ne, openBlock as h, ref as g, renderList as _, toDisplayString as v, unref as y, watch as b, withCtx as x, withModifiers as S } from "vue";
7
+ // src/components/utility/tour.ce.vue
8
+ var C = ["aria-label"], w = {
9
+ key: 0,
10
+ role: "status"
11
+ }, T = { class: "kima-tour__actions" }, E = /*#__PURE__*/ e(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
12
+ __name: "tour.ce",
13
+ props: {
14
+ open: Boolean,
15
+ steps: {
16
+ type: Array,
17
+ default: () => []
18
+ },
19
+ modelValue: {
20
+ type: Number,
21
+ default: 0
22
+ },
23
+ label: {
24
+ type: String,
25
+ default: "功能导览"
26
+ }
27
+ },
28
+ emits: [
29
+ "update:open",
30
+ "update:modelValue",
31
+ "step",
32
+ "target-missing",
33
+ "finish",
34
+ "close"
35
+ ],
36
+ setup(e, { emit: E }) {
37
+ let D = e, O = E, { root: k, forwardedAttrs: A } = ee(), [j, M] = r(D, "open", O), [N, P] = r(D, "modelValue", O), F = g(null), I = g(null), L = g(!1), R = g({
38
+ width: 1024,
39
+ height: 768
40
+ }), z = a(() => D.steps[N.value] || {}), B, V, H, U = !1, W, G;
41
+ function K() {
42
+ try {
43
+ let e = z.value.target, t = typeof e == "string" ? k.value.ownerDocument.querySelector(e) : e;
44
+ return t?.isConnected && t.getClientRects().length ? t : null;
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+ function q() {
50
+ if (!j.value || !k.value) return;
51
+ R.value = {
52
+ width: innerWidth,
53
+ height: innerHeight
54
+ };
55
+ let e = K();
56
+ if (L.value = !e, !e) {
57
+ I.value = null, G !== N.value && (G = N.value, O("target-missing", N.value, z.value.target));
58
+ return;
59
+ }
60
+ G = void 0;
61
+ let t = e.getBoundingClientRect();
62
+ I.value = {
63
+ left: Math.max(0, t.left - 6),
64
+ top: Math.max(0, t.top - 6),
65
+ right: Math.min(innerWidth, t.right + 6),
66
+ bottom: Math.min(innerHeight, t.bottom + 6)
67
+ };
68
+ }
69
+ function J() {
70
+ cancelAnimationFrame(H), H = requestAnimationFrame(q);
71
+ }
72
+ async function Y(e = !0) {
73
+ if (!U || !j.value) return;
74
+ let t = K();
75
+ e && t && t !== W && t.scrollIntoView({
76
+ block: "center",
77
+ inline: "nearest",
78
+ behavior: n(k.value) ? "instant" : "smooth"
79
+ }), W = t, q(), O("step", N.value), await p(), F.value?.querySelector("[data-tour-primary]")?.focus();
80
+ }
81
+ function X(e = "close") {
82
+ j.value && (M(!1), O("close", e));
83
+ }
84
+ function Z() {
85
+ N.value >= D.steps.length - 1 ? (O("finish"), X("finish")) : P(N.value + 1);
86
+ }
87
+ function Q() {
88
+ N.value > 0 && P(N.value - 1);
89
+ }
90
+ function re(e) {
91
+ if (e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), X("escape")), e.key === "ArrowRight" && (e.preventDefault(), Z()), e.key === "ArrowLeft" && (e.preventDefault(), Q()), e.key === "Tab") {
92
+ let t = [...F.value.querySelectorAll("button:not(:disabled)")], n = t.indexOf(document.activeElement);
93
+ e.shiftKey && n <= 0 ? (e.preventDefault(), t.at(-1)?.focus()) : !e.shiftKey && n === t.length - 1 && (e.preventDefault(), t[0]?.focus());
94
+ }
95
+ }
96
+ let ie = a(() => {
97
+ let e = Math.min(360, R.value.width - 32), t = I.value ? Math.min(Math.max(16, I.value.left), R.value.width - e - 16) : (R.value.width - e) / 2, n = I.value ? I.value.bottom + 16 : R.value.height / 2 - 100;
98
+ return {
99
+ width: `${e}px`,
100
+ left: `${t}px`,
101
+ top: `${Math.max(16, Math.min(n, R.value.height - 280))}px`
102
+ };
103
+ }), ae = a(() => {
104
+ let e = I.value, t = R.value;
105
+ return e ? [
106
+ {
107
+ left: 0,
108
+ top: 0,
109
+ width: t.width,
110
+ height: e.top
111
+ },
112
+ {
113
+ left: 0,
114
+ top: e.bottom,
115
+ width: t.width,
116
+ height: Math.max(0, t.height - e.bottom)
117
+ },
118
+ {
119
+ left: 0,
120
+ top: e.top,
121
+ width: e.left,
122
+ height: Math.max(0, e.bottom - e.top)
123
+ },
124
+ {
125
+ left: e.right,
126
+ top: e.top,
127
+ width: Math.max(0, t.width - e.right),
128
+ height: Math.max(0, e.bottom - e.top)
129
+ }
130
+ ] : [{
131
+ left: 0,
132
+ top: 0,
133
+ width: t.width,
134
+ height: t.height
135
+ }];
136
+ });
137
+ async function $() {
138
+ U && (j.value ? (F.value.open || (B = document.activeElement, F.value.showModal()), await Y()) : (F.value.open && F.value.close(), B?.isConnected && B.focus({ preventScroll: !0 }), B = null, W = null));
139
+ }
140
+ return b(j, $, { flush: "post" }), b([N, () => D.steps], () => Y(), {
141
+ deep: !0,
142
+ flush: "post"
143
+ }), ne(() => {
144
+ U = !0, document.addEventListener("scroll", J, !0), window.addEventListener("resize", J), V = new MutationObserver(J), V.observe(document.body, {
145
+ childList: !0,
146
+ subtree: !0
147
+ }), $();
148
+ }), te(() => {
149
+ U = !1, V?.disconnect(), cancelAnimationFrame(H), document.removeEventListener("scroll", J, !0), window.removeEventListener("resize", J), F.value?.open && F.value.close(), B?.isConnected && B.focus({ preventScroll: !0 });
150
+ }), (n, r) => (h(), c("div", f({
151
+ ref_key: "root",
152
+ ref: k
153
+ }, y(A), { class: "kima-tour" }), [l("dialog", {
154
+ ref_key: "dialog",
155
+ ref: F,
156
+ class: "kima-tour__dialog",
157
+ "aria-label": e.label,
158
+ onKeydown: re,
159
+ onCancel: r[1] ||= S((e) => X("escape"), ["prevent", "stop"])
160
+ }, [
161
+ (h(!0), c(i, null, _(ae.value, (e, t) => (h(), c("div", {
162
+ key: t,
163
+ class: "kima-tour__mask",
164
+ style: m(Object.fromEntries(Object.entries(e).map(([e, t]) => [e, `${t}px`]))),
165
+ "aria-hidden": "true"
166
+ }, null, 4))), 128)),
167
+ I.value ? (h(), c("div", {
168
+ key: 0,
169
+ class: "kima-tour__spotlight",
170
+ style: m({
171
+ left: `${I.value.left}px`,
172
+ top: `${I.value.top}px`,
173
+ width: `${Math.max(0, I.value.right - I.value.left)}px`,
174
+ height: `${Math.max(0, I.value.bottom - I.value.top)}px`
175
+ }),
176
+ "aria-hidden": "true"
177
+ }, null, 4)) : s("", !0),
178
+ l("section", {
179
+ class: "kima-tour__panel",
180
+ style: m(ie.value)
181
+ }, [
182
+ l("p", null, v(y(N) + 1) + " / " + v(e.steps.length), 1),
183
+ l("h2", null, v(z.value.title || e.label), 1),
184
+ l("p", null, v(z.value.description), 1),
185
+ L.value ? (h(), c("p", w, "未找到目标,可继续下一步或退出。")) : s("", !0),
186
+ l("div", T, [
187
+ d(t, {
188
+ variant: "text",
189
+ onClick: r[0] ||= (e) => X("button")
190
+ }, {
191
+ default: x(() => [...r[2] ||= [u("退出", -1)]]),
192
+ _: 1
193
+ }),
194
+ y(N) > 0 ? (h(), o(t, {
195
+ key: 0,
196
+ variant: "tonal",
197
+ onClick: Q
198
+ }, {
199
+ default: x(() => [...r[3] ||= [u("上一步", -1)]]),
200
+ _: 1
201
+ })) : s("", !0),
202
+ d(t, {
203
+ "data-tour-primary": "",
204
+ onClick: Z
205
+ }, {
206
+ default: x(() => [u(v(y(N) >= e.steps.length - 1 ? "完成" : "下一步"), 1)]),
207
+ _: 1
208
+ })
209
+ ])
210
+ ], 4)
211
+ ], 40, C)], 16));
212
+ }
213
+ }), [["__scopeId", "data-v-b5823fc3"]]);
214
+ export { E as default };