perf: add truthProp util (#8522)

* perf: add TruthyProp util

* chore: rename

* chore: upd
This commit is contained in:
neverland 2021-04-14 10:26:21 +08:00 committed by GitHub
parent 9381640d2e
commit bd609e1df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 226 additions and 460 deletions

View File

@ -1,5 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { extend, createNamespace, UnknownProp } from '../utils'; import { extend, createNamespace, unknownProp } from '../utils';
import { ACTION_BAR_KEY } from '../action-bar/ActionBar'; import { ACTION_BAR_KEY } from '../action-bar/ActionBar';
// Composables // Composables
@ -21,7 +21,7 @@ export default defineComponent({
icon: String, icon: String,
color: String, color: String,
badge: [Number, String], badge: [Number, String],
iconClass: UnknownProp, iconClass: unknownProp,
}), }),
setup(props, { slots }) { setup(props, { slots }) {

View File

@ -1,5 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
const [name, bem] = createNamespace('action-bar'); const [name, bem] = createNamespace('action-bar');
@ -10,10 +10,7 @@ export default defineComponent({
name, name,
props: { props: {
safeAreaInsetBottom: { safeAreaInsetBottom: truthProp,
type: Boolean,
default: true,
},
}, },
setup(props, { slots }) { setup(props, { slots }) {

View File

@ -1,7 +1,7 @@
import { nextTick, PropType, defineComponent } from 'vue'; import { nextTick, PropType, defineComponent } from 'vue';
// Utils // Utils
import { pick, extend, createNamespace } from '../utils'; import { pick, extend, truthProp, createNamespace } from '../utils';
// Components // Components
import { Icon } from '../icon'; import { Icon } from '../icon';
@ -26,27 +26,18 @@ export default defineComponent({
props: extend({}, popupSharedProps, { props: extend({}, popupSharedProps, {
title: String, title: String,
round: truthProp,
actions: Array as PropType<ActionSheetAction[]>, actions: Array as PropType<ActionSheetAction[]>,
closeable: truthProp,
cancelText: String, cancelText: String,
description: String, description: String,
closeOnPopstate: Boolean, closeOnPopstate: Boolean,
closeOnClickAction: Boolean, closeOnClickAction: Boolean,
round: { safeAreaInsetBottom: truthProp,
type: Boolean,
default: true,
},
closeable: {
type: Boolean,
default: true,
},
closeIcon: { closeIcon: {
type: String, type: String,
default: 'cross', default: 'cross',
}, },
safeAreaInsetBottom: {
type: Boolean,
default: true,
},
}), }),
emits: ['select', 'cancel', 'update:show'], emits: ['select', 'cancel', 'update:show'],

View File

@ -13,6 +13,7 @@ import {
extend, extend,
isObject, isObject,
isMobile, isMobile,
truthProp,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
@ -73,6 +74,8 @@ export default defineComponent({
validator: Function as PropType< validator: Function as PropType<
(key: string, value: string) => string | undefined (key: string, value: string) => string | undefined
>, >,
showArea: truthProp,
showDetail: truthProp,
showDelete: Boolean, showDelete: Boolean,
showPostal: Boolean, showPostal: Boolean,
disableArea: Boolean, disableArea: Boolean,
@ -83,14 +86,6 @@ export default defineComponent({
areaPlaceholder: String, areaPlaceholder: String,
deleteButtonText: String, deleteButtonText: String,
showSearchResult: Boolean, showSearchResult: Boolean,
showArea: {
type: Boolean,
default: true,
},
showDetail: {
type: Boolean,
default: true,
},
detailRows: { detailRows: {
type: [Number, String], type: [Number, String],
default: 1, default: 1,

View File

@ -1,7 +1,7 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
// Components // Components
import { Button } from '../button'; import { Button } from '../button';
@ -15,6 +15,7 @@ export default defineComponent({
props: { props: {
modelValue: [Number, String], modelValue: [Number, String],
switchable: truthProp,
disabledText: String, disabledText: String,
addButtonText: String, addButtonText: String,
defaultTagText: String, defaultTagText: String,
@ -26,10 +27,6 @@ export default defineComponent({
type: Array as PropType<AddressListAddress[]>, type: Array as PropType<AddressListAddress[]>,
default: () => [], default: () => [],
}, },
switchable: {
type: Boolean,
default: true,
},
}, },
emits: [ emits: [

View File

@ -1,5 +1,11 @@
import { PropType, CSSProperties, defineComponent } from 'vue'; import { PropType, CSSProperties, defineComponent } from 'vue';
import { isDef, addUnit, isNumeric, createNamespace } from '../utils'; import {
isDef,
addUnit,
isNumeric,
truthProp,
createNamespace,
} from '../utils';
const [name, bem] = createNamespace('badge'); const [name, bem] = createNamespace('badge');
@ -12,14 +18,11 @@ export default defineComponent({
color: String, color: String,
offset: (Array as unknown) as PropType<[string | number, string | number]>, offset: (Array as unknown) as PropType<[string | number, string | number]>,
content: [Number, String], content: [Number, String],
showZero: truthProp,
tag: { tag: {
type: String as PropType<keyof HTMLElementTagNameMap>, type: String as PropType<keyof HTMLElementTagNameMap>,
default: 'div', default: 'div',
}, },
showZero: {
type: Boolean,
default: true,
},
}, },
setup(props, { slots }) { setup(props, { slots }) {

View File

@ -9,7 +9,13 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { pick, isDate, getScrollTop, ComponentInstance } from '../utils'; import {
pick,
isDate,
truthProp,
getScrollTop,
ComponentInstance,
} from '../utils';
import { import {
t, t,
bem, bem,
@ -46,69 +52,39 @@ export default defineComponent({
show: Boolean, show: Boolean,
title: String, title: String,
color: String, color: String,
round: truthProp,
readonly: Boolean, readonly: Boolean,
poppable: truthProp,
teleport: [String, Object] as PropType<TeleportProps['to']>, teleport: [String, Object] as PropType<TeleportProps['to']>,
showMark: truthProp,
showTitle: truthProp,
formatter: Function as PropType<(item: CalendarDayItem) => CalendarDayItem>, formatter: Function as PropType<(item: CalendarDayItem) => CalendarDayItem>,
rowHeight: [Number, String], rowHeight: [Number, String],
confirmText: String, confirmText: String,
rangePrompt: String, rangePrompt: String,
lazyRender: truthProp,
showConfirm: truthProp,
// TODO: remove any // TODO: remove any
// see: https://github.com/vuejs/vue-next/issues/2668 // see: https://github.com/vuejs/vue-next/issues/2668
defaultDate: [Date, Array] as any, defaultDate: [Date, Array] as any,
allowSameDay: Boolean, allowSameDay: Boolean,
showSubtitle: truthProp,
closeOnPopstate: truthProp,
confirmDisabledText: String, confirmDisabledText: String,
closeOnClickOverlay: truthProp,
safeAreaInsetBottom: truthProp,
type: { type: {
type: String as PropType<CalendarType>, type: String as PropType<CalendarType>,
default: 'single', default: 'single',
}, },
round: {
type: Boolean,
default: true,
},
position: { position: {
type: String as PropType<PopupPosition>, type: String as PropType<PopupPosition>,
default: 'bottom', default: 'bottom',
}, },
poppable: {
type: Boolean,
default: true,
},
maxRange: { maxRange: {
type: [Number, String], type: [Number, String],
default: null, default: null,
}, },
lazyRender: {
type: Boolean,
default: true,
},
showMark: {
type: Boolean,
default: true,
},
showTitle: {
type: Boolean,
default: true,
},
showConfirm: {
type: Boolean,
default: true,
},
showSubtitle: {
type: Boolean,
default: true,
},
closeOnPopstate: {
type: Boolean,
default: true,
},
closeOnClickOverlay: {
type: Boolean,
default: true,
},
safeAreaInsetBottom: {
type: Boolean,
default: true,
},
minDate: { minDate: {
type: Date, type: Date,
validator: isDate, validator: isDate,

View File

@ -1,5 +1,5 @@
import { nextTick, PropType, reactive, watch, defineComponent } from 'vue'; import { nextTick, PropType, reactive, watch, defineComponent } from 'vue';
import { createNamespace, extend } from '../utils'; import { createNamespace, truthProp, extend } from '../utils';
// Components // Components
import { Tab } from '../tab'; import { Tab } from '../tab';
@ -32,6 +32,8 @@ export default defineComponent({
props: { props: {
title: String, title: String,
closeable: truthProp,
swipeable: truthProp,
modelValue: [Number, String], modelValue: [Number, String],
fieldNames: Object as PropType<CascaderFieldNames>, fieldNames: Object as PropType<CascaderFieldNames>,
placeholder: String, placeholder: String,
@ -40,18 +42,10 @@ export default defineComponent({
type: Array as PropType<CascaderOption[]>, type: Array as PropType<CascaderOption[]>,
default: () => [], default: () => [],
}, },
closeable: {
type: Boolean,
default: true,
},
closeIcon: { closeIcon: {
type: String, type: String,
default: 'cross', default: 'cross',
}, },
swipeable: {
type: Boolean,
default: true,
},
}, },
emits: ['close', 'change', 'finish', 'update:modelValue'], emits: ['close', 'change', 'finish', 'update:modelValue'],

View File

@ -1,5 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [name, bem] = createNamespace('cell-group'); const [name, bem] = createNamespace('cell-group');
@ -11,10 +11,7 @@ export default defineComponent({
props: { props: {
title: String, title: String,
border: { border: truthProp,
type: Boolean,
default: true,
},
}, },
setup(props, { slots, attrs }) { setup(props, { slots, attrs }) {

View File

@ -1,7 +1,13 @@
import { PropType, CSSProperties, defineComponent } from 'vue'; import { PropType, CSSProperties, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, extend, isDef, UnknownProp } from '../utils'; import {
createNamespace,
extend,
isDef,
truthProp,
unknownProp,
} from '../utils';
// Composables // Composables
import { useRoute, routeProps } from '../composables/use-route'; import { useRoute, routeProps } from '../composables/use-route';
@ -21,17 +27,14 @@ export const cellProps = {
label: [Number, String], label: [Number, String],
center: Boolean, center: Boolean,
isLink: Boolean, isLink: Boolean,
border: truthProp,
required: Boolean, required: Boolean,
iconPrefix: String, iconPrefix: String,
valueClass: UnknownProp, valueClass: unknownProp,
labelClass: UnknownProp, labelClass: unknownProp,
titleClass: UnknownProp, titleClass: unknownProp,
titleStyle: (null as unknown) as PropType<string | CSSProperties>, titleStyle: (null as unknown) as PropType<string | CSSProperties>,
arrowDirection: String as PropType<CellArrowDirection>, arrowDirection: String as PropType<CellArrowDirection>,
border: {
type: Boolean,
default: true,
},
clickable: { clickable: {
type: Boolean as PropType<boolean | null>, type: Boolean as PropType<boolean | null>,
default: null, default: null,

View File

@ -1,7 +1,7 @@
import { computed, watch, defineComponent } from 'vue'; import { computed, watch, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, extend, pick } from '../utils'; import { createNamespace, extend, pick, truthProp } from '../utils';
import { import {
CHECKBOX_GROUP_KEY, CHECKBOX_GROUP_KEY,
CheckboxGroupProvide, CheckboxGroupProvide,
@ -21,10 +21,7 @@ export default defineComponent({
name, name,
props: extend({}, checkerProps, { props: extend({}, checkerProps, {
bindGroup: { bindGroup: truthProp,
type: Boolean,
default: true,
},
}), }),
emits: ['change', 'update:modelValue'], emits: ['change', 'update:modelValue'],

View File

@ -1,5 +1,5 @@
import { ref, computed, PropType, defineComponent } from 'vue'; import { ref, computed, PropType, defineComponent } from 'vue';
import { addUnit, extend, UnknownProp } from '../utils'; import { addUnit, extend, unknownProp, truthProp } from '../utils';
import { Icon } from '../icon'; import { Icon } from '../icon';
export type CheckerShape = 'square' | 'round'; export type CheckerShape = 'square' | 'round';
@ -15,10 +15,10 @@ export type CheckerParent = {
}; };
export const checkerProps = { export const checkerProps = {
name: UnknownProp, name: unknownProp,
disabled: Boolean, disabled: Boolean,
iconSize: [Number, String], iconSize: [Number, String],
modelValue: UnknownProp, modelValue: unknownProp,
checkedColor: String, checkedColor: String,
labelPosition: String as PropType<CheckerLabelPosition>, labelPosition: String as PropType<CheckerLabelPosition>,
labelDisabled: Boolean, labelDisabled: Boolean,
@ -33,10 +33,7 @@ export default defineComponent({
role: String, role: String,
parent: Object as PropType<CheckerParent | null>, parent: Object as PropType<CheckerParent | null>,
checked: Boolean, checked: Boolean,
bindGroup: { bindGroup: truthProp,
type: Boolean,
default: true,
},
bem: { bem: {
type: Function, type: Function,
required: true as const, required: true as const,

View File

@ -1,6 +1,6 @@
import { watch, computed, PropType, CSSProperties, defineComponent } from 'vue'; import { watch, computed, PropType, CSSProperties, defineComponent } from 'vue';
import { raf, cancelRaf } from '@vant/use'; import { raf, cancelRaf } from '@vant/use';
import { isObject, getSizeStyle, createNamespace } from '../utils'; import { isObject, getSizeStyle, truthProp, createNamespace } from '../utils';
const [name, bem] = createNamespace('circle'); const [name, bem] = createNamespace('circle');
@ -24,6 +24,7 @@ export default defineComponent({
text: String, text: String,
size: [Number, String], size: [Number, String],
color: [String, Object] as PropType<string | Record<string, string>>, color: [String, Object] as PropType<string | Record<string, string>>,
clockwise: truthProp,
layerColor: String, layerColor: String,
strokeLinecap: String as PropType<CanvasLineCap>, strokeLinecap: String as PropType<CanvasLineCap>,
currentRate: { currentRate: {
@ -46,10 +47,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: 40, default: 40,
}, },
clockwise: {
type: Boolean,
default: true,
},
}, },
emits: ['update:currentRate'], emits: ['update:currentRate'],

View File

@ -2,7 +2,7 @@ import { ref, watch, computed, nextTick, defineComponent } from 'vue';
// Utils // Utils
import { cellProps } from '../cell/Cell'; import { cellProps } from '../cell/Cell';
import { createNamespace, extend, pick } from '../utils'; import { createNamespace, extend, pick, truthProp } from '../utils';
import { COLLAPSE_KEY, CollapseProvide } from '../collapse/Collapse'; import { COLLAPSE_KEY, CollapseProvide } from '../collapse/Collapse';
// Composables // Composables
@ -20,12 +20,9 @@ export default defineComponent({
props: extend({}, cellProps, { props: extend({}, cellProps, {
name: [Number, String], name: [Number, String],
isLink: truthProp,
disabled: Boolean, disabled: Boolean,
readonly: Boolean, readonly: Boolean,
isLink: {
type: Boolean,
default: true,
},
}), }),
setup(props, { slots }) { setup(props, { slots }) {

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
@ -16,6 +16,7 @@ export default defineComponent({
name, name,
props: { props: {
border: truthProp,
accordion: Boolean, accordion: Boolean,
modelValue: { modelValue: {
type: [String, Number, Array] as PropType< type: [String, Number, Array] as PropType<
@ -23,10 +24,6 @@ export default defineComponent({
>, >,
default: '', default: '',
}, },
border: {
type: Boolean,
default: true,
},
}, },
emits: ['change', 'update:modelValue'], emits: ['change', 'update:modelValue'],

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { Cell } from '../cell'; import { Cell } from '../cell';
const [name, bem, t] = createNamespace('contact-card'); const [name, bem, t] = createNamespace('contact-card');
@ -13,10 +13,7 @@ export default defineComponent({
tel: String, tel: String,
name: String, name: String,
addText: String, addText: String,
editable: { editable: truthProp,
type: Boolean,
default: true,
},
type: { type: {
type: String as PropType<ContactCardType>, type: String as PropType<ContactCardType>,
default: 'add', default: 'add',

View File

@ -1,7 +1,7 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, UnknownProp } from '../utils'; import { createNamespace, unknownProp } from '../utils';
// Components // Components
import { Tag } from '../tag'; import { Tag } from '../tag';
@ -26,7 +26,7 @@ export default defineComponent({
props: { props: {
list: Array as PropType<ContactListItem[]>, list: Array as PropType<ContactListItem[]>,
addText: String, addText: String,
modelValue: UnknownProp, modelValue: unknownProp,
defaultTagText: String, defaultTagText: String,
}, },

View File

@ -1,7 +1,7 @@
import { watch, computed, defineComponent } from 'vue'; import { watch, computed, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { parseFormat } from './utils'; import { parseFormat } from './utils';
// Composables // Composables
@ -14,6 +14,7 @@ export default defineComponent({
name, name,
props: { props: {
autoStart: truthProp,
millisecond: Boolean, millisecond: Boolean,
time: { time: {
type: [Number, String], type: [Number, String],
@ -23,10 +24,6 @@ export default defineComponent({
type: String, type: String,
default: 'HH:mm:ss', default: 'HH:mm:ss',
}, },
autoStart: {
type: Boolean,
default: true,
},
}, },
emits: ['change', 'finish'], emits: ['change', 'finish'],

View File

@ -1,7 +1,7 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
// Utils // Utils
import { isDef, createNamespace } from '../utils'; import { isDef, truthProp, createNamespace } from '../utils';
// Components // Components
import { Cell } from '../cell'; import { Cell } from '../cell';
@ -38,6 +38,8 @@ export default defineComponent({
props: { props: {
title: String, title: String,
border: truthProp,
editable: truthProp,
coupons: { coupons: {
type: Array as PropType<CouponInfo[]>, type: Array as PropType<CouponInfo[]>,
default: () => [], default: () => [],
@ -46,14 +48,6 @@ export default defineComponent({
type: String, type: String,
default: '¥', default: '¥',
}, },
border: {
type: Boolean,
default: true,
},
editable: {
type: Boolean,
default: true,
},
chosenCoupon: { chosenCoupon: {
type: [Number, String], type: [Number, String],
default: -1, default: -1,

View File

@ -9,7 +9,7 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
// Composables // Composables
import { useWindowSize } from '@vant/use'; import { useWindowSize } from '@vant/use';
@ -29,8 +29,11 @@ export default defineComponent({
name, name,
props: { props: {
showCount: truthProp,
enabledTitle: String, enabledTitle: String,
disabledTitle: String, disabledTitle: String,
showExchangeBar: truthProp,
showCloseButton: truthProp,
closeButtonText: String, closeButtonText: String,
inputPlaceholder: String, inputPlaceholder: String,
exchangeButtonText: String, exchangeButtonText: String,
@ -60,18 +63,6 @@ export default defineComponent({
type: Number, type: Number,
default: -1, default: -1,
}, },
showExchangeBar: {
type: Boolean,
default: true,
},
showCloseButton: {
type: Boolean,
default: true,
},
showCount: {
type: Boolean,
default: true,
},
currency: { currency: {
type: String, type: String,
default: '¥', default: '¥',

View File

@ -6,8 +6,9 @@ import {
pick, pick,
extend, extend,
addUnit, addUnit,
truthProp,
isFunction, isFunction,
UnknownProp, unknownProp,
createNamespace, createNamespace,
} from '../utils'; } from '../utils';
import { BORDER_TOP, BORDER_LEFT } from '../utils/constant'; import { BORDER_TOP, BORDER_LEFT } from '../utils/constant';
@ -42,27 +43,21 @@ export default defineComponent({
message: [String, Function] as PropType<DialogMessage>, message: [String, Function] as PropType<DialogMessage>,
callback: Function as PropType<(action?: DialogAction) => void>, callback: Function as PropType<(action?: DialogAction) => void>,
allowHtml: Boolean, allowHtml: Boolean,
className: UnknownProp, className: unknownProp,
beforeClose: Function as PropType<Interceptor>, beforeClose: Function as PropType<Interceptor>,
messageAlign: String as PropType<DialogMessageAlign>, messageAlign: String as PropType<DialogMessageAlign>,
closeOnPopstate: truthProp,
showCancelButton: Boolean, showCancelButton: Boolean,
cancelButtonText: String, cancelButtonText: String,
cancelButtonColor: String, cancelButtonColor: String,
confirmButtonText: String, confirmButtonText: String,
confirmButtonColor: String, confirmButtonColor: String,
showConfirmButton: truthProp,
closeOnClickOverlay: Boolean, closeOnClickOverlay: Boolean,
transition: { transition: {
type: String, type: String,
default: 'van-dialog-bounce', default: 'van-dialog-bounce',
}, },
showConfirmButton: {
type: Boolean,
default: true,
},
closeOnPopstate: {
type: Boolean,
default: true,
},
}), }),
emits: ['confirm', 'cancel', 'update:show'], emits: ['confirm', 'cancel', 'update:show'],

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
const [name, bem] = createNamespace('divider'); const [name, bem] = createNamespace('divider');
@ -10,10 +10,7 @@ export default defineComponent({
props: { props: {
dashed: Boolean, dashed: Boolean,
hairline: { hairline: truthProp,
type: Boolean,
default: true,
},
contentPosition: { contentPosition: {
type: String as PropType<DividerContentPosition>, type: String as PropType<DividerContentPosition>,
default: 'center', default: 'center',

View File

@ -8,7 +8,12 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { createNamespace, getZIndexStyle, UnknownProp } from '../utils'; import {
truthProp,
unknownProp,
getZIndexStyle,
createNamespace,
} from '../utils';
import { import {
DROPDOWN_KEY, DROPDOWN_KEY,
DropdownMenuProvide, DropdownMenuProvide,
@ -38,16 +43,13 @@ export default defineComponent({
title: String, title: String,
disabled: Boolean, disabled: Boolean,
teleport: [String, Object] as PropType<TeleportProps['to']>, teleport: [String, Object] as PropType<TeleportProps['to']>,
modelValue: UnknownProp, lazyRender: truthProp,
titleClass: UnknownProp, modelValue: unknownProp,
titleClass: unknownProp,
options: { options: {
type: Array as PropType<DropdownItemOption[]>, type: Array as PropType<DropdownItemOption[]>,
default: () => [], default: () => [],
}, },
lazyRender: {
type: Boolean,
default: true,
},
}, },
emits: ['open', 'opened', 'close', 'closed', 'change', 'update:modelValue'], emits: ['open', 'opened', 'close', 'closed', 'change', 'update:modelValue'],

View File

@ -9,7 +9,7 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { isDef, ComponentInstance, createNamespace } from '../utils'; import { isDef, truthProp, createNamespace, ComponentInstance } from '../utils';
// Composables // Composables
import { import {
@ -27,12 +27,11 @@ export const DROPDOWN_KEY = Symbol(name);
export type DropdownMenuDirection = 'up' | 'down'; export type DropdownMenuDirection = 'up' | 'down';
const props = { const props = {
overlay: truthProp,
zIndex: [Number, String], zIndex: [Number, String],
activeColor: String, activeColor: String,
overlay: { closeOnClickOutside: truthProp,
type: Boolean, closeOnClickOverlay: truthProp,
default: true,
},
duration: { duration: {
type: [Number, String], type: [Number, String],
default: 0.2, default: 0.2,
@ -41,14 +40,6 @@ const props = {
type: String as PropType<DropdownMenuDirection>, type: String as PropType<DropdownMenuDirection>,
default: 'down', default: 'down',
}, },
closeOnClickOutside: {
type: Boolean,
default: true,
},
closeOnClickOverlay: {
type: Boolean,
default: true,
},
}; };
export type DropdownMenuProvide = { export type DropdownMenuProvide = {

View File

@ -15,7 +15,7 @@ import {
isDef, isDef,
extend, extend,
addUnit, addUnit,
UnknownProp, unknownProp,
resetScroll, resetScroll,
formatNumber, formatNumber,
preventDefault, preventDefault,
@ -83,7 +83,7 @@ export const fieldProps = {
default: 'clear', default: 'clear',
}, },
modelValue: { modelValue: {
type: [String, Number], type: [Number, String],
default: '', default: '',
}, },
clearTrigger: { clearTrigger: {
@ -105,7 +105,7 @@ export default defineComponent({
rules: Array as PropType<FieldRule[]>, rules: Array as PropType<FieldRule[]>,
autosize: [Boolean, Object] as PropType<boolean | FieldAutosizeConfig>, autosize: [Boolean, Object] as PropType<boolean | FieldAutosizeConfig>,
labelWidth: [Number, String], labelWidth: [Number, String],
labelClass: UnknownProp, labelClass: unknownProp,
labelAlign: String as PropType<FieldTextAlign>, labelAlign: String as PropType<FieldTextAlign>,
autocomplete: String, autocomplete: String,
showWordLimit: Boolean, showWordLimit: Boolean,

View File

@ -1,7 +1,7 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, ComponentInstance } from '../utils'; import { truthProp, createNamespace, ComponentInstance } from '../utils';
// Composables // Composables
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
@ -30,19 +30,13 @@ export default defineComponent({
inputAlign: String as PropType<FieldTextAlign>, inputAlign: String as PropType<FieldTextAlign>,
scrollToError: Boolean, scrollToError: Boolean,
validateFirst: Boolean, validateFirst: Boolean,
submitOnEnter: truthProp,
showErrorMessage: truthProp,
errorMessageAlign: String as PropType<FieldTextAlign>, errorMessageAlign: String as PropType<FieldTextAlign>,
submitOnEnter: {
type: Boolean,
default: true,
},
validateTrigger: { validateTrigger: {
type: String as PropType<FieldValidateTrigger>, type: String as PropType<FieldValidateTrigger>,
default: 'onBlur', default: 'onBlur',
}, },
showErrorMessage: {
type: Boolean,
default: true,
},
}, },
emits: ['submit', 'failed'], emits: ['submit', 'failed'],

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent, ExtractPropTypes } from 'vue'; import { PropType, defineComponent, ExtractPropTypes } from 'vue';
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit, truthProp } from '../utils';
import { BORDER_TOP } from '../utils/constant'; import { BORDER_TOP } from '../utils/constant';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
@ -11,6 +11,8 @@ export type GridDirection = 'horizontal' | 'vertical';
const props = { const props = {
square: Boolean, square: Boolean,
center: truthProp,
border: truthProp,
gutter: [Number, String], gutter: [Number, String],
iconSize: [Number, String], iconSize: [Number, String],
direction: String as PropType<GridDirection>, direction: String as PropType<GridDirection>,
@ -19,14 +21,6 @@ const props = {
type: [Number, String], type: [Number, String],
default: 4, default: 4,
}, },
center: {
type: Boolean,
default: true,
},
border: {
type: Boolean,
default: true,
},
}; };
export type GridProvide = { export type GridProvide = {

View File

@ -12,7 +12,8 @@ import {
// Utils // Utils
import { import {
pick, pick,
UnknownProp, truthProp,
unknownProp,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
@ -40,24 +41,20 @@ export default defineComponent({
props: { props: {
show: Boolean, show: Boolean,
loop: truthProp,
overlay: truthProp,
closeable: Boolean, closeable: Boolean,
showIndex: truthProp,
className: unknownProp,
transition: String, transition: String,
className: UnknownProp,
beforeClose: Function as PropType<Interceptor>, beforeClose: Function as PropType<Interceptor>,
overlayStyle: Object as PropType<CSSProperties>, overlayStyle: Object as PropType<CSSProperties>,
showIndicators: Boolean, showIndicators: Boolean,
closeOnPopstate: truthProp,
images: { images: {
type: Array as PropType<string[]>, type: Array as PropType<string[]>,
default: () => [], default: () => [],
}, },
loop: {
type: Boolean,
default: true,
},
overlay: {
type: Boolean,
default: true,
},
minZoom: { minZoom: {
type: [Number, String], type: [Number, String],
default: 1 / 3, default: 1 / 3,
@ -66,10 +63,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: 3, default: 3,
}, },
showIndex: {
type: Boolean,
default: true,
},
swipeDuration: { swipeDuration: {
type: [Number, String], type: [Number, String],
default: 300, default: 300,
@ -82,10 +75,6 @@ export default defineComponent({
type: String, type: String,
default: 'clear', default: 'clear',
}, },
closeOnPopstate: {
type: Boolean,
default: true,
},
closeIconPosition: { closeIconPosition: {
type: String as PropType<PopupCloseIconPosition>, type: String as PropType<PopupCloseIconPosition>,
default: 'top-right', default: 'top-right',

View File

@ -14,6 +14,7 @@ import {
isDef, isDef,
addUnit, addUnit,
inBrowser, inBrowser,
truthProp,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
@ -38,15 +39,9 @@ export default defineComponent({
radius: [Number, String], radius: [Number, String],
lazyLoad: Boolean, lazyLoad: Boolean,
iconSize: [Number, String], iconSize: [Number, String],
showError: truthProp,
iconPrefix: String, iconPrefix: String,
showError: { showLoading: truthProp,
type: Boolean,
default: true,
},
showLoading: {
type: Boolean,
default: true,
},
errorIcon: { errorIcon: {
type: String, type: String,
default: 'photo-fail', default: 'photo-fail',

View File

@ -14,6 +14,7 @@ import {
import { import {
isDef, isDef,
isHidden, isHidden,
truthProp,
getScrollTop, getScrollTop,
preventDefault, preventDefault,
createNamespace, createNamespace,
@ -46,12 +47,9 @@ const [name, bem] = createNamespace('index-bar');
export const INDEX_BAR_KEY = Symbol(name); export const INDEX_BAR_KEY = Symbol(name);
const props = { const props = {
sticky: truthProp,
zIndex: [Number, String], zIndex: [Number, String],
highlightColor: String, highlightColor: String,
sticky: {
type: Boolean,
default: true,
},
stickyOffsetTop: { stickyOffsetTop: {
type: Number, type: Number,
default: 0, default: 0,

View File

@ -9,7 +9,7 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { isHidden, createNamespace } from '../utils'; import { isHidden, truthProp, createNamespace } from '../utils';
// Composables // Composables
import { useRect, useScrollParent, useEventListener } from '@vant/use'; import { useRect, useScrollParent, useEventListener } from '@vant/use';
@ -30,6 +30,7 @@ export default defineComponent({
errorText: String, errorText: String,
loadingText: String, loadingText: String,
finishedText: String, finishedText: String,
immediateCheck: truthProp,
offset: { offset: {
type: [Number, String], type: [Number, String],
default: 300, default: 300,
@ -38,10 +39,6 @@ export default defineComponent({
type: String as PropType<'up' | 'down'>, type: String as PropType<'up' | 'down'>,
default: 'down', default: 'down',
}, },
immediateCheck: {
type: Boolean,
default: true,
},
}, },
emits: ['load', 'update:error', 'update:loading'], emits: ['load', 'update:error', 'update:loading'],

View File

@ -1,7 +1,7 @@
import { ref, CSSProperties, defineComponent } from 'vue'; import { ref, CSSProperties, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, getZIndexStyle } from '../utils'; import { truthProp, createNamespace, getZIndexStyle } from '../utils';
import { BORDER_BOTTOM } from '../utils/constant'; import { BORDER_BOTTOM } from '../utils/constant';
// Composables // Composables
@ -19,15 +19,12 @@ export default defineComponent({
title: String, title: String,
fixed: Boolean, fixed: Boolean,
zIndex: [Number, String], zIndex: [Number, String],
border: truthProp,
leftText: String, leftText: String,
rightText: String, rightText: String,
leftArrow: Boolean, leftArrow: Boolean,
placeholder: Boolean, placeholder: Boolean,
safeAreaInsetTop: Boolean, safeAreaInsetTop: Boolean,
border: {
type: Boolean,
default: true,
},
}, },
emits: ['click-left', 'click-right'], emits: ['click-left', 'click-right'],

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { createNamespace, extend, UnknownProp } from '../utils'; import { createNamespace, extend, unknownProp } from '../utils';
import { Popup } from '../popup'; import { Popup } from '../popup';
import { popupSharedProps } from '../popup/shared'; import { popupSharedProps } from '../popup/shared';
@ -13,7 +13,7 @@ export default defineComponent({
props: extend({}, popupSharedProps, { props: extend({}, popupSharedProps, {
color: String, color: String,
message: [Number, String], message: [Number, String],
className: UnknownProp, className: unknownProp,
background: String, background: String,
lockScroll: Boolean, lockScroll: Boolean,
type: { type: {

View File

@ -9,8 +9,19 @@ import {
TeleportProps, TeleportProps,
defineComponent, defineComponent,
} from 'vue'; } from 'vue';
import { createNamespace, getZIndexStyle, stopPropagation } from '../utils';
// Utils
import {
truthProp,
getZIndexStyle,
stopPropagation,
createNamespace,
} from '../utils';
// Composables
import { useClickAway } from '@vant/use'; import { useClickAway } from '@vant/use';
// Components
import NumberKeyboardKey, { KeyType } from './NumberKeyboardKey'; import NumberKeyboardKey, { KeyType } from './NumberKeyboardKey';
const [name, bem] = createNamespace('number-keyboard'); const [name, bem] = createNamespace('number-keyboard');
@ -32,10 +43,15 @@ export default defineComponent({
title: String, title: String,
zIndex: [Number, String], zIndex: [Number, String],
teleport: [String, Object] as PropType<TeleportProps['to']>, teleport: [String, Object] as PropType<TeleportProps['to']>,
transition: truthProp,
blurOnClose: truthProp,
showDeleteKey: truthProp,
randomKeyOrder: Boolean, randomKeyOrder: Boolean,
closeButtonText: String, closeButtonText: String,
deleteButtonText: String, deleteButtonText: String,
closeButtonLoading: Boolean, closeButtonLoading: Boolean,
hideOnClickOutside: truthProp,
safeAreaInsetBottom: truthProp,
theme: { theme: {
type: String as PropType<NumberKeyboardTheme>, type: String as PropType<NumberKeyboardTheme>,
default: 'default', default: 'default',
@ -52,26 +68,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: Number.MAX_VALUE, default: Number.MAX_VALUE,
}, },
transition: {
type: Boolean,
default: true,
},
blurOnClose: {
type: Boolean,
default: true,
},
showDeleteKey: {
type: Boolean,
default: true,
},
hideOnClickOutside: {
type: Boolean,
default: true,
},
safeAreaInsetBottom: {
type: Boolean,
default: true,
},
}, },
emits: [ emits: [

View File

@ -3,7 +3,8 @@ import {
noop, noop,
isDef, isDef,
extend, extend,
UnknownProp, truthProp,
unknownProp,
preventDefault, preventDefault,
createNamespace, createNamespace,
getZIndexStyle, getZIndexStyle,
@ -19,12 +20,9 @@ export default defineComponent({
show: Boolean, show: Boolean,
zIndex: [Number, String], zIndex: [Number, String],
duration: [Number, String], duration: [Number, String],
className: UnknownProp, className: unknownProp,
lockScroll: truthProp,
customStyle: Object as PropType<CSSProperties>, customStyle: Object as PropType<CSSProperties>,
lockScroll: {
type: Boolean,
default: true,
},
}, },
setup(props, { slots }) { setup(props, { slots }) {

View File

@ -1,5 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit, truthProp } from '../utils';
import { BORDER_LEFT, BORDER_SURROUND } from '../utils/constant'; import { BORDER_LEFT, BORDER_SURROUND } from '../utils/constant';
const [name, bem] = createNamespace('password-input'); const [name, bem] = createNamespace('password-input');
@ -9,13 +9,10 @@ export default defineComponent({
props: { props: {
info: String, info: String,
mask: truthProp,
gutter: [Number, String], gutter: [Number, String],
focused: Boolean, focused: Boolean,
errorInfo: String, errorInfo: String,
mask: {
type: Boolean,
default: true,
},
value: { value: {
type: String, type: String,
default: '', default: '',

View File

@ -4,6 +4,7 @@ import { ref, watch, computed, PropType, defineComponent } from 'vue';
import { import {
extend, extend,
unitToPx, unitToPx,
truthProp,
preventDefault, preventDefault,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
@ -46,16 +47,13 @@ export const pickerProps = {
loading: Boolean, loading: Boolean,
readonly: Boolean, readonly: Boolean,
allowHtml: Boolean, allowHtml: Boolean,
showToolbar: truthProp,
cancelButtonText: String, cancelButtonText: String,
confirmButtonText: String, confirmButtonText: String,
itemHeight: { itemHeight: {
type: [Number, String], type: [Number, String],
default: 44, default: 44,
}, },
showToolbar: {
type: Boolean,
default: true,
},
visibleItemCount: { visibleItemCount: {
type: [Number, String], type: [Number, String],
default: 6, default: 6,

View File

@ -6,7 +6,7 @@ import { deepClone } from '../utils/deep-clone';
import { import {
range, range,
isObject, isObject,
UnknownProp, unknownProp,
preventDefault, preventDefault,
createNamespace, createNamespace,
} from '../utils'; } from '../utils';
@ -66,7 +66,7 @@ export default defineComponent({
props: { props: {
readonly: Boolean, readonly: Boolean,
allowHtml: Boolean, allowHtml: Boolean,
className: UnknownProp, className: unknownProp,
textKey: { textKey: {
type: String, type: String,
required: true, required: true,

View File

@ -15,7 +15,8 @@ import { Instance, createPopper, offsetModifier } from '@vant/popperjs';
import { import {
pick, pick,
extend, extend,
UnknownProp, truthProp,
unknownProp,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
@ -71,8 +72,11 @@ export default defineComponent({
show: Boolean, show: Boolean,
overlay: Boolean, overlay: Boolean,
duration: [Number, String], duration: [Number, String],
overlayClass: UnknownProp, overlayClass: unknownProp,
overlayStyle: Object as PropType<CSSProperties>, overlayStyle: Object as PropType<CSSProperties>,
closeOnClickAction: truthProp,
closeOnClickOverlay: truthProp,
closeOnClickOutside: truthProp,
offset: { offset: {
type: (Array as unknown) as PropType<[number, number]>, type: (Array as unknown) as PropType<[number, number]>,
default: () => [0, 8], default: () => [0, 8],
@ -97,18 +101,6 @@ export default defineComponent({
type: [String, Object] as PropType<TeleportProps['to']>, type: [String, Object] as PropType<TeleportProps['to']>,
default: 'body', default: 'body',
}, },
closeOnClickAction: {
type: Boolean,
default: true,
},
closeOnClickOverlay: {
type: Boolean,
default: true,
},
closeOnClickOutside: {
type: Boolean,
default: true,
},
}, },
emits: ['select', 'touchstart', 'update:show'], emits: ['select', 'touchstart', 'update:show'],

View File

@ -1,41 +1,29 @@
import { PropType, CSSProperties, TeleportProps } from 'vue'; import { PropType, CSSProperties, TeleportProps } from 'vue';
import { UnknownProp } from '../utils'; import { truthProp, unknownProp } from '../utils';
export const popupSharedProps = { export const popupSharedProps = {
// whether to show popup // whether to show popup
show: Boolean, show: Boolean,
// z-index // z-index
zIndex: [Number, String], zIndex: [Number, String],
// whether to show overlay
overlay: truthProp,
// transition duration // transition duration
duration: [Number, String], duration: [Number, String],
// teleport // teleport
teleport: [String, Object] as PropType<TeleportProps['to']>, teleport: [String, Object] as PropType<TeleportProps['to']>,
// prevent body scroll
lockScroll: truthProp,
// whether to lazy render
lazyRender: truthProp,
// overlay custom style // overlay custom style
overlayStyle: Object as PropType<CSSProperties>, overlayStyle: Object as PropType<CSSProperties>,
// overlay custom class name // overlay custom class name
overlayClass: UnknownProp, overlayClass: unknownProp,
// Initial rendering animation // Initial rendering animation
transitionAppear: Boolean, transitionAppear: Boolean,
// whether to show overlay
overlay: {
type: Boolean,
default: true,
},
// prevent body scroll
lockScroll: {
type: Boolean,
default: true,
},
// whether to lazy render
lazyRender: {
type: Boolean,
default: true,
},
// whether to close popup when overlay is clicked // whether to close popup when overlay is clicked
closeOnClickOverlay: { closeOnClickOverlay: truthProp,
type: Boolean,
default: true,
},
}; };
export type PopupSharedPropKeys = Array<keyof typeof popupSharedProps>; export type PopupSharedPropKeys = Array<keyof typeof popupSharedProps>;

View File

@ -7,7 +7,7 @@ import {
onMounted, onMounted,
defineComponent, defineComponent,
} from 'vue'; } from 'vue';
import { createNamespace, addUnit } from '../utils'; import { truthProp, createNamespace, addUnit } from '../utils';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
const [name, bem] = createNamespace('progress'); const [name, bem] = createNamespace('progress');
@ -20,6 +20,7 @@ export default defineComponent({
inactive: Boolean, inactive: Boolean,
pivotText: String, pivotText: String,
textColor: String, textColor: String,
showPivot: truthProp,
pivotColor: String, pivotColor: String,
trackColor: String, trackColor: String,
strokeWidth: [Number, String], strokeWidth: [Number, String],
@ -28,10 +29,6 @@ export default defineComponent({
required: true, required: true,
validator: (value: number | string) => value >= 0 && value <= 100, validator: (value: number | string) => value >= 0 && value <= 100,
}, },
showPivot: {
type: Boolean,
default: true,
},
}, },
setup(props) { setup(props) {

View File

@ -1,5 +1,5 @@
import { watch, defineComponent, ExtractPropTypes } from 'vue'; import { watch, defineComponent, ExtractPropTypes } from 'vue';
import { UnknownProp, createNamespace } from '../utils'; import { unknownProp, createNamespace } from '../utils';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';
import { CheckerParent } from '../checkbox/Checker'; import { CheckerParent } from '../checkbox/Checker';
@ -12,7 +12,7 @@ const props = {
disabled: Boolean, disabled: Boolean,
iconSize: [Number, String], iconSize: [Number, String],
direction: String, direction: String,
modelValue: UnknownProp, modelValue: unknownProp,
checkedColor: String, checkedColor: String,
}; };

View File

@ -1,7 +1,7 @@
import { computed, defineComponent } from 'vue'; import { computed, defineComponent } from 'vue';
// Utils // Utils
import { addUnit, createNamespace, preventDefault } from '../utils'; import { addUnit, truthProp, createNamespace, preventDefault } from '../utils';
// Composables // Composables
import { useRefs } from '../composables/use-refs'; import { useRefs } from '../composables/use-refs';
@ -40,6 +40,7 @@ export default defineComponent({
disabled: Boolean, disabled: Boolean,
allowHalf: Boolean, allowHalf: Boolean,
voidColor: String, voidColor: String,
touchable: truthProp,
iconPrefix: String, iconPrefix: String,
disabledColor: String, disabledColor: String,
modelValue: { modelValue: {
@ -58,10 +59,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: 5, default: 5,
}, },
touchable: {
type: Boolean,
default: true,
},
}, },
emits: ['change', 'update:modelValue'], emits: ['change', 'update:modelValue'],

View File

@ -1,5 +1,5 @@
import { computed, PropType, ComputedRef, defineComponent } from 'vue'; import { computed, PropType, ComputedRef, defineComponent } from 'vue';
import { createNamespace, ComponentInstance } from '../utils'; import { truthProp, createNamespace, ComponentInstance } from '../utils';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
const [name, bem] = createNamespace('row'); const [name, bem] = createNamespace('row');
@ -25,16 +25,13 @@ export default defineComponent({
name, name,
props: { props: {
wrap: truthProp,
align: String as PropType<RowAlign>, align: String as PropType<RowAlign>,
justify: String as PropType<RowJustify>, justify: String as PropType<RowJustify>,
tag: { tag: {
type: String as PropType<keyof HTMLElementTagNameMap>, type: String as PropType<keyof HTMLElementTagNameMap>,
default: 'div', default: 'div',
}, },
wrap: {
type: Boolean,
default: true,
},
gutter: { gutter: {
type: [Number, String], type: [Number, String],
default: 0, default: 0,

View File

@ -4,6 +4,7 @@ import { ref, PropType, defineComponent } from 'vue';
import { import {
pick, pick,
extend, extend,
truthProp,
createNamespace, createNamespace,
preventDefault, preventDefault,
ComponentInstance, ComponentInstance,
@ -25,6 +26,7 @@ export default defineComponent({
props: extend({}, fieldProps, { props: extend({}, fieldProps, {
label: String, label: String,
clearable: truthProp,
actionText: String, actionText: String,
background: String, background: String,
showAction: Boolean, showAction: Boolean,
@ -32,10 +34,6 @@ export default defineComponent({
type: String as PropType<SearchShape>, type: String as PropType<SearchShape>,
default: 'square', default: 'square',
}, },
clearable: {
type: Boolean,
default: true,
},
leftIcon: { leftIcon: {
type: String, type: String,
default: 'search', default: 'search',

View File

@ -1,7 +1,7 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
// Utils // Utils
import { createNamespace, extend, pick } from '../utils'; import { truthProp, createNamespace, extend, pick } from '../utils';
import { popupSharedProps, popupSharedPropKeys } from '../popup/shared'; import { popupSharedProps, popupSharedPropKeys } from '../popup/shared';
// Components // Components
@ -49,18 +49,12 @@ export default defineComponent({
title: String, title: String,
cancelText: String, cancelText: String,
description: String, description: String,
closeOnPopstate: truthProp,
safeAreaInsetBottom: truthProp,
options: { options: {
type: Array as PropType<ShareSheetOptions>, type: Array as PropType<ShareSheetOptions>,
default: () => [], default: () => [],
}, },
closeOnPopstate: {
type: Boolean,
default: true,
},
safeAreaInsetBottom: {
type: Boolean,
default: true,
},
}), }),
emits: ['cancel', 'select', 'update:show'], emits: ['cancel', 'select', 'update:show'],

View File

@ -1,5 +1,5 @@
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { createNamespace, addUnit, getSizeStyle } from '../utils'; import { addUnit, truthProp, getSizeStyle, createNamespace } from '../utils';
const [name, bem] = createNamespace('skeleton'); const [name, bem] = createNamespace('skeleton');
const DEFAULT_ROW_WIDTH = '100%'; const DEFAULT_ROW_WIDTH = '100%';
@ -12,20 +12,14 @@ export default defineComponent({
title: Boolean, title: Boolean,
round: Boolean, round: Boolean,
avatar: Boolean, avatar: Boolean,
loading: truthProp,
animate: truthProp,
avatarSize: [Number, String], avatarSize: [Number, String],
titleWidth: [Number, String], titleWidth: [Number, String],
row: { row: {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
loading: {
type: Boolean,
default: true,
},
animate: {
type: Boolean,
default: true,
},
avatarShape: { avatarShape: {
type: String as PropType<'square' | 'round'>, type: String as PropType<'square' | 'round'>,
default: 'round', default: 'round',

View File

@ -4,6 +4,7 @@ import { ref, watch, computed, PropType, defineComponent } from 'vue';
import { import {
isDef, isDef,
addUnit, addUnit,
truthProp,
resetScroll, resetScroll,
formatNumber, formatNumber,
getSizeStyle, getSizeStyle,
@ -39,6 +40,10 @@ export default defineComponent({
theme: String as PropType<StepperTheme>, theme: String as PropType<StepperTheme>,
integer: Boolean, integer: Boolean,
disabled: Boolean, disabled: Boolean,
showPlus: truthProp,
showMinus: truthProp,
showInput: truthProp,
longPress: truthProp,
allowEmpty: Boolean, allowEmpty: Boolean,
modelValue: [Number, String], modelValue: [Number, String],
inputWidth: [Number, String], inputWidth: [Number, String],
@ -69,22 +74,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: 1, default: 1,
}, },
showPlus: {
type: Boolean,
default: true,
},
showMinus: {
type: Boolean,
default: true,
},
showInput: {
type: Boolean,
default: true,
},
longPress: {
type: Boolean,
default: true,
},
}, },
emits: [ emits: [

View File

@ -1,5 +1,5 @@
import { PropType, CSSProperties, defineComponent } from 'vue'; import { PropType, CSSProperties, defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
// Components // Components
import { Icon } from '../icon'; import { Icon } from '../icon';
@ -21,10 +21,7 @@ export default defineComponent({
buttonText: String, buttonText: String,
buttonColor: String, buttonColor: String,
suffixLabel: String, suffixLabel: String,
safeAreaInsetBottom: { safeAreaInsetBottom: truthProp,
type: Boolean,
default: true,
},
decimalLength: { decimalLength: {
type: [Number, String], type: [Number, String],
default: 2, default: 2,

View File

@ -17,6 +17,7 @@ import {
import { import {
range, range,
isHidden, isHidden,
truthProp,
preventDefault, preventDefault,
createNamespace, createNamespace,
ComponentInstance, ComponentInstance,
@ -37,15 +38,15 @@ const [name, bem] = createNamespace('swipe');
export const SWIPE_KEY = Symbol(name); export const SWIPE_KEY = Symbol(name);
const props = { const props = {
loop: truthProp,
width: [Number, String], width: [Number, String],
height: [Number, String], height: [Number, String],
vertical: Boolean, vertical: Boolean,
touchable: truthProp,
lazyRender: Boolean, lazyRender: Boolean,
indicatorColor: String, indicatorColor: String,
loop: { showIndicators: truthProp,
type: Boolean, stopPropagation: truthProp,
default: true,
},
autoplay: { autoplay: {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
@ -54,22 +55,10 @@ const props = {
type: [Number, String], type: [Number, String],
default: 500, default: 500,
}, },
touchable: {
type: Boolean,
default: true,
},
initialSwipe: { initialSwipe: {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
showIndicators: {
type: Boolean,
default: true,
},
stopPropagation: {
type: Boolean,
default: true,
},
}; };
export type SwipeToOptions = { export type SwipeToOptions = {

View File

@ -1,5 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { createNamespace, addUnit, UnknownProp } from '../utils'; import { createNamespace, addUnit, unknownProp } from '../utils';
import { useLinkField } from '../composables/use-link-field'; import { useLinkField } from '../composables/use-link-field';
import { Loading } from '../loading'; import { Loading } from '../loading';
@ -12,15 +12,15 @@ export default defineComponent({
size: [Number, String], size: [Number, String],
loading: Boolean, loading: Boolean,
disabled: Boolean, disabled: Boolean,
modelValue: UnknownProp, modelValue: unknownProp,
activeColor: String, activeColor: String,
inactiveColor: String, inactiveColor: String,
activeValue: { activeValue: {
type: UnknownProp, type: unknownProp,
default: true as unknown, default: true as unknown,
}, },
inactiveValue: { inactiveValue: {
type: UnknownProp, type: unknownProp,
default: false as unknown, default: false as unknown,
}, },
}, },

View File

@ -8,7 +8,7 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { createNamespace, extend, UnknownProp } from '../utils'; import { createNamespace, extend, unknownProp } from '../utils';
import { TABS_KEY, TabsProvide } from '../tabs/Tabs'; import { TABS_KEY, TabsProvide } from '../tabs/Tabs';
// Composables // Composables
@ -29,7 +29,7 @@ export default defineComponent({
badge: [Number, String], badge: [Number, String],
title: String, title: String,
disabled: Boolean, disabled: Boolean,
titleClass: UnknownProp, titleClass: unknownProp,
titleStyle: [String, Object] as PropType<string | CSSProperties>, titleStyle: [String, Object] as PropType<string | CSSProperties>,
}), }),

View File

@ -1,7 +1,7 @@
import { ref, PropType, defineComponent, ExtractPropTypes } from 'vue'; import { ref, PropType, defineComponent, ExtractPropTypes } from 'vue';
// Utils // Utils
import { createNamespace, getZIndexStyle } from '../utils'; import { truthProp, createNamespace, getZIndexStyle } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant'; import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { callInterceptor, Interceptor } from '../utils/interceptor'; import { callInterceptor, Interceptor } from '../utils/interceptor';
@ -15,6 +15,8 @@ export const TABBAR_KEY = Symbol(name);
const props = { const props = {
route: Boolean, route: Boolean,
fixed: truthProp,
border: truthProp,
zIndex: [Number, String], zIndex: [Number, String],
placeholder: Boolean, placeholder: Boolean,
activeColor: String, activeColor: String,
@ -24,14 +26,6 @@ const props = {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
border: {
type: Boolean,
default: true,
},
fixed: {
type: Boolean,
default: true,
},
safeAreaInsetBottom: { safeAreaInsetBottom: {
type: Boolean as PropType<boolean | null>, type: Boolean as PropType<boolean | null>,
default: null, default: null,

View File

@ -9,8 +9,8 @@ import {
onActivated, onActivated,
CSSProperties, CSSProperties,
defineComponent, defineComponent,
ComponentPublicInstance,
ExtractPropTypes, ExtractPropTypes,
ComponentPublicInstance,
} from 'vue'; } from 'vue';
// Utils // Utils
@ -19,6 +19,7 @@ import {
addUnit, addUnit,
isHidden, isHidden,
unitToPx, unitToPx,
truthProp,
getVisibleTop, getVisibleTop,
getElementTop, getElementTop,
createNamespace, createNamespace,
@ -58,9 +59,11 @@ const props = {
border: Boolean, border: Boolean,
sticky: Boolean, sticky: Boolean,
animated: Boolean, animated: Boolean,
ellipsis: truthProp,
swipeable: Boolean, swipeable: Boolean,
scrollspy: Boolean, scrollspy: Boolean,
background: String, background: String,
lazyRender: truthProp,
lineWidth: [Number, String], lineWidth: [Number, String],
lineHeight: [Number, String], lineHeight: [Number, String],
beforeChange: Function as PropType<Interceptor>, beforeChange: Function as PropType<Interceptor>,
@ -74,10 +77,6 @@ const props = {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
ellipsis: {
type: Boolean,
default: true,
},
duration: { duration: {
type: [Number, String], type: [Number, String],
default: 0.3, default: 0.3,
@ -86,10 +85,6 @@ const props = {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
}, },
lazyRender: {
type: Boolean,
default: true,
},
swipeThreshold: { swipeThreshold: {
type: [Number, String], type: [Number, String],
default: 5, default: 5,

View File

@ -1,5 +1,5 @@
import { CSSProperties, PropType, Transition, defineComponent } from 'vue'; import { CSSProperties, PropType, Transition, defineComponent } from 'vue';
import { createNamespace } from '../utils'; import { truthProp, createNamespace } from '../utils';
import { Icon } from '../icon'; import { Icon } from '../icon';
const [name, bem] = createNamespace('tag'); const [name, bem] = createNamespace('tag');
@ -12,6 +12,7 @@ export default defineComponent({
props: { props: {
size: String, size: String,
mark: Boolean, mark: Boolean,
show: truthProp,
color: String, color: String,
plain: Boolean, plain: Boolean,
round: Boolean, round: Boolean,
@ -21,10 +22,6 @@ export default defineComponent({
type: String as PropType<TagType>, type: String as PropType<TagType>,
default: 'default', default: 'default',
}, },
show: {
type: Boolean,
default: true,
},
}, },
emits: ['close'], emits: ['close'],

View File

@ -8,7 +8,7 @@ import {
} from 'vue'; } from 'vue';
// Utils // Utils
import { createNamespace, isDef, UnknownProp } from '../utils'; import { createNamespace, isDef, unknownProp } from '../utils';
import { lockClick } from './lock-click'; import { lockClick } from './lock-click';
// Components // Components
@ -30,11 +30,11 @@ export default defineComponent({
overlay: Boolean, overlay: Boolean,
message: [Number, String], message: [Number, String],
iconSize: [Number, String], iconSize: [Number, String],
className: UnknownProp, className: unknownProp,
iconPrefix: String, iconPrefix: String,
loadingType: String as PropType<LoadingType>, loadingType: String as PropType<LoadingType>,
forbidClick: Boolean, forbidClick: Boolean,
overlayClass: UnknownProp, overlayClass: unknownProp,
overlayStyle: Object as PropType<CSSProperties>, overlayStyle: Object as PropType<CSSProperties>,
closeOnClick: Boolean, closeOnClick: Boolean,
closeOnClickOverlay: Boolean, closeOnClickOverlay: Boolean,

View File

@ -5,6 +5,7 @@ import {
pick, pick,
extend, extend,
isPromise, isPromise,
truthProp,
getSizeStyle, getSizeStyle,
ComponentInstance, ComponentInstance,
} from '../utils'; } from '../utils';
@ -60,11 +61,15 @@ export default defineComponent({
disabled: Boolean, disabled: Boolean,
lazyLoad: Boolean, lazyLoad: Boolean,
uploadText: String, uploadText: String,
deletable: truthProp,
afterRead: Function as PropType<UploaderAfterRead>, afterRead: Function as PropType<UploaderAfterRead>,
showUpload: truthProp,
beforeRead: Function as PropType<UploaderBeforeRead>, beforeRead: Function as PropType<UploaderBeforeRead>,
beforeDelete: Function as PropType<Interceptor>, beforeDelete: Function as PropType<Interceptor>,
previewSize: [Number, String], previewSize: [Number, String],
previewImage: truthProp,
previewOptions: Object as PropType<ImagePreviewOptions>, previewOptions: Object as PropType<ImagePreviewOptions>,
previewFullImage: truthProp,
name: { name: {
type: [Number, String], type: [Number, String],
default: '', default: '',
@ -85,22 +90,6 @@ export default defineComponent({
type: [Number, String], type: [Number, String],
default: Number.MAX_VALUE, default: Number.MAX_VALUE,
}, },
deletable: {
type: Boolean,
default: true,
},
showUpload: {
type: Boolean,
default: true,
},
previewImage: {
type: Boolean,
default: true,
},
previewFullImage: {
type: Boolean,
default: true,
},
imageFit: { imageFit: {
type: String as PropType<ImageFit>, type: String as PropType<ImageFit>,
default: 'cover', default: 'cover',

View File

@ -12,7 +12,7 @@ import { Loading } from '../loading';
export default defineComponent({ export default defineComponent({
props: { props: {
name: [String, Number], name: [Number, String],
index: Number, index: Number,
imageFit: String as PropType<ImageFit>, imageFit: String as PropType<ImageFit>,
lazyLoad: Boolean, lazyLoad: Boolean,

View File

@ -6,8 +6,12 @@ export const extend = Object.assign;
export const inBrowser = typeof window !== 'undefined'; export const inBrowser = typeof window !== 'undefined';
// unknown type for Vue prop // PropTypes
export const UnknownProp = (null as unknown) as PropType<unknown>; export const unknownProp = (null as unknown) as PropType<unknown>;
export const truthProp = {
type: Boolean,
default: true as const,
};
// eslint-disable-next-line // eslint-disable-next-line
export type ComponentInstance = ComponentPublicInstance<{}, any>; export type ComponentInstance = ComponentPublicInstance<{}, any>;