side-bar-item.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 = Object.assign(Object.assign({}, props), { tId: {
  17. type: String,
  18. } });
  19. this.relations = {
  20. '../side-bar/side-bar': {
  21. type: 'parent',
  22. linked(parent) {
  23. this.parent = parent;
  24. this.updateActive(parent.data.value);
  25. },
  26. },
  27. };
  28. this.observers = {
  29. icon(v) {
  30. this.setData({ _icon: typeof v === 'string' ? { name: v } : v });
  31. },
  32. };
  33. this.data = {
  34. classPrefix: name,
  35. prefix,
  36. active: false,
  37. isPre: false,
  38. isNext: false,
  39. };
  40. this.methods = {
  41. updateActive(value) {
  42. const active = value === this.data.value;
  43. this.setData({
  44. active,
  45. });
  46. },
  47. handleClick() {
  48. var _a;
  49. if (this.data.disabled)
  50. return;
  51. const { value, label } = this.data;
  52. (_a = this.parent) === null || _a === void 0 ? void 0 : _a.doChange({ value, label });
  53. },
  54. };
  55. }
  56. };
  57. SideBarItem = __decorate([
  58. wxComponent()
  59. ], SideBarItem);
  60. export default SideBarItem;