2023-03-21 12:05:24 +00:00
|
|
|
<script>
|
2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
2024-01-02 10:18:28 +00:00
|
|
|
import { toVariables } from 'primevue/theme';
|
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-10-02 10:46:09 +00:00
|
|
|
import BaseComponentStyle from './style/BaseComponentStyle';
|
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-10-02 10:46:09 +00:00
|
|
|
BaseComponentStyle.loadStyle({ nonce: this.$config?.csp?.nonce });
|
|
|
|
this.$options.style && this.$style.loadStyle({ nonce: this.$config?.csp?.nonce });
|
2023-08-02 11:59:10 +00:00
|
|
|
}
|
2023-05-30 09:59:17 +00:00
|
|
|
}
|
2024-01-02 10:18:28 +00:00
|
|
|
},
|
|
|
|
$globalTheme: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newValue) {
|
|
|
|
if (newValue) {
|
2024-02-13 09:36:36 +00:00
|
|
|
const { variables, css } = newValue;
|
2024-02-11 09:37:25 +00:00
|
|
|
const { colorScheme, ...vRest } = variables || {};
|
|
|
|
const { dark, ...csRest } = colorScheme || {};
|
|
|
|
const vRest_css = ObjectUtils.isNotEmpty(vRest) ? toVariables({ [this.$style.name]: vRest }).css : '';
|
|
|
|
const csRest_css = ObjectUtils.isNotEmpty(csRest) ? toVariables({ [this.$style.name]: csRest }).css : '';
|
|
|
|
const dark_css = ObjectUtils.isNotEmpty(dark) ? toVariables({ [this.$style.name]: dark }, { selector: '.p-dark' }).css : '';
|
|
|
|
const variables_css = `${vRest_css}${csRest_css}${dark_css}`;
|
|
|
|
|
|
|
|
this.$style?.loadTheme(`${variables_css}${css}`, { useStyleOptions: this.$styleOptions });
|
2024-01-02 10:18:28 +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-10-02 10:46:09 +00:00
|
|
|
BaseStyle.loadStyle({ 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
|
|
|
},
|
2024-01-29 12:35:09 +00:00
|
|
|
_mergeProps(fn, ...args) {
|
|
|
|
return ObjectUtils.isFunction(fn) ? fn(...args) : mergeProps(...args);
|
|
|
|
},
|
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-10-02 10:46:09 +00:00
|
|
|
ObjectUtils.isNotEmpty(globalCSS) && BaseComponentStyle.loadGlobalStyle(globalCSS, { nonce: this.$config?.csp?.nonce });
|
2024-01-02 10:18:28 +00:00
|
|
|
|
|
|
|
this._loadThemeVariables();
|
|
|
|
|
|
|
|
BaseComponentStyle.loadGlobalTheme(this.$presetTheme?.components?.global?.css, { nonce: this.$config?.csp?.nonce });
|
|
|
|
},
|
|
|
|
_loadThemeVariables() {
|
2024-02-12 10:30:01 +00:00
|
|
|
const { primitive, semantic } = this.$presetTheme;
|
|
|
|
const { colorScheme, ...sRest } = semantic || {};
|
|
|
|
const { dark, ...csRest } = colorScheme || {};
|
|
|
|
const primitive_css = ObjectUtils.isNotEmpty(primitive) ? toVariables({ primitive }).css : '';
|
|
|
|
const sRest_css = ObjectUtils.isNotEmpty(sRest) ? toVariables({ semantic: sRest }).css : '';
|
|
|
|
const csRest_css = ObjectUtils.isNotEmpty(csRest) ? toVariables({ light: csRest }).css : '';
|
|
|
|
const dark_css = ObjectUtils.isNotEmpty(dark) ? toVariables({ dark }, { selector: '.p-dark' }).css : '';
|
|
|
|
const semantic_css = `${sRest_css}${csRest_css}${dark_css}`;
|
|
|
|
|
|
|
|
BaseStyle.loadTheme(primitive_css, { name: 'primitive-variables', nonce: this.$config?.csp?.nonce });
|
|
|
|
BaseStyle.loadTheme(semantic_css, { name: 'semantic-variables', nonce: this.$config?.csp?.nonce });
|
|
|
|
|
|
|
|
/*const { variables } = this.$presetTheme;
|
2024-02-11 09:37:25 +00:00
|
|
|
const { colorScheme, ...vRest } = variables || {};
|
|
|
|
const { dark, ...csRest } = colorScheme || {};
|
|
|
|
const vRest_css = ObjectUtils.isNotEmpty(vRest) ? toVariables({ light: vRest }).css : '';
|
|
|
|
const csRest_css = ObjectUtils.isNotEmpty(csRest) ? toVariables({ light: csRest }).css : '';
|
|
|
|
const dark_css = ObjectUtils.isNotEmpty(dark) ? toVariables({ dark }, { selector: '.p-dark' }).css : '';
|
|
|
|
const variables_css = `${vRest_css}${csRest_css}${dark_css}`;
|
|
|
|
|
2024-02-12 10:30:01 +00:00
|
|
|
BaseStyle.loadTheme(variables_css, { name: 'theme-variables', nonce: this.$config?.csp?.nonce });*/
|
2024-02-11 09:37:25 +00:00
|
|
|
/*const { primitive, semantic } = this.$presetTheme;
|
2024-02-05 13:00:52 +00:00
|
|
|
const { colorScheme, ...sRest } = semantic || {};
|
|
|
|
const { dark, ...csRest } = colorScheme || {};
|
2024-01-02 10:18:28 +00:00
|
|
|
|
2024-02-05 13:00:52 +00:00
|
|
|
// primitive
|
|
|
|
BaseStyle.loadTheme(toVariables({ primitive }).css, { name: 'primitive-variables', nonce: this.$config?.csp?.nonce });
|
|
|
|
|
|
|
|
// semantic -> light + common
|
|
|
|
const light_common_css = `${toVariables({ light: { ...sRest, ...csRest } }).css}${toVariables({ dark }, { selector: '.p-dark' }).css}`;
|
|
|
|
|
|
|
|
BaseStyle.loadTheme(light_common_css, { name: 'semantic-variables', nonce: this.$config?.csp?.nonce });
|
|
|
|
|
|
|
|
/*Object.entries(rest).forEach(([key, value]) => {
|
2024-01-02 10:18:28 +00:00
|
|
|
const v = toVariables({ [key]: value });
|
|
|
|
|
|
|
|
BaseStyle.loadTheme(v.css, { name: `${key}-variables`, nonce: this.$config?.csp?.nonce });
|
2024-02-11 09:37:25 +00:00
|
|
|
});
|
|
|
|
*/
|
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-08-17 23:51:01 +00:00
|
|
|
const searchOut = /./g.test(key) && !!params[key.split('.')[0]];
|
2023-09-20 11:25:33 +00:00
|
|
|
const { mergeSections = true, mergeProps: useMergeProps = false } = this._getPropValue('ptOptions') || this.$config?.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;
|
2024-02-10 00:19:32 +00:00
|
|
|
const self = searchOut ? undefined : this._getPTSelf(obj, this._getPTClassValue, key, { ...params, global: global || {} });
|
2024-01-30 14:35:32 +00:00
|
|
|
const datasets = this._getPTDatasets(key);
|
2023-04-25 11:36:01 +00:00
|
|
|
|
2024-01-29 12:35:09 +00:00
|
|
|
return mergeSections || (!mergeSections && self) ? (useMergeProps ? this._mergeProps(useMergeProps, global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
|
2023-04-25 11:36:01 +00:00
|
|
|
},
|
2024-02-10 00:19:32 +00:00
|
|
|
_getPTSelf(obj = {}, ...args) {
|
|
|
|
return mergeProps(
|
|
|
|
this._usePT(this._getPT(obj, this.$name), ...args), // Exp; <component :pt="{}"
|
|
|
|
this._usePT(this.$_attrsPT, ...args) // Exp; <component :pt:[passthrough_key]:[attribute]="{value}" or <component :pt:[passthrough_key]="() =>{value}"
|
|
|
|
);
|
|
|
|
},
|
2024-01-30 14:35:32 +00:00
|
|
|
_getPTDatasets(key = '') {
|
|
|
|
const datasetPrefix = 'data-pc-';
|
|
|
|
const isExtended = key === 'root' && ObjectUtils.isNotEmpty(this.pt?.['data-pc-section']);
|
|
|
|
|
|
|
|
return (
|
|
|
|
key !== 'transition' && {
|
|
|
|
...(key === 'root' && {
|
|
|
|
[`${datasetPrefix}name`]: ObjectUtils.toFlatCase(isExtended ? this.pt?.['data-pc-section'] : this.$.type.name),
|
|
|
|
...(isExtended && { [`${datasetPrefix}extend`]: ObjectUtils.toFlatCase(this.$.type.name) })
|
|
|
|
}),
|
|
|
|
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
|
|
|
|
}
|
|
|
|
);
|
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) {
|
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
|
|
|
};
|
|
|
|
|
2023-09-20 11:48:21 +00:00
|
|
|
return pt?.hasOwnProperty('_usept')
|
2023-08-17 23:51:01 +00:00
|
|
|
? {
|
2023-09-20 11:48:21 +00:00
|
|
|
_usept: pt['_usept'],
|
2023-08-17 23:51:01 +00:00
|
|
|
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-20 11:25:33 +00:00
|
|
|
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || this.$config?.ptOptions || {};
|
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;
|
|
|
|
|
2024-01-29 12:35:09 +00:00
|
|
|
return mergeSections || (!mergeSections && value) ? (useMergeProps ? this._mergeProps(useMergeProps, 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
|
|
|
},
|
2024-02-10 00:19:32 +00:00
|
|
|
ptmi(key = '', params = {}) {
|
2024-02-11 08:10:29 +00:00
|
|
|
// inheritAttrs:true without `pt:*`
|
2024-02-10 00:19:32 +00:00
|
|
|
return mergeProps(this.$_attrsNoPT, this.ptm(key, 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-10-02 10:46:09 +00:00
|
|
|
return !this.isUnstyled ? this._getOptionValue(this.$style.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-10-02 10:46:09 +00:00
|
|
|
const self = this._getOptionValue(this.$style.inlineStyles, key, { ...this.$params, ...params });
|
|
|
|
const base = this._getOptionValue(BaseComponentStyle.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
|
|
|
},
|
2024-01-02 10:18:28 +00:00
|
|
|
$presetTheme() {
|
|
|
|
const { preset, options } = this.$config?.theme || {};
|
|
|
|
|
|
|
|
return ObjectUtils.getItemValue(preset, options);
|
|
|
|
},
|
|
|
|
$globalTheme() {
|
|
|
|
return ObjectUtils.getItemValue(this.$presetTheme?.components?.[this.$style.name], this.$params);
|
|
|
|
},
|
2023-08-02 10:39:12 +00:00
|
|
|
$params() {
|
2023-12-18 17:07:16 +00:00
|
|
|
const parentInstance = this._getHostInstance(this) || this.$parent;
|
2023-12-05 11:06:32 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
instance: this,
|
|
|
|
props: this.$props,
|
|
|
|
state: this.$data,
|
2023-12-10 21:41:17 +00:00
|
|
|
attrs: this.$attrs,
|
2023-12-05 11:06:32 +00:00
|
|
|
parent: {
|
|
|
|
instance: parentInstance,
|
|
|
|
props: parentInstance?.$props,
|
2023-12-10 21:41:17 +00:00
|
|
|
state: parentInstance?.$data,
|
2023-12-10 21:43:59 +00:00
|
|
|
attrs: parentInstance?.$attrs
|
2023-12-05 11:06:32 +00:00
|
|
|
},
|
|
|
|
/* @deprecated since v3.43.0. Use the `parent.instance` instead of the `parentInstance`.*/
|
|
|
|
parentInstance
|
|
|
|
};
|
2023-08-02 10:39:12 +00:00
|
|
|
},
|
2023-10-02 10:46:09 +00:00
|
|
|
$style() {
|
2024-02-13 09:36:36 +00:00
|
|
|
return { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, loadCustomStyle: () => {}, loadTheme: () => {}, ...(this._getHostInstance(this) || {}).$style, ...this.$options.style };
|
2023-08-11 01:34:02 +00:00
|
|
|
},
|
2024-01-02 10:18:28 +00:00
|
|
|
$styleOptions() {
|
|
|
|
return { nonce: this.$config?.csp?.nonce };
|
|
|
|
},
|
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;
|
2024-02-10 00:19:32 +00:00
|
|
|
},
|
|
|
|
$_attrsPT() {
|
|
|
|
return Object.entries(this.$attrs || {})
|
|
|
|
.filter(([key]) => key?.startsWith('pt:'))
|
|
|
|
.reduce((result, [key, value]) => {
|
|
|
|
const [, ...rest] = key.split(':');
|
|
|
|
|
|
|
|
rest?.reduce((currentObj, nestedKey, index, array) => {
|
|
|
|
!currentObj[nestedKey] && (currentObj[nestedKey] = index === array.length - 1 ? value : {});
|
|
|
|
|
|
|
|
return currentObj[nestedKey];
|
|
|
|
}, result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}, {});
|
|
|
|
},
|
|
|
|
$_attrsNoPT() {
|
|
|
|
// $attrs without `pt:*`
|
|
|
|
return Object.entries(this.$attrs || {})
|
2024-02-13 09:36:36 +00:00
|
|
|
.filter(([key]) => !key?.startsWith('pt:') && !key?.startsWith('sx:'))
|
2024-02-11 08:46:46 +00:00
|
|
|
.reduce((acc, [key, value]) => {
|
|
|
|
acc[key] = value;
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, {});
|
2023-05-10 11:49:54 +00:00
|
|
|
}
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|