zs
2025-06-04 5a149d626ae8bc3fa4bddbb53f8caf40f51f6da6
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
import { Component, defineComponent, h } from 'vue'
import styles from './TdButton.module.scss'
import Text from '../Text/Text'
import IconButton from '../IconButton/IconButton'
 
export default defineComponent({
  name: 'TdButton',
  props: {
    text: {
      type: [String, Object],
      default: '',
    },
    icon: {
      type: String,
      default: '',
    },
    tip: {
      type: String,
      default: '',
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    hover: {
      type: Boolean,
      default: false,
    },
    style: {
      type: Object,
      default: () => ({}),
    },
  },
  emits: ['click'],
  setup(props, { slots, emit }) {
    return () => {
      const style = {
        filter: `grayscale(${props.disabled ? 1 : 0})`,
        cursor: props.disabled ? 'no-drop' : 'pointer',
      }
      return (
        <div
          class={{ [styles.text]: true, 's-row--td-hover': props.hover }}
          style={style}
        >
          <div class="s-td-name" style={props.style}>
            <Text truncated={true} tip={props.tip}>
              {slots.default?.()}
            </Text>
          </div>
          <IconButton
            disabled={props.disabled}
            onClick={() => emit('click')}
            icon={props.icon}
            class="s-icon-btn"
          >
            {props.text}
          </IconButton>
        </div>
      )
    }
  },
})