Refactor #5502
parent
5671752903
commit
e896552ccb
|
@ -101,6 +101,8 @@ export interface PrimeVueConfiguration {
|
||||||
locale?: PrimeVueLocaleOptions;
|
locale?: PrimeVueLocaleOptions;
|
||||||
filterMatchModeOptions?: any;
|
filterMatchModeOptions?: any;
|
||||||
zIndex?: PrimeVueZIndexOptions;
|
zIndex?: PrimeVueZIndexOptions;
|
||||||
|
theme?: any;
|
||||||
|
unstyled?: boolean;
|
||||||
pt?: PassThrough<PrimeVuePTOptions>;
|
pt?: PassThrough<PrimeVuePTOptions>;
|
||||||
ptOptions?: PassThroughOptions;
|
ptOptions?: PassThroughOptions;
|
||||||
csp?: PrimeVueCSPOptions;
|
csp?: PrimeVueCSPOptions;
|
||||||
|
|
|
@ -133,6 +133,8 @@ export const defaultOptions = {
|
||||||
menu: 1000,
|
menu: 1000,
|
||||||
tooltip: 1100
|
tooltip: 1100
|
||||||
},
|
},
|
||||||
|
theme: undefined,
|
||||||
|
unstyled: false,
|
||||||
pt: undefined,
|
pt: undefined,
|
||||||
ptOptions: {
|
ptOptions: {
|
||||||
mergeSections: true,
|
mergeSections: true,
|
||||||
|
@ -167,7 +169,9 @@ export function setup(app, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install: () => {
|
install: (app, options) => {
|
||||||
console.error("This plugin has been removed in v4 version. Use 'PrimeVueStyled' plugin for styled mode, and 'PrimeVueUnstyled' plugin for unstyled mode.");
|
const configOptions = { ...defaultOptions, ...options };
|
||||||
|
|
||||||
|
setup(app, configOptions);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default defineNuxtModule({
|
||||||
layerOrder: 'tailwind-base, primevue, tailwind-utilities',
|
layerOrder: 'tailwind-base, primevue, tailwind-utilities',
|
||||||
importPT: undefined,
|
importPT: undefined,
|
||||||
importTheme: undefined,
|
importTheme: undefined,
|
||||||
unstyled: false,
|
unstyled: undefined,
|
||||||
options: {},
|
options: {},
|
||||||
components: {
|
components: {
|
||||||
prefix: '',
|
prefix: '',
|
||||||
|
@ -41,7 +41,7 @@ export default defineNuxtModule({
|
||||||
const resolver = createResolver(import.meta.url);
|
const resolver = createResolver(import.meta.url);
|
||||||
const registered = register(moduleOptions);
|
const registered = register(moduleOptions);
|
||||||
const { importPT, importTheme, options, unstyled } = moduleOptions;
|
const { importPT, importTheme, options, unstyled } = moduleOptions;
|
||||||
const hasTheme = importTheme && !unstyled;
|
const hasTheme = importTheme && unstyled !== true && !options.unstyled;
|
||||||
|
|
||||||
nuxt.options.runtimeConfig.public.primevue = {
|
nuxt.options.runtimeConfig.public.primevue = {
|
||||||
...moduleOptions,
|
...moduleOptions,
|
||||||
|
@ -103,7 +103,7 @@ export default defineNuxtPlugin(({ vueApp }) => {
|
||||||
const pt = ${importPT ? `{ pt: ${importPT.as} }` : `{}`};
|
const pt = ${importPT ? `{ pt: ${importPT.as} }` : `{}`};
|
||||||
const theme = ${hasTheme ? `{ theme: ${importTheme.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.services.map((service) => `vueApp.use(${service.as});`).join('\n')}
|
||||||
${registered.directives.map((directive) => `vueApp.directive('${directive.name}', ${directive.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) {
|
function registerConfig(resolvePath, moduleOptions) {
|
||||||
return [
|
const configs = [];
|
||||||
unstyled
|
|
||||||
? {
|
if (moduleOptions.unstyled === true) {
|
||||||
name: 'PrimeVueUnstyled',
|
configs.push({
|
||||||
as: 'PrimeVueUnstyled',
|
name: 'PrimeVueUnstyled',
|
||||||
from: resolvePath({ name: 'PrimeVueUnstyled', as: 'PrimeVueUnstyled', from: `primevue/unstyled`, type: 'config' })
|
as: 'PrimeVueUnstyled',
|
||||||
}
|
from: resolvePath({ name: 'PrimeVueUnstyled', as: 'PrimeVueUnstyled', from: `primevue/unstyled`, type: 'config' })
|
||||||
: {
|
});
|
||||||
name: 'PrimeVueStyled',
|
} else if (moduleOptions.unstyled === false) {
|
||||||
as: 'PrimeVueStyled',
|
configs.push({
|
||||||
from: resolvePath({ name: 'PrimeVueStyled', as: 'PrimeVueStyled', from: `primevue/styled`, type: 'config' })
|
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 = {}) {
|
function registerComponents(resolvePath, options = {}) {
|
||||||
|
@ -140,7 +146,7 @@ function registerInjectStylesAsString(moduleOptions) {
|
||||||
export function register(moduleOptions) {
|
export function register(moduleOptions) {
|
||||||
const resolvePath = (resolveOptions) => Utils.object.getPath(moduleOptions.resolvePath, resolveOptions);
|
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 components = registerComponents(resolvePath, moduleOptions.components);
|
||||||
const directives = registerDirectives(resolvePath, moduleOptions.directives);
|
const directives = registerDirectives(resolvePath, moduleOptions.directives);
|
||||||
const composables = registerComposables(resolvePath, moduleOptions.composables);
|
const composables = registerComposables(resolvePath, moduleOptions.composables);
|
||||||
|
|
|
@ -25,6 +25,7 @@ export default defineNuxtConfig({
|
||||||
options: {
|
options: {
|
||||||
ripple: true
|
ripple: true
|
||||||
},
|
},
|
||||||
|
unstyled: false,
|
||||||
layerOrder: 'primevue',
|
layerOrder: 'primevue',
|
||||||
importTheme: { from: '@/themes/aura.js' },
|
importTheme: { from: '@/themes/aura.js' },
|
||||||
resolvePath: function ({ as, from, type }) {
|
resolvePath: function ({ as, from, type }) {
|
||||||
|
|
Loading…
Reference in New Issue