react-table-edit 1.4.12 → 1.4.14
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/dist/component/edit-form/index.d.ts +1 -10
- package/dist/component/select-table/index.d.ts +1 -22
- package/dist/component/table/key-handlers.d.ts +6 -4
- package/dist/component/type/index.d.ts +194 -2
- package/dist/index.d.ts +228 -67
- package/dist/index.js +68 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,224 +1,352 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, {
|
|
2
|
+
import React__default, { ReactNode, Dispatch, SetStateAction, JSX } from 'react';
|
|
3
3
|
import { UseFormSetValue, UseFormGetValues, UseFormReset, Control, UseFormWatch, FieldErrors } from 'react-hook-form';
|
|
4
4
|
import { TFunction } from 'react-i18next';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
field: string;
|
|
9
|
-
headerText: string;
|
|
10
|
-
visible?: boolean;
|
|
11
|
-
textAlign?: 'left' | 'right' | 'center';
|
|
12
|
-
type?: 'text' | 'numeric' | 'date' | 'datetime';
|
|
13
|
-
template?: any;
|
|
14
|
-
typeCondition?: any;
|
|
15
|
-
fraction?: number;
|
|
16
|
-
width?: number;
|
|
17
|
-
maxWidth?: number;
|
|
18
|
-
minWidth?: number;
|
|
19
|
-
};
|
|
20
|
-
type IFTableSelectFormat = {
|
|
21
|
-
dateFormat?: string;
|
|
22
|
-
datetimeFormat?: string;
|
|
23
|
-
decimalSeparator?: string;
|
|
24
|
-
thousandSeparator?: string;
|
|
25
|
-
colorNegative?: string;
|
|
26
|
-
prefixNegative?: string;
|
|
27
|
-
suffixNegative?: string;
|
|
28
|
-
};
|
|
29
|
-
type Props$1 = {
|
|
30
|
-
id?: string;
|
|
31
|
-
value: any;
|
|
32
|
-
options: any[];
|
|
33
|
-
fieldValue?: string;
|
|
34
|
-
fieldLabel?: string;
|
|
35
|
-
textAlign?: 'left' | 'right' | 'center';
|
|
36
|
-
placeholder?: string;
|
|
37
|
-
invalid?: boolean;
|
|
38
|
-
menuWidth?: number;
|
|
39
|
-
width?: number;
|
|
40
|
-
isMulti?: boolean;
|
|
41
|
-
noHeader?: boolean;
|
|
42
|
-
maxHeight?: number;
|
|
43
|
-
columns?: IFColumnSelectTable[];
|
|
44
|
-
isClearable?: boolean;
|
|
45
|
-
isDisabled?: boolean;
|
|
46
|
-
allowCreate?: boolean;
|
|
47
|
-
showFooter?: boolean;
|
|
48
|
-
formatSetting?: IFTableSelectFormat;
|
|
49
|
-
component?: string | HTMLElement | React__default.RefObject<HTMLElement> | undefined;
|
|
50
|
-
formatOptionLabel?: (ele: any) => JSX.Element;
|
|
51
|
-
loadOptions?: (keyword: string, callback: (rs: any[]) => void) => void;
|
|
52
|
-
onKeyDown?: (e: React__default.KeyboardEvent<HTMLInputElement>) => any;
|
|
53
|
-
onOpenMenu?: () => void;
|
|
54
|
-
handleAdd?: (e?: any) => void;
|
|
55
|
-
onPaste?: (e: React__default.ClipboardEvent<HTMLInputElement>) => void;
|
|
56
|
-
onCloseMenu?: () => void;
|
|
57
|
-
footerComponent?: () => JSX.Element;
|
|
58
|
-
onChange: (val: any) => void;
|
|
59
|
-
};
|
|
60
|
-
declare const SelectTable: React__default.ForwardRefExoticComponent<Props$1 & React__default.RefAttributes<unknown>>;
|
|
61
|
-
|
|
62
|
-
type FromItemsField = {
|
|
63
|
-
name: string;
|
|
64
|
-
label: string;
|
|
65
|
-
type: 'text' | 'numeric' | 'select' | 'selectCreatable';
|
|
66
|
-
disabled?: boolean;
|
|
67
|
-
fraction?: number;
|
|
68
|
-
min?: number;
|
|
69
|
-
max?: number;
|
|
70
|
-
options?: any[];
|
|
71
|
-
};
|
|
72
|
-
|
|
7
|
+
/** Căn lề văn bản trong bảng */
|
|
73
8
|
type ITextAlign = 'center' | 'left' | 'right';
|
|
9
|
+
/** Loại chỉnh sửa của cột */
|
|
74
10
|
type IEditType = 'text' | 'numeric' | 'datetime' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'formInline' | 'color';
|
|
11
|
+
/** Cấu hình thao tác trên cột */
|
|
75
12
|
type ICommandItem = {
|
|
13
|
+
/** ID thao tác */
|
|
76
14
|
id: string;
|
|
15
|
+
/** Màu hiển thị thao tác */
|
|
77
16
|
color?: string;
|
|
17
|
+
/** Tooltip mô tả thao tác */
|
|
78
18
|
tooltip?: string;
|
|
19
|
+
/** Icon đại diện thao tác */
|
|
79
20
|
icon?: string;
|
|
21
|
+
/** Template hiển thị thao tác */
|
|
80
22
|
commandTemplate?: ReactNode;
|
|
81
23
|
};
|
|
24
|
+
/** Cấu hình thanh công cụ (toolbar) */
|
|
82
25
|
type IFToolbarOptions = {
|
|
26
|
+
/** Vị trí hiển thị (trái, phải, giữa) */
|
|
83
27
|
align: 'left' | 'right' | 'center';
|
|
28
|
+
/** Template toolbar */
|
|
84
29
|
template: any;
|
|
85
30
|
};
|
|
31
|
+
/** Cấu hình phần tử form khi dùng loại cột `form` */
|
|
86
32
|
type ISettingFormElement = {
|
|
33
|
+
/** Schema định nghĩa cấu trúc form */
|
|
87
34
|
schema: any;
|
|
35
|
+
/** Kích thước nhãn */
|
|
88
36
|
labelSize?: 'label-small' | 'label-medium' | 'label-large';
|
|
37
|
+
/** Chiều rộng popup form */
|
|
89
38
|
menuWidth?: number;
|
|
39
|
+
/** Chiều cao popup form */
|
|
90
40
|
menuHeight?: number;
|
|
41
|
+
/** Giá trị hiển thị */
|
|
91
42
|
displayValue?: any;
|
|
43
|
+
/** Tự mở khi focus */
|
|
92
44
|
openOnFocus?: boolean;
|
|
45
|
+
/** Cho phép xóa giá trị */
|
|
93
46
|
isClearable?: boolean;
|
|
47
|
+
/** Sự kiện mở form */
|
|
94
48
|
onFormOpen?: (rowData: any, itemsField: FromItemsField[], setItemsField: Dispatch<SetStateAction<FromItemsField[]>>) => void;
|
|
49
|
+
/** Sự kiện submit form */
|
|
95
50
|
onFormSubmit?: (rowData: any, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>, reset: UseFormReset<any>) => void;
|
|
51
|
+
/** Footer tùy chỉnh trong form */
|
|
96
52
|
footerTemplate?: (rowData: any) => JSX.Element;
|
|
53
|
+
/** Sự kiện thay đổi trường dữ liệu */
|
|
97
54
|
onChangeField?: (rowData: any, field: string, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>) => void;
|
|
55
|
+
/** Sự kiện thay đổi form */
|
|
98
56
|
onChange?: (rowData: any) => void;
|
|
99
57
|
};
|
|
58
|
+
/** Cấu hình cho cột kiểu `select` */
|
|
100
59
|
type ISettingSelectElement = {
|
|
60
|
+
/** Cho phép xóa giá trị */
|
|
101
61
|
isClearable?: boolean;
|
|
62
|
+
/** Cho phép chọn nhiều */
|
|
102
63
|
isMulti?: boolean;
|
|
64
|
+
/** Không hiển thị header */
|
|
103
65
|
noHeader?: boolean;
|
|
66
|
+
/** Hiển thị footer */
|
|
104
67
|
showFooter?: boolean;
|
|
68
|
+
/** Tự động chọn các con */
|
|
105
69
|
selectChilds?: boolean;
|
|
70
|
+
/** Cho phép thêm mới */
|
|
106
71
|
allowCreate?: boolean;
|
|
72
|
+
/** Giá trị mặc định */
|
|
107
73
|
defaultValue?: any;
|
|
74
|
+
/** Trường lấy giá trị */
|
|
108
75
|
fieldValue?: string;
|
|
76
|
+
/** Trường hiển thị nhãn */
|
|
109
77
|
fieldLabel?: string;
|
|
78
|
+
/** Trường con */
|
|
110
79
|
fieldChild?: string;
|
|
80
|
+
/** Danh sách options */
|
|
111
81
|
options?: any[];
|
|
82
|
+
/** Chiều rộng popup chọn */
|
|
112
83
|
widthPopup?: string | number;
|
|
84
|
+
/** Chiều cao popup chọn */
|
|
113
85
|
heightPopup?: string | number;
|
|
86
|
+
/** Icon của nhóm chọn */
|
|
114
87
|
iconGroup?: string;
|
|
88
|
+
/** Sự kiện thêm mới */
|
|
115
89
|
handAddNew?: any;
|
|
90
|
+
/** Hàm validate option */
|
|
116
91
|
validateOption?: any;
|
|
92
|
+
/** Trường lấy options */
|
|
117
93
|
optionsField?: string;
|
|
94
|
+
/** Danh sách cột hiển thị trong bảng chọn */
|
|
118
95
|
columns?: IFColumnSelectTable[];
|
|
96
|
+
/** Tuỳ chỉnh hiển thị option */
|
|
119
97
|
formatOptionLabel?: (ele: any) => JSX.Element;
|
|
98
|
+
/** Component footer trong menu chọn */
|
|
120
99
|
footerComponent?: () => JSX.Element;
|
|
100
|
+
/** Load options động */
|
|
121
101
|
loadOptions?: (keyword: string, callback: (rs: any[]) => void) => void;
|
|
102
|
+
/** Sự kiện mở menu */
|
|
122
103
|
onOpenMenu?: (row: any, col: IColumnTable, indexRow: number) => void;
|
|
123
104
|
};
|
|
105
|
+
/** Cấu hình cho kiểu số */
|
|
124
106
|
type ISettingNumericElement = {
|
|
107
|
+
/** Giá trị nhỏ nhất */
|
|
125
108
|
min?: number;
|
|
109
|
+
/** Giá trị lớn nhất */
|
|
126
110
|
max?: number;
|
|
111
|
+
/** Số chữ số thập phân */
|
|
127
112
|
fraction?: number;
|
|
113
|
+
/** Cho phép giá trị âm */
|
|
128
114
|
allowNegative?: boolean;
|
|
129
115
|
};
|
|
116
|
+
/** Định nghĩa cột bảng */
|
|
130
117
|
type IColumnTable = {
|
|
118
|
+
/** Tên thuộc tính */
|
|
131
119
|
field: string;
|
|
120
|
+
/** Tiêu đề hiển thị ở header */
|
|
132
121
|
headerText?: string;
|
|
122
|
+
/** Khóa chính */
|
|
133
123
|
isPrimarykey?: boolean;
|
|
124
|
+
/** Duy nhất trong bảng */
|
|
134
125
|
isUnikey?: boolean;
|
|
126
|
+
/** Có tính tổng */
|
|
135
127
|
haveSum?: boolean;
|
|
128
|
+
/** Có tooltip */
|
|
136
129
|
haveToolTip?: boolean;
|
|
130
|
+
/** Chiều rộng cột */
|
|
137
131
|
width?: number | string;
|
|
132
|
+
/** Chiều rộng tối thiểu */
|
|
138
133
|
minWidth?: number | string;
|
|
134
|
+
/** Chiều rộng tối đa */
|
|
139
135
|
maxWidth?: number | string;
|
|
136
|
+
/** Cho phép chỉnh sửa */
|
|
140
137
|
editEnable?: boolean;
|
|
138
|
+
/** Có hiển thị không */
|
|
141
139
|
visible?: boolean;
|
|
140
|
+
/** Không cho phép thay đổi trạng thái ẩn/hiện */
|
|
142
141
|
invisibleDisable?: boolean;
|
|
142
|
+
/** Kiểu chỉnh sửa */
|
|
143
143
|
editType?: IEditType;
|
|
144
|
+
/** Căn lề */
|
|
144
145
|
textAlign?: ITextAlign;
|
|
146
|
+
/** Cố định trái/phải */
|
|
145
147
|
fixedType?: 'left' | 'right' | undefined;
|
|
148
|
+
/** Danh sách thao tác */
|
|
146
149
|
commandItems?: ICommandItem[];
|
|
150
|
+
/** Placeholder trong ô input */
|
|
147
151
|
placeholder?: string;
|
|
152
|
+
/** Cấu hình cho kiểu numeric */
|
|
148
153
|
numericSettings?: ISettingNumericElement;
|
|
154
|
+
/** Cấu hình cho kiểu select */
|
|
149
155
|
selectSettings?: ISettingSelectElement;
|
|
156
|
+
/** Cấu hình cho kiểu form */
|
|
150
157
|
formSettings?: ISettingFormElement;
|
|
158
|
+
/** Danh sách cột con */
|
|
151
159
|
columns?: IColumnTable[];
|
|
160
|
+
/** Không cho phép dán giá trị */
|
|
152
161
|
disablePaste?: boolean;
|
|
162
|
+
/**Giá trị trường callback khi copy xuống các dòng dưới */
|
|
163
|
+
callbackValue?: (row: any) => any;
|
|
164
|
+
/** Validate giá trị */
|
|
153
165
|
validate?: (value: any, row: any) => string | undefined;
|
|
166
|
+
/** Điều kiện disable cột */
|
|
154
167
|
disabledCondition?: (row: any) => boolean;
|
|
168
|
+
/** Callback khi thay đổi giá trị */
|
|
155
169
|
callback?: (value: any, indexRow: number, item: any) => void;
|
|
170
|
+
/** Template hiển thị khi không ở chế độ edit */
|
|
156
171
|
template?: (row: any, indexRow: number) => JSX.Element | string | number | undefined;
|
|
172
|
+
/** Xác định loại edit dựa trên điều kiện */
|
|
157
173
|
editTypeCondition?: (row: any) => string;
|
|
174
|
+
/** Sự kiện khi paste dữ liệu */
|
|
158
175
|
onPaste?: (dataRow: any, dataPaste: any) => void;
|
|
176
|
+
/** Xác thực dữ liệu được paste */
|
|
159
177
|
onPasteValidate?: (dataPaste: string, dataRow: any, rowIndex: number) => Promise<any>;
|
|
160
178
|
};
|
|
179
|
+
/** Cấu hình phân trang */
|
|
161
180
|
type IFTableEditPaging = {
|
|
181
|
+
/** Bật phân trang */
|
|
162
182
|
allowPaging?: boolean;
|
|
183
|
+
/** Phân trang phía client */
|
|
163
184
|
pagingClient?: boolean;
|
|
185
|
+
/** Trang hiện tại */
|
|
164
186
|
currentPage?: number;
|
|
187
|
+
/** Hàm cập nhật trang hiện tại */
|
|
165
188
|
setCurrentPage?: Dispatch<SetStateAction<number>>;
|
|
189
|
+
/** Hàm cập nhật số dòng mỗi trang */
|
|
166
190
|
setPageSize?: Dispatch<SetStateAction<number>>;
|
|
191
|
+
/** Số dòng mỗi trang */
|
|
167
192
|
pageSize?: number;
|
|
193
|
+
/** Tổng số dòng */
|
|
168
194
|
totalItem?: number;
|
|
195
|
+
/** Các lựa chọn số dòng/trang */
|
|
169
196
|
pageOptions?: number[];
|
|
170
197
|
};
|
|
198
|
+
/** Cấu hình các nút thao tác trên bảng */
|
|
171
199
|
type IFTableEditButton = {
|
|
200
|
+
/** Vô hiệu hóa nút xóa tất cả */
|
|
172
201
|
deleteAllDisable?: boolean;
|
|
202
|
+
/** Vô hiệu hóa nút chèn sau */
|
|
173
203
|
insertAfterDisable?: boolean;
|
|
204
|
+
/** Vô hiệu hóa nút chèn trước */
|
|
174
205
|
insertBeforeDisable?: boolean;
|
|
206
|
+
/** Vô hiệu hóa nút nhân bản */
|
|
175
207
|
duplicateDisable?: boolean;
|
|
176
208
|
};
|
|
209
|
+
/** Cấu hình toolbar bảng */
|
|
177
210
|
type IFTableEditToolbar = {
|
|
211
|
+
/** Hiển thị thanh công cụ trên */
|
|
178
212
|
showTopToolbar?: boolean;
|
|
213
|
+
/** Danh sách toolbar trên */
|
|
179
214
|
toolbarOptions?: IFToolbarOptions[];
|
|
215
|
+
/** Danh sách toolbar dưới */
|
|
180
216
|
toolbarBottomOptions?: IFToolbarOptions[];
|
|
217
|
+
/** Hiển thị thanh công cụ dưới */
|
|
181
218
|
showBottomToolbar?: boolean;
|
|
182
219
|
};
|
|
220
|
+
/** Cấu hình tìm kiếm trong bảng */
|
|
183
221
|
type IFTableEditSearchSetting = {
|
|
222
|
+
/** Bật tìm kiếm */
|
|
184
223
|
searchEnable?: boolean;
|
|
224
|
+
/** Tìm kiếm phía client */
|
|
185
225
|
searchClient?: boolean;
|
|
226
|
+
/** Từ khóa tìm kiếm */
|
|
186
227
|
searchTerm?: string;
|
|
228
|
+
/** Các trường dùng để tìm kiếm */
|
|
187
229
|
keyField?: string[];
|
|
230
|
+
/** Hàm cập nhật từ khóa */
|
|
188
231
|
setSearchTerm?: Dispatch<SetStateAction<string>>;
|
|
189
232
|
};
|
|
233
|
+
/** Cấu hình định dạng số, ngày... */
|
|
190
234
|
type IFTableEditFormat = {
|
|
235
|
+
/** Định dạng ngày */
|
|
191
236
|
dateFormat?: string;
|
|
237
|
+
/** Định dạng ngày giờ */
|
|
192
238
|
datetimeFormat?: string;
|
|
239
|
+
/** Ký tự phân cách phần thập phân */
|
|
193
240
|
decimalSeparator?: string;
|
|
241
|
+
/** Ký tự phân cách phần nghìn */
|
|
194
242
|
thousandSeparator?: string;
|
|
243
|
+
/** Màu số âm */
|
|
195
244
|
colorNegative?: string;
|
|
245
|
+
/** Tiền tố số âm */
|
|
196
246
|
prefixNegative?: string;
|
|
247
|
+
/** Hậu tố số âm */
|
|
197
248
|
suffixNegative?: string;
|
|
198
249
|
};
|
|
250
|
+
/** Cấu hình page size */
|
|
199
251
|
type IFPageSize = {
|
|
252
|
+
/** Số dòng mỗi trang */
|
|
200
253
|
pageSize: number;
|
|
201
254
|
};
|
|
255
|
+
/** Cấu hình current page */
|
|
202
256
|
type IFCurrentPage = {
|
|
257
|
+
/** Trang hiện tại */
|
|
203
258
|
currentPage: number;
|
|
204
259
|
};
|
|
260
|
+
/** Cấu hình current page kèm trang cũ */
|
|
205
261
|
type IFCurrentPageConfig = {
|
|
262
|
+
/** Trang hiện tại */
|
|
206
263
|
currentPage: number;
|
|
264
|
+
/** Trang cũ */
|
|
207
265
|
oldPage: number;
|
|
208
266
|
};
|
|
267
|
+
/** Header bảng hỗ trợ merge cột */
|
|
209
268
|
type IHeaderColumnTable = {
|
|
269
|
+
/** Tên thuộc tính */
|
|
210
270
|
field: string;
|
|
271
|
+
/** Tiêu đề header */
|
|
211
272
|
headerText?: string;
|
|
273
|
+
/** Chiều rộng */
|
|
212
274
|
width?: number | string;
|
|
275
|
+
/** Chiều rộng tối thiểu */
|
|
213
276
|
minWidth?: number | string;
|
|
277
|
+
/** Chiều rộng tối đa */
|
|
214
278
|
maxWidth?: number | string;
|
|
279
|
+
/** Hiển thị/ẩn */
|
|
215
280
|
visible?: boolean;
|
|
281
|
+
/** Số dòng chiếm (rowspan) */
|
|
216
282
|
rowspan?: number;
|
|
283
|
+
/** Cột con */
|
|
217
284
|
columns?: IColumnTable[];
|
|
285
|
+
/** Căn lề */
|
|
218
286
|
textAlign?: ITextAlign;
|
|
287
|
+
/** Cố định trái/phải */
|
|
219
288
|
fixedType?: 'left' | 'right' | undefined;
|
|
289
|
+
/** Thứ tự cột */
|
|
220
290
|
index?: number;
|
|
221
291
|
};
|
|
292
|
+
type IFColumnSelectTable = {
|
|
293
|
+
/** Tên thuộc tính trường dữ liệu */
|
|
294
|
+
field: string;
|
|
295
|
+
/** Tiêu đề hiển thị ở phần header của cột */
|
|
296
|
+
headerText: string;
|
|
297
|
+
/** Cờ cho phép hiển thị hoặc ẩn cột (mặc định là true) */
|
|
298
|
+
visible?: boolean;
|
|
299
|
+
/** Căn lề nội dung trong cột: trái, phải, giữa */
|
|
300
|
+
textAlign?: 'left' | 'right' | 'center';
|
|
301
|
+
/** Loại dữ liệu của cột: văn bản, số, ngày, ngày giờ */
|
|
302
|
+
type?: 'text' | 'numeric' | 'date' | 'datetime';
|
|
303
|
+
/** Template tùy chỉnh nội dung hiển thị trong ô */
|
|
304
|
+
template?: any;
|
|
305
|
+
/** Điều kiện thay đổi kiểu dữ liệu của cột */
|
|
306
|
+
typeCondition?: any;
|
|
307
|
+
/** Số chữ số sau dấu phẩy (dùng cho số thực) */
|
|
308
|
+
fraction?: number;
|
|
309
|
+
/** Chiều rộng cột (tính bằng pixel) */
|
|
310
|
+
width?: number;
|
|
311
|
+
/** Chiều rộng tối đa của cột */
|
|
312
|
+
maxWidth?: number;
|
|
313
|
+
/** Chiều rộng tối thiểu của cột */
|
|
314
|
+
minWidth?: number;
|
|
315
|
+
};
|
|
316
|
+
type IFTableSelectFormat = {
|
|
317
|
+
/** Định dạng ngày (vd: 'dd/MM/yyyy') */
|
|
318
|
+
dateFormat?: string;
|
|
319
|
+
/** Định dạng ngày giờ (vd: 'dd/MM/yyyy HH:mm:ss') */
|
|
320
|
+
datetimeFormat?: string;
|
|
321
|
+
/** Ký tự phân cách phần thập phân (vd: ',') */
|
|
322
|
+
decimalSeparator?: string;
|
|
323
|
+
/** Ký tự phân cách hàng nghìn (vd: '.') */
|
|
324
|
+
thousandSeparator?: string;
|
|
325
|
+
/** Màu hiển thị số âm (vd: 'red') */
|
|
326
|
+
colorNegative?: string;
|
|
327
|
+
/** Tiền tố hiển thị trước số âm (vd: '(') */
|
|
328
|
+
prefixNegative?: string;
|
|
329
|
+
/** Hậu tố hiển thị sau số âm (vd: ')') */
|
|
330
|
+
suffixNegative?: string;
|
|
331
|
+
};
|
|
332
|
+
type FromItemsField = {
|
|
333
|
+
/** Tên thuộc tính (dùng làm key khi thao tác dữ liệu) */
|
|
334
|
+
name: string;
|
|
335
|
+
/** Nhãn hiển thị cho trường dữ liệu */
|
|
336
|
+
label: string;
|
|
337
|
+
/** Loại trường dữ liệu: văn bản, số, chọn, chọn có thể tạo mới */
|
|
338
|
+
type: 'text' | 'numeric' | 'select' | 'selectCreatable';
|
|
339
|
+
/** Trường có bị disable hay không (không cho chỉnh sửa) */
|
|
340
|
+
disabled?: boolean;
|
|
341
|
+
/** Số chữ số sau dấu phẩy (chỉ áp dụng với loại 'numeric') */
|
|
342
|
+
fraction?: number;
|
|
343
|
+
/** Giá trị tối thiểu (chỉ áp dụng với loại 'numeric') */
|
|
344
|
+
min?: number;
|
|
345
|
+
/** Giá trị tối đa (chỉ áp dụng với loại 'numeric') */
|
|
346
|
+
max?: number;
|
|
347
|
+
/** Danh sách lựa chọn (chỉ áp dụng với loại 'select' và 'selectCreatable') */
|
|
348
|
+
options?: any[];
|
|
349
|
+
};
|
|
222
350
|
|
|
223
351
|
type IFTableEditProps = {
|
|
224
352
|
idTable?: string;
|
|
@@ -300,6 +428,39 @@ type IFDataProps$1 = {
|
|
|
300
428
|
};
|
|
301
429
|
declare const TabsMenuComponent: ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode, windowSize, renderModal }: IFDataProps$1) => react_jsx_runtime.JSX.Element;
|
|
302
430
|
|
|
431
|
+
type Props$1 = {
|
|
432
|
+
id?: string;
|
|
433
|
+
value: any;
|
|
434
|
+
options: any[];
|
|
435
|
+
fieldValue?: string;
|
|
436
|
+
fieldLabel?: string;
|
|
437
|
+
textAlign?: 'left' | 'right' | 'center';
|
|
438
|
+
placeholder?: string;
|
|
439
|
+
invalid?: boolean;
|
|
440
|
+
menuWidth?: number;
|
|
441
|
+
width?: number;
|
|
442
|
+
isMulti?: boolean;
|
|
443
|
+
noHeader?: boolean;
|
|
444
|
+
maxHeight?: number;
|
|
445
|
+
columns?: IFColumnSelectTable[];
|
|
446
|
+
isClearable?: boolean;
|
|
447
|
+
isDisabled?: boolean;
|
|
448
|
+
allowCreate?: boolean;
|
|
449
|
+
showFooter?: boolean;
|
|
450
|
+
formatSetting?: IFTableSelectFormat;
|
|
451
|
+
component?: string | HTMLElement | React__default.RefObject<HTMLElement> | undefined;
|
|
452
|
+
formatOptionLabel?: (ele: any) => JSX.Element;
|
|
453
|
+
loadOptions?: (keyword: string, callback: (rs: any[]) => void) => void;
|
|
454
|
+
onKeyDown?: (e: React__default.KeyboardEvent<HTMLInputElement>) => any;
|
|
455
|
+
onOpenMenu?: () => void;
|
|
456
|
+
handleAdd?: (e?: any) => void;
|
|
457
|
+
onPaste?: (e: React__default.ClipboardEvent<HTMLInputElement>) => void;
|
|
458
|
+
onCloseMenu?: () => void;
|
|
459
|
+
footerComponent?: () => JSX.Element;
|
|
460
|
+
onChange: (val: any) => void;
|
|
461
|
+
};
|
|
462
|
+
declare const SelectTable: React__default.ForwardRefExoticComponent<Props$1 & React__default.RefAttributes<unknown>>;
|
|
463
|
+
|
|
303
464
|
type IFColumnSelectTableTree = {
|
|
304
465
|
field: string;
|
|
305
466
|
headerText: string;
|
package/dist/index.js
CHANGED
|
@@ -42264,7 +42264,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42264
42264
|
return ((item.align === 'center') ? jsxRuntime.jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : '');
|
|
42265
42265
|
}) }), jsxRuntime.jsxs("div", { className: "r-toolbar-right", children: [toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
42266
42266
|
return ((item.align === 'right') ? jsxRuntime.jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : '');
|
|
42267
|
-
}), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item me-25', { 'd-none': headerColumns.length > 1 }), "aria-disabled": "false", children: jsxRuntime.jsx(SvgSettings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item me-25', { 'd-none': editDisable || addDisable }), "aria-disabled": "false", children: jsxRuntime.jsxs(UncontrolledDropdown, { className: 'dropdown-user nav-item', children: [jsxRuntime.jsx(DropdownToggle$1, { tag: 'div', color: "primary", onClick: (e) => e.preventDefault(), children: jsxRuntime.jsx(SvgInfo, { className: "cursor-pointer text-primary" }) }), jsxRuntime.jsx(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown', children: jsxRuntime.jsxs("ul", { className: "mb-0 pe-50", children: [jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\u00E2n b\u1EA3n" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Ch\u1ECDn \u00F4 v\u00E0 Ctrl + V \u0111\u1EC3 d\u00E1n th\u00F4ng tin t\u1EEB excel" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + C \u0111\u1EC3 sao ch\u00E9p h\u00E0ng" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + V \u0111\u1EC3 d\u00E1n h\u00E0ng" })] }) })] }) })] })] }) }));
|
|
42267
|
+
}), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item me-25', { 'd-none': headerColumns.length > 1 }), "aria-disabled": "false", children: jsxRuntime.jsx(SvgSettings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item me-25', { 'd-none': editDisable || addDisable }), "aria-disabled": "false", children: jsxRuntime.jsxs(UncontrolledDropdown, { className: 'dropdown-user nav-item', children: [jsxRuntime.jsx(DropdownToggle$1, { tag: 'div', color: "primary", onClick: (e) => e.preventDefault(), children: jsxRuntime.jsx(SvgInfo, { className: "cursor-pointer text-primary" }) }), jsxRuntime.jsx(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown', children: jsxRuntime.jsxs("ul", { className: "mb-0 pe-50", children: [jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\u00E2n b\u1EA3n" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Ch\u1ECDn \u00F4 v\u00E0 Ctrl + V \u0111\u1EC3 d\u00E1n th\u00F4ng tin t\u1EEB excel" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + C \u0111\u1EC3 sao ch\u00E9p h\u00E0ng" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\u00E0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\u00E0ng v\u00E0 nh\u1EA5n Ctrl + V \u0111\u1EC3 d\u00E1n h\u00E0ng" }), jsxRuntime.jsx("li", { style: { fontSize: 13 }, children: "Nh\u1EA5n Ctrl + Shift + \u2193 \u0111\u1EC3 sao ch\u00E9p d\u1EEF li\u1EC7u \u00F4 cho c\u00E1c d\u00F2ng d\u01B0\u1EDBi" })] }) })] }) })] })] }) }));
|
|
42268
42268
|
};
|
|
42269
42269
|
|
|
42270
42270
|
const handleArrowRight = (e, params) => {
|
|
@@ -42301,31 +42301,73 @@ const isSelectMenuOpen = (element) => {
|
|
|
42301
42301
|
return element && ["select__control--menu-is-open", "select-100__control--menu-is-open", "select-200__control--menu-is-open", "select-300__control--menu-is-open", "select-400__control--menu-is-open", "select-500__control--menu-is-open"].some(className => element.getElementsByClassName(className).length > 0);
|
|
42302
42302
|
};
|
|
42303
42303
|
const handleArrowUp = (e, params) => {
|
|
42304
|
-
const { idElement, indexCol, indexRow, pagingClient, pagingSetting, setIndexFocus, focusNewElement } = params;
|
|
42305
|
-
|
|
42306
|
-
|
|
42307
|
-
|
|
42308
|
-
|
|
42309
|
-
|
|
42310
|
-
|
|
42311
|
-
|
|
42312
|
-
|
|
42304
|
+
const { idElement, indexCol, indexRow, pagingClient, pagingSetting, setIndexFocus, focusNewElement, rowChange, changeDataSource, contentColumns, dataSource, row } = params;
|
|
42305
|
+
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
|
42306
|
+
if (indexRow > 0) {
|
|
42307
|
+
const column = contentColumns[indexCol - 1];
|
|
42308
|
+
for (let index = indexRow - 1; index > 0; index--) {
|
|
42309
|
+
const element = dataSource[index];
|
|
42310
|
+
element[column.field ?? ''] = row[column.field ?? ''];
|
|
42311
|
+
if (column.callback && column.callbackValue) {
|
|
42312
|
+
const value = column.callbackValue(row);
|
|
42313
|
+
column.callback(value, index, element);
|
|
42314
|
+
}
|
|
42315
|
+
if (rowChange) {
|
|
42316
|
+
rowChange(element, indexRow, column.field);
|
|
42317
|
+
}
|
|
42318
|
+
}
|
|
42319
|
+
changeDataSource(dataSource);
|
|
42313
42320
|
e.preventDefault();
|
|
42314
42321
|
return e.code;
|
|
42315
42322
|
}
|
|
42316
42323
|
}
|
|
42324
|
+
else {
|
|
42325
|
+
const element = document.getElementById(idElement);
|
|
42326
|
+
if (!isSelectMenuOpen(element)) {
|
|
42327
|
+
if (indexRow > 1) {
|
|
42328
|
+
if (pagingClient && (pagingSetting?.currentPage ?? 0) !== 1 && (indexRow % (pagingSetting?.pageSize ?? 0)) === 1 && pagingSetting?.setCurrentPage) {
|
|
42329
|
+
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) - 1);
|
|
42330
|
+
}
|
|
42331
|
+
setIndexFocus(indexRow - 2);
|
|
42332
|
+
focusNewElement(indexCol, indexRow - 1, true);
|
|
42333
|
+
e.preventDefault();
|
|
42334
|
+
return e.code;
|
|
42335
|
+
}
|
|
42336
|
+
}
|
|
42337
|
+
}
|
|
42317
42338
|
};
|
|
42318
42339
|
const handleArrowDown = (e, params) => {
|
|
42319
|
-
const { idElement, indexCol, indexRow, totalCount, pagingClient, pagingSetting, setIndexFocus, focusNewElement } = params;
|
|
42320
|
-
|
|
42321
|
-
|
|
42322
|
-
|
|
42323
|
-
|
|
42324
|
-
|
|
42325
|
-
|
|
42326
|
-
|
|
42327
|
-
|
|
42328
|
-
|
|
42340
|
+
const { idElement, indexCol, indexRow, totalCount, pagingClient, pagingSetting, setIndexFocus, focusNewElement, rowChange, changeDataSource, dataSource, contentColumns, row } = params;
|
|
42341
|
+
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
|
42342
|
+
if (indexRow < totalCount) {
|
|
42343
|
+
const column = contentColumns[indexCol - 1];
|
|
42344
|
+
for (let index = indexRow; index < totalCount; index++) {
|
|
42345
|
+
const element = dataSource[index];
|
|
42346
|
+
element[column.field ?? ''] = row[column.field ?? ''];
|
|
42347
|
+
if (column.callback && column.callbackValue) {
|
|
42348
|
+
const value = column.callbackValue(row);
|
|
42349
|
+
column.callback(value, index, element);
|
|
42350
|
+
}
|
|
42351
|
+
if (rowChange) {
|
|
42352
|
+
rowChange(element, indexRow, column.field);
|
|
42353
|
+
}
|
|
42354
|
+
}
|
|
42355
|
+
changeDataSource(dataSource);
|
|
42356
|
+
e.preventDefault();
|
|
42357
|
+
return e.code;
|
|
42358
|
+
}
|
|
42359
|
+
}
|
|
42360
|
+
else {
|
|
42361
|
+
const element = document.getElementById(idElement);
|
|
42362
|
+
if (!isSelectMenuOpen(element) && indexRow < totalCount) {
|
|
42363
|
+
if (pagingClient && (indexRow % (pagingSetting?.pageSize ?? 0)) === 0 && pagingSetting?.setCurrentPage) {
|
|
42364
|
+
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 1) + 1);
|
|
42365
|
+
}
|
|
42366
|
+
setIndexFocus(indexRow);
|
|
42367
|
+
focusNewElement(indexCol, indexRow + 1, true);
|
|
42368
|
+
e.preventDefault();
|
|
42369
|
+
return e.code;
|
|
42370
|
+
}
|
|
42329
42371
|
}
|
|
42330
42372
|
};
|
|
42331
42373
|
const handleTab = (e, params) => {
|
|
@@ -42704,9 +42746,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42704
42746
|
}
|
|
42705
42747
|
handleDataChange(row, col, indexRow);
|
|
42706
42748
|
}, dateFormat: "dd/MM/yyyy HH:mm", onKeyDown: (e) => {
|
|
42707
|
-
|
|
42708
|
-
return true;
|
|
42709
|
-
}
|
|
42749
|
+
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42710
42750
|
} }));
|
|
42711
42751
|
case 'select':
|
|
42712
42752
|
let valueSelect;
|
|
@@ -42752,7 +42792,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42752
42792
|
}
|
|
42753
42793
|
handleDataChange(row, col, indexRow);
|
|
42754
42794
|
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t('Select'), loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, invalid: (col.validate && !isNullOrUndefined$1(col.validate(row[col.field], row))), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', allowCreate: col.selectSettings?.allowCreate, onKeyDown: (e) => {
|
|
42755
|
-
|
|
42795
|
+
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42756
42796
|
}, onOpenMenu: () => {
|
|
42757
42797
|
if (col.selectSettings?.onOpenMenu) {
|
|
42758
42798
|
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
@@ -42808,7 +42848,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42808
42848
|
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42809
42849
|
}
|
|
42810
42850
|
}, loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? 'children', selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', onKeyDown: (e) => {
|
|
42811
|
-
|
|
42851
|
+
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42812
42852
|
}, onPaste: (e) => {
|
|
42813
42853
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42814
42854
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
@@ -42823,7 +42863,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42823
42863
|
}
|
|
42824
42864
|
handleDataChange(row, col, indexRow);
|
|
42825
42865
|
}, onKeyDown: (e) => {
|
|
42826
|
-
|
|
42866
|
+
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42827
42867
|
} }));
|
|
42828
42868
|
case 'numeric':
|
|
42829
42869
|
const numericFormatProps = {
|
|
@@ -42973,6 +43013,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42973
43013
|
addDisable,
|
|
42974
43014
|
editDisable,
|
|
42975
43015
|
focusNewElement,
|
|
43016
|
+
changeDataSource,
|
|
43017
|
+
rowChange,
|
|
42976
43018
|
handleDuplicate: () => handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate),
|
|
42977
43019
|
idElement,
|
|
42978
43020
|
indexCol,
|