tab-panel.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. import { SuperComponent, wxComponent } from '../common/src/index';
  8. import props from './tab-panel-props';
  9. import config from '../common/config';
  10. const { prefix } = config;
  11. const name = `${prefix}-tab-panel`;
  12. let TabPanel = class TabPanel extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.relations = {
  16. './tabs': {
  17. type: 'ancestor',
  18. },
  19. };
  20. this.properties = props;
  21. this.data = {
  22. prefix,
  23. classPrefix: name,
  24. active: false,
  25. hide: true,
  26. };
  27. this.observers = {
  28. label() {
  29. this.update();
  30. },
  31. };
  32. }
  33. getComputedName() {
  34. if (this.properties.value != null) {
  35. return `${this.properties.value}`;
  36. }
  37. return `${this.index}`;
  38. }
  39. update() {
  40. if (this.parent) {
  41. this.parent.updateTabs();
  42. }
  43. }
  44. render(active, parent) {
  45. this.setData({
  46. active,
  47. hide: !parent.animated && !active,
  48. });
  49. }
  50. };
  51. TabPanel = __decorate([
  52. wxComponent()
  53. ], TabPanel);
  54. export default TabPanel;