index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. component_1.VantComponent({
  6. relation: 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,
  29. accordion = _a.accordion,
  30. value = _a.value;
  31. var changeItem = name;
  32. if (!accordion) {
  33. name = expanded
  34. ? (value || []).concat(name)
  35. : (value || []).filter(function (activeName) {
  36. return activeName !== name;
  37. });
  38. } else {
  39. name = expanded ? name : '';
  40. }
  41. if (expanded) {
  42. this.$emit('open', changeItem);
  43. } else {
  44. this.$emit('close', changeItem);
  45. }
  46. this.$emit('change', name);
  47. this.$emit('input', name);
  48. },
  49. },
  50. });