tab-panel.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 './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.externalClasses = [`${prefix}-class`];
  16. this.relations = {
  17. '../tabs/tabs': {
  18. type: 'ancestor',
  19. },
  20. };
  21. this.options = {
  22. multipleSlots: true,
  23. };
  24. this.properties = props;
  25. this.data = {
  26. prefix,
  27. classPrefix: name,
  28. active: false,
  29. hide: true,
  30. id: '',
  31. };
  32. this.observers = {
  33. 'label, badgeProps, disabled, icon, panel, value'() {
  34. this.update();
  35. },
  36. };
  37. }
  38. setId(id) {
  39. this.setData({ id });
  40. }
  41. getComputedName() {
  42. if (this.properties.value != null) {
  43. return `${this.properties.value}`;
  44. }
  45. return `${this.index}`;
  46. }
  47. update() {
  48. var _a;
  49. (_a = this.$parent) === null || _a === void 0 ? void 0 : _a.updateTabs();
  50. }
  51. render(active, parent) {
  52. this.setData({
  53. active,
  54. hide: !parent.data.animation && !active,
  55. });
  56. }
  57. };
  58. TabPanel = __decorate([
  59. wxComponent()
  60. ], TabPanel);
  61. export default TabPanel;