@tachybase/client 1.6.21 → 1.6.22
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/api-client/APIClient.d.ts +2 -1
- package/es/api-client/APIClient.mjs +6 -3
- package/es/application/Plugin.d.ts +2 -2
- package/es/application/hoc/withDynamicSchemaProps.mjs +1 -1
- package/es/application/schema-initializer/hooks/index.mjs +4 -1
- package/es/application/schema-settings/components/SchemaSettingsChildren.mjs +14 -14
- package/es/application/utils/clientModuleRegistry.d.ts +2 -0
- package/es/application/utils/clientModuleRegistry.mjs +9 -0
- package/es/application/utils/globalDeps.mjs +3 -3
- package/es/block-provider/BlockProvider.d.ts +1 -27
- package/es/block-provider/BlockProvider.mjs +1 -3
- package/es/block-provider/BlockRequestContext.d.ts +27 -0
- package/es/block-provider/BlockRequestContext.mjs +5 -0
- package/es/block-provider/FormBlockContext.d.ts +32 -0
- package/es/block-provider/FormBlockContext.mjs +5 -0
- package/es/block-provider/FormBlockProvider.d.ts +1 -33
- package/es/block-provider/FormBlockProvider.mjs +4 -5
- package/es/built-in/acl/ACLCollectionFieldProvider.d.ts +1 -0
- package/es/built-in/acl/ACLCollectionFieldProvider.mjs +42 -0
- package/es/built-in/acl/ACLContext.d.ts +9 -0
- package/es/built-in/acl/ACLContext.mjs +24 -0
- package/es/built-in/acl/ACLPlugin.mjs +2 -1
- package/es/built-in/acl/ACLProvider.d.ts +0 -11
- package/es/built-in/acl/ACLProvider.mjs +6 -51
- package/es/built-in/acl/index.d.ts +2 -0
- package/es/built-in/acl/index.mjs +2 -0
- package/es/collection-manager/hooks/useCollectionManager_deprecated.mjs +2 -1
- package/es/collection-manager/sub-table.d.ts +1 -1
- package/es/data-source/data-source/DataSourceManager.d.ts +1 -2
- package/es/data-source/data-source/DataSourceManager.mjs +1 -2
- package/es/data-source/data-source/constants.d.ts +2 -0
- package/es/data-source/data-source/constants.mjs +3 -0
- package/es/data-source/utils.d.ts +2 -2
- package/es/data-source/utils.mjs +1 -1
- package/es/exports.d.ts +46 -0
- package/es/exports.mjs +46 -0
- package/es/filter-provider/utils.d.ts +2 -14
- package/es/filter-provider/utils.mjs +2 -57
- package/es/index.d.ts +1 -46
- package/es/index.mjs +4 -46
- package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.d.ts +2 -86
- package/es/record-provider/index.mjs +3 -3
- package/es/schema-component/antd/action/Action.mjs +7 -6
- package/es/schema-component/antd/action/hooks.mjs +3 -2
- package/es/schema-component/antd/association-field/AssociationSelect.mjs +4 -3
- package/es/schema-component/antd/association-field/hooks.mjs +18 -1
- package/es/schema-component/antd/cron/CronSet.mjs +9 -3
- package/es/schema-component/antd/filter/conditionUtils.d.ts +2 -0
- package/es/schema-component/antd/filter/conditionUtils.mjs +133 -0
- package/es/schema-component/antd/filter/dateValueUtils.d.ts +13 -0
- package/es/schema-component/antd/filter/dateValueUtils.mjs +66 -0
- package/es/schema-component/antd/filter/useFilterActionProps.d.ts +2 -4
- package/es/schema-component/antd/filter/useFilterActionProps.mjs +3 -181
- package/es/schema-component/antd/filter/useGetFilterOptions.d.ts +2 -0
- package/es/schema-component/antd/filter/useGetFilterOptions.mjs +54 -0
- package/es/schema-component/antd/form/Form.mjs +1 -1
- package/es/schema-component/antd/form-item/FormItem.FilterFormDesigner.mjs +1 -1
- package/es/schema-component/antd/form-item/FormItem.d.ts +1 -1
- package/es/schema-component/antd/form-item/FormItem.mjs +14 -12
- package/es/schema-component/antd/form-item/SchemaSettingOptions.d.ts +1 -14
- package/es/schema-component/antd/form-item/SchemaSettingOptions.mjs +1 -33
- package/es/schema-component/antd/form-item/hooks/useLazyLoadDisplayAssociationFieldsOfForm.mjs +4 -3
- package/es/schema-component/antd/form-item/hooks/useParseDefaultValue.mjs +5 -3
- package/es/schema-component/antd/form-item/operatorUtils.d.ts +14 -0
- package/es/schema-component/antd/form-item/operatorUtils.mjs +36 -0
- package/es/schema-component/antd/form-v2/Form.mjs +26 -167
- package/es/schema-component/antd/form-v2/FormLinkageRules.d.ts +9 -0
- package/es/schema-component/antd/form-v2/FormLinkageRules.mjs +191 -0
- package/es/schema-component/antd/form-v2/Templates.mjs +1 -1
- package/es/schema-component/antd/grid/Grid.mjs +6 -4
- package/es/schema-component/antd/grid-card/GridCard.Item.mjs +2 -2
- package/es/schema-component/antd/icon-picker/IconFilterInput.mjs +12 -4
- package/es/schema-component/antd/icon-picker/IconPicker.mjs +1 -1
- package/es/schema-component/antd/input/Json.d.ts +1 -4
- package/es/schema-component/antd/input/ReadPretty.mjs +2 -2
- package/es/schema-component/antd/input-number/ReadPretty.mjs +1 -1
- package/es/schema-component/antd/markdown/Markdown.Void.Designer.mjs +2 -1
- package/es/schema-component/antd/markdown/Markdown.Void.mjs +10 -2
- package/es/schema-component/antd/markdown/Markdown.mjs +1 -1
- package/es/schema-component/antd/markdown/util.mjs +5 -0
- package/es/schema-component/antd/rich-text/RichText.mjs +1 -1
- package/es/schema-component/antd/select/FormulaSelect.mjs +1 -2
- package/es/schema-component/antd/select/ReadPretty.mjs +2 -2
- package/es/schema-component/antd/select/Select.mjs +1 -2
- package/es/schema-component/antd/select/utils.d.ts +2 -1
- package/es/schema-component/antd/select/utils.mjs +2 -2
- package/es/schema-component/antd/time-picker/ReadPretty.mjs +1 -1
- package/es/schema-component/antd/upload/ReadPretty.mjs +5 -5
- package/es/schema-component/antd/upload/Upload.mjs +6 -5
- package/es/schema-component/antd/variable/Input.mjs +1 -1
- package/es/schema-component/antd/variable/TextArea.mjs +1 -1
- package/es/schema-component/hooks/useDesigner.mjs +9 -3
- package/es/schema-component/hooks/useOptionalNavigate.d.ts +1 -0
- package/es/schema-component/hooks/useOptionalNavigate.mjs +2 -0
- package/es/schema-settings/DataTemplates/components/Designer.mjs +2 -1
- package/es/schema-settings/VariableInput/hooks/useBaseVariable.mjs +2 -1
- package/es/schema-settings/VariableInput/hooks/useBlockCollection.mjs +1 -1
- package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.mjs +2 -1
- package/es/schema-settings/VariableInput/hooks/useFormVariable.mjs +1 -1
- package/es/schema-settings/VariableInput/hooks/useRecordVariable.mjs +1 -1
- package/es/style/theme/AntdAppProvider.mjs +2 -2
- package/es/user/ChangePassword.d.ts +4 -1
- package/es/user/CurrentUserContext.d.ts +2 -0
- package/es/user/CurrentUserContext.mjs +5 -0
- package/es/user/CurrentUserProvider.d.ts +0 -3
- package/es/user/CurrentUserProvider.mjs +3 -5
- package/es/user/EditProfile.d.ts +4 -1
- package/es/user/LanguageSettings.d.ts +4 -1
- package/es/user/SwitchRole.d.ts +4 -1
- package/es/user/index.d.ts +1 -0
- package/es/user/index.mjs +1 -0
- package/es/variables/VariablesProvider.mjs +1 -1
- package/lib/api-client/APIClient.js +8 -5
- package/lib/application/hoc/withDynamicSchemaProps.js +3 -3
- package/lib/application/schema-initializer/hooks/index.js +4 -1
- package/lib/application/schema-settings/components/SchemaSettingsChildren.js +14 -14
- package/lib/application/utils/clientModuleRegistry.js +46 -0
- package/lib/application/utils/globalDeps.js +2 -2
- package/lib/block-provider/BlockProvider.js +6 -8
- package/lib/block-provider/BlockRequestContext.js +42 -0
- package/lib/block-provider/FormBlockContext.js +42 -0
- package/lib/block-provider/FormBlockProvider.js +13 -14
- package/lib/built-in/acl/ACLCollectionFieldProvider.js +76 -0
- package/lib/built-in/acl/ACLContext.js +70 -0
- package/lib/built-in/acl/ACLPlugin.js +2 -1
- package/lib/built-in/acl/ACLProvider.js +13 -76
- package/lib/built-in/acl/index.js +27 -9
- package/lib/collection-manager/hooks/useCollectionManager_deprecated.js +4 -3
- package/lib/data-source/data-source/DataSourceManager.js +6 -7
- package/lib/data-source/data-source/constants.js +40 -0
- package/lib/data-source/utils.js +2 -2
- package/lib/exports.js +769 -0
- package/lib/filter-provider/utils.js +7 -63
- package/lib/index.js +10 -714
- package/lib/record-provider/index.js +6 -6
- package/lib/schema-component/antd/action/Action.js +9 -8
- package/lib/schema-component/antd/action/hooks.js +3 -2
- package/lib/schema-component/antd/association-field/AssociationSelect.js +3 -2
- package/lib/schema-component/antd/association-field/hooks.js +18 -1
- package/lib/schema-component/antd/cron/CronSet.js +8 -2
- package/lib/schema-component/antd/filter/conditionUtils.js +180 -0
- package/lib/schema-component/antd/filter/dateValueUtils.js +116 -0
- package/lib/schema-component/antd/filter/useFilterActionProps.js +7 -186
- package/lib/schema-component/antd/filter/useGetFilterOptions.js +91 -0
- package/lib/schema-component/antd/form/Form.js +4 -4
- package/lib/schema-component/antd/form-item/FormItem.FilterFormDesigner.js +2 -2
- package/lib/schema-component/antd/form-item/FormItem.js +23 -20
- package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +6 -38
- package/lib/schema-component/antd/form-item/hooks/useLazyLoadDisplayAssociationFieldsOfForm.js +9 -7
- package/lib/schema-component/antd/form-item/hooks/useParseDefaultValue.js +12 -8
- package/lib/schema-component/antd/form-item/operatorUtils.js +76 -0
- package/lib/schema-component/antd/form-v2/Form.js +204 -317
- package/lib/schema-component/antd/form-v2/FormLinkageRules.js +236 -0
- package/lib/schema-component/antd/form-v2/Templates.js +2 -2
- package/lib/schema-component/antd/grid/Grid.js +11 -9
- package/lib/schema-component/antd/grid-card/GridCard.Item.js +2 -2
- package/lib/schema-component/antd/icon-picker/IconFilterInput.js +12 -4
- package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -1
- package/lib/schema-component/antd/input/ReadPretty.js +10 -10
- package/lib/schema-component/antd/input-number/ReadPretty.js +1 -1
- package/lib/schema-component/antd/markdown/Markdown.Void.Designer.js +6 -5
- package/lib/schema-component/antd/markdown/Markdown.Void.js +138 -111
- package/lib/schema-component/antd/markdown/Markdown.js +2 -2
- package/lib/schema-component/antd/markdown/util.js +5 -0
- package/lib/schema-component/antd/rich-text/RichText.js +2 -2
- package/lib/schema-component/antd/select/FormulaSelect.js +1 -2
- package/lib/schema-component/antd/select/ReadPretty.js +2 -2
- package/lib/schema-component/antd/select/Select.js +1 -2
- package/lib/schema-component/antd/select/utils.js +6 -3
- package/lib/schema-component/antd/time-picker/ReadPretty.js +2 -2
- package/lib/schema-component/antd/upload/ReadPretty.js +5 -5
- package/lib/schema-component/antd/upload/Upload.js +6 -5
- package/lib/schema-component/antd/variable/Input.js +1 -1
- package/lib/schema-component/antd/variable/TextArea.js +1 -1
- package/lib/schema-component/hooks/useDesigner.js +57 -23
- package/lib/schema-component/hooks/useOptionalNavigate.js +36 -0
- package/lib/schema-settings/DataTemplates/components/Designer.js +4 -3
- package/lib/schema-settings/VariableInput/hooks/useBaseVariable.js +4 -3
- package/lib/schema-settings/VariableInput/hooks/useBlockCollection.js +2 -2
- package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.js +4 -3
- package/lib/schema-settings/VariableInput/hooks/useFormVariable.js +2 -2
- package/lib/schema-settings/VariableInput/hooks/useRecordVariable.js +2 -2
- package/lib/style/theme/AntdAppProvider.js +4 -4
- package/lib/user/CurrentUserContext.js +42 -0
- package/lib/user/CurrentUserProvider.js +6 -14
- package/lib/user/index.js +24 -12
- package/lib/variables/VariablesProvider.js +2 -2
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { connect, mapReadPretty, useFieldSchema } from "@tachybase/schema";
|
|
3
|
+
import { connect, mapProps, mapReadPretty, useFieldSchema } from "@tachybase/schema";
|
|
4
4
|
import { Select } from "antd";
|
|
5
5
|
import { useCollection_deprecated } from "../../../collection-manager/index.mjs";
|
|
6
6
|
import { useCompile } from "../../hooks/index.mjs";
|
|
@@ -24,6 +24,7 @@ const CronSetInternal = (props)=>{
|
|
|
24
24
|
label: compile(item.label)
|
|
25
25
|
})), [
|
|
26
26
|
props.options,
|
|
27
|
+
uiSchemaOptions,
|
|
27
28
|
customizeOption
|
|
28
29
|
]);
|
|
29
30
|
useEffect(()=>{
|
|
@@ -86,7 +87,8 @@ const ReadPretty = (props)=>{
|
|
|
86
87
|
const { getField } = useCollection_deprecated();
|
|
87
88
|
const uiSchemaOptions = null == (_getField = getField(null == fieldSchema ? void 0 : fieldSchema.name)) ? void 0 : _getField.uiSchema.enum;
|
|
88
89
|
const options = useMemo(()=>(props.options || []).concat(uiSchemaOptions || []), [
|
|
89
|
-
props.options
|
|
90
|
+
props.options,
|
|
91
|
+
uiSchemaOptions
|
|
90
92
|
]);
|
|
91
93
|
const label = useMemo(()=>{
|
|
92
94
|
var _options_find;
|
|
@@ -102,5 +104,9 @@ const ReadPretty = (props)=>{
|
|
|
102
104
|
}))
|
|
103
105
|
});
|
|
104
106
|
};
|
|
105
|
-
const CronSet = connect(CronSetInternal,
|
|
107
|
+
const CronSet = connect(CronSetInternal, mapProps({
|
|
108
|
+
dataSource: 'options',
|
|
109
|
+
value: 'value',
|
|
110
|
+
onInput: 'onChange'
|
|
111
|
+
}), mapReadPretty(ReadPretty));
|
|
106
112
|
export { CronSet };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import flat from "flat";
|
|
2
|
+
import { resolveDatePickerRangeValueInfo } from "../date-picker/util.mjs";
|
|
3
|
+
import { FILTER_OPERATORS_WITH_ARRAY_VALUES, normalizeDateBetweenValue, shouldUseDefaultDateBoundary } from "./dateValueUtils.mjs";
|
|
4
|
+
import { hasDuplicateKeys } from "./utils.mjs";
|
|
5
|
+
const isEmpty = (obj)=>Array.isArray(obj) && 0 === obj.length || obj && 0 === Object.keys(obj).length && Object.getPrototypeOf(obj) === Object.prototype;
|
|
6
|
+
const CUSTOM_FILTER_VARIABLE_REGEXP = /^\{\{\$nFilter\.([^}]+)\}\}$/;
|
|
7
|
+
const getCustomFilterValue = function(items, key) {
|
|
8
|
+
let rawItems = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
9
|
+
if (rawItems && key in rawItems) return rawItems[key];
|
|
10
|
+
if (key in items) return items[key];
|
|
11
|
+
const arrayItems = Object.keys(items).filter((itemKey)=>itemKey.startsWith("".concat(key, ".")) && /^\d+$/.test(itemKey.slice(key.length + 1))).sort((a, b)=>Number(a.slice(key.length + 1)) - Number(b.slice(key.length + 1))).map((itemKey)=>items[itemKey]);
|
|
12
|
+
return arrayItems.length ? arrayItems : void 0;
|
|
13
|
+
};
|
|
14
|
+
const findCustomFieldSchemaInTree = (schema, key)=>{
|
|
15
|
+
if (!schema) return null;
|
|
16
|
+
if (schema.name === "__custom.".concat(key) || schema.name === key) return schema;
|
|
17
|
+
const properties = schema.properties || {};
|
|
18
|
+
for (const propertyKey of Object.keys(properties)){
|
|
19
|
+
if (propertyKey === "__custom.".concat(key) || propertyKey === key) return properties[propertyKey];
|
|
20
|
+
const found = findCustomFieldSchemaInTree(properties[propertyKey], key);
|
|
21
|
+
if (found) return found;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
const findCustomFieldSchema = (schema, key)=>{
|
|
26
|
+
let current = schema;
|
|
27
|
+
while(current){
|
|
28
|
+
const found = findCustomFieldSchemaInTree(current, key);
|
|
29
|
+
if (found) return found;
|
|
30
|
+
current = current.parent;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
const getDatePickerComponent = (fieldSchema)=>{
|
|
35
|
+
var _fieldSchema_xcomponentprops;
|
|
36
|
+
if ((null == fieldSchema ? void 0 : fieldSchema['x-component']) === 'CollectionField') {
|
|
37
|
+
var _fieldSchema_xcomponentprops1;
|
|
38
|
+
return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1.component;
|
|
39
|
+
}
|
|
40
|
+
return (null == fieldSchema ? void 0 : fieldSchema['x-component']) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
|
|
41
|
+
};
|
|
42
|
+
const getDatePickerShowTime = (fieldSchema)=>{
|
|
43
|
+
var _fieldSchema_xcomponentprops;
|
|
44
|
+
return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.showTime;
|
|
45
|
+
};
|
|
46
|
+
const expandArrayValueFilter = function(filterSchemaItem, filterKey, value, customFlat) {
|
|
47
|
+
let options = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {};
|
|
48
|
+
const pathParts = filterKey.split('.');
|
|
49
|
+
const operator = pathParts.pop();
|
|
50
|
+
if ('$dateBetween' === operator && Array.isArray(value)) {
|
|
51
|
+
const valueInfo = resolveDatePickerRangeValueInfo(value, {
|
|
52
|
+
component: options.component,
|
|
53
|
+
showTime: options.showTime,
|
|
54
|
+
preferDateBoundaryFallback: options.useDefaultDateBoundary
|
|
55
|
+
});
|
|
56
|
+
filterSchemaItem[filterKey] = normalizeDateBetweenValue(value, {
|
|
57
|
+
useDefaultDateBoundary: options.useDefaultDateBoundary,
|
|
58
|
+
valueMode: valueInfo.mode,
|
|
59
|
+
valueSource: valueInfo.source,
|
|
60
|
+
preferDateBoundaryFallback: 'retained-date-boundary' === valueInfo.source
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!Array.isArray(value) || FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator || '')) {
|
|
65
|
+
filterSchemaItem[filterKey] = value;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (0 === value.length) return void delete filterSchemaItem[filterKey];
|
|
69
|
+
let branchEndIndex = -1;
|
|
70
|
+
for(let index = pathParts.length - 2; index >= 0; index--)if ([
|
|
71
|
+
'$and',
|
|
72
|
+
'$or'
|
|
73
|
+
].includes(pathParts[index]) && /^\d+$/.test(pathParts[index + 1])) {
|
|
74
|
+
branchEndIndex = index;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
const branchPath = branchEndIndex >= 0 ? pathParts.slice(0, branchEndIndex + 2).join('.') : '';
|
|
78
|
+
const fieldPath = pathParts.slice(branchEndIndex + 2).join('.');
|
|
79
|
+
const conditions = value.map((item)=>customFlat.unflatten({
|
|
80
|
+
["".concat(fieldPath, ".").concat(operator)]: item
|
|
81
|
+
}));
|
|
82
|
+
delete filterSchemaItem[filterKey];
|
|
83
|
+
filterSchemaItem[branchPath ? "".concat(branchPath, ".$or") : '$or'] = conditions;
|
|
84
|
+
};
|
|
85
|
+
const getCustomCondition = function(filter, fieldSchema) {
|
|
86
|
+
let customFlat = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : flat;
|
|
87
|
+
var _filterSchema_$and, _filterSchema_$or;
|
|
88
|
+
const filterSchema = fieldSchema ? fieldSchema['x-filter-rules'] : '';
|
|
89
|
+
const filterSchemaItem = customFlat(filterSchema || '');
|
|
90
|
+
const items = customFlat(filter || {});
|
|
91
|
+
const isCustomFilter = (null == filterSchema ? void 0 : null == (_filterSchema_$and = filterSchema.$and) ? void 0 : _filterSchema_$and.length) || (null == filterSchema ? void 0 : null == (_filterSchema_$or = filterSchema.$or) ? void 0 : _filterSchema_$or.length);
|
|
92
|
+
const isFilterCustom = isCustomFilter ? hasDuplicateKeys(items, filterSchemaItem) : false;
|
|
93
|
+
if (isFilterCustom) return customFlat.unflatten(items);
|
|
94
|
+
if (!isCustomFilter) return customFlat.unflatten({});
|
|
95
|
+
{
|
|
96
|
+
for(const filterKey in filterSchemaItem){
|
|
97
|
+
const match = 'string' == typeof filterSchemaItem[filterKey] && filterSchemaItem[filterKey].match(CUSTOM_FILTER_VARIABLE_REGEXP);
|
|
98
|
+
if (!match) continue;
|
|
99
|
+
const customFieldSchema = findCustomFieldSchema(fieldSchema, match[1]);
|
|
100
|
+
expandArrayValueFilter(filterSchemaItem, filterKey, getCustomFilterValue(items, match[1], filter || {}), customFlat, {
|
|
101
|
+
useDefaultDateBoundary: shouldUseDefaultDateBoundary(customFieldSchema),
|
|
102
|
+
component: getDatePickerComponent(customFieldSchema),
|
|
103
|
+
showTime: getDatePickerShowTime(customFieldSchema)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
for(const item in filterSchemaItem){
|
|
107
|
+
const value = filterSchemaItem[item];
|
|
108
|
+
if (null == value || '' === value || 'string' == typeof value && value.includes('$nFilter')) delete filterSchemaItem[item];
|
|
109
|
+
}
|
|
110
|
+
const flatFieldSchema = customFlat.unflatten(filterSchemaItem);
|
|
111
|
+
if (Array.isArray(null == flatFieldSchema ? void 0 : flatFieldSchema['$and'])) flatFieldSchema['$and'] = flatFieldSchema['$and'].filter(Boolean);
|
|
112
|
+
if (Array.isArray(null == flatFieldSchema ? void 0 : flatFieldSchema['$or'])) flatFieldSchema['$or'] = flatFieldSchema['$or'].filter(Boolean);
|
|
113
|
+
return flatFieldSchema;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const removeNullCondition = function(filter) {
|
|
117
|
+
let customFlat = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : flat;
|
|
118
|
+
const items = customFlat(filter || {});
|
|
119
|
+
const values = {};
|
|
120
|
+
for(const key in items){
|
|
121
|
+
const value = items[key];
|
|
122
|
+
if (null != value && !isEmpty(value)) values[key] = value;
|
|
123
|
+
}
|
|
124
|
+
for (const key of Object.keys(values))if (key.endsWith('$dateBetween.0')) {
|
|
125
|
+
const key1 = key.replace(/\$dateBetween\.0$/, '$dateBetween.1');
|
|
126
|
+
if (!(key1 in values)) values[key1] = values[key];
|
|
127
|
+
} else if (key.endsWith('$dateBetween.1')) {
|
|
128
|
+
const key0 = key.replace(/\$dateBetween\.1$/, '$dateBetween.0');
|
|
129
|
+
if (!(key0 in values)) values[key0] = values[key];
|
|
130
|
+
}
|
|
131
|
+
return customFlat.unflatten(values);
|
|
132
|
+
};
|
|
133
|
+
export { getCustomCondition, removeNullCondition };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DatePickerRangeValueMode, type DatePickerRangeValueSource } from '../date-picker/util';
|
|
2
|
+
/**
|
|
3
|
+
* 筛选值为数组的操作符;与 transformToFilter 的 flatten breakOn、filterByCleanedFields 路径去重共用,避免两处列表漂移。
|
|
4
|
+
*/
|
|
5
|
+
export declare const FILTER_OPERATORS_WITH_ARRAY_VALUES: Set<string>;
|
|
6
|
+
export type NormalizeDateBetweenOptions = {
|
|
7
|
+
useDefaultDateBoundary?: boolean;
|
|
8
|
+
valueMode?: DatePickerRangeValueMode;
|
|
9
|
+
valueSource?: DatePickerRangeValueSource;
|
|
10
|
+
preferDateBoundaryFallback?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const normalizeDateBetweenValue: (value: any[], options?: NormalizeDateBetweenOptions) => any[];
|
|
13
|
+
export declare const shouldUseDefaultDateBoundary: (fieldSchema?: any) => boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { isDatePickerDefaultRangeBoundaryValue } from "../date-picker/util.mjs";
|
|
3
|
+
const FILTER_OPERATORS_WITH_ARRAY_VALUES = new Set([
|
|
4
|
+
'$match',
|
|
5
|
+
'$notMatch',
|
|
6
|
+
'$anyOf',
|
|
7
|
+
'$noneOf',
|
|
8
|
+
'$childIn',
|
|
9
|
+
'$childNotIn',
|
|
10
|
+
'$dateBetween',
|
|
11
|
+
'$in',
|
|
12
|
+
'$notIn'
|
|
13
|
+
]);
|
|
14
|
+
const getDatePickerComponent = (fieldSchema)=>{
|
|
15
|
+
var _fieldSchema_xcomponentprops;
|
|
16
|
+
if ((null == fieldSchema ? void 0 : fieldSchema['x-component']) === 'CollectionField') {
|
|
17
|
+
var _fieldSchema_xcomponentprops1;
|
|
18
|
+
return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1.component;
|
|
19
|
+
}
|
|
20
|
+
return (null == fieldSchema ? void 0 : fieldSchema['x-component']) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
|
|
21
|
+
};
|
|
22
|
+
const isDateOnlyString = (value)=>'string' == typeof value && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
23
|
+
const hasExplicitTime = (value)=>'string' == typeof value && /[T\s]\d{2}:\d{2}/.test(value);
|
|
24
|
+
const normalizeLocalDateBoundaryInput = (value)=>{
|
|
25
|
+
if ('string' != typeof value) return value;
|
|
26
|
+
return value.replace(/Z$/, '').replace(/[+-]\d\d:\d\d$/, '');
|
|
27
|
+
};
|
|
28
|
+
const normalizeDateBetweenBoundary = function(value, boundary) {
|
|
29
|
+
let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
30
|
+
const m = dayjs(value);
|
|
31
|
+
if (!m.isValid()) return value;
|
|
32
|
+
if (isDateOnlyString(value)) return ('start' === boundary ? m.startOf('day') : m.endOf('day')).toISOString();
|
|
33
|
+
if ('date' === options.valueMode) {
|
|
34
|
+
if ('metadata' === options.valueSource || 'retained-local-date-boundary' === options.valueSource) return m.toISOString();
|
|
35
|
+
const localBoundary = dayjs(normalizeLocalDateBoundaryInput(value));
|
|
36
|
+
return ('start' === boundary ? localBoundary.startOf('day') : localBoundary.endOf('day')).toISOString();
|
|
37
|
+
}
|
|
38
|
+
if (hasExplicitTime(value)) return m.toISOString();
|
|
39
|
+
if (!options.useDefaultDateBoundary) return m.toISOString();
|
|
40
|
+
return ('start' === boundary ? m.startOf('day') : m.endOf('day')).toISOString();
|
|
41
|
+
};
|
|
42
|
+
const shouldApplyDefaultDateBoundary = function(start, end, value) {
|
|
43
|
+
let options = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
|
|
44
|
+
if ('datetime' === options.valueMode) return false;
|
|
45
|
+
if ('date' === options.valueMode) return true;
|
|
46
|
+
if (!options.useDefaultDateBoundary) return false;
|
|
47
|
+
if (isDateOnlyString(start) || isDateOnlyString(end)) return true;
|
|
48
|
+
return options.preferDateBoundaryFallback && 'date' === options.valueMode && isDatePickerDefaultRangeBoundaryValue(start, 'start') && isDatePickerDefaultRangeBoundaryValue(end, 'end');
|
|
49
|
+
};
|
|
50
|
+
const normalizeDateBetweenValue = function(value) {
|
|
51
|
+
let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
52
|
+
const normalized = value.filter(Boolean);
|
|
53
|
+
if (0 === normalized.length) return null;
|
|
54
|
+
const start = normalized[0];
|
|
55
|
+
const end = 1 === normalized.length ? normalized[0] : normalized[normalized.length - 1];
|
|
56
|
+
const boundaryOptions = {
|
|
57
|
+
...options,
|
|
58
|
+
useDefaultDateBoundary: shouldApplyDefaultDateBoundary(start, end, value, options)
|
|
59
|
+
};
|
|
60
|
+
return [
|
|
61
|
+
normalizeDateBetweenBoundary(start, 'start', boundaryOptions),
|
|
62
|
+
normalizeDateBetweenBoundary(end, 'end', boundaryOptions)
|
|
63
|
+
];
|
|
64
|
+
};
|
|
65
|
+
const shouldUseDefaultDateBoundary = (fieldSchema)=>'DatePicker.RangePicker' === getDatePickerComponent(fieldSchema);
|
|
66
|
+
export { FILTER_OPERATORS_WITH_ARRAY_VALUES, normalizeDateBetweenValue, shouldUseDefaultDateBoundary };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { getCustomCondition, removeNullCondition } from './conditionUtils';
|
|
2
|
+
export { useGetFilterFieldOptions, useGetFilterOptions } from './useGetFilterOptions';
|
|
2
3
|
export declare const useFilterOptions: (collectionName: string) => any[];
|
|
3
|
-
export declare const useGetFilterFieldOptions: () => (fields: any) => any[];
|
|
4
4
|
export declare const useFilterFieldOptions: (fields: any) => any[];
|
|
5
|
-
export declare const getCustomCondition: any;
|
|
6
|
-
export declare const removeNullCondition: any;
|
|
7
5
|
export declare const useFilterActionProps: () => {
|
|
8
6
|
options: any;
|
|
9
7
|
onSubmit(values: any): any;
|
|
@@ -1,70 +1,18 @@
|
|
|
1
1
|
import { useField, useFieldSchema } from "@tachybase/schema";
|
|
2
|
-
import flat from "flat";
|
|
3
2
|
import lodash from "lodash";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
5
4
|
import { useBlockRequestContext } from "../../../block-provider/index.mjs";
|
|
6
5
|
import { useCollectionManager_deprecated, useCollection_deprecated } from "../../../collection-manager/index.mjs";
|
|
7
|
-
import {
|
|
6
|
+
import { mergeFilter } from "../../../filter-provider/utils.mjs";
|
|
8
7
|
import { useDataLoadingMode } from "../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
const useGetFilterOptions = ()=>{
|
|
12
|
-
const { getCollectionFields } = useCollectionManager_deprecated();
|
|
13
|
-
const getFilterFieldOptions = useGetFilterFieldOptions();
|
|
14
|
-
return (collectionName, dataSource)=>{
|
|
15
|
-
const fields = getCollectionFields(collectionName, dataSource);
|
|
16
|
-
const options = getFilterFieldOptions(fields);
|
|
17
|
-
return options;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
8
|
+
import { getCustomCondition, removeNullCondition } from "./conditionUtils.mjs";
|
|
9
|
+
import { useGetFilterFieldOptions, useGetFilterOptions } from "./useGetFilterOptions.mjs";
|
|
20
10
|
const useFilterOptions = (collectionName)=>{
|
|
21
11
|
const { getCollectionFields } = useCollectionManager_deprecated();
|
|
22
12
|
const fields = getCollectionFields(collectionName);
|
|
23
13
|
const options = useFilterFieldOptions(fields);
|
|
24
14
|
return options;
|
|
25
15
|
};
|
|
26
|
-
const useGetFilterFieldOptions = ()=>{
|
|
27
|
-
var _fieldSchema_xcomponentprops;
|
|
28
|
-
const fieldSchema = useFieldSchema();
|
|
29
|
-
const nonfilterable = (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.nonfilterable) || [];
|
|
30
|
-
const { getCollectionFields, getInterface } = useCollectionManager_deprecated();
|
|
31
|
-
const field2option = (field, depth)=>{
|
|
32
|
-
var _field_uiSchema, _operators_filter;
|
|
33
|
-
if (nonfilterable.length && 1 === depth && nonfilterable.includes(field.name)) return;
|
|
34
|
-
if (!field.interface) return;
|
|
35
|
-
const fieldInterface = getInterface(field.interface);
|
|
36
|
-
if (!(null == fieldInterface ? void 0 : fieldInterface.filterable)) return;
|
|
37
|
-
const { nested, children, operators } = fieldInterface.filterable;
|
|
38
|
-
const option = {
|
|
39
|
-
name: field.name,
|
|
40
|
-
type: field.type,
|
|
41
|
-
target: field.target,
|
|
42
|
-
title: (null == field ? void 0 : null == (_field_uiSchema = field.uiSchema) ? void 0 : _field_uiSchema.title) || field.name,
|
|
43
|
-
schema: null == field ? void 0 : field.uiSchema,
|
|
44
|
-
interface: field.interface,
|
|
45
|
-
operators: (null == operators ? void 0 : null == (_operators_filter = operators.filter) ? void 0 : _operators_filter.call(operators, (operator)=>!(null == operator ? void 0 : operator.visible) || operator.visible(field))) || []
|
|
46
|
-
};
|
|
47
|
-
if (field.target && depth > 2) return;
|
|
48
|
-
if (depth > 2) return option;
|
|
49
|
-
if (null == children ? void 0 : children.length) option['children'] = children;
|
|
50
|
-
if (nested) {
|
|
51
|
-
const targetFields = getCollectionFields(field.target);
|
|
52
|
-
const options = getOptions(targetFields, depth + 1).filter(Boolean);
|
|
53
|
-
option['children'] = option['children'] || [];
|
|
54
|
-
option['children'].push(...options);
|
|
55
|
-
}
|
|
56
|
-
return option;
|
|
57
|
-
};
|
|
58
|
-
const getOptions = (fields, depth)=>{
|
|
59
|
-
const options = [];
|
|
60
|
-
fields.forEach((field)=>{
|
|
61
|
-
const option = field2option(field, depth);
|
|
62
|
-
if (option) options.push(option);
|
|
63
|
-
});
|
|
64
|
-
return options;
|
|
65
|
-
};
|
|
66
|
-
return (fields)=>getOptions(fields, 1);
|
|
67
|
-
};
|
|
68
16
|
const useFilterFieldOptions = (fields)=>{
|
|
69
17
|
var _fieldSchema_xcomponentprops;
|
|
70
18
|
const fieldSchema = useFieldSchema();
|
|
@@ -106,132 +54,6 @@ const useFilterFieldOptions = (fields)=>{
|
|
|
106
54
|
};
|
|
107
55
|
return getOptions(fields, 1);
|
|
108
56
|
};
|
|
109
|
-
const isEmpty = (obj)=>Array.isArray(obj) && 0 === obj.length || obj && 0 === Object.keys(obj).length && Object.getPrototypeOf(obj) === Object.prototype;
|
|
110
|
-
const CUSTOM_FILTER_VARIABLE_REGEXP = /^\{\{\$nFilter\.([^}]+)\}\}$/;
|
|
111
|
-
const getCustomFilterValue = function(items, key) {
|
|
112
|
-
let rawItems = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
113
|
-
if (rawItems && key in rawItems) return rawItems[key];
|
|
114
|
-
if (key in items) return items[key];
|
|
115
|
-
const arrayItems = Object.keys(items).filter((itemKey)=>itemKey.startsWith("".concat(key, ".")) && /^\d+$/.test(itemKey.slice(key.length + 1))).sort((a, b)=>Number(a.slice(key.length + 1)) - Number(b.slice(key.length + 1))).map((itemKey)=>items[itemKey]);
|
|
116
|
-
return arrayItems.length ? arrayItems : void 0;
|
|
117
|
-
};
|
|
118
|
-
const findCustomFieldSchemaInTree = (schema, key)=>{
|
|
119
|
-
if (!schema) return null;
|
|
120
|
-
if (schema.name === "__custom.".concat(key) || schema.name === key) return schema;
|
|
121
|
-
const properties = schema.properties || {};
|
|
122
|
-
for (const propertyKey of Object.keys(properties)){
|
|
123
|
-
if (propertyKey === "__custom.".concat(key) || propertyKey === key) return properties[propertyKey];
|
|
124
|
-
const found = findCustomFieldSchemaInTree(properties[propertyKey], key);
|
|
125
|
-
if (found) return found;
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
128
|
-
};
|
|
129
|
-
const findCustomFieldSchema = (schema, key)=>{
|
|
130
|
-
let current = schema;
|
|
131
|
-
while(current){
|
|
132
|
-
const found = findCustomFieldSchemaInTree(current, key);
|
|
133
|
-
if (found) return found;
|
|
134
|
-
current = current.parent;
|
|
135
|
-
}
|
|
136
|
-
return null;
|
|
137
|
-
};
|
|
138
|
-
const getDatePickerComponent = (fieldSchema)=>{
|
|
139
|
-
var _fieldSchema_xcomponentprops;
|
|
140
|
-
if ((null == fieldSchema ? void 0 : fieldSchema['x-component']) === 'CollectionField') {
|
|
141
|
-
var _fieldSchema_xcomponentprops1;
|
|
142
|
-
return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1.component;
|
|
143
|
-
}
|
|
144
|
-
return (null == fieldSchema ? void 0 : fieldSchema['x-component']) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
|
|
145
|
-
};
|
|
146
|
-
const getDatePickerShowTime = (fieldSchema)=>{
|
|
147
|
-
var _fieldSchema_xcomponentprops;
|
|
148
|
-
return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.showTime;
|
|
149
|
-
};
|
|
150
|
-
const expandArrayValueFilter = function(filterSchemaItem, filterKey, value, customFlat) {
|
|
151
|
-
let options = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {};
|
|
152
|
-
const pathParts = filterKey.split('.');
|
|
153
|
-
const operator = pathParts.pop();
|
|
154
|
-
if ('$dateBetween' === operator && Array.isArray(value)) {
|
|
155
|
-
const valueInfo = resolveDatePickerRangeValueInfo(value, {
|
|
156
|
-
component: options.component,
|
|
157
|
-
showTime: options.showTime,
|
|
158
|
-
preferDateBoundaryFallback: options.useDefaultDateBoundary
|
|
159
|
-
});
|
|
160
|
-
filterSchemaItem[filterKey] = normalizeDateBetweenValue(value, {
|
|
161
|
-
useDefaultDateBoundary: options.useDefaultDateBoundary,
|
|
162
|
-
valueMode: valueInfo.mode,
|
|
163
|
-
valueSource: valueInfo.source,
|
|
164
|
-
preferDateBoundaryFallback: 'retained-date-boundary' === valueInfo.source
|
|
165
|
-
});
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (!Array.isArray(value) || FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator || '')) {
|
|
169
|
-
filterSchemaItem[filterKey] = value;
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (0 === value.length) return void delete filterSchemaItem[filterKey];
|
|
173
|
-
let branchEndIndex = -1;
|
|
174
|
-
for(let index = pathParts.length - 2; index >= 0; index--)if ([
|
|
175
|
-
'$and',
|
|
176
|
-
'$or'
|
|
177
|
-
].includes(pathParts[index]) && /^\d+$/.test(pathParts[index + 1])) {
|
|
178
|
-
branchEndIndex = index;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
const branchPath = branchEndIndex >= 0 ? pathParts.slice(0, branchEndIndex + 2).join('.') : '';
|
|
182
|
-
const fieldPath = pathParts.slice(branchEndIndex + 2).join('.');
|
|
183
|
-
const conditions = value.map((item)=>customFlat.unflatten({
|
|
184
|
-
["".concat(fieldPath, ".").concat(operator)]: item
|
|
185
|
-
}));
|
|
186
|
-
delete filterSchemaItem[filterKey];
|
|
187
|
-
filterSchemaItem[branchPath ? "".concat(branchPath, ".$or") : '$or'] = conditions;
|
|
188
|
-
};
|
|
189
|
-
const getCustomCondition = function(filter, fieldSchema) {
|
|
190
|
-
let customFlat = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : flat;
|
|
191
|
-
var _filterSchema_$and, _filterSchema_$or;
|
|
192
|
-
const filterSchema = fieldSchema ? fieldSchema['x-filter-rules'] : '';
|
|
193
|
-
const filterSchemaItem = customFlat(filterSchema || '');
|
|
194
|
-
const items = customFlat(filter || {});
|
|
195
|
-
const isCustomFilter = (null == filterSchema ? void 0 : null == (_filterSchema_$and = filterSchema.$and) ? void 0 : _filterSchema_$and.length) || (null == filterSchema ? void 0 : null == (_filterSchema_$or = filterSchema.$or) ? void 0 : _filterSchema_$or.length);
|
|
196
|
-
const isFilterCustom = isCustomFilter ? hasDuplicateKeys(items, filterSchemaItem) : false;
|
|
197
|
-
if (isFilterCustom) return customFlat.unflatten(items);
|
|
198
|
-
if (!isCustomFilter) return customFlat.unflatten({});
|
|
199
|
-
{
|
|
200
|
-
var _flatFieldSchema_$and, _flatFieldSchema_$or;
|
|
201
|
-
for(const filterKey in filterSchemaItem){
|
|
202
|
-
const match = 'string' == typeof filterSchemaItem[filterKey] && filterSchemaItem[filterKey].match(CUSTOM_FILTER_VARIABLE_REGEXP);
|
|
203
|
-
if (!match) continue;
|
|
204
|
-
const customFieldSchema = findCustomFieldSchema(fieldSchema, match[1]);
|
|
205
|
-
expandArrayValueFilter(filterSchemaItem, filterKey, getCustomFilterValue(items, match[1], filter || {}), customFlat, {
|
|
206
|
-
useDefaultDateBoundary: shouldUseDefaultDateBoundary(customFieldSchema),
|
|
207
|
-
component: getDatePickerComponent(customFieldSchema),
|
|
208
|
-
showTime: getDatePickerShowTime(customFieldSchema)
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
for(const item in filterSchemaItem)if (!filterSchemaItem[item] || filterSchemaItem[item].includes('$nFilter')) delete filterSchemaItem[item];
|
|
212
|
-
const flatFieldSchema = customFlat.unflatten(filterSchemaItem);
|
|
213
|
-
flatFieldSchema['$and'] = null == flatFieldSchema ? void 0 : null == (_flatFieldSchema_$and = flatFieldSchema['$and']) ? void 0 : _flatFieldSchema_$and.filter(Boolean);
|
|
214
|
-
flatFieldSchema['$or'] = null == flatFieldSchema ? void 0 : null == (_flatFieldSchema_$or = flatFieldSchema['$or']) ? void 0 : _flatFieldSchema_$or.filter(Boolean);
|
|
215
|
-
return flatFieldSchema;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
const removeNullCondition = function(filter) {
|
|
219
|
-
let customFlat = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : flat;
|
|
220
|
-
const items = customFlat(filter || {});
|
|
221
|
-
const values = {};
|
|
222
|
-
for(const key in items){
|
|
223
|
-
const value = items[key];
|
|
224
|
-
if (null != value && !isEmpty(value)) values[key] = value;
|
|
225
|
-
}
|
|
226
|
-
for (const key of Object.keys(values))if (key.endsWith('$dateBetween.0')) {
|
|
227
|
-
const key1 = key.replace(/\$dateBetween\.0$/, '$dateBetween.1');
|
|
228
|
-
if (!(key1 in values)) values[key1] = values[key];
|
|
229
|
-
} else if (key.endsWith('$dateBetween.1')) {
|
|
230
|
-
const key0 = key.replace(/\$dateBetween\.1$/, '$dateBetween.0');
|
|
231
|
-
if (!(key0 in values)) values[key0] = values[key];
|
|
232
|
-
}
|
|
233
|
-
return customFlat.unflatten(values);
|
|
234
|
-
};
|
|
235
57
|
const useFilterActionProps = ()=>{
|
|
236
58
|
const { name } = useCollection_deprecated();
|
|
237
59
|
const options = useFilterOptions(name);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useFieldSchema } from "@tachybase/schema";
|
|
2
|
+
import { useCollectionManager_deprecated } from "../../../collection-manager/index.mjs";
|
|
3
|
+
const useGetFilterFieldOptions = ()=>{
|
|
4
|
+
var _fieldSchema_xcomponentprops;
|
|
5
|
+
const fieldSchema = useFieldSchema();
|
|
6
|
+
const nonfilterable = (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.nonfilterable) || [];
|
|
7
|
+
const { getCollectionFields, getInterface } = useCollectionManager_deprecated();
|
|
8
|
+
const field2option = (field, depth)=>{
|
|
9
|
+
var _field_uiSchema, _operators_filter;
|
|
10
|
+
if (nonfilterable.length && 1 === depth && nonfilterable.includes(field.name)) return;
|
|
11
|
+
if (!field.interface) return;
|
|
12
|
+
const fieldInterface = getInterface(field.interface);
|
|
13
|
+
if (!(null == fieldInterface ? void 0 : fieldInterface.filterable)) return;
|
|
14
|
+
const { nested, children, operators } = fieldInterface.filterable;
|
|
15
|
+
const option = {
|
|
16
|
+
name: field.name,
|
|
17
|
+
type: field.type,
|
|
18
|
+
target: field.target,
|
|
19
|
+
title: (null == field ? void 0 : null == (_field_uiSchema = field.uiSchema) ? void 0 : _field_uiSchema.title) || field.name,
|
|
20
|
+
schema: null == field ? void 0 : field.uiSchema,
|
|
21
|
+
interface: field.interface,
|
|
22
|
+
operators: (null == operators ? void 0 : null == (_operators_filter = operators.filter) ? void 0 : _operators_filter.call(operators, (operator)=>!(null == operator ? void 0 : operator.visible) || operator.visible(field))) || []
|
|
23
|
+
};
|
|
24
|
+
if (field.target && depth > 2) return;
|
|
25
|
+
if (depth > 2) return option;
|
|
26
|
+
if (null == children ? void 0 : children.length) option['children'] = children;
|
|
27
|
+
if (nested) {
|
|
28
|
+
const targetFields = getCollectionFields(field.target);
|
|
29
|
+
const options = getOptions(targetFields, depth + 1).filter(Boolean);
|
|
30
|
+
option['children'] = option['children'] || [];
|
|
31
|
+
option['children'].push(...options);
|
|
32
|
+
}
|
|
33
|
+
return option;
|
|
34
|
+
};
|
|
35
|
+
const getOptions = (fields, depth)=>{
|
|
36
|
+
const options = [];
|
|
37
|
+
fields.forEach((field)=>{
|
|
38
|
+
const option = field2option(field, depth);
|
|
39
|
+
if (option) options.push(option);
|
|
40
|
+
});
|
|
41
|
+
return options;
|
|
42
|
+
};
|
|
43
|
+
return (fields)=>getOptions(fields, 1);
|
|
44
|
+
};
|
|
45
|
+
const useGetFilterOptions = ()=>{
|
|
46
|
+
const { getCollectionFields } = useCollectionManager_deprecated();
|
|
47
|
+
const getFilterFieldOptions = useGetFilterFieldOptions();
|
|
48
|
+
return (collectionName, dataSource)=>{
|
|
49
|
+
const fields = getCollectionFields(collectionName, dataSource);
|
|
50
|
+
const options = getFilterFieldOptions(fields);
|
|
51
|
+
return options;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export { useGetFilterFieldOptions, useGetFilterOptions };
|
|
@@ -3,11 +3,11 @@ import { createContext, useContext, useEffect, useMemo } from "react";
|
|
|
3
3
|
import { FieldContext, FormContext, RecursionField, createForm, observer, useField, useFieldSchema } from "@tachybase/schema";
|
|
4
4
|
import { FormLayout } from "@tego/client";
|
|
5
5
|
import { ConfigProvider, Spin } from "antd";
|
|
6
|
-
import { useAttach, useComponent } from "../../index.mjs";
|
|
7
6
|
import { useRequest } from "../../../api-client/index.mjs";
|
|
8
7
|
import { useCollection_deprecated } from "../../../collection-manager/index.mjs";
|
|
9
8
|
import { GeneralSchemaDesigner, SchemaSettingsDivider, SchemaSettingsRemove, SchemaSettingsTemplate } from "../../../schema-settings/index.mjs";
|
|
10
9
|
import { useSchemaTemplate } from "../../../schema-templates/index.mjs";
|
|
10
|
+
import { useAttach, useComponent } from "../../hooks/index.mjs";
|
|
11
11
|
const FormComponent = (props)=>{
|
|
12
12
|
const { form, children, ...others } = props;
|
|
13
13
|
const field = useField();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { GeneralSchemaDesigner } from "../../../schema-settings/
|
|
3
|
+
import { GeneralSchemaDesigner } from "../../../schema-settings/GeneralSchemaDesigner.mjs";
|
|
4
4
|
const FilterFormDesigner = ()=>/*#__PURE__*/ jsx(GeneralSchemaDesigner, {
|
|
5
5
|
schemaSettings: "FilterFormItemSettings"
|
|
6
6
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Collection_deprecated } from '../../../collection-manager';
|
|
1
|
+
import { Collection_deprecated } from '../../../collection-manager/hooks/useCollection_deprecated';
|
|
2
2
|
export declare const FormItem: {
|
|
3
3
|
(props: any): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
@@ -4,19 +4,20 @@ import { useField, useFieldSchema } from "@tachybase/schema";
|
|
|
4
4
|
import { FormItem } from "@tego/client";
|
|
5
5
|
import { createStyles } from "antd-style";
|
|
6
6
|
import classnames from "classnames";
|
|
7
|
-
import { useApp } from "../../../application/
|
|
7
|
+
import { useApp } from "../../../application/hooks/useApp.mjs";
|
|
8
8
|
import { useFormActiveFields } from "../../../block-provider/hooks/useFormActiveFields.mjs";
|
|
9
|
-
import { ACLCollectionFieldProvider } from "../../../built-in/acl/
|
|
10
|
-
import { CollectionFieldProvider
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { ACLCollectionFieldProvider } from "../../../built-in/acl/ACLCollectionFieldProvider.mjs";
|
|
10
|
+
import { CollectionFieldProvider } from "../../../data-source/collection-field/CollectionFieldProvider.mjs";
|
|
11
|
+
import { useContextConfigSetting } from "../../../data-source/data-block/context/ConfigSetting.provider.mjs";
|
|
12
|
+
import { GeneralSchemaDesigner } from "../../../schema-settings/GeneralSchemaDesigner.mjs";
|
|
13
13
|
import useContextVariable from "../../../variables/hooks/useContextVariable.mjs";
|
|
14
|
-
import
|
|
14
|
+
import useVariables from "../../../variables/hooks/useVariables.mjs";
|
|
15
|
+
import { BlockItem } from "../block-item/BlockItem.mjs";
|
|
15
16
|
import { HTMLEncode } from "../input/shared.mjs";
|
|
16
17
|
import { FilterFormDesigner } from "./FormItem.FilterFormDesigner.mjs";
|
|
17
18
|
import useLazyLoadDisplayAssociationFieldsOfForm from "./hooks/useLazyLoadDisplayAssociationFieldsOfForm.mjs";
|
|
18
19
|
import useParseDefaultValue from "./hooks/useParseDefaultValue.mjs";
|
|
19
|
-
import { useEnsureOperatorsValid } from "./
|
|
20
|
+
import { useEnsureOperatorsValid } from "./operatorUtils.mjs";
|
|
20
21
|
function _tagged_template_literal(strings, raw) {
|
|
21
22
|
if (!raw) raw = strings.slice(0);
|
|
22
23
|
return Object.freeze(Object.defineProperties(strings, {
|
|
@@ -109,16 +110,17 @@ const FormItem_FormItem = (props)=>{
|
|
|
109
110
|
}), [
|
|
110
111
|
showTitle
|
|
111
112
|
]);
|
|
113
|
+
const item = /*#__PURE__*/ jsx(FormItem, {
|
|
114
|
+
className: className,
|
|
115
|
+
...props,
|
|
116
|
+
extra: extra
|
|
117
|
+
});
|
|
112
118
|
return /*#__PURE__*/ jsx(CollectionFieldProvider, {
|
|
113
119
|
allowNull: true,
|
|
114
120
|
children: /*#__PURE__*/ jsx(BlockItem, {
|
|
115
121
|
className: 'tb-form-item',
|
|
116
122
|
children: /*#__PURE__*/ jsx(ACLCollectionFieldProvider, {
|
|
117
|
-
children:
|
|
118
|
-
className: className,
|
|
119
|
-
...props,
|
|
120
|
-
extra: extra
|
|
121
|
-
})
|
|
123
|
+
children: item
|
|
122
124
|
})
|
|
123
125
|
})
|
|
124
126
|
});
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const findFilterOperators: (schema: Schema) => {
|
|
3
|
-
operators: any;
|
|
4
|
-
uid: any;
|
|
5
|
-
} | {
|
|
6
|
-
operators?: undefined;
|
|
7
|
-
uid?: undefined;
|
|
8
|
-
};
|
|
9
|
-
export declare const getDefaultFilterOperatorValue: (schema: Schema, operatorList?: any[]) => any;
|
|
1
|
+
export { findFilterOperators, getDefaultFilterOperatorValue, useEnsureOperatorsValid } from './operatorUtils';
|
|
10
2
|
export declare const EditTitle: () => import("react/jsx-runtime").JSX.Element;
|
|
11
3
|
export declare const EditDescription: () => import("react/jsx-runtime").JSX.Element;
|
|
12
4
|
export declare const EditTooltip: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,10 +7,5 @@ export declare const EditValidationRules: () => import("react/jsx-runtime").JSX.
|
|
|
15
7
|
export declare const EditDefaultValue: () => import("react/jsx-runtime").JSX.Element;
|
|
16
8
|
export declare const EditComponent: () => import("react/jsx-runtime").JSX.Element;
|
|
17
9
|
export declare const EditPattern: () => import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
/**
|
|
19
|
-
* 如果用户没有手动设置过 operator,那么在筛选的时候 operator 会是空的,
|
|
20
|
-
* 该方法确保 operator 一定有值(需要在 FormItem 中调用)
|
|
21
|
-
*/
|
|
22
|
-
export declare const useEnsureOperatorsValid: () => void;
|
|
23
10
|
export declare const EditOperator: () => import("react/jsx-runtime").JSX.Element;
|
|
24
11
|
export declare const EditTitleField: () => import("react/jsx-runtime").JSX.Element;
|