<commit_before>import { getObjectPropsIdSchema, getWidget } from '../../utils'
import SchemaProp from '../props/schema-prop.js'

export default {
  props: {
    name: String,
    schema: Object,
    uiSchema: Object,
    errorSchema: [Object, Boolean],
    idSchema: Object,
    value: Object,
    registry: Object,
    uiOptions: Object,
  },

  computed: {
    props () {
      const idSchema = getObjectPropsIdSchema(this.schema, this.idSchema)
      return Object.keys(this.schema.properties).map(propName => {
        const propValue = (this.value || {})[propName]
        const propSchema = this.schema.properties[propName]
        const propUiSchema = this.uiSchema && this.uiSchema[propName] ? this.uiSchema[propName] : {}
        const propErrorSchema = this.errorSchema ? this.errorSchema[propName] : {}
        const propIdSchema = idSchema[propName]
        const propHandlers = this.uiOptions && this.uiOptions.handlers ? this.uiOptions.handlers[propName] : undefined
        return {
          name: propName,
          value: propValue,
          schema: propSchema,
          uiSchema: propUiSchema,
          errorSchema: propErrorSchema,
          idSchema: propIdSchema,
          handlers: propHandlers,
        }
      })
    }
  },

  methods: {
    isRequired (name) {
      return (
        Array.isArray(this.schema.required) && this.schema.required.indexOf(name) !== -1
      )
    },
    hasGroups (stepNumber) {
      if (stepNumber) {
        return this.uiOptions && this.uiOptions['ui:groups'] && this.uiOptions['ui:groups'][`step:${stepNumber}`]
      } else {
        return this.uiOptions && this.uiOptions['ui:groups']
      }
    },
    getGroupsProp (stepNumber) {
      const steps = this.uiOptions['ui:groups']
      if (stepNumber) {
        return steps[`step:${stepNumber}`]
      } else {
        return steps
      }
    },
    getGroups (props, stepNumber) {
      const groups = this.getGroupsProp(stepNumber)
      return Object.keys(groups).map(group => {
        if (group.includes('ui:others')) {
          return {...groups[group], props}
        } else {
          return {...groups[group], props: this.getProps(props, groups[group].props)}
        }
      })
    },
    renderProps (h, props) {
      return props.map(prop => {
        return h(SchemaProp, {
          props: {
            name: prop.name,
            schema: prop.schema,
            uiSchema: prop.uiSchema,
            errorSchema: prop.errorSchema,
            idSchema: prop.idSchema,
            required: this.isRequired(prop.name),
            value: prop.value,
            registry: this.registry,
          },
          on: {
            input: propVal => {
              this.$emit('input', Object.assign({}, this.value, {[prop.name]: propVal}))
            },
            blur: propVal => {
              this.$emit('blur', Object.assign({}, this.value, {[prop.name]: propVal}))
            },
            'parent-value': val => {
              this.$emit('input', val)
            },
          }
        })
      })
    },
    renderGroups (h, page, stepNumber) {
      if (this.hasGroups(stepNumber)) {
        return this.getGroups(page, stepNumber).map(group => {
          return h(getWidget(this.schema,
            group.widget || 'wrapper',
            this.registry.widgets), {
              props: {
                ...group['ui:options'],
              },
            }, this.renderProps.bind(this)(h, group.props))
        })
      } else {
        return this.renderProps.bind(this)(h, page)
      }
    }
  },
}
<commit_msg>refactor: change ui:groups to array type<commit_after>import { getObjectPropsIdSchema, getWidget } from '../../utils'
import SchemaProp from '../props/schema-prop.js'
import findIndex from 'lodash-es/findIndex'

export default {
  props: {
    name: String,
    schema: Object,
    uiSchema: Object,
    errorSchema: [Object, Boolean],
    idSchema: Object,
    value: Object,
    registry: Object,
    uiOptions: Object,
  },

  computed: {
    props () {
      const idSchema = getObjectPropsIdSchema(this.schema, this.idSchema)
      return Object.keys(this.schema.properties).map(propName => {
        const propValue = (this.value || {})[propName]
        const propSchema = this.schema.properties[propName]
        const propUiSchema = this.uiSchema && this.uiSchema[propName] ? this.uiSchema[propName] : {}
        const propErrorSchema = this.errorSchema ? this.errorSchema[propName] : {}
        const propIdSchema = idSchema[propName]
        const propHandlers = this.uiOptions && this.uiOptions.handlers ? this.uiOptions.handlers[propName] : undefined
        return {
          name: propName,
          value: propValue,
          schema: propSchema,
          uiSchema: propUiSchema,
          errorSchema: propErrorSchema,
          idSchema: propIdSchema,
          handlers: propHandlers,
        }
      })
    }
  },

  methods: {
    isRequired (name) {
      return (
        Array.isArray(this.schema.required) && this.schema.required.indexOf(name) !== -1
      )
    },
    hasGroups (stepNumber) {
      if (stepNumber) {
        return this.uiOptions &&
          this.uiOptions['ui:groups'] &&
          findIndex(this.uiOptions['ui:groups'], {step: stepNumber})
      } else {
        return this.uiOptions && this.uiOptions['ui:groups']
      }
    },
    getGroupsProp (stepNumber) {
      const steps = this.uiOptions['ui:groups']
      if (stepNumber) {
        return steps[findIndex(steps, {step: stepNumber})].groups
      } else {
        return steps
      }
    },
    getGroups (props, stepNumber) {
      const groups = this.getGroupsProp(stepNumber)
      return groups.map(group => {
        if (group.includes('ui:others')) {
          return {...group, props}
        } else {
          return {...group, props: this.getProps(props, group.props)}
        }
      })
    },
    renderProps (h, props) {
      return props.map(prop => {
        return h(SchemaProp, {
          props: {
            name: prop.name,
            schema: prop.schema,
            uiSchema: prop.uiSchema,
            errorSchema: prop.errorSchema,
            idSchema: prop.idSchema,
            required: this.isRequired(prop.name),
            value: prop.value,
            registry: this.registry,
          },
          on: {
            input: propVal => {
              this.$emit('input', Object.assign({}, this.value, {[prop.name]: propVal}))
            },
            blur: propVal => {
              this.$emit('blur', Object.assign({}, this.value, {[prop.name]: propVal}))
            },
            'parent-value': val => {
              this.$emit('input', val)
            },
          }
        })
      })
    },
    renderGroups (h, page, stepNumber) {
      if (this.hasGroups(stepNumber)) {
        return this.getGroups(page, stepNumber).map(group => {
          return h(getWidget(this.schema,
            group.widget || 'wrapper',
            this.registry.widgets), {
              props: {
                ...group['ui:options'],
              },
            }, this.renderProps.bind(this)(h, group.props))
        })
      } else {
        return this.renderProps.bind(this)(h, page)
      }
    }
  },
}

{'fraction_non_alphanumeric': 0.13503043718871058, 'fraction_numerical': 0.0002767017155506364, 'mean_word_length': 1.9530228758169934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5510164', 'n_tokens_mistral': 2073, 'n_tokens_neox': 2072, 'n_words': 397}