@tachybase/client 1.6.10 → 1.6.11
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.
- package/es/block-provider/hooks/index.mjs +11 -3
- package/es/filter-provider/utils.d.ts +4 -0
- package/es/filter-provider/utils.mjs +27 -14
- package/es/schema-component/antd/filter/useFilterActionProps.mjs +7 -0
- package/lib/block-provider/hooks/index.js +10 -2
- package/lib/filter-provider/utils.js +29 -13
- package/lib/schema-component/antd/filter/useFilterActionProps.js +7 -0
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ import { useAPIClient, useRequest } from "../../api-client/index.mjs";
|
|
|
14
14
|
import { PathHandler } from "../../built-in/dynamic-page/utils.mjs";
|
|
15
15
|
import { useCollectionManager_deprecated, useCollection_deprecated } from "../../collection-manager/index.mjs";
|
|
16
16
|
import { useFilterBlock } from "../../filter-provider/FilterProvider.mjs";
|
|
17
|
-
import { mergeFilter as utils_mjs_mergeFilter, transformToFilter } from "../../filter-provider/utils.mjs";
|
|
17
|
+
import { FILTER_OPERATORS_WITH_ARRAY_VALUES, mergeFilter as utils_mjs_mergeFilter, transformToFilter } from "../../filter-provider/utils.mjs";
|
|
18
18
|
import { useRecord } from "../../record-provider/index.mjs";
|
|
19
19
|
import { getCustomCondition, removeNullCondition, useActionContext, useCompile, useDesignable } from "../../schema-component/index.mjs";
|
|
20
20
|
import { isSubMode } from "../../schema-component/antd/association-field/util.mjs";
|
|
@@ -43,10 +43,18 @@ function filterByCleanedFields(mergeFilter) {
|
|
|
43
43
|
const value = items[key];
|
|
44
44
|
if (void 0 === value) continue;
|
|
45
45
|
const pathParts = key.split('.');
|
|
46
|
-
const filteredParts = pathParts.filter((p
|
|
46
|
+
const filteredParts = pathParts.filter((p, i, arr)=>{
|
|
47
|
+
if ([
|
|
47
48
|
'$and',
|
|
48
49
|
'$or'
|
|
49
|
-
].includes(p));
|
|
50
|
+
].includes(p)) return false;
|
|
51
|
+
if (/^\d+$/.test(p)) {
|
|
52
|
+
const prev = i > 0 ? arr[i - 1] : '';
|
|
53
|
+
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(prev)) return true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
50
58
|
const fieldPath = filteredParts.join('.');
|
|
51
59
|
const uniqueKey = "".concat(fieldPath);
|
|
52
60
|
if (!seen.has(uniqueKey)) {
|
|
@@ -9,6 +9,10 @@ export declare enum FilterBlockType {
|
|
|
9
9
|
COLLAPSE = 3
|
|
10
10
|
}
|
|
11
11
|
export declare const mergeFilter: (filters: any[], op?: string) => any;
|
|
12
|
+
/**
|
|
13
|
+
* 筛选值为数组的操作符;与 transformToFilter 的 flatten breakOn、filterByCleanedFields 路径去重共用,避免两处列表漂移。
|
|
14
|
+
*/
|
|
15
|
+
export declare const FILTER_OPERATORS_WITH_ARRAY_VALUES: Set<string>;
|
|
12
16
|
export declare const getSupportFieldsByAssociation: (inheritCollectionsChain: string[], block: DataBlock) => CollectionFieldOptions_deprecated[];
|
|
13
17
|
export declare const getSupportFieldsByForeignKey: (filterBlockCollection: ReturnType<typeof useCollection_deprecated>, block: DataBlock) => import("./FilterProvider").ForeignKeyField[];
|
|
14
18
|
/**
|
|
@@ -26,6 +26,17 @@ const mergeFilter = function(filters) {
|
|
|
26
26
|
[op]: items
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
+
const FILTER_OPERATORS_WITH_ARRAY_VALUES = new Set([
|
|
30
|
+
'$match',
|
|
31
|
+
'$notMatch',
|
|
32
|
+
'$anyOf',
|
|
33
|
+
'$noneOf',
|
|
34
|
+
'$childIn',
|
|
35
|
+
'$childNotIn',
|
|
36
|
+
'$dateBetween',
|
|
37
|
+
'$in',
|
|
38
|
+
'$notIn'
|
|
39
|
+
]);
|
|
29
40
|
const getSupportFieldsByAssociation = (inheritCollectionsChain, block)=>{
|
|
30
41
|
var _block_associatedFields;
|
|
31
42
|
return null == (_block_associatedFields = block.associatedFields) ? void 0 : _block_associatedFields.filter((field)=>null == inheritCollectionsChain ? void 0 : inheritCollectionsChain.some((collectionName)=>collectionName === field.target));
|
|
@@ -50,17 +61,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
50
61
|
values = flatten(values, {
|
|
51
62
|
breakOn (param) {
|
|
52
63
|
let { value, path } = param;
|
|
53
|
-
if ([
|
|
54
|
-
'$match',
|
|
55
|
-
'$notMatch',
|
|
56
|
-
'$anyOf',
|
|
57
|
-
'$noneOf',
|
|
58
|
-
'$childIn',
|
|
59
|
-
'$childNotIn',
|
|
60
|
-
'$dateBetween',
|
|
61
|
-
'$in',
|
|
62
|
-
'$notIn'
|
|
63
|
-
].includes(operators[path])) return true;
|
|
64
|
+
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operators[path])) return true;
|
|
64
65
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(path));
|
|
65
66
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
66
67
|
if (Array.isArray(value)) return true;
|
|
@@ -93,9 +94,21 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
93
94
|
};
|
|
94
95
|
} else if ('$dateBetween' === operators[key]) {
|
|
95
96
|
if (Array.isArray(value)) {
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const normalized = [];
|
|
98
|
+
for(const index in value){
|
|
99
|
+
if (!value[index]) continue;
|
|
100
|
+
let v = value[index];
|
|
101
|
+
if ('string' != typeof v && !(v instanceof Date)) v = dayjs(v).toISOString();
|
|
102
|
+
normalized.push(v);
|
|
98
103
|
}
|
|
104
|
+
if (0 === normalized.length) return null;
|
|
105
|
+
value = 1 === normalized.length ? [
|
|
106
|
+
normalized[0],
|
|
107
|
+
normalized[0]
|
|
108
|
+
] : [
|
|
109
|
+
normalized[0],
|
|
110
|
+
normalized[normalized.length - 1]
|
|
111
|
+
];
|
|
99
112
|
}
|
|
100
113
|
}
|
|
101
114
|
return {
|
|
@@ -184,4 +197,4 @@ const isInFilterFormBlock = (fieldSchema)=>{
|
|
|
184
197
|
}
|
|
185
198
|
return false;
|
|
186
199
|
};
|
|
187
|
-
export { utils_FilterBlockType as FilterBlockType, getSupportFieldsByAssociation, getSupportFieldsByForeignKey, isAssocField, isInFilterFormBlock, isSameCollection, mergeFilter, transformToFilter, useAssociatedFields, useFilterAPI, useSupportedBlocks };
|
|
200
|
+
export { FILTER_OPERATORS_WITH_ARRAY_VALUES, utils_FilterBlockType as FilterBlockType, getSupportFieldsByAssociation, getSupportFieldsByForeignKey, isAssocField, isInFilterFormBlock, isSameCollection, mergeFilter, transformToFilter, useAssociatedFields, useFilterAPI, useSupportedBlocks };
|
|
@@ -141,6 +141,13 @@ const removeNullCondition = function(filter) {
|
|
|
141
141
|
const value = items[key];
|
|
142
142
|
if (null != value && !isEmpty(value)) values[key] = value;
|
|
143
143
|
}
|
|
144
|
+
for (const key of Object.keys(values))if (key.endsWith('$dateBetween.0')) {
|
|
145
|
+
const key1 = key.replace(/\$dateBetween\.0$/, '$dateBetween.1');
|
|
146
|
+
if (!(key1 in values)) values[key1] = values[key];
|
|
147
|
+
} else if (key.endsWith('$dateBetween.1')) {
|
|
148
|
+
const key0 = key.replace(/\$dateBetween\.1$/, '$dateBetween.0');
|
|
149
|
+
if (!(key0 in values)) values[key0] = values[key];
|
|
150
|
+
}
|
|
144
151
|
return customFlat.unflatten(values);
|
|
145
152
|
};
|
|
146
153
|
const useFilterActionProps = ()=>{
|
|
@@ -356,10 +356,18 @@ var __webpack_exports__ = {};
|
|
|
356
356
|
const value = items[key];
|
|
357
357
|
if (void 0 === value) continue;
|
|
358
358
|
const pathParts = key.split('.');
|
|
359
|
-
const filteredParts = pathParts.filter((p
|
|
359
|
+
const filteredParts = pathParts.filter((p, i, arr)=>{
|
|
360
|
+
if ([
|
|
360
361
|
'$and',
|
|
361
362
|
'$or'
|
|
362
|
-
].includes(p));
|
|
363
|
+
].includes(p)) return false;
|
|
364
|
+
if (/^\d+$/.test(p)) {
|
|
365
|
+
const prev = i > 0 ? arr[i - 1] : '';
|
|
366
|
+
if (_filter_provider_utils__WEBPACK_IMPORTED_MODULE_16__.FILTER_OPERATORS_WITH_ARRAY_VALUES.has(prev)) return true;
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
return true;
|
|
370
|
+
});
|
|
363
371
|
const fieldPath = filteredParts.join('.');
|
|
364
372
|
const uniqueKey = "".concat(fieldPath);
|
|
365
373
|
if (!seen.has(uniqueKey)) {
|
|
@@ -34,6 +34,7 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
mergeFilter: ()=>mergeFilter,
|
|
37
|
+
FILTER_OPERATORS_WITH_ARRAY_VALUES: ()=>FILTER_OPERATORS_WITH_ARRAY_VALUES,
|
|
37
38
|
transformToFilter: ()=>transformToFilter,
|
|
38
39
|
isSameCollection: ()=>isSameCollection,
|
|
39
40
|
getSupportFieldsByForeignKey: ()=>getSupportFieldsByForeignKey,
|
|
@@ -75,6 +76,17 @@ const mergeFilter = function(filters) {
|
|
|
75
76
|
[op]: items
|
|
76
77
|
};
|
|
77
78
|
};
|
|
79
|
+
const FILTER_OPERATORS_WITH_ARRAY_VALUES = new Set([
|
|
80
|
+
'$match',
|
|
81
|
+
'$notMatch',
|
|
82
|
+
'$anyOf',
|
|
83
|
+
'$noneOf',
|
|
84
|
+
'$childIn',
|
|
85
|
+
'$childNotIn',
|
|
86
|
+
'$dateBetween',
|
|
87
|
+
'$in',
|
|
88
|
+
'$notIn'
|
|
89
|
+
]);
|
|
78
90
|
const getSupportFieldsByAssociation = (inheritCollectionsChain, block)=>{
|
|
79
91
|
var _block_associatedFields;
|
|
80
92
|
return null == (_block_associatedFields = block.associatedFields) ? void 0 : _block_associatedFields.filter((field)=>null == inheritCollectionsChain ? void 0 : inheritCollectionsChain.some((collectionName)=>collectionName === field.target));
|
|
@@ -99,17 +111,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
99
111
|
values = (0, client_namespaceObject.flatten)(values, {
|
|
100
112
|
breakOn (param) {
|
|
101
113
|
let { value, path } = param;
|
|
102
|
-
if ([
|
|
103
|
-
'$match',
|
|
104
|
-
'$notMatch',
|
|
105
|
-
'$anyOf',
|
|
106
|
-
'$noneOf',
|
|
107
|
-
'$childIn',
|
|
108
|
-
'$childNotIn',
|
|
109
|
-
'$dateBetween',
|
|
110
|
-
'$in',
|
|
111
|
-
'$notIn'
|
|
112
|
-
].includes(operators[path])) return true;
|
|
114
|
+
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operators[path])) return true;
|
|
113
115
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(path));
|
|
114
116
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
115
117
|
if (Array.isArray(value)) return true;
|
|
@@ -142,9 +144,21 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
142
144
|
};
|
|
143
145
|
} else if ('$dateBetween' === operators[key]) {
|
|
144
146
|
if (Array.isArray(value)) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
const normalized = [];
|
|
148
|
+
for(const index in value){
|
|
149
|
+
if (!value[index]) continue;
|
|
150
|
+
let v = value[index];
|
|
151
|
+
if ('string' != typeof v && !(v instanceof Date)) v = external_dayjs_default()(v).toISOString();
|
|
152
|
+
normalized.push(v);
|
|
147
153
|
}
|
|
154
|
+
if (0 === normalized.length) return null;
|
|
155
|
+
value = 1 === normalized.length ? [
|
|
156
|
+
normalized[0],
|
|
157
|
+
normalized[0]
|
|
158
|
+
] : [
|
|
159
|
+
normalized[0],
|
|
160
|
+
normalized[normalized.length - 1]
|
|
161
|
+
];
|
|
148
162
|
}
|
|
149
163
|
}
|
|
150
164
|
return {
|
|
@@ -233,6 +247,7 @@ const isInFilterFormBlock = (fieldSchema)=>{
|
|
|
233
247
|
}
|
|
234
248
|
return false;
|
|
235
249
|
};
|
|
250
|
+
exports.FILTER_OPERATORS_WITH_ARRAY_VALUES = __webpack_exports__.FILTER_OPERATORS_WITH_ARRAY_VALUES;
|
|
236
251
|
exports.FilterBlockType = __webpack_exports__.FilterBlockType;
|
|
237
252
|
exports.getSupportFieldsByAssociation = __webpack_exports__.getSupportFieldsByAssociation;
|
|
238
253
|
exports.getSupportFieldsByForeignKey = __webpack_exports__.getSupportFieldsByForeignKey;
|
|
@@ -245,6 +260,7 @@ exports.useAssociatedFields = __webpack_exports__.useAssociatedFields;
|
|
|
245
260
|
exports.useFilterAPI = __webpack_exports__.useFilterAPI;
|
|
246
261
|
exports.useSupportedBlocks = __webpack_exports__.useSupportedBlocks;
|
|
247
262
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
263
|
+
"FILTER_OPERATORS_WITH_ARRAY_VALUES",
|
|
248
264
|
"FilterBlockType",
|
|
249
265
|
"getSupportFieldsByAssociation",
|
|
250
266
|
"getSupportFieldsByForeignKey",
|
|
@@ -187,6 +187,13 @@ const removeNullCondition = function(filter) {
|
|
|
187
187
|
const value = items[key];
|
|
188
188
|
if (null != value && !isEmpty(value)) values[key] = value;
|
|
189
189
|
}
|
|
190
|
+
for (const key of Object.keys(values))if (key.endsWith('$dateBetween.0')) {
|
|
191
|
+
const key1 = key.replace(/\$dateBetween\.0$/, '$dateBetween.1');
|
|
192
|
+
if (!(key1 in values)) values[key1] = values[key];
|
|
193
|
+
} else if (key.endsWith('$dateBetween.1')) {
|
|
194
|
+
const key0 = key.replace(/\$dateBetween\.1$/, '$dateBetween.0');
|
|
195
|
+
if (!(key0 in values)) values[key0] = values[key];
|
|
196
|
+
}
|
|
190
197
|
return customFlat.unflatten(values);
|
|
191
198
|
};
|
|
192
199
|
const useFilterActionProps = ()=>{
|