@equinor/apollo-components 2.0.0 → 3.0.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 +11 -15
- package/dist/index.js +22 -20
- package/dist/index.mjs +22 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,18 +45,6 @@ interface TableHeaderProps<T> {
|
|
|
45
45
|
}
|
|
46
46
|
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
47
47
|
|
|
48
|
-
interface HeaderConfig {
|
|
49
|
-
sticky?: boolean;
|
|
50
|
-
}
|
|
51
|
-
interface FilterConfig {
|
|
52
|
-
enableTableCaption?: boolean;
|
|
53
|
-
totalRowCount?: number;
|
|
54
|
-
columnSelect?: boolean;
|
|
55
|
-
globalFilter?: boolean;
|
|
56
|
-
globalFilterPlaceholder?: string;
|
|
57
|
-
filterFromLeafRows?: boolean;
|
|
58
|
-
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
59
|
-
}
|
|
60
48
|
interface TableRowWrapper<T> {
|
|
61
49
|
(props: TableRowWrapperProps<T>): ReactElement;
|
|
62
50
|
}
|
|
@@ -109,10 +97,10 @@ interface DataTableProps<T> {
|
|
|
109
97
|
columns: ColumnDef<T, any>[];
|
|
110
98
|
cellConfig?: CellConfig<T>;
|
|
111
99
|
rowConfig?: RowConfig<T>;
|
|
112
|
-
headerConfig?: HeaderConfig;
|
|
113
100
|
isLoading?: boolean;
|
|
114
101
|
height?: string;
|
|
115
102
|
width?: string;
|
|
103
|
+
stickyHeader?: boolean;
|
|
116
104
|
/**
|
|
117
105
|
* Defaults to `'auto'`.
|
|
118
106
|
*
|
|
@@ -139,7 +127,10 @@ interface DataTableProps<T> {
|
|
|
139
127
|
};
|
|
140
128
|
globalFilter?: ControlledState<string>;
|
|
141
129
|
columnVisibility?: ControlledState<VisibilityState>;
|
|
142
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Everything that has todo with the area (banner) over the table
|
|
132
|
+
*/
|
|
133
|
+
bannerConfig?: {
|
|
143
134
|
enableTableCaption?: boolean;
|
|
144
135
|
totalRowCount?: number;
|
|
145
136
|
enableColumnSelect?: boolean;
|
|
@@ -147,6 +138,11 @@ interface DataTableProps<T> {
|
|
|
147
138
|
globalFilterPlaceholder?: string;
|
|
148
139
|
filterFromLeafRows?: boolean;
|
|
149
140
|
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
141
|
+
/**
|
|
142
|
+
* Default 1rem
|
|
143
|
+
* Accepts any CSS padding value
|
|
144
|
+
*/
|
|
145
|
+
padding?: string;
|
|
150
146
|
};
|
|
151
147
|
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
152
148
|
infiniteScroll?: InfiniteScrollConfig;
|
|
@@ -179,4 +175,4 @@ declare type TypographyProps = {
|
|
|
179
175
|
} & TypographyProps$1;
|
|
180
176
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
181
177
|
|
|
182
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell,
|
|
178
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, HTMLPropsRef, HierarchyCell, InfiniteScrollConfig, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, prependSelectColumn };
|
package/dist/index.js
CHANGED
|
@@ -802,12 +802,12 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
802
802
|
|
|
803
803
|
// src/DataTable/components/DataTableHeader.tsx
|
|
804
804
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
805
|
-
var
|
|
805
|
+
var TableBannerWrapper = import_styled_components15.default.div`
|
|
806
806
|
display: flex;
|
|
807
807
|
align-items: center;
|
|
808
808
|
justify-content: space-between;
|
|
809
809
|
gap: 0.5rem;
|
|
810
|
-
padding: 1rem;
|
|
810
|
+
padding: ${(props) => props.padding || "1rem"};
|
|
811
811
|
`;
|
|
812
812
|
var FilterContainer = import_styled_components15.default.div`
|
|
813
813
|
display: flex;
|
|
@@ -815,45 +815,47 @@ var FilterContainer = import_styled_components15.default.div`
|
|
|
815
815
|
gap: 1rem;
|
|
816
816
|
justify-content: flex-end;
|
|
817
817
|
`;
|
|
818
|
-
function
|
|
818
|
+
function TableBanner({
|
|
819
819
|
table,
|
|
820
|
-
|
|
820
|
+
bannerConfig,
|
|
821
821
|
tableCaption,
|
|
822
822
|
globalFilter
|
|
823
823
|
}) {
|
|
824
824
|
var _a;
|
|
825
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(TableBannerWrapper, {
|
|
826
826
|
className: "--table-caption",
|
|
827
|
+
padding: bannerConfig == null ? void 0 : bannerConfig.padding,
|
|
827
828
|
children: [
|
|
828
829
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(FilterContainer, {
|
|
829
830
|
className: "--filter-container-left",
|
|
830
831
|
children: [
|
|
831
|
-
(
|
|
832
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react15.Typography, {
|
|
832
833
|
variant: "h3",
|
|
834
|
+
as: "h2",
|
|
833
835
|
children: tableCaption
|
|
834
836
|
}),
|
|
835
|
-
(_a =
|
|
837
|
+
(_a = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _a.call(bannerConfig, table)
|
|
836
838
|
]
|
|
837
839
|
}),
|
|
838
840
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FilterContainer, {
|
|
839
841
|
className: "--filter-container-right",
|
|
840
842
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, {
|
|
841
843
|
children: [
|
|
842
|
-
(
|
|
844
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableGlobalFilterInput) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DebouncedInput, {
|
|
843
845
|
value: globalFilter.state,
|
|
844
846
|
icon: import_eds_icons7.search,
|
|
845
|
-
placeholder:
|
|
847
|
+
placeholder: bannerConfig.globalFilterPlaceholder ?? "Search all columns",
|
|
846
848
|
onChange: (value) => globalFilter.onChange(String(value))
|
|
847
849
|
}),
|
|
848
|
-
(
|
|
850
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableColumnSelect) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ColumnSelect, {
|
|
849
851
|
table
|
|
850
852
|
}),
|
|
851
|
-
(
|
|
853
|
+
(bannerConfig == null ? void 0 : bannerConfig.totalRowCount) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", {
|
|
852
854
|
children: [
|
|
853
855
|
table.options.data.length.toLocaleString(),
|
|
854
856
|
" /",
|
|
855
857
|
" ",
|
|
856
|
-
|
|
858
|
+
bannerConfig.totalRowCount.toLocaleString(),
|
|
857
859
|
" rows"
|
|
858
860
|
]
|
|
859
861
|
})
|
|
@@ -984,8 +986,8 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
984
986
|
}
|
|
985
987
|
`;
|
|
986
988
|
function DataTable(props) {
|
|
987
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r
|
|
988
|
-
const { columns, data,
|
|
989
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
990
|
+
const { columns, data, bannerConfig, cellConfig, sorting } = props;
|
|
989
991
|
const [internalColumnVisibility, setInternalColumnVisibility] = (0, import_react5.useState)({});
|
|
990
992
|
const [columnVisibility, setColumnVisibility] = [
|
|
991
993
|
((_a = props.columnVisibility) == null ? void 0 : _a.state) ?? internalColumnVisibility,
|
|
@@ -996,7 +998,7 @@ function DataTable(props) {
|
|
|
996
998
|
((_c = props.globalFilter) == null ? void 0 : _c.state) ?? internalGlobalFilterState,
|
|
997
999
|
((_d = props.globalFilter) == null ? void 0 : _d.onChange) ?? setInternalGlobalFilterState
|
|
998
1000
|
];
|
|
999
|
-
const shouldEnableGlobalFilter = ((_e = props.
|
|
1001
|
+
const shouldEnableGlobalFilter = ((_e = props.bannerConfig) == null ? void 0 : _e.enableGlobalFilterInput) || Boolean(props.globalFilter);
|
|
1000
1002
|
function enableGlobalFilter(value) {
|
|
1001
1003
|
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
1002
1004
|
}
|
|
@@ -1040,7 +1042,7 @@ function DataTable(props) {
|
|
|
1040
1042
|
enableExpanding: Boolean(props.expansion),
|
|
1041
1043
|
enableMultiRowSelection: ((_n = props.rowSelection) == null ? void 0 : _n.mode) === "multiple",
|
|
1042
1044
|
enableSubRowSelection: ((_o = props.rowSelection) == null ? void 0 : _o.mode) !== "single",
|
|
1043
|
-
filterFromLeafRows:
|
|
1045
|
+
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
1044
1046
|
getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
|
|
1045
1047
|
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
1046
1048
|
getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
|
|
@@ -1070,9 +1072,9 @@ function DataTable(props) {
|
|
|
1070
1072
|
width: props == null ? void 0 : props.width,
|
|
1071
1073
|
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
1072
1074
|
children: [
|
|
1073
|
-
props.
|
|
1075
|
+
props.bannerConfig && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TableBanner, {
|
|
1074
1076
|
table,
|
|
1075
|
-
|
|
1077
|
+
bannerConfig: props.bannerConfig,
|
|
1076
1078
|
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
1077
1079
|
tableCaption: props.tableCaption
|
|
1078
1080
|
}),
|
|
@@ -1096,14 +1098,14 @@ function DataTable(props) {
|
|
|
1096
1098
|
rowConfig,
|
|
1097
1099
|
cellConfig,
|
|
1098
1100
|
isLoading,
|
|
1099
|
-
stickyHeader:
|
|
1101
|
+
stickyHeader: props.stickyHeader
|
|
1100
1102
|
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
1101
1103
|
tableCaption: props.tableCaption,
|
|
1102
1104
|
table,
|
|
1103
1105
|
rowConfig,
|
|
1104
1106
|
cellConfig,
|
|
1105
1107
|
isLoading,
|
|
1106
|
-
stickyHeader:
|
|
1108
|
+
stickyHeader: props.stickyHeader
|
|
1107
1109
|
})
|
|
1108
1110
|
})
|
|
1109
1111
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -766,12 +766,12 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
766
766
|
|
|
767
767
|
// src/DataTable/components/DataTableHeader.tsx
|
|
768
768
|
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
769
|
-
var
|
|
769
|
+
var TableBannerWrapper = styled15.div`
|
|
770
770
|
display: flex;
|
|
771
771
|
align-items: center;
|
|
772
772
|
justify-content: space-between;
|
|
773
773
|
gap: 0.5rem;
|
|
774
|
-
padding: 1rem;
|
|
774
|
+
padding: ${(props) => props.padding || "1rem"};
|
|
775
775
|
`;
|
|
776
776
|
var FilterContainer = styled15.div`
|
|
777
777
|
display: flex;
|
|
@@ -779,45 +779,47 @@ var FilterContainer = styled15.div`
|
|
|
779
779
|
gap: 1rem;
|
|
780
780
|
justify-content: flex-end;
|
|
781
781
|
`;
|
|
782
|
-
function
|
|
782
|
+
function TableBanner({
|
|
783
783
|
table,
|
|
784
|
-
|
|
784
|
+
bannerConfig,
|
|
785
785
|
tableCaption,
|
|
786
786
|
globalFilter
|
|
787
787
|
}) {
|
|
788
788
|
var _a;
|
|
789
|
-
return /* @__PURE__ */ jsxs8(
|
|
789
|
+
return /* @__PURE__ */ jsxs8(TableBannerWrapper, {
|
|
790
790
|
className: "--table-caption",
|
|
791
|
+
padding: bannerConfig == null ? void 0 : bannerConfig.padding,
|
|
791
792
|
children: [
|
|
792
793
|
/* @__PURE__ */ jsxs8(FilterContainer, {
|
|
793
794
|
className: "--filter-container-left",
|
|
794
795
|
children: [
|
|
795
|
-
(
|
|
796
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ jsx15(Typography2, {
|
|
796
797
|
variant: "h3",
|
|
798
|
+
as: "h2",
|
|
797
799
|
children: tableCaption
|
|
798
800
|
}),
|
|
799
|
-
(_a =
|
|
801
|
+
(_a = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _a.call(bannerConfig, table)
|
|
800
802
|
]
|
|
801
803
|
}),
|
|
802
804
|
/* @__PURE__ */ jsx15(FilterContainer, {
|
|
803
805
|
className: "--filter-container-right",
|
|
804
806
|
children: /* @__PURE__ */ jsxs8(Fragment3, {
|
|
805
807
|
children: [
|
|
806
|
-
(
|
|
808
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableGlobalFilterInput) && /* @__PURE__ */ jsx15(DebouncedInput, {
|
|
807
809
|
value: globalFilter.state,
|
|
808
810
|
icon: search,
|
|
809
|
-
placeholder:
|
|
811
|
+
placeholder: bannerConfig.globalFilterPlaceholder ?? "Search all columns",
|
|
810
812
|
onChange: (value) => globalFilter.onChange(String(value))
|
|
811
813
|
}),
|
|
812
|
-
(
|
|
814
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableColumnSelect) && /* @__PURE__ */ jsx15(ColumnSelect, {
|
|
813
815
|
table
|
|
814
816
|
}),
|
|
815
|
-
(
|
|
817
|
+
(bannerConfig == null ? void 0 : bannerConfig.totalRowCount) && /* @__PURE__ */ jsxs8("span", {
|
|
816
818
|
children: [
|
|
817
819
|
table.options.data.length.toLocaleString(),
|
|
818
820
|
" /",
|
|
819
821
|
" ",
|
|
820
|
-
|
|
822
|
+
bannerConfig.totalRowCount.toLocaleString(),
|
|
821
823
|
" rows"
|
|
822
824
|
]
|
|
823
825
|
})
|
|
@@ -948,8 +950,8 @@ var DataTableWrapper = styled16.div`
|
|
|
948
950
|
}
|
|
949
951
|
`;
|
|
950
952
|
function DataTable(props) {
|
|
951
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r
|
|
952
|
-
const { columns, data,
|
|
953
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
954
|
+
const { columns, data, bannerConfig, cellConfig, sorting } = props;
|
|
953
955
|
const [internalColumnVisibility, setInternalColumnVisibility] = useState4({});
|
|
954
956
|
const [columnVisibility, setColumnVisibility] = [
|
|
955
957
|
((_a = props.columnVisibility) == null ? void 0 : _a.state) ?? internalColumnVisibility,
|
|
@@ -960,7 +962,7 @@ function DataTable(props) {
|
|
|
960
962
|
((_c = props.globalFilter) == null ? void 0 : _c.state) ?? internalGlobalFilterState,
|
|
961
963
|
((_d = props.globalFilter) == null ? void 0 : _d.onChange) ?? setInternalGlobalFilterState
|
|
962
964
|
];
|
|
963
|
-
const shouldEnableGlobalFilter = ((_e = props.
|
|
965
|
+
const shouldEnableGlobalFilter = ((_e = props.bannerConfig) == null ? void 0 : _e.enableGlobalFilterInput) || Boolean(props.globalFilter);
|
|
964
966
|
function enableGlobalFilter(value) {
|
|
965
967
|
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
966
968
|
}
|
|
@@ -1004,7 +1006,7 @@ function DataTable(props) {
|
|
|
1004
1006
|
enableExpanding: Boolean(props.expansion),
|
|
1005
1007
|
enableMultiRowSelection: ((_n = props.rowSelection) == null ? void 0 : _n.mode) === "multiple",
|
|
1006
1008
|
enableSubRowSelection: ((_o = props.rowSelection) == null ? void 0 : _o.mode) !== "single",
|
|
1007
|
-
filterFromLeafRows:
|
|
1009
|
+
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
1008
1010
|
getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
|
|
1009
1011
|
getCoreRowModel: getCoreRowModel(),
|
|
1010
1012
|
getExpandedRowModel: getExpandedRowModel(),
|
|
@@ -1034,9 +1036,9 @@ function DataTable(props) {
|
|
|
1034
1036
|
width: props == null ? void 0 : props.width,
|
|
1035
1037
|
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
1036
1038
|
children: [
|
|
1037
|
-
props.
|
|
1039
|
+
props.bannerConfig && /* @__PURE__ */ jsx18(TableBanner, {
|
|
1038
1040
|
table,
|
|
1039
|
-
|
|
1041
|
+
bannerConfig: props.bannerConfig,
|
|
1040
1042
|
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
1041
1043
|
tableCaption: props.tableCaption
|
|
1042
1044
|
}),
|
|
@@ -1060,14 +1062,14 @@ function DataTable(props) {
|
|
|
1060
1062
|
rowConfig,
|
|
1061
1063
|
cellConfig,
|
|
1062
1064
|
isLoading,
|
|
1063
|
-
stickyHeader:
|
|
1065
|
+
stickyHeader: props.stickyHeader
|
|
1064
1066
|
}) : /* @__PURE__ */ jsx18(BasicTable, {
|
|
1065
1067
|
tableCaption: props.tableCaption,
|
|
1066
1068
|
table,
|
|
1067
1069
|
rowConfig,
|
|
1068
1070
|
cellConfig,
|
|
1069
1071
|
isLoading,
|
|
1070
|
-
stickyHeader:
|
|
1072
|
+
stickyHeader: props.stickyHeader
|
|
1071
1073
|
})
|
|
1072
1074
|
})
|
|
1073
1075
|
]
|