epic-designer-cjh
Version:
基于vue3的设计器,可视化开发页面表单
74 lines (73 loc) • 2.6 kB
JavaScript
import { i as h } from "./interopRequireDefault-40f894e3.js";
import { r as j, h as b } from "./useConfigInject-bc9599af.js";
import { r as q } from "./_vue_commonjs-external-eb7fec7f.js";
var r = {}, c;
function M() {
if (c)
return r;
c = 1;
var f = h;
Object.defineProperty(r, "__esModule", {
value: !0
}), r.useProvideFormItemContext = r.useInjectFormItemContext = r.default = void 0;
var F = f(j()), e = q, I = f(b()), l = Symbol("ContextProps"), d = Symbol("InternalContextProps"), p = function(i) {
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (0, e.computed)(function() {
return !0;
}), t = (0, e.ref)(/* @__PURE__ */ new Map()), m = function(u, _) {
t.value.set(u, _), t.value = new Map(t.value);
}, y = function(u) {
t.value.delete(u), t.value = new Map(t.value);
}, g = (0, e.getCurrentInstance)();
(0, e.watch)([n, t], function() {
if (process.env.NODE_ENV !== "production" && n.value && t.value.size > 1) {
(0, I.default)(!1, "Form.Item", "FormItem can only collect one field item, you haved set ".concat((0, F.default)(t.value.values()).map(function(u) {
return "`".concat(u.name, "`");
}).join(", "), " ").concat(t.value.size, " field items.\n You can set not need to be collected fields into `a-form-item-rest`"));
for (var a = g; a.parent; )
console.warn("at", a.type), a = a.parent;
}
}), (0, e.provide)(l, i), (0, e.provide)(d, {
addFormItemField: m,
removeFormItemField: y
});
};
r.useProvideFormItemContext = p;
var v = {
id: (0, e.computed)(function() {
}),
onFieldBlur: function() {
},
onFieldChange: function() {
},
clearValidate: function() {
}
}, s = {
addFormItemField: function() {
},
removeFormItemField: function() {
}
}, C = function() {
var i = (0, e.inject)(d, s), n = Symbol("FormItemFieldKey"), t = (0, e.getCurrentInstance)();
return i.addFormItemField(n, t.type), (0, e.onBeforeUnmount)(function() {
i.removeFormItemField(n);
}), (0, e.provide)(d, s), (0, e.provide)(l, v), (0, e.inject)(l, v);
};
r.useInjectFormItemContext = C;
var x = (0, e.defineComponent)({
compatConfig: {
MODE: 3
},
name: "AFormItemRest",
setup: function(i, n) {
var t = n.slots;
return (0, e.provide)(d, s), (0, e.provide)(l, v), function() {
var m;
return (m = t.default) === null || m === void 0 ? void 0 : m.call(t);
};
}
});
return r.default = x, r;
}
export {
M as r
};