From bd554b2c3772dc29b2110708d2424357b6a99bb4 Mon Sep 17 00:00:00 2001 From: catchonme Date: Fri, 10 Jan 2020 12:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9C=E8=89=B2=E9=80=89=E6=8B=A9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/renderers/Form/Color.md | 5 +++-- src/components/ColorPicker.tsx | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/renderers/Form/Color.md b/docs/renderers/Form/Color.md index 1f1572e6..d0bd4d30 100644 --- a/docs/renderers/Form/Color.md +++ b/docs/renderers/Form/Color.md @@ -6,8 +6,9 @@ - `format` 请选择 `hex`、`hls`、`rgb`或者`rgba`。默认为 `hex`。 - `presetColors` 选择器底部的默认颜色 - 默认为`['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF']`,数组内为空则不显示默认颜色 -- `allowCustomColor` 自定义颜色选择,默认为`false`,使用 `presetColors` 自定义颜色 +- `allowCustomColor` 是否允许自定义颜色,默认为`true`,为`false`时只能选择颜色,使用 `presetColors` 设定颜色选择范围 - `clearable` 是否显示清除按钮。 +- `resetValue` 默认为 `""`, 删除后设置此配置项给定的值。 ```schema:height="400" scope="form-item" { @@ -20,6 +21,6 @@ "type": "color", "name": "customColor", "label": "自定义颜色", - "allowCustomColor": true + "allowCustomColor": false } ``` diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx index ccc6504b..60a1b3f5 100644 --- a/src/components/ColorPicker.tsx +++ b/src/components/ColorPicker.tsx @@ -46,7 +46,7 @@ export class ColorControl extends React.PureComponent< format: 'hex', clearable: true, placeholder: '请选择颜色', - allowCustomColor: false + allowCustomColor: true // closeOnSelect: true }; state = { @@ -254,19 +254,19 @@ export class ColorControl extends React.PureComponent< overlay > {allowCustomColor ? ( + + ) : ( - ) : ( - - ) - } + )} ) : null}