From a342eb351e57becd8cc194e94c42af9a171b1360 Mon Sep 17 00:00:00 2001 From: zhixin Date: Tue, 20 Aug 2019 08:52:34 +0800 Subject: [PATCH] Added singleRadio option to support hide radio buttons --- docs/_i18n/en/documentation/options.md | 10 ++++++++ docs/_i18n/zh-cn/documentation/options.md | 10 ++++++++ docs/_includes/example-list.md | 1 + docs/examples/single-radio.html | 30 +++++++++++++++++++++++ src/MultipleSelect.js | 11 +++++++-- src/multiple-select.scss | 24 +++++++++++++++++- 6 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 docs/examples/single-radio.html diff --git a/docs/_i18n/en/documentation/options.md b/docs/_i18n/en/documentation/options.md index baf14dfb..b25c0730 100644 --- a/docs/_i18n/en/documentation/options.md +++ b/docs/_i18n/en/documentation/options.md @@ -80,6 +80,16 @@ Option format: **Example:** Single Row +## singleRadio + +**Type:** Boolean + +**Detail:** Allows you to show the radio input when `single` is set to `true` (from v1.4.0). + +**Default:** `false` + +**Example:** Single Radio + ## multiple **Type:** Boolean diff --git a/docs/_i18n/zh-cn/documentation/options.md b/docs/_i18n/zh-cn/documentation/options.md index de6444b5..19db9e9e 100644 --- a/docs/_i18n/zh-cn/documentation/options.md +++ b/docs/_i18n/zh-cn/documentation/options.md @@ -80,6 +80,16 @@ Option 格式: **例子:** Single Row +## singleRadio + +**类型:** Boolean + +**说明:** 当 `single` 设置为 `true` 的时候允许显示单选框(v1.4.0)。 + +**默认:** `false` + +**例子:** Single Radio + ## multiple **类型:** Boolean diff --git a/docs/_includes/example-list.md b/docs/_includes/example-list.md index 4fb7e3b1..65391a07 100644 --- a/docs/_includes/example-list.md +++ b/docs/_includes/example-list.md @@ -12,6 +12,7 @@
  • The Placeholder
  • Hide Select All
  • Single Row
  • +
  • Single Radio
  • Multiple Items
  • Multiple Items Optgroups
  • Hide Optgroup Check
  • diff --git a/docs/examples/single-radio.html b/docs/examples/single-radio.html new file mode 100644 index 00000000..afe24bf7 --- /dev/null +++ b/docs/examples/single-radio.html @@ -0,0 +1,30 @@ + + + + + + + diff --git a/src/MultipleSelect.js b/src/MultipleSelect.js index 58779aa8..5db67f93 100644 --- a/src/MultipleSelect.js +++ b/src/MultipleSelect.js @@ -251,9 +251,14 @@ class MultipleSelect { const customStyle = this.options.styler(row.value) const style = customStyle ? sprintf`style="${s}"`(customStyle) : '' + let classes = row.classes + + if (this.options.single && !this.options.singleRadio) { + classes += ' hide-radio' + } return [ - sprintf`
  • `(multiple, row.classes || '', title, style), + sprintf`
  • `(multiple, classes || '', title, style), sprintf`