From ac39f677a0131b3196e0d913c0952fa0eab1ee26 Mon Sep 17 00:00:00 2001 From: Serge Pavlyuk Date: Thu, 4 Jul 2024 12:07:43 +0300 Subject: [PATCH] feat: group properties (#152) --- .../__stories__/DashKitGroupsShowcase.tsx | 7 ++++++- src/components/GridLayout/GridLayout.js | 14 +++++++++---- src/typings/config.ts | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/components/DashKit/__stories__/DashKitGroupsShowcase.tsx b/src/components/DashKit/__stories__/DashKitGroupsShowcase.tsx index e4d30a4..4976162 100644 --- a/src/components/DashKit/__stories__/DashKitGroupsShowcase.tsx +++ b/src/components/DashKit/__stories__/DashKitGroupsShowcase.tsx @@ -7,8 +7,10 @@ import { ActionPanel, DashKit, DashKitDnDWrapper, + DashKitGroup, DashKitProps, DashkitGroupRenderProps, + ReactGridLayoutProps, } from '../../..'; import {DEFAULT_GROUP, MenuItems} from '../../../helpers'; import {i18n} from '../../../i18n'; @@ -153,7 +155,7 @@ export const DashKitGroupsShowcase: React.FC = () => { [config], ); - const groups = React.useMemo( + const groups = React.useMemo( () => [ { id: fixedGroup, @@ -185,6 +187,9 @@ export const DashKitGroupsShowcase: React.FC = () => { ); }, + gridProperties: (props: ReactGridLayoutProps) => { + return {...props, compactType: 'horizontal'}; + }, }, { id: DEFAULT_GROUP, diff --git a/src/components/GridLayout/GridLayout.js b/src/components/GridLayout/GridLayout.js index 4fabddd..69e9c9a 100644 --- a/src/components/GridLayout/GridLayout.js +++ b/src/components/GridLayout/GridLayout.js @@ -203,7 +203,7 @@ export default class GridLayout extends React.PureComponent { ); } - renderGroup(group, renderLayout, renderItems, offset = 0) { + renderGroup(group, renderLayout, renderItems, offset = 0, groupGridProperties) { const { registerManager, editMode, @@ -213,11 +213,17 @@ export default class GridLayout extends React.PureComponent { outerDnDEnable, } = this.context; + const properties = groupGridProperties + ? groupGridProperties({ + ...registerManager.gridLayout, + }) + : registerManager.gridLayout; + return ( ; + export interface DashKitGroup { id?: string; render?: ( @@ -28,4 +47,5 @@ export interface DashKitGroup { children: React.ReactNode, props: DashkitGroupRenderProps, ) => React.ReactNode; + gridProperties?: (props: ReactGridLayoutProps) => ReactGridLayoutProps; }