1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
index.tsx 1.5 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
HughHzWu Отправлено 6 лет назад 267b8e7
import React, { Component, ReactNode } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import omit from 'lodash/omit';
import RcSwitch from '../rc-components/switch';
import { Size } from '../_util/enum';
import { getPrefixCls } from '../configure';
export interface SwitchProps {
prefixCls?: string;
size?: Size;
className?: string;
checked?: boolean;
defaultChecked?: boolean;
onChange?: (checked: boolean) => any;
checkedChildren?: ReactNode;
unCheckedChildren?: ReactNode;
disabled?: boolean;
loading?: boolean;
}
export default class Switch extends Component<SwitchProps, {}> {
static displayName = 'Switch';
static propTypes = {
prefixCls: PropTypes.string,
// size=default and size=large are the same
size: PropTypes.oneOf([Size.small, Size.default, Size.large]),
className: PropTypes.string,
};
private rcSwitch: any;
focus() {
this.rcSwitch.focus();
}
blur() {
this.rcSwitch.blur();
}
saveSwitch = (node: RcSwitch | null) => {
this.rcSwitch = node;
};
render() {
const { prefixCls: customizePrefixCls, size, loading, className = '' } = this.props;
const prefixCls = getPrefixCls('switch', customizePrefixCls);
const classes = classNames(className, {
[`${prefixCls}-small`]: size === Size.small,
[`${prefixCls}-loading`]: loading,
});
return (
<RcSwitch
{...omit(this.props, ['loading'])}
prefixCls={prefixCls}
className={classes}
ref={this.saveSwitch}
/>
);
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/open-hand-choerodon-ui.git
git@gitlife.ru:oschina-mirror/open-hand-choerodon-ui.git
oschina-mirror
open-hand-choerodon-ui
open-hand-choerodon-ui
1.5.0-beta.0