@equinor/apollo-components 3.1.8-cell.0 → 3.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/dist/index.d.ts +5 -1
- package/dist/index.js +62 -18
- package/dist/index.mjs +69 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import * as _equinor_eds_core_react from '@equinor/eds-core-react';
|
|
|
7
7
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
8
8
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
9
9
|
import { SetRequired } from 'type-fest';
|
|
10
|
+
import { TableOptions } from '@tanstack/table-core/build/lib/types';
|
|
10
11
|
|
|
11
12
|
interface AppShellProps {
|
|
12
13
|
children?: ReactNode;
|
|
@@ -38,8 +39,10 @@ declare function DynamicCell<T>({ cell, highlight, getStickyCellColor }: TableCe
|
|
|
38
39
|
|
|
39
40
|
interface HeaderCellProps<TData, TValue> {
|
|
40
41
|
header: Header<TData, TValue>;
|
|
42
|
+
/** Needed for column resizing */
|
|
43
|
+
table: Table<TData>;
|
|
41
44
|
}
|
|
42
|
-
declare const HeaderCell: <TData, TValue>({ header }: HeaderCellProps<TData, TValue>) => JSX.Element;
|
|
45
|
+
declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
|
|
43
46
|
|
|
44
47
|
declare type HierarchyCellOptions = {
|
|
45
48
|
getRowDepth?: () => number;
|
|
@@ -133,6 +136,7 @@ interface DataTableProps<T> {
|
|
|
133
136
|
virtual?: boolean;
|
|
134
137
|
getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
|
|
135
138
|
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
139
|
+
columnResizing?: boolean | TableOptions<T>['columnResizeMode'];
|
|
136
140
|
rowSelection?: Partial<ControlledState<RowSelectionState>> & {
|
|
137
141
|
mode?: RowSelectionMode;
|
|
138
142
|
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
package/dist/index.js
CHANGED
|
@@ -2594,16 +2594,40 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2594
2594
|
// src/cells/HeaderCell.tsx
|
|
2595
2595
|
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
2596
2596
|
var import_eds_icons3 = require("@equinor/eds-icons");
|
|
2597
|
+
var import_eds_tokens3 = require("@equinor/eds-tokens");
|
|
2597
2598
|
var import_react_table2 = require("@tanstack/react-table");
|
|
2598
2599
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2599
2600
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2600
|
-
var
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2601
|
+
var resizeCellStyle = import_styled_components6.css`
|
|
2602
|
+
.resizer {
|
|
2603
|
+
position: absolute;
|
|
2604
|
+
right: 0;
|
|
2605
|
+
top: 0;
|
|
2606
|
+
height: 100%;
|
|
2607
|
+
width: 4px;
|
|
2608
|
+
opacity: 0;
|
|
2609
|
+
background: #aaa;
|
|
2610
|
+
cursor: col-resize;
|
|
2611
|
+
user-select: none;
|
|
2612
|
+
touch-action: none;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
.resizer.isResizing {
|
|
2616
|
+
background: ${import_eds_tokens3.tokens.colors.interactive.focus.hex};
|
|
2617
|
+
opacity: 1;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
&:hover .resizer {
|
|
2621
|
+
opacity: 1;
|
|
2622
|
+
}
|
|
2623
|
+
`;
|
|
2624
|
+
var StickyCell2 = (0, import_styled_components6.default)(StickyHeaderCell)`
|
|
2625
|
+
${resizeCellStyle}
|
|
2605
2626
|
`;
|
|
2606
|
-
var
|
|
2627
|
+
var Cell2 = (0, import_styled_components6.default)(import_eds_core_react6.Table.Cell)`
|
|
2628
|
+
${resizeCellStyle}
|
|
2629
|
+
`;
|
|
2630
|
+
var HeaderCell = ({ header, table }) => {
|
|
2607
2631
|
var _a;
|
|
2608
2632
|
const style = {
|
|
2609
2633
|
width: header.column.getSize(),
|
|
@@ -2616,21 +2640,29 @@ var HeaderCell = ({ header }) => {
|
|
|
2616
2640
|
colSpan: header.colSpan
|
|
2617
2641
|
};
|
|
2618
2642
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
|
|
2619
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StickyCell2, {
|
|
2620
2644
|
...cellProps,
|
|
2621
2645
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContent, {
|
|
2622
|
-
header
|
|
2646
|
+
header,
|
|
2647
|
+
table
|
|
2623
2648
|
})
|
|
2624
2649
|
}, header.id);
|
|
2625
2650
|
}
|
|
2626
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Cell2, {
|
|
2627
2652
|
...cellProps,
|
|
2628
2653
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContent, {
|
|
2629
|
-
header
|
|
2654
|
+
header,
|
|
2655
|
+
table
|
|
2630
2656
|
})
|
|
2631
2657
|
}, header.id);
|
|
2632
2658
|
};
|
|
2633
|
-
|
|
2659
|
+
var HeaderDiv = import_styled_components6.default.div`
|
|
2660
|
+
display: flex;
|
|
2661
|
+
align-items: center;
|
|
2662
|
+
gap: 0.25rem;
|
|
2663
|
+
z-index: 5;
|
|
2664
|
+
`;
|
|
2665
|
+
function HeaderContent({ header, table }) {
|
|
2634
2666
|
if (header.isPlaceholder)
|
|
2635
2667
|
return null;
|
|
2636
2668
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(HeaderDiv, {
|
|
@@ -2646,7 +2678,16 @@ function HeaderContent({ header }) {
|
|
|
2646
2678
|
none: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, {
|
|
2647
2679
|
data: import_eds_icons3.arrow_drop_down
|
|
2648
2680
|
})
|
|
2649
|
-
}[header.column.getIsSorted()] ?? null
|
|
2681
|
+
}[header.column.getIsSorted()] ?? null,
|
|
2682
|
+
table.options.enableColumnResizing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
2683
|
+
onMouseDown: header.getResizeHandler(),
|
|
2684
|
+
onTouchStart: header.getResizeHandler(),
|
|
2685
|
+
onClick: (e) => e.stopPropagation(),
|
|
2686
|
+
className: `resizer ${header.column.getIsResizing() ? "isResizing" : ""}`,
|
|
2687
|
+
style: {
|
|
2688
|
+
transform: table.options.columnResizeMode === "onEnd" && header.column.getIsResizing() ? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)` : ""
|
|
2689
|
+
}
|
|
2690
|
+
})
|
|
2650
2691
|
]
|
|
2651
2692
|
});
|
|
2652
2693
|
}
|
|
@@ -2664,12 +2705,12 @@ function getSort({ column }) {
|
|
|
2664
2705
|
}
|
|
2665
2706
|
|
|
2666
2707
|
// src/cells/HierarchyCell.tsx
|
|
2667
|
-
var
|
|
2708
|
+
var import_eds_tokens5 = require("@equinor/eds-tokens");
|
|
2668
2709
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2669
2710
|
|
|
2670
2711
|
// src/cells/TypographyCustom.tsx
|
|
2671
2712
|
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
2672
|
-
var
|
|
2713
|
+
var import_eds_tokens4 = require("@equinor/eds-tokens");
|
|
2673
2714
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2674
2715
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2675
2716
|
var truncateStyle = {
|
|
@@ -2703,7 +2744,7 @@ var TypographyCustom = (props) => {
|
|
|
2703
2744
|
});
|
|
2704
2745
|
};
|
|
2705
2746
|
var HoverCapture = import_styled_components7.default.div`
|
|
2706
|
-
height: ${
|
|
2747
|
+
height: ${import_eds_tokens4.tokens.typography.table.cell_text.lineHeight};
|
|
2707
2748
|
background-color: inherit;
|
|
2708
2749
|
|
|
2709
2750
|
position: relative;
|
|
@@ -2738,11 +2779,11 @@ var CellWrapper = (0, import_styled_components8.default)(TypographyCustom)`
|
|
|
2738
2779
|
${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
|
|
2739
2780
|
|
|
2740
2781
|
${({ depth }) => depth > 0 && import_styled_components8.css`
|
|
2741
|
-
border-left: 3px solid ${
|
|
2782
|
+
border-left: 3px solid ${import_eds_tokens5.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
2742
2783
|
gap: 0.5rem;
|
|
2743
2784
|
.--divider {
|
|
2744
2785
|
width: ${depth * 32}px;
|
|
2745
|
-
background-color: ${
|
|
2786
|
+
background-color: ${import_eds_tokens5.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
2746
2787
|
height: 3px;
|
|
2747
2788
|
border-radius: 0 5px 5px 0;
|
|
2748
2789
|
}
|
|
@@ -2998,7 +3039,8 @@ function TableHeader({ table, sticky }) {
|
|
|
2998
3039
|
sticky,
|
|
2999
3040
|
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Row, {
|
|
3000
3041
|
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(HeaderCell, {
|
|
3001
|
-
header
|
|
3042
|
+
header,
|
|
3043
|
+
table
|
|
3002
3044
|
}, header.id))
|
|
3003
3045
|
}, headerGroup.id))
|
|
3004
3046
|
});
|
|
@@ -3460,6 +3502,8 @@ function DataTable(props) {
|
|
|
3460
3502
|
});
|
|
3461
3503
|
}
|
|
3462
3504
|
},
|
|
3505
|
+
enableColumnResizing: Boolean(props.columnResizing),
|
|
3506
|
+
columnResizeMode: typeof props.columnResizing === "boolean" ? "onChange" : props.columnResizing,
|
|
3463
3507
|
enableSorting: sorting == null ? void 0 : sorting.enableSorting,
|
|
3464
3508
|
manualSorting: sorting == null ? void 0 : sorting.manualSorting,
|
|
3465
3509
|
enableExpanding: Boolean(props.expansion),
|
package/dist/index.mjs
CHANGED
|
@@ -2547,18 +2547,42 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2547
2547
|
}
|
|
2548
2548
|
|
|
2549
2549
|
// src/cells/HeaderCell.tsx
|
|
2550
|
-
import { Icon as Icon3, Table as
|
|
2550
|
+
import { Icon as Icon3, Table as EdsTable } from "@equinor/eds-core-react";
|
|
2551
2551
|
import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
|
|
2552
|
+
import { tokens as tokens3 } from "@equinor/eds-tokens";
|
|
2552
2553
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
2553
|
-
import styled6 from "styled-components";
|
|
2554
|
+
import styled6, { css as css3 } from "styled-components";
|
|
2554
2555
|
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2555
|
-
var
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2556
|
+
var resizeCellStyle = css3`
|
|
2557
|
+
.resizer {
|
|
2558
|
+
position: absolute;
|
|
2559
|
+
right: 0;
|
|
2560
|
+
top: 0;
|
|
2561
|
+
height: 100%;
|
|
2562
|
+
width: 4px;
|
|
2563
|
+
opacity: 0;
|
|
2564
|
+
background: #aaa;
|
|
2565
|
+
cursor: col-resize;
|
|
2566
|
+
user-select: none;
|
|
2567
|
+
touch-action: none;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
.resizer.isResizing {
|
|
2571
|
+
background: ${tokens3.colors.interactive.focus.hex};
|
|
2572
|
+
opacity: 1;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
&:hover .resizer {
|
|
2576
|
+
opacity: 1;
|
|
2577
|
+
}
|
|
2578
|
+
`;
|
|
2579
|
+
var StickyCell2 = styled6(StickyHeaderCell)`
|
|
2580
|
+
${resizeCellStyle}
|
|
2560
2581
|
`;
|
|
2561
|
-
var
|
|
2582
|
+
var Cell2 = styled6(EdsTable.Cell)`
|
|
2583
|
+
${resizeCellStyle}
|
|
2584
|
+
`;
|
|
2585
|
+
var HeaderCell = ({ header, table }) => {
|
|
2562
2586
|
var _a;
|
|
2563
2587
|
const style = {
|
|
2564
2588
|
width: header.column.getSize(),
|
|
@@ -2571,21 +2595,29 @@ var HeaderCell = ({ header }) => {
|
|
|
2571
2595
|
colSpan: header.colSpan
|
|
2572
2596
|
};
|
|
2573
2597
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
|
|
2574
|
-
return /* @__PURE__ */ jsx6(
|
|
2598
|
+
return /* @__PURE__ */ jsx6(StickyCell2, {
|
|
2575
2599
|
...cellProps,
|
|
2576
2600
|
children: /* @__PURE__ */ jsx6(HeaderContent, {
|
|
2577
|
-
header
|
|
2601
|
+
header,
|
|
2602
|
+
table
|
|
2578
2603
|
})
|
|
2579
2604
|
}, header.id);
|
|
2580
2605
|
}
|
|
2581
|
-
return /* @__PURE__ */ jsx6(
|
|
2606
|
+
return /* @__PURE__ */ jsx6(Cell2, {
|
|
2582
2607
|
...cellProps,
|
|
2583
2608
|
children: /* @__PURE__ */ jsx6(HeaderContent, {
|
|
2584
|
-
header
|
|
2609
|
+
header,
|
|
2610
|
+
table
|
|
2585
2611
|
})
|
|
2586
2612
|
}, header.id);
|
|
2587
2613
|
};
|
|
2588
|
-
|
|
2614
|
+
var HeaderDiv = styled6.div`
|
|
2615
|
+
display: flex;
|
|
2616
|
+
align-items: center;
|
|
2617
|
+
gap: 0.25rem;
|
|
2618
|
+
z-index: 5;
|
|
2619
|
+
`;
|
|
2620
|
+
function HeaderContent({ header, table }) {
|
|
2589
2621
|
if (header.isPlaceholder)
|
|
2590
2622
|
return null;
|
|
2591
2623
|
return /* @__PURE__ */ jsxs3(HeaderDiv, {
|
|
@@ -2601,7 +2633,16 @@ function HeaderContent({ header }) {
|
|
|
2601
2633
|
none: /* @__PURE__ */ jsx6(Icon3, {
|
|
2602
2634
|
data: arrow_drop_down
|
|
2603
2635
|
})
|
|
2604
|
-
}[header.column.getIsSorted()] ?? null
|
|
2636
|
+
}[header.column.getIsSorted()] ?? null,
|
|
2637
|
+
table.options.enableColumnResizing && /* @__PURE__ */ jsx6("div", {
|
|
2638
|
+
onMouseDown: header.getResizeHandler(),
|
|
2639
|
+
onTouchStart: header.getResizeHandler(),
|
|
2640
|
+
onClick: (e) => e.stopPropagation(),
|
|
2641
|
+
className: `resizer ${header.column.getIsResizing() ? "isResizing" : ""}`,
|
|
2642
|
+
style: {
|
|
2643
|
+
transform: table.options.columnResizeMode === "onEnd" && header.column.getIsResizing() ? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)` : ""
|
|
2644
|
+
}
|
|
2645
|
+
})
|
|
2605
2646
|
]
|
|
2606
2647
|
});
|
|
2607
2648
|
}
|
|
@@ -2619,14 +2660,14 @@ function getSort({ column }) {
|
|
|
2619
2660
|
}
|
|
2620
2661
|
|
|
2621
2662
|
// src/cells/HierarchyCell.tsx
|
|
2622
|
-
import { tokens as
|
|
2623
|
-
import styled8, { css as
|
|
2663
|
+
import { tokens as tokens5 } from "@equinor/eds-tokens";
|
|
2664
|
+
import styled8, { css as css4 } from "styled-components";
|
|
2624
2665
|
|
|
2625
2666
|
// src/cells/TypographyCustom.tsx
|
|
2626
2667
|
import {
|
|
2627
2668
|
Typography as EdsTypography
|
|
2628
2669
|
} from "@equinor/eds-core-react";
|
|
2629
|
-
import { tokens as
|
|
2670
|
+
import { tokens as tokens4 } from "@equinor/eds-tokens";
|
|
2630
2671
|
import styled7 from "styled-components";
|
|
2631
2672
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2632
2673
|
var truncateStyle = {
|
|
@@ -2660,7 +2701,7 @@ var TypographyCustom = (props) => {
|
|
|
2660
2701
|
});
|
|
2661
2702
|
};
|
|
2662
2703
|
var HoverCapture = styled7.div`
|
|
2663
|
-
height: ${
|
|
2704
|
+
height: ${tokens4.typography.table.cell_text.lineHeight};
|
|
2664
2705
|
background-color: inherit;
|
|
2665
2706
|
|
|
2666
2707
|
position: relative;
|
|
@@ -2694,12 +2735,12 @@ var CellWrapper = styled8(TypographyCustom)`
|
|
|
2694
2735
|
|
|
2695
2736
|
${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
|
|
2696
2737
|
|
|
2697
|
-
${({ depth }) => depth > 0 &&
|
|
2698
|
-
border-left: 3px solid ${
|
|
2738
|
+
${({ depth }) => depth > 0 && css4`
|
|
2739
|
+
border-left: 3px solid ${tokens5.colors.infographic.primary__moss_green_34.hex};
|
|
2699
2740
|
gap: 0.5rem;
|
|
2700
2741
|
.--divider {
|
|
2701
2742
|
width: ${depth * 32}px;
|
|
2702
|
-
background-color: ${
|
|
2743
|
+
background-color: ${tokens5.colors.infographic.primary__moss_green_34.hex};
|
|
2703
2744
|
height: 3px;
|
|
2704
2745
|
border-radius: 0 5px 5px 0;
|
|
2705
2746
|
}
|
|
@@ -2955,7 +2996,8 @@ function TableHeader({ table, sticky }) {
|
|
|
2955
2996
|
sticky,
|
|
2956
2997
|
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx12(Table4.Row, {
|
|
2957
2998
|
children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx12(HeaderCell, {
|
|
2958
|
-
header
|
|
2999
|
+
header,
|
|
3000
|
+
table
|
|
2959
3001
|
}, header.id))
|
|
2960
3002
|
}, headerGroup.id))
|
|
2961
3003
|
});
|
|
@@ -2973,7 +3015,7 @@ import { useEffect as useEffect3, useRef as useRef3, useState as useState6 } fro
|
|
|
2973
3015
|
import styled16 from "styled-components";
|
|
2974
3016
|
|
|
2975
3017
|
// src/DataTable/components/BasicTable.tsx
|
|
2976
|
-
import { Table as
|
|
3018
|
+
import { Table as EdsTable2 } from "@equinor/eds-core-react";
|
|
2977
3019
|
|
|
2978
3020
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
2979
3021
|
import { DotProgress, Table as Table5, Typography as Typography2 } from "@equinor/eds-core-react";
|
|
@@ -3068,9 +3110,9 @@ function BasicTable({
|
|
|
3068
3110
|
tableCaption
|
|
3069
3111
|
}) {
|
|
3070
3112
|
const tableRows = table.getRowModel().rows;
|
|
3071
|
-
return /* @__PURE__ */ jsxs8(
|
|
3113
|
+
return /* @__PURE__ */ jsxs8(EdsTable2, {
|
|
3072
3114
|
children: [
|
|
3073
|
-
/* @__PURE__ */ jsx15(
|
|
3115
|
+
/* @__PURE__ */ jsx15(EdsTable2.Caption, {
|
|
3074
3116
|
hidden: true,
|
|
3075
3117
|
children: tableCaption
|
|
3076
3118
|
}),
|
|
@@ -3423,6 +3465,8 @@ function DataTable(props) {
|
|
|
3423
3465
|
});
|
|
3424
3466
|
}
|
|
3425
3467
|
},
|
|
3468
|
+
enableColumnResizing: Boolean(props.columnResizing),
|
|
3469
|
+
columnResizeMode: typeof props.columnResizing === "boolean" ? "onChange" : props.columnResizing,
|
|
3426
3470
|
enableSorting: sorting == null ? void 0 : sorting.enableSorting,
|
|
3427
3471
|
manualSorting: sorting == null ? void 0 : sorting.manualSorting,
|
|
3428
3472
|
enableExpanding: Boolean(props.expansion),
|