@gravity-ui/chartkit 5.22.3 → 5.23.0

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.
@@ -30,6 +30,12 @@ const ChartKitComponent = (props) => {
30
30
  widgetRef.current.reflow(details);
31
31
  }
32
32
  },
33
+ yagrSubscribe() {
34
+ var _a;
35
+ if ((_a = widgetRef.current) === null || _a === void 0 ? void 0 : _a.yagrSubscribe) {
36
+ widgetRef.current.yagrSubscribe();
37
+ }
38
+ },
33
39
  }), []);
34
40
  return (React.createElement(React.Suspense, { fallback: React.createElement(Loader, { renderPluginLoader: renderPluginLoader }) },
35
41
  React.createElement("div", { className: b({ mobile: isMobile }, 'chartkit-theme_common') },
@@ -26,7 +26,9 @@ export class ErrorBoundary extends React.Component {
26
26
  componentDidUpdate(prevProps) {
27
27
  if (prevProps.data !== this.props.data) {
28
28
  const { error } = this.state;
29
- if (error && 'code' in error && error.code === CHARTKIT_ERROR_CODE.NO_DATA) {
29
+ if (error &&
30
+ 'code' in error &&
31
+ [CHARTKIT_ERROR_CODE.NO_DATA, CHARTKIT_ERROR_CODE.INVALID_DATA].includes(String(error.code))) {
30
32
  this.resetError();
31
33
  }
32
34
  }
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { ChartKitWidgetRef } from '../../../types';
3
2
  declare const D3Widget: React.ForwardRefExoticComponent<{
4
3
  type: "d3";
5
4
  data: import("@gravity-ui/charts").ChartData<any>;
@@ -15,5 +14,5 @@ declare const D3Widget: React.ForwardRefExoticComponent<{
15
14
  tooltip?: {
16
15
  splitted?: boolean | undefined;
17
16
  } | undefined;
18
- } & React.RefAttributes<ChartKitWidgetRef | undefined>>;
17
+ } & React.RefAttributes<Partial<import("../../../types").ChartKitRef> | undefined>>;
19
18
  export default D3Widget;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { ChartKitWidgetRef } from '../../../types';
3
2
  declare const HighchartsWidget: React.ForwardRefExoticComponent<{
4
3
  type: "highcharts";
5
4
  data: import("..").HighchartsWidgetData;
@@ -25,5 +24,5 @@ declare const HighchartsWidget: React.ForwardRefExoticComponent<{
25
24
  }, state: {
26
25
  forceUpdate: boolean;
27
26
  }, callExternalOnChange?: boolean | undefined) => void) | undefined;
28
- } & React.RefAttributes<ChartKitWidgetRef | undefined>>;
27
+ } & React.RefAttributes<Partial<import("../../../types").ChartKitRef> | undefined>>;
29
28
  export default HighchartsWidget;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { ChartKitWidgetRef } from '../../../types';
3
2
  import './IndicatorWidget.css';
4
3
  declare const IndicatorWidget: React.ForwardRefExoticComponent<{
5
4
  type: "indicator";
@@ -14,5 +13,5 @@ declare const IndicatorWidget: React.ForwardRefExoticComponent<{
14
13
  renderPluginLoader?: import("../../../types").ChartKitRenderPluginLoader | undefined;
15
14
  } & {
16
15
  formatNumber?: (<T = any>(value: number, options?: T | undefined) => string) | undefined;
17
- } & React.RefAttributes<ChartKitWidgetRef | undefined>>;
16
+ } & React.RefAttributes<Partial<import("../../../types").ChartKitRef> | undefined>>;
18
17
  export default IndicatorWidget;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { ChartKitWidgetRef } from '../../../types';
3
2
  import './polyfills';
4
3
  import '@gravity-ui/yagr/dist/index.css';
5
4
  import './YagrWidget.css';
@@ -18,5 +17,5 @@ declare const YagrWidget: React.ForwardRefExoticComponent<{
18
17
  tooltip?: (<T extends import("../types").CustomTooltipProps = import("../types").CustomTooltipProps>(props: T) => React.ReactNode) | undefined;
19
18
  } & {
20
19
  id: string;
21
- } & React.RefAttributes<ChartKitWidgetRef | undefined>>;
20
+ } & React.RefAttributes<Partial<import("../../../types").ChartKitRef> | undefined>>;
22
21
  export default YagrWidget;
@@ -35,6 +35,13 @@ const YagrWidget = React.forwardRef(function YagrWidget(props, forwardedRef) {
35
35
  reflow() {
36
36
  onWindowResize();
37
37
  },
38
+ yagrSubscribe() {
39
+ var _a;
40
+ const impl = (_a = yagrRef.current) === null || _a === void 0 ? void 0 : _a.yagr();
41
+ if (impl) {
42
+ impl.subscribe();
43
+ }
44
+ },
38
45
  }), [onWindowResize]);
39
46
  React.useEffect(() => {
40
47
  var _a, _b, _c, _d, _e;
@@ -6,10 +6,9 @@ export type ChartKitLang = 'ru' | 'en';
6
6
  export type ChartKitType = keyof ChartKitWidget;
7
7
  export type ChartKitRef = {
8
8
  reflow: (details?: unknown) => void;
9
+ yagrSubscribe: () => void;
9
10
  };
10
- export type ChartKitWidgetRef = {
11
- reflow?: ChartKitRef['reflow'];
12
- };
11
+ export type ChartKitWidgetRef = Partial<ChartKitRef>;
13
12
  export type ChartKitOnLoadData<T extends ChartKitType> = {
14
13
  widget?: ChartKitWidget[T]['widget'];
15
14
  widgetRendering?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "5.22.3",
3
+ "version": "5.23.0",
4
4
  "description": "React component used to render charts based on any sources you need",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:gravity-ui/ChartKit.git",