From 2ac49bb1f925a45585cac5126d9dcdf5890d65bb Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Mon, 23 Dec 2024 05:10:34 +0200 Subject: [PATCH] format --- packages/core/src/common/index.ts | 12 +++++----- .../src/dom_components/model/Component.ts | 20 ++++++++--------- .../model/ComponentDynamicValueListener.ts | 10 ++++----- .../ConditionalTraits.ts | 22 ++++++++++--------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/core/src/common/index.ts b/packages/core/src/common/index.ts index 090d76136..34292a4e9 100644 --- a/packages/core/src/common/index.ts +++ b/packages/core/src/common/index.ts @@ -2,7 +2,7 @@ import Backbone from 'backbone'; import { HTMLParserOptions } from '../parser/config/config'; export { default as $ } from '../utils/cash-dom'; -interface NOOP { } +interface NOOP {} export const collectionEvents = 'add remove reset change'; @@ -62,7 +62,7 @@ export interface Dimensions { width: number; } -export interface BoxRect extends Coordinates, Dimensions { } +export interface BoxRect extends Coordinates, Dimensions {} export type ElementRect = { top: number; @@ -77,13 +77,13 @@ export type CombinedModelConstructorOptions< > = Backbone.ModelConstructorOptions & E; export interface ViewOptions - extends Backbone.ViewOptions { } + extends Backbone.ViewOptions {} -export class Model extends Backbone.Model { } +export class Model extends Backbone.Model {} -export class Collection extends Backbone.Collection { } +export class Collection extends Backbone.Collection {} -export class View extends Backbone.View { } +export class View extends Backbone.View {} export type PickMatching = { [K in keyof T as T[K] extends V ? K : never]: T[K] }; diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 89d87dd5f..8225988f3 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -54,12 +54,12 @@ import { import { ComponentDynamicValueListener } from './ComponentDynamicValueListener'; import { DynamicValueWatcher } from './DynamicValueWatcher'; -export interface IComponent extends ExtractMethods { } +export interface IComponent extends ExtractMethods {} export interface DynamicWatchersOptions { skipWatcherUpdates?: boolean; } -export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions { } -export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions { } +export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions {} +export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions {} const escapeRegExp = (str: string) => { return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); @@ -226,12 +226,12 @@ export default class Component extends StyleableModel { return this.frame?.getPage(); } - preInit() { } + preInit() {} /** * Hook method, called once the model is created */ - init() { } + init() {} /** * Hook method, called when the model has been updated (eg. updated some model's property) @@ -239,12 +239,12 @@ export default class Component extends StyleableModel { * @param {*} value Property value, if triggered after some property update * @param {*} previous Property previous value, if triggered after some property update */ - updated(property: string, value: any, previous: any) { } + updated(property: string, value: any, previous: any) {} /** * Hook method, called once the model has been removed */ - removed() { } + removed() {} em!: EditorModel; opt!: ComponentOptions; @@ -1575,14 +1575,14 @@ export default class Component extends StyleableModel { const dynamicTraitsObj = this.componentDVListener.getTraitsDefs(); const keys = Object.keys(dynamicTraitsObj); const serializedTraits: ObjectAny[] = []; - keys.forEach(key => { + keys.forEach((key) => { const traitJSON = this.getTrait(key).toJSON(); const traitValue = dynamicTraitsObj[key]; serializedTraits.push({ ...traitJSON, name: key, - value: traitValue - }) + value: traitValue, + }); }); if (serializedTraits.length > 0) { obj[dynamicAttrKey] = serializedTraits; diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts index a9fb36e40..ec33da1f8 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueListener.ts @@ -35,20 +35,18 @@ export class ComponentDynamicValueListener { } if (Array.isArray(values[dynamicAttrKey]) && values[dynamicAttrKey].length > 0) { - values.traits = values.traits - ? [...values[dynamicAttrKey], ...values.traits] - : values[dynamicAttrKey]; + values.traits = values.traits ? [...values[dynamicAttrKey], ...values.traits] : values[dynamicAttrKey]; } if (values.traits) { const evaluatedTraitsValues = DynamicValueWatcher.getStaticValues( values.traits.map((trait: any) => trait.value), - em + em, ); props.traits = values.traits.map((trait: any, index: number) => ({ ...trait, - value: evaluatedTraitsValues[index] + value: evaluatedTraitsValues[index], })); } @@ -80,7 +78,7 @@ export class ComponentDynamicValueListener { } watchTraits(traits: (string | ObjectAny)[]) { - const evaluatedTraits: { [key: string]: ObjectAny } = {} + const evaluatedTraits: { [key: string]: ObjectAny } = {}; traits?.forEach((trait: any) => { if (typeof trait === 'string' || !trait.name) { return; diff --git a/packages/core/test/specs/data_sources/model/conditional_variables/ConditionalTraits.ts b/packages/core/test/specs/data_sources/model/conditional_variables/ConditionalTraits.ts index 5895b64b5..fa7f78d9c 100644 --- a/packages/core/test/specs/data_sources/model/conditional_variables/ConditionalTraits.ts +++ b/packages/core/test/specs/data_sources/model/conditional_variables/ConditionalTraits.ts @@ -176,18 +176,20 @@ describe('TraitConditionalVariable', () => { component: { components: [ { - [dynamicAttrKey]: [{ - name: 'dynamicTrait', - value: { - condition: { - left: 0, - operator: '>', - right: -1, + [dynamicAttrKey]: [ + { + name: 'dynamicTrait', + value: { + condition: { + left: 0, + operator: '>', + right: -1, + }, + ifTrue: 'Positive', + type: 'conditional-variable', }, - ifTrue: 'Positive', - type: 'conditional-variable', }, - }], + ], type: 'text', }, ],