Skip to content

Commit 50b8af7

Browse files
committed
feat(unstyled): safer handling of usePrimeVue
1 parent ed2d1ed commit 50b8af7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/composables/useFormKitInput.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { usePrimeVue } from 'primevue/config'
22
import { computed } from 'vue'
33

44
export function useFormKitInput(context: any) {
5-
const primevue = usePrimeVue()
6-
75
const isInvalid = computed(() => {
86
return context?.state.validationVisible && !context?.state.valid
97
})
@@ -12,8 +10,20 @@ export function useFormKitInput(context: any) {
1210
return (context?.state.validationVisible && !context?.state.valid) ? `${context?.attrs?.class} p-invalid` : context?.attrs?.class
1311
})
1412

13+
function isGlobalUnstyledMode(): boolean {
14+
let result = false
15+
try {
16+
const primevue = usePrimeVue()
17+
result = primevue?.config?.unstyled || false
18+
}
19+
// eslint-disable-next-line unused-imports/no-unused-vars
20+
catch (e) {
21+
}
22+
return result
23+
}
24+
1525
const unstyled = computed(() => {
16-
return context?.unstyled ?? primevue?.config?.unstyled
26+
return context?.unstyled ?? isGlobalUnstyledMode()
1727
})
1828

1929
function handleBlur(event: Event) {

0 commit comments

Comments
 (0)