@gravity-ui/dashkit 8.17.3-beta.0 → 8.17.4
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.css +8 -0
- package/build/cjs/components/GridItem/GridItem.js +3 -3
- package/build/cjs/components/GridLayout/GridLayout.d.ts +2 -2
- package/build/cjs/components/GridLayout/GridLayout.js +28 -22
- package/build/esm/components/GridItem/GridItem.css +8 -0
- package/build/esm/components/GridItem/GridItem.js +3 -3
- package/build/esm/components/GridLayout/GridLayout.d.ts +2 -2
- package/build/esm/components/GridLayout/GridLayout.js +28 -22
- package/package.json +1 -1
|
@@ -76,6 +76,14 @@
|
|
|
76
76
|
user-select: none;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
.react-grid-focus-capture {
|
|
80
|
+
position: absolute;
|
|
81
|
+
display: block;
|
|
82
|
+
z-index: 6;
|
|
83
|
+
max-width: 100%;
|
|
84
|
+
max-height: 100%;
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
.react-grid-item .react-resizable-handle {
|
|
80
88
|
position: absolute;
|
|
81
89
|
width: 20px;
|
|
@@ -96,7 +96,7 @@ class GridItem extends react_1.default.PureComponent {
|
|
|
96
96
|
render() {
|
|
97
97
|
// из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
|
|
98
98
|
// https://github.com/STRML/react-grid-layout/issues/721
|
|
99
|
-
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging,
|
|
99
|
+
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, isDraggedOut, noOverlay, focusable, withCustomHandle, isPlaceholder = false, } = this.props;
|
|
100
100
|
const { editMode } = this.context;
|
|
101
101
|
const width = Number.parseInt(style.width, 10);
|
|
102
102
|
const height = Number.parseInt(style.height, 10);
|
|
@@ -115,7 +115,7 @@ class GridItem extends react_1.default.PureComponent {
|
|
|
115
115
|
const { _editActive } = this.props.item.data;
|
|
116
116
|
return (react_1.default.createElement("div", Object.assign({ className: b({
|
|
117
117
|
'is-dragging': isDragging,
|
|
118
|
-
'is-dragged-out':
|
|
118
|
+
'is-dragged-out': isDraggedOut,
|
|
119
119
|
'is-focused': this.state.isFocused,
|
|
120
120
|
'with-custom-handle': withCustomHandle,
|
|
121
121
|
}, preparedClassName), "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, (focusable
|
|
@@ -136,7 +136,7 @@ GridItem.propTypes = {
|
|
|
136
136
|
id: prop_types_1.default.string,
|
|
137
137
|
item: prop_types_1.default.object,
|
|
138
138
|
isDragging: prop_types_1.default.bool,
|
|
139
|
-
|
|
139
|
+
isDraggedOut: prop_types_1.default.bool,
|
|
140
140
|
layout: prop_types_1.default.array,
|
|
141
141
|
forwardedRef: prop_types_1.default.any,
|
|
142
142
|
forwardedPluginRef: prop_types_1.default.any,
|
|
@@ -48,10 +48,10 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
48
48
|
e: any;
|
|
49
49
|
element: any;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
updateDraggingElementState(group: any, layoutItem: any, e: any): void;
|
|
52
52
|
_initDragCoordinatesWatcher(element: any): void;
|
|
53
53
|
_parendDragNode: any;
|
|
54
|
-
_forceCursorCapture(parentElement: any, position: any): void;
|
|
54
|
+
_forceCursorCapture(parentElement: any, position: any, parentRect: any): void;
|
|
55
55
|
_updateDragCoordinates(e: any): void;
|
|
56
56
|
_resetDragWatcher(): void;
|
|
57
57
|
_onDragStart(group: any, _newLayout: any, layoutItem: any, _newItem: any, _placeholder: any, e: any, element: any): void;
|
|
@@ -270,7 +270,7 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
270
270
|
element,
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
updateDraggingElementState(group, layoutItem, e) {
|
|
274
274
|
let currentDraggingElement = this.state.currentDraggingElement;
|
|
275
275
|
if (!currentDraggingElement) {
|
|
276
276
|
const { temporaryLayout } = this.context;
|
|
@@ -294,20 +294,23 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
294
294
|
this.setState({ draggedOut: false });
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
// When element is going back and prointer-event: none is removed mouse enter event is not fired
|
|
298
|
+
// So to trigger it we are forcing this event by adding transparent block under the mouse
|
|
299
|
+
_forceCursorCapture(parentElement, position, parentRect) {
|
|
300
|
+
const block = document.createElement('div');
|
|
301
|
+
block.classList.add('react-grid-focus-capture');
|
|
302
|
+
const blockSize = 44;
|
|
300
303
|
const offset = blockSize / 2;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
parentElement.appendChild(
|
|
304
|
+
// Keeping elemnt inside current grid
|
|
305
|
+
const top = Math.min(Math.max(position.top - offset, 0), parentRect.height - blockSize);
|
|
306
|
+
const left = Math.min(Math.max(position.left - offset, 0), parentRect.width - blockSize);
|
|
307
|
+
block.style.width = `${blockSize}px`;
|
|
308
|
+
block.style.height = `${blockSize}px`;
|
|
309
|
+
block.style.top = `${top}px`;
|
|
310
|
+
block.style.left = `${left}px`;
|
|
311
|
+
parentElement.appendChild(block);
|
|
309
312
|
setTimeout(() => {
|
|
310
|
-
|
|
313
|
+
block.remove();
|
|
311
314
|
}, 100);
|
|
312
315
|
}
|
|
313
316
|
_updateDragCoordinates(e) {
|
|
@@ -325,12 +328,14 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
325
328
|
draggedOut = false;
|
|
326
329
|
}
|
|
327
330
|
if (draggedOut !== this.state.draggedOut) {
|
|
328
|
-
this.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
331
|
+
this.setState({ draggedOut });
|
|
332
|
+
if (!draggedOut) {
|
|
333
|
+
this._forceCursorCapture(parent, {
|
|
334
|
+
top: clientY - parentRect.top,
|
|
335
|
+
left: clientX - parentRect.left,
|
|
336
|
+
}, parentRect);
|
|
337
|
+
}
|
|
332
338
|
}
|
|
333
|
-
this.setState({ draggedOut });
|
|
334
339
|
}
|
|
335
340
|
_resetDragWatcher() {
|
|
336
341
|
this._parendDragNode = null;
|
|
@@ -344,13 +349,13 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
344
349
|
this.setState({ isDragging: true });
|
|
345
350
|
}
|
|
346
351
|
else {
|
|
347
|
-
this.
|
|
352
|
+
this.updateDraggingElementState(group, layoutItem, e);
|
|
348
353
|
this.setState({ isDragging: true });
|
|
349
354
|
}
|
|
350
355
|
}
|
|
351
356
|
_onDrag(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
352
357
|
var _a;
|
|
353
|
-
this._updateDragCoordinates(e
|
|
358
|
+
this._updateDragCoordinates(e);
|
|
354
359
|
(_a = this.context.onDrag) === null || _a === void 0 ? void 0 : _a.call(this, this.prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element));
|
|
355
360
|
}
|
|
356
361
|
_onDragStop(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
@@ -379,7 +384,6 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
379
384
|
if (this.context.temporaryLayout) {
|
|
380
385
|
return;
|
|
381
386
|
}
|
|
382
|
-
console.log('_onTargetRestore');
|
|
383
387
|
const { currentDraggingElement } = this.state;
|
|
384
388
|
if (currentDraggingElement) {
|
|
385
389
|
this.setState({
|
|
@@ -428,7 +432,9 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
428
432
|
}
|
|
429
433
|
: null)),
|
|
430
434
|
renderItems.map((item, i) => {
|
|
431
|
-
|
|
435
|
+
const isCurrentItem = (currentDraggingElement === null || currentDraggingElement === void 0 ? void 0 : currentDraggingElement.item.id) === item.id;
|
|
436
|
+
const isDraggedOut = isCurrentItem && this.state.draggedOut;
|
|
437
|
+
return (react_1.default.createElement(GridItem_1.default, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: item.id, id: item.id, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isDraggedOut: isDraggedOut, noOverlay: noOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender }));
|
|
432
438
|
}),
|
|
433
439
|
this.renderTemporaryPlaceholder()));
|
|
434
440
|
}
|
|
@@ -76,6 +76,14 @@
|
|
|
76
76
|
user-select: none;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
.react-grid-focus-capture {
|
|
80
|
+
position: absolute;
|
|
81
|
+
display: block;
|
|
82
|
+
z-index: 6;
|
|
83
|
+
max-width: 100%;
|
|
84
|
+
max-height: 100%;
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
.react-grid-item .react-resizable-handle {
|
|
80
88
|
position: absolute;
|
|
81
89
|
width: 20px;
|
|
@@ -94,7 +94,7 @@ class GridItem extends React.PureComponent {
|
|
|
94
94
|
render() {
|
|
95
95
|
// из-за бага, что Grid Items unmounts при изменении static, isDraggable, isResaizable
|
|
96
96
|
// https://github.com/STRML/react-grid-layout/issues/721
|
|
97
|
-
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging,
|
|
97
|
+
const { style, onMouseDown, onMouseUp, onTouchEnd, onTouchStart, children, className, isDragging, isDraggedOut, noOverlay, focusable, withCustomHandle, isPlaceholder = false, } = this.props;
|
|
98
98
|
const { editMode } = this.context;
|
|
99
99
|
const width = Number.parseInt(style.width, 10);
|
|
100
100
|
const height = Number.parseInt(style.height, 10);
|
|
@@ -113,7 +113,7 @@ class GridItem extends React.PureComponent {
|
|
|
113
113
|
const { _editActive } = this.props.item.data;
|
|
114
114
|
return (React.createElement("div", Object.assign({ className: b({
|
|
115
115
|
'is-dragging': isDragging,
|
|
116
|
-
'is-dragged-out':
|
|
116
|
+
'is-dragged-out': isDraggedOut,
|
|
117
117
|
'is-focused': this.state.isFocused,
|
|
118
118
|
'with-custom-handle': withCustomHandle,
|
|
119
119
|
}, preparedClassName), "data-qa": "dashkit-grid-item", style: style, ref: this.props.forwardedRef }, reactGridLayoutProps, (focusable
|
|
@@ -134,7 +134,7 @@ GridItem.propTypes = {
|
|
|
134
134
|
id: PropTypes.string,
|
|
135
135
|
item: PropTypes.object,
|
|
136
136
|
isDragging: PropTypes.bool,
|
|
137
|
-
|
|
137
|
+
isDraggedOut: PropTypes.bool,
|
|
138
138
|
layout: PropTypes.array,
|
|
139
139
|
forwardedRef: PropTypes.any,
|
|
140
140
|
forwardedPluginRef: PropTypes.any,
|
|
@@ -48,10 +48,10 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
48
48
|
e: any;
|
|
49
49
|
element: any;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
updateDraggingElementState(group: any, layoutItem: any, e: any): void;
|
|
52
52
|
_initDragCoordinatesWatcher(element: any): void;
|
|
53
53
|
_parendDragNode: any;
|
|
54
|
-
_forceCursorCapture(parentElement: any, position: any): void;
|
|
54
|
+
_forceCursorCapture(parentElement: any, position: any, parentRect: any): void;
|
|
55
55
|
_updateDragCoordinates(e: any): void;
|
|
56
56
|
_resetDragWatcher(): void;
|
|
57
57
|
_onDragStart(group: any, _newLayout: any, layoutItem: any, _newItem: any, _placeholder: any, e: any, element: any): void;
|
|
@@ -267,7 +267,7 @@ class GridLayout extends React.PureComponent {
|
|
|
267
267
|
element,
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
|
|
270
|
+
updateDraggingElementState(group, layoutItem, e) {
|
|
271
271
|
let currentDraggingElement = this.state.currentDraggingElement;
|
|
272
272
|
if (!currentDraggingElement) {
|
|
273
273
|
const { temporaryLayout } = this.context;
|
|
@@ -291,20 +291,23 @@ class GridLayout extends React.PureComponent {
|
|
|
291
291
|
this.setState({ draggedOut: false });
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
// When element is going back and prointer-event: none is removed mouse enter event is not fired
|
|
295
|
+
// So to trigger it we are forcing this event by adding transparent block under the mouse
|
|
296
|
+
_forceCursorCapture(parentElement, position, parentRect) {
|
|
297
|
+
const block = document.createElement('div');
|
|
298
|
+
block.classList.add('react-grid-focus-capture');
|
|
299
|
+
const blockSize = 44;
|
|
297
300
|
const offset = blockSize / 2;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
parentElement.appendChild(
|
|
301
|
+
// Keeping elemnt inside current grid
|
|
302
|
+
const top = Math.min(Math.max(position.top - offset, 0), parentRect.height - blockSize);
|
|
303
|
+
const left = Math.min(Math.max(position.left - offset, 0), parentRect.width - blockSize);
|
|
304
|
+
block.style.width = `${blockSize}px`;
|
|
305
|
+
block.style.height = `${blockSize}px`;
|
|
306
|
+
block.style.top = `${top}px`;
|
|
307
|
+
block.style.left = `${left}px`;
|
|
308
|
+
parentElement.appendChild(block);
|
|
306
309
|
setTimeout(() => {
|
|
307
|
-
|
|
310
|
+
block.remove();
|
|
308
311
|
}, 100);
|
|
309
312
|
}
|
|
310
313
|
_updateDragCoordinates(e) {
|
|
@@ -322,12 +325,14 @@ class GridLayout extends React.PureComponent {
|
|
|
322
325
|
draggedOut = false;
|
|
323
326
|
}
|
|
324
327
|
if (draggedOut !== this.state.draggedOut) {
|
|
325
|
-
this.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
this.setState({ draggedOut });
|
|
329
|
+
if (!draggedOut) {
|
|
330
|
+
this._forceCursorCapture(parent, {
|
|
331
|
+
top: clientY - parentRect.top,
|
|
332
|
+
left: clientX - parentRect.left,
|
|
333
|
+
}, parentRect);
|
|
334
|
+
}
|
|
329
335
|
}
|
|
330
|
-
this.setState({ draggedOut });
|
|
331
336
|
}
|
|
332
337
|
_resetDragWatcher() {
|
|
333
338
|
this._parendDragNode = null;
|
|
@@ -341,13 +346,13 @@ class GridLayout extends React.PureComponent {
|
|
|
341
346
|
this.setState({ isDragging: true });
|
|
342
347
|
}
|
|
343
348
|
else {
|
|
344
|
-
this.
|
|
349
|
+
this.updateDraggingElementState(group, layoutItem, e);
|
|
345
350
|
this.setState({ isDragging: true });
|
|
346
351
|
}
|
|
347
352
|
}
|
|
348
353
|
_onDrag(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
349
354
|
var _a;
|
|
350
|
-
this._updateDragCoordinates(e
|
|
355
|
+
this._updateDragCoordinates(e);
|
|
351
356
|
(_a = this.context.onDrag) === null || _a === void 0 ? void 0 : _a.call(this, this.prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element));
|
|
352
357
|
}
|
|
353
358
|
_onDragStop(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
@@ -376,7 +381,6 @@ class GridLayout extends React.PureComponent {
|
|
|
376
381
|
if (this.context.temporaryLayout) {
|
|
377
382
|
return;
|
|
378
383
|
}
|
|
379
|
-
console.log('_onTargetRestore');
|
|
380
384
|
const { currentDraggingElement } = this.state;
|
|
381
385
|
if (currentDraggingElement) {
|
|
382
386
|
this.setState({
|
|
@@ -425,7 +429,9 @@ class GridLayout extends React.PureComponent {
|
|
|
425
429
|
}
|
|
426
430
|
: null)),
|
|
427
431
|
renderItems.map((item, i) => {
|
|
428
|
-
|
|
432
|
+
const isCurrentItem = (currentDraggingElement === null || currentDraggingElement === void 0 ? void 0 : currentDraggingElement.item.id) === item.id;
|
|
433
|
+
const isDraggedOut = isCurrentItem && this.state.draggedOut;
|
|
434
|
+
return (React.createElement(GridItem, { forwardedPluginRef: this.getMemoForwardRefCallback(offset + i), key: item.id, id: item.id, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, isDraggedOut: isDraggedOut, noOverlay: noOverlay, focusable: focusable, withCustomHandle: Boolean(draggableHandleClassName), onItemMountChange: onItemMountChange, onItemRender: onItemRender }));
|
|
429
435
|
}),
|
|
430
436
|
this.renderTemporaryPlaceholder()));
|
|
431
437
|
}
|