@tachybase/client 1.6.21 → 1.6.23

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 (191) hide show
  1. package/es/api-client/APIClient.d.ts +2 -1
  2. package/es/api-client/APIClient.mjs +6 -3
  3. package/es/application/Plugin.d.ts +2 -2
  4. package/es/application/hoc/withDynamicSchemaProps.mjs +1 -1
  5. package/es/application/schema-initializer/hooks/index.mjs +4 -1
  6. package/es/application/schema-settings/components/SchemaSettingsChildren.mjs +14 -14
  7. package/es/application/utils/clientModuleRegistry.d.ts +2 -0
  8. package/es/application/utils/clientModuleRegistry.mjs +9 -0
  9. package/es/application/utils/globalDeps.mjs +2 -2
  10. package/es/block-provider/BlockProvider.d.ts +1 -27
  11. package/es/block-provider/BlockProvider.mjs +1 -3
  12. package/es/block-provider/BlockRequestContext.d.ts +27 -0
  13. package/es/block-provider/BlockRequestContext.mjs +5 -0
  14. package/es/block-provider/FormBlockContext.d.ts +32 -0
  15. package/es/block-provider/FormBlockContext.mjs +5 -0
  16. package/es/block-provider/FormBlockProvider.d.ts +1 -33
  17. package/es/block-provider/FormBlockProvider.mjs +4 -5
  18. package/es/built-in/acl/ACLCollectionFieldProvider.d.ts +1 -0
  19. package/es/built-in/acl/ACLCollectionFieldProvider.mjs +42 -0
  20. package/es/built-in/acl/ACLContext.d.ts +9 -0
  21. package/es/built-in/acl/ACLContext.mjs +24 -0
  22. package/es/built-in/acl/ACLPlugin.mjs +2 -1
  23. package/es/built-in/acl/ACLProvider.d.ts +0 -11
  24. package/es/built-in/acl/ACLProvider.mjs +6 -51
  25. package/es/built-in/acl/index.d.ts +2 -0
  26. package/es/built-in/acl/index.mjs +2 -0
  27. package/es/built-in/locale/LocalePlugin.d.ts +2 -0
  28. package/es/built-in/locale/LocalePlugin.mjs +13 -4
  29. package/es/collection-manager/hooks/useCollectionManager_deprecated.mjs +2 -1
  30. package/es/collection-manager/sub-table.d.ts +1 -1
  31. package/es/data-source/data-source/DataSourceManager.d.ts +1 -2
  32. package/es/data-source/data-source/DataSourceManager.mjs +1 -2
  33. package/es/data-source/data-source/constants.d.ts +2 -0
  34. package/es/data-source/data-source/constants.mjs +3 -0
  35. package/es/data-source/utils.d.ts +2 -2
  36. package/es/data-source/utils.mjs +1 -1
  37. package/es/exports.d.ts +46 -0
  38. package/es/exports.mjs +46 -0
  39. package/es/filter-provider/utils.d.ts +2 -14
  40. package/es/filter-provider/utils.mjs +2 -57
  41. package/es/index.d.ts +1 -46
  42. package/es/index.mjs +4 -46
  43. package/es/modules/fields/component/SubTable/subTablePopoverComponentFieldSettings.d.ts +2 -86
  44. package/es/record-provider/index.mjs +3 -3
  45. package/es/schema-component/antd/action/Action.mjs +7 -6
  46. package/es/schema-component/antd/action/hooks.mjs +3 -2
  47. package/es/schema-component/antd/association-field/AssociationSelect.mjs +4 -3
  48. package/es/schema-component/antd/association-field/hooks.mjs +18 -1
  49. package/es/schema-component/antd/cron/CronSet.mjs +9 -3
  50. package/es/schema-component/antd/filter/conditionUtils.d.ts +2 -0
  51. package/es/schema-component/antd/filter/conditionUtils.mjs +133 -0
  52. package/es/schema-component/antd/filter/dateValueUtils.d.ts +13 -0
  53. package/es/schema-component/antd/filter/dateValueUtils.mjs +66 -0
  54. package/es/schema-component/antd/filter/useFilterActionProps.d.ts +2 -4
  55. package/es/schema-component/antd/filter/useFilterActionProps.mjs +3 -181
  56. package/es/schema-component/antd/filter/useGetFilterOptions.d.ts +2 -0
  57. package/es/schema-component/antd/filter/useGetFilterOptions.mjs +54 -0
  58. package/es/schema-component/antd/form/Form.mjs +1 -1
  59. package/es/schema-component/antd/form-item/FormItem.FilterFormDesigner.mjs +1 -1
  60. package/es/schema-component/antd/form-item/FormItem.d.ts +1 -1
  61. package/es/schema-component/antd/form-item/FormItem.mjs +14 -12
  62. package/es/schema-component/antd/form-item/SchemaSettingOptions.d.ts +1 -14
  63. package/es/schema-component/antd/form-item/SchemaSettingOptions.mjs +1 -33
  64. package/es/schema-component/antd/form-item/hooks/useLazyLoadDisplayAssociationFieldsOfForm.mjs +4 -3
  65. package/es/schema-component/antd/form-item/hooks/useParseDefaultValue.mjs +5 -3
  66. package/es/schema-component/antd/form-item/operatorUtils.d.ts +14 -0
  67. package/es/schema-component/antd/form-item/operatorUtils.mjs +36 -0
  68. package/es/schema-component/antd/form-v2/Form.mjs +26 -167
  69. package/es/schema-component/antd/form-v2/FormLinkageRules.d.ts +9 -0
  70. package/es/schema-component/antd/form-v2/FormLinkageRules.mjs +191 -0
  71. package/es/schema-component/antd/form-v2/Templates.mjs +1 -1
  72. package/es/schema-component/antd/grid/Grid.mjs +5 -2
  73. package/es/schema-component/antd/grid-card/GridCard.Item.mjs +2 -2
  74. package/es/schema-component/antd/icon-picker/IconFilterInput.mjs +12 -4
  75. package/es/schema-component/antd/icon-picker/IconPicker.mjs +1 -1
  76. package/es/schema-component/antd/input/Json.d.ts +1 -4
  77. package/es/schema-component/antd/input/ReadPretty.mjs +2 -2
  78. package/es/schema-component/antd/input-number/ReadPretty.mjs +1 -1
  79. package/es/schema-component/antd/markdown/Markdown.Void.Designer.mjs +2 -1
  80. package/es/schema-component/antd/markdown/Markdown.Void.mjs +10 -2
  81. package/es/schema-component/antd/markdown/Markdown.mjs +1 -1
  82. package/es/schema-component/antd/markdown/util.mjs +5 -0
  83. package/es/schema-component/antd/rich-text/RichText.mjs +1 -1
  84. package/es/schema-component/antd/select/FormulaSelect.mjs +1 -2
  85. package/es/schema-component/antd/select/ReadPretty.mjs +2 -2
  86. package/es/schema-component/antd/select/Select.mjs +1 -2
  87. package/es/schema-component/antd/select/utils.d.ts +2 -1
  88. package/es/schema-component/antd/select/utils.mjs +2 -2
  89. package/es/schema-component/antd/time-picker/ReadPretty.mjs +1 -1
  90. package/es/schema-component/antd/upload/ReadPretty.mjs +5 -5
  91. package/es/schema-component/antd/upload/Upload.mjs +6 -5
  92. package/es/schema-component/antd/variable/Input.mjs +1 -1
  93. package/es/schema-component/antd/variable/TextArea.mjs +1 -1
  94. package/es/schema-component/hooks/useDesigner.mjs +9 -3
  95. package/es/schema-component/hooks/useOptionalNavigate.d.ts +1 -0
  96. package/es/schema-component/hooks/useOptionalNavigate.mjs +2 -0
  97. package/es/schema-settings/DataTemplates/components/Designer.mjs +2 -1
  98. package/es/schema-settings/VariableInput/hooks/useBaseVariable.mjs +2 -1
  99. package/es/schema-settings/VariableInput/hooks/useBlockCollection.mjs +1 -1
  100. package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.mjs +2 -1
  101. package/es/schema-settings/VariableInput/hooks/useFormVariable.mjs +1 -1
  102. package/es/schema-settings/VariableInput/hooks/useRecordVariable.mjs +1 -1
  103. package/es/style/theme/AntdAppProvider.mjs +2 -2
  104. package/es/user/ChangePassword.d.ts +4 -1
  105. package/es/user/CurrentUserContext.d.ts +2 -0
  106. package/es/user/CurrentUserContext.mjs +5 -0
  107. package/es/user/CurrentUserProvider.d.ts +0 -3
  108. package/es/user/CurrentUserProvider.mjs +3 -5
  109. package/es/user/EditProfile.d.ts +4 -1
  110. package/es/user/LanguageSettings.d.ts +4 -1
  111. package/es/user/SwitchRole.d.ts +4 -1
  112. package/es/user/index.d.ts +1 -0
  113. package/es/user/index.mjs +1 -0
  114. package/es/variables/VariablesProvider.mjs +1 -1
  115. package/lib/api-client/APIClient.js +8 -5
  116. package/lib/application/hoc/withDynamicSchemaProps.js +3 -3
  117. package/lib/application/schema-initializer/hooks/index.js +4 -1
  118. package/lib/application/schema-settings/components/SchemaSettingsChildren.js +14 -14
  119. package/lib/application/utils/clientModuleRegistry.js +46 -0
  120. package/lib/application/utils/globalDeps.js +2 -2
  121. package/lib/block-provider/BlockProvider.js +6 -8
  122. package/lib/block-provider/BlockRequestContext.js +42 -0
  123. package/lib/block-provider/FormBlockContext.js +42 -0
  124. package/lib/block-provider/FormBlockProvider.js +13 -14
  125. package/lib/built-in/acl/ACLCollectionFieldProvider.js +76 -0
  126. package/lib/built-in/acl/ACLContext.js +70 -0
  127. package/lib/built-in/acl/ACLPlugin.js +2 -1
  128. package/lib/built-in/acl/ACLProvider.js +13 -76
  129. package/lib/built-in/acl/index.js +27 -9
  130. package/lib/built-in/locale/LocalePlugin.js +17 -5
  131. package/lib/collection-manager/hooks/useCollectionManager_deprecated.js +4 -3
  132. package/lib/data-source/data-source/DataSourceManager.js +6 -7
  133. package/lib/data-source/data-source/constants.js +40 -0
  134. package/lib/data-source/utils.js +2 -2
  135. package/lib/exports.js +769 -0
  136. package/lib/filter-provider/utils.js +7 -63
  137. package/lib/index.js +10 -714
  138. package/lib/record-provider/index.js +6 -6
  139. package/lib/schema-component/antd/action/Action.js +9 -8
  140. package/lib/schema-component/antd/action/hooks.js +3 -2
  141. package/lib/schema-component/antd/association-field/AssociationSelect.js +3 -2
  142. package/lib/schema-component/antd/association-field/hooks.js +18 -1
  143. package/lib/schema-component/antd/cron/CronSet.js +8 -2
  144. package/lib/schema-component/antd/filter/conditionUtils.js +180 -0
  145. package/lib/schema-component/antd/filter/dateValueUtils.js +116 -0
  146. package/lib/schema-component/antd/filter/useFilterActionProps.js +7 -186
  147. package/lib/schema-component/antd/filter/useGetFilterOptions.js +91 -0
  148. package/lib/schema-component/antd/form/Form.js +4 -4
  149. package/lib/schema-component/antd/form-item/FormItem.FilterFormDesigner.js +2 -2
  150. package/lib/schema-component/antd/form-item/FormItem.js +23 -20
  151. package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +6 -38
  152. package/lib/schema-component/antd/form-item/hooks/useLazyLoadDisplayAssociationFieldsOfForm.js +9 -7
  153. package/lib/schema-component/antd/form-item/hooks/useParseDefaultValue.js +12 -8
  154. package/lib/schema-component/antd/form-item/operatorUtils.js +76 -0
  155. package/lib/schema-component/antd/form-v2/Form.js +204 -317
  156. package/lib/schema-component/antd/form-v2/FormLinkageRules.js +236 -0
  157. package/lib/schema-component/antd/form-v2/Templates.js +2 -2
  158. package/lib/schema-component/antd/grid/Grid.js +10 -7
  159. package/lib/schema-component/antd/grid-card/GridCard.Item.js +2 -2
  160. package/lib/schema-component/antd/icon-picker/IconFilterInput.js +12 -4
  161. package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -1
  162. package/lib/schema-component/antd/input/ReadPretty.js +10 -10
  163. package/lib/schema-component/antd/input-number/ReadPretty.js +1 -1
  164. package/lib/schema-component/antd/markdown/Markdown.Void.Designer.js +6 -5
  165. package/lib/schema-component/antd/markdown/Markdown.Void.js +138 -111
  166. package/lib/schema-component/antd/markdown/Markdown.js +2 -2
  167. package/lib/schema-component/antd/markdown/util.js +5 -0
  168. package/lib/schema-component/antd/rich-text/RichText.js +2 -2
  169. package/lib/schema-component/antd/select/FormulaSelect.js +1 -2
  170. package/lib/schema-component/antd/select/ReadPretty.js +2 -2
  171. package/lib/schema-component/antd/select/Select.js +1 -2
  172. package/lib/schema-component/antd/select/utils.js +6 -3
  173. package/lib/schema-component/antd/time-picker/ReadPretty.js +2 -2
  174. package/lib/schema-component/antd/upload/ReadPretty.js +5 -5
  175. package/lib/schema-component/antd/upload/Upload.js +6 -5
  176. package/lib/schema-component/antd/variable/Input.js +1 -1
  177. package/lib/schema-component/antd/variable/TextArea.js +1 -1
  178. package/lib/schema-component/hooks/useDesigner.js +57 -23
  179. package/lib/schema-component/hooks/useOptionalNavigate.js +36 -0
  180. package/lib/schema-settings/DataTemplates/components/Designer.js +4 -3
  181. package/lib/schema-settings/VariableInput/hooks/useBaseVariable.js +4 -3
  182. package/lib/schema-settings/VariableInput/hooks/useBlockCollection.js +2 -2
  183. package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.js +4 -3
  184. package/lib/schema-settings/VariableInput/hooks/useFormVariable.js +2 -2
  185. package/lib/schema-settings/VariableInput/hooks/useRecordVariable.js +2 -2
  186. package/lib/style/theme/AntdAppProvider.js +4 -4
  187. package/lib/user/CurrentUserContext.js +42 -0
  188. package/lib/user/CurrentUserProvider.js +6 -14
  189. package/lib/user/index.js +24 -12
  190. package/lib/variables/VariablesProvider.js +2 -2
  191. package/package.json +5 -4
@@ -9,7 +9,7 @@ import { RecordProvider, useAPIClient, useApp, useCollectionRecordData } from ".
9
9
  import { isVariable } from "../../../variables/utils/isVariable.mjs";
10
10
  import { getInnermostKeyAndValue } from "../../common/utils/uitls.mjs";
11
11
  import { RemoteSelect } from "../remote-select/index.mjs";
12
- import hooks, { useAssociationFieldContext } from "./hooks.mjs";
12
+ import hooks, { useAssociationFieldContext, useFieldNames } from "./hooks.mjs";
13
13
  const filterAnalyses = (filters)=>{
14
14
  if (!filters) return;
15
15
  const type = Object.keys(filters)[0] || '$and';
@@ -41,6 +41,7 @@ const InternalAssociationSelect = observer((props)=>{
41
41
  const isAllowAddNew = fieldSchema['x-add-new'];
42
42
  const { t } = useTranslation();
43
43
  const { multiple } = props;
44
+ const fieldNames = useFieldNames(props);
44
45
  const form = useForm();
45
46
  const api = useAPIClient();
46
47
  const resource = api.resource(collectionField.target);
@@ -68,11 +69,10 @@ const InternalAssociationSelect = observer((props)=>{
68
69
  };
69
70
  }, []);
70
71
  const handleCreateAction = async (props)=>{
71
- var _field_componentProps_fieldNames, _field_componentProps;
72
72
  const { search: value, callBack } = props;
73
73
  const { data: { data } } = await resource.create({
74
74
  values: {
75
- [(null == field ? void 0 : null == (_field_componentProps = field.componentProps) ? void 0 : null == (_field_componentProps_fieldNames = _field_componentProps.fieldNames) ? void 0 : _field_componentProps_fieldNames.label) || 'id']: value
75
+ [fieldNames.label || 'id']: value
76
76
  }
77
77
  });
78
78
  if (data) {
@@ -121,6 +121,7 @@ const InternalAssociationSelect = observer((props)=>{
121
121
  width: '100%'
122
122
  },
123
123
  ...props,
124
+ fieldNames: fieldNames,
124
125
  size: 'middle',
125
126
  objectValue: objectValue,
126
127
  value: value || innerValue,
@@ -130,12 +130,29 @@ function useServiceOptions(props) {
130
130
  const useFieldNames = (props)=>{
131
131
  var _fieldSchema_xcomponentprops_field_uiSchema_xcomponentprops, _fieldSchema_xcomponentprops_field_uiSchema, _fieldSchema_xcomponentprops_field, _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
132
132
  const fieldSchema = useFieldSchema();
133
+ const { options: collectionField } = useAssociationFieldContext();
134
+ const { getCollection } = useCollectionManager_deprecated();
133
135
  const fieldNames = (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : null == (_fieldSchema_xcomponentprops_field = _fieldSchema_xcomponentprops['field']) ? void 0 : null == (_fieldSchema_xcomponentprops_field_uiSchema = _fieldSchema_xcomponentprops_field['uiSchema']) ? void 0 : null == (_fieldSchema_xcomponentprops_field_uiSchema_xcomponentprops = _fieldSchema_xcomponentprops_field_uiSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops_field_uiSchema_xcomponentprops['fieldNames']) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['fieldNames']) || props.fieldNames;
134
- return {
136
+ if (fieldNames) return {
135
137
  label: 'label',
136
138
  value: 'value',
137
139
  ...fieldNames
138
140
  };
141
+ if (null == collectionField ? void 0 : collectionField.target) {
142
+ const targetCollection = getCollection(collectionField.target);
143
+ if (targetCollection) {
144
+ var _targetCollection_getPrimaryKey;
145
+ const pk = targetCollection.filterTargetKey || (null == (_targetCollection_getPrimaryKey = targetCollection.getPrimaryKey) ? void 0 : _targetCollection_getPrimaryKey.call(targetCollection)) || 'id';
146
+ return {
147
+ label: targetCollection.titleField || pk,
148
+ value: pk
149
+ };
150
+ }
151
+ }
152
+ return {
153
+ label: 'label',
154
+ value: 'value'
155
+ };
139
156
  };
140
157
  const SubFormContext = createContext(null);
141
158
  SubFormContext.displayName = 'SubFormContext';
@@ -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, mapReadPretty(ReadPretty));
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,2 @@
1
+ export declare const getCustomCondition: any;
2
+ export declare const removeNullCondition: any;
@@ -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 declare const useGetFilterOptions: () => (collectionName: any, dataSource?: string) => any[];
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 { FILTER_OPERATORS_WITH_ARRAY_VALUES, mergeFilter, normalizeDateBetweenValue, shouldUseDefaultDateBoundary } from "../../../filter-provider/utils.mjs";
6
+ import { mergeFilter } from "../../../filter-provider/utils.mjs";
8
7
  import { useDataLoadingMode } from "../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem.mjs";
9
- import { resolveDatePickerRangeValueInfo } from "../date-picker/util.mjs";
10
- import { hasDuplicateKeys } from "./utils.mjs";
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,2 @@
1
+ export declare const useGetFilterFieldOptions: () => (fields: any) => any[];
2
+ export declare const useGetFilterOptions: () => (collectionName: any, dataSource?: string) => any[];
@@ -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/index.mjs";
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;