Refactor #3965 - Update BaseComponent
parent
6c29642632
commit
57b6f2c63a
|
@ -41,6 +41,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
_getHostInstance(instance) {
|
||||||
|
return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined;
|
||||||
|
},
|
||||||
_getOptionValue(options, key = '', params = {}) {
|
_getOptionValue(options, key = '', params = {}) {
|
||||||
const fKeys = ObjectUtils.convertToFlatCase(key).split('.');
|
const fKeys = ObjectUtils.convertToFlatCase(key).split('.');
|
||||||
const fKey = fKeys.shift();
|
const fKey = fKeys.shift();
|
||||||
|
@ -51,10 +54,10 @@ export default {
|
||||||
: undefined
|
: undefined
|
||||||
: ObjectUtils.getItemValue(options, params);
|
: ObjectUtils.getItemValue(options, params);
|
||||||
},
|
},
|
||||||
_getPTValue(obj = {}, key = '', params = {}) {
|
_getPTValue(obj = {}, key = '', params = {}, searchInDefaultPT = true) {
|
||||||
const datasetPrefix = 'data-pc-';
|
const datasetPrefix = 'data-pc-';
|
||||||
const self = this._getOptionValue(obj, key, params);
|
const self = this._getOptionValue(obj, key, params);
|
||||||
const globalPT = this._getOptionValue(this.defaultPT, key, params);
|
const globalPT = searchInDefaultPT ? this._getOptionValue(this.defaultPT, key, params) : undefined;
|
||||||
const merged = mergeProps(self, globalPT, {
|
const merged = mergeProps(self, globalPT, {
|
||||||
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.convertToFlatCase(this.$.type.name) }),
|
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.convertToFlatCase(this.$.type.name) }),
|
||||||
[`${datasetPrefix}section`]: ObjectUtils.convertToFlatCase(key)
|
[`${datasetPrefix}section`]: ObjectUtils.convertToFlatCase(key)
|
||||||
|
@ -71,13 +74,13 @@ export default {
|
||||||
return this._getPTValue(this.pt, key, { props: this.$props, state: this.$data, ...params });
|
return this._getPTValue(this.pt, key, { props: this.$props, state: this.$data, ...params });
|
||||||
},
|
},
|
||||||
ptmo(obj = {}, key = '', params = {}) {
|
ptmo(obj = {}, key = '', params = {}) {
|
||||||
return this._getPTValue(obj, key, params);
|
return this._getPTValue(obj, key, params, false);
|
||||||
},
|
},
|
||||||
cx(key = '', params = {}) {
|
cx(key = '', params = {}) {
|
||||||
return !this.isUnstyled ? this._getOptionValue(this.$css.classes, key, { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance, ...params }) : undefined;
|
return !this.isUnstyled ? this._getOptionValue(this.$css.classes, key, { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance, ...params }) : undefined;
|
||||||
},
|
},
|
||||||
cxo(key = '', params = {}) {
|
cxo(key = '', params = {}) {
|
||||||
return !this.isUnstyled ? this._getOptionValue(this.$parentInstance.$parentInstance.$css.classes, key, { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance, ...params }) : undefined;
|
return this.cx(key, params);
|
||||||
},
|
},
|
||||||
sx(key = '', when = true, params = {}) {
|
sx(key = '', when = true, params = {}) {
|
||||||
if (when) {
|
if (when) {
|
||||||
|
@ -90,14 +93,7 @@ export default {
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
sxo(key = '', when = true, params = {}) {
|
sxo(key = '', when = true, params = {}) {
|
||||||
if (when) {
|
return this.sx(key, when, params);
|
||||||
const self = this._getOptionValue(this.$parentInstance.$parentInstance.$css.inlineStyles, key, { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance, ...params });
|
|
||||||
const base = this._getOptionValue(inlineStyles, key, { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance, ...params });
|
|
||||||
|
|
||||||
return [base, self];
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -108,7 +104,7 @@ export default {
|
||||||
return this.unstyled !== undefined ? this.unstyled : this.$primevue.config.unstyled;
|
return this.unstyled !== undefined ? this.unstyled : this.$primevue.config.unstyled;
|
||||||
},
|
},
|
||||||
$css() {
|
$css() {
|
||||||
return { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, ...(this.$parentInstance || {}).$css, ...this.$options.css };
|
return { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, ...(this._getHostInstance(this) || {}).$css, ...this.$options.css };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,6 +125,7 @@ import BodyCell from './BodyCell.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TableBody',
|
name: 'TableBody',
|
||||||
|
hostName: 'DataTable',
|
||||||
extends: BaseComponent,
|
extends: BaseComponent,
|
||||||
emits: [
|
emits: [
|
||||||
'rowgroup-toggle',
|
'rowgroup-toggle',
|
||||||
|
|
|
@ -137,6 +137,7 @@ import HeaderCheckbox from './HeaderCheckbox.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TableHeader',
|
name: 'TableHeader',
|
||||||
|
hostName: 'DataTable',
|
||||||
extends: BaseComponent,
|
extends: BaseComponent,
|
||||||
emits: [
|
emits: [
|
||||||
'column-click',
|
'column-click',
|
||||||
|
|
Loading…
Reference in New Issue