@cloudbase/weda-ui 3.1.7 → 3.1.9

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.
@@ -304,7 +304,8 @@
304
304
  "target": "*(xIsCountEmpty)",
305
305
  "condition": "{{ $self.value && ($self.value.format !=='datetime' && $self.value.format !=='date') }}"
306
306
  }
307
- ]
307
+ ],
308
+ "remarks": "X轴数值字段选择"
308
309
  },
309
310
  "xStatistics": {
310
311
  "title": "统计维度",
@@ -344,7 +345,8 @@
344
345
  "target": "*(groupKey)",
345
346
  "condition": "{{ (!$self.value || !$self.value.numValue || $self.value.numValue.length<=1) && !!$self.__datasourceName }}"
346
347
  }
347
- ]
348
+ ],
349
+ "remarks": "Y轴数值字段选择"
348
350
  },
349
351
  "groupKey": {
350
352
  "type": "object",
@@ -584,7 +586,8 @@
584
586
  "title": "显示数值",
585
587
  "type": "boolean",
586
588
  "x-index": 310,
587
- "default": true
589
+ "default": true,
590
+ "remarks": "数值(Y轴)显示数值"
588
591
  },
589
592
  "dataTagShow": {
590
593
  "x-index": 320,
@@ -597,7 +600,8 @@
597
600
  "title": "显示数值",
598
601
  "type": "boolean",
599
602
  "x-index": 330,
600
- "default": true
603
+ "default": true,
604
+ "remarks": "数据标签显示数值"
601
605
  },
602
606
  "unitShow": {
603
607
  "x-index": 340,
@@ -247,7 +247,8 @@
247
247
  "target": "*(xIsCountEmpty)",
248
248
  "condition": "{{ $self.value && ($self.value.format !=='datetime' && $self.value.format !=='date') }}"
249
249
  }
250
- ]
250
+ ],
251
+ "remarks": "X轴数值字段选择"
251
252
  },
252
253
  "xStatistics": {
253
254
  "title": "统计维度",
@@ -286,7 +287,8 @@
286
287
  "condition": "{{ (!$self.value || !$self.value.numValue || $self.value.numValue.length<=1) && !!$self.__datasourceName }}"
287
288
  }
288
289
  ],
289
- "x-datasource-method-reset": {}
290
+ "x-datasource-method-reset": {},
291
+ "remarks": "Y轴数值字段选择"
290
292
  },
291
293
  "groupKey": {
292
294
  "type": "object",
@@ -530,7 +532,8 @@
530
532
  "type": "boolean",
531
533
  "x-index": 300,
532
534
  "default": true,
533
- "x-category": "高级属性"
535
+ "x-category": "高级属性",
536
+ "remarks": "数值(Y轴)字段选择"
534
537
  },
535
538
  "dataTagShow": {
536
539
  "x-index": 310,
@@ -545,7 +548,8 @@
545
548
  "type": "boolean",
546
549
  "x-index": 320,
547
550
  "default": true,
548
- "x-category": "高级属性"
551
+ "x-category": "高级属性",
552
+ "remarks": "数据标签字段选择"
549
553
  },
550
554
  "unitShow": {
551
555
  "x-index": 330,
@@ -245,7 +245,8 @@
245
245
  "target": "*(xIsCountEmpty)",
246
246
  "condition": "{{ $self.value && ($self.value.format !=='datetime' && $self.value.format !=='date') }}"
247
247
  }
248
- ]
248
+ ],
249
+ "remarks": "X轴数值字段选择"
249
250
  },
250
251
  "xStatistics": {
251
252
  "title": "统计维度",
@@ -277,7 +278,8 @@
277
278
  "isMethod": true,
278
279
  "dataSourceNamePropKey": "dataSource",
279
280
  "maxFieldCount": 1
280
- }
281
+ },
282
+ "remarks": "Y轴数值字段选择"
281
283
  },
282
284
  "legendShow": {
283
285
  "x-index": 120,
@@ -358,7 +360,8 @@
358
360
  "type": "boolean",
359
361
  "x-index": 170,
360
362
  "default": true,
361
- "x-category": "高级属性"
363
+ "x-category": "高级属性",
364
+ "remarks": "数据标签字段选择"
362
365
  },
363
366
  "isPercent": {
364
367
  "title": "显示百分比",
@@ -3,6 +3,21 @@ export const sortBy = (props) => {
3
3
  return a[props] - b[props];
4
4
  };
5
5
  };
6
+ const platMaps = {
7
+ PCWEB: 'PC端',
8
+ MOBILEWEB: '移动端',
9
+ MP: '小程序',
10
+ WEB: 'WEB端',
11
+ };
12
+ const platTranslate = (platforms = []) => {
13
+ const platRemark = [];
14
+ if (platforms && platforms.length > 0) {
15
+ platforms.forEach((e) => {
16
+ platRemark.push(platMaps[e]);
17
+ });
18
+ }
19
+ return platRemark;
20
+ };
6
21
  export const objFormat = (args, type, origin) => {
7
22
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
8
23
  //判断属性title值是否为拓展写法
@@ -16,9 +31,9 @@ export const objFormat = (args, type, origin) => {
16
31
  description: ((_e = args[i]) === null || _e === void 0 ? void 0 : _e.remarks) || '-',
17
32
  platforms: args[i]['x-platforms']
18
33
  ? args[i]['x-platforms'].indexOf('MP') > -1
19
- ? '小程序端'
34
+ ? '小程序'
20
35
  : args[i]['x-platforms'].indexOf('WEB') > -1
21
- ? 'web端'
36
+ ? 'WEB端'
22
37
  : '兼容三端'
23
38
  : '兼容三端',
24
39
  });
@@ -30,11 +45,15 @@ export const objFormat = (args, type, origin) => {
30
45
  args[i]['x-component'] == 'Divider') {
31
46
  continue;
32
47
  }
48
+ const titleName = args[i].title.indexOf('{{') != -1
49
+ ? (_h = args[i]) === null || _h === void 0 ? void 0 : _h.title.match(uuidReg)[1]
50
+ : (_j = args[i]) === null || _j === void 0 ? void 0 : _j.title;
33
51
  transformData.push({
34
52
  code: i,
35
- title: args[i].title.indexOf('{{') != -1
36
- ? (_h = args[i]) === null || _h === void 0 ? void 0 : _h.title.match(uuidReg)[1]
37
- : (_j = args[i]) === null || _j === void 0 ? void 0 : _j.title,
53
+ title: titleName +
54
+ (platTranslate(args[i]['x-platforms']).length > 0
55
+ ? '(' + platTranslate(args[i]['x-platforms']).join(',') + ')'
56
+ : ''),
38
57
  description: ((_k = args[i]) === null || _k === void 0 ? void 0 : _k.remarks) || '-',
39
58
  type: ((_l = args[i]) === null || _l === void 0 ? void 0 : _l.type) || '-',
40
59
  default: JSON.stringify((_m = args[i]) === null || _m === void 0 ? void 0 : _m.default) || '-',
@@ -0,0 +1,3 @@
1
+ .weapps__modal {
2
+ z-index: 5001 !important;
3
+ }
@@ -1,3 +1,4 @@
1
+ import './index.css';
1
2
  export default function showModal({ data }: {
2
3
  data: any;
3
4
  }): Promise<unknown>;
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { forwardRef, useState, useEffect, useImperativeHandle } from 'react';
4
4
  import { Modal, Button, Text, ConfigProvider } from 'tea-component';
5
5
  import { noop } from '../../utils/constant';
6
+ import './index.css';
6
7
  const ModalShow = forwardRef(function ModalShow(props, ref) {
7
8
  const [visible, setVisible] = useState(false);
8
9
  // 渲染之后,马上显示
@@ -70,12 +70,6 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
70
70
  setProgress(percentCompleted);
71
71
  };
72
72
  const uploadToTcb = (file) => {
73
- if ((file === null || file === void 0 ? void 0 : file.type.split('/')[0]) !== 'image') {
74
- weui.alert('请上传图片', {
75
- title: 'Image Type Error',
76
- });
77
- return false;
78
- }
79
73
  setUploading(true);
80
74
  getCloudInstance().then(async (tcb) => {
81
75
  var _a;
@@ -105,6 +99,29 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
105
99
  ? IMAGE_TYPES
106
100
  : Array.from(new Set(acceptTypes));
107
101
  }, [acceptTypes]);
102
+ const islegalType = (files, accepts) => {
103
+ const illegalType = [];
104
+ let isImage = true;
105
+ for (const file of files) {
106
+ if ((file === null || file === void 0 ? void 0 : file.type.split('/')[0]) !== 'image') {
107
+ weui.alert('请上传图片', {
108
+ title: 'Image Type Error',
109
+ });
110
+ isImage = false;
111
+ break;
112
+ }
113
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
114
+ ? null
115
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
116
+ }
117
+ if (!isImage)
118
+ return false;
119
+ if (illegalType.length > 0) {
120
+ weui.alert('不支持上传' + Array.from(new Set(illegalType)).join(',') + '格式图片');
121
+ return false;
122
+ }
123
+ return true;
124
+ };
108
125
  const showAdd = React.useMemo(() => {
109
126
  if (single) {
110
127
  // single 模式时,仅当数组为空时显示
@@ -125,6 +142,8 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
125
142
  "%")))),
126
143
  showAdd && (React.createElement("div", { className: "weui-uploader__input-box" }, !disabled && (React.createElement("input", { id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: true, onChange: (e) => {
127
144
  const files = [...e.target.files];
145
+ if (!islegalType(files, accepts))
146
+ return;
128
147
  if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
129
148
  weui.alert('请上传不超过10M的图片');
130
149
  return false;
@@ -150,7 +169,8 @@ function SingleImage({ src, deleteBySrc }) {
150
169
  React.useEffect(() => {
151
170
  const getSrc = async () => {
152
171
  try {
153
- const _src = await getTempFileURL(src);
172
+ const url = await getTempFileURL(src);
173
+ const _src = encodeURI(url);
154
174
  setRealSrc(_src);
155
175
  return _src;
156
176
  }
@@ -68,8 +68,36 @@ export function UploaderPCInner(props) {
68
68
  fileRef.current = fileIDList;
69
69
  }
70
70
  });
71
+ //验证上传文件类型是否合法
72
+ const islegalType = (files, accepts) => {
73
+ const illegalType = [];
74
+ let isImage = true;
75
+ for (const file of files) {
76
+ if ((file === null || file === void 0 ? void 0 : file.type.split('/')[0]) !== 'image') {
77
+ message.error({ content: '请上传图片' });
78
+ isImage = false;
79
+ break;
80
+ }
81
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
82
+ ? null
83
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
84
+ }
85
+ if (!isImage)
86
+ return false;
87
+ if (illegalType.length > 0) {
88
+ message.error({
89
+ content: '不支持上传' +
90
+ Array.from(new Set(illegalType)).join(',') +
91
+ '格式图片',
92
+ });
93
+ return false;
94
+ }
95
+ return true;
96
+ };
71
97
  // 方法:上传前,判断图片大小、数量是否满足,取消默认组件的上传事件,用自定义的 tcb 上传方法
72
98
  const beforeHandle = (file, fileList, isAccepted, error) => {
99
+ if (!islegalType(fileList, extraProps['accept']))
100
+ return;
73
101
  if (!isAccepted) {
74
102
  try {
75
103
  const errorList = [];
@@ -164,7 +192,8 @@ export const TcbImage = (props) => {
164
192
  React.useEffect(() => {
165
193
  const getSrc = async () => {
166
194
  try {
167
- const _src = await getTempFileURL(fileID);
195
+ const url = await getTempFileURL(fileID);
196
+ const _src = encodeURI(url);
168
197
  _src ? setSrc(_src) : setIsError(true);
169
198
  }
170
199
  catch (e) {
@@ -83,15 +83,29 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
83
83
  ? ['*']
84
84
  : Array.from(new Set(acceptTypes));
85
85
  }, [acceptTypes]);
86
+ const islegalType = (files, accepts) => {
87
+ const illegalType = [];
88
+ for (const file of files) {
89
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
90
+ ? null
91
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
92
+ }
93
+ if (illegalType.length > 0) {
94
+ weui.alert('不支持上传' + Array.from(new Set(illegalType)).join(',') + '格式文件');
95
+ return false;
96
+ }
97
+ return true;
98
+ };
86
99
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
87
100
  const handleChange = ({ fileID, uuid, type, size }) => {
88
101
  // 上传时新增事件
89
102
  if (type === 'add') {
90
103
  fileID && setFileSizeObj((obj) => ({ ...obj, [fileID]: size }));
91
- fileID && setfileIDList([...fileIDList, fileID]);
104
+ fileID && setfileIDList((fileIDList) => [...fileIDList, fileID]);
92
105
  }
93
106
  else {
94
- fileID && setfileIDList(fileIDList.filter((f) => f !== fileID));
107
+ fileID &&
108
+ setfileIDList((fileIDList) => fileIDList.filter((f) => f !== fileID));
95
109
  }
96
110
  uuid && setFileList((list) => list.filter((item) => uuid !== (item === null || item === void 0 ? void 0 : item._uuid)));
97
111
  };
@@ -120,6 +134,12 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
120
134
  React.createElement("div", null, btnDisabled ? (React.createElement(Button, { type: "weak", className: classNames(`${CLASS_PREFIX}__btn--weak`), disabled: btnDisabled }, btnTitle)) : (React.createElement("div", null,
121
135
  React.createElement("input", { id: "uploaderInput", type: "file", "data-testid": "button-up", className: "weui-uploader-mobile__input", accept: accepts.join(','), multiple: !single, onChange: (e) => {
122
136
  const fileList = [...e.target.files];
137
+ //校验逻辑与图片有出入,文件类型限制为全部时,不设限
138
+ if (!(accepts.includes('*') ||
139
+ accepts.includes('') ||
140
+ accepts.length === 0) &&
141
+ !islegalType(fileList, accepts))
142
+ return;
123
143
  if (single && fileList.length > 1) {
124
144
  weui.alert(`上传文件总数不能超过1个`);
125
145
  return false;
@@ -68,6 +68,11 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
68
68
  });
69
69
  // 批量上传文件前置事件
70
70
  const handleBefore = (file, fileList, isAccepted, error) => {
71
+ if (!((acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('*')) ||
72
+ (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('')) ||
73
+ (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.length) === 0) &&
74
+ !islegalType(fileList, uploadProps['accept']))
75
+ return;
71
76
  if (fileList.length + fileIDList.length > maxUploadCount) {
72
77
  message.warning({ content: `上传文件总数不能超过${maxUploadCount}个` });
73
78
  return false;
@@ -112,6 +117,24 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
112
117
  tips && (uploadProps['title'] = tips);
113
118
  maxSize && (uploadProps['maxSize'] = maxSize * 1024 * 1024);
114
119
  const btnDisabled = fileIDList.length >= maxUploadCount || (single && fileIDList.length > 0);
120
+ //验证上传文件类型是否合法
121
+ const islegalType = (files, accepts) => {
122
+ const illegalType = [];
123
+ for (const file of files) {
124
+ accepts.some((item) => item === (file === null || file === void 0 ? void 0 : file.type))
125
+ ? null
126
+ : illegalType.push(file === null || file === void 0 ? void 0 : file.type);
127
+ }
128
+ if (illegalType.length > 0) {
129
+ message.error({
130
+ content: '不支持上传' +
131
+ Array.from(new Set(illegalType)).join(',') +
132
+ '格式文件',
133
+ });
134
+ return false;
135
+ }
136
+ return true;
137
+ };
115
138
  return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
116
139
  React.createElement(FileContext.Provider, { value: {
117
140
  uploadPath,
@@ -121,9 +144,9 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
121
144
  isEdit,
122
145
  events,
123
146
  fileSizeObj,
124
- } },
125
- React.createElement("div", { className: `${CLASS_PREFIX}` },
126
- isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled || btnDisabled ? (React.createElement(Button, { type: "weak", disabled: true }, btnTitle)) : (React.createElement(Upload, { ...uploadProps, beforeUpload: handleBefore },
147
+ }, "data-testid": "button-up" },
148
+ React.createElement("div", { className: `${CLASS_PREFIX}`, "data-testid": "UploadFilePc" },
149
+ isEdit && (React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled || btnDisabled ? (React.createElement(Button, { type: "weak", disabled: true }, btnTitle)) : (React.createElement(Upload, { ...uploadProps, beforeUpload: handleBefore, "data-testid": "Upload" },
127
150
  React.createElement(Button, { type: "weak", className: `${CLASS_PREFIX}__btn--weak` }, btnTitle),
128
151
  !single && (React.createElement(Text, { theme: "weak", className: `${CLASS_PREFIX}__btn-descripe` }, "\u652F\u6301\u6279\u91CF\u4E0A\u4F20")))))),
129
152
  React.createElement(List, { split: "divide" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",