@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,5 +1,6 @@
1
1
  import type { Ref } from 'react';
2
2
  import type { OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
  import cx from 'classnames';
4
5
  import type { Line as LineType } from 'd3-shape';
5
6
  import type { AddSVGProps, LinePathConfig } from '../types';
@@ -15,7 +16,7 @@ export type LinePathProps<Datum> = {
15
16
  /** Fill color of the path element. */
16
17
  fill?: string;
17
18
  /** className applied to path element. */
18
- className?: string;
19
+ className?: Octane.SVGProps<SVGPathElement>['className'];
19
20
  } & LinePathConfig<Datum>;
20
21
 
21
22
  export default function LinePath<Datum>({
@@ -1,6 +1,7 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
2
  import type { Ref } from 'react';
3
3
  import type { OctaneNode } from 'octane';
4
+ import type { Octane } from 'octane/jsx-runtime';
4
5
  import type { Line as LineType } from 'd3-shape';
5
6
  import type { AddSVGProps, LinePathConfig } from '../types';
6
7
  export type LinePathProps<Datum> = {
@@ -15,6 +16,6 @@ export type LinePathProps<Datum> = {
15
16
  /** Fill color of the path element. */
16
17
  fill?: string;
17
18
  /** className applied to path element. */
18
- className?: string;
19
+ className?: Octane.SVGProps<SVGPathElement>['className'];
19
20
  } & LinePathConfig<Datum>;
20
21
  export default function LinePath<Datum>({ children, data, x, y, fill, className, curve, innerRef, defined, ...restProps }: AddSVGProps<LinePathProps<Datum>, SVGPathElement>): import("react").JSX.Element;
@@ -1,13 +1,14 @@
1
1
  import type { Area } from 'd3-shape';
2
2
  import type { Ref } from 'react';
3
3
  import type { OctaneNode } from 'octane';
4
+ import type { Octane } from 'octane/jsx-runtime';
4
5
  import type { AreaPathConfig } from './D3ShapeConfig';
5
6
 
6
7
  export type BaseAreaProps<Datum> = {
7
8
  /** Override render function which is passed the configured area generator as input. */
8
9
  children?: (args: { path: Area<Datum> }) => OctaneNode;
9
10
  /** Classname applied to path element. */
10
- className?: string;
11
+ className?: Octane.SVGProps<SVGPathElement>['className'];
11
12
  /** Array of data for which to generate an area shape. */
12
13
  data?: Datum[];
13
14
  /** React RefObject passed to the path element. */
package/src/text/types.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { CSSProperties, Ref, SVGAttributes } from 'react';
1
+ import type { CSSProperties, Ref } from 'react';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
 
3
- type SVGTSpanProps = SVGAttributes<SVGTSpanElement>;
4
- type SVGTextProps = SVGAttributes<SVGTextElement>;
4
+ type SVGTSpanProps = Octane.SVGProps<SVGTSpanElement>;
5
+ type SVGTextProps = Octane.SVGProps<SVGTextElement>;
5
6
 
6
7
  type OwnProps = {
7
8
  /** className to apply to the SVGText element. */
@@ -1,15 +1,18 @@
1
- import type { ReactElement, FunctionComponent, HTMLProps, ComponentType } from 'react';
1
+ import type { ComponentBody, ElementDescriptor, OctaneNode } from 'octane';
2
+ import type { Octane } from 'octane/jsx-runtime';
2
3
 
3
4
  import type { UseTooltipParams } from '../hooks/useTooltip.tsrx';
4
5
  import useTooltip from '../hooks/useTooltip.tsrx';
5
6
 
6
7
  export type WithTooltipProvidedProps<TooltipData> = UseTooltipParams<TooltipData>;
7
- type WithTooltipContainerProps = HTMLProps<HTMLDivElement>;
8
- type RenderTooltipContainer =
9
- (children: ReactElement, containerProps?: WithTooltipContainerProps) => ReactElement;
8
+ type WithTooltipContainerProps = Octane.HTMLAttributes<HTMLDivElement>;
9
+ type RenderTooltipContainer = (
10
+ children: ElementDescriptor,
11
+ containerProps?: WithTooltipContainerProps,
12
+ ) => ElementDescriptor | OctaneNode;
10
13
 
11
14
  export default function withTooltip<BaseComponentProps = {}, TooltipData = {}>(
12
- BaseComponent: ComponentType<BaseComponentProps & WithTooltipProvidedProps<TooltipData>>,
15
+ BaseComponent: ComponentBody<BaseComponentProps & WithTooltipProvidedProps<TooltipData>>,
13
16
  containerProps: WithTooltipContainerProps = {
14
17
  style: {
15
18
  position: 'relative',
@@ -17,13 +20,15 @@ export default function withTooltip<BaseComponentProps = {}, TooltipData = {}>(
17
20
  height: 'inherit',
18
21
  } as const,
19
22
  },
20
- renderContainer: RenderTooltipContainer = (children, props) => <div {...props}>{children}</div>,
21
- ) {
22
- const WrappedComponent: FunctionComponent<BaseComponentProps> = (props) => {
23
+ renderContainer: RenderTooltipContainer = function defaultRenderContainer(children, props) {
24
+ return <div {...props}>{children}</div>;
25
+ },
26
+ ): (props: BaseComponentProps) => OctaneNode {
27
+ function WrappedComponent(props: BaseComponentProps): OctaneNode {
23
28
  const tooltipProps = useTooltip<TooltipData>();
24
29
 
25
30
  return renderContainer(<BaseComponent {...tooltipProps} {...props} />, containerProps);
26
- };
31
+ }
27
32
 
28
33
  return WrappedComponent;
29
34
  }
@@ -1,8 +1,9 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type { ReactElement, FunctionComponent, HTMLProps, ComponentType } from 'react';
2
+ import type { ComponentBody, ElementDescriptor, OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
  import type { UseTooltipParams } from '../hooks/useTooltip.tsrx';
4
5
  export type WithTooltipProvidedProps<TooltipData> = UseTooltipParams<TooltipData>;
5
- type WithTooltipContainerProps = HTMLProps<HTMLDivElement>;
6
- type RenderTooltipContainer = (children: ReactElement, containerProps?: WithTooltipContainerProps) => ReactElement;
7
- export default function withTooltip<BaseComponentProps = {}, TooltipData = {}>(BaseComponent: ComponentType<BaseComponentProps & WithTooltipProvidedProps<TooltipData>>, containerProps?: WithTooltipContainerProps, renderContainer?: RenderTooltipContainer): FunctionComponent<BaseComponentProps>;
6
+ type WithTooltipContainerProps = Octane.HTMLAttributes<HTMLDivElement>;
7
+ type RenderTooltipContainer = (children: ElementDescriptor, containerProps?: WithTooltipContainerProps) => ElementDescriptor | OctaneNode;
8
+ export default function withTooltip<BaseComponentProps = {}, TooltipData = {}>(BaseComponent: ComponentBody<BaseComponentProps & WithTooltipProvidedProps<TooltipData>>, containerProps?: WithTooltipContainerProps, renderContainer?: RenderTooltipContainer): (props: BaseComponentProps) => OctaneNode;
8
9
  export {};
@@ -1,4 +1,3 @@
1
- import type React from 'react';
2
1
  import type { OctaneNode } from 'octane';
3
2
  import ChartTooltipContent from './ChartTooltipContent.tsrx';
4
3
  import FloatingTooltip from './FloatingTooltip.tsrx';
@@ -77,7 +76,9 @@ export default function ChartTooltip<Datum = unknown>({
77
76
  offset={offset}
78
77
  collisionPadding={collisionPadding}
79
78
  >
80
- {(state) => {
79
+ {function renderChartTooltip(
80
+ state: FloatingTooltipRootState<ChartTooltipItem<Datum>[]>,
81
+ ) {
81
82
  const content =
82
83
  renderContent?.({ items, config, state }) ??
83
84
  <ChartTooltipContent label={label} items={items} config={config} {...contentProps} />;
@@ -1,5 +1,4 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type React from 'react';
3
2
  import type { OctaneNode } from 'octane';
4
3
  import type { ChartTooltipConfig, ChartTooltipContentProps, ChartTooltipItem } from './ChartTooltipContent.tsrx';
5
4
  import type { FloatingTooltipOffset, FloatingTooltipPadding, FloatingTooltipPortalProps, FloatingTooltipPositionerProps, FloatingTooltipRootState, TooltipAnchor, TooltipPlacement, UseFloatingTooltipOptions } from './types';
@@ -27,4 +26,4 @@ export type ChartTooltipProps<Datum = unknown> = ChartTooltipControlledProps<Dat
27
26
  state: FloatingTooltipRootState<ChartTooltipItem<Datum>[]>;
28
27
  }) => OctaneNode;
29
28
  };
30
- export default function ChartTooltip<Datum = unknown>({ anchor, collisionPadding, config, contentProps, floatingOptions, items, label, offset, open, placement, portal, portalProps, positionerProps, renderContent, strategy, }: ChartTooltipProps<Datum>): React.JSX.Element;
29
+ export default function ChartTooltip<Datum = unknown>({ anchor, collisionPadding, config, contentProps, floatingOptions, items, label, offset, open, placement, portal, portalProps, positionerProps, renderContent, strategy, }: ChartTooltipProps<Datum>): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
- import type React from 'react';
2
- import type { OctaneNode } from 'octane';
1
+ import type { ComponentBody, OctaneNode } from 'octane';
2
+ import type { CSSProperties } from 'react';
3
+ import type { Octane } from 'octane/jsx-runtime';
3
4
 
4
5
  export type ChartTooltipItem<Datum = unknown> = {
5
6
  key: string;
@@ -19,7 +20,7 @@ export type ChartTooltipItem<Datum = unknown> = {
19
20
  export type ChartTooltipConfig<Datum = unknown> = Record<string, {
20
21
  label?: OctaneNode | ((item: ChartTooltipItem<Datum>) => OctaneNode);
21
22
  color?: string | ((item: ChartTooltipItem<Datum>) => string | undefined);
22
- icon?: React.ComponentType<{ item: ChartTooltipItem<Datum> }>;
23
+ icon?: ComponentBody<{ item: ChartTooltipItem<Datum> }>;
23
24
  formatValue?: (value: unknown, item: ChartTooltipItem<Datum>) => OctaneNode;
24
25
  formatLabel?: (item: ChartTooltipItem<Datum>) => OctaneNode;
25
26
  hide?: boolean;
@@ -45,7 +46,7 @@ export type ChartTooltipItemRenderParams<Datum = unknown> = {
45
46
 
46
47
  export type ChartTooltipValueRenderParams<Datum = unknown> = ChartTooltipItemRenderParams<Datum>;
47
48
 
48
- export type ChartTooltipContentProps<Datum = unknown> = React.HTMLAttributes<HTMLDivElement> & {
49
+ export type ChartTooltipContentProps<Datum = unknown> = Octane.HTMLAttributes<HTMLDivElement> & {
49
50
  label?: OctaneNode;
50
51
  items: ChartTooltipItem<Datum>[];
51
52
  config?: ChartTooltipConfig<Datum>;
@@ -56,7 +57,7 @@ export type ChartTooltipContentProps<Datum = unknown> = React.HTMLAttributes<HTM
56
57
  renderLabel?: (params: ChartTooltipLabelRenderParams<Datum>) => OctaneNode;
57
58
  renderItem?: (params: ChartTooltipItemRenderParams<Datum>) => OctaneNode;
58
59
  renderValue?: (params: ChartTooltipValueRenderParams<Datum>) => OctaneNode;
59
- getItemKey?: (item: ChartTooltipItem<Datum>, index: number) => React.Key;
60
+ getItemKey?: (item: ChartTooltipItem<Datum>, index: number) => string | number;
60
61
  'data-testid'?: string;
61
62
  };
62
63
 
@@ -66,7 +67,7 @@ type VisibleItem<Datum> = {
66
67
  item: ChartTooltipItem<Datum>;
67
68
  };
68
69
 
69
- type ChartTooltipItemStyle = React.CSSProperties & {
70
+ type ChartTooltipItemStyle = CSSProperties & {
70
71
  '--visx-tooltip-item-color'?: string;
71
72
  };
72
73
 
@@ -1,6 +1,6 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type React from 'react';
3
- import type { OctaneNode } from 'octane';
2
+ import type { ComponentBody, OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
4
4
  export type ChartTooltipItem<Datum = unknown> = {
5
5
  key: string;
6
6
  datum?: Datum;
@@ -18,7 +18,7 @@ export type ChartTooltipItem<Datum = unknown> = {
18
18
  export type ChartTooltipConfig<Datum = unknown> = Record<string, {
19
19
  label?: OctaneNode | ((item: ChartTooltipItem<Datum>) => OctaneNode);
20
20
  color?: string | ((item: ChartTooltipItem<Datum>) => string | undefined);
21
- icon?: React.ComponentType<{
21
+ icon?: ComponentBody<{
22
22
  item: ChartTooltipItem<Datum>;
23
23
  }>;
24
24
  formatValue?: (value: unknown, item: ChartTooltipItem<Datum>) => OctaneNode;
@@ -41,7 +41,7 @@ export type ChartTooltipItemRenderParams<Datum = unknown> = {
41
41
  indicator: ChartTooltipIndicator;
42
42
  };
43
43
  export type ChartTooltipValueRenderParams<Datum = unknown> = ChartTooltipItemRenderParams<Datum>;
44
- export type ChartTooltipContentProps<Datum = unknown> = React.HTMLAttributes<HTMLDivElement> & {
44
+ export type ChartTooltipContentProps<Datum = unknown> = Octane.HTMLAttributes<HTMLDivElement> & {
45
45
  label?: OctaneNode;
46
46
  items: ChartTooltipItem<Datum>[];
47
47
  config?: ChartTooltipConfig<Datum>;
@@ -52,7 +52,7 @@ export type ChartTooltipContentProps<Datum = unknown> = React.HTMLAttributes<HTM
52
52
  renderLabel?: (params: ChartTooltipLabelRenderParams<Datum>) => OctaneNode;
53
53
  renderItem?: (params: ChartTooltipItemRenderParams<Datum>) => OctaneNode;
54
54
  renderValue?: (params: ChartTooltipValueRenderParams<Datum>) => OctaneNode;
55
- getItemKey?: (item: ChartTooltipItem<Datum>, index: number) => React.Key;
55
+ getItemKey?: (item: ChartTooltipItem<Datum>, index: number) => string | number;
56
56
  'data-testid'?: string;
57
57
  };
58
- export default function ChartTooltipContent<Datum = unknown>({ className, config, getItemKey, hideIndicator, hideLabel, indicator, items, label, renderItem, renderLabel, renderValue, sortItems, 'data-testid': dataTestId, ...restProps }: ChartTooltipContentProps<Datum>): React.JSX.Element | null;
58
+ export default function ChartTooltipContent<Datum = unknown>({ className, config, getItemKey, hideIndicator, hideLabel, indicator, items, label, renderItem, renderLabel, renderValue, sortItems, 'data-testid': dataTestId, ...restProps }: ChartTooltipContentProps<Datum>): import("react").JSX.Element | null;
@@ -1,6 +1,9 @@
1
1
  import { FloatingArrow, FloatingDelayGroup, FloatingPortal } from '@octanejs/floating-ui';
2
2
  import { cloneElement, isValidElement, useCallback } from 'octane';
3
- import type React from 'react';
3
+ import type { ElementDescriptor } from 'octane';
4
+ import type { CSSProperties } from 'react';
5
+ import type { Octane } from 'octane/jsx-runtime';
6
+ import type { HTMLProps } from '@octanejs/floating-ui';
4
7
  import { FloatingTooltipContextProvider, useFloatingTooltipContext } from './context.tsrx';
5
8
  import useFloatingTooltip from './useFloatingTooltip.tsrx';
6
9
  import type {
@@ -18,13 +21,13 @@ import type {
18
21
  } from './types';
19
22
 
20
23
  type RenderElementProps<ElementProps, State> = {
21
- defaultElement: React.ReactElement;
24
+ defaultElement: ElementDescriptor;
22
25
  props: ElementProps;
23
- render?: React.ReactElement | ((props: ElementProps, state: State) => React.ReactElement);
26
+ render?: ElementDescriptor | ((props: ElementProps, state: State) => ElementDescriptor);
24
27
  state: State;
25
28
  };
26
29
 
27
- type FloatingCssVariables = React.CSSProperties & {
30
+ type FloatingCssVariables = CSSProperties & {
28
31
  '--visx-tooltip-transform-origin'?: string;
29
32
  '--visx-tooltip-arrow-x'?: string;
30
33
  '--visx-tooltip-arrow-y'?: string;
@@ -34,9 +37,9 @@ type FloatingDataAttributes = {
34
37
  [key: `data-${string}`]: string | undefined;
35
38
  };
36
39
 
37
- type FloatingReferenceProps = React.HTMLProps<Element> & FloatingDataAttributes;
38
- type FloatingDivProps = React.HTMLProps<HTMLDivElement> & FloatingDataAttributes;
39
- type FloatingSvgProps = React.SVGProps<SVGSVGElement> & FloatingDataAttributes;
40
+ type FloatingReferenceProps = HTMLProps<Element> & FloatingDataAttributes;
41
+ type FloatingDivProps = HTMLProps<HTMLDivElement> & FloatingDataAttributes;
42
+ type FloatingSvgProps = Octane.SVGProps<SVGSVGElement> & FloatingDataAttributes;
40
43
 
41
44
  function renderElement<ElementProps, State>({
42
45
  defaultElement,
@@ -47,10 +50,10 @@ function renderElement<ElementProps, State>({
47
50
  if (typeof render === 'function') return render(props, state);
48
51
 
49
52
  if (isValidElement(render)) {
50
- return cloneElement(render, props as Partial<unknown> & React.Attributes);
53
+ return cloneElement(render, props as Partial<unknown>);
51
54
  }
52
55
 
53
- return cloneElement(defaultElement, props as Partial<unknown> & React.Attributes);
56
+ return cloneElement(defaultElement, props as Partial<unknown>);
54
57
  }
55
58
 
56
59
  function getTransformOrigin(state: FloatingTooltipRootState) {
@@ -149,7 +152,7 @@ function Trigger({ disabled = false, render }: FloatingTooltipTriggerProps) {
149
152
 
150
153
  if (typeof render === 'function') return render(triggerProps, triggerState);
151
154
 
152
- return cloneElement(render, triggerProps as Partial<unknown> & React.Attributes);
155
+ return cloneElement(render, triggerProps as Partial<unknown>);
153
156
  }
154
157
 
155
158
  function Portal({ children, container, disabled = false }: FloatingTooltipPortalProps) {
@@ -182,12 +185,14 @@ function Positioner({ children, id, render, style, ...restProps }: FloatingToolt
182
185
  style: {
183
186
  ...state.floatingStyles,
184
187
  ...getFloatingCssVariables(state),
185
- ...style,
188
+ ...(typeof style === 'object' && style != null ? style : null),
186
189
  },
187
190
  };
188
- const positionerProps = state.getFloatingProps(basePositionerProps);
191
+ const positionerProps = state.getFloatingProps(
192
+ basePositionerProps as HTMLProps<HTMLElement>,
193
+ ) as HTMLProps<HTMLDivElement>;
189
194
 
190
- return renderElement<React.HTMLProps<HTMLDivElement>, FloatingTooltipPositionerState>({
195
+ return renderElement<HTMLProps<HTMLDivElement>, FloatingTooltipPositionerState>({
191
196
  defaultElement: <div />,
192
197
  props: positionerProps,
193
198
  render,
@@ -207,7 +212,7 @@ function Content({ children, render, ...restProps }: FloatingTooltipContentProps
207
212
  'data-visx-tooltip-content': '',
208
213
  };
209
214
 
210
- return renderElement<React.HTMLProps<HTMLDivElement>, FloatingTooltipContentState>({
215
+ return renderElement<HTMLProps<HTMLDivElement>, FloatingTooltipContentState>({
211
216
  defaultElement: <div />,
212
217
  props: contentProps,
213
218
  render,
@@ -228,16 +233,17 @@ function Arrow({
228
233
  if (!state.mounted) return null;
229
234
 
230
235
  if (render) {
236
+ const svgRest = restProps as Octane.SVGProps<SVGSVGElement>;
231
237
  const baseArrowProps: FloatingSvgProps = {
232
- ...restProps,
238
+ ...svgRest,
233
239
  height,
234
240
  'data-visx-tooltip-arrow': '',
235
241
  ref: state.arrowRef,
236
242
  width,
237
243
  };
238
- const arrowProps = state.getArrowProps(baseArrowProps);
244
+ const arrowProps = state.getArrowProps(baseArrowProps) as Octane.SVGProps<SVGSVGElement>;
239
245
 
240
- return renderElement<React.SVGProps<SVGSVGElement>, FloatingTooltipArrowState>({
246
+ return renderElement<Octane.SVGProps<SVGSVGElement>, FloatingTooltipArrowState>({
241
247
  defaultElement: <svg />,
242
248
  props: arrowProps,
243
249
  render,
@@ -246,7 +252,7 @@ function Arrow({
246
252
  }
247
253
 
248
254
  return <FloatingArrow
249
- {...restProps}
255
+ {...(restProps as object)}
250
256
  data-visx-tooltip-arrow=""
251
257
  ref={state.arrowRef}
252
258
  context={state.context}
@@ -1,13 +1,13 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
- import type React from 'react';
2
+ import type { ElementDescriptor } from 'octane';
3
3
  import type { FloatingTooltipArrowProps, FloatingTooltipContentProps, FloatingTooltipPortalProps, FloatingTooltipPositionerProps, FloatingTooltipProviderProps, FloatingTooltipRootProps, FloatingTooltipTriggerProps } from './types';
4
- declare function Provider({ children, closeDelay, delay, skipDelay, }: FloatingTooltipProviderProps): React.JSX.Element;
5
- declare function Root<TData = unknown>({ children, forceMount, ...options }: FloatingTooltipRootProps<TData>): React.JSX.Element;
6
- declare function Trigger({ disabled, render }: FloatingTooltipTriggerProps): import("octane").ElementDescriptor<any> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
4
+ declare function Provider({ children, closeDelay, delay, skipDelay, }: FloatingTooltipProviderProps): import("react").JSX.Element;
5
+ declare function Root<TData = unknown>({ children, forceMount, ...options }: FloatingTooltipRootProps<TData>): import("react").JSX.Element;
6
+ declare function Trigger({ disabled, render }: FloatingTooltipTriggerProps): ElementDescriptor<any>;
7
7
  declare function Portal({ children, container, disabled }: FloatingTooltipPortalProps): unknown;
8
- declare function Positioner({ children, id, render, style, ...restProps }: FloatingTooltipPositionerProps): import("octane").ElementDescriptor<any> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
9
- declare function Content({ children, render, ...restProps }: FloatingTooltipContentProps): import("octane").ElementDescriptor<any> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
10
- declare function Arrow({ height, padding: _padding, render, tipRadius, width, ...restProps }: FloatingTooltipArrowProps): React.JSX.Element | import("octane").ElementDescriptor<any> | null;
8
+ declare function Positioner({ children, id, render, style, ...restProps }: FloatingTooltipPositionerProps): ElementDescriptor<any> | null;
9
+ declare function Content({ children, render, ...restProps }: FloatingTooltipContentProps): ElementDescriptor<any> | null;
10
+ declare function Arrow({ height, padding: _padding, render, tipRadius, width, ...restProps }: FloatingTooltipArrowProps): import("react").JSX.Element | ElementDescriptor<any> | null;
11
11
  declare const FloatingTooltip: {
12
12
  Arrow: typeof Arrow;
13
13
  Content: typeof Content;
@@ -1,6 +1,5 @@
1
1
  import { createContext, useContext } from 'octane';
2
2
  import type { OctaneNode } from 'octane';
3
- import type React from 'react';
4
3
  import type { FloatingTooltipRootState } from './types';
5
4
 
6
5
  const FloatingTooltipContext = createContext<FloatingTooltipRootState<any> | null>(null);
@@ -1,10 +1,9 @@
1
1
  // Generated by scripts/generate-tsrx-types.mjs.
2
2
  import type { OctaneNode } from 'octane';
3
- import type React from 'react';
4
3
  import type { FloatingTooltipRootState } from './types';
5
4
  export type FloatingTooltipContextProviderProps = {
6
5
  children: OctaneNode;
7
6
  value: FloatingTooltipRootState<any>;
8
7
  };
9
- export declare function FloatingTooltipContextProvider({ children, value, }: FloatingTooltipContextProviderProps): React.JSX.Element;
8
+ export declare function FloatingTooltipContextProvider({ children, value, }: FloatingTooltipContextProviderProps): import("react").JSX.Element;
10
9
  export declare function useFloatingTooltipContext(componentName: string): FloatingTooltipRootState<any>;
@@ -1,5 +1,4 @@
1
- import type React from 'react';
2
- import type {
1
+ export type {
3
2
  Boundary,
4
3
  FlipOptions,
5
4
  HideOptions,
@@ -16,110 +15,15 @@ import type {
16
15
  } from '@floating-ui/dom';
17
16
 
18
17
  export type {
19
- Boundary,
20
- FlipOptions,
21
- HideOptions,
22
- Middleware,
23
- MiddlewareData,
24
- OffsetOptions,
25
- Padding,
26
- Placement,
27
- ReferenceElement,
28
- ShiftOptions,
29
- SizeOptions,
30
- Strategy,
31
- VirtualElement,
32
- };
33
-
34
- export type OpenChangeReason =
35
- | 'outside-press'
36
- | 'escape-key'
37
- | 'ancestor-scroll'
38
- | 'reference-press'
39
- | 'click'
40
- | 'hover'
41
- | 'focus'
42
- | 'focus-out'
43
- | 'list-navigation'
44
- | 'safe-polygon';
45
-
46
- export type Delay = number | Partial<{ open: number; close: number }>;
47
-
48
- export type UseHoverProps = {
49
- enabled?: boolean;
50
- handleClose?: ((context: unknown) => (event: MouseEvent) => void) | null;
51
- restMs?: number | (() => number);
52
- delay?: Delay | (() => Delay);
53
- mouseOnly?: boolean;
54
- move?: boolean;
55
- };
56
-
57
- export type UseFocusProps = {
58
- enabled?: boolean;
59
- visibleOnly?: boolean;
60
- };
61
-
62
- export type UseDismissProps = {
63
- enabled?: boolean;
64
- escapeKey?: boolean;
65
- outsidePress?: boolean | ((event: MouseEvent) => boolean);
66
- outsidePressEvent?: 'pointerdown' | 'mousedown' | 'click';
67
- referencePress?: boolean;
68
- referencePressEvent?: 'pointerdown' | 'mousedown' | 'click';
69
- ancestorScroll?: boolean;
70
- bubbles?: boolean | { escapeKey?: boolean; outsidePress?: boolean };
71
- capture?: boolean | { escapeKey?: boolean; outsidePress?: boolean };
72
- };
73
-
74
- export type UseRoleProps = {
75
- enabled?: boolean;
76
- role?:
77
- | 'tooltip'
78
- | 'dialog'
79
- | 'alertdialog'
80
- | 'menu'
81
- | 'listbox'
82
- | 'grid'
83
- | 'tree'
84
- | 'label'
85
- | 'select'
86
- | 'combobox';
87
- };
88
-
89
- export type UseFloatingOptions = {
90
- whileElementsMounted?: (
91
- reference: ReferenceElement,
92
- floating: HTMLElement,
93
- update: () => void,
94
- ) => void | (() => void);
95
- };
96
-
97
- type MutableReference<T> = { current: T };
98
-
99
- export type UseFloatingReturn<RT extends ReferenceElement = ReferenceElement> = {
100
- x: number;
101
- y: number;
102
- placement: Placement;
103
- strategy: Strategy;
104
- floatingStyles: React.CSSProperties;
105
- middlewareData: MiddlewareData;
106
- update: () => void;
107
- refs: {
108
- reference: MutableReference<RT | null>;
109
- floating: MutableReference<HTMLElement | null>;
110
- domReference: MutableReference<Element | null>;
111
- setReference: (node: RT | null) => void;
112
- setPositionReference: (node: RT | null) => void;
113
- setFloating: (node: HTMLElement | null) => void;
114
- };
115
- context: Record<string, unknown>;
116
- };
117
-
118
- export type FloatingUiArrowProps = React.SVGProps<SVGSVGElement> & {
119
- context: unknown;
120
- width?: number;
121
- height?: number;
122
- tipRadius?: number;
123
- staticOffset?: string | number | null;
124
- d?: string;
125
- };
18
+ Delay,
19
+ HTMLProps,
20
+ OpenChangeReason,
21
+ UseFloatingOptions,
22
+ UseFloatingReturn,
23
+ UseDismissProps,
24
+ UseFocusProps,
25
+ UseHoverProps,
26
+ UseRoleProps,
27
+ } from '@octanejs/floating-ui';
28
+
29
+ export type { FloatingArrowProps as FloatingUiArrowProps } from '@octanejs/floating-ui';
@@ -1,5 +1,7 @@
1
- import type React from 'react';
2
- import type { OctaneNode } from 'octane';
1
+ import type { CSSProperties } from 'react';
2
+ import type { ElementDescriptor, OctaneNode } from 'octane';
3
+ import type { Octane } from 'octane/jsx-runtime';
4
+ import type { HTMLProps } from '@octanejs/floating-ui';
3
5
  import type {
4
6
  Boundary,
5
7
  Delay,
@@ -16,7 +18,6 @@ import type {
16
18
  SizeOptions,
17
19
  Strategy,
18
20
  UseDismissProps,
19
- FloatingUiArrowProps,
20
21
  UseFloatingOptions,
21
22
  UseFloatingReturn,
22
23
  UseFocusProps,
@@ -109,12 +110,12 @@ export type UseFloatingTooltipReturn<TData = unknown> = {
109
110
  strategy: Strategy;
110
111
  x: number | null;
111
112
  y: number | null;
112
- floatingStyles: React.CSSProperties;
113
+ floatingStyles: CSSProperties;
113
114
  middlewareData: MiddlewareData;
114
115
 
115
116
  refs: UseFloatingReturn<ReferenceElement>['refs'];
116
117
  context: UseFloatingReturn<ReferenceElement>['context'];
117
- arrowRef: React.RefCallback<SVGSVGElement>;
118
+ arrowRef: (node: SVGSVGElement | null) => void;
118
119
 
119
120
  setAnchor: (anchor: TooltipAnchor | null) => void;
120
121
  setData: (data: TData | undefined) => void;
@@ -122,9 +123,9 @@ export type UseFloatingTooltipReturn<TData = unknown> = {
122
123
  openTooltip: (data?: TData, anchor?: TooltipAnchor | null) => void;
123
124
  closeTooltip: () => void;
124
125
 
125
- getReferenceProps: <TProps extends React.HTMLProps<Element>>(props?: TProps) => TProps;
126
- getFloatingProps: <TProps extends React.HTMLProps<HTMLElement>>(props?: TProps) => TProps;
127
- getArrowProps: <TProps extends React.SVGProps<SVGSVGElement>>(props?: TProps) => TProps;
126
+ getReferenceProps: <TProps extends HTMLProps<Element>>(props?: TProps) => TProps;
127
+ getFloatingProps: <TProps extends HTMLProps<HTMLElement>>(props?: TProps) => TProps;
128
+ getArrowProps: <TProps extends Octane.SVGProps<SVGSVGElement>>(props?: TProps) => TProps;
128
129
  };
129
130
 
130
131
  export type FloatingTooltipProviderProps = {
@@ -149,51 +150,53 @@ export type FloatingTooltipTriggerState = {
149
150
 
150
151
  export type FloatingTooltipTriggerProps = {
151
152
  render:
152
- | React.ReactElement
153
- | ((props: React.HTMLProps<Element>, state: FloatingTooltipTriggerState) => React.ReactElement);
153
+ | ElementDescriptor
154
+ | ((props: HTMLProps<Element>, state: FloatingTooltipTriggerState) => ElementDescriptor);
154
155
  disabled?: boolean;
155
156
  };
156
157
 
157
158
  export type FloatingTooltipPortalProps = {
158
- container?: HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null;
159
+ container?: HTMLElement | ShadowRoot | { current: HTMLElement | ShadowRoot | null } | null;
159
160
  disabled?: boolean;
160
161
  children: OctaneNode;
161
162
  };
162
163
 
163
164
  export type FloatingTooltipPositionerState = FloatingTooltipRootState;
164
165
 
165
- export type FloatingTooltipPositionerProps = React.HTMLAttributes<HTMLDivElement> & {
166
+ export type FloatingTooltipPositionerProps = Octane.HTMLAttributes<HTMLDivElement> & {
166
167
  'data-testid'?: string;
167
168
  render?:
168
- | React.ReactElement
169
+ | ElementDescriptor
169
170
  | ((
170
- props: React.HTMLProps<HTMLDivElement>,
171
+ props: HTMLProps<HTMLDivElement>,
171
172
  state: FloatingTooltipPositionerState,
172
- ) => React.ReactElement);
173
+ ) => ElementDescriptor);
173
174
  };
174
175
 
175
176
  export type FloatingTooltipContentState = FloatingTooltipRootState;
176
177
 
177
- export type FloatingTooltipContentProps = React.HTMLAttributes<HTMLDivElement> & {
178
+ export type FloatingTooltipContentProps = Octane.HTMLAttributes<HTMLDivElement> & {
178
179
  render?:
179
- | React.ReactElement
180
- | ((
181
- props: React.HTMLProps<HTMLDivElement>,
182
- state: FloatingTooltipContentState,
183
- ) => React.ReactElement);
180
+ | ElementDescriptor
181
+ | ((props: HTMLProps<HTMLDivElement>, state: FloatingTooltipContentState) => ElementDescriptor);
184
182
  };
185
183
 
186
184
  export type FloatingTooltipArrowState = FloatingTooltipRootState;
187
185
 
188
186
  export type FloatingTooltipArrowProps = Omit<
189
- FloatingUiArrowProps,
190
- 'context' | 'padding' | 'ref'
187
+ Octane.SVGProps<SVGSVGElement>,
188
+ 'width' | 'height' | 'ref'
191
189
  > & {
190
+ width?: number;
191
+ height?: number;
192
+ tipRadius?: number;
193
+ staticOffset?: string | number | null;
194
+ d?: string;
192
195
  padding?: never;
193
196
  render?:
194
- | React.ReactElement
197
+ | ElementDescriptor
195
198
  | ((
196
- props: React.SVGProps<SVGSVGElement>,
199
+ props: Octane.SVGProps<SVGSVGElement>,
197
200
  state: FloatingTooltipArrowState,
198
- ) => React.ReactElement);
201
+ ) => ElementDescriptor);
199
202
  };