popup.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 { classNames } from '../common/utils';
  11. import transition from '../mixins/transition';
  12. delete props.visible;
  13. const { prefix } = config;
  14. const name = `${prefix}-popup`;
  15. let Popup = class Popup extends SuperComponent {
  16. constructor() {
  17. super(...arguments);
  18. this.externalClasses = ['t-class', 't-class-content'];
  19. this.behaviors = [transition()];
  20. this.options = {
  21. multipleSlots: true,
  22. };
  23. this.properties = props;
  24. this.data = {
  25. prefix,
  26. classPrefix: name,
  27. className: name,
  28. };
  29. this.lifetimes = {
  30. attached() {
  31. this.setClass();
  32. },
  33. };
  34. this.methods = {
  35. setClass() {
  36. const { placement, showOverlay } = this.properties;
  37. const className = classNames(name, `${name}--${placement}`, {
  38. [`${name}--overlay-transparent`]: !showOverlay,
  39. });
  40. this.setData({
  41. className,
  42. });
  43. },
  44. handleOverlayClick() {
  45. const { closeOnOverlayClick } = this.properties;
  46. if (closeOnOverlayClick) {
  47. this.triggerEvent('visible-change', { visible: false });
  48. }
  49. },
  50. handleClose() {
  51. this.triggerEvent('visible-change', { visible: false });
  52. },
  53. };
  54. }
  55. };
  56. Popup = __decorate([
  57. wxComponent()
  58. ], Popup);
  59. export default Popup;