Files
manolia-alpha/node_modules/buetify/lib/utils/getThemeableFunctionalComponent.js
Robin COuret e0e50af706 init component
2026-02-16 17:28:37 +01:00

32 lines
1.1 KiB
JavaScript
Executable File

import { isSome } from 'fp-ts/lib/Option';
import { inject, h, defineComponent } from 'vue';
import { DEFAULT_THEME_COLOR_MAP, DEFAULT_THEME_INJECTION, getThemeClasses, useThemePropsDefinition, THEME_INJECTION_SYMBOL } from '../composables/theme';
import { mergeClasses } from './mergeClasses';
export function isThemeable(props, injection) {
return !!props.isThemeable && !!props.themeMap && isSome(injection.currentTheme.value);
}
export function getThemeableFunctionalComponent({
cls,
el = 'div',
themeMap = DEFAULT_THEME_COLOR_MAP
}) {
return defineComponent({
props: { ...useThemePropsDefinition(themeMap, true),
tag: {
type: [String, Function],
default: el
}
},
setup(props, {
slots
}) {
const themeInjection = inject(THEME_INJECTION_SYMBOL, DEFAULT_THEME_INJECTION);
return () => h(props.tag, {
class: isThemeable(props, themeInjection) ? mergeClasses(getThemeClasses(props.themeMap, themeInjection), cls) : cls
}, slots.default && slots.default());
}
});
}
//# sourceMappingURL=getThemeableFunctionalComponent.js.map