@tachybase/client 1.6.15 → 1.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/block-provider/hooks/index.mjs +7 -2
- package/es/built-in/pm/PluginManager.mjs +5 -3
- package/es/collection-manager/templates/components/sql-collection/PreviewTable.mjs +4 -0
- package/es/filter-provider/utils.d.ts +4 -1
- package/es/filter-provider/utils.mjs +38 -6
- package/es/schema-component/antd/date-picker/ReadPretty.mjs +3 -2
- package/es/schema-component/antd/date-picker/util.d.ts +1 -0
- package/es/schema-component/antd/date-picker/util.mjs +11 -3
- package/es/schema-component/antd/form-item/SchemaSettingOptions.d.ts +1 -0
- package/es/schema-component/antd/form-item/SchemaSettingOptions.mjs +20 -3
- package/es/schema-component/antd/grid-card/GridCard.mjs +3 -2
- package/es/schema-component/antd/list/List.mjs +3 -2
- package/es/schema-component/antd/pagination/index.d.ts +1 -0
- package/es/schema-component/antd/pagination/index.mjs +3 -1
- package/es/schema-component/antd/pagination/utils.d.ts +12 -0
- package/es/schema-component/antd/pagination/utils.mjs +22 -0
- package/es/schema-component/antd/table/Table.Void.mjs +3 -2
- package/es/schema-component/antd/table-v2/Table.mjs +2 -1
- package/lib/block-provider/hooks/index.js +7 -2
- package/lib/built-in/pm/PluginManager.js +5 -3
- package/lib/collection-manager/templates/components/sql-collection/PreviewTable.js +4 -0
- package/lib/filter-provider/utils.js +37 -5
- package/lib/schema-component/antd/date-picker/ReadPretty.js +3 -2
- package/lib/schema-component/antd/date-picker/util.js +14 -3
- package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +22 -2
- package/lib/schema-component/antd/grid-card/GridCard.js +3 -2
- package/lib/schema-component/antd/list/List.js +3 -2
- package/lib/schema-component/antd/pagination/index.js +77 -25
- package/lib/schema-component/antd/pagination/utils.js +62 -0
- package/lib/schema-component/antd/table/Table.Void.js +3 -2
- package/lib/schema-component/antd/table-v2/Table.js +2 -1
- package/package.json +1 -1
|
@@ -418,7 +418,7 @@ const useFilterBlockActionProps = ()=>{
|
|
|
418
418
|
const fieldSchema = useFieldSchema();
|
|
419
419
|
const { getDataBlocks } = useFilterBlock();
|
|
420
420
|
const { name } = useCollection_deprecated();
|
|
421
|
-
const { getCollectionJoinField } = useCollectionManager_deprecated();
|
|
421
|
+
const { getCollectionJoinField, getInterface } = useCollectionManager_deprecated();
|
|
422
422
|
actionField.data = actionField.data || {};
|
|
423
423
|
return {
|
|
424
424
|
async onClick () {
|
|
@@ -451,7 +451,12 @@ const useFilterBlockActionProps = ()=>{
|
|
|
451
451
|
for(const key in form.values['__custom'])if (form.values['__custom'][key]) filter.customValues[key] = form.values['__custom'][key];
|
|
452
452
|
filter.customFilter = getCustomCondition(filter.customValues, fieldSchema);
|
|
453
453
|
}
|
|
454
|
-
storedFilter[uid] = removeNullCondition(transformToFilter(filter.formValues, fieldSchema, getCollectionJoinField, name)
|
|
454
|
+
storedFilter[uid] = removeNullCondition(transformToFilter(filter.formValues, fieldSchema, getCollectionJoinField, name, (_, param)=>{
|
|
455
|
+
let { fieldSchema, collectionField } = param;
|
|
456
|
+
var _fieldSchema_xdesignerprops, _getInterface_filterable, _getInterface;
|
|
457
|
+
const fieldInterface = (null == fieldSchema ? void 0 : null == (_fieldSchema_xdesignerprops = fieldSchema['x-designer-props']) ? void 0 : _fieldSchema_xdesignerprops.interface) || (null == collectionField ? void 0 : collectionField.interface);
|
|
458
|
+
return fieldInterface ? (null == (_getInterface = getInterface(fieldInterface)) ? void 0 : null == (_getInterface_filterable = _getInterface.filterable) ? void 0 : _getInterface_filterable.operators) || [] : [];
|
|
459
|
+
}));
|
|
455
460
|
const mergedFilter = utils_mjs_mergeFilter([
|
|
456
461
|
...Object.values(storedFilter).map((filter)=>removeNullCondition(filter)),
|
|
457
462
|
getFilterSourceDefaultFilter(getDataBlocks(), uid),
|
|
@@ -7,6 +7,7 @@ import lodash from "lodash";
|
|
|
7
7
|
import { useTranslation as external_react_i18next_useTranslation } from "react-i18next";
|
|
8
8
|
import { useRequest } from "../../api-client/index.mjs";
|
|
9
9
|
import { i18n } from "../../i18n/index.mjs";
|
|
10
|
+
import { withAutoQuickJumper } from "../../schema-component/index.mjs";
|
|
10
11
|
import "../../style/index.mjs";
|
|
11
12
|
import { useACLRoleContext } from "../acl/index.mjs";
|
|
12
13
|
import { SwitchAction } from "./PluginCard.mjs";
|
|
@@ -295,9 +296,10 @@ const LocalPlugins = ()=>{
|
|
|
295
296
|
columns: columns,
|
|
296
297
|
dataSource: filteredList,
|
|
297
298
|
rowKey: "id",
|
|
298
|
-
pagination: {
|
|
299
|
-
pageSize: 100
|
|
300
|
-
|
|
299
|
+
pagination: withAutoQuickJumper({
|
|
300
|
+
pageSize: 100,
|
|
301
|
+
total: filteredList.length
|
|
302
|
+
})
|
|
301
303
|
})
|
|
302
304
|
]
|
|
303
305
|
})
|
|
@@ -4,6 +4,7 @@ import { Schema, observer, useForm } from "@tachybase/schema";
|
|
|
4
4
|
import { Table } from "antd";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
6
6
|
import { useAsyncData } from "../../../../async-data-provider/index.mjs";
|
|
7
|
+
import { withAutoQuickJumper } from "../../../../schema-component/antd/pagination/utils.mjs";
|
|
7
8
|
const PreviewTable = observer(()=>{
|
|
8
9
|
const { data: res, loading, error } = useAsyncData();
|
|
9
10
|
const { data } = res || {};
|
|
@@ -47,6 +48,9 @@ const PreviewTable = observer(()=>{
|
|
|
47
48
|
bordered: true,
|
|
48
49
|
dataSource: dataSource,
|
|
49
50
|
columns: columns,
|
|
51
|
+
pagination: withAutoQuickJumper({
|
|
52
|
+
total: dataSource.length
|
|
53
|
+
}),
|
|
50
54
|
scroll: {
|
|
51
55
|
x: 150 * columns.length,
|
|
52
56
|
y: 300
|
|
@@ -21,7 +21,10 @@ export declare const getSupportFieldsByForeignKey: (filterBlockCollection: Retur
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
export declare const useSupportedBlocks: (filterBlockType: FilterBlockType) => DataBlock[];
|
|
24
|
-
export declare const transformToFilter: (values: Record<string, any>, fieldSchema: Schema, getCollectionJoinField: (name: string) => CollectionFieldOptions_deprecated, collectionName: string
|
|
24
|
+
export declare const transformToFilter: (values: Record<string, any>, fieldSchema: Schema, getCollectionJoinField: (name: string) => CollectionFieldOptions_deprecated, collectionName: string, getOperatorList?: (path: string, options: {
|
|
25
|
+
fieldSchema?: Schema;
|
|
26
|
+
collectionField?: CollectionFieldOptions_deprecated;
|
|
27
|
+
}) => any[]) => {
|
|
25
28
|
$and: ({
|
|
26
29
|
[x: string]: {
|
|
27
30
|
$isTruly: boolean;
|
|
@@ -6,7 +6,7 @@ import lodash from "lodash";
|
|
|
6
6
|
import { findFilterTargets } from "../block-provider/hooks/index.mjs";
|
|
7
7
|
import { useCollectionManager_deprecated, useCollection_deprecated } from "../collection-manager/index.mjs";
|
|
8
8
|
import { removeNullCondition } from "../schema-component/index.mjs";
|
|
9
|
-
import { findFilterOperators } from "../schema-component/antd/form-item/SchemaSettingOptions.mjs";
|
|
9
|
+
import { findFilterOperators, getDefaultFilterOperatorValue } from "../schema-component/antd/form-item/SchemaSettingOptions.mjs";
|
|
10
10
|
import { useFilterBlock } from "./FilterProvider.mjs";
|
|
11
11
|
import { getFilterSourceDefaultFilter } from "./incomingFilterFromSources.mjs";
|
|
12
12
|
var utils_FilterBlockType = /*#__PURE__*/ function(FilterBlockType) {
|
|
@@ -57,13 +57,44 @@ const useSupportedBlocks = (filterBlockType)=>{
|
|
|
57
57
|
return fieldSchema['x-uid'] !== block.uid && (isSameCollection(block.collection, collection) || (null == (_getSupportFieldsByAssociation = getSupportFieldsByAssociation(getAllCollectionsInheritChain(collection.name, collection.dataSource), block)) ? void 0 : _getSupportFieldsByAssociation.length) || (null == (_getSupportFieldsByForeignKey = getSupportFieldsByForeignKey(collection, block)) ? void 0 : _getSupportFieldsByForeignKey.length));
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
|
-
const
|
|
60
|
+
const findSchemaByName = (schema, name)=>{
|
|
61
|
+
if (!schema) return null;
|
|
62
|
+
if (schema.name === name) return schema;
|
|
63
|
+
const properties = schema.properties || {};
|
|
64
|
+
for (const key of Object.keys(properties)){
|
|
65
|
+
const found = findSchemaByName(properties[key], name);
|
|
66
|
+
if (found) return found;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
const getFilterSchemaRoot = (schema)=>{
|
|
71
|
+
let current = schema;
|
|
72
|
+
while(current){
|
|
73
|
+
if (current['x-filter-operators'] || current['x-filter-targets']) return current;
|
|
74
|
+
current = current.parent;
|
|
75
|
+
}
|
|
76
|
+
return schema;
|
|
77
|
+
};
|
|
78
|
+
const resolveFilterOperator = function(schema, path) {
|
|
79
|
+
let operators = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, getOperatorList = arguments.length > 3 ? arguments[3] : void 0, collectionField = arguments.length > 4 ? arguments[4] : void 0;
|
|
80
|
+
if (operators[path]) return operators[path];
|
|
81
|
+
if (!getOperatorList) return;
|
|
82
|
+
const fieldSchema = findSchemaByName(getFilterSchemaRoot(schema), path);
|
|
83
|
+
const operatorList = getOperatorList(path, {
|
|
84
|
+
fieldSchema,
|
|
85
|
+
collectionField
|
|
86
|
+
}) || [];
|
|
87
|
+
if (!operatorList.length || !fieldSchema) return;
|
|
88
|
+
return getDefaultFilterOperatorValue(fieldSchema, operatorList);
|
|
89
|
+
};
|
|
90
|
+
const transformToFilter = (values, fieldSchema, getCollectionJoinField, collectionName, getOperatorList)=>{
|
|
61
91
|
const { operators } = findFilterOperators(fieldSchema);
|
|
62
92
|
values = flatten(values, {
|
|
63
93
|
breakOn (param) {
|
|
64
94
|
let { value, path } = param;
|
|
65
|
-
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operators[path])) return true;
|
|
66
95
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(path));
|
|
96
|
+
const operator = resolveFilterOperator(fieldSchema, path, operators, getOperatorList, collectionField);
|
|
97
|
+
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator)) return true;
|
|
67
98
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
68
99
|
if (Array.isArray(value)) return true;
|
|
69
100
|
const targetKey = collectionField.targetKey || 'id';
|
|
@@ -77,12 +108,13 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
77
108
|
const defKey = key;
|
|
78
109
|
let value = lodash.get(values, key);
|
|
79
110
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(key));
|
|
111
|
+
const operator = resolveFilterOperator(fieldSchema, defKey, operators, getOperatorList, collectionField);
|
|
80
112
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
81
113
|
value = getValuesByPath(value, collectionField.targetKey || 'id');
|
|
82
114
|
key = "".concat(key, ".").concat(collectionField.targetKey || 'id');
|
|
83
115
|
}
|
|
84
116
|
if (!value) return null;
|
|
85
|
-
if ('$isTruly' ===
|
|
117
|
+
if ('$isTruly' === operator || '$isFalsy' === operator) {
|
|
86
118
|
if ('true' === value) return {
|
|
87
119
|
[key]: {
|
|
88
120
|
$isTruly: true
|
|
@@ -93,7 +125,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
93
125
|
$isFalsy: true
|
|
94
126
|
}
|
|
95
127
|
};
|
|
96
|
-
} else if ('$dateBetween' ===
|
|
128
|
+
} else if ('$dateBetween' === operator) {
|
|
97
129
|
if (Array.isArray(value)) {
|
|
98
130
|
const normalized = [];
|
|
99
131
|
for(const index in value){
|
|
@@ -114,7 +146,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
114
146
|
}
|
|
115
147
|
return {
|
|
116
148
|
[key]: {
|
|
117
|
-
[operators[key] ||
|
|
149
|
+
[operators[key] || operator || '$eq']: value
|
|
118
150
|
}
|
|
119
151
|
};
|
|
120
152
|
}).filter(Boolean)
|
|
@@ -5,13 +5,14 @@ import { getDefaultFormat, str2moment } from "@tego/client";
|
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import dayjs from "dayjs";
|
|
7
7
|
import { usePrefixCls } from "../__builtins__/index.mjs";
|
|
8
|
+
import { normalizeDatePickerParseOptions } from "./util.mjs";
|
|
8
9
|
const ReadPretty = ()=>null;
|
|
9
10
|
ReadPretty.DatePicker = function(props) {
|
|
10
11
|
const prefixCls = usePrefixCls("description-date-picker", props);
|
|
11
12
|
if (!props.value) return /*#__PURE__*/ jsx("div", {});
|
|
12
13
|
const getLabels = ()=>{
|
|
13
14
|
const format = getDefaultFormat(props);
|
|
14
|
-
const m = str2moment(props.value, props);
|
|
15
|
+
const m = str2moment(props.value, normalizeDatePickerParseOptions(props));
|
|
15
16
|
const labels = dayjs.isDayjs(m) ? m.format(format) : '';
|
|
16
17
|
return isArr(labels) ? labels.join('~') : labels;
|
|
17
18
|
};
|
|
@@ -24,7 +25,7 @@ ReadPretty.DateRangePicker = function(props) {
|
|
|
24
25
|
const prefixCls = usePrefixCls("description-text", props);
|
|
25
26
|
const format = getDefaultFormat(props);
|
|
26
27
|
const getLabels = ()=>{
|
|
27
|
-
const m = str2moment(props.value, props);
|
|
28
|
+
const m = str2moment(props.value, normalizeDatePickerParseOptions(props));
|
|
28
29
|
if (!m) return '';
|
|
29
30
|
const labels = m.map((m)=>m.format(format));
|
|
30
31
|
return isArr(labels) ? labels.join('~') : labels;
|
|
@@ -5,6 +5,7 @@ export interface Moment2strOptions {
|
|
|
5
5
|
utc?: boolean;
|
|
6
6
|
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
7
7
|
}
|
|
8
|
+
export declare const normalizeDatePickerParseOptions: (options?: Moment2strOptions) => Moment2strOptions;
|
|
8
9
|
export declare const moment2str: (value?: Dayjs | null, options?: Moment2strOptions) => any;
|
|
9
10
|
export declare const mapDatePicker: () => (props: any) => any;
|
|
10
11
|
export declare const mapRangePicker: () => (props: any) => any;
|
|
@@ -20,6 +20,14 @@ const toLocalByPicker = (value, picker)=>{
|
|
|
20
20
|
if (!value || !dayjs.isDayjs(value)) return value;
|
|
21
21
|
return toStringByPicker(value, picker, 'local');
|
|
22
22
|
};
|
|
23
|
+
const normalizeDatePickerParseOptions = function() {
|
|
24
|
+
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
25
|
+
if (false === options.utc || options.showTime || 'boolean' == typeof options.gmt || options.picker) return options;
|
|
26
|
+
return {
|
|
27
|
+
...options,
|
|
28
|
+
gmt: true
|
|
29
|
+
};
|
|
30
|
+
};
|
|
23
31
|
const moment2str = function(value) {
|
|
24
32
|
let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
25
33
|
const { showTime, gmt, picker, utc = true } = options;
|
|
@@ -39,7 +47,7 @@ const mapDatePicker = function() {
|
|
|
39
47
|
return {
|
|
40
48
|
...props,
|
|
41
49
|
format: format,
|
|
42
|
-
value: str2moment(props.value, props),
|
|
50
|
+
value: str2moment(props.value, normalizeDatePickerParseOptions(props)),
|
|
43
51
|
onChange: (value)=>{
|
|
44
52
|
if (onChange) {
|
|
45
53
|
if (!props.showTime && value) value = value.startOf('day');
|
|
@@ -56,7 +64,7 @@ const mapRangePicker = function() {
|
|
|
56
64
|
return {
|
|
57
65
|
...props,
|
|
58
66
|
format: format,
|
|
59
|
-
value: str2moment(props.value, props),
|
|
67
|
+
value: str2moment(props.value, normalizeDatePickerParseOptions(props)),
|
|
60
68
|
onChange: (value)=>{
|
|
61
69
|
if (onChange) onChange(value ? [
|
|
62
70
|
moment2str(getRangeStart(value[0], props), props),
|
|
@@ -190,4 +198,4 @@ const getDateExact = ()=>({
|
|
|
190
198
|
tomorrowLocal: ()=>dayjs().add(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|
191
199
|
tomorrowDate: ()=>dayjs().add(1, 'day').format('YYYY-MM-DD')
|
|
192
200
|
});
|
|
193
|
-
export { getDateExact, getDateRanges, mapDatePicker, mapRangePicker, moment2str };
|
|
201
|
+
export { getDateExact, getDateRanges, mapDatePicker, mapRangePicker, moment2str, normalizeDatePickerParseOptions };
|
|
@@ -6,6 +6,7 @@ export declare const findFilterOperators: (schema: Schema) => {
|
|
|
6
6
|
operators?: undefined;
|
|
7
7
|
uid?: undefined;
|
|
8
8
|
};
|
|
9
|
+
export declare const getDefaultFilterOperatorValue: (schema: Schema, operatorList?: any[]) => any;
|
|
9
10
|
export declare const EditTitle: () => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export declare const EditDescription: () => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export declare const EditTooltip: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,6 +21,23 @@ const findFilterOperators = (schema)=>{
|
|
|
21
21
|
}
|
|
22
22
|
return {};
|
|
23
23
|
};
|
|
24
|
+
const getSchemaFilterComponent = (schema)=>{
|
|
25
|
+
var _schema_xcomponentprops;
|
|
26
|
+
return (null == schema ? void 0 : null == (_schema_xcomponentprops = schema['x-component-props']) ? void 0 : _schema_xcomponentprops.component) || (null == schema ? void 0 : schema['x-component']);
|
|
27
|
+
};
|
|
28
|
+
const getDefaultFilterOperatorValue = function(schema) {
|
|
29
|
+
let operatorList = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [];
|
|
30
|
+
var _operatorList_find, _operatorList_;
|
|
31
|
+
const component = getSchemaFilterComponent(schema);
|
|
32
|
+
if (component) {
|
|
33
|
+
const matched = operatorList.find((item)=>{
|
|
34
|
+
var _item_schema;
|
|
35
|
+
return (null == item ? void 0 : null == (_item_schema = item.schema) ? void 0 : _item_schema['x-component']) === component;
|
|
36
|
+
});
|
|
37
|
+
if (null == matched ? void 0 : matched.value) return matched.value;
|
|
38
|
+
}
|
|
39
|
+
return (null == (_operatorList_find = operatorList.find((item)=>null == item ? void 0 : item.selected)) ? void 0 : _operatorList_find.value) || (null == (_operatorList_ = operatorList[0]) ? void 0 : _operatorList_.value);
|
|
40
|
+
};
|
|
24
41
|
const EditTitle = ()=>{
|
|
25
42
|
var _collectionField_uiSchema;
|
|
26
43
|
const { getCollectionJoinField } = useCollectionManager_deprecated();
|
|
@@ -428,7 +445,7 @@ const useEnsureOperatorsValid = ()=>{
|
|
|
428
445
|
const fieldSchema = useFieldSchema();
|
|
429
446
|
const operatorList = useOperatorList();
|
|
430
447
|
const { operators: storedOperators } = findFilterOperators(fieldSchema);
|
|
431
|
-
if (storedOperators && operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList
|
|
448
|
+
if (storedOperators && operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = getDefaultFilterOperatorValue(fieldSchema, operatorList);
|
|
432
449
|
};
|
|
433
450
|
const EditOperator = ()=>{
|
|
434
451
|
const compile = useCompile();
|
|
@@ -438,7 +455,7 @@ const EditOperator = ()=>{
|
|
|
438
455
|
const { dn } = useDesignable();
|
|
439
456
|
const operatorList = useOperatorList();
|
|
440
457
|
const { operators: storedOperators = {}, uid } = findFilterOperators(fieldSchema);
|
|
441
|
-
if (operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList
|
|
458
|
+
if (operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = getDefaultFilterOperatorValue(fieldSchema, operatorList);
|
|
442
459
|
return operatorList.length ? /*#__PURE__*/ jsx(SchemaSettingsSelectItem, {
|
|
443
460
|
title: t('Operator'),
|
|
444
461
|
value: storedOperators[fieldSchema.name],
|
|
@@ -559,4 +576,4 @@ const EditTitleField = ()=>{
|
|
|
559
576
|
}
|
|
560
577
|
}, "title-field") : null;
|
|
561
578
|
};
|
|
562
|
-
export { EditComponent, EditDefaultValue, EditDescription, EditOperator, EditPattern, EditRequired, EditTitle, EditTitleField, EditTooltip, EditValidationRules, findFilterOperators, useEnsureOperatorsValid };
|
|
579
|
+
export { EditComponent, EditDefaultValue, EditDescription, EditOperator, EditPattern, EditRequired, EditTitle, EditTitleField, EditTooltip, EditValidationRules, findFilterOperators, getDefaultFilterOperatorValue, useEnsureOperatorsValid };
|
|
@@ -9,6 +9,7 @@ import { SortableItem } from "../../common/index.mjs";
|
|
|
9
9
|
import { InfiniteScroll } from "../../common/infinite-scroll/infinite-scroll.mjs";
|
|
10
10
|
import { SchemaComponentOptions } from "../../core/index.mjs";
|
|
11
11
|
import { useDesigner, useProps } from "../../hooks/index.mjs";
|
|
12
|
+
import { withAutoQuickJumper } from "../pagination/utils.mjs";
|
|
12
13
|
import { GridCardBlockProvider, useGridCardBlockContext, useGridCardItemProps } from "./GridCard.Decorator.mjs";
|
|
13
14
|
import { GridCardDesigner } from "./GridCard.Designer.mjs";
|
|
14
15
|
import { GridCardItem } from "./GridCard.Item.mjs";
|
|
@@ -106,14 +107,14 @@ const InternalGridCard = (props)=>{
|
|
|
106
107
|
className: classnames('tb-card-list', styles.designer),
|
|
107
108
|
children: [
|
|
108
109
|
/*#__PURE__*/ jsx(List, {
|
|
109
|
-
pagination: !meta || meta.count <= meta.pageSize || needInfiniteScroll ? false : {
|
|
110
|
+
pagination: !meta || meta.count <= meta.pageSize || needInfiniteScroll ? false : withAutoQuickJumper({
|
|
110
111
|
...pagination,
|
|
111
112
|
onChange: onPaginationChange,
|
|
112
113
|
total: (null == meta ? void 0 : meta.count) || 0,
|
|
113
114
|
pageSize: (null == meta ? void 0 : meta.pageSize) || 10,
|
|
114
115
|
current: (null == meta ? void 0 : meta.page) || 1,
|
|
115
116
|
pageSizeOptions: pageSizeOptions
|
|
116
|
-
},
|
|
117
|
+
}),
|
|
117
118
|
dataSource: field.value,
|
|
118
119
|
grid: {
|
|
119
120
|
...columnCount,
|
|
@@ -7,6 +7,7 @@ import { withDynamicSchemaProps } from "../../../application/hoc/withDynamicSche
|
|
|
7
7
|
import { SortableItem } from "../../common/index.mjs";
|
|
8
8
|
import { SchemaComponentOptions } from "../../core/index.mjs";
|
|
9
9
|
import { useDesigner } from "../../hooks/index.mjs";
|
|
10
|
+
import { withAutoQuickJumper } from "../pagination/utils.mjs";
|
|
10
11
|
import { useListActionBarProps } from "./hooks.mjs";
|
|
11
12
|
import { ListBlockProvider, useListBlockContext, useListItemProps } from "./List.Decorator.mjs";
|
|
12
13
|
import { ListDesigner } from "./List.Designer.mjs";
|
|
@@ -54,12 +55,12 @@ const InternalList = (props)=>{
|
|
|
54
55
|
children: [
|
|
55
56
|
/*#__PURE__*/ jsx(List, {
|
|
56
57
|
...props,
|
|
57
|
-
pagination: !meta || meta.count <= meta.pageSize ? false : {
|
|
58
|
+
pagination: !meta || meta.count <= meta.pageSize ? false : withAutoQuickJumper({
|
|
58
59
|
onChange: onPaginationChange,
|
|
59
60
|
total: (null == meta ? void 0 : meta.count) || 0,
|
|
60
61
|
pageSize: (null == meta ? void 0 : meta.pageSize) || 10,
|
|
61
62
|
current: (null == meta ? void 0 : meta.page) || 1
|
|
62
|
-
},
|
|
63
|
+
}),
|
|
63
64
|
loading: null == service ? void 0 : service.loading,
|
|
64
65
|
children: (null == (_field_value = field.value) ? void 0 : _field_value.length) ? field.value.map((item, index)=>/*#__PURE__*/ jsx(RecursionField, {
|
|
65
66
|
basePath: field.address,
|
|
@@ -4,6 +4,8 @@ import { observer } from "@tachybase/schema";
|
|
|
4
4
|
import { Pagination } from "antd";
|
|
5
5
|
import { withDynamicSchemaProps } from "../../../application/hoc/withDynamicSchemaProps.mjs";
|
|
6
6
|
import { useProps } from "../../hooks/useProps.mjs";
|
|
7
|
+
import { withAutoQuickJumper } from "./utils.mjs";
|
|
8
|
+
export * from "./utils.mjs";
|
|
7
9
|
const pagination_Pagination = withDynamicSchemaProps(observer((props)=>{
|
|
8
10
|
const { hidden, ...others } = useProps(props);
|
|
9
11
|
if (hidden) return null;
|
|
@@ -13,7 +15,7 @@ const pagination_Pagination = withDynamicSchemaProps(observer((props)=>{
|
|
|
13
15
|
return /*#__PURE__*/ jsx("div", {
|
|
14
16
|
onKeyPress: onKeypress,
|
|
15
17
|
children: /*#__PURE__*/ jsx(Pagination, {
|
|
16
|
-
...others
|
|
18
|
+
...withAutoQuickJumper(others)
|
|
17
19
|
})
|
|
18
20
|
});
|
|
19
21
|
}, {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type PaginationLike = {
|
|
2
|
+
defaultPageSize?: number;
|
|
3
|
+
pageSize?: number;
|
|
4
|
+
showLessItems?: boolean;
|
|
5
|
+
showQuickJumper?: unknown;
|
|
6
|
+
simple?: unknown;
|
|
7
|
+
total?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const getPaginationPageCount: (pagination?: PaginationLike) => number;
|
|
10
|
+
export declare const shouldAutoEnableQuickJumper: (pagination?: PaginationLike) => boolean;
|
|
11
|
+
export declare const withAutoQuickJumper: <T extends PaginationLike | false | undefined>(pagination: T) => T;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
2
|
+
const getPageBufferSize = (showLessItems)=>showLessItems ? 1 : 2;
|
|
3
|
+
const getQuickJumperAutoThreshold = (showLessItems)=>2 * getPageBufferSize(showLessItems) + 3;
|
|
4
|
+
const getPaginationPageCount = (pagination)=>{
|
|
5
|
+
if (!pagination) return 0;
|
|
6
|
+
const total = Number(pagination.total);
|
|
7
|
+
const pageSize = Number(pagination.pageSize || pagination.defaultPageSize || DEFAULT_PAGE_SIZE);
|
|
8
|
+
if (!Number.isFinite(total) || total <= 0 || !Number.isFinite(pageSize) || pageSize <= 0) return 0;
|
|
9
|
+
return Math.ceil(total / pageSize);
|
|
10
|
+
};
|
|
11
|
+
const shouldAutoEnableQuickJumper = (pagination)=>{
|
|
12
|
+
if (!pagination || void 0 !== pagination.showQuickJumper || pagination.simple) return false;
|
|
13
|
+
return getPaginationPageCount(pagination) > getQuickJumperAutoThreshold(pagination.showLessItems);
|
|
14
|
+
};
|
|
15
|
+
const withAutoQuickJumper = (pagination)=>{
|
|
16
|
+
if (!pagination || false === pagination || !shouldAutoEnableQuickJumper(pagination)) return pagination;
|
|
17
|
+
return {
|
|
18
|
+
...pagination,
|
|
19
|
+
showQuickJumper: true
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export { getPaginationPageCount, shouldAutoEnableQuickJumper, withAutoQuickJumper };
|
|
@@ -4,6 +4,7 @@ import { FieldContext, FormContext, createForm, observer, useField, useFieldSche
|
|
|
4
4
|
import { cloneDeep } from "lodash";
|
|
5
5
|
import { AsyncDataProvider, useAsyncData, useRequest } from "../../../index.mjs";
|
|
6
6
|
import { useAttach } from "../../hooks/index.mjs";
|
|
7
|
+
import { withAutoQuickJumper } from "../pagination/utils.mjs";
|
|
7
8
|
import { TableArray } from "./Table.Array.mjs";
|
|
8
9
|
const usePaginationProps = (props, service)=>{
|
|
9
10
|
var _props_request_params, _props_request, _service_data;
|
|
@@ -19,7 +20,7 @@ const usePaginationProps = (props, service)=>{
|
|
|
19
20
|
pagination.current = page;
|
|
20
21
|
pagination.pageSize = pageSize;
|
|
21
22
|
}
|
|
22
|
-
return {
|
|
23
|
+
return withAutoQuickJumper({
|
|
23
24
|
showSizeChanger: true,
|
|
24
25
|
...pagination,
|
|
25
26
|
onChange (page, pageSize) {
|
|
@@ -30,7 +31,7 @@ const usePaginationProps = (props, service)=>{
|
|
|
30
31
|
pageSize
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
};
|
|
34
|
+
});
|
|
34
35
|
};
|
|
35
36
|
const useRequestProps = (props)=>{
|
|
36
37
|
const { request, pagination, dataSource } = props;
|
|
@@ -16,6 +16,7 @@ import { withDynamicSchemaProps } from "../../../application/hoc/withDynamicSche
|
|
|
16
16
|
import { isNewRecord, markRecordAsNew } from "../../../data-source/collection-record/isNewRecord.mjs";
|
|
17
17
|
import { DeclareVariable } from "../../../modules/variable/DeclareVariable.mjs";
|
|
18
18
|
import { SubFormProvider } from "../association-field/hooks.mjs";
|
|
19
|
+
import { withAutoQuickJumper } from "../pagination/utils.mjs";
|
|
19
20
|
import { ColumnFieldProvider } from "./components/ColumnFieldProvider.mjs";
|
|
20
21
|
import { useStyles } from "./Table.styles.mjs";
|
|
21
22
|
import { extractIndex, isCollectionFieldComponent, isColumnComponent } from "./utils.mjs";
|
|
@@ -229,7 +230,7 @@ const usePaginationProps = (pagination1, pagination2)=>{
|
|
|
229
230
|
...pagination1,
|
|
230
231
|
...pagination2
|
|
231
232
|
};
|
|
232
|
-
return result.total ? result : false;
|
|
233
|
+
return result.total ? withAutoQuickJumper(result) : false;
|
|
233
234
|
};
|
|
234
235
|
const Table_Table = withDynamicSchemaProps(observer((props)=>{
|
|
235
236
|
var _schema_parent, _field_data, _field_value_slice_filter, _field_value_slice, _field_value_slice1, _field_value, _fieldSchema_parent_xdecoratorprops, _fieldSchema_parent;
|
|
@@ -734,7 +734,7 @@ var __webpack_exports__ = {};
|
|
|
734
734
|
const fieldSchema = (0, _tachybase_schema__WEBPACK_IMPORTED_MODULE_1__.useFieldSchema)();
|
|
735
735
|
const { getDataBlocks } = (0, _filter_provider_FilterProvider__WEBPACK_IMPORTED_MODULE_15__.useFilterBlock)();
|
|
736
736
|
const { name } = (0, _collection_manager__WEBPACK_IMPORTED_MODULE_14__.useCollection_deprecated)();
|
|
737
|
-
const { getCollectionJoinField } = (0, _collection_manager__WEBPACK_IMPORTED_MODULE_14__.useCollectionManager_deprecated)();
|
|
737
|
+
const { getCollectionJoinField, getInterface } = (0, _collection_manager__WEBPACK_IMPORTED_MODULE_14__.useCollectionManager_deprecated)();
|
|
738
738
|
actionField.data = actionField.data || {};
|
|
739
739
|
return {
|
|
740
740
|
async onClick () {
|
|
@@ -767,7 +767,12 @@ var __webpack_exports__ = {};
|
|
|
767
767
|
for(const key in form.values['__custom'])if (form.values['__custom'][key]) filter.customValues[key] = form.values['__custom'][key];
|
|
768
768
|
filter.customFilter = (0, _schema_component__WEBPACK_IMPORTED_MODULE_19__.getCustomCondition)(filter.customValues, fieldSchema);
|
|
769
769
|
}
|
|
770
|
-
storedFilter[uid] = (0, _schema_component__WEBPACK_IMPORTED_MODULE_19__.removeNullCondition)((0, _filter_provider_utils__WEBPACK_IMPORTED_MODULE_17__.transformToFilter)(filter.formValues, fieldSchema, getCollectionJoinField, name)
|
|
770
|
+
storedFilter[uid] = (0, _schema_component__WEBPACK_IMPORTED_MODULE_19__.removeNullCondition)((0, _filter_provider_utils__WEBPACK_IMPORTED_MODULE_17__.transformToFilter)(filter.formValues, fieldSchema, getCollectionJoinField, name, (_, param)=>{
|
|
771
|
+
let { fieldSchema, collectionField } = param;
|
|
772
|
+
var _fieldSchema_xdesignerprops, _getInterface_filterable, _getInterface;
|
|
773
|
+
const fieldInterface = (null == fieldSchema ? void 0 : null == (_fieldSchema_xdesignerprops = fieldSchema['x-designer-props']) ? void 0 : _fieldSchema_xdesignerprops.interface) || (null == collectionField ? void 0 : collectionField.interface);
|
|
774
|
+
return fieldInterface ? (null == (_getInterface = getInterface(fieldInterface)) ? void 0 : null == (_getInterface_filterable = _getInterface.filterable) ? void 0 : _getInterface_filterable.operators) || [] : [];
|
|
775
|
+
}));
|
|
771
776
|
const mergedFilter = (0, _filter_provider_utils__WEBPACK_IMPORTED_MODULE_17__.mergeFilter)([
|
|
772
777
|
...Object.values(storedFilter).map((filter)=>(0, _schema_component__WEBPACK_IMPORTED_MODULE_19__.removeNullCondition)(filter)),
|
|
773
778
|
(0, _filter_provider_incomingFilterFromSources__WEBPACK_IMPORTED_MODULE_16__.getFilterSourceDefaultFilter)(getDataBlocks(), uid),
|
|
@@ -45,6 +45,7 @@ var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodas
|
|
|
45
45
|
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
46
46
|
const index_js_namespaceObject = require("../../api-client/index.js");
|
|
47
47
|
const external_i18n_index_js_namespaceObject = require("../../i18n/index.js");
|
|
48
|
+
const external_schema_component_index_js_namespaceObject = require("../../schema-component/index.js");
|
|
48
49
|
require("../../style/index.js");
|
|
49
50
|
const external_acl_index_js_namespaceObject = require("../acl/index.js");
|
|
50
51
|
const external_PluginCard_js_namespaceObject = require("./PluginCard.js");
|
|
@@ -333,9 +334,10 @@ const LocalPlugins = ()=>{
|
|
|
333
334
|
columns: columns,
|
|
334
335
|
dataSource: filteredList,
|
|
335
336
|
rowKey: "id",
|
|
336
|
-
pagination: {
|
|
337
|
-
pageSize: 100
|
|
338
|
-
|
|
337
|
+
pagination: (0, external_schema_component_index_js_namespaceObject.withAutoQuickJumper)({
|
|
338
|
+
pageSize: 100,
|
|
339
|
+
total: filteredList.length
|
|
340
|
+
})
|
|
339
341
|
})
|
|
340
342
|
]
|
|
341
343
|
})
|
|
@@ -32,6 +32,7 @@ const schema_namespaceObject = require("@tachybase/schema");
|
|
|
32
32
|
const external_antd_namespaceObject = require("antd");
|
|
33
33
|
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
34
34
|
const index_js_namespaceObject = require("../../../../async-data-provider/index.js");
|
|
35
|
+
const utils_js_namespaceObject = require("../../../../schema-component/antd/pagination/utils.js");
|
|
35
36
|
const PreviewTable = (0, schema_namespaceObject.observer)(()=>{
|
|
36
37
|
const { data: res, loading, error } = (0, index_js_namespaceObject.useAsyncData)();
|
|
37
38
|
const { data } = res || {};
|
|
@@ -75,6 +76,9 @@ const PreviewTable = (0, schema_namespaceObject.observer)(()=>{
|
|
|
75
76
|
bordered: true,
|
|
76
77
|
dataSource: dataSource,
|
|
77
78
|
columns: columns,
|
|
79
|
+
pagination: (0, utils_js_namespaceObject.withAutoQuickJumper)({
|
|
80
|
+
total: dataSource.length
|
|
81
|
+
}),
|
|
78
82
|
scroll: {
|
|
79
83
|
x: 150 * columns.length,
|
|
80
84
|
y: 300
|
|
@@ -107,13 +107,44 @@ const useSupportedBlocks = (filterBlockType)=>{
|
|
|
107
107
|
return fieldSchema['x-uid'] !== block.uid && (isSameCollection(block.collection, collection) || (null == (_getSupportFieldsByAssociation = getSupportFieldsByAssociation(getAllCollectionsInheritChain(collection.name, collection.dataSource), block)) ? void 0 : _getSupportFieldsByAssociation.length) || (null == (_getSupportFieldsByForeignKey = getSupportFieldsByForeignKey(collection, block)) ? void 0 : _getSupportFieldsByForeignKey.length));
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
|
-
const
|
|
110
|
+
const findSchemaByName = (schema, name)=>{
|
|
111
|
+
if (!schema) return null;
|
|
112
|
+
if (schema.name === name) return schema;
|
|
113
|
+
const properties = schema.properties || {};
|
|
114
|
+
for (const key of Object.keys(properties)){
|
|
115
|
+
const found = findSchemaByName(properties[key], name);
|
|
116
|
+
if (found) return found;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
};
|
|
120
|
+
const getFilterSchemaRoot = (schema)=>{
|
|
121
|
+
let current = schema;
|
|
122
|
+
while(current){
|
|
123
|
+
if (current['x-filter-operators'] || current['x-filter-targets']) return current;
|
|
124
|
+
current = current.parent;
|
|
125
|
+
}
|
|
126
|
+
return schema;
|
|
127
|
+
};
|
|
128
|
+
const resolveFilterOperator = function(schema, path) {
|
|
129
|
+
let operators = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, getOperatorList = arguments.length > 3 ? arguments[3] : void 0, collectionField = arguments.length > 4 ? arguments[4] : void 0;
|
|
130
|
+
if (operators[path]) return operators[path];
|
|
131
|
+
if (!getOperatorList) return;
|
|
132
|
+
const fieldSchema = findSchemaByName(getFilterSchemaRoot(schema), path);
|
|
133
|
+
const operatorList = getOperatorList(path, {
|
|
134
|
+
fieldSchema,
|
|
135
|
+
collectionField
|
|
136
|
+
}) || [];
|
|
137
|
+
if (!operatorList.length || !fieldSchema) return;
|
|
138
|
+
return (0, SchemaSettingOptions_js_namespaceObject.getDefaultFilterOperatorValue)(fieldSchema, operatorList);
|
|
139
|
+
};
|
|
140
|
+
const transformToFilter = (values, fieldSchema, getCollectionJoinField, collectionName, getOperatorList)=>{
|
|
111
141
|
const { operators } = (0, SchemaSettingOptions_js_namespaceObject.findFilterOperators)(fieldSchema);
|
|
112
142
|
values = (0, client_namespaceObject.flatten)(values, {
|
|
113
143
|
breakOn (param) {
|
|
114
144
|
let { value, path } = param;
|
|
115
|
-
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operators[path])) return true;
|
|
116
145
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(path));
|
|
146
|
+
const operator = resolveFilterOperator(fieldSchema, path, operators, getOperatorList, collectionField);
|
|
147
|
+
if (FILTER_OPERATORS_WITH_ARRAY_VALUES.has(operator)) return true;
|
|
117
148
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
118
149
|
if (Array.isArray(value)) return true;
|
|
119
150
|
const targetKey = collectionField.targetKey || 'id';
|
|
@@ -127,12 +158,13 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
127
158
|
const defKey = key;
|
|
128
159
|
let value = external_lodash_default().get(values, key);
|
|
129
160
|
const collectionField = getCollectionJoinField("".concat(collectionName, ".").concat(key));
|
|
161
|
+
const operator = resolveFilterOperator(fieldSchema, defKey, operators, getOperatorList, collectionField);
|
|
130
162
|
if (null == collectionField ? void 0 : collectionField.target) {
|
|
131
163
|
value = (0, client_namespaceObject.getValuesByPath)(value, collectionField.targetKey || 'id');
|
|
132
164
|
key = "".concat(key, ".").concat(collectionField.targetKey || 'id');
|
|
133
165
|
}
|
|
134
166
|
if (!value) return null;
|
|
135
|
-
if ('$isTruly' ===
|
|
167
|
+
if ('$isTruly' === operator || '$isFalsy' === operator) {
|
|
136
168
|
if ('true' === value) return {
|
|
137
169
|
[key]: {
|
|
138
170
|
$isTruly: true
|
|
@@ -143,7 +175,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
143
175
|
$isFalsy: true
|
|
144
176
|
}
|
|
145
177
|
};
|
|
146
|
-
} else if ('$dateBetween' ===
|
|
178
|
+
} else if ('$dateBetween' === operator) {
|
|
147
179
|
if (Array.isArray(value)) {
|
|
148
180
|
const normalized = [];
|
|
149
181
|
for(const index in value){
|
|
@@ -164,7 +196,7 @@ const transformToFilter = (values, fieldSchema, getCollectionJoinField, collecti
|
|
|
164
196
|
}
|
|
165
197
|
return {
|
|
166
198
|
[key]: {
|
|
167
|
-
[operators[key] ||
|
|
199
|
+
[operators[key] || operator || '$eq']: value
|
|
168
200
|
}
|
|
169
201
|
};
|
|
170
202
|
}).filter(Boolean)
|
|
@@ -44,13 +44,14 @@ var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_c
|
|
|
44
44
|
const external_dayjs_namespaceObject = require("dayjs");
|
|
45
45
|
var external_dayjs_default = /*#__PURE__*/ __webpack_require__.n(external_dayjs_namespaceObject);
|
|
46
46
|
const index_js_namespaceObject = require("../__builtins__/index.js");
|
|
47
|
+
const external_util_js_namespaceObject = require("./util.js");
|
|
47
48
|
const ReadPretty = ()=>null;
|
|
48
49
|
ReadPretty.DatePicker = function(props) {
|
|
49
50
|
const prefixCls = (0, index_js_namespaceObject.usePrefixCls)("description-date-picker", props);
|
|
50
51
|
if (!props.value) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {});
|
|
51
52
|
const getLabels = ()=>{
|
|
52
53
|
const format = (0, client_namespaceObject.getDefaultFormat)(props);
|
|
53
|
-
const m = (0, client_namespaceObject.str2moment)(props.value, props);
|
|
54
|
+
const m = (0, client_namespaceObject.str2moment)(props.value, (0, external_util_js_namespaceObject.normalizeDatePickerParseOptions)(props));
|
|
54
55
|
const labels = external_dayjs_default().isDayjs(m) ? m.format(format) : '';
|
|
55
56
|
return (0, schema_namespaceObject.isArr)(labels) ? labels.join('~') : labels;
|
|
56
57
|
};
|
|
@@ -63,7 +64,7 @@ ReadPretty.DateRangePicker = function(props) {
|
|
|
63
64
|
const prefixCls = (0, index_js_namespaceObject.usePrefixCls)("description-text", props);
|
|
64
65
|
const format = (0, client_namespaceObject.getDefaultFormat)(props);
|
|
65
66
|
const getLabels = ()=>{
|
|
66
|
-
const m = (0, client_namespaceObject.str2moment)(props.value, props);
|
|
67
|
+
const m = (0, client_namespaceObject.str2moment)(props.value, (0, external_util_js_namespaceObject.normalizeDatePickerParseOptions)(props));
|
|
67
68
|
if (!m) return '';
|
|
68
69
|
const labels = m.map((m)=>m.format(format));
|
|
69
70
|
return (0, schema_namespaceObject.isArr)(labels) ? labels.join('~') : labels;
|
|
@@ -36,6 +36,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
mapRangePicker: ()=>mapRangePicker,
|
|
37
37
|
moment2str: ()=>moment2str,
|
|
38
38
|
mapDatePicker: ()=>mapDatePicker,
|
|
39
|
+
normalizeDatePickerParseOptions: ()=>normalizeDatePickerParseOptions,
|
|
39
40
|
getDateExact: ()=>getDateExact,
|
|
40
41
|
getDateRanges: ()=>getDateRanges
|
|
41
42
|
});
|
|
@@ -62,6 +63,14 @@ const toLocalByPicker = (value, picker)=>{
|
|
|
62
63
|
if (!value || !external_dayjs_default().isDayjs(value)) return value;
|
|
63
64
|
return toStringByPicker(value, picker, 'local');
|
|
64
65
|
};
|
|
66
|
+
const normalizeDatePickerParseOptions = function() {
|
|
67
|
+
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
68
|
+
if (false === options.utc || options.showTime || 'boolean' == typeof options.gmt || options.picker) return options;
|
|
69
|
+
return {
|
|
70
|
+
...options,
|
|
71
|
+
gmt: true
|
|
72
|
+
};
|
|
73
|
+
};
|
|
65
74
|
const moment2str = function(value) {
|
|
66
75
|
let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
|
67
76
|
const { showTime, gmt, picker, utc = true } = options;
|
|
@@ -81,7 +90,7 @@ const mapDatePicker = function() {
|
|
|
81
90
|
return {
|
|
82
91
|
...props,
|
|
83
92
|
format: format,
|
|
84
|
-
value: (0, client_namespaceObject.str2moment)(props.value, props),
|
|
93
|
+
value: (0, client_namespaceObject.str2moment)(props.value, normalizeDatePickerParseOptions(props)),
|
|
85
94
|
onChange: (value)=>{
|
|
86
95
|
if (onChange) {
|
|
87
96
|
if (!props.showTime && value) value = value.startOf('day');
|
|
@@ -98,7 +107,7 @@ const mapRangePicker = function() {
|
|
|
98
107
|
return {
|
|
99
108
|
...props,
|
|
100
109
|
format: format,
|
|
101
|
-
value: (0, client_namespaceObject.str2moment)(props.value, props),
|
|
110
|
+
value: (0, client_namespaceObject.str2moment)(props.value, normalizeDatePickerParseOptions(props)),
|
|
102
111
|
onChange: (value)=>{
|
|
103
112
|
if (onChange) onChange(value ? [
|
|
104
113
|
moment2str(getRangeStart(value[0], props), props),
|
|
@@ -237,12 +246,14 @@ exports.getDateRanges = __webpack_exports__.getDateRanges;
|
|
|
237
246
|
exports.mapDatePicker = __webpack_exports__.mapDatePicker;
|
|
238
247
|
exports.mapRangePicker = __webpack_exports__.mapRangePicker;
|
|
239
248
|
exports.moment2str = __webpack_exports__.moment2str;
|
|
249
|
+
exports.normalizeDatePickerParseOptions = __webpack_exports__.normalizeDatePickerParseOptions;
|
|
240
250
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
241
251
|
"getDateExact",
|
|
242
252
|
"getDateRanges",
|
|
243
253
|
"mapDatePicker",
|
|
244
254
|
"mapRangePicker",
|
|
245
|
-
"moment2str"
|
|
255
|
+
"moment2str",
|
|
256
|
+
"normalizeDatePickerParseOptions"
|
|
246
257
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
247
258
|
Object.defineProperty(exports, '__esModule', {
|
|
248
259
|
value: true
|
|
@@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
38
38
|
EditRequired: ()=>EditRequired,
|
|
39
39
|
EditValidationRules: ()=>EditValidationRules,
|
|
40
40
|
findFilterOperators: ()=>findFilterOperators,
|
|
41
|
+
getDefaultFilterOperatorValue: ()=>getDefaultFilterOperatorValue,
|
|
41
42
|
useEnsureOperatorsValid: ()=>useEnsureOperatorsValid,
|
|
42
43
|
EditTooltip: ()=>EditTooltip,
|
|
43
44
|
EditTitleField: ()=>EditTitleField,
|
|
@@ -70,6 +71,23 @@ const findFilterOperators = (schema)=>{
|
|
|
70
71
|
}
|
|
71
72
|
return {};
|
|
72
73
|
};
|
|
74
|
+
const getSchemaFilterComponent = (schema)=>{
|
|
75
|
+
var _schema_xcomponentprops;
|
|
76
|
+
return (null == schema ? void 0 : null == (_schema_xcomponentprops = schema['x-component-props']) ? void 0 : _schema_xcomponentprops.component) || (null == schema ? void 0 : schema['x-component']);
|
|
77
|
+
};
|
|
78
|
+
const getDefaultFilterOperatorValue = function(schema) {
|
|
79
|
+
let operatorList = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [];
|
|
80
|
+
var _operatorList_find, _operatorList_;
|
|
81
|
+
const component = getSchemaFilterComponent(schema);
|
|
82
|
+
if (component) {
|
|
83
|
+
const matched = operatorList.find((item)=>{
|
|
84
|
+
var _item_schema;
|
|
85
|
+
return (null == item ? void 0 : null == (_item_schema = item.schema) ? void 0 : _item_schema['x-component']) === component;
|
|
86
|
+
});
|
|
87
|
+
if (null == matched ? void 0 : matched.value) return matched.value;
|
|
88
|
+
}
|
|
89
|
+
return (null == (_operatorList_find = operatorList.find((item)=>null == item ? void 0 : item.selected)) ? void 0 : _operatorList_find.value) || (null == (_operatorList_ = operatorList[0]) ? void 0 : _operatorList_.value);
|
|
90
|
+
};
|
|
73
91
|
const EditTitle = ()=>{
|
|
74
92
|
var _collectionField_uiSchema;
|
|
75
93
|
const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
|
|
@@ -477,7 +495,7 @@ const useEnsureOperatorsValid = ()=>{
|
|
|
477
495
|
const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
|
|
478
496
|
const operatorList = (0, useOperators_js_namespaceObject.useOperatorList)();
|
|
479
497
|
const { operators: storedOperators } = findFilterOperators(fieldSchema);
|
|
480
|
-
if (storedOperators && operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList
|
|
498
|
+
if (storedOperators && operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = getDefaultFilterOperatorValue(fieldSchema, operatorList);
|
|
481
499
|
};
|
|
482
500
|
const EditOperator = ()=>{
|
|
483
501
|
const compile = (0, external_hooks_index_js_namespaceObject.useCompile)();
|
|
@@ -487,7 +505,7 @@ const EditOperator = ()=>{
|
|
|
487
505
|
const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
|
|
488
506
|
const operatorList = (0, useOperators_js_namespaceObject.useOperatorList)();
|
|
489
507
|
const { operators: storedOperators = {}, uid } = findFilterOperators(fieldSchema);
|
|
490
|
-
if (operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList
|
|
508
|
+
if (operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = getDefaultFilterOperatorValue(fieldSchema, operatorList);
|
|
491
509
|
return operatorList.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
|
|
492
510
|
title: t('Operator'),
|
|
493
511
|
value: storedOperators[fieldSchema.name],
|
|
@@ -619,6 +637,7 @@ exports.EditTitleField = __webpack_exports__.EditTitleField;
|
|
|
619
637
|
exports.EditTooltip = __webpack_exports__.EditTooltip;
|
|
620
638
|
exports.EditValidationRules = __webpack_exports__.EditValidationRules;
|
|
621
639
|
exports.findFilterOperators = __webpack_exports__.findFilterOperators;
|
|
640
|
+
exports.getDefaultFilterOperatorValue = __webpack_exports__.getDefaultFilterOperatorValue;
|
|
622
641
|
exports.useEnsureOperatorsValid = __webpack_exports__.useEnsureOperatorsValid;
|
|
623
642
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
624
643
|
"EditComponent",
|
|
@@ -632,6 +651,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
632
651
|
"EditTooltip",
|
|
633
652
|
"EditValidationRules",
|
|
634
653
|
"findFilterOperators",
|
|
654
|
+
"getDefaultFilterOperatorValue",
|
|
635
655
|
"useEnsureOperatorsValid"
|
|
636
656
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
637
657
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -47,6 +47,7 @@ const index_js_namespaceObject = require("../../common/index.js");
|
|
|
47
47
|
const infinite_scroll_js_namespaceObject = require("../../common/infinite-scroll/infinite-scroll.js");
|
|
48
48
|
const external_core_index_js_namespaceObject = require("../../core/index.js");
|
|
49
49
|
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
|
|
50
|
+
const utils_js_namespaceObject = require("../pagination/utils.js");
|
|
50
51
|
const external_GridCard_Decorator_js_namespaceObject = require("./GridCard.Decorator.js");
|
|
51
52
|
const external_GridCard_Designer_js_namespaceObject = require("./GridCard.Designer.js");
|
|
52
53
|
const external_GridCard_Item_js_namespaceObject = require("./GridCard.Item.js");
|
|
@@ -144,14 +145,14 @@ const InternalGridCard = (props)=>{
|
|
|
144
145
|
className: external_classnames_default()('tb-card-list', styles.designer),
|
|
145
146
|
children: [
|
|
146
147
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.List, {
|
|
147
|
-
pagination: !meta || meta.count <= meta.pageSize || needInfiniteScroll ? false : {
|
|
148
|
+
pagination: !meta || meta.count <= meta.pageSize || needInfiniteScroll ? false : (0, utils_js_namespaceObject.withAutoQuickJumper)({
|
|
148
149
|
...pagination,
|
|
149
150
|
onChange: onPaginationChange,
|
|
150
151
|
total: (null == meta ? void 0 : meta.count) || 0,
|
|
151
152
|
pageSize: (null == meta ? void 0 : meta.pageSize) || 10,
|
|
152
153
|
current: (null == meta ? void 0 : meta.page) || 1,
|
|
153
154
|
pageSizeOptions: external_options_js_namespaceObject.pageSizeOptions
|
|
154
|
-
},
|
|
155
|
+
}),
|
|
155
156
|
dataSource: field.value,
|
|
156
157
|
grid: {
|
|
157
158
|
...columnCount,
|
|
@@ -45,6 +45,7 @@ const withDynamicSchemaProps_js_namespaceObject = require("../../../application/
|
|
|
45
45
|
const index_js_namespaceObject = require("../../common/index.js");
|
|
46
46
|
const external_core_index_js_namespaceObject = require("../../core/index.js");
|
|
47
47
|
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
|
|
48
|
+
const utils_js_namespaceObject = require("../pagination/utils.js");
|
|
48
49
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
49
50
|
const external_List_Decorator_js_namespaceObject = require("./List.Decorator.js");
|
|
50
51
|
const external_List_Designer_js_namespaceObject = require("./List.Designer.js");
|
|
@@ -93,12 +94,12 @@ const InternalList = (props)=>{
|
|
|
93
94
|
children: [
|
|
94
95
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.List, {
|
|
95
96
|
...props,
|
|
96
|
-
pagination: !meta || meta.count <= meta.pageSize ? false : {
|
|
97
|
+
pagination: !meta || meta.count <= meta.pageSize ? false : (0, utils_js_namespaceObject.withAutoQuickJumper)({
|
|
97
98
|
onChange: onPaginationChange,
|
|
98
99
|
total: (null == meta ? void 0 : meta.count) || 0,
|
|
99
100
|
pageSize: (null == meta ? void 0 : meta.pageSize) || 10,
|
|
100
101
|
current: (null == meta ? void 0 : meta.page) || 1
|
|
101
|
-
},
|
|
102
|
+
}),
|
|
102
103
|
loading: null == service ? void 0 : service.loading,
|
|
103
104
|
children: (null == (_field_value = field.value) ? void 0 : _field_value.length) ? field.value.map((item, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
|
|
104
105
|
basePath: field.address,
|
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"../../../application/hoc/withDynamicSchemaProps": function(module) {
|
|
4
|
+
module.exports = require("../../../application/hoc/withDynamicSchemaProps.js");
|
|
5
|
+
},
|
|
6
|
+
"../../hooks/useProps": function(module) {
|
|
7
|
+
module.exports = require("../../hooks/useProps.js");
|
|
8
|
+
},
|
|
9
|
+
"./utils?198b": function(module) {
|
|
10
|
+
module.exports = require("./utils.js");
|
|
11
|
+
},
|
|
12
|
+
"@tachybase/schema": function(module) {
|
|
13
|
+
module.exports = require("@tachybase/schema");
|
|
14
|
+
},
|
|
15
|
+
antd: function(module) {
|
|
16
|
+
module.exports = require("antd");
|
|
17
|
+
},
|
|
18
|
+
react: function(module) {
|
|
19
|
+
module.exports = require("react");
|
|
20
|
+
},
|
|
21
|
+
"react/jsx-runtime": function(module) {
|
|
22
|
+
module.exports = require("react/jsx-runtime");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var __webpack_module_cache__ = {};
|
|
26
|
+
function __webpack_require__(moduleId) {
|
|
27
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
28
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
29
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
30
|
+
exports: {}
|
|
31
|
+
};
|
|
32
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
33
|
+
return module.exports;
|
|
34
|
+
}
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.n = (module)=>{
|
|
37
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
38
|
+
__webpack_require__.d(getter, {
|
|
39
|
+
a: getter
|
|
40
|
+
});
|
|
41
|
+
return getter;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
3
44
|
(()=>{
|
|
4
45
|
__webpack_require__.d = (exports1, definition)=>{
|
|
5
46
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -22,31 +63,42 @@ var __webpack_require__ = {};
|
|
|
22
63
|
};
|
|
23
64
|
})();
|
|
24
65
|
var __webpack_exports__ = {};
|
|
25
|
-
|
|
26
|
-
__webpack_require__.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
-
require("react");
|
|
31
|
-
const schema_namespaceObject = require("@tachybase/schema");
|
|
32
|
-
const external_antd_namespaceObject = require("antd");
|
|
33
|
-
const withDynamicSchemaProps_js_namespaceObject = require("../../../application/hoc/withDynamicSchemaProps.js");
|
|
34
|
-
const useProps_js_namespaceObject = require("../../hooks/useProps.js");
|
|
35
|
-
const Pagination = (0, withDynamicSchemaProps_js_namespaceObject.withDynamicSchemaProps)((0, schema_namespaceObject.observer)((props)=>{
|
|
36
|
-
const { hidden, ...others } = (0, useProps_js_namespaceObject.useProps)(props);
|
|
37
|
-
if (hidden) return null;
|
|
38
|
-
const onKeypress = (e)=>{
|
|
39
|
-
if ('Enter' === e.key) e.preventDefault();
|
|
40
|
-
};
|
|
41
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
42
|
-
onKeyPress: onKeypress,
|
|
43
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Pagination, {
|
|
44
|
-
...others
|
|
45
|
-
})
|
|
66
|
+
(()=>{
|
|
67
|
+
__webpack_require__.r(__webpack_exports__);
|
|
68
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
69
|
+
Pagination: ()=>Pagination
|
|
46
70
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react/jsx-runtime");
|
|
72
|
+
__webpack_require__("react");
|
|
73
|
+
var _tachybase_schema__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@tachybase/schema");
|
|
74
|
+
var antd__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("antd");
|
|
75
|
+
var _application_hoc_withDynamicSchemaProps__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../../../application/hoc/withDynamicSchemaProps");
|
|
76
|
+
var _hooks_useProps__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../hooks/useProps");
|
|
77
|
+
var _utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./utils?198b");
|
|
78
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
79
|
+
for(var __WEBPACK_IMPORT_KEY__ in _utils__WEBPACK_IMPORTED_MODULE_6__)if ([
|
|
80
|
+
"Pagination",
|
|
81
|
+
"default"
|
|
82
|
+
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
83
|
+
return _utils__WEBPACK_IMPORTED_MODULE_6__[key];
|
|
84
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
85
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
86
|
+
const Pagination = (0, _application_hoc_withDynamicSchemaProps__WEBPACK_IMPORTED_MODULE_4__.withDynamicSchemaProps)((0, _tachybase_schema__WEBPACK_IMPORTED_MODULE_2__.observer)((props)=>{
|
|
87
|
+
const { hidden, ...others } = (0, _hooks_useProps__WEBPACK_IMPORTED_MODULE_5__.useProps)(props);
|
|
88
|
+
if (hidden) return null;
|
|
89
|
+
const onKeypress = (e)=>{
|
|
90
|
+
if ('Enter' === e.key) e.preventDefault();
|
|
91
|
+
};
|
|
92
|
+
return /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
|
|
93
|
+
onKeyPress: onKeypress,
|
|
94
|
+
children: /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(antd__WEBPACK_IMPORTED_MODULE_3__.Pagination, {
|
|
95
|
+
...(0, _utils__WEBPACK_IMPORTED_MODULE_6__.withAutoQuickJumper)(others)
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}, {
|
|
99
|
+
displayName: 'Pagination'
|
|
100
|
+
}));
|
|
101
|
+
})();
|
|
50
102
|
exports.Pagination = __webpack_exports__.Pagination;
|
|
51
103
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
52
104
|
"Pagination"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getPaginationPageCount: ()=>getPaginationPageCount,
|
|
28
|
+
shouldAutoEnableQuickJumper: ()=>shouldAutoEnableQuickJumper,
|
|
29
|
+
withAutoQuickJumper: ()=>withAutoQuickJumper
|
|
30
|
+
});
|
|
31
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
32
|
+
const getPageBufferSize = (showLessItems)=>showLessItems ? 1 : 2;
|
|
33
|
+
const getQuickJumperAutoThreshold = (showLessItems)=>2 * getPageBufferSize(showLessItems) + 3;
|
|
34
|
+
const getPaginationPageCount = (pagination)=>{
|
|
35
|
+
if (!pagination) return 0;
|
|
36
|
+
const total = Number(pagination.total);
|
|
37
|
+
const pageSize = Number(pagination.pageSize || pagination.defaultPageSize || DEFAULT_PAGE_SIZE);
|
|
38
|
+
if (!Number.isFinite(total) || total <= 0 || !Number.isFinite(pageSize) || pageSize <= 0) return 0;
|
|
39
|
+
return Math.ceil(total / pageSize);
|
|
40
|
+
};
|
|
41
|
+
const shouldAutoEnableQuickJumper = (pagination)=>{
|
|
42
|
+
if (!pagination || void 0 !== pagination.showQuickJumper || pagination.simple) return false;
|
|
43
|
+
return getPaginationPageCount(pagination) > getQuickJumperAutoThreshold(pagination.showLessItems);
|
|
44
|
+
};
|
|
45
|
+
const withAutoQuickJumper = (pagination)=>{
|
|
46
|
+
if (!pagination || false === pagination || !shouldAutoEnableQuickJumper(pagination)) return pagination;
|
|
47
|
+
return {
|
|
48
|
+
...pagination,
|
|
49
|
+
showQuickJumper: true
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.getPaginationPageCount = __webpack_exports__.getPaginationPageCount;
|
|
53
|
+
exports.shouldAutoEnableQuickJumper = __webpack_exports__.shouldAutoEnableQuickJumper;
|
|
54
|
+
exports.withAutoQuickJumper = __webpack_exports__.withAutoQuickJumper;
|
|
55
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
56
|
+
"getPaginationPageCount",
|
|
57
|
+
"shouldAutoEnableQuickJumper",
|
|
58
|
+
"withAutoQuickJumper"
|
|
59
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
60
|
+
Object.defineProperty(exports, '__esModule', {
|
|
61
|
+
value: true
|
|
62
|
+
});
|
|
@@ -32,6 +32,7 @@ const schema_namespaceObject = require("@tachybase/schema");
|
|
|
32
32
|
const external_lodash_namespaceObject = require("lodash");
|
|
33
33
|
const external_index_js_namespaceObject = require("../../../index.js");
|
|
34
34
|
const index_js_namespaceObject = require("../../hooks/index.js");
|
|
35
|
+
const utils_js_namespaceObject = require("../pagination/utils.js");
|
|
35
36
|
const external_Table_Array_js_namespaceObject = require("./Table.Array.js");
|
|
36
37
|
const usePaginationProps = (props, service)=>{
|
|
37
38
|
var _props_request_params, _props_request, _service_data;
|
|
@@ -47,7 +48,7 @@ const usePaginationProps = (props, service)=>{
|
|
|
47
48
|
pagination.current = page;
|
|
48
49
|
pagination.pageSize = pageSize;
|
|
49
50
|
}
|
|
50
|
-
return {
|
|
51
|
+
return (0, utils_js_namespaceObject.withAutoQuickJumper)({
|
|
51
52
|
showSizeChanger: true,
|
|
52
53
|
...pagination,
|
|
53
54
|
onChange (page, pageSize) {
|
|
@@ -58,7 +59,7 @@ const usePaginationProps = (props, service)=>{
|
|
|
58
59
|
pageSize
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
};
|
|
62
|
+
});
|
|
62
63
|
};
|
|
63
64
|
const useRequestProps = (props)=>{
|
|
64
65
|
const { request, pagination, dataSource } = props;
|
|
@@ -56,6 +56,7 @@ const withDynamicSchemaProps_js_namespaceObject = require("../../../application/
|
|
|
56
56
|
const isNewRecord_js_namespaceObject = require("../../../data-source/collection-record/isNewRecord.js");
|
|
57
57
|
const DeclareVariable_js_namespaceObject = require("../../../modules/variable/DeclareVariable.js");
|
|
58
58
|
const hooks_js_namespaceObject = require("../association-field/hooks.js");
|
|
59
|
+
const utils_js_namespaceObject = require("../pagination/utils.js");
|
|
59
60
|
const ColumnFieldProvider_js_namespaceObject = require("./components/ColumnFieldProvider.js");
|
|
60
61
|
const external_Table_styles_js_namespaceObject = require("./Table.styles.js");
|
|
61
62
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
@@ -269,7 +270,7 @@ const usePaginationProps = (pagination1, pagination2)=>{
|
|
|
269
270
|
...pagination1,
|
|
270
271
|
...pagination2
|
|
271
272
|
};
|
|
272
|
-
return result.total ? result : false;
|
|
273
|
+
return result.total ? (0, utils_js_namespaceObject.withAutoQuickJumper)(result) : false;
|
|
273
274
|
};
|
|
274
275
|
const Table = (0, withDynamicSchemaProps_js_namespaceObject.withDynamicSchemaProps)((0, schema_namespaceObject.observer)((props)=>{
|
|
275
276
|
var _schema_parent, _field_data, _field_value_slice_filter, _field_value_slice, _field_value_slice1, _field_value, _fieldSchema_parent_xdecoratorprops, _fieldSchema_parent;
|