x-next 1.9.0 → 1.10.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 (33) hide show
  1. package/AI_USAGE.md +67 -7
  2. package/CHANGELOG.md +24 -0
  3. package/dist/_utils/chart/scale.d.ts +1 -1
  4. package/dist/components/_components/chart/axis-labels.d.ts +8 -0
  5. package/dist/components/link/Link.vue.d.ts +1 -1
  6. package/dist/components/link/index.d.ts +3 -3
  7. package/dist/components/virtual-list-v2/interface.d.ts +3 -0
  8. package/dist/components/virtual-list-v2/virtual-list.vue.d.ts +336 -1
  9. package/dist/es/_hooks/use-component-ref.js +9 -9
  10. package/dist/es/_utils/chart/scale.js +44 -39
  11. package/dist/es/components/_components/chart/ChartAxis.js +61 -36
  12. package/dist/es/components/_components/chart/axis-labels.js +26 -0
  13. package/dist/es/components/button/Button.js +23 -23
  14. package/dist/es/components/form-select/Select.js +142 -141
  15. package/dist/es/components/trigger/Trigger.js +174 -183
  16. package/dist/es/components/virtual-list-v2/virtual-list.vue.js +22 -23
  17. package/dist/es/components/virtual-list-v2/virtual-list.vue2.js +67 -53
  18. package/dist/es/icons/icon.js +37 -36
  19. package/dist/es/icons/index.js +6 -8
  20. package/dist/es/icons/public/lucide-names.js +167 -0
  21. package/dist/es/icons/public/lucide.js +75 -188
  22. package/dist/es/index.js +152 -148
  23. package/dist/es/style.css +1 -1
  24. package/dist/icons/index.d.ts +3 -3
  25. package/dist/icons/names.d.ts +2 -2
  26. package/dist/icons/public/lucide-names.d.ts +32 -0
  27. package/dist/icons/public/lucide.d.ts +2 -2
  28. package/dist/index.cjs +3 -62
  29. package/dist/index.umd.js +3 -62
  30. package/dist/style/base.css +1 -1
  31. package/dist/style/button.css +1 -1
  32. package/dist/style.css +1 -1
  33. package/package.json +3 -2
@@ -1,77 +1,82 @@
1
- const h = (t) => Number(t.toPrecision(12)), g = (t) => Number(t.toFixed(4)), f = (t) => Math.max(2, Math.floor(t)), p = (t) => {
1
+ const a = (t) => Number(t.toPrecision(12)), g = (t) => Number(t.toFixed(4)), f = (t) => Math.max(2, Math.floor(t)), F = (t) => {
2
2
  if (!Number.isFinite(t) || t <= 0) return 0;
3
- const e = 10 ** Math.floor(Math.log10(t)), i = t / e;
4
- return e * (i <= 1 ? 1 : i <= 2 ? 2 : i <= 5 ? 5 : 10);
5
- }, x = (t, e = 4) => {
3
+ const n = 10 ** Math.floor(Math.log10(t)), e = t / n;
4
+ return n * (e <= 1 ? 1 : e <= 2 ? 2 : e <= 5 ? 5 : 10);
5
+ }, x = (t, n = 4) => {
6
6
  if (!Number.isFinite(t) || t <= 0)
7
7
  return { max: 0, ticks: [0] };
8
- const i = f(e) - 1, s = p(t / i), r = h(Math.ceil(t / s) * s), n = Math.round(r / s);
8
+ const e = f(n) - 1, s = F(t / e), r = a(Math.ceil(t / s) * s), i = Math.round(r / s);
9
9
  return {
10
10
  max: r,
11
- ticks: Array.from({ length: n + 1 }, (o, c) => h(s * c))
11
+ ticks: Array.from({ length: i + 1 }, (o, c) => a(s * c))
12
12
  };
13
- }, M = (t, e = 4, i) => {
14
- const s = f(e);
15
- if (Number.isFinite(i) && i > 0) {
16
- const r = i, n = s - 1;
13
+ }, d = (t, n = 4, e) => {
14
+ const s = f(n);
15
+ if (Number.isFinite(e) && e > 0) {
16
+ const r = e, i = s - 1;
17
17
  return {
18
18
  max: r,
19
19
  ticks: Array.from(
20
- { length: n + 1 },
21
- (o, c) => g(r / n * c)
20
+ { length: i + 1 },
21
+ (o, c) => g(r / i * c)
22
22
  )
23
23
  };
24
24
  }
25
25
  return x(t, s);
26
- }, d = (t, e, i = 4) => {
27
- const s = Number.isFinite(t) ? t : 0, r = Number.isFinite(e) ? e : 0, n = Math.min(0, s), o = Math.max(0, r);
28
- if (n === 0 && o === 0)
26
+ }, M = (t, n, e = 4) => {
27
+ const s = Number.isFinite(t) ? t : 0, r = Number.isFinite(n) ? n : 0, i = Math.min(0, s), o = Math.max(0, r);
28
+ if (i === 0 && o === 0)
29
29
  return { min: 0, max: 0, ticks: [0] };
30
- const c = f(i) - 1, u = p((o - n) / c), l = h(Math.floor(n / u) * u), m = h(Math.ceil(o / u) * u), a = Math.round((m - l) / u);
30
+ const c = f(e) - 1, u = F((o - i) / c), h = a(Math.floor(i / u) * u), m = a(Math.ceil(o / u) * u), l = Math.round((m - h) / u);
31
31
  return {
32
- min: l,
32
+ min: h,
33
33
  max: m,
34
- ticks: Array.from({ length: a + 1 }, (N, b) => h(l + u * b))
34
+ ticks: Array.from({ length: l + 1 }, (N, b) => a(h + u * b))
35
35
  };
36
- }, A = (t, e, i = 4, s, r) => {
37
- const n = f(i), o = Number.isFinite(s), c = Number.isFinite(r);
36
+ }, A = (t, n, e = 4, s, r) => {
37
+ const i = f(e), o = Number.isFinite(s), c = Number.isFinite(r);
38
38
  if (!o && !c)
39
- return d(t, e, n);
40
- const u = Math.min(0, Number.isFinite(t) ? t : 0), l = Math.max(0, Number.isFinite(e) ? e : 0);
41
- let m = o ? s : u, a = c ? r : l;
42
- m > a && ([m, a] = [a, m]);
43
- const N = n - 1;
39
+ return M(t, n, i);
40
+ const u = Math.min(0, Number.isFinite(t) ? t : 0), h = Math.max(0, Number.isFinite(n) ? n : 0);
41
+ let m = o ? s : u, l = c ? r : h;
42
+ m > l && ([m, l] = [l, m]);
43
+ const N = i - 1;
44
44
  return {
45
45
  min: m,
46
- max: a,
46
+ max: l,
47
47
  ticks: Array.from(
48
48
  { length: N + 1 },
49
- (b, F) => g(m + (a - m) / N * F)
49
+ (b, p) => g(m + (l - m) / N * p)
50
50
  )
51
51
  };
52
52
  }, k = (t) => {
53
53
  if (!Number.isFinite(t)) return "";
54
- const e = Number(Number(t.toPrecision(12)).toFixed(4)), [i, s] = String(Math.abs(e)).split("."), r = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
55
- return `${e < 0 ? "-" : ""}${r}${s ? `.${s}` : ""}`;
56
- }, y = (t, e) => {
57
- let i = 0;
54
+ const n = Number(Number(t.toPrecision(12)).toFixed(4)), [e, s] = String(Math.abs(n)).split("."), r = e.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
55
+ return `${n < 0 ? "-" : ""}${r}${s ? `.${s}` : ""}`;
56
+ }, y = (t, n) => {
57
+ let e = 0;
58
58
  for (const s of t)
59
- i += s.charCodeAt(0) > 255 ? 1 : 0.6;
60
- return i * e;
61
- }, S = (t, e, i, s = 8) => {
59
+ e += s.charCodeAt(0) > 255 ? 1 : 0.6;
60
+ return e * n;
61
+ }, S = (t, n, e, s = 8) => {
62
62
  if (t <= 0) return [];
63
- const r = Math.max(1, Math.ceil((i + s) / Math.max(e, 1))), n = [];
63
+ const r = Math.max(1, Math.ceil((e + s) / Math.max(n, 1))), i = [];
64
64
  for (let c = 0; c < t; c += r)
65
- n.push(c);
65
+ i.push(c);
66
66
  const o = t - 1;
67
- return n[n.length - 1] !== o && (n.length > 1 && o - n[n.length - 1] < r * 0.6 && n.pop(), n.push(o)), n;
67
+ if (i[i.length - 1] !== o) {
68
+ for (; i.length && (o - i[i.length - 1]) * n < e + s; )
69
+ i.pop();
70
+ i.push(o);
71
+ }
72
+ return i;
68
73
  };
69
74
  export {
70
75
  k as defaultValueFormatter,
71
76
  y as estimateTextWidth,
72
77
  A as getDomain,
73
- d as getNiceDomain,
78
+ M as getNiceDomain,
74
79
  x as getNiceScale,
75
- M as getScale,
80
+ d as getScale,
76
81
  S as pickLabelIndices
77
82
  };
@@ -1,6 +1,8 @@
1
- import { defineComponent as s, createVNode as a } from "vue";
2
- import { getClassNameMixin as i } from "../../../_utils/config.js";
3
- const y = 6, x = 8, c = /* @__PURE__ */ s({
1
+ import { defineComponent as x, ref as u, computed as h, onMounted as b, watchPostEffect as g, onBeforeUnmount as L, createVNode as n } from "vue";
2
+ import { getClassNameMixin as S } from "../../../_utils/config.js";
3
+ import { layoutAxisLabels as v } from "./axis-labels.js";
4
+ import { estimateTextWidth as z } from "../../../_utils/chart/scale.js";
5
+ const A = 6, w = 8, N = /* @__PURE__ */ x({
4
6
  name: "ChartAxis",
5
7
  props: {
6
8
  plot: {
@@ -36,44 +38,67 @@ const y = 6, x = 8, c = /* @__PURE__ */ s({
36
38
  default: !0
37
39
  }
38
40
  },
39
- setup(e) {
40
- const l = i("chart"), o = () => ({
41
- fontSize: `${e.fontSize}px`,
42
- fill: e.color
43
- });
44
- return () => a("g", null, [e.showHorizontalLines && a("g", {
45
- class: l.element("grid")
46
- }, [e.ticks.map((t, n) => a("line", {
47
- key: n,
48
- class: [l.element("grid-line"), {
49
- [l.is("baseline")]: t.isBaseline
41
+ setup(t) {
42
+ const o = S("chart"), f = () => ({
43
+ fontSize: `${t.fontSize}px`,
44
+ fill: t.color
45
+ }), s = u(), d = u(), m = (e) => v(t.xLabels, t.plot.left, t.plot.right, t.fontSize * 0.6, e), y = h(() => d.value ?? m((e) => z(e, t.fontSize)));
46
+ let i = null, c = !0;
47
+ const a = () => {
48
+ if (!c || !s.value) return;
49
+ const e = getComputedStyle(s.value);
50
+ if (i) {
51
+ i.font = `${e.fontStyle} ${e.fontWeight} ${t.fontSize}px ${e.fontFamily}`;
52
+ const l = Number.parseFloat(e.letterSpacing) || 0;
53
+ d.value = m((r) => i.measureText(r).width + Math.max(0, Array.from(r).length - 1) * l);
54
+ }
55
+ };
56
+ return b(() => {
57
+ var e, l;
58
+ i = document.createElement("canvas").getContext("2d"), a(), (e = document.fonts) == null || e.addEventListener("loadingdone", a), (l = document.fonts) == null || l.ready.then(a);
59
+ }), g(() => {
60
+ t.xLabels, t.plot, t.fontSize, a();
61
+ }), L(() => {
62
+ var e;
63
+ c = !1, (e = document.fonts) == null || e.removeEventListener("loadingdone", a);
64
+ }), () => n("g", {
65
+ ref: s,
66
+ style: {
67
+ fontSize: `${t.fontSize}px`
68
+ }
69
+ }, [t.showHorizontalLines && n("g", {
70
+ class: o.element("grid")
71
+ }, [t.ticks.map((e, l) => n("line", {
72
+ key: l,
73
+ class: [o.element("grid-line"), {
74
+ [o.is("baseline")]: e.isBaseline
50
75
  }],
51
- x1: e.plot.left,
52
- x2: e.plot.left + e.plot.width,
53
- y1: t.y,
54
- y2: t.y
55
- }, null))]), e.showY && a("g", {
56
- class: l.element("y-labels")
57
- }, [e.ticks.map((t, n) => a("text", {
58
- key: n,
59
- class: l.element("axis-label"),
60
- x: e.plot.left - y,
61
- y: t.y,
76
+ x1: t.plot.left,
77
+ x2: t.plot.left + t.plot.width,
78
+ y1: e.y,
79
+ y2: e.y
80
+ }, null))]), t.showY && n("g", {
81
+ class: o.element("y-labels")
82
+ }, [t.ticks.map((e, l) => n("text", {
83
+ key: l,
84
+ class: o.element("axis-label"),
85
+ x: t.plot.left - A,
86
+ y: e.y,
62
87
  "text-anchor": "end",
63
88
  "dominant-baseline": "middle",
64
- style: o()
65
- }, [t.label]))]), e.showX && a("g", {
66
- class: l.element("x-labels")
67
- }, [e.xLabels.map((t, n) => a("text", {
68
- key: n,
69
- class: l.element("axis-label"),
70
- x: t.x,
71
- y: e.plot.bottom + x + e.fontSize * 0.9,
89
+ style: f()
90
+ }, [e.label]))]), t.showX && n("g", {
91
+ class: o.element("x-labels")
92
+ }, [y.value.map((e, l) => n("text", {
93
+ key: l,
94
+ class: o.element("axis-label"),
95
+ x: e.x,
96
+ y: t.plot.bottom + w + t.fontSize * 0.9,
72
97
  "text-anchor": "middle",
73
- style: o()
74
- }, [t.text]))])]);
98
+ style: f()
99
+ }, [e.text, e.title && n("title", null, [e.title])]))])]);
75
100
  }
76
101
  });
77
102
  export {
78
- c as default
103
+ N as default
79
104
  };
@@ -0,0 +1,26 @@
1
+ const M = (h, f, d, u, i) => {
2
+ const n = Math.max(0, d - f);
3
+ if (n <= 0) return [];
4
+ const m = [];
5
+ let I = Number.POSITIVE_INFINITY;
6
+ for (let c = h.length - 1; c >= 0; c--) {
7
+ const l = h[c];
8
+ let e = l.text, t = i(e);
9
+ if (t > n) {
10
+ if (i("…") > n) continue;
11
+ const a = Array.from(e);
12
+ let o = 0, s = a.length;
13
+ for (; o < s; ) {
14
+ const r = Math.ceil((o + s) / 2);
15
+ i(`${a.slice(0, r).join("")}…`) <= n ? o = r : s = r - 1;
16
+ }
17
+ e = `${a.slice(0, o).join("")}…`, t = i(e);
18
+ }
19
+ const x = Math.max(f + t / 2, Math.min(l.x, d - t / 2));
20
+ x + t / 2 + u > I || (m.push({ x, text: e, width: t, ...e !== l.text ? { title: l.text } : {} }), I = x - t / 2);
21
+ }
22
+ return m.reverse();
23
+ };
24
+ export {
25
+ M as layoutAxisLabels
26
+ };
@@ -1,5 +1,5 @@
1
- import { defineComponent as O, getCurrentInstance as P, inject as p, reactive as x, computed as c, withDirectives as T, createVNode as o, resolveDirective as F } from "vue";
2
- import { getClassNameMixin as L } from "../../_utils/config.js";
1
+ import { defineComponent as O, getCurrentInstance as P, inject as x, reactive as F, computed as t, withDirectives as T, createVNode as u, resolveDirective as L } from "vue";
2
+ import { getClassNameMixin as p } from "../../_utils/config.js";
3
3
  import { buttonProps as A } from "./props.js";
4
4
  import B from "../../icons/animation/animation-loading.js";
5
5
  import I from "../../directives/wave.js";
@@ -18,51 +18,51 @@ const H = /* @__PURE__ */ O({
18
18
  slots: l,
19
19
  emit: h
20
20
  }) {
21
- const f = P(), a = p(K, void 0), {
21
+ const s = P(), a = x(K, void 0), {
22
22
  mergedSize: k
23
23
  } = N(void 0, {
24
24
  defaultValue: "medium"
25
- }), r = x({
25
+ }), r = F({
26
26
  clicked: !1,
27
27
  isDebounce: !1
28
- }), i = L("button"), w = (n) => n.replace(/[A-Z]/g, (d) => `-${d.toLowerCase()}`), u = (n) => {
29
- const d = (f == null ? void 0 : f.vnode.props) ?? {};
28
+ }), i = p("button"), w = (n) => n.replace(/[A-Z]/g, (d) => `-${d.toLowerCase()}`), o = (n) => {
29
+ const d = (s == null ? void 0 : s.vnode.props) ?? {};
30
30
  return Object.prototype.hasOwnProperty.call(d, n) || Object.prototype.hasOwnProperty.call(d, w(n));
31
- }, s = c(() => u("type") ? e.type : (a == null ? void 0 : a.type) ?? e.type), v = c(() => u("size") ? e.size : (a == null ? void 0 : a.size) ?? k.value), b = c(() => u("status") ? e.status : (a == null ? void 0 : a.status) ?? e.status), g = c(() => u("shape") ? e.shape : (a == null ? void 0 : a.shape) ?? e.shape), m = c(() => u("disabled") ? e.disabled : (a == null ? void 0 : a.disabled) ?? e.disabled), D = c(() => [i.block, s.value && s.value !== "default" && i.modifier(s.value), v.value && i.modifier(v.value), b.value && i.modifier(b.value), m.value && i.is("disabled"), e.block && i.modifier("block"), e.plain && i.modifier("plain"), g.value && i.modifier(g.value), e.link && i.modifier("link"), !e.border && i.modifier("hide-border"), t.value && i.modifier("loading"), e.loadingFill && i.modifier("loading-fill"), e.narrow && i.modifier("narrow")]), z = () => {
31
+ }, m = t(() => o("type") ? e.type : (a == null ? void 0 : a.type) ?? e.type), v = t(() => o("size") ? e.size : (a == null ? void 0 : a.size) ?? k.value), b = t(() => o("status") ? e.status : (a == null ? void 0 : a.status) ?? e.status), g = t(() => o("shape") ? e.shape : (a == null ? void 0 : a.shape) ?? e.shape), f = t(() => o("disabled") ? e.disabled : (a == null ? void 0 : a.disabled) ?? e.disabled), D = t(() => [i.block, m.value && m.value !== "default" && i.modifier(m.value), v.value && i.modifier(v.value), b.value && i.modifier(b.value), f.value && i.is("disabled"), e.block && i.modifier("block"), e.plain && i.modifier("plain"), g.value && i.modifier(g.value), e.link && i.modifier("link"), !e.border && i.modifier("hide-border"), c.value && i.modifier("loading"), e.loadingFill && i.modifier("loading-fill"), e.narrow && i.modifier("narrow")]), z = () => {
32
32
  e.debounce > 0 && !r.isDebounce && (r.isDebounce = !0, setTimeout(() => {
33
33
  r.isDebounce = !1;
34
34
  }, e.debounce));
35
- }, t = c(() => e.loading || r.clicked || r.isDebounce), S = c(() => m.value || t.value || e.link || s.value === "text"), j = (n) => {
35
+ }, c = t(() => e.loading || r.clicked || r.isDebounce), S = t(() => f.value || c.value || e.link || m.value === "text"), j = (n) => {
36
36
  var d;
37
- n.detail > 0 && ((d = n.currentTarget) == null || d.blur()), !(m.value || t.value) && (z(), h("click", n));
37
+ n.detail > 0 && ((d = n.currentTarget) == null || d.blur()), !(f.value || c.value) && (z(), h("click", n));
38
38
  };
39
39
  return () => {
40
40
  var n, d, y;
41
- return T(o("button", {
41
+ return T(u("button", {
42
42
  class: D.value,
43
43
  type: e.htmlType,
44
- disabled: m.value || t.value,
45
- "aria-busy": t.value || void 0,
44
+ disabled: f.value || c.value,
45
+ "aria-busy": c.value || void 0,
46
46
  onClick: j
47
- }, [o("span", {
47
+ }, [u("span", {
48
48
  class: i.element("loading"),
49
+ "aria-hidden": "true",
49
50
  style: {
50
51
  display: "flex",
51
- opacity: t.value ? 1 : 0,
52
- width: t.value ? "auto" : 0,
53
- marginRight: t.value && !e.loadingFill ? "4px" : "0",
54
- overflow: "hidden",
55
- transition: "all 0.3s ease"
52
+ opacity: c.value ? 1 : 0,
53
+ width: c.value ? e.loadingFill ? "100%" : "1em" : 0,
54
+ marginRight: c.value && !e.loadingFill ? "4px" : "0",
55
+ overflow: "hidden"
56
56
  }
57
- }, [o(B, null, null)]), !!l.prefix && o("span", {
57
+ }, [c.value && u(B, null, null)]), !!l.prefix && u("span", {
58
58
  class: i.element("prefix")
59
- }, [(n = l.prefix) == null ? void 0 : n.call(l)]), l.icon && o("span", {
59
+ }, [(n = l.prefix) == null ? void 0 : n.call(l)]), l.icon && u("span", {
60
60
  class: i.element("prefix")
61
- }, [(d = l.icon) == null ? void 0 : d.call(l)]), o("span", {
61
+ }, [(d = l.icon) == null ? void 0 : d.call(l)]), u("span", {
62
62
  class: i.element("content")
63
- }, [(y = l.default) == null ? void 0 : y.call(l)]), l.suffix && o("span", {
63
+ }, [(y = l.default) == null ? void 0 : y.call(l)]), l.suffix && u("span", {
64
64
  class: i.element("suffix")
65
- }, [l.suffix()])]), [[F("wave"), {
65
+ }, [l.suffix()])]), [[L("wave"), {
66
66
  disabled: S.value
67
67
  }]]);
68
68
  };