@gravity-ui/dashkit 4.0.0 → 5.0.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -0
  3. package/build/cjs/components/DashKit/DashKit.d.ts +1 -2
  4. package/build/cjs/components/Item/Item.d.ts +4 -8
  5. package/build/cjs/components/OverlayControls/OverlayControls.d.ts +10 -1
  6. package/build/cjs/components/OverlayControls/OverlayControls.js +1 -2
  7. package/build/cjs/hocs/prepareItem.d.ts +4 -8
  8. package/build/cjs/hocs/withContext.js +2 -12
  9. package/build/cjs/plugins/Text/Text.d.ts +4 -4
  10. package/build/cjs/shared/modules/helpers.d.ts +1 -1
  11. package/build/cjs/shared/modules/state-and-params.d.ts +1 -1
  12. package/build/cjs/shared/types/common.d.ts +1 -1
  13. package/build/cjs/shared/types/state-and-params.d.ts +5 -5
  14. package/build/cjs/typings/common.d.ts +1 -1
  15. package/build/cjs/typings/config.d.ts +1 -1
  16. package/build/cjs/utils/configure.d.ts +2 -2
  17. package/build/cjs/utils/register-manager.d.ts +3 -3
  18. package/build/esm/components/DashKit/DashKit.d.ts +1 -2
  19. package/build/esm/components/Item/Item.d.ts +4 -8
  20. package/build/esm/components/OverlayControls/OverlayControls.d.ts +10 -1
  21. package/build/esm/components/OverlayControls/OverlayControls.js +1 -2
  22. package/build/esm/hocs/prepareItem.d.ts +4 -8
  23. package/build/esm/hocs/withContext.js +2 -12
  24. package/build/esm/plugins/Text/Text.d.ts +4 -4
  25. package/build/esm/shared/modules/helpers.d.ts +1 -1
  26. package/build/esm/shared/modules/state-and-params.d.ts +1 -1
  27. package/build/esm/shared/types/common.d.ts +1 -1
  28. package/build/esm/shared/types/state-and-params.d.ts +5 -5
  29. package/build/esm/typings/common.d.ts +1 -1
  30. package/build/esm/typings/config.d.ts +1 -1
  31. package/build/esm/utils/configure.d.ts +2 -2
  32. package/build/esm/utils/register-manager.d.ts +3 -3
  33. package/package.json +14 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.0.0](https://github.com/gravity-ui/dashkit/compare/v4.1.0...v5.0.0) (2023-02-01)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * up @gravity-ui/uikit to 4 version ([#39](https://github.com/gravity-ui/dashkit/issues/39))
9
+
10
+ ### Features
11
+
12
+ * up @gravity-ui/uikit to 4 version ([#39](https://github.com/gravity-ui/dashkit/issues/39)) ([8b4c123](https://github.com/gravity-ui/dashkit/commit/8b4c123a69009918518d4c296af3c315f811afd9))
13
+
14
+ ## [4.1.0](https://github.com/gravity-ui/dashkit/compare/v4.0.0...v4.1.0) (2023-01-31)
15
+
16
+
17
+ ### Features
18
+
19
+ * remove preventDoubleCompact flag ([#37](https://github.com/gravity-ui/dashkit/issues/37)) ([9b95e61](https://github.com/gravity-ui/dashkit/commit/9b95e61b7939a9883fda832947e70728b8f66410))
20
+
3
21
  ## [4.0.0](https://github.com/gravity-ui/dashkit/compare/v3.5.0...v4.0.0) (2022-12-19)
4
22
 
5
23
 
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # @gravity-ui/dashkit · [![npm package](https://img.shields.io/npm/v/@gravity-ui/dashkit)](https://www.npmjs.com/package/@gravity-ui/dashkit) [![CI](https://img.shields.io/github/actions/workflow/status/gravity-ui/dashkit/.github/workflows/ci.yaml?branch=main&label=CI&logo=github)](https://github.com/gravity-ui/dashkit/actions/workflows/ci.yaml?query=branch:main) [![storybook](https://img.shields.io/badge/Storybook-deployed-ff4685)](https://preview.gravity-ui.com/dashkit/)
2
+
1
3
  # DashKit
2
4
 
3
5
  A dashboard grid rendering library.
@@ -21,11 +21,10 @@ interface DashKitDefaultProps {
21
21
  overlayControls?: Record<string, OverlayControlItem[]>;
22
22
  noOverlay?: boolean;
23
23
  draggableHandleClassName?: string;
24
- _EXPERIMENTAL_preventDoubleCompact?: boolean;
25
24
  }
26
25
  export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {
27
26
  }
28
- declare type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
27
+ type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
29
28
  export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
30
29
  static defaultProps: DashKitDefaultProps;
31
30
  static registerPlugins(...plugins: Plugin[]): void;
@@ -3,12 +3,10 @@ declare const _default: {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
4
  _onStateAndParamsChange: (stateAndParams: any) => void;
5
5
  render(): JSX.Element;
6
- context: any;
6
+ context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
8
8
  forceUpdate(callback?: (() => void) | undefined): void;
9
- readonly props: Readonly<any> & Readonly<{
10
- children?: React.ReactNode;
11
- }>;
9
+ readonly props: Readonly<any>;
12
10
  state: Readonly<any>;
13
11
  refs: {
14
12
  [key: string]: React.ReactInstance;
@@ -29,12 +27,10 @@ declare const _default: {
29
27
  shouldComponentUpdate(nextProps: any): boolean;
30
28
  _onStateAndParamsChange: (stateAndParams: any) => void;
31
29
  render(): JSX.Element;
32
- context: any;
30
+ context: unknown;
33
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
34
32
  forceUpdate(callback?: (() => void) | undefined): void;
35
- readonly props: Readonly<any> & Readonly<{
36
- children?: React.ReactNode;
37
- }>;
33
+ readonly props: Readonly<any>;
38
34
  state: Readonly<any>;
39
35
  refs: {
40
36
  [key: string]: React.ReactInstance;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { ConfigItem, PluginBase, StringParams } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
4
+ import type { RegisterManager } from '../../utils/register-manager';
4
5
  export declare enum OverlayControlsPosition {
5
6
  TopRight = "top_right",
6
7
  TopLeft = "top_left",
@@ -35,9 +36,17 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
35
36
  items?: OverlayControlItem[];
36
37
  overlayControls?: Record<string, OverlayControlItem[]>;
37
38
  }
39
+ type DashKitCtx = React.Context<{
40
+ registerManager: RegisterManager;
41
+ itemsParams: Record<string, StringParams>;
42
+ editItem: (item: ConfigItem) => void;
43
+ removeItem: (id: string) => void;
44
+ config: Config;
45
+ }>;
38
46
  declare class OverlayControls extends React.Component<OverlayControlsProps> {
39
47
  static contextType: React.Context<any>;
40
48
  static defaultProps: OverlayControlsDefaultProps;
49
+ context: React.ContextType<DashKitCtx>;
41
50
  render(): JSX.Element;
42
51
  private renderControlsItem;
43
52
  private getDropDownMenuItemConfig;
@@ -143,8 +143,7 @@ class OverlayControls extends react_1.default.Component {
143
143
  }
144
144
  renderDropdownMenu() {
145
145
  const { view, size } = this.props;
146
- const { registerManager } = this.context;
147
- const itemsParams = this.context.itemsParams;
146
+ const { registerManager, itemsParams } = this.context;
148
147
  const configItem = this.props.configItem;
149
148
  const itemParams = itemsParams[configItem.id];
150
149
  let menu = registerManager.settings.menu;
@@ -3,12 +3,10 @@ export function prepareItem(Component: any): {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
4
  _onStateAndParamsChange: (stateAndParams: any) => void;
5
5
  render(): JSX.Element;
6
- context: any;
6
+ context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
8
8
  forceUpdate(callback?: (() => void) | undefined): void;
9
- readonly props: Readonly<any> & Readonly<{
10
- children?: React.ReactNode;
11
- }>;
9
+ readonly props: Readonly<any>;
12
10
  state: Readonly<any>;
13
11
  refs: {
14
12
  [key: string]: React.ReactInstance;
@@ -29,12 +27,10 @@ export function prepareItem(Component: any): {
29
27
  shouldComponentUpdate(nextProps: any): boolean;
30
28
  _onStateAndParamsChange: (stateAndParams: any) => void;
31
29
  render(): JSX.Element;
32
- context: any;
30
+ context: unknown;
33
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
34
32
  forceUpdate(callback?: (() => void) | undefined): void;
35
- readonly props: Readonly<any> & Readonly<{
36
- children?: React.ReactNode;
37
- }>;
33
+ readonly props: Readonly<any>;
38
34
  state: Readonly<any>;
39
35
  refs: {
40
36
  [key: string]: React.ReactInstance;
@@ -7,8 +7,6 @@ const DashKitContext_1 = require("../context/DashKitContext");
7
7
  const utils_1 = require("../utils");
8
8
  const shared_1 = require("../shared");
9
9
  const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
10
- const react_grid_layout_1 = require("react-grid-layout");
11
- const LAYOUT_COMPACTING_TYPE = 'vertical';
12
10
  function useMemoStateContext(props) {
13
11
  // так как мы не хотим хранить параметры виджета с активированной автовысотой в сторе и на сервере, актуальный
14
12
  // (видимый юзером в конкретный момент времени) лэйаут (массив объектов с данными о ширине, высоте,
@@ -38,22 +36,14 @@ function useMemoStateContext(props) {
38
36
  return Object.assign({}, item);
39
37
  }
40
38
  });
41
- // [experimental] if the _prevent Double Compact is enabled, then skip recalculate layout with auto height
42
- // после того, как у виждета активировали автовысоту и его параметр "h" изменился, это приведёт, также, и к
43
- // изменению параметра (координаты) "y" у элементов расположенных под ним, поэтому, после того, как
44
- // значения параметра "h" виджетов с активированной автовысотой были изменены, необходимо изменить и
45
- // координату "y" виджетов расположенных ниже
46
- const compactedLayout = props._EXPERIMENTAL_preventDoubleCompact
47
- ? currentInnerLayout
48
- : react_grid_layout_1.utils.compact(currentInnerLayout, LAYOUT_COMPACTING_TYPE, props.registerManager.gridLayout.cols);
49
39
  const newConfig = utils_1.UpdateManager.updateLayout({
50
- layout: compactedLayout,
40
+ layout: currentInnerLayout,
51
41
  config: props.config,
52
42
  });
53
43
  if (!(0, isEqual_1.default)(newConfig.layout, props.config.layout)) {
54
44
  onChange({ config: newConfig });
55
45
  }
56
- }, [props._EXPERIMENTAL_preventDoubleCompact, props.registerManager, props.config, onChange]);
46
+ }, [props.config, onChange]);
57
47
  const onItemRemove = react_1.default.useCallback((id) => {
58
48
  onChange(utils_1.UpdateManager.removeItem({
59
49
  id,
@@ -5,7 +5,7 @@ declare enum LoadStatus {
5
5
  Success = "success",
6
6
  Fail = "fail"
7
7
  }
8
- export declare type PluginTextApiHandler = (data: {
8
+ export type PluginTextApiHandler = (data: {
9
9
  text: string;
10
10
  }) => Promise<{
11
11
  result: string;
@@ -40,11 +40,11 @@ export declare class PluginText extends React.PureComponent<PluginTextProps, Plu
40
40
  private onRetryClick;
41
41
  get withMarkdown(): boolean;
42
42
  }
43
- declare type PluginDataProps = Omit<PluginTextProps, 'apiHandler'>;
44
- export declare type PluginTextObjectSettings = {
43
+ type PluginDataProps = Omit<PluginTextProps, 'apiHandler'>;
44
+ export type PluginTextObjectSettings = {
45
45
  apiHandler?: PluginTextApiHandler;
46
46
  };
47
- export declare type PluginTextObject = Plugin<PluginDataProps> & {
47
+ export type PluginTextObject = Plugin<PluginDataProps> & {
48
48
  setSettings: (settings: PluginTextObjectSettings) => PluginTextObject;
49
49
  _apiHandler?: PluginTextApiHandler;
50
50
  };
@@ -6,7 +6,7 @@ export declare function prerenderItems({ items, plugins, }: {
6
6
  export declare function getItemsStateAndParamsMeta(itemsStateAndParams: ItemsStateAndParams): StateAndParamsMetaData | undefined;
7
7
  export declare function getCurrentVersion(itemsStateAndParams: ItemsStateAndParams): number;
8
8
  export declare function isItemWithTabs(item: Pick<ConfigItem, 'data'>): item is Pick<ConfigItemWithTabs, 'data'>;
9
- export declare type FormedQueueData = {
9
+ export type FormedQueueData = {
10
10
  id: string;
11
11
  namespace: string;
12
12
  params: StringParams;
@@ -6,7 +6,7 @@ export interface GetItemsParamsArg {
6
6
  itemsStateAndParams: ItemsStateAndParams;
7
7
  plugins: PluginBase[];
8
8
  }
9
- declare type GetItemsParamsReturn = Record<string, StringParams>;
9
+ type GetItemsParamsReturn = Record<string, StringParams>;
10
10
  export declare function getItemsParams({ defaultGlobalParams, globalParams, config, itemsStateAndParams, plugins, }: GetItemsParamsArg): GetItemsParamsReturn;
11
11
  export declare function getItemsState({ config, itemsStateAndParams, }: {
12
12
  config: Config;
@@ -1,4 +1,4 @@
1
- export declare type Dictionary<T = unknown> = Record<string, T>;
1
+ export type Dictionary<T = unknown> = Record<string, T>;
2
2
  export interface StringParams extends Dictionary<string | string[]> {
3
3
  }
4
4
  export interface GlobalParams extends StringParams {
@@ -7,16 +7,16 @@ export interface QueueItem {
7
7
  id: string;
8
8
  tabId?: string;
9
9
  }
10
- export declare type StateAndParamsMetaData = {
10
+ export type StateAndParamsMetaData = {
11
11
  queue: QueueItem[];
12
12
  version: number;
13
13
  };
14
- export declare type StateAndParamsMeta = {
14
+ export type StateAndParamsMeta = {
15
15
  [META_KEY]: StateAndParamsMetaData;
16
16
  };
17
- export declare type ItemStateAndParams = {
17
+ export type ItemStateAndParams = {
18
18
  params?: StringParams;
19
19
  state?: ItemState;
20
20
  };
21
- export declare type ItemsStateAndParamsBase = Record<string, ItemStateAndParams>;
22
- export declare type ItemsStateAndParams = ItemsStateAndParamsBase | StateAndParamsMeta;
21
+ export type ItemsStateAndParamsBase = Record<string, ItemStateAndParams>;
22
+ export type ItemsStateAndParams = ItemsStateAndParamsBase | StateAndParamsMeta;
@@ -11,7 +11,7 @@ export interface Settings {
11
11
  isMobile?: boolean;
12
12
  menu?: Array<MenuItem>;
13
13
  }
14
- export declare type MenuItem = typeof MenuItems[keyof typeof MenuItems] | OverlayCustomControlItem;
14
+ export type MenuItem = typeof MenuItems[keyof typeof MenuItems] | OverlayCustomControlItem;
15
15
  export interface SettingsProps {
16
16
  autoupdateInterval: number;
17
17
  silentLoading: boolean;
@@ -4,4 +4,4 @@ export interface AddConfigItem extends Omit<ConfigItem, 'id' | 'namespace'> {
4
4
  namespace?: string;
5
5
  layout?: ConfigLayout;
6
6
  }
7
- export declare type SetConfigItem = ConfigItem | AddConfigItem;
7
+ export type SetConfigItem = ConfigItem | AddConfigItem;
@@ -1,8 +1,8 @@
1
- export declare type Lang = 'ru' | 'en';
1
+ export type Lang = 'ru' | 'en';
2
2
  interface Config {
3
3
  lang?: Lang;
4
4
  }
5
- declare type Subscriber = (config: Config) => void;
5
+ type Subscriber = (config: Config) => void;
6
6
  export declare const configure: (newConfig: Config) => void;
7
7
  export declare const subscribeConfigure: (sub: Subscriber) => () => void;
8
8
  export declare const getConfig: () => Config;
@@ -7,17 +7,17 @@ interface RegisterManagerDefaultLayout {
7
7
  minW: number;
8
8
  minH: number;
9
9
  }
10
- export declare type RegisterManagerPluginLayout = RegisterManagerDefaultLayout & PluginDefaultLayout;
10
+ export type RegisterManagerPluginLayout = RegisterManagerDefaultLayout & PluginDefaultLayout;
11
11
  export interface RegisterManagerPlugin extends Omit<Plugin, 'defaultLayout'> {
12
12
  defaultLayout: RegisterManagerDefaultLayout & Plugin['defaultLayout'];
13
13
  }
14
- export declare type RegisterManagerGridLayout = {
14
+ export type RegisterManagerGridLayout = {
15
15
  margin: [number, number];
16
16
  rowHeight: number;
17
17
  cols: number;
18
18
  containerPadding: [number, number];
19
19
  } & Settings['gridLayout'];
20
- export declare type RegisterManagerSettings = {
20
+ export type RegisterManagerSettings = {
21
21
  theme: string;
22
22
  } & Settings;
23
23
  export declare class RegisterManager {
@@ -21,11 +21,10 @@ interface DashKitDefaultProps {
21
21
  overlayControls?: Record<string, OverlayControlItem[]>;
22
22
  noOverlay?: boolean;
23
23
  draggableHandleClassName?: string;
24
- _EXPERIMENTAL_preventDoubleCompact?: boolean;
25
24
  }
26
25
  export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {
27
26
  }
28
- declare type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
27
+ type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
29
28
  export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
30
29
  static defaultProps: DashKitDefaultProps;
31
30
  static registerPlugins(...plugins: Plugin[]): void;
@@ -3,12 +3,10 @@ declare const _default: {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
4
  _onStateAndParamsChange: (stateAndParams: any) => void;
5
5
  render(): JSX.Element;
6
- context: any;
6
+ context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
8
8
  forceUpdate(callback?: (() => void) | undefined): void;
9
- readonly props: Readonly<any> & Readonly<{
10
- children?: React.ReactNode;
11
- }>;
9
+ readonly props: Readonly<any>;
12
10
  state: Readonly<any>;
13
11
  refs: {
14
12
  [key: string]: React.ReactInstance;
@@ -29,12 +27,10 @@ declare const _default: {
29
27
  shouldComponentUpdate(nextProps: any): boolean;
30
28
  _onStateAndParamsChange: (stateAndParams: any) => void;
31
29
  render(): JSX.Element;
32
- context: any;
30
+ context: unknown;
33
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
34
32
  forceUpdate(callback?: (() => void) | undefined): void;
35
- readonly props: Readonly<any> & Readonly<{
36
- children?: React.ReactNode;
37
- }>;
33
+ readonly props: Readonly<any>;
38
34
  state: Readonly<any>;
39
35
  refs: {
40
36
  [key: string]: React.ReactInstance;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { ConfigItem, PluginBase, StringParams } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
4
+ import type { RegisterManager } from '../../utils/register-manager';
4
5
  import './OverlayControls.css';
5
6
  export declare enum OverlayControlsPosition {
6
7
  TopRight = "top_right",
@@ -36,9 +37,17 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
36
37
  items?: OverlayControlItem[];
37
38
  overlayControls?: Record<string, OverlayControlItem[]>;
38
39
  }
40
+ type DashKitCtx = React.Context<{
41
+ registerManager: RegisterManager;
42
+ itemsParams: Record<string, StringParams>;
43
+ editItem: (item: ConfigItem) => void;
44
+ removeItem: (id: string) => void;
45
+ config: Config;
46
+ }>;
39
47
  declare class OverlayControls extends React.Component<OverlayControlsProps> {
40
48
  static contextType: React.Context<any>;
41
49
  static defaultProps: OverlayControlsDefaultProps;
50
+ context: React.ContextType<DashKitCtx>;
42
51
  render(): JSX.Element;
43
52
  private renderControlsItem;
44
53
  private getDropDownMenuItemConfig;
@@ -140,8 +140,7 @@ class OverlayControls extends React.Component {
140
140
  }
141
141
  renderDropdownMenu() {
142
142
  const { view, size } = this.props;
143
- const { registerManager } = this.context;
144
- const itemsParams = this.context.itemsParams;
143
+ const { registerManager, itemsParams } = this.context;
145
144
  const configItem = this.props.configItem;
146
145
  const itemParams = itemsParams[configItem.id];
147
146
  let menu = registerManager.settings.menu;
@@ -3,12 +3,10 @@ export function prepareItem(Component: any): {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
4
  _onStateAndParamsChange: (stateAndParams: any) => void;
5
5
  render(): JSX.Element;
6
- context: any;
6
+ context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
8
8
  forceUpdate(callback?: (() => void) | undefined): void;
9
- readonly props: Readonly<any> & Readonly<{
10
- children?: React.ReactNode;
11
- }>;
9
+ readonly props: Readonly<any>;
12
10
  state: Readonly<any>;
13
11
  refs: {
14
12
  [key: string]: React.ReactInstance;
@@ -29,12 +27,10 @@ export function prepareItem(Component: any): {
29
27
  shouldComponentUpdate(nextProps: any): boolean;
30
28
  _onStateAndParamsChange: (stateAndParams: any) => void;
31
29
  render(): JSX.Element;
32
- context: any;
30
+ context: unknown;
33
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
34
32
  forceUpdate(callback?: (() => void) | undefined): void;
35
- readonly props: Readonly<any> & Readonly<{
36
- children?: React.ReactNode;
37
- }>;
33
+ readonly props: Readonly<any>;
38
34
  state: Readonly<any>;
39
35
  refs: {
40
36
  [key: string]: React.ReactInstance;
@@ -3,8 +3,6 @@ import { DashKitContext } from '../context/DashKitContext';
3
3
  import { UpdateManager } from '../utils';
4
4
  import { getItemsParams, getItemsState } from '../shared';
5
5
  import isEqual from 'lodash/isEqual';
6
- import { utils as gridLayoutUtils } from 'react-grid-layout';
7
- const LAYOUT_COMPACTING_TYPE = 'vertical';
8
6
  function useMemoStateContext(props) {
9
7
  // так как мы не хотим хранить параметры виджета с активированной автовысотой в сторе и на сервере, актуальный
10
8
  // (видимый юзером в конкретный момент времени) лэйаут (массив объектов с данными о ширине, высоте,
@@ -34,22 +32,14 @@ function useMemoStateContext(props) {
34
32
  return Object.assign({}, item);
35
33
  }
36
34
  });
37
- // [experimental] if the _prevent Double Compact is enabled, then skip recalculate layout with auto height
38
- // после того, как у виждета активировали автовысоту и его параметр "h" изменился, это приведёт, также, и к
39
- // изменению параметра (координаты) "y" у элементов расположенных под ним, поэтому, после того, как
40
- // значения параметра "h" виджетов с активированной автовысотой были изменены, необходимо изменить и
41
- // координату "y" виджетов расположенных ниже
42
- const compactedLayout = props._EXPERIMENTAL_preventDoubleCompact
43
- ? currentInnerLayout
44
- : gridLayoutUtils.compact(currentInnerLayout, LAYOUT_COMPACTING_TYPE, props.registerManager.gridLayout.cols);
45
35
  const newConfig = UpdateManager.updateLayout({
46
- layout: compactedLayout,
36
+ layout: currentInnerLayout,
47
37
  config: props.config,
48
38
  });
49
39
  if (!isEqual(newConfig.layout, props.config.layout)) {
50
40
  onChange({ config: newConfig });
51
41
  }
52
- }, [props._EXPERIMENTAL_preventDoubleCompact, props.registerManager, props.config, onChange]);
42
+ }, [props.config, onChange]);
53
43
  const onItemRemove = React.useCallback((id) => {
54
44
  onChange(UpdateManager.removeItem({
55
45
  id,
@@ -6,7 +6,7 @@ declare enum LoadStatus {
6
6
  Success = "success",
7
7
  Fail = "fail"
8
8
  }
9
- export declare type PluginTextApiHandler = (data: {
9
+ export type PluginTextApiHandler = (data: {
10
10
  text: string;
11
11
  }) => Promise<{
12
12
  result: string;
@@ -41,11 +41,11 @@ export declare class PluginText extends React.PureComponent<PluginTextProps, Plu
41
41
  private onRetryClick;
42
42
  get withMarkdown(): boolean;
43
43
  }
44
- declare type PluginDataProps = Omit<PluginTextProps, 'apiHandler'>;
45
- export declare type PluginTextObjectSettings = {
44
+ type PluginDataProps = Omit<PluginTextProps, 'apiHandler'>;
45
+ export type PluginTextObjectSettings = {
46
46
  apiHandler?: PluginTextApiHandler;
47
47
  };
48
- export declare type PluginTextObject = Plugin<PluginDataProps> & {
48
+ export type PluginTextObject = Plugin<PluginDataProps> & {
49
49
  setSettings: (settings: PluginTextObjectSettings) => PluginTextObject;
50
50
  _apiHandler?: PluginTextApiHandler;
51
51
  };
@@ -6,7 +6,7 @@ export declare function prerenderItems({ items, plugins, }: {
6
6
  export declare function getItemsStateAndParamsMeta(itemsStateAndParams: ItemsStateAndParams): StateAndParamsMetaData | undefined;
7
7
  export declare function getCurrentVersion(itemsStateAndParams: ItemsStateAndParams): number;
8
8
  export declare function isItemWithTabs(item: Pick<ConfigItem, 'data'>): item is Pick<ConfigItemWithTabs, 'data'>;
9
- export declare type FormedQueueData = {
9
+ export type FormedQueueData = {
10
10
  id: string;
11
11
  namespace: string;
12
12
  params: StringParams;
@@ -6,7 +6,7 @@ export interface GetItemsParamsArg {
6
6
  itemsStateAndParams: ItemsStateAndParams;
7
7
  plugins: PluginBase[];
8
8
  }
9
- declare type GetItemsParamsReturn = Record<string, StringParams>;
9
+ type GetItemsParamsReturn = Record<string, StringParams>;
10
10
  export declare function getItemsParams({ defaultGlobalParams, globalParams, config, itemsStateAndParams, plugins, }: GetItemsParamsArg): GetItemsParamsReturn;
11
11
  export declare function getItemsState({ config, itemsStateAndParams, }: {
12
12
  config: Config;
@@ -1,4 +1,4 @@
1
- export declare type Dictionary<T = unknown> = Record<string, T>;
1
+ export type Dictionary<T = unknown> = Record<string, T>;
2
2
  export interface StringParams extends Dictionary<string | string[]> {
3
3
  }
4
4
  export interface GlobalParams extends StringParams {
@@ -7,16 +7,16 @@ export interface QueueItem {
7
7
  id: string;
8
8
  tabId?: string;
9
9
  }
10
- export declare type StateAndParamsMetaData = {
10
+ export type StateAndParamsMetaData = {
11
11
  queue: QueueItem[];
12
12
  version: number;
13
13
  };
14
- export declare type StateAndParamsMeta = {
14
+ export type StateAndParamsMeta = {
15
15
  [META_KEY]: StateAndParamsMetaData;
16
16
  };
17
- export declare type ItemStateAndParams = {
17
+ export type ItemStateAndParams = {
18
18
  params?: StringParams;
19
19
  state?: ItemState;
20
20
  };
21
- export declare type ItemsStateAndParamsBase = Record<string, ItemStateAndParams>;
22
- export declare type ItemsStateAndParams = ItemsStateAndParamsBase | StateAndParamsMeta;
21
+ export type ItemsStateAndParamsBase = Record<string, ItemStateAndParams>;
22
+ export type ItemsStateAndParams = ItemsStateAndParamsBase | StateAndParamsMeta;
@@ -11,7 +11,7 @@ export interface Settings {
11
11
  isMobile?: boolean;
12
12
  menu?: Array<MenuItem>;
13
13
  }
14
- export declare type MenuItem = typeof MenuItems[keyof typeof MenuItems] | OverlayCustomControlItem;
14
+ export type MenuItem = typeof MenuItems[keyof typeof MenuItems] | OverlayCustomControlItem;
15
15
  export interface SettingsProps {
16
16
  autoupdateInterval: number;
17
17
  silentLoading: boolean;
@@ -4,4 +4,4 @@ export interface AddConfigItem extends Omit<ConfigItem, 'id' | 'namespace'> {
4
4
  namespace?: string;
5
5
  layout?: ConfigLayout;
6
6
  }
7
- export declare type SetConfigItem = ConfigItem | AddConfigItem;
7
+ export type SetConfigItem = ConfigItem | AddConfigItem;
@@ -1,8 +1,8 @@
1
- export declare type Lang = 'ru' | 'en';
1
+ export type Lang = 'ru' | 'en';
2
2
  interface Config {
3
3
  lang?: Lang;
4
4
  }
5
- declare type Subscriber = (config: Config) => void;
5
+ type Subscriber = (config: Config) => void;
6
6
  export declare const configure: (newConfig: Config) => void;
7
7
  export declare const subscribeConfigure: (sub: Subscriber) => () => void;
8
8
  export declare const getConfig: () => Config;
@@ -7,17 +7,17 @@ interface RegisterManagerDefaultLayout {
7
7
  minW: number;
8
8
  minH: number;
9
9
  }
10
- export declare type RegisterManagerPluginLayout = RegisterManagerDefaultLayout & PluginDefaultLayout;
10
+ export type RegisterManagerPluginLayout = RegisterManagerDefaultLayout & PluginDefaultLayout;
11
11
  export interface RegisterManagerPlugin extends Omit<Plugin, 'defaultLayout'> {
12
12
  defaultLayout: RegisterManagerDefaultLayout & Plugin['defaultLayout'];
13
13
  }
14
- export declare type RegisterManagerGridLayout = {
14
+ export type RegisterManagerGridLayout = {
15
15
  margin: [number, number];
16
16
  rowHeight: number;
17
17
  cols: number;
18
18
  containerPadding: [number, number];
19
19
  } & Settings['gridLayout'];
20
- export declare type RegisterManagerSettings = {
20
+ export type RegisterManagerSettings = {
21
21
  theme: string;
22
22
  } & Settings;
23
23
  export declare class RegisterManager {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,9 +28,9 @@
28
28
  "test": "jest",
29
29
  "clean": "gulp clean",
30
30
  "build": "gulp",
31
- "start": "start-storybook -p 7120",
31
+ "start": "env TS_NODE_PROJECT=.storybook/tsconfig.json start-storybook -p 7120",
32
32
  "typecheck": "tsc --noEmit",
33
- "build-storybook": "build-storybook -c .storybook -o storybook-static",
33
+ "build-storybook": "env TS_NODE_PROJECT=.storybook/tsconfig.json build-storybook -c .storybook -o storybook-static",
34
34
  "prepare": "husky install",
35
35
  "prepublishOnly": "npm run lint && npm run test && npm run build"
36
36
  },
@@ -41,25 +41,25 @@
41
41
  "react-grid-layout": "^1.3.4"
42
42
  },
43
43
  "peerDependencies": {
44
- "@gravity-ui/uikit": "^3.0.0",
44
+ "@gravity-ui/uikit": "^4.0.0",
45
45
  "bem-cn-lite": "^4.0.0",
46
- "react": "^16.0.0 || ^17.0.0"
46
+ "react": "^16.8.0 || ^17 || ^18"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@commitlint/cli": "^17.0.3",
50
50
  "@commitlint/config-conventional": "^17.0.3",
51
+ "@gravity-ui/eslint-config": "^1.0.2",
52
+ "@gravity-ui/prettier-config": "^1.0.1",
53
+ "@gravity-ui/stylelint-config": "^1.0.1",
54
+ "@gravity-ui/tsconfig": "^1.0.0",
55
+ "@gravity-ui/uikit": "^4.0.5",
51
56
  "@storybook/addon-essentials": "^6.5.9",
52
57
  "@storybook/preset-scss": "^1.0.3",
53
58
  "@storybook/react": "^6.5.9",
54
59
  "@types/enzyme": "^3.10.8",
55
60
  "@types/jest": "^26.0.20",
56
61
  "@types/lodash": "^4.14.170",
57
- "@types/react": "^17.0.47",
58
- "@gravity-ui/eslint-config": "^1.0.2",
59
- "@gravity-ui/prettier-config": "^1.0.1",
60
- "@gravity-ui/stylelint-config": "^1.0.1",
61
- "@gravity-ui/tsconfig": "^1.0.0",
62
- "@gravity-ui/uikit": "^3.0.0",
62
+ "@types/react": "^18.0.27",
63
63
  "babel-jest": "^26.6.3",
64
64
  "bem-cn-lite": "^4.0.0",
65
65
  "copyfiles": "^2.4.1",
@@ -78,15 +78,15 @@
78
78
  "npm-run-all": "^4.1.5",
79
79
  "postcss": "^8.4.12",
80
80
  "prettier": "^2.6.0",
81
- "react": "^17.0.2",
81
+ "react": "^18.2.0",
82
82
  "react-docgen-typescript": "^2.2.2",
83
- "react-dom": "^17.0.2",
83
+ "react-dom": "^18.2.0",
84
84
  "rimraf": "^3.0.2",
85
85
  "sass": "^1.53.0",
86
86
  "sass-loader": "^10.3.1",
87
87
  "stylelint": "^14.6.0",
88
88
  "ts-jest": "^26.5.3",
89
- "typescript": "^4.7.4"
89
+ "typescript": "^4.9.5"
90
90
  },
91
91
  "husky": {
92
92
  "hooks": {