Theming API: Added fallback param to inline dt method.

This commit is contained in:
mertsincan 2024-03-28 13:01:28 +00:00
parent c25b2e0559
commit 468106cfb8
3 changed files with 8 additions and 8 deletions

View file

@ -3,10 +3,10 @@ import Theme, { SharedUtils } from 'primevue/themes';
export const $dt = (tokenPath, type) => {
const config = Theme.getPConfig();
return dt(config?.theme, tokenPath, type);
return dt(config?.theme, tokenPath, undefined, type);
};
export const dt = (theme = {}, tokenPath, type) => {
export const dt = (theme = {}, tokenPath, fallback, type) => {
if (tokenPath) {
const VARIABLE = Theme.defaults.variable;
const { prefix, transform } = theme?.options || {};
@ -14,7 +14,7 @@ export const dt = (theme = {}, tokenPath, type) => {
const token = SharedUtils.object.test(regex, tokenPath) ? tokenPath : `{${tokenPath}}`;
const isStrictTransform = type === 'value' || transform === 'strict'; // @todo - TRANSFORM: strict | lenient(default)
return isStrictTransform ? Theme.getTokenValue(tokenPath) : SharedUtils.object.getVariableValue(token, undefined, prefix, [VARIABLE.excludedKeyRegex]);
return isStrictTransform ? Theme.getTokenValue(tokenPath) : SharedUtils.object.getVariableValue(token, undefined, prefix, [VARIABLE.excludedKeyRegex], fallback);
}
return '';