Skip to content

Commit ef77574

Browse files
committed
feat: add prefix option to headless ui resolver
1 parent e613c81 commit ef77574

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/core/resolvers/headless-ui.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,35 @@ const components = [
4242
'TabPanel',
4343
]
4444

45+
export interface HeadlessUiResolverOptions {
46+
/**
47+
* prefix for headless ui components used in templates
48+
*
49+
* @default ""
50+
*/
51+
prefix?: string
52+
}
53+
4554
/**
4655
* Resolver for headlessui
4756
*
4857
* @link https://github.com/tailwindlabs/headlessui
4958
*/
50-
export function HeadlessUiResolver(): ComponentResolver {
59+
export function HeadlessUiResolver({
60+
prefix = ""
61+
}: HeadlessUiResolverOptions): ComponentResolver {
5162
return {
5263
type: 'component',
5364
resolve: (name: string) => {
54-
if (components.includes(name))
55-
return { importName: name, path: '@headlessui/vue' }
65+
if (name.startsWith(prefix)) {
66+
const componentName = name.replace(new RegExp(`\^\(${prefix}\)`), "")
67+
if (components.includes(componentName)) {
68+
return {
69+
importName: componentName,
70+
path: "@headlessui/vue",
71+
}
72+
}
73+
}
5674
}
5775
}
5876
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy