panelui-native 0.99.0 → 0.101.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.
Files changed (46) hide show
  1. package/README.md +2 -0
  2. package/lib/module/components/animated-badge/index.js +24 -2
  3. package/lib/module/components/animated-badge/index.js.map +1 -1
  4. package/lib/module/components/bump-chart/index.js +1236 -0
  5. package/lib/module/components/bump-chart/index.js.map +1 -0
  6. package/lib/module/components/compare/index.js +576 -0
  7. package/lib/module/components/compare/index.js.map +1 -0
  8. package/lib/module/components/mirror-area-chart/index.js +1113 -0
  9. package/lib/module/components/mirror-area-chart/index.js.map +1 -0
  10. package/lib/module/components/sankey-chart/index.js +933 -0
  11. package/lib/module/components/sankey-chart/index.js.map +1 -0
  12. package/lib/module/components/sankey-chart/sankey-layout.js +530 -0
  13. package/lib/module/components/sankey-chart/sankey-layout.js.map +1 -0
  14. package/lib/module/icons/index.js +15 -3
  15. package/lib/module/icons/index.js.map +1 -1
  16. package/lib/module/index.js +4 -0
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/module/utils/chart.js +101 -0
  19. package/lib/module/utils/chart.js.map +1 -1
  20. package/lib/typescript/src/components/animated-badge/index.d.ts +5 -0
  21. package/lib/typescript/src/components/animated-badge/index.d.ts.map +1 -1
  22. package/lib/typescript/src/components/bump-chart/index.d.ts +267 -0
  23. package/lib/typescript/src/components/bump-chart/index.d.ts.map +1 -0
  24. package/lib/typescript/src/components/compare/index.d.ts +183 -0
  25. package/lib/typescript/src/components/compare/index.d.ts.map +1 -0
  26. package/lib/typescript/src/components/mirror-area-chart/index.d.ts +263 -0
  27. package/lib/typescript/src/components/mirror-area-chart/index.d.ts.map +1 -0
  28. package/lib/typescript/src/components/sankey-chart/index.d.ts +307 -0
  29. package/lib/typescript/src/components/sankey-chart/index.d.ts.map +1 -0
  30. package/lib/typescript/src/components/sankey-chart/sankey-layout.d.ts +107 -0
  31. package/lib/typescript/src/components/sankey-chart/sankey-layout.d.ts.map +1 -0
  32. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +4 -0
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/lib/typescript/src/utils/chart.d.ts +40 -0
  36. package/lib/typescript/src/utils/chart.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/components/animated-badge/index.tsx +35 -2
  39. package/src/components/bump-chart/index.tsx +1455 -0
  40. package/src/components/compare/index.tsx +650 -0
  41. package/src/components/mirror-area-chart/index.tsx +1333 -0
  42. package/src/components/sankey-chart/index.tsx +1165 -0
  43. package/src/components/sankey-chart/sankey-layout.ts +645 -0
  44. package/src/icons/index.tsx +20 -6
  45. package/src/index.ts +62 -0
  46. package/src/utils/chart.ts +116 -0
package/src/index.ts CHANGED
@@ -504,6 +504,15 @@ export {
504
504
  type ComboboxSelection,
505
505
  type ComboboxPresentation,
506
506
  } from './components/combobox';
507
+ export {
508
+ Compare,
509
+ type CompareProps,
510
+ type CompareBeforeProps,
511
+ type CompareAfterProps,
512
+ type CompareHandleProps,
513
+ type CompareLabelProps,
514
+ type CompareOrientation,
515
+ } from './components/compare';
507
516
  export {
508
517
  ContextMenu,
509
518
  type ContextMenuProps,
@@ -711,6 +720,25 @@ export {
711
720
  type BubbleChartPoint,
712
721
  type BubbleChartStatus,
713
722
  } from './components/bubble-chart';
723
+ export {
724
+ BumpChart,
725
+ useBumpChart,
726
+ bumpRanks,
727
+ type BumpChartProps,
728
+ type BumpChartHandle,
729
+ type BumpChartHeaderProps,
730
+ type BumpChartGridProps,
731
+ type BumpChartLineProps,
732
+ type BumpChartSkeletonProps,
733
+ type BumpChartXAxisProps,
734
+ type BumpChartYAxisProps,
735
+ type BumpChartLabelsProps,
736
+ type BumpChartTooltipProps,
737
+ type BumpChartLegendProps,
738
+ type BumpChartStatus,
739
+ type BumpChartDatum,
740
+ type BumpRanks,
741
+ } from './components/bump-chart';
714
742
  export {
715
743
  PyramidChart,
716
744
  usePyramidChart,
@@ -927,6 +955,24 @@ export {
927
955
  type MessageScrollerButtonProps,
928
956
  type MessageScrollerPosition,
929
957
  } from './components/message-scroller';
958
+ export {
959
+ MirrorAreaChart,
960
+ useMirrorAreaChart,
961
+ type MirrorAreaChartProps,
962
+ type MirrorAreaChartHandle,
963
+ type MirrorAreaChartHeaderProps,
964
+ type MirrorAreaChartGridProps,
965
+ type MirrorAreaChartBaselineProps,
966
+ type MirrorAreaChartAreaProps,
967
+ type MirrorAreaChartSkeletonProps,
968
+ type MirrorAreaChartXAxisProps,
969
+ type MirrorAreaChartYAxisProps,
970
+ type MirrorAreaChartTooltipProps,
971
+ type MirrorAreaChartLegendProps,
972
+ type MirrorAreaChartStatus,
973
+ type MirrorAreaChartSide,
974
+ type MirrorAreaChartDatum,
975
+ } from './components/mirror-area-chart';
930
976
  export {
931
977
  Message,
932
978
  type MessageProps,
@@ -1065,6 +1111,22 @@ export {
1065
1111
  type RingChartLegendProps,
1066
1112
  type RingDatum,
1067
1113
  } from './components/ring-chart';
1114
+ export {
1115
+ SankeyChart,
1116
+ useSankeyChart,
1117
+ type SankeyChartProps,
1118
+ type SankeyChartHandle,
1119
+ type SankeyChartHeaderProps,
1120
+ type SankeyChartLinksProps,
1121
+ type SankeyChartNodesProps,
1122
+ type SankeyChartLabelsProps,
1123
+ type SankeyChartTooltipProps,
1124
+ type SankeyChartSkeletonProps,
1125
+ type SankeyChartStatus,
1126
+ type SankeyNode,
1127
+ type SankeyLink,
1128
+ type SankeyAlign,
1129
+ } from './components/sankey-chart';
1068
1130
  export {
1069
1131
  ScatterChart,
1070
1132
  useScatterChart,
@@ -560,6 +560,76 @@ export function areaPath(
560
560
  .join(' ');
561
561
  }
562
562
 
563
+ /**
564
+ * A colour as a gradient stop: the colour without its alpha, and the alpha as
565
+ * the stop's opacity. A `<Stop>` given `rgba(255,255,255,0.13)` as its colour
566
+ * draws it opaque on native, so a translucent token such as `--color-skeleton`
567
+ * comes out solid white in a dark theme.
568
+ */
569
+ export function colorStop(color: string): { stopColor: string; stopOpacity: number } {
570
+ const value = color.trim();
571
+ const clamp = (alpha: number) => (Number.isFinite(alpha) ? Math.min(Math.max(alpha, 0), 1) : 1);
572
+
573
+ // #rgba and #rrggbbaa
574
+ if (/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.test(value)) {
575
+ const body =
576
+ value.length === 5
577
+ ? value
578
+ .slice(1)
579
+ .split('')
580
+ .map((digit) => digit + digit)
581
+ .join('')
582
+ : value.slice(1);
583
+ return {
584
+ stopColor: `#${body.slice(0, 6)}`,
585
+ stopOpacity: clamp(parseInt(body.slice(6, 8), 16) / 255),
586
+ };
587
+ }
588
+
589
+ // rgba(r, g, b, a) and rgb(r g b / a)
590
+ const match = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)\s*[,/]\s*([\d.]+%?)\s*\)$/i.exec(value);
591
+ if (match) {
592
+ const raw = match[4]!;
593
+ const alpha = raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw);
594
+ return { stopColor: `rgb(${match[1]}, ${match[2]}, ${match[3]})`, stopOpacity: clamp(alpha) };
595
+ }
596
+
597
+ return { stopColor: value, stopOpacity: 1 };
598
+ }
599
+
600
+ /**
601
+ * One unbroken run of points joined by S-curves, for a chart of positions.
602
+ *
603
+ * Each join leaves one point level and arrives at the next one level, with
604
+ * both control points at the midpoint between them. A line that holds its
605
+ * position stays flat, and a line that changes position crosses over in the
606
+ * middle of the gap. The monotone curve suits values, not places: it bends
607
+ * through every point, so a series holding its rank would still look like it
608
+ * was moving.
609
+ */
610
+ export function bumpSegment(points: ChartPoint[]): string {
611
+ 'worklet';
612
+ if (!points.length) return '';
613
+ let d = `M${points[0]!.x},${points[0]!.y}`;
614
+ for (let i = 1; i < points.length; i += 1) {
615
+ const from = points[i - 1]!;
616
+ const to = points[i]!;
617
+ const mid = (from.x + to.x) / 2;
618
+ d += ` C${mid},${from.y} ${mid},${to.y} ${to.x},${to.y}`;
619
+ }
620
+ return d;
621
+ }
622
+
623
+ /** A dot at every point, as one path, so a series' markers cost one node. */
624
+ export function dotsPath(points: ChartPoint[], radius: number): string {
625
+ 'worklet';
626
+ let d = '';
627
+ for (const point of points) {
628
+ d += `M${point.x - radius},${point.y} a${radius},${radius} 0 1,0 ${radius * 2},0 a${radius},${radius} 0 1,0 ${-radius * 2},0 `;
629
+ }
630
+ return d;
631
+ }
632
+
563
633
  /**
564
634
  * A rounded rectangle, built as a path rather than drawn as a `Rect`.
565
635
  *
@@ -1087,3 +1157,49 @@ export function ribbonPath(
1087
1157
  `Z`
1088
1158
  );
1089
1159
  }
1160
+
1161
+ /**
1162
+ * One ribbon of a flow diagram: a band of constant thickness running from a
1163
+ * centre at one end to a different centre at the other.
1164
+ *
1165
+ * Given by centres rather than edges because that is what the layout produces
1166
+ * — a ribbon is stacked against its node's edge and then recorded by its
1167
+ * middle, so that growing it in place thickens it about its own centre line
1168
+ * instead of sliding it down the node.
1169
+ *
1170
+ * The ends stay vertical whatever the two centres are, so a ribbon meets the
1171
+ * flat side of a node exactly rather than at the angle it happened to arrive.
1172
+ * `curve` is how far the control points reach towards the middle, as a
1173
+ * fraction of the horizontal run: `0.5` puts both on the halfway line, which
1174
+ * is the S that reads as one continuous flow, and `0` gives a straight
1175
+ * diagonal.
1176
+ */
1177
+ export function flowPath(
1178
+ x0: number,
1179
+ cy0: number,
1180
+ x1: number,
1181
+ cy1: number,
1182
+ thickness: number,
1183
+ curve: number
1184
+ ): string {
1185
+ 'worklet';
1186
+ if (!(thickness > 0)) return '';
1187
+
1188
+ const half = thickness / 2;
1189
+ const topStart = cy0 - half;
1190
+ const topEnd = cy1 - half;
1191
+ const bottomStart = cy0 + half;
1192
+ const bottomEnd = cy1 + half;
1193
+
1194
+ const run = x1 - x0;
1195
+ const near = x0 + run * curve;
1196
+ const far = x1 - run * curve;
1197
+
1198
+ return (
1199
+ `M${x0},${topStart}` +
1200
+ `C${near},${topStart},${far},${topEnd},${x1},${topEnd}` +
1201
+ `L${x1},${bottomEnd}` +
1202
+ `C${far},${bottomEnd},${near},${bottomStart},${x0},${bottomStart}` +
1203
+ `Z`
1204
+ );
1205
+ }