@douyinfe/semi-foundation 2.21.2 → 2.21.3-alpha.0
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.
|
@@ -84,6 +84,18 @@ declare class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<Re
|
|
|
84
84
|
memoizedFilterColumns: (columns: BaseColumnProps<RecordType>[], ignoreKeys?: string[]) => BaseColumnProps<RecordType>[];
|
|
85
85
|
memoizedFlattenFnsColumns: (columns: BaseColumnProps<RecordType>[], childrenColumnName?: string) => BaseColumnProps<RecordType>[];
|
|
86
86
|
memoizedPagination: (pagination: BasePagination) => BasePagination;
|
|
87
|
+
/**
|
|
88
|
+
* update columns in place, and use default values as initial values if the sorting and filtering columns have no values
|
|
89
|
+
*/
|
|
90
|
+
static initColumnsFilteredValueAndSorterOrder(columns: BaseColumnProps<unknown>[]): BaseColumnProps<unknown>[];
|
|
91
|
+
/**
|
|
92
|
+
* init filteredValue of filtering column, use defaultFilteredValue or [] when it is undefined
|
|
93
|
+
*/
|
|
94
|
+
static initFilteredValue(column: BaseColumnProps<unknown>): void;
|
|
95
|
+
/**
|
|
96
|
+
* init sortOrder of sorting column, use defaultSortOrder or [] when it is undefined
|
|
97
|
+
*/
|
|
98
|
+
static initSorterOrder(column: BaseColumnProps<unknown>): void;
|
|
87
99
|
constructor(adapter: TableAdapter<RecordType>);
|
|
88
100
|
init(): void;
|
|
89
101
|
initExpandedRowKeys({ groups }?: {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
9
|
+
|
|
8
10
|
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
9
11
|
|
|
10
12
|
var _slice2 = _interopRequireDefault(require("lodash/slice"));
|
|
@@ -102,6 +104,59 @@ class TableFoundation extends _foundation.default {
|
|
|
102
104
|
this.memoizedFlattenFnsColumns = (0, _memoizeOne.default)(_utils.flattenColumns);
|
|
103
105
|
this.memoizedPagination = (0, _memoizeOne.default)(mergePagination, _isEqual2.default);
|
|
104
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* update columns in place, and use default values as initial values if the sorting and filtering columns have no values
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
static initColumnsFilteredValueAndSorterOrder(columns) {
|
|
113
|
+
columns.forEach(column => {
|
|
114
|
+
TableFoundation.initFilteredValue(column);
|
|
115
|
+
TableFoundation.initSorterOrder(column);
|
|
116
|
+
});
|
|
117
|
+
return columns;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* init filteredValue of filtering column, use defaultFilteredValue or [] when it is undefined
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
static initFilteredValue(column) {
|
|
125
|
+
const {
|
|
126
|
+
defaultFilteredValue,
|
|
127
|
+
filteredValue,
|
|
128
|
+
filters
|
|
129
|
+
} = column;
|
|
130
|
+
const hasFilter = Array.isArray(filters) && filters.length;
|
|
131
|
+
|
|
132
|
+
if (hasFilter && (0, _isUndefined2.default)(filteredValue)) {
|
|
133
|
+
if (Array.isArray(defaultFilteredValue) && defaultFilteredValue.length) {
|
|
134
|
+
column.filteredValue = defaultFilteredValue;
|
|
135
|
+
} else {
|
|
136
|
+
column.filteredValue = [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* init sortOrder of sorting column, use defaultSortOrder or [] when it is undefined
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
static initSorterOrder(column) {
|
|
146
|
+
const {
|
|
147
|
+
defaultSortOrder,
|
|
148
|
+
sortOrder,
|
|
149
|
+
sorter
|
|
150
|
+
} = column;
|
|
151
|
+
|
|
152
|
+
if (sorter && (0, _isUndefined2.default)(sortOrder)) {
|
|
153
|
+
if (!(0, _isUndefined2.default)(defaultSortOrder)) {
|
|
154
|
+
column.sortOrder = defaultSortOrder;
|
|
155
|
+
} else {
|
|
156
|
+
column.sortOrder = false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
105
160
|
|
|
106
161
|
init() {
|
|
107
162
|
const dataSource = [...this.getProp('dataSource')];
|
|
@@ -84,6 +84,18 @@ declare class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<Re
|
|
|
84
84
|
memoizedFilterColumns: (columns: BaseColumnProps<RecordType>[], ignoreKeys?: string[]) => BaseColumnProps<RecordType>[];
|
|
85
85
|
memoizedFlattenFnsColumns: (columns: BaseColumnProps<RecordType>[], childrenColumnName?: string) => BaseColumnProps<RecordType>[];
|
|
86
86
|
memoizedPagination: (pagination: BasePagination) => BasePagination;
|
|
87
|
+
/**
|
|
88
|
+
* update columns in place, and use default values as initial values if the sorting and filtering columns have no values
|
|
89
|
+
*/
|
|
90
|
+
static initColumnsFilteredValueAndSorterOrder(columns: BaseColumnProps<unknown>[]): BaseColumnProps<unknown>[];
|
|
91
|
+
/**
|
|
92
|
+
* init filteredValue of filtering column, use defaultFilteredValue or [] when it is undefined
|
|
93
|
+
*/
|
|
94
|
+
static initFilteredValue(column: BaseColumnProps<unknown>): void;
|
|
95
|
+
/**
|
|
96
|
+
* init sortOrder of sorting column, use defaultSortOrder or [] when it is undefined
|
|
97
|
+
*/
|
|
98
|
+
static initSorterOrder(column: BaseColumnProps<unknown>): void;
|
|
87
99
|
constructor(adapter: TableAdapter<RecordType>);
|
|
88
100
|
init(): void;
|
|
89
101
|
initExpandedRowKeys({ groups }?: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isUndefined from "lodash/isUndefined";
|
|
1
2
|
import _isEqual from "lodash/isEqual";
|
|
2
3
|
import _slice from "lodash/slice";
|
|
3
4
|
import _isMap from "lodash/isMap";
|
|
@@ -77,6 +78,59 @@ class TableFoundation extends BaseFoundation {
|
|
|
77
78
|
this.memoizedFlattenFnsColumns = memoizeOne(flattenColumns);
|
|
78
79
|
this.memoizedPagination = memoizeOne(mergePagination, _isEqual);
|
|
79
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* update columns in place, and use default values as initial values if the sorting and filtering columns have no values
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
static initColumnsFilteredValueAndSorterOrder(columns) {
|
|
87
|
+
columns.forEach(column => {
|
|
88
|
+
TableFoundation.initFilteredValue(column);
|
|
89
|
+
TableFoundation.initSorterOrder(column);
|
|
90
|
+
});
|
|
91
|
+
return columns;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* init filteredValue of filtering column, use defaultFilteredValue or [] when it is undefined
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
static initFilteredValue(column) {
|
|
99
|
+
const {
|
|
100
|
+
defaultFilteredValue,
|
|
101
|
+
filteredValue,
|
|
102
|
+
filters
|
|
103
|
+
} = column;
|
|
104
|
+
const hasFilter = Array.isArray(filters) && filters.length;
|
|
105
|
+
|
|
106
|
+
if (hasFilter && _isUndefined(filteredValue)) {
|
|
107
|
+
if (Array.isArray(defaultFilteredValue) && defaultFilteredValue.length) {
|
|
108
|
+
column.filteredValue = defaultFilteredValue;
|
|
109
|
+
} else {
|
|
110
|
+
column.filteredValue = [];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* init sortOrder of sorting column, use defaultSortOrder or [] when it is undefined
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
static initSorterOrder(column) {
|
|
120
|
+
const {
|
|
121
|
+
defaultSortOrder,
|
|
122
|
+
sortOrder,
|
|
123
|
+
sorter
|
|
124
|
+
} = column;
|
|
125
|
+
|
|
126
|
+
if (sorter && _isUndefined(sortOrder)) {
|
|
127
|
+
if (!_isUndefined(defaultSortOrder)) {
|
|
128
|
+
column.sortOrder = defaultSortOrder;
|
|
129
|
+
} else {
|
|
130
|
+
column.sortOrder = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
80
134
|
|
|
81
135
|
init() {
|
|
82
136
|
const dataSource = [...this.getProp('dataSource')];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.3-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "45d27fa307080eb6ca923b8adb20ae46b90bcfdc",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|
package/table/foundation.ts
CHANGED
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
filter,
|
|
18
18
|
isMap,
|
|
19
19
|
slice,
|
|
20
|
-
isEqual
|
|
20
|
+
isEqual,
|
|
21
|
+
isUndefined
|
|
21
22
|
} from 'lodash';
|
|
22
23
|
import memoizeOne from 'memoize-one';
|
|
23
24
|
|
|
@@ -114,6 +115,46 @@ class TableFoundation<RecordType> extends BaseFoundation<TableAdapter<RecordType
|
|
|
114
115
|
memoizedFlattenFnsColumns: (columns: BaseColumnProps<RecordType>[], childrenColumnName?: string) => BaseColumnProps<RecordType>[];
|
|
115
116
|
memoizedPagination: (pagination: BasePagination) => BasePagination;
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* update columns in place, and use default values as initial values if the sorting and filtering columns have no values
|
|
120
|
+
*/
|
|
121
|
+
static initColumnsFilteredValueAndSorterOrder(columns: BaseColumnProps<unknown>[]) {
|
|
122
|
+
columns.forEach(column => {
|
|
123
|
+
TableFoundation.initFilteredValue(column);
|
|
124
|
+
TableFoundation.initSorterOrder(column);
|
|
125
|
+
});
|
|
126
|
+
return columns;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* init filteredValue of filtering column, use defaultFilteredValue or [] when it is undefined
|
|
131
|
+
*/
|
|
132
|
+
static initFilteredValue(column: BaseColumnProps<unknown>) {
|
|
133
|
+
const { defaultFilteredValue, filteredValue, filters } = column;
|
|
134
|
+
const hasFilter = Array.isArray(filters) && filters.length;
|
|
135
|
+
if (hasFilter && isUndefined(filteredValue)) {
|
|
136
|
+
if (Array.isArray(defaultFilteredValue) && defaultFilteredValue.length) {
|
|
137
|
+
column.filteredValue = defaultFilteredValue;
|
|
138
|
+
} else {
|
|
139
|
+
column.filteredValue = [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* init sortOrder of sorting column, use defaultSortOrder or [] when it is undefined
|
|
146
|
+
*/
|
|
147
|
+
static initSorterOrder(column: BaseColumnProps<unknown>) {
|
|
148
|
+
const { defaultSortOrder, sortOrder, sorter } = column;
|
|
149
|
+
if (sorter && isUndefined(sortOrder)) {
|
|
150
|
+
if (!isUndefined(defaultSortOrder)) {
|
|
151
|
+
column.sortOrder = defaultSortOrder;
|
|
152
|
+
} else {
|
|
153
|
+
column.sortOrder = false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
117
158
|
constructor(adapter: TableAdapter<RecordType>) {
|
|
118
159
|
super({ ...adapter });
|
|
119
160
|
|