77 v-model =" boundValue"
88 :data-component-id =" block.componentId"
99 :style =" styles"
10+ :class =" classes"
1011 v-on =" componentEvents"
1112 >
1213 <!-- Dynamically render named slots -->
2829
2930<script setup lang="ts">
3031import Block from " @/utils/block"
31- import { computed , onMounted , ref , useAttrs } from " vue"
32+ import { computed , onMounted , ref , useAttrs , inject } from " vue"
3233import { useRouter , useRoute } from " vue-router"
3334import { createResource } from " frappe-ui"
3435import { getComponentRoot , isDynamicValue , getDynamicValue , isHTML , executeUserScript } from " @/utils/helpers"
@@ -43,8 +44,21 @@ const props = defineProps<{
4344
4445const componentRef = ref (null )
4546const styles = computed (() => props .block .getStyles ())
47+ const classes = computed (() => {
48+ return [attrs .class , ... props .block .getClasses ()]
49+ })
4650
51+ const repeaterContext = inject (" repeaterContext" , {})
4752const store = useAppStore ()
53+
54+ const getEvaluationContext = () => {
55+ return {
56+ ... store .variables ,
57+ ... store .resources ,
58+ ... repeaterContext ,
59+ }
60+ }
61+
4862const getComponentProps = () => {
4963 if (! props .block || props .block .isRoot ()) return []
5064
@@ -53,7 +67,7 @@ const getComponentProps = () => {
5367
5468 Object .entries (propValues ).forEach (([propName , config ]) => {
5569 if (isDynamicValue (config )) {
56- propValues [propName ] = getDynamicValue (config , { ... store . resources , ... store . variables } )
70+ propValues [propName ] = getDynamicValue (config , getEvaluationContext () )
5771 }
5872 })
5973 return propValues
@@ -70,7 +84,7 @@ const componentProps = computed(() => {
7084// visibility
7185const showComponent = computed (() => {
7286 if (props .block .visibilityCondition ) {
73- const value = getDynamicValue (props .block .visibilityCondition , { ... store . resources , ... store . variables } )
87+ const value = getDynamicValue (props .block .visibilityCondition , getEvaluationContext () )
7488 return typeof value === " string" ? value === " true" : value
7589 }
7690 return true
@@ -91,7 +105,7 @@ const boundValue = computed({
91105 }
92106 return value
93107 } else if (isDynamicValue (modelValue )) {
94- return getDynamicValue (modelValue , { ... store . resources , ... store . variables } )
108+ return getDynamicValue (modelValue , getEvaluationContext () )
95109 }
96110 return modelValue
97111 },
@@ -190,7 +204,7 @@ const componentEvents = computed(() => {
190204 }
191205 } else if (event .action === " Run Script" ) {
192206 return () => {
193- executeUserScript (event .script , store .variables , store .resources )
207+ executeUserScript (event .script , store .variables , store .resources , repeaterContext )
194208 }
195209 }
196210 }
0 commit comments