aio-table 8.0.1 → 9.1.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 +169 -159
  2. package/index.d.ts +98 -0
  3. package/index.js +449 -2898
  4. package/package.json +26 -28
  5. package/README.md +0 -792
package/index.css CHANGED
@@ -1,216 +1,226 @@
1
- .table {
2
- background: #eee;
3
- overflow: hidden;
4
- flex: 1;
5
- font-size: 12px;
6
- color: #888;
7
- padding: 12px;
1
+ :root {
2
+ --aio-table-color: #0069ff;
3
+ --aio-table-transition: 0.3s;
8
4
  }
9
5
 
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)
6
+ .aio-table-rtl {
7
+ direction: rtl;
19
8
  }
20
9
 
21
- .row-relative-filter {
22
- opacity: 0.4;
10
+ .aio-table .aio-table-text {
11
+ height: 100%;
23
12
  }
24
13
 
25
- .table-title {
26
- background: #f8f8f8;
27
- height: 48px;
14
+ .aio-table-color input {
15
+ width: 100%;
16
+ padding: 0;
17
+ margin: 0;
18
+ border: none;
19
+ outline: none;
20
+ -webkit-appearance: none;
21
+ -moz-appearance: none;
22
+ appearance: none;
28
23
  }
29
-
30
- .cell-content {
31
- display: flex;
32
- overflow: hidden;
24
+
25
+ .aio-table-color img {
26
+ display: none;
33
27
  }
34
28
 
35
- .cell-subtext {
36
- font-size: 74%;
37
- opacity: 0.5;
29
+ .aio-table-color input::-webkit-color-swatch {
30
+ border: none;
31
+ padding: 0;
38
32
  }
39
33
 
40
- .row {
41
- box-shadow: 0 3px 6px 0px rgba(80, 80, 80, 0.2);
34
+ .aio-table {
35
+ box-sizing: border-box;
36
+ border-radius: 4px;
37
+ font-size: 12px;
38
+ height: fit-content;
39
+ display: flex;
40
+ flex-direction: column;
41
+ width: 100%;
42
+ background: #eee;
43
+ color: #888;
44
+ padding: 0;
45
+ border: 1px solid #eee;
46
+ gap: 0;
42
47
  }
43
48
 
44
- .cell {
45
- height: 48px;
46
- display: flex;
47
- align-items: center;
48
- padding: 0 12px;
49
- flex-shrink: 0;
50
- background: #fff;
49
+ .aio-table .aio-table {
50
+ color: inherit;
51
51
  }
52
52
 
53
- .cell.striped {
54
- background: #f7f7f7;
53
+ .aio-table-unit {
54
+ width: 100%;
55
+ flex: 1;
56
+ overflow: auto;
57
+ display:flex;
58
+ flex-direction: column;
55
59
  }
56
60
 
57
- .table-toggle {
58
- width: 16px;
59
- height: 24px;
60
- display: flex;
61
- align-items: center;
62
- justify-content: center;
61
+ .aio-table-header {
62
+ top: 0;
63
+ display: flex;
64
+ position: sticky;
65
+ position: -webkit-sticky;
66
+ z-index: 10;
67
+ background: #f8f8f8;
68
+ min-width: fit-content;
63
69
  }
64
70
 
65
- .table-toolbar {
66
- padding: 8px;
67
- display: flex;
68
- width: 100%;
69
- align-items: center;
71
+ .aio-table-title {
72
+ padding: 0 12px;
73
+ font-weight: bold;
74
+ height: 36px;
75
+ display: flex;
76
+ align-items: center;
77
+ box-sizing: border-box;
78
+ flex-shrink: 0;
79
+ overflow: hidden;
70
80
  }
71
81
 
72
- .table-paging {
73
- padding: 8px;
82
+ .aio-table-title-justify {
83
+ padding: 0;
84
+ justify-content: center;
74
85
  }
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
+ .aio-table-rows{
87
+ display:flex;
88
+ flex-direction: column;
89
+ gap:1px;
86
90
  }
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;
91
+ .aio-table-row {
92
+ display: flex;
93
+ min-width: fit-content;
98
94
  }
99
-
100
- .toolbar-popup-header {
101
- height: 36px;
102
- line-height: 36px;
103
- text-align: center;
104
- border-bottom: 1px solid #ddd;
105
-
95
+ .aio-table-cell {
96
+ padding: 6px 12px;
97
+ box-sizing: border-box;
98
+ display: flex;
99
+ align-items: center;
100
+ flex-shrink: 0;
101
+ min-height: 24px;
102
+ gap:6px;
103
+ background:#fff;
106
104
  }
107
105
 
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;
106
+ .aio-table-cell-before{
107
+ display:flex;
108
+ align-items: center;
109
+ justify-content: center;
119
110
  }
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;
111
+ .aio-table-cell-after{
112
+ display:flex;
113
+ align-items: center;
114
+ justify-content: center;
115
+ }
116
+ .aio-table-cell-value{
117
+ flex:1;
118
+ display:flex;
119
+ flex-direction: column;
120
+ }
121
+ .aio-table-cell-value.has-subtext:after {
122
+ content: attr(data-subtext);
123
+ font-size: 85%;
124
+ opacity: 0.7;
125
+ }
126
+ .aio-table-cell .aio-table-container {
127
+ width: 100%;
128
128
  }
129
129
 
130
- .table-group-row {
131
- height: 48px;
132
- width: fit-content;
133
-
130
+ .aio-table-cell .aio-table {
131
+ width: 100%;
132
+ background: none;
133
+ border: none;
134
+ border-radius: 0;
135
+ background: none;
136
+ height: 100%;
137
+ min-height: 30px;
134
138
  }
135
139
 
136
- .table-filter-popup {
137
- padding: 6px;
138
- width: 300px;
140
+ .aio-table-cell .aio-table input {
141
+ padding: 0;
142
+ background: none;
139
143
  }
140
144
 
141
- .table-filter-add {
142
- height: 24px;
143
- width: 100%;
144
- margin: 3px;
145
- border: 1px solid #ddd;
146
- background: #eee;
145
+ .aio-table-cell-justify.aio-table-cell{
146
+ padding: 0 !important;
147
+ }
148
+ .aio-table-cell-justify .aio-table-cell-value{
149
+ padding: 0;
150
+ align-items: center;
147
151
  }
148
152
 
149
- .table-filter-item {
150
- padding: 3px;
153
+ .aio-table-cell-justify > input {
154
+ text-align: center;
151
155
  }
152
156
 
153
- .table-filter-operator {
154
- border: 1px solid #ddd;
155
- background: #fff;
156
- height: 24px;
157
- width: 100%;
157
+ .aio-table-toolbar {
158
+ left: 0;
159
+ display: flex;
160
+ width: 100%;
161
+ align-items: center;
162
+ background: #f8f8f8;
163
+ z-index: 100;
164
+ box-sizing: border-box;
165
+ min-height: 36px;
158
166
  }
159
167
 
160
- .table-filter-value {
161
- border: 1px solid #ddd;
162
- padding: 0 3px;
163
- width: 100%;
164
- outline: none;
165
- font-family: inherit;
168
+ .aio-table-toolbar-content {
169
+ font-weight: bold;
170
+ padding: 0 12px;
171
+ height: 100%;
172
+ display: flex;
173
+ align-items: center;
166
174
  }
167
175
 
168
- .table-filter-remove {
169
- border: 1px solid #ddd;
176
+ .aio-table-toolbar-button {
177
+ height: 100%;
178
+ display: flex;
179
+ align-items: center;
180
+ justify-content: center;
181
+ min-width: 36px;
182
+ border: none;
183
+ background: none;
170
184
  }
171
185
 
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
186
 
182
- }
183
187
 
184
- .table-inline-edit-input:focus {
185
- border-bottom: 2px solid dodgerblue;
186
- border-top: 2px solid transparent;
188
+ .aio-table-remove {
189
+ border: none;
190
+ width: 36px;
191
+ background: none;
192
+ color: inherit;
193
+ align-items: center;
194
+ display: flex;
187
195
  }
188
196
 
189
- /* custom scrollbar */
190
- .rows::-webkit-scrollbar {
191
- width: 10px !important;
192
- height: 10px !important;
197
+ .aio-table-remove-title {
198
+ border: none;
199
+ width: 36px;
200
+ background: none;
201
+ color: inherit;
193
202
  }
194
203
 
195
- .table-freeze-container::-webkit-scrollbar {
196
- width: 0px !important;
204
+ .aio-table-border-h {
205
+ height: 1px;
206
+ flex-shrink: 0;
197
207
  }
198
208
 
199
- .rows::-webkit-scrollbar-track {
200
- background-color: transparent;
209
+ .aio-table-border-v {
210
+ width: 1px;
211
+ flex-shrink: 0;
201
212
  }
202
213
 
203
- .rows::-webkit-scrollbar-thumb {
204
- background-color: #cdd4e0;
205
- border-radius: 20px;
206
- border: 3px solid transparent;
207
- background-clip: content-box;
214
+ .aio-table-search {
215
+ flex: 1;
216
+ height: 100%;
217
+ padding: 6px;
218
+ box-sizing: border-box;
208
219
  }
209
220
 
210
- .rows::-webkit-scrollbar-thumb {
211
- background-color: #b1b9ca;
221
+ .aio-table-search .aio-input {
222
+ background: #fff;
223
+ border: none;
224
+ min-height: 30px;
212
225
  }
213
226
 
214
- .rows::-webkit-scrollbar-thumb:hover {
215
- background-color: #6f7888;
216
- }
package/index.d.ts ADDED
@@ -0,0 +1,98 @@
1
+ import { ReactNode } from "react";
2
+ import "./index.css";
3
+ import { I_filter, I_filter_item, I_filter_saved_item, I_paging, I_sort } from "../../aio-component-utils";
4
+ type I_rowOption<T, R> = (p: I_rowDetail<T>) => R;
5
+ type I_cellOption<T, R> = ((p: I_cellDetail<T>) => R) | string;
6
+ type I_rowDetail<T> = {
7
+ row: T;
8
+ rowIndex: number;
9
+ isFirst: boolean;
10
+ isLast: boolean;
11
+ };
12
+ type I_cellDetail<T> = I_rowDetail<T> & {
13
+ column: I_table_column<T>;
14
+ change: (newRow: T) => void;
15
+ isDate: boolean;
16
+ };
17
+ export type I_table_paging = I_paging;
18
+ export type I_table_sort<T> = I_sort<T>;
19
+ export type I_table_filter = I_filter;
20
+ export type I_table_filter_item = I_filter_item;
21
+ export type I_table_filter_saved_item = I_filter_saved_item;
22
+ export type I_table_column<T> = {
23
+ title?: any;
24
+ sort?: true | I_table_sort<T>;
25
+ filterId?: string;
26
+ search?: boolean;
27
+ id?: string;
28
+ _id?: string;
29
+ width?: any;
30
+ minWidth?: any;
31
+ excel?: string | boolean;
32
+ justify?: boolean;
33
+ value?: string;
34
+ attrs?: I_cellOption<T, {
35
+ [attrs: string]: any;
36
+ }>;
37
+ before?: I_cellOption<T, ReactNode>;
38
+ after?: I_cellOption<T, ReactNode>;
39
+ subtext?: I_cellOption<T, ReactNode>;
40
+ template?: I_cellOption<T, ReactNode>;
41
+ titleAttrs?: {
42
+ [attrs: string]: any;
43
+ };
44
+ type?: 'text' | 'number' | 'month' | 'day' | 'hour' | 'minute';
45
+ };
46
+ export type I_table<T> = {
47
+ fa?: boolean;
48
+ addText?: ReactNode | ((value: any) => ReactNode);
49
+ columns?: I_table_column<T>[];
50
+ excel?: string | ((value: any[]) => any[]);
51
+ getValue?: {
52
+ [key: string]: (p: {
53
+ row: T;
54
+ column: I_table_column<T>;
55
+ rowIndex: number;
56
+ change: (newRow: T) => void;
57
+ }) => any;
58
+ };
59
+ headerAttrs?: any;
60
+ onAdd?: () => Promise<T | undefined>;
61
+ onRemove?: (p: {
62
+ row: T;
63
+ rowIndex?: number;
64
+ }) => Promise<boolean>;
65
+ onChangePaging?: (newPaging: I_table_paging) => void;
66
+ onChangeSort?: (sorts: I_table_sort<T>[]) => Promise<boolean>;
67
+ onSwap?: true | ((newValue: T[], startRow: T, endRow: T) => void);
68
+ onSearch?: true | ((searchValue: string) => void);
69
+ paging?: I_table_paging;
70
+ removeText?: string;
71
+ rowOption?: {
72
+ before?: I_rowOption<T, ReactNode>;
73
+ after?: I_rowOption<T, ReactNode>;
74
+ attrs?: I_rowOption<T, {
75
+ [attrs: string]: any;
76
+ }>;
77
+ template?: I_rowOption<T, ReactNode>;
78
+ };
79
+ cellAttrs?: string | ((p: {
80
+ row: T;
81
+ column: I_table_column<T>;
82
+ rowIndex: number;
83
+ }) => any);
84
+ rowsTemplate?: (rows: T[]) => ReactNode;
85
+ toolbar?: ReactNode | (() => ReactNode);
86
+ toolbarAttrs?: any;
87
+ tabIndex?: number;
88
+ value: T[];
89
+ onChange?: (v: T[]) => void;
90
+ className?: string;
91
+ style?: any;
92
+ attrs?: any;
93
+ placeholder?: ReactNode;
94
+ filter?: I_table_filter;
95
+ gap?: [number, number];
96
+ };
97
+ declare const AIOTable: <T>(props: I_table<T>) => JSX.Element;
98
+ export default AIOTable;