import { isObject } from "@adpt/utils" ; import ld from "lodash" ; import { isElement } from "../jsx" ; export const publicElementFields = { props : null , componentType : null } ; export function deepFilterElemsToPublic ( o ) { if ( ! isObject ( o ) ) return o ; if ( ld . isArray ( o ) ) { return o . map ( ( item ) => deepFilterElemsToPublic ( item ) ) ; } if ( isElement ( o ) ) { const filtered = ld . pickBy ( o , ( value , key ) => { return key in publicElementFields ; } ) ; if ( filtered . props != null ) { const { handle , ... fProps } = filtered . props ; ( filtered as any ) . props = deepFilterElemsToPublic ( fProps ) ; } return filtered ; } const ret = { } ; for ( const key in o ) { ret [ key ] = deepFilterElemsToPublic ( o [ key ] ) ; } return ret ; }