side-bar-item.js 2.0 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 config from '../common/config';
  9. import props from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-side-bar-item`;
  12. let SideBarItem = class SideBarItem extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.externalClasses = [`${prefix}-class`];
  16. this.properties = props;
  17. this.relations = {
  18. '../side-bar/side-bar': {
  19. type: 'parent',
  20. linked(parent) {
  21. this.parent = parent;
  22. this.updateActive(parent.data.value);
  23. },
  24. },
  25. };
  26. this.observers = {};
  27. this.data = {
  28. classPrefix: name,
  29. prefix,
  30. active: false,
  31. isPre: false,
  32. isNext: false,
  33. };
  34. this.methods = {
  35. updateActive(value) {
  36. const active = value === this.data.value;
  37. this.setData({
  38. active,
  39. });
  40. },
  41. handleClick() {
  42. var _a;
  43. if (this.data.disabled)
  44. return;
  45. const { value, label } = this.data;
  46. (_a = this.parent) === null || _a === void 0 ? void 0 : _a.doChange({ value, label });
  47. },
  48. };
  49. }
  50. };
  51. SideBarItem = __decorate([
  52. wxComponent()
  53. ], SideBarItem);
  54. export default SideBarItem;