@sentio/ui-dashboard 0.3.0 → 0.3.4
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.css +14 -18
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +89 -49
- package/dist/index.d.ts +89 -49
- package/dist/index.js +235 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -20
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -5260,7 +5260,6 @@ var TimeSeriesChart = forwardRef5(
|
|
|
5260
5260
|
}
|
|
5261
5261
|
return _noLegend;
|
|
5262
5262
|
}, [_noLegend, chartType, series?.length]);
|
|
5263
|
-
console.log("options", options);
|
|
5264
5263
|
return /* @__PURE__ */ jsxs18(
|
|
5265
5264
|
"div",
|
|
5266
5265
|
{
|
|
@@ -5802,7 +5801,7 @@ var operators = {
|
|
|
5802
5801
|
"<=": "less or equal"
|
|
5803
5802
|
};
|
|
5804
5803
|
var renderTreeLine = (index, isLast) => {
|
|
5805
|
-
return /* @__PURE__ */ jsx33("div", { className: "mr-2 flex
|
|
5804
|
+
return /* @__PURE__ */ jsx33("div", { className: "mr-2 flex w-3 flex-col items-center justify-center", children: /* @__PURE__ */ jsxs23("div", { className: "flex h-full w-full items-center", children: [
|
|
5806
5805
|
/* @__PURE__ */ jsx33(
|
|
5807
5806
|
"div",
|
|
5808
5807
|
{
|
|
@@ -5843,16 +5842,16 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
5843
5842
|
})
|
|
5844
5843
|
);
|
|
5845
5844
|
}
|
|
5846
|
-
return /* @__PURE__ */ jsxs23("div", { className: "flex w-full flex-col rounded-md
|
|
5845
|
+
return /* @__PURE__ */ jsxs23("div", { className: "flex w-full flex-col gap-2 rounded-md", children: [
|
|
5847
5846
|
(rules || []).map((rule, index) => {
|
|
5848
5847
|
const isLast = index === (rules || []).length - 1;
|
|
5849
5848
|
return /* @__PURE__ */ jsxs23(
|
|
5850
5849
|
"div",
|
|
5851
5850
|
{
|
|
5852
|
-
className: "text-text-foreground flex h-
|
|
5851
|
+
className: "text-text-foreground flex h-8 items-center",
|
|
5853
5852
|
children: [
|
|
5854
5853
|
renderTreeLine(index, isLast),
|
|
5855
|
-
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel
|
|
5854
|
+
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel inline-flex h-full items-center pr-2 font-medium", children: "If value is" }),
|
|
5856
5855
|
/* @__PURE__ */ jsx33(
|
|
5857
5856
|
"select",
|
|
5858
5857
|
{
|
|
@@ -5881,7 +5880,7 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
5881
5880
|
}
|
|
5882
5881
|
}
|
|
5883
5882
|
),
|
|
5884
|
-
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-
|
|
5883
|
+
/* @__PURE__ */ jsx33("span", { className: "sm:text-ilabel inline-flex h-full items-center rounded-none px-2 font-medium", children: ", then show" }),
|
|
5885
5884
|
/* @__PURE__ */ jsx33(
|
|
5886
5885
|
"input",
|
|
5887
5886
|
{
|
|
@@ -5900,16 +5899,10 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
5900
5899
|
"button",
|
|
5901
5900
|
{
|
|
5902
5901
|
type: "button",
|
|
5903
|
-
className: "mx-2",
|
|
5902
|
+
className: "text-text-foreground-disabled hover:text-primary-600 mx-2 cursor-pointer",
|
|
5904
5903
|
"aria-label": "remove",
|
|
5905
5904
|
onClick: () => removeRule(index),
|
|
5906
|
-
children: /* @__PURE__ */ jsx33(
|
|
5907
|
-
LuTrash2,
|
|
5908
|
-
{
|
|
5909
|
-
className: "icon text-text-foreground-disabled",
|
|
5910
|
-
"aria-hidden": "true"
|
|
5911
|
-
}
|
|
5912
|
-
)
|
|
5905
|
+
children: /* @__PURE__ */ jsx33(LuTrash2, { className: "icon", "aria-hidden": "true" })
|
|
5913
5906
|
}
|
|
5914
5907
|
)
|
|
5915
5908
|
]
|
|
@@ -5917,18 +5910,16 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
5917
5910
|
index
|
|
5918
5911
|
);
|
|
5919
5912
|
}),
|
|
5920
|
-
/* @__PURE__ */
|
|
5913
|
+
/* @__PURE__ */ jsx33(
|
|
5921
5914
|
Button3,
|
|
5922
5915
|
{
|
|
5923
5916
|
type: "button",
|
|
5924
5917
|
role: "secondary",
|
|
5925
|
-
className: "
|
|
5918
|
+
className: "w-fit flex-none py-1.5!",
|
|
5926
5919
|
"aria-label": "remove",
|
|
5927
5920
|
onClick: addRule,
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
"Add Formatting Rule"
|
|
5931
|
-
]
|
|
5921
|
+
icon: /* @__PURE__ */ jsx33(LuPlus, {}),
|
|
5922
|
+
children: "Add Formatting Rule"
|
|
5932
5923
|
}
|
|
5933
5924
|
)
|
|
5934
5925
|
] });
|
|
@@ -6578,6 +6569,224 @@ function ScatterControls({
|
|
|
6578
6569
|
}
|
|
6579
6570
|
);
|
|
6580
6571
|
}
|
|
6572
|
+
|
|
6573
|
+
// src/charts/options/TableControls.tsx
|
|
6574
|
+
import { useMemo as useMemo11 } from "react";
|
|
6575
|
+
import { produce as produce14 } from "immer";
|
|
6576
|
+
import { defaults as defaults8 } from "lodash";
|
|
6577
|
+
import { Checkbox as Checkbox5, DisclosurePanel as DisclosurePanel11 } from "@sentio/ui-core";
|
|
6578
|
+
|
|
6579
|
+
// src/charts/table-utils.ts
|
|
6580
|
+
import { startCase } from "lodash";
|
|
6581
|
+
var TEMPLATE_TOKEN = /{{([\s\S]+?)}}/g;
|
|
6582
|
+
function sanitizeLabels(labels) {
|
|
6583
|
+
const result = {};
|
|
6584
|
+
for (const k in labels) {
|
|
6585
|
+
switch (k) {
|
|
6586
|
+
case "contract_name":
|
|
6587
|
+
result["contract"] = labels[k];
|
|
6588
|
+
break;
|
|
6589
|
+
case "contract_address":
|
|
6590
|
+
result["address"] = labels[k];
|
|
6591
|
+
break;
|
|
6592
|
+
}
|
|
6593
|
+
result[k] = labels[k];
|
|
6594
|
+
}
|
|
6595
|
+
return result;
|
|
6596
|
+
}
|
|
6597
|
+
function aliasTemplate(alias, labels) {
|
|
6598
|
+
if (alias) {
|
|
6599
|
+
try {
|
|
6600
|
+
const safe = sanitizeLabels(labels);
|
|
6601
|
+
return alias.replace(TEMPLATE_TOKEN, (_, m1) => {
|
|
6602
|
+
const value = safe[m1.trim()];
|
|
6603
|
+
return value == null ? `` : value;
|
|
6604
|
+
});
|
|
6605
|
+
} catch (e) {
|
|
6606
|
+
return alias;
|
|
6607
|
+
}
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
function escapeColumnId(id) {
|
|
6611
|
+
return id.replace(/[\W_.]+/g, "_");
|
|
6612
|
+
}
|
|
6613
|
+
function getColumnNameId(labels, alias, displayName) {
|
|
6614
|
+
const s = aliasTemplate(alias, labels) || startCase(displayName);
|
|
6615
|
+
return { columnName: s, columnId: escapeColumnId(s) };
|
|
6616
|
+
}
|
|
6617
|
+
|
|
6618
|
+
// src/charts/options/TableControls.tsx
|
|
6619
|
+
import { jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6620
|
+
var defaultConfig7 = {
|
|
6621
|
+
calculation: "LAST",
|
|
6622
|
+
sortColumns: [],
|
|
6623
|
+
showColumns: void 0,
|
|
6624
|
+
columnWidths: {},
|
|
6625
|
+
columnOrders: [],
|
|
6626
|
+
showPlainData: false,
|
|
6627
|
+
calculations: {},
|
|
6628
|
+
valueConfigs: {}
|
|
6629
|
+
};
|
|
6630
|
+
function getDefaultValueConfig(type) {
|
|
6631
|
+
switch (type) {
|
|
6632
|
+
case "NUMBER":
|
|
6633
|
+
return {
|
|
6634
|
+
...defaultConfig4,
|
|
6635
|
+
valueFormatter: "NumberFormatter"
|
|
6636
|
+
};
|
|
6637
|
+
case "TIME":
|
|
6638
|
+
return {
|
|
6639
|
+
...defaultConfig4,
|
|
6640
|
+
valueFormatter: "DateFormatter"
|
|
6641
|
+
};
|
|
6642
|
+
default:
|
|
6643
|
+
return {
|
|
6644
|
+
...defaultConfig4,
|
|
6645
|
+
valueFormatter: "StringFormatter"
|
|
6646
|
+
};
|
|
6647
|
+
}
|
|
6648
|
+
}
|
|
6649
|
+
var CalculationItems3 = [
|
|
6650
|
+
{ label: "All", value: "ALL" },
|
|
6651
|
+
{ label: "Last", value: "LAST" },
|
|
6652
|
+
{ label: "First", value: "FIRST" },
|
|
6653
|
+
{ label: "Total", value: "TOTAL" },
|
|
6654
|
+
{ label: "Mean", value: "MEAN" },
|
|
6655
|
+
{ label: "Max", value: "MAX" },
|
|
6656
|
+
{ label: "Min", value: "MIN" }
|
|
6657
|
+
];
|
|
6658
|
+
function TableControls({ config, defaultOpen, onChange, data }) {
|
|
6659
|
+
config = defaults8({}, config, defaultConfig7);
|
|
6660
|
+
function onCalculationChange(col, cal) {
|
|
6661
|
+
config && onChange(
|
|
6662
|
+
produce14(config, (draft) => {
|
|
6663
|
+
if (col === "") {
|
|
6664
|
+
delete draft.calculations;
|
|
6665
|
+
draft.calculation = cal;
|
|
6666
|
+
} else {
|
|
6667
|
+
draft.calculations = draft.calculations || {};
|
|
6668
|
+
draft.calculations[col] = cal;
|
|
6669
|
+
}
|
|
6670
|
+
})
|
|
6671
|
+
);
|
|
6672
|
+
}
|
|
6673
|
+
function onValueConfigChange(col, valueConfig) {
|
|
6674
|
+
config && onChange(
|
|
6675
|
+
produce14(config, (draft) => {
|
|
6676
|
+
draft.valueConfigs = draft.valueConfigs || {};
|
|
6677
|
+
draft.valueConfigs[col] = valueConfig;
|
|
6678
|
+
})
|
|
6679
|
+
);
|
|
6680
|
+
}
|
|
6681
|
+
function onMapSeriesAsColumnsChange(checked) {
|
|
6682
|
+
config && onChange(produce14(config, (draft) => void (draft.showPlainData = checked)));
|
|
6683
|
+
}
|
|
6684
|
+
const calculations = useMemo11(() => {
|
|
6685
|
+
if (!config?.showPlainData) {
|
|
6686
|
+
return CalculationItems3.filter((item) => item.value !== "ALL");
|
|
6687
|
+
}
|
|
6688
|
+
return CalculationItems3;
|
|
6689
|
+
}, [config?.showPlainData]);
|
|
6690
|
+
const isSql = data?.result !== void 0;
|
|
6691
|
+
const columns = useMemo11(() => {
|
|
6692
|
+
if (config?.showPlainData) {
|
|
6693
|
+
return [];
|
|
6694
|
+
}
|
|
6695
|
+
const map = {};
|
|
6696
|
+
if (isSql) {
|
|
6697
|
+
const results = data?.result;
|
|
6698
|
+
if (results) {
|
|
6699
|
+
for (const [name, type] of Object.entries(results?.columnTypes || {})) {
|
|
6700
|
+
map[name] = {
|
|
6701
|
+
name,
|
|
6702
|
+
type
|
|
6703
|
+
};
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6706
|
+
} else {
|
|
6707
|
+
const results = data?.results;
|
|
6708
|
+
for (const r of results || []) {
|
|
6709
|
+
for (const s of r?.matrix?.samples || []) {
|
|
6710
|
+
const { columnId, columnName } = getColumnNameId(
|
|
6711
|
+
s?.metric?.labels || {},
|
|
6712
|
+
r.alias,
|
|
6713
|
+
s.metric?.displayName
|
|
6714
|
+
);
|
|
6715
|
+
map[columnId] = {
|
|
6716
|
+
name: columnName
|
|
6717
|
+
};
|
|
6718
|
+
}
|
|
6719
|
+
}
|
|
6720
|
+
}
|
|
6721
|
+
return Object.keys(map).sort().map((k) => ({ columnId: k, column: map[k] }));
|
|
6722
|
+
}, [data, config]);
|
|
6723
|
+
return /* @__PURE__ */ jsxs29(
|
|
6724
|
+
DisclosurePanel11,
|
|
6725
|
+
{
|
|
6726
|
+
title: "Table Options",
|
|
6727
|
+
defaultOpen,
|
|
6728
|
+
containerClassName: "w-full bg-default-bg",
|
|
6729
|
+
children: [
|
|
6730
|
+
!isSql && /* @__PURE__ */ jsxs29("div", { className: "min-h-8 flex items-center", children: [
|
|
6731
|
+
/* @__PURE__ */ jsx39("div", { className: "w-48 px-2", children: /* @__PURE__ */ jsx39(
|
|
6732
|
+
Checkbox5,
|
|
6733
|
+
{
|
|
6734
|
+
checked: config?.showPlainData,
|
|
6735
|
+
onChange: onMapSeriesAsColumnsChange,
|
|
6736
|
+
label: "Show plain data"
|
|
6737
|
+
}
|
|
6738
|
+
) }),
|
|
6739
|
+
config?.showPlainData && /* @__PURE__ */ jsxs29("div", { className: "flex", children: [
|
|
6740
|
+
/* @__PURE__ */ jsx39("span", { className: "border-main sm:text-icontent inline-flex items-center rounded-l-md border border-r-0 bg-gray-50 px-3", children: "Calculation" }),
|
|
6741
|
+
/* @__PURE__ */ jsx39(
|
|
6742
|
+
"select",
|
|
6743
|
+
{
|
|
6744
|
+
value: config.calculation,
|
|
6745
|
+
className: "border-main text-text-foreground sm:text-icontent focus:border-primary-600 hover:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7 focus:ring-0",
|
|
6746
|
+
onChange: (e) => {
|
|
6747
|
+
onCalculationChange("", e.target.value);
|
|
6748
|
+
},
|
|
6749
|
+
children: calculations.map((d) => {
|
|
6750
|
+
return /* @__PURE__ */ jsx39("option", { value: d.value, children: d.label }, d.value);
|
|
6751
|
+
})
|
|
6752
|
+
}
|
|
6753
|
+
)
|
|
6754
|
+
] }),
|
|
6755
|
+
/* @__PURE__ */ jsx39("div", {})
|
|
6756
|
+
] }),
|
|
6757
|
+
/* @__PURE__ */ jsx39("div", { className: "divide-border-color flex flex-col gap-2 divide-y", children: columns.map(({ columnId, column }) => /* @__PURE__ */ jsxs29("div", { className: "flex items-start pb-2", children: [
|
|
6758
|
+
/* @__PURE__ */ jsx39("h4", { className: "text-text-foreground text-icontent leading-7.5 w-48 px-2 font-medium", children: column.name }),
|
|
6759
|
+
/* @__PURE__ */ jsxs29("div", { className: "flex flex-1 flex-wrap items-start gap-2 rounded-md", children: [
|
|
6760
|
+
!isSql && /* @__PURE__ */ jsxs29("div", { className: "flex", children: [
|
|
6761
|
+
/* @__PURE__ */ jsx39("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" }),
|
|
6762
|
+
/* @__PURE__ */ jsx39(
|
|
6763
|
+
"select",
|
|
6764
|
+
{
|
|
6765
|
+
value: config?.calculations && config?.calculations[columnId] || "LAST",
|
|
6766
|
+
className: "border-main text-text-foreground sm:text-icontent focus:border-primary-600 hover:border-primary-600 inline-flex items-center rounded-r-md border pl-4 pr-7 focus:ring-0",
|
|
6767
|
+
onChange: (e) => onCalculationChange(
|
|
6768
|
+
columnId,
|
|
6769
|
+
e.target.value
|
|
6770
|
+
),
|
|
6771
|
+
children: calculations.map((d) => {
|
|
6772
|
+
return /* @__PURE__ */ jsx39("option", { value: d.value, children: d.label }, d.value);
|
|
6773
|
+
})
|
|
6774
|
+
}
|
|
6775
|
+
)
|
|
6776
|
+
] }),
|
|
6777
|
+
/* @__PURE__ */ jsx39(
|
|
6778
|
+
ValueOptions,
|
|
6779
|
+
{
|
|
6780
|
+
onChange: (cfg) => onValueConfigChange(columnId, cfg),
|
|
6781
|
+
config: config?.valueConfigs && config.valueConfigs[columnId] || getDefaultValueConfig(column.type)
|
|
6782
|
+
}
|
|
6783
|
+
)
|
|
6784
|
+
] })
|
|
6785
|
+
] }, columnId)) })
|
|
6786
|
+
]
|
|
6787
|
+
}
|
|
6788
|
+
);
|
|
6789
|
+
}
|
|
6581
6790
|
export {
|
|
6582
6791
|
AggregateInput,
|
|
6583
6792
|
AreaIcon_default as AreaIcon,
|
|
@@ -6615,6 +6824,7 @@ export {
|
|
|
6615
6824
|
ScatterControls,
|
|
6616
6825
|
ScatterIcon_default as ScatterIcon,
|
|
6617
6826
|
SystemLabels,
|
|
6827
|
+
TableControls,
|
|
6618
6828
|
TableIcon_default as TableIcon,
|
|
6619
6829
|
TimeSeriesChart,
|
|
6620
6830
|
ValueControls,
|
|
@@ -6627,8 +6837,10 @@ export {
|
|
|
6627
6837
|
defaultConfig5 as defaultDataConfig,
|
|
6628
6838
|
defaultConfig as defaultPieConfig,
|
|
6629
6839
|
defaultConfig6 as defaultScatterConfig,
|
|
6840
|
+
defaultConfig7 as defaultTableConfig,
|
|
6630
6841
|
defaultConfig3 as defaultValueConfig,
|
|
6631
6842
|
defaultConfig4 as defaultValueControlsConfig,
|
|
6843
|
+
getDefaultValueConfig,
|
|
6632
6844
|
isAggrOrRollupFunction,
|
|
6633
6845
|
sentioColors,
|
|
6634
6846
|
sentioTheme,
|