<commit_before>
<template>
  <form novalidate>
    <div class="row" v-for="(formRow, rowIdx) of formRows" :key="rowIdx">
      <template v-for="(field, fieldIdx) of formRow" :key="rowIdx + '_' + fieldIdx">
        <div class="field">
          <os-label>{{field.label}}</os-label>
          <component :ref="'osField-' + field.name" :is="field.component" v-bind="field"
            v-model="formModel[field.name]" v-os-tooltip.bottom="field.tooltip"
            :form="ctx" @update:model-value="handleInput(field)">
          </component>
          <div v-if="v$.formModel[field.name] && v$.formModel[field.name].$error">
            <os-inline-message>{{errorMessages[field.name]}}</os-inline-message>
          </div>
        </div>
      </template>
    </div>

    <os-divider></os-divider>

    <div class="row">
      <div class="field">
        <slot></slot>
      </div>
    </div>
  </form>
</template>

<script>

import { reactive } from 'vue';
import useVuelidate from '@vuelidate/core'

import alertSvc from '@/common/services/Alerts.js';
import fieldFactory from '@/common/services/FieldFactory.js';
import exprUtil from '@/common/services/ExpressionUtil.js';

export default {
   props: ['schema', 'data'],

   emits: ['input', 'form-validity'],

   setup(props) {
     let ctx = reactive({
       formData: props.data || {},
       fd: function(name) {
         let object = ctx.formData;
         if (!name) {
           return object;
         }

         let props = name.split('.');
         for (let i = 0; i < props.length; ++i) {
           if (!object) {
             return undefined;
           }
           object = object[props[i]];
         }

         return object;
       }
     });

     return {
       ctx,
       v$: useVuelidate(),
     };
   },

   methods: {
     handleInput: function(field) {
       exprUtil.setValue(this.ctx.formData, field.name, this.formModel[field.name]);
       this.$emit('input', {field: field, data: this.ctx.formData})
       if (this.v$.formModel[field.name]) {
         this.v$.formModel[field.name].$touch();
       }

       this.$emit('form-validity', {invalid: this.v$.$invalid});
     },

     validate: function() {
       this.v$.$touch();

       let invalid = this.v$.$invalid;
       for (let formRow of this.formRows) {
         for (let field of formRow) {<commit_msg>Form widget: Updated the widget to emit an input event with the following data items - field for which the input was done, the actual input value, and the entire form data.<commit_after>
<template>
  <form novalidate>
    <div class="row" v-for="(formRow, rowIdx) of formRows" :key="rowIdx">
      <template v-for="(field, fieldIdx) of formRow" :key="rowIdx + '_' + fieldIdx">
        <div class="field">
          <os-label>{{field.label}}</os-label>
          <component :ref="'osField-' + field.name" :is="field.component" v-bind="field"
            v-model="formModel[field.name]" v-os-tooltip.bottom="field.tooltip"
            :form="ctx" @update:model-value="handleInput(field)">
          </component>
          <div v-if="v$.formModel[field.name] && v$.formModel[field.name].$error">
            <os-inline-message>{{errorMessages[field.name]}}</os-inline-message>
          </div>
        </div>
      </template>
    </div>

    <os-divider></os-divider>

    <div class="row">
      <div class="field">
        <slot></slot>
      </div>
    </div>
  </form>
</template>

<script>

import { reactive } from 'vue';
import useVuelidate from '@vuelidate/core'

import alertSvc from '@/common/services/Alerts.js';
import fieldFactory from '@/common/services/FieldFactory.js';
import exprUtil from '@/common/services/ExpressionUtil.js';

export default {
   props: ['schema', 'data'],

   emits: ['input', 'form-validity'],

   setup(props) {
     let ctx = reactive({
       formData: props.data || {},
       fd: function(name) {
         let object = ctx.formData;
         if (!name) {
           return object;
         }

         let props = name.split('.');
         for (let i = 0; i < props.length; ++i) {
           if (!object) {
             return undefined;
           }
           object = object[props[i]];
         }

         return object;
       }
     });

     return {
       ctx,
       v$: useVuelidate(),
     };
   },

   methods: {
     handleInput: function(field) {
       exprUtil.setValue(this.ctx.formData, field.name, this.formModel[field.name]);
       this.$emit('input', {field: field, value: this.formModel[field.name], data: this.ctx.formData})
       if (this.v$.formModel[field.name]) {
         this.v$.formModel[field.name].$touch();
       }

       this.$emit('form-validity', {invalid: this.v$.$invalid});
     },

     validate: function() {
       this.v$.$touch();

       let invalid = this.v$.$invalid;
       for (let formRow of this.formRows) {
         for (let field of formRow) {
{'fraction_non_alphanumeric': 0.1706868356500409, 'fraction_numerical': 0.0004088307440719542, 'mean_word_length': 2.297169811320755, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5088508', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1533, 'n_words': 328}