@gravity-ui/chartkit 3.0.0-beta.1 → 3.0.0-beta.11

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 (86) hide show
  1. package/build/components/ChartKit.css +19 -19
  2. package/build/components/ChartKit.d.ts +6 -4
  3. package/build/components/ChartKit.js +2 -2
  4. package/build/components/ErrorBoundary/ErrorBoundary.d.ts +2 -2
  5. package/build/components/Loader/Loader.d.ts +3 -3
  6. package/build/i18n/index.d.ts +2 -2
  7. package/build/libs/chartkit-error/chartkit-error.d.ts +1 -1
  8. package/build/libs/settings/__tests__/settings.test.js +2 -9
  9. package/build/libs/settings/eventEmitter.d.ts +11 -0
  10. package/build/libs/settings/eventEmitter.js +25 -0
  11. package/build/libs/settings/settings.d.ts +7 -4
  12. package/build/libs/settings/settings.js +8 -13
  13. package/build/plugins/highcharts/__stories__/Line.stories.d.ts +2 -3
  14. package/build/plugins/highcharts/__stories__/Pie.stories.d.ts +2 -3
  15. package/build/plugins/highcharts/__stories__/area/Range.stories.d.ts +2 -3
  16. package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +2 -3
  17. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +2 -3
  18. package/build/plugins/highcharts/__stories__/column/Vertical.stories.d.ts +2 -3
  19. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.d.ts +2 -3
  20. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.d.ts +2 -3
  21. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.d.ts +2 -3
  22. package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +1 -1
  23. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.d.ts +2 -3
  24. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.d.ts +2 -3
  25. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.d.ts +2 -3
  26. package/build/plugins/highcharts/mocks/complex.js +1 -1
  27. package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +3 -1
  28. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +3 -3
  29. package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +6 -0
  30. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +1 -1
  31. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.d.ts +3 -3
  32. package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.js +2 -5
  33. package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +0 -1
  34. package/build/plugins/highcharts/renderer/helpers/config/config.js +14 -14
  35. package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
  36. package/build/plugins/highcharts/renderer/helpers/config/types.d.ts +2 -2
  37. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.d.ts +1 -1
  38. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.d.ts +1 -1
  39. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.d.ts +1 -1
  40. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.d.ts +1 -1
  41. package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +33 -0
  42. package/build/plugins/highcharts/renderer/helpers/config/utils/index.js +8 -0
  43. package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.d.ts +1 -1
  44. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.d.ts +1 -1
  45. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.d.ts +2 -2
  46. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.js +2 -2
  47. package/build/plugins/highcharts/renderer/helpers/graph.css +4 -4
  48. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +1 -1
  49. package/build/plugins/highcharts/renderer/helpers/graph.js +2 -2
  50. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.d.ts +1 -0
  51. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +5 -2
  52. package/build/plugins/highcharts/renderer/helpers/prepare-data.js +3 -3
  53. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.d.ts +0 -2
  54. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.js +0 -9
  55. package/build/plugins/highcharts/renderer/helpers/tooltip/index.d.ts +1 -1
  56. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +4 -5
  57. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.d.ts +1 -1
  58. package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +5 -5
  59. package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +3 -12
  60. package/build/plugins/highcharts/renderer/helpers/types.d.ts +2 -2
  61. package/build/plugins/highcharts/types/comments.d.ts +1 -1
  62. package/build/plugins/highcharts/types/misc.d.ts +4 -4
  63. package/build/plugins/highcharts/types/widget.d.ts +13 -5
  64. package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +2 -2
  65. package/build/plugins/indicator/renderer/IndicatorItem.d.ts +2 -2
  66. package/build/plugins/indicator/renderer/IndicatorWidget.css +1 -1
  67. package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +3 -1
  68. package/build/plugins/indicator/types.d.ts +2 -2
  69. package/build/plugins/shared/format-number/i18n/i18n.d.ts +1 -1
  70. package/build/plugins/shared/format-number/types.d.ts +2 -2
  71. package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +3 -4
  72. package/build/plugins/yagr/__stories__/Yagr.stories.js +3 -1
  73. package/build/plugins/yagr/renderer/YagrWidget.css +1 -1
  74. package/build/plugins/yagr/renderer/YagrWidget.d.ts +4 -1
  75. package/build/plugins/yagr/renderer/YagrWidget.js +13 -12
  76. package/build/plugins/yagr/renderer/tooltip/renderTooltip.js +2 -2
  77. package/build/plugins/yagr/renderer/tooltip/tooltip.css +14 -14
  78. package/build/plugins/yagr/renderer/tooltip/types.d.ts +4 -4
  79. package/build/plugins/yagr/renderer/utils.d.ts +1 -1
  80. package/build/plugins/yagr/renderer/utils.js +3 -3
  81. package/build/plugins/yagr/types.d.ts +2 -1
  82. package/build/types/index.d.ts +22 -22
  83. package/build/types/misc.d.ts +1 -1
  84. package/build/types/widget.d.ts +5 -1
  85. package/package.json +16 -11
  86. package/CHANGELOG.md +0 -489
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import isEmpty from 'lodash/isEmpty';
3
+ import { useForkRef } from '@gravity-ui/uikit';
3
4
  import YagrComponent from '@gravity-ui/yagr/dist/react';
4
5
  import { i18n } from '../../../i18n';
5
6
  import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../libs';
@@ -9,8 +10,9 @@ import './polyfills';
9
10
  import '@gravity-ui/yagr/dist/index.css';
10
11
  import './YagrWidget.css';
11
12
  const YagrWidget = React.forwardRef((props, forwardedRef) => {
12
- const { id, data: { data }, onLoad, onRender, onChartLoad, } = props;
13
+ const { id, data: { data }, pluginRef, onLoad, onRender, onChartLoad, } = props;
13
14
  const yagrRef = React.useRef(null);
15
+ const handleRef = useForkRef(pluginRef, yagrRef);
14
16
  if (!data || isEmpty(data)) {
15
17
  throw new ChartKitError({
16
18
  code: CHARTKIT_ERROR_CODE.NO_DATA,
@@ -21,18 +23,14 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
21
23
  const handleChartLoading = React.useCallback((chart, { renderTime }) => {
22
24
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(Object.assign(Object.assign({}, data), { widget: chart, widgetRendering: renderTime }));
23
25
  onRender === null || onRender === void 0 ? void 0 : onRender({ renderTime });
24
- }, [onLoad, data]);
26
+ }, [onLoad, onRender, data]);
25
27
  const onWindowResize = React.useCallback(() => {
26
28
  if (yagrRef.current) {
27
29
  const chart = yagrRef.current.yagr();
28
30
  if (!chart) {
29
31
  return;
30
32
  }
31
- const root = chart.root;
32
- const height = root.offsetHeight;
33
- const width = root.offsetWidth;
34
- chart.uplot.setSize({ width, height });
35
- chart.uplot.redraw();
33
+ chart.reflow();
36
34
  }
37
35
  }, []);
38
36
  React.useImperativeHandle(forwardedRef, () => ({
@@ -41,25 +39,28 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
41
39
  },
42
40
  }), [onWindowResize]);
43
41
  React.useEffect(() => {
44
- var _a, _b, _c, _d;
42
+ var _a, _b, _c, _d, _e, _f;
45
43
  const yagr = (_a = yagrRef.current) === null || _a === void 0 ? void 0 : _a.yagr();
46
44
  if (!yagr) {
47
45
  return;
48
46
  }
47
+ if ((_c = (_b = yagr.config) === null || _b === void 0 ? void 0 : _b.tooltip) === null || _c === void 0 ? void 0 : _c.virtual) {
48
+ return;
49
+ }
49
50
  const handlers = {
50
51
  mouseMove: null,
51
52
  mouseDown: null,
52
53
  };
53
- (_b = yagr.plugins.tooltip) === null || _b === void 0 ? void 0 : _b.on('render', (tooltip) => {
54
+ (_d = yagr.plugins.tooltip) === null || _d === void 0 ? void 0 : _d.on('render', (tooltip) => {
54
55
  synchronizeTooltipTablesCellsWidth(tooltip);
55
56
  });
56
- (_c = yagr.plugins.tooltip) === null || _c === void 0 ? void 0 : _c.on('pin', (tooltip, { actions }) => {
57
+ (_e = yagr.plugins.tooltip) === null || _e === void 0 ? void 0 : _e.on('pin', (tooltip, { actions }) => {
57
58
  handlers.mouseMove = checkFocus({ tooltip, yagr });
58
59
  handlers.mouseDown = detectClickOutside({ tooltip, actions, yagr });
59
60
  document.addEventListener('mousemove', handlers.mouseMove);
60
61
  document.addEventListener('mousedown', handlers.mouseDown);
61
62
  });
62
- (_d = yagr.plugins.tooltip) === null || _d === void 0 ? void 0 : _d.on('unpin', () => {
63
+ (_f = yagr.plugins.tooltip) === null || _f === void 0 ? void 0 : _f.on('unpin', () => {
63
64
  if (handlers.mouseMove) {
64
65
  document.removeEventListener('mousemove', handlers.mouseMove);
65
66
  handlers.mouseMove = null;
@@ -74,6 +75,6 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
74
75
  var _a;
75
76
  onChartLoad === null || onChartLoad === void 0 ? void 0 : onChartLoad({ widget: (_a = yagrRef.current) === null || _a === void 0 ? void 0 : _a.yagr() });
76
77
  }, [yagrRef, onChartLoad]);
77
- return (React.createElement(YagrComponent, { ref: yagrRef, id: id, config: config, debug: debug, onChartLoad: handleChartLoading }));
78
+ return (React.createElement(YagrComponent, { ref: handleRef, id: id, config: config, debug: debug, onChartLoad: handleChartLoading }));
78
79
  });
79
80
  export default YagrWidget;
@@ -1,4 +1,4 @@
1
- import moment from 'moment';
1
+ import { dateTime } from '@gravity-ui/date-utils';
2
2
  import { formatTooltip } from './tooltip';
3
3
  const calcOption = (d) => {
4
4
  return typeof d === 'object' && d !== null
@@ -39,7 +39,7 @@ export const renderTooltip = (data) => {
39
39
  : undefined;
40
40
  const tooltipFormatOptions = {
41
41
  activeRowAlwaysFirstInTooltip: rows.length > 1,
42
- tooltipHeader: moment(x / timeMultiplier).format('DD MMMM YYYY HH:mm:ss'),
42
+ tooltipHeader: dateTime({ input: x / timeMultiplier }).format('DD MMMM YYYY HH:mm:ss'),
43
43
  shared: true,
44
44
  lines: rows.map((row, i) => (Object.assign(Object.assign({}, row), { seriesName: row.name || 'Serie ' + (i + 1), seriesColor: row.color, selectedSeries: row.active, seriesIdx: row.seriesIdx, percentValue: typeof row.transformed === 'number' ? row.transformed.toFixed(1) : '' }))),
45
45
  withPercent: calcOption(opts.percent),
@@ -4,26 +4,26 @@
4
4
  }
5
5
 
6
6
  .chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-header td:last-child {
7
- padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
7
+ padding-right: calc(18px + var(--g-scrollbar-width, 15px));
8
8
  }
9
9
 
10
10
  .chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-footer td:last-child {
11
- padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
11
+ padding-right: calc(18px + var(--g-scrollbar-width, 15px));
12
12
  }
13
13
 
14
14
  .chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-row td:last-child {
15
- padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
15
+ padding-right: calc(18px + var(--g-scrollbar-width, 15px));
16
16
  }
17
17
 
18
18
  .chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-rows__summ-tr td:last-child {
19
- padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
19
+ padding-right: calc(18px + var(--g-scrollbar-width, 15px));
20
20
  }
21
21
 
22
22
  ._tooltip {
23
23
  border-radius: 5px;
24
- background: var(--yc-color-infographics-tooltip-bg);
25
- background-color: var(--yc-color-infographics-tooltip-bg);
26
- color: var(--yc-color-text-primary);
24
+ background: var(--g-color-infographics-tooltip-bg);
25
+ background-color: var(--g-color-infographics-tooltip-bg);
26
+ color: var(--g-color-text-primary);
27
27
  font-size: 12px;
28
28
  overflow: hidden;
29
29
  box-sizing: border-box;
@@ -150,7 +150,7 @@
150
150
  ._tooltip-rows__table thead._tooltip-header tr:not(._tooltip-fake-row):first-child td {
151
151
  padding-top: 6px;
152
152
  padding-bottom: 6px;
153
- border-bottom: 1px solid var(--yc-color-line-generic);
153
+ border-bottom: 1px solid var(--g-color-line-generic);
154
154
  }
155
155
 
156
156
  ._tooltip-rows__table tbody {
@@ -169,11 +169,11 @@
169
169
  }
170
170
 
171
171
  ._tooltip-rows__table tbody._tooltip-list ._tooltip-row-dark-bg {
172
- background-color: var(--yc-color-base-generic);
172
+ background-color: var(--g-color-base-generic);
173
173
  }
174
174
 
175
175
  ._tooltip-rows__table tbody ._hidden-rows-sum._hidden-rows-sum-dark-bg {
176
- background-color: var(--yc-color-base-generic);
176
+ background-color: var(--g-color-base-generic);
177
177
  }
178
178
 
179
179
  ._tooltip-rows__table tbody ._hidden-rows-sum td {
@@ -281,9 +281,9 @@
281
281
 
282
282
  ._tooltip-rows__summ-td {
283
283
  padding: 6px 0 6px 3px;
284
- color: var(--yc-color-text-complementary);
284
+ color: var(--g-color-text-complementary);
285
285
  font-size: 12px;
286
- border-top: 1px solid var(--yc-color-line-generic);
286
+ border-top: 1px solid var(--g-color-line-generic);
287
287
  }
288
288
 
289
289
  ._tooltip-rows__summ-td-value {
@@ -308,7 +308,7 @@
308
308
  ._tooltip-right__td {
309
309
  vertical-align: top;
310
310
  opacity: 0.9;
311
- border-left: 1px solid var(--yc-color-line-generic);
311
+ border-left: 1px solid var(--g-color-line-generic);
312
312
  white-space: normal;
313
313
  font-size: 8pt;
314
314
  position: relative;
@@ -348,7 +348,7 @@
348
348
  }
349
349
 
350
350
  ._tooltip-right__traf-div_for-split-tooltip {
351
- color: var(--yc-color-text-secondary);
351
+ color: var(--g-color-text-secondary);
352
352
  padding-left: 8px;
353
353
  border-top: none;
354
354
  border-left: 2px solid;
@@ -1,4 +1,4 @@
1
- export declare type TooltipData = {
1
+ export type TooltipData = {
2
2
  /** Tooltip lines data */
3
3
  lines: Array<TooltipLine>;
4
4
  /** Tooltip comments */
@@ -35,10 +35,10 @@ export declare type TooltipData = {
35
35
  /** Sum of the values of the hidden ("not fit" in the tooltip) rows */
36
36
  hiddenRowsSum?: number | string;
37
37
  };
38
- export declare type TooltipExtraData = {
38
+ export type TooltipExtraData = {
39
39
  lastVisibleRowIndex: number;
40
40
  };
41
- export declare type TooltipLine = {
41
+ export type TooltipLine = {
42
42
  /** Color displayed in a separate cell */
43
43
  seriesColor: string;
44
44
  /** Series name */
@@ -64,7 +64,7 @@ export declare type TooltipLine = {
64
64
  replaceCellAt?: Record<number, (line: TooltipLine) => string>;
65
65
  insertCellAt?: Record<number, (line: TooltipLine) => string>;
66
66
  };
67
- export declare type RowRenderingConfig = {
67
+ export type RowRenderingConfig = {
68
68
  cellsRenderers: Array<(line: TooltipLine) => string>;
69
69
  isSelectedLine?: boolean;
70
70
  allowComment?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { Yagr, YagrWidgetData, YagrTheme, MinimalValidConfig } from '../types';
2
- declare type ShapeYagrConfigArgs = {
2
+ type ShapeYagrConfigArgs = {
3
3
  data: YagrWidgetData['data'];
4
4
  libraryConfig: YagrWidgetData['libraryConfig'];
5
5
  theme: YagrTheme;
@@ -1,5 +1,5 @@
1
- import moment from 'moment';
2
1
  import merge from 'lodash/merge';
2
+ import { dateTime } from '@gravity-ui/date-utils';
3
3
  import { defaults } from '@gravity-ui/yagr';
4
4
  import { settings } from '../../../libs';
5
5
  import { renderTooltip } from './tooltip';
@@ -75,8 +75,8 @@ export const detectClickOutside = (args) => (event) => {
75
75
  const getXAxisFormatter = (msm = 1) => (_, ticks) => {
76
76
  const range = (ticks[ticks.length - 1] - ticks[0]) / msm;
77
77
  return ticks.map((rawValue) => {
78
- const d = moment(rawValue / msm);
79
- if (d.hour() === 0 && d.minutes() === 0 && d.seconds() === 0) {
78
+ const d = dateTime({ input: rawValue / msm });
79
+ if (d.hour() === 0 && d.minute() === 0 && d.second() === 0) {
80
80
  return d.format('DD.MM.YY');
81
81
  }
82
82
  return d.format(range < 300 ? 'HH:mm:ss' : 'HH:mm');
@@ -1,7 +1,8 @@
1
1
  import type { RawSerieData, YagrConfig } from '@gravity-ui/yagr';
2
2
  export type { default as Yagr } from '@gravity-ui/yagr';
3
+ export type { YagrReactRef } from '@gravity-ui/yagr/dist/react';
3
4
  export * from '@gravity-ui/yagr/dist/types';
4
- export declare type YagrWidgetData = {
5
+ export type YagrWidgetData = {
5
6
  data: {
6
7
  graphs: RawSerieData[];
7
8
  timeline: number[];
@@ -2,56 +2,56 @@ import React from 'react';
2
2
  import type { ChartKitWidget } from './widget';
3
3
  import { ChartKitError } from '../libs';
4
4
  export type { ChartKitHolidays } from './misc';
5
- export declare type ChartKitLang = 'ru' | 'en';
6
- export declare type ChartKitType = keyof ChartKitWidget;
7
- export declare type ChartKitRef = {
5
+ export type ChartKitLang = 'ru' | 'en';
6
+ export type ChartKitType = keyof ChartKitWidget;
7
+ export type ChartKitRef = {
8
8
  reflow: (details?: unknown) => void;
9
9
  };
10
- export declare type ChartKitWidgetRef = {
10
+ export type ChartKitWidgetRef = {
11
11
  reflow?: ChartKitRef['reflow'];
12
12
  };
13
- export declare type ChartKitOnLoadData<T extends ChartKitType> = {
13
+ export type ChartKitOnLoadData<T extends ChartKitType> = {
14
14
  widget?: ChartKitWidget[T]['widget'];
15
15
  widgetRendering?: number;
16
16
  };
17
- export declare type ChartKitOnRenderData = {
17
+ export type ChartKitOnRenderData = {
18
18
  renderTime?: number;
19
19
  };
20
- export declare type ChartKitOnChartLoad<T extends ChartKitType> = {
20
+ export type ChartKitOnChartLoad<T extends ChartKitType> = {
21
21
  widget?: ChartKitWidget[T]['widget'] | null;
22
22
  };
23
- export declare type ChartKitOnError = (data: {
23
+ export type ChartKitOnError = (data: {
24
24
  error: any;
25
25
  }) => void;
26
- export declare type ChartKitProps<T extends ChartKitType> = {
26
+ export type ChartKitProps<T extends ChartKitType> = {
27
27
  type: T;
28
28
  data: ChartKitWidget[T]['data'];
29
+ /** Plugin component's react ref */
30
+ pluginRef?: ChartKitWidget[T]['pluginRef'];
29
31
  id?: string;
30
32
  isMobile?: boolean;
31
33
  onLoad?: (data?: ChartKitOnLoadData<T>) => void;
32
- /**
33
- * called on each render
34
- * @param data
35
- */
34
+ /** Fires on each chartkit plugin's component render */
36
35
  onRender?: (data: ChartKitOnRenderData) => void;
37
- /**
38
- * called on chart mount
39
- * @param data
40
- */
36
+ /** Fires on chartkit plugin's component mount */
41
37
  onChartLoad?: (data: ChartKitOnChartLoad<T>) => void;
42
- renderError?: RenderError;
38
+ /** Fires in case of unhandled plugin's exception */
43
39
  onError?: ChartKitOnError;
40
+ /** Used to render user's error component */
41
+ renderError?: RenderError;
42
+ /** Used to render user's plugin loader component */
43
+ renderPluginLoader?: () => React.ReactNode;
44
44
  } & {
45
- [key in keyof Omit<ChartKitWidget[T], 'data' | 'widget'>]: ChartKitWidget[T][key];
45
+ [key in keyof Omit<ChartKitWidget[T], 'data' | 'widget' | 'pluginRef'>]: ChartKitWidget[T][key];
46
46
  };
47
- export declare type ChartKitPlugin = {
47
+ export type ChartKitPlugin = {
48
48
  type: ChartKitType;
49
49
  renderer: React.LazyExoticComponent<any>;
50
50
  };
51
- export declare type RenderErrorOpts = {
51
+ export type RenderErrorOpts = {
52
52
  message: string;
53
53
  error: ChartKitError | Error;
54
54
  resetError: () => void;
55
55
  };
56
- export declare type RenderError = (opts: RenderErrorOpts) => React.ReactNode;
56
+ export type RenderError = (opts: RenderErrorOpts) => React.ReactNode;
57
57
  export type { ChartKitWidget };
@@ -1,4 +1,4 @@
1
- export declare type ChartKitHolidays = {
1
+ export type ChartKitHolidays = {
2
2
  holiday: Record<string, Record<string, string>>;
3
3
  weekend: Record<string, Record<string, string>>;
4
4
  };
@@ -1,19 +1,23 @@
1
- import type { Yagr, YagrWidgetData } from '../plugins/yagr/types';
1
+ /// <reference types="react" />
2
+ import type { Yagr, YagrReactRef, YagrWidgetData } from '../plugins/yagr/types';
2
3
  import type { IndicatorWidgetData } from '../plugins/indicator/types';
3
4
  import type { Highcharts, HighchartsWidgetData, StringParams } from '../plugins/highcharts/types';
4
5
  export interface ChartKitWidget {
5
6
  yagr: {
6
7
  data: YagrWidgetData;
7
8
  widget: Yagr;
9
+ pluginRef: React.MutableRefObject<YagrReactRef | null>;
8
10
  };
9
11
  indicator: {
10
12
  data: IndicatorWidgetData;
11
13
  widget: never;
14
+ pluginRef: never;
12
15
  formatNumber?: <T = any>(value: number, options?: T) => string;
13
16
  };
14
17
  highcharts: {
15
18
  data: HighchartsWidgetData;
16
19
  widget: Highcharts.Chart | null;
20
+ pluginRef: never;
17
21
  hoistConfigError?: boolean;
18
22
  nonBodyScroll?: boolean;
19
23
  splitTooltip?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.11",
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",
@@ -13,7 +13,8 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@gravity-ui/yagr": "^3.3.0",
16
+ "@gravity-ui/date-utils": "^1.4.1",
17
+ "@gravity-ui/yagr": "^3.4.0",
17
18
  "bem-cn-lite": "^4.1.0",
18
19
  "highcharts": "^8.2.2",
19
20
  "highcharts-react-official": "^3.0.0",
@@ -21,16 +22,21 @@
21
22
  "react-split-pane": "^0.1.92"
22
23
  },
23
24
  "devDependencies": {
25
+ "@babel/preset-env": "^7.22.6",
26
+ "@babel/preset-react": "^7.22.5",
27
+ "@babel/preset-typescript": "^7.22.5",
24
28
  "@gravity-ui/eslint-config": "^1.0.2",
25
29
  "@gravity-ui/i18n": "^1.0.0",
26
30
  "@gravity-ui/prettier-config": "^1.0.1",
27
31
  "@gravity-ui/stylelint-config": "^1.0.1",
28
32
  "@gravity-ui/tsconfig": "^1.0.0",
29
- "@gravity-ui/uikit": "^4.2.0",
30
- "@storybook/addon-essentials": "^6.5.9",
31
- "@storybook/addon-knobs": "^6.4.0",
33
+ "@gravity-ui/uikit": "^5.0.0-beta.1",
34
+ "@storybook/addon-essentials": "^7.0.26",
35
+ "@storybook/addon-knobs": "^7.0.2",
36
+ "@storybook/cli": "^7.0.26",
32
37
  "@storybook/preset-scss": "^1.0.3",
33
- "@storybook/react": "^6.5.9",
38
+ "@storybook/react": "^7.0.26",
39
+ "@storybook/react-webpack5": "^7.0.26",
34
40
  "@types/jest": "^28.1.3",
35
41
  "@types/lodash": "^4.14.177",
36
42
  "@types/node": "^18.0.0",
@@ -49,7 +55,6 @@
49
55
  "jest": "^28.1.3",
50
56
  "jest-environment-jsdom": "^28.1.2",
51
57
  "lint-staged": "^10.2.7",
52
- "moment": "^2.29.4",
53
58
  "npm-run-all": "^4.1.5",
54
59
  "prettier": "^2.6.0",
55
60
  "react": "^17.0.2",
@@ -58,22 +63,22 @@
58
63
  "rimraf": "^3.0.2",
59
64
  "sass": "^1.56.2",
60
65
  "sass-loader": "^10.2.1",
66
+ "storybook": "^7.0.26",
61
67
  "style-loader": "^2.0.0",
62
68
  "stylelint": "^14.6.0",
63
69
  "ts-jest": "^28.0.5",
64
70
  "ts-node": "^10.2.1",
65
- "typescript": "^4.2.3"
71
+ "typescript": "^4.9.5"
66
72
  },
67
73
  "peerDependencies": {
68
- "@gravity-ui/uikit": "^4.0.0",
69
- "moment": "^2.19.3",
74
+ "@gravity-ui/uikit": "^5.0.0-beta.1",
70
75
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
71
76
  },
72
77
  "scripts": {
73
78
  "test": "jest",
74
79
  "test:watch": "jest --watchAll",
75
80
  "clean": "gulp clean",
76
- "start": "cross-env TS_NODE_PROJECT=.storybook/tsconfig.json start-storybook -p 7007",
81
+ "start": "storybook dev -p 7007",
77
82
  "build": "gulp",
78
83
  "lint:js": "eslint --quiet --ext .js,.jsx,.ts,.tsx .",
79
84
  "lint:styles": "stylelint '{styles,src}/**/*.scss' --quiet",