progress.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. import { getBackgroundColor } from './utils';
  11. const { prefix } = config;
  12. const classPrefix = `${prefix}-progress`;
  13. let Progress = class Progress extends SuperComponent {
  14. constructor() {
  15. super(...arguments);
  16. this.externalClasses = [`${prefix}-class-label`];
  17. this.options = {
  18. multipleSlots: true,
  19. };
  20. this.properties = props;
  21. this.data = {
  22. prefix,
  23. classPrefix,
  24. colorBar: '',
  25. computedStatus: '',
  26. computedProgress: 0,
  27. };
  28. this.observers = {
  29. percentage(percentage) {
  30. percentage = Math.max(0, Math.min(percentage, 100));
  31. this.setData({
  32. computedStatus: percentage === 100 ? 'success' : '',
  33. computedProgress: percentage,
  34. });
  35. },
  36. color(color) {
  37. this.setData({
  38. colorBar: getBackgroundColor(color),
  39. });
  40. },
  41. };
  42. }
  43. };
  44. Progress = __decorate([
  45. wxComponent()
  46. ], Progress);
  47. export default Progress;
  48. //# sourceMappingURL=progress.js.map