diff --git a/src/main.ts b/src/main.ts index 3fddd12..3ee8c33 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,21 +1,5 @@ import utils from './utils/index' -interface ComponentOptions { - tag: string - template: string - style?: string - onMount?: (this: CustomElement) => void - onUnmount?: () => void - onAttributeChanged?: ( - attrName: string, - oldValue: string, - newValue: string, - ) => void - states?: Record - statesListeners?: { [key: string]: (value: unknown) => void } - funcs?: { [key: string]: (...args: unknown[]) => void } -} - export default (options: ComponentOptions) => { const { tag, diff --git a/src/types.d.ts b/src/types.d.ts index 9b7a3b9..14904f7 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -2,3 +2,28 @@ interface CustomElement extends HTMLElement { setState(key_path: string, value: unknown): void getState(key_path: string): unknown } + +interface ListRenderingContext { + states: Record + stateToElementsMap: Record> + statesListeners: Record void> + setState: (keyPath: string, value: unknown) => void + getState: (keyPath: string) => unknown + triggerFunc: (eventName: string, ...args: unknown[]) => void +} + +interface ComponentOptions { + tag: string + template: string + style?: string + onMount?: (this: CustomElement) => void + onUnmount?: () => void + onAttributeChanged?: ( + attrName: string, + oldValue: string, + newValue: string, + ) => void + states?: Record + statesListeners?: { [key: string]: (value: unknown) => void } + funcs?: { [key: string]: (...args: unknown[]) => void } +} diff --git a/src/utils/processTemplateMarco.ts b/src/utils/processTemplateMarco.ts index 3827801..14c4df5 100644 --- a/src/utils/processTemplateMarco.ts +++ b/src/utils/processTemplateMarco.ts @@ -307,16 +307,6 @@ function setupConditionRendering( } } -// Interface for list rendering context -interface ListRenderingContext { - states: Record - stateToElementsMap: Record> - statesListeners: Record void> - setState: (keyPath: string, value: unknown) => void - getState: (keyPath: string) => unknown - triggerFunc: (eventName: string, ...args: unknown[]) => void -} - // Evaluate expressions using the item context function evaluateExpressionWithItemContext( expression: string,