x-next 1.4.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.
Files changed (144) hide show
  1. package/AI_USAGE.md +2 -2
  2. package/CHANGELOG.md +71 -0
  3. package/dist/_utils/color.d.ts +53 -0
  4. package/dist/components/color-picker/ColorPicker.d.ts +239 -0
  5. package/dist/components/color-picker/gradient-slider.d.ts +52 -0
  6. package/dist/components/color-picker/index.d.ts +238 -0
  7. package/dist/components/color-picker/panel.d.ts +721 -0
  8. package/dist/components/color-picker/sv-panel.d.ts +48 -0
  9. package/dist/components/date-picker/DatePicker.vue.d.ts +3 -3
  10. package/dist/components/date-picker/index.d.ts +6 -6
  11. package/dist/components/dropdown/Dropdown.vue.d.ts +34 -4
  12. package/dist/components/dropdown/DropdownButton.vue.d.ts +37 -6
  13. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +34 -4
  14. package/dist/components/dropdown/dropdown-panel.vue.d.ts +30 -0
  15. package/dist/components/dropdown/index.d.ts +212 -29
  16. package/dist/components/form/FormItem.vue.d.ts +3 -3
  17. package/dist/components/form/form-item-label.vue.d.ts +3 -3
  18. package/dist/components/form/index.d.ts +6 -6
  19. package/dist/components/form-select/Select.d.ts +3 -3
  20. package/dist/components/form-select/SelectDropdown.vue.d.ts +30 -0
  21. package/dist/components/form-select/index.d.ts +66 -6
  22. package/dist/components/form-slider/Slider.vue.d.ts +3 -3
  23. package/dist/components/form-slider/index.d.ts +6 -6
  24. package/dist/components/form-slider/slider-button.vue.d.ts +3 -3
  25. package/dist/components/heatmap/Heatmap.d.ts +311 -0
  26. package/dist/components/heatmap/helpers/matrix.d.ts +58 -0
  27. package/dist/components/heatmap/index.d.ts +372 -0
  28. package/dist/components/heatmap/interface.d.ts +57 -0
  29. package/dist/components/image/Image.vue.d.ts +3 -3
  30. package/dist/components/image/ImagePreview.vue.d.ts +3 -3
  31. package/dist/components/image/ImagePreviewAction.d.ts +3 -3
  32. package/dist/components/image/ImagePreviewGroup.vue.d.ts +3 -3
  33. package/dist/components/image/index.d.ts +24 -24
  34. package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
  35. package/dist/components/index.d.ts +2 -0
  36. package/dist/components/menu/sub-menu-pop.vue.d.ts +3 -3
  37. package/dist/components/network/Network.vue.d.ts +1 -1
  38. package/dist/components/network/index.d.ts +3 -3
  39. package/dist/components/network/utils.d.ts +2 -0
  40. package/dist/components/pagination/page-item-ellipsis.vue.d.ts +9 -0
  41. package/dist/components/pagination/page-jumper.vue.d.ts +6 -0
  42. package/dist/components/pagination/page-options.vue.d.ts +6 -6
  43. package/dist/components/popover/Popover.d.ts +1 -1
  44. package/dist/components/popover/index.d.ts +3 -3
  45. package/dist/components/popup/Popup.d.ts +1 -1
  46. package/dist/components/popup/index.d.ts +3 -3
  47. package/dist/components/skeleton/SkeletonShape.vue.d.ts +3 -3
  48. package/dist/components/skeleton/index.d.ts +6 -6
  49. package/dist/components/spin/Spin.d.ts +38 -0
  50. package/dist/components/spin/index.d.ts +30 -0
  51. package/dist/components/steps/context.d.ts +9 -0
  52. package/dist/components/table/Table.d.ts +1 -1
  53. package/dist/components/table/index.d.ts +3 -3
  54. package/dist/components/tabs/TabPane.vue.d.ts +2 -0
  55. package/dist/components/tabs/Tabs.d.ts +1 -1
  56. package/dist/components/tabs/index.d.ts +9 -3
  57. package/dist/components/tabs/interface.d.ts +4 -0
  58. package/dist/components/time-picker/TimePicker.vue.d.ts +3 -3
  59. package/dist/components/time-picker/index.d.ts +6 -6
  60. package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
  61. package/dist/components/tooltip/index.d.ts +3 -3
  62. package/dist/components/trigger/Trigger.d.ts +1 -1
  63. package/dist/components/trigger/index.d.ts +3 -3
  64. package/dist/components/watermark/Watermark.d.ts +1 -1
  65. package/dist/components/watermark/index.d.ts +3 -3
  66. package/dist/es/_styles/palette-aliases.js +8 -0
  67. package/dist/es/_utils/color.js +73 -0
  68. package/dist/es/components/button/Button.js +2 -2
  69. package/dist/es/components/color-picker/ColorPicker.js +239 -0
  70. package/dist/es/components/color-picker/gradient-slider.js +79 -0
  71. package/dist/es/components/color-picker/index.js +8 -0
  72. package/dist/es/components/color-picker/panel.js +307 -0
  73. package/dist/es/components/color-picker/sv-panel.js +99 -0
  74. package/dist/es/components/dropdown/Dropdown.vue2.js +11 -4
  75. package/dist/es/components/dropdown/DropdownButton.vue.js +8 -7
  76. package/dist/es/components/dropdown/DropdownButton.vue2.js +19 -17
  77. package/dist/es/components/dropdown/DropdownSubmenu.vue.js +18 -17
  78. package/dist/es/components/dropdown/dropdown-panel.vue.js +17 -17
  79. package/dist/es/components/form-input/Input.js +7 -7
  80. package/dist/es/components/form-input/InputPassword.vue2.js +2 -2
  81. package/dist/es/components/form-input/InputSearch.js +2 -2
  82. package/dist/es/components/form-input-number/InputNumber.js +12 -12
  83. package/dist/es/components/heatmap/Heatmap.js +334 -0
  84. package/dist/es/components/heatmap/helpers/matrix.js +106 -0
  85. package/dist/es/components/heatmap/index.js +8 -0
  86. package/dist/es/components/index.js +118 -114
  87. package/dist/es/components/menu/MenuSubMenu.js +50 -36
  88. package/dist/es/components/menu/sub-menu-pop.vue2.js +30 -30
  89. package/dist/es/components/network/Network.vue2.js +72 -72
  90. package/dist/es/components/network/utils.js +44 -35
  91. package/dist/es/components/pagination/Pagination.js +124 -112
  92. package/dist/es/components/pagination/page-item-ellipsis.vue.js +13 -12
  93. package/dist/es/components/pagination/page-item-ellipsis.vue2.js +19 -15
  94. package/dist/es/components/pagination/page-jumper.vue.js +13 -12
  95. package/dist/es/components/pagination/page-jumper.vue2.js +7 -4
  96. package/dist/es/components/pagination/page-options.vue.js +4 -3
  97. package/dist/es/components/pagination/page-options.vue2.js +17 -15
  98. package/dist/es/components/skeleton/Skeleton.vue.js +11 -9
  99. package/dist/es/components/skeleton/SkeletonLine.vue.js +9 -8
  100. package/dist/es/components/skeleton/SkeletonShape.vue.js +8 -7
  101. package/dist/es/components/spin/Spin.js +124 -60
  102. package/dist/es/components/steps/Step.vue2.js +51 -47
  103. package/dist/es/components/steps/Steps.vue2.js +22 -19
  104. package/dist/es/components/table/Table.js +3 -1
  105. package/dist/es/components/tabs/TabPane.vue.js +11 -9
  106. package/dist/es/components/tabs/TabPane.vue2.js +28 -24
  107. package/dist/es/components/tabs/tabs-nav.js +20 -18
  108. package/dist/es/components/tabs/tabs-tab.vue.js +10 -8
  109. package/dist/es/components/trigger/Trigger.js +19 -19
  110. package/dist/es/icons/_self/empty-better.js +25 -8
  111. package/dist/es/index.js +162 -158
  112. package/dist/es/locale/en-US.js +19 -2
  113. package/dist/es/locale/zh-CN.js +19 -2
  114. package/dist/es/style.css +1 -1
  115. package/dist/index.cjs +4 -4
  116. package/dist/index.umd.js +4 -4
  117. package/dist/locale/interface.d.ts +30 -0
  118. package/dist/style/base.css +1 -1
  119. package/dist/style/button.css +1 -1
  120. package/dist/style/color-picker.css +1 -0
  121. package/dist/style/color-picker.js +2 -0
  122. package/dist/style/date-picker.css +1 -1
  123. package/dist/style/dropdown.css +1 -1
  124. package/dist/style/empty.css +1 -1
  125. package/dist/style/form-checkbox.css +1 -1
  126. package/dist/style/form-input-tag.css +1 -1
  127. package/dist/style/form-input.css +1 -1
  128. package/dist/style/form-radio.css +1 -1
  129. package/dist/style/form-textarea.css +1 -1
  130. package/dist/style/form.css +1 -1
  131. package/dist/style/heatmap.css +1 -0
  132. package/dist/style/heatmap.js +2 -0
  133. package/dist/style/image.css +1 -1
  134. package/dist/style/menu.css +1 -1
  135. package/dist/style/pagination.css +1 -1
  136. package/dist/style/skeleton.css +1 -1
  137. package/dist/style/spin.css +1 -1
  138. package/dist/style/steps.css +1 -1
  139. package/dist/style/table.css +1 -1
  140. package/dist/style/tabs.css +1 -1
  141. package/dist/style.css +1 -1
  142. package/dist/types.d.ts +2 -0
  143. package/package.json +3 -2
  144. package/volar.d.ts +2 -0
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as ce, toRefs as de, ref as h, computed as r, watch as fe, createVNode as i, mergeProps as F, createTextVNode as me, nextTick as ve } from "vue";
2
- import { INPUT_EVENTS as R } from "../../_utils/constant.js";
2
+ import { INPUT_EVENTS as _ } from "../../_utils/constant.js";
3
3
  import pe from "../_components/feedback-icon/index.vue.js";
4
4
  import { Enter as he } from "../../_utils/keycode.js";
5
5
  import ge from "../_components/icon-hover/index.vue.js";
@@ -229,7 +229,7 @@ const Ke = /* @__PURE__ */ ce({
229
229
  var n, a;
230
230
  I.value = !1, k(c.value, e), s("blur", e), (a = (n = v.value) == null ? void 0 : n.onBlur) == null || a.call(n, e);
231
231
  }, E = (e) => {
232
- var L, O;
232
+ var L, R;
233
233
  const {
234
234
  value: n,
235
235
  selectionStart: a,
@@ -240,7 +240,7 @@ const Ke = /* @__PURE__ */ ce({
240
240
  b();
241
241
  return;
242
242
  }
243
- S(n), s("input", n, e), (O = (L = v.value) == null ? void 0 : L.onInput) == null || O.call(L, e), b();
243
+ S(n), s("input", n, e), (R = (L = v.value) == null ? void 0 : L.onInput) == null || R.call(L, e), b();
244
244
  } else
245
245
  x.value = !0, A.value = c.value + (e.data ?? "");
246
246
  }, b = () => {
@@ -265,7 +265,7 @@ const Ke = /* @__PURE__ */ ce({
265
265
  }, ae = (e) => {
266
266
  const n = e.key || e.code;
267
267
  !x.value && n === he.key && (k(c.value, e), s("pressEnter", e));
268
- }, M = r(() => j(j(m, R), ["class", "style"])), le = r(() => xe(m, R)), ue = r(() => [l.element("outer"), m.class, l.element(`outer-size-${N.value}`), {
268
+ }, M = r(() => j(j(m, _), ["class", "style"])), le = r(() => xe(m, _)), ue = r(() => [l.element("outer"), m.class, l.element(`outer-size-${N.value}`), {
269
269
  [l.element("outer-has-suffix")]: !!u.suffix,
270
270
  [l.element("outer-disabled")]: g.value
271
271
  }]), oe = (e) => [l.element("wrapper"), !e && m.class, {
@@ -280,7 +280,7 @@ const Ke = /* @__PURE__ */ ce({
280
280
  ...ie.value
281
281
  };
282
282
  return T.value && (e["aria-invalid"] = !0), e;
283
- }), _ = (e) => {
283
+ }), O = (e) => {
284
284
  var n;
285
285
  return i("span", F({
286
286
  class: oe(e),
@@ -330,9 +330,9 @@ const Ke = /* @__PURE__ */ ce({
330
330
  style: m.style
331
331
  }, M.value), [u.prepend && i("span", {
332
332
  class: l.element("prepend")
333
- }, [u.prepend()]), _(!0), u.append && i("span", {
333
+ }, [u.prepend()]), O(!0), u.append && i("span", {
334
334
  class: l.element("append")
335
- }, [u.append()])]) : _()
335
+ }, [u.append()])]) : O()
336
336
  };
337
337
  },
338
338
  methods: {
@@ -5,7 +5,7 @@ import h from "../../icons/default/eye-invisible.js";
5
5
  import g from "../../_hooks/use-merge-state.js";
6
6
  import { useLocale as B } from "../../locale/index.js";
7
7
  import R from "./Input.js";
8
- import { useFormItem as _ } from "../../_hooks/use-form-item.js";
8
+ import { useFormItem as E } from "../../_hooks/use-form-item.js";
9
9
  const M = d({
10
10
  name: "InputPassword",
11
11
  components: {
@@ -59,7 +59,7 @@ const M = d({
59
59
  "update:visibility"
60
60
  ],
61
61
  setup(e, { emit: o }) {
62
- const { visibility: l, defaultVisibility: a, disabled: n } = c(e), r = v(), { t: u } = B(), { mergedDisabled: s } = _({ disabled: n }), f = () => {
62
+ const { visibility: l, defaultVisibility: a, disabled: n } = c(e), r = v(), { t: u } = B(), { mergedDisabled: s } = E({ disabled: n }), f = () => {
63
63
  s.value || m(!i.value);
64
64
  }, [i, p] = g(
65
65
  a.value,
@@ -7,7 +7,7 @@ import { Button as P } from "../button/index.js";
7
7
  import k from "./Input.js";
8
8
  import { useSize as T } from "../../_hooks/use-size.js";
9
9
  import { useFormItem as N } from "../../_hooks/use-form-item.js";
10
- import { getClassNameMixin as _ } from "../../_utils/config.js";
10
+ import { getClassNameMixin as F } from "../../_utils/config.js";
11
11
  const E = /* @__PURE__ */ x({
12
12
  name: "InputSearch",
13
13
  props: {
@@ -76,7 +76,7 @@ const E = /* @__PURE__ */ x({
76
76
  const {
77
77
  size: s,
78
78
  disabled: b
79
- } = S(e), i = _("input-search"), {
79
+ } = S(e), i = F("input-search"), {
80
80
  t: p
81
81
  } = I(), {
82
82
  mergedSize: g,
@@ -1,11 +1,11 @@
1
- import { defineComponent as G, toRefs as J, ref as V, computed as D, watch as p, onUnmounted as Q, createVNode as o, Fragment as Z } from "vue";
1
+ import { defineComponent as J, toRefs as Q, ref as V, computed as D, watch as E, onUnmounted as X, createVNode as o, Fragment as Z } from "vue";
2
2
  import O from "../../node_modules/.pnpm/number-precision@1.6.0/node_modules/number-precision/build/index.es.js";
3
3
  import { isNumber as s, isUndefined as ee } from "../../_utils/is.js";
4
4
  import ne from "../../icons/default/up.js";
5
5
  import ue from "../../icons/default/down.js";
6
6
  import te from "../../icons/default/plus.js";
7
7
  import ae from "../../icons/default/minus.js";
8
- import E from "../button/Button.js";
8
+ import _ from "../button/Button.js";
9
9
  import { Input as le } from "../form-input/index.js";
10
10
  import { useFormItem as ie } from "../../_hooks/use-form-item.js";
11
11
  import { useSize as re } from "../../_hooks/use-size.js";
@@ -13,7 +13,7 @@ import { getKeyDownHandler as de, KEYBOARD_KEY as A } from "../../_utils/keyboar
13
13
  import { getClassNameMixin as oe } from "../../_utils/config.js";
14
14
  const fe = 800, me = 150;
15
15
  O.enableBoundaryChecking(!1);
16
- const Ie = /* @__PURE__ */ G({
16
+ const Ie = /* @__PURE__ */ J({
17
17
  name: "InputNumber",
18
18
  props: {
19
19
  /**
@@ -232,7 +232,7 @@ const Ie = /* @__PURE__ */ G({
232
232
  const {
233
233
  size: F,
234
234
  disabled: P
235
- } = J(n), d = oe("input-number"), B = V(), {
235
+ } = Q(n), d = oe("input-number"), B = V(), {
236
236
  mergedSize: $,
237
237
  mergedDisabled: v,
238
238
  eventHandlers: I
@@ -272,7 +272,7 @@ const Ie = /* @__PURE__ */ G({
272
272
  const e = R(l.value), u = w(e);
273
273
  (e !== l.value || f.value !== u) && (f.value = u), i("update:modelValue", e);
274
274
  };
275
- p(() => [n.max, n.min], () => {
275
+ E(() => [n.max, n.min], () => {
276
276
  z(), M(l.value);
277
277
  });
278
278
  const N = (e, u) => {
@@ -295,8 +295,8 @@ const Ie = /* @__PURE__ */ G({
295
295
  x = window.setTimeout(c, fe);
296
296
  }
297
297
  }, k = (e, u) => {
298
- var t, r, c, _;
299
- e = e.trim().replace(/。/g, "."), e = ((t = n.parser) == null ? void 0 : t.call(n, e)) ?? e, (s(Number(e)) || /^(\.|-)$/.test(e)) && (f.value = ((r = n.formatter) == null ? void 0 : r.call(n, e)) ?? e, M(l.value), i("input", l.value, f.value, u), n.modelEvent === "input" && (i("update:modelValue", l.value), i("change", l.value, u), (_ = (c = I.value) == null ? void 0 : c.onChange) == null || _.call(c, u)));
298
+ var t, r, c, p;
299
+ e = e.trim().replace(/。/g, "."), e = ((t = n.parser) == null ? void 0 : t.call(n, e)) ?? e, (s(Number(e)) || /^(\.|-)$/.test(e)) && (f.value = ((r = n.formatter) == null ? void 0 : r.call(n, e)) ?? e, M(l.value), i("input", l.value, f.value, u), n.modelEvent === "input" && (i("update:modelValue", l.value), i("change", l.value, u), (p = (c = I.value) == null ? void 0 : c.onChange) == null || p.call(c, u)));
300
300
  }, T = (e) => {
301
301
  i("focus", e);
302
302
  }, K = (e, u) => {
@@ -313,7 +313,7 @@ const Ie = /* @__PURE__ */ G({
313
313
  }]])), Y = (e) => {
314
314
  i("keydown", e), e.defaultPrevented || W(e);
315
315
  };
316
- p(() => n.modelValue, (e) => {
316
+ E(() => n.modelValue, (e) => {
317
317
  e !== l.value && (f.value = w(e), M(e));
318
318
  });
319
319
  const q = () => {
@@ -345,7 +345,7 @@ const Ie = /* @__PURE__ */ G({
345
345
  }, [a.minus ? (t = a.minus) == null ? void 0 : t.call(a) : o(ue, null, null)])])]);
346
346
  }, L = D(() => [d.block, d.modifier(`mode-${n.mode}`), d.modifier(`size-${g.value}`), {
347
347
  [d.modifier("readonly")]: n.readOnly
348
- }]), j = () => o(E, {
348
+ }]), j = () => o(_, {
349
349
  size: g.value,
350
350
  shape: "square",
351
351
  narrow: !0,
@@ -357,7 +357,7 @@ const Ie = /* @__PURE__ */ G({
357
357
  onMouseleave: m
358
358
  }, {
359
359
  icon: () => o(ae, null, null)
360
- }), X = () => o(E, {
360
+ }), G = () => o(_, {
361
361
  size: g.value,
362
362
  shape: "square",
363
363
  narrow: !0,
@@ -370,7 +370,7 @@ const Ie = /* @__PURE__ */ G({
370
370
  }, {
371
371
  icon: () => o(te, null, null)
372
372
  });
373
- return Q(m), {
373
+ return X(m), {
374
374
  inputRef: B,
375
375
  render: () => {
376
376
  const e = n.mode === "embed" ? {
@@ -382,7 +382,7 @@ const Ie = /* @__PURE__ */ G({
382
382
  prepend: n.hideButton ? a.prepend : j,
383
383
  prefix: a.prefix,
384
384
  suffix: a.suffix,
385
- append: n.hideButton ? a.append : X
385
+ append: n.hideButton ? a.append : G
386
386
  };
387
387
  return o(le, {
388
388
  key: `input-number-${n.mode}`,
@@ -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
+ };
@@ -0,0 +1,8 @@
1
+ import t from "./Heatmap.js";
2
+ import { generateComponent as e } from "../../_utils/vue-eco.js";
3
+ import { getComponentPrefix as o } from "../../_utils/config.js";
4
+ const r = e(o("Heatmap"), t);
5
+ export {
6
+ r as Heatmap,
7
+ r as default
8
+ };