Browse Source

Replace types with interfaces

pull/6359/head
mohamedsalem401 1 year ago
parent
commit
d4fe2c3e51
  1. 23
      packages/core/src/data_sources/model/collection_component/types.ts
  2. 2
      packages/core/src/dom_components/index.ts
  3. 14
      packages/core/src/dom_components/model/Component.ts

23
packages/core/src/data_sources/model/collection_component/types.ts

@ -4,12 +4,13 @@ import { ComponentDefinition } from '../../../dom_components/model/types';
import { CollectionVariableDefinition } from '../../../../test/specs/dom_components/model/ComponentTypes';
import { DataVariableDefinition } from '../DataVariable';
type CollectionDataSource = any[] | DataVariableDefinition | CollectionVariableDefinition;
type CollectionConfig = {
export type CollectionDataSource = any[] | DataVariableDefinition | CollectionVariableDefinition;
export interface CollectionConfig {
startIndex?: number;
endIndex?: number;
dataSource: CollectionDataSource;
};
}
export enum CollectionStateVariableType {
currentIndex = 'currentIndex',
@ -21,7 +22,7 @@ export enum CollectionStateVariableType {
remainingItems = 'remainingItems',
}
export type CollectionState = {
export interface CollectionState {
[CollectionStateVariableType.currentIndex]: number;
[CollectionStateVariableType.startIndex]: number;
[CollectionStateVariableType.currentItem]: any;
@ -29,19 +30,19 @@ export type CollectionState = {
[CollectionStateVariableType.collectionName]?: string;
[CollectionStateVariableType.totalItems]: number;
[CollectionStateVariableType.remainingItems]: number;
};
}
export type CollectionsStateMap = {
export interface CollectionsStateMap {
[key: string]: CollectionState;
};
}
export type CollectionComponentDefinition = {
export interface CollectionComponentDefinition extends ComponentDefinition {
[keyCollectionDefinition]: CollectionDefinition;
} & ComponentDefinition;
}
export type CollectionDefinition = {
export interface CollectionDefinition {
type: typeof CollectionComponentType;
collectionName?: string;
config: CollectionConfig;
block: ComponentDefinition;
};
}

2
packages/core/src/dom_components/index.ts

@ -130,7 +130,7 @@ import ComponentConditionalVariable from '../data_sources/model/conditional_vari
import ConditionalComponentView from '../data_sources/view/ComponentDynamicView';
import CollectionComponent from '../data_sources/model/collection_component/CollectionComponent';
import CollectionComponentView from '../data_sources/model/collection_component/CollectionComponentView';
import { CollectionComponentType } from "../data_sources/model/collection_component/constants";
import { CollectionComponentType } from '../data_sources/model/collection_component/constants';
export type ComponentEvent =
| 'component:create'

14
packages/core/src/dom_components/model/Component.ts

@ -56,9 +56,9 @@ import {
import { ComponentDynamicValueWatcher } from './ComponentDynamicValueWatcher';
import { DynamicWatchersOptions } from './DynamicValueWatcher';
export interface IComponent extends ExtractMethods<Component> { }
export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions { }
export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions { }
export interface IComponent extends ExtractMethods<Component> {}
export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions {}
export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions {}
const escapeRegExp = (str: string) => {
return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
@ -229,12 +229,12 @@ export default class Component extends StyleableModel<ComponentProperties> {
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)
@ -242,12 +242,12 @@ export default class Component extends StyleableModel<ComponentProperties> {
* @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;

Loading…
Cancel
Save