@gravity-ui/dashkit 8.1.0-beta.0 → 8.1.0-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/ActionPanel/types.d.ts +1 -0
- package/build/cjs/components/GridItem/GridItem.js +3 -2
- package/build/cjs/components/GridLayout/GridLayout.d.ts +1 -0
- package/build/cjs/components/GridLayout/GridLayout.js +16 -5
- package/build/cjs/components/Item/Item.d.ts +1 -0
- package/build/cjs/components/Item/Item.js +7 -1
- package/build/cjs/hocs/prepareItem.d.ts +1 -0
- package/build/cjs/hocs/prepareItem.js +4 -2
- package/build/cjs/plugins/Text/Text.js +0 -3
- package/build/esm/components/ActionPanel/types.d.ts +1 -0
- package/build/esm/components/GridItem/GridItem.js +3 -2
- package/build/esm/components/GridLayout/GridLayout.d.ts +1 -0
- package/build/esm/components/GridLayout/GridLayout.js +16 -5
- package/build/esm/components/Item/Item.d.ts +1 -0
- package/build/esm/components/Item/Item.js +7 -1
- package/build/esm/hocs/prepareItem.d.ts +1 -0
- package/build/esm/hocs/prepareItem.js +4 -2
- package/build/esm/plugins/Text/Text.js +0 -3
- package/package.json +1 -1
|
@@ -72,7 +72,7 @@ class GridItem extends react_1.default.PureComponent {
|
|
|
72
72
|
render() {
|
|
73
73
|
// из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
|
|
74
74
|
// https://github.com/STRML/react-grid-layout/issues/721
|
|
75
|
-
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, noOverlay, focusable, withCustomHandle, } = this.props;
|
|
75
|
+
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, noOverlay, focusable, withCustomHandle, isPlaceholder, } = this.props;
|
|
76
76
|
const { editMode } = this.context;
|
|
77
77
|
const width = Number.parseInt(style.width, 10);
|
|
78
78
|
const height = Number.parseInt(style.height, 10);
|
|
@@ -97,7 +97,7 @@ class GridItem extends react_1.default.PureComponent {
|
|
|
97
97
|
}
|
|
98
98
|
: {})),
|
|
99
99
|
react_1.default.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
|
|
100
|
-
react_1.default.createElement(Item_1.default, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef })),
|
|
100
|
+
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 })),
|
|
101
101
|
!noOverlay && this.renderOverlay(),
|
|
102
102
|
preparedChildren));
|
|
103
103
|
}
|
|
@@ -111,6 +111,7 @@ GridItem.propTypes = {
|
|
|
111
111
|
overlayControls: prop_types_1.default.object,
|
|
112
112
|
forwardedRef: prop_types_1.default.any,
|
|
113
113
|
forwardedPluginRef: prop_types_1.default.any,
|
|
114
|
+
isPlaceholder: prop_types_1.default.bool,
|
|
114
115
|
// from react-grid-layout:
|
|
115
116
|
children: prop_types_1.default.node,
|
|
116
117
|
className: prop_types_1.default.string,
|
|
@@ -23,6 +23,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
23
23
|
_onStop: (newLayout: any) => void;
|
|
24
24
|
_onDropDragOver: (e: any) => any;
|
|
25
25
|
_onDrop: (layout: any, item: any, e: any) => false | undefined;
|
|
26
|
+
renderTemporaryPlaceholder(): JSX.Element | null;
|
|
26
27
|
render(): JSX.Element;
|
|
27
28
|
}
|
|
28
29
|
import React from 'react';
|
|
@@ -134,6 +134,15 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
134
134
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
+
renderTemporaryPlaceholder() {
|
|
138
|
+
const { temporaryLayout, dragOverPlugin, noOverlay, draggableHandleClassName } = this.context;
|
|
139
|
+
if (!temporaryLayout) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const id = constants_1.TEMPORARY_ITEM_ID;
|
|
143
|
+
const type = dragOverPlugin.type;
|
|
144
|
+
return (react_1.default.createElement(GridItem_1.default, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
145
|
+
}
|
|
137
146
|
render() {
|
|
138
147
|
const { layout, temporaryLayout, config, registerManager, editMode, noOverlay, focusable, draggableHandleClassName, outerDnDEnable, } = this.context;
|
|
139
148
|
this.pluginsRefs.length = config.items.length;
|
|
@@ -145,11 +154,13 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
145
154
|
onDropDragOver: this._onDropDragOver,
|
|
146
155
|
onDrop: this._onDrop,
|
|
147
156
|
}
|
|
148
|
-
: null), { draggableCancel: `.${constants_1.OVERLAY_CONTROLS_CLASS_NAME}` }),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
: null), { draggableCancel: `.${constants_1.OVERLAY_CONTROLS_CLASS_NAME}` }),
|
|
158
|
+
config.items.map((item, i) => {
|
|
159
|
+
return (react_1.default.createElement(GridItem_1.default, { forwardedPluginRef: (pluginRef) => {
|
|
160
|
+
this.pluginsRefs[i] = pluginRef;
|
|
161
|
+
}, key: item.id, id: item.id, item: item, layout: temporaryLayout || layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, noOverlay: noOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
162
|
+
}),
|
|
163
|
+
this.renderTemporaryPlaceholder()));
|
|
153
164
|
}
|
|
154
165
|
}
|
|
155
166
|
GridLayout.contextType = DashKitContext_1.DashKitContext;
|
|
@@ -56,6 +56,7 @@ declare const _default: {
|
|
|
56
56
|
width: PropTypes.Requireable<number>;
|
|
57
57
|
height: PropTypes.Requireable<number>;
|
|
58
58
|
transform: PropTypes.Requireable<string>;
|
|
59
|
+
isPlaceholder: PropTypes.Requireable<boolean>;
|
|
59
60
|
forwardedPluginRef: PropTypes.Requireable<any>;
|
|
60
61
|
};
|
|
61
62
|
contextType: React.Context<any>;
|
|
@@ -7,11 +7,16 @@ const prepareItem_1 = require("../../hocs/prepareItem");
|
|
|
7
7
|
const cn_1 = require("../../utils/cn");
|
|
8
8
|
const b = (0, cn_1.cn)('dashkit-item');
|
|
9
9
|
// TODO: getDerivedStateFromError и заглушка с ошибкой
|
|
10
|
-
const Item = ({ registerManager, rendererProps, type, forwardedPluginRef }) => {
|
|
10
|
+
const Item = ({ registerManager, rendererProps, type, isPlaceholder, forwardedPluginRef }) => {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
if (!registerManager.check(type)) {
|
|
12
13
|
console.warn(`type [${type}] не зарегистрирован`);
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
16
|
+
if (isPlaceholder) {
|
|
17
|
+
return (react_1.default.createElement("div", { className: b('placeholder') }, ((_b = (_a = registerManager
|
|
18
|
+
.getItem(type)).placeholderRenderer) === null || _b === void 0 ? void 0 : _b.call(_a, rendererProps, forwardedPluginRef)) || null));
|
|
19
|
+
}
|
|
15
20
|
return (react_1.default.createElement("div", { className: b('renderer') }, registerManager.getItem(type).renderer(rendererProps, forwardedPluginRef)));
|
|
16
21
|
};
|
|
17
22
|
Item.propTypes = {
|
|
@@ -19,5 +24,6 @@ Item.propTypes = {
|
|
|
19
24
|
rendererProps: prop_types_1.default.object,
|
|
20
25
|
registerManager: prop_types_1.default.object,
|
|
21
26
|
type: prop_types_1.default.string,
|
|
27
|
+
isPlaceholder: prop_types_1.default.bool,
|
|
22
28
|
};
|
|
23
29
|
exports.default = (0, prepareItem_1.prepareItem)(Item);
|
|
@@ -56,6 +56,7 @@ export function prepareItem(Component: any): {
|
|
|
56
56
|
width: PropTypes.Requireable<number>;
|
|
57
57
|
height: PropTypes.Requireable<number>;
|
|
58
58
|
transform: PropTypes.Requireable<string>;
|
|
59
|
+
isPlaceholder: PropTypes.Requireable<boolean>;
|
|
59
60
|
forwardedPluginRef: PropTypes.Requireable<any>;
|
|
60
61
|
};
|
|
61
62
|
contextType: React.Context<any>;
|
|
@@ -26,7 +26,7 @@ function prepareItem(Component) {
|
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
render() {
|
|
29
|
-
const { id, width, height, item, adjustWidgetLayout, layout } = this.props;
|
|
29
|
+
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder } = this.props;
|
|
30
30
|
const { itemsState, itemsParams, registerManager, settings, context, editMode } = this.context;
|
|
31
31
|
const { type, data, defaults, namespace } = item;
|
|
32
32
|
const rendererProps = {
|
|
@@ -45,8 +45,9 @@ function prepareItem(Component) {
|
|
|
45
45
|
layout,
|
|
46
46
|
gridLayout: registerManager.gridLayout,
|
|
47
47
|
adjustWidgetLayout,
|
|
48
|
+
isPlaceholder,
|
|
48
49
|
};
|
|
49
|
-
return (react_1.default.createElement(Component, { forwardedPluginRef: this.props.forwardedPluginRef, rendererProps: rendererProps, registerManager: registerManager, type: type }));
|
|
50
|
+
return (react_1.default.createElement(Component, { forwardedPluginRef: this.props.forwardedPluginRef, rendererProps: rendererProps, registerManager: registerManager, type: type, isPlaceholder: isPlaceholder }));
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
_a.propTypes = {
|
|
@@ -58,6 +59,7 @@ function prepareItem(Component) {
|
|
|
58
59
|
width: prop_types_1.default.number,
|
|
59
60
|
height: prop_types_1.default.number,
|
|
60
61
|
transform: prop_types_1.default.string,
|
|
62
|
+
isPlaceholder: prop_types_1.default.bool,
|
|
61
63
|
forwardedPluginRef: prop_types_1.default.any,
|
|
62
64
|
},
|
|
63
65
|
_a.contextType = DashKitContext_1.DashKitContext,
|
|
@@ -117,8 +117,5 @@ const plugin = {
|
|
|
117
117
|
renderer(props, forwardedRef) {
|
|
118
118
|
return react_1.default.createElement(PluginText, Object.assign({}, props, { apiHandler: plugin._apiHandler, ref: forwardedRef }));
|
|
119
119
|
},
|
|
120
|
-
placeholderRenderer(_, forwardedRef) {
|
|
121
|
-
return react_1.default.createElement("div", { ref: forwardedRef }, "Text placeholder");
|
|
122
|
-
},
|
|
123
120
|
};
|
|
124
121
|
exports.default = plugin;
|
|
@@ -70,7 +70,7 @@ class GridItem extends React.PureComponent {
|
|
|
70
70
|
render() {
|
|
71
71
|
// из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
|
|
72
72
|
// https://github.com/STRML/react-grid-layout/issues/721
|
|
73
|
-
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, noOverlay, focusable, withCustomHandle, } = this.props;
|
|
73
|
+
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, noOverlay, focusable, withCustomHandle, isPlaceholder, } = this.props;
|
|
74
74
|
const { editMode } = this.context;
|
|
75
75
|
const width = Number.parseInt(style.width, 10);
|
|
76
76
|
const height = Number.parseInt(style.height, 10);
|
|
@@ -95,7 +95,7 @@ class GridItem extends React.PureComponent {
|
|
|
95
95
|
}
|
|
96
96
|
: {})),
|
|
97
97
|
React.createElement("div", { className: b('item', { editMode: editMode && !_editActive && !noOverlay }) },
|
|
98
|
-
React.createElement(Item, { id: this.props.id, item: this.props.item, shouldItemUpdate: !isDragging, width: width, height: height, transform: transform, adjustWidgetLayout: this.props.adjustWidgetLayout, layout: this.props.layout, forwardedPluginRef: this.props.forwardedPluginRef })),
|
|
98
|
+
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 })),
|
|
99
99
|
!noOverlay && this.renderOverlay(),
|
|
100
100
|
preparedChildren));
|
|
101
101
|
}
|
|
@@ -109,6 +109,7 @@ GridItem.propTypes = {
|
|
|
109
109
|
overlayControls: PropTypes.object,
|
|
110
110
|
forwardedRef: PropTypes.any,
|
|
111
111
|
forwardedPluginRef: PropTypes.any,
|
|
112
|
+
isPlaceholder: PropTypes.bool,
|
|
112
113
|
// from react-grid-layout:
|
|
113
114
|
children: PropTypes.node,
|
|
114
115
|
className: PropTypes.string,
|
|
@@ -23,6 +23,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
23
23
|
_onStop: (newLayout: any) => void;
|
|
24
24
|
_onDropDragOver: (e: any) => any;
|
|
25
25
|
_onDrop: (layout: any, item: any, e: any) => false | undefined;
|
|
26
|
+
renderTemporaryPlaceholder(): JSX.Element | null;
|
|
26
27
|
render(): JSX.Element;
|
|
27
28
|
}
|
|
28
29
|
import React from 'react';
|
|
@@ -131,6 +131,15 @@ class GridLayout extends React.PureComponent {
|
|
|
131
131
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
renderTemporaryPlaceholder() {
|
|
135
|
+
const { temporaryLayout, dragOverPlugin, noOverlay, draggableHandleClassName } = this.context;
|
|
136
|
+
if (!temporaryLayout) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const id = TEMPORARY_ITEM_ID;
|
|
140
|
+
const type = dragOverPlugin.type;
|
|
141
|
+
return (React.createElement(GridItem, { key: id, id: id, item: { id, type, data: {} }, layout: temporaryLayout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isPlaceholder: true, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
142
|
+
}
|
|
134
143
|
render() {
|
|
135
144
|
const { layout, temporaryLayout, config, registerManager, editMode, noOverlay, focusable, draggableHandleClassName, outerDnDEnable, } = this.context;
|
|
136
145
|
this.pluginsRefs.length = config.items.length;
|
|
@@ -142,11 +151,13 @@ class GridLayout extends React.PureComponent {
|
|
|
142
151
|
onDropDragOver: this._onDropDragOver,
|
|
143
152
|
onDrop: this._onDrop,
|
|
144
153
|
}
|
|
145
|
-
: null), { draggableCancel: `.${OVERLAY_CONTROLS_CLASS_NAME}` }),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
: null), { draggableCancel: `.${OVERLAY_CONTROLS_CLASS_NAME}` }),
|
|
155
|
+
config.items.map((item, i) => {
|
|
156
|
+
return (React.createElement(GridItem, { forwardedPluginRef: (pluginRef) => {
|
|
157
|
+
this.pluginsRefs[i] = pluginRef;
|
|
158
|
+
}, key: item.id, id: item.id, item: item, layout: temporaryLayout || layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, noOverlay: noOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
159
|
+
}),
|
|
160
|
+
this.renderTemporaryPlaceholder()));
|
|
150
161
|
}
|
|
151
162
|
}
|
|
152
163
|
GridLayout.contextType = DashKitContext;
|
|
@@ -56,6 +56,7 @@ declare const _default: {
|
|
|
56
56
|
width: PropTypes.Requireable<number>;
|
|
57
57
|
height: PropTypes.Requireable<number>;
|
|
58
58
|
transform: PropTypes.Requireable<string>;
|
|
59
|
+
isPlaceholder: PropTypes.Requireable<boolean>;
|
|
59
60
|
forwardedPluginRef: PropTypes.Requireable<any>;
|
|
60
61
|
};
|
|
61
62
|
contextType: React.Context<any>;
|
|
@@ -5,11 +5,16 @@ import { cn } from '../../utils/cn';
|
|
|
5
5
|
import './Item.css';
|
|
6
6
|
const b = cn('dashkit-item');
|
|
7
7
|
// TODO: getDerivedStateFromError и заглушка с ошибкой
|
|
8
|
-
const Item = ({ registerManager, rendererProps, type, forwardedPluginRef }) => {
|
|
8
|
+
const Item = ({ registerManager, rendererProps, type, isPlaceholder, forwardedPluginRef }) => {
|
|
9
|
+
var _a, _b;
|
|
9
10
|
if (!registerManager.check(type)) {
|
|
10
11
|
console.warn(`type [${type}] не зарегистрирован`);
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
14
|
+
if (isPlaceholder) {
|
|
15
|
+
return (React.createElement("div", { className: b('placeholder') }, ((_b = (_a = registerManager
|
|
16
|
+
.getItem(type)).placeholderRenderer) === null || _b === void 0 ? void 0 : _b.call(_a, rendererProps, forwardedPluginRef)) || null));
|
|
17
|
+
}
|
|
13
18
|
return (React.createElement("div", { className: b('renderer') }, registerManager.getItem(type).renderer(rendererProps, forwardedPluginRef)));
|
|
14
19
|
};
|
|
15
20
|
Item.propTypes = {
|
|
@@ -17,5 +22,6 @@ Item.propTypes = {
|
|
|
17
22
|
rendererProps: PropTypes.object,
|
|
18
23
|
registerManager: PropTypes.object,
|
|
19
24
|
type: PropTypes.string,
|
|
25
|
+
isPlaceholder: PropTypes.bool,
|
|
20
26
|
};
|
|
21
27
|
export default prepareItem(Item);
|
|
@@ -56,6 +56,7 @@ export function prepareItem(Component: any): {
|
|
|
56
56
|
width: PropTypes.Requireable<number>;
|
|
57
57
|
height: PropTypes.Requireable<number>;
|
|
58
58
|
transform: PropTypes.Requireable<string>;
|
|
59
|
+
isPlaceholder: PropTypes.Requireable<boolean>;
|
|
59
60
|
forwardedPluginRef: PropTypes.Requireable<any>;
|
|
60
61
|
};
|
|
61
62
|
contextType: React.Context<any>;
|
|
@@ -22,7 +22,7 @@ export function prepareItem(Component) {
|
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
render() {
|
|
25
|
-
const { id, width, height, item, adjustWidgetLayout, layout } = this.props;
|
|
25
|
+
const { id, width, height, item, adjustWidgetLayout, layout, isPlaceholder } = this.props;
|
|
26
26
|
const { itemsState, itemsParams, registerManager, settings, context, editMode } = this.context;
|
|
27
27
|
const { type, data, defaults, namespace } = item;
|
|
28
28
|
const rendererProps = {
|
|
@@ -41,8 +41,9 @@ export function prepareItem(Component) {
|
|
|
41
41
|
layout,
|
|
42
42
|
gridLayout: registerManager.gridLayout,
|
|
43
43
|
adjustWidgetLayout,
|
|
44
|
+
isPlaceholder,
|
|
44
45
|
};
|
|
45
|
-
return (React.createElement(Component, { forwardedPluginRef: this.props.forwardedPluginRef, rendererProps: rendererProps, registerManager: registerManager, type: type }));
|
|
46
|
+
return (React.createElement(Component, { forwardedPluginRef: this.props.forwardedPluginRef, rendererProps: rendererProps, registerManager: registerManager, type: type, isPlaceholder: isPlaceholder }));
|
|
46
47
|
}
|
|
47
48
|
},
|
|
48
49
|
_a.propTypes = {
|
|
@@ -54,6 +55,7 @@ export function prepareItem(Component) {
|
|
|
54
55
|
width: PropTypes.number,
|
|
55
56
|
height: PropTypes.number,
|
|
56
57
|
transform: PropTypes.string,
|
|
58
|
+
isPlaceholder: PropTypes.bool,
|
|
57
59
|
forwardedPluginRef: PropTypes.any,
|
|
58
60
|
},
|
|
59
61
|
_a.contextType = DashKitContext,
|
|
@@ -113,8 +113,5 @@ const plugin = {
|
|
|
113
113
|
renderer(props, forwardedRef) {
|
|
114
114
|
return React.createElement(PluginText, Object.assign({}, props, { apiHandler: plugin._apiHandler, ref: forwardedRef }));
|
|
115
115
|
},
|
|
116
|
-
placeholderRenderer(_, forwardedRef) {
|
|
117
|
-
return React.createElement("div", { ref: forwardedRef }, "Text placeholder");
|
|
118
|
-
},
|
|
119
116
|
};
|
|
120
117
|
export default plugin;
|