drafter-react 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +110 -2
- package/dist/charts/AreaChart.d.ts +12 -0
- package/dist/charts/AreaChart.js +35 -0
- package/dist/charts/BarChart.d.ts +36 -0
- package/dist/charts/BarChart.js +246 -0
- package/dist/charts/BoxPlotChart.d.ts +20 -0
- package/dist/charts/BoxPlotChart.js +50 -0
- package/dist/charts/BubbleChart.d.ts +15 -0
- package/dist/charts/BubbleChart.js +49 -0
- package/dist/charts/BulletChart.d.ts +15 -0
- package/dist/charts/BulletChart.js +42 -0
- package/dist/charts/CandlestickChart.d.ts +28 -0
- package/dist/charts/CandlestickChart.js +70 -0
- package/dist/charts/FunnelChart.d.ts +12 -0
- package/dist/charts/FunnelChart.js +40 -0
- package/dist/charts/GanttChart.d.ts +13 -0
- package/dist/charts/GanttChart.js +43 -0
- package/dist/charts/GaugeChart.d.ts +12 -0
- package/dist/charts/GaugeChart.js +71 -0
- package/dist/charts/Heatmap.d.ts +15 -0
- package/dist/charts/Heatmap.js +54 -0
- package/dist/charts/LineChart.d.ts +20 -0
- package/dist/charts/LineChart.js +65 -0
- package/dist/charts/PieChart.d.ts +20 -0
- package/dist/charts/PieChart.js +75 -0
- package/dist/charts/PolarAreaChart.d.ts +12 -0
- package/dist/charts/PolarAreaChart.js +36 -0
- package/dist/charts/RadarChart.d.ts +8 -0
- package/dist/charts/RadarChart.js +49 -0
- package/dist/charts/SankeyChart.d.ts +20 -0
- package/dist/charts/SankeyChart.js +114 -0
- package/dist/charts/ScatterPlot.d.ts +13 -0
- package/dist/charts/ScatterPlot.js +31 -0
- package/dist/charts/StepLineChart.d.ts +8 -0
- package/dist/charts/StepLineChart.js +32 -0
- package/dist/charts/StreamGraphChart.d.ts +12 -0
- package/dist/charts/StreamGraphChart.js +51 -0
- package/dist/charts/SunburstChart.d.ts +14 -0
- package/dist/charts/SunburstChart.js +69 -0
- package/dist/charts/TreemapChart.d.ts +13 -0
- package/dist/charts/TreemapChart.js +116 -0
- package/dist/core/colors.d.ts +29 -0
- package/dist/core/colors.js +40 -0
- package/dist/core/geometry.d.ts +16 -0
- package/dist/core/geometry.js +16 -0
- package/dist/core/paths.d.ts +21 -0
- package/dist/core/paths.js +74 -0
- package/dist/core/scales.d.ts +42 -0
- package/dist/core/scales.js +78 -0
- package/dist/core/types.d.ts +48 -0
- package/dist/core/types.js +20 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +36 -0
- package/dist/svg/Chart.d.ts +30 -0
- package/dist/svg/Chart.js +21 -0
- package/dist/svg/primitives.d.ts +86 -0
- package/dist/svg/primitives.js +77 -0
- package/dist/svg/styles.d.ts +1 -0
- package/dist/svg/styles.js +40 -0
- package/package.json +52 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import type { Size } from '../core/geometry.js';
|
|
3
|
+
/** Props every chart accepts: its box, appearance and entrance animation. */
|
|
4
|
+
export interface ChartFrameProps {
|
|
5
|
+
/** Width of the drawing in user units; also the rendered pixel width. Default 480. */
|
|
6
|
+
readonly width?: number;
|
|
7
|
+
/** Height of the drawing in user units. Default 300. */
|
|
8
|
+
readonly height?: number;
|
|
9
|
+
/** `auto` follows the visitor's `prefers-color-scheme`. Default `light`. */
|
|
10
|
+
readonly scheme?: 'light' | 'dark' | 'auto';
|
|
11
|
+
/** Play the entrance animation. Default true. */
|
|
12
|
+
readonly animate?: boolean;
|
|
13
|
+
readonly durationMs?: number;
|
|
14
|
+
/** Accessible name announced by screen readers. */
|
|
15
|
+
readonly label?: string;
|
|
16
|
+
readonly className?: string;
|
|
17
|
+
readonly style?: CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
/** The drawing box a chart lays its geometry out in. */
|
|
20
|
+
export declare function frameSize(frame: ChartFrameProps): Size;
|
|
21
|
+
/**
|
|
22
|
+
* The single host every chart wraps: an `<svg>` carrying the theme, the
|
|
23
|
+
* accessible name and the animation switch. It has no state and no effects, so
|
|
24
|
+
* a chart renders in a React Server Component and ships no JavaScript.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Chart({ scheme, animate, durationMs, label, className, style, children, ...frame }: ChartFrameProps & {
|
|
27
|
+
readonly children?: ReactNode;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
29
|
+
/** A CSS animation delay, for staggering marks. */
|
|
30
|
+
export declare function delay(ms: number): CSSProperties;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { chartCss } from './styles.js';
|
|
3
|
+
const DEFAULT_WIDTH = 480;
|
|
4
|
+
const DEFAULT_HEIGHT = 300;
|
|
5
|
+
/** The drawing box a chart lays its geometry out in. */
|
|
6
|
+
export function frameSize(frame) {
|
|
7
|
+
return { width: frame.width ?? DEFAULT_WIDTH, height: frame.height ?? DEFAULT_HEIGHT };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The single host every chart wraps: an `<svg>` carrying the theme, the
|
|
11
|
+
* accessible name and the animation switch. It has no state and no effects, so
|
|
12
|
+
* a chart renders in a React Server Component and ships no JavaScript.
|
|
13
|
+
*/
|
|
14
|
+
export function Chart({ scheme = 'light', animate = true, durationMs = 1100, label, className, style, children, ...frame }) {
|
|
15
|
+
const { width, height } = frameSize(frame);
|
|
16
|
+
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: className ? `drafter ${className}` : 'drafter', viewBox: `0 0 ${width} ${height}`, width: width, height: height, role: "img", "aria-label": label, "data-scheme": scheme, "data-animate": animate ? '' : undefined, style: { '--drafter-duration': `${durationMs}ms`, ...style }, children: [_jsx("style", { dangerouslySetInnerHTML: { __html: chartCss } }), children] }));
|
|
17
|
+
}
|
|
18
|
+
/** A CSS animation delay, for staggering marks. */
|
|
19
|
+
export function delay(ms) {
|
|
20
|
+
return { animationDelay: `${Math.round(ms)}ms` };
|
|
21
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import type { Point } from '../core/geometry.js';
|
|
3
|
+
import { type ChartBounds } from '../core/scales.js';
|
|
4
|
+
export type HAlign = 'start' | 'center' | 'end';
|
|
5
|
+
export type VAlign = 'top' | 'center' | 'bottom';
|
|
6
|
+
export interface LabelProps {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly color?: string;
|
|
11
|
+
readonly fontSize?: number;
|
|
12
|
+
readonly weight?: 400 | 500 | 600 | 700;
|
|
13
|
+
readonly h?: HAlign;
|
|
14
|
+
readonly v?: VAlign;
|
|
15
|
+
readonly className?: string;
|
|
16
|
+
readonly style?: CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
/** A chart label anchored at `(x, y)` by `h`/`v`. */
|
|
19
|
+
export declare function Label({ text, x, y, color, fontSize, weight, h, v, className, style, }: LabelProps): import("react").JSX.Element | null;
|
|
20
|
+
/**
|
|
21
|
+
* A soft vertical gradient fading from `color` at `topAlpha` to transparent,
|
|
22
|
+
* with Drafter's `[a, a*0.45, 0]` stops. Reference it as `fill="url(#id)"`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function AreaGradient({ id, color, top, bottom, topAlpha, }: {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly color: string;
|
|
27
|
+
readonly top: number;
|
|
28
|
+
readonly bottom: number;
|
|
29
|
+
readonly topAlpha?: number;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
/** A filled dot with a surface-coloured halo — marks line vertices. */
|
|
32
|
+
export declare function VertexDot({ x, y, color, radius, className, style, children, }: {
|
|
33
|
+
readonly x: number;
|
|
34
|
+
readonly y: number;
|
|
35
|
+
readonly color: string;
|
|
36
|
+
readonly radius: number;
|
|
37
|
+
readonly className?: string;
|
|
38
|
+
readonly style?: CSSProperties;
|
|
39
|
+
/** Typically a `<title>` for the hover tooltip. */
|
|
40
|
+
readonly children?: ReactNode;
|
|
41
|
+
}): import("react").JSX.Element;
|
|
42
|
+
export interface SmoothLineProps {
|
|
43
|
+
readonly points: readonly Point[];
|
|
44
|
+
readonly color: string;
|
|
45
|
+
/** The y the gradient fill closes down to. */
|
|
46
|
+
readonly baseline: number;
|
|
47
|
+
readonly strokeWidth?: number;
|
|
48
|
+
readonly fill?: boolean;
|
|
49
|
+
/** The leading-edge dot that rides the line as it traces in. */
|
|
50
|
+
readonly endDot?: boolean;
|
|
51
|
+
readonly smooth?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One line series: a traced stroke, an optional gradient area wiped in from the
|
|
55
|
+
* left, and a dot that rides the leading edge — Drafter's signature reveal,
|
|
56
|
+
* done entirely in CSS.
|
|
57
|
+
*/
|
|
58
|
+
export declare function SmoothLine({ points, color, baseline, strokeWidth, fill, endDot, smooth, }: SmoothLineProps): import("react").JSX.Element | null;
|
|
59
|
+
/**
|
|
60
|
+
* Reveals its children with a clockwise sweep around `(cx, cy)`, the radial
|
|
61
|
+
* counterpart of the line trace: a masked stroke as wide as the radius, traced
|
|
62
|
+
* in. `startAngle` is in radians (0 = +x); the default starts at 12 o'clock.
|
|
63
|
+
*/
|
|
64
|
+
export declare function RadialSweep({ cx, cy, radius, startAngle, children, }: {
|
|
65
|
+
readonly cx: number;
|
|
66
|
+
readonly cy: number;
|
|
67
|
+
readonly radius: number;
|
|
68
|
+
readonly startAngle?: number;
|
|
69
|
+
readonly children?: ReactNode;
|
|
70
|
+
}): import("react").JSX.Element;
|
|
71
|
+
/** Faint horizontal grid lines at "nice" steps of `max`, with value labels. */
|
|
72
|
+
export declare function ValueGrid({ bounds, max }: {
|
|
73
|
+
readonly bounds: ChartBounds;
|
|
74
|
+
readonly max: number;
|
|
75
|
+
}): import("react").JSX.Element | null;
|
|
76
|
+
/**
|
|
77
|
+
* X-axis labels for point-anchored series (first label on the left edge, last
|
|
78
|
+
* on the right), thinned so at most ~6 are drawn.
|
|
79
|
+
*/
|
|
80
|
+
export declare function CategoryLabels({ bounds, categories, count, }: {
|
|
81
|
+
readonly bounds: ChartBounds;
|
|
82
|
+
readonly categories: readonly string[];
|
|
83
|
+
readonly count: number;
|
|
84
|
+
}): import("react").JSX.Element | null;
|
|
85
|
+
/** Compact tick text: integers stay integers, fractions keep up to 2 decimals. */
|
|
86
|
+
export declare function formatTick(value: number): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { areaPath, polylinePath, smoothPath } from '../core/paths.js';
|
|
4
|
+
import { ChartAxis, normalizedLabels } from '../core/scales.js';
|
|
5
|
+
import { theme } from '../core/colors.js';
|
|
6
|
+
const ANCHOR = { start: 'start', center: 'middle', end: 'end' };
|
|
7
|
+
const BASELINE = { top: 'text-before-edge', center: 'central', bottom: 'text-after-edge' };
|
|
8
|
+
/** A chart label anchored at `(x, y)` by `h`/`v`. */
|
|
9
|
+
export function Label({ text, x, y, color = theme.label, fontSize = 11, weight = 400, h = 'start', v = 'top', className, style, }) {
|
|
10
|
+
if (!text)
|
|
11
|
+
return null;
|
|
12
|
+
return (_jsx("text", { x: x, y: y, fill: color, fontSize: fontSize, fontWeight: weight, textAnchor: ANCHOR[h], dominantBaseline: BASELINE[v], className: className, style: style, children: text }));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A soft vertical gradient fading from `color` at `topAlpha` to transparent,
|
|
16
|
+
* with Drafter's `[a, a*0.45, 0]` stops. Reference it as `fill="url(#id)"`.
|
|
17
|
+
*/
|
|
18
|
+
export function AreaGradient({ id, color, top, bottom, topAlpha = 0.32, }) {
|
|
19
|
+
return (_jsxs("linearGradient", { id: id, gradientUnits: "userSpaceOnUse", x1: 0, y1: top, x2: 0, y2: bottom, children: [_jsx("stop", { offset: 0, stopColor: color, stopOpacity: topAlpha }), _jsx("stop", { offset: 0.5, stopColor: color, stopOpacity: topAlpha * 0.45 }), _jsx("stop", { offset: 1, stopColor: color, stopOpacity: 0 })] }));
|
|
20
|
+
}
|
|
21
|
+
/** A filled dot with a surface-coloured halo — marks line vertices. */
|
|
22
|
+
export function VertexDot({ x, y, color, radius, className, style, children, }) {
|
|
23
|
+
return (_jsxs("g", { className: className, style: style, children: [_jsx("circle", { cx: x, cy: y, r: radius * 1.7, fill: theme.surface }), _jsx("circle", { cx: x, cy: y, r: radius, fill: color }), children] }));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One line series: a traced stroke, an optional gradient area wiped in from the
|
|
27
|
+
* left, and a dot that rides the leading edge — Drafter's signature reveal,
|
|
28
|
+
* done entirely in CSS.
|
|
29
|
+
*/
|
|
30
|
+
export function SmoothLine({ points, color, baseline, strokeWidth = 4, fill = true, endDot = true, smooth = true, }) {
|
|
31
|
+
const gradientId = useId();
|
|
32
|
+
const first = points[0];
|
|
33
|
+
const last = points[points.length - 1];
|
|
34
|
+
if (!first || !last || points.length < 2)
|
|
35
|
+
return null;
|
|
36
|
+
const line = smooth ? smoothPath(points) : polylinePath(points);
|
|
37
|
+
const top = points.reduce((min, p) => Math.min(min, p.y), Infinity);
|
|
38
|
+
return (_jsxs("g", { children: [fill ? (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(AreaGradient, { id: gradientId, color: color, top: top, bottom: baseline }) }), _jsx("path", { className: "d-wipe", d: areaPath(line, first.x, last.x, baseline), fill: `url(#${gradientId})` })] })) : null, _jsx("path", { className: "d-trace", d: line, pathLength: 1, fill: "none", stroke: color, strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }), endDot ? (_jsxs("g", { className: "d-ride", style: { offsetPath: `path("${line}")` }, children: [_jsx("circle", { r: strokeWidth * 1.5, fill: theme.surface }), _jsx("circle", { r: strokeWidth * 0.95, fill: color })] })) : null] }));
|
|
39
|
+
}
|
|
40
|
+
const HUB = 2;
|
|
41
|
+
/**
|
|
42
|
+
* Reveals its children with a clockwise sweep around `(cx, cy)`, the radial
|
|
43
|
+
* counterpart of the line trace: a masked stroke as wide as the radius, traced
|
|
44
|
+
* in. `startAngle` is in radians (0 = +x); the default starts at 12 o'clock.
|
|
45
|
+
*/
|
|
46
|
+
export function RadialSweep({ cx, cy, radius, startAngle = -Math.PI / 2, children, }) {
|
|
47
|
+
const maskId = useId();
|
|
48
|
+
// Slightly oversized so the mask edge never antialiases against the artwork.
|
|
49
|
+
const reach = radius + 4;
|
|
50
|
+
return (_jsxs(_Fragment, { children: [_jsxs("mask", { id: maskId, maskUnits: "userSpaceOnUse", x: cx - reach, y: cy - reach, width: reach * 2, height: reach * 2, children: [_jsx("circle", { cx: cx, cy: cy, r: HUB + 0.5, fill: "#fff" }), _jsx("circle", { className: "d-trace", cx: cx, cy: cy, r: (reach + HUB) / 2, pathLength: 1, fill: "none", stroke: "#fff", strokeWidth: reach - HUB, transform: `rotate(${(startAngle * 180) / Math.PI} ${cx} ${cy})` })] }), _jsx("g", { mask: `url(#${maskId})`, children: children })] }));
|
|
51
|
+
}
|
|
52
|
+
/** Faint horizontal grid lines at "nice" steps of `max`, with value labels. */
|
|
53
|
+
export function ValueGrid({ bounds, max }) {
|
|
54
|
+
if (!(max > 0))
|
|
55
|
+
return null;
|
|
56
|
+
const step = ChartAxis.gridStep(max);
|
|
57
|
+
const rows = Array.from({ length: Math.trunc(max / step) + 1 }, (_, i) => i * step);
|
|
58
|
+
return (_jsx("g", { children: rows.map((value) => {
|
|
59
|
+
const y = bounds.bottom - (value / max) * bounds.height;
|
|
60
|
+
return (_jsxs("g", { children: [_jsx("line", { x1: bounds.left, x2: bounds.right, y1: y, y2: y, stroke: theme.grid }), _jsx(Label, { text: formatTick(value), x: bounds.left - 8, y: y, h: "end", v: "center" })] }, value));
|
|
61
|
+
}) }));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* X-axis labels for point-anchored series (first label on the left edge, last
|
|
65
|
+
* on the right), thinned so at most ~6 are drawn.
|
|
66
|
+
*/
|
|
67
|
+
export function CategoryLabels({ bounds, categories, count, }) {
|
|
68
|
+
if (count < 2)
|
|
69
|
+
return null;
|
|
70
|
+
const labels = normalizedLabels(categories, count);
|
|
71
|
+
const stride = Math.max(1, Math.ceil(count / 6));
|
|
72
|
+
return (_jsx("g", { children: labels.map((label, i) => i % stride === 0 ? (_jsx(Label, { text: label, x: bounds.left + (i * bounds.width) / (count - 1), y: bounds.bottom + 16, h: "center", v: "center" }, i)) : null) }));
|
|
73
|
+
}
|
|
74
|
+
/** Compact tick text: integers stay integers, fractions keep up to 2 decimals. */
|
|
75
|
+
export function formatTick(value) {
|
|
76
|
+
return `${Math.round(value * 100) / 100}`;
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chartCss: string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The whole runtime of the library: one small stylesheet. Theme colours resolve
|
|
3
|
+
* through custom properties and every entrance animation is a CSS keyframe that
|
|
4
|
+
* runs *from* a hidden state *to* the element's natural one — so with
|
|
5
|
+
* animations off (or `prefers-reduced-motion`) a chart is simply finished.
|
|
6
|
+
*/
|
|
7
|
+
const dark = '--_dg:var(--drafter-grid,#2a2e37);--_dl:var(--drafter-label,#8a92a2);--_ds:var(--drafter-surface,#1b1e25)';
|
|
8
|
+
export const chartCss = [
|
|
9
|
+
'.drafter{--_dg:var(--drafter-grid,#edf0f5);--_dl:var(--drafter-label,#9aa3b2);--_ds:var(--drafter-surface,#fff);max-width:100%;height:auto;font-family:inherit}',
|
|
10
|
+
`.drafter[data-scheme=dark]{${dark}}`,
|
|
11
|
+
`@media(prefers-color-scheme:dark){.drafter[data-scheme=auto]{${dark}}}`,
|
|
12
|
+
'.drafter text{font-variant-numeric:tabular-nums}',
|
|
13
|
+
'.drafter .d-mark{transition:opacity .15s}',
|
|
14
|
+
'.drafter .d-mark:hover{opacity:.78}',
|
|
15
|
+
'.drafter .d-ride{offset-rotate:0deg;offset-distance:100%}',
|
|
16
|
+
'.drafter :is(.d-grow-up,.d-grow-down,.d-grow-right,.d-pop){transform-box:fill-box}',
|
|
17
|
+
'.drafter .d-grow-up{transform-origin:50% 100%}',
|
|
18
|
+
'.drafter .d-grow-down{transform-origin:50% 0}',
|
|
19
|
+
'.drafter .d-grow-right{transform-origin:0 50%}',
|
|
20
|
+
'.drafter .d-pop{transform-origin:50% 50%}',
|
|
21
|
+
'.drafter[data-animate] :is(.d-trace,.d-wipe,.d-ride,.d-grow-up,.d-grow-down,.d-grow-right,.d-pop,.d-fade,.d-spin){animation:var(--drafter-duration) cubic-bezier(.42,0,.58,1) backwards}',
|
|
22
|
+
'.drafter[data-animate] .d-trace{animation-name:drafter-trace}',
|
|
23
|
+
'.drafter[data-animate] .d-wipe{animation-name:drafter-wipe}',
|
|
24
|
+
'.drafter[data-animate] .d-ride{animation-name:drafter-ride}',
|
|
25
|
+
'.drafter[data-animate] :is(.d-grow-up,.d-grow-down){animation-name:drafter-grow-y}',
|
|
26
|
+
'.drafter[data-animate] .d-grow-right{animation-name:drafter-grow-x}',
|
|
27
|
+
'.drafter[data-animate] .d-pop{animation-name:drafter-pop}',
|
|
28
|
+
'.drafter[data-animate] .d-fade{animation-name:drafter-fade}',
|
|
29
|
+
'.drafter[data-animate] .d-spin{animation-name:drafter-spin}',
|
|
30
|
+
// Paths opt in with pathLength={1}; the gap is longer than the path so it never wraps.
|
|
31
|
+
'@keyframes drafter-trace{from{stroke-dasharray:1 1.2;stroke-dashoffset:1}to{stroke-dasharray:1 1.2;stroke-dashoffset:0}}',
|
|
32
|
+
'@keyframes drafter-wipe{from{clip-path:inset(-50% 100% -50% -1%)}to{clip-path:inset(-50% -1% -50% -1%)}}',
|
|
33
|
+
'@keyframes drafter-ride{from{offset-distance:0%}}',
|
|
34
|
+
'@keyframes drafter-grow-y{from{transform:scaleY(0)}}',
|
|
35
|
+
'@keyframes drafter-grow-x{from{transform:scaleX(0)}}',
|
|
36
|
+
'@keyframes drafter-pop{from{transform:scale(0);opacity:0}}',
|
|
37
|
+
'@keyframes drafter-fade{from{opacity:0}}',
|
|
38
|
+
'@keyframes drafter-spin{from{transform:rotate(-90deg) scale(.6);opacity:0}}',
|
|
39
|
+
'@media(prefers-reduced-motion:reduce){.drafter[data-animate] *{animation:none!important}}',
|
|
40
|
+
].join('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drafter-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Drafter charts for React and Next.js — 27 SVG chart types that render in Server Components with zero client JavaScript.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Ranbir Singh (AndroidPoet)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/AndroidPoet/drafter-react.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"react",
|
|
13
|
+
"nextjs",
|
|
14
|
+
"charts",
|
|
15
|
+
"svg",
|
|
16
|
+
"server-components",
|
|
17
|
+
"rsc",
|
|
18
|
+
"dataviz",
|
|
19
|
+
"drafter"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"prepublishOnly": "npm run typecheck && npm test && npm run build"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=18"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/react": "^19.0.0",
|
|
48
|
+
"@types/react-dom": "^19.0.0",
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"react-dom": "^19.0.0",
|
|
51
|
+
"typescript": "^5.6.0",
|
|
52
|
+
"vitest": "^3.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|