From 6e5329cbe049aa8927aa696b9611f5b9f6e5fecb Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 2 Mar 2021 17:55:22 +0800 Subject: [PATCH] chore: rename variables and comments --- src/action-bar-button/index.tsx | 2 +- src/action-bar-icon/index.tsx | 2 +- src/action-sheet/index.tsx | 8 ++++---- src/address-edit/index.tsx | 2 +- src/area/index.tsx | 2 +- src/calendar/components/Month.tsx | 2 +- src/calendar/index.tsx | 6 +++--- src/cell/index.tsx | 2 +- src/checkbox-group/index.tsx | 10 ++++------ src/checkbox/index.tsx | 12 +++++++++--- src/collapse-item/index.tsx | 2 +- src/count-down/index.tsx | 2 +- src/coupon-list/index.tsx | 2 +- src/datetime-picker/DatePicker.tsx | 2 +- src/datetime-picker/TimePicker.tsx | 2 +- src/dialog/Dialog.tsx | 6 +++--- src/dropdown-item/index.tsx | 2 +- src/dropdown-menu/index.tsx | 2 +- src/field/index.tsx | 2 +- src/form/index.tsx | 2 +- src/grid-item/index.tsx | 2 +- src/image-preview/ImagePreview.tsx | 10 +++++----- src/image-preview/ImagePreviewItem.tsx | 2 +- src/index-anchor/index.tsx | 2 +- src/index-bar/index.tsx | 2 +- src/list/index.tsx | 2 +- src/nav-bar/index.tsx | 2 +- src/notice-bar/index.tsx | 2 +- src/picker/PickerColumn.tsx | 2 +- src/picker/index.tsx | 2 +- src/popover/index.tsx | 12 ++++++------ src/popup/index.tsx | 2 +- src/pull-refresh/index.tsx | 2 +- src/radio-group/index.tsx | 7 +++---- src/radio/index.tsx | 2 +- src/rate/index.tsx | 2 +- src/search/index.tsx | 2 +- src/share-sheet/index.tsx | 6 +++--- src/slider/index.tsx | 2 +- src/step/index.tsx | 2 +- src/stepper/index.tsx | 2 +- src/sticky/index.tsx | 2 +- src/swipe-cell/index.tsx | 2 +- src/swipe/index.tsx | 2 +- src/tab/index.tsx | 2 +- src/tabbar-item/index.tsx | 2 +- src/tabbar/index.tsx | 2 +- src/tabs/index.tsx | 2 +- src/toast/Toast.tsx | 10 +++++----- src/uploader/index.tsx | 2 +- 50 files changed, 85 insertions(+), 82 deletions(-) diff --git a/src/action-bar-button/index.tsx b/src/action-bar-button/index.tsx index fc3087a32..ca2068e0a 100644 --- a/src/action-bar-button/index.tsx +++ b/src/action-bar-button/index.tsx @@ -2,7 +2,7 @@ import { computed, PropType } from 'vue'; import { createNamespace } from '../utils'; import { ACTION_BAR_KEY } from '../action-bar'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; import { useRoute, routeProps } from '../composables/use-route'; diff --git a/src/action-bar-icon/index.tsx b/src/action-bar-icon/index.tsx index d562ddfcd..e92e8690e 100644 --- a/src/action-bar-icon/index.tsx +++ b/src/action-bar-icon/index.tsx @@ -1,7 +1,7 @@ import { createNamespace, UnknownProp } from '../utils'; import { ACTION_BAR_KEY } from '../action-bar'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useRoute, routeProps } from '../composables/use-route'; diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index 11d2e4d45..7897b5041 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -51,10 +51,10 @@ export default createComponent({ emits: ['select', 'cancel', 'update:show'], setup(props, { slots, emit }) { - const onUpdateShow = (show: boolean) => emit('update:show', show); + const updateShow = (show: boolean) => emit('update:show', show); const onCancel = () => { - onUpdateShow(false); + updateShow(false); emit('cancel'); }; @@ -118,7 +118,7 @@ export default createComponent({ emit('select', item, index); if (props.closeOnClickAction) { - onUpdateShow(false); + updateShow(false); } }; @@ -157,7 +157,7 @@ export default createComponent({ safeAreaInsetBottom={props.safeAreaInsetBottom} {...{ ...pick(props, popupSharedPropKeys), - 'onUpdate:show': onUpdateShow, + 'onUpdate:show': updateShow, }} > {renderHeader()} diff --git a/src/address-edit/index.tsx b/src/address-edit/index.tsx index c73637a6e..19ab25aa8 100644 --- a/src/address-edit/index.tsx +++ b/src/address-edit/index.tsx @@ -4,7 +4,7 @@ import { ref, watch, computed, nextTick, reactive, PropType } from 'vue'; import { ComponentInstance, createNamespace, isObject } from '../utils'; import { isMobile } from '../utils/validate/mobile'; -// Composition +// Composables import { useExpose } from '../composables/use-expose'; // Components diff --git a/src/area/index.tsx b/src/area/index.tsx index a35953e39..afef504fa 100644 --- a/src/area/index.tsx +++ b/src/area/index.tsx @@ -13,7 +13,7 @@ import { import { deepClone } from '../utils/deep-clone'; import { pick, createNamespace, ComponentInstance } from '../utils'; -// Composition +// Composables import { useExpose } from '../composables/use-expose'; // Components diff --git a/src/calendar/components/Month.tsx b/src/calendar/components/Month.tsx index e8fc4dea9..7e2601722 100644 --- a/src/calendar/components/Month.tsx +++ b/src/calendar/components/Month.tsx @@ -12,7 +12,7 @@ import { formatMonthTitle, } from '../utils'; -// Composition +// Composables import { useToggle } from '@vant/use'; import { useExpose } from '../../composables/use-expose'; import { useHeight } from '../../composables/use-height'; diff --git a/src/calendar/index.tsx b/src/calendar/index.tsx index d76e81371..0089b7e9a 100644 --- a/src/calendar/index.tsx +++ b/src/calendar/index.tsx @@ -17,7 +17,7 @@ import { getDayByOffset, } from './utils'; -// Composition +// Composables import { raf, useRect, onMountedOrActivated } from '@vant/use'; import { useRefs } from '../composables/use-refs'; import { useExpose } from '../composables/use-expose'; @@ -424,7 +424,7 @@ export default createComponent({ } }; - const togglePopup = (value: boolean) => emit('update:show', value); + const updateShow = (value: boolean) => emit('update:show', value); const renderMonth = (date: Date, index: number) => { const showMonthTitle = index !== 0 || !props.showSubtitle; @@ -533,7 +533,7 @@ export default createComponent({ teleport={props.teleport} closeOnPopstate={props.closeOnPopstate} closeOnClickOverlay={props.closeOnClickOverlay} - {...{ 'onUpdate:show': togglePopup }} + {...{ 'onUpdate:show': updateShow }} > {renderCalendar()} diff --git a/src/cell/index.tsx b/src/cell/index.tsx index c03db1543..f299a2c32 100644 --- a/src/cell/index.tsx +++ b/src/cell/index.tsx @@ -3,7 +3,7 @@ import { PropType, CSSProperties } from 'vue'; // Utils import { createNamespace, isDef, UnknownProp } from '../utils'; -// Composition +// Composables import { useRoute, routeProps } from '../composables/use-route'; // Components diff --git a/src/checkbox-group/index.tsx b/src/checkbox-group/index.tsx index 40d31acef..057a97dc2 100644 --- a/src/checkbox-group/index.tsx +++ b/src/checkbox-group/index.tsx @@ -21,7 +21,7 @@ export type CheckboxGroupProvide = CheckerParent & { max: number | string; modelValue: unknown[]; }; - updateModelValue: (value: unknown[]) => void; + updateValue: (value: unknown[]) => void; }; export default createComponent({ @@ -42,9 +42,7 @@ export default createComponent({ setup(props, { emit, slots }) { const { children, linkChildren } = useChildren(CHECKBOX_GROUP_KEY); - const updateModelValue = (value: unknown[]) => { - emit('update:modelValue', value); - }; + const updateValue = (value: unknown[]) => emit('update:modelValue', value); const toggleAll = (options: CheckboxGroupToggleAllOptions = {}) => { if (typeof options === 'boolean') { @@ -64,7 +62,7 @@ export default createComponent({ }); const names = checkedChildren.map((item: any) => item.name); - updateModelValue(names); + updateValue(names); }; watch( @@ -76,7 +74,7 @@ export default createComponent({ useLinkField(() => props.modelValue); linkChildren({ props, - updateModelValue, + updateValue, }); return () =>
{slots.default?.()}
; diff --git a/src/checkbox/index.tsx b/src/checkbox/index.tsx index 0addf1762..f63e50ad0 100644 --- a/src/checkbox/index.tsx +++ b/src/checkbox/index.tsx @@ -1,10 +1,16 @@ import { computed, watch } from 'vue'; + +// Utils import { createNamespace, pick } from '../utils'; +import { CHECKBOX_GROUP_KEY, CheckboxGroupProvide } from '../checkbox-group'; + +// Composables import { useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; import { useLinkField } from '../composables/use-link-field'; + +// Components import Checker, { checkerProps } from './Checker'; -import { CHECKBOX_GROUP_KEY, CheckboxGroupProvide } from '../checkbox-group'; const [createComponent, bem] = createNamespace('checkbox'); @@ -34,7 +40,7 @@ export default createComponent({ value.push(name); if (props.bindGroup) { - parent!.updateModelValue(value); + parent!.updateValue(value); } } } else { @@ -44,7 +50,7 @@ export default createComponent({ value.splice(index, 1); if (props.bindGroup) { - parent!.updateModelValue(value); + parent!.updateValue(value); } } } diff --git a/src/collapse-item/index.tsx b/src/collapse-item/index.tsx index a8c72effa..3b35ade9b 100644 --- a/src/collapse-item/index.tsx +++ b/src/collapse-item/index.tsx @@ -3,7 +3,7 @@ import { ref, watch, computed, nextTick } from 'vue'; // Utils import { createNamespace } from '../utils'; -// Composition +// Composables import { raf, doubleRaf, useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; import { useLazyRender } from '../composables/use-lazy-render'; diff --git a/src/count-down/index.tsx b/src/count-down/index.tsx index 1e79fda6d..c36e315d2 100644 --- a/src/count-down/index.tsx +++ b/src/count-down/index.tsx @@ -4,7 +4,7 @@ import { watch, computed } from 'vue'; import { createNamespace } from '../utils'; import { parseFormat } from './utils'; -// Composition +// Composables import { useCountDown } from '@vant/use'; import { useExpose } from '../composables/use-expose'; diff --git a/src/coupon-list/index.tsx b/src/coupon-list/index.tsx index 3c1438ed9..8d35f81ae 100644 --- a/src/coupon-list/index.tsx +++ b/src/coupon-list/index.tsx @@ -3,7 +3,7 @@ import { watch, computed, nextTick, reactive, PropType, onMounted } from 'vue'; // Utils import { createNamespace } from '../utils'; -// Composition +// Composables import { useWindowSize } from '@vant/use'; import { useRefs } from '../composables/use-refs'; diff --git a/src/datetime-picker/DatePicker.tsx b/src/datetime-picker/DatePicker.tsx index d45f707e4..e9115456c 100644 --- a/src/datetime-picker/DatePicker.tsx +++ b/src/datetime-picker/DatePicker.tsx @@ -19,7 +19,7 @@ import { DatetimePickerType, } from './utils'; -// Composition +// Composables import { useExpose } from '../composables/use-expose'; // Components diff --git a/src/datetime-picker/TimePicker.tsx b/src/datetime-picker/TimePicker.tsx index 977a24caa..ddac21448 100644 --- a/src/datetime-picker/TimePicker.tsx +++ b/src/datetime-picker/TimePicker.tsx @@ -10,7 +10,7 @@ import { } from '../utils'; import { times, sharedProps, pickerKeys } from './utils'; -// Composition +// Composables import { useExpose } from '../composables/use-expose'; // Components diff --git a/src/dialog/Dialog.tsx b/src/dialog/Dialog.tsx index 6c00dc88c..46b961fae 100644 --- a/src/dialog/Dialog.tsx +++ b/src/dialog/Dialog.tsx @@ -64,10 +64,10 @@ export default createComponent({ cancel: false, }); - const onUpdateShow = (value: boolean) => emit('update:show', value); + const updateShow = (value: boolean) => emit('update:show', value); const close = (action: DialogAction) => { - onUpdateShow(false); + updateShow(false); if (props.callback) { props.callback(action); } @@ -212,7 +212,7 @@ export default createComponent({ aria-labelledby={title || message} {...{ ...pick(props, popupKeys), - 'onUpdate:show': onUpdateShow, + 'onUpdate:show': updateShow, }} > {renderTitle()} diff --git a/src/dropdown-item/index.tsx b/src/dropdown-item/index.tsx index 439344c56..8ef7917f9 100644 --- a/src/dropdown-item/index.tsx +++ b/src/dropdown-item/index.tsx @@ -10,7 +10,7 @@ import { import { createNamespace, UnknownProp } from '../utils'; import { DROPDOWN_KEY, DropdownMenuProvide } from '../dropdown-menu'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; diff --git a/src/dropdown-menu/index.tsx b/src/dropdown-menu/index.tsx index 74531bb8e..d005bebae 100644 --- a/src/dropdown-menu/index.tsx +++ b/src/dropdown-menu/index.tsx @@ -3,7 +3,7 @@ import { ref, computed, PropType, CSSProperties, Ref } from 'vue'; // Utils import { isDef, ComponentInstance, createNamespace } from '../utils'; -// Composition +// Composables import { useRect, useChildren, diff --git a/src/field/index.tsx b/src/field/index.tsx index 3863823b9..7d66cef70 100644 --- a/src/field/index.tsx +++ b/src/field/index.tsx @@ -26,7 +26,7 @@ import { } from '../utils'; import { runSyncRule } from './utils'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; import { FORM_KEY, FIELD_KEY } from '../composables/use-link-field'; diff --git a/src/form/index.tsx b/src/form/index.tsx index faddb6335..c022baee0 100644 --- a/src/form/index.tsx +++ b/src/form/index.tsx @@ -3,7 +3,7 @@ import { PropType } from 'vue'; // Utils import { createNamespace, ComponentInstance } from '../utils'; -// Composition +// Composables import { useChildren } from '@vant/use'; import { FORM_KEY } from '../composables/use-link-field'; import { useExpose } from '../composables/use-expose'; diff --git a/src/grid-item/index.tsx b/src/grid-item/index.tsx index 3efdcae32..a47231348 100644 --- a/src/grid-item/index.tsx +++ b/src/grid-item/index.tsx @@ -5,7 +5,7 @@ import { createNamespace, addUnit } from '../utils'; import { BORDER } from '../utils/constant'; import { GRID_KEY, GridProvide } from '../grid'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useRoute, routeProps } from '../composables/use-route'; diff --git a/src/image-preview/ImagePreview.tsx b/src/image-preview/ImagePreview.tsx index 018b290a7..145ea9ced 100644 --- a/src/image-preview/ImagePreview.tsx +++ b/src/image-preview/ImagePreview.tsx @@ -1,10 +1,10 @@ -import { nextTick, onMounted, PropType, reactive, ref, watch } from 'vue'; +import { ref, watch, nextTick, onMounted, PropType, reactive } from 'vue'; // Utils import { ComponentInstance, UnknownProp, createNamespace } from '../utils'; import { callInterceptor, Interceptor } from '../utils/interceptor'; -// Composition +// Composables import { useWindowSize } from '@vant/use'; import { useExpose } from '../composables/use-expose'; @@ -98,13 +98,13 @@ export default createComponent({ const emitScale = (args: ImagePreviewScaleEventParams) => emit('scale', args); - const toggle = (show: boolean) => emit('update:show', show); + const updateShow = (show: boolean) => emit('update:show', show); const emitClose = () => { callInterceptor({ interceptor: props.beforeClose, args: [state.active], - done: () => toggle(false), + done: () => updateShow(false), }); }; @@ -221,7 +221,7 @@ export default createComponent({ overlayClass={bem('overlay')} closeOnPopstate={props.closeOnPopstate} onClosed={onClosed} - {...{ 'onUpdate:show': toggle }} + {...{ 'onUpdate:show': updateShow }} > {renderClose()} {renderImages()} diff --git a/src/image-preview/ImagePreviewItem.tsx b/src/image-preview/ImagePreviewItem.tsx index 2b19f9232..8f48ec03b 100644 --- a/src/image-preview/ImagePreviewItem.tsx +++ b/src/image-preview/ImagePreviewItem.tsx @@ -3,7 +3,7 @@ import { watch, computed, reactive, CSSProperties, defineComponent } from 'vue'; // Utils import { range, preventDefault, createNamespace } from '../utils'; -// Composition +// Composables import { useTouch } from '../composables/use-touch'; // Component diff --git a/src/index-anchor/index.tsx b/src/index-anchor/index.tsx index 5ca88e2cd..54bafda60 100644 --- a/src/index-anchor/index.tsx +++ b/src/index-anchor/index.tsx @@ -6,7 +6,7 @@ import { BORDER_BOTTOM } from '../utils/constant'; import { INDEX_BAR_KEY, IndexBarProvide } from '../index-bar'; import { getScrollTop, getRootScrollTop } from '../utils/dom/scroll'; -// Composition +// Composables import { useRect, useParent } from '@vant/use'; import { useExpose } from '../composables/use-expose'; diff --git a/src/index-bar/index.tsx b/src/index-bar/index.tsx index 5ca1b0567..c92dc819d 100644 --- a/src/index-bar/index.tsx +++ b/src/index-bar/index.tsx @@ -20,7 +20,7 @@ import { ComponentInstance, } from '../utils'; -// Composition +// Composables import { useRect, useChildren, diff --git a/src/list/index.tsx b/src/list/index.tsx index 242889f03..a762a7331 100644 --- a/src/list/index.tsx +++ b/src/list/index.tsx @@ -3,7 +3,7 @@ import { ref, watch, nextTick, onUpdated, onMounted, PropType } from 'vue'; // Utils import { isHidden, createNamespace } from '../utils'; -// Composition +// Composables import { useRect, useScrollParent, useEventListener } from '@vant/use'; import { useExpose } from '../composables/use-expose'; diff --git a/src/nav-bar/index.tsx b/src/nav-bar/index.tsx index 786533b5c..08ef5c7f1 100644 --- a/src/nav-bar/index.tsx +++ b/src/nav-bar/index.tsx @@ -4,7 +4,7 @@ import { ref, CSSProperties } from 'vue'; import { createNamespace } from '../utils'; import { BORDER_BOTTOM } from '../utils/constant'; -// Composition +// Composables import { usePlaceholder } from '../composables/use-placeholder'; // Components diff --git a/src/notice-bar/index.tsx b/src/notice-bar/index.tsx index 38c30067b..7bb21c8cb 100644 --- a/src/notice-bar/index.tsx +++ b/src/notice-bar/index.tsx @@ -1,7 +1,7 @@ import { ref, watch, reactive, PropType } from 'vue'; import { isDef, createNamespace } from '../utils'; -// Composition +// Composables import { raf, useRect, diff --git a/src/picker/PickerColumn.tsx b/src/picker/PickerColumn.tsx index c69713891..d22e7441d 100644 --- a/src/picker/PickerColumn.tsx +++ b/src/picker/PickerColumn.tsx @@ -11,7 +11,7 @@ import { createNamespace, } from '../utils'; -// Composition +// Composables import { useParent } from '@vant/use'; import { useTouch } from '../composables/use-touch'; import { useExpose } from '../composables/use-expose'; diff --git a/src/picker/index.tsx b/src/picker/index.tsx index 4070564ba..6c5997f00 100644 --- a/src/picker/index.tsx +++ b/src/picker/index.tsx @@ -9,7 +9,7 @@ import { } from '../utils'; import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; -// Composition +// Composables import { useChildren } from '@vant/use'; import { useExpose } from '../composables/use-expose'; diff --git a/src/popover/index.tsx b/src/popover/index.tsx index 2d6535cc7..0e1a7b275 100644 --- a/src/popover/index.tsx +++ b/src/popover/index.tsx @@ -13,7 +13,7 @@ import { Instance, createPopper, offsetModifier } from '@vant/popperjs'; import { ComponentInstance, createNamespace } from '../utils'; import { BORDER_BOTTOM } from '../utils/constant'; -// Composition +// Composables import { useClickAway } from '@vant/use'; // Components @@ -125,11 +125,11 @@ export default createComponent({ }); }; - const toggle = (value: boolean) => emit('update:show', value); + const updateShow = (value: boolean) => emit('update:show', value); const onClickWrapper = () => { if (props.trigger === 'click') { - toggle(!props.show); + updateShow(!props.show); } }; @@ -146,11 +146,11 @@ export default createComponent({ emit('select', action, index); if (props.closeOnClickAction) { - toggle(false); + updateShow(false); } }; - const onClickAway = () => toggle(false); + const onClickAway = () => updateShow(false); const renderAction = (action: PopoverAction, index: number) => { const { icon, text, color, disabled, className } = action; @@ -194,7 +194,7 @@ export default createComponent({ transition="van-popover-zoom" lockScroll={false} onTouchstart={onTouchstart} - {...{ ...attrs, 'onUpdate:show': toggle }} + {...{ ...attrs, 'onUpdate:show': updateShow }} >