@maple-design/cli-vue 0.0.0-stage → 1.1.0
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,25 @@
|
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
// Like Cedar's active-header-links: replace the URL without navigating the
|
|
4
|
+
// viewport or adding a back entry. Keep preview navigation separate from this.
|
|
5
|
+
export function createScrollHashSync(router: Router) {
|
|
6
|
+
let pending = false
|
|
7
|
+
return {
|
|
8
|
+
get pending() {
|
|
9
|
+
return pending
|
|
10
|
+
},
|
|
11
|
+
async replace(hash: string) {
|
|
12
|
+
if (pending || router.currentRoute.value.hash === hash) return
|
|
13
|
+
const { path, query } = router.currentRoute.value
|
|
14
|
+
const scrollBehavior = router.options.scrollBehavior
|
|
15
|
+
pending = true
|
|
16
|
+
router.options.scrollBehavior = undefined
|
|
17
|
+
try {
|
|
18
|
+
await router.replace({ path, query, hash })
|
|
19
|
+
} finally {
|
|
20
|
+
router.options.scrollBehavior = scrollBehavior
|
|
21
|
+
pending = false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
2
|
+
import type { Router } from 'vue-router'
|
|
3
|
+
import { installRouteRecovery } from './route-recovery'
|
|
4
|
+
|
|
5
|
+
afterEach(() => vi.unstubAllGlobals())
|
|
6
|
+
function fixture() {
|
|
7
|
+
const storage = new Map<string, string>()
|
|
8
|
+
const location = { pathname: '/', assign: vi.fn(), reload: vi.fn() }
|
|
9
|
+
vi.stubGlobal('window', {
|
|
10
|
+
location,
|
|
11
|
+
sessionStorage: {
|
|
12
|
+
getItem: (key: string) => storage.get(key) ?? null,
|
|
13
|
+
setItem: (key: string, value: string) => storage.set(key, value),
|
|
14
|
+
removeItem: (key: string) => storage.delete(key),
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
let error: (error: Error, to: { fullPath: string }) => void
|
|
18
|
+
let complete: (to: object, from: object, failure?: object) => void
|
|
19
|
+
const router = {
|
|
20
|
+
onError: (handler: typeof error) => {
|
|
21
|
+
error = handler
|
|
22
|
+
},
|
|
23
|
+
afterEach: (handler: typeof complete) => {
|
|
24
|
+
complete = handler
|
|
25
|
+
},
|
|
26
|
+
resolve: (path: string) => ({ href: '#' + path }),
|
|
27
|
+
} as unknown as Router
|
|
28
|
+
installRouteRecovery(router)
|
|
29
|
+
return {
|
|
30
|
+
location,
|
|
31
|
+
storage,
|
|
32
|
+
error: (...args: Parameters<typeof error>) => error(...args),
|
|
33
|
+
complete: () => complete({}, {}),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
it('reloads a stale chunk at the requested Input route once, then clears the guard on success', () => {
|
|
37
|
+
const host = fixture()
|
|
38
|
+
const failure = new Error('Failed to fetch dynamically imported module: /assets/input-old.js')
|
|
39
|
+
host.error(failure, { fullPath: '/zh-CN/input' })
|
|
40
|
+
expect(host.location.assign).toHaveBeenCalledWith('#/zh-CN/input')
|
|
41
|
+
expect(host.location.reload).toHaveBeenCalledTimes(1)
|
|
42
|
+
host.error(failure, { fullPath: '/zh-CN/input' })
|
|
43
|
+
expect(host.location.reload).toHaveBeenCalledTimes(1)
|
|
44
|
+
host.complete()
|
|
45
|
+
expect(host.storage.size).toBe(0)
|
|
46
|
+
})
|
|
47
|
+
it('does not reload for component errors', () => {
|
|
48
|
+
const host = fixture()
|
|
49
|
+
host.error(new Error('Component render failed'), { fullPath: '/zh-CN/input' })
|
|
50
|
+
expect(host.location.reload).not.toHaveBeenCalled()
|
|
51
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
const chunkFailure =
|
|
4
|
+
/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Loading chunk .+ failed|Unable to preload CSS/i
|
|
5
|
+
|
|
6
|
+
/** A preview rebuild replaces hashed assets. Retry the requested route with the new entry once. */
|
|
7
|
+
export function installRouteRecovery(router: Router) {
|
|
8
|
+
const key = `maple-site-route-retry:${window.location.pathname}`
|
|
9
|
+
let retry: string | null = null
|
|
10
|
+
try {
|
|
11
|
+
retry = window.sessionStorage.getItem(key)
|
|
12
|
+
} catch {
|
|
13
|
+
/* Storage can be unavailable in embedded previews. */
|
|
14
|
+
}
|
|
15
|
+
router.onError((error, to) => {
|
|
16
|
+
if (!chunkFailure.test(String(error?.message ?? error)) || retry === to.fullPath) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
retry = to.fullPath
|
|
20
|
+
try {
|
|
21
|
+
window.sessionStorage.setItem(key, retry)
|
|
22
|
+
} catch {
|
|
23
|
+
/* The in-memory guard still prevents repeated retries. */
|
|
24
|
+
}
|
|
25
|
+
window.location.assign(router.resolve(to.fullPath).href)
|
|
26
|
+
window.location.reload()
|
|
27
|
+
})
|
|
28
|
+
router.afterEach((_to, _from, failure) => {
|
|
29
|
+
if (!failure) {
|
|
30
|
+
retry = null
|
|
31
|
+
try {
|
|
32
|
+
window.sessionStorage.removeItem(key)
|
|
33
|
+
} catch {
|
|
34
|
+
/* No persistent guard was stored. */
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"downlevelIteration": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"jsx": "preserve",
|
|
11
|
+
"lib": ["esnext", "dom"],
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"outDir": "./lib"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/site/types.ts
ADDED
package/site/utils.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface Menu {
|
|
2
|
+
doc: string
|
|
3
|
+
text: Record<string, string>
|
|
4
|
+
type: MenuTypes
|
|
5
|
+
useMobile?: boolean
|
|
6
|
+
parent?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum MenuTypes {
|
|
10
|
+
TITLE = 1,
|
|
11
|
+
COMPONENT = 2,
|
|
12
|
+
DOCUMENTATION = 3,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function removeEmpty(object: Record<string, string> = {}) {
|
|
16
|
+
return Object.keys(object).reduce((record: Record<string, string>, key) => {
|
|
17
|
+
const value = object[key]
|
|
18
|
+
value && (record[key] = value)
|
|
19
|
+
return record
|
|
20
|
+
}, {})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const absoluteAssetRE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i
|
|
24
|
+
|
|
25
|
+
/** Resolve a public asset against Vite's configured base path. */
|
|
26
|
+
export function resolveSiteAsset(source = '') {
|
|
27
|
+
if (!source || absoluteAssetRE.test(source)) {
|
|
28
|
+
return source
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const base = import.meta.env.BASE_URL || '/'
|
|
32
|
+
return `${base.endsWith('/') ? base : `${base}/`}${source.replace(/^\.\//, '')}`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isPhone() {
|
|
36
|
+
return /Android|webOS|iPhone|iPod|BlackBerry|Pad/i.test(navigator.userAgent)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function inIframe() {
|
|
40
|
+
return window.self !== window.top
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function utoa(data: string): string {
|
|
44
|
+
return btoa(unescape(encodeURIComponent(data)))
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineComponent } from 'vue'
|
|
2
|
+
import { props } from './props'
|
|
3
|
+
import { createNamespace } from '../utils/components'
|
|
4
|
+
import './style'
|
|
5
|
+
|
|
6
|
+
const { name, n, classes } = createNamespace('<%- kebabCaseName %>')
|
|
7
|
+
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
name,
|
|
10
|
+
props,
|
|
11
|
+
setup(props, { slots }) {
|
|
12
|
+
return () => {
|
|
13
|
+
return <div class={n()}>{ slots.default?.() }</div>
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="n()"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { defineComponent } from 'vue'
|
|
7
|
+
import { props } from './props'
|
|
8
|
+
import { createNamespace } from '../utils/components'
|
|
9
|
+
|
|
10
|
+
const { name, n, classes } = createNamespace('<%- kebabCaseName %>')
|
|
11
|
+
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name,
|
|
14
|
+
props,
|
|
15
|
+
setup(props) {
|
|
16
|
+
return {
|
|
17
|
+
n,
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VarComponent, BasicAttributes, SetPropsDefaults } from '../../types/varComponent'
|
|
2
|
+
|
|
3
|
+
export declare const <%- camelizeName %>Props: Record<keyof <%- bigCamelizeName %>Props, any>
|
|
4
|
+
|
|
5
|
+
export interface <%- bigCamelizeName %>Props extends BasicAttributes {}
|
|
6
|
+
|
|
7
|
+
export class <%- bigCamelizeName %> extends VarComponent {
|
|
8
|
+
static setPropsDefaults: SetPropsDefaults<<%- bigCamelizeName %>Props>
|
|
9
|
+
|
|
10
|
+
$props: <%- bigCamelizeName %>Props
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class _<%- bigCamelizeName %>Component extends <%- bigCamelizeName %> {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import <%- bigCamelizeName %> from '..'
|
|
2
|
+
import <%- bigCamelizeNamespace + bigCamelizeName %> from '../<%- bigCamelizeName %>'
|
|
3
|
+
import { createApp } from 'vue'
|
|
4
|
+
import { mount } from '@vue/test-utils'
|
|
5
|
+
import { expect, test } from 'vitest'
|
|
6
|
+
|
|
7
|
+
test('test <%- kebabCaseName %> plugin', () => {
|
|
8
|
+
const app = createApp({}).use(<%- bigCamelizeName %>)
|
|
9
|
+
expect(app.component(<%- bigCamelizeName %>.name)).toBeTruthy()
|
|
10
|
+
})
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import <%- bigCamelizeNamespace + bigCamelizeName %> from '..'
|
|
3
|
+
<% if (!locale) { -%>
|
|
4
|
+
import { AppType } from '@maple-design/cli-vue/client'
|
|
5
|
+
<% } -%>
|
|
6
|
+
<% if (locale) { -%>
|
|
7
|
+
import { watchLang, AppType } from '@maple-design/cli-vue/client'
|
|
8
|
+
import { use, t } from './locale'
|
|
9
|
+
|
|
10
|
+
watchLang(use)
|
|
11
|
+
<% } -%>
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<app-type>Mobile phone example code</app-type>
|
|
16
|
+
<mp-<%- kebabCaseName %>/>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Locale } from '@maple-design/ui-vue'
|
|
2
|
+
import enUS from './en-US'
|
|
3
|
+
import zhCN from './zh-CN'
|
|
4
|
+
|
|
5
|
+
const { add, use: exampleUse, t, merge } = Locale.useLocale()
|
|
6
|
+
|
|
7
|
+
const use = (lang: string) => {
|
|
8
|
+
Locale.use(lang)
|
|
9
|
+
exampleUse(lang)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Locale.add('zh-CN', Locale.zhCN)
|
|
13
|
+
Locale.add('en-US', Locale.enUS)
|
|
14
|
+
add('zh-CN', zhCN)
|
|
15
|
+
add('en-US', enUS)
|
|
16
|
+
|
|
17
|
+
export { add, t, merge, use }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// lib
|
|
3
|
+
import { add as _add, use as _use, useLocale } from '../../../locale'
|
|
4
|
+
import _enCN from '../../../locale/en-US'
|
|
5
|
+
import _zhCN from '../../../locale/zh-CN'
|
|
6
|
+
import enUS from './en-US'
|
|
7
|
+
// mobile example doc
|
|
8
|
+
import zhCN from './zh-CN'
|
|
9
|
+
|
|
10
|
+
const { add, use: exampleUse, t, merge } = useLocale()
|
|
11
|
+
|
|
12
|
+
const use = (lang: string) => {
|
|
13
|
+
_use(lang)
|
|
14
|
+
exampleUse(lang)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { add, t, merge, use }
|
|
18
|
+
|
|
19
|
+
// lib
|
|
20
|
+
_add('zh-CN', _zhCN)
|
|
21
|
+
_add('en-US', _enCN)
|
|
22
|
+
// mobile example doc
|
|
23
|
+
add('zh-CN', zhCN)
|
|
24
|
+
add('en-US', enUS)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import <%- bigCamelizeName %> from './<%- bigCamelizeName %><%- style === 'vue' ? '.vue' : '' %>'
|
|
2
|
+
import { withInstall, withPropsDefaultsSetter } from '../utils/components'
|
|
3
|
+
import { props as <%- camelizeName %>Props } from './props'
|
|
4
|
+
|
|
5
|
+
withInstall(<%- bigCamelizeName %>)
|
|
6
|
+
withPropsDefaultsSetter(<%- bigCamelizeName %>, <%- camelizeName %>Props)
|
|
7
|
+
|
|
8
|
+
export { <%- camelizeName %>Props }
|
|
9
|
+
|
|
10
|
+
export const _<%- bigCamelizeName %>Component = <%- bigCamelizeName %>
|
|
11
|
+
|
|
12
|
+
export default <%- bigCamelizeName %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const props = {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './<%- camelizeName %>';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less'
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Vue component library template
|
|
2
|
+
|
|
3
|
+
### Reference
|
|
4
|
+
|
|
5
|
+
[@maple-design/cli-vue 中文文档](https://github.com/loca-spirit/maple-design-mobile/blob/main/packages/cli/README.md)
|
|
6
|
+
[@maple-design/cli-vue documentation](https://github.com/loca-spirit/maple-design-mobile/blob/main/packages/cli/README.md)
|
|
7
|
+
|
|
8
|
+
### Quickstart
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
pnpm install
|
|
12
|
+
pnpm dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Commands
|
|
16
|
+
|
|
17
|
+
#### Start the development server
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
pnpm dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### Build documentation site
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
pnpm build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Building component libraries
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
pnpm compile
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Lint code
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
pnpm lint
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Run unit test
|
|
42
|
+
|
|
43
|
+
```shell
|
|
44
|
+
pnpm test
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Run unit test in watch mode
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
pnpm test:watch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Run unit test and report coverage
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
pnpm test:coverage
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Mount Git Hooks
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
npx simple-git-hooks
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Generate changelog
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
pnpm changelog
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Release
|
|
72
|
+
|
|
73
|
+
tips:
|
|
74
|
+
- 1.The registry of npm must be the official source of npm
|
|
75
|
+
- 2.The npm must be logged in
|
|
76
|
+
|
|
77
|
+
```shell
|
|
78
|
+
pnpm release
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Create component template files
|
|
82
|
+
|
|
83
|
+
```shell
|
|
84
|
+
pnpm run create
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
本文件夹是组件库项目模板,不是工作区包。`maple-library-template-vue` 为模板占位名称;CLI 生成后使用用户输入的项目包名,并将内部 workspace 依赖替换为版本依赖。
|
|
89
|
+
|
|
90
|
+
生成项目已包含 ui-build.config.mjs 和 tsconfig.declaration.json。pnpm compile 输出 es/index.mjs、lib/index.js、types-generated/index.d.ts 和 es/library.css;发布包 files 包含 types-generated。运行时需要的 shared 包保留在 dependencies,所有内部版本在生成时转为 semver。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { defineConfig } = require("@configurajs/eslint");
|
|
2
|
+
|
|
3
|
+
module.export = defineConfig({
|
|
4
|
+
ignores: [
|
|
5
|
+
"lib/**",
|
|
6
|
+
"es/**",
|
|
7
|
+
"umd/**",
|
|
8
|
+
"site/**",
|
|
9
|
+
"public/**",
|
|
10
|
+
"coverage/**",
|
|
11
|
+
"highlight/**",
|
|
12
|
+
"types/index.d.ts",
|
|
13
|
+
".maple/**",
|
|
14
|
+
],
|
|
15
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "maple-library-template-vue",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A components library example",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "es/index.mjs",
|
|
7
|
+
"typings": "types-generated/index.d.ts",
|
|
8
|
+
"web-types": "highlight/web-types.en-US.json",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"Vue",
|
|
11
|
+
"UI"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"es/**/style/*",
|
|
16
|
+
"lib/**/style/*",
|
|
17
|
+
"*.css",
|
|
18
|
+
"*.less"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"preinstall": "npx only-allow pnpm",
|
|
22
|
+
"postinstall": "simple-git-hooks",
|
|
23
|
+
"dev": "maple-cli dev",
|
|
24
|
+
"build": "maple-cli build",
|
|
25
|
+
"preview": "maple-cli preview",
|
|
26
|
+
"compile": "maple-cli compile",
|
|
27
|
+
"lint": "eslint . --fix",
|
|
28
|
+
"format": "prettier --write .",
|
|
29
|
+
"changelog": "maple-cli changelog",
|
|
30
|
+
"release": "pnpm compile && maple-cli release",
|
|
31
|
+
"test": "maple-cli test",
|
|
32
|
+
"test:watch": "maple-cli test -w",
|
|
33
|
+
"test:coverage": "maple-cli test -cov",
|
|
34
|
+
"create": "maple-cli create"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"vue": "^3.2.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@maple-design/cli-vue": "workspace:*",
|
|
41
|
+
"@maple-design/icons-vue": "workspace:*",
|
|
42
|
+
"@maple-design/touch-emulator-vue": "workspace:*",
|
|
43
|
+
"@maple-design/ui-vue": "workspace:*",
|
|
44
|
+
"@vue/test-utils": "2.4.6",
|
|
45
|
+
"@vue/runtime-core": "3.5.13",
|
|
46
|
+
"@vitest/coverage-istanbul": "3.0.6",
|
|
47
|
+
"@configurajs/eslint": "*",
|
|
48
|
+
"@configurajs/prettier": "*",
|
|
49
|
+
"jsdom": "24.1.1",
|
|
50
|
+
"vitest": "3.0.6",
|
|
51
|
+
"clipboard": "^2.0.6",
|
|
52
|
+
"eslint": "^9.17.0",
|
|
53
|
+
"lint-staged": "^10.5.0",
|
|
54
|
+
"live-server": "^1.2.1",
|
|
55
|
+
"prettier": "^3.5.2",
|
|
56
|
+
"simple-git-hooks": "^2.8.0",
|
|
57
|
+
"typescript": "5.6.3",
|
|
58
|
+
"vue": "3.5.13",
|
|
59
|
+
"vue-router": "4.5.0",
|
|
60
|
+
"vue-tsc": "^2.2.12"
|
|
61
|
+
},
|
|
62
|
+
"lint-staged": {
|
|
63
|
+
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
64
|
+
"*.{ts,tsx,js,vue}": "eslint --fix"
|
|
65
|
+
},
|
|
66
|
+
"simple-git-hooks": {
|
|
67
|
+
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
68
|
+
"commit-msg": "pnpm exec maple-cli commit-lint -p $1"
|
|
69
|
+
},
|
|
70
|
+
"packageManager": "pnpm@9.6.0",
|
|
71
|
+
"engines": {
|
|
72
|
+
"pnpm": ">=9.0",
|
|
73
|
+
"node": ">=20.19.0"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@maple-design/shared-vue": "workspace:*"
|
|
77
|
+
},
|
|
78
|
+
"style": "es/library.css",
|
|
79
|
+
"exports": {
|
|
80
|
+
".": {
|
|
81
|
+
"types": "./types-generated/index.d.ts",
|
|
82
|
+
"import": "./es/index.mjs",
|
|
83
|
+
"require": "./lib/index.js"
|
|
84
|
+
},
|
|
85
|
+
"./style": "./es/library.css",
|
|
86
|
+
"./package.json": "./package.json",
|
|
87
|
+
"./*": {
|
|
88
|
+
"types": "./types-generated/*/index.d.ts",
|
|
89
|
+
"import": "./es/*/index.mjs",
|
|
90
|
+
"require": "./lib/*/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./*/style": {
|
|
93
|
+
"import": "./es/*/style/index.mjs",
|
|
94
|
+
"require": "./lib/*/style/index.js"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="138px" height="146px" viewBox="0 0 138 146" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>编组 2备份 4</title>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient x1="42.6722626%" y1="13.5075845%" x2="58.7114688%" y2="100%" id="linearGradient-1">
|
|
6
|
+
<stop stop-color="#3999FF" offset="0%"></stop>
|
|
7
|
+
<stop stop-color="#8F28FB" offset="100%"></stop>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
<linearGradient x1="50%" y1="15.5408894%" x2="50%" y2="100%" id="linearGradient-2">
|
|
10
|
+
<stop stop-color="#722DFA" offset="0%"></stop>
|
|
11
|
+
<stop stop-color="#21D4FD" offset="100%"></stop>
|
|
12
|
+
</linearGradient>
|
|
13
|
+
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-3">
|
|
14
|
+
<stop stop-color="#0DBBFA" offset="0%"></stop>
|
|
15
|
+
<stop stop-color="#2EF4D0" offset="100%"></stop>
|
|
16
|
+
</linearGradient>
|
|
17
|
+
<linearGradient x1="40.4455375%" y1="0%" x2="61.1107186%" y2="100%" id="linearGradient-4">
|
|
18
|
+
<stop stop-color="#54E7FA" offset="0%"></stop>
|
|
19
|
+
<stop stop-color="#3478FF" offset="100%"></stop>
|
|
20
|
+
</linearGradient>
|
|
21
|
+
</defs>
|
|
22
|
+
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
23
|
+
<g id="编组-2备份-4">
|
|
24
|
+
<path d="M61.1454478,0 L80.8081453,0 C83.2200978,-4.36166956e-15 85.3680539,1.52588995 86.1620863,3.80339469 L133.110133,138.463395 C134.14103,141.420295 132.579697,144.653043 129.622797,145.683941 C129.022705,145.893158 128.391709,146 127.756192,146 L104.065574,146 L104.065574,146 L55.7915068,7.53660531 C54.7606091,4.57970533 56.3219425,1.34695661 59.2788425,0.316058965 C59.8789348,0.106841966 60.5099303,8.99852687e-15 61.1454478,0 Z" id="矩形备份-19" fill="url(#linearGradient-1)" transform="translate(94.450820, 73.000000) scale(-1, 1) translate(-94.450820, -73.000000) "></path>
|
|
25
|
+
<path d="M10.7758114,0.143137255 L28.2717621,0.143137255 C31.4003503,0.143137255 33.937707,2.67721101 33.9417574,5.8057966 L34.0758197,109.356863 L34.0758197,109.356863 L2.40368852,141.419608 L2.27081564,8.65664929 C2.26611457,3.95946985 6.0701199,0.147842583 10.7672993,0.143141514 C10.7701367,0.143138675 10.772974,0.143137255 10.7758114,0.143137255 Z" id="矩形备份-20" fill="url(#linearGradient-2)" transform="translate(18.169057, 70.781373) scale(-1, 1) translate(-18.169057, -70.781373) "></path>
|
|
26
|
+
<path d="M59.4954713,57.5193828 L80.5061701,57.5193828 C83.6322889,57.5193828 86.1686187,60.0496067 86.1761536,63.1757164 L86.440508,172.851892 C86.4456008,174.964841 85.2753699,176.905341 83.4041828,177.886788 L54.099775,193.257088 L54.099775,193.257088 L53.8254839,63.201341 C53.8188796,60.0698934 56.3520656,57.5259998 59.4835131,57.5193954 C59.4874992,57.519387 59.4914852,57.5193828 59.4954713,57.5193828 Z" id="矩形备份-21" fill="url(#linearGradient-3)" transform="translate(70.131148, 125.388235) rotate(-270.000000) translate(-70.131148, -125.388235) "></path>
|
|
27
|
+
<path d="M8.0988647,0 L27.7025748,0 C30.0859285,1.09876935e-16 32.2148633,1.49046324 33.0303471,3.72996343 L83.9352009,143.526025 L83.9352009,143.526025 L84.8360656,146 L57.1334908,146 C54.7501371,146 52.6212023,144.509537 51.8057185,142.270037 L2.77109236,7.61003657 C1.69963975,4.66758916 3.21638072,1.41368027 6.15882813,0.34222766 C6.78058382,0.115823698 7.43717075,1.89790805e-15 8.0988647,0 Z" id="矩形备份-22" fill="url(#linearGradient-4)"></path>
|
|
28
|
+
</g>
|
|
29
|
+
</g>
|
|
30
|
+
</svg>
|