12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = require("../common/component");
- var relation_1 = require("../common/relation");
- var animate_1 = require("./animate");
- (0, component_1.VantComponent)({
- classes: ['title-class', 'content-class'],
- relation: (0, relation_1.useParent)('collapse'),
- props: {
- name: null,
- title: null,
- value: null,
- icon: String,
- label: String,
- disabled: Boolean,
- clickable: Boolean,
- border: {
- type: Boolean,
- value: true,
- },
- isLink: {
- type: Boolean,
- value: true,
- },
- },
- data: {
- expanded: false,
- },
- mounted: function () {
- this.updateExpanded();
- this.mounted = true;
- },
- methods: {
- updateExpanded: function () {
- if (!this.parent) {
- return;
- }
- var _a = this.parent.data, value = _a.value, accordion = _a.accordion;
- var _b = this.parent.children, children = _b === void 0 ? [] : _b;
- var name = this.data.name;
- var index = children.indexOf(this);
- var currentName = name == null ? index : name;
- var expanded = accordion
- ? value === currentName
- : (value || []).some(function (name) { return name === currentName; });
- if (expanded !== this.data.expanded) {
- (0, animate_1.setContentAnimate)(this, expanded, this.mounted);
- }
- this.setData({ index: index, expanded: expanded });
- },
- onClick: function () {
- if (this.data.disabled) {
- return;
- }
- var _a = this.data, name = _a.name, expanded = _a.expanded;
- var index = this.parent.children.indexOf(this);
- var currentName = name == null ? index : name;
- this.parent.switch(currentName, !expanded);
- },
- },
- });
|