@propellerads/table 4.8.0 → 5.0.1
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/dist/index.d.ts +2 -2
- package/dist/table.cjs.development.js +62 -39
- package/dist/table.cjs.development.js.map +1 -1
- package/dist/table.cjs.production.min.js +1 -1
- package/dist/table.cjs.production.min.js.map +1 -1
- package/dist/table.esm.js +62 -39
- package/dist/table.esm.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/package.json +8 -11
- package/src/index.tsx +77 -115
- package/src/propsGetter.tsx +49 -40
- package/src/style.tsx +41 -46
- package/src/types.tsx +117 -105
- package/src/useLoadingState.tsx +14 -9
- package/CHANGELOG.md +0 -85
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
FunctionComponent, useEffect, useMemo, useRef,
|
|
3
|
-
} from 'react';
|
|
1
|
+
import React, {FunctionComponent, useEffect, useMemo, useRef} from 'react';
|
|
4
2
|
import {
|
|
5
3
|
useSortBy,
|
|
6
4
|
useTable,
|
|
@@ -12,9 +10,7 @@ import {
|
|
|
12
10
|
Column,
|
|
13
11
|
} from 'react-table';
|
|
14
12
|
|
|
15
|
-
import {
|
|
16
|
-
ArrowDown, ArrowUp, COLOR, SIZE,
|
|
17
|
-
} from '@propellerads/icon';
|
|
13
|
+
import {ArrowDown, ArrowUp, COLOR, SIZE} from '@propellerads/icon';
|
|
18
14
|
import Checkbox from '@propellerads/input-checkbox';
|
|
19
15
|
|
|
20
16
|
import useLoadingState from './useLoadingState';
|
|
@@ -46,24 +42,41 @@ import {
|
|
|
46
42
|
} from './propsGetter';
|
|
47
43
|
|
|
48
44
|
import {
|
|
49
|
-
TableRoot,
|
|
50
|
-
TableWrapper,
|
|
51
|
-
TableContent,
|
|
52
|
-
HeadCell,
|
|
53
|
-
TableLoading,
|
|
54
|
-
TableLoadingInner,
|
|
55
|
-
TD,
|
|
56
|
-
TableCore,
|
|
57
|
-
THead,
|
|
58
|
-
TR,
|
|
59
|
-
TH,
|
|
60
|
-
TBody,
|
|
61
|
-
TRGroup,
|
|
62
|
-
TFoot,
|
|
63
|
-
EmptyStateCell,
|
|
64
|
-
TResizer,
|
|
45
|
+
TableRoot as _TableRoot,
|
|
46
|
+
TableWrapper as _TableWrapper,
|
|
47
|
+
TableContent as _TableContent,
|
|
48
|
+
HeadCell as _HeadCell,
|
|
49
|
+
TableLoading as _TableLoading,
|
|
50
|
+
TableLoadingInner as _TableLoadingInner,
|
|
51
|
+
TD as _TD,
|
|
52
|
+
TableCore as _TableCore,
|
|
53
|
+
THead as _THead,
|
|
54
|
+
TR as _TR,
|
|
55
|
+
TH as _TH,
|
|
56
|
+
TBody as _TBody,
|
|
57
|
+
TRGroup as _TRGroup,
|
|
58
|
+
TFoot as _TFoot,
|
|
59
|
+
EmptyStateCell as _EmptyStateCell,
|
|
60
|
+
TResizer as _TResizer,
|
|
65
61
|
} from './style';
|
|
66
62
|
|
|
63
|
+
const TableRoot = _TableRoot as unknown as React.FunctionComponent<DefaultObject>;
|
|
64
|
+
const TableWrapper = _TableWrapper as unknown as React.FunctionComponent<DefaultObject>;
|
|
65
|
+
const TableContent = _TableContent as unknown as React.FunctionComponent<DefaultObject>;
|
|
66
|
+
const HeadCell = _HeadCell as unknown as React.FunctionComponent<DefaultObject>;
|
|
67
|
+
const TableLoading = _TableLoading as unknown as React.FunctionComponent<DefaultObject>;
|
|
68
|
+
const TableLoadingInner = _TableLoadingInner as unknown as React.FunctionComponent<DefaultObject>;
|
|
69
|
+
const TD = _TD as unknown as React.FunctionComponent<DefaultObject>;
|
|
70
|
+
const TableCore = _TableCore as unknown as React.FunctionComponent<DefaultObject>;
|
|
71
|
+
const THead = _THead as unknown as React.FunctionComponent<DefaultObject>;
|
|
72
|
+
const TR = _TR as unknown as React.FunctionComponent<DefaultObject>;
|
|
73
|
+
const TH = _TH as unknown as React.FunctionComponent<DefaultObject>;
|
|
74
|
+
const TBody = _TBody as unknown as React.FunctionComponent<DefaultObject>;
|
|
75
|
+
const TRGroup = _TRGroup as unknown as React.FunctionComponent<DefaultObject>;
|
|
76
|
+
const TFoot = _TFoot as unknown as React.FunctionComponent<DefaultObject>;
|
|
77
|
+
const EmptyStateCell = _EmptyStateCell as unknown as React.FunctionComponent<DefaultObject>;
|
|
78
|
+
const TResizer = _TResizer as unknown as React.FunctionComponent<DefaultObject>;
|
|
79
|
+
|
|
67
80
|
const isEnableRowSelectDefault: () => boolean = () => true;
|
|
68
81
|
const selectColumnPropsDefault = {};
|
|
69
82
|
const getRowPrePropsDefault: () => DefaultObject = () => ({});
|
|
@@ -98,6 +111,22 @@ function isFunction(reference?: (arg1?: any, arg2?: any) => void) {
|
|
|
98
111
|
return typeof reference === 'function';
|
|
99
112
|
}
|
|
100
113
|
|
|
114
|
+
function renderResizer(column) {
|
|
115
|
+
if (column.isResizable) {
|
|
116
|
+
return (
|
|
117
|
+
<TResizer
|
|
118
|
+
{...column.getResizerProps()}
|
|
119
|
+
onClick={(e) => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
}}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
101
130
|
function getHeadContent(column: ColumnWithSort) {
|
|
102
131
|
if (column.isSorted && column.isSortedDesc) {
|
|
103
132
|
return (
|
|
@@ -152,7 +181,6 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
152
181
|
rowSubComponent,
|
|
153
182
|
isEnableRowSelect,
|
|
154
183
|
selectColumnProps,
|
|
155
|
-
isResizableColumns,
|
|
156
184
|
} = props;
|
|
157
185
|
|
|
158
186
|
const memoColumns = useMemo(() => columns, [columns]);
|
|
@@ -168,14 +196,10 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
168
196
|
const showLoading = showLoadingState && isLoading;
|
|
169
197
|
const hasSelectedRowsAbility = onSelectRowsChange && isFunction(onSelectRowsChange);
|
|
170
198
|
const hasManualSortBy = onSortedChange && isFunction(onSortedChange);
|
|
171
|
-
const hasControlledPagination = fetchData
|
|
172
|
-
&& controlledPagination
|
|
173
|
-
&& Object.keys(controlledPagination).length > 0;
|
|
199
|
+
const hasControlledPagination = fetchData && controlledPagination && Object.keys(controlledPagination).length > 0;
|
|
174
200
|
|
|
175
201
|
const options: TableOptionsProps = {
|
|
176
|
-
columns: showLoading
|
|
177
|
-
? (loadingColumns as Column<DefaultObject>[])
|
|
178
|
-
: memoColumns,
|
|
202
|
+
columns: showLoading ? (loadingColumns as Column<DefaultObject>[]) : memoColumns,
|
|
179
203
|
data: showLoading ? loadingData : data,
|
|
180
204
|
initialState,
|
|
181
205
|
disableSortRemove,
|
|
@@ -189,9 +213,7 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
189
213
|
|
|
190
214
|
if (hasControlledPagination) {
|
|
191
215
|
if (typeof controlledPagination?.pageCount === 'undefined') {
|
|
192
|
-
throw new Error(
|
|
193
|
-
'You have to pass pageCount in controlledPagination data',
|
|
194
|
-
);
|
|
216
|
+
throw new Error('You have to pass pageCount in controlledPagination data');
|
|
195
217
|
}
|
|
196
218
|
|
|
197
219
|
options.initialState = {
|
|
@@ -213,12 +235,8 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
213
235
|
const newColumn = {
|
|
214
236
|
id: 'selection',
|
|
215
237
|
disableSortBy: true,
|
|
216
|
-
Header: (instance: TableHooksInstanceProps & {
|
|
217
|
-
const {
|
|
218
|
-
getToggleAllPageRowsSelectedProps,
|
|
219
|
-
toggleAllPageRowsSelected,
|
|
220
|
-
page,
|
|
221
|
-
} = instance;
|
|
238
|
+
Header: (instance: TableHooksInstanceProps & {toggleAllPageRowsSelected: () => void}) => {
|
|
239
|
+
const {getToggleAllPageRowsSelectedProps, toggleAllPageRowsSelected, page} = instance;
|
|
222
240
|
|
|
223
241
|
const isDisabledAllRows = page.map(({original}) => original).filter(isEnableRowSelect).length === 0;
|
|
224
242
|
|
|
@@ -231,13 +249,8 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
231
249
|
/>
|
|
232
250
|
);
|
|
233
251
|
},
|
|
234
|
-
Cell: ({row}: {
|
|
235
|
-
const {
|
|
236
|
-
id,
|
|
237
|
-
original,
|
|
238
|
-
toggleRowSelected,
|
|
239
|
-
getToggleRowSelectedProps,
|
|
240
|
-
} = row;
|
|
252
|
+
Cell: ({row}: {row: SelectableRow}) => {
|
|
253
|
+
const {id, original, toggleRowSelected, getToggleRowSelectedProps} = row;
|
|
241
254
|
|
|
242
255
|
const elementId = Number.isInteger(original.id) ? original.id : id;
|
|
243
256
|
const isEnabled = isEnableRowSelect(row.original);
|
|
@@ -254,10 +267,7 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
254
267
|
...selectColumnProps,
|
|
255
268
|
};
|
|
256
269
|
|
|
257
|
-
hooks.visibleColumns.push((tableColumns: Array<StandardColumn>) => [
|
|
258
|
-
newColumn,
|
|
259
|
-
...tableColumns,
|
|
260
|
-
]);
|
|
270
|
+
hooks.visibleColumns.push((tableColumns: Array<StandardColumn>) => [newColumn, ...tableColumns]);
|
|
261
271
|
};
|
|
262
272
|
|
|
263
273
|
const {
|
|
@@ -311,9 +321,7 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
311
321
|
|
|
312
322
|
useEffect(() => {
|
|
313
323
|
if (hasSelectedRowsAbility) {
|
|
314
|
-
onSelectRowsChange?.(
|
|
315
|
-
selectedFlatRows?.map((row: StandardRow) => row.original).filter(isEnableRowSelect),
|
|
316
|
-
);
|
|
324
|
+
onSelectRowsChange?.(selectedFlatRows?.map((row: StandardRow) => row.original).filter(isEnableRowSelect));
|
|
317
325
|
}
|
|
318
326
|
}, [selectedRowIds]);
|
|
319
327
|
|
|
@@ -321,8 +329,8 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
321
329
|
|
|
322
330
|
if (hasDefaultPagination && hasControlledPagination) {
|
|
323
331
|
throw new Error(
|
|
324
|
-
'You have to pass either hasDefaultPagination true boolean prop or '
|
|
325
|
-
|
|
332
|
+
'You have to pass either hasDefaultPagination true boolean prop or ' +
|
|
333
|
+
'pass fetchData callback and controlledPagination data',
|
|
326
334
|
);
|
|
327
335
|
}
|
|
328
336
|
|
|
@@ -404,52 +412,26 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
404
412
|
|
|
405
413
|
return (
|
|
406
414
|
<TableRoot className="table-root">
|
|
407
|
-
<TableLoading
|
|
408
|
-
isLoading={!showLoadingState && isLoading}
|
|
409
|
-
className="table-loading"
|
|
410
|
-
>
|
|
415
|
+
<TableLoading isLoading={!showLoadingState && isLoading} className="table-loading">
|
|
411
416
|
<TableLoadingInner>{loadingMessage}</TableLoadingInner>
|
|
412
417
|
</TableLoading>
|
|
413
418
|
<TableWrapper ref={tableWrapperRef} className="table-wrapper">
|
|
414
419
|
<TableContent id={tableContentId} className="table-content">
|
|
415
|
-
<TableCore
|
|
416
|
-
{..._getTableProps(getTableBodyProps(getTableProps))}
|
|
417
|
-
ref={tableRef}
|
|
418
|
-
>
|
|
420
|
+
<TableCore {..._getTableProps(getTableBodyProps(getTableProps))} ref={tableRef}>
|
|
419
421
|
<THead className="table-head" data-role="table-head">
|
|
420
422
|
{headerGroups.map((headerGroup) => (
|
|
421
|
-
<TR
|
|
422
|
-
{...headerGroup.getHeaderGroupProps(
|
|
423
|
-
getTableElementProps(getHeaderGroupProps),
|
|
424
|
-
)}
|
|
425
|
-
>
|
|
423
|
+
<TR {...headerGroup.getHeaderGroupProps(getTableElementProps(getHeaderGroupProps))}>
|
|
426
424
|
{headerGroup.headers.map((column) => {
|
|
427
|
-
const headerProps = extendSortByProps(
|
|
428
|
-
column,
|
|
429
|
-
) as DefaultObject;
|
|
425
|
+
const headerProps = extendSortByProps(column) as DefaultObject;
|
|
430
426
|
|
|
431
427
|
return (
|
|
432
428
|
<TH
|
|
433
429
|
{...column.getHeaderProps(
|
|
434
|
-
getTableElementInternalProps(
|
|
435
|
-
headerProps,
|
|
436
|
-
getHeaderProps,
|
|
437
|
-
mainCellGetter,
|
|
438
|
-
),
|
|
430
|
+
getTableElementInternalProps(headerProps, getHeaderProps, mainCellGetter),
|
|
439
431
|
)}
|
|
440
432
|
>
|
|
441
433
|
{getHeadContent(column)}
|
|
442
|
-
{
|
|
443
|
-
<TResizer
|
|
444
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
445
|
-
// @ts-ignore
|
|
446
|
-
{...column.getResizerProps()}
|
|
447
|
-
onClick={(e) => {
|
|
448
|
-
e.preventDefault();
|
|
449
|
-
e.stopPropagation();
|
|
450
|
-
}}
|
|
451
|
-
/>
|
|
452
|
-
)}
|
|
434
|
+
{renderResizer(column)}
|
|
453
435
|
</TH>
|
|
454
436
|
);
|
|
455
437
|
})}
|
|
@@ -459,17 +441,9 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
459
441
|
{footerPlacement.includes(FOOTER_PLACEMENT.TOP) && (
|
|
460
442
|
<TFoot className="table-footer-top" data-role="table-footer-top">
|
|
461
443
|
{footerGroups.map((group) => (
|
|
462
|
-
<TR
|
|
463
|
-
{...group.getFooterGroupProps(
|
|
464
|
-
getTableElementProps(getFooterGroupProps),
|
|
465
|
-
)}
|
|
466
|
-
>
|
|
444
|
+
<TR {...group.getFooterGroupProps(getTableElementProps(getFooterGroupProps))}>
|
|
467
445
|
{group.headers.map((column) => (
|
|
468
|
-
<TD
|
|
469
|
-
{...column.getFooterProps(
|
|
470
|
-
getTableElementProps(getFooterProps, mainCellGetter),
|
|
471
|
-
)}
|
|
472
|
-
>
|
|
446
|
+
<TD {...column.getFooterProps(getTableElementProps(getFooterProps, mainCellGetter))}>
|
|
473
447
|
{column.render('Footer')}
|
|
474
448
|
</TD>
|
|
475
449
|
))}
|
|
@@ -483,17 +457,17 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
483
457
|
const {isDelimiterTd} = getRowPreProps(row);
|
|
484
458
|
|
|
485
459
|
if (isDelimiterTd) {
|
|
460
|
+
const cell = row.cells[0].render('Cell') as React.ReactNode;
|
|
461
|
+
|
|
486
462
|
return (
|
|
487
463
|
<React.Fragment key={`group_${row.index}`}>
|
|
488
464
|
<TRGroup>
|
|
489
465
|
<TR {...row.getRowProps(getTableRowProps(getRowProps))}>
|
|
490
466
|
<TD
|
|
491
467
|
colSpan={visibleColumns.length}
|
|
492
|
-
{...row.cells[0].getCellProps(
|
|
493
|
-
getTableCellProps(getCellProps, cellGetter),
|
|
494
|
-
)}
|
|
468
|
+
{...row.cells[0].getCellProps(getTableCellProps(getCellProps, cellGetter))}
|
|
495
469
|
>
|
|
496
|
-
<strong>{
|
|
470
|
+
<strong>{cell}</strong>
|
|
497
471
|
</TD>
|
|
498
472
|
</TR>
|
|
499
473
|
</TRGroup>
|
|
@@ -507,11 +481,7 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
507
481
|
<TRGroup>
|
|
508
482
|
<TR {...row.getRowProps(getTableRowProps(getRowProps))}>
|
|
509
483
|
{row.cells.map((cell: StandardCell) => (
|
|
510
|
-
<TD
|
|
511
|
-
{...cell.getCellProps(
|
|
512
|
-
getTableCellProps(getCellProps, cellGetter),
|
|
513
|
-
)}
|
|
514
|
-
>
|
|
484
|
+
<TD {...cell.getCellProps(getTableCellProps(getCellProps, cellGetter))}>
|
|
515
485
|
{cell.render('Cell')}
|
|
516
486
|
</TD>
|
|
517
487
|
))}
|
|
@@ -525,17 +495,9 @@ const Table: FunctionComponent<TableProps & DefaultProps> = (props) => {
|
|
|
525
495
|
{footerPlacement.includes(FOOTER_PLACEMENT.BOTTOM) && (
|
|
526
496
|
<TFoot className="table-footer-bottom" data-role="table-footer-bottom">
|
|
527
497
|
{footerGroups.map((group) => (
|
|
528
|
-
<TR
|
|
529
|
-
{...group.getFooterGroupProps(
|
|
530
|
-
getTableElementProps(getFooterGroupProps),
|
|
531
|
-
)}
|
|
532
|
-
>
|
|
498
|
+
<TR {...group.getFooterGroupProps(getTableElementProps(getFooterGroupProps))}>
|
|
533
499
|
{group.headers.map((column) => (
|
|
534
|
-
<TD
|
|
535
|
-
{...column.getFooterProps(
|
|
536
|
-
getTableElementProps(getFooterProps, mainCellGetter),
|
|
537
|
-
)}
|
|
538
|
-
>
|
|
500
|
+
<TD {...column.getFooterProps(getTableElementProps(getFooterProps, mainCellGetter))}>
|
|
539
501
|
{column.render('Footer')}
|
|
540
502
|
</TD>
|
|
541
503
|
))}
|
package/src/propsGetter.tsx
CHANGED
|
@@ -37,50 +37,59 @@ export const getTableProps: GetTableContainerPropsGetter = (userGetter, getter =
|
|
|
37
37
|
return getter;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const getTableElementProps:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
export const getTableElementProps: GetTableElementPropsGetter<ElementHeaderFooterPropGetter> = (
|
|
41
|
+
userGetter,
|
|
42
|
+
getter = defaultGetter,
|
|
43
|
+
) => {
|
|
44
|
+
if (userGetter) {
|
|
45
|
+
return (props, meta) => ({
|
|
46
|
+
...getter(props, meta),
|
|
47
|
+
...userGetter(props, meta),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
return getter;
|
|
52
|
+
};
|
|
51
53
|
|
|
52
|
-
export const getTableRowProps:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
export const getTableRowProps: GetTableElementPropsGetter<ElementRowPropGetter> = (
|
|
55
|
+
userGetter,
|
|
56
|
+
getter = defaultGetter,
|
|
57
|
+
) => {
|
|
58
|
+
if (userGetter) {
|
|
59
|
+
return (props, meta) => ({
|
|
60
|
+
...getter(props, meta),
|
|
61
|
+
...userGetter(props, meta),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
return getter;
|
|
66
|
+
};
|
|
63
67
|
|
|
64
|
-
export const getTableCellProps:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
export const getTableCellProps: GetTableElementPropsGetter<ElementCellPropGetter> = (
|
|
69
|
+
userGetter,
|
|
70
|
+
getter = defaultGetter,
|
|
71
|
+
) => {
|
|
72
|
+
if (userGetter) {
|
|
73
|
+
return (props, meta) => ({
|
|
74
|
+
...getter(props, meta),
|
|
75
|
+
...userGetter(props, meta),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
return getter;
|
|
80
|
+
};
|
|
75
81
|
|
|
76
|
-
export const getTableElementInternalProps:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
82
|
+
export const getTableElementInternalProps: GetTableElementInternalPropsGetter = (
|
|
83
|
+
internalProps,
|
|
84
|
+
userGetter,
|
|
85
|
+
getter = defaultGetter,
|
|
86
|
+
) => {
|
|
87
|
+
if (userGetter) {
|
|
88
|
+
return (props, meta) => ({
|
|
89
|
+
...getter({...props, ...internalProps}, meta),
|
|
90
|
+
...userGetter(props, meta),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
84
93
|
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
return (props: DefaultObject, meta: BaseMeta) => getter({...props, ...internalProps}, meta);
|
|
95
|
+
};
|
package/src/style.tsx
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/* eslint max-len: off */
|
|
2
|
-
import styled, {
|
|
3
|
-
|
|
4
|
-
} from 'styled-components';
|
|
5
|
-
import {
|
|
6
|
-
fontNormal,
|
|
7
|
-
white,
|
|
8
|
-
black,
|
|
9
|
-
spacing,
|
|
10
|
-
gray80,
|
|
11
|
-
gray95,
|
|
12
|
-
} from '@propellerads/stylevariables';
|
|
2
|
+
import styled, {keyframes, css, CSSObject} from 'styled-components';
|
|
3
|
+
import {fontNormal, white, black, spacing, gray80, gray95} from '@propellerads/stylevariables';
|
|
13
4
|
|
|
14
5
|
const loadingAnimation = keyframes`
|
|
15
6
|
from {
|
|
@@ -24,23 +15,25 @@ const loadingAnimation = keyframes`
|
|
|
24
15
|
`;
|
|
25
16
|
|
|
26
17
|
export const TableLoading = styled.div`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
${(props: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
18
|
+
display: block;
|
|
19
|
+
position: absolute;
|
|
20
|
+
left: 0;
|
|
21
|
+
right: 0;
|
|
22
|
+
top: 0;
|
|
23
|
+
bottom: 0;
|
|
24
|
+
background: rgba(255, 255, 255, 0.8);
|
|
25
|
+
transition: all 0.3s ease;
|
|
26
|
+
z-index: -1;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
|
|
30
|
+
${(props: {isLoading: boolean}) =>
|
|
31
|
+
props.isLoading &&
|
|
32
|
+
css`
|
|
33
|
+
opacity: 1;
|
|
34
|
+
z-index: 2;
|
|
35
|
+
pointer-events: all;
|
|
36
|
+
`}
|
|
44
37
|
`;
|
|
45
38
|
|
|
46
39
|
export const TableLoadingInner = styled.div`
|
|
@@ -58,7 +51,7 @@ export const TableLoadingInner = styled.div`
|
|
|
58
51
|
export const TableWrapper = styled.div`
|
|
59
52
|
position: relative;
|
|
60
53
|
overflow: hidden;
|
|
61
|
-
|
|
54
|
+
|
|
62
55
|
&::before {
|
|
63
56
|
bottom: 10px;
|
|
64
57
|
content: '';
|
|
@@ -69,7 +62,7 @@ export const TableWrapper = styled.div`
|
|
|
69
62
|
height: 100%;
|
|
70
63
|
top: 0;
|
|
71
64
|
left: -10px;
|
|
72
|
-
box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
|
|
65
|
+
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
|
|
73
66
|
transition: 0.3s opacity;
|
|
74
67
|
}
|
|
75
68
|
|
|
@@ -83,16 +76,16 @@ export const TableWrapper = styled.div`
|
|
|
83
76
|
position: absolute;
|
|
84
77
|
top: 0;
|
|
85
78
|
right: -10px;
|
|
86
|
-
box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
|
|
79
|
+
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
|
|
87
80
|
transition: 0.3s opacity;
|
|
88
81
|
}
|
|
89
|
-
|
|
82
|
+
|
|
90
83
|
&.shadow_left {
|
|
91
84
|
&::before {
|
|
92
85
|
opacity: 1 !important;
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
|
-
|
|
88
|
+
|
|
96
89
|
&.shadow_right {
|
|
97
90
|
&::after {
|
|
98
91
|
opacity: 1 !important;
|
|
@@ -119,7 +112,7 @@ export const TableCore = styled.div`
|
|
|
119
112
|
flex: auto 1;
|
|
120
113
|
display: flex;
|
|
121
114
|
flex-direction: column;
|
|
122
|
-
align-items: stretch;
|
|
115
|
+
align-items: stretch;
|
|
123
116
|
border-collapse: collapse;
|
|
124
117
|
`;
|
|
125
118
|
|
|
@@ -128,16 +121,18 @@ export const HeadCell = styled.div`
|
|
|
128
121
|
`;
|
|
129
122
|
|
|
130
123
|
export const TD = styled.div`
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
${({align}: {
|
|
139
|
-
|
|
140
|
-
|
|
124
|
+
white-space: nowrap;
|
|
125
|
+
text-overflow: ellipsis;
|
|
126
|
+
line-height: 1.3rem;
|
|
127
|
+
padding: 7px 4px;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
transition: width 0.3s ease 0s, min-width, padding, opacity;
|
|
130
|
+
|
|
131
|
+
${({align}: {align?: CSSObject; colSpan?: number}) =>
|
|
132
|
+
align &&
|
|
133
|
+
css`
|
|
134
|
+
text-align: ${align};
|
|
135
|
+
`}
|
|
141
136
|
`;
|
|
142
137
|
|
|
143
138
|
export const EmptyStateCell = styled.div`
|
|
@@ -163,7 +158,7 @@ export const THead = styled.div`
|
|
|
163
158
|
display: flex;
|
|
164
159
|
flex-direction: column;
|
|
165
160
|
user-select: none;
|
|
166
|
-
|
|
161
|
+
|
|
167
162
|
${TH}, ${TD} {
|
|
168
163
|
padding: 0 4px;
|
|
169
164
|
line-height: normal;
|
|
@@ -210,7 +205,7 @@ export const TResizer = styled.div`
|
|
|
210
205
|
top: 0;
|
|
211
206
|
z-index: 1;
|
|
212
207
|
touch-action: none;
|
|
213
|
-
|
|
208
|
+
|
|
214
209
|
&:after {
|
|
215
210
|
content: '↔';
|
|
216
211
|
position: absolute;
|