Refactor #5502
parent
5671752903
commit
e896552ccb
|
@ -101,6 +101,8 @@ export interface PrimeVueConfiguration {
|
|||
locale?: PrimeVueLocaleOptions;
|
||||
filterMatchModeOptions?: any;
|
||||
zIndex?: PrimeVueZIndexOptions;
|
||||
theme?: any;
|
||||
unstyled?: boolean;
|
||||
pt?: PassThrough<PrimeVuePTOptions>;
|
||||
ptOptions?: PassThroughOptions;
|
||||
csp?: PrimeVueCSPOptions;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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')}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -25,6 +25,7 @@ export default defineNuxtConfig({
|
|||
options: {
|
||||
ripple: true
|
||||
},
|
||||
unstyled: false,
|
||||
layerOrder: 'primevue',
|
||||
importTheme: { from: '@/themes/aura.js' },
|
||||
resolvePath: function ({ as, from, type }) {
|
||||
|
|
Loading…
Reference in New Issue