UNPKG

@progress/kendo-vue-charts

Version:
140 lines (139 loc) 3.26 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { defineComponent as s, createVNode as o } from "vue"; import { noop as h, guid as a, getDefaultSlots as l } from "@progress/kendo-vue-common"; const p = /* @__PURE__ */ s({ name: "KendoConfiguration", props: { chartKey: String, config: { type: Object, default: function() { return {}; } } }, data() { return { childState: {}, index: null }; }, provide() { return { addChild: this.addChildOption, removeChild: this.removeChildOption, childOption: !0 }; }, inject: { childOption: { default: null }, addChild: { default: h }, removeChild: { default: h }, child: { default: {} }, parentKey: { default: null }, chartCollection: { default: null }, dispatchOptions: { default: null }, childrenObserver: { default: null } }, created() { this.currentIndex = void 0, this.uid = a(), this.addChild && this.addChild({ chartKey: this.$props.chartKey, payload: Object.assign({}, this.$props.config), uid: this.uid }); }, mounted() { this.dispatch(); }, watch: { config(t, i) { JSON.stringify(t) !== JSON.stringify(i) && this.dispatch(); } }, unmounted() { this.onDestroyed(); }, render() { const t = l(this); return o("div", null, [t]); }, methods: { onDestroyed() { if (this.removeChild) { this.removeChild({ uid: this.uid }); const { chartKey: t, parentStore: i, config: e } = this.$props; (i || this.dispatchOptions)({ chartKey: t, parentKey: this.parentKey, chartCollectionIdxKey: this.chartCollection + "_", uid: this.uid }); } }, addChildOption(t) { this.childState = { ...this.childState, [t.chartKey]: t.payload }, this.dispatch(); }, removeChildOption() { this.childState = {}; }, dispatch() { const { chartKey: t, parentStore: i, config: e } = this.$props, d = i || this.dispatchOptions; if (this.childOption) { this.addChild({ chartKey: t, payload: Object.assign({}, e, this.childState) }); return; } this.chartCollection ? (this.currentIndex = this.child.collection.findIndex((n) => n.uid === this.uid), d({ chartKey: t, parentKey: this.parentKey, chartCollectionIdxKey: this.chartCollection + "_" + this.currentIndex, payload: Object.assign({}, e, { uid: this.uid }, this.childState) })) : d({ chartKey: t, payload: Object.assign({}, e, this.childState) }); } } }); export { p as Configuration };