添加 AssocicatedCheckboxes 草稿

This commit is contained in:
2betop 2020-05-28 20:28:11 +08:00
parent 878bb8c8f3
commit 9dffaa875b
3 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,17 @@
/**
*
*
* tree
*/
import React from 'react';
export interface AssociatedCheckboxesProps {}
export class AssociatedCheckboxes extends React.Component<
AssociatedCheckboxesProps
> {
render() {
return <div>todo</div>;
}
}

View File

@ -1,3 +1,6 @@
/**
*
*/
import {Checkboxes, CheckboxesProps} from './Checkboxes';
import {themeable} from '../theme';
import React from 'react';
@ -8,12 +11,16 @@ import {getTreeDepth} from '../utils/helper';
import times from 'lodash/times';
import Spinner from './Spinner';
export interface ChainedCheckboxesProps extends CheckboxesProps {
defaultSelectedIndex?: string;
}
export interface ChainedCheckboxesState {
selected: Array<string>;
}
export class ChainedCheckboxes extends Checkboxes<
CheckboxesProps,
ChainedCheckboxesProps,
ChainedCheckboxesState
> {
valueArray: Array<Option>;
@ -21,6 +28,16 @@ export class ChainedCheckboxes extends Checkboxes<
selected: []
};
componentDidMount() {
const defaultSelectedIndex = this.props.defaultSelectedIndex;
if (defaultSelectedIndex !== undefined) {
this.setState({
selected: [`${defaultSelectedIndex}`]
});
}
}
selectOption(option: Option, depth: number, id: string) {
const {onDeferLoad} = this.props;

View File

@ -150,6 +150,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
onChange={onChange}
option2value={option2value}
onDeferLoad={onDeferLoad}
defaultSelectedIndex={option.defaultSelectedIndex}
/>
) : (
<ListCheckboxes