refactor: reorganize all components (#8303)

This commit is contained in:
neverland
2021-03-08 11:50:37 +08:00
committed by GitHub
parent 3144a63d2b
commit e540876398
193 changed files with 1307 additions and 400 deletions
-17
View File
@@ -1,17 +0,0 @@
/**
* Create a basic component with common options
*/
import { App, defineComponent, ComponentOptionsWithObjectProps } from 'vue';
import { camelize } from '../format/string';
export function createComponent(name: string) {
return function (sfc: ComponentOptionsWithObjectProps) {
sfc.name = name;
sfc.install = (app: App) => {
app.component(name as string, sfc);
app.component(camelize(`-${name}`), sfc);
};
return defineComponent(sfc);
} as typeof defineComponent;
}
+1 -6
View File
@@ -1,12 +1,7 @@
import { createBEM } from './bem';
import { createComponent } from './component';
import { createTranslate } from './translate';
export function createNamespace(name: string) {
name = 'van-' + name;
return [
createComponent(name),
createBEM(name),
createTranslate(name),
] as const;
return [name, createBEM(name), createTranslate(name)] as const;
}
+1
View File
@@ -1,5 +1,6 @@
export * from './base';
export * from './create';
export * from './installable';
export * from './format/unit';
export * from './format/number';
export * from './format/string';
+13
View File
@@ -0,0 +1,13 @@
import { App } from 'vue';
import { camelize } from './format/string';
export function installable<T>(options: T) {
return {
...options,
install(app: App) {
const { name } = options as any;
app.component(name, options);
app.component(camelize(`-${name}`), options);
},
};
}