panelui-native 0.61.1 → 0.62.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/src/index.ts CHANGED
@@ -556,6 +556,41 @@ export {
556
556
  type PieChartStatus,
557
557
  type PieDatum,
558
558
  } from './components/pie-chart';
559
+ export {
560
+ LiveLineChart,
561
+ useLiveLineChart,
562
+ type LiveLineChartProps,
563
+ type LiveLineChartHandle,
564
+ type LiveLineChartHeaderProps,
565
+ type LiveLineChartGridProps,
566
+ type LiveLineChartAreaProps,
567
+ type LiveLineChartLineProps,
568
+ type LiveLineChartTipProps,
569
+ type LiveLineChartXAxisProps,
570
+ type LiveLineChartYAxisProps,
571
+ type LiveLineChartTooltipProps,
572
+ type LiveLineChartSkeletonProps,
573
+ type LiveLineChartStatus,
574
+ type LiveLineMomentum,
575
+ type LiveLineMomentumColors,
576
+ type LiveLinePoint,
577
+ } from './components/live-line-chart';
578
+ export {
579
+ PolarAreaChart,
580
+ usePolarAreaChart,
581
+ type PolarAreaChartProps,
582
+ type PolarAreaChartHandle,
583
+ type PolarAreaChartHeaderProps,
584
+ type PolarAreaChartGridProps,
585
+ type PolarAreaChartWedgesProps,
586
+ type PolarAreaChartLabelsProps,
587
+ type PolarAreaChartTooltipProps,
588
+ type PolarAreaChartLegendProps,
589
+ type PolarAreaChartSkeletonProps,
590
+ type PolarAreaChartStatus,
591
+ type PolarAreaScale,
592
+ type PolarAreaDatum,
593
+ } from './components/polar-area-chart';
559
594
  export { Textarea, type TextareaProps } from './components/textarea';
560
595
  export {
561
596
  TagInput,
@@ -130,6 +130,50 @@ const INK_FLOOR = 3;
130
130
  * the colour it was given. Compositing happens in gamma space, the way the
131
131
  * renderer does it, before the luminance is taken.
132
132
  */
133
+ /** A colour moved `amount` of the way towards white, or towards black when negative. */
134
+ function tone(color: string, amount: number): string {
135
+ const rgb = channelsOf(color);
136
+ if (!rgb) return color;
137
+
138
+ const target = amount >= 0 ? 255 : 0;
139
+ const t = Math.min(Math.abs(amount), 0.85);
140
+ const [r, g, b] = rgb.map((c) => Math.round(c + (target - c) * t));
141
+ return `rgb(${r}, ${g}, ${b})`;
142
+ }
143
+
144
+ /**
145
+ * The colour for the `index`th thing in a chart that draws an unbounded number
146
+ * of them.
147
+ *
148
+ * There are five series tokens, and a chart is routinely asked to draw six
149
+ * things. Taking the palette modulo its length hands two of them the identical
150
+ * colour, which in a chart whose whole job is telling parts apart is a bug the
151
+ * theme decides the severity of — on a theme whose first token is green, the
152
+ * sixth wedge is a second green one.
153
+ *
154
+ * So each further lap through the palette is drawn a step further along a tone
155
+ * run, keeping the theme's own hues rather than inventing new ones.
156
+ *
157
+ * The run goes *away* from whichever end the colour already sits near, and
158
+ * always in that one direction. Alternating lighter and darker would be the
159
+ * obvious thing and it reintroduces the bug on the themes that matter: a token
160
+ * of `#fafafa` lightened is `#fafafa` back again, so the second lap of a
161
+ * near-white palette entry is the same colour it was trying not to be.
162
+ */
163
+ export function seriesColorAt(palette: string[], index: number): string {
164
+ if (!palette.length) return FALLBACK_SERIES[0]!;
165
+
166
+ const base = palette[index % palette.length]!;
167
+ const lap = Math.floor(index / palette.length);
168
+ if (lap <= 0) return base;
169
+
170
+ const rgb = channelsOf(base);
171
+ const away = rgb && luminanceOf(rgb) > 0.4 ? -1 : 1;
172
+ // Each lap covers two thirds of what is left, so every one lands somewhere
173
+ // the last did not.
174
+ return tone(base, away * (1 - 0.66 ** lap));
175
+ }
176
+
133
177
  export function inkOn(fill: string, behind?: string, opacity = 1): ChartInk {
134
178
  const front = channelsOf(fill);
135
179
  if (!front) return LIGHT_INK;