@empathyco/x-components
Version:
Empathy X Components
51 lines (48 loc) • 1.5 kB
JavaScript
import { forEach } from '@empathyco/x-utils';
import { defineComponent, inject, ref, watch } from 'vue';
import { extraParamsXModule } from '../x-module.js';
import _sfc_main$1 from './extra-params.vue.js';
var _sfc_main = defineComponent({
name: 'SnippetConfigExtraParams',
xModule: extraParamsXModule.name,
components: {
ExtraParams: _sfc_main$1,
},
props: {
values: {
type: Object,
},
excludedExtraParams: {
type: Array,
default: () => [
'callbacks',
'productId',
'uiLang',
'consent',
'documentDirection',
'filters',
'isSpa',
'queriesPreview',
],
},
},
setup(props) {
const snippetConfig = inject('snippetConfig');
const extraParams = ref({});
watch([() => snippetConfig, () => props.values], () => {
forEach({ ...props.values, ...snippetConfig }, (name, value) => {
if (!props.excludedExtraParams.includes(name) && extraParams.value[name] !== value) {
extraParams.value = { ...extraParams.value, [name]: value };
}
});
}, {
deep: true,
immediate: true,
});
return {
extraParams,
};
},
});
export { _sfc_main as default };
//# sourceMappingURL=snippet-config-extra-params.vue2.js.map