@tachybase/client 1.6.17 → 1.6.18

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 (27) hide show
  1. package/es/block-provider/hooks/index.mjs +2 -8
  2. package/es/data-source/data-block/DataBlockRequestProvider.mjs +5 -5
  3. package/es/filter-provider/utils.d.ts +6 -0
  4. package/es/filter-provider/utils.mjs +55 -16
  5. package/es/modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings.mjs +2 -3
  6. package/es/modules/fields/component/Nester/subformComponentFieldSettings.mjs +1 -2
  7. package/es/modules/fields/component/Picker/recordPickerComponentFieldSettings.mjs +2 -3
  8. package/es/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.mjs +1 -2
  9. package/es/modules/fields/component/Select/selectComponentFieldSettings.mjs +1 -2
  10. package/es/schema-component/antd/association-select/AssociationSelect.mjs +3 -3
  11. package/es/schema-component/antd/filter/useFilterActionProps.mjs +61 -7
  12. package/es/schema-component/antd/form-item/FormItem.Settings.mjs +1 -2
  13. package/es/schema-initializer/utils.d.ts +1 -0
  14. package/es/schema-initializer/utils.mjs +7 -6
  15. package/lib/block-provider/hooks/index.js +2 -8
  16. package/lib/data-source/data-block/DataBlockRequestProvider.js +5 -5
  17. package/lib/filter-provider/utils.js +60 -15
  18. package/lib/modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings.js +2 -3
  19. package/lib/modules/fields/component/Nester/subformComponentFieldSettings.js +1 -2
  20. package/lib/modules/fields/component/Picker/recordPickerComponentFieldSettings.js +2 -3
  21. package/lib/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.js +1 -2
  22. package/lib/modules/fields/component/Select/selectComponentFieldSettings.js +1 -2
  23. package/lib/schema-component/antd/association-select/AssociationSelect.js +3 -3
  24. package/lib/schema-component/antd/filter/useFilterActionProps.js +60 -6
  25. package/lib/schema-component/antd/form-item/FormItem.Settings.js +1 -2
  26. package/lib/schema-initializer/utils.js +9 -5
  27. package/package.json +1 -1
@@ -424,7 +424,6 @@ const useFilterBlockActionProps = ()=>{
424
424
  async onClick () {
425
425
  const { targets = [], uid } = findFilterTargets(fieldSchema);
426
426
  actionField.data.loading = true;
427
- let prevMergedFilter = {};
428
427
  try {
429
428
  await Promise.all(getDataBlocks().map(async (block)=>{
430
429
  var _block_service_params, _block_service_params_, _block_service_params1, _Object_keys;
@@ -461,11 +460,9 @@ const useFilterBlockActionProps = ()=>{
461
460
  ...Object.values(storedFilter).map((filter)=>removeNullCondition(filter)),
462
461
  getFilterSourceDefaultFilter(getDataBlocks(), uid),
463
462
  block.defaultFilter,
464
- filter.customFilter,
465
- prevMergedFilter
463
+ filter.customFilter
466
464
  ]);
467
465
  const currFilter = filterByCleanedFields(mergedFilter);
468
- prevMergedFilter = currFilter;
469
466
  if ('manual' === block.dataLoadingMode && lodash.isEmpty(currFilter)) return block.clearData();
470
467
  return block.doFilter({
471
468
  ...param,
@@ -493,7 +490,6 @@ const useResetBlockActionProps = ()=>{
493
490
  const { targets, uid } = findFilterTargets(fieldSchema);
494
491
  form.reset();
495
492
  actionField.data.loading = true;
496
- let prevMergedFilter = {};
497
493
  try {
498
494
  await Promise.all(getDataBlocks().map(async (block)=>{
499
495
  var _block_service_params, _block_service_params_, _block_service_params1;
@@ -506,11 +502,9 @@ const useResetBlockActionProps = ()=>{
506
502
  const currFilter = utils_mjs_mergeFilter([
507
503
  ...Object.values(storedFilter),
508
504
  getFilterSourceDefaultFilter(getDataBlocks(), uid),
509
- block.defaultFilter,
510
- prevMergedFilter
505
+ block.defaultFilter
511
506
  ]);
512
507
  const mergedFilter = filterByCleanedFields(currFilter);
513
- prevMergedFilter = mergedFilter;
514
508
  return block.doFilter({
515
509
  ...param,
516
510
  page: 1,
@@ -52,14 +52,14 @@ function useParentRequest(options) {
52
52
  if (parentRecord) return Promise.resolve({
53
53
  data: parentRecord
54
54
  });
55
- if (!association || !sourceKey) return Promise.resolve({
55
+ if (!association || !sourceKey || null == sourceId) return Promise.resolve({
56
56
  data: void 0
57
57
  });
58
58
  const arr = association.split('.');
59
- const url = "".concat(arr[0], ":get?filter[").concat(sourceKey, "]=").concat(sourceId);
60
- const res = await api.request({
61
- url,
62
- headers
59
+ const res = await api.resource(arr[0], void 0, headers).get({
60
+ filter: {
61
+ [sourceKey]: sourceId
62
+ }
63
63
  });
64
64
  return res.data;
65
65
  }, {
@@ -21,6 +21,11 @@ export declare const getSupportFieldsByForeignKey: (filterBlockCollection: Retur
21
21
  * @returns
22
22
  */
23
23
  export declare const useSupportedBlocks: (filterBlockType: FilterBlockType) => DataBlock[];
24
+ type NormalizeDateBetweenOptions = {
25
+ useDefaultDateBoundary?: boolean;
26
+ };
27
+ export declare const normalizeDateBetweenValue: (value: any[], options?: NormalizeDateBetweenOptions) => any[];
28
+ export declare const shouldUseDefaultDateBoundary: (fieldSchema?: any) => boolean;
24
29
  export declare const transformToFilter: (values: Record<string, any>, fieldSchema: Schema, getCollectionJoinField: (name: string) => CollectionFieldOptions_deprecated, collectionName: string, getOperatorList?: (path: string, options: {
25
30
  fieldSchema?: Schema;
26
31
  collectionField?: CollectionFieldOptions_deprecated;
@@ -49,3 +54,4 @@ export declare const useFilterAPI: () => {
49
54
  doFilter: (value: any, field?: string | ((target: FilterTarget["targets"][0]) => string), operator?: string | ((target: FilterTarget["targets"][0]) => string)) => void;
50
55
  };
51
56
  export declare const isInFilterFormBlock: (fieldSchema: Schema) => boolean;
57
+ export {};
@@ -62,6 +62,7 @@ const findSchemaByName = (schema, name)=>{
62
62
  if (schema.name === name) return schema;
63
63
  const properties = schema.properties || {};
64
64
  for (const key of Object.keys(properties)){
65
+ if (key === name) return properties[key];
65
66
  const found = findSchemaByName(properties[key], name);
66
67
  if (found) return found;
67
68
  }
@@ -87,6 +88,54 @@ const resolveFilterOperator = function(schema, path) {
87
88
  if (!operatorList.length || !fieldSchema) return;
88
89
  return getDefaultFilterOperatorValue(fieldSchema, operatorList);
89
90
  };
91
+ const isDateOnlyString = (value)=>'string' == typeof value && /^\d{4}-\d{2}-\d{2}$/.test(value);
92
+ const hasExplicitTime = (value)=>'string' == typeof value && /[T\s]\d{2}:\d{2}/.test(value);
93
+ const isDefaultDateBoundaryValue = (value, boundary)=>{
94
+ if (isDateOnlyString(value)) return true;
95
+ if ('string' != typeof value) return false;
96
+ const match = value.match(/^\d{4}-\d{2}-\d{2}[T\s](\d{2}:\d{2}:\d{2})(?:\.\d{3})?(?:Z|[+-]\d\d:\d\d)?$/);
97
+ if (!match) return false;
98
+ return 'start' === boundary ? '00:00:00' === match[1] : '23:59:59' === match[1];
99
+ };
100
+ const normalizeDefaultDateBoundaryInput = (value)=>{
101
+ if ('string' != typeof value) return value;
102
+ return value.replace(/Z$/, '').replace(/[+-]\d\d:\d\d$/, '');
103
+ };
104
+ const normalizeDateBetweenBoundary = function(value, boundary) {
105
+ let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
106
+ const rawValue = options.useDefaultDateBoundary ? normalizeDefaultDateBoundaryInput(value) : value;
107
+ const m = dayjs(rawValue);
108
+ if (!m.isValid()) return value;
109
+ if (!options.useDefaultDateBoundary && hasExplicitTime(rawValue) && !isDateOnlyString(rawValue)) return m.toISOString();
110
+ return ('start' === boundary ? m.startOf('day') : m.endOf('day')).toISOString();
111
+ };
112
+ const shouldApplyDefaultDateBoundary = function(start, end) {
113
+ let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
114
+ if (!options.useDefaultDateBoundary) return false;
115
+ if (isDateOnlyString(start) || isDateOnlyString(end)) return true;
116
+ return isDefaultDateBoundaryValue(start, 'start') && isDefaultDateBoundaryValue(end, 'end');
117
+ };
118
+ const normalizeDateBetweenValue = function(value) {
119
+ let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
120
+ const normalized = value.filter(Boolean);
121
+ if (0 === normalized.length) return null;
122
+ const start = normalized[0];
123
+ const end = 1 === normalized.length ? normalized[0] : normalized[normalized.length - 1];
124
+ const boundaryOptions = {
125
+ ...options,
126
+ useDefaultDateBoundary: shouldApplyDefaultDateBoundary(start, end, options)
127
+ };
128
+ return [
129
+ normalizeDateBetweenBoundary(start, 'start', boundaryOptions),
130
+ normalizeDateBetweenBoundary(end, 'end', boundaryOptions)
131
+ ];
132
+ };
133
+ const shouldUseDefaultDateBoundary = (fieldSchema)=>{
134
+ var _fieldSchema_xcomponentprops;
135
+ if (!fieldSchema) return false;
136
+ const component = fieldSchema['x-component'] || (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
137
+ return 'DatePicker.RangePicker' === component;
138
+ };
90
139
  const transformToFilter = (values, fieldSchema, getCollectionJoinField, collectionName, getOperatorList)=>{
91
140
  const { operators } = findFilterOperators(fieldSchema);
92
141
  values = flatten(values, {
@@ -108,6 +157,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
108
157
  const defKey = key;
109
158
  let value = lodash.get(values, key);
110
159
  const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(key));
160
+ const currentFieldSchema = findSchemaByName(getFilterSchemaRoot(fieldSchema), defKey);
111
161
  const operator = resolveFilterOperator(fieldSchema, defKey, operators, getOperatorList, collectionField);
112
162
  if (null == collectionField ? void 0 : collectionField.target) {
113
163
  value = getValuesByPath(value, collectionField.targetKey || 'id');
@@ -127,21 +177,10 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
127
177
  };
128
178
  } else if ('$dateBetween' === operator) {
129
179
  if (Array.isArray(value)) {
130
- const normalized = [];
131
- for(const index in value){
132
- if (!value[index]) continue;
133
- let v = value[index];
134
- if ('string' != typeof v && !(v instanceof Date)) v = dayjs(v).toISOString();
135
- normalized.push(v);
136
- }
137
- if (0 === normalized.length) return null;
138
- value = 1 === normalized.length ? [
139
- normalized[0],
140
- normalized[0]
141
- ] : [
142
- normalized[0],
143
- normalized[normalized.length - 1]
144
- ];
180
+ value = normalizeDateBetweenValue(value, {
181
+ useDefaultDateBoundary: shouldUseDefaultDateBoundary(currentFieldSchema)
182
+ });
183
+ if (!value) return null;
145
184
  }
146
185
  }
147
186
  return {
@@ -231,4 +270,4 @@ const isInFilterFormBlock = (fieldSchema)=>{
231
270
  }
232
271
  return false;
233
272
  };
234
- export { FILTER_OPERATORS_WITH_ARRAY_VALUES, utils_FilterBlockType as FilterBlockType, getSupportFieldsByAssociation, getSupportFieldsByForeignKey, isAssocField, isInFilterFormBlock, isSameCollection, mergeFilter, transformToFilter, useAssociatedFields, useFilterAPI, useSupportedBlocks };
273
+ export { FILTER_OPERATORS_WITH_ARRAY_VALUES, utils_FilterBlockType as FilterBlockType, getSupportFieldsByAssociation, getSupportFieldsByForeignKey, isAssocField, isInFilterFormBlock, isSameCollection, mergeFilter, normalizeDateBetweenValue, shouldUseDefaultDateBoundary, transformToFilter, useAssociatedFields, useFilterAPI, useSupportedBlocks };
@@ -20,14 +20,13 @@ const allowMultiple = {
20
20
  ].includes(null == collectionField ? void 0 : collectionField.type);
21
21
  },
22
22
  useComponentProps () {
23
- var _fieldSchema_xcomponentprops;
24
23
  const { t } = useTranslation();
25
24
  const field = useField();
26
25
  const fieldSchema = useFieldSchema();
27
26
  const { dn, refresh } = useDesignable();
28
27
  return {
29
28
  title: t('Allow multiple'),
30
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
29
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
31
30
  onChange (value) {
32
31
  const schema = {
33
32
  ['x-uid']: fieldSchema['x-uid']
@@ -126,7 +125,7 @@ const drawerSubTableComponentFieldSettings = new SchemaSettings({
126
125
  value: 'large'
127
126
  }
128
127
  ],
129
- value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) == 'modal' ? 'large' : 'middle',
128
+ value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) === 'modal' ? 'large' : 'middle',
130
129
  onChange: (value)=>{
131
130
  field.componentProps.openSize = value;
132
131
  fieldSchema['x-component-props'] = {
@@ -19,14 +19,13 @@ const allowMultiple = {
19
19
  ].includes(null == collectionField ? void 0 : collectionField.type);
20
20
  },
21
21
  useComponentProps () {
22
- var _fieldSchema_xcomponentprops;
23
22
  const { t } = useTranslation();
24
23
  const field = useField();
25
24
  const fieldSchema = useFieldSchema();
26
25
  const { dn, refresh } = useDesignable();
27
26
  return {
28
27
  title: t('Allow multiple'),
29
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
28
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
30
29
  onChange (value) {
31
30
  const schema = {
32
31
  ['x-uid']: fieldSchema['x-uid']
@@ -60,14 +60,13 @@ const allowMultiple = {
60
60
  ].includes(null == collectionField ? void 0 : collectionField.type);
61
61
  },
62
62
  useComponentProps () {
63
- var _fieldSchema_xcomponentprops;
64
63
  const { t } = useTranslation();
65
64
  const field = useField();
66
65
  const fieldSchema = useFieldSchema();
67
66
  const { dn, refresh } = useDesignable();
68
67
  return {
69
68
  title: t('Allow multiple'),
70
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
69
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
71
70
  onChange (value) {
72
71
  const schema = {
73
72
  ['x-uid']: fieldSchema['x-uid']
@@ -165,7 +164,7 @@ const recordPickerComponentFieldSettings = new SchemaSettings({
165
164
  value: 'large'
166
165
  }
167
166
  ],
168
- value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) == 'modal' ? 'large' : 'middle',
167
+ value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) === 'modal' ? 'large' : 'middle',
169
168
  onChange: (value)=>{
170
169
  field.componentProps.openSize = value;
171
170
  fieldSchema['x-component-props'] = {
@@ -20,14 +20,13 @@ const allowMultiple = {
20
20
  ].includes(null == collectionField ? void 0 : collectionField.type);
21
21
  },
22
22
  useComponentProps () {
23
- var _fieldSchema_xcomponentprops;
24
23
  const { t } = useTranslation();
25
24
  const field = useField();
26
25
  const fieldSchema = useFieldSchema();
27
26
  const { dn, refresh } = useDesignable();
28
27
  return {
29
28
  title: t('Allow multiple'),
30
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
29
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
31
30
  onChange (value) {
32
31
  const schema = {
33
32
  ['x-uid']: fieldSchema['x-uid']
@@ -123,7 +123,6 @@ const allowMultiple = {
123
123
  ].includes(null == collectionField ? void 0 : collectionField.type);
124
124
  },
125
125
  useComponentProps () {
126
- var _fieldSchema_xcomponentprops;
127
126
  const { t } = useTranslation();
128
127
  const field = useField();
129
128
  const { fieldSchema: tableColumnSchema } = useColumnSchema();
@@ -132,7 +131,7 @@ const allowMultiple = {
132
131
  const { dn, refresh } = useDesignable();
133
132
  return {
134
133
  title: t('Allow multiple'),
135
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
134
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
136
135
  onChange (value) {
137
136
  const schema = {
138
137
  ['x-uid']: fieldSchema['x-uid']
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo } from "react";
3
3
  import { connect, mapProps, mapReadPretty, uid, useField, useFieldSchema } from "@tachybase/schema";
4
- import { LoadingOutlined } from "@ant-design/icons";
5
4
  import { ArrayCollapse, ArrayItems, FormLayout } from "@tego/client";
5
+ import { LoadingOutlined } from "@ant-design/icons";
6
6
  import lodash from "lodash";
7
7
  import { useTranslation } from "react-i18next";
8
8
  import { useFilterByTk, useFormBlockContext } from "../../../block-provider/index.mjs";
@@ -66,7 +66,7 @@ const InternalAssociationSelect = connect((props)=>{
66
66
  })), mapReadPretty(ReadPretty));
67
67
  const AssociationSelect = InternalAssociationSelect;
68
68
  AssociationSelect.Designer = function() {
69
- var _interfaceConfig_validateSchema, _collectionField_uiSchema, _field_componentProps_service_params, _field_componentProps_service, _field_componentProps, _fieldSchema_xcomponentprops, _field_componentProps_service_params1, _field_componentProps_service1, _field_componentProps1, _field_componentProps_fieldNames, _field_componentProps2;
69
+ var _interfaceConfig_validateSchema, _collectionField_uiSchema, _field_componentProps_service_params, _field_componentProps_service, _field_componentProps, _field_componentProps_service_params1, _field_componentProps_service1, _field_componentProps1, _field_componentProps_fieldNames, _field_componentProps2;
70
70
  const { getCollectionFields, getInterface, getCollectionJoinField, getCollection, isTitleField } = useCollectionManager_deprecated();
71
71
  const { getField } = useCollection_deprecated();
72
72
  const { form } = useFormBlockContext();
@@ -318,7 +318,7 @@ AssociationSelect.Designer = function() {
318
318
  }),
319
319
  IsShowMultipleSwitch() ? /*#__PURE__*/ jsx(SchemaSettingsSwitchItem, {
320
320
  title: t('Allow multiple'),
321
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
321
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
322
322
  onChange: (value)=>{
323
323
  const schema = {
324
324
  ['x-uid']: fieldSchema['x-uid']
@@ -4,7 +4,7 @@ import lodash from "lodash";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { useBlockRequestContext } from "../../../block-provider/index.mjs";
6
6
  import { useCollectionManager_deprecated, useCollection_deprecated } from "../../../collection-manager/index.mjs";
7
- import { mergeFilter } from "../../../filter-provider/utils.mjs";
7
+ import { FILTER_OPERATORS_WITH_ARRAY_VALUES, mergeFilter, normalizeDateBetweenValue, shouldUseDefaultDateBoundary } from "../../../filter-provider/utils.mjs";
8
8
  import { useDataLoadingMode } from "../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem.mjs";
9
9
  import { hasDuplicateKeys } from "./utils.mjs";
10
10
  const useGetFilterOptions = ()=>{
@@ -106,6 +106,60 @@ const useFilterFieldOptions = (fields)=>{
106
106
  return getOptions(fields, 1);
107
107
  };
108
108
  const isEmpty = (obj)=>Array.isArray(obj) && 0 === obj.length || obj && 0 === Object.keys(obj).length && Object.getPrototypeOf(obj) === Object.prototype;
109
+ const CUSTOM_FILTER_VARIABLE_REGEXP = /^\{\{\$nFilter\.([^}]+)\}\}$/;
110
+ const getCustomFilterValue = (items, key)=>{
111
+ if (key in items) return items[key];
112
+ 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]);
113
+ return arrayItems.length ? arrayItems : void 0;
114
+ };
115
+ const findCustomFieldSchemaInTree = (schema, key)=>{
116
+ if (!schema) return null;
117
+ if (schema.name === "__custom.".concat(key) || schema.name === key) return schema;
118
+ const properties = schema.properties || {};
119
+ for (const propertyKey of Object.keys(properties)){
120
+ if (propertyKey === "__custom.".concat(key) || propertyKey === key) return properties[propertyKey];
121
+ const found = findCustomFieldSchemaInTree(properties[propertyKey], key);
122
+ if (found) return found;
123
+ }
124
+ return null;
125
+ };
126
+ const findCustomFieldSchema = (schema, key)=>{
127
+ let current = schema;
128
+ while(current){
129
+ const found = findCustomFieldSchemaInTree(current, key);
130
+ if (found) return found;
131
+ current = current.parent;
132
+ }
133
+ return null;
134
+ };
135
+ const expandArrayValueFilter = function(filterSchemaItem, filterKey, value, customFlat) {
136
+ let options = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {};
137
+ const pathParts = filterKey.split('.');
138
+ const operator = pathParts.pop();
139
+ if ('$dateBetween' === operator && Array.isArray(value)) {
140
+ filterSchemaItem[filterKey] = normalizeDateBetweenValue(value, options);
141
+ return;
142
+ }
143
+ if (!Array.isArray(value) || FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator || '')) {
144
+ filterSchemaItem[filterKey] = value;
145
+ return;
146
+ }
147
+ let branchEndIndex = -1;
148
+ for(let index = pathParts.length - 2; index >= 0; index--)if ([
149
+ '$and',
150
+ '$or'
151
+ ].includes(pathParts[index]) && /^\d+$/.test(pathParts[index + 1])) {
152
+ branchEndIndex = index;
153
+ break;
154
+ }
155
+ const branchPath = branchEndIndex >= 0 ? pathParts.slice(0, branchEndIndex + 2).join('.') : '';
156
+ const fieldPath = pathParts.slice(branchEndIndex + 2).join('.');
157
+ const conditions = value.map((item)=>customFlat.unflatten({
158
+ ["".concat(fieldPath, ".").concat(operator)]: item
159
+ }));
160
+ delete filterSchemaItem[filterKey];
161
+ filterSchemaItem[branchPath ? "".concat(branchPath, ".$or") : '$or'] = conditions;
162
+ };
109
163
  const getCustomCondition = function(filter, fieldSchema) {
110
164
  let customFlat = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : flat;
111
165
  var _filterSchema_$and, _filterSchema_$or;
@@ -119,12 +173,12 @@ const getCustomCondition = function(filter, fieldSchema) {
119
173
  {
120
174
  var _flatFieldSchema_$and, _flatFieldSchema_$or;
121
175
  for(const filterKey in filterSchemaItem){
122
- var _filterSchemaItem_filterKey;
123
- const match = null == (_filterSchemaItem_filterKey = filterSchemaItem[filterKey]) ? void 0 : _filterSchemaItem_filterKey.slice(11, -2);
124
- const collection = null == match ? void 0 : match.split('.')[0];
125
- const filterItems = Object.keys(items).filter((item)=>item.includes(collection));
126
- if (filterItems.length > 1) filterSchemaItem[filterKey] = filterItems.map((key)=>items[key]);
127
- else filterSchemaItem[filterKey] = items[filterItems[0]];
176
+ const match = 'string' == typeof filterSchemaItem[filterKey] && filterSchemaItem[filterKey].match(CUSTOM_FILTER_VARIABLE_REGEXP);
177
+ if (!match) continue;
178
+ const customFieldSchema = findCustomFieldSchema(fieldSchema, match[1]);
179
+ expandArrayValueFilter(filterSchemaItem, filterKey, getCustomFilterValue(items, match[1]), customFlat, {
180
+ useDefaultDateBoundary: shouldUseDefaultDateBoundary(customFieldSchema)
181
+ });
128
182
  }
129
183
  for(const item in filterSchemaItem)if (!filterSchemaItem[item] || filterSchemaItem[item].includes('$nFilter')) delete filterSchemaItem[item];
130
184
  const flatFieldSchema = customFlat.unflatten(filterSchemaItem);
@@ -836,14 +836,13 @@ const formItemSettings = new SchemaSettings({
836
836
  return isAssociationField && IsShowMultipleSwitch();
837
837
  },
838
838
  useComponentProps () {
839
- var _fieldSchema_xcomponentprops;
840
839
  const { t } = useTranslation();
841
840
  const field = useField();
842
841
  const fieldSchema = useFieldSchema();
843
842
  const { dn, refresh } = useDesignable();
844
843
  return {
845
844
  title: t('Allow multiple'),
846
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
845
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
847
846
  onChange (value) {
848
847
  const schema = {
849
848
  ['x-uid']: fieldSchema['x-uid']
@@ -83,6 +83,7 @@ export declare const useInheritsTableColumnInitializerFields: () => {
83
83
  export declare const useFormItemInitializerFields: (options?: any) => SchemaInitializerItemType[];
84
84
  export declare const useFilterFormItemInitializerFields: (options?: any) => SchemaInitializerItemType[];
85
85
  export declare const useAssociatedFormItemInitializerFields: (options?: any) => SchemaInitializerItemType[];
86
+ export declare const createFilterAssociatedResultSchema: (schemaName: any, field: any, collectionName: any, fieldPath: any) => SchemaInitializerItemType;
86
87
  export declare const useFilterAssociatedFormItemInitializerFields: () => SchemaInitializerItemType[];
87
88
  export declare const useInheritsFormItemInitializerFields: (options?: any) => {
88
89
  [x: string]: SchemaInitializerItemType[];
@@ -327,7 +327,7 @@ const useFilterFormItemInitializerFields = (options)=>{
327
327
  'x-component': 'CollectionField',
328
328
  'x-decorator': 'FormItem',
329
329
  'x-collection-field': "".concat(name, ".").concat(field.name),
330
- 'x-component-props': null == (_field_uiSchema2 = field.uiSchema) ? void 0 : _field_uiSchema2['x-component-props']
330
+ 'x-component-props': (null == (_field_uiSchema2 = field.uiSchema) ? void 0 : _field_uiSchema2['x-component-props']) || {}
331
331
  };
332
332
  }
333
333
  const resultItem = {
@@ -438,7 +438,7 @@ const getItem = (field, schemaName, collectionName, getCollectionFields, process
438
438
  'oho',
439
439
  'o2m',
440
440
  'm2m'
441
- ].includes(subField.interface)) options.push(getResultSchema("".concat(schemaName, ".").concat(subField.name), subField, collectionName, (fieldPath || '') + field.key));
441
+ ].includes(subField.interface)) options.push(createFilterAssociatedResultSchema("".concat(schemaName, ".").concat(subField.name), subField, collectionName, (fieldPath || '') + field.key));
442
442
  options.push(getItem(subField, "".concat(schemaName, ".").concat(subField.name), collectionName, getCollectionFields, [
443
443
  ...processedCollections,
444
444
  field.target
@@ -453,9 +453,9 @@ const getItem = (field, schemaName, collectionName, getCollectionFields, process
453
453
  };
454
454
  }
455
455
  if (isAssocField(field)) return null;
456
- return getResultSchema(schemaName, field, collectionName, (fieldPath || '') + field.key);
456
+ return createFilterAssociatedResultSchema(schemaName, field, collectionName, (fieldPath || '') + field.key);
457
457
  };
458
- const getResultSchema = (schemaName, field, collectionName, fieldPath)=>{
458
+ const createFilterAssociatedResultSchema = (schemaName, field, collectionName, fieldPath)=>{
459
459
  var _field_uiSchema, _field_uiSchema1, _field_uiSchema2;
460
460
  const schema = {
461
461
  type: 'string',
@@ -468,7 +468,8 @@ const getResultSchema = (schemaName, field, collectionName, fieldPath)=>{
468
468
  'x-component': 'CollectionField',
469
469
  'x-read-pretty': false,
470
470
  'x-decorator': 'FormItem',
471
- 'x-collection-field': "".concat(collectionName, ".").concat(schemaName)
471
+ 'x-collection-field': "".concat(collectionName, ".").concat(schemaName),
472
+ 'x-component-props': {}
472
473
  };
473
474
  const result = {
474
475
  name: (null == (_field_uiSchema = field.uiSchema) ? void 0 : _field_uiSchema.title) || field.name,
@@ -1374,4 +1375,4 @@ function useAssociationFields(param) {
1374
1375
  t
1375
1376
  ]);
1376
1377
  }
1377
- export { createDetailsBlockSchema, createFormBlockSchema, createReadPrettyFormBlockSchema, createTableBlockSchema, findSchema, findTableColumn, gridRowColWrap, itemsMerge, removeGridFormItem, removeTableColumn, useAssociatedFormItemInitializerFields, useAssociatedTableColumnInitializerFields, useCollectionDataSourceItems, useCurrentSchema, useCustomFormItemInitializerFields, useFilterAssociatedFormItemInitializerFields, useFilterFormItemInitializerFields, useFilterInheritsFormItemInitializerFields, useFormItemInitializerFields, useInheritsFormItemInitializerFields, useInheritsTableColumnInitializerFields, useRecordCollectionDataSourceItems, useRemoveGridFormItem, useTableColumnInitializerFields };
1378
+ export { createDetailsBlockSchema, createFilterAssociatedResultSchema, createFormBlockSchema, createReadPrettyFormBlockSchema, createTableBlockSchema, findSchema, findTableColumn, gridRowColWrap, itemsMerge, removeGridFormItem, removeTableColumn, useAssociatedFormItemInitializerFields, useAssociatedTableColumnInitializerFields, useCollectionDataSourceItems, useCurrentSchema, useCustomFormItemInitializerFields, useFilterAssociatedFormItemInitializerFields, useFilterFormItemInitializerFields, useFilterInheritsFormItemInitializerFields, useFormItemInitializerFields, useInheritsFormItemInitializerFields, useInheritsTableColumnInitializerFields, useRecordCollectionDataSourceItems, useRemoveGridFormItem, useTableColumnInitializerFields };
@@ -740,7 +740,6 @@ var __webpack_exports__ = {};
740
740
  async onClick () {
741
741
  const { targets = [], uid } = findFilterTargets(fieldSchema);
742
742
  actionField.data.loading = true;
743
- let prevMergedFilter = {};
744
743
  try {
745
744
  await Promise.all(getDataBlocks().map(async (block)=>{
746
745
  var _block_service_params, _block_service_params_, _block_service_params1, _Object_keys;
@@ -777,11 +776,9 @@ var __webpack_exports__ = {};
777
776
  ...Object.values(storedFilter).map((filter)=>(0, _schema_component__WEBPACK_IMPORTED_MODULE_19__.removeNullCondition)(filter)),
778
777
  (0, _filter_provider_incomingFilterFromSources__WEBPACK_IMPORTED_MODULE_16__.getFilterSourceDefaultFilter)(getDataBlocks(), uid),
779
778
  block.defaultFilter,
780
- filter.customFilter,
781
- prevMergedFilter
779
+ filter.customFilter
782
780
  ]);
783
781
  const currFilter = filterByCleanedFields(mergedFilter);
784
- prevMergedFilter = currFilter;
785
782
  if ('manual' === block.dataLoadingMode && lodash__WEBPACK_IMPORTED_MODULE_5___default().isEmpty(currFilter)) return block.clearData();
786
783
  return block.doFilter({
787
784
  ...param,
@@ -809,7 +806,6 @@ var __webpack_exports__ = {};
809
806
  const { targets, uid } = findFilterTargets(fieldSchema);
810
807
  form.reset();
811
808
  actionField.data.loading = true;
812
- let prevMergedFilter = {};
813
809
  try {
814
810
  await Promise.all(getDataBlocks().map(async (block)=>{
815
811
  var _block_service_params, _block_service_params_, _block_service_params1;
@@ -822,11 +818,9 @@ var __webpack_exports__ = {};
822
818
  const currFilter = (0, _filter_provider_utils__WEBPACK_IMPORTED_MODULE_17__.mergeFilter)([
823
819
  ...Object.values(storedFilter),
824
820
  (0, _filter_provider_incomingFilterFromSources__WEBPACK_IMPORTED_MODULE_16__.getFilterSourceDefaultFilter)(getDataBlocks(), uid),
825
- block.defaultFilter,
826
- prevMergedFilter
821
+ block.defaultFilter
827
822
  ]);
828
823
  const mergedFilter = filterByCleanedFields(currFilter);
829
- prevMergedFilter = mergedFilter;
830
824
  return block.doFilter({
831
825
  ...param,
832
826
  page: 1,
@@ -82,14 +82,14 @@ function useParentRequest(options) {
82
82
  if (parentRecord) return Promise.resolve({
83
83
  data: parentRecord
84
84
  });
85
- if (!association || !sourceKey) return Promise.resolve({
85
+ if (!association || !sourceKey || null == sourceId) return Promise.resolve({
86
86
  data: void 0
87
87
  });
88
88
  const arr = association.split('.');
89
- const url = "".concat(arr[0], ":get?filter[").concat(sourceKey, "]=").concat(sourceId);
90
- const res = await api.request({
91
- url,
92
- headers
89
+ const res = await api.resource(arr[0], void 0, headers).get({
90
+ filter: {
91
+ [sourceKey]: sourceId
92
+ }
93
93
  });
94
94
  return res.data;
95
95
  }, {
@@ -35,6 +35,7 @@ __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
36
  mergeFilter: ()=>mergeFilter,
37
37
  FILTER_OPERATORS_WITH_ARRAY_VALUES: ()=>FILTER_OPERATORS_WITH_ARRAY_VALUES,
38
+ normalizeDateBetweenValue: ()=>normalizeDateBetweenValue,
38
39
  transformToFilter: ()=>transformToFilter,
39
40
  isSameCollection: ()=>isSameCollection,
40
41
  getSupportFieldsByForeignKey: ()=>getSupportFieldsByForeignKey,
@@ -43,6 +44,7 @@ __webpack_require__.d(__webpack_exports__, {
43
44
  isAssocField: ()=>isAssocField,
44
45
  useAssociatedFields: ()=>useAssociatedFields,
45
46
  isInFilterFormBlock: ()=>isInFilterFormBlock,
47
+ shouldUseDefaultDateBoundary: ()=>shouldUseDefaultDateBoundary,
46
48
  useFilterAPI: ()=>useFilterAPI,
47
49
  useSupportedBlocks: ()=>useSupportedBlocks
48
50
  });
@@ -112,6 +114,7 @@ const findSchemaByName = (schema, name)=>{
112
114
  if (schema.name === name) return schema;
113
115
  const properties = schema.properties || {};
114
116
  for (const key of Object.keys(properties)){
117
+ if (key === name) return properties[key];
115
118
  const found = findSchemaByName(properties[key], name);
116
119
  if (found) return found;
117
120
  }
@@ -137,6 +140,54 @@ const resolveFilterOperator = function(schema, path) {
137
140
  if (!operatorList.length || !fieldSchema) return;
138
141
  return (0, SchemaSettingOptions_js_namespaceObject.getDefaultFilterOperatorValue)(fieldSchema, operatorList);
139
142
  };
143
+ const isDateOnlyString = (value)=>'string' == typeof value && /^\d{4}-\d{2}-\d{2}$/.test(value);
144
+ const hasExplicitTime = (value)=>'string' == typeof value && /[T\s]\d{2}:\d{2}/.test(value);
145
+ const isDefaultDateBoundaryValue = (value, boundary)=>{
146
+ if (isDateOnlyString(value)) return true;
147
+ if ('string' != typeof value) return false;
148
+ const match = value.match(/^\d{4}-\d{2}-\d{2}[T\s](\d{2}:\d{2}:\d{2})(?:\.\d{3})?(?:Z|[+-]\d\d:\d\d)?$/);
149
+ if (!match) return false;
150
+ return 'start' === boundary ? '00:00:00' === match[1] : '23:59:59' === match[1];
151
+ };
152
+ const normalizeDefaultDateBoundaryInput = (value)=>{
153
+ if ('string' != typeof value) return value;
154
+ return value.replace(/Z$/, '').replace(/[+-]\d\d:\d\d$/, '');
155
+ };
156
+ const normalizeDateBetweenBoundary = function(value, boundary) {
157
+ let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
158
+ const rawValue = options.useDefaultDateBoundary ? normalizeDefaultDateBoundaryInput(value) : value;
159
+ const m = external_dayjs_default()(rawValue);
160
+ if (!m.isValid()) return value;
161
+ if (!options.useDefaultDateBoundary && hasExplicitTime(rawValue) && !isDateOnlyString(rawValue)) return m.toISOString();
162
+ return ('start' === boundary ? m.startOf('day') : m.endOf('day')).toISOString();
163
+ };
164
+ const shouldApplyDefaultDateBoundary = function(start, end) {
165
+ let options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
166
+ if (!options.useDefaultDateBoundary) return false;
167
+ if (isDateOnlyString(start) || isDateOnlyString(end)) return true;
168
+ return isDefaultDateBoundaryValue(start, 'start') && isDefaultDateBoundaryValue(end, 'end');
169
+ };
170
+ const normalizeDateBetweenValue = function(value) {
171
+ let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
172
+ const normalized = value.filter(Boolean);
173
+ if (0 === normalized.length) return null;
174
+ const start = normalized[0];
175
+ const end = 1 === normalized.length ? normalized[0] : normalized[normalized.length - 1];
176
+ const boundaryOptions = {
177
+ ...options,
178
+ useDefaultDateBoundary: shouldApplyDefaultDateBoundary(start, end, options)
179
+ };
180
+ return [
181
+ normalizeDateBetweenBoundary(start, 'start', boundaryOptions),
182
+ normalizeDateBetweenBoundary(end, 'end', boundaryOptions)
183
+ ];
184
+ };
185
+ const shouldUseDefaultDateBoundary = (fieldSchema)=>{
186
+ var _fieldSchema_xcomponentprops;
187
+ if (!fieldSchema) return false;
188
+ const component = fieldSchema['x-component'] || (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
189
+ return 'DatePicker.RangePicker' === component;
190
+ };
140
191
  const transformToFilter = (values, fieldSchema, getCollectionJoinField, collectionName, getOperatorList)=>{
141
192
  const { operators } = (0, SchemaSettingOptions_js_namespaceObject.findFilterOperators)(fieldSchema);
142
193
  values = (0, client_namespaceObject.flatten)(values, {
@@ -158,6 +209,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
158
209
  const defKey = key;
159
210
  let value = external_lodash_default().get(values, key);
160
211
  const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(key));
212
+ const currentFieldSchema = findSchemaByName(getFilterSchemaRoot(fieldSchema), defKey);
161
213
  const operator = resolveFilterOperator(fieldSchema, defKey, operators, getOperatorList, collectionField);
162
214
  if (null == collectionField ? void 0 : collectionField.target) {
163
215
  value = (0, client_namespaceObject.getValuesByPath)(value, collectionField.targetKey || 'id');
@@ -177,21 +229,10 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
177
229
  };
178
230
  } else if ('$dateBetween' === operator) {
179
231
  if (Array.isArray(value)) {
180
- const normalized = [];
181
- for(const index in value){
182
- if (!value[index]) continue;
183
- let v = value[index];
184
- if ('string' != typeof v && !(v instanceof Date)) v = external_dayjs_default()(v).toISOString();
185
- normalized.push(v);
186
- }
187
- if (0 === normalized.length) return null;
188
- value = 1 === normalized.length ? [
189
- normalized[0],
190
- normalized[0]
191
- ] : [
192
- normalized[0],
193
- normalized[normalized.length - 1]
194
- ];
232
+ value = normalizeDateBetweenValue(value, {
233
+ useDefaultDateBoundary: shouldUseDefaultDateBoundary(currentFieldSchema)
234
+ });
235
+ if (!value) return null;
195
236
  }
196
237
  }
197
238
  return {
@@ -289,6 +330,8 @@ exports.isAssocField = __webpack_exports__.isAssocField;
289
330
  exports.isInFilterFormBlock = __webpack_exports__.isInFilterFormBlock;
290
331
  exports.isSameCollection = __webpack_exports__.isSameCollection;
291
332
  exports.mergeFilter = __webpack_exports__.mergeFilter;
333
+ exports.normalizeDateBetweenValue = __webpack_exports__.normalizeDateBetweenValue;
334
+ exports.shouldUseDefaultDateBoundary = __webpack_exports__.shouldUseDefaultDateBoundary;
292
335
  exports.transformToFilter = __webpack_exports__.transformToFilter;
293
336
  exports.useAssociatedFields = __webpack_exports__.useAssociatedFields;
294
337
  exports.useFilterAPI = __webpack_exports__.useFilterAPI;
@@ -302,6 +345,8 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
302
345
  "isInFilterFormBlock",
303
346
  "isSameCollection",
304
347
  "mergeFilter",
348
+ "normalizeDateBetweenValue",
349
+ "shouldUseDefaultDateBoundary",
305
350
  "transformToFilter",
306
351
  "useAssociatedFields",
307
352
  "useFilterAPI",
@@ -48,14 +48,13 @@ const allowMultiple = {
48
48
  ].includes(null == collectionField ? void 0 : collectionField.type);
49
49
  },
50
50
  useComponentProps () {
51
- var _fieldSchema_xcomponentprops;
52
51
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
53
52
  const field = (0, schema_namespaceObject.useField)();
54
53
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
55
54
  const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
56
55
  return {
57
56
  title: t('Allow multiple'),
58
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
57
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
59
58
  onChange (value) {
60
59
  const schema = {
61
60
  ['x-uid']: fieldSchema['x-uid']
@@ -154,7 +153,7 @@ const drawerSubTableComponentFieldSettings = new SchemaSettings_js_namespaceObje
154
153
  value: 'large'
155
154
  }
156
155
  ],
157
- value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) == 'modal' ? 'large' : 'middle',
156
+ value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) === 'modal' ? 'large' : 'middle',
158
157
  onChange: (value)=>{
159
158
  field.componentProps.openSize = value;
160
159
  fieldSchema['x-component-props'] = {
@@ -47,14 +47,13 @@ const allowMultiple = {
47
47
  ].includes(null == collectionField ? void 0 : collectionField.type);
48
48
  },
49
49
  useComponentProps () {
50
- var _fieldSchema_xcomponentprops;
51
50
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
52
51
  const field = (0, schema_namespaceObject.useField)();
53
52
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
54
53
  const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
55
54
  return {
56
55
  title: t('Allow multiple'),
57
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
56
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
58
57
  onChange (value) {
59
58
  const schema = {
60
59
  ['x-uid']: fieldSchema['x-uid']
@@ -89,14 +89,13 @@ const allowMultiple = {
89
89
  ].includes(null == collectionField ? void 0 : collectionField.type);
90
90
  },
91
91
  useComponentProps () {
92
- var _fieldSchema_xcomponentprops;
93
92
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
94
93
  const field = (0, schema_namespaceObject.useField)();
95
94
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
96
95
  const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
97
96
  return {
98
97
  title: t('Allow multiple'),
99
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
98
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
100
99
  onChange (value) {
101
100
  const schema = {
102
101
  ['x-uid']: fieldSchema['x-uid']
@@ -194,7 +193,7 @@ const recordPickerComponentFieldSettings = new SchemaSettings_js_namespaceObject
194
193
  value: 'large'
195
194
  }
196
195
  ],
197
- value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) == 'modal' ? 'large' : 'middle',
196
+ value: null != (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops1['openMode']) === 'modal' ? 'large' : 'middle',
198
197
  onChange: (value)=>{
199
198
  field.componentProps.openSize = value;
200
199
  fieldSchema['x-component-props'] = {
@@ -48,14 +48,13 @@ const allowMultiple = {
48
48
  ].includes(null == collectionField ? void 0 : collectionField.type);
49
49
  },
50
50
  useComponentProps () {
51
- var _fieldSchema_xcomponentprops;
52
51
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
53
52
  const field = (0, schema_namespaceObject.useField)();
54
53
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
55
54
  const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
56
55
  return {
57
56
  title: t('Allow multiple'),
58
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
57
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
59
58
  onChange (value) {
60
59
  const schema = {
61
60
  ['x-uid']: fieldSchema['x-uid']
@@ -169,7 +169,6 @@ const allowMultiple = {
169
169
  ].includes(null == collectionField ? void 0 : collectionField.type);
170
170
  },
171
171
  useComponentProps () {
172
- var _fieldSchema_xcomponentprops;
173
172
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
174
173
  const field = (0, schema_namespaceObject.useField)();
175
174
  const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
@@ -178,7 +177,7 @@ const allowMultiple = {
178
177
  const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
179
178
  return {
180
179
  title: t('Allow multiple'),
181
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
180
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
182
181
  onChange (value) {
183
182
  const schema = {
184
183
  ['x-uid']: fieldSchema['x-uid']
@@ -39,8 +39,8 @@ __webpack_require__.d(__webpack_exports__, {
39
39
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
40
40
  const external_react_namespaceObject = require("react");
41
41
  const schema_namespaceObject = require("@tachybase/schema");
42
- const icons_namespaceObject = require("@ant-design/icons");
43
42
  const client_namespaceObject = require("@tego/client");
43
+ const icons_namespaceObject = require("@ant-design/icons");
44
44
  const external_lodash_namespaceObject = require("lodash");
45
45
  var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
46
46
  const external_react_i18next_namespaceObject = require("react-i18next");
@@ -106,7 +106,7 @@ const InternalAssociationSelect = (0, schema_namespaceObject.connect)((props)=>{
106
106
  })), (0, schema_namespaceObject.mapReadPretty)(external_ReadPretty_js_namespaceObject.ReadPretty));
107
107
  const AssociationSelect = InternalAssociationSelect;
108
108
  AssociationSelect.Designer = function() {
109
- var _interfaceConfig_validateSchema, _collectionField_uiSchema, _field_componentProps_service_params, _field_componentProps_service, _field_componentProps, _fieldSchema_xcomponentprops, _field_componentProps_service_params1, _field_componentProps_service1, _field_componentProps1, _field_componentProps_fieldNames, _field_componentProps2;
109
+ var _interfaceConfig_validateSchema, _collectionField_uiSchema, _field_componentProps_service_params, _field_componentProps_service, _field_componentProps, _field_componentProps_service_params1, _field_componentProps_service1, _field_componentProps1, _field_componentProps_fieldNames, _field_componentProps2;
110
110
  const { getCollectionFields, getInterface, getCollectionJoinField, getCollection, isTitleField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
111
111
  const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
112
112
  const { form } = (0, index_js_namespaceObject.useFormBlockContext)();
@@ -358,7 +358,7 @@ AssociationSelect.Designer = function() {
358
358
  }),
359
359
  IsShowMultipleSwitch() ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaSettings_js_namespaceObject.SchemaSettingsSwitchItem, {
360
360
  title: t('Allow multiple'),
361
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
361
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
362
362
  onChange: (value)=>{
363
363
  const schema = {
364
364
  ['x-uid']: fieldSchema['x-uid']
@@ -152,6 +152,60 @@ const useFilterFieldOptions = (fields)=>{
152
152
  return getOptions(fields, 1);
153
153
  };
154
154
  const isEmpty = (obj)=>Array.isArray(obj) && 0 === obj.length || obj && 0 === Object.keys(obj).length && Object.getPrototypeOf(obj) === Object.prototype;
155
+ const CUSTOM_FILTER_VARIABLE_REGEXP = /^\{\{\$nFilter\.([^}]+)\}\}$/;
156
+ const getCustomFilterValue = (items, key)=>{
157
+ if (key in items) return items[key];
158
+ 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]);
159
+ return arrayItems.length ? arrayItems : void 0;
160
+ };
161
+ const findCustomFieldSchemaInTree = (schema, key)=>{
162
+ if (!schema) return null;
163
+ if (schema.name === "__custom.".concat(key) || schema.name === key) return schema;
164
+ const properties = schema.properties || {};
165
+ for (const propertyKey of Object.keys(properties)){
166
+ if (propertyKey === "__custom.".concat(key) || propertyKey === key) return properties[propertyKey];
167
+ const found = findCustomFieldSchemaInTree(properties[propertyKey], key);
168
+ if (found) return found;
169
+ }
170
+ return null;
171
+ };
172
+ const findCustomFieldSchema = (schema, key)=>{
173
+ let current = schema;
174
+ while(current){
175
+ const found = findCustomFieldSchemaInTree(current, key);
176
+ if (found) return found;
177
+ current = current.parent;
178
+ }
179
+ return null;
180
+ };
181
+ const expandArrayValueFilter = function(filterSchemaItem, filterKey, value, customFlat) {
182
+ let options = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {};
183
+ const pathParts = filterKey.split('.');
184
+ const operator = pathParts.pop();
185
+ if ('$dateBetween' === operator && Array.isArray(value)) {
186
+ filterSchemaItem[filterKey] = (0, utils_js_namespaceObject.normalizeDateBetweenValue)(value, options);
187
+ return;
188
+ }
189
+ if (!Array.isArray(value) || utils_js_namespaceObject.FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator || '')) {
190
+ filterSchemaItem[filterKey] = value;
191
+ return;
192
+ }
193
+ let branchEndIndex = -1;
194
+ for(let index = pathParts.length - 2; index >= 0; index--)if ([
195
+ '$and',
196
+ '$or'
197
+ ].includes(pathParts[index]) && /^\d+$/.test(pathParts[index + 1])) {
198
+ branchEndIndex = index;
199
+ break;
200
+ }
201
+ const branchPath = branchEndIndex >= 0 ? pathParts.slice(0, branchEndIndex + 2).join('.') : '';
202
+ const fieldPath = pathParts.slice(branchEndIndex + 2).join('.');
203
+ const conditions = value.map((item)=>customFlat.unflatten({
204
+ ["".concat(fieldPath, ".").concat(operator)]: item
205
+ }));
206
+ delete filterSchemaItem[filterKey];
207
+ filterSchemaItem[branchPath ? "".concat(branchPath, ".$or") : '$or'] = conditions;
208
+ };
155
209
  const getCustomCondition = function(filter, fieldSchema) {
156
210
  let customFlat = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : external_flat_default();
157
211
  var _filterSchema_$and, _filterSchema_$or;
@@ -165,12 +219,12 @@ const getCustomCondition = function(filter, fieldSchema) {
165
219
  {
166
220
  var _flatFieldSchema_$and, _flatFieldSchema_$or;
167
221
  for(const filterKey in filterSchemaItem){
168
- var _filterSchemaItem_filterKey;
169
- const match = null == (_filterSchemaItem_filterKey = filterSchemaItem[filterKey]) ? void 0 : _filterSchemaItem_filterKey.slice(11, -2);
170
- const collection = null == match ? void 0 : match.split('.')[0];
171
- const filterItems = Object.keys(items).filter((item)=>item.includes(collection));
172
- if (filterItems.length > 1) filterSchemaItem[filterKey] = filterItems.map((key)=>items[key]);
173
- else filterSchemaItem[filterKey] = items[filterItems[0]];
222
+ const match = 'string' == typeof filterSchemaItem[filterKey] && filterSchemaItem[filterKey].match(CUSTOM_FILTER_VARIABLE_REGEXP);
223
+ if (!match) continue;
224
+ const customFieldSchema = findCustomFieldSchema(fieldSchema, match[1]);
225
+ expandArrayValueFilter(filterSchemaItem, filterKey, getCustomFilterValue(items, match[1]), customFlat, {
226
+ useDefaultDateBoundary: (0, utils_js_namespaceObject.shouldUseDefaultDateBoundary)(customFieldSchema)
227
+ });
174
228
  }
175
229
  for(const item in filterSchemaItem)if (!filterSchemaItem[item] || filterSchemaItem[item].includes('$nFilter')) delete filterSchemaItem[item];
176
230
  const flatFieldSchema = customFlat.unflatten(filterSchemaItem);
@@ -885,14 +885,13 @@ const formItemSettings = new index_js_namespaceObject.SchemaSettings({
885
885
  return isAssociationField && IsShowMultipleSwitch();
886
886
  },
887
887
  useComponentProps () {
888
- var _fieldSchema_xcomponentprops;
889
888
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
890
889
  const field = (0, schema_namespaceObject.useField)();
891
890
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
892
891
  const { dn, refresh } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
893
892
  return {
894
893
  title: t('Allow multiple'),
895
- checked: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 ? true : fieldSchema['x-component-props'].multiple,
894
+ checked: void 0 === (fieldSchema['x-component-props'] || {}).multiple ? true : fieldSchema['x-component-props'].multiple,
896
895
  onChange (value) {
897
896
  const schema = {
898
897
  ['x-uid']: fieldSchema['x-uid']
@@ -49,6 +49,7 @@ __webpack_require__.d(__webpack_exports__, {
49
49
  useAssociatedTableColumnInitializerFields: ()=>useAssociatedTableColumnInitializerFields,
50
50
  useFilterFormItemInitializerFields: ()=>useFilterFormItemInitializerFields,
51
51
  useFormItemInitializerFields: ()=>useFormItemInitializerFields,
52
+ createFilterAssociatedResultSchema: ()=>createFilterAssociatedResultSchema,
52
53
  gridRowColWrap: ()=>gridRowColWrap,
53
54
  useCustomFormItemInitializerFields: ()=>useCustomFormItemInitializerFields,
54
55
  useFilterInheritsFormItemInitializerFields: ()=>useFilterInheritsFormItemInitializerFields,
@@ -388,7 +389,7 @@ const useFilterFormItemInitializerFields = (options)=>{
388
389
  'x-component': 'CollectionField',
389
390
  'x-decorator': 'FormItem',
390
391
  'x-collection-field': "".concat(name, ".").concat(field.name),
391
- 'x-component-props': null == (_field_uiSchema2 = field.uiSchema) ? void 0 : _field_uiSchema2['x-component-props']
392
+ 'x-component-props': (null == (_field_uiSchema2 = field.uiSchema) ? void 0 : _field_uiSchema2['x-component-props']) || {}
392
393
  };
393
394
  }
394
395
  const resultItem = {
@@ -499,7 +500,7 @@ const getItem = (field, schemaName, collectionName, getCollectionFields, process
499
500
  'oho',
500
501
  'o2m',
501
502
  'm2m'
502
- ].includes(subField.interface)) options.push(getResultSchema("".concat(schemaName, ".").concat(subField.name), subField, collectionName, (fieldPath || '') + field.key));
503
+ ].includes(subField.interface)) options.push(createFilterAssociatedResultSchema("".concat(schemaName, ".").concat(subField.name), subField, collectionName, (fieldPath || '') + field.key));
503
504
  options.push(getItem(subField, "".concat(schemaName, ".").concat(subField.name), collectionName, getCollectionFields, [
504
505
  ...processedCollections,
505
506
  field.target
@@ -514,9 +515,9 @@ const getItem = (field, schemaName, collectionName, getCollectionFields, process
514
515
  };
515
516
  }
516
517
  if ((0, utils_js_namespaceObject.isAssocField)(field)) return null;
517
- return getResultSchema(schemaName, field, collectionName, (fieldPath || '') + field.key);
518
+ return createFilterAssociatedResultSchema(schemaName, field, collectionName, (fieldPath || '') + field.key);
518
519
  };
519
- const getResultSchema = (schemaName, field, collectionName, fieldPath)=>{
520
+ const createFilterAssociatedResultSchema = (schemaName, field, collectionName, fieldPath)=>{
520
521
  var _field_uiSchema, _field_uiSchema1, _field_uiSchema2;
521
522
  const schema = {
522
523
  type: 'string',
@@ -529,7 +530,8 @@ const getResultSchema = (schemaName, field, collectionName, fieldPath)=>{
529
530
  'x-component': 'CollectionField',
530
531
  'x-read-pretty': false,
531
532
  'x-decorator': 'FormItem',
532
- 'x-collection-field': "".concat(collectionName, ".").concat(schemaName)
533
+ 'x-collection-field': "".concat(collectionName, ".").concat(schemaName),
534
+ 'x-component-props': {}
533
535
  };
534
536
  const result = {
535
537
  name: (null == (_field_uiSchema = field.uiSchema) ? void 0 : _field_uiSchema.title) || field.name,
@@ -1436,6 +1438,7 @@ function useAssociationFields(param) {
1436
1438
  ]);
1437
1439
  }
1438
1440
  exports.createDetailsBlockSchema = __webpack_exports__.createDetailsBlockSchema;
1441
+ exports.createFilterAssociatedResultSchema = __webpack_exports__.createFilterAssociatedResultSchema;
1439
1442
  exports.createFormBlockSchema = __webpack_exports__.createFormBlockSchema;
1440
1443
  exports.createReadPrettyFormBlockSchema = __webpack_exports__.createReadPrettyFormBlockSchema;
1441
1444
  exports.createTableBlockSchema = __webpack_exports__.createTableBlockSchema;
@@ -1461,6 +1464,7 @@ exports.useRemoveGridFormItem = __webpack_exports__.useRemoveGridFormItem;
1461
1464
  exports.useTableColumnInitializerFields = __webpack_exports__.useTableColumnInitializerFields;
1462
1465
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
1463
1466
  "createDetailsBlockSchema",
1467
+ "createFilterAssociatedResultSchema",
1464
1468
  "createFormBlockSchema",
1465
1469
  "createReadPrettyFormBlockSchema",
1466
1470
  "createTableBlockSchema",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/client",
3
- "version": "1.6.17",
3
+ "version": "1.6.18",
4
4
  "homepage": "https://github.com/tegojs/tego-standard#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/tegojs/tego-standard/issues"