@panneau/ui 5.0.0-alpha.36 → 5.0.0-alpha.37

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.
Files changed (53) hide show
  1. package/README.md +8 -2
  2. package/dist/bar-chart/BarChart.css +76 -0
  3. package/dist/bar-chart/BarChart.d.ts +33 -0
  4. package/dist/bar-chart/BarChart.d.ts.map +1 -0
  5. package/dist/bar-chart/BarChart.js +151 -0
  6. package/dist/bar-chart/BarChart.js.map +1 -0
  7. package/dist/bar-chart/BarChart.module.js +26 -0
  8. package/dist/bar-chart/BarChart.module.js.map +1 -0
  9. package/dist/bar-chart/tokens.d.ts +3 -0
  10. package/dist/bar-chart/tokens.d.ts.map +1 -0
  11. package/dist/bar-chart/tokens.js +17 -0
  12. package/dist/bar-chart/tokens.js.map +1 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4 -2
  16. package/dist/line-chart/LineChart.css +223 -24
  17. package/dist/line-chart/LineChart.d.ts +45 -10
  18. package/dist/line-chart/LineChart.d.ts.map +1 -1
  19. package/dist/line-chart/LineChart.js +580 -265
  20. package/dist/line-chart/LineChart.js.map +1 -1
  21. package/dist/line-chart/LineChart.module.js +42 -5
  22. package/dist/line-chart/LineChart.module.js.map +1 -1
  23. package/dist/line-chart/geometry.d.ts +37 -0
  24. package/dist/line-chart/geometry.d.ts.map +1 -0
  25. package/dist/line-chart/geometry.js +115 -0
  26. package/dist/line-chart/geometry.js.map +1 -0
  27. package/dist/line-chart/tokens.d.ts +1 -1
  28. package/dist/line-chart/tokens.d.ts.map +1 -1
  29. package/dist/line-chart/tokens.js +11 -7
  30. package/dist/line-chart/tokens.js.map +1 -1
  31. package/dist/meter/Meter.css +23 -0
  32. package/dist/meter/Meter.d.ts +26 -0
  33. package/dist/meter/Meter.d.ts.map +1 -0
  34. package/dist/meter/Meter.js +99 -0
  35. package/dist/meter/Meter.js.map +1 -0
  36. package/dist/meter/Meter.module.js +16 -0
  37. package/dist/meter/Meter.module.js.map +1 -0
  38. package/dist/meter/tokens.d.ts +3 -0
  39. package/dist/meter/tokens.d.ts.map +1 -0
  40. package/dist/meter/tokens.js +15 -0
  41. package/dist/meter/tokens.js.map +1 -0
  42. package/dist/stat/Stat.css +4 -0
  43. package/dist/stat/Stat.d.ts +11 -3
  44. package/dist/stat/Stat.d.ts.map +1 -1
  45. package/dist/stat/Stat.js +67 -42
  46. package/dist/stat/Stat.js.map +1 -1
  47. package/dist/stat/Stat.module.js +3 -1
  48. package/dist/stat/Stat.module.js.map +1 -1
  49. package/dist/theme/components.d.ts +3 -1
  50. package/dist/theme/components.d.ts.map +1 -1
  51. package/dist/theme/components.js +4 -0
  52. package/dist/theme/components.js.map +1 -1
  53. package/package.json +3 -3
@@ -1,14 +1,86 @@
1
1
  .panneau-line-chart-chart {
2
+ --_panneau-line-chart-plot-height: var(
3
+ --_panneau-line-chart-height,
4
+ var(--panneau-line-chart-height, 8rem)
5
+ );
6
+ --_panneau-line-chart-reveal: var(
7
+ --panneau-line-chart-reveal-duration,
8
+ calc(var(--panneau-duration-slow) * 3)
9
+ );
10
+
2
11
  display: flex;
3
12
  flex-direction: column;
4
13
  gap: var(--panneau-space-1);
5
14
  min-width: 0;
6
15
  margin: 0;
16
+ container: panneau-line-chart / inline-size;
17
+ font-size: var(--panneau-line-chart-label-font-size, var(--panneau-font-size-xs));
18
+ line-height: 1.5;
19
+ }
20
+
21
+ .panneau-line-chart-skeleton {
22
+ height: var(--_panneau-line-chart-plot-height);
23
+ }
24
+
25
+ .panneau-line-chart-axis-label {
26
+ color: var(--panneau-color-text-muted);
27
+ }
28
+
29
+ /* The scale on the left of the plot, the dates under it */
30
+ .panneau-line-chart-body {
31
+ display: grid;
32
+ grid-template-columns: minmax(0, 1fr);
33
+ column-gap: var(--panneau-space-2);
34
+ row-gap: var(--panneau-space-1);
35
+ }
36
+
37
+ .panneau-line-chart-chart[data-axis] .panneau-line-chart-body {
38
+ grid-template-columns: auto minmax(0, 1fr);
39
+ /* Room for the top graduation, centered on its line */
40
+ padding-block-start: 0.75em;
41
+ }
42
+
43
+ /* Room for a value written above the highest point */
44
+ .panneau-line-chart-chart[data-labels] .panneau-line-chart-body {
45
+ padding-block-start: 2em;
46
+ }
47
+
48
+ .panneau-line-chart-scale {
49
+ position: relative;
50
+ height: var(--_panneau-line-chart-plot-height);
51
+ color: var(--panneau-color-text-muted);
52
+ font-variant-numeric: tabular-nums;
53
+ text-align: end;
54
+ }
55
+
56
+ .panneau-line-chart-widest {
57
+ display: block;
58
+ height: 0;
59
+ overflow: hidden;
60
+ visibility: hidden;
61
+ }
62
+
63
+ .panneau-line-chart-tick {
64
+ position: absolute;
65
+ inset-inline-end: 0;
66
+ transform: translateY(-50%);
67
+ white-space: nowrap;
7
68
  }
8
69
 
9
70
  .panneau-line-chart-plot {
10
71
  position: relative;
11
- height: var(--_panneau-line-chart-height, var(--panneau-line-chart-height, 8rem));
72
+ height: var(--_panneau-line-chart-plot-height);
73
+ border-radius: var(--panneau-radius-sm);
74
+ touch-action: pan-y;
75
+ }
76
+
77
+ .panneau-line-chart-plot[role='slider'] {
78
+ cursor: crosshair;
79
+ }
80
+
81
+ .panneau-line-chart-plot[role='slider']:focus-visible {
82
+ outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
83
+ outline-offset: 4px;
12
84
  }
13
85
 
14
86
  .panneau-line-chart-svg {
@@ -18,15 +90,33 @@
18
90
  overflow: visible;
19
91
  }
20
92
 
93
+ .panneau-line-chart-grid,
21
94
  .panneau-line-chart-baseline {
22
- stroke: var(--panneau-color-border);
23
95
  stroke-width: 1px;
24
96
  vector-effect: non-scaling-stroke;
97
+ shape-rendering: crispEdges;
98
+ }
99
+
100
+ .panneau-line-chart-grid {
101
+ stroke: var(--panneau-line-chart-grid-color, var(--panneau-color-border));
102
+ stroke-opacity: 0.6;
103
+ }
104
+
105
+ .panneau-line-chart-baseline {
106
+ stroke: var(--panneau-color-border);
107
+ }
108
+
109
+ .panneau-line-chart-area-top {
110
+ stop-color: var(--_panneau-line-chart-color);
111
+ stop-opacity: var(--panneau-line-chart-area-opacity, 0.2);
112
+ }
113
+
114
+ .panneau-line-chart-area-bottom {
115
+ stop-color: var(--_panneau-line-chart-color);
116
+ stop-opacity: 0;
25
117
  }
26
118
 
27
119
  .panneau-line-chart-area {
28
- fill: var(--_panneau-line-chart-color);
29
- fill-opacity: var(--panneau-line-chart-area-opacity, 0.12);
30
120
  stroke: none;
31
121
  }
32
122
 
@@ -39,36 +129,145 @@
39
129
  vector-effect: non-scaling-stroke;
40
130
  }
41
131
 
42
- /* A path of no length with a round cap: a dot that the stretched plot doesn't deform. */
132
+ /* The line draws itself from the left when the chart appears, then its labels fade in */
133
+ .panneau-line-chart-reveal {
134
+ animation: panneau-line-chart-reveal var(--_panneau-line-chart-reveal) var(--panneau-ease-out) both;
135
+ }
136
+
137
+ .panneau-line-chart-marks {
138
+ animation: panneau-line-chart-fade-in var(--panneau-duration-slow) var(--panneau-ease-out)
139
+ var(--_panneau-line-chart-reveal) both;
140
+ }
141
+
142
+ @keyframes panneau-line-chart-reveal {
143
+ from {
144
+ clip-path: inset(-10% 100% -10% -10%);
145
+ }
146
+
147
+ to {
148
+ clip-path: inset(-10% -10% -10% -10%);
149
+ }
150
+ }
151
+
152
+ @keyframes panneau-line-chart-fade-in {
153
+ from {
154
+ opacity: 0;
155
+ }
156
+ }
157
+
158
+ @media (prefers-reduced-motion: reduce) {
159
+ .panneau-line-chart-reveal,
160
+ .panneau-line-chart-marks {
161
+ animation: none;
162
+ }
163
+ }
164
+
165
+ /* A dot, round whatever the width of the chart, with a ring of the surface around it */
43
166
  .panneau-line-chart-dot {
44
- fill: none;
45
- stroke: var(--_panneau-line-chart-color);
46
- stroke-width: var(--panneau-line-chart-dot-size, 6px);
47
- stroke-linecap: round;
48
- vector-effect: non-scaling-stroke;
167
+ position: absolute;
168
+ width: var(--panneau-line-chart-dot-size, 8px);
169
+ height: var(--panneau-line-chart-dot-size, 8px);
170
+ border-radius: 50%;
171
+ background-color: var(--_panneau-line-chart-color);
172
+ box-shadow: 0 0 0 2px var(--panneau-card-bg, var(--panneau-color-surface));
173
+ transform: translate(-50%, -50%);
174
+ pointer-events: none;
49
175
  }
50
176
 
51
- .panneau-line-chart-max,
52
- .panneau-line-chart-labels {
53
- font-size: var(--panneau-line-chart-label-font-size, var(--panneau-font-size-xs));
54
- font-variant-numeric: var(--panneau-font-numeric);
55
- color: var(--panneau-color-text-muted);
177
+ .panneau-line-chart-active-dot {
178
+ width: calc(var(--panneau-line-chart-dot-size, 8px) + 2px);
179
+ height: calc(var(--panneau-line-chart-dot-size, 8px) + 2px);
56
180
  }
57
181
 
58
- .panneau-line-chart-max {
182
+ .panneau-line-chart-crosshair {
59
183
  position: absolute;
60
- inset-block-start: 0;
61
- inset-inline-start: 0;
62
- line-height: 1;
63
- transform: translateY(-50%);
64
- padding-inline-end: var(--panneau-space-1);
184
+ inset-block: 0;
185
+ width: 1px;
186
+ background-color: var(--panneau-color-border-control);
187
+ transform: translateX(-50%);
188
+ pointer-events: none;
189
+ }
190
+
191
+ /* A value on the line: above or under its point, kept inside the width of the plot */
192
+ .panneau-line-chart-value-label,
193
+ .panneau-line-chart-tooltip {
194
+ position: absolute;
195
+ white-space: nowrap;
196
+ pointer-events: none;
197
+ --_panneau-line-chart-shift-x: calc(var(--_x) * -1%);
198
+ }
199
+
200
+ .panneau-line-chart-value-label {
201
+ padding-inline: 2px;
202
+ font-weight: var(--panneau-font-weight-medium);
203
+ font-variant-numeric: tabular-nums;
204
+ color: var(--panneau-color-text);
65
205
  background-color: var(--panneau-card-bg, var(--panneau-color-surface));
206
+ border-radius: var(--panneau-radius-sm);
207
+ }
208
+
209
+ .panneau-line-chart-value-label[data-placement='above'],
210
+ .panneau-line-chart-tooltip[data-placement='above'] {
211
+ transform: translate(var(--_panneau-line-chart-shift-x), calc(-100% - 0.5rem));
212
+ }
213
+
214
+ .panneau-line-chart-value-label[data-placement='below'],
215
+ .panneau-line-chart-tooltip[data-placement='below'] {
216
+ transform: translate(var(--_panneau-line-chart-shift-x), 0.5rem);
66
217
  }
67
218
 
68
- .panneau-line-chart-labels {
219
+ .panneau-line-chart-tooltip {
69
220
  display: flex;
70
- justify-content: space-between;
71
- gap: var(--panneau-space-2);
221
+ flex-direction: column;
222
+ padding: var(--panneau-space-1) var(--panneau-space-2);
223
+ color: var(--panneau-color-text);
224
+ background-color: var(--panneau-color-surface);
225
+ border: 1px solid var(--panneau-color-border);
226
+ border-radius: var(--panneau-radius-sm);
227
+ box-shadow: var(--panneau-shadow-sm, none);
228
+ z-index: 1;
229
+ }
230
+
231
+ .panneau-line-chart-tooltip-value {
232
+ font-size: var(--panneau-font-size-sm);
233
+ font-weight: var(--panneau-font-weight-bold);
234
+ font-variant-numeric: tabular-nums;
235
+ }
236
+
237
+ .panneau-line-chart-tooltip-label {
238
+ color: var(--panneau-color-text-muted);
239
+ }
240
+
241
+ .panneau-line-chart-dates {
242
+ position: relative;
243
+ grid-column: -2 / -1;
244
+ height: 1.5em;
245
+ color: var(--panneau-color-text-muted);
246
+ }
247
+
248
+ /* Centered under its point, the first and last kept inside the width of the plot */
249
+ .panneau-line-chart-date {
250
+ position: absolute;
251
+ white-space: nowrap;
252
+ transform: translateX(-50%);
253
+ }
254
+
255
+ .panneau-line-chart-date[data-edge='start'] {
256
+ transform: none;
257
+ }
258
+
259
+ .panneau-line-chart-date[data-edge='end'] {
260
+ transform: translateX(-100%);
261
+ }
262
+
263
+ .panneau-line-chart-minor {
264
+ display: none;
265
+ }
266
+
267
+ @container panneau-line-chart (min-width: 28rem) {
268
+ .panneau-line-chart-minor {
269
+ display: inline;
270
+ }
72
271
  }
73
272
 
74
273
  .panneau-line-chart-visually-hidden {
@@ -1,7 +1,9 @@
1
1
  /** A point of a `LineChart`. */
2
2
  export interface LineChartPoint {
3
- /** What the point is, under the chart and in its table: a day, a week, a month. */
3
+ /** What the point is, in its table and its tooltip: a day, a week, a month. */
4
4
  label: string;
5
+ /** A shorter label, under the chart: `Oct 5`. The `label` by default. */
6
+ shortLabel?: string | undefined;
5
7
  value: number;
6
8
  }
7
9
  export interface LineChartProps {
@@ -9,18 +11,51 @@ export interface LineChartProps {
9
11
  label: string;
10
12
  /** The points, in order. Left `undefined` while they load: a skeleton of the plot. */
11
13
  points?: LineChartPoint[] | undefined;
12
- /** Formats a value, in the table and the top of the scale. Defaults to a number of the locale. */
13
- formatValue?: (value: number) => string;
14
+ /** Formats a value: in the table, the labels on the line and the tooltip. A number of the locale by default. */
15
+ formatValue?: ((value: number) => string) | undefined;
16
+ /**
17
+ * Formats a graduation of the scale, short: `1 min`, `25 %`. A number of the locale by default,
18
+ * compact (`10K`) on a scale that reaches 10,000.
19
+ */
20
+ formatTick?: ((value: number) => string) | undefined;
21
+ /** What the values are, above the scale: `Entries`, `Minutes`. */
22
+ axisLabel?: string | undefined;
23
+ /**
24
+ * Shows the scale: round graduations, with a line across the plot for each. Without it, a line
25
+ * at 0 alone, for a chart that only shows a trend. `true` by default.
26
+ */
27
+ showAxis?: boolean | undefined;
28
+ /** Writes the last value at the end of the line. `true` by default. */
29
+ showLast?: boolean | undefined;
30
+ /** Marks the highest value on the line, with its value. */
31
+ showMax?: boolean | undefined;
32
+ /**
33
+ * Shows the value of the point under the pointer, or chosen with the arrow keys: for a long
34
+ * series, where a point can't be read from the scale. Off by default: the values a chart needs
35
+ * are on it, and every one is in its table.
36
+ */
37
+ isInteractive?: boolean | undefined;
38
+ /**
39
+ * Fixes the bounds of the scale: `{ min: 0, max: 1 }` for a ratio. From 0, or the lowest value
40
+ * under it, to a round value above the highest by default.
41
+ */
42
+ domain?: {
43
+ min?: number | undefined;
44
+ max?: number | undefined;
45
+ } | undefined;
46
+ /** `monotone` (default) curves through the points without going past them, `linear` joins them straight. */
47
+ curve?: 'monotone' | 'linear' | undefined;
14
48
  /** Height of the plot, without the labels: `'10rem'`. Defaults to the `height` token. */
15
- height?: string;
49
+ height?: string | undefined;
16
50
  /** The categorical color of the line, from 0. Defaults to the first. */
17
- color?: number;
18
- className?: string;
51
+ color?: number | undefined;
52
+ className?: string | undefined;
19
53
  }
20
54
  /**
21
- * A line of values over time, on the categorical chart colors of the theme: the line, the area
22
- * under it, the top of its scale, and the labels of its first and last points. The plot is hidden
23
- * from assistive technologies, which read the values in a table instead.
55
+ * A line of values over time, on the categorical chart colors of the theme: a curve and the area
56
+ * under it, a scale of round graduations, labels of dates under it, and the last value at the end
57
+ * of the line. The plot is hidden from assistive technologies, which read the values in a table;
58
+ * with `isInteractive`, the pointer and the arrow keys also show the value of each point.
24
59
  */
25
- export declare function LineChart({ label, points, formatValue, height, color, className, }: LineChartProps): import("react").JSX.Element;
60
+ export declare function LineChart({ label, points, formatValue, formatTick, axisLabel, showAxis, showLast, showMax, isInteractive, domain, curve, height, color, className, }: LineChartProps): import("react").JSX.Element;
26
61
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/line-chart/LineChart.tsx"],"names":[],"mappings":"AAQA,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC3B,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC3B,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACtC,kGAAkG;IAClG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACtB,KAAK,EACL,MAAM,EACN,WAAW,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