nanoplot 0.0.21 → 0.0.23

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 (62) hide show
  1. package/bun.lockb +0 -0
  2. package/dist/index.css +1 -1
  3. package/dist/src/components/Bars/Bars.d.ts +1 -1
  4. package/dist/src/components/Bars/Bars.js +1 -1
  5. package/dist/src/components/Bars/components/BarsVerticalLoading.js +2 -2
  6. package/dist/src/components/Bars/components/HorizontalBars.js +6 -6
  7. package/dist/src/{app/bar-graph → components/Bars}/components/Rect.js +3 -3
  8. package/dist/src/components/Bars/components/VerticalBars.d.ts +1 -1
  9. package/dist/src/components/Bars/components/VerticalBars.js +29 -45
  10. package/dist/src/components/Graph/Graph.d.ts +1 -1
  11. package/dist/src/components/Graph/Graph.js +6 -6
  12. package/dist/src/components/GridLines/GridLines.js +2 -2
  13. package/dist/src/components/Legend/Legend.d.ts +2 -2
  14. package/dist/src/components/Legend/Legend.js +3 -3
  15. package/dist/src/components/Lines/Lines.d.ts +3 -3
  16. package/dist/src/components/Lines/Lines.js +13 -25
  17. package/dist/src/components/Lines/components/LinesLoading.js +1 -1
  18. package/dist/src/components/Lines/components/LinesTooltip.d.ts +1 -1
  19. package/dist/src/components/Lines/components/LinesTooltip.js +7 -7
  20. package/dist/src/components/Overlay/Overlay.d.ts +4 -0
  21. package/dist/src/components/Overlay/Overlay.js +9 -5
  22. package/dist/src/components/Overlay/OverlayRect.js +4 -4
  23. package/dist/src/components/Pie/Pie.js +8 -8
  24. package/dist/src/components/Pie/components/PieEmpty.js +2 -2
  25. package/dist/src/components/Pie/components/PieLoading.js +3 -3
  26. package/dist/src/components/Radar/Radar.js +6 -6
  27. package/dist/src/components/Radar/components/RadarSkeleton.js +3 -3
  28. package/dist/src/components/Scatter/Scatter.js +6 -6
  29. package/dist/src/components/Scatter/components/ScatterLoading.js +1 -1
  30. package/dist/src/components/Sunburst/Sunburst.js +3 -3
  31. package/dist/src/components/Sunburst/SunburstLoading.js +1 -1
  32. package/dist/src/components/Tooltip/Popup.d.ts +1 -1
  33. package/dist/src/components/Tooltip/Popup.js +2 -2
  34. package/dist/src/components/Worldmap/Worldmap.d.ts +3 -3
  35. package/dist/src/components/Worldmap/Worldmap.js +187 -7
  36. package/dist/src/components/XAxis/XAxis.d.ts +2 -2
  37. package/dist/src/components/XAxis/XAxis.js +4 -4
  38. package/dist/src/components/YAxis/YAxis.d.ts +2 -2
  39. package/dist/src/components/YAxis/YAxis.js +4 -4
  40. package/dist/src/export/index.d.ts +2 -2
  41. package/dist/src/export/index.js +2 -2
  42. package/dist/src/hooks/use-graph/use-client-graph.d.ts +1 -1
  43. package/dist/src/hooks/use-graph/use-graph.js +2 -2
  44. package/dist/src/hooks/use-graph/use-server-graph.d.ts +1 -1
  45. package/dist/src/hooks/use-mouse-coordinates.js +1 -1
  46. package/dist/src/utils/children/children.d.ts +1 -1
  47. package/dist/src/utils/color/color.d.ts +1 -0
  48. package/dist/src/utils/color/color.js +43 -0
  49. package/dist/src/utils/coordinates/coordinates.d.ts +1 -1
  50. package/dist/src/utils/coordinates/coordinates.js +1 -1
  51. package/dist/src/utils/domain/date-domain.d.ts +1 -1
  52. package/dist/src/utils/domain/domain.d.ts +3 -3
  53. package/dist/src/utils/domain/domain.js +4 -4
  54. package/dist/src/utils/graph/graph.d.ts +1 -1
  55. package/dist/tsconfig.typings.tsbuildinfo +1 -1
  56. package/package.json +2 -2
  57. package/tailwind-container-queries.ts +5 -1
  58. package/tsconfig.json +1 -4
  59. package/tsconfig.typings.json +1 -1
  60. package/dist/src/utils/countries.d.ts +0 -181
  61. package/dist/src/utils/countries.js +0 -181
  62. /package/dist/src/{app/bar-graph → components/Bars}/components/Rect.d.ts +0 -0
@@ -89,4 +89,47 @@ export const ColorUtils = {
89
89
  ];
90
90
  return `rgb(${r}, ${g}, ${b})`;
91
91
  },
92
+ textFor: (color) => {
93
+ var _a;
94
+ const isKnownColor = (_a = COLORS.find(({ fill }) => fill === color)) === null || _a === void 0 ? void 0 : _a.color;
95
+ if (isKnownColor)
96
+ return isKnownColor;
97
+ const hexToRgb = (hex) => {
98
+ hex = hex.replace(/^#/, "");
99
+ if (hex.length === 3)
100
+ hex = hex
101
+ .split("")
102
+ .map((x) => x + x)
103
+ .join("");
104
+ const num = parseInt(hex, 16);
105
+ return [num >> 16, (num >> 8) & 255, num & 255];
106
+ };
107
+ const hslToRgb = (h, s, l) => {
108
+ s /= 100;
109
+ l /= 100;
110
+ const k = (n) => (n + h / 30) % 12;
111
+ const a = s * Math.min(l, 1 - l);
112
+ const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1));
113
+ return [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
114
+ };
115
+ let rgb = null;
116
+ // Extract first hex color
117
+ const hexMatch = color.match(/#([0-9a-fA-F]{3,6})/);
118
+ if (hexMatch)
119
+ rgb = hexToRgb(hexMatch[0]);
120
+ // Extract first RGB color
121
+ const rgbMatch = color.match(/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/);
122
+ if (rgbMatch)
123
+ rgb = rgbMatch.slice(1, 4).map(Number);
124
+ // Extract first HSL color and convert to RGB (supporting "deg" in hue)
125
+ const hslMatch = color.match(/hsl\(\s*(\d+)(?:deg)?,\s*(\d+)%?,\s*(\d+)%?\s*\)/);
126
+ if (hslMatch)
127
+ rgb = hslToRgb(Number(hslMatch[1]), Number(hslMatch[2]), Number(hslMatch[3]));
128
+ // Default to white if parsing fails
129
+ if (!rgb)
130
+ rgb = [255, 255, 255];
131
+ // Calculate brightness
132
+ const brightness = Math.round((rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000);
133
+ return brightness > 125 ? "black" : "white";
134
+ },
92
135
  };
@@ -1,4 +1,4 @@
1
- import { GraphContext } from "@/hooks/use-graph/use-graph";
1
+ import { GraphContext } from "../../hooks/use-graph/use-graph";
2
2
  export declare const CoordinatesUtils: {
3
3
  xCoordinateFor: ({ domain, viewbox }: {
4
4
  viewbox: GraphContext["viewbox"];
@@ -1,4 +1,4 @@
1
- import { MathUtils } from "@/utils/math/math";
1
+ import { MathUtils } from "../math/math";
2
2
  export const CoordinatesUtils = {
3
3
  xCoordinateFor: ({ domain, viewbox }) => {
4
4
  /*
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from "react";
2
- import { XAxis } from "@/components/XAxis/XAxis";
2
+ import { XAxis } from "../../components/XAxis/XAxis";
3
3
  type Jumps = NonNullable<ComponentProps<typeof XAxis>["ticks"]>["jumps"];
4
4
  type TimeseriesFormats = NonNullable<Exclude<Jumps, number | "auto">>;
5
5
  export declare const times: {
@@ -1,7 +1,7 @@
1
- import { XAxis } from "@/components/XAxis/XAxis";
2
1
  import { ComponentProps } from "react";
3
- import { GraphContext } from "@/hooks/use-graph/use-graph";
4
- import { YAxis } from "@/components/YAxis/YAxis";
2
+ import { GraphContext } from "../../hooks/use-graph/use-graph";
3
+ import { XAxis } from "../../components/XAxis/XAxis";
4
+ import { YAxis } from "../../components/YAxis/YAxis";
5
5
  export declare const DomainUtils: {
6
6
  autoMinFor: (value: number) => number;
7
7
  autoMaxFor: (value: number) => number;
@@ -1,7 +1,7 @@
1
- import { GraphUtils } from "@/utils/graph/graph";
2
- import { MathUtils } from "@/utils/math/math";
3
- import { ObjectUtils } from "@/utils/object/object";
4
- import { DateDomain } from "@/utils/domain/date-domain";
1
+ import { GraphUtils } from "../graph/graph";
2
+ import { DateDomain } from "./date-domain";
3
+ import { MathUtils } from "../math/math";
4
+ import { ObjectUtils } from "../object/object";
5
5
  const roundUp = (num, nearest) => Math.ceil(num / nearest) * nearest;
6
6
  const roundDown = (num, nearest) => Math.floor(num / nearest) * nearest;
7
7
  export const DomainUtils = {
@@ -1,4 +1,4 @@
1
- import { SegmentDataset, XYDataset } from "@/hooks/use-graph/use-graph";
1
+ import { SegmentDataset, XYDataset } from "../../hooks/use-graph/use-graph";
2
2
  export declare const GraphUtils: {
3
3
  isSegmentData: (data: SegmentDataset | XYDataset) => data is SegmentDataset;
4
4
  isXYData: (data: SegmentDataset | XYDataset) => data is XYDataset;