aio-table 8.0.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.css +0 -216
  2. package/index.d.ts +139 -0
  3. package/index.js +523 -2898
  4. package/package.json +26 -28
  5. package/README.md +0 -792
package/index.css CHANGED
@@ -1,216 +0,0 @@
1
- .table {
2
- background: #eee;
3
- overflow: hidden;
4
- flex: 1;
5
- font-size: 12px;
6
- color: #888;
7
- padding: 12px;
8
- }
9
-
10
- .table-header {
11
- position: sticky !important;
12
- top: 0;
13
- z-index: 10;
14
- overflow: visible;
15
- font-weight: bold;
16
- user-select: none;
17
- background: #ddd;
18
- box-shadow: 0 3px 6px 0px rgba(80, 80, 80, 0.2)
19
- }
20
-
21
- .row-relative-filter {
22
- opacity: 0.4;
23
- }
24
-
25
- .table-title {
26
- background: #f8f8f8;
27
- height: 48px;
28
- }
29
-
30
- .cell-content {
31
- display: flex;
32
- overflow: hidden;
33
- }
34
-
35
- .cell-subtext {
36
- font-size: 74%;
37
- opacity: 0.5;
38
- }
39
-
40
- .row {
41
- box-shadow: 0 3px 6px 0px rgba(80, 80, 80, 0.2);
42
- }
43
-
44
- .cell {
45
- height: 48px;
46
- display: flex;
47
- align-items: center;
48
- padding: 0 12px;
49
- flex-shrink: 0;
50
- background: #fff;
51
- }
52
-
53
- .cell.striped {
54
- background: #f7f7f7;
55
- }
56
-
57
- .table-toggle {
58
- width: 16px;
59
- height: 24px;
60
- display: flex;
61
- align-items: center;
62
- justify-content: center;
63
- }
64
-
65
- .table-toolbar {
66
- padding: 8px;
67
- display: flex;
68
- width: 100%;
69
- align-items: center;
70
- }
71
-
72
- .table-paging {
73
- padding: 8px;
74
- }
75
-
76
- .toolbar-icon {
77
- display: flex;
78
- align-items: center;
79
- justify-content: center;
80
- border: none;
81
- width: 30px !important;
82
- background: #fff;
83
- height: 30px;
84
- margin: 0 3px;
85
- border-radius: 100%;
86
- }
87
-
88
- .table-toolbar-item {
89
- display: flex;
90
- align-items: center;
91
- justify-content: center;
92
- border: none;
93
- min-width: 30px !important;
94
- background: #fff;
95
- height: 30px;
96
- margin: 0 3px;
97
- border-radius: 36px;
98
- }
99
-
100
- .toolbar-popup-header {
101
- height: 36px;
102
- line-height: 36px;
103
- text-align: center;
104
- border-bottom: 1px solid #ddd;
105
-
106
- }
107
-
108
- .aio-table-search {
109
- flex: 1;
110
- border-radius: 36px;
111
- background: #fff;
112
- height: 30px;
113
- display: flex;
114
- align-items: center;
115
- border: 1px solid #eee;
116
- padding: 0 6px;
117
- box-sizing: border-box;
118
- margin: 0 3px;
119
- }
120
-
121
- .aio-table-search input {
122
- font-family: inherit;
123
- flex: 1;
124
- border: none;
125
- outline: none;
126
- height: 100%;
127
- background: none;
128
- }
129
-
130
- .table-group-row {
131
- height: 48px;
132
- width: fit-content;
133
-
134
- }
135
-
136
- .table-filter-popup {
137
- padding: 6px;
138
- width: 300px;
139
- }
140
-
141
- .table-filter-add {
142
- height: 24px;
143
- width: 100%;
144
- margin: 3px;
145
- border: 1px solid #ddd;
146
- background: #eee;
147
- }
148
-
149
- .table-filter-item {
150
- padding: 3px;
151
- }
152
-
153
- .table-filter-operator {
154
- border: 1px solid #ddd;
155
- background: #fff;
156
- height: 24px;
157
- width: 100%;
158
- }
159
-
160
- .table-filter-value {
161
- border: 1px solid #ddd;
162
- padding: 0 3px;
163
- width: 100%;
164
- outline: none;
165
- font-family: inherit;
166
- }
167
-
168
- .table-filter-remove {
169
- border: 1px solid #ddd;
170
- }
171
-
172
- .table-inline-edit-input {
173
- width: 100% !important;
174
- height: 100%;
175
- max-height: 36px;
176
- border: none;
177
- background: none;
178
- outline: none;
179
- font-family: inherit;
180
- min-height: 16px;
181
-
182
- }
183
-
184
- .table-inline-edit-input:focus {
185
- border-bottom: 2px solid dodgerblue;
186
- border-top: 2px solid transparent;
187
- }
188
-
189
- /* custom scrollbar */
190
- .rows::-webkit-scrollbar {
191
- width: 10px !important;
192
- height: 10px !important;
193
- }
194
-
195
- .table-freeze-container::-webkit-scrollbar {
196
- width: 0px !important;
197
- }
198
-
199
- .rows::-webkit-scrollbar-track {
200
- background-color: transparent;
201
- }
202
-
203
- .rows::-webkit-scrollbar-thumb {
204
- background-color: #cdd4e0;
205
- border-radius: 20px;
206
- border: 3px solid transparent;
207
- background-clip: content-box;
208
- }
209
-
210
- .rows::-webkit-scrollbar-thumb {
211
- background-color: #b1b9ca;
212
- }
213
-
214
- .rows::-webkit-scrollbar-thumb:hover {
215
- background-color: #6f7888;
216
- }
package/index.d.ts ADDED
@@ -0,0 +1,139 @@
1
+ import { ReactNode } from "react";
2
+ import * as UT from 'aio-utils';
3
+ import "./index.css";
4
+ type I_rows<T> = {
5
+ rows: T[];
6
+ searchedRows: T[];
7
+ sortedRows: T[];
8
+ pagedRows: T[];
9
+ };
10
+ export type AI_table_param<T> = {
11
+ row: T;
12
+ column: I_column<T>;
13
+ rowIndex: number;
14
+ };
15
+ export type I_column<T> = {
16
+ title?: any;
17
+ value?: any;
18
+ sort?: true | I_sort<T>;
19
+ search?: boolean;
20
+ id?: string;
21
+ _id?: string;
22
+ width?: any;
23
+ minWidth?: any;
24
+ titleAttrs?: {
25
+ [key: string]: any;
26
+ } | string;
27
+ template?: string | ((p: {
28
+ row: T;
29
+ column: I_column<T>;
30
+ rowIndex: number;
31
+ change: (newRow: T) => void;
32
+ }) => ReactNode);
33
+ excel?: string | boolean;
34
+ justify?: boolean;
35
+ cellAttrs?: {
36
+ [key: string]: any;
37
+ } | ((p: {
38
+ row: T;
39
+ rowIndex: number;
40
+ column: I_column<T>;
41
+ }) => any) | string;
42
+ };
43
+ export type I_sort<T> = {
44
+ active?: boolean;
45
+ dir?: 'dec' | 'inc';
46
+ title?: ReactNode;
47
+ type?: 'string' | 'number';
48
+ sortId?: string;
49
+ getValue?: (row: T) => any;
50
+ };
51
+ export type I_context<T> = {
52
+ rootProps: I_AIOTable<T>;
53
+ columns: I_column<T>[];
54
+ ROWS: I_rows<T>;
55
+ add: () => void;
56
+ remove: (row: T, index: number) => void;
57
+ search: (searchValue: string) => void;
58
+ exportToExcel: () => void;
59
+ sorts: I_sort<T>[];
60
+ setSorts: (newSorts: I_sort<T>[]) => void;
61
+ sortRows: (rows: T[], sorts: I_sort<T>[]) => T[];
62
+ excelColumns: I_column<T>[];
63
+ getRowAttrs: (row: T, rowIndex: number) => any;
64
+ getCellAttrs: I_getCellAttrs<T>;
65
+ getDynamics: any;
66
+ DragColumns: UT.I_useDrag;
67
+ getIcon: UT.GetSvg["getIcon"];
68
+ };
69
+ export type I_getCellAttrs<T> = (p: {
70
+ row: T;
71
+ rowIndex: number;
72
+ column: I_column<T>;
73
+ type: 'title' | 'cell';
74
+ }) => any;
75
+ export type AI_table_paging = {
76
+ serverSide?: boolean;
77
+ number: number;
78
+ size: number;
79
+ length?: number;
80
+ sizes?: number[];
81
+ };
82
+ export type I_AIOTable<T> = {
83
+ addText?: ReactNode | ((value: any) => ReactNode);
84
+ columnGap?: number;
85
+ columns?: I_column<T>[];
86
+ excel?: string | ((value: any[]) => any[]);
87
+ getValue?: {
88
+ [key: string]: (p: {
89
+ row: T;
90
+ column: I_column<T>;
91
+ rowIndex: number;
92
+ change: (newRow: T) => void;
93
+ }) => any;
94
+ };
95
+ headerAttrs?: any;
96
+ onAdd?: () => Promise<T | undefined>;
97
+ onChangePaging?: (newPaging: AI_table_paging) => void;
98
+ onChangeSort?: (sorts: I_sort<T>[]) => Promise<boolean>;
99
+ onSwap?: true | ((newValue: T[], startRow: T, endRow: T) => void);
100
+ onSearch?: true | ((searchValue: string) => void);
101
+ paging?: AI_table_paging;
102
+ removeText?: string;
103
+ rowAfter?: (p: {
104
+ row: T;
105
+ rowIndex: number;
106
+ }) => ReactNode;
107
+ rowAttrs?: (p: {
108
+ row: T;
109
+ rowIndex: number;
110
+ }) => any;
111
+ rowBefore?: (p: {
112
+ row: T;
113
+ rowIndex: number;
114
+ }) => ReactNode;
115
+ rowGap?: number;
116
+ rowsTemplate?: (rows: T[]) => ReactNode;
117
+ rowTemplate?: (p: {
118
+ row: T;
119
+ rowIndex: number;
120
+ isLast: boolean;
121
+ }) => ReactNode;
122
+ toolbar?: ReactNode | (() => ReactNode);
123
+ toolbarAttrs?: any;
124
+ tabIndex?: number;
125
+ value: T[];
126
+ onChange?: (v: T[]) => void;
127
+ className?: string;
128
+ style?: any;
129
+ attrs?: any;
130
+ onRemove?: true | ((p: {
131
+ row: T;
132
+ action?: Function;
133
+ rowIndex?: number;
134
+ parent?: T;
135
+ }) => Promise<boolean | void>);
136
+ placeholder?: ReactNode;
137
+ };
138
+ declare const AIOTable: <T>(rootProps: I_AIOTable<T>) => JSX.Element;
139
+ export default AIOTable;