Files
appco_dist/.output/server/chunks/build/FormItemContext-BlKvWASA.mjs
T
2026-01-27 16:02:45 +03:30

83 lines
2.6 KiB
JavaScript

import { computed, ref, getCurrentInstance, watch, provide, inject, defineComponent } from 'file:///mnt/new-volume-7/vue_projects/montify/montify/node_modules/vue/index.mjs';
import { N as createContext } from './server.mjs';
const ContextKey = /* @__PURE__ */ Symbol("ContextProps");
const InternalContextKey = /* @__PURE__ */ Symbol("InternalContextProps");
const useProvideFormItemContext = function(props) {
let useValidation = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : computed(() => true);
const formItemFields = ref(/* @__PURE__ */ new Map());
const addFormItemField = (key, type) => {
formItemFields.value.set(key, type);
formItemFields.value = new Map(formItemFields.value);
};
const removeFormItemField = (key) => {
formItemFields.value.delete(key);
formItemFields.value = new Map(formItemFields.value);
};
getCurrentInstance();
watch([useValidation, formItemFields], () => {
});
provide(ContextKey, props);
provide(InternalContextKey, {
addFormItemField,
removeFormItemField
});
};
const defaultContext = {
id: computed(() => void 0),
onFieldBlur: () => {
},
onFieldChange: () => {
},
clearValidate: () => {
}
};
const defaultInternalContext = {
addFormItemField: () => {
},
removeFormItemField: () => {
}
};
const useInjectFormItemContext = () => {
const internalContext = inject(InternalContextKey, defaultInternalContext);
const formItemFieldKey = /* @__PURE__ */ Symbol("FormItemFieldKey");
const instance = getCurrentInstance();
internalContext.addFormItemField(formItemFieldKey, instance.type);
provide(InternalContextKey, defaultInternalContext);
provide(ContextKey, defaultContext);
return inject(ContextKey, defaultContext);
};
const FormItemRest = defineComponent({
compatConfig: {
MODE: 3
},
name: "AFormItemRest",
setup(_, _ref) {
let {
slots
} = _ref;
provide(InternalContextKey, defaultInternalContext);
provide(ContextKey, defaultContext);
return () => {
var _a;
return (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots);
};
}
});
const FormItemInputContext = createContext({});
const NoFormStatus = defineComponent({
name: "NoFormStatus",
setup(_, _ref2) {
let {
slots
} = _ref2;
FormItemInputContext.useProvide({});
return () => {
var _a;
return (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots);
};
}
});
export { FormItemInputContext as F, NoFormStatus as N, FormItemRest as a, useProvideFormItemContext as b, useInjectFormItemContext as u };