@sentio/ui-dashboard 0.2.4 → 0.2.6

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/index.mjs CHANGED
@@ -2989,6 +2989,684 @@ var ChartTypeButtonGroup = ({
2989
2989
  ) });
2990
2990
  };
2991
2991
 
2992
+ // src/charts/ChartTooltip.tsx
2993
+ import { Fragment as Fragment5, useMemo as useMemo5 } from "react";
2994
+ import dayjs from "dayjs";
2995
+ import utc from "dayjs/plugin/utc";
2996
+ import timezone from "dayjs/plugin/timezone";
2997
+ import { isNumber, some, sortBy as sortBy2 } from "lodash";
2998
+ import BigDecimal from "@sentio/bigdecimal";
2999
+ import { LuCircleUserRound, LuList } from "react-icons/lu";
3000
+ import { CopyButton, classNames as classNames5 } from "@sentio/ui-core";
3001
+
3002
+ // src/charts/duration.ts
3003
+ var longUnits = {
3004
+ s: "seconds",
3005
+ m: "minutes",
3006
+ h: "hours",
3007
+ d: "days",
3008
+ w: "weeks",
3009
+ M: "months",
3010
+ y: "years"
3011
+ };
3012
+ function durationToLongString(d) {
3013
+ const u = longUnits[d.unit ?? ""] ?? "";
3014
+ return Number(d.value) === 1 ? u.replace(/s$/, "") : u;
3015
+ }
3016
+
3017
+ // src/charts/ChartTooltip.tsx
3018
+ import { Fragment as Fragment6, jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
3019
+ dayjs.extend(utc);
3020
+ dayjs.extend(timezone);
3021
+ function isValidValue(value, includeZero) {
3022
+ if (includeZero) {
3023
+ return Number.isFinite(value);
3024
+ } else {
3025
+ return Number.isFinite(value) && value !== 0;
3026
+ }
3027
+ }
3028
+ function ChartTooltip({
3029
+ data,
3030
+ numberFormatter,
3031
+ compareTimeDuration,
3032
+ highlightSeriesId,
3033
+ title,
3034
+ showTotal,
3035
+ onViewLogs,
3036
+ viewLogDisabled,
3037
+ onViewUsers,
3038
+ viewUsersDisabled,
3039
+ isFixed
3040
+ }) {
3041
+ const {
3042
+ series,
3043
+ hasCompare,
3044
+ hasCurrent,
3045
+ currentTime,
3046
+ compareTime,
3047
+ markers,
3048
+ compareMarkers,
3049
+ total,
3050
+ compareTotal
3051
+ } = useMemo5(() => {
3052
+ const params = sortBy2(data, (p) => -p.value[1]);
3053
+ const hasCompare2 = some(
3054
+ params,
3055
+ (param) => param.seriesId.endsWith("_compare")
3056
+ );
3057
+ const seriesData = {};
3058
+ const markers2 = {};
3059
+ const compareMarkers2 = {};
3060
+ let currentTime2;
3061
+ let compareTime2;
3062
+ let total2 = new BigDecimal(0);
3063
+ let compareTotal2 = new BigDecimal(0);
3064
+ for (const p of params) {
3065
+ const { marker, seriesName, value, seriesId } = p;
3066
+ if (seriesId.endsWith("_compare")) {
3067
+ const id = seriesId.replace("_compare", "");
3068
+ compareMarkers2[id] = marker;
3069
+ if (compareTime2 === void 0) {
3070
+ compareTime2 = dayjs(value[0]);
3071
+ }
3072
+ if (isValidValue(value[1], hasCompare2)) {
3073
+ seriesData[id] = {
3074
+ seriesId: id,
3075
+ ...seriesData[id],
3076
+ compareValue: value[1],
3077
+ compareTime: value[0],
3078
+ seriesName
3079
+ };
3080
+ compareTotal2 = compareTotal2.plus(value[1]);
3081
+ }
3082
+ } else {
3083
+ markers2[seriesId] = marker;
3084
+ if (currentTime2 === void 0) {
3085
+ currentTime2 = dayjs(value[0]);
3086
+ }
3087
+ if (isValidValue(value[1], hasCompare2)) {
3088
+ seriesData[seriesId] = {
3089
+ seriesId,
3090
+ ...seriesData[seriesId],
3091
+ time: value[0],
3092
+ value: value[1],
3093
+ seriesName
3094
+ };
3095
+ total2 = total2.plus(value[1]);
3096
+ }
3097
+ }
3098
+ }
3099
+ const series2 = sortBy2(Object.values(seriesData), (s) => -s.value);
3100
+ const hasCurrent2 = series2[0]?.value !== void 0;
3101
+ if (compareTimeDuration && compareTime2 && !currentTime2) {
3102
+ currentTime2 = compareTime2.add(
3103
+ Number(compareTimeDuration.value),
3104
+ compareTimeDuration.unit
3105
+ );
3106
+ }
3107
+ return {
3108
+ series: series2,
3109
+ hasCompare: hasCompare2,
3110
+ currentTime: currentTime2,
3111
+ compareTime: compareTime2,
3112
+ hasCurrent: hasCurrent2,
3113
+ markers: markers2,
3114
+ compareMarkers: compareMarkers2,
3115
+ total: total2,
3116
+ compareTotal: compareTotal2
3117
+ };
3118
+ }, [data]);
3119
+ const renderRow = (p, idx) => {
3120
+ const { seriesName, compareValue, value, seriesId } = p;
3121
+ const highlighted = seriesId === highlightSeriesId;
3122
+ const marker = markers[seriesId];
3123
+ const diff = hasCompare && hasCurrent && compareValue != null && value != null ? new BigDecimal(value).minus(compareValue).div(compareValue).toNumber() : void 0;
3124
+ const showViewLogs = onViewLogs && !viewLogDisabled?.(seriesId, idx);
3125
+ const showViewUsers = onViewUsers && !viewUsersDisabled?.(seriesId, idx);
3126
+ return /* @__PURE__ */ jsxs14(Fragment5, { children: [
3127
+ /* @__PURE__ */ jsxs14(
3128
+ "div",
3129
+ {
3130
+ className: classNames5(
3131
+ "sentio-tooltip-item series-name text-text-foreground inline-flex items-center overflow-hidden",
3132
+ "group",
3133
+ highlighted ? "highlighted" : ""
3134
+ ),
3135
+ style: { minWidth: "4rem" },
3136
+ children: [
3137
+ /* @__PURE__ */ jsx20("span", { dangerouslySetInnerHTML: { __html: marker || "" } }),
3138
+ /* @__PURE__ */ jsx20("span", { className: "truncate", children: seriesName }),
3139
+ showViewLogs && isFixed && /* @__PURE__ */ jsx20(
3140
+ "button",
3141
+ {
3142
+ className: "text-text-foreground/60 hover:text-text-foreground invisible ml-1 text-xs underline group-hover:visible",
3143
+ onClick: (e) => {
3144
+ e.preventDefault();
3145
+ e.stopPropagation();
3146
+ onViewLogs(seriesId, idx);
3147
+ },
3148
+ title: "View logs",
3149
+ children: /* @__PURE__ */ jsx20(LuList, { className: "h-4 w-4" })
3150
+ }
3151
+ ),
3152
+ showViewUsers && isFixed && /* @__PURE__ */ jsx20(
3153
+ "button",
3154
+ {
3155
+ className: "text-text-foreground/60 hover:text-text-foreground invisible ml-1 text-xs underline group-hover:visible",
3156
+ onClick: (e) => {
3157
+ e.preventDefault();
3158
+ e.stopPropagation();
3159
+ onViewUsers(seriesId, idx);
3160
+ },
3161
+ title: "View users",
3162
+ children: /* @__PURE__ */ jsx20(LuCircleUserRound, { className: "h-4 w-4" })
3163
+ }
3164
+ ),
3165
+ isFixed && /* @__PURE__ */ jsx20(
3166
+ CopyButton,
3167
+ {
3168
+ size: 16,
3169
+ text: seriesName,
3170
+ className: "invisible ml-1 group-hover:visible"
3171
+ }
3172
+ )
3173
+ ]
3174
+ },
3175
+ idx
3176
+ ),
3177
+ /* @__PURE__ */ jsxs14(
3178
+ "div",
3179
+ {
3180
+ className: classNames5(
3181
+ "sentio-tooltip-item min-w-16 flex items-center truncate pl-1 text-right font-semibold",
3182
+ highlighted ? "highlighted" : ""
3183
+ ),
3184
+ children: [
3185
+ /* @__PURE__ */ jsx20("span", { children: hasCurrent ? numberFormatter(value, seriesId) : "-" }),
3186
+ diff !== void 0 && Number.isFinite(diff) && /* @__PURE__ */ jsxs14(
3187
+ "span",
3188
+ {
3189
+ className: classNames5(
3190
+ "ml-1 text-xs",
3191
+ diff > 0 ? "text-green-500" : "text-red"
3192
+ ),
3193
+ children: [
3194
+ diff > 0 ? "+" : "",
3195
+ (diff * 100).toFixed(2),
3196
+ "%"
3197
+ ]
3198
+ }
3199
+ )
3200
+ ]
3201
+ },
3202
+ `${idx}-value`
3203
+ )
3204
+ ] }, idx);
3205
+ };
3206
+ const renderCompareRow = (p, idx) => {
3207
+ const { seriesName, compareValue, seriesId } = p;
3208
+ const highlighted = seriesId === highlightSeriesId;
3209
+ const compareMarker = compareMarkers[seriesId];
3210
+ return /* @__PURE__ */ jsxs14(Fragment5, { children: [
3211
+ /* @__PURE__ */ jsxs14(
3212
+ "div",
3213
+ {
3214
+ className: classNames5(
3215
+ "sentio-tooltip-item sentio-tooltip-compare-item series-name text-text-foreground-secondary truncate",
3216
+ highlighted ? "highlighted" : ""
3217
+ ),
3218
+ style: { minWidth: "4rem" },
3219
+ children: [
3220
+ /* @__PURE__ */ jsx20(
3221
+ "span",
3222
+ {
3223
+ dangerouslySetInnerHTML: { __html: compareMarker || "" }
3224
+ }
3225
+ ),
3226
+ seriesName
3227
+ ]
3228
+ },
3229
+ idx
3230
+ ),
3231
+ /* @__PURE__ */ jsx20(
3232
+ "div",
3233
+ {
3234
+ className: classNames5(
3235
+ "sentio-tooltip-item min-w-16 text-text-foreground-secondary truncate pl-1 text-right font-semibold",
3236
+ highlighted ? "highlighted" : ""
3237
+ ),
3238
+ children: isNumber(compareValue) ? numberFormatter(compareValue, seriesId) : "-"
3239
+ },
3240
+ `${idx}-value`
3241
+ )
3242
+ ] }, idx);
3243
+ };
3244
+ const renderTotalRow = () => {
3245
+ if (!showTotal || series.length < 2) return null;
3246
+ const diff = hasCompare && hasCurrent && total && compareTotal ? total.minus(compareTotal).div(compareTotal).toNumber() : void 0;
3247
+ return /* @__PURE__ */ jsxs14("div", { className: "border-border-color col-span-2 mt-1 flex items-center justify-between border-t pt-1", children: [
3248
+ /* @__PURE__ */ jsx20("div", { className: "sentio-tooltip-item series-name text-text-foreground truncate font-semibold", children: "Total" }),
3249
+ /* @__PURE__ */ jsxs14("div", { className: "sentio-tooltip-item min-w-16 flex items-center truncate pl-1 text-right font-semibold", children: [
3250
+ /* @__PURE__ */ jsx20("span", { children: hasCurrent ? numberFormatter(total.toNumber()) : "-" }),
3251
+ diff !== void 0 && Number.isFinite(diff) && /* @__PURE__ */ jsxs14(
3252
+ "span",
3253
+ {
3254
+ className: classNames5(
3255
+ "ml-1 text-xs",
3256
+ diff > 0 ? "text-green-500" : "text-red"
3257
+ ),
3258
+ children: [
3259
+ diff > 0 ? "+" : "",
3260
+ (diff * 100).toFixed(2),
3261
+ "%"
3262
+ ]
3263
+ }
3264
+ )
3265
+ ] })
3266
+ ] });
3267
+ };
3268
+ const renderCompareTotalRow = () => {
3269
+ if (!showTotal || series.length < 2 || !hasCompare) return null;
3270
+ return /* @__PURE__ */ jsxs14("div", { className: "border-border-color col-span-2 mt-1 flex items-center justify-between border-t pt-1", children: [
3271
+ /* @__PURE__ */ jsx20("div", { className: "sentio-tooltip-item sentio-tooltip-compare-item series-name text-text-foreground-secondary truncate font-semibold", children: "Total" }),
3272
+ /* @__PURE__ */ jsx20("div", { className: "sentio-tooltip-item min-w-16 text-text-foreground-secondary truncate pl-1 text-right font-semibold", children: isNumber(compareTotal) ? numberFormatter(compareTotal.toNumber()) : "-" })
3273
+ ] });
3274
+ };
3275
+ return /* @__PURE__ */ jsxs14(
3276
+ "div",
3277
+ {
3278
+ className: classNames5("grid w-full px-2"),
3279
+ style: { gridTemplateColumns: "1fr auto" },
3280
+ children: [
3281
+ /* @__PURE__ */ jsx20(
3282
+ "div",
3283
+ {
3284
+ className: classNames5(
3285
+ "pl-2",
3286
+ "text-text-foreground-secondary col-span-2 text-left"
3287
+ ),
3288
+ children: title ?? currentTime?.format("YYYY-MM-DD HH:mm:ss")
3289
+ }
3290
+ ),
3291
+ !series || series.length === 0 ? /* @__PURE__ */ jsx20("div", { className: "text-text-foreground-secondary pl-2 text-sm", children: "No data available" }) : /* @__PURE__ */ jsxs14(Fragment6, { children: [
3292
+ series.map((s, idx) => renderRow(s, idx)),
3293
+ renderTotalRow(),
3294
+ hasCompare && compareTimeDuration && /* @__PURE__ */ jsxs14(Fragment6, { children: [
3295
+ /* @__PURE__ */ jsxs14(
3296
+ "div",
3297
+ {
3298
+ className: classNames5(
3299
+ "mt-2 pl-2",
3300
+ "text-text-foreground-secondary col-span-2 text-left"
3301
+ ),
3302
+ children: [
3303
+ compareTime?.format("YYYY-MM-DD HH:mm:ss"),
3304
+ " (previous",
3305
+ " ",
3306
+ durationToLongString(compareTimeDuration),
3307
+ ")"
3308
+ ]
3309
+ }
3310
+ ),
3311
+ series.map((s, idx) => renderCompareRow(s, idx)),
3312
+ renderCompareTotalRow()
3313
+ ] })
3314
+ ] })
3315
+ ]
3316
+ }
3317
+ );
3318
+ }
3319
+
3320
+ // src/charts/ScatterChartTooltip.tsx
3321
+ import { Fragment as Fragment7, useMemo as useMemo6 } from "react";
3322
+ import dayjs2 from "dayjs";
3323
+ import utc2 from "dayjs/plugin/utc";
3324
+ import timezone2 from "dayjs/plugin/timezone";
3325
+ import { isNumber as isNumber2 } from "lodash";
3326
+ import { LuCircleUserRound as LuCircleUserRound2, LuList as LuList2 } from "react-icons/lu";
3327
+ import { CopyButton as CopyButton2, classNames as classNames6 } from "@sentio/ui-core";
3328
+ import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
3329
+ dayjs2.extend(utc2);
3330
+ dayjs2.extend(timezone2);
3331
+ function ScatterChartTooltip({
3332
+ data,
3333
+ numberFormatter,
3334
+ highlightSeriesId,
3335
+ title,
3336
+ onViewLogs,
3337
+ viewLogDisabled,
3338
+ onViewUsers,
3339
+ viewUsersDisabled,
3340
+ isFixed,
3341
+ sizeTitle = "Size"
3342
+ }) {
3343
+ const { point, seriesName, seriesId, marker } = useMemo6(() => {
3344
+ const param = Array.isArray(data) ? data[0] : data;
3345
+ return {
3346
+ point: param,
3347
+ seriesName: param?.seriesName || "",
3348
+ seriesId: param?.seriesId || "",
3349
+ marker: param?.marker || ""
3350
+ };
3351
+ }, [data]);
3352
+ if (!point || !point.value) {
3353
+ return /* @__PURE__ */ jsx21("div", { className: "w-full px-2", children: /* @__PURE__ */ jsx21("div", { className: "text-text-foreground-secondary pl-2 text-sm", children: "No data available" }) });
3354
+ }
3355
+ const { value } = point;
3356
+ const [xValue, yValue, sizeValue] = value;
3357
+ const highlighted = seriesId === highlightSeriesId;
3358
+ const showViewLogs = onViewLogs && !viewLogDisabled?.(seriesId, 0);
3359
+ const showViewUsers = onViewUsers && !viewUsersDisabled?.(seriesId, 0);
3360
+ const formatValue = (val) => {
3361
+ if (val instanceof Date) {
3362
+ return dayjs2(val).format("YYYY-MM-DD HH:mm:ss");
3363
+ } else if (isNumber2(val)) {
3364
+ return numberFormatter(val);
3365
+ } else {
3366
+ return String(val);
3367
+ }
3368
+ };
3369
+ return /* @__PURE__ */ jsxs15(
3370
+ "div",
3371
+ {
3372
+ className: classNames6("grid w-full px-2"),
3373
+ style: { gridTemplateColumns: "1fr auto" },
3374
+ children: [
3375
+ /* @__PURE__ */ jsx21(
3376
+ "div",
3377
+ {
3378
+ className: classNames6(
3379
+ "mb-2 pl-2",
3380
+ "text-text-foreground-secondary col-span-2 text-left"
3381
+ ),
3382
+ children: title ?? dayjs2(xValue).format("YYYY-MM-DD HH:mm:ss")
3383
+ }
3384
+ ),
3385
+ /* @__PURE__ */ jsxs15(
3386
+ "div",
3387
+ {
3388
+ className: classNames6(
3389
+ "sentio-tooltip-item series-name text-text-foreground inline-flex items-center overflow-hidden",
3390
+ "group",
3391
+ highlighted ? "highlighted" : ""
3392
+ ),
3393
+ style: { minWidth: "4rem" },
3394
+ children: [
3395
+ /* @__PURE__ */ jsx21("span", { dangerouslySetInnerHTML: { __html: marker || "" } }),
3396
+ /* @__PURE__ */ jsx21("span", { className: "truncate", children: seriesName }),
3397
+ showViewLogs && isFixed && /* @__PURE__ */ jsx21(
3398
+ "button",
3399
+ {
3400
+ className: "text-text-foreground/60 hover:text-text-foreground invisible ml-1 text-xs underline group-hover:visible",
3401
+ onClick: (e) => {
3402
+ e.preventDefault();
3403
+ e.stopPropagation();
3404
+ onViewLogs(seriesId, 0);
3405
+ },
3406
+ title: "View logs",
3407
+ children: /* @__PURE__ */ jsx21(LuList2, { className: "h-4 w-4" })
3408
+ }
3409
+ ),
3410
+ showViewUsers && isFixed && /* @__PURE__ */ jsx21(
3411
+ "button",
3412
+ {
3413
+ className: "text-text-foreground/60 hover:text-text-foreground invisible ml-1 text-xs underline group-hover:visible",
3414
+ onClick: (e) => {
3415
+ e.preventDefault();
3416
+ e.stopPropagation();
3417
+ onViewUsers(seriesId, 0);
3418
+ },
3419
+ title: "View users",
3420
+ children: /* @__PURE__ */ jsx21(LuCircleUserRound2, { className: "h-4 w-4" })
3421
+ }
3422
+ ),
3423
+ isFixed && /* @__PURE__ */ jsx21(
3424
+ CopyButton2,
3425
+ {
3426
+ size: 16,
3427
+ text: seriesName,
3428
+ className: "invisible ml-1 group-hover:visible"
3429
+ }
3430
+ )
3431
+ ]
3432
+ }
3433
+ ),
3434
+ /* @__PURE__ */ jsx21(
3435
+ "div",
3436
+ {
3437
+ className: classNames6(
3438
+ "sentio-tooltip-item min-w-16 flex items-center truncate pl-1 text-right font-semibold",
3439
+ highlighted ? "highlighted" : ""
3440
+ ),
3441
+ children: /* @__PURE__ */ jsx21("span", { children: formatValue(yValue) })
3442
+ }
3443
+ ),
3444
+ sizeValue !== void 0 && sizeValue !== null && /* @__PURE__ */ jsxs15(Fragment7, { children: [
3445
+ /* @__PURE__ */ jsx21("div", { className: "border-border-color col-span-2 my-2 w-full border-t" }),
3446
+ /* @__PURE__ */ jsx21(
3447
+ "div",
3448
+ {
3449
+ className: "sentio-tooltip-item series-name text-text-foreground-secondary truncate",
3450
+ style: { minWidth: "4rem" },
3451
+ children: sizeTitle
3452
+ }
3453
+ ),
3454
+ /* @__PURE__ */ jsx21("div", { className: "sentio-tooltip-item min-w-16 text-text-foreground-secondary truncate pl-1 text-right font-semibold", children: formatValue(sizeValue) })
3455
+ ] })
3456
+ ]
3457
+ }
3458
+ );
3459
+ }
3460
+
3461
+ // src/charts/PieChart.tsx
3462
+ import { forwardRef as forwardRef2, useEffect as useEffect6, useState as useState8 } from "react";
3463
+ import { useResizeDetector as useResizeDetector3 } from "react-resize-detector";
3464
+ import { jsx as jsx22 } from "react/jsx-runtime";
3465
+ var theresholdWidth = 480;
3466
+ var TOOLTIP_MIN_VIEWPORT_LEFT = 8;
3467
+ var TOOLTIP_MIN_VIEWPORT_RIGHT = 8;
3468
+ var PieChart2 = forwardRef2(
3469
+ (props, ref) => {
3470
+ const {
3471
+ series,
3472
+ valueFormatter,
3473
+ config,
3474
+ title,
3475
+ minHeight,
3476
+ loading,
3477
+ style,
3478
+ onInitChart
3479
+ } = props;
3480
+ const [options, setOptions] = useState8({});
3481
+ const isDarkMode = useDarkMode();
3482
+ const isMobile2 = isMobile();
3483
+ const { width, ref: resizeRef } = useResizeDetector3({
3484
+ refreshMode: "debounce",
3485
+ refreshRate: 500,
3486
+ handleHeight: false
3487
+ });
3488
+ const tooltipPosition = (point, _params, _dom, _rect, size) => {
3489
+ const chartRect = resizeRef.current?.getBoundingClientRect();
3490
+ const chartLeft = chartRect?.left ?? 0;
3491
+ const winW = typeof window !== "undefined" ? window.innerWidth : size.viewSize[0];
3492
+ const [w, h] = size.contentSize;
3493
+ const minXInChart = TOOLTIP_MIN_VIEWPORT_LEFT - chartLeft;
3494
+ const maxXInChart = winW - TOOLTIP_MIN_VIEWPORT_RIGHT - chartLeft - w;
3495
+ let x = point[0] + 12;
3496
+ if (x > maxXInChart) {
3497
+ x = point[0] - w - 12;
3498
+ }
3499
+ if (x < minXInChart) x = minXInChart;
3500
+ if (x > maxXInChart) x = maxXInChart;
3501
+ const y = Math.max(0, point[1] - h / 2);
3502
+ return [x, y];
3503
+ };
3504
+ useEffect6(() => {
3505
+ const isHLegend = width && width < theresholdWidth;
3506
+ const winW = typeof window !== "undefined" ? window.innerWidth : 1024;
3507
+ const tooltipMaxWidth = Math.max(160, Math.min(280, winW - 48));
3508
+ const tooltipExtraCss = isMobile2 ? `max-width: ${tooltipMaxWidth}px; white-space: normal; word-break: break-word; overflow-wrap: anywhere;` : "";
3509
+ const d = [];
3510
+ series.forEach((s) => {
3511
+ if (s.data.length > 0 && s.data[0] && s.data[0][1] != null) {
3512
+ const rawValue = s.data[0][1];
3513
+ if (config?.pieConfig?.absValue) {
3514
+ d.push({ name: s.name, value: Math.abs(rawValue) });
3515
+ } else if (rawValue > 0) {
3516
+ d.push({ name: s.name, value: rawValue });
3517
+ }
3518
+ }
3519
+ });
3520
+ const total = d.reduce((acc, cur) => acc + cur.value, 0);
3521
+ d.sort((a, b) => {
3522
+ const percentA = a.value / total * 100;
3523
+ const percentB = b.value / total * 100;
3524
+ return percentB - percentA;
3525
+ });
3526
+ const pieSeries = [
3527
+ {
3528
+ type: "pie",
3529
+ radius: [config?.pieConfig?.pieType == "Donut" ? "40%" : 0, "70%"],
3530
+ center: isHLegend ? ["50%", "50%"] : ["35%", "50%"],
3531
+ label: { show: false },
3532
+ labelLine: { length: 10, length2: 10, maxSurfaceAngle: 50 },
3533
+ data: d
3534
+ }
3535
+ ];
3536
+ const options2 = {
3537
+ title: { text: title, left: 8 },
3538
+ legend: isHLegend ? {
3539
+ type: "scroll",
3540
+ orient: "horizontal",
3541
+ bottom: 12,
3542
+ left: "center",
3543
+ animation: true,
3544
+ animationDurationUpdate: 300,
3545
+ pageIconSize: [10, 8],
3546
+ pageButtonItemGap: 2,
3547
+ pageButtonGap: 4,
3548
+ textStyle: {
3549
+ width: width ? width * 0.4 : 100,
3550
+ overflow: "truncate"
3551
+ },
3552
+ tooltip: {
3553
+ show: true,
3554
+ appendToBody: true,
3555
+ extraCssText: tooltipExtraCss,
3556
+ position: tooltipPosition,
3557
+ formatter: function(params) {
3558
+ const name = params.name;
3559
+ const item = d.find((i) => i.name === name);
3560
+ let ret = name;
3561
+ if (config?.pieConfig?.showValue && item) {
3562
+ ret += "<br/>" + valueFormatter(item.value);
3563
+ }
3564
+ if (config?.pieConfig?.showPercent && item) {
3565
+ const percent = (item.value / d.reduce((acc, cur) => acc + cur.value, 0) * 100).toFixed(2);
3566
+ ret += config.pieConfig.showValue ? ` \u2022 ${percent}%` : `
3567
+ ${percent}%`;
3568
+ }
3569
+ return ret;
3570
+ }
3571
+ }
3572
+ } : {
3573
+ type: "scroll",
3574
+ orient: "vertical",
3575
+ right: 16,
3576
+ top: title ? 48 : 8,
3577
+ width: "35%",
3578
+ animation: true,
3579
+ animationDurationUpdate: 300,
3580
+ tooltip: {
3581
+ show: true,
3582
+ appendToBody: true,
3583
+ extraCssText: tooltipExtraCss,
3584
+ position: tooltipPosition,
3585
+ formatter: function(params) {
3586
+ const name = params.name;
3587
+ const item = d.find((i) => i.name === name);
3588
+ let ret = name;
3589
+ if (config?.pieConfig?.showValue && item) {
3590
+ ret += "<br/>" + valueFormatter(item.value);
3591
+ }
3592
+ if (config?.pieConfig?.showPercent && item) {
3593
+ const percent = (item.value / d.reduce((acc, cur) => acc + cur.value, 0) * 100).toFixed(2);
3594
+ ret += config.pieConfig.showValue ? ` \u2022 ${percent}%` : `
3595
+ ${percent}%`;
3596
+ }
3597
+ return ret;
3598
+ }
3599
+ },
3600
+ icon: "roundRect",
3601
+ itemWidth: 12,
3602
+ itemHeight: 12,
3603
+ itemGap: 6,
3604
+ show: true,
3605
+ pageIconSize: [8, 10],
3606
+ pageButtonGap: 4,
3607
+ pageButtonItemGap: 2,
3608
+ pageIconColor: isDarkMode ? "#909399" : "#4E5969",
3609
+ pageIconInactiveColor: isDarkMode ? "#606266" : "#C9CDD4",
3610
+ textStyle: {
3611
+ width: width ? width * 0.3 : "auto",
3612
+ overflow: "truncate",
3613
+ lineHeight: 16,
3614
+ fontSize: 12,
3615
+ rich: { value: { padding: [4, 0, 0, 0] } }
3616
+ },
3617
+ formatter: (name) => {
3618
+ const item = d.find((i) => i.name === name);
3619
+ let ret = name;
3620
+ if (config?.pieConfig?.showValue && item) {
3621
+ ret += "\n" + valueFormatter(item.value);
3622
+ }
3623
+ if (config?.pieConfig?.showPercent && item) {
3624
+ const percent = (item.value / d.reduce((acc, cur) => acc + cur.value, 0) * 100).toFixed(2);
3625
+ ret += config.pieConfig.showValue ? ` \u2022 ${percent}%` : `
3626
+ ${percent}%`;
3627
+ }
3628
+ return ret;
3629
+ }
3630
+ },
3631
+ tooltip: {
3632
+ trigger: "item",
3633
+ appendToBody: true,
3634
+ extraCssText: tooltipExtraCss,
3635
+ position: tooltipPosition,
3636
+ formatter: ({ name, data, percent }) => {
3637
+ let ret = `${name}`;
3638
+ if (config?.pieConfig?.showValue) {
3639
+ ret += "<br/>" + valueFormatter(data.value);
3640
+ }
3641
+ if (config?.pieConfig?.showPercent) {
3642
+ ret += config.pieConfig.showValue ? ` (${percent}%)` : `
3643
+ ${percent}%`;
3644
+ }
3645
+ return ret;
3646
+ }
3647
+ },
3648
+ toolbox: { show: false },
3649
+ animation: false,
3650
+ series: pieSeries
3651
+ };
3652
+ setOptions(options2);
3653
+ }, [series, config, valueFormatter, isDarkMode, isMobile2, width, title]);
3654
+ return /* @__PURE__ */ jsx22("div", { className: "h-full w-full", ref: resizeRef, children: /* @__PURE__ */ jsx22(
3655
+ ReactEChartsBase,
3656
+ {
3657
+ ref,
3658
+ loading,
3659
+ option: options,
3660
+ minHeight,
3661
+ style,
3662
+ noLegend: true,
3663
+ onInitChart
3664
+ }
3665
+ ) });
3666
+ }
3667
+ );
3668
+ PieChart2.displayName = "PieChart";
3669
+
2992
3670
  // src/charts/options/LineControls.tsx
2993
3671
  import { produce as produce4 } from "immer";
2994
3672
  import {
@@ -2996,7 +3674,7 @@ import {
2996
3674
  NewButtonGroup as ButtonGroup2,
2997
3675
  Checkbox
2998
3676
  } from "@sentio/ui-core";
2999
- import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
3677
+ import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
3000
3678
  var lineStyles = [
3001
3679
  { label: "Solid", value: "Solid" },
3002
3680
  { label: "Dotted", value: "Dotted" }
@@ -3016,13 +3694,13 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
3016
3694
  })
3017
3695
  );
3018
3696
  };
3019
- return /* @__PURE__ */ jsx20(
3697
+ return /* @__PURE__ */ jsx23(
3020
3698
  DisclosurePanel,
3021
3699
  {
3022
3700
  title: "Line style",
3023
3701
  containerClassName: "w-full bg-default-bg",
3024
- children: /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-4", children: [
3025
- /* @__PURE__ */ jsx20(
3702
+ children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-4", children: [
3703
+ /* @__PURE__ */ jsx23(
3026
3704
  ButtonGroup2,
3027
3705
  {
3028
3706
  buttons: lineStyles,
@@ -3031,7 +3709,7 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
3031
3709
  small: true
3032
3710
  }
3033
3711
  ),
3034
- /* @__PURE__ */ jsx20(
3712
+ /* @__PURE__ */ jsx23(
3035
3713
  Checkbox,
3036
3714
  {
3037
3715
  label: "Smooth Curves",
@@ -3045,16 +3723,16 @@ var LineControls = ({ config, defaultOpen, onChange }) => {
3045
3723
  };
3046
3724
 
3047
3725
  // src/charts/options/LabelControls.tsx
3048
- import { useEffect as useEffect6, useMemo as useMemo5 } from "react";
3726
+ import { useEffect as useEffect7, useMemo as useMemo7 } from "react";
3049
3727
  import { produce as produce5 } from "immer";
3050
3728
  import { Button as NewButton2, DisclosurePanel as DisclosurePanel2, HelpIcon as HelpIcon2 } from "@sentio/ui-core";
3051
- import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
3729
+ import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
3052
3730
  var initialConfig = {
3053
3731
  columns: [],
3054
3732
  alias: ""
3055
3733
  };
3056
3734
  var LabelControls = ({ config, setConfig, defaultOpen }) => {
3057
- useEffect6(() => {
3735
+ useEffect7(() => {
3058
3736
  if (config?.columns && config.columns.length > 0 && !config.alias) {
3059
3737
  const aliasParts = [];
3060
3738
  config.columns.forEach((colConfig) => {
@@ -3084,31 +3762,31 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
3084
3762
  })
3085
3763
  );
3086
3764
  };
3087
- const _defaultOpen = useMemo5(() => {
3765
+ const _defaultOpen = useMemo7(() => {
3088
3766
  if (defaultOpen) {
3089
3767
  return true;
3090
3768
  }
3091
3769
  return config?.alias !== "" || config?.columns && config.columns.length > 0;
3092
3770
  }, [config, defaultOpen]);
3093
- return /* @__PURE__ */ jsx21(
3771
+ return /* @__PURE__ */ jsx24(
3094
3772
  DisclosurePanel2,
3095
3773
  {
3096
3774
  title: "Label Controls",
3097
3775
  defaultOpen: _defaultOpen,
3098
3776
  containerClassName: "w-full bg-default-bg",
3099
- children: /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2", children: [
3100
- /* @__PURE__ */ jsxs15("div", { className: "inline-flex h-8", children: [
3101
- /* @__PURE__ */ jsxs15("span", { className: "sm:text-icontent border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-2 font-medium", children: [
3777
+ children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
3778
+ /* @__PURE__ */ jsxs17("div", { className: "inline-flex h-8", children: [
3779
+ /* @__PURE__ */ jsxs17("span", { className: "sm:text-icontent border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-2 font-medium", children: [
3102
3780
  "Label Alias",
3103
- /* @__PURE__ */ jsx21(
3781
+ /* @__PURE__ */ jsx24(
3104
3782
  HelpIcon2,
3105
3783
  {
3106
- text: /* @__PURE__ */ jsxs15("div", { className: "text-icontent text-text-foreground", children: [
3107
- /* @__PURE__ */ jsx21("div", { children: "Series name override or template." }),
3108
- /* @__PURE__ */ jsxs15("div", { children: [
3784
+ text: /* @__PURE__ */ jsxs17("div", { className: "text-icontent text-text-foreground", children: [
3785
+ /* @__PURE__ */ jsx24("div", { children: "Series name override or template." }),
3786
+ /* @__PURE__ */ jsxs17("div", { children: [
3109
3787
  "Ex.",
3110
3788
  " ",
3111
- /* @__PURE__ */ jsx21("span", { className: "text-primary mx-1 font-semibold italic", children: "{{contract}}" }),
3789
+ /* @__PURE__ */ jsx24("span", { className: "text-primary mx-1 font-semibold italic", children: "{{contract}}" }),
3112
3790
  " ",
3113
3791
  "will be replaced with the value of the contract label."
3114
3792
  ] })
@@ -3116,7 +3794,7 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
3116
3794
  }
3117
3795
  )
3118
3796
  ] }),
3119
- /* @__PURE__ */ jsx21(
3797
+ /* @__PURE__ */ jsx24(
3120
3798
  "input",
3121
3799
  {
3122
3800
  type: "text",
@@ -3127,7 +3805,7 @@ var LabelControls = ({ config, setConfig, defaultOpen }) => {
3127
3805
  }
3128
3806
  )
3129
3807
  ] }),
3130
- /* @__PURE__ */ jsx21(
3808
+ /* @__PURE__ */ jsx24(
3131
3809
  NewButton2,
3132
3810
  {
3133
3811
  type: "button",
@@ -3151,7 +3829,7 @@ import {
3151
3829
  DisclosurePanel as DisclosurePanel3,
3152
3830
  NewButtonGroup as ButtonGroup3
3153
3831
  } from "@sentio/ui-core";
3154
- import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
3832
+ import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
3155
3833
  var defaultConfig = {
3156
3834
  pieType: "Pie",
3157
3835
  calculation: "LAST",
@@ -3186,14 +3864,14 @@ function PieChartControls({ config, defaultOpen, onChange }) {
3186
3864
  })
3187
3865
  );
3188
3866
  }
3189
- return /* @__PURE__ */ jsx22(
3867
+ return /* @__PURE__ */ jsx25(
3190
3868
  DisclosurePanel3,
3191
3869
  {
3192
3870
  title: "Pie Chart Options",
3193
3871
  defaultOpen,
3194
3872
  containerClassName: "w-full bg-default-bg",
3195
- children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-4", children: [
3196
- /* @__PURE__ */ jsx22("div", { className: "shadow-xs flex rounded-md", children: /* @__PURE__ */ jsx22(
3873
+ children: /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-4", children: [
3874
+ /* @__PURE__ */ jsx25("div", { className: "shadow-xs flex rounded-md", children: /* @__PURE__ */ jsx25(
3197
3875
  ButtonGroup3,
3198
3876
  {
3199
3877
  small: true,
@@ -3202,21 +3880,21 @@ function PieChartControls({ config, defaultOpen, onChange }) {
3202
3880
  onChange: onPieTypeChange
3203
3881
  }
3204
3882
  ) }),
3205
- /* @__PURE__ */ jsxs16("div", { className: "shadow-xs flex rounded-md", children: [
3206
- /* @__PURE__ */ jsx22("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
3207
- /* @__PURE__ */ jsx22(
3883
+ /* @__PURE__ */ jsxs18("div", { className: "shadow-xs flex rounded-md", children: [
3884
+ /* @__PURE__ */ jsx25("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
3885
+ /* @__PURE__ */ jsx25(
3208
3886
  "select",
3209
3887
  {
3210
3888
  value: config.calculation,
3211
3889
  className: "sm:text-ilabel text-text-foreground border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
3212
3890
  onChange: (e) => onCalculationChange(e.target.value),
3213
3891
  children: CalculationItems.map((d) => {
3214
- return /* @__PURE__ */ jsx22("option", { value: d.value, children: d.label }, d.value);
3892
+ return /* @__PURE__ */ jsx25("option", { value: d.value, children: d.label }, d.value);
3215
3893
  })
3216
3894
  }
3217
3895
  )
3218
3896
  ] }),
3219
- /* @__PURE__ */ jsx22(
3897
+ /* @__PURE__ */ jsx25(
3220
3898
  Checkbox2,
3221
3899
  {
3222
3900
  checked: config?.showValue,
@@ -3225,7 +3903,7 @@ function PieChartControls({ config, defaultOpen, onChange }) {
3225
3903
  labelClassName: "whitespace-nowrap"
3226
3904
  }
3227
3905
  ),
3228
- /* @__PURE__ */ jsx22(
3906
+ /* @__PURE__ */ jsx25(
3229
3907
  Checkbox2,
3230
3908
  {
3231
3909
  checked: config?.showPercent,
@@ -3234,7 +3912,7 @@ function PieChartControls({ config, defaultOpen, onChange }) {
3234
3912
  labelClassName: "whitespace-nowrap"
3235
3913
  }
3236
3914
  ),
3237
- /* @__PURE__ */ jsx22(
3915
+ /* @__PURE__ */ jsx25(
3238
3916
  Checkbox2,
3239
3917
  {
3240
3918
  checked: config?.absValue,
@@ -3252,7 +3930,7 @@ function PieChartControls({ config, defaultOpen, onChange }) {
3252
3930
  import { produce as produce7 } from "immer";
3253
3931
  import { defaults as defaults2 } from "lodash";
3254
3932
  import { DisclosurePanel as DisclosurePanel4 } from "@sentio/ui-core";
3255
- import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
3933
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
3256
3934
  var defaultConfig2 = {
3257
3935
  direction: "HORIZONTAL",
3258
3936
  calculation: "LAST",
@@ -3297,70 +3975,70 @@ function BarGaugeControls({ config, defaultOpen, onChange }) {
3297
3975
  })
3298
3976
  );
3299
3977
  }
3300
- function onSortByChange(sortBy2) {
3978
+ function onSortByChange(sortBy3) {
3301
3979
  config && onChange(
3302
3980
  produce7(config, (draft) => {
3303
3981
  draft.sort = draft.sort || {};
3304
- draft.sort.sortBy = sortBy2;
3982
+ draft.sort.sortBy = sortBy3;
3305
3983
  })
3306
3984
  );
3307
3985
  }
3308
- return /* @__PURE__ */ jsx23(
3986
+ return /* @__PURE__ */ jsx26(
3309
3987
  DisclosurePanel4,
3310
3988
  {
3311
3989
  title: "Bar Gauge Options",
3312
3990
  defaultOpen,
3313
3991
  containerClassName: "w-full bg-default-bg",
3314
- children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-4", children: [
3315
- /* @__PURE__ */ jsxs17("div", { className: "shadow-xs flex rounded-md", children: [
3316
- /* @__PURE__ */ jsx23("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Direction" }),
3317
- /* @__PURE__ */ jsx23(
3992
+ children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-4", children: [
3993
+ /* @__PURE__ */ jsxs19("div", { className: "shadow-xs flex rounded-md", children: [
3994
+ /* @__PURE__ */ jsx26("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Direction" }),
3995
+ /* @__PURE__ */ jsx26(
3318
3996
  "select",
3319
3997
  {
3320
3998
  value: config.direction,
3321
3999
  className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
3322
4000
  onChange: (e) => onDirectionChange(e.target.value),
3323
4001
  children: directionItems.map((d) => {
3324
- return /* @__PURE__ */ jsx23("option", { value: d.value, children: d.label }, d.value);
4002
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
3325
4003
  })
3326
4004
  }
3327
4005
  )
3328
4006
  ] }),
3329
- /* @__PURE__ */ jsxs17("div", { className: "shadow-xs flex rounded-md", children: [
3330
- /* @__PURE__ */ jsx23("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
3331
- /* @__PURE__ */ jsx23(
4007
+ /* @__PURE__ */ jsxs19("div", { className: "shadow-xs flex rounded-md", children: [
4008
+ /* @__PURE__ */ jsx26("span", { className: "sm:text-ilabel border-main inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3 ", children: "Calculation" }),
4009
+ /* @__PURE__ */ jsx26(
3332
4010
  "select",
3333
4011
  {
3334
4012
  value: config.calculation,
3335
4013
  className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7",
3336
4014
  onChange: (e) => onCalculationChange(e.target.value),
3337
4015
  children: CalculationItems2.map((d) => {
3338
- return /* @__PURE__ */ jsx23("option", { value: d.value, children: d.label }, d.value);
4016
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
3339
4017
  })
3340
4018
  }
3341
4019
  )
3342
4020
  ] }),
3343
- /* @__PURE__ */ jsxs17("div", { className: "shadow-xs flex rounded-md", children: [
3344
- /* @__PURE__ */ jsx23("span", { className: "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap rounded-l-md border border-r-0 bg-gray-50 px-3", children: "Sort by" }),
3345
- /* @__PURE__ */ jsx23(
4021
+ /* @__PURE__ */ jsxs19("div", { className: "shadow-xs flex rounded-md", children: [
4022
+ /* @__PURE__ */ jsx26("span", { className: "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap rounded-l-md border border-r-0 bg-gray-50 px-3", children: "Sort by" }),
4023
+ /* @__PURE__ */ jsx26(
3346
4024
  "select",
3347
4025
  {
3348
4026
  value: config?.sort?.sortBy,
3349
4027
  className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center border pl-4 pr-7",
3350
4028
  onChange: (e) => onSortByChange(e.target.value),
3351
4029
  children: sortByItems.map((d) => {
3352
- return /* @__PURE__ */ jsx23("option", { value: d.value, children: d.label }, d.value);
4030
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
3353
4031
  })
3354
4032
  }
3355
4033
  ),
3356
- /* @__PURE__ */ jsx23(
4034
+ /* @__PURE__ */ jsx26(
3357
4035
  "select",
3358
4036
  {
3359
4037
  value: config?.sort?.orderDesc + "",
3360
4038
  className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 focus:border-primary-600 inline-flex items-center rounded-r-md border border-l-0 pl-4 pr-7",
3361
4039
  onChange: (e) => onOrderChange(e.target.value === "true"),
3362
4040
  children: orderItems.map((d) => {
3363
- return /* @__PURE__ */ jsx23("option", { value: d.value + "", children: d.label }, d.label);
4041
+ return /* @__PURE__ */ jsx26("option", { value: d.value + "", children: d.label }, d.label);
3364
4042
  })
3365
4043
  }
3366
4044
  )
@@ -3372,13 +4050,13 @@ function BarGaugeControls({ config, defaultOpen, onChange }) {
3372
4050
 
3373
4051
  // src/charts/options/ValueOptions.tsx
3374
4052
  import { produce as produce9 } from "immer";
3375
- import { ComboInput, classNames as classNames6 } from "@sentio/ui-core";
4053
+ import { ComboInput, classNames as classNames8 } from "@sentio/ui-core";
3376
4054
 
3377
4055
  // src/charts/options/ValueStringMapping.tsx
3378
4056
  import { LuPlus, LuTrash2 } from "react-icons/lu";
3379
- import { Button, classNames as classNames5 } from "@sentio/ui-core";
4057
+ import { Button, classNames as classNames7 } from "@sentio/ui-core";
3380
4058
  import { produce as produce8 } from "immer";
3381
- import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
4059
+ import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
3382
4060
  var operators = {
3383
4061
  ">": "greater than",
3384
4062
  ">=": "greater or equal",
@@ -3388,17 +4066,17 @@ var operators = {
3388
4066
  "<=": "less or equal"
3389
4067
  };
3390
4068
  var renderTreeLine = (index, isLast) => {
3391
- return /* @__PURE__ */ jsx24("div", { className: "mr-2 flex h-12 w-3 flex-col items-center justify-center", children: /* @__PURE__ */ jsxs18("div", { className: "flex h-full w-full items-center", children: [
3392
- /* @__PURE__ */ jsx24(
4069
+ return /* @__PURE__ */ jsx27("div", { className: "mr-2 flex h-12 w-3 flex-col items-center justify-center", children: /* @__PURE__ */ jsxs20("div", { className: "flex h-full w-full items-center", children: [
4070
+ /* @__PURE__ */ jsx27(
3393
4071
  "div",
3394
4072
  {
3395
- className: classNames5(
4073
+ className: classNames7(
3396
4074
  "w-px bg-gray-300",
3397
4075
  isLast ? "h-1/2 self-start" : index === 0 ? "h-full self-end" : "h-full"
3398
4076
  )
3399
4077
  }
3400
4078
  ),
3401
- /* @__PURE__ */ jsx24("div", { className: "h-px w-3 bg-gray-300" })
4079
+ /* @__PURE__ */ jsx27("div", { className: "h-px w-3 bg-gray-300" })
3402
4080
  ] }) });
3403
4081
  };
3404
4082
  function ValueStringMapping({ rules, onChange }) {
@@ -3429,31 +4107,31 @@ function ValueStringMapping({ rules, onChange }) {
3429
4107
  })
3430
4108
  );
3431
4109
  }
3432
- return /* @__PURE__ */ jsxs18("div", { className: "flex w-full flex-col rounded-md py-2", children: [
4110
+ return /* @__PURE__ */ jsxs20("div", { className: "flex w-full flex-col rounded-md py-2", children: [
3433
4111
  (rules || []).map((rule, index) => {
3434
4112
  const isLast = index === (rules || []).length - 1;
3435
- return /* @__PURE__ */ jsxs18(
4113
+ return /* @__PURE__ */ jsxs20(
3436
4114
  "div",
3437
4115
  {
3438
4116
  className: "text-text-foreground flex h-10 items-center py-1",
3439
4117
  children: [
3440
4118
  renderTreeLine(index, isLast),
3441
- /* @__PURE__ */ jsx24("span", { className: "sm:text-ilabel inline-flex h-full items-center pr-3 font-medium", children: "If value is" }),
3442
- /* @__PURE__ */ jsx24(
4119
+ /* @__PURE__ */ jsx27("span", { className: "sm:text-ilabel inline-flex h-full items-center pr-3 font-medium", children: "If value is" }),
4120
+ /* @__PURE__ */ jsx27(
3443
4121
  "select",
3444
4122
  {
3445
4123
  value: rule.comparison,
3446
4124
  onChange: (e) => changeRule(index, "comparison", e.target.value),
3447
4125
  className: "rounded-r-0 sm:text-ilabel border-main text-text-foreground focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 inline-flex h-full items-center rounded-l-md border border-r-0 bg-gray-50 py-1 pl-4 pr-7",
3448
4126
  children: Object.entries(operators).map(([op, display]) => {
3449
- return /* @__PURE__ */ jsxs18("option", { value: op, children: [
4127
+ return /* @__PURE__ */ jsxs20("option", { value: op, children: [
3450
4128
  "is ",
3451
4129
  display
3452
4130
  ] }, op);
3453
4131
  })
3454
4132
  }
3455
4133
  ),
3456
- /* @__PURE__ */ jsx24(
4134
+ /* @__PURE__ */ jsx27(
3457
4135
  "input",
3458
4136
  {
3459
4137
  type: "text",
@@ -3467,8 +4145,8 @@ function ValueStringMapping({ rules, onChange }) {
3467
4145
  }
3468
4146
  }
3469
4147
  ),
3470
- /* @__PURE__ */ jsx24("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-3 font-medium", children: ", then show" }),
3471
- /* @__PURE__ */ jsx24(
4148
+ /* @__PURE__ */ jsx27("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-3 font-medium", children: ", then show" }),
4149
+ /* @__PURE__ */ jsx27(
3472
4150
  "input",
3473
4151
  {
3474
4152
  type: "text",
@@ -3482,14 +4160,14 @@ function ValueStringMapping({ rules, onChange }) {
3482
4160
  }
3483
4161
  }
3484
4162
  ),
3485
- /* @__PURE__ */ jsx24(
4163
+ /* @__PURE__ */ jsx27(
3486
4164
  "button",
3487
4165
  {
3488
4166
  type: "button",
3489
4167
  className: "mx-2",
3490
4168
  "aria-label": "remove",
3491
4169
  onClick: () => removeRule(index),
3492
- children: /* @__PURE__ */ jsx24(
4170
+ children: /* @__PURE__ */ jsx27(
3493
4171
  LuTrash2,
3494
4172
  {
3495
4173
  className: "icon text-text-foreground-disabled",
@@ -3503,7 +4181,7 @@ function ValueStringMapping({ rules, onChange }) {
3503
4181
  index
3504
4182
  );
3505
4183
  }),
3506
- /* @__PURE__ */ jsxs18(
4184
+ /* @__PURE__ */ jsxs20(
3507
4185
  Button,
3508
4186
  {
3509
4187
  type: "button",
@@ -3512,7 +4190,7 @@ function ValueStringMapping({ rules, onChange }) {
3512
4190
  "aria-label": "remove",
3513
4191
  onClick: addRule,
3514
4192
  children: [
3515
- /* @__PURE__ */ jsx24(LuPlus, { className: classNames5("h-4 w-4"), "aria-hidden": "true" }),
4193
+ /* @__PURE__ */ jsx27(LuPlus, { className: classNames7("h-4 w-4"), "aria-hidden": "true" }),
3516
4194
  "Add Formatting Rule"
3517
4195
  ]
3518
4196
  }
@@ -3521,7 +4199,7 @@ function ValueStringMapping({ rules, onChange }) {
3521
4199
  }
3522
4200
 
3523
4201
  // src/charts/options/ValueOptions.tsx
3524
- import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
4202
+ import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
3525
4203
  var ValueFormatters = [
3526
4204
  { label: "Number", value: "NumberFormatter" },
3527
4205
  { label: "Date", value: "DateFormatter" },
@@ -3550,10 +4228,10 @@ var CurrencySymbols = [
3550
4228
  var AddonLabel = ({
3551
4229
  className,
3552
4230
  children
3553
- }) => /* @__PURE__ */ jsx25(
4231
+ }) => /* @__PURE__ */ jsx28(
3554
4232
  "span",
3555
4233
  {
3556
- className: classNames6(
4234
+ className: classNames8(
3557
4235
  "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap bg-gray-50 px-3",
3558
4236
  className
3559
4237
  ),
@@ -3626,9 +4304,9 @@ var ValueOptions = ({
3626
4304
  function numberAddons(style) {
3627
4305
  switch (style) {
3628
4306
  case "None":
3629
- return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3630
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-l-0", children: "Fraction Digits" }),
3631
- /* @__PURE__ */ jsx25(
4307
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4308
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-l-0", children: "Fraction Digits" }),
4309
+ /* @__PURE__ */ jsx28(
3632
4310
  "input",
3633
4311
  {
3634
4312
  disabled: true,
@@ -3639,9 +4317,9 @@ var ValueOptions = ({
3639
4317
  ] });
3640
4318
  case "Percent":
3641
4319
  case "Standard":
3642
- return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3643
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-x-0", children: "Fraction Digits" }),
3644
- /* @__PURE__ */ jsx25(
4320
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4321
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-x-0", children: "Fraction Digits" }),
4322
+ /* @__PURE__ */ jsx28(
3645
4323
  "input",
3646
4324
  {
3647
4325
  type: "number",
@@ -3655,9 +4333,9 @@ var ValueOptions = ({
3655
4333
  )
3656
4334
  ] });
3657
4335
  case "Currency":
3658
- return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3659
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-r-0", children: "Symbol" }),
3660
- /* @__PURE__ */ jsx25("div", { className: "w-28 ", children: /* @__PURE__ */ jsx25(
4336
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4337
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-r-0", children: "Symbol" }),
4338
+ /* @__PURE__ */ jsx28("div", { className: "w-28 ", children: /* @__PURE__ */ jsx28(
3661
4339
  ComboInput,
3662
4340
  {
3663
4341
  onChange: onChangeSymbol,
@@ -3670,8 +4348,8 @@ var ValueOptions = ({
3670
4348
  value: config?.currencySymbol
3671
4349
  }
3672
4350
  ) }),
3673
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border", children: "Precision" }),
3674
- /* @__PURE__ */ jsx25(
4351
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border", children: "Precision" }),
4352
+ /* @__PURE__ */ jsx28(
3675
4353
  "input",
3676
4354
  {
3677
4355
  type: "number",
@@ -3686,9 +4364,9 @@ var ValueOptions = ({
3686
4364
  )
3687
4365
  ] });
3688
4366
  default:
3689
- return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3690
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-x-0", children: "Max significant digits" }),
3691
- /* @__PURE__ */ jsx25(
4367
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4368
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-x-0", children: "Max significant digits" }),
4369
+ /* @__PURE__ */ jsx28(
3692
4370
  "input",
3693
4371
  {
3694
4372
  type: "number",
@@ -3703,62 +4381,62 @@ var ValueOptions = ({
3703
4381
  ] });
3704
4382
  }
3705
4383
  }
3706
- return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3707
- /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsxs19("div", { className: "flex", children: [
3708
- /* @__PURE__ */ jsx25(AddonLabel, { className: "rounded-l-md border border-r-0", children: "Value formatter" }),
3709
- /* @__PURE__ */ jsx25(
4384
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4385
+ /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs21("div", { className: "flex", children: [
4386
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "rounded-l-md border border-r-0", children: "Value formatter" }),
4387
+ /* @__PURE__ */ jsx28(
3710
4388
  "select",
3711
4389
  {
3712
4390
  value: config.valueFormatter,
3713
- className: classNames6(
4391
+ className: classNames8(
3714
4392
  "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 inline-flex items-center border py-1.5 pl-4 pr-7 focus:ring-0",
3715
4393
  config.valueFormatter == "StringFormatter" ? "rounded-r-md" : ""
3716
4394
  ),
3717
4395
  onChange: (e) => onChangeFormatter(e.target.value),
3718
4396
  children: formatters.map((d) => {
3719
- return /* @__PURE__ */ jsx25("option", { value: d.value, children: d.label }, d.value);
4397
+ return /* @__PURE__ */ jsx28("option", { value: d.value, children: d.label }, d.value);
3720
4398
  })
3721
4399
  }
3722
4400
  ),
3723
- config.valueFormatter == "NumberFormatter" && /* @__PURE__ */ jsxs19(Fragment5, { children: [
3724
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-l-0 border-r-0", children: "Style" }),
3725
- /* @__PURE__ */ jsxs19(
4401
+ config.valueFormatter == "NumberFormatter" && /* @__PURE__ */ jsxs21(Fragment8, { children: [
4402
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-l-0 border-r-0", children: "Style" }),
4403
+ /* @__PURE__ */ jsxs21(
3726
4404
  "select",
3727
4405
  {
3728
4406
  value: config.style,
3729
4407
  className: "sm:text-ilabel border-main text-text-foreground hover:border-primary-600 inline-flex items-center border py-1 pl-4 pr-7 focus:ring-0",
3730
4408
  onChange: (e) => onStyleChange(e.target.value),
3731
4409
  children: [
3732
- /* @__PURE__ */ jsx25("option", { value: "None", children: "None" }),
3733
- /* @__PURE__ */ jsx25("option", { value: "Compact", children: "Compact" }),
3734
- /* @__PURE__ */ jsx25("option", { value: "Standard", children: "Standard" }),
3735
- /* @__PURE__ */ jsx25("option", { value: "Scientific", children: "Scientific" }),
3736
- /* @__PURE__ */ jsx25("option", { value: "Percent", children: "Percent" }),
3737
- /* @__PURE__ */ jsx25("option", { value: "Currency", children: "Currency" })
4410
+ /* @__PURE__ */ jsx28("option", { value: "None", children: "None" }),
4411
+ /* @__PURE__ */ jsx28("option", { value: "Compact", children: "Compact" }),
4412
+ /* @__PURE__ */ jsx28("option", { value: "Standard", children: "Standard" }),
4413
+ /* @__PURE__ */ jsx28("option", { value: "Scientific", children: "Scientific" }),
4414
+ /* @__PURE__ */ jsx28("option", { value: "Percent", children: "Percent" }),
4415
+ /* @__PURE__ */ jsx28("option", { value: "Currency", children: "Currency" })
3738
4416
  ]
3739
4417
  }
3740
4418
  ),
3741
4419
  config.style && numberAddons(config.style)
3742
4420
  ] }),
3743
- config.valueFormatter == "DateFormatter" && /* @__PURE__ */ jsxs19(Fragment5, { children: [
3744
- /* @__PURE__ */ jsx25(AddonLabel, { className: "border border-l-0", children: "Date format" }),
3745
- /* @__PURE__ */ jsx25(
4421
+ config.valueFormatter == "DateFormatter" && /* @__PURE__ */ jsxs21(Fragment8, { children: [
4422
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-l-0", children: "Date format" }),
4423
+ /* @__PURE__ */ jsx28(
3746
4424
  "select",
3747
4425
  {
3748
4426
  value: config.dateFormat,
3749
4427
  className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center rounded-r-md border border-l-0 py-1 pl-4 pr-7",
3750
4428
  onChange: (e) => onChangeDateFormat(e.target.value),
3751
4429
  children: dateFormats.map((d) => {
3752
- return /* @__PURE__ */ jsx25("option", { value: d.value, children: d.label }, d.value);
4430
+ return /* @__PURE__ */ jsx28("option", { value: d.value, children: d.label }, d.value);
3753
4431
  })
3754
4432
  }
3755
4433
  )
3756
4434
  ] })
3757
4435
  ] }) }),
3758
- (showPrefix || showSuffix) && /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsxs19("div", { className: "mt-2 flex items-center gap-4", children: [
3759
- showPrefix && /* @__PURE__ */ jsxs19("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
3760
- /* @__PURE__ */ jsx25("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Prefix" }),
3761
- /* @__PURE__ */ jsx25(
4436
+ (showPrefix || showSuffix) && /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs21("div", { className: "mt-2 flex items-center gap-4", children: [
4437
+ showPrefix && /* @__PURE__ */ jsxs21("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
4438
+ /* @__PURE__ */ jsx28("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Prefix" }),
4439
+ /* @__PURE__ */ jsx28(
3762
4440
  "input",
3763
4441
  {
3764
4442
  type: "text",
@@ -3769,9 +4447,9 @@ var ValueOptions = ({
3769
4447
  }
3770
4448
  )
3771
4449
  ] }),
3772
- showSuffix && /* @__PURE__ */ jsxs19("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
3773
- /* @__PURE__ */ jsx25("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Suffix" }),
3774
- /* @__PURE__ */ jsx25(
4450
+ showSuffix && /* @__PURE__ */ jsxs21("div", { className: "border-main hover:border-primary-600 focus-within:border-primary-600 focus-within:ring-3 focus-within:ring-primary-500/30 text-icontent inline-flex items-center rounded-md border", children: [
4451
+ /* @__PURE__ */ jsx28("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Suffix" }),
4452
+ /* @__PURE__ */ jsx28(
3775
4453
  "input",
3776
4454
  {
3777
4455
  type: "text",
@@ -3783,7 +4461,7 @@ var ValueOptions = ({
3783
4461
  )
3784
4462
  ] })
3785
4463
  ] }) }),
3786
- config.valueFormatter == "StringFormatter" && /* @__PURE__ */ jsx25(
4464
+ config.valueFormatter == "StringFormatter" && /* @__PURE__ */ jsx28(
3787
4465
  ValueStringMapping,
3788
4466
  {
3789
4467
  rules: config.mappingRules || [],
@@ -3797,7 +4475,7 @@ var ValueOptions = ({
3797
4475
  import { defaults as defaults3 } from "lodash";
3798
4476
  import { Checkbox as Checkbox3, DisclosurePanel as DisclosurePanel5 } from "@sentio/ui-core";
3799
4477
  import { produce as produce10 } from "immer";
3800
- import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
4478
+ import { jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
3801
4479
  var defaultConfig4 = {
3802
4480
  valueFormatter: "NumberFormatter",
3803
4481
  showValueLabel: false,
@@ -3824,14 +4502,14 @@ var ValueControls = ({
3824
4502
  function toggleTooltipTotal(checked) {
3825
4503
  config && onChange(produce10(config, (draft) => void (draft.tooltipTotal = checked)));
3826
4504
  }
3827
- return /* @__PURE__ */ jsxs20(
4505
+ return /* @__PURE__ */ jsxs22(
3828
4506
  DisclosurePanel5,
3829
4507
  {
3830
4508
  title: "Value Options",
3831
4509
  defaultOpen,
3832
4510
  containerClassName: "w-full bg-default-bg",
3833
4511
  children: [
3834
- /* @__PURE__ */ jsx26(
4512
+ /* @__PURE__ */ jsx29(
3835
4513
  ValueOptions,
3836
4514
  {
3837
4515
  onChange,
@@ -3841,8 +4519,8 @@ var ValueControls = ({
3841
4519
  showSuffix
3842
4520
  }
3843
4521
  ),
3844
- /* @__PURE__ */ jsxs20("div", { className: "mt-2 flex items-center gap-2", children: [
3845
- /* @__PURE__ */ jsx26(
4522
+ /* @__PURE__ */ jsxs22("div", { className: "mt-2 flex items-center gap-2", children: [
4523
+ /* @__PURE__ */ jsx29(
3846
4524
  Checkbox3,
3847
4525
  {
3848
4526
  checked: config?.showValueLabel,
@@ -3850,7 +4528,7 @@ var ValueControls = ({
3850
4528
  label: "Show value label"
3851
4529
  }
3852
4530
  ),
3853
- /* @__PURE__ */ jsx26(
4531
+ /* @__PURE__ */ jsx29(
3854
4532
  Checkbox3,
3855
4533
  {
3856
4534
  checked: config?.tooltipTotal,
@@ -3872,6 +4550,7 @@ export {
3872
4550
  BarGuageIcon_default as BarGuageIcon,
3873
4551
  BarIcon_default as BarIcon,
3874
4552
  ChartLegend,
4553
+ ChartTooltip,
3875
4554
  ChartTypeButtonGroup,
3876
4555
  EventsFunctionCategories,
3877
4556
  EventsFunctionMap,
@@ -3884,12 +4563,14 @@ export {
3884
4563
  LabelsInput,
3885
4564
  LineControls,
3886
4565
  LineIcon_default as LineIcon,
4566
+ PieChart2 as PieChart,
3887
4567
  PieChartControls,
3888
4568
  PieIcon_default as PieIcon,
3889
4569
  QueryValueIcon_default as QueryValueIcon,
3890
4570
  ReactEChartsBase,
3891
4571
  RefreshButton,
3892
4572
  RefreshContext,
4573
+ ScatterChartTooltip,
3893
4574
  ScatterIcon_default as ScatterIcon,
3894
4575
  SystemLabels,
3895
4576
  TableIcon_default as TableIcon,