├── .gitignore ├── .npmrc ├── .nuxtrc ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── eslint.config.mjs ├── package.json ├── playground ├── app.vue ├── assets │ ├── svg-icons │ │ └── account-circle.svg │ └── virtual.icons.css ├── components │ └── Myinput.vue ├── layouts │ └── default.vue ├── nuxt.config.ts ├── package.json ├── pages │ ├── component │ │ ├── action-sheet.vue │ │ ├── app-bar.vue │ │ ├── avatar.vue │ │ ├── back-top.vue │ │ ├── badge.vue │ │ ├── bottom-navigation.vue │ │ ├── breadcrumbs.vue │ │ ├── button.vue │ │ ├── card.vue │ │ ├── cell.vue │ │ ├── checkbox.vue │ │ ├── chip.vue │ │ ├── collapse-transition.vue │ │ ├── collapse.vue │ │ ├── countdown.vue │ │ ├── counter.vue │ │ ├── date-picker.vue │ │ ├── dialog.vue │ │ ├── divider.vue │ │ ├── drag.vue │ │ ├── elevation.vue │ │ ├── ellipsis.vue │ │ ├── fab.vue │ │ ├── floating-panel.vue │ │ ├── form.vue │ │ ├── hover.vue │ │ ├── icon.vue │ │ ├── image-preview.vue │ │ ├── image.vue │ │ ├── index-bar.vue │ │ ├── input.vue │ │ ├── layout.vue │ │ ├── lazy.vue │ │ ├── link.vue │ │ ├── list.vue │ │ ├── loading-bar.vue │ │ ├── loading.vue │ │ ├── menu-select.vue │ │ ├── menu.vue │ │ ├── overlay.vue │ │ ├── pagination.vue │ │ ├── paper.vue │ │ ├── picker.vue │ │ ├── popup.vue │ │ ├── progress.vue │ │ ├── pull-refresh.vue │ │ ├── radio.vue │ │ ├── rate.vue │ │ ├── result.vue │ │ ├── ripple.vue │ │ ├── select.vue │ │ ├── skeleton.vue │ │ ├── slider.vue │ │ ├── snackbar.vue │ │ ├── space.vue │ │ ├── steps.vue │ │ ├── sticky.vue │ │ ├── style-provider.vue │ │ ├── swipe.vue │ │ ├── switch.vue │ │ ├── table.vue │ │ ├── tabs.vue │ │ ├── time-picker.vue │ │ ├── tooltip.vue │ │ ├── uploader.vue │ │ └── watermark.vue │ └── index.vue ├── pnpm-lock.yaml └── store.ts ├── pnpm-lock.yaml ├── src ├── config.ts ├── module.ts ├── types.ts └── utils.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | 4 | # Logs 5 | *.log* 6 | 7 | # Temp directories 8 | .temp 9 | .tmp 10 | .cache 11 | 12 | # Yarn 13 | **/.yarn/cache 14 | **/.yarn/*state* 15 | 16 | # Generated dirs 17 | dist 18 | 19 | # Nuxt 20 | .nuxt 21 | .output 22 | .vercel_build_output 23 | .build-* 24 | .env 25 | .netlify 26 | 27 | # Env 28 | .env 29 | 30 | # Testing 31 | reports 32 | coverage 33 | *.lcov 34 | .nyc_output 35 | 36 | # VSCode 37 | .vscode/* 38 | !.vscode/settings.json 39 | !.vscode/tasks.json 40 | !.vscode/launch.json 41 | !.vscode/extensions.json 42 | !.vscode/*.code-snippets 43 | 44 | # Intellij idea 45 | *.iml 46 | .idea 47 | 48 | # OSX 49 | .DS_Store 50 | .AppleDouble 51 | .LSOverride 52 | .AppleDB 53 | .AppleDesktop 54 | Network Trash Folder 55 | Temporary Items 56 | .apdisk 57 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | -------------------------------------------------------------------------------- /.nuxtrc: -------------------------------------------------------------------------------- 1 | imports.autoImport=true 2 | typescript.includeWorkspace=true 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | // Enable the ESlint flat config support 4 | "eslint.experimental.useFlatConfig": true, 5 | 6 | // Disable the default formatter, use eslint instead 7 | "prettier.enable": false, 8 | "editor.formatOnSave": false, 9 | 10 | // Auto fix 11 | "editor.codeActionsOnSave": { 12 | "source.fixAll.eslint": "explicit", 13 | "source.organizeImports": "never" 14 | }, 15 | 16 | // Silent the stylistic rules in you IDE, but still auto fix them 17 | "eslint.rules.customizations": [ 18 | { "rule": "style/*", "severity": "off" }, 19 | { "rule": "format/*", "severity": "off" }, 20 | { "rule": "*-indent", "severity": "off" }, 21 | { "rule": "*-spacing", "severity": "off" }, 22 | { "rule": "*-spaces", "severity": "off" }, 23 | { "rule": "*-order", "severity": "off" }, 24 | { "rule": "*-dangle", "severity": "off" }, 25 | { "rule": "*-newline", "severity": "off" }, 26 | { "rule": "*quotes", "severity": "off" }, 27 | { "rule": "*semi", "severity": "off" } 28 | ], 29 | 30 | // Enable eslint for all supported languages 31 | "eslint.validate": [ 32 | "javascript", 33 | "javascriptreact", 34 | "typescript", 35 | "typescriptreact", 36 | "vue", 37 | "html", 38 | "markdown", 39 | "json", 40 | "jsonc", 41 | "yaml", 42 | "toml" 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## v0.1.5 3 | 4 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.1.4...v0.1.5) 5 | 6 | ### 🩹 Fixes 7 | 8 | - Regexp fixed ([0b27f92](https://github.com/varletjs/varlet-nuxt/commit/0b27f92)) 9 | - Regexp fixed ([87d6d5c](https://github.com/varletjs/varlet-nuxt/commit/87d6d5c)) 10 | 11 | ### ❤️ Contributors 12 | 13 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 14 | 15 | ## v0.1.4 16 | 17 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.1.3...v0.1.4) 18 | 19 | ### 🩹 Fixes 20 | 21 | - When the option icon is undefined then filter the icon plugin ([1881d42](https://github.com/varletjs/varlet-nuxt/commit/1881d42)) 22 | 23 | ### 🏡 Chore 24 | 25 | - Updated to the final patch ([#21](https://github.com/varletjs/varlet-nuxt/pull/21)) 26 | - Upgrade dependency ([6e87eb7](https://github.com/varletjs/varlet-nuxt/commit/6e87eb7)) 27 | - Upgrade dependency to supports locale provider ([89bed3f](https://github.com/varletjs/varlet-nuxt/commit/89bed3f)) 28 | 29 | ### ❤️ Contributors 30 | 31 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 32 | - 阿菜 Cai ([@RSS1102](http://github.com/RSS1102)) 33 | 34 | ## v0.1.4-1718250695.6e87eb7 35 | 36 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.1.3...v0.1.4-1718250695.6e87eb7) 37 | 38 | ### 🏡 Chore 39 | 40 | - Updated to the final patch ([#21](https://github.com/varletjs/varlet-nuxt/pull/21)) 41 | - Upgrade dependency ([6e87eb7](https://github.com/varletjs/varlet-nuxt/commit/6e87eb7)) 42 | 43 | ### ❤️ Contributors 44 | 45 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 46 | - 阿菜 Cai ([@RSS1102](http://github.com/RSS1102)) 47 | 48 | ## v0.1.3 49 | 50 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.1.2...v0.1.3) 51 | 52 | 53 | ### 🚀 Enhancements 54 | 55 | - Integration varlet icon builder ([9313325](https://github.com/varletjs/varlet-nuxt/commit/9313325)) 56 | - Update the meta configKey & playground config ([0f96570](https://github.com/varletjs/varlet-nuxt/commit/0f96570)) 57 | 58 | ### 📖 Documentation 59 | 60 | - Declare the parameter passing method ([#19](https://github.com/varletjs/varlet-nuxt/pull/19)) 61 | 62 | ### 🏡 Chore 63 | 64 | - Remove unuse import ([98b4a3b](https://github.com/varletjs/varlet-nuxt/commit/98b4a3b)) 65 | 66 | ### ✅ Tests 67 | 68 | - 增加关于`@varlet/unplugin-icon-builder`的测试 ([#18](https://github.com/varletjs/varlet-nuxt/pull/18)) 69 | 70 | ### ❤️ Contributors 71 | 72 | - 阿菜 Cai ([@RSS1102](http://github.com/RSS1102)) 73 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 74 | 75 | ## v0.1.2 76 | 77 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.1.1...v0.1.2) 78 | 79 | 80 | ### 📖 Documentation 81 | 82 | - Use new `nuxi module add` command in installation ([#16](https://github.com/varletjs/varlet-nuxt/pull/16)) 83 | 84 | ### ❤️ Contributors 85 | 86 | - Daniel Roe ([@danielroe](http://github.com/danielroe)) 87 | 88 | ## v0.1.1 89 | 90 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.10...v0.1.1) 91 | 92 | 93 | ### 🚀 Enhancements 94 | 95 | - Support customer module path & rename excludeConfig ([2c03c31](https://github.com/varletjs/varlet-nuxt/commit/2c03c31)) 96 | 97 | ### 🏡 Chore 98 | 99 | - **release:** V0.0.10 ([ae4c94e](https://github.com/varletjs/varlet-nuxt/commit/ae4c94e)) 100 | - Update readme ([56c379b](https://github.com/varletjs/varlet-nuxt/commit/56c379b)) 101 | 102 | ### ❤️ Contributors 103 | 104 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 105 | 106 | ## v0.0.10 107 | 108 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.9...v0.0.10) 109 | 110 | ### 🩹 Fixes 111 | 112 | - Fix the path in dev ([2f8a036](https://github.com/varletjs/varlet-nuxt/commit/2f8a036)) 113 | 114 | ### 🏡 Chore 115 | 116 | - **release:** V0.0.9 ([c3476ac](https://github.com/varletjs/varlet-nuxt/commit/c3476ac)) 117 | 118 | ### ❤️ Contributors 119 | 120 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 121 | 122 | ## v0.0.9 123 | 124 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.7...v0.0.9) 125 | 126 | 127 | ### 🚀 Enhancements 128 | 129 | - Add button demo ([#11](https://github.com/varletjs/varlet-nuxt/pull/11)) 130 | - Add all varlet demo ([#13](https://github.com/varletjs/varlet-nuxt/pull/13)) 131 | - Processing path for lays ([577df5d](https://github.com/varletjs/varlet-nuxt/commit/577df5d)) 132 | 133 | ### 🩹 Fixes 134 | 135 | - Fix the build sourcemap warning ([3c7f1c4](https://github.com/varletjs/varlet-nuxt/commit/3c7f1c4)) 136 | 137 | ### 🏡 Chore 138 | 139 | - Update readme & dependencie ([b27b907](https://github.com/varletjs/varlet-nuxt/commit/b27b907)) 140 | 141 | ### ❤️ Contributors 142 | 143 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 144 | - Phil ([@lq-c](http://github.com/lq-c)) 145 | 146 | ## v0.0.7 147 | 148 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.6...v0.0.7) 149 | 150 | 151 | ### 🩹 Fixes 152 | 153 | - Component style lost fixed ([9089b0f](https://github.com/varletjs/varlet-nuxt/commit/9089b0f)) 154 | 155 | ### 🏡 Chore 156 | 157 | - **release:** V0.0.6 ([2a42e48](https://github.com/varletjs/varlet-nuxt/commit/2a42e48)) 158 | 159 | ### ❤️ Contributors 160 | 161 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 162 | 163 | ## v0.0.6 164 | 165 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.5...v0.0.6) 166 | 167 | 168 | ### 🚀 Enhancements 169 | 170 | - Make up the functional component ([6f2e3fd](https://github.com/varletjs/varlet-nuxt/commit/6f2e3fd)) 171 | 172 | ### ❤️ Contributors 173 | 174 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 175 | 176 | ## v0.0.5 177 | 178 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.4...v0.0.5) 179 | 180 | 181 | ### 🚀 Enhancements 182 | 183 | - Support the function component ([06d0f27](https://github.com/varletjs/varlet-nuxt/commit/06d0f27)) 184 | - Supports directive & lazy load component ([afd6516](https://github.com/varletjs/varlet-nuxt/commit/afd6516)) 185 | 186 | ### 💅 Refactors 187 | 188 | - The component import ([e5f9fd2](https://github.com/varletjs/varlet-nuxt/commit/e5f9fd2)) 189 | 190 | ### 🏡 Chore 191 | 192 | - Remove unuse code ([a9deb42](https://github.com/varletjs/varlet-nuxt/commit/a9deb42)) 193 | - **deps-dev:** Bump semver from 5.7.1 to 5.7.2 ([#6](https://github.com/varletjs/varlet-nuxt/pull/6)) 194 | 195 | ### ❤️ Contributors 196 | 197 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 198 | - Xiaomo ([@zhangmo8](http://github.com/zhangmo8)) 199 | 200 | ## v0.0.4 201 | 202 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.3...v0.0.4) 203 | 204 | 205 | ### 🚀 Enhancements 206 | 207 | - Supports the webpack plugin ([10be091](https://github.com/varletjs/varlet-nuxt/commit/10be091)) 208 | - Follow the automatic import configuration ([1dc4f19](https://github.com/varletjs/varlet-nuxt/commit/1dc4f19)) 209 | 210 | ### 🩹 Fixes 211 | 212 | - Complete the mission function components and replace pnpm 7.x to 8.x ([#2](https://github.com/varletjs/varlet-nuxt/pull/2)) 213 | 214 | ### ❤️ Contributors 215 | 216 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 217 | - Wegi8 <18272190626@163.com> 218 | - Haoziqaq ([@haoziqaq](http://github.com/haoziqaq)) 219 | 220 | ## v0.0.3 221 | 222 | [compare changes](https://github.com/varletjs/varlet-nuxt/compare/v0.0.2...v0.0.3) 223 | 224 | 225 | ### 🏡 Chore 226 | 227 | - Update the readme ([f643334](https://github.com/varletjs/varlet-nuxt/commit/f643334)) 228 | 229 | ### ❤️ Contributors 230 | 231 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 232 | 233 | ## v0.0.2 234 | 235 | 236 | ### 🚀 Enhancements 237 | 238 | - Component import finish ([c9b22b4](https://github.com/varletjs/varlet-nuxt/commit/c9b22b4)) 239 | - Directives and function component support ([a53e534](https://github.com/varletjs/varlet-nuxt/commit/a53e534)) 240 | - Function component supports ([7f2e90e](https://github.com/varletjs/varlet-nuxt/commit/7f2e90e)) 241 | 242 | ### 🏡 Chore 243 | 244 | - Update readme ([b3028ed](https://github.com/varletjs/varlet-nuxt/commit/b3028ed)) 245 | - Directive debugger ([873f52c](https://github.com/varletjs/varlet-nuxt/commit/873f52c)) 246 | - **release:** V1.1.0 ([de56b8b](https://github.com/varletjs/varlet-nuxt/commit/de56b8b)) 247 | 248 | ### ❤️ Contributors 249 | 250 | - Zhangmo8 ([@zhangmo8](http://github.com/zhangmo8)) 251 | - Jiahengz 252 | - Wegi8 253 | 254 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 varletjs 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Varlet Nuxt 2 | 3 | 🌟 Inspired by [vant-nuxt](https://github.com/vant-ui/vant-nuxt) and [element-plus-nuxt](https://github.com/element-plus/element-plus-nuxt) 4 | 5 | Welcome to contribute this repo 6 | 7 | Varlet Module for Nuxt3 8 | 9 | ## Feature 10 | 11 | - Auto import Varlet component in you Nuxt Project 12 | - Auto import Varlet the directive 13 | - Lazy load component 14 | - Material Design Nuxt Component with Material 3 Version 15 | 16 | ## Quick Setup 17 | 18 | 1. Add `@varlet/nuxt` dependency to your project 19 | 20 | ```bash 21 | npx nuxi@latest module add varlet 22 | ``` 23 | 24 | 2. Add `@varlet/nuxt` to the `modules` section of `nuxt.config.ts` 25 | 26 | ```js 27 | export default defineNuxtConfig({ 28 | modules: ['@varlet/nuxt'], 29 | varlet: { 30 | modulePath: '...', 31 | exclude: ['...'], 32 | icon: {} 33 | } 34 | }) 35 | ``` 36 | 37 | That's it! You can now use Varlet Module in your Nuxt app ✨ 38 | 39 | tips: If you running `varlet` on the PC. Please install [`@varlet/touch-emulator`](https://varlet.gitee.io/varlet-ui/#/zh-CN/browserAdaptation) 40 | 41 | ### Options 42 | 43 | | fieldName | require | default | effect | 44 | | ---------- | ------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------- | 45 | | modulePath | false | undefind | customer you workspace path if you want | 46 | | exclude | false | '.nuxt', 'node_modules' | exclude some path that you won't transform | 47 | | icon | false | undefined | [svg icon to iconfont](https://github.com/varletjs/varlet-iconx/tree/main/packages/varlet-unplugin-icon-builder) | 48 | 49 | ## Contribution 50 | 51 | We recommend using pnpm 52 | 53 | ```bash 54 | # Install dependencies 55 | pnpm install 56 | 57 | # Generate type stubs 58 | pnpm run dev:prepare 59 | 60 | # Develop with the playground 61 | pnpm run dev 62 | 63 | # Build the playground 64 | pnpm run dev:build 65 | 66 | # Run ESLint 67 | pnpm run lint 68 | 69 | # Release new version 70 | pnpm run release 71 | ``` 72 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // eslint.config.js 2 | import antfu from '@antfu/eslint-config' 3 | 4 | export default antfu({ 5 | ignores: [ 6 | '**/fixtures', 7 | '**/node_modules', 8 | '**/dist', 9 | '**/.nuxt', 10 | ], 11 | }) 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@varlet/nuxt", 3 | "type": "module", 4 | "version": "0.1.5", 5 | "description": "varlet module for nuxt", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/varletjs/varlet-nuxt.git" 10 | }, 11 | "bugs": "https://github.com/varletjs/varlet-nuxt/issues", 12 | "keywords": [ 13 | "varlet", 14 | "nuxt" 15 | ], 16 | "exports": { 17 | ".": { 18 | "types": "./dist/types.d.ts", 19 | "import": "./dist/module.mjs", 20 | "require": "./dist/module.cjs" 21 | } 22 | }, 23 | "main": "./dist/module.cjs", 24 | "types": "./dist/types.d.ts", 25 | "files": [ 26 | "dist" 27 | ], 28 | "scripts": { 29 | "preinstall": "npx only-allow pnpm", 30 | "prepack": "nuxt-module-build build", 31 | "clear": "rm -rf ./playground/node_modules/.cache && rm -rf ./playground/.nuxt", 32 | "dev": "nuxi dev playground", 33 | "dev:build": "nuxi build playground", 34 | "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground", 35 | "build": "npm run dev:prepare && nuxt-module-build build", 36 | "gen": "npx changelogen --release", 37 | "release:beta": "npm run build && npx changelogen --canary && npm publish --beta && git push --follow-tags", 38 | "release": "npm run build && npx changelogen --release && npm publish && git push --follow-tags", 39 | "lint": "eslint . --fix" 40 | }, 41 | "peerDependencies": { 42 | "@varlet/ui": "latest" 43 | }, 44 | "dependencies": { 45 | "@nuxt/kit": "^3.12.1", 46 | "@varlet/ui": "3.3.0", 47 | "@varlet/unplugin-icon-builder": "^0.2.28", 48 | "knitwork": "^1.1.0", 49 | "magic-string": "^0.30.10", 50 | "unplugin": "^1.10.1" 51 | }, 52 | "devDependencies": { 53 | "@antfu/eslint-config": "^2.21.1", 54 | "@nuxt/eslint-config": "^0.3.13", 55 | "@nuxt/module-builder": "^0.7.1", 56 | "@nuxt/schema": "^3.12.1", 57 | "@nuxtjs/eslint-config-typescript": "^12.1.0", 58 | "@types/node": "^20.14.2", 59 | "changelogen": "^0.5.5", 60 | "eslint": "^9.4.0", 61 | "husky": "^9.0.11", 62 | "lint-staged": "^15.2.6", 63 | "nuxt": "^3.12.1", 64 | "typescript": "^5.4.5" 65 | }, 66 | "husky": { 67 | "hooks": { 68 | "pre-commit": "lint-staged" 69 | } 70 | }, 71 | "lint-staged": { 72 | "*.{js,jsx}": [ 73 | "eslint --fix", 74 | "git add" 75 | ], 76 | "*.{ts,tsx}": [ 77 | "eslint --fix", 78 | "git add" 79 | ] 80 | }, 81 | "publishConfig": { 82 | "access": "public", 83 | "registry": "https://registry.npmjs.org/" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /playground/app.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 16 | -------------------------------------------------------------------------------- /playground/assets/svg-icons/account-circle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /playground/assets/virtual.icons.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "i-icons"; 3 | src: url("data:font/truetype;charset=utf-8;base64,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") format("truetype"); 4 | font-weight: normal; 5 | font-style: normal; 6 | } 7 | 8 | .i { 9 | font-family: "i-icons"; 10 | font-style: normal; 11 | } 12 | 13 | .i-account-circle::before { 14 | content: "\ea01"; 15 | } 16 | -------------------------------------------------------------------------------- /playground/components/Myinput.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 24 | 25 | 30 | -------------------------------------------------------------------------------- /playground/nuxt.config.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'node:path' 2 | import { defineNuxtConfig } from 'nuxt/config' 3 | import varletModules from '..' 4 | 5 | const svgIconsDir = resolve(__dirname, './assets/svg-icons') 6 | 7 | export default defineNuxtConfig({ 8 | modules: [varletModules], 9 | varlet: { 10 | icon: { 11 | dir: svgIconsDir, 12 | generatedFilename: './playground/assets/virtual.icons.css', 13 | }, 14 | }, 15 | }) 16 | -------------------------------------------------------------------------------- /playground/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-module-playground", 3 | "private": true, 4 | "scripts": { 5 | "build": "nuxt build", 6 | "dev": "nuxt dev --host --port=8888", 7 | "generate": "nuxt generate", 8 | "preview": "nuxt preview", 9 | "postinstall": "nuxt prepare" 10 | }, 11 | "dependencies": { 12 | "@varlet/touch-emulator": "^3.0.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /playground/pages/component/action-sheet.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 29 | -------------------------------------------------------------------------------- /playground/pages/component/app-bar.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 43 | -------------------------------------------------------------------------------- /playground/pages/component/avatar.vue: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/back-top.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 13 | -------------------------------------------------------------------------------- /playground/pages/component/badge.vue: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /playground/pages/component/bottom-navigation.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /playground/pages/component/breadcrumbs.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/button.vue: -------------------------------------------------------------------------------- 1 | 6 | 26 | -------------------------------------------------------------------------------- /playground/pages/component/card.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/cell.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 41 | -------------------------------------------------------------------------------- /playground/pages/component/checkbox.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 26 | -------------------------------------------------------------------------------- /playground/pages/component/chip.vue: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /playground/pages/component/collapse-transition.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /playground/pages/component/collapse.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | -------------------------------------------------------------------------------- /playground/pages/component/countdown.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/counter.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/date-picker.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/dialog.vue: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | -------------------------------------------------------------------------------- /playground/pages/component/divider.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /playground/pages/component/drag.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/elevation.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 12 | 13 | 27 | -------------------------------------------------------------------------------- /playground/pages/component/ellipsis.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /playground/pages/component/fab.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 22 | -------------------------------------------------------------------------------- /playground/pages/component/floating-panel.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /playground/pages/component/form.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 82 | -------------------------------------------------------------------------------- /playground/pages/component/hover.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | 20 | 43 | -------------------------------------------------------------------------------- /playground/pages/component/icon.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /playground/pages/component/image-preview.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | -------------------------------------------------------------------------------- /playground/pages/component/image.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /playground/pages/component/index-bar.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 24 | 25 | 36 | -------------------------------------------------------------------------------- /playground/pages/component/input.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 50 | 51 | 60 | -------------------------------------------------------------------------------- /playground/pages/component/layout.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 47 | -------------------------------------------------------------------------------- /playground/pages/component/lazy.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /playground/pages/component/link.vue: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /playground/pages/component/list.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 28 | -------------------------------------------------------------------------------- /playground/pages/component/loading-bar.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 41 | -------------------------------------------------------------------------------- /playground/pages/component/loading.vue: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/menu-select.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 20 | -------------------------------------------------------------------------------- /playground/pages/component/menu.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /playground/pages/component/overlay.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | -------------------------------------------------------------------------------- /playground/pages/component/pagination.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /playground/pages/component/paper.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /playground/pages/component/picker.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 26 | -------------------------------------------------------------------------------- /playground/pages/component/popup.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 75 | 76 | 82 | -------------------------------------------------------------------------------- /playground/pages/component/progress.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 32 | -------------------------------------------------------------------------------- /playground/pages/component/pull-refresh.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /playground/pages/component/radio.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 20 | -------------------------------------------------------------------------------- /playground/pages/component/rate.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | -------------------------------------------------------------------------------- /playground/pages/component/result.vue: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/ripple.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 20 | -------------------------------------------------------------------------------- /playground/pages/component/select.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 133 | 134 | 151 | -------------------------------------------------------------------------------- /playground/pages/component/skeleton.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | -------------------------------------------------------------------------------- /playground/pages/component/slider.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/snackbar.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /playground/pages/component/space.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/steps.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | -------------------------------------------------------------------------------- /playground/pages/component/sticky.vue: -------------------------------------------------------------------------------- 1 | /* 2 | *此组件需要客户端渲染 3 | *使用时需使用client-only包裹 4 | **/ 5 | 6 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /playground/pages/component/style-provider.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 32 | -------------------------------------------------------------------------------- /playground/pages/component/swipe.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 27 | -------------------------------------------------------------------------------- /playground/pages/component/switch.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/table.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 48 | 49 | 58 | -------------------------------------------------------------------------------- /playground/pages/component/tabs.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /playground/pages/component/time-picker.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /playground/pages/component/tooltip.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playground/pages/component/uploader.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 19 | -------------------------------------------------------------------------------- /playground/pages/component/watermark.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | -------------------------------------------------------------------------------- /playground/pages/index.vue: -------------------------------------------------------------------------------- 1 | 86 | 87 | 108 | 109 | 123 | -------------------------------------------------------------------------------- /playground/pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | dependencies: 8 | '@varlet/touch-emulator': 9 | specifier: ^3.0.3 10 | version: 3.0.3 11 | 12 | packages: 13 | 14 | /@varlet/touch-emulator@3.0.3: 15 | resolution: {integrity: sha512-egVFgA0829qYO0ykaz4PlwpLEUuXEuQmb3rd6C2QtWbSwSM9xoxOjCCwlcxZbTySOGs3llXEPN6O3IwwHLOQRA==} 16 | dev: false 17 | -------------------------------------------------------------------------------- /playground/store.ts: -------------------------------------------------------------------------------- 1 | export const locale = ref('en-US') 2 | 3 | export function switchLocale() { 4 | const targetLocale = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN' 5 | setLocale(targetLocale) 6 | } 7 | 8 | export const messages = ref({ 9 | 'zh-CN': Locale.zhCN, 10 | 'en-US': Locale.enUS, 11 | }) 12 | 13 | function setLocale(value: string) { 14 | locale.value = value 15 | 16 | Locale.add(value, messages.value[value as keyof typeof messages.value]) 17 | Locale.use(value) 18 | } 19 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | export const moduleName = '@varlet/ui' 2 | 3 | export const nameSpace = 'var' 4 | 5 | export const functional: string[] = [ 6 | 'ImagePreview', 7 | 'Snackbar', 8 | 'Picker', 9 | 'ActionSheet', 10 | 'Dialog', 11 | 'Locale', 12 | 'StyleProvider', 13 | 'LoadingBar', 14 | ] 15 | 16 | export const directives = ['ripple', 'lazy', 'hover'] 17 | 18 | export const excludeFolders = ['.nuxt', 'node_modules'] 19 | -------------------------------------------------------------------------------- /src/module.ts: -------------------------------------------------------------------------------- 1 | import { cwd } from 'node:process' 2 | import { addComponentsDir, addImports, createResolver, defineNuxtModule } from '@nuxt/kit' 3 | import type { Nuxt } from '@nuxt/schema' 4 | import { createUnplugin } from 'unplugin' 5 | import MagicString from 'magic-string' 6 | import { genImport } from 'knitwork' 7 | 8 | import iconBuilderVite from '@varlet/unplugin-icon-builder/vite' 9 | import iconBuilderWebpack from '@varlet/unplugin-icon-builder/webpack' 10 | 11 | import type { ModuleOptions } from './types' 12 | import { directives, excludeFolders, functional, moduleName, nameSpace } from './config' 13 | import { genStylePath, pascalCase } from './utils' 14 | 15 | const componentReg = /_component_[vV]ar\w+ /g 16 | const functionComponentReg = new RegExp(functional.join('|'), 'g') 17 | 18 | const directiveReg = new RegExp(`_resolveDirective\\(\\"(${directives.join('|')})\\"\\)`, 'g') 19 | 20 | const CMD = cwd() 21 | const { resolve } = createResolver(import.meta.url) 22 | const relativePath = resolve(CMD, `node_modules/${moduleName}`) 23 | 24 | function matchComponentName(componentStr: string): string { 25 | const componentName = componentStr.replace(/_component_(v|V)ar(|_)+/, '').replaceAll('_', '-') 26 | return componentName.trim() 27 | } 28 | 29 | const transformPathPlugin = createUnplugin((pluginOptions) => { 30 | const { exclude = [] } = pluginOptions 31 | 32 | return { 33 | name: `${moduleName}:transform`, 34 | enforce: 'post', 35 | transformInclude(id) { 36 | return ![...excludeFolders, ...exclude].some(entry => id.includes(entry)) 37 | }, 38 | transform(_code) { 39 | const code: MagicString = new MagicString(_code) 40 | 41 | code.replace(componentReg, (componentStr: string) => { 42 | const componentName = matchComponentName(componentStr) 43 | 44 | if (componentName) 45 | code.prepend(genStylePath(componentName)) 46 | 47 | return componentStr 48 | }) 49 | 50 | code.replace(functionComponentReg, (componentStr: string) => { 51 | code.prepend(genStylePath(componentStr)) 52 | return componentStr 53 | }) 54 | 55 | code.replace(directiveReg, (directiveStr) => { 56 | const directiveName = directiveStr.match(new RegExp(`${directives.join('|')}`))?.[0] 57 | 58 | if (directiveName) { 59 | code.prepend(genImport(`${moduleName}`, [ 60 | { 61 | name: pascalCase(directiveName), 62 | }, 63 | ])) 64 | code.prepend(genStylePath(directiveName)) 65 | 66 | return pascalCase(directiveName) 67 | } 68 | 69 | return directiveStr 70 | }) 71 | 72 | if (code.hasChanged()) { 73 | return { 74 | code: code.toString(), 75 | map: code.generateMap({ source: moduleName, includeContent: true }), 76 | } 77 | } 78 | }, 79 | } 80 | }) 81 | 82 | export default defineNuxtModule({ 83 | meta: { 84 | name: moduleName, 85 | configKey: 'varlet', 86 | }, 87 | setup(_options: ModuleOptions, nuxt: Nuxt) { 88 | nuxt.options.build.transpile.push(moduleName) 89 | 90 | addComponentsDir({ 91 | path: `${_options?.modulePath || relativePath}/es`, 92 | prefix: nameSpace, 93 | pathPrefix: true, 94 | extensions: ['js', 'vue', 'ts', 'mjs'], 95 | pattern: ['**/**/index.*'], 96 | extendComponent(component) { 97 | const componentName = component.pascalName.replace(pascalCase(nameSpace), '') 98 | return { 99 | ...component, 100 | export: `_${componentName}Component`, 101 | } 102 | }, 103 | }) 104 | 105 | addImports(functional.map((name: any) => 106 | ({ name, from: `${moduleName}` }), 107 | )) 108 | 109 | nuxt.hook('vite:extendConfig', (config) => { 110 | config.plugins = config.plugins || [] 111 | config.plugins.push(transformPathPlugin.vite(_options), _options?.icon && iconBuilderVite(_options?.icon)) 112 | }) 113 | 114 | nuxt.hook('webpack:config', (configs) => { 115 | configs.forEach((config) => { 116 | config.plugins.push(transformPathPlugin.webpack(_options), _options?.icon && iconBuilderWebpack(_options?.icon)) 117 | }) 118 | }) 119 | }, 120 | }) 121 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from '@varlet/unplugin-icon-builder/types' 2 | 3 | export interface ModuleOptions { 4 | modulePath?: string 5 | exclude?: string[] 6 | icon?: Options 7 | } 8 | 9 | declare module '@nuxt/schema' { 10 | interface NuxtConfig { 11 | varlet?: Partial 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import { genImport } from 'knitwork' 2 | import { moduleName } from './config' 3 | 4 | export function genStylePath(dirName: string) { 5 | return genImport(`${moduleName}/es/${kebabCase(dirName)}/style/index.mjs`) 6 | } 7 | 8 | export function pascalCase(str: string): string { 9 | return str 10 | .split(/[^a-z0-9]/i) 11 | .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) 12 | .join('') 13 | } 14 | 15 | export function kebabCase(str: string): string { 16 | return str 17 | .replace(/([a-z])([A-Z])/g, '$1-$2') 18 | .toLowerCase() 19 | .trim() 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./playground/.nuxt/tsconfig.json", 3 | 4 | "compilerOptions": { 5 | "moduleResolution": "node", 6 | "skipLibCheck": true 7 | } 8 | } 9 | --------------------------------------------------------------------------------