@octanejs/visx 0.1.37 → 0.1.39

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 (102) hide show
  1. package/package.json +4 -4
  2. package/src/annotation/components/EditableAnnotation.tsrx +6 -3
  3. package/src/annotation/components/EditableAnnotation.tsrx.d.ts +2 -2
  4. package/src/annotation/components/Label.tsrx +11 -2
  5. package/src/axis/axis/Axis.tsrx +4 -2
  6. package/src/brush/BaseBrush.tsrx +6 -7
  7. package/src/brush/BaseBrush.tsrx.d.ts +2 -3
  8. package/src/brush/BrushOverlay.tsrx +11 -8
  9. package/src/brush/BrushOverlay.tsrx.d.ts +3 -8
  10. package/src/brush/BrushSelection.tsrx +2 -3
  11. package/src/brush/BrushSelection.tsrx.d.ts +1 -2
  12. package/src/internal/useMeasure.tsrx +1 -1
  13. package/src/internal/useMeasure.tsrx.d.ts +1 -1
  14. package/src/kernel/warnings.ts +4 -0
  15. package/src/legend/legends/Legend/LegendItem.tsrx +2 -2
  16. package/src/legend/legends/Legend/LegendItem.tsrx.d.ts +2 -2
  17. package/src/legend/legends/Legend/LegendLabel.tsrx +2 -2
  18. package/src/legend/legends/Legend/LegendLabel.tsrx.d.ts +2 -2
  19. package/src/legend/legends/Legend/index.tsrx +30 -31
  20. package/src/legend/types/index.ts +3 -6
  21. package/src/responsive/types/index.ts +3 -21
  22. package/src/sankey/Sankey.tsrx +9 -5
  23. package/src/sankey/Sankey.tsrx.d.ts +3 -3
  24. package/src/shape/shapes/Bar.tsrx +2 -1
  25. package/src/shape/shapes/Bar.tsrx.d.ts +2 -1
  26. package/src/shape/shapes/BarRounded.tsrx +2 -1
  27. package/src/shape/shapes/BarRounded.tsrx.d.ts +2 -1
  28. package/src/shape/shapes/Line.tsrx +2 -1
  29. package/src/shape/shapes/Line.tsrx.d.ts +2 -1
  30. package/src/shape/shapes/LinePath.tsrx +2 -1
  31. package/src/shape/shapes/LinePath.tsrx.d.ts +2 -1
  32. package/src/shape/types/area.ts +2 -1
  33. package/src/text/index.ts +1 -0
  34. package/src/text/types.ts +4 -3
  35. package/src/theme/utils/warn.ts +4 -0
  36. package/src/tooltip/enhancers/withTooltip.tsrx +14 -9
  37. package/src/tooltip/enhancers/withTooltip.tsrx.d.ts +5 -4
  38. package/src/tooltip/floating/ChartTooltip.tsrx +4 -3
  39. package/src/tooltip/floating/ChartTooltip.tsrx.d.ts +2 -3
  40. package/src/tooltip/floating/ChartTooltipContent.tsrx +7 -6
  41. package/src/tooltip/floating/ChartTooltipContent.tsrx.d.ts +6 -6
  42. package/src/tooltip/floating/FloatingTooltip.tsrx +24 -18
  43. package/src/tooltip/floating/FloatingTooltip.tsrx.d.ts +7 -7
  44. package/src/tooltip/floating/context.tsrx +0 -1
  45. package/src/tooltip/floating/context.tsrx.d.ts +1 -2
  46. package/src/tooltip/floating/internalTypes.ts +13 -109
  47. package/src/tooltip/floating/types.ts +29 -26
  48. package/src/tooltip/floating/useChartTooltip.tsrx +1 -2
  49. package/src/tooltip/floating/useChartTooltip.tsrx.d.ts +1 -2
  50. package/src/tooltip/floating/useFloatingTooltip.tsrx +11 -6
  51. package/src/tooltip/hooks/useTooltipInPortal.tsrx +2 -2
  52. package/src/tooltip/hooks/useTooltipInPortal.tsrx.d.ts +2 -2
  53. package/src/tooltip/tooltips/Tooltip.tsrx +5 -2
  54. package/src/tooltip/tooltips/Tooltip.tsrx.d.ts +3 -2
  55. package/src/tooltip/tooltips/TooltipWithBounds.tsrx +9 -3
  56. package/src/tooltip/tooltips/TooltipWithBounds.tsrx.d.ts +6 -4
  57. package/src/xychart/components/Tooltip.tsrx +0 -2
  58. package/src/xychart/components/XYChart.tsrx +4 -1
  59. package/src/xychart/components/XYChart.tsrx.d.ts +0 -1
  60. package/src/xychart/components/annotation/private/BaseAnnotation.tsrx +2 -2
  61. package/src/xychart/components/annotation/private/BaseAnnotation.tsrx.d.ts +2 -2
  62. package/src/xychart/components/axis/BaseAxis.tsrx +2 -2
  63. package/src/xychart/components/axis/BaseAxis.tsrx.d.ts +2 -2
  64. package/src/xychart/components/grid/BaseGrid.tsrx +3 -3
  65. package/src/xychart/components/grid/BaseGrid.tsrx.d.ts +3 -3
  66. package/src/xychart/components/series/AnimatedGlyphSeries.tsrx +2 -2
  67. package/src/xychart/components/series/AnimatedGlyphSeries.tsrx.d.ts +2 -2
  68. package/src/xychart/components/series/GlyphSeries.tsrx +1 -2
  69. package/src/xychart/components/series/GlyphSeries.tsrx.d.ts +2 -2
  70. package/src/xychart/components/series/private/AnimatedGlyphs.tsrx +1 -2
  71. package/src/xychart/components/series/private/AnimatedGlyphs.tsrx.d.ts +2 -2
  72. package/src/xychart/components/series/private/BaseAreaSeries.tsrx +6 -3
  73. package/src/xychart/components/series/private/BaseAreaSeries.tsrx.d.ts +3 -3
  74. package/src/xychart/components/series/private/BaseAreaStack.tsrx +36 -28
  75. package/src/xychart/components/series/private/BaseAreaStack.tsrx.d.ts +4 -4
  76. package/src/xychart/components/series/private/BaseBarGroup.tsrx +3 -5
  77. package/src/xychart/components/series/private/BaseBarGroup.tsrx.d.ts +2 -3
  78. package/src/xychart/components/series/private/BaseBarSeries.tsrx +2 -2
  79. package/src/xychart/components/series/private/BaseBarSeries.tsrx.d.ts +2 -2
  80. package/src/xychart/components/series/private/BaseBarStack.tsrx +11 -7
  81. package/src/xychart/components/series/private/BaseBarStack.tsrx.d.ts +3 -3
  82. package/src/xychart/components/series/private/BaseLineSeries.tsrx +6 -3
  83. package/src/xychart/components/series/private/BaseLineSeries.tsrx.d.ts +3 -3
  84. package/src/xychart/hooks/useEventEmitter.tsrx +1 -2
  85. package/src/xychart/hooks/useEventEmitter.tsrx.d.ts +1 -2
  86. package/src/xychart/hooks/useEventEmitters.tsrx +0 -1
  87. package/src/xychart/hooks/useEventEmitters.tsrx.d.ts +0 -1
  88. package/src/xychart/hooks/useEventHandlers.tsrx +0 -1
  89. package/src/xychart/hooks/useEventHandlers.tsrx.d.ts +0 -1
  90. package/src/xychart/hooks/useSeriesEvents.tsrx +0 -1
  91. package/src/xychart/hooks/useSeriesEvents.tsrx.d.ts +0 -1
  92. package/src/xychart/hooks/useStackedData.tsrx.d.ts +1 -1
  93. package/src/xychart/index.ts +1 -0
  94. package/src/xychart/typeguards/events.ts +0 -2
  95. package/src/xychart/types/series.ts +0 -1
  96. package/src/xychart/types/svgPath.ts +5 -0
  97. package/src/xychart/types/theme.ts +4 -3
  98. package/src/xychart/utils/combineBarStackData.ts +1 -2
  99. package/src/xychart/utils/getChildrenAndGrandchildrenWithProps.ts +4 -5
  100. package/src/zoom/Zoom.tsrx +22 -20
  101. package/src/zoom/Zoom.tsrx.d.ts +3 -3
  102. package/src/zoom/types.ts +14 -27
@@ -1,5 +1,5 @@
1
- import { Fragment, createElement, useCallback, useContext, useMemo } from 'octane';
2
- import type { ReactElement, FC } from 'react';
1
+ import { Fragment, useCallback, useContext, useMemo } from 'octane';
2
+ import type { ElementDescriptor } from 'octane';
3
3
  import type { Octane } from 'octane/jsx-runtime';
4
4
  import type { AxisScale } from '@octanejs/visx/axis';
5
5
  import type { SeriesPoint } from 'd3-shape';
@@ -15,6 +15,7 @@ import type {
15
15
  NearestDatumReturnType,
16
16
  SeriesProps,
17
17
  } from '../../../types';
18
+ import type { SvgPathComponent } from '../../../types/svgPath';
18
19
  import DataContext from '../../../context/DataContext.tsrx';
19
20
  import type { BaseAreaSeriesProps } from './BaseAreaSeries.tsrx';
20
21
  import { BaseGlyphSeries } from './BaseGlyphSeries.tsrx';
@@ -23,6 +24,7 @@ import { getStackValue } from '../../../utils/combineBarStackData';
23
24
  import isValidNumber from '../../../typeguards/isValidNumber';
24
25
  import findNearestStackDatum from '../../../utils/findNearestStackDatum';
25
26
  import { AREASTACK_EVENT_SOURCE, XYCHART_EVENT_SOURCE } from '../../../constants';
27
+ import type { SeriesEventsParams } from '../../../hooks/useSeriesEvents.tsrx';
26
28
  import useSeriesEvents from '../../../hooks/useSeriesEvents.tsrx';
27
29
  import defaultRenderGlyph from './defaultRenderGlyph.tsrx';
28
30
  import getScaleBandwidth from '../../../utils/getScaleBandwidth';
@@ -36,10 +38,10 @@ type AreaStackDatum<XScale extends AxisScale, YScale extends AxisScale> =
36
38
  export type BaseAreaStackProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> =
37
39
  {
38
40
  /** `AreaSeries` elements, note we can't strictly enforce this with TS yet. */
39
- children: | ReactElement<AreaStackChildProps<XScale, YScale, Datum>>
40
- | ReactElement<AreaStackChildProps<XScale, YScale, Datum>>[];
41
+ children: | ElementDescriptor<AreaStackChildProps<XScale, YScale, Datum>>
42
+ | ElementDescriptor<AreaStackChildProps<XScale, YScale, Datum>>[];
41
43
  /** Rendered component which is passed path props by BaseAreaStack after processing. */
42
- PathComponent?: FC<Omit<Octane.SVGProps<SVGPathElement>, 'ref'>> | 'path';
44
+ PathComponent?: SvgPathComponent;
43
45
  /** Sets the curve factory (from @octanejs/visx/curve or d3-curve) for the line generator. Defaults to curveLinear. */
44
46
  curve?: AreaProps<Datum>['curve'];
45
47
  /** Whether to render a Line along value of the Area shape (area is fill only). */
@@ -53,7 +55,9 @@ export type BaseAreaStackProps<XScale extends AxisScale, YScale extends AxisScal
53
55
  | 'onFocus'
54
56
  | 'enableEvents'>;
55
57
 
56
- const identity = (_: unknown) => _;
58
+ function identity<T>(value: T): T {
59
+ return value;
60
+ }
57
61
 
58
62
  function BaseAreaStack<XScale extends AxisScale, YScale extends AxisScale, Datum extends object>({
59
63
  PathComponent = 'path',
@@ -118,7 +122,7 @@ function BaseAreaStack<XScale extends AxisScale, YScale extends AxisScale, Datum
118
122
  // pull out all area + line props for each dataKey
119
123
  const stacks = useMemo(
120
124
  () => stackedData.map((stack, stackIndex) => {
121
- const areaSeries: ReactElement<BaseAreaSeriesProps<XScale, YScale, Datum>> | undefined =
125
+ const areaSeries: ElementDescriptor<BaseAreaSeriesProps<XScale, YScale, Datum>> | undefined =
122
126
  seriesChildren.find((child) => child.props.dataKey === stack.key);
123
127
  const {
124
128
  data,
@@ -163,9 +167,11 @@ function BaseAreaStack<XScale extends AxisScale, YScale extends AxisScale, Datum
163
167
  const eventEmitters = useSeriesEvents<XScale, YScale, Datum>({
164
168
  dataKey: dataKeys,
165
169
  enableEvents,
166
- // @ts-expect-error Datum input + return type are expected to be the same type but they differ
167
- // for AreaStack (registry data is StackedDatum, return type is user Datum)
168
- findNearestDatum,
170
+ findNearestDatum: findNearestDatum as unknown as SeriesEventsParams<
171
+ XScale,
172
+ YScale,
173
+ Datum
174
+ >['findNearestDatum'],
169
175
  onBlur,
170
176
  onFocus,
171
177
  onPointerMove,
@@ -196,22 +202,24 @@ function BaseAreaStack<XScale extends AxisScale, YScale extends AxisScale, Datum
196
202
  if (dataKeys.some((key) => dataRegistry.get(key) == null) || !xScale || !yScale || !colorScale) {
197
203
  return null;
198
204
  }
199
- const areaNodes = stacks.map(
200
- (stack) => createElement(
201
- Area,
202
- { key: stack.key, curve, ...stack.accessors },
203
- ({ path }: { path: (data: typeof stack.data) => string | null }) => createElement(
204
- PathComponent,
205
- {
206
- className: 'visx-area',
207
- stroke: 'transparent',
208
- d: path(stack.data) || '',
209
- ...stack.areaProps,
210
- ...eventEmitters,
211
- },
212
- ),
213
- ),
214
- );
205
+ const areaNodes = stacks.map(function (stack) {
206
+ function renderAreaPath(args: { path: (data: typeof stack.data) => string | null }) {
207
+ return (
208
+ <PathComponent
209
+ className="visx-area"
210
+ stroke="transparent"
211
+ d={args.path(stack.data) || ''}
212
+ {...stack.areaProps}
213
+ {...eventEmitters}
214
+ />
215
+ );
216
+ }
217
+ return (
218
+ <Area key={stack.key} curve={curve} {...stack.accessors}>
219
+ {renderAreaPath}
220
+ </Area>
221
+ );
222
+ });
215
223
 
216
224
  return <g className="visx-area-stack">
217
225
  {areaNodes}
@@ -249,8 +257,8 @@ function BaseAreaStack<XScale extends AxisScale, YScale extends AxisScale, Datum
249
257
  data={stack.data}
250
258
  xAccessor={stack.accessors.x || stack.accessors.x1}
251
259
  yAccessor={stack.accessors.y || stack.accessors.y1}
252
- xScale={identity}
253
- yScale={identity}
260
+ xScale={identity as unknown as XScale}
261
+ yScale={identity as unknown as YScale}
254
262
  renderGlyphs={renderGlyphs}
255
263
  />;
256
264
  })}
@@ -1,16 +1,16 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { ReactElement, FC } from 'react';
3
- import type { Octane } from 'octane/jsx-runtime';
2
+ import type { ElementDescriptor } from 'octane';
4
3
  import type { AxisScale } from '@octanejs/visx/axis';
5
4
  import type { StackPathConfig, AreaProps } from '@octanejs/visx/shape';
6
5
  import type { SeriesProps } from '../../../types';
6
+ import type { SvgPathComponent } from '../../../types/svgPath';
7
7
  import type { BaseAreaSeriesProps } from './BaseAreaSeries.tsrx';
8
8
  type AreaStackChildProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> = Omit<BaseAreaSeriesProps<XScale, YScale, Datum>, 'PathComponent' | 'curve'>;
9
9
  export type BaseAreaStackProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> = {
10
10
  /** `AreaSeries` elements, note we can't strictly enforce this with TS yet. */
11
- children: ReactElement<AreaStackChildProps<XScale, YScale, Datum>> | ReactElement<AreaStackChildProps<XScale, YScale, Datum>>[];
11
+ children: ElementDescriptor<AreaStackChildProps<XScale, YScale, Datum>> | ElementDescriptor<AreaStackChildProps<XScale, YScale, Datum>>[];
12
12
  /** Rendered component which is passed path props by BaseAreaStack after processing. */
13
- PathComponent?: FC<Omit<Octane.SVGProps<SVGPathElement>, 'ref'>> | 'path';
13
+ PathComponent?: SvgPathComponent;
14
14
  /** Sets the curve factory (from @octanejs/visx/curve or d3-curve) for the line generator. Defaults to curveLinear. */
15
15
  curve?: AreaProps<Datum>['curve'];
16
16
  /** Whether to render a Line along value of the Area shape (area is fill only). */
@@ -1,6 +1,5 @@
1
1
  import { useContext, useMemo, useEffect, useCallback } from 'octane';
2
- import type { ReactElement, FC } from 'react';
3
- import type { OctaneNode } from 'octane';
2
+ import type { ComponentBody, OctaneNode } from 'octane';
4
3
  import type { PositionScale } from '@octanejs/visx/shape';
5
4
  import { scaleBand } from '@octanejs/visx/scale';
6
5
  import type { BaseBarSeriesProps } from './BaseBarSeries.tsrx';
@@ -30,7 +29,7 @@ export type BaseBarGroupProps<XScale extends PositionScale, YScale extends Posit
30
29
  /** Comparator function to sort `dataKeys` within a bar group. By default the DOM rendering order of `BarGroup`s `children` is used. */
31
30
  sortBars?: (dataKeyA: string, dataKeyB: string) => number;
32
31
  /** Rendered component which is passed BarsProps by BaseBarGroup after processing. */
33
- BarsComponent: FC<BarsProps<XScale, YScale>>;
32
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
34
33
  } & Pick<SeriesProps<XScale, YScale, Datum>, | 'onPointerMove'
35
34
  | 'onPointerOut'
36
35
  | 'onPointerUp'
@@ -149,8 +148,7 @@ export default function BaseBarGroup<XScale extends PositionScale, YScale extend
149
148
  const getWidth = horizontal ? (d: Datum) => Math.abs(getLength(d)) : () => barThickness;
150
149
  const getHeight = horizontal ? () => barThickness : (d: Datum) => Math.abs(getLength(d));
151
150
  // get props from child BarSeries, if available
152
- const childBarSeries: ReactElement<BaseBarSeriesProps<XScale, YScale, Datum>> | undefined =
153
- barSeriesChildren.find((child) => child.props.dataKey === key);
151
+ const childBarSeries = barSeriesChildren.find((child) => child.props.dataKey === key);
154
152
  const { colorAccessor, radius, radiusAll, radiusBottom, radiusLeft, radiusRight, radiusTop } =
155
153
  childBarSeries?.props || {};
156
154
 
@@ -1,6 +1,5 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { FC } from 'react';
3
- import type { OctaneNode } from 'octane';
2
+ import type { ComponentBody, OctaneNode } from 'octane';
4
3
  import type { PositionScale } from '@octanejs/visx/shape';
5
4
  import type { BarsProps, SeriesProps } from '../../../types';
6
5
  export type BaseBarGroupProps<XScale extends PositionScale, YScale extends PositionScale, Datum extends object> = {
@@ -11,6 +10,6 @@ export type BaseBarGroupProps<XScale extends PositionScale, YScale extends Posit
11
10
  /** Comparator function to sort `dataKeys` within a bar group. By default the DOM rendering order of `BarGroup`s `children` is used. */
12
11
  sortBars?: (dataKeyA: string, dataKeyB: string) => number;
13
12
  /** Rendered component which is passed BarsProps by BaseBarGroup after processing. */
14
- BarsComponent: FC<BarsProps<XScale, YScale>>;
13
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
15
14
  } & Pick<SeriesProps<XScale, YScale, Datum>, 'onPointerMove' | 'onPointerOut' | 'onPointerUp' | 'onPointerDown' | 'onBlur' | 'onFocus' | 'enableEvents'>;
16
15
  export default function BaseBarGroup<XScale extends PositionScale, YScale extends PositionScale, Datum extends object>({ children, padding, sortBars, BarsComponent, onBlur, onFocus, onPointerMove, onPointerOut, onPointerUp, onPointerDown, enableEvents, }: BaseBarGroupProps<XScale, YScale, Datum>): import("react").JSX.Element | null;
@@ -1,5 +1,5 @@
1
1
  import { useContext, useEffect, useMemo } from 'octane';
2
- import type { FC } from 'react';
2
+ import type { ComponentBody } from 'octane';
3
3
  import type { AxisScale } from '@octanejs/visx/axis';
4
4
  import DataContext from '../../../context/DataContext.tsrx';
5
5
  import type { Bar, BarsProps, DataContextType, SeriesProps } from '../../../types';
@@ -13,7 +13,7 @@ import useSeriesEvents from '../../../hooks/useSeriesEvents.tsrx';
13
13
  export type BaseBarSeriesProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> =
14
14
  SeriesProps<XScale, YScale, Datum> & {
15
15
  /** Rendered component which is passed BarsProps by BaseBarSeries after processing. */
16
- BarsComponent: FC<BarsProps<XScale, YScale>>;
16
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
17
17
  /**
18
18
  * Specify bar padding when bar thickness does not come from a `band` scale.
19
19
  * Accepted values are [0, 1], 0 = no padding, 1 = no bar, defaults to 0.1.
@@ -1,10 +1,10 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { FC } from 'react';
2
+ import type { ComponentBody } from 'octane';
3
3
  import type { AxisScale } from '@octanejs/visx/axis';
4
4
  import type { BarsProps, SeriesProps } from '../../../types';
5
5
  export type BaseBarSeriesProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> = SeriesProps<XScale, YScale, Datum> & {
6
6
  /** Rendered component which is passed BarsProps by BaseBarSeries after processing. */
7
- BarsComponent: FC<BarsProps<XScale, YScale>>;
7
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
8
8
  /**
9
9
  * Specify bar padding when bar thickness does not come from a `band` scale.
10
10
  * Accepted values are [0, 1], 0 = no padding, 1 = no bar, defaults to 0.1.
@@ -1,5 +1,5 @@
1
1
  import { useContext, useCallback } from 'octane';
2
- import type { ReactElement, FC } from 'react';
2
+ import type { ComponentBody, ElementDescriptor } from 'octane';
3
3
  import type { SeriesPoint } from 'd3-shape';
4
4
  import type { PositionScale, StackPathConfig } from '@octanejs/visx/shape';
5
5
  import { getFirstItem, getSecondItem, getBandwidth } from '@octanejs/visx/shape';
@@ -19,6 +19,7 @@ import type {
19
19
  import isValidNumber from '../../../typeguards/isValidNumber';
20
20
  import { getStackValue } from '../../../utils/combineBarStackData';
21
21
  import { BARSTACK_EVENT_SOURCE, XYCHART_EVENT_SOURCE } from '../../../constants';
22
+ import type { SeriesEventsParams } from '../../../hooks/useSeriesEvents.tsrx';
22
23
  import useSeriesEvents from '../../../hooks/useSeriesEvents.tsrx';
23
24
  import findNearestStackDatum from '../../../utils/findNearestStackDatum';
24
25
  import useStackedData from '../../../hooks/useStackedData.tsrx';
@@ -32,10 +33,10 @@ type StackBar<XScale extends PositionScale, YScale extends PositionScale> =
32
33
  export type BaseBarStackProps<XScale extends PositionScale, YScale extends PositionScale, Datum extends object> =
33
34
  {
34
35
  /** `BarSeries` elements, note we can't strictly enforce this with TS yet. */
35
- children: | ReactElement<BarStackChildProps<XScale, YScale, Datum>>
36
- | ReactElement<BarStackChildProps<XScale, YScale, Datum>>[];
36
+ children: | ElementDescriptor<BarStackChildProps<XScale, YScale, Datum>>
37
+ | ElementDescriptor<BarStackChildProps<XScale, YScale, Datum>>[];
37
38
  /** Rendered component which is passed BarsProps by BaseBarStack after processing. */
38
- BarsComponent: FC<BarsProps<XScale, YScale>>;
39
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
39
40
  } & Pick<StackPathConfig<Datum, string>, | 'offset'
40
41
  | 'order'> & Pick<SeriesProps<XScale, YScale, Datum>, | 'onPointerMove'
41
42
  | 'onPointerOut'
@@ -88,8 +89,11 @@ function BaseBarStack<XScale extends PositionScale, YScale extends PositionScale
88
89
  const eventEmitters = useSeriesEvents<XScale, YScale, Datum>({
89
90
  dataKey: dataKeys,
90
91
  enableEvents,
91
- // @ts-expect-error Datum input + return type are expected to be the same type but they differ for BarStack (registry data is StackedDatum, return type is user Datum)
92
- findNearestDatum,
92
+ findNearestDatum: findNearestDatum as unknown as SeriesEventsParams<
93
+ XScale,
94
+ YScale,
95
+ Datum
96
+ >['findNearestDatum'],
93
97
  onBlur,
94
98
  onFocus,
95
99
  onPointerMove,
@@ -136,7 +140,7 @@ function BaseBarStack<XScale extends PositionScale, YScale extends PositionScale
136
140
  if (!entry) return null;
137
141
 
138
142
  // get props from child BarSeries, if available
139
- const childBarSeries: ReactElement<BaseBarSeriesProps<XScale, YScale, Datum>> | undefined =
143
+ const childBarSeries: ElementDescriptor<BaseBarSeriesProps<XScale, YScale, Datum>> | undefined =
140
144
  seriesChildren.find((child) => child.props.dataKey === barStack.key);
141
145
  const { colorAccessor, radius, radiusAll, radiusBottom, radiusLeft, radiusRight, radiusTop } =
142
146
  childBarSeries?.props || {};
@@ -1,14 +1,14 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { ReactElement, FC } from 'react';
2
+ import type { ComponentBody, ElementDescriptor } from 'octane';
3
3
  import type { PositionScale, StackPathConfig } from '@octanejs/visx/shape';
4
4
  import type { BaseBarSeriesProps } from './BaseBarSeries.tsrx';
5
5
  import type { BarsProps, SeriesProps } from '../../../types';
6
6
  type BarStackChildProps<XScale extends PositionScale, YScale extends PositionScale, Datum extends object> = Omit<BaseBarSeriesProps<XScale, YScale, Datum>, 'BarsComponent'>;
7
7
  export type BaseBarStackProps<XScale extends PositionScale, YScale extends PositionScale, Datum extends object> = {
8
8
  /** `BarSeries` elements, note we can't strictly enforce this with TS yet. */
9
- children: ReactElement<BarStackChildProps<XScale, YScale, Datum>> | ReactElement<BarStackChildProps<XScale, YScale, Datum>>[];
9
+ children: ElementDescriptor<BarStackChildProps<XScale, YScale, Datum>> | ElementDescriptor<BarStackChildProps<XScale, YScale, Datum>>[];
10
10
  /** Rendered component which is passed BarsProps by BaseBarStack after processing. */
11
- BarsComponent: FC<BarsProps<XScale, YScale>>;
11
+ BarsComponent: ComponentBody<BarsProps<XScale, YScale>>;
12
12
  } & Pick<StackPathConfig<Datum, string>, 'offset' | 'order'> & Pick<SeriesProps<XScale, YScale, Datum>, 'onPointerMove' | 'onPointerOut' | 'onPointerUp' | 'onPointerDown' | 'onBlur' | 'onFocus' | 'enableEvents'>;
13
13
  declare function BaseBarStack<XScale extends PositionScale, YScale extends PositionScale, Datum extends object>({ children, order, offset, BarsComponent, onBlur, onFocus, onPointerMove, onPointerOut, onPointerUp, onPointerDown, enableEvents, }: BaseBarStackProps<XScale, YScale, Datum>): import("react").JSX.Element | null;
14
14
  export default BaseBarStack;
@@ -1,11 +1,11 @@
1
1
  import { Fragment, useContext, useCallback, useMemo, useEffect } from 'octane';
2
- import type { FC } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { LinePathProps } from '@octanejs/visx/shape';
5
4
  import { LinePath } from '@octanejs/visx/shape';
6
5
  import type { AxisScale } from '@octanejs/visx/axis';
7
6
  import DataContext from '../../../context/DataContext.tsrx';
8
7
  import type { DataContextType, GlyphsProps, SeriesProps } from '../../../types';
8
+ import type { SvgPathComponent } from '../../../types/svgPath';
9
9
  import getScaledValueFactory from '../../../utils/getScaledValueFactory';
10
10
  import isValidNumber from '../../../typeguards/isValidNumber';
11
11
  import { LINESERIES_EVENT_SOURCE, XYCHART_EVENT_SOURCE } from '../../../constants';
@@ -16,12 +16,15 @@ import useSeriesEvents from '../../../hooks/useSeriesEvents.tsrx';
16
16
  export type BaseLineSeriesProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> =
17
17
  SeriesProps<XScale, YScale, Datum> & {
18
18
  /** Rendered component which is passed path props by BaseLineSeries after processing. */
19
- PathComponent?: FC<Omit<Octane.SVGProps<SVGPathElement>, 'ref'>> | 'path';
19
+ PathComponent?: SvgPathComponent;
20
20
  /** Sets the curve factory (from @octanejs/visx/curve or d3-curve) for the line generator. Defaults to curveLinear. */
21
21
  curve?: LinePathProps<Datum>['curve'];
22
22
  /** Given a datakey, returns its color. Falls back to theme color if unspecified or if a null-ish value is returned. */
23
23
  colorAccessor?: (dataKey: string) => string | undefined | null;
24
- } & Omit<Octane.SVGProps<SVGPathElement>, 'x' | 'y' | 'x0' | 'x1' | 'y0' | 'y1' | 'ref'>;
24
+ } & Omit<
25
+ Octane.SVGProps<SVGPathElement>,
26
+ 'x' | 'y' | 'x0' | 'x1' | 'y0' | 'y1' | 'ref' | 'children'
27
+ >;
25
28
 
26
29
  function BaseLineSeries<XScale extends AxisScale, YScale extends AxisScale, Datum extends object>({
27
30
  colorAccessor,
@@ -1,15 +1,15 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { FC } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { LinePathProps } from '@octanejs/visx/shape';
5
4
  import type { AxisScale } from '@octanejs/visx/axis';
6
5
  import type { SeriesProps } from '../../../types';
6
+ import type { SvgPathComponent } from '../../../types/svgPath';
7
7
  export type BaseLineSeriesProps<XScale extends AxisScale, YScale extends AxisScale, Datum extends object> = SeriesProps<XScale, YScale, Datum> & {
8
8
  /** Rendered component which is passed path props by BaseLineSeries after processing. */
9
- PathComponent?: FC<Omit<Octane.SVGProps<SVGPathElement>, 'ref'>> | 'path';
9
+ PathComponent?: SvgPathComponent;
10
10
  /** Sets the curve factory (from @octanejs/visx/curve or d3-curve) for the line generator. Defaults to curveLinear. */
11
11
  curve?: LinePathProps<Datum>['curve'];
12
12
  /** Given a datakey, returns its color. Falls back to theme color if unspecified or if a null-ish value is returned. */
13
13
  colorAccessor?: (dataKey: string) => string | undefined | null;
14
- } & Omit<Octane.SVGProps<SVGPathElement>, 'x' | 'y' | 'x0' | 'x1' | 'y0' | 'y1' | 'ref'>;
14
+ } & Omit<Octane.SVGProps<SVGPathElement>, 'x' | 'y' | 'x0' | 'x1' | 'y0' | 'y1' | 'ref' | 'children'>;
15
15
  export default function BaseBaseLineSeriesWithRegisteredData<XScale extends AxisScale, YScale extends AxisScale, Datum extends object>(props: BaseLineSeriesProps<XScale, YScale, Datum>): import("react").JSX.Element | null;
@@ -1,4 +1,3 @@
1
- import type { PointerEvent, FocusEvent } from 'react';
2
1
  import { useCallback, useContext, useEffect, useRef } from 'octane';
3
2
  import { localPoint } from '@octanejs/visx/event';
4
3
  import EventEmitterContext from '../context/EventEmitterContext.tsrx';
@@ -8,7 +7,7 @@ export type EventType =
8
7
  'pointermove' | 'pointerout' | 'pointerup' | 'pointerdown' | 'focus' | 'blur';
9
8
 
10
9
  export type HandlerParams = {
11
- /** The react PointerEvent or FocusEvent. */
10
+ /** The native PointerEvent or FocusEvent. */
12
11
  event: PointerEvent | FocusEvent;
13
12
  /** Position of the PointerEvent in svg coordinates. */
14
13
  svgPoint: ReturnType<typeof localPoint>;
@@ -1,9 +1,8 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { PointerEvent, FocusEvent } from 'react';
3
2
  import { localPoint } from '@octanejs/visx/event';
4
3
  export type EventType = 'pointermove' | 'pointerout' | 'pointerup' | 'pointerdown' | 'focus' | 'blur';
5
4
  export type HandlerParams = {
6
- /** The react PointerEvent or FocusEvent. */
5
+ /** The native PointerEvent or FocusEvent. */
7
6
  event: PointerEvent | FocusEvent;
8
7
  /** Position of the PointerEvent in svg coordinates. */
9
8
  svgPoint: ReturnType<typeof localPoint>;
@@ -1,4 +1,3 @@
1
- import type { PointerEvent, FocusEvent } from 'react';
2
1
  import { useCallback } from 'octane';
3
2
  import useEventEmitter from './useEventEmitter.tsrx';
4
3
 
@@ -1,5 +1,4 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { PointerEvent, FocusEvent } from 'react';
3
2
  type PointerEventEmitterParams = {
4
3
  /** Source of the events, e.g., the component name. */
5
4
  source: string;
@@ -1,5 +1,4 @@
1
1
  import type { AxisScale } from '@octanejs/visx/axis';
2
- import type { PointerEvent, FocusEvent } from 'react';
3
2
  import { useCallback, useContext } from 'octane';
4
3
  import DataContext from '../context/DataContext.tsrx';
5
4
  import { isFocusEvent, isPointerEvent } from '../typeguards/events';
@@ -1,6 +1,5 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
2
  import type { AxisScale } from '@octanejs/visx/axis';
3
- import type { PointerEvent, FocusEvent } from 'react';
4
3
  import type { EventHandlerParams, NearestDatumArgs, NearestDatumReturnType } from '../types';
5
4
  export declare const POINTER_EVENTS_ALL = "__POINTER_EVENTS_ALL";
6
5
  export declare const POINTER_EVENTS_NEAREST = "__POINTER_EVENTS_NEAREST";
@@ -1,4 +1,3 @@
1
- import type { FocusEvent, PointerEvent } from 'react';
2
1
  import { useCallback, useContext } from 'octane';
3
2
  import type { AxisScale } from '@octanejs/visx/axis';
4
3
  import TooltipContext from '../context/TooltipContext.tsrx';
@@ -1,5 +1,4 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { FocusEvent, PointerEvent } from 'react';
3
2
  import type { AxisScale } from '@octanejs/visx/axis';
4
3
  import type { SeriesProps } from '../types';
5
4
  import type { PointerEventHandlerParams } from './useEventHandlers.tsrx';
@@ -7,7 +7,7 @@ type UseStackedData<Datum extends object> = {
7
7
  children: OctaneNode;
8
8
  } & Pick<StackPathConfig<Datum, string>, 'offset' | 'order'>;
9
9
  export default function useStackedData<XScale extends AxisScale, YScale extends AxisScale, Datum extends object, ChildrenProps extends SeriesProps<XScale, YScale, Datum>>({ children, order, offset, }: UseStackedData<Datum>): {
10
- seriesChildren: import("react").ReactElement<ChildrenProps, string | import("react").JSXElementConstructor<any>>[];
10
+ seriesChildren: import("octane").ElementDescriptor<ChildrenProps>[];
11
11
  dataKeys: string[];
12
12
  stackedData: import("d3-shape").Series<CombinedStackData<XScale, YScale>, string>[];
13
13
  };
@@ -1,3 +1,4 @@
1
+ /// <reference path="../external.d.ts" />
1
2
  // @octanejs/visx/xychart
2
3
  // components
3
4
  export { default as Annotation } from './components/annotation/Annotation.tsrx';
@@ -1,5 +1,3 @@
1
- import type { FocusEvent, PointerEvent } from 'react';
2
-
3
1
  type EventType = PointerEvent | FocusEvent;
4
2
 
5
3
  // functional definition of a PointerEvent (mouse, touch)
@@ -1,4 +1,3 @@
1
- import type { PointerEvent, FocusEvent } from 'react';
2
1
  import type { Octane } from 'octane/jsx-runtime';
3
2
  import type { AxisScale } from '@octanejs/visx/axis';
4
3
  import type { ScaleInput } from '@octanejs/visx/scale';
@@ -0,0 +1,5 @@
1
+ import type { ComponentBody } from 'octane';
2
+ import type { Octane } from 'octane/jsx-runtime';
3
+
4
+ /** Host `path` or an Octane component that accepts path SVG props. */
5
+ export type SvgPathComponent = 'path' | ComponentBody<Omit<Octane.SVGProps<SVGPathElement>, 'ref'>>;
@@ -1,9 +1,10 @@
1
- import type { CSSProperties, HTMLAttributes, SVGAttributes } from 'react';
1
+ import type { CSSProperties } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
  import type { TextProps } from '@octanejs/visx/text';
3
4
 
4
- export type HTMLTextStyles = HTMLAttributes<HTMLDivElement>['style'];
5
+ export type HTMLTextStyles = CSSProperties;
5
6
 
6
- export type LineStyles = Omit<SVGAttributes<SVGLineElement>, 'Key'>;
7
+ export type LineStyles = Omit<Octane.SVGProps<SVGLineElement>, 'key' | 'ref'>;
7
8
 
8
9
  export type GridStyles = CSSProperties;
9
10
 
@@ -1,4 +1,3 @@
1
- import type { ReactElement } from 'react';
2
1
  import type { AxisScale } from '@octanejs/visx/axis';
3
2
  import type { CombinedStackData, SeriesProps } from '../types';
4
3
 
@@ -17,7 +16,7 @@ export default function combineBarStackData<
17
16
  YScale extends AxisScale,
18
17
  Datum extends object,
19
18
  >(
20
- seriesChildren: ReactElement<SeriesProps<XScale, YScale, Datum>>[],
19
+ seriesChildren: ReadonlyArray<{ props: SeriesProps<XScale, YScale, Datum> }>,
21
20
  horizontal?: boolean,
22
21
  ): CombinedStackData<XScale, YScale>[] {
23
22
  const dataByStackValue = new Map<string, CombinedStackData<XScale, YScale>>();
@@ -1,9 +1,8 @@
1
- import type { ReactElement } from 'react';
2
- import type { OctaneNode } from 'octane';
1
+ import type { ElementDescriptor, OctaneNode } from 'octane';
3
2
  import { Children } from 'octane';
4
3
 
5
4
  /** Returns whether the OctaneNode has props (and therefore is an `Element` versus primitive type) */
6
- function isChildWithProps<P extends object>(child: OctaneNode): child is ReactElement<P> {
5
+ function isChildWithProps<P extends object>(child: OctaneNode): child is ElementDescriptor<P> {
7
6
  return !!child && typeof child === 'object' && 'props' in child && child.props != null;
8
7
  }
9
8
 
@@ -13,7 +12,7 @@ function isChildWithProps<P extends object>(child: OctaneNode): child is ReactEl
13
12
  */
14
13
  export default function getChildrenAndGrandchildrenWithProps<P extends object>(
15
14
  children: OctaneNode,
16
- ): ReactElement<P>[] {
15
+ ): ElementDescriptor<P>[] {
17
16
  return Children.toArray(children)
18
17
  .flatMap((child) => {
19
18
  if (isChildWithProps(child) && (child.props as any).children) {
@@ -21,5 +20,5 @@ export default function getChildrenAndGrandchildrenWithProps<P extends object>(
21
20
  }
22
21
  return child;
23
22
  })
24
- .filter((child) => isChildWithProps<P>(child)) as unknown as ReactElement<P>[];
23
+ .filter((child) => isChildWithProps<P>(child)) as unknown as ElementDescriptor<P>[];
25
24
  }
@@ -1,7 +1,7 @@
1
1
  // OCTANE DIVERGENCE[visx-native-zoom-gestures][differential:visx-native-gestures]:
2
2
  // Zoom attaches native wheel/pointer/touch listeners rather than @use-gesture/react at runtime.
3
3
  import { useState, useRef, useCallback, useEffect } from 'octane';
4
- import type { ReactElement } from 'react';
4
+ import type { OctaneNode } from 'octane';
5
5
  import { localPoint } from '@octanejs/visx/event';
6
6
  import {
7
7
  composeMatrices,
@@ -98,7 +98,7 @@ export type ZoomProps<ElementType> = {
98
98
  constrain?: (transform: TransformMatrix, prevTransform: TransformMatrix) => TransformMatrix;
99
99
  /** Initial transform matrix to apply. */
100
100
  initialTransformMatrix?: TransformMatrix;
101
- children: (zoom: ZoomType<ElementType>) => ReactElement;
101
+ children: (zoom: ZoomType<ElementType>) => OctaneNode;
102
102
  };
103
103
 
104
104
  function Zoom<ElementType extends Element>({
@@ -113,8 +113,8 @@ function Zoom<ElementType extends Element>({
113
113
  height,
114
114
  constrain,
115
115
  children,
116
- }: ZoomProps<ElementType>): ReactElement {
117
- const containerRef = useRef<ElementType>(null);
116
+ }: ZoomProps<ElementType>): OctaneNode {
117
+ const containerRef = useRef<ElementType | null>(null);
118
118
  const matrixStateRef = useRef<TransformMatrix>(initialTransformMatrix);
119
119
  const pointerActiveRef = useRef(false);
120
120
  const lastPinchDistanceRef = useRef(0);
@@ -250,7 +250,8 @@ function Zoom<ElementType extends Element>({
250
250
 
251
251
  const handlePinch: ZoomType<ElementType>['handlePinch'] = useCallback((state) => {
252
252
  const { origin: [ox, oy], memo } = state;
253
- let currentMemo = memo;
253
+ type PinchMemo = { top: number; left: number };
254
+ let currentMemo = memo as PinchMemo | undefined;
254
255
  if (containerRef.current) {
255
256
  const { top, left } = currentMemo ?? containerRef.current.getBoundingClientRect();
256
257
  if (!currentMemo) {
@@ -326,21 +327,22 @@ function Zoom<ElementType extends Element>({
326
327
  lastPinchDistanceRef.current = distance;
327
328
  };
328
329
 
329
- target.addEventListener('pointerdown', onPointerDown);
330
- target.addEventListener('wheel', onWheel, { passive: false });
331
- target.addEventListener('touchstart', onTouchStart, { passive: false });
332
- target.addEventListener('touchmove', onTouchMove, { passive: false });
333
- window.addEventListener('pointermove', onPointerMove);
334
- window.addEventListener('pointerup', onPointerUp);
335
- window.addEventListener('pointercancel', onPointerUp);
336
- return () => {
337
- target.removeEventListener('pointerdown', onPointerDown);
338
- target.removeEventListener('wheel', onWheel);
339
- target.removeEventListener('touchstart', onTouchStart);
340
- target.removeEventListener('touchmove', onTouchMove);
341
- window.removeEventListener('pointermove', onPointerMove);
342
- window.removeEventListener('pointerup', onPointerUp);
343
- window.removeEventListener('pointercancel', onPointerUp);
330
+ const element: Element = target;
331
+ element.addEventListener('pointerdown', onPointerDown as EventListener);
332
+ element.addEventListener('wheel', onWheel as EventListener, { passive: false });
333
+ element.addEventListener('touchstart', onTouchStart as EventListener, { passive: false });
334
+ element.addEventListener('touchmove', onTouchMove as EventListener, { passive: false });
335
+ window.addEventListener('pointermove', onPointerMove as EventListener);
336
+ window.addEventListener('pointerup', onPointerUp as EventListener);
337
+ window.addEventListener('pointercancel', onPointerUp as EventListener);
338
+ return function removeZoomListeners() {
339
+ element.removeEventListener('pointerdown', onPointerDown as EventListener);
340
+ element.removeEventListener('wheel', onWheel as EventListener);
341
+ element.removeEventListener('touchstart', onTouchStart as EventListener);
342
+ element.removeEventListener('touchmove', onTouchMove as EventListener);
343
+ window.removeEventListener('pointermove', onPointerMove as EventListener);
344
+ window.removeEventListener('pointerup', onPointerUp as EventListener);
345
+ window.removeEventListener('pointercancel', onPointerUp as EventListener);
344
346
  };
345
347
  }, [dragEnd, dragMove, dragStart, handlePinch, handleWheel]);
346
348
 
@@ -1,5 +1,5 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { ReactElement } from 'react';
2
+ import type { OctaneNode } from 'octane';
3
3
  import type { TransformMatrix, Scale, PinchDelta, GenericWheelEvent, Zoom as ZoomType } from './types';
4
4
  export type ZoomProps<ElementType> = {
5
5
  /** Width of the zoom container. */
@@ -56,7 +56,7 @@ export type ZoomProps<ElementType> = {
56
56
  constrain?: (transform: TransformMatrix, prevTransform: TransformMatrix) => TransformMatrix;
57
57
  /** Initial transform matrix to apply. */
58
58
  initialTransformMatrix?: TransformMatrix;
59
- children: (zoom: ZoomType<ElementType>) => ReactElement;
59
+ children: (zoom: ZoomType<ElementType>) => OctaneNode;
60
60
  };
61
- declare function Zoom<ElementType extends Element>({ scaleXMin, scaleXMax, scaleYMin, scaleYMax, initialTransformMatrix, wheelDelta, pinchDelta, width, height, constrain, children, }: ZoomProps<ElementType>): ReactElement;
61
+ declare function Zoom<ElementType extends Element>({ scaleXMin, scaleXMax, scaleYMin, scaleYMax, initialTransformMatrix, wheelDelta, pinchDelta, width, height, constrain, children, }: ZoomProps<ElementType>): OctaneNode;
62
62
  export default Zoom;