react-open-source-grid 1.6.6 → 1.7.0
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/assets/{index-CQcTDWao.css → index-90D-dENa.css} +1 -1
- package/dist/assets/{index-DgcHJP8T.js → index-Ds2EPIvF.js} +206 -91
- package/dist/assets/index.js +1 -1
- package/dist/assets/{layoutPersistence-BOTIXT8B.js → layoutPersistence-CTemzqZG.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/lib/charts/ChartOverlay.d.ts +20 -0
- package/dist/lib/charts/QuickChart.d.ts +22 -0
- package/dist/lib/charts/index.d.ts +12 -0
- package/dist/lib/charts/rangeToChart.d.ts +23 -0
- package/dist/lib/charts/types.d.ts +63 -0
- package/dist/lib/components/ChartsDemo.d.ts +9 -0
- package/dist/lib/index.cjs +496 -0
- package/dist/lib/index.css +215 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +506 -0
- package/package.json +5 -3
package/dist/lib/index.cjs
CHANGED
|
@@ -337,6 +337,7 @@ __export(index_exports, {
|
|
|
337
337
|
AdvancedFilterBuilder: () => AdvancedFilterBuilder,
|
|
338
338
|
BadgeCell: () => BadgeCell,
|
|
339
339
|
ButtonCell: () => ButtonCell,
|
|
340
|
+
ChartOverlay: () => ChartOverlay,
|
|
340
341
|
ColumnChooser: () => ColumnChooser,
|
|
341
342
|
ColumnFilters: () => ColumnFilters,
|
|
342
343
|
CurrencyCell: () => CurrencyCell,
|
|
@@ -362,6 +363,7 @@ __export(index_exports, {
|
|
|
362
363
|
PivotToolbar: () => PivotToolbar,
|
|
363
364
|
PriorityIndicator: () => PriorityIndicator,
|
|
364
365
|
ProgressBar: () => ProgressBar,
|
|
366
|
+
QuickChart: () => QuickChart,
|
|
365
367
|
Rating: () => Rating,
|
|
366
368
|
RichSelectEditor: () => RichSelectEditor,
|
|
367
369
|
ServerAdapter: () => ServerAdapter,
|
|
@@ -373,6 +375,7 @@ __export(index_exports, {
|
|
|
373
375
|
VirtualScroller: () => VirtualScroller,
|
|
374
376
|
WebSocketMockFeed: () => WebSocketMockFeed,
|
|
375
377
|
alpineTheme: () => alpineTheme,
|
|
378
|
+
buildChartConfigFromRange: () => buildChartConfigFromRange,
|
|
376
379
|
buildPivot: () => buildPivot,
|
|
377
380
|
buildTreeFromFlat: () => buildTreeFromFlat,
|
|
378
381
|
collapseAllNodes: () => collapseAllNodes,
|
|
@@ -411,11 +414,14 @@ __export(index_exports, {
|
|
|
411
414
|
isTreeNode: () => isTreeNode,
|
|
412
415
|
loadDensityMode: () => loadDensityMode,
|
|
413
416
|
materialTheme: () => materialTheme,
|
|
417
|
+
normalizeRange: () => normalizeRange,
|
|
414
418
|
parseFormattedNumber: () => parseFormattedNumber,
|
|
415
419
|
quartzTheme: () => quartzTheme,
|
|
416
420
|
saveDensityMode: () => saveDensityMode,
|
|
417
421
|
themes: () => themes,
|
|
418
422
|
toggleNodeExpansion: () => toggleNodeExpansion,
|
|
423
|
+
updateChartTheme: () => updateChartTheme,
|
|
424
|
+
updateChartType: () => updateChartType,
|
|
419
425
|
useDensityMode: () => useDensityMode,
|
|
420
426
|
useEditorAutoFocus: () => useEditorAutoFocus,
|
|
421
427
|
useEditorClickOutside: () => useEditorClickOutside,
|
|
@@ -13937,11 +13943,496 @@ function renderMarkdownPreview(markdown) {
|
|
|
13937
13943
|
}
|
|
13938
13944
|
return html;
|
|
13939
13945
|
}
|
|
13946
|
+
|
|
13947
|
+
// src/charts/rangeToChart.ts
|
|
13948
|
+
function normalizeRange(range) {
|
|
13949
|
+
const startRow = Math.min(range.start.rowIndex, range.end.rowIndex);
|
|
13950
|
+
const endRow = Math.max(range.start.rowIndex, range.end.rowIndex);
|
|
13951
|
+
const startCol = Math.min(range.start.colIndex, range.end.colIndex);
|
|
13952
|
+
const endCol = Math.max(range.start.colIndex, range.end.colIndex);
|
|
13953
|
+
return { startRow, endRow, startCol, endCol };
|
|
13954
|
+
}
|
|
13955
|
+
function isNumeric(value) {
|
|
13956
|
+
if (value === null || value === void 0 || value === "") {
|
|
13957
|
+
return false;
|
|
13958
|
+
}
|
|
13959
|
+
const num = Number(value);
|
|
13960
|
+
return !isNaN(num) && isFinite(num);
|
|
13961
|
+
}
|
|
13962
|
+
function toNumber2(value) {
|
|
13963
|
+
if (isNumeric(value)) {
|
|
13964
|
+
return Number(value);
|
|
13965
|
+
}
|
|
13966
|
+
return 0;
|
|
13967
|
+
}
|
|
13968
|
+
function generateChartId() {
|
|
13969
|
+
return `chart-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
13970
|
+
}
|
|
13971
|
+
var DEFAULT_COLORS = [
|
|
13972
|
+
"#8884d8",
|
|
13973
|
+
// blue
|
|
13974
|
+
"#82ca9d",
|
|
13975
|
+
// green
|
|
13976
|
+
"#ffc658",
|
|
13977
|
+
// yellow
|
|
13978
|
+
"#ff7c7c",
|
|
13979
|
+
// red
|
|
13980
|
+
"#a28fd0",
|
|
13981
|
+
// purple
|
|
13982
|
+
"#ff9f40",
|
|
13983
|
+
// orange
|
|
13984
|
+
"#4bc0c0",
|
|
13985
|
+
// teal
|
|
13986
|
+
"#ff6384"
|
|
13987
|
+
// pink
|
|
13988
|
+
];
|
|
13989
|
+
function buildChartConfigFromRange(options) {
|
|
13990
|
+
const {
|
|
13991
|
+
range,
|
|
13992
|
+
rows,
|
|
13993
|
+
columns,
|
|
13994
|
+
chartType,
|
|
13995
|
+
useFirstColumnAsCategory = true,
|
|
13996
|
+
title,
|
|
13997
|
+
theme = "light"
|
|
13998
|
+
} = options;
|
|
13999
|
+
const normalized = normalizeRange(range);
|
|
14000
|
+
const { startRow, endRow, startCol, endCol } = normalized;
|
|
14001
|
+
if (startRow < 0 || endRow >= rows.length) {
|
|
14002
|
+
throw new Error("Invalid row range");
|
|
14003
|
+
}
|
|
14004
|
+
if (startCol < 0 || endCol >= columns.length) {
|
|
14005
|
+
throw new Error("Invalid column range");
|
|
14006
|
+
}
|
|
14007
|
+
const selectedRows = rows.slice(startRow, endRow + 1);
|
|
14008
|
+
const selectedColumns = columns.slice(startCol, endCol + 1);
|
|
14009
|
+
let categoryColumnIndex = 0;
|
|
14010
|
+
let dataColumnStartIndex = 0;
|
|
14011
|
+
if (useFirstColumnAsCategory && selectedColumns.length > 1) {
|
|
14012
|
+
categoryColumnIndex = 0;
|
|
14013
|
+
dataColumnStartIndex = 1;
|
|
14014
|
+
} else {
|
|
14015
|
+
categoryColumnIndex = -1;
|
|
14016
|
+
dataColumnStartIndex = 0;
|
|
14017
|
+
}
|
|
14018
|
+
const xLabels = [];
|
|
14019
|
+
if (categoryColumnIndex >= 0) {
|
|
14020
|
+
const categoryField = selectedColumns[categoryColumnIndex].field;
|
|
14021
|
+
selectedRows.forEach((row) => {
|
|
14022
|
+
const value = row[categoryField];
|
|
14023
|
+
xLabels.push(value !== null && value !== void 0 ? String(value) : "");
|
|
14024
|
+
});
|
|
14025
|
+
} else {
|
|
14026
|
+
for (let i = 0; i < selectedRows.length; i++) {
|
|
14027
|
+
xLabels.push(i + 1);
|
|
14028
|
+
}
|
|
14029
|
+
}
|
|
14030
|
+
const series = [];
|
|
14031
|
+
const dataColumns = selectedColumns.slice(dataColumnStartIndex);
|
|
14032
|
+
dataColumns.forEach((column, index) => {
|
|
14033
|
+
const seriesData = [];
|
|
14034
|
+
const field = column.field;
|
|
14035
|
+
let hasNumericData = false;
|
|
14036
|
+
selectedRows.forEach((row) => {
|
|
14037
|
+
const value = row[field];
|
|
14038
|
+
if (isNumeric(value)) {
|
|
14039
|
+
hasNumericData = true;
|
|
14040
|
+
seriesData.push(toNumber2(value));
|
|
14041
|
+
} else {
|
|
14042
|
+
seriesData.push(0);
|
|
14043
|
+
}
|
|
14044
|
+
});
|
|
14045
|
+
if (hasNumericData) {
|
|
14046
|
+
series.push({
|
|
14047
|
+
name: column.headerName || field,
|
|
14048
|
+
data: seriesData,
|
|
14049
|
+
color: DEFAULT_COLORS[index % DEFAULT_COLORS.length]
|
|
14050
|
+
});
|
|
14051
|
+
}
|
|
14052
|
+
});
|
|
14053
|
+
if (series.length === 0) {
|
|
14054
|
+
throw new Error("No numeric data found in the selected range");
|
|
14055
|
+
}
|
|
14056
|
+
if (chartType === "pie") {
|
|
14057
|
+
if (series.length === 1) {
|
|
14058
|
+
} else {
|
|
14059
|
+
const summedData = new Array(xLabels.length).fill(0);
|
|
14060
|
+
series.forEach((s) => {
|
|
14061
|
+
s.data.forEach((value, idx) => {
|
|
14062
|
+
summedData[idx] += value;
|
|
14063
|
+
});
|
|
14064
|
+
});
|
|
14065
|
+
series.length = 0;
|
|
14066
|
+
series.push({
|
|
14067
|
+
name: "Total",
|
|
14068
|
+
data: summedData,
|
|
14069
|
+
color: DEFAULT_COLORS[0]
|
|
14070
|
+
});
|
|
14071
|
+
}
|
|
14072
|
+
}
|
|
14073
|
+
return {
|
|
14074
|
+
id: generateChartId(),
|
|
14075
|
+
type: chartType,
|
|
14076
|
+
title: title || `${chartType.charAt(0).toUpperCase() + chartType.slice(1)} Chart`,
|
|
14077
|
+
xLabels,
|
|
14078
|
+
series,
|
|
14079
|
+
theme
|
|
14080
|
+
};
|
|
14081
|
+
}
|
|
14082
|
+
function updateChartType(config, newType) {
|
|
14083
|
+
var _a;
|
|
14084
|
+
return {
|
|
14085
|
+
...config,
|
|
14086
|
+
type: newType,
|
|
14087
|
+
title: ((_a = config.title) == null ? void 0 : _a.replace(
|
|
14088
|
+
/^(Line|Bar|Area|Pie)/i,
|
|
14089
|
+
newType.charAt(0).toUpperCase() + newType.slice(1)
|
|
14090
|
+
)) || `${newType.charAt(0).toUpperCase() + newType.slice(1)} Chart`
|
|
14091
|
+
};
|
|
14092
|
+
}
|
|
14093
|
+
function updateChartTheme(config, newTheme) {
|
|
14094
|
+
return {
|
|
14095
|
+
...config,
|
|
14096
|
+
theme: newTheme
|
|
14097
|
+
};
|
|
14098
|
+
}
|
|
14099
|
+
|
|
14100
|
+
// src/charts/QuickChart.tsx
|
|
14101
|
+
var import_react40 = __toESM(require("react"), 1);
|
|
14102
|
+
var import_recharts = require("recharts");
|
|
14103
|
+
var import_html_to_image = require("html-to-image");
|
|
14104
|
+
var QuickChart = ({
|
|
14105
|
+
config,
|
|
14106
|
+
onClose,
|
|
14107
|
+
onChangeType,
|
|
14108
|
+
onToggleTheme,
|
|
14109
|
+
allowTypeSwitch = true,
|
|
14110
|
+
allowThemeSwitch = true,
|
|
14111
|
+
width = 600,
|
|
14112
|
+
height = 400
|
|
14113
|
+
}) => {
|
|
14114
|
+
const chartRef = (0, import_react40.useRef)(null);
|
|
14115
|
+
const theme = config.theme || "light";
|
|
14116
|
+
const transformedData = config.xLabels.map((label, index) => {
|
|
14117
|
+
const dataPoint = { name: label };
|
|
14118
|
+
config.series.forEach((series) => {
|
|
14119
|
+
dataPoint[series.name] = series.data[index] || 0;
|
|
14120
|
+
});
|
|
14121
|
+
return dataPoint;
|
|
14122
|
+
});
|
|
14123
|
+
const pieData = config.series.length > 0 ? config.xLabels.map((label, index) => ({
|
|
14124
|
+
name: label,
|
|
14125
|
+
value: config.series[0].data[index] || 0
|
|
14126
|
+
})) : [];
|
|
14127
|
+
const handleExportPNG = async () => {
|
|
14128
|
+
if (!chartRef.current) return;
|
|
14129
|
+
try {
|
|
14130
|
+
const dataUrl = await (0, import_html_to_image.toPng)(chartRef.current, {
|
|
14131
|
+
quality: 1,
|
|
14132
|
+
pixelRatio: 2,
|
|
14133
|
+
backgroundColor: theme === "dark" ? "#1a1a1a" : "#ffffff"
|
|
14134
|
+
});
|
|
14135
|
+
const link = document.createElement("a");
|
|
14136
|
+
link.download = `${config.title || "chart"}-${Date.now()}.png`;
|
|
14137
|
+
link.href = dataUrl;
|
|
14138
|
+
link.click();
|
|
14139
|
+
} catch (error) {
|
|
14140
|
+
console.error("Failed to export chart:", error);
|
|
14141
|
+
}
|
|
14142
|
+
};
|
|
14143
|
+
const chartTypeIcon = (type) => {
|
|
14144
|
+
switch (type) {
|
|
14145
|
+
case "line":
|
|
14146
|
+
return "\u{1F4C8}";
|
|
14147
|
+
case "bar":
|
|
14148
|
+
return "\u{1F4CA}";
|
|
14149
|
+
case "area":
|
|
14150
|
+
return "\u{1F4C9}";
|
|
14151
|
+
case "pie":
|
|
14152
|
+
return "\u{1F967}";
|
|
14153
|
+
default:
|
|
14154
|
+
return "\u{1F4CA}";
|
|
14155
|
+
}
|
|
14156
|
+
};
|
|
14157
|
+
const renderChart = () => {
|
|
14158
|
+
const commonProps = {
|
|
14159
|
+
data: config.type === "pie" ? pieData : transformedData,
|
|
14160
|
+
margin: { top: 5, right: 30, left: 20, bottom: 5 }
|
|
14161
|
+
};
|
|
14162
|
+
const axisProps = {
|
|
14163
|
+
stroke: theme === "dark" ? "#888" : "#666"
|
|
14164
|
+
};
|
|
14165
|
+
const gridProps = {
|
|
14166
|
+
strokeDasharray: "3 3",
|
|
14167
|
+
stroke: theme === "dark" ? "#333" : "#ddd"
|
|
14168
|
+
};
|
|
14169
|
+
switch (config.type) {
|
|
14170
|
+
case "line":
|
|
14171
|
+
return /* @__PURE__ */ import_react40.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.LineChart, { ...commonProps }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.CartesianGrid, { ...gridProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.XAxis, { dataKey: "name", ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.YAxis, { ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(
|
|
14172
|
+
import_recharts.Tooltip,
|
|
14173
|
+
{
|
|
14174
|
+
contentStyle: {
|
|
14175
|
+
backgroundColor: theme === "dark" ? "#2a2a2a" : "#fff",
|
|
14176
|
+
border: `1px solid ${theme === "dark" ? "#444" : "#ccc"}`,
|
|
14177
|
+
color: theme === "dark" ? "#fff" : "#000"
|
|
14178
|
+
}
|
|
14179
|
+
}
|
|
14180
|
+
), /* @__PURE__ */ import_react40.default.createElement(import_recharts.Legend, null), config.series.map((series) => /* @__PURE__ */ import_react40.default.createElement(
|
|
14181
|
+
import_recharts.Line,
|
|
14182
|
+
{
|
|
14183
|
+
key: series.name,
|
|
14184
|
+
type: "monotone",
|
|
14185
|
+
dataKey: series.name,
|
|
14186
|
+
stroke: series.color,
|
|
14187
|
+
strokeWidth: 2,
|
|
14188
|
+
dot: { r: 4 },
|
|
14189
|
+
activeDot: { r: 6 }
|
|
14190
|
+
}
|
|
14191
|
+
))));
|
|
14192
|
+
case "bar":
|
|
14193
|
+
return /* @__PURE__ */ import_react40.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.BarChart, { ...commonProps }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.CartesianGrid, { ...gridProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.XAxis, { dataKey: "name", ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.YAxis, { ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(
|
|
14194
|
+
import_recharts.Tooltip,
|
|
14195
|
+
{
|
|
14196
|
+
contentStyle: {
|
|
14197
|
+
backgroundColor: theme === "dark" ? "#2a2a2a" : "#fff",
|
|
14198
|
+
border: `1px solid ${theme === "dark" ? "#444" : "#ccc"}`,
|
|
14199
|
+
color: theme === "dark" ? "#fff" : "#000"
|
|
14200
|
+
}
|
|
14201
|
+
}
|
|
14202
|
+
), /* @__PURE__ */ import_react40.default.createElement(import_recharts.Legend, null), config.series.map((series) => /* @__PURE__ */ import_react40.default.createElement(import_recharts.Bar, { key: series.name, dataKey: series.name, fill: series.color }))));
|
|
14203
|
+
case "area":
|
|
14204
|
+
return /* @__PURE__ */ import_react40.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.AreaChart, { ...commonProps }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.CartesianGrid, { ...gridProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.XAxis, { dataKey: "name", ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(import_recharts.YAxis, { ...axisProps }), /* @__PURE__ */ import_react40.default.createElement(
|
|
14205
|
+
import_recharts.Tooltip,
|
|
14206
|
+
{
|
|
14207
|
+
contentStyle: {
|
|
14208
|
+
backgroundColor: theme === "dark" ? "#2a2a2a" : "#fff",
|
|
14209
|
+
border: `1px solid ${theme === "dark" ? "#444" : "#ccc"}`,
|
|
14210
|
+
color: theme === "dark" ? "#fff" : "#000"
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14213
|
+
), /* @__PURE__ */ import_react40.default.createElement(import_recharts.Legend, null), config.series.map((series) => /* @__PURE__ */ import_react40.default.createElement(
|
|
14214
|
+
import_recharts.Area,
|
|
14215
|
+
{
|
|
14216
|
+
key: series.name,
|
|
14217
|
+
type: "monotone",
|
|
14218
|
+
dataKey: series.name,
|
|
14219
|
+
fill: series.color,
|
|
14220
|
+
stroke: series.color,
|
|
14221
|
+
fillOpacity: 0.6
|
|
14222
|
+
}
|
|
14223
|
+
))));
|
|
14224
|
+
case "pie":
|
|
14225
|
+
return /* @__PURE__ */ import_react40.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: "100%" }, /* @__PURE__ */ import_react40.default.createElement(import_recharts.PieChart, null, /* @__PURE__ */ import_react40.default.createElement(
|
|
14226
|
+
import_recharts.Pie,
|
|
14227
|
+
{
|
|
14228
|
+
data: pieData,
|
|
14229
|
+
cx: "50%",
|
|
14230
|
+
cy: "50%",
|
|
14231
|
+
labelLine: false,
|
|
14232
|
+
label: ({ name, percent }) => `${name}: ${(percent * 100).toFixed(0)}%`,
|
|
14233
|
+
outerRadius: Math.min(height, width) / 4,
|
|
14234
|
+
fill: "#8884d8",
|
|
14235
|
+
dataKey: "value"
|
|
14236
|
+
},
|
|
14237
|
+
pieData.map((_, index) => {
|
|
14238
|
+
var _a;
|
|
14239
|
+
return /* @__PURE__ */ import_react40.default.createElement(
|
|
14240
|
+
import_recharts.Cell,
|
|
14241
|
+
{
|
|
14242
|
+
key: `cell-${index}`,
|
|
14243
|
+
fill: ((_a = config.series[0]) == null ? void 0 : _a.color) || ["#8884d8", "#82ca9d", "#ffc658", "#ff7c7c", "#a28fd0"][index % 5]
|
|
14244
|
+
}
|
|
14245
|
+
);
|
|
14246
|
+
})
|
|
14247
|
+
), /* @__PURE__ */ import_react40.default.createElement(
|
|
14248
|
+
import_recharts.Tooltip,
|
|
14249
|
+
{
|
|
14250
|
+
contentStyle: {
|
|
14251
|
+
backgroundColor: theme === "dark" ? "#2a2a2a" : "#fff",
|
|
14252
|
+
border: `1px solid ${theme === "dark" ? "#444" : "#ccc"}`,
|
|
14253
|
+
color: theme === "dark" ? "#fff" : "#000"
|
|
14254
|
+
}
|
|
14255
|
+
}
|
|
14256
|
+
), /* @__PURE__ */ import_react40.default.createElement(import_recharts.Legend, null)));
|
|
14257
|
+
default:
|
|
14258
|
+
return /* @__PURE__ */ import_react40.default.createElement("div", null, "Unsupported chart type");
|
|
14259
|
+
}
|
|
14260
|
+
};
|
|
14261
|
+
return /* @__PURE__ */ import_react40.default.createElement(
|
|
14262
|
+
"div",
|
|
14263
|
+
{
|
|
14264
|
+
ref: chartRef,
|
|
14265
|
+
className: `quick-chart quick-chart--${theme}`,
|
|
14266
|
+
style: { width, height }
|
|
14267
|
+
},
|
|
14268
|
+
/* @__PURE__ */ import_react40.default.createElement("div", { className: "quick-chart__header" }, /* @__PURE__ */ import_react40.default.createElement("h3", { className: "quick-chart__title" }, config.title), /* @__PURE__ */ import_react40.default.createElement("div", { className: "quick-chart__controls" }, allowTypeSwitch && onChangeType && /* @__PURE__ */ import_react40.default.createElement("div", { className: "quick-chart__type-selector" }, ["line", "bar", "area", "pie"].map((type) => /* @__PURE__ */ import_react40.default.createElement(
|
|
14269
|
+
"button",
|
|
14270
|
+
{
|
|
14271
|
+
key: type,
|
|
14272
|
+
className: `quick-chart__type-btn ${config.type === type ? "quick-chart__type-btn--active" : ""}`,
|
|
14273
|
+
onClick: () => onChangeType(type),
|
|
14274
|
+
title: `${type.charAt(0).toUpperCase() + type.slice(1)} Chart`,
|
|
14275
|
+
"aria-label": `Switch to ${type} chart`
|
|
14276
|
+
},
|
|
14277
|
+
chartTypeIcon(type)
|
|
14278
|
+
))), allowThemeSwitch && onToggleTheme && /* @__PURE__ */ import_react40.default.createElement(
|
|
14279
|
+
"button",
|
|
14280
|
+
{
|
|
14281
|
+
className: "quick-chart__btn",
|
|
14282
|
+
onClick: onToggleTheme,
|
|
14283
|
+
title: "Toggle theme",
|
|
14284
|
+
"aria-label": "Toggle theme"
|
|
14285
|
+
},
|
|
14286
|
+
theme === "dark" ? "\u2600\uFE0F" : "\u{1F319}"
|
|
14287
|
+
), /* @__PURE__ */ import_react40.default.createElement(
|
|
14288
|
+
"button",
|
|
14289
|
+
{
|
|
14290
|
+
className: "quick-chart__btn",
|
|
14291
|
+
onClick: handleExportPNG,
|
|
14292
|
+
title: "Export as PNG",
|
|
14293
|
+
"aria-label": "Export chart as PNG"
|
|
14294
|
+
},
|
|
14295
|
+
"\u{1F4E5}"
|
|
14296
|
+
), onClose && /* @__PURE__ */ import_react40.default.createElement(
|
|
14297
|
+
"button",
|
|
14298
|
+
{
|
|
14299
|
+
className: "quick-chart__btn quick-chart__close",
|
|
14300
|
+
onClick: onClose,
|
|
14301
|
+
title: "Close",
|
|
14302
|
+
"aria-label": "Close chart"
|
|
14303
|
+
},
|
|
14304
|
+
"\xD7"
|
|
14305
|
+
))),
|
|
14306
|
+
/* @__PURE__ */ import_react40.default.createElement("div", { className: "quick-chart__body" }, renderChart())
|
|
14307
|
+
);
|
|
14308
|
+
};
|
|
14309
|
+
|
|
14310
|
+
// src/charts/ChartOverlay.tsx
|
|
14311
|
+
var import_react41 = __toESM(require("react"), 1);
|
|
14312
|
+
var ChartOverlay = ({
|
|
14313
|
+
config,
|
|
14314
|
+
onClose,
|
|
14315
|
+
onChangeType,
|
|
14316
|
+
onToggleTheme,
|
|
14317
|
+
position = "bottom-right",
|
|
14318
|
+
draggable = true
|
|
14319
|
+
}) => {
|
|
14320
|
+
const overlayRef = (0, import_react41.useRef)(null);
|
|
14321
|
+
const [isDragging, setIsDragging] = (0, import_react41.useState)(false);
|
|
14322
|
+
const [dragOffset, setDragOffset] = (0, import_react41.useState)({ x: 0, y: 0 });
|
|
14323
|
+
const [chartPosition, setChartPosition] = (0, import_react41.useState)({ x: 0, y: 0 });
|
|
14324
|
+
const [dimensions] = (0, import_react41.useState)({ width: 600, height: 400 });
|
|
14325
|
+
(0, import_react41.useEffect)(() => {
|
|
14326
|
+
if (!overlayRef.current) return;
|
|
14327
|
+
const updatePosition = () => {
|
|
14328
|
+
const viewport = {
|
|
14329
|
+
width: window.innerWidth,
|
|
14330
|
+
height: window.innerHeight
|
|
14331
|
+
};
|
|
14332
|
+
let x = 0;
|
|
14333
|
+
let y = 0;
|
|
14334
|
+
switch (position) {
|
|
14335
|
+
case "top-right":
|
|
14336
|
+
x = viewport.width - dimensions.width - 40;
|
|
14337
|
+
y = 40;
|
|
14338
|
+
break;
|
|
14339
|
+
case "top-left":
|
|
14340
|
+
x = 40;
|
|
14341
|
+
y = 40;
|
|
14342
|
+
break;
|
|
14343
|
+
case "bottom-right":
|
|
14344
|
+
x = viewport.width - dimensions.width - 40;
|
|
14345
|
+
y = viewport.height - dimensions.height - 40;
|
|
14346
|
+
break;
|
|
14347
|
+
case "bottom-left":
|
|
14348
|
+
x = 40;
|
|
14349
|
+
y = viewport.height - dimensions.height - 40;
|
|
14350
|
+
break;
|
|
14351
|
+
case "center":
|
|
14352
|
+
x = (viewport.width - dimensions.width) / 2;
|
|
14353
|
+
y = (viewport.height - dimensions.height) / 2;
|
|
14354
|
+
break;
|
|
14355
|
+
}
|
|
14356
|
+
setChartPosition({ x, y });
|
|
14357
|
+
};
|
|
14358
|
+
updatePosition();
|
|
14359
|
+
window.addEventListener("resize", updatePosition);
|
|
14360
|
+
return () => window.removeEventListener("resize", updatePosition);
|
|
14361
|
+
}, [position, dimensions]);
|
|
14362
|
+
const handleMouseDown = (e) => {
|
|
14363
|
+
if (!draggable) return;
|
|
14364
|
+
if (e.target.closest(".quick-chart__body")) return;
|
|
14365
|
+
setIsDragging(true);
|
|
14366
|
+
setDragOffset({
|
|
14367
|
+
x: e.clientX - chartPosition.x,
|
|
14368
|
+
y: e.clientY - chartPosition.y
|
|
14369
|
+
});
|
|
14370
|
+
};
|
|
14371
|
+
(0, import_react41.useEffect)(() => {
|
|
14372
|
+
if (!isDragging) return;
|
|
14373
|
+
const handleMouseMove = (e) => {
|
|
14374
|
+
const newX = e.clientX - dragOffset.x;
|
|
14375
|
+
const newY = e.clientY - dragOffset.y;
|
|
14376
|
+
const maxX = window.innerWidth - dimensions.width;
|
|
14377
|
+
const maxY = window.innerHeight - dimensions.height;
|
|
14378
|
+
setChartPosition({
|
|
14379
|
+
x: Math.max(0, Math.min(newX, maxX)),
|
|
14380
|
+
y: Math.max(0, Math.min(newY, maxY))
|
|
14381
|
+
});
|
|
14382
|
+
};
|
|
14383
|
+
const handleMouseUp = () => {
|
|
14384
|
+
setIsDragging(false);
|
|
14385
|
+
};
|
|
14386
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
14387
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
14388
|
+
return () => {
|
|
14389
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
14390
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
14391
|
+
};
|
|
14392
|
+
}, [isDragging, dragOffset, dimensions]);
|
|
14393
|
+
(0, import_react41.useEffect)(() => {
|
|
14394
|
+
const handleKeyDown = (e) => {
|
|
14395
|
+
if (e.key === "Escape") {
|
|
14396
|
+
onClose();
|
|
14397
|
+
}
|
|
14398
|
+
};
|
|
14399
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
14400
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
14401
|
+
}, [onClose]);
|
|
14402
|
+
return /* @__PURE__ */ import_react41.default.createElement("div", { className: "chart-overlay" }, /* @__PURE__ */ import_react41.default.createElement("div", { className: "chart-overlay__backdrop", onClick: onClose }), /* @__PURE__ */ import_react41.default.createElement(
|
|
14403
|
+
"div",
|
|
14404
|
+
{
|
|
14405
|
+
ref: overlayRef,
|
|
14406
|
+
className: `chart-overlay__container ${isDragging ? "chart-overlay__container--dragging" : ""} ${draggable ? "chart-overlay__container--draggable" : ""}`,
|
|
14407
|
+
style: {
|
|
14408
|
+
left: chartPosition.x,
|
|
14409
|
+
top: chartPosition.y,
|
|
14410
|
+
width: dimensions.width,
|
|
14411
|
+
height: dimensions.height
|
|
14412
|
+
},
|
|
14413
|
+
onMouseDown: handleMouseDown
|
|
14414
|
+
},
|
|
14415
|
+
/* @__PURE__ */ import_react41.default.createElement(
|
|
14416
|
+
QuickChart,
|
|
14417
|
+
{
|
|
14418
|
+
config,
|
|
14419
|
+
onClose,
|
|
14420
|
+
onChangeType,
|
|
14421
|
+
onToggleTheme,
|
|
14422
|
+
allowTypeSwitch: true,
|
|
14423
|
+
allowThemeSwitch: true,
|
|
14424
|
+
width: dimensions.width,
|
|
14425
|
+
height: dimensions.height
|
|
14426
|
+
}
|
|
14427
|
+
)
|
|
14428
|
+
));
|
|
14429
|
+
};
|
|
13940
14430
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13941
14431
|
0 && (module.exports = {
|
|
13942
14432
|
AdvancedFilterBuilder,
|
|
13943
14433
|
BadgeCell,
|
|
13944
14434
|
ButtonCell,
|
|
14435
|
+
ChartOverlay,
|
|
13945
14436
|
ColumnChooser,
|
|
13946
14437
|
ColumnFilters,
|
|
13947
14438
|
CurrencyCell,
|
|
@@ -13967,6 +14458,7 @@ function renderMarkdownPreview(markdown) {
|
|
|
13967
14458
|
PivotToolbar,
|
|
13968
14459
|
PriorityIndicator,
|
|
13969
14460
|
ProgressBar,
|
|
14461
|
+
QuickChart,
|
|
13970
14462
|
Rating,
|
|
13971
14463
|
RichSelectEditor,
|
|
13972
14464
|
ServerAdapter,
|
|
@@ -13978,6 +14470,7 @@ function renderMarkdownPreview(markdown) {
|
|
|
13978
14470
|
VirtualScroller,
|
|
13979
14471
|
WebSocketMockFeed,
|
|
13980
14472
|
alpineTheme,
|
|
14473
|
+
buildChartConfigFromRange,
|
|
13981
14474
|
buildPivot,
|
|
13982
14475
|
buildTreeFromFlat,
|
|
13983
14476
|
collapseAllNodes,
|
|
@@ -14016,11 +14509,14 @@ function renderMarkdownPreview(markdown) {
|
|
|
14016
14509
|
isTreeNode,
|
|
14017
14510
|
loadDensityMode,
|
|
14018
14511
|
materialTheme,
|
|
14512
|
+
normalizeRange,
|
|
14019
14513
|
parseFormattedNumber,
|
|
14020
14514
|
quartzTheme,
|
|
14021
14515
|
saveDensityMode,
|
|
14022
14516
|
themes,
|
|
14023
14517
|
toggleNodeExpansion,
|
|
14518
|
+
updateChartTheme,
|
|
14519
|
+
updateChartType,
|
|
14024
14520
|
useDensityMode,
|
|
14025
14521
|
useEditorAutoFocus,
|
|
14026
14522
|
useEditorClickOutside,
|