@unovis/react 1.0.0-beta.3 → 1.0.0-beta.4

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 (95) hide show
  1. package/components/area/index.d.ts +10 -10
  2. package/components/area/index.js +8 -6
  3. package/components/area/index.js.map +1 -1
  4. package/components/axis/index.d.ts +10 -10
  5. package/components/axis/index.js +8 -6
  6. package/components/axis/index.js.map +1 -1
  7. package/components/brush/index.d.ts +10 -10
  8. package/components/brush/index.js +8 -6
  9. package/components/brush/index.js.map +1 -1
  10. package/components/chord-diagram/index.d.ts +13 -13
  11. package/components/crosshair/index.d.ts +10 -10
  12. package/components/crosshair/index.js +8 -6
  13. package/components/crosshair/index.js.map +1 -1
  14. package/components/donut/index.d.ts +10 -10
  15. package/components/donut/index.js +8 -6
  16. package/components/donut/index.js.map +1 -1
  17. package/components/free-brush/index.d.ts +10 -10
  18. package/components/free-brush/index.js +8 -6
  19. package/components/free-brush/index.js.map +1 -1
  20. package/components/graph/index.d.ts +10 -10
  21. package/components/graph/index.js +8 -6
  22. package/components/graph/index.js.map +1 -1
  23. package/components/grouped-bar/index.d.ts +10 -10
  24. package/components/grouped-bar/index.js +8 -6
  25. package/components/grouped-bar/index.js.map +1 -1
  26. package/components/line/index.d.ts +10 -10
  27. package/components/line/index.js +8 -6
  28. package/components/line/index.js.map +1 -1
  29. package/components/sankey/index.d.ts +10 -10
  30. package/components/sankey/index.js +8 -6
  31. package/components/sankey/index.js.map +1 -1
  32. package/components/scatter/index.d.ts +10 -10
  33. package/components/scatter/index.js +8 -6
  34. package/components/scatter/index.js.map +1 -1
  35. package/components/stacked-bar/index.d.ts +10 -10
  36. package/components/stacked-bar/index.js +8 -6
  37. package/components/stacked-bar/index.js.map +1 -1
  38. package/components/timeline/index.d.ts +10 -10
  39. package/components/timeline/index.js +8 -6
  40. package/components/timeline/index.js.map +1 -1
  41. package/components/tooltip/index.d.ts +10 -10
  42. package/components/tooltip/index.js +8 -6
  43. package/components/tooltip/index.js.map +1 -1
  44. package/components/topojson-map/index.d.ts +14 -14
  45. package/components/topojson-map/index.js +8 -6
  46. package/components/topojson-map/index.js.map +1 -1
  47. package/components/xy-labels/index.d.ts +10 -10
  48. package/components/xy-labels/index.js +8 -6
  49. package/components/xy-labels/index.js.map +1 -1
  50. package/components.d.ts +19 -19
  51. package/composites/time-series/index.d.ts +54 -54
  52. package/composites/time-series/style.d.ts +3 -3
  53. package/composites.d.ts +1 -1
  54. package/containers/single-container/index.d.ts +6 -6
  55. package/containers/xy-container/index.d.ts +8 -8
  56. package/containers.d.ts +2 -2
  57. package/html-components/bullet-legend/index.d.ts +3 -3
  58. package/html-components/leaflet-flow-map/index.d.ts +15 -15
  59. package/html-components/leaflet-map/index.d.ts +12 -12
  60. package/index.d.ts +3 -3
  61. package/package.json +5 -3
  62. package/types/dom.d.ts +3 -3
  63. package/utils/react.d.ts +4 -4
  64. package/utils/react.js +1 -1
  65. package/utils/react.js.map +1 -1
  66. package/src/components/area/index.d.ts +0 -10
  67. package/src/components/axis/index.d.ts +0 -10
  68. package/src/components/brush/index.d.ts +0 -10
  69. package/src/components/chord-diagram/index.d.ts +0 -13
  70. package/src/components/crosshair/index.d.ts +0 -10
  71. package/src/components/donut/index.d.ts +0 -10
  72. package/src/components/free-brush/index.d.ts +0 -10
  73. package/src/components/graph/index.d.ts +0 -10
  74. package/src/components/grouped-bar/index.d.ts +0 -10
  75. package/src/components/line/index.d.ts +0 -10
  76. package/src/components/sankey/index.d.ts +0 -10
  77. package/src/components/scatter/index.d.ts +0 -10
  78. package/src/components/stacked-bar/index.d.ts +0 -10
  79. package/src/components/timeline/index.d.ts +0 -10
  80. package/src/components/tooltip/index.d.ts +0 -10
  81. package/src/components/topojson-map/index.d.ts +0 -14
  82. package/src/components/xy-labels/index.d.ts +0 -10
  83. package/src/components.d.ts +0 -19
  84. package/src/composites/time-series/index.d.ts +0 -54
  85. package/src/composites/time-series/style.d.ts +0 -3
  86. package/src/composites.d.ts +0 -1
  87. package/src/containers/single-container/index.d.ts +0 -6
  88. package/src/containers/xy-container/index.d.ts +0 -8
  89. package/src/containers.d.ts +0 -2
  90. package/src/html-components/bullet-legend/index.d.ts +0 -3
  91. package/src/html-components/leaflet-flow-map/index.d.ts +0 -15
  92. package/src/html-components/leaflet-map/index.d.ts +0 -12
  93. package/src/index.d.ts +0 -3
  94. package/src/types/dom.d.ts +0 -3
  95. package/src/utils/react.d.ts +0 -4
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Area, AreaConfigInterface } from '@unovis/ts';
3
- export declare type VisAreaRef<Datum> = {
4
- component: Area<Datum>;
5
- };
6
- export declare type VisAreaProps<Datum> = AreaConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisAreaRef<Datum>>;
9
- };
10
- export declare const VisArea: (<Datum>(props: VisAreaProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Area, AreaConfigInterface } from '@unovis/ts';
3
+ export declare type VisAreaRef<Datum> = {
4
+ component?: Area<Datum>;
5
+ };
6
+ export declare type VisAreaProps<Datum> = AreaConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisAreaRef<Datum>>;
9
+ };
10
+ export declare const VisArea: (<Datum>(props: VisAreaProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Area } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisAreaFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Area(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Area(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-component", { ref: ref });
21
23
  }
22
24
  const VisArea = React.memo(React.forwardRef(VisAreaFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/area/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Area, AreaConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisAreaRef<Datum> = {\n component: Area<Datum>;\n}\n\nexport type VisAreaProps<Datum> = AreaConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisAreaRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisAreaFC<Datum> (props: VisAreaProps<Datum>, fRef: ForwardedRef<VisAreaRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Area<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Area<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Area(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Area<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Area<Datum>>).__component__ }))\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisArea: (<Datum>(props: VisAreaProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisAreaFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,SAAS,CAAS,KAA0B,EAAE,IAAqC,EAAA;AAC1F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAG1D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AACjE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAA;KAExC,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAA4C,CAAC,aAAa,CAAA;QACjF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAA4C,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AACjH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,OAAO,GAAgE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/area/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Area, AreaConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisAreaRef<Datum> = {\n component?: Area<Datum>;\n}\n\nexport type VisAreaProps<Datum> = AreaConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisAreaRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisAreaFC<Datum> (props: VisAreaProps<Datum>, fRef: ForwardedRef<VisAreaRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Area<Datum>>>(null)\n const [component, setComponent] = useState<Area<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Area<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Area<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisArea: (<Datum>(props: VisAreaProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisAreaFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,SAAS,CAAS,KAA0B,EAAE,IAAqC,EAAA;AAC1F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAe,CAAA;IAGzD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AAKjE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,IAAI,CAAQ,KAAK,CAAC,CAAA;QACzD,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,OAAO,GAAgE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Axis, AxisConfigInterface } from '@unovis/ts';
3
- export declare type VisAxisRef<Datum> = {
4
- component: Axis<Datum>;
5
- };
6
- export declare type VisAxisProps<Datum> = AxisConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisAxisRef<Datum>>;
9
- };
10
- export declare const VisAxis: (<Datum>(props: VisAxisProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Axis, AxisConfigInterface } from '@unovis/ts';
3
+ export declare type VisAxisRef<Datum> = {
4
+ component?: Axis<Datum>;
5
+ };
6
+ export declare type VisAxisProps<Datum> = AxisConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisAxisRef<Datum>>;
9
+ };
10
+ export declare const VisAxis: (<Datum>(props: VisAxisProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Axis } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisAxisFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Axis(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Axis(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-axis", { ref: ref });
21
23
  }
22
24
  const VisAxis = React.memo(React.forwardRef(VisAxisFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/axis/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Axis, AxisConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisAxisRef<Datum> = {\n component: Axis<Datum>;\n}\n\nexport type VisAxisProps<Datum> = AxisConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisAxisRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisAxisFC<Datum> (props: VisAxisProps<Datum>, fRef: ForwardedRef<VisAxisRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Axis<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Axis<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Axis(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Axis<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Axis<Datum>>).__component__ }))\n return <vis-axis ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisAxis: (<Datum>(props: VisAxisProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisAxisFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,SAAS,CAAS,KAA0B,EAAE,IAAqC,EAAA;AAC1F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAG1D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AACjE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAA;KAExC,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAA4C,CAAC,aAAa,CAAA;QACjF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAA4C,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AACjH,IAAA,OAAO,KAAU,CAAA,aAAA,CAAA,UAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AAC/B,CAAC;AAIY,MAAA,OAAO,GAAgE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/axis/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Axis, AxisConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisAxisRef<Datum> = {\n component?: Axis<Datum>;\n}\n\nexport type VisAxisProps<Datum> = AxisConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisAxisRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisAxisFC<Datum> (props: VisAxisProps<Datum>, fRef: ForwardedRef<VisAxisRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Axis<Datum>>>(null)\n const [component, setComponent] = useState<Axis<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Axis<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Axis<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-axis ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisAxis: (<Datum>(props: VisAxisProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisAxisFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,SAAS,CAAS,KAA0B,EAAE,IAAqC,EAAA;AAC1F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAe,CAAA;IAGzD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AAKjE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,IAAI,CAAQ,KAAK,CAAC,CAAA;QACzD,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAU,CAAA,aAAA,CAAA,UAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AAC/B,CAAC;AAIY,MAAA,OAAO,GAAgE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Brush, BrushConfigInterface } from '@unovis/ts';
3
- export declare type VisBrushRef<Datum> = {
4
- component: Brush<Datum>;
5
- };
6
- export declare type VisBrushProps<Datum> = BrushConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisBrushRef<Datum>>;
9
- };
10
- export declare const VisBrush: (<Datum>(props: VisBrushProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Brush, BrushConfigInterface } from '@unovis/ts';
3
+ export declare type VisBrushRef<Datum> = {
4
+ component?: Brush<Datum>;
5
+ };
6
+ export declare type VisBrushProps<Datum> = BrushConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisBrushRef<Datum>>;
9
+ };
10
+ export declare const VisBrush: (<Datum>(props: VisBrushProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Brush } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisBrushFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Brush(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Brush(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-component", { ref: ref });
21
23
  }
22
24
  const VisBrush = React.memo(React.forwardRef(VisBrushFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Brush, BrushConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisBrushRef<Datum> = {\n component: Brush<Datum>;\n}\n\nexport type VisBrushProps<Datum> = BrushConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisBrushRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisBrushFC<Datum> (props: VisBrushProps<Datum>, fRef: ForwardedRef<VisBrushRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Brush<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Brush<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Brush(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Brush<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Brush<Datum>>).__component__ }))\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisBrush: (<Datum>(props: VisBrushProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisBrushFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAS,KAA2B,EAAE,IAAsC,EAAA;AAC7F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAA;IAG3D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA6C,CAAA;AAClE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;KAEzC,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAA6C,CAAC,aAAa,CAAA;QAClF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAA6C,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AAClH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAAiE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Brush, BrushConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisBrushRef<Datum> = {\n component?: Brush<Datum>;\n}\n\nexport type VisBrushProps<Datum> = BrushConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisBrushRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisBrushFC<Datum> (props: VisBrushProps<Datum>, fRef: ForwardedRef<VisBrushRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Brush<Datum>>>(null)\n const [component, setComponent] = useState<Brush<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Brush<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Brush<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisBrush: (<Datum>(props: VisBrushProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisBrushFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAS,KAA2B,EAAE,IAAsC,EAAA;AAC7F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAA;IAC3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAgB,CAAA;IAG1D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA6C,CAAA;AAKlE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,KAAK,CAAQ,KAAK,CAAC,CAAA;QAC1D,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAAiE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
@@ -1,13 +1,13 @@
1
- import { Ref } from 'react';
2
- import { ChordDiagram, ChordDiagramConfigInterface, ChordInputNode, ChordInputLink } from '@unovis/ts';
3
- export declare type VisChordDiagramRef<N extends ChordInputNode, L extends ChordInputLink> = {
4
- component: ChordDiagram<N, L>;
5
- };
6
- export declare type VisChordDiagramProps<N extends ChordInputNode, L extends ChordInputLink> = ChordDiagramConfigInterface<N, L> & {
7
- data?: {
8
- nodes: N[];
9
- links?: L[];
10
- };
11
- ref?: Ref<VisChordDiagramRef<N, L>>;
12
- };
13
- export declare const VisChordDiagram: (<N extends ChordInputNode, L extends ChordInputLink>(props: VisChordDiagramProps<N, L>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { ChordDiagram, ChordDiagramConfigInterface, ChordInputNode, ChordInputLink } from '@unovis/ts';
3
+ export declare type VisChordDiagramRef<N extends ChordInputNode, L extends ChordInputLink> = {
4
+ component?: ChordDiagram<N, L>;
5
+ };
6
+ export declare type VisChordDiagramProps<N extends ChordInputNode, L extends ChordInputLink> = ChordDiagramConfigInterface<N, L> & {
7
+ data?: {
8
+ nodes: N[];
9
+ links?: L[];
10
+ };
11
+ ref?: Ref<VisChordDiagramRef<N, L>>;
12
+ };
13
+ export declare const VisChordDiagram: (<N extends ChordInputNode, L extends ChordInputLink>(props: VisChordDiagramProps<N, L>) => JSX.Element | null);
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Crosshair, CrosshairConfigInterface } from '@unovis/ts';
3
- export declare type VisCrosshairRef<Datum> = {
4
- component: Crosshair<Datum>;
5
- };
6
- export declare type VisCrosshairProps<Datum> = CrosshairConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisCrosshairRef<Datum>>;
9
- };
10
- export declare const VisCrosshair: (<Datum>(props: VisCrosshairProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Crosshair, CrosshairConfigInterface } from '@unovis/ts';
3
+ export declare type VisCrosshairRef<Datum> = {
4
+ component?: Crosshair<Datum>;
5
+ };
6
+ export declare type VisCrosshairProps<Datum> = CrosshairConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisCrosshairRef<Datum>>;
9
+ };
10
+ export declare const VisCrosshair: (<Datum>(props: VisCrosshairProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Crosshair } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisCrosshairFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Crosshair(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Crosshair(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-crosshair", { ref: ref });
21
23
  }
22
24
  const VisCrosshair = React.memo(React.forwardRef(VisCrosshairFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Crosshair, CrosshairConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisCrosshairRef<Datum> = {\n component: Crosshair<Datum>;\n}\n\nexport type VisCrosshairProps<Datum> = CrosshairConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisCrosshairRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisCrosshairFC<Datum> (props: VisCrosshairProps<Datum>, fRef: ForwardedRef<VisCrosshairRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Crosshair<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Crosshair<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Crosshair(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Crosshair<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Crosshair<Datum>>).__component__ }))\n return <vis-crosshair ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisCrosshair: (<Datum>(props: VisCrosshairProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisCrosshairFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,cAAc,CAAS,KAA+B,EAAE,IAA0C,EAAA;AACzG,IAAA,MAAM,GAAG,GAAG,MAAM,CAAwC,IAAI,CAAC,CAAA;IAG/D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAAiD,CAAA;AACtE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAA;KAE7C,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAAiD,CAAC,aAAa,CAAA;QACtF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAAiD,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AACtH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,YAAY,GAAqE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Crosshair, CrosshairConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisCrosshairRef<Datum> = {\n component?: Crosshair<Datum>;\n}\n\nexport type VisCrosshairProps<Datum> = CrosshairConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisCrosshairRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisCrosshairFC<Datum> (props: VisCrosshairProps<Datum>, fRef: ForwardedRef<VisCrosshairRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Crosshair<Datum>>>(null)\n const [component, setComponent] = useState<Crosshair<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Crosshair<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Crosshair<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-crosshair ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisCrosshair: (<Datum>(props: VisCrosshairProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisCrosshairFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,cAAc,CAAS,KAA+B,EAAE,IAA0C,EAAA;AACzG,IAAA,MAAM,GAAG,GAAG,MAAM,CAAwC,IAAI,CAAC,CAAA;IAC/D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAoB,CAAA;IAG9D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAAiD,CAAA;AAKtE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,SAAS,CAAQ,KAAK,CAAC,CAAA;QAC9D,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,YAAY,GAAqE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Donut, DonutConfigInterface } from '@unovis/ts';
3
- export declare type VisDonutRef<Datum> = {
4
- component: Donut<Datum>;
5
- };
6
- export declare type VisDonutProps<Datum> = DonutConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisDonutRef<Datum>>;
9
- };
10
- export declare const VisDonut: (<Datum>(props: VisDonutProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Donut, DonutConfigInterface } from '@unovis/ts';
3
+ export declare type VisDonutRef<Datum> = {
4
+ component?: Donut<Datum>;
5
+ };
6
+ export declare type VisDonutProps<Datum> = DonutConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisDonutRef<Datum>>;
9
+ };
10
+ export declare const VisDonut: (<Datum>(props: VisDonutProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Donut } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisDonutFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Donut(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Donut(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-component", { ref: ref });
21
23
  }
22
24
  const VisDonut = React.memo(React.forwardRef(VisDonutFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/donut/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Donut, DonutConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisDonutRef<Datum> = {\n component: Donut<Datum>;\n}\n\nexport type VisDonutProps<Datum> = DonutConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisDonutRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisDonutFC<Datum> (props: VisDonutProps<Datum>, fRef: ForwardedRef<VisDonutRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Donut<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Donut<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Donut(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Donut<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Donut<Datum>>).__component__ }))\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisDonut: (<Datum>(props: VisDonutProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisDonutFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAS,KAA2B,EAAE,IAAsC,EAAA;AAC7F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAA;IAG3D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA6C,CAAA;AAClE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;KAEzC,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAA6C,CAAC,aAAa,CAAA;QAClF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAA6C,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AAClH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAAiE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/donut/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Donut, DonutConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisDonutRef<Datum> = {\n component?: Donut<Datum>;\n}\n\nexport type VisDonutProps<Datum> = DonutConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisDonutRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisDonutFC<Datum> (props: VisDonutProps<Datum>, fRef: ForwardedRef<VisDonutRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<Donut<Datum>>>(null)\n const [component, setComponent] = useState<Donut<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Donut<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Donut<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisDonut: (<Datum>(props: VisDonutProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisDonutFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAS,KAA2B,EAAE,IAAsC,EAAA;AAC7F,IAAA,MAAM,GAAG,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAA;IAC3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAgB,CAAA;IAG1D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA6C,CAAA;AAKlE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,KAAK,CAAQ,KAAK,CAAC,CAAA;QAC1D,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAAiE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { FreeBrush, FreeBrushConfigInterface } from '@unovis/ts';
3
- export declare type VisFreeBrushRef<Datum> = {
4
- component: FreeBrush<Datum>;
5
- };
6
- export declare type VisFreeBrushProps<Datum> = FreeBrushConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisFreeBrushRef<Datum>>;
9
- };
10
- export declare const VisFreeBrush: (<Datum>(props: VisFreeBrushProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { FreeBrush, FreeBrushConfigInterface } from '@unovis/ts';
3
+ export declare type VisFreeBrushRef<Datum> = {
4
+ component?: FreeBrush<Datum>;
5
+ };
6
+ export declare type VisFreeBrushProps<Datum> = FreeBrushConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisFreeBrushRef<Datum>>;
9
+ };
10
+ export declare const VisFreeBrush: (<Datum>(props: VisFreeBrushProps<Datum>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { FreeBrush } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisFreeBrushFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new FreeBrush(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new FreeBrush(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-component", { ref: ref });
21
23
  }
22
24
  const VisFreeBrush = React.memo(React.forwardRef(VisFreeBrushFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/free-brush/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { FreeBrush, FreeBrushConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisFreeBrushRef<Datum> = {\n component: FreeBrush<Datum>;\n}\n\nexport type VisFreeBrushProps<Datum> = FreeBrushConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisFreeBrushRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisFreeBrushFC<Datum> (props: VisFreeBrushProps<Datum>, fRef: ForwardedRef<VisFreeBrushRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<FreeBrush<Datum>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<FreeBrush<Datum>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new FreeBrush(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<FreeBrush<Datum>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<FreeBrush<Datum>>).__component__ }))\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisFreeBrush: (<Datum>(props: VisFreeBrushProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisFreeBrushFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,cAAc,CAAS,KAA+B,EAAE,IAA0C,EAAA;AACzG,IAAA,MAAM,GAAG,GAAG,MAAM,CAAwC,IAAI,CAAC,CAAA;IAG/D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAAiD,CAAA;AACtE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAA;KAE7C,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAAiD,CAAC,aAAa,CAAA;QACtF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAAiD,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AACtH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,YAAY,GAAqE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/free-brush/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { FreeBrush, FreeBrushConfigInterface } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisFreeBrushRef<Datum> = {\n component?: FreeBrush<Datum>;\n}\n\nexport type VisFreeBrushProps<Datum> = FreeBrushConfigInterface<Datum> & {\n data?: Datum[];\n ref?: Ref<VisFreeBrushRef<Datum>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisFreeBrushFC<Datum> (props: VisFreeBrushProps<Datum>, fRef: ForwardedRef<VisFreeBrushRef<Datum>>): JSX.Element {\n const ref = useRef<VisComponentElement<FreeBrush<Datum>>>(null)\n const [component, setComponent] = useState<FreeBrush<Datum>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<FreeBrush<Datum>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new FreeBrush<Datum>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisFreeBrush: (<Datum>(props: VisFreeBrushProps<Datum>) => JSX.Element | null) = React.memo(React.forwardRef(VisFreeBrushFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,cAAc,CAAS,KAA+B,EAAE,IAA0C,EAAA;AACzG,IAAA,MAAM,GAAG,GAAG,MAAM,CAAwC,IAAI,CAAC,CAAA;IAC/D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAoB,CAAA;IAG9D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAAiD,CAAA;AAKtE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,SAAS,CAAQ,KAAK,CAAC,CAAA;QAC9D,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,YAAY,GAAqE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { Graph, GraphConfigInterface, GraphInputNode, GraphInputLink } from '@unovis/ts';
3
- export declare type VisGraphRef<N extends GraphInputNode, L extends GraphInputLink> = {
4
- component: Graph<N, L>;
5
- };
6
- export declare type VisGraphProps<N extends GraphInputNode, L extends GraphInputLink> = GraphConfigInterface<N, L> & {
7
- data?: any;
8
- ref?: Ref<VisGraphRef<N, L>>;
9
- };
10
- export declare const VisGraph: (<N extends GraphInputNode, L extends GraphInputLink>(props: VisGraphProps<N, L>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { Graph, GraphConfigInterface, GraphInputNode, GraphInputLink } from '@unovis/ts';
3
+ export declare type VisGraphRef<N extends GraphInputNode, L extends GraphInputLink> = {
4
+ component?: Graph<N, L>;
5
+ };
6
+ export declare type VisGraphProps<N extends GraphInputNode, L extends GraphInputLink> = GraphConfigInterface<N, L> & {
7
+ data?: any;
8
+ ref?: Ref<VisGraphRef<N, L>>;
9
+ };
10
+ export declare const VisGraph: (<N extends GraphInputNode, L extends GraphInputLink>(props: VisGraphProps<N, L>) => JSX.Element | null);
@@ -1,22 +1,24 @@
1
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
1
+ import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
2
2
  import { Graph } from '@unovis/ts';
3
3
  import { arePropsEqual } from '../../utils/react.js';
4
4
 
5
5
  function VisGraphFC(props, fRef) {
6
6
  const ref = useRef(null);
7
+ const [component, setComponent] = useState();
7
8
  useEffect(() => {
8
- var _a;
9
9
  const element = ref.current;
10
- (_a = element.__component__) === null || _a === void 0 ? void 0 : _a.destroy();
11
- element.__component__ = new Graph(props);
10
+ const hasAlreadyBeenInitialized = element.__component__;
11
+ const c = element.__component__ || new Graph(props);
12
+ setComponent(c);
13
+ element.__component__ = c;
14
+ return () => hasAlreadyBeenInitialized && c.destroy();
12
15
  }, []);
13
16
  useEffect(() => {
14
- const component = ref.current.__component__;
15
17
  if (props.data)
16
18
  component === null || component === void 0 ? void 0 : component.setData(props.data);
17
19
  component === null || component === void 0 ? void 0 : component.setConfig(props);
18
20
  });
19
- useImperativeHandle(fRef, () => ({ component: ref.current.__component__ }));
21
+ useImperativeHandle(fRef, () => ({ component }), [component]);
20
22
  return React.createElement("vis-component", { ref: ref });
21
23
  }
22
24
  const VisGraph = React.memo(React.forwardRef(VisGraphFC), arePropsEqual);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/graph/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef } from 'react'\nimport { Graph, GraphConfigInterface, GraphInputNode, GraphInputLink } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisGraphRef<N extends GraphInputNode, L extends GraphInputLink> = {\n component: Graph<N, L>;\n}\n\nexport type VisGraphProps<N extends GraphInputNode, L extends GraphInputLink> = GraphConfigInterface<N, L> & {\n data?: any;\n ref?: Ref<VisGraphRef<N, L>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisGraphFC<N extends GraphInputNode, L extends GraphInputLink> (props: VisGraphProps<N, L>, fRef: ForwardedRef<VisGraphRef<N, L>>): JSX.Element {\n const ref = useRef<VisComponentElement<Graph<N, L>>>(null)\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Graph<N, L>>)\n element.__component__?.destroy() // Destroy component if exists already (to comply with React 18 strict mode, which renders components twice in dev mode)\n element.__component__ = new Graph(props)\n // We don't have a clean up function because the component will be destroyed by its container (e.g. XYContainer or SingleContainer)\n }, [])\n\n // On Props Update\n useEffect(() => {\n const component = (ref.current as VisComponentElement<Graph<N, L>>).__component__\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component: (ref.current as VisComponentElement<Graph<N, L>>).__component__ }))\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisGraph: (<N extends GraphInputNode, L extends GraphInputLink>(props: VisGraphProps<N, L>) => JSX.Element | null) = React.memo(React.forwardRef(VisGraphFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAsD,KAA0B,EAAE,IAAqC,EAAA;AACxI,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAG1D,SAAS,CAAC,MAAK;;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AACjE,QAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAa,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,aAAa,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;KAEzC,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,SAAS,GAAI,GAAG,CAAC,OAA4C,CAAC,aAAa,CAAA;QACjF,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAG,GAAG,CAAC,OAA4C,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AACjH,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAA6G,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/graph/index.tsx"],"sourcesContent":["// !!! This code was automatically generated. You should not change it !!!\nimport React, { ForwardedRef, Ref, useImperativeHandle, useEffect, useRef, useState } from 'react'\nimport { Graph, GraphConfigInterface, GraphInputNode, GraphInputLink } from '@unovis/ts'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisGraphRef<N extends GraphInputNode, L extends GraphInputLink> = {\n component?: Graph<N, L>;\n}\n\nexport type VisGraphProps<N extends GraphInputNode, L extends GraphInputLink> = GraphConfigInterface<N, L> & {\n data?: any;\n ref?: Ref<VisGraphRef<N, L>>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisGraphFC<N extends GraphInputNode, L extends GraphInputLink> (props: VisGraphProps<N, L>, fRef: ForwardedRef<VisGraphRef<N, L>>): JSX.Element {\n const ref = useRef<VisComponentElement<Graph<N, L>>>(null)\n const [component, setComponent] = useState<Graph<N, L>>()\n\n // On Mount\n useEffect(() => {\n const element = (ref.current as VisComponentElement<Graph<N, L>>)\n\n // React 18 in Strict Mode renders components twice. At the same time, a Container that contains this component\n // (e.g. XYContainer) will be updated only after the first render. So we need to make sure that the component will\n // be initialized only once and won't get destroyed after the first render\n const hasAlreadyBeenInitialized = element.__component__\n const c = element.__component__ || new Graph<N, L>(props)\n setComponent(c)\n element.__component__ = c\n\n return () => hasAlreadyBeenInitialized && c.destroy()\n }, [])\n\n // On Props Update\n useEffect(() => {\n if (props.data) component?.setData(props.data)\n component?.setConfig(props)\n })\n\n useImperativeHandle(fRef, () => ({ component }), [component])\n return <vis-component ref={ref} />\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisGraph: (<N extends GraphInputNode, L extends GraphInputLink>(props: VisGraphProps<N, L>) => JSX.Element | null) = React.memo(React.forwardRef(VisGraphFC), arePropsEqual)\n"],"names":[],"mappings":";;;;AAoBA,SAAS,UAAU,CAAsD,KAA0B,EAAE,IAAqC,EAAA;AACxI,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAe,CAAA;IAGzD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAI,GAAG,CAAC,OAA4C,CAAA;AAKjE,QAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAA;QACvD,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,KAAK,CAAO,KAAK,CAAC,CAAA;QACzD,YAAY,CAAC,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QAEzB,OAAO,MAAM,yBAAyB,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;KACtD,EAAE,EAAE,CAAC,CAAA;IAGN,SAAS,CAAC,MAAK;QACb,IAAI,KAAK,CAAC,IAAI;YAAE,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9C,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,SAAS,CAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,KAAC,CAAC,CAAA;AAEF,IAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,IAAA,OAAO,KAAe,CAAA,aAAA,CAAA,eAAA,EAAA,EAAA,GAAG,EAAE,GAAG,GAAI,CAAA;AACpC,CAAC;AAIY,MAAA,QAAQ,GAA6G,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa;;;;"}
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
2
- import { GroupedBar, GroupedBarConfigInterface } from '@unovis/ts';
3
- export declare type VisGroupedBarRef<Datum> = {
4
- component: GroupedBar<Datum>;
5
- };
6
- export declare type VisGroupedBarProps<Datum> = GroupedBarConfigInterface<Datum> & {
7
- data?: Datum[];
8
- ref?: Ref<VisGroupedBarRef<Datum>>;
9
- };
10
- export declare const VisGroupedBar: (<Datum>(props: VisGroupedBarProps<Datum>) => JSX.Element | null);
1
+ import { Ref } from 'react';
2
+ import { GroupedBar, GroupedBarConfigInterface } from '@unovis/ts';
3
+ export declare type VisGroupedBarRef<Datum> = {
4
+ component?: GroupedBar<Datum>;
5
+ };
6
+ export declare type VisGroupedBarProps<Datum> = GroupedBarConfigInterface<Datum> & {
7
+ data?: Datum[];
8
+ ref?: Ref<VisGroupedBarRef<Datum>>;
9
+ };
10
+ export declare const VisGroupedBar: (<Datum>(props: VisGroupedBarProps<Datum>) => JSX.Element | null);