2019-01-12 11:33:27 +08:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2019-03-15 15:12:28 +08:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2019-08-28 10:50:19 +08:00
|
|
|
import Base from '../base';
|
2019-03-15 15:12:28 +08:00
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
const Divider = {
|
2018-04-08 21:17:20 +08:00
|
|
|
name: 'ADivider',
|
2018-01-30 18:22:41 +08:00
|
|
|
props: {
|
2019-03-15 15:12:28 +08:00
|
|
|
prefixCls: PropTypes.string,
|
2018-09-05 21:28:54 +08:00
|
|
|
type: PropTypes.oneOf(['horizontal', 'vertical', '']).def('horizontal'),
|
2018-01-30 18:22:41 +08:00
|
|
|
dashed: PropTypes.bool,
|
2020-03-07 19:45:13 +08:00
|
|
|
orientation: PropTypes.oneOf(['left', 'right', 'center']),
|
2018-01-30 18:22:41 +08:00
|
|
|
},
|
2019-03-15 15:12:28 +08:00
|
|
|
inject: {
|
2019-09-11 22:35:25 +08:00
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
2018-01-30 18:22:41 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
render() {
|
2020-03-07 19:45:13 +08:00
|
|
|
const { prefixCls: customizePrefixCls, type, $slots, dashed, orientation = 'center' } = this;
|
2019-09-11 22:35:25 +08:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-03-15 15:12:28 +08:00
|
|
|
const prefixCls = getPrefixCls('divider', customizePrefixCls);
|
|
|
|
const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation;
|
|
|
|
|
|
|
|
const classString = {
|
|
|
|
[prefixCls]: true,
|
|
|
|
[`${prefixCls}-${type}`]: true,
|
|
|
|
[`${prefixCls}-with-text${orientationPrefix}`]: $slots.default,
|
|
|
|
[`${prefixCls}-dashed`]: !!dashed,
|
|
|
|
};
|
|
|
|
|
2018-01-30 18:22:41 +08:00
|
|
|
return (
|
2020-03-07 19:45:13 +08:00
|
|
|
<div class={classString} role="separator">
|
2019-03-15 15:12:28 +08:00
|
|
|
{$slots.default && <span class={`${prefixCls}-inner-text`}>{$slots.default}</span>}
|
2018-01-30 18:22:41 +08:00
|
|
|
</div>
|
2019-01-12 11:33:27 +08:00
|
|
|
);
|
2018-01-30 18:22:41 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-03-19 10:16:27 +08:00
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
/* istanbul ignore next */
|
2019-01-12 11:33:27 +08:00
|
|
|
Divider.install = function(Vue) {
|
2019-08-28 10:50:19 +08:00
|
|
|
Vue.use(Base);
|
2019-01-12 11:33:27 +08:00
|
|
|
Vue.component(Divider.name, Divider);
|
|
|
|
};
|
2018-09-19 13:21:57 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export default Divider;
|