From a7c3bf15e3b673dd436333470b687387b135e340 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Sat, 30 Mar 2024 12:29:27 +0000 Subject: [PATCH] Theming API: Refactor on definePreset action --- components/lib/themes/actions/definePreset.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/components/lib/themes/actions/definePreset.js b/components/lib/themes/actions/definePreset.js index 59eb9cef9..6a1cbe698 100644 --- a/components/lib/themes/actions/definePreset.js +++ b/components/lib/themes/actions/definePreset.js @@ -1,13 +1,8 @@ -import Theme from 'primevue/themes'; +import Theme, { SharedUtils } from 'primevue/themes'; export default (preset1, preset2) => { - const [{ primitive: p1, semantic: s1, components: c1, directives: d1 }, { primitive: p2, semantic: s2, components: c2, directives: d2 }] = [preset1, preset2]; - const newPreset = { - primitive: { ...p1, ...p2 }, - semantic: { ...s1, ...s2 }, - components: { ...c1, ...c2 }, - directives: { ...d1, ...d2 } - }; + const VARIABLE = Theme.defaults.variable; + const newPreset = SharedUtils.object.mergeKeysByRegex(preset1, preset2, VARIABLE.excludedKeyRegex); Theme.setPreset(newPreset);