@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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunks/button.cjs +44 -0
  3. package/dist/chunks/button.mjs +42 -0
  4. package/dist/chunks/card.cjs +39 -0
  5. package/dist/chunks/card.mjs +37 -0
  6. package/dist/chunks/col.cjs +39 -0
  7. package/dist/chunks/col.mjs +37 -0
  8. package/dist/chunks/datePicker.cjs +47 -0
  9. package/dist/chunks/datePicker.mjs +45 -0
  10. package/dist/chunks/form.cjs +116 -0
  11. package/dist/chunks/form.mjs +114 -0
  12. package/dist/chunks/formItem.cjs +24 -0
  13. package/dist/chunks/formItem.mjs +22 -0
  14. package/dist/chunks/modal.cjs +136 -0
  15. package/dist/chunks/modal.mjs +134 -0
  16. package/dist/chunks/row.cjs +39 -0
  17. package/dist/chunks/row.mjs +37 -0
  18. package/dist/chunks/uploadFile.cjs +138 -0
  19. package/dist/chunks/uploadFile.mjs +136 -0
  20. package/dist/chunks/uploadImage.cjs +152 -0
  21. package/dist/chunks/uploadImage.mjs +150 -0
  22. package/dist/index.cjs +3047 -0
  23. package/dist/index.d.cts +5 -0
  24. package/dist/index.d.mts +5 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.mjs +3045 -0
  27. package/package.json +38 -0
  28. package/src/button/button.vue +19 -0
  29. package/src/button/index.ts +204 -0
  30. package/src/card/card.ts +38 -0
  31. package/src/card/index.ts +65 -0
  32. package/src/cascader/cascader.vue +24 -0
  33. package/src/cascader/index.ts +201 -0
  34. package/src/checkbox/index.ts +101 -0
  35. package/src/col/col.ts +38 -0
  36. package/src/col/index.ts +22 -0
  37. package/src/color-picker/index.ts +109 -0
  38. package/src/date-picker/datePicker.ts +48 -0
  39. package/src/date-picker/index.ts +301 -0
  40. package/src/form/form.vue +153 -0
  41. package/src/form/index.ts +196 -0
  42. package/src/form-item/formItem.vue +12 -0
  43. package/src/form-item/index.ts +10 -0
  44. package/src/index.less +33 -0
  45. package/src/index.ts +131 -0
  46. package/src/input/index.ts +171 -0
  47. package/src/input-number/index.ts +182 -0
  48. package/src/input-password/index.ts +154 -0
  49. package/src/modal/index.ts +20 -0
  50. package/src/modal/modal.vue +98 -0
  51. package/src/radio/index.ts +107 -0
  52. package/src/row/index.ts +116 -0
  53. package/src/row/row.ts +38 -0
  54. package/src/select/index.ts +231 -0
  55. package/src/slider/index.ts +145 -0
  56. package/src/switch/index.ts +143 -0
  57. package/src/textarea/index.ts +164 -0
  58. package/src/time-picker/index.ts +192 -0
  59. package/src/upload-file/index.ts +90 -0
  60. package/src/upload-file/uploadFile.vue +145 -0
  61. package/src/upload-image/index.ts +71 -0
  62. package/src/upload-image/uploadImage.vue +167 -0
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+ const epicDesigner = require('epic-designer');
5
+ const antDesignVue = require('ant-design-vue');
6
+
7
+ const _hoisted_1 = { class: "epic-upload-image" };
8
+ const _hoisted_2 = { key: 0 };
9
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
10
+ __name: "uploadImage",
11
+ props: {
12
+ maxCount: { type: Number, required: false, default: 99 },
13
+ modelValue: { type: String, required: false, default: "" }
14
+ },
15
+ emits: ["update:modelValue", "change"],
16
+ setup(__props, { emit: __emit }) {
17
+ const props = __props;
18
+ const emits = __emit;
19
+ const formItemContext = antDesignVue.Form.useInjectFormItemContext();
20
+ const attrs = vue.useAttrs();
21
+ const fileList = vue.ref([]);
22
+ let urlString = "";
23
+ const imgUrl = vue.ref("");
24
+ const visible = vue.ref(false);
25
+ const setVisible = (value) => {
26
+ visible.value = value;
27
+ };
28
+ vue.watch(
29
+ () => fileList.value,
30
+ (list) => {
31
+ urlString = list.filter((file) => file.status === "done").map((file) => file.url).join(",");
32
+ emits("update:modelValue", urlString);
33
+ emits("change", urlString);
34
+ formItemContext.onFieldChange();
35
+ }
36
+ );
37
+ vue.watch(
38
+ () => props.modelValue,
39
+ (modelValue) => {
40
+ if (urlString === modelValue) return;
41
+ if (modelValue === "") {
42
+ fileList.value = [];
43
+ return;
44
+ }
45
+ if (modelValue && fileList.value) {
46
+ fileList.value = modelValue.split(",").map((url) => ({
47
+ name: url,
48
+ status: "done",
49
+ uid: epicDesigner.getUUID(),
50
+ url
51
+ }));
52
+ }
53
+ },
54
+ { deep: true, immediate: true }
55
+ );
56
+ function handleUpdate(e) {
57
+ vue.nextTick(() => {
58
+ fileList.value = e;
59
+ });
60
+ }
61
+ const handleChange = (info) => {
62
+ var _a, _b;
63
+ if (info.file.status === "uploading") {
64
+ return;
65
+ }
66
+ if (info.file.status === "done") {
67
+ const url = (_b = (_a = info.file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url;
68
+ if (!info.file.url && !url) {
69
+ info.file.status = "error";
70
+ antDesignVue.message.error("\u4E0A\u4F20\u5931\u8D25");
71
+ return;
72
+ }
73
+ info.file.url = url;
74
+ info.file.thumbUrl = url;
75
+ }
76
+ if (info.file.status === "error") {
77
+ antDesignVue.message.error("upload error");
78
+ }
79
+ };
80
+ const beforeUpload = () => {
81
+ };
82
+ const getUploadProps = vue.computed(() => {
83
+ var _a;
84
+ return {
85
+ ...attrs,
86
+ accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg",
87
+ headers: (_a = epicDesigner.pluginManager.global.axiosConfig) == null ? void 0 : _a.headers,
88
+ "onBefore-upload": beforeUpload,
89
+ onChange: handleChange,
90
+ onPreview: handlePreview,
91
+ "file-list": fileList.value,
92
+ "list-type": "picture-card",
93
+ "onUpdate:file-list": handleUpdate
94
+ };
95
+ });
96
+ function handlePreview(e) {
97
+ if (!e.url) return;
98
+ imgUrl.value = e.url;
99
+ setVisible(true);
100
+ }
101
+ function previewError() {
102
+ if (!imgUrl.value) return;
103
+ antDesignVue.message.error("\u56FE\u7247\u5730\u5740\u65E0\u6CD5\u8BBF\u95EE!");
104
+ }
105
+ return (_ctx, _cache) => {
106
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
107
+ vue.createVNode(
108
+ vue.unref(antDesignVue.Upload),
109
+ vue.normalizeProps(vue.guardReactiveProps(getUploadProps.value)),
110
+ {
111
+ default: vue.withCtx(() => {
112
+ var _a, _b;
113
+ return [
114
+ ((_b = (_a = fileList.value) == null ? void 0 : _a.length) != null ? _b : 0) < props.maxCount ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [..._cache[0] || (_cache[0] = [
115
+ vue.createElementVNode(
116
+ "span",
117
+ { class: "icon--epic icon--epic--cloud-upload-outlined mr-2px text-$epic-text-main text-lg" },
118
+ null,
119
+ -1
120
+ /* CACHED */
121
+ ),
122
+ vue.createElementVNode(
123
+ "div",
124
+ { class: "ant-upload-text" },
125
+ "\u70B9\u51FB\u4E0A\u4F20",
126
+ -1
127
+ /* CACHED */
128
+ )
129
+ ])])) : vue.createCommentVNode("v-if", true)
130
+ ];
131
+ }),
132
+ _: 1
133
+ /* STABLE */
134
+ },
135
+ 16
136
+ /* FULL_PROPS */
137
+ ),
138
+ vue.createVNode(vue.unref(antDesignVue.Image), {
139
+ style: { "display": "none" },
140
+ src: imgUrl.value,
141
+ preview: {
142
+ visible: visible.value,
143
+ onVisibleChange: setVisible
144
+ },
145
+ onError: previewError
146
+ }, null, 8, ["src", "preview"])
147
+ ]);
148
+ };
149
+ }
150
+ });
151
+
152
+ exports.default = _sfc_main;
@@ -0,0 +1,150 @@
1
+ import { defineComponent, useAttrs, ref, watch, computed, createElementBlock, openBlock, createVNode, unref, normalizeProps, guardReactiveProps, withCtx, createCommentVNode, createElementVNode, nextTick } from 'vue';
2
+ import { getUUID, pluginManager } from 'epic-designer';
3
+ import { Form, Upload, Image, message } from 'ant-design-vue';
4
+
5
+ const _hoisted_1 = { class: "epic-upload-image" };
6
+ const _hoisted_2 = { key: 0 };
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ __name: "uploadImage",
9
+ props: {
10
+ maxCount: { type: Number, required: false, default: 99 },
11
+ modelValue: { type: String, required: false, default: "" }
12
+ },
13
+ emits: ["update:modelValue", "change"],
14
+ setup(__props, { emit: __emit }) {
15
+ const props = __props;
16
+ const emits = __emit;
17
+ const formItemContext = Form.useInjectFormItemContext();
18
+ const attrs = useAttrs();
19
+ const fileList = ref([]);
20
+ let urlString = "";
21
+ const imgUrl = ref("");
22
+ const visible = ref(false);
23
+ const setVisible = (value) => {
24
+ visible.value = value;
25
+ };
26
+ watch(
27
+ () => fileList.value,
28
+ (list) => {
29
+ urlString = list.filter((file) => file.status === "done").map((file) => file.url).join(",");
30
+ emits("update:modelValue", urlString);
31
+ emits("change", urlString);
32
+ formItemContext.onFieldChange();
33
+ }
34
+ );
35
+ watch(
36
+ () => props.modelValue,
37
+ (modelValue) => {
38
+ if (urlString === modelValue) return;
39
+ if (modelValue === "") {
40
+ fileList.value = [];
41
+ return;
42
+ }
43
+ if (modelValue && fileList.value) {
44
+ fileList.value = modelValue.split(",").map((url) => ({
45
+ name: url,
46
+ status: "done",
47
+ uid: getUUID(),
48
+ url
49
+ }));
50
+ }
51
+ },
52
+ { deep: true, immediate: true }
53
+ );
54
+ function handleUpdate(e) {
55
+ nextTick(() => {
56
+ fileList.value = e;
57
+ });
58
+ }
59
+ const handleChange = (info) => {
60
+ var _a, _b;
61
+ if (info.file.status === "uploading") {
62
+ return;
63
+ }
64
+ if (info.file.status === "done") {
65
+ const url = (_b = (_a = info.file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url;
66
+ if (!info.file.url && !url) {
67
+ info.file.status = "error";
68
+ message.error("\u4E0A\u4F20\u5931\u8D25");
69
+ return;
70
+ }
71
+ info.file.url = url;
72
+ info.file.thumbUrl = url;
73
+ }
74
+ if (info.file.status === "error") {
75
+ message.error("upload error");
76
+ }
77
+ };
78
+ const beforeUpload = () => {
79
+ };
80
+ const getUploadProps = computed(() => {
81
+ var _a;
82
+ return {
83
+ ...attrs,
84
+ accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg",
85
+ headers: (_a = pluginManager.global.axiosConfig) == null ? void 0 : _a.headers,
86
+ "onBefore-upload": beforeUpload,
87
+ onChange: handleChange,
88
+ onPreview: handlePreview,
89
+ "file-list": fileList.value,
90
+ "list-type": "picture-card",
91
+ "onUpdate:file-list": handleUpdate
92
+ };
93
+ });
94
+ function handlePreview(e) {
95
+ if (!e.url) return;
96
+ imgUrl.value = e.url;
97
+ setVisible(true);
98
+ }
99
+ function previewError() {
100
+ if (!imgUrl.value) return;
101
+ message.error("\u56FE\u7247\u5730\u5740\u65E0\u6CD5\u8BBF\u95EE!");
102
+ }
103
+ return (_ctx, _cache) => {
104
+ return openBlock(), createElementBlock("div", _hoisted_1, [
105
+ createVNode(
106
+ unref(Upload),
107
+ normalizeProps(guardReactiveProps(getUploadProps.value)),
108
+ {
109
+ default: withCtx(() => {
110
+ var _a, _b;
111
+ return [
112
+ ((_b = (_a = fileList.value) == null ? void 0 : _a.length) != null ? _b : 0) < props.maxCount ? (openBlock(), createElementBlock("div", _hoisted_2, [..._cache[0] || (_cache[0] = [
113
+ createElementVNode(
114
+ "span",
115
+ { class: "icon--epic icon--epic--cloud-upload-outlined mr-2px text-$epic-text-main text-lg" },
116
+ null,
117
+ -1
118
+ /* CACHED */
119
+ ),
120
+ createElementVNode(
121
+ "div",
122
+ { class: "ant-upload-text" },
123
+ "\u70B9\u51FB\u4E0A\u4F20",
124
+ -1
125
+ /* CACHED */
126
+ )
127
+ ])])) : createCommentVNode("v-if", true)
128
+ ];
129
+ }),
130
+ _: 1
131
+ /* STABLE */
132
+ },
133
+ 16
134
+ /* FULL_PROPS */
135
+ ),
136
+ createVNode(unref(Image), {
137
+ style: { "display": "none" },
138
+ src: imgUrl.value,
139
+ preview: {
140
+ visible: visible.value,
141
+ onVisibleChange: setVisible
142
+ },
143
+ onError: previewError
144
+ }, null, 8, ["src", "preview"])
145
+ ]);
146
+ };
147
+ }
148
+ });
149
+
150
+ export { _sfc_main as default };