@pond-ts/charts 0.57.0 → 0.58.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 (73) hide show
  1. package/CHANGELOG.md +1070 -1
  2. package/dist/AreaChart.d.ts +12 -1
  3. package/dist/AreaChart.js +131 -13
  4. package/dist/BarChart.js +184 -30
  5. package/dist/BarList.d.ts +85 -5
  6. package/dist/BarList.js +25 -4
  7. package/dist/BoxList.d.ts +70 -3
  8. package/dist/BoxList.js +21 -7
  9. package/dist/BoxPlot.d.ts +2 -1
  10. package/dist/BoxPlot.js +101 -9
  11. package/dist/Candlestick.d.ts +13 -1
  12. package/dist/Candlestick.js +89 -3
  13. package/dist/ChartContainer.d.ts +36 -48
  14. package/dist/ChartContainer.js +465 -59
  15. package/dist/ChartRow.d.ts +9 -2
  16. package/dist/ChartRow.js +86 -12
  17. package/dist/HeatMap.d.ts +176 -0
  18. package/dist/HeatMap.js +344 -0
  19. package/dist/Layers.d.ts +5 -1
  20. package/dist/Layers.js +1014 -253
  21. package/dist/Legend.js +8 -4
  22. package/dist/LineChart.d.ts +18 -1
  23. package/dist/LineChart.js +165 -4
  24. package/dist/ListTable.d.ts +30 -3
  25. package/dist/ListTable.js +381 -23
  26. package/dist/ScatterChart.d.ts +3 -2
  27. package/dist/ScatterChart.js +68 -4
  28. package/dist/XAxis.js +40 -22
  29. package/dist/area.d.ts +34 -1
  30. package/dist/area.js +88 -1
  31. package/dist/bars.d.ts +57 -3
  32. package/dist/bars.js +237 -26
  33. package/dist/box.d.ts +2 -2
  34. package/dist/box.js +158 -40
  35. package/dist/brush.d.ts +142 -0
  36. package/dist/brush.js +179 -0
  37. package/dist/child-index.d.ts +27 -0
  38. package/dist/child-index.js +57 -0
  39. package/dist/context.d.ts +859 -33
  40. package/dist/cursors.d.ts +161 -0
  41. package/dist/cursors.js +503 -0
  42. package/dist/decimate.d.ts +78 -1
  43. package/dist/decimate.js +157 -0
  44. package/dist/heat.d.ts +163 -0
  45. package/dist/heat.js +659 -0
  46. package/dist/index.d.ts +11 -2
  47. package/dist/index.js +22 -0
  48. package/dist/line.d.ts +137 -0
  49. package/dist/line.js +328 -0
  50. package/dist/ohlc.d.ts +16 -1
  51. package/dist/ohlc.js +93 -4
  52. package/dist/scatter.d.ts +17 -9
  53. package/dist/scatter.js +221 -33
  54. package/dist/select.d.ts +13 -5
  55. package/dist/select.js +14 -6
  56. package/dist/selection-fixtures.d.ts +174 -0
  57. package/dist/selection-fixtures.js +569 -0
  58. package/dist/selection-stories.d.ts +73 -0
  59. package/dist/selection-stories.js +301 -0
  60. package/dist/selectors.d.ts +316 -0
  61. package/dist/selectors.js +391 -0
  62. package/dist/span.d.ts +122 -0
  63. package/dist/span.js +203 -0
  64. package/dist/sweep.d.ts +154 -0
  65. package/dist/sweep.js +282 -0
  66. package/dist/theme.d.ts +456 -5
  67. package/dist/theme.js +217 -41
  68. package/dist/tracker.d.ts +6 -0
  69. package/dist/tracker.js +6 -0
  70. package/dist/tradingAxis.fixture.d.ts +78 -0
  71. package/dist/tradingAxis.fixture.js +215 -0
  72. package/dist/useChartLegend.js +18 -3
  73. package/package.json +3 -3
@@ -0,0 +1,57 @@
1
+ import { Children, cloneElement, Fragment, isValidElement, useEffect, useRef, } from 'react';
2
+ import { isDev } from './dev.js';
3
+ /**
4
+ * Inject each child's JSX position as an `index` prop, so a child registers its
5
+ * **declaration order** rather than its mount order — and warn (dev, once per
6
+ * component instance) when a `<Fragment>` child swallows that injection.
7
+ *
8
+ * Two components inject this way — `<ChartRow>` into its axes, `<Layers>` into
9
+ * its draw layers — and both are defeated the same way: a fragment accepts no
10
+ * props, so the index stops there and every element inside falls back to its
11
+ * `index = 0` default. What makes it worth a warning rather than a doc note is
12
+ * that the failure is **silent and plausible**: the sort is stable, so the
13
+ * resulting tie resolves to mount order, which on a synchronous tree matches
14
+ * declaration order. The stack looks correct right up to the case the injection
15
+ * exists for — an element toggled on between two others, which lands on top
16
+ * instead of slotting into place.
17
+ *
18
+ * The fragment is deliberately **not** cloned. Cloning it makes React emit its
19
+ * own, vaguer "invalid prop `index` supplied to `React.Fragment`" on top of
20
+ * ours, which is how this class of bug hid in plain sight: the message named the
21
+ * prop but not the consequence, so it read as cosmetic.
22
+ *
23
+ * @param children the component's `children`
24
+ * @param owner the component name, for the warning (e.g. `'<Layers>'`)
25
+ * @param consequence what breaks, in one clause — the part a reader acts on
26
+ */
27
+ export function useIndexedChildren(children, owner, consequence) {
28
+ let sawFragmentChild = false;
29
+ // `Children.map`'s own return type is a conditional over the `children` type
30
+ // argument, which collapses to something non-iterable when `children` is the
31
+ // broad `ReactNode`. Both callers need the array (one iterates it, one renders
32
+ // it), so the shape is pinned here — `Children.map` really does hand back an
33
+ // array, or `null`/`undefined` for absent children, which both callers handle.
34
+ const indexed = Children.map(children, (child, index) => {
35
+ if (!isValidElement(child))
36
+ return child;
37
+ if (child.type === Fragment) {
38
+ sawFragmentChild = true;
39
+ return child;
40
+ }
41
+ return cloneElement(child, { index });
42
+ });
43
+ // Warned from an effect rather than from the map above: that runs during
44
+ // render, and a render-phase ref write would let a discarded concurrent
45
+ // render burn the once-per-instance flag and swallow the warning entirely.
46
+ const warned = useRef(false);
47
+ useEffect(() => {
48
+ if (!isDev || !sawFragmentChild || warned.current)
49
+ return;
50
+ warned.current = true;
51
+ console.warn(`[pond-charts] a <Fragment> child of ${owner} swallows the injected ` +
52
+ `declaration index, so ${consequence}. List them as direct children, ` +
53
+ 'or return a keyed array instead of a fragment.');
54
+ }, [sawFragmentChild, owner, consequence]);
55
+ return indexed;
56
+ }
57
+ //# sourceMappingURL=child-index.js.map