import { computed } from 'vue'
import { useTable } from '../hooks/use-table'
import './index.less'
import { getUsingConfig } from '@cip/utils/util'
import CipButton from '../cip-button'
export default {
  name: 'CipButtonText',
  inheritAttrs: false,
  props: {
    type: {
      type: String,
      default: 'primary'
    },
    size: String,
    icon: {},
    disabled: Boolean
  },
  setup (props, { attrs, slots }) {
    const cipTable = useTable()
    const $size = computed(() => {
      return getUsingConfig(props.size, cipTable.size, 'default')
    })
    console.log($size.value)
    /* 修改danger类型的按钮 转换为primary [注： UI标准中无颜色区分] */
    return () => <CipButton
      {...attrs}
      link
      class={['cip-table-button', `cip-table-button--${$size.value}`]}
      disabled={props.disabled}
      type={props.type === 'danger' ? 'primary' : props.type}
      size={$size.value}
      icon={props.icon}
    >
      {slots.default?.()}
    </CipButton>
  }
}
