@gravity-ui/dashkit 10.4.1 → 10.4.3
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/DashKit/__tests__/controlled-layout.test.js +68 -4
- package/build/cjs/components/DashKit/__tests__/controlled-layout.test.js.map +1 -1
- package/build/cjs/components/GridItem/GridItem.d.ts +20 -0
- package/build/cjs/components/GridItem/GridItem.js +3 -1
- package/build/cjs/components/GridItem/GridItem.js.map +1 -1
- package/build/cjs/components/GridLayout/ReactGridLayout.d.ts +37 -2
- package/build/cjs/components/GridLayout/ReactGridLayout.js +211 -4
- package/build/cjs/components/GridLayout/ReactGridLayout.js.map +1 -1
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.d.ts +2 -0
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.js +397 -0
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.js.map +1 -0
- package/build/cjs/hocs/withContext.js +35 -13
- package/build/cjs/hocs/withContext.js.map +1 -1
- package/build/cjs/package.json +1 -1
- package/build/esm/components/DashKit/__tests__/controlled-layout.test.js +69 -5
- package/build/esm/components/DashKit/__tests__/controlled-layout.test.js.map +1 -1
- package/build/esm/components/GridItem/GridItem.d.ts +20 -0
- package/build/esm/components/GridItem/GridItem.js +2 -2
- package/build/esm/components/GridItem/GridItem.js.map +1 -1
- package/build/esm/components/GridLayout/ReactGridLayout.d.ts +37 -2
- package/build/esm/components/GridLayout/ReactGridLayout.js +213 -5
- package/build/esm/components/GridLayout/ReactGridLayout.js.map +1 -1
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.d.ts +2 -0
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.js +394 -0
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.js.map +1 -0
- package/build/esm/hocs/withContext.js +35 -13
- package/build/esm/hocs/withContext.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/package.json +3 -2
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
import React from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
2
4
|
// @ts-expect-error - utils is not exported in type definitions
|
|
3
|
-
import ReactGridLayout, {
|
|
5
|
+
import ReactGridLayout, { utils } from 'react-grid-layout';
|
|
6
|
+
import ResizeObserverPolyfill from 'resize-observer-polyfill';
|
|
4
7
|
import { DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME } from "../../constants/index.js";
|
|
8
|
+
const GRID_LAYOUT_CLASS_NAME = 'react-grid-layout';
|
|
5
9
|
const isRefObject = (value) => {
|
|
6
10
|
return (typeof value === 'object' &&
|
|
7
11
|
value !== null &&
|
|
8
12
|
'current' in value &&
|
|
9
13
|
typeof value.current === 'object');
|
|
10
14
|
};
|
|
15
|
+
const getGridItemStyle = ({ cols, containerPadding, margin, width, x, y, w, h, rowHeight, useCSSTransforms, }) => {
|
|
16
|
+
const [marginX, marginY] = margin;
|
|
17
|
+
const [paddingX, paddingY] = containerPadding;
|
|
18
|
+
const columnWidth = (width - marginX * (cols - 1) - paddingX * 2) / cols;
|
|
19
|
+
const position = {
|
|
20
|
+
height: Math.round(rowHeight * h + marginY * (h - 1)),
|
|
21
|
+
left: Math.round((columnWidth + marginX) * x + paddingX),
|
|
22
|
+
top: Math.round(paddingY + (rowHeight + marginY) * y),
|
|
23
|
+
width: Math.round(columnWidth * w + marginX * (w - 1)),
|
|
24
|
+
};
|
|
25
|
+
return useCSSTransforms
|
|
26
|
+
? Object.assign(Object.assign({}, utils.setTransform(position)), { left: '', top: '' }) : Object.assign(Object.assign({}, utils.setTopLeft(position)), { MozTransform: '', OTransform: '', WebkitTransform: '', msTransform: '', transform: '' });
|
|
27
|
+
};
|
|
11
28
|
class DragOverLayout extends ReactGridLayout {
|
|
12
29
|
constructor(props, context) {
|
|
13
30
|
super(props, context);
|
|
@@ -16,6 +33,7 @@ class DragOverLayout extends ReactGridLayout {
|
|
|
16
33
|
// Without this flag, our setState would trigger onLayoutChange back to the consumer
|
|
17
34
|
// that just initiated the action, causing a spurious 'change' event.
|
|
18
35
|
this._isRestoringExternalLayout = false;
|
|
36
|
+
this.gridItemChildren = new WeakMap();
|
|
19
37
|
// Reset placeholder when item dragged from outside
|
|
20
38
|
this.resetExternalPlaceholder = () => {
|
|
21
39
|
// @ts-expect-error - dragEnterCounter is an internal property of parent class
|
|
@@ -85,6 +103,11 @@ class DragOverLayout extends ReactGridLayout {
|
|
|
85
103
|
this.parentOnDragStop(i, x, y, sintEv);
|
|
86
104
|
}
|
|
87
105
|
};
|
|
106
|
+
this.extendedOnDragOver = (e) => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
(_b = (_a = this.props).onBeforeDragOver) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
109
|
+
return this.parentOnDragOver(e);
|
|
110
|
+
};
|
|
88
111
|
this.isSharedDragTarget = () => {
|
|
89
112
|
var _a;
|
|
90
113
|
const drag = (_a = this.props.dragStateRef) === null || _a === void 0 ? void 0 : _a.current;
|
|
@@ -148,6 +171,10 @@ class DragOverLayout extends ReactGridLayout {
|
|
|
148
171
|
this.parentOnDragStop = this.onDragStop;
|
|
149
172
|
// @ts-expect-error - assigning custom method to parent's onDragStop
|
|
150
173
|
this.onDragStop = this.extendedOnDragStop;
|
|
174
|
+
// @ts-expect-error - onDragOver is a protected method in parent class
|
|
175
|
+
this.parentOnDragOver = this.onDragOver;
|
|
176
|
+
// @ts-expect-error - assigning custom method to parent's onDragOver
|
|
177
|
+
this.onDragOver = this.extendedOnDragOver;
|
|
151
178
|
}
|
|
152
179
|
componentDidMount() {
|
|
153
180
|
var _a, _b;
|
|
@@ -259,6 +286,22 @@ class DragOverLayout extends ReactGridLayout {
|
|
|
259
286
|
if (!gridItem) {
|
|
260
287
|
return gridItem;
|
|
261
288
|
}
|
|
289
|
+
const { cols, containerPadding, h, margin, rowHeight, useCSSTransforms, w, x, y } = gridItem.props;
|
|
290
|
+
const [marginX, marginY] = margin;
|
|
291
|
+
const [paddingX, paddingY] = containerPadding;
|
|
292
|
+
const gridItemMetadata = {
|
|
293
|
+
'data-dashkit-grid-cols': String(cols),
|
|
294
|
+
'data-dashkit-grid-h': String(h),
|
|
295
|
+
'data-dashkit-grid-margin-x': String(marginX),
|
|
296
|
+
'data-dashkit-grid-margin-y': String(marginY),
|
|
297
|
+
'data-dashkit-grid-padding-x': String(paddingX),
|
|
298
|
+
'data-dashkit-grid-padding-y': String(paddingY),
|
|
299
|
+
'data-dashkit-grid-row-height': String(rowHeight),
|
|
300
|
+
'data-dashkit-grid-use-css-transforms': String(useCSSTransforms),
|
|
301
|
+
'data-dashkit-grid-w': String(w),
|
|
302
|
+
'data-dashkit-grid-x': String(x),
|
|
303
|
+
'data-dashkit-grid-y': String(y),
|
|
304
|
+
};
|
|
262
305
|
// Lazy proxy for transformScaleRef so react-draggable reads fresh scale without re-render.
|
|
263
306
|
const { transformScaleRef } = this.props;
|
|
264
307
|
const lazyScale = transformScaleRef
|
|
@@ -271,12 +314,177 @@ class DragOverLayout extends ReactGridLayout {
|
|
|
271
314
|
style: this.isSharedDragTarget()
|
|
272
315
|
? Object.assign(Object.assign({}, gridItem.props.style), { opacity: 0 }) : gridItem.props.style, className: `${OVERLAY_CLASS_NAME} ${DROPPING_ELEMENT_CLASS_NAME}`, droppingPosition: this.calculateDroppingPosition(gridItem.props) }));
|
|
273
316
|
}
|
|
317
|
+
const gridChild = gridItem.props.children;
|
|
318
|
+
const cachedGridItemChild = this.gridItemChildren.get(gridChild);
|
|
319
|
+
const gridItemChild = cachedGridItemChild &&
|
|
320
|
+
Object.keys(gridItemMetadata).every((key) => cachedGridItemChild.metadata[key] === gridItemMetadata[key])
|
|
321
|
+
? cachedGridItemChild.child
|
|
322
|
+
: React.cloneElement(gridChild, gridItemMetadata);
|
|
323
|
+
if (gridItemChild !== (cachedGridItemChild === null || cachedGridItemChild === void 0 ? void 0 : cachedGridItemChild.child)) {
|
|
324
|
+
this.gridItemChildren.set(gridChild, {
|
|
325
|
+
child: gridItemChild,
|
|
326
|
+
metadata: gridItemMetadata,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
274
329
|
if (lazyScale !== undefined) {
|
|
275
|
-
return React.cloneElement(gridItem, {
|
|
330
|
+
return React.cloneElement(gridItem, {
|
|
331
|
+
children: gridItemChild,
|
|
332
|
+
transformScale: lazyScale,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return React.cloneElement(gridItem, { children: gridItemChild });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
class PassiveWidthProvider extends React.Component {
|
|
339
|
+
constructor() {
|
|
340
|
+
super(...arguments);
|
|
341
|
+
this.state = { interactionRevision: 0, isMounted: false, settledWidth: 1280 };
|
|
342
|
+
this.element = null;
|
|
343
|
+
this.elementRef = React.createRef();
|
|
344
|
+
this.widthRef = { current: 1280 };
|
|
345
|
+
this.gridItems = [];
|
|
346
|
+
this.isComponentMounted = false;
|
|
347
|
+
this.cacheGridItems = () => {
|
|
348
|
+
const node = this.element;
|
|
349
|
+
this.gridItems = node
|
|
350
|
+
? Array.from(node.children).filter((child) => child instanceof HTMLElement &&
|
|
351
|
+
child.matches('.react-grid-item[data-dashkit-grid-cols]'))
|
|
352
|
+
: [];
|
|
353
|
+
this.lastAppliedWidth = undefined;
|
|
354
|
+
};
|
|
355
|
+
this.updateGridItems = (width) => {
|
|
356
|
+
if (width === this.lastAppliedWidth) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.lastAppliedWidth = width;
|
|
360
|
+
this.gridItems.forEach((item) => {
|
|
361
|
+
if (item.classList.contains('react-draggable-dragging') ||
|
|
362
|
+
item.classList.contains('resizing')) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
const { dataset, style } = item;
|
|
366
|
+
const cols = Number(dataset.dashkitGridCols);
|
|
367
|
+
const x = Number(dataset.dashkitGridX);
|
|
368
|
+
const y = Number(dataset.dashkitGridY);
|
|
369
|
+
const w = Number(dataset.dashkitGridW);
|
|
370
|
+
const h = Number(dataset.dashkitGridH);
|
|
371
|
+
const marginX = Number(dataset.dashkitGridMarginX);
|
|
372
|
+
const marginY = Number(dataset.dashkitGridMarginY);
|
|
373
|
+
const paddingX = Number(dataset.dashkitGridPaddingX);
|
|
374
|
+
const paddingY = Number(dataset.dashkitGridPaddingY);
|
|
375
|
+
const rowHeight = Number(dataset.dashkitGridRowHeight);
|
|
376
|
+
const useCSSTransforms = dataset.dashkitGridUseCssTransforms === 'true';
|
|
377
|
+
if ([cols, x, y, w, h, marginX, marginY, paddingX, paddingY, rowHeight].some((value) => !Number.isFinite(value))) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
Object.assign(style, getGridItemStyle({
|
|
381
|
+
cols,
|
|
382
|
+
containerPadding: [paddingX, paddingY],
|
|
383
|
+
h,
|
|
384
|
+
margin: [marginX, marginY],
|
|
385
|
+
rowHeight,
|
|
386
|
+
useCSSTransforms,
|
|
387
|
+
w,
|
|
388
|
+
width,
|
|
389
|
+
x,
|
|
390
|
+
y,
|
|
391
|
+
}));
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
this.handlePointerDown = () => {
|
|
395
|
+
if (!this.props.isDraggable && !this.props.isResizable) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
flushSync(() => {
|
|
399
|
+
this.setState((state) => ({
|
|
400
|
+
interactionRevision: state.interactionRevision + 1,
|
|
401
|
+
settledWidth: this.widthRef.current,
|
|
402
|
+
}));
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
this.syncSettledWidth = () => {
|
|
406
|
+
if (this.state.settledWidth === this.widthRef.current) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
flushSync(() => {
|
|
410
|
+
this.setState({ settledWidth: this.widthRef.current });
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
this.scheduleSettledWidthCommit = () => {
|
|
414
|
+
if (this.settledWidthCommitFrame !== undefined) {
|
|
415
|
+
window.cancelAnimationFrame(this.settledWidthCommitFrame);
|
|
416
|
+
}
|
|
417
|
+
this.settledWidthCommitFrame = window.requestAnimationFrame(() => {
|
|
418
|
+
this.settledWidthCommitFrame = window.requestAnimationFrame(() => {
|
|
419
|
+
this.settledWidthCommitFrame = undefined;
|
|
420
|
+
if (this.state.settledWidth !== this.widthRef.current) {
|
|
421
|
+
this.setState({ settledWidth: this.widthRef.current });
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
this.syncElement = () => {
|
|
427
|
+
var _a;
|
|
428
|
+
const node = this.elementRef.current;
|
|
429
|
+
if (node === this.element) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (this.element) {
|
|
433
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.element);
|
|
434
|
+
this.element.removeEventListener('pointerdown', this.handlePointerDown, true);
|
|
435
|
+
}
|
|
436
|
+
this.element = node;
|
|
437
|
+
if (node && this.isComponentMounted) {
|
|
438
|
+
this.observeElement(node);
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
this.observeElement = (node) => {
|
|
442
|
+
var _a;
|
|
443
|
+
this.widthRef.current = node.clientWidth;
|
|
444
|
+
this.cacheGridItems();
|
|
445
|
+
this.updateGridItems(this.widthRef.current);
|
|
446
|
+
node.addEventListener('pointerdown', this.handlePointerDown, true);
|
|
447
|
+
(_a = this.resizeObserver) !== null && _a !== void 0 ? _a : (this.resizeObserver = new (typeof ResizeObserver === 'function' ? ResizeObserver : ResizeObserverPolyfill)((entries) => {
|
|
448
|
+
const entry = entries.find((currentEntry) => currentEntry.target === this.element);
|
|
449
|
+
if (!entry) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
this.widthRef.current = entry.contentRect.width;
|
|
453
|
+
this.updateGridItems(this.widthRef.current);
|
|
454
|
+
this.scheduleSettledWidthCommit();
|
|
455
|
+
}));
|
|
456
|
+
this.resizeObserver.observe(node);
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
componentDidMount() {
|
|
460
|
+
this.isComponentMounted = true;
|
|
461
|
+
this.syncElement();
|
|
462
|
+
this.setState({ isMounted: true, settledWidth: this.widthRef.current });
|
|
463
|
+
}
|
|
464
|
+
componentDidUpdate() {
|
|
465
|
+
this.syncElement();
|
|
466
|
+
this.cacheGridItems();
|
|
467
|
+
this.updateGridItems(this.widthRef.current);
|
|
468
|
+
}
|
|
469
|
+
componentWillUnmount() {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
this.isComponentMounted = false;
|
|
472
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
473
|
+
this.resizeObserver = undefined;
|
|
474
|
+
if (this.settledWidthCommitFrame !== undefined) {
|
|
475
|
+
window.cancelAnimationFrame(this.settledWidthCommitFrame);
|
|
476
|
+
this.settledWidthCommitFrame = undefined;
|
|
477
|
+
}
|
|
478
|
+
(_b = this.element) === null || _b === void 0 ? void 0 : _b.removeEventListener('pointerdown', this.handlePointerDown, true);
|
|
479
|
+
this.element = null;
|
|
480
|
+
}
|
|
481
|
+
render() {
|
|
482
|
+
const _a = this.props, { measureBeforeMount } = _a, props = __rest(_a, ["measureBeforeMount"]);
|
|
483
|
+
if (measureBeforeMount && !this.state.isMounted) {
|
|
484
|
+
return (React.createElement("div", { className: [props.className, GRID_LAYOUT_CLASS_NAME].filter(Boolean).join(' '), ref: this.elementRef, style: props.style }));
|
|
276
485
|
}
|
|
277
|
-
return
|
|
486
|
+
return (React.createElement(DragOverLayout, Object.assign({}, props, { innerRef: this.elementRef, onBeforeDragOver: this.syncSettledWidth, width: this.state.settledWidth })));
|
|
278
487
|
}
|
|
279
488
|
}
|
|
280
|
-
|
|
281
|
-
export const Layout = WidthProvider(DragOverLayout);
|
|
489
|
+
export const Layout = PassiveWidthProvider;
|
|
282
490
|
//# sourceMappingURL=ReactGridLayout.js.map
|
|
@@ -1 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CAAC","sourcesContent":["import React from 'react';\n\nimport type {Layout as RGLLayout} from 'react-grid-layout';\n// @ts-expect-error - utils is not exported in type definitions\nimport ReactGridLayout, {WidthProvider, utils} from 'react-grid-layout';\n\nimport {DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME} from '../../constants';\n\nconst isRefObject = (\n value: React.Ref<HTMLDivElement>,\n): value is React.RefObject<HTMLDivElement> => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'current' in value &&\n typeof value.current === 'object'\n );\n};\n\ntype SharedDragPosition = {\n offsetX: number;\n offsetY: number;\n};\n\ntype DragOverLayoutProps = ReactGridLayout.ReactGridLayoutProps & {\n innerRef?: React.Ref<HTMLDivElement>;\n isDragCaptured?: boolean;\n dragStateRef?: React.MutableRefObject<{isDragging: boolean; sourceGroup: string | null}>;\n sharedDragPositionRef?: React.MutableRefObject<SharedDragPosition | null>;\n group?: string;\n onDragTargetRestore?: () => void;\n transformScaleRef?: React.MutableRefObject<number>;\n groupResetRegistryRef?: React.MutableRefObject<Map<string, () => void>>;\n externalLayoutRevision?: number;\n};\n\ntype DragOverLayoutState = {\n layout: RGLLayout[];\n activeDrag: RGLLayout | null;\n};\n\ntype RGLLayoutWithPlaceholder = RGLLayout & {placeholder?: boolean};\n\ntype OnDragMethod = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n) => void;\n\nclass DragOverLayout extends ReactGridLayout {\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. We need to narrow the props type from ReactGridLayoutProps to DragOverLayoutProps for type safety in our custom methods\n props: DragOverLayoutProps;\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. State is initialized by parent constructor\n state: DragOverLayoutState;\n\n parentOnDrag: OnDragMethod;\n parentOnDragStop: OnDragMethod;\n _savedDraggedOutLayout: RGLLayout[] | null = null;\n // Suppresses onLayoutMaybeChanged during imperative layout restore actions.\n // Without this flag, our setState would trigger onLayoutChange back to the consumer\n // that just initiated the action, causing a spurious 'change' event.\n _isRestoringExternalLayout = false;\n\n constructor(props: DragOverLayoutProps, context?: unknown) {\n super(props, context);\n\n // @ts-expect-error - onDrag is a protected method in parent class\n this.parentOnDrag = this.onDrag;\n // @ts-expect-error - assigning custom method to parent's onDrag\n this.onDrag = this.extendedOnDrag;\n\n // @ts-expect-error - onDragStop is a protected method in parent class\n this.parentOnDragStop = this.onDragStop;\n // @ts-expect-error - assigning custom method to parent's onDragStop\n this.onDragStop = this.extendedOnDragStop;\n }\n\n componentDidMount(): void {\n super.componentDidMount?.();\n\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.set(\n this.props.group,\n this.resetExternalPlaceholder,\n );\n }\n\n // If cursor is moved out of the window there is a bug\n // which leaves placeholder element in grid, this action needed to reset this state\n window.addEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.addEventListener('mouseup', this.mouseUpHandler);\n innerElement.addEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.addEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.addEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n componentDidUpdate(prevProps: DragOverLayoutProps, prevState: DragOverLayoutState): void {\n const revisionChanged =\n prevProps.externalLayoutRevision !== this.props.externalLayoutRevision;\n\n if (revisionChanged && this.props.layout) {\n const newLayout = utils.synchronizeLayoutWithChildren(\n this.props.layout,\n this.props.children,\n this.props.cols,\n utils.compactType(this.props),\n this.props.allowOverlap,\n );\n\n this._isRestoringExternalLayout = true;\n // Override both layout and propsLayout so getDerivedStateFromProps\n // doesn't revert our update on the next render cycle.\n this.setState(\n {\n layout: newLayout,\n propsLayout: this.props.layout,\n } as unknown as DragOverLayoutState,\n () => {\n this._isRestoringExternalLayout = false;\n },\n );\n // RGL's shouldComponentUpdate only tracks activeDrag/mounted/droppingPosition — not\n // state.layout. So setState({layout}) alone is silently ignored (no re-render).\n // forceUpdate bypasses SCU and is batched with the setState above, producing a\n // single render cycle with the merged state that includes the restored layout.\n this.forceUpdate();\n // Don't call super here: restoring is an external action, not a user drag/resize.\n // onLayoutMaybeChanged is suppressed via _isRestoringExternalLayout.\n return;\n }\n\n // Maintain parent behavior for all non-restore cycles (drag, resize, etc.).\n super.componentDidUpdate?.(prevProps, prevState);\n }\n\n onLayoutMaybeChanged(newLayout: RGLLayout[], oldLayout: RGLLayout[]): void {\n if (this._isRestoringExternalLayout) {\n return;\n }\n // @ts-expect-error — onLayoutMaybeChanged is not in ReactGridLayout's public types\n super.onLayoutMaybeChanged(newLayout, oldLayout);\n }\n\n componentWillUnmount(): void {\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.delete(this.props.group);\n }\n\n window.removeEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.removeEventListener('mouseup', this.mouseUpHandler);\n innerElement.removeEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.removeEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.removeEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n // react-grid-layout doens't calculate it's height when last element is removed\n // and just keeps the previous value\n // so for autosize to work in that case we are resetting it's height value\n containerHeight(): string | undefined {\n if (this.props.autoSize && this.state.layout.length === 0) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n // @ts-expect-error - containerHeight is a protected method in parent class\n return super.containerHeight();\n }\n\n // innerRef is passed by WithProvider without this wrapper there are only\n // * findDOMNode - deprecated\n // * rewrite whole ReactGridLayout.render method\n // so in that case don't try to use this class on it's own\n // or pass innerRef: React.MutableRef as it's not optional prop\n getInnerElement(): HTMLDivElement | null {\n const {innerRef} = this.props;\n\n return innerRef && isRefObject(innerRef) && innerRef.current ? innerRef.current : null;\n }\n\n // Reset placeholder when item dragged from outside\n resetExternalPlaceholder = (): void => {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n if (this.dragEnterCounter) {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n this.dragEnterCounter = 0;\n // @ts-expect-error - removeDroppingPlaceholder is a protected method in parent class\n this.removeDroppingPlaceholder();\n }\n };\n\n // Hide placeholder when element is dragged out\n hideLocalPlaceholder = (i: string): RGLLayout[] => {\n const {layout} = this.state;\n const {cols} = this.props;\n const savedLayout = layout.map((item) => ({...item}));\n\n let hiddenElement: RGLLayout | undefined;\n const newLayout = utils.compact(\n layout.filter((item) => {\n if (item.i === i) {\n hiddenElement = item;\n return false;\n }\n\n return true;\n }),\n utils.compactType(this.props),\n cols,\n );\n\n if (hiddenElement) {\n newLayout.push(hiddenElement);\n }\n\n this.setState({\n activeDrag: null,\n layout: newLayout,\n });\n\n return savedLayout;\n };\n\n extendedOnDrag = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n if (this.props.isDragCaptured) {\n if (!this._savedDraggedOutLayout) {\n this._savedDraggedOutLayout = this.hideLocalPlaceholder(i);\n }\n\n return;\n }\n\n this._savedDraggedOutLayout = null;\n // parent onDrag will show new placeholder again\n this.parentOnDrag(i, x, y, sintEv);\n };\n\n extendedOnDragStop = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n // Restoring layout if item was dropped outside of the grid\n if (this._savedDraggedOutLayout) {\n const savedLayout = this._savedDraggedOutLayout;\n const l = utils.getLayoutItem(savedLayout, i);\n\n // Create placeholder (display only)\n const placeholder: RGLLayoutWithPlaceholder = {\n w: l.w,\n h: l.h,\n x: l.x,\n y: l.y,\n placeholder: true,\n i: i,\n };\n\n this.setState(\n {\n layout: savedLayout,\n activeDrag: placeholder,\n },\n () => {\n this.parentOnDragStop(i, x, y, sintEv);\n },\n );\n\n this._savedDraggedOutLayout = null;\n } else {\n this.parentOnDragStop(i, x, y, sintEv);\n }\n };\n\n isSharedDragTarget = (): boolean => {\n const drag = this.props.dragStateRef?.current;\n return Boolean(drag?.isDragging);\n };\n\n // Proxy mouse events -> drag methods for dnd between groups\n mouseEnterHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragEnter is a protected method in parent class\n this.onDragEnter(e);\n } else if (this.props.isDragCaptured) {\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseLeaveHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragLeave is a protected method in parent class\n this.onDragLeave(e);\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseMoveHandler = (e: MouseEvent): void => {\n if (\n this.isSharedDragTarget() &&\n this.props.group !== this.props.dragStateRef?.current.sourceGroup\n ) {\n if (!(e as MouseEvent & {nativeEvent?: MouseEvent}).nativeEvent) {\n // Emulate nativeEvent for firefox\n const target = this.getInnerElement() || (e.target as HTMLElement);\n\n (e as MouseEvent & {nativeEvent: Partial<MouseEvent>}).nativeEvent = {\n clientX: e.clientX,\n clientY: e.clientY,\n target,\n };\n }\n\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.onDragOver(e);\n }\n };\n\n mouseUpHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n e.preventDefault();\n const {droppingItem} = this.props;\n const {layout} = this.state;\n const item = layout.find((l) => l.i === droppingItem?.i);\n\n // reset dragEnter counter on drop for all registered groups\n this.props.groupResetRegistryRef?.current.forEach((reset) => reset());\n\n if (item) {\n this.props.onDrop?.(layout, item, e);\n }\n }\n };\n\n calculateDroppingPosition(itemProps: {\n containerWidth: number;\n cols: number;\n w: number;\n h: number;\n rowHeight: number;\n margin: [number, number];\n transformScale: number;\n droppingPosition: {left: number; top: number};\n }): {left: number; top: number} {\n const {containerWidth, cols, w, h, rowHeight, margin, transformScale, droppingPosition} =\n itemProps;\n const sharedDragPosition = this.props.sharedDragPositionRef?.current;\n\n let offsetX: number, offsetY: number;\n\n if (sharedDragPosition) {\n offsetX = sharedDragPosition.offsetX;\n offsetY = sharedDragPosition.offsetY;\n } else {\n offsetX = (((containerWidth / cols) * w) / 2 || 0) * transformScale;\n offsetY = ((h * rowHeight + (h - 1) * margin[1]) / 2 || 0) * transformScale;\n }\n\n return {\n ...droppingPosition,\n left: droppingPosition.left - offsetX,\n top: droppingPosition.top - offsetY,\n };\n }\n\n // Drop item from outside gets 0,0 droppingPosition\n // centering cursor on newly creted grid item\n // And cause grid-layout using it's own GridItem to make it look\n // like overlay adding className\n processGridItem(\n child: React.ReactElement,\n isDroppingItem?: boolean,\n ): React.ReactElement | undefined {\n // @ts-expect-error - processGridItem is a protected method in parent class\n const gridItem = super.processGridItem?.(child, isDroppingItem);\n\n if (!gridItem) {\n return gridItem;\n }\n\n // Lazy proxy for transformScaleRef so react-draggable reads fresh scale without re-render.\n const {transformScaleRef} = this.props;\n const lazyScale = transformScaleRef\n ? ({valueOf: () => transformScaleRef.current} as unknown as number)\n : undefined;\n\n if (isDroppingItem) {\n // React.cloneElement is just cleaner then copy-paste whole processGridItem method\n return React.cloneElement(gridItem, {\n ...(lazyScale !== undefined && {transformScale: lazyScale}),\n // hiding preview if dragging shared item\n style: this.isSharedDragTarget()\n ? {...gridItem.props.style, opacity: 0}\n : gridItem.props.style,\n className: `${OVERLAY_CLASS_NAME} ${DROPPING_ELEMENT_CLASS_NAME}`,\n droppingPosition: this.calculateDroppingPosition(gridItem.props),\n });\n }\n\n if (lazyScale !== undefined) {\n return React.cloneElement(gridItem, {transformScale: lazyScale});\n }\n\n return gridItem;\n }\n}\n\n// eslint-disable-next-line new-cap\nexport const Layout = WidthProvider<DragOverLayoutProps>(DragOverLayout);\n"]}
|
|
1
|
+
{"version":3,"file":"ReactGridLayout.js","sourceRoot":"../../../../src","sources":["components/GridLayout/ReactGridLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,+DAA+D;AAC/D,OAAO,eAAe,EAAE,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,sBAAsB,M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ACH,oBAAC,cAAc,oBACP,KAAK,IACT,QAAQ,EAAE,IAAI,CAAC,UAAU,EACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAChC,CACL,CAAC;IACN,CAAC;CA4IJ;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,oBAAoB,CAAC","sourcesContent":["import React from 'react';\n\nimport {flushSync} from 'react-dom';\nimport type {Layout as RGLLayout} from 'react-grid-layout';\n// @ts-expect-error - utils is not exported in type definitions\nimport ReactGridLayout, {utils} from 'react-grid-layout';\nimport ResizeObserverPolyfill from 'resize-observer-polyfill';\n\nimport {DROPPING_ELEMENT_CLASS_NAME, OVERLAY_CLASS_NAME} from '../../constants';\n\nconst GRID_LAYOUT_CLASS_NAME = 'react-grid-layout';\n\nconst isRefObject = (\n value: React.Ref<HTMLDivElement>,\n): value is React.RefObject<HTMLDivElement> => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'current' in value &&\n typeof value.current === 'object'\n );\n};\n\ntype SharedDragPosition = {\n offsetX: number;\n offsetY: number;\n};\n\ntype DragOverLayoutProps = ReactGridLayout.ReactGridLayoutProps & {\n innerRef?: React.Ref<HTMLDivElement>;\n isDragCaptured?: boolean;\n dragStateRef?: React.MutableRefObject<{isDragging: boolean; sourceGroup: string | null}>;\n sharedDragPositionRef?: React.MutableRefObject<SharedDragPosition | null>;\n group?: string;\n onDragTargetRestore?: () => void;\n transformScaleRef?: React.MutableRefObject<number>;\n groupResetRegistryRef?: React.MutableRefObject<Map<string, () => void>>;\n externalLayoutRevision?: number;\n onBeforeDragOver?: () => void;\n};\n\ntype DragOverLayoutState = {\n layout: RGLLayout[];\n activeDrag: RGLLayout | null;\n};\n\ntype RGLLayoutWithPlaceholder = RGLLayout & {placeholder?: boolean};\n\ntype PassiveWidthProviderProps = DragOverLayoutProps & {\n measureBeforeMount?: boolean;\n};\n\ntype OnDragMethod = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n) => void;\n\nconst getGridItemStyle = ({\n cols,\n containerPadding,\n margin,\n width,\n x,\n y,\n w,\n h,\n rowHeight,\n useCSSTransforms,\n}: {\n cols: number;\n containerPadding: [number, number];\n h: number;\n margin: [number, number];\n rowHeight: number;\n useCSSTransforms: boolean;\n w: number;\n width: number;\n x: number;\n y: number;\n}) => {\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const columnWidth = (width - marginX * (cols - 1) - paddingX * 2) / cols;\n const position = {\n height: Math.round(rowHeight * h + marginY * (h - 1)),\n left: Math.round((columnWidth + marginX) * x + paddingX),\n top: Math.round(paddingY + (rowHeight + marginY) * y),\n width: Math.round(columnWidth * w + marginX * (w - 1)),\n };\n\n return useCSSTransforms\n ? {...utils.setTransform(position), left: '', top: ''}\n : {\n ...utils.setTopLeft(position),\n MozTransform: '',\n OTransform: '',\n WebkitTransform: '',\n msTransform: '',\n transform: '',\n };\n};\n\nclass DragOverLayout extends ReactGridLayout {\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. We need to narrow the props type from ReactGridLayoutProps to DragOverLayoutProps for type safety in our custom methods\n props: DragOverLayoutProps;\n // @ts-expect-error - TypeScript doesn't allow direct property redeclaration in extending classes. State is initialized by parent constructor\n state: DragOverLayoutState;\n\n parentOnDrag: OnDragMethod;\n parentOnDragStop: OnDragMethod;\n parentOnDragOver: (e: MouseEvent) => false | void;\n _savedDraggedOutLayout: RGLLayout[] | null = null;\n // Suppresses onLayoutMaybeChanged during imperative layout restore actions.\n // Without this flag, our setState would trigger onLayoutChange back to the consumer\n // that just initiated the action, causing a spurious 'change' event.\n _isRestoringExternalLayout = false;\n private readonly gridItemChildren = new WeakMap<\n React.ReactElement,\n {child: React.ReactElement; metadata: Record<string, string>}\n >();\n\n constructor(props: DragOverLayoutProps, context?: unknown) {\n super(props, context);\n\n // @ts-expect-error - onDrag is a protected method in parent class\n this.parentOnDrag = this.onDrag;\n // @ts-expect-error - assigning custom method to parent's onDrag\n this.onDrag = this.extendedOnDrag;\n\n // @ts-expect-error - onDragStop is a protected method in parent class\n this.parentOnDragStop = this.onDragStop;\n // @ts-expect-error - assigning custom method to parent's onDragStop\n this.onDragStop = this.extendedOnDragStop;\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.parentOnDragOver = this.onDragOver;\n // @ts-expect-error - assigning custom method to parent's onDragOver\n this.onDragOver = this.extendedOnDragOver;\n }\n\n componentDidMount(): void {\n super.componentDidMount?.();\n\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.set(\n this.props.group,\n this.resetExternalPlaceholder,\n );\n }\n\n // If cursor is moved out of the window there is a bug\n // which leaves placeholder element in grid, this action needed to reset this state\n window.addEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.addEventListener('mouseup', this.mouseUpHandler);\n innerElement.addEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.addEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.addEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n componentDidUpdate(prevProps: DragOverLayoutProps, prevState: DragOverLayoutState): void {\n const revisionChanged =\n prevProps.externalLayoutRevision !== this.props.externalLayoutRevision;\n\n if (revisionChanged && this.props.layout) {\n const newLayout = utils.synchronizeLayoutWithChildren(\n this.props.layout,\n this.props.children,\n this.props.cols,\n utils.compactType(this.props),\n this.props.allowOverlap,\n );\n\n this._isRestoringExternalLayout = true;\n // Override both layout and propsLayout so getDerivedStateFromProps\n // doesn't revert our update on the next render cycle.\n this.setState(\n {\n layout: newLayout,\n propsLayout: this.props.layout,\n } as unknown as DragOverLayoutState,\n () => {\n this._isRestoringExternalLayout = false;\n },\n );\n // RGL's shouldComponentUpdate only tracks activeDrag/mounted/droppingPosition — not\n // state.layout. So setState({layout}) alone is silently ignored (no re-render).\n // forceUpdate bypasses SCU and is batched with the setState above, producing a\n // single render cycle with the merged state that includes the restored layout.\n this.forceUpdate();\n // Don't call super here: restoring is an external action, not a user drag/resize.\n // onLayoutMaybeChanged is suppressed via _isRestoringExternalLayout.\n return;\n }\n\n // Maintain parent behavior for all non-restore cycles (drag, resize, etc.).\n super.componentDidUpdate?.(prevProps, prevState);\n }\n\n onLayoutMaybeChanged(newLayout: RGLLayout[], oldLayout: RGLLayout[]): void {\n if (this._isRestoringExternalLayout) {\n return;\n }\n // @ts-expect-error — onLayoutMaybeChanged is not in ReactGridLayout's public types\n super.onLayoutMaybeChanged(newLayout, oldLayout);\n }\n\n componentWillUnmount(): void {\n if (this.props.group !== undefined) {\n this.props.groupResetRegistryRef?.current.delete(this.props.group);\n }\n\n window.removeEventListener('dragend', this.resetExternalPlaceholder);\n const innerElement = this.getInnerElement();\n\n if (innerElement) {\n innerElement.removeEventListener('mouseup', this.mouseUpHandler);\n innerElement.removeEventListener('mouseenter', this.mouseEnterHandler);\n innerElement.removeEventListener('mouseleave', this.mouseLeaveHandler);\n innerElement.removeEventListener('mousemove', this.mouseMoveHandler);\n }\n }\n\n // react-grid-layout doens't calculate it's height when last element is removed\n // and just keeps the previous value\n // so for autosize to work in that case we are resetting it's height value\n containerHeight(): string | undefined {\n if (this.props.autoSize && this.state.layout.length === 0) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n // @ts-expect-error - containerHeight is a protected method in parent class\n return super.containerHeight();\n }\n\n // innerRef is passed by WithProvider without this wrapper there are only\n // * findDOMNode - deprecated\n // * rewrite whole ReactGridLayout.render method\n // so in that case don't try to use this class on it's own\n // or pass innerRef: React.MutableRef as it's not optional prop\n getInnerElement(): HTMLDivElement | null {\n const {innerRef} = this.props;\n\n return innerRef && isRefObject(innerRef) && innerRef.current ? innerRef.current : null;\n }\n\n // Reset placeholder when item dragged from outside\n resetExternalPlaceholder = (): void => {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n if (this.dragEnterCounter) {\n // @ts-expect-error - dragEnterCounter is an internal property of parent class\n this.dragEnterCounter = 0;\n // @ts-expect-error - removeDroppingPlaceholder is a protected method in parent class\n this.removeDroppingPlaceholder();\n }\n };\n\n // Hide placeholder when element is dragged out\n hideLocalPlaceholder = (i: string): RGLLayout[] => {\n const {layout} = this.state;\n const {cols} = this.props;\n const savedLayout = layout.map((item) => ({...item}));\n\n let hiddenElement: RGLLayout | undefined;\n const newLayout = utils.compact(\n layout.filter((item) => {\n if (item.i === i) {\n hiddenElement = item;\n return false;\n }\n\n return true;\n }),\n utils.compactType(this.props),\n cols,\n );\n\n if (hiddenElement) {\n newLayout.push(hiddenElement);\n }\n\n this.setState({\n activeDrag: null,\n layout: newLayout,\n });\n\n return savedLayout;\n };\n\n extendedOnDrag = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n if (this.props.isDragCaptured) {\n if (!this._savedDraggedOutLayout) {\n this._savedDraggedOutLayout = this.hideLocalPlaceholder(i);\n }\n\n return;\n }\n\n this._savedDraggedOutLayout = null;\n // parent onDrag will show new placeholder again\n this.parentOnDrag(i, x, y, sintEv);\n };\n\n extendedOnDragStop = (\n i: string,\n x: number,\n y: number,\n sintEv: {e: Event; node: HTMLElement},\n ): void => {\n // Restoring layout if item was dropped outside of the grid\n if (this._savedDraggedOutLayout) {\n const savedLayout = this._savedDraggedOutLayout;\n const l = utils.getLayoutItem(savedLayout, i);\n\n // Create placeholder (display only)\n const placeholder: RGLLayoutWithPlaceholder = {\n w: l.w,\n h: l.h,\n x: l.x,\n y: l.y,\n placeholder: true,\n i: i,\n };\n\n this.setState(\n {\n layout: savedLayout,\n activeDrag: placeholder,\n },\n () => {\n this.parentOnDragStop(i, x, y, sintEv);\n },\n );\n\n this._savedDraggedOutLayout = null;\n } else {\n this.parentOnDragStop(i, x, y, sintEv);\n }\n };\n\n extendedOnDragOver = (e: MouseEvent): false | void => {\n this.props.onBeforeDragOver?.();\n return this.parentOnDragOver(e);\n };\n\n isSharedDragTarget = (): boolean => {\n const drag = this.props.dragStateRef?.current;\n return Boolean(drag?.isDragging);\n };\n\n // Proxy mouse events -> drag methods for dnd between groups\n mouseEnterHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragEnter is a protected method in parent class\n this.onDragEnter(e);\n } else if (this.props.isDragCaptured) {\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseLeaveHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n // @ts-expect-error - onDragLeave is a protected method in parent class\n this.onDragLeave(e);\n this.props.onDragTargetRestore?.();\n }\n };\n\n mouseMoveHandler = (e: MouseEvent): void => {\n if (\n this.isSharedDragTarget() &&\n this.props.group !== this.props.dragStateRef?.current.sourceGroup\n ) {\n if (!(e as MouseEvent & {nativeEvent?: MouseEvent}).nativeEvent) {\n // Emulate nativeEvent for firefox\n const target = this.getInnerElement() || (e.target as HTMLElement);\n\n (e as MouseEvent & {nativeEvent: Partial<MouseEvent>}).nativeEvent = {\n clientX: e.clientX,\n clientY: e.clientY,\n target,\n };\n }\n\n // @ts-expect-error - onDragOver is a protected method in parent class\n this.onDragOver(e);\n }\n };\n\n mouseUpHandler = (e: MouseEvent): void => {\n if (this.isSharedDragTarget()) {\n e.preventDefault();\n const {droppingItem} = this.props;\n const {layout} = this.state;\n const item = layout.find((l) => l.i === droppingItem?.i);\n\n // reset dragEnter counter on drop for all registered groups\n this.props.groupResetRegistryRef?.current.forEach((reset) => reset());\n\n if (item) {\n this.props.onDrop?.(layout, item, e);\n }\n }\n };\n\n calculateDroppingPosition(itemProps: {\n containerWidth: number;\n cols: number;\n w: number;\n h: number;\n rowHeight: number;\n margin: [number, number];\n transformScale: number;\n droppingPosition: {left: number; top: number};\n }): {left: number; top: number} {\n const {containerWidth, cols, w, h, rowHeight, margin, transformScale, droppingPosition} =\n itemProps;\n const sharedDragPosition = this.props.sharedDragPositionRef?.current;\n\n let offsetX: number, offsetY: number;\n\n if (sharedDragPosition) {\n offsetX = sharedDragPosition.offsetX;\n offsetY = sharedDragPosition.offsetY;\n } else {\n offsetX = (((containerWidth / cols) * w) / 2 || 0) * transformScale;\n offsetY = ((h * rowHeight + (h - 1) * margin[1]) / 2 || 0) * transformScale;\n }\n\n return {\n ...droppingPosition,\n left: droppingPosition.left - offsetX,\n top: droppingPosition.top - offsetY,\n };\n }\n\n // Drop item from outside gets 0,0 droppingPosition\n // centering cursor on newly creted grid item\n // And cause grid-layout using it's own GridItem to make it look\n // like overlay adding className\n processGridItem(\n child: React.ReactElement,\n isDroppingItem?: boolean,\n ): React.ReactElement | undefined {\n // @ts-expect-error - processGridItem is a protected method in parent class\n const gridItem = super.processGridItem?.(child, isDroppingItem);\n\n if (!gridItem) {\n return gridItem;\n }\n\n const {cols, containerPadding, h, margin, rowHeight, useCSSTransforms, w, x, y} =\n gridItem.props;\n const [marginX, marginY] = margin;\n const [paddingX, paddingY] = containerPadding;\n const gridItemMetadata: Record<string, string> = {\n 'data-dashkit-grid-cols': String(cols),\n 'data-dashkit-grid-h': String(h),\n 'data-dashkit-grid-margin-x': String(marginX),\n 'data-dashkit-grid-margin-y': String(marginY),\n 'data-dashkit-grid-padding-x': String(paddingX),\n 'data-dashkit-grid-padding-y': String(paddingY),\n 'data-dashkit-grid-row-height': String(rowHeight),\n 'data-dashkit-grid-use-css-transforms': String(useCSSTransforms),\n 'data-dashkit-grid-w': String(w),\n 'data-dashkit-grid-x': String(x),\n 'data-dashkit-grid-y': String(y),\n };\n // Lazy proxy for transformScaleRef so react-draggable reads fresh scale without re-render.\n const {transformScaleRef} = this.props;\n const lazyScale = transformScaleRef\n ? ({valueOf: () => transformScaleRef.current} as unknown as number)\n : undefined;\n\n if (isDroppingItem) {\n // React.cloneElement is just cleaner then copy-paste whole processGridItem method\n return React.cloneElement(gridItem, {\n ...(lazyScale !== undefined && {transformScale: lazyScale}),\n // hiding preview if dragging shared item\n style: this.isSharedDragTarget()\n ? {...gridItem.props.style, opacity: 0}\n : gridItem.props.style,\n className: `${OVERLAY_CLASS_NAME} ${DROPPING_ELEMENT_CLASS_NAME}`,\n droppingPosition: this.calculateDroppingPosition(gridItem.props),\n });\n }\n\n const gridChild = gridItem.props.children as React.ReactElement<Record<string, string>>;\n const cachedGridItemChild = this.gridItemChildren.get(gridChild);\n const gridItemChild =\n cachedGridItemChild &&\n Object.keys(gridItemMetadata).every(\n (key) => cachedGridItemChild.metadata[key] === gridItemMetadata[key],\n )\n ? cachedGridItemChild.child\n : React.cloneElement(gridChild, gridItemMetadata);\n\n if (gridItemChild !== cachedGridItemChild?.child) {\n this.gridItemChildren.set(gridChild, {\n child: gridItemChild,\n metadata: gridItemMetadata,\n });\n }\n\n if (lazyScale !== undefined) {\n return React.cloneElement(gridItem, {\n children: gridItemChild,\n transformScale: lazyScale,\n });\n }\n\n return React.cloneElement(gridItem, {children: gridItemChild});\n }\n}\n\nclass PassiveWidthProvider extends React.Component<\n PassiveWidthProviderProps,\n {interactionRevision: number; isMounted: boolean; settledWidth: number}\n> {\n state = {interactionRevision: 0, isMounted: false, settledWidth: 1280};\n\n private element: HTMLDivElement | null = null;\n private readonly elementRef = React.createRef<HTMLDivElement>();\n private readonly widthRef = {current: 1280};\n private gridItems: HTMLElement[] = [];\n private lastAppliedWidth?: number;\n private resizeObserver?: ResizeObserver;\n private settledWidthCommitFrame?: number;\n private isComponentMounted = false;\n\n componentDidMount() {\n this.isComponentMounted = true;\n this.syncElement();\n this.setState({isMounted: true, settledWidth: this.widthRef.current});\n }\n\n componentDidUpdate() {\n this.syncElement();\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n }\n\n componentWillUnmount() {\n this.isComponentMounted = false;\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n if (this.settledWidthCommitFrame !== undefined) {\n window.cancelAnimationFrame(this.settledWidthCommitFrame);\n this.settledWidthCommitFrame = undefined;\n }\n this.element?.removeEventListener('pointerdown', this.handlePointerDown, true);\n this.element = null;\n }\n\n render() {\n const {measureBeforeMount, ...props} = this.props;\n\n if (measureBeforeMount && !this.state.isMounted) {\n return (\n <div\n className={[props.className, GRID_LAYOUT_CLASS_NAME].filter(Boolean).join(' ')}\n ref={this.elementRef}\n style={props.style}\n />\n );\n }\n\n return (\n <DragOverLayout\n {...props}\n innerRef={this.elementRef}\n onBeforeDragOver={this.syncSettledWidth}\n width={this.state.settledWidth}\n />\n );\n }\n\n private cacheGridItems = () => {\n const node = this.element;\n this.gridItems = node\n ? Array.from(node.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement &&\n child.matches('.react-grid-item[data-dashkit-grid-cols]'),\n )\n : [];\n this.lastAppliedWidth = undefined;\n };\n\n private updateGridItems = (width: number) => {\n if (width === this.lastAppliedWidth) {\n return;\n }\n this.lastAppliedWidth = width;\n\n this.gridItems.forEach((item) => {\n if (\n item.classList.contains('react-draggable-dragging') ||\n item.classList.contains('resizing')\n ) {\n return;\n }\n\n const {dataset, style} = item;\n const cols = Number(dataset.dashkitGridCols);\n const x = Number(dataset.dashkitGridX);\n const y = Number(dataset.dashkitGridY);\n const w = Number(dataset.dashkitGridW);\n const h = Number(dataset.dashkitGridH);\n const marginX = Number(dataset.dashkitGridMarginX);\n const marginY = Number(dataset.dashkitGridMarginY);\n const paddingX = Number(dataset.dashkitGridPaddingX);\n const paddingY = Number(dataset.dashkitGridPaddingY);\n const rowHeight = Number(dataset.dashkitGridRowHeight);\n const useCSSTransforms = dataset.dashkitGridUseCssTransforms === 'true';\n\n if (\n [cols, x, y, w, h, marginX, marginY, paddingX, paddingY, rowHeight].some(\n (value) => !Number.isFinite(value),\n )\n ) {\n return;\n }\n\n Object.assign(\n style,\n getGridItemStyle({\n cols,\n containerPadding: [paddingX, paddingY],\n h,\n margin: [marginX, marginY],\n rowHeight,\n useCSSTransforms,\n w,\n width,\n x,\n y,\n }),\n );\n });\n };\n\n private handlePointerDown = () => {\n if (!this.props.isDraggable && !this.props.isResizable) {\n return;\n }\n\n flushSync(() => {\n this.setState((state) => ({\n interactionRevision: state.interactionRevision + 1,\n settledWidth: this.widthRef.current,\n }));\n });\n };\n\n private syncSettledWidth = () => {\n if (this.state.settledWidth === this.widthRef.current) {\n return;\n }\n\n flushSync(() => {\n this.setState({settledWidth: this.widthRef.current});\n });\n };\n\n private scheduleSettledWidthCommit = () => {\n if (this.settledWidthCommitFrame !== undefined) {\n window.cancelAnimationFrame(this.settledWidthCommitFrame);\n }\n this.settledWidthCommitFrame = window.requestAnimationFrame(() => {\n this.settledWidthCommitFrame = window.requestAnimationFrame(() => {\n this.settledWidthCommitFrame = undefined;\n if (this.state.settledWidth !== this.widthRef.current) {\n this.setState({settledWidth: this.widthRef.current});\n }\n });\n });\n };\n\n private syncElement = () => {\n const node = this.elementRef.current;\n if (node === this.element) {\n return;\n }\n\n if (this.element) {\n this.resizeObserver?.unobserve(this.element);\n this.element.removeEventListener('pointerdown', this.handlePointerDown, true);\n }\n\n this.element = node;\n if (node && this.isComponentMounted) {\n this.observeElement(node);\n }\n };\n\n private observeElement = (node: HTMLDivElement) => {\n this.widthRef.current = node.clientWidth;\n this.cacheGridItems();\n this.updateGridItems(this.widthRef.current);\n node.addEventListener('pointerdown', this.handlePointerDown, true);\n this.resizeObserver ??= new (\n typeof ResizeObserver === 'function' ? ResizeObserver : ResizeObserverPolyfill\n )((entries: ResizeObserverEntry[]) => {\n const entry = entries.find((currentEntry) => currentEntry.target === this.element);\n if (!entry) {\n return;\n }\n\n this.widthRef.current = entry.contentRect.width;\n this.updateGridItems(this.widthRef.current);\n this.scheduleSettledWidthCommit();\n });\n this.resizeObserver.observe(node);\n };\n}\n\nexport const Layout = PassiveWidthProvider;\n"]}
|