diff --git a/components/lib/config/PrimeVue.d.ts b/components/lib/config/PrimeVue.d.ts index 12ec2e6b4..7fc4b0971 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -101,6 +101,8 @@ export interface PrimeVueConfiguration { locale?: PrimeVueLocaleOptions; filterMatchModeOptions?: any; zIndex?: PrimeVueZIndexOptions; + theme?: any; + unstyled?: boolean; pt?: PassThrough; ptOptions?: PassThroughOptions; csp?: PrimeVueCSPOptions; diff --git a/components/lib/config/PrimeVue.js b/components/lib/config/PrimeVue.js index 2fd736135..7541d6176 100644 --- a/components/lib/config/PrimeVue.js +++ b/components/lib/config/PrimeVue.js @@ -133,6 +133,8 @@ export const defaultOptions = { menu: 1000, tooltip: 1100 }, + theme: undefined, + unstyled: false, pt: undefined, ptOptions: { mergeSections: true, @@ -167,7 +169,9 @@ export function setup(app, options) { } export default { - install: () => { - console.error("This plugin has been removed in v4 version. Use 'PrimeVueStyled' plugin for styled mode, and 'PrimeVueUnstyled' plugin for unstyled mode."); + install: (app, options) => { + const configOptions = { ...defaultOptions, ...options }; + + setup(app, configOptions); } }; diff --git a/modules/nuxt-primevue/module.js b/modules/nuxt-primevue/module.js index c6c821496..cc0ada2ce 100644 --- a/modules/nuxt-primevue/module.js +++ b/modules/nuxt-primevue/module.js @@ -15,7 +15,7 @@ export default defineNuxtModule({ layerOrder: 'tailwind-base, primevue, tailwind-utilities', importPT: undefined, importTheme: undefined, - unstyled: false, + unstyled: undefined, options: {}, components: { prefix: '', @@ -41,7 +41,7 @@ export default defineNuxtModule({ const resolver = createResolver(import.meta.url); const registered = register(moduleOptions); const { importPT, importTheme, options, unstyled } = moduleOptions; - const hasTheme = importTheme && !unstyled; + const hasTheme = importTheme && unstyled !== true && !options.unstyled; nuxt.options.runtimeConfig.public.primevue = { ...moduleOptions, @@ -103,7 +103,7 @@ export default defineNuxtPlugin(({ vueApp }) => { const pt = ${importPT ? `{ pt: ${importPT.as} }` : `{}`}; const theme = ${hasTheme ? `{ theme: ${importTheme.as} }` : `{}`}; - usePrimeVue && vueApp.use(${unstyled ? 'PrimeVueUnstyled' : 'PrimeVueStyled'}, { ...options, ...pt, ...theme }); + usePrimeVue && vueApp.use(${unstyled === true ? 'PrimeVueUnstyled' : unstyled === false ? 'PrimeVueStyled' : 'PrimeVue'}, { ...options, ...pt, ...theme }); ${registered.services.map((service) => `vueApp.use(${service.as});`).join('\n')} ${registered.directives.map((directive) => `vueApp.directive('${directive.name}', ${directive.as});`).join('\n')} }); diff --git a/modules/nuxt-primevue/register.js b/modules/nuxt-primevue/register.js index 07da9dc85..f604a81a0 100644 --- a/modules/nuxt-primevue/register.js +++ b/modules/nuxt-primevue/register.js @@ -17,20 +17,26 @@ function registerItems(items = [], options = {}, params) { }); } -function registerConfig(resolvePath, unstyled = false) { - return [ - unstyled - ? { - name: 'PrimeVueUnstyled', - as: 'PrimeVueUnstyled', - from: resolvePath({ name: 'PrimeVueUnstyled', as: 'PrimeVueUnstyled', from: `primevue/unstyled`, type: 'config' }) - } - : { - name: 'PrimeVueStyled', - as: 'PrimeVueStyled', - from: resolvePath({ name: 'PrimeVueStyled', as: 'PrimeVueStyled', from: `primevue/styled`, type: 'config' }) - } - ]; +function registerConfig(resolvePath, moduleOptions) { + const configs = []; + + if (moduleOptions.unstyled === true) { + configs.push({ + name: 'PrimeVueUnstyled', + as: 'PrimeVueUnstyled', + from: resolvePath({ name: 'PrimeVueUnstyled', as: 'PrimeVueUnstyled', from: `primevue/unstyled`, type: 'config' }) + }); + } else if (moduleOptions.unstyled === false) { + configs.push({ + name: 'PrimeVueStyled', + as: 'PrimeVueStyled', + from: resolvePath({ name: 'PrimeVueStyled', as: 'PrimeVueStyled', from: `primevue/styled`, type: 'config' }) + }); + } else { + configs.push({ name: 'PrimeVue', as: 'PrimeVue', from: resolvePath({ name: 'PrimeVue', as: 'PrimeVue', from: `primevue/config`, type: 'config' }) }); + } + + return configs; } function registerComponents(resolvePath, options = {}) { @@ -140,7 +146,7 @@ function registerInjectStylesAsString(moduleOptions) { export function register(moduleOptions) { const resolvePath = (resolveOptions) => Utils.object.getPath(moduleOptions.resolvePath, resolveOptions); - const config = registerConfig(resolvePath, moduleOptions.unstyled); + const config = registerConfig(resolvePath, moduleOptions); const components = registerComponents(resolvePath, moduleOptions.components); const directives = registerDirectives(resolvePath, moduleOptions.directives); const composables = registerComposables(resolvePath, moduleOptions.composables); diff --git a/nuxt.config.js b/nuxt.config.js index 991c45457..6832a9882 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -25,6 +25,7 @@ export default defineNuxtConfig({ options: { ripple: true }, + unstyled: false, layerOrder: 'primevue', importTheme: { from: '@/themes/aura.js' }, resolvePath: function ({ as, from, type }) {