@equinor/apollo-components 1.5.1 → 1.5.2
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 +16 -2
- package/dist/index.js +47 -14
- package/dist/index.mjs +45 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconData } from '@equinor/eds-icons';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, ComponentProps } from 'react';
|
|
4
|
-
import { Cell, CellContext, ColumnDef, Row, RowSelectionState, SortingState } from '@tanstack/react-table';
|
|
4
|
+
import { Cell, CellContext, ColumnDef, Row, RowSelectionState, SortingState, Table, HeaderContext } from '@tanstack/react-table';
|
|
5
5
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
6
6
|
import * as styled_components from 'styled-components';
|
|
7
7
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
@@ -84,6 +84,20 @@ declare const tableSortingAtom: jotai.PrimitiveAtom<SortingState> & {
|
|
|
84
84
|
init: SortingState;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
interface TableHeaderProps<T> {
|
|
88
|
+
table: Table<T>;
|
|
89
|
+
sticky?: boolean;
|
|
90
|
+
}
|
|
91
|
+
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Capitalize the table header.
|
|
95
|
+
*
|
|
96
|
+
* React table utility function.
|
|
97
|
+
* @param context
|
|
98
|
+
* @returns A capitalized header
|
|
99
|
+
*/
|
|
100
|
+
declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
|
|
87
101
|
/** Prepend a column definition array with a select column. */
|
|
88
102
|
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableConfig<T>): ColumnDef<T, unknown>[];
|
|
89
103
|
|
|
@@ -107,4 +121,4 @@ declare type TypographyProps = {
|
|
|
107
121
|
*/
|
|
108
122
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
109
123
|
|
|
110
|
-
export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowSelectionMode, SelectColumnDef, StickyCell, TypographyCustom, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
|
124
|
+
export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ __export(src_exports, {
|
|
|
34
34
|
HierarchyCell: () => HierarchyCell,
|
|
35
35
|
SelectColumnDef: () => SelectColumnDef,
|
|
36
36
|
StickyCell: () => StickyCell,
|
|
37
|
+
TableHeader: () => TableHeader,
|
|
37
38
|
TypographyCustom: () => TypographyCustom,
|
|
39
|
+
capitalizeHeader: () => capitalizeHeader,
|
|
38
40
|
globalFilterAtom: () => globalFilterAtom,
|
|
39
41
|
prependSelectColumn: () => prependSelectColumn,
|
|
40
42
|
rowSelectionAtom: () => rowSelectionAtom,
|
|
@@ -458,22 +460,31 @@ var HeaderDiv = import_styled_components11.default.div`
|
|
|
458
460
|
display: flex;
|
|
459
461
|
align-items: center;
|
|
460
462
|
gap: 0.25rem;
|
|
463
|
+
z-index: 5;
|
|
461
464
|
`;
|
|
462
465
|
var StyledStickyCell2 = (0, import_styled_components11.default)(StickyCell)`
|
|
463
|
-
z-index: 5;
|
|
464
466
|
${leftCellShadow}
|
|
465
467
|
`;
|
|
466
468
|
var HeaderCell = ({ header }) => {
|
|
467
469
|
var _a;
|
|
470
|
+
const style = {
|
|
471
|
+
width: header.column.getSize() === -1 ? "auto" : header.column.getSize()
|
|
472
|
+
};
|
|
473
|
+
const cellProps = {
|
|
474
|
+
style,
|
|
475
|
+
sort: getSort(header),
|
|
476
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
477
|
+
colSpan: header.colSpan
|
|
478
|
+
};
|
|
468
479
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
|
|
469
480
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledStickyCell2, {
|
|
470
|
-
|
|
481
|
+
...cellProps,
|
|
471
482
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
472
483
|
header
|
|
473
484
|
})
|
|
474
485
|
}, header.id);
|
|
475
486
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
|
|
476
|
-
|
|
487
|
+
...cellProps,
|
|
477
488
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
478
489
|
header
|
|
479
490
|
})
|
|
@@ -483,31 +494,47 @@ function HeaderContent({ header }) {
|
|
|
483
494
|
if (header.isPlaceholder)
|
|
484
495
|
return null;
|
|
485
496
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(HeaderDiv, {
|
|
486
|
-
onClick: header.column.getToggleSortingHandler(),
|
|
487
497
|
children: [
|
|
488
498
|
(0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
489
499
|
{
|
|
490
500
|
asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
491
|
-
data: import_eds_icons4.
|
|
501
|
+
data: import_eds_icons4.arrow_drop_up
|
|
492
502
|
}),
|
|
493
503
|
desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
494
|
-
data: import_eds_icons4.
|
|
504
|
+
data: import_eds_icons4.arrow_drop_down
|
|
505
|
+
}),
|
|
506
|
+
none: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
507
|
+
data: import_eds_icons4.arrow_drop_down
|
|
495
508
|
})
|
|
496
509
|
}[header.column.getIsSorted()] ?? null
|
|
497
510
|
]
|
|
498
511
|
});
|
|
499
512
|
}
|
|
513
|
+
function getSort({ column }) {
|
|
514
|
+
if (!column.getCanSort())
|
|
515
|
+
return void 0;
|
|
516
|
+
switch (column.getIsSorted()) {
|
|
517
|
+
case "asc":
|
|
518
|
+
return "ascending";
|
|
519
|
+
case "desc":
|
|
520
|
+
return "descending";
|
|
521
|
+
default:
|
|
522
|
+
return "none";
|
|
523
|
+
}
|
|
524
|
+
}
|
|
500
525
|
|
|
501
526
|
// src/DataTable/components/TableHeader.tsx
|
|
502
527
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
children:
|
|
507
|
-
header
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
})
|
|
528
|
+
function TableHeader({ table, sticky }) {
|
|
529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Head, {
|
|
530
|
+
sticky,
|
|
531
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
|
|
532
|
+
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HeaderCell, {
|
|
533
|
+
header
|
|
534
|
+
}, header.id))
|
|
535
|
+
}, headerGroup.id))
|
|
536
|
+
});
|
|
537
|
+
}
|
|
511
538
|
|
|
512
539
|
// src/DataTable/components/BasicTable.tsx
|
|
513
540
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
@@ -543,6 +570,10 @@ var import_react2 = require("react");
|
|
|
543
570
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
544
571
|
|
|
545
572
|
// src/DataTable/utils.tsx
|
|
573
|
+
function capitalizeHeader(context) {
|
|
574
|
+
const header = context.header.id;
|
|
575
|
+
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
576
|
+
}
|
|
546
577
|
function enableOrUndefined(enabled, value) {
|
|
547
578
|
return Boolean(enabled) ? value : void 0;
|
|
548
579
|
}
|
|
@@ -954,7 +985,9 @@ DataTable2.Provider = DataTableProvider;
|
|
|
954
985
|
HierarchyCell,
|
|
955
986
|
SelectColumnDef,
|
|
956
987
|
StickyCell,
|
|
988
|
+
TableHeader,
|
|
957
989
|
TypographyCustom,
|
|
990
|
+
capitalizeHeader,
|
|
958
991
|
globalFilterAtom,
|
|
959
992
|
prependSelectColumn,
|
|
960
993
|
rowSelectionAtom,
|
package/dist/index.mjs
CHANGED
|
@@ -422,22 +422,31 @@ var HeaderDiv = styled10.div`
|
|
|
422
422
|
display: flex;
|
|
423
423
|
align-items: center;
|
|
424
424
|
gap: 0.25rem;
|
|
425
|
+
z-index: 5;
|
|
425
426
|
`;
|
|
426
427
|
var StyledStickyCell2 = styled10(StickyCell)`
|
|
427
|
-
z-index: 5;
|
|
428
428
|
${leftCellShadow}
|
|
429
429
|
`;
|
|
430
430
|
var HeaderCell = ({ header }) => {
|
|
431
431
|
var _a;
|
|
432
|
+
const style = {
|
|
433
|
+
width: header.column.getSize() === -1 ? "auto" : header.column.getSize()
|
|
434
|
+
};
|
|
435
|
+
const cellProps = {
|
|
436
|
+
style,
|
|
437
|
+
sort: getSort(header),
|
|
438
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
439
|
+
colSpan: header.colSpan
|
|
440
|
+
};
|
|
432
441
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
|
|
433
442
|
return /* @__PURE__ */ jsx9(StyledStickyCell2, {
|
|
434
|
-
|
|
443
|
+
...cellProps,
|
|
435
444
|
children: /* @__PURE__ */ jsx9(HeaderContent, {
|
|
436
445
|
header
|
|
437
446
|
})
|
|
438
447
|
}, header.id);
|
|
439
448
|
return /* @__PURE__ */ jsx9(Table4.Cell, {
|
|
440
|
-
|
|
449
|
+
...cellProps,
|
|
441
450
|
children: /* @__PURE__ */ jsx9(HeaderContent, {
|
|
442
451
|
header
|
|
443
452
|
})
|
|
@@ -447,31 +456,47 @@ function HeaderContent({ header }) {
|
|
|
447
456
|
if (header.isPlaceholder)
|
|
448
457
|
return null;
|
|
449
458
|
return /* @__PURE__ */ jsxs6(HeaderDiv, {
|
|
450
|
-
onClick: header.column.getToggleSortingHandler(),
|
|
451
459
|
children: [
|
|
452
460
|
flexRender2(header.column.columnDef.header, header.getContext()),
|
|
453
461
|
{
|
|
454
462
|
asc: /* @__PURE__ */ jsx9(Icon4, {
|
|
455
|
-
data:
|
|
463
|
+
data: arrow_drop_up
|
|
456
464
|
}),
|
|
457
465
|
desc: /* @__PURE__ */ jsx9(Icon4, {
|
|
458
|
-
data:
|
|
466
|
+
data: arrow_drop_down
|
|
467
|
+
}),
|
|
468
|
+
none: /* @__PURE__ */ jsx9(Icon4, {
|
|
469
|
+
data: arrow_drop_down
|
|
459
470
|
})
|
|
460
471
|
}[header.column.getIsSorted()] ?? null
|
|
461
472
|
]
|
|
462
473
|
});
|
|
463
474
|
}
|
|
475
|
+
function getSort({ column }) {
|
|
476
|
+
if (!column.getCanSort())
|
|
477
|
+
return void 0;
|
|
478
|
+
switch (column.getIsSorted()) {
|
|
479
|
+
case "asc":
|
|
480
|
+
return "ascending";
|
|
481
|
+
case "desc":
|
|
482
|
+
return "descending";
|
|
483
|
+
default:
|
|
484
|
+
return "none";
|
|
485
|
+
}
|
|
486
|
+
}
|
|
464
487
|
|
|
465
488
|
// src/DataTable/components/TableHeader.tsx
|
|
466
489
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
children:
|
|
471
|
-
header
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
})
|
|
490
|
+
function TableHeader({ table, sticky }) {
|
|
491
|
+
return /* @__PURE__ */ jsx10(Table5.Head, {
|
|
492
|
+
sticky,
|
|
493
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(Table5.Row, {
|
|
494
|
+
children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx10(HeaderCell, {
|
|
495
|
+
header
|
|
496
|
+
}, header.id))
|
|
497
|
+
}, headerGroup.id))
|
|
498
|
+
});
|
|
499
|
+
}
|
|
475
500
|
|
|
476
501
|
// src/DataTable/components/BasicTable.tsx
|
|
477
502
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -507,6 +532,10 @@ import { useRef, useState as useState2 } from "react";
|
|
|
507
532
|
import styled11 from "styled-components";
|
|
508
533
|
|
|
509
534
|
// src/DataTable/utils.tsx
|
|
535
|
+
function capitalizeHeader(context) {
|
|
536
|
+
const header = context.header.id;
|
|
537
|
+
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
538
|
+
}
|
|
510
539
|
function enableOrUndefined(enabled, value) {
|
|
511
540
|
return Boolean(enabled) ? value : void 0;
|
|
512
541
|
}
|
|
@@ -917,7 +946,9 @@ export {
|
|
|
917
946
|
HierarchyCell,
|
|
918
947
|
SelectColumnDef,
|
|
919
948
|
StickyCell,
|
|
949
|
+
TableHeader,
|
|
920
950
|
TypographyCustom,
|
|
951
|
+
capitalizeHeader,
|
|
921
952
|
globalFilterAtom,
|
|
922
953
|
prependSelectColumn,
|
|
923
954
|
rowSelectionAtom,
|