<script lang="ts">
import hwInputView from './viewElements/hw-input-view.vue';
import hwInputNumberView from './viewElements/hw-input-number-view.vue';
import hwFormView from './viewElements/hw-form-view.vue';
import hwTableView from './viewElements/hw-table-view.vue';
import hwChartView from './viewElements/hw-chart-view.vue';
import hwSliderView from './viewElements/hw-slider-view.vue';
import hwRadioGroupView from './viewElements/hw-radio-group-view.vue';

export default {
  name: 'hw-form',
  components: {
    hwInputView,
    hwInputNumberView,
    hwFormView,
    hwTableView,
    hwChartView,
    hwSliderView,
    hwRadioGroupView
  }
};
</script>

<template>
  <div class="hw-form">
    <div v-for="i in widgetList" :key="i.uuid">
      <component :is="i.type+'-view'" :options="i.options" :tasks="i.tasks" :formData="formData" />
    </div>
  </div>

</template>

<script lang="ts" setup>

const props = defineProps({
  widgetList: Object
});

const { widgetList } = toRefs(props);

const formData = ref({});
provide('globalFormData', formData);
const formDataOperation = {
  get: (key) => {
    return formData.value[key];
  },
  set: (key, value) => {
    formData.value[key] = value;
  }
};
provide('formDataOperation', formDataOperation);
</script>
<style scoped lang="less">
.hw-form {
  min-height: 20px;
  border: 1px dashed #ccc;
  margin: 2px;
  padding: 2px;
  position: relative;

  &:hover {
    background-color: #0001;
    border-color: #00afff;
  }
}
</style>



