( item: any, mappers: Mappers, config: Config, recurseSlots: boolean = false, shouldDefaultSlots: boolean = true )
| 206 | ): Promise<T>; |
| 207 | |
| 208 | export function mapFields( |
| 209 | item: any, |
| 210 | mappers: Mappers, |
| 211 | config: Config, |
| 212 | recurseSlots: boolean = false, |
| 213 | shouldDefaultSlots: boolean = true |
| 214 | ): any { |
| 215 | const itemType = "type" in item ? item.type : "root"; |
| 216 | |
| 217 | const componentConfig = |
| 218 | itemType === "root" ? config.root : config.components?.[itemType]; |
| 219 | |
| 220 | const newProps = walkObject({ |
| 221 | value: shouldDefaultSlots |
| 222 | ? defaultSlots(item.props ?? {}, componentConfig?.fields ?? {}) |
| 223 | : item.props, |
| 224 | fields: componentConfig?.fields ?? {}, |
| 225 | mappers, |
| 226 | id: item.props ? item.props.id ?? "root" : "root", |
| 227 | getPropPath: (k) => k, |
| 228 | config, |
| 229 | recurseSlots, |
| 230 | }); |
| 231 | |
| 232 | if (isPromise(newProps)) { |
| 233 | return newProps.then((resolvedProps) => ({ |
| 234 | ...item, |
| 235 | props: resolvedProps, |
| 236 | })); |
| 237 | } |
| 238 | |
| 239 | return { |
| 240 | ...item, |
| 241 | props: newProps, |
| 242 | }; |
| 243 | } |
no test coverage detected