chore: add Numeric type

This commit is contained in:
chenjiahan 2022-03-27 17:40:00 +08:00
parent dbad7571ac
commit 8dc8c54bca
126 changed files with 238 additions and 194 deletions

View File

@ -0,0 +1,5 @@
export { useTranslate, initDemoLocale } from './use-translate';
/** Generate the CDN URL of assets. */
export const cdnURL = (path: string) =>
`https://cdn.jsdelivr.net/npm/@vant/assets/${path}`;

View File

@ -104,7 +104,3 @@ export function useTranslate(i18n: Record<string, any>) {
return createTranslate(demoName); return createTranslate(demoName);
} }
/** Generate the CDN URL of assets. */
export const cdnURL = (path: string) =>
`https://cdn.jsdelivr.net/npm/@vant/assets/${path}`;

View File

@ -2,7 +2,7 @@
import VanActionBar from '..'; import VanActionBar from '..';
import VanActionBarIcon from '../../action-bar-icon'; import VanActionBarIcon from '../../action-bar-icon';
import VanActionBarButton from '../../action-bar-button'; import VanActionBarButton from '../../action-bar-button';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanActionSheet, { ActionSheetAction } from '..'; import VanActionSheet, { ActionSheetAction } from '..';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanAddressEdit from '..'; import VanAddressEdit from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { areaList } from '@vant/area-data'; import { areaList } from '@vant/area-data';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,7 +1,12 @@
import { defineComponent, type PropType } from 'vue'; import { defineComponent, type PropType } from 'vue';
// Utils // Utils
import { createNamespace, extend, makeRequiredProp } from '../utils'; import {
extend,
createNamespace,
makeRequiredProp,
type Numeric,
} from '../utils';
// Components // Components
import { Tag } from '../tag'; import { Tag } from '../tag';
@ -12,8 +17,8 @@ import { Radio } from '../radio';
const [name, bem] = createNamespace('address-item'); const [name, bem] = createNamespace('address-item');
export type AddressListAddress = { export type AddressListAddress = {
id: number | string; id: Numeric;
tel: number | string; tel: Numeric;
name: string; name: string;
address: string; address: string;
isDefault?: boolean; isDefault?: boolean;

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanAddressList from '..'; import VanAddressList from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -3,7 +3,7 @@ import VanArea from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { areaList } from '@vant/area-data'; import { areaList } from '@vant/area-data';
import { areaListEn } from './area-en'; import { areaListEn } from './area-en';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -13,6 +13,7 @@ import {
numericProp, numericProp,
makeStringProp, makeStringProp,
createNamespace, createNamespace,
type Numeric,
} from '../utils'; } from '../utils';
const [name, bem] = createNamespace('badge'); const [name, bem] = createNamespace('badge');
@ -28,7 +29,7 @@ const badgeProps = {
max: numericProp, max: numericProp,
tag: makeStringProp<keyof HTMLElementTagNameMap>('div'), tag: makeStringProp<keyof HTMLElementTagNameMap>('div'),
color: String, color: String,
offset: Array as unknown as PropType<[string | number, string | number]>, offset: Array as unknown as PropType<[Numeric, Numeric]>,
content: numericProp, content: numericProp,
showZero: truthProp, showZero: truthProp,
position: makeStringProp<BadgePosition>('top-right'), position: makeStringProp<BadgePosition>('top-right'),

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanBadge from '..'; import VanBadge from '..';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import VanButton from '..'; import VanButton from '..';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import VanCalendar from '..'; import VanCalendar from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const minDate = new Date(2012, 0, 10); const minDate = new Date(2012, 0, 10);
const maxDate = new Date(2012, 2, 20); const maxDate = new Date(2012, 2, 20);

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanCalendar from '..'; import VanCalendar from '..';
import { reactive } from 'vue'; import { reactive } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import TiledDisplay from './TiledDisplay.vue'; import TiledDisplay from './TiledDisplay.vue';
import type { CalendarDayItem } from '../types'; import type { CalendarDayItem } from '../types';

View File

@ -1,4 +1,5 @@
import type { ComponentPublicInstance, ComputedRef, Ref } from 'vue'; import type { ComponentPublicInstance, ComputedRef, Ref } from 'vue';
import type { Numeric } from '../utils';
import type { CalendarProps } from './Calendar'; import type { CalendarProps } from './Calendar';
import type { CalendarMonthProps } from './CalendarMonth'; import type { CalendarMonthProps } from './CalendarMonth';
@ -18,7 +19,7 @@ export type CalendarDayType =
export type CalendarDayItem = { export type CalendarDayItem = {
date?: Date; date?: Date;
text?: string | number; text?: Numeric;
type?: CalendarDayType; type?: CalendarDayType;
topInfo?: string; topInfo?: string;
className?: unknown; className?: unknown;

View File

@ -2,7 +2,7 @@
import VanCard from '..'; import VanCard from '..';
import VanTag from '../../tag'; import VanTag from '../../tag';
import VanButton from '../../button'; import VanButton from '../../button';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -14,6 +14,7 @@ import {
makeStringProp, makeStringProp,
createNamespace, createNamespace,
HAPTICS_FEEDBACK, HAPTICS_FEEDBACK,
type Numeric,
} from '../utils'; } from '../utils';
// Components // Components
@ -68,7 +69,7 @@ export default defineComponent({
const getSelectedOptionsByValue = ( const getSelectedOptionsByValue = (
options: CascaderOption[], options: CascaderOption[],
value: string | number value: Numeric
): CascaderOption[] | undefined => { ): CascaderOption[] | undefined => {
for (const option of options) { for (const option of options) {
if (option[valueKey] === value) { if (option[valueKey] === value) {

View File

@ -3,10 +3,11 @@ import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import VanCascader, { CascaderOption } from '..'; import VanCascader, { CascaderOption } from '..';
import { computed, reactive } from 'vue'; import { computed, reactive } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { deepClone } from '../../utils/deep-clone'; import { deepClone } from '../../utils/deep-clone';
import zhCNOptions from './area-zh-CN'; import zhCNOptions from './area-zh-CN';
import enUSOptions from './area-en-US'; import enUSOptions from './area-en-US';
import type { Numeric } from '../../utils';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {
@ -55,7 +56,7 @@ const t = useTranslate({
type StateItem = { type StateItem = {
show: boolean; show: boolean;
value: string | number | undefined; value: Numeric | undefined;
result: string; result: string;
options?: CascaderOption[]; options?: CascaderOption[];
tabIndex?: number; tabIndex?: number;
@ -129,7 +130,7 @@ const onFinish = (
{ {
value, value,
selectedOptions, selectedOptions,
}: { value: number | string; selectedOptions: CascaderOption[] } }: { value: Numeric; selectedOptions: CascaderOption[] }
) => { ) => {
const result = selectedOptions const result = selectedOptions
.map((option) => option.text || option.name) .map((option) => option.text || option.name)

View File

@ -1,6 +1,8 @@
import type { Numeric } from '../utils';
export type CascaderOption = { export type CascaderOption = {
text?: string; text?: string;
value?: string | number; value?: Numeric;
color?: string; color?: string;
disabled?: boolean; disabled?: boolean;
children?: CascaderOption[]; children?: CascaderOption[];

View File

@ -3,7 +3,7 @@ import VanCellGroup from '../../cell-group';
import VanCell from '..'; import VanCell from '..';
import VanTag from '../../tag'; import VanTag from '../../tag';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -7,6 +7,7 @@ import {
unknownProp, unknownProp,
makeStringProp, makeStringProp,
makeRequiredProp, makeRequiredProp,
type Numeric,
} from '../utils'; } from '../utils';
import { Icon } from '../icon'; import { Icon } from '../icon';
@ -16,7 +17,7 @@ export type CheckerLabelPosition = 'left' | 'right';
export type CheckerParent = { export type CheckerParent = {
props: { props: {
disabled?: boolean; disabled?: boolean;
iconSize?: number | string; iconSize?: Numeric;
direction?: CheckerDirection; direction?: CheckerDirection;
checkedColor?: string; checkedColor?: string;
}; };

View File

@ -5,7 +5,7 @@ import VanButton from '../../button';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import VanCell from '../../cell'; import VanCell from '../../cell';
import { ref, reactive } from 'vue'; import { ref, reactive } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import { useRefs } from '../../composables/use-refs'; import { useRefs } from '../../composables/use-refs';
import type { CheckboxInstance } from '../types'; import type { CheckboxInstance } from '../types';
import type { CheckboxGroupInstance } from '../../checkbox-group'; import type { CheckboxGroupInstance } from '../../checkbox-group';

View File

@ -16,13 +16,14 @@ import {
makeNumberProp, makeNumberProp,
makeNumericProp, makeNumericProp,
createNamespace, createNamespace,
type Numeric,
} from '../utils'; } from '../utils';
const [name, bem] = createNamespace('circle'); const [name, bem] = createNamespace('circle');
let uid = 0; let uid = 0;
const format = (rate: string | number) => Math.min(Math.max(+rate, 0), 100); const format = (rate: Numeric) => Math.min(Math.max(+rate, 0), 100);
function getPath(clockwise: boolean, viewBoxSize: number) { function getPath(clockwise: boolean, viewBoxSize: number) {
const sweepFlag = clockwise ? 1 : 0; const sweepFlag = clockwise ? 1 : 0;

View File

@ -2,7 +2,7 @@
import VanCircle from '..'; import VanCircle from '..';
import VanButton from '../../button'; import VanButton from '../../button';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanRow from '../../row'; import VanRow from '../../row';
import VanCol from '..'; import VanCol from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -4,14 +4,19 @@ import {
type InjectionKey, type InjectionKey,
type ExtractPropTypes, type ExtractPropTypes,
} from 'vue'; } from 'vue';
import { truthProp, createNamespace, BORDER_TOP_BOTTOM } from '../utils'; import {
truthProp,
createNamespace,
BORDER_TOP_BOTTOM,
type Numeric,
} from '../utils';
import { useChildren } from '@vant/use'; import { useChildren } from '@vant/use';
const [name, bem] = createNamespace('collapse'); const [name, bem] = createNamespace('collapse');
export type CollapseProvide = { export type CollapseProvide = {
toggle: (name: number | string, expanded: boolean) => void; toggle: (name: Numeric, expanded: boolean) => void;
isExpanded: (name: number | string) => boolean; isExpanded: (name: Numeric) => boolean;
}; };
export const COLLAPSE_KEY: InjectionKey<CollapseProvide> = Symbol(name); export const COLLAPSE_KEY: InjectionKey<CollapseProvide> = Symbol(name);
@ -20,9 +25,7 @@ const collapseProps = {
border: truthProp, border: truthProp,
accordion: Boolean, accordion: Boolean,
modelValue: { modelValue: {
type: [String, Number, Array] as PropType< type: [String, Number, Array] as PropType<Numeric | Numeric[]>,
string | number | Array<string | number>
>,
default: '', default: '',
}, },
}; };
@ -30,7 +33,7 @@ const collapseProps = {
export type CollapseProps = ExtractPropTypes<typeof collapseProps>; export type CollapseProps = ExtractPropTypes<typeof collapseProps>;
function validateModelValue( function validateModelValue(
modelValue: string | number | Array<string | number>, modelValue: Numeric | Numeric[],
accordion: boolean accordion: boolean
) { ) {
if (accordion && Array.isArray(modelValue)) { if (accordion && Array.isArray(modelValue)) {
@ -58,28 +61,26 @@ export default defineComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const { linkChildren } = useChildren(COLLAPSE_KEY); const { linkChildren } = useChildren(COLLAPSE_KEY);
const updateName = (name: number | string | Array<number | string>) => { const updateName = (name: Numeric | Numeric[]) => {
emit('change', name); emit('change', name);
emit('update:modelValue', name); emit('update:modelValue', name);
}; };
const toggle = (name: number | string, expanded: boolean) => { const toggle = (name: Numeric, expanded: boolean) => {
const { accordion, modelValue } = props; const { accordion, modelValue } = props;
if (accordion) { if (accordion) {
updateName(name === modelValue ? '' : name); updateName(name === modelValue ? '' : name);
} else if (expanded) { } else if (expanded) {
updateName((modelValue as Array<number | string>).concat(name)); updateName((modelValue as Numeric[]).concat(name));
} else { } else {
updateName( updateName(
(modelValue as Array<number | string>).filter( (modelValue as Numeric[]).filter((activeName) => activeName !== name)
(activeName) => activeName !== name
)
); );
} }
}; };
const isExpanded = (name: number | string) => { const isExpanded = (name: Numeric) => {
const { accordion, modelValue } = props; const { accordion, modelValue } = props;
if ( if (
@ -91,7 +92,7 @@ export default defineComponent({
return accordion return accordion
? modelValue === name ? modelValue === name
: (modelValue as Array<number | string>).includes(name); : (modelValue as Numeric[]).includes(name);
}; };
linkChildren({ toggle, isExpanded }); linkChildren({ toggle, isExpanded });

View File

@ -3,7 +3,7 @@ import VanCollapse from '..';
import VanCollapseItem from '../../collapse-item'; import VanCollapseItem from '../../collapse-item';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -7,7 +7,12 @@ import {
type CSSProperties, type CSSProperties,
type ExtractPropTypes, type ExtractPropTypes,
} from 'vue'; } from 'vue';
import { kebabCase, makeStringProp, createNamespace } from '../utils'; import {
kebabCase,
makeStringProp,
createNamespace,
type Numeric,
} from '../utils';
const [name, bem] = createNamespace('config-provider'); const [name, bem] = createNamespace('config-provider');
@ -20,14 +25,14 @@ export const CONFIG_PROVIDER_KEY: InjectionKey<ConfigProviderProvide> =
const configProviderProps = { const configProviderProps = {
tag: makeStringProp<keyof HTMLElementTagNameMap>('div'), tag: makeStringProp<keyof HTMLElementTagNameMap>('div'),
themeVars: Object as PropType<Record<string, string | number>>, themeVars: Object as PropType<Record<string, Numeric>>,
iconPrefix: String, iconPrefix: String,
}; };
export type ConfigProviderProps = ExtractPropTypes<typeof configProviderProps>; export type ConfigProviderProps = ExtractPropTypes<typeof configProviderProps>;
function mapThemeVarsToCSSVars(themeVars: Record<string, string | number>) { function mapThemeVarsToCSSVars(themeVars: Record<string, Numeric>) {
const cssVars: Record<string, string | number> = {}; const cssVars: Record<string, Numeric> = {};
Object.keys(themeVars).forEach((key) => { Object.keys(themeVars).forEach((key) => {
cssVars[`--van-${kebabCase(key)}`] = themeVars[key]; cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
}); });

View File

@ -6,7 +6,7 @@ import VanSlider from '../../slider';
import VanButton from '../../button'; import VanButton from '../../button';
import VanConfigProvider from '..'; import VanConfigProvider from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanContactCard from '..'; import VanContactCard from '..';
import { computed } from 'vue'; import { computed } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import VanContactEdit, { type ContactEditInfo } from '..'; import VanContactEdit, { type ContactEditInfo } from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,7 +1,7 @@
import { defineComponent, type PropType, type ExtractPropTypes } from 'vue'; import { defineComponent, type PropType, type ExtractPropTypes } from 'vue';
// Utils // Utils
import { createNamespace, unknownProp } from '../utils'; import { createNamespace, unknownProp, type Numeric } from '../utils';
// Components // Components
import { Tag } from '../tag'; import { Tag } from '../tag';
@ -14,8 +14,8 @@ import { RadioGroup } from '../radio-group';
const [name, bem, t] = createNamespace('contact-list'); const [name, bem, t] = createNamespace('contact-list');
export type ContactListItem = { export type ContactListItem = {
id?: number | string; id?: Numeric;
tel: number | string; tel: Numeric;
name: string; name: string;
isDefault?: boolean; isDefault?: boolean;
}; };

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanContactList from '..'; import VanContactList from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -3,7 +3,7 @@ import VanGrid from '../../grid';
import VanGridItem from '../../grid-item'; import VanGridItem from '../../grid-item';
import VanCountDown, { type CountDownInstance } from '..'; import VanCountDown, { type CountDownInstance } from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -3,7 +3,7 @@ import VanCouponCell from '../../coupon-cell';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import VanCouponList from '..'; import VanCouponList from '..';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { CouponInfo } from '../../coupon'; import { CouponInfo } from '../../coupon';
import { Toast } from '../../toast'; import { Toast } from '../../toast';

View File

@ -1,6 +1,6 @@
import { later, mount } from '../../../test'; import { later, mount } from '../../../test';
import { CouponList } from '..'; import { CouponList } from '..';
import { cdnURL } from '../../../docs/site/use-translate'; import { cdnURL } from '../../../docs/site';
const coupon = { const coupon = {
id: 1, id: 1,

View File

@ -1,10 +1,15 @@
import { computed, defineComponent, type PropType } from 'vue'; import { computed, defineComponent, type PropType } from 'vue';
import { makeStringProp, createNamespace, makeRequiredProp } from '../utils'; import {
makeStringProp,
createNamespace,
makeRequiredProp,
type Numeric,
} from '../utils';
import { getDate, formatAmount, formatDiscount } from './utils'; import { getDate, formatAmount, formatDiscount } from './utils';
import { Checkbox } from '../checkbox'; import { Checkbox } from '../checkbox';
export type CouponInfo = { export type CouponInfo = {
id: string | number; id: Numeric;
name: string; name: string;
endAt: number; endAt: number;
value: number; value: number;

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanDatetimePicker from '..'; import VanDatetimePicker from '..';
import { reactive } from 'vue'; import { reactive } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import { Dialog } from '..'; import { Dialog } from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import type { DialogAction } from '../types'; import type { DialogAction } from '../types';
const VanDialog = Dialog.Component; const VanDialog = Dialog.Component;

View File

@ -1,6 +1,6 @@
import { Dialog } from './function-call'; import { Dialog } from './function-call';
import type { CSSProperties, TeleportProps } from 'vue'; import type { CSSProperties, TeleportProps } from 'vue';
import type { Interceptor } from '../utils'; import type { Interceptor, Numeric } from '../utils';
export type DialogTheme = 'default' | 'round-button'; export type DialogTheme = 'default' | 'round-button';
export type DialogAction = 'confirm' | 'cancel'; export type DialogAction = 'confirm' | 'cancel';
@ -9,7 +9,7 @@ export type DialogMessageAlign = 'left' | 'center' | 'right';
export type DialogOptions = { export type DialogOptions = {
title?: string; title?: string;
width?: string | number; width?: Numeric;
theme?: DialogTheme; theme?: DialogTheme;
message?: DialogMessage; message?: DialogMessage;
overlay?: boolean; overlay?: boolean;

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import VanDivider from '..'; import VanDivider from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,10 +1,11 @@
import type { DropdownItemProps } from './DropdownItem'; import type { DropdownItemProps } from './DropdownItem';
import type { VNode, ComponentPublicInstance } from 'vue'; import type { VNode, ComponentPublicInstance } from 'vue';
import type { Numeric } from '../utils';
export type DropdownItemOption = { export type DropdownItemOption = {
text: string; text: string;
icon?: string; icon?: string;
value: number | string; value: Numeric;
}; };
export type DropdownItemExpose = { export type DropdownItemExpose = {

View File

@ -5,7 +5,7 @@ import VanCell from '../../cell';
import VanSwitch from '../../switch'; import VanSwitch from '../../switch';
import VanButton from '../../button'; import VanButton from '../../button';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import type { DropdownItemInstance } from '../../dropdown-item'; import type { DropdownItemInstance } from '../../dropdown-item';
const t = useTranslate({ const t = useTranslate({

View File

@ -4,7 +4,7 @@ import VanTabs from '../../tabs';
import VanTab from '../../tab'; import VanTab from '../../tab';
import VanButton from '../../button'; import VanButton from '../../button';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanField from '..';
import VanButton from '../../button'; import VanButton from '../../button';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanField from '..'; import VanField from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -4,7 +4,7 @@ import VanField from '../../field';
import VanButton from '../../button'; import VanButton from '../../button';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { FieldValidateError } from '../../field/types'; import { FieldValidateError } from '../../field/types';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import VanForm from '..'; import VanForm from '..';
import VanRate from '../../rate'; import VanRate from '../../rate';
import VanRadio from '../../radio'; import VanRadio from '../../radio';

View File

@ -4,7 +4,7 @@ import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import { ref } from 'vue'; import { ref } from 'vue';
import { areaList } from '@vant/area-data'; import { areaList } from '@vant/area-data';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { areaListEn } from '../../area/demo/area-en'; import { areaListEn } from '../../area/demo/area-en';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanField from '../../field'; import VanField from '../../field';
import VanCalendar from '../../calendar'; import VanCalendar from '../../calendar';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import VanDatetimePicker from '../../datetime-picker'; import VanDatetimePicker from '../../datetime-picker';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import VanPicker from '../../picker'; import VanPicker from '../../picker';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -4,7 +4,7 @@ import VanField from '../../field';
import VanButton from '../../button'; import VanButton from '../../button';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { FieldValidateError } from '../../field/types'; import { FieldValidateError } from '../../field/types';
import { Toast } from '../../toast'; import { Toast } from '../../toast';

View File

@ -2,7 +2,7 @@
import VanGrid from '..'; import VanGrid from '..';
import VanGridItem from '../../grid-item'; import VanGridItem from '../../grid-item';
import VanImage from '../../image'; import VanImage from '../../image';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -6,7 +6,7 @@ import VanRow from '../../row';
import VanCol from '../../col'; import VanCol from '../../col';
import icons from '@vant/icons'; import icons from '@vant/icons';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import { Notify } from '../../notify'; import { Notify } from '../../notify';
// from https://30secondsofcode.org // from https://30secondsofcode.org

View File

@ -1,6 +1,6 @@
import { Icon } from '..'; import { Icon } from '..';
import { mount } from '../../../test'; import { mount } from '../../../test';
import { cdnURL } from '../../../docs/site/use-translate'; import { cdnURL } from '../../../docs/site';
test('should render icon with builtin icon name correctly', () => { test('should render icon with builtin icon name correctly', () => {
const wrapper = mount(Icon, { const wrapper = mount(Icon, {

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import { ImagePreview, ImagePreviewOptions } from '..'; import { ImagePreview, ImagePreviewOptions } from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const VanImagePreview = ImagePreview.Component; const VanImagePreview = ImagePreview.Component;

View File

@ -1,5 +1,5 @@
import { DOMWrapper } from '@vue/test-utils/dist/domWrapper'; import { DOMWrapper } from '@vue/test-utils/dist/domWrapper';
import { cdnURL } from '../../../docs/site/use-translate'; import { cdnURL } from '../../../docs/site';
import { trigger } from '../../../test'; import { trigger } from '../../../test';
export const images = [ export const images = [

View File

@ -3,7 +3,7 @@ import VanRow from '../../row';
import VanImage from '..'; import VanImage from '..';
import VanCol from '../../col'; import VanCol from '../../col';
import VanLoading from '../../loading'; import VanLoading from '../../loading';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -25,6 +25,7 @@ import {
createNamespace, createNamespace,
getRootScrollTop, getRootScrollTop,
setRootScrollTop, setRootScrollTop,
type Numeric,
} from '../utils'; } from '../utils';
// Composables // Composables
@ -58,7 +59,7 @@ const indexBarProps = {
highlightColor: String, highlightColor: String,
stickyOffsetTop: makeNumberProp(0), stickyOffsetTop: makeNumberProp(0),
indexList: { indexList: {
type: Array as PropType<Array<string | number>>, type: Array as PropType<Numeric[]>,
default: genAlphabet, default: genAlphabet,
}, },
}; };
@ -76,7 +77,7 @@ export default defineComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const root = ref<HTMLElement>(); const root = ref<HTMLElement>();
const activeAnchor = ref<string | number>(''); const activeAnchor = ref<Numeric>('');
const touch = useTouch(); const touch = useTouch();
const scrollParent = useScrollParent(root); const scrollParent = useScrollParent(root);
@ -207,7 +208,7 @@ export default defineComponent({
); );
}); });
const scrollTo = (index: string | number) => { const scrollTo = (index: Numeric) => {
selectActiveIndex = String(index); selectActiveIndex = String(index);
const match = getMatchAnchor(selectActiveIndex); const match = getMatchAnchor(selectActiveIndex);

View File

@ -5,7 +5,7 @@ import VanIndexBar from '..';
import VanIndexAnchor from '../../index-anchor'; import VanIndexAnchor from '../../index-anchor';
import VanCell from '../../cell'; import VanCell from '../../cell';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,4 +1,5 @@
import type { ComponentPublicInstance } from 'vue'; import type { ComponentPublicInstance } from 'vue';
import type { Numeric } from '../utils';
import type { IndexBarProps } from './IndexBar'; import type { IndexBarProps } from './IndexBar';
export type IndexBarProvide = { export type IndexBarProvide = {
@ -6,7 +7,7 @@ export type IndexBarProvide = {
}; };
export type IndexBarExpose = { export type IndexBarExpose = {
scrollTo: (index: string | number) => void; scrollTo: (index: Numeric) => void;
}; };
export type IndexBarInstance = ComponentPublicInstance< export type IndexBarInstance = ComponentPublicInstance<

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import Lazyload from '..'; import Lazyload from '..';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
if (window.app) { if (window.app) {
window.app.use(Lazyload, { lazyComponent: true }); window.app.use(Lazyload, { lazyComponent: true });

View File

@ -5,7 +5,7 @@ import VanList from '..';
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanPullRefresh from '../../pull-refresh'; import VanPullRefresh from '../../pull-refresh';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import VanLoading from '..'; import VanLoading from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanNavBar from '..'; import VanNavBar from '..';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanNoticeBar from '..'; import VanNoticeBar from '..';
import VanSwipe from '../../swipe'; import VanSwipe from '../../swipe';
import VanSwipeItem from '../../swipe-item'; import VanSwipeItem from '../../swipe-item';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanCell from '../../cell';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { ref } from 'vue'; import { ref } from 'vue';
import { Notify, type NotifyType } from '..'; import { Notify, type NotifyType } from '..';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const VanNotify = Notify.Component; const VanNotify = Notify.Component;

View File

@ -1,6 +1,7 @@
import { Notify } from './function-call'; import { Notify } from './function-call';
import type { Numeric } from '../utils';
export type NotifyMessage = string | number; export type NotifyMessage = Numeric;
export type NotifyType = 'primary' | 'success' | 'danger' | 'warning'; export type NotifyType = 'primary' | 'success' | 'danger' | 'warning';

View File

@ -21,6 +21,7 @@ import {
stopPropagation, stopPropagation,
createNamespace, createNamespace,
HAPTICS_FEEDBACK, HAPTICS_FEEDBACK,
type Numeric,
} from '../utils'; } from '../utils';
// Composables // Composables
@ -34,7 +35,7 @@ const [name, bem] = createNamespace('number-keyboard');
export type NumberKeyboardTheme = 'default' | 'custom'; export type NumberKeyboardTheme = 'default' | 'custom';
type KeyConfig = { type KeyConfig = {
text?: number | string; text?: Numeric;
type?: KeyType; type?: KeyType;
color?: string; color?: string;
wider?: boolean; wider?: boolean;

View File

@ -3,7 +3,7 @@ import VanCell from '../../cell';
import VanField from '../../field'; import VanField from '../../field';
import VanNumberKeyboard from '..'; import VanNumberKeyboard from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanButton from '../../button'; import VanButton from '../../button';
import VanOverlay from '..'; import VanOverlay from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -11,19 +11,20 @@ import {
makeNumericProp, makeNumericProp,
createNamespace, createNamespace,
BORDER_SURROUND, BORDER_SURROUND,
type Numeric,
} from '../utils'; } from '../utils';
const [name, bem, t] = createNamespace('pagination'); const [name, bem, t] = createNamespace('pagination');
type PageItem = { type PageItem = {
text: string | number; text: Numeric;
number: number; number: number;
active?: boolean; active?: boolean;
}; };
const makePage = ( const makePage = (
number: number, number: number,
text: string | number, text: Numeric,
active?: boolean active?: boolean
): PageItem => ({ number, text, active }); ): PageItem => ({ number, text, active });

View File

@ -2,7 +2,7 @@
import VanPagination from '..'; import VanPagination from '..';
import VanIcon from '../../icon'; import VanIcon from '../../icon';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanPasswordInput from '..';
import VanNumberKeyboard from '../../number-keyboard'; import VanNumberKeyboard from '../../number-keyboard';
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import { ComponentInstance } from '../../utils'; import { ComponentInstance } from '../../utils';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -4,7 +4,7 @@ import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { dateColumns, cascadeColumns, cascadeColumnsCustomKey } from './data'; import { dateColumns, cascadeColumns, cascadeColumnsCustomKey } from './data';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,5 +1,6 @@
/* eslint-disable no-use-before-define */ /* eslint-disable no-use-before-define */
import type { ComponentPublicInstance } from 'vue'; import type { ComponentPublicInstance } from 'vue';
import type { Numeric } from '../utils';
import type { PickerProps } from './Picker'; import type { PickerProps } from './Picker';
export type PickerToolbarPosition = 'top' | 'bottom'; export type PickerToolbarPosition = 'top' | 'bottom';
@ -11,13 +12,13 @@ export type PickerFieldNames = {
}; };
export type PickerObjectOption = { export type PickerObjectOption = {
text?: string | number; text?: Numeric;
disabled?: boolean; disabled?: boolean;
// for custom filed names // for custom filed names
[key: PropertyKey]: any; [key: PropertyKey]: any;
}; };
export type PickerOption = string | number | PickerObjectOption; export type PickerOption = Numeric | PickerObjectOption;
export type PickerObjectColumn = { export type PickerObjectColumn = {
values?: PickerOption[]; values?: PickerOption[];

View File

@ -8,7 +8,7 @@ import VanPicker from '../../picker';
import VanGrid from '../../grid'; import VanGrid from '../../grid';
import VanGridItem from '../../grid-item'; import VanGridItem from '../../grid-item';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanPopup from '..'; import VanPopup from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,5 +1,11 @@
import { computed, defineComponent, type ExtractPropTypes } from 'vue'; import { computed, defineComponent, type ExtractPropTypes } from 'vue';
import { addUnit, truthProp, numericProp, createNamespace } from '../utils'; import {
addUnit,
truthProp,
numericProp,
createNamespace,
type Numeric,
} from '../utils';
const [name, bem] = createNamespace('progress'); const [name, bem] = createNamespace('progress');
@ -15,7 +21,7 @@ const progressProps = {
percentage: { percentage: {
type: numericProp, type: numericProp,
default: 0, default: 0,
validator: (value: number | string) => value >= 0 && value <= 100, validator: (value: Numeric) => value >= 0 && value <= 100,
}, },
}; };

View File

@ -2,7 +2,7 @@
import VanProgress from '..'; import VanProgress from '..';
import VanButton from '../../button'; import VanButton from '../../button';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -3,7 +3,7 @@ import VanTabs from '../../tabs';
import VanTab from '../../tab'; import VanTab from '../../tab';
import VanPullRefresh from '..'; import VanPullRefresh from '..';
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -4,7 +4,7 @@ import VanRadio from '..';
import VanCellGroup from '../../cell-group'; import VanCellGroup from '../../cell-group';
import VanCell from '../../cell'; import VanCell from '../../cell';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanRate from '..'; import VanRate from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanSearch from '..'; import VanSearch from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanShareSheet, { ShareSheetOption, ShareSheetOptions } from '..'; import VanShareSheet, { ShareSheetOption, ShareSheetOptions } from '..';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -4,7 +4,7 @@ import VanGridItem from '../../grid-item';
import VanSidebar from '..'; import VanSidebar from '..';
import VanSidebarItem from '../../sidebar-item'; import VanSidebarItem from '../../sidebar-item';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -7,6 +7,7 @@ import {
makeStringProp, makeStringProp,
makeNumericProp, makeNumericProp,
createNamespace, createNamespace,
type Numeric,
} from '../utils'; } from '../utils';
const [name, bem] = createNamespace('skeleton'); const [name, bem] = createNamespace('skeleton');
@ -26,9 +27,7 @@ const skeletonProps = {
titleWidth: numericProp, titleWidth: numericProp,
avatarShape: makeStringProp<SkeletonAvatarShape>('round'), avatarShape: makeStringProp<SkeletonAvatarShape>('round'),
rowWidth: { rowWidth: {
type: [Number, String, Array] as PropType< type: [Number, String, Array] as PropType<Numeric | Numeric[]>,
number | string | (number | string)[]
>,
default: DEFAULT_ROW_WIDTH, default: DEFAULT_ROW_WIDTH,
}, },
}; };

View File

@ -2,7 +2,7 @@
import VanSkeleton from '..'; import VanSkeleton from '..';
import VanSwitch from '../../switch'; import VanSwitch from '../../switch';
import { ref } from 'vue'; import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site/use-translate'; import { cdnURL, useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import VanSlider from '..'; import VanSlider from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -24,6 +24,7 @@ import {
callInterceptor, callInterceptor,
makeNumericProp, makeNumericProp,
HAPTICS_FEEDBACK, HAPTICS_FEEDBACK,
type Numeric,
} from '../utils'; } from '../utils';
// Composables // Composables
@ -34,7 +35,7 @@ const [name, bem] = createNamespace('stepper');
const LONG_PRESS_INTERVAL = 200; const LONG_PRESS_INTERVAL = 200;
const LONG_PRESS_START_TIME = 600; const LONG_PRESS_START_TIME = 600;
const isEqual = (value1?: string | number, value2?: string | number) => const isEqual = (value1?: Numeric, value2?: Numeric) =>
String(value1) === String(value2); String(value1) === String(value2);
export type StepperTheme = 'default' | 'round'; export type StepperTheme = 'default' | 'round';
@ -82,7 +83,7 @@ export default defineComponent({
], ],
setup(props, { emit }) { setup(props, { emit }) {
const format = (value: string | number) => { const format = (value: Numeric) => {
const { min, max, allowEmpty, decimalLength } = props; const { min, max, allowEmpty, decimalLength } = props;
if (allowEmpty && value === '') { if (allowEmpty && value === '') {
@ -139,7 +140,7 @@ export default defineComponent({
} }
}; };
const setValue = (value: string | number) => { const setValue = (value: Numeric) => {
if (props.beforeChange) { if (props.beforeChange) {
callInterceptor(props.beforeChange, { callInterceptor(props.beforeChange, {
args: [value], args: [value],

View File

@ -2,7 +2,7 @@
import VanCell from '../../cell'; import VanCell from '../../cell';
import VanStepper from '..'; import VanStepper from '..';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { Toast } from '../../toast';
const t = useTranslate({ const t = useTranslate({

View File

@ -3,7 +3,7 @@ import VanSteps from '..';
import VanStep from '../../step'; import VanStep from '../../step';
import VanButton from '../../button'; import VanButton from '../../button';
import { ref } from 'vue'; import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate'; import { useTranslate } from '../../../docs/site';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {

Some files were not shown because too many files have changed in this diff Show More