@seekalfred/primitives 0.7.1 → 0.7.4
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 +255 -5
- package/dist/alert/alert.d.ts +49 -4
- package/dist/alert/alert.js +66 -38
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/index.d.ts +2 -2
- package/dist/alert/index.js +2 -2
- package/dist/alert-dialog/alert-dialog.d.ts +31 -4
- package/dist/alert-dialog/alert-dialog.js +75 -26
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/announcement-bar/announcement-bar.d.ts +15 -4
- package/dist/announcement-bar/announcement-bar.js +31 -6
- package/dist/announcement-bar/announcement-bar.js.map +1 -1
- package/dist/avatar/avatar.d.ts +7 -0
- package/dist/avatar/avatar.js +33 -12
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +1 -1
- package/dist/bar-chart/bar-chart-series.d.ts +75 -0
- package/dist/bar-chart/bar-chart-series.js +401 -0
- package/dist/bar-chart/bar-chart-series.js.map +1 -0
- package/dist/bar-chart/bar-chart.d.ts +25 -1
- package/dist/bar-chart/bar-chart.js +26 -1
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -1
- package/dist/button/button.d.ts +1 -1
- package/dist/calendar/calendar.d.ts +1 -1
- package/dist/card/card.d.ts +22 -1
- package/dist/card/card.js +60 -7
- package/dist/card/card.js.map +1 -1
- package/dist/carousel/carousel.d.ts +21 -0
- package/dist/carousel/carousel.js +34 -8
- package/dist/carousel/carousel.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +11 -0
- package/dist/chip-group/chip-group.js +50 -34
- package/dist/chip-group/chip-group.js.map +1 -1
- package/dist/chip-group/index.d.ts +2 -2
- package/dist/copy-button/copy-button.d.ts +37 -5
- package/dist/copy-button/copy-button.js +35 -11
- package/dist/copy-button/copy-button.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +22 -0
- package/dist/donut-chart/donut-chart.js +35 -18
- package/dist/donut-chart/donut-chart.js.map +1 -1
- package/dist/donut-chart/index.d.ts +2 -2
- package/dist/empty-state/empty-state.d.ts +21 -0
- package/dist/empty-state/empty-state.js +16 -4
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/empty-state/index.d.ts +2 -2
- package/dist/empty-state/index.js +2 -2
- package/dist/file-drop-zone/file-drop-zone.d.ts +29 -3
- package/dist/file-drop-zone/file-drop-zone.js +26 -8
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/filter-bar/filter-bar.d.ts +4 -1
- package/dist/filter-bar/filter-bar.js +53 -9
- package/dist/filter-bar/filter-bar.js.map +1 -1
- package/dist/gauge/gauge.d.ts +18 -1
- package/dist/gauge/gauge.js +35 -21
- package/dist/gauge/gauge.js.map +1 -1
- package/dist/gauge/index.d.ts +2 -2
- package/dist/index.d.ts +15 -14
- package/dist/index.js +9 -9
- package/dist/input/input.d.ts +7 -0
- package/dist/input/input.js +7 -5
- package/dist/input/input.js.map +1 -1
- package/dist/lib/field-shell.js +6 -3
- package/dist/lib/field-shell.js.map +1 -1
- package/dist/lib/field-surface.js +22 -1
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/required-marker.js +20 -0
- package/dist/lib/required-marker.js.map +1 -0
- package/dist/lib/use-copy-feedback.js +17 -3
- package/dist/lib/use-copy-feedback.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -2
- package/dist/line-chart/line-chart.d.ts +144 -2
- package/dist/line-chart/line-chart.js +314 -46
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -2
- package/dist/money-input/money-input.d.ts +36 -1
- package/dist/money-input/money-input.js +30 -14
- package/dist/money-input/money-input.js.map +1 -1
- package/dist/morph-select/morph-select.d.ts +26 -1
- package/dist/morph-select/morph-select.js +28 -6
- package/dist/morph-select/morph-select.js.map +1 -1
- package/dist/multi-select/index.d.ts +2 -2
- package/dist/multi-select/index.js +2 -2
- package/dist/multi-select/multi-select.d.ts +74 -2
- package/dist/multi-select/multi-select.js +213 -39
- package/dist/multi-select/multi-select.js.map +1 -1
- package/dist/password-field/password-field.d.ts +16 -0
- package/dist/password-field/password-field.js +37 -8
- package/dist/password-field/password-field.js.map +1 -1
- package/dist/popover/index.d.ts +2 -2
- package/dist/popover/index.js +2 -2
- package/dist/popover/popover.d.ts +39 -2
- package/dist/popover/popover.js +29 -2
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/index.js +2 -2
- package/dist/progress/progress.d.ts +68 -3
- package/dist/progress/progress.js +156 -39
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/index.d.ts +2 -2
- package/dist/radio-group/index.js +2 -2
- package/dist/radio-group/radio-group.d.ts +33 -3
- package/dist/radio-group/radio-group.js +109 -9
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/scroll-area/scroll-area.js +4 -3
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/scrub-input.d.ts +11 -1
- package/dist/scrub-input/scrub-input.js +22 -10
- package/dist/scrub-input/scrub-input.js.map +1 -1
- package/dist/search-field/search-field.d.ts +22 -1
- package/dist/search-field/search-field.js +22 -7
- package/dist/search-field/search-field.js.map +1 -1
- package/dist/select/select.d.ts +10 -1
- package/dist/select/select.js +11 -8
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +21 -9
- package/dist/separator/separator.js +33 -11
- package/dist/separator/separator.js.map +1 -1
- package/dist/sparkline/sparkline.d.ts +27 -2
- package/dist/sparkline/sparkline.js +115 -18
- package/dist/sparkline/sparkline.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +65 -1
- package/dist/stat-card/stat-card.js +98 -25
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +115 -5
- package/dist/table/table.js +374 -94
- package/dist/table/table.js.map +1 -1
- package/dist/text-shimmer/text-shimmer.d.ts +18 -2
- package/dist/text-shimmer/text-shimmer.js +5 -2
- package/dist/text-shimmer/text-shimmer.js.map +1 -1
- package/dist/textarea/textarea.d.ts +7 -0
- package/dist/textarea/textarea.js +3 -1
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/time-picker/time-picker.d.ts +36 -1
- package/dist/time-picker/time-picker.js +33 -5
- package/dist/time-picker/time-picker.js.map +1 -1
- package/dist/toast/toast.d.ts +2 -2
- package/dist/usage-meter/index.d.ts +2 -2
- package/dist/usage-meter/usage-meter.d.ts +30 -0
- package/dist/usage-meter/usage-meter.js +56 -38
- package/dist/usage-meter/usage-meter.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/lib/required-marker.tsx
|
|
3
|
+
/**
|
|
4
|
+
* The required marker after a field's label: one red asterisk, the same in
|
|
5
|
+
* every field (FieldShell's, and Select's own label). Decoration only
|
|
6
|
+
* (aria-hidden): the control's own `required` is what a screen reader
|
|
7
|
+
* announces, so the name stays "Email", not "Email star".
|
|
8
|
+
*/
|
|
9
|
+
function RequiredMarker() {
|
|
10
|
+
return /* @__PURE__ */ jsx("span", {
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
"data-slot": "field-required",
|
|
13
|
+
className: "-ms-1 text-destructive-strong",
|
|
14
|
+
children: "*"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { RequiredMarker };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=required-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-marker.js","names":[],"sources":["../../src/lib/required-marker.tsx"],"sourcesContent":["/**\n * The required marker after a field's label: one red asterisk, the same in\n * every field (FieldShell's, and Select's own label). Decoration only\n * (aria-hidden): the control's own `required` is what a screen reader\n * announces, so the name stays \"Email\", not \"Email star\".\n */\nexport function RequiredMarker() {\n return (\n <span aria-hidden=\"true\" data-slot=\"field-required\" className=\"-ms-1 text-destructive-strong\">\n *\n </span>\n );\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,iBAAiB;CAC/B,OACE,oBAAC,QAAD;EAAM,eAAY;EAAO,aAAU;EAAiB,WAAU;EAAgC,UAAA;CAExF,CAAA;AAEV"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
//#region src/lib/use-copy-feedback.ts
|
|
3
|
+
/**
|
|
4
|
+
* Runs a consumer's callback so that a throw inside it cannot reject the
|
|
5
|
+
* promise our press handler fires and forgets (an unhandled rejection). The
|
|
6
|
+
* error is reported the way an uncaught one would be, so it still shows up.
|
|
7
|
+
*/
|
|
8
|
+
function callSafely(callback) {
|
|
9
|
+
try {
|
|
10
|
+
callback();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (typeof globalThis.reportError === "function") globalThis.reportError(error);
|
|
13
|
+
else console.error(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
3
16
|
/** Clipboard state for actions that render their own button: copy, show copied or failed for a while, then go back to idle. */
|
|
4
17
|
function useCopyFeedback(duration = 1900) {
|
|
5
18
|
const [state, setState] = useState("idle");
|
|
@@ -14,16 +27,17 @@ function useCopyFeedback(duration = 1900) {
|
|
|
14
27
|
}, []);
|
|
15
28
|
return {
|
|
16
29
|
state,
|
|
17
|
-
copy: useCallback(async (value) => {
|
|
30
|
+
copy: useCallback(async (value, onError) => {
|
|
18
31
|
if (timeout.current) clearTimeout(timeout.current);
|
|
19
32
|
try {
|
|
20
33
|
await navigator.clipboard.writeText(value);
|
|
21
34
|
setState("copied");
|
|
22
35
|
timeout.current = setTimeout(reset, duration);
|
|
23
36
|
return true;
|
|
24
|
-
} catch {
|
|
37
|
+
} catch (error) {
|
|
25
38
|
setState("error");
|
|
26
39
|
timeout.current = setTimeout(reset, duration);
|
|
40
|
+
callSafely(() => onError?.(error));
|
|
27
41
|
return false;
|
|
28
42
|
}
|
|
29
43
|
}, [duration, reset]),
|
|
@@ -31,6 +45,6 @@ function useCopyFeedback(duration = 1900) {
|
|
|
31
45
|
};
|
|
32
46
|
}
|
|
33
47
|
//#endregion
|
|
34
|
-
export { useCopyFeedback };
|
|
48
|
+
export { callSafely, useCopyFeedback };
|
|
35
49
|
|
|
36
50
|
//# sourceMappingURL=use-copy-feedback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-copy-feedback.js","names":[],"sources":["../../src/lib/use-copy-feedback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type CopyFeedbackState = \"idle\" | \"copied\" | \"error\";\n\n/** Clipboard state for actions that render their own button: copy, show copied or failed for a while, then go back to idle. */\nexport function useCopyFeedback(duration = 1900) {\n const [state, setState] = useState<CopyFeedbackState>(\"idle\");\n const timeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const reset = useCallback(() => {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = null;\n setState(\"idle\");\n }, []);\n\n useEffect(\n () => () => {\n if (timeout.current) clearTimeout(timeout.current);\n },\n [],\n );\n\n /** Resolves true if the text reached the clipboard. */\n const copy = useCallback(\n async (value: string) => {\n if (timeout.current) clearTimeout(timeout.current);\n try {\n await navigator.clipboard.writeText(value);\n setState(\"copied\");\n timeout.current = setTimeout(reset, duration);\n return true;\n } catch {\n setState(\"error\");\n timeout.current = setTimeout(reset, duration);\n return false;\n }\n },\n [duration, reset],\n );\n\n return { state, copy, reset };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-copy-feedback.js","names":[],"sources":["../../src/lib/use-copy-feedback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type CopyFeedbackState = \"idle\" | \"copied\" | \"error\";\n\n/**\n * Runs a consumer's callback so that a throw inside it cannot reject the\n * promise our press handler fires and forgets (an unhandled rejection). The\n * error is reported the way an uncaught one would be, so it still shows up.\n */\nexport function callSafely(callback: () => void) {\n try {\n callback();\n } catch (error) {\n if (typeof globalThis.reportError === \"function\") globalThis.reportError(error);\n else console.error(error);\n }\n}\n\n/** Clipboard state for actions that render their own button: copy, show copied or failed for a while, then go back to idle. */\nexport function useCopyFeedback(duration = 1900) {\n const [state, setState] = useState<CopyFeedbackState>(\"idle\");\n const timeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const reset = useCallback(() => {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = null;\n setState(\"idle\");\n }, []);\n\n useEffect(\n () => () => {\n if (timeout.current) clearTimeout(timeout.current);\n },\n [],\n );\n\n /** Resolves true if the text reached the clipboard. `onError` gets whatever the clipboard rejected with. */\n const copy = useCallback(\n async (value: string, onError?: (error: unknown) => void) => {\n if (timeout.current) clearTimeout(timeout.current);\n try {\n await navigator.clipboard.writeText(value);\n setState(\"copied\");\n timeout.current = setTimeout(reset, duration);\n return true;\n } catch (error) {\n setState(\"error\");\n timeout.current = setTimeout(reset, duration);\n callSafely(() => onError?.(error));\n return false;\n }\n },\n [duration, reset],\n );\n\n return { state, copy, reset };\n}\n"],"mappings":";;;;;;;AASA,SAAgB,WAAW,UAAsB;CAC/C,IAAI;EACF,SAAS;CACX,SAAS,OAAO;EACd,IAAI,OAAO,WAAW,gBAAgB,YAAY,WAAW,YAAY,KAAK;OACzE,QAAQ,MAAM,KAAK;CAC1B;AACF;;AAGA,SAAgB,gBAAgB,WAAW,MAAM;CAC/C,MAAM,CAAC,OAAO,YAAY,SAA4B,MAAM;CAC5D,MAAM,UAAU,OAA6C,IAAI;CAEjE,MAAM,QAAQ,kBAAkB;EAC9B,IAAI,QAAQ,SAAS,aAAa,QAAQ,OAAO;EACjD,QAAQ,UAAU;EAClB,SAAS,MAAM;CACjB,GAAG,CAAC,CAAC;CAEL,sBACc;EACV,IAAI,QAAQ,SAAS,aAAa,QAAQ,OAAO;CACnD,GACA,CAAC,CACH;CAqBA,OAAO;EAAE;EAAO,MAlBH,YACX,OAAO,OAAe,YAAuC;GAC3D,IAAI,QAAQ,SAAS,aAAa,QAAQ,OAAO;GACjD,IAAI;IACF,MAAM,UAAU,UAAU,UAAU,KAAK;IACzC,SAAS,QAAQ;IACjB,QAAQ,UAAU,WAAW,OAAO,QAAQ;IAC5C,OAAO;GACT,SAAS,OAAO;IACd,SAAS,OAAO;IAChB,QAAQ,UAAU,WAAW,OAAO,QAAQ;IAC5C,iBAAiB,UAAU,KAAK,CAAC;IACjC,OAAO;GACT;EACF,GACA,CAAC,UAAU,KAAK,CAGC;EAAG;CAAM;AAC9B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LINE_CHART_DRAW_MS, LineChart, LineChartDatum, LineChartProps, LineChartSeries } from "./line-chart.js";
|
|
2
|
-
export { LINE_CHART_DRAW_MS, LineChart, type LineChartDatum, type LineChartProps, type LineChartSeries };
|
|
1
|
+
import { LINE_CHART_DRAW_MS, LineChart, LineChartBand, LineChartDatum, LineChartMarker, LineChartProps, LineChartReference, LineChartSeries, LineChartTone, LineChartTooltipContext } from "./line-chart.js";
|
|
2
|
+
export { LINE_CHART_DRAW_MS, LineChart, type LineChartBand, type LineChartDatum, type LineChartMarker, type LineChartProps, type LineChartReference, type LineChartSeries, type LineChartTone, type LineChartTooltipContext };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
//#region src/line-chart/line-chart.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* LineChart: one or more measures over time, when the shape of the trend
|
|
@@ -26,6 +27,19 @@ export interface LineChartSeries {
|
|
|
26
27
|
dashed?: boolean;
|
|
27
28
|
/** A faint fill under the line. Defaults to true for the first series. */
|
|
28
29
|
area?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Prints each value above its point, read with `formatValue` (without `unit`).
|
|
32
|
+
* A missing value (with `missing` `"gap"` or `"connect"`) has no label. For a
|
|
33
|
+
* few points: labels on a dense line collide.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
pointLabels?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* A label above the series' last point with a value. `true` prints that value
|
|
39
|
+
* (read with `formatValue`, without `unit`); a string prints the text, such as
|
|
40
|
+
* "Heading for 1,800", and is read in the chart's summary.
|
|
41
|
+
*/
|
|
42
|
+
endLabel?: boolean | string;
|
|
29
43
|
}
|
|
30
44
|
export interface LineChartDatum {
|
|
31
45
|
/** Stable identity, such as an ISO date. */
|
|
@@ -34,8 +48,91 @@ export interface LineChartDatum {
|
|
|
34
48
|
label: string;
|
|
35
49
|
/** Short label on the x axis. Leave it out to keep the axis quiet at that point. */
|
|
36
50
|
axisLabel?: string;
|
|
37
|
-
/**
|
|
38
|
-
|
|
51
|
+
/**
|
|
52
|
+
* One value per series key. A missing value (`undefined` or `null`) counts as
|
|
53
|
+
* zero, unless the chart's `missing` is `"gap"`.
|
|
54
|
+
*/
|
|
55
|
+
values: Record<string, number | null | undefined>;
|
|
56
|
+
}
|
|
57
|
+
/** The colour role of a reference line or an event marker. `"neutral"` is the quiet default. */
|
|
58
|
+
export type LineChartTone = "neutral" | "accent" | "success" | "warning" | "danger";
|
|
59
|
+
/**
|
|
60
|
+
* A reference line: a horizontal line at a value (a target, a threshold), or a
|
|
61
|
+
* vertical line at one datum (today, a launch). Drawn dashed and quiet, behind
|
|
62
|
+
* the series, with its label at the line's end.
|
|
63
|
+
*/
|
|
64
|
+
export type LineChartReference = {
|
|
65
|
+
/** Stable identity. */
|
|
66
|
+
key: string;
|
|
67
|
+
/** Short text beside the line, such as "Target" or "Today". Also read to screen readers. */
|
|
68
|
+
label: string;
|
|
69
|
+
/**
|
|
70
|
+
* Colours the line and its label, for a line whose colour carries meaning,
|
|
71
|
+
* such as a "Goal" in warning. Still dashed, still behind the series.
|
|
72
|
+
* @default "neutral"
|
|
73
|
+
*/
|
|
74
|
+
tone?: LineChartTone;
|
|
75
|
+
} & ({
|
|
76
|
+
/**
|
|
77
|
+
* A value on the value axis: a horizontal line. The scale grows to keep it
|
|
78
|
+
* in view, even when every value is missing. A value that is not finite
|
|
79
|
+
* draws nothing. Read with `formatValue` (given the chart's first series)
|
|
80
|
+
* and `unit`, like the series.
|
|
81
|
+
*/
|
|
82
|
+
value: number;
|
|
83
|
+
at?: never;
|
|
84
|
+
} | {
|
|
85
|
+
/** The `key` of a datum: a vertical line at that point. A key not in `data` draws nothing. */
|
|
86
|
+
at: string;
|
|
87
|
+
value?: never;
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* An event on the category axis, such as "prompts changed": a short stem up
|
|
91
|
+
* from the baseline at one datum, with a short visible label above it.
|
|
92
|
+
*/
|
|
93
|
+
export interface LineChartMarker {
|
|
94
|
+
/** Stable identity. */
|
|
95
|
+
key: string;
|
|
96
|
+
/** The `key` of a datum. A key not in `data` draws nothing. */
|
|
97
|
+
at: string;
|
|
98
|
+
/** Short visible text, such as "Changed" or "v2". */
|
|
99
|
+
label: string;
|
|
100
|
+
/** What happened, read to screen readers in place of `label`, such as "Prompt set changed". */
|
|
101
|
+
description?: string;
|
|
102
|
+
/** @default "neutral" */
|
|
103
|
+
tone?: LineChartTone;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A shaded band across the plot between two values, such as "Page 1" for
|
|
107
|
+
* ranks 1 to 10. Drawn behind the gridlines and the series, clipped to the
|
|
108
|
+
* value axis; it never grows the scale.
|
|
109
|
+
*/
|
|
110
|
+
export interface LineChartBand {
|
|
111
|
+
/** Stable identity. */
|
|
112
|
+
key: string;
|
|
113
|
+
/** One edge of the band, on the value axis. Either order. */
|
|
114
|
+
from: number;
|
|
115
|
+
/** The other edge. */
|
|
116
|
+
to: number;
|
|
117
|
+
/** Short text inside the band at its top inline-start corner, such as "Page 1". Hidden when the band is too thin to hold it. */
|
|
118
|
+
label: string;
|
|
119
|
+
/** What the band means, read in the chart's summary in place of `label` and its range, such as "Page 1: ranks 1 to 10". */
|
|
120
|
+
description?: string;
|
|
121
|
+
/** @default "neutral" */
|
|
122
|
+
tone?: LineChartTone;
|
|
123
|
+
}
|
|
124
|
+
/** What `renderTooltip` is given for the point under the crosshair. */
|
|
125
|
+
export interface LineChartTooltipContext {
|
|
126
|
+
datum: LineChartDatum;
|
|
127
|
+
index: number;
|
|
128
|
+
/** The series on show, in order. */
|
|
129
|
+
series: LineChartSeries[];
|
|
130
|
+
/** Each shown series' value at this point; `null` when it is missing (with `missing` `"gap"` or `"connect"`). */
|
|
131
|
+
values: Record<string, number | null>;
|
|
132
|
+
/** Reads a value the way the default tooltip does: `formatValue`, `unit`, and `missingLabel` for `null`. */
|
|
133
|
+
format: (value: number | null, series: LineChartSeries) => string;
|
|
134
|
+
/** The default tooltip content (the date and one row per series), to keep and add to. */
|
|
135
|
+
readout: ReactNode;
|
|
39
136
|
}
|
|
40
137
|
export interface LineChartProps {
|
|
41
138
|
data: LineChartDatum[];
|
|
@@ -66,6 +163,51 @@ export interface LineChartProps {
|
|
|
66
163
|
categoryLabel?: string;
|
|
67
164
|
/** Smooth monotone curves that never swing past the data, or straight segments. @default "smooth" */
|
|
68
165
|
curve?: "smooth" | "linear";
|
|
166
|
+
/**
|
|
167
|
+
* How a missing value (`undefined`, `null` or not a finite number) is drawn.
|
|
168
|
+
* `"zero"` counts it as zero, as before. `"gap"` breaks the line (and its
|
|
169
|
+
* area) there, leaves it out of the scale, hides the crosshair dot on it and
|
|
170
|
+
* reads it as `missingLabel` in the tooltip and the data table. A point with
|
|
171
|
+
* missing neighbours on both sides is drawn as a dot. `"connect"` is the same,
|
|
172
|
+
* except the line runs on across missing values between two present ones,
|
|
173
|
+
* through the straight line between them (a projection known at a few
|
|
174
|
+
* points); before the first value and after the last, nothing is drawn.
|
|
175
|
+
* @default "zero"
|
|
176
|
+
*/
|
|
177
|
+
missing?: "zero" | "gap" | "connect";
|
|
178
|
+
/** Read in place of a missing value when `missing` is `"gap"` or `"connect"`. @default "No data" */
|
|
179
|
+
missingLabel?: string;
|
|
180
|
+
/** Reference lines: targets at a value, or markers such as "today" at a datum. */
|
|
181
|
+
references?: LineChartReference[];
|
|
182
|
+
/** Events on the category axis, each with a short visible label. Read in the summary and when scrubbed to. */
|
|
183
|
+
markers?: LineChartMarker[];
|
|
184
|
+
/**
|
|
185
|
+
* Flips the value axis: the lowest value at the top, the highest on the
|
|
186
|
+
* baseline. For ranks, where 1 is best. Pair it with `valueDomain`, such as
|
|
187
|
+
* `{ min: 1 }`, so the axis starts at rank 1 rather than 0.
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
reversed?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Pins either end of the value axis, such as `{ min: 1, max: 100 }` for ranks
|
|
193
|
+
* #1 to #100. An end left out fits the data as before (from zero at the low
|
|
194
|
+
* end). The pinned values are always ticks. A value past a pinned end is drawn
|
|
195
|
+
* past the edge, so pin a range that covers the data.
|
|
196
|
+
*/
|
|
197
|
+
valueDomain?: {
|
|
198
|
+
min?: number;
|
|
199
|
+
max?: number;
|
|
200
|
+
};
|
|
201
|
+
/** Shaded bands between two values, such as rank pages. Read in the summary. */
|
|
202
|
+
bands?: LineChartBand[];
|
|
203
|
+
/**
|
|
204
|
+
* Replaces the tooltip's content for the point under the crosshair. It is
|
|
205
|
+
* given the point and the default `readout`, to keep and add to (gained and
|
|
206
|
+
* lost counts under a total). Return `null` (or `undefined`, `false`, `0` or `""`) to show no tooltip at that point.
|
|
207
|
+
* The tooltip is visual only: the slider's value text, the summary and the
|
|
208
|
+
* data table still read every value.
|
|
209
|
+
*/
|
|
210
|
+
renderTooltip?: (context: LineChartTooltipContext) => ReactNode;
|
|
69
211
|
/** Extra classes for the root. Merged last. */
|
|
70
212
|
className?: string;
|
|
71
213
|
}
|