diff --git a/packages/client/src/blocks/table/demos/demo1.tsx b/packages/client/src/blocks/table/demos/demo1.tsx
deleted file mode 100644
index b0cae4bf6..000000000
--- a/packages/client/src/blocks/table/demos/demo1.tsx
+++ /dev/null
@@ -1,283 +0,0 @@
-import React from 'react';
-import { SchemaRenderer } from '../../';
-import { uid } from '@formily/shared';
-import Editor from '@monaco-editor/react';
-import { createForm } from '@formily/core';
-import { observer } from '@formily/react';
-
-const schema = {
- name: `t_${uid()}`,
- type: 'array',
- 'x-component': 'Table',
- // default: [
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // { key: uid(), field1: uid(), field2: uid() },
- // ],
- 'x-component-props': {
- rowKey: 'key',
- // isRemoteDataSource: true,
- },
- properties: {
- [`a_${uid()}`]: {
- type: 'void',
- 'x-component': 'Table.ActionBar',
- properties: {
- action1: {
- type: 'void',
- name: 'action1',
- title: '筛选',
- 'x-component': 'Action',
- properties: {
- popover1: {
- type: 'void',
- title: '弹窗标题',
- 'x-component': 'Action.Popover',
- 'x-component-props': {},
- properties: {
- [uid()]: {
- name: 'form',
- type: 'object',
- 'x-component': 'Form',
- properties: {
- filter: {
- type: 'string',
- title: '字段1',
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- action: {
- type: 'void',
- title: '提交',
- 'x-component': 'Action',
- 'x-component-props': {
- 'useAction': '{{ useTableFilterAction }}'
- },
- }
- }
- },
- },
- },
- },
- },
- action2: {
- type: 'void',
- name: 'action1',
- title: '新增',
- 'x-component': 'Action',
- 'x-designable-bar': 'Action.DesignableBar',
- properties: {
- drawer1: {
- type: 'void',
- title: '抽屉标题',
- 'x-component': 'Action.Drawer',
- 'x-component-props': {},
- properties: {
- [uid()]: {
- name: 'form',
- type: 'object',
- 'x-component': 'Form',
- properties: {
- field1: {
- type: 'string',
- title: '字段1',
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- field2: {
- type: 'string',
- title: '字段2',
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- action: {
- type: 'void',
- title: '提交',
- 'x-component': 'Action',
- 'x-component-props': {
- 'useAction': '{{ useTableCreateAction }}'
- },
- }
- }
- },
- },
- },
- },
- },
- action3: {
- type: 'void',
- name: 'action1',
- title: '删除',
- 'x-component': 'Action',
- 'x-component-props': {
- 'useAction': '{{ useTableDestroyAction }}'
- },
- },
- },
- },
- [`a_${uid()}`]: {
- type: 'void',
- 'x-component': 'Table.ActionBar',
- 'x-component-props': {
- align: 'bottom',
- },
- properties: {
- pagination: {
- type: 'void',
- 'x-component': 'Table.Pagination',
- 'x-component-props': {
- defaultPageSize: 5,
- },
- },
- },
- },
- [`c_${uid()}`]: {
- type: 'void',
- title: '排序',
- 'x-component': 'Table.Column',
- properties: {
- sort: {
- type: 'void',
- 'x-component': 'Table.SortHandle',
- },
- },
- },
- [`c_${uid()}`]: {
- type: 'void',
- title: '序号',
- 'x-component': 'Table.Column',
- properties: {
- index: {
- type: 'void',
- 'x-component': 'Table.Index',
- },
- },
- },
- [`c_${uid()}`]: {
- type: 'void',
- title: '字段1',
- 'x-component': 'Table.Column',
- 'x-component-props': {
- title: 'z1',
- },
- 'x-designable-bar': 'Table.Column.DesignableBar',
- properties: {
- field1: {
- type: 'string',
- required: true,
- 'x-read-pretty': true,
- 'x-decorator-props': {
- feedbackLayout: 'popover',
- },
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- },
- },
- [`c_${uid()}`]: {
- type: 'void',
- title: '字段2',
- 'x-component': 'Table.Column',
- properties: {
- field2: {
- type: 'string',
- // title: '字段2',
- required: true,
- 'x-read-pretty': true,
- 'x-decorator-props': {
- feedbackLayout: 'popover',
- },
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- },
- },
- [`col_${uid()}`]: {
- type: 'void',
- title: '操作',
- 'x-component': 'Table.Column',
- properties: {
- action3: {
- type: 'void',
- title: '删除',
- 'x-component': 'Action',
- 'x-component-props': {
- 'useAction': '{{ useTableDestroyAction }}'
- },
- },
- action2: {
- type: 'void',
- name: 'action1',
- title: '修改',
- 'x-component': 'Action',
- 'x-default-action': true,
- 'x-designable-bar': 'Action.DesignableBar',
- properties: {
- drawer1: {
- type: 'void',
- title: '编辑表单',
- 'x-component': 'Action.Drawer',
- 'x-component-props': {},
- properties: {
- [uid()]: {
- name: 'form',
- type: 'void',
- 'x-component': 'Form',
- 'x-component-props': {
- 'useValues': '{{ useTableRow }}',
- },
- properties: {
- field1: {
- type: 'string',
- title: '字段1',
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- field2: {
- type: 'string',
- title: '字段2',
- 'x-decorator': 'FormItem',
- 'x-component': 'Input',
- },
- action: {
- type: 'void',
- title: '提交',
- 'x-component': 'Action',
- 'x-component-props': {
- 'useAction': '{{ useTableUpdateAction }}'
- },
- }
- }
- },
- },
- },
- },
- },
- },
- },
- },
-};
-
-const form = createForm();
-
-export default observer(() => {
- return (
-
-
-
-
- )
-});
diff --git a/packages/client/src/components/drag-and-drop/index.tsx b/packages/client/src/components/drag-and-drop/index.tsx
index 9a8a9d3ee..388cbd8db 100644
--- a/packages/client/src/components/drag-and-drop/index.tsx
+++ b/packages/client/src/components/drag-and-drop/index.tsx
@@ -4,7 +4,7 @@ import { useMouseEvents, useWillUnmount } from 'beautiful-react-hooks';
import { useField, useFieldSchema } from '@formily/react';
import { useMount } from 'ahooks';
import constate from 'constate';
-import { useSchemaPath } from '../../blocks';
+import { useSchemaPath } from '../../schemas';
export const DraggableBlockContext = createContext({
dragRef: null,
diff --git a/packages/client/src/blocks/DesignableSchemaField/index.tsx b/packages/client/src/schemas/DesignableSchemaField/index.tsx
similarity index 100%
rename from packages/client/src/blocks/DesignableSchemaField/index.tsx
rename to packages/client/src/schemas/DesignableSchemaField/index.tsx
diff --git a/packages/client/src/blocks/action/index.md b/packages/client/src/schemas/action/index.md
similarity index 73%
rename from packages/client/src/blocks/action/index.md
rename to packages/client/src/schemas/action/index.md
index c3a29588c..af15c5328 100644
--- a/packages/client/src/blocks/action/index.md
+++ b/packages/client/src/schemas/action/index.md
@@ -5,8 +5,8 @@ nav:
path: /client
group:
order: 1
- title: Components - 组件
- path: /client/components
+ title: Schemas
+ path: /client/schemas
---
# Action - 操作
@@ -94,6 +94,107 @@ export default () => {
}
```
+## Action.Dropdown - 下拉操作
+
+```tsx
+import React from 'react';
+import { SchemaRenderer } from '../';
+
+function useAction() {
+ return {
+ run() {
+ alert('这是自定义的操作逻辑');
+ }
+ }
+}
+
+const popoverSchema = {
+ type: 'void',
+ name: 'action1',
+ title: '按钮',
+ 'x-component': 'Action',
+ properties: {
+ popover1: {
+ type: 'void',
+ title: '弹窗标题',
+ 'x-component': 'Action.Popover',
+ 'x-component-props': {},
+ properties: {
+ input: {
+ type: 'string',
+ 'x-component': 'Input',
+ }
+ },
+ },
+ },
+};
+
+const drawerSchema = {
+ type: 'void',
+ title: '按钮',
+ 'x-component': 'Action',
+ properties: {
+ drawer1: {
+ type: 'void',
+ title: '抽屉标题',
+ 'x-component': 'Action.Drawer',
+ 'x-component-props': {},
+ properties: {
+ input: {
+ type: 'string',
+ 'x-decorator': 'FormItem',
+ 'x-component': 'Input',
+ },
+ action2: {
+ type: 'void',
+ title: '打开二级抽屉',
+ // 'x-decorator': 'FormItem',
+ 'x-component': 'Action',
+ properties: {
+ drawer1: {
+ type: 'void',
+ title: '二级抽屉标题',
+ 'x-component': 'Action.Drawer',
+ 'x-component-props': {},
+ properties: {
+ input: {
+ type: 'string',
+ 'x-component': 'Input',
+ },
+ },
+ },
+ },
+ }
+ },
+ },
+ },
+};
+
+const schema = {
+ type: 'void',
+ name: 'action1',
+ title: '下拉菜单',
+ 'x-component': 'Action.Dropdown',
+ properties: {
+ action1: {
+ type: 'void',
+ name: 'action1',
+ title: '按钮',
+ 'x-component': 'Action',
+ 'x-component-props': {
+ useAction,
+ },
+ },
+ action2: drawerSchema,
+ action3: popoverSchema,
+ },
+};
+
+export default () => {
+ return
+}
+```
+
## Action.Popover - 打开气泡
```tsx
diff --git a/packages/client/src/blocks/action/index.tsx b/packages/client/src/schemas/action/index.tsx
similarity index 85%
rename from packages/client/src/blocks/action/index.tsx
rename to packages/client/src/schemas/action/index.tsx
index 95a7a984a..f5cbda794 100644
--- a/packages/client/src/blocks/action/index.tsx
+++ b/packages/client/src/schemas/action/index.tsx
@@ -12,10 +12,10 @@ import {
} from '@formily/react';
import { Button, Dropdown, Menu, Popover, Space, Drawer, Modal } from 'antd';
import { Link, useHistory, LinkProps } from 'react-router-dom';
-import { SchemaRenderer, useDesignable } from '../';
+import { SchemaRenderer, useDesignable } from '..';
import ReactDOM from 'react-dom';
import get from 'lodash/get';
-import { MenuOutlined } from '@ant-design/icons';
+import { MenuOutlined, DownOutlined } from '@ant-design/icons';
import classNames from 'classnames';
import { useMount } from 'ahooks';
import { uid } from '@formily/shared';
@@ -78,6 +78,7 @@ export type ActionType = React.FC & {
Drawer?: React.FC;
Modal?: React.FC;
Dropdown?: React.FC;
+ Group?: React.FC;
DesignableBar?: React.FC;
};
@@ -115,7 +116,7 @@ const BaseAction = observer((props: any) => {
field.componentProps.setVisible = setVisible;
}, []);
- console.log('BaseAction', { field, schema }, field.title)
+ console.log('BaseAction', { field, schema }, field.title);
const renderButton = () => (