es-grid-template 1.9.18 → 1.9.20
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/ali-table/Grid.js +2 -1
- package/es/ali-table/base-table/styles.scss +6 -10
- package/es/grid-component/type.d.ts +118 -37
- package/es/group-component/hook/utils.d.ts +26 -25
- package/es/table-component/header/TableHeadCell2.js +3 -1
- package/es/table-component/header/renderFilter.d.ts +2 -0
- package/es/table-component/header/renderFilter.js +32 -4
- package/es/table-component/hook/utils.d.ts +2 -0
- package/es/table-component/hook/utils.js +171 -2
- package/lib/ali-table/Grid.js +2 -1
- package/lib/ali-table/base-table/styles.scss +6 -10
- package/lib/grid-component/type.d.ts +118 -37
- package/lib/group-component/hook/utils.d.ts +22 -21
- package/lib/table-component/header/TableHeadCell2.js +3 -1
- package/lib/table-component/header/renderFilter.d.ts +2 -0
- package/lib/table-component/header/renderFilter.js +32 -4
- package/lib/table-component/hook/utils.d.ts +2 -0
- package/lib/table-component/hook/utils.js +177 -5
- package/package.json +2 -2
|
@@ -42,16 +42,12 @@ $prefix: 'ui-rc' !default;
|
|
|
42
42
|
.ui-rc-grid-table-wrapper.dark {
|
|
43
43
|
|
|
44
44
|
.ui-rc-grid-horizontal-scroll-container {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
background: rgba(255, 255, 255, 0.5);
|
|
52
|
-
}
|
|
45
|
+
&::-webkit-scrollbar-thumb {
|
|
46
|
+
background: rgba(255, 255, 255, 0.3);
|
|
47
|
+
}
|
|
48
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
49
|
+
background: rgba(255, 255, 255, 0.5);
|
|
50
|
+
}
|
|
53
51
|
}
|
|
54
|
-
|
|
55
52
|
|
|
56
|
-
|
|
57
53
|
}
|
|
@@ -4,7 +4,7 @@ import type { Cell, Header, OnChangeFn } from '@tanstack/react-table';
|
|
|
4
4
|
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
5
5
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
6
6
|
import type { PaginationLocale } from 'rc-master-ui/lib/pagination/Pagination';
|
|
7
|
-
import { BaseTableCSSVariables } from '../ali-table/base-table/styles';
|
|
7
|
+
import type { BaseTableCSSVariables } from '../ali-table/base-table/styles';
|
|
8
8
|
declare module "@tanstack/table-core" {
|
|
9
9
|
interface ColumnMeta<any, any> extends ColumnTable {
|
|
10
10
|
rowSpan?: number;
|
|
@@ -135,95 +135,175 @@ export interface SpanRect {
|
|
|
135
135
|
right: number;
|
|
136
136
|
}
|
|
137
137
|
export type ColumnTable<RecordType = AnyObject> = {
|
|
138
|
+
/** Field key dùng để mapping dữ liệu */
|
|
138
139
|
field: string;
|
|
140
|
+
/** Text hiển thị ở header */
|
|
141
|
+
headerText?: string;
|
|
142
|
+
/** Field gốc trước khi transform */
|
|
139
143
|
fieldOriginal?: string;
|
|
144
|
+
/** Độ rộng column */
|
|
140
145
|
width?: number;
|
|
146
|
+
/** Độ rộng tối đa */
|
|
141
147
|
maxWidth?: number;
|
|
148
|
+
/** Độ rộng tối thiểu */
|
|
142
149
|
minWidth?: number;
|
|
150
|
+
/** Hiển thị trong popup chọn column */
|
|
151
|
+
showInColumnChoose?: boolean;
|
|
152
|
+
/** Kiểu dữ liệu của column */
|
|
143
153
|
type?: IColumnType;
|
|
154
|
+
/** Format hiển thị dữ liệu column type = number */
|
|
155
|
+
format?: IFormat | ((rowData: any) => IFormat);
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Please use `isSummary` instead.
|
|
158
|
+
* @since 1.7.25
|
|
159
|
+
*/
|
|
144
160
|
haveSum?: boolean;
|
|
161
|
+
/** Có tính tổng column type = number hay không
|
|
162
|
+
*
|
|
163
|
+
* Mặc định = true
|
|
164
|
+
*/
|
|
145
165
|
isSummary?: boolean;
|
|
166
|
+
/** Có tính tổng theo group */
|
|
167
|
+
sumGroup?: boolean;
|
|
168
|
+
/** Template custom cho ô summary */
|
|
146
169
|
summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
|
|
147
|
-
/** Custom method to get cell props */
|
|
148
|
-
format?: IFormat | ((rowData: any) => IFormat);
|
|
149
|
-
allowFiltering?: boolean;
|
|
150
170
|
/**
|
|
151
171
|
* @deprecated Please use `allowSortering` instead.
|
|
152
172
|
* @since 1.7.25
|
|
153
173
|
*/
|
|
154
174
|
sorter?: boolean;
|
|
175
|
+
/** Cho phép filter
|
|
176
|
+
*
|
|
177
|
+
* Mặc định = true
|
|
178
|
+
*/
|
|
179
|
+
allowFiltering?: boolean;
|
|
180
|
+
/** Cho phép sort dữ liệu
|
|
181
|
+
*
|
|
182
|
+
* Mặc định = true
|
|
183
|
+
* */
|
|
155
184
|
allowSortering?: boolean;
|
|
185
|
+
/** Kiểu filter */
|
|
186
|
+
typeFilter?: TypeFilter;
|
|
187
|
+
/** Toán tử filter mặc định */
|
|
156
188
|
operator?: FilterOperator;
|
|
189
|
+
/** Ẩn phần chọn toán tử filter
|
|
190
|
+
* mặc đinh = false
|
|
191
|
+
*/
|
|
157
192
|
hideOperator?: boolean;
|
|
193
|
+
/** Custom Placeholder cho input/ Select/ Date.... filter */
|
|
158
194
|
placeholder?: string;
|
|
159
|
-
|
|
160
|
-
typeFilter?: TypeFilter;
|
|
195
|
+
/** Data source cho select/filter */
|
|
161
196
|
source?: any[];
|
|
197
|
+
/** Hiển thị ô search trong select filter */
|
|
162
198
|
showFilterSearch?: boolean;
|
|
163
|
-
headerText?: string;
|
|
164
199
|
/**
|
|
165
200
|
* @deprecated Please use `visible` instead.
|
|
166
201
|
* @since 1.7.33
|
|
167
202
|
*/
|
|
168
203
|
hidden?: boolean;
|
|
204
|
+
/** Hiển thị / ẩn column
|
|
205
|
+
* mặc định = true
|
|
206
|
+
* */
|
|
169
207
|
visible?: boolean;
|
|
208
|
+
/** Tooltip cho header */
|
|
170
209
|
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
210
|
+
/** Tên group header */
|
|
171
211
|
columnGroupText?: string;
|
|
172
|
-
/**
|
|
173
|
-
* @deprecated Please use `textAlign` instead.
|
|
174
|
-
* @since 1.7.34
|
|
175
|
-
*/
|
|
176
|
-
align?: ITextAlign;
|
|
177
|
-
textAlign?: ITextAlign;
|
|
212
|
+
/** Canh lề nội dung header */
|
|
178
213
|
headerTextAlign?: ITextAlign;
|
|
179
|
-
|
|
180
|
-
showTooltip?: boolean;
|
|
181
|
-
tooltipDescription?: string | ((args: {
|
|
182
|
-
value: any;
|
|
183
|
-
rowData: RecordType;
|
|
184
|
-
}) => ReactNode | ReactElement);
|
|
214
|
+
/** Template custom render header */
|
|
185
215
|
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
|
|
186
|
-
commandItems?: CommandItem[];
|
|
187
|
-
children?: ColumnTable<RecordType>[];
|
|
188
|
-
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
189
|
-
disable?: boolean | ((rowData: any) => boolean);
|
|
190
|
-
editEnable?: boolean | ((rowData: any) => boolean);
|
|
191
|
-
isClearable?: boolean;
|
|
192
|
-
maxDate?: any;
|
|
193
|
-
minDate?: any;
|
|
194
|
-
maxTime?: any;
|
|
195
|
-
minTime?: any;
|
|
196
|
-
max?: number;
|
|
197
|
-
min?: number;
|
|
198
|
-
editSelectSettings?: IEditSelectSettings;
|
|
199
|
-
editFromSettings?: IEditFromSettings;
|
|
200
216
|
/**
|
|
201
217
|
* @deprecated Please use `fixed` instead.
|
|
202
218
|
* @since 1.7.25
|
|
203
219
|
*/
|
|
204
220
|
fixedType?: FixedType;
|
|
221
|
+
/** Fixed column trái/phải */
|
|
205
222
|
fixed?: FixedType;
|
|
206
223
|
/**
|
|
207
|
-
* @deprecated Please use `wrapSettings` instead.
|
|
224
|
+
* @deprecated Please use `wrapSettings` on Table instead.
|
|
208
225
|
* @since 1.7.34
|
|
209
226
|
*/
|
|
210
227
|
headerTextWrap?: boolean;
|
|
228
|
+
/** Hiển thị dấu ... khi text overflow */
|
|
211
229
|
ellipsis?: boolean;
|
|
230
|
+
/** Cho phép resize column
|
|
231
|
+
*
|
|
232
|
+
* Mặc định = true
|
|
233
|
+
*/
|
|
212
234
|
allowResizing?: boolean;
|
|
213
|
-
|
|
235
|
+
/**
|
|
236
|
+
* @deprecated Please use `textAlign` instead.
|
|
237
|
+
* @since 1.7.34
|
|
238
|
+
*/
|
|
239
|
+
align?: ITextAlign;
|
|
240
|
+
/** Canh lề nội dung cell */
|
|
241
|
+
textAlign?: ITextAlign;
|
|
242
|
+
/** Template custom render cell */
|
|
243
|
+
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
244
|
+
/** Hiển thị tooltip cell */
|
|
245
|
+
showTooltip?: boolean;
|
|
246
|
+
/** Nội dung tooltip của cell */
|
|
247
|
+
tooltipDescription?: string | ((args: {
|
|
248
|
+
value: any;
|
|
249
|
+
rowData: RecordType;
|
|
250
|
+
}) => ReactNode | ReactElement);
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated Please use `getCellProps` instead.
|
|
253
|
+
* @since 1.7.34
|
|
254
|
+
*/
|
|
214
255
|
onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Please use `headerCellProps` instead.
|
|
258
|
+
* @since 1.7.34
|
|
259
|
+
*/
|
|
215
260
|
onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
261
|
+
/**
|
|
262
|
+
* @deprecated Please use `getCellProps` instead.
|
|
263
|
+
* @since 1.7.34
|
|
264
|
+
*/
|
|
265
|
+
onCell?: (rowData: RecordType, index: number) => React.TdHTMLAttributes<HTMLTableCellElement>;
|
|
216
266
|
onCellFooterStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
|
|
217
|
-
sumGroup?: boolean;
|
|
218
267
|
/** Custom data retrieval method */
|
|
268
|
+
/** Custom method lấy value cell */
|
|
219
269
|
getValue?: (row: any, rowIndex: number) => any;
|
|
220
|
-
/** Custom render method */
|
|
221
270
|
/** Custom method to get cell props */
|
|
222
271
|
getCellProps?: (value: any, row: any, rowIndex: number) => CellProps;
|
|
223
272
|
/** Props for the header cell */
|
|
224
273
|
headerCellProps?: CellProps;
|
|
225
274
|
/** Custom method to get cell SpanRect */
|
|
275
|
+
/** Custom merge cell */
|
|
226
276
|
getSpanRect?: (value: any, row: any, rowIndex: number) => SpanRect;
|
|
277
|
+
/** Kiểu editor khi edit cell */
|
|
278
|
+
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
279
|
+
/** Disable editor */
|
|
280
|
+
disable?: boolean | ((rowData: any) => boolean);
|
|
281
|
+
/** Cho phép edit */
|
|
282
|
+
editEnable?: boolean | ((rowData: any) => boolean);
|
|
283
|
+
/** Cho phép clear value khi edit */
|
|
284
|
+
isClearable?: boolean;
|
|
285
|
+
/** Ngày lớn nhất cho date picker */
|
|
286
|
+
maxDate?: any;
|
|
287
|
+
/** Ngày nhỏ nhất cho date picker */
|
|
288
|
+
minDate?: any;
|
|
289
|
+
/** Thời gian lớn nhất */
|
|
290
|
+
maxTime?: any;
|
|
291
|
+
/** Thời gian nhỏ nhất */
|
|
292
|
+
minTime?: any;
|
|
293
|
+
/** Giá trị số lớn nhất khi editType : number */
|
|
294
|
+
max?: number;
|
|
295
|
+
/** Giá trị số nhỏ nhất khi editType : number */
|
|
296
|
+
min?: number;
|
|
297
|
+
/** Config select editor */
|
|
298
|
+
editSelectSettings?: IEditSelectSettings;
|
|
299
|
+
/** Config form editor */
|
|
300
|
+
editFromSettings?: IEditFromSettings;
|
|
301
|
+
/** Cho phép select column */
|
|
302
|
+
allowSelection?: boolean | ((rowData: RecordType) => boolean);
|
|
303
|
+
/** Danh sách command/action trong column type = command */
|
|
304
|
+
commandItems?: CommandItem[];
|
|
305
|
+
/** Column con (multi header/group column) */
|
|
306
|
+
children?: ColumnTable<RecordType>[];
|
|
227
307
|
};
|
|
228
308
|
export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
|
|
229
309
|
export type IFTheme = {
|
|
@@ -315,6 +395,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
315
395
|
}) => void;
|
|
316
396
|
expandable?: ExpandableConfig<RecordType>;
|
|
317
397
|
actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
|
|
398
|
+
bottom?: ReactNode;
|
|
318
399
|
rowClassName?: string | RowClassName<RecordType>;
|
|
319
400
|
onRowStyles?: CSSProperties | ((data: RecordType) => CSSProperties);
|
|
320
401
|
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
@@ -155,42 +155,53 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
|
|
|
155
155
|
export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordType>[], fixedFields: string[]) => {
|
|
156
156
|
fixed: string;
|
|
157
157
|
field: string;
|
|
158
|
+
headerText?: string;
|
|
158
159
|
fieldOriginal?: string;
|
|
159
160
|
width?: number;
|
|
160
161
|
maxWidth?: number;
|
|
161
162
|
minWidth?: number;
|
|
163
|
+
showInColumnChoose?: boolean;
|
|
162
164
|
type?: IColumnType;
|
|
165
|
+
format?: IFormat | ((rowData: any) => IFormat);
|
|
163
166
|
haveSum?: boolean;
|
|
164
167
|
isSummary?: boolean;
|
|
168
|
+
sumGroup?: boolean;
|
|
165
169
|
summaryTemplate?: (data: number, key: string) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
166
|
-
format?: IFormat | ((rowData: any) => IFormat);
|
|
167
|
-
allowFiltering?: boolean;
|
|
168
170
|
sorter?: boolean;
|
|
171
|
+
allowFiltering?: boolean;
|
|
169
172
|
allowSortering?: boolean;
|
|
173
|
+
typeFilter?: TypeFilter;
|
|
170
174
|
operator?: FilterOperator;
|
|
171
175
|
hideOperator?: boolean;
|
|
172
176
|
placeholder?: string;
|
|
173
|
-
showInColumnChoose?: boolean;
|
|
174
|
-
typeFilter?: TypeFilter;
|
|
175
177
|
source?: any[];
|
|
176
178
|
showFilterSearch?: boolean;
|
|
177
|
-
headerText?: string;
|
|
178
179
|
hidden?: boolean;
|
|
179
180
|
visible?: boolean;
|
|
180
181
|
headerTooltip?: string | boolean | (() => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
181
182
|
columnGroupText?: string;
|
|
183
|
+
headerTextAlign?: import("./../../grid-component/type").ITextAlign;
|
|
184
|
+
headerTemplate?: import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((column: ColumnTable<RecordType>) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
185
|
+
fixedType?: import("./../../grid-component/type").FixedType;
|
|
186
|
+
headerTextWrap?: boolean;
|
|
187
|
+
ellipsis?: boolean;
|
|
188
|
+
allowResizing?: boolean;
|
|
182
189
|
align?: import("./../../grid-component/type").ITextAlign;
|
|
183
190
|
textAlign?: import("./../../grid-component/type").ITextAlign;
|
|
184
|
-
headerTextAlign?: import("./../../grid-component/type").ITextAlign;
|
|
185
191
|
template?: import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
186
192
|
showTooltip?: boolean;
|
|
187
193
|
tooltipDescription?: string | ((args: {
|
|
188
194
|
value: any;
|
|
189
195
|
rowData: RecordType;
|
|
190
196
|
}) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
onCellStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
|
|
198
|
+
onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
|
|
199
|
+
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
200
|
+
onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
|
|
201
|
+
getValue?: (row: any, rowIndex: number) => any;
|
|
202
|
+
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
203
|
+
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
204
|
+
getSpanRect?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").SpanRect;
|
|
194
205
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
195
206
|
disable?: boolean | ((rowData: any) => boolean);
|
|
196
207
|
editEnable?: boolean | ((rowData: any) => boolean);
|
|
@@ -203,18 +214,8 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
203
214
|
min?: number;
|
|
204
215
|
editSelectSettings?: import("./../../grid-component/type").IEditSelectSettings;
|
|
205
216
|
editFromSettings?: import("./../../grid-component/type").IEditFromSettings;
|
|
206
|
-
fixedType?: import("./../../grid-component/type").FixedType;
|
|
207
|
-
headerTextWrap?: boolean;
|
|
208
|
-
ellipsis?: boolean;
|
|
209
|
-
allowResizing?: boolean;
|
|
210
217
|
allowSelection?: boolean | ((rowData: RecordType) => boolean);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "minWidth" | "position" | "width">);
|
|
214
|
-
sumGroup?: boolean;
|
|
215
|
-
getValue?: (row: any, rowIndex: number) => any;
|
|
216
|
-
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
217
|
-
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
218
|
-
getSpanRect?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").SpanRect;
|
|
218
|
+
commandItems?: import("./../../grid-component/type").CommandItem[];
|
|
219
|
+
children?: ColumnTable<RecordType>[];
|
|
219
220
|
}[];
|
|
220
221
|
export declare function sortColumnsByField<T extends ColumnTable>(columns: T[], priorityFields: string[]): T[];
|
|
@@ -203,7 +203,9 @@ const TableHeadCell2 = props => {
|
|
|
203
203
|
doFilter,
|
|
204
204
|
format,
|
|
205
205
|
dataSourceFilter,
|
|
206
|
-
tableLocal
|
|
206
|
+
tableLocal,
|
|
207
|
+
prevFilterValue: column.getFilterValue(),
|
|
208
|
+
triggerVisible
|
|
207
209
|
})), /*#__PURE__*/_react.default.createElement(_antd.Space, {
|
|
208
210
|
style: {
|
|
209
211
|
justifyContent: 'end',
|
|
@@ -16,6 +16,8 @@ type RenderFilterProps<RecordType> = {
|
|
|
16
16
|
dateRangeLocale?: any;
|
|
17
17
|
doFilter?: (type: boolean) => void;
|
|
18
18
|
tableLocal: any;
|
|
19
|
+
prevFilterValue?: string[];
|
|
20
|
+
triggerVisible?: (visible: boolean) => void;
|
|
19
21
|
};
|
|
20
22
|
export declare const renderFilter: <RecordType>(args: RenderFilterProps<RecordType>) => React.JSX.Element;
|
|
21
23
|
export {};
|
|
@@ -19,6 +19,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
19
19
|
|
|
20
20
|
// import type { AnyObject } from './type';
|
|
21
21
|
|
|
22
|
+
const isEqualDateArray = (arr1, arr2) => {
|
|
23
|
+
if (arr1?.length !== arr2?.length) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return arr1?.every((item, index) => {
|
|
27
|
+
const date1 = new Date(item).getTime();
|
|
28
|
+
const date2 = new Date(arr2?.[index]).getTime();
|
|
29
|
+
return date1 === date2;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
22
32
|
const renderFilter = args => {
|
|
23
33
|
const {
|
|
24
34
|
column,
|
|
@@ -29,7 +39,9 @@ const renderFilter = args => {
|
|
|
29
39
|
dataSourceFilter,
|
|
30
40
|
format,
|
|
31
41
|
doFilter,
|
|
32
|
-
tableLocal
|
|
42
|
+
tableLocal,
|
|
43
|
+
prevFilterValue,
|
|
44
|
+
triggerVisible
|
|
33
45
|
} = args;
|
|
34
46
|
const {
|
|
35
47
|
format: columnFormat,
|
|
@@ -106,10 +118,26 @@ const renderFilter = args => {
|
|
|
106
118
|
onChange: value => {
|
|
107
119
|
const newDateRangeValue = value ? [value[0] ? (0, _moment.default)(value[0]).format() : '', value[1] ? (0, _moment.default)(value[1]).format() : ''] : [];
|
|
108
120
|
setSelectedKeys(newDateRangeValue);
|
|
109
|
-
}
|
|
121
|
+
},
|
|
122
|
+
onOk: value => {
|
|
123
|
+
const newDateRangeValue = value ? [value[0] ? (0, _moment.default)(value[0]).format() : '', value[1] ? (0, _moment.default)(value[1]).format() : ''] : [];
|
|
124
|
+
setSelectedKeys(newDateRangeValue);
|
|
125
|
+
},
|
|
126
|
+
onExit: () => {
|
|
127
|
+
// clear nhưng chưa ấn OK
|
|
128
|
+
if (!dateRangeValue) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
// Click ok
|
|
133
|
+
if (!isEqualDateArray(dateRangeValue, prevFilterValue)) {
|
|
134
|
+
// giá trị khác nhau
|
|
135
|
+
doFilter?.(true);
|
|
136
|
+
} else {
|
|
137
|
+
// giá trị = nhau
|
|
138
|
+
triggerVisible?.(false);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
113
141
|
|
|
114
142
|
// menuClassName="rc-menu-popup"
|
|
115
143
|
,
|
|
@@ -67,6 +67,8 @@ export declare const detectSeparators: (str: string) => {
|
|
|
67
67
|
thousandSeparator: string;
|
|
68
68
|
decimalSeparator: string;
|
|
69
69
|
};
|
|
70
|
+
export declare const isDateValue: (value: any) => boolean;
|
|
71
|
+
export declare const convertFomatedDateToDate: (value: string) => Date | null;
|
|
70
72
|
export declare function isDateString(str: any): boolean;
|
|
71
73
|
export declare function compareDates(date1: any, date2: any): boolean;
|
|
72
74
|
export declare function compareDate(itemValue: any, value: any): boolean;
|
|
@@ -17,7 +17,7 @@ exports.compareDate = compareDate;
|
|
|
17
17
|
exports.compareDates = compareDates;
|
|
18
18
|
exports.convertArrayWithIndent = void 0;
|
|
19
19
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
20
|
-
exports.convertFlatColumn1 = exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
20
|
+
exports.convertFomatedDateToDate = exports.convertFlatColumn1 = exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
21
21
|
exports.convertFormat = convertFormat;
|
|
22
22
|
exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
23
23
|
exports.countUnselectedChildren = countUnselectedChildren;
|
|
@@ -44,7 +44,7 @@ exports.getVisibleFields = getVisibleFields;
|
|
|
44
44
|
exports.groupArrayByColumns = groupArrayByColumns;
|
|
45
45
|
exports.isColor = void 0;
|
|
46
46
|
exports.isDateString = isDateString;
|
|
47
|
-
exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
47
|
+
exports.isEmpty = exports.isEditable = exports.isDisable = exports.isDateValue = void 0;
|
|
48
48
|
exports.isEqualSet = isEqualSet;
|
|
49
49
|
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isFormattedNumber = void 0;
|
|
50
50
|
exports.isObjEqual = isObjEqual;
|
|
@@ -61,7 +61,8 @@ exports.sumFields = sumFields;
|
|
|
61
61
|
exports.sumNumberFields = sumNumberFields;
|
|
62
62
|
exports.sumSize = void 0;
|
|
63
63
|
exports.toggleRowAndChildren = toggleRowAndChildren;
|
|
64
|
-
exports.
|
|
64
|
+
exports.unFlattenData = void 0;
|
|
65
|
+
exports.updateArrayByKey = void 0;
|
|
65
66
|
exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
|
|
66
67
|
exports.updateColumnsByGroup = exports.updateColumns1 = void 0;
|
|
67
68
|
exports.updateOrInsert = updateOrInsert;
|
|
@@ -825,6 +826,174 @@ const detectSeparators = str => {
|
|
|
825
826
|
return null;
|
|
826
827
|
};
|
|
827
828
|
exports.detectSeparators = detectSeparators;
|
|
829
|
+
const isDateValue = value => {
|
|
830
|
+
if (value === null || value === undefined) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// Date object
|
|
835
|
+
if (value instanceof Date) {
|
|
836
|
+
return !isNaN(value.getTime());
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// number timestamp
|
|
840
|
+
if (typeof value === 'number') {
|
|
841
|
+
const date = new Date(value);
|
|
842
|
+
return !isNaN(date.getTime());
|
|
843
|
+
}
|
|
844
|
+
if (typeof value !== 'string') return false;
|
|
845
|
+
const str = value.trim();
|
|
846
|
+
if (!str) {
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// Các format date phổ biến
|
|
851
|
+
const patterns = [
|
|
852
|
+
// dd/MM/yyyy
|
|
853
|
+
/^\d{2}\/\d{2}\/\d{4}$/,
|
|
854
|
+
// d/M/yyyy
|
|
855
|
+
/^\d{1,2}\/\d{1,2}\/\d{4}$/,
|
|
856
|
+
// yyyy/MM/dd
|
|
857
|
+
/^\d{4}\/\d{2}\/\d{2}$/,
|
|
858
|
+
// yyyy/M/d
|
|
859
|
+
/^\d{4}\/\d{1,2}\/\d{1,2}$/,
|
|
860
|
+
// MM/yyyy
|
|
861
|
+
/^\d{2}\/\d{4}$/,
|
|
862
|
+
// M/yyyy
|
|
863
|
+
/^\d{1,2}\/\d{4}$/,
|
|
864
|
+
// yyyy/MM
|
|
865
|
+
/^\d{4}\/\d{2}$/,
|
|
866
|
+
// yyyy/M
|
|
867
|
+
/^\d{4}\/\d{1,2}$/,
|
|
868
|
+
// dd-MM-yyyy
|
|
869
|
+
/^\d{2}-\d{2}-\d{4}$/,
|
|
870
|
+
// yyyy-MM-dd
|
|
871
|
+
/^\d{4}-\d{2}-\d{2}$/,
|
|
872
|
+
// yyyy-M-d
|
|
873
|
+
/^\d{4}-\d{1,2}-\d{1,2}$/,
|
|
874
|
+
// ISO datetime
|
|
875
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,
|
|
876
|
+
// ISO datetime milliseconds
|
|
877
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?$/,
|
|
878
|
+
// yyyyMMdd
|
|
879
|
+
/^\d{8}$/,
|
|
880
|
+
// dd MMM yyyy
|
|
881
|
+
/^\d{1,2}\s[A-Za-z]{3}\s\d{4}$/,
|
|
882
|
+
// MMM dd, yyyy
|
|
883
|
+
/^[A-Za-z]{3}\s\d{1,2},\s\d{4}$/,
|
|
884
|
+
// full text date
|
|
885
|
+
/^[A-Za-z]+,\s[A-Za-z]+\s\d{1,2},\s\d{4}$/];
|
|
886
|
+
const matched = patterns.some(regex => regex.test(str));
|
|
887
|
+
if (matched) {
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// fallback:
|
|
892
|
+
// nếu regex không match nhưng Date parse được
|
|
893
|
+
if (!matched) {
|
|
894
|
+
const fallbackDate = new Date(str);
|
|
895
|
+
return !isNaN(fallbackDate.getTime());
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// validate real date
|
|
899
|
+
const date = new Date(str);
|
|
900
|
+
return !isNaN(date.getTime());
|
|
901
|
+
};
|
|
902
|
+
exports.isDateValue = isDateValue;
|
|
903
|
+
const convertFomatedDateToDate = value => {
|
|
904
|
+
const monthMap = {
|
|
905
|
+
Jan: 0,
|
|
906
|
+
Feb: 1,
|
|
907
|
+
Mar: 2,
|
|
908
|
+
Apr: 3,
|
|
909
|
+
May: 4,
|
|
910
|
+
Jun: 5,
|
|
911
|
+
Jul: 6,
|
|
912
|
+
Aug: 7,
|
|
913
|
+
Sep: 8,
|
|
914
|
+
Oct: 9,
|
|
915
|
+
Nov: 10,
|
|
916
|
+
Dec: 11
|
|
917
|
+
};
|
|
918
|
+
let date = null;
|
|
919
|
+
|
|
920
|
+
// dd/MM/yyyy | d/M/yyyy
|
|
921
|
+
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
|
922
|
+
const [d, m, y] = value.split('/').map(Number);
|
|
923
|
+
date = new Date(y, m - 1, d);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// yyyy/MM/dd | yyyy/M/d
|
|
927
|
+
else if (/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(value)) {
|
|
928
|
+
const [y, m, d] = value.split('/').map(Number);
|
|
929
|
+
date = new Date(y, m - 1, d);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// MM/yyyy | M/yyyy
|
|
933
|
+
else if (/^\d{1,2}\/\d{4}$/.test(value)) {
|
|
934
|
+
const [m, y] = value.split('/').map(Number);
|
|
935
|
+
date = new Date(y, m - 1, 1);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// yyyy/MM | yyyy/M
|
|
939
|
+
else if (/^\d{4}\/\d{1,2}$/.test(value)) {
|
|
940
|
+
const [y, m] = value.split('/').map(Number);
|
|
941
|
+
date = new Date(y, m - 1, 1);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// dd-MM-yyyy
|
|
945
|
+
else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
946
|
+
const [d, m, y] = value.split('-').map(Number);
|
|
947
|
+
date = new Date(y, m - 1, d);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// yyyy-MM-dd | yyyy-M-d
|
|
951
|
+
else if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(value)) {
|
|
952
|
+
const [y, m, d] = value.split('-').map(Number);
|
|
953
|
+
date = new Date(y, m - 1, d);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// ISO datetime
|
|
957
|
+
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(value)) {
|
|
958
|
+
date = new Date(value);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// ISO datetime milliseconds
|
|
962
|
+
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?$/.test(value)) {
|
|
963
|
+
date = new Date(value);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// yyyyMMdd
|
|
967
|
+
else if (/^\d{8}$/.test(value)) {
|
|
968
|
+
const y = Number(value.slice(0, 4));
|
|
969
|
+
const m = Number(value.slice(4, 6));
|
|
970
|
+
const d = Number(value.slice(6, 8));
|
|
971
|
+
date = new Date(y, m - 1, d);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// dd MMM yyyy
|
|
975
|
+
else if (/^\d{1,2}\s[A-Za-z]{3}\s\d{4}$/.test(value)) {
|
|
976
|
+
const [d, mon, y] = value.split(' ');
|
|
977
|
+
date = new Date(Number(y), monthMap[mon], Number(d));
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// MMM dd, yyyy
|
|
981
|
+
else if (/^[A-Za-z]{3}\s\d{1,2},\s\d{4}$/.test(value)) {
|
|
982
|
+
const [mon, dayComma, y] = value.split(' ');
|
|
983
|
+
const d = Number(dayComma.replace(',', ''));
|
|
984
|
+
date = new Date(Number(y), monthMap[mon], d);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// full text date
|
|
988
|
+
else if (/^[A-Za-z]+,\s[A-Za-z]+\s\d{1,2},\s\d{4}$/.test(value)) {
|
|
989
|
+
date = new Date(value);
|
|
990
|
+
}
|
|
991
|
+
if (!date || isNaN(date.getTime())) {
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
return date;
|
|
995
|
+
};
|
|
996
|
+
exports.convertFomatedDateToDate = convertFomatedDateToDate;
|
|
828
997
|
function isDate(value) {
|
|
829
998
|
if (value instanceof Date) {
|
|
830
999
|
return !isNaN(value.getTime());
|
|
@@ -885,8 +1054,11 @@ const shouldInclude = (item, queries, ignoreAccents) => {
|
|
|
885
1054
|
} = query;
|
|
886
1055
|
const itemValue = item[field];
|
|
887
1056
|
let condition = false;
|
|
888
|
-
|
|
889
|
-
const
|
|
1057
|
+
|
|
1058
|
+
// const aaa = convertFomatedDateToDate('25/01/2026')
|
|
1059
|
+
|
|
1060
|
+
const isDateComparison = isDate(itemValue) || isDateString(value) || isDateValue(itemValue) || isDateValue(value);
|
|
1061
|
+
const itemDate = isDateComparison ? isNaN(new Date(itemValue).getTime()) ? convertFomatedDateToDate(itemValue) : new Date(itemValue) : null;
|
|
890
1062
|
const queryDate = isDateComparison ? parseToDate(value) : null;
|
|
891
1063
|
const itemStr = removeVietnameseTones(itemValue?.toString().toLowerCase?.() ?? '');
|
|
892
1064
|
const queryStr = removeVietnameseTones(value?.toString().toLowerCase?.() ?? '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.20",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rc-checkbox": "^3.5.0",
|
|
67
67
|
"rc-dropdown": "^4.2.1",
|
|
68
68
|
"rc-field-form": "^2.6.0",
|
|
69
|
-
"rc-master-ui": "1.1.
|
|
69
|
+
"rc-master-ui": "1.1.59",
|
|
70
70
|
"rc-select": "^14.16.3",
|
|
71
71
|
"rc-tooltip": "^6.3.0",
|
|
72
72
|
"rc-tree": "^5.10.1",
|