@gravity-ui/dashkit 8.19.0 → 8.19.1-beta.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/build/cjs/components/GridItem/GridItem.js +2 -1
- package/build/cjs/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/cjs/components/GridLayout/GridLayout.js +4 -4
- package/build/cjs/components/Item/Item.d.ts +1 -0
- package/build/cjs/components/OverlayControls/OverlayControls.js +1 -1
- package/build/cjs/hocs/prepareItem.d.ts +1 -0
- package/build/cjs/hocs/prepareItem.js +11 -3
- package/build/esm/components/GridItem/GridItem.js +2 -1
- package/build/esm/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/esm/components/GridLayout/GridLayout.js +4 -4
- package/build/esm/components/Item/Item.d.ts +1 -0
- package/build/esm/components/OverlayControls/OverlayControls.js +1 -1
- package/build/esm/hocs/prepareItem.d.ts +1 -0
- package/build/esm/hocs/prepareItem.js +11 -3
- package/package.json +1 -1
|
@@ -126,13 +126,14 @@ class GridItem extends react_1.default.PureComponent {
|
|
|
126
126
|
}
|
|
127
127
|
: {})),
|
|
128
128
|
react_1.default.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
|
|
129
|
-
react_1.default.createElement(Item_1.default, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender })),
|
|
129
|
+
react_1.default.createElement(Item_1.default, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender, gridLayout: this.props.gridLayout })),
|
|
130
130
|
!noOverlay && this.renderOverlay(),
|
|
131
131
|
preparedChildren));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
GridItem.propTypes = {
|
|
135
135
|
adjustWidgetLayout: prop_types_1.default.func.isRequired,
|
|
136
|
+
gridLayout: prop_types_1.default.object,
|
|
136
137
|
id: prop_types_1.default.string,
|
|
137
138
|
item: prop_types_1.default.object,
|
|
138
139
|
isDragging: prop_types_1.default.bool,
|
|
@@ -66,7 +66,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
66
66
|
_onExternalDrop: (group: any, newLayout: any, item: any, e: any) => void;
|
|
67
67
|
_onDrop: (group: any, newLayout: any, item: any, e: any) => false | undefined;
|
|
68
68
|
_onDropDragOver: (group: any, e: any) => any;
|
|
69
|
-
renderTemporaryPlaceholder(): JSX.Element | null;
|
|
69
|
+
renderTemporaryPlaceholder(gridLayout: any): JSX.Element | null;
|
|
70
70
|
renderGroup(group: any, renderLayout: any, renderItems: any, offset: number | undefined, groupGridProperties: any): JSX.Element;
|
|
71
71
|
render(): any;
|
|
72
72
|
}
|
|
@@ -400,14 +400,14 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
renderTemporaryPlaceholder() {
|
|
403
|
+
renderTemporaryPlaceholder(gridLayout) {
|
|
404
404
|
const { temporaryLayout, noOverlay, draggableHandleClassName } = this.context;
|
|
405
405
|
if (!temporaryLayout || !temporaryLayout.dragProps) {
|
|
406
406
|
return null;
|
|
407
407
|
}
|
|
408
408
|
const id = constants_1.TEMPORARY_ITEM_ID;
|
|
409
409
|
const { type } = temporaryLayout.dragProps;
|
|
410
|
-
return (react_1.default.createElement(GridItem_1.default, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout.data, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName) }));
|
|
410
|
+
return (react_1.default.createElement(GridItem_1.default, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout.data, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), gridLayout: gridLayout }));
|
|
411
411
|
}
|
|
412
412
|
renderGroup(group, renderLayout, renderItems, offset = 0, groupGridProperties) {
|
|
413
413
|
const { registerManager, editMode, noOverlay, focusable, draggableHandleClassName, outerDnDEnable, onItemMountChange, onItemRender, } = this.context;
|
|
@@ -441,9 +441,9 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
441
441
|
const itemNoOverlay = hasOwnGroupProperties && 'noOverlay' in properties
|
|
442
442
|
? properties.noOverlay
|
|
443
443
|
: noOverlay;
|
|
444
|
-
return (react_1.default.createElement(GridItem_1.default, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: keyId, id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender }));
|
|
444
|
+
return (react_1.default.createElement(GridItem_1.default, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: keyId, id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender, gridLayout: properties }));
|
|
445
445
|
}),
|
|
446
|
-
this.renderTemporaryPlaceholder()));
|
|
446
|
+
this.renderTemporaryPlaceholder(properties)));
|
|
447
447
|
}
|
|
448
448
|
render() {
|
|
449
449
|
const { config, groups, editMode, context } = this.context;
|
|
@@ -52,6 +52,7 @@ declare const _default: {
|
|
|
52
52
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
53
53
|
};
|
|
54
54
|
propTypes: {
|
|
55
|
+
gridLayout: PropTypes.Requireable<object>;
|
|
55
56
|
adjustWidgetLayout: PropTypes.Validator<(...args: any[]) => any>;
|
|
56
57
|
layout: PropTypes.Requireable<any[]>;
|
|
57
58
|
id: PropTypes.Requireable<string>;
|
|
@@ -107,7 +107,7 @@ class OverlayControls extends react_1.default.Component {
|
|
|
107
107
|
}
|
|
108
108
|
const getPreparedCopyItemOptions = (_d = (_c = this.context) === null || _c === void 0 ? void 0 : _c.getPreparedCopyItemOptions) !== null && _d !== void 0 ? _d : (_e = this.context.context) === null || _e === void 0 ? void 0 : _e.getPreparedCopyItemOptions;
|
|
109
109
|
if (typeof getPreparedCopyItemOptions === 'function') {
|
|
110
|
-
options =
|
|
110
|
+
options = getPreparedCopyItemOptions(options);
|
|
111
111
|
}
|
|
112
112
|
try {
|
|
113
113
|
localStorage.setItem(constants_1.COPIED_WIDGET_STORE_KEY, JSON.stringify(options));
|
|
@@ -52,6 +52,7 @@ export function prepareItem(Component: any): {
|
|
|
52
52
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
53
53
|
};
|
|
54
54
|
propTypes: {
|
|
55
|
+
gridLayout: PropTypes.Requireable<object>;
|
|
55
56
|
adjustWidgetLayout: PropTypes.Validator<(...args: any[]) => any>;
|
|
56
57
|
layout: PropTypes.Requireable<any[]>;
|
|
57
58
|
id: PropTypes.Requireable<string>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.prepareItem = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
|
|
6
7
|
const prop_types_1 = tslib_1.__importDefault(require("prop-types"));
|
|
7
8
|
const DashKitContext_1 = require("../context/DashKitContext");
|
|
8
9
|
function prepareItem(Component) {
|
|
@@ -15,7 +16,7 @@ function prepareItem(Component) {
|
|
|
15
16
|
};
|
|
16
17
|
this._currentRenderProps = {};
|
|
17
18
|
this.getRenderProps = () => {
|
|
18
|
-
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder } = this.props;
|
|
19
|
+
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder, gridLayout } = this.props;
|
|
19
20
|
const { itemsState, itemsParams, registerManager, settings, context, editMode } = this.context;
|
|
20
21
|
const { data, defaults, namespace } = item;
|
|
21
22
|
const rendererProps = {
|
|
@@ -32,11 +33,17 @@ function prepareItem(Component) {
|
|
|
32
33
|
settings,
|
|
33
34
|
context,
|
|
34
35
|
layout,
|
|
35
|
-
gridLayout: registerManager.gridLayout,
|
|
36
|
+
gridLayout: gridLayout || registerManager.gridLayout,
|
|
36
37
|
adjustWidgetLayout,
|
|
37
38
|
isPlaceholder,
|
|
38
39
|
};
|
|
39
|
-
const changedProp = Object.entries(rendererProps).find(([key, value]) =>
|
|
40
|
+
const changedProp = Object.entries(rendererProps).find(([key, value]) => {
|
|
41
|
+
// Checking gridLayoout deep as groups gridProperties method has tendancy to creat new objects
|
|
42
|
+
if (key === 'gridLayout') {
|
|
43
|
+
return !(0, isEqual_1.default)(this._currentRenderProps[key], value);
|
|
44
|
+
}
|
|
45
|
+
return this._currentRenderProps[key] !== value;
|
|
46
|
+
});
|
|
40
47
|
if (changedProp) {
|
|
41
48
|
this._currentRenderProps = rendererProps;
|
|
42
49
|
}
|
|
@@ -62,6 +69,7 @@ function prepareItem(Component) {
|
|
|
62
69
|
}
|
|
63
70
|
},
|
|
64
71
|
_a.propTypes = {
|
|
72
|
+
gridLayout: prop_types_1.default.object,
|
|
65
73
|
adjustWidgetLayout: prop_types_1.default.func.isRequired,
|
|
66
74
|
layout: prop_types_1.default.array,
|
|
67
75
|
id: prop_types_1.default.string,
|
|
@@ -124,13 +124,14 @@ class GridItem extends React.PureComponent {
|
|
|
124
124
|
}
|
|
125
125
|
: {})),
|
|
126
126
|
React.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
|
|
127
|
-
React.createElement(Item, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender })),
|
|
127
|
+
React.createElement(Item, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, isPlaceholder: isPlaceholder, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef, onItemMountChange: this.props.onItemMountChange, onItemRender: this.props.onItemRender, gridLayout: this.props.gridLayout })),
|
|
128
128
|
!noOverlay && this.renderOverlay(),
|
|
129
129
|
preparedChildren));
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
GridItem.propTypes = {
|
|
133
133
|
adjustWidgetLayout: PropTypes.func.isRequired,
|
|
134
|
+
gridLayout: PropTypes.object,
|
|
134
135
|
id: PropTypes.string,
|
|
135
136
|
item: PropTypes.object,
|
|
136
137
|
isDragging: PropTypes.bool,
|
|
@@ -66,7 +66,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
66
66
|
_onExternalDrop: (group: any, newLayout: any, item: any, e: any) => void;
|
|
67
67
|
_onDrop: (group: any, newLayout: any, item: any, e: any) => false | undefined;
|
|
68
68
|
_onDropDragOver: (group: any, e: any) => any;
|
|
69
|
-
renderTemporaryPlaceholder(): JSX.Element | null;
|
|
69
|
+
renderTemporaryPlaceholder(gridLayout: any): JSX.Element | null;
|
|
70
70
|
renderGroup(group: any, renderLayout: any, renderItems: any, offset: number | undefined, groupGridProperties: any): JSX.Element;
|
|
71
71
|
render(): any;
|
|
72
72
|
}
|
|
@@ -397,14 +397,14 @@ class GridLayout extends React.PureComponent {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
renderTemporaryPlaceholder() {
|
|
400
|
+
renderTemporaryPlaceholder(gridLayout) {
|
|
401
401
|
const { temporaryLayout, noOverlay, draggableHandleClassName } = this.context;
|
|
402
402
|
if (!temporaryLayout || !temporaryLayout.dragProps) {
|
|
403
403
|
return null;
|
|
404
404
|
}
|
|
405
405
|
const id = TEMPORARY_ITEM_ID;
|
|
406
406
|
const { type } = temporaryLayout.dragProps;
|
|
407
|
-
return (React.createElement(GridItem, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout.data, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName) }));
|
|
407
|
+
return (React.createElement(GridItem, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout.data, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), gridLayout: gridLayout }));
|
|
408
408
|
}
|
|
409
409
|
renderGroup(group, renderLayout, renderItems, offset = 0, groupGridProperties) {
|
|
410
410
|
const { registerManager, editMode, noOverlay, focusable, draggableHandleClassName, outerDnDEnable, onItemMountChange, onItemRender, } = this.context;
|
|
@@ -438,9 +438,9 @@ class GridLayout extends React.PureComponent {
|
|
|
438
438
|
const itemNoOverlay = hasOwnGroupProperties && 'noOverlay' in properties
|
|
439
439
|
? properties.noOverlay
|
|
440
440
|
: noOverlay;
|
|
441
|
-
return (React.createElement(GridItem, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: keyId, id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender }));
|
|
441
|
+
return (React.createElement(GridItem, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: keyId, id: keyId, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: isDragging, isDraggedOut: isDraggedOut, noOverlay: itemNoOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender, gridLayout: properties }));
|
|
442
442
|
}),
|
|
443
|
-
this.renderTemporaryPlaceholder()));
|
|
443
|
+
this.renderTemporaryPlaceholder(properties)));
|
|
444
444
|
}
|
|
445
445
|
render() {
|
|
446
446
|
const { config, groups, editMode, context } = this.context;
|
|
@@ -52,6 +52,7 @@ declare const _default: {
|
|
|
52
52
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
53
53
|
};
|
|
54
54
|
propTypes: {
|
|
55
|
+
gridLayout: PropTypes.Requireable<object>;
|
|
55
56
|
adjustWidgetLayout: PropTypes.Validator<(...args: any[]) => any>;
|
|
56
57
|
layout: PropTypes.Requireable<any[]>;
|
|
57
58
|
id: PropTypes.Requireable<string>;
|
|
@@ -104,7 +104,7 @@ class OverlayControls extends React.Component {
|
|
|
104
104
|
}
|
|
105
105
|
const getPreparedCopyItemOptions = (_d = (_c = this.context) === null || _c === void 0 ? void 0 : _c.getPreparedCopyItemOptions) !== null && _d !== void 0 ? _d : (_e = this.context.context) === null || _e === void 0 ? void 0 : _e.getPreparedCopyItemOptions;
|
|
106
106
|
if (typeof getPreparedCopyItemOptions === 'function') {
|
|
107
|
-
options =
|
|
107
|
+
options = getPreparedCopyItemOptions(options);
|
|
108
108
|
}
|
|
109
109
|
try {
|
|
110
110
|
localStorage.setItem(COPIED_WIDGET_STORE_KEY, JSON.stringify(options));
|
|
@@ -52,6 +52,7 @@ export function prepareItem(Component: any): {
|
|
|
52
52
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
53
53
|
};
|
|
54
54
|
propTypes: {
|
|
55
|
+
gridLayout: PropTypes.Requireable<object>;
|
|
55
56
|
adjustWidgetLayout: PropTypes.Validator<(...args: any[]) => any>;
|
|
56
57
|
layout: PropTypes.Requireable<any[]>;
|
|
57
58
|
id: PropTypes.Requireable<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import isEqual from 'lodash/isEqual';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { DashKitContext } from '../context/DashKitContext';
|
|
4
5
|
export function prepareItem(Component) {
|
|
@@ -11,7 +12,7 @@ export function prepareItem(Component) {
|
|
|
11
12
|
};
|
|
12
13
|
this._currentRenderProps = {};
|
|
13
14
|
this.getRenderProps = () => {
|
|
14
|
-
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder } = this.props;
|
|
15
|
+
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder, gridLayout } = this.props;
|
|
15
16
|
const { itemsState, itemsParams, registerManager, settings, context, editMode } = this.context;
|
|
16
17
|
const { data, defaults, namespace } = item;
|
|
17
18
|
const rendererProps = {
|
|
@@ -28,11 +29,17 @@ export function prepareItem(Component) {
|
|
|
28
29
|
settings,
|
|
29
30
|
context,
|
|
30
31
|
layout,
|
|
31
|
-
gridLayout: registerManager.gridLayout,
|
|
32
|
+
gridLayout: gridLayout || registerManager.gridLayout,
|
|
32
33
|
adjustWidgetLayout,
|
|
33
34
|
isPlaceholder,
|
|
34
35
|
};
|
|
35
|
-
const changedProp = Object.entries(rendererProps).find(([key, value]) =>
|
|
36
|
+
const changedProp = Object.entries(rendererProps).find(([key, value]) => {
|
|
37
|
+
// Checking gridLayoout deep as groups gridProperties method has tendancy to creat new objects
|
|
38
|
+
if (key === 'gridLayout') {
|
|
39
|
+
return !isEqual(this._currentRenderProps[key], value);
|
|
40
|
+
}
|
|
41
|
+
return this._currentRenderProps[key] !== value;
|
|
42
|
+
});
|
|
36
43
|
if (changedProp) {
|
|
37
44
|
this._currentRenderProps = rendererProps;
|
|
38
45
|
}
|
|
@@ -58,6 +65,7 @@ export function prepareItem(Component) {
|
|
|
58
65
|
}
|
|
59
66
|
},
|
|
60
67
|
_a.propTypes = {
|
|
68
|
+
gridLayout: PropTypes.object,
|
|
61
69
|
adjustWidgetLayout: PropTypes.func.isRequired,
|
|
62
70
|
layout: PropTypes.array,
|
|
63
71
|
id: PropTypes.string,
|