init component
This commit is contained in:
32
node_modules/buetify/lib/utils/getThemeableFunctionalComponent.js
generated
vendored
Executable file
32
node_modules/buetify/lib/utils/getThemeableFunctionalComponent.js
generated
vendored
Executable 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
|
||||
Reference in New Issue
Block a user