@lucasromero/matrix-ui 0.9.0 → 0.11.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/CHANGELOG.md +21 -0
- package/README.md +1 -0
- package/dist/components/AreaChart/AreaChart.d.ts +3 -0
- package/dist/components/AreaChart/AreaChart.js +14 -0
- package/dist/components/AreaChart/index.d.ts +1 -0
- package/dist/components/BarChart/BarChart.d.ts +3 -0
- package/dist/components/BarChart/BarChart.js +134 -0
- package/dist/components/BarChart/index.d.ts +1 -0
- package/dist/components/Chart/ChartAxes.d.ts +2 -0
- package/dist/components/Chart/ChartAxes.js +28 -0
- package/dist/components/Chart/ChartFrame.d.ts +7 -0
- package/dist/components/Chart/ChartFrame.js +108 -0
- package/dist/components/Chart/ChartPatterns.d.ts +3 -0
- package/dist/components/Chart/ChartPatterns.js +27 -0
- package/dist/components/Chart/ChartPlot.d.ts +2 -0
- package/dist/components/Chart/ChartPlot.js +101 -0
- package/dist/components/Chart/LinearChart.d.ts +3 -0
- package/dist/components/Chart/LinearChart.js +133 -0
- package/dist/components/Chart/RadialChart.d.ts +20 -0
- package/dist/components/Chart/RadialChart.js +112 -0
- package/dist/components/Chart/index.module.js +38 -0
- package/dist/components/Chart/math.d.ts +19 -0
- package/dist/components/Chart/math.js +82 -0
- package/dist/components/Chart/useChartSize.d.ts +3 -0
- package/dist/components/Chart/useChartSize.js +24 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.js +37 -29
- package/dist/components/CodeBlock/HighlightedCode.d.ts +7 -0
- package/dist/components/CodeBlock/HighlightedCode.js +26 -0
- package/dist/components/CodeBlock/highlight.d.ts +2 -0
- package/dist/components/CodeBlock/highlight.js +104 -0
- package/dist/components/CodeBlock/index.module.js +23 -3
- package/dist/components/DonutChart/DonutChart.d.ts +19 -0
- package/dist/components/DonutChart/DonutChart.js +12 -0
- package/dist/components/DonutChart/index.d.ts +1 -0
- package/dist/components/LineChart/LineChart.d.ts +3 -0
- package/dist/components/LineChart/LineChart.js +14 -0
- package/dist/components/LineChart/index.d.ts +1 -0
- package/dist/components/PieChart/PieChart.d.ts +17 -0
- package/dist/components/PieChart/PieChart.js +12 -0
- package/dist/components/PieChart/index.d.ts +1 -0
- package/dist/components/Sparkline/Sparkline.d.ts +7 -0
- package/dist/components/Sparkline/Sparkline.js +56 -0
- package/dist/components/Sparkline/index.d.ts +1 -0
- package/dist/components/Sparkline/index.module.js +9 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +66 -60
- package/dist/styles.css +1 -1
- package/dist/types/areaChartType.d.ts +5 -0
- package/dist/types/barChartType.d.ts +8 -0
- package/dist/types/chartType.d.ts +156 -0
- package/dist/types/codeBlockType.d.ts +20 -0
- package/dist/types/donutChartType.d.ts +6 -0
- package/dist/types/index.d.ts +8 -1
- package/dist/types/lineChartType.d.ts +5 -0
- package/dist/types/pieChartType.d.ts +2 -0
- package/dist/types/sparklineType.d.ts +14 -0
- package/package.json +3 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { HTMLAttributes, PointerEvent, ReactNode } from "react";
|
|
2
|
+
/** A step of the chart palette, from `--matrix-chart-color-1` to `--matrix-chart-color-8`. */
|
|
3
|
+
export type ChartColor = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
4
|
+
export type ChartSeries<Row> = {
|
|
5
|
+
/** Key of the number in each row. A missing, `null`, or invalid number is left out. */
|
|
6
|
+
key: Extract<keyof Row, string>;
|
|
7
|
+
/** Name of the series, shown in the legend, the tooltip, and the table. */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Color of the series. Defaults to its position in `series`. Set it when
|
|
11
|
+
* series can be filtered, so each one keeps its color. Series after the
|
|
12
|
+
* eighth are gray without one.
|
|
13
|
+
*/
|
|
14
|
+
color?: ChartColor;
|
|
15
|
+
};
|
|
16
|
+
export type ChartBaseProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
17
|
+
/** Visible title of the chart, which names it, such as "Revenue by month". */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Hides the title visually. It still names the chart. Defaults to `false`. */
|
|
20
|
+
hideLabel?: boolean;
|
|
21
|
+
/** Height of the chart in pixels, without its title, legend, and table. Defaults to `240`. */
|
|
22
|
+
height?: number;
|
|
23
|
+
/** Formats values in the tooltip, the table, and announcements. Defaults to English number formatting. */
|
|
24
|
+
formatValue?: (value: number) => string;
|
|
25
|
+
/** Shows the data as a visible table below the chart. Without it, the table is only for assistive technology. Defaults to `false`. */
|
|
26
|
+
showTable?: boolean;
|
|
27
|
+
/** Header of the table's first column. Defaults to "Category". */
|
|
28
|
+
categoryLabel?: string;
|
|
29
|
+
/** Adds a pattern to each filled area, so they can be told apart without color. Patterns always show in forced-colors mode. Defaults to `false`. */
|
|
30
|
+
patterns?: boolean;
|
|
31
|
+
/** Shown instead of the chart when there is no data. Defaults to "No data to show". */
|
|
32
|
+
emptyMessage?: ReactNode;
|
|
33
|
+
/** Instructions read when the chart is focused. Defaults to "Use the arrow keys to read each value." */
|
|
34
|
+
keyboardHint?: string;
|
|
35
|
+
};
|
|
36
|
+
export type CartesianChartProps<Row extends object> = ChartBaseProps & {
|
|
37
|
+
/** Rows of data, in display order. */
|
|
38
|
+
data: readonly Row[];
|
|
39
|
+
/** Key of the category in each row, such as a month. */
|
|
40
|
+
categoryKey: Extract<keyof Row, string>;
|
|
41
|
+
/** Series to show, in display order. */
|
|
42
|
+
series: readonly ChartSeries<Row>[];
|
|
43
|
+
/** Formats categories. Defaults to the category as text. */
|
|
44
|
+
formatCategory?: (category: string) => string;
|
|
45
|
+
/** Formats values on the axis. Defaults to `formatValue`, or to short numbers such as "20K". */
|
|
46
|
+
formatAxisValue?: (value: number) => string;
|
|
47
|
+
/** Shows the legend. Defaults to `true` with more than one series. */
|
|
48
|
+
showLegend?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type ChartSlice = {
|
|
51
|
+
/** Name of the slice, shown in the legend, the tooltip, and the table. */
|
|
52
|
+
label: string;
|
|
53
|
+
/** Size of the slice. Zero, negative, and invalid values are left out. */
|
|
54
|
+
value: number;
|
|
55
|
+
/** Color of the slice. Defaults to its position in `data`. Slices after the eighth are gray without one. */
|
|
56
|
+
color?: ChartColor;
|
|
57
|
+
};
|
|
58
|
+
export type RadialChartProps = ChartBaseProps & {
|
|
59
|
+
/** Slices, in display order, clockwise from the top. */
|
|
60
|
+
data: readonly ChartSlice[];
|
|
61
|
+
/** Header of the table's value column. Defaults to "Value". */
|
|
62
|
+
valueLabel?: string;
|
|
63
|
+
/** Header of the table's share column. Defaults to "Share". */
|
|
64
|
+
shareLabel?: string;
|
|
65
|
+
/** Formats a slice's share, from 0 to 1. Defaults to a percentage, such as "25%". */
|
|
66
|
+
formatShare?: (share: number) => string;
|
|
67
|
+
/** Shows the legend, with each slice's share. Defaults to `true`. */
|
|
68
|
+
showLegend?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type ChartSize = {
|
|
71
|
+
width: number;
|
|
72
|
+
fontSize: number;
|
|
73
|
+
};
|
|
74
|
+
export type ChartScale = {
|
|
75
|
+
min: number;
|
|
76
|
+
max: number;
|
|
77
|
+
ticks: number[];
|
|
78
|
+
};
|
|
79
|
+
export type ChartBox = {
|
|
80
|
+
left: number;
|
|
81
|
+
top: number;
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
};
|
|
85
|
+
export type ChartPoint = {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
};
|
|
89
|
+
export type ChartLegendItem = {
|
|
90
|
+
label: string;
|
|
91
|
+
color: string;
|
|
92
|
+
slot: number;
|
|
93
|
+
mark: "line" | "fill";
|
|
94
|
+
value?: string;
|
|
95
|
+
};
|
|
96
|
+
export type ChartTooltip = {
|
|
97
|
+
title?: string;
|
|
98
|
+
rows: {
|
|
99
|
+
label: string;
|
|
100
|
+
value: string;
|
|
101
|
+
color: string;
|
|
102
|
+
}[];
|
|
103
|
+
};
|
|
104
|
+
export type ChartTable = {
|
|
105
|
+
headers: string[];
|
|
106
|
+
rows: string[][];
|
|
107
|
+
};
|
|
108
|
+
export type ChartFrameProps = Omit<ChartBaseProps, "height" | "formatValue" | "categoryLabel" | "keyboardHint"> & {
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
legend: ChartLegendItem[];
|
|
111
|
+
patternId: string;
|
|
112
|
+
table: ChartTable;
|
|
113
|
+
isEmpty: boolean;
|
|
114
|
+
};
|
|
115
|
+
export type ChartPlotProps = {
|
|
116
|
+
label: string;
|
|
117
|
+
height: number;
|
|
118
|
+
hint: string;
|
|
119
|
+
count: number;
|
|
120
|
+
patternId: string;
|
|
121
|
+
findIndex: (point: ChartPoint, size: ChartSize) => number | null;
|
|
122
|
+
getAnchor: (index: number, size: ChartSize) => ChartPoint;
|
|
123
|
+
getTooltip: (index: number) => ChartTooltip;
|
|
124
|
+
render: (size: ChartSize, active: number | null) => ReactNode;
|
|
125
|
+
overlay?: ReactNode;
|
|
126
|
+
};
|
|
127
|
+
export type ChartPointerEvent = PointerEvent<HTMLDivElement>;
|
|
128
|
+
export type ChartSeriesValues = {
|
|
129
|
+
label: string;
|
|
130
|
+
color: string;
|
|
131
|
+
slot: number;
|
|
132
|
+
values: (number | null)[];
|
|
133
|
+
};
|
|
134
|
+
export type ChartSwatchProps = {
|
|
135
|
+
item: ChartLegendItem;
|
|
136
|
+
patternId: string;
|
|
137
|
+
};
|
|
138
|
+
export type ChartAxesProps = {
|
|
139
|
+
box: ChartBox;
|
|
140
|
+
scale: ChartScale;
|
|
141
|
+
size: ChartSize;
|
|
142
|
+
categories: string[];
|
|
143
|
+
positions: number[];
|
|
144
|
+
formatTick: (value: number) => string;
|
|
145
|
+
alignEnds: boolean;
|
|
146
|
+
};
|
|
147
|
+
export type RadialChartBaseProps = RadialChartProps & {
|
|
148
|
+
innerRatio: number;
|
|
149
|
+
center?: ReactNode;
|
|
150
|
+
};
|
|
151
|
+
export type LinearChartKind = "line" | "area";
|
|
152
|
+
export type LinearChartBaseProps<Row extends object> = CartesianChartProps<Row> & {
|
|
153
|
+
kind: LinearChartKind;
|
|
154
|
+
includeZero: boolean;
|
|
155
|
+
stacked: boolean;
|
|
156
|
+
};
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import type { HTMLAttributes } from "react";
|
|
2
2
|
export type CopyStatus = "idle" | "copied" | "failed";
|
|
3
|
+
/** Languages CodeBlock can color. */
|
|
4
|
+
export type CodeBlockLanguage = "css" | "go" | "graphql" | "html" | "js" | "json" | "jsx" | "markdown" | "python" | "rust" | "sql" | "ts" | "tsx" | "yaml";
|
|
5
|
+
/** Color schemes for code, named after the editor themes they follow. Each has light and dark colors. */
|
|
6
|
+
export type CodeBlockColor = "vscode" | "github" | "one" | "dracula" | "solarized";
|
|
7
|
+
export type CodeRole = "comment" | "keyword" | "control" | "string" | "number" | "function" | "type" | "property" | "tag" | "attribute" | "variable" | "delimiter" | "bracket1" | "bracket2" | "bracket3";
|
|
8
|
+
export type CodeToken = {
|
|
9
|
+
text: string;
|
|
10
|
+
role: CodeRole | null;
|
|
11
|
+
};
|
|
12
|
+
export type CodeWordPattern = {
|
|
13
|
+
pattern: RegExp;
|
|
14
|
+
role: CodeRole;
|
|
15
|
+
};
|
|
3
16
|
export type CodeBlockProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "title"> & {
|
|
4
17
|
/** Code to display and copy. Trailing whitespace is not displayed. */
|
|
5
18
|
code: string;
|
|
6
19
|
/** Visible title above the code, such as a file name. */
|
|
7
20
|
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Language of the code, which colors it. Without it, the code is one color.
|
|
23
|
+
* The code that colors it loads only when a block has a language.
|
|
24
|
+
*/
|
|
25
|
+
language?: CodeBlockLanguage;
|
|
26
|
+
/** Color scheme of the code. It needs `language`. Defaults to "vscode". */
|
|
27
|
+
codeColor?: CodeBlockColor;
|
|
8
28
|
/** Visible text of the copy button. Defaults to "Copy". */
|
|
9
29
|
copyLabel?: string;
|
|
10
30
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { ButtonClassNameOptions, ButtonProps, ButtonSize, ButtonVariant, }
|
|
|
9
9
|
export type { CardProps } from "./cardType.js";
|
|
10
10
|
export type { CheckboxProps } from "./checkboxType.js";
|
|
11
11
|
export type { ChipProps, ChipSize } from "./chipType.js";
|
|
12
|
-
export type { CodeBlockProps, CopyStatus } from "./codeBlockType.js";
|
|
12
|
+
export type { CodeBlockColor, CodeBlockLanguage, CodeBlockProps, CodeRole, CodeToken, CodeWordPattern, CopyStatus, } from "./codeBlockType.js";
|
|
13
13
|
export type { ComboboxOption, ComboboxProps } from "./comboboxType.js";
|
|
14
14
|
export type { ContainerProps, ContainerSize } from "./containerType.js";
|
|
15
15
|
export type { DateInputProps } from "./dateInputType.js";
|
|
@@ -59,3 +59,10 @@ export type { TooltipProps } from "./tooltipType.js";
|
|
|
59
59
|
export type { UseDisclosureButtonProps, UseDisclosureOptions, UseDisclosurePanelProps, UseDisclosureResult, } from "./useDisclosureType.js";
|
|
60
60
|
export type { UseMediaQueryOptions } from "./useMediaQueryType.js";
|
|
61
61
|
export type { VisuallyHiddenProps } from "./visuallyHiddenType.js";
|
|
62
|
+
export type { AreaChartProps } from "./areaChartType.js";
|
|
63
|
+
export type { BarChartOrientation, BarChartProps } from "./barChartType.js";
|
|
64
|
+
export type { CartesianChartProps, ChartAxesProps, ChartBaseProps, ChartBox, ChartColor, ChartFrameProps, ChartLegendItem, ChartPlotProps, ChartPoint, ChartPointerEvent, ChartScale, ChartSeries, ChartSeriesValues, ChartSize, ChartSlice, ChartSwatchProps, ChartTable, ChartTooltip, LinearChartBaseProps, LinearChartKind, RadialChartBaseProps, RadialChartProps, } from "./chartType.js";
|
|
65
|
+
export type { DonutChartProps } from "./donutChartType.js";
|
|
66
|
+
export type { LineChartProps } from "./lineChartType.js";
|
|
67
|
+
export type { PieChartProps } from "./pieChartType.js";
|
|
68
|
+
export type { SparklineProps } from "./sparklineType.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CartesianChartProps } from "./chartType.js";
|
|
2
|
+
export type LineChartProps<Row extends object> = CartesianChartProps<Row> & {
|
|
3
|
+
/** Starts the value axis at zero. Turn it off to show small changes between large values. Defaults to `true`. */
|
|
4
|
+
includeZero?: boolean;
|
|
5
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import type { ChartColor } from "./chartType.js";
|
|
3
|
+
export type SparklineProps = Omit<HTMLAttributes<HTMLSpanElement>, "children" | "color"> & {
|
|
4
|
+
/** Values, in order. Invalid values are left out of the line. */
|
|
5
|
+
data: readonly number[];
|
|
6
|
+
/** Accessible name, which should say what the trend shows, such as "Revenue rose from $2K to $8K this year". */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Color of the line. Defaults to `1`. */
|
|
9
|
+
color?: ChartColor;
|
|
10
|
+
/** Fills the area below the line. Defaults to `false`. */
|
|
11
|
+
area?: boolean;
|
|
12
|
+
/** Height in pixels. Defaults to `32`. The width fills the container. */
|
|
13
|
+
height?: number;
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucasromero/matrix-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Reusable, accessible React and TypeScript components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"libphonenumber-js": "^1.13.15",
|
|
43
|
-
"lucide-react": "^1.69.0"
|
|
43
|
+
"lucide-react": "^1.69.0",
|
|
44
|
+
"prism-react-renderer": "^2.4.1"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"react": "^18.0.0 || ^19.0.0",
|