From 85233c2357cf4d42e4f95ac929441a127a6d64bf Mon Sep 17 00:00:00 2001 From: nikoloza Date: Wed, 27 Nov 2024 07:36:01 +0400 Subject: [PATCH] fix content and childProps --- packages/uikit/Atoms/Collection.js | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/uikit/Atoms/Collection.js b/packages/uikit/Atoms/Collection.js index eda65c30b..dec6e4eb4 100644 --- a/packages/uikit/Atoms/Collection.js +++ b/packages/uikit/Atoms/Collection.js @@ -1,46 +1,45 @@ 'use strict' import { isState, getChildStateInKey } from '@domql/state' -import { isString, isNot, isArray, isObject, isObjectLike, exec, deepClone, addAdditionalExtend } from '@domql/utils' +import { isString, isNumber, isNot, isArray, isObject, isObjectLike, exec, deepClone, addAdditionalExtend } from '@domql/utils' export const Collection = { define: { $collection: (param, el, state) => { const { __ref: ref } = el - const { children, childrenAs, childExtends } = (el.props || {}) - const childrenExec = children && exec(children, el, state) - - if (isArray(childrenExec)) { - param = deepClone(childrenExec) - if (childrenAs) param = param.map(v => ({ extend: childExtends, [childrenAs]: v })) - } else if (isObject(childrenExec)) { - if (childrenExec.$$typeof) return el.call('renderReact', childrenExec, el) - param = deepClone(childrenExec) - param = Object.keys(param).map(v => { - const val = param[v] - return addAdditionalExtend(v, val) - }) - el.removeContent() - el.content = { - extend: childExtends, - props: { - childProps: el.props && el.props.childProps + const { children: childrenProps, childrenAs, childExtends } = (el.props || {}) + const children = childrenProps && exec(childrenProps, el, state) + + if (children) { + if (isObject(children)) { + if (children.$$typeof) return el.call('renderReact', children, el) + param = deepClone(children) + param = Object.keys(param).map(v => { + const val = param[v] + return addAdditionalExtend(v, val) + }) + } else if (isArray(children)) { + param = deepClone(children) + if (childrenAs) { + param = param.map(v => ({ + extend: childExtends, + [childrenAs]: v + })) } + } else if (isString(children) || isNumber(children)) { + el.removeContent() + el.content = { text: param } + return } - return - } else if (childrenExec) { - el.removeContent() - el.content = { text: param } - return } if (!param) return + const filterReact = param.filter(v => !v.$$typeof) if (filterReact.length !== param.length) { const extractedReactComponents = param.filter(v => v.$$typeof) el.call('renderReact', extractedReactComponents, el) - } - param = filterReact + } param = filterReact if (isString(param)) { if (param === 'state') param = state.parse() @@ -67,6 +66,7 @@ export const Collection = { const obj = { tag: 'fragment', props: { + ignoreChildProps: true, childProps: el.props && el.props.childProps } }