All files index.ts

93.75% Statements 30/32
80% Branches 24/30
87.5% Functions 7/8
96.29% Lines 26/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179  1x 6x 6x 11x 6x   1x 1x 1x 1x                               18x 18x                   18x 18x           1x 1x       1x     1x     1x     1x           1x       1x       1x       1x       1x       1x                                                                                                                                                                                            
import { defineComponentHOC, Doraemon, Component, Event, Emit } from '@doraemon-ui/miniprogram.core-js'
const { classNames } = Doraemon.util

@ComIponent({
  props: {E
    prefixCls: {
      type: String,
      default: 'dora-button',
    },
    darkmode: {
      type: String,
      default: Doraemon.config.darkmode,
    },
    type: {
      type: String,
      default: 'stable',
    },
    clear: {
      type: Boolean,
      default: false,
    },
    block: {
      type: Boolean,
      default: false,
    },
    full: {
      type: Boolean,
      default: false,
    },
    outline: {
      type: Boolean,
      default: false,
    },
    bordered: {
      type: Boolean,
      default: true,
    },
    size: {
      type: String,
      default: 'default',
    },
    disabled: {
      type: Boolean,
      default: false,
    },E
    loading: {
      type: Boolean,
      default: false,
    },
    formType: {
      type: String,
      default: '',
    },
    openType: {
      type: String,
      default: '',
    },
    hoverClass: {
      type: String,
      default: 'default',
    },
    hoverStopPropagation: {
      type: Boolean,
      default: false,
    },
    hoverStartTime: {
      type: Number,
      default: 20,
    },
    hoverStayTime: {
      type: Number,
      default: 70,
    },
    lang: {
      type: String,
      default: 'en',
    },
    sessionFrom: {
      type: String,
      default: '',
    },
    sendMessageTitle: {
      type: String,
      default: '',
    },
    sendMessagePath: {
      type: String,
      default: '',
    },
    sendMessageImg: {
      type: String,
      default: '',
    },
    showMessageCard: {
      type: Boolean,
      default: false,
    },
    appParameter: {
      type: String,
      default: '',
    },
  },
})
class Button extends Doraemon {
  /**
   * 自定义类名前缀
   *
   * @type {string}
   * @memberof Button
   */
  prefixCls!: string
 
  /**
   * 当前的主题
   *
   * @type {string}
   * @memberof Button
   */
  darkmode!: string
 
  get classes () {
    const { prefixCls, hoverClass, type, size, block, full, clear, outline, bordered, disabled } = this as any
    const wrap = classNames(prefixCls, {
      [`${prefixCls}--${type}`]: type,
      [`${prefixCls}--${size}`]: size,
      [`${prefixCls}--block`]: block,
      [`${prefixCls}--full`]: full,
      [`${prefixCls}--clear`]: clear,
      [`${prefixCls}--outline`]: outline,
      [`${prefixCls}--bordered`]: bordered,
      [`${prefixCls}--disabled`]: disabled,
    })
    const hover = hoverClass && hoverClass !== 'default' ? hoverClass : `${prefixCls}--hover`
 
    return {
      wrap,
      hover,
    }
  }
 
  onClick () {
    if (!(this as any).disabled && !(this as any).loading) {
      this.$emit('click')
    }
  }
 
  @Event()
  @Emit('getuserinfo')
  onGetUserInfo (e) {
    return e.target
  }
 
  @Event()
  @Emit('contact')
  onContact (e) {
    return e.target
  }
 
  @Event()
  @Emit('getphonenumber')
  onGetPhoneNumber (e) {
    return e.target
  }
 
  @Event()
  @Emit('opensetting')
  onOpenSetting (e) {
    return e.target
  }
 
  @Event()
  @Emit('error')
  onError (e) {
    return e.target
  }
}
 
export default defineComponentHOC()(Button)