2023-03-21 12:05:24 +00:00
|
|
|
<script>
|
2023-07-03 22:20:35 +00:00
|
|
|
import { loadBaseStyle } from 'primevue/base';
|
|
|
|
import { useStyle } from 'primevue/usestyle';
|
2023-03-21 12:05:24 +00:00
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
2023-05-10 11:49:54 +00:00
|
|
|
import { mergeProps } from 'vue';
|
2023-03-21 12:05:24 +00:00
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const inlineStyles = {};
|
|
|
|
|
|
|
|
const buttonStyles = `
|
|
|
|
.p-button {
|
|
|
|
display: inline-flex;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
align-items: center;
|
|
|
|
vertical-align: bottom;
|
|
|
|
text-align: center;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-label {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-icon-right {
|
|
|
|
order: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button:disabled {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-icon-only {
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-icon-only .p-button-label {
|
|
|
|
visibility: hidden;
|
|
|
|
width: 0;
|
|
|
|
flex: 0 0 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-vertical {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-button-icon-bottom {
|
|
|
|
order: 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-buttonset .p-button {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2023-08-18 01:13:44 +00:00
|
|
|
.p-buttonset .p-button:not(:last-child), .p-buttonset .p-button:not(:last-child):hover {
|
2023-07-03 22:20:35 +00:00
|
|
|
border-right: 0 none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-buttonset .p-button:not(:first-of-type):not(:last-of-type) {
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-buttonset .p-button:first-of-type {
|
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-buttonset .p-button:last-of-type {
|
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-buttonset .p-button:focus {
|
|
|
|
position: relative;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
const checkboxStyles = `
|
|
|
|
.p-checkbox {
|
|
|
|
display: inline-flex;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
vertical-align: bottom;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-checkbox.p-checkbox-disabled {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-checkbox-box {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
const inputTextStyles = `
|
|
|
|
.p-fluid .p-inputtext {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* InputGroup */
|
|
|
|
.p-inputgroup {
|
|
|
|
display: flex;
|
|
|
|
align-items: stretch;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inputgroup-addon {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inputgroup .p-float-label {
|
|
|
|
display: flex;
|
|
|
|
align-items: stretch;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inputgroup .p-inputtext,
|
|
|
|
.p-fluid .p-inputgroup .p-inputtext,
|
|
|
|
.p-inputgroup .p-inputwrapper,
|
|
|
|
.p-fluid .p-inputgroup .p-input {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
width: 1%;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Floating Label */
|
|
|
|
.p-float-label {
|
|
|
|
display: block;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label label {
|
|
|
|
position: absolute;
|
|
|
|
pointer-events: none;
|
|
|
|
top: 50%;
|
|
|
|
margin-top: -.5rem;
|
|
|
|
transition-property: all;
|
|
|
|
transition-timing-function: ease;
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label textarea ~ label {
|
|
|
|
top: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label input:focus ~ label,
|
|
|
|
.p-float-label input.p-filled ~ label,
|
|
|
|
.p-float-label textarea:focus ~ label,
|
|
|
|
.p-float-label textarea.p-filled ~ label,
|
|
|
|
.p-float-label .p-inputwrapper-focus ~ label,
|
|
|
|
.p-float-label .p-inputwrapper-filled ~ label {
|
|
|
|
top: -.75rem;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label .input:-webkit-autofill ~ label {
|
|
|
|
top: -20px;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label .p-placeholder,
|
|
|
|
.p-float-label input::placeholder,
|
|
|
|
.p-float-label .p-inputtext::placeholder {
|
|
|
|
opacity: 0;
|
|
|
|
transition-property: all;
|
|
|
|
transition-timing-function: ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-float-label .p-focus .p-placeholder,
|
|
|
|
.p-float-label input:focus::placeholder,
|
|
|
|
.p-float-label .p-inputtext:focus::placeholder {
|
|
|
|
opacity: 1;
|
|
|
|
transition-property: all;
|
|
|
|
transition-timing-function: ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-input-icon-left,
|
|
|
|
.p-input-icon-right {
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-input-icon-left > i,
|
|
|
|
.p-input-icon-left > svg,
|
|
|
|
.p-input-icon-right > i,
|
|
|
|
.p-input-icon-right > svg {
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
margin-top: -.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-fluid .p-input-icon-left,
|
|
|
|
.p-fluid .p-input-icon-right {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
const radioButtonStyles = `
|
|
|
|
.p-radiobutton {
|
|
|
|
position: relative;
|
|
|
|
display: inline-flex;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-radiobutton.p-radiobutton-disabled {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-radiobutton-box {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-radiobutton-icon {
|
|
|
|
-webkit-backface-visibility: hidden;
|
|
|
|
backface-visibility: hidden;
|
|
|
|
transform: translateZ(0) scale(.1);
|
|
|
|
border-radius: 50%;
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-radiobutton-box.p-highlight .p-radiobutton-icon {
|
|
|
|
transform: translateZ(0) scale(1.0, 1.0);
|
|
|
|
visibility: visible;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
const styles = `
|
|
|
|
.p-component, .p-component * {
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-hidden-space {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-reset {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
border: 0;
|
|
|
|
outline: 0;
|
|
|
|
text-decoration: none;
|
|
|
|
font-size: 100%;
|
|
|
|
list-style: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-disabled, .p-disabled * {
|
|
|
|
cursor: default !important;
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-component-overlay {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2023-07-05 13:43:00 +00:00
|
|
|
.p-unselectable-text {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-sr-only {
|
|
|
|
border: 0;
|
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
|
|
clip-path: inset(50%);
|
|
|
|
height: 1px;
|
|
|
|
margin: -1px;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 0;
|
|
|
|
position: absolute;
|
|
|
|
width: 1px;
|
|
|
|
word-wrap: normal !important;
|
|
|
|
}
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
.p-link {
|
|
|
|
text-align: left;
|
|
|
|
background-color: transparent;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
border: none;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-link:disabled {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Non vue overlay animations */
|
|
|
|
.p-connected-overlay {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scaleY(0.8);
|
|
|
|
transition: transform .12s cubic-bezier(0, 0, 0.2, 1), opacity .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 .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 .12s cubic-bezier(0, 0, 0.2, 1), opacity .12s cubic-bezier(0, 0, 0.2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-connected-overlay-leave-active {
|
|
|
|
transition: opacity .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;
|
|
|
|
}
|
|
|
|
${buttonStyles}
|
|
|
|
${checkboxStyles}
|
|
|
|
${inputTextStyles}
|
|
|
|
${radioButtonStyles}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'common', manual: true });
|
2023-08-02 10:39:12 +00:00
|
|
|
const { load: loadGlobalStyle } = useStyle('', { name: 'global', manual: true });
|
2023-05-19 10:32:44 +00:00
|
|
|
|
2023-03-21 12:05:24 +00:00
|
|
|
export default {
|
2023-03-31 21:51:41 +00:00
|
|
|
name: 'BaseComponent',
|
2023-03-21 12:05:24 +00:00
|
|
|
props: {
|
|
|
|
pt: {
|
|
|
|
type: Object,
|
2023-04-26 08:57:02 +00:00
|
|
|
default: undefined
|
2023-05-16 10:29:56 +00:00
|
|
|
},
|
2023-09-04 21:23:35 +00:00
|
|
|
ptOptions: {
|
|
|
|
type: Object,
|
|
|
|
default: undefined
|
|
|
|
},
|
2023-05-16 10:29:56 +00:00
|
|
|
unstyled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: undefined
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
|
|
|
},
|
2023-05-30 09:59:17 +00:00
|
|
|
inject: {
|
|
|
|
$parentInstance: {
|
|
|
|
default: undefined
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
isUnstyled: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newValue) {
|
2023-08-02 11:59:10 +00:00
|
|
|
if (!newValue) {
|
2023-08-11 01:34:02 +00:00
|
|
|
loadStyle(undefined, { nonce: this.$config?.csp?.nonce });
|
|
|
|
this.$options.css && this.$css.loadStyle(undefined, { nonce: this.$config?.csp?.nonce });
|
2023-08-02 11:59:10 +00:00
|
|
|
}
|
2023-05-30 09:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-07-04 01:28:19 +00:00
|
|
|
beforeCreate() {
|
2023-08-17 23:51:01 +00:00
|
|
|
const _usept = this.pt?.['_usept'];
|
|
|
|
const originalValue = _usept ? this.pt?.originalValue?.[this.$.type.name] : undefined;
|
|
|
|
const value = _usept ? this.pt?.value?.[this.$.type.name] : this.pt;
|
|
|
|
|
|
|
|
(value || originalValue)?.hooks?.['onBeforeCreate']?.();
|
|
|
|
|
|
|
|
const _useptInConfig = this.$config?.pt?.['_usept'];
|
|
|
|
const originalValueInConfig = _useptInConfig ? this.$primevue?.config?.pt?.originalValue : undefined;
|
|
|
|
const valueInConfig = _useptInConfig ? this.$primevue?.config?.pt?.value : this.$primevue?.config?.pt;
|
|
|
|
|
|
|
|
(valueInConfig || originalValueInConfig)?.[this.$.type.name]?.hooks?.['onBeforeCreate']?.();
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
created() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onCreated');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
2023-07-03 22:20:35 +00:00
|
|
|
beforeMount() {
|
2023-08-11 01:34:02 +00:00
|
|
|
loadBaseStyle(undefined, { nonce: this.$config?.csp?.nonce });
|
2023-08-02 10:39:12 +00:00
|
|
|
this._loadGlobalStyles();
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onBeforeMount');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onMounted');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
beforeUpdate() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onBeforeUpdate');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
updated() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onUpdated');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
beforeUnmount() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onBeforeUnmount');
|
2023-07-04 01:28:19 +00:00
|
|
|
},
|
|
|
|
unmounted() {
|
2023-07-10 09:34:48 +00:00
|
|
|
this._hook('onUnmounted');
|
2023-07-03 22:20:35 +00:00
|
|
|
},
|
2023-03-21 12:05:24 +00:00
|
|
|
methods: {
|
2023-07-04 01:28:19 +00:00
|
|
|
_hook(hookName) {
|
2023-08-17 23:51:01 +00:00
|
|
|
if (!this.$options.hostName) {
|
|
|
|
const selfHook = this._usePT(this._getPT(this.pt, this.$.type.name), this._getOptionValue, `hooks.${hookName}`);
|
|
|
|
const defaultHook = this._useDefaultPT(this._getOptionValue, `hooks.${hookName}`);
|
2023-07-04 01:28:19 +00:00
|
|
|
|
2023-08-17 23:51:01 +00:00
|
|
|
selfHook?.();
|
|
|
|
defaultHook?.();
|
|
|
|
}
|
2023-08-02 10:39:12 +00:00
|
|
|
},
|
|
|
|
_loadGlobalStyles() {
|
|
|
|
/*
|
|
|
|
* @todo Add self custom css support;
|
|
|
|
* <Panel :pt="{ css: `...` }" .../>
|
|
|
|
*
|
|
|
|
* const selfCSS = this._getPTClassValue(this.pt, 'css', this.$params);
|
|
|
|
* const defaultCSS = this._getPTClassValue(this.defaultPT, 'css', this.$params);
|
|
|
|
* const mergedCSS = mergeProps(selfCSS, defaultCSS);
|
|
|
|
* ObjectUtils.isNotEmpty(mergedCSS?.class) && this.$css.loadCustomStyle(mergedCSS?.class);
|
|
|
|
*/
|
|
|
|
|
2023-08-17 23:51:01 +00:00
|
|
|
const globalCSS = this._useGlobalPT(this._getOptionValue, 'global.css', this.$params);
|
2023-08-02 10:39:12 +00:00
|
|
|
|
2023-08-11 01:34:02 +00:00
|
|
|
ObjectUtils.isNotEmpty(globalCSS) && loadGlobalStyle(globalCSS, { nonce: this.$config?.csp?.nonce });
|
2023-08-02 10:39:12 +00:00
|
|
|
},
|
2023-06-08 11:16:48 +00:00
|
|
|
_getHostInstance(instance) {
|
|
|
|
return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined;
|
|
|
|
},
|
2023-09-07 09:48:40 +00:00
|
|
|
_getPropValue(name) {
|
|
|
|
return this[name] || this._getHostInstance(this)?.[name];
|
|
|
|
},
|
2023-05-25 12:47:40 +00:00
|
|
|
_getOptionValue(options, key = '', params = {}) {
|
2023-07-10 09:34:48 +00:00
|
|
|
const fKeys = ObjectUtils.toFlatCase(key).split('.');
|
2023-05-23 21:10:36 +00:00
|
|
|
const fKey = fKeys.shift();
|
2023-04-03 00:12:25 +00:00
|
|
|
|
2023-05-23 23:40:14 +00:00
|
|
|
return fKey
|
|
|
|
? ObjectUtils.isObject(options)
|
2023-07-10 09:34:48 +00:00
|
|
|
? this._getOptionValue(ObjectUtils.getItemValue(options[Object.keys(options).find((k) => ObjectUtils.toFlatCase(k) === fKey) || ''], params), fKeys.join('.'), params)
|
2023-05-23 23:40:14 +00:00
|
|
|
: undefined
|
|
|
|
: ObjectUtils.getItemValue(options, params);
|
2023-04-03 00:12:25 +00:00
|
|
|
},
|
2023-06-08 11:16:48 +00:00
|
|
|
_getPTValue(obj = {}, key = '', params = {}, searchInDefaultPT = true) {
|
2023-05-24 00:59:42 +00:00
|
|
|
const datasetPrefix = 'data-pc-';
|
2023-08-17 23:51:01 +00:00
|
|
|
const searchOut = /./g.test(key) && !!params[key.split('.')[0]];
|
2023-09-07 09:48:40 +00:00
|
|
|
const { mergeSections = true, mergeProps: useMergeProps = false } = this._getPropValue('ptOptions') || {};
|
2023-09-04 21:23:35 +00:00
|
|
|
const global = searchInDefaultPT ? (searchOut ? this._useGlobalPT(this._getPTClassValue, key, params) : this._useDefaultPT(this._getPTClassValue, key, params)) : undefined;
|
2023-09-05 10:18:36 +00:00
|
|
|
const self = searchOut ? undefined : this._usePT(this._getPT(obj, this.$name), this._getPTClassValue, key, { ...params, global: global || {} });
|
2023-09-04 21:23:35 +00:00
|
|
|
const datasets = key !== 'transition' && {
|
|
|
|
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.toFlatCase(this.$.type.name) }),
|
|
|
|
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
|
|
|
};
|
2023-04-25 11:36:01 +00:00
|
|
|
|
2023-09-04 21:23:35 +00:00
|
|
|
return mergeSections || (!mergeSections && self) ? (useMergeProps ? mergeProps(global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
|
2023-04-25 11:36:01 +00:00
|
|
|
},
|
2023-08-02 10:39:12 +00:00
|
|
|
_getPTClassValue(...args) {
|
|
|
|
const value = this._getOptionValue(...args);
|
|
|
|
|
|
|
|
return ObjectUtils.isString(value) || ObjectUtils.isArray(value) ? { class: value } : value;
|
|
|
|
},
|
2023-08-17 23:51:01 +00:00
|
|
|
_getPT(pt, key = '', callback) {
|
|
|
|
const _usept = pt?.['_usept'];
|
|
|
|
|
2023-09-05 10:18:36 +00:00
|
|
|
const getValue = (value, checkSameKey = false) => {
|
2023-08-17 23:51:01 +00:00
|
|
|
const computedValue = callback ? callback(value) : value;
|
2023-09-04 12:25:33 +00:00
|
|
|
const _key = ObjectUtils.toFlatCase(key);
|
|
|
|
const _cKey = ObjectUtils.toFlatCase(this.$name);
|
2023-08-17 23:51:01 +00:00
|
|
|
|
2023-09-05 10:18:36 +00:00
|
|
|
return (checkSameKey ? (_key !== _cKey ? computedValue?.[_key] : undefined) : computedValue?.[_key]) ?? computedValue;
|
2023-08-17 23:51:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return ObjectUtils.isNotEmpty(_usept)
|
|
|
|
? {
|
|
|
|
_usept,
|
|
|
|
originalValue: getValue(pt.originalValue),
|
|
|
|
value: getValue(pt.value)
|
|
|
|
}
|
2023-09-05 10:18:36 +00:00
|
|
|
: getValue(pt, true);
|
2023-08-17 23:51:01 +00:00
|
|
|
},
|
|
|
|
_usePT(pt, callback, key, params) {
|
|
|
|
const fn = (value) => callback(value, key, params);
|
|
|
|
|
|
|
|
if (pt?.hasOwnProperty('_usept')) {
|
2023-09-05 10:18:36 +00:00
|
|
|
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || {};
|
2023-08-17 23:51:01 +00:00
|
|
|
const originalValue = fn(pt.originalValue);
|
|
|
|
const value = fn(pt.value);
|
|
|
|
|
|
|
|
if (originalValue === undefined && value === undefined) return undefined;
|
|
|
|
else if (ObjectUtils.isString(value)) return value;
|
|
|
|
else if (ObjectUtils.isString(originalValue)) return originalValue;
|
|
|
|
|
2023-08-28 21:00:10 +00:00
|
|
|
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
|
2023-08-17 23:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return fn(pt);
|
|
|
|
},
|
|
|
|
_useGlobalPT(callback, key, params) {
|
|
|
|
return this._usePT(this.globalPT, callback, key, params);
|
|
|
|
},
|
|
|
|
_useDefaultPT(callback, key, params) {
|
|
|
|
return this._usePT(this.defaultPT, callback, key, params);
|
|
|
|
},
|
2023-03-21 12:05:24 +00:00
|
|
|
ptm(key = '', params = {}) {
|
2023-08-02 10:39:12 +00:00
|
|
|
return this._getPTValue(this.pt, key, { ...this.$params, ...params });
|
2023-03-22 12:11:03 +00:00
|
|
|
},
|
|
|
|
ptmo(obj = {}, key = '', params = {}) {
|
2023-07-04 02:24:37 +00:00
|
|
|
return this._getPTValue(obj, key, { instance: this, ...params }, false);
|
2023-05-19 10:32:44 +00:00
|
|
|
},
|
2023-05-19 11:14:50 +00:00
|
|
|
cx(key = '', params = {}) {
|
2023-08-02 10:39:12 +00:00
|
|
|
return !this.isUnstyled ? this._getOptionValue(this.$css.classes, key, { ...this.$params, ...params }) : undefined;
|
2023-05-23 09:15:04 +00:00
|
|
|
},
|
2023-05-19 11:14:50 +00:00
|
|
|
sx(key = '', when = true, params = {}) {
|
2023-05-19 10:32:44 +00:00
|
|
|
if (when) {
|
2023-08-02 10:39:12 +00:00
|
|
|
const self = this._getOptionValue(this.$css.inlineStyles, key, { ...this.$params, ...params });
|
|
|
|
const base = this._getOptionValue(inlineStyles, key, { ...this.$params, ...params });
|
2023-05-19 10:32:44 +00:00
|
|
|
|
|
|
|
return [base, self];
|
|
|
|
}
|
|
|
|
|
2023-06-07 13:50:56 +00:00
|
|
|
return undefined;
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
2023-05-10 11:49:54 +00:00
|
|
|
},
|
|
|
|
computed: {
|
2023-07-13 11:12:07 +00:00
|
|
|
globalPT() {
|
2023-08-17 23:51:01 +00:00
|
|
|
return this._getPT(this.$config?.pt, undefined, (value) => ObjectUtils.getItemValue(value, { instance: this }));
|
2023-07-13 11:12:07 +00:00
|
|
|
},
|
2023-05-10 11:49:54 +00:00
|
|
|
defaultPT() {
|
2023-08-22 13:51:41 +00:00
|
|
|
return this._getPT(this.$config?.pt, undefined, (value) => this._getOptionValue(value, this.$name, { ...this.$params }) || ObjectUtils.getItemValue(value, { ...this.$params }));
|
2023-05-16 10:29:56 +00:00
|
|
|
},
|
|
|
|
isUnstyled() {
|
2023-08-30 21:08:41 +00:00
|
|
|
return this.unstyled !== undefined ? this.unstyled : this.$config?.unstyled;
|
2023-05-30 09:59:17 +00:00
|
|
|
},
|
2023-08-02 10:39:12 +00:00
|
|
|
$params() {
|
|
|
|
return { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance };
|
|
|
|
},
|
2023-05-30 09:59:17 +00:00
|
|
|
$css() {
|
2023-08-02 10:39:12 +00:00
|
|
|
return { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, loadCustomStyle: () => {}, ...(this._getHostInstance(this) || {}).$css, ...this.$options.css };
|
2023-08-11 01:34:02 +00:00
|
|
|
},
|
|
|
|
$config() {
|
|
|
|
return this.$primevue?.config;
|
2023-08-17 23:51:01 +00:00
|
|
|
},
|
|
|
|
$name() {
|
|
|
|
return this.$options.hostName || this.$.type.name;
|
2023-05-10 11:49:54 +00:00
|
|
|
}
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|