init component

This commit is contained in:
Robin COuret
2026-02-16 17:28:37 +01:00
parent 460c7a25e0
commit e0e50af706
4557 changed files with 666911 additions and 8 deletions

View File

@@ -0,0 +1,32 @@
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