@sentio/ui-dashboard 0.3.4 → 0.3.5
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 +109 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +92 -55
- package/dist/index.d.ts +92 -55
- package/dist/index.js +349 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +342 -1
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5915,7 +5915,7 @@ function ValueStringMapping({ rules, onChange }) {
|
|
|
5915
5915
|
{
|
|
5916
5916
|
type: "button",
|
|
5917
5917
|
role: "secondary",
|
|
5918
|
-
className: "w-fit flex-none
|
|
5918
|
+
className: "py-1.5! w-fit flex-none",
|
|
5919
5919
|
"aria-label": "remove",
|
|
5920
5920
|
onClick: addRule,
|
|
5921
5921
|
icon: /* @__PURE__ */ jsx33(LuPlus, {}),
|
|
@@ -6787,6 +6787,340 @@ function TableControls({ config, defaultOpen, onChange, data }) {
|
|
|
6787
6787
|
}
|
|
6788
6788
|
);
|
|
6789
6789
|
}
|
|
6790
|
+
|
|
6791
|
+
// src/dashboard/EditDashboardDialog.tsx
|
|
6792
|
+
import { useState as useState11, useRef as useRef5, useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo12 } from "react";
|
|
6793
|
+
import { BaseDialog } from "@sentio/ui-core";
|
|
6794
|
+
import { jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6795
|
+
var EditDashboardDialog = ({
|
|
6796
|
+
dashboard,
|
|
6797
|
+
open,
|
|
6798
|
+
onClose,
|
|
6799
|
+
onUpdate
|
|
6800
|
+
}) => {
|
|
6801
|
+
const [processing, setProcessing] = useState11(false);
|
|
6802
|
+
const [updateDisabled, setUpdateDisabled] = useState11(true);
|
|
6803
|
+
const inputElementRef = useRef5(null);
|
|
6804
|
+
const onCloseAndReset = useCallback6(() => {
|
|
6805
|
+
onClose?.();
|
|
6806
|
+
if (dashboard?.name && inputElementRef.current) {
|
|
6807
|
+
inputElementRef.current.value = dashboard.name;
|
|
6808
|
+
}
|
|
6809
|
+
}, [onClose, dashboard?.name]);
|
|
6810
|
+
const onOk = useCallback6(() => {
|
|
6811
|
+
if (!inputElementRef.current?.value) {
|
|
6812
|
+
return;
|
|
6813
|
+
}
|
|
6814
|
+
setProcessing(true);
|
|
6815
|
+
onUpdate({ ...dashboard, name: inputElementRef.current?.value }).then(() => {
|
|
6816
|
+
onCloseAndReset();
|
|
6817
|
+
}).finally(() => {
|
|
6818
|
+
setProcessing(false);
|
|
6819
|
+
});
|
|
6820
|
+
}, [onCloseAndReset, onUpdate, dashboard]);
|
|
6821
|
+
useEffect10(() => {
|
|
6822
|
+
if (open && dashboard?.name && inputElementRef.current) {
|
|
6823
|
+
inputElementRef.current.value = dashboard.name;
|
|
6824
|
+
}
|
|
6825
|
+
}, [open, dashboard?.name]);
|
|
6826
|
+
const onInputChange = useCallback6(
|
|
6827
|
+
(evt) => {
|
|
6828
|
+
const value = evt.target.value;
|
|
6829
|
+
if (!value || value === dashboard?.name) {
|
|
6830
|
+
setUpdateDisabled(true);
|
|
6831
|
+
} else {
|
|
6832
|
+
setUpdateDisabled(false);
|
|
6833
|
+
}
|
|
6834
|
+
},
|
|
6835
|
+
[dashboard?.name]
|
|
6836
|
+
);
|
|
6837
|
+
const okProps = useMemo12(
|
|
6838
|
+
() => ({
|
|
6839
|
+
processing,
|
|
6840
|
+
disabled: updateDisabled
|
|
6841
|
+
}),
|
|
6842
|
+
[updateDisabled, processing]
|
|
6843
|
+
);
|
|
6844
|
+
return /* @__PURE__ */ jsx40(
|
|
6845
|
+
BaseDialog,
|
|
6846
|
+
{
|
|
6847
|
+
title: "Edit Dashboard",
|
|
6848
|
+
open,
|
|
6849
|
+
onClose: onCloseAndReset,
|
|
6850
|
+
cancelText: "Close",
|
|
6851
|
+
onCancel: onCloseAndReset,
|
|
6852
|
+
onOk,
|
|
6853
|
+
okProps,
|
|
6854
|
+
okText: "Update",
|
|
6855
|
+
footerBorder: false,
|
|
6856
|
+
initialFocus: inputElementRef,
|
|
6857
|
+
children: /* @__PURE__ */ jsx40(
|
|
6858
|
+
"form",
|
|
6859
|
+
{
|
|
6860
|
+
method: "dialog",
|
|
6861
|
+
className: "text-text-foreground relative mb-4 mt-2 px-4",
|
|
6862
|
+
onSubmit: onOk,
|
|
6863
|
+
children: /* @__PURE__ */ jsxs30("div", { className: "grid py-2 text-sm", children: [
|
|
6864
|
+
/* @__PURE__ */ jsx40("div", { className: "sm:text-ilabel text-text-foreground-secondary mb-2 mt-1", children: "Dashboard Name" }),
|
|
6865
|
+
/* @__PURE__ */ jsx40(
|
|
6866
|
+
"input",
|
|
6867
|
+
{
|
|
6868
|
+
defaultValue: dashboard?.name,
|
|
6869
|
+
placeholder: "Provide a new name for your dashboard",
|
|
6870
|
+
type: "text",
|
|
6871
|
+
required: true,
|
|
6872
|
+
name: "dashboard-name",
|
|
6873
|
+
id: "new-dashboard-name",
|
|
6874
|
+
className: "focus:border-primary-600 focus:ring-primary-600/30 focus:ring-3 hover:border-primary-600 sm:text-ilabel border-main block w-full rounded-md",
|
|
6875
|
+
ref: inputElementRef,
|
|
6876
|
+
onChange: onInputChange
|
|
6877
|
+
}
|
|
6878
|
+
)
|
|
6879
|
+
] })
|
|
6880
|
+
}
|
|
6881
|
+
)
|
|
6882
|
+
}
|
|
6883
|
+
);
|
|
6884
|
+
};
|
|
6885
|
+
|
|
6886
|
+
// src/dashboard/EditGroupDialog.tsx
|
|
6887
|
+
import { useEffect as useEffect11, useMemo as useMemo13, useRef as useRef6, useState as useState12 } from "react";
|
|
6888
|
+
import { BaseDialog as BaseDialog2, Select as Select2, classNames as classNames12 } from "@sentio/ui-core";
|
|
6889
|
+
import { LuCheck as LuCheck2 } from "react-icons/lu";
|
|
6890
|
+
|
|
6891
|
+
// src/dashboard/group-styles.ts
|
|
6892
|
+
var CLASSIC_INDEX = {
|
|
6893
|
+
blue: 0,
|
|
6894
|
+
cyan: 1,
|
|
6895
|
+
pink: 2,
|
|
6896
|
+
yellow: 3,
|
|
6897
|
+
green: 4,
|
|
6898
|
+
lightblue: 5,
|
|
6899
|
+
purple: 6,
|
|
6900
|
+
red: 7,
|
|
6901
|
+
orange: 8
|
|
6902
|
+
};
|
|
6903
|
+
var HIGHLIGHT_COLORS = [
|
|
6904
|
+
{ key: "green", name: "Sentio Green" },
|
|
6905
|
+
{ key: "blue", name: "Sentio Blue" },
|
|
6906
|
+
{ key: "cyan", name: "Sentio Cyan" },
|
|
6907
|
+
{ key: "lightblue", name: "Sentio Light Blue" },
|
|
6908
|
+
{ key: "purple", name: "Sentio Purple" },
|
|
6909
|
+
{ key: "pink", name: "Sentio Pink" },
|
|
6910
|
+
{ key: "red", name: "Sentio Red" },
|
|
6911
|
+
{ key: "orange", name: "Sentio Orange" },
|
|
6912
|
+
{ key: "yellow", name: "Sentio Yellow" }
|
|
6913
|
+
];
|
|
6914
|
+
var DEFAULT_HIGHLIGHT_KEY = "green";
|
|
6915
|
+
function getHighlightHex(key, isDark) {
|
|
6916
|
+
if (!key) return void 0;
|
|
6917
|
+
const idx = CLASSIC_INDEX[key];
|
|
6918
|
+
if (idx === void 0) return void 0;
|
|
6919
|
+
return sentioColors[isDark ? "dark" : "light"].classic[idx];
|
|
6920
|
+
}
|
|
6921
|
+
function readableForeground(hex) {
|
|
6922
|
+
const m = hex.replace("#", "");
|
|
6923
|
+
const r = parseInt(m.slice(0, 2), 16) / 255;
|
|
6924
|
+
const g = parseInt(m.slice(2, 4), 16) / 255;
|
|
6925
|
+
const b = parseInt(m.slice(4, 6), 16) / 255;
|
|
6926
|
+
const lin = (v) => v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
6927
|
+
const L = 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
|
|
6928
|
+
return L > 0.5 ? "#1f2937" : "#ffffff";
|
|
6929
|
+
}
|
|
6930
|
+
function resolveHighlight(colorKey, isDark) {
|
|
6931
|
+
const hex = getHighlightHex(colorKey, isDark) ?? getHighlightHex(DEFAULT_HIGHLIGHT_KEY, isDark);
|
|
6932
|
+
return { solid: hex, foreground: readableForeground(hex) };
|
|
6933
|
+
}
|
|
6934
|
+
function resolveHeaderStyle(style, colorKey, isDark) {
|
|
6935
|
+
if (!style || style === "DEFAULT") return {};
|
|
6936
|
+
const color = resolveHighlight(colorKey, isDark);
|
|
6937
|
+
return { backgroundColor: color.solid, color: color.foreground };
|
|
6938
|
+
}
|
|
6939
|
+
|
|
6940
|
+
// src/dashboard/EditGroupDialog.tsx
|
|
6941
|
+
import { Fragment as Fragment10, jsx as jsx41, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
6942
|
+
function StyleCard({ selected, label, onClick, preview }) {
|
|
6943
|
+
return /* @__PURE__ */ jsxs31(
|
|
6944
|
+
"button",
|
|
6945
|
+
{
|
|
6946
|
+
type: "button",
|
|
6947
|
+
onClick,
|
|
6948
|
+
className: classNames12(
|
|
6949
|
+
"flex flex-col items-stretch overflow-hidden rounded-lg border bg-white text-left transition-colors",
|
|
6950
|
+
"dark:bg-default-bg",
|
|
6951
|
+
selected ? "border-primary-600 ring-primary-600/30 ring-3 shadow-sm" : "border-main hover:border-primary-400"
|
|
6952
|
+
),
|
|
6953
|
+
children: [
|
|
6954
|
+
/* @__PURE__ */ jsx41("div", { className: "bg-hover/40 flex h-28 items-center justify-center", children: preview }),
|
|
6955
|
+
/* @__PURE__ */ jsxs31(
|
|
6956
|
+
"div",
|
|
6957
|
+
{
|
|
6958
|
+
className: classNames12(
|
|
6959
|
+
"border-main flex items-center justify-center gap-1.5 border-t px-2 py-2 text-sm",
|
|
6960
|
+
selected ? "text-primary-600 font-semibold" : "text-text-foreground font-medium"
|
|
6961
|
+
),
|
|
6962
|
+
children: [
|
|
6963
|
+
selected && /* @__PURE__ */ jsx41(LuCheck2, { className: "h-3.5 w-3.5" }),
|
|
6964
|
+
label
|
|
6965
|
+
]
|
|
6966
|
+
}
|
|
6967
|
+
)
|
|
6968
|
+
]
|
|
6969
|
+
}
|
|
6970
|
+
);
|
|
6971
|
+
}
|
|
6972
|
+
function DefaultPreview() {
|
|
6973
|
+
return /* @__PURE__ */ jsx41("div", { className: "border-main bg-default-bg text-text-foreground flex h-16 w-32 items-center rounded border px-2 text-base", children: "Title" });
|
|
6974
|
+
}
|
|
6975
|
+
function EmphasisPreview({
|
|
6976
|
+
color
|
|
6977
|
+
}) {
|
|
6978
|
+
return /* @__PURE__ */ jsxs31("div", { className: "border-main bg-default-bg flex h-16 w-32 flex-col rounded border", children: [
|
|
6979
|
+
/* @__PURE__ */ jsx41(
|
|
6980
|
+
"div",
|
|
6981
|
+
{
|
|
6982
|
+
className: "flex h-9 items-center justify-center text-sm font-semibold",
|
|
6983
|
+
style: { backgroundColor: color.solid, color: color.foreground },
|
|
6984
|
+
children: "Title"
|
|
6985
|
+
}
|
|
6986
|
+
),
|
|
6987
|
+
/* @__PURE__ */ jsx41("div", { className: "flex-1" })
|
|
6988
|
+
] });
|
|
6989
|
+
}
|
|
6990
|
+
function EditGroupDialog({
|
|
6991
|
+
open,
|
|
6992
|
+
onClose,
|
|
6993
|
+
title,
|
|
6994
|
+
style,
|
|
6995
|
+
highlightColor,
|
|
6996
|
+
onSave
|
|
6997
|
+
}) {
|
|
6998
|
+
const [draftTitle, setDraftTitle] = useState12(title);
|
|
6999
|
+
const [draftStyle, setDraftStyle] = useState12(style);
|
|
7000
|
+
const [draftColor, setDraftColor] = useState12(highlightColor);
|
|
7001
|
+
const titleRef = useRef6(null);
|
|
7002
|
+
const isDark = useDarkMode();
|
|
7003
|
+
useEffect11(() => {
|
|
7004
|
+
if (!open) return;
|
|
7005
|
+
setDraftTitle(title);
|
|
7006
|
+
setDraftStyle(style || "DEFAULT");
|
|
7007
|
+
setDraftColor(
|
|
7008
|
+
highlightColor || (style && style !== "DEFAULT" ? DEFAULT_HIGHLIGHT_KEY : "")
|
|
7009
|
+
);
|
|
7010
|
+
}, [open, title, style, highlightColor]);
|
|
7011
|
+
const previewColor = useMemo13(
|
|
7012
|
+
() => resolveHighlight(draftColor, isDark),
|
|
7013
|
+
[draftColor, isDark]
|
|
7014
|
+
);
|
|
7015
|
+
const onPickStyle = (next) => {
|
|
7016
|
+
setDraftStyle(next);
|
|
7017
|
+
if (next !== "DEFAULT" && !draftColor) {
|
|
7018
|
+
setDraftColor(DEFAULT_HIGHLIGHT_KEY);
|
|
7019
|
+
}
|
|
7020
|
+
};
|
|
7021
|
+
const onOk = () => {
|
|
7022
|
+
onSave({
|
|
7023
|
+
title: draftTitle.trim() || "Group",
|
|
7024
|
+
style: draftStyle,
|
|
7025
|
+
// Persist '' for DEFAULT so we don't pollute the model with an unused
|
|
7026
|
+
// color when the user reverts.
|
|
7027
|
+
highlightColor: draftStyle === "DEFAULT" ? "" : draftColor || DEFAULT_HIGHLIGHT_KEY
|
|
7028
|
+
});
|
|
7029
|
+
onClose();
|
|
7030
|
+
};
|
|
7031
|
+
const colorOptions = useMemo13(
|
|
7032
|
+
() => HIGHLIGHT_COLORS.map((c) => {
|
|
7033
|
+
const resolved = resolveHighlight(c.key, isDark);
|
|
7034
|
+
return {
|
|
7035
|
+
value: c.key,
|
|
7036
|
+
title: c.name,
|
|
7037
|
+
label: ({ selected }) => /* @__PURE__ */ jsxs31("div", { className: "flex w-full items-center gap-2.5 pr-2", children: [
|
|
7038
|
+
/* @__PURE__ */ jsx41(
|
|
7039
|
+
"div",
|
|
7040
|
+
{
|
|
7041
|
+
className: "flex h-5 w-5 items-center justify-center rounded text-xs font-bold",
|
|
7042
|
+
style: {
|
|
7043
|
+
backgroundColor: resolved.solid,
|
|
7044
|
+
color: resolved.foreground
|
|
7045
|
+
},
|
|
7046
|
+
children: "T"
|
|
7047
|
+
}
|
|
7048
|
+
),
|
|
7049
|
+
/* @__PURE__ */ jsx41("span", { className: "flex-1 text-sm", children: c.name }),
|
|
7050
|
+
selected && /* @__PURE__ */ jsx41(LuCheck2, { className: "text-primary-600 h-4 w-4" })
|
|
7051
|
+
] })
|
|
7052
|
+
};
|
|
7053
|
+
}),
|
|
7054
|
+
[isDark]
|
|
7055
|
+
);
|
|
7056
|
+
return /* @__PURE__ */ jsx41(
|
|
7057
|
+
BaseDialog2,
|
|
7058
|
+
{
|
|
7059
|
+
title: "Edit Group",
|
|
7060
|
+
open,
|
|
7061
|
+
onClose,
|
|
7062
|
+
cancelText: "Cancel",
|
|
7063
|
+
onCancel: onClose,
|
|
7064
|
+
onOk,
|
|
7065
|
+
okText: "Save",
|
|
7066
|
+
panelClassName: "sm:max-w-xl",
|
|
7067
|
+
initialFocus: titleRef,
|
|
7068
|
+
children: /* @__PURE__ */ jsxs31("div", { className: "text-text-foreground px-4 pb-2 pt-4", children: [
|
|
7069
|
+
/* @__PURE__ */ jsx41("h4", { className: "text-text-foreground mb-3 text-sm font-semibold", children: "Display options" }),
|
|
7070
|
+
/* @__PURE__ */ jsx41("label", { className: "text-text-foreground-secondary text-ilabel mb-1 block", children: "Title" }),
|
|
7071
|
+
/* @__PURE__ */ jsx41(
|
|
7072
|
+
"input",
|
|
7073
|
+
{
|
|
7074
|
+
ref: titleRef,
|
|
7075
|
+
type: "text",
|
|
7076
|
+
value: draftTitle,
|
|
7077
|
+
onChange: (e) => setDraftTitle(e.target.value),
|
|
7078
|
+
onKeyDown: (e) => {
|
|
7079
|
+
if (e.key === "Enter") {
|
|
7080
|
+
e.preventDefault();
|
|
7081
|
+
onOk();
|
|
7082
|
+
}
|
|
7083
|
+
},
|
|
7084
|
+
className: "focus:border-primary-600 focus:ring-primary-600/30 focus:ring-3 hover:border-primary-600 sm:text-ilabel border-main mb-4 block w-full rounded-md"
|
|
7085
|
+
}
|
|
7086
|
+
),
|
|
7087
|
+
/* @__PURE__ */ jsxs31("div", { className: "mb-4 grid grid-cols-2 gap-3", children: [
|
|
7088
|
+
/* @__PURE__ */ jsx41(
|
|
7089
|
+
StyleCard,
|
|
7090
|
+
{
|
|
7091
|
+
selected: draftStyle === "DEFAULT",
|
|
7092
|
+
label: "Default",
|
|
7093
|
+
onClick: () => onPickStyle("DEFAULT"),
|
|
7094
|
+
preview: /* @__PURE__ */ jsx41(DefaultPreview, {})
|
|
7095
|
+
}
|
|
7096
|
+
),
|
|
7097
|
+
/* @__PURE__ */ jsx41(
|
|
7098
|
+
StyleCard,
|
|
7099
|
+
{
|
|
7100
|
+
selected: draftStyle === "EMPHASIS",
|
|
7101
|
+
label: "Emphasis",
|
|
7102
|
+
onClick: () => onPickStyle("EMPHASIS"),
|
|
7103
|
+
preview: /* @__PURE__ */ jsx41(EmphasisPreview, { color: previewColor })
|
|
7104
|
+
}
|
|
7105
|
+
)
|
|
7106
|
+
] }),
|
|
7107
|
+
draftStyle !== "DEFAULT" && /* @__PURE__ */ jsxs31(Fragment10, { children: [
|
|
7108
|
+
/* @__PURE__ */ jsx41("label", { className: "text-text-foreground-secondary text-ilabel mb-1 block", children: "Highlight Color" }),
|
|
7109
|
+
/* @__PURE__ */ jsx41(
|
|
7110
|
+
Select2,
|
|
7111
|
+
{
|
|
7112
|
+
value: draftColor || DEFAULT_HIGHLIGHT_KEY,
|
|
7113
|
+
onChange: (v) => setDraftColor(v),
|
|
7114
|
+
options: colorOptions,
|
|
7115
|
+
size: "md",
|
|
7116
|
+
asLayer: true
|
|
7117
|
+
}
|
|
7118
|
+
)
|
|
7119
|
+
] })
|
|
7120
|
+
] })
|
|
7121
|
+
}
|
|
7122
|
+
);
|
|
7123
|
+
}
|
|
6790
7124
|
export {
|
|
6791
7125
|
AggregateInput,
|
|
6792
7126
|
AreaIcon_default as AreaIcon,
|
|
@@ -6799,13 +7133,17 @@ export {
|
|
|
6799
7133
|
ChartLegend,
|
|
6800
7134
|
ChartTooltip,
|
|
6801
7135
|
ChartTypeButtonGroup,
|
|
7136
|
+
DEFAULT_HIGHLIGHT_KEY,
|
|
6802
7137
|
DataControls,
|
|
7138
|
+
EditDashboardDialog,
|
|
7139
|
+
EditGroupDialog,
|
|
6803
7140
|
EventsFunctionCategories,
|
|
6804
7141
|
EventsFunctionMap,
|
|
6805
7142
|
FunctionInput,
|
|
6806
7143
|
FunctionMap,
|
|
6807
7144
|
FunctionsCategories,
|
|
6808
7145
|
FunctionsPanel,
|
|
7146
|
+
HIGHLIGHT_COLORS,
|
|
6809
7147
|
LabelControls,
|
|
6810
7148
|
LabelSearchProvider,
|
|
6811
7149
|
LabelsInput,
|
|
@@ -6841,7 +7179,10 @@ export {
|
|
|
6841
7179
|
defaultConfig3 as defaultValueConfig,
|
|
6842
7180
|
defaultConfig4 as defaultValueControlsConfig,
|
|
6843
7181
|
getDefaultValueConfig,
|
|
7182
|
+
getHighlightHex,
|
|
6844
7183
|
isAggrOrRollupFunction,
|
|
7184
|
+
resolveHeaderStyle,
|
|
7185
|
+
resolveHighlight,
|
|
6845
7186
|
sentioColors,
|
|
6846
7187
|
sentioTheme,
|
|
6847
7188
|
sentioThemeDark,
|