├── .nvmrc
├── .npmrc
├── packages
├── components
│ ├── index.ts
│ ├── icon
│ │ ├── index.ts
│ │ └── src
│ │ │ ├── icon.ts
│ │ │ └── icon.vue
│ └── package.json
├── theme-chalk
│ ├── src
│ │ ├── index.scss
│ │ ├── fonts
│ │ │ ├── iconfont.ttf
│ │ │ ├── iconfont.woff
│ │ │ └── iconfont.woff2
│ │ ├── mixins
│ │ │ ├── mixins.scss
│ │ │ └── config.scss
│ │ └── icon.scss
│ ├── package.json
│ └── gulpfile.ts
├── utils
│ ├── index.ts
│ ├── gulpfile.ts
│ ├── package.json
│ ├── with-install.ts
│ └── with-name.ts
└── tg-ui
│ ├── package.json
│ └── index.ts
├── docs
├── .gitignore
├── src
│ ├── public
│ │ ├── logo.png
│ │ └── favicon.ico
│ ├── components
│ │ ├── index.md
│ │ ├── example.md
│ │ ├── count-to.md
│ │ ├── watermark.md
│ │ ├── cropper.md
│ │ └── excel.md
│ ├── index.md
│ └── guide
│ │ ├── component.md
│ │ └── index.md
├── netlify.toml
├── .vitepress
│ ├── theme
│ │ ├── index.ts
│ │ ├── styles
│ │ │ └── index.css
│ │ └── components
│ │ │ └── Button.vue
│ ├── components.d.ts
│ ├── plugins
│ │ └── navbar.ts
│ └── config.ts
├── .editorconfig
├── env.d.ts
├── tsconfig.json
├── package.json
├── README.md
├── LICENSE
└── pnpm-lock.yaml
├── .eslintrc.json
├── .markdownlint.json
├── internal
├── plop
│ ├── constants
│ │ └── index.js
│ ├── component
│ │ ├── hbs
│ │ │ ├── less.hbs
│ │ │ ├── exports.hbs
│ │ │ ├── vue.hbs
│ │ │ └── ts.hbs
│ │ └── config.js
│ ├── package.json
│ └── utils
│ │ └── index.js
├── build
│ ├── utils
│ │ ├── index.ts
│ │ ├── gulp.ts
│ │ ├── pkg.ts
│ │ └── process.ts
│ ├── tasks
│ │ ├── index.ts
│ │ ├── utils.ts
│ │ ├── gen-types.ts
│ │ ├── full-component.ts
│ │ └── component.ts
│ ├── config
│ │ ├── constants.ts
│ │ ├── paths.ts
│ │ └── bundle.ts
│ └── gulpfile.ts
└── build2
│ ├── utils
│ ├── index.ts
│ ├── pkg.ts
│ ├── gulp.ts
│ └── process.ts
│ ├── config
│ ├── constants.ts
│ ├── paths.ts
│ └── bundle.ts
│ ├── tasks
│ ├── index.ts
│ ├── utils.ts
│ ├── gen-entry-types.ts
│ ├── component.ts
│ ├── full-component.ts
│ └── gen-types.ts
│ ├── tsconfig.json
│ ├── package.json
│ └── gulpfile.ts
├── examples
├── .eslintrc.json
├── public
│ └── favicon.ico
├── src
│ ├── assets
│ │ └── logo.png
│ ├── main.ts
│ ├── constants
│ │ └── index.ts
│ ├── App.vue
│ └── components
│ │ └── HelloWorld.vue
├── vite.config.ts
├── index.html
└── package.json
├── .husky
├── pre-commit
└── commit-msg
├── commitlint.config.js
├── .eslintignore
├── pnpm-workspace.yaml
├── .gitattributes
├── .npmignore
├── .editorConfig
├── typings
└── vue-shim.d.ts
├── .gitpod.yml
├── plopfile.js
├── .gitignore
├── README.md
├── LICENSE
├── .vscode
└── extensions.json
├── tsconfig.json
└── package.json
/.nvmrc:
--------------------------------------------------------------------------------
1 | v16
2 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist = true
2 |
--------------------------------------------------------------------------------
/packages/components/index.ts:
--------------------------------------------------------------------------------
1 | export * from './icon'
2 |
--------------------------------------------------------------------------------
/packages/theme-chalk/src/index.scss:
--------------------------------------------------------------------------------
1 | @use 'icon.scss';
2 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | node_modules
3 | components.d.ts
4 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@zgsgs"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "MD033": false,
3 | "MD013": false
4 | }
5 |
--------------------------------------------------------------------------------
/internal/plop/constants/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | PREFIX: 'tg-',
3 | }
4 |
--------------------------------------------------------------------------------
/examples/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-console": "off"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npm run lint:fix
5 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = { extends: ['@commitlint/config-conventional'] }
2 |
--------------------------------------------------------------------------------
/packages/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from './with-install'
2 | export * from './with-name'
3 |
--------------------------------------------------------------------------------
/docs/src/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/docs/src/public/logo.png
--------------------------------------------------------------------------------
/internal/plop/component/hbs/less.hbs:
--------------------------------------------------------------------------------
1 | .{{prefixName}} {
2 |
3 | }
4 |
5 | .{{name}} {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/docs/src/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/docs/src/public/favicon.ico
--------------------------------------------------------------------------------
/examples/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/examples/public/favicon.ico
--------------------------------------------------------------------------------
/examples/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/examples/src/assets/logo.png
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npx --no-install commitlint --edit $1
5 |
--------------------------------------------------------------------------------
/internal/build/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from './gulp'
2 | export * from './pkg'
3 | export * from './process'
4 |
--------------------------------------------------------------------------------
/internal/build2/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from './process'
2 | export * from './gulp'
3 | export * from './pkg'
4 |
--------------------------------------------------------------------------------
/docs/src/components/index.md:
--------------------------------------------------------------------------------
1 | # 组件
2 |
3 | `src/components` 下的组件没有进行全局注册,也没有通过 `unplugins-vue-components` 自动导入,使用时需要自己手动导入。
4 |
--------------------------------------------------------------------------------
/packages/theme-chalk/src/fonts/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/packages/theme-chalk/src/fonts/iconfont.ttf
--------------------------------------------------------------------------------
/packages/theme-chalk/src/fonts/iconfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/packages/theme-chalk/src/fonts/iconfont.woff
--------------------------------------------------------------------------------
/packages/theme-chalk/src/fonts/iconfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/happy-vue/tg-ui/HEAD/packages/theme-chalk/src/fonts/iconfont.woff2
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | pnpm-lock.yaml
4 | CHANGELOG.en-US.md
5 | !.*
6 | docs/components.d.ts
7 | coverage
8 | ssr-testing/cases/*
--------------------------------------------------------------------------------
/internal/build/tasks/index.ts:
--------------------------------------------------------------------------------
1 | export * from './component'
2 | export * from './full-component'
3 | export * from './gen-types'
4 | export * from './utils'
5 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - packages/** # 存放编写的组件库
3 | - internal/* # 构建配置包
4 | - examples # 应用案例
5 | - docs # 项目文档
6 | - plop # 构建脚手架
7 |
--------------------------------------------------------------------------------
/internal/build/config/constants.ts:
--------------------------------------------------------------------------------
1 | export const PKG_NAME = 'tg-ui'
2 |
3 | export const PKG_PREFIX = `@${PKG_NAME}`
4 |
5 | export const VERSION = '0.0.0-dev.0'
6 |
--------------------------------------------------------------------------------
/internal/build2/config/constants.ts:
--------------------------------------------------------------------------------
1 | export const PKG_NAME = 'tg-ui'
2 |
3 | export const PKG_PREFIX = `@${PKG_NAME}`
4 |
5 | export const VERSION = '0.0.0-dev.0'
6 |
--------------------------------------------------------------------------------
/internal/build2/tasks/index.ts:
--------------------------------------------------------------------------------
1 | // 任务执行器 gulp 任务名 就会执行对应的任务
2 | export * from './component'
3 | export * from './full-component'
4 | export * from './gen-types'
5 | export * from './utils'
6 |
--------------------------------------------------------------------------------
/packages/theme-chalk/src/mixins/mixins.scss:
--------------------------------------------------------------------------------
1 | // 声明公共的sass方法
2 |
3 | /*
4 | * 引入config
5 | */
6 | @use 'config' as *;
7 |
8 | /*
9 | * 将config暴露给全局使用
10 | */
11 | @forward 'config';
12 |
--------------------------------------------------------------------------------
/packages/utils/gulpfile.ts:
--------------------------------------------------------------------------------
1 | // 打包工具方法
2 | // import { buildUtils } from '@tg-ui/build/tasks'
3 | import { buildUtils } from '../../internal/build/tasks'
4 |
5 | export default buildUtils(__dirname, 'utils')
6 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 | *.ts linguist-detectable=false
3 | *.css linguist-detectable=false
4 | *.scss linguist-detectable=false
5 | *.js linguist-detectable=true
6 | *.vue linguist-detectable=true
7 |
--------------------------------------------------------------------------------
/packages/components/icon/index.ts:
--------------------------------------------------------------------------------
1 | import { withInstall } from '@tg-ui/utils/with-install'
2 | import Icon from './src/icon.vue'
3 |
4 | const TgIcon = withInstall(Icon)
5 |
6 | export { TgIcon }
7 | export default TgIcon
8 |
--------------------------------------------------------------------------------
/examples/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import TgIcon from '@tg-ui/components/icon'
3 | import App from './App.vue'
4 | import '@tg-ui/theme-chalk/src/index.scss'
5 |
6 | const app = createApp(App)
7 | app.use(TgIcon)
8 | app.mount('#app')
9 |
--------------------------------------------------------------------------------
/docs/netlify.toml:
--------------------------------------------------------------------------------
1 | [build.environment]
2 | # bypass npm auto install
3 | NPM_FLAGS = "--version"
4 | NODE_VERSION = "16"
5 |
6 | [build]
7 | publish = ".vitepress/dist"
8 | command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
9 |
--------------------------------------------------------------------------------
/packages/components/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/components",
3 | "version": "1.0.0",
4 | "main": "index.ts",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "author": "",
9 | "license": "ISC"
10 | }
11 |
--------------------------------------------------------------------------------
/packages/theme-chalk/src/mixins/config.scss:
--------------------------------------------------------------------------------
1 | // 命名空间
2 | $namespace: 'tg';
3 |
4 | /**
5 | * 命名规范 BEM规范
6 |
7 |
11 |
12 | */
13 |
--------------------------------------------------------------------------------
/packages/utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/utils",
3 | "version": "1.0.0",
4 | "license": "ISC",
5 | "author": "",
6 | "main": "index.js",
7 | "scripts": {
8 | "build": "gulp --require sucrase/register/ts -f ./gulpfile.ts"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/index.ts:
--------------------------------------------------------------------------------
1 | import { h } from 'vue'
2 | import { VPTheme } from '@vue/theme'
3 |
4 | import './styles/index.css'
5 |
6 | export default Object.assign({}, VPTheme, {
7 | Layout: () => {
8 | return h(VPTheme.Layout, null, {})
9 | }
10 | })
11 |
--------------------------------------------------------------------------------
/packages/theme-chalk/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/theme-chalk",
3 | "version": "1.0.0",
4 | "license": "ISC",
5 | "author": "",
6 | "main": "index.js",
7 | "scripts": {
8 | "build": "gulp --require sucrase/register/ts -f ./gulpfile.ts"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/docs/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_size = 2
6 | indent_style = space
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | insert_final_newline = false
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/internal/plop/component/hbs/exports.hbs:
--------------------------------------------------------------------------------
1 | import { withInstall } from '@tg-ui/utils/with-install';
2 | import {{pascalName}} from './src/{{name}}.vue';
3 |
4 | const {{pascalPrefixName}} = withInstall({{pascalName}});
5 |
6 | export { {{pascalPrefixName}} };
7 | export default {{pascalPrefixName}};
8 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # 忽略目录
2 | .idea
3 | .vscode
4 | build/
5 | docs/
6 | examples/
7 | packages/
8 | public/
9 | node_modules/
10 | typings/
11 |
12 | # 忽略指定文件
13 | babel.config.js
14 | tsconfig.json
15 | tslint.json
16 | vue.config.js
17 | .gitignore
18 | .browserslistrc
19 | *.map
20 |
--------------------------------------------------------------------------------
/examples/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import vue from '@vitejs/plugin-vue'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [vue()],
7 | css: {
8 | modules: {
9 | localsConvention: 'camelCase',
10 | },
11 | },
12 | })
13 |
--------------------------------------------------------------------------------
/.editorConfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*.{js,jsx,ts,tsx,vue}]
5 | charset = "utf-8"
6 | indent_style = space
7 | indent_size = 2
8 | end_of_line = lf
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | quote_type = single
12 | max_line_length = 100
13 |
--------------------------------------------------------------------------------
/docs/src/components/example.md:
--------------------------------------------------------------------------------
1 | # ExampleTemplate
2 |
3 | 这是一个简单的示例模版,不一定要按照这个格式来编写。也欢迎你提出更好的模版示例。
4 |
5 | ## Example
6 |
7 | 组件相关案例。
8 |
9 | ## Types
10 |
11 | 组件相关类型。
12 |
13 | ## Function
14 |
15 | 组件提供相关方法。
16 |
17 | ## Events
18 |
19 | 组件相关事件。
20 |
21 | ## 贡献者
22 |
23 | - [zgsgs](https://github.com/zgsgs)
24 |
--------------------------------------------------------------------------------
/typings/vue-shim.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
--------------------------------------------------------------------------------
/packages/components/icon/src/icon.ts:
--------------------------------------------------------------------------------
1 | // 放置组件的props和一些公共的方法
2 | import type { ExtractPropTypes } from 'vue'
3 | // as const,会让对象的每个属性变成只读(readonly)
4 | export const iconProps = {
5 | size: {
6 | type: Number,
7 | },
8 | color: {
9 | type: String,
10 | },
11 | }
12 |
13 | export type IconProps = ExtractPropTypes
14 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | # This configuration file was automatically generated by Gitpod.
2 | # Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
3 | # and commit this file to your remote git repository to share the goodness with others.
4 |
5 | tasks:
6 | - init: npm install && npm run build
7 | command: npm run dev
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/src/constants/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: Lin ZeFan
3 | * @Date: 2022-04-09 19:53:29
4 | * @LastEditTime : 2022-05-04 13:48:36
5 | * @LastEditors : Please set LastEditors
6 | * @Description:
7 | * @FilePath : \tg-ui\examples\src\constants\index.ts
8 | *
9 | */
10 | export const PREFIX = 'tg-'
11 |
12 | export default {
13 | PREFIX,
14 | }
15 |
--------------------------------------------------------------------------------
/internal/plop/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/plop",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "",
6 | "keywords": [],
7 | "license": "ISC",
8 | "author": "",
9 | "scripts": {
10 | "component": "plop component",
11 | "api": "plop api"
12 | },
13 | "devDependencies": {
14 | "plop": "^3.0.5"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/docs/.vitepress/components.d.ts:
--------------------------------------------------------------------------------
1 | // generated by unplugin-vue-components
2 | // We suggest you to commit this file into source control
3 | // Read more: https://github.com/vuejs/vue-next/pull/3399
4 |
5 | declare module 'vue' {
6 | export interface GlobalComponents {
7 | Button: typeof import('./theme/components/Button.vue')['default']
8 | }
9 | }
10 |
11 | export { }
12 |
--------------------------------------------------------------------------------
/packages/tg-ui/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tg-ui",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "lib/index.js",
6 | "module": "es/index.js",
7 | "output": {
8 | "exports": "named"
9 | },
10 | "scripts": {
11 | "test": "echo \"Error: no test specified\" && exit 1"
12 | },
13 | "keywords": [],
14 | "author": "",
15 | "license": "ISC"
16 | }
17 |
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Vite App
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/plopfile.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: Lin ZeFan
3 | * @Date: 2022-04-09 17:57:14
4 | * @LastEditTime : 2022-04-22 23:22:16
5 | * @LastEditors : Please set LastEditors
6 | * @Description: plop模板
7 | * @FilePath : \tg-ui\plopfile.js
8 | *
9 | */
10 |
11 | const setComponent = require('./packages/plop/component/config');
12 |
13 | module.exports = function (plop) {
14 | setComponent(plop);
15 | };
16 |
--------------------------------------------------------------------------------
/examples/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/examples",
3 | "private": true,
4 | "description": "",
5 | "scripts": {
6 | "dev": "vite"
7 | },
8 | "keywords": [],
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {},
12 | "devDependencies": {
13 | "vue": "^3.2.25",
14 | "@vitejs/plugin-vue": "^2.3.0",
15 | "typescript": "^4.5.4",
16 | "vite": "^2.9.0",
17 | "vue-tsc": "^0.29.8"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/internal/build2/utils/pkg.ts:
--------------------------------------------------------------------------------
1 | import { PKG_PREFIX } from '../config/constants'
2 | import { bundleConfig } from '../config/bundle'
3 | import type { Module } from '../config/bundle'
4 |
5 | // 重写打包后的包 处理路径 @tg-ui/es => tg-ui/es
6 | export const pathRewriter = (module: Module) => {
7 | const { bundle: { path } } = bundleConfig[module]
8 | return (id: string) => {
9 | id = id.replaceAll(`${PKG_PREFIX}/`, `${path}/`)
10 | return id
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/internal/build/utils/gulp.ts:
--------------------------------------------------------------------------------
1 | import type { TaskFunction } from 'gulp'
2 | import { buildRoot } from '../config/paths'
3 | import { run } from './process'
4 |
5 | // 携带任务名称
6 | export const withTaskName = (name: string, fn: T) =>
7 | Object.assign(fn, { displayName: name })
8 |
9 | // 执行任务
10 | export const runTask = (name: string) =>
11 | withTaskName(`shellTask: ${name}`, () => {
12 | run(`pnpm run build ${name}`, buildRoot)
13 | })
14 |
15 |
--------------------------------------------------------------------------------
/internal/build2/utils/gulp.ts:
--------------------------------------------------------------------------------
1 | import type { TaskFunction } from 'gulp'
2 | import { buildRoot } from '../config/paths'
3 | import { run } from './process'
4 |
5 | // 携带任务名称
6 | export const withTaskName = (name: string, fn: T) =>
7 | Object.assign(fn, { displayName: name })
8 |
9 | // 执行任务
10 | export const runTask = (name: string) =>
11 | withTaskName(`shellTask: ${name}`, () => {
12 | run(`pnpm run build ${name}`, buildRoot)
13 | })
14 |
15 |
--------------------------------------------------------------------------------
/docs/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
10 | declare module '@vue/theme/config' {
11 | import type { UserConfig } from 'vitepress'
12 | const config: () => Promise
13 | export default config
14 | }
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | dist-ssr
11 | *.local
12 |
13 | # Editor directories and files
14 | .vscode/*
15 | !.vscode/extensions.json
16 | .idea
17 | .DS_Store
18 | *.suo
19 | *.ntvs*
20 | *.njsproj
21 | *.sln
22 | *.sw?
23 |
24 | # Package Manager
25 | node_modules
26 | .pnpm-debug.log*
27 |
28 | # Bundle
29 | dist
30 | coverage
31 |
32 | # local env files
33 | *.local
34 | cypress/screenshots/*
35 | cypress/videos/*
36 | tmp
37 |
--------------------------------------------------------------------------------
/docs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "dist",
4 | "target": "esnext",
5 | "module": "esnext",
6 | "jsx": "preserve",
7 | "moduleResolution": "node",
8 | "esModuleInterop": true,
9 | "resolveJsonModule": true,
10 | "allowJs": true,
11 | "strict": true,
12 | "baseUrl": ".",
13 | "paths": {
14 | "/@theme/*": [
15 | ".vitepress/theme/*"
16 | ]
17 | }
18 | },
19 | "include": [
20 | "env.d.ts",
21 | "src/**/*",
22 | ".vitepress/**/*"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/internal/plop/component/hbs/vue.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 | 开始编写你的 {{prefixName}} 组件吧
4 |
5 |
6 |
7 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/styles/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --vt-c-bg-code: #fff5f5;
3 | --vt-c-text-code: #ff502c;
4 | }
5 |
6 | .dark {
7 | --vt-c-bg-code: var(--vt-c-black-mute);
8 | --vt-c-text-code: var(--vt-c-text-dark-code);
9 | }
10 |
11 | /* inline code */
12 | .vt-doc :not(pre) > code {
13 | background-color: var(--vt-c-bg-code);
14 | color: var(--vt-c-text-code);
15 | }
16 |
17 | .VPFooter {
18 | background-color: var(--vt-c-bg) !important;
19 | }
20 |
21 | .VPFooter .copyright {
22 | font-size: .9rem;
23 | color: var(--vt-c-text-light);
24 | opacity: 0.6;
25 | }
26 |
27 | .VPNavBarSearch {
28 | display: none !important;
29 | }
30 |
--------------------------------------------------------------------------------
/packages/utils/with-install.ts:
--------------------------------------------------------------------------------
1 | // 只是导入类型不是导入App的值
2 | import type { App, Plugin } from 'vue'
3 | /**
4 | * 组件外部使用use时执行install,然后将组件注册为全局
5 | */
6 |
7 | // 类型必须导出否则生成不了.d.ts文件
8 | export type SFCWithInstall = T & Plugin
9 |
10 | /**
11 | * 定义一个withInstall方法处理以下组件类型问题
12 | * @param comp
13 | */
14 | export const withInstall = (comp: T) => {
15 | /**
16 | * 直接写comp.install = function(){} 的话会报错,因为comp下没有install方法
17 | * 所以从vue中引入Plugin类型,断言comp的类型为T&Plugin
18 | */
19 | (comp as SFCWithInstall).install = function (app: App) {
20 | app.component((comp as any).name, comp)
21 | }
22 | return comp as SFCWithInstall
23 | }
24 |
--------------------------------------------------------------------------------
/internal/plop/component/hbs/ts.hbs:
--------------------------------------------------------------------------------
1 | import { buildProps, definePropType } from '@tg-ui/utils'
2 | import type { ExtractPropTypes } from 'vue'
3 | import type {{pascalName}} from './{{name}}.vue'
4 |
5 | export const {{camelName}}Props = buildProps({
6 | prop: {
7 | type: String,
8 | default: '',
9 | },
10 | } as const)
11 |
12 | export type {{pascalName}}Props = ExtractPropTypes
13 |
14 | export const {{camelName}}Emits = {
15 | error: (evt: Event) => evt instanceof Event,
16 | }
17 |
18 | export type {{pascalName}}Emits = typeof {{camelName}}Emits
19 |
20 | export type {{pascalName}}Instance = InstanceType
21 |
--------------------------------------------------------------------------------
/internal/build/utils/pkg.ts:
--------------------------------------------------------------------------------
1 | // import { PKG_PREFIX } from '../config/constants'
2 | // import { bundleConfig } from '../config/bundle'
3 | // import type { Module } from '../config/bundle'
4 |
5 | // // 重写打包后的包 处理路径 @tg-ui/es => tg-ui/es
6 | // export const pathRewriter = (module: Module) => {
7 | // const { bundle: { path } } = bundleConfig[module]
8 | // return (id: string) => {
9 | // id = id.replaceAll(`${PKG_PREFIX}/`, `${path}/`)
10 | // return id
11 | // }
12 | // }
13 |
14 | // 重写打包后的@tg-ui 路径
15 | export const pathRewriter = (format: string) => {
16 | return (id: string) => {
17 | id = id.replaceAll('@tg-ui', `tg-ui/${format}`)
18 | return id
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/tg-ui/index.ts:
--------------------------------------------------------------------------------
1 | // import { WIcon,WButton } from "@tg-ui/components";
2 | import * as components from '@tg-ui/components'
3 | import type { App } from 'vue'
4 |
5 | // const components = [WIcon,WButton];
6 |
7 | const install = (app: App) => {
8 | // 每个组件在写的时候都提供了install方法
9 |
10 | // 有的是组件,有的可能是指令 xxx.install = () => { app.directive() }
11 | // components.forEach((component) => app.use(component));
12 |
13 | Object.entries(components).forEach(([name, component]) => {
14 | app.component(name, component)
15 | })
16 | }
17 |
18 | // use: app.use(WPlus)
19 | export default {
20 | install,
21 | }
22 |
23 | // use: import { WIcon } from 'tg-ui
24 | export * from '@tg-ui/components'
25 |
--------------------------------------------------------------------------------
/packages/components/icon/src/icon.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/src/App.vue:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 | Icon Test
12 |
13 |
14 |
15 |
25 |
--------------------------------------------------------------------------------
/docs/src/index.md:
--------------------------------------------------------------------------------
1 | # 介绍
2 |
3 | 提供现成的开箱解决方案及丰富的示例,提高开发效率。
4 |
5 | ## 文档
6 |
7 | - 仓库地址 [tg-ui-docs](https://github.com/zgsgs/tg-ui-docs)。
8 | - 采用 [Vitepress](https://github.com/vuejs/vitepress) 构建的,依赖于 [@vue/theme](https://github.com/vuejs/theme)。
9 | - 如发现文档有误,欢迎提 PR 帮助我们改进。
10 |
11 | ## 本地运行项目
12 |
13 | 如需本地运行文档,请拉取代码到本地。
14 |
15 | ``` bash
16 | # 拉取代码
17 | git clone https://github.com/zgsgs/tg-ui
18 |
19 | # 安装依赖
20 | pnpm install
21 |
22 | # 运行项目
23 | pnpm run dev
24 | ```
25 |
26 | ## 如何加入我们
27 |
28 | - 目前 [tg-ui](https://github.com/zgsgs/tg-ui) 正在火热更新中,欢迎您的参与,共同维护,逐步完善。
29 | - 如果你想加入我们,可以多提供一些好的建议或者提交 PR,我们会根据你的活跃度邀请你加入。
30 | - 你也可以添加微信:`wulian988` 了解更多。
31 |
32 | ## 贡献者
33 |
34 | - [zgsgs](https://github.com/zgsgs)
35 |
36 | ## LICENSE
37 |
38 | MIT, Copyright (c) 2021 zgsgs.
39 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/docs",
3 | "version": "0.0.1",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "dev": "vitepress dev",
8 | "build": "vitepress build",
9 | "serve": "vitepress serve"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/zgsgs/tg-ui.git"
14 | },
15 | "keywords": [],
16 | "author": "",
17 | "license": "ISC",
18 | "bugs": {
19 | "url": "https://github.com/zgsgs/tg-ui/issues"
20 | },
21 | "homepage": "https://github.com/zgsgs/tg-ui#readme",
22 | "devDependencies": {
23 | "@types/node": "^17.0.23",
24 | "@vue/theme": "^1.0.1",
25 | "unplugin-vue-components": "^0.18.5",
26 | "vite": "^2.9.1",
27 | "vitepress": "^0.22.3",
28 | "vue": "^3.2.31"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docs/src/guide/component.md:
--------------------------------------------------------------------------------
1 | # 组件开发规范
2 |
3 | [src/components](https://github.com/zgsgs/zgsgs/packges/components) 下新增组件需遵从以下规范。
4 |
5 | ## 目录结构
6 |
7 | ```bash
8 | ├── components
9 | │ ├── example
10 | │ │ ├── src
11 | │ │ │ ├── example.less
12 | │ │ │ ├── example.ts
13 | │ │ │ ├── example.vue
14 | │ │ │ ├── example-other.ts
15 | │ │ └── index.ts
16 | ```
17 |
18 | ## `index.ts` 作为统一出口
19 |
20 | ``` ts
21 | // Example/index.ts
22 | import { withInstall } from '@tg-ui/utils/with-install'
23 | import Example from './src/example.vue'
24 |
25 | const TgExample = withInstall(Example)
26 |
27 | export { TgExample }
28 | export default TgExample
29 |
30 | ```
31 |
32 | ## 组件示例、文档
33 |
34 | 当你完成了一个组件开发,在提交 PR 之前,请更新 Demo 示例,以及编写相关文档。
35 |
36 | 文档仓库地址:[tg-ui](https://github.com/zgsgs/tg-ui)
37 |
38 | 文档编写模版:[Example](../components/example)
39 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/components/Button.vue:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
40 |
--------------------------------------------------------------------------------
/docs/src/guide/index.md:
--------------------------------------------------------------------------------
1 | # 贡献指南
2 |
3 | 你好!很高兴你有兴趣为 [tg-ui](https://github.com/zgsgs/tg-ui) 做贡献。在提交您的贡献之前,请务必花点时间阅读以下指南:
4 |
5 | [[toc]]
6 |
7 | ## 开发设置
8 |
9 | 你将需要 [Node.js](https://nodejs.org) 版本 16+ 和 [pnpm](https://github.com/pnpm/pnpm)。
10 |
11 | 我们还建议安装 [ni](https://github.com/antfu/ni) 以帮助使用不同的包管理器在 repos 之间切换。`ni` 还提供了方便的 `nr` 命令,可以更轻松地运行 npm 脚本。
12 |
13 | ## 任务状态
14 |
15 | - issue `Assignee` 有指向时,表示任务已被领取;
16 | - issue 下有人留言要去做这个功能,表示任务已被领取;
17 | - 否则,视为未被领取。
18 |
19 | ## 领取任务
20 |
21 | - 项目成员:对应 issue `Assignee` 指向自己;
22 | - 非项目成员:对应任务 issue 下留言,项目成员看见会为你修改 `Assignee` 指向。
23 |
24 | ## 提交 PR 指南
25 |
26 | - 如果添加新功能:
27 | - 在 PR 描述中添加 `close #1`。
28 | - 如果修复错误:
29 | - 如果您正在解决一个特殊问题,请在您的 PR 标题中添加(#xxxx 问题 ID)以获得更好的发布日志,例如 `update entities encoding/decoding (fix #1)`。
30 | - 在 PR 中提供错误的详细描述。
31 | - 在 PR 上进行多个小提交是可以的 - GitHub 可以在合并之前自动压缩它们。
32 |
33 | ## 最后
34 |
35 | 祝,编码快乐,收获满满,玩的愉快...
36 |
--------------------------------------------------------------------------------
/internal/build2/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@vue/tsconfig/tsconfig.node.json",
3 | "compilerOptions": {
4 | "module": "ESNext", // 打包模块类型ESNext
5 | "declaration": false, // 默认不要声明文件
6 | "noImplicitAny": false, // 支持类型不标注可以默认any
7 | "removeComments": true, // 删除注释
8 | "moduleResolution": "node", // 按照node模块来解析
9 | "esModuleInterop": true, // 支持es6,commonjs模块
10 | "jsx": "preserve", // jsx 不转
11 | "noLib": false, // 不处理类库
12 | "target": "es6", // 遵循es6版本
13 | "sourceMap": true,
14 | "lib": [
15 | // 编译时用的库
16 | "ESNext",
17 | "DOM"
18 | ],
19 | "allowSyntheticDefaultImports": true, // 允许没有导出的模块中导入
20 | "experimentalDecorators": true, // 装饰器语法
21 | "forceConsistentCasingInFileNames": true, // 强制区分大小写
22 | "resolveJsonModule": true, // 解析json模块
23 | "strict": true, // 是否启动严格模式
24 | "skipLibCheck": true // 跳过类库检测
25 | },
26 | "include": [
27 | "**/*"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/packages/utils/with-name.ts:
--------------------------------------------------------------------------------
1 | export function camelize(event: string) {
2 | /** replace的第二个参数为函数
3 | * 参数一:正则匹配的结,即-x
4 | * 参数二:为\w
5 | */
6 | // replace的函数回调有个特点,正则里面只要有()包裹的,判断为分组($1),都会单独返会一个结果,所以这里参数2是-后的字母,如果(\w)换成\w,那参数2会是匹配结果的下标
7 | return event.replace(/-(\w)/g, (_, str: string) => {
8 | return str.toUpperCase()
9 | })
10 | }
11 | /**
12 | * @description: 转大驼峰 取出首字母,转换为大写 + 切割掉首字母
13 | * @access: public
14 | * @param {string} event
15 | * @return {*}
16 | */
17 | export function capitalize(event: string) {
18 | return event ? event.charAt(0).toLocaleUpperCase() + event.slice(1) : ''
19 | }
20 |
21 | /**
22 | * @description: 校验kebab-case
23 | * @access: public
24 | * @param {string} event
25 | * @return {*}
26 | */
27 | export function validateKebabCase(event: string) {
28 | if (!event || event.trim() === '')
29 | return '组件名称不能为空'
30 |
31 | if (/[A-Z]/.test(event))
32 | return '组件名称请遵守 kebab-case'
33 |
34 | return true
35 | }
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # tg-ui
2 |
3 | `tg-ui` 是基于 Vue 3 + Typescript + Vite 技术开发的前端 Vue 组件库。该项目采用`pnpm+monorepo`进行包管理,使用`gulp`控制打包流程,`rollup`进行打包。
4 |
5 | ## Demo
6 |
7 | ## 目标
8 |
9 | - 开发出完备的组件库
10 | - 提供易用好用,易维护,易拓展的调用方式
11 | - 抱团进步,一起学习,共同维护,相互 review,步步高升
12 | - 熟悉组件库开发,熟悉开源项目流程
13 | - 300start
14 |
15 | ## 参与贡献
16 |
17 | 使用 Issues 管理项目。
18 | [Issues](https://github.com/zgsgs/tg-ui/issues)
19 |
20 | ## 待完成需求列表
21 |
22 | [New feature](https://github.com/zgsgs/tg-ui/labels/feature)
23 |
24 | ## 任务是否被领取
25 |
26 | - 当 issue 存在 `Developer` 或格式为 `Developer:username` 的 `label`,既已被领取。
27 | - 否则,视为未被领取。
28 |
29 | ## 如何领取任务
30 |
31 | - 项目成员:对应 issue 添加 `label`,格式为:`Developer:username`。
32 | - 非项目成员:issue 留言,管理员会为你添加 `label` -> `Developer`。
33 |
34 | ## 参考项目汇总
35 |
36 | 拿到一个需求,没有灵感,不知道该怎么下手?
37 |
38 | 如果你遇到这样的问题,那么你可以[去这里](https://github.com/zgsgs/tg-ui/discussions/4)研究一下这些项目,寻找一些灵感~
39 |
40 | ## 加入小组
41 |
42 | 项目初期暂时不增加社群维护成本,等做出一定成绩再吸纳更多优秀的同学参与。
43 |
44 | ## LICENSE
45 |
46 | MIT, Copyright (c) 2021 zgsgs.
47 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # tg-ui
2 |
3 | `tg-ui` 是基于 Vue 3 + Typescript + Vite 技术开发的前端 Vue 组件库。该项目采用`pnpm+monorepo`进行包管理,使用`gulp`控制打包流程,`rollup`进行打包。
4 |
5 | ## Demo
6 |
7 | ## 目标
8 |
9 | - 开发出完备的组件库
10 | - 提供易用好用,易维护,易拓展的调用方式
11 | - 抱团进步,一起学习,共同维护,相互 review,步步高升
12 | - 熟悉组件库开发,熟悉开源项目流程
13 | - 300start
14 |
15 | ## 参与贡献
16 |
17 | 使用 Issues 管理项目。
18 | [Issues](https://github.com/zgsgs/tg-ui/issues)
19 |
20 | ## 待完成需求列表
21 |
22 | [New feature](https://github.com/zgsgs/tg-ui/labels/feature)
23 |
24 | ## 任务是否被领取
25 |
26 | - 当 issue 存在 `Developer` 或格式为 `Developer:username` 的 `label`,既已被领取。
27 | - 否则,视为未被领取。
28 |
29 | ## 如何领取任务
30 |
31 | - 项目成员:对应 issue 添加 `label`,格式为:`Developer:username`。
32 | - 非项目成员:issue 留言,管理员会为你添加 `label` -> `Developer`。
33 |
34 | ## 参考项目汇总
35 |
36 | 拿到一个需求,没有灵感,不知道该怎么下手?
37 |
38 | 如果你遇到这样的问题,那么你可以[去这里](https://github.com/zgsgs/tg-ui/discussions/4)研究一下这些项目,寻找一些灵感~
39 |
40 | ## 加入小组
41 |
42 | 项目初期暂时不增加社群维护成本,等做出一定成绩再吸纳更多优秀的同学参与。
43 |
44 | ## LICENSE
45 |
46 | MIT, Copyright (c) 2021 zgsgs.
47 |
--------------------------------------------------------------------------------
/docs/.vitepress/plugins/navbar.ts:
--------------------------------------------------------------------------------
1 | import type { Plugin } from 'vite'
2 |
3 | // Due to https://github.com/vuejs/theme/commit/842e4451fbf13925d1c67aa4274f86fc5a8510f7
4 | export function NavbarFix(): Plugin {
5 | return {
6 | name: 'navbar-fix',
7 | enforce: 'pre',
8 | transform(code, id) {
9 | if (id.includes('VPNavBarTitle.vue') && !id.endsWith('.css')) {
10 | return `
11 |
12 |
13 |
14 | tg-ui
15 |
16 |
17 |
18 |
40 | `
41 | }
42 | },
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 jason
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 jason
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/internal/build2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tg-ui/build",
3 | "type": "module",
4 | "version": "0.0.1",
5 | "private": true,
6 | "description": "Internal build tools",
7 | "keywords": [],
8 | "license": "MIT",
9 | "author": "zgsgs",
10 | "main": "index.js",
11 | "scripts": {
12 | "build": "gulp --require sucrase/register/ts -f ./gulpfile.ts"
13 | },
14 | "devDependencies": {
15 | "@rollup/plugin-commonjs": "^21.0.3",
16 | "@rollup/plugin-node-resolve": "^13.2.0",
17 | "@types/gulp": "^4.0.9",
18 | "@types/gulp-autoprefixer": "^0.0.33",
19 | "@types/gulp-clean-css": "^4.3.0",
20 | "@types/gulp-sass": "^5.0.0",
21 | "@types/sass": "^1.43.1",
22 | "@vue/compiler-sfc": "^3.2.32",
23 | "fast-glob": "^3.2.11",
24 | "gulp": "^4.0.2",
25 | "gulp-autoprefixer": "^8.0.0",
26 | "gulp-clean-css": "^4.3.0",
27 | "gulp-sass": "^5.1.0",
28 | "gulp-typescript": "^6.0.0-alpha.1",
29 | "rollup": "^2.70.1",
30 | "rollup-plugin-typescript2": "^0.31.2",
31 | "rollup-plugin-vue": "^6.0.0",
32 | "sucrase": "^3.20.3",
33 | "ts-morph": "^14.0.0",
34 | "typescript": "^4.5.4",
35 | "vue": "^3.2.25",
36 | "vue-tsc": "^0.29.8"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "github.github-vscode-theme",
4 | "emmanuelbeziat.vscode-great-icons",
5 | "redjue.git-commit-plugin",
6 | "github.vscode-pull-request-github",
7 | "formulahendry.auto-close-tag",
8 | "formulahendry.auto-complete-tag",
9 | "steoates.autoimport",
10 | "formulahendry.auto-rename-tag",
11 | "coenraads.bracket-pair-colorizer-2",
12 | "naumovs.color-highlight",
13 | "pranaygp.vscode-css-peek",
14 | "mikestead.dotenv",
15 | "editorconfig.editorconfig",
16 | "johnsoncodehk.volar",
17 | "dbaeumer.vscode-eslint",
18 | "mhutchie.git-graph",
19 | "eamodio.gitlens",
20 | "lokalise.i18n-ally",
21 | "afzalsayed96.icones",
22 | "antfu.iconify",
23 | "kisstkondoros.vscode-gutter-preview",
24 | "xabikos.javascriptsnippets",
25 | "whtouche.vscode-js-console-utils",
26 | "ritwickdey.liveserver",
27 | "yzhang.markdown-all-in-one",
28 | "jimdong.naive-ui-snippets",
29 | "christian-kohler.path-intellisense",
30 | "esbenp.prettier-vscode",
31 | "johnsoncodehk.vscode-typescript-vue-plugin",
32 | "dariofuzinato.vue-peek",
33 | "wscats.vue",
34 | "antfu.unocss"
35 | ],
36 | }
37 |
--------------------------------------------------------------------------------
/examples/src/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 | {{ msg }}
11 |
12 |
13 | Recommended IDE setup:
14 | VSCode
15 | +
16 | Volar
17 |
18 |
19 | See README.md for more information.
20 |
21 |
22 |
23 | Vite Docs
24 |
25 | |
26 | Vue 3 Docs
27 |
28 |
29 |
32 |
33 | Edit
34 | components/HelloWorld.vue to test hot module replacement.
35 |
36 |
37 |
38 |
56 |
--------------------------------------------------------------------------------
/internal/build2/gulpfile.ts:
--------------------------------------------------------------------------------
1 | // import { mkdir } from 'fs/promises'
2 | import { parallel, series } from 'gulp'
3 | import { genTypes } from './tasks/gen-types'
4 | import { run, runTask, withTaskName } from './utils'
5 | import { buildOutput, uiRoot } from './config/paths'
6 | import { genEntryTypes } from './tasks/gen-entry-types'
7 |
8 | // gulp 不打包只做代码转化 使用它做流程控制
9 |
10 | // 拷贝源码
11 | const copyPackage = () => async () => {
12 | await run(`cp ${uiRoot}/package.json ${buildOutput}/package.json`)
13 | }
14 |
15 | /**
16 | * 1. 打包样式
17 | * 2. 打包工具方法
18 | * 3. 打包所有组件
19 | * 4. 打包每个组件
20 | * 5. 生成一个组件库
21 | * 6. 发布组件
22 | */
23 | export default series(
24 | withTaskName('clean', async () => {
25 | await run('rm -rf ./dist') // 删除dist目录
26 | }),
27 | // withTaskName('mkdir', () => mkdir(sdOutput, { recursive: true })),
28 | parallel(
29 | // 并行执行 packages 目录下的 build 脚本
30 | withTaskName('buildPackages', async () => {
31 | await run('pnpm run --filter ./packages --parallel build')
32 | }),
33 | runTask('buildFullComponent'),
34 | runTask('buildComponent'),
35 | ),
36 | parallel(genEntryTypes, copyPackage()),
37 | parallel(genTypes, copyPackage()),
38 | )
39 |
40 | // 任务执行器 gulp 任务名 就会执行对应的任务
41 | export * from './tasks'
42 |
--------------------------------------------------------------------------------
/internal/build/gulpfile.ts:
--------------------------------------------------------------------------------
1 | import { parallel, series } from 'gulp'
2 | import { genTypes } from './tasks'
3 | import { run, withTaskName } from './utils'
4 | import { buildOutput, uiRoot } from './config/paths'
5 |
6 | // gulp 不打包只做代码转化 使用它做流程控制
7 |
8 | // 拷贝源码
9 | const copySourceCode = () => async () => {
10 | await run(`cp ${uiRoot}/package.json ${buildOutput}/package.json`)
11 | }
12 |
13 | /**
14 | * 1. 打包样式
15 | * 2. 打包工具方法
16 | * 3. 打包所有组件
17 | * 4. 打包每个组件
18 | * 5. 生成一个组件库
19 | * 6. 发布组件
20 | */
21 | export default series(
22 | withTaskName('clean', async () => {
23 | await run('rm -rf ./dist') // 删除dist目录
24 | }),
25 | parallel(
26 | // 并行执行packages目录下的build脚本
27 | withTaskName('buildPackages', async () => {
28 | await run('pnpm run --filter ./packages --parallel build')
29 | }),
30 | // 执行build命令时会调用rollup,给rollup传参数buildFullComponent,那么就会执行导出任务叫buildFullComponent
31 | // runTask('buildFullComponent'),
32 | withTaskName('buildFullComponent', async () => {
33 | await run('pnpm run build buildFullComponent')
34 | }),
35 | withTaskName('buildComponent', async () => {
36 | await run('pnpm run build buildComponent')
37 | }),
38 | ),
39 | parallel(genTypes, copySourceCode()),
40 | )
41 |
42 | // 任务执行器 gulp 任务名 就会执行对应的任务
43 | export * from './tasks'
44 |
--------------------------------------------------------------------------------
/docs/src/components/count-to.md:
--------------------------------------------------------------------------------
1 | # CountTo
2 |
3 | 数字动画组件。
4 |
5 | ## Example
6 |
7 | ``` vue
8 |
14 |
15 |
16 |
17 |
18 | ```
19 |
20 | ## Props
21 |
22 | | 属性 | 类型 | 默认值 | 说明 |
23 | | ---------- | --------- | -------- | ----------- |
24 | | startVal | `number` | `0` | 起始值 |
25 | | endVal | `number` | `2022` | 结束值 |
26 | | duration | `number` | `1000` | 动画持续时间 |
27 | | autoplay | `boolean` | `true` | 自动执行 |
28 | | prefix | `string` | - | 前缀 |
29 | | suffix | `string` | - | 后缀 |
30 | | separator | `string` | `,` | 分隔符 |
31 | | color | `string` | - | 字体颜色 |
32 | | useEasing | `boolean` | `true` | 是否开启动画 |
33 | | transition | `string` | `linear` | 动画效果 |
34 | | decimals | `number` | `0` | 保留小数点位数 |
35 |
36 | ## Methods
37 |
38 | | 名称 | 回调参数 | 说明 |
39 | | ----- | ---------- | ------------ |
40 | | start | `()=>void` | 开始执行动画 |
41 | | reset | `()=>void` | 重置 |
42 |
43 | ## 贡献者
44 |
45 | - [zgsgs](https://github.com/zgsgs)
46 |
--------------------------------------------------------------------------------
/internal/build/config/paths.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { PKG_NAME } from './constants'
3 |
4 | /* 源文件 */
5 | // 项目根目录
6 | export const projectRoot = resolve(__dirname, '..', '..', '..')
7 | // 包目录
8 | export const pkgRoot = resolve(projectRoot, 'packages')
9 | // 包/组件目录
10 | export const vueComponentRoot = resolve(pkgRoot, 'components')
11 | // 包/共享
12 | export const sharedRoot = resolve(pkgRoot, 'shared')
13 | // 包/生产库
14 | export const uiRoot = resolve(pkgRoot, PKG_NAME)
15 | // 构建脚本目录
16 | export const buildRoot = resolve(projectRoot, 'internal', 'build')
17 |
18 | /* output */
19 | // 打包输出目录
20 | export const buildOutput = resolve(projectRoot, 'dist')
21 | // 输出UI目录
22 | export const uiOutput = resolve(buildOutput, PKG_NAME)
23 | // 组件导出文件类型输出目录
24 | export const uiTypeOutput = resolve(buildOutput, 'entry/types')
25 | // 类型输出目录
26 | export const typesOutput = resolve(buildOutput, 'types')
27 | // 组件类型输出目录
28 | export const componentTypeOutput = resolve(typesOutput, 'components')
29 |
30 | /* package.json位置 */
31 | export const projPackage = resolve(projectRoot, 'package.json')
32 | export const vueComponentPackage = resolve(vueComponentRoot, 'package.json')
33 | export const uiPackage = resolve(uiRoot, 'package.json')
34 | export const sharedPackage = resolve(sharedRoot, 'package.json')
35 |
36 | /* tsconfig.json */
37 | // 根目录的 ts 配置
38 | export const tsConfigRoot = resolve(projectRoot, 'tsconfig.json')
39 |
--------------------------------------------------------------------------------
/internal/build2/config/paths.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { PKG_NAME } from './constants'
3 |
4 | /* 源文件 */
5 | // 项目根目录
6 | export const projectRoot = resolve(__dirname, '..', '..', '..', '..')
7 | // 包目录
8 | export const pkgRoot = resolve(projectRoot, 'packages')
9 | // 包/组件目录
10 | export const vueComponentRoot = resolve(pkgRoot, 'components')
11 | // 包/共享
12 | export const sharedRoot = resolve(pkgRoot, 'shared')
13 | // 包/生产库
14 | export const uiRoot = resolve(pkgRoot, PKG_NAME)
15 | // 构建脚本目录
16 | export const buildRoot = resolve(projectRoot, 'internal', 'build')
17 |
18 | /* output */
19 | // 打包输出目录
20 | export const buildOutput = resolve(projectRoot, 'dist')
21 | // 输出UI目录
22 | export const uiOutput = resolve(buildOutput, PKG_NAME)
23 | // 组件导出文件类型输出目录
24 | export const uiTypeOutput = resolve(buildOutput, 'entry/types')
25 | // 类型输出目录
26 | export const typesOutput = resolve(buildOutput, 'types')
27 | // 组件类型输出目录
28 | export const componentTypeOutput = resolve(typesOutput, 'components')
29 |
30 | /* package.json位置 */
31 | export const projPackage = resolve(projectRoot, 'package.json')
32 | export const vueComponentPackage = resolve(vueComponentRoot, 'package.json')
33 | export const uiPackage = resolve(uiRoot, 'package.json')
34 | export const sharedPackage = resolve(sharedRoot, 'package.json')
35 |
36 | /* tsconfig.json */
37 | // 根目录的 ts 配置
38 | export const tsConfigRoot = resolve(projectRoot, 'tsconfig.json')
39 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "ESNext", // 打包模块类型ESNext
4 | "declaration": false, // 默认不要声明文件
5 | "noImplicitAny": false, // 支持类型不标注可以默认any
6 | "removeComments": true, // 删除注释
7 | "moduleResolution": "node", // 按照node模块来解析
8 | "esModuleInterop": true, // 支持es6,commonjs模块
9 | "jsx": "preserve", // jsx 不转
10 | "noLib": false, // 不处理类库
11 | "target": "es6", // 遵循es6版本
12 | "sourceMap": true,
13 | "lib": [
14 | // 编译时用的库
15 | "ESNext",
16 | "DOM"
17 | ],
18 | "allowSyntheticDefaultImports": true, // 允许没有导出的模块中导入
19 | "experimentalDecorators": true, // 装饰器语法
20 | "forceConsistentCasingInFileNames": true, // 强制区分大小写
21 | "resolveJsonModule": true, // 解析json模块
22 | "strict": true, // 是否启动严格模式
23 | "skipLibCheck": true, // 跳过类库检测
24 | "paths": {
25 | "~/*": [
26 | "./*"
27 | ],
28 | "@/*": [
29 | "./src/*"
30 | ]
31 | }
32 | },
33 | "include": [
34 | "examples/**/*.ts",
35 | "examples/**/*.tsx",
36 | "examples/**/*.vue",
37 | "packages/**/*.ts",
38 | "packages/**/*.tsx",
39 | "packages/**/*.vue",
40 | "tests/**/*.ts",
41 | "tests/**/*.tsx",
42 | "typings/**/*.ts",
43 | "typings/**/*.d.ts"
44 | ],
45 | "exclude": [
46 | // 排除掉哪些类库
47 | "node_modules",
48 | "**/__tests__",
49 | "dist/**",
50 | "tg-ui/**"
51 | ]
52 | }
53 |
--------------------------------------------------------------------------------
/internal/build/tasks/utils.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { dest, parallel, series, src } from 'gulp'
3 | import ts from 'gulp-typescript'
4 | import { withTaskName } from '../utils/index'
5 | import { buildOutput, projectRoot } from '../config/paths'
6 | import { bundleConfig } from '../config/bundle'
7 |
8 | // 专门打包utils,指令,hooks等ts文件
9 | export const buildUtils = (dirName: string, name: string) => {
10 | const tasks = Object.entries(bundleConfig).map(([, config]) => {
11 | const tsConfig = path.resolve(projectRoot, 'tsconfig.json')
12 | const inputs = ['**/*.ts', '!gulpfile.ts', '!node_modules']
13 | const output = path.resolve(dirName, 'dist', config.output.name)
14 | // 安装依赖gulp-typescript
15 | return series(
16 | // 处理ts文件
17 | withTaskName(`build: ${dirName}`, () => {
18 | return src(inputs)
19 | .pipe(
20 | ts.createProject(tsConfig, {
21 | declaration: true, // 需要生成声明文件
22 | strict: false, // 关闭严格模式
23 | module: config.module,
24 | })(),
25 | )
26 | .pipe(dest(output))
27 | }),
28 | withTaskName(`copy: ${dirName}`, () => {
29 | // 将打包好的文件放到 es=>utils 和 lib => utils
30 | // 将utils模块拷贝到dist目录下的es和lib目录
31 | return src(`${output}/**`).pipe(
32 | dest(path.resolve(buildOutput, config.output.name, name)),
33 | )
34 | }),
35 | )
36 | })
37 | return parallel(...tasks)
38 | }
39 |
--------------------------------------------------------------------------------
/internal/build2/tasks/utils.ts:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import ts from 'gulp-typescript'
3 | import { dest, parallel, series, src } from 'gulp'
4 | import { withTaskName } from '../utils'
5 | import { buildOutput, projectRoot } from '../config/paths'
6 | import { bundleConfig } from '../config/bundle'
7 |
8 | // 专门打包 utils、指令、hooks 等 ts 文件
9 | export const buildUtils = (dirName: string, name: string) => {
10 | const tasks = Object.entries(bundleConfig).map(([, config]) => {
11 | const tsConfig = path.resolve(projectRoot, 'tsconfig.json')
12 | const inputs = ['**/*.ts', '!gulpfile.ts', '!node_modules']
13 | const output = path.resolve(dirName, 'dist', config.output.name)
14 | // 安装依赖gulp-typescript
15 | return series(
16 | // 处理ts文件
17 | withTaskName(`build: ${dirName}`, () => {
18 | return src(inputs)
19 | .pipe(
20 | ts.createProject(tsConfig, {
21 | declaration: true, // 需要生成声明文件
22 | strict: false, // 关闭严格模式
23 | module: config.module,
24 | })(),
25 | )
26 | .pipe(dest(output))
27 | }),
28 | withTaskName(`copy: ${dirName}`, () => {
29 | // 将打包好的文件放到 es=>utils 和 lib => utils
30 | // 将utils模块拷贝到dist目录下的es和lib目录
31 | return src(`${output}/**`).pipe(
32 | dest(path.resolve(buildOutput, config.output.name, name)),
33 | )
34 | }),
35 | )
36 | })
37 | return parallel(...tasks)
38 | }
39 |
--------------------------------------------------------------------------------
/internal/build/utils/process.ts:
--------------------------------------------------------------------------------
1 | import { spawn } from 'child_process'
2 | import { projectRoot } from '../config/paths'
3 |
4 | /**
5 | * 子进程
6 | * child_process.spawn(command[, args][, options])
7 | * command 要运行的命令。
8 | * args 字符串参数列表。
9 | * options