From d2275455befd29502059dcbe6a2984b1c28dfa71 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 22 Dec 2022 20:01:28 +0800 Subject: [PATCH] fix(client/demos): gird x-initializer --- .../antd/grid/demos/demo3.tsx | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/grid/demos/demo3.tsx b/packages/core/client/src/schema-component/antd/grid/demos/demo3.tsx index 05616e8b21..a1311fe258 100644 --- a/packages/core/client/src/schema-component/antd/grid/demos/demo3.tsx +++ b/packages/core/client/src/schema-component/antd/grid/demos/demo3.tsx @@ -1,18 +1,60 @@ import { ISchema, observer, useFieldSchema } from '@formily/react'; import { uid } from '@formily/shared'; import { - BlockItem, CardItem, DragHandler, - Form, Grid, Markdown, SchemaComponent, SchemaComponentProvider, + SchemaInitializer, SchemaInitializerProvider } from '@nocobase/client'; import React from 'react'; +const gridRowColWrap = (schema) => { + return { + type: 'void', + 'x-component': 'Grid.Row', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'Grid.Col', + properties: { + [schema.name || uid()]: schema, + }, + }, + }, + }; +}; + +export const AddBlockButton = (props: any) => { + const { insertPosition, component } = props; + return ( + + ); +}; + const Block = observer((props) => { const fieldSchema = useFieldSchema(); return ( @@ -29,7 +71,7 @@ const schema: ISchema = { grid: { type: 'void', 'x-component': 'Grid', - 'x-item-initializer': 'AddBlockItem', + 'x-initializer': 'AddBlockButton', 'x-uid': uid(), properties: {}, }, @@ -38,8 +80,8 @@ const schema: ISchema = { export default function App() { return ( - - + +