@propellerads/table 3.0.0 → 4.2.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.
package/src/style.tsx CHANGED
@@ -1,5 +1,7 @@
1
1
  /* eslint max-len: off */
2
- import styled, {createGlobalStyle, keyframes} from 'styled-components';
2
+ import styled, {
3
+ keyframes, css, CSSObject,
4
+ } from 'styled-components';
3
5
  import {
4
6
  fontNormal,
5
7
  white,
@@ -7,7 +9,6 @@ import {
7
9
  spacing,
8
10
  gray80,
9
11
  gray95,
10
- semiWhite,
11
12
  } from '@propellerads/stylevariables';
12
13
 
13
14
  const loadingAnimation = keyframes`
@@ -22,433 +23,181 @@ const loadingAnimation = keyframes`
22
23
  }
23
24
  `;
24
25
 
25
- export const EmptyStateCell = styled.div`
26
- width: 100%;
27
- height: ${spacing * 4}px;
28
- background: linear-gradient(to left, ${gray95}, ${white}, ${gray95});
29
- background-size: 200% 200%;
30
- animation: ${loadingAnimation} 1.6s linear infinite;
26
+ export const TableLoading = styled.div`
27
+ display: block;
28
+ position: absolute;
29
+ left: 0;
30
+ right: 0;
31
+ top: 0;
32
+ bottom: 0;
33
+ background: rgba(255, 255, 255, 0.8);
34
+ transition: all 0.3s ease;
35
+ z-index: -1;
36
+ opacity: 0;
37
+ pointer-events: none;
38
+
39
+ ${(props: { isLoading: boolean }) => props.isLoading && css`
40
+ opacity: 1;
41
+ z-index: 2;
42
+ pointer-events: all;
43
+ `}
31
44
  `;
32
45
 
33
- const CommonStyles = createGlobalStyle`
34
-
35
- .ReactTable {
36
- font-size: ${fontNormal}px;
37
- position: relative;
38
- display: flex;
39
- flex-direction: column;
40
- border: 0;
41
-
42
- .pagination-bottom {
43
- padding: 24px 0;
44
- }
45
-
46
- &__header-cell_right {
47
- text-align: right !important;
48
- flex-direction: row !important;
49
- justify-content: flex-end !important;
50
-
51
- &:before {
52
- margin-left: 0 !important;
53
- margin-right: 4px !important;
54
- }
55
- }
56
-
57
- .rt-thead {
58
- flex: 1 0 auto;
59
- display: flex;
60
- flex-direction: column;
61
- user-select: none;
62
- }
63
-
64
- .rt-table {
65
- flex: auto 1;
66
- display: flex;
67
- flex-direction: column;
68
- align-items: stretch;
69
- width: 100%;
70
- border-collapse: collapse;
71
- overflow: auto;
72
- }
73
- }
74
-
75
- .ReactTable .rt-thead.-filters input,
76
- .ReactTable .rt-thead.-filters select {
77
- border: 1px solid rgba(0, 0, 0, 0.1);
78
- background: ${white};
79
- padding: 2px 7px;
80
- margin: 4px 0;
81
- font-size: inherit;
82
- border-radius: 3px;
83
- font-weight: normal;
84
- outline: none;
85
- }
86
-
87
- .ReactTable .rt-thead .rt-th,
88
- .ReactTable .rt-thead .rt-td {
89
- padding: 0 4px;
90
- line-height: normal;
91
- position: relative;
92
- transition: box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
93
- color: ${black};
94
- font-weight: 500;
95
- outline: none;
96
- }
97
-
98
- .ReactTable .rt-thead .rt-th {
99
- display: flex;
100
- }
101
-
102
- .ReactTable .rt-thead .rt-th.-cursor-pointer,
103
- .ReactTable .rt-thead .rt-td.-cursor-pointer {
104
- cursor: pointer;
105
- transition: 220ms ease;
106
- display: flex;
107
- flex-direction: row-reverse;
108
- justify-content: flex-end;
109
- align-items: center;
110
-
111
-
112
- &:before {
113
- transition: 220ms ease;
114
- content: '';
115
- min-width: 12px;
116
- width: 12px;
117
- height: 12px;
118
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAAEEfUpiAAAABGdBTUEAALGPC/xhBQAAAlZJREFUWAntVklSwzAQtJ1ck/AYtpA78COKLEWoLHe+wx3C8hggOSehW7iNrMgb5gIVVblmNOrpGWuksYMgHv1+f0s1kkEyGg6HY00SSaNcEmO2YkMTnUoycX3dhZ28XAcD8KXlMhlHHzDF6PMql0OKxpkUMjQZNwzD3mw2e7SdB4PB23a7PQhpjEFdGBbz+TzE/B3mDnUDEIgSbEsA21zkPDXIxCdlzJuUcSh8y7wAXKtN0CQLU/VtJdeyBrcZPneGIIqi281m8wCioNFonE0mk0WWIzCmBNjpALUbp7aapw1EN3QGu6kbdbt2mlNypAi+TEFgE8lG6a2tDXD1wvPvOrjzv3EOah+k/0AQ13rpljBvjntwyBITE8VHtwVDKZLRaHSEe/BKZwaPrONZSILIx+v1+sVExgWcTqdjUwWbBKAPAtxBZ0R+pp23l85QvxuKSNgQXRKkfeJzJsHObdTmqLsSpGFHlm2HgAsiEYjS50y7l4ALNkmWM3G5gyQsVR4oM4M8J67ZGXKuIlCvMmpfxirBfNh9AvsdSHYAp/oaLaPnOyi/aUObYiu+EmfIe6q/idi4Qhu6dH8Z5SBZ9RqyjSPOPXrigTjYYCLTkqHICNkCiP9JSzh1LfuPVAYG1zs/A25wxk41Is9uMOgKP2wX7g9b0Q7En497+HdIouG21VQCAvkS4dcB6xcozRNxWQmUDaxY3gS0mJUI3uIcW2oSERa7dBrXuC0bpfvG9hr13AQE9iWitSxZFFh+pRIQuEwiZQOLs1ICcvIlUjWwuGpJJsKnDskn5F1o5Z7NGz4AAAAASUVORK5CYII=');
119
- background-size: contain;
120
- opacity: 0;
121
- margin-left: 4px;
122
- }
123
- }
46
+ export const TableLoadingInner = styled.div`
47
+ position: absolute;
48
+ display: block;
49
+ text-align: center;
50
+ width: 100%;
51
+ top: 50%;
52
+ left: 0;
53
+ color: rgba(0, 0, 0, 0.6);
54
+ transform: translateY(-52%);
55
+ transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
56
+ `;
124
57
 
125
- .ReactTable .rt-thead .rt-th.-sort-asc,
126
- .ReactTable .rt-thead .rt-td.-sort-asc {
127
- padding-left: 4px;
58
+ export const TableWrapper = styled.div`
59
+ position: relative;
60
+ overflow: hidden;
61
+
62
+ &::before {
63
+ bottom: 10px;
64
+ content: '';
65
+ opacity: 0;
66
+ pointer-events: none;
67
+ position: absolute;
68
+ width: 10px;
69
+ height: 100%;
70
+ top: 0;
71
+ left: -10px;
72
+ box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
73
+ transition: 0.3s opacity;
74
+ }
128
75
 
129
- &:before {
130
- transform: rotate(180deg);
131
- opacity: 1;
76
+ &::after {
77
+ bottom: 10px;
78
+ content: '';
79
+ opacity: 0;
80
+ pointer-events: none;
81
+ width: 10px;
82
+ height: 100%;
83
+ position: absolute;
84
+ top: 0;
85
+ right: -10px;
86
+ box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
87
+ transition: 0.3s opacity;
88
+ }
89
+
90
+ &.shadow_left {
91
+ &::before {
92
+ opacity: 1 !important;
132
93
  }
133
- }
134
-
135
- .ReactTable .rt-thead .rt-th.-sort-desc,
136
- .ReactTable .rt-thead .rt-td.-sort-desc {
137
- padding-left: 4px;
138
-
139
- &:before {
140
- opacity: 1;
94
+ }
95
+
96
+ &.shadow_right {
97
+ &::after {
98
+ opacity: 1 !important;
141
99
  }
142
- }
143
-
144
- .ReactTable .rt-thead .rt-th:last-child,
145
- .ReactTable .rt-thead .rt-td:last-child {
146
- border-right: 0;
147
- }
148
-
149
- .ReactTable .rt-thead .rt-resizable-header {
150
- overflow: visible;
151
- display: flex;
152
- align-items: center;
153
- }
154
-
155
- .ReactTable .rt-thead .rt-resizable-header:last-child {
156
- overflow: hidden;
157
- }
158
-
159
- .ReactTable .rt-thead .rt-resizable-header-content {
160
- overflow: hidden;
161
- text-overflow: ellipsis;
162
- }
163
-
164
- .ReactTable .rt-thead .rt-header-pivot {
165
- border-right-color: #f7f7f7;
166
- }
167
-
168
- .ReactTable .rt-thead .rt-header-pivot:after,
169
- .ReactTable .rt-thead .rt-header-pivot:before {
170
- left: 100%;
171
- top: 50%;
172
- border: solid transparent;
173
- content: ' ';
174
- height: 0;
175
- width: 0;
176
- position: absolute;
177
- pointer-events: none;
178
- }
179
-
180
- .ReactTable .rt-thead .rt-header-pivot:after {
181
- border-color: rgba(255, 255, 255, 0);
182
- border-left-color: ${white};
183
- border-width: 8px;
184
- margin-top: -8px;
185
- }
186
-
187
- .ReactTable .rt-thead .rt-header-pivot:before {
188
- border-color: rgba(102, 102, 102, 0);
189
- border-left-color: #f7f7f7;
190
- border-width: 10px;
191
- margin-top: -10px;
192
- }
193
-
194
- .ReactTable .rt-tbody {
195
- flex: 99999 1 auto;
196
- display: flex;
197
- flex-direction: column;
198
- overflow: auto;
199
- border-top: 1px solid ${gray80};
200
- margin-top: ${spacing * 2}px;
201
- }
202
-
203
- .ReactTable .rt-tbody .rt-tr-group {
204
- box-shadow: inset 0 -1px 0 0 ${gray95};
205
- }
206
-
207
- .ReactTable .rt-tbody .rt-tr-group:hover {
208
- background-color: ${semiWhite};
209
- transition: 0.2s ease-in-out;
210
- }
100
+ }
101
+ `;
211
102
 
212
- .ReactTable .rt-tbody .rt-td:last-child {
213
- border-right: 0;
214
- }
103
+ export const TableRoot = styled.div`
104
+ font-size: ${fontNormal}px;
105
+ position: relative;
106
+ display: flex;
107
+ flex-direction: column;
108
+ border: 0;
109
+ `;
215
110
 
216
- .ReactTable .rt-tbody .rt-expandable {
217
- cursor: pointer;
218
- text-overflow: clip;
219
- }
111
+ export const TableContent = styled.div`
112
+ display: block;
113
+ max-width: 100%;
114
+ overflow-x: scroll;
115
+ overflow-y: hidden;
116
+ `;
220
117
 
221
- .ReactTable .rt-tr-group {
222
- flex: 1 0 auto;
223
- display: flex;
224
- flex-direction: column;
225
- align-items: stretch;
226
- }
118
+ export const TableCore = styled.div`
119
+ flex: auto 1;
120
+ display: flex;
121
+ flex-direction: column;
122
+ align-items: stretch;
123
+ border-collapse: collapse;
124
+ width: max-content;
125
+ `;
227
126
 
228
- .ReactTable .rt-tr {
229
- flex: 1 0 auto;
230
- display: inline-flex;
231
- padding: 0;
232
- align-items: center;
233
- }
127
+ export const HeadCell = styled.div`
128
+ display: inline-flex;
129
+ `;
234
130
 
235
- .ReactTable .rt-th,
236
- .ReactTable .rt-td {
237
- flex: 1 0 0;
131
+ export const TD = styled.div`
238
132
  white-space: nowrap;
239
133
  text-overflow: ellipsis;
134
+ line-height: 1.3rem;
240
135
  padding: 7px 4px;
241
136
  overflow: hidden;
242
- transition: 0.3s ease;
243
- transition-property: width, min-width, padding, opacity;
244
- line-height: 1.3rem;
245
- }
246
-
247
- .ReactTable .rt-th.-hidden,
248
- .ReactTable .rt-td.-hidden {
249
- width: 0 !important;
250
- min-width: 0 !important;
251
- padding: 0 !important;
252
- border: 0 !important;
253
- opacity: 0 !important;
254
- }
255
-
256
- .ReactTable .rt-expander {
257
- display: inline-block;
258
- position: relative;
259
- color: transparent;
260
- margin: 0 10px;
261
- }
262
-
263
- .ReactTable .rt-expander:after {
264
- content: '';
265
- position: absolute;
266
- width: 0;
267
- height: 0;
268
- top: 50%;
269
- left: 50%;
270
- transform: translate(-50%, -50%) rotate(-90deg);
271
- border-left: 5.04px solid transparent;
272
- border-right: 5.04px solid transparent;
273
- border-top: 7px solid rgba(0, 0, 0, 0.8);
274
- transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
275
- cursor: pointer;
276
- }
277
-
278
- .ReactTable .rt-expander.-open:after {
279
- transform: translate(-50%, -50%) rotate(0);
280
- }
281
-
282
- .ReactTable .rt-resizer {
283
- display: inline-block;
284
- position: absolute;
285
- width: 36px;
286
- top: 0;
287
- bottom: 0;
288
- right: -18px;
289
- cursor: col-resize;
290
- z-index: 10;
291
- }
292
-
293
- .ReactTable .rt-tfoot {
294
- background: ${gray95};
295
- flex: 1 0 auto;
296
- display: flex;
297
- flex-direction: column;
298
- }
299
-
300
- .ReactTable .rt-tfoot .rt-td {
301
- }
302
-
303
- .ReactTable .rt-tfoot .rt-td:last-child {
304
- border-right: 0;
305
- }
306
-
307
- .ReactTable.-striped .rt-tr.-odd {
308
- background: rgba(0, 0, 0, 0.03);
309
- }
310
-
311
- .ReactTable.-highlight .rt-tbody .rt-tr:not(.-padRow):hover {
312
- background: rgba(0, 0, 0, 0.05);
137
+ transition: width 0.3s ease 0s, min-width, padding, opacity;
138
+
139
+ ${({align}: { align?: CSSObject, colSpan?: number }) => align && css`
140
+ text-align: ${align}`
313
141
  }
142
+ `;
314
143
 
315
- .ReactTable .-pagination {
316
- z-index: 1;
317
- display: flex;
318
- justify-content: space-between;
319
- align-items: stretch;
320
- flex-wrap: wrap;
321
- padding: 3px;
322
- }
144
+ export const EmptyStateCell = styled.div`
145
+ width: 100%;
146
+ height: ${spacing * 4}px;
147
+ background: linear-gradient(to left, ${gray95}, ${white}, ${gray95});
148
+ background-size: 200% 200%;
149
+ animation: ${loadingAnimation} 1.6s linear infinite;
150
+ `;
323
151
 
324
- .ReactTable .-pagination input,
325
- .ReactTable .-pagination select {
326
- border: 1px solid rgba(0, 0, 0, 0.1);
327
- background: ${white};
328
- padding: 5px 7px;
329
- font-size: inherit;
330
- border-radius: 3px;
331
- font-weight: normal;
332
- outline: none;
333
- }
152
+ export const TH = styled.div`
153
+ padding: 0 4px;
154
+ line-height: normal;
155
+ position: relative;
156
+ transition: box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s;
157
+ color: rgb(0, 0, 0);
158
+ font-weight: 500;
159
+ outline: none;
160
+ `;
334
161
 
335
- .ReactTable .-pagination .-btn {
336
- appearance: none;
337
- display: block;
338
- width: 100%;
339
- height: 100%;
340
- border: 0;
341
- border-radius: 3px;
342
- padding: 6px;
343
- font-size: 1em;
344
- color: rgba(0, 0, 0, 0.6);
345
- transition: all 0.1s ease;
346
- cursor: pointer;
162
+ export const THead = styled.div`
163
+ flex: 1 0 auto;
164
+ display: flex;
165
+ flex-direction: column;
166
+ user-select: none;
167
+
168
+ ${TH}, ${TD} {
169
+ padding: 0 4px;
170
+ line-height: normal;
171
+ position: relative;
172
+ transition: box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
173
+ color: ${black};
174
+ font-weight: 500;
347
175
  outline: none;
348
- background-color: white;
349
- color: #0080ff;
350
- box-shadow: inset 0 0 0 1px #0080ff;
351
- }
352
-
353
- .ReactTable .-pagination .-btn[disabled] {
354
- opacity: 0;
355
- cursor: default;
356
- }
357
-
358
- .ReactTable .-pagination .-btn:not([disabled]):hover {
359
- }
360
-
361
- .ReactTable .-pagination .-previous,
362
- .ReactTable .-pagination .-next {
363
- flex: 1;
364
- text-align: center;
365
- }
366
-
367
- .ReactTable .-pagination .-center {
368
- flex: 1.5;
369
- text-align: center;
370
- margin-bottom: 0;
371
- display: -webkit-box;
372
- display: -ms-flexbox;
373
- display: flex;
374
- flex-direction: row;
375
- flex-wrap: wrap;
376
- align-items: center;
377
- justify-content: space-around;
378
- }
379
-
380
- .ReactTable .-pagination .-pageInfo {
381
- display: inline-block;
382
- margin: 3px 10px;
383
- white-space: nowrap;
384
- }
385
-
386
- .ReactTable .-pagination .-pageJump {
387
- display: inline-block;
388
- }
389
-
390
- .ReactTable .-pagination .-pageJump input {
391
- width: 70px;
392
- text-align: center;
393
- }
394
-
395
- .ReactTable .-pagination .-pageSizeOptions {
396
- margin: 3px 10px;
397
- }
398
-
399
- .ReactTable .rt-noData {
400
- display: flex;
401
- justify-content: center;
402
- background: transparent;
403
- transition: all 0.3s ease;
404
- z-index: 1;
405
- pointer-events: none;
406
- color: rgba(0, 0, 0, 0.5);
407
- }
408
-
409
- .ReactTable .-loading {
410
- display: block;
411
- position: absolute;
412
- left: 0;
413
- right: 0;
414
- top: 0;
415
- bottom: 0;
416
- background: rgba(255, 255, 255, 0.8);
417
- transition: all 0.3s ease;
418
- z-index: -1;
419
- opacity: 0;
420
- pointer-events: none;
421
- }
422
-
423
- .ReactTable .-loading > div {
424
- position: absolute;
425
- display: block;
426
- text-align: center;
427
- width: 100%;
428
- top: 50%;
429
- left: 0;
430
- font-size: 15px;
431
- color: rgba(0, 0, 0, 0.6);
432
- transform: translateY(-52%);
433
- transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
434
- }
176
+ }
177
+ `;
435
178
 
436
- .ReactTable .-loading.-active {
437
- opacity: 1;
438
- z-index: 2;
439
- pointer-events: all;
440
- }
179
+ export const TRGroup = styled.div`
180
+ display: flex;
181
+ flex: 1 0 auto;
182
+ box-shadow: inset 0 -1px 0 0 ${gray95};
183
+ `;
441
184
 
442
- .ReactTable .-loading.-active > div {
443
- transform: translateY(50%);
444
- }
185
+ export const TR = styled.div`
186
+ flex: 1 0 auto;
187
+ display: inline-flex;
188
+ padding: 0;
189
+ -webkit-box-align: center;
190
+ align-items: center;
191
+ `;
445
192
 
446
- .ReactTable .rt-resizing .rt-th,
447
- .ReactTable .rt-resizing .rt-td {
448
- transition: none !important;
449
- cursor: col-resize;
450
- user-select: none;
451
- }
193
+ export const TBody = styled.div`
194
+ border-top: 1px solid ${gray80};
195
+ margin-top: ${spacing * 2}px;
452
196
  `;
453
197
 
454
- export {CommonStyles};
198
+ export const TFoot = styled.div`
199
+ background: ${gray95};
200
+ flex: 1 0 auto;
201
+ display: flex;
202
+ flex-direction: column;
203
+ `;