@northstar-js/charts 0.0.0-stage → 0.2.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 +21 -0
- package/dist/Axis.d.ts +17 -0
- package/dist/Axis.d.ts.map +1 -0
- package/dist/Axis.js +13 -0
- package/dist/Axis.js.map +1 -0
- package/dist/ClaimInstrument.d.ts +31 -0
- package/dist/ClaimInstrument.d.ts.map +1 -0
- package/dist/ClaimInstrument.js +33 -0
- package/dist/ClaimInstrument.js.map +1 -0
- package/dist/Composition.d.ts +17 -0
- package/dist/Composition.d.ts.map +1 -0
- package/dist/Composition.js +19 -0
- package/dist/Composition.js.map +1 -0
- package/dist/Distribution.d.ts +14 -0
- package/dist/Distribution.d.ts.map +1 -0
- package/dist/Distribution.js +19 -0
- package/dist/Distribution.js.map +1 -0
- package/dist/Figure.d.ts +24 -0
- package/dist/Figure.d.ts.map +1 -0
- package/dist/Figure.js +17 -0
- package/dist/Figure.js.map +1 -0
- package/dist/Legend.d.ts +12 -0
- package/dist/Legend.d.ts.map +1 -0
- package/dist/Legend.js +6 -0
- package/dist/Legend.js.map +1 -0
- package/dist/Ranking.d.ts +12 -0
- package/dist/Ranking.d.ts.map +1 -0
- package/dist/Ranking.js +14 -0
- package/dist/Ranking.js.map +1 -0
- package/dist/RunProgress.d.ts +18 -0
- package/dist/RunProgress.d.ts.map +1 -0
- package/dist/RunProgress.js +22 -0
- package/dist/RunProgress.js.map +1 -0
- package/dist/Tooltip.d.ts +12 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +25 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/format.d.ts +20 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +44 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/marks.d.ts +18 -0
- package/dist/marks.d.ts.map +1 -0
- package/dist/marks.js +17 -0
- package/dist/marks.js.map +1 -0
- package/dist/tokens.d.ts +17 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +26 -0
- package/dist/tokens.js.map +1 -0
- package/package.json +55 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ali Amaan
|
|
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.
|
package/dist/Axis.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface AxisProps {
|
|
2
|
+
/** Pixel length of the axis. */
|
|
3
|
+
length: number;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
/** Major tick step in domain units. Default (max - min) / 4. */
|
|
7
|
+
step?: number;
|
|
8
|
+
/** Domain value of the meridian (the midpoint line). Omit for none. */
|
|
9
|
+
meridian?: number;
|
|
10
|
+
x?: number;
|
|
11
|
+
y?: number;
|
|
12
|
+
format?: (n: number) => string;
|
|
13
|
+
showLabels?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** A horizontal axis drawn inside an <svg>: horizon rule, major ticks, optional meridian. */
|
|
16
|
+
export declare function Axis({ length, min, max, step, meridian, x, y, format, showLabels }: AxisProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Axis.d.ts","sourceRoot":"","sources":["../src/Axis.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,6FAA6F;AAC7F,wBAAgB,IAAI,CAAC,EAAE,MAAM,EAAE,GAAO,EAAE,GAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAK,EAAE,CAAK,EAAE,MAAe,EAAE,UAAiB,EAAE,EAAE,SAAS,2CAuB/H"}
|
package/dist/Axis.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { v } from './tokens.js';
|
|
3
|
+
/** A horizontal axis drawn inside an <svg>: horizon rule, major ticks, optional meridian. */
|
|
4
|
+
export function Axis({ length, min = 0, max = 100, step, meridian, x = 0, y = 0, format = String, showLabels = true }) {
|
|
5
|
+
const s = step ?? (max - min) / 4;
|
|
6
|
+
const ticks = [];
|
|
7
|
+
if (s > 0)
|
|
8
|
+
for (let t = min; t <= max + 1e-9; t += s)
|
|
9
|
+
ticks.push(+t.toFixed(6));
|
|
10
|
+
const px = (t) => x + ((t - min) / (max - min || 1)) * length;
|
|
11
|
+
return (_jsxs("g", { "data-part": "axis", children: [_jsx("line", { x1: x, x2: x + length, y1: y, y2: y, stroke: v.line2, strokeWidth: 1, "data-part": "horizon" }), ticks.map((t) => (_jsxs("g", { "data-part": "tick", children: [_jsx("line", { x1: px(t), x2: px(t), y1: y, y2: y + 4, stroke: v.text3, strokeWidth: 1 }), showLabels && (_jsx("text", { x: px(t), y: y + 15, textAnchor: "middle", fontSize: 11, fill: v.text3, fontFamily: v.mono, children: format(t) }))] }, t))), meridian !== undefined && (_jsx("line", { x1: px(meridian), x2: px(meridian), y1: y - 12, y2: y + 4, stroke: v.text3, strokeDasharray: "2 2", "data-part": "meridian" }))] }));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Axis.js.map
|
package/dist/Axis.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Axis.js","sourceRoot":"","sources":["../src/Axis.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAiBhC,6FAA6F;AAC7F,MAAM,UAAU,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,GAAG,IAAI,EAAa;IAC9H,MAAM,CAA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I,YAC3F,MAAM,CAAC,CAAC,CAAC,GACL,CACR,KANK,CAAC,CAOL,CACL,CAAC,EACD,QAAQ,KAAK,SAAS,IAAI,CACzB,eAAM,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,eAAe,EAAC,KAAK,eAAW,UAAU,GAAG,CAChI,IACC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
interface Base extends Omit<SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
3
|
+
width?: number;
|
|
4
|
+
locale?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LevelInstrument extends Base {
|
|
7
|
+
claim: 'level';
|
|
8
|
+
/** Share 0-1. */
|
|
9
|
+
value: number;
|
|
10
|
+
/** Band in percentage points. Optional. */
|
|
11
|
+
band?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DirectionInstrument extends Base {
|
|
14
|
+
claim: 'direction';
|
|
15
|
+
/** -1 left of the meridian, 0 on it, 1 right of it. */
|
|
16
|
+
direction: -1 | 0 | 1;
|
|
17
|
+
}
|
|
18
|
+
export interface RankingInstrument extends Base {
|
|
19
|
+
claim: 'ranking';
|
|
20
|
+
/** 1-based rank. */
|
|
21
|
+
rank: number;
|
|
22
|
+
of: number;
|
|
23
|
+
}
|
|
24
|
+
export type ClaimInstrumentProps = LevelInstrument | DirectionInstrument | RankingInstrument;
|
|
25
|
+
/**
|
|
26
|
+
* The claim instrument: one glyph per claim class. Level is a node with a capped band on a 0-100 axis,
|
|
27
|
+
* direction a gauge needle on a detent (no number), ranking a position on a ladder (no value).
|
|
28
|
+
*/
|
|
29
|
+
export declare function ClaimInstrument(props: ClaimInstrumentProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=ClaimInstrument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaimInstrument.d.ts","sourceRoot":"","sources":["../src/ClaimInstrument.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQtC,UAAU,IAAK,SAAQ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,eAAgB,SAAQ,IAAI;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,mBAAoB,SAAQ,IAAI;IAC/C,KAAK,EAAE,WAAW,CAAC;IACnB,uDAAuD;IACvD,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACvB;AACD,MAAM,WAAW,iBAAkB,SAAQ,IAAI;IAC7C,KAAK,EAAE,SAAS,CAAC;IACjB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA+C1D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Axis } from './Axis.js';
|
|
3
|
+
import { CLAIM_LABEL } from './Figure.js';
|
|
4
|
+
import { formatBand, formatPercent } from './format.js';
|
|
5
|
+
import { MeasuredNode } from './marks.js';
|
|
6
|
+
import { v } from './tokens.js';
|
|
7
|
+
/**
|
|
8
|
+
* The claim instrument: one glyph per claim class. Level is a node with a capped band on a 0-100 axis,
|
|
9
|
+
* direction a gauge needle on a detent (no number), ranking a position on a ladder (no value).
|
|
10
|
+
*/
|
|
11
|
+
export function ClaimInstrument(props) {
|
|
12
|
+
const claim = props.claim;
|
|
13
|
+
if (props.claim === 'level') {
|
|
14
|
+
const { value, band, width = 290, locale = 'en', claim: _c, ...rest } = props;
|
|
15
|
+
const L = width - 20, x0 = 10, y = 22;
|
|
16
|
+
const px = (pct) => x0 + (Math.max(0, Math.min(100, pct)) / 100) * L;
|
|
17
|
+
const pct = value * 100;
|
|
18
|
+
const aria = `${CLAIM_LABEL[claim]}: ${formatPercent(value, { locale })}${band !== undefined ? ` ${formatBand(band, { locale })}` : ''}`;
|
|
19
|
+
return (_jsxs("svg", { width: width, height: 44, viewBox: `0 0 ${width} 44`, role: "img", "aria-label": aria, "data-part": "claim-instrument", "data-claim": claim, ...rest, children: [_jsx(Axis, { length: L, x: x0, y: y, meridian: 50, showLabels: false }), band !== undefined && (_jsxs("g", { "data-part": "band", stroke: v.signalEdge, strokeWidth: 1.5, children: [_jsx("line", { x1: px(pct - band), x2: px(pct + band), y1: y, y2: y }), _jsx("line", { x1: px(pct - band), x2: px(pct - band), y1: y - 4, y2: y + 4 }), _jsx("line", { x1: px(pct + band), x2: px(pct + band), y1: y - 4, y2: y + 4 })] })), _jsx(MeasuredNode, { cx: px(pct), cy: y })] }));
|
|
20
|
+
}
|
|
21
|
+
if (props.claim === 'direction') {
|
|
22
|
+
const { direction, width = 96, claim: _c, locale: _l, ...rest } = props;
|
|
23
|
+
const cx = width / 2, cy = 44, r = 36;
|
|
24
|
+
const ang = (-90 + direction * 50) * (Math.PI / 180);
|
|
25
|
+
const words = { '-1': 'left of the meridian', '0': 'on the meridian', '1': 'right of the meridian' };
|
|
26
|
+
return (_jsxs("svg", { width: width, height: 48, viewBox: `0 0 ${width} 48`, role: "img", "aria-label": `Direction: ${words[direction]}`, "data-part": "claim-instrument", "data-claim": claim, "data-direction": direction, ...rest, children: [_jsx("path", { d: `M${cx - r} ${cy}A${r} ${r} 0 0 1 ${cx + r} ${cy}`, fill: "none", stroke: v.line2 }), _jsx("line", { x1: cx, x2: cx, y1: cy - r - 3, y2: cy - r + 5, stroke: v.text3, "data-part": "meridian" }), _jsx("line", { "data-part": "needle", x1: cx, y1: cy, x2: cx + Math.cos(ang) * (r - 6), y2: cy + Math.sin(ang) * (r - 6), stroke: v.signal, strokeWidth: 2, strokeLinecap: "round" }), _jsx("circle", { cx: cx, cy: cy, r: 2.5, fill: v.signal })] }));
|
|
27
|
+
}
|
|
28
|
+
const { rank, of, width = 160, claim: _c, locale: _l, ...rest } = props;
|
|
29
|
+
const n = Math.max(1, Math.floor(of)), k = Math.max(1, Math.min(n, Math.floor(rank)));
|
|
30
|
+
const step = n > 1 ? (width - 16) / (n - 1) : 0;
|
|
31
|
+
return (_jsxs("svg", { width: width, height: 20, viewBox: `0 0 ${width} 20`, role: "img", "aria-label": `Ranking: ${k} of ${n}`, "data-part": "claim-instrument", "data-claim": claim, ...rest, children: [_jsx("line", { x1: 8, x2: width - 8, y1: 10, y2: 10, stroke: v.line2 }), Array.from({ length: n }, (_, i) => i + 1 === k ? _jsx(MeasuredNode, { cx: 8 + i * step, cy: 10 }, i) : _jsx("rect", { x: 8 + i * step - 2, y: 8, width: 4, height: 4, fill: v.text3 }, i))] }));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ClaimInstrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaimInstrument.js","sourceRoot":"","sources":["../src/ClaimInstrument.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,aA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GAAG,IAAI,EAAE,EAAE,EAAE,EAAE,IAA3B,CAAC,CAA8B,CAAC,CAAC,CAAC,eAAc,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,IAAhE,CAAC,CAAmE,CACnJ,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
export interface CompositionRow {
|
|
3
|
+
label: string;
|
|
4
|
+
/** Published margin (target share, 0-1). */
|
|
5
|
+
margin: number;
|
|
6
|
+
/** The panel's share, 0-1. Omit before the panel is built. */
|
|
7
|
+
panel?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CompositionProps extends Omit<SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
10
|
+
margins: CompositionRow[];
|
|
11
|
+
width?: number;
|
|
12
|
+
locale?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Margins versus panel: a bar per category for the panel, a tick for the published margin. */
|
|
16
|
+
export declare function Composition({ margins, width, locale, title, ...rest }: CompositionProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Composition.d.ts","sourceRoot":"","sources":["../src/Composition.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzF,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,KAAW,EAAE,MAAa,EAAE,KAAqB,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,2CA6BpH"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatPercent } from './format.js';
|
|
3
|
+
import { v } from './tokens.js';
|
|
4
|
+
/** Margins versus panel: a bar per category for the panel, a tick for the published margin. */
|
|
5
|
+
export function Composition({ margins, width = 480, locale = 'en', title = 'Composition', ...rest }) {
|
|
6
|
+
const row = 24, labelW = Math.min(160, width * 0.35), valW = 48;
|
|
7
|
+
const barW = Math.max(40, width - labelW - valW);
|
|
8
|
+
const max = Math.max(0.0001, ...margins.flatMap((r) => [r.margin, r.panel ?? 0]));
|
|
9
|
+
const sx = (s) => labelW + (s / max) * barW;
|
|
10
|
+
const H = margins.length * row + 4;
|
|
11
|
+
const aria = `${title}: ${margins
|
|
12
|
+
.map((r) => `${r.label} margin ${formatPercent(r.margin, { locale })}${r.panel !== undefined ? `, panel ${formatPercent(r.panel, { locale })}` : ''}`)
|
|
13
|
+
.join('; ')}`;
|
|
14
|
+
return (_jsx("svg", { width: width, height: H, viewBox: `0 0 ${width} ${H}`, role: "img", "aria-label": aria, "data-part": "composition", ...rest, children: margins.map((r, i) => {
|
|
15
|
+
const y = i * row + 4;
|
|
16
|
+
return (_jsxs("g", { "data-part": "row", children: [_jsx("text", { x: 0, y: y + 12, fontSize: 12, fill: v.text2, fontFamily: v.sans, children: r.label }), _jsx("line", { x1: labelW, x2: labelW + barW, y1: y + 16.5, y2: y + 16.5, stroke: v.line1 }), r.panel !== undefined && (_jsx("rect", { "data-part": "panel", x: labelW, y: y + 5, width: Math.max(0, sx(r.panel) - labelW), height: 10, fill: v.signal })), _jsx("line", { "data-part": "margin", x1: sx(r.margin), x2: sx(r.margin), y1: y + 1, y2: y + 19, stroke: v.text1, strokeWidth: 1.5 }), _jsx("text", { x: width, y: y + 13, textAnchor: "end", fontSize: 11, fill: v.text2, fontFamily: v.mono, children: formatPercent(r.panel ?? r.margin, { locale }) })] }, r.label));
|
|
17
|
+
}) }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../src/Composition.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAiBhC,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,GAAG,aAAa,EAAE,GAAG,IAAI,EAAoB;IACnH,MAAM,GAAG,GAAG,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE,CA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GAAI,EACnF,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CACxB,4BAAgB,OAAO,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAI,CACtH,EACD,4BAAgB,QAAQ,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAI,EACzH,eAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,UAAU,EAAC,KAAK,EAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,YACxF,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAC1C,KATD,CAAC,CAAC,KAAK,CAUX,CACL,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
export interface DistributionProps extends Omit<SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
3
|
+
/** Anchor labels, step 1 first (five for Likert). */
|
|
4
|
+
anchors: string[];
|
|
5
|
+
/** Shares 0-1, one per anchor. */
|
|
6
|
+
shares: number[];
|
|
7
|
+
width?: number;
|
|
8
|
+
locale?: string;
|
|
9
|
+
/** Accessible title. */
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
/** A Likert distribution: one stacked bar on the horizon, ordinal ramp, share labels under each step. */
|
|
13
|
+
export declare function Distribution({ anchors, shares, width, locale, title, ...rest }: DistributionProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=Distribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Distribution.d.ts","sourceRoot":"","sources":["../src/Distribution.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1F,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kCAAkC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAW,EAAE,MAAa,EAAE,KAAsB,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,2CA2B/H"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatPercent } from './format.js';
|
|
3
|
+
import { likertRamp, v } from './tokens.js';
|
|
4
|
+
/** A Likert distribution: one stacked bar on the horizon, ordinal ramp, share labels under each step. */
|
|
5
|
+
export function Distribution({ anchors, shares, width = 480, locale = 'en', title = 'Distribution', ...rest }) {
|
|
6
|
+
const total = shares.reduce((s, x) => s + (Number.isFinite(x) ? Math.max(0, x) : 0), 0) || 1;
|
|
7
|
+
const H = 56, barY = 8, barH = 16;
|
|
8
|
+
let x = 0;
|
|
9
|
+
const segs = anchors.map((a, i) => {
|
|
10
|
+
const share = Math.max(0, shares[i] ?? 0);
|
|
11
|
+
const w = (share / total) * width;
|
|
12
|
+
const seg = { a, share, x, w, color: likertRamp[Math.min(i, likertRamp.length - 1)] ?? v.text3 };
|
|
13
|
+
x += w;
|
|
14
|
+
return seg;
|
|
15
|
+
});
|
|
16
|
+
const label = `${title}: ${segs.map((s) => `${s.a} ${formatPercent(s.share, { locale })}`).join(', ')}`;
|
|
17
|
+
return (_jsxs("svg", { width: width, height: H, viewBox: `0 0 ${width} ${H}`, role: "img", "aria-label": label, "data-part": "distribution", ...rest, children: [_jsx("line", { x1: 0, x2: width, y1: barY + barH + 0.5, y2: barY + barH + 0.5, stroke: v.line2, "data-part": "horizon" }), segs.map((s, i) => (_jsxs("g", { "data-part": "segment", "data-anchor": s.a, children: [_jsx("rect", { x: s.x, y: barY, width: Math.max(0, s.w - 1), height: barH, fill: s.color }), s.w >= 24 && (_jsx("text", { x: s.x + s.w / 2, y: barY + barH + 16, textAnchor: "middle", fontSize: 11, fill: v.text2, fontFamily: v.mono, children: formatPercent(s.share, { locale }) }))] }, i)))] }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Distribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Distribution.js","sourceRoot":"","sources":["../src/Distribution.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAa5C,yGAAyG;AACzG,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,GAAG,cAAc,EAAE,GAAG,IAAI,EAAqB;IAC9H,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,C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AO,KAAK,IAAI,CAAC,EAAE,EAAE,IAAI,EAAC,KAAK,gBAAa,KAAK,eAAY,cAAc,KAAK,IAAI,aACzH,eAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,eAAY,SAAS,GAAG,EAC5G,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAClB,0BAAqB,SAAS,iBAAc,CAAC,CAAC,CAAC,aAC7C,eAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,GAAI,EAClF,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CACZ,eAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE,EAAE,UAAU,EAAC,QAAQ,EAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,YAC7G,aAAa,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,GAC9B,CACR,KANK,CAAC,CAOL,CACL,CAAC,IACE,CACP,CAAC;AACJ,CAAC"}
|
package/dist/Figure.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { ClaimClass, FigureValue } from '@northstar-js/contracts';
|
|
3
|
+
export declare const CLAIM_LABEL: Record<ClaimClass, string>;
|
|
4
|
+
export interface FigureProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
5
|
+
/** The share, 0-1. */
|
|
6
|
+
value: number;
|
|
7
|
+
/** Error band in percentage points. Optional. */
|
|
8
|
+
band?: number;
|
|
9
|
+
/** Claim class label. Optional. */
|
|
10
|
+
claim?: ClaimClass;
|
|
11
|
+
/** Qualifying sentence. Optional. */
|
|
12
|
+
caption?: ReactNode;
|
|
13
|
+
state?: FigureValue['state'];
|
|
14
|
+
/** Short label above the number. */
|
|
15
|
+
label?: ReactNode;
|
|
16
|
+
locale?: string;
|
|
17
|
+
digits?: number;
|
|
18
|
+
size?: 'sm' | 'md' | 'lg';
|
|
19
|
+
/** Overrides the formatted number. */
|
|
20
|
+
format?: (value: number) => string;
|
|
21
|
+
}
|
|
22
|
+
/** One displayed figure: the number, with its band, claim class and caption when given. */
|
|
23
|
+
export declare function Figure({ value, band, claim, caption, state, label, locale, digits, size, format, style, ...rest }: FigureProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=Figure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Figure.d.ts","sourceRoot":"","sources":["../src/Figure.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAIvE,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAkE,CAAC;AAEtH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAChF,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,qCAAqC;IACrC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,sCAAsC;IACtC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAID,2FAA2F;AAC3F,wBAAgB,MAAM,CAAC,EACrB,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAY,EAAE,KAAK,EAAE,MAAa,EAAE,MAAU,EAAE,IAAW,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EACjH,EAAE,WAAW,2CA2Cb"}
|
package/dist/Figure.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatBand, formatPercent } from './format.js';
|
|
3
|
+
import { v } from './tokens.js';
|
|
4
|
+
export const CLAIM_LABEL = { level: 'Level', direction: 'Direction', ranking: 'Ranking' };
|
|
5
|
+
const SIZE = { sm: 18, md: 32, lg: 48 };
|
|
6
|
+
/** One displayed figure: the number, with its band, claim class and caption when given. */
|
|
7
|
+
export function Figure({ value, band, claim, caption, state = 'ok', label, locale = 'en', digits = 0, size = 'md', format, style, ...rest }) {
|
|
8
|
+
const withheld = state === 'withheld';
|
|
9
|
+
const stale = state === 'stale';
|
|
10
|
+
const text = withheld ? 'Withheld' : format ? format(value) : formatPercent(value, { locale, digits });
|
|
11
|
+
return (_jsxs("figure", { "data-part": "figure", "data-state": state, ...(claim ? { 'data-claim': claim } : {}), style: {
|
|
12
|
+
margin: 0, display: 'grid', gap: 4, fontFamily: v.sans, color: v.text1,
|
|
13
|
+
...(stale ? { border: `1px dashed ${v.line2}`, padding: 8, borderRadius: 6 } : {}),
|
|
14
|
+
...style,
|
|
15
|
+
}, ...rest, children: [(label !== undefined || claim || stale) && (_jsxs("div", { style: { display: 'flex', gap: 8, fontSize: 12, color: v.text2 }, children: [label !== undefined && _jsx("span", { "data-part": "label", children: label }), claim && _jsx("span", { "data-part": "claim", children: CLAIM_LABEL[claim] }), stale && _jsx("span", { "data-part": "stale", children: "Stale" })] })), _jsxs("div", { style: { display: 'flex', alignItems: 'baseline', gap: 8 }, children: [_jsx("span", { "data-part": "value", style: { fontFamily: v.mono, fontVariantNumeric: 'tabular-nums', fontSize: withheld ? 15 : SIZE[size], lineHeight: 1.1, color: withheld ? v.text3 : v.text1 }, children: text }), band !== undefined && !withheld && (_jsx("span", { "data-part": "band", style: { fontFamily: v.mono, fontSize: 13, color: v.text2 }, children: formatBand(band, { locale }) }))] }), caption !== undefined && (_jsx("figcaption", { "data-part": "caption", style: { fontSize: 12, color: v.text2 }, children: caption }))] }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Figure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Figure.js","sourceRoot":"","sources":["../src/Figure.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,MAAM,CAAC,MAAM,WAAW,GAA+B,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAqBtH,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW,CAAC;AAEjD,2FAA2F;AAC3F,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,E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AQ,EAC7D,KAAK,IAAI,4BAAgB,OAAO,YAAE,WAAW,CAAC,KAAK,CAAC,GAAQ,EAC5D,KAAK,IAAI,4BAAgB,OAAO,sBAAa,IAC1C,CACP,EACD,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,aAC7D,4BACY,OAAO,EACjB,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,YAE5J,IAAI,GACA,EACN,IAAI,KAAK,SAAS,IAAI,CAAC,QAAQ,IAAI,CAClC,4BAAgB,MAAM,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,YAC/E,UAAU,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,GACxB,CACR,IACG,EACL,OAAO,KAAK,SAAS,IAAI,CACxB,kCAAsB,SAAS,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,YACpE,OAAO,GACG,CACd,IACM,CACV,CAAC;AACJ,CAAC"}
|
package/dist/Legend.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export interface LegendItem {
|
|
3
|
+
label: string;
|
|
4
|
+
color: string;
|
|
5
|
+
/** Swatch shape. Default 'square'. */
|
|
6
|
+
shape?: 'square' | 'star' | 'line';
|
|
7
|
+
}
|
|
8
|
+
export interface LegendProps extends HTMLAttributes<HTMLUListElement> {
|
|
9
|
+
items: LegendItem[];
|
|
10
|
+
}
|
|
11
|
+
export declare function Legend({ items, style, ...rest }: LegendProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=Legend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../src/Legend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IACnE,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,2CAuB5D"}
|
package/dist/Legend.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { v } from './tokens.js';
|
|
3
|
+
export function Legend({ items, style, ...rest }) {
|
|
4
|
+
return (_jsx("ul", { "data-part": "legend", style: { display: 'flex', flexWrap: 'wrap', gap: 12, listStyle: 'none', margin: 0, padding: 0, fontSize: 12, color: v.text2, fontFamily: v.sans, ...style }, ...rest, children: items.map((it) => (_jsxs("li", { style: { display: 'inline-flex', alignItems: 'center', gap: 6 }, children: [_jsx("svg", { width: 10, height: 10, viewBox: "0 0 10 10", "aria-hidden": "true", children: it.shape === 'line' ? (_jsx("line", { x1: 0, x2: 10, y1: 5, y2: 5, stroke: it.color, strokeWidth: 2 })) : it.shape === 'star' ? (_jsx("path", { d: "M5 0L6.6 3.4L10 5L6.6 6.6L5 10L3.4 6.6L0 5L3.4 3.4Z", fill: it.color })) : (_jsx("rect", { width: 10, height: 10, fill: it.color })) }), it.label] }, it.label))) }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=Legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Legend.js","sourceRoot":"","sources":["../src/Legend.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAahC,MAAM,UAAU,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAe;IAC3D,OAAO,CACL,0BACY,QAAQ,EAClB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,EAAE,KACvJ,IAAI,YAEP,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CACjB,cAAmB,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAChF,cAAK,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAC,WAAW,iBAAa,MAAM,YAC/D,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CACrB,eAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,GAAI,CACxE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CACxB,eAAM,CAAC,EAAC,qDAAqD,EAAC,IAAI,EAAE,EAAE,CAAC,KAAK,GAAI,CACjF,CAAC,CAAC,CAAC,CACF,eAAM,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAI,CAChD,GACG,EACL,EAAE,CAAC,KAAK,KAVF,EAAE,CAAC,KAAK,CAWZ,CACN,CAAC,GACC,CACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
export interface RankingProps extends Omit<SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
3
|
+
/** Option labels in ranked order, first is top. */
|
|
4
|
+
items: string[];
|
|
5
|
+
width?: number;
|
|
6
|
+
/** Index to emphasise with the signal colour. Default 0. */
|
|
7
|
+
highlight?: number | null;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A ranking ladder: options on a spine, evenly spaced, no values. */
|
|
11
|
+
export declare function Ranking({ items, width, highlight, title, ...rest }: RankingProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=Ranking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ranking.d.ts","sourceRoot":"","sources":["../src/Ranking.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACrF,mDAAmD;IACnD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,KAAW,EAAE,SAAa,EAAE,KAAwB,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,2CAmB7G"}
|
package/dist/Ranking.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MeasuredNode } from './marks.js';
|
|
3
|
+
import { v } from './tokens.js';
|
|
4
|
+
/** A ranking ladder: options on a spine, evenly spaced, no values. */
|
|
5
|
+
export function Ranking({ items, width = 320, highlight = 0, title = 'Ranked options', ...rest }) {
|
|
6
|
+
const row = 28, H = items.length * row + 8, spineX = 28;
|
|
7
|
+
const aria = `${title}: ${items.map((it, i) => `${i + 1}. ${it}`).join(', ')}`;
|
|
8
|
+
return (_jsxs("svg", { width: width, height: H, viewBox: `0 0 ${width} ${H}`, role: "img", "aria-label": aria, "data-part": "ranking", ...rest, children: [items.length > 1 && _jsx("line", { x1: spineX, x2: spineX, y1: row / 2 + 4, y2: (items.length - 0.5) * row + 4, stroke: v.line2, "data-part": "spine" }), items.map((it, i) => {
|
|
9
|
+
const y = i * row + row / 2 + 4;
|
|
10
|
+
const on = highlight === i;
|
|
11
|
+
return (_jsxs("g", { "data-part": "rank", "data-rank": i + 1, children: [_jsx("text", { x: 0, y: y + 4, fontSize: 11, fill: v.text3, fontFamily: v.mono, children: i + 1 }), on ? _jsx(MeasuredNode, { cx: spineX, cy: y }) : _jsx("rect", { x: spineX - 3, y: y - 3, width: 6, height: 6, fill: v.text2 }), _jsx("text", { x: spineX + 14, y: y + 4, fontSize: 13, fill: on ? v.text1 : v.text2, fontFamily: v.sans, children: it })] }, `${i}-${it}`));
|
|
12
|
+
})] }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Ranking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ranking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C,MAAM,EAAE,GAAG,SAAS,KAAK,CAAC,CAAC;gBAC3B,OAAO,CACL,0BAAgC,MAAM,eAAY,CAAC,GAAG,CAAC,aACrD,eAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,YAAG,CAAC,GAAG,CAAC,GAAQ,EACpF,EAAE,CAAC,CAAC,CAAC,KAAC,YAAY,IAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAI,CAAC,CAAC,CAAC,eAAM,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,GAAI,EACjH,eAAM,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,YAAG,EAAE,GAAQ,KAHrG,GAAG,CAAC,IAAI,EAAE,EAAE,CAIhB,CACL,CAAC;YACJ,CAAC,CAAC,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export type RunProgressState = 'running' | 'complete' | 'partial' | 'failed';
|
|
3
|
+
export interface RunProgressProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** Items (or respondents) finished. */
|
|
5
|
+
done: number;
|
|
6
|
+
total: number;
|
|
7
|
+
state?: RunProgressState;
|
|
8
|
+
/** Unit label for the count, e.g. "items". */
|
|
9
|
+
unit?: string;
|
|
10
|
+
width?: number;
|
|
11
|
+
locale?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run progress: a row of stars, lit as items finish, with a word for the state. Static (nothing loops),
|
|
15
|
+
* so it is the same under reduced motion. State is told by the word and the shape, not by colour alone.
|
|
16
|
+
*/
|
|
17
|
+
export declare function RunProgress({ done, total, state, unit, width, locale, style, ...rest }: RunProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=RunProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunProgress.d.ts","sourceRoot":"","sources":["../src/RunProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK5C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7E,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACtE,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAiB,EAAE,IAAc,EAAE,KAAW,EAAE,MAAa,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,2CAqC3I"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatNumber } from './format.js';
|
|
3
|
+
import { starPath } from './marks.js';
|
|
4
|
+
import { v } from './tokens.js';
|
|
5
|
+
const WORD = { running: 'Running', complete: 'Complete', partial: 'Partial', failed: 'Failed' };
|
|
6
|
+
/**
|
|
7
|
+
* Run progress: a row of stars, lit as items finish, with a word for the state. Static (nothing loops),
|
|
8
|
+
* so it is the same under reduced motion. State is told by the word and the shape, not by colour alone.
|
|
9
|
+
*/
|
|
10
|
+
export function RunProgress({ done, total, state = 'running', unit = 'items', width = 240, locale = 'en', style, ...rest }) {
|
|
11
|
+
const t = Math.max(0, Math.floor(total));
|
|
12
|
+
const d = Math.max(0, Math.min(t, Math.floor(done)));
|
|
13
|
+
const slots = Math.min(t, 24);
|
|
14
|
+
const lit = t ? Math.round((d / t) * slots) : 0;
|
|
15
|
+
const step = slots > 1 ? (width - 8) / (slots - 1) : 0;
|
|
16
|
+
return (_jsxs("div", { role: "progressbar", "aria-valuemin": 0, "aria-valuemax": t, "aria-valuenow": d, "aria-valuetext": `${WORD[state]}: ${formatNumber(d, { locale })} of ${formatNumber(t, { locale })} ${unit}`, "data-part": "run-progress", "data-state": state, style: { display: 'grid', gap: 6, fontFamily: v.sans, ...style }, ...rest, children: [_jsx("svg", { width: width, height: 12, viewBox: `0 0 ${width} 12`, "aria-hidden": "true", children: Array.from({ length: slots }, (_, i) => {
|
|
17
|
+
const on = i < lit;
|
|
18
|
+
const failedHere = state === 'failed' && i === lit;
|
|
19
|
+
return failedHere ? (_jsx("path", { d: `M${4 + i * step - 3} 3L${4 + i * step + 3} 9M${4 + i * step + 3} 3L${4 + i * step - 3} 9`, stroke: v.text2, strokeWidth: 1.5, "data-mark": "failed" }, i)) : (_jsx("path", { d: starPath(4 + i * step, 6, on ? 4 : 2.5), fill: on ? v.signal : v.line2, "data-mark": on ? 'done' : 'pending' }, i));
|
|
20
|
+
}) }), _jsxs("div", { style: { display: 'flex', gap: 8, fontSize: 12, color: v.text2 }, children: [_jsx("span", { "data-part": "state", children: WORD[state] }), _jsxs("span", { style: { fontFamily: v.mono, fontVariantNumeric: 'tabular-nums' }, children: [formatNumber(d, { locale }), " / ", formatNumber(t, { locale }), " ", unit] })] })] }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=RunProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunProgress.js","sourceRoot":"","sources":["../src/RunProgress.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAehC,MAAM,IAAI,GAAqC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAElI;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,IAAI,GAAG,OAAO,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAoB;IAC1I,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAA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AG,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,eAAa,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAhH,CAAC,CAAmH,CAChI,CAAC;gBACJ,CAAC,CAAC,GACE,EACN,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,aACnE,4BAAgB,OAAO,YAAE,IAAI,CAAC,KAAK,CAAC,GAAQ,EAC5C,gBAAM,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,aACpE,YAAY,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,SAAK,YAAY,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,OAAG,IAAI,IAC9D,IACH,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Whether the tooltip is shown. Controlled: charts hold no hover state. */
|
|
4
|
+
open?: boolean;
|
|
5
|
+
/** Position in px relative to the positioned chart container. */
|
|
6
|
+
x?: number;
|
|
7
|
+
y?: number;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** A chart tooltip. Stateless and server-safe; the caller decides when it is open and where. */
|
|
11
|
+
export declare function Tooltip({ open, x, y, children, style, ...rest }: TooltipProps): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,cAAc,CAAC;IAClE,4EAA4E;IAC5E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iEAAiE;IACjE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,gGAAgG;AAChG,wBAAgB,OAAO,CAAC,EAAE,IAAY,EAAE,CAAK,EAAE,CAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,kDA4B7F"}
|
package/dist/Tooltip.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { v } from './tokens.js';
|
|
3
|
+
/** A chart tooltip. Stateless and server-safe; the caller decides when it is open and where. */
|
|
4
|
+
export function Tooltip({ open = false, x = 0, y = 0, children, style, ...rest }) {
|
|
5
|
+
if (!open)
|
|
6
|
+
return null;
|
|
7
|
+
return (_jsx("div", { role: "tooltip", "data-part": "tooltip", style: {
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
left: x,
|
|
10
|
+
top: y,
|
|
11
|
+
transform: 'translate(-50%, calc(-100% - 8px))',
|
|
12
|
+
pointerEvents: 'none',
|
|
13
|
+
zIndex: 90,
|
|
14
|
+
background: v.surface2,
|
|
15
|
+
color: v.text1,
|
|
16
|
+
border: `1px solid ${v.line2}`,
|
|
17
|
+
borderRadius: 6,
|
|
18
|
+
padding: '4px 8px',
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
fontFamily: v.sans,
|
|
21
|
+
whiteSpace: 'nowrap',
|
|
22
|
+
...style,
|
|
23
|
+
}, ...rest, children: children }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAWhC,gGAAgG;AAChG,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAgB;IAC5F,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACL,cACE,IAAI,EAAC,SAAS,eACJ,SAAS,EACnB,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,CAAC;YACN,SAAS,EAAE,oCAAoC;YAC/C,aAAa,EAAE,MAAM;YACrB,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,CAAC,CAAC,QAAQ;YACtB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE;YAC9B,YAAY,EAAE,CAAC;YACf,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,CAAC,CAAC,IAAI;YAClB,UAAU,EAAE,QAAQ;YACpB,GAAG,KAAK;SACT,KACG,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number formatting for figures. Locale-aware through Intl; English ('en') is the default.
|
|
3
|
+
* Shares are fractions (0.42); points and bands are percentage points (6 -> "6 pp").
|
|
4
|
+
*/
|
|
5
|
+
export interface FormatOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** Fraction digits. Default 0. */
|
|
8
|
+
digits?: number;
|
|
9
|
+
}
|
|
10
|
+
/** A share (0-1) as a percentage: 0.42 -> "42%". */
|
|
11
|
+
export declare function formatPercent(share: number, { locale, digits }?: FormatOptions): string;
|
|
12
|
+
/** Percentage points: 6 -> "6 pp"; with `sign`, 1.5 -> "+1.5 pp". */
|
|
13
|
+
export declare function formatPoints(pp: number, { locale, digits, sign }?: FormatOptions & {
|
|
14
|
+
sign?: boolean;
|
|
15
|
+
}): string;
|
|
16
|
+
/** A band in percentage points: 6 -> "± 6 pp". */
|
|
17
|
+
export declare function formatBand(pp: number, opts?: FormatOptions): string;
|
|
18
|
+
/** A plain count: 1200 -> "1,200". */
|
|
19
|
+
export declare function formatNumber(n: number, { locale, digits }?: FormatOptions): string;
|
|
20
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgBD,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAa,EAAE,MAAU,EAAE,GAAE,aAAkB,GAAG,MAAM,CAKtG;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,EAAE,MAAa,EAAE,MAAU,EAAE,IAAY,EAAE,GAAE,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GACnF,MAAM,CAUR;AAED,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAEvE;AAED,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,MAAa,EAAE,MAAU,EAAE,GAAE,aAAkB,GAAG,MAAM,CAGjG"}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const cache = new Map();
|
|
2
|
+
function nf(locale, opts) {
|
|
3
|
+
const key = locale + JSON.stringify(opts);
|
|
4
|
+
let f = cache.get(key);
|
|
5
|
+
if (!f) {
|
|
6
|
+
f = new Intl.NumberFormat(locale, opts);
|
|
7
|
+
cache.set(key, f);
|
|
8
|
+
}
|
|
9
|
+
return f;
|
|
10
|
+
}
|
|
11
|
+
const MINUS = '−';
|
|
12
|
+
const NBSP = ' ';
|
|
13
|
+
/** A share (0-1) as a percentage: 0.42 -> "42%". */
|
|
14
|
+
export function formatPercent(share, { locale = 'en', digits = 0 } = {}) {
|
|
15
|
+
if (!Number.isFinite(share))
|
|
16
|
+
return '–';
|
|
17
|
+
return nf(locale, { style: 'percent', minimumFractionDigits: digits, maximumFractionDigits: digits })
|
|
18
|
+
.format(share)
|
|
19
|
+
.replace('-', MINUS);
|
|
20
|
+
}
|
|
21
|
+
/** Percentage points: 6 -> "6 pp"; with `sign`, 1.5 -> "+1.5 pp". */
|
|
22
|
+
export function formatPoints(pp, { locale = 'en', digits = 0, sign = false } = {}) {
|
|
23
|
+
if (!Number.isFinite(pp))
|
|
24
|
+
return '–';
|
|
25
|
+
const s = nf(locale, {
|
|
26
|
+
minimumFractionDigits: digits,
|
|
27
|
+
maximumFractionDigits: digits,
|
|
28
|
+
signDisplay: sign ? 'exceptZero' : 'auto',
|
|
29
|
+
})
|
|
30
|
+
.format(pp)
|
|
31
|
+
.replace('-', MINUS);
|
|
32
|
+
return `${s}${NBSP}pp`;
|
|
33
|
+
}
|
|
34
|
+
/** A band in percentage points: 6 -> "± 6 pp". */
|
|
35
|
+
export function formatBand(pp, opts = {}) {
|
|
36
|
+
return `±${NBSP}${formatPoints(Math.abs(pp), opts)}`;
|
|
37
|
+
}
|
|
38
|
+
/** A plain count: 1200 -> "1,200". */
|
|
39
|
+
export function formatNumber(n, { locale = 'en', digits = 0 } = {}) {
|
|
40
|
+
if (!Number.isFinite(n))
|
|
41
|
+
return '–';
|
|
42
|
+
return nf(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n).replace('-', MINUS);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAUA,MAAM,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;AACnD,SAAS,EAAE,CAAC,MAAc,EAAE,IAA8B;IACxD,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC,KAAoB,EAAE;IAC5F,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC;SAClG,MAAM,CAAC,KAAK,CAAC;SACb,OAAO,CAAC,GAAG,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IM_LABEL, type FigureProps } from './Figure.js';
|
|
2
|
+
export { Distribution, type DistributionProps } from './Distribution.js';
|
|
3
|
+
export { Composition, type CompositionProps, type CompositionRow } from './Composition.js';
|
|
4
|
+
export { Ranking, type RankingProps } from './Ranking.js';
|
|
5
|
+
export { ClaimInstrument, type ClaimInstrumentProps, type LevelInstrument, type DirectionInstrument, type RankingInstrument, } from './ClaimInstrument.js';
|
|
6
|
+
export { RunProgress, type RunProgressProps, type RunProgressState } from './RunProgress.js';
|
|
7
|
+
export { Axis, type AxisProps } from './Axis.js';
|
|
8
|
+
export { Legend, type LegendProps, type LegendItem } from './Legend.js';
|
|
9
|
+
export { Tooltip, type TooltipProps } from './Tooltip.js';
|
|
10
|
+
export { AgentStar, MeasuredNode, starPath, type AgentStarProps, type MeasuredNodeProps } from './marks.js';
|
|
11
|
+
export { likertRamp } from './tokens.js';
|
|
12
|
+
export * from './format.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Figure, CLAIM_LABEL } from './Figure.js';
|
|
2
|
+
export { Distribution } from './Distribution.js';
|
|
3
|
+
export { Composition } from './Composition.js';
|
|
4
|
+
export { Ranking } from './Ranking.js';
|
|
5
|
+
export { ClaimInstrument, } from './ClaimInstrument.js';
|
|
6
|
+
export { RunProgress } from './RunProgress.js';
|
|
7
|
+
export { Axis } from './Axis.js';
|
|
8
|
+
export { Legend } from './Legend.js';
|
|
9
|
+
export { Tooltip } from './Tooltip.js';
|
|
10
|
+
export { AgentStar, MeasuredNode, starPath } from './marks.js';
|
|
11
|
+
export { likertRamp } from './tokens.js';
|
|
12
|
+
export * from './format.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAA0B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,WAAW,EAA8C,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,eAAe,GAKhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAgD,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAkB,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,EAAqC,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAA+C,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
package/dist/marks.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
/** Four-point star path centred on (cx, cy) with outer radius r. */
|
|
3
|
+
export declare function starPath(cx: number, cy: number, r: number): string;
|
|
4
|
+
export type AgentStarProps = {
|
|
5
|
+
cx: number;
|
|
6
|
+
cy: number;
|
|
7
|
+
r?: number;
|
|
8
|
+
} & Omit<SVGProps<SVGPathElement>, 'd'>;
|
|
9
|
+
/** An agent: a small four-point star. */
|
|
10
|
+
export declare function AgentStar({ cx, cy, r, ...rest }: AgentStarProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export type MeasuredNodeProps = {
|
|
12
|
+
cx: number;
|
|
13
|
+
cy: number;
|
|
14
|
+
size?: number;
|
|
15
|
+
} & SVGProps<SVGRectElement>;
|
|
16
|
+
/** A measured value: a filled square node in the signal colour. */
|
|
17
|
+
export declare function MeasuredNode({ cx, cy, size, ...rest }: MeasuredNodeProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../src/marks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC;AAE1G,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAK,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,2CAEnE;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AAErG,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,2CAE5E"}
|
package/dist/marks.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { v } from './tokens.js';
|
|
3
|
+
/** Four-point star path centred on (cx, cy) with outer radius r. */
|
|
4
|
+
export function starPath(cx, cy, r) {
|
|
5
|
+
const i = r * 0.32;
|
|
6
|
+
const p = (x, y) => `${+(cx + x).toFixed(2)} ${+(cy + y).toFixed(2)}`;
|
|
7
|
+
return `M${p(0, -r)}L${p(i, -i)}L${p(r, 0)}L${p(i, i)}L${p(0, r)}L${p(-i, i)}L${p(-r, 0)}L${p(-i, -i)}Z`;
|
|
8
|
+
}
|
|
9
|
+
/** An agent: a small four-point star. */
|
|
10
|
+
export function AgentStar({ cx, cy, r = 3, ...rest }) {
|
|
11
|
+
return _jsx("path", { d: starPath(cx, cy, r), fill: v.text1, "data-mark": "agent", ...rest });
|
|
12
|
+
}
|
|
13
|
+
/** A measured value: a filled square node in the signal colour. */
|
|
14
|
+
export function MeasuredNode({ cx, cy, size = 7, ...rest }) {
|
|
15
|
+
return _jsx("rect", { x: cx - size / 2, y: cy - size / 2, width: size, height: size, fill: v.signal, "data-mark": "node", ...rest });
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.js","sourceRoot":"","sources":["../src/marks.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CAAC,EAAU,EAAE,EAAU,EAAE,CAAS;IACxD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAC3G,CAAC;AAID,yCAAyC;AACzC,MAAM,UAAU,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAkB;IAClE,OAAO,eAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,eAAY,OAAO,KAAK,IAAI,GAAI,CAAC;AACrF,CAAC;AAID,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,EAAqB;IAC3E,OAAO,eAAM,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,eAAY,MAAM,KAAK,IAAI,GAAI,CAAC;AAC5H,CAAC"}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** CSS variables used by charts. */
|
|
2
|
+
export declare const v: {
|
|
3
|
+
readonly signal: string;
|
|
4
|
+
readonly signalWash: string;
|
|
5
|
+
readonly signalEdge: string;
|
|
6
|
+
readonly text1: string;
|
|
7
|
+
readonly text2: string;
|
|
8
|
+
readonly text3: string;
|
|
9
|
+
readonly line1: string;
|
|
10
|
+
readonly line2: string;
|
|
11
|
+
readonly surface2: string;
|
|
12
|
+
readonly mono: "var(--ns-font-mono, \"IBM Plex Mono\", ui-monospace, monospace)";
|
|
13
|
+
readonly sans: "var(--ns-font-sans, Inter, system-ui, sans-serif)";
|
|
14
|
+
};
|
|
15
|
+
/** Ordinal Likert ramp, five steps (color.data.likert.1-5). */
|
|
16
|
+
export declare const likertRamp: readonly [string, string, string, string, string];
|
|
17
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAKA,oCAAoC;AACpC,eAAO,MAAM,CAAC;;;;;;;;;;;;CAYJ,CAAC;AAEX,+DAA+D;AAC/D,eAAO,MAAM,UAAU,mDAMb,CAAC"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cssVar, tokens } from '@northstar-js/tokens';
|
|
2
|
+
/** var(--ns-…, <Night value>) from @northstar-js/tokens, so a chart renders even without tokens.css. */
|
|
3
|
+
const ref = (path) => `var(${cssVar[path]}, ${tokens.themes.night[path]})`;
|
|
4
|
+
/** CSS variables used by charts. */
|
|
5
|
+
export const v = {
|
|
6
|
+
signal: ref('color.signal.default'),
|
|
7
|
+
signalWash: ref('color.signal.wash'),
|
|
8
|
+
signalEdge: ref('color.signal.edge'),
|
|
9
|
+
text1: ref('color.text.1'),
|
|
10
|
+
text2: ref('color.text.2'),
|
|
11
|
+
text3: ref('color.text.3'),
|
|
12
|
+
line1: ref('color.line.1'),
|
|
13
|
+
line2: ref('color.line.2'),
|
|
14
|
+
surface2: ref('color.surface.2'),
|
|
15
|
+
mono: 'var(--ns-font-mono, "IBM Plex Mono", ui-monospace, monospace)',
|
|
16
|
+
sans: 'var(--ns-font-sans, Inter, system-ui, sans-serif)',
|
|
17
|
+
};
|
|
18
|
+
/** Ordinal Likert ramp, five steps (color.data.likert.1-5). */
|
|
19
|
+
export const likertRamp = [
|
|
20
|
+
ref('color.data.likert.1'),
|
|
21
|
+
ref('color.data.likert.2'),
|
|
22
|
+
ref('color.data.likert.3'),
|
|
23
|
+
ref('color.data.likert.4'),
|
|
24
|
+
ref('color.data.likert.5'),
|
|
25
|
+
];
|
|
26
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,sBAAsB,CAAC;AAE3E,wGAAwG;AACxG,MAAM,GAAG,GAAG,CAAC,IAAoB,EAAU,EAAE,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AAEnG,oCAAoC;AACpC,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,MAAM,EAAE,GAAG,CAAC,sBAAsB,CAAC;IACnC,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC;IACpC,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC;IACpC,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;IAC1B,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAChC,IAAI,EAAE,+DAA+D;IACrE,IAAI,EAAE,mDAAmD;CACjD,CAAC;AAEX,+DAA+D;AAC/D,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,CAAC,qBAAqB,CAAC;IAC1B,GAAG,CAAC,qBAAqB,CAAC;IAC1B,GAAG,CAAC,qBAAqB,CAAC;IAC1B,GAAG,CAAC,qBAAqB,CAAC;IAC1B,GAAG,CAAC,qBAAqB,CAAC;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@northstar-js/charts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Star-native figures and data visualisation for Northstar: React SVG components styled by --ns-* CSS variables.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./format": {
|
|
22
|
+
"types": "./dist/format.d.ts",
|
|
23
|
+
"import": "./dist/format.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@northstar-js/contracts": "0.2.0",
|
|
28
|
+
"@northstar-js/tokens": "0.2.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@testing-library/dom": "10.4.0",
|
|
35
|
+
"@testing-library/react": "16.3.0",
|
|
36
|
+
"@types/react": "19.1.8",
|
|
37
|
+
"@types/react-dom": "19.1.6",
|
|
38
|
+
"jsdom": "26.1.0",
|
|
39
|
+
"react": "19.1.0",
|
|
40
|
+
"react-dom": "19.1.0",
|
|
41
|
+
"typescript": "5.9.3",
|
|
42
|
+
"vitest": "3.2.7"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/ali-amaan/northstar-design-system.git",
|
|
47
|
+
"directory": "packages/charts"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://ali-amaan.github.io/northstar-design-system/",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/ali-amaan/northstar-design-system/issues"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc -p tsconfig.build.json",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"test": "vitest run"
|
|
57
|
+
}
|
|
6
58
|
}
|
package/README.md
DELETED