@cloudbase/weda-ui 3.8.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/configs/components/dataView.d.ts +14 -0
  2. package/dist/configs/components/dataView.js +104 -6
  3. package/dist/configs/components/listView.d.ts +29 -0
  4. package/dist/configs/components/listView.js +145 -24
  5. package/dist/configs/components/wd-input-number.d.ts +8 -0
  6. package/dist/configs/components/wd-input-number.js +9 -0
  7. package/dist/configs/components/wd-markdown.d.ts +95 -0
  8. package/dist/configs/components/wd-markdown.js +142 -0
  9. package/dist/configs/components/wd-menu-layout.d.ts +13 -10
  10. package/dist/configs/components/wd-menu-layout.js +12 -1
  11. package/dist/configs/components/wd-menu-nav-tab-layou.d.ts +27 -0
  12. package/dist/configs/components/wd-menu-nav-tab-layou.js +31 -0
  13. package/dist/configs/components/wd-table.d.ts +1 -1
  14. package/dist/configs/components/wd-table.js +1 -0
  15. package/dist/configs/index.d.ts +340 -10
  16. package/dist/configs/index.js +4 -0
  17. package/dist/configs/type-utils/type-form.js +1 -1
  18. package/dist/configs/utils/layout.d.ts +1 -1
  19. package/dist/configs/utils/layout.js +215 -6
  20. package/dist/style/index.scss +1 -1
  21. package/dist/web/components/dataView/index.js +5 -3
  22. package/dist/web/components/index.d.ts +2 -0
  23. package/dist/web/components/index.js +4 -0
  24. package/dist/web/components/listView/index.js +48 -13
  25. package/dist/web/components/listView/interface.d.ts +4 -0
  26. package/dist/web/components/listView/useQueryParams.d.ts +11 -0
  27. package/dist/web/components/listView/useQueryParams.js +23 -0
  28. package/dist/web/components/richTextView/index.js +4 -38
  29. package/dist/web/components/richTextView/useImgTransform.d.ts +1 -0
  30. package/dist/web/components/richTextView/useImgTransform.js +47 -0
  31. package/dist/web/components/wd-input-number/wd-input-number.js +16 -9
  32. package/dist/web/components/wd-markdown/github-markdown-light.css +1139 -0
  33. package/dist/web/components/wd-markdown/index.d.ts +4 -0
  34. package/dist/web/components/wd-markdown/index.js +3 -0
  35. package/dist/web/components/wd-markdown/style.d.ts +3 -0
  36. package/dist/web/components/wd-markdown/style.js +3 -0
  37. package/dist/web/components/wd-markdown/wd-markdown.d.ts +7 -0
  38. package/dist/web/components/wd-markdown/wd-markdown.js +88 -0
  39. package/dist/web/components/wd-menu-layout/components/H5Menu.js +3 -1
  40. package/dist/web/components/wd-menu-layout/components/NavTabMenu.d.ts +3 -0
  41. package/dist/web/components/wd-menu-layout/components/NavTabMenu.js +7 -0
  42. package/dist/web/components/wd-menu-layout/style.d.ts +1 -0
  43. package/dist/web/components/wd-menu-layout/style.js +1 -0
  44. package/dist/web/components/wd-menu-layout/wd-menu-layout.js +5 -2
  45. package/dist/web/components/wd-menu-nav-tab-layout/index.d.ts +6 -0
  46. package/dist/web/components/wd-menu-nav-tab-layout/index.js +5 -0
  47. package/dist/web/components/wd-table/components/FieldRender/index.js +5 -2
  48. package/dist/web/utils/getModelParams.d.ts +2 -0
  49. package/dist/web/utils/getModelParams.js +73 -4
  50. package/package.json +5 -2
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React, { useCallback, useImperativeHandle, useState, useRef, } from 'react';
2
+ import React, { useCallback, useState, useRef } from 'react';
3
+ import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
3
4
  import ListView from '../listView';
4
5
  import { useLoopRenderDetect } from '../common/use-loop-render-detect';
5
6
  /**
@@ -16,10 +17,11 @@ export default React.forwardRef(function DataView(props, ref) {
16
17
  }, []);
17
18
  const refresh = useCallback(() => { var _a, _b; return (_b = (_a = listViewRef.current) === null || _a === void 0 ? void 0 : _a.refresh) === null || _b === void 0 ? void 0 : _b.call(_a); }, [listViewRef.current]);
18
19
  const deleteOne = useCallback((params) => { var _a, _b; return (_b = (_a = listViewRef.current) === null || _a === void 0 ? void 0 : _a.deleteOne) === null || _b === void 0 ? void 0 : _b.call(_a, params); }, [listViewRef.current]);
19
- useImperativeHandle(ref, () => ({ record, refresh, deleteOne }), [
20
+ useSetWidgetApi(() => ({
20
21
  record,
21
22
  refresh,
22
23
  deleteOne,
23
- ]);
24
+ dataSourceVersion: props.supportManyRelated ? 'v2' : 'v1',
25
+ }), [record, refresh, deleteOne, props.supportManyRelated], ref);
24
26
  return (_jsx(ListView, { ...props, ref: listViewRef, isRecords: false, orderBy: undefined, orderType: undefined, template: "none", pageSize: 1, pagination: "none", beforeDataChange: beforeDataChange, refType: "dataView", dataSourceData: [].concat(props.dataSourceData) }));
25
27
  });
@@ -128,6 +128,7 @@ export { default as WdMenPlantLayout } from "./wd-menu-plant-layout";
128
128
  export { default as WdMenuVerticalLayout } from "./wd-menu-vertical-layout";
129
129
  export { default as WdMenuTabLayout } from "./wd-menu-tab-layout";
130
130
  export { default as WdMenuNavLayout } from "./wd-menu-nav-layout";
131
+ export { default as WdMenuNavTabLayout } from "./wd-menu-nav-tab-layout";
131
132
  export { default as WdMenuList } from "./wd-menu-list";
132
133
  export { default as WdCard } from "./wd-card";
133
134
  export { default as WdLayout } from "./wd-layout";
@@ -142,6 +143,7 @@ export const WdCodeEditor: any;
142
143
  export const WdMember: any;
143
144
  export const WdLocation: any;
144
145
  export const WdRichText: any;
146
+ export const WdMarkdown: any;
145
147
  export { default as WdCanvas } from "./wd-canvas";
146
148
  export { default as WdAudio } from "./wd-audio";
147
149
  export { default as WdFormObj } from "./wd-form-obj";
@@ -177,6 +177,7 @@ export { default as WdMenPlantLayout } from './wd-menu-plant-layout';
177
177
  export { default as WdMenuVerticalLayout } from './wd-menu-vertical-layout';
178
178
  export { default as WdMenuTabLayout } from './wd-menu-tab-layout';
179
179
  export { default as WdMenuNavLayout } from './wd-menu-nav-layout';
180
+ export { default as WdMenuNavTabLayout } from './wd-menu-nav-tab-layout';
180
181
  export { default as WdMenuList } from './wd-menu-list';
181
182
  // export { default as WdLoading } from './wd-loading';
182
183
  export { default as WdCard } from './wd-card';
@@ -201,6 +202,9 @@ export const WdLocation = loadable(() => import('./wd-location'), {
201
202
  export const WdRichText = loadable(() => import('./wd-rich-text'), {
202
203
  fallback,
203
204
  });
205
+ export const WdMarkdown = loadable(() => import('./wd-markdown'), {
206
+ fallback,
207
+ });
204
208
  export { default as WdCanvas } from './wd-canvas';
205
209
  export { default as WdAudio } from './wd-audio';
206
210
  export { default as WdFormObj } from './wd-form-obj';
@@ -12,6 +12,7 @@ import { useLoopRenderDetect } from '../common/use-loop-render-detect';
12
12
  import { getModelParams } from '../../utils/getModelParams';
13
13
  import { WdCompError } from '../../utils/error';
14
14
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
15
+ import { useQueryParams } from './useQueryParams';
15
16
  const BLOCK_NAME = 'weda-list-view';
16
17
  const LISTVIEW_MESSAGE = {
17
18
  methods_no_support: '当前组件绑定了APIs,暂不支持进行数据删除',
@@ -25,6 +26,17 @@ const getIdeMockData = (length = 3) => Array.from({ length }).map(() => Object.c
25
26
  const getStringValue = (v) => (typeof v === 'string' ? v : '');
26
27
  const defaultCloudbase = { callDataSource, isInIde };
27
28
  const defaultBeforeDataChange = (v) => v;
29
+ const getQueryParams = (isV2protocol, params) => {
30
+ if (isV2protocol) {
31
+ params.getCount = true;
32
+ params.pageNumber = params.pageNo;
33
+ if (params.orderBy && ['asc', 'desc'].includes(params.orderType)) {
34
+ params.orderBy = [{ [params.orderBy]: params.orderType }];
35
+ }
36
+ params.compatibleWithV1 = true;
37
+ }
38
+ return params;
39
+ };
28
40
  /**
29
41
  * 数据容器-列表视图
30
42
  */
@@ -33,13 +45,14 @@ export default React.forwardRef(function ListView(props, ref) {
33
45
  const { dataSourceType, bindConnectMetadata, connectorMethod, connectorParams: rawConnectorParams, datasource, dataSourceData: rawDataSourceData, // 表达式: 值
34
46
  template, enableTotal, // 表达式: 启用动态分页
35
47
  total: rawTotal, // 表达式: 总页数
36
- pageSize = 5, pagination, events, className, children, isRecords = true, //是否展示回调recoreds字段
48
+ pageSize = 5, pageIndex: _pageNo = 1, pagination, events, className, children, isRecords = true, //是否展示回调records字段
37
49
  isSetStatus: rawIsSetStatus = false, //是否开启异常状态
38
50
  isSetLoading: rawIsSetLoading = true, // 是否开启加载状态
39
51
  loading = false, // 数据加载状态,仅表达式生效
40
52
  emptyText, //空状态时的文案
41
53
  loadCompletedText = '', // 加载到底提示
42
- appCloud = defaultCloudbase, beforeDataChange = defaultBeforeDataChange, refType = 'listView', loadButtonText, ...rest } = props;
54
+ appCloud = defaultCloudbase, beforeDataChange = defaultBeforeDataChange, refType = 'listView', loadButtonText, selectFieldType = 'main', // 查询字段范围类型
55
+ ...rest } = props;
43
56
  const platform = usePlatform();
44
57
  const isH5 = platform === 'h5';
45
58
  const isSetStatus = dataSourceType !== 'expression' ? rawIsSetStatus : false;
@@ -50,6 +63,7 @@ export default React.forwardRef(function ListView(props, ref) {
50
63
  const methodName = getStringValue(dataSourceType === 'data-model'
51
64
  ? ((_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName) || 'wedaGetRecords'
52
65
  : connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name);
66
+ const isV2protocol = methodName === 'wedaGetRecordsV2';
53
67
  const dataSourceName = getStringValue(dataSourceType === 'data-model'
54
68
  ? datasource === null || datasource === void 0 ? void 0 : datasource.name
55
69
  : (_b = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _b === void 0 ? void 0 : _b.name);
@@ -66,7 +80,7 @@ export default React.forwardRef(function ListView(props, ref) {
66
80
  const paramRef = useRef({
67
81
  dataSourceName,
68
82
  methodName,
69
- params: { pageNo: 1, pageSize, connectorParams, modelParams },
83
+ params: { pageNo: _pageNo, pageSize, connectorParams, modelParams },
70
84
  pagination,
71
85
  }); // 最新请求参数
72
86
  const exprRef = useRef({ total: 0, dataSourceData: [], enableTotal }); // 对比表达式变化
@@ -90,6 +104,13 @@ export default React.forwardRef(function ListView(props, ref) {
90
104
  message: '',
91
105
  requestId: '',
92
106
  });
107
+ const isReadyToGetAuthField = dataSourceType === 'data-model' && isV2protocol && !!dataSourceName;
108
+ const { queryParams, fieldsLoading } = useQueryParams({
109
+ dataSourceName,
110
+ isReadyToGetAuthField,
111
+ selectFieldType,
112
+ modelParams,
113
+ });
93
114
  // 组件卸载时触发
94
115
  useEffect(() => {
95
116
  clearContext();
@@ -109,13 +130,18 @@ export default React.forwardRef(function ListView(props, ref) {
109
130
  var _a, _b;
110
131
  clearDelay();
111
132
  if (!isIdeMockData) {
133
+ // authFields 加载中,不触发请求
134
+ if (isV2protocol && fieldsLoading) {
135
+ return;
136
+ }
112
137
  fetchData({
113
138
  dataSourceName,
114
139
  methodName,
115
140
  params: {
116
141
  ...(_a = paramRef.current) === null || _a === void 0 ? void 0 : _a.params,
117
- pageNo: 1,
142
+ pageNo: _pageNo,
118
143
  pageSize,
144
+ modelParams: queryParams,
119
145
  },
120
146
  pagination,
121
147
  }, {
@@ -128,15 +154,15 @@ export default React.forwardRef(function ListView(props, ref) {
128
154
  state: getContextState(),
129
155
  });
130
156
  }
131
- }, [methodName, dataSourceName, pageSize, pagination, dataSourceType]);
157
+ }, [methodName, dataSourceName, pageSize, _pageNo, pagination, dataSourceType, isV2protocol, isIdeMockData, fieldsLoading]);
132
158
  // props 对象类型监听,需重新分页
133
159
  useEffect(() => {
134
160
  var _a, _b, _c, _d;
135
161
  if (dataSourceType === 'data-model') {
136
- if (!isequal((_b = (_a = paramRef.current) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.modelParams, modelParams)) {
162
+ if (!isequal((_b = (_a = paramRef.current) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.modelParams, queryParams)) {
137
163
  clearDelay();
138
164
  fetchData({
139
- params: { pageNo: 1, modelParams },
165
+ params: { pageNo: _pageNo, modelParams: queryParams },
140
166
  }, { isInitData: true });
141
167
  }
142
168
  }
@@ -205,7 +231,7 @@ export default React.forwardRef(function ListView(props, ref) {
205
231
  const temp = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
206
232
  dataSourceName,
207
233
  methodName,
208
- params: tcbParams,
234
+ params: getQueryParams(isV2protocol, tcbParams),
209
235
  swr: param.swr,
210
236
  }, true));
211
237
  records = records.concat(temp.records || []);
@@ -216,7 +242,7 @@ export default React.forwardRef(function ListView(props, ref) {
216
242
  console.error('fetchDataLoop: ', e);
217
243
  }
218
244
  return { records: records.slice(0, count), total };
219
- }, [appCloud]);
245
+ }, [appCloud, isV2protocol]);
220
246
  // 加载成功(包含为空)事件
221
247
  const onSuccessCb = useCallback(({ records, total, isTriggerEmpty, datasource }) => {
222
248
  var _a, _b;
@@ -317,7 +343,7 @@ export default React.forwardRef(function ListView(props, ref) {
317
343
  * isInitData: 是否初始化数据默认否, isFetchCurrent: 是否拉取当前所有数据默认否
318
344
  */
319
345
  const fetchData = useCallback(async (param, options) => {
320
- var _a, _b, _c;
346
+ var _a, _b, _c, _d;
321
347
  const { isInitData, isFetchCurrent } = options || {};
322
348
  // 合并参数并保存,useEffect 中需要比对
323
349
  paramRef.current = {
@@ -330,8 +356,13 @@ export default React.forwardRef(function ListView(props, ref) {
330
356
  // 不触发请求
331
357
  if (!(dataSourceName && methodName) && dataSourceType !== 'expression')
332
358
  return;
359
+ // select为空时,不触发请求
360
+ if (isV2protocol && !((_a = Object.keys(modelParams === null || modelParams === void 0 ? void 0 : modelParams.select)) === null || _a === void 0 ? void 0 : _a.length)) {
361
+ setStatus('loading');
362
+ return;
363
+ }
333
364
  // 分页变化事件
334
- (_a = events === null || events === void 0 ? void 0 : events.onPagingChange) === null || _a === void 0 ? void 0 : _a.call(events, { query: { pageNo, pageSize } });
365
+ (_b = events === null || events === void 0 ? void 0 : events.onPagingChange) === null || _b === void 0 ? void 0 : _b.call(events, { query: { pageNo, pageSize } });
335
366
  setStatus('loading');
336
367
  // 前端分页时,应该触发表达式
337
368
  if (dataSourceType === 'expression') {
@@ -365,7 +396,7 @@ export default React.forwardRef(function ListView(props, ref) {
365
396
  data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
366
397
  dataSourceName,
367
398
  methodName,
368
- params: tcbParams,
399
+ params: getQueryParams(isV2protocol, tcbParams),
369
400
  swr: param.swr,
370
401
  }, true));
371
402
  }
@@ -400,7 +431,7 @@ export default React.forwardRef(function ListView(props, ref) {
400
431
  : refType === 'dataView'
401
432
  ? 'WdDataView.QueryError'
402
433
  : 'WdListView.QueryError',
403
- requestId: (_c = (_b = e === null || e === void 0 ? void 0 : e.original) === null || _b === void 0 ? void 0 : _b.original) === null || _c === void 0 ? void 0 : _c.requestId,
434
+ requestId: (_d = (_c = e === null || e === void 0 ? void 0 : e.original) === null || _c === void 0 ? void 0 : _c.original) === null || _d === void 0 ? void 0 : _d.requestId,
404
435
  original: e === null || e === void 0 ? void 0 : e.original,
405
436
  });
406
437
  }
@@ -418,6 +449,8 @@ export default React.forwardRef(function ListView(props, ref) {
418
449
  events,
419
450
  enableTotal,
420
451
  setExpression,
452
+ isV2protocol,
453
+ fieldsLoading,
421
454
  ]);
422
455
  // 计算上下文对象数据
423
456
  const getContextState = (state = {}) => {
@@ -515,6 +548,7 @@ export default React.forwardRef(function ListView(props, ref) {
515
548
  total,
516
549
  pageNo,
517
550
  pageSize: statePageSize,
551
+ dataSourceVersion: isV2protocol ? 'v2' : 'v1',
518
552
  // 组件方法
519
553
  deleteOne: async (_id) => {
520
554
  try {
@@ -558,6 +592,7 @@ export default React.forwardRef(function ListView(props, ref) {
558
592
  methodRefresh,
559
593
  dataRef.current.records,
560
594
  err,
595
+ isV2protocol,
561
596
  ], ref);
562
597
  /**
563
598
  * 分页,加载更多
@@ -113,6 +113,10 @@ export interface IListView extends IDataContainer {
113
113
  * 显示行数
114
114
  */
115
115
  pageSize?: number;
116
+ /**
117
+ * 页码
118
+ */
119
+ pageNo?: number;
116
120
  /**
117
121
  * 分页类型,加载更多|底部刷新|分页器
118
122
  */
@@ -0,0 +1,11 @@
1
+ interface QueryParams {
2
+ fieldsLoading: boolean;
3
+ queryParams: any;
4
+ }
5
+ export declare const useQueryParams: ({ dataSourceName, isReadyToGetAuthField, selectFieldType, modelParams, }: {
6
+ dataSourceName: any;
7
+ isReadyToGetAuthField: any;
8
+ selectFieldType: any;
9
+ modelParams: any;
10
+ }) => QueryParams;
11
+ export {};
@@ -0,0 +1,23 @@
1
+ import { useMemo } from 'react';
2
+ import { useDataSource } from '../../utils/hooks/useDataSource';
3
+ export const useQueryParams = ({ dataSourceName, isReadyToGetAuthField, selectFieldType, modelParams, }) => {
4
+ const needQueryFields = selectFieldType === 'all';
5
+ const { data: dataSource, error } = useDataSource(isReadyToGetAuthField && needQueryFields ? dataSourceName : '');
6
+ const queryParams = useMemo(() => {
7
+ var _a;
8
+ const result = {
9
+ fieldsLoading: needQueryFields,
10
+ queryParams: modelParams,
11
+ };
12
+ if (selectFieldType === 'all') {
13
+ const select = {};
14
+ Object.keys(((_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.schema) === null || _a === void 0 ? void 0 : _a.properties) || {}).forEach((name) => {
15
+ select[name] = true;
16
+ });
17
+ result.queryParams.select = select;
18
+ result.fieldsLoading = !error && !dataSource;
19
+ }
20
+ return result;
21
+ }, [dataSource, error, modelParams, needQueryFields, selectFieldType]);
22
+ return queryParams;
23
+ };
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
2
+ import { useEffect, useRef } from 'react';
3
3
  import classNames from '../../utils/classnames';
4
- import { getTempFileURL } from '../../utils/tcb';
5
- import { LOAD_ERR_IMG_BASE64, getWhitelist } from '../../utils/constant';
4
+ import { getWhitelist } from '../../utils/constant';
6
5
  import { getOnClick } from '../wd-unified-link/utils';
6
+ import { useImgTransform } from './useImgTransform';
7
7
  import destr from 'destr';
8
8
  import './style';
9
9
  import xss from 'xss';
@@ -14,41 +14,7 @@ export default function RichTextView({ value = '', className, style, id, }) {
14
14
  'weda-RichTextView': true,
15
15
  [className]: className,
16
16
  });
17
- const [displayValue, setDisplayValue] = useState('');
18
- const regex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
19
- const iferror = `javascript:this.width='80';this.src='${LOAD_ERR_IMG_BASE64}';this.onerror=null`;
20
- let tempValue = (parseValue || '')
21
- .toString()
22
- .replace(/<img style="/g, `<img style="max-width:100%;`)
23
- .replace(/<img /g, `<img onerror=${iferror} `);
24
- const getSrc = async (img) => {
25
- const url = img.replace(regex, '$1');
26
- if (img.includes('cloud://')) {
27
- const newURL = await getTempFileURL(url);
28
- if (newURL) {
29
- tempValue = tempValue.replace(new RegExp(url, 'g'), newURL);
30
- }
31
- }
32
- };
33
- useEffect(() => {
34
- try {
35
- const imgs = parseValue.match(regex);
36
- if (imgs && imgs.length > 0) {
37
- (async () => {
38
- await Promise.all(imgs.map(async (img) => {
39
- await getSrc(img);
40
- }));
41
- setDisplayValue(tempValue);
42
- })();
43
- }
44
- else {
45
- setDisplayValue(tempValue);
46
- }
47
- }
48
- catch (e) {
49
- setDisplayValue(tempValue);
50
- }
51
- }, [value]);
17
+ const displayValue = useImgTransform(parseValue);
52
18
  const richTextRef = useRef(null);
53
19
  useEffect(() => {
54
20
  if (richTextRef.current) {
@@ -0,0 +1 @@
1
+ export declare const useImgTransform: (value: string) => string;
@@ -0,0 +1,47 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { getTempFileURL } from '../../utils/tcb';
3
+ import { LOAD_ERR_IMG_BASE64 } from '../../utils/constant';
4
+ const regex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
5
+ const iferror = `javascript:this.width='80';this.src='${LOAD_ERR_IMG_BASE64}';this.onerror=null`;
6
+ const transformImag = (value) => {
7
+ return (value || '')
8
+ .toString()
9
+ .replace(/<img style="/g, `<img style="max-width:100%;`)
10
+ .replace(/<img /g, `<img onerror=${iferror} `);
11
+ };
12
+ const getSrc = async (img) => {
13
+ const url = img.replace(regex, '$1');
14
+ if (img.includes('cloud://')) {
15
+ return await getTempFileURL(url);
16
+ }
17
+ };
18
+ export const useImgTransform = (value) => {
19
+ const [displayValue, setDisplayValue] = useState('');
20
+ useEffect(() => {
21
+ let tempValue = transformImag(value);
22
+ try {
23
+ const imgs = value.match(regex);
24
+ if (imgs && imgs.length > 0) {
25
+ (async () => {
26
+ const imgRes = await Promise.all(imgs.map(async (img) => {
27
+ return await getSrc(img);
28
+ }));
29
+ imgs.forEach((img, index) => {
30
+ const url = img.replace(regex, '$1');
31
+ if (imgRes[index]) {
32
+ tempValue = tempValue.replace(new RegExp(url, 'g'), imgRes[index]);
33
+ }
34
+ });
35
+ setDisplayValue(tempValue);
36
+ })();
37
+ }
38
+ else {
39
+ setDisplayValue(tempValue);
40
+ }
41
+ }
42
+ catch (e) {
43
+ setDisplayValue(tempValue);
44
+ }
45
+ }, [value]);
46
+ return displayValue;
47
+ };
@@ -322,6 +322,7 @@ export const WdInputNumber = forwardRef(function WdInputNumber(props, ref) {
322
322
  const onChange = (e) => {
323
323
  const value = typeof e === 'string' ? e : e.target.value;
324
324
  setShowValue(value);
325
+ onRealChange(e, '', { needSetData: false, value });
325
326
  };
326
327
  /**
327
328
  * 真实值变化
@@ -329,22 +330,28 @@ export const WdInputNumber = forwardRef(function WdInputNumber(props, ref) {
329
330
  * @param type
330
331
  * @returns
331
332
  */
332
- const onRealChange = (e, type = '') => {
333
- var _a, _b;
333
+ const onRealChange = (e, type = '', { needSetData = true, value = '' } = {}) => {
334
+ var _a, _b, _c, _d;
334
335
  if (editDisabled)
335
336
  return realValue;
336
337
  if (['plus', 'minus'].includes(type)) {
337
338
  if (!isNumber(props.step) ||
338
339
  (type === 'plus' && stepPlusDisabled) ||
339
- (type === 'minus' && stepMinusDisabled))
340
- return Number(showValue);
340
+ (type === 'minus' && stepMinusDisabled)) {
341
+ return Number(value || showValue);
342
+ }
341
343
  }
342
- const toShow = getShowValue(filterDigit(showValue), type);
344
+ const toShow = getShowValue(filterDigit(value || showValue), type);
343
345
  const toReal = getRealValue(toShow);
344
- setShowValue(toShow);
345
- setRealValue(toReal);
346
- changeForm(toReal);
347
- (_b = (_a = props.events) === null || _a === void 0 ? void 0 : _a.change) === null || _b === void 0 ? void 0 : _b.call(_a, { value: toReal }, { originEvent: e });
346
+ if (needSetData) {
347
+ setShowValue(toShow);
348
+ setRealValue(toReal);
349
+ changeForm(toReal);
350
+ (_b = (_a = props.events) === null || _a === void 0 ? void 0 : _a.change) === null || _b === void 0 ? void 0 : _b.call(_a, { value: toReal }, { originEvent: e });
351
+ }
352
+ else {
353
+ (_d = (_c = props.events) === null || _c === void 0 ? void 0 : _c.input) === null || _d === void 0 ? void 0 : _d.call(_c, { value: toReal }, { originEvent: e });
354
+ }
348
355
  return toReal;
349
356
  };
350
357
  const onClear = (e) => {