index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. var relation_1 = require("../common/relation");
  5. (0, component_1.VantComponent)({
  6. relation: (0, relation_1.useChildren)('collapse-item'),
  7. props: {
  8. value: {
  9. type: null,
  10. observer: 'updateExpanded',
  11. },
  12. accordion: {
  13. type: Boolean,
  14. observer: 'updateExpanded',
  15. },
  16. border: {
  17. type: Boolean,
  18. value: true,
  19. },
  20. },
  21. methods: {
  22. updateExpanded: function () {
  23. this.children.forEach(function (child) {
  24. child.updateExpanded();
  25. });
  26. },
  27. switch: function (name, expanded) {
  28. var _a = this.data, accordion = _a.accordion, value = _a.value;
  29. var changeItem = name;
  30. if (!accordion) {
  31. name = expanded
  32. ? (value || []).concat(name)
  33. : (value || []).filter(function (activeName) { return activeName !== name; });
  34. }
  35. else {
  36. name = expanded ? name : '';
  37. }
  38. if (expanded) {
  39. this.$emit('open', changeItem);
  40. }
  41. else {
  42. this.$emit('close', changeItem);
  43. }
  44. this.$emit('change', name);
  45. this.$emit('input', name);
  46. },
  47. },
  48. });