diff --git a/packages/runtime/src/App.tsx b/packages/runtime/src/App.tsx index eb7daf4d..6bbb6b10 100644 --- a/packages/runtime/src/App.tsx +++ b/packages/runtime/src/App.tsx @@ -26,8 +26,7 @@ import { globalHandlerMap } from './handler'; type ArrayElement = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; -type ApplicationComponents = RuntimeApplication['spec']['components']; -type ApplicationComponent = ApplicationComponents[0]; +type ApplicationComponent = RuntimeApplication['spec']['components'][0]; type ApplicationTrait = ArrayElement; export const ImplWrapper = React.forwardRef< diff --git a/packages/runtime/src/components/chakra-ui/List.tsx b/packages/runtime/src/components/chakra-ui/List.tsx index d175574d..2586610e 100644 --- a/packages/runtime/src/components/chakra-ui/List.tsx +++ b/packages/runtime/src/components/chakra-ui/List.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useRef } from 'react'; +import React, { useRef } from 'react'; import { Application, createComponent, @@ -6,11 +6,9 @@ import { } from '@meta-ui/core'; import { Static, Type } from '@sinclair/typebox'; import { List as BaseList, ListItem as BaseListItem } from '@chakra-ui/react'; -import Text, { TextProps, TextPropertySchema } from '../_internal/Text'; import { ComponentImplementation } from '../../registry'; import { ImplWrapper, resolveAppComponents } from '../../App'; import { mapValuesDeep, maskedEval } from '../../store'; -import { values } from 'lodash'; import { parseType } from '../../util-methods'; import { LIST_ITEM_EXP, LIST_ITEM_INDEX_EXP } from '../../constants'; @@ -34,7 +32,7 @@ const List: ComponentImplementation<{ listData: Static; template: Static; onClick?: () => void; -}> = ({ listData, template, mergeState, subscribeMethods, app }) => { +}> = ({ listData, template, app }) => { if (!listData) { return null; } @@ -42,24 +40,22 @@ const List: ComponentImplementation<{ const parsedtemplete = template.map(parseTypeComponents); const listItems = listData.map((listItem, i) => { + // this memo only diff listItem, dosen't compare expressions if (itemElementMemo.current.has(listItem.id)) { if (itemElementMemo.current.get(listItem.id).value === listItem) { return itemElementMemo.current.get(listItem.id).ele; } } - const evaledTemplate = mapValuesDeep( - { parsedtemplete }, - ({ value, key }) => { - if (typeof value === 'string') { - return maskedEval(value, true, { - [LIST_ITEM_EXP]: listItem, - [LIST_ITEM_INDEX_EXP]: i, - }); - } - return value; + const evaledTemplate = mapValuesDeep({ parsedtemplete }, ({ value }) => { + if (typeof value === 'string') { + return maskedEval(value, true, { + [LIST_ITEM_EXP]: listItem, + [LIST_ITEM_INDEX_EXP]: i, + }); } - ).parsedtemplete; + return value; + }).parsedtemplete; const { topLevelComponents, slotComponentsMap } = resolveAppComponents( evaledTemplate, diff --git a/packages/runtime/src/registry.tsx b/packages/runtime/src/registry.tsx index 6bd82fd3..e2a20981 100644 --- a/packages/runtime/src/registry.tsx +++ b/packages/runtime/src/registry.tsx @@ -61,6 +61,7 @@ export type ComponentMergedProps = { style?: CSSProperties; data?: Record; callbackMap?: CallbackMap; + app?: RuntimeApplication; }; export type ComponentImplementation = React.FC< diff --git a/packages/runtime/src/traits/core/arrayState.tsx b/packages/runtime/src/traits/core/arrayState.tsx index 847a0d58..a7ccca77 100644 --- a/packages/runtime/src/traits/core/arrayState.tsx +++ b/packages/runtime/src/traits/core/arrayState.tsx @@ -17,7 +17,6 @@ const ArrayStateTrait: TraitImplementation<{ if (!hasInitialized) { mergeState({ [key]: initialValue }); - const upperCaseKey = capitalizeFirstLetter(key); const methods = { setArray({ key, value }: KeyValue) { mergeState({ [key]: value }); @@ -51,10 +50,6 @@ const ArrayStateTrait: TraitImplementation<{ }; }; -function capitalizeFirstLetter(str: string) { - return str.charAt(0).toUpperCase() + str.slice(1); -} - const KeyPropertySchema = Type.String(); const InitialValuePropertySchema = Type.Array(Type.Any());