@sentio/ui-dashboard 0.2.3 → 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
@@ -2566,1235 +2566,1981 @@ var RefreshButton = (props) => {
2566
2566
  ) });
2567
2567
  };
2568
2568
 
2569
- // src/charts/options/LineControls.tsx
2570
- import { produce as produce4 } from "immer";
2571
- import {
2572
- DisclosurePanel,
2573
- NewButtonGroup as ButtonGroup,
2574
- Checkbox
2575
- } from "@sentio/ui-core";
2569
+ // src/charts/ChartTypeButtonGroup.tsx
2570
+ import { useState as useState7 } from "react";
2571
+ import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
2572
+ import { NewButtonGroup as ButtonGroup } from "@sentio/ui-core";
2573
+
2574
+ // src/charts/icons/BarGuageIcon.tsx
2576
2575
  import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
2577
- var lineStyles = [
2578
- { label: "Solid", value: "Solid" },
2579
- { label: "Dotted", value: "Dotted" }
2580
- ];
2581
- var LineControls = ({ config, defaultOpen, onChange }) => {
2582
- const setStyle = (style) => {
2583
- onChange(
2584
- produce4(config || {}, (draft) => {
2585
- draft.style = style;
2586
- })
2587
- );
2588
- };
2589
- const setSmooth = (smooth) => {
2590
- onChange(
2591
- produce4(config || {}, (draft) => {
2592
- draft.smooth = smooth;
2593
- })
2594
- );
2595
- };
2596
- return /* @__PURE__ */ jsx11(
2597
- DisclosurePanel,
2598
- {
2599
- title: "Line style",
2600
- containerClassName: "w-full bg-default-bg",
2601
- children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-4", children: [
2602
- /* @__PURE__ */ jsx11(
2603
- ButtonGroup,
2576
+ var SvgIcon = ({ className }) => /* @__PURE__ */ jsxs7(
2577
+ "svg",
2578
+ {
2579
+ width: "14",
2580
+ height: "14",
2581
+ viewBox: "0 0 14 14",
2582
+ fill: "currentColor",
2583
+ className,
2584
+ xmlns: "http://www.w3.org/2000/svg",
2585
+ children: [
2586
+ /* @__PURE__ */ jsx11(
2587
+ "path",
2588
+ {
2589
+ d: "M2.12791 1.5625V12.4375C2.12791 12.5938 2.07311 12.7267 1.96349 12.836C1.85387 12.9453 1.7207 13 1.56396 13C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375V1.5625C1 1.40617 1.05481 1.27333 1.16442 1.164C1.27404 1.05467 1.40722 1 1.56396 1C1.7207 1 1.85387 1.05467 1.96349 1.164C2.07311 1.27333 2.12791 1.40617 2.12791 1.5625ZM1.56396 11.875H12.436C12.5928 11.875 12.726 11.9297 12.8356 12.039C12.9452 12.1483 13 12.2812 13 12.4375C13 12.5938 12.9452 12.7267 12.8356 12.836C12.726 12.9453 12.5928 13 12.436 13H1.56396C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375C1 12.2812 1.05481 12.1483 1.16442 12.039C1.27404 11.9297 1.40722 11.875 1.56396 11.875Z",
2590
+ fill: "currentColor"
2591
+ }
2592
+ ),
2593
+ /* @__PURE__ */ jsx11(
2594
+ "path",
2595
+ {
2596
+ d: "M3.64159 4.02495H9.43859C9.59493 4.02495 9.72776 3.97014 9.83709 3.86052C9.94643 3.75091 10.0011 3.61773 10.0011 3.46099C10.0011 3.30425 9.94643 3.17108 9.83709 3.06146C9.72776 2.95184 9.59493 2.89703 9.43859 2.89703L3.64159 2.89703C3.48526 2.89703 3.35243 2.95184 3.24309 3.06146C3.13376 3.17108 3.07909 3.30425 3.07909 3.46099C3.07909 3.61773 3.13376 3.75091 3.24309 3.86052C3.35243 3.97014 3.48526 4.02495 3.64159 4.02495Z",
2597
+ fill: "currentColor"
2598
+ }
2599
+ ),
2600
+ /* @__PURE__ */ jsx11(
2601
+ "path",
2602
+ {
2603
+ d: "M3.64209 10.0244H11.4701C11.6264 10.0244 11.7593 9.96964 11.8686 9.86002C11.9779 9.7504 12.0326 9.61723 12.0326 9.46049C12.0326 9.30375 11.9779 9.17057 11.8686 9.06096C11.7593 8.95134 11.6264 8.89653 11.4701 8.89653H3.64209C3.48576 8.89653 3.35293 8.95134 3.24359 9.06096C3.13426 9.17057 3.07959 9.30375 3.07959 9.46049C3.07959 9.61723 3.13426 9.7504 3.24359 9.86002C3.35293 9.96964 3.48576 10.0244 3.64209 10.0244Z",
2604
+ fill: "currentColor"
2605
+ }
2606
+ ),
2607
+ /* @__PURE__ */ jsx11(
2608
+ "path",
2609
+ {
2610
+ d: "M3.64209 7.01668L7.47009 7.01668C7.62643 7.01634 7.75926 6.95886 7.86859 6.84423C7.97793 6.7296 8.03259 6.5991 8.03259 6.45272C8.03259 6.29598 7.97793 6.1628 7.86859 6.05319C7.75926 5.94357 7.62643 5.88876 7.47009 5.88876H3.64209C3.48576 5.88876 3.35293 5.94357 3.24359 6.05319C3.13426 6.1628 3.07959 6.29598 3.07959 6.45272C3.07959 6.60946 3.13426 6.74263 3.24359 6.85225C3.35293 6.96187 3.48576 7.01668 3.64209 7.01668Z",
2611
+ fill: "currentColor"
2612
+ }
2613
+ )
2614
+ ]
2615
+ }
2616
+ );
2617
+ var BarGuageIcon_default = SvgIcon;
2618
+
2619
+ // src/charts/icons/QueryValueIcon.tsx
2620
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
2621
+ var SvgIcon2 = ({ className }) => /* @__PURE__ */ jsxs8(
2622
+ "svg",
2623
+ {
2624
+ width: "14",
2625
+ height: "14",
2626
+ viewBox: "0 0 14 14",
2627
+ fill: "none",
2628
+ className,
2629
+ xmlns: "http://www.w3.org/2000/svg",
2630
+ children: [
2631
+ /* @__PURE__ */ jsxs8("g", { clipPath: "url(#clip0_3670_4424)", children: [
2632
+ /* @__PURE__ */ jsx12(
2633
+ "path",
2604
2634
  {
2605
- buttons: lineStyles,
2606
- value: config?.style || "Solid",
2607
- onChange: setStyle,
2608
- small: true
2635
+ d: "M11.5 1.5H2.5C1.67157 1.5 1 2.11561 1 2.875V11.125C1 11.8844 1.67157 12.5 2.5 12.5H11.5C12.3284 12.5 13 11.8844 13 11.125V2.875C13 2.11561 12.3284 1.5 11.5 1.5Z",
2636
+ stroke: "currentColor",
2637
+ strokeWidth: "1.16667",
2638
+ strokeLinecap: "round",
2639
+ strokeLinejoin: "round"
2609
2640
  }
2610
2641
  ),
2611
- /* @__PURE__ */ jsx11(
2612
- Checkbox,
2642
+ /* @__PURE__ */ jsx12(
2643
+ "path",
2613
2644
  {
2614
- label: "Smooth Curves",
2615
- checked: config?.smooth,
2616
- onChange: setSmooth
2645
+ d: "M7.98188 5.77273H6.39097L5.75461 5.13636L6.39097 4.5H7.98188L8.61824 5.13636L7.98188 5.77273Z",
2646
+ fill: "currentColor"
2617
2647
  }
2618
- )
2619
- ] })
2620
- }
2621
- );
2622
- };
2623
-
2624
- // src/charts/options/LabelControls.tsx
2625
- import { useEffect as useEffect6, useMemo as useMemo5 } from "react";
2626
- import { produce as produce5 } from "immer";
2627
- import { Button as NewButton2, DisclosurePanel as DisclosurePanel2, HelpIcon as HelpIcon2 } from "@sentio/ui-core";
2628
- import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
2629
- var initialConfig = {
2630
- columns: [],
2631
- alias: ""
2632
- };
2633
- var LabelControls = ({ config, setConfig, defaultOpen }) => {
2634
- useEffect6(() => {
2635
- if (config?.columns && config.columns.length > 0 && !config.alias) {
2636
- const aliasParts = [];
2637
- config.columns.forEach((colConfig) => {
2638
- if (!colConfig.name) return;
2639
- if (colConfig.showLabel === false && colConfig.showValue === false) {
2640
- } else if (colConfig.showValue === false) {
2641
- aliasParts.push(colConfig.name);
2642
- } else {
2643
- aliasParts.push(`{{${colConfig.name}}}`);
2644
- }
2645
- });
2646
- if (aliasParts.length > 0) {
2647
- const migratedAlias = aliasParts.join(", ");
2648
- setConfig(
2649
- produce5(config, (draft) => {
2650
- draft.alias = migratedAlias;
2651
- draft.columns = [];
2652
- })
2653
- );
2654
- }
2655
- }
2656
- }, [config, setConfig]);
2657
- const onAliasChanged = (alias) => {
2658
- setConfig(
2659
- produce5(config ?? initialConfig, (draft) => {
2660
- draft.alias = alias;
2661
- })
2662
- );
2663
- };
2664
- const _defaultOpen = useMemo5(() => {
2665
- if (defaultOpen) {
2666
- return true;
2667
- }
2668
- return config?.alias !== "" || config?.columns && config.columns.length > 0;
2669
- }, [config, defaultOpen]);
2670
- return /* @__PURE__ */ jsx12(
2671
- DisclosurePanel2,
2672
- {
2673
- title: "Label Controls",
2674
- defaultOpen: _defaultOpen,
2675
- containerClassName: "w-full bg-default-bg",
2676
- children: /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
2677
- /* @__PURE__ */ jsxs8("div", { className: "inline-flex h-8", children: [
2678
- /* @__PURE__ */ jsxs8("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: [
2679
- "Label Alias",
2680
- /* @__PURE__ */ jsx12(
2681
- HelpIcon2,
2682
- {
2683
- text: /* @__PURE__ */ jsxs8("div", { className: "text-icontent text-text-foreground", children: [
2684
- /* @__PURE__ */ jsx12("div", { children: "Series name override or template." }),
2685
- /* @__PURE__ */ jsxs8("div", { children: [
2686
- "Ex.",
2687
- " ",
2688
- /* @__PURE__ */ jsx12("span", { className: "text-primary mx-1 font-semibold italic", children: "{{contract}}" }),
2689
- " ",
2690
- "will be replaced with the value of the contract label."
2691
- ] })
2692
- ] })
2693
- }
2694
- )
2695
- ] }),
2696
- /* @__PURE__ */ jsx12(
2697
- "input",
2698
- {
2699
- type: "text",
2700
- value: config?.alias || "",
2701
- onChange: (e) => onAliasChanged(e.target.value),
2702
- placeholder: "Enter alias...",
2703
- className: "focus:border-primary-500 sm:text-icontent border-main inline-flex w-64 items-center rounded-r-md border px-2"
2704
- }
2705
- )
2706
- ] }),
2648
+ ),
2707
2649
  /* @__PURE__ */ jsx12(
2708
- NewButton2,
2650
+ "path",
2709
2651
  {
2710
- type: "button",
2711
- role: "link",
2712
- onClick: () => {
2713
- setConfig(initialConfig);
2714
- },
2715
- children: "Reset"
2652
+ d: "M7.98188 11.5H6.39097L5.75461 10.8637L6.39097 10.2273H7.98188L8.61824 10.8637L7.98188 11.5Z",
2653
+ fill: "currentColor"
2654
+ }
2655
+ ),
2656
+ /* @__PURE__ */ jsx12(
2657
+ "path",
2658
+ {
2659
+ d: "M8.30005 9.90907V6.09089L8.93641 5.45453L9.57278 6.09089V9.90907L8.93641 10.5454L8.30005 9.90907Z",
2660
+ fill: "currentColor"
2661
+ }
2662
+ ),
2663
+ /* @__PURE__ */ jsx12(
2664
+ "path",
2665
+ {
2666
+ d: "M4.80005 9.90907V6.09089L5.43641 5.45453L6.07278 6.09089V9.90907L5.43641 10.5454L4.80005 9.90907Z",
2667
+ fill: "currentColor"
2668
+ }
2669
+ ),
2670
+ /* @__PURE__ */ jsx12(
2671
+ "path",
2672
+ {
2673
+ d: "M1 3.5L13 3.5",
2674
+ stroke: "currentColor",
2675
+ strokeWidth: "1.16667",
2676
+ strokeLinecap: "round",
2677
+ strokeLinejoin: "round"
2716
2678
  }
2717
2679
  )
2718
- ] })
2719
- }
2720
- );
2721
- };
2680
+ ] }),
2681
+ /* @__PURE__ */ jsx12("defs", { children: /* @__PURE__ */ jsx12("clipPath", { id: "clip0_3670_4424", children: /* @__PURE__ */ jsx12("rect", { width: "14", height: "14", fill: "white" }) }) })
2682
+ ]
2683
+ }
2684
+ );
2685
+ var QueryValueIcon_default = SvgIcon2;
2722
2686
 
2723
- // src/charts/options/PieChartControls.tsx
2724
- import { produce as produce6 } from "immer";
2725
- import { defaults } from "lodash";
2726
- import {
2727
- Checkbox as Checkbox2,
2728
- DisclosurePanel as DisclosurePanel3,
2729
- NewButtonGroup as ButtonGroup2
2730
- } from "@sentio/ui-core";
2687
+ // src/charts/icons/TableIcon.tsx
2731
2688
  import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
2732
- var defaultConfig = {
2733
- pieType: "Pie",
2734
- calculation: "LAST",
2735
- showPercent: true,
2736
- showValue: true,
2737
- absValue: false
2738
- };
2739
- var CalculationItems = [
2740
- { label: "Last", value: "LAST" },
2741
- { label: "First", value: "FIRST" },
2742
- { label: "Total", value: "TOTAL" },
2743
- { label: "Mean", value: "MEAN" },
2744
- { label: "Max", value: "MAX" },
2745
- { label: "Min", value: "MIN" }
2746
- ];
2747
- var PieTypeItems = [
2748
- { label: "Pie", value: "Pie" },
2749
- { label: "Donut", value: "Donut" }
2750
- ];
2751
- function PieChartControls({ config, defaultOpen, onChange }) {
2752
- config = defaults(config, defaultConfig);
2753
- function onCalculationChange(cal) {
2754
- config && onChange(produce6(config, (draft) => void (draft.calculation = cal)));
2755
- }
2756
- function onPieTypeChange(pieType) {
2757
- config && onChange(produce6(config, (draft) => void (draft.pieType = pieType)));
2758
- }
2759
- function toggle(field, value) {
2760
- config && onChange(
2761
- produce6(config, (draft) => {
2762
- draft[field] = value;
2763
- })
2764
- );
2765
- }
2766
- return /* @__PURE__ */ jsx13(
2767
- DisclosurePanel3,
2768
- {
2769
- title: "Pie Chart Options",
2770
- defaultOpen,
2771
- containerClassName: "w-full bg-default-bg",
2772
- children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-4", children: [
2773
- /* @__PURE__ */ jsx13("div", { className: "shadow-xs flex rounded-md", children: /* @__PURE__ */ jsx13(
2774
- ButtonGroup2,
2775
- {
2776
- small: true,
2777
- buttons: PieTypeItems,
2778
- value: config.pieType,
2779
- onChange: onPieTypeChange
2780
- }
2781
- ) }),
2782
- /* @__PURE__ */ jsxs9("div", { className: "shadow-xs flex rounded-md", children: [
2783
- /* @__PURE__ */ jsx13("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" }),
2784
- /* @__PURE__ */ jsx13(
2785
- "select",
2786
- {
2787
- value: config.calculation,
2788
- 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",
2789
- onChange: (e) => onCalculationChange(e.target.value),
2790
- children: CalculationItems.map((d) => {
2791
- return /* @__PURE__ */ jsx13("option", { value: d.value, children: d.label }, d.value);
2792
- })
2793
- }
2794
- )
2795
- ] }),
2689
+ var SvgIcon3 = ({ className }) => /* @__PURE__ */ jsxs9(
2690
+ "svg",
2691
+ {
2692
+ width: "14",
2693
+ height: "14",
2694
+ viewBox: "0 0 14 14",
2695
+ fill: "none",
2696
+ xmlns: "http://www.w3.org/2000/svg",
2697
+ className,
2698
+ children: [
2699
+ /* @__PURE__ */ jsxs9("g", { clipPath: "url(#clip0_3670_4416)", children: [
2796
2700
  /* @__PURE__ */ jsx13(
2797
- Checkbox2,
2701
+ "path",
2798
2702
  {
2799
- checked: config?.showValue,
2800
- onChange: (v) => toggle("showValue", v),
2801
- label: "Show value",
2802
- labelClassName: "whitespace-nowrap"
2703
+ d: "M11.5 2H2.5C1.67157 2 1 2.55964 1 3.25V10.75C1 11.4404 1.67157 12 2.5 12H11.5C12.3284 12 13 11.4404 13 10.75V3.25C13 2.55964 12.3284 2 11.5 2Z",
2704
+ stroke: "currentColor",
2705
+ strokeWidth: "1.16667",
2706
+ strokeLinecap: "round",
2707
+ strokeLinejoin: "round"
2803
2708
  }
2804
2709
  ),
2805
2710
  /* @__PURE__ */ jsx13(
2806
- Checkbox2,
2711
+ "path",
2807
2712
  {
2808
- checked: config?.showPercent,
2809
- onChange: (v) => toggle("showPercent", v),
2810
- label: "Show percent",
2811
- labelClassName: "whitespace-nowrap"
2713
+ d: "M1 5L13 5",
2714
+ stroke: "currentColor",
2715
+ strokeWidth: "1.16667",
2716
+ strokeLinecap: "round",
2717
+ strokeLinejoin: "round"
2812
2718
  }
2813
2719
  ),
2814
2720
  /* @__PURE__ */ jsx13(
2815
- Checkbox2,
2721
+ "path",
2816
2722
  {
2817
- checked: config?.absValue,
2818
- onChange: (v) => toggle("absValue", v),
2819
- label: "Use absolute values",
2820
- labelClassName: "whitespace-nowrap"
2723
+ d: "M6 2L6 12",
2724
+ stroke: "currentColor",
2725
+ strokeWidth: "1.16667",
2726
+ strokeLinecap: "round",
2727
+ strokeLinejoin: "round"
2821
2728
  }
2822
2729
  )
2823
- ] })
2824
- }
2825
- );
2826
- }
2730
+ ] }),
2731
+ /* @__PURE__ */ jsx13("defs", { children: /* @__PURE__ */ jsx13("clipPath", { id: "clip0_3670_4416", children: /* @__PURE__ */ jsx13("rect", { width: "14", height: "14", fill: "white" }) }) })
2732
+ ]
2733
+ }
2734
+ );
2735
+ var TableIcon_default = SvgIcon3;
2827
2736
 
2828
- // src/charts/options/BarGaugeControls.tsx
2829
- import { produce as produce7 } from "immer";
2830
- import { defaults as defaults2 } from "lodash";
2831
- import { DisclosurePanel as DisclosurePanel4 } from "@sentio/ui-core";
2737
+ // src/charts/icons/AreaIcon.tsx
2832
2738
  import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
2833
- var defaultConfig2 = {
2834
- direction: "HORIZONTAL",
2835
- calculation: "LAST",
2836
- sort: {
2837
- sortBy: "ByName",
2838
- orderDesc: true
2839
- }
2840
- };
2841
- var directionItems = [
2842
- { label: "Horizontal", value: "HORIZONTAL" },
2843
- { label: "Vertical", value: "VERTICAL" }
2844
- ];
2845
- var CalculationItems2 = [
2846
- { label: "Last", value: "LAST" },
2847
- { label: "First", value: "FIRST" },
2848
- { label: "Total", value: "TOTAL" },
2849
- { label: "Mean", value: "MEAN" },
2850
- { label: "Max", value: "MAX" },
2851
- { label: "Min", value: "MIN" }
2852
- ];
2853
- var sortByItems = [
2854
- { label: "Name", value: "ByName" },
2855
- { label: "Value", value: "ByValue" }
2856
- ];
2857
- var orderItems = [
2858
- { label: "Ascendant", value: "false" },
2859
- { label: "Descendant", value: "true" }
2860
- ];
2861
- function BarGaugeControls({ config, defaultOpen, onChange }) {
2862
- config = defaults2(config, defaultConfig2);
2863
- function onCalculationChange(cal) {
2864
- config && onChange(produce7(config, (draft) => void (draft.calculation = cal)));
2865
- }
2866
- function onDirectionChange(dir) {
2867
- config && onChange(produce7(config, (draft) => void (draft.direction = dir)));
2868
- }
2869
- function onOrderChange(orderDesc) {
2870
- config && onChange(
2871
- produce7(config, (draft) => {
2872
- draft.sort = draft.sort || {};
2873
- draft.sort.orderDesc = orderDesc;
2874
- })
2875
- );
2876
- }
2877
- function onSortByChange(sortBy2) {
2878
- config && onChange(
2879
- produce7(config, (draft) => {
2880
- draft.sort = draft.sort || {};
2881
- draft.sort.sortBy = sortBy2;
2882
- })
2883
- );
2739
+ var SvgIcon4 = ({ className }) => /* @__PURE__ */ jsxs10(
2740
+ "svg",
2741
+ {
2742
+ width: "14",
2743
+ height: "14",
2744
+ viewBox: "0 0 14 14",
2745
+ fill: "none",
2746
+ xmlns: "http://www.w3.org/2000/svg",
2747
+ className,
2748
+ children: [
2749
+ /* @__PURE__ */ jsx14("g", { clipPath: "url(#clip0_1774_9545)", children: /* @__PURE__ */ jsx14(
2750
+ "path",
2751
+ {
2752
+ d: "M12.6193 13.1249H1.35364C1.21685 13.1249 1.10062 13.0771 1.00495 12.9814C0.909284 12.8857 0.86145 12.7695 0.86145 12.6327V1.35352C0.86145 1.21672 0.909284 1.10049 1.00495 1.00483C1.10062 0.909161 1.21685 0.861328 1.35364 0.861328C1.49043 0.861328 1.60666 0.909161 1.70233 1.00483C1.79799 1.10049 1.84583 1.21672 1.84583 1.35352V12.1405H12.6193C12.7561 12.1405 12.8723 12.1883 12.968 12.284C13.0636 12.3797 13.1115 12.4959 13.1115 12.6327C13.1115 12.7695 13.0636 12.8857 12.968 12.9814C12.8723 13.0771 12.7561 13.1249 12.6193 13.1249ZM2.62501 10.9374L4.22451 8.08008C4.26097 8.0162 4.31566 7.97289 4.38858 7.95014C4.46149 7.92739 4.53441 7.92972 4.60733 7.95714L6.12501 8.66808L7.73851 6.33008C7.83885 6.19329 7.96193 6.16135 8.10776 6.23427L9.61189 6.99989L11.7994 3.56814C11.8633 3.46781 11.9521 3.43368 12.0658 3.46577C12.1796 3.49785 12.2366 3.5731 12.2369 3.69152V10.8009C12.2369 10.9467 12.1845 11.072 12.0798 11.1767C11.9751 11.2814 11.8498 11.3338 11.704 11.3338H2.87176C2.77143 11.3338 2.69399 11.2905 2.63945 11.2038C2.58491 11.1172 2.58039 11.0284 2.62589 10.9374H2.62501Z",
2753
+ fill: "currentColor"
2754
+ }
2755
+ ) }),
2756
+ /* @__PURE__ */ jsx14("defs", { children: /* @__PURE__ */ jsx14("clipPath", { id: "clip0_1774_9545", children: /* @__PURE__ */ jsx14("rect", { width: "14", height: "14", fill: "white" }) }) })
2757
+ ]
2884
2758
  }
2885
- return /* @__PURE__ */ jsx14(
2886
- DisclosurePanel4,
2887
- {
2888
- title: "Bar Gauge Options",
2889
- defaultOpen,
2890
- containerClassName: "w-full bg-default-bg",
2891
- children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-4", children: [
2892
- /* @__PURE__ */ jsxs10("div", { className: "shadow-xs flex rounded-md", children: [
2893
- /* @__PURE__ */ jsx14("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" }),
2894
- /* @__PURE__ */ jsx14(
2895
- "select",
2896
- {
2897
- value: config.direction,
2898
- 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",
2899
- onChange: (e) => onDirectionChange(e.target.value),
2900
- children: directionItems.map((d) => {
2901
- return /* @__PURE__ */ jsx14("option", { value: d.value, children: d.label }, d.value);
2902
- })
2903
- }
2904
- )
2905
- ] }),
2906
- /* @__PURE__ */ jsxs10("div", { className: "shadow-xs flex rounded-md", children: [
2907
- /* @__PURE__ */ jsx14("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" }),
2908
- /* @__PURE__ */ jsx14(
2909
- "select",
2910
- {
2911
- value: config.calculation,
2912
- 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",
2913
- onChange: (e) => onCalculationChange(e.target.value),
2914
- children: CalculationItems2.map((d) => {
2915
- return /* @__PURE__ */ jsx14("option", { value: d.value, children: d.label }, d.value);
2916
- })
2917
- }
2918
- )
2919
- ] }),
2920
- /* @__PURE__ */ jsxs10("div", { className: "shadow-xs flex rounded-md", children: [
2921
- /* @__PURE__ */ jsx14("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" }),
2922
- /* @__PURE__ */ jsx14(
2923
- "select",
2924
- {
2925
- value: config?.sort?.sortBy,
2926
- 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",
2927
- onChange: (e) => onSortByChange(e.target.value),
2928
- children: sortByItems.map((d) => {
2929
- return /* @__PURE__ */ jsx14("option", { value: d.value, children: d.label }, d.value);
2930
- })
2931
- }
2932
- ),
2933
- /* @__PURE__ */ jsx14(
2934
- "select",
2935
- {
2936
- value: config?.sort?.orderDesc + "",
2937
- 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",
2938
- onChange: (e) => onOrderChange(e.target.value === "true"),
2939
- children: orderItems.map((d) => {
2940
- return /* @__PURE__ */ jsx14("option", { value: d.value + "", children: d.label }, d.label);
2941
- })
2942
- }
2943
- )
2944
- ] })
2945
- ] })
2946
- }
2947
- );
2948
- }
2949
-
2950
- // src/charts/options/ValueOptions.tsx
2951
- import { produce as produce9 } from "immer";
2952
- import { ComboInput, classNames as classNames6 } from "@sentio/ui-core";
2759
+ );
2760
+ var AreaIcon_default = SvgIcon4;
2953
2761
 
2954
- // src/charts/options/ValueStringMapping.tsx
2955
- import { LuPlus, LuTrash2 } from "react-icons/lu";
2956
- import { Button, classNames as classNames5 } from "@sentio/ui-core";
2957
- import { produce as produce8 } from "immer";
2958
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
2959
- var operators = {
2960
- ">": "greater than",
2961
- ">=": "greater or equal",
2962
- "==": "equal",
2963
- "!=": "not equal",
2964
- "<": "less than",
2965
- "<=": "less or equal"
2966
- };
2967
- var renderTreeLine = (index, isLast) => {
2968
- return /* @__PURE__ */ jsx15("div", { className: "mr-2 flex h-12 w-3 flex-col items-center justify-center", children: /* @__PURE__ */ jsxs11("div", { className: "flex h-full w-full items-center", children: [
2969
- /* @__PURE__ */ jsx15(
2970
- "div",
2762
+ // src/charts/icons/BarIcon.tsx
2763
+ import { jsx as jsx15 } from "react/jsx-runtime";
2764
+ var SvgIcon5 = ({ className }) => /* @__PURE__ */ jsx15(
2765
+ "svg",
2766
+ {
2767
+ width: "14",
2768
+ height: "14",
2769
+ viewBox: "0 0 14 14",
2770
+ fill: "none",
2771
+ xmlns: "http://www.w3.org/2000/svg",
2772
+ className,
2773
+ children: /* @__PURE__ */ jsx15(
2774
+ "path",
2971
2775
  {
2972
- className: classNames5(
2973
- "w-px bg-gray-300",
2974
- isLast ? "h-1/2 self-start" : index === 0 ? "h-full self-end" : "h-full"
2975
- )
2776
+ d: "M2.12791 1.5625V12.4375C2.12791 12.5938 2.07311 12.7267 1.96349 12.836C1.85387 12.9453 1.7207 13 1.56396 13C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375V1.5625C1 1.40617 1.05481 1.27333 1.16442 1.164C1.27404 1.05467 1.40722 1 1.56396 1C1.7207 1 1.85387 1.05467 1.96349 1.164C2.07311 1.27333 2.12791 1.40617 2.12791 1.5625ZM1.56396 11.875H12.436C12.5928 11.875 12.726 11.9297 12.8356 12.039C12.9452 12.1483 13 12.2812 13 12.4375C13 12.5938 12.9452 12.7267 12.8356 12.836C12.726 12.9453 12.5928 13 12.436 13H1.56396C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375C1 12.2812 1.05481 12.1483 1.16442 12.039C1.27404 11.9297 1.40722 11.875 1.56396 11.875ZM5.12014 4.578V10.375C5.12014 10.5313 5.06534 10.6642 4.95572 10.7735C4.8461 10.8828 4.71293 10.9375 4.55619 10.9375C4.39945 10.9375 4.26627 10.8828 4.15665 10.7735C4.04704 10.6642 3.99223 10.5313 3.99223 10.375V4.578C3.99223 4.42167 4.04704 4.28883 4.15665 4.1795C4.26627 4.07017 4.39945 4.0155 4.55619 4.0155C4.71293 4.0155 4.8461 4.07017 4.95572 4.1795C5.06534 4.28883 5.12014 4.42167 5.12014 4.578ZM11.1196 2.5465V10.3745C11.1196 10.5308 11.0648 10.6637 10.9552 10.773C10.8456 10.8823 10.7124 10.937 10.5557 10.937C10.3989 10.937 10.2658 10.8823 10.1562 10.773C10.0465 10.6637 9.99173 10.5308 9.99173 10.3745V2.5465C9.99173 2.39017 10.0465 2.25733 10.1562 2.148C10.2658 2.03867 10.3989 1.984 10.5557 1.984C10.7124 1.984 10.8456 2.03867 10.9552 2.148C11.0648 2.25733 11.1196 2.39017 11.1196 2.5465ZM8.11187 6.5465V10.3745C8.11187 10.5308 8.05706 10.6637 7.94745 10.773C7.83783 10.8823 7.70465 10.937 7.54792 10.937C7.39118 10.937 7.258 10.8823 7.14838 10.773C7.03877 10.6637 6.98396 10.5308 6.98396 10.3745V6.5465C6.98396 6.39017 7.03877 6.25733 7.14838 6.148C7.258 6.03867 7.39118 5.984 7.54792 5.984C7.69429 5.984 7.8248 6.03867 7.93943 6.148C8.05406 6.25733 8.11154 6.39017 8.11187 6.5465Z",
2777
+ fill: "currentColor"
2976
2778
  }
2977
- ),
2978
- /* @__PURE__ */ jsx15("div", { className: "h-px w-3 bg-gray-300" })
2979
- ] }) });
2980
- };
2981
- function ValueStringMapping({ rules, onChange }) {
2982
- const addRule = () => {
2983
- onChange(
2984
- produce8(rules, (draft) => {
2985
- draft = draft || [];
2986
- draft.push({
2987
- comparison: "==",
2988
- value: 0,
2989
- text: ""
2990
- });
2991
- })
2992
- );
2993
- };
2994
- function removeRule(index) {
2995
- onChange(
2996
- produce8(rules, (draft) => {
2997
- draft.splice(index, 1);
2998
- })
2999
- );
2779
+ )
3000
2780
  }
3001
- function changeRule(index, field, value) {
3002
- onChange(
3003
- produce8(rules, (draft) => {
3004
- ;
3005
- draft[index][field] = value;
3006
- })
3007
- );
2781
+ );
2782
+ var BarIcon_default = SvgIcon5;
2783
+
2784
+ // src/charts/icons/LineIcon.tsx
2785
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
2786
+ var SvgIcon6 = ({ className }) => /* @__PURE__ */ jsxs11(
2787
+ "svg",
2788
+ {
2789
+ width: "14",
2790
+ height: "14",
2791
+ viewBox: "0 0 14 14",
2792
+ fill: "none",
2793
+ xmlns: "http://www.w3.org/2000/svg",
2794
+ className,
2795
+ children: [
2796
+ /* @__PURE__ */ jsx16("g", { clipPath: "url(#clip0_1774_9563)", children: /* @__PURE__ */ jsx16(
2797
+ "path",
2798
+ {
2799
+ d: "M12.6191 13.1249H1.35352C1.21672 13.1249 1.10049 13.0771 1.00483 12.9814C0.909161 12.8857 0.861328 12.7695 0.861328 12.6327V1.35352C0.861328 1.21672 0.909161 1.10049 1.00483 1.00483C1.10049 0.909161 1.21672 0.861328 1.35352 0.861328C1.49031 0.861328 1.60654 0.909161 1.7022 1.00483C1.79787 1.10049 1.8457 1.21672 1.8457 1.35352V12.1405H12.6191C12.7559 12.1405 12.8722 12.1883 12.9678 12.284C13.0635 12.3797 13.1113 12.4959 13.1113 12.6327C13.1113 12.7695 13.0635 12.8857 12.9678 12.9814C12.8722 13.0771 12.7559 13.1249 12.6191 13.1249ZM5.26345 10.1582C5.0902 10.1582 4.95341 10.0853 4.85308 9.93945L2.7067 6.52127C2.63379 6.40285 2.61104 6.27758 2.63845 6.14545C2.66587 6.01333 2.73645 5.91081 2.8502 5.83789C2.96395 5.76497 3.08704 5.74222 3.21945 5.76964C3.35187 5.79706 3.45439 5.86545 3.52702 5.97483L5.05827 8.46333L5.68739 6.04352C5.72385 5.89768 5.81047 5.79283 5.94727 5.72895L8.43576 4.52583C8.55418 4.47099 8.67274 4.45962 8.79145 4.4917C8.91016 4.52379 9.00583 4.59437 9.07845 4.70345L10.3227 6.72689L12.155 1.21702C12.2005 1.08927 12.2826 0.993599 12.4013 0.930016C12.52 0.866432 12.6431 0.857245 12.7705 0.902453C12.898 0.947661 12.9936 1.02977 13.0575 1.14877C13.1214 1.26777 13.1306 1.39085 13.0851 1.51802L10.9247 8.03939C10.8608 8.24006 10.724 8.35177 10.5143 8.37452C10.3046 8.39727 10.1451 8.32202 10.0357 8.14877L8.46333 5.60558L6.59039 6.50814L5.74252 9.78939C5.68768 9.9991 5.55556 10.1177 5.34614 10.1451C5.31872 10.1541 5.29131 10.1586 5.26389 10.1586L5.26345 10.1582Z",
2800
+ fill: "currentColor"
2801
+ }
2802
+ ) }),
2803
+ /* @__PURE__ */ jsx16("defs", { children: /* @__PURE__ */ jsx16("clipPath", { id: "clip0_1774_9563", children: /* @__PURE__ */ jsx16("rect", { width: "14", height: "14", fill: "white" }) }) })
2804
+ ]
3008
2805
  }
3009
- return /* @__PURE__ */ jsxs11("div", { className: "flex w-full flex-col rounded-md py-2", children: [
3010
- (rules || []).map((rule, index) => {
3011
- const isLast = index === (rules || []).length - 1;
3012
- return /* @__PURE__ */ jsxs11(
2806
+ );
2807
+ var LineIcon_default = SvgIcon6;
2808
+
2809
+ // src/charts/icons/PieIcon.tsx
2810
+ import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
2811
+ var SvgIcon7 = ({ className }) => /* @__PURE__ */ jsxs12(
2812
+ "svg",
2813
+ {
2814
+ width: "14",
2815
+ height: "14",
2816
+ viewBox: "0 0 14 14",
2817
+ fill: "none",
2818
+ xmlns: "http://www.w3.org/2000/svg",
2819
+ className,
2820
+ children: [
2821
+ /* @__PURE__ */ jsxs12("g", { clipPath: "url(#clip0_28267_7202)", children: [
2822
+ /* @__PURE__ */ jsx17(
2823
+ "path",
2824
+ {
2825
+ d: "M5.83329 1.86662C4.92079 2.07816 4.08149 2.52998 3.40247 3.17523C2.72345 3.82048 2.22942 4.63564 1.97164 5.53618C1.71386 6.43671 1.70171 7.38982 1.93644 8.29663C2.17118 9.20345 2.64426 10.0309 3.30661 10.6933C3.96896 11.3556 4.79646 11.8287 5.70327 12.0635C6.61009 12.2982 7.56319 12.286 8.46373 12.0283C9.36426 11.7705 10.1794 11.2765 10.8247 10.5974C11.4699 9.91841 11.9217 9.07912 12.1333 8.16662C12.1333 8.01191 12.0718 7.86353 11.9624 7.75414C11.853 7.64474 11.7047 7.58328 11.55 7.58328H7.58329C7.27387 7.58328 6.97713 7.46037 6.75833 7.24157C6.53954 7.02278 6.41662 6.72604 6.41662 6.41662V2.33328C6.40938 2.26417 6.38848 2.19719 6.35515 2.13621C6.32182 2.07524 6.27671 2.02149 6.22245 1.97808C6.16819 1.93467 6.10585 1.90247 6.03905 1.88333C5.97224 1.8642 5.90231 1.85852 5.83329 1.86662Z",
2826
+ stroke: "currentColor",
2827
+ strokeWidth: "1.16667",
2828
+ strokeLinecap: "round",
2829
+ strokeLinejoin: "round"
2830
+ }
2831
+ ),
2832
+ /* @__PURE__ */ jsx17(
2833
+ "path",
2834
+ {
2835
+ d: "M8.75 2.04175C9.49067 2.30255 10.1634 2.72617 10.7187 3.28142C11.2739 3.83668 11.6975 4.50941 11.9583 5.25008H9.33333C9.17862 5.25008 9.03025 5.18862 8.92085 5.07923C8.81146 4.96983 8.75 4.82146 8.75 4.66675V2.04175Z",
2836
+ stroke: "currentColor",
2837
+ strokeWidth: "1.16667",
2838
+ strokeLinecap: "round",
2839
+ strokeLinejoin: "round"
2840
+ }
2841
+ )
2842
+ ] }),
2843
+ /* @__PURE__ */ jsx17("defs", { children: /* @__PURE__ */ jsx17("clipPath", { id: "clip0_28267_7202", children: /* @__PURE__ */ jsx17("rect", { width: "14", height: "14", fill: "white" }) }) })
2844
+ ]
2845
+ }
2846
+ );
2847
+ var PieIcon_default = SvgIcon7;
2848
+
2849
+ // src/charts/icons/ScatterIcon.tsx
2850
+ import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
2851
+ var SvgIcon8 = ({ className }) => /* @__PURE__ */ jsxs13(
2852
+ "svg",
2853
+ {
2854
+ width: "14",
2855
+ height: "14",
2856
+ viewBox: "0 0 14 14",
2857
+ fill: "none",
2858
+ xmlns: "http://www.w3.org/2000/svg",
2859
+ className,
2860
+ children: [
2861
+ /* @__PURE__ */ jsxs13("g", { clipPath: "url(#clip0_28248_7302)", children: [
2862
+ /* @__PURE__ */ jsx18(
2863
+ "path",
2864
+ {
2865
+ d: "M1.75 1.75V12.25H12.25",
2866
+ stroke: "currentColor",
2867
+ strokeWidth: "1.16667",
2868
+ strokeLinecap: "round",
2869
+ strokeLinejoin: "round"
2870
+ }
2871
+ ),
2872
+ /* @__PURE__ */ jsx18(
2873
+ "path",
2874
+ {
2875
+ d: "M4.66663 8.75879V8.76754",
2876
+ stroke: "currentColor",
2877
+ strokeWidth: "1.16667",
2878
+ strokeLinecap: "round",
2879
+ strokeLinejoin: "round"
2880
+ }
2881
+ ),
2882
+ /* @__PURE__ */ jsx18(
2883
+ "path",
2884
+ {
2885
+ d: "M9.33337 9.34204V9.35079",
2886
+ stroke: "currentColor",
2887
+ strokeWidth: "1.16667",
2888
+ strokeLinecap: "round",
2889
+ strokeLinejoin: "round"
2890
+ }
2891
+ ),
2892
+ /* @__PURE__ */ jsx18(
2893
+ "path",
2894
+ {
2895
+ d: "M4.66663 4.10083V4.10958",
2896
+ stroke: "currentColor",
2897
+ strokeWidth: "1.16667",
2898
+ strokeLinecap: "round",
2899
+ strokeLinejoin: "round"
2900
+ }
2901
+ ),
2902
+ /* @__PURE__ */ jsx18(
2903
+ "path",
2904
+ {
2905
+ d: "M7 6.43408V6.44283",
2906
+ stroke: "currentColor",
2907
+ strokeWidth: "1.16667",
2908
+ strokeLinecap: "round",
2909
+ strokeLinejoin: "round"
2910
+ }
2911
+ ),
2912
+ /* @__PURE__ */ jsx18(
2913
+ "path",
2914
+ {
2915
+ d: "M11.0834 6.43408V6.44283",
2916
+ stroke: "currentColor",
2917
+ strokeWidth: "1.16667",
2918
+ strokeLinecap: "round",
2919
+ strokeLinejoin: "round"
2920
+ }
2921
+ )
2922
+ ] }),
2923
+ /* @__PURE__ */ jsx18("defs", { children: /* @__PURE__ */ jsx18("clipPath", { id: "clip0_28248_7302", children: /* @__PURE__ */ jsx18("rect", { width: "14", height: "14", fill: "white" }) }) })
2924
+ ]
2925
+ }
2926
+ );
2927
+ var ScatterIcon_default = SvgIcon8;
2928
+
2929
+ // src/charts/ChartTypeButtonGroup.tsx
2930
+ import { jsx as jsx19 } from "react/jsx-runtime";
2931
+ var visuals = [
2932
+ {
2933
+ label: "Lines",
2934
+ value: "LINE",
2935
+ icon: /* @__PURE__ */ jsx19(LineIcon_default, { className: "mr-1 h-4 w-4" })
2936
+ },
2937
+ { label: "Bars", value: "BAR", icon: /* @__PURE__ */ jsx19(BarIcon_default, { className: "mr-1 h-4 w-4" }) },
2938
+ {
2939
+ label: "Areas",
2940
+ value: "AREA",
2941
+ icon: /* @__PURE__ */ jsx19(AreaIcon_default, { className: "mr-1 h-4 w-4" })
2942
+ },
2943
+ {
2944
+ label: "Bar Gauge",
2945
+ value: "BAR_GAUGE",
2946
+ icon: /* @__PURE__ */ jsx19(BarGuageIcon_default, { className: "mr-1 h-4 w-4" })
2947
+ },
2948
+ {
2949
+ label: "Scatter",
2950
+ value: "SCATTER",
2951
+ icon: /* @__PURE__ */ jsx19(ScatterIcon_default, { className: "mr-1 h-4 w-4" })
2952
+ },
2953
+ {
2954
+ label: "Query Value",
2955
+ value: "QUERY_VALUE",
2956
+ icon: /* @__PURE__ */ jsx19(QueryValueIcon_default, { className: "mr-1 h-4 w-4" })
2957
+ },
2958
+ {
2959
+ label: "Table",
2960
+ value: "TABLE",
2961
+ icon: /* @__PURE__ */ jsx19(TableIcon_default, { className: "mr-1 h-4 w-4" })
2962
+ },
2963
+ { label: "Pie", value: "PIE", icon: /* @__PURE__ */ jsx19(PieIcon_default, { className: "mr-1 h-4 w-4" }) }
2964
+ ];
2965
+ var ChartTypeButtonGroup = ({
2966
+ value,
2967
+ onChange,
2968
+ small = false
2969
+ }) => {
2970
+ const [hideLabel, setHideLabel] = useState7(small);
2971
+ const { ref } = useResizeDetector2({
2972
+ onResize: ({ width }) => {
2973
+ if (width) {
2974
+ setHideLabel(width < 800);
2975
+ }
2976
+ },
2977
+ refreshMode: "throttle",
2978
+ refreshRate: 100
2979
+ });
2980
+ return /* @__PURE__ */ jsx19("div", { className: "w-full flex-1", ref, children: /* @__PURE__ */ jsx19(
2981
+ ButtonGroup,
2982
+ {
2983
+ buttons: visuals,
2984
+ value,
2985
+ onChange,
2986
+ small,
2987
+ hideLabel
2988
+ }
2989
+ ) });
2990
+ };
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(
3013
3128
  "div",
3014
3129
  {
3015
- className: "text-text-foreground flex h-10 items-center py-1",
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" },
3016
3136
  children: [
3017
- renderTreeLine(index, isLast),
3018
- /* @__PURE__ */ jsx15("span", { className: "sm:text-ilabel inline-flex h-full items-center pr-3 font-medium", children: "If value is" }),
3019
- /* @__PURE__ */ jsx15(
3020
- "select",
3137
+ /* @__PURE__ */ jsx20("span", { dangerouslySetInnerHTML: { __html: marker || "" } }),
3138
+ /* @__PURE__ */ jsx20("span", { className: "truncate", children: seriesName }),
3139
+ showViewLogs && isFixed && /* @__PURE__ */ jsx20(
3140
+ "button",
3021
3141
  {
3022
- value: rule.comparison,
3023
- onChange: (e) => changeRule(index, "comparison", e.target.value),
3024
- 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",
3025
- children: Object.entries(operators).map(([op, display]) => {
3026
- return /* @__PURE__ */ jsxs11("option", { value: op, children: [
3027
- "is ",
3028
- display
3029
- ] }, op);
3030
- })
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" })
3031
3150
  }
3032
3151
  ),
3033
- /* @__PURE__ */ jsx15(
3034
- "input",
3152
+ showViewUsers && isFixed && /* @__PURE__ */ jsx20(
3153
+ "button",
3035
3154
  {
3036
- type: "text",
3037
- name: "value",
3038
- id: "value",
3039
- className: "w-30 rounded-l-0 sm:text-ilabel border-main hover:border-primary-600 focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 block h-full rounded-r-md border px-2 py-1",
3040
- placeholder: "0",
3041
- value: rule.value,
3042
- onChange: (e) => {
3043
- changeRule(index, "value", e.target.value);
3044
- }
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" })
3045
3163
  }
3046
3164
  ),
3047
- /* @__PURE__ */ jsx15("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-3 font-medium", children: ", then show" }),
3048
- /* @__PURE__ */ jsx15(
3049
- "input",
3165
+ isFixed && /* @__PURE__ */ jsx20(
3166
+ CopyButton,
3050
3167
  {
3051
- type: "text",
3052
- name: "text",
3053
- id: "text",
3054
- className: "sm:text-ilabel border-main hover:border-primary-600 focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 block h-full w-80 rounded-md px-2 py-1",
3055
- placeholder: "Display text (e.g. High, Low, Normal)",
3056
- value: rule.text,
3057
- onChange: (e) => {
3058
- changeRule(index, "text", e.target.value);
3059
- }
3168
+ size: 16,
3169
+ text: seriesName,
3170
+ className: "invisible ml-1 group-hover:visible"
3060
3171
  }
3061
- ),
3062
- /* @__PURE__ */ jsx15(
3063
- "button",
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",
3064
3188
  {
3065
- type: "button",
3066
- className: "mx-2",
3067
- "aria-label": "remove",
3068
- onClick: () => removeRule(index),
3069
- children: /* @__PURE__ */ jsx15(
3070
- LuTrash2,
3071
- {
3072
- className: "icon text-text-foreground-disabled",
3073
- "aria-hidden": "true"
3074
- }
3075
- )
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
+ ]
3076
3198
  }
3077
3199
  )
3078
3200
  ]
3079
3201
  },
3080
- index
3081
- );
3082
- }),
3083
- /* @__PURE__ */ jsxs11(
3084
- Button,
3085
- {
3086
- type: "button",
3087
- role: "secondary",
3088
- className: "mt-1 w-fit flex-none",
3089
- "aria-label": "remove",
3090
- onClick: addRule,
3091
- children: [
3092
- /* @__PURE__ */ jsx15(LuPlus, { className: classNames5("h-4 w-4"), "aria-hidden": "true" }),
3093
- "Add Formatting Rule"
3094
- ]
3095
- }
3096
- )
3097
- ] });
3098
- }
3099
-
3100
- // src/charts/options/ValueOptions.tsx
3101
- import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
3102
- var ValueFormatters = [
3103
- { label: "Number", value: "NumberFormatter" },
3104
- { label: "Date", value: "DateFormatter" },
3105
- { label: "String", value: "StringFormatter" }
3106
- ];
3107
- var defaultConfig3 = {
3108
- valueFormatter: "NumberFormatter",
3109
- showValueLabel: false,
3110
- maxSignificantDigits: 3,
3111
- dateFormat: "LLL",
3112
- mappingRules: [],
3113
- style: "None"
3114
- };
3115
- var dateFormats = [
3116
- { label: "Localized format", value: "LLL" },
3117
- { label: "ISO String", value: "YYYY-MM-DDTHH:mm:ss.sssZ" }
3118
- ];
3119
- var CurrencySymbols = [
3120
- { label: "USD", value: "$" },
3121
- { label: "EUR", value: "\u20AC" },
3122
- { label: "GBP", value: "\xA3" },
3123
- { label: "CNY or JPY", value: "\xA5" },
3124
- { label: "BTC", value: "\u0243" },
3125
- { label: "ETH", value: "\u039E" }
3126
- ];
3127
- var AddonLabel = ({
3128
- className,
3129
- children
3130
- }) => /* @__PURE__ */ jsx16(
3131
- "span",
3132
- {
3133
- className: classNames6(
3134
- "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap bg-gray-50 px-3",
3135
- className
3136
- ),
3137
- children
3138
- }
3139
- );
3140
- var ValueOptions = ({
3141
- config,
3142
- onChange,
3143
- formatters = ValueFormatters,
3144
- showPrefix,
3145
- showSuffix
3146
- }) => {
3147
- function onChangeDateFormat(f) {
3148
- onChange(produce9(config, (draft) => void (draft.dateFormat = f)));
3149
- }
3150
- function onChangeFormatter(f) {
3151
- onChange(produce9(config, (draft) => void (draft.valueFormatter = f)));
3152
- }
3153
- function onChangeSymbol(symbol) {
3154
- onChange(produce9(config, (draft) => void (draft.currencySymbol = symbol)));
3155
- }
3156
- function onStyleChange(notation) {
3157
- onChange(
3158
- produce9(config, (draft) => {
3159
- draft.style = notation;
3160
- })
3161
- );
3162
- }
3163
- function onDigitsChange(value, option) {
3164
- onChange(
3165
- produce9(config, (draft) => {
3166
- const d = draft;
3167
- if (value) {
3168
- const maxSignificantDigits = parseInt(value);
3169
- if (maxSignificantDigits >= 0 && maxSignificantDigits <= 20) {
3170
- d[option] = maxSignificantDigits;
3171
- }
3172
- } else {
3173
- delete d[option];
3174
- }
3175
- })
3176
- );
3177
- }
3178
- function onMappingRulesChange(rules) {
3179
- onChange(produce9(config, (draft) => void (draft.mappingRules = rules)));
3180
- }
3181
- function onPrefixChange(value) {
3182
- onChange(
3183
- produce9(config, (draft) => {
3184
- if (value) {
3185
- draft.prefix = value;
3186
- } else {
3187
- delete draft.prefix;
3188
- }
3189
- })
3190
- );
3191
- }
3192
- function onSuffixChange(value) {
3193
- onChange(
3194
- produce9(config, (draft) => {
3195
- if (value) {
3196
- draft.suffix = value;
3197
- } else {
3198
- delete draft.suffix;
3199
- }
3200
- })
3201
- );
3202
- }
3203
- function numberAddons(style) {
3204
- switch (style) {
3205
- case "None":
3206
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
3207
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-l-0", children: "Fraction Digits" }),
3208
- /* @__PURE__ */ jsx16(
3209
- "input",
3210
- {
3211
- disabled: true,
3212
- className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main rounded-r-md border border-l-0 py-1",
3213
- value: ""
3214
- }
3215
- )
3216
- ] });
3217
- case "Percent":
3218
- case "Standard":
3219
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
3220
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-x-0", children: "Fraction Digits" }),
3221
- /* @__PURE__ */ jsx16(
3222
- "input",
3223
- {
3224
- type: "number",
3225
- min: 0,
3226
- max: 20,
3227
- className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main focus:ring-3 focus:ring-primary-600/30 hover:border-primary-600 rounded-r-md border py-1",
3228
- value: config.maxFractionDigits,
3229
- placeholder: "0-20",
3230
- onChange: (e) => onDigitsChange(e.target.value, "maxFractionDigits")
3231
- }
3232
- )
3233
- ] });
3234
- case "Currency":
3235
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
3236
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-r-0", children: "Symbol" }),
3237
- /* @__PURE__ */ jsx16("div", { className: "w-28 ", children: /* @__PURE__ */ jsx16(
3238
- ComboInput,
3239
- {
3240
- onChange: onChangeSymbol,
3241
- options: CurrencySymbols.map((s) => s.value),
3242
- displayFn: (s) => {
3243
- const name = CurrencySymbols.find((c) => c.value === s)?.label;
3244
- return `${name} (${s})`;
3245
- },
3246
- placeholder: "$",
3247
- value: config?.currencySymbol
3248
- }
3249
- ) }),
3250
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border", children: "Precision" }),
3251
- /* @__PURE__ */ jsx16(
3252
- "input",
3253
- {
3254
- type: "number",
3255
- min: 0,
3256
- max: 20,
3257
- className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main rounded-r-md border border-l-0 py-1",
3258
- value: config.precision,
3259
- defaultValue: 2,
3260
- placeholder: "0-20",
3261
- onChange: (e) => onDigitsChange(e.target.value, "precision")
3262
- }
3263
- )
3264
- ] });
3265
- default:
3266
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
3267
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-x-0", children: "Max significant digits" }),
3268
- /* @__PURE__ */ jsx16(
3269
- "input",
3270
- {
3271
- type: "number",
3272
- min: 1,
3273
- max: 21,
3274
- className: "focus:border-primary-600 sm:text-ilabel min-w-20 border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 rounded-r-md border py-1",
3275
- value: config.maxSignificantDigits,
3276
- placeholder: "1-21",
3277
- onChange: (e) => onDigitsChange(e.target.value, "maxSignificantDigits")
3278
- }
3279
- )
3280
- ] });
3281
- }
3282
- }
3283
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
3284
- /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsxs12("div", { className: "flex", children: [
3285
- /* @__PURE__ */ jsx16(AddonLabel, { className: "rounded-l-md border border-r-0", children: "Value formatter" }),
3286
- /* @__PURE__ */ jsx16(
3287
- "select",
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",
3288
3213
  {
3289
- value: config.valueFormatter,
3290
- className: classNames6(
3291
- "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",
3292
- config.valueFormatter == "StringFormatter" ? "rounded-r-md" : ""
3214
+ className: classNames5(
3215
+ "sentio-tooltip-item sentio-tooltip-compare-item series-name text-text-foreground-secondary truncate",
3216
+ highlighted ? "highlighted" : ""
3293
3217
  ),
3294
- onChange: (e) => onChangeFormatter(e.target.value),
3295
- children: formatters.map((d) => {
3296
- return /* @__PURE__ */ jsx16("option", { value: d.value, children: d.label }, d.value);
3297
- })
3298
- }
3218
+ style: { minWidth: "4rem" },
3219
+ children: [
3220
+ /* @__PURE__ */ jsx20(
3221
+ "span",
3222
+ {
3223
+ dangerouslySetInnerHTML: { __html: compareMarker || "" }
3224
+ }
3225
+ ),
3226
+ seriesName
3227
+ ]
3228
+ },
3229
+ idx
3299
3230
  ),
3300
- config.valueFormatter == "NumberFormatter" && /* @__PURE__ */ jsxs12(Fragment5, { children: [
3301
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-l-0 border-r-0", children: "Style" }),
3302
- /* @__PURE__ */ jsxs12(
3303
- "select",
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",
3304
3253
  {
3305
- value: config.style,
3306
- 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",
3307
- onChange: (e) => onStyleChange(e.target.value),
3254
+ className: classNames5(
3255
+ "ml-1 text-xs",
3256
+ diff > 0 ? "text-green-500" : "text-red"
3257
+ ),
3308
3258
  children: [
3309
- /* @__PURE__ */ jsx16("option", { value: "None", children: "None" }),
3310
- /* @__PURE__ */ jsx16("option", { value: "Compact", children: "Compact" }),
3311
- /* @__PURE__ */ jsx16("option", { value: "Standard", children: "Standard" }),
3312
- /* @__PURE__ */ jsx16("option", { value: "Scientific", children: "Scientific" }),
3313
- /* @__PURE__ */ jsx16("option", { value: "Percent", children: "Percent" }),
3314
- /* @__PURE__ */ jsx16("option", { value: "Currency", children: "Currency" })
3259
+ diff > 0 ? "+" : "",
3260
+ (diff * 100).toFixed(2),
3261
+ "%"
3315
3262
  ]
3316
3263
  }
3317
- ),
3318
- config.style && numberAddons(config.style)
3319
- ] }),
3320
- config.valueFormatter == "DateFormatter" && /* @__PURE__ */ jsxs12(Fragment5, { children: [
3321
- /* @__PURE__ */ jsx16(AddonLabel, { className: "border border-l-0", children: "Date format" }),
3322
- /* @__PURE__ */ jsx16(
3323
- "select",
3324
- {
3325
- value: config.dateFormat,
3326
- 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",
3327
- onChange: (e) => onChangeDateFormat(e.target.value),
3328
- children: dateFormats.map((d) => {
3329
- return /* @__PURE__ */ jsx16("option", { value: d.value, children: d.label }, d.value);
3330
- })
3331
- }
3332
3264
  )
3333
3265
  ] })
3334
- ] }) }),
3335
- (showPrefix || showSuffix) && /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsxs12("div", { className: "mt-2 flex items-center gap-4", children: [
3336
- showPrefix && /* @__PURE__ */ jsxs12("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: [
3337
- /* @__PURE__ */ jsx16("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Prefix" }),
3338
- /* @__PURE__ */ jsx16(
3339
- "input",
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",
3340
3283
  {
3341
- type: "text",
3342
- className: "border-0 px-3 py-1.5 focus:ring-0",
3343
- value: config.prefix || "",
3344
- placeholder: "e.g., $, #",
3345
- onChange: (e) => onPrefixChange(e.target.value)
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")
3346
3289
  }
3347
- )
3348
- ] }),
3349
- showSuffix && /* @__PURE__ */ jsxs12("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: [
3350
- /* @__PURE__ */ jsx16("div", { className: "h-7.5 leading-7.5 border-r px-3", children: "Suffix" }),
3351
- /* @__PURE__ */ jsx16(
3352
- "input",
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",
3353
3377
  {
3354
- type: "text",
3355
- className: "min-w-32 border-0 px-3 py-1.5 focus:ring-0",
3356
- value: config.suffix || "",
3357
- placeholder: "e.g., %, USD, tokens",
3358
- onChange: (e) => onSuffixChange(e.target.value)
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")
3359
3383
  }
3360
- )
3361
- ] })
3362
- ] }) }),
3363
- config.valueFormatter == "StringFormatter" && /* @__PURE__ */ jsx16(
3364
- ValueStringMapping,
3365
- {
3366
- rules: config.mappingRules || [],
3367
- onChange: onMappingRulesChange
3368
- }
3369
- )
3370
- ] });
3371
- };
3372
-
3373
- // src/charts/options/ValueControls.tsx
3374
- import { defaults as defaults3 } from "lodash";
3375
- import { Checkbox as Checkbox3, DisclosurePanel as DisclosurePanel5 } from "@sentio/ui-core";
3376
- import { produce as produce10 } from "immer";
3377
- import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
3378
- var defaultConfig4 = {
3379
- valueFormatter: "NumberFormatter",
3380
- showValueLabel: false,
3381
- maxSignificantDigits: 3,
3382
- dateFormat: "LLL",
3383
- mappingRules: [],
3384
- style: "None",
3385
- maxFractionDigits: 2
3386
- };
3387
- var ValueControls = ({
3388
- config,
3389
- defaultOpen,
3390
- onChange,
3391
- formatters = ValueFormatters,
3392
- showPrefix,
3393
- showSuffix
3394
- }) => {
3395
- config = defaults3(config || {}, defaultConfig4);
3396
- function toggleShowValueLabel(checked) {
3397
- config && onChange(
3398
- produce10(config, (draft) => void (draft.showValueLabel = checked))
3399
- );
3400
- }
3401
- function toggleTooltipTotal(checked) {
3402
- config && onChange(produce10(config, (draft) => void (draft.tooltipTotal = checked)));
3403
- }
3404
- return /* @__PURE__ */ jsxs13(
3405
- DisclosurePanel5,
3406
- {
3407
- title: "Value Options",
3408
- defaultOpen,
3409
- containerClassName: "w-full bg-default-bg",
3410
- children: [
3411
- /* @__PURE__ */ jsx17(
3412
- ValueOptions,
3384
+ ),
3385
+ /* @__PURE__ */ jsxs15(
3386
+ "div",
3413
3387
  {
3414
- onChange,
3415
- config,
3416
- formatters,
3417
- showPrefix,
3418
- showSuffix
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
+ ]
3419
3432
  }
3420
3433
  ),
3421
- /* @__PURE__ */ jsxs13("div", { className: "mt-2 flex items-center gap-2", children: [
3422
- /* @__PURE__ */ jsx17(
3423
- Checkbox3,
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",
3424
3448
  {
3425
- checked: config?.showValueLabel,
3426
- onChange: toggleShowValueLabel,
3427
- label: "Show value label"
3449
+ className: "sentio-tooltip-item series-name text-text-foreground-secondary truncate",
3450
+ style: { minWidth: "4rem" },
3451
+ children: sizeTitle
3428
3452
  }
3429
3453
  ),
3430
- /* @__PURE__ */ jsx17(
3431
- Checkbox3,
3432
- {
3433
- checked: config?.tooltipTotal,
3434
- onChange: toggleTooltipTotal,
3435
- label: "Show total in tooltip"
3436
- }
3437
- )
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) })
3438
3455
  ] })
3439
3456
  ]
3440
3457
  }
3441
3458
  );
3442
- };
3459
+ }
3443
3460
 
3444
- // src/charts/icons/LineIcon.tsx
3445
- import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
3446
- var SvgIcon = ({ className }) => /* @__PURE__ */ jsxs14(
3447
- "svg",
3448
- {
3449
- width: "14",
3450
- height: "14",
3451
- viewBox: "0 0 14 14",
3452
- fill: "none",
3453
- xmlns: "http://www.w3.org/2000/svg",
3454
- className,
3455
- children: [
3456
- /* @__PURE__ */ jsx18("g", { clipPath: "url(#clip0_1774_9563)", children: /* @__PURE__ */ jsx18(
3457
- "path",
3458
- {
3459
- d: "M12.6191 13.1249H1.35352C1.21672 13.1249 1.10049 13.0771 1.00483 12.9814C0.909161 12.8857 0.861328 12.7695 0.861328 12.6327V1.35352C0.861328 1.21672 0.909161 1.10049 1.00483 1.00483C1.10049 0.909161 1.21672 0.861328 1.35352 0.861328C1.49031 0.861328 1.60654 0.909161 1.7022 1.00483C1.79787 1.10049 1.8457 1.21672 1.8457 1.35352V12.1405H12.6191C12.7559 12.1405 12.8722 12.1883 12.9678 12.284C13.0635 12.3797 13.1113 12.4959 13.1113 12.6327C13.1113 12.7695 13.0635 12.8857 12.9678 12.9814C12.8722 13.0771 12.7559 13.1249 12.6191 13.1249ZM5.26345 10.1582C5.0902 10.1582 4.95341 10.0853 4.85308 9.93945L2.7067 6.52127C2.63379 6.40285 2.61104 6.27758 2.63845 6.14545C2.66587 6.01333 2.73645 5.91081 2.8502 5.83789C2.96395 5.76497 3.08704 5.74222 3.21945 5.76964C3.35187 5.79706 3.45439 5.86545 3.52702 5.97483L5.05827 8.46333L5.68739 6.04352C5.72385 5.89768 5.81047 5.79283 5.94727 5.72895L8.43576 4.52583C8.55418 4.47099 8.67274 4.45962 8.79145 4.4917C8.91016 4.52379 9.00583 4.59437 9.07845 4.70345L10.3227 6.72689L12.155 1.21702C12.2005 1.08927 12.2826 0.993599 12.4013 0.930016C12.52 0.866432 12.6431 0.857245 12.7705 0.902453C12.898 0.947661 12.9936 1.02977 13.0575 1.14877C13.1214 1.26777 13.1306 1.39085 13.0851 1.51802L10.9247 8.03939C10.8608 8.24006 10.724 8.35177 10.5143 8.37452C10.3046 8.39727 10.1451 8.32202 10.0357 8.14877L8.46333 5.60558L6.59039 6.50814L5.74252 9.78939C5.68768 9.9991 5.55556 10.1177 5.34614 10.1451C5.31872 10.1541 5.29131 10.1586 5.26389 10.1586L5.26345 10.1582Z",
3460
- fill: "currentColor"
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
+ }
3461
3518
  }
3462
- ) }),
3463
- /* @__PURE__ */ jsx18("defs", { children: /* @__PURE__ */ jsx18("clipPath", { id: "clip0_1774_9563", children: /* @__PURE__ */ jsx18("rect", { width: "14", height: "14", fill: "white" }) }) })
3464
- ]
3465
- }
3466
- );
3467
- var LineIcon_default = SvgIcon;
3468
-
3469
- // src/charts/icons/AreaIcon.tsx
3470
- import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
3471
- var SvgIcon2 = ({ className }) => /* @__PURE__ */ jsxs15(
3472
- "svg",
3473
- {
3474
- width: "14",
3475
- height: "14",
3476
- viewBox: "0 0 14 14",
3477
- fill: "none",
3478
- xmlns: "http://www.w3.org/2000/svg",
3479
- className,
3480
- children: [
3481
- /* @__PURE__ */ jsx19("g", { clipPath: "url(#clip0_1774_9545)", children: /* @__PURE__ */ jsx19(
3482
- "path",
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 = [
3483
3527
  {
3484
- d: "M12.6193 13.1249H1.35364C1.21685 13.1249 1.10062 13.0771 1.00495 12.9814C0.909284 12.8857 0.86145 12.7695 0.86145 12.6327V1.35352C0.86145 1.21672 0.909284 1.10049 1.00495 1.00483C1.10062 0.909161 1.21685 0.861328 1.35364 0.861328C1.49043 0.861328 1.60666 0.909161 1.70233 1.00483C1.79799 1.10049 1.84583 1.21672 1.84583 1.35352V12.1405H12.6193C12.7561 12.1405 12.8723 12.1883 12.968 12.284C13.0636 12.3797 13.1115 12.4959 13.1115 12.6327C13.1115 12.7695 13.0636 12.8857 12.968 12.9814C12.8723 13.0771 12.7561 13.1249 12.6193 13.1249ZM2.62501 10.9374L4.22451 8.08008C4.26097 8.0162 4.31566 7.97289 4.38858 7.95014C4.46149 7.92739 4.53441 7.92972 4.60733 7.95714L6.12501 8.66808L7.73851 6.33008C7.83885 6.19329 7.96193 6.16135 8.10776 6.23427L9.61189 6.99989L11.7994 3.56814C11.8633 3.46781 11.9521 3.43368 12.0658 3.46577C12.1796 3.49785 12.2366 3.5731 12.2369 3.69152V10.8009C12.2369 10.9467 12.1845 11.072 12.0798 11.1767C11.9751 11.2814 11.8498 11.3338 11.704 11.3338H2.87176C2.77143 11.3338 2.69399 11.2905 2.63945 11.2038C2.58491 11.1172 2.58039 11.0284 2.62589 10.9374H2.62501Z",
3485
- fill: "currentColor"
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
3486
3534
  }
3487
- ) }),
3488
- /* @__PURE__ */ jsx19("defs", { children: /* @__PURE__ */ jsx19("clipPath", { id: "clip0_1774_9545", children: /* @__PURE__ */ jsx19("rect", { width: "14", height: "14", fill: "white" }) }) })
3489
- ]
3490
- }
3491
- );
3492
- var AreaIcon_default = SvgIcon2;
3493
-
3494
- // src/charts/icons/BarIcon.tsx
3495
- import { jsx as jsx20 } from "react/jsx-runtime";
3496
- var SvgIcon3 = ({ className }) => /* @__PURE__ */ jsx20(
3497
- "svg",
3498
- {
3499
- width: "14",
3500
- height: "14",
3501
- viewBox: "0 0 14 14",
3502
- fill: "none",
3503
- xmlns: "http://www.w3.org/2000/svg",
3504
- className,
3505
- children: /* @__PURE__ */ jsx20(
3506
- "path",
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,
3507
3656
  {
3508
- d: "M2.12791 1.5625V12.4375C2.12791 12.5938 2.07311 12.7267 1.96349 12.836C1.85387 12.9453 1.7207 13 1.56396 13C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375V1.5625C1 1.40617 1.05481 1.27333 1.16442 1.164C1.27404 1.05467 1.40722 1 1.56396 1C1.7207 1 1.85387 1.05467 1.96349 1.164C2.07311 1.27333 2.12791 1.40617 2.12791 1.5625ZM1.56396 11.875H12.436C12.5928 11.875 12.726 11.9297 12.8356 12.039C12.9452 12.1483 13 12.2812 13 12.4375C13 12.5938 12.9452 12.7267 12.8356 12.836C12.726 12.9453 12.5928 13 12.436 13H1.56396C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375C1 12.2812 1.05481 12.1483 1.16442 12.039C1.27404 11.9297 1.40722 11.875 1.56396 11.875ZM5.12014 4.578V10.375C5.12014 10.5313 5.06534 10.6642 4.95572 10.7735C4.8461 10.8828 4.71293 10.9375 4.55619 10.9375C4.39945 10.9375 4.26627 10.8828 4.15665 10.7735C4.04704 10.6642 3.99223 10.5313 3.99223 10.375V4.578C3.99223 4.42167 4.04704 4.28883 4.15665 4.1795C4.26627 4.07017 4.39945 4.0155 4.55619 4.0155C4.71293 4.0155 4.8461 4.07017 4.95572 4.1795C5.06534 4.28883 5.12014 4.42167 5.12014 4.578ZM11.1196 2.5465V10.3745C11.1196 10.5308 11.0648 10.6637 10.9552 10.773C10.8456 10.8823 10.7124 10.937 10.5557 10.937C10.3989 10.937 10.2658 10.8823 10.1562 10.773C10.0465 10.6637 9.99173 10.5308 9.99173 10.3745V2.5465C9.99173 2.39017 10.0465 2.25733 10.1562 2.148C10.2658 2.03867 10.3989 1.984 10.5557 1.984C10.7124 1.984 10.8456 2.03867 10.9552 2.148C11.0648 2.25733 11.1196 2.39017 11.1196 2.5465ZM8.11187 6.5465V10.3745C8.11187 10.5308 8.05706 10.6637 7.94745 10.773C7.83783 10.8823 7.70465 10.937 7.54792 10.937C7.39118 10.937 7.258 10.8823 7.14838 10.773C7.03877 10.6637 6.98396 10.5308 6.98396 10.3745V6.5465C6.98396 6.39017 7.03877 6.25733 7.14838 6.148C7.258 6.03867 7.39118 5.984 7.54792 5.984C7.69429 5.984 7.8248 6.03867 7.93943 6.148C8.05406 6.25733 8.11154 6.39017 8.11187 6.5465Z",
3509
- fill: "currentColor"
3657
+ ref,
3658
+ loading,
3659
+ option: options,
3660
+ minHeight,
3661
+ style,
3662
+ noLegend: true,
3663
+ onInitChart
3510
3664
  }
3511
- )
3512
- }
3513
- );
3514
- var BarIcon_default = SvgIcon3;
3515
-
3516
- // src/charts/icons/BarGuageIcon.tsx
3517
- import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
3518
- var SvgIcon4 = ({ className }) => /* @__PURE__ */ jsxs16(
3519
- "svg",
3520
- {
3521
- width: "14",
3522
- height: "14",
3523
- viewBox: "0 0 14 14",
3524
- fill: "currentColor",
3525
- className,
3526
- xmlns: "http://www.w3.org/2000/svg",
3527
- children: [
3528
- /* @__PURE__ */ jsx21(
3529
- "path",
3530
- {
3531
- d: "M2.12791 1.5625V12.4375C2.12791 12.5938 2.07311 12.7267 1.96349 12.836C1.85387 12.9453 1.7207 13 1.56396 13C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375V1.5625C1 1.40617 1.05481 1.27333 1.16442 1.164C1.27404 1.05467 1.40722 1 1.56396 1C1.7207 1 1.85387 1.05467 1.96349 1.164C2.07311 1.27333 2.12791 1.40617 2.12791 1.5625ZM1.56396 11.875H12.436C12.5928 11.875 12.726 11.9297 12.8356 12.039C12.9452 12.1483 13 12.2812 13 12.4375C13 12.5938 12.9452 12.7267 12.8356 12.836C12.726 12.9453 12.5928 13 12.436 13H1.56396C1.40722 13 1.27404 12.9453 1.16442 12.836C1.05481 12.7267 1 12.5938 1 12.4375C1 12.2812 1.05481 12.1483 1.16442 12.039C1.27404 11.9297 1.40722 11.875 1.56396 11.875Z",
3532
- fill: "currentColor"
3533
- }
3534
- ),
3535
- /* @__PURE__ */ jsx21(
3536
- "path",
3537
- {
3538
- d: "M3.64159 4.02495H9.43859C9.59493 4.02495 9.72776 3.97014 9.83709 3.86052C9.94643 3.75091 10.0011 3.61773 10.0011 3.46099C10.0011 3.30425 9.94643 3.17108 9.83709 3.06146C9.72776 2.95184 9.59493 2.89703 9.43859 2.89703L3.64159 2.89703C3.48526 2.89703 3.35243 2.95184 3.24309 3.06146C3.13376 3.17108 3.07909 3.30425 3.07909 3.46099C3.07909 3.61773 3.13376 3.75091 3.24309 3.86052C3.35243 3.97014 3.48526 4.02495 3.64159 4.02495Z",
3539
- fill: "currentColor"
3540
- }
3541
- ),
3542
- /* @__PURE__ */ jsx21(
3543
- "path",
3544
- {
3545
- d: "M3.64209 10.0244H11.4701C11.6264 10.0244 11.7593 9.96964 11.8686 9.86002C11.9779 9.7504 12.0326 9.61723 12.0326 9.46049C12.0326 9.30375 11.9779 9.17057 11.8686 9.06096C11.7593 8.95134 11.6264 8.89653 11.4701 8.89653H3.64209C3.48576 8.89653 3.35293 8.95134 3.24359 9.06096C3.13426 9.17057 3.07959 9.30375 3.07959 9.46049C3.07959 9.61723 3.13426 9.7504 3.24359 9.86002C3.35293 9.96964 3.48576 10.0244 3.64209 10.0244Z",
3546
- fill: "currentColor"
3547
- }
3548
- ),
3549
- /* @__PURE__ */ jsx21(
3550
- "path",
3551
- {
3552
- d: "M3.64209 7.01668L7.47009 7.01668C7.62643 7.01634 7.75926 6.95886 7.86859 6.84423C7.97793 6.7296 8.03259 6.5991 8.03259 6.45272C8.03259 6.29598 7.97793 6.1628 7.86859 6.05319C7.75926 5.94357 7.62643 5.88876 7.47009 5.88876H3.64209C3.48576 5.88876 3.35293 5.94357 3.24359 6.05319C3.13426 6.1628 3.07959 6.29598 3.07959 6.45272C3.07959 6.60946 3.13426 6.74263 3.24359 6.85225C3.35293 6.96187 3.48576 7.01668 3.64209 7.01668Z",
3553
- fill: "currentColor"
3554
- }
3555
- )
3556
- ]
3665
+ ) });
3557
3666
  }
3558
3667
  );
3559
- var BarGuageIcon_default = SvgIcon4;
3668
+ PieChart2.displayName = "PieChart";
3560
3669
 
3561
- // src/charts/icons/PieIcon.tsx
3562
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
3563
- var SvgIcon5 = ({ className }) => /* @__PURE__ */ jsxs17(
3564
- "svg",
3565
- {
3566
- width: "14",
3567
- height: "14",
3568
- viewBox: "0 0 14 14",
3569
- fill: "none",
3570
- xmlns: "http://www.w3.org/2000/svg",
3571
- className,
3572
- children: [
3573
- /* @__PURE__ */ jsxs17("g", { clipPath: "url(#clip0_28267_7202)", children: [
3574
- /* @__PURE__ */ jsx22(
3575
- "path",
3670
+ // src/charts/options/LineControls.tsx
3671
+ import { produce as produce4 } from "immer";
3672
+ import {
3673
+ DisclosurePanel,
3674
+ NewButtonGroup as ButtonGroup2,
3675
+ Checkbox
3676
+ } from "@sentio/ui-core";
3677
+ import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
3678
+ var lineStyles = [
3679
+ { label: "Solid", value: "Solid" },
3680
+ { label: "Dotted", value: "Dotted" }
3681
+ ];
3682
+ var LineControls = ({ config, defaultOpen, onChange }) => {
3683
+ const setStyle = (style) => {
3684
+ onChange(
3685
+ produce4(config || {}, (draft) => {
3686
+ draft.style = style;
3687
+ })
3688
+ );
3689
+ };
3690
+ const setSmooth = (smooth) => {
3691
+ onChange(
3692
+ produce4(config || {}, (draft) => {
3693
+ draft.smooth = smooth;
3694
+ })
3695
+ );
3696
+ };
3697
+ return /* @__PURE__ */ jsx23(
3698
+ DisclosurePanel,
3699
+ {
3700
+ title: "Line style",
3701
+ containerClassName: "w-full bg-default-bg",
3702
+ children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-4", children: [
3703
+ /* @__PURE__ */ jsx23(
3704
+ ButtonGroup2,
3576
3705
  {
3577
- d: "M5.83329 1.86662C4.92079 2.07816 4.08149 2.52998 3.40247 3.17523C2.72345 3.82048 2.22942 4.63564 1.97164 5.53618C1.71386 6.43671 1.70171 7.38982 1.93644 8.29663C2.17118 9.20345 2.64426 10.0309 3.30661 10.6933C3.96896 11.3556 4.79646 11.8287 5.70327 12.0635C6.61009 12.2982 7.56319 12.286 8.46373 12.0283C9.36426 11.7705 10.1794 11.2765 10.8247 10.5974C11.4699 9.91841 11.9217 9.07912 12.1333 8.16662C12.1333 8.01191 12.0718 7.86353 11.9624 7.75414C11.853 7.64474 11.7047 7.58328 11.55 7.58328H7.58329C7.27387 7.58328 6.97713 7.46037 6.75833 7.24157C6.53954 7.02278 6.41662 6.72604 6.41662 6.41662V2.33328C6.40938 2.26417 6.38848 2.19719 6.35515 2.13621C6.32182 2.07524 6.27671 2.02149 6.22245 1.97808C6.16819 1.93467 6.10585 1.90247 6.03905 1.88333C5.97224 1.8642 5.90231 1.85852 5.83329 1.86662Z",
3578
- stroke: "currentColor",
3579
- strokeWidth: "1.16667",
3580
- strokeLinecap: "round",
3581
- strokeLinejoin: "round"
3706
+ buttons: lineStyles,
3707
+ value: config?.style || "Solid",
3708
+ onChange: setStyle,
3709
+ small: true
3582
3710
  }
3583
3711
  ),
3584
- /* @__PURE__ */ jsx22(
3585
- "path",
3712
+ /* @__PURE__ */ jsx23(
3713
+ Checkbox,
3586
3714
  {
3587
- d: "M8.75 2.04175C9.49067 2.30255 10.1634 2.72617 10.7187 3.28142C11.2739 3.83668 11.6975 4.50941 11.9583 5.25008H9.33333C9.17862 5.25008 9.03025 5.18862 8.92085 5.07923C8.81146 4.96983 8.75 4.82146 8.75 4.66675V2.04175Z",
3588
- stroke: "currentColor",
3589
- strokeWidth: "1.16667",
3590
- strokeLinecap: "round",
3591
- strokeLinejoin: "round"
3715
+ label: "Smooth Curves",
3716
+ checked: config?.smooth,
3717
+ onChange: setSmooth
3592
3718
  }
3593
3719
  )
3594
- ] }),
3595
- /* @__PURE__ */ jsx22("defs", { children: /* @__PURE__ */ jsx22("clipPath", { id: "clip0_28267_7202", children: /* @__PURE__ */ jsx22("rect", { width: "14", height: "14", fill: "white" }) }) })
3596
- ]
3597
- }
3598
- );
3599
- var PieIcon_default = SvgIcon5;
3720
+ ] })
3721
+ }
3722
+ );
3723
+ };
3600
3724
 
3601
- // src/charts/icons/QueryValueIcon.tsx
3602
- import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
3603
- var SvgIcon6 = ({ className }) => /* @__PURE__ */ jsxs18(
3604
- "svg",
3605
- {
3606
- width: "14",
3607
- height: "14",
3608
- viewBox: "0 0 14 14",
3609
- fill: "none",
3610
- className,
3611
- xmlns: "http://www.w3.org/2000/svg",
3612
- children: [
3613
- /* @__PURE__ */ jsxs18("g", { clipPath: "url(#clip0_3670_4424)", children: [
3614
- /* @__PURE__ */ jsx23(
3615
- "path",
3725
+ // src/charts/options/LabelControls.tsx
3726
+ import { useEffect as useEffect7, useMemo as useMemo7 } from "react";
3727
+ import { produce as produce5 } from "immer";
3728
+ import { Button as NewButton2, DisclosurePanel as DisclosurePanel2, HelpIcon as HelpIcon2 } from "@sentio/ui-core";
3729
+ import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
3730
+ var initialConfig = {
3731
+ columns: [],
3732
+ alias: ""
3733
+ };
3734
+ var LabelControls = ({ config, setConfig, defaultOpen }) => {
3735
+ useEffect7(() => {
3736
+ if (config?.columns && config.columns.length > 0 && !config.alias) {
3737
+ const aliasParts = [];
3738
+ config.columns.forEach((colConfig) => {
3739
+ if (!colConfig.name) return;
3740
+ if (colConfig.showLabel === false && colConfig.showValue === false) {
3741
+ } else if (colConfig.showValue === false) {
3742
+ aliasParts.push(colConfig.name);
3743
+ } else {
3744
+ aliasParts.push(`{{${colConfig.name}}}`);
3745
+ }
3746
+ });
3747
+ if (aliasParts.length > 0) {
3748
+ const migratedAlias = aliasParts.join(", ");
3749
+ setConfig(
3750
+ produce5(config, (draft) => {
3751
+ draft.alias = migratedAlias;
3752
+ draft.columns = [];
3753
+ })
3754
+ );
3755
+ }
3756
+ }
3757
+ }, [config, setConfig]);
3758
+ const onAliasChanged = (alias) => {
3759
+ setConfig(
3760
+ produce5(config ?? initialConfig, (draft) => {
3761
+ draft.alias = alias;
3762
+ })
3763
+ );
3764
+ };
3765
+ const _defaultOpen = useMemo7(() => {
3766
+ if (defaultOpen) {
3767
+ return true;
3768
+ }
3769
+ return config?.alias !== "" || config?.columns && config.columns.length > 0;
3770
+ }, [config, defaultOpen]);
3771
+ return /* @__PURE__ */ jsx24(
3772
+ DisclosurePanel2,
3773
+ {
3774
+ title: "Label Controls",
3775
+ defaultOpen: _defaultOpen,
3776
+ containerClassName: "w-full bg-default-bg",
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: [
3780
+ "Label Alias",
3781
+ /* @__PURE__ */ jsx24(
3782
+ HelpIcon2,
3783
+ {
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: [
3787
+ "Ex.",
3788
+ " ",
3789
+ /* @__PURE__ */ jsx24("span", { className: "text-primary mx-1 font-semibold italic", children: "{{contract}}" }),
3790
+ " ",
3791
+ "will be replaced with the value of the contract label."
3792
+ ] })
3793
+ ] })
3794
+ }
3795
+ )
3796
+ ] }),
3797
+ /* @__PURE__ */ jsx24(
3798
+ "input",
3799
+ {
3800
+ type: "text",
3801
+ value: config?.alias || "",
3802
+ onChange: (e) => onAliasChanged(e.target.value),
3803
+ placeholder: "Enter alias...",
3804
+ className: "focus:border-primary-500 sm:text-icontent border-main inline-flex w-64 items-center rounded-r-md border px-2"
3805
+ }
3806
+ )
3807
+ ] }),
3808
+ /* @__PURE__ */ jsx24(
3809
+ NewButton2,
3616
3810
  {
3617
- d: "M11.5 1.5H2.5C1.67157 1.5 1 2.11561 1 2.875V11.125C1 11.8844 1.67157 12.5 2.5 12.5H11.5C12.3284 12.5 13 11.8844 13 11.125V2.875C13 2.11561 12.3284 1.5 11.5 1.5Z",
3618
- stroke: "currentColor",
3619
- strokeWidth: "1.16667",
3620
- strokeLinecap: "round",
3621
- strokeLinejoin: "round"
3811
+ type: "button",
3812
+ role: "link",
3813
+ onClick: () => {
3814
+ setConfig(initialConfig);
3815
+ },
3816
+ children: "Reset"
3622
3817
  }
3623
- ),
3624
- /* @__PURE__ */ jsx23(
3625
- "path",
3818
+ )
3819
+ ] })
3820
+ }
3821
+ );
3822
+ };
3823
+
3824
+ // src/charts/options/PieChartControls.tsx
3825
+ import { produce as produce6 } from "immer";
3826
+ import { defaults } from "lodash";
3827
+ import {
3828
+ Checkbox as Checkbox2,
3829
+ DisclosurePanel as DisclosurePanel3,
3830
+ NewButtonGroup as ButtonGroup3
3831
+ } from "@sentio/ui-core";
3832
+ import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
3833
+ var defaultConfig = {
3834
+ pieType: "Pie",
3835
+ calculation: "LAST",
3836
+ showPercent: true,
3837
+ showValue: true,
3838
+ absValue: false
3839
+ };
3840
+ var CalculationItems = [
3841
+ { label: "Last", value: "LAST" },
3842
+ { label: "First", value: "FIRST" },
3843
+ { label: "Total", value: "TOTAL" },
3844
+ { label: "Mean", value: "MEAN" },
3845
+ { label: "Max", value: "MAX" },
3846
+ { label: "Min", value: "MIN" }
3847
+ ];
3848
+ var PieTypeItems = [
3849
+ { label: "Pie", value: "Pie" },
3850
+ { label: "Donut", value: "Donut" }
3851
+ ];
3852
+ function PieChartControls({ config, defaultOpen, onChange }) {
3853
+ config = defaults(config, defaultConfig);
3854
+ function onCalculationChange(cal) {
3855
+ config && onChange(produce6(config, (draft) => void (draft.calculation = cal)));
3856
+ }
3857
+ function onPieTypeChange(pieType) {
3858
+ config && onChange(produce6(config, (draft) => void (draft.pieType = pieType)));
3859
+ }
3860
+ function toggle(field, value) {
3861
+ config && onChange(
3862
+ produce6(config, (draft) => {
3863
+ draft[field] = value;
3864
+ })
3865
+ );
3866
+ }
3867
+ return /* @__PURE__ */ jsx25(
3868
+ DisclosurePanel3,
3869
+ {
3870
+ title: "Pie Chart Options",
3871
+ defaultOpen,
3872
+ containerClassName: "w-full bg-default-bg",
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(
3875
+ ButtonGroup3,
3626
3876
  {
3627
- d: "M7.98188 5.77273H6.39097L5.75461 5.13636L6.39097 4.5H7.98188L8.61824 5.13636L7.98188 5.77273Z",
3628
- fill: "currentColor"
3877
+ small: true,
3878
+ buttons: PieTypeItems,
3879
+ value: config.pieType,
3880
+ onChange: onPieTypeChange
3881
+ }
3882
+ ) }),
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(
3886
+ "select",
3887
+ {
3888
+ value: config.calculation,
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",
3890
+ onChange: (e) => onCalculationChange(e.target.value),
3891
+ children: CalculationItems.map((d) => {
3892
+ return /* @__PURE__ */ jsx25("option", { value: d.value, children: d.label }, d.value);
3893
+ })
3894
+ }
3895
+ )
3896
+ ] }),
3897
+ /* @__PURE__ */ jsx25(
3898
+ Checkbox2,
3899
+ {
3900
+ checked: config?.showValue,
3901
+ onChange: (v) => toggle("showValue", v),
3902
+ label: "Show value",
3903
+ labelClassName: "whitespace-nowrap"
3629
3904
  }
3630
3905
  ),
3631
- /* @__PURE__ */ jsx23(
3632
- "path",
3906
+ /* @__PURE__ */ jsx25(
3907
+ Checkbox2,
3633
3908
  {
3634
- d: "M7.98188 11.5H6.39097L5.75461 10.8637L6.39097 10.2273H7.98188L8.61824 10.8637L7.98188 11.5Z",
3635
- fill: "currentColor"
3909
+ checked: config?.showPercent,
3910
+ onChange: (v) => toggle("showPercent", v),
3911
+ label: "Show percent",
3912
+ labelClassName: "whitespace-nowrap"
3636
3913
  }
3637
3914
  ),
3638
- /* @__PURE__ */ jsx23(
3639
- "path",
3915
+ /* @__PURE__ */ jsx25(
3916
+ Checkbox2,
3917
+ {
3918
+ checked: config?.absValue,
3919
+ onChange: (v) => toggle("absValue", v),
3920
+ label: "Use absolute values",
3921
+ labelClassName: "whitespace-nowrap"
3922
+ }
3923
+ )
3924
+ ] })
3925
+ }
3926
+ );
3927
+ }
3928
+
3929
+ // src/charts/options/BarGaugeControls.tsx
3930
+ import { produce as produce7 } from "immer";
3931
+ import { defaults as defaults2 } from "lodash";
3932
+ import { DisclosurePanel as DisclosurePanel4 } from "@sentio/ui-core";
3933
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
3934
+ var defaultConfig2 = {
3935
+ direction: "HORIZONTAL",
3936
+ calculation: "LAST",
3937
+ sort: {
3938
+ sortBy: "ByName",
3939
+ orderDesc: true
3940
+ }
3941
+ };
3942
+ var directionItems = [
3943
+ { label: "Horizontal", value: "HORIZONTAL" },
3944
+ { label: "Vertical", value: "VERTICAL" }
3945
+ ];
3946
+ var CalculationItems2 = [
3947
+ { label: "Last", value: "LAST" },
3948
+ { label: "First", value: "FIRST" },
3949
+ { label: "Total", value: "TOTAL" },
3950
+ { label: "Mean", value: "MEAN" },
3951
+ { label: "Max", value: "MAX" },
3952
+ { label: "Min", value: "MIN" }
3953
+ ];
3954
+ var sortByItems = [
3955
+ { label: "Name", value: "ByName" },
3956
+ { label: "Value", value: "ByValue" }
3957
+ ];
3958
+ var orderItems = [
3959
+ { label: "Ascendant", value: "false" },
3960
+ { label: "Descendant", value: "true" }
3961
+ ];
3962
+ function BarGaugeControls({ config, defaultOpen, onChange }) {
3963
+ config = defaults2(config, defaultConfig2);
3964
+ function onCalculationChange(cal) {
3965
+ config && onChange(produce7(config, (draft) => void (draft.calculation = cal)));
3966
+ }
3967
+ function onDirectionChange(dir) {
3968
+ config && onChange(produce7(config, (draft) => void (draft.direction = dir)));
3969
+ }
3970
+ function onOrderChange(orderDesc) {
3971
+ config && onChange(
3972
+ produce7(config, (draft) => {
3973
+ draft.sort = draft.sort || {};
3974
+ draft.sort.orderDesc = orderDesc;
3975
+ })
3976
+ );
3977
+ }
3978
+ function onSortByChange(sortBy3) {
3979
+ config && onChange(
3980
+ produce7(config, (draft) => {
3981
+ draft.sort = draft.sort || {};
3982
+ draft.sort.sortBy = sortBy3;
3983
+ })
3984
+ );
3985
+ }
3986
+ return /* @__PURE__ */ jsx26(
3987
+ DisclosurePanel4,
3988
+ {
3989
+ title: "Bar Gauge Options",
3990
+ defaultOpen,
3991
+ containerClassName: "w-full bg-default-bg",
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(
3996
+ "select",
3997
+ {
3998
+ value: config.direction,
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",
4000
+ onChange: (e) => onDirectionChange(e.target.value),
4001
+ children: directionItems.map((d) => {
4002
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
4003
+ })
4004
+ }
4005
+ )
4006
+ ] }),
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(
4010
+ "select",
4011
+ {
4012
+ value: config.calculation,
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",
4014
+ onChange: (e) => onCalculationChange(e.target.value),
4015
+ children: CalculationItems2.map((d) => {
4016
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
4017
+ })
4018
+ }
4019
+ )
4020
+ ] }),
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(
4024
+ "select",
4025
+ {
4026
+ value: config?.sort?.sortBy,
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",
4028
+ onChange: (e) => onSortByChange(e.target.value),
4029
+ children: sortByItems.map((d) => {
4030
+ return /* @__PURE__ */ jsx26("option", { value: d.value, children: d.label }, d.value);
4031
+ })
4032
+ }
4033
+ ),
4034
+ /* @__PURE__ */ jsx26(
4035
+ "select",
4036
+ {
4037
+ value: config?.sort?.orderDesc + "",
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",
4039
+ onChange: (e) => onOrderChange(e.target.value === "true"),
4040
+ children: orderItems.map((d) => {
4041
+ return /* @__PURE__ */ jsx26("option", { value: d.value + "", children: d.label }, d.label);
4042
+ })
4043
+ }
4044
+ )
4045
+ ] })
4046
+ ] })
4047
+ }
4048
+ );
4049
+ }
4050
+
4051
+ // src/charts/options/ValueOptions.tsx
4052
+ import { produce as produce9 } from "immer";
4053
+ import { ComboInput, classNames as classNames8 } from "@sentio/ui-core";
4054
+
4055
+ // src/charts/options/ValueStringMapping.tsx
4056
+ import { LuPlus, LuTrash2 } from "react-icons/lu";
4057
+ import { Button, classNames as classNames7 } from "@sentio/ui-core";
4058
+ import { produce as produce8 } from "immer";
4059
+ import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
4060
+ var operators = {
4061
+ ">": "greater than",
4062
+ ">=": "greater or equal",
4063
+ "==": "equal",
4064
+ "!=": "not equal",
4065
+ "<": "less than",
4066
+ "<=": "less or equal"
4067
+ };
4068
+ var renderTreeLine = (index, isLast) => {
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(
4071
+ "div",
4072
+ {
4073
+ className: classNames7(
4074
+ "w-px bg-gray-300",
4075
+ isLast ? "h-1/2 self-start" : index === 0 ? "h-full self-end" : "h-full"
4076
+ )
4077
+ }
4078
+ ),
4079
+ /* @__PURE__ */ jsx27("div", { className: "h-px w-3 bg-gray-300" })
4080
+ ] }) });
4081
+ };
4082
+ function ValueStringMapping({ rules, onChange }) {
4083
+ const addRule = () => {
4084
+ onChange(
4085
+ produce8(rules, (draft) => {
4086
+ draft = draft || [];
4087
+ draft.push({
4088
+ comparison: "==",
4089
+ value: 0,
4090
+ text: ""
4091
+ });
4092
+ })
4093
+ );
4094
+ };
4095
+ function removeRule(index) {
4096
+ onChange(
4097
+ produce8(rules, (draft) => {
4098
+ draft.splice(index, 1);
4099
+ })
4100
+ );
4101
+ }
4102
+ function changeRule(index, field, value) {
4103
+ onChange(
4104
+ produce8(rules, (draft) => {
4105
+ ;
4106
+ draft[index][field] = value;
4107
+ })
4108
+ );
4109
+ }
4110
+ return /* @__PURE__ */ jsxs20("div", { className: "flex w-full flex-col rounded-md py-2", children: [
4111
+ (rules || []).map((rule, index) => {
4112
+ const isLast = index === (rules || []).length - 1;
4113
+ return /* @__PURE__ */ jsxs20(
4114
+ "div",
4115
+ {
4116
+ className: "text-text-foreground flex h-10 items-center py-1",
4117
+ children: [
4118
+ renderTreeLine(index, isLast),
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(
4121
+ "select",
4122
+ {
4123
+ value: rule.comparison,
4124
+ onChange: (e) => changeRule(index, "comparison", e.target.value),
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",
4126
+ children: Object.entries(operators).map(([op, display]) => {
4127
+ return /* @__PURE__ */ jsxs20("option", { value: op, children: [
4128
+ "is ",
4129
+ display
4130
+ ] }, op);
4131
+ })
4132
+ }
4133
+ ),
4134
+ /* @__PURE__ */ jsx27(
4135
+ "input",
4136
+ {
4137
+ type: "text",
4138
+ name: "value",
4139
+ id: "value",
4140
+ className: "w-30 rounded-l-0 sm:text-ilabel border-main hover:border-primary-600 focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 block h-full rounded-r-md border px-2 py-1",
4141
+ placeholder: "0",
4142
+ value: rule.value,
4143
+ onChange: (e) => {
4144
+ changeRule(index, "value", e.target.value);
4145
+ }
4146
+ }
4147
+ ),
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(
4150
+ "input",
4151
+ {
4152
+ type: "text",
4153
+ name: "text",
4154
+ id: "text",
4155
+ className: "sm:text-ilabel border-main hover:border-primary-600 focus:border-primary-600 focus:ring-3 focus:ring-primary-600/30 block h-full w-80 rounded-md px-2 py-1",
4156
+ placeholder: "Display text (e.g. High, Low, Normal)",
4157
+ value: rule.text,
4158
+ onChange: (e) => {
4159
+ changeRule(index, "text", e.target.value);
4160
+ }
4161
+ }
4162
+ ),
4163
+ /* @__PURE__ */ jsx27(
4164
+ "button",
4165
+ {
4166
+ type: "button",
4167
+ className: "mx-2",
4168
+ "aria-label": "remove",
4169
+ onClick: () => removeRule(index),
4170
+ children: /* @__PURE__ */ jsx27(
4171
+ LuTrash2,
4172
+ {
4173
+ className: "icon text-text-foreground-disabled",
4174
+ "aria-hidden": "true"
4175
+ }
4176
+ )
4177
+ }
4178
+ )
4179
+ ]
4180
+ },
4181
+ index
4182
+ );
4183
+ }),
4184
+ /* @__PURE__ */ jsxs20(
4185
+ Button,
4186
+ {
4187
+ type: "button",
4188
+ role: "secondary",
4189
+ className: "mt-1 w-fit flex-none",
4190
+ "aria-label": "remove",
4191
+ onClick: addRule,
4192
+ children: [
4193
+ /* @__PURE__ */ jsx27(LuPlus, { className: classNames7("h-4 w-4"), "aria-hidden": "true" }),
4194
+ "Add Formatting Rule"
4195
+ ]
4196
+ }
4197
+ )
4198
+ ] });
4199
+ }
4200
+
4201
+ // src/charts/options/ValueOptions.tsx
4202
+ import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
4203
+ var ValueFormatters = [
4204
+ { label: "Number", value: "NumberFormatter" },
4205
+ { label: "Date", value: "DateFormatter" },
4206
+ { label: "String", value: "StringFormatter" }
4207
+ ];
4208
+ var defaultConfig3 = {
4209
+ valueFormatter: "NumberFormatter",
4210
+ showValueLabel: false,
4211
+ maxSignificantDigits: 3,
4212
+ dateFormat: "LLL",
4213
+ mappingRules: [],
4214
+ style: "None"
4215
+ };
4216
+ var dateFormats = [
4217
+ { label: "Localized format", value: "LLL" },
4218
+ { label: "ISO String", value: "YYYY-MM-DDTHH:mm:ss.sssZ" }
4219
+ ];
4220
+ var CurrencySymbols = [
4221
+ { label: "USD", value: "$" },
4222
+ { label: "EUR", value: "\u20AC" },
4223
+ { label: "GBP", value: "\xA3" },
4224
+ { label: "CNY or JPY", value: "\xA5" },
4225
+ { label: "BTC", value: "\u0243" },
4226
+ { label: "ETH", value: "\u039E" }
4227
+ ];
4228
+ var AddonLabel = ({
4229
+ className,
4230
+ children
4231
+ }) => /* @__PURE__ */ jsx28(
4232
+ "span",
4233
+ {
4234
+ className: classNames8(
4235
+ "sm:text-ilabel border-main inline-flex items-center whitespace-nowrap bg-gray-50 px-3",
4236
+ className
4237
+ ),
4238
+ children
4239
+ }
4240
+ );
4241
+ var ValueOptions = ({
4242
+ config,
4243
+ onChange,
4244
+ formatters = ValueFormatters,
4245
+ showPrefix,
4246
+ showSuffix
4247
+ }) => {
4248
+ function onChangeDateFormat(f) {
4249
+ onChange(produce9(config, (draft) => void (draft.dateFormat = f)));
4250
+ }
4251
+ function onChangeFormatter(f) {
4252
+ onChange(produce9(config, (draft) => void (draft.valueFormatter = f)));
4253
+ }
4254
+ function onChangeSymbol(symbol) {
4255
+ onChange(produce9(config, (draft) => void (draft.currencySymbol = symbol)));
4256
+ }
4257
+ function onStyleChange(notation) {
4258
+ onChange(
4259
+ produce9(config, (draft) => {
4260
+ draft.style = notation;
4261
+ })
4262
+ );
4263
+ }
4264
+ function onDigitsChange(value, option) {
4265
+ onChange(
4266
+ produce9(config, (draft) => {
4267
+ const d = draft;
4268
+ if (value) {
4269
+ const maxSignificantDigits = parseInt(value);
4270
+ if (maxSignificantDigits >= 0 && maxSignificantDigits <= 20) {
4271
+ d[option] = maxSignificantDigits;
4272
+ }
4273
+ } else {
4274
+ delete d[option];
4275
+ }
4276
+ })
4277
+ );
4278
+ }
4279
+ function onMappingRulesChange(rules) {
4280
+ onChange(produce9(config, (draft) => void (draft.mappingRules = rules)));
4281
+ }
4282
+ function onPrefixChange(value) {
4283
+ onChange(
4284
+ produce9(config, (draft) => {
4285
+ if (value) {
4286
+ draft.prefix = value;
4287
+ } else {
4288
+ delete draft.prefix;
4289
+ }
4290
+ })
4291
+ );
4292
+ }
4293
+ function onSuffixChange(value) {
4294
+ onChange(
4295
+ produce9(config, (draft) => {
4296
+ if (value) {
4297
+ draft.suffix = value;
4298
+ } else {
4299
+ delete draft.suffix;
4300
+ }
4301
+ })
4302
+ );
4303
+ }
4304
+ function numberAddons(style) {
4305
+ switch (style) {
4306
+ case "None":
4307
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4308
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-l-0", children: "Fraction Digits" }),
4309
+ /* @__PURE__ */ jsx28(
4310
+ "input",
4311
+ {
4312
+ disabled: true,
4313
+ className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main rounded-r-md border border-l-0 py-1",
4314
+ value: ""
4315
+ }
4316
+ )
4317
+ ] });
4318
+ case "Percent":
4319
+ case "Standard":
4320
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4321
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-x-0", children: "Fraction Digits" }),
4322
+ /* @__PURE__ */ jsx28(
4323
+ "input",
4324
+ {
4325
+ type: "number",
4326
+ min: 0,
4327
+ max: 20,
4328
+ className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main focus:ring-3 focus:ring-primary-600/30 hover:border-primary-600 rounded-r-md border py-1",
4329
+ value: config.maxFractionDigits,
4330
+ placeholder: "0-20",
4331
+ onChange: (e) => onDigitsChange(e.target.value, "maxFractionDigits")
4332
+ }
4333
+ )
4334
+ ] });
4335
+ case "Currency":
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(
4339
+ ComboInput,
4340
+ {
4341
+ onChange: onChangeSymbol,
4342
+ options: CurrencySymbols.map((s) => s.value),
4343
+ displayFn: (s) => {
4344
+ const name = CurrencySymbols.find((c) => c.value === s)?.label;
4345
+ return `${name} (${s})`;
4346
+ },
4347
+ placeholder: "$",
4348
+ value: config?.currencySymbol
4349
+ }
4350
+ ) }),
4351
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border", children: "Precision" }),
4352
+ /* @__PURE__ */ jsx28(
4353
+ "input",
4354
+ {
4355
+ type: "number",
4356
+ min: 0,
4357
+ max: 20,
4358
+ className: "focus:border-primary-500 sm:text-ilabel min-w-20 border-main rounded-r-md border border-l-0 py-1",
4359
+ value: config.precision,
4360
+ defaultValue: 2,
4361
+ placeholder: "0-20",
4362
+ onChange: (e) => onDigitsChange(e.target.value, "precision")
4363
+ }
4364
+ )
4365
+ ] });
4366
+ default:
4367
+ return /* @__PURE__ */ jsxs21(Fragment8, { children: [
4368
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-x-0", children: "Max significant digits" }),
4369
+ /* @__PURE__ */ jsx28(
4370
+ "input",
4371
+ {
4372
+ type: "number",
4373
+ min: 1,
4374
+ max: 21,
4375
+ className: "focus:border-primary-600 sm:text-ilabel min-w-20 border-main hover:border-primary-600 focus:ring-3 focus:ring-primary-600/30 rounded-r-md border py-1",
4376
+ value: config.maxSignificantDigits,
4377
+ placeholder: "1-21",
4378
+ onChange: (e) => onDigitsChange(e.target.value, "maxSignificantDigits")
4379
+ }
4380
+ )
4381
+ ] });
4382
+ }
4383
+ }
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(
4388
+ "select",
4389
+ {
4390
+ value: config.valueFormatter,
4391
+ className: classNames8(
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",
4393
+ config.valueFormatter == "StringFormatter" ? "rounded-r-md" : ""
4394
+ ),
4395
+ onChange: (e) => onChangeFormatter(e.target.value),
4396
+ children: formatters.map((d) => {
4397
+ return /* @__PURE__ */ jsx28("option", { value: d.value, children: d.label }, d.value);
4398
+ })
4399
+ }
4400
+ ),
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(
4404
+ "select",
3640
4405
  {
3641
- d: "M8.30005 9.90907V6.09089L8.93641 5.45453L9.57278 6.09089V9.90907L8.93641 10.5454L8.30005 9.90907Z",
3642
- fill: "currentColor"
4406
+ value: config.style,
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",
4408
+ onChange: (e) => onStyleChange(e.target.value),
4409
+ children: [
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" })
4416
+ ]
3643
4417
  }
3644
4418
  ),
3645
- /* @__PURE__ */ jsx23(
3646
- "path",
4419
+ config.style && numberAddons(config.style)
4420
+ ] }),
4421
+ config.valueFormatter == "DateFormatter" && /* @__PURE__ */ jsxs21(Fragment8, { children: [
4422
+ /* @__PURE__ */ jsx28(AddonLabel, { className: "border border-l-0", children: "Date format" }),
4423
+ /* @__PURE__ */ jsx28(
4424
+ "select",
3647
4425
  {
3648
- d: "M4.80005 9.90907V6.09089L5.43641 5.45453L6.07278 6.09089V9.90907L5.43641 10.5454L4.80005 9.90907Z",
3649
- fill: "currentColor"
4426
+ value: config.dateFormat,
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",
4428
+ onChange: (e) => onChangeDateFormat(e.target.value),
4429
+ children: dateFormats.map((d) => {
4430
+ return /* @__PURE__ */ jsx28("option", { value: d.value, children: d.label }, d.value);
4431
+ })
3650
4432
  }
3651
- ),
3652
- /* @__PURE__ */ jsx23(
3653
- "path",
4433
+ )
4434
+ ] })
4435
+ ] }) }),
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(
4440
+ "input",
3654
4441
  {
3655
- d: "M1 3.5L13 3.5",
3656
- stroke: "currentColor",
3657
- strokeWidth: "1.16667",
3658
- strokeLinecap: "round",
3659
- strokeLinejoin: "round"
4442
+ type: "text",
4443
+ className: "border-0 px-3 py-1.5 focus:ring-0",
4444
+ value: config.prefix || "",
4445
+ placeholder: "e.g., $, #",
4446
+ onChange: (e) => onPrefixChange(e.target.value)
3660
4447
  }
3661
4448
  )
3662
4449
  ] }),
3663
- /* @__PURE__ */ jsx23("defs", { children: /* @__PURE__ */ jsx23("clipPath", { id: "clip0_3670_4424", children: /* @__PURE__ */ jsx23("rect", { width: "14", height: "14", fill: "white" }) }) })
3664
- ]
3665
- }
3666
- );
3667
- var QueryValueIcon_default = SvgIcon6;
3668
-
3669
- // src/charts/icons/ScatterIcon.tsx
3670
- import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
3671
- var SvgIcon7 = ({ className }) => /* @__PURE__ */ jsxs19(
3672
- "svg",
3673
- {
3674
- width: "14",
3675
- height: "14",
3676
- viewBox: "0 0 14 14",
3677
- fill: "none",
3678
- xmlns: "http://www.w3.org/2000/svg",
3679
- className,
3680
- children: [
3681
- /* @__PURE__ */ jsxs19("g", { clipPath: "url(#clip0_28248_7302)", children: [
3682
- /* @__PURE__ */ jsx24(
3683
- "path",
3684
- {
3685
- d: "M1.75 1.75V12.25H12.25",
3686
- stroke: "currentColor",
3687
- strokeWidth: "1.16667",
3688
- strokeLinecap: "round",
3689
- strokeLinejoin: "round"
3690
- }
3691
- ),
3692
- /* @__PURE__ */ jsx24(
3693
- "path",
3694
- {
3695
- d: "M4.66663 8.75879V8.76754",
3696
- stroke: "currentColor",
3697
- strokeWidth: "1.16667",
3698
- strokeLinecap: "round",
3699
- strokeLinejoin: "round"
3700
- }
3701
- ),
3702
- /* @__PURE__ */ jsx24(
3703
- "path",
3704
- {
3705
- d: "M9.33337 9.34204V9.35079",
3706
- stroke: "currentColor",
3707
- strokeWidth: "1.16667",
3708
- strokeLinecap: "round",
3709
- strokeLinejoin: "round"
3710
- }
3711
- ),
3712
- /* @__PURE__ */ jsx24(
3713
- "path",
3714
- {
3715
- d: "M4.66663 4.10083V4.10958",
3716
- stroke: "currentColor",
3717
- strokeWidth: "1.16667",
3718
- strokeLinecap: "round",
3719
- strokeLinejoin: "round"
3720
- }
3721
- ),
3722
- /* @__PURE__ */ jsx24(
3723
- "path",
3724
- {
3725
- d: "M7 6.43408V6.44283",
3726
- stroke: "currentColor",
3727
- strokeWidth: "1.16667",
3728
- strokeLinecap: "round",
3729
- strokeLinejoin: "round"
3730
- }
3731
- ),
3732
- /* @__PURE__ */ jsx24(
3733
- "path",
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(
4453
+ "input",
3734
4454
  {
3735
- d: "M11.0834 6.43408V6.44283",
3736
- stroke: "currentColor",
3737
- strokeWidth: "1.16667",
3738
- strokeLinecap: "round",
3739
- strokeLinejoin: "round"
4455
+ type: "text",
4456
+ className: "min-w-32 border-0 px-3 py-1.5 focus:ring-0",
4457
+ value: config.suffix || "",
4458
+ placeholder: "e.g., %, USD, tokens",
4459
+ onChange: (e) => onSuffixChange(e.target.value)
3740
4460
  }
3741
4461
  )
3742
- ] }),
3743
- /* @__PURE__ */ jsx24("defs", { children: /* @__PURE__ */ jsx24("clipPath", { id: "clip0_28248_7302", children: /* @__PURE__ */ jsx24("rect", { width: "14", height: "14", fill: "white" }) }) })
3744
- ]
3745
- }
3746
- );
3747
- var ScatterIcon_default = SvgIcon7;
4462
+ ] })
4463
+ ] }) }),
4464
+ config.valueFormatter == "StringFormatter" && /* @__PURE__ */ jsx28(
4465
+ ValueStringMapping,
4466
+ {
4467
+ rules: config.mappingRules || [],
4468
+ onChange: onMappingRulesChange
4469
+ }
4470
+ )
4471
+ ] });
4472
+ };
3748
4473
 
3749
- // src/charts/icons/TableIcon.tsx
3750
- import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
3751
- var SvgIcon8 = ({ className }) => /* @__PURE__ */ jsxs20(
3752
- "svg",
3753
- {
3754
- width: "14",
3755
- height: "14",
3756
- viewBox: "0 0 14 14",
3757
- fill: "none",
3758
- xmlns: "http://www.w3.org/2000/svg",
3759
- className,
3760
- children: [
3761
- /* @__PURE__ */ jsxs20("g", { clipPath: "url(#clip0_3670_4416)", children: [
3762
- /* @__PURE__ */ jsx25(
3763
- "path",
3764
- {
3765
- d: "M11.5 2H2.5C1.67157 2 1 2.55964 1 3.25V10.75C1 11.4404 1.67157 12 2.5 12H11.5C12.3284 12 13 11.4404 13 10.75V3.25C13 2.55964 12.3284 2 11.5 2Z",
3766
- stroke: "currentColor",
3767
- strokeWidth: "1.16667",
3768
- strokeLinecap: "round",
3769
- strokeLinejoin: "round"
3770
- }
3771
- ),
3772
- /* @__PURE__ */ jsx25(
3773
- "path",
4474
+ // src/charts/options/ValueControls.tsx
4475
+ import { defaults as defaults3 } from "lodash";
4476
+ import { Checkbox as Checkbox3, DisclosurePanel as DisclosurePanel5 } from "@sentio/ui-core";
4477
+ import { produce as produce10 } from "immer";
4478
+ import { jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
4479
+ var defaultConfig4 = {
4480
+ valueFormatter: "NumberFormatter",
4481
+ showValueLabel: false,
4482
+ maxSignificantDigits: 3,
4483
+ dateFormat: "LLL",
4484
+ mappingRules: [],
4485
+ style: "None",
4486
+ maxFractionDigits: 2
4487
+ };
4488
+ var ValueControls = ({
4489
+ config,
4490
+ defaultOpen,
4491
+ onChange,
4492
+ formatters = ValueFormatters,
4493
+ showPrefix,
4494
+ showSuffix
4495
+ }) => {
4496
+ config = defaults3(config || {}, defaultConfig4);
4497
+ function toggleShowValueLabel(checked) {
4498
+ config && onChange(
4499
+ produce10(config, (draft) => void (draft.showValueLabel = checked))
4500
+ );
4501
+ }
4502
+ function toggleTooltipTotal(checked) {
4503
+ config && onChange(produce10(config, (draft) => void (draft.tooltipTotal = checked)));
4504
+ }
4505
+ return /* @__PURE__ */ jsxs22(
4506
+ DisclosurePanel5,
4507
+ {
4508
+ title: "Value Options",
4509
+ defaultOpen,
4510
+ containerClassName: "w-full bg-default-bg",
4511
+ children: [
4512
+ /* @__PURE__ */ jsx29(
4513
+ ValueOptions,
3774
4514
  {
3775
- d: "M1 5L13 5",
3776
- stroke: "currentColor",
3777
- strokeWidth: "1.16667",
3778
- strokeLinecap: "round",
3779
- strokeLinejoin: "round"
4515
+ onChange,
4516
+ config,
4517
+ formatters,
4518
+ showPrefix,
4519
+ showSuffix
3780
4520
  }
3781
4521
  ),
3782
- /* @__PURE__ */ jsx25(
3783
- "path",
3784
- {
3785
- d: "M6 2L6 12",
3786
- stroke: "currentColor",
3787
- strokeWidth: "1.16667",
3788
- strokeLinecap: "round",
3789
- strokeLinejoin: "round"
3790
- }
3791
- )
3792
- ] }),
3793
- /* @__PURE__ */ jsx25("defs", { children: /* @__PURE__ */ jsx25("clipPath", { id: "clip0_3670_4416", children: /* @__PURE__ */ jsx25("rect", { width: "14", height: "14", fill: "white" }) }) })
3794
- ]
3795
- }
3796
- );
3797
- var TableIcon_default = SvgIcon8;
4522
+ /* @__PURE__ */ jsxs22("div", { className: "mt-2 flex items-center gap-2", children: [
4523
+ /* @__PURE__ */ jsx29(
4524
+ Checkbox3,
4525
+ {
4526
+ checked: config?.showValueLabel,
4527
+ onChange: toggleShowValueLabel,
4528
+ label: "Show value label"
4529
+ }
4530
+ ),
4531
+ /* @__PURE__ */ jsx29(
4532
+ Checkbox3,
4533
+ {
4534
+ checked: config?.tooltipTotal,
4535
+ onChange: toggleTooltipTotal,
4536
+ label: "Show total in tooltip"
4537
+ }
4538
+ )
4539
+ ] })
4540
+ ]
4541
+ }
4542
+ );
4543
+ };
3798
4544
  export {
3799
4545
  AggregateInput,
3800
4546
  AreaIcon_default as AreaIcon,
@@ -3804,6 +4550,8 @@ export {
3804
4550
  BarGuageIcon_default as BarGuageIcon,
3805
4551
  BarIcon_default as BarIcon,
3806
4552
  ChartLegend,
4553
+ ChartTooltip,
4554
+ ChartTypeButtonGroup,
3807
4555
  EventsFunctionCategories,
3808
4556
  EventsFunctionMap,
3809
4557
  FunctionInput,
@@ -3815,12 +4563,14 @@ export {
3815
4563
  LabelsInput,
3816
4564
  LineControls,
3817
4565
  LineIcon_default as LineIcon,
4566
+ PieChart2 as PieChart,
3818
4567
  PieChartControls,
3819
4568
  PieIcon_default as PieIcon,
3820
4569
  QueryValueIcon_default as QueryValueIcon,
3821
4570
  ReactEChartsBase,
3822
4571
  RefreshButton,
3823
4572
  RefreshContext,
4573
+ ScatterChartTooltip,
3824
4574
  ScatterIcon_default as ScatterIcon,
3825
4575
  SystemLabels,
3826
4576
  TableIcon_default as TableIcon,