@particle-academy/fancy-slides 0.1.3 → 0.1.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/{chart-host-VIGM3J5Q.js → chart-host-BHP6GUWO.js} +5 -3
- package/dist/chart-host-BHP6GUWO.js.map +1 -0
- package/dist/index.cjs +97 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +97 -8
- package/dist/index.js.map +1 -1
- package/dist/registry.cjs +2 -0
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.js +1 -1
- package/package.json +3 -3
- package/dist/chart-host-VIGM3J5Q.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { EChart } from '@particle-academy/fancy-echarts';
|
|
1
|
+
import { registerAll, registerBuiltinThemes, EChart } from '@particle-academy/fancy-echarts';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
// src/registry/element-renderers/chart-host.tsx
|
|
5
|
+
registerAll();
|
|
6
|
+
registerBuiltinThemes();
|
|
5
7
|
function ChartHost({ element }) {
|
|
6
8
|
return /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsx(EChart, { option: element.option, theme: element.chartTheme }) });
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export { ChartHost as default };
|
|
10
|
-
//# sourceMappingURL=chart-host-
|
|
11
|
-
//# sourceMappingURL=chart-host-
|
|
12
|
+
//# sourceMappingURL=chart-host-BHP6GUWO.js.map
|
|
13
|
+
//# sourceMappingURL=chart-host-BHP6GUWO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/registry/element-renderers/chart-host.tsx"],"names":[],"mappings":";;;;AAYA,WAAA,EAAY;AACZ,qBAAA,EAAsB;AAEP,SAAR,SAAA,CAA2B,EAAE,OAAA,EAAQ,EAAoD;AAC5F,EAAA,2BACK,KAAA,EAAA,EAAI,KAAA,EAAO,EAAE,KAAA,EAAO,QAAQ,MAAA,EAAQ,MAAA,EAAO,EACxC,QAAA,kBAAA,GAAA,CAAC,UAAO,MAAA,EAAQ,OAAA,CAAQ,QAAkD,KAAA,EAAO,OAAA,CAAQ,YAAY,CAAA,EACzG,CAAA;AAER","file":"chart-host-BHP6GUWO.js","sourcesContent":["import { EChart, registerAll, registerBuiltinThemes } from \"@particle-academy/fancy-echarts\";\nimport type { ChartElement } from \"../../types\";\n\n// fancy-echarts ships its chart types as opt-in tree-shake-friendly modules,\n// so the consumer normally calls `registerAll()` somewhere global. The\n// registry subpath here is the natural spot to wire it: this module only\n// loads when a deck actually contains a chart element (defaultElementRegistry\n// is React.lazy), so the registration cost is paid by chart-using hosts\n// only — non-chart consumers never even import this file.\n//\n// `registerAll()` is idempotent on echarts' side, so re-imports across\n// chunks are safe.\nregisterAll();\nregisterBuiltinThemes();\n\nexport default function ChartHost({ element }: { element: ChartElement; slideWidthPx: number }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\" }}>\n <EChart option={element.option as Parameters<typeof EChart>[0][\"option\"]} theme={element.chartTheme} />\n </div>\n );\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1115,6 +1115,90 @@ function reduce(deck, op) {
|
|
|
1115
1115
|
};
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
|
+
|
|
1119
|
+
// src/utils/chart-presets.ts
|
|
1120
|
+
var QUARTERS = ["Q1", "Q2", "Q3", "Q4"];
|
|
1121
|
+
var REVENUE = [24e3, 38e3, 31e3, 47e3];
|
|
1122
|
+
function chartStarterOption(kind) {
|
|
1123
|
+
switch (kind) {
|
|
1124
|
+
case "bar":
|
|
1125
|
+
return {
|
|
1126
|
+
grid: { top: 24, left: 56, right: 16, bottom: 32 },
|
|
1127
|
+
tooltip: { trigger: "axis" },
|
|
1128
|
+
xAxis: { type: "category", data: [...QUARTERS] },
|
|
1129
|
+
yAxis: { type: "value" },
|
|
1130
|
+
series: [{ type: "bar", name: "Revenue", data: [...REVENUE] }]
|
|
1131
|
+
};
|
|
1132
|
+
case "line":
|
|
1133
|
+
return {
|
|
1134
|
+
grid: { top: 24, left: 56, right: 16, bottom: 32 },
|
|
1135
|
+
tooltip: { trigger: "axis" },
|
|
1136
|
+
xAxis: { type: "category", data: [...QUARTERS] },
|
|
1137
|
+
yAxis: { type: "value" },
|
|
1138
|
+
series: [{ type: "line", name: "Revenue", smooth: true, data: [...REVENUE] }]
|
|
1139
|
+
};
|
|
1140
|
+
case "area":
|
|
1141
|
+
return {
|
|
1142
|
+
grid: { top: 24, left: 56, right: 16, bottom: 32 },
|
|
1143
|
+
tooltip: { trigger: "axis" },
|
|
1144
|
+
xAxis: { type: "category", data: [...QUARTERS] },
|
|
1145
|
+
yAxis: { type: "value" },
|
|
1146
|
+
series: [
|
|
1147
|
+
{
|
|
1148
|
+
type: "line",
|
|
1149
|
+
name: "Revenue",
|
|
1150
|
+
smooth: true,
|
|
1151
|
+
areaStyle: {},
|
|
1152
|
+
data: [...REVENUE]
|
|
1153
|
+
}
|
|
1154
|
+
]
|
|
1155
|
+
};
|
|
1156
|
+
case "pie":
|
|
1157
|
+
return {
|
|
1158
|
+
tooltip: { trigger: "item" },
|
|
1159
|
+
legend: { bottom: 0 },
|
|
1160
|
+
series: [
|
|
1161
|
+
{
|
|
1162
|
+
type: "pie",
|
|
1163
|
+
radius: ["40%", "70%"],
|
|
1164
|
+
name: "Segment",
|
|
1165
|
+
data: [
|
|
1166
|
+
{ value: 1048, name: "Direct" },
|
|
1167
|
+
{ value: 735, name: "Search" },
|
|
1168
|
+
{ value: 580, name: "Email" }
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
]
|
|
1172
|
+
};
|
|
1173
|
+
case "scatter":
|
|
1174
|
+
return {
|
|
1175
|
+
grid: { top: 24, left: 48, right: 16, bottom: 32 },
|
|
1176
|
+
tooltip: { trigger: "item" },
|
|
1177
|
+
xAxis: { type: "value" },
|
|
1178
|
+
yAxis: { type: "value" },
|
|
1179
|
+
series: [
|
|
1180
|
+
{
|
|
1181
|
+
type: "scatter",
|
|
1182
|
+
name: "Points",
|
|
1183
|
+
symbolSize: 12,
|
|
1184
|
+
data: [
|
|
1185
|
+
[10, 8.04],
|
|
1186
|
+
[8, 6.95],
|
|
1187
|
+
[13, 7.58],
|
|
1188
|
+
[9, 8.81],
|
|
1189
|
+
[11, 8.33],
|
|
1190
|
+
[14, 9.96],
|
|
1191
|
+
[6, 7.24],
|
|
1192
|
+
[4, 4.26],
|
|
1193
|
+
[12, 10.84],
|
|
1194
|
+
[7, 4.82],
|
|
1195
|
+
[5, 5.68]
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
]
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1118
1202
|
function SlideRail({
|
|
1119
1203
|
slides,
|
|
1120
1204
|
selectedId,
|
|
@@ -1240,7 +1324,16 @@ function EditorToolbar({
|
|
|
1240
1324
|
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertShape?.("arrow"), children: "Arrow" })
|
|
1241
1325
|
] })
|
|
1242
1326
|
] }),
|
|
1243
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1327
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactFancy.Dropdown, { children: [
|
|
1328
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Action, { variant: "ghost", size: "sm", icon: "bar-chart", iconTrailing: "chevron-down", disabled, "aria-label": "Insert chart" }) }),
|
|
1329
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactFancy.Dropdown.Items, { children: [
|
|
1330
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertChart?.("bar"), children: "Bar chart" }),
|
|
1331
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertChart?.("line"), children: "Line chart" }),
|
|
1332
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertChart?.("area"), children: "Area chart" }),
|
|
1333
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertChart?.("pie"), children: "Pie chart" }),
|
|
1334
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Dropdown.Item, { onClick: () => onInsertChart?.("scatter"), children: "Scatter" })
|
|
1335
|
+
] })
|
|
1336
|
+
] }),
|
|
1244
1337
|
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Tooltip, { content: "Insert code", children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Action, { variant: "ghost", size: "sm", icon: "code", onClick: onInsertCode, disabled, "aria-label": "Insert code" }) }),
|
|
1245
1338
|
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Tooltip, { content: "Insert table", children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Action, { variant: "ghost", size: "sm", icon: "table", onClick: onInsertTable, disabled, "aria-label": "Insert table" }) }),
|
|
1246
1339
|
/* @__PURE__ */ jsxRuntime.jsx(reactFancy.Separator, { orientation: "vertical" }),
|
|
@@ -1620,17 +1713,13 @@ function DeckEditor({
|
|
|
1620
1713
|
[insert]
|
|
1621
1714
|
);
|
|
1622
1715
|
const insertChart = react.useCallback(
|
|
1623
|
-
() => insert({
|
|
1716
|
+
(kind = "bar") => insert({
|
|
1624
1717
|
type: "chart",
|
|
1625
1718
|
x: 0.1,
|
|
1626
1719
|
y: 0.2,
|
|
1627
1720
|
w: 0.8,
|
|
1628
1721
|
h: 0.6,
|
|
1629
|
-
option:
|
|
1630
|
-
xAxis: { type: "category", data: ["Q1", "Q2", "Q3", "Q4"] },
|
|
1631
|
-
yAxis: { type: "value" },
|
|
1632
|
-
series: [{ type: "bar", data: [24, 38, 31, 47] }]
|
|
1633
|
-
}
|
|
1722
|
+
option: chartStarterOption(kind)
|
|
1634
1723
|
}),
|
|
1635
1724
|
[insert]
|
|
1636
1725
|
);
|
|
@@ -1771,6 +1860,7 @@ exports.SlideViewer = SlideViewer;
|
|
|
1771
1860
|
exports.SpeakerNotes = SpeakerNotes;
|
|
1772
1861
|
exports.TextElementRenderer = TextElementRenderer;
|
|
1773
1862
|
exports.builtinThemes = builtinThemes;
|
|
1863
|
+
exports.chartStarterOption = chartStarterOption;
|
|
1774
1864
|
exports.darkTheme = darkTheme;
|
|
1775
1865
|
exports.deckId = deckId;
|
|
1776
1866
|
exports.defaultTheme = defaultTheme;
|