x-next 1.6.0 → 1.8.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 (166) hide show
  1. package/AI_USAGE.md +182 -4
  2. package/CHANGELOG.md +74 -0
  3. package/dist/_hooks/use-chart-size.d.ts +25 -0
  4. package/dist/_utils/chart/index.d.ts +6 -0
  5. package/dist/_utils/chart/padding.d.ts +15 -0
  6. package/dist/_utils/chart/path.d.ts +34 -0
  7. package/dist/_utils/chart/scale.d.ts +55 -0
  8. package/dist/components/_components/chart/ChartAxis.d.ts +85 -0
  9. package/dist/components/_components/chart/ChartLegend.d.ts +26 -0
  10. package/dist/components/_components/chart/ChartTooltip.d.ts +76 -0
  11. package/dist/components/_components/chart/colors.d.ts +10 -0
  12. package/dist/components/_components/chart/interface.d.ts +38 -0
  13. package/dist/components/bar-chart/BarChart.d.ts +278 -0
  14. package/dist/components/bar-chart/helpers/layout.d.ts +55 -0
  15. package/dist/components/bar-chart/index.d.ts +600 -0
  16. package/dist/components/bar-chart/interface.d.ts +74 -0
  17. package/dist/components/bar-chart/props.d.ts +145 -0
  18. package/dist/components/date-picker/DatePicker.vue.d.ts +3 -3
  19. package/dist/components/date-picker/index.d.ts +6 -6
  20. package/dist/components/draggable/Draggable.d.ts +1 -1
  21. package/dist/components/draggable/index.d.ts +2 -2
  22. package/dist/components/drawer/index.d.ts +6 -6
  23. package/dist/components/drawer/src/Drawer.vue.d.ts +3 -3
  24. package/dist/components/dropdown/Dropdown.vue.d.ts +4 -4
  25. package/dist/components/dropdown/DropdownButton.vue.d.ts +5 -5
  26. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +4 -4
  27. package/dist/components/dropdown/index.d.ts +29 -29
  28. package/dist/components/form/FormItem.vue.d.ts +12 -12
  29. package/dist/components/form/form-item-label.vue.d.ts +3 -3
  30. package/dist/components/form/index.d.ts +24 -24
  31. package/dist/components/form-select/Select.d.ts +3 -3
  32. package/dist/components/form-select/index.d.ts +6 -6
  33. package/dist/components/form-slider/Slider.vue.d.ts +3 -3
  34. package/dist/components/form-slider/index.d.ts +6 -6
  35. package/dist/components/form-slider/slider-button.vue.d.ts +3 -3
  36. package/dist/components/grid/Row.vue.d.ts +3 -3
  37. package/dist/components/grid/index.d.ts +9 -9
  38. package/dist/components/heatmap/Heatmap.d.ts +10 -0
  39. package/dist/components/heatmap/index.d.ts +30 -0
  40. package/dist/components/image/Image.vue.d.ts +125 -17
  41. package/dist/components/image/ImagePreview.vue.d.ts +97 -7
  42. package/dist/components/image/ImagePreviewAction.d.ts +3 -3
  43. package/dist/components/image/ImagePreviewGroup.vue.d.ts +100 -7
  44. package/dist/components/image/hooks/use-image-drag.d.ts +2 -2
  45. package/dist/components/image/index.d.ts +712 -124
  46. package/dist/components/image/interface.d.ts +9 -1
  47. package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
  48. package/dist/components/index.d.ts +4 -0
  49. package/dist/components/line-chart/LineChart.d.ts +295 -0
  50. package/dist/components/line-chart/helpers/layout.d.ts +74 -0
  51. package/dist/components/line-chart/index.d.ts +614 -0
  52. package/dist/components/line-chart/interface.d.ts +76 -0
  53. package/dist/components/line-chart/props.d.ts +173 -0
  54. package/dist/components/menu/sub-menu-pop.vue.d.ts +3 -3
  55. package/dist/components/pagination/page-options.vue.d.ts +6 -6
  56. package/dist/components/pie-chart/PieChart.d.ts +219 -0
  57. package/dist/components/pie-chart/index.d.ts +470 -0
  58. package/dist/components/pie-chart/interface.d.ts +58 -0
  59. package/dist/components/pie-chart/props.d.ts +107 -0
  60. package/dist/components/popconfirm/src/popup.vue.d.ts +3 -3
  61. package/dist/components/popover/Popover.d.ts +1 -1
  62. package/dist/components/popover/index.d.ts +3 -3
  63. package/dist/components/popup/Popup.d.ts +1 -1
  64. package/dist/components/popup/index.d.ts +3 -3
  65. package/dist/components/space/Space.d.ts +1 -1
  66. package/dist/components/space/index.d.ts +3 -3
  67. package/dist/components/tabs/Tabs.d.ts +1 -1
  68. package/dist/components/tabs/index.d.ts +3 -3
  69. package/dist/components/time-picker/TimePicker.vue.d.ts +3 -3
  70. package/dist/components/time-picker/index.d.ts +6 -6
  71. package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
  72. package/dist/components/tooltip/index.d.ts +3 -3
  73. package/dist/components/trend-chart/components/TrendChart.d.ts +19 -96
  74. package/dist/components/trend-chart/index.d.ts +33 -187
  75. package/dist/components/trend-chart/props.d.ts +9 -78
  76. package/dist/components/trend-chart/themes.d.ts +0 -1
  77. package/dist/components/trigger/Trigger.d.ts +1 -1
  78. package/dist/components/trigger/index.d.ts +3 -3
  79. package/dist/components/upload/Upload.d.ts +372 -0
  80. package/dist/components/upload/context.d.ts +28 -0
  81. package/dist/components/upload/index.d.ts +656 -0
  82. package/dist/components/upload/interface.d.ts +110 -0
  83. package/dist/components/upload/props.d.ts +321 -0
  84. package/dist/components/upload/upload-list-item.d.ts +15 -0
  85. package/dist/components/upload/upload-list.d.ts +11 -0
  86. package/dist/components/upload/upload-picture-item.d.ts +20 -0
  87. package/dist/components/upload/upload-trigger.d.ts +8 -0
  88. package/dist/components/upload/utils.d.ts +48 -0
  89. package/dist/es/_hooks/use-chart-size.js +25 -0
  90. package/dist/es/_styles/palette-aliases.js +7 -4
  91. package/dist/es/_utils/chart/padding.js +22 -0
  92. package/dist/es/_utils/chart/path.js +69 -0
  93. package/dist/es/_utils/chart/scale.js +77 -0
  94. package/dist/es/components/_components/chart/ChartAxis.js +79 -0
  95. package/dist/es/components/_components/chart/ChartLegend.js +53 -0
  96. package/dist/es/components/_components/chart/ChartTooltip.js +64 -0
  97. package/dist/es/components/_components/chart/colors.js +12 -0
  98. package/dist/es/components/bar-chart/BarChart.js +470 -0
  99. package/dist/es/components/bar-chart/helpers/layout.js +53 -0
  100. package/dist/es/components/bar-chart/index.js +8 -0
  101. package/dist/es/components/bar-chart/props.js +148 -0
  102. package/dist/es/components/heatmap/Heatmap.js +244 -169
  103. package/dist/es/components/image/Image.vue.js +55 -45
  104. package/dist/es/components/image/Image.vue2.js +113 -92
  105. package/dist/es/components/image/ImagePreview.vue.js +66 -53
  106. package/dist/es/components/image/ImagePreview.vue2.js +219 -171
  107. package/dist/es/components/image/ImagePreviewAction.js +12 -15
  108. package/dist/es/components/image/ImagePreviewGroup.vue.js +21 -20
  109. package/dist/es/components/image/ImagePreviewGroup.vue2.js +45 -39
  110. package/dist/es/components/image/hooks/use-image-drag.js +16 -14
  111. package/dist/es/components/index.js +136 -128
  112. package/dist/es/components/line-chart/LineChart.js +532 -0
  113. package/dist/es/components/line-chart/helpers/layout.js +80 -0
  114. package/dist/es/components/line-chart/index.js +8 -0
  115. package/dist/es/components/line-chart/props.js +178 -0
  116. package/dist/es/components/pie-chart/PieChart.js +397 -0
  117. package/dist/es/components/pie-chart/index.js +8 -0
  118. package/dist/es/components/pie-chart/props.js +104 -0
  119. package/dist/es/components/trend-chart/components/TrendChart.js +143 -183
  120. package/dist/es/components/trend-chart/components/trend-chart-curve.js +85 -81
  121. package/dist/es/components/trend-chart/props.js +28 -74
  122. package/dist/es/components/trend-chart/themes.js +30 -31
  123. package/dist/es/components/upload/Upload.js +420 -0
  124. package/dist/es/components/upload/context.js +4 -0
  125. package/dist/es/components/upload/index.js +8 -0
  126. package/dist/es/components/upload/props.js +321 -0
  127. package/dist/es/components/upload/upload-list-item.js +138 -0
  128. package/dist/es/components/upload/upload-list.js +48 -0
  129. package/dist/es/components/upload/upload-picture-item.js +109 -0
  130. package/dist/es/components/upload/upload-trigger.js +89 -0
  131. package/dist/es/components/upload/utils.js +195 -0
  132. package/dist/es/icons/_self/upload-icons.js +103 -0
  133. package/dist/es/index.js +197 -189
  134. package/dist/es/locale/en-US.js +30 -1
  135. package/dist/es/locale/zh-CN.js +30 -1
  136. package/dist/es/style.css +1 -1
  137. package/dist/icons/_self/upload-icons.d.ts +523 -0
  138. package/dist/index.cjs +4 -4
  139. package/dist/index.umd.js +4 -4
  140. package/dist/locale/interface.d.ts +45 -0
  141. package/dist/style/bar-chart.css +1 -0
  142. package/dist/style/bar-chart.js +2 -0
  143. package/dist/style/base.css +1 -1
  144. package/dist/style/heatmap.css +1 -1
  145. package/dist/style/image.css +1 -1
  146. package/dist/style/line-chart.css +1 -0
  147. package/dist/style/line-chart.js +2 -0
  148. package/dist/style/pie-chart.css +1 -0
  149. package/dist/style/pie-chart.js +2 -0
  150. package/dist/style/upload.css +1 -0
  151. package/dist/style/upload.js +2 -0
  152. package/dist/style.css +1 -1
  153. package/dist/types.d.ts +4 -0
  154. package/package.json +1 -1
  155. package/volar.d.ts +4 -0
  156. package/dist/components/trend-chart/components/trend-chart-grid.d.ts +0 -55
  157. package/dist/components/trend-chart/components/trend-chart-labels.d.ts +0 -26
  158. package/dist/components/trend-chart/helpers/genPath.d.ts +0 -8
  159. package/dist/components/trend-chart/helpers/getPadding.d.ts +0 -8
  160. package/dist/components/trend-chart/helpers/validatePadding.d.ts +0 -2
  161. package/dist/es/_hooks/use-popup-overflow-hidden.js +0 -29
  162. package/dist/es/components/trend-chart/components/trend-chart-grid.js +0 -62
  163. package/dist/es/components/trend-chart/components/trend-chart-labels.js +0 -75
  164. package/dist/es/components/trend-chart/helpers/genPath.js +0 -22
  165. package/dist/es/components/trend-chart/helpers/getPadding.js +0 -21
  166. package/dist/es/components/trend-chart/helpers/validatePadding.js +0 -7
@@ -1,250 +1,210 @@
1
- import { defineComponent as Z, useId as p, reactive as ee, computed as u, ref as j, onMounted as te, nextTick as f, onUnmounted as le, watch as N, createVNode as m, mergeProps as S, h as ae, Fragment as ne } from "vue";
2
- import ie from "../helpers/getPadding.js";
3
- import ue from "../helpers/genPoints.js";
4
- import { useLocale as oe } from "../../../locale/index.js";
5
- import F from "./trend-chart-grid.js";
6
- import E from "./trend-chart-labels.js";
7
- import $ from "./trend-chart-curve.js";
8
- import { getComponentPrefix as re } from "../../../_utils/config.js";
9
- import { trendChartProps as me } from "../props.js";
10
- import { TrendChartTheme as x } from "../themes.js";
11
- const we = /* @__PURE__ */ Z({
12
- name: re("TrendChart"),
1
+ import { defineComponent as B, useId as U, reactive as _, computed as l, ref as j, onMounted as H, onUnmounted as q, watch as N, nextTick as J, createVNode as m, h as K, Fragment as Q, mergeProps as Z } from "vue";
2
+ import p from "../helpers/genPoints.js";
3
+ import { useLocale as ee } from "../../../locale/index.js";
4
+ import R from "./trend-chart-curve.js";
5
+ import { getComponentPrefix as te } from "../../../_utils/config.js";
6
+ import { trendChartProps as ne } from "../props.js";
7
+ import { TrendChartTheme as d } from "../themes.js";
8
+ import { getPadding as ae } from "../../../_utils/chart/padding.js";
9
+ const ce = /* @__PURE__ */ B({
10
+ name: te("TrendChart"),
13
11
  components: {
14
- TrendChartGrid: F,
15
- TrendChartLabels: E,
16
- TrendChartCurve: $
12
+ TrendChartCurve: R
17
13
  },
18
- props: me,
14
+ props: ne,
19
15
  emits: {
20
16
  "mouse-move": (t) => !0
21
17
  },
22
18
  setup(t, {
23
- emit: w
19
+ emit: y
24
20
  }) {
25
21
  const {
26
- t: B
27
- } = oe(), A = `x-trend-chart-clip-${p()}`, a = ee({
22
+ t: T
23
+ } = ee(), C = `x-trend-chart-clip-${U()}`, i = _({
28
24
  width: null,
29
25
  height: null,
30
- labelsOverflowObject: {
31
- top: 0,
32
- right: 0,
33
- bottom: 0,
34
- left: 0
35
- },
36
26
  activeIndex: null
37
- }), D = (e, l = {}) => ({
27
+ }), k = (e, n = {}) => ({
38
28
  ...e,
39
- ...l,
29
+ ...n,
40
30
  stroke: {
41
31
  ...e.stroke,
42
- ...l.color ? {
43
- color: l.color
32
+ ...n.color ? {
33
+ color: n.color
44
34
  } : {},
45
- ...l.stroke
35
+ ...n.stroke
46
36
  },
47
37
  fill: {
48
38
  ...e.fill,
49
- ...l.color ? {
50
- color: l.color
39
+ ...n.color ? {
40
+ color: n.color
51
41
  } : {},
52
- ...l.fill
42
+ ...n.fill
53
43
  },
54
44
  point: {
55
45
  ...e.point,
56
- ...l.color ? {
57
- color: l.color
46
+ ...n.color ? {
47
+ color: n.color
58
48
  } : {},
59
- ...l.point
49
+ ...n.point
60
50
  },
61
51
  axisLine: {
62
52
  ...e.axisLine,
63
- ...l.color ? {
64
- color: l.color
53
+ ...n.color ? {
54
+ color: n.color
65
55
  } : {},
66
- ...l.axisLine
56
+ ...n.axisLine
67
57
  }
68
- }), g = u(() => {
69
- let e = x.PRIMARY;
70
- return t.status === "success" ? e = x.SUCCESS : t.status === "danger" ? e = x.DANGER : t.status === "warning" ? e = x.WARNING : t.status === "strong" ? e = x.STRONG : t.status === "info" && (e = x.INFO), D(e, t.theme);
71
- }), h = u(() => t.dataset.filter((e) => Number.isFinite(e))), G = u(() => h.value.length > 0), c = u(() => ie(t.padding)), n = u(() => {
72
- const e = Number(c.value.left) + Number(a.labelsOverflowObject.left), l = Number(c.value.top) + Number(a.labelsOverflowObject.top), i = Math.max(e, (a.width ?? 0) - Number(c.value.right) - Number(a.labelsOverflowObject.right)), o = Math.max(l, (a.height ?? 0) - Number(c.value.bottom) - Number(a.labelsOverflowObject.bottom));
58
+ }), x = l(() => {
59
+ let e = d.PRIMARY;
60
+ return t.status === "success" ? e = d.SUCCESS : t.status === "danger" ? e = d.DANGER : t.status === "warning" ? e = d.WARNING : t.status === "strong" ? e = d.STRONG : t.status === "info" && (e = d.INFO), k(e, t.theme);
61
+ }), c = l(() => t.dataset.filter((e) => Number.isFinite(e))), V = l(() => c.value.length > 0), g = l(() => ae(t.padding)), a = l(() => {
62
+ const e = Number(g.value.left), n = Number(g.value.top), u = Math.max(e, (i.width ?? 0) - Number(g.value.right)), o = Math.max(n, (i.height ?? 0) - Number(g.value.bottom));
73
63
  return {
74
64
  minX: e,
75
- minY: l,
76
- maxX: i,
65
+ minY: n,
66
+ maxX: u,
77
67
  maxY: o
78
68
  };
79
- }), r = u(() => {
80
- const e = h.value, l = e.length ? Math.max(...e) : 0, i = e.length ? Math.min(...e) : 0;
81
- let o = Number.isFinite(t.max) ? t.max : l, s = Number.isFinite(t.min) ? t.min : i;
82
- return s > o && ([s, o] = [o, s]), {
69
+ }), r = l(() => {
70
+ const e = c.value, n = e.length ? Math.max(...e) : 0, u = e.length ? Math.min(...e) : 0;
71
+ let o = Number.isFinite(t.max) ? t.max : n, v = Number.isFinite(t.min) ? t.min : u;
72
+ return v > o && ([v, o] = [o, v]), {
83
73
  maxValue: o,
84
- minValue: s,
74
+ minValue: v,
85
75
  maxAmount: e.length
86
76
  };
87
- }), W = u(() => ({
77
+ }), F = l(() => ({
88
78
  width: typeof t.width == "number" ? `${t.width}px` : t.width,
89
79
  height: typeof t.height == "number" ? `${t.height}px` : t.height
90
- })), b = u(() => n.value.maxX - n.value.minX), L = u(() => n.value.maxY - n.value.minY), U = u(() => ({
91
- x: n.value.minX,
92
- y: n.value.minY,
93
- width: b.value,
94
- height: L.value,
80
+ })), f = l(() => a.value.maxX - a.value.minX), b = l(() => a.value.maxY - a.value.minY), S = l(() => {
81
+ var n, u;
82
+ if (t.showPoints === !1) return 0;
83
+ const e = Number(((u = (n = x.value) == null ? void 0 : n.point) == null ? void 0 : u.width) ?? 3);
84
+ return Number.isFinite(e) && e > 0 ? e + 1 : 0;
85
+ }), w = l(() => {
86
+ const e = S.value;
87
+ return {
88
+ x: a.value.minX - e,
89
+ y: a.value.minY - e,
90
+ width: f.value + e * 2,
91
+ height: b.value + e * 2
92
+ };
93
+ }), z = l(() => ({
94
+ x: a.value.minX,
95
+ y: a.value.minY,
96
+ width: f.value,
97
+ height: b.value,
95
98
  opacity: 0
96
- })), R = u(() => ({
97
- x: n.value.minX + b.value / 2,
98
- y: n.value.minY + L.value / 2
99
- })), X = u(() => {
99
+ })), L = l(() => ({
100
+ x: a.value.minX + f.value / 2,
101
+ y: a.value.minY + b.value / 2
102
+ })), P = l(() => {
100
103
  if (r.value.maxAmount <= 0)
101
104
  return [];
102
105
  if (r.value.maxAmount === 1)
103
- return [Math.round(n.value.minX + b.value / 2)];
104
- const e = b.value / (r.value.maxAmount - 1);
106
+ return [Math.round(a.value.minX + f.value / 2)];
107
+ const e = f.value / (r.value.maxAmount - 1);
105
108
  return Array.from({
106
109
  length: r.value.maxAmount
107
- }, (l, i) => Math.round(n.value.minX + e * i));
108
- }), y = u(() => a.activeIndex === null ? null : X.value[a.activeIndex] ?? null), _ = u(() => ue(h.value, n.value, r.value.maxValue, r.value.minValue, r.value.maxAmount)), H = u(() => {
109
- const e = a.activeIndex === null ? null : _.value[a.activeIndex];
110
- return e ? Math.min(Math.max(e.y, n.value.minY), n.value.maxY) : n.value.minY;
111
- }), v = j(null), M = j(null), O = () => {
112
- if (v.value) {
113
- const e = v.value.getBoundingClientRect();
114
- a.width = e.width, a.height = e.height;
110
+ }, (n, u) => Math.round(a.value.minX + e * u));
111
+ }), I = l(() => i.activeIndex === null ? null : P.value[i.activeIndex] ?? null), O = l(() => p(c.value, a.value, r.value.maxValue, r.value.minValue, r.value.maxAmount)), E = l(() => {
112
+ const e = i.activeIndex === null ? null : O.value[i.activeIndex];
113
+ return e ? Math.min(Math.max(e.y, a.value.minY), a.value.maxY) : a.value.minY;
114
+ }), s = j(null), M = () => {
115
+ if (s.value) {
116
+ const e = s.value.getBoundingClientRect();
117
+ i.width = e.width, i.height = e.height;
115
118
  }
116
- }, C = () => {
117
- a.labelsOverflowObject = {
118
- top: 0,
119
- right: 0,
120
- bottom: 0,
121
- left: 0
122
- };
123
- }, I = () => {
124
- if (v.value && M.value) {
125
- const e = v.value.getBoundingClientRect(), l = M.value.$el.getBoundingClientRect();
126
- a.labelsOverflowObject = {
127
- top: Math.max(0, Number(e.top) - Number(l.top) + Number(c.value.top)),
128
- right: Math.max(0, Number(l.right) - Number(e.right) + Number(c.value.right)),
129
- bottom: Math.max(0, Number(l.bottom) - Number(e.bottom) + Number(c.value.bottom)),
130
- left: Math.max(0, Number(c.value.left) - Number(l.left) + Number(e.left))
131
- };
132
- } else
133
- C();
134
- }, P = () => {
135
- O(), f(() => {
136
- C(), f(I);
137
- });
138
- }, q = (e) => {
139
- const l = X.value;
140
- if (!l.length)
119
+ }, X = () => {
120
+ M();
121
+ }, D = (e) => {
122
+ const n = P.value;
123
+ if (!n.length)
141
124
  return null;
142
- let i = 0;
143
- return l.forEach((o, s) => {
144
- Math.abs(o - e) < Math.abs(l[i] - e) && (i = s);
145
- }), i;
146
- }, J = (e) => {
147
- if (v.value) {
148
- const l = v.value.getBoundingClientRect();
149
- a.activeIndex = q(e.clientX - l.left);
125
+ let u = 0;
126
+ return n.forEach((o, v) => {
127
+ Math.abs(o - e) < Math.abs(n[u] - e) && (u = v);
128
+ }), u;
129
+ }, G = (e) => {
130
+ if (s.value) {
131
+ const n = s.value.getBoundingClientRect();
132
+ i.activeIndex = D(e.clientX - n.left);
150
133
  }
151
- }, K = () => {
152
- a.activeIndex = null;
134
+ }, W = () => {
135
+ i.activeIndex = null;
153
136
  };
154
- let d = null;
155
- const Q = () => {
156
- typeof ResizeObserver > "u" || !v.value || (d = new ResizeObserver(() => {
157
- P();
158
- }), d.observe(v.value));
159
- }, V = () => {
160
- P();
137
+ let h = null;
138
+ const $ = () => {
139
+ typeof ResizeObserver > "u" || !s.value || (h = new ResizeObserver(() => {
140
+ X();
141
+ }), h.observe(s.value));
142
+ }, A = () => {
143
+ X();
161
144
  };
162
- return te(() => {
163
- O(), f(I), Q(), window.addEventListener("resize", V);
164
- }), le(() => {
165
- d == null || d.disconnect(), d = null, window.removeEventListener("resize", V);
166
- }), N(() => a.activeIndex, (e) => {
145
+ return H(() => {
146
+ M(), $(), window.addEventListener("resize", A);
147
+ }), q(() => {
148
+ h == null || h.disconnect(), h = null, window.removeEventListener("resize", A);
149
+ }), N(() => i.activeIndex, (e) => {
167
150
  if (e !== null) {
168
- const l = h.value[e];
169
- if (l === void 0) {
170
- w("mouse-move", null);
151
+ const n = c.value[e];
152
+ if (n === void 0) {
153
+ y("mouse-move", null);
171
154
  return;
172
155
  }
173
- w("mouse-move", {
156
+ y("mouse-move", {
174
157
  index: e,
175
- data: l
158
+ data: n
176
159
  });
177
160
  } else
178
- w("mouse-move", null);
179
- }), N(h, (e) => {
180
- a.activeIndex !== null && a.activeIndex >= e.length && (a.activeIndex = null);
181
- }), N(() => [t.labels, t.dataset, t.min, t.max, t.padding], () => {
182
- C(), f(() => {
183
- O(), f(I);
184
- });
185
- }, {
186
- deep: !0
187
- }), N(() => {
188
- var e, l, i, o;
189
- return [(e = t.grid) == null ? void 0 : e.verticalLines, (l = t.grid) == null ? void 0 : l.verticalLinesNumber, (o = (i = t.labels) == null ? void 0 : i.xLabels) == null ? void 0 : o.length, h.value.length];
190
- }, () => {
161
+ y("mouse-move", null);
162
+ }), N(c, (e) => {
163
+ i.activeIndex !== null && i.activeIndex >= e.length && (i.activeIndex = null);
164
+ }), N(() => [t.dataset, t.min, t.max, t.padding, t.height], () => {
165
+ J(M);
191
166
  }, {
192
- immediate: !0,
193
167
  deep: !0
194
168
  }), () => {
195
- var e, l, i, o, s, Y, T, z, k;
169
+ var e, n, u, o, v, Y;
196
170
  return m("svg", {
197
171
  class: "x-trend-chart",
198
- ref: v,
172
+ ref: s,
199
173
  xmlns: "http://www.w3.org/2000/svg",
200
174
  width: "100%",
201
175
  height: "100%",
202
- style: W.value,
176
+ style: F.value,
203
177
  role: t.ariaLabel ? "img" : void 0,
204
178
  "aria-label": t.ariaLabel
205
179
  }, [m("defs", null, [m("clipPath", {
206
- id: A
180
+ id: C
207
181
  }, [m("rect", {
208
- x: n.value.minX,
209
- y: n.value.minY,
210
- width: Math.max(0, b.value),
211
- height: Math.max(0, L.value)
212
- }, null)])]), t.grid && m(F, {
213
- class: "grid",
214
- verticalLines: t.grid.verticalLines,
215
- verticalLinesNumber: t.grid.verticalLinesNumber || ((l = (e = t.labels) == null ? void 0 : e.xLabels) == null ? void 0 : l.length) || r.value.maxAmount,
216
- horizontalLines: t.grid.horizontalLines,
217
- horizontalLinesNumber: t.grid.horizontalLinesNumber || ((i = t.labels) == null ? void 0 : i.yLabels) || 4,
218
- boundary: n.value
219
- }, null), t.labels && m(E, S({
220
- ref: M,
221
- class: "labels"
222
- }, t.labels, {
223
- boundary: n.value,
224
- minValue: r.value.minValue,
225
- maxValue: r.value.maxValue
226
- }), null), m($, {
182
+ x: w.value.x,
183
+ y: w.value.y,
184
+ width: Math.max(0, w.value.width),
185
+ height: Math.max(0, w.value.height)
186
+ }, null)])]), m(R, {
227
187
  class: "curve",
228
- data: h.value,
229
- boundary: n.value,
188
+ data: c.value,
189
+ boundary: a.value,
230
190
  minValue: r.value.minValue,
231
191
  maxValue: r.value.maxValue,
232
192
  maxAmount: r.value.maxAmount,
233
- activeLineParams: a.activeIndex === null ? null : {
234
- index: a.activeIndex
193
+ activeLineParams: i.activeIndex === null ? null : {
194
+ index: i.activeIndex
235
195
  },
236
- clipPath: `url(#${A})`,
196
+ clipPath: `url(#${C})`,
237
197
  smooth: t.smooth,
238
198
  stroke: t.stroke,
239
199
  fill: t.fill,
240
200
  showPoints: t.showPoints,
241
201
  tooltip: t.tooltip,
242
202
  tooltipFormatter: t.tooltipFormatter,
243
- theme: g.value
244
- }, null), !G.value && ae("text", {
203
+ theme: x.value
204
+ }, null), !V.value && K("text", {
245
205
  class: "x-trend-chart-empty",
246
- x: R.value.x,
247
- y: R.value.y,
206
+ x: L.value.x,
207
+ y: L.value.y,
248
208
  "text-anchor": "middle",
249
209
  "dominant-baseline": "middle",
250
210
  style: {
@@ -252,27 +212,27 @@ const we = /* @__PURE__ */ Z({
252
212
  fontSize: "12px",
253
213
  pointerEvents: "none"
254
214
  }
255
- }, B("common.noData")), t.interactive && m(ne, null, [m("line", {
215
+ }, T("common.noData")), t.interactive && m(Q, null, [m("line", {
256
216
  class: "x-trend-chart-active-line",
257
- x1: y.value ?? n.value.minX,
258
- x2: y.value ?? n.value.minX,
259
- y1: H.value,
260
- y2: n.value.maxY,
261
- visibility: y.value !== null ? "visible" : "hidden",
217
+ x1: I.value ?? a.value.minX,
218
+ x2: I.value ?? a.value.minX,
219
+ y1: E.value,
220
+ y2: a.value.maxY,
221
+ visibility: I.value !== null ? "visible" : "hidden",
262
222
  style: {
263
- stroke: (s = (o = g.value) == null ? void 0 : o.axisLine) == null ? void 0 : s.color,
264
- strokeWidth: (T = (Y = g.value) == null ? void 0 : Y.axisLine) == null ? void 0 : T.width,
265
- strokeOpacity: (k = (z = g.value) == null ? void 0 : z.axisLine) == null ? void 0 : k.opacity
223
+ stroke: (n = (e = x.value) == null ? void 0 : e.axisLine) == null ? void 0 : n.color,
224
+ strokeWidth: (o = (u = x.value) == null ? void 0 : u.axisLine) == null ? void 0 : o.width,
225
+ strokeOpacity: (Y = (v = x.value) == null ? void 0 : v.axisLine) == null ? void 0 : Y.opacity
266
226
  }
267
- }, null), m("rect", S({
227
+ }, null), m("rect", Z({
268
228
  class: "x-trend-chart-overlay"
269
- }, U.value, {
270
- onMousemove: J,
271
- onMouseout: K
229
+ }, z.value, {
230
+ onMousemove: G,
231
+ onMouseout: W
272
232
  }), null)])]);
273
233
  };
274
234
  }
275
235
  });
276
236
  export {
277
- we as default
237
+ ce as default
278
238
  };
@@ -1,106 +1,110 @@
1
- import { defineComponent as T, useId as W, computed as i, createVNode as o } from "vue";
2
- import G from "../helpers/genPoints.js";
3
- import H from "../helpers/genPath.js";
4
- import { getComponentPrefix as O } from "../../../_utils/config.js";
5
- import { trendChartCurveProps as S } from "../props.js";
6
- const _ = /* @__PURE__ */ T({
7
- name: O("TrendChartCurve"),
8
- props: S,
9
- setup(e) {
10
- const x = `x-trend-chart-fill-${W()}`, h = i(() => G(e.data, e.boundary, e.maxValue, e.minValue, e.maxAmount)), v = i(() => H([...h.value], e.smooth, e.boundary)), k = i(() => {
11
- var t;
12
- return e.fill && ((t = v.value) == null ? void 0 : t.fillPath) && h.value.length > 1 && e.maxValue !== e.minValue;
13
- }), y = i(() => {
14
- var t, l;
15
- return ((l = (t = e.theme) == null ? void 0 : t.fill) == null ? void 0 : l.color) || "var(--x-color-text-secondary)";
16
- }), b = i(() => {
17
- var t, l;
18
- return ((l = (t = e.theme) == null ? void 0 : t.fill) == null ? void 0 : l.opacity) ?? 0.1;
1
+ import { defineComponent as I, useId as M, computed as i, createVNode as o } from "vue";
2
+ import N from "../helpers/genPoints.js";
3
+ import { getComponentPrefix as R } from "../../../_utils/config.js";
4
+ import { trendChartCurveProps as A } from "../props.js";
5
+ import { genAreaPath as G, genLinePath as H } from "../../../_utils/chart/path.js";
6
+ import { estimateTextWidth as L } from "../../../_utils/chart/scale.js";
7
+ const j = /* @__PURE__ */ I({
8
+ name: R("TrendChartCurve"),
9
+ props: A,
10
+ setup(t) {
11
+ const b = `x-trend-chart-fill-${M()}`, h = i(() => N(t.data, t.boundary, t.maxValue, t.minValue, t.maxAmount)), y = i(() => ({
12
+ linePath: H(h.value, t.smooth),
13
+ fillPath: G(h.value, t.boundary.maxY, t.smooth)
14
+ })), k = i(() => {
15
+ var e;
16
+ return t.fill && ((e = y.value) == null ? void 0 : e.fillPath) && h.value.length > 1 && t.maxValue !== t.minValue;
17
+ }), x = i(() => {
18
+ var e, l;
19
+ return ((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.color) || "var(--x-color-text-secondary)";
20
+ }), P = i(() => {
21
+ var e, l;
22
+ return ((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.opacity) ?? 0.1;
19
23
  }), g = i(() => {
20
- var t, l;
21
- return (((l = (t = e.theme) == null ? void 0 : t.fill) == null ? void 0 : l.type) ?? "gradient") === "gradient";
22
- }), u = i(() => {
23
- var t;
24
- return ((t = e.activeLineParams) == null ? void 0 : t.index) ?? -1;
25
- }), C = 18, w = i(() => {
26
- if (e.showPoints === !1) return !1;
27
- if (e.showPoints === !0) return !0;
28
- const t = h.value.length;
29
- return t <= 2 ? !0 : (e.boundary.maxX - e.boundary.minX) / (t - 1) >= C;
30
- }), V = (t) => {
31
- var a, n;
32
- const l = ((n = (a = e.theme) == null ? void 0 : a.point) == null ? void 0 : n.width) ?? 3;
33
- return t ? l + 1 : l;
34
- }, I = (t) => {
35
- var a, n, c, r, m, f;
36
- const l = ((n = (a = e.theme) == null ? void 0 : a.point) == null ? void 0 : n.color) ?? ((r = (c = e.theme) == null ? void 0 : c.stroke) == null ? void 0 : r.color);
37
- return t ? {
24
+ var e, l;
25
+ return (((l = (e = t.theme) == null ? void 0 : e.fill) == null ? void 0 : l.type) ?? "gradient") === "gradient";
26
+ }), s = i(() => {
27
+ var e;
28
+ return ((e = t.activeLineParams) == null ? void 0 : e.index) ?? -1;
29
+ }), C = 18, X = i(() => {
30
+ if (t.showPoints === !1) return !1;
31
+ if (t.showPoints === !0) return !0;
32
+ const e = h.value.length;
33
+ return e <= 2 ? !0 : (t.boundary.maxX - t.boundary.minX) / (e - 1) >= C;
34
+ }), w = (e) => {
35
+ var n, a;
36
+ const l = ((a = (n = t.theme) == null ? void 0 : n.point) == null ? void 0 : a.width) ?? 3;
37
+ return e ? l + 1 : l;
38
+ }, T = (e) => {
39
+ var n, a, d, r, u, c;
40
+ const l = ((a = (n = t.theme) == null ? void 0 : n.point) == null ? void 0 : a.color) ?? ((r = (d = t.theme) == null ? void 0 : d.stroke) == null ? void 0 : r.color);
41
+ return e ? {
38
42
  fill: l,
39
43
  stroke: l,
40
44
  strokeWidth: 1
41
45
  } : {
42
46
  fill: l,
43
- opacity: (f = (m = e.theme) == null ? void 0 : m.point) == null ? void 0 : f.opacity
47
+ opacity: (c = (u = t.theme) == null ? void 0 : u.point) == null ? void 0 : c.opacity
44
48
  };
45
- }, N = i(() => {
46
- var a, n, c, r, m, f, P;
47
- const t = [];
48
- k.value && t.push(o("path", {
49
+ }, V = i(() => {
50
+ var n, a, d, r, u, c, v;
51
+ const e = [];
52
+ k.value && e.push(o("path", {
49
53
  class: "x-trend-chart-fill",
50
- d: v.value.fillPath,
54
+ d: y.value.fillPath,
51
55
  fill: "none",
52
56
  style: {
53
- fill: g.value ? `url(#${x})` : y.value,
54
- opacity: g.value ? 1 : b.value
57
+ fill: g.value ? `url(#${b})` : x.value,
58
+ opacity: g.value ? 1 : P.value
55
59
  }
56
- }, null)), e.stroke && ((a = v.value) != null && a.linePath) && t.push(o("path", {
60
+ }, null)), t.stroke && ((n = y.value) != null && n.linePath) && e.push(o("path", {
57
61
  class: "x-trend-chart-stroke",
58
- d: v.value.linePath,
62
+ d: y.value.linePath,
59
63
  fill: "none",
60
64
  stroke: "none",
61
65
  "stroke-linecap": "round",
62
66
  "stroke-linejoin": "round",
63
67
  style: {
64
- stroke: (c = (n = e.theme) == null ? void 0 : n.stroke) == null ? void 0 : c.color,
65
- strokeWidth: (m = (r = e.theme) == null ? void 0 : r.stroke) == null ? void 0 : m.width,
66
- opacity: (P = (f = e.theme) == null ? void 0 : f.stroke) == null ? void 0 : P.opacity
68
+ stroke: (d = (a = t.theme) == null ? void 0 : a.stroke) == null ? void 0 : d.color,
69
+ strokeWidth: (u = (r = t.theme) == null ? void 0 : r.stroke) == null ? void 0 : u.width,
70
+ opacity: (v = (c = t.theme) == null ? void 0 : c.stroke) == null ? void 0 : v.opacity
67
71
  }
68
72
  }, null));
69
- const l = h.value.map((s, d) => ({
70
- point: s,
71
- index: d
73
+ const l = h.value.map((m, f) => ({
74
+ point: m,
75
+ index: f
72
76
  })).filter(({
73
- index: s
74
- }) => w.value || s === u.value);
75
- return l.length && t.push(o("g", {
77
+ index: m
78
+ }) => X.value || m === s.value);
79
+ return l.length && e.push(o("g", {
76
80
  class: "x-trend-chart-points"
77
81
  }, [l.map(({
78
- point: s,
79
- index: d
82
+ point: m,
83
+ index: f
80
84
  }) => o("circle", {
81
- key: d,
85
+ key: f,
82
86
  class: {
83
87
  point: !0,
84
- "x-trend-chart-point-active": u.value === d
88
+ "x-trend-chart-point-active": s.value === f
85
89
  },
86
- cx: s.x,
87
- cy: s.y,
88
- r: V(u.value === d),
89
- style: I(u.value === d)
90
- }, null))])), t;
91
- }), R = i(() => {
92
- const t = h.value[u.value];
93
- if (!e.tooltip || u.value < 0 || !t)
90
+ cx: m.x,
91
+ cy: m.y,
92
+ r: w(s.value === f),
93
+ style: T(s.value === f)
94
+ }, null))])), e;
95
+ }), W = i(() => {
96
+ const e = h.value[s.value];
97
+ if (!t.tooltip || s.value < 0 || !e)
94
98
  return null;
95
- const l = e.tooltipFormatter(e.data[u.value]), a = Math.max(24, l.length * 7 + 12), n = 18, r = t.y - n - 6 >= e.boundary.minY ? t.y - n - 6 : t.y + 6;
99
+ const l = t.tooltipFormatter(t.data[s.value]), n = Math.max(24, Math.round(L(l, 12)) + 12), a = 18, r = e.y - a - 6 >= t.boundary.minY ? e.y - a - 6 : e.y + 6, u = t.boundary.minX + n / 2, c = t.boundary.maxX - n / 2, v = c >= u ? Math.min(Math.max(e.x, u), c) : (t.boundary.minX + t.boundary.maxX) / 2;
96
100
  return o("g", {
97
101
  class: "x-trend-chart-tooltip",
98
102
  "pointer-events": "none"
99
103
  }, [o("rect", {
100
- x: t.x - a / 2,
104
+ x: v - n / 2,
101
105
  y: r,
102
- width: a,
103
- height: n,
106
+ width: n,
107
+ height: a,
104
108
  rx: 4,
105
109
  style: {
106
110
  fill: "var(--x-color-bg-popup)",
@@ -108,8 +112,8 @@ const _ = /* @__PURE__ */ T({
108
112
  strokeWidth: 1
109
113
  }
110
114
  }, null), o("text", {
111
- x: t.x,
112
- y: r + n / 2,
115
+ x: v,
116
+ y: r + a / 2,
113
117
  "text-anchor": "middle",
114
118
  "dominant-baseline": "middle",
115
119
  style: {
@@ -119,26 +123,26 @@ const _ = /* @__PURE__ */ T({
119
123
  }, [l])]);
120
124
  });
121
125
  return () => o("g", {
122
- class: e.className
126
+ class: t.className
123
127
  }, [o("defs", null, [o("linearGradient", {
124
- id: x,
128
+ id: b,
125
129
  x1: "0",
126
130
  y1: "0",
127
131
  x2: "0",
128
132
  y2: "1"
129
133
  }, [o("stop", {
130
134
  offset: "0%",
131
- "stop-color": y.value,
132
- "stop-opacity": b.value
135
+ "stop-color": x.value,
136
+ "stop-opacity": P.value
133
137
  }, null), o("stop", {
134
138
  offset: "100%",
135
- "stop-color": y.value,
139
+ "stop-color": x.value,
136
140
  "stop-opacity": "0"
137
141
  }, null)])]), o("g", {
138
- "clip-path": e.clipPath
139
- }, [N.value]), R.value]);
142
+ "clip-path": t.clipPath
143
+ }, [V.value]), W.value]);
140
144
  }
141
145
  });
142
146
  export {
143
- _ as default
147
+ j as default
144
148
  };