Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
lhbxs committed Feb 4, 2024
2 parents 76a0e60 + d9027aa commit 387996e
Show file tree
Hide file tree
Showing 78 changed files with 8,171 additions and 6,313 deletions.
2 changes: 1 addition & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default defineConfig({
'form-render': path.resolve(__dirname, 'packages/form-render/src'),
'table-render': path.resolve(__dirname, 'packages/table-render/src'),
'@xrenders/schema-builder': path.resolve(__dirname, 'tools/schema-builder/src'),
'form-render-mobile': path.resolve(__dirname, 'packages/form-render-mobile/src'),
// 'form-render-mobile': path.resolve(__dirname, 'packages/form-render-mobile/src'),
'@xrenders/data-render': path.resolve(__dirname, 'packages/data-render/src'),
},
codeSplitting: { jsStrategy: 'granularChunks' },
Expand Down
2 changes: 1 addition & 1 deletion docs/form-render/advanced-bind.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default Demo;
```

## 进阶
- 对象嵌套情况, bind 要写决定路径
- 对象嵌套情况, bind 要写绝对路径
- List 组件嵌套情况,bind 路径从 List 嵌套的子节点开始写
```jsx
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion docs/form-render/api-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ group:
| configProvider | antd 的 configProvider,配置透传 | <a href="https://ant-design.antgroup.com/components/config-provider-cn/#API" target="_blank">ConfigProviderProps</a> | - |
| validateMessages | 修改默认的校验提示信息,详见[ValidateMessages](/form-render/advanced-validate) | `Record<string, string>` | - |
| id | 表单的 id,一般用于标识一个表单的语义化名称 | `string \| number` | - |

| antdVersion | antd 的版本 | `v4 \| v5` | `v5` |
## FormInstance

| <div style="width:200px">参数</div> | 描述 | 类型 |
Expand Down
15 changes: 15 additions & 0 deletions docs/form-render/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ toc: false

form-render 有生命周期的概念,请在 onMount 这个钩子里 set。

##### 3. type 为 object 类型自定义组件没有接收到 value 与 onChange 属性

例如下面这种 Schema 结构的自定义组件,2.x 会判定它是容器组件并非表单控件,那如何解决这种误判呢?增加一个 widgetType: 'field'
```js
{
type: "object",
widget: "WidgetObj",
properties: {
name: {
title: "name",
type: "string",
}
}
}
```
149 changes: 149 additions & 0 deletions docs/form-render/test/removeHidden.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import React from 'react';
import FormRender, { useForm } from 'form-render';

const schema = {
type: 'object',
properties: {
switch1: {
title: '禁用输入框',
type: 'boolean',
widget: 'switch'
},
input1: {
title: '输入框',
type: 'string',
hidden: '{{ formData.switch1 === true }}'
},

list: {
title: 'List 场景',
type: 'array',
widget: 'CardList',
items: {
type: 'object',
widget: 'card',
title: 'List.Item',
properties: {
switch1: {
title: '隐藏输入框 2 ',
type: 'boolean',
widget: 'switch'
},
input1: {
title: '输入框 1',
type: 'string',
description: '给输入框 赋值'
},
input2: {
title: '输入框 2',
type: 'string',
defaultValue: '{{ rootValue.input1 }}',
hidden: '{{ rootValue.switch1 }}'
},
obj: {
type: 'object',
title: '卡片主题',
description: '这是一个对象类型',
widget: 'collapse',
column: 3,

properties: {
input1: {
title: '输入框 A',
type: 'string',
hidden: '{{ rootValue.obj.switchx }}',
},
input2: {
title: '输入框 B',
type: 'string',
},
input3: {
title: '输入框 C',
type: 'string',
},
switchx: {
title: '隐藏输入框 2 ',
type: 'boolean',
widget: 'switch'
},
},
},
array: {
title: 'array 场景',
type: 'array',
widget: 'CardList',
items: {
type: 'object',
widget: 'card',
title: 'List.Item',
properties: {
switch1: {
title: '隐藏输入框 2 ',
type: 'boolean',
widget: 'switch'
},
input2: {
title: '输入框 2',
type: 'string',
hidden: '{{ rootValue.switch1 }}'
},
obj: {
type: 'object',
title: '卡片主题',
description: '这是一个对象类型',
widget: 'collapse',
column: 3,
// hidden: '{{ rootValue.switch1 }}',
properties: {
input1: {
title: '输入框 A',
type: 'string',
hidden: '{{ rootValue.obj.switch }}',
},
switch: {
title: '隐藏输入框A ',
type: 'boolean',
widget: 'switch'
},
},
},
}
}
}
}
}
}
}
};


export default () => {
const form = useForm();

const onFinish = (data) => {


const values = form.getValues();
console.log(data, '-----data', values)
};

return (
<FormRender
form={form}
schema={schema}
onFinish={onFinish}
footer={true}
className='xxx'
// removeHiddenData={false}
onMount={() => {
form.setValues({
switch1: true,
xxx: 1
})

form.setValueByPath('switch1', false);
}}
/>
);
}

4 changes: 3 additions & 1 deletion docs/form-render/test/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ mobile: false

<!-- <code src='./test/list.tsx'></code> -->

<!-- <code src='./test/dependencies.tsx'></code> -->
<!-- <code src='./test/dependencies.tsx'></code> -->

<!-- <code src='./test/removeHidden.tsx'></code> -->
Loading

0 comments on commit 387996e

Please sign in to comment.