devextreme-vue
Version:
DevExtreme Vue UI and Visualization Components
83 lines (81 loc) • 2.9 kB
JavaScript
/*!
* devextreme-vue
* Version: 25.1.6
* Build date: Mon Oct 13 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-vue
*/
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInnerChanges = exports.getConfig = exports.initOptionChangedFunc = exports.initDxConfiguration = void 0;
const vue_1 = require("vue");
const vue_helper_1 = require("./vue-helper");
const configuration_1 = require("./configuration");
function getConfig(vueInstance) {
const componentOptions = (0, vue_helper_1.getNodeOptions)(vueInstance);
if (!componentOptions) {
return;
}
return componentOptions.$_config || vueInstance.$_config;
}
exports.getConfig = getConfig;
function getInnerChanges(vueInstance) {
const componentOptions = (0, vue_helper_1.getNodeOptions)(vueInstance);
if (!componentOptions) {
return;
}
return componentOptions.$_innerChanges || vueInstance.$_innerChanges;
}
exports.getInnerChanges = getInnerChanges;
function initOptionChangedFunc(config, props, vueInstance, innerChanges) {
if (!config) {
return;
}
config.init(Object.keys(props));
if (vueInstance) {
(0, configuration_1.setEmitOptionChangedFunc)(config, vueInstance, innerChanges);
}
}
exports.initOptionChangedFunc = initOptionChangedFunc;
function getComponentInfo({ name, isCollectionItem, ownerConfig }, removed) {
const parentPath = ownerConfig?.fullPath;
const optionPath = name && parentPath ? `${parentPath}.${name}` : name || '';
return {
optionPath,
isCollection: isCollectionItem,
removed,
};
}
function initDxConfiguration() {
return (0, vue_1.defineComponent)({
beforeMount() {
const thisComponent = this;
const config = getConfig(thisComponent);
const innerChanges = getInnerChanges(thisComponent);
initOptionChangedFunc(config, (0, vue_helper_1.getNodeTypeOfComponent)(thisComponent).props, thisComponent, innerChanges);
(0, configuration_1.bindOptionWatchers)(config, this, innerChanges);
},
mounted() {
if (this.$parent.$_instance) {
this.$parent.$_config.componentsCountChanged
.push(getComponentInfo(getConfig(this)));
}
},
beforeUnmount() {
const config = getConfig(this);
if (config) {
this.$parent.$_config.componentsCountChanged
.push(getComponentInfo(config, true));
}
},
render() {
return null;
},
});
}
exports.initDxConfiguration = initDxConfiguration;