<commit_before>import * as avalon from 'avalon2';
import { findParentComponent } from '../../vendor/avx-component/avx-util';

/**
 * 表单项组件
 * @prop label 表单项标签
 * 
 * @example
 * ``` html
 * <ms-form-item :widget="{label: '标题'}">
        <ms-input :widget="{value: @title, col: 'title'}"></ms-input>
    </ms-form-item>
 * ```
 */
avalon.component('ms-form-item', {
    template: __inline('./ms-form-item.html'),
    defaults: {
        $formVm: null,
        label: '',
        control: '',
        inline: false,
        dirty: false,
        reasons: [],
        hasRules: false,
        className: '',
        inlineFormGroupStyle: { verticalAlign: 'top' },
        inlineMessageStyle: { marginBottom: 0 },
        onFieldChange(descriptor) {
            this.$formVm.type !== 'search' && this.$formVm.$form.setFieldsValue({
                [descriptor.name]: { value: descriptor.value, denyValidate: descriptor.denyValidate }
            });
            if (!descriptor.rules) return ;
            this.hasRules = true;
            this.$formVm.$form.addFields({
                [descriptor.name]: { rules: descriptor.rules }
            });
            this.$formVm.$form.on('error' + descriptor.name, (reasons) => {
                this.dirty = true;
                this.reasons = reasons;
            });
            this.$formVm.$form.on('reset', fields => {
                if (~Object.keys(fields).indexOf(descriptor.name)) {
                    this.dirty = false;
                    this.reasons = [];
                }
            });
        },
        onFormChange(meta) {
            this.dirty = true;
            this.$formVm.onFormChange(meta);
        },
        onInit(event) {
            event.target._ctype_ = 'ms-form-item';
            event.target._vm_ = this;
            this.$formVm = findParentComponent(this, 'ms-form');
            if (this.$formVm === null) {
                throw 'ms-form-item 必须放在 ms-form 内';
            }
            this.inline = this.$formVm.inline;
        },
        onReady(event) {
        }
    },
    soleSlot: 'control'
});<commit_msg>解决表单验证在搜索场景下的样式问题<commit_after>import * as avalon from 'avalon2';
import { findParentComponent } from '../../vendor/avx-component/avx-util';

/**
 * 表单项组件
 * @prop label 表单项标签
 * 
 * @example
 * ``` html
 * <ms-form-item :widget="{label: '标题'}">
        <ms-input :widget="{value: @title, col: 'title'}"></ms-input>
    </ms-form-item>
 * ```
 */
avalon.component('ms-form-item', {
    template: __inline('./ms-form-item.html'),
    defaults: {
        $formVm: null,
        label: '',
        control: '',
        inline: false,
        dirty: false,
        reasons: [],
        hasRules: false,
        className: '',
        inlineFormGroupStyle: { verticalAlign: 'top' },
        inlineMessageStyle: { marginBottom: 0 },
        onFieldChange(descriptor) {
            this.$formVm.type !== 'search' && this.$formVm.$form.setFieldsValue({
                [descriptor.name]: { value: descriptor.value, denyValidate: descriptor.denyValidate }
            });
            if (!descriptor.rules) return ;
            this.hasRules = true;
            this.$formVm.$form.addFields({
                [descriptor.name]: { rules: descriptor.rules }
            });
            this.$formVm.$form.on('error' + descriptor.name, (reasons) => {
                this.dirty = true;
                this.reasons = reasons;
            });
            this.$formVm.$form.on('reset', fields => {
                if (~Object.keys(fields).indexOf(descriptor.name)) {
                    this.dirty = false;
                    this.reasons = [];
                }
            });
        },
        onFormChange(meta) {
            if (this.$formVm.$form.autoAsyncChange) {
                this.dirty = true;
            }
            this.$formVm.onFormChange(meta);
        },
        onInit(event) {
            event.target._ctype_ = 'ms-form-item';
            event.target._vm_ = this;
            this.$formVm = findParentComponent(this, 'ms-form');
            if (this.$formVm === null) {
                throw 'ms-form-item 必须放在 ms-form 内';
            }
            this.inline = this.$formVm.inline;
        },
        onReady(event) {
        }
    },
    soleSlot: 'control'
});
{'fraction_non_alphanumeric': 0.1576366184026156, 'fraction_numerical': 0.0009341429238673517, 'mean_word_length': 1.6405672009864365, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '1345661', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1299, 'n_words': 208}