Commit 231fdfd9 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加禁用属性

parent 1aa900fd
......@@ -44,6 +44,10 @@ export type ApplicableListProps = {
* 选项改变触发事件
*/
onChange?: (value: ValueType) => void,
/**
* 是否禁用
*/
disabled?: boolean,
};
const ShopList: React.FC<ApplicableListProps> = (props) => {
......@@ -52,6 +56,7 @@ const ShopList: React.FC<ApplicableListProps> = (props) => {
value: outerValue,
defaultValue = [],
onChange,
disabled,
} = props;
const initValue = 'value' in props ? outerValue : defaultValue;
const [value, setValue] = useState<ValueType>(initValue);
......@@ -77,6 +82,7 @@ const ShopList: React.FC<ApplicableListProps> = (props) => {
value={value}
onChange={handleChange}
className={styles['applicable-list-checkboxGroup']}
disabled={disabled}
>
<Row gutter={16}>
{options.map((item) => {
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-25 11:34:36
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-08 17:08:39
* @LastEditTime: 2021-08-02 17:40:56
* @Description: 会员方块复选框
*/
import React, { useState, useEffect, useRef } from 'react';
......@@ -88,6 +88,10 @@ export type MemberCheckboxGroupProps = {
* fetchOptions 额外的请求参数
*/
extraParams?: { [key: string]: any },
/**
* 是否禁用
*/
disabled?: boolean,
};
const MemberCheckboxGroup: React.FC<MemberCheckboxGroupProps> = (props) => {
......@@ -99,6 +103,7 @@ const MemberCheckboxGroup: React.FC<MemberCheckboxGroupProps> = (props) => {
showMoreAction = false,
fetchOptions,
extraParams,
disabled,
} = props;
const initValue = 'value' in props ? outerValue : defaultValue;
const [value, setValue] = useState<ValueType>(initValue);
......@@ -187,6 +192,7 @@ const MemberCheckboxGroup: React.FC<MemberCheckboxGroupProps> = (props) => {
value={value}
onChange={handleChange}
className={styles['member-list-checkboxGroup']}
disabled={disabled}
>
<Row gutter={[16, 16]}>
{optionList.map((item) => {
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-23 10:14:05
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-30 19:15:26
* @LastEditTime: 2021-08-02 17:42:33
* @Description: 豆腐方块复选框
*/
import React, { useState, useEffect } from 'react';
......@@ -44,6 +44,10 @@ export type TofuCheckboxGroupProps = {
* 选项改变触发事件
*/
onChange?: (value: ValueType) => void,
/**
* 是否禁用
*/
disabled?: boolean,
};
const TofuCheckboxGroup: React.FC<TofuCheckboxGroupProps> = (props) => {
......@@ -52,6 +56,7 @@ const TofuCheckboxGroup: React.FC<TofuCheckboxGroupProps> = (props) => {
value: outerValue,
defaultValue = [],
onChange,
disabled,
} = props;
const initValue = 'value' in props ? outerValue : defaultValue;
const [value, setValue] = useState<ValueType>(initValue);
......@@ -77,6 +82,7 @@ const TofuCheckboxGroup: React.FC<TofuCheckboxGroupProps> = (props) => {
value={value}
onChange={handleChange}
className={styles['tofuCheckbox-list-checkboxGroup']}
disabled={disabled}
>
{options.map((item) => {
const itemCls = classNames(styles['tofuCheckbox-list-item'], {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment