@cloudbase/weda-ui 3.3.2 → 3.3.3

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 (44) hide show
  1. package/dist/web/components/calendar/index.js +37 -39
  2. package/dist/web/components/carousel/index.js +62 -62
  3. package/dist/web/components/chart/bar/index.js +0 -4
  4. package/dist/web/components/chart/common/Chart.d.ts +0 -1
  5. package/dist/web/components/chart/common/Chart.js +1 -9
  6. package/dist/web/components/chart/common/chart-custom-connector.js +1 -1
  7. package/dist/web/components/chart/common/core/eChartBase.js +1 -1
  8. package/dist/web/components/chart/common/data-transform.js +1 -1
  9. package/dist/web/components/chart/common/useChart.js +2 -11
  10. package/dist/web/components/common/use-loop-render-detect.d.ts +2 -2
  11. package/dist/web/components/common/use-loop-render-detect.js +7 -9
  12. package/dist/web/components/form/checkbox/index.js +29 -29
  13. package/dist/web/components/form/form/index.js +1 -3
  14. package/dist/web/components/form/location/common/mapChoose.js +1 -2
  15. package/dist/web/components/form/location/common/mapView.js +1 -4
  16. package/dist/web/components/form/location/components/LocationPC/location.PC.js +0 -4
  17. package/dist/web/components/form/radio/index.js +3 -3
  18. package/dist/web/components/form/select/allTimePicker/index.js +0 -1
  19. package/dist/web/components/form/select/h5.js +4 -18
  20. package/dist/web/components/form/select/index.js +1 -8
  21. package/dist/web/components/form/select/use-options.js +1 -1
  22. package/dist/web/components/form/uploader/uploader.h5.js +2 -2
  23. package/dist/web/components/form/uploader/uploader.pc.js +1 -1
  24. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +7 -9
  25. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +6 -9
  26. package/dist/web/components/formdetail/index.js +10 -12
  27. package/dist/web/components/graphicCard/index.js +6 -5
  28. package/dist/web/components/image/index.js +1 -1
  29. package/dist/web/components/listView/index.js +0 -1
  30. package/dist/web/components/lottery/index.js +16 -10
  31. package/dist/web/components/navLayout/index.js +1 -1
  32. package/dist/web/components/navigationBar/horizontalMenu.js +1 -1
  33. package/dist/web/components/richText/index.js +2 -1
  34. package/dist/web/components/richTextView/index.js +18 -20
  35. package/dist/web/components/scrollView/index.d.ts +0 -1
  36. package/dist/web/components/scrollView/index.js +4 -6
  37. package/dist/web/components/swiper/index.js +62 -62
  38. package/dist/web/components/text/index.js +8 -10
  39. package/dist/web/components/uploaderView/index.js +1 -1
  40. package/dist/web/components/wedaVideo/index.js +2 -14
  41. package/dist/web/utils/tmap.d.ts +3 -0
  42. package/dist/web/utils/tmap.js +21 -0
  43. package/dist/web/utils/useSyncValue.js +0 -1
  44. package/package.json +20 -20
@@ -132,14 +132,7 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
132
132
  defaultMutiRegion,
133
133
  };
134
134
  }
135
- }, [
136
- defaultValue,
137
- defaultDate,
138
- defaultTime,
139
- defaultRegion,
140
- defaultMutiRegion,
141
- dateMode,
142
- ]);
135
+ });
143
136
  React.useEffect(() => {
144
137
  if (mode == 'region' || mode == 'mutiRegion') {
145
138
  if (regionData.length < 1) {
@@ -98,6 +98,6 @@ export function useOptions(params) {
98
98
  if (state.status === 'success') {
99
99
  setOptions(state.result);
100
100
  }
101
- }, [setOptions, state, state.status]);
101
+ }, [state, state.status]);
102
102
  return [options];
103
103
  }
@@ -36,7 +36,7 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
36
36
  return inputValue;
37
37
  }
38
38
  return [];
39
- }, [inputValue, setInputValue]);
39
+ }, [inputValue]);
40
40
  const finalMaxImgCount = React.useMemo(() => {
41
41
  if (single)
42
42
  return 1;
@@ -59,7 +59,7 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
59
59
  onChange && onChange(fileIdList);
60
60
  events.change && events.change({ value: fileIdList });
61
61
  }
62
- }, [events, fileIdList, onChange, single]);
62
+ }, [fileIdList]);
63
63
  const onProgress = (progressEvent) => {
64
64
  let percentCompleted = 0;
65
65
  try {
@@ -53,7 +53,7 @@ export function UploaderPCInner(props) {
53
53
  initialValue = initialValue[0] ? [initialValue[0]] : [];
54
54
  }
55
55
  setfileIDList(initialValue);
56
- }, [defaultValue, single]);
56
+ }, [defaultValue]);
57
57
  // 值变化事件
58
58
  React.useEffect(() => {
59
59
  if (!isObjectEqual(fileRef.current, fileIDList)) {
@@ -70,7 +70,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
70
70
  (_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
71
71
  fileRef.current = fileIDList;
72
72
  }
73
- }, [events, fileIDList, onChange, single]);
73
+ }, [fileIDList]);
74
74
  // 外层组件类
75
75
  const cls = classNames({
76
76
  'weda-ui': true,
@@ -218,9 +218,12 @@ const TcbFileUpload = ({ file, disabled }) => {
218
218
  const title = (file === null || file === void 0 ? void 0 : file.name) || '';
219
219
  const uuid = file === null || file === void 0 ? void 0 : file._uuid;
220
220
  return { size, title, uuid };
221
- }, [file === null || file === void 0 ? void 0 : file._uuid, file === null || file === void 0 ? void 0 : file.name, file === null || file === void 0 ? void 0 : file.size]);
221
+ }, [file === null || file === void 0 ? void 0 : file._uuid]);
222
+ React.useEffect(() => {
223
+ handleUpload(file);
224
+ }, [file === null || file === void 0 ? void 0 : file._uuid]);
222
225
  // 上传过程
223
- const handleUpload = React.useCallback(async (file) => {
226
+ const handleUpload = async (file) => {
224
227
  var _a;
225
228
  const tcb = await getCloudInstance();
226
229
  try {
@@ -242,12 +245,7 @@ const TcbFileUpload = ({ file, disabled }) => {
242
245
  setStatus('UPLOAD_STATUS_ERROR');
243
246
  (_a = events === null || events === void 0 ? void 0 : events.error) === null || _a === void 0 ? void 0 : _a.call(events, err);
244
247
  }
245
- },
246
- // eslint-disable-next-line react-hooks/exhaustive-deps
247
- [size, uploadPath, uuid]);
248
- React.useEffect(() => {
249
- handleUpload(file);
250
- }, [file, file._uuid, handleUpload]);
248
+ };
251
249
  return (React.createElement("div", { className: `${CLASS_PREFIX}__item`, role: "TcbFileUpload" },
252
250
  React.createElement("div", { className: `${CLASS_PREFIX}__item-left` },
253
251
  React.createElement(UploadFileStatus, { status: status, percent: percent, size: size, title: title, percentSize: (((file === null || file === void 0 ? void 0 : file.size) / 1024) * percent) / 100 })),
@@ -61,7 +61,6 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
61
61
  (_c = events === null || events === void 0 ? void 0 : events.success) === null || _c === void 0 ? void 0 : _c.call(events, { value: pureFileIDList });
62
62
  fileRef.current = fileIDList;
63
63
  }
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
64
  }, [fileIDList]);
66
65
  // 外层组件类
67
66
  const cls = classNames({
@@ -210,9 +209,12 @@ const TcbFileUpload = ({ file, disabled }) => {
210
209
  const title = (file === null || file === void 0 ? void 0 : file.name) || '';
211
210
  const uuid = file === null || file === void 0 ? void 0 : file._uuid;
212
211
  return { size, title, uuid };
213
- }, [file === null || file === void 0 ? void 0 : file._uuid, file === null || file === void 0 ? void 0 : file.name, file === null || file === void 0 ? void 0 : file.size]);
212
+ }, [file === null || file === void 0 ? void 0 : file._uuid]);
213
+ React.useEffect(() => {
214
+ handleUpload(file);
215
+ }, [file === null || file === void 0 ? void 0 : file._uuid]);
214
216
  // 上传过程
215
- const handleUpload = React.useCallback(async (file) => {
217
+ const handleUpload = async (file) => {
216
218
  const tcb = await getCloudInstance();
217
219
  try {
218
220
  setStatus('0');
@@ -233,12 +235,7 @@ const TcbFileUpload = ({ file, disabled }) => {
233
235
  setStatus('3');
234
236
  events.error && events.error(e);
235
237
  }
236
- },
237
- // eslint-disable-next-line react-hooks/exhaustive-deps
238
- [size, uploadPath, uuid]);
239
- React.useEffect(() => {
240
- handleUpload(file);
241
- }, [file, file._uuid, handleUpload]);
238
+ };
242
239
  return (React.createElement("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-body` },
243
240
  React.createElement("div", { className: `${CLASS_PREFIX}--item-title`, title: title }, cutFileTitle(title)),
244
241
  React.createElement("div", { className: `${CLASS_PREFIX}--item-size` }, size),
@@ -1,4 +1,4 @@
1
- import React, { useEffect, forwardRef, useImperativeHandle, useState, useCallback, } from 'react';
1
+ import React, { useEffect, useRef, forwardRef, useImperativeHandle, useState, } from 'react';
2
2
  import destr from 'destr';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { usePlatform, randomStr } from '../../utils/platform';
@@ -60,11 +60,12 @@ export const changeHandle = ({ type, name, data, childFormItem, isPureArray, par
60
60
  };
61
61
  export default forwardRef(function FormDetail(props, ref) {
62
62
  const { className, id, style, children, events, name, value: initDetailValue, isPureArray, parent, } = props;
63
+ const observeRef = useRef(null); // 当前监听对象
63
64
  const [defaultValue, setDetailValue] = useState([]);
64
65
  const [contextData, setContextData] = useState([]);
65
66
  const [childFormItem, setCildFormItem] = useState([]);
66
67
  const platform = usePlatform();
67
- const init = useCallback((defaultValue) => {
68
+ const init = (defaultValue) => {
68
69
  var _a;
69
70
  const formDetailItemValue = {};
70
71
  let childFormItem = defaultValue[0] ? Object.keys(defaultValue[0]) : [];
@@ -110,12 +111,10 @@ export default forwardRef(function FormDetail(props, ref) {
110
111
  // eslint-disable-next-line rulesdir/no-timer
111
112
  setTimeout(() => {
112
113
  if (!isObjectEqual(formDetailItemValue, {})) {
113
- if ((parent === null || parent === void 0 ? void 0 : parent.setValue) && typeof (parent === null || parent === void 0 ? void 0 : parent.setValue) === 'function') {
114
- parent === null || parent === void 0 ? void 0 : parent.setValue(formDetailItemValue);
115
- }
114
+ parent.setValue(formDetailItemValue);
116
115
  }
117
116
  }, 0);
118
- }, [events, isPureArray, name, parent]);
117
+ };
119
118
  // 初始化context的值
120
119
  useEffect(() => {
121
120
  if (!isObjectEqual(initDetailValue, defaultValue)) {
@@ -129,13 +128,12 @@ export default forwardRef(function FormDetail(props, ref) {
129
128
  setDetailValue(initDetailValue);
130
129
  // 组件卸载时触发
131
130
  return () => {
132
- var _a;
133
- (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data: [] });
131
+ var _a, _b;
132
+ (_a = observeRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
133
+ (_b = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _b === void 0 ? void 0 : _b.call(events, { data: [] });
134
134
  };
135
- // 只执行一次;
136
- // eslint-disable-next-line react-hooks/exhaustive-deps
137
135
  }, []);
138
- const onChange = useCallback((type, params) => {
136
+ const onChange = (type, params) => {
139
137
  var _a;
140
138
  let data = destr(contextData);
141
139
  data = changeHandle({
@@ -148,7 +146,7 @@ export default forwardRef(function FormDetail(props, ref) {
148
146
  });
149
147
  setContextData(data);
150
148
  (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data });
151
- }, [childFormItem, contextData, events, isPureArray, name]);
149
+ };
152
150
  useImperativeHandle(ref, () => {
153
151
  return {
154
152
  methods: {
@@ -1,4 +1,4 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo } from 'react';
2
2
  import './index.css';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { Row, Col, ConfigProvider, Button, Text } from 'tea-component';
@@ -12,6 +12,7 @@ const CLASS_PREFIX = 'weda-graphic-card';
12
12
  export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC, iconWidthSize, iconHeightSize, titleVisible, desVisible, buttonVisible, textAlign, className, titleColor, titleFontWeight, titleFontSize, titleLineHeight, titleMaxLines, desColor, desFontWeight, desFontSize, desLineHeight, desMaxLines, buttonText, style, }) {
13
13
  const platform = usePlatform();
14
14
  const isH5 = platform === 'h5';
15
+ const [colCount, setColCount] = React.useState(2);
15
16
  // 一个栅格的宽度
16
17
  const { width } = useWindowSize();
17
18
  const singleGrid = useMemo(() => (width - 24 * 2) / 12, [width]);
@@ -23,10 +24,10 @@ export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC,
23
24
  [className]: className,
24
25
  [`${CLASS_PREFIX}-mobile`]: isH5,
25
26
  });
26
- const colCount = useMemo(() => {
27
+ useEffect(() => {
27
28
  const col = isH5 ? ColMobile : ColPC;
28
- return col !== null && col !== void 0 ? col : 2;
29
- }, [ColMobile, ColPC, isH5]);
29
+ setColCount(col);
30
+ }, [isH5]);
30
31
  const cardList = useMemo(() => {
31
32
  const list = [];
32
33
  if (prevColRef.current !== colCount ||
@@ -121,7 +122,7 @@ export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC,
121
122
  ? iconHeightSize
122
123
  : (Number(height) * parseInt(iconHeightSize)) / 100 + 'px';
123
124
  return { width, height };
124
- }, [platform, ColMobile, ColPC, iconWidthSize, iconHeightSize]);
125
+ }, [iconWidthSize, iconHeightSize, ColMobile, ColPC, isH5]);
125
126
  const tapTo = (colInfo = navOption[0]) => {
126
127
  switch (colInfo === null || colInfo === void 0 ? void 0 : colInfo.tapStatus) {
127
128
  case 'tap':
@@ -46,7 +46,7 @@ src, alt, mode, lazyLoad, imgPreview, maskClosable, fit, }) {
46
46
  else {
47
47
  return style;
48
48
  }
49
- }, [objectFit, style]);
49
+ }, [style, fit]);
50
50
  return src === realSrc || (realSrc !== undefined && src !== realSrc) ? (React.createElement(ImageInner, { objectFit: realFit, style: realStyle, className: cls, alt: alt, src: realSrc, isError: isError, setIsError: setIsError, events: events, lazyLoad: lazyLoad, imgPreview: imgPreview, maskClosable: maskClosable })) : null;
51
51
  }
52
52
  function getObjectFitByWxImageMode(mode) {
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-hooks/exhaustive-deps */
2
1
  import React, { useState, useEffect, useRef, useCallback } from 'react';
3
2
  import { callDataSource } from '../../utils/tcb';
4
3
  import { isInIde, getWhereList } from '../../utils/platform';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/jsx-key */
2
- import React, { useState, useEffect, useCallback, useImperativeHandle, useMemo, } from 'react';
2
+ import React, { useState, useEffect, useCallback, useImperativeHandle, } from 'react';
3
3
  import { usePlatform } from '../../utils/platform';
4
4
  import classNames from '../../utils/classnames';
5
5
  import './index.css';
@@ -14,7 +14,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
14
14
  const [lotteryList, setLotteryList] = useState([]);
15
15
  const [btnActived, setBtnActived] = useState(false);
16
16
  //获取初始化默认数据,数据不足8条设置默认,超过8条获取前8条
17
- const lotteryListDefault = useMemo(() => {
17
+ const lotteryListDefault = () => {
18
18
  const list = [];
19
19
  if (prizeList == null) {
20
20
  return list;
@@ -39,15 +39,21 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
39
39
  }
40
40
  }
41
41
  return list;
42
- }, [prizeList]);
42
+ };
43
43
  const startLottery = useCallback(() => {
44
- setLotteryList(lotteryListDefault);
44
+ setLotteryList(lotteryListDefault());
45
45
  setBtnActived(true);
46
46
  if (lotteryAction.isStart)
47
47
  return;
48
48
  events === null || events === void 0 ? void 0 : events.clickLotteryButton();
49
49
  setIsStartLottery(true);
50
- }, [lotteryListDefault, events]);
50
+ }, [
51
+ lotteryAction.isStart,
52
+ setIsStartLottery,
53
+ setBtnActived,
54
+ lotteryListDefault,
55
+ setLotteryList,
56
+ ]);
51
57
  useImperativeHandle(ref, () => {
52
58
  return {
53
59
  methods: {
@@ -56,8 +62,8 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
56
62
  };
57
63
  }, [startLottery]);
58
64
  useEffect(() => {
59
- setLotteryList(lotteryListDefault);
60
- }, [lotteryListDefault]);
65
+ setLotteryList(lotteryListDefault());
66
+ }, [prizeList]);
61
67
  useEffect(() => {
62
68
  lotteryAction.animationCallback = ({ idx, isEnd }) => {
63
69
  setActivedId(idx == -1 ? 0 : idx);
@@ -84,7 +90,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
84
90
  }, 700);
85
91
  }
86
92
  };
87
- }, [events, lotteryList]);
93
+ }, [lotteryList]);
88
94
  useEffect(() => {
89
95
  // 当满足开启抽奖条件并且点击了开奖开关时,启用抽奖
90
96
  if (enablePrize && isStartLottery) {
@@ -102,7 +108,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
102
108
  //立马停止抽奖
103
109
  lotteryAction.stop();
104
110
  }
105
- }, [isStartLottery, enablePrize, prizeResult]);
111
+ }, [isStartLottery, enablePrize]);
106
112
  useEffect(() => {
107
113
  // 设置抽奖结果
108
114
  lotteryAction.end(prizeResult);
@@ -182,7 +188,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
182
188
  setDotHeight(dotHeight);
183
189
  }
184
190
  }
185
- }, [platform, style]);
191
+ }, [style]);
186
192
  const renderDot = (direction, list) => {
187
193
  return (React.createElement(React.Fragment, null,
188
194
  React.createElement("div", { className: classNames(`${CLASS_PREFIX}__dot`, `${CLASS_PREFIX}__dot-${direction}`) }, list.map((item, index) => {
@@ -54,7 +54,7 @@ export default function NavLayout({ navOption = emptyArray, mobileCol, pcCol, ic
54
54
  }, [colCount, navOption]);
55
55
  React.useEffect(() => {
56
56
  setColCount(platform === 'h5' ? mobileCol : pcCol);
57
- }, [mobileCol, pcCol, platform]);
57
+ }, [mobileCol, pcCol]);
58
58
  // 每个col的宽度百分比
59
59
  const colStyle = {
60
60
  width: `${(1 / colCount) * 100}%`,
@@ -48,7 +48,7 @@ const HorizontalMenu = ({ menuData, navigationStyle, selected, setSelected }) =>
48
48
  if (platform !== 'h5' && isHorizontal && ((_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.children)) {
49
49
  getMenuOffset();
50
50
  }
51
- }, [platform, isHorizontal, navWrapRef, getMenuOffset]);
51
+ }, [platform, isHorizontal, navWrapRef]);
52
52
  // 渲染下拉菜单
53
53
  const renderMenuList = (item, navigationStyle) => {
54
54
  return (React.createElement(List, { type: "option", className: `${CLASS_PREFIX}__dropdown-menu-list`, style: { background: navigationStyle.menuBackgroundColor } }, item === null || item === void 0 ? void 0 : item.map((menu) => {
@@ -92,7 +92,7 @@ label, labelVisible, value: initialValue, readOnly, layout, requiredFlag, onChan
92
92
  useEffect(() => {
93
93
  const state = createStateFromContent(initialValue, {});
94
94
  setEditorState(state);
95
- }, [initialValue]);
95
+ }, []);
96
96
  const excludeControls = useMemo(() => {
97
97
  const result = [
98
98
  'media',
@@ -134,6 +134,7 @@ label, labelVisible, value: initialValue, readOnly, layout, requiredFlag, onChan
134
134
  maxSize,
135
135
  cloudPath,
136
136
  latestEditorState,
137
+ insertMedias,
137
138
  setEditorState,
138
139
  isH5,
139
140
  ]);
@@ -1,10 +1,9 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import classNames from '../../utils/classnames';
3
3
  import { getTempFileURL } from '../../utils/tcb';
4
4
  import './index.css';
5
5
  import { LOAD_ERR_IMG_BASE64 } from '../../utils/constant';
6
6
  import destr from 'destr';
7
- const imgRegex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
8
7
  export default function RichTextView({ value = '', className, style, id, }) {
9
8
  const parseValue = destr(value);
10
9
  const cls = classNames({
@@ -13,26 +12,25 @@ export default function RichTextView({ value = '', className, style, id, }) {
13
12
  [className]: className,
14
13
  });
15
14
  const [displayValue, setDisplayValue] = useState('');
15
+ const regex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
16
16
  const iferror = `javascript:this.width='80';this.src='${LOAD_ERR_IMG_BASE64}';this.onerror=null`;
17
- const valueWithErrorHandle = useMemo(() => {
18
- return parseValue
19
- .toString()
20
- .replace(/<img /g, `<img onerror=${iferror} style="max-width:100%" `);
21
- }, [iferror, parseValue]);
22
- useEffect(() => {
23
- const getSrc = async (img) => {
24
- const url = img.replace(imgRegex, '$1');
25
- if (img.includes('cloud://')) {
26
- const newURL = await getTempFileURL(url);
27
- if (newURL) {
28
- const htmlWithTempUrl = valueWithErrorHandle.replace(new RegExp(url, 'g'), newURL);
29
- setDisplayValue(htmlWithTempUrl);
30
- }
17
+ let tempValue = parseValue
18
+ .toString()
19
+ .replace(/<img /g, `<img onerror=${iferror} style="max-width:100%" `);
20
+ const getSrc = async (img) => {
21
+ const url = img.replace(regex, '$1');
22
+ if (img.includes('cloud://')) {
23
+ const newURL = await getTempFileURL(url);
24
+ if (newURL) {
25
+ tempValue = tempValue.replace(new RegExp(url, 'g'), newURL);
26
+ setDisplayValue(tempValue);
31
27
  }
32
- };
33
- setDisplayValue(valueWithErrorHandle);
28
+ }
29
+ };
30
+ useEffect(() => {
31
+ setDisplayValue(tempValue);
34
32
  try {
35
- const imgs = parseValue.match(imgRegex);
33
+ const imgs = parseValue.match(regex);
36
34
  if (imgs && imgs.length > 0) {
37
35
  imgs.forEach((img) => {
38
36
  getSrc(img);
@@ -40,7 +38,7 @@ export default function RichTextView({ value = '', className, style, id, }) {
40
38
  }
41
39
  }
42
40
  catch (e) { }
43
- }, [parseValue, valueWithErrorHandle]);
41
+ }, [value]);
44
42
  return (displayValue && (React.createElement("div", { className: cls, style: style, id: id },
45
43
  React.createElement("div", { dangerouslySetInnerHTML: { __html: displayValue } }))));
46
44
  }
@@ -8,7 +8,6 @@ export interface PropsType extends CommonPropsType {
8
8
  scrollIntoView?: string;
9
9
  upperThreshold?: number;
10
10
  lowerThreshold?: number;
11
- domRef?: any;
12
11
  }
13
12
  export default function ScrollView({ id, scrollX, scrollY, style, scrollTop, scrollLeft, scrollIntoView, className, children, upperThreshold, lowerThreshold, events, }: {
14
13
  id: any;
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import classNames from '../../utils/classnames';
3
- export default function ScrollView({ id, scrollX = false, scrollY = true, style, scrollTop, scrollLeft, scrollIntoView, className, children, upperThreshold = 50, lowerThreshold = 50,
4
- // domRef,
5
- events, }) {
3
+ export default function ScrollView({ id, scrollX = false, scrollY = true, style, scrollTop, scrollLeft, scrollIntoView, className, children, upperThreshold = 50, lowerThreshold = 50, events, }) {
6
4
  const [toUpper, setToUpper] = React.useState(false);
7
5
  const [toLower, setToLower] = React.useState(false);
8
6
  const [scrollLeftPos, setScrollLeftPos] = React.useState(0);
@@ -66,10 +64,10 @@ events, }) {
66
64
  }, [scrollLeft]);
67
65
  React.useEffect(() => {
68
66
  toUpper && events.scrolltoupper();
69
- }, [events, toUpper]);
67
+ }, [toUpper]);
70
68
  React.useEffect(() => {
71
69
  toLower && events.scrolltolower();
72
- }, [events, toLower]);
70
+ }, [toLower]);
73
71
  React.useEffect(() => {
74
72
  if (scrollIntoView) {
75
73
  const children = scrollViewRef.current.children;
@@ -78,7 +76,7 @@ events, }) {
78
76
  scrollX && (scrollViewRef.current.scrollLeft = item.offsetLeft);
79
77
  // console.log('children', children, item)
80
78
  }
81
- }, [scrollIntoView, scrollX, scrollY]);
79
+ }, [scrollIntoView]);
82
80
  const webStyles = {
83
81
  position: 'relative',
84
82
  width: '100%',
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useState, useCallback, useEffect, useRef } from 'react';
2
+ import { useState, useEffect, useRef } from 'react';
3
3
  import classNames from '../../utils/classnames';
4
4
  import Swipe from 'react-easy-swipe';
5
5
  import { useDebouncedCallback, useEventListener, useResizeObserver, } from '@react-hookz/web';
@@ -12,15 +12,6 @@ export default function Swiper({ children, className, style, autoplay = true, ci
12
12
  const [swipeStyle, setSwipeStyle] = useState(null);
13
13
  const [height, setHeight] = useState(0);
14
14
  const { change = () => { } } = events;
15
- const setIndex = useCallback((index) => {
16
- if (index >= itemCount) {
17
- index = 0;
18
- }
19
- if (index < 0) {
20
- index = itemCount - 1;
21
- }
22
- setCurrentIndex(index);
23
- }, [itemCount]);
24
15
  useEffect(() => {
25
16
  if (autoplay) {
26
17
  // 自动切换
@@ -30,60 +21,10 @@ export default function Swiper({ children, className, style, autoplay = true, ci
30
21
  }, interval);
31
22
  return () => clearInterval(timer);
32
23
  }
33
- }, [currentIndex, autoplay, itemCount, interval, setIndex]);
24
+ }, [currentIndex, autoplay, itemCount]);
34
25
  // 触发切换
35
26
  const pre = useRef({ index: currentIndex }).current;
36
27
  useEffect(() => {
37
- // 设置容器样式、动画
38
- // TODO fix settimeout mess
39
- const updateSwipeStyle = (to, cur, length) => {
40
- // 最后向前到最开始
41
- if (to === 0 && cur === length - 1) {
42
- circular &&
43
- setSwipeStyle({
44
- transform: `translate3d(0, 0, 0)`,
45
- });
46
- // 不知道
47
- // eslint-disable-next-line rulesdir/no-timer
48
- setTimeout(() => {
49
- setSwipeStyle({
50
- transform: vertical
51
- ? `translate3d(0, -100%, 0)`
52
- : `translate3d(-100%, 0, 0)`,
53
- transitionDuration: `${duration}ms`,
54
- });
55
- }, 50);
56
- return;
57
- }
58
- // 第一个后退到最后
59
- if (to === length - 1 && cur === 0) {
60
- circular &&
61
- setSwipeStyle({
62
- transform: vertical
63
- ? `translate3d(0, -${(to + 2) * 100}%, 0)`
64
- : `translate3d(-${(to + 2) * 100}%, 0, 0)`,
65
- });
66
- // eslint-disable-next-line rulesdir/no-timer
67
- setTimeout(() => {
68
- setSwipeStyle({
69
- transform: vertical
70
- ? `translate3d(0, -${(to + 1) * 100}%, 0)`
71
- : `translate3d(-${(to + 1) * 100}%, 0, 0)`,
72
- transitionDuration: `${duration}ms`,
73
- });
74
- }, 50);
75
- return;
76
- }
77
- const style = {
78
- transform: vertical
79
- ? `translate3d(0, -${(to + 1) * 100}%, 0)`
80
- : `translate3d(-${(to + 1) * 100}%, 0, 0)`,
81
- };
82
- if (to !== cur) {
83
- style.transitionDuration = `${duration}ms`;
84
- }
85
- setSwipeStyle(style);
86
- };
87
28
  updateSwipeStyle(currentIndex, pre.index, itemCount);
88
29
  change({
89
30
  current: currentIndex,
@@ -91,7 +32,7 @@ export default function Swiper({ children, className, style, autoplay = true, ci
91
32
  return () => {
92
33
  pre.index = currentIndex;
93
34
  };
94
- }, [change, circular, currentIndex, duration, itemCount, pre, vertical]);
35
+ }, [currentIndex, vertical]);
95
36
  const outerWrapRef = useRef();
96
37
  useEventListener(outerWrapRef, 'load', (e) => {
97
38
  setHeight(e.target.clientHeight);
@@ -99,6 +40,65 @@ export default function Swiper({ children, className, style, autoplay = true, ci
99
40
  const itemsClone = React.Children.map(children, (x, i) => {
100
41
  return (React.createElement("div", { className: "g-swiper-item", "data-index": i }, x));
101
42
  });
43
+ const setIndex = (index) => {
44
+ if (index >= itemCount) {
45
+ index = 0;
46
+ }
47
+ if (index < 0) {
48
+ index = itemCount - 1;
49
+ }
50
+ setCurrentIndex(index);
51
+ };
52
+ // 设置容器样式、动画
53
+ // TODO fix settimeout mess
54
+ const updateSwipeStyle = (to, cur, length) => {
55
+ // 最后向前到最开始
56
+ if (to === 0 && cur === length - 1) {
57
+ circular &&
58
+ setSwipeStyle({
59
+ transform: `translate3d(0, 0, 0)`,
60
+ });
61
+ // 不知道
62
+ // eslint-disable-next-line rulesdir/no-timer
63
+ setTimeout(() => {
64
+ setSwipeStyle({
65
+ transform: vertical
66
+ ? `translate3d(0, -100%, 0)`
67
+ : `translate3d(-100%, 0, 0)`,
68
+ transitionDuration: `${duration}ms`,
69
+ });
70
+ }, 50);
71
+ return;
72
+ }
73
+ // 第一个后退到最后
74
+ if (to === length - 1 && cur === 0) {
75
+ circular &&
76
+ setSwipeStyle({
77
+ transform: vertical
78
+ ? `translate3d(0, -${(to + 2) * 100}%, 0)`
79
+ : `translate3d(-${(to + 2) * 100}%, 0, 0)`,
80
+ });
81
+ // eslint-disable-next-line rulesdir/no-timer
82
+ setTimeout(() => {
83
+ setSwipeStyle({
84
+ transform: vertical
85
+ ? `translate3d(0, -${(to + 1) * 100}%, 0)`
86
+ : `translate3d(-${(to + 1) * 100}%, 0, 0)`,
87
+ transitionDuration: `${duration}ms`,
88
+ });
89
+ }, 50);
90
+ return;
91
+ }
92
+ const style = {
93
+ transform: vertical
94
+ ? `translate3d(0, -${(to + 1) * 100}%, 0)`
95
+ : `translate3d(-${(to + 1) * 100}%, 0, 0)`,
96
+ };
97
+ if (to !== cur) {
98
+ style.transitionDuration = `${duration}ms`;
99
+ }
100
+ setSwipeStyle(style);
101
+ };
102
102
  return (React.createElement("div", { className: classNames('g-swiper weda-ui', className, {
103
103
  vertical: vertical,
104
104
  }), style: { height: height ? height : 'auto', ...style }, ref: outerWrapRef, id: id },
@@ -2,17 +2,15 @@ import * as React from 'react';
2
2
  import classNames from '../../utils/classnames';
3
3
  import './index.css';
4
4
  export default function Text({ text, maxLines, space, userSelect, style, className, events, id, level, contenteditable, onInput, onBlur, }) {
5
- const inlineStyle = React.useMemo(() => {
6
- const textStyle = {
7
- WebkitLineClamp: maxLines,
8
- whiteSpace: space ? 'pre-wrap' : 'pre-line',
9
- };
10
- if (!userSelect) {
11
- textStyle.userSelect = 'none';
12
- }
13
- return { ...textStyle, ...style };
14
- }, [maxLines, space, userSelect, style]);
5
+ const textStyle = {
6
+ WebkitLineClamp: maxLines,
7
+ whiteSpace: space ? 'pre-wrap' : 'pre-line',
8
+ };
9
+ if (!userSelect) {
10
+ textStyle.userSelect = 'none';
11
+ }
15
12
  const levelName = level === '0' || !level ? '' : `level_${level}`;
13
+ const inlineStyle = React.useMemo(() => ({ ...textStyle, ...style }), [textStyle, style]);
16
14
  return (React.createElement("p", {
17
15
  //@ts-expect-error contentEditable type def sucks
18
16
  contentEditable: contenteditable, onInput: onInput, onBlur: onBlur, style: inlineStyle, className: classNames('weda-text', 'weda-ui', className, levelName), id: id, onClick: (e) => events.tap({}, { originEvent: e }) }, text));