From 8dc8c54bca9086028ae2992d7475a07ccd615451 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 27 Mar 2022 17:40:00 +0800 Subject: [PATCH] chore: add Numeric type --- packages/vant/docs/site/index.ts | 5 +++ packages/vant/docs/site/use-translate.ts | 4 --- packages/vant/src/action-bar/demo/index.vue | 2 +- packages/vant/src/action-sheet/demo/index.vue | 2 +- packages/vant/src/address-edit/demo/index.vue | 2 +- .../vant/src/address-list/AddressListItem.tsx | 11 +++++-- packages/vant/src/address-list/demo/index.vue | 2 +- packages/vant/src/area/demo/index.vue | 2 +- packages/vant/src/badge/Badge.tsx | 3 +- packages/vant/src/badge/demo/index.vue | 2 +- packages/vant/src/button/demo/index.vue | 2 +- .../vant/src/calendar/demo/TiledDisplay.vue | 2 +- packages/vant/src/calendar/demo/index.vue | 2 +- packages/vant/src/calendar/types.ts | 3 +- packages/vant/src/card/demo/index.vue | 2 +- packages/vant/src/cascader/Cascader.tsx | 3 +- packages/vant/src/cascader/demo/index.vue | 7 +++-- packages/vant/src/cascader/types.ts | 4 ++- packages/vant/src/cell/demo/index.vue | 2 +- packages/vant/src/checkbox/Checker.tsx | 3 +- packages/vant/src/checkbox/demo/index.vue | 2 +- packages/vant/src/circle/Circle.tsx | 3 +- packages/vant/src/circle/demo/index.vue | 2 +- packages/vant/src/col/demo/index.vue | 2 +- packages/vant/src/collapse/Collapse.tsx | 31 ++++++++++--------- packages/vant/src/collapse/demo/index.vue | 2 +- .../src/config-provider/ConfigProvider.tsx | 13 +++++--- .../vant/src/config-provider/demo/index.vue | 2 +- packages/vant/src/contact-card/demo/index.vue | 2 +- packages/vant/src/contact-edit/demo/index.vue | 2 +- .../vant/src/contact-list/ContactList.tsx | 6 ++-- packages/vant/src/contact-list/demo/index.vue | 2 +- packages/vant/src/count-down/demo/index.vue | 2 +- packages/vant/src/coupon-list/demo/index.vue | 2 +- .../vant/src/coupon-list/test/index.spec.ts | 2 +- packages/vant/src/coupon/Coupon.tsx | 9 ++++-- .../vant/src/datetime-picker/demo/index.vue | 2 +- packages/vant/src/dialog/demo/index.vue | 2 +- packages/vant/src/dialog/types.ts | 4 +-- packages/vant/src/divider/demo/index.vue | 2 +- packages/vant/src/dropdown-item/types.ts | 3 +- .../vant/src/dropdown-menu/demo/index.vue | 2 +- packages/vant/src/empty/demo/index.vue | 2 +- packages/vant/src/field/demo/Autosize.vue | 2 +- packages/vant/src/field/demo/BasicUsage.vue | 2 +- packages/vant/src/field/demo/CustomType.vue | 2 +- packages/vant/src/field/demo/Disabled.vue | 2 +- packages/vant/src/field/demo/ErrorInfo.vue | 2 +- packages/vant/src/field/demo/FormatValue.vue | 2 +- packages/vant/src/field/demo/InputAlign.vue | 2 +- packages/vant/src/field/demo/InsertButton.vue | 2 +- packages/vant/src/field/demo/ShowIcon.vue | 2 +- .../vant/src/field/demo/ShowWordLimit.vue | 2 +- packages/vant/src/form/demo/BasicUsage.vue | 2 +- packages/vant/src/form/demo/FieldType.vue | 2 +- packages/vant/src/form/demo/FieldTypeArea.vue | 2 +- .../vant/src/form/demo/FieldTypeCalendar.vue | 2 +- .../src/form/demo/FieldTypeDatetimePicker.vue | 2 +- .../vant/src/form/demo/FieldTypePicker.vue | 2 +- packages/vant/src/form/demo/ValidateRules.vue | 2 +- packages/vant/src/grid/demo/index.vue | 2 +- packages/vant/src/icon/demo/index.vue | 2 +- packages/vant/src/icon/test/index.spec.ts | 2 +- .../vant/src/image-preview/demo/index.vue | 2 +- .../vant/src/image-preview/test/shared.ts | 2 +- packages/vant/src/image/demo/index.vue | 2 +- packages/vant/src/index-bar/IndexBar.tsx | 7 +++-- packages/vant/src/index-bar/demo/index.vue | 2 +- packages/vant/src/index-bar/types.ts | 3 +- packages/vant/src/lazyload/demo/index.vue | 2 +- packages/vant/src/list/demo/index.vue | 2 +- packages/vant/src/loading/demo/index.vue | 2 +- packages/vant/src/nav-bar/demo/index.vue | 2 +- packages/vant/src/notice-bar/demo/index.vue | 2 +- packages/vant/src/notify/demo/index.vue | 2 +- packages/vant/src/notify/types.ts | 3 +- .../src/number-keyboard/NumberKeyboard.tsx | 3 +- .../vant/src/number-keyboard/demo/index.vue | 2 +- packages/vant/src/overlay/demo/index.vue | 2 +- packages/vant/src/pagination/Pagination.tsx | 5 +-- packages/vant/src/pagination/demo/index.vue | 2 +- .../vant/src/password-input/demo/index.vue | 2 +- packages/vant/src/picker/demo/index.vue | 2 +- packages/vant/src/picker/types.ts | 5 +-- packages/vant/src/popover/demo/index.vue | 2 +- packages/vant/src/popup/demo/index.vue | 2 +- packages/vant/src/progress/Progress.tsx | 10 ++++-- packages/vant/src/progress/demo/index.vue | 2 +- packages/vant/src/pull-refresh/demo/index.vue | 2 +- packages/vant/src/radio/demo/index.vue | 2 +- packages/vant/src/rate/demo/index.vue | 2 +- packages/vant/src/search/demo/index.vue | 2 +- packages/vant/src/share-sheet/demo/index.vue | 2 +- packages/vant/src/sidebar/demo/index.vue | 2 +- packages/vant/src/skeleton/Skeleton.tsx | 5 ++- packages/vant/src/skeleton/demo/index.vue | 2 +- packages/vant/src/slider/demo/index.vue | 2 +- packages/vant/src/stepper/Stepper.tsx | 7 +++-- packages/vant/src/stepper/demo/index.vue | 2 +- packages/vant/src/steps/demo/index.vue | 2 +- packages/vant/src/sticky/demo/index.vue | 2 +- packages/vant/src/style/demo/index.vue | 2 +- packages/vant/src/submit-bar/demo/index.vue | 2 +- packages/vant/src/swipe-cell/demo/index.vue | 2 +- packages/vant/src/swipe/demo/index.vue | 2 +- packages/vant/src/switch/demo/index.vue | 2 +- packages/vant/src/tab/demo/Shrink.vue | 2 +- packages/vant/src/tab/demo/index.vue | 2 +- packages/vant/src/tabbar/Tabbar.tsx | 7 +++-- packages/vant/src/tabbar/demo/index.vue | 2 +- packages/vant/src/tabs/Tabs.tsx | 15 +++++---- packages/vant/src/tabs/types.ts | 9 +++--- packages/vant/src/tag/demo/index.vue | 2 +- packages/vant/src/toast/demo/index.vue | 2 +- packages/vant/src/toast/types.ts | 5 +-- packages/vant/src/tree-select/TreeSelect.tsx | 11 +++---- packages/vant/src/tree-select/demo/index.vue | 2 +- packages/vant/src/uploader/Uploader.tsx | 3 +- .../vant/src/uploader/UploaderPreviewItem.tsx | 5 +-- packages/vant/src/uploader/demo/index.vue | 2 +- packages/vant/src/uploader/test/index.spec.ts | 9 +++--- packages/vant/src/uploader/types.ts | 10 +++--- packages/vant/src/utils/basic.ts | 2 ++ packages/vant/src/utils/format.ts | 14 ++++----- packages/vant/src/utils/validate.ts | 4 +-- packages/vant/test/demo.ts | 2 +- 126 files changed, 238 insertions(+), 194 deletions(-) create mode 100644 packages/vant/docs/site/index.ts diff --git a/packages/vant/docs/site/index.ts b/packages/vant/docs/site/index.ts new file mode 100644 index 000000000..8972e4cdd --- /dev/null +++ b/packages/vant/docs/site/index.ts @@ -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}`; diff --git a/packages/vant/docs/site/use-translate.ts b/packages/vant/docs/site/use-translate.ts index 38c33dda2..7d29e43d3 100644 --- a/packages/vant/docs/site/use-translate.ts +++ b/packages/vant/docs/site/use-translate.ts @@ -104,7 +104,3 @@ export function useTranslate(i18n: Record) { return createTranslate(demoName); } - -/** Generate the CDN URL of assets. */ -export const cdnURL = (path: string) => - `https://cdn.jsdelivr.net/npm/@vant/assets/${path}`; diff --git a/packages/vant/src/action-bar/demo/index.vue b/packages/vant/src/action-bar/demo/index.vue index e500db8ee..eed313bc9 100644 --- a/packages/vant/src/action-bar/demo/index.vue +++ b/packages/vant/src/action-bar/demo/index.vue @@ -2,7 +2,7 @@ import VanActionBar from '..'; import VanActionBarIcon from '../../action-bar-icon'; import VanActionBarButton from '../../action-bar-button'; -import { useTranslate } from '../../../docs/site/use-translate'; +import { useTranslate } from '../../../docs/site'; import { Toast } from '../../toast'; const t = useTranslate({ diff --git a/packages/vant/src/action-sheet/demo/index.vue b/packages/vant/src/action-sheet/demo/index.vue index 89f571698..5af5339b2 100644 --- a/packages/vant/src/action-sheet/demo/index.vue +++ b/packages/vant/src/action-sheet/demo/index.vue @@ -2,7 +2,7 @@ import VanCell from '../../cell'; import VanActionSheet, { ActionSheetAction } from '..'; import { ref, computed } from 'vue'; -import { useTranslate } from '../../../docs/site/use-translate'; +import { useTranslate } from '../../../docs/site'; import { Toast } from '../../toast'; const t = useTranslate({ diff --git a/packages/vant/src/address-edit/demo/index.vue b/packages/vant/src/address-edit/demo/index.vue index df907b623..4d8617646 100644 --- a/packages/vant/src/address-edit/demo/index.vue +++ b/packages/vant/src/address-edit/demo/index.vue @@ -2,7 +2,7 @@ import VanAddressEdit from '..'; import { ref } from 'vue'; import { areaList } from '@vant/area-data'; -import { useTranslate } from '../../../docs/site/use-translate'; +import { useTranslate } from '../../../docs/site'; import { Toast } from '../../toast'; const t = useTranslate({ diff --git a/packages/vant/src/address-list/AddressListItem.tsx b/packages/vant/src/address-list/AddressListItem.tsx index babf7f602..278ad5fbd 100644 --- a/packages/vant/src/address-list/AddressListItem.tsx +++ b/packages/vant/src/address-list/AddressListItem.tsx @@ -1,7 +1,12 @@ import { defineComponent, type PropType } from 'vue'; // Utils -import { createNamespace, extend, makeRequiredProp } from '../utils'; +import { + extend, + createNamespace, + makeRequiredProp, + type Numeric, +} from '../utils'; // Components import { Tag } from '../tag'; @@ -12,8 +17,8 @@ import { Radio } from '../radio'; const [name, bem] = createNamespace('address-item'); export type AddressListAddress = { - id: number | string; - tel: number | string; + id: Numeric; + tel: Numeric; name: string; address: string; isDefault?: boolean; diff --git a/packages/vant/src/address-list/demo/index.vue b/packages/vant/src/address-list/demo/index.vue index 2ed2ae7a9..45e5a9f7a 100644 --- a/packages/vant/src/address-list/demo/index.vue +++ b/packages/vant/src/address-list/demo/index.vue @@ -1,7 +1,7 @@