@gravity-ui/dashkit 8.20.0 → 8.20.2

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.
@@ -43,6 +43,7 @@ export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaul
43
43
  type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
44
44
  export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
45
45
  static defaultProps: DashKitDefaultProps;
46
+ static contextType: React.Context<any>;
46
47
  static registerPlugins(...plugins: Plugin[]): void;
47
48
  static reloadPlugins(...plugins: Plugin[]): void;
48
49
  static setSettings(settings: Settings): void;
@@ -6,7 +6,9 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const noop_1 = tslib_1.__importDefault(require("lodash/noop"));
7
7
  const pick_1 = tslib_1.__importDefault(require("lodash/pick"));
8
8
  const constants_1 = require("../../constants");
9
+ const DashKitContext_1 = require("../../context/DashKitContext");
9
10
  const utils_1 = require("../../utils");
11
+ const DashKitDnDWrapper_1 = require("../DashKitDnDWrapper/DashKitDnDWrapper");
10
12
  const DashKitView_1 = tslib_1.__importDefault(require("../DashKitView/DashKitView"));
11
13
  const registerManager = new utils_1.RegisterManager();
12
14
  const getReflowProps = (props) => Object.assign({ compactType: 'vertical', cols: 36 }, (0, pick_1.default)(props, 'cols', 'maxRows', 'compactType'));
@@ -79,7 +81,11 @@ class DashKit extends react_1.default.PureComponent {
79
81
  });
80
82
  }
81
83
  render() {
82
- return react_1.default.createElement(DashKitView_1.default, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props));
84
+ const content = (react_1.default.createElement(DashKitView_1.default, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props)));
85
+ if (!this.context && this.props.groups) {
86
+ return react_1.default.createElement(DashKitDnDWrapper_1.DashKitDnDWrapper, null, content);
87
+ }
88
+ return content;
83
89
  }
84
90
  getItemsMeta() {
85
91
  var _a;
@@ -102,3 +108,4 @@ DashKit.defaultProps = {
102
108
  noOverlay: false,
103
109
  focusable: false,
104
110
  };
111
+ DashKit.contextType = DashKitContext_1.DashKitDnDContext;
@@ -281,7 +281,7 @@ function useMemoStateContext(props) {
281
281
  h: maxH ? Math.min(h, maxH) : h,
282
282
  w: maxW ? Math.min(w, maxW) : w,
283
283
  };
284
- if ((onDropDragOverContext === null || onDropDragOverContext === void 0 ? void 0 : onDropDragOverContext(Object.assign(Object.assign(Object.assign({}, sharedItem), itemLayout), { parent: group }), sharedItem !== null && sharedItem !== void 0 ? sharedItem : null)) === false) {
284
+ if ((onDropDragOverContext === null || onDropDragOverContext === void 0 ? void 0 : onDropDragOverContext(Object.assign(Object.assign(Object.assign({}, sharedItem), itemLayout), { parent: group, type: (sharedItem === null || sharedItem === void 0 ? void 0 : sharedItem.type) || (dragOverPlugin === null || dragOverPlugin === void 0 ? void 0 : dragOverPlugin.type) }), sharedItem !== null && sharedItem !== void 0 ? sharedItem : null)) === false) {
285
285
  return false;
286
286
  }
287
287
  return itemLayout;
@@ -43,6 +43,7 @@ export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaul
43
43
  type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
44
44
  export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
45
45
  static defaultProps: DashKitDefaultProps;
46
+ static contextType: React.Context<any>;
46
47
  static registerPlugins(...plugins: Plugin[]): void;
47
48
  static reloadPlugins(...plugins: Plugin[]): void;
48
49
  static setSettings(settings: Settings): void;
@@ -2,7 +2,9 @@ import React from 'react';
2
2
  import noop from 'lodash/noop';
3
3
  import pick from 'lodash/pick';
4
4
  import { DEFAULT_GROUP, DEFAULT_NAMESPACE } from '../../constants';
5
+ import { DashKitDnDContext } from '../../context/DashKitContext';
5
6
  import { RegisterManager, UpdateManager, reflowLayout } from '../../utils';
7
+ import { DashKitDnDWrapper } from '../DashKitDnDWrapper/DashKitDnDWrapper';
6
8
  import DashKitView from '../DashKitView/DashKitView';
7
9
  const registerManager = new RegisterManager();
8
10
  const getReflowProps = (props) => Object.assign({ compactType: 'vertical', cols: 36 }, pick(props, 'cols', 'maxRows', 'compactType'));
@@ -75,7 +77,11 @@ export class DashKit extends React.PureComponent {
75
77
  });
76
78
  }
77
79
  render() {
78
- return React.createElement(DashKitView, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props));
80
+ const content = (React.createElement(DashKitView, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props)));
81
+ if (!this.context && this.props.groups) {
82
+ return React.createElement(DashKitDnDWrapper, null, content);
83
+ }
84
+ return content;
79
85
  }
80
86
  getItemsMeta() {
81
87
  var _a;
@@ -97,3 +103,4 @@ DashKit.defaultProps = {
97
103
  noOverlay: false,
98
104
  focusable: false,
99
105
  };
106
+ DashKit.contextType = DashKitDnDContext;
@@ -278,7 +278,7 @@ function useMemoStateContext(props) {
278
278
  h: maxH ? Math.min(h, maxH) : h,
279
279
  w: maxW ? Math.min(w, maxW) : w,
280
280
  };
281
- if ((onDropDragOverContext === null || onDropDragOverContext === void 0 ? void 0 : onDropDragOverContext(Object.assign(Object.assign(Object.assign({}, sharedItem), itemLayout), { parent: group }), sharedItem !== null && sharedItem !== void 0 ? sharedItem : null)) === false) {
281
+ if ((onDropDragOverContext === null || onDropDragOverContext === void 0 ? void 0 : onDropDragOverContext(Object.assign(Object.assign(Object.assign({}, sharedItem), itemLayout), { parent: group, type: (sharedItem === null || sharedItem === void 0 ? void 0 : sharedItem.type) || (dragOverPlugin === null || dragOverPlugin === void 0 ? void 0 : dragOverPlugin.type) }), sharedItem !== null && sharedItem !== void 0 ? sharedItem : null)) === false) {
282
282
  return false;
283
283
  }
284
284
  return itemLayout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "8.20.0",
3
+ "version": "8.20.2",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {