@osdk/react-components 0.2.0-beta.1 → 0.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +21 -5
- package/build/browser/base-components/checkbox/Checkbox.js +27 -32
- package/build/browser/base-components/checkbox/Checkbox.module.css +79 -0
- package/build/browser/base-components/checkbox/Checkbox.module.css.js +7 -0
- package/build/browser/object-table/CellContextMenu.js +23 -20
- package/build/browser/object-table/CellContextMenu.module.css +20 -0
- package/build/browser/object-table/CellContextMenu.module.css.js +6 -0
- package/build/browser/object-table/LoadingCell.js +24 -29
- package/build/browser/object-table/LoadingCell.module.css +48 -0
- package/build/browser/object-table/LoadingCell.module.css.js +8 -0
- package/build/browser/object-table/LoadingRow.js +24 -50
- package/build/browser/object-table/LoadingStateTable.js +46 -340
- package/build/browser/object-table/NonIdealState.js +23 -20
- package/build/browser/object-table/NonIdealState.module.css +28 -0
- package/build/browser/object-table/NonIdealState.module.css.js +7 -0
- package/build/browser/object-table/Table.js +51 -933
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/Table.module.css +22 -0
- package/build/browser/object-table/Table.module.css.js +6 -0
- package/build/browser/object-table/TableBody.js +36 -260
- package/build/browser/object-table/TableBody.module.css +20 -0
- package/build/browser/object-table/TableBody.module.css.js +6 -0
- package/build/browser/object-table/TableCell.js +31 -111
- package/build/browser/object-table/TableCell.module.css +62 -0
- package/build/browser/object-table/TableCell.module.css.js +7 -0
- package/build/browser/object-table/TableHeader.js +38 -215
- package/build/browser/object-table/TableHeader.module.css +101 -0
- package/build/browser/object-table/TableHeader.module.css.js +10 -0
- package/build/browser/object-table/TableHeaderContent.js +21 -18
- package/build/browser/object-table/TableHeaderContent.module.css +30 -0
- package/build/browser/object-table/TableHeaderContent.module.css.js +6 -0
- package/build/browser/object-table/TableHeaderWithPopover.js +66 -80
- package/build/browser/object-table/TableHeaderWithPopover.module.css +110 -0
- package/build/browser/object-table/TableHeaderWithPopover.module.css.js +15 -0
- package/build/browser/object-table/TableRow.js +26 -144
- package/build/browser/object-table/TableRow.module.css +60 -0
- package/build/browser/object-table/TableRow.module.css.js +6 -0
- package/build/browser/styles.css +615 -0
- package/build/cjs/public/experimental.cjs +5 -5
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/esm/object-table/Table.js +5 -5
- package/build/esm/object-table/Table.js.map +1 -1
- package/package.json +9 -6
|
@@ -1 +1 @@
|
|
|
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
|
|
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 <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 </table>\n {!hasData && error == null && <NonIdealState message={\"No Data\"} />}\n {error != null && (\n <NonIdealState message={`Error Loading Data: ${error.message}`} />\n )}\n </div>\n );\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
.osdkTableContainer {
|
|
18
|
+
position: relative; /* needed for sticky header */
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
}
|
|
@@ -1,250 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var css2 = '/*\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\n.osdkTableCell {\n display: flex;\n align-items: center;\n text-align: left;\n position: relative;\n padding: var(--osdk-table-cell-padding);\n font-size: var(--osdk-table-cell-fontSize);\n color: var(--osdk-table-cell-color);\n background-color: inherit;\n border-right: var(--osdk-table-cell-divider);\n\n &:first-child {\n border-left: var(--osdk-table-border);\n }\n\n &:last-child {\n border-right: var(--osdk-table-border);\n }\n}\n\n.osdkTableCell[data-pinned="left"],\n.osdkTableCell[data-pinned="right"] {\n position: sticky;\n z-index: var(--osdk-surface-z-index-1);\n}\n\n/* Last left-pinned column - no left-pinned siblings after it */\n.osdkTableCell[data-pinned="left"]:not(:has(~ [data-pinned="left"])) {\n border-right: var(--osdk-table-pinned-column-border);\n}\n\n/* First right-pinned column - no right-pinned siblings before it */\n.osdkTableCell[data-pinned="right"]:not(:has(~ [data-pinned="right"]):nth-child(n+2)) {\n border-left: var(--osdk-table-pinned-column-border);\n}\n\n.osdkTableCell:has([role="checkbox"]) {\n justify-content: center;\n}\n\n.osdkTableCellContent:not(:has([role="checkbox"])) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: left;\n}\n';
|
|
17
|
-
if (typeof document !== "undefined") {
|
|
18
|
-
const style = document.createElement("style");
|
|
19
|
-
style.textContent = css2;
|
|
20
|
-
document.head.appendChild(style);
|
|
21
|
-
}
|
|
22
|
-
var TableCell_default = { "osdkTableCell": "osdkTableCell", "osdkTableCellContent": "osdkTableCellContent" };
|
|
23
|
-
function LoadingCell({
|
|
24
|
-
width
|
|
25
|
-
}) {
|
|
26
|
-
return /* @__PURE__ */ React.createElement("td", {
|
|
27
|
-
className: TableCell_default.osdkTableCell,
|
|
28
|
-
style: {
|
|
29
|
-
width
|
|
30
|
-
}
|
|
31
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
32
|
-
className: classNames(LoadingCell_default.osdkLoadingCell, LoadingCell_default.osdkCellSkeleton)
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
var css3 = '/*\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\n.osdkTableRow {\n position: absolute;\n display: flex;\n background-color: var(--osdk-table-row-bg-default);\n border-top: var(--osdk-table-row-divider);\n border-bottom: var(--osdk-table-border-width) solid transparent;\n\n &:last-child {\n border-bottom: var(--osdk-table-border);\n }\n\n /* Zebra rows */\n &:nth-child(even) {\n background-color: var(\n --osdk-table-row-bg-alternate,\n var(--osdk-table-row-bg-default)\n );\n }\n\n &:hover {\n z-index: 1;\n background-color: var(\n --osdk-table-row-bg-hover,\n var(--osdk-surface-background-color-default-hover)\n );\n border-top-color: var(--osdk-table-row-border-color-hover);\n border-bottom-color: var(--osdk-table-row-border-color-hover);\n }\n\n &[data-selected="true"] {\n z-index: 2;\n background-color: var(--osdk-table-row-bg-active);\n border-top-color: var(--osdk-table-row-border-color-active);\n border-bottom-color: var(--osdk-table-row-border-color-active);\n }\n\n &[data-selected="true"] + &[data-selected="true"] {\n border-top-color: transparent;\n }\n\n &[data-selected="true"]:has(+ &[data-selected="true"]) {\n border-bottom-color: transparent;\n }\n}\n';
|
|
36
|
-
if (typeof document !== "undefined") {
|
|
37
|
-
const style = document.createElement("style");
|
|
38
|
-
style.textContent = css3;
|
|
39
|
-
document.head.appendChild(style);
|
|
40
|
-
}
|
|
41
|
-
var TableRow_default = { "osdkTableRow": "osdkTableRow" };
|
|
42
|
-
function LoadingRow({
|
|
43
|
-
headers,
|
|
44
|
-
columnCount,
|
|
45
|
-
translateY,
|
|
46
|
-
rowHeight = 40,
|
|
47
|
-
columnWidth = 80
|
|
48
|
-
}) {
|
|
49
|
-
return /* @__PURE__ */ React2.createElement("tr", {
|
|
50
|
-
className: TableRow_default.osdkTableRow,
|
|
51
|
-
style: {
|
|
52
|
-
height: `${rowHeight}px`,
|
|
53
|
-
transform: `translateY(${translateY}px)`
|
|
54
|
-
}
|
|
55
|
-
}, /* @__PURE__ */ React2.createElement(React2.Fragment, null, Array.from({
|
|
56
|
-
length: columnCount
|
|
57
|
-
}).map((_, index) => {
|
|
58
|
-
const width = headers.length > index ? headers[index].getSize() : columnWidth;
|
|
59
|
-
return /* @__PURE__ */ React2.createElement(LoadingCell, {
|
|
60
|
-
key: `loading-cell-${index}`,
|
|
61
|
-
width
|
|
62
|
-
});
|
|
63
|
-
})));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// build/browser/object-table/TableBody.module.css
|
|
67
|
-
var css4 = '/*\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\n.osdkTableBody {\n display: grid;\n position: relative;\n}\n';
|
|
68
|
-
if (typeof document !== "undefined") {
|
|
69
|
-
const style = document.createElement("style");
|
|
70
|
-
style.textContent = css4;
|
|
71
|
-
document.head.appendChild(style);
|
|
72
|
-
}
|
|
73
|
-
var TableBody_default = { "osdkTableBody": "osdkTableBody" };
|
|
74
|
-
|
|
75
|
-
// build/browser/object-table/TableRow.js
|
|
76
|
-
import React5, { useCallback as useCallback2 } from "react";
|
|
77
|
-
|
|
78
|
-
// build/browser/object-table/TableCell.js
|
|
79
|
-
import { flexRender } from "@tanstack/react-table";
|
|
80
|
-
import React4, { useRef as useRef2 } from "react";
|
|
81
|
-
|
|
82
|
-
// build/browser/object-table/CellContextMenu.js
|
|
83
|
-
import React3, { useEffect, useRef } from "react";
|
|
84
|
-
import { createPortal } from "react-dom";
|
|
85
|
-
var css5 = '/*\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\n.osdkCellContextMenu {\n position: fixed;\n z-index: var(--osdk-surface-z-index-2);\n}\n';
|
|
86
|
-
if (typeof document !== "undefined") {
|
|
87
|
-
const style = document.createElement("style");
|
|
88
|
-
style.textContent = css5;
|
|
89
|
-
document.head.appendChild(style);
|
|
90
|
-
}
|
|
91
|
-
var CellContextMenu_default = { "osdkCellContextMenu": "osdkCellContextMenu" };
|
|
92
|
-
function CellContextMenu({
|
|
93
|
-
cell,
|
|
94
|
-
position,
|
|
95
|
-
onClose,
|
|
96
|
-
renderContent
|
|
97
|
-
}) {
|
|
98
|
-
const ref = useRef(null);
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
const handleClickOutside = (event) => {
|
|
101
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
102
|
-
onClose();
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
106
|
-
return () => {
|
|
107
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
108
|
-
};
|
|
109
|
-
}, [onClose]);
|
|
110
|
-
return /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement("div", {
|
|
111
|
-
ref,
|
|
112
|
-
className: CellContextMenu_default.osdkCellContextMenu,
|
|
113
|
-
style: {
|
|
114
|
-
left: position.left,
|
|
115
|
-
top: position.top,
|
|
116
|
-
minWidth: position.width
|
|
117
|
-
}
|
|
118
|
-
}, renderContent(cell.row.original, cell)), document.body);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// build/browser/object-table/hooks/useCellContextMenu.js
|
|
122
|
-
import { useCallback, useState } from "react";
|
|
123
|
-
var useCellContextMenu = ({
|
|
124
|
-
tdRef
|
|
125
|
-
}) => {
|
|
126
|
-
const [popoverPosition, setPopoverPosition] = useState(null);
|
|
127
|
-
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
|
128
|
-
const handleOpenContextMenu = useCallback((event) => {
|
|
129
|
-
event.preventDefault();
|
|
130
|
-
event.stopPropagation();
|
|
131
|
-
if (tdRef.current) {
|
|
132
|
-
const rect = tdRef.current.getBoundingClientRect();
|
|
133
|
-
const position = {
|
|
134
|
-
left: rect.left,
|
|
135
|
-
top: rect.bottom,
|
|
136
|
-
width: rect.width
|
|
137
|
-
};
|
|
138
|
-
setPopoverPosition(position);
|
|
139
|
-
setIsContextMenuOpen(true);
|
|
140
|
-
}
|
|
141
|
-
}, [tdRef]);
|
|
142
|
-
const handleCloseContextMenu = useCallback(() => {
|
|
143
|
-
setIsContextMenuOpen(false);
|
|
144
|
-
setPopoverPosition(null);
|
|
145
|
-
}, []);
|
|
146
|
-
return {
|
|
147
|
-
isContextMenuOpen,
|
|
148
|
-
handleOpenContextMenu,
|
|
149
|
-
handleCloseContextMenu,
|
|
150
|
-
popoverPosition
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// build/browser/object-table/TableCell.module.css
|
|
155
|
-
var css6 = '/*\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\n.osdkTableCell {\n display: flex;\n align-items: center;\n text-align: left;\n position: relative;\n padding: var(--osdk-table-cell-padding);\n font-size: var(--osdk-table-cell-fontSize);\n color: var(--osdk-table-cell-color);\n background-color: inherit;\n border-right: var(--osdk-table-cell-divider);\n\n &:first-child {\n border-left: var(--osdk-table-border);\n }\n\n &:last-child {\n border-right: var(--osdk-table-border);\n }\n}\n\n.osdkTableCell[data-pinned="left"],\n.osdkTableCell[data-pinned="right"] {\n position: sticky;\n z-index: var(--osdk-surface-z-index-1);\n}\n\n/* Last left-pinned column - no left-pinned siblings after it */\n.osdkTableCell[data-pinned="left"]:not(:has(~ [data-pinned="left"])) {\n border-right: var(--osdk-table-pinned-column-border);\n}\n\n/* First right-pinned column - no right-pinned siblings before it */\n.osdkTableCell[data-pinned="right"]:not(:has(~ [data-pinned="right"]):nth-child(n+2)) {\n border-left: var(--osdk-table-pinned-column-border);\n}\n\n.osdkTableCell:has([role="checkbox"]) {\n justify-content: center;\n}\n\n.osdkTableCellContent:not(:has([role="checkbox"])) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: left;\n}\n';
|
|
156
|
-
if (typeof document !== "undefined") {
|
|
157
|
-
const style = document.createElement("style");
|
|
158
|
-
style.textContent = css6;
|
|
159
|
-
document.head.appendChild(style);
|
|
160
|
-
}
|
|
161
|
-
var TableCell_default2 = { "osdkTableCell": "osdkTableCell", "osdkTableCellContent": "osdkTableCellContent" };
|
|
162
|
-
|
|
163
|
-
// build/browser/object-table/utils/constants.js
|
|
164
|
-
var SELECTION_COLUMN_ID = "__selection__";
|
|
165
|
-
|
|
166
|
-
// build/browser/object-table/utils/getColumnPinningStyles.js
|
|
167
|
-
function getColumnPinningStyles(column) {
|
|
168
|
-
const isPinned = column.getIsPinned();
|
|
169
|
-
return {
|
|
170
|
-
columnStyles: {
|
|
171
|
-
left: isPinned === "left" ? `${column.getStart("left")}px` : void 0,
|
|
172
|
-
right: isPinned === "right" ? `${column.getAfter("right")}px` : void 0,
|
|
173
|
-
width: column.getSize()
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// build/browser/object-table/TableCell.js
|
|
179
|
-
function TableCell({
|
|
180
|
-
cell,
|
|
181
|
-
renderCellContextMenu
|
|
182
|
-
}) {
|
|
183
|
-
const tdRef = useRef2(null);
|
|
184
|
-
const isSelectColumn = cell.column.id === SELECTION_COLUMN_ID;
|
|
185
|
-
const {
|
|
186
|
-
isContextMenuOpen,
|
|
187
|
-
handleOpenContextMenu,
|
|
188
|
-
handleCloseContextMenu,
|
|
189
|
-
popoverPosition
|
|
190
|
-
} = useCellContextMenu({
|
|
191
|
-
tdRef
|
|
192
|
-
});
|
|
193
|
-
const {
|
|
194
|
-
columnStyles
|
|
195
|
-
} = getColumnPinningStyles(cell.column);
|
|
196
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("td", {
|
|
197
|
-
ref: tdRef,
|
|
198
|
-
"data-pinned": cell.column.getIsPinned(),
|
|
199
|
-
className: TableCell_default2.osdkTableCell,
|
|
200
|
-
style: columnStyles,
|
|
201
|
-
onContextMenu: handleOpenContextMenu
|
|
202
|
-
}, /* @__PURE__ */ React4.createElement("div", {
|
|
203
|
-
className: TableCell_default2.osdkTableCellContent
|
|
204
|
-
}, flexRender(cell.column.columnDef.cell, cell.getContext()))), !isSelectColumn && isContextMenuOpen && !!popoverPosition && !!renderCellContextMenu && /* @__PURE__ */ React4.createElement(CellContextMenu, {
|
|
205
|
-
cell,
|
|
206
|
-
position: popoverPosition,
|
|
207
|
-
onClose: handleCloseContextMenu,
|
|
208
|
-
renderContent: renderCellContextMenu
|
|
209
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// build/browser/object-table/TableRow.module.css
|
|
213
|
-
var css7 = '/*\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\n.osdkTableRow {\n position: absolute;\n display: flex;\n background-color: var(--osdk-table-row-bg-default);\n border-top: var(--osdk-table-row-divider);\n border-bottom: var(--osdk-table-border-width) solid transparent;\n\n &:last-child {\n border-bottom: var(--osdk-table-border);\n }\n\n /* Zebra rows */\n &:nth-child(even) {\n background-color: var(\n --osdk-table-row-bg-alternate,\n var(--osdk-table-row-bg-default)\n );\n }\n\n &:hover {\n z-index: 1;\n background-color: var(\n --osdk-table-row-bg-hover,\n var(--osdk-surface-background-color-default-hover)\n );\n border-top-color: var(--osdk-table-row-border-color-hover);\n border-bottom-color: var(--osdk-table-row-border-color-hover);\n }\n\n &[data-selected="true"] {\n z-index: 2;\n background-color: var(--osdk-table-row-bg-active);\n border-top-color: var(--osdk-table-row-border-color-active);\n border-bottom-color: var(--osdk-table-row-border-color-active);\n }\n\n &[data-selected="true"] + &[data-selected="true"] {\n border-top-color: transparent;\n }\n\n &[data-selected="true"]:has(+ &[data-selected="true"]) {\n border-bottom-color: transparent;\n }\n}\n';
|
|
214
|
-
if (typeof document !== "undefined") {
|
|
215
|
-
const style = document.createElement("style");
|
|
216
|
-
style.textContent = css7;
|
|
217
|
-
document.head.appendChild(style);
|
|
218
|
-
}
|
|
219
|
-
var TableRow_default2 = { "osdkTableRow": "osdkTableRow" };
|
|
220
|
-
|
|
221
|
-
// build/browser/object-table/TableRow.js
|
|
222
|
-
function TableRow({
|
|
223
|
-
row,
|
|
224
|
-
virtualRow,
|
|
225
|
-
onRowClick,
|
|
226
|
-
renderCellContextMenu
|
|
227
|
-
}) {
|
|
228
|
-
const handleClick = useCallback2(() => {
|
|
229
|
-
onRowClick?.(row.original);
|
|
230
|
-
}, [onRowClick, row.original]);
|
|
231
|
-
return /* @__PURE__ */ React5.createElement("tr", {
|
|
232
|
-
"data-selected": row.getIsSelected(),
|
|
233
|
-
className: TableRow_default2.osdkTableRow,
|
|
234
|
-
style: {
|
|
235
|
-
height: `${virtualRow.size}px`,
|
|
236
|
-
transform: `translateY(${virtualRow.start}px)`
|
|
237
|
-
},
|
|
238
|
-
onClick: handleClick
|
|
239
|
-
}, row.getVisibleCells().map((cell) => /* @__PURE__ */ React5.createElement(TableCell, {
|
|
240
|
-
key: cell.id,
|
|
241
|
-
cell,
|
|
242
|
-
renderCellContextMenu
|
|
243
|
-
})));
|
|
244
|
-
}
|
|
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
|
+
*/
|
|
245
16
|
|
|
246
|
-
|
|
247
|
-
|
|
17
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
18
|
+
import React, { useLayoutEffect } from "react";
|
|
19
|
+
import { LoadingRow } from "./LoadingRow.js";
|
|
20
|
+
import styles from "./TableBody.module.css.js";
|
|
21
|
+
import { TableRow } from "./TableRow.js";
|
|
22
|
+
export function TableBody({
|
|
248
23
|
rows,
|
|
249
24
|
tableContainerRef,
|
|
250
25
|
onRowClick,
|
|
@@ -253,39 +28,40 @@ function TableBody({
|
|
|
253
28
|
isLoadingMore = false,
|
|
254
29
|
headerGroups = []
|
|
255
30
|
}) {
|
|
31
|
+
// Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.
|
|
256
32
|
const rowVirtualizer = useVirtualizer({
|
|
257
33
|
count: rows.length,
|
|
258
34
|
estimateSize: () => rowHeight,
|
|
259
35
|
getScrollElement: () => tableContainerRef.current,
|
|
260
36
|
overscan: 5
|
|
261
37
|
});
|
|
38
|
+
|
|
39
|
+
// Measure the virtualizer after the DOM has been laid out to ensure proper dimensions
|
|
262
40
|
useLayoutEffect(() => {
|
|
263
41
|
rowVirtualizer.measure();
|
|
264
42
|
}, [rowVirtualizer, rows.length]);
|
|
265
43
|
const totalSize = rowVirtualizer.getTotalSize();
|
|
266
44
|
const bodyHeight = isLoadingMore ? totalSize + rowHeight : totalSize;
|
|
267
45
|
const headers = headerGroups[0]?.headers ?? [];
|
|
268
|
-
return
|
|
269
|
-
className:
|
|
46
|
+
return /*#__PURE__*/React.createElement("tbody", {
|
|
47
|
+
className: styles.osdkTableBody,
|
|
270
48
|
style: {
|
|
271
49
|
height: `${bodyHeight}px`
|
|
272
50
|
}
|
|
273
|
-
}, rowVirtualizer.getVirtualItems().map(
|
|
51
|
+
}, rowVirtualizer.getVirtualItems().map(virtualRow => {
|
|
274
52
|
const row = rows[virtualRow.index];
|
|
275
|
-
return
|
|
53
|
+
return /*#__PURE__*/React.createElement(TableRow, {
|
|
276
54
|
key: row.id,
|
|
277
|
-
row,
|
|
278
|
-
virtualRow,
|
|
279
|
-
onRowClick,
|
|
280
|
-
renderCellContextMenu
|
|
55
|
+
row: row,
|
|
56
|
+
virtualRow: virtualRow,
|
|
57
|
+
onRowClick: onRowClick,
|
|
58
|
+
renderCellContextMenu: renderCellContextMenu
|
|
281
59
|
});
|
|
282
|
-
}), isLoadingMore &&
|
|
283
|
-
headers,
|
|
60
|
+
}), isLoadingMore && /*#__PURE__*/React.createElement(LoadingRow, {
|
|
61
|
+
headers: headers,
|
|
284
62
|
translateY: totalSize,
|
|
285
|
-
rowHeight,
|
|
63
|
+
rowHeight: rowHeight,
|
|
286
64
|
columnCount: headers.length
|
|
287
65
|
}));
|
|
288
66
|
}
|
|
289
|
-
|
|
290
|
-
TableBody
|
|
291
|
-
};
|
|
67
|
+
//# sourceMappingURL=TableBody.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
.osdkTableBody {
|
|
18
|
+
display: grid;
|
|
19
|
+
position: relative;
|
|
20
|
+
}
|
|
@@ -1,109 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
*/
|
|
4
16
|
|
|
5
|
-
|
|
6
|
-
import React, {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
var CellContextMenu_default = { "osdkCellContextMenu": "osdkCellContextMenu" };
|
|
15
|
-
function CellContextMenu({
|
|
16
|
-
cell,
|
|
17
|
-
position,
|
|
18
|
-
onClose,
|
|
19
|
-
renderContent
|
|
20
|
-
}) {
|
|
21
|
-
const ref = useRef(null);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
const handleClickOutside = (event) => {
|
|
24
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
25
|
-
onClose();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
29
|
-
return () => {
|
|
30
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
31
|
-
};
|
|
32
|
-
}, [onClose]);
|
|
33
|
-
return /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
|
|
34
|
-
ref,
|
|
35
|
-
className: CellContextMenu_default.osdkCellContextMenu,
|
|
36
|
-
style: {
|
|
37
|
-
left: position.left,
|
|
38
|
-
top: position.top,
|
|
39
|
-
minWidth: position.width
|
|
40
|
-
}
|
|
41
|
-
}, renderContent(cell.row.original, cell)), document.body);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// build/browser/object-table/hooks/useCellContextMenu.js
|
|
45
|
-
import { useCallback, useState } from "react";
|
|
46
|
-
var useCellContextMenu = ({
|
|
47
|
-
tdRef
|
|
48
|
-
}) => {
|
|
49
|
-
const [popoverPosition, setPopoverPosition] = useState(null);
|
|
50
|
-
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
|
51
|
-
const handleOpenContextMenu = useCallback((event) => {
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
event.stopPropagation();
|
|
54
|
-
if (tdRef.current) {
|
|
55
|
-
const rect = tdRef.current.getBoundingClientRect();
|
|
56
|
-
const position = {
|
|
57
|
-
left: rect.left,
|
|
58
|
-
top: rect.bottom,
|
|
59
|
-
width: rect.width
|
|
60
|
-
};
|
|
61
|
-
setPopoverPosition(position);
|
|
62
|
-
setIsContextMenuOpen(true);
|
|
63
|
-
}
|
|
64
|
-
}, [tdRef]);
|
|
65
|
-
const handleCloseContextMenu = useCallback(() => {
|
|
66
|
-
setIsContextMenuOpen(false);
|
|
67
|
-
setPopoverPosition(null);
|
|
68
|
-
}, []);
|
|
69
|
-
return {
|
|
70
|
-
isContextMenuOpen,
|
|
71
|
-
handleOpenContextMenu,
|
|
72
|
-
handleCloseContextMenu,
|
|
73
|
-
popoverPosition
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// build/browser/object-table/TableCell.module.css
|
|
78
|
-
var css2 = '/*\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\n.osdkTableCell {\n display: flex;\n align-items: center;\n text-align: left;\n position: relative;\n padding: var(--osdk-table-cell-padding);\n font-size: var(--osdk-table-cell-fontSize);\n color: var(--osdk-table-cell-color);\n background-color: inherit;\n border-right: var(--osdk-table-cell-divider);\n\n &:first-child {\n border-left: var(--osdk-table-border);\n }\n\n &:last-child {\n border-right: var(--osdk-table-border);\n }\n}\n\n.osdkTableCell[data-pinned="left"],\n.osdkTableCell[data-pinned="right"] {\n position: sticky;\n z-index: var(--osdk-surface-z-index-1);\n}\n\n/* Last left-pinned column - no left-pinned siblings after it */\n.osdkTableCell[data-pinned="left"]:not(:has(~ [data-pinned="left"])) {\n border-right: var(--osdk-table-pinned-column-border);\n}\n\n/* First right-pinned column - no right-pinned siblings before it */\n.osdkTableCell[data-pinned="right"]:not(:has(~ [data-pinned="right"]):nth-child(n+2)) {\n border-left: var(--osdk-table-pinned-column-border);\n}\n\n.osdkTableCell:has([role="checkbox"]) {\n justify-content: center;\n}\n\n.osdkTableCellContent:not(:has([role="checkbox"])) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: left;\n}\n';
|
|
79
|
-
if (typeof document !== "undefined") {
|
|
80
|
-
const style = document.createElement("style");
|
|
81
|
-
style.textContent = css2;
|
|
82
|
-
document.head.appendChild(style);
|
|
83
|
-
}
|
|
84
|
-
var TableCell_default = { "osdkTableCell": "osdkTableCell", "osdkTableCellContent": "osdkTableCellContent" };
|
|
85
|
-
|
|
86
|
-
// build/browser/object-table/utils/constants.js
|
|
87
|
-
var SELECTION_COLUMN_ID = "__selection__";
|
|
88
|
-
|
|
89
|
-
// build/browser/object-table/utils/getColumnPinningStyles.js
|
|
90
|
-
function getColumnPinningStyles(column) {
|
|
91
|
-
const isPinned = column.getIsPinned();
|
|
92
|
-
return {
|
|
93
|
-
columnStyles: {
|
|
94
|
-
left: isPinned === "left" ? `${column.getStart("left")}px` : void 0,
|
|
95
|
-
right: isPinned === "right" ? `${column.getAfter("right")}px` : void 0,
|
|
96
|
-
width: column.getSize()
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// build/browser/object-table/TableCell.js
|
|
102
|
-
function TableCell({
|
|
17
|
+
import { flexRender } from "@tanstack/react-table";
|
|
18
|
+
import React, { useRef } from "react";
|
|
19
|
+
import { CellContextMenu } from "./CellContextMenu.js";
|
|
20
|
+
import { useCellContextMenu } from "./hooks/useCellContextMenu.js";
|
|
21
|
+
import styles from "./TableCell.module.css.js";
|
|
22
|
+
import { SELECTION_COLUMN_ID } from "./utils/constants.js";
|
|
23
|
+
import { getColumnPinningStyles } from "./utils/getColumnPinningStyles.js";
|
|
24
|
+
export function TableCell({
|
|
103
25
|
cell,
|
|
104
26
|
renderCellContextMenu
|
|
105
27
|
}) {
|
|
106
|
-
const tdRef =
|
|
28
|
+
const tdRef = useRef(null);
|
|
107
29
|
const isSelectColumn = cell.column.id === SELECTION_COLUMN_ID;
|
|
108
30
|
const {
|
|
109
31
|
isContextMenuOpen,
|
|
@@ -116,21 +38,19 @@ function TableCell({
|
|
|
116
38
|
const {
|
|
117
39
|
columnStyles
|
|
118
40
|
} = getColumnPinningStyles(cell.column);
|
|
119
|
-
return
|
|
41
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("td", {
|
|
120
42
|
ref: tdRef,
|
|
121
43
|
"data-pinned": cell.column.getIsPinned(),
|
|
122
|
-
className:
|
|
44
|
+
className: styles.osdkTableCell,
|
|
123
45
|
style: columnStyles,
|
|
124
46
|
onContextMenu: handleOpenContextMenu
|
|
125
|
-
},
|
|
126
|
-
className:
|
|
127
|
-
}, flexRender(cell.column.columnDef.cell, cell.getContext()))), !isSelectColumn && isContextMenuOpen && !!popoverPosition && !!renderCellContextMenu &&
|
|
128
|
-
cell,
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: styles.osdkTableCellContent
|
|
49
|
+
}, flexRender(cell.column.columnDef.cell, cell.getContext()))), !isSelectColumn && isContextMenuOpen && !!popoverPosition && !!renderCellContextMenu && /*#__PURE__*/React.createElement(CellContextMenu, {
|
|
50
|
+
cell: cell,
|
|
129
51
|
position: popoverPosition,
|
|
130
52
|
onClose: handleCloseContextMenu,
|
|
131
53
|
renderContent: renderCellContextMenu
|
|
132
54
|
}));
|
|
133
55
|
}
|
|
134
|
-
|
|
135
|
-
TableCell
|
|
136
|
-
};
|
|
56
|
+
//# sourceMappingURL=TableCell.js.map
|