From 948aeac29799948ae13c525f9689b909986e3288 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Tue, 10 Dec 2024 01:22:22 +0200 Subject: [PATCH] Refactor with ObjectAny --- .../dom_components/model/ComponentDynamicValueListener.ts | 7 ++----- .../core/src/dom_components/model/DynamicValueWatcher.ts | 7 ++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts index 3259235c0..59b59d123 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts @@ -1,5 +1,4 @@ import { ObjectAny } from '../../common'; -import { evaluateDynamicValueDefinition, isDynamicValueDefinition } from '../../data_sources/model/utils'; import EditorModel from '../../editor/model/Editor'; import Component from './Component'; import { DynamicValueWatcher } from './DynamicValueWatcher'; @@ -22,9 +21,7 @@ export class ComponentDynamicValueListener { } static evaluateComponentDef( - values: { - [key: string]: any; - }, + values: ObjectAny, em: EditorModel, ) { const props = DynamicValueWatcher.getStaticValues(values, em); @@ -33,7 +30,7 @@ export class ComponentDynamicValueListener { return props; } - watchComponentDef(values: { [key: string]: any }) { + watchComponentDef(values: ObjectAny) { this.watchProps(values); this.watchAttributes(values.attributes); } diff --git a/packages/core/src/dom_components/model/DynamicValueWatcher.ts b/packages/core/src/dom_components/model/DynamicValueWatcher.ts index 0722bf6ae..505d5ba73 100644 --- a/packages/core/src/dom_components/model/DynamicValueWatcher.ts +++ b/packages/core/src/dom_components/model/DynamicValueWatcher.ts @@ -1,3 +1,4 @@ +import { ObjectAny } from '../../common'; import DynamicVariableListenerManager from '../../data_sources/model/DataVariableListenerManager'; import { evaluateDynamicValueDefinition, isDynamicValueDefinition } from '../../data_sources/model/utils'; import EditorModel from '../../editor/model/Editor'; @@ -27,13 +28,13 @@ export class DynamicValueWatcher { return evaluatedValues; } - static areStaticValues(values: { [key: string]: any }) { + static areStaticValues(values: ObjectAny) { return Object.keys(values).every((key) => { return !isDynamicValueDefinition(values[key]); }); } - watchDynamicValue(values: { [key: string]: any }) { + watchDynamicValue(values: ObjectAny) { const dynamicProps = this.getDynamicValues(values); const propsKeys = Object.keys(dynamicProps); for (let index = 0; index < propsKeys.length; index++) { @@ -51,7 +52,7 @@ export class DynamicValueWatcher { return dynamicProps; } - private getDynamicValues(values: { [key: string]: any }) { + private getDynamicValues(values: ObjectAny) { const dynamicValues = { ...values }; const propsKeys = Object.keys(dynamicValues); for (let index = 0; index < propsKeys.length; index++) {