@cloudbase/weda-ui 3.13.1 → 3.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,16 @@
1
1
  import { useState, useEffect, useCallback } from 'react';
2
2
  const defaultPage = 1;
3
+ const getUniqueOption = (option) => {
4
+ var _a;
5
+ const optionMap = option.reduce((acc, item) => {
6
+ if (!acc[item.value]) {
7
+ acc[item.value] = item;
8
+ }
9
+ return acc;
10
+ }, {});
11
+ const uniqueOption = (_a = Object.values(optionMap)) === null || _a === void 0 ? void 0 : _a.filter((item) => item === null || item === void 0 ? void 0 : item.value);
12
+ return uniqueOption;
13
+ };
3
14
  const getDataBase = (format, fields) => {
4
15
  const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
5
16
  const data = filter === null || filter === void 0 ? void 0 : filter.map((item) => {
@@ -43,7 +54,7 @@ export const mapResult = (records, primaryColumn) => {
43
54
  extra: childItem,
44
55
  }));
45
56
  };
46
- export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value }) => {
57
+ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
47
58
  const [option, setOption] = useState([]);
48
59
  const [total, setTotal] = useState(0);
49
60
  const [loading, setLoading] = useState(true);
@@ -63,7 +74,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
63
74
  db: childDbName,
64
75
  }),
65
76
  ];
66
- if (value) {
77
+ if (value && isInsertSelectedValue) {
67
78
  if (isMultiple) {
68
79
  value.forEach((i) => {
69
80
  if (i) {
@@ -83,7 +94,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
83
94
  let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
84
95
  const itemResult = [...rest];
85
96
  // 若下拉列表中无选中值,则将选中值插到数组头部
86
- if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length)) || value) {
97
+ if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
87
98
  itemResult.forEach((i) => {
88
99
  transformedRecords = unshiftVal(transformedRecords, i, option);
89
100
  });
@@ -92,6 +103,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
92
103
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
93
104
  optionRes = [...option, ...optionRes];
94
105
  }
106
+ optionRes = getUniqueOption(optionRes);
95
107
  setOption(optionRes);
96
108
  setTotal(result === null || result === void 0 ? void 0 : result.total);
97
109
  setLoading(false);
@@ -8,6 +8,9 @@ export const convertMoment = (val) => {
8
8
  let m = null;
9
9
  try {
10
10
  m = moment(val);
11
+ if (Object.prototype.hasOwnProperty.call(val, '$date')) {
12
+ m = moment(val.$date);
13
+ }
11
14
  if (!(m === null || m === void 0 ? void 0 : m.isValid()))
12
15
  return null;
13
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.13.1",
3
+ "version": "3.13.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -85,7 +85,7 @@
85
85
  "description": "腾讯云微搭低代码组件库模板",
86
86
  "dependencies": {
87
87
  "@antv/g6": "^4.8.5",
88
- "@cloudbase/weda-client": "^1.1.14",
88
+ "@cloudbase/weda-client": "^1.1.15",
89
89
  "@codemirror/autocomplete": "^6.16.0",
90
90
  "@codemirror/lang-javascript": "^6.2.2",
91
91
  "@codemirror/lang-json": "^6.0.1",
@@ -147,9 +147,9 @@
147
147
  "@babel/preset-env": "^7.22.15",
148
148
  "@babel/preset-react": "^7.22.15",
149
149
  "@babel/preset-typescript": "^7.22.15",
150
- "@cloudbase/cals": "^1.2.5",
150
+ "@cloudbase/cals": "^1.2.8",
151
151
  "@cloudbase/lowcode-cli": "^0.22.0",
152
- "@cloudbase/weda-cloud-sdk": "^1.0.94",
152
+ "@cloudbase/weda-cloud-sdk": "^1.0.96",
153
153
  "@commitlint/cli": "^16.0.2",
154
154
  "@commitlint/config-conventional": "^17.7.0",
155
155
  "@craco/craco": "^7.1.0",