skeleton.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 { isNumber } from '../common/utils';
  11. const { prefix } = config;
  12. const name = `${prefix}-skeleton`;
  13. let Skeleton = class Skeleton extends SuperComponent {
  14. constructor() {
  15. super(...arguments);
  16. this.externalClasses = ['t-class', 't-class-avatar', 't-class-text'];
  17. this.properties = props;
  18. this.observers = {
  19. rowCol(val) {
  20. const rowStyles = [];
  21. const isNumList = [];
  22. if (Array.isArray(val)) {
  23. val.forEach((v) => {
  24. if (isNumber(v)) {
  25. const curArr = [];
  26. const defaultWidth = `${(686 - 32 * (v - 1)) / v}rpx`;
  27. // eslint-disable-next-line no-plusplus
  28. for (let i = 0; i < v; i++) {
  29. curArr.push({ width: defaultWidth, height: '32rpx' });
  30. }
  31. rowStyles.push(curArr);
  32. isNumList.push(true);
  33. }
  34. else {
  35. rowStyles.push(Array.isArray(v) ? v : [v]);
  36. isNumList.push(false);
  37. }
  38. });
  39. }
  40. this.setData({ rowStyles, isNumList });
  41. },
  42. };
  43. this.data = {
  44. classPrefix: name,
  45. isNumList: [],
  46. rowStyles: [],
  47. };
  48. }
  49. };
  50. Skeleton = __decorate([
  51. wxComponent()
  52. ], Skeleton);
  53. export default Skeleton;
  54. //# sourceMappingURL=skeleton.js.map