import { ref } from 'vue';
import { createNamespace } from '../utils';
import { useTouch } from '../composition/use-touch';
import Loading from '../loading';
import { DeleteIcon, CollapseIcon } from './Icon';
const [createComponent, bem] = createNamespace('key');
export default createComponent({
props: {
type: String,
text: [Number, String],
color: String,
wider: Boolean,
large: Boolean,
loading: Boolean,
},
emits: ['press'],
setup(props, { emit, slots }) {
const active = ref(false);
const touch = useTouch();
const onTouchStart = (event) => {
touch.start(event);
active.value = true;
};
const onTouchMove = (event) => {
touch.move(event);
if (touch.direction.value) {
active.value = false;
}
};
const onTouchEnd = (event) => {
if (active.value) {
// eliminate tap delay on safari
// see: https://github.com/youzan/vant/issues/6836
if (!slots.default) {
event.preventDefault();
}
active.value = false;
emit('press', props.text, props.type);
}
};
const renderContent = () => {
if (props.loading) {
return