From 01e49fe0a8d17c63061770430ee5995450db3d6f Mon Sep 17 00:00:00 2001 From: catchonme Date: Sun, 29 Sep 2019 11:35:58 +0800 Subject: [PATCH] =?UTF-8?q?tree=E9=80=89=E9=A1=B9disabled=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=92=8C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/renderers.md | 1 + docs/renderers/Form/Tag.md | 43 +++++++++++++++++++++++++++++++ examples/components/Doc.jsx | 7 +++++ examples/components/Form/Full.jsx | 11 ++++++++ src/components/Tree.tsx | 3 ++- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 docs/renderers/Form/Tag.md diff --git a/docs/renderers.md b/docs/renderers.md index fc681c8d..7082658a 100644 --- a/docs/renderers.md +++ b/docs/renderers.md @@ -26,6 +26,7 @@ amis 页面是通过 JSON 配置出来的,是由一个一个渲染模型组成 - [Email](./renderers/Form/Email.md): Email 输入框 - [Password](./renderers/Form/Password.md): 密码输入框 - [Number](./renderers/Form/Number.md): 数字输入框 + - [Tag](./renderers/Form/Tag.md): 标签输入框 - [Select](./renderers/Form/Select.md): 选项表单 - [Chained-Select](./renderers/Form/Chained-Select.md): 无限级别下拉 - [Checkbox](./renderers/Form/Checkbox.md): 勾选框 diff --git a/docs/renderers/Form/Tag.md b/docs/renderers/Form/Tag.md new file mode 100644 index 00000000..0e48b5e1 --- /dev/null +++ b/docs/renderers/Form/Tag.md @@ -0,0 +1,43 @@ +### Tag + +标签输入框。 + +- `type` 请设置成 `tag` +- `clearable` 在有值的时候是否显示一个删除图标在右侧。 +- `resetValue` 默认为 `""`, 删除后设置此配置项给定的值。 +- `optionsTip` 选项提示,默认为 `最近您使用的标签` +- `options` 选项配置,类型为数组,成员格式如下,或者直接为字符串,配置后用户输入内容时会作为选项提示辅助输入 + - `label` 文字 + - `value` 值 +- `source` 通过 `options` 只能配置静态数据,如果设置了 `source` 则会从接口拉取,实现动态效果。 +- `joinValues` 默认为 `true` +- 单选模式:当用户选中某个选项时,选项中的 value 将被作为该表单项的值提交,否则,整个选项对象都会作为该表单项的值提交。 +- 多选模式:选中的多个选项的 `value` 会通过 `delimiter` 连接起来,否则直接将以数组的形式提交值。 +- `delimiter` 默认为 `,` +- `extractValue` 默认为 `false`, `joinValues`设置为`false`时生效, 开启后将选中的选项 value 的值封装为数组,作为当前表单项的值。 +- **还有更多通用配置请参考** [FormItem](./FormItem.md) + +```schema:height="200" scope="form-item" +{ + "type": "tag", + "name": "tag", + "label": "标签" +} +``` + +带提示功能 + +```schema:height="240" scope="form-item" +{ + "type": "tag", + "name": "tag", + "label": "标签", + "clearable": true, + "options": [ + "wangzhaojun", + "libai", + "luna", + "zhongkui" + ] +} +``` diff --git a/examples/components/Doc.jsx b/examples/components/Doc.jsx index 60afa377..345927bc 100644 --- a/examples/components/Doc.jsx +++ b/examples/components/Doc.jsx @@ -189,6 +189,13 @@ export default { cb(null, makeMarkdownRenderer(doc)); }), }, + { + label: 'Tag', + path: '/docs/renderers/Form/Tag', + getComponent: (location, cb) => require(['../../docs/renderers/Form/Tag.md'], (doc) => { + cb(null, makeMarkdownRenderer(doc)); + }), + }, { label: 'Select', path: '/docs/renderers/Form/Select', diff --git a/examples/components/Form/Full.jsx b/examples/components/Form/Full.jsx index 63851403..95cde50c 100644 --- a/examples/components/Form/Full.jsx +++ b/examples/components/Form/Full.jsx @@ -60,6 +60,17 @@ export default { { type: "divider" }, + { + type: "tag", + name: "tag", + label: "标签", + placeholder: '', + clearable: true, + options: ["lixiaolong", "zhouxingxing", "yipingpei", "liyuanfang"] + }, + { + type: "divider" + }, { type: "text", name: "placeholder", diff --git a/src/components/Tree.tsx b/src/components/Tree.tsx index d76626eb..6413283e 100644 --- a/src/components/Tree.tsx +++ b/src/components/Tree.tsx @@ -556,7 +556,8 @@ export class TreeSelector extends React.Component {highlightTxt ? highlight(item[nameField], highlightTxt) : item[nameField]} - {!addTop + {!nodeDisabled + && !addTop && !addItem && !editItem ? (