2024-05-13 21:57:53 +00:00
|
|
|
import { Theme, dt } from 'primevue/themes';
|
2023-10-02 10:46:09 +00:00
|
|
|
import { useStyle } from 'primevue/usestyle';
|
2024-02-20 11:44:09 +00:00
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
2023-10-02 10:46:09 +00:00
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
2024-05-13 14:02:20 +00:00
|
|
|
* {
|
2024-05-01 08:26:48 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Non vue overlay animations */
|
|
|
|
.p-connected-overlay {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scaleY(0.8);
|
|
|
|
transition: transform 0.12s cubic-bezier(0, 0, 0.2, 1),
|
|
|
|
opacity 0.12s cubic-bezier(0, 0, 0.2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-visible {
|
|
|
|
opacity: 1;
|
|
|
|
transform: scaleY(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-hidden {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scaleY(1);
|
|
|
|
transition: opacity 0.1s linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vue based overlay animations */
|
|
|
|
.p-connected-overlay-enter-from {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scaleY(0.8);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-enter-active {
|
|
|
|
transition: transform 0.12s cubic-bezier(0, 0, 0.2, 1),
|
|
|
|
opacity 0.12s cubic-bezier(0, 0, 0.2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-leave-active {
|
|
|
|
transition: opacity 0.1s linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Toggleable Content */
|
|
|
|
.p-toggleable-content-enter-from,
|
|
|
|
.p-toggleable-content-leave-to {
|
|
|
|
max-height: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-toggleable-content-enter-to,
|
|
|
|
.p-toggleable-content-leave-from {
|
|
|
|
max-height: 1000px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-toggleable-content-leave-active {
|
|
|
|
overflow: hidden;
|
|
|
|
transition: max-height 0.45s cubic-bezier(0, 1, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-toggleable-content-enter-active {
|
|
|
|
overflow: hidden;
|
|
|
|
transition: max-height 1s ease-in-out;
|
|
|
|
}
|
|
|
|
|
2024-05-13 14:02:20 +00:00
|
|
|
.p-disabled,
|
|
|
|
.p-disabled * {
|
|
|
|
cursor: default;
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-disabled,
|
|
|
|
.p-component:disabled {
|
2024-05-13 14:02:20 +00:00
|
|
|
opacity: ${dt('disabled.opacity')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.pi {
|
2024-05-08 07:32:33 +00:00
|
|
|
font-size: ${dt('icon.size')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-icon {
|
2024-05-08 07:32:33 +00:00
|
|
|
width: ${dt('icon.size')};
|
|
|
|
height: ${dt('icon.size')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-13 14:02:20 +00:00
|
|
|
.p-overlay-mask {
|
2024-05-25 13:40:04 +00:00
|
|
|
background: ${dt('mask.background')};
|
|
|
|
color: ${dt('mask.color')};
|
2024-05-13 14:02:20 +00:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-13 14:02:20 +00:00
|
|
|
.p-overlay-mask-enter {
|
2024-05-25 13:40:04 +00:00
|
|
|
animation: p-overlay-mask-enter-animation ${dt('mask.transition.duration')} forwards;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-13 14:02:20 +00:00
|
|
|
.p-overlay-mask-leave {
|
2024-05-25 13:40:04 +00:00
|
|
|
animation: p-overlay-mask-leave-animation ${dt('mask.transition.duration')} forwards;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-13 14:02:20 +00:00
|
|
|
@keyframes p-overlay-mask-enter-animation {
|
2024-05-01 08:26:48 +00:00
|
|
|
from {
|
2024-05-13 09:10:09 +00:00
|
|
|
background: transparent;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
to {
|
2024-05-13 09:10:09 +00:00
|
|
|
background: ${dt('mask.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-13 14:02:20 +00:00
|
|
|
@keyframes p-overlay-mask-leave-animation {
|
2024-05-01 08:26:48 +00:00
|
|
|
from {
|
2024-05-13 09:10:09 +00:00
|
|
|
background: ${dt('mask.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
to {
|
2024-05-13 09:10:09 +00:00
|
|
|
background: transparent;
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2024-04-15 09:17:29 +00:00
|
|
|
const css = ({ dt }) => `
|
2023-10-02 10:46:09 +00:00
|
|
|
.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;
|
2024-04-15 09:17:29 +00:00
|
|
|
padding-right: ${dt('scrollbar.width')};
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const classes = {};
|
|
|
|
|
|
|
|
const inlineStyles = {};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'base',
|
|
|
|
css,
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes,
|
|
|
|
inlineStyles,
|
2024-05-02 22:12:36 +00:00
|
|
|
load(style, options = {}, transform = (cs) => cs) {
|
|
|
|
const computedStyle = transform(ObjectUtils.getItemValue(style, { dt }));
|
2024-04-15 09:17:29 +00:00
|
|
|
|
2024-05-02 22:12:36 +00:00
|
|
|
return computedStyle ? useStyle(ObjectUtils.minifyCSS(computedStyle), { name: this.name, ...options }) : {};
|
2023-10-02 10:46:09 +00:00
|
|
|
},
|
2024-05-02 22:12:36 +00:00
|
|
|
loadCSS(options = {}) {
|
|
|
|
return this.load(this.css, options);
|
2024-05-01 08:26:48 +00:00
|
|
|
},
|
2024-05-02 22:12:36 +00:00
|
|
|
loadTheme(options = {}) {
|
|
|
|
return this.load(this.theme, options, (computedStyle) => Theme.transformCSS(options.name || this.name, computedStyle));
|
2024-01-02 10:18:28 +00:00
|
|
|
},
|
2024-05-14 08:35:40 +00:00
|
|
|
getCommonTheme(params) {
|
|
|
|
return Theme.getCommon(this.name, params);
|
2024-03-05 09:22:33 +00:00
|
|
|
},
|
2024-05-14 08:35:40 +00:00
|
|
|
getComponentTheme(params) {
|
|
|
|
return Theme.getComponent(this.name, params);
|
2024-03-05 09:22:33 +00:00
|
|
|
},
|
2024-05-14 08:35:40 +00:00
|
|
|
getDirectiveTheme(params) {
|
|
|
|
return Theme.getDirective(this.name, params);
|
2024-03-05 11:59:37 +00:00
|
|
|
},
|
2024-05-14 08:35:40 +00:00
|
|
|
getPresetTheme(preset, selector, params) {
|
|
|
|
return Theme.getCustomPreset(this.name, preset, selector, params);
|
2024-04-01 13:08:53 +00:00
|
|
|
},
|
2024-03-18 10:57:17 +00:00
|
|
|
getLayerOrderThemeCSS() {
|
|
|
|
return Theme.getLayerOrderCSS(this.name);
|
|
|
|
},
|
2023-10-02 10:46:09 +00:00
|
|
|
getStyleSheet(extendedCSS = '', props = {}) {
|
2023-10-04 09:20:15 +00:00
|
|
|
if (this.css) {
|
2024-05-02 22:12:36 +00:00
|
|
|
const _css = ObjectUtils.getItemValue(this.css, { dt });
|
|
|
|
const _style = ObjectUtils.minifyCSS(`${_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(' ');
|
2023-10-02 10:46:09 +00:00
|
|
|
|
2024-05-02 22:12:36 +00:00
|
|
|
return `<style type="text/css" data-primevue-style-id="${this.name}" ${_props}>${_style}</style>`;
|
2023-10-04 09:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2023-10-02 10:46:09 +00:00
|
|
|
},
|
2024-03-29 11:25:15 +00:00
|
|
|
getCommonThemeStyleSheet(params, props = {}) {
|
|
|
|
return Theme.getCommonStyleSheet(this.name, params, props);
|
2024-03-05 09:22:33 +00:00
|
|
|
},
|
2024-03-29 11:25:15 +00:00
|
|
|
getThemeStyleSheet(params, props = {}) {
|
2024-05-02 22:12:36 +00:00
|
|
|
let css = [Theme.getStyleSheet(this.name, params, props)];
|
|
|
|
|
|
|
|
if (this.theme) {
|
2024-05-24 17:09:26 +00:00
|
|
|
const name = this.name === 'base' ? 'global-style' : `${this.name}-style`;
|
2024-05-02 22:12:36 +00:00
|
|
|
const _css = ObjectUtils.getItemValue(this.theme, { dt });
|
|
|
|
const _style = ObjectUtils.minifyCSS(Theme.transformCSS(name, _css));
|
|
|
|
const _props = Object.entries(props)
|
|
|
|
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
|
|
|
|
.join(' ');
|
|
|
|
|
|
|
|
css.push(`<style type="text/css" data-primevue-style-id="${name}" ${_props}>${_style}</style>`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return css.join('');
|
2024-03-05 09:22:33 +00:00
|
|
|
},
|
2023-10-02 10:46:09 +00:00
|
|
|
extend(style) {
|
2024-05-01 08:26:48 +00:00
|
|
|
return { ...this, css: undefined, theme: undefined, ...style };
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
};
|