es-grid-template 0.0.8 → 0.0.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.
Files changed (114) hide show
  1. package/LICENSE +21 -19
  2. package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
  3. package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
  4. package/es/grid-component/EditableCell.d.ts +19 -0
  5. package/es/grid-component/EditableCell.js +842 -0
  6. package/es/{FilterSearch.js → grid-component/FilterSearch.js} +1 -1
  7. package/es/grid-component/GridStyle.d.ts +4 -0
  8. package/es/grid-component/GridStyle.js +5 -0
  9. package/es/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -2
  10. package/es/grid-component/InternalTable.js +283 -0
  11. package/es/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
  12. package/es/grid-component/Message/Message.d.ts +2 -0
  13. package/es/grid-component/Message/Message.js +16 -0
  14. package/es/grid-component/Message/index.d.ts +1 -0
  15. package/es/grid-component/Message/index.js +1 -0
  16. package/{lib → es/grid-component}/TableGrid.d.ts +2 -2
  17. package/es/grid-component/TableGrid.js +375 -0
  18. package/es/grid-component/async-table-select/index.d.ts +9 -0
  19. package/es/grid-component/async-table-select/index.js +37 -0
  20. package/{lib → es/grid-component}/hooks/constant.d.ts +14 -0
  21. package/es/{hooks → grid-component/hooks}/constant.js +16 -1
  22. package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
  23. package/es/grid-component/hooks/useColumns/index.js +422 -0
  24. package/es/grid-component/hooks/utils.d.ts +35 -0
  25. package/es/{hooks → grid-component/hooks}/utils.js +124 -16
  26. package/es/grid-component/index.d.ts +2 -0
  27. package/es/grid-component/index.js +2 -0
  28. package/es/grid-component/rc-table/Grid.d.ts +8 -0
  29. package/es/grid-component/rc-table/Grid.js +99 -0
  30. package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
  31. package/es/grid-component/rc-table/GridEdit.js +706 -0
  32. package/es/grid-component/type.d.ts +225 -0
  33. package/es/grid-component/useContext.d.ts +27 -0
  34. package/es/grid-component/useContext.js +4 -0
  35. package/es/index.d.ts +1 -2
  36. package/es/index.js +2 -2
  37. package/es/table-grid/styles.scss +551 -0
  38. package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
  39. package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
  40. package/lib/grid-component/EditableCell.d.ts +19 -0
  41. package/lib/grid-component/EditableCell.js +844 -0
  42. package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +1 -1
  43. package/lib/grid-component/GridStyle.d.ts +4 -0
  44. package/lib/grid-component/GridStyle.js +12 -0
  45. package/lib/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -2
  46. package/lib/grid-component/InternalTable.js +292 -0
  47. package/lib/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
  48. package/lib/grid-component/Message/Message.d.ts +2 -0
  49. package/lib/grid-component/Message/Message.js +25 -0
  50. package/lib/grid-component/Message/index.d.ts +1 -0
  51. package/lib/grid-component/Message/index.js +16 -0
  52. package/{es → lib/grid-component}/TableGrid.d.ts +2 -2
  53. package/lib/grid-component/TableGrid.js +382 -0
  54. package/lib/grid-component/async-table-select/index.d.ts +9 -0
  55. package/lib/grid-component/async-table-select/index.js +46 -0
  56. package/{es → lib/grid-component}/hooks/constant.d.ts +14 -0
  57. package/lib/{hooks → grid-component/hooks}/constant.js +17 -2
  58. package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
  59. package/lib/grid-component/hooks/useColumns/index.js +435 -0
  60. package/lib/grid-component/hooks/utils.d.ts +35 -0
  61. package/lib/{hooks → grid-component/hooks}/utils.js +140 -19
  62. package/lib/grid-component/index.d.ts +2 -0
  63. package/lib/grid-component/index.js +9 -0
  64. package/lib/grid-component/rc-table/Grid.d.ts +8 -0
  65. package/lib/grid-component/rc-table/Grid.js +108 -0
  66. package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
  67. package/lib/grid-component/rc-table/GridEdit.js +715 -0
  68. package/lib/grid-component/type.d.ts +225 -0
  69. package/lib/grid-component/useContext.d.ts +27 -0
  70. package/lib/grid-component/useContext.js +10 -0
  71. package/lib/index.d.ts +1 -2
  72. package/lib/index.js +7 -3
  73. package/lib/table-grid/styles.scss +551 -0
  74. package/package.json +15 -6
  75. package/es/InternalTable.js +0 -185
  76. package/es/TableGrid.js +0 -1055
  77. package/es/hooks/useColumns/index.d.ts +0 -2
  78. package/es/hooks/useColumns/index.js +0 -25
  79. package/es/hooks/utils.d.ts +0 -19
  80. package/es/styles.scss +0 -296
  81. package/es/type.d.ts +0 -100
  82. package/lib/InternalTable.js +0 -194
  83. package/lib/TableGrid.js +0 -1063
  84. package/lib/hooks/useColumns/index.d.ts +0 -2
  85. package/lib/hooks/useColumns/index.js +0 -31
  86. package/lib/hooks/utils.d.ts +0 -19
  87. package/lib/styles.scss +0 -296
  88. package/lib/type.d.ts +0 -100
  89. /package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
  90. /package/es/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
  91. /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  92. /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  93. /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  94. /package/es/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.d.ts} +0 -0
  95. /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
  96. /package/es/{hooks → grid-component/hooks}/index.js +0 -0
  97. /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  98. /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  99. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  100. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  101. /package/es/{type.js → grid-component/type.js} +0 -0
  102. /package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
  103. /package/lib/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
  104. /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  105. /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  106. /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  107. /package/lib/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.d.ts} +0 -0
  108. /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
  109. /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
  110. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  111. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  112. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  113. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  114. /package/lib/{type.js → grid-component/type.js} +0 -0
@@ -1,2 +0,0 @@
1
- import type { ColumnsType, ColumnType } from "../../type";
2
- export declare function flatColumns<RecordType>(columns: ColumnsType<RecordType>, parentKey?: string): ColumnType<RecordType>[];
@@ -1,25 +0,0 @@
1
- // import * as React from 'react'
2
-
3
- export function flatColumns(columns, parentKey = 'key') {
4
- // @ts-ignore
5
- return columns.filter(column => column && typeof column === 'object').reduce((list, column, index) => {
6
- const {
7
- fixed
8
- } = column;
9
- // Convert `fixed='true'` to `fixed='left'` instead
10
- const parsedFixed = fixed === true ? 'left' : fixed;
11
- const mergedKey = `${parentKey}-${index}`;
12
- const subColumns = column.children;
13
- if (subColumns && subColumns.length > 0) {
14
- return [...list, ...flatColumns(subColumns, mergedKey).map(subColum => ({
15
- fixed: parsedFixed,
16
- ...subColum
17
- }))];
18
- }
19
- return [...list, {
20
- key: mergedKey,
21
- ...column,
22
- fixed: parsedFixed
23
- }];
24
- }, []);
25
- }
@@ -1,19 +0,0 @@
1
- import dayjs from "dayjs";
2
- import type { EditType, IColumnType, TypeFilter } from "rc-master-ui";
3
- import type { ColumnType } from "../type";
4
- export declare const sumDataByField: (data: any[], field: string) => any;
5
- export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
6
- export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
7
- export declare const isEmpty: (d: any) => boolean;
8
- export declare const isNullOrUndefined: (d: any) => boolean;
9
- export declare const convertDayjsToDate: (dateString: string, format: string) => Date;
10
- export declare const convertDateToDayjs: (date: Date | undefined, format: string) => dayjs.Dayjs;
11
- export declare const isNameColor: (strColor: string) => boolean;
12
- export declare const isColor: (value: string) => boolean;
13
- export declare const getAllVisibleKeys: (columns: any[]) => any[];
14
- export declare const getVisibleColumnKeys: (columns: any[]) => string[];
15
- export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[]): string[];
16
- export declare const updateColumns: (columns: any[], includes: string[]) => any[];
17
- export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, col: ColumnType<any>) => string;
18
- export declare const getTypeFilter: (col: ColumnType<any>) => TypeFilter;
19
- export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
package/es/styles.scss DELETED
@@ -1,296 +0,0 @@
1
- $prefix: 'ui-rc' !default;
2
- $primary: #eb4619 !default;
3
- $rowHoverBg: #FBDED6 !default;
4
- $rowSelectedBg: #FEF2EF !default;
5
- $tableBorderColor: #e0e0e0 !default;
6
- //$rowSelectedHoverBg: 'ui-rc' !default;
7
-
8
-
9
- .popup-context-menu {
10
- min-width: 200px;
11
- }
12
-
13
- .react-resizable {
14
- position: relative;
15
- background-clip: padding-box;
16
- }
17
-
18
- .react-resizable-handle {
19
- position: absolute;
20
- right: -5px;
21
- bottom: 0;
22
- z-index: 1;
23
- width: 10px;
24
- height: 100%;
25
- cursor: col-resize;
26
- //transform: translateY(-50%);
27
- }
28
-
29
- // -------------- Table -------------
30
- .#{$prefix}-table-wrapper {
31
- &.table-none-column-select {
32
- .#{$prefix}-table-cell {
33
- &.#{$prefix}-table-selection-column {
34
- padding: 0 !important;
35
- overflow: hidden !important;
36
- border-inline-end: 0 !important;
37
- //flex: 0 0 0 !important;
38
- //width: 0 !important;
39
- }
40
- }
41
- }
42
-
43
- .#{$prefix}-table-tbody {
44
- .#{$prefix}-table-row {
45
- &.#{$prefix}-table-row-selected {
46
- >.#{$prefix}-table-cell {
47
- background: #FEF2EF;
48
- }
49
- }
50
- >.#{$prefix}-table-cell {
51
- &.#{$prefix}-table-cell-row-hover {
52
- background: #FBDED6;
53
- }
54
- }
55
- }
56
- }
57
-
58
- .#{$prefix}-table-tbody-virtual {
59
- .#{$prefix}-table-cell {
60
- border-bottom: 1px solid $tableBorderColor;
61
- }
62
- }
63
-
64
- .#{$prefix}-table-bordered {
65
-
66
- .#{$prefix}-table-tbody-virtual {
67
- .#{$prefix}-table-cell {
68
- border-inline-end: 1px solid $tableBorderColor;
69
- }
70
- }
71
-
72
- }
73
-
74
-
75
- .#{$prefix}-table {
76
- &.#{$prefix}-table-bordered {
77
- > .#{$prefix}-table-container {
78
-
79
- > .#{$prefix}-table-content,
80
- > .#{$prefix}-table-header,
81
- > .#{$prefix}-table-body,
82
- > .#{$prefix}-table-summary {
83
- > table {
84
- > thead {
85
- > tr:not(:last-child) {
86
- > th {
87
- border-bottom: 1px solid $tableBorderColor;
88
- }
89
- }
90
- }
91
- }
92
- }
93
-
94
- border-inline-start: 1px solid $tableBorderColor;
95
- border-top: 1px solid $tableBorderColor;
96
-
97
-
98
- > .#{$prefix}-table-content,
99
- > .#{$prefix}-table-header,
100
- > .#{$prefix}-table-body,
101
- > .#{$prefix}-table-summary {
102
- > table {
103
- > thead,
104
- > tbody,
105
- > tfoot {
106
- > tr {
107
- > th,
108
- > td {
109
- border-inline-end: 1px solid $tableBorderColor;
110
- }
111
- }
112
- }
113
- }
114
- }
115
-
116
- }
117
-
118
- >.#{$prefix}-table-title {
119
- border: 1px solid $tableBorderColor;
120
- border-bottom: 0;
121
- }
122
- }
123
- }
124
-
125
-
126
- .#{$prefix}-table-thead >tr>th,
127
- .#{$prefix}-table-thead >tr>td {
128
- background-color: #ffffff;
129
- }
130
-
131
- .#{$prefix}-table-thead {
132
- > tr {
133
- > th,
134
- > td {
135
- border-bottom: 1px solid $tableBorderColor;
136
- }
137
- }
138
- }
139
-
140
- .#{$prefix}-table-summary {
141
- .#{$prefix}-table-cell {
142
- background-color: #fafafa;
143
- }
144
-
145
- > tr > td {
146
- border-bottom: 1px solid $tableBorderColor;
147
- }
148
- }
149
-
150
- .#{$prefix}-table-bordered .#{$prefix}-table-tbody-virtual .#{$prefix}-table-cell.#{$prefix}-table-cell-fix-right-first:before {
151
- border-inline-start: 1px solid $tableBorderColor;
152
- }
153
-
154
- .#{$prefix}-table.#{$prefix}-table-bordered {
155
- > .#{$prefix}-table-container {
156
- > .#{$prefix}-table-header > table > thead > tr,
157
- > .#{$prefix}-table-summary > table > tfoot > tr {
158
- > .#{$prefix}-table-cell-fix-right-first::before {
159
- border-inline-start: 1px solid $tableBorderColor;
160
- content: "";
161
- position: absolute;
162
- inset-block: 0;
163
- inset-inline-start: -1px;
164
- }
165
- }
166
- }
167
- }
168
-
169
-
170
- .#{$prefix}-table.#{$prefix}-table-bordered {
171
- > .#{$prefix}-table-container {
172
- > .#{$prefix}-table-header > table > thead > tr,
173
- > .#{$prefix}-table-summary > table > tfoot > tr {
174
- > .#{$prefix}-table-cell-fix-right-first::after {
175
- border-inline-end: 0;
176
- }
177
- }
178
- }
179
- }
180
-
181
- .#{$prefix}-table-ping-left {
182
- .#{$prefix}-table-cell-fix-left-first::after,
183
- .#{$prefix}-table-cell-fix-left-last::after {
184
- box-shadow: inset 10px 0 8px -8px rgba(5, 5, 5, 0.2);
185
- }
186
- }
187
-
188
- .#{$prefix}-table-ping-right {
189
- .#{$prefix}-table-cell-fix-right-first::after,
190
- .#{$prefix}-table-cell-fix-right-last::after {
191
- box-shadow: inset -10px 0 8px -8px rgba(5, 5, 5, 0.2);
192
- }
193
- }
194
-
195
- .#{$prefix}-spin-nested-loading >div>.#{$prefix}-spin {
196
- max-height: 100%;
197
- }
198
-
199
-
200
- }
201
-
202
- // -------------- Checkbox ----------
203
-
204
- .#{$prefix}-checkbox-indeterminate {
205
- &:hover {
206
- .#{$prefix}-checkbox-inner {
207
- border-color: $primary !important; ;
208
- }
209
- }
210
- .#{$prefix}-checkbox-inner {
211
- &:after {
212
- background-color: $primary;
213
- }
214
- }
215
- }
216
-
217
- .#{$prefix}-checkbox {
218
- &.#{$prefix}-checkbox-checked {
219
- &:hover {
220
- .#{$prefix}-checkbox-inner {
221
- background-color: $primary;
222
- border-color: $primary;
223
- }
224
- }
225
- .#{$prefix}-checkbox-inner {
226
- background-color: $primary;
227
- border-color: $primary;
228
- }
229
- }
230
- }
231
-
232
- .#{$prefix}-checkbox:not(.#{$prefix}-checkbox-disabled):hover {
233
- .#{$prefix}-checkbox-inner {
234
- border-color: $primary;
235
- }
236
- }
237
-
238
- .#{$prefix}-checkbox-wrapper:not(.#{$prefix}-checkbox-wrapper-disabled):hover {
239
- .#{$prefix}-checkbox-inner {
240
- border-color: $primary;
241
- }
242
- .#{$prefix}-checkbox-checked:not(.#{$prefix}-checkbox-disabled) {
243
- .#{$prefix}-checkbox-inner {
244
- background-color: $primary;
245
- }
246
- }
247
- }
248
-
249
- // ------------ Tree ---------------
250
-
251
- .#{$prefix}-tree {
252
- .#{$prefix}-tree-checkbox-checked {
253
- .#{$prefix}-tree-checkbox-inner {
254
- background-color: $primary;
255
- border-color: $primary;
256
- }
257
- }
258
-
259
- .#{$prefix}-tree-checkbox-wrapper-checked:not(.#{$prefix}-tree-checkbox-wrapper-disabled):hover,
260
- .#{$prefix}-tree-checkbox-checked:not(.#{$prefix}-tree-checkbox-disabled):hover {
261
- .#{$prefix}-tree-checkbox-inner {
262
- background-color: $primary;
263
- }
264
- }
265
-
266
- .#{$prefix}-tree-checkbox-wrapper:not(.#{$prefix}-tree-checkbox-wrapper-disabled):hover,
267
- .#{$prefix}-tree-checkbox:not(.#{$prefix}-tree-checkbox-disabled):hover {
268
- .#{$prefix}-tree-checkbox-inner {
269
- border-color: $primary;
270
- }
271
- }
272
- }
273
-
274
-
275
-
276
-
277
- .#{$prefix}-pagination {
278
- &::before {
279
- content: "";
280
- position: absolute;
281
- border-left: 1px solid $tableBorderColor;
282
- height: 55px;
283
- bottom: 0;
284
- left: 0;
285
- }
286
- &::after {
287
- content: "";
288
- position: absolute;
289
- border-left: 1px solid $tableBorderColor;
290
- height: 55px;
291
- bottom: 0;
292
- visibility: visible;
293
- right: 0;
294
- }
295
- border-bottom: 1px solid $tableBorderColor;
296
- }
package/es/type.d.ts DELETED
@@ -1,100 +0,0 @@
1
- import type { Key, ReactElement, ReactNode } from "react";
2
- import type React from "react";
3
- import type { IOperator } from "./hooks";
4
- import type { TypeFilter, TableProps, TableColumnType as RcColumnType } from "rc-master-ui";
5
- import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/interface";
6
- import type { ToolbarItem } from "rc-master-ui/es/toolbar";
7
- import type { ItemType } from "rc-master-ui/es/menu/interface";
8
- export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
9
- export type AnyObject = Record<PropertyKey, any>;
10
- export interface ColumnGroupType<RecordType = AnyObject> extends Omit<ColumnType<RecordType>, 'dataIndex'> {
11
- children: ColumnsType<RecordType>;
12
- }
13
- export type ColumnType<RecordType> = RcColumnType<RecordType> & {
14
- type?: IColumnType;
15
- isSummary?: boolean;
16
- summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
17
- maxWidth?: string | number;
18
- format?: IFormat;
19
- allowFiltering?: boolean;
20
- operator?: FilterOperator;
21
- placeholder?: string;
22
- showInColumnChoose?: boolean;
23
- typeFilter?: TypeFilter;
24
- children?: ColumnsType<RecordType>;
25
- headerText?: string;
26
- };
27
- export type ColumnsType<RecordType = AnyObject> = (ColumnGroupType<RecordType> | ColumnType<RecordType>)[];
28
- export interface GridTableProps<RecordType> extends Omit<TableProps<RecordType>, 'columns' | 'rowSelection' | 'loading'> {
29
- columns?: ColumnsType<RecordType>;
30
- format?: IFormat;
31
- t?: any;
32
- lang?: string;
33
- contextMenuItems?: any[];
34
- contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
35
- contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
36
- contextMenuClick?: (args: ContextInfo<RecordType>) => void;
37
- recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
38
- toolbarItems?: ToolbarItem[];
39
- showColumnChoose?: boolean;
40
- onFilter?: (query: {
41
- field: string;
42
- key: string;
43
- operator: IOperator;
44
- predicate: 'and' | 'or';
45
- value: any;
46
- }[]) => void;
47
- selectionSettings?: SelectionSettings;
48
- rowKey?: string;
49
- rowSelection?: RowSelection<RecordType>;
50
- rowSelected?: (args: {
51
- type: string;
52
- rowData: RecordType;
53
- selected: RecordType | RecordType[];
54
- }) => void;
55
- dataSourceFilter?: SourceFilter[];
56
- onFilterClick?: (column: ColumnType<RecordType>, callback: (key: string, data: any) => void) => void;
57
- loading?: boolean;
58
- allowResizing?: boolean;
59
- }
60
- export type SourceFilter = {
61
- key: string;
62
- data: any[];
63
- loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
64
- };
65
- export type RowSelection<RecordType> = Omit<TableRowSelection<RecordType>, 'type' | 'columnWidth' | 'hideSelectAll' | 'defaultSelectedRowKeys'>;
66
- export type SelectionSettings = {
67
- mode?: 'checkbox' | 'radio';
68
- type?: 'single' | 'multiple';
69
- checkboxOnly?: boolean;
70
- hideSelectAll?: boolean;
71
- columnWidth?: number | string;
72
- defaultSelectedRowKeys?: Key[];
73
- };
74
- export type RecordDoubleClickEventArgs<RecordType> = {
75
- rowData: RecordType;
76
- rowIndex: number | undefined;
77
- e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
78
- };
79
- export type ContextInfo<RecordType> = {
80
- rowInfo: {
81
- rowData: RecordType | null;
82
- };
83
- event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
84
- item: ItemType;
85
- };
86
- export type IFormat = {
87
- thousandSeparator?: string;
88
- decimalSeparator?: string;
89
- decimalScale?: number | undefined;
90
- allowNegative?: boolean;
91
- prefix?: string | undefined;
92
- suffix?: string | undefined;
93
- fixedDecimalScale?: boolean;
94
- dateFormat?: string;
95
- datetimeFormat?: string;
96
- timeFormat?: string;
97
- weekFormat?: string;
98
- monthFormat?: string;
99
- yearFormat?: string;
100
- };
@@ -1,194 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _rcMasterUi = require("rc-master-ui");
11
- var _dayjs = _interopRequireDefault(require("dayjs"));
12
- require("dayjs/locale/es");
13
- require("dayjs/locale/vi");
14
- require("./styles.scss");
15
- var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
16
- var _styledComponents = _interopRequireDefault(require("styled-components"));
17
- var _TableGrid = _interopRequireDefault(require("./TableGrid"));
18
- var _reactResizable = require("react-resizable");
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
- // import {ColumnsChoose} from "./ColumnsChoose";
22
-
23
- _dayjs.default.extend(_customParseFormat.default);
24
- const ResizableTitle = props => {
25
- const {
26
- onResize,
27
- width,
28
- ...restProps
29
- } = props;
30
- if (!width) {
31
- return /*#__PURE__*/_react.default.createElement("th", restProps);
32
- }
33
- return (
34
- /*#__PURE__*/
35
- // @ts-ignore
36
- _react.default.createElement(_reactResizable.Resizable, {
37
- width: width,
38
- height: 0,
39
- handle: /*#__PURE__*/_react.default.createElement("span", {
40
- className: "react-resizable-handle",
41
- onClick: e => {
42
- e.stopPropagation();
43
- }
44
- }),
45
- onResize: onResize,
46
- draggableOpts: {
47
- enableUserSelectHack: false
48
- }
49
- }, /*#__PURE__*/_react.default.createElement("th", restProps))
50
- );
51
- };
52
- const GridStyle = _styledComponents.default.div.withConfig({
53
- displayName: "GridStyle",
54
- componentId: "es-grid-template__sc-1fs85vo-0"
55
- })([".ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
56
- const InternalTable = props => {
57
- const {
58
- columns,
59
- // title,
60
- dataSource,
61
- // toolbarItems,
62
- // showColumnChoose,
63
- ...rest
64
- } = props;
65
- const [tmpColumns, setColumns] = (0, _react.useState)([]);
66
- (0, _react.useEffect)(() => {
67
- const rs = columns ? [_rcMasterUi.Table.SELECTION_COLUMN, ...columns] : [];
68
- setColumns(rs);
69
- }, [columns]);
70
- const handleResize = indexPath => (e, {
71
- size
72
- }) => {
73
- const updateColumns = (cols, path) => {
74
- const [currentIndex, ...restPath] = path;
75
- return cols.map((col, idx) => {
76
- if (idx === currentIndex) {
77
- if (restPath.length === 0) {
78
- // Cập nhật width của cột cuối cùng trong path
79
- // return { ...col, width: size.width }
80
-
81
- // Kiểm tra minWidth trước khi cập nhật width
82
- if (col.minWidth && size.width < col.minWidth) {
83
- e.preventDefault();
84
- return col; // Không cập nhật nếu nhỏ hơn minWidth
85
- }
86
-
87
- // Kiểm tra minWidth trước khi cập nhật width
88
- if (col.maxWidth && size.width > col.maxWidth) {
89
- e.preventDefault();
90
- return col; // Không cập nhật nếu nhỏ hơn minWidth
91
- }
92
- return {
93
- ...col,
94
- width: size.width
95
- };
96
- } else if (col.children) {
97
- // Tiếp tục cập nhật các cấp con
98
- return {
99
- ...col,
100
- children: updateColumns(col.children, restPath)
101
- };
102
- }
103
- }
104
- // e.preventDefault()
105
- return col;
106
- });
107
- };
108
- setColumns(prevColumns => updateColumns(prevColumns, indexPath));
109
- };
110
- const addResizeHandlers = _react.default.useCallback((cols, parentPath = []) => {
111
- return cols.map((col, index) => {
112
- const currentPath = [...parentPath, index];
113
- if (!col?.dataIndex && !col.key) {
114
- return col;
115
- }
116
- if (col.children) {
117
- return {
118
- ...col,
119
- title: col.headerText ?? col.title,
120
- ellipsis: col.ellipsis !== false,
121
- children: addResizeHandlers(col.children, currentPath)
122
- };
123
- }
124
- return {
125
- ...col,
126
- title: col.headerText ?? col.title,
127
- ellipsis: col.ellipsis !== false,
128
- onHeaderCell: () => ({
129
- width: col.width,
130
- onResize: handleResize(currentPath)
131
- })
132
- };
133
- });
134
- }, []);
135
- const resizableColumns = _react.default.useMemo(() => {
136
- return addResizeHandlers(tmpColumns);
137
- }, [addResizeHandlers, tmpColumns]);
138
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(GridStyle, {
139
- heightTable: props.style?.minHeight,
140
- style: {
141
- position: 'relative'
142
- }
143
- }, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
144
- dataSource: dataSource,
145
- components: {
146
- header: {
147
- cell: ResizableTitle
148
- }
149
- },
150
- columns: resizableColumns,
151
- setColumns: setColumns,
152
- showSorterTooltip: {
153
- target: 'sorter-icon'
154
- }
155
-
156
- // title={() => {
157
- // return (
158
- // <Fragment>
159
- // <div>
160
- // {title?.(dataSource as any)}
161
- // </div>
162
- //
163
- //
164
- // {(toolbarItems || showColumnChoose !== false) && (
165
- // <div style={{display: 'flex', justifyContent: 'space-between'}}>
166
- //
167
- // <Toolbar
168
- // style={{width: '100%'}}
169
- // items={toolbarItems ?? []}
170
- // mode={'responsive'}
171
- // // mode={'scroll'}
172
- // onClick={(val: any) => {
173
- // console.log(val)
174
- // }}
175
- // />
176
- //
177
- // {showColumnChoose && (
178
- // <ColumnsChoose
179
- // columns={resizableColumns}
180
- // setColumns={setColumns}
181
- // />
182
- // )}
183
- //
184
- // <div />
185
- // </div>
186
- // )}
187
- //
188
- //
189
- // </Fragment>
190
- // )
191
- // }}
192
- }))));
193
- };
194
- var _default = exports.default = InternalTable;