2022-01-31 20:02:59 +01:00
|
|
|
import { Helpers } from "@budibase/bbui"
|
2024-03-06 14:33:00 +01:00
|
|
|
import { processObjectSync } from "@budibase/string-templates"
|
|
|
|
import { snippets } from "../stores"
|
|
|
|
import { get } from "svelte/store"
|
2020-11-25 10:50:51 +01:00
|
|
|
|
|
|
|
/**
|
2021-01-21 11:42:14 +01:00
|
|
|
* Recursively enriches all props in a props object and returns the new props.
|
|
|
|
* Props are deeply cloned so that no mutation is done to the source object.
|
2020-11-25 10:50:51 +01:00
|
|
|
*/
|
2021-06-01 15:59:42 +02:00
|
|
|
export const enrichDataBindings = (props, context) => {
|
2024-03-06 14:33:00 +01:00
|
|
|
const totalContext = { ...context, snippets: get(snippets) }
|
|
|
|
const opts = { cache: true }
|
|
|
|
return processObjectSync(Helpers.cloneDeep(props), totalContext, opts)
|
2021-01-21 11:42:14 +01:00
|
|
|
}
|