@cloudbase/weda-ui 3.1.6 → 3.2.0

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 (82) hide show
  1. package/dist/configs/components/chart/bar.json +14 -7
  2. package/dist/configs/components/chart/line.json +14 -7
  3. package/dist/configs/components/chart/pie.json +12 -6
  4. package/dist/configs/components/form/departTreeSelect.json +124 -0
  5. package/dist/configs/components/form/userTreeSelect.json +128 -0
  6. package/dist/configs/components/formdetail.json +105 -0
  7. package/dist/configs/components/listView.json +9 -1
  8. package/dist/configs/components/lottery.json +1 -1
  9. package/dist/configs/components/tabs.json +10 -9
  10. package/dist/configs/components/wxOpenApi/share.json +5 -2
  11. package/dist/configs/index.d.ts +6 -0
  12. package/dist/configs/index.js +6 -0
  13. package/dist/docs/common/format.js +24 -5
  14. package/dist/web/actions/showModal/index.css +3 -0
  15. package/dist/web/actions/showModal/index.d.ts +1 -0
  16. package/dist/web/actions/showModal/index.js +1 -0
  17. package/dist/web/components/calendar/index.js +10 -2
  18. package/dist/web/components/carousel/index.js +4 -0
  19. package/dist/web/components/chart/common/core/eChartBase.js +8 -2
  20. package/dist/web/components/form/form/index.js +10 -7
  21. package/dist/web/components/form/location/common/mapChoose.js +2 -0
  22. package/dist/web/components/form/location/common/mapView.js +2 -0
  23. package/dist/web/components/form/location/components/LocationH5/location.h5.js +3 -1
  24. package/dist/web/components/form/location/components/LocationH5/location.module.css +3 -0
  25. package/dist/web/components/form/select/h5.js +4 -0
  26. package/dist/web/components/form/select/index.js +2 -8
  27. package/dist/web/components/form/switch/index.js +3 -2
  28. package/dist/web/components/form/switch/switch.module.css +7 -0
  29. package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -0
  30. package/dist/web/components/form/uploader/uploader.h5.js +41 -17
  31. package/dist/web/components/form/uploader/uploader.pc.js +31 -2
  32. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +36 -14
  33. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +34 -11
  34. package/dist/web/components/form/userOrgSelect/comTool.d.ts +7 -0
  35. package/dist/web/components/form/userOrgSelect/comTool.js +89 -0
  36. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +20 -0
  37. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +259 -0
  38. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
  39. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +153 -0
  40. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
  41. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
  42. package/dist/web/components/form/userOrgSelect/index.d.ts +2 -0
  43. package/dist/web/components/form/userOrgSelect/index.js +17 -0
  44. package/dist/web/components/form/userOrgSelect/userOrgSelect.less +643 -0
  45. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +24 -0
  46. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.js +276 -0
  47. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
  48. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +229 -0
  49. package/dist/web/components/form/userOrgSelect/utils.d.ts +35 -0
  50. package/dist/web/components/form/userOrgSelect/utils.js +72 -0
  51. package/dist/web/components/formdetail/index.css +115 -0
  52. package/dist/web/components/formdetail/index.d.ts +28 -0
  53. package/dist/web/components/formdetail/index.js +170 -0
  54. package/dist/web/components/index.d.ts +3 -0
  55. package/dist/web/components/index.js +3 -0
  56. package/dist/web/components/listView/index.css +35 -5
  57. package/dist/web/components/listView/index.js +92 -68
  58. package/dist/web/components/listView/interface.d.ts +5 -0
  59. package/dist/web/components/lottery/index.js +2 -1
  60. package/dist/web/components/lottery/lotteryUtil.js +1 -0
  61. package/dist/web/components/navigationBar/index.css +21 -29
  62. package/dist/web/components/richText/index.css +1 -0
  63. package/dist/web/components/swiper/index.js +5 -1
  64. package/dist/web/components/wedaVideo/index.js +1 -0
  65. package/dist/web/utils/getUserService.d.ts +17 -0
  66. package/dist/web/utils/getUserService.js +148 -0
  67. package/dist/web/utils/platform.js +2 -0
  68. package/dist/web/weda-ui.css +9 -0
  69. package/package.json +14 -13
  70. package/dist/asset-manifest.json +0 -17
  71. package/dist/index.html +0 -88
  72. package/dist/static/js/bundle.js +0 -963
  73. package/dist/static/js/bundle.js.map +0 -1
  74. package/dist/static/js/main.chunk.js +0 -8841
  75. package/dist/static/js/main.chunk.js.map +0 -1
  76. package/dist/static/js/vendors~main.chunk.js +0 -247885
  77. package/dist/static/js/vendors~main.chunk.js.map +0 -1
  78. package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +0 -627
  79. package/dist/web/components/auth/index.d.ts +0 -10
  80. package/dist/web/components/auth/index.js +0 -37
  81. package/dist/web/utils/events.d.ts +0 -1
  82. package/dist/web/utils/events.js +0 -2
@@ -1,4 +1,5 @@
1
1
  export namespace components {
2
+ export { FormDetail };
2
3
  export { Button };
3
4
  export { Text };
4
5
  export { Container };
@@ -41,6 +42,8 @@ export namespace components {
41
42
  export { Share };
42
43
  export { UserInfo };
43
44
  export { Lottery };
45
+ export { UserTreeSelect };
46
+ export { DepartTreeSelect };
44
47
  }
45
48
  export namespace actions {
46
49
  export { showToast };
@@ -51,6 +54,7 @@ declare namespace _default {
51
54
  export { actions };
52
55
  }
53
56
  export default _default;
57
+ import FormDetail from "./components/formdetail.json";
54
58
  import Button from "./components/button.json";
55
59
  import Text from "./components/text.json";
56
60
  import Container from "./components/container.json";
@@ -93,5 +97,7 @@ import PhoneCode from "./components/wxOpenApi/phoneCode.json";
93
97
  import Share from "./components/wxOpenApi/share.json";
94
98
  import UserInfo from "./components/wxOpenApi/userInfo.json";
95
99
  import Lottery from "./components/lottery.json";
100
+ import UserTreeSelect from "./components/form/userTreeSelect.json";
101
+ import DepartTreeSelect from "./components/form/departTreeSelect.json";
96
102
  import showToast from "./actions/showToast.json";
97
103
  import showModal from "./actions/showModal.json";
@@ -46,7 +46,11 @@ import PhoneCode from './components/wxOpenApi/phoneCode.json';
46
46
  import Share from './components/wxOpenApi/share.json';
47
47
  import UserInfo from './components/wxOpenApi/userInfo.json';
48
48
  import Lottery from './components/lottery.json';
49
+ import UserTreeSelect from './components/form/userTreeSelect.json';
50
+ import DepartTreeSelect from './components/form/departTreeSelect.json';
51
+ import FormDetail from './components/formdetail.json';
49
52
  export const components = {
53
+ FormDetail,
50
54
  Button,
51
55
  Text,
52
56
  Container,
@@ -94,6 +98,8 @@ export const components = {
94
98
  Share,
95
99
  UserInfo,
96
100
  Lottery,
101
+ UserTreeSelect,
102
+ DepartTreeSelect,
97
103
  };
98
104
  export const actions = {
99
105
  showToast,
@@ -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
  // 渲染之后,马上显示
@@ -137,14 +137,22 @@ export default function Calendar({ className, style, initVisible, initValue, con
137
137
  React.createElement("div", { className: blockName + '__control-section-cell' },
138
138
  React.createElement(Select, { appearance: "button", size: controlSectionSize, value: String(year), options: yearSelectOptions(), onChange: (selectYear) => setYear(parseInt(selectYear)) })),
139
139
  React.createElement("div", { className: blockName + '__control-section-cell' },
140
- React.createElement(Select, { appearance: "button", size: controlSectionSize, value: String(month), options: monthSelectOptions(), onChange: (selectMonth) => setMonth(parseInt(selectMonth)) })))) : (React.createElement("div", { className: `${blockName}__current-date` }, `${year} 年 ${month} 月`)))),
140
+ React.createElement(Select, { appearance: "button", size: controlSectionSize, value: String(month), options: monthSelectOptions(), onChange: (selectMonth) => setMonth(parseInt(selectMonth)) })))) : (React.createElement("div", { className: `${blockName}__current-date` },
141
+ year,
142
+ " \u5E74 ",
143
+ month,
144
+ " \u6708")))),
141
145
  React.createElement("div", { className: blockName + '__control_h5', "data-testid": "weda-calendar-control-h5" },
142
146
  visible && (React.createElement("div", { className: blockName + '_prevMonth wedatea2td-icon-arrowleft--line', onClick: () => {
143
147
  // 上一个月
144
148
  setYear(month === 1 ? year - 1 : year);
145
149
  setMonth(month === 1 ? 12 : month - 1);
146
150
  } })),
147
- React.createElement("div", { className: `${blockName}__current-date` }, `${year}年${month}月`),
151
+ React.createElement("div", { className: `${blockName}__current-date` },
152
+ year,
153
+ "\u5E74",
154
+ month,
155
+ "\u6708"),
148
156
  visible && (React.createElement("div", { className: blockName + '_nextMonth wedatea2td-icon-arrowright--line', onClick: () => {
149
157
  // 下一个月
150
158
  setYear(month === 12 ? year + 1 : year);
@@ -16,6 +16,8 @@ export default function Carousel({ className, style, autoplay, circular, vertica
16
16
  // 自动切换
17
17
  useEffect(() => {
18
18
  if (autoplay) {
19
+ // 自动切换
20
+ // eslint-disable-next-line rulesdir/no-timer
19
21
  const timer = setInterval(() => {
20
22
  setIndex(currentIndex + 1);
21
23
  }, interval);
@@ -63,6 +65,7 @@ export default function Carousel({ className, style, autoplay, circular, vertica
63
65
  setSwipeStyle({
64
66
  transform: `translate3d(0, 0, 0)`,
65
67
  });
68
+ // eslint-disable-next-line rulesdir/no-timer
66
69
  setTimeout(() => {
67
70
  setSwipeStyle({
68
71
  transform: vertical
@@ -81,6 +84,7 @@ export default function Carousel({ className, style, autoplay, circular, vertica
81
84
  ? `translate3d(0, -${(to + 2) * 100}%, 0)`
82
85
  : `translate3d(-${(to + 2) * 100}%, 0, 0)`,
83
86
  });
87
+ // eslint-disable-next-line rulesdir/no-timer
84
88
  setTimeout(() => {
85
89
  setSwipeStyle({
86
90
  transform: vertical
@@ -90,7 +90,13 @@ class EchartBase extends AbstractEchartBaseModal {
90
90
  *
91
91
  **/
92
92
  async getSourceData(sourceName = '', methods = '', dataSourceType = '', params) {
93
- var _a;
93
+ var _a, _b, _c;
94
+ if (!sourceName ||
95
+ Object.keys((_a = params === null || params === void 0 ? void 0 : params.dimension) !== null && _a !== void 0 ? _a : {}).length <= 0 ||
96
+ ((_b = params.value) !== null && _b !== void 0 ? _b : []).length <= 0) {
97
+ console.warn('charts 参数不完整');
98
+ return [];
99
+ }
94
100
  try {
95
101
  if (dataSourceType === 'database') {
96
102
  return await callWedaApi({
@@ -109,7 +115,7 @@ class EchartBase extends AbstractEchartBaseModal {
109
115
  methodName: methods,
110
116
  params,
111
117
  });
112
- return (_a = res.result) !== null && _a !== void 0 ? _a : [];
118
+ return (_c = res.result) !== null && _c !== void 0 ? _c : [];
113
119
  }
114
120
  catch (err) {
115
121
  return [];
@@ -5,6 +5,7 @@ import { usePlatform, isInIde } from '../../../utils/platform';
5
5
  import { callDataSource, callConnector } from '../../../utils/tcb';
6
6
  import weui from '../../../utils/weui';
7
7
  import './index.css';
8
+ const formTypeWithInitValue = ['edit', 'read'];
8
9
  /**
9
10
  * 表单容器组件
10
11
  */
@@ -27,7 +28,7 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
27
28
  let initValue = {};
28
29
  if (isDataModel) {
29
30
  // 数据模型查询条件
30
- if (formType === 'edit' && dataSourceName) {
31
+ if (formTypeWithInitValue.includes(formType) && dataSourceName) {
31
32
  initValue = await appCloud.callDataSource({
32
33
  dataSourceName,
33
34
  methodName: 'wedaGetItem',
@@ -37,13 +38,13 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
37
38
  (_a = events === null || events === void 0 ? void 0 : events.onInitValue) === null || _a === void 0 ? void 0 : _a.call(events, initValue);
38
39
  }
39
40
  else {
40
- alertError(platform);
41
+ alertError(platform, '表单容器数据查询失败');
41
42
  }
42
43
  }
43
44
  }
44
45
  else {
45
46
  // 连接器查询条件
46
- if (formType === 'edit' &&
47
+ if (formTypeWithInitValue.includes(formType) &&
47
48
  dataSourceName &&
48
49
  methodGetItem &&
49
50
  paramGetItem) {
@@ -59,13 +60,15 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
59
60
  }
60
61
  }
61
62
  catch (e) {
62
- alertError(platform);
63
+ alertError(platform, '表单容器数据查询失败');
63
64
  }
64
65
  };
65
- if (dataSourceName && formType === 'edit') {
66
+ if (dataSourceName && formTypeWithInitValue.includes(formType)) {
66
67
  if ((isDataModel && _id) ||
67
68
  (!isDataModel && paramGetItem && methodGetItem)) {
68
69
  clearTimeout(timeRef.current);
70
+ // 防抖
71
+ // eslint-disable-next-line rulesdir/no-timer
69
72
  timeRef.current = setTimeout(() => getData(), 100);
70
73
  }
71
74
  }
@@ -93,11 +96,11 @@ export default function Form({ className, contentSlot, style, id, layout, formTy
93
96
  /**
94
97
  * 根据平台不同,展示不同的错误提示消息
95
98
  */
96
- function alertError(platform = 'h5', message = '更新场景下未查询到数据') {
99
+ function alertError(platform = 'h5', message) {
97
100
  if (isInIde())
98
101
  return;
99
102
  if (platform === 'h5') {
100
- weui.toast(message, { className: 'weda-form-toast' });
103
+ weui.toast(message, { duration: 2000, className: 'weda-form-toast' });
101
104
  }
102
105
  else {
103
106
  TeaMessage.error({ content: message });
@@ -322,6 +322,8 @@ export default function MapChoose({ changeLocation, onConfirm, onClose, currentL
322
322
  }
323
323
  else {
324
324
  setSearchValue('');
325
+ // 不知道
326
+ // eslint-disable-next-line rulesdir/no-timer
325
327
  setTimeout(() => {
326
328
  setSearchList([]);
327
329
  }, 300);
@@ -87,6 +87,8 @@ export default function MapView({ APIKEY = '', drag = true, zoom = true, latlng
87
87
  };
88
88
  document.body.appendChild(script);
89
89
  }
90
+ // 不知道
91
+ // eslint-disable-next-line rulesdir/no-timer
90
92
  setTimeout(() => {
91
93
  loadScript();
92
94
  }, 1000);
@@ -10,6 +10,7 @@ import SelectModal from '../../common/selectModal';
10
10
  import { propTypes, defaultProps } from '../../common/propsConfig';
11
11
  import { callDataSource } from '../../../../../utils/tcb';
12
12
  import { inH5IsMobile } from '../../../../../utils/platform';
13
+ import styles from './location.module.css';
13
14
  const { useEffect, useState, useRef } = React;
14
15
  export default function LocationH5(props) {
15
16
  const {
@@ -288,12 +289,13 @@ export default function LocationH5(props) {
288
289
  return status;
289
290
  };
290
291
  const LocationEl = (React.createElement("div", { className: "form-location weda-ui_form-location", "data-testid": "form-location" },
291
- React.createElement("div", { className: "form-location-warp", style: { display: layout === 'vertical' ? 'block' : 'flex' } },
292
+ React.createElement("div", { className: `form-location-warp ${styles.locationDisabled}`, style: { display: layout === 'vertical' ? 'block' : 'flex' } },
292
293
  labelVisible && (React.createElement("div", { className: "form-location-label" },
293
294
  React.createElement("label", null, label),
294
295
  requiredFlag && React.createElement("span", null, "*"))),
295
296
  React.createElement("div", { className: classNames({
296
297
  'form-location-con': true,
298
+ [styles.locationContent]: true,
297
299
  'form-location-con_vertical': layout === 'vertical',
298
300
  }) },
299
301
  React.createElement("img", { src: "https://qcloudimg.tencent-cloud.cn/raw/6542e1ce1dd36a90085b2eb979801df9.png", alt: "" }),
@@ -0,0 +1,3 @@
1
+ .location_locationDisabled__5aEWr .location_locationContent__4BWhz {
2
+ opacity: 0.4;
3
+ }
@@ -188,9 +188,13 @@ defaultRegion, defaultMutiRegion, separator, regionType, onChange, }) {
188
188
  onRegionClick();
189
189
  }
190
190
  else {
191
+ // 轮询直到他不为空
192
+ // eslint-disable-next-line rulesdir/no-timer
191
193
  setTimeout(cb, 200);
192
194
  }
193
195
  };
196
+ // 轮询直到他不为空
197
+ // eslint-disable-next-line rulesdir/no-timer
194
198
  regionTimer = setTimeout(cb, 200);
195
199
  };
196
200
  const onRegionClick = function () {
@@ -174,7 +174,7 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
174
174
  const createDropdown = () => {
175
175
  switch (mode) {
176
176
  case 'selector':
177
- return (React.createElement(PureSelectPc, { size: size, onChange: (value) => {
177
+ return (React.createElement(PureSelectPc, { disabled: disabled, size: size, onChange: (value) => {
178
178
  var _a;
179
179
  onChange && onChange(value);
180
180
  (_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
@@ -222,13 +222,7 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
222
222
  index !== 0 && `${separator}`,
223
223
  label || value))), value: region }));
224
224
  case 'mutiRegion':
225
- return (React.createElement(Cascader, { clearable: true, searchable: true, className: sizeClassName, type: "menu", disabled: disabled, data: regionTree, multiple: false, onChange: onDataChange, onLoad: (regionTree, options) => {
226
- return new Promise((resolve) => {
227
- setTimeout(() => {
228
- resolve();
229
- }, 1000);
230
- });
231
- }, valueRender: (options) => options.map(({ label, value }, index) => (React.createElement(React.Fragment, { key: `${value}-${index}` },
225
+ return (React.createElement(Cascader, { clearable: true, searchable: true, className: sizeClassName, type: "menu", disabled: disabled, data: regionTree, multiple: false, onChange: onDataChange, valueRender: (options) => options.map(({ label, value }, index) => (React.createElement(React.Fragment, { key: `${value}-${index}` },
232
226
  index !== 0 && ',',
233
227
  label || value))), value: mutiRegion }));
234
228
  }
@@ -6,6 +6,7 @@ import { ConfigProvider, Switch as TeaSwitch } from 'tea-component';
6
6
  import { renderDecorator } from '../renderDecorator';
7
7
  import { useSyncValue } from '../../../utils/useSyncValue';
8
8
  import { emptyObject } from '../../../utils/constant';
9
+ import styles from './switch.module.css';
9
10
  export default function Switch({
10
11
  // 系统属性
11
12
  id, className, style, events = emptyObject,
@@ -34,11 +35,11 @@ label = '标题', labelVisible = true, checked: defaultChecked, layout = 'horizo
34
35
  isFlex ? React.createElement("div", { className: "weui-cell__bd" }) : null,
35
36
  React.createElement("div", { className: isFlex ? 'weui-cell__ft' : 'weui-cell__bd' },
36
37
  React.createElement("label", { htmlFor: _id, key: _id, className: "weui-switch-cp" },
37
- !disabled && (React.createElement("input", { id: _id, className: "weui-switch-cp__input", type: "checkbox", checked: checked, disabled: disabled, onChange: (ev) => {
38
+ React.createElement("input", { id: _id, className: `weui-switch-cp__input ${styles.wedaSwitchInput}`, type: "checkbox", checked: checked, disabled: disabled, onChange: (ev) => {
38
39
  const value = ev.target.checked;
39
40
  setChecked(value);
40
41
  events.change({ value }, { orgianalEvent: ev });
41
- } })),
42
+ } }),
42
43
  React.createElement("div", { className: "weui-switch-cp__box" }))))) : (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
43
44
  React.createElement(TeaSwitch, { id: _id, value: checked, disabled: disabled, onChange: (value, context) => {
44
45
  const originEvent = context.event;
@@ -0,0 +1,7 @@
1
+ .switch_wedaSwitchInput__iwKfX.weui-switch-cp__input {
2
+ position: absolute;
3
+ width: 0;
4
+ height: 0;
5
+ opacity: 0;
6
+ overflow: hidden;
7
+ }
@@ -7,6 +7,7 @@ export declare function ImageUploaderH5({ title, maxUploadCount, maxSize, accept
7
7
  export interface SingleImageProps {
8
8
  src: string;
9
9
  deleteBySrc: (url: string) => void;
10
+ disabled: boolean;
10
11
  }
11
12
  export interface H5UploaderProps extends CommonFormPropsType {
12
13
  title?: string;
@@ -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 模式时,仅当数组为空时显示
@@ -118,13 +135,15 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
118
135
  React.createElement(UploaderLabel, { layout: layout, title: title, currentCount: fileIdList.length, maxCount: finalMaxImgCount, requiredFlag: requiredFlag })),
119
136
  React.createElement("div", { className: "weui-uploader__bd" },
120
137
  React.createElement("ul", { className: "weui-uploader__files", id: "uploaderFiles" },
121
- (fileIdList !== null && fileIdList !== void 0 ? fileIdList : []).map((f) => (React.createElement(SingleImage, { key: f, src: f, deleteBySrc: deleteFile }))),
138
+ (fileIdList !== null && fileIdList !== void 0 ? fileIdList : []).map((f) => (React.createElement(SingleImage, { key: f, src: f, deleteBySrc: deleteFile, disabled: disabled }))),
122
139
  uploading && (React.createElement("li", { className: "weui-uploader__file weui-uploader__file_status" },
123
140
  React.createElement("div", { className: "weui-uploader__file-content" },
124
141
  progress,
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;
@@ -141,7 +160,7 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
141
160
  files.forEach((f) => uploadToTcb(f));
142
161
  } }))))))));
143
162
  }
144
- function SingleImage({ src, deleteBySrc }) {
163
+ function SingleImage({ src, deleteBySrc, disabled }) {
145
164
  const [error, setError] = React.useState(false);
146
165
  const cls = classNames({
147
166
  'weui-uploader__file': true,
@@ -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
  }
@@ -170,12 +190,14 @@ function SingleImage({ src, deleteBySrc }) {
170
190
  backgroundImage: `url(${realSrc})`,
171
191
  };
172
192
  const showGallery = () => {
173
- const gallery = weui.gallery(realSrc, {
174
- onDelete: function () {
175
- deleteBySrc(src);
176
- gallery.hide();
177
- },
178
- });
193
+ const gallery = weui.gallery(realSrc, disabled
194
+ ? undefined
195
+ : {
196
+ onDelete: function () {
197
+ deleteBySrc(src);
198
+ gallery.hide();
199
+ },
200
+ });
179
201
  };
180
202
  return (React.createElement("li", { className: cls, style: imgStyle, onClick: showGallery }, error || status ? (React.createElement("div", { className: "weui-uploader__file-content" }, error ? (React.createElement("i", { role: "img", "aria-label": "\u9519\u8BEF", className: "weui-icon-warn" })) : (React.createElement("i", { className: "weui-loading", style: { width: 30, height: 30 } })))) : (false)));
181
203
  }
@@ -187,7 +209,8 @@ const UploaderLabel = ({ layout, title, currentCount, maxCount, requiredFlag, })
187
209
  React.createElement("p", { className: "weui-uploader__title" }, title),
188
210
  React.createElement("div", { className: "weui-uploader__info" },
189
211
  React.createElement("span", { id: "uploadCount" }, currentCount),
190
- `/${maxCount}`)),
212
+ "/",
213
+ maxCount)),
191
214
  requiredFlag && React.createElement("label", { className: "weda-formcells__flag" }, "*"))));
192
215
  }
193
216
  return (React.createElement("div", { className: "weda-formcells__label weui-cell" },
@@ -196,5 +219,6 @@ const UploaderLabel = ({ layout, title, currentCount, maxCount, requiredFlag, })
196
219
  requiredFlag && React.createElement("label", { className: "weda-formcells__flag" }, "*")),
197
220
  React.createElement("div", { className: "weui-uploader__info" },
198
221
  React.createElement("span", { id: "uploadCount" }, currentCount),
199
- `/${maxCount}`)));
222
+ "/",
223
+ maxCount)));
200
224
  };
@@ -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 = [];
@@ -138,7 +166,7 @@ export function UploaderPCInner(props) {
138
166
  fileIDList.map((d) => (React.createElement("div", { className: "_weda-fn-upload-result__item", key: d },
139
167
  React.createElement(TcbImage, { fileID: d }),
140
168
  React.createElement("div", { className: "_weda-fn-upload-result__op" },
141
- React.createElement(Button, { onClick: () => deleteHandle(d), className: `${CLASS_PREFIX}__btn` }, "\u5220\u9664"))))),
169
+ React.createElement(Button, { disabled: disabled, onClick: () => deleteHandle(d), className: `${CLASS_PREFIX}__btn` }, "\u5220\u9664"))))),
142
170
  uploading && (React.createElement("div", { className: "_weda-fn-upload-result__item" },
143
171
  React.createElement("div", { className: "_weda-fn-upload-result__status", key: "_place_image" },
144
172
  React.createElement(Icon, { type: "loading" }),
@@ -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) {