From 8489918dca5cc5093738f964e3b09972aca1a0fa Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 27 Jun 2019 11:11:47 +0800 Subject: [PATCH] [improvement] rename use to createNamespace (#3658) --- packages/action-sheet/index.tsx | 6 +++--- packages/address-edit/Detail.js | 6 +++--- packages/address-edit/index.js | 6 +++--- packages/address-list/Item.tsx | 6 +++--- packages/address-list/index.tsx | 6 +++--- packages/area/index.js | 6 +++--- packages/button/index.tsx | 6 +++--- packages/card/index.tsx | 6 +++--- packages/cell-group/index.tsx | 6 +++--- packages/cell/index.tsx | 8 ++++---- packages/checkbox-group/index.js | 6 +++--- packages/checkbox/index.js | 6 +++--- packages/circle/index.js | 6 +++--- packages/col/index.js | 6 +++--- packages/collapse-item/index.js | 6 +++--- packages/collapse/index.js | 6 +++--- packages/contact-card/index.tsx | 6 +++--- packages/contact-edit/index.js | 6 +++--- packages/contact-list/index.tsx | 6 +++--- packages/coupon-cell/index.tsx | 6 +++--- packages/coupon-list/index.js | 6 +++--- packages/coupon/index.js | 6 +++--- packages/datetime-picker/index.js | 6 +++--- packages/dialog/Dialog.js | 6 +++--- packages/dropdown-item/index.js | 6 +++--- packages/dropdown-menu/index.js | 6 +++--- packages/field/index.js | 6 +++--- packages/goods-action-button/index.tsx | 6 +++--- packages/goods-action-icon/index.tsx | 6 +++--- packages/goods-action/index.tsx | 6 +++--- packages/icon/index.tsx | 6 +++--- packages/image-preview/ImagePreview.js | 6 +++--- packages/image/index.js | 6 +++--- packages/index-anchor/index.js | 6 +++--- packages/index-bar/index.js | 6 +++--- packages/info/index.tsx | 6 +++--- packages/list/index.js | 6 +++--- packages/loading/index.tsx | 6 +++--- packages/nav-bar/index.tsx | 6 +++--- packages/notice-bar/index.js | 6 +++--- packages/notify/Notify.tsx | 6 +++--- packages/number-keyboard/Key.js | 6 +++--- packages/number-keyboard/index.js | 6 +++--- packages/overlay/index.tsx | 6 +++--- packages/pagination/index.js | 6 +++--- packages/panel/index.tsx | 6 +++--- packages/password-input/index.tsx | 6 +++--- packages/picker/PickerColumn.js | 6 +++--- packages/picker/index.js | 6 +++--- packages/popup/index.js | 6 +++--- packages/progress/index.js | 6 +++--- packages/pull-refresh/index.js | 6 +++--- packages/radio-group/index.js | 6 +++--- packages/radio/index.js | 6 +++--- packages/rate/index.tsx | 6 +++--- packages/row/index.js | 6 +++--- packages/search/index.tsx | 6 +++--- packages/sidebar-item/index.js | 6 +++--- packages/sidebar/index.js | 6 +++--- packages/skeleton/index.tsx | 6 +++--- packages/sku/Sku.js | 6 +++--- packages/sku/components/SkuActions.tsx | 6 +++--- packages/sku/components/SkuHeader.tsx | 6 +++--- packages/sku/components/SkuImgUploader.js | 6 +++--- packages/sku/components/SkuMessages.js | 6 +++--- packages/sku/components/SkuRow.tsx | 6 +++--- packages/sku/components/SkuRowItem.js | 6 +++--- packages/sku/components/SkuStepper.js | 6 +++--- packages/slider/index.js | 6 +++--- packages/step/index.js | 6 +++--- packages/stepper/index.js | 6 +++--- packages/steps/index.js | 6 +++--- packages/submit-bar/index.tsx | 6 +++--- packages/swipe-cell/index.js | 6 +++--- packages/swipe-item/index.js | 6 +++--- packages/swipe/index.js | 6 +++--- packages/switch-cell/index.tsx | 6 +++--- packages/switch/index.tsx | 6 +++--- packages/tab/index.js | 6 +++--- packages/tabbar-item/index.js | 6 +++--- packages/tabbar/index.js | 6 +++--- packages/tabs/Content.js | 6 +++--- packages/tabs/Title.js | 4 ++-- packages/tabs/index.js | 6 +++--- packages/tag/index.tsx | 6 +++--- packages/toast/Toast.js | 6 +++--- packages/tree-select/index.tsx | 6 +++--- packages/uploader/index.js | 6 +++--- packages/utils/{use => create}/bem.ts | 2 +- packages/utils/{use/sfc.ts => create/component.ts} | 2 +- packages/utils/{use => create}/i18n.ts | 2 +- packages/utils/create/index.ts | 14 ++++++++++++++ packages/utils/index.ts | 2 +- packages/utils/use/index.ts | 14 -------------- 94 files changed, 282 insertions(+), 282 deletions(-) rename packages/utils/{use => create}/bem.ts (96%) rename packages/utils/{use/sfc.ts => create/component.ts} (98%) rename packages/utils/{use => create}/i18n.ts (89%) create mode 100644 packages/utils/create/index.ts delete mode 100644 packages/utils/use/index.ts diff --git a/packages/action-sheet/index.tsx b/packages/action-sheet/index.tsx index f6d6e14fe..f8846fe6c 100644 --- a/packages/action-sheet/index.tsx +++ b/packages/action-sheet/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import { PopupMixin } from '../mixins/popup'; import Icon from '../icon'; @@ -28,7 +28,7 @@ export type ActionSheetProps = PopupMixinProps & { safeAreaInsetBottom?: boolean; }; -const [sfc, bem] = use('action-sheet'); +const [createComponent, bem] = createNamespace('action-sheet'); function ActionSheet( h: CreateElement, @@ -155,4 +155,4 @@ ActionSheet.props = { } }; -export default sfc(ActionSheet); +export default createComponent(ActionSheet); diff --git a/packages/address-edit/Detail.js b/packages/address-edit/Detail.js index 1a816b788..570926de8 100644 --- a/packages/address-edit/Detail.js +++ b/packages/address-edit/Detail.js @@ -1,12 +1,12 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { isAndroid } from '../utils/validate/system'; import Cell from '../cell'; import Field from '../field'; -const [sfc, bem, t] = use('address-edit-detail'); +const [createComponent, bem, t] = createNamespace('address-edit-detail'); const android = isAndroid(); -export default sfc({ +export default createComponent({ props: { value: String, error: Boolean, diff --git a/packages/address-edit/index.js b/packages/address-edit/index.js index 460caf29c..b8c9ac47a 100644 --- a/packages/address-edit/index.js +++ b/packages/address-edit/index.js @@ -1,4 +1,4 @@ -import { use, isObj } from '../utils'; +import { createNamespace, isObj } from '../utils'; import { isMobile } from '../utils/validate/mobile'; import Area from '../area'; import Field from '../field'; @@ -9,7 +9,7 @@ import Dialog from '../dialog'; import Detail from './Detail'; import SwitchCell from '../switch-cell'; -const [sfc, bem, t] = use('address-edit'); +const [createComponent, bem, t] = createNamespace('address-edit'); const defaultData = { name: '', @@ -24,7 +24,7 @@ const defaultData = { isDefault: false }; -export default sfc({ +export default createComponent({ props: { areaList: Object, isSaving: Boolean, diff --git a/packages/address-list/Item.tsx b/packages/address-list/Item.tsx index d18841412..13302b737 100644 --- a/packages/address-list/Item.tsx +++ b/packages/address-list/Item.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { RED } from '../utils/color'; import { emit, inherit } from '../utils/functional'; import Icon from '../icon'; @@ -27,7 +27,7 @@ export type AddressItemEvents = { onSelect(): void; }; -const [sfc, bem] = use('address-item'); +const [createComponent, bem] = createNamespace('address-item'); function AddressItem( h: CreateElement, @@ -91,4 +91,4 @@ AddressItem.props = { switchable: Boolean }; -export default sfc(AddressItem); +export default createComponent(AddressItem); diff --git a/packages/address-list/index.tsx b/packages/address-list/index.tsx index 2a6204b4e..987688811 100644 --- a/packages/address-list/index.tsx +++ b/packages/address-list/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import Button from '../button'; import RadioGroup from '../radio-group'; @@ -21,7 +21,7 @@ export type AddressListSlots = DefaultSlots & { top?: ScopedSlot; }; -const [sfc, bem, t] = use('address-list'); +const [createComponent, bem, t] = createNamespace('address-list'); function AddressList( h: CreateElement, @@ -90,4 +90,4 @@ AddressList.props = { } }; -export default sfc(AddressList); +export default createComponent(AddressList); diff --git a/packages/area/index.js b/packages/area/index.js index e10fdee84..7928b88f8 100644 --- a/packages/area/index.js +++ b/packages/area/index.js @@ -1,10 +1,10 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Picker from '../picker'; import { pickerProps } from '../picker/shared'; -const [sfc, bem] = use('area'); +const [createComponent, bem] = createNamespace('area'); -export default sfc({ +export default createComponent({ props: { ...pickerProps, value: String, diff --git a/packages/button/index.tsx b/packages/button/index.tsx index fdf273557..b0fb5042a 100644 --- a/packages/button/index.tsx +++ b/packages/button/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import { routeProps, RouteProps, functionalRoute } from '../utils/router'; import Icon from '../icon'; @@ -35,7 +35,7 @@ export type ButtonEvents = { onClick?(event: Event): void; }; -const [sfc, bem] = use('button'); +const [createComponent, bem] = createNamespace('button'); function Button( h: CreateElement, @@ -148,4 +148,4 @@ Button.props = { } }; -export default sfc(Button); +export default createComponent(Button); diff --git a/packages/card/index.tsx b/packages/card/index.tsx index afe58eee9..4acff4b3f 100644 --- a/packages/card/index.tsx +++ b/packages/card/index.tsx @@ -1,4 +1,4 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { emit, inherit } from '../utils/functional'; import Tag from '../tag'; import Image from '../image'; @@ -38,7 +38,7 @@ export type CardEvents = { onClick?(event: Event): void; }; -const [sfc, bem] = use('card'); +const [createComponent, bem] = createNamespace('card'); function Card( h: CreateElement, @@ -187,4 +187,4 @@ Card.props = { } }; -export default sfc(Card); +export default createComponent(Card); diff --git a/packages/cell-group/index.tsx b/packages/cell-group/index.tsx index 2c1415032..ce281b9eb 100644 --- a/packages/cell-group/index.tsx +++ b/packages/cell-group/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit } from '../utils/functional'; // Types @@ -10,7 +10,7 @@ export type CellGroupProps = { border: boolean }; -const [sfc, bem] = use('cell-group'); +const [createComponent, bem] = createNamespace('cell-group'); function CellGroup( h: CreateElement, @@ -47,4 +47,4 @@ CellGroup.props = { } }; -export default sfc(CellGroup); +export default createComponent(CellGroup); diff --git a/packages/cell/index.tsx b/packages/cell/index.tsx index 6b47d086c..a82424a0a 100644 --- a/packages/cell/index.tsx +++ b/packages/cell/index.tsx @@ -1,4 +1,4 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { cellProps, SharedCellProps } from './shared'; import { emit, inherit } from '../utils/functional'; import { routeProps, RouteProps, functionalRoute } from '../utils/router'; @@ -7,7 +7,7 @@ import Icon from '../icon'; // Types import { CreateElement, RenderContext } from 'vue/types'; import { ScopedSlot, DefaultSlots } from '../utils/types'; -import { Mods } from '../utils/use/bem'; +import { Mods } from '../utils/create/bem'; export type CellProps = RouteProps & SharedCellProps & { @@ -26,7 +26,7 @@ export type CellEvents = { onClick?(event: Event): void; }; -const [sfc, bem] = use('cell'); +const [createComponent, bem] = createNamespace('cell'); function Cell( h: CreateElement, @@ -106,4 +106,4 @@ Cell.props = { arrowDirection: String }; -export default sfc(Cell); +export default createComponent(Cell); diff --git a/packages/checkbox-group/index.js b/packages/checkbox-group/index.js index 4957d2c56..25facb784 100644 --- a/packages/checkbox-group/index.js +++ b/packages/checkbox-group/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ParentMixin } from '../mixins/relation'; -const [sfc, bem] = use('checkbox-group'); +const [createComponent, bem] = createNamespace('checkbox-group'); -export default sfc({ +export default createComponent({ mixins: [ParentMixin('vanCheckbox')], props: { diff --git a/packages/checkbox/index.js b/packages/checkbox/index.js index 03b308799..fca7428d1 100644 --- a/packages/checkbox/index.js +++ b/packages/checkbox/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { CheckboxMixin } from '../mixins/checkbox'; -const [sfc, bem] = use('checkbox'); +const [createComponent, bem] = createNamespace('checkbox'); -export default sfc({ +export default createComponent({ mixins: [CheckboxMixin({ bem, role: 'checkbox', diff --git a/packages/circle/index.js b/packages/circle/index.js index beccb1cde..be62bf167 100644 --- a/packages/circle/index.js +++ b/packages/circle/index.js @@ -1,8 +1,8 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { raf, cancelRaf } from '../utils/dom/raf'; import { BLUE, WHITE } from '../utils/color'; -const [sfc, bem] = use('circle'); +const [createComponent, bem] = createNamespace('circle'); const PERIMETER = 3140; const PATH = 'M 530 530 m -500, 0 a 500, 500 0 1, 1 1000, 0 a 500, 500 0 1, 1 -1000, 0'; @@ -10,7 +10,7 @@ function format(rate) { return Math.min(Math.max(rate, 0), 100); } -export default sfc({ +export default createComponent({ props: { text: String, value: Number, diff --git a/packages/col/index.js b/packages/col/index.js index e372b7156..ccd3360c8 100644 --- a/packages/col/index.js +++ b/packages/col/index.js @@ -1,8 +1,8 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const [sfc, bem] = use('col'); +const [createComponent, bem] = createNamespace('col'); -export default sfc({ +export default createComponent({ props: { span: [Number, String], offset: [Number, String], diff --git a/packages/collapse-item/index.js b/packages/collapse-item/index.js index ed261db4e..c68bfa48c 100644 --- a/packages/collapse-item/index.js +++ b/packages/collapse-item/index.js @@ -1,13 +1,13 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { raf } from '../utils/dom/raf'; import Cell from '../cell'; import { cellProps } from '../cell/shared'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('collapse-item'); +const [createComponent, bem] = createNamespace('collapse-item'); const CELL_SLOTS = ['title', 'icon', 'right-icon']; -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanCollapse')], props: { diff --git a/packages/collapse/index.js b/packages/collapse/index.js index 6652d4687..8a15340e1 100644 --- a/packages/collapse/index.js +++ b/packages/collapse/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ParentMixin } from '../mixins/relation'; -const [sfc, bem] = use('collapse'); +const [createComponent, bem] = createNamespace('collapse'); -export default sfc({ +export default createComponent({ mixins: [ParentMixin('vanCollapse')], props: { diff --git a/packages/contact-card/index.tsx b/packages/contact-card/index.tsx index c813fbcf2..faf71fe18 100644 --- a/packages/contact-card/index.tsx +++ b/packages/contact-card/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import Cell from '../cell'; @@ -6,7 +6,7 @@ import Cell from '../cell'; import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/types'; -const [sfc, bem, t] = use('contact-card'); +const [createComponent, bem, t] = createNamespace('contact-card'); export type ContactCardProps = { tel?: string; @@ -65,4 +65,4 @@ ContactCard.props = { } }; -export default sfc(ContactCard); +export default createComponent(ContactCard); diff --git a/packages/contact-edit/index.js b/packages/contact-edit/index.js index e664189b5..45107b364 100644 --- a/packages/contact-edit/index.js +++ b/packages/contact-edit/index.js @@ -1,18 +1,18 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Button from '../button'; import Field from '../field'; import Toast from '../toast'; import Dialog from '../dialog'; import { isMobile } from '../utils/validate/mobile'; -const [sfc, bem, t] = use('contact-edit'); +const [createComponent, bem, t] = createNamespace('contact-edit'); const defaultContact = { tel: '', name: '' }; -export default sfc({ +export default createComponent({ props: { isEdit: Boolean, isSaving: Boolean, diff --git a/packages/contact-list/index.tsx b/packages/contact-list/index.tsx index 6aa66f0bc..d89e44c6d 100644 --- a/packages/contact-list/index.tsx +++ b/packages/contact-list/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { RED } from '../utils/color'; import { emit, inherit } from '../utils/functional'; import Icon from '../icon'; @@ -23,7 +23,7 @@ export type ContactListProps = { addText?: string; }; -const [sfc, bem, t] = use('contact-list'); +const [createComponent, bem, t] = createNamespace('contact-list'); function ContactList( h: CreateElement, @@ -90,4 +90,4 @@ ContactList.props = { addText: String }; -export default sfc(ContactList); +export default createComponent(ContactList); diff --git a/packages/coupon-cell/index.tsx b/packages/coupon-cell/index.tsx index 1bc30e4a3..5cba96912 100644 --- a/packages/coupon-cell/index.tsx +++ b/packages/coupon-cell/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit } from '../utils/functional'; import Cell from '../cell'; @@ -16,7 +16,7 @@ export type CouponCellProps = { chosenCoupon: number; }; -const [sfc, bem, t] = use('coupon-cell'); +const [createComponent, bem, t] = createNamespace('coupon-cell'); function formatValue(props: CouponCellProps) { const { coupons, chosenCoupon, currency } = props; @@ -79,4 +79,4 @@ CouponCell.props = { } }; -export default sfc(CouponCell); +export default createComponent(CouponCell); diff --git a/packages/coupon-list/index.js b/packages/coupon-list/index.js index 28ec121f4..c376a4ff8 100644 --- a/packages/coupon-list/index.js +++ b/packages/coupon-list/index.js @@ -1,14 +1,14 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Tab from '../tab'; import Tabs from '../tabs'; import Field from '../field'; import Button from '../button'; import Coupon from '../coupon'; -const [sfc, bem, t] = use('coupon-list'); +const [createComponent, bem, t] = createNamespace('coupon-list'); const EMPTY_IMAGE = 'https://img.yzcdn.cn/vant/coupon-empty.png'; -export default sfc({ +export default createComponent({ model: { prop: 'code' }, diff --git a/packages/coupon/index.js b/packages/coupon/index.js index bd040337f..d78539b65 100644 --- a/packages/coupon/index.js +++ b/packages/coupon/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { RED } from '../utils/color'; import { padZero } from '../utils/format/string'; import Checkbox from '../checkbox'; -const [sfc, bem, t] = use('coupon'); +const [createComponent, bem, t] = createNamespace('coupon'); function getDate(timeStamp) { const date = new Date(timeStamp * 1000); @@ -20,7 +20,7 @@ function formatAmount(amount) { return (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2); } -export default sfc({ +export default createComponent({ props: { coupon: Object, chosen: Boolean, diff --git a/packages/datetime-picker/index.js b/packages/datetime-picker/index.js index dd9fcb246..40a838d6e 100644 --- a/packages/datetime-picker/index.js +++ b/packages/datetime-picker/index.js @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { range } from '../utils/format/number'; import { padZero } from '../utils/format/string'; import Picker from '../picker'; @@ -10,10 +10,10 @@ import { getMonthEndDay } from './utils'; -const [sfc, bem] = use('datetime-picker'); +const [createComponent, bem] = createNamespace('datetime-picker'); const currentYear = new Date().getFullYear(); -export default sfc({ +export default createComponent({ props: { ...pickerProps, value: null, diff --git a/packages/dialog/Dialog.js b/packages/dialog/Dialog.js index bb36d21e0..5f0c4f925 100644 --- a/packages/dialog/Dialog.js +++ b/packages/dialog/Dialog.js @@ -1,10 +1,10 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { PopupMixin } from '../mixins/popup'; import Button from '../button'; -const [sfc, bem, t] = use('dialog'); +const [createComponent, bem, t] = createNamespace('dialog'); -export default sfc({ +export default createComponent({ mixins: [PopupMixin], props: { diff --git a/packages/dropdown-item/index.js b/packages/dropdown-item/index.js index 1e6ca8587..42d148b89 100644 --- a/packages/dropdown-item/index.js +++ b/packages/dropdown-item/index.js @@ -1,12 +1,12 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Cell from '../cell'; import Icon from '../icon'; import Popup from '../popup'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('dropdown-item'); +const [createComponent, bem] = createNamespace('dropdown-item'); -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanDropdownMenu')], props: { diff --git a/packages/dropdown-menu/index.js b/packages/dropdown-menu/index.js index 805a15df4..e04211c34 100644 --- a/packages/dropdown-menu/index.js +++ b/packages/dropdown-menu/index.js @@ -1,11 +1,11 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { BLUE } from '../utils/color'; import { ParentMixin } from '../mixins/relation'; import { ClickOutsideMixin } from '../mixins/click-outside'; -const [sfc, bem] = use('dropdown-menu'); +const [createComponent, bem] = createNamespace('dropdown-menu'); -export default sfc({ +export default createComponent({ mixins: [ ParentMixin('vanDropdownMenu'), ClickOutsideMixin({ diff --git a/packages/field/index.js b/packages/field/index.js index c352c96a7..dd87099ac 100644 --- a/packages/field/index.js +++ b/packages/field/index.js @@ -3,12 +3,12 @@ import Cell from '../cell'; import { cellProps } from '../cell/shared'; import { preventDefault } from '../utils/dom/event'; import { getRootScrollTop } from '../utils/dom/scroll'; -import { use, isObj, isDef, suffixPx } from '../utils'; +import { createNamespace, isObj, isDef, suffixPx } from '../utils'; import { isIOS } from '../utils/validate/system'; -const [sfc, bem] = use('field'); +const [createComponent, bem] = createNamespace('field'); -export default sfc({ +export default createComponent({ inheritAttrs: false, props: { diff --git a/packages/goods-action-button/index.tsx b/packages/goods-action-button/index.tsx index 5d6514803..aa149994c 100644 --- a/packages/goods-action-button/index.tsx +++ b/packages/goods-action-button/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Button, { ButtonType, ButtonEvents } from '../button'; import { emit, inherit } from '../utils/functional'; import { functionalRoute, routeProps, RouteProps } from '../utils/router'; @@ -15,7 +15,7 @@ export type GoodsActionButtonProps = RouteProps & { disabled?: boolean; }; -const [sfc, bem] = use('goods-action-button'); +const [createComponent, bem] = createNamespace('goods-action-button'); function GoodsActionButton( h: CreateElement, @@ -52,4 +52,4 @@ GoodsActionButton.props = { disabled: Boolean }; -export default sfc(GoodsActionButton); +export default createComponent(GoodsActionButton); diff --git a/packages/goods-action-icon/index.tsx b/packages/goods-action-icon/index.tsx index 472da2bba..9ab055bfc 100644 --- a/packages/goods-action-icon/index.tsx +++ b/packages/goods-action-icon/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Icon, { IconEvents } from '../icon'; import { emit, inherit } from '../utils/functional'; import { functionalRoute, routeProps, RouteProps } from '../utils/router'; @@ -14,7 +14,7 @@ export type GoodsActionIconProps = RouteProps & { iconClass?: any; }; -const [sfc, bem] = use('goods-action-icon'); +const [createComponent, bem] = createNamespace('goods-action-icon'); function GoodsActionIcon( h: CreateElement, @@ -54,4 +54,4 @@ GoodsActionIcon.props = { iconClass: null as any }; -export default sfc(GoodsActionIcon); +export default createComponent(GoodsActionIcon); diff --git a/packages/goods-action/index.tsx b/packages/goods-action/index.tsx index d89154b29..6b8d063da 100644 --- a/packages/goods-action/index.tsx +++ b/packages/goods-action/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit } from '../utils/functional'; // Types @@ -9,7 +9,7 @@ export type GoodsActionProps = { safeAreaInsetBottom?: boolean; }; -const [sfc, bem] = use('goods-action'); +const [createComponent, bem] = createNamespace('goods-action'); function GoodsAction( h: CreateElement, @@ -31,4 +31,4 @@ GoodsAction.props = { safeAreaInsetBottom: Boolean }; -export default sfc(GoodsAction); +export default createComponent(GoodsAction); diff --git a/packages/icon/index.tsx b/packages/icon/index.tsx index 8623e788e..832bdf7c1 100644 --- a/packages/icon/index.tsx +++ b/packages/icon/index.tsx @@ -1,4 +1,4 @@ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { inherit } from '../utils/functional'; import Info from '../info'; import Image from '../image'; @@ -20,7 +20,7 @@ export type IconEvents = { onClick?(event: Event): void; }; -const [sfc, bem] = use('icon'); +const [createComponent, bem] = createNamespace('icon'); function isImage(name?: string): boolean { return name ? name.indexOf('/') !== -1 : false; @@ -65,4 +65,4 @@ Icon.props = { } }; -export default sfc(Icon); +export default createComponent(Icon); diff --git a/packages/image-preview/ImagePreview.js b/packages/image-preview/ImagePreview.js index 2a40fcbde..628540fe3 100644 --- a/packages/image-preview/ImagePreview.js +++ b/packages/image-preview/ImagePreview.js @@ -1,4 +1,4 @@ -import { use, isServer } from '../utils'; +import { createNamespace, isServer } from '../utils'; import { range } from '../utils/format/number'; import { preventDefault } from '../utils/dom/event'; import { PopupMixin } from '../mixins/popup'; @@ -6,7 +6,7 @@ import { TouchMixin } from '../mixins/touch'; import Swipe from '../swipe'; import SwipeItem from '../swipe-item'; -const [sfc, bem] = use('image-preview'); +const [createComponent, bem] = createNamespace('image-preview'); function getDistance(touches) { return Math.sqrt( @@ -17,7 +17,7 @@ function getDistance(touches) { ); } -export default sfc({ +export default createComponent({ mixins: [PopupMixin, TouchMixin], props: { diff --git a/packages/image/index.js b/packages/image/index.js index 1a7d40006..b8f47c4fb 100644 --- a/packages/image/index.js +++ b/packages/image/index.js @@ -1,9 +1,9 @@ -import { use, isDef, suffixPx } from '../utils'; +import { createNamespace, isDef, suffixPx } from '../utils'; import Icon from '../icon'; -const [sfc, bem] = use('image'); +const [createComponent, bem] = createNamespace('image'); -export default sfc({ +export default createComponent({ props: { src: String, fit: String, diff --git a/packages/index-anchor/index.js b/packages/index-anchor/index.js index 201445170..0582121ea 100644 --- a/packages/index-anchor/index.js +++ b/packages/index-anchor/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('index-anchor'); +const [createComponent, bem] = createNamespace('index-anchor'); -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanIndexBar', { indexKey: 'childrenIndex' })], props: { diff --git a/packages/index-bar/index.js b/packages/index-bar/index.js index e7cdb46e9..1d757851a 100644 --- a/packages/index-bar/index.js +++ b/packages/index-bar/index.js @@ -1,13 +1,13 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { TouchMixin } from '../mixins/touch'; import { ParentMixin } from '../mixins/relation'; import { BindEventMixin } from '../mixins/bind-event'; import { GREEN } from '../utils/color'; import { getScrollTop, getElementTop, getScrollEventTarget } from '../utils/dom/scroll'; -const [sfc, bem] = use('index-bar'); +const [createComponent, bem] = createNamespace('index-bar'); -export default sfc({ +export default createComponent({ mixins: [ TouchMixin, ParentMixin('vanIndexBar'), diff --git a/packages/info/index.tsx b/packages/info/index.tsx index c64f09ecf..9e57b527b 100644 --- a/packages/info/index.tsx +++ b/packages/info/index.tsx @@ -1,4 +1,4 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { inherit } from '../utils/functional'; // Types @@ -9,7 +9,7 @@ export type InfoProps = { info?: string | number; }; -const [sfc, bem] = use('info'); +const [createComponent, bem] = createNamespace('info'); function Info( h: CreateElement, @@ -32,4 +32,4 @@ Info.props = { info: [String, Number] }; -export default sfc(Info); +export default createComponent(Info); diff --git a/packages/list/index.js b/packages/list/index.js index 6beb271b9..a2abefea0 100644 --- a/packages/list/index.js +++ b/packages/list/index.js @@ -1,11 +1,11 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Loading from '../loading'; import { BindEventMixin } from '../mixins/bind-event'; import { getScrollEventTarget } from '../utils/dom/scroll'; -const [sfc, bem, t] = use('list'); +const [createComponent, bem, t] = createNamespace('list'); -export default sfc({ +export default createComponent({ mixins: [ BindEventMixin(function (bind) { if (!this.scroller) { diff --git a/packages/loading/index.tsx b/packages/loading/index.tsx index 8c281eeb4..015d5769e 100644 --- a/packages/loading/index.tsx +++ b/packages/loading/index.tsx @@ -1,4 +1,4 @@ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { GRAY } from '../utils/color'; import { inherit } from '../utils/functional'; @@ -16,7 +16,7 @@ export type LoadingProps = { textSize?: string | number; }; -const [sfc, bem] = use('loading'); +const [createComponent, bem] = createNamespace('loading'); function LoadingIcon(h: CreateElement, props: LoadingProps) { if (props.type === 'spinner') { @@ -87,4 +87,4 @@ Loading.props = { } }; -export default sfc(Loading); +export default createComponent(Loading); diff --git a/packages/nav-bar/index.tsx b/packages/nav-bar/index.tsx index 080620c77..519c0d9df 100644 --- a/packages/nav-bar/index.tsx +++ b/packages/nav-bar/index.tsx @@ -1,4 +1,4 @@ -import { use, noop } from '../utils'; +import { createNamespace, noop } from '../utils'; import { inherit } from '../utils/functional'; import Icon from '../icon'; @@ -27,7 +27,7 @@ export type NavBarEvents = { 'click-right'?(event: Event): void; }; -const [sfc, bem] = use('nav-bar'); +const [createComponent, bem] = createNamespace('nav-bar'); function NavBar( h: CreateElement, @@ -86,4 +86,4 @@ NavBar.props = { } }; -export default sfc(NavBar); +export default createComponent(NavBar); diff --git a/packages/notice-bar/index.js b/packages/notice-bar/index.js index 4c633c8a2..9e8f083c9 100644 --- a/packages/notice-bar/index.js +++ b/packages/notice-bar/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Icon from '../icon'; -const [sfc, bem] = use('notice-bar'); +const [createComponent, bem] = createNamespace('notice-bar'); -export default sfc({ +export default createComponent({ props: { text: String, mode: String, diff --git a/packages/notify/Notify.tsx b/packages/notify/Notify.tsx index 05c94c798..c3a39d25a 100644 --- a/packages/notify/Notify.tsx +++ b/packages/notify/Notify.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { RED, WHITE } from '../utils/color'; import { inherit } from '../utils/functional'; import { PopupMixin } from '../mixins/popup'; @@ -17,7 +17,7 @@ export type NotifyProps = PopupMixinProps & { background: string; }; -const [sfc, bem] = use('notify'); +const [createComponent, bem] = createNamespace('notify'); function Notify( h: CreateElement, @@ -64,4 +64,4 @@ Notify.props = { } }; -export default sfc(Notify); +export default createComponent(Notify); diff --git a/packages/number-keyboard/Key.js b/packages/number-keyboard/Key.js index e9299f050..b9169ed72 100644 --- a/packages/number-keyboard/Key.js +++ b/packages/number-keyboard/Key.js @@ -1,8 +1,8 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const [sfc, bem] = use('key'); +const [createComponent, bem] = createNamespace('key'); -export default sfc({ +export default createComponent({ props: { type: String, theme: Array, diff --git a/packages/number-keyboard/index.js b/packages/number-keyboard/index.js index a7ff5bc0f..56c6c42e3 100644 --- a/packages/number-keyboard/index.js +++ b/packages/number-keyboard/index.js @@ -1,13 +1,13 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { stopPropagation } from '../utils/dom/event'; import { BindEventMixin } from '../mixins/bind-event'; import Key from './Key'; -const [sfc, bem, t] = use('number-keyboard'); +const [createComponent, bem, t] = createNamespace('number-keyboard'); const CLOSE_KEY_THEME = ['blue', 'big']; const DELETE_KEY_THEME = ['delete', 'big', 'gray']; -export default sfc({ +export default createComponent({ mixins: [ BindEventMixin(function (bind) { if (this.hideOnClickOutside) { diff --git a/packages/overlay/index.tsx b/packages/overlay/index.tsx index a7f9b78ea..f7c53c020 100644 --- a/packages/overlay/index.tsx +++ b/packages/overlay/index.tsx @@ -1,4 +1,4 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { inherit } from '../utils/functional'; import { preventDefault } from '../utils/dom/event'; @@ -18,7 +18,7 @@ export type OverlayEvents = { click(event: Event): void; }; -const [sfc, bem] = use('overlay'); +const [createComponent, bem] = createNamespace('overlay'); function preventTouchMove(event: TouchEvent) { preventDefault(event, true); @@ -63,4 +63,4 @@ Overlay.props = { } }; -export default sfc(Overlay); +export default createComponent(Overlay); diff --git a/packages/pagination/index.js b/packages/pagination/index.js index 3999d0b66..f55f1b06c 100644 --- a/packages/pagination/index.js +++ b/packages/pagination/index.js @@ -1,12 +1,12 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const [sfc, bem, t] = use('pagination'); +const [createComponent, bem, t] = createNamespace('pagination'); function makePage(number, text, active) { return { number, text, active }; } -export default sfc({ +export default createComponent({ props: { value: Number, prevText: String, diff --git a/packages/panel/index.tsx b/packages/panel/index.tsx index ffd4ee5e8..a7d0da6e7 100644 --- a/packages/panel/index.tsx +++ b/packages/panel/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Cell from '../cell'; import CellGroup from '../cell-group'; import { inherit } from '../utils/functional'; @@ -19,7 +19,7 @@ export type PanelSlots = DefaultSlots & { footer?: ScopedSlot; }; -const [sfc, bem] = use('panel'); +const [createComponent, bem] = createNamespace('panel'); function Panel( h: CreateElement, @@ -62,4 +62,4 @@ Panel.props = { status: String }; -export default sfc(Panel); +export default createComponent(Panel); diff --git a/packages/password-input/index.tsx b/packages/password-input/index.tsx index 867d8a82c..0b472b47b 100644 --- a/packages/password-input/index.tsx +++ b/packages/password-input/index.tsx @@ -1,4 +1,4 @@ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { emit, inherit } from '../utils/functional'; // Types @@ -14,7 +14,7 @@ export type PasswordInputProps = { errorInfo?: string; }; -const [sfc, bem] = use('password-input'); +const [createComponent, bem] = createNamespace('password-input'); function PasswordInput( h: CreateElement, @@ -76,4 +76,4 @@ PasswordInput.props = { } }; -export default sfc(PasswordInput); +export default createComponent(PasswordInput); diff --git a/packages/picker/PickerColumn.js b/packages/picker/PickerColumn.js index b04b1b510..7cc3cf0c4 100644 --- a/packages/picker/PickerColumn.js +++ b/packages/picker/PickerColumn.js @@ -1,5 +1,5 @@ import { deepClone } from '../utils/deep-clone'; -import { use, isObj } from '../utils'; +import { createNamespace, isObj } from '../utils'; import { range } from '../utils/format/number'; import { preventDefault } from '../utils/dom/event'; import { TouchMixin } from '../mixins/touch'; @@ -13,7 +13,7 @@ const MOMENTUM_DURATION = 1000; const MOMENTUM_LIMIT_TIME = 300; const MOMENTUM_LIMIT_DISTANCE = 15; -const [sfc, bem] = use('picker-column'); +const [createComponent, bem] = createNamespace('picker-column'); function getElementTranslateY(element) { const { transform } = window.getComputedStyle(element); @@ -26,7 +26,7 @@ function isOptionDisabled(option) { return isObj(option) && option.disabled; } -export default sfc({ +export default createComponent({ mixins: [TouchMixin], props: { diff --git a/packages/picker/index.js b/packages/picker/index.js index 8e602a3e1..f62cda13e 100644 --- a/packages/picker/index.js +++ b/packages/picker/index.js @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { preventDefault } from '../utils/dom/event'; import { deepClone } from '../utils/deep-clone'; import { pickerProps } from './shared'; @@ -6,9 +6,9 @@ import { BLUE } from '../utils/color'; import Loading from '../loading'; import PickerColumn from './PickerColumn'; -const [sfc, bem, t] = use('picker'); +const [createComponent, bem, t] = createNamespace('picker'); -export default sfc({ +export default createComponent({ props: { ...pickerProps, columns: Array, diff --git a/packages/popup/index.js b/packages/popup/index.js index 3a14c414a..bd71a4787 100644 --- a/packages/popup/index.js +++ b/packages/popup/index.js @@ -1,9 +1,9 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { PopupMixin } from '../mixins/popup'; -const [sfc, bem] = use('popup'); +const [createComponent, bem] = createNamespace('popup'); -export default sfc({ +export default createComponent({ mixins: [PopupMixin], props: { diff --git a/packages/progress/index.js b/packages/progress/index.js index 886d8b201..8ad85e78a 100644 --- a/packages/progress/index.js +++ b/packages/progress/index.js @@ -1,9 +1,9 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { BLUE, WHITE } from '../utils/color'; -const [sfc, bem] = use('progress'); +const [createComponent, bem] = createNamespace('progress'); -export default sfc({ +export default createComponent({ props: { inactive: Boolean, pivotText: String, diff --git a/packages/pull-refresh/index.js b/packages/pull-refresh/index.js index 8882f669a..1b22c47f5 100644 --- a/packages/pull-refresh/index.js +++ b/packages/pull-refresh/index.js @@ -1,13 +1,13 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { preventDefault } from '../utils/dom/event'; import { TouchMixin } from '../mixins/touch'; import { getScrollTop, getScrollEventTarget } from '../utils/dom/scroll'; import Loading from '../loading'; -const [sfc, bem, t] = use('pull-refresh'); +const [createComponent, bem, t] = createNamespace('pull-refresh'); const TEXT_STATUS = ['pulling', 'loosing', 'success']; -export default sfc({ +export default createComponent({ mixins: [TouchMixin], props: { diff --git a/packages/radio-group/index.js b/packages/radio-group/index.js index a0fa93d47..9273d2ffe 100644 --- a/packages/radio-group/index.js +++ b/packages/radio-group/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ParentMixin } from '../mixins/relation'; -const [sfc, bem] = use('radio-group'); +const [createComponent, bem] = createNamespace('radio-group'); -export default sfc({ +export default createComponent({ mixins: [ParentMixin('vanRadio')], props: { diff --git a/packages/radio/index.js b/packages/radio/index.js index 05d44d6a2..3f4427511 100644 --- a/packages/radio/index.js +++ b/packages/radio/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { CheckboxMixin } from '../mixins/checkbox'; -const [sfc, bem] = use('radio'); +const [createComponent, bem] = createNamespace('radio'); -export default sfc({ +export default createComponent({ mixins: [CheckboxMixin({ bem, role: 'radio', diff --git a/packages/rate/index.tsx b/packages/rate/index.tsx index cb14e4f7a..0616f99f3 100644 --- a/packages/rate/index.tsx +++ b/packages/rate/index.tsx @@ -1,5 +1,5 @@ /* eslint-disable prefer-spread */ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { emit, inherit } from '../utils/functional'; import { preventDefault } from '../utils/dom/event'; import Icon from '../icon'; @@ -8,7 +8,7 @@ import Icon from '../icon'; import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/types'; -const [sfc, bem] = use('rate'); +const [createComponent, bem] = createNamespace('rate'); export type RateProps = { size: number; @@ -186,4 +186,4 @@ Rate.props = { } }; -export default sfc(Rate); +export default createComponent(Rate); diff --git a/packages/row/index.js b/packages/row/index.js index 0d2f01256..dac61a99d 100644 --- a/packages/row/index.js +++ b/packages/row/index.js @@ -1,8 +1,8 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const [sfc, bem] = use('row'); +const [createComponent, bem] = createNamespace('row'); -export default sfc({ +export default createComponent({ props: { type: String, align: String, diff --git a/packages/search/index.tsx b/packages/search/index.tsx index 48d0d9291..b86434ac1 100644 --- a/packages/search/index.tsx +++ b/packages/search/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit, emit } from '../utils/functional'; import { preventDefault } from '../utils/dom/event'; import Field from '../field'; @@ -7,7 +7,7 @@ import Field from '../field'; import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots, ScopedSlot } from '../utils/types'; -const [sfc, bem, t] = use('search'); +const [createComponent, bem, t] = createNamespace('search'); export type SearchProps = { shape: string; @@ -134,4 +134,4 @@ Search.props = { } }; -export default sfc(Search); +export default createComponent(Search); diff --git a/packages/sidebar-item/index.js b/packages/sidebar-item/index.js index 1aac9a18e..0a98113fe 100644 --- a/packages/sidebar-item/index.js +++ b/packages/sidebar-item/index.js @@ -1,10 +1,10 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Info from '../info'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('sidebar-item'); +const [createComponent, bem] = createNamespace('sidebar-item'); -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanSidebar')], props: { diff --git a/packages/sidebar/index.js b/packages/sidebar/index.js index fd8713d03..f002c1f48 100644 --- a/packages/sidebar/index.js +++ b/packages/sidebar/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ParentMixin } from '../mixins/relation'; -const [sfc, bem] = use('sidebar'); +const [createComponent, bem] = createNamespace('sidebar'); -export default sfc({ +export default createComponent({ mixins: [ParentMixin('vanSidebar')], props: { diff --git a/packages/skeleton/index.tsx b/packages/skeleton/index.tsx index 7f3cd4325..af98ae96e 100644 --- a/packages/skeleton/index.tsx +++ b/packages/skeleton/index.tsx @@ -1,4 +1,4 @@ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { inherit } from '../utils/functional'; // Types @@ -17,7 +17,7 @@ export type SkeletonProps = { rowWidth: number | string | (number | string)[]; }; -const [sfc, bem] = use('skeleton'); +const [createComponent, bem] = createNamespace('skeleton'); const DEFAULT_ROW_WIDTH = '100%'; const DEFAULT_LAST_ROW_WIDTH = '60%'; @@ -113,4 +113,4 @@ Skeleton.props = { } }; -export default sfc(Skeleton); +export default createComponent(Skeleton); diff --git a/packages/sku/Sku.js b/packages/sku/Sku.js index bdfff7354..19f8f4700 100644 --- a/packages/sku/Sku.js +++ b/packages/sku/Sku.js @@ -9,14 +9,14 @@ import SkuRowItem from './components/SkuRowItem'; import SkuStepper from './components/SkuStepper'; import SkuMessages from './components/SkuMessages'; import SkuActions from './components/SkuActions'; -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { isAllSelected, isSkuChoosable, getSkuComb, getSelectedSkuValues } from './utils/skuHelper'; import { LIMIT_TYPE, UNSELECTED_SKU_VALUE_ID } from './constants'; -const [sfc] = use('sku'); +const [createComponent] = createNamespace('sku'); const { QUOTA_LIMIT } = LIMIT_TYPE; -export default sfc({ +export default createComponent({ props: { sku: Object, goods: Object, diff --git a/packages/sku/components/SkuActions.tsx b/packages/sku/components/SkuActions.tsx index 3ffb453fb..52b4b6721 100644 --- a/packages/sku/components/SkuActions.tsx +++ b/packages/sku/components/SkuActions.tsx @@ -1,4 +1,4 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import { inherit } from '../../utils/functional'; import Button from '../../button'; @@ -12,7 +12,7 @@ export type SkuActionsProps = { showAddCartBtn?: boolean; }; -const [sfc, bem] = use('sku-actions'); +const [createComponent, bem] = createNamespace('sku-actions'); function SkuActions( h: CreateElement, @@ -52,4 +52,4 @@ SkuActions.props = { showAddCartBtn: Boolean }; -export default sfc(SkuActions); +export default createComponent(SkuActions); diff --git a/packages/sku/components/SkuHeader.tsx b/packages/sku/components/SkuHeader.tsx index 61c7f41fb..7d3e24af6 100644 --- a/packages/sku/components/SkuHeader.tsx +++ b/packages/sku/components/SkuHeader.tsx @@ -1,4 +1,4 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import { inherit } from '../../utils/functional'; import Icon from '../../icon'; @@ -14,7 +14,7 @@ export type SkuHeaderProps = { selectedSku: SelectedSkuData; }; -const [sfc, bem] = use('sku-header'); +const [createComponent, bem] = createNamespace('sku-header'); function getSkuImg(sku: SkuData, selectedSku: SelectedSkuData) { const id = selectedSku.s1; @@ -71,4 +71,4 @@ SkuHeader.props = { selectedSku: Object }; -export default sfc(SkuHeader); +export default createComponent(SkuHeader); diff --git a/packages/sku/components/SkuImgUploader.js b/packages/sku/components/SkuImgUploader.js index a9200b2e5..f3759d37b 100644 --- a/packages/sku/components/SkuImgUploader.js +++ b/packages/sku/components/SkuImgUploader.js @@ -1,11 +1,11 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import Icon from '../../icon'; import Loading from '../../loading'; import Uploader from '../../uploader'; -const [sfc, bem] = use('sku-img-uploader'); +const [createComponent, bem] = createNamespace('sku-img-uploader'); -export default sfc({ +export default createComponent({ props: { value: String, uploadImg: Function, diff --git a/packages/sku/components/SkuMessages.js b/packages/sku/components/SkuMessages.js index 22fdabebc..c5e75f157 100644 --- a/packages/sku/components/SkuMessages.js +++ b/packages/sku/components/SkuMessages.js @@ -1,4 +1,4 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import Cell from '../../cell'; import CellGroup from '../../cell-group'; import Field from '../../field'; @@ -6,7 +6,7 @@ import { isEmail } from '../../utils/validate/email'; import { isNumber } from '../../utils/validate/number'; import SkuImgUploader from './SkuImgUploader'; -const [sfc, bem] = use('sku-messages'); +const [createComponent, bem] = createNamespace('sku-messages'); const PLACEHOLDER = { id_no: '输入身份证号码', @@ -19,7 +19,7 @@ const PLACEHOLDER = { mobile: '输入手机号码' }; -export default sfc({ +export default createComponent({ props: { messages: Array, messageConfig: Object, diff --git a/packages/sku/components/SkuRow.tsx b/packages/sku/components/SkuRow.tsx index d2ebb6933..c593409dd 100644 --- a/packages/sku/components/SkuRow.tsx +++ b/packages/sku/components/SkuRow.tsx @@ -1,4 +1,4 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import { inherit } from '../../utils/functional'; // Types @@ -10,7 +10,7 @@ export type SkuRowProps = { skuRow: SkuTreeItemData; }; -const [sfc, bem] = use('sku-row'); +const [createComponent, bem] = createNamespace('sku-row'); function SkuRow( h: CreateElement, @@ -30,4 +30,4 @@ SkuRow.props = { skuRow: Object }; -export default sfc(SkuRow); +export default createComponent(SkuRow); diff --git a/packages/sku/components/SkuRowItem.js b/packages/sku/components/SkuRowItem.js index 88e8df0ca..c1dc1de7d 100644 --- a/packages/sku/components/SkuRowItem.js +++ b/packages/sku/components/SkuRowItem.js @@ -1,9 +1,9 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import { isSkuChoosable } from '../utils/skuHelper'; -const [sfc] = use('sku-row-item'); +const [createComponent] = createNamespace('sku-row-item'); -export default sfc({ +export default createComponent({ props: { skuList: Array, skuValue: Object, diff --git a/packages/sku/components/SkuStepper.js b/packages/sku/components/SkuStepper.js index 2d808a871..f0fa91239 100644 --- a/packages/sku/components/SkuStepper.js +++ b/packages/sku/components/SkuStepper.js @@ -1,11 +1,11 @@ -import { use } from '../../utils'; +import { createNamespace } from '../../utils'; import Stepper from '../../stepper'; import { LIMIT_TYPE } from '../constants'; -const [sfc] = use('sku-stepper'); +const [createComponent] = createNamespace('sku-stepper'); const { QUOTA_LIMIT, STOCK_LIMIT } = LIMIT_TYPE; -export default sfc({ +export default createComponent({ props: { quota: Number, quotaUsed: Number, diff --git a/packages/slider/index.js b/packages/slider/index.js index f13a28f1e..250474480 100644 --- a/packages/slider/index.js +++ b/packages/slider/index.js @@ -1,10 +1,10 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { TouchMixin } from '../mixins/touch'; import { preventDefault } from '../utils/dom/event'; -const [sfc, bem] = use('slider'); +const [createComponent, bem] = createNamespace('slider'); -export default sfc({ +export default createComponent({ mixins: [TouchMixin], props: { diff --git a/packages/step/index.js b/packages/step/index.js index eb27ad146..a7eb29311 100644 --- a/packages/step/index.js +++ b/packages/step/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import Icon from '../icon'; -const [sfc, bem] = use('step'); +const [createComponent, bem] = createNamespace('step'); -export default sfc({ +export default createComponent({ beforeCreate() { const { steps } = this.$parent; const index = this.$parent.slots().indexOf(this.$vnode); diff --git a/packages/stepper/index.js b/packages/stepper/index.js index 4375138d7..f354cadd9 100644 --- a/packages/stepper/index.js +++ b/packages/stepper/index.js @@ -1,8 +1,8 @@ -import { use, isDef, suffixPx } from '../utils'; +import { createNamespace, isDef, suffixPx } from '../utils'; -const [sfc, bem] = use('stepper'); +const [createComponent, bem] = createNamespace('stepper'); -export default sfc({ +export default createComponent({ props: { value: null, integer: Boolean, diff --git a/packages/steps/index.js b/packages/steps/index.js index d8729a590..d6893dd6a 100644 --- a/packages/steps/index.js +++ b/packages/steps/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { GREEN } from '../utils/color'; -const [sfc, bem] = use('steps'); +const [createComponent, bem] = createNamespace('steps'); -export default sfc({ +export default createComponent({ props: { active: Number, inactiveIcon: String, diff --git a/packages/submit-bar/index.tsx b/packages/submit-bar/index.tsx index 7794f4ff1..cb9e47f84 100644 --- a/packages/submit-bar/index.tsx +++ b/packages/submit-bar/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import Button, { ButtonType } from '../button'; import Icon from '../icon'; @@ -27,7 +27,7 @@ export type SubmitBarSlots = DefaultSlots & { tip?: ScopedSlot; }; -const [sfc, bem, t] = use('submit-bar'); +const [createComponent, bem, t] = createNamespace('submit-bar'); function SubmitBar( h: CreateElement, @@ -119,4 +119,4 @@ SubmitBar.props = { } }; -export default sfc(SubmitBar); +export default createComponent(SubmitBar); diff --git a/packages/swipe-cell/index.js b/packages/swipe-cell/index.js index 1d169aa30..1c81bb042 100644 --- a/packages/swipe-cell/index.js +++ b/packages/swipe-cell/index.js @@ -1,13 +1,13 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { range } from '../utils/format/number'; import { preventDefault } from '../utils/dom/event'; import { TouchMixin } from '../mixins/touch'; import { ClickOutsideMixin } from '../mixins/click-outside'; -const [sfc, bem] = use('swipe-cell'); +const [createComponent, bem] = createNamespace('swipe-cell'); const THRESHOLD = 0.15; -export default sfc({ +export default createComponent({ mixins: [ TouchMixin, ClickOutsideMixin({ diff --git a/packages/swipe-item/index.js b/packages/swipe-item/index.js index c6c91b9b4..30a3582aa 100644 --- a/packages/swipe-item/index.js +++ b/packages/swipe-item/index.js @@ -1,8 +1,8 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const [sfc, bem] = use('swipe-item'); +const [createComponent, bem] = createNamespace('swipe-item'); -export default sfc({ +export default createComponent({ data() { return { offset: 0 diff --git a/packages/swipe/index.js b/packages/swipe/index.js index b25b3300a..56ffe6b13 100644 --- a/packages/swipe/index.js +++ b/packages/swipe/index.js @@ -1,11 +1,11 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { preventDefault } from '../utils/dom/event'; import { TouchMixin } from '../mixins/touch'; import { BindEventMixin } from '../mixins/bind-event'; -const [sfc, bem] = use('swipe'); +const [createComponent, bem] = createNamespace('swipe'); -export default sfc({ +export default createComponent({ mixins: [ TouchMixin, BindEventMixin(function (bind, isBind) { diff --git a/packages/switch-cell/index.tsx b/packages/switch-cell/index.tsx index b5bd54322..c7589f737 100644 --- a/packages/switch-cell/index.tsx +++ b/packages/switch-cell/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit } from '../utils/functional'; import Cell from '../cell'; import Switch, { SwitchEvents } from '../switch'; @@ -15,7 +15,7 @@ export type SwitchCellProps = SharedSwitchProps & { cellSize?: string; }; -const [sfc, bem] = use('switch-cell'); +const [createComponent, bem] = createNamespace('switch-cell'); function SwitchCell( h: CreateElement, @@ -51,4 +51,4 @@ SwitchCell.props = { } }; -export default sfc(SwitchCell); +export default createComponent(SwitchCell); diff --git a/packages/switch/index.tsx b/packages/switch/index.tsx index 900b9ecc1..1ee5bd0a5 100644 --- a/packages/switch/index.tsx +++ b/packages/switch/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { BLUE, GRAY_DARK } from '../utils/color'; import { switchProps, SharedSwitchProps } from './shared'; import { emit, inherit } from '../utils/functional'; @@ -12,7 +12,7 @@ export type SwitchEvents = { onChange?(checked: boolean): void; }; -const [sfc, bem] = use('switch'); +const [createComponent, bem] = createNamespace('switch'); function Switch( h: CreateElement, @@ -69,4 +69,4 @@ function Switch( Switch.props = switchProps; -export default sfc(Switch); +export default createComponent(Switch); diff --git a/packages/tab/index.js b/packages/tab/index.js index 9d4a9db20..8ab0d2108 100644 --- a/packages/tab/index.js +++ b/packages/tab/index.js @@ -1,10 +1,10 @@ /* eslint-disable object-shorthand */ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('tab'); +const [createComponent, bem] = createNamespace('tab'); -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanTabs')], props: { diff --git a/packages/tabbar-item/index.js b/packages/tabbar-item/index.js index 53ed00b22..3f3170a90 100644 --- a/packages/tabbar-item/index.js +++ b/packages/tabbar-item/index.js @@ -1,12 +1,12 @@ -import { use, isObj } from '../utils'; +import { createNamespace, isObj } from '../utils'; import Icon from '../icon'; import Info from '../info'; import { route, routeProps } from '../utils/router'; import { ChildrenMixin } from '../mixins/relation'; -const [sfc, bem] = use('tabbar-item'); +const [createComponent, bem] = createNamespace('tabbar-item'); -export default sfc({ +export default createComponent({ mixins: [ChildrenMixin('vanTabbar')], props: { diff --git a/packages/tabbar/index.js b/packages/tabbar/index.js index dae4f069d..6020bec40 100644 --- a/packages/tabbar/index.js +++ b/packages/tabbar/index.js @@ -1,9 +1,9 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { ParentMixin } from '../mixins/relation'; -const [sfc, bem] = use('tabbar'); +const [createComponent, bem] = createNamespace('tabbar'); -export default sfc({ +export default createComponent({ mixins: [ParentMixin('vanTabbar')], props: { diff --git a/packages/tabs/Content.js b/packages/tabs/Content.js index cbc592921..c729031db 100644 --- a/packages/tabs/Content.js +++ b/packages/tabs/Content.js @@ -1,10 +1,10 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { TouchMixin } from '../mixins/touch'; -const [sfc, bem] = use('tabs'); +const [createComponent, bem] = createNamespace('tabs'); const MIN_SWIPE_DISTANCE = 50; -export default sfc({ +export default createComponent({ mixins: [TouchMixin], props: { diff --git a/packages/tabs/Title.js b/packages/tabs/Title.js index 7862ad64e..cbafd0f86 100644 --- a/packages/tabs/Title.js +++ b/packages/tabs/Title.js @@ -1,6 +1,6 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; -const bem = use('tab')[1]; +const bem = createNamespace('tab')[1]; export default { props: { diff --git a/packages/tabs/index.js b/packages/tabs/index.js index 36885d946..c717aa1c2 100644 --- a/packages/tabs/index.js +++ b/packages/tabs/index.js @@ -1,4 +1,4 @@ -import { use, isDef, suffixPx } from '../utils'; +import { createNamespace, isDef, suffixPx } from '../utils'; import { scrollLeftTo } from './utils'; import { on, off } from '../utils/dom/event'; import { ParentMixin } from '../mixins/relation'; @@ -12,9 +12,9 @@ import { import Title from './Title'; import Content from './Content'; -const [sfc, bem] = use('tabs'); +const [createComponent, bem] = createNamespace('tabs'); -export default sfc({ +export default createComponent({ mixins: [ ParentMixin('vanTabs'), BindEventMixin(function (bind, isBind) { diff --git a/packages/tag/index.tsx b/packages/tag/index.tsx index 1e6fe3d74..4d9b04f64 100644 --- a/packages/tag/index.tsx +++ b/packages/tag/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { inherit } from '../utils/functional'; import { RED, BLUE, GREEN, GRAY_DARK } from '../utils/color'; @@ -20,7 +20,7 @@ export type TagProps = { textColor?: string; }; -const [sfc, bem] = use('tag'); +const [createComponent, bem] = createNamespace('tag'); const COLOR_MAP: { [key: string]: string } = { danger: RED, @@ -75,4 +75,4 @@ Tag.props = { textColor: String }; -export default sfc(Tag); +export default createComponent(Tag); diff --git a/packages/toast/Toast.js b/packages/toast/Toast.js index 9557e3b0c..ec5de8d39 100644 --- a/packages/toast/Toast.js +++ b/packages/toast/Toast.js @@ -1,11 +1,11 @@ -import { use, isDef } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { PopupMixin } from '../mixins/popup'; import Icon from '../icon'; import Loading from '../loading'; -const [sfc, bem] = use('toast'); +const [createComponent, bem] = createNamespace('toast'); -export default sfc({ +export default createComponent({ mixins: [PopupMixin], props: { diff --git a/packages/tree-select/index.tsx b/packages/tree-select/index.tsx index 7d7191d12..1e2cc9a1b 100644 --- a/packages/tree-select/index.tsx +++ b/packages/tree-select/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { createNamespace } from '../utils'; import { emit, inherit } from '../utils/functional'; import Icon from '../icon'; @@ -25,7 +25,7 @@ export type TreeSelectProps = { mainActiveIndex: number; }; -const [sfc, bem] = use('tree-select'); +const [createComponent, bem] = createNamespace('tree-select'); function TreeSelect( h: CreateElement, @@ -102,4 +102,4 @@ TreeSelect.props = { } }; -export default sfc(TreeSelect); +export default createComponent(TreeSelect); diff --git a/packages/uploader/index.js b/packages/uploader/index.js index 76ab6f453..7ee5e51f8 100644 --- a/packages/uploader/index.js +++ b/packages/uploader/index.js @@ -1,16 +1,16 @@ -import { use, suffixPx } from '../utils'; +import { createNamespace, suffixPx } from '../utils'; import { toArray, readFile, isOversize } from './utils'; import Icon from '../icon'; import Image from '../image'; import ImagePreview from '../image-preview'; -const [sfc, bem] = use('uploader'); +const [createComponent, bem] = createNamespace('uploader'); function isImageDataUrl(dataUrl) { return dataUrl.indexOf('data:image') === 0; } -export default sfc({ +export default createComponent({ inheritAttrs: false, model: { diff --git a/packages/utils/use/bem.ts b/packages/utils/create/bem.ts similarity index 96% rename from packages/utils/use/bem.ts rename to packages/utils/create/bem.ts index 2ee97b1c0..137db92c3 100644 --- a/packages/utils/use/bem.ts +++ b/packages/utils/create/bem.ts @@ -36,7 +36,7 @@ function prefix(name: string, mods: Mods): Mods { return ret; } -export function useBEM(name: string) { +export function createBEM(name: string) { return function (el?: Mods, mods?: Mods): Mods { if (el && typeof el !== 'string') { mods = el; diff --git a/packages/utils/use/sfc.ts b/packages/utils/create/component.ts similarity index 98% rename from packages/utils/use/sfc.ts rename to packages/utils/create/component.ts index 945f49287..5dcf7b3c9 100644 --- a/packages/utils/use/sfc.ts +++ b/packages/utils/create/component.ts @@ -76,7 +76,7 @@ function transformFunctionComponent(pure: FunctionComponent): VantComponentOptio }; } -export function useSFC(name: string) { +export function createComponent(name: string) { return function ( sfc: VantComponentOptions | FunctionComponent ): TsxComponent { diff --git a/packages/utils/use/i18n.ts b/packages/utils/create/i18n.ts similarity index 89% rename from packages/utils/use/i18n.ts rename to packages/utils/create/i18n.ts index fec8eabc1..dc31f3fc3 100644 --- a/packages/utils/use/i18n.ts +++ b/packages/utils/create/i18n.ts @@ -2,7 +2,7 @@ import { get } from '..'; import { camelize } from '../format/string'; import locale from '../../locale'; -export function useI18N(name: string) { +export function createI18N(name: string) { const prefix = camelize(name) + '.'; return function (path: string, ...args: any[]): string { diff --git a/packages/utils/create/index.ts b/packages/utils/create/index.ts new file mode 100644 index 000000000..912080031 --- /dev/null +++ b/packages/utils/create/index.ts @@ -0,0 +1,14 @@ +import { createBEM } from './bem'; +import { createComponent } from './component'; +import { createI18N } from './i18n'; + +type CreateNamespaceReturn = [ + ReturnType, + ReturnType, + ReturnType +]; + +export function createNamespace(name: string): CreateNamespaceReturn { + name = 'van-' + name; + return [createComponent(name), createBEM(name), createI18N(name)]; +} diff --git a/packages/utils/index.ts b/packages/utils/index.ts index e881a3827..fed678f6f 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; -export { use } from './use'; +export { createNamespace } from './create'; export { suffixPx } from './format/unit'; export const isServer: boolean = Vue.prototype.$isServer; diff --git a/packages/utils/use/index.ts b/packages/utils/use/index.ts deleted file mode 100644 index 1cc093fb9..000000000 --- a/packages/utils/use/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useBEM } from './bem'; -import { useSFC } from './sfc'; -import { useI18N } from './i18n'; - -type UseReturn = [ - ReturnType, - ReturnType, - ReturnType -]; - -export function use(name: string): UseReturn { - name = 'van-' + name; - return [useSFC(name), useBEM(name), useI18N(name)]; -}