@cloudbase/weda-ui 3.4.4 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/configs/components/chart/bar.json +113 -8
  2. package/dist/configs/components/chart/line.js +113 -8
  3. package/dist/configs/components/chart/pie.json +113 -8
  4. package/dist/configs/components/chart/statisticsCard.json +57 -0
  5. package/dist/configs/components/dataView.js +7 -7
  6. package/dist/configs/components/graphicCard.json +1 -1
  7. package/dist/configs/components/listView.js +113 -9
  8. package/dist/configs/components/navLayout.json +1 -1
  9. package/dist/configs/components/table.json +124 -9
  10. package/dist/style/index.scss +1 -1
  11. package/dist/web/components/chart/common/data-transform.js +1 -1
  12. package/dist/web/components/chart/statisticsCard/index.js +1 -1
  13. package/dist/web/components/flow/components/UserSelectModel/UserSelect.js +9 -11
  14. package/dist/web/components/flow/components/UserSelectModel/UserSelectMobile.js +2 -6
  15. package/dist/web/components/flow/modules/chart/index.css +0 -3
  16. package/dist/web/components/flow/modules/control/ApprovalPopup.js +2 -3
  17. package/dist/web/components/flow/modules/control/Control.js +27 -15
  18. package/dist/web/components/flow/modules/control/ControlMobile.css +32 -0
  19. package/dist/web/components/flow/modules/control/ControlMobile.js +28 -13
  20. package/dist/web/components/flow/modules/control/FlowTaskInfoModal.js +4 -4
  21. package/dist/web/components/flow/modules/control/provider/useControlModel.js +2 -6
  22. package/dist/web/components/flow/modules/control/provider/useMobileModel.js +0 -2
  23. package/dist/web/components/flow/modules/control/provider/useRevokeAndBackHook.js +2 -0
  24. package/dist/web/components/flow/modules/control/utils/index.js +1 -0
  25. package/dist/web/components/flow/modules/control/utils/tools.js +3 -0
  26. package/dist/web/components/form/select/dropdown-select/h5.js +1 -1
  27. package/dist/web/components/form/select/dropdown-select/index.css +7 -0
  28. package/dist/web/components/form/select/index.js +2 -7
  29. package/dist/web/components/form/textarea/index.js +1 -1
  30. package/dist/web/components/form/uploaderFile/index.css +6 -5
  31. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +10 -11
  32. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +3 -2
  33. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +39 -22
  34. package/dist/web/components/form/userOrgSelect/component/user-select-h5/user-select-h5.js +11 -2
  35. package/dist/web/components/listView/index.js +94 -97
  36. package/dist/web/components/richTextView/index.css +2 -0
  37. package/dist/web/components/swiper/index.js +14 -8
  38. package/dist/web/components/table/BaseTable.js +3 -3
  39. package/dist/web/utils/hooks/use-cloud-id-temp-url.js +2 -1
  40. package/dist/web/utils/platform.js +9 -1
  41. package/package.json +3 -3
@@ -123,13 +123,6 @@ export default React.forwardRef(function ListView(props, ref) {
123
123
  });
124
124
  }
125
125
  }, [shouldBottomLoad]);
126
- // 组件方法
127
- useImperativeHandle(ref, () => ({
128
- methods: {
129
- deleteOne: methodDeleteOne,
130
- refresh: methodRefresh,
131
- },
132
- }));
133
126
  // 清除延迟状态
134
127
  const clearDelay = () => {
135
128
  clearTimeout(delayRef.current.statusTimer);
@@ -158,76 +151,10 @@ export default React.forwardRef(function ListView(props, ref) {
158
151
  const { total = 0 } = dataRef.current || {};
159
152
  return pageNo * pageSize < total;
160
153
  };
161
- /**
162
- * 列表视图拉取数据
163
- * 方法仅依赖入参和paramRef的参数
164
- * isInitData: 是否初始化数据默认否, isFetchCurrent: 是否拉取当前所有数据默认否
165
- */
166
- const fetchData = async (param, options) => {
167
- var _a;
168
- const fetchVersion = (delayRef.current.version = getUuid());
169
- const { isInitData, isFetchCurrent } = options || {};
170
- // 合并参数并保存,useEffect 中需要比对
171
- paramRef.current = {
172
- ...paramRef.current,
173
- ...param,
174
- params: { ...paramRef.current.params, ...param === null || param === void 0 ? void 0 : param.params },
175
- };
176
- const { dataSourceName, methodName, params } = paramRef.current;
177
- const { orderBy, orderType, pageNo, pageSize, where, connectorParams } = params || {};
178
- if (!(dataSourceName && methodName))
179
- return;
180
- setStatus('loading');
181
- let tcbParams = {};
182
- // tcb分页参数
183
- if (!isNil(pageNo) && !isNil(pageSize)) {
184
- tcbParams['pageNo'] = pageNo;
185
- tcbParams['pageSize'] = pageSize;
186
- }
187
- if (isModel) {
188
- // tcb排序参数
189
- if (orderBy && ORDERTYPE.includes(orderType)) {
190
- tcbParams['orderBy'] = orderBy;
191
- tcbParams['orderType'] = orderType;
192
- }
193
- // tcb过滤参数
194
- const whereEffected = [].concat(getWhereList(where));
195
- whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
196
- }
197
- else {
198
- // 内部分页参数覆盖查询入参
199
- tcbParams = Object.assign({}, connectorParams, tcbParams);
200
- }
201
- // tcb结果和事件
202
- let data = {};
203
- const eventDatasource = isModel
204
- ? datasource
205
- : { ...bindConnectMetadata, ...connectorMethod };
206
- try {
207
- if (isFetchCurrent) {
208
- data = await fetchDataLoop({ dataSourceName, methodName, params: tcbParams }, dataRef.current.records.length);
209
- }
210
- else {
211
- data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
212
- dataSourceName,
213
- methodName,
214
- params: tcbParams,
215
- }, true));
216
- }
217
- if (fetchVersion !== delayRef.current.version)
218
- return;
219
- isInitData && (dataRef.current = { total: 0, records: [] });
220
- onEvents(data, eventDatasource);
221
- }
222
- catch (e) {
223
- setStatus('fail');
224
- (_a = events === null || events === void 0 ? void 0 : events.queryFail) === null || _a === void 0 ? void 0 : _a.call(events, { datasource: eventDatasource, data: null });
225
- }
226
- };
227
154
  /**
228
155
  * 循环调用接口获取当前已加载的数据
229
156
  */
230
- const fetchDataLoop = async (param = {}, count = 0) => {
157
+ const fetchDataLoop = useCallback(async (param = {}, count = 0) => {
231
158
  let [records, total] = [[], 0];
232
159
  try {
233
160
  const { dataSourceName, methodName, params } = param || {};
@@ -248,11 +175,11 @@ export default React.forwardRef(function ListView(props, ref) {
248
175
  console.error('fetchDataLoop: ', e);
249
176
  }
250
177
  return { records: records.slice(0, count), total };
251
- };
178
+ }, [appCloud]);
252
179
  /**
253
180
  * 根据fetchData方法返回值,回调给外部事件
254
181
  */
255
- const onEvents = (data, datasource) => {
182
+ const onEvents = useCallback((data, datasource) => {
256
183
  var _a, _b;
257
184
  const fetchRecords = [].concat(!isRecords && !isModel ? data : (data === null || data === void 0 ? void 0 : data.records) || []);
258
185
  const total = Number(data === null || data === void 0 ? void 0 : data.total) || 0;
@@ -298,7 +225,82 @@ export default React.forwardRef(function ListView(props, ref) {
298
225
  else {
299
226
  successCb();
300
227
  }
301
- };
228
+ }, [beforeDataChange, events, isModel, isRecords, pagination]);
229
+ /**
230
+ * 列表视图拉取数据
231
+ * 方法仅依赖入参和paramRef的参数
232
+ * isInitData: 是否初始化数据默认否, isFetchCurrent: 是否拉取当前所有数据默认否
233
+ */
234
+ const fetchData = useCallback(async (param, options) => {
235
+ var _a;
236
+ const fetchVersion = (delayRef.current.version = getUuid());
237
+ const { isInitData, isFetchCurrent } = options || {};
238
+ // 合并参数并保存,useEffect 中需要比对
239
+ paramRef.current = {
240
+ ...paramRef.current,
241
+ ...param,
242
+ params: { ...paramRef.current.params, ...param === null || param === void 0 ? void 0 : param.params },
243
+ };
244
+ const { dataSourceName, methodName, params } = paramRef.current;
245
+ const { orderBy, orderType, pageNo, pageSize, where, connectorParams } = params || {};
246
+ if (!(dataSourceName && methodName))
247
+ return;
248
+ setStatus('loading');
249
+ let tcbParams = {};
250
+ // tcb分页参数
251
+ if (!isNil(pageNo) && !isNil(pageSize)) {
252
+ tcbParams['pageNo'] = pageNo;
253
+ tcbParams['pageSize'] = pageSize;
254
+ }
255
+ if (isModel) {
256
+ // tcb排序参数
257
+ if (orderBy && ORDERTYPE.includes(orderType)) {
258
+ tcbParams['orderBy'] = orderBy;
259
+ tcbParams['orderType'] = orderType;
260
+ }
261
+ // tcb过滤参数
262
+ const whereEffected = [].concat(getWhereList(where));
263
+ whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
264
+ }
265
+ else {
266
+ // 内部分页参数覆盖查询入参
267
+ tcbParams = Object.assign({}, connectorParams, tcbParams);
268
+ }
269
+ // tcb结果和事件
270
+ let data = {};
271
+ const eventDatasource = isModel
272
+ ? datasource
273
+ : { ...bindConnectMetadata, ...connectorMethod };
274
+ try {
275
+ if (isFetchCurrent) {
276
+ data = await fetchDataLoop({ dataSourceName, methodName, params: tcbParams }, dataRef.current.records.length);
277
+ }
278
+ else {
279
+ data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
280
+ dataSourceName,
281
+ methodName,
282
+ params: tcbParams,
283
+ }, true));
284
+ }
285
+ if (fetchVersion !== delayRef.current.version)
286
+ return;
287
+ isInitData && (dataRef.current = { total: 0, records: [] });
288
+ onEvents(data, eventDatasource);
289
+ }
290
+ catch (e) {
291
+ setStatus('fail');
292
+ (_a = events === null || events === void 0 ? void 0 : events.queryFail) === null || _a === void 0 ? void 0 : _a.call(events, { datasource: eventDatasource, data: null });
293
+ }
294
+ }, [
295
+ appCloud,
296
+ bindConnectMetadata,
297
+ connectorMethod,
298
+ datasource,
299
+ events,
300
+ fetchDataLoop,
301
+ isModel,
302
+ onEvents,
303
+ ]);
302
304
  /**
303
305
  * 计算上下文对象数据
304
306
  */
@@ -311,23 +313,19 @@ export default React.forwardRef(function ListView(props, ref) {
311
313
  /**
312
314
  * 组件刷新方法,重新初始化
313
315
  */
314
- const methodRefreshFromStart = async () => {
316
+ const methodRefreshFromStart = useCallback(async () => {
315
317
  try {
316
318
  clearDelay();
317
319
  await fetchData({ params: { pageNo: 1 } }, { isInitData: true });
318
- alertErrorMessage({
319
- message: LISTVIEW_MESSAGE.refresh_success,
320
- icon: 'success',
321
- });
322
320
  }
323
321
  catch (e) {
324
322
  alertErrorMessage({ message: LISTVIEW_MESSAGE.refresh_fail });
325
323
  }
326
- };
324
+ }, [fetchData]);
327
325
  /**
328
326
  * 组件刷新当前方法,保持当前已加载的数据列表状态
329
327
  */
330
- const methodRefreshKeepPage = async () => {
328
+ const methodRefreshKeepPage = useCallback(async () => {
331
329
  try {
332
330
  clearDelay();
333
331
  const { pageNo, pageSize } = paramRef.current.params;
@@ -342,30 +340,26 @@ export default React.forwardRef(function ListView(props, ref) {
342
340
  else {
343
341
  await methodRefreshFromStart();
344
342
  }
345
- alertErrorMessage({
346
- message: LISTVIEW_MESSAGE.refresh_success,
347
- icon: 'success',
348
- });
349
343
  }
350
344
  catch (e) {
351
345
  alertErrorMessage({ message: LISTVIEW_MESSAGE.refresh_fail });
352
346
  }
353
- };
347
+ }, [fetchData, methodRefreshFromStart, pagination]);
354
348
  /**
355
349
  * 组件刷新方法,通过类别区分
356
350
  */
357
- const methodRefresh = (params) => {
351
+ const methodRefresh = useCallback((params) => {
358
352
  if (typeof params === 'object' && (params === null || params === void 0 ? void 0 : params.type) === 'refreshKeepPage') {
359
353
  methodRefreshKeepPage();
360
354
  }
361
355
  else {
362
356
  methodRefreshFromStart();
363
357
  }
364
- };
358
+ }, [methodRefreshFromStart, methodRefreshKeepPage]);
365
359
  /**
366
360
  * 组件删除单条方法
367
361
  */
368
- const methodDeleteOne = async (params) => {
362
+ const methodDeleteOne = useCallback(async (params) => {
369
363
  try {
370
364
  if (!isModel) {
371
365
  return alertErrorMessage({
@@ -385,15 +379,18 @@ export default React.forwardRef(function ListView(props, ref) {
385
379
  params: { _id },
386
380
  }));
387
381
  await methodRefreshKeepPage();
388
- alertErrorMessage({
389
- message: LISTVIEW_MESSAGE.deleteOne_success,
390
- icon: 'success',
391
- });
392
382
  }
393
383
  catch (e) {
394
384
  alertErrorMessage({ message: LISTVIEW_MESSAGE.deleteOne_fail });
395
385
  }
396
- };
386
+ }, [appCloud, isModel, methodRefreshKeepPage]);
387
+ // 组件方法
388
+ useImperativeHandle(ref, () => ({
389
+ methods: {
390
+ deleteOne: methodDeleteOne,
391
+ refresh: methodRefresh,
392
+ },
393
+ }), [methodDeleteOne, methodRefresh]);
397
394
  /**
398
395
  * 分页,加载更多
399
396
  */
@@ -1,5 +1,7 @@
1
1
  .weda-RichTextView {
2
2
  font-size: 14px;
3
+ word-wrap: break-word;
4
+ word-break: break-all;
3
5
  }
4
6
  .weda-RichTextView blockquote {
5
7
  margin: 0 0 10px;
@@ -6,6 +6,7 @@ import { useDebouncedCallback, useEventListener, useResizeObserver, } from '@rea
6
6
  import './index.css';
7
7
  import { emptyObject } from '../../utils/constant';
8
8
  export default function Swiper({ children, className, style, autoplay = true, circular = true, vertical = false, indicatorDots, indicatorColor = 'rgba(200, 200, 200, 0.9)', indicatorActiveColor = 'rgba(0, 0, 0, 0.9)', duration = 500, interval = 5000, current = 0, events = emptyObject, id, }) {
9
+ var _a;
9
10
  const originChildrenRef = useRef(null);
10
11
  const [realChildren, setRealChildren] = useState([]);
11
12
  const itemCount = React.Children.count(realChildren);
@@ -15,14 +16,19 @@ export default function Swiper({ children, className, style, autoplay = true, ci
15
16
  const [height, setHeight] = useState(0);
16
17
  const { change = () => { } } = events;
17
18
  useEffect(() => {
18
- const realChildren = Array.from(originChildrenRef.current.children).map((elem) => {
19
- const reactFiberProp = Object.keys(elem).find((prop) => prop.startsWith('__reactInternalInstance'));
20
- const reactFiber = elem[reactFiberProp];
21
- const reactElem = React.createElement(reactFiber.elementType, reactFiber.pendingProps);
22
- return reactElem;
23
- });
24
- setRealChildren(realChildren);
25
- }, [children]);
19
+ // 等待dom渲染完成
20
+ // eslint-disable-next-line rulesdir/no-timer
21
+ const timer = setTimeout(() => {
22
+ const realChildren = Array.from(originChildrenRef.current.children).map((elem) => {
23
+ const reactFiberProp = Object.keys(elem).find((prop) => prop.startsWith('__reactInternalInstance'));
24
+ const reactFiber = elem[reactFiberProp];
25
+ const reactElem = React.createElement(reactFiber.elementType, reactFiber.pendingProps);
26
+ return reactElem;
27
+ });
28
+ setRealChildren(realChildren);
29
+ }, 0);
30
+ return () => clearTimeout(timer);
31
+ }, [(_a = originChildrenRef.current) === null || _a === void 0 ? void 0 : _a.children, children]);
26
32
  useEffect(() => {
27
33
  if (autoplay) {
28
34
  // 自动切换
@@ -422,7 +422,7 @@ export const BaseTable = (props) => {
422
422
  connectorParamsRef.current = connectorParams;
423
423
  }
424
424
  }, [connectorParams]);
425
- // 移动端和自定义APIs场景不支持导入功能,监听变化存到表格上下文中
425
+ // 移动端和APIs场景不支持导入功能,监听变化存到表格上下文中
426
426
  useEffect(() => {
427
427
  handleContext({ state: { isH5, isModel } });
428
428
  }, [isH5, isModel]);
@@ -661,7 +661,7 @@ export const BaseTable = (props) => {
661
661
  // 刷新表格(查看当前页数据)
662
662
  refreshKeepPage: () => fetchData({ searchValues, pageSize, pageNo: pageIndex }),
663
663
  },
664
- }));
664
+ }), [pageIndex, pageSize, searchValues, selectedKeys, records]);
665
665
  // 表格选中事件
666
666
  const handleRowsSelect = (keys) => {
667
667
  if (events === null || events === void 0 ? void 0 : events.rowsSelect) {
@@ -975,7 +975,7 @@ export const BaseTable = (props) => {
975
975
  return slotRender(slots.globalButton);
976
976
  }
977
977
  else if (enableGlobalButton === undefined) {
978
- // 移动端和自定义APIs场景不支持导入功能
978
+ // 移动端和APIs场景不支持导入功能
979
979
  const buttonsList = isH5 || !isModel
980
980
  ? buttons.filter((i) => i.action !== 'import')
981
981
  : buttons;
@@ -1,8 +1,9 @@
1
1
  import useSWR from 'swr';
2
2
  import { getTempFileURL } from '../tcb';
3
+ import { transFileCloudidToName } from '../platform';
3
4
  export function useTempUrl(cloudId) {
4
5
  const prefix = 'tcb:cloud-id:temp-url';
5
- const key = `${prefix}:${cloudId}`;
6
+ const key = `${prefix}:${transFileCloudidToName(cloudId)}`;
6
7
  return useSWR(key, async () => {
7
8
  if (!(cloudId === null || cloudId === void 0 ? void 0 : cloudId.startsWith('cloud://'))) {
8
9
  return cloudId;
@@ -152,7 +152,7 @@ export const isWXIDE = () => /wechatideplugin/i.test(navigator.userAgent);
152
152
  export const resolveStaticResourceUrl = (path) => {
153
153
  var _a, _b;
154
154
  try {
155
- // eslint-disable-next-line no-unsafe-optional-chaining
155
+ // eslint-disable-next-line no-unsafe-optional-chaining, prettier/prettier
156
156
  const resourceUrl = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.__internal__) === null || _b === void 0 ? void 0 : _b.resolveStaticResourceUrl(path);
157
157
  return resourceUrl;
158
158
  }
@@ -349,3 +349,11 @@ export const getUserInfo = () => {
349
349
  export const isSupportLoading = () => {
350
350
  return 'loading' in HTMLImageElement.prototype;
351
351
  };
352
+ /**
353
+ * 判断web是否被小程序嵌套
354
+ */
355
+ export const isWebInMiniprogram = () => {
356
+ var ua = navigator.userAgent.toLowerCase();
357
+ return ((ua.match(/micromessenger/i) && ua.match(/miniprogram/i)) ||
358
+ window['__wxjs_environment'] === 'miniprogram');
359
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -61,7 +61,7 @@
61
61
  "license": "MIT",
62
62
  "description": "腾讯云微搭低代码组件库模板",
63
63
  "dependencies": {
64
- "@antv/g6": "3.8.5",
64
+ "@antv/g6": "^4.8.5",
65
65
  "@loadable/component": "^5.15.2",
66
66
  "@react-hookz/web": "^14.2.2",
67
67
  "@sinclair/typebox": "^0.25.3",
@@ -85,7 +85,7 @@
85
85
  "react-infinite-scroll-component": "6.1.0",
86
86
  "react-vant": "3.0.0-rc.7",
87
87
  "spark-md5": "^3.0.2",
88
- "swr": "^1.3.0",
88
+ "swr": "^2.0.3",
89
89
  "tdesign-icons-react": "0.0.8",
90
90
  "tea-component": "^2.7.8",
91
91
  "uuid": "8.3.2",