@cloudbase/weda-ui 3.17.2 → 3.17.4

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 (42) hide show
  1. package/dist/configs/components/container.js +2 -1
  2. package/dist/configs/components/wd-ad.js +40 -0
  3. package/dist/configs/components/wd-calendar.d.ts +21 -1
  4. package/dist/configs/components/wd-calendar.js +40 -1
  5. package/dist/configs/components/wd-side-tab.d.ts +13 -1
  6. package/dist/configs/components/wd-side-tab.js +30 -1
  7. package/dist/configs/components/wd-tabbar.d.ts +15 -2
  8. package/dist/configs/components/wd-tabbar.js +36 -2
  9. package/dist/configs/components/wd-top-tab.d.ts +12 -0
  10. package/dist/configs/components/wd-top-tab.js +29 -0
  11. package/dist/configs/components/web-view.js +1 -1
  12. package/dist/configs/index.d.ts +122 -8
  13. package/dist/style/weda-ui.min.css +2 -2
  14. package/dist/web/components/chart/common/core/eChartBar.d.ts +1 -1
  15. package/dist/web/components/chart/common/core/eChartBar.js +10 -9
  16. package/dist/web/components/chart/common/core/eChartLine.d.ts +1 -1
  17. package/dist/web/components/chart/common/core/eChartLine.js +10 -9
  18. package/dist/web/components/chart/common/core/eChartPie.d.ts +2 -2
  19. package/dist/web/components/chart/common/core/eChartPie.js +4 -3
  20. package/dist/web/components/form/select/allTimePicker/index.css +9 -9
  21. package/dist/web/components/form/select/allTimePicker/index.d.ts +1 -1
  22. package/dist/web/components/form/select/allTimePicker/index.js +27 -37
  23. package/dist/web/components/form/select/dropdown-select/h5.js +5 -5
  24. package/dist/web/components/form/select/dropdown-select/index.css +15 -20
  25. package/dist/web/components/form/select/index.css +8 -20
  26. package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +7 -13
  27. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +22 -28
  28. package/dist/web/components/form/uploader/upload/index.d.ts +1 -1
  29. package/dist/web/components/form/uploader/upload/index.js +4 -3
  30. package/dist/web/components/form/uploader/uploader.h5.js +2 -3
  31. package/dist/web/components/form/uploader/uploader.pc.js +1 -1
  32. package/dist/web/components/wd-ad/wd-ad.d.ts +2 -2
  33. package/dist/web/components/wd-ad/wd-ad.js +11 -2
  34. package/dist/web/components/wd-select/select/selectUI.js +18 -18
  35. package/dist/web/components/wd-select/wd-select.css +6 -6
  36. package/dist/web/components/wd-select/wd-select.js +2 -2
  37. package/dist/web/components/wd-select-multiple/wd-select-multiple.css +11 -26
  38. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +2 -2
  39. package/dist/web/components/wd-table/components/FieldRender/index.js +1 -1
  40. package/dist/web/components/wd-upload-image/wd-upload-image.js +1 -1
  41. package/dist/web/components/web-view/web-view.js +18 -28
  42. package/package.json +1 -1
@@ -34,10 +34,7 @@ export function SelectPickerH5({ updateValue, selectedValue, options, isTurnPage
34
34
  const dealSelectedValue = (value) => {
35
35
  const index = selectedValueCache.findIndex((v) => v === value);
36
36
  if (index > -1) {
37
- return [
38
- ...selectedValueCache.slice(0, index),
39
- ...selectedValueCache.slice(index + 1),
40
- ];
37
+ return [...selectedValueCache.slice(0, index), ...selectedValueCache.slice(index + 1)];
41
38
  }
42
39
  return [...selectedValueCache, value];
43
40
  };
@@ -59,9 +56,7 @@ export function SelectPickerH5({ updateValue, selectedValue, options, isTurnPage
59
56
  setSelectedValueCache(Array.isArray(selectedValue) ? selectedValue : [selectedValue]);
60
57
  };
61
58
  const confirm = () => {
62
- updateValue(selectedValueCache
63
- .map((v) => options.find((item) => item.value === v))
64
- .filter((v) => !!v));
59
+ updateValue(selectedValueCache.map((v) => options.find((item) => item.value === v)).filter((v) => !!v));
65
60
  getIsShow();
66
61
  };
67
62
  const contentScroll = () => {
@@ -109,22 +104,21 @@ export function SelectPickerH5({ updateValue, selectedValue, options, isTurnPage
109
104
  } }))] }), _jsx("button", { className: "weda-ui-custom-search__btn-cancle", onClick: () => {
110
105
  setInputFocus(false);
111
106
  setSearchValue('');
112
- }, children: "\u53D6\u6D88" })] }), status === Status.ALl_EMPTY ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { className: "weda-ui-custom-picker__cloumns weda-ui-custom-picker__cloumns--select-multiple ", style: {
107
+ }, children: "\u53D6\u6D88" })] }), status === Status.ALl_EMPTY ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { className: "weda-ui-custom-picker__columns weda-ui-custom-picker__columns--select-multiple ", style: {
113
108
  height: inputFocus ? 'calc(100vh - 160px)' : '280px',
114
- }, onScroll: contentScroll, ref: contentRef, children: [_jsxs("ul", { className: "weda-ui-custom-picker__cloumn", style: {
109
+ }, onScroll: contentScroll, ref: contentRef, children: [_jsxs("ul", { className: "weda-ui-custom-picker__column", style: {
115
110
  height: inputFocus ? 'calc(100vh - 190px)' : '250px',
116
111
  }, children: [options === null || options === void 0 ? void 0 : options.map((item, index) => {
117
112
  // is-selected 选中态
118
113
  // is-disabled 禁用态
119
- const itemCls = classNames('weda-ui-custom-picker__cloumn-item', {
114
+ const itemCls = classNames('weda-ui-custom-picker__column-item', {
120
115
  'is-selected': checkIndex(item),
121
116
  'is-disabled': index === -1 || item.disabled,
122
117
  });
123
118
  return (_jsx("li", { className: itemCls, onClick: () => {
124
119
  if (item.disabled)
125
120
  return;
126
- if (selectedValueCache &&
127
- selectedValueCache.length > 49) {
121
+ if (selectedValueCache && selectedValueCache.length > 49) {
128
122
  if (selectedValueCache.indexOf(item.value) !== -1) {
129
123
  // updateValue(item);
130
124
  setSelectedValueCache(dealSelectedValue(item.value));
@@ -141,6 +135,6 @@ export function SelectPickerH5({ updateValue, selectedValue, options, isTurnPage
141
135
  setSelectedValueCache(dealSelectedValue(item.value));
142
136
  setInd(Math.random());
143
137
  }
144
- }, children: _jsx("p", { className: 'weda-ui-custom-picker__cloumn-item-text-multiple', children: item.label }) }, index));
138
+ }, children: _jsx("p", { className: 'weda-ui-custom-picker__column-item-text-multiple', children: item.label }) }, index));
145
139
  }), status === Status.LOADING && (_jsx("li", { children: _jsx(Loading, {}) }, 'loading')), status === Status.ERROR && (_jsx("li", { children: _jsx(Retry, { reTry: reTry }) }, 'retry')), status === Status.EMPTY && (_jsx("li", { children: _jsx(Empty, {}) }, 'empty'))] }), addRelationButton] }))] })] })] }) })) : null;
146
140
  }
@@ -77,25 +77,23 @@
77
77
  transform: translateX(0);
78
78
  }
79
79
 
80
- .weda-ui-custom-search.is-focused
81
- .weda-ui-custom-search-box__search-placeholder {
80
+ .weda-ui-custom-search.is-focused .weda-ui-custom-search-box__search-placeholder {
82
81
  display: none;
83
82
  }
84
83
 
85
- .weda-ui-custom-picker__cloumn-item.is-current {
84
+ .weda-ui-custom-picker__column-item.is-current {
86
85
  color: rgba(0, 0, 0, 0.9);
87
86
  }
88
87
 
89
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
90
- .weda-ui-custom-picker__cloumn-item {
88
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple .weda-ui-custom-picker__column-item {
91
89
  height: 56px;
92
90
  justify-content: flex-start;
93
91
  color: rgba(0, 0, 0, 0.9);
94
92
  position: relative;
95
93
  }
96
94
 
97
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
98
- .weda-ui-custom-picker__cloumn-item::before {
95
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple
96
+ .weda-ui-custom-picker__column-item::before {
99
97
  content: '';
100
98
  position: absolute;
101
99
  bottom: 0;
@@ -105,12 +103,12 @@
105
103
  transform: scaleY(0.5);
106
104
  }
107
105
 
108
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
109
- .weda-ui-custom-picker__cloumn-item.is-selected {
106
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple
107
+ .weda-ui-custom-picker__column-item.is-selected {
110
108
  color: rgba(0, 0, 0, 0.9);
111
109
  }
112
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
113
- .weda-ui-custom-picker__cloumn-item::after {
110
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple
111
+ .weda-ui-custom-picker__column-item::after {
114
112
  content: '';
115
113
  width: 20px;
116
114
  height: 20px;
@@ -121,8 +119,8 @@
121
119
  left: 5px;
122
120
  }
123
121
 
124
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
125
- .weda-ui-custom-picker__cloumn-item.is-selected::after {
122
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple
123
+ .weda-ui-custom-picker__column-item.is-selected::after {
126
124
  content: '';
127
125
  width: 21px;
128
126
  height: 21px;
@@ -137,24 +135,23 @@
137
135
  background-color: var(--wd-color-brand, #0052d9);
138
136
  }
139
137
 
140
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple
141
- .weda-ui-custom-picker__cloumn-item.is-disabled {
138
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple
139
+ .weda-ui-custom-picker__column-item.is-disabled {
142
140
  color: rgba(0, 0, 0, 0.26);
143
141
  }
144
142
 
145
143
  /* 下拉选择类型 */
146
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple {
144
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple {
147
145
  padding: 0 16px;
148
146
  height: 280px;
149
147
  }
150
148
 
151
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple::before,
152
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple::after {
149
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple::before,
150
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple::after {
153
151
  display: none;
154
152
  }
155
153
 
156
- .weda-ui-custom-picker__cloumns--select-multiple
157
- .weda-ui-custom-picker__cloumn {
154
+ .weda-ui-custom-picker__columns--select-multiple .weda-ui-custom-picker__column {
158
155
  height: 250px;
159
156
  }
160
157
 
@@ -174,7 +171,7 @@
174
171
  caret-color: #000000;
175
172
  }
176
173
 
177
- .weda-ui-custom-picker__cloumn-item-text-multiple {
174
+ .weda-ui-custom-picker__column-item-text-multiple {
178
175
  overflow: hidden;
179
176
  text-overflow: ellipsis;
180
177
  white-space: nowrap;
@@ -240,10 +237,7 @@
240
237
  no-repeat center;
241
238
  }
242
239
 
243
- .is-disabled
244
- .wedatea2td-dropdown-link
245
- .wedatea2td-dropdown__value
246
- .wedatea2td-icon-arrowdown,
240
+ .is-disabled .wedatea2td-dropdown-link .wedatea2td-dropdown__value .wedatea2td-icon-arrowdown,
247
241
  .is-disabled .wedatea2td-dropdown__header .wedatea2td-icon-arrowdown {
248
242
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+Y2hldnJvbi1kb3duPC90aXRsZT4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJJY29ucyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIyNC4wMDAwMDAsIC05NTEuMDAwMDAwKSI+CiAgICAgICAgICAgIDxnIGlkPSJjaGV2cm9uLWRvd24iIHRyYW5zZm9ybT0idHJhbnNsYXRlKDIyNC4wMDAwMDAsIDk1MS4wMDAwMDApIj4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNiwwIEwxNiwxNiBMMCwxNiBMMCwwIEwxNiwwIFoiIGlkPSLnn6nlvaIiIG9wYWNpdHk9IjAuNjAwMDAwMDI0Ij48L3BhdGg+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNC40NTk2MTM1Niw1LjU0MDQwNTI3IEw3Ljk5OTk5NDI4LDkuMDgwNzg1NzUgTDExLjU0MDM3NDgsNS41NDA0MDUyNyBMMTIuNDU5NjEzOCw2LjQ1OTY0NDA4IEw3Ljk5OTk5NDI4LDEwLjkxOTI2MzQgTDMuNTQwMzc0NzYsNi40NTk2NDQwOCBMNC40NTk2MTM1Niw1LjU0MDQwNTI3IFoiIGlkPSLot6/lvoQtNC0oU3Ryb2tlKSIgZmlsbD0iIzAwMDAwMCI+PC9wYXRoPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
249
243
  }
@@ -281,13 +275,13 @@
281
275
  margin-right: 5px;
282
276
  }
283
277
 
284
- .weda-ui-custom-picker__cloumns {
278
+ .weda-ui-custom-picker__columns {
285
279
  display: flex;
286
280
  flex-direction: column;
287
281
  }
288
- .weda-ui-custom-picker__cloumn {
282
+ .weda-ui-custom-picker__column {
289
283
  width: 100%;
290
284
  }
291
- .weda-ui-custom-picker__cloumns .wd-add-relation-button-wrap {
285
+ .weda-ui-custom-picker__columns .wd-add-relation-button-wrap {
292
286
  margin: 10px 0;
293
287
  }
@@ -5,11 +5,11 @@ interface UploadProps extends EventsType {
5
5
  name?: DataType['name'];
6
6
  value?: DataType['value'] | string;
7
7
  acceptTypes?: any;
8
- capture?: any;
9
8
  disabled?: boolean;
10
9
  readOnly?: boolean;
11
10
  uploadPath?: string;
12
11
  multiple?: boolean;
12
+ sourceType?: DataType['sourceType'];
13
13
  isCompressBeforeUpload?: DataType['isCompressBeforeUpload'];
14
14
  compressQuality?: DataType['compressQuality'];
15
15
  compressedHeight?: DataType['compressedHeight'];
@@ -5,7 +5,7 @@ import { upload as uploadAction, checkBeforeUpload, getPreviewFileMap, getInitTe
5
5
  import { errorHandler } from '../../../../utils/error';
6
6
  import { isNil } from '../../../../utils/lodash';
7
7
  import { toBase64Uri } from '../../../../utils/file2base64';
8
- import { randomStr } from '../../../../utils/platform';
8
+ import { randomStr, browserEnv } from '../../../../utils/platform';
9
9
  // 默认图片类型
10
10
  export const IMAGE_TYPES = [
11
11
  'image/jpg',
@@ -17,7 +17,7 @@ export const IMAGE_TYPES = [
17
17
  'image/gif',
18
18
  ];
19
19
  export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
20
- const { maxUploadCount, acceptTypes, multiple, maxSize, capture, disabled, readOnly, name, isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, events, onChange, callbacks, setUploadHandle, value: _value, } = props;
20
+ const { maxUploadCount, acceptTypes, multiple, maxSize, disabled, readOnly, name, isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, events, onChange, callbacks, setUploadHandle, value: _value, sourceType, } = props;
21
21
  const inputRef = React.useRef(null);
22
22
  const [inputId, setInputId] = useState(() => {
23
23
  return getUuid();
@@ -196,5 +196,6 @@ export const Upload = forwardRef(function Upload({ children, ...props }, ref) {
196
196
  }
197
197
  return uploadHandle;
198
198
  }, [deleteFile, onClick, previewFile, setUploadHandle, uploadInstance]);
199
- return (_jsxs(React.Fragment, { children: [_jsx("input", { ref: inputRef, name: name, disabled: disabled || readOnly, type: "file", onClick: (e) => e.stopPropagation(), style: { display: 'none' }, accept: accepts, multiple: multiple, onChange: uploadChange, ...(capture != null ? { capture } : {}) }, inputId), children] }));
199
+ const capture = sourceType === 'camera' ? true : null;
200
+ return (_jsxs(React.Fragment, { children: [_jsx("input", { ref: inputRef, name: name, disabled: disabled || readOnly, type: "file", onClick: (e) => e.stopPropagation(), style: { display: 'none' }, accept: accepts, multiple: multiple && !(browserEnv().android && browserEnv().weixin), onChange: uploadChange, ...(capture != null ? { capture } : {}) }, inputId), children] }));
200
201
  });
@@ -2,7 +2,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import * as React from 'react';
3
3
  import weui from '../../../utils/weui';
4
4
  import classNames from '../../../utils/classnames';
5
- import { browserEnv } from '../../../utils/platform';
6
5
  import { IMAGE_TYPES, encodeConvert } from './uploader.pc';
7
6
  import { useTempUrl } from '../../../utils/hooks/use-cloud-id-temp-url';
8
7
  import { Upload } from './upload';
@@ -41,8 +40,8 @@ export function ImageUploaderH5(props) {
41
40
  outSetUploadHandle(uploadHandle);
42
41
  }
43
42
  }, [outSetUploadHandle]);
44
- const multiple = !single && !(browserEnv().android && browserEnv().weixin);
45
- return (_jsx("div", { className: cls, id: id, style: style, children: _jsxs("div", { className: classNames('weui-uploader weui-cells weui-cells_form weda-formcells', layout, layoutCls), children: [_jsx("div", { className: classNames('weui-uploader__hd', layout), children: _jsx(UploaderLabel, { layout: layout, label: label, labelVisible: labelVisible, currentCount: tempFile.length, maxCount: finalMaxImgCount, requiredFlag: requiredFlag }) }), _jsx("div", { className: "weui-uploader__bd", children: _jsx(Upload, { ...props, acceptTypes: acceptTypes, events: events, capture: sourceType === 'camera' ? 'capture' : null, multiple: multiple, maxSize: maxSize, maxUploadCount: maxUploadCount, disabled: disabled, onChange: onChange, callbacks: callbacks, ref: uploadRef, value: defaultValue, setUploadHandle: setUploadRef, children: _jsxs("ul", { className: "weui-uploader__files", id: "uploaderFiles", children: [(_a = (tempFile !== null && tempFile !== void 0 ? tempFile : [])) === null || _a === void 0 ? void 0 : _a.map((f) => (_jsx(SingleImage, { tempFile: f, deleteBySrc: (file) => {
43
+ const multiple = !single;
44
+ return (_jsx("div", { className: cls, id: id, style: style, children: _jsxs("div", { className: classNames('weui-uploader weui-cells weui-cells_form weda-formcells', layout, layoutCls), children: [_jsx("div", { className: classNames('weui-uploader__hd', layout), children: _jsx(UploaderLabel, { layout: layout, label: label, labelVisible: labelVisible, currentCount: tempFile.length, maxCount: finalMaxImgCount, requiredFlag: requiredFlag }) }), _jsx("div", { className: "weui-uploader__bd", children: _jsx(Upload, { ...props, acceptTypes: acceptTypes, events: events, multiple: multiple, maxSize: maxSize, maxUploadCount: maxUploadCount, disabled: disabled, onChange: onChange, callbacks: callbacks, ref: uploadRef, value: defaultValue, setUploadHandle: setUploadRef, sourceType: sourceType, children: _jsxs("ul", { className: "weui-uploader__files", id: "uploaderFiles", children: [(_a = (tempFile !== null && tempFile !== void 0 ? tempFile : [])) === null || _a === void 0 ? void 0 : _a.map((f) => (_jsx(SingleImage, { tempFile: f, deleteBySrc: (file) => {
46
45
  var _a;
47
46
  (_a = uploadRef === null || uploadRef === void 0 ? void 0 : uploadRef.current) === null || _a === void 0 ? void 0 : _a.delete({ cloudId: file.cloudId });
48
47
  }, disabled: disabled || readOnly || sourceType === 'album', imgTypeCls: imgTypeCls }, f === null || f === void 0 ? void 0 : f.cloudId))), tempFile.length < 1 && readOnly && _jsx(_Fragment, { children: "-" }), showAdd && !readOnly && (_jsx("li", { className: `weui-uploader__input-box ${imgTypeCls}`, children: !disabled && sourceType !== 'album' && (_jsx("span", { onClick: () => {
@@ -45,7 +45,7 @@ export function UploaderPCInner(props) {
45
45
  tips && (extraProps['title'] = tips);
46
46
  maxSize && (extraProps['maxSize'] = maxSize * 1024 * 1024);
47
47
  const hasActions = !uploading && !readOnly && !(disabled || sourceType === 'camera');
48
- return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(Upload, { ...extraProps, ref: uploadRef, value: defaultValue, setUploadHandle: setUploadRef, children: _jsxs("div", { className: "_weda-fn-upload-result", children: [tempFile === null || tempFile === void 0 ? void 0 : tempFile.map((d, index) => (_jsx("div", { className: `_weda-fn-upload-result__item ${imgTypeCls}`, children: _jsx(TcbImage, { index: index, allFile: tempFile, tempFile: d, imgTypeCls: imgTypeCls, isZoom: true, previewIcon: "td:browse", portalContainer: portalContainer, actions: hasActions && (_jsx(WdIcon, { className: `${CLASS_PREFIX}__image-actions-delete`, name: "td:delete", onClick: () => deleteHandle(d), size: "sm" })) }) }, d.cloudId))), _jsxs("div", { className: `${CLASS_PREFIX}__input-box`, children: [readOnly && tempFile.length < 1 && _jsx("div", { children: "-" }), sourceType === 'camera' || (disabled && !readOnly) ? (_jsx("div", { className: `_weda-fn-upload-result__item wedatea2td-disabled weda-uploader-btn__box ${imgTypeCls}`, children: _jsxs("div", { className: "_weda-fn-upload-result__status", children: [_jsx("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }), _jsx("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset", children: btnTitle })] }) })) : (((!single && tempFile.length < maxUploadCount) || (single && tempFile.length < 1 && !uploading)) &&
48
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(Upload, { ...extraProps, ref: uploadRef, value: defaultValue, setUploadHandle: setUploadRef, sourceType: sourceType, children: _jsxs("div", { className: "_weda-fn-upload-result", children: [tempFile === null || tempFile === void 0 ? void 0 : tempFile.map((d, index) => (_jsx("div", { className: `_weda-fn-upload-result__item ${imgTypeCls}`, children: _jsx(TcbImage, { index: index, allFile: tempFile, tempFile: d, imgTypeCls: imgTypeCls, isZoom: true, previewIcon: "td:browse", portalContainer: portalContainer, actions: hasActions && (_jsx(WdIcon, { className: `${CLASS_PREFIX}__image-actions-delete`, name: "td:delete", onClick: () => deleteHandle(d), size: "sm" })) }) }, d.cloudId))), _jsxs("div", { className: `${CLASS_PREFIX}__input-box`, children: [readOnly && tempFile.length < 1 && _jsx("div", { children: "-" }), sourceType === 'camera' || (disabled && !readOnly) ? (_jsx("div", { className: `_weda-fn-upload-result__item wedatea2td-disabled weda-uploader-btn__box ${imgTypeCls}`, children: _jsxs("div", { className: "_weda-fn-upload-result__status", children: [_jsx("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }), _jsx("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset", children: btnTitle })] }) })) : (((!single && tempFile.length < maxUploadCount) || (single && tempFile.length < 1 && !uploading)) &&
49
49
  !readOnly && (
50
50
  // single 模式时,当数组为空且不在上传文件过程中时显示
51
51
  _jsxs("div", {
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { CommonPropsType } from '../../types';
3
3
  import type { DataType } from '../../../configs/components/wd-ad';
4
4
  /**
5
5
  * 广告组件,web 端仅用于编辑器展示
6
6
  */
7
- export declare function WdAd(props: WdAdProps): JSX.Element;
7
+ export declare const WdAd: React.ForwardRefExoticComponent<WdAdProps & React.RefAttributes<unknown>>;
8
8
  export interface WdAdProps extends CommonPropsType, DataType {
9
9
  }
@@ -1,19 +1,28 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import { forwardRef } from 'react';
4
+ import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
2
5
  import { useConfig } from '../../utils/config-context';
3
6
  import { BannerAd, VideoAd, GridAd } from './ad-view';
4
7
  import { Bubble, ConfigProvider } from 'tea-component';
5
8
  import { useCanPreview } from '../../utils/hooks/useCanPreview';
6
9
  import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
10
+ import { alertErrorMessage } from '../../utils/platform';
7
11
  /**
8
12
  * 广告组件,web 端仅用于编辑器展示
9
13
  */
10
- export function WdAd(props) {
14
+ export const WdAd = forwardRef(function WdAd(props, ref) {
11
15
  const { className, id, style, adType: _adType = X_RUNTIME_DEFAULT.adType, gridCount: _gridCount = X_RUNTIME_DEFAULT.gridCount, } = props;
12
16
  const adType = ['banner', 'video', 'grid', 'rewardedVideoAd'].includes(_adType) ? _adType : 'banner';
13
17
  const gridCount = _gridCount == 8 ? 8 : 5;
14
18
  const { classPrefix } = useConfig();
15
19
  const canPreview = useCanPreview();
20
+ useSetWidgetApi(() => ({
21
+ show: () => {
22
+ alertErrorMessage({ message: '该组件必须在小程序真实环境使用才能够看到实际效果。' });
23
+ },
24
+ }), [], ref);
16
25
  if (!canPreview)
17
26
  return null;
18
27
  return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(Bubble, { placement: "auto", openDelay: 300, content: _jsxs(_Fragment, { children: ["\u8BE5\u7EC4\u4EF6\u5FC5\u987B\u5728\u5C0F\u7A0B\u5E8F\u771F\u5B9E\u73AF\u5883\u4F7F\u7528\u624D\u80FD\u591F\u770B\u5230\u5B9E\u9645\u6548\u679C\u3002", _jsx("br", {}), "\u8BF7\u9075\u5FAA\u5FAE\u4FE1\u5E7F\u544A\u7EC4\u4EF6\u5E94\u7528\u89C4\u8303\uFF0C\u5426\u5219\u53EF\u80FD\u5BFC\u81F4\u5C0F\u7A0B\u5E8F\u5BA1\u6838\u5931\u8D25\u3002"] }), children: _jsxs("div", { className: `${classPrefix}-ad ${classPrefix}-ad--${adType} ${className}`, id: id, style: style, children: [adType === 'banner' && _jsx(BannerAd, {}), ['rewardedVideoAd', 'video'].includes(adType) && _jsx(VideoAd, {}), adType === 'grid' && _jsx(GridAd, { gridCount: gridCount })] }) }) }));
19
- }
28
+ });
@@ -12,16 +12,16 @@ import AllEmpty from '../../form/select/status/allEmpty';
12
12
  import { X_RUNTIME_DEFAULT } from '../../../../configs/type-utils/x-runtime-default';
13
13
  import '../style';
14
14
  const OptionList = ({ options, inputFocus, currentSelected, optionClick, bottomTips, onScrollBottom }) => {
15
- return (_jsxs(List, { className: "weda-ui-custom-picker__cloumn", style: {
15
+ return (_jsxs(List, { className: "weda-ui-custom-picker__column", style: {
16
16
  height: inputFocus ? 'calc(100vh - 190px)' : '250px',
17
17
  }, onScrollBottom: onScrollBottom, children: [options === null || options === void 0 ? void 0 : options.map((item, index) => {
18
18
  // is-selected 选中态
19
- // is-disabled 禁用态,该状态备用,暂时不让生效index === -1
20
- const itemCls = classNames('weda-ui-custom-picker__cloumn-item', {
19
+ // is-disabled 禁用态
20
+ const itemCls = classNames('weda-ui-custom-picker__column-item', {
21
21
  'is-selected': currentSelected.find((i) => i.value === item.value),
22
22
  'is-disabled': item.disabled,
23
23
  });
24
- return (_jsx(List.Item, { className: itemCls, onClick: (e) => optionClick(item, e), children: _jsx("p", { className: 'weda-ui-custom-picker__cloumn-item-text', children: item.text || item.label }) }, index));
24
+ return (_jsx(List.Item, { className: itemCls, onClick: (e) => optionClick(item, e), children: _jsx("p", { className: 'weda-ui-custom-picker__column-item-text', children: item.text || item.label }) }, index));
25
25
  }), bottomTips && (_jsx(List.Item, { children: _jsx("div", { className: "weda-ui-custom-picker__status weda-ui-custom-picker__status--empty", children: bottomTips }) }))] }));
26
26
  };
27
27
  const getSelectedItem = (options = [], value) => {
@@ -31,9 +31,9 @@ const getSelectedItem = (options = [], value) => {
31
31
  function SelectH5(props) {
32
32
  const { placeholder, name, disabled, footer, options = [], value, onChange, overlayClassName, searchable, bottomTips, onSearch, onOpen, onScrollBottom, mode, readValue, popupContainer, searchPlaceholder, filterable, onBlur, onFocus, } = props;
33
33
  const isMultiple = mode === 'multiple';
34
- const customPickerCls = classNames('weda-ui-custom-picker__cloumns', {
35
- 'weda-ui-custom-picker__cloumns--select-multiple': isMultiple,
36
- 'weda-ui-custom-picker__cloumns--select': !isMultiple,
34
+ const customPickerCls = classNames('weda-ui-custom-picker__columns', {
35
+ 'weda-ui-custom-picker__columns--select-multiple': isMultiple,
36
+ 'weda-ui-custom-picker__columns--select': !isMultiple,
37
37
  [`${overlayClassName}`]: true,
38
38
  });
39
39
  const [visible, setVisible] = useState(false);
@@ -133,24 +133,24 @@ function SelectH5(props) {
133
133
  else {
134
134
  setVisible(false);
135
135
  }
136
- }, onOk: handleOk, header: inputFocus, className: `${classPrefix}-cascader-modal`, okButtonVisible: isMultiple, popupContainer: popupContainer, children: [searchable && renderSearch(), _jsx("div", { className: `${classPrefix}-custom-view-content`, children: !bottomTips && !(customOptions === null || customOptions === void 0 ? void 0 : customOptions.length) ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { children: [_jsx("div", { className: customPickerCls, "data-testid": "weda-ui-custom-picker__cloumns", style: {
136
+ }, onOk: handleOk, header: inputFocus, className: `${classPrefix}-cascader-modal`, okButtonVisible: isMultiple, popupContainer: popupContainer, children: [searchable && renderSearch(), _jsx("div", { className: `${classPrefix}-custom-view-content`, children: !bottomTips && !(customOptions === null || customOptions === void 0 ? void 0 : customOptions.length) ? (_jsx(AllEmpty, { height: inputFocus ? 'calc(100vh - 160px)' : '280px' })) : (_jsxs("div", { children: [_jsx("div", { className: customPickerCls, "data-testid": "weda-ui-custom-picker__columns", style: {
137
137
  height: inputFocus ? 'calc(100vh - 160px)' : '280px',
138
138
  }, children: _jsx(OptionList, { onScrollBottom: onScrollBottom, options: customOptions, inputFocus: inputFocus, currentSelected: currentSelected, optionClick: optionClick, bottomTips: bottomTips }) }), footer] })) })] })] }));
139
139
  }
140
140
  export function SelectUI(props) {
141
- const { placeholder, size, disabled, onChange, onSearch, searchable, options = [], value, footer, overlayClassName, onOpen, onScrollBottom, tips, bottomTips, mode, format, readOnly, setAllOption, listHeight, listWidth, popupContainer, searchPlaceholder = '搜索选项', matchButtonWidth = true, enableRelationTag = X_RUNTIME_DEFAULT.enableRelationTag, ...restProps } = props;
141
+ const { placeholder, size, disabled, onChange, onSearch, searchable, options = [], value, footer, overlayClassName, onOpen, onScrollBottom, tips, bottomTips, mode, format, readOnly, listHeight, listWidth, popupContainer, searchPlaceholder = '搜索选项', matchButtonWidth = true, enableRelationTag = X_RUNTIME_DEFAULT.enableRelationTag, ...restProps } = props;
142
142
  const platform = usePlatform();
143
- const [currentOption] = useSyncValue((options === null || options === void 0 ? void 0 : options.map(({ label, value }) => ({ label, value }))) || [], isObjectEqual);
144
- // 更新option,从而更新最新的选项值
145
- useEffect(() => {
146
- if (setAllOption) {
147
- setAllOption(currentOption);
148
- }
149
- }, [currentOption, setAllOption]);
150
143
  const isMultiple = mode === 'multiple';
144
+ const [selectedItem, setSelectedItem] = useState([]);
145
+ useEffect(() => {
146
+ // 缓存展示的选中项
147
+ setSelectedItem((selectItem) => {
148
+ const newSelectItem = getSelectedItem(options, value);
149
+ return (newSelectItem === null || newSelectItem === void 0 ? void 0 : newSelectItem.length) ? newSelectItem : selectItem;
150
+ });
151
+ }, [options, value]);
151
152
  const readValue = useMemo(() => {
152
153
  var _a, _b;
153
- const selectedItem = getSelectedItem(options, value);
154
154
  if (isMultiple) {
155
155
  return selectedItem
156
156
  .map((i) => textToString(i === null || i === void 0 ? void 0 : i.label) || textToString(i.value) || textToString(value))
@@ -159,7 +159,7 @@ export function SelectUI(props) {
159
159
  else {
160
160
  return textToString((_a = selectedItem[0]) === null || _a === void 0 ? void 0 : _a.label) || textToString((_b = selectedItem[0]) === null || _b === void 0 ? void 0 : _b.value) || textToString(value);
161
161
  }
162
- }, [isMultiple, options, value]);
162
+ }, [isMultiple, selectedItem, value]);
163
163
  const render = () => {
164
164
  if (platform === 'h5') {
165
165
  return _jsx(SelectH5, { ...props, readValue: readValue, searchPlaceholder: searchPlaceholder });
@@ -174,21 +174,21 @@
174
174
  min-height: 105px;
175
175
  }
176
176
  /* h5端关联下拉样式 */
177
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select.wd-relation-select-overlay
178
- .weda-ui-custom-picker__cloumn-item {
177
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select.wd-relation-select-overlay
178
+ .weda-ui-custom-picker__column-item {
179
179
  height: auto;
180
180
  }
181
- .wd-relation-select-overlay .weda-ui-custom-picker__cloumn-item-text {
181
+ .wd-relation-select-overlay .weda-ui-custom-picker__column-item-text {
182
182
  margin: 0;
183
183
  }
184
- .weda-ui-custom-picker__cloumns.wd-relation-select-overlay {
184
+ .weda-ui-custom-picker__columns.wd-relation-select-overlay {
185
185
  overflow: auto;
186
186
  }
187
- .weda-ui-custom-picker__cloumns.wd-relation-select-overlay .weda-ui-custom-picker__cloumn {
187
+ .weda-ui-custom-picker__columns.wd-relation-select-overlay .weda-ui-custom-picker__column {
188
188
  width: auto;
189
189
  min-width: 100%;
190
190
  }
191
- .weda-ui-custom-picker__cloumns.wd-relation-select-overlay .weda-ui-custom-picker__cloumn-item.is-selected {
191
+ .weda-ui-custom-picker__columns.wd-relation-select-overlay .weda-ui-custom-picker__column-item.is-selected {
192
192
  background-color: var(--wd-color-brand-light, #ecf2fe);
193
193
  border-radius: 3px;
194
194
  }
@@ -55,10 +55,10 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
55
55
  value,
56
56
  });
57
57
  const onFocus = (e) => {
58
- events.focus(null, { originEvent: e });
58
+ (events === null || events === void 0 ? void 0 : events.focus) && (events === null || events === void 0 ? void 0 : events.focus(null, { originEvent: e }));
59
59
  };
60
60
  const onBlur = (e) => {
61
- events.blur(null, { originEvent: e });
61
+ (events === null || events === void 0 ? void 0 : events.blur) && (events === null || events === void 0 ? void 0 : events.blur(null, { originEvent: e }));
62
62
  };
63
63
  const isRelation = isFormatWithRelation(format);
64
64
  const LabelAdornment = isRelation && (_jsx(RelationalSetting, { size: props.size, refresh: () => {
@@ -45,34 +45,23 @@
45
45
  display: none;
46
46
  }
47
47
 
48
- .wd-form-item.wd-pc-select-multiple-root
49
- .form-select-multiple-pc
50
- .wedatea2td-dropdown-btn.wedatea2td-dropdown__header {
48
+ .wd-form-item.wd-pc-select-multiple-root .form-select-multiple-pc .wedatea2td-dropdown-btn.wedatea2td-dropdown__header {
51
49
  border: none;
52
50
  padding: 0;
53
51
  display: flex;
54
52
  align-items: center;
55
53
  }
56
54
 
57
- .wd-form-item.wd-pc-select-multiple-root
58
- .form-select-multiple-pc
59
- i.wedatea2td-icon-arrowdown {
55
+ .wd-form-item.wd-pc-select-multiple-root .form-select-multiple-pc i.wedatea2td-icon-arrowdown {
60
56
  display: none;
61
57
  }
62
58
 
63
- .wd-form-item.wd-pc-select-multiple-root
64
- .form-select-multiple-pc
65
- i.wedatea2td-icon-dismiss {
59
+ .wd-form-item.wd-pc-select-multiple-root .form-select-multiple-pc i.wedatea2td-icon-dismiss {
66
60
  display: none;
67
61
  }
68
62
 
69
- .wd-form-item.wd-pc-select-multiple-root
70
- .form-select-multiple-pc
71
- .wedatea2td-text-weak,
72
- .wd-form-item.wd-pc-select-multiple-root
73
- .wedatea2td-dropdown__value
74
- div
75
- div:not(.weda-ui-show-label) {
63
+ .wd-form-item.wd-pc-select-multiple-root .form-select-multiple-pc .wedatea2td-text-weak,
64
+ .wd-form-item.wd-pc-select-multiple-root .wedatea2td-dropdown__value div div:not(.weda-ui-show-label) {
76
65
  color: var(--wd-color-text-placeholder) !important;
77
66
  }
78
67
 
@@ -88,10 +77,7 @@
88
77
  padding-right: calc(var(--wd-size-icon-md));
89
78
  }
90
79
 
91
- .wd-relation-select-overlay.multiple
92
- .wedatea2td-dropdown-box
93
- .wedatea2td-list--option
94
- > li {
80
+ .wd-relation-select-overlay.multiple .wedatea2td-dropdown-box .wedatea2td-list--option > li {
95
81
  width: fit-content !important;
96
82
  min-width: 100%;
97
83
  padding: 0;
@@ -106,20 +92,19 @@
106
92
  overflow: hidden;
107
93
  }
108
94
  /* h5端关联下拉样式 */
109
- .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple.wd-relation-select-overlay
110
- .weda-ui-custom-picker__cloumn-item {
95
+ .weda-ui-custom-picker__columns.weda-ui-custom-picker__columns--select-multiple.wd-relation-select-overlay
96
+ .weda-ui-custom-picker__column-item {
111
97
  height: auto;
112
98
  }
113
- .weda-ui-custom-picker__cloumns--select-multiple
114
- .weda-ui-custom-picker__cloumn-item-text {
99
+ .weda-ui-custom-picker__columns--select-multiple .weda-ui-custom-picker__column-item-text {
115
100
  overflow: hidden;
116
101
  text-overflow: ellipsis;
117
102
  white-space: nowrap;
118
103
  margin-left: 30px;
119
104
  margin-right: 0;
120
105
  }
121
- .weda-ui-custom-picker__cloumns--select-multiple.weda-ui-custom-picker__cloumns
122
- .weda-ui-custom-picker__cloumn-item-text {
106
+ .weda-ui-custom-picker__columns--select-multiple.weda-ui-custom-picker__columns
107
+ .weda-ui-custom-picker__column-item-text {
123
108
  overflow: hidden;
124
109
  text-overflow: ellipsis;
125
110
  white-space: nowrap;
@@ -57,10 +57,10 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
57
57
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.change) === null || _a === void 0 ? void 0 : _a.call(delayEvents, { value: v, context });
58
58
  };
59
59
  const onFocus = (e) => {
60
- events.focus(null, { originEvent: e });
60
+ (events === null || events === void 0 ? void 0 : events.focus) && events.focus(null, { originEvent: e });
61
61
  };
62
62
  const onBlur = (e) => {
63
- events.blur(null, { originEvent: e });
63
+ (events === null || events === void 0 ? void 0 : events.blur) && events.blur(null, { originEvent: e });
64
64
  };
65
65
  const isRelation = isFormatWithRelation(format);
66
66
  const LabelAdornment = isRelation && (_jsx(RelationalSetting, { size: props.size, refresh: () => {
@@ -703,7 +703,7 @@ export const getFieldValue = (name, _record, relatedFieldName, isManyField) => {
703
703
  }
704
704
  return v2 !== undefined ? v2 : v1;
705
705
  }
706
- return record[name];
706
+ return record === null || record === void 0 ? void 0 : record[name];
707
707
  };
708
708
  export const slotRender = (Slot, props = {}) => {
709
709
  if (typeof Slot === 'function') {
@@ -44,5 +44,5 @@ export const WdUploadImage = forwardRef(function WdUploadImage(props, ref) {
44
44
  const multiple = !single;
45
45
  if (!visible)
46
46
  return null;
47
- return (_jsx(WdFormItem, { ...formItemProps, children: template === 'custom' ? (_jsx(Upload, { events: events, acceptTypes: acceptTypes, maxSize: maxSize, maxUploadCount: maxUploadCount, readOnly: readOnly, disabled: disabled, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, callbacks: callbacks, value: value, multiple: multiple, capture: sourceType === 'camera' ? 'capture' : null, onChange: onChange, ref: uploadRef, setUploadHandle: setUploadHandle, children: children })) : (_jsx(Uploader, { events: events, labelVisible: false, acceptTypes: acceptTypes, defaultValue: value, maxSize: maxSize, maxUploadCount: maxUploadCount, single: single, tips: tips, showShape: showShape, readOnly: readOnly, disabled: disabled, decorator: null, onChange: onChange, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, sourceType: sourceType, callbacks: callbacks, setUploadHandle: setUploadHandle })) }));
47
+ return (_jsx(WdFormItem, { ...formItemProps, children: template === 'custom' ? (_jsx(Upload, { events: events, acceptTypes: acceptTypes, maxSize: maxSize, maxUploadCount: maxUploadCount, readOnly: readOnly, disabled: disabled, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, callbacks: callbacks, value: value, multiple: multiple, sourceType: sourceType, onChange: onChange, ref: uploadRef, setUploadHandle: setUploadHandle, children: children })) : (_jsx(Uploader, { events: events, labelVisible: false, acceptTypes: acceptTypes, defaultValue: value, maxSize: maxSize, maxUploadCount: maxUploadCount, single: single, tips: tips, showShape: showShape, readOnly: readOnly, disabled: disabled, decorator: null, onChange: onChange, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, sourceType: sourceType, callbacks: callbacks, setUploadHandle: setUploadHandle })) }));
48
48
  });
@@ -1,13 +1,14 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef, useRef, useEffect } from 'react';
2
+ import React, { forwardRef, useRef, useEffect } from 'react';
3
+ import { autorun } from 'mobx';
3
4
  import classNames from '../../utils/classnames';
4
5
  import { useConfig } from '../../utils/config-context';
5
- import { isInIde, usePlatform } from '../../utils/platform';
6
+ import { usePlatform } from '../../utils/platform';
6
7
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
7
- import { Bubble } from 'tea-component';
8
+ import { Bubble, ConfigProvider } from 'tea-component';
8
9
  import EmptyContent from '../statusContent';
9
10
  import './style';
10
- export const WebView = forwardRef(function WebView({ link = '', events, className, style, allow = 'microphone;camera;midi;encrypted-media;geolocation;fullscreen;clipboard-write;clipboard-read;', sandbox = 'allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads', }, ref) {
11
+ export const WebView = forwardRef(function WebView({ id, link = '', events, className, style, allow = 'microphone;camera;midi;encrypted-media;geolocation;fullscreen;clipboard-write;clipboard-read;', sandbox = 'allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads', }, ref) {
11
12
  const platform = usePlatform();
12
13
  const iframeRef = useRef(null);
13
14
  // 样式
@@ -17,33 +18,22 @@ export const WebView = forwardRef(function WebView({ link = '', events, classNam
17
18
  [`${classPrefix}-web-view-container`]: true,
18
19
  [platformCss]: true,
19
20
  };
20
- function onLoad() {
21
- try {
22
- linkCheck(link);
23
- }
24
- catch {
25
- onError();
26
- }
27
- }
28
- // 检测src是否存在
29
- function linkCheck(src) {
30
- const link = document.createElement('link');
31
- link.rel = 'stylesheet';
32
- link.type = 'text/css';
33
- // 这里设置需要检测的url
34
- link.href = src;
35
- link.onload = function () {
36
- onSuccess();
37
- };
38
- link.onerror = function () {
39
- onError();
21
+ const [editorPlatforms, setEditorPlatforms] = React.useState([]);
22
+ const dispose = React.useMemo(() => {
23
+ return autorun(() => {
24
+ var _a, _b;
25
+ setEditorPlatforms((_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.editorPlatforms);
26
+ });
27
+ }, []);
28
+ React.useEffect(() => {
29
+ return () => {
30
+ dispose();
40
31
  };
41
- document.body.appendChild(link);
42
- }
32
+ }, [dispose]);
43
33
  function onError() {
44
34
  (events === null || events === void 0 ? void 0 : events.error) && events.error({ src: link });
45
35
  }
46
- function onSuccess() {
36
+ function onLoad() {
47
37
  (events === null || events === void 0 ? void 0 : events.load) && (events === null || events === void 0 ? void 0 : events.load({ src: link }));
48
38
  }
49
39
  // Widget API,挂载组件只读属性和组件方法
@@ -68,5 +58,5 @@ export const WebView = forwardRef(function WebView({ link = '', events, classNam
68
58
  (events === null || events === void 0 ? void 0 : events.message) && (events === null || events === void 0 ? void 0 : events.message({ data: e.data }));
69
59
  }, false);
70
60
  }, [events, link]);
71
- return (_jsx(_Fragment, { children: isInIde() ? (_jsx(_Fragment, { children: _jsx(Bubble, { content: "\u8BE5\u7EC4\u4EF6\u5728\u5C0F\u7A0B\u5E8F\u7AEF\u5C06\u94FA\u6EE1\u6574\u4E2A\u9875\u9762\u5E76\u8986\u76D6\u5176\u4ED6\u7EC4\u4EF6\uFF0C\u5E76\u4E14\u5C0F\u7A0B\u5E8F\u4E3A\u4F01\u4E1A\u4E3B\u4F53\u65F6\u624D\u80FD\u6B63\u5E38\u4F7F\u7528", children: link ? (_jsx("iframe", { src: link, style: style, className: classNames(classes, className) })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) }) })) : (_jsx(_Fragment, { children: link ? (_jsx("iframe", { onLoad: onLoad, onError: () => onError(), ref: iframeRef, id: 'web-view', name: 'web-view', src: link, title: 'web-view', style: style, className: classNames(classes, className), allow: allow, sandbox: sandbox })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) })) }));
61
+ return (_jsx(_Fragment, { children: (editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP')) ? (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(Bubble, { placement: "left", content: "\u8BE5\u7EC4\u4EF6\u5728\u5C0F\u7A0B\u5E8F\u7AEF\u5C06\u94FA\u6EE1\u6574\u4E2A\u9875\u9762\u5E76\u8986\u76D6\u5176\u4ED6\u7EC4\u4EF6\uFF0C\u5E76\u4E14\u5C0F\u7A0B\u5E8F\u4E3A\u4F01\u4E1A\u4E3B\u4F53\u65F6\u624D\u80FD\u6B63\u5E38\u4F7F\u7528", children: link ? (_jsx("iframe", { src: link, style: style, className: classNames(classes, className) })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) }) })) : (_jsx(_Fragment, { children: link ? (_jsx("iframe", { id: id, onLoad: onLoad, onError: onError, ref: iframeRef, name: 'web-view', src: link, title: 'web-view', style: style, className: classNames(classes, className), allow: allow, sandbox: sandbox })) : (_jsx("div", { style: style, className: classNames(classes, className), children: _jsx(EmptyContent, { emptyText: "\u6682\u65E0\u7F51\u9875\uFF0C\u8BF7\u8F93\u5165\u7F51\u9875\u94FE\u63A5", component: "table", isH5: true }) })) })) }));
72
62
  });