@kiva/kv-components 8.27.0 → 8.28.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.
@@ -1 +1 @@
1
- .segment-circle[data-v-73c9f5f9]{transition:stroke-dashoffset .5s ease-in-out}.skeleton-ring[data-v-73c9f5f9]{opacity:1;transition:opacity .5s ease-in-out}.skeleton-ring--loading[data-v-73c9f5f9]{animation:skeleton-ring-pulse-73c9f5f9 1.4s ease-in-out infinite;transform-origin:center}.legend-dot[data-v-73c9f5f9]{transition:background-color .5s ease-in-out}@keyframes skeleton-ring-pulse-73c9f5f9{0%,to{opacity:.45}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.skeleton-ring--loading[data-v-73c9f5f9]{animation:none}}
1
+ .segment-circle[data-v-9afd557d]{transition:stroke-dashoffset var(--segment-grow-duration, .5s) ease-in-out}.skeleton-ring[data-v-9afd557d]{opacity:1;transition:opacity .5s ease-in-out}.skeleton-ring--loading[data-v-9afd557d]{animation:skeleton-ring-pulse-9afd557d 1.4s ease-in-out infinite;transform-origin:center}.legend-dot[data-v-9afd557d]{transition:background-color .5s ease-in-out}@keyframes skeleton-ring-pulse-9afd557d{0%,to{opacity:.45}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.skeleton-ring--loading[data-v-9afd557d]{animation:none}}
@@ -1,29 +1,30 @@
1
1
  import y from "./KvPieChartV22.js";
2
- import { resolveComponent as x, openBlock as l, createElementBlock as o, createElementVNode as r, normalizeClass as k, createCommentVNode as n, Fragment as d, renderList as c, normalizeStyle as s, toDisplayString as w, createBlock as _, withCtx as b } from "vue";
2
+ import { resolveComponent as x, openBlock as l, createElementBlock as o, normalizeStyle as s, createElementVNode as r, normalizeClass as k, createCommentVNode as n, Fragment as d, renderList as c, toDisplayString as w, createBlock as _, withCtx as b } from "vue";
3
3
  import "./KvPieChartV2.css";
4
4
  import u from "../_virtual/_plugin-vue_export-helper.js";
5
- const v = {
6
- class: "kv-pie-chart-v2 tw-flex tw-flex-col tw-items-center tw-gap-1",
7
- "aria-label": "Pie chart"
8
- }, C = { class: "tw-px-2" }, D = {
5
+ const v = { class: "tw-px-2" }, C = {
9
6
  viewBox: "0 0 262 262",
10
7
  fill: "none",
11
8
  class: "tw-w-full",
12
9
  role: "img",
13
10
  "aria-hidden": "true"
14
- }, S = ["cx", "cy", "r", "stroke", "stroke-width"], L = ["cx", "cy", "r", "stroke", "stroke-width", "stroke-dasharray", "transform"], O = ["cx", "cy", "r", "stroke", "stroke-width", "stroke-dasharray", "transform"], V = {
11
+ }, D = ["cx", "cy", "r", "stroke", "stroke-width"], S = ["cx", "cy", "r", "stroke", "stroke-width", "stroke-dasharray", "transform"], L = ["cx", "cy", "r", "stroke", "stroke-width", "stroke-dasharray", "transform"], O = {
15
12
  key: 0,
16
13
  class: "tw-flex tw-flex-wrap tw-justify-center tw-gap-0.5 tw-w-full tw-pt-0.5"
17
- }, W = { class: "tw-flex tw-gap-0.5 tw-items-center tw-min-w-0 tw-overflow-hidden" }, B = { class: "tw-font-medium tw-text-small tw-text-primary tw-whitespace-nowrap tw-truncate" }, p = { class: "tw-flex tw-gap-0.5 tw-items-center tw-shrink-0" }, E = { class: "tw-grid tw-grid-cols-2 tw-grid-flow-row tw-gap-0.5" }, I = { class: "tw-flex tw-gap-0.5 tw-items-center tw-shrink-0 tw-overflow-hidden" }, X = { class: "tw-font-medium tw-text-small tw-text-primary tw-whitespace-nowrap tw-truncate" }, Y = {
14
+ }, V = { class: "tw-flex tw-gap-0.5 tw-items-center tw-min-w-0 tw-overflow-hidden" }, W = { class: "tw-font-medium tw-text-small tw-text-primary tw-whitespace-nowrap tw-truncate" }, B = { class: "tw-flex tw-gap-0.5 tw-items-center tw-shrink-0" }, E = { class: "tw-grid tw-grid-cols-2 tw-grid-flow-row tw-gap-0.5" }, I = { class: "tw-flex tw-gap-0.5 tw-items-center tw-shrink-0 tw-overflow-hidden" }, X = { class: "tw-font-medium tw-text-small tw-text-primary tw-whitespace-nowrap tw-truncate" }, Y = {
18
15
  class: "tw-font-light tw-text-small tw-text-primary tw-text-right tw-shrink-0 tw-tabular-nums",
19
16
  style: { "min-width": "2.8ch" }
20
17
  };
21
- function G(N, i, a, t, M, R) {
18
+ function G(N, i, a, t, p, M) {
22
19
  var h, m;
23
- const f = x("kv-lightbox");
24
- return l(), o("figure", v, [
25
- r("div", C, [
26
- (l(), o("svg", D, [
20
+ const g = x("kv-lightbox");
21
+ return l(), o("figure", {
22
+ class: "kv-pie-chart-v2 tw-flex tw-flex-col tw-items-center tw-gap-1",
23
+ style: s({ "--segment-grow-duration": `${a.growDuration}ms` }),
24
+ "aria-label": "Pie chart"
25
+ }, [
26
+ r("div", v, [
27
+ (l(), o("svg", C, [
27
28
  a.loading || !t.hasData ? (l(), o("circle", {
28
29
  key: 0,
29
30
  cx: t.CX,
@@ -33,7 +34,7 @@ function G(N, i, a, t, M, R) {
33
34
  "stroke-width": a.strokeWidth,
34
35
  fill: "none",
35
36
  class: k(["skeleton-ring", { "skeleton-ring--loading": a.loading }])
36
- }, null, 10, S)) : n("", !0),
37
+ }, null, 10, D)) : n("", !0),
37
38
  (l(!0), o(d, null, c(t.visibleSegments, (e) => (l(), o("circle", {
38
39
  key: e.label,
39
40
  cx: t.CX,
@@ -49,7 +50,7 @@ function G(N, i, a, t, M, R) {
49
50
  strokeDashoffset: e.isVisible ? 0 : e.dashLength,
50
51
  transitionDelay: `${e.delay}ms`
51
52
  })
52
- }, null, 12, L))), 128)),
53
+ }, null, 12, S))), 128)),
53
54
  t.otherSegment ? (l(), o("circle", {
54
55
  key: 1,
55
56
  cx: t.CX,
@@ -65,15 +66,15 @@ function G(N, i, a, t, M, R) {
65
66
  strokeDashoffset: t.otherSegment.isVisible ? 0 : t.otherSegment.dashLength,
66
67
  transitionDelay: `${t.otherSegment.delay}ms`
67
68
  })
68
- }, null, 12, O)) : n("", !0)
69
+ }, null, 12, L)) : n("", !0)
69
70
  ]))
70
71
  ]),
71
- t.hasData && !a.loading ? (l(), o("div", V, [
72
- (l(!0), o(d, null, c(t.visibleSegments, (e, g) => (l(), o("div", {
72
+ t.hasData && !a.loading ? (l(), o("div", O, [
73
+ (l(!0), o(d, null, c(t.visibleSegments, (e, f) => (l(), o("div", {
73
74
  key: e.label,
74
75
  class: "tw-bg-gray-100 tw-flex tw-gap-0.5 tw-items-center tw-px-1 tw-py-0.5 tw-rounded-xs"
75
76
  }, [
76
- r("div", W, [
77
+ r("div", V, [
77
78
  r("span", {
78
79
  class: "tw-shrink-0 tw-w-1 tw-h-1 tw-rounded-full legend-dot",
79
80
  style: s({
@@ -81,12 +82,12 @@ function G(N, i, a, t, M, R) {
81
82
  transitionDelay: `${e.delay}ms`
82
83
  })
83
84
  }, null, 4),
84
- r("span", B, w(e.label), 1)
85
+ r("span", W, w(e.label), 1)
85
86
  ]),
86
87
  r("span", {
87
88
  class: "tw-font-light tw-text-small tw-text-primary tw-text-right tw-shrink-0 tw-tabular-nums",
88
89
  style: s({ minWidth: t.valueMinWidth })
89
- }, w(t.formatDisplayValue(g)), 5)
90
+ }, w(t.formatDisplayValue(f)), 5)
90
91
  ]))), 128)),
91
92
  t.otherItems.length > 0 ? (l(), o("button", {
92
93
  key: 0,
@@ -94,7 +95,7 @@ function G(N, i, a, t, M, R) {
94
95
  type: "button",
95
96
  onClick: i[0] || (i[0] = (e) => t.showOtherLightbox = !0)
96
97
  }, [
97
- r("div", p, [
98
+ r("div", B, [
98
99
  r("span", {
99
100
  class: "tw-shrink-0 tw-w-1 tw-h-1 tw-rounded-full legend-dot",
100
101
  style: s({
@@ -110,7 +111,7 @@ function G(N, i, a, t, M, R) {
110
111
  }, w(t.formatOtherDisplayValue()), 5)
111
112
  ])) : n("", !0)
112
113
  ])) : n("", !0),
113
- t.hasData && !a.loading ? (l(), _(f, {
114
+ t.hasData && !a.loading ? (l(), _(g, {
114
115
  key: 1,
115
116
  visible: t.showOtherLightbox,
116
117
  title: "Other",
@@ -135,9 +136,9 @@ function G(N, i, a, t, M, R) {
135
136
  ]),
136
137
  _: 1
137
138
  }, 8, ["visible"])) : n("", !0)
138
- ]);
139
+ ], 4);
139
140
  }
140
- const A = /* @__PURE__ */ u(y, [["render", G], ["__scopeId", "data-v-73c9f5f9"]]);
141
+ const T = /* @__PURE__ */ u(y, [["render", G], ["__scopeId", "data-v-9afd557d"]]);
141
142
  export {
142
- A as default
143
+ T as default
143
144
  };
@@ -45,6 +45,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
45
45
  type: NumberConstructor;
46
46
  default: number;
47
47
  };
48
+ growDuration: {
49
+ type: NumberConstructor;
50
+ default: number;
51
+ };
48
52
  animateOut: {
49
53
  type: BooleanConstructor;
50
54
  default: boolean;
@@ -108,6 +112,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
108
112
  type: NumberConstructor;
109
113
  default: number;
110
114
  };
115
+ growDuration: {
116
+ type: NumberConstructor;
117
+ default: number;
118
+ };
111
119
  animateOut: {
112
120
  type: BooleanConstructor;
113
121
  default: boolean;
@@ -120,6 +128,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
120
128
  unit: PieChartUnit;
121
129
  shownSegments: number;
122
130
  segmentGap: number;
131
+ growDuration: number;
123
132
  animateOut: boolean;
124
133
  }, {}, {
125
134
  KvLightbox: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
@@ -1,8 +1,8 @@
1
1
  import { toRefs as z, ref as I, computed as u, onMounted as J, watch as U, onUnmounted as Q } from "vue";
2
- import { getPieChartColor as $, OTHER_SEGMENT_BG_COLOR as Z, LOADING_BG_COLOR as ee } from "../utils/pieChartColors.js";
2
+ import { getPieChartColor as D, OTHER_SEGMENT_BG_COLOR as Z, LOADING_BG_COLOR as ee } from "../utils/pieChartColors.js";
3
3
  import { easeInOutCubic as te } from "../utils/useCountUp.js";
4
4
  import ae from "./KvLightbox.js";
5
- const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
5
+ const E = 262, le = E / 2, ne = E / 2, ce = {
6
6
  name: "KvPieChartV2",
7
7
  components: {
8
8
  KvLightbox: ae
@@ -62,6 +62,15 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
62
62
  type: Number,
63
63
  default: 1e3
64
64
  },
65
+ /**
66
+ * Duration in milliseconds of each segment's grow animation. The stagger between
67
+ * segments and the count-up pacing use this same value, so lowering it speeds up
68
+ * the whole ring — draw and numbers — in sync. Default keeps the original timing.
69
+ */
70
+ growDuration: {
71
+ type: Number,
72
+ default: 500
73
+ },
65
74
  /**
66
75
  * When changed from false to true, plays the reverse sweep-out animation.
67
76
  */
@@ -72,61 +81,62 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
72
81
  },
73
82
  setup(g) {
74
83
  const {
75
- values: A,
84
+ values: M,
76
85
  unit: m,
77
- loading: M,
86
+ loading: w,
78
87
  shownSegments: d,
79
- strokeWidth: B,
80
- segmentGap: T,
81
- initialDelay: D,
82
- animateOut: y
83
- } = z(g), k = I(!1), c = I(!1), G = u(() => Math.max((E - B.value) / 2, 1)), b = u(() => 2 * Math.PI * G.value), h = u(() => [...A.value].sort((e, t) => t.value - e.value)), o = u(() => h.value.reduce((e, t) => e + t.value, 0)), O = u(() => A.value.length > 0), S = u(() => h.value.slice(0, d.value)), C = u(() => h.value.slice(d.value).map((t, n) => ({
88
+ strokeWidth: W,
89
+ segmentGap: A,
90
+ initialDelay: T,
91
+ growDuration: y,
92
+ animateOut: b
93
+ } = z(g), k = I(!1), c = I(!1), V = u(() => Math.max((E - W.value) / 2, 1)), C = u(() => 2 * Math.PI * V.value), h = u(() => [...M.value].sort((e, t) => t.value - e.value)), o = u(() => h.value.reduce((e, t) => e + t.value, 0)), L = u(() => M.value.length > 0), S = u(() => h.value.slice(0, d.value)), O = u(() => h.value.slice(d.value).map((t, n) => ({
84
94
  ...t,
85
- color: $(d.value + n, t.color)
95
+ color: D(d.value + n, t.color)
86
96
  }))), q = u(() => h.value.map((e, t) => ({
87
97
  ...e,
88
- color: $(t, e.color)
89
- }))), w = u(() => C.value.reduce((e, t) => e + t.value, 0)), R = u(() => o.value > 0 ? w.value / o.value : 0), f = u(() => {
98
+ color: D(t, e.color)
99
+ }))), x = u(() => O.value.reduce((e, t) => e + t.value, 0)), N = u(() => o.value > 0 ? x.value / o.value : 0), f = u(() => {
90
100
  let e = 0;
91
101
  return S.value.map((t, n) => {
92
- const a = o.value > 0 ? t.value / o.value : 0, l = Math.max(a * b.value - T.value, 0), s = e * 360 - 90;
102
+ const a = o.value > 0 ? t.value / o.value : 0, l = Math.max(a * C.value - A.value, 0), s = e * 360 - 90;
93
103
  return e += a, {
94
104
  label: t.label,
95
105
  value: t.value,
96
106
  percent: a,
97
- color: $(n, t.color),
107
+ color: D(n, t.color),
98
108
  dashLength: l,
99
109
  startDeg: s,
100
- delay: D.value + n * W,
101
- isVisible: c.value && !y.value
110
+ delay: T.value + n * y.value,
111
+ isVisible: c.value && !b.value
102
112
  };
103
113
  });
104
114
  }), v = u(() => {
105
- if (C.value.length === 0) return null;
115
+ if (O.value.length === 0) return null;
106
116
  let e = 0;
107
117
  S.value.forEach((l) => {
108
118
  e += o.value > 0 ? l.value / o.value : 0;
109
119
  });
110
- const t = Math.max(R.value * b.value - T.value, 0), n = e * 360 - 90, a = S.value.length;
120
+ const t = Math.max(N.value * C.value - A.value, 0), n = e * 360 - 90, a = S.value.length;
111
121
  return {
112
122
  label: "Other",
113
- value: w.value,
114
- percent: R.value,
123
+ value: x.value,
124
+ percent: N.value,
115
125
  color: "#C4C4C4",
116
126
  dashLength: t,
117
127
  startDeg: n,
118
- delay: D.value + a * W,
119
- isVisible: c.value && !y.value
128
+ delay: T.value + a * y.value,
129
+ isVisible: c.value && !b.value
120
130
  };
121
- }), r = I([]), p = [], i = [], V = (e) => m.value === "percent" ? Math.round(e.percent * 100) : e.value, _ = (e, t, n) => {
131
+ }), r = I([]), p = [], i = [], _ = (e) => m.value === "percent" ? Math.round(e.percent * 100) : e.value, F = (e, t, n) => {
122
132
  let a = null;
123
133
  function l(s) {
124
134
  a === null && (a = s);
125
- const L = s - a, P = Math.min(L / ue, 1), Y = te(P), j = Math.round(t + (n - t) * Y);
126
- r.value[e] = j, P < 1 && (i[e] = requestAnimationFrame(l));
135
+ const $ = s - a, R = Math.min($ / y.value, 1), Y = te(R), j = Math.round(t + (n - t) * Y);
136
+ r.value[e] = j, R < 1 && (i[e] = requestAnimationFrame(l));
127
137
  }
128
138
  i[e] = requestAnimationFrame(l);
129
- }, x = (e = !1) => {
139
+ }, G = (e = !1) => {
130
140
  p.forEach(clearTimeout), p.length = 0, i.forEach(cancelAnimationFrame), i.length = 0;
131
141
  const t = [
132
142
  ...f.value,
@@ -135,12 +145,12 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
135
145
  for (; r.value.length < t.length; )
136
146
  r.value.push(0);
137
147
  t.forEach((n, a) => {
138
- const l = V(n), { delay: s } = n, L = setTimeout(() => {
139
- e ? _(a, r.value[a], 0) : _(a, 0, l);
148
+ const l = _(n), { delay: s } = n, $ = setTimeout(() => {
149
+ e ? F(a, r.value[a], 0) : F(a, 0, l);
140
150
  }, s);
141
- p.push(L);
151
+ p.push($);
142
152
  });
143
- }, N = (e) => {
153
+ }, P = (e) => {
144
154
  const t = r.value[e] ?? 0;
145
155
  switch (m.value) {
146
156
  case "percent":
@@ -164,7 +174,7 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
164
174
  }
165
175
  }, X = () => {
166
176
  const e = f.value.length;
167
- return N(e);
177
+ return P(e);
168
178
  }, H = u(() => {
169
179
  const e = [
170
180
  ...f.value,
@@ -172,7 +182,7 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
172
182
  ];
173
183
  let t = 0;
174
184
  return e.forEach((n) => {
175
- const a = V(n);
185
+ const a = _(n);
176
186
  let l;
177
187
  switch (m.value) {
178
188
  case "percent":
@@ -186,27 +196,27 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
186
196
  }
187
197
  l.length > t && (t = l.length);
188
198
  }), `${t}ch`;
189
- }), F = () => {
199
+ }), B = () => {
190
200
  requestAnimationFrame(() => {
191
201
  requestAnimationFrame(() => {
192
- c.value = !0, x(!1);
202
+ c.value = !0, G(!1);
193
203
  });
194
204
  });
195
205
  };
196
206
  return J(() => {
197
- !M.value && O.value && F();
198
- }), U(M, (e) => {
199
- !e && O.value && F();
200
- }), U(y, (e) => {
201
- e && (c.value = !1, x(!0));
207
+ !w.value && L.value && B();
208
+ }), U(w, (e) => {
209
+ !e && L.value && B();
210
+ }), U(b, (e) => {
211
+ e && (c.value = !1, G(!0));
202
212
  }), Q(() => {
203
213
  p.forEach(clearTimeout), i.forEach(cancelAnimationFrame);
204
214
  }), {
205
215
  // Constants
206
216
  CX: le,
207
217
  CY: ne,
208
- radius: G,
209
- circumference: b,
218
+ radius: V,
219
+ circumference: C,
210
220
  LOADING_BG_COLOR: ee,
211
221
  OTHER_SEGMENT_BG_COLOR: Z,
212
222
  // State
@@ -214,19 +224,19 @@ const E = 262, le = E / 2, ne = E / 2, W = 500, ue = 500, ve = {
214
224
  animatedIn: c,
215
225
  displayValues: r,
216
226
  // Computed
217
- hasData: O,
227
+ hasData: L,
218
228
  visibleSegments: f,
219
229
  otherSegment: v,
220
- otherItems: C,
230
+ otherItems: O,
221
231
  allItemsWithColors: q,
222
232
  valueMinWidth: H,
223
233
  // Methods
224
- formatDisplayValue: N,
234
+ formatDisplayValue: P,
225
235
  formatItemValue: K,
226
236
  formatOtherDisplayValue: X
227
237
  };
228
238
  }
229
239
  };
230
240
  export {
231
- ve as default
241
+ ce as default
232
242
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "8.27.0",
3
+ "version": "8.28.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -113,5 +113,5 @@
113
113
  "dependencies": {
114
114
  "fuse.js": "^7.1.0"
115
115
  },
116
- "gitHead": "bb636116de28fdd44916765d3f498617f473ed22"
116
+ "gitHead": "88c9f72fd0eacc5c167b9697bda2527c073d7356"
117
117
  }