@gravity-ui/dashkit 5.5.0 → 5.6.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.6.1](https://github.com/gravity-ui/dashkit/compare/v5.6.0...v5.6.1) (2023-06-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **react-grid-layout:** fixed react-grid-layout issue ([#59](https://github.com/gravity-ui/dashkit/issues/59)) ([bdb3f87](https://github.com/gravity-ui/dashkit/commit/bdb3f87731cf82b8267c913bb0010c65f7014018))
9
+
10
+ ## [5.6.0](https://github.com/gravity-ui/dashkit/compare/v5.5.0...v5.6.0) (2023-04-18)
11
+
12
+
13
+ ### Features
14
+
15
+ * add item state to overlay dropdown menu action handler ([#57](https://github.com/gravity-ui/dashkit/issues/57)) ([78b13fa](https://github.com/gravity-ui/dashkit/commit/78b13fa4107e94abd93c6e469a36840b61b6a10a))
16
+
3
17
  ## [5.5.0](https://github.com/gravity-ui/dashkit/compare/v5.4.0...v5.5.0) (2023-04-17)
4
18
 
5
19
 
@@ -10,7 +10,7 @@ const OverlayControls_1 = tslib_1.__importDefault(require("../OverlayControls/Ov
10
10
  const b = (0, bem_cn_lite_1.default)('dashkit-grid-item');
11
11
  class GridItem extends react_1.default.PureComponent {
12
12
  renderOverlay() {
13
- const { overlayControls } = this.props;
13
+ const { overlayControls, isDragging } = this.props;
14
14
  const { editMode } = this.context;
15
15
  if (!editMode || this.props.item.data._editActive) {
16
16
  return null;
@@ -19,7 +19,7 @@ class GridItem extends react_1.default.PureComponent {
19
19
  const controls = overlayControls && overlayControls[item.type];
20
20
  return (react_1.default.createElement(react_1.default.Fragment, null,
21
21
  react_1.default.createElement("div", { className: b('overlay') }),
22
- react_1.default.createElement(OverlayControls_1.default, { configItem: item, items: controls, overlayControls: overlayControls })));
22
+ react_1.default.createElement(OverlayControls_1.default, { configItem: item, items: controls, isDragging: isDragging, overlayControls: overlayControls })));
23
23
  }
24
24
  render() {
25
25
  // из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams, Config, ItemState } from '../../shared';
4
4
  import type { RegisterManager } from '../../utils/register-manager';
5
5
  export declare enum OverlayControlsPosition {
6
6
  TopRight = "top_right",
@@ -23,7 +23,7 @@ export interface OverlayCustomControlItem {
23
23
  title?: string;
24
24
  icon?: MenuItemProps['icon'];
25
25
  iconSize?: number | string;
26
- handler?: (item: ConfigItem, params: StringParams) => void;
26
+ handler?: (item: ConfigItem, params: StringParams, state: ItemState) => void;
27
27
  visible?: (item: ConfigItem) => boolean;
28
28
  className?: string;
29
29
  qa?: string;
@@ -34,6 +34,7 @@ interface OverlayControlsDefaultProps {
34
34
  size: ButtonSize;
35
35
  }
36
36
  interface OverlayControlsProps extends OverlayControlsDefaultProps {
37
+ isDragging?: boolean;
37
38
  configItem: ConfigItem;
38
39
  items?: OverlayControlItem[];
39
40
  overlayControls?: Record<string, OverlayControlItem[]>;
@@ -41,6 +42,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
41
42
  type DashKitCtx = React.Context<{
42
43
  registerManager: RegisterManager;
43
44
  itemsParams: Record<string, StringParams>;
45
+ itemsState: Record<string, ItemState>;
44
46
  editItem: (item: ConfigItem) => void;
45
47
  removeItem: (id: string) => void;
46
48
  config: Config;
@@ -76,6 +76,11 @@ class OverlayControls extends react_1.default.Component {
76
76
  this.context.editItem(this.props.configItem);
77
77
  };
78
78
  this.onRemoveItem = () => {
79
+ // Otherwise it will crush an app dute to the issue in react-grid-layout
80
+ // https://github.com/react-grid-layout/react-grid-layout/issues/1836
81
+ if (this.props.isDragging) {
82
+ return;
83
+ }
79
84
  const { id } = this.props.configItem;
80
85
  this.context.removeItem(id);
81
86
  };
@@ -143,9 +148,10 @@ class OverlayControls extends react_1.default.Component {
143
148
  }
144
149
  renderDropdownMenu() {
145
150
  const { view, size } = this.props;
146
- const { registerManager, itemsParams } = this.context;
151
+ const { registerManager, itemsParams, itemsState } = this.context;
147
152
  const configItem = this.props.configItem;
148
153
  const itemParams = itemsParams[configItem.id];
154
+ const itemState = itemsState[configItem.id];
149
155
  let menu = registerManager.settings.menu;
150
156
  if (!menu.length) {
151
157
  menu = DEFAULT_DROPDOWN_MENU;
@@ -164,7 +170,7 @@ class OverlayControls extends react_1.default.Component {
164
170
  }
165
171
  const itemHandler = item.handler;
166
172
  const itemAction = typeof itemHandler === 'function'
167
- ? () => itemHandler(configItem, itemParams)
173
+ ? () => itemHandler(configItem, itemParams, itemState)
168
174
  : ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
169
175
  return {
170
176
  text: item.title || (0, i18n_1.default)(item.id),
@@ -8,7 +8,7 @@ import OverlayControls from '../OverlayControls/OverlayControls';
8
8
  const b = block('dashkit-grid-item');
9
9
  class GridItem extends React.PureComponent {
10
10
  renderOverlay() {
11
- const { overlayControls } = this.props;
11
+ const { overlayControls, isDragging } = this.props;
12
12
  const { editMode } = this.context;
13
13
  if (!editMode || this.props.item.data._editActive) {
14
14
  return null;
@@ -17,7 +17,7 @@ class GridItem extends React.PureComponent {
17
17
  const controls = overlayControls && overlayControls[item.type];
18
18
  return (React.createElement(React.Fragment, null,
19
19
  React.createElement("div", { className: b('overlay') }),
20
- React.createElement(OverlayControls, { configItem: item, items: controls, overlayControls: overlayControls })));
20
+ React.createElement(OverlayControls, { configItem: item, items: controls, isDragging: isDragging, overlayControls: overlayControls })));
21
21
  }
22
22
  render() {
23
23
  // из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams, Config, ItemState } from '../../shared';
4
4
  import type { RegisterManager } from '../../utils/register-manager';
5
5
  import './OverlayControls.css';
6
6
  export declare enum OverlayControlsPosition {
@@ -24,7 +24,7 @@ export interface OverlayCustomControlItem {
24
24
  title?: string;
25
25
  icon?: MenuItemProps['icon'];
26
26
  iconSize?: number | string;
27
- handler?: (item: ConfigItem, params: StringParams) => void;
27
+ handler?: (item: ConfigItem, params: StringParams, state: ItemState) => void;
28
28
  visible?: (item: ConfigItem) => boolean;
29
29
  className?: string;
30
30
  qa?: string;
@@ -35,6 +35,7 @@ interface OverlayControlsDefaultProps {
35
35
  size: ButtonSize;
36
36
  }
37
37
  interface OverlayControlsProps extends OverlayControlsDefaultProps {
38
+ isDragging?: boolean;
38
39
  configItem: ConfigItem;
39
40
  items?: OverlayControlItem[];
40
41
  overlayControls?: Record<string, OverlayControlItem[]>;
@@ -42,6 +43,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
42
43
  type DashKitCtx = React.Context<{
43
44
  registerManager: RegisterManager;
44
45
  itemsParams: Record<string, StringParams>;
46
+ itemsState: Record<string, ItemState>;
45
47
  editItem: (item: ConfigItem) => void;
46
48
  removeItem: (id: string) => void;
47
49
  config: Config;
@@ -73,6 +73,11 @@ class OverlayControls extends React.Component {
73
73
  this.context.editItem(this.props.configItem);
74
74
  };
75
75
  this.onRemoveItem = () => {
76
+ // Otherwise it will crush an app dute to the issue in react-grid-layout
77
+ // https://github.com/react-grid-layout/react-grid-layout/issues/1836
78
+ if (this.props.isDragging) {
79
+ return;
80
+ }
76
81
  const { id } = this.props.configItem;
77
82
  this.context.removeItem(id);
78
83
  };
@@ -140,9 +145,10 @@ class OverlayControls extends React.Component {
140
145
  }
141
146
  renderDropdownMenu() {
142
147
  const { view, size } = this.props;
143
- const { registerManager, itemsParams } = this.context;
148
+ const { registerManager, itemsParams, itemsState } = this.context;
144
149
  const configItem = this.props.configItem;
145
150
  const itemParams = itemsParams[configItem.id];
151
+ const itemState = itemsState[configItem.id];
146
152
  let menu = registerManager.settings.menu;
147
153
  if (!menu.length) {
148
154
  menu = DEFAULT_DROPDOWN_MENU;
@@ -161,7 +167,7 @@ class OverlayControls extends React.Component {
161
167
  }
162
168
  const itemHandler = item.handler;
163
169
  const itemAction = typeof itemHandler === 'function'
164
- ? () => itemHandler(configItem, itemParams)
170
+ ? () => itemHandler(configItem, itemParams, itemState)
165
171
  : ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
166
172
  return {
167
173
  text: item.title || i18n(item.id),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "5.5.0",
3
+ "version": "5.6.1",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {