1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _vueTypes = require('../_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _propsUtil = require('../_util/props-util');
var _vcSwitch = require('../vc-switch');
var _vcSwitch2 = _interopRequireDefault(_vcSwitch);
var _wave = require('../_util/wave');
var _wave2 = _interopRequireDefault(_wave);
var _icon = require('../icon');
var _icon2 = _interopRequireDefault(_icon);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var Switch = {
name: 'ASwitch',
model: {
prop: 'checked',
event: 'change'
},
props: {
prefixCls: _vueTypes2['default'].string.def('ant-switch'),
// size=default and size=large are the same
size: _vueTypes2['default'].oneOf(['small', 'default', 'large']),
disabled: _vueTypes2['default'].bool,
checkedChildren: _vueTypes2['default'].any,
unCheckedChildren: _vueTypes2['default'].any,
tabIndex: _vueTypes2['default'].number,
checked: _vueTypes2['default'].bool,
defaultChecked: _vueTypes2['default'].bool,
autoFocus: _vueTypes2['default'].bool,
loading: _vueTypes2['default'].bool
},
methods: {
focus: function focus() {
this.$refs.refSwitchNode.focus();
},
blur: function blur() {
this.$refs.refSwitchNode.blur();
}
},
render: function render() {
var _classes;
var h = arguments[0];
var _getOptionProps = (0, _propsUtil.getOptionProps)(this),
prefixCls = _getOptionProps.prefixCls,
size = _getOptionProps.size,
loading = _getOptionProps.loading,
disabled = _getOptionProps.disabled,
restProps = (0, _objectWithoutProperties3['default'])(_getOptionProps, ['prefixCls', 'size', 'loading', 'disabled']);
var classes = (_classes = {}, (0, _defineProperty3['default'])(_classes, prefixCls + '-small', size === 'small'), (0, _defineProperty3['default'])(_classes, prefixCls + '-loading', loading), _classes);
var loadingIcon = loading ? h(_icon2['default'], {
attrs: { type: 'loading' },
'class': prefixCls + '-loading-icon' }) : null;
var switchProps = {
props: (0, _extends3['default'])({}, restProps, {
prefixCls: prefixCls,
loadingIcon: loadingIcon,
checkedChildren: (0, _propsUtil.getComponentFromProp)(this, 'checkedChildren'),
unCheckedChildren: (0, _propsUtil.getComponentFromProp)(this, 'unCheckedChildren'),
disabled: disabled || loading
}),
on: this.$listeners,
'class': classes,
ref: 'refSwitchNode'
};
return h(
_wave2['default'],
{
attrs: { insertExtraNode: true }
},
[h(_vcSwitch2['default'], switchProps)]
);
}
};
/* istanbul ignore next */
Switch.install = function (Vue) {
Vue.component(Switch.name, Switch);
};
exports['default'] = Switch;