"use strict";
const common_vendor = require("../../common/vendor.js");
const composables_useFormValidation = require("../../composables/useFormValidation.js");
const _sfc_main = {
  __name: "index",
  props: {
    // 表单数据 - 支持v-model
    modelValue: {
      type: Object,
      default: () => ({})
    },
    // 校验规则配置
    rules: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const formData = common_vendor.computed({
      get: () => props.modelValue,
      set: (value) => emit("update:modelValue", value)
    });
    const { validateField, validateForm, errors, clearErrors, getFieldConfig, setFieldConfigs } = composables_useFormValidation.useFormValidation(props.rules);
    common_vendor.watch(() => props.rules, (newRules) => {
      setFieldConfigs(newRules);
    }, { deep: true, immediate: true });
    common_vendor.computed(() => {
      return Object.keys(errors.value).some(
        (key) => errors.value[key] && errors.value[key].length > 0
      );
    });
    common_vendor.provide("validateField", validateField);
    common_vendor.provide("errors", errors);
    common_vendor.provide("clearErrors", clearErrors);
    common_vendor.provide("formData", formData);
    common_vendor.provide("getFieldConfig", getFieldConfig);
    common_vendor.provide("validateForm", validateForm);
    __expose({
      validateForm,
      validateField,
      errors,
      clearErrors
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.gei(_ctx, "")
      };
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-354b68fa"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/Form/index.js.map
