@reactloom/charts 0.0.0-stage → 1.0.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 +41 -2
- package/dist/LICENSE +21 -0
- package/dist/_internal/hooks/use-isomorphic-layout-effect.js +7 -0
- package/dist/_internal/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/_internal/primitives/visually-hidden.js +29 -0
- package/dist/_internal/primitives/visually-hidden.js.map +1 -0
- package/dist/_internal/utils/cx.js +10 -0
- package/dist/_internal/utils/cx.js.map +1 -0
- package/dist/_internal/utils/warn.js +13 -0
- package/dist/_internal/utils/warn.js.map +1 -0
- package/dist/advanced-charts.d.ts +37 -0
- package/dist/advanced-charts.d.ts.map +1 -0
- package/dist/advanced-charts.js +587 -0
- package/dist/advanced-charts.js.map +1 -0
- package/dist/cartesian.d.ts +25 -0
- package/dist/cartesian.d.ts.map +1 -0
- package/dist/cartesian.js +461 -0
- package/dist/cartesian.js.map +1 -0
- package/dist/chart-frame.d.ts +55 -0
- package/dist/chart-frame.d.ts.map +1 -0
- package/dist/chart-frame.js +148 -0
- package/dist/chart-frame.js.map +1 -0
- package/dist/charts.d.ts +35 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +47 -0
- package/dist/charts.js.map +1 -0
- package/dist/charts.module.js +126 -0
- package/dist/charts.module.js.map +1 -0
- package/dist/format.d.ts +42 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +101 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/item-charts.d.ts +140 -0
- package/dist/item-charts.d.ts.map +1 -0
- package/dist/item-charts.js +1476 -0
- package/dist/item-charts.js.map +1 -0
- package/dist/pie-chart.d.ts +23 -0
- package/dist/pie-chart.d.ts.map +1 -0
- package/dist/pie-chart.js +216 -0
- package/dist/pie-chart.js.map +1 -0
- package/dist/sparkline.d.ts +25 -0
- package/dist/sparkline.d.ts.map +1 -0
- package/dist/sparkline.js +88 -0
- package/dist/sparkline.js.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +99 -3
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reactloom/charts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Accessible React charts for ReactLoom: `LineChart`, `AreaChart`, `BarChart`, `PieChart` and
|
|
4
|
+
`Sparkline`, drawn with [visx](https://airbnb.io/visx) primitives (ADR-0010).
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add @reactloom/charts @reactloom/ui @reactloom/theme
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import '@reactloom/charts/styles.css';
|
|
12
|
+
import { LineChart } from '@reactloom/charts';
|
|
13
|
+
|
|
14
|
+
<LineChart
|
|
15
|
+
title="Revenue and costs, 2026"
|
|
16
|
+
data={monthly}
|
|
17
|
+
x="month"
|
|
18
|
+
series={[
|
|
19
|
+
{ key: 'revenue', label: 'Revenue' },
|
|
20
|
+
{ key: 'costs', label: 'Costs' },
|
|
21
|
+
]}
|
|
22
|
+
valueFormat={{ style: 'currency', currency: 'USD' }}
|
|
23
|
+
/>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- **A figure with words:** named by `title`, described by your `description` or a summary
|
|
27
|
+
generated from the data (range, extremes, change), plus a "Show data table" alternative.
|
|
28
|
+
- **Keyboard:** one tab stop; arrow keys move between points with a tooltip and a polite live
|
|
29
|
+
readout. Not `role="application"`.
|
|
30
|
+
- **Theme colours:** series use `--pl-color-chart-1…6` from `@reactloom/theme` (3:1 against the
|
|
31
|
+
background in every built-in theme); dash patterns in Windows high-contrast mode.
|
|
32
|
+
- **Locale and direction:** numbers and dates use the active `LocaleProvider` locale; charts
|
|
33
|
+
mirror in right-to-left layouts.
|
|
34
|
+
- **Size:** about 21 kB brotli for a cartesian chart (visx/d3 included, shared between charts),
|
|
35
|
+
7 kB for PieChart, 1.5 kB for Sparkline.
|
|
36
|
+
|
|
37
|
+
Limits: SVG, so very dense series (tens of thousands of separate marks) get slow — line and area
|
|
38
|
+
series stay one path. Charts read the layout direction when they mount.
|
|
39
|
+
|
|
40
|
+
Documentation and live examples: <https://www.reactloom.dev/components/line-chart>
|
|
41
|
+
|
|
42
|
+
MIT licensed.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ReactLoom UI contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
// ../hooks/src/use-isomorphic-layout-effect.ts
|
|
3
|
+
/** `useLayoutEffect` in the browser, `useEffect` on the server (avoids SSR warnings). */
|
|
4
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
5
|
+
export { useIsomorphicLayoutEffect };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=use-isomorphic-layout-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-isomorphic-layout-effect.js","names":[],"sources":["../../../../hooks/src/use-isomorphic-layout-effect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server (avoids SSR warnings). */\nexport const useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect;\n"],"mappings":";;;AAGA,IAAa,4BAA4B,OAAO,aAAa,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// ../primitives/src/visually-hidden.tsx
|
|
4
|
+
var hidden = {
|
|
5
|
+
position: "absolute",
|
|
6
|
+
width: 1,
|
|
7
|
+
height: 1,
|
|
8
|
+
padding: 0,
|
|
9
|
+
margin: -1,
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
clip: "rect(0 0 0 0)",
|
|
12
|
+
clipPath: "inset(50%)",
|
|
13
|
+
whiteSpace: "nowrap",
|
|
14
|
+
border: 0
|
|
15
|
+
};
|
|
16
|
+
/** Content available to assistive technology but not rendered visually. */
|
|
17
|
+
var VisuallyHidden = /*#__PURE__*/ forwardRef(function VisuallyHidden({ style, ...props }, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx("span", {
|
|
19
|
+
ref,
|
|
20
|
+
...props,
|
|
21
|
+
style: {
|
|
22
|
+
...hidden,
|
|
23
|
+
...style
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
export { VisuallyHidden };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=visually-hidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../../primitives/src/visually-hidden.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type HTMLAttributes } from 'react';\n\nconst hidden: CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\nexport type VisuallyHiddenProps = HTMLAttributes<HTMLSpanElement>;\n\n/** Content available to assistive technology but not rendered visually. */\nexport const VisuallyHidden = /*#__PURE__*/ forwardRef<HTMLSpanElement, VisuallyHiddenProps>(function VisuallyHidden(\n { style, ...props },\n ref,\n) {\n return <span ref={ref} {...props} style={{ ...hidden, ...style }} />;\n});\n"],"mappings":";;;AAEA,IAAM,SAAwB;CAC5B,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,UAAU;CACV,YAAY;CACZ,QAAQ;AACV;;AAKA,IAAa,iBAA+B,yBAAiD,SAAS,eACpG,EAAE,OAAO,GAAG,SACZ,KACA;CACA,OAAO,oBAAC,QAAD;EAAW;EAAK,GAAI;EAAO,OAAO;GAAE,GAAG;GAAQ,GAAG;EAAM;CAAI,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ../utils/src/cx.ts
|
|
2
|
+
/** Joins truthy class names with a single space. */
|
|
3
|
+
function cx(...values) {
|
|
4
|
+
let out = "";
|
|
5
|
+
for (const v of values) if (v) out = out ? `${out} ${v}` : v;
|
|
6
|
+
return out || void 0;
|
|
7
|
+
}
|
|
8
|
+
export { cx };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=cx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cx.js","names":[],"sources":["../../../../utils/src/cx.ts"],"sourcesContent":["type ClassValue = string | false | null | undefined;\n\n/** Joins truthy class names with a single space. */\nexport function cx(...values: ClassValue[]): string | undefined {\n let out = '';\n for (const v of values) if (v) out = out ? `${out} ${v}` : v;\n return out || undefined;\n}\n"],"mappings":";;AAGA,SAAgB,GAAG,GAAG,QAA0C;CAC9D,IAAI,MAAM;CACV,KAAK,MAAM,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM;CAC3D,OAAO,OAAO,KAAA;AAChB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ../utils/src/warn.ts
|
|
2
|
+
/** True unless the consumer's bundler replaced NODE_ENV with "production". */
|
|
3
|
+
var isDev = typeof process === "undefined" || process.env.NODE_ENV !== "production";
|
|
4
|
+
var seen = /* @__PURE__ */ new Set();
|
|
5
|
+
/** Development-only warning, printed once per message. Stripped by consumers' minifiers in prod. */
|
|
6
|
+
function warnOnce(message) {
|
|
7
|
+
if (!isDev || seen.has(message)) return;
|
|
8
|
+
seen.add(message);
|
|
9
|
+
console.warn(`[reactloom] ${message}`);
|
|
10
|
+
}
|
|
11
|
+
export { isDev, warnOnce };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=warn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.js","names":[],"sources":["../../../../utils/src/warn.ts"],"sourcesContent":["declare const process: { env: { NODE_ENV?: string } } | undefined;\n\n/** True unless the consumer's bundler replaced NODE_ENV with \"production\". */\nexport const isDev: boolean =\n typeof process === 'undefined' || process.env.NODE_ENV !== 'production';\n\nconst seen = new Set<string>();\n\n/** Development-only warning, printed once per message. Stripped by consumers' minifiers in prod. */\nexport function warnOnce(message: string): void {\n if (!isDev || seen.has(message)) return;\n seen.add(message);\n console.warn(`[reactloom] ${message}`);\n}\n"],"mappings":";;AAGA,IAAa,QACX,OAAO,YAAY,eAAA,QAAA,IAAA,aAAwC;AAE7D,IAAM,uBAAO,IAAI,IAAY;;AAG7B,SAAgB,SAAS,SAAuB;CAC9C,IAAI,CAAC,SAAS,KAAK,IAAI,OAAO,GAAG;CACjC,KAAK,IAAI,OAAO;CAChB,QAAQ,KAAK,eAAe,SAAS;AACvC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Accessor, ChartBaseProps, ChartSeries, XValue } from './types.js';
|
|
2
|
+
export interface ComboChartProps<Row> extends ChartBaseProps {
|
|
3
|
+
data: readonly Row[];
|
|
4
|
+
x: Accessor<Row, XValue>;
|
|
5
|
+
xFormat?: (value: XValue) => string;
|
|
6
|
+
yFormat?: (value: number) => string;
|
|
7
|
+
secondaryYFormat?: (value: number) => string;
|
|
8
|
+
/** Series rendered as bars. */
|
|
9
|
+
barSeries: readonly ChartSeries<Row>[];
|
|
10
|
+
/** Series rendered as lines. */
|
|
11
|
+
lineSeries: readonly ChartSeries<Row>[];
|
|
12
|
+
/** Use an independent right Y-axis for `lineSeries`. @default false */
|
|
13
|
+
dualAxis?: boolean;
|
|
14
|
+
xLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Combination bar and line chart with optional dual Y-axis, keyboard point exploration,
|
|
18
|
+
* generated summary, and an accessible data table.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ComboChart<Row>({ data, x, xFormat, yFormat, secondaryYFormat, barSeries, lineSeries, dualAxis, xLabel, title, hideTitle, description, hideDescription, height, loading, emptyState, table, messages: messagesProp, className, id, }: ComboChartProps<Row>): import("react").JSX.Element;
|
|
21
|
+
export interface CandlestickChartProps<Row> extends ChartBaseProps {
|
|
22
|
+
data: readonly Row[];
|
|
23
|
+
x: Accessor<Row, XValue>;
|
|
24
|
+
open: Accessor<Row, number>;
|
|
25
|
+
high: Accessor<Row, number>;
|
|
26
|
+
low: Accessor<Row, number>;
|
|
27
|
+
close: Accessor<Row, number>;
|
|
28
|
+
xFormat?: (value: XValue) => string;
|
|
29
|
+
yFormat?: (value: number) => string;
|
|
30
|
+
xLabel?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Financial OHLC candlestick chart with bullish/bearish encoding, keyboard exploration,
|
|
34
|
+
* generated summary, and an accessible data table.
|
|
35
|
+
*/
|
|
36
|
+
export declare function CandlestickChart<Row>({ data, x, open, high, low, close, xFormat, yFormat, xLabel, title, hideTitle, description, hideDescription, height, loading, emptyState, table, messages: messagesProp, className, id, }: CandlestickChartProps<Row>): import("react").JSX.Element;
|
|
37
|
+
//# sourceMappingURL=advanced-charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced-charts.d.ts","sourceRoot":"","sources":["../src/advanced-charts.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAgBhF,MAAM,WAAW,eAAe,CAAC,GAAG,CAAE,SAAQ,cAAc;IAC1D,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;IACrB,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,+BAA+B;IAC/B,SAAS,EAAE,SAAS,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;IACvC,gCAAgC;IAChC,UAAU,EAAE,SAAS,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,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