@cloudbase/weda-ui 3.14.4 → 3.15.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 (44) hide show
  1. package/dist/configs/components/listView.d.ts +11 -0
  2. package/dist/configs/components/listView.js +53 -0
  3. package/dist/configs/components/wd-select-multiple.d.ts +72 -28
  4. package/dist/configs/components/wd-select-multiple.js +233 -19
  5. package/dist/configs/components/wd-select.d.ts +70 -29
  6. package/dist/configs/components/wd-select.js +211 -17
  7. package/dist/configs/index.d.ts +174 -60
  8. package/dist/configs/type-utils/type-form.js +65 -21
  9. package/dist/configs/type-utils/x-runtime-default.d.ts +2 -0
  10. package/dist/configs/type-utils/x-runtime-default.js +4 -0
  11. package/dist/style/index.css +15 -0
  12. package/dist/style/index.scss +1 -1
  13. package/dist/style/weda-ui.min.css +3 -3
  14. package/dist/web/components/form/uploader/util.js +3 -2
  15. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +3 -2
  16. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +3 -2
  17. package/dist/web/components/listView/index.css +4 -2
  18. package/dist/web/components/listView/index.js +25 -43
  19. package/dist/web/components/richText/index.js +3 -2
  20. package/dist/web/components/statusContent/index.js +1 -1
  21. package/dist/web/components/wd-input/wd-input.js +16 -20
  22. package/dist/web/components/wd-select/contexts/selectContext.d.ts +15 -0
  23. package/dist/web/components/wd-select/contexts/selectContext.js +13 -0
  24. package/dist/web/components/wd-select/hooks/useChooseList.d.ts +19 -0
  25. package/dist/web/components/wd-select/hooks/useChooseList.js +94 -0
  26. package/dist/web/components/wd-select/relationSelect/enumSelect.d.ts +2 -0
  27. package/dist/web/components/wd-select/relationSelect/enumSelect.js +48 -0
  28. package/dist/web/components/wd-select/relationSelect/index.d.ts +2 -0
  29. package/dist/web/components/wd-select/relationSelect/index.js +19 -0
  30. package/dist/web/components/wd-select/relationSelect/queryParams.d.ts +15 -0
  31. package/dist/web/components/wd-select/relationSelect/queryParams.js +15 -0
  32. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +0 -2
  33. package/dist/web/components/wd-select/relationSelect/relationSelect.js +39 -83
  34. package/dist/web/components/wd-select/select/index.js +1 -1
  35. package/dist/web/components/wd-select/wd-select.css +8 -0
  36. package/dist/web/components/wd-select/wd-select.js +11 -8
  37. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +11 -8
  38. package/dist/web/components/wd-table/components/FieldRender/index.js +3 -3
  39. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +8 -13
  40. package/dist/web/utils/getModelParams.d.ts +6 -1
  41. package/dist/web/utils/getModelParams.js +16 -13
  42. package/dist/web/utils/tcb.d.ts +4 -0
  43. package/dist/web/utils/tcb.js +11 -9
  44. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import { compressImage } from './compress';
2
- import { getCloudInstance } from '../../../utils/tcb';
2
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
3
3
  import { toBase64Uri } from '../../../utils/file2base64';
4
4
  import { randomStr } from '../../../utils/platform';
5
5
  import { errorHandler } from '../../../utils/error';
@@ -41,7 +41,8 @@ const uploadToTcb = async (item, props) => {
41
41
  const { file, uploadPath } = item;
42
42
  try {
43
43
  const tcb = await getCloudInstance();
44
- const cloudPath = `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`;
44
+ const _uploadPath = getDefaultUploadPath(uploadPath);
45
+ const cloudPath = `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`;
45
46
  const { fileID } = await tcb.uploadFile({
46
47
  cloudPath,
47
48
  filePath: file,
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import isObjectEqual from '../../../utils/isObjectEqual';
4
4
  import { ConfigProvider, Button, Text, List, Progress, Tooltip } from 'tea-component';
5
5
  import { filterStrList, isCloudFileID, isHttpFileID, transSize, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, alertErrorMessage, } from '../../../utils/platform';
6
- import { getCloudInstance } from '../../../utils/tcb';
6
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
7
7
  import classNames from '../../../utils/classnames';
8
8
  import { renderDecorator } from '../renderDecorator';
9
9
  import { emptyArray, emptyObject } from '../../../utils/constant';
@@ -263,8 +263,9 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
263
263
  const tcb = await getCloudInstance();
264
264
  try {
265
265
  setStatus('UPLOAD_STATUS_PENDING');
266
+ const _uploadPath = getDefaultUploadPath(uploadPath);
266
267
  const { fileID } = await tcb.uploadFile({
267
- cloudPath: `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
268
+ cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
268
269
  filePath: file,
269
270
  onUploadProgress: (progressEvent) => {
270
271
  let percent = 0;
@@ -4,7 +4,7 @@ import { Upload, ConfigProvider, Icon, List } from 'tea-component';
4
4
  import { WdButton } from '../../wd-button';
5
5
  import { WdText } from '../../wd-text';
6
6
  import { filterStrList, isCloudFileID, isHttpFileID, isDataUri, transSize, cutFileTitle, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, alertErrorMessage, } from '../../../utils/platform';
7
- import { getCloudInstance } from '../../../utils/tcb';
7
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
8
8
  import classNames from '../../../utils/classnames';
9
9
  import { renderDecorator } from '../renderDecorator';
10
10
  import isObjectEqual from '../../../utils/isObjectEqual';
@@ -255,8 +255,9 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
255
255
  const tcb = await getCloudInstance();
256
256
  try {
257
257
  setStatus('0');
258
+ const _uploadPath = getDefaultUploadPath(uploadPath);
258
259
  const { fileID } = await tcb.uploadFile({
259
- cloudPath: `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
260
+ cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
260
261
  filePath: file,
261
262
  onUploadProgress: (progressEvent) => {
262
263
  let percent = 0;
@@ -53,16 +53,18 @@
53
53
  padding-top: 1px;
54
54
  }
55
55
 
56
- .weda-list-view__container .weda-list-view__more div.weda-list-view__more-text {
56
+ .weda-list-view__container .weda-list-view__more .weda-list-view__more-text {
57
57
  padding-top: 8px;
58
58
  padding-bottom: 8px;
59
59
  font-size: 12px;
60
60
  line-height: 18px;
61
- color: rgba(0, 0, 0, 0.26);
62
61
  text-align: center;
63
62
  box-sizing: border-box;
64
63
  cursor: pointer;
65
64
  }
65
+ .weda-list-view__container .weda-list-view__more-text {
66
+ color: rgba(0, 0, 0, 0.26);
67
+ }
66
68
 
67
69
  .weda-list-view__container .weda-list-view__more .weda-list-view__more-text.h5 {
68
70
  font-size: 14px;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useState, useEffect, useRef, useCallback, useMemo, } from 'react';
2
+ import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
3
3
  import { callDataSource } from '../../utils/tcb';
4
- import { isInIde, alertErrorMessage, usePlatform, getParseValue, textToString, } from '../../utils/platform';
4
+ import { isInIde, alertErrorMessage, usePlatform, getParseValue, textToString } from '../../utils/platform';
5
+ import { useConfig } from '../../utils/config-context';
5
6
  import classNames from '../../utils/classnames';
6
7
  import isequal from 'lodash.isequal';
7
8
  import './style';
@@ -51,22 +52,27 @@ export default React.forwardRef(function ListView(props, ref) {
51
52
  appCloud = defaultCloudbase, beforeDataChange = defaultBeforeDataChange, refType = 'listView', loadButtonText, selectFieldType = 'main', // 查询字段范围类型
52
53
  ...rest } = props;
53
54
  const platform = usePlatform();
55
+ const { classPrefix } = useConfig();
54
56
  const isH5 = platform === 'h5';
57
+ // listView 组件的 class
58
+ const classList = {
59
+ 'weda-ui': true,
60
+ [`${classPrefix}-list-view`]: true,
61
+ [`${BLOCK_NAME}__container`]: true,
62
+ // 响应式css api
63
+ [`${classPrefix}-${platform}-list-view`]: true,
64
+ };
55
65
  const isSetStatus = dataSourceType !== 'expression' ? rawIsSetStatus : false;
56
66
  const isSetLoading = dataSourceType !== 'expression' ? rawIsSetLoading : true;
57
67
  const connectorParams = getParseValue(rawConnectorParams);
58
68
  const dataSourceData = getParseValue(rawDataSourceData);
59
- const methodName = getStringValue(dataSourceType === 'data-model'
60
- ? ((_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName) || 'wedaGetRecords'
61
- : connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name);
69
+ const methodName = getStringValue(dataSourceType === 'data-model' ? ((_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName) || 'wedaGetRecords' : connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name);
62
70
  const isV2protocol = methodName === 'wedaGetRecordsV2';
63
71
  const modelParams = getModelParams({
64
72
  ...props,
65
73
  supportManyRelated: isV2protocol,
66
74
  }); // 包括 where 和 order
67
- const dataSourceName = getStringValue(dataSourceType === 'data-model'
68
- ? datasource === null || datasource === void 0 ? void 0 : datasource.name
69
- : (_b = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _b === void 0 ? void 0 : _b.name);
75
+ const dataSourceName = getStringValue(dataSourceType === 'data-model' ? datasource === null || datasource === void 0 ? void 0 : datasource.name : (_b = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _b === void 0 ? void 0 : _b.name);
70
76
  useLoopRenderDetect({ limit: 600 });
71
77
  const [entry, setEntry] = useState(null); // 触底的observer对象
72
78
  const [_status, setStatus] = useState(''); // 查询状态
@@ -95,9 +101,7 @@ export default React.forwardRef(function ListView(props, ref) {
95
101
  initExpr: false,
96
102
  }); // 请求防抖、异步时使用最后一次请求
97
103
  const isIdeMockData = !(dataSourceName && methodName) && ((_c = appCloud === null || appCloud === void 0 ? void 0 : appCloud.isInIde) === null || _c === void 0 ? void 0 : _c.call(appCloud)); // 在ide环境且未绑定数据源时,存在mock数据逻辑
98
- const shouldBottomLoad = pagination === 'bottomLoad' &&
99
- (entry === null || entry === void 0 ? void 0 : entry.isIntersecting) &&
100
- ['', 'success'].includes(status); // 能否触底加载
104
+ const shouldBottomLoad = pagination === 'bottomLoad' && (entry === null || entry === void 0 ? void 0 : entry.isIntersecting) && ['', 'success'].includes(status); // 能否触底加载
101
105
  // 返回的错误信息
102
106
  const [err, setErr] = useState({
103
107
  code: '',
@@ -267,9 +271,7 @@ export default React.forwardRef(function ListView(props, ref) {
267
271
  clearTimeout(delayRef.current.statusTimer);
268
272
  delayRef.current.statusTimer = null;
269
273
  }
270
- delayRef.current.statusTimer = window.setTimeout(statusCb, pagination === 'bottomLoad' && dataSourceType === 'expression'
271
- ? 3000
272
- : 150);
274
+ delayRef.current.statusTimer = window.setTimeout(statusCb, pagination === 'bottomLoad' && dataSourceType === 'expression' ? 3000 : 150);
273
275
  }
274
276
  else {
275
277
  statusCb();
@@ -298,11 +300,7 @@ export default React.forwardRef(function ListView(props, ref) {
298
300
  var _a, _b, _c;
299
301
  setStatus('fail');
300
302
  const obj = {
301
- code: (e === null || e === void 0 ? void 0 : e.code)
302
- ? e === null || e === void 0 ? void 0 : e.code
303
- : refType === 'dataView'
304
- ? 'WdDataView.QueryError'
305
- : 'WdListView.QueryError',
303
+ code: (e === null || e === void 0 ? void 0 : e.code) ? e === null || e === void 0 ? void 0 : e.code : refType === 'dataView' ? 'WdDataView.QueryError' : 'WdListView.QueryError',
306
304
  message: `${e === null || e === void 0 ? void 0 : e.message}`,
307
305
  requestId: (_b = (_a = e === null || e === void 0 ? void 0 : e.original) === null || _a === void 0 ? void 0 : _a.original) === null || _b === void 0 ? void 0 : _b.requestId,
308
306
  };
@@ -426,11 +424,7 @@ export default React.forwardRef(function ListView(props, ref) {
426
424
  catch (e) {
427
425
  onFailCb(e);
428
426
  throw new WdCompError(`${e === null || e === void 0 ? void 0 : e.message}` || '', {
429
- code: (e === null || e === void 0 ? void 0 : e.code)
430
- ? e === null || e === void 0 ? void 0 : e.code
431
- : refType === 'dataView'
432
- ? 'WdDataView.QueryError'
433
- : 'WdListView.QueryError',
427
+ code: (e === null || e === void 0 ? void 0 : e.code) ? e === null || e === void 0 ? void 0 : e.code : refType === 'dataView' ? 'WdDataView.QueryError' : 'WdListView.QueryError',
434
428
  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,
435
429
  original: e === null || e === void 0 ? void 0 : e.original,
436
430
  });
@@ -584,21 +578,12 @@ export default React.forwardRef(function ListView(props, ref) {
584
578
  },
585
579
  error: err,
586
580
  };
587
- }, [
588
- total,
589
- pageNo,
590
- statePageSize,
591
- methodDeleteOne,
592
- methodRefresh,
593
- dataRef.current.records,
594
- err,
595
- isV2protocol,
596
- ], ref);
581
+ }, [total, pageNo, statePageSize, methodDeleteOne, methodRefresh, dataRef.current.records, err, isV2protocol], ref);
597
582
  /**
598
583
  * 分页,加载更多
599
584
  */
600
585
  const renderLoadMore = () => {
601
- const MoreButton = (_jsx("div", { className: `${BLOCK_NAME}__more-text ${isH5 ? 'h5' : ''}`, onClick: () => {
586
+ const MoreButton = (_jsx("div", { className: `${BLOCK_NAME}__more-text ${classPrefix}-list-view__more-text ${isH5 ? 'h5' : ''}`, onClick: () => {
602
587
  var _a, _b;
603
588
  return fetchData({
604
589
  params: { pageNo: ((_b = (_a = paramRef.current) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.pageNo) + 1 },
@@ -614,9 +599,7 @@ export default React.forwardRef(function ListView(props, ref) {
614
599
  * 分页,底部刷新
615
600
  */
616
601
  const renderBottomLoad = () => {
617
- return (_jsx("div", { ref: nodeRefCallback, className: `${BLOCK_NAME}__bottom-load`, children: status === 'loading' && isSetLoading
618
- ? LoadingSymbol
619
- : !hasNextPage() && LoadEnd }));
602
+ return (_jsx("div", { ref: nodeRefCallback, className: `${BLOCK_NAME}__bottom-load`, children: status === 'loading' && isSetLoading ? LoadingSymbol : !hasNextPage() && LoadEnd }));
620
603
  };
621
604
  /**
622
605
  * 分页,分页器,含ideMockData的判断
@@ -635,7 +618,7 @@ export default React.forwardRef(function ListView(props, ref) {
635
618
  const renderStatus = () => {
636
619
  switch (status) {
637
620
  case 'empty':
638
- return (emptyText && (_jsx(EmptyContent, { emptyText: emptyText, component: "listview" })));
621
+ return emptyText && _jsx(EmptyContent, { emptyText: emptyText, component: "listview" });
639
622
  case 'fail':
640
623
  return (isSetStatus && (_jsx(EmptyContent, { emptyText: '数据加载失败', errorObj: err, icon: 'error', isH5: isH5, component: "listview", hasRecord: dataRef.current.records.length > 0 })));
641
624
  case 'loading':
@@ -650,10 +633,9 @@ export default React.forwardRef(function ListView(props, ref) {
650
633
  /**
651
634
  * 加载到底状态组件
652
635
  */
653
- const LoadEnd = status === 'success' && loadCompletedText && (_jsx("div", { className: `${BLOCK_NAME}__load-completed`, children: String(loadCompletedText) }));
654
- return (_jsxs("div", { ...rest, className: classNames('weda-ui', `${BLOCK_NAME}__container`, className), children: [children && (_jsxs("div", { className: classNames(`${BLOCK_NAME}__content`, {
636
+ const LoadEnd = status === 'success' && loadCompletedText && (_jsx("div", { className: `${BLOCK_NAME}__load-completed ${classPrefix}-list-view__load-completed`, children: String(loadCompletedText) }));
637
+ return (_jsxs("div", { ...rest, className: classNames(classList, className), children: [children && (_jsxs("div", { className: classNames(`${BLOCK_NAME}__content`, {
655
638
  [`${BLOCK_NAME}-card`]: template === 'cardList',
656
- [`${BLOCK_NAME}__content-blank`]: (status === 'empty' && emptyText) ||
657
- (status === 'fail' && isSetStatus),
639
+ [`${BLOCK_NAME}__content-blank`]: (status === 'empty' && emptyText) || (status === 'fail' && isSetStatus),
658
640
  }), children: [status === 'fail' && refType === 'dataView' ? (_jsx(EmptyContent, { emptyText: '数据加载失败', errorObj: err, icon: 'error', isH5: isH5 })) : (children), renderStatus()] })), _jsxs("div", { className: classNames(`${BLOCK_NAME}__more`, `${BLOCK_NAME}__more-${pagination}`), children: [pagination === 'bottomLoad' && renderBottomLoad(), pagination === 'loadMoreButton' && renderLoadMore(), pagination === 'pagination' && renderPagination()] })] }));
659
641
  });
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import classNames from '../../utils/classnames';
4
- import { getTempFileURL } from '../../utils/tcb';
4
+ import { getTempFileURL, getDefaultUploadPath } from '../../utils/tcb';
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
  import { LOAD_ERR_IMG_BASE64, RICH_TEXT_ICON_PACK, getWhitelist } from '../../utils/constant';
7
7
  import { renderDecorator } from '../form/renderDecorator';
@@ -112,7 +112,8 @@ initialContent, placeholder, iconPack, maxSize, cloudPath, visible, }) {
112
112
  const tcb = await ((_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.cloud) === null || _b === void 0 ? void 0 : _b.getCloudInstance());
113
113
  try {
114
114
  const fileType = (_e = (_d = (_c = file === null || file === void 0 ? void 0 : file.name) === null || _c === void 0 ? void 0 : _c.split('.')) === null || _d === void 0 ? void 0 : _d.pop()) === null || _e === void 0 ? void 0 : _e.toLowerCase();
115
- const path = `${cloudPath}/uploader-${uuidv4()}.${fileType}`;
115
+ const _uploadPath = getDefaultUploadPath(cloudPath);
116
+ const path = `${_uploadPath}/uploader-${uuidv4()}.${fileType}`;
116
117
  const { fileID } = await tcb.uploadFile({
117
118
  cloudPath: path,
118
119
  filePath: file,
@@ -20,7 +20,7 @@ export default function StatusContent(props) {
20
20
  isH5: isH5,
21
21
  'wd-status-content__content-white': hasRecord,
22
22
  'wd-status-content__content-grey': !hasRecord,
23
- })}`, children: [hasRecord ? (_jsx(_Fragment, {})) : (_jsx("span", { className: `wd-status-content__status-icon ${icon}` })), _jsx("p", { className: `wd-status-content__text-fail ${isH5 && 'isH5'}`, children: emptyText }), (errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) ? (_jsxs("p", { className: `wd-status-content__code-fail ${isH5 && 'isH5'}`, children: ["\u9519\u8BEF\u7801: ", errorObj.code] })) : null, (errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) ? (_jsxs("p", { className: `wd-status-content__detail-fail`, onClick: () => setVisible(true), children: [_jsx("span", { className: `wd-status-content__desc-fail ${isH5 && 'isH5'}`, children: "\u67E5\u770B\u8BE6\u7EC6\u5F02\u5E38\u4FE1\u606F" }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "6", height: "10", viewBox: "0 0 6 10", fill: "none", children: _jsx("path", { d: "M1.45964 9.45972L0.540405 8.54048L4.08079 5.0001L0.540405 1.45972L1.45964 0.540478L5.91926 5.0001L1.45964 9.45972Z", fill: "black", fillOpacity: "0.9" }) })] })) : null] }) }), isH5 && visible ? (_jsx(Portal, { type: "div", disableOutsidePointerEvents: true, disableOutsideScroll: true, children: _jsxs("div", { className: "wd-status-content__picker", children: [_jsx("div", { className: "wd-status-content__backdrop", onClick: () => {
23
+ })}`, children: [hasRecord ? _jsx(_Fragment, {}) : _jsx("span", { className: `wd-status-content__status-icon ${icon}` }), _jsx("p", { className: `wd-status-content__text-fail wd-status-content__text ${isH5 && 'isH5'}`, children: emptyText }), (errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) ? (_jsxs("p", { className: `wd-status-content__code-fail ${isH5 && 'isH5'}`, children: ["\u9519\u8BEF\u7801: ", errorObj.code] })) : null, (errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) ? (_jsxs("p", { className: `wd-status-content__detail-fail`, onClick: () => setVisible(true), children: [_jsx("span", { className: `wd-status-content__desc-fail ${isH5 && 'isH5'}`, children: "\u67E5\u770B\u8BE6\u7EC6\u5F02\u5E38\u4FE1\u606F" }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "6", height: "10", viewBox: "0 0 6 10", fill: "none", children: _jsx("path", { d: "M1.45964 9.45972L0.540405 8.54048L4.08079 5.0001L0.540405 1.45972L1.45964 0.540478L5.91926 5.0001L1.45964 9.45972Z", fill: "black", fillOpacity: "0.9" }) })] })) : null] }) }), isH5 && visible ? (_jsx(Portal, { type: "div", disableOutsidePointerEvents: true, disableOutsideScroll: true, children: _jsxs("div", { className: "wd-status-content__picker", children: [_jsx("div", { className: "wd-status-content__backdrop", onClick: () => {
24
24
  setVisible(false);
25
25
  } }), _jsxs("div", { className: "wd-status-content__picker-inner", children: [_jsxs("p", { className: "wd-status-content__picker-title", children: ["\u8BE6\u7EC6\u5F02\u5E38\u4FE1\u606F", _jsx("span", { onClick: () => {
26
26
  setVisible(false);
@@ -1,9 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /* eslint max-lines: [error, 500] */
3
- import { forwardRef, useImperativeHandle, useEffect, useMemo, useRef, useState, useCallback, } from 'react';
3
+ import { forwardRef, useImperativeHandle, useEffect, useMemo, useRef, useState, useCallback } from 'react';
4
4
  import { WdFormItem, WdInputGroup } from '../wd-form-item';
5
5
  import { useFormInputTrait } from '../form-input-hooks';
6
- import { WdIcon } from '../wd-icon';
6
+ import WdIcon from '../wd-icon';
7
7
  import { filterPropsWithOn, getUuid } from '../../utils/tool';
8
8
  import { KEY_DOWN_CODE } from '../../utils/constant';
9
9
  import classNames from '../../utils/classnames';
@@ -63,6 +63,7 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
63
63
  const countCls = `${classPrefix}-input__limit-number`;
64
64
  const platform = usePlatform();
65
65
  const isH5 = platform === 'h5';
66
+ const [currentInputType, setCurrentInputType] = useState(inputType);
66
67
  useEffect(() => {
67
68
  if (isEqual(valueRef.current, value))
68
69
  return; // 监听非输入引起的value变化,比如调用 setValue, clearValue
@@ -135,18 +136,7 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
135
136
  readOnly,
136
137
  before,
137
138
  after,
138
- }), [
139
- innerHandle,
140
- name,
141
- value,
142
- label,
143
- required,
144
- visible,
145
- disabled,
146
- readOnly,
147
- before,
148
- after,
149
- ]);
139
+ }), [innerHandle, name, value, label, required, visible, disabled, readOnly, before, after]);
150
140
  const formItemProps = {
151
141
  ...props,
152
142
  validateErrorMsg,
@@ -158,6 +148,9 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
158
148
  inputId,
159
149
  layout: props.layout,
160
150
  readBeforeAfter: !isUnionValue,
151
+ className: classNames(props.className, {
152
+ 'password-input': password,
153
+ }),
161
154
  };
162
155
  const inputAdornmentClick = (type) => {
163
156
  var _a;
@@ -170,11 +163,14 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
170
163
  size,
171
164
  onClick: inputAdornmentClick,
172
165
  };
166
+ const passwordIconRender = () => (_jsx("div", { className: `${classPrefix}-input-password-icon ${classPrefix}-${platform}-input-password-icon`, children: _jsx(WdIcon, { events: {
167
+ tap: () => {
168
+ setCurrentInputType(currentInputType === 'password' ? 'text' : 'password');
169
+ },
170
+ }, size: 'xs', name: currentInputType === 'password' ? 'td:browse-off' : 'td:browse', type: 'inner' }) }));
173
171
  if (!visible)
174
172
  return null;
175
- return (_jsx(WdFormItem, { ...formItemProps, children: _jsx(WdInputGroup, { ...inputGroupProps, children: _jsxs("div", { className: `${cls} ${template === 'greySearchBox'
176
- ? 'wd-input-input-search template search-box color-grey is-pc-bordered'
177
- : ''} ${template === 'whiteSearchBox'
178
- ? 'wd-input-input-search template search-box color-white is-pc-bordered'
179
- : ''} ${isH5 ? 'is-h5-borderless' : ''}`, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, onClick: () => inputAdornmentClick('prefix'), children: _jsx(WdIcon, { size: iconSize, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx("div", { className: contentCls, children: _jsx("input", { id: inputId, className: inputCls, type: inputType, placeholder: placeholder, value: currentInputValue !== null && currentInputValue !== void 0 ? currentInputValue : '', disabled: disabled, name: name, autoFocus: focus, autoComplete: "off", maxLength: maxLength, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onCompositionStart: handleZhStart, onCompositionEnd: handleZhEnd, ...startWithOnProps }) }), hasClearIcon && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { size: iconSize, className: `${classPrefix}-icon__trigger`, name: "td:close-circle-filled", onMouseDown: onClear }) })), !hasClearIcon && suffixType && (_jsx("div", { className: suffixCls, onClick: () => inputAdornmentClick('suffix'), children: _jsx(WdIcon, { size: iconSize, name: suffixIcon, type: suffixType, src: suffixSrc, className: suffixIconCls }) })), counterVisible && (_jsxs("span", { className: countCls, children: [counter, "/", maxLength] }))] }) }) }));
173
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsxs("div", { className: `${cls} ${template === 'greySearchBox' ? 'wd-input-input-search template search-box color-grey is-pc-bordered' : ''} ${template === 'whiteSearchBox'
174
+ ? 'wd-input-input-search template search-box color-white is-pc-bordered'
175
+ : ''} ${isH5 ? 'is-h5-borderless' : ''}`, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, onClick: () => inputAdornmentClick('prefix'), children: _jsx(WdIcon, { size: iconSize, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx("div", { className: contentCls, children: _jsx("input", { id: inputId, className: inputCls, type: currentInputType, placeholder: placeholder, value: currentInputValue !== null && currentInputValue !== void 0 ? currentInputValue : '', disabled: disabled, name: name, autoFocus: focus, autoComplete: "off", maxLength: maxLength, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onCompositionStart: handleZhStart, onCompositionEnd: handleZhEnd, ...startWithOnProps }) }), hasClearIcon && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { size: iconSize, className: `${classPrefix}-icon__trigger`, name: "td:close-circle-filled", onMouseDown: onClear }) })), !hasClearIcon && suffixType && (_jsx("div", { className: suffixCls, onClick: () => inputAdornmentClick('suffix'), children: _jsx(WdIcon, { size: iconSize, name: suffixIcon, type: suffixType, src: suffixSrc, className: suffixIconCls }) })), counterVisible && (_jsxs("span", { className: countCls, children: [counter, "/", maxLength] }))] }) }), password && passwordIconRender()] }) }));
180
176
  });
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { DataType } from '../../../../configs/components/wd-select';
3
+ interface SelectContextValue {
4
+ options: DataType['range'];
5
+ setOptions?(options: DataType['range']): void;
6
+ value?: DataType['value'];
7
+ }
8
+ interface ISelectProvider {
9
+ children?: React.ReactNode;
10
+ options: DataType['range'];
11
+ setOptions: (options: DataType['range']) => void;
12
+ }
13
+ export declare function SelectProvider({ children, options, setOptions }: ISelectProvider): JSX.Element;
14
+ export declare function useSelectContext(): SelectContextValue | null;
15
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useContext } from 'react';
3
+ import { createContext } from '../../../utils/global-context';
4
+ const SelectContext = createContext({
5
+ options: [],
6
+ setOptions: () => { },
7
+ }, 'SelectContext');
8
+ export function SelectProvider({ children, options, setOptions }) {
9
+ return (_jsx(SelectContext.Provider, { value: useMemo(() => ({ options, setOptions }), [options, setOptions]), children: children }));
10
+ }
11
+ export function useSelectContext() {
12
+ return useContext(SelectContext);
13
+ }
@@ -0,0 +1,19 @@
1
+ export declare const mapResult: (records: any, primaryColumn: any) => any;
2
+ export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue, }: {
3
+ dataSourceAPI: any;
4
+ queryParams: any;
5
+ childDbName: any;
6
+ primaryColumn: any;
7
+ value: any;
8
+ isInsertSelectedValue?: boolean;
9
+ }) => {
10
+ result: {
11
+ disabled?: boolean;
12
+ label: string;
13
+ value: string;
14
+ }[];
15
+ total: number;
16
+ isValidating: boolean;
17
+ empty: () => void;
18
+ getRelationOptions: () => Promise<void>;
19
+ };
@@ -0,0 +1,94 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { useSelectContext } from '../contexts/selectContext';
3
+ const defaultPage = 1;
4
+ const getUniqueOption = (option) => {
5
+ var _a;
6
+ const optionMap = option.reduce((acc, item) => {
7
+ if (!acc[item.value]) {
8
+ acc[item.value] = item;
9
+ }
10
+ return acc;
11
+ }, {});
12
+ const uniqueOption = (_a = Object.values(optionMap)) === null || _a === void 0 ? void 0 : _a.filter((item) => item === null || item === void 0 ? void 0 : item.value);
13
+ return uniqueOption;
14
+ };
15
+ export const mapResult = (records, primaryColumn) => {
16
+ var _a;
17
+ return (_a = records === null || records === void 0 ? void 0 : records.filter((i) => i._id)) === null || _a === void 0 ? void 0 : _a.map((childItem) => ({
18
+ _id: childItem._id,
19
+ value: childItem._id,
20
+ text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
21
+ label: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
22
+ extra: childItem,
23
+ }));
24
+ };
25
+ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
26
+ const [total, setTotal] = useState(0);
27
+ const [loading, setLoading] = useState(true);
28
+ const { options, setOptions } = useSelectContext();
29
+ const unshiftVal = (transformedRecords, itemResult, originOption) => {
30
+ if (itemResult &&
31
+ transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
32
+ originOption.findIndex((item) => item._id === itemResult._id) < 0) {
33
+ return [itemResult, ...transformedRecords];
34
+ }
35
+ return transformedRecords;
36
+ };
37
+ const fetchData = useCallback(async () => {
38
+ setLoading(true);
39
+ const isMultiple = Array.isArray(value);
40
+ const promiseList = [
41
+ dataSourceAPI.getRecordListV2({ ...queryParams, pageNumber: queryParams.pageNo }, {
42
+ db: childDbName,
43
+ }),
44
+ ];
45
+ if (value && isInsertSelectedValue) {
46
+ if (isMultiple) {
47
+ value.forEach((i) => {
48
+ if (i) {
49
+ promiseList.push(dataSourceAPI.getRecord(i, {
50
+ db: childDbName,
51
+ }));
52
+ }
53
+ });
54
+ }
55
+ else {
56
+ promiseList.push(dataSourceAPI.getRecord(value, {
57
+ db: childDbName,
58
+ }));
59
+ }
60
+ }
61
+ const [result, ...rest] = await Promise.all(promiseList);
62
+ let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
63
+ const itemResult = [...rest];
64
+ // 若下拉列表中无选中值,则将选中值插到数组头部
65
+ if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
66
+ itemResult.forEach((i) => {
67
+ transformedRecords = unshiftVal(transformedRecords, i, options);
68
+ });
69
+ }
70
+ let optionRes = mapResult(transformedRecords, primaryColumn);
71
+ if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
72
+ optionRes = [...options, ...optionRes];
73
+ }
74
+ optionRes = getUniqueOption(optionRes);
75
+ setOptions(optionRes);
76
+ setTotal(result === null || result === void 0 ? void 0 : result.total);
77
+ setLoading(false);
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ }, [childDbName, primaryColumn, queryParams, value]);
80
+ useEffect(() => {
81
+ if (childDbName) {
82
+ fetchData();
83
+ }
84
+ }, [childDbName, fetchData]);
85
+ return {
86
+ result: options || [],
87
+ total: total,
88
+ isValidating: loading,
89
+ empty: () => {
90
+ setOptions([]);
91
+ },
92
+ getRelationOptions: fetchData,
93
+ };
94
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function EnumSelect(props: any): JSX.Element;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import { useState, useImperativeHandle, useEffect, useCallback } from 'react';
4
+ import { LoadingTip } from 'tea-component';
5
+ import { SelectUI as Select } from '../select/selectUI';
6
+ import { requestEnumOption } from '../../form/select/request';
7
+ import { useSelectContext } from '../contexts/selectContext';
8
+ export function EnumSelect(props) {
9
+ const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
10
+ const { options, setOptions } = useSelectContext();
11
+ const [isLoading, setLoading] = useState(false);
12
+ // 获取枚举字段类型的下拉选项
13
+ const getEnumOption = useCallback(async () => {
14
+ const params = {
15
+ format,
16
+ dataSourceName,
17
+ viewId,
18
+ where,
19
+ primaryField,
20
+ enumName,
21
+ };
22
+ setLoading(true);
23
+ const enumOptions = await requestEnumOption(params);
24
+ setOptions(enumOptions);
25
+ setLoading(false);
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, [dataSourceName, enumName, format, primaryField, viewId, where]);
28
+ useEffect(() => {
29
+ getEnumOption();
30
+ }, [getEnumOption]);
31
+ useImperativeHandle(childRef, () => {
32
+ return {
33
+ refresh: async () => {
34
+ setRefreshStatus(true);
35
+ await getEnumOption();
36
+ // eslint-disable-next-line rulesdir/no-timer
37
+ const timer = setTimeout(() => {
38
+ setRefreshStatus(false);
39
+ clearTimeout(timer);
40
+ }, 500);
41
+ },
42
+ };
43
+ }, [getEnumOption, setRefreshStatus]);
44
+ const searchHandle = (keyword) => {
45
+ onSearch(keyword);
46
+ };
47
+ return (_jsx(Select, { ...props, mode: mode, searchable: true, matchButtonWidth: true, placeholder: placeholder, appearance: 'button', size: size, disabled: disabled, autoClearSearchValue: true, options: options, value: value, onChange: onChange, onSearch: searchHandle, footer: addRelationButton, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined }));
48
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function CustomSelect(props: any): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { LoadingTip } from 'tea-component';
4
+ import { EnumSelect } from './enumSelect';
5
+ import { RelationSelect } from './relationSelect';
6
+ import { WdIcon } from '../../wd-icon';
7
+ export function CustomSelect(props) {
8
+ const { format, addRelationButtonText, enableAddRelationButton, events } = props;
9
+ const isEnumType = format === 'x-enum';
10
+ const [refreshStatus, setRefreshStatus] = useState(false);
11
+ const addRelationButton = enableAddRelationButton && (_jsxs("span", { className: "wd-add-relation-button-wrap", onClick: () => {
12
+ var _a;
13
+ (_a = events === null || events === void 0 ? void 0 : events.onAddRelationButtonClick) === null || _a === void 0 ? void 0 : _a.call(events);
14
+ }, children: [_jsx(WdIcon, { size: 'xs', name: 'td:add-circle' }), addRelationButtonText] }));
15
+ if (refreshStatus) {
16
+ return _jsx(LoadingTip, {});
17
+ }
18
+ return isEnumType ? (_jsx(EnumSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus })) : (_jsx(RelationSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus }));
19
+ }
@@ -0,0 +1,15 @@
1
+ interface IqueryParams {
2
+ filter?: {
3
+ where?: object;
4
+ };
5
+ select?: {
6
+ [name: string]: boolean;
7
+ };
8
+ orderBy?: {
9
+ [name: string]: 'asc' | 'desc';
10
+ }[];
11
+ getCount?: boolean;
12
+ compatibleWithV1?: boolean;
13
+ }
14
+ export declare const getDefaultQuery: (props: any) => IqueryParams;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ import { getFilter, getSelectFields, transformSorter } from '../../../utils/getModelParams';
2
+ import { getWhereList } from '../../../utils/platform';
3
+ export const getDefaultQuery = (props) => {
4
+ const params = {};
5
+ // 兼容旧的筛选条件
6
+ const queryCondition = props.supportManyRelated ? props.queryCondition : getWhereList(props.where);
7
+ // 支持多关联查询,需要将查询条件转换为filter
8
+ params.filter = getFilter(queryCondition);
9
+ params.select = getSelectFields(props);
10
+ // 处理排序字段
11
+ params.orderBy = transformSorter(props.sorter);
12
+ params.getCount = true;
13
+ params.compatibleWithV1 = true;
14
+ return params;
15
+ };
@@ -1,4 +1,2 @@
1
1
  /// <reference types="react" />
2
2
  export declare function RelationSelect(props: any): JSX.Element;
3
- export declare function EnumSelect(props: any): JSX.Element;
4
- export declare function CustomSelect(props: any): JSX.Element;