Refactor #6408
parent
94a54fce68
commit
32c6c77ca3
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { Theme, ThemeService } from '@primeuix/styled';
|
import { Theme, ThemeService } from '@primeuix/styled';
|
||||||
import { findSingle } from '@primeuix/utils/dom';
|
import { findSingle, isClient } from '@primeuix/utils/dom';
|
||||||
import { getKeyValue, isArray, isFunction, isNotEmpty, isString, resolve, toFlatCase } from '@primeuix/utils/object';
|
import { getKeyValue, isArray, isFunction, isNotEmpty, isString, resolve, toFlatCase } from '@primeuix/utils/object';
|
||||||
import { uuid } from '@primeuix/utils/uuid';
|
import { uuid } from '@primeuix/utils/uuid';
|
||||||
import Base from '@primevue/core/base';
|
import Base from '@primevue/core/base';
|
||||||
|
@ -59,7 +59,6 @@ export default {
|
||||||
rootEl: undefined,
|
rootEl: undefined,
|
||||||
$attrSelector: undefined,
|
$attrSelector: undefined,
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
this.$attrSelector = uuid('pc');
|
|
||||||
const _usept = this.pt?.['_usept'];
|
const _usept = this.pt?.['_usept'];
|
||||||
const originalValue = _usept ? this.pt?.originalValue?.[this.$.type.name] : undefined;
|
const originalValue = _usept ? this.pt?.originalValue?.[this.$.type.name] : undefined;
|
||||||
const value = _usept ? this.pt?.value?.[this.$.type.name] : this.pt;
|
const value = _usept ? this.pt?.value?.[this.$.type.name] : this.pt;
|
||||||
|
@ -71,22 +70,24 @@ export default {
|
||||||
const valueInConfig = _useptInConfig ? this.$primevue?.config?.pt?.value : this.$primevue?.config?.pt;
|
const valueInConfig = _useptInConfig ? this.$primevue?.config?.pt?.value : this.$primevue?.config?.pt;
|
||||||
|
|
||||||
(valueInConfig || originalValueInConfig)?.[this.$.type.name]?.hooks?.['onBeforeCreate']?.();
|
(valueInConfig || originalValueInConfig)?.[this.$.type.name]?.hooks?.['onBeforeCreate']?.();
|
||||||
|
this.$attrSelector = uuid('pc');
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this._hook('onCreated');
|
this._hook('onCreated');
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
this._loadStyles();
|
|
||||||
this._hook('onBeforeMount');
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
// @todo - improve performance
|
// @todo - improve performance
|
||||||
this.rootEl = findSingle(this.$el, `[data-pc-name="${toFlatCase(this.$.type.name)}"]`);
|
this.rootEl = findSingle(this.$el, `[data-pc-name="${toFlatCase(this.$.type.name)}"]`);
|
||||||
|
|
||||||
if (this.rootEl) {
|
if (this.rootEl) {
|
||||||
|
this.$attrSelector && !this.rootEl.hasAttribute(this.$attrSelector) && this.rootEl.setAttribute(this.$attrSelector, '');
|
||||||
this.rootEl.$pc = { name: this.$.type.name, attrSelector: this.$attrSelector, ...this.$params };
|
this.rootEl.$pc = { name: this.$.type.name, attrSelector: this.$attrSelector, ...this.$params };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._loadStyles();
|
||||||
|
this._hook('onBeforeMount');
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
this._hook('onMounted');
|
this._hook('onMounted');
|
||||||
},
|
},
|
||||||
beforeUpdate() {
|
beforeUpdate() {
|
||||||
|
@ -233,7 +234,7 @@ export default {
|
||||||
...(key === 'root' && {
|
...(key === 'root' && {
|
||||||
[`${datasetPrefix}name`]: toFlatCase(isExtended ? this.pt?.['data-pc-section'] : this.$.type.name),
|
[`${datasetPrefix}name`]: toFlatCase(isExtended ? this.pt?.['data-pc-section'] : this.$.type.name),
|
||||||
...(isExtended && { [`${datasetPrefix}extend`]: toFlatCase(this.$.type.name) }),
|
...(isExtended && { [`${datasetPrefix}extend`]: toFlatCase(this.$.type.name) }),
|
||||||
[`${this.$attrSelector}`]: ''
|
...(isClient() && { [`${this.$attrSelector}`]: '' })
|
||||||
}),
|
}),
|
||||||
[`${datasetPrefix}section`]: toFlatCase(key)
|
[`${datasetPrefix}section`]: toFlatCase(key)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue