primevue-mirror/components/lib/base/style/BaseStyle.js

74 lines
2.1 KiB
JavaScript
Raw Normal View History

2024-03-05 11:08:00 +00:00
import BaseThemeStyle from 'primevue/basetheme/style';
import { useStyle } from 'primevue/usestyle';
2024-02-20 11:44:09 +00:00
import { ObjectUtils } from 'primevue/utils';
const css = `
.p-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.p-hidden-accessible input,
.p-hidden-accessible select {
transform: scale(0);
}
.p-overflow-hidden {
overflow: hidden;
padding-right: var(--scrollbar-width);
}
`;
const classes = {};
const inlineStyles = {};
export default {
name: 'base',
css,
classes,
inlineStyles,
loadStyle(options = {}) {
2024-02-20 11:44:09 +00:00
return this.css ? useStyle(ObjectUtils.minifyCSS(this.css), { name: this.name, ...options }) : {};
},
2024-01-02 10:18:28 +00:00
loadTheme(theme, options = {}) {
2024-02-20 11:44:09 +00:00
return theme ? useStyle(ObjectUtils.minifyCSS(theme), { name: `${this.name}-style`, ...options }) : {};
2024-01-02 10:18:28 +00:00
},
2024-03-05 11:08:00 +00:00
getCommonThemeCSS(preset, base, params, theme) {
return BaseThemeStyle.getCommon(this.name, preset, base, params, theme);
2024-03-05 09:22:33 +00:00
},
2024-03-05 11:08:00 +00:00
getPresetThemeCSS(presetCTheme, theme) {
return BaseThemeStyle.getPresetC(this.name, presetCTheme, theme);
2024-03-05 09:22:33 +00:00
},
2024-03-05 11:08:00 +00:00
getBaseThemeCSS(baseCTheme, params, theme) {
return BaseThemeStyle.getBaseC(this.name, baseCTheme, params, theme);
2024-03-05 09:22:33 +00:00
},
getStyleSheet(extendedCSS = '', props = {}) {
2023-10-04 09:20:15 +00:00
if (this.css) {
2024-02-20 11:44:09 +00:00
const _css = ObjectUtils.minifyCSS(`${this.css}${extendedCSS}`);
2023-10-04 09:20:15 +00:00
const _props = Object.entries(props)
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
.join(' ');
2024-02-20 11:44:09 +00:00
return `<style type="text/css" data-primevue-style-id="${this.name}" ${_props}>${_css}</style>`;
2023-10-04 09:20:15 +00:00
}
return '';
},
2024-03-05 11:08:00 +00:00
getCommonThemeStyleSheet(theme = {}, params, props = {}) {
return BaseThemeStyle.getCommonStyleSheet(this.name, theme, params, props);
2024-03-05 09:22:33 +00:00
},
2024-03-05 11:08:00 +00:00
getThemeStyleSheet(theme = {}, params, props = {}) {
return BaseThemeStyle.getStyleSheet(this.name, theme, params, props);
2024-03-05 09:22:33 +00:00
},
extend(style) {
2023-10-04 09:20:15 +00:00
return { ...this, css: undefined, ...style };
}
};