@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,192 @@
1
+ import type { ComponentConfigModel } from '@epic-designer/types';
2
+
3
+ export default {
4
+ bindModel: 'value',
5
+ component: async () => (await import('ant-design-vue')).TimePicker,
6
+ config: {
7
+ attribute: [
8
+ {
9
+ field: 'field',
10
+ label: '字段名',
11
+ type: 'input',
12
+ },
13
+ {
14
+ field: 'label',
15
+ label: '标题',
16
+ type: 'input',
17
+ },
18
+ {
19
+ field: 'componentProps.defaultValue',
20
+ label: '默认值',
21
+ type: 'time',
22
+ },
23
+ {
24
+ field: 'componentProps.placeholder',
25
+ label: '占位内容',
26
+ type: 'input',
27
+ },
28
+ {
29
+ componentProps: {
30
+ placeholder: '请输入',
31
+ },
32
+ field: 'componentProps.format',
33
+ label: '显示格式',
34
+ type: 'input',
35
+ },
36
+ {
37
+ componentProps: {
38
+ placeholder: '请输入',
39
+ },
40
+ field: 'componentProps.valueFormat',
41
+ label: '数据格式',
42
+ type: 'input',
43
+ },
44
+ {
45
+ componentProps: {
46
+ allowClear: true,
47
+ options: [
48
+ {
49
+ label: '大号',
50
+ value: 'large',
51
+ },
52
+ {
53
+ label: '中等',
54
+ value: 'middle',
55
+ },
56
+ {
57
+ label: '小型',
58
+ value: 'small',
59
+ },
60
+ ],
61
+ placeholder: '请选择',
62
+ },
63
+ field: 'componentProps.size',
64
+ label: '尺寸',
65
+ type: 'select',
66
+ },
67
+ {
68
+ componentProps: {
69
+ placeholder: '请输入',
70
+ },
71
+ field: 'componentProps.hourStep',
72
+ label: '小时选项间隔',
73
+ type: 'number',
74
+ },
75
+ {
76
+ componentProps: {
77
+ placeholder: '请输入',
78
+ },
79
+ field: 'componentProps.minuteStep',
80
+ label: '分钟选项间隔',
81
+ type: 'number',
82
+ },
83
+ {
84
+ componentProps: {
85
+ placeholder: '请输入',
86
+ },
87
+ field: 'componentProps.secondStep',
88
+ label: '秒选项间隔',
89
+ type: 'number',
90
+ },
91
+ {
92
+ componentProps: {
93
+ allowClear: true,
94
+ options: [
95
+ {
96
+ label: 'bottomLeft',
97
+ value: 'bottomLeft',
98
+ },
99
+ {
100
+ label: 'bottomRight',
101
+ value: 'bottomRight',
102
+ },
103
+ {
104
+ label: 'topLeft',
105
+ value: 'topLeft',
106
+ },
107
+ {
108
+ label: 'topRight',
109
+ value: 'topRight',
110
+ },
111
+ ],
112
+ placeholder: '请选择',
113
+ },
114
+ field: 'componentProps.placement',
115
+ label: '弹出框位置',
116
+ type: 'select',
117
+ },
118
+ {
119
+ changeSync: true,
120
+ field: 'componentProps.use12Hours',
121
+ label: '12小时制',
122
+ onChange({ value, values }) {
123
+ values.componentProps.defaultValue = null;
124
+ if (value) {
125
+ values.componentProps.format = 'h:mm:ss a';
126
+ values.componentProps.valueFormat = 'h:mm:ss a';
127
+ } else {
128
+ values.componentProps.format = 'HH:mm:ss';
129
+ values.componentProps.valueFormat = 'HH:mm:ss';
130
+ }
131
+ },
132
+ type: 'switch',
133
+ },
134
+ {
135
+ componentProps: {
136
+ checkedValue: false,
137
+ unCheckedValue: true,
138
+ },
139
+ field: 'componentProps.bordered',
140
+ label: '无边框',
141
+ type: 'switch',
142
+ },
143
+ {
144
+ field: 'componentProps.inputReadOnly',
145
+ label: '禁止键盘输入',
146
+ type: 'switch',
147
+ },
148
+ {
149
+ field: 'componentProps.allowClear',
150
+ label: '可清空',
151
+ type: 'switch',
152
+ },
153
+ {
154
+ field: 'componentProps.disabled',
155
+ label: '禁用',
156
+ type: 'switch',
157
+ },
158
+ {
159
+ field: 'componentProps.hidden',
160
+ label: '隐藏',
161
+ type: 'switch',
162
+ },
163
+ {
164
+ description: '校验规则需要配合表单使用',
165
+ field: 'rules',
166
+ label: '表单校验',
167
+ layout: 'vertical',
168
+ type: 'ERuleEditor',
169
+ },
170
+ ],
171
+ event: [
172
+ {
173
+ description: '值变化时',
174
+ type: 'change',
175
+ },
176
+ ],
177
+ },
178
+ defaultSchema: {
179
+ componentProps: {
180
+ format: 'HH:mm:ss',
181
+ placeholder: '请输入',
182
+ valueFormat: 'HH:mm:ss',
183
+ },
184
+ field: 'time',
185
+ input: true,
186
+ label: '时间选择器',
187
+ type: 'time',
188
+ },
189
+ groupName: '表单',
190
+ icon: 'icon--epic--time-line',
191
+ sort: 920,
192
+ } as ComponentConfigModel;
@@ -0,0 +1,90 @@
1
+ import type { ComponentConfigModel } from '@epic-designer/types';
2
+
3
+ export default {
4
+ bindModel: 'modelValue',
5
+ component: () => import('./uploadFile.vue'),
6
+ config: {
7
+ attribute: [
8
+ {
9
+ field: 'field',
10
+ label: '字段名',
11
+ type: 'input',
12
+ },
13
+ {
14
+ field: 'label',
15
+ label: '标题',
16
+ type: 'input',
17
+ },
18
+ {
19
+ field: 'componentProps.action',
20
+ label: '请求地址',
21
+ type: 'input',
22
+ },
23
+ {
24
+ componentProps: {
25
+ allowClear: true,
26
+ options: [
27
+ {
28
+ label: 'text',
29
+ value: 'text',
30
+ },
31
+ {
32
+ label: 'picture',
33
+ value: 'picture',
34
+ },
35
+ ],
36
+ placeholder: '请选择',
37
+ },
38
+ field: 'componentProps.listType',
39
+ label: '列表样式',
40
+ type: 'select',
41
+ },
42
+ {
43
+ field: 'componentProps.multiple',
44
+ label: '多选',
45
+ type: 'switch',
46
+ },
47
+ {
48
+ componentProps: {
49
+ min: 0,
50
+ placeholder: '请输入',
51
+ },
52
+ field: 'componentProps.maxCount',
53
+ label: '允许上传最大数量',
54
+ type: 'number',
55
+ },
56
+ {
57
+ field: 'componentProps.disabled',
58
+ label: '禁用',
59
+ type: 'switch',
60
+ },
61
+ {
62
+ field: 'componentProps.hidden',
63
+ label: '隐藏',
64
+ type: 'switch',
65
+ },
66
+ {
67
+ componentProps: {
68
+ ruleType: 'string',
69
+ },
70
+ description: '校验规则需要配合表单使用',
71
+ field: 'rules',
72
+ label: '表单校验',
73
+ layout: 'vertical',
74
+ type: 'ERuleEditor',
75
+ },
76
+ ],
77
+ },
78
+ defaultSchema: {
79
+ componentProps: {
80
+ action: 'https://examples.epicjs.cn/epic-mock/common/upload',
81
+ },
82
+ field: 'uploadFile',
83
+ input: true,
84
+ label: '上传文件',
85
+ type: 'upload-file',
86
+ },
87
+ groupName: '表单',
88
+ icon: 'icon--epic--upload-rounded',
89
+ sort: 920,
90
+ } as ComponentConfigModel;
@@ -0,0 +1,145 @@
1
+ <script lang="ts" setup>
2
+ import type {
3
+ UploadChangeParam,
4
+ UploadFile,
5
+ UploadProps,
6
+ } from 'ant-design-vue';
7
+
8
+ import { computed, nextTick, ref, useAttrs, watch } from 'vue';
9
+
10
+ import { pluginManager } from '@epic-designer/manager';
11
+ import { getUUID } from '@epic-designer/utils';
12
+ import { Button, Form, message, Upload } from 'ant-design-vue';
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ maxCount?: number;
17
+ modelValue?: string;
18
+ }>(),
19
+ {
20
+ maxCount: 99,
21
+ modelValue: '',
22
+ },
23
+ );
24
+
25
+ const emits = defineEmits(['update:modelValue', 'change']);
26
+ const formItemContext = Form.useInjectFormItemContext();
27
+ const attrs = useAttrs();
28
+ const fileList = ref<UploadProps['fileList']>([]);
29
+ let urlString = '';
30
+
31
+ watch(
32
+ () => fileList.value,
33
+ (list) => {
34
+ urlString = list!
35
+ .filter((file) => file.status === 'done')
36
+ .map((file) => file.url)
37
+ .join(',');
38
+ emits('update:modelValue', urlString);
39
+ emits('change', urlString);
40
+ formItemContext.onFieldChange();
41
+ },
42
+ );
43
+ // 处理传递进来的值
44
+ watch(
45
+ () => props.modelValue,
46
+ (modelValue) => {
47
+ // urlString 等于 data 不进行处理
48
+ if (urlString === modelValue) return;
49
+
50
+ if (modelValue === '') {
51
+ fileList.value = [];
52
+ return;
53
+ }
54
+
55
+ if (modelValue && fileList.value) {
56
+ fileList.value = modelValue.split(',').map((url) => ({
57
+ name: url,
58
+ status: 'done',
59
+ uid: getUUID() as string,
60
+ url,
61
+ }));
62
+ }
63
+ },
64
+ { deep: true, immediate: true },
65
+ );
66
+
67
+ function handleUpdate(e: UploadProps['fileList']): void {
68
+ nextTick(() => {
69
+ fileList.value = e;
70
+ });
71
+ }
72
+
73
+ // 处理数据结果
74
+ const handleChange = (info: UploadChangeParam): void => {
75
+ if (info.file.status === 'uploading') {
76
+ return;
77
+ }
78
+
79
+ if (info.file.status === 'done') {
80
+ // Get this url from response in real world.
81
+ const url: string | undefined = info.file.response?.data?.url;
82
+ if (!info.file.url && !url) {
83
+ info.file.status = 'error';
84
+ message.error('上传失败');
85
+ return;
86
+ }
87
+ // 赋值url
88
+ info.file.url = url;
89
+ info.file.thumbUrl = url;
90
+ }
91
+
92
+ if (info.file.status === 'error') {
93
+ message.error('upload error');
94
+ }
95
+ };
96
+
97
+ // 上传前处理
98
+ const beforeUpload = (): void => {
99
+ // const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
100
+ // if (!isJpgOrPng) {
101
+ // message.error('您只能上传JPG/PNG文件!');
102
+ // }
103
+ // const isLt2M = file.size / 1024 / 1024 < 2;
104
+ // if (!isLt2M) {
105
+ // message.error('图片大小超过 2MB!');
106
+ // }
107
+ // return isJpgOrPng && isLt2M;
108
+ };
109
+
110
+ const getUploadProps = computed<UploadProps>(() => ({
111
+ ...attrs,
112
+ headers: pluginManager.global.axiosConfig?.headers,
113
+ 'onBefore-upload': beforeUpload,
114
+ onChange: handleChange,
115
+ onPreview: handlePreview,
116
+ 'file-list': fileList.value,
117
+ 'onUpdate:file-list': handleUpdate,
118
+ }));
119
+
120
+ /**
121
+ * 预览功能
122
+ * @param {*} e
123
+ */
124
+ function handlePreview(e: UploadFile): void {
125
+ console.log(e);
126
+ if (!e.url) return;
127
+ window.open(e.url, '_blank');
128
+ }
129
+ </script>
130
+
131
+ <template>
132
+ <div class="epic-upload-file">
133
+ <Upload v-bind="getUploadProps">
134
+ <Button
135
+ class="flex items-center"
136
+ v-if="(fileList?.length ?? 0) < props.maxCount"
137
+ >
138
+ <span
139
+ class="icon--epic icon--epic--cloud-upload-outlined text-lg"
140
+ ></span>
141
+ <div class="ant-upload-text">上传文件</div>
142
+ </Button>
143
+ </Upload>
144
+ </div>
145
+ </template>
@@ -0,0 +1,71 @@
1
+ import type { ComponentConfigModel } from '@epic-designer/types';
2
+
3
+ export default {
4
+ bindModel: 'modelValue',
5
+ component: () => import('./uploadImage.vue'),
6
+ config: {
7
+ attribute: [
8
+ {
9
+ field: 'field',
10
+ label: '字段名',
11
+ type: 'input',
12
+ },
13
+ {
14
+ field: 'label',
15
+ label: '标题',
16
+ type: 'input',
17
+ },
18
+ {
19
+ field: 'componentProps.action',
20
+ label: '请求地址',
21
+ type: 'input',
22
+ },
23
+ {
24
+ field: 'componentProps.multiple',
25
+ label: '多选',
26
+ type: 'switch',
27
+ },
28
+ {
29
+ componentProps: {
30
+ min: 0,
31
+ placeholder: '请输入',
32
+ },
33
+ field: 'componentProps.maxCount',
34
+ label: '允许上传最大数量',
35
+ type: 'number',
36
+ },
37
+ {
38
+ field: 'componentProps.disabled',
39
+ label: '禁用',
40
+ type: 'switch',
41
+ },
42
+ {
43
+ field: 'componentProps.hidden',
44
+ label: '隐藏',
45
+ type: 'switch',
46
+ },
47
+ {
48
+ componentProps: {
49
+ ruleType: 'string',
50
+ },
51
+ description: '校验规则需要配合表单使用',
52
+ field: 'rules',
53
+ label: '表单校验',
54
+ layout: 'vertical',
55
+ type: 'ERuleEditor',
56
+ },
57
+ ],
58
+ },
59
+ defaultSchema: {
60
+ componentProps: {
61
+ action: 'https://examples.epicjs.cn/epic-mock/common/upload',
62
+ },
63
+ field: 'uploadImage',
64
+ input: true,
65
+ label: '上传图片',
66
+ type: 'upload-image',
67
+ },
68
+ groupName: '表单',
69
+ icon: 'icon--epic--imagesmode-outline-rounded',
70
+ sort: 920,
71
+ } as ComponentConfigModel;
@@ -0,0 +1,167 @@
1
+ <script lang="ts" setup>
2
+ import type {
3
+ UploadChangeParam,
4
+ UploadFile,
5
+ UploadProps,
6
+ } from 'ant-design-vue';
7
+
8
+ import { computed, nextTick, ref, useAttrs, watch } from 'vue';
9
+
10
+ import { pluginManager } from '@epic-designer/manager';
11
+ import { getUUID } from '@epic-designer/utils';
12
+ import { Form, Image, message, Upload } from 'ant-design-vue';
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ maxCount?: number;
17
+ modelValue?: string;
18
+ }>(),
19
+ {
20
+ maxCount: 99,
21
+ modelValue: '',
22
+ },
23
+ );
24
+
25
+ const emits = defineEmits(['update:modelValue', 'change']);
26
+ const formItemContext = Form.useInjectFormItemContext();
27
+ const attrs = useAttrs();
28
+ const fileList = ref<UploadProps['fileList']>([]);
29
+ let urlString = '';
30
+
31
+ const imgUrl = ref('');
32
+ const visible = ref(false);
33
+ const setVisible = (value: boolean): void => {
34
+ visible.value = value;
35
+ };
36
+
37
+ watch(
38
+ () => fileList.value,
39
+ (list) => {
40
+ urlString = list!
41
+ .filter((file) => file.status === 'done')
42
+ .map((file) => file.url)
43
+ .join(',');
44
+ emits('update:modelValue', urlString);
45
+ emits('change', urlString);
46
+ formItemContext.onFieldChange();
47
+ },
48
+ );
49
+ // 处理传递进来的值
50
+ watch(
51
+ () => props.modelValue,
52
+ (modelValue) => {
53
+ // urlString 等于 data 不进行处理
54
+ if (urlString === modelValue) return;
55
+
56
+ if (modelValue === '') {
57
+ fileList.value = [];
58
+ return;
59
+ }
60
+
61
+ if (modelValue && fileList.value) {
62
+ fileList.value = modelValue.split(',').map((url) => ({
63
+ name: url,
64
+ status: 'done',
65
+ uid: getUUID() as string,
66
+ url,
67
+ }));
68
+ }
69
+ },
70
+ { deep: true, immediate: true },
71
+ );
72
+
73
+ function handleUpdate(e: UploadProps['fileList']): void {
74
+ nextTick(() => {
75
+ fileList.value = e;
76
+ });
77
+ }
78
+
79
+ // 处理数据结果
80
+ const handleChange = (info: UploadChangeParam): void => {
81
+ if (info.file.status === 'uploading') {
82
+ return;
83
+ }
84
+
85
+ if (info.file.status === 'done') {
86
+ // Get this url from response in real world.
87
+ const url: string | undefined = info.file.response?.data?.url;
88
+ if (!info.file.url && !url) {
89
+ info.file.status = 'error';
90
+ message.error('上传失败');
91
+ return;
92
+ }
93
+ // 赋值url
94
+ info.file.url = url;
95
+ info.file.thumbUrl = url;
96
+ }
97
+
98
+ if (info.file.status === 'error') {
99
+ message.error('upload error');
100
+ }
101
+ };
102
+
103
+ // 上传前处理
104
+ const beforeUpload = (): void => {
105
+ // const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
106
+ // if (!isJpgOrPng) {
107
+ // message.error('您只能上传JPG/PNG文件!');
108
+ // }
109
+ // const isLt2M = file.size / 1024 / 1024 < 2;
110
+ // if (!isLt2M) {
111
+ // message.error('图片大小超过 2MB!');
112
+ // }
113
+ // return isJpgOrPng && isLt2M;
114
+ };
115
+
116
+ const getUploadProps = computed<UploadProps>(() => ({
117
+ ...attrs,
118
+ accept: 'image/gif,image/jpeg,image/jpg,image/png,image/svg',
119
+ headers: pluginManager.global.axiosConfig?.headers,
120
+ 'onBefore-upload': beforeUpload,
121
+ onChange: handleChange,
122
+ onPreview: handlePreview,
123
+ 'file-list': fileList.value,
124
+ 'list-type': 'picture-card',
125
+ 'onUpdate:file-list': handleUpdate,
126
+ }));
127
+
128
+ /**
129
+ * 预览功能
130
+ * @param {*} e
131
+ */
132
+ function handlePreview(e: UploadFile): void {
133
+ if (!e.url) return;
134
+ imgUrl.value = e.url;
135
+ setVisible(true);
136
+ }
137
+
138
+ /**
139
+ * 预览异常处理
140
+ */
141
+ function previewError(): void {
142
+ if (!imgUrl.value) return;
143
+ message.error('图片地址无法访问!');
144
+ }
145
+ </script>
146
+
147
+ <template>
148
+ <div class="epic-upload-image">
149
+ <Upload v-bind="getUploadProps">
150
+ <div v-if="(fileList?.length ?? 0) < props.maxCount">
151
+ <span
152
+ class="icon--epic icon--epic--cloud-upload-outlined mr-2px text-$epic-text-main text-lg"
153
+ ></span>
154
+ <div class="ant-upload-text">点击上传</div>
155
+ </div>
156
+ </Upload>
157
+ <Image
158
+ style="display: none"
159
+ :src="imgUrl"
160
+ :preview="{
161
+ visible,
162
+ onVisibleChange: setVisible,
163
+ }"
164
+ @error="previewError"
165
+ />
166
+ </div>
167
+ </template>