web-mojo 2.2.57 → 2.2.59
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/dist/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +1 -10105
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -588
- package/dist/auth.es.js.map +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +1 -571
- package/dist/charts.es.js.map +1 -1
- package/dist/chunks/ChatView-D4A9rIX3.js +2 -0
- package/dist/chunks/ChatView-D4A9rIX3.js.map +1 -0
- package/dist/chunks/ChatView-nxaq8aIo.js +2 -0
- package/dist/chunks/ChatView-nxaq8aIo.js.map +1 -0
- package/dist/chunks/Collection-1sPoIFvQ.js +2 -0
- package/dist/chunks/{Collection-DaiL0uGl.js.map → Collection-1sPoIFvQ.js.map} +1 -1
- package/dist/chunks/{Collection-CxbNKOas.js → Collection-DSBRXpwK.js} +2 -2
- package/dist/chunks/{Collection-CxbNKOas.js.map → Collection-DSBRXpwK.js.map} +1 -1
- package/dist/chunks/{ContextMenu-ClwHEbbD.js → ContextMenu-BWy7WqF4.js} +2 -2
- package/dist/chunks/{ContextMenu-ClwHEbbD.js.map → ContextMenu-BWy7WqF4.js.map} +1 -1
- package/dist/chunks/ContextMenu-BvniQz-N.js +3 -0
- package/dist/chunks/{ContextMenu-sgvgSACY.js.map → ContextMenu-BvniQz-N.js.map} +1 -1
- package/dist/chunks/DataView--nUWtq6r.js +2 -0
- package/dist/chunks/{DataView-Dzo0jbs2.js.map → DataView--nUWtq6r.js.map} +1 -1
- package/dist/chunks/{DataView-1xh3GFeC.js → DataView-CK3Z0TJH.js} +2 -2
- package/dist/chunks/{DataView-1xh3GFeC.js.map → DataView-CK3Z0TJH.js.map} +1 -1
- package/dist/chunks/Dialog-BcgSR01Z.js +2 -0
- package/dist/chunks/{Dialog-DOGDalUq.js.map → Dialog-BcgSR01Z.js.map} +1 -1
- package/dist/chunks/{Dialog-CQlTDhZS.js → Dialog-DwCTFV6O.js} +2 -2
- package/dist/chunks/{Dialog-CQlTDhZS.js.map → Dialog-DwCTFV6O.js.map} +1 -1
- package/dist/chunks/FormPlugins-DvQ-G5J5.js +2 -0
- package/dist/chunks/{FormPlugins-DY6e88YT.js.map → FormPlugins-DvQ-G5J5.js.map} +1 -1
- package/dist/chunks/{FormView-DaKA4Sys.js → FormView-CRmEReTC.js} +3 -3
- package/dist/chunks/{FormView-DaKA4Sys.js.map → FormView-CRmEReTC.js.map} +1 -1
- package/dist/chunks/FormView-OLA7t-yv.js +3 -0
- package/dist/chunks/{FormView-Dz3mYasQ.js.map → FormView-OLA7t-yv.js.map} +1 -1
- package/dist/chunks/ListView-6JQ6tRXs.js +2 -0
- package/dist/chunks/{ListView-X5w5jf51.js.map → ListView-6JQ6tRXs.js.map} +1 -1
- package/dist/chunks/{ListView-CDzKIpd8.js → ListView-DVStKiMi.js} +2 -2
- package/dist/chunks/{ListView-CDzKIpd8.js.map → ListView-DVStKiMi.js.map} +1 -1
- package/dist/chunks/{MetricsCountryMapView-Dx2cw7ya.js → MetricsCountryMapView-CnAEbUw_.js} +2 -2
- package/dist/chunks/{MetricsCountryMapView-Dx2cw7ya.js.map → MetricsCountryMapView-CnAEbUw_.js.map} +1 -1
- package/dist/chunks/MetricsCountryMapView-J067qrrt.js +2 -0
- package/dist/chunks/{MetricsCountryMapView-B2xz6zUw.js.map → MetricsCountryMapView-J067qrrt.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-CBuso0OE.js → MetricsMiniChartWidget-BeD1slGs.js} +2 -2
- package/dist/chunks/{MetricsMiniChartWidget-CBuso0OE.js.map → MetricsMiniChartWidget-BeD1slGs.js.map} +1 -1
- package/dist/chunks/MetricsMiniChartWidget-x2gFjHOU.js +2 -0
- package/dist/chunks/{MetricsMiniChartWidget-DvKd7Qrk.js.map → MetricsMiniChartWidget-x2gFjHOU.js.map} +1 -1
- package/dist/chunks/PDFViewer-CsyKn-gh.js +2 -0
- package/dist/chunks/{PDFViewer-EJ9cOfPF.js.map → PDFViewer-CsyKn-gh.js.map} +1 -1
- package/dist/chunks/{PDFViewer-ofMGdSaj.js → PDFViewer-DSa4BZCm.js} +2 -2
- package/dist/chunks/{PDFViewer-ofMGdSaj.js.map → PDFViewer-DSa4BZCm.js.map} +1 -1
- package/dist/chunks/Rest-DHbszkuP.js +2 -0
- package/dist/chunks/Rest-DHbszkuP.js.map +1 -0
- package/dist/chunks/Rest-Ds9e8tN8.js +2 -0
- package/dist/chunks/Rest-Ds9e8tN8.js.map +1 -0
- package/dist/chunks/TokenManager-D6SjKgPZ.js +2 -0
- package/dist/chunks/{TokenManager-DoN9e6q6.js.map → TokenManager-D6SjKgPZ.js.map} +1 -1
- package/dist/chunks/{TokenManager-Gqvj7SDX.js → TokenManager-REbha1Le.js} +2 -2
- package/dist/chunks/{TokenManager-Gqvj7SDX.js.map → TokenManager-REbha1Le.js.map} +1 -1
- package/dist/chunks/WebApp-CULZpO_0.js +2 -0
- package/dist/chunks/{WebApp-6qvqmOts.js.map → WebApp-CULZpO_0.js.map} +1 -1
- package/dist/chunks/{WebApp-_dgpwtFw.js → WebApp-DovLtA60.js} +2 -2
- package/dist/chunks/{WebApp-_dgpwtFw.js.map → WebApp-DovLtA60.js.map} +1 -1
- package/dist/chunks/WebSocketClient-B-wc3mez.js +2 -0
- package/dist/chunks/{WebSocketClient-DG2olXpH.js.map → WebSocketClient-B-wc3mez.js.map} +1 -1
- package/dist/chunks/{WebSocketClient-MFkFlSue.js → WebSocketClient-BdZ9QYll.js} +2 -2
- package/dist/chunks/{WebSocketClient-MFkFlSue.js.map → WebSocketClient-BdZ9QYll.js.map} +1 -1
- package/dist/chunks/version-C3dnl1bg.js +2 -0
- package/dist/chunks/version-C3dnl1bg.js.map +1 -0
- package/dist/chunks/{version-BVADfTA5.js → version-ioN546cp.js} +2 -2
- package/dist/chunks/{version-BVADfTA5.js.map → version-ioN546cp.js.map} +1 -1
- package/dist/css/web-mojo.css +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +1 -957
- package/dist/docit.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -3252
- package/dist/index.es.js.map +1 -1
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +1 -3737
- package/dist/lightbox.es.js.map +1 -1
- package/dist/loader.umd.js +2 -2
- package/dist/map.cjs.js +1 -1
- package/dist/map.es.js +1 -1032
- package/dist/map.es.js.map +1 -1
- package/dist/mojo-auth.es.js +338 -0
- package/dist/mojo-auth.umd.js +1 -0
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.es.js +1 -224
- package/dist/timeline.es.js.map +1 -1
- package/dist/web-mojo.lite.iife.js +14 -3
- package/dist/web-mojo.lite.iife.js.map +1 -1
- package/dist/web-mojo.lite.iife.min.js +6 -6
- package/dist/web-mojo.lite.iife.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/ChatView-9k6xBWXk.js +0 -7632
- package/dist/chunks/ChatView-9k6xBWXk.js.map +0 -1
- package/dist/chunks/ChatView-CdtuCDYm.js +0 -2
- package/dist/chunks/ChatView-CdtuCDYm.js.map +0 -1
- package/dist/chunks/Collection-DaiL0uGl.js +0 -1014
- package/dist/chunks/ContextMenu-sgvgSACY.js +0 -1535
- package/dist/chunks/DataView-Dzo0jbs2.js +0 -862
- package/dist/chunks/Dialog-DOGDalUq.js +0 -1579
- package/dist/chunks/FormPlugins-DY6e88YT.js +0 -124
- package/dist/chunks/FormView-Dz3mYasQ.js +0 -8636
- package/dist/chunks/ListView-X5w5jf51.js +0 -495
- package/dist/chunks/MetricsCountryMapView-B2xz6zUw.js +0 -1054
- package/dist/chunks/MetricsMiniChartWidget-DvKd7Qrk.js +0 -3283
- package/dist/chunks/PDFViewer-EJ9cOfPF.js +0 -946
- package/dist/chunks/Rest-CgSjfMaU.js +0 -2
- package/dist/chunks/Rest-CgSjfMaU.js.map +0 -1
- package/dist/chunks/Rest-W-sPfGh9.js +0 -4375
- package/dist/chunks/Rest-W-sPfGh9.js.map +0 -1
- package/dist/chunks/TokenManager-DoN9e6q6.js +0 -1423
- package/dist/chunks/WebApp-6qvqmOts.js +0 -1386
- package/dist/chunks/WebSocketClient-DG2olXpH.js +0 -209
- package/dist/chunks/version-OyPGnx30.js +0 -38
- package/dist/chunks/version-OyPGnx30.js.map +0 -1
package/dist/charts.es.js
CHANGED
|
@@ -1,572 +1,2 @@
|
|
|
1
|
-
import { B, M, b, c, a, P, S } from "./chunks/MetricsMiniChartWidget-DvKd7Qrk.js";
|
|
2
|
-
import { V as View, d as dataFormatter } from "./chunks/Rest-W-sPfGh9.js";
|
|
3
|
-
import { W } from "./chunks/WebApp-6qvqmOts.js";
|
|
4
|
-
import { B as B2, a as a2, V, b as b2, c as c2, d } from "./chunks/version-OyPGnx30.js";
|
|
5
|
-
class CircularProgress extends View {
|
|
6
|
-
constructor(options = {}) {
|
|
7
|
-
super({
|
|
8
|
-
className: `circular-progress ${options.className || ""}`,
|
|
9
|
-
...options
|
|
10
|
-
});
|
|
11
|
-
this.SIZE_PRESETS = {
|
|
12
|
-
"xs": 40,
|
|
13
|
-
"sm": 60,
|
|
14
|
-
"md": 80,
|
|
15
|
-
"lg": 120,
|
|
16
|
-
"xl": 180
|
|
17
|
-
};
|
|
18
|
-
this.STROKE_PRESETS = {
|
|
19
|
-
"xs": 4,
|
|
20
|
-
"sm": 6,
|
|
21
|
-
"md": 8,
|
|
22
|
-
"lg": 12,
|
|
23
|
-
"xl": 16
|
|
24
|
-
};
|
|
25
|
-
this.value = options.value !== void 0 ? options.value : 0;
|
|
26
|
-
this.min = options.min !== void 0 ? options.min : 0;
|
|
27
|
-
this.max = options.max !== void 0 ? options.max : 100;
|
|
28
|
-
this.sizePreset = typeof options.size === "string" && this.SIZE_PRESETS[options.size] ? options.size : null;
|
|
29
|
-
this.size = this.resolveSize(options.size !== void 0 ? options.size : "md");
|
|
30
|
-
this.strokeWidth = options.strokeWidth === "auto" || options.strokeWidth === void 0 ? this.getAutoStrokeWidth(options.size) : options.strokeWidth;
|
|
31
|
-
this.theme = options.theme || "basic";
|
|
32
|
-
this.variant = options.variant || "default";
|
|
33
|
-
this.color = options.color;
|
|
34
|
-
this.trackColor = options.trackColor;
|
|
35
|
-
this.textColor = options.textColor;
|
|
36
|
-
this.gradientColors = options.gradientColors || null;
|
|
37
|
-
this.applyTheme();
|
|
38
|
-
this.applyVariant();
|
|
39
|
-
this.rotation = options.rotation !== void 0 ? options.rotation : -90;
|
|
40
|
-
this.gap = options.gap || 0;
|
|
41
|
-
this.showValue = options.showValue !== false;
|
|
42
|
-
this.valueFormat = options.valueFormat || "percentage";
|
|
43
|
-
this.valueFormatter = options.valueFormatter || null;
|
|
44
|
-
this.label = options.label || null;
|
|
45
|
-
this.labelHtml = options.labelHtml || null;
|
|
46
|
-
this.icon = options.icon || null;
|
|
47
|
-
this.animate = options.animate !== false;
|
|
48
|
-
this.animationDuration = options.animationDuration || 600;
|
|
49
|
-
this.animationEasing = options.animationEasing || "ease-out";
|
|
50
|
-
this.rounded = options.rounded !== false;
|
|
51
|
-
this.shadow = options.shadow || false;
|
|
52
|
-
this.clickable = options.clickable || false;
|
|
53
|
-
this.tooltip = options.tooltip || null;
|
|
54
|
-
this.tooltipPlacement = options.tooltipPlacement || "top";
|
|
55
|
-
this.segments = options.segments || null;
|
|
56
|
-
this.segmentGap = options.segmentGap || 2;
|
|
57
|
-
this.dataFormatter = dataFormatter;
|
|
58
|
-
this.svg = null;
|
|
59
|
-
this.centerElement = null;
|
|
60
|
-
this.popover = null;
|
|
61
|
-
this.gradientId = `gradient-${Math.random().toString(36).substr(2, 9)}`;
|
|
62
|
-
}
|
|
63
|
-
resolveSize(size) {
|
|
64
|
-
if (typeof size === "string" && this.SIZE_PRESETS[size]) {
|
|
65
|
-
return this.SIZE_PRESETS[size];
|
|
66
|
-
}
|
|
67
|
-
return typeof size === "number" ? size : this.SIZE_PRESETS.md;
|
|
68
|
-
}
|
|
69
|
-
getAutoStrokeWidth(size) {
|
|
70
|
-
if (typeof size === "string" && this.STROKE_PRESETS[size]) {
|
|
71
|
-
return this.STROKE_PRESETS[size];
|
|
72
|
-
}
|
|
73
|
-
const actualSize = this.resolveSize(size);
|
|
74
|
-
if (actualSize <= 40) return 4;
|
|
75
|
-
if (actualSize <= 60) return 6;
|
|
76
|
-
if (actualSize <= 80) return 8;
|
|
77
|
-
if (actualSize <= 120) return 12;
|
|
78
|
-
return 16;
|
|
79
|
-
}
|
|
80
|
-
applyTheme() {
|
|
81
|
-
const themes = {
|
|
82
|
-
"basic": {
|
|
83
|
-
trackColor: "#e9ecef",
|
|
84
|
-
textColor: null,
|
|
85
|
-
// Use default
|
|
86
|
-
backgroundColor: null
|
|
87
|
-
},
|
|
88
|
-
"shadowed": {
|
|
89
|
-
trackColor: "#d1d5db",
|
|
90
|
-
textColor: null,
|
|
91
|
-
backgroundColor: null,
|
|
92
|
-
shadow: true
|
|
93
|
-
},
|
|
94
|
-
"dark": {
|
|
95
|
-
trackColor: "#374151",
|
|
96
|
-
textColor: "#e5e7eb",
|
|
97
|
-
backgroundColor: "#1f2937"
|
|
98
|
-
},
|
|
99
|
-
"light": {
|
|
100
|
-
trackColor: "#f3f4f6",
|
|
101
|
-
textColor: "#111827",
|
|
102
|
-
backgroundColor: "#ffffff"
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const themeConfig = themes[this.theme] || themes.basic;
|
|
106
|
-
if (!this.trackColor) {
|
|
107
|
-
this.trackColor = themeConfig.trackColor;
|
|
108
|
-
}
|
|
109
|
-
if (!this.textColor && themeConfig.textColor) {
|
|
110
|
-
this.textColor = themeConfig.textColor;
|
|
111
|
-
}
|
|
112
|
-
if (themeConfig.shadow && this.shadow === false) {
|
|
113
|
-
this.shadow = themeConfig.shadow;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
applyVariant() {
|
|
117
|
-
const variants = {
|
|
118
|
-
"success": { color: "#198754", trackColor: "rgba(25, 135, 84, 0.1)" },
|
|
119
|
-
"danger": { color: "#dc3545", trackColor: "rgba(220, 53, 69, 0.1)" },
|
|
120
|
-
"warning": { color: "#ffc107", trackColor: "rgba(255, 193, 7, 0.1)" },
|
|
121
|
-
"info": { color: "#0dcaf0", trackColor: "rgba(13, 202, 240, 0.1)" },
|
|
122
|
-
"default": { color: "#0d6efd" }
|
|
123
|
-
// Default blue color
|
|
124
|
-
};
|
|
125
|
-
if (variants[this.variant]) {
|
|
126
|
-
const variantColors = variants[this.variant];
|
|
127
|
-
if (!this.color) {
|
|
128
|
-
this.color = variantColors.color;
|
|
129
|
-
}
|
|
130
|
-
if (variantColors.trackColor && this.trackColor === this.applyTheme.trackColor) {
|
|
131
|
-
this.trackColor = variantColors.trackColor;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (!this.color) {
|
|
135
|
-
this.color = "#0d6efd";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
getTemplate() {
|
|
139
|
-
const sizeClass = this.sizePreset ? `circular-progress-${this.sizePreset}` : "";
|
|
140
|
-
const variantClass = this.variant !== "default" ? `circular-progress-${this.variant}` : "";
|
|
141
|
-
const themeClass = this.theme !== "basic" ? `circular-progress-theme-${this.theme}` : "";
|
|
142
|
-
const clickableClass = this.clickable ? "circular-progress-clickable" : "";
|
|
143
|
-
const shadowClass = this.shadow ? "circular-progress-shadow" : "";
|
|
144
|
-
const textColorStyle = this.textColor ? `color: ${this.textColor};` : "";
|
|
145
|
-
return `
|
|
146
|
-
<div class="circular-progress-container ${sizeClass} ${variantClass} ${themeClass} ${clickableClass} ${shadowClass}"
|
|
147
|
-
style="width: ${this.size}px; height: ${this.size}px;">
|
|
148
|
-
<svg class="circular-progress-svg"
|
|
149
|
-
width="${this.size}"
|
|
150
|
-
height="${this.size}"
|
|
151
|
-
viewBox="0 0 ${this.size} ${this.size}">
|
|
152
|
-
</svg>
|
|
153
|
-
<div class="circular-progress-center" style="${textColorStyle}">
|
|
154
|
-
<div class="circular-progress-content"></div>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
`;
|
|
158
|
-
}
|
|
159
|
-
async onAfterRender() {
|
|
160
|
-
this.svg = this.element.querySelector(".circular-progress-svg");
|
|
161
|
-
this.centerElement = this.element.querySelector(".circular-progress-content");
|
|
162
|
-
this.containerElement = this.element.querySelector(".circular-progress-container");
|
|
163
|
-
this.renderProgress();
|
|
164
|
-
this.renderCenterContent();
|
|
165
|
-
if (this.clickable) {
|
|
166
|
-
this.setupClickHandler();
|
|
167
|
-
}
|
|
168
|
-
if (this.tooltip && this.clickable) {
|
|
169
|
-
this.setupTooltip();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
renderProgress() {
|
|
173
|
-
if (!this.svg) return;
|
|
174
|
-
this.svg.innerHTML = "";
|
|
175
|
-
const center = this.size / 2;
|
|
176
|
-
const radius = (this.size - this.strokeWidth) / 2;
|
|
177
|
-
const circumference = 2 * Math.PI * radius;
|
|
178
|
-
if (this.gradientColors && this.gradientColors.length > 1) {
|
|
179
|
-
this.createGradient();
|
|
180
|
-
}
|
|
181
|
-
if (this.segments && Array.isArray(this.segments) && this.segments.length > 0) {
|
|
182
|
-
this.renderSegments(center, radius, circumference);
|
|
183
|
-
} else {
|
|
184
|
-
this.renderSingleProgress(center, radius, circumference);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
renderSingleProgress(center, radius, circumference) {
|
|
188
|
-
const arcLength = this.gap > 0 ? 360 - this.gap : 360;
|
|
189
|
-
const arcCircumference = arcLength / 360 * circumference;
|
|
190
|
-
const track = this.createCircle(center, radius, {
|
|
191
|
-
stroke: this.trackColor,
|
|
192
|
-
strokeWidth: this.strokeWidth,
|
|
193
|
-
fill: "none",
|
|
194
|
-
strokeLinecap: this.rounded ? "round" : "butt",
|
|
195
|
-
strokeDasharray: this.gap > 0 ? `${arcCircumference} ${circumference}` : "none",
|
|
196
|
-
transform: `rotate(${this.rotation} ${center} ${center})`
|
|
197
|
-
});
|
|
198
|
-
this.svg.appendChild(track);
|
|
199
|
-
const percentage = this.getPercentage();
|
|
200
|
-
const progressLength = percentage / 100 * arcCircumference;
|
|
201
|
-
const dashOffset = arcCircumference - progressLength;
|
|
202
|
-
const strokeColor = this.gradientColors ? `url(#${this.gradientId})` : this.color;
|
|
203
|
-
const progress = this.createCircle(center, radius, {
|
|
204
|
-
stroke: strokeColor,
|
|
205
|
-
strokeWidth: this.strokeWidth,
|
|
206
|
-
fill: "none",
|
|
207
|
-
strokeLinecap: this.rounded ? "round" : "butt",
|
|
208
|
-
strokeDasharray: `${arcCircumference} ${circumference}`,
|
|
209
|
-
strokeDashoffset: this.animate ? arcCircumference : dashOffset,
|
|
210
|
-
transform: `rotate(${this.rotation} ${center} ${center})`,
|
|
211
|
-
class: "circular-progress-bar"
|
|
212
|
-
});
|
|
213
|
-
this.svg.appendChild(progress);
|
|
214
|
-
if (this.animate) {
|
|
215
|
-
this.animateProgress(progress, dashOffset);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
renderSegments(center, radius, circumference) {
|
|
219
|
-
const arcLength = this.gap > 0 ? 360 - this.gap : 360;
|
|
220
|
-
const arcCircumference = arcLength / 360 * circumference;
|
|
221
|
-
const track = this.createCircle(center, radius, {
|
|
222
|
-
stroke: this.trackColor,
|
|
223
|
-
strokeWidth: this.strokeWidth,
|
|
224
|
-
fill: "none",
|
|
225
|
-
strokeLinecap: this.rounded ? "round" : "butt",
|
|
226
|
-
strokeDasharray: this.gap > 0 ? `${arcCircumference} ${circumference}` : "none",
|
|
227
|
-
transform: `rotate(${this.rotation} ${center} ${center})`
|
|
228
|
-
});
|
|
229
|
-
this.svg.appendChild(track);
|
|
230
|
-
const total = this.segments.reduce((sum, seg) => sum + (seg.value || 0), 0);
|
|
231
|
-
if (total > this.max) {
|
|
232
|
-
console.warn("CircularProgress: Segment total exceeds max value. Clamping to max.");
|
|
233
|
-
}
|
|
234
|
-
let currentOffset = 0;
|
|
235
|
-
this.segments.forEach((segment, index) => {
|
|
236
|
-
const segmentPercentage = (segment.value || 0) / (this.max - this.min) * 100;
|
|
237
|
-
const segmentLength = segmentPercentage / 100 * arcCircumference;
|
|
238
|
-
const gapLength = this.segmentGap / 360 * circumference;
|
|
239
|
-
if (segmentLength > 0) {
|
|
240
|
-
const segmentCircle = this.createCircle(center, radius, {
|
|
241
|
-
stroke: segment.color || this.color,
|
|
242
|
-
strokeWidth: this.strokeWidth,
|
|
243
|
-
fill: "none",
|
|
244
|
-
strokeLinecap: this.rounded ? "round" : "butt",
|
|
245
|
-
strokeDasharray: `${segmentLength} ${circumference}`,
|
|
246
|
-
strokeDashoffset: this.animate ? arcCircumference : -currentOffset,
|
|
247
|
-
transform: `rotate(${this.rotation} ${center} ${center})`,
|
|
248
|
-
class: `circular-progress-segment circular-progress-segment-${index}`,
|
|
249
|
-
"data-segment-index": index
|
|
250
|
-
});
|
|
251
|
-
this.svg.appendChild(segmentCircle);
|
|
252
|
-
if (this.animate) {
|
|
253
|
-
this.animateProgress(segmentCircle, -currentOffset, index * 100);
|
|
254
|
-
}
|
|
255
|
-
currentOffset += segmentLength + gapLength;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
createCircle(cx, cy, attributes = {}) {
|
|
260
|
-
const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
261
|
-
circle.setAttribute("cx", cx);
|
|
262
|
-
circle.setAttribute("cy", cx);
|
|
263
|
-
circle.setAttribute("r", cy);
|
|
264
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
265
|
-
if (key === "strokeWidth") {
|
|
266
|
-
circle.setAttribute("stroke-width", value);
|
|
267
|
-
} else if (key === "strokeLinecap") {
|
|
268
|
-
circle.setAttribute("stroke-linecap", value);
|
|
269
|
-
} else if (key === "strokeDasharray") {
|
|
270
|
-
circle.setAttribute("stroke-dasharray", value);
|
|
271
|
-
} else if (key === "strokeDashoffset") {
|
|
272
|
-
circle.setAttribute("stroke-dashoffset", value);
|
|
273
|
-
} else {
|
|
274
|
-
circle.setAttribute(key, value);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
return circle;
|
|
278
|
-
}
|
|
279
|
-
createGradient() {
|
|
280
|
-
const defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
281
|
-
const gradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
|
|
282
|
-
gradient.setAttribute("id", this.gradientId);
|
|
283
|
-
gradient.setAttribute("x1", "0%");
|
|
284
|
-
gradient.setAttribute("y1", "0%");
|
|
285
|
-
gradient.setAttribute("x2", "100%");
|
|
286
|
-
gradient.setAttribute("y2", "100%");
|
|
287
|
-
this.gradientColors.forEach((color, index) => {
|
|
288
|
-
const stop = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
289
|
-
const offset = index / (this.gradientColors.length - 1) * 100;
|
|
290
|
-
stop.setAttribute("offset", `${offset}%`);
|
|
291
|
-
stop.setAttribute("stop-color", color);
|
|
292
|
-
gradient.appendChild(stop);
|
|
293
|
-
});
|
|
294
|
-
defs.appendChild(gradient);
|
|
295
|
-
this.svg.appendChild(defs);
|
|
296
|
-
}
|
|
297
|
-
animateProgress(circle, targetOffset, delay = 0) {
|
|
298
|
-
setTimeout(() => {
|
|
299
|
-
circle.style.transition = `stroke-dashoffset ${this.animationDuration}ms ${this.animationEasing}`;
|
|
300
|
-
circle.style.strokeDashoffset = targetOffset;
|
|
301
|
-
}, delay);
|
|
302
|
-
}
|
|
303
|
-
renderCenterContent() {
|
|
304
|
-
if (!this.centerElement) return;
|
|
305
|
-
if (this.labelHtml) {
|
|
306
|
-
this.centerElement.innerHTML = this.labelHtml;
|
|
307
|
-
} else if (this.icon) {
|
|
308
|
-
this.centerElement.innerHTML = `<i class="${this.icon}"></i>`;
|
|
309
|
-
} else if (this.showValue) {
|
|
310
|
-
const formattedValue = this.getFormattedValue();
|
|
311
|
-
let html = `<div class="circular-progress-value">${formattedValue}</div>`;
|
|
312
|
-
if (this.label) {
|
|
313
|
-
html += `<div class="circular-progress-label">${this.label}</div>`;
|
|
314
|
-
}
|
|
315
|
-
this.centerElement.innerHTML = html;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
getFormattedValue() {
|
|
319
|
-
const value = this.value;
|
|
320
|
-
const min = this.min;
|
|
321
|
-
const max = this.max;
|
|
322
|
-
if (this.valueFormatter && typeof this.valueFormatter === "function") {
|
|
323
|
-
return this.valueFormatter(value, min, max);
|
|
324
|
-
}
|
|
325
|
-
switch (this.valueFormat) {
|
|
326
|
-
case "percentage":
|
|
327
|
-
return `${Math.round(this.getPercentage())}%`;
|
|
328
|
-
case "fraction":
|
|
329
|
-
return `${value}/${max}`;
|
|
330
|
-
case "value":
|
|
331
|
-
return value.toString();
|
|
332
|
-
default:
|
|
333
|
-
if (this.dataFormatter) {
|
|
334
|
-
try {
|
|
335
|
-
return this.dataFormatter.pipe(value, this.valueFormat);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
console.warn("CircularProgress: DataFormatter error, falling back to percentage", error);
|
|
338
|
-
return `${Math.round(this.getPercentage())}%`;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return `${Math.round(this.getPercentage())}%`;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
getPercentage() {
|
|
345
|
-
const range = this.max - this.min;
|
|
346
|
-
if (range === 0) return 0;
|
|
347
|
-
return (this.value - this.min) / range * 100;
|
|
348
|
-
}
|
|
349
|
-
setupClickHandler() {
|
|
350
|
-
if (!this.containerElement) return;
|
|
351
|
-
this.containerElement.style.cursor = "pointer";
|
|
352
|
-
this.containerElement.addEventListener("click", (e) => {
|
|
353
|
-
e.preventDefault();
|
|
354
|
-
e.stopPropagation();
|
|
355
|
-
const percentage = this.getPercentage();
|
|
356
|
-
this.emit("progress:clicked", {
|
|
357
|
-
value: this.value,
|
|
358
|
-
percentage,
|
|
359
|
-
min: this.min,
|
|
360
|
-
max: this.max
|
|
361
|
-
});
|
|
362
|
-
if (this.tooltip) {
|
|
363
|
-
this.togglePopover();
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
setupTooltip() {
|
|
368
|
-
}
|
|
369
|
-
togglePopover() {
|
|
370
|
-
if (!this.containerElement || typeof window.bootstrap === "undefined") {
|
|
371
|
-
console.warn("CircularProgress: Bootstrap is required for tooltip support");
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (!this.popover) {
|
|
375
|
-
const content = this.getTooltipContent();
|
|
376
|
-
const title = typeof this.tooltip === "object" && this.tooltip.title ? this.tooltip.title : void 0;
|
|
377
|
-
const popoverConfig = {
|
|
378
|
-
content,
|
|
379
|
-
html: true,
|
|
380
|
-
placement: this.tooltipPlacement,
|
|
381
|
-
trigger: "manual",
|
|
382
|
-
container: "body"
|
|
383
|
-
};
|
|
384
|
-
if (title) {
|
|
385
|
-
popoverConfig.title = title;
|
|
386
|
-
}
|
|
387
|
-
this.popover = new window.bootstrap.Popover(this.containerElement, popoverConfig);
|
|
388
|
-
}
|
|
389
|
-
const popoverElement = window.bootstrap.Popover.getInstance(this.containerElement);
|
|
390
|
-
if (popoverElement && this.containerElement.getAttribute("aria-describedby")) {
|
|
391
|
-
this.popover.hide();
|
|
392
|
-
} else {
|
|
393
|
-
this.popover.setContent({
|
|
394
|
-
".popover-body": this.getTooltipContent()
|
|
395
|
-
});
|
|
396
|
-
this.popover.show();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
getTooltipContent() {
|
|
400
|
-
if (typeof this.tooltip === "function") {
|
|
401
|
-
return this.tooltip(this.value, {
|
|
402
|
-
min: this.min,
|
|
403
|
-
max: this.max,
|
|
404
|
-
percentage: this.getPercentage()
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
if (typeof this.tooltip === "object") {
|
|
408
|
-
return this.tooltip.html || this.tooltip.content || "";
|
|
409
|
-
}
|
|
410
|
-
return this.tooltip || "";
|
|
411
|
-
}
|
|
412
|
-
// Public API
|
|
413
|
-
setValue(value, animate = true) {
|
|
414
|
-
this.value;
|
|
415
|
-
this.value = Math.max(this.min, Math.min(this.max, value));
|
|
416
|
-
this.renderCenterContent();
|
|
417
|
-
if (this.svg && !this.segments) {
|
|
418
|
-
const progressBar = this.svg.querySelector(".circular-progress-bar");
|
|
419
|
-
if (progressBar) {
|
|
420
|
-
const radius = this.size / 2 - this.strokeWidth / 2;
|
|
421
|
-
const circumference = 2 * Math.PI * radius;
|
|
422
|
-
const arcLength = this.gap > 0 ? 360 - this.gap : 360;
|
|
423
|
-
const arcCircumference = arcLength / 360 * circumference;
|
|
424
|
-
const percentage = this.getPercentage();
|
|
425
|
-
const progressLength = percentage / 100 * arcCircumference;
|
|
426
|
-
const dashOffset = arcCircumference - progressLength;
|
|
427
|
-
if (animate) {
|
|
428
|
-
progressBar.style.transition = `stroke-dashoffset ${this.animationDuration}ms ${this.animationEasing}`;
|
|
429
|
-
progressBar.style.strokeDashoffset = dashOffset;
|
|
430
|
-
} else {
|
|
431
|
-
progressBar.style.transition = "none";
|
|
432
|
-
progressBar.style.strokeDashoffset = dashOffset;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
} else {
|
|
436
|
-
const oldAnimate = this.animate;
|
|
437
|
-
this.animate = animate;
|
|
438
|
-
this.renderProgress();
|
|
439
|
-
this.animate = oldAnimate;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
setRange(min, max) {
|
|
443
|
-
this.min = min;
|
|
444
|
-
this.max = max;
|
|
445
|
-
this.renderProgress();
|
|
446
|
-
this.renderCenterContent();
|
|
447
|
-
}
|
|
448
|
-
increment(amount = 1) {
|
|
449
|
-
this.setValue(this.value + amount);
|
|
450
|
-
}
|
|
451
|
-
decrement(amount = 1) {
|
|
452
|
-
this.setValue(this.value - amount);
|
|
453
|
-
}
|
|
454
|
-
setColor(color) {
|
|
455
|
-
this.color = color;
|
|
456
|
-
this.gradientColors = null;
|
|
457
|
-
if (this.svg && !this.segments) {
|
|
458
|
-
const progressBar = this.svg.querySelector(".circular-progress-bar");
|
|
459
|
-
if (progressBar) {
|
|
460
|
-
progressBar.setAttribute("stroke", color);
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
this.renderProgress();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
setGradient(colors) {
|
|
467
|
-
if (Array.isArray(colors) && colors.length > 1) {
|
|
468
|
-
this.gradientColors = colors;
|
|
469
|
-
this.gradientId = `gradient-${Math.random().toString(36).substr(2, 9)}`;
|
|
470
|
-
this.renderProgress();
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
setSize(size) {
|
|
474
|
-
if (this.containerElement && this.sizePreset) {
|
|
475
|
-
this.containerElement.classList.remove(`circular-progress-${this.sizePreset}`);
|
|
476
|
-
}
|
|
477
|
-
this.sizePreset = typeof size === "string" && this.SIZE_PRESETS[size] ? size : null;
|
|
478
|
-
this.size = this.resolveSize(size);
|
|
479
|
-
this.strokeWidth = this.getAutoStrokeWidth(size);
|
|
480
|
-
if (this.containerElement) {
|
|
481
|
-
this.containerElement.style.width = `${this.size}px`;
|
|
482
|
-
this.containerElement.style.height = `${this.size}px`;
|
|
483
|
-
if (this.sizePreset) {
|
|
484
|
-
this.containerElement.classList.add(`circular-progress-${this.sizePreset}`);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (this.svg) {
|
|
488
|
-
this.svg.setAttribute("width", this.size);
|
|
489
|
-
this.svg.setAttribute("height", this.size);
|
|
490
|
-
this.svg.setAttribute("viewBox", `0 0 ${this.size} ${this.size}`);
|
|
491
|
-
}
|
|
492
|
-
this.renderProgress();
|
|
493
|
-
}
|
|
494
|
-
animateTo(targetValue, duration = 1e3) {
|
|
495
|
-
const startValue = this.value;
|
|
496
|
-
const diff = targetValue - startValue;
|
|
497
|
-
const startTime = performance.now();
|
|
498
|
-
const animate = (currentTime) => {
|
|
499
|
-
const elapsed = currentTime - startTime;
|
|
500
|
-
const progress = Math.min(elapsed / duration, 1);
|
|
501
|
-
const easeProgress = 1 - Math.pow(1 - progress, 3);
|
|
502
|
-
const newValue = startValue + diff * easeProgress;
|
|
503
|
-
this.setValue(newValue, false);
|
|
504
|
-
if (progress < 1) {
|
|
505
|
-
requestAnimationFrame(animate);
|
|
506
|
-
} else {
|
|
507
|
-
this.setValue(targetValue, false);
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
requestAnimationFrame(animate);
|
|
511
|
-
}
|
|
512
|
-
pulse() {
|
|
513
|
-
if (!this.containerElement) return;
|
|
514
|
-
this.containerElement.style.animation = "none";
|
|
515
|
-
setTimeout(() => {
|
|
516
|
-
this.containerElement.style.animation = "circular-progress-pulse 0.5s ease-out";
|
|
517
|
-
}, 10);
|
|
518
|
-
setTimeout(() => {
|
|
519
|
-
this.containerElement.style.animation = "";
|
|
520
|
-
}, 500);
|
|
521
|
-
}
|
|
522
|
-
complete() {
|
|
523
|
-
this.variant = "success";
|
|
524
|
-
this.applyVariant();
|
|
525
|
-
this.setValue(this.max);
|
|
526
|
-
this.pulse();
|
|
527
|
-
}
|
|
528
|
-
reset() {
|
|
529
|
-
this.setValue(this.min);
|
|
530
|
-
}
|
|
531
|
-
hide() {
|
|
532
|
-
if (this.element) {
|
|
533
|
-
this.element.style.display = "none";
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
show() {
|
|
537
|
-
if (this.element) {
|
|
538
|
-
this.element.style.display = "";
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
getValue() {
|
|
542
|
-
return this.value;
|
|
543
|
-
}
|
|
544
|
-
getPercentageValue() {
|
|
545
|
-
return this.getPercentage();
|
|
546
|
-
}
|
|
547
|
-
async onBeforeDestroy() {
|
|
548
|
-
if (this.popover) {
|
|
549
|
-
this.popover.dispose();
|
|
550
|
-
this.popover = null;
|
|
551
|
-
}
|
|
552
|
-
await super.onBeforeDestroy();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
export {
|
|
556
|
-
B2 as BUILD_TIME,
|
|
557
|
-
B as BaseChart,
|
|
558
|
-
CircularProgress,
|
|
559
|
-
M as MetricsChart,
|
|
560
|
-
b as MetricsMiniChart,
|
|
561
|
-
c as MetricsMiniChartWidget,
|
|
562
|
-
a as MiniChart,
|
|
563
|
-
P as PieChart,
|
|
564
|
-
S as SeriesChart,
|
|
565
|
-
a2 as VERSION,
|
|
566
|
-
V as VERSION_INFO,
|
|
567
|
-
b2 as VERSION_MAJOR,
|
|
568
|
-
c2 as VERSION_MINOR,
|
|
569
|
-
d as VERSION_REVISION,
|
|
570
|
-
W as WebApp
|
|
571
|
-
};
|
|
1
|
+
import{B as t,M as e,a as s,b as i,c as r,P as o,S as a}from"./chunks/MetricsMiniChartWidget-x2gFjHOU.js";import{V as n,d as h}from"./chunks/Rest-DHbszkuP.js";import{W as l}from"./chunks/WebApp-CULZpO_0.js";import{B as c,V as u,a as g,b as d,c as m,d as p}from"./chunks/version-C3dnl1bg.js";class CircularProgress extends n{constructor(t={}){super({className:`circular-progress ${t.className||""}`,...t}),this.SIZE_PRESETS={xs:40,sm:60,md:80,lg:120,xl:180},this.STROKE_PRESETS={xs:4,sm:6,md:8,lg:12,xl:16},this.value=void 0!==t.value?t.value:0,this.min=void 0!==t.min?t.min:0,this.max=void 0!==t.max?t.max:100,this.sizePreset="string"==typeof t.size&&this.SIZE_PRESETS[t.size]?t.size:null,this.size=this.resolveSize(void 0!==t.size?t.size:"md"),this.strokeWidth="auto"===t.strokeWidth||void 0===t.strokeWidth?this.getAutoStrokeWidth(t.size):t.strokeWidth,this.theme=t.theme||"basic",this.variant=t.variant||"default",this.color=t.color,this.trackColor=t.trackColor,this.textColor=t.textColor,this.gradientColors=t.gradientColors||null,this.applyTheme(),this.applyVariant(),this.rotation=void 0!==t.rotation?t.rotation:-90,this.gap=t.gap||0,this.showValue=!1!==t.showValue,this.valueFormat=t.valueFormat||"percentage",this.valueFormatter=t.valueFormatter||null,this.label=t.label||null,this.labelHtml=t.labelHtml||null,this.icon=t.icon||null,this.animate=!1!==t.animate,this.animationDuration=t.animationDuration||600,this.animationEasing=t.animationEasing||"ease-out",this.rounded=!1!==t.rounded,this.shadow=t.shadow||!1,this.clickable=t.clickable||!1,this.tooltip=t.tooltip||null,this.tooltipPlacement=t.tooltipPlacement||"top",this.segments=t.segments||null,this.segmentGap=t.segmentGap||2,this.dataFormatter=h,this.svg=null,this.centerElement=null,this.popover=null,this.gradientId=`gradient-${Math.random().toString(36).substr(2,9)}`}resolveSize(t){return"string"==typeof t&&this.SIZE_PRESETS[t]?this.SIZE_PRESETS[t]:"number"==typeof t?t:this.SIZE_PRESETS.md}getAutoStrokeWidth(t){if("string"==typeof t&&this.STROKE_PRESETS[t])return this.STROKE_PRESETS[t];const e=this.resolveSize(t);return e<=40?4:e<=60?6:e<=80?8:e<=120?12:16}applyTheme(){const t={basic:{trackColor:"#e9ecef",textColor:null,backgroundColor:null},shadowed:{trackColor:"#d1d5db",textColor:null,backgroundColor:null,shadow:!0},dark:{trackColor:"#374151",textColor:"#e5e7eb",backgroundColor:"#1f2937"},light:{trackColor:"#f3f4f6",textColor:"#111827",backgroundColor:"#ffffff"}},e=t[this.theme]||t.basic;this.trackColor||(this.trackColor=e.trackColor),!this.textColor&&e.textColor&&(this.textColor=e.textColor),e.shadow&&!1===this.shadow&&(this.shadow=e.shadow)}applyVariant(){const t={success:{color:"#198754",trackColor:"rgba(25, 135, 84, 0.1)"},danger:{color:"#dc3545",trackColor:"rgba(220, 53, 69, 0.1)"},warning:{color:"#ffc107",trackColor:"rgba(255, 193, 7, 0.1)"},info:{color:"#0dcaf0",trackColor:"rgba(13, 202, 240, 0.1)"},default:{color:"#0d6efd"}};if(t[this.variant]){const e=t[this.variant];this.color||(this.color=e.color),e.trackColor&&this.trackColor===this.applyTheme.trackColor&&(this.trackColor=e.trackColor)}this.color||(this.color="#0d6efd")}getTemplate(){const t=this.sizePreset?`circular-progress-${this.sizePreset}`:"",e="default"!==this.variant?`circular-progress-${this.variant}`:"",s="basic"!==this.theme?`circular-progress-theme-${this.theme}`:"",i=this.clickable?"circular-progress-clickable":"",r=this.shadow?"circular-progress-shadow":"",o=this.textColor?`color: ${this.textColor};`:"";return`\n <div class="circular-progress-container ${t} ${e} ${s} ${i} ${r}"\n style="width: ${this.size}px; height: ${this.size}px;">\n <svg class="circular-progress-svg" \n width="${this.size}" \n height="${this.size}"\n viewBox="0 0 ${this.size} ${this.size}">\n </svg>\n <div class="circular-progress-center" style="${o}">\n <div class="circular-progress-content"></div>\n </div>\n </div>\n `}async onAfterRender(){this.svg=this.element.querySelector(".circular-progress-svg"),this.centerElement=this.element.querySelector(".circular-progress-content"),this.containerElement=this.element.querySelector(".circular-progress-container"),this.renderProgress(),this.renderCenterContent(),this.clickable&&this.setupClickHandler(),this.tooltip&&this.clickable&&this.setupTooltip()}renderProgress(){if(!this.svg)return;this.svg.innerHTML="";const t=this.size/2,e=(this.size-this.strokeWidth)/2,s=2*Math.PI*e;this.gradientColors&&this.gradientColors.length>1&&this.createGradient(),this.segments&&Array.isArray(this.segments)&&this.segments.length>0?this.renderSegments(t,e,s):this.renderSingleProgress(t,e,s)}renderSingleProgress(t,e,s){const i=(this.gap>0?360-this.gap:360)/360*s,r=this.createCircle(t,e,{stroke:this.trackColor,strokeWidth:this.strokeWidth,fill:"none",strokeLinecap:this.rounded?"round":"butt",strokeDasharray:this.gap>0?`${i} ${s}`:"none",transform:`rotate(${this.rotation} ${t} ${t})`});this.svg.appendChild(r);const o=i-this.getPercentage()/100*i,a=this.gradientColors?`url(#${this.gradientId})`:this.color,n=this.createCircle(t,e,{stroke:a,strokeWidth:this.strokeWidth,fill:"none",strokeLinecap:this.rounded?"round":"butt",strokeDasharray:`${i} ${s}`,strokeDashoffset:this.animate?i:o,transform:`rotate(${this.rotation} ${t} ${t})`,class:"circular-progress-bar"});this.svg.appendChild(n),this.animate&&this.animateProgress(n,o)}renderSegments(t,e,s){const i=(this.gap>0?360-this.gap:360)/360*s,r=this.createCircle(t,e,{stroke:this.trackColor,strokeWidth:this.strokeWidth,fill:"none",strokeLinecap:this.rounded?"round":"butt",strokeDasharray:this.gap>0?`${i} ${s}`:"none",transform:`rotate(${this.rotation} ${t} ${t})`});this.svg.appendChild(r),this.segments.reduce((t,e)=>t+(e.value||0),0)>this.max&&console.warn("CircularProgress: Segment total exceeds max value. Clamping to max.");let o=0;this.segments.forEach((r,a)=>{const n=(r.value||0)/(this.max-this.min)*100/100*i,h=this.segmentGap/360*s;if(n>0){const l=this.createCircle(t,e,{stroke:r.color||this.color,strokeWidth:this.strokeWidth,fill:"none",strokeLinecap:this.rounded?"round":"butt",strokeDasharray:`${n} ${s}`,strokeDashoffset:this.animate?i:-o,transform:`rotate(${this.rotation} ${t} ${t})`,class:`circular-progress-segment circular-progress-segment-${a}`,"data-segment-index":a});this.svg.appendChild(l),this.animate&&this.animateProgress(l,-o,100*a),o+=n+h}})}createCircle(t,e,s={}){const i=document.createElementNS("http://www.w3.org/2000/svg","circle");return i.setAttribute("cx",t),i.setAttribute("cy",t),i.setAttribute("r",e),Object.entries(s).forEach(([t,e])=>{"strokeWidth"===t?i.setAttribute("stroke-width",e):"strokeLinecap"===t?i.setAttribute("stroke-linecap",e):"strokeDasharray"===t?i.setAttribute("stroke-dasharray",e):"strokeDashoffset"===t?i.setAttribute("stroke-dashoffset",e):i.setAttribute(t,e)}),i}createGradient(){const t=document.createElementNS("http://www.w3.org/2000/svg","defs"),e=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");e.setAttribute("id",this.gradientId),e.setAttribute("x1","0%"),e.setAttribute("y1","0%"),e.setAttribute("x2","100%"),e.setAttribute("y2","100%"),this.gradientColors.forEach((t,s)=>{const i=document.createElementNS("http://www.w3.org/2000/svg","stop"),r=s/(this.gradientColors.length-1)*100;i.setAttribute("offset",`${r}%`),i.setAttribute("stop-color",t),e.appendChild(i)}),t.appendChild(e),this.svg.appendChild(t)}animateProgress(t,e,s=0){setTimeout(()=>{t.style.transition=`stroke-dashoffset ${this.animationDuration}ms ${this.animationEasing}`,t.style.strokeDashoffset=e},s)}renderCenterContent(){if(this.centerElement)if(this.labelHtml)this.centerElement.innerHTML=this.labelHtml;else if(this.icon)this.centerElement.innerHTML=`<i class="${this.icon}"></i>`;else if(this.showValue){let t=`<div class="circular-progress-value">${this.getFormattedValue()}</div>`;this.label&&(t+=`<div class="circular-progress-label">${this.label}</div>`),this.centerElement.innerHTML=t}}getFormattedValue(){const t=this.value,e=this.min,s=this.max;if(this.valueFormatter&&"function"==typeof this.valueFormatter)return this.valueFormatter(t,e,s);switch(this.valueFormat){case"percentage":return`${Math.round(this.getPercentage())}%`;case"fraction":return`${t}/${s}`;case"value":return t.toString();default:if(this.dataFormatter)try{return this.dataFormatter.pipe(t,this.valueFormat)}catch(i){return console.warn("CircularProgress: DataFormatter error, falling back to percentage",i),`${Math.round(this.getPercentage())}%`}return`${Math.round(this.getPercentage())}%`}}getPercentage(){const t=this.max-this.min;return 0===t?0:(this.value-this.min)/t*100}setupClickHandler(){this.containerElement&&(this.containerElement.style.cursor="pointer",this.containerElement.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const e=this.getPercentage();this.emit("progress:clicked",{value:this.value,percentage:e,min:this.min,max:this.max}),this.tooltip&&this.togglePopover()}))}setupTooltip(){}togglePopover(){if(this.containerElement&&void 0!==window.bootstrap){if(!this.popover){const t=this.getTooltipContent(),e="object"==typeof this.tooltip&&this.tooltip.title?this.tooltip.title:void 0,s={content:t,html:!0,placement:this.tooltipPlacement,trigger:"manual",container:"body"};e&&(s.title=e),this.popover=new window.bootstrap.Popover(this.containerElement,s)}window.bootstrap.Popover.getInstance(this.containerElement)&&this.containerElement.getAttribute("aria-describedby")?this.popover.hide():(this.popover.setContent({".popover-body":this.getTooltipContent()}),this.popover.show())}else console.warn("CircularProgress: Bootstrap is required for tooltip support")}getTooltipContent(){return"function"==typeof this.tooltip?this.tooltip(this.value,{min:this.min,max:this.max,percentage:this.getPercentage()}):"object"==typeof this.tooltip?this.tooltip.html||this.tooltip.content||"":this.tooltip||""}setValue(t,e=!0){if(this.value,this.value=Math.max(this.min,Math.min(this.max,t)),this.renderCenterContent(),this.svg&&!this.segments){const t=this.svg.querySelector(".circular-progress-bar");if(t){const s=this.size/2-this.strokeWidth/2,i=2*Math.PI*s,r=(this.gap>0?360-this.gap:360)/360*i,o=r-this.getPercentage()/100*r;e?(t.style.transition=`stroke-dashoffset ${this.animationDuration}ms ${this.animationEasing}`,t.style.strokeDashoffset=o):(t.style.transition="none",t.style.strokeDashoffset=o)}}else{const t=this.animate;this.animate=e,this.renderProgress(),this.animate=t}}setRange(t,e){this.min=t,this.max=e,this.renderProgress(),this.renderCenterContent()}increment(t=1){this.setValue(this.value+t)}decrement(t=1){this.setValue(this.value-t)}setColor(t){if(this.color=t,this.gradientColors=null,this.svg&&!this.segments){const e=this.svg.querySelector(".circular-progress-bar");e&&e.setAttribute("stroke",t)}else this.renderProgress()}setGradient(t){Array.isArray(t)&&t.length>1&&(this.gradientColors=t,this.gradientId=`gradient-${Math.random().toString(36).substr(2,9)}`,this.renderProgress())}setSize(t){this.containerElement&&this.sizePreset&&this.containerElement.classList.remove(`circular-progress-${this.sizePreset}`),this.sizePreset="string"==typeof t&&this.SIZE_PRESETS[t]?t:null,this.size=this.resolveSize(t),this.strokeWidth=this.getAutoStrokeWidth(t),this.containerElement&&(this.containerElement.style.width=`${this.size}px`,this.containerElement.style.height=`${this.size}px`,this.sizePreset&&this.containerElement.classList.add(`circular-progress-${this.sizePreset}`)),this.svg&&(this.svg.setAttribute("width",this.size),this.svg.setAttribute("height",this.size),this.svg.setAttribute("viewBox",`0 0 ${this.size} ${this.size}`)),this.renderProgress()}animateTo(t,e=1e3){const s=this.value,i=t-s,r=performance.now(),o=a=>{const n=a-r,h=Math.min(n/e,1),l=1-Math.pow(1-h,3),c=s+i*l;this.setValue(c,!1),h<1?requestAnimationFrame(o):this.setValue(t,!1)};requestAnimationFrame(o)}pulse(){this.containerElement&&(this.containerElement.style.animation="none",setTimeout(()=>{this.containerElement.style.animation="circular-progress-pulse 0.5s ease-out"},10),setTimeout(()=>{this.containerElement.style.animation=""},500))}complete(){this.variant="success",this.applyVariant(),this.setValue(this.max),this.pulse()}reset(){this.setValue(this.min)}hide(){this.element&&(this.element.style.display="none")}show(){this.element&&(this.element.style.display="")}getValue(){return this.value}getPercentageValue(){return this.getPercentage()}async onBeforeDestroy(){this.popover&&(this.popover.dispose(),this.popover=null),await super.onBeforeDestroy()}}export{c as BUILD_TIME,t as BaseChart,CircularProgress,e as MetricsChart,s as MetricsMiniChart,i as MetricsMiniChartWidget,r as MiniChart,o as PieChart,a as SeriesChart,u as VERSION,g as VERSION_INFO,d as VERSION_MAJOR,m as VERSION_MINOR,p as VERSION_REVISION,l as WebApp};
|
|
572
2
|
//# sourceMappingURL=charts.es.js.map
|