@gravity-ui/chartkit 3.0.0-beta.5 → 3.0.0-beta.7

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.
@@ -8,6 +8,7 @@ declare const ChartKitComponent: <T extends keyof import("../types").ChartKitWid
8
8
  export declare const ChartKit: <T extends keyof import("../types").ChartKitWidget>(props: {
9
9
  type: T;
10
10
  data: import("../types").ChartKitWidget[T]["data"];
11
+ pluginRef?: import("../types").ChartKitWidget[T]["pluginRef"] | undefined;
11
12
  id?: string | undefined;
12
13
  isMobile?: boolean | undefined;
13
14
  onLoad?: ((data?: import("../types").ChartKitOnLoadData<T> | undefined) => void) | undefined;
@@ -16,7 +17,7 @@ export declare const ChartKit: <T extends keyof import("../types").ChartKitWidge
16
17
  onError?: import("../types").ChartKitOnError | undefined;
17
18
  renderError?: import("../types").RenderError | undefined;
18
19
  renderPluginLoader?: (() => React.ReactNode) | undefined;
19
- } & (Omit<import("../types").ChartKitWidget[T], "widget" | "data"> extends infer T_1 ? { [key in keyof T_1]: import("../types").ChartKitWidget[T][key]; } : never) & {
20
+ } & (Omit<import("../types").ChartKitWidget[T], "widget" | "data" | "pluginRef"> extends infer T_1 ? { [key in keyof T_1]: import("../types").ChartKitWidget[T][key]; } : never) & {
20
21
  ref?: React.ForwardedRef<ChartKitRef | undefined> | undefined;
21
22
  }) => ReturnType<typeof ChartKitComponent>;
22
23
  export {};
@@ -1,13 +1,6 @@
1
- import { DEFAULT_LOCALE_SPECIFICATION, settings } from '../settings';
2
- const resetSettings = () => settings.set({
3
- lang: 'en',
4
- locale: DEFAULT_LOCALE_SPECIFICATION,
5
- });
1
+ import { settings } from '../settings';
2
+ const resetSettings = () => settings.set({ lang: 'en' });
6
3
  describe('libs/settings', () => {
7
- it('Default locale should be equal DEFAULT_LOCALE_SPECIFICATION', () => {
8
- const result = settings.get('locale');
9
- expect(result).toStrictEqual(DEFAULT_LOCALE_SPECIFICATION);
10
- });
11
4
  it('Default lang should be equal to en', () => {
12
5
  const result = settings.get('lang');
13
6
  expect(result).toBe('en');
@@ -0,0 +1,11 @@
1
+ type EventObject<T = unknown> = {
2
+ id: string;
3
+ action: (args: T) => void;
4
+ };
5
+ export declare class EventEmitter<EventsMap = unknown> {
6
+ private events;
7
+ on<MapKey extends keyof EventsMap>(type: MapKey, event: EventObject<EventsMap[MapKey]>): void;
8
+ off<MapKey extends keyof EventsMap>(type: MapKey, eventId: string): void;
9
+ dispatch<MapKey extends keyof EventsMap>(type: MapKey, args: EventsMap[MapKey]): void;
10
+ }
11
+ export {};
@@ -0,0 +1,25 @@
1
+ export class EventEmitter {
2
+ constructor() {
3
+ this.events = {};
4
+ }
5
+ on(type, event) {
6
+ if (this.events[type]) {
7
+ this.events[type].push(event);
8
+ }
9
+ else {
10
+ this.events[type] = [event];
11
+ }
12
+ }
13
+ off(type, eventId) {
14
+ if (this.events[type]) {
15
+ this.events[type] = this.events[type].filter(({ id }) => id !== eventId);
16
+ }
17
+ }
18
+ dispatch(type, args) {
19
+ if (this.events[type]) {
20
+ this.events[type].forEach(({ action }) => {
21
+ action(args);
22
+ });
23
+ }
24
+ }
25
+ }
@@ -1,17 +1,20 @@
1
- import moment from 'moment';
2
1
  import type { ChartKitPlugin, ChartKitLang, ChartKitHolidays } from '../../types';
2
+ import { EventEmitter } from './eventEmitter';
3
3
  interface Settings {
4
4
  plugins: ChartKitPlugin[];
5
5
  lang: ChartKitLang;
6
- locale?: moment.LocaleSpecification;
7
6
  extra?: {
8
7
  holidays?: ChartKitHolidays;
9
8
  };
10
9
  }
11
10
  type SettingKey = keyof Settings;
12
- export declare const DEFAULT_LOCALE_SPECIFICATION: moment.LocaleSpecification;
11
+ type SettingsEventsMap = {
12
+ 'change-lang': ChartKitLang;
13
+ };
14
+ export declare const settingsEventEmitter: EventEmitter<SettingsEventsMap>;
13
15
  declare class ChartKitSettings {
14
16
  private settings;
17
+ constructor();
15
18
  get<T extends SettingKey>(key: T): Settings[T];
16
19
  set(updates: Partial<Settings>): void;
17
20
  }
@@ -1,9 +1,9 @@
1
- import moment from 'moment';
2
1
  import get from 'lodash/get';
3
2
  import merge from 'lodash/merge';
4
3
  import { configure } from '@gravity-ui/uikit';
5
4
  import { i18nFactory } from '../../i18n';
6
- export const DEFAULT_LOCALE_SPECIFICATION = { week: { dow: 1, doy: 7 } };
5
+ import { EventEmitter } from './eventEmitter';
6
+ export const settingsEventEmitter = new EventEmitter();
7
7
  const removeUndefinedValues = (data) => {
8
8
  return Object.entries(data).reduce((acc, [key, value]) => {
9
9
  if (typeof value !== 'undefined') {
@@ -12,12 +12,7 @@ const removeUndefinedValues = (data) => {
12
12
  return acc;
13
13
  }, {});
14
14
  };
15
- const updateLocale = (args) => {
16
- const { lang, locale } = args;
17
- if (locale) {
18
- moment.updateLocale(lang, locale);
19
- }
20
- moment.locale(lang);
15
+ const updateLang = (lang) => {
21
16
  configure({ lang });
22
17
  i18nFactory.setLang(lang);
23
18
  };
@@ -27,19 +22,19 @@ class ChartKitSettings {
27
22
  plugins: [],
28
23
  lang: 'en',
29
24
  };
25
+ updateLang(this.get('lang'));
30
26
  }
31
27
  get(key) {
32
28
  return get(this.settings, key);
33
29
  }
34
30
  set(updates) {
35
31
  const filteredUpdates = removeUndefinedValues(updates);
36
- if (filteredUpdates.lang || filteredUpdates.locale) {
32
+ this.settings = merge(this.settings, filteredUpdates);
33
+ if (filteredUpdates.lang) {
37
34
  const lang = filteredUpdates.lang || this.get('lang');
38
- const locale = filteredUpdates.locale || this.get('locale');
39
- updateLocale({ lang, locale });
35
+ updateLang(lang);
36
+ settingsEventEmitter.dispatch('change-lang', lang);
40
37
  }
41
- this.settings = merge(this.settings, filteredUpdates);
42
38
  }
43
39
  }
44
40
  export const settings = new ChartKitSettings();
45
- settings.set({ locale: DEFAULT_LOCALE_SPECIFICATION });
@@ -3,6 +3,7 @@ import type { ChartKitWidgetRef } from '../../../types';
3
3
  declare const HighchartsWidget: React.ForwardRefExoticComponent<{
4
4
  type: "highcharts";
5
5
  data: import("../types").HighchartsWidgetData;
6
+ pluginRef?: undefined;
6
7
  id?: string | undefined;
7
8
  isMobile?: boolean | undefined;
8
9
  onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"highcharts"> | undefined) => void) | undefined;
@@ -3,12 +3,18 @@ import Highcharts from 'highcharts';
3
3
  import HighchartsReact from 'highcharts-react-official';
4
4
  import get from 'lodash/get';
5
5
  import { settings } from '../../../../libs';
6
+ import { settingsEventEmitter } from '../../../../libs/settings/settings';
6
7
  import { markChartPerformance, getChartPerformanceDuration, getRandomCKId } from '../../../../utils';
7
8
  import { getGraph } from '../helpers/graph';
8
9
  import { initHighchartsModules } from '../helpers/init-highcharts-modules';
10
+ import { initHighchartsLangOptions } from '../helpers/highcharts/highcharts';
9
11
  import { withSplitPane } from './withSplitPane/withSplitPane';
10
12
  import './HighchartsComponent.css';
11
13
  const HighcharsReactWithSplitPane = withSplitPane(HighchartsReact);
14
+ settingsEventEmitter.on('change-lang', {
15
+ id: 'hc-lang-handler',
16
+ action: initHighchartsLangOptions,
17
+ });
12
18
  initHighchartsModules();
13
19
  export class HighchartsComponent extends React.PureComponent {
14
20
  constructor() {
@@ -10,7 +10,7 @@ import isNumber from 'lodash/isNumber';
10
10
  import throttle from 'lodash/throttle';
11
11
  import pick from 'lodash/pick';
12
12
  import debounce from 'lodash/debounce';
13
- import moment from 'moment';
13
+ import { dateTime } from '@gravity-ui/date-utils';
14
14
  import { i18n } from '../../../../../i18n';
15
15
  import { formatNumber } from '../../../../shared';
16
16
  import { getCommentsOnLine, drawComments, hideComments, drawOnlyRendererComments, } from '../comments/drawing';
@@ -1071,7 +1071,9 @@ function drillOnClick(event, { options, chartType }) {
1071
1071
  drillDownFilter =
1072
1072
  chartType === 'scatter' ? drillDownFilter - 180 * 60 * 1000 : drillDownFilter;
1073
1073
  }
1074
- return isDateTime ? moment(drillDownFilter).format('YYYY-MM-DD') : drillDownFilter;
1074
+ return isDateTime
1075
+ ? dateTime({ input: drillDownFilter }).format('YYYY-MM-DD')
1076
+ : drillDownFilter;
1075
1077
  }
1076
1078
  return filter;
1077
1079
  });
@@ -1,4 +1,4 @@
1
- import moment from 'moment';
1
+ import { dateTime } from '@gravity-ui/date-utils';
2
2
  import { getXAxisThresholdValue } from './getXAxisThresholdValue';
3
3
  const HOUR_IN_MS = 1000 * 60 * 60;
4
4
  const DAY_IN_MS = HOUR_IN_MS * 24;
@@ -18,7 +18,7 @@ export const getDefaultPeriodInMS = (periodSettings, series) => {
18
18
  if (maxXValue === null) {
19
19
  return null;
20
20
  }
21
- const minXValue = moment(maxXValue).subtract(value, period);
21
+ const minXValue = dateTime({ input: maxXValue }).subtract(value, period);
22
22
  const range = maxXValue - minXValue.valueOf();
23
23
  return {
24
24
  minRange,
@@ -2,3 +2,4 @@ export function initHighcharts({ isMobile }: {
2
2
  isMobile: any;
3
3
  }): void;
4
4
  export function initHighchartsMap(): void;
5
+ export function initHighchartsLangOptions(): void;
@@ -113,7 +113,7 @@ Highcharts.setOptions({
113
113
  },
114
114
  },
115
115
  });
116
- function initHighcharts({ isMobile }) {
116
+ function initHighchartsLangOptions() {
117
117
  Highcharts.setOptions({
118
118
  lang: {
119
119
  resetZoom: '⟲',
@@ -159,6 +159,9 @@ function initHighcharts({ isMobile }) {
159
159
  thousandsSep: i18n('highcharts', 'thousands-sep'),
160
160
  },
161
161
  });
162
+ }
163
+ function initHighcharts({ isMobile }) {
164
+ initHighchartsLangOptions();
162
165
  // https://github.com/highcharts/highcharts/issues/11494
163
166
  (function (H) {
164
167
  H.wrap(H.Tooltip.prototype, 'getLabel', function (proceed, ...rest) {
@@ -347,4 +350,4 @@ function initHighchartsMap() {
347
350
  }
348
351
  });
349
352
  }
350
- export { initHighcharts, initHighchartsMap };
353
+ export { initHighcharts, initHighchartsMap, initHighchartsLangOptions };
@@ -1,5 +1,5 @@
1
- import moment from 'moment';
2
1
  import lodashMin from 'lodash/min';
2
+ import { dateTime } from '@gravity-ui/date-utils';
3
3
  import { i18n } from '../../../../i18n';
4
4
  import { ChartKitError, CHARTKIT_ERROR_CODE } from '../../../../libs';
5
5
  import { DEFAULT_LINES_LIMIT } from './constants';
@@ -70,9 +70,9 @@ function removeHolidays(data, options, holidays) {
70
70
  graphsData[i] = [];
71
71
  });
72
72
  data.categories_ms.forEach((ts, i) => {
73
- const datetime = moment(ts).format('YYYYMMDD');
73
+ const key = dateTime({ input: ts }).format('YYYYMMDD');
74
74
  const region = (options.region && options.region.toLowerCase()) || 'tot';
75
- const holiday = holidays.holiday[region][datetime] || holidays.weekend[region][datetime];
75
+ const holiday = holidays.holiday[region][key] || holidays.weekend[region][key];
76
76
  if (!holiday) {
77
77
  timeline.push(ts);
78
78
  data.graphs.forEach((graph, j) => graphsData[j].push(graph.data[i]));
@@ -5,8 +5,7 @@ export const escapeHTML = (html = '') => {
5
5
  return elem.innerHTML;
6
6
  };
7
7
  export const getSortedLines = (lines, sort = {}) => {
8
- // set eneabled to true after https://github.com/gravity-ui/chartkit/issues/171
9
- const { enabled = false, order = 'desc', iteratee = 'originalValue' } = sort;
8
+ const { enabled = true, order = 'desc', iteratee = 'originalValue' } = sort;
10
9
  if (!enabled) {
11
10
  return [...lines];
12
11
  }
@@ -4,6 +4,7 @@ import './IndicatorWidget.css';
4
4
  declare const IndicatorWidget: React.ForwardRefExoticComponent<{
5
5
  type: "indicator";
6
6
  data: import("../types").IndicatorWidgetData;
7
+ pluginRef?: undefined;
7
8
  id?: string | undefined;
8
9
  isMobile?: boolean | undefined;
9
10
  onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"indicator"> | undefined) => void) | undefined;
@@ -12,12 +12,14 @@ export default {
12
12
  const LineTemplate = () => {
13
13
  const [shown, setShown] = React.useState(false);
14
14
  const chartkitRef = React.useRef();
15
+ // Example of usage pluginRef property
16
+ const yagrPluginRef = React.useRef(null);
15
17
  if (!shown) {
16
18
  settings.set({ plugins: [YagrPlugin] });
17
19
  return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
18
20
  }
19
21
  return (React.createElement("div", { style: { height: 300, width: '100%' } },
20
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10 })));
22
+ React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10, pluginRef: yagrPluginRef })));
21
23
  };
22
24
  const UpdatesTemplate = () => {
23
25
  const [shown, setShown] = React.useState(false);
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { YagrReactRef } from '@gravity-ui/yagr/dist/react';
2
3
  import type { ChartKitWidgetRef } from '../../../types';
3
4
  import './polyfills';
4
5
  import '@gravity-ui/yagr/dist/index.css';
@@ -6,6 +7,7 @@ import './YagrWidget.css';
6
7
  declare const YagrWidget: React.ForwardRefExoticComponent<{
7
8
  type: "yagr";
8
9
  data: import("../types").YagrWidgetData;
10
+ pluginRef?: React.MutableRefObject<YagrReactRef | null> | undefined;
9
11
  id?: string | undefined;
10
12
  isMobile?: boolean | undefined;
11
13
  onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"yagr"> | undefined) => void) | undefined;
@@ -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),
@@ -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,5 +1,6 @@
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
5
  export type YagrWidgetData = {
5
6
  data: {
@@ -26,6 +26,8 @@ export type ChartKitOnError = (data: {
26
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;
@@ -40,7 +42,7 @@ export type ChartKitProps<T extends ChartKitType> = {
40
42
  /** Used to render user's plugin loader component */
41
43
  renderPluginLoader?: () => React.ReactNode;
42
44
  } & {
43
- [key in keyof Omit<ChartKitWidget[T], 'data' | 'widget'>]: ChartKitWidget[T][key];
45
+ [key in keyof Omit<ChartKitWidget[T], 'data' | 'widget' | 'pluginRef'>]: ChartKitWidget[T][key];
44
46
  };
45
47
  export type ChartKitPlugin = {
46
48
  type: ChartKitType;
@@ -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.5",
3
+ "version": "3.0.0-beta.7",
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.4",
16
+ "@gravity-ui/date-utils": "^1.4.1",
17
+ "@gravity-ui/yagr": "^3.3.5",
17
18
  "bem-cn-lite": "^4.1.0",
18
19
  "highcharts": "^8.2.2",
19
20
  "highcharts-react-official": "^3.0.0",
@@ -54,7 +55,6 @@
54
55
  "jest": "^28.1.3",
55
56
  "jest-environment-jsdom": "^28.1.2",
56
57
  "lint-staged": "^10.2.7",
57
- "moment": "^2.29.4",
58
58
  "npm-run-all": "^4.1.5",
59
59
  "prettier": "^2.6.0",
60
60
  "react": "^17.0.2",
@@ -72,7 +72,6 @@
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@gravity-ui/uikit": "^4.0.0",
75
- "moment": "^2.19.3",
76
75
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
77
76
  },
78
77
  "scripts": {