x-next 1.5.0 → 1.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.
- package/AI_USAGE.md +2 -2
- package/CHANGELOG.md +36 -0
- package/dist/_utils/color.d.ts +53 -0
- package/dist/components/color-picker/ColorPicker.d.ts +239 -0
- package/dist/components/color-picker/gradient-slider.d.ts +52 -0
- package/dist/components/color-picker/index.d.ts +238 -0
- package/dist/components/color-picker/panel.d.ts +721 -0
- package/dist/components/color-picker/sv-panel.d.ts +48 -0
- package/dist/components/date-picker/DatePicker.vue.d.ts +3 -3
- package/dist/components/date-picker/index.d.ts +6 -6
- package/dist/components/dropdown/Dropdown.vue.d.ts +34 -4
- package/dist/components/dropdown/DropdownButton.vue.d.ts +35 -5
- package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +34 -4
- package/dist/components/dropdown/dropdown-panel.vue.d.ts +30 -0
- package/dist/components/dropdown/index.d.ts +209 -29
- package/dist/components/form/FormItem.vue.d.ts +3 -3
- package/dist/components/form/form-item-label.vue.d.ts +3 -3
- package/dist/components/form/index.d.ts +6 -6
- package/dist/components/form-select/Select.d.ts +3 -3
- package/dist/components/form-select/SelectDropdown.vue.d.ts +30 -0
- package/dist/components/form-select/index.d.ts +66 -6
- package/dist/components/form-slider/Slider.vue.d.ts +3 -3
- package/dist/components/form-slider/index.d.ts +6 -6
- package/dist/components/form-slider/slider-button.vue.d.ts +3 -3
- package/dist/components/heatmap/Heatmap.d.ts +311 -0
- package/dist/components/heatmap/helpers/matrix.d.ts +58 -0
- package/dist/components/heatmap/index.d.ts +372 -0
- package/dist/components/heatmap/interface.d.ts +57 -0
- package/dist/components/image/Image.vue.d.ts +3 -3
- package/dist/components/image/ImagePreview.vue.d.ts +3 -3
- package/dist/components/image/ImagePreviewAction.d.ts +3 -3
- package/dist/components/image/ImagePreviewGroup.vue.d.ts +3 -3
- package/dist/components/image/index.d.ts +24 -24
- package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/components/menu/sub-menu-pop.vue.d.ts +3 -3
- package/dist/components/network/Network.vue.d.ts +1 -1
- package/dist/components/network/index.d.ts +3 -3
- package/dist/components/network/utils.d.ts +2 -0
- package/dist/components/pagination/page-item-ellipsis.vue.d.ts +9 -0
- package/dist/components/pagination/page-jumper.vue.d.ts +6 -0
- package/dist/components/pagination/page-options.vue.d.ts +6 -6
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -3
- package/dist/components/popup/Popup.d.ts +1 -1
- package/dist/components/popup/index.d.ts +3 -3
- package/dist/components/skeleton/SkeletonShape.vue.d.ts +3 -3
- package/dist/components/skeleton/index.d.ts +6 -6
- package/dist/components/spin/Spin.d.ts +38 -0
- package/dist/components/spin/index.d.ts +30 -0
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/tabs/Tabs.d.ts +1 -1
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/time-picker/TimePicker.vue.d.ts +3 -3
- package/dist/components/time-picker/index.d.ts +6 -6
- package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/components/trigger/Trigger.d.ts +1 -1
- package/dist/components/trigger/index.d.ts +3 -3
- package/dist/components/watermark/Watermark.d.ts +1 -1
- package/dist/components/watermark/index.d.ts +3 -3
- package/dist/es/_styles/palette-aliases.js +8 -0
- package/dist/es/_utils/color.js +73 -0
- package/dist/es/components/button/Button.js +2 -2
- package/dist/es/components/color-picker/ColorPicker.js +239 -0
- package/dist/es/components/color-picker/gradient-slider.js +79 -0
- package/dist/es/components/color-picker/index.js +8 -0
- package/dist/es/components/color-picker/panel.js +307 -0
- package/dist/es/components/color-picker/sv-panel.js +99 -0
- package/dist/es/components/dropdown/dropdown-panel.vue.js +17 -17
- package/dist/es/components/form-input/Input.js +7 -7
- package/dist/es/components/form-input/InputPassword.vue2.js +2 -2
- package/dist/es/components/form-input/InputSearch.js +2 -2
- package/dist/es/components/form-input-number/InputNumber.js +12 -12
- package/dist/es/components/heatmap/Heatmap.js +334 -0
- package/dist/es/components/heatmap/helpers/matrix.js +106 -0
- package/dist/es/components/heatmap/index.js +8 -0
- package/dist/es/components/index.js +118 -114
- package/dist/es/components/menu/sub-menu-pop.vue2.js +12 -12
- package/dist/es/components/network/Network.vue2.js +72 -72
- package/dist/es/components/network/utils.js +44 -35
- package/dist/es/components/pagination/Pagination.js +113 -104
- package/dist/es/components/pagination/page-item-ellipsis.vue.js +13 -12
- package/dist/es/components/pagination/page-item-ellipsis.vue2.js +19 -15
- package/dist/es/components/pagination/page-jumper.vue.js +13 -12
- package/dist/es/components/pagination/page-jumper.vue2.js +7 -4
- package/dist/es/components/pagination/page-options.vue.js +4 -3
- package/dist/es/components/pagination/page-options.vue2.js +17 -15
- package/dist/es/components/skeleton/Skeleton.vue.js +11 -9
- package/dist/es/components/skeleton/SkeletonLine.vue.js +9 -8
- package/dist/es/components/skeleton/SkeletonShape.vue.js +8 -7
- package/dist/es/components/spin/Spin.js +124 -60
- package/dist/es/components/table/Table.js +3 -1
- package/dist/es/components/trigger/Trigger.js +19 -19
- package/dist/es/icons/_self/empty-better.js +25 -8
- package/dist/es/index.js +162 -158
- package/dist/es/locale/en-US.js +17 -1
- package/dist/es/locale/zh-CN.js +17 -1
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/locale/interface.d.ts +28 -0
- package/dist/style/base.css +1 -1
- package/dist/style/button.css +1 -1
- package/dist/style/color-picker.css +1 -0
- package/dist/style/color-picker.js +2 -0
- package/dist/style/date-picker.css +1 -1
- package/dist/style/empty.css +1 -1
- package/dist/style/form-checkbox.css +1 -1
- package/dist/style/form-input-tag.css +1 -1
- package/dist/style/form-input.css +1 -1
- package/dist/style/form-radio.css +1 -1
- package/dist/style/form-textarea.css +1 -1
- package/dist/style/form.css +1 -1
- package/dist/style/heatmap.css +1 -0
- package/dist/style/heatmap.js +2 -0
- package/dist/style/image.css +1 -1
- package/dist/style/menu.css +1 -1
- package/dist/style/pagination.css +1 -1
- package/dist/style/skeleton.css +1 -1
- package/dist/style/spin.css +1 -1
- package/dist/style/steps.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/volar.d.ts +2 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { defineComponent as W, createVNode as l, toRefs as $, computed as n, ref as q, Fragment as j } from "vue";
|
|
2
|
+
import { getClassNameMixin as P } from "../../_utils/config.js";
|
|
3
|
+
import { useSize as T } from "../../_hooks/use-size.js";
|
|
4
|
+
import { useLocale as V } from "../../locale/index.js";
|
|
5
|
+
import { isObject as _ } from "../../_utils/is.js";
|
|
6
|
+
import { throttleByRaf as F } from "../../_utils/throttle-by-raf.js";
|
|
7
|
+
import { Spin as H } from "../spin/index.js";
|
|
8
|
+
import { getWeekdayLabels as G } from "../date-picker/utils.js";
|
|
9
|
+
import { CELL_SIZE as A, resolveRange as U, indexDataByDay as Z, getValueExtent as J, buildMatrix as K, DEFAULT_COLOR_LEVELS as Q, getMonthLabels as X, isCellInRequestedRange as ee } from "./helpers/matrix.js";
|
|
10
|
+
const ue = /* @__PURE__ */ W({
|
|
11
|
+
name: "Heatmap",
|
|
12
|
+
props: {
|
|
13
|
+
/**
|
|
14
|
+
* @zh 热力图数据
|
|
15
|
+
* @en Heatmap data
|
|
16
|
+
*/
|
|
17
|
+
data: {
|
|
18
|
+
type: Array,
|
|
19
|
+
default: () => []
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* @zh 要渲染的自然年;设置后优先于 startDate / endDate
|
|
23
|
+
* @en Year to render; takes priority over startDate / endDate
|
|
24
|
+
*/
|
|
25
|
+
year: {
|
|
26
|
+
type: Number
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* @zh 自定义范围起始(时间戳或日期字符串)
|
|
30
|
+
* @en Custom range start (timestamp or date string)
|
|
31
|
+
*/
|
|
32
|
+
startDate: {
|
|
33
|
+
type: [Number, String]
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* @zh 自定义范围结束(时间戳或日期字符串)
|
|
37
|
+
* @en Custom range end (timestamp or date string)
|
|
38
|
+
*/
|
|
39
|
+
endDate: {
|
|
40
|
+
type: [Number, String]
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* @zh 由浅到深的色阶;不传使用内置主色阶
|
|
44
|
+
* @en Colors from light to dark; built-in primary ramp when omitted
|
|
45
|
+
*/
|
|
46
|
+
activeColors: {
|
|
47
|
+
type: Array
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* @zh 最小值(含无数据格)的颜色
|
|
51
|
+
* @en Color for the minimum value and cells without data
|
|
52
|
+
*/
|
|
53
|
+
minimumColor: {
|
|
54
|
+
type: String
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* @zh 格子尺寸
|
|
58
|
+
* @en Cell size
|
|
59
|
+
* @values 'small', 'medium', 'large'
|
|
60
|
+
* @defaultValue 'medium'
|
|
61
|
+
*/
|
|
62
|
+
size: {
|
|
63
|
+
type: String
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* @zh 一周的起始日(0 为周日)
|
|
67
|
+
* @en First day of the week (0 is Sunday)
|
|
68
|
+
* @defaultValue 0
|
|
69
|
+
*/
|
|
70
|
+
firstDayOfWeek: {
|
|
71
|
+
type: Number,
|
|
72
|
+
default: 0,
|
|
73
|
+
validator: (e) => e >= 0 && e <= 6
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* @zh 是否展示星期标签
|
|
77
|
+
* @en Whether to show weekday labels
|
|
78
|
+
* @defaultValue true
|
|
79
|
+
*/
|
|
80
|
+
showWeekLabels: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: !0
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* @zh 是否展示月份标签
|
|
86
|
+
* @en Whether to show month labels
|
|
87
|
+
* @defaultValue true
|
|
88
|
+
*/
|
|
89
|
+
showMonthLabels: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: !0
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* @zh 是否展示颜色图例
|
|
95
|
+
* @en Whether to show the color indicator
|
|
96
|
+
* @defaultValue true
|
|
97
|
+
*/
|
|
98
|
+
showColorIndicator: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: !0
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* @zh 鼠标悬浮提示;传对象时透传给内部浮层
|
|
104
|
+
* @en Hover tooltip; pass an object to configure the inner popup
|
|
105
|
+
* @defaultValue true
|
|
106
|
+
*/
|
|
107
|
+
tooltip: {
|
|
108
|
+
type: [Boolean, Object],
|
|
109
|
+
default: !0
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* @zh 加载中
|
|
113
|
+
* @en Loading state
|
|
114
|
+
* @defaultValue false
|
|
115
|
+
*/
|
|
116
|
+
loading: {
|
|
117
|
+
type: [Boolean, Object],
|
|
118
|
+
default: !1
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* @zh 无障碍名称;设置后根节点带 role="img"
|
|
122
|
+
* @en Accessible name; adds role="img" to the root when set
|
|
123
|
+
*/
|
|
124
|
+
ariaLabel: {
|
|
125
|
+
type: String
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
emits: {
|
|
129
|
+
/**
|
|
130
|
+
* @zh 点击某个日期格时触发
|
|
131
|
+
* @en Emitted when a day cell is clicked
|
|
132
|
+
* @param {HeatmapCell} cell
|
|
133
|
+
* @param {MouseEvent} ev
|
|
134
|
+
*/
|
|
135
|
+
cellClick: (e, b) => !0
|
|
136
|
+
},
|
|
137
|
+
slots: Object,
|
|
138
|
+
setup(e, {
|
|
139
|
+
emit: b,
|
|
140
|
+
slots: I
|
|
141
|
+
}) {
|
|
142
|
+
const {
|
|
143
|
+
t: v,
|
|
144
|
+
locale: O
|
|
145
|
+
} = V(), h = P("heatmap"), {
|
|
146
|
+
mergedSize: x
|
|
147
|
+
} = T($(e).size, {
|
|
148
|
+
defaultValue: "medium"
|
|
149
|
+
}), c = n(() => A[x.value] ?? A.medium), d = n(() => {
|
|
150
|
+
var t;
|
|
151
|
+
return (t = e.activeColors) != null && t.length ? e.activeColors : ["var(--x-heatmap-color-level-1)", "var(--x-heatmap-color-level-2)", "var(--x-heatmap-color-level-3)", "var(--x-heatmap-color-level-4)", "var(--x-heatmap-color-level-5)"];
|
|
152
|
+
}), C = n(() => e.minimumColor ?? "var(--x-heatmap-color-empty)"), k = n(() => [C.value, ...d.value]), i = n(() => U({
|
|
153
|
+
year: e.year,
|
|
154
|
+
startDate: e.startDate,
|
|
155
|
+
endDate: e.endDate,
|
|
156
|
+
data: e.data
|
|
157
|
+
}, e.firstDayOfWeek)), y = n(() => Z(e.data)), E = n(() => J(e.data)), p = n(() => i.value ? K(i.value, y.value, E.value, d.value.length || Q) : []), R = n(() => {
|
|
158
|
+
const t = Array.from({
|
|
159
|
+
length: 7
|
|
160
|
+
}, () => []);
|
|
161
|
+
return p.value.forEach((a) => {
|
|
162
|
+
t[a.rowIndex].push(a);
|
|
163
|
+
}), t;
|
|
164
|
+
}), N = n(() => G(e.firstDayOfWeek, O.value.datePicker)), L = n(() => {
|
|
165
|
+
if (!i.value) return [];
|
|
166
|
+
const t = i.value.requestedStart.year() !== i.value.requestedEnd.year();
|
|
167
|
+
return X(i.value, p.value, (a) => t ? a.format("YYYY-MM") : v("heatmap.month", {
|
|
168
|
+
month: a.month() + 1
|
|
169
|
+
}));
|
|
170
|
+
}), r = (t) => k.value[t.level] ?? C.value, w = (t) => {
|
|
171
|
+
const a = t.date.format("YYYY-MM-DD"), m = t.value;
|
|
172
|
+
return m === null ? v("heatmap.noData", {
|
|
173
|
+
date: a
|
|
174
|
+
}) : v("heatmap.value", {
|
|
175
|
+
date: a,
|
|
176
|
+
value: m
|
|
177
|
+
});
|
|
178
|
+
}, f = q(null), g = n(() => e.tooltip !== !1), S = n(() => f.value === null ? null : p.value[f.value] ?? null), Y = n(() => {
|
|
179
|
+
const t = S.value;
|
|
180
|
+
if (!t) return {};
|
|
181
|
+
const a = 2, m = t.colIndex * (c.value + a) + c.value / 2, D = t.rowIndex * (c.value + a) + c.value;
|
|
182
|
+
return {
|
|
183
|
+
left: `${m}px`,
|
|
184
|
+
top: `${D + 6}px`
|
|
185
|
+
};
|
|
186
|
+
}), z = (t) => {
|
|
187
|
+
var D;
|
|
188
|
+
if (!g.value) return;
|
|
189
|
+
const a = t.target, m = (D = a == null ? void 0 : a.dataset) == null ? void 0 : D.index;
|
|
190
|
+
f.value = m === void 0 ? null : Number(m);
|
|
191
|
+
}, B = () => {
|
|
192
|
+
f.value = null;
|
|
193
|
+
}, o = (t, a) => {
|
|
194
|
+
b("cellClick", t, a);
|
|
195
|
+
}, u = F(z), s = n(() => ({
|
|
196
|
+
"--x-heatmap-cell-size": `${c.value}px`,
|
|
197
|
+
gridTemplateRows: `repeat(7, ${c.value}px)`
|
|
198
|
+
}));
|
|
199
|
+
return {
|
|
200
|
+
t: v,
|
|
201
|
+
className: h,
|
|
202
|
+
mergedSize: x,
|
|
203
|
+
cells: p,
|
|
204
|
+
rows: R,
|
|
205
|
+
range: i,
|
|
206
|
+
gridStyle: s,
|
|
207
|
+
weekdayLabels: N,
|
|
208
|
+
monthLabels: L,
|
|
209
|
+
activeCell: S,
|
|
210
|
+
tooltipEnabled: g,
|
|
211
|
+
tooltipStyle: Y,
|
|
212
|
+
cellColor: r,
|
|
213
|
+
cellLabel: w,
|
|
214
|
+
handleCellClick: o,
|
|
215
|
+
throttledMove: u,
|
|
216
|
+
clearActive: B,
|
|
217
|
+
isInRange: (t) => i.value ? ee(t, i.value.requestedStart, i.value.requestedEnd) : !0,
|
|
218
|
+
colorPalette: k,
|
|
219
|
+
slots: I
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
render() {
|
|
223
|
+
const {
|
|
224
|
+
className: e,
|
|
225
|
+
mergedSize: b,
|
|
226
|
+
cells: I,
|
|
227
|
+
rows: v,
|
|
228
|
+
range: O,
|
|
229
|
+
gridStyle: h,
|
|
230
|
+
weekdayLabels: x,
|
|
231
|
+
monthLabels: c,
|
|
232
|
+
activeCell: d,
|
|
233
|
+
tooltipEnabled: C,
|
|
234
|
+
tooltipStyle: k,
|
|
235
|
+
cellColor: i,
|
|
236
|
+
cellLabel: y,
|
|
237
|
+
handleCellClick: E,
|
|
238
|
+
throttledMove: p,
|
|
239
|
+
clearActive: R,
|
|
240
|
+
isInRange: N,
|
|
241
|
+
colorPalette: L,
|
|
242
|
+
slots: r,
|
|
243
|
+
t: w
|
|
244
|
+
} = this;
|
|
245
|
+
if (!O) return null;
|
|
246
|
+
const f = _(this.loading) ? this.loading : {
|
|
247
|
+
loading: this.loading,
|
|
248
|
+
dot: "color"
|
|
249
|
+
}, g = C && d !== null, S = () => l("div", {
|
|
250
|
+
class: e.element("grid"),
|
|
251
|
+
style: {
|
|
252
|
+
...h,
|
|
253
|
+
"--x-heatmap-cell-gap": "var(--x-spacing-1)"
|
|
254
|
+
},
|
|
255
|
+
onMousemove: p,
|
|
256
|
+
onMouseleave: R
|
|
257
|
+
}, [v.map((o, u) => o.map((s) => l("div", {
|
|
258
|
+
key: s.timestamp,
|
|
259
|
+
class: [e.element("cell"), e.modifier(`level-${s.level}`), {
|
|
260
|
+
[e.is("out-of-range")]: !N(s)
|
|
261
|
+
}],
|
|
262
|
+
style: {
|
|
263
|
+
backgroundColor: i(s)
|
|
264
|
+
},
|
|
265
|
+
"data-index": I.indexOf(s),
|
|
266
|
+
title: g ? void 0 : y(s),
|
|
267
|
+
onClick: (M) => E(s, M),
|
|
268
|
+
role: "gridcell",
|
|
269
|
+
"aria-label": y(s)
|
|
270
|
+
}, [])))]), Y = () => {
|
|
271
|
+
if (!g || !d) return null;
|
|
272
|
+
const o = {
|
|
273
|
+
...d,
|
|
274
|
+
label: y(d)
|
|
275
|
+
};
|
|
276
|
+
return l("div", {
|
|
277
|
+
class: [e.element("tooltip"), e.is("visible")],
|
|
278
|
+
style: k,
|
|
279
|
+
role: "tooltip"
|
|
280
|
+
}, [r.tooltip ? r.tooltip(o) : o.label]);
|
|
281
|
+
}, z = () => {
|
|
282
|
+
var o, u;
|
|
283
|
+
return this.showColorIndicator ? l("div", {
|
|
284
|
+
class: e.element("indicator")
|
|
285
|
+
}, [r.indicator ? r.indicator({
|
|
286
|
+
colors: L
|
|
287
|
+
}) : l(j, null, [l("span", {
|
|
288
|
+
class: e.element("indicator-leading")
|
|
289
|
+
}, [((o = r["indicator-leading-text"]) == null ? void 0 : o.call(r)) ?? w("heatmap.less")]), L.map((s, M) => l("span", {
|
|
290
|
+
key: M,
|
|
291
|
+
class: e.element("indicator-swatch"),
|
|
292
|
+
style: {
|
|
293
|
+
backgroundColor: s
|
|
294
|
+
}
|
|
295
|
+
}, null)), l("span", {
|
|
296
|
+
class: e.element("indicator-trailing")
|
|
297
|
+
}, [((u = r["indicator-trailing-text"]) == null ? void 0 : u.call(r)) ?? w("heatmap.more")])])]) : null;
|
|
298
|
+
}, B = () => l("div", {
|
|
299
|
+
class: e.element("body")
|
|
300
|
+
}, [this.showWeekLabels && l("div", {
|
|
301
|
+
class: e.element("week-labels"),
|
|
302
|
+
style: h
|
|
303
|
+
}, [x.map((o, u) => l("span", {
|
|
304
|
+
key: u,
|
|
305
|
+
class: e.element("week-label"),
|
|
306
|
+
style: {
|
|
307
|
+
visibility: u % 2 === 1 ? "visible" : "hidden"
|
|
308
|
+
}
|
|
309
|
+
}, [o]))]), l("div", {
|
|
310
|
+
class: e.element("grid-wrapper")
|
|
311
|
+
}, [this.showMonthLabels && l("div", {
|
|
312
|
+
class: e.element("month-labels"),
|
|
313
|
+
style: h
|
|
314
|
+
}, [c.map((o) => l("span", {
|
|
315
|
+
key: o.text,
|
|
316
|
+
class: e.element("month-label"),
|
|
317
|
+
style: {
|
|
318
|
+
gridColumn: o.colIndex + 1
|
|
319
|
+
}
|
|
320
|
+
}, [o.text]))]), S()]), Y()]);
|
|
321
|
+
return l("div", {
|
|
322
|
+
class: [e.block, e.modifier(`size-${b}`)],
|
|
323
|
+
role: this.ariaLabel ? "img" : void 0,
|
|
324
|
+
"aria-label": this.ariaLabel
|
|
325
|
+
}, [l(H, f, {
|
|
326
|
+
default: () => [B(), z(), r.footer && l("div", {
|
|
327
|
+
class: e.element("footer")
|
|
328
|
+
}, [r.footer()])]
|
|
329
|
+
})]);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
export {
|
|
333
|
+
ue as default
|
|
334
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { dayjs as l } from "../../../_utils/date.js";
|
|
2
|
+
const E = {
|
|
3
|
+
small: 10,
|
|
4
|
+
medium: 12,
|
|
5
|
+
large: 16
|
|
6
|
+
}, v = 5, h = (e, a) => {
|
|
7
|
+
const t = (e.day() - a + 7) % 7;
|
|
8
|
+
return e.subtract(t, "day");
|
|
9
|
+
}, b = (e) => typeof e == "number" ? l(e) : l(e), I = (e, a) => {
|
|
10
|
+
const { year: t, startDate: s, endDate: n, data: f } = e;
|
|
11
|
+
let o = null, r = null;
|
|
12
|
+
if (typeof t == "number" && Number.isFinite(t)) {
|
|
13
|
+
const i = l(`${t}-01-01`);
|
|
14
|
+
i.isValid() && (o = i, r = i.endOf("year").startOf("day"));
|
|
15
|
+
}
|
|
16
|
+
if (!o && (s !== void 0 || n !== void 0)) {
|
|
17
|
+
if (s !== void 0) {
|
|
18
|
+
const i = b(s);
|
|
19
|
+
i.isValid() && (o = i);
|
|
20
|
+
}
|
|
21
|
+
if (n !== void 0) {
|
|
22
|
+
const i = b(n);
|
|
23
|
+
i.isValid() && (r = i);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (!o || !r) {
|
|
27
|
+
const i = (f ?? []).filter(
|
|
28
|
+
(m) => m && Number.isFinite(m.timestamp)
|
|
29
|
+
);
|
|
30
|
+
if (i.length) {
|
|
31
|
+
const m = i.map((g) => l(g.timestamp).startOf("day").valueOf());
|
|
32
|
+
o || (o = l(Math.min(...m))), r || (r = l(Math.max(...m)));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!o || !r) return null;
|
|
36
|
+
if (o.isAfter(r)) {
|
|
37
|
+
const i = o;
|
|
38
|
+
o = r, r = i;
|
|
39
|
+
}
|
|
40
|
+
const u = o.startOf("day"), c = r.startOf("day"), y = h(u, a), d = h(c, a).add(6, "day"), p = d.diff(y, "day") + 1;
|
|
41
|
+
return {
|
|
42
|
+
start: y,
|
|
43
|
+
end: d,
|
|
44
|
+
days: p,
|
|
45
|
+
weeks: Math.ceil(p / 7),
|
|
46
|
+
/* 用户请求的原始范围(未按周对齐),用于区分补齐格 */
|
|
47
|
+
requestedStart: u,
|
|
48
|
+
requestedEnd: c
|
|
49
|
+
};
|
|
50
|
+
}, L = (e) => {
|
|
51
|
+
const a = /* @__PURE__ */ new Map();
|
|
52
|
+
return (e ?? []).forEach((t) => {
|
|
53
|
+
if (!t || !Number.isFinite(t.timestamp)) return;
|
|
54
|
+
const s = l(t.timestamp).startOf("day").valueOf(), n = t.value;
|
|
55
|
+
a.set(s, typeof n == "number" && Number.isFinite(n) ? n : null);
|
|
56
|
+
}), a;
|
|
57
|
+
}, M = (e, a, t, s) => {
|
|
58
|
+
if (typeof e != "number" || !Number.isFinite(e) || s <= 0) return 0;
|
|
59
|
+
if (t <= a) return s;
|
|
60
|
+
const n = (e - a) / (t - a), f = Math.ceil(n * s);
|
|
61
|
+
return Math.min(s, Math.max(1, f));
|
|
62
|
+
}, F = (e) => {
|
|
63
|
+
let a = 1 / 0, t = -1 / 0;
|
|
64
|
+
return (e ?? []).forEach((s) => {
|
|
65
|
+
const n = s == null ? void 0 : s.value;
|
|
66
|
+
typeof n != "number" || !Number.isFinite(n) || (n < a && (a = n), n > t && (t = n));
|
|
67
|
+
}), a === 1 / 0 ? null : { min: a, max: t };
|
|
68
|
+
}, V = (e, a, t, s) => {
|
|
69
|
+
const n = (t == null ? void 0 : t.min) ?? 0, f = (t == null ? void 0 : t.max) ?? 0;
|
|
70
|
+
return Array.from({ length: e.days }, (o, r) => {
|
|
71
|
+
const u = e.start.add(r, "day"), c = u.valueOf(), d = a.has(c) ? a.get(c) ?? null : null;
|
|
72
|
+
return {
|
|
73
|
+
timestamp: c,
|
|
74
|
+
date: u,
|
|
75
|
+
value: d,
|
|
76
|
+
level: M(d, n, f, s),
|
|
77
|
+
rowIndex: r % 7,
|
|
78
|
+
colIndex: Math.floor(r / 7)
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}, D = (e, a, t) => {
|
|
82
|
+
const s = [];
|
|
83
|
+
for (let n = 0; n < e.weeks; n += 1) {
|
|
84
|
+
const f = a[n * 7];
|
|
85
|
+
if (!f) continue;
|
|
86
|
+
const o = f.date.format("YYYY-MM"), r = s[s.length - 1];
|
|
87
|
+
if (r && r.monthKey === o) {
|
|
88
|
+
r.span += 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
s.push({ monthKey: o, text: t(f.date), colIndex: n, span: 1 });
|
|
92
|
+
}
|
|
93
|
+
return s.filter((n) => n.span >= 3 || s.length <= 2).map(({ text: n, colIndex: f }) => ({ text: n, colIndex: f }));
|
|
94
|
+
}, N = (e, a, t) => !e.date.isBefore(a, "day") && !e.date.isAfter(t, "day");
|
|
95
|
+
export {
|
|
96
|
+
E as CELL_SIZE,
|
|
97
|
+
v as DEFAULT_COLOR_LEVELS,
|
|
98
|
+
V as buildMatrix,
|
|
99
|
+
M as getColorLevel,
|
|
100
|
+
D as getMonthLabels,
|
|
101
|
+
F as getValueExtent,
|
|
102
|
+
L as indexDataByDay,
|
|
103
|
+
N as isCellInRequestedRange,
|
|
104
|
+
I as resolveRange,
|
|
105
|
+
h as startOfWeekByDay
|
|
106
|
+
};
|