UNPKG

devextreme-vue

Version:

DevExtreme Vue UI and Visualization Components

77 lines (75 loc) 2.57 kB
/*! * 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 */ import { defineComponent } from 'vue'; import { getNodeOptions, getNodeTypeOfComponent } from './vue-helper'; import { bindOptionWatchers, setEmitOptionChangedFunc } from './configuration'; function getConfig(vueInstance) { const componentOptions = getNodeOptions(vueInstance); if (!componentOptions) { return; } return componentOptions.$_config || vueInstance.$_config; } function getInnerChanges(vueInstance) { const componentOptions = getNodeOptions(vueInstance); if (!componentOptions) { return; } return componentOptions.$_innerChanges || vueInstance.$_innerChanges; } function initOptionChangedFunc(config, props, vueInstance, innerChanges) { if (!config) { return; } config.init(Object.keys(props)); if (vueInstance) { setEmitOptionChangedFunc(config, vueInstance, innerChanges); } } 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 defineComponent({ beforeMount() { const thisComponent = this; const config = getConfig(thisComponent); const innerChanges = getInnerChanges(thisComponent); initOptionChangedFunc(config, getNodeTypeOfComponent(thisComponent).props, thisComponent, innerChanges); 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; }, }); } export { initDxConfiguration, initOptionChangedFunc, getConfig, getInnerChanges, };