@recharts/devtools 0.0.13 → 0.0.14

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.
@@ -14,6 +14,8 @@ import { useRechartsDevtoolsContext } from '../context/RechartsDevtoolsContext.j
14
14
  import { RechartsAnnotations } from './RechartsAnnotations.js';
15
15
  import { YAxisTicksInspector } from '../inspectors/YAxisTicksInspector.js';
16
16
  import { XAxisTicksInspector } from '../inspectors/XAxisTicksInspector.js';
17
+ import { useIsTooltipActiveInspector } from '../inspectors/useIsTooltipActiveInspector.js';
18
+ import { useActiveTooltipCoordinateInspector } from '../inspectors/useActiveTooltipCoordinateInspector.js';
17
19
  const INSPECTORS = {
18
20
  'useChartWidth | useChartHeight': ChartDimensionInspector,
19
21
  useMargin: MarginInspector,
@@ -25,6 +27,8 @@ const INSPECTORS = {
25
27
  useActiveTooltipLabel: ActiveTooltipLabelInspector,
26
28
  useXAxisTicks: XAxisTicksInspector,
27
29
  useYAxisTicks: YAxisTicksInspector,
30
+ useIsTooltipActive: useIsTooltipActiveInspector,
31
+ useActiveTooltipCoordinate: useActiveTooltipCoordinateInspector,
28
32
  };
29
33
  const isValidInspectorKey = (key) => {
30
34
  return key != null && key in INSPECTORS;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  export declare function ValueInspector({ value }: {
3
3
  value: unknown;
4
4
  }): React.JSX.Element;
5
- export declare function ObjectInspector({ obj }: {
6
- obj: Record<string, any> | undefined;
5
+ export declare function ObjectInspector<T extends object>({ obj, }: {
6
+ obj: Readonly<T> | undefined;
7
7
  }): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { PrimitiveInspector } from './PrimitiveInspector.js';
2
+ import { PrimitiveInspector, serializePrimitive } from './PrimitiveInspector.js';
3
3
  /*
4
4
  * Values that are expanded by default:
5
5
  * - primitives
@@ -31,11 +31,20 @@ export function ValueInspector({ value }) {
31
31
  }
32
32
  return React.createElement(NotPrimitiveInspector, { value: value });
33
33
  }
34
- export function ObjectInspector({ obj }) {
34
+ function getOwnEnumerableKeys(obj) {
35
+ const keys = [];
36
+ for (const key in obj) {
37
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
38
+ keys.push(key);
39
+ }
40
+ }
41
+ return keys;
42
+ }
43
+ export function ObjectInspector({ obj, }) {
35
44
  if (obj == null) {
36
- return React.createElement("code", null, JSON.stringify(obj));
45
+ return React.createElement("code", null, serializePrimitive(obj));
37
46
  }
38
- const keys = Object.keys(obj);
47
+ const keys = getOwnEnumerableKeys(obj);
39
48
  return (React.createElement("div", null, keys.map((key) => (React.createElement("div", { key: key },
40
49
  React.createElement("strong", null, key),
41
50
  ": ",
@@ -0,0 +1,2 @@
1
+ import { InspectorDef } from '../types.js';
2
+ export declare const useActiveTooltipCoordinateInspector: InspectorDef;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { useActiveTooltipCoordinate } from 'recharts';
3
+ import { useEventDispatch } from '../components/useEventDispatch.js';
4
+ import { ObjectInspector } from './generic/ObjectInspector.js';
5
+ export const useActiveTooltipCoordinateInspector = {
6
+ Inspector: () => {
7
+ const tooltipCoordinate = useActiveTooltipCoordinate();
8
+ useEventDispatch(tooltipCoordinate);
9
+ return React.createElement(ObjectInspector, { obj: tooltipCoordinate });
10
+ },
11
+ };
@@ -0,0 +1,2 @@
1
+ import { InspectorDef } from '../types.js';
2
+ export declare const useIsTooltipActiveInspector: InspectorDef;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { useIsTooltipActive } from 'recharts';
3
+ import { useEventDispatch } from '../components/useEventDispatch.js';
4
+ import { PrimitiveInspector } from './generic/PrimitiveInspector.js';
5
+ export const useIsTooltipActiveInspector = {
6
+ Inspector: () => {
7
+ const tooltipActive = useIsTooltipActive();
8
+ useEventDispatch(tooltipActive);
9
+ return React.createElement(PrimitiveInspector, { value: tooltipActive });
10
+ },
11
+ };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "type": "module",
7
- "version": "0.0.13",
7
+ "version": "0.0.14",
8
8
  "description": "Devtools and helper functions for Recharts",
9
9
  "main": "dist/index.js",
10
10
  "types": "dist/index.d.ts",
@@ -19,8 +19,7 @@
19
19
  "type-check": "tsc --noEmit",
20
20
  "test": "vitest run",
21
21
  "lint": "eslint src test",
22
- "format": "prettier --write \"{src,test}/**/*.ts\"",
23
- "release": "node ./scripts/publish.js"
22
+ "format": "prettier --write \"{src,test}/**/*.ts\""
24
23
  },
25
24
  "keywords": [
26
25
  "recharts",