diff --git a/build-meta.js b/build-meta.js index 14486010e..f6a85e403 100644 --- a/build-meta.js +++ b/build-meta.js @@ -15,6 +15,7 @@ function copyDependencies(inFolder, outFolder) { copyDependencies('./components/lib/', 'dist/'); copyDependencies('./components/lib/icons/', 'dist/icons/'); +copyDependencies('./components/lib/passthrough/', 'dist/passthrough/'); fs.copySync(path.resolve(__dirname, './components/lib/ts-helpers.d.ts'), 'dist/ts-helpers.d.ts'); fs.copySync(path.resolve(__dirname, './package-build.json'), 'dist/package.json'); diff --git a/components/lib/passthrough/index.d.ts b/components/lib/passthrough/index.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/components/lib/passthrough/index.js b/components/lib/passthrough/index.js new file mode 100644 index 000000000..e00cf4406 --- /dev/null +++ b/components/lib/passthrough/index.js @@ -0,0 +1,19 @@ +import { mergeProps } from 'vue'; + +// @todo: Improve this method +export const usePassThrough = (theme, pt = {}, { merge = false }) => { + const newTheme = { ...theme }; + const componentNames = Object.keys(pt); + + return componentNames.reduce((t, n) => { + if (!merge) { + t[n] = pt[n]; + } else { + t[n] = Object.entries(pt[n]).reduce((_t, [sk, sv]) => { + return mergeProps(t[n][sk], sv); + }, {}); + } + + return t; + }, newTheme); +}; diff --git a/components/lib/passthrough/package.json b/components/lib/passthrough/package.json new file mode 100644 index 000000000..6f42b3185 --- /dev/null +++ b/components/lib/passthrough/package.json @@ -0,0 +1,6 @@ +{ + "main": "./index.cjs.js", + "module": "./index.esm.js", + "unpkg": "./index.min.js", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/components/lib/tailwind/Tailwind.d.ts b/components/lib/passthrough/tailwind/index.d.ts similarity index 60% rename from components/lib/tailwind/Tailwind.d.ts rename to components/lib/passthrough/tailwind/index.d.ts index 943112fec..ddfd708c0 100644 --- a/components/lib/tailwind/Tailwind.d.ts +++ b/components/lib/passthrough/tailwind/index.d.ts @@ -1,4 +1,4 @@ -import { PrimeVuePTOptions } from '../config'; +import { PrimeVuePTOptions } from '../../config'; interface Tailwind extends PrimeVuePTOptions {} diff --git a/components/lib/tailwind/Tailwind.js b/components/lib/passthrough/tailwind/index.js similarity index 99% rename from components/lib/tailwind/Tailwind.js rename to components/lib/passthrough/tailwind/index.js index 4a51b3665..a92927b50 100644 --- a/components/lib/tailwind/Tailwind.js +++ b/components/lib/passthrough/tailwind/index.js @@ -14,6 +14,7 @@ export const TRANSITIONS = { leaveToClass: 'opacity-0' } }; + export default { global: { css: ` diff --git a/components/lib/passthrough/tailwind/package.json b/components/lib/passthrough/tailwind/package.json new file mode 100644 index 000000000..6f42b3185 --- /dev/null +++ b/components/lib/passthrough/tailwind/package.json @@ -0,0 +1,6 @@ +{ + "main": "./index.cjs.js", + "module": "./index.esm.js", + "unpkg": "./index.min.js", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/components/lib/tailwind/package.json b/components/lib/tailwind/package.json deleted file mode 100644 index 342a90638..000000000 --- a/components/lib/tailwind/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "main": "./tailwind.cjs.js", - "module": "./tailwind.esm.js", - "unpkg": "./tailwind.min.js", - "types": "./Tailwind.d.ts" -} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js index 8161109dd..b5c129a3c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -59,6 +59,11 @@ const CORE_ICON_DEPENDENCIES = { 'primevue/icons/windowminimize': 'primevue.icons.windowminimize' }; +const CORE_PASSTHROUGH_DEPENDENCIES = { + 'primevue/passthrough': 'primevue.passthrough', + 'primevue/passthrough/tailwind': 'primevue.passthrough.tailwind' +}; + const CORE_DEPENDENCIES = { 'primevue/utils': 'primevue.utils', 'primevue/api': 'primevue.api', @@ -93,7 +98,7 @@ const CORE_DEPENDENCIES = { 'primevue/menu': 'primevue.menu', 'primevue/tieredmenu': 'primevue.tieredmenu', 'primevue/badge': 'primevue.badge', - 'primevue/tailwind': 'primevue.tailwind' + ...CORE_PASSTHROUGH_DEPENDENCIES }; // dependencies @@ -283,8 +288,9 @@ function addConfig() { addEntry('config', 'PrimeVue.js', 'config'); } -function addTailwind() { - addEntry('tailwind', 'Tailwind', 'tailwind'); +function addPassThrough() { + addEntry('passthrough', 'index.js', 'index'); + addEntry('passthrough/tailwind', 'index.js', 'index'); } function addUtils() { @@ -322,7 +328,7 @@ addDirectives(); addServices(); addSFC(); addIcon(); -addTailwind(); +addPassThrough(); addCore(); export default entries; diff --git a/vite.config.js b/vite.config.js index 790a18d00..f6be84c24 100644 --- a/vite.config.js +++ b/vite.config.js @@ -80,7 +80,8 @@ export default { 'primevue/terminalservice': path.resolve(__dirname, './components/lib/terminalservice/TerminalService.js'), 'primevue/dynamicdialogeventbus': path.resolve(__dirname, './components/lib/dynamicdialogeventbus/DynamicDialogEventBus.js'), 'primevue/virtualscroller': path.resolve(__dirname, './components/lib/virtualscroller/VirtualScroller.vue'), - 'primevue/tailwind': path.resolve(__dirname, './components/lib/tailwind/Tailwind.js') + 'primevue/passthrough': path.resolve(__dirname, './components/lib/passthrough/index.js'), + 'primevue/passthrough/tailwind': path.resolve(__dirname, './components/lib/passthrough/tailwind/index.js') } } };