Merge branch 'dev' of https://github.com/sadeghbarati/shadcn-vue into update-www-docs

This commit is contained in:
Sadegh Barati 2023-09-12 23:02:43 +03:30
commit ba8e360e4b
6 changed files with 35 additions and 33 deletions

View File

@ -15,15 +15,15 @@ Accessible and customizable components that you can copy and paste into your app
## Documentation ## Documentation
Visit https://shadcn-vue.com/docs to view the documentation. [View documentation here](https://www.shadcn-vue.com/docs/introduction.html)
## Credits ## Credits
All credits go to these open-source works and resources All credits go to these open-source works and resources
- [Shadnc UI](https://ui.shadcn.com) for creating this beautiful project - [Shadcn UI](https://ui.shadcn.com) for creating this beautiful project.
- [Shadnc Svelte](https://shadcn-svelte.com) for some inspiration for registry - [Shadcn Svelte](https://shadcn-svelte.com) for some inspiration for registry.
- [Radix Vue](https://radix-vue.com) for doing all the hard work to make sure components are accessible - [Radix Vue](https://radix-vue.com) for doing all the hard work to make sure components are accessible.
- [VueUse](https://vueuse.org) for providing many useful utilities. - [VueUse](https://vueuse.org) for providing many useful utilities.
- [ahmedmayara](https://github.com/ahmedmayara/shadcn-vue) for populating many components - [ahmedmayara](https://github.com/ahmedmayara/shadcn-vue) for populating many components

View File

@ -20,9 +20,7 @@ const { config } = useConfigStore()
<Select v-model="config.style"> <Select v-model="config.style">
<SelectTrigger :class="cn('h-7 w-[145px] text-xs [&_svg]:h-4 [&_svg]:w-4', props.class)"> <SelectTrigger :class="cn('h-7 w-[145px] text-xs [&_svg]:h-4 [&_svg]:w-4', props.class)">
<span class="text-muted-foreground">Style: </span> <span class="text-muted-foreground">Style: </span>
<SelectValue placeholder="Select style"> <SelectValue placeholder="Select style" />
{{ styles.find(s => s.name === config.style)?.label }}
</SelectValue>
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem v-for="style in styles" :key="style.name" :value="style.name" class="text-xs"> <SelectItem v-for="style in styles" :key="style.name" :value="style.name" class="text-xs">

View File

@ -39,7 +39,7 @@
"@vue/compiler-dom": "^3.3.4", "@vue/compiler-dom": "^3.3.4",
"autoprefixer": "^10.4.15", "autoprefixer": "^10.4.15",
"lodash.template": "^4.5.0", "lodash.template": "^4.5.0",
"radix-vue": "^0.1.33", "radix-vue": "^0.1.34",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"tailwind-merge": "^1.14.0", "tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3", "tailwindcss": "^3.3.3",

View File

@ -61,7 +61,7 @@
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"ora": "^7.0.1", "ora": "^7.0.1",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"radix-vue": "^0.1.32", "radix-vue": "^0.1.34",
"recast": "^0.23.4", "recast": "^0.23.4",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-morph": "^19.0.0", "ts-morph": "^19.0.0",

View File

@ -1,6 +1,7 @@
import path from 'node:path' import path from 'node:path'
import { existsSync } from 'node:fs' import { existsSync } from 'node:fs'
import { cosmiconfig } from 'cosmiconfig' import { cosmiconfig } from 'cosmiconfig'
import type { ConfigLoaderResult } from 'tsconfig-paths'
import { loadConfig } from 'tsconfig-paths' import { loadConfig } from 'tsconfig-paths'
import * as z from 'zod' import * as z from 'zod'
import { resolveImport } from '@/src/utils/resolve-import' import { resolveImport } from '@/src/utils/resolve-import'
@ -62,24 +63,27 @@ export async function getConfig(cwd: string) {
} }
export async function resolveConfigPaths(cwd: string, config: RawConfig) { export async function resolveConfigPaths(cwd: string, config: RawConfig) {
const TSCONFIG_PATH = config.framework === 'nuxt' ? '.nuxt/tsconfig.json' : './tsconfig.json' let tsConfig: ConfigLoaderResult | undefined
if (config.typescript) {
const TSCONFIG_PATH = config.framework === 'nuxt' ? '.nuxt/tsconfig.json' : './tsconfig.json'
// Read tsconfig.json. // Read tsconfig.json.
const tsconfigPath = path.resolve(cwd, TSCONFIG_PATH) const tsconfigPath = path.resolve(cwd, TSCONFIG_PATH)
let tsConfig = loadConfig(tsconfigPath) tsConfig = loadConfig(tsconfigPath)
// In new Vue project, tsconfig has references to tsconfig.app.json, which is causing the path not resolving correctly // In new Vue project, tsconfig has references to tsconfig.app.json, which is causing the path not resolving correctly
// If no paths were found, try to load tsconfig.app.json. // If no paths were found, try to load tsconfig.app.json.
if ('paths' in tsConfig && Object.keys(tsConfig.paths).length === 0) { if ('paths' in tsConfig && Object.keys(tsConfig.paths).length === 0) {
const FALLBACK_TSCONFIG_PATH = path.resolve(cwd, './tsconfig.app.json') const FALLBACK_TSCONFIG_PATH = path.resolve(cwd, './tsconfig.app.json')
if (existsSync(FALLBACK_TSCONFIG_PATH)) if (existsSync(FALLBACK_TSCONFIG_PATH))
tsConfig = loadConfig(FALLBACK_TSCONFIG_PATH) tsConfig = loadConfig(FALLBACK_TSCONFIG_PATH)
} }
if (tsConfig.resultType === 'failed') { if (tsConfig.resultType === 'failed') {
throw new Error( throw new Error(
`Failed to load tsconfig.json. ${tsConfig.message ?? ''}`.trim(), `Failed to load tsconfig.json. ${tsConfig.message ?? ''}`.trim(),
) )
}
} }
return configSchema.parse({ return configSchema.parse({
@ -87,8 +91,8 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) {
resolvedPaths: { resolvedPaths: {
tailwindConfig: path.resolve(cwd, config.tailwind.config), tailwindConfig: path.resolve(cwd, config.tailwind.config),
tailwindCss: path.resolve(cwd, config.tailwind.css), tailwindCss: path.resolve(cwd, config.tailwind.css),
utils: await resolveImport(config.aliases.utils, tsConfig), utils: tsConfig ? await resolveImport(config.aliases.utils, tsConfig) : config.aliases.utils,
components: await resolveImport(config.aliases.components, tsConfig), components: tsConfig ? await resolveImport(config.aliases.components, tsConfig) : config.aliases.components,
}, },
}) })
} }

View File

@ -115,8 +115,8 @@ importers:
specifier: ^4.5.0 specifier: ^4.5.0
version: 4.5.0 version: 4.5.0
radix-vue: radix-vue:
specifier: ^0.1.33 specifier: ^0.1.34
version: 0.1.33(vue@3.3.4) version: 0.1.34(vue@3.3.4)
rimraf: rimraf:
specifier: ^5.0.1 specifier: ^5.0.1
version: 5.0.1 version: 5.0.1
@ -196,8 +196,8 @@ importers:
specifier: ^2.4.2 specifier: ^2.4.2
version: 2.4.2 version: 2.4.2
radix-vue: radix-vue:
specifier: ^0.1.32 specifier: ^0.1.34
version: 0.1.32(vue@3.3.4) version: 0.1.34(vue@3.3.4)
recast: recast:
specifier: ^0.23.4 specifier: ^0.23.4
version: 0.23.4 version: 0.23.4
@ -6383,8 +6383,8 @@ packages:
resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==} resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==}
dev: false dev: false
/radix-vue@0.1.32(vue@3.3.4): /radix-vue@0.1.34(vue@3.3.4):
resolution: {integrity: sha512-z6vlBDT0GuVP2vu2LKJjWnyQB8jDWwE0eGqgO3IlrpeLOq5zpDA+ReaOJyJjf8m1We539fy+9wubKaBnHfBalw==} resolution: {integrity: sha512-x5Mv8pFT43Ubz0md6gG/5+Zkz8QrOnZXnk2b1CFSrfHebykYNLAW3jX47sf4nmoDYYvH3mAi9QU1XMlCl7/h8Q==}
dependencies: dependencies:
'@floating-ui/dom': 1.5.1 '@floating-ui/dom': 1.5.1
'@floating-ui/vue': 1.0.2(vue@3.3.4) '@floating-ui/vue': 1.0.2(vue@3.3.4)