@caqophony/ui 0.9.1 → 0.9.3
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/dist/charts.d.mts +11 -2
- package/dist/charts.js +19 -6
- package/dist/index.js +1 -1
- package/dist/material.d.mts +15 -1
- package/dist/material.js +4 -0
- package/package.json +1 -1
package/dist/charts.d.mts
CHANGED
|
@@ -40,8 +40,13 @@ interface LineChartProps extends BaseChartProps {
|
|
|
40
40
|
/** Date format for labels */
|
|
41
41
|
dateFormat?: Intl.DateTimeFormatOptions;
|
|
42
42
|
}
|
|
43
|
+
interface ChartValueUnit {
|
|
44
|
+
kind: 'percent';
|
|
45
|
+
scale: 1 | 100;
|
|
46
|
+
}
|
|
43
47
|
interface BarChartProps extends BaseChartProps {
|
|
44
48
|
data: ChartDataPoint[];
|
|
49
|
+
unit?: ChartValueUnit;
|
|
45
50
|
/** Label for the dataset */
|
|
46
51
|
label?: string;
|
|
47
52
|
/** Bar color */
|
|
@@ -60,7 +65,7 @@ type NumberFormatMode = 'compact' | 'full' | 'currency';
|
|
|
60
65
|
|
|
61
66
|
declare function LineChart({ data, label, secondaryLabel, color, secondaryColor, fill, showLegend, height, emptyMessage, dateFormat, className, }: LineChartProps): react_jsx_runtime.JSX.Element;
|
|
62
67
|
|
|
63
|
-
declare function BarChart({ data, label, color, horizontal, showLegend, height, emptyMessage, className, }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
declare function BarChart({ data, label, color, horizontal, showLegend, height, emptyMessage, className, unit, }: BarChartProps): react_jsx_runtime.JSX.Element;
|
|
64
69
|
|
|
65
70
|
declare function DoughnutChart({ data, colors, showPercentage, showLegend, height, emptyMessage, className, }: DoughnutChartProps): react_jsx_runtime.JSX.Element;
|
|
66
71
|
|
|
@@ -92,6 +97,10 @@ declare function ChartSkeleton({ height, className }: ChartSkeletonProps): react
|
|
|
92
97
|
* Format a number for display in charts (compact: 1K, 1M, etc.)
|
|
93
98
|
*/
|
|
94
99
|
declare function formatNumber(value: number, mode?: NumberFormatMode): string;
|
|
100
|
+
/**
|
|
101
|
+
* Format a chart value in its unit: a plain number compact, a percent as `64.6%`
|
|
102
|
+
*/
|
|
103
|
+
declare function formatValue(value: number, unit?: ChartValueUnit): string;
|
|
95
104
|
/**
|
|
96
105
|
* Format a date for chart labels
|
|
97
106
|
*/
|
|
@@ -114,4 +123,4 @@ declare const CHART_COLORS: {
|
|
|
114
123
|
readonly gray: "rgb(107, 114, 128)";
|
|
115
124
|
};
|
|
116
125
|
|
|
117
|
-
export { BarChart, type BarChartProps, type BaseChartProps, CHART_COLORS, type ChartDataPoint, ChartSkeleton, DoughnutChart, type DoughnutChartProps, LineChart, type LineChartProps, type NumberFormatMode, type TimeSeriesDataPoint, formatDateLabel, formatNumber, generateColors };
|
|
126
|
+
export { BarChart, type BarChartProps, type BaseChartProps, CHART_COLORS, type ChartDataPoint, ChartSkeleton, type ChartValueUnit, DoughnutChart, type DoughnutChartProps, LineChart, type LineChartProps, type NumberFormatMode, type TimeSeriesDataPoint, formatDateLabel, formatNumber, formatValue, generateColors };
|
package/dist/charts.js
CHANGED
|
@@ -25,6 +25,14 @@ function formatNumber(value, mode = "compact") {
|
|
|
25
25
|
}
|
|
26
26
|
return value.toString();
|
|
27
27
|
}
|
|
28
|
+
var PERCENT_FRACTION_DIGITS = 1;
|
|
29
|
+
function formatValue(value, unit) {
|
|
30
|
+
if (unit === void 0) return formatNumber(value);
|
|
31
|
+
return new Intl.NumberFormat("en-US", {
|
|
32
|
+
style: "percent",
|
|
33
|
+
maximumFractionDigits: PERCENT_FRACTION_DIGITS
|
|
34
|
+
}).format(unit.scale === 100 ? value / 100 : value);
|
|
35
|
+
}
|
|
28
36
|
function formatDateLabel(date, options = { month: "short", day: "numeric" }) {
|
|
29
37
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
30
38
|
return d.toLocaleDateString("en-US", options);
|
|
@@ -205,8 +213,9 @@ function paletteOf(el) {
|
|
|
205
213
|
grid: read(BAR_TOKENS.grid)
|
|
206
214
|
};
|
|
207
215
|
}
|
|
208
|
-
var valueTick = (tickValue) =>
|
|
209
|
-
typeof tickValue === "number" ? tickValue : parseFloat(String(tickValue))
|
|
216
|
+
var valueTick = (unit) => (tickValue) => formatValue(
|
|
217
|
+
typeof tickValue === "number" ? tickValue : parseFloat(String(tickValue)),
|
|
218
|
+
unit
|
|
210
219
|
);
|
|
211
220
|
function BarChart({
|
|
212
221
|
data,
|
|
@@ -216,7 +225,8 @@ function BarChart({
|
|
|
216
225
|
showLegend = false,
|
|
217
226
|
height = 256,
|
|
218
227
|
emptyMessage = "No data available",
|
|
219
|
-
className
|
|
228
|
+
className,
|
|
229
|
+
unit
|
|
220
230
|
}) {
|
|
221
231
|
const box = useRef(null);
|
|
222
232
|
const [palette, setPalette] = useState(null);
|
|
@@ -239,10 +249,12 @@ function BarChart({
|
|
|
239
249
|
]
|
|
240
250
|
};
|
|
241
251
|
}, [data, label, color, palette]);
|
|
252
|
+
const scale = unit?.scale;
|
|
242
253
|
const options = useMemo2(() => {
|
|
254
|
+
const valueUnit = scale === void 0 ? void 0 : { kind: "percent", scale };
|
|
243
255
|
const valueAxis = {
|
|
244
256
|
beginAtZero: true,
|
|
245
|
-
ticks: { callback: valueTick, color: palette?.text },
|
|
257
|
+
ticks: { callback: valueTick(valueUnit), color: palette?.text },
|
|
246
258
|
grid: { color: palette?.grid },
|
|
247
259
|
border: { display: false }
|
|
248
260
|
};
|
|
@@ -265,14 +277,14 @@ function BarChart({
|
|
|
265
277
|
callbacks: {
|
|
266
278
|
label: (context) => {
|
|
267
279
|
const val = horizontal ? context.parsed.x : context.parsed.y;
|
|
268
|
-
return val === null ? `${context.dataset.label}: no value` : `${context.dataset.label}: ${
|
|
280
|
+
return val === null ? `${context.dataset.label}: no value` : `${context.dataset.label}: ${formatValue(val, valueUnit)}`;
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
283
|
}
|
|
272
284
|
},
|
|
273
285
|
scales: horizontal ? { x: valueAxis, y: categoryAxis } : { x: categoryAxis, y: valueAxis }
|
|
274
286
|
};
|
|
275
|
-
}, [horizontal, showLegend, palette]);
|
|
287
|
+
}, [horizontal, showLegend, palette, scale]);
|
|
276
288
|
if (data.length === 0) {
|
|
277
289
|
return /* @__PURE__ */ jsx2(
|
|
278
290
|
"div",
|
|
@@ -386,5 +398,6 @@ export {
|
|
|
386
398
|
LineChart,
|
|
387
399
|
formatDateLabel,
|
|
388
400
|
formatNumber,
|
|
401
|
+
formatValue,
|
|
389
402
|
generateColors
|
|
390
403
|
};
|
package/dist/index.js
CHANGED
|
@@ -4945,7 +4945,7 @@ var SectionCard = React38.forwardRef(
|
|
|
4945
4945
|
flush && children ? "border-b border-border" : ""
|
|
4946
4946
|
),
|
|
4947
4947
|
children: [
|
|
4948
|
-
/* @__PURE__ */ jsxs41("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
4948
|
+
/* @__PURE__ */ jsxs41("div", { className: "flex min-w-0 flex-1 basis-48 flex-col gap-1", children: [
|
|
4949
4949
|
title && /* @__PURE__ */ jsx52(
|
|
4950
4950
|
"h2",
|
|
4951
4951
|
{
|
package/dist/material.d.mts
CHANGED
|
@@ -91,6 +91,20 @@ declare const STACK_ZONE_RATIO = 1.25;
|
|
|
91
91
|
* it to the zone as drawn.
|
|
92
92
|
*/
|
|
93
93
|
declare const STACK_ZONE_MIN_WIDTH = 390;
|
|
94
|
+
/**
|
|
95
|
+
* #6812 — the side column's least box at the views a page is judged at, as a
|
|
96
|
+
* `side` frame is drawn in it. Its width is narrowest at 1024 (\`lg\`), where the
|
|
97
|
+
* grid's two even columns are 512px each, with no gutter. Its height is at
|
|
98
|
+
* least `height="tall"`'s 46rem (736px); `fold` is 836px at the 900px views and
|
|
99
|
+
* taller copy only grows either. A `contain` frame draws at the smaller of
|
|
100
|
+
* the two scales, so `check-tree`'s `art-text-min-size` judges a side frame's
|
|
101
|
+
* text by both, and the author's prompt states them. Classes cannot be
|
|
102
|
+
* interpolated: a browser test (`material-primitives-5956`) holds the drawn
|
|
103
|
+
* column to these numbers.
|
|
104
|
+
*/
|
|
105
|
+
declare const SIDE_ZONE_MIN_WIDTH = 512;
|
|
106
|
+
/** #6812 — the side column's least height: see `SIDE_ZONE_MIN_WIDTH`. */
|
|
107
|
+
declare const SIDE_ZONE_MIN_HEIGHT = 736;
|
|
94
108
|
interface HeroSceneProps {
|
|
95
109
|
/**
|
|
96
110
|
* The hero's height from `lg` up, and both are minimums: taller copy grows it.
|
|
@@ -610,4 +624,4 @@ interface WordmarkProps {
|
|
|
610
624
|
/** A product name with its mark. */
|
|
611
625
|
declare function Wordmark({ name, mark, href }: WordmarkProps): react_jsx_runtime.JSX.Element;
|
|
612
626
|
|
|
613
|
-
export { BLEED_BOTH_SIDES, Band, type BandEdgeSpec, type BandProps, CloudBank, type CloudBankProps, Columns, type ColumnsProps, Display, type DisplayProps, type FieldReach, type FieldSize, Figure, type FigureProps, type FigureSpec, type Gap, Halo, type HaloProps, HeroScene, type HeroSceneProps, Inline, type InlineProps, Inset, type InsetProps, Ridge, type RidgeProps, RouteLine, type RouteLineProps, type RoutePoint, SCENE_MEASURES, STACK_ZONE_MIN_WIDTH, STACK_ZONE_RATIO, type SceneBound, type SceneMeasure, SkyField, type SkyFieldProps, Spacer, type SpacerProps, Split, type SplitProps, Stack, type StackProps, Stars, type StarsProps, Text, type TextProps, type Tone, Vignette, type VignetteProps, Wordmark, type WordmarkProps, cloudBankPaths, ridgePath, starDots };
|
|
627
|
+
export { BLEED_BOTH_SIDES, Band, type BandEdgeSpec, type BandProps, CloudBank, type CloudBankProps, Columns, type ColumnsProps, Display, type DisplayProps, type FieldReach, type FieldSize, Figure, type FigureProps, type FigureSpec, type Gap, Halo, type HaloProps, HeroScene, type HeroSceneProps, Inline, type InlineProps, Inset, type InsetProps, Ridge, type RidgeProps, RouteLine, type RouteLineProps, type RoutePoint, SCENE_MEASURES, SIDE_ZONE_MIN_HEIGHT, SIDE_ZONE_MIN_WIDTH, STACK_ZONE_MIN_WIDTH, STACK_ZONE_RATIO, type SceneBound, type SceneMeasure, SkyField, type SkyFieldProps, Spacer, type SpacerProps, Split, type SplitProps, Stack, type StackProps, Stars, type StarsProps, Text, type TextProps, type Tone, Vignette, type VignetteProps, Wordmark, type WordmarkProps, cloudBankPaths, ridgePath, starDots };
|
package/dist/material.js
CHANGED
|
@@ -776,6 +776,8 @@ function Figure({ spec, alt, children, fit = "aspect" }) {
|
|
|
776
776
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
777
777
|
var STACK_ZONE_RATIO = 1.25;
|
|
778
778
|
var STACK_ZONE_MIN_WIDTH = 390;
|
|
779
|
+
var SIDE_ZONE_MIN_WIDTH = 512;
|
|
780
|
+
var SIDE_ZONE_MIN_HEIGHT = 736;
|
|
779
781
|
var HEIGHT2 = {
|
|
780
782
|
fold: "lg:min-h-[min(calc(100svh-4rem),56rem)]",
|
|
781
783
|
tall: "lg:min-h-[46rem]"
|
|
@@ -1074,6 +1076,8 @@ export {
|
|
|
1074
1076
|
Ridge,
|
|
1075
1077
|
RouteLine,
|
|
1076
1078
|
SCENE_MEASURES,
|
|
1079
|
+
SIDE_ZONE_MIN_HEIGHT,
|
|
1080
|
+
SIDE_ZONE_MIN_WIDTH,
|
|
1077
1081
|
STACK_ZONE_MIN_WIDTH,
|
|
1078
1082
|
STACK_ZONE_RATIO,
|
|
1079
1083
|
SkyField,
|