@octanejs/visx 0.1.36 → 0.1.38

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 (98) 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/legend/legends/Legend/LegendItem.tsrx +2 -2
  15. package/src/legend/legends/Legend/LegendItem.tsrx.d.ts +2 -2
  16. package/src/legend/legends/Legend/LegendLabel.tsrx +2 -2
  17. package/src/legend/legends/Legend/LegendLabel.tsrx.d.ts +2 -2
  18. package/src/legend/legends/Legend/index.tsrx +30 -31
  19. package/src/legend/types/index.ts +3 -6
  20. package/src/responsive/types/index.ts +3 -21
  21. package/src/sankey/Sankey.tsrx +9 -5
  22. package/src/sankey/Sankey.tsrx.d.ts +3 -3
  23. package/src/shape/shapes/Bar.tsrx +2 -1
  24. package/src/shape/shapes/Bar.tsrx.d.ts +2 -1
  25. package/src/shape/shapes/BarRounded.tsrx +2 -1
  26. package/src/shape/shapes/BarRounded.tsrx.d.ts +2 -1
  27. package/src/shape/shapes/Line.tsrx +2 -1
  28. package/src/shape/shapes/Line.tsrx.d.ts +2 -1
  29. package/src/shape/shapes/LinePath.tsrx +2 -1
  30. package/src/shape/shapes/LinePath.tsrx.d.ts +2 -1
  31. package/src/shape/types/area.ts +2 -1
  32. package/src/text/types.ts +4 -3
  33. package/src/tooltip/enhancers/withTooltip.tsrx +14 -9
  34. package/src/tooltip/enhancers/withTooltip.tsrx.d.ts +5 -4
  35. package/src/tooltip/floating/ChartTooltip.tsrx +3 -2
  36. package/src/tooltip/floating/ChartTooltip.tsrx.d.ts +1 -2
  37. package/src/tooltip/floating/ChartTooltipContent.tsrx +7 -6
  38. package/src/tooltip/floating/ChartTooltipContent.tsrx.d.ts +6 -6
  39. package/src/tooltip/floating/FloatingTooltip.tsrx +24 -18
  40. package/src/tooltip/floating/FloatingTooltip.tsrx.d.ts +7 -7
  41. package/src/tooltip/floating/context.tsrx +0 -1
  42. package/src/tooltip/floating/context.tsrx.d.ts +1 -2
  43. package/src/tooltip/floating/internalTypes.ts +13 -109
  44. package/src/tooltip/floating/types.ts +29 -26
  45. package/src/tooltip/floating/useChartTooltip.tsrx +1 -2
  46. package/src/tooltip/floating/useChartTooltip.tsrx.d.ts +1 -2
  47. package/src/tooltip/floating/useFloatingTooltip.tsrx +11 -6
  48. package/src/tooltip/hooks/useTooltipInPortal.tsrx +2 -2
  49. package/src/tooltip/hooks/useTooltipInPortal.tsrx.d.ts +2 -2
  50. package/src/tooltip/tooltips/Tooltip.tsrx +5 -2
  51. package/src/tooltip/tooltips/Tooltip.tsrx.d.ts +3 -2
  52. package/src/tooltip/tooltips/TooltipWithBounds.tsrx +9 -3
  53. package/src/tooltip/tooltips/TooltipWithBounds.tsrx.d.ts +6 -4
  54. package/src/xychart/components/Tooltip.tsrx +0 -2
  55. package/src/xychart/components/XYChart.tsrx +0 -1
  56. package/src/xychart/components/XYChart.tsrx.d.ts +0 -1
  57. package/src/xychart/components/annotation/private/BaseAnnotation.tsrx +2 -2
  58. package/src/xychart/components/annotation/private/BaseAnnotation.tsrx.d.ts +2 -2
  59. package/src/xychart/components/axis/BaseAxis.tsrx +2 -2
  60. package/src/xychart/components/axis/BaseAxis.tsrx.d.ts +2 -2
  61. package/src/xychart/components/grid/BaseGrid.tsrx +3 -3
  62. package/src/xychart/components/grid/BaseGrid.tsrx.d.ts +3 -3
  63. package/src/xychart/components/series/AnimatedGlyphSeries.tsrx +2 -2
  64. package/src/xychart/components/series/AnimatedGlyphSeries.tsrx.d.ts +2 -2
  65. package/src/xychart/components/series/GlyphSeries.tsrx +1 -2
  66. package/src/xychart/components/series/GlyphSeries.tsrx.d.ts +2 -2
  67. package/src/xychart/components/series/private/AnimatedGlyphs.tsrx +1 -2
  68. package/src/xychart/components/series/private/AnimatedGlyphs.tsrx.d.ts +2 -2
  69. package/src/xychart/components/series/private/BaseAreaSeries.tsrx +6 -3
  70. package/src/xychart/components/series/private/BaseAreaSeries.tsrx.d.ts +3 -3
  71. package/src/xychart/components/series/private/BaseAreaStack.tsrx +36 -28
  72. package/src/xychart/components/series/private/BaseAreaStack.tsrx.d.ts +4 -4
  73. package/src/xychart/components/series/private/BaseBarGroup.tsrx +3 -5
  74. package/src/xychart/components/series/private/BaseBarGroup.tsrx.d.ts +2 -3
  75. package/src/xychart/components/series/private/BaseBarSeries.tsrx +2 -2
  76. package/src/xychart/components/series/private/BaseBarSeries.tsrx.d.ts +2 -2
  77. package/src/xychart/components/series/private/BaseBarStack.tsrx +11 -7
  78. package/src/xychart/components/series/private/BaseBarStack.tsrx.d.ts +3 -3
  79. package/src/xychart/components/series/private/BaseLineSeries.tsrx +6 -3
  80. package/src/xychart/components/series/private/BaseLineSeries.tsrx.d.ts +3 -3
  81. package/src/xychart/hooks/useEventEmitter.tsrx +1 -2
  82. package/src/xychart/hooks/useEventEmitter.tsrx.d.ts +1 -2
  83. package/src/xychart/hooks/useEventEmitters.tsrx +0 -1
  84. package/src/xychart/hooks/useEventEmitters.tsrx.d.ts +0 -1
  85. package/src/xychart/hooks/useEventHandlers.tsrx +0 -1
  86. package/src/xychart/hooks/useEventHandlers.tsrx.d.ts +0 -1
  87. package/src/xychart/hooks/useSeriesEvents.tsrx +0 -1
  88. package/src/xychart/hooks/useSeriesEvents.tsrx.d.ts +0 -1
  89. package/src/xychart/hooks/useStackedData.tsrx.d.ts +1 -1
  90. package/src/xychart/typeguards/events.ts +0 -2
  91. package/src/xychart/types/series.ts +0 -1
  92. package/src/xychart/types/svgPath.ts +5 -0
  93. package/src/xychart/types/theme.ts +4 -3
  94. package/src/xychart/utils/combineBarStackData.ts +1 -2
  95. package/src/xychart/utils/getChildrenAndGrandchildrenWithProps.ts +4 -5
  96. package/src/zoom/Zoom.tsrx +22 -20
  97. package/src/zoom/Zoom.tsrx.d.ts +3 -3
  98. package/src/zoom/types.ts +14 -27
@@ -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,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;
package/src/zoom/types.ts CHANGED
@@ -1,16 +1,8 @@
1
- import type { Handler, UserHandlers, WebKitGestureEvent } from '@use-gesture/core/types';
2
- import type {
3
- MouseEvent as ReactMouseEvent,
4
- PointerEvent as ReactPointerEvent,
5
- RefObject,
6
- TouchEvent as ReactTouchEvent,
7
- WheelEvent as ReactWheelEvent,
8
- } from 'react';
1
+ import type { RefObject } from 'react';
9
2
 
10
- export type GenericWheelEvent = ReactWheelEvent | WheelEvent;
3
+ export type GenericWheelEvent = WheelEvent;
11
4
 
12
- export type InteractionEvent =
13
- ReactMouseEvent | ReactTouchEvent | ReactPointerEvent | MouseEvent | TouchEvent | PointerEvent;
5
+ export type InteractionEvent = MouseEvent | TouchEvent | PointerEvent;
14
6
 
15
7
  export interface TransformMatrix {
16
8
  scaleX: number;
@@ -30,20 +22,15 @@ export type Translate = Pick<TransformMatrix, 'translateX' | 'translateY'>;
30
22
 
31
23
  export type Scale = Pick<TransformMatrix, 'scaleX' | 'scaleY'>;
32
24
 
33
- export type PinchDelta = (
34
- params: Parameters<
35
- Handler<
36
- 'pinch',
37
- | TouchEvent
38
- | ReactTouchEvent
39
- | PointerEvent
40
- | ReactPointerEvent
41
- | WheelEvent
42
- | ReactWheelEvent
43
- | WebKitGestureEvent
44
- >
45
- >[0],
46
- ) => Scale;
25
+ type PinchDeltaState = {
26
+ event: TouchEvent | PointerEvent | WheelEvent;
27
+ origin: [number, number];
28
+ offset: [number, number];
29
+ lastOffset: [number, number];
30
+ memo: unknown;
31
+ };
32
+
33
+ export type PinchDelta = (params: PinchDeltaState) => Scale;
47
34
 
48
35
  export interface ScaleSignature {
49
36
  scaleX: TransformMatrix['scaleX'];
@@ -72,9 +59,9 @@ export interface ProvidedZoom<ElementType> {
72
59
  /** Resets the transform to the initial transform specified by props. */
73
60
  reset: () => void;
74
61
  /** Callback for a wheel event, updating scale based on props.wheelDelta, relative to the mouse position. */
75
- handleWheel: (event: ReactWheelEvent | WheelEvent) => void;
62
+ handleWheel: (event: GenericWheelEvent) => void;
76
63
  /** Callback for a pinch event, updating scale based on props.pinchDelta relative to the pinch position. */
77
- handlePinch: UserHandlers['onPinch'];
64
+ handlePinch: (state: PinchDeltaState) => unknown;
78
65
  /** Callback for dragEnd, sets isDragging to false. */
79
66
  dragEnd: () => void;
80
67
  /** Callback for dragMove, results in a scale transform. */