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

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 (77) hide show
  1. package/build/components/ChartKit.d.ts +6 -4
  2. package/build/components/ChartKit.js +2 -2
  3. package/build/components/ErrorBoundary/ErrorBoundary.d.ts +2 -2
  4. package/build/components/Loader/Loader.d.ts +3 -3
  5. package/build/i18n/index.d.ts +2 -2
  6. package/build/libs/chartkit-error/chartkit-error.d.ts +1 -1
  7. package/build/libs/settings/__tests__/settings.test.js +2 -9
  8. package/build/libs/settings/eventEmitter.d.ts +11 -0
  9. package/build/libs/settings/eventEmitter.js +25 -0
  10. package/build/libs/settings/settings.d.ts +7 -4
  11. package/build/libs/settings/settings.js +8 -13
  12. package/build/plugins/highcharts/__stories__/Line.stories.d.ts +2 -3
  13. package/build/plugins/highcharts/__stories__/Pie.stories.d.ts +2 -3
  14. package/build/plugins/highcharts/__stories__/area/Range.stories.d.ts +2 -3
  15. package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +2 -3
  16. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +2 -3
  17. package/build/plugins/highcharts/__stories__/column/Vertical.stories.d.ts +2 -3
  18. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.d.ts +2 -3
  19. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.d.ts +2 -3
  20. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.d.ts +2 -3
  21. package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +1 -1
  22. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.d.ts +2 -3
  23. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.d.ts +2 -3
  24. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.d.ts +2 -3
  25. package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +3 -1
  26. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +3 -3
  27. package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +6 -0
  28. package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.d.ts +3 -3
  29. package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.js +2 -5
  30. package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +0 -1
  31. package/build/plugins/highcharts/renderer/helpers/config/config.js +10 -10
  32. package/build/plugins/highcharts/renderer/helpers/config/types.d.ts +2 -2
  33. package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.d.ts +1 -1
  34. package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.d.ts +1 -1
  35. package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.d.ts +1 -1
  36. package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.d.ts +1 -1
  37. package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +33 -0
  38. package/build/plugins/highcharts/renderer/helpers/config/utils/index.js +8 -0
  39. package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.d.ts +1 -1
  40. package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.d.ts +1 -1
  41. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.d.ts +2 -2
  42. package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.js +2 -2
  43. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +1 -1
  44. package/build/plugins/highcharts/renderer/helpers/graph.js +2 -2
  45. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.d.ts +1 -0
  46. package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +5 -2
  47. package/build/plugins/highcharts/renderer/helpers/prepare-data.js +3 -3
  48. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.d.ts +0 -2
  49. package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.js +0 -9
  50. package/build/plugins/highcharts/renderer/helpers/tooltip/index.d.ts +1 -1
  51. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +4 -5
  52. package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.d.ts +1 -1
  53. package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +3 -12
  54. package/build/plugins/highcharts/renderer/helpers/types.d.ts +2 -2
  55. package/build/plugins/highcharts/types/comments.d.ts +1 -1
  56. package/build/plugins/highcharts/types/misc.d.ts +4 -4
  57. package/build/plugins/highcharts/types/widget.d.ts +13 -5
  58. package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +2 -2
  59. package/build/plugins/indicator/renderer/IndicatorItem.d.ts +2 -2
  60. package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +3 -1
  61. package/build/plugins/indicator/types.d.ts +2 -2
  62. package/build/plugins/shared/format-number/i18n/i18n.d.ts +1 -1
  63. package/build/plugins/shared/format-number/types.d.ts +2 -2
  64. package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +3 -4
  65. package/build/plugins/yagr/__stories__/Yagr.stories.js +3 -1
  66. package/build/plugins/yagr/renderer/YagrWidget.d.ts +4 -1
  67. package/build/plugins/yagr/renderer/YagrWidget.js +13 -12
  68. package/build/plugins/yagr/renderer/tooltip/renderTooltip.js +2 -2
  69. package/build/plugins/yagr/renderer/tooltip/types.d.ts +4 -4
  70. package/build/plugins/yagr/renderer/utils.d.ts +1 -1
  71. package/build/plugins/yagr/renderer/utils.js +3 -3
  72. package/build/plugins/yagr/types.d.ts +2 -1
  73. package/build/types/index.d.ts +22 -22
  74. package/build/types/misc.d.ts +1 -1
  75. package/build/types/widget.d.ts +5 -1
  76. package/package.json +14 -9
  77. package/CHANGELOG.md +0 -489
@@ -1,21 +1,23 @@
1
1
  import React from 'react';
2
2
  import type { ChartKitType, ChartKitRef, ChartKitProps } from '../types';
3
3
  import './ChartKit.css';
4
- declare type ChartKitComponentProps<T extends ChartKitType> = Omit<ChartKitProps<T>, 'onError'> & {
4
+ type ChartKitComponentProps<T extends ChartKitType> = Omit<ChartKitProps<T>, 'onError'> & {
5
5
  instanceRef?: React.ForwardedRef<ChartKitRef | undefined>;
6
6
  };
7
- declare const ChartKitComponent: <T extends keyof import("../types").ChartKitWidget>(props: ChartKitComponentProps<T>) => JSX.Element;
7
+ declare const ChartKitComponent: <T extends keyof import("../types").ChartKitWidget>(props: ChartKitComponentProps<T>) => React.JSX.Element;
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;
14
15
  onRender?: ((data: import("../types").ChartKitOnRenderData) => void) | undefined;
15
16
  onChartLoad?: ((data: import("../types").ChartKitOnChartLoad<T>) => void) | undefined;
16
- renderError?: import("../types").RenderError | undefined;
17
17
  onError?: import("../types").ChartKitOnError | undefined;
18
- } & { [key in keyof Omit<import("../types").ChartKitWidget[T], "widget" | "data">]: import("../types").ChartKitWidget[T][key]; } & {
18
+ renderError?: import("../types").RenderError | undefined;
19
+ renderPluginLoader?: (() => React.ReactNode) | undefined;
20
+ } & (Omit<import("../types").ChartKitWidget[T], "widget" | "data" | "pluginRef"> extends infer T_1 ? { [key in keyof T_1]: import("../types").ChartKitWidget[T][key]; } : never) & {
19
21
  ref?: React.ForwardedRef<ChartKitRef | undefined> | undefined;
20
22
  }) => ReturnType<typeof ChartKitComponent>;
21
23
  export {};
@@ -10,7 +10,7 @@ import './ChartKit.css';
10
10
  const b = block('chartkit');
11
11
  const ChartKitComponent = (props) => {
12
12
  const widgetRef = React.useRef();
13
- const { instanceRef, id: propsId, type, isMobile } = props, restProps = __rest(props, ["instanceRef", "id", "type", "isMobile"]);
13
+ const { instanceRef, id: propsId, type, isMobile, renderPluginLoader } = props, restProps = __rest(props, ["instanceRef", "id", "type", "isMobile", "renderPluginLoader"]);
14
14
  const ckId = React.useMemo(() => getRandomCKId(), []);
15
15
  const id = propsId || ckId;
16
16
  const lang = settings.get('lang');
@@ -31,7 +31,7 @@ const ChartKitComponent = (props) => {
31
31
  }
32
32
  },
33
33
  }), []);
34
- return (React.createElement(React.Suspense, { fallback: React.createElement(Loader, null) },
34
+ return (React.createElement(React.Suspense, { fallback: (renderPluginLoader === null || renderPluginLoader === void 0 ? void 0 : renderPluginLoader()) || React.createElement(Loader, null) },
35
35
  React.createElement("div", { className: b({ mobile: isMobile }, 'chartkit-theme_common') },
36
36
  React.createElement(ChartComponent, Object.assign({ ref: widgetRef, id: id, lang: lang }, restProps)))));
37
37
  };
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { ChartKitError } from '../../libs';
3
3
  import type { ChartKitOnError, ChartKitType, ChartKitWidget, RenderError } from '../../types';
4
- declare type Props = {
4
+ type Props = {
5
5
  onError?: ChartKitOnError;
6
6
  data: ChartKitWidget[ChartKitType]['data'];
7
7
  renderError?: RenderError;
8
8
  };
9
- declare type State = {
9
+ type State = {
10
10
  error?: ChartKitError | Error;
11
11
  };
12
12
  export declare class ErrorBoundary extends React.Component<Props, State> {
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { LoaderProps as BaseLoaderProps } from '@gravity-ui/uikit';
3
3
  import './Loader.css';
4
- declare type LoaderProps = BaseLoaderProps;
5
- export declare const Loader: (props: LoaderProps) => JSX.Element;
4
+ type LoaderProps = BaseLoaderProps;
5
+ export declare const Loader: (props: LoaderProps) => React.JSX.Element;
6
6
  export {};
@@ -1,7 +1,7 @@
1
1
  import { I18N, I18NFn } from '@gravity-ui/i18n';
2
2
  import en from './keysets/en.json';
3
- declare type Keysets = typeof en;
4
- declare type TypedI18n = I18NFn<Keysets>;
3
+ type Keysets = typeof en;
4
+ type TypedI18n = I18NFn<Keysets>;
5
5
  declare const i18nFactory: I18N;
6
6
  declare const i18n: TypedI18n;
7
7
  export { i18nFactory, i18n };
@@ -1,4 +1,4 @@
1
- export declare type ChartKitErrorArgs = {
1
+ export type ChartKitErrorArgs = {
2
2
  code?: number | string;
3
3
  originalError?: Error;
4
4
  message?: string;
@@ -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
- declare type SettingKey = keyof Settings;
12
- export declare const DEFAULT_LOCALE_SPECIFICATION: moment.LocaleSpecification;
10
+ type SettingKey = keyof Settings;
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 });
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const Line: Story<any>;
3
+ export declare const Line: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const Pie: Story<any>;
3
+ export declare const Pie: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const AreaRange: Story<any>;
3
+ export declare const AreaRange: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const AreaStacked: Story<any>;
3
+ export declare const AreaStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Story, Meta } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const HorizontalStacked: Story<any>;
3
+ export declare const HorizontalStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Story, Meta } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const Vertical: Story<any>;
3
+ export declare const Vertical: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Story, Meta } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const VerticalStacked: Story<any>;
3
+ export declare const VerticalStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Story, Meta } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const ComboChart: Story<any>;
3
+ export declare const ComboChart: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const TwoAxis: Story<import("@storybook/react").Args>;
3
+ export declare const TwoAxis: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { RenderError } from '../../../../types';
3
3
  import { HighchartsWidgetData } from '../../types';
4
- export declare type ChartStoryProps = {
4
+ export type ChartStoryProps = {
5
5
  data: HighchartsWidgetData;
6
6
  withoutPlugin?: boolean;
7
7
  visible?: boolean;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const CustomErrorRender: Story<import("@storybook/react").Args>;
3
+ export declare const CustomErrorRender: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const NoData: Story<import("@storybook/react").Args>;
3
+ export declare const NoData: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,4 +1,3 @@
1
- import { Meta, Story } from '@storybook/react';
2
- declare const _default: Meta<import("@storybook/react").Args>;
1
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
2
  export default _default;
4
- export declare const WithTotals: Story<any>;
3
+ export declare const WithTotals: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -3,13 +3,15 @@ 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;
9
10
  onRender?: ((data: import("../../../types").ChartKitOnRenderData) => void) | undefined;
10
11
  onChartLoad?: ((data: import("../../../types").ChartKitOnChartLoad<"highcharts">) => void) | undefined;
11
- renderError?: import("../../../types").RenderError | undefined;
12
12
  onError?: import("../../../types").ChartKitOnError | undefined;
13
+ renderError?: import("../../../types").RenderError | undefined;
14
+ renderPluginLoader?: (() => React.ReactNode) | undefined;
13
15
  } & {
14
16
  hoistConfigError?: boolean | undefined;
15
17
  nonBodyScroll?: boolean | undefined;
@@ -3,8 +3,8 @@ import Highcharts, { ChartCallbackFunction, Options, Chart } from 'highcharts';
3
3
  import type { ChartKitProps } from '../../../../types';
4
4
  import type { HighchartsWidgetData, StringParams } from '../../types';
5
5
  import './HighchartsComponent.css';
6
- declare type Props = ChartKitProps<'highcharts'>;
7
- declare type State = {
6
+ type Props = ChartKitProps<'highcharts'>;
7
+ type State = {
8
8
  prevData: HighchartsWidgetData | null;
9
9
  options: (Options & {
10
10
  useHighStock: boolean;
@@ -576,7 +576,7 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
576
576
  private chartComponent;
577
577
  componentDidMount(): void;
578
578
  componentDidUpdate(): void;
579
- render(): JSX.Element | null;
579
+ render(): React.JSX.Element | null;
580
580
  reflow: () => void;
581
581
  extendChartInstance: (chart: Chart) => void;
582
582
  getParams: () => StringParams;
@@ -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() {
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Split, SplitPaneProps } from 'react-split-pane';
3
3
  import './StyledSplitPane.css';
4
- export declare type PaneSplit = Split;
5
- declare type Props = SplitPaneProps & {
4
+ export type PaneSplit = Split;
5
+ type Props = SplitPaneProps & {
6
6
  paneOneRender: () => React.ReactNode;
7
7
  paneTwoRender: () => React.ReactNode;
8
8
  };
9
- export declare const StyledSplitPane: ({ paneOneRender, paneTwoRender, ...splitPaneProps }: Props) => JSX.Element;
9
+ export declare const StyledSplitPane: ({ paneOneRender, paneTwoRender, ...splitPaneProps }: Props) => React.JSX.Element;
10
10
  export {};
@@ -1,7 +1,7 @@
1
1
  /* eslint callback-return: 0 */
2
2
  import React from 'react';
3
3
  import block from 'bem-cn-lite';
4
- import { get, debounce } from 'lodash';
4
+ import { debounce, get } from 'lodash';
5
5
  import { getRandomCKId } from '../../../../../utils';
6
6
  import { chartTypesWithoutCrosshair } from '../../helpers/config/config';
7
7
  import { StyledSplitPane } from '../StyledSplitPane/StyledSplitPane';
@@ -42,10 +42,7 @@ function getPointsForInitialRefresh(chart) {
42
42
  return points;
43
43
  }
44
44
  function forceHoverState(chart, activePoints) {
45
- const chartType = get(chart, 'userOptions.chart.type');
46
- if (!chartType) {
47
- return;
48
- }
45
+ const chartType = get(chart, 'userOptions.chart.type') || '';
49
46
  if (chartType === 'pie') {
50
47
  chart.tooltip.refresh(activePoints);
51
48
  chart.pointsForInitialRefresh = activePoints;
@@ -588,4 +588,3 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
588
588
  export const chartTypesWithoutCrosshair: string[];
589
589
  export const chartTypesWithoutYCrosshair: string[];
590
590
  export const chartTypesWithNativeTooltip: string[];
591
- import Highcharts from "highcharts";
@@ -10,13 +10,13 @@ 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';
17
17
  import formatTooltip, { TOOLTIP_ROW_CLASS_NAME, SERIES_NAME_DATA_ATTRIBUTE, TOOLTIP_HEADER_CLASS_NAME, TOOLTIP_LIST_CLASS_NAME, TOOLTIP_FOOTER_CLASS_NAME, TOOLTIP_CONTAINER_CLASS_NAME, TOOLTIP_ROW_NAME_CLASS_NANE, } from '../tooltip';
18
18
  import defaultOptions from './options';
19
- import { calculatePrecision, isTooltipShared, isSafari, mergeArrayWithObject, concatStrings, buildNavigatorFallback, addShowInNavigatorToSeries, setNavigatorDefaultPeriod, numberFormat, getFormatOptionsFromLine, checkTooltipPinningAvailability, } from './utils';
19
+ import { calculatePrecision, isTooltipShared, isSafari, mergeArrayWithObject, concatStrings, buildNavigatorFallback, addShowInNavigatorToSeries, setNavigatorDefaultPeriod, numberFormat, getFormatOptionsFromLine, checkTooltipPinningAvailability, getSortedData, } from './utils';
20
20
  import { handleLegendItemClick } from './handleLegendItemClick';
21
21
  import { getChartKitFormattedValue } from './utils/getChartKitFormattedValue';
22
22
  const b = block('chartkit-tooltip');
@@ -381,7 +381,7 @@ function validateCellManipulationConfig(tooltipOptions, property, item) {
381
381
  }
382
382
  }
383
383
  function getTooltip(tooltip, options, comments, holidays) {
384
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
385
385
  const serieType = (this.series && this.series.type) || tooltip.chart.options.chart.type;
386
386
  const chart = tooltip.chart;
387
387
  const xAxis = chart.xAxis[0];
@@ -412,7 +412,6 @@ function getTooltip(tooltip, options, comments, holidays) {
412
412
  count: 1,
413
413
  shared: true,
414
414
  unsafe: Boolean(options.unsafe),
415
- sort: (_b = options === null || options === void 0 ? void 0 : options.tooltip) === null || _b === void 0 ? void 0 : _b.sort,
416
415
  };
417
416
  if (typeof options.manageTooltipConfig === 'function') {
418
417
  json = callManageTooltipConfig(options, json, chart);
@@ -440,7 +439,7 @@ function getTooltip(tooltip, options, comments, holidays) {
440
439
  let points = [];
441
440
  let shared;
442
441
  if (this.points) {
443
- points = this.points;
442
+ points = getSortedData(this.points, (_b = options === null || options === void 0 ? void 0 : options.tooltip) === null || _b === void 0 ? void 0 : _b.sort);
444
443
  shared = true;
445
444
  }
446
445
  else {
@@ -459,7 +458,6 @@ function getTooltip(tooltip, options, comments, holidays) {
459
458
  withPercent: false,
460
459
  tooltipHeader: null,
461
460
  unsafe: Boolean(options.unsafe),
462
- sort: (_c = options === null || options === void 0 ? void 0 : options.tooltip) === null || _c === void 0 ? void 0 : _c.sort,
463
461
  };
464
462
  if (isDatetimeXAxis) {
465
463
  const items = this.points || Highcharts.splat(this);
@@ -476,9 +474,9 @@ function getTooltip(tooltip, options, comments, holidays) {
476
474
  }
477
475
  json.tooltipHeader = chart.time.dateFormat(xDateFormat, this.x);
478
476
  }
479
- else if ((_f = (_e = (_d = extendedPoint.point) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.xFormatted) !== null && _f !== void 0 ? _f : (extendedPoint.x || extendedPoint.x === 0)) {
480
- const customTooltipHeaderFormatter = (_g = options === null || options === void 0 ? void 0 : options.highcharts) === null || _g === void 0 ? void 0 : _g.tooltipHeaderFormatter;
481
- const tooltipHeaderStringValue = String((_k = (_j = (_h = extendedPoint.point) === null || _h === void 0 ? void 0 : _h.options) === null || _j === void 0 ? void 0 : _j.xFormatted) !== null && _k !== void 0 ? _k : extendedPoint.x);
477
+ else if ((_e = (_d = (_c = extendedPoint.point) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.xFormatted) !== null && _e !== void 0 ? _e : (extendedPoint.x || extendedPoint.x === 0)) {
478
+ const customTooltipHeaderFormatter = (_f = options === null || options === void 0 ? void 0 : options.highcharts) === null || _f === void 0 ? void 0 : _f.tooltipHeaderFormatter;
479
+ const tooltipHeaderStringValue = String((_j = (_h = (_g = extendedPoint.point) === null || _g === void 0 ? void 0 : _g.options) === null || _h === void 0 ? void 0 : _h.xFormatted) !== null && _j !== void 0 ? _j : extendedPoint.x);
482
480
  json.tooltipHeader = customTooltipHeaderFormatter
483
481
  ? customTooltipHeaderFormatter(tooltipHeaderStringValue)
484
482
  : tooltipHeaderStringValue;
@@ -1071,7 +1069,9 @@ function drillOnClick(event, { options, chartType }) {
1071
1069
  drillDownFilter =
1072
1070
  chartType === 'scatter' ? drillDownFilter - 180 * 60 * 1000 : drillDownFilter;
1073
1071
  }
1074
- return isDateTime ? moment(drillDownFilter).format('YYYY-MM-DD') : drillDownFilter;
1072
+ return isDateTime
1073
+ ? dateTime({ input: drillDownFilter }).format('YYYY-MM-DD')
1074
+ : drillDownFilter;
1075
1075
  }
1076
1076
  return filter;
1077
1077
  });
@@ -1,6 +1,6 @@
1
- export declare type NavigatorPeriod = {
1
+ export type NavigatorPeriod = {
2
2
  type: string;
3
3
  value: string;
4
4
  period: Period;
5
5
  };
6
- export declare type Period = 'month' | 'year' | 'day' | 'hour' | 'week' | 'quarter';
6
+ export type Period = 'month' | 'year' | 'day' | 'hour' | 'week' | 'quarter';
@@ -1,5 +1,5 @@
1
1
  import { NavigatorLinesMode } from '../../constants';
2
- declare type AddShowInNavigatorToSeriesArgs = {
2
+ type AddShowInNavigatorToSeriesArgs = {
3
3
  linesMode: NavigatorLinesMode;
4
4
  graphs: Record<string, any>[];
5
5
  baseSeriesName: string;
@@ -1 +1 @@
1
- export declare const buildNavigatorFallback: (graphs: Record<string, any>[], baseSeriesName?: string | undefined) => void;
1
+ export declare const buildNavigatorFallback: (graphs: Record<string, any>[], baseSeriesName?: string) => void;
@@ -2,4 +2,4 @@ export declare const calculatePrecision: (alternativePrecision: number | null, o
2
2
  normalizeDiv: boolean;
3
3
  normalizeSub: boolean;
4
4
  precision?: number;
5
- }, originalValue?: number | undefined) => number | null | undefined;
5
+ }, originalValue?: number) => number | undefined;
@@ -1,3 +1,3 @@
1
1
  import type { FormatNumberOptions } from '../../../../../shared';
2
2
  import type { TooltipLine } from '../../tooltip/types';
3
- export declare const getFormatOptionsFromLine: (line?: Partial<TooltipLine> | undefined) => FormatNumberOptions | undefined;
3
+ export declare const getFormatOptionsFromLine: (line?: Partial<TooltipLine>) => FormatNumberOptions | undefined;
@@ -1,3 +1,4 @@
1
+ import type { HighchartsSortData } from '../../../../types/widget';
1
2
  export { addShowInNavigatorToSeries } from './addShowInNavigatorToSeries';
2
3
  export { buildNavigatorFallback } from './buildNavigatorFallback';
3
4
  export { calculatePrecision } from './calculatePrecision';
@@ -11,3 +12,35 @@ export { isSafari } from './isSafari';
11
12
  export { mergeArrayWithObject } from './mergeArrayWithObject';
12
13
  export { numberFormat } from './numberFormat';
13
14
  export { setNavigatorDefaultPeriod } from './setNavigatorDefaultPeriod';
15
+ export declare const getSortedData: <T extends Record<string, any>>(data: T[], sort?: HighchartsSortData) => (number | T | (() => IterableIterator<T>) | (() => {
16
+ copyWithin: boolean;
17
+ entries: boolean;
18
+ fill: boolean;
19
+ find: boolean;
20
+ findIndex: boolean;
21
+ keys: boolean;
22
+ values: boolean;
23
+ }) | (() => string) | (() => string) | (() => T | undefined) | ((...items: T[]) => number) | {
24
+ (...items: ConcatArray<T>[]): T[];
25
+ (...items: (T | ConcatArray<T>)[]): T[];
26
+ } | ((separator?: string | undefined) => string) | (() => T[]) | (() => T | undefined) | ((start?: number | undefined, end?: number | undefined) => T[]) | ((compareFn?: ((a: T, b: T) => number) | undefined) => T[]) | {
27
+ (start: number, deleteCount?: number | undefined): T[];
28
+ (start: number, deleteCount: number, ...items: T[]): T[];
29
+ } | ((...items: T[]) => number) | ((searchElement: T, fromIndex?: number | undefined) => number) | ((searchElement: T, fromIndex?: number | undefined) => number) | {
30
+ <S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[];
31
+ (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
32
+ } | ((predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any) => boolean) | ((callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any) => void) | (<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]) | {
33
+ <S_1 extends T>(predicate: (value: T, index: number, array: T[]) => value is S_1, thisArg?: any): S_1[];
34
+ (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];
35
+ } | {
36
+ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
37
+ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
38
+ <U_1>(callbackfn: (previousValue: U_1, currentValue: T, currentIndex: number, array: T[]) => U_1, initialValue: U_1): U_1;
39
+ } | {
40
+ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
41
+ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
42
+ <U_2>(callbackfn: (previousValue: U_2, currentValue: T, currentIndex: number, array: T[]) => U_2, initialValue: U_2): U_2;
43
+ } | {
44
+ <S_2 extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S_2, thisArg?: any): S_2 | undefined;
45
+ (predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
46
+ } | ((predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any) => number) | ((value: T, start?: number | undefined, end?: number | undefined) => T[]) | ((target: number, start: number, end?: number | undefined) => T[]) | (() => IterableIterator<[number, T]>) | (() => IterableIterator<number>) | (() => IterableIterator<T>) | ((searchElement: T, fromIndex?: number | undefined) => boolean) | (<U_3, This = undefined>(callback: (this: This, value: T, index: number, array: T[]) => U_3 | readonly U_3[], thisArg?: This | undefined) => U_3[]) | (<A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[]) | ((index: number) => T | undefined))[];
@@ -1,3 +1,4 @@
1
+ import orderBy from 'lodash/orderBy';
1
2
  export { addShowInNavigatorToSeries } from './addShowInNavigatorToSeries';
2
3
  export { buildNavigatorFallback } from './buildNavigatorFallback';
3
4
  export { calculatePrecision } from './calculatePrecision';
@@ -11,3 +12,10 @@ export { isSafari } from './isSafari';
11
12
  export { mergeArrayWithObject } from './mergeArrayWithObject';
12
13
  export { numberFormat } from './numberFormat';
13
14
  export { setNavigatorDefaultPeriod } from './setNavigatorDefaultPeriod';
15
+ export const getSortedData = (data, sort = {}) => {
16
+ const { enabled = true, order = 'desc', iteratee = 'y' } = sort;
17
+ if (!enabled) {
18
+ return [...data];
19
+ }
20
+ return orderBy(data, iteratee, order);
21
+ };
@@ -1,2 +1,2 @@
1
1
  import type { Highcharts } from '../../../../types';
2
- export declare const isNavigatorSeries: (series?: Highcharts.Point | Highcharts.Series | undefined) => boolean;
2
+ export declare const isNavigatorSeries: (series?: Highcharts.Series | Highcharts.Point) => boolean;