@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/visx",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -123,10 +123,10 @@
123
123
  "mitt": "^2.1.0",
124
124
  "reduce-css-calc": "^1.3.0",
125
125
  "svg-path-properties": "2.0.2",
126
- "@octanejs/floating-ui": "0.1.42"
126
+ "@octanejs/floating-ui": "0.1.44"
127
127
  },
128
128
  "peerDependencies": {
129
- "octane": "0.1.43"
129
+ "octane": "0.1.45"
130
130
  },
131
131
  "devDependencies": {
132
132
  "@juggle/resize-observer": "^3.4.0",
@@ -149,7 +149,7 @@
149
149
  "react-dom": "^19.2.7",
150
150
  "typescript": "^5.9.3",
151
151
  "vitest": "^4.1.10",
152
- "octane": "0.1.43"
152
+ "octane": "0.1.45"
153
153
  },
154
154
  "scripts": {
155
155
  "compile:check": "node scripts/check-tsrx-compile.mjs",
@@ -1,9 +1,12 @@
1
1
  /* eslint-disable react/jsx-handler-names */
2
2
  import { useCallback, useRef } from 'octane';
3
- import type { MouseEvent, TouchEvent } from 'react';
4
3
  import type { Octane } from 'octane/jsx-runtime';
5
4
  import type { OctaneNode } from 'octane';
6
- import type { UseDrag, HandlerArgs as DragHandlerArgs } from '@octanejs/visx/drag';
5
+ import type {
6
+ UseDrag,
7
+ HandlerArgs as DragHandlerArgs,
8
+ MouseTouchOrPointerEvent,
9
+ } from '@octanejs/visx/drag';
7
10
  import { useDrag } from '@octanejs/visx/drag';
8
11
  import type { AnnotationContextType } from '../types';
9
12
  import Annotation from './Annotation.tsrx';
@@ -36,7 +39,7 @@ export type HandlerArgs = {
36
39
  y: number;
37
40
  dx: number;
38
41
  dy: number;
39
- event: MouseEvent | TouchEvent;
42
+ event: MouseTouchOrPointerEvent;
40
43
  };
41
44
 
42
45
  const defaultDragHandleProps = {
@@ -1,7 +1,7 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { MouseEvent, TouchEvent } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { OctaneNode } from 'octane';
4
+ import type { MouseTouchOrPointerEvent } from '@octanejs/visx/drag';
5
5
  import type { AnnotationContextType } from '../types';
6
6
  export type EditableAnnotationProps = Pick<AnnotationContextType, 'x' | 'y' | 'dx' | 'dy'> & {
7
7
  /** Width of the possible drag canvas (e.g., SVG container). */
@@ -30,6 +30,6 @@ export type HandlerArgs = {
30
30
  y: number;
31
31
  dx: number;
32
32
  dy: number;
33
- event: MouseEvent | TouchEvent;
33
+ event: MouseTouchOrPointerEvent;
34
34
  };
35
35
  export default function EditableAnnotation({ canEditLabel, canEditSubject, children, dx: labelDx, dy: labelDy, height, labelDragHandleProps, onDragEnd, onDragMove, onDragStart, subjectDragHandleProps, width, x: subjectX, y: subjectY, }: EditableAnnotationProps): import("react").JSX.Element;
@@ -62,6 +62,15 @@ export type LabelProps = {
62
62
 
63
63
  const DEFAULT_PADDING = { top: 12, right: 12, bottom: 12, left: 12 };
64
64
 
65
+ function toFontSizeNumber(value: string | number | undefined): number {
66
+ if (typeof value === 'number' && Number.isFinite(value)) return value;
67
+ if (typeof value === 'string') {
68
+ const parsed = Number.parseFloat(value);
69
+ if (Number.isFinite(parsed)) return parsed;
70
+ }
71
+ return 0;
72
+ }
73
+
65
74
  function getCompletePadding(padding: LabelProps['backgroundPadding']) {
66
75
  if (typeof padding === 'undefined') return DEFAULT_PADDING;
67
76
  if (typeof padding === 'number') {
@@ -122,10 +131,10 @@ export default function Label({
122
131
  });
123
132
 
124
133
  const fallbackTitleHeight = title
125
- ? Math.max(1, titleWordsByLine.length) * titleFontSize * 1.1
134
+ ? Math.max(1, titleWordsByLine.length) * toFontSizeNumber(titleFontSize) * 1.1
126
135
  : 0;
127
136
  const fallbackSubtitleHeight = subtitle
128
- ? Math.max(1, subtitleWordsByLine.length) * subtitleFontSize * 1.1
137
+ ? Math.max(1, subtitleWordsByLine.length) * toFontSizeNumber(subtitleFontSize) * 1.1
129
138
  : 0;
130
139
  // Keep annotation geometry byte-stable across SSR and hydration. Browser font
131
140
  // measurement would move the label after adoption; useText's deterministic
@@ -1,13 +1,15 @@
1
1
  import cx from 'classnames';
2
2
  import { createElement } from 'octane';
3
3
  import { Group } from '@octanejs/visx/group';
4
- import type { SharedAxisProps, AxisScale } from '../types';
4
+ import type { SharedAxisProps, AxisScale, AxisRendererProps } from '../types';
5
5
  import AxisRenderer from './AxisRenderer.tsrx';
6
6
  import type { OrientationType } from '../constants/orientation';
7
7
  import Orientation from '../constants/orientation';
8
8
  import useAxis from '../react/useAxis.tsrx';
9
9
 
10
- const renderAxis = (axis: Parameters<typeof AxisRenderer>[0]) => createElement(AxisRenderer, axis);
10
+ function renderAxis<Scale extends AxisScale>(axis: AxisRendererProps<Scale>) {
11
+ return createElement(AxisRenderer, axis as Parameters<typeof AxisRenderer>[0]);
12
+ }
11
13
 
12
14
  export type AxisProps<Scale extends AxisScale> = SharedAxisProps<Scale> & {
13
15
  orientation?: OrientationType;
@@ -1,5 +1,4 @@
1
1
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'octane';
2
- import type { PointerEvent } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { OctaneNode } from 'octane';
5
4
  import { Group } from '@octanejs/visx/group';
@@ -22,7 +21,7 @@ import type {
22
21
  } from './types';
23
22
  import { debounce, getPageCoordinates, normalizeBrushStartEnd } from './utils';
24
23
 
25
- type PointerHandlerEvent = PointerEvent<SVGRectElement>;
24
+ type PointerHandlerEvent = PointerEvent | MouseEvent;
26
25
 
27
26
  const DEFAULT_MARGIN = { left: 0, top: 0, right: 0, bottom: 0 };
28
27
  const DEFAULT_RESIZE_TRIGGER_AREAS: ResizeTriggerAreas[] = ['left', 'right'];
@@ -45,7 +44,7 @@ export type BaseBrushProps = {
45
44
  onMouseUp?: (event: PointerHandlerEvent) => void;
46
45
  onMouseMove?: (event: PointerHandlerEvent) => void;
47
46
  onClick?: (event: PointerHandlerEvent) => void;
48
- clickSensitivity: number;
47
+ clickSensitivity?: number;
49
48
  disableDraggingSelection: boolean;
50
49
  disableDraggingOverlay?: boolean;
51
50
  resetOnEnd?: boolean;
@@ -162,7 +161,7 @@ export function BaseBrush(inputProps: BaseBrushProps) {
162
161
  const start = { ...previous.start };
163
162
  const end = { ...previous.end };
164
163
  normalizeBrushStartEnd(start, end, previous.extent);
165
- let next = {
164
+ let next: BaseBrushState = {
166
165
  ...previous,
167
166
  start,
168
167
  end,
@@ -330,7 +329,7 @@ export function BaseBrush(inputProps: BaseBrushProps) {
330
329
  const { onBrushEnd, resetOnEnd, useWindowMoveEvents } = propsRef.current;
331
330
  if (useWindowMoveEvents) return;
332
331
  updateBrush((previous) => {
333
- let next = {
332
+ let next: BaseBrushState = {
334
333
  ...previous,
335
334
  start: { x: previous.extent.x0, y: previous.extent.y0 },
336
335
  end: { x: previous.extent.x1, y: previous.extent.y1 },
@@ -449,7 +448,7 @@ export function BaseBrush(inputProps: BaseBrushProps) {
449
448
  height={stageHeight}
450
449
  onClick={(event) => {
451
450
  const duration = mouseUpTimeRef.current - mouseDownTimeRef.current;
452
- if (onClick && duration < clickSensitivity) onClick(event);
451
+ if (onClick && duration < (clickSensitivity ?? 200)) onClick(event);
453
452
  }}
454
453
  style={{ cursor: 'default' }}
455
454
  />
@@ -470,7 +469,7 @@ export function BaseBrush(inputProps: BaseBrushProps) {
470
469
  onDoubleClick={reset}
471
470
  onClick={(event: PointerHandlerEvent) => {
472
471
  const duration = mouseUpTimeRef.current - mouseDownTimeRef.current;
473
- if (onClick && duration < clickSensitivity) onClick(event);
472
+ if (onClick && duration < (clickSensitivity ?? 200)) onClick(event);
474
473
  }}
475
474
  onPointerDown={(event: PointerHandlerEvent) => {
476
475
  mouseDownTimeRef.current = Date.now();
@@ -1,10 +1,9 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { PointerEvent } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { OctaneNode } from 'octane';
5
4
  import type { BrushHandleRenderProps } from './BrushHandle.tsrx';
6
5
  import type { MarginShape, BrushShape, ResizeTriggerAreas, PartialBrushStartEnd, BrushingType, BrushPageOffset } from './types';
7
- type PointerHandlerEvent = PointerEvent<SVGRectElement>;
6
+ type PointerHandlerEvent = PointerEvent | MouseEvent;
8
7
  export type BaseBrushProps = {
9
8
  brushDirection?: 'horizontal' | 'vertical' | 'both';
10
9
  initialBrushPosition?: PartialBrushStartEnd;
@@ -23,7 +22,7 @@ export type BaseBrushProps = {
23
22
  onMouseUp?: (event: PointerHandlerEvent) => void;
24
23
  onMouseMove?: (event: PointerHandlerEvent) => void;
25
24
  onClick?: (event: PointerHandlerEvent) => void;
26
- clickSensitivity: number;
25
+ clickSensitivity?: number;
27
26
  disableDraggingSelection: boolean;
28
27
  disableDraggingOverlay?: boolean;
29
28
  resetOnEnd?: boolean;
@@ -1,17 +1,20 @@
1
- import type { CSSProperties, PointerEvent } from 'react';
1
+ import type { CSSProperties } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
  import { Bar } from '@octanejs/visx/shape';
3
4
 
4
5
  type BrushOverlayProps = {
5
6
  width: number;
6
7
  height: number;
7
8
  style?: CSSProperties;
8
- onClick?: (event: PointerEvent<SVGRectElement>) => void;
9
- onDoubleClick?: (event: PointerEvent<SVGRectElement>) => void;
10
- onPointerDown?: (event: PointerEvent<SVGRectElement>) => void;
11
- onPointerLeave?: (event: PointerEvent<SVGRectElement>) => void;
12
- onPointerMove?: (event: PointerEvent<SVGRectElement>) => void;
13
- onPointerUp?: (event: PointerEvent<SVGRectElement>) => void;
14
- };
9
+ } & Pick<
10
+ Octane.SVGProps<SVGRectElement>,
11
+ | 'onClick'
12
+ | 'onDoubleClick'
13
+ | 'onPointerDown'
14
+ | 'onPointerLeave'
15
+ | 'onPointerMove'
16
+ | 'onPointerUp'
17
+ >;
15
18
 
16
19
  export default function BrushOverlay(props: BrushOverlayProps) {
17
20
  return <Bar className="visx-brush-overlay" fill="transparent" x={0} y={0} {...props} />;
@@ -1,15 +1,10 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { CSSProperties, PointerEvent } from 'react';
2
+ import type { CSSProperties } from 'react';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
  type BrushOverlayProps = {
4
5
  width: number;
5
6
  height: number;
6
7
  style?: CSSProperties;
7
- onClick?: (event: PointerEvent<SVGRectElement>) => void;
8
- onDoubleClick?: (event: PointerEvent<SVGRectElement>) => void;
9
- onPointerDown?: (event: PointerEvent<SVGRectElement>) => void;
10
- onPointerLeave?: (event: PointerEvent<SVGRectElement>) => void;
11
- onPointerMove?: (event: PointerEvent<SVGRectElement>) => void;
12
- onPointerUp?: (event: PointerEvent<SVGRectElement>) => void;
13
- };
8
+ } & Pick<Octane.SVGProps<SVGRectElement>, 'onClick' | 'onDoubleClick' | 'onPointerDown' | 'onPointerLeave' | 'onPointerMove' | 'onPointerUp'>;
14
9
  export default function BrushOverlay(props: BrushOverlayProps): import("react").JSX.Element;
15
10
  export {};
@@ -1,5 +1,4 @@
1
1
  /* eslint react/jsx-handler-names: 0 */
2
- import type { PointerEvent } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { HandlerArgs as DragArgs } from '@octanejs/visx/drag';
5
4
  import { Drag } from '@octanejs/visx/drag';
@@ -10,7 +9,7 @@ import { getPageCoordinates } from './utils';
10
9
 
11
10
  const DRAGGING_OVERLAY_STYLES = { cursor: 'move' };
12
11
 
13
- type PointerHandler = (event: PointerEvent<SVGRectElement>) => void;
12
+ type PointerHandler = (event: PointerEvent) => void;
14
13
 
15
14
  export type BrushSelectionProps = {
16
15
  width: number;
@@ -167,7 +166,7 @@ export default function BrushSelection(props: BrushSelectionProps) {
167
166
  if (onMouseUp) onMouseUp(event);
168
167
  }}
169
168
  onClick={(event) => {
170
- if (onClick) onClick(event as PointerEvent<SVGRectElement>);
169
+ if (onClick) onClick(event as unknown as PointerEvent);
171
170
  }}
172
171
  style={{
173
172
  pointerEvents: brush.isBrushing || brush.activeHandle ? 'none' : 'all',
@@ -1,10 +1,9 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { PointerEvent } from 'react';
3
2
  import type { Octane } from 'octane/jsx-runtime';
4
3
  import type { HandlerArgs as DragArgs } from '@octanejs/visx/drag';
5
4
  import type { BaseBrushState as BrushState, UpdateBrush } from './BaseBrush.tsrx';
6
5
  import type { BrushPageOffset, BrushingType } from './types';
7
- type PointerHandler = (event: PointerEvent<SVGRectElement>) => void;
6
+ type PointerHandler = (event: PointerEvent) => void;
8
7
  export type BrushSelectionProps = {
9
8
  width: number;
10
9
  height: number;
@@ -19,7 +19,7 @@ export type ResizeObserverConstructor =
19
19
  export type Options = {
20
20
  debounce?: number | { scroll?: number; resize?: number };
21
21
  scroll?: boolean;
22
- polyfill?: ResizeObserverConstructor;
22
+ polyfill?: ResizeObserverConstructor | (new (callback: ResizeObserverCallback) => ResizeObserver);
23
23
  offsetSize?: boolean;
24
24
  };
25
25
 
@@ -16,7 +16,7 @@ export type Options = {
16
16
  resize?: number;
17
17
  };
18
18
  scroll?: boolean;
19
- polyfill?: ResizeObserverConstructor;
19
+ polyfill?: ResizeObserverConstructor | (new (callback: ResizeObserverCallback) => ResizeObserver);
20
20
  offsetSize?: boolean;
21
21
  };
22
22
  export default function useMeasure(options?: Options): readonly [(element: HTMLElement | SVGElement | null) => void, RectReadOnly, () => void];
@@ -1,3 +1,7 @@
1
+ // Keep the literal expression below available to bundler define substitution
2
+ // without requiring Node ambient types in browser consumers.
3
+ declare const process: { env: { NODE_ENV?: string } };
4
+
1
5
  export type WarnCode = 'EMPTY_DATA' | 'NAN_IN_DATA';
2
6
  export type WarnDetails = Readonly<Record<string, unknown>>;
3
7
 
@@ -1,5 +1,5 @@
1
- import type { HTMLProps } from 'react';
2
1
  import type { OctaneNode } from 'octane';
2
+ import type { Octane } from 'octane/jsx-runtime';
3
3
  import type { FlexDirection } from '../../types';
4
4
 
5
5
  export type LegendItemProps = {
@@ -22,7 +22,7 @@ export default function LegendItem({
22
22
  display = 'flex',
23
23
  children,
24
24
  ...restProps
25
- }: LegendItemProps & Omit<HTMLProps<HTMLDivElement>, keyof LegendItemProps>) {
25
+ }: LegendItemProps & Omit<Octane.HTMLAttributes<HTMLDivElement>, keyof LegendItemProps>) {
26
26
  return <div
27
27
  className="visx-legend-item"
28
28
  style={{
@@ -1,6 +1,6 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { HTMLProps } from 'react';
3
2
  import type { OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
4
4
  import type { FlexDirection } from '../../types';
5
5
  export type LegendItemProps = {
6
6
  /** Flex direction for the legend item layout. Determines if the shape and label are arranged horizontally or vertically. */
@@ -14,4 +14,4 @@ export type LegendItemProps = {
14
14
  /** CSS display property for the legend item. */
15
15
  display?: string;
16
16
  };
17
- export default function LegendItem({ flexDirection, alignItems, margin, display, children, ...restProps }: LegendItemProps & Omit<HTMLProps<HTMLDivElement>, keyof LegendItemProps>): import("react").JSX.Element;
17
+ export default function LegendItem({ flexDirection, alignItems, margin, display, children, ...restProps }: LegendItemProps & Omit<Octane.HTMLAttributes<HTMLDivElement>, keyof LegendItemProps>): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
- import type { HTMLProps } from 'react';
2
1
  import type { OctaneNode } from 'octane';
2
+ import type { Octane } from 'octane/jsx-runtime';
3
3
 
4
4
  export type LegendLabelOwnProps = {
5
5
  /** Horizontal alignment of the label text. Maps to CSS justify-content property. */
@@ -15,7 +15,7 @@ export type LegendLabelOwnProps = {
15
15
  };
16
16
 
17
17
  export type LegendLabelProps =
18
- LegendLabelOwnProps & Omit<HTMLProps<HTMLDivElement>, keyof LegendLabelOwnProps>;
18
+ LegendLabelOwnProps & Omit<Octane.HTMLAttributes<HTMLDivElement>, keyof LegendLabelOwnProps>;
19
19
 
20
20
  export default function LegendLabel({
21
21
  flex = '1',
@@ -1,6 +1,6 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { HTMLProps } from 'react';
3
2
  import type { OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
4
4
  export type LegendLabelOwnProps = {
5
5
  /** Horizontal alignment of the label text. Maps to CSS justify-content property. */
6
6
  align?: string;
@@ -13,5 +13,5 @@ export type LegendLabelOwnProps = {
13
13
  /** Child elements to render. If provided, overrides the label prop. */
14
14
  children?: OctaneNode;
15
15
  };
16
- export type LegendLabelProps = LegendLabelOwnProps & Omit<HTMLProps<HTMLDivElement>, keyof LegendLabelOwnProps>;
16
+ export type LegendLabelProps = LegendLabelOwnProps & Omit<Octane.HTMLAttributes<HTMLDivElement>, keyof LegendLabelOwnProps>;
17
17
  export default function LegendLabel({ flex, label, margin, align, children, ...restProps }: LegendLabelProps): import("react").JSX.Element;
@@ -1,6 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import type { OctaneNode } from 'octane';
3
- import { createElement } from 'octane';
4
3
  import cx from 'classnames';
5
4
  import type { AnyD3Scale, ScaleInput } from '@octanejs/visx/scale';
6
5
  import LegendItem from './LegendItem.tsrx';
@@ -100,36 +99,36 @@ export default function Legend<Scale extends AnyD3Scale>({
100
99
  if (children) return <>
101
100
  {children(labels)}
102
101
  </>;
103
- const legendItems = labels.map(
104
- (label, i) => createElement(
105
- LegendItem,
106
- {
107
- key: `legend-${label.text}-${i}`,
108
- margin: itemMargin,
109
- flexDirection: itemDirection,
110
- ...legendItemProps,
111
- },
112
- createElement(LegendShape, {
113
- shape,
114
- height: shapeHeight,
115
- width: shapeWidth,
116
- margin: shapeMargin,
117
- item: domain[i],
118
- itemIndex: i,
119
- label,
120
- fill,
121
- size,
122
- shapeStyle,
123
- }),
124
- createElement(LegendLabel, {
125
- label: label.text,
126
- flex: labelFlex,
127
- margin: labelMargin,
128
- align: labelAlign,
129
- ...legendLabelProps,
130
- }),
131
- ),
132
- );
102
+ const legendItems = labels.map(function (label, i) {
103
+ return (
104
+ <LegendItem
105
+ key={`legend-${label.text}-${i}`}
106
+ margin={itemMargin}
107
+ flexDirection={itemDirection}
108
+ {...legendItemProps}
109
+ >
110
+ <LegendShape
111
+ shape={shape}
112
+ height={shapeHeight}
113
+ width={shapeWidth}
114
+ margin={shapeMargin}
115
+ item={domain[i]}
116
+ itemIndex={i}
117
+ label={label}
118
+ fill={fill}
119
+ size={size}
120
+ shapeStyle={shapeStyle}
121
+ />
122
+ <LegendLabel
123
+ label={label.text}
124
+ flex={labelFlex}
125
+ margin={labelMargin}
126
+ align={labelAlign}
127
+ {...legendLabelProps}
128
+ />
129
+ </LegendItem>
130
+ );
131
+ });
133
132
 
134
133
  return <div
135
134
  className={cx('visx-legend', className)}
@@ -1,5 +1,6 @@
1
1
  import type { AnyD3Scale, ScaleInput } from '@octanejs/visx/scale';
2
- import type { ComponentClass, CSSProperties, FC } from 'react';
2
+ import type { ComponentBody } from 'octane';
3
+ import type { CSSProperties } from 'react';
3
4
 
4
5
  export type LabelFormatterFactory<Scale extends AnyD3Scale> = (args: {
5
6
  scale: Scale;
@@ -35,11 +36,7 @@ export type RenderShapeProvidedProps<Data, Output> = {
35
36
  };
36
37
 
37
38
  export type LegendShape<Data, Output> =
38
- | 'rect'
39
- | 'circle'
40
- | 'line'
41
- | FC<RenderShapeProvidedProps<Data, Output>>
42
- | ComponentClass<RenderShapeProvidedProps<Data, Output>>;
39
+ 'rect' | 'circle' | 'line' | ComponentBody<RenderShapeProvidedProps<Data, Output>>;
43
40
 
44
41
  export type FillAccessor<Datum, Output> = (
45
42
  label: FormattedLabel<Datum, Output>,
@@ -1,26 +1,8 @@
1
- // @TODO remove all these types when upgraded to TS 4 which has its own declaration
2
- interface ResizeObserverEntry {
3
- contentRect: {
4
- left: number;
5
- top: number;
6
- width: number;
7
- height: number;
8
- };
9
- }
10
-
11
- type ResizeObserverCallback = (entries: ResizeObserverEntry[], observer: ResizeObserver) => void;
1
+ export type ResizeObserver = globalThis.ResizeObserver;
12
2
 
13
- export declare class ResizeObserver {
14
- constructor(callback: ResizeObserverCallback);
15
- observe(target: Element, options?: any): void;
16
- unobserve(target: Element): void;
17
- disconnect(): void;
18
- static toString(): string;
19
- }
20
-
21
- export interface ResizeObserverPolyfill {
3
+ export type ResizeObserverPolyfill = {
22
4
  new (callback: ResizeObserverCallback): ResizeObserver;
23
- }
5
+ };
24
6
 
25
7
  export interface PrivateWindow {
26
8
  ResizeObserver: ResizeObserverPolyfill;
@@ -1,5 +1,5 @@
1
- import type { SVGAttributes } from 'react';
2
1
  import type { OctaneNode } from 'octane';
2
+ import type { Octane } from 'octane/jsx-runtime';
3
3
  import cx from 'classnames';
4
4
  import { Group } from '@octanejs/visx/group';
5
5
  import type { SankeyExtraProperties, SankeyGraph, SankeyLink, SankeyNode } from 'd3-sankey';
@@ -9,13 +9,13 @@ import type { Link } from 'd3-shape';
9
9
  const DEFAULT_COLOR = '#000';
10
10
 
11
11
  type NodeProps =
12
- Pick<SVGAttributes<SVGRectElement>, | 'stroke'
12
+ Pick<Octane.SVGProps<SVGRectElement>, | 'stroke'
13
13
  | 'strokeOpacity'
14
14
  | 'strokeWidth'
15
15
  | 'fill'
16
16
  | 'fillOpacity'>;
17
17
  type LinkProps =
18
- Pick<SVGAttributes<SVGPathElement>, | 'fill'
18
+ Pick<Octane.SVGProps<SVGPathElement>, | 'fill'
19
19
  | 'fillOpacity'
20
20
  | 'stroke'
21
21
  | 'strokeOpacity'
@@ -113,8 +113,12 @@ export default function Sankey<NodeDatum extends SankeyExtraProperties, LinkDatu
113
113
  if (extent) sankey.extent(extent);
114
114
  if (size) sankey.size(size);
115
115
  if (iterations) sankey.iterations(iterations);
116
- if (nodeSort) sankey.nodeSort(nodeSort);
117
- if (linkSort) sankey.linkSort(linkSort);
116
+ if (nodeSort) {
117
+ sankey.nodeSort(nodeSort as (a: SankeyNode<NodeDatum, LinkDatum>, b: SankeyNode<NodeDatum, LinkDatum>) => number);
118
+ }
119
+ if (linkSort) {
120
+ sankey.linkSort(linkSort as (a: SankeyLink<NodeDatum, LinkDatum>, b: SankeyLink<NodeDatum, LinkDatum>) => number);
121
+ }
118
122
 
119
123
  const graph = sankey(root);
120
124
  const createPath = sankeyLinkHorizontal<NodeDatum, LinkDatum>();
@@ -1,10 +1,10 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { SVGAttributes } from 'react';
3
2
  import type { OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
4
4
  import type { SankeyExtraProperties, SankeyGraph, SankeyLink, SankeyNode } from 'd3-sankey';
5
5
  import type { Link } from 'd3-shape';
6
- type NodeProps = Pick<SVGAttributes<SVGRectElement>, 'stroke' | 'strokeOpacity' | 'strokeWidth' | 'fill' | 'fillOpacity'>;
7
- type LinkProps = Pick<SVGAttributes<SVGPathElement>, 'fill' | 'fillOpacity' | 'stroke' | 'strokeOpacity' | 'strokeWidth' | 'strokeDasharray' | 'strokeDashoffset'>;
6
+ type NodeProps = Pick<Octane.SVGProps<SVGRectElement>, 'stroke' | 'strokeOpacity' | 'strokeWidth' | 'fill' | 'fillOpacity'>;
7
+ type LinkProps = Pick<Octane.SVGProps<SVGPathElement>, 'fill' | 'fillOpacity' | 'stroke' | 'strokeOpacity' | 'strokeWidth' | 'strokeDasharray' | 'strokeDashoffset'>;
8
8
  type CreatePath<NodeDatum extends SankeyExtraProperties, LinkDatum extends SankeyExtraProperties> = Link<any, SankeyLink<NodeDatum, LinkDatum>, [number, number]>;
9
9
  type NodeIdAccessor<NodeDatum extends SankeyExtraProperties, LinkDatum extends SankeyExtraProperties> = (node: SankeyNode<NodeDatum, LinkDatum>) => string | number;
10
10
  type SourceAccessor<NodeDatum extends SankeyExtraProperties, LinkDatum extends SankeyExtraProperties> = Exclude<Parameters<CreatePath<NodeDatum, LinkDatum>['source']>, undefined>[0];
@@ -1,10 +1,11 @@
1
1
  import type { Ref } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
  import cx from 'classnames';
3
4
  import type { AddSVGProps } from '../types';
4
5
 
5
6
  export type BarProps = {
6
7
  /** className to apply to rect element. */
7
- className?: string;
8
+ className?: Octane.SVGProps<SVGRectElement>['className'];
8
9
  /** reference to rect element. */
9
10
  innerRef?: Ref<SVGRectElement>;
10
11
  };
@@ -1,9 +1,10 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
2
  import type { Ref } from 'react';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
  import type { AddSVGProps } from '../types';
4
5
  export type BarProps = {
5
6
  /** className to apply to rect element. */
6
- className?: string;
7
+ className?: Octane.SVGProps<SVGRectElement>['className'];
7
8
  /** reference to rect element. */
8
9
  innerRef?: Ref<SVGRectElement>;
9
10
  };
@@ -1,11 +1,12 @@
1
1
  import type { Ref } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
  import type { OctaneNode } from 'octane';
3
4
  import cx from 'classnames';
4
5
  import type { AddSVGProps } from '../types';
5
6
 
6
7
  export type BarRoundedProps = {
7
8
  /** className to apply to path element. */
8
- className?: string;
9
+ className?: Octane.SVGProps<SVGPathElement>['className'];
9
10
  /** reference to path element. */
10
11
  innerRef?: Ref<SVGPathElement>;
11
12
  /** left position of the bar */
@@ -1,10 +1,11 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
2
  import type { Ref } from 'react';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
  import type { OctaneNode } from 'octane';
4
5
  import type { AddSVGProps } from '../types';
5
6
  export type BarRoundedProps = {
6
7
  /** className to apply to path element. */
7
- className?: string;
8
+ className?: Octane.SVGProps<SVGPathElement>['className'];
8
9
  /** reference to path element. */
9
10
  innerRef?: Ref<SVGPathElement>;
10
11
  /** left position of the bar */
@@ -1,4 +1,5 @@
1
1
  import type { Ref } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
  import cx from 'classnames';
3
4
  import type { AddSVGProps } from '../types';
4
5
 
@@ -9,7 +10,7 @@ interface Point {
9
10
 
10
11
  export type LineProps = {
11
12
  /** className to apply to line element. */
12
- className?: string;
13
+ className?: Octane.SVGProps<SVGLineElement>['className'];
13
14
  /** reference to line element. */
14
15
  innerRef?: Ref<SVGLineElement>;
15
16
  /** fill color applied to line element. */