@cloudbase/weda-ui 3.10.2 → 3.11.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 (85) hide show
  1. package/dist/configs/components/button.js +1 -1
  2. package/dist/configs/components/chart/bar.d.ts +146 -0
  3. package/dist/configs/components/chart/bar.js +1147 -0
  4. package/dist/configs/components/dataView.js +0 -16
  5. package/dist/configs/components/image.js +1 -1
  6. package/dist/configs/components/listView.js +0 -16
  7. package/dist/configs/components/lottery.js +1 -1
  8. package/dist/configs/components/navigationBar.json +1 -1
  9. package/dist/configs/components/wd-audio.js +1 -1
  10. package/dist/configs/components/wd-button.js +2 -2
  11. package/dist/configs/components/wd-icon.js +1 -1
  12. package/dist/configs/components/wd-image.js +1 -1
  13. package/dist/configs/components/wd-input-email.d.ts +2 -2
  14. package/dist/configs/components/wd-input-phone.d.ts +2 -2
  15. package/dist/configs/components/wd-input-url.d.ts +2 -2
  16. package/dist/configs/components/wd-link.js +1 -1
  17. package/dist/configs/components/wd-rating.js +2 -2
  18. package/dist/configs/components/wd-select-multiple.d.ts +23 -0
  19. package/dist/configs/components/wd-select-multiple.js +26 -1
  20. package/dist/configs/components/wd-select.d.ts +23 -0
  21. package/dist/configs/components/wd-select.js +25 -0
  22. package/dist/configs/components/wd-side-tab.js +2 -2
  23. package/dist/configs/components/wd-table.d.ts +1 -1
  24. package/dist/configs/components/wd-table.js +1 -0
  25. package/dist/configs/components/wd-top-tab.js +2 -2
  26. package/dist/configs/components/wd-upload-image.js +1 -1
  27. package/dist/configs/components/wedaVideo.js +3 -3
  28. package/dist/configs/components/wxOpenApi/share.js +1 -1
  29. package/dist/configs/index.d.ts +1674 -2996
  30. package/dist/configs/index.js +1 -1
  31. package/dist/configs/type-utils/type-form.d.ts +6 -0
  32. package/dist/configs/type-utils/type-form.js +63 -22
  33. package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
  34. package/dist/configs/type-utils/x-runtime-default.js +1 -0
  35. package/dist/enum/index.js +5 -1
  36. package/dist/style/index.css +2 -0
  37. package/dist/style/index.scss +1 -1
  38. package/dist/style/weda-ui.min.css +2 -2
  39. package/dist/web/components/form/select/index.css +2 -2
  40. package/dist/web/components/form/select/request.d.ts +3 -3
  41. package/dist/web/components/form/select/request.js +1 -0
  42. package/dist/web/components/form/select/status/index.d.ts +3 -1
  43. package/dist/web/components/form/select/status/index.js +3 -1
  44. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +5 -5
  45. package/dist/web/components/form-date/index.d.ts +1 -1
  46. package/dist/web/components/form-email/index.d.ts +1 -1
  47. package/dist/web/components/form-input/index.d.ts +1 -1
  48. package/dist/web/components/form-input-hooks/index.js +10 -1
  49. package/dist/web/components/form-input-hooks/validator.d.ts +1 -0
  50. package/dist/web/components/form-input-hooks/validator.js +6 -2
  51. package/dist/web/components/form-phone/index.d.ts +1 -1
  52. package/dist/web/components/form-time/index.d.ts +1 -1
  53. package/dist/web/components/form-url/index.d.ts +1 -1
  54. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  55. package/dist/web/components/wd-date/elements/Modal.h5.js +3 -3
  56. package/dist/web/components/wd-form/index.js +1 -1
  57. package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
  58. package/dist/web/components/wd-input/wd-input.d.ts +1 -1
  59. package/dist/web/components/wd-input-email/wd-input-email.d.ts +1 -1
  60. package/dist/web/components/wd-input-phone/wd-input-phone.d.ts +1 -1
  61. package/dist/web/components/wd-input-url/wd-input-url.d.ts +1 -1
  62. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +4 -0
  63. package/dist/web/components/wd-select/relationSelect/relationSelect.js +202 -0
  64. package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js} +4 -4
  65. package/dist/web/components/wd-select/select/index.d.ts +2 -0
  66. package/dist/web/components/wd-select/select/index.js +8 -0
  67. package/dist/web/components/wd-select/select/selectUI.d.ts +3 -0
  68. package/dist/web/components/wd-select/select/selectUI.js +190 -0
  69. package/dist/web/components/wd-select/style.d.ts +2 -0
  70. package/dist/web/components/wd-select/style.js +2 -0
  71. package/dist/web/components/wd-select/wd-select.css +83 -0
  72. package/dist/web/components/wd-select/wd-select.d.ts +0 -1
  73. package/dist/web/components/wd-select/wd-select.js +18 -8
  74. package/dist/web/components/wd-select-multiple/style.d.ts +2 -0
  75. package/dist/web/components/wd-select-multiple/style.js +2 -0
  76. package/dist/web/components/wd-select-multiple/wd-select-multiple.css +30 -4
  77. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +18 -7
  78. package/dist/web/components/wd-table/components/FieldRender/index.d.ts +7 -4
  79. package/dist/web/components/wd-table/components/FieldRender/index.js +23 -7
  80. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +1 -0
  81. package/dist/web/components/wd-table/hooks/useChooseList.js +55 -26
  82. package/dist/web/utils/platform.js +3 -3
  83. package/package.json +2 -2
  84. package/dist/configs/components/chart/bar.json +0 -1144
  85. /package/dist/web/components/wd-select/{relationalSetting.d.ts → relationSelect/relationalSetting.d.ts} +0 -0
@@ -39,7 +39,7 @@ export const TextWrap = React.memo(function TextWrapComp(props) {
39
39
  export function getFieldRender(field = {}, extra = {}) {
40
40
  var _a;
41
41
  const { type, format, items, properties, title, parentDatasource } = field;
42
- const { modelType, showTip = true, detailText = '详情', isH5 } = extra;
42
+ const { modelType, showTip = true, detailText = '详情', isH5, showRelationWithTag = true, } = extra;
43
43
  const textProps = { showTip };
44
44
  // 枚举-旧,新版 TODO
45
45
  if ((_a = field['x-enumObj']) === null || _a === void 0 ? void 0 : _a.length) {
@@ -135,6 +135,12 @@ export function getFieldRender(field = {}, extra = {}) {
135
135
  (format === 'father-son' || format === 'related')) {
136
136
  const primaryField = ((_b = (_a = field === null || field === void 0 ? void 0 : field.parentDatasource) === null || _a === void 0 ? void 0 : _a.schema) === null || _b === void 0 ? void 0 : _b['x-primary-column']) || '';
137
137
  const relatedField = (_c = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _c === void 0 ? void 0 : _c.relatedField;
138
+ if (!showRelationWithTag) {
139
+ if (typeof fieldValue === 'string') {
140
+ return _jsx(TextWrap, { ...textProps, children: fieldValue });
141
+ }
142
+ return (_jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] || '-' }));
143
+ }
138
144
  if (typeof fieldValue === 'string') {
139
145
  return fieldValue && fieldValue !== '-' ? (_jsx(WdTag, { range: fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.split(',').map((i) => ({
140
146
  label: i,
@@ -194,6 +200,9 @@ export function getFieldRender(field = {}, extra = {}) {
194
200
  const primaryField = ((_e = (_d = field === null || field === void 0 ? void 0 : field.parentDatasource) === null || _d === void 0 ? void 0 : _d.schema) === null || _e === void 0 ? void 0 : _e['x-primary-column']) || '';
195
201
  const relatedField = (_f = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _f === void 0 ? void 0 : _f.relatedField;
196
202
  const _readValue = fieldValue[relatedField] || fieldValue[primaryField];
203
+ if (!showRelationWithTag) {
204
+ return (_jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] }));
205
+ }
197
206
  return _readValue ? (_jsx(WdTag, { range: _readValue === null || _readValue === void 0 ? void 0 : _readValue.split(',').map((i) => ({
198
207
  label: i,
199
208
  value: i,
@@ -314,6 +323,7 @@ export const DataTableView = ({ fields, value }) => {
314
323
  fields: rawFieldsSort,
315
324
  isH5: false,
316
325
  supportManyRelated: false,
326
+ showRelationWithTag: false,
317
327
  });
318
328
  return baseColumns;
319
329
  }, [rawFields]);
@@ -412,8 +422,8 @@ export const formatNumberFix = (val, field, setZero = false) => {
412
422
  * 根据 fields 信息生成 column
413
423
  * h5 和 pc 部分参数不同
414
424
  */
415
- export const getColumns = ({ columnSets = [], fields, isH5 = false, supportManyRelated, }) => fields === null || fields === void 0 ? void 0 : fields.map((item) => formatFieldToColumn(item, isH5, columnSets, supportManyRelated));
416
- const TableCell = ({ record, field, isH5, supportManyRelated }) => {
425
+ export const getColumns = ({ columnSets = [], fields, isH5 = false, supportManyRelated, showRelationWithTag, }) => fields === null || fields === void 0 ? void 0 : fields.map((item) => formatFieldToColumn(item, isH5, columnSets, supportManyRelated, showRelationWithTag));
426
+ const TableCell = ({ record, field, isH5, supportManyRelated, showRelationWithTag, }) => {
417
427
  const component = React.useMemo(() => {
418
428
  const { name } = field;
419
429
  const value = getFieldValue(name, record);
@@ -424,12 +434,14 @@ const TableCell = ({ record, field, isH5, supportManyRelated }) => {
424
434
  relation: record[`@${name}`],
425
435
  supportManyRelated,
426
436
  isH5,
437
+ showRelationWithTag,
427
438
  }
428
439
  : {
429
440
  modelType: 'table',
430
441
  relation: record[`@${name}`],
431
442
  supportManyRelated,
432
443
  isH5,
444
+ showRelationWithTag,
433
445
  };
434
446
  return getFieldRender(field, extra)(value);
435
447
  }, [record, field, isH5]);
@@ -440,7 +452,7 @@ const TableCell = ({ record, field, isH5, supportManyRelated }) => {
440
452
  * 根据 field 属性,生成 column 配置
441
453
  * https://git.woa.com/QBase/lcap/common-application-specs/blob/master/types/platform/datasource.ts
442
454
  */
443
- export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated) => {
455
+ export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated, showRelationWithTag) => {
444
456
  const { name, title } = field;
445
457
  // 计算列宽度,略大于计算宽度
446
458
  const width = getFieldWidth(field) + 10;
@@ -450,7 +462,7 @@ export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated)
450
462
  width: !item || (item === null || item === void 0 ? void 0 : item.widthType) === 'auto' || isIllegalWidth
451
463
  ? width
452
464
  : item === null || item === void 0 ? void 0 : item.width,
453
- render: (record) => (_jsx(TableCell, { record: record, field: field, isH5: isH5, supportManyRelated: supportManyRelated })),
465
+ render: (record) => (_jsx(TableCell, { record: record, field: field, isH5: isH5, supportManyRelated: supportManyRelated, showRelationWithTag: showRelationWithTag })),
454
466
  key: name,
455
467
  slotKey: (item === null || item === void 0 ? void 0 : item.slotKey) || name,
456
468
  header: title,
@@ -725,7 +737,7 @@ const TableSlotCell = ({ record, rowKey, recordIndex, column, columnIndex, slot,
725
737
  * slots: object 模型表格作用域插槽
726
738
  * isH5: 判断自定义插槽列能否展示,目前是正常展示
727
739
  */
728
- export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5, supportManyRelated, }) => {
740
+ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5, supportManyRelated, showRelationWithTag, }) => {
729
741
  if (!Array.isArray(columnSets) || !(columnSets === null || columnSets === void 0 ? void 0 : columnSets.length))
730
742
  return columns;
731
743
  const columnSetsReg = columnSets.map((item) => {
@@ -774,6 +786,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
774
786
  rowId: record._id,
775
787
  supportManyRelated,
776
788
  isH5,
789
+ showRelationWithTag,
777
790
  }
778
791
  : {
779
792
  modelType: 'table',
@@ -782,6 +795,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
782
795
  rowId: record._id,
783
796
  supportManyRelated,
784
797
  isH5,
798
+ showRelationWithTag,
785
799
  };
786
800
  const value = getFieldValue(key, record, relatedField, isMany(_oriField));
787
801
  const component = getFieldRender(field, extra)(value);
@@ -897,12 +911,13 @@ export const getFixedColumnSets = ({ fixedFront = '', fixedEnd = '', columnSets,
897
911
  /**
898
912
  * 列管理字段转换
899
913
  */
900
- export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, }) => {
914
+ export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, showRelationWithTag = true, }) => {
901
915
  const defaultColumns = getColumns({
902
916
  columnSets,
903
917
  fields,
904
918
  isH5: false,
905
919
  supportManyRelated,
920
+ showRelationWithTag,
906
921
  });
907
922
  let fixedColumnSets = columnSets;
908
923
  // h5端不冻结
@@ -920,6 +935,7 @@ export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEn
920
935
  fields,
921
936
  isH5,
922
937
  supportManyRelated,
938
+ showRelationWithTag,
923
939
  });
924
940
  return baseColumns.map((i) => ({
925
941
  ...i,
@@ -11,4 +11,5 @@ export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName,
11
11
  total: number;
12
12
  isValidating: boolean;
13
13
  empty: () => void;
14
+ getRelationOptions: () => Promise<void>;
14
15
  };
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState, useEffect, useCallback } from 'react';
2
2
  const defaultPage = 1;
3
3
  const getDataBase = (format, fields) => {
4
4
  const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
@@ -37,41 +37,69 @@ export const mapResult = (records, primaryColumn) => {
37
37
  return records === null || records === void 0 ? void 0 : records.map((childItem) => ({
38
38
  value: childItem._id,
39
39
  text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
40
+ label: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
41
+ extra: childItem,
40
42
  }));
41
43
  };
42
44
  export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, }) => {
43
45
  const [option, setOption] = useState([]);
44
46
  const [total, setTotal] = useState(0);
45
47
  const [loading, setLoading] = useState(true);
46
- useEffect(() => {
47
- async function fetchData() {
48
- setLoading(true);
49
- const [result, itemResult] = await Promise.all([
50
- dataSourceAPI.getRecordList(queryParams, {
51
- db: childDbName,
52
- }),
53
- value
54
- ? dataSourceAPI.getRecord(value, {
55
- db: childDbName,
56
- })
57
- : Promise.resolve(),
58
- ]);
59
- let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
60
- if (value &&
61
- transformedRecords.findIndex((item) => item._id === value) < 0) {
62
- transformedRecords = [itemResult, ...transformedRecords];
48
+ const unshiftVal = (transformedRecords, itemResult) => {
49
+ if (itemResult &&
50
+ transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
51
+ option.findIndex((item) => item._id === itemResult._id) < 0) {
52
+ return [itemResult, ...transformedRecords];
53
+ }
54
+ return transformedRecords;
55
+ };
56
+ const fetchData = useCallback(async () => {
57
+ setLoading(true);
58
+ const isMultiple = Array.isArray(value);
59
+ const promiseList = [
60
+ dataSourceAPI.getRecordList(queryParams, {
61
+ db: childDbName,
62
+ }),
63
+ ];
64
+ if (value === null || value === void 0 ? void 0 : value.length) {
65
+ if (isMultiple) {
66
+ value.forEach((i) => {
67
+ if (i) {
68
+ promiseList.push(dataSourceAPI.getRecord(i, {
69
+ db: childDbName,
70
+ }));
71
+ }
72
+ });
63
73
  }
64
- let optionRes = mapResult(transformedRecords, primaryColumn);
65
- if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
66
- optionRes = [...option, ...optionRes];
74
+ else {
75
+ promiseList.push(dataSourceAPI.getRecord(value, {
76
+ db: childDbName,
77
+ }));
67
78
  }
68
- setOption(optionRes);
69
- setTotal(result === null || result === void 0 ? void 0 : result.total);
70
- setLoading(false);
71
79
  }
72
- fetchData();
80
+ const [result, ...rest] = await Promise.all(promiseList);
81
+ let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
82
+ const itemResult = [...rest];
83
+ // 若下拉列表中无选中值,则将选中值插到数组头部
84
+ if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length)) || value) {
85
+ itemResult.forEach((i) => {
86
+ transformedRecords = unshiftVal(transformedRecords, i);
87
+ });
88
+ }
89
+ let optionRes = mapResult(transformedRecords, primaryColumn);
90
+ if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
91
+ optionRes = [...option, ...optionRes];
92
+ }
93
+ setOption(optionRes);
94
+ setTotal(result === null || result === void 0 ? void 0 : result.total);
95
+ setLoading(false);
73
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
- }, [childDbName, queryParams]);
97
+ }, [childDbName, primaryColumn, queryParams]);
98
+ useEffect(() => {
99
+ if (childDbName) {
100
+ fetchData();
101
+ }
102
+ }, [childDbName, fetchData]);
75
103
  return {
76
104
  result: option || [],
77
105
  total: total,
@@ -79,5 +107,6 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
79
107
  empty: () => {
80
108
  setOption([]);
81
109
  },
110
+ getRelationOptions: fetchData,
82
111
  };
83
112
  };
@@ -284,12 +284,12 @@ export const textToString = (text) => {
284
284
  * 统一错误提示
285
285
  */
286
286
  export function alertErrorMessage({ message, duration = 3000, icon = 'none' }) {
287
- var _a, _b, _c, _d, _e;
287
+ var _a, _b, _c, _d, _e, _f;
288
288
  const smallScreen = (_b = (_a = window === null || window === void 0 ? void 0 : window.matchMedia('(max-width: 768px)')) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : isH5Platform();
289
289
  const touchDevice = (_d = (_c = window === null || window === void 0 ? void 0 : window.matchMedia('(pointer:coarse)')) === null || _c === void 0 ? void 0 : _c.matches) !== null && _d !== void 0 ? _d : smallScreen;
290
290
  const platform = touchDevice || smallScreen ? 'h5' : 'pc';
291
- if (platform === 'h5') {
292
- (_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.showToast({
291
+ if (platform === 'h5' && ((_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.showToast)) {
292
+ (_f = window === null || window === void 0 ? void 0 : window.app) === null || _f === void 0 ? void 0 : _f.showToast({
293
293
  title: message,
294
294
  icon,
295
295
  duration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.10.2",
3
+ "version": "3.11.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -274,7 +274,7 @@
274
274
  "!.temp/dist/*.map"
275
275
  ],
276
276
  "webpack": false,
277
- "limit": "900 KB"
277
+ "limit": "950 KB"
278
278
  }
279
279
  ],
280
280
  "nyc": {