@maple-design/cli-vue 0.0.0-stage → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -2
- package/README.zh-CN.md +305 -0
- package/bin/cli.mjs +5 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/lib/client/appType.d.ts +4 -0
- package/lib/client/appType.js +7 -0
- package/lib/client/index.d.ts +29 -0
- package/lib/client/index.js +170 -0
- package/lib/client/language.d.ts +11 -0
- package/lib/client/language.js +52 -0
- package/lib/client/theme-state.d.ts +3 -0
- package/lib/client/theme-state.js +6 -0
- package/lib/node/bin.d.ts +2 -0
- package/lib/node/bin.js +154 -0
- package/lib/node/commands/build.d.ts +1 -0
- package/lib/node/commands/build.js +15 -0
- package/lib/node/commands/checklist.d.ts +6 -0
- package/lib/node/commands/checklist.js +59 -0
- package/lib/node/commands/compile.d.ts +3 -0
- package/lib/node/commands/compile.js +41 -0
- package/lib/node/commands/create.d.ts +8 -0
- package/lib/node/commands/create.js +91 -0
- package/lib/node/commands/dev.d.ts +6 -0
- package/lib/node/commands/dev.js +58 -0
- package/lib/node/commands/extension.d.ts +3 -0
- package/lib/node/commands/extension.js +5 -0
- package/lib/node/commands/gen.d.ts +24 -0
- package/lib/node/commands/gen.js +91 -0
- package/lib/node/commands/icons.d.ts +4 -0
- package/lib/node/commands/icons.js +15 -0
- package/lib/node/commands/preview.d.ts +4 -0
- package/lib/node/commands/preview.js +18 -0
- package/lib/node/commands/styleVars.d.ts +1 -0
- package/lib/node/commands/styleVars.js +6 -0
- package/lib/node/commands/test.d.ts +7 -0
- package/lib/node/commands/test.js +16 -0
- package/lib/node/commands/vite.d.ts +2 -0
- package/lib/node/commands/vite.js +14 -0
- package/lib/node/compiler/compileModule.d.ts +4 -0
- package/lib/node/compiler/compileModule.js +78 -0
- package/lib/node/compiler/compileSFC.d.ts +6 -0
- package/lib/node/compiler/compileSFC.js +119 -0
- package/lib/node/compiler/compileScript.d.ts +27 -0
- package/lib/node/compiler/compileScript.js +221 -0
- package/lib/node/compiler/compileSiteEntry.d.ts +19 -0
- package/lib/node/compiler/compileSiteEntry.js +164 -0
- package/lib/node/compiler/compileStyle.d.ts +14 -0
- package/lib/node/compiler/compileStyle.js +55 -0
- package/lib/node/compiler/compileStyleVars.d.ts +3 -0
- package/lib/node/compiler/compileStyleVars.js +46 -0
- package/lib/node/compiler/compileTemplateHighlight.d.ts +18 -0
- package/lib/node/compiler/compileTemplateHighlight.js +133 -0
- package/lib/node/compiler/compileTypes.d.ts +2 -0
- package/lib/node/compiler/compileTypes.js +58 -0
- package/lib/node/compiler/generateLibraryEntry.d.ts +3 -0
- package/lib/node/compiler/generateLibraryEntry.js +152 -0
- package/lib/node/compiler/siteRoutes.d.ts +4 -0
- package/lib/node/compiler/siteRoutes.js +9 -0
- package/lib/node/config/maple.config.d.ts +215 -0
- package/lib/node/config/maple.config.js +32 -0
- package/lib/node/config/maple.default.config.d.ts +2 -0
- package/lib/node/config/maple.default.config.js +386 -0
- package/lib/node/config/site-resolver.d.ts +25 -0
- package/lib/node/config/site-resolver.js +138 -0
- package/lib/node/config/vite.config.d.ts +28 -0
- package/lib/node/config/vite.config.js +209 -0
- package/lib/node/config/vitest.config.d.ts +2 -0
- package/lib/node/config/vitest.config.js +54 -0
- package/lib/node/config/vitest.setup.d.ts +1 -0
- package/lib/node/config/vitest.setup.js +8 -0
- package/lib/node/index.d.ts +13 -0
- package/lib/node/index.js +13 -0
- package/lib/node/release/index.d.ts +20 -0
- package/lib/node/release/index.js +147 -0
- package/lib/node/shared/constant.d.ts +47 -0
- package/lib/node/shared/constant.js +53 -0
- package/lib/node/shared/fsUtils.d.ts +18 -0
- package/lib/node/shared/fsUtils.js +57 -0
- package/lib/node/shared/logger.d.ts +8 -0
- package/lib/node/shared/logger.js +18 -0
- package/lib/node/shared/serial-task.d.ts +2 -0
- package/lib/node/shared/serial-task.js +9 -0
- package/package.json +111 -3
- package/site/documentation-sections.spec.ts +45 -0
- package/site/documentation-sections.ts +48 -0
- package/site/index.html +89 -0
- package/site/mobile/App.vue +437 -0
- package/site/mobile/AppHome.vue +154 -0
- package/site/mobile/main.ts +99 -0
- package/site/mobile/route-sync.spec.ts +34 -0
- package/site/mobile/route-sync.ts +10 -0
- package/site/mobile.html +70 -0
- package/site/module.d.ts +5 -0
- package/site/pc/App.vue +44 -0
- package/site/pc/Layout.vue +641 -0
- package/site/pc/components/AppAd.vue +117 -0
- package/site/pc/components/AppHeader.vue +459 -0
- package/site/pc/components/AppMobile.spec.ts +204 -0
- package/site/pc/components/AppMobile.vue +201 -0
- package/site/pc/components/AppOutline.spec.ts +89 -0
- package/site/pc/components/AppOutline.vue +161 -0
- package/site/pc/components/AppSidebar.vue +144 -0
- package/site/pc/components/code-example/CodeExample.spec.ts +36 -0
- package/site/pc/components/code-example/CodeExample.vue +164 -0
- package/site/pc/components/code-example/codeExample.less +88 -0
- package/site/pc/components/code-example/index.ts +10 -0
- package/site/pc/components/demo-preview/DemoPreview.vue +92 -0
- package/site/pc/components/demo-preview/index.ts +8 -0
- package/site/pc/components/mobile-preview-url.ts +17 -0
- package/site/pc/components/preview-section.spec.ts +24 -0
- package/site/pc/components/preview-section.ts +23 -0
- package/site/pc/main.ts +108 -0
- package/site/pc/pages/index/index.vue +421 -0
- package/site/pc/pages/index/locale/en-US.ts +1 -0
- package/site/pc/pages/index/locale/zh-CN.ts +1 -0
- package/site/pc/responsive-layout.spec.ts +40 -0
- package/site/pc/route-state.spec.ts +34 -0
- package/site/pc/route-state.ts +25 -0
- package/site/pc/scroll-hash.spec.ts +49 -0
- package/site/pc/scroll-hash.ts +25 -0
- package/site/route-recovery.spec.ts +51 -0
- package/site/route-recovery.ts +38 -0
- package/site/tsconfig.json +16 -0
- package/site/types.ts +6 -0
- package/site/utils.ts +45 -0
- package/template/create/[ComponentName].tsx.ejs +16 -0
- package/template/create/[ComponentName].vue.ejs +21 -0
- package/template/create/[componentName].d.ts.ejs +13 -0
- package/template/create/__tests__/index.spec.js.ejs +10 -0
- package/template/create/docs/en-US.md +0 -0
- package/template/create/docs/zh-CN.md +0 -0
- package/template/create/example/index.vue.ejs +17 -0
- package/template/create/example/locale/_index.ts +17 -0
- package/template/create/example/locale/en-US.ts +3 -0
- package/template/create/example/locale/index.ts +24 -0
- package/template/create/example/locale/zh-CN.ts +3 -0
- package/template/create/index.ts.ejs +12 -0
- package/template/create/props.ts +1 -0
- package/template/create/style/[componentName].less.ejs +5 -0
- package/template/create/style/index.less.ejs +1 -0
- package/template/create/style/index.ts.ejs +1 -0
- package/template/generators/base/.browserslistrc +2 -0
- package/template/generators/base/.prettierignore +14 -0
- package/template/generators/base/README.md +90 -0
- package/template/generators/base/_gitignore +19 -0
- package/template/generators/base/eslint.config.js +15 -0
- package/template/generators/base/package.json +97 -0
- package/template/generators/base/prettier.config.js +3 -0
- package/template/generators/base/public/logo.svg +30 -0
- package/template/generators/base/shims/shims-md.d.ts +4 -0
- package/template/generators/base/shims/shims-vue.d.ts +6 -0
- package/template/generators/base/tsconfig.declaration.json +21 -0
- package/template/generators/base/tsconfig.json +28 -0
- package/template/generators/base/ui-build.config.mjs +16 -0
- package/template/generators/config/default/base/docs/home.zh-CN.md +3 -0
- package/template/generators/config/default/base/maple.config.mjs +49 -0
- package/template/generators/config/default/sfc/src/button/Button.vue +34 -0
- package/template/generators/config/default/sfc/src/button/__tests__/index.spec.js +8 -0
- package/template/generators/config/default/sfc/src/button/docs/zh-CN.md +39 -0
- package/template/generators/config/default/sfc/src/button/example/BasicUse.vue +7 -0
- package/template/generators/config/default/sfc/src/button/example/ModifyColor.vue +7 -0
- package/template/generators/config/default/sfc/src/button/example/index.vue +12 -0
- package/template/generators/config/default/sfc/src/button/index.ts +8 -0
- package/template/generators/config/default/sfc/src/button/style/button.less +14 -0
- package/template/generators/config/default/sfc/src/button/style/index.less +1 -0
- package/template/generators/config/default/sfc/src/button/style/index.ts +1 -0
- package/template/generators/config/default/sfc/src/utils/components.ts +20 -0
- package/template/generators/config/default/tsx/src/button/Button.tsx +30 -0
- package/template/generators/config/default/tsx/src/button/__tests__/index.spec.js +8 -0
- package/template/generators/config/default/tsx/src/button/docs/zh-CN.md +39 -0
- package/template/generators/config/default/tsx/src/button/example/BasicUse.vue +7 -0
- package/template/generators/config/default/tsx/src/button/example/ModifyColor.vue +7 -0
- package/template/generators/config/default/tsx/src/button/example/index.vue +12 -0
- package/template/generators/config/default/tsx/src/button/index.ts +8 -0
- package/template/generators/config/default/tsx/src/button/style/button.less +14 -0
- package/template/generators/config/default/tsx/src/button/style/index.less +1 -0
- package/template/generators/config/default/tsx/src/button/style/index.ts +1 -0
- package/template/generators/config/default/tsx/src/utils/components.ts +20 -0
- package/template/generators/config/i18n/base/docs/home.en-US.md +3 -0
- package/template/generators/config/i18n/base/docs/home.zh-CN.md +3 -0
- package/template/generators/config/i18n/base/maple.config.mjs +51 -0
- package/template/generators/config/i18n/sfc/src/button/Button.vue +38 -0
- package/template/generators/config/i18n/sfc/src/button/__tests__/index.spec.js +8 -0
- package/template/generators/config/i18n/sfc/src/button/docs/en-US.md +39 -0
- package/template/generators/config/i18n/sfc/src/button/docs/zh-CN.md +39 -0
- package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +11 -0
- package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +11 -0
- package/template/generators/config/i18n/sfc/src/button/example/index.vue +15 -0
- package/template/generators/config/i18n/sfc/src/button/example/locale/en-US.ts +5 -0
- package/template/generators/config/i18n/sfc/src/button/example/locale/index.ts +23 -0
- package/template/generators/config/i18n/sfc/src/button/example/locale/zh-CN.ts +5 -0
- package/template/generators/config/i18n/sfc/src/button/index.ts +8 -0
- package/template/generators/config/i18n/sfc/src/button/style/button.less +14 -0
- package/template/generators/config/i18n/sfc/src/button/style/index.less +1 -0
- package/template/generators/config/i18n/sfc/src/button/style/index.ts +1 -0
- package/template/generators/config/i18n/sfc/src/locale/__tests__/index.spec.js +52 -0
- package/template/generators/config/i18n/sfc/src/locale/docs/en-US.md +26 -0
- package/template/generators/config/i18n/sfc/src/locale/docs/zh-CN.md +25 -0
- package/template/generators/config/i18n/sfc/src/locale/en-US.d.ts +5 -0
- package/template/generators/config/i18n/sfc/src/locale/en-US.ts +7 -0
- package/template/generators/config/i18n/sfc/src/locale/index.ts +82 -0
- package/template/generators/config/i18n/sfc/src/locale/zh-CN.d.ts +5 -0
- package/template/generators/config/i18n/sfc/src/locale/zh-CN.ts +7 -0
- package/template/generators/config/i18n/sfc/src/utils/components.ts +20 -0
- package/template/generators/config/i18n/tsx/src/button/Button.tsx +35 -0
- package/template/generators/config/i18n/tsx/src/button/__tests__/index.spec.js +8 -0
- package/template/generators/config/i18n/tsx/src/button/docs/en-US.md +39 -0
- package/template/generators/config/i18n/tsx/src/button/docs/zh-CN.md +39 -0
- package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +11 -0
- package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +11 -0
- package/template/generators/config/i18n/tsx/src/button/example/index.vue +15 -0
- package/template/generators/config/i18n/tsx/src/button/example/locale/en-US.ts +5 -0
- package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -0
- package/template/generators/config/i18n/tsx/src/button/example/locale/zh-CN.ts +5 -0
- package/template/generators/config/i18n/tsx/src/button/index.ts +8 -0
- package/template/generators/config/i18n/tsx/src/button/style/button.less +14 -0
- package/template/generators/config/i18n/tsx/src/button/style/index.less +1 -0
- package/template/generators/config/i18n/tsx/src/button/style/index.ts +1 -0
- package/template/generators/config/i18n/tsx/src/locale/__tests__/index.spec.js +52 -0
- package/template/generators/config/i18n/tsx/src/locale/docs/en-US.md +26 -0
- package/template/generators/config/i18n/tsx/src/locale/docs/zh-CN.md +25 -0
- package/template/generators/config/i18n/tsx/src/locale/en-US.d.ts +5 -0
- package/template/generators/config/i18n/tsx/src/locale/en-US.ts +7 -0
- package/template/generators/config/i18n/tsx/src/locale/index.ts +82 -0
- package/template/generators/config/i18n/tsx/src/locale/zh-CN.d.ts +5 -0
- package/template/generators/config/i18n/tsx/src/locale/zh-CN.ts +7 -0
- package/template/generators/config/i18n/tsx/src/utils/components.ts +20 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "types-generated",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
8
|
+
"noEmit": false,
|
|
9
|
+
"noEmitOnError": true
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.ts",
|
|
13
|
+
"src/**/*.tsx",
|
|
14
|
+
"src/**/*.vue"
|
|
15
|
+
],
|
|
16
|
+
"exclude": [
|
|
17
|
+
"src/**/__tests__/**",
|
|
18
|
+
"src/**/example/**",
|
|
19
|
+
"src/**/__demos__/**"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"downlevelIteration": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"lib": [
|
|
10
|
+
"esnext",
|
|
11
|
+
"dom"
|
|
12
|
+
],
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"jsxImportSource": "vue",
|
|
15
|
+
"jsx": "preserve",
|
|
16
|
+
"types": [
|
|
17
|
+
"vitest/globals"
|
|
18
|
+
],
|
|
19
|
+
"target": "ES2020",
|
|
20
|
+
"module": "ESNext",
|
|
21
|
+
"moduleResolution": "Bundler"
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
"src/**/*.ts",
|
|
25
|
+
"src/**/*.tsx",
|
|
26
|
+
"src/**/*.vue"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
const root = fileURLToPath(new URL('.', import.meta.url))
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
root,
|
|
9
|
+
name: pkg.name,
|
|
10
|
+
globalName: 'ComponentLibrary',
|
|
11
|
+
bundleName: 'library',
|
|
12
|
+
emitTypes: false,
|
|
13
|
+
vueSfcStyles: false,
|
|
14
|
+
external: ['vue', ...Object.keys(pkg.dependencies ?? {})],
|
|
15
|
+
globals: { vue: 'Vue' },
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineConfig } from '@maple-design/cli-vue'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
namespace: 'va',
|
|
5
|
+
logo: './logo.svg',
|
|
6
|
+
useMobile: true,
|
|
7
|
+
pc: {
|
|
8
|
+
header: {
|
|
9
|
+
darkMode: null,
|
|
10
|
+
i18n: null,
|
|
11
|
+
playground: null,
|
|
12
|
+
versions: null,
|
|
13
|
+
},
|
|
14
|
+
menu: [
|
|
15
|
+
{
|
|
16
|
+
text: {
|
|
17
|
+
'zh-CN': '开发指南',
|
|
18
|
+
},
|
|
19
|
+
type: 1,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
text: {
|
|
23
|
+
'zh-CN': '基本介绍',
|
|
24
|
+
},
|
|
25
|
+
doc: 'home-fill',
|
|
26
|
+
type: 3,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
text: {
|
|
30
|
+
'zh-CN': '基础组件',
|
|
31
|
+
},
|
|
32
|
+
type: 1,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: {
|
|
36
|
+
'zh-CN': 'Button 按钮',
|
|
37
|
+
},
|
|
38
|
+
doc: 'button',
|
|
39
|
+
type: 2,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
mobile: {
|
|
44
|
+
header: {
|
|
45
|
+
i18n: null,
|
|
46
|
+
darkMode: null,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button :class="n()" :style="{ background: color }" @click="handleClick">
|
|
3
|
+
<slot />
|
|
4
|
+
</button>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { defineComponent, PropType } from 'vue'
|
|
9
|
+
import { createNamespace } from '../utils/components'
|
|
10
|
+
|
|
11
|
+
const { name, n, classes } = createNamespace('button')
|
|
12
|
+
|
|
13
|
+
export default defineComponent({
|
|
14
|
+
name,
|
|
15
|
+
props: {
|
|
16
|
+
color: {
|
|
17
|
+
type: String,
|
|
18
|
+
},
|
|
19
|
+
onClick: {
|
|
20
|
+
type: Function as PropType<(e: Event) => void>,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
setup(props) {
|
|
24
|
+
const handleClick = (e: Event) => {
|
|
25
|
+
props.onClick?.(e)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
n,
|
|
30
|
+
handleClick,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 按钮
|
|
2
|
+
|
|
3
|
+
### 基本使用
|
|
4
|
+
```html
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```vue
|
|
9
|
+
import BasicUse from '../example/BasicUse'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### 主题色按钮
|
|
13
|
+
```html
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
import ModifyColor from '../example/ModifyColor'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Button Props
|
|
24
|
+
|
|
25
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| `color` | 按钮颜色 | _string_ | `default` |
|
|
28
|
+
|
|
29
|
+
### Button Events
|
|
30
|
+
|
|
31
|
+
| 事件名 | 说明 | 参数 |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `click` | 点击按钮时触发 | `event: Event` |
|
|
34
|
+
|
|
35
|
+
### Button Slots
|
|
36
|
+
|
|
37
|
+
| 插槽名 | 说明 | 参数 |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `default` | 按钮内容 | `-` |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { AppType } from '@maple-design/cli-vue/client'
|
|
3
|
+
import VaButton from '..'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<app-type>基本使用</app-type>
|
|
8
|
+
<va-button>起步</va-button>
|
|
9
|
+
|
|
10
|
+
<app-type>修改颜色</app-type>
|
|
11
|
+
<va-button color="#03A9F4">起步</va-button>
|
|
12
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { App, Component, Plugin } from 'vue'
|
|
2
|
+
import { createNamespaceFn } from '@maple-design/shared-vue'
|
|
3
|
+
|
|
4
|
+
export type ComponentWithInstall<T> = T & Plugin
|
|
5
|
+
|
|
6
|
+
export function withInstall<T = Component>(component: Component, target?: T): ComponentWithInstall<T> {
|
|
7
|
+
const componentWithInstall = target ?? component
|
|
8
|
+
|
|
9
|
+
;(componentWithInstall as ComponentWithInstall<T>).install = function (app: App) {
|
|
10
|
+
const { name } = component
|
|
11
|
+
|
|
12
|
+
if (name) {
|
|
13
|
+
app.component(name, component)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return componentWithInstall as ComponentWithInstall<T>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const createNamespace = createNamespaceFn('va')
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineComponent, PropType } from 'vue'
|
|
2
|
+
import { createNamespace } from '../utils/components'
|
|
3
|
+
import './style'
|
|
4
|
+
|
|
5
|
+
const { name, n, classes } = createNamespace('button')
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name,
|
|
9
|
+
props: {
|
|
10
|
+
color: {
|
|
11
|
+
type: String,
|
|
12
|
+
},
|
|
13
|
+
onClick: {
|
|
14
|
+
type: Function as PropType<(e: Event) => void>,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
setup(props, { slots }) {
|
|
18
|
+
const handleClick = (e: Event) => props.onClick?.(e)
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
const { color } = props
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<button class={n()} style={{ background: color }} onClick={handleClick}>
|
|
25
|
+
{slots.default?.()}
|
|
26
|
+
</button>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 按钮
|
|
2
|
+
|
|
3
|
+
### 基本使用
|
|
4
|
+
```html
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```vue
|
|
9
|
+
import BasicUse from '../example/BasicUse'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### 主题色按钮
|
|
13
|
+
```html
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
import ModifyColor from '../example/ModifyColor'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Button Props
|
|
24
|
+
|
|
25
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| `color` | 按钮颜色 | _string_ | `default` |
|
|
28
|
+
|
|
29
|
+
### Button Events
|
|
30
|
+
|
|
31
|
+
| 事件名 | 说明 | 参数 |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `click` | 点击按钮时触发 | `event: Event` |
|
|
34
|
+
|
|
35
|
+
### Button Slots
|
|
36
|
+
|
|
37
|
+
| 插槽名 | 说明 | 参数 |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `default` | 按钮内容 | `-` |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { AppType } from '@maple-design/cli-vue/client'
|
|
3
|
+
import VaButton from '..'
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<app-type>基本使用</app-type>
|
|
8
|
+
<va-button>起步</va-button>
|
|
9
|
+
|
|
10
|
+
<app-type>修改颜色</app-type>
|
|
11
|
+
<va-button color="#03A9F4">起步</va-button>
|
|
12
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { App, Component, Plugin } from 'vue'
|
|
2
|
+
import { createNamespaceFn } from '@maple-design/shared-vue'
|
|
3
|
+
|
|
4
|
+
export type ComponentWithInstall<T> = T & Plugin
|
|
5
|
+
|
|
6
|
+
export function withInstall<T = Component>(component: Component, target?: T): ComponentWithInstall<T> {
|
|
7
|
+
const componentWithInstall = target ?? component
|
|
8
|
+
|
|
9
|
+
;(componentWithInstall as ComponentWithInstall<T>).install = function (app: App) {
|
|
10
|
+
const { name } = component
|
|
11
|
+
|
|
12
|
+
if (name) {
|
|
13
|
+
app.component(name, component)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return componentWithInstall as ComponentWithInstall<T>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const createNamespace = createNamespaceFn('va')
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineConfig } from '@maple-design/cli-vue'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
namespace: 'va',
|
|
5
|
+
logo: './logo.svg',
|
|
6
|
+
useMobile: true,
|
|
7
|
+
pc: {
|
|
8
|
+
header: {
|
|
9
|
+
darkMode: null,
|
|
10
|
+
playground: null,
|
|
11
|
+
versions: null,
|
|
12
|
+
},
|
|
13
|
+
menu: [
|
|
14
|
+
{
|
|
15
|
+
text: {
|
|
16
|
+
'zh-CN': '开发指南',
|
|
17
|
+
'en-US': 'Developer Guide',
|
|
18
|
+
},
|
|
19
|
+
type: 1,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
text: {
|
|
23
|
+
'zh-CN': '基本介绍',
|
|
24
|
+
'en-US': 'Basic Introduce',
|
|
25
|
+
},
|
|
26
|
+
doc: 'home-fill',
|
|
27
|
+
type: 3,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
text: {
|
|
31
|
+
'zh-CN': '基础组件',
|
|
32
|
+
'en-US': 'Basic Components',
|
|
33
|
+
},
|
|
34
|
+
type: 1,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
text: {
|
|
38
|
+
'zh-CN': 'Button 按钮',
|
|
39
|
+
'en-US': 'Button',
|
|
40
|
+
},
|
|
41
|
+
doc: 'button',
|
|
42
|
+
type: 2,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
mobile: {
|
|
47
|
+
header: {
|
|
48
|
+
darkMode: null,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button :class="n()" :style="{ background: color }" @click="handleClick">
|
|
3
|
+
{{ t('button') }}
|
|
4
|
+
<slot />
|
|
5
|
+
</button>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { defineComponent, PropType } from 'vue'
|
|
10
|
+
// i18n for component's internal
|
|
11
|
+
import { t } from '../locale'
|
|
12
|
+
import { createNamespace } from '../utils/components'
|
|
13
|
+
|
|
14
|
+
const { name, n, classes } = createNamespace('button')
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name,
|
|
18
|
+
props: {
|
|
19
|
+
color: {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
onClick: {
|
|
23
|
+
type: Function as PropType<(e: Event) => void>,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
setup(props) {
|
|
27
|
+
const handleClick = (e: Event) => {
|
|
28
|
+
props.onClick?.(e)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
t,
|
|
33
|
+
n,
|
|
34
|
+
handleClick,
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
### Basic Use
|
|
4
|
+
```html
|
|
5
|
+
<va-button>start</va-button>
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```vue
|
|
9
|
+
import BasicUse from '../example/BasicUse'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Theme Color Button
|
|
13
|
+
```html
|
|
14
|
+
<va-button color="#009688">start</va-button>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
import ModifyColor from '../example/ModifyColor'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Button Props
|
|
24
|
+
|
|
25
|
+
| Prop | Description | Type | Default |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| `color` | Button background color | _string_ | `default` |
|
|
28
|
+
|
|
29
|
+
### Button Events
|
|
30
|
+
|
|
31
|
+
| Event | Description | Arguments |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `click` | Triggered when the button is clicked | `event: Event` |
|
|
34
|
+
|
|
35
|
+
### Button Slots
|
|
36
|
+
|
|
37
|
+
| Slot | Description | Arguments |
|
|
38
|
+
|-----------| --- | --- |
|
|
39
|
+
| `default` | Button content | `-` |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 按钮
|
|
2
|
+
|
|
3
|
+
### 基本使用
|
|
4
|
+
```html
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```vue
|
|
9
|
+
import BasicUse from '../example/BasicUse'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### 主题色按钮
|
|
13
|
+
```html
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
import ModifyColor from '../example/ModifyColor'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Button Props
|
|
24
|
+
|
|
25
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| `color` | 按钮颜色 | _string_ | `default` |
|
|
28
|
+
|
|
29
|
+
### Button Events
|
|
30
|
+
|
|
31
|
+
| 事件名 | 说明 | 参数 |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `click` | 点击按钮时触发 | `event: Event` |
|
|
34
|
+
|
|
35
|
+
### Button Slots
|
|
36
|
+
|
|
37
|
+
| 插槽名 | 说明 | 参数 |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `default` | 按钮内容 | `-` |
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { watchLang } from '@maple-design/cli-vue/client'
|
|
3
|
+
import VaButton from '..'
|
|
4
|
+
import { t, use } from './locale'
|
|
5
|
+
|
|
6
|
+
watchLang(use, 'pc')
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<va-button color="#03A9F4">{{ t('start') }}</va-button>
|
|
11
|
+
</template>
|