@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.
- package/CHANGELOG.md +1070 -1
- package/dist/AreaChart.d.ts +12 -1
- package/dist/AreaChart.js +131 -13
- package/dist/BarChart.js +184 -30
- package/dist/BarList.d.ts +85 -5
- package/dist/BarList.js +25 -4
- package/dist/BoxList.d.ts +70 -3
- package/dist/BoxList.js +21 -7
- package/dist/BoxPlot.d.ts +2 -1
- package/dist/BoxPlot.js +101 -9
- package/dist/Candlestick.d.ts +13 -1
- package/dist/Candlestick.js +89 -3
- package/dist/ChartContainer.d.ts +36 -48
- package/dist/ChartContainer.js +465 -59
- package/dist/ChartRow.d.ts +9 -2
- package/dist/ChartRow.js +86 -12
- package/dist/HeatMap.d.ts +176 -0
- package/dist/HeatMap.js +344 -0
- package/dist/Layers.d.ts +5 -1
- package/dist/Layers.js +1014 -253
- package/dist/Legend.js +8 -4
- package/dist/LineChart.d.ts +18 -1
- package/dist/LineChart.js +165 -4
- package/dist/ListTable.d.ts +30 -3
- package/dist/ListTable.js +381 -23
- package/dist/ScatterChart.d.ts +3 -2
- package/dist/ScatterChart.js +68 -4
- package/dist/XAxis.js +40 -22
- package/dist/area.d.ts +34 -1
- package/dist/area.js +88 -1
- package/dist/bars.d.ts +57 -3
- package/dist/bars.js +237 -26
- package/dist/box.d.ts +2 -2
- package/dist/box.js +158 -40
- package/dist/brush.d.ts +142 -0
- package/dist/brush.js +179 -0
- package/dist/child-index.d.ts +27 -0
- package/dist/child-index.js +57 -0
- package/dist/context.d.ts +859 -33
- package/dist/cursors.d.ts +161 -0
- package/dist/cursors.js +503 -0
- package/dist/decimate.d.ts +78 -1
- package/dist/decimate.js +157 -0
- package/dist/heat.d.ts +163 -0
- package/dist/heat.js +659 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +22 -0
- package/dist/line.d.ts +137 -0
- package/dist/line.js +328 -0
- package/dist/ohlc.d.ts +16 -1
- package/dist/ohlc.js +93 -4
- package/dist/scatter.d.ts +17 -9
- package/dist/scatter.js +221 -33
- package/dist/select.d.ts +13 -5
- package/dist/select.js +14 -6
- package/dist/selection-fixtures.d.ts +174 -0
- package/dist/selection-fixtures.js +569 -0
- package/dist/selection-stories.d.ts +73 -0
- package/dist/selection-stories.js +301 -0
- package/dist/selectors.d.ts +316 -0
- package/dist/selectors.js +391 -0
- package/dist/span.d.ts +122 -0
- package/dist/span.js +203 -0
- package/dist/sweep.d.ts +154 -0
- package/dist/sweep.js +282 -0
- package/dist/theme.d.ts +456 -5
- package/dist/theme.js +217 -41
- package/dist/tracker.d.ts +6 -0
- package/dist/tracker.js +6 -0
- package/dist/tradingAxis.fixture.d.ts +78 -0
- package/dist/tradingAxis.fixture.js +215 -0
- package/dist/useChartLegend.js +18 -3
- 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
|