@epic-designer/antd 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/chunks/button.cjs +44 -0
- package/dist/chunks/button.mjs +42 -0
- package/dist/chunks/card.cjs +39 -0
- package/dist/chunks/card.mjs +37 -0
- package/dist/chunks/col.cjs +39 -0
- package/dist/chunks/col.mjs +37 -0
- package/dist/chunks/datePicker.cjs +47 -0
- package/dist/chunks/datePicker.mjs +45 -0
- package/dist/chunks/form.cjs +116 -0
- package/dist/chunks/form.mjs +114 -0
- package/dist/chunks/formItem.cjs +24 -0
- package/dist/chunks/formItem.mjs +22 -0
- package/dist/chunks/modal.cjs +136 -0
- package/dist/chunks/modal.mjs +134 -0
- package/dist/chunks/row.cjs +39 -0
- package/dist/chunks/row.mjs +37 -0
- package/dist/chunks/uploadFile.cjs +138 -0
- package/dist/chunks/uploadFile.mjs +136 -0
- package/dist/chunks/uploadImage.cjs +152 -0
- package/dist/chunks/uploadImage.mjs +150 -0
- package/dist/index.cjs +3047 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3045 -0
- package/package.json +38 -0
- package/src/button/button.vue +19 -0
- package/src/button/index.ts +204 -0
- package/src/card/card.ts +38 -0
- package/src/card/index.ts +65 -0
- package/src/cascader/cascader.vue +24 -0
- package/src/cascader/index.ts +201 -0
- package/src/checkbox/index.ts +101 -0
- package/src/col/col.ts +38 -0
- package/src/col/index.ts +22 -0
- package/src/color-picker/index.ts +109 -0
- package/src/date-picker/datePicker.ts +48 -0
- package/src/date-picker/index.ts +301 -0
- package/src/form/form.vue +153 -0
- package/src/form/index.ts +196 -0
- package/src/form-item/formItem.vue +12 -0
- package/src/form-item/index.ts +10 -0
- package/src/index.less +33 -0
- package/src/index.ts +131 -0
- package/src/input/index.ts +171 -0
- package/src/input-number/index.ts +182 -0
- package/src/input-password/index.ts +154 -0
- package/src/modal/index.ts +20 -0
- package/src/modal/modal.vue +98 -0
- package/src/radio/index.ts +107 -0
- package/src/row/index.ts +116 -0
- package/src/row/row.ts +38 -0
- package/src/select/index.ts +231 -0
- package/src/slider/index.ts +145 -0
- package/src/switch/index.ts +143 -0
- package/src/textarea/index.ts +164 -0
- package/src/time-picker/index.ts +192 -0
- package/src/upload-file/index.ts +90 -0
- package/src/upload-file/uploadFile.vue +145 -0
- package/src/upload-image/index.ts +71 -0
- package/src/upload-image/uploadImage.vue +167 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 kchengz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
7
|
+
__name: "button",
|
|
8
|
+
props: {
|
|
9
|
+
componentSchema: {
|
|
10
|
+
default: () => ({}),
|
|
11
|
+
type: Object
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
return (_ctx, _cache) => {
|
|
17
|
+
var _a;
|
|
18
|
+
return vue.openBlock(), vue.createBlock(
|
|
19
|
+
vue.unref(antDesignVue.Button),
|
|
20
|
+
vue.normalizeProps(vue.guardReactiveProps((_a = props.componentSchema) == null ? void 0 : _a.componentProps)),
|
|
21
|
+
{
|
|
22
|
+
default: vue.withCtx(() => [
|
|
23
|
+
vue.renderSlot(_ctx.$slots, "default", {}, () => {
|
|
24
|
+
var _a2;
|
|
25
|
+
return [
|
|
26
|
+
vue.createTextVNode(
|
|
27
|
+
vue.toDisplayString((_a2 = props.componentSchema) == null ? void 0 : _a2.label),
|
|
28
|
+
1
|
|
29
|
+
/* TEXT */
|
|
30
|
+
)
|
|
31
|
+
];
|
|
32
|
+
})
|
|
33
|
+
]),
|
|
34
|
+
_: 3
|
|
35
|
+
/* FORWARDED */
|
|
36
|
+
},
|
|
37
|
+
16
|
|
38
|
+
/* FULL_PROPS */
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineComponent, createBlock, openBlock, unref, normalizeProps, guardReactiveProps, withCtx, renderSlot, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
import { Button } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
__name: "button",
|
|
6
|
+
props: {
|
|
7
|
+
componentSchema: {
|
|
8
|
+
default: () => ({}),
|
|
9
|
+
type: Object
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(__props) {
|
|
13
|
+
const props = __props;
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return openBlock(), createBlock(
|
|
17
|
+
unref(Button),
|
|
18
|
+
normalizeProps(guardReactiveProps((_a = props.componentSchema) == null ? void 0 : _a.componentProps)),
|
|
19
|
+
{
|
|
20
|
+
default: withCtx(() => [
|
|
21
|
+
renderSlot(_ctx.$slots, "default", {}, () => {
|
|
22
|
+
var _a2;
|
|
23
|
+
return [
|
|
24
|
+
createTextVNode(
|
|
25
|
+
toDisplayString((_a2 = props.componentSchema) == null ? void 0 : _a2.label),
|
|
26
|
+
1
|
|
27
|
+
/* TEXT */
|
|
28
|
+
)
|
|
29
|
+
];
|
|
30
|
+
})
|
|
31
|
+
]),
|
|
32
|
+
_: 3
|
|
33
|
+
/* FORWARDED */
|
|
34
|
+
},
|
|
35
|
+
16
|
|
36
|
+
/* FULL_PROPS */
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const card = vue.defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
componentSchema: {
|
|
9
|
+
default: () => ({}),
|
|
10
|
+
require: true,
|
|
11
|
+
type: Object
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setup(props, { slots }) {
|
|
15
|
+
return () => {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const componentSchema = {
|
|
18
|
+
...props.componentSchema,
|
|
19
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
20
|
+
};
|
|
21
|
+
const children = (_c = componentSchema.children) != null ? _c : [];
|
|
22
|
+
delete componentSchema.children;
|
|
23
|
+
return vue.h(antDesignVue.Card, componentSchema, {
|
|
24
|
+
default: () => vue.renderSlot(
|
|
25
|
+
slots,
|
|
26
|
+
"edit-node",
|
|
27
|
+
{},
|
|
28
|
+
() => children.map(
|
|
29
|
+
(subcomponentSchema) => vue.renderSlot(slots, "node", {
|
|
30
|
+
componentSchema: subcomponentSchema
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.default = card;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent, h, renderSlot } from 'vue';
|
|
2
|
+
import { Card } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const card = defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
componentSchema: {
|
|
7
|
+
default: () => ({}),
|
|
8
|
+
require: true,
|
|
9
|
+
type: Object
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
return () => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const componentSchema = {
|
|
16
|
+
...props.componentSchema,
|
|
17
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
18
|
+
};
|
|
19
|
+
const children = (_c = componentSchema.children) != null ? _c : [];
|
|
20
|
+
delete componentSchema.children;
|
|
21
|
+
return h(Card, componentSchema, {
|
|
22
|
+
default: () => renderSlot(
|
|
23
|
+
slots,
|
|
24
|
+
"edit-node",
|
|
25
|
+
{},
|
|
26
|
+
() => children.map(
|
|
27
|
+
(subcomponentSchema) => renderSlot(slots, "node", {
|
|
28
|
+
componentSchema: subcomponentSchema
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { card as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const col = vue.defineComponent({
|
|
7
|
+
props: {
|
|
8
|
+
componentSchema: {
|
|
9
|
+
default: () => ({}),
|
|
10
|
+
require: true,
|
|
11
|
+
type: Object
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
setup(props, { slots }) {
|
|
15
|
+
return () => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const componentSchema = {
|
|
18
|
+
...props.componentSchema,
|
|
19
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
20
|
+
};
|
|
21
|
+
const children = componentSchema.children;
|
|
22
|
+
delete componentSchema.children;
|
|
23
|
+
return vue.h(antDesignVue.Col, componentSchema, {
|
|
24
|
+
default: () => vue.renderSlot(
|
|
25
|
+
slots,
|
|
26
|
+
"edit-node",
|
|
27
|
+
{},
|
|
28
|
+
() => children.map(
|
|
29
|
+
(subcomponentSchema) => vue.renderSlot(slots, "node", {
|
|
30
|
+
componentSchema: subcomponentSchema
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.default = col;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent, h, renderSlot } from 'vue';
|
|
2
|
+
import { Col } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const col = defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
componentSchema: {
|
|
7
|
+
default: () => ({}),
|
|
8
|
+
require: true,
|
|
9
|
+
type: Object
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
return () => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const componentSchema = {
|
|
16
|
+
...props.componentSchema,
|
|
17
|
+
title: (_b = (_a = props.componentSchema) == null ? void 0 : _a.label) != null ? _b : ""
|
|
18
|
+
};
|
|
19
|
+
const children = componentSchema.children;
|
|
20
|
+
delete componentSchema.children;
|
|
21
|
+
return h(Col, componentSchema, {
|
|
22
|
+
default: () => renderSlot(
|
|
23
|
+
slots,
|
|
24
|
+
"edit-node",
|
|
25
|
+
{},
|
|
26
|
+
() => children.map(
|
|
27
|
+
(subcomponentSchema) => renderSlot(slots, "node", {
|
|
28
|
+
componentSchema: subcomponentSchema
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { col as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const datePicker = vue.defineComponent({
|
|
7
|
+
emits: ["update:modelValue", "change", "blur"],
|
|
8
|
+
name: "EDatePicker",
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: {
|
|
11
|
+
default: null,
|
|
12
|
+
type: [String, Object, Array]
|
|
13
|
+
},
|
|
14
|
+
type: {
|
|
15
|
+
default: "date",
|
|
16
|
+
type: String
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
setup(props, { emit }) {
|
|
20
|
+
vue.watch(
|
|
21
|
+
() => props.type,
|
|
22
|
+
() => {
|
|
23
|
+
handleUpdate();
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
function handleUpdate(e = null) {
|
|
27
|
+
emit("update:modelValue", e);
|
|
28
|
+
emit("change", e);
|
|
29
|
+
emit("blur", e);
|
|
30
|
+
}
|
|
31
|
+
return () => {
|
|
32
|
+
let cmp = antDesignVue.DatePicker;
|
|
33
|
+
const compProps = {
|
|
34
|
+
"onUpdate:value": handleUpdate,
|
|
35
|
+
picker: props.type.replace(/range$/, ""),
|
|
36
|
+
showTime: props.type.includes("time"),
|
|
37
|
+
value: props.modelValue
|
|
38
|
+
};
|
|
39
|
+
if (props.type.includes("range")) {
|
|
40
|
+
cmp = antDesignVue.DatePicker.RangePicker;
|
|
41
|
+
}
|
|
42
|
+
return vue.h(cmp, compProps);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.default = datePicker;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineComponent, watch, h } from 'vue';
|
|
2
|
+
import { DatePicker } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const datePicker = defineComponent({
|
|
5
|
+
emits: ["update:modelValue", "change", "blur"],
|
|
6
|
+
name: "EDatePicker",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {
|
|
9
|
+
default: null,
|
|
10
|
+
type: [String, Object, Array]
|
|
11
|
+
},
|
|
12
|
+
type: {
|
|
13
|
+
default: "date",
|
|
14
|
+
type: String
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(props, { emit }) {
|
|
18
|
+
watch(
|
|
19
|
+
() => props.type,
|
|
20
|
+
() => {
|
|
21
|
+
handleUpdate();
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
function handleUpdate(e = null) {
|
|
25
|
+
emit("update:modelValue", e);
|
|
26
|
+
emit("change", e);
|
|
27
|
+
emit("blur", e);
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
let cmp = DatePicker;
|
|
31
|
+
const compProps = {
|
|
32
|
+
"onUpdate:value": handleUpdate,
|
|
33
|
+
picker: props.type.replace(/range$/, ""),
|
|
34
|
+
showTime: props.type.includes("time"),
|
|
35
|
+
value: props.modelValue
|
|
36
|
+
};
|
|
37
|
+
if (props.type.includes("range")) {
|
|
38
|
+
cmp = DatePicker.RangePicker;
|
|
39
|
+
}
|
|
40
|
+
return h(cmp, compProps);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { datePicker as default };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
7
|
+
...{
|
|
8
|
+
inheritAttrs: false
|
|
9
|
+
},
|
|
10
|
+
__name: "form",
|
|
11
|
+
props: {
|
|
12
|
+
componentSchema: { type: Object, required: true, default: () => ({ type: "" }) },
|
|
13
|
+
scrollToFirstError: { type: Boolean, required: false, default: false }
|
|
14
|
+
},
|
|
15
|
+
setup(__props, { expose: __expose }) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const props = __props;
|
|
18
|
+
const designerProps = vue.inject("designerProps");
|
|
19
|
+
const pageManager = vue.inject("pageManager", {});
|
|
20
|
+
const form = vue.ref(null);
|
|
21
|
+
const forms = vue.inject("forms", {});
|
|
22
|
+
const formData = pageManager.setFormData(
|
|
23
|
+
{},
|
|
24
|
+
(_b = (_a = props.componentSchema) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.name
|
|
25
|
+
);
|
|
26
|
+
vue.provide("formData", formData);
|
|
27
|
+
function getData() {
|
|
28
|
+
return formData;
|
|
29
|
+
}
|
|
30
|
+
async function validate() {
|
|
31
|
+
var _a2, _b2;
|
|
32
|
+
try {
|
|
33
|
+
return await ((_a2 = form.value) == null ? void 0 : _a2.validateFields());
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (props.scrollToFirstError) {
|
|
36
|
+
(_b2 = form.value) == null ? void 0 : _b2.scrollToField(error.errorFields[0].name.toString());
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function setData(data) {
|
|
42
|
+
Object.assign(formData, data);
|
|
43
|
+
}
|
|
44
|
+
const mountedForm = (vNode) => {
|
|
45
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
46
|
+
form.value = (_a2 = vNode.component) == null ? void 0 : _a2.exposed;
|
|
47
|
+
if (((_b2 = props.componentSchema) == null ? void 0 : _b2.type) === "form" && forms.value && form.value) {
|
|
48
|
+
const name = (_g = (_f = (_d = (_c = props.componentSchema) == null ? void 0 : _c.componentProps) == null ? void 0 : _d.name) != null ? _f : (_e = props.componentSchema) == null ? void 0 : _e.name) != null ? _g : "default";
|
|
49
|
+
form.value.validate = validate;
|
|
50
|
+
forms.value[name] = form.value;
|
|
51
|
+
form.value.getData = getData;
|
|
52
|
+
form.value.setData = setData;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const componentProps = vue.computed(() => {
|
|
57
|
+
const recordProps = props.componentSchema.componentProps;
|
|
58
|
+
let labelCol = recordProps.labelCol;
|
|
59
|
+
let wrapperCol = recordProps.wrapperCol;
|
|
60
|
+
if (recordProps.layout === "vertical") {
|
|
61
|
+
labelCol = wrapperCol = { span: 24 };
|
|
62
|
+
} else if (recordProps.layout === "inline" && recordProps.labelLayout === "fixed") {
|
|
63
|
+
labelCol = {};
|
|
64
|
+
wrapperCol = { flex: 1 };
|
|
65
|
+
} else if (recordProps.labelLayout === "fixed") {
|
|
66
|
+
labelCol = {
|
|
67
|
+
flex: `${typeof recordProps.labelWidth === "number" ? `${recordProps.labelWidth}px` : recordProps.labelWidth}`
|
|
68
|
+
};
|
|
69
|
+
wrapperCol = { flex: 1 };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...recordProps,
|
|
73
|
+
labelCol,
|
|
74
|
+
wrapperCol
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
function onFinish() {
|
|
78
|
+
}
|
|
79
|
+
const children = vue.computed(() => {
|
|
80
|
+
var _a2;
|
|
81
|
+
return (_a2 = props.componentSchema.children) != null ? _a2 : [];
|
|
82
|
+
});
|
|
83
|
+
__expose({
|
|
84
|
+
form,
|
|
85
|
+
getData,
|
|
86
|
+
setData,
|
|
87
|
+
validate
|
|
88
|
+
});
|
|
89
|
+
return (_ctx, _cache) => {
|
|
90
|
+
var _a2;
|
|
91
|
+
return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Form), vue.mergeProps({ model: vue.unref(formData) }, componentProps.value, {
|
|
92
|
+
onFinish,
|
|
93
|
+
class: { "epic-form-mode": (_a2 = vue.unref(designerProps)) == null ? void 0 : _a2.formMode },
|
|
94
|
+
onVnodeMounted: mountedForm
|
|
95
|
+
}), {
|
|
96
|
+
default: vue.withCtx(() => [
|
|
97
|
+
vue.renderSlot(_ctx.$slots, "edit-node", {}, () => [
|
|
98
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
99
|
+
vue.Fragment,
|
|
100
|
+
null,
|
|
101
|
+
vue.renderList(children.value, (item) => {
|
|
102
|
+
return vue.renderSlot(_ctx.$slots, "node", { componentSchema: item });
|
|
103
|
+
}),
|
|
104
|
+
256
|
|
105
|
+
/* UNKEYED_FRAGMENT */
|
|
106
|
+
))
|
|
107
|
+
])
|
|
108
|
+
]),
|
|
109
|
+
_: 3
|
|
110
|
+
/* FORWARDED */
|
|
111
|
+
}, 16, ["model", "class"]);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { defineComponent, inject, ref, provide, computed, createBlock, openBlock, unref, mergeProps, withCtx, renderSlot, createElementBlock, Fragment, renderList } from 'vue';
|
|
2
|
+
import { Form } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
...{
|
|
6
|
+
inheritAttrs: false
|
|
7
|
+
},
|
|
8
|
+
__name: "form",
|
|
9
|
+
props: {
|
|
10
|
+
componentSchema: { type: Object, required: true, default: () => ({ type: "" }) },
|
|
11
|
+
scrollToFirstError: { type: Boolean, required: false, default: false }
|
|
12
|
+
},
|
|
13
|
+
setup(__props, { expose: __expose }) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const props = __props;
|
|
16
|
+
const designerProps = inject("designerProps");
|
|
17
|
+
const pageManager = inject("pageManager", {});
|
|
18
|
+
const form = ref(null);
|
|
19
|
+
const forms = inject("forms", {});
|
|
20
|
+
const formData = pageManager.setFormData(
|
|
21
|
+
{},
|
|
22
|
+
(_b = (_a = props.componentSchema) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.name
|
|
23
|
+
);
|
|
24
|
+
provide("formData", formData);
|
|
25
|
+
function getData() {
|
|
26
|
+
return formData;
|
|
27
|
+
}
|
|
28
|
+
async function validate() {
|
|
29
|
+
var _a2, _b2;
|
|
30
|
+
try {
|
|
31
|
+
return await ((_a2 = form.value) == null ? void 0 : _a2.validateFields());
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (props.scrollToFirstError) {
|
|
34
|
+
(_b2 = form.value) == null ? void 0 : _b2.scrollToField(error.errorFields[0].name.toString());
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function setData(data) {
|
|
40
|
+
Object.assign(formData, data);
|
|
41
|
+
}
|
|
42
|
+
const mountedForm = (vNode) => {
|
|
43
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
44
|
+
form.value = (_a2 = vNode.component) == null ? void 0 : _a2.exposed;
|
|
45
|
+
if (((_b2 = props.componentSchema) == null ? void 0 : _b2.type) === "form" && forms.value && form.value) {
|
|
46
|
+
const name = (_g = (_f = (_d = (_c = props.componentSchema) == null ? void 0 : _c.componentProps) == null ? void 0 : _d.name) != null ? _f : (_e = props.componentSchema) == null ? void 0 : _e.name) != null ? _g : "default";
|
|
47
|
+
form.value.validate = validate;
|
|
48
|
+
forms.value[name] = form.value;
|
|
49
|
+
form.value.getData = getData;
|
|
50
|
+
form.value.setData = setData;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const componentProps = computed(() => {
|
|
55
|
+
const recordProps = props.componentSchema.componentProps;
|
|
56
|
+
let labelCol = recordProps.labelCol;
|
|
57
|
+
let wrapperCol = recordProps.wrapperCol;
|
|
58
|
+
if (recordProps.layout === "vertical") {
|
|
59
|
+
labelCol = wrapperCol = { span: 24 };
|
|
60
|
+
} else if (recordProps.layout === "inline" && recordProps.labelLayout === "fixed") {
|
|
61
|
+
labelCol = {};
|
|
62
|
+
wrapperCol = { flex: 1 };
|
|
63
|
+
} else if (recordProps.labelLayout === "fixed") {
|
|
64
|
+
labelCol = {
|
|
65
|
+
flex: `${typeof recordProps.labelWidth === "number" ? `${recordProps.labelWidth}px` : recordProps.labelWidth}`
|
|
66
|
+
};
|
|
67
|
+
wrapperCol = { flex: 1 };
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
...recordProps,
|
|
71
|
+
labelCol,
|
|
72
|
+
wrapperCol
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
function onFinish() {
|
|
76
|
+
}
|
|
77
|
+
const children = computed(() => {
|
|
78
|
+
var _a2;
|
|
79
|
+
return (_a2 = props.componentSchema.children) != null ? _a2 : [];
|
|
80
|
+
});
|
|
81
|
+
__expose({
|
|
82
|
+
form,
|
|
83
|
+
getData,
|
|
84
|
+
setData,
|
|
85
|
+
validate
|
|
86
|
+
});
|
|
87
|
+
return (_ctx, _cache) => {
|
|
88
|
+
var _a2;
|
|
89
|
+
return openBlock(), createBlock(unref(Form), mergeProps({ model: unref(formData) }, componentProps.value, {
|
|
90
|
+
onFinish,
|
|
91
|
+
class: { "epic-form-mode": (_a2 = unref(designerProps)) == null ? void 0 : _a2.formMode },
|
|
92
|
+
onVnodeMounted: mountedForm
|
|
93
|
+
}), {
|
|
94
|
+
default: withCtx(() => [
|
|
95
|
+
renderSlot(_ctx.$slots, "edit-node", {}, () => [
|
|
96
|
+
(openBlock(true), createElementBlock(
|
|
97
|
+
Fragment,
|
|
98
|
+
null,
|
|
99
|
+
renderList(children.value, (item) => {
|
|
100
|
+
return renderSlot(_ctx.$slots, "node", { componentSchema: item });
|
|
101
|
+
}),
|
|
102
|
+
256
|
|
103
|
+
/* UNKEYED_FRAGMENT */
|
|
104
|
+
))
|
|
105
|
+
])
|
|
106
|
+
]),
|
|
107
|
+
_: 3
|
|
108
|
+
/* FORWARDED */
|
|
109
|
+
}, 16, ["model", "class"]);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const antDesignVue = require('ant-design-vue');
|
|
5
|
+
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
7
|
+
__name: "formItem",
|
|
8
|
+
setup(__props) {
|
|
9
|
+
const attrs = vue.useAttrs();
|
|
10
|
+
return (_ctx, _cache) => {
|
|
11
|
+
return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.FormItem), vue.mergeProps(vue.unref(attrs), {
|
|
12
|
+
name: vue.unref(attrs).field
|
|
13
|
+
}), {
|
|
14
|
+
default: vue.withCtx(() => [
|
|
15
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
16
|
+
]),
|
|
17
|
+
_: 3
|
|
18
|
+
/* FORWARDED */
|
|
19
|
+
}, 16, ["name"]);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, createBlock, openBlock, unref, mergeProps, withCtx, renderSlot } from 'vue';
|
|
2
|
+
import { FormItem } from 'ant-design-vue';
|
|
3
|
+
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
__name: "formItem",
|
|
6
|
+
setup(__props) {
|
|
7
|
+
const attrs = useAttrs();
|
|
8
|
+
return (_ctx, _cache) => {
|
|
9
|
+
return openBlock(), createBlock(unref(FormItem), mergeProps(unref(attrs), {
|
|
10
|
+
name: unref(attrs).field
|
|
11
|
+
}), {
|
|
12
|
+
default: withCtx(() => [
|
|
13
|
+
renderSlot(_ctx.$slots, "default")
|
|
14
|
+
]),
|
|
15
|
+
_: 3
|
|
16
|
+
/* FORWARDED */
|
|
17
|
+
}, 16, ["name"]);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { _sfc_main as default };
|