[improvement] rename use to createNamespace (#3658)
This commit is contained in:
@@ -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;
|
||||
@@ -76,7 +76,7 @@ function transformFunctionComponent(pure: FunctionComponent): VantComponentOptio
|
||||
};
|
||||
}
|
||||
|
||||
export function useSFC(name: string) {
|
||||
export function createComponent(name: string) {
|
||||
return function<Props = DefaultProps, Events = {}, Slots = {}> (
|
||||
sfc: VantComponentOptions | FunctionComponent
|
||||
): TsxComponent<Props, Events, Slots> {
|
||||
@@ -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 {
|
||||
@@ -0,0 +1,14 @@
|
||||
import { createBEM } from './bem';
|
||||
import { createComponent } from './component';
|
||||
import { createI18N } from './i18n';
|
||||
|
||||
type CreateNamespaceReturn = [
|
||||
ReturnType<typeof createComponent>,
|
||||
ReturnType<typeof createBEM>,
|
||||
ReturnType<typeof createI18N>
|
||||
];
|
||||
|
||||
export function createNamespace(name: string): CreateNamespaceReturn {
|
||||
name = 'van-' + name;
|
||||
return [createComponent(name), createBEM(name), createI18N(name)];
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { useBEM } from './bem';
|
||||
import { useSFC } from './sfc';
|
||||
import { useI18N } from './i18n';
|
||||
|
||||
type UseReturn = [
|
||||
ReturnType<typeof useSFC>,
|
||||
ReturnType<typeof useBEM>,
|
||||
ReturnType<typeof useI18N>
|
||||
];
|
||||
|
||||
export function use(name: string): UseReturn {
|
||||
name = 'van-' + name;
|
||||
return [useSFC(name), useBEM(name), useI18N(name)];
|
||||
}
|
||||
Reference in New Issue
Block a user