@ohu-mobile/core
Version:
63 lines (62 loc) • 1.82 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ArrowDownSOutlined2 = _interopRequireDefault(require("@ohu-mobile/icons/lib/ArrowDownSOutlined"));
var _defineComponent = require("../_utils/defineComponent");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = exports.default = (0, _defineComponent.defineAncestorComponent)('collapse').create({
model: {
prop: 'value',
event: 'change'
},
props: {
expandIcon: _defineComponent.props.ofType().default(function () {
return _ArrowDownSOutlined2.default;
}),
expandIconPosition: _defineComponent.props.ofType().default('right'),
value: _defineComponent.props.ofType().optional,
accordion: (0, _defineComponent.props)(Boolean).default(false)
},
watch: {
value: function value(current) {
this.state = current;
}
},
data: function data() {
return {
state: this.value
};
},
methods: {
itemChange: function itemChange(key, expand) {
if (this.state === undefined && !this.accordion) {
this.state = [];
}
if (this.accordion) {
this.state = expand ? key : '';
} else if (this.state instanceof Array) {
if (expand) {
if (this.state.indexOf(key) >= 0) return;
this.state.push(key);
} else {
var index = this.state.indexOf(key);
if (index < 0) return;
this.state.splice(index, 1);
}
} else {
return;
}
this.$emit('change', this.state);
}
},
render: function render() {
var h = arguments[0];
var $slots = this.$slots;
var root = this.$rootCls();
return h("div", {
"class": root
}, [$slots.default]);
}
});