index.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { computed } from 'vue'
  2. import { useTable } from '../hooks/use-table'
  3. import './index.less'
  4. import { getUsingConfig } from '@cip/utils/util'
  5. import CipButton from '../cip-button'
  6. export default {
  7. name: 'CipButtonText',
  8. inheritAttrs: false,
  9. props: {
  10. type: {
  11. type: String,
  12. default: 'primary'
  13. },
  14. size: String,
  15. icon: {},
  16. disabled: Boolean
  17. },
  18. setup (props, { attrs, slots }) {
  19. const cipTable = useTable()
  20. const $size = computed(() => {
  21. return getUsingConfig(props.size, cipTable.size, 'default')
  22. })
  23. const type = computed(() => {
  24. if (props.disabled) return 'default'
  25. return props.type === 'danger' ? 'primary' : props.type
  26. })
  27. /* 修改danger类型的按钮 转换为primary [注: UI标准中无颜色区分] */
  28. return () => <CipButton
  29. {...attrs}
  30. link
  31. class={['cip-table-button', `cip-table-button--${$size.value}`]}
  32. disabled={props.disabled}
  33. type={type.value}
  34. size={$size.value}
  35. icon={props.icon}
  36. >
  37. {slots.default?.()}
  38. </CipButton>
  39. }
  40. }