@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.
Files changed (228) hide show
  1. package/README.md +305 -2
  2. package/README.zh-CN.md +305 -0
  3. package/bin/cli.mjs +5 -0
  4. package/client.d.ts +1 -0
  5. package/client.js +1 -0
  6. package/lib/client/appType.d.ts +4 -0
  7. package/lib/client/appType.js +7 -0
  8. package/lib/client/index.d.ts +29 -0
  9. package/lib/client/index.js +170 -0
  10. package/lib/client/language.d.ts +11 -0
  11. package/lib/client/language.js +52 -0
  12. package/lib/client/theme-state.d.ts +3 -0
  13. package/lib/client/theme-state.js +6 -0
  14. package/lib/node/bin.d.ts +2 -0
  15. package/lib/node/bin.js +154 -0
  16. package/lib/node/commands/build.d.ts +1 -0
  17. package/lib/node/commands/build.js +15 -0
  18. package/lib/node/commands/checklist.d.ts +6 -0
  19. package/lib/node/commands/checklist.js +59 -0
  20. package/lib/node/commands/compile.d.ts +3 -0
  21. package/lib/node/commands/compile.js +41 -0
  22. package/lib/node/commands/create.d.ts +8 -0
  23. package/lib/node/commands/create.js +91 -0
  24. package/lib/node/commands/dev.d.ts +6 -0
  25. package/lib/node/commands/dev.js +58 -0
  26. package/lib/node/commands/extension.d.ts +3 -0
  27. package/lib/node/commands/extension.js +5 -0
  28. package/lib/node/commands/gen.d.ts +24 -0
  29. package/lib/node/commands/gen.js +91 -0
  30. package/lib/node/commands/icons.d.ts +4 -0
  31. package/lib/node/commands/icons.js +15 -0
  32. package/lib/node/commands/preview.d.ts +4 -0
  33. package/lib/node/commands/preview.js +18 -0
  34. package/lib/node/commands/styleVars.d.ts +1 -0
  35. package/lib/node/commands/styleVars.js +6 -0
  36. package/lib/node/commands/test.d.ts +7 -0
  37. package/lib/node/commands/test.js +16 -0
  38. package/lib/node/commands/vite.d.ts +2 -0
  39. package/lib/node/commands/vite.js +14 -0
  40. package/lib/node/compiler/compileModule.d.ts +4 -0
  41. package/lib/node/compiler/compileModule.js +78 -0
  42. package/lib/node/compiler/compileSFC.d.ts +6 -0
  43. package/lib/node/compiler/compileSFC.js +119 -0
  44. package/lib/node/compiler/compileScript.d.ts +27 -0
  45. package/lib/node/compiler/compileScript.js +221 -0
  46. package/lib/node/compiler/compileSiteEntry.d.ts +19 -0
  47. package/lib/node/compiler/compileSiteEntry.js +164 -0
  48. package/lib/node/compiler/compileStyle.d.ts +14 -0
  49. package/lib/node/compiler/compileStyle.js +55 -0
  50. package/lib/node/compiler/compileStyleVars.d.ts +3 -0
  51. package/lib/node/compiler/compileStyleVars.js +46 -0
  52. package/lib/node/compiler/compileTemplateHighlight.d.ts +18 -0
  53. package/lib/node/compiler/compileTemplateHighlight.js +133 -0
  54. package/lib/node/compiler/compileTypes.d.ts +2 -0
  55. package/lib/node/compiler/compileTypes.js +58 -0
  56. package/lib/node/compiler/generateLibraryEntry.d.ts +3 -0
  57. package/lib/node/compiler/generateLibraryEntry.js +152 -0
  58. package/lib/node/compiler/siteRoutes.d.ts +4 -0
  59. package/lib/node/compiler/siteRoutes.js +9 -0
  60. package/lib/node/config/maple.config.d.ts +215 -0
  61. package/lib/node/config/maple.config.js +32 -0
  62. package/lib/node/config/maple.default.config.d.ts +2 -0
  63. package/lib/node/config/maple.default.config.js +386 -0
  64. package/lib/node/config/site-resolver.d.ts +25 -0
  65. package/lib/node/config/site-resolver.js +138 -0
  66. package/lib/node/config/vite.config.d.ts +28 -0
  67. package/lib/node/config/vite.config.js +209 -0
  68. package/lib/node/config/vitest.config.d.ts +2 -0
  69. package/lib/node/config/vitest.config.js +54 -0
  70. package/lib/node/config/vitest.setup.d.ts +1 -0
  71. package/lib/node/config/vitest.setup.js +8 -0
  72. package/lib/node/index.d.ts +13 -0
  73. package/lib/node/index.js +13 -0
  74. package/lib/node/release/index.d.ts +20 -0
  75. package/lib/node/release/index.js +147 -0
  76. package/lib/node/shared/constant.d.ts +47 -0
  77. package/lib/node/shared/constant.js +53 -0
  78. package/lib/node/shared/fsUtils.d.ts +18 -0
  79. package/lib/node/shared/fsUtils.js +57 -0
  80. package/lib/node/shared/logger.d.ts +8 -0
  81. package/lib/node/shared/logger.js +18 -0
  82. package/lib/node/shared/serial-task.d.ts +2 -0
  83. package/lib/node/shared/serial-task.js +9 -0
  84. package/package.json +111 -3
  85. package/site/documentation-sections.spec.ts +45 -0
  86. package/site/documentation-sections.ts +48 -0
  87. package/site/index.html +89 -0
  88. package/site/mobile/App.vue +437 -0
  89. package/site/mobile/AppHome.vue +154 -0
  90. package/site/mobile/main.ts +99 -0
  91. package/site/mobile/route-sync.spec.ts +34 -0
  92. package/site/mobile/route-sync.ts +10 -0
  93. package/site/mobile.html +70 -0
  94. package/site/module.d.ts +5 -0
  95. package/site/pc/App.vue +44 -0
  96. package/site/pc/Layout.vue +641 -0
  97. package/site/pc/components/AppAd.vue +117 -0
  98. package/site/pc/components/AppHeader.vue +459 -0
  99. package/site/pc/components/AppMobile.spec.ts +204 -0
  100. package/site/pc/components/AppMobile.vue +201 -0
  101. package/site/pc/components/AppOutline.spec.ts +89 -0
  102. package/site/pc/components/AppOutline.vue +161 -0
  103. package/site/pc/components/AppSidebar.vue +144 -0
  104. package/site/pc/components/code-example/CodeExample.spec.ts +36 -0
  105. package/site/pc/components/code-example/CodeExample.vue +164 -0
  106. package/site/pc/components/code-example/codeExample.less +88 -0
  107. package/site/pc/components/code-example/index.ts +10 -0
  108. package/site/pc/components/demo-preview/DemoPreview.vue +92 -0
  109. package/site/pc/components/demo-preview/index.ts +8 -0
  110. package/site/pc/components/mobile-preview-url.ts +17 -0
  111. package/site/pc/components/preview-section.spec.ts +24 -0
  112. package/site/pc/components/preview-section.ts +23 -0
  113. package/site/pc/main.ts +108 -0
  114. package/site/pc/pages/index/index.vue +421 -0
  115. package/site/pc/pages/index/locale/en-US.ts +1 -0
  116. package/site/pc/pages/index/locale/zh-CN.ts +1 -0
  117. package/site/pc/responsive-layout.spec.ts +40 -0
  118. package/site/pc/route-state.spec.ts +34 -0
  119. package/site/pc/route-state.ts +25 -0
  120. package/site/pc/scroll-hash.spec.ts +49 -0
  121. package/site/pc/scroll-hash.ts +25 -0
  122. package/site/route-recovery.spec.ts +51 -0
  123. package/site/route-recovery.ts +38 -0
  124. package/site/tsconfig.json +16 -0
  125. package/site/types.ts +6 -0
  126. package/site/utils.ts +45 -0
  127. package/template/create/[ComponentName].tsx.ejs +16 -0
  128. package/template/create/[ComponentName].vue.ejs +21 -0
  129. package/template/create/[componentName].d.ts.ejs +13 -0
  130. package/template/create/__tests__/index.spec.js.ejs +10 -0
  131. package/template/create/docs/en-US.md +0 -0
  132. package/template/create/docs/zh-CN.md +0 -0
  133. package/template/create/example/index.vue.ejs +17 -0
  134. package/template/create/example/locale/_index.ts +17 -0
  135. package/template/create/example/locale/en-US.ts +3 -0
  136. package/template/create/example/locale/index.ts +24 -0
  137. package/template/create/example/locale/zh-CN.ts +3 -0
  138. package/template/create/index.ts.ejs +12 -0
  139. package/template/create/props.ts +1 -0
  140. package/template/create/style/[componentName].less.ejs +5 -0
  141. package/template/create/style/index.less.ejs +1 -0
  142. package/template/create/style/index.ts.ejs +1 -0
  143. package/template/generators/base/.browserslistrc +2 -0
  144. package/template/generators/base/.prettierignore +14 -0
  145. package/template/generators/base/README.md +90 -0
  146. package/template/generators/base/_gitignore +19 -0
  147. package/template/generators/base/eslint.config.js +15 -0
  148. package/template/generators/base/package.json +97 -0
  149. package/template/generators/base/prettier.config.js +3 -0
  150. package/template/generators/base/public/logo.svg +30 -0
  151. package/template/generators/base/shims/shims-md.d.ts +4 -0
  152. package/template/generators/base/shims/shims-vue.d.ts +6 -0
  153. package/template/generators/base/tsconfig.declaration.json +21 -0
  154. package/template/generators/base/tsconfig.json +28 -0
  155. package/template/generators/base/ui-build.config.mjs +16 -0
  156. package/template/generators/config/default/base/docs/home.zh-CN.md +3 -0
  157. package/template/generators/config/default/base/maple.config.mjs +49 -0
  158. package/template/generators/config/default/sfc/src/button/Button.vue +34 -0
  159. package/template/generators/config/default/sfc/src/button/__tests__/index.spec.js +8 -0
  160. package/template/generators/config/default/sfc/src/button/docs/zh-CN.md +39 -0
  161. package/template/generators/config/default/sfc/src/button/example/BasicUse.vue +7 -0
  162. package/template/generators/config/default/sfc/src/button/example/ModifyColor.vue +7 -0
  163. package/template/generators/config/default/sfc/src/button/example/index.vue +12 -0
  164. package/template/generators/config/default/sfc/src/button/index.ts +8 -0
  165. package/template/generators/config/default/sfc/src/button/style/button.less +14 -0
  166. package/template/generators/config/default/sfc/src/button/style/index.less +1 -0
  167. package/template/generators/config/default/sfc/src/button/style/index.ts +1 -0
  168. package/template/generators/config/default/sfc/src/utils/components.ts +20 -0
  169. package/template/generators/config/default/tsx/src/button/Button.tsx +30 -0
  170. package/template/generators/config/default/tsx/src/button/__tests__/index.spec.js +8 -0
  171. package/template/generators/config/default/tsx/src/button/docs/zh-CN.md +39 -0
  172. package/template/generators/config/default/tsx/src/button/example/BasicUse.vue +7 -0
  173. package/template/generators/config/default/tsx/src/button/example/ModifyColor.vue +7 -0
  174. package/template/generators/config/default/tsx/src/button/example/index.vue +12 -0
  175. package/template/generators/config/default/tsx/src/button/index.ts +8 -0
  176. package/template/generators/config/default/tsx/src/button/style/button.less +14 -0
  177. package/template/generators/config/default/tsx/src/button/style/index.less +1 -0
  178. package/template/generators/config/default/tsx/src/button/style/index.ts +1 -0
  179. package/template/generators/config/default/tsx/src/utils/components.ts +20 -0
  180. package/template/generators/config/i18n/base/docs/home.en-US.md +3 -0
  181. package/template/generators/config/i18n/base/docs/home.zh-CN.md +3 -0
  182. package/template/generators/config/i18n/base/maple.config.mjs +51 -0
  183. package/template/generators/config/i18n/sfc/src/button/Button.vue +38 -0
  184. package/template/generators/config/i18n/sfc/src/button/__tests__/index.spec.js +8 -0
  185. package/template/generators/config/i18n/sfc/src/button/docs/en-US.md +39 -0
  186. package/template/generators/config/i18n/sfc/src/button/docs/zh-CN.md +39 -0
  187. package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +11 -0
  188. package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +11 -0
  189. package/template/generators/config/i18n/sfc/src/button/example/index.vue +15 -0
  190. package/template/generators/config/i18n/sfc/src/button/example/locale/en-US.ts +5 -0
  191. package/template/generators/config/i18n/sfc/src/button/example/locale/index.ts +23 -0
  192. package/template/generators/config/i18n/sfc/src/button/example/locale/zh-CN.ts +5 -0
  193. package/template/generators/config/i18n/sfc/src/button/index.ts +8 -0
  194. package/template/generators/config/i18n/sfc/src/button/style/button.less +14 -0
  195. package/template/generators/config/i18n/sfc/src/button/style/index.less +1 -0
  196. package/template/generators/config/i18n/sfc/src/button/style/index.ts +1 -0
  197. package/template/generators/config/i18n/sfc/src/locale/__tests__/index.spec.js +52 -0
  198. package/template/generators/config/i18n/sfc/src/locale/docs/en-US.md +26 -0
  199. package/template/generators/config/i18n/sfc/src/locale/docs/zh-CN.md +25 -0
  200. package/template/generators/config/i18n/sfc/src/locale/en-US.d.ts +5 -0
  201. package/template/generators/config/i18n/sfc/src/locale/en-US.ts +7 -0
  202. package/template/generators/config/i18n/sfc/src/locale/index.ts +82 -0
  203. package/template/generators/config/i18n/sfc/src/locale/zh-CN.d.ts +5 -0
  204. package/template/generators/config/i18n/sfc/src/locale/zh-CN.ts +7 -0
  205. package/template/generators/config/i18n/sfc/src/utils/components.ts +20 -0
  206. package/template/generators/config/i18n/tsx/src/button/Button.tsx +35 -0
  207. package/template/generators/config/i18n/tsx/src/button/__tests__/index.spec.js +8 -0
  208. package/template/generators/config/i18n/tsx/src/button/docs/en-US.md +39 -0
  209. package/template/generators/config/i18n/tsx/src/button/docs/zh-CN.md +39 -0
  210. package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +11 -0
  211. package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +11 -0
  212. package/template/generators/config/i18n/tsx/src/button/example/index.vue +15 -0
  213. package/template/generators/config/i18n/tsx/src/button/example/locale/en-US.ts +5 -0
  214. package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -0
  215. package/template/generators/config/i18n/tsx/src/button/example/locale/zh-CN.ts +5 -0
  216. package/template/generators/config/i18n/tsx/src/button/index.ts +8 -0
  217. package/template/generators/config/i18n/tsx/src/button/style/button.less +14 -0
  218. package/template/generators/config/i18n/tsx/src/button/style/index.less +1 -0
  219. package/template/generators/config/i18n/tsx/src/button/style/index.ts +1 -0
  220. package/template/generators/config/i18n/tsx/src/locale/__tests__/index.spec.js +52 -0
  221. package/template/generators/config/i18n/tsx/src/locale/docs/en-US.md +26 -0
  222. package/template/generators/config/i18n/tsx/src/locale/docs/zh-CN.md +25 -0
  223. package/template/generators/config/i18n/tsx/src/locale/en-US.d.ts +5 -0
  224. package/template/generators/config/i18n/tsx/src/locale/en-US.ts +7 -0
  225. package/template/generators/config/i18n/tsx/src/locale/index.ts +82 -0
  226. package/template/generators/config/i18n/tsx/src/locale/zh-CN.d.ts +5 -0
  227. package/template/generators/config/i18n/tsx/src/locale/zh-CN.ts +7 -0
  228. 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,3 @@
1
+ ### 介绍
2
+
3
+ 这里可以介绍一下组件库, 想写什么就写什么...
@@ -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,8 @@
1
+ import { createApp } from 'vue'
2
+ import { expect, test } from 'vitest'
3
+ import Button from '..'
4
+
5
+ test('test button use', () => {
6
+ const app = createApp({}).use(Button)
7
+ expect(app.component(Button.name)).toBeTruthy()
8
+ })
@@ -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,7 @@
1
+ <script setup>
2
+ import VaButton from '..'
3
+ </script>
4
+
5
+ <template>
6
+ <va-button>起步</va-button>
7
+ </template>
@@ -0,0 +1,7 @@
1
+ <script setup>
2
+ import VaButton from '..'
3
+ </script>
4
+
5
+ <template>
6
+ <va-button color="#03A9F4">起步</va-button>
7
+ </template>
@@ -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,8 @@
1
+ import { withInstall } from '../utils/components'
2
+ import Button from './Button.vue'
3
+
4
+ withInstall(Button)
5
+
6
+ export const _ButtonComponent = Button
7
+
8
+ export default Button
@@ -0,0 +1,14 @@
1
+ .va-button {
2
+ display: flex;
3
+ padding: 10px;
4
+ background: #3a7afe;
5
+ color: #fff;
6
+ outline: none;
7
+ border: none;
8
+ border-radius: 2px;
9
+ cursor: pointer;
10
+
11
+ &:active {
12
+ opacity: 0.9;
13
+ }
14
+ }
@@ -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,8 @@
1
+ import { createApp } from 'vue'
2
+ import { expect, test } from 'vitest'
3
+ import Button from '..'
4
+
5
+ test('test button use', () => {
6
+ const app = createApp({}).use(Button)
7
+ expect(app.component(Button.name)).toBeTruthy()
8
+ })
@@ -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,7 @@
1
+ <script setup>
2
+ import VaButton from '..'
3
+ </script>
4
+
5
+ <template>
6
+ <va-button>起步</va-button>
7
+ </template>
@@ -0,0 +1,7 @@
1
+ <script setup>
2
+ import VaButton from '..'
3
+ </script>
4
+
5
+ <template>
6
+ <va-button color="#03A9F4">起步</va-button>
7
+ </template>
@@ -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,8 @@
1
+ import { withInstall } from '../utils/components'
2
+ import Button from './Button'
3
+
4
+ withInstall(Button)
5
+
6
+ export const _ButtonComponent = Button
7
+
8
+ export default Button
@@ -0,0 +1,14 @@
1
+ .va-button {
2
+ display: flex;
3
+ padding: 10px;
4
+ background: #3a7afe;
5
+ color: #fff;
6
+ outline: none;
7
+ border: none;
8
+ border-radius: 2px;
9
+ cursor: pointer;
10
+
11
+ &:active {
12
+ opacity: 0.9;
13
+ }
14
+ }
@@ -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,3 @@
1
+ ### Intro
2
+
3
+ Introduce the library, write whatever you want to write...
@@ -0,0 +1,3 @@
1
+ ### 介绍
2
+
3
+ 这里可以介绍一下组件库, 想写什么就写什么...
@@ -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,8 @@
1
+ import { createApp } from 'vue'
2
+ import { expect, test } from 'vitest'
3
+ import Button from '../index'
4
+
5
+ test('test button use', () => {
6
+ const app = createApp({}).use(Button)
7
+ expect(app.component(Button.name)).toBeTruthy()
8
+ })
@@ -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>{{ t('start') }}</va-button>
11
+ </template>
@@ -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>