@osdk/react-components 0.1.0-beta.6 → 0.1.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/CHANGELOG.md +33 -0
- package/README.md +2 -5
- package/build/browser/base-components/checkbox/Checkbox.js +32 -27
- package/build/browser/object-table/CellContextMenu.js +20 -23
- package/build/browser/object-table/LoadingCell.js +38 -0
- package/build/browser/object-table/LoadingCell.js.map +1 -0
- package/build/browser/object-table/LoadingRow.js +69 -0
- package/build/browser/object-table/LoadingRow.js.map +1 -0
- package/build/browser/object-table/LoadingStateTable.js +395 -0
- package/build/browser/object-table/LoadingStateTable.js.map +1 -0
- package/build/browser/object-table/NonIdealState.js +25 -0
- package/build/browser/object-table/NonIdealState.js.map +1 -0
- package/build/browser/object-table/ObjectTable.js +6 -5
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/Table.js +948 -45
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/TableBody.js +269 -34
- package/build/browser/object-table/TableBody.js.map +1 -1
- package/build/browser/object-table/TableCell.js +111 -31
- package/build/browser/object-table/TableCell.js.map +1 -1
- package/build/browser/object-table/TableHeader.js +215 -38
- package/build/browser/object-table/TableHeaderContent.js +18 -21
- package/build/browser/object-table/TableHeaderContent.js.map +1 -1
- package/build/browser/object-table/TableHeaderWithPopover.js +80 -66
- package/build/browser/object-table/TableRow.js +144 -26
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js +18 -20
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
- package/build/browser/object-table/hooks/useColumnDefs.js +6 -2
- package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/browser/object-table/hooks/useColumnPinning.js.map +1 -1
- package/build/browser/object-table/hooks/useColumnVisibility.js.map +1 -1
- package/build/browser/object-table/hooks/useObjectTableData.js +7 -6
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/object-table/hooks/useRowSelection.js.map +1 -1
- package/build/browser/object-table/hooks/useSelectionColumn.js.map +1 -1
- package/build/browser/object-table/hooks/useTableSorting.js.map +1 -1
- package/build/browser/object-table/utils/getRowId.js.map +1 -1
- package/build/cjs/public/experimental.cjs +435 -264
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +114 -56
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +8 -11
- package/build/esm/base-components/checkbox/Checkbox.module.css +10 -3
- package/build/esm/object-table/CellContextMenu.module.css +1 -1
- package/build/{browser/object-table/CellContextMenu.module.css → esm/object-table/LoadingCell.js} +16 -3
- package/build/esm/object-table/LoadingCell.js.map +1 -0
- package/build/esm/object-table/LoadingCell.module.css +48 -0
- package/build/esm/object-table/LoadingRow.js +43 -0
- package/build/esm/object-table/LoadingRow.js.map +1 -0
- package/build/esm/object-table/LoadingStateTable.js +101 -0
- package/build/esm/object-table/LoadingStateTable.js.map +1 -0
- package/build/{browser/object-table/TableHeaderContent.module.css → esm/object-table/NonIdealState.js} +11 -13
- package/build/esm/object-table/NonIdealState.js.map +1 -0
- package/build/{browser/object-table/Table.module.css → esm/object-table/NonIdealState.module.css} +10 -4
- package/build/esm/object-table/ObjectTable.js +6 -5
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/Table.js +34 -13
- package/build/esm/object-table/Table.js.map +1 -1
- package/build/esm/object-table/Table.module.css +2 -2
- package/build/esm/object-table/TableBody.js +13 -2
- package/build/esm/object-table/TableBody.js.map +1 -1
- package/build/esm/object-table/TableCell.js.map +1 -1
- package/build/esm/object-table/TableCell.module.css +7 -8
- package/build/esm/object-table/TableHeader.module.css +15 -9
- package/build/esm/object-table/TableHeaderContent.js.map +1 -1
- package/build/esm/object-table/TableHeaderWithPopover.module.css +31 -26
- package/build/esm/object-table/TableRow.module.css +1 -1
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js +18 -20
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
- package/build/esm/object-table/hooks/useColumnDefs.js +6 -2
- package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/esm/object-table/hooks/useColumnPinning.js.map +1 -1
- package/build/esm/object-table/hooks/useColumnVisibility.js.map +1 -1
- package/build/esm/object-table/hooks/useObjectTableData.js +7 -6
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/object-table/hooks/useRowSelection.js.map +1 -1
- package/build/esm/object-table/hooks/useSelectionColumn.js.map +1 -1
- package/build/esm/object-table/hooks/useTableSorting.js.map +1 -1
- package/build/esm/object-table/utils/getRowId.js.map +1 -1
- package/build/types/object-table/LoadingCell.d.ts +4 -0
- package/build/types/object-table/LoadingCell.d.ts.map +1 -0
- package/build/types/object-table/LoadingRow.d.ts +11 -0
- package/build/types/object-table/LoadingRow.d.ts.map +1 -0
- package/build/types/object-table/LoadingStateTable.d.ts +11 -0
- package/build/types/object-table/LoadingStateTable.d.ts.map +1 -0
- package/build/types/object-table/NonIdealState.d.ts +6 -0
- package/build/types/object-table/NonIdealState.d.ts.map +1 -0
- package/build/types/object-table/ObjectTable.d.ts +4 -4
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +4 -8
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/Table.d.ts +2 -1
- package/build/types/object-table/Table.d.ts.map +1 -1
- package/build/types/object-table/TableBody.d.ts +4 -2
- package/build/types/object-table/TableBody.d.ts.map +1 -1
- package/build/types/object-table/TableHeaderContent.d.ts.map +1 -1
- package/build/types/object-table/hooks/useColumnDefs.d.ts +3 -3
- package/build/types/object-table/hooks/useColumnDefs.d.ts.map +1 -1
- package/build/types/object-table/hooks/useColumnPinning.d.ts +3 -3
- package/build/types/object-table/hooks/useColumnPinning.d.ts.map +1 -1
- package/build/types/object-table/hooks/useColumnVisibility.d.ts +3 -3
- package/build/types/object-table/hooks/useColumnVisibility.d.ts.map +1 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts +6 -6
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
- package/build/types/object-table/hooks/useRowSelection.d.ts +3 -3
- package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
- package/build/types/object-table/hooks/useSelectionColumn.d.ts +2 -2
- package/build/types/object-table/hooks/useSelectionColumn.d.ts.map +1 -1
- package/build/types/object-table/hooks/useTableSorting.d.ts +3 -3
- package/build/types/object-table/hooks/useTableSorting.d.ts.map +1 -1
- package/build/types/object-table/utils/getRowId.d.ts +3 -3
- package/build/types/object-table/utils/getRowId.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/browser/base-components/checkbox/Checkbox.module.css +0 -72
- package/build/browser/object-table/TableBody.module.css +0 -20
- package/build/browser/object-table/TableCell.module.css +0 -63
- package/build/browser/object-table/TableHeader.module.css +0 -95
- package/build/browser/object-table/TableHeaderWithPopover.module.css +0 -105
- package/build/browser/object-table/TableRow.module.css +0 -60
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import classNames from "classnames";
|
|
18
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
19
|
+
import loadingStyles from "./LoadingCell.module.css";
|
|
20
|
+
import { LoadingRow } from "./LoadingRow.js";
|
|
21
|
+
import bodyStyles from "./TableBody.module.css";
|
|
22
|
+
import { TableHeader } from "./TableHeader.js";
|
|
23
|
+
import headerStyles from "./TableHeader.module.css";
|
|
24
|
+
const MIN_ROWS = 5;
|
|
25
|
+
export function LoadingStateTable({
|
|
26
|
+
table,
|
|
27
|
+
tableContainerRef,
|
|
28
|
+
headerGroups,
|
|
29
|
+
rowHeight = 40,
|
|
30
|
+
columnWidth = 120
|
|
31
|
+
}) {
|
|
32
|
+
// If selection enabled, there will be a header for the selection column
|
|
33
|
+
const isSelectionEnabled = table.options.enableRowSelection;
|
|
34
|
+
const minHeaderCount = isSelectionEnabled ? 1 : 0;
|
|
35
|
+
const headers = headerGroups[0]?.headers ?? [];
|
|
36
|
+
const hasHeadersLoaded = headers.length > minHeaderCount;
|
|
37
|
+
const headerRef = useRef(null);
|
|
38
|
+
const bodyRef = useRef(null);
|
|
39
|
+
const [loadingRowCount, setLoadingRowCount] = useState(MIN_ROWS);
|
|
40
|
+
const [loadingColumnCount, setLoadingColumnCount] = useState(headers.length);
|
|
41
|
+
// Calculate number of columns needed to fill container width
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (hasHeadersLoaded) {
|
|
44
|
+
setLoadingColumnCount(headers.length);
|
|
45
|
+
} else {
|
|
46
|
+
if (tableContainerRef.current) {
|
|
47
|
+
const tableWidth = tableContainerRef.current.clientWidth;
|
|
48
|
+
if (tableWidth > 0) {
|
|
49
|
+
const columnsNeeded = Math.ceil(tableWidth / columnWidth);
|
|
50
|
+
setLoadingColumnCount(columnsNeeded);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, [columnWidth, hasHeadersLoaded, headers, tableContainerRef]);
|
|
55
|
+
|
|
56
|
+
// Calculate number of rows needed to fill container height
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (tableContainerRef.current) {
|
|
59
|
+
const containerHeight = tableContainerRef.current.clientHeight;
|
|
60
|
+
const availableHeight = containerHeight - rowHeight;
|
|
61
|
+
if (availableHeight > 0) {
|
|
62
|
+
const rowsNeeded = Math.ceil(availableHeight / rowHeight);
|
|
63
|
+
setLoadingRowCount(Math.max(rowsNeeded, MIN_ROWS));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, [tableContainerRef, rowHeight]);
|
|
67
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, hasHeadersLoaded ? /*#__PURE__*/React.createElement(TableHeader, {
|
|
68
|
+
table: table
|
|
69
|
+
}) : /*#__PURE__*/React.createElement("thead", {
|
|
70
|
+
className: headerStyles.osdkTableHeader,
|
|
71
|
+
ref: headerRef
|
|
72
|
+
}, /*#__PURE__*/React.createElement("tr", {
|
|
73
|
+
className: headerStyles.osdkTableHeaderRow
|
|
74
|
+
}, Array.from({
|
|
75
|
+
length: loadingColumnCount
|
|
76
|
+
}).map((_, index) => {
|
|
77
|
+
const width = headers.length > index ? headers[index].getSize() : columnWidth;
|
|
78
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
79
|
+
key: `loading-header-${index}`,
|
|
80
|
+
className: headerStyles.osdkTableHeaderCell,
|
|
81
|
+
style: {
|
|
82
|
+
width
|
|
83
|
+
}
|
|
84
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: classNames(headerStyles.osdkLoadingHeaderCell, loadingStyles.osdkCellSkeleton)
|
|
86
|
+
}));
|
|
87
|
+
}))), /*#__PURE__*/React.createElement("tbody", {
|
|
88
|
+
className: bodyStyles.osdkTableBody,
|
|
89
|
+
ref: bodyRef
|
|
90
|
+
}, Array.from({
|
|
91
|
+
length: loadingRowCount
|
|
92
|
+
}).map((_, index) => /*#__PURE__*/React.createElement(LoadingRow, {
|
|
93
|
+
key: `skeleton-${index}`,
|
|
94
|
+
columnCount: loadingColumnCount,
|
|
95
|
+
headers: headers,
|
|
96
|
+
translateY: rowHeight * index,
|
|
97
|
+
rowHeight: rowHeight,
|
|
98
|
+
columnWidth: columnWidth
|
|
99
|
+
}))));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=LoadingStateTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingStateTable.js","names":["classNames","React","useEffect","useRef","useState","loadingStyles","LoadingRow","bodyStyles","TableHeader","headerStyles","MIN_ROWS","LoadingStateTable","table","tableContainerRef","headerGroups","rowHeight","columnWidth","isSelectionEnabled","options","enableRowSelection","minHeaderCount","headers","hasHeadersLoaded","length","headerRef","bodyRef","loadingRowCount","setLoadingRowCount","loadingColumnCount","setLoadingColumnCount","current","tableWidth","clientWidth","columnsNeeded","Math","ceil","containerHeight","clientHeight","availableHeight","rowsNeeded","max","createElement","Fragment","className","osdkTableHeader","ref","osdkTableHeaderRow","Array","from","map","_","index","width","getSize","key","osdkTableHeaderCell","style","osdkLoadingHeaderCell","osdkCellSkeleton","osdkTableBody","columnCount","translateY"],"sources":["LoadingStateTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HeaderGroup, RowData, Table } from \"@tanstack/react-table\";\nimport classNames from \"classnames\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport loadingStyles from \"./LoadingCell.module.css\";\nimport { LoadingRow } from \"./LoadingRow.js\";\nimport bodyStyles from \"./TableBody.module.css\";\nimport { TableHeader } from \"./TableHeader.js\";\nimport headerStyles from \"./TableHeader.module.css\";\n\ninterface LoadingStateTableProps<TData extends RowData> {\n table: Table<TData>;\n tableContainerRef: React.RefObject<HTMLDivElement>;\n headerGroups: Array<HeaderGroup<TData>>;\n rowHeight?: number;\n columnWidth?: number;\n}\n\nconst MIN_ROWS = 5;\n\nexport function LoadingStateTable<TData extends RowData>({\n table,\n tableContainerRef,\n headerGroups,\n rowHeight = 40,\n columnWidth = 120,\n}: LoadingStateTableProps<TData>): React.ReactElement {\n // If selection enabled, there will be a header for the selection column\n const isSelectionEnabled = table.options.enableRowSelection;\n const minHeaderCount = isSelectionEnabled ? 1 : 0;\n const headers = headerGroups[0]?.headers ?? [];\n const hasHeadersLoaded = headers.length > minHeaderCount;\n\n const headerRef = useRef<HTMLTableSectionElement>(null);\n const bodyRef = useRef<HTMLTableSectionElement>(null);\n const [loadingRowCount, setLoadingRowCount] = useState<number>(MIN_ROWS);\n const [loadingColumnCount, setLoadingColumnCount] = useState<number>(\n headers.length,\n );\n // Calculate number of columns needed to fill container width\n useEffect(() => {\n if (hasHeadersLoaded) {\n setLoadingColumnCount(headers.length);\n } else {\n if (tableContainerRef.current) {\n const tableWidth = tableContainerRef.current.clientWidth;\n if (tableWidth > 0) {\n const columnsNeeded = Math.ceil(tableWidth / columnWidth);\n setLoadingColumnCount(columnsNeeded);\n }\n }\n }\n }, [columnWidth, hasHeadersLoaded, headers, tableContainerRef]);\n\n // Calculate number of rows needed to fill container height\n useEffect(() => {\n if (tableContainerRef.current) {\n const containerHeight = tableContainerRef.current.clientHeight;\n const availableHeight = containerHeight - rowHeight;\n\n if (availableHeight > 0) {\n const rowsNeeded = Math.ceil(availableHeight / rowHeight);\n setLoadingRowCount(Math.max(rowsNeeded, MIN_ROWS));\n }\n }\n }, [tableContainerRef, rowHeight]);\n\n return (\n <>\n {hasHeadersLoaded\n ? <TableHeader table={table} />\n : (\n <thead className={headerStyles.osdkTableHeader} ref={headerRef}>\n <tr className={headerStyles.osdkTableHeaderRow}>\n {Array.from({ length: loadingColumnCount }).map((\n _,\n index,\n ) => {\n const width = headers.length > index\n ? headers[index].getSize()\n : columnWidth;\n return (\n <th\n key={`loading-header-${index}`}\n className={headerStyles.osdkTableHeaderCell}\n style={{ width }}\n >\n <div\n className={classNames(\n headerStyles.osdkLoadingHeaderCell,\n loadingStyles.osdkCellSkeleton,\n )}\n />\n </th>\n );\n })}\n </tr>\n </thead>\n )}\n <tbody className={bodyStyles.osdkTableBody} ref={bodyRef}>\n {Array.from({ length: loadingRowCount }).map((_, index) => (\n <LoadingRow\n key={`skeleton-${index}`}\n columnCount={loadingColumnCount}\n headers={headers}\n translateY={rowHeight * index}\n rowHeight={rowHeight}\n columnWidth={columnWidth}\n />\n ))}\n </tbody>\n </>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,OAAOC,aAAa,MAAM,0BAA0B;AACpD,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAOC,YAAY,MAAM,0BAA0B;AAUnD,MAAMC,QAAQ,GAAG,CAAC;AAElB,OAAO,SAASC,iBAAiBA,CAAwB;EACvDC,KAAK;EACLC,iBAAiB;EACjBC,YAAY;EACZC,SAAS,GAAG,EAAE;EACdC,WAAW,GAAG;AACe,CAAC,EAAsB;EACpD;EACA,MAAMC,kBAAkB,GAAGL,KAAK,CAACM,OAAO,CAACC,kBAAkB;EAC3D,MAAMC,cAAc,GAAGH,kBAAkB,GAAG,CAAC,GAAG,CAAC;EACjD,MAAMI,OAAO,GAAGP,YAAY,CAAC,CAAC,CAAC,EAAEO,OAAO,IAAI,EAAE;EAC9C,MAAMC,gBAAgB,GAAGD,OAAO,CAAC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EAAEA,OAAQ;IACjBwC,UAAU,EAAE9C,SAAS,GAAGoC,KAAM;IAC9BpC,SAAS,EAAEA,SAAU;IACrBC,WAAW,EAAEA;EAAY,CAC1B,CACF,CACI,CACP,CAAC;AAEP","ignoreList":[]}
|
|
@@ -14,17 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.osdkHeaderContent:has([role="checkbox"]) {
|
|
28
|
-
display: flex;
|
|
29
|
-
justify-content: center;
|
|
17
|
+
import React from "react";
|
|
18
|
+
import styles from "./NonIdealState.module.css";
|
|
19
|
+
export function NonIdealState({
|
|
20
|
+
message
|
|
21
|
+
}) {
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: styles.container
|
|
24
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: styles.message
|
|
26
|
+
}, message));
|
|
30
27
|
}
|
|
28
|
+
//# sourceMappingURL=NonIdealState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NonIdealState.js","names":["React","styles","NonIdealState","message","createElement","className","container"],"sources":["NonIdealState.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport styles from \"./NonIdealState.module.css\";\n\ninterface NonIdealStateProps {\n message: string;\n}\n\nexport function NonIdealState(\n { message }: NonIdealStateProps,\n): React.ReactElement {\n return (\n <div className={styles.container}>\n <div className={styles.message}>\n {message}\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,4BAA4B;AAM/C,OAAO,SAASC,aAAaA,CAC3B;EAAEC;AAA4B,CAAC,EACX;EACpB,oBACEH,KAAA,CAAAI,aAAA;IAAKC,SAAS,EAAEJ,MAAM,CAACK;EAAU,gBAC/BN,KAAA,CAAAI,aAAA;IAAKC,SAAS,EAAEJ,MAAM,CAACE;EAAQ,GAC5BA,OACE,CACF,CAAC;AAEV","ignoreList":[]}
|
package/build/{browser/object-table/Table.module.css → esm/object-table/NonIdealState.module.css}
RENAMED
|
@@ -14,9 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
.container {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
min-height: 80px;
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
.message {
|
|
27
|
+
color: var(--osdk-typography-color-muted);
|
|
28
|
+
}
|
|
@@ -31,12 +31,11 @@ import { getRowId } from "./utils/getRowId.js";
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```tsx
|
|
34
|
-
* <ObjectTable
|
|
34
|
+
* <ObjectTable objectType={MyObjectType} />
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
export function ObjectTable({
|
|
39
|
-
objectSet,
|
|
40
39
|
objectType,
|
|
41
40
|
columnDefinitions,
|
|
42
41
|
filter,
|
|
@@ -62,8 +61,9 @@ export function ObjectTable({
|
|
|
62
61
|
const {
|
|
63
62
|
data,
|
|
64
63
|
fetchMore,
|
|
65
|
-
isLoading
|
|
66
|
-
|
|
64
|
+
isLoading,
|
|
65
|
+
error
|
|
66
|
+
} = useObjectTableData(objectType, columnDefinitions, filter, sorting);
|
|
67
67
|
const {
|
|
68
68
|
columns,
|
|
69
69
|
loading: isColumnsLoading
|
|
@@ -135,7 +135,8 @@ export function ObjectTable({
|
|
|
135
135
|
onRowClick: props.onRowClick,
|
|
136
136
|
rowHeight: props.rowHeight,
|
|
137
137
|
renderCellContextMenu: onRenderCellContextMenu,
|
|
138
|
-
className: props.className
|
|
138
|
+
className: props.className,
|
|
139
|
+
error: error
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
//# sourceMappingURL=ObjectTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useState","useColumnDefs","useColumnPinning","useColumnVisibility","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","ObjectTable","
|
|
1
|
+
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useState","useColumnDefs","useColumnPinning","useColumnVisibility","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","ObjectTable","objectType","columnDefinitions","filter","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onRowSelection","renderCellContextMenu","selectionMode","selectedRows","props","columnSizing","setColumnSizing","sorting","onSortingChange","data","fetchMore","isLoading","error","columns","loading","isColumnsLoading","columnVisibility","rowSelection","isAllSelected","hasSelection","onToggleAll","onToggleRow","selectionColumn","allColumns","columnPinning","onColumnPinningChange","hasSelectionColumn","table","state","onColumnSizingChange","enableRowSelection","columnResizeMode","columnResizeDirection","manualSorting","defaultColumn","minSize","onRenderCellContextMenu","row","cell","getValue","createElement","fetchNextPage","onRowClick","rowHeight","className"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { Cell, ColumnSizingState } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useColumnPinning } from \"./hooks/useColumnPinning.js\";\nimport { useColumnVisibility } from \"./hooks/useColumnVisibility.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport { useTableSorting } from \"./hooks/useTableSorting.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { BaseTable } from \"./Table.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectType,\n columnDefinitions,\n filter,\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n onColumnsPinnedChanged,\n onRowSelection,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const [columnSizing, setColumnSizing] = useState<ColumnSizingState>({});\n\n const { sorting, onSortingChange } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >(\n {\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n },\n );\n\n const { data, fetchMore, isLoading, error } = useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n filter,\n sorting,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const columnVisibility = useColumnVisibility({ columnDefinitions });\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n onRowSelection,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n { selectionMode, isAllSelected, hasSelection, onToggleAll, onToggleRow },\n );\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const { columnPinning, onColumnPinningChange } = useColumnPinning({\n columnDefinitions,\n hasSelectionColumn: selectionColumn != null,\n onColumnsPinnedChanged,\n });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? [],\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n rowSelection,\n sorting,\n columnSizing,\n columnPinning,\n },\n onSortingChange,\n onColumnSizingChange: setColumnSizing,\n onColumnPinningChange,\n enableRowSelection: selectionMode !== \"none\",\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n manualSorting: true, // Enable manual sorting to indicate server-side sorting\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\n });\n\n const onRenderCellContextMenu = useCallback(\n (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cell: Cell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n return renderCellContextMenu?.(row, cell.getValue());\n },\n [renderCellContextMenu],\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n return (\n <BaseTable\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n className={props.className}\n error={error}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC7D,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAE5D,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,QAAQ,QAAQ,qBAAqB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,UAAU;EACVC,iBAAiB;EACjBC,MAAM;EACNC,OAAO;EACPC,cAAc;EACdC,gBAAgB;EAChBC,sBAAsB;EACtBC,cAAc;EACdC,qBAAqB;EACrBC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZ,GAAGC;AACuC,CAAC,EAAsB;EACjE,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAA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;IAClCmD,KAAK,EAAE;MACLZ,gBAAgB;MAChBC,YAAY;MACZV,OAAO;MACPF,YAAY;MACZmB;IACF,CAAC;IACDhB,eAAe;IACfqB,oBAAoB,EAAEvB,eAAe;IACrCmB,qBAAqB;IACrBK,kBAAkB,EAAE5B,aAAa,KAAK,MAAM;IAC5C6B,gBAAgB,EAAE,UAAU;IAC5BC,qBAAqB,EAAE,KAAK;IAC5BC,aAAa,EAAE,IAAI;IAAE;IACrBC,aAAa,EAAE;MACbC,OAAO,EAAE;IACX,CAAC;IACD5C;EACF,CAAC,CAAC;EAEF,MAAM6C,uBAAuB,GAAGxD,WAAW,CACzC,CACEyD,GAAkE,EAClEC,IAGC,KACE;IACH,OAAOrC,qBAAqB,GAAGoC,GAAG,EAAEC,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;EACtD,CAAC,EACD,CAACtC,qBAAqB,CACxB,CAAC;EAID,oBACEtB,KAAA,CAAA6D,aAAA,CAAClD,SAAS;IACRqC,KAAK,EAAEA,KAAM;IACbhB,SAAS,EALUA,SAAS,IAAII,gBAKN;IAC1B0B,aAAa,EAAE/B,SAAU;IACzBgC,UAAU,EAAEtC,KAAK,CAACsC,UAAW;IAC7BC,SAAS,EAAEvC,KAAK,CAACuC,SAAU;IAC3B1C,qBAAqB,EAAEmC,uBAAwB;IAC/CQ,SAAS,EAAExC,KAAK,CAACwC,SAAU;IAC3BhC,KAAK,EAAEA;EAAM,CACd,CAAC;AAEN","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n
|
|
1
|
+
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | {\n type: \"property\";\n id: PropertyKeys<Q>;\n }\n | {\n type: \"function\";\n id: keyof FunctionColumns;\n }\n | {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n };\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object type of the object\n */\n objectType: Q;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n filterable?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n orderable?: boolean;\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called when the visible columns change.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The new list of column visibility states\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n */\n\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n className?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import classNames from "classnames";
|
|
18
|
-
import React, { useCallback, useRef } from "react";
|
|
18
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
19
|
+
import { LoadingStateTable } from "./LoadingStateTable.js";
|
|
20
|
+
import { NonIdealState } from "./NonIdealState.js";
|
|
19
21
|
import styles from "./Table.module.css";
|
|
20
22
|
import { TableBody } from "./TableBody.js";
|
|
21
23
|
import { TableHeader } from "./TableHeader.js";
|
|
@@ -26,47 +28,66 @@ export function BaseTable({
|
|
|
26
28
|
onRowClick,
|
|
27
29
|
rowHeight,
|
|
28
30
|
renderCellContextMenu,
|
|
29
|
-
className
|
|
31
|
+
className,
|
|
32
|
+
error
|
|
30
33
|
}) {
|
|
31
34
|
const tableContainerRef = useRef(null);
|
|
35
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
32
36
|
|
|
33
37
|
// Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight
|
|
34
38
|
const fetchingRef = useRef(false);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!isLoading || fetchNextPage == null) {
|
|
41
|
+
setIsLoadingMore(false);
|
|
42
|
+
}
|
|
43
|
+
}, [isLoading, fetchNextPage]);
|
|
35
44
|
const fetchMoreOnEndReached = useCallback(async containerRefElement => {
|
|
36
|
-
if (containerRefElement && !fetchingRef.current) {
|
|
45
|
+
if (containerRefElement && !fetchingRef.current && !isLoadingMore) {
|
|
37
46
|
const {
|
|
38
47
|
scrollHeight,
|
|
39
48
|
scrollTop,
|
|
40
49
|
clientHeight
|
|
41
50
|
} = containerRefElement;
|
|
42
|
-
if (scrollHeight - scrollTop - clientHeight < 100 && !isLoading) {
|
|
51
|
+
if (scrollHeight - scrollTop - clientHeight < 100 && !isLoading && fetchNextPage != null) {
|
|
43
52
|
fetchingRef.current = true;
|
|
53
|
+
setIsLoadingMore(true);
|
|
44
54
|
try {
|
|
45
|
-
await fetchNextPage
|
|
55
|
+
await fetchNextPage();
|
|
46
56
|
} finally {
|
|
47
57
|
fetchingRef.current = false;
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
|
-
}, [fetchNextPage, isLoading]);
|
|
61
|
+
}, [fetchNextPage, isLoading, isLoadingMore]);
|
|
52
62
|
const handleScroll = useCallback(async e => {
|
|
53
63
|
await fetchMoreOnEndReached(e.currentTarget);
|
|
54
64
|
}, [fetchMoreOnEndReached]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
const rows = table.getRowModel().rows;
|
|
66
|
+
const headerGroups = table.getHeaderGroups();
|
|
67
|
+
const hasData = rows.length > 0;
|
|
58
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
69
|
ref: tableContainerRef,
|
|
60
70
|
className: classNames(styles.osdkTableContainer, className),
|
|
61
71
|
onScroll: handleScroll
|
|
62
|
-
}, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement(
|
|
72
|
+
}, /*#__PURE__*/React.createElement("table", null, isLoading && !hasData ? /*#__PURE__*/React.createElement(LoadingStateTable, {
|
|
73
|
+
table: table,
|
|
74
|
+
headerGroups: headerGroups,
|
|
75
|
+
rowHeight: rowHeight,
|
|
76
|
+
tableContainerRef: tableContainerRef
|
|
77
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableHeader, {
|
|
63
78
|
table: table
|
|
64
|
-
}), /*#__PURE__*/React.createElement(
|
|
65
|
-
|
|
79
|
+
}), !hasData && error == null ? /*#__PURE__*/React.createElement(NonIdealState, {
|
|
80
|
+
message: "No Data"
|
|
81
|
+
}) : /*#__PURE__*/React.createElement(TableBody, {
|
|
82
|
+
rows: rows,
|
|
66
83
|
tableContainerRef: tableContainerRef,
|
|
67
84
|
onRowClick: onRowClick,
|
|
68
85
|
rowHeight: rowHeight,
|
|
69
|
-
renderCellContextMenu: renderCellContextMenu
|
|
86
|
+
renderCellContextMenu: renderCellContextMenu,
|
|
87
|
+
isLoadingMore: isLoadingMore,
|
|
88
|
+
headerGroups: headerGroups
|
|
89
|
+
})), error != null && /*#__PURE__*/React.createElement(NonIdealState, {
|
|
90
|
+
message: `Error Loading Data: ${error.message}`
|
|
70
91
|
})));
|
|
71
92
|
}
|
|
72
93
|
//# sourceMappingURL=Table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","names":["classNames","React","useCallback","useRef","styles","TableBody","TableHeader","BaseTable","table","isLoading","fetchNextPage","onRowClick","rowHeight","renderCellContextMenu","className","tableContainerRef","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","createElement","ref","osdkTableContainer","onScroll","
|
|
1
|
+
{"version":3,"file":"Table.js","names":["classNames","React","useCallback","useEffect","useRef","useState","LoadingStateTable","NonIdealState","styles","TableBody","TableHeader","BaseTable","table","isLoading","fetchNextPage","onRowClick","rowHeight","renderCellContextMenu","className","error","tableContainerRef","isLoadingMore","setIsLoadingMore","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","rows","getRowModel","headerGroups","getHeaderGroups","hasData","length","createElement","ref","osdkTableContainer","onScroll","Fragment","message"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData, Table } from \"@tanstack/react-table\";\nimport classNames from \"classnames\";\nimport React, {\n type ReactElement,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { LoadingStateTable } from \"./LoadingStateTable.js\";\nimport { NonIdealState } from \"./NonIdealState.js\";\nimport styles from \"./Table.module.css\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableHeader } from \"./TableHeader.js\";\n\nexport interface BaseTableProps<TData extends RowData> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n className?: string;\n error?: Error;\n}\n\nexport function BaseTable<TData extends RowData>(\n {\n table,\n isLoading,\n fetchNextPage,\n onRowClick,\n rowHeight,\n renderCellContextMenu,\n className,\n error,\n }: BaseTableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n useEffect(() => {\n if (!isLoading || fetchNextPage == null) {\n setIsLoadingMore(false);\n }\n }, [isLoading, fetchNextPage]);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current && !isLoadingMore) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading && fetchNextPage != null\n ) {\n fetchingRef.current = true;\n setIsLoadingMore(true);\n try {\n await fetchNextPage();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading, isLoadingMore],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n const rows = table.getRowModel().rows;\n const headerGroups = table.getHeaderGroups();\n const hasData = rows.length > 0;\n\n return (\n <div\n ref={tableContainerRef}\n className={classNames(styles.osdkTableContainer, className)}\n onScroll={handleScroll}\n >\n <table>\n {isLoading && !hasData\n ? (\n <LoadingStateTable\n table={table}\n headerGroups={headerGroups}\n rowHeight={rowHeight}\n tableContainerRef={tableContainerRef}\n />\n )\n : (\n <>\n <TableHeader table={table} />\n {!hasData && error == null\n ? <NonIdealState message={\"No Data\"} />\n : (\n <TableBody\n rows={rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n renderCellContextMenu={renderCellContextMenu}\n isLoadingMore={isLoadingMore}\n headerGroups={headerGroups}\n />\n )}\n </>\n )}\n {error != null && (\n <NonIdealState message={`Error Loading Data: ${error.message}`} />\n )}\n </table>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAEVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAOC,MAAM,MAAM,oBAAoB;AACvC,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAgB9C,OAAO,SAASC,SAASA,CACvB;EACEC,KAAK;EACLC,SAAS;EACTC,aAAa;EACbC,UAAU;EACVC,SAAS;EACTC,qBAAqB;EACrBC,SAAS;EACTC;AACqB,CAAC,EACV;EACd,MAAMC,iBAAiB,GAAGhB,MAAM,CAAiB,IAAI,CAAC;EACtD,MAAM,CAACiB,aAAa,EAAEC,gBAAgB,CAAC,GAAGjB,QAAQ,CAAC,KAAK,CAAC;;EAEzD;EACA,MAAMkB,WAAW,GAAGnB,MAAM,CAAC,KAAK,CAAC;EAEjCD,SAAS,CAAC,MAAM;IACd,IAAI,CAACU,SAAS,IAAIC,aAAa,IAA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AA,gBACG1B,SAAS,IAAI,CAACwB,OAAO,gBAElBpC,KAAA,CAAAsC,aAAA,CAACjC,iBAAiB;IAChBM,KAAK,EAAEA,KAAM;IACbuB,YAAY,EAAEA,YAAa;IAC3BnB,SAAS,EAAEA,SAAU;IACrBI,iBAAiB,EAAEA;EAAkB,CACtC,CAAC,gBAGFnB,KAAA,CAAAsC,aAAA,CAAAtC,KAAA,CAAA0C,QAAA,qBACE1C,KAAA,CAAAsC,aAAA,CAAC7B,WAAW;IAACE,KAAK,EAAEA;EAAM,CAAE,CAAC,EAC5B,CAACyB,OAAO,IAAIlB,KAAK,IAAI,IAAI,gBACtBlB,KAAA,CAAAsC,aAAA,CAAChC,aAAa;IAACqC,OAAO,EAAE;EAAU,CAAE,CAAC,gBAErC3C,KAAA,CAAAsC,aAAA,CAAC9B,SAAS;IACRwB,IAAI,EAAEA,IAAK;IACXb,iBAAiB,EAAEA,iBAAkB;IACrCL,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,qBAAqB,EAAEA,qBAAsB;IAC7CI,aAAa,EAAEA,aAAc;IAC7Bc,YAAY,EAAEA;EAAa,CAC5B,CAEL,CACH,EACFhB,KAAK,IAAI,IAAI,iBACZlB,KAAA,CAAAsC,aAAA,CAAChC,aAAa;IAACqC,OAAO,EAAE,uBAAuBzB,KAAK,CAACyB,OAAO;EAAG,CAAE,CAE9D,CACJ,CAAC;AAEV","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
18
18
|
import React, { useLayoutEffect } from "react";
|
|
19
|
+
import { LoadingRow } from "./LoadingRow.js";
|
|
19
20
|
import styles from "./TableBody.module.css";
|
|
20
21
|
import { TableRow } from "./TableRow.js";
|
|
21
22
|
export function TableBody({
|
|
@@ -23,7 +24,9 @@ export function TableBody({
|
|
|
23
24
|
tableContainerRef,
|
|
24
25
|
onRowClick,
|
|
25
26
|
renderCellContextMenu,
|
|
26
|
-
rowHeight = 40
|
|
27
|
+
rowHeight = 40,
|
|
28
|
+
isLoadingMore = false,
|
|
29
|
+
headerGroups = []
|
|
27
30
|
}) {
|
|
28
31
|
// Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.
|
|
29
32
|
const rowVirtualizer = useVirtualizer({
|
|
@@ -37,10 +40,13 @@ export function TableBody({
|
|
|
37
40
|
useLayoutEffect(() => {
|
|
38
41
|
rowVirtualizer.measure();
|
|
39
42
|
}, [rowVirtualizer, rows.length]);
|
|
43
|
+
const totalSize = rowVirtualizer.getTotalSize();
|
|
44
|
+
const bodyHeight = isLoadingMore ? totalSize + rowHeight : totalSize;
|
|
45
|
+
const headers = headerGroups[0]?.headers ?? [];
|
|
40
46
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
41
47
|
className: styles.osdkTableBody,
|
|
42
48
|
style: {
|
|
43
|
-
height: `${
|
|
49
|
+
height: `${bodyHeight}px`
|
|
44
50
|
}
|
|
45
51
|
}, rowVirtualizer.getVirtualItems().map(virtualRow => {
|
|
46
52
|
const row = rows[virtualRow.index];
|
|
@@ -51,6 +57,11 @@ export function TableBody({
|
|
|
51
57
|
onRowClick: onRowClick,
|
|
52
58
|
renderCellContextMenu: renderCellContextMenu
|
|
53
59
|
});
|
|
60
|
+
}), isLoadingMore && /*#__PURE__*/React.createElement(LoadingRow, {
|
|
61
|
+
headers: headers,
|
|
62
|
+
translateY: totalSize,
|
|
63
|
+
rowHeight: rowHeight,
|
|
64
|
+
columnCount: headers.length
|
|
54
65
|
}));
|
|
55
66
|
}
|
|
56
67
|
//# sourceMappingURL=TableBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableBody.js","names":["useVirtualizer","React","useLayoutEffect","styles","TableRow","TableBody","rows","tableContainerRef","onRowClick","renderCellContextMenu","rowHeight","rowVirtualizer","count","length","estimateSize","getScrollElement","current","overscan","measure","createElement","className","osdkTableBody","style","height","
|
|
1
|
+
{"version":3,"file":"TableBody.js","names":["useVirtualizer","React","useLayoutEffect","LoadingRow","styles","TableRow","TableBody","rows","tableContainerRef","onRowClick","renderCellContextMenu","rowHeight","isLoadingMore","headerGroups","rowVirtualizer","count","length","estimateSize","getScrollElement","current","overscan","measure","totalSize","getTotalSize","bodyHeight","headers","createElement","className","osdkTableBody","style","height","getVirtualItems","map","virtualRow","row","index","key","id","translateY","columnCount"],"sources":["TableBody.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, HeaderGroup, Row, RowData } from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useLayoutEffect } from \"react\";\nimport { LoadingRow } from \"./LoadingRow.js\";\nimport styles from \"./TableBody.module.css\";\nimport { TableRow } from \"./TableRow.js\";\n\ninterface TableBodyProps<TData extends RowData> {\n rows: Array<Row<TData>>;\n tableContainerRef: React.RefObject<HTMLDivElement>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n isLoadingMore?: boolean;\n headerGroups?: Array<HeaderGroup<TData>>;\n}\n\nexport function TableBody<TData extends RowData>({\n rows,\n tableContainerRef,\n onRowClick,\n renderCellContextMenu,\n rowHeight = 40,\n isLoadingMore = false,\n headerGroups = [],\n}: TableBodyProps<TData>): React.ReactElement {\n // Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.\n const rowVirtualizer = useVirtualizer<HTMLDivElement, HTMLTableRowElement>({\n count: rows.length,\n estimateSize: () => rowHeight,\n getScrollElement: () => tableContainerRef.current,\n overscan: 5,\n });\n\n // Measure the virtualizer after the DOM has been laid out to ensure proper dimensions\n useLayoutEffect(() => {\n rowVirtualizer.measure();\n }, [rowVirtualizer, rows.length]);\n\n const totalSize = rowVirtualizer.getTotalSize();\n const bodyHeight = isLoadingMore\n ? totalSize + rowHeight\n : totalSize;\n\n const headers = headerGroups[0]?.headers ?? [];\n\n return (\n <tbody\n className={styles.osdkTableBody}\n style={{\n height: `${bodyHeight}px`,\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n\n return (\n <TableRow\n key={row.id}\n row={row}\n virtualRow={virtualRow}\n onRowClick={onRowClick}\n renderCellContextMenu={renderCellContextMenu}\n />\n );\n })}\n {isLoadingMore && (\n <LoadingRow\n headers={headers}\n translateY={totalSize}\n rowHeight={rowHeight}\n columnCount={headers.length}\n />\n )}\n </tbody>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,yBAAyB;AACxD,OAAOC,KAAK,IAAIC,eAAe,QAAQ,OAAO;AAC9C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAOC,MAAM,MAAM,wBAAwB;AAC3C,SAASC,QAAQ,QAAQ,eAAe;AAexC,OAAO,SAASC,SAASA,CAAwB;EAC/CC,IAAI;EACJC,iBAAiB;EACjBC,UAAU;EACVC,qBAAqB;EACrBC,SAAS,GAAG,EAAE;EACdC,aAAa,GAAG,KAAK;EACrBC,YAAY,GAAG;AACM,CAAC,EAAsB;EAC5C;EACA,MAAMC,cAAc,GAAGd,cAAc,CAAsC;IACzEe,KAAK,EAAER,IAAI,CAACS,MAAM;IAClBC,YAAY,EAAEA,CAAA,KAAMN,SAAS;IAC7BO,gBAAgB,EAAEA,CAAA,KAAMV,iBAAiB,CAACW,OAAO;IACjDC,QAAQ,EAAE;EACZ,CAAC,CAAC;;EAEF;EACAlB,eAAe,CAAC,MAAM;IACpBY,cAAc,CAACO,OAAO,CAAC,CAAC;EAC1B,CAAC,EAAE,CAACP,cAAc,EAAEP,IAAI,CAACS,MAAM,CAAC,CAAC;EAEjC,MAAMM,SAAS,GAAGR,cAAc,CAACS,YAAY,CAAC,CAAC;EAC/C,MAAMC,UAAU,GAAGZ,aAAa,GAC5BU,SAAS,GAAGX,SAAS,GACrBW,SAAS;EAEb,MAAMG,OAAO,GAAGZ,YAAY,CAAC,CAAC,CAAC,EAAEY,OAAO,IAAI,EAAE;EAE9C,oBACExB,KAAA,CAAAyB,aAAA;IACEC,SAAS,EAAEvB,MAAM,CAACwB,aAAc;IAChCC,KAAK,EAAE;MACLC,MAAM,EAAE,GAAGN,UAAU;IACvB;EAAE,GAEDV,cAAc,CAACiB,eAAe,CAAC,CAAC,CAACC,GAAG,CAAEC,UAAU,IAAK;IACpD,MAAMC,GAAG,GAAG3B,IAAI,CAAC0B,UAAU,CAACE,KAAK,CAAC;IAElC,oBACElC,KAAA,CAAAyB,aAAA,CAACrB,QAAQ;MACP+B,GAAG,EAAEF,GAAG,CAACG,EAAG;MACZH,GAAG,EAAEA,GAAI;MACTD,UAAU,EAAEA,UAAW;MACvBxB,UAAU,EAAEA,UAAW;MACvBC,qBAAqB,EAAEA;IAAsB,CAC9C,CAAC;EAEN,CAAC,CAAC,EACDE,aAAa,iBACZX,KAAA,CAAAyB,aAAA,CAACvB,UAAU;IACTsB,OAAO,EAAEA,OAAQ;IACjBa,UAAU,EAAEhB,SAAU;IACtBX,SAAS,EAAEA,SAAU;IACrB4B,WAAW,EAAEd,OAAO,CAACT;EAAO,CAC7B,CAEE,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.js","names":["flexRender","React","useRef","CellContextMenu","useCellContextMenu","styles","SELECTION_COLUMN_ID","getColumnPinningStyles","TableCell","cell","renderCellContextMenu","tdRef","isSelectColumn","column","id","isContextMenuOpen","handleOpenContextMenu","handleCloseContextMenu","popoverPosition","columnStyles","createElement","Fragment","ref","getIsPinned","className","osdkTableCell","style","onContextMenu","osdkTableCellContent","columnDef","getContext","position","onClose","renderContent"],"sources":["TableCell.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData } from \"@tanstack/react-table\";\nimport { flexRender } from \"@tanstack/react-table\";\nimport type { ReactNode } from \"react\";\nimport React, { useRef } from \"react\";\nimport { CellContextMenu } from \"./CellContextMenu.js\";\nimport { useCellContextMenu } from \"./hooks/useCellContextMenu.js\";\nimport styles from \"./TableCell.module.css\";\nimport { SELECTION_COLUMN_ID } from \"./utils/constants.js\";\nimport { getColumnPinningStyles } from \"./utils/getColumnPinningStyles.js\";\n\ninterface TableCellProps<TData extends RowData> {\n cell: Cell<TData, unknown>;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n}\n\nexport function TableCell<TData extends RowData>(\n { cell, renderCellContextMenu }: TableCellProps<TData>,\n): React.ReactElement {\n const tdRef = useRef<HTMLTableCellElement>(null);\n const isSelectColumn = cell.column.id === SELECTION_COLUMN_ID;\n\n const {\n isContextMenuOpen,\n handleOpenContextMenu,\n handleCloseContextMenu,\n popoverPosition,\n } = useCellContextMenu({\n tdRef,\n });\n\n const shouldRenderContextMenu = !isSelectColumn && isContextMenuOpen\n && !!popoverPosition\n && !!renderCellContextMenu;\n\n const { columnStyles } = getColumnPinningStyles(cell.column);\n\n return (\n <>\n <td\n ref={tdRef}\n data-pinned={cell.column.getIsPinned()}\n className={styles.osdkTableCell}\n style={columnStyles}\n onContextMenu={handleOpenContextMenu}\n >\n <div className={styles.osdkTableCellContent}>\n {flexRender(cell.column.columnDef.cell
|
|
1
|
+
{"version":3,"file":"TableCell.js","names":["flexRender","React","useRef","CellContextMenu","useCellContextMenu","styles","SELECTION_COLUMN_ID","getColumnPinningStyles","TableCell","cell","renderCellContextMenu","tdRef","isSelectColumn","column","id","isContextMenuOpen","handleOpenContextMenu","handleCloseContextMenu","popoverPosition","columnStyles","createElement","Fragment","ref","getIsPinned","className","osdkTableCell","style","onContextMenu","osdkTableCellContent","columnDef","getContext","position","onClose","renderContent"],"sources":["TableCell.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData } from \"@tanstack/react-table\";\nimport { flexRender } from \"@tanstack/react-table\";\nimport type { ReactNode } from \"react\";\nimport React, { useRef } from \"react\";\nimport { CellContextMenu } from \"./CellContextMenu.js\";\nimport { useCellContextMenu } from \"./hooks/useCellContextMenu.js\";\nimport styles from \"./TableCell.module.css\";\nimport { SELECTION_COLUMN_ID } from \"./utils/constants.js\";\nimport { getColumnPinningStyles } from \"./utils/getColumnPinningStyles.js\";\n\ninterface TableCellProps<TData extends RowData> {\n cell: Cell<TData, unknown>;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n}\n\nexport function TableCell<TData extends RowData>(\n { cell, renderCellContextMenu }: TableCellProps<TData>,\n): React.ReactElement {\n const tdRef = useRef<HTMLTableCellElement>(null);\n const isSelectColumn = cell.column.id === SELECTION_COLUMN_ID;\n\n const {\n isContextMenuOpen,\n handleOpenContextMenu,\n handleCloseContextMenu,\n popoverPosition,\n } = useCellContextMenu({\n tdRef,\n });\n\n const shouldRenderContextMenu = !isSelectColumn && isContextMenuOpen\n && !!popoverPosition\n && !!renderCellContextMenu;\n\n const { columnStyles } = getColumnPinningStyles(cell.column);\n\n return (\n <>\n <td\n ref={tdRef}\n data-pinned={cell.column.getIsPinned()}\n className={styles.osdkTableCell}\n style={columnStyles}\n onContextMenu={handleOpenContextMenu}\n >\n <div className={styles.osdkTableCellContent}>\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n ) as ReactNode}\n </div>\n </td>\n {shouldRenderContextMenu\n && (\n <CellContextMenu\n cell={cell}\n position={popoverPosition}\n onClose={handleCloseContextMenu}\n renderContent={renderCellContextMenu}\n />\n )}\n </>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,uBAAuB;AAElD,OAAOC,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,OAAOC,MAAM,MAAM,wBAAwB;AAC3C,SAASC,mBAAmB,QAAQ,sBAAsB;AAC1D,SAASC,sBAAsB,QAAQ,mCAAmC;AAU1E,OAAO,SAASC,SAASA,CACvB;EAAEC,IAAI;EAAEC;AAA6C,CAAC,EAClC;EACpB,MAAMC,KAAK,GAAGT,MAAM,CAAuB,IAAI,CAAC;EAChD,MAAMU,cAAc,GAAGH,IAAI,CAACI,MAAM,CAACC,EAAE,KAAKR,mBAAmB;EAE7D,MAAM;IACJS,iBAAiB;IACjBC,qBAAqB;IACrBC,sBAAsB;IACtBC;EACF,CAAC,GAAGd,kBAAkB,CAAC;IACrBO;EACF,CAAC,CAAC;EAMF,MAAM;IAAEQ;EAAa,CAAC,GAAGZ,sBAAsB,CAACE,IAAI,CAACI,MAAM,CAAC;EAE5D,oBACEZ,KAAA,CAAAmB,aAAA,CAAAnB,KAAA,CAAAoB,QAAA,qBACEpB,KAAA,CAAAmB,aAAA;IACEE,GAAG,EAAEX,KAAM;IACX,eAAaF,IAAI,CAACI,MAAM,CAACU,WAAW,CAAC,CAAE;IACvCC,SAAS,EAAEnB,MAAM,CAACoB,aAAc;IAChCC,KAAK,EAAEP,YAAa;IACpBQ,aAAa,EAAEX;EAAsB,gBAErCf,KAAA,CAAAmB,aAAA;IAAKI,SAAS,EAAEnB,MAAM,CAACuB;EAAqB,GACzC5B,UAAU,CACTS,IAAI,CAACI,MAAM,CAACgB,SAAS,CAACpB,IAAI,EAC1BA,IAAI,CAACqB,UAAU,CAAC,CAClB,CACG,CACH,CAAC,EArBuB,CAAClB,cAAc,IAAIG,iBAAiB,IAC/D,CAAC,CAACG,eAAe,IACjB,CAAC,CAACR,qBAAqB,iBAsBpBT,KAAA,CAAAmB,aAAA,CAACjB,eAAe;IACdM,IAAI,EAAEA,IAAK;IACXsB,QAAQ,EAAEb,eAAgB;IAC1Bc,OAAO,EAAEf,sBAAuB;IAChCgB,aAAa,EAAEvB;EAAsB,CACtC,CAEL,CAAC;AAEP","ignoreList":[]}
|
|
@@ -34,25 +34,24 @@
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.osdkTableCell:has([role="checkbox"]) {
|
|
38
|
-
justify-content: center;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
37
|
.osdkTableCell[data-pinned="left"],
|
|
43
38
|
.osdkTableCell[data-pinned="right"] {
|
|
44
39
|
position: sticky;
|
|
45
|
-
z-index: var(--
|
|
40
|
+
z-index: var(--osdk-surface-z-index-1);
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
/* Last left-pinned column - no left-pinned siblings after it */
|
|
49
44
|
.osdkTableCell[data-pinned="left"]:not(:has(~ [data-pinned="left"])) {
|
|
50
|
-
border-right:
|
|
45
|
+
border-right: var(--osdk-table-pinned-column-border);
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
/* First right-pinned column - no right-pinned siblings before it */
|
|
54
49
|
.osdkTableCell[data-pinned="right"]:not(:has(~ [data-pinned="right"]):nth-child(n+2)) {
|
|
55
|
-
border-left:
|
|
50
|
+
border-left: var(--osdk-table-pinned-column-border);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.osdkTableCell:has([role="checkbox"]) {
|
|
54
|
+
justify-content: center;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
.osdkTableCellContent:not(:has([role="checkbox"])) {
|