mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: prefer arrow function shorthand
This commit is contained in:
parent
2fd0d54da1
commit
a0addef294
@ -51,9 +51,7 @@ export default createComponent({
|
|||||||
emits: ['select', 'cancel', 'update:show'],
|
emits: ['select', 'cancel', 'update:show'],
|
||||||
|
|
||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
const onUpdateShow = (show: boolean) => {
|
const onUpdateShow = (show: boolean) => emit('update:show', show);
|
||||||
emit('update:show', show);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
onUpdateShow(false);
|
onUpdateShow(false);
|
||||||
|
@ -83,24 +83,14 @@ export default createComponent({
|
|||||||
label={express.address}
|
label={express.address}
|
||||||
class={bem('search-item')}
|
class={bem('search-item')}
|
||||||
border={false}
|
border={false}
|
||||||
onClick={() => {
|
onClick={() => onSelect(express)}
|
||||||
onSelect(express);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFocus = (event: Event) => {
|
const onBlur = (event: Event) => emit('blur', event);
|
||||||
emit('focus', event);
|
const onFocus = (event: Event) => emit('focus', event);
|
||||||
};
|
const onInput = (value: string) => emit('input', value);
|
||||||
|
|
||||||
const onBlur = (event: Event) => {
|
|
||||||
emit('blur', event);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onInput = (value: string) => {
|
|
||||||
emit('input', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (props.show) {
|
if (props.show) {
|
||||||
|
@ -239,12 +239,8 @@ export default createComponent({
|
|||||||
Dialog.confirm({
|
Dialog.confirm({
|
||||||
title: t('confirmDelete'),
|
title: t('confirmDelete'),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => emit('delete', state.data))
|
||||||
emit('delete', state.data);
|
.catch(() => emit('cancel-delete', state.data));
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
emit('cancel-delete', state.data);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// get values of area component
|
// get values of area component
|
||||||
@ -277,9 +273,7 @@ export default createComponent({
|
|||||||
<Switch
|
<Switch
|
||||||
v-model={state.data.isDefault}
|
v-model={state.data.isDefault}
|
||||||
size="24"
|
size="24"
|
||||||
onChange={(event) => {
|
onChange={(event) => emit('change-default', event)}
|
||||||
emit('change-default', event);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@ -306,9 +300,7 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.areaList,
|
() => props.areaList,
|
||||||
() => {
|
() => setAreaCode(state.data.areaCode)
|
||||||
setAreaCode(state.data.areaCode);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -378,9 +370,7 @@ export default createComponent({
|
|||||||
onBlur={onDetailBlur}
|
onBlur={onDetailBlur}
|
||||||
onFocus={() => onFocus('addressDetail')}
|
onFocus={() => onFocus('addressDetail')}
|
||||||
onInput={onChangeDetail}
|
onInput={onChangeDetail}
|
||||||
onSelect-search={(event: Event) => {
|
onSelect-search={(event: Event) => emit('select-search', event)}
|
||||||
emit('select-search', event);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
{props.showPostal && (
|
{props.showPostal && (
|
||||||
<Field
|
<Field
|
||||||
|
@ -51,9 +51,7 @@ export default createComponent({
|
|||||||
emit(name, item, index);
|
emit(name, item, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => emit('click-item', item, index);
|
||||||
emit('click-item', item, index);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSelect = () => {
|
const onSelect = () => {
|
||||||
const name = disabled ? 'select-disabled' : 'select';
|
const name = disabled ? 'select-disabled' : 'select';
|
||||||
@ -87,24 +85,18 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderBottom = () => {
|
const renderBottom = () => (
|
||||||
const onClick = () => {
|
<div class={bem('bottom')}>
|
||||||
emit('add');
|
<Button
|
||||||
};
|
round
|
||||||
|
block
|
||||||
return (
|
type="danger"
|
||||||
<div class={bem('bottom')}>
|
text={props.addButtonText || t('add')}
|
||||||
<Button
|
class={bem('add')}
|
||||||
round
|
onClick={() => emit('add')}
|
||||||
block
|
/>
|
||||||
type="danger"
|
</div>
|
||||||
text={props.addButtonText || t('add')}
|
);
|
||||||
class={bem('add')}
|
|
||||||
onClick={onClick}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const List = renderList(props.list);
|
const List = renderList(props.list);
|
||||||
|
@ -294,9 +294,7 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.columnsNum,
|
() => props.columnsNum,
|
||||||
() => {
|
() => nextTick(setValues)
|
||||||
nextTick(setValues);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useExpose({ reset, getArea, getValues });
|
useExpose({ reset, getArea, getValues });
|
||||||
|
@ -237,9 +237,7 @@ export default createComponent({
|
|||||||
color={props.color}
|
color={props.color}
|
||||||
offset={offset.value}
|
offset={offset.value}
|
||||||
rowHeight={rowHeight.value}
|
rowHeight={rowHeight.value}
|
||||||
onClick={(item) => {
|
onClick={(item) => emit('click', item)}
|
||||||
emit('click', item);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -332,9 +332,7 @@ export default createComponent({
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onConfirm = () => {
|
const onConfirm = () => emit('confirm', copyDates(state.currentDate));
|
||||||
emit('confirm', copyDates(state.currentDate));
|
|
||||||
};
|
|
||||||
|
|
||||||
const select = (date: Date | Date[], complete?: boolean) => {
|
const select = (date: Date | Date[], complete?: boolean) => {
|
||||||
const setCurrentDate = (date: Date | Date[]) => {
|
const setCurrentDate = (date: Date | Date[]) => {
|
||||||
@ -426,9 +424,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const togglePopup = (value: boolean) => {
|
const togglePopup = (value: boolean) => emit('update:show', value);
|
||||||
emit('update:show', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderMonth = (date: Date, index: number) => {
|
const renderMonth = (date: Date, index: number) => {
|
||||||
const showMonthTitle = index !== 0 || !props.showSubtitle;
|
const showMonthTitle = index !== 0 || !props.showSubtitle;
|
||||||
|
@ -80,9 +80,7 @@ export default createComponent({
|
|||||||
<a
|
<a
|
||||||
href={props.thumbLink}
|
href={props.thumbLink}
|
||||||
class={bem('thumb')}
|
class={bem('thumb')}
|
||||||
onClick={(event) => {
|
onClick={(event: MouseEvent) => emit('click-thumb', event)}
|
||||||
emit('click-thumb', event);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{renderThumbImage()}
|
{renderThumbImage()}
|
||||||
{renderThumbTag()}
|
{renderThumbTag()}
|
||||||
|
@ -172,9 +172,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => emit('close');
|
||||||
emit('close');
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderHeader = () => (
|
const renderHeader = () => (
|
||||||
<div class={bem('header')}>
|
<div class={bem('header')}>
|
||||||
@ -200,9 +198,7 @@ export default createComponent({
|
|||||||
<li
|
<li
|
||||||
class={bem('option', { selected: isSelected })}
|
class={bem('option', { selected: isSelected })}
|
||||||
style={{ color: isSelected ? props.activeColor : undefined }}
|
style={{ color: isSelected ? props.activeColor : undefined }}
|
||||||
onClick={() => {
|
onClick={() => onSelect(option, tabIndex)}
|
||||||
onSelect(option, tabIndex);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<span>{option[textKey]}</span>
|
<span>{option[textKey]}</span>
|
||||||
{isSelected ? (
|
{isSelected ? (
|
||||||
|
@ -69,9 +69,7 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(value) => {
|
(value) => emit('change', value)
|
||||||
emit('change', value);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useExpose({ toggleAll });
|
useExpose({ toggleAll });
|
||||||
|
@ -67,9 +67,7 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(value) => {
|
(value) => emit('change', value)
|
||||||
emit('change', value);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useExpose({ toggle, props, checked });
|
useExpose({ toggle, props, checked });
|
||||||
|
@ -59,9 +59,7 @@ export default createComponent({
|
|||||||
const onDelete = () => {
|
const onDelete = () => {
|
||||||
Dialog.confirm({
|
Dialog.confirm({
|
||||||
title: t('confirmDelete'),
|
title: t('confirmDelete'),
|
||||||
}).then(() => {
|
}).then(() => emit('delete', contact));
|
||||||
emit('delete', contact);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderButtons = () => (
|
const renderButtons = () => (
|
||||||
@ -90,9 +88,7 @@ export default createComponent({
|
|||||||
<Switch
|
<Switch
|
||||||
v-model={contact.isDefault}
|
v-model={contact.isDefault}
|
||||||
size={24}
|
size={24}
|
||||||
onChange={(checked: boolean) => {
|
onChange={(checked: boolean) => emit('change-default', checked)}
|
||||||
emit('change-default', checked);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,9 +96,7 @@ export default createComponent({
|
|||||||
type="danger"
|
type="danger"
|
||||||
class={bem('add')}
|
class={bem('add')}
|
||||||
text={props.addText || t('addText')}
|
text={props.addText || t('addText')}
|
||||||
onClick={() => {
|
onClick={() => emit('add')}
|
||||||
emit('add');
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -207,9 +207,7 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => state.code,
|
() => state.code,
|
||||||
(value) => {
|
(value) => emit('update:code', value)
|
||||||
emit('update:code', value);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(() => props.displayedCouponIndex, scrollToCoupon);
|
watch(() => props.displayedCouponIndex, scrollToCoupon);
|
||||||
@ -233,9 +231,7 @@ export default createComponent({
|
|||||||
type="danger"
|
type="danger"
|
||||||
class={bem('close')}
|
class={bem('close')}
|
||||||
text={props.closeButtonText || t('close')}
|
text={props.closeButtonText || t('close')}
|
||||||
onClick={() => {
|
onClick={() => emit('change', -1)}
|
||||||
emit('change', -1);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,7 +60,7 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
return new Date(timestamp);
|
return new Date(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -270,16 +270,12 @@ export default createComponent({
|
|||||||
emit('confirm', currentDate.value);
|
emit('confirm', currentDate.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCancel = () => {
|
const onCancel = () => emit('cancel');
|
||||||
emit('cancel');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
updateInnerValue();
|
updateInnerValue();
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
nextTick(() => {
|
nextTick(() => emit('change', currentDate.value));
|
||||||
emit('change', currentDate.value);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -290,9 +286,9 @@ export default createComponent({
|
|||||||
|
|
||||||
watch(columns, updateColumnValue);
|
watch(columns, updateColumnValue);
|
||||||
|
|
||||||
watch(currentDate, (value, oldValue) => {
|
watch(currentDate, (value, oldValue) =>
|
||||||
emit('update:modelValue', oldValue ? value : null);
|
emit('update:modelValue', oldValue ? value : null)
|
||||||
});
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.filter, () => props.minDate, () => props.maxDate],
|
[() => props.filter, () => props.minDate, () => props.maxDate],
|
||||||
|
@ -119,21 +119,13 @@ export default createComponent({
|
|||||||
updateColumnValue();
|
updateColumnValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onConfirm = () => {
|
const onConfirm = () => emit('confirm', currentDate.value);
|
||||||
emit('confirm', currentDate.value);
|
const onCancel = () => emit('cancel');
|
||||||
};
|
|
||||||
|
|
||||||
const onCancel = () => {
|
|
||||||
emit('cancel');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
updateInnerValue();
|
updateInnerValue();
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
nextTick(() => {
|
nextTick(() => emit('change', currentDate.value));
|
||||||
emit('change', currentDate.value);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,9 +147,7 @@ export default createComponent({
|
|||||||
updateInnerValue
|
updateInnerValue
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(currentDate, (value) => {
|
watch(currentDate, (value) => emit('update:modelValue', value));
|
||||||
emit('update:modelValue', value);
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
|
@ -64,9 +64,7 @@ export default createComponent({
|
|||||||
cancel: false,
|
cancel: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onUpdateShow = (value: boolean) => {
|
const onUpdateShow = (value: boolean) => emit('update:show', value);
|
||||||
emit('update:show', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const close = (action: DialogAction) => {
|
const close = (action: DialogAction) => {
|
||||||
onUpdateShow(false);
|
onUpdateShow(false);
|
||||||
|
@ -64,11 +64,10 @@ export default createComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const createEmitter = (eventName: 'open' | 'close' | 'opened') => () =>
|
const getEmitter = (name: 'open' | 'close' | 'opened') => () => emit(name);
|
||||||
emit(eventName);
|
const onOpen = getEmitter('open');
|
||||||
const onOpen = createEmitter('open');
|
const onClose = getEmitter('close');
|
||||||
const onClose = createEmitter('close');
|
const onOpened = getEmitter('opened');
|
||||||
const onOpened = createEmitter('opened');
|
|
||||||
|
|
||||||
const onClosed = () => {
|
const onClosed = () => {
|
||||||
state.showWrapper = false;
|
state.showWrapper = false;
|
||||||
|
@ -330,17 +330,13 @@ export default createComponent({
|
|||||||
resetScroll();
|
resetScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClickInput = (event: MouseEvent) => {
|
const onClickInput = (event: MouseEvent) => emit('click-input', event);
|
||||||
emit('click-input', event);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onClickLeftIcon = (event: MouseEvent) => {
|
const onClickLeftIcon = (event: MouseEvent) =>
|
||||||
emit('click-left-icon', event);
|
emit('click-left-icon', event);
|
||||||
};
|
|
||||||
|
|
||||||
const onClickRightIcon = (event: MouseEvent) => {
|
const onClickRightIcon = (event: MouseEvent) =>
|
||||||
emit('click-right-icon', event);
|
emit('click-right-icon', event);
|
||||||
};
|
|
||||||
|
|
||||||
const onClear = (event: MouseEvent) => {
|
const onClear = (event: MouseEvent) => {
|
||||||
preventDefault(event);
|
preventDefault(event);
|
||||||
|
@ -156,9 +156,7 @@ export default createComponent({
|
|||||||
const values = getValues();
|
const values = getValues();
|
||||||
|
|
||||||
validate()
|
validate()
|
||||||
.then(() => {
|
.then(() => emit('submit', values))
|
||||||
emit('submit', values);
|
|
||||||
})
|
|
||||||
.catch((errors: FieldValidateError[]) => {
|
.catch((errors: FieldValidateError[]) => {
|
||||||
emit('failed', { values, errors });
|
emit('failed', { values, errors });
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ import ImagePreviewItem from './ImagePreviewItem';
|
|||||||
|
|
||||||
const [createComponent, bem] = createNamespace('image-preview');
|
const [createComponent, bem] = createNamespace('image-preview');
|
||||||
|
|
||||||
|
export type ImagePreviewScaleEventParams = {
|
||||||
|
scale: number;
|
||||||
|
index: number;
|
||||||
|
};
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
@ -90,21 +95,16 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const emitScale = (args: { scale: number; index: number }) => {
|
const emitScale = (args: ImagePreviewScaleEventParams) =>
|
||||||
emit('scale', args);
|
emit('scale', args);
|
||||||
};
|
|
||||||
|
|
||||||
const toggle = (show: boolean) => {
|
const toggle = (show: boolean) => emit('update:show', show);
|
||||||
emit('update:show', show);
|
|
||||||
};
|
|
||||||
|
|
||||||
const emitClose = () => {
|
const emitClose = () => {
|
||||||
callInterceptor({
|
callInterceptor({
|
||||||
interceptor: props.beforeClose,
|
interceptor: props.beforeClose,
|
||||||
args: [state.active],
|
args: [state.active],
|
||||||
done: () => {
|
done: () => toggle(false),
|
||||||
toggle(false);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -174,9 +174,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClosed = () => {
|
const onClosed = () => emit('closed');
|
||||||
emit('closed');
|
|
||||||
};
|
|
||||||
|
|
||||||
const swipeTo = (index: number, options?: SwipeToOptions) => {
|
const swipeTo = (index: number, options?: SwipeToOptions) => {
|
||||||
if (swipeRef.value) {
|
if (swipeRef.value) {
|
||||||
|
@ -173,9 +173,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = () => {
|
const init = () => nextTick(onScroll);
|
||||||
nextTick(onScroll);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEventListener('scroll', onScroll, { target: scrollParent });
|
useEventListener('scroll', onScroll, { target: scrollParent });
|
||||||
|
|
||||||
|
@ -34,13 +34,8 @@ export default createComponent({
|
|||||||
const navBarRef = ref<HTMLElement>();
|
const navBarRef = ref<HTMLElement>();
|
||||||
const renderPlaceholder = usePlaceholder(navBarRef, bem);
|
const renderPlaceholder = usePlaceholder(navBarRef, bem);
|
||||||
|
|
||||||
const onClickLeft = (event: MouseEvent) => {
|
const onClickLeft = (event: MouseEvent) => emit('click-left', event);
|
||||||
emit('click-left', event);
|
const onClickRight = (event: MouseEvent) => emit('click-right', event);
|
||||||
};
|
|
||||||
|
|
||||||
const onClickRight = (event: MouseEvent) => {
|
|
||||||
emit('click-right', event);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderLeft = () => {
|
const renderLeft = () => {
|
||||||
if (slots.left) {
|
if (slots.left) {
|
||||||
|
@ -146,9 +146,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAnimationEnd = () => {
|
const onAnimationEnd = () => emit(props.show ? 'show' : 'hide');
|
||||||
emit(props.show ? 'show' : 'hide');
|
|
||||||
};
|
|
||||||
|
|
||||||
const onPress = (text: string, type: KeyType) => {
|
const onPress = (text: string, type: KeyType) => {
|
||||||
if (text === '') {
|
if (text === '') {
|
||||||
|
@ -144,9 +144,7 @@ export default createComponent({
|
|||||||
const value = props.modelValue;
|
const value = props.modelValue;
|
||||||
const simple = props.mode !== 'multi';
|
const simple = props.mode !== 'multi';
|
||||||
|
|
||||||
const onSelect = (value: number) => () => {
|
const onSelect = (value: number) => () => select(value, true);
|
||||||
select(value, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul class={bem({ simple })}>
|
<ul class={bem({ simple })}>
|
||||||
|
@ -289,9 +289,7 @@ export default createComponent({
|
|||||||
disabled,
|
disabled,
|
||||||
selected: index === state.index,
|
selected: index === state.index,
|
||||||
}),
|
}),
|
||||||
onClick: () => {
|
onClick: () => onClickItem(index),
|
||||||
onClickItem(index);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const childData = {
|
const childData = {
|
||||||
|
@ -286,9 +286,7 @@ export default createComponent({
|
|||||||
emitAction('confirm');
|
emitAction('confirm');
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => emitAction('cancel');
|
||||||
emitAction('cancel');
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderTitle = () => {
|
const renderTitle = () => {
|
||||||
if (slots.title) {
|
if (slots.title) {
|
||||||
@ -342,9 +340,7 @@ export default createComponent({
|
|||||||
swipeDuration={props.swipeDuration}
|
swipeDuration={props.swipeDuration}
|
||||||
initialOptions={item[valuesKey]}
|
initialOptions={item[valuesKey]}
|
||||||
visibleItemCount={props.visibleItemCount}
|
visibleItemCount={props.visibleItemCount}
|
||||||
onChange={() => {
|
onChange={() => onChange(columnIndex)}
|
||||||
onChange(columnIndex);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -125,9 +125,7 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggle = (value: boolean) => {
|
const toggle = (value: boolean) => emit('update:show', value);
|
||||||
emit('update:show', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onClickWrapper = () => {
|
const onClickWrapper = () => {
|
||||||
if (props.trigger === 'click') {
|
if (props.trigger === 'click') {
|
||||||
@ -152,9 +150,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClickAway = () => {
|
const onClickAway = () => toggle(false);
|
||||||
toggle(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderAction = (action: PopoverAction, index: number) => {
|
const renderAction = (action: PopoverAction, index: number) => {
|
||||||
const { icon, text, color, disabled, className } = action;
|
const { icon, text, color, disabled, className } = action;
|
||||||
|
@ -179,9 +179,7 @@ export default createComponent({
|
|||||||
emit('update:modelValue', true);
|
emit('update:modelValue', true);
|
||||||
|
|
||||||
// ensure value change can be watched
|
// ensure value change can be watched
|
||||||
nextTick(() => {
|
nextTick(() => emit('refresh'));
|
||||||
emit('refresh');
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
setStatus(0);
|
setStatus(0);
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,12 @@ export default createComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const { linkChildren } = useChildren(RADIO_KEY);
|
const { linkChildren } = useChildren(RADIO_KEY);
|
||||||
|
|
||||||
const updateModelValue = (value: unknown) => {
|
const updateModelValue = (value: unknown) =>
|
||||||
emit('update:modelValue', value);
|
emit('update:modelValue', value);
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(value) => {
|
(value) => emit('change', value)
|
||||||
emit('change', value);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
linkChildren({
|
linkChildren({
|
||||||
|
@ -120,9 +120,7 @@ export default createComponent({
|
|||||||
class: null,
|
class: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const onInput = (value: string) => {
|
const onInput = (value: string) => emit('update:modelValue', value);
|
||||||
emit('update:modelValue', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
|
@ -65,18 +65,15 @@ export default createComponent({
|
|||||||
emits: ['cancel', 'select', 'update:show'],
|
emits: ['cancel', 'select', 'update:show'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const toggle = (value: boolean) => {
|
const toggle = (value: boolean) => emit('update:show', value);
|
||||||
emit('update:show', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
toggle(false);
|
toggle(false);
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (option: ShareSheetOption, index: number) => {
|
const onSelect = (option: ShareSheetOption, index: number) =>
|
||||||
emit('select', option, index);
|
emit('select', option, index);
|
||||||
};
|
|
||||||
|
|
||||||
const renderHeader = () => {
|
const renderHeader = () => {
|
||||||
const title = slots.title ? slots.title() : props.title;
|
const title = slots.title ? slots.title() : props.title;
|
||||||
@ -103,9 +100,7 @@ export default createComponent({
|
|||||||
role="button"
|
role="button"
|
||||||
tabindex={0}
|
tabindex={0}
|
||||||
class={[bem('option'), className]}
|
class={[bem('option'), className]}
|
||||||
onClick={() => {
|
onClick={() => onSelect(option, index)}
|
||||||
onSelect(option, index);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<img src={getIconURL(icon)} class={bem('icon')} />
|
<img src={getIconURL(icon)} class={bem('icon')} />
|
||||||
{name && <span class={bem('name')}>{name}</span>}
|
{name && <span class={bem('name')}>{name}</span>}
|
||||||
|
@ -52,9 +52,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const onClickStep = () => {
|
const onClickStep = () => parent.onClickStep(index.value);
|
||||||
parent.onClickStep(index.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderCircle = () => {
|
const renderCircle = () => {
|
||||||
const { finishIcon, activeIcon, activeColor, inactiveIcon } = parentProps;
|
const { finishIcon, activeIcon, activeColor, inactiveIcon } = parentProps;
|
||||||
|
@ -46,9 +46,7 @@ export default createComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const { linkChildren } = useChildren(STEPS_KEY);
|
const { linkChildren } = useChildren(STEPS_KEY);
|
||||||
|
|
||||||
const onClickStep = (index: number) => {
|
const onClickStep = (index: number) => emit('click-step', index);
|
||||||
emit('click-step', index);
|
|
||||||
};
|
|
||||||
|
|
||||||
linkChildren({
|
linkChildren({
|
||||||
props,
|
props,
|
||||||
|
@ -83,9 +83,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClickButton = () => {
|
const onClickButton = () => emit('submit');
|
||||||
emit('submit');
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderButton = () => {
|
const renderButton = () => {
|
||||||
if (slots.button) {
|
if (slots.button) {
|
||||||
|
@ -147,9 +147,7 @@ export default createComponent({
|
|||||||
position,
|
position,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
done: () => {
|
done: () => close(position),
|
||||||
close(position);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -186,13 +184,7 @@ export default createComponent({
|
|||||||
close,
|
close,
|
||||||
});
|
});
|
||||||
|
|
||||||
useClickAway(
|
useClickAway(root, () => onClick('outside'), { eventName: 'touchstart' });
|
||||||
root,
|
|
||||||
() => {
|
|
||||||
onClick('outside');
|
|
||||||
},
|
|
||||||
{ eventName: 'touchstart' }
|
|
||||||
);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const wrapperStyle = {
|
const wrapperStyle = {
|
||||||
|
@ -297,9 +297,7 @@ export default createComponent({
|
|||||||
autoplay();
|
autoplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
const resize = () => {
|
const resize = () => initialize(state.active);
|
||||||
initialize(state.active);
|
|
||||||
};
|
|
||||||
|
|
||||||
let touchStartTime: number;
|
let touchStartTime: number;
|
||||||
|
|
||||||
@ -454,9 +452,7 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(initialize);
|
onMounted(initialize);
|
||||||
onActivated(() => {
|
onActivated(() => initialize(state.active));
|
||||||
initialize(state.active);
|
|
||||||
});
|
|
||||||
onDeactivated(stopAutoplay);
|
onDeactivated(stopAutoplay);
|
||||||
onBeforeUnmount(stopAutoplay);
|
onBeforeUnmount(stopAutoplay);
|
||||||
|
|
||||||
|
@ -29,9 +29,7 @@ export default createComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const swipeRef = ref<ComponentInstance>();
|
const swipeRef = ref<ComponentInstance>();
|
||||||
|
|
||||||
const onChange = (index: number) => {
|
const onChange = (index: number) => emit('change', index);
|
||||||
emit('change', index);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderChildren = () => {
|
const renderChildren = () => {
|
||||||
const Content = slots.default?.();
|
const Content = slots.default?.();
|
||||||
|
@ -438,9 +438,8 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRendered = (name: string | number, title?: string) => {
|
const onRendered = (name: string | number, title?: string) =>
|
||||||
emit('rendered', name, title);
|
emit('rendered', name, title);
|
||||||
};
|
|
||||||
|
|
||||||
useExpose({
|
useExpose({
|
||||||
resize: setLine,
|
resize: setLine,
|
||||||
|
@ -70,9 +70,7 @@ export default createComponent({
|
|||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggle = (show: boolean) => {
|
const toggle = (show: boolean) => emit('update:show', show);
|
||||||
emit('update:show', show);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderIcon = () => {
|
const renderIcon = () => {
|
||||||
const { icon, type, iconPrefix, loadingType } = props;
|
const { icon, type, iconPrefix, loadingType } = props;
|
||||||
|
@ -56,15 +56,11 @@ export default defineComponent({
|
|||||||
callInterceptor({
|
callInterceptor({
|
||||||
interceptor: beforeDelete,
|
interceptor: beforeDelete,
|
||||||
args: [item, { name, index }],
|
args: [item, { name, index }],
|
||||||
done() {
|
done: () => emit('delete'),
|
||||||
emit('delete');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPreview = () => {
|
const onPreview = () => emit('preview');
|
||||||
emit('preview');
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderDeleteIcon = () => {
|
const renderDeleteIcon = () => {
|
||||||
if (props.deletable && props.item.status !== 'uploading') {
|
if (props.deletable && props.item.status !== 'uploading') {
|
||||||
|
@ -233,9 +233,7 @@ export default createComponent({
|
|||||||
|
|
||||||
let imagePreview: ComponentInstance | undefined;
|
let imagePreview: ComponentInstance | undefined;
|
||||||
|
|
||||||
const onClosePreview = () => {
|
const onClosePreview = () => emit('close-preview');
|
||||||
emit('close-preview');
|
|
||||||
};
|
|
||||||
|
|
||||||
const previewImage = (item: FileListItem) => {
|
const previewImage = (item: FileListItem) => {
|
||||||
if (props.previewFullImage) {
|
if (props.previewFullImage) {
|
||||||
@ -285,15 +283,9 @@ export default createComponent({
|
|||||||
v-slots={{ 'preview-cover': slots['preview-cover'] }}
|
v-slots={{ 'preview-cover': slots['preview-cover'] }}
|
||||||
item={item}
|
item={item}
|
||||||
index={index}
|
index={index}
|
||||||
onClick={() => {
|
onClick={() => emit('click-preview', item, getDetail(index))}
|
||||||
emit('click-preview', item, getDetail(index));
|
onDelete={() => deleteFile(item, index)}
|
||||||
}}
|
onPreview={() => previewImage(item)}
|
||||||
onDelete={() => {
|
|
||||||
deleteFile(item, index);
|
|
||||||
}}
|
|
||||||
onPreview={() => {
|
|
||||||
previewImage(item);
|
|
||||||
}}
|
|
||||||
{...pick(props, ['name', 'lazyLoad'])}
|
{...pick(props, ['name', 'lazyLoad'])}
|
||||||
{...previewData}
|
{...previewData}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user