From 94363cd1c55a62d02a36b3a694592ac51ad556ef Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Tue, 12 May 2020 14:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20checkboxes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scss/components/form/_checks.scss | 20 +++++ scss/components/form/_selections.scss | 2 - src/components/Checkboxes.tsx | 120 ++++++++++++-------------- src/components/Select.tsx | 4 +- src/components/Selections.tsx | 12 +-- 5 files changed, 84 insertions(+), 74 deletions(-) diff --git a/scss/components/form/_checks.scss b/scss/components/form/_checks.scss index b9e884031..d8911c73e 100644 --- a/scss/components/form/_checks.scss +++ b/scss/components/form/_checks.scss @@ -2,6 +2,7 @@ margin: 0 $gap-sm 0 0; font-weight: $fontWeightNormal; user-select: none; + pointer-events: none; input { opacity: 0; @@ -20,8 +21,10 @@ display: inline-block; vertical-align: middle; position: relative; + pointer-events: all; + span { + pointer-events: all; margin-left: $Checkbox-gap; cursor: pointer; @@ -230,6 +233,7 @@ color: $text--muted-color; margin-left: $Checkbox-gap; margin-top: $gap-xs; + pointer-events: all; } } @@ -274,6 +278,22 @@ } .#{$ns}Checkboxes { + > .#{$ns}Checkbox { + display: block; + height: $Form-input-height; + line-height: $Form-input-lineHeight; + font-size: $Form-input-fontSize; + padding: ( + $Form-input-height - $Form-input-lineHeight * $Form-input-fontSize + )/2 $gap-sm + ($Form-input-height - $Form-input-lineHeight * $Form-input-fontSize)/2 + ($gap-sm + $Checkbox-size); + } + + &--inline > .#{$ns}Checkbox { + display: inline-block; + } + &-addBtn { display: block; cursor: pointer; diff --git a/scss/components/form/_selections.scss b/scss/components/form/_selections.scss index 83e8ed781..ef51edc70 100644 --- a/scss/components/form/_selections.scss +++ b/scss/components/form/_selections.scss @@ -27,8 +27,6 @@ &-items { flex-grow: 1; - height: 0; - overflow: auto; } &-item { diff --git a/src/components/Checkboxes.tsx b/src/components/Checkboxes.tsx index 7db2358a8..994bfdf9c 100644 --- a/src/components/Checkboxes.tsx +++ b/src/components/Checkboxes.tsx @@ -8,117 +8,111 @@ import React from 'react'; import uncontrollable from 'uncontrollable'; import Checkbox from './Checkbox'; import chunk from 'lodash/chunk'; -import {ClassNamesFn, themeable} from '../theme'; -import {Option, OptionProps, value2array} from './Select'; +import {ClassNamesFn, themeable, ThemeProps} from '../theme'; +import {Option, value2array, Options} from './Select'; +import find from 'lodash/find'; // import isPlainObject from 'lodash/isPlainObject'; -interface CheckboxesProps extends OptionProps { - id?: string; - key?: string; +interface CheckboxesProps extends ThemeProps { + options: Options; className?: string; - type: string; placeholder?: string; - disabled?: boolean; - value?: string; - onChange?: Function; + value?: Array; + onChange?: (value: Array