react-table-edit 1.4.11 → 1.4.13

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.
@@ -1,16 +1,7 @@
1
1
  import { ClipboardEvent, Dispatch, JSX, SetStateAction } from "react";
2
2
  import { UseFormGetValues, UseFormReset, UseFormSetValue } from "react-hook-form";
3
3
  import { InferType } from "yup";
4
- export type FromItemsField = {
5
- name: string;
6
- label: string;
7
- type: 'text' | 'numeric' | 'select' | 'selectCreatable';
8
- disabled?: boolean;
9
- fraction?: number;
10
- min?: number;
11
- max?: number;
12
- options?: any[];
13
- };
4
+ import { FromItemsField } from "../type";
14
5
  type Props = {
15
6
  id?: string;
16
7
  field?: string;
@@ -1,26 +1,5 @@
1
1
  import React, { JSX } from "react";
2
- export type IFColumnSelectTable = {
3
- field: string;
4
- headerText: string;
5
- visible?: boolean;
6
- textAlign?: 'left' | 'right' | 'center';
7
- type?: 'text' | 'numeric' | 'date' | 'datetime';
8
- template?: any;
9
- typeCondition?: any;
10
- fraction?: number;
11
- width?: number;
12
- maxWidth?: number;
13
- minWidth?: number;
14
- };
15
- export type IFTableSelectFormat = {
16
- dateFormat?: string;
17
- datetimeFormat?: string;
18
- decimalSeparator?: string;
19
- thousandSeparator?: string;
20
- colorNegative?: string;
21
- prefixNegative?: string;
22
- suffixNegative?: string;
23
- };
2
+ import { IFColumnSelectTable, IFTableSelectFormat } from "../type";
24
3
  type Props = {
25
4
  id?: string;
26
5
  value: any;
@@ -10,7 +10,8 @@ type IFDataProps = {
10
10
  setColumn: Dispatch<SetStateAction<IHeaderColumnTable[]>>;
11
11
  indexCol: number;
12
12
  indexParent: number;
13
- objWidthFix: any;
13
+ objWidthFixLeft: any;
14
+ objWidthFixRight: any;
14
15
  totalCount: number;
15
16
  selectedRows: any[];
16
17
  isMulti: boolean;
@@ -1,20 +1,22 @@
1
1
  import { KeyboardEvent } from "react";
2
- import { IFTableEditPaging } from "../type";
2
+ import { IColumnTable, IFTableEditPaging } from "../type";
3
3
  export interface KeyHandlerParams {
4
4
  row: any;
5
5
  dataSource: any[];
6
6
  indexRow: number;
7
7
  indexCol: number;
8
- contentColumns: any[];
8
+ contentColumns: IColumnTable[];
9
9
  idElement: string;
10
10
  pagingClient?: boolean;
11
11
  totalCount: number;
12
12
  columnLastEdit: number;
13
- moveIndexRowToNewPage: () => void;
14
13
  editDisable?: boolean;
15
14
  addDisable?: boolean;
16
- handleDuplicate: () => void;
17
15
  pagingSetting?: IFTableEditPaging;
16
+ changeDataSource: (data: any[], numberOfRows?: number) => void;
17
+ rowChange?: (row: any, indexRow: number, field: string) => void;
18
+ handleDuplicate: () => void;
19
+ moveIndexRowToNewPage: () => void;
18
20
  focusNewElement: (col: number, row: number, onLoad?: boolean) => void;
19
21
  setIndexFocus: (index: number) => void;
20
22
  }
@@ -1,154 +1,346 @@
1
1
  import { Dispatch, ReactNode, SetStateAction, JSX } from "react";
2
- import { IFColumnSelectTable } from "../select-table";
3
- import { FromItemsField } from "../edit-form";
4
2
  import { UseFormGetValues, UseFormReset, UseFormSetValue } from "react-hook-form";
3
+ /** Căn lề văn bản trong bảng */
5
4
  type ITextAlign = 'center' | 'left' | 'right';
5
+ /** Loại chỉnh sửa của cột */
6
6
  type IEditType = 'text' | 'numeric' | 'datetime' | 'selectTree' | 'date' | 'select' | 'checkbox' | 'form' | 'formInline' | 'color';
7
+ /** Cấu hình thao tác trên cột */
7
8
  export type ICommandItem = {
9
+ /** ID thao tác */
8
10
  id: string;
11
+ /** Màu hiển thị thao tác */
9
12
  color?: string;
13
+ /** Tooltip mô tả thao tác */
10
14
  tooltip?: string;
15
+ /** Icon đại diện thao tác */
11
16
  icon?: string;
17
+ /** Template hiển thị thao tác */
12
18
  commandTemplate?: ReactNode;
13
19
  };
20
+ /** Cấu hình thanh công cụ (toolbar) */
14
21
  export type IFToolbarOptions = {
22
+ /** Vị trí hiển thị (trái, phải, giữa) */
15
23
  align: 'left' | 'right' | 'center';
24
+ /** Template toolbar */
16
25
  template: any;
17
26
  };
27
+ /** Cấu hình phần tử form khi dùng loại cột `form` */
18
28
  export type ISettingFormElement = {
29
+ /** Schema định nghĩa cấu trúc form */
19
30
  schema: any;
31
+ /** Kích thước nhãn */
20
32
  labelSize?: 'label-small' | 'label-medium' | 'label-large';
33
+ /** Chiều rộng popup form */
21
34
  menuWidth?: number;
35
+ /** Chiều cao popup form */
22
36
  menuHeight?: number;
37
+ /** Giá trị hiển thị */
23
38
  displayValue?: any;
39
+ /** Tự mở khi focus */
24
40
  openOnFocus?: boolean;
41
+ /** Cho phép xóa giá trị */
25
42
  isClearable?: boolean;
43
+ /** Sự kiện mở form */
26
44
  onFormOpen?: (rowData: any, itemsField: FromItemsField[], setItemsField: Dispatch<SetStateAction<FromItemsField[]>>) => void;
45
+ /** Sự kiện submit form */
27
46
  onFormSubmit?: (rowData: any, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>, reset: UseFormReset<any>) => void;
47
+ /** Footer tùy chỉnh trong form */
28
48
  footerTemplate?: (rowData: any) => JSX.Element;
49
+ /** Sự kiện thay đổi trường dữ liệu */
29
50
  onChangeField?: (rowData: any, field: string, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>) => void;
51
+ /** Sự kiện thay đổi form */
30
52
  onChange?: (rowData: any) => void;
31
53
  };
54
+ /** Cấu hình cho cột kiểu `select` */
32
55
  export type ISettingSelectElement = {
56
+ /** Cho phép xóa giá trị */
33
57
  isClearable?: boolean;
58
+ /** Cho phép chọn nhiều */
34
59
  isMulti?: boolean;
60
+ /** Không hiển thị header */
35
61
  noHeader?: boolean;
62
+ /** Hiển thị footer */
36
63
  showFooter?: boolean;
64
+ /** Tự động chọn các con */
37
65
  selectChilds?: boolean;
66
+ /** Cho phép thêm mới */
38
67
  allowCreate?: boolean;
68
+ /** Giá trị mặc định */
39
69
  defaultValue?: any;
70
+ /** Trường lấy giá trị */
40
71
  fieldValue?: string;
72
+ /** Trường hiển thị nhãn */
41
73
  fieldLabel?: string;
74
+ /** Trường con */
42
75
  fieldChild?: string;
76
+ /** Danh sách options */
43
77
  options?: any[];
78
+ /** Chiều rộng popup chọn */
44
79
  widthPopup?: string | number;
80
+ /** Chiều cao popup chọn */
45
81
  heightPopup?: string | number;
82
+ /** Icon của nhóm chọn */
46
83
  iconGroup?: string;
84
+ /** Sự kiện thêm mới */
47
85
  handAddNew?: any;
86
+ /** Hàm validate option */
48
87
  validateOption?: any;
88
+ /** Trường lấy options */
49
89
  optionsField?: string;
90
+ /** Danh sách cột hiển thị trong bảng chọn */
50
91
  columns?: IFColumnSelectTable[];
92
+ /** Tuỳ chỉnh hiển thị option */
51
93
  formatOptionLabel?: (ele: any) => JSX.Element;
94
+ /** Component footer trong menu chọn */
52
95
  footerComponent?: () => JSX.Element;
96
+ /** Load options động */
53
97
  loadOptions?: (keyword: string, callback: (rs: any[]) => void) => void;
98
+ /** Sự kiện mở menu */
54
99
  onOpenMenu?: (row: any, col: IColumnTable, indexRow: number) => void;
55
100
  };
101
+ /** Cấu hình cho kiểu số */
56
102
  export type ISettingNumericElement = {
103
+ /** Giá trị nhỏ nhất */
57
104
  min?: number;
105
+ /** Giá trị lớn nhất */
58
106
  max?: number;
107
+ /** Số chữ số thập phân */
59
108
  fraction?: number;
109
+ /** Cho phép giá trị âm */
60
110
  allowNegative?: boolean;
61
111
  };
112
+ /** Định nghĩa cột bảng */
62
113
  export type IColumnTable = {
114
+ /** Tên thuộc tính */
63
115
  field: string;
116
+ /** Tiêu đề hiển thị ở header */
64
117
  headerText?: string;
118
+ /** Khóa chính */
65
119
  isPrimarykey?: boolean;
120
+ /** Duy nhất trong bảng */
66
121
  isUnikey?: boolean;
122
+ /** Có tính tổng */
67
123
  haveSum?: boolean;
124
+ /** Có tooltip */
68
125
  haveToolTip?: boolean;
126
+ /** Chiều rộng cột */
69
127
  width?: number | string;
128
+ /** Chiều rộng tối thiểu */
70
129
  minWidth?: number | string;
130
+ /** Chiều rộng tối đa */
71
131
  maxWidth?: number | string;
132
+ /** Cho phép chỉnh sửa */
72
133
  editEnable?: boolean;
134
+ /** Có hiển thị không */
73
135
  visible?: boolean;
136
+ /** Không cho phép thay đổi trạng thái ẩn/hiện */
74
137
  invisibleDisable?: boolean;
138
+ /** Kiểu chỉnh sửa */
75
139
  editType?: IEditType;
140
+ /** Căn lề */
76
141
  textAlign?: ITextAlign;
142
+ /** Cố định trái/phải */
77
143
  fixedType?: 'left' | 'right' | undefined;
144
+ /** Danh sách thao tác */
78
145
  commandItems?: ICommandItem[];
146
+ /** Placeholder trong ô input */
79
147
  placeholder?: string;
148
+ /** Cấu hình cho kiểu numeric */
80
149
  numericSettings?: ISettingNumericElement;
150
+ /** Cấu hình cho kiểu select */
81
151
  selectSettings?: ISettingSelectElement;
152
+ /** Cấu hình cho kiểu form */
82
153
  formSettings?: ISettingFormElement;
154
+ /** Danh sách cột con */
83
155
  columns?: IColumnTable[];
156
+ /** Không cho phép dán giá trị */
84
157
  disablePaste?: boolean;
158
+ /**Giá trị trường callback khi copy xuống các dòng dưới */
159
+ callbackValue?: (row: any) => any;
160
+ /** Validate giá trị */
85
161
  validate?: (value: any, row: any) => string | undefined;
162
+ /** Điều kiện disable cột */
86
163
  disabledCondition?: (row: any) => boolean;
164
+ /** Callback khi thay đổi giá trị */
87
165
  callback?: (value: any, indexRow: number, item: any) => void;
166
+ /** Template hiển thị khi không ở chế độ edit */
88
167
  template?: (row: any, indexRow: number) => JSX.Element | string | number | undefined;
168
+ /** Xác định loại edit dựa trên điều kiện */
89
169
  editTypeCondition?: (row: any) => string;
170
+ /** Sự kiện khi paste dữ liệu */
90
171
  onPaste?: (dataRow: any, dataPaste: any) => void;
172
+ /** Xác thực dữ liệu được paste */
91
173
  onPasteValidate?: (dataPaste: string, dataRow: any, rowIndex: number) => Promise<any>;
92
174
  };
175
+ /** Cấu hình phân trang */
93
176
  export type IFTableEditPaging = {
177
+ /** Bật phân trang */
94
178
  allowPaging?: boolean;
179
+ /** Phân trang phía client */
95
180
  pagingClient?: boolean;
181
+ /** Trang hiện tại */
96
182
  currentPage?: number;
183
+ /** Hàm cập nhật trang hiện tại */
97
184
  setCurrentPage?: Dispatch<SetStateAction<number>>;
185
+ /** Hàm cập nhật số dòng mỗi trang */
98
186
  setPageSize?: Dispatch<SetStateAction<number>>;
187
+ /** Số dòng mỗi trang */
99
188
  pageSize?: number;
189
+ /** Tổng số dòng */
100
190
  totalItem?: number;
191
+ /** Các lựa chọn số dòng/trang */
101
192
  pageOptions?: number[];
102
193
  };
194
+ /** Cấu hình các nút thao tác trên bảng */
103
195
  export type IFTableEditButton = {
196
+ /** Vô hiệu hóa nút xóa tất cả */
104
197
  deleteAllDisable?: boolean;
198
+ /** Vô hiệu hóa nút chèn sau */
105
199
  insertAfterDisable?: boolean;
200
+ /** Vô hiệu hóa nút chèn trước */
106
201
  insertBeforeDisable?: boolean;
202
+ /** Vô hiệu hóa nút nhân bản */
107
203
  duplicateDisable?: boolean;
108
204
  };
205
+ /** Cấu hình toolbar bảng */
109
206
  export type IFTableEditToolbar = {
207
+ /** Hiển thị thanh công cụ trên */
110
208
  showTopToolbar?: boolean;
209
+ /** Danh sách toolbar trên */
111
210
  toolbarOptions?: IFToolbarOptions[];
211
+ /** Danh sách toolbar dưới */
112
212
  toolbarBottomOptions?: IFToolbarOptions[];
213
+ /** Hiển thị thanh công cụ dưới */
113
214
  showBottomToolbar?: boolean;
114
215
  };
216
+ /** Cấu hình tìm kiếm trong bảng */
115
217
  export type IFTableEditSearchSetting = {
218
+ /** Bật tìm kiếm */
116
219
  searchEnable?: boolean;
220
+ /** Tìm kiếm phía client */
117
221
  searchClient?: boolean;
222
+ /** Từ khóa tìm kiếm */
118
223
  searchTerm?: string;
224
+ /** Các trường dùng để tìm kiếm */
119
225
  keyField?: string[];
226
+ /** Hàm cập nhật từ khóa */
120
227
  setSearchTerm?: Dispatch<SetStateAction<string>>;
121
228
  };
229
+ /** Cấu hình định dạng số, ngày... */
122
230
  export type IFTableEditFormat = {
231
+ /** Định dạng ngày */
123
232
  dateFormat?: string;
233
+ /** Định dạng ngày giờ */
124
234
  datetimeFormat?: string;
235
+ /** Ký tự phân cách phần thập phân */
125
236
  decimalSeparator?: string;
237
+ /** Ký tự phân cách phần nghìn */
126
238
  thousandSeparator?: string;
239
+ /** Màu số âm */
127
240
  colorNegative?: string;
241
+ /** Tiền tố số âm */
128
242
  prefixNegative?: string;
243
+ /** Hậu tố số âm */
129
244
  suffixNegative?: string;
130
245
  };
246
+ /** Cấu hình page size */
131
247
  export type IFPageSize = {
248
+ /** Số dòng mỗi trang */
132
249
  pageSize: number;
133
250
  };
251
+ /** Cấu hình current page */
134
252
  export type IFCurrentPage = {
253
+ /** Trang hiện tại */
135
254
  currentPage: number;
136
255
  };
256
+ /** Cấu hình current page kèm trang cũ */
137
257
  export type IFCurrentPageConfig = {
258
+ /** Trang hiện tại */
138
259
  currentPage: number;
260
+ /** Trang cũ */
139
261
  oldPage: number;
140
262
  };
263
+ /** Header bảng hỗ trợ merge cột */
141
264
  export type IHeaderColumnTable = {
265
+ /** Tên thuộc tính */
142
266
  field: string;
267
+ /** Tiêu đề header */
143
268
  headerText?: string;
269
+ /** Chiều rộng */
144
270
  width?: number | string;
271
+ /** Chiều rộng tối thiểu */
145
272
  minWidth?: number | string;
273
+ /** Chiều rộng tối đa */
146
274
  maxWidth?: number | string;
275
+ /** Hiển thị/ẩn */
147
276
  visible?: boolean;
277
+ /** Số dòng chiếm (rowspan) */
148
278
  rowspan?: number;
279
+ /** Cột con */
149
280
  columns?: IColumnTable[];
281
+ /** Căn lề */
150
282
  textAlign?: ITextAlign;
283
+ /** Cố định trái/phải */
151
284
  fixedType?: 'left' | 'right' | undefined;
285
+ /** Thứ tự cột */
152
286
  index?: number;
153
287
  };
288
+ export type IFColumnSelectTable = {
289
+ /** Tên thuộc tính trường dữ liệu */
290
+ field: string;
291
+ /** Tiêu đề hiển thị ở phần header của cột */
292
+ headerText: string;
293
+ /** Cờ cho phép hiển thị hoặc ẩn cột (mặc định là true) */
294
+ visible?: boolean;
295
+ /** Căn lề nội dung trong cột: trái, phải, giữa */
296
+ textAlign?: 'left' | 'right' | 'center';
297
+ /** Loại dữ liệu của cột: văn bản, số, ngày, ngày giờ */
298
+ type?: 'text' | 'numeric' | 'date' | 'datetime';
299
+ /** Template tùy chỉnh nội dung hiển thị trong ô */
300
+ template?: any;
301
+ /** Điều kiện thay đổi kiểu dữ liệu của cột */
302
+ typeCondition?: any;
303
+ /** Số chữ số sau dấu phẩy (dùng cho số thực) */
304
+ fraction?: number;
305
+ /** Chiều rộng cột (tính bằng pixel) */
306
+ width?: number;
307
+ /** Chiều rộng tối đa của cột */
308
+ maxWidth?: number;
309
+ /** Chiều rộng tối thiểu của cột */
310
+ minWidth?: number;
311
+ };
312
+ export type IFTableSelectFormat = {
313
+ /** Định dạng ngày (vd: 'dd/MM/yyyy') */
314
+ dateFormat?: string;
315
+ /** Định dạng ngày giờ (vd: 'dd/MM/yyyy HH:mm:ss') */
316
+ datetimeFormat?: string;
317
+ /** Ký tự phân cách phần thập phân (vd: ',') */
318
+ decimalSeparator?: string;
319
+ /** Ký tự phân cách hàng nghìn (vd: '.') */
320
+ thousandSeparator?: string;
321
+ /** Màu hiển thị số âm (vd: 'red') */
322
+ colorNegative?: string;
323
+ /** Tiền tố hiển thị trước số âm (vd: '(') */
324
+ prefixNegative?: string;
325
+ /** Hậu tố hiển thị sau số âm (vd: ')') */
326
+ suffixNegative?: string;
327
+ };
328
+ export type FromItemsField = {
329
+ /** Tên thuộc tính (dùng làm key khi thao tác dữ liệu) */
330
+ name: string;
331
+ /** Nhãn hiển thị cho trường dữ liệu */
332
+ label: string;
333
+ /** Loại trường dữ liệu: văn bản, số, chọn, chọn có thể tạo mới */
334
+ type: 'text' | 'numeric' | 'select' | 'selectCreatable';
335
+ /** Trường có bị disable hay không (không cho chỉnh sửa) */
336
+ disabled?: boolean;
337
+ /** Số chữ số sau dấu phẩy (chỉ áp dụng với loại 'numeric') */
338
+ fraction?: number;
339
+ /** Giá trị tối thiểu (chỉ áp dụng với loại 'numeric') */
340
+ min?: number;
341
+ /** Giá trị tối đa (chỉ áp dụng với loại 'numeric') */
342
+ max?: number;
343
+ /** Danh sách lựa chọn (chỉ áp dụng với loại 'select' và 'selectCreatable') */
344
+ options?: any[];
345
+ };
154
346
  export {};