@tachybase/client 1.6.17 → 1.6.19

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 (30) 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 +10 -0
  4. package/es/filter-provider/utils.mjs +68 -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/date-picker/util.d.ts +18 -0
  12. package/es/schema-component/antd/date-picker/util.mjs +62 -5
  13. package/es/schema-component/antd/filter/useFilterActionProps.mjs +85 -7
  14. package/es/schema-component/antd/form-item/FormItem.Settings.mjs +1 -2
  15. package/es/schema-initializer/utils.d.ts +1 -0
  16. package/es/schema-initializer/utils.mjs +7 -6
  17. package/lib/block-provider/hooks/index.js +2 -8
  18. package/lib/data-source/data-block/DataBlockRequestProvider.js +5 -5
  19. package/lib/filter-provider/utils.js +73 -15
  20. package/lib/modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings.js +2 -3
  21. package/lib/modules/fields/component/Nester/subformComponentFieldSettings.js +1 -2
  22. package/lib/modules/fields/component/Picker/recordPickerComponentFieldSettings.js +2 -3
  23. package/lib/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.js +1 -2
  24. package/lib/modules/fields/component/Select/selectComponentFieldSettings.js +1 -2
  25. package/lib/schema-component/antd/association-select/AssociationSelect.js +3 -3
  26. package/lib/schema-component/antd/date-picker/util.js +81 -6
  27. package/lib/schema-component/antd/filter/useFilterActionProps.js +84 -6
  28. package/lib/schema-component/antd/form-item/FormItem.Settings.js +1 -2
  29. package/lib/schema-initializer/utils.js +9 -5
  30. package/package.json +1 -1
@@ -52,6 +52,7 @@ const index_js_namespaceObject = require("../../../block-provider/index.js");
52
52
  const external_collection_manager_index_js_namespaceObject = require("../../../collection-manager/index.js");
53
53
  const utils_js_namespaceObject = require("../../../filter-provider/utils.js");
54
54
  const setDataLoadingModeSettingsItem_js_namespaceObject = require("../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem.js");
55
+ const util_js_namespaceObject = require("../date-picker/util.js");
55
56
  const external_utils_js_namespaceObject = require("./utils.js");
56
57
  const useGetFilterOptions = ()=>{
57
58
  const { getCollectionFields } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
@@ -152,6 +153,81 @@ const useFilterFieldOptions = (fields)=>{
152
153
  return getOptions(fields, 1);
153
154
  };
154
155
  const isEmpty = (obj)=>Array.isArray(obj) && 0 === obj.length || obj && 0 === Object.keys(obj).length && Object.getPrototypeOf(obj) === Object.prototype;
156
+ const CUSTOM_FILTER_VARIABLE_REGEXP = /^\{\{\$nFilter\.([^}]+)\}\}$/;
157
+ const getCustomFilterValue = function(items, key) {
158
+ let rawItems = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
159
+ if (rawItems && key in rawItems) return rawItems[key];
160
+ if (key in items) return items[key];
161
+ 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]);
162
+ return arrayItems.length ? arrayItems : void 0;
163
+ };
164
+ const findCustomFieldSchemaInTree = (schema, key)=>{
165
+ if (!schema) return null;
166
+ if (schema.name === "__custom.".concat(key) || schema.name === key) return schema;
167
+ const properties = schema.properties || {};
168
+ for (const propertyKey of Object.keys(properties)){
169
+ if (propertyKey === "__custom.".concat(key) || propertyKey === key) return properties[propertyKey];
170
+ const found = findCustomFieldSchemaInTree(properties[propertyKey], key);
171
+ if (found) return found;
172
+ }
173
+ return null;
174
+ };
175
+ const findCustomFieldSchema = (schema, key)=>{
176
+ let current = schema;
177
+ while(current){
178
+ const found = findCustomFieldSchemaInTree(current, key);
179
+ if (found) return found;
180
+ current = current.parent;
181
+ }
182
+ return null;
183
+ };
184
+ const getDatePickerComponent = (fieldSchema)=>{
185
+ var _fieldSchema_xcomponentprops;
186
+ return (null == fieldSchema ? void 0 : fieldSchema['x-component']) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.component);
187
+ };
188
+ const getDatePickerShowTime = (fieldSchema)=>{
189
+ var _fieldSchema_xcomponentprops;
190
+ return null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.showTime;
191
+ };
192
+ const expandArrayValueFilter = function(filterSchemaItem, filterKey, value, customFlat) {
193
+ let options = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : {};
194
+ const pathParts = filterKey.split('.');
195
+ const operator = pathParts.pop();
196
+ if ('$dateBetween' === operator && Array.isArray(value)) {
197
+ const valueInfo = (0, util_js_namespaceObject.resolveDatePickerRangeValueInfo)(value, {
198
+ component: options.component,
199
+ showTime: options.showTime,
200
+ preferDateBoundaryFallback: options.useDefaultDateBoundary
201
+ });
202
+ filterSchemaItem[filterKey] = (0, utils_js_namespaceObject.normalizeDateBetweenValue)(value, {
203
+ useDefaultDateBoundary: options.useDefaultDateBoundary,
204
+ valueMode: valueInfo.mode,
205
+ valueSource: valueInfo.source,
206
+ preferDateBoundaryFallback: 'retained-date-boundary' === valueInfo.source
207
+ });
208
+ return;
209
+ }
210
+ if (!Array.isArray(value) || utils_js_namespaceObject.FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator || '')) {
211
+ filterSchemaItem[filterKey] = value;
212
+ return;
213
+ }
214
+ if (0 === value.length) return void delete filterSchemaItem[filterKey];
215
+ let branchEndIndex = -1;
216
+ for(let index = pathParts.length - 2; index >= 0; index--)if ([
217
+ '$and',
218
+ '$or'
219
+ ].includes(pathParts[index]) && /^\d+$/.test(pathParts[index + 1])) {
220
+ branchEndIndex = index;
221
+ break;
222
+ }
223
+ const branchPath = branchEndIndex >= 0 ? pathParts.slice(0, branchEndIndex + 2).join('.') : '';
224
+ const fieldPath = pathParts.slice(branchEndIndex + 2).join('.');
225
+ const conditions = value.map((item)=>customFlat.unflatten({
226
+ ["".concat(fieldPath, ".").concat(operator)]: item
227
+ }));
228
+ delete filterSchemaItem[filterKey];
229
+ filterSchemaItem[branchPath ? "".concat(branchPath, ".$or") : '$or'] = conditions;
230
+ };
155
231
  const getCustomCondition = function(filter, fieldSchema) {
156
232
  let customFlat = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : external_flat_default();
157
233
  var _filterSchema_$and, _filterSchema_$or;
@@ -165,12 +241,14 @@ const getCustomCondition = function(filter, fieldSchema) {
165
241
  {
166
242
  var _flatFieldSchema_$and, _flatFieldSchema_$or;
167
243
  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]];
244
+ const match = 'string' == typeof filterSchemaItem[filterKey] && filterSchemaItem[filterKey].match(CUSTOM_FILTER_VARIABLE_REGEXP);
245
+ if (!match) continue;
246
+ const customFieldSchema = findCustomFieldSchema(fieldSchema, match[1]);
247
+ expandArrayValueFilter(filterSchemaItem, filterKey, getCustomFilterValue(items, match[1], filter || {}), customFlat, {
248
+ useDefaultDateBoundary: (0, utils_js_namespaceObject.shouldUseDefaultDateBoundary)(customFieldSchema),
249
+ component: getDatePickerComponent(customFieldSchema),
250
+ showTime: getDatePickerShowTime(customFieldSchema)
251
+ });
174
252
  }
175
253
  for(const item in filterSchemaItem)if (!filterSchemaItem[item] || filterSchemaItem[item].includes('$nFilter')) delete filterSchemaItem[item];
176
254
  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.19",
4
4
  "homepage": "https://github.com/tegojs/tego-standard#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/tegojs/tego-standard/issues"