@x-wave/blog 2.5.0 → 2.6.1
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/README.md +79 -1
- package/components/Chart/index.d.ts +27 -0
- package/index.d.ts +1 -0
- package/index.js +22386 -1361
- package/package.json +5 -3
- package/styles/index.css +1 -1
package/README.md
CHANGED
|
@@ -368,7 +368,85 @@ Images support automatic dark mode variants. If a dark variant exists at `image-
|
|
|
368
368
|
|
|
369
369
|
---
|
|
370
370
|
|
|
371
|
-
|
|
371
|
+
#### Charts
|
|
372
|
+
|
|
373
|
+
Embed responsive charts directly in your Markdown using fenced code blocks with the `chart` language identifier. The body must be valid JSON.
|
|
374
|
+
|
|
375
|
+
Supported chart types: `bar`, `line`, `pie`.
|
|
376
|
+
|
|
377
|
+
**Bar chart:**
|
|
378
|
+
|
|
379
|
+
````mdx
|
|
380
|
+
```chart
|
|
381
|
+
{
|
|
382
|
+
"type": "bar",
|
|
383
|
+
"title": "Monthly Revenue",
|
|
384
|
+
"xKey": "month",
|
|
385
|
+
"data": [
|
|
386
|
+
{ "month": "Jan", "revenue": 4000 },
|
|
387
|
+
{ "month": "Feb", "revenue": 3000 },
|
|
388
|
+
{ "month": "Mar", "revenue": 5000 }
|
|
389
|
+
],
|
|
390
|
+
"series": [{ "key": "revenue", "name": "Revenue" }]
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
````
|
|
394
|
+
|
|
395
|
+
**Line chart:**
|
|
396
|
+
|
|
397
|
+
````mdx
|
|
398
|
+
```chart
|
|
399
|
+
{
|
|
400
|
+
"type": "line",
|
|
401
|
+
"title": "Daily Users",
|
|
402
|
+
"xKey": "day",
|
|
403
|
+
"data": [
|
|
404
|
+
{ "day": "Mon", "users": 120, "sessions": 200 },
|
|
405
|
+
{ "day": "Tue", "users": 150, "sessions": 230 },
|
|
406
|
+
{ "day": "Wed", "users": 180, "sessions": 260 }
|
|
407
|
+
],
|
|
408
|
+
"series": [
|
|
409
|
+
{ "key": "users", "name": "Users", "color": "#6366f1" },
|
|
410
|
+
{ "key": "sessions", "name": "Sessions", "color": "#10b981" }
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
````
|
|
415
|
+
|
|
416
|
+
**Pie chart:**
|
|
417
|
+
|
|
418
|
+
````mdx
|
|
419
|
+
```chart
|
|
420
|
+
{
|
|
421
|
+
"type": "pie",
|
|
422
|
+
"title": "Traffic Sources",
|
|
423
|
+
"data": [
|
|
424
|
+
{ "name": "Organic", "value": 400 },
|
|
425
|
+
{ "name": "Referral", "value": 300 },
|
|
426
|
+
{ "name": "Direct", "value": 200 }
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
````
|
|
431
|
+
|
|
432
|
+
**Chart JSON fields:**
|
|
433
|
+
|
|
434
|
+
| Field | Type | Required | Description |
|
|
435
|
+
|---|---|---|---|
|
|
436
|
+
| `type` | `"bar" \| "line" \| "pie"` | Yes | Chart type |
|
|
437
|
+
| `data` | `object[]` | Yes | Array of data points |
|
|
438
|
+
| `title` | `string` | No | Chart title displayed above |
|
|
439
|
+
| `xKey` | `string` | No | Key for X-axis categories (bar/line). Default: `"name"` |
|
|
440
|
+
| `xLabel` | `string` | No | Label for the X-axis |
|
|
441
|
+
| `yLabel` | `string` | No | Label for the Y-axis |
|
|
442
|
+
| `series` | `{ key, name?, color? }[]` | No | Data series definitions (bar/line). Auto-detected from numeric keys if omitted |
|
|
443
|
+
| `nameKey` | `string` | No | Key for slice labels (pie). Default: `"name"` |
|
|
444
|
+
| `valueKey` | `string` | No | Key for slice values (pie). Default: `"value"` |
|
|
445
|
+
| `height` | `number` | No | Chart height in pixels. Default: `350` |
|
|
446
|
+
|
|
447
|
+
Charts are fully responsive and adapt to dark/light themes automatically.
|
|
448
|
+
|
|
449
|
+
---
|
|
372
450
|
|
|
373
451
|
## API reference
|
|
374
452
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface SeriesConfig {
|
|
2
|
+
key: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ChartConfig {
|
|
7
|
+
type: 'bar' | 'line' | 'pie';
|
|
8
|
+
data: Record<string, unknown>[];
|
|
9
|
+
title?: string;
|
|
10
|
+
xKey?: string;
|
|
11
|
+
xLabel?: string;
|
|
12
|
+
yLabel?: string;
|
|
13
|
+
series?: SeriesConfig[];
|
|
14
|
+
nameKey?: string;
|
|
15
|
+
valueKey?: string;
|
|
16
|
+
height?: number;
|
|
17
|
+
}
|
|
18
|
+
interface ChartBlockProps {
|
|
19
|
+
config: ChartConfig;
|
|
20
|
+
}
|
|
21
|
+
export declare function ChartBlock({ config }: ChartBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Parses a JSON string into a ChartConfig.
|
|
24
|
+
* Returns null if the JSON is invalid or missing required fields.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseChartConfig(json: string): ChartConfig | null;
|
|
27
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { BlogRoot } from './components/BlogRoot';
|
|
|
5
5
|
export { BlogSidebar } from './components/BlogSidebar';
|
|
6
6
|
export type { BreadcrumbProps } from './components/Breadcrumb';
|
|
7
7
|
export { Breadcrumb } from './components/Breadcrumb';
|
|
8
|
+
export { ChartBlock } from './components/Chart';
|
|
8
9
|
export { ContentPage } from './components/ContentPage';
|
|
9
10
|
export { DocumentationLayout } from './components/DocumentationLayout';
|
|
10
11
|
export { DocumentationRoutes } from './components/DocumentationRoutes';
|