From e4d190ea2a562e7d6c7df7ab37eaf72bce2c3314 Mon Sep 17 00:00:00 2001 From: Serge Pavlyuk Date: Wed, 20 Nov 2024 01:26:20 +0300 Subject: [PATCH] feat: pass gridLayout setting for each group --- src/components/GridItem/GridItem.js | 2 ++ src/components/GridLayout/GridLayout.js | 6 ++++-- src/hocs/prepareItem.js | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/GridItem/GridItem.js b/src/components/GridItem/GridItem.js index ae7bf24..be69810 100644 --- a/src/components/GridItem/GridItem.js +++ b/src/components/GridItem/GridItem.js @@ -48,6 +48,7 @@ const windowFocusObserver = new WindowFocusObserver(); class GridItem extends React.PureComponent { static propTypes = { adjustWidgetLayout: PropTypes.func.isRequired, + gridLayout: PropTypes.object, id: PropTypes.string, item: PropTypes.object, isDragging: PropTypes.bool, @@ -222,6 +223,7 @@ class GridItem extends React.PureComponent { forwardedPluginRef={this.props.forwardedPluginRef} onItemMountChange={this.props.onItemMountChange} onItemRender={this.props.onItemRender} + gridLayout={this.props.gridLayout} /> {!noOverlay && this.renderOverlay()} diff --git a/src/components/GridLayout/GridLayout.js b/src/components/GridLayout/GridLayout.js index 129a1b5..6c65d8f 100644 --- a/src/components/GridLayout/GridLayout.js +++ b/src/components/GridLayout/GridLayout.js @@ -551,7 +551,7 @@ export default class GridLayout extends React.PureComponent { return false; }; - renderTemporaryPlaceholder() { + renderTemporaryPlaceholder(gridLayout) { const {temporaryLayout, noOverlay, draggableHandleClassName} = this.context; if (!temporaryLayout || !temporaryLayout.dragProps) { @@ -572,6 +572,7 @@ export default class GridLayout extends React.PureComponent { isPlaceholder={true} noOverlay={noOverlay} withCustomHandle={Boolean(draggableHandleClassName)} + gridLayout={gridLayout} /> ); } @@ -662,10 +663,11 @@ export default class GridLayout extends React.PureComponent { withCustomHandle={Boolean(draggableHandleClassName)} onItemMountChange={onItemMountChange} onItemRender={onItemRender} + gridLayout={properties} /> ); })} - {this.renderTemporaryPlaceholder()} + {this.renderTemporaryPlaceholder(properties)} ); } diff --git a/src/hocs/prepareItem.js b/src/hocs/prepareItem.js index 229f1bd..8f56c71 100644 --- a/src/hocs/prepareItem.js +++ b/src/hocs/prepareItem.js @@ -7,6 +7,7 @@ import {DashKitContext} from '../context/DashKitContext'; export function prepareItem(Component) { return class PrepareItem extends React.Component { static propTypes = { + gridLayout: PropTypes.object, adjustWidgetLayout: PropTypes.func.isRequired, layout: PropTypes.array, id: PropTypes.string, @@ -45,7 +46,8 @@ export function prepareItem(Component) { _currentRenderProps = {}; getRenderProps = () => { - const {id, width, height, item, adjustWidgetLayout, layout, isPlaceholder} = this.props; + const {id, width, height, item, adjustWidgetLayout, layout, isPlaceholder, gridLayout} = + this.props; const {itemsState, itemsParams, registerManager, settings, context, editMode} = this.context; const {data, defaults, namespace} = item; @@ -64,7 +66,7 @@ export function prepareItem(Component) { settings, context, layout, - gridLayout: registerManager.gridLayout, + gridLayout: gridLayout || registerManager.gridLayout, adjustWidgetLayout, isPlaceholder, };