@osdk/react-components 0.1.0-beta.0 → 0.1.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 +31 -0
- package/README.md +56 -6
- package/build/browser/object-table/CellContextMenu.js +48 -0
- package/build/browser/object-table/CellContextMenu.js.map +1 -0
- package/build/browser/object-table/ObjectTable.js +114 -0
- package/build/browser/object-table/ObjectTable.js.map +1 -0
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/SelectionCells.js +67 -0
- package/build/browser/object-table/SelectionCells.js.map +1 -0
- package/build/browser/object-table/Table.js +81 -0
- package/build/browser/object-table/Table.js.map +1 -0
- package/build/browser/object-table/TableBody.js +56 -0
- package/build/browser/object-table/TableBody.js.map +1 -0
- package/build/browser/object-table/TableCell.js +51 -0
- package/build/browser/object-table/TableCell.js.map +1 -0
- package/build/browser/object-table/TableHeader.js +63 -0
- package/build/browser/object-table/TableHeader.js.map +1 -0
- package/build/browser/object-table/TableRow.js +42 -0
- package/build/browser/object-table/TableRow.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js +147 -0
- package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js +508 -0
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useDefaultTableStates.test.js +178 -0
- package/build/browser/object-table/hooks/__tests__/useDefaultTableStates.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js +229 -0
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js +548 -0
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js +274 -0
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -0
- package/build/browser/object-table/hooks/useCellContextMenu.js +48 -0
- package/build/browser/object-table/hooks/useCellContextMenu.js.map +1 -0
- package/build/browser/object-table/hooks/useColumnDefs.js +87 -0
- package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -0
- package/build/browser/object-table/hooks/useDefaultTableStates.js +43 -0
- package/build/browser/object-table/hooks/useDefaultTableStates.js.map +1 -0
- package/build/browser/object-table/hooks/useObjectTableData.js +49 -0
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -0
- package/build/browser/object-table/hooks/useRowSelection.js +180 -0
- package/build/browser/object-table/hooks/useRowSelection.js.map +1 -0
- package/build/browser/object-table/hooks/useSelectionColumn.js +51 -0
- package/build/browser/object-table/hooks/useSelectionColumn.js.map +1 -0
- package/build/browser/{junk.test.js → object-table/utils/getRowId.js} +6 -8
- package/build/browser/object-table/utils/getRowId.js.map +1 -0
- package/build/browser/public/experimental.js +18 -1
- package/build/browser/public/experimental.js.map +1 -1
- package/build/cjs/public/experimental.cjs +4256 -0
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +39 -17
- package/build/esm/object-table/CellContextMenu.js +48 -0
- package/build/esm/object-table/CellContextMenu.js.map +1 -0
- package/build/esm/object-table/ObjectTable.js +114 -0
- package/build/esm/object-table/ObjectTable.js.map +1 -0
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/SelectionCells.js +67 -0
- package/build/esm/object-table/SelectionCells.js.map +1 -0
- package/build/esm/object-table/Table.js +81 -0
- package/build/esm/object-table/Table.js.map +1 -0
- package/build/esm/object-table/TableBody.js +56 -0
- package/build/esm/object-table/TableBody.js.map +1 -0
- package/build/esm/object-table/TableCell.js +51 -0
- package/build/esm/object-table/TableCell.js.map +1 -0
- package/build/esm/object-table/TableHeader.js +63 -0
- package/build/esm/object-table/TableHeader.js.map +1 -0
- package/build/esm/object-table/TableRow.js +42 -0
- package/build/esm/object-table/TableRow.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js +147 -0
- package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js +508 -0
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useDefaultTableStates.test.js +178 -0
- package/build/esm/object-table/hooks/__tests__/useDefaultTableStates.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js +229 -0
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js +548 -0
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js +274 -0
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -0
- package/build/esm/object-table/hooks/useCellContextMenu.js +48 -0
- package/build/esm/object-table/hooks/useCellContextMenu.js.map +1 -0
- package/build/esm/object-table/hooks/useColumnDefs.js +87 -0
- package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -0
- package/build/esm/object-table/hooks/useDefaultTableStates.js +43 -0
- package/build/esm/object-table/hooks/useDefaultTableStates.js.map +1 -0
- package/build/esm/object-table/hooks/useObjectTableData.js +49 -0
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -0
- package/build/esm/object-table/hooks/useRowSelection.js +180 -0
- package/build/esm/object-table/hooks/useRowSelection.js.map +1 -0
- package/build/esm/object-table/hooks/useSelectionColumn.js +51 -0
- package/build/esm/object-table/hooks/useSelectionColumn.js.map +1 -0
- package/build/esm/{junk.test.js → object-table/utils/getRowId.js} +6 -8
- package/build/esm/object-table/utils/getRowId.js.map +1 -0
- package/build/esm/public/experimental.js +18 -1
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/object-table/CellContextMenu.d.ts +11 -0
- package/build/types/object-table/CellContextMenu.d.ts.map +1 -0
- package/build/types/object-table/ObjectTable.d.ts +16 -0
- package/build/types/object-table/ObjectTable.d.ts.map +1 -0
- package/build/types/object-table/ObjectTableApi.d.ts +30 -20
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/SelectionCells.d.ts +14 -0
- package/build/types/object-table/SelectionCells.d.ts.map +1 -0
- package/build/types/object-table/Table.d.ts +12 -0
- package/build/types/object-table/Table.d.ts.map +1 -0
- package/build/types/object-table/TableBody.d.ts +11 -0
- package/build/types/object-table/TableBody.d.ts.map +1 -0
- package/build/types/object-table/TableCell.d.ts +8 -0
- package/build/types/object-table/TableCell.d.ts.map +1 -0
- package/build/types/object-table/TableHeader.d.ts +7 -0
- package/build/types/object-table/TableHeader.d.ts.map +1 -0
- package/build/types/object-table/TableRow.d.ts +11 -0
- package/build/types/object-table/TableRow.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useCellContextMenu.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useColumnDefs.test.d.ts +1 -0
- package/build/types/object-table/hooks/__tests__/useColumnDefs.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useDefaultTableStates.test.d.ts +1 -0
- package/build/types/object-table/hooks/__tests__/useDefaultTableStates.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useObjectTableData.test.d.ts +1 -0
- package/build/types/object-table/hooks/__tests__/useObjectTableData.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts +1 -0
- package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts +1 -0
- package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/useCellContextMenu.d.ts +17 -0
- package/build/types/object-table/hooks/useCellContextMenu.d.ts.map +1 -0
- package/build/types/object-table/hooks/useColumnDefs.d.ts +20 -0
- package/build/types/object-table/hooks/useColumnDefs.d.ts.map +1 -0
- package/build/types/object-table/hooks/useDefaultTableStates.d.ts +19 -0
- package/build/types/object-table/hooks/useDefaultTableStates.d.ts.map +1 -0
- package/build/types/object-table/hooks/useObjectTableData.d.ts +13 -0
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -0
- package/build/types/object-table/hooks/useRowSelection.d.ts +22 -0
- package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -0
- package/build/types/object-table/hooks/useSelectionColumn.d.ts +15 -0
- package/build/types/object-table/hooks/useSelectionColumn.d.ts.map +1 -0
- package/build/types/object-table/utils/getRowId.d.ts +6 -0
- package/build/types/object-table/utils/getRowId.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +2 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +11 -4
- package/build/browser/junk.test.js.map +0 -1
- package/build/esm/junk.test.js.map +0 -1
- package/build/types/junk.test.d.ts.map +0 -1
- /package/build/types/{junk.test.d.ts → object-table/hooks/__tests__/useCellContextMenu.test.d.ts} +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
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 { useCallback, useMemo, useState } from "react";
|
|
18
|
+
import { getRowId, getRowIdFromPrimaryKey } from "../utils/getRowId.js";
|
|
19
|
+
export function useRowSelection({
|
|
20
|
+
selectionMode = "none",
|
|
21
|
+
selectedRows,
|
|
22
|
+
onRowSelection,
|
|
23
|
+
data
|
|
24
|
+
}) {
|
|
25
|
+
// The rowSelectionState in uncontrolled mode
|
|
26
|
+
const [internalRowSelection, setInternalRowSelection] = useState({});
|
|
27
|
+
|
|
28
|
+
// Used for shift-click behavior in "multiple" mode
|
|
29
|
+
const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState(null);
|
|
30
|
+
const isControlled = selectedRows !== undefined;
|
|
31
|
+
const isSelectionEnabled = selectionMode !== "none";
|
|
32
|
+
|
|
33
|
+
// Row selection state
|
|
34
|
+
// If controlled mode, return the state from selectedRows prop
|
|
35
|
+
// If uncontrolled, return the internalRowSelection state
|
|
36
|
+
const rowSelectionState = useMemo(() => {
|
|
37
|
+
if (!isSelectionEnabled) return {};
|
|
38
|
+
if (isControlled && selectedRows) {
|
|
39
|
+
return getRowSelectionState(selectedRows);
|
|
40
|
+
}
|
|
41
|
+
return internalRowSelection;
|
|
42
|
+
}, [isSelectionEnabled, isControlled, selectedRows, internalRowSelection]);
|
|
43
|
+
const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;
|
|
44
|
+
const totalCount = data?.length ?? 0;
|
|
45
|
+
const isAllSelected = totalCount > 0 && selectedCount === totalCount;
|
|
46
|
+
const onToggleAll = useCallback(() => {
|
|
47
|
+
if (!isSelectionEnabled || !data) return;
|
|
48
|
+
const newSelectedRows = isAllSelected ? [] : data.map(item => item.$primaryKey);
|
|
49
|
+
if (!isControlled) {
|
|
50
|
+
setInternalRowSelection(getRowSelectionState(newSelectedRows));
|
|
51
|
+
}
|
|
52
|
+
onRowSelection?.(newSelectedRows);
|
|
53
|
+
}, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);
|
|
54
|
+
const onToggleRow = useCallback((rowId, rowIndex, isShiftClick = false) => {
|
|
55
|
+
if (!isSelectionEnabled || !data) return;
|
|
56
|
+
let newSelectedRows = [];
|
|
57
|
+
if (selectionMode === "single") {
|
|
58
|
+
newSelectedRows = getSingleSelectionRows({
|
|
59
|
+
rowId,
|
|
60
|
+
rowIndex,
|
|
61
|
+
data,
|
|
62
|
+
rowSelectionState
|
|
63
|
+
});
|
|
64
|
+
setLastSelectedRowIndex(rowIndex);
|
|
65
|
+
} else {
|
|
66
|
+
// Multiple selection mode
|
|
67
|
+
|
|
68
|
+
// When user does shiftClick but lastSelectedRowIndex is null,
|
|
69
|
+
// it is treated as a normal click in multiple selection
|
|
70
|
+
if (isShiftClick && lastSelectedRowIndex != null) {
|
|
71
|
+
newSelectedRows = getRangeSelectionRows({
|
|
72
|
+
rowId,
|
|
73
|
+
rowIndex,
|
|
74
|
+
data,
|
|
75
|
+
lastSelectedRowIndex,
|
|
76
|
+
rowSelectionState
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
newSelectedRows = getMultipleSelectionRows({
|
|
80
|
+
rowId,
|
|
81
|
+
rowIndex,
|
|
82
|
+
data,
|
|
83
|
+
rowSelectionState
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
setLastSelectedRowIndex(rowIndex);
|
|
87
|
+
}
|
|
88
|
+
if (!isControlled) {
|
|
89
|
+
setInternalRowSelection(getRowSelectionState(newSelectedRows));
|
|
90
|
+
}
|
|
91
|
+
onRowSelection?.(newSelectedRows);
|
|
92
|
+
}, [isSelectionEnabled, data, selectionMode, lastSelectedRowIndex, isControlled, rowSelectionState, onRowSelection]);
|
|
93
|
+
return {
|
|
94
|
+
rowSelection: rowSelectionState,
|
|
95
|
+
isAllSelected,
|
|
96
|
+
hasSelection: selectedCount > 0,
|
|
97
|
+
onToggleAll,
|
|
98
|
+
onToggleRow
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function getSingleSelectionRows({
|
|
102
|
+
rowId,
|
|
103
|
+
rowIndex,
|
|
104
|
+
data,
|
|
105
|
+
rowSelectionState
|
|
106
|
+
}) {
|
|
107
|
+
const primaryKey = data[rowIndex].$primaryKey;
|
|
108
|
+
// Toggle row selection in single selection mode
|
|
109
|
+
const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];
|
|
110
|
+
return newSelectedRows;
|
|
111
|
+
}
|
|
112
|
+
function getRangeSelectionRows({
|
|
113
|
+
lastSelectedRowIndex,
|
|
114
|
+
rowIndex,
|
|
115
|
+
data,
|
|
116
|
+
rowSelectionState
|
|
117
|
+
}) {
|
|
118
|
+
// This function is only called if lastSelectedRowIndex is not null
|
|
119
|
+
// This condition is added for typechecks only
|
|
120
|
+
if (lastSelectedRowIndex != null) {
|
|
121
|
+
const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);
|
|
122
|
+
const primaryKeysInRange = rowsInRange.map(item => item.$primaryKey);
|
|
123
|
+
const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);
|
|
124
|
+
|
|
125
|
+
// Add all rows in range to selectedRows if not yet selected
|
|
126
|
+
const newSelectedRows = [...currentlySelected];
|
|
127
|
+
primaryKeysInRange.forEach(item => {
|
|
128
|
+
if (!newSelectedRows.includes(item)) {
|
|
129
|
+
newSelectedRows.push(item);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return newSelectedRows;
|
|
133
|
+
}
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
function getMultipleSelectionRows({
|
|
137
|
+
rowIndex,
|
|
138
|
+
data,
|
|
139
|
+
rowSelectionState
|
|
140
|
+
}) {
|
|
141
|
+
const primaryKey = data[rowIndex].$primaryKey;
|
|
142
|
+
const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);
|
|
143
|
+
// Handles single row toggle in multiple selection mode
|
|
144
|
+
const newSelectedRows = currentlySelected.includes(primaryKey) ? currentlySelected.filter(i => i !== primaryKey) : [...currentlySelected, primaryKey];
|
|
145
|
+
return newSelectedRows;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Builds a range of rows from startIndex to endIndex
|
|
150
|
+
*/
|
|
151
|
+
function getRowsInRange(data, startIndex, endIndex) {
|
|
152
|
+
const start = Math.min(startIndex, endIndex);
|
|
153
|
+
const end = Math.max(startIndex, endIndex);
|
|
154
|
+
const rows = [];
|
|
155
|
+
for (let i = start; i <= end; i++) {
|
|
156
|
+
const item = data[i];
|
|
157
|
+
if (item) {
|
|
158
|
+
rows.push(item);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return rows;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Converts an array of primary keys to a RowSelectionState object
|
|
166
|
+
*/
|
|
167
|
+
function getRowSelectionState(primaryKeys) {
|
|
168
|
+
return primaryKeys.reduce((acc, primaryKey) => {
|
|
169
|
+
acc[getRowIdFromPrimaryKey(primaryKey)] = true;
|
|
170
|
+
return acc;
|
|
171
|
+
}, {});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Converts from a RowSelectionState object back to an array of primary keys
|
|
176
|
+
*/
|
|
177
|
+
function getSelectedPrimaryKeys(selectionState, data) {
|
|
178
|
+
return data.filter(item => selectionState[getRowId(item)]).map(item => item.$primaryKey);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=useRowSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRowSelection.js","names":["useCallback","useMemo","useState","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","onRowSelection","data","internalRowSelection","setInternalRowSelection","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","isSelectionEnabled","rowSelectionState","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","isAllSelected","onToggleAll","newSelectedRows","map","item","$primaryKey","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","rowSelection","hasSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.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 { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\nexport interface UseRowSelectionProps<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (\n rowId: string,\n rowIndex: number,\n isShiftClick?: boolean,\n ) => void;\n}\n\nexport function useRowSelection<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n onRowSelection,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n // The rowSelectionState in uncontrolled mode\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\n\n // Used for shift-click behavior in \"multiple\" mode\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const isSelectionEnabled = selectionMode !== \"none\";\n\n // Row selection state\n // If controlled mode, return the state from selectedRows prop\n // If uncontrolled, return the internalRowSelection state\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!isSelectionEnabled) return {};\n if (isControlled && selectedRows) {\n return getRowSelectionState(selectedRows);\n }\n return internalRowSelection;\n }, [\n isSelectionEnabled,\n isControlled,\n selectedRows,\n internalRowSelection,\n ]);\n\n const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;\n const totalCount = data?.length ?? 0;\n const isAllSelected = totalCount > 0 && selectedCount === totalCount;\n const hasSelection = selectedCount > 0;\n\n const onToggleAll = useCallback(() => {\n if (!isSelectionEnabled || !data) return;\n\n const newSelectedRows: PrimaryKeyType<Q>[] = isAllSelected\n ? []\n : data.map(item => item.$primaryKey);\n\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n }, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!isSelectionEnabled || !data) return;\n\n let newSelectedRows: PrimaryKeyType<Q>[] = [];\n\n if (selectionMode === \"single\") {\n newSelectedRows = getSingleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n setLastSelectedRowIndex(rowIndex);\n } else {\n // Multiple selection mode\n\n // When user does shiftClick but lastSelectedRowIndex is null,\n // it is treated as a normal click in multiple selection\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows(\n { rowId, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n }\n setLastSelectedRowIndex(rowIndex);\n }\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n },\n [\n isSelectionEnabled,\n data,\n selectionMode,\n lastSelectedRowIndex,\n isControlled,\n rowSelectionState,\n onRowSelection,\n ],\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { rowId, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n // Toggle row selection in single selection mode\n const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];\n return newSelectedRows;\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { lastSelectedRowIndex, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n // This function is only called if lastSelectedRowIndex is not null\n // This condition is added for typechecks only\n if (lastSelectedRowIndex != null) {\n const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);\n const primaryKeysInRange = rowsInRange.map(item => item.$primaryKey);\n\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n\n // Add all rows in range to selectedRows if not yet selected\n const newSelectedRows = [...currentlySelected];\n primaryKeysInRange.forEach(item => {\n if (!newSelectedRows.includes(item)) {\n newSelectedRows.push(item);\n }\n });\n return newSelectedRows;\n }\n return [];\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n // Handles single row toggle in multiple selection mode\n const newSelectedRows = currentlySelected.includes(primaryKey)\n ? currentlySelected.filter(i => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n return newSelectedRows;\n}\n\n/**\n * Builds a range of rows from startIndex to endIndex\n */\nfunction getRowsInRange<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>,\n startIndex: number,\n endIndex: number,\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> = [];\n\n for (let i = start; i <= end; i++) {\n const item = data[i];\n if (item) {\n rows.push(item);\n }\n }\n\n return rows;\n}\n\n/**\n * Converts an array of primary keys to a RowSelectionState object\n */\nfunction getRowSelectionState<Q extends ObjectTypeDefinition>(\n primaryKeys: PrimaryKeyType<Q>[],\n): RowSelectionState {\n return primaryKeys.reduce<RowSelectionState>(\n (acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n },\n {},\n );\n}\n\n/**\n * Converts from a RowSelectionState object back to an array of primary keys\n */\nfunction getSelectedPrimaryKeys<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>,\n): PrimaryKeyType<Q>[] {\n return data\n .filter(item => selectionState[getRowId(item)])\n .map(item => item.$primaryKey);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAC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ACjCrD,IAA8D,EACzC;EACrB,OAAOA,IAAI,CACRa,MAAM,CAACQ,IAAI,IAAIgC,cAAc,CAAC3D,QAAQ,CAAC2B,IAAI,CAAC,CAAC,CAAC,CAC9CD,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,WAAW,CAAC;AAClC","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 React, { useMemo } from "react";
|
|
18
|
+
import { SelectionCell, SelectionHeaderCell } from "../SelectionCells.js";
|
|
19
|
+
export const SELECTION_COLUMN_ID = "__selection__";
|
|
20
|
+
export const useSelectionColumn = ({
|
|
21
|
+
selectionMode,
|
|
22
|
+
isAllSelected,
|
|
23
|
+
hasSelection,
|
|
24
|
+
onToggleAll,
|
|
25
|
+
onToggleRow
|
|
26
|
+
}) => {
|
|
27
|
+
const selectionColumn = useMemo(() => {
|
|
28
|
+
if (selectionMode === "none") return null;
|
|
29
|
+
return {
|
|
30
|
+
id: SELECTION_COLUMN_ID,
|
|
31
|
+
header: () => selectionMode === "multiple" ? /*#__PURE__*/React.createElement(SelectionHeaderCell, {
|
|
32
|
+
isAllSelected: isAllSelected,
|
|
33
|
+
hasSelection: hasSelection,
|
|
34
|
+
onToggleAll: onToggleAll
|
|
35
|
+
}) : null,
|
|
36
|
+
cell: ({
|
|
37
|
+
row
|
|
38
|
+
}) => /*#__PURE__*/React.createElement(SelectionCell, {
|
|
39
|
+
row: row,
|
|
40
|
+
onToggleRow: onToggleRow
|
|
41
|
+
}),
|
|
42
|
+
size: 50,
|
|
43
|
+
minSize: 50,
|
|
44
|
+
maxSize: 50,
|
|
45
|
+
enableSorting: false,
|
|
46
|
+
enableResizing: false
|
|
47
|
+
};
|
|
48
|
+
}, [selectionMode, isAllSelected, hasSelection, onToggleAll, onToggleRow]);
|
|
49
|
+
return selectionColumn;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=useSelectionColumn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectionColumn.js","names":["React","useMemo","SelectionCell","SelectionHeaderCell","SELECTION_COLUMN_ID","useSelectionColumn","selectionMode","isAllSelected","hasSelection","onToggleAll","onToggleRow","selectionColumn","id","header","createElement","cell","row","size","minSize","maxSize","enableSorting","enableResizing"],"sources":["useSelectionColumn.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 ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { ColumnDef } from \"@tanstack/react-table\";\nimport React, { useMemo } from \"react\";\nimport { SelectionCell, SelectionHeaderCell } from \"../SelectionCells.js\";\n\ninterface UseSelectionColumnProps {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (id: string, rowIndex: number, isShiftClick: boolean) => void;\n}\n\nexport const SELECTION_COLUMN_ID = \"__selection__\";\nexport const useSelectionColumn = <\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n>({\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n}: UseSelectionColumnProps):\n | ColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n | null =>\n{\n const selectionColumn = useMemo(() => {\n if (selectionMode === \"none\") return null;\n\n return {\n id: SELECTION_COLUMN_ID,\n header: () => (\n selectionMode === \"multiple\"\n ? (\n <SelectionHeaderCell\n isAllSelected={isAllSelected}\n hasSelection={hasSelection}\n onToggleAll={onToggleAll}\n />\n )\n : null\n ),\n cell: ({ row }: { row: any }) => (\n <SelectionCell\n row={row}\n onToggleRow={onToggleRow}\n />\n ),\n size: 50,\n minSize: 50,\n maxSize: 50,\n enableSorting: false,\n enableResizing: false,\n };\n }, [\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n ]);\n\n return selectionColumn;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,aAAa,EAAEC,mBAAmB,QAAQ,sBAAsB;AAUzE,OAAO,MAAMC,mBAAmB,GAAG,eAAe;AAClD,OAAO,MAAMC,kBAAkB,GAAGA,CAMhC;EACAC,aAAa;EACbC,aAAa;EACbC,YAAY;EACZC,WAAW;EACXC;AACuB,CAAC,KAK1B;EACE,MAAMC,eAAe,GAAGV,OAAO,CAAC,MAAM;IACpC,IAAIK,aAAa,KAAK,MAAM,EAAE,OAAO,IAAI;IAEzC,OAAO;MACLM,EAAE,EAAER,mBAAmB;MACvBS,MAAM,EAAEA,CAAA,KACNP,aAAa,KAAK,UAAU,gBAExBN,KAAA,CAAAc,aAAA,CAACX,mBAAmB;QAClBI,aAAa,EAAEA,aAAc;QAC7BC,YAAY,EAAEA,YAAa;QAC3BC,WAAW,EAAEA;MAAY,CAC1B,CAAC,GAEF,IACL;MACDM,IAAI,EAAEA,CAAC;QAAEC;MAAkB,CAAC,kBAC1BhB,KAAA,CAAAc,aAAA,CAACZ,aAAa;QACZc,GAAG,EAAEA,GAAI;QACTN,WAAW,EAAEA;MAAY,CAC1B,CACF;MACDO,IAAI,EAAE,EAAE;MACRC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,aAAa,EAAE,KAAK;MACpBC,cAAc,EAAE;IAClB,CAAC;EACH,CAAC,EAAE,CACDf,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,WAAW,CACZ,CAAC;EAEF,OAAOC,eAAe;AACxB,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=junk.test.js.map
|
|
17
|
+
export const getRowId = row => {
|
|
18
|
+
return getRowIdFromPrimaryKey(row.$primaryKey);
|
|
19
|
+
};
|
|
20
|
+
export const getRowIdFromPrimaryKey = primaryKey => primaryKey.toString();
|
|
21
|
+
//# sourceMappingURL=getRowId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRowId.js","names":["getRowId","row","getRowIdFromPrimaryKey","$primaryKey","primaryKey","toString"],"sources":["getRowId.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 ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\n\nexport const getRowId = <\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n>(\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n): string => {\n return getRowIdFromPrimaryKey(row.$primaryKey);\n};\n\nexport const getRowIdFromPrimaryKey = <Q extends ObjectTypeDefinition>(\n primaryKey: PrimaryKeyType<Q>,\n): string => primaryKey.toString();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,MAAMA,QAAQ,GAOnBC,GAAkE,IACvD;EACX,OAAOC,sBAAsB,CAACD,GAAG,CAACE,WAAW,CAAC;AAChD,CAAC;AAED,OAAO,MAAMD,sBAAsB,GACjCE,UAA6B,IAClBA,UAAU,CAACC,QAAQ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
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
|
+
// ObjectTable that loads and displays data for a given objectSet
|
|
18
|
+
export { ObjectTable } from "../object-table/ObjectTable.js";
|
|
2
19
|
//# sourceMappingURL=experimental.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":[],"sources":["experimental.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\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\nexport type {
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["ObjectTable"],"sources":["experimental.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\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,SAASA,WAAW,QAAQ,gCAAgC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Cell, RowData } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { PopoverPosition } from "./hooks/useCellContextMenu.js";
|
|
4
|
+
interface CellContextMenuProps<TData extends RowData> {
|
|
5
|
+
cell: Cell<TData, unknown>;
|
|
6
|
+
position: PopoverPosition;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
renderContent: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function CellContextMenu<TData extends RowData>({ cell, position, onClose, renderContent }: CellContextMenuProps<TData>): React.ReactElement;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,MAAM,eAAe,uBAAwB;AAC3D,OAAO,WAAkC,OAAQ;AAEjD,cAAc,uBAAuB,+BAAgC;UAE3D,qBAAqB,cAAc,SAAS;CACpD,MAAM,KAAK;CACX,UAAU;CACV;CACA,gBAAgBA,KAAK,OAAOC,MAAM,KAAK,oBAAoB,MAAM;AAClE;AAED,OAAO,iBAAS,gBAAgB,cAAc,SAAS,EACrD,MACA,UACA,SACA,eAC4B,EAA3B,qBAAqB,SAAS,MAAM","names":["row: TData","cell: Cell<TData, unknown>"],"sources":["../../../src/object-table/CellContextMenu.tsx"],"version":3,"file":"CellContextMenu.d.ts"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ObjectTypeDefinition, QueryDefinition, SimplePropertyDef } from "@osdk/api";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { ObjectTableProps } from "./ObjectTableApi.js";
|
|
4
|
+
/**
|
|
5
|
+
* ObjectTable - A headless table component for displaying OSDK object sets
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function ObjectTable<
|
|
13
|
+
Q extends ObjectTypeDefinition,
|
|
14
|
+
RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,
|
|
15
|
+
FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>
|
|
16
|
+
>({ objectSet, objectType, columnDefinitions, filter, onRowSelection, renderCellContextMenu, selectionMode, selectedRows,...props }: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cACE,sBAGA,iBACA,yBACK,WAAY;AAOnB,OAAO,WAA+C,OAAQ;AAM9D,cAAc,wBAAwB,qBAAsB;;;;;;;;;AAa5D,OAAO,iBAAS;CACd,UAAU;CACV,aAAa,eAAe,qBAAqB;CAIjD,wBAAwB,eAAe,gBAAgB,CAAE,MAAK;EAI9D,EACA,WACA,YACA,mBACA,QACA,gBACA,uBACA,eACA,aACA,GAAG,OACwC,EAA1C,iBAAiB,GAAG,MAAM,mBAAmB,MAAM","names":[],"sources":["../../../src/object-table/ObjectTable.tsx"],"version":3,"file":"ObjectTable.d.ts"}
|
|
@@ -2,11 +2,17 @@ import type { DerivedProperty, ObjectSet, ObjectTypeDefinition, Osdk, PrimaryKey
|
|
|
2
2
|
import type * as React from "react";
|
|
3
3
|
export type ColumnDefinition<
|
|
4
4
|
Q extends ObjectTypeDefinition,
|
|
5
|
-
RDPs extends Record<string, SimplePropertyDef>,
|
|
6
|
-
FunctionColumns extends Record<string, QueryDefinition<{}>>
|
|
5
|
+
RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,
|
|
6
|
+
FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>
|
|
7
7
|
> = {
|
|
8
8
|
locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>
|
|
9
|
+
/**
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
9
12
|
isVisible?: boolean
|
|
13
|
+
/**
|
|
14
|
+
* @default none
|
|
15
|
+
*/
|
|
10
16
|
pinned?: "left" | "right" | "none"
|
|
11
17
|
width?: number
|
|
12
18
|
minWidth?: number
|
|
@@ -14,16 +20,16 @@ export type ColumnDefinition<
|
|
|
14
20
|
resizable?: boolean
|
|
15
21
|
orderable?: boolean
|
|
16
22
|
filterable?: boolean
|
|
17
|
-
renderCell?: (object: Osdk.Instance<Q>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode
|
|
23
|
+
renderCell?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode
|
|
18
24
|
renderHeader?: () => React.ReactNode
|
|
19
25
|
};
|
|
20
|
-
type ColumnDefinitionLocator<
|
|
26
|
+
export type ColumnDefinitionLocator<
|
|
21
27
|
Q extends ObjectTypeDefinition,
|
|
22
|
-
RDPs extends Record<string, SimplePropertyDef>,
|
|
23
|
-
FunctionColumns extends Record<string, QueryDefinition<{}>> =
|
|
28
|
+
RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,
|
|
29
|
+
FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>
|
|
24
30
|
> = {
|
|
25
31
|
type: "property"
|
|
26
|
-
|
|
32
|
+
id: PropertyKeys<Q>
|
|
27
33
|
} | {
|
|
28
34
|
type: "function"
|
|
29
35
|
id: keyof FunctionColumns
|
|
@@ -34,7 +40,7 @@ type ColumnDefinitionLocator<
|
|
|
34
40
|
};
|
|
35
41
|
export interface ObjectTableProps<
|
|
36
42
|
Q extends ObjectTypeDefinition,
|
|
37
|
-
RDPs extends Record<string, SimplePropertyDef> =
|
|
43
|
+
RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,
|
|
38
44
|
FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>
|
|
39
45
|
> {
|
|
40
46
|
/**
|
|
@@ -42,6 +48,10 @@ export interface ObjectTableProps<
|
|
|
42
48
|
*/
|
|
43
49
|
objectSet: ObjectSet<Q>;
|
|
44
50
|
/**
|
|
51
|
+
* The object type of the object
|
|
52
|
+
*/
|
|
53
|
+
objectType: Q;
|
|
54
|
+
/**
|
|
45
55
|
* Ordered list of column definitions to show in the table
|
|
46
56
|
*
|
|
47
57
|
* If not provided, all of the properties of the object type will be shown in default order.
|
|
@@ -119,23 +129,18 @@ export interface ObjectTableProps<
|
|
|
119
129
|
*/
|
|
120
130
|
onColumnResize?: (columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns, newWidth: number) => void;
|
|
121
131
|
/**
|
|
122
|
-
* Called when a cell is clicked.
|
|
123
|
-
*
|
|
124
|
-
* @param object The object representing the row
|
|
125
|
-
* @param columnDefinition The column definition for the clicked cell
|
|
126
|
-
*/
|
|
127
|
-
onCellClick?: (object: Osdk.Instance<Q>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => void;
|
|
128
|
-
/**
|
|
129
132
|
* Called when a row is clicked.
|
|
130
133
|
*
|
|
131
134
|
* @param object The object representing the clicked row
|
|
132
135
|
*/
|
|
133
|
-
onRowClick?: (object: Osdk.Instance<Q>) => void;
|
|
136
|
+
onRowClick?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>) => void;
|
|
134
137
|
/**
|
|
135
138
|
* Selection mode for the table rows.
|
|
136
139
|
*
|
|
137
140
|
* If multiple, a checkbox will be shown for each row to allow selecting multiple rows
|
|
138
141
|
* as well as a top-level checkbox in the header to select all rows.
|
|
142
|
+
*
|
|
143
|
+
* @default "none"
|
|
139
144
|
*/
|
|
140
145
|
selectionMode?: "single" | "multiple" | "none";
|
|
141
146
|
/**
|
|
@@ -147,12 +152,17 @@ export interface ObjectTableProps<
|
|
|
147
152
|
* Called when the row selection changes.
|
|
148
153
|
* Required when row selection is controlled.
|
|
149
154
|
*
|
|
150
|
-
* @param
|
|
155
|
+
* @param selectedRowIds The primary keys of currently selected rows
|
|
151
156
|
*/
|
|
152
|
-
onRowSelection?: (
|
|
157
|
+
onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;
|
|
153
158
|
/**
|
|
154
159
|
* If provided, will render this context menu when right clicking on a cell
|
|
155
160
|
*/
|
|
156
|
-
renderCellContextMenu?: (
|
|
161
|
+
renderCellContextMenu?: (row: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>, cellValue: unknown) => React.ReactNode;
|
|
162
|
+
/**
|
|
163
|
+
* The height of each row in pixels.
|
|
164
|
+
*
|
|
165
|
+
* @default 40
|
|
166
|
+
*/
|
|
167
|
+
rowHeight?: number;
|
|
157
168
|
}
|
|
158
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,iBACA,WACA,sBACA,MACA,gBACA,cACA,iBACA,mBACA,mBACK,WAAY;AACnB,iBAAiB,WAAW,OAAQ;AAEpC,YAAY;CACV,UAAU;CACV,aAAa,eAAe;
|
|
1
|
+
{"mappings":"AAgBA,cACE,iBACA,WACA,sBACA,MACA,gBACA,cACA,iBACA,mBACA,mBACK,WAAY;AACnB,iBAAiB,WAAW,OAAQ;AAEpC,YAAY;CACV,UAAU;CACV,aAAa,eAAe,qBAAqB;CAIjD,wBAAwB,eAAe,gBAAgB,CAAE,MAAK;IAI5D;CACF,SAAS,wBAAwB,GAAG,MAAM;;;;CAK1C;;;;CAKA,SAAS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BACEC,KAAK,KAAK,SAAS,GAAG,sBAAsB,aAAa,IAAI,OAC7DC,uBACG,MAAM;;;;;;CAOX;AACD","names":["object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>","locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>","newWhere: WhereClause<Q, RDPs>","newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>","newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>","newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>","columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns","newWidth: number","selectedRowIds: PrimaryKeyType<Q>[]","row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>","cellValue: unknown"],"sources":["../../../src/object-table/ObjectTableApi.ts"],"version":3,"file":"ObjectTableApi.d.ts"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface SelectionHeaderCellProps {
|
|
4
|
+
isAllSelected: boolean;
|
|
5
|
+
hasSelection: boolean;
|
|
6
|
+
onToggleAll: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function SelectionHeaderCell({ isAllSelected, hasSelection, onToggleAll }: SelectionHeaderCellProps): React.ReactElement;
|
|
9
|
+
interface SelectionCellProps<TData extends RowData> {
|
|
10
|
+
row: Row<TData>;
|
|
11
|
+
onToggleRow: (rowId: string, rowIndex: number, isShiftClick: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function SelectionCell<TData extends RowData>({ row, onToggleRow }: SelectionCellProps<TData>): React.ReactElement;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,KAAK,eAAe,uBAAwB;AAC1D,OAAO,WAA4B,OAAQ;UAEjC,yBAAyB;CACjC;CACA;CACA;AACD;AAED,OAAO,iBAAS,oBAAoB,EAClC,eACA,cACA,aACyB,EAAxB,2BAA2B,MAAM;UAuB1B,mBAAmB,cAAc,SAAS;CAClD,KAAK,IAAI;CACT,cAAcA,eAAeC,kBAAkBC;AAChD;AAGD,OAAO,iBAAS,cAAc,cAAc,SAAS,EACnD,KACA,aAC0B,EAAzB,mBAAmB,SAAS,MAAM","names":["rowId: string","rowIndex: number","isShiftClick: boolean"],"sources":["../../../src/object-table/SelectionCells.tsx"],"version":3,"file":"SelectionCells.d.ts"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Cell, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import React, { type ReactElement } from "react";
|
|
3
|
+
interface TableProps<TData extends RowData> {
|
|
4
|
+
table: Table<TData>;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
fetchNextPage?: () => Promise<void>;
|
|
7
|
+
onRowClick?: (row: TData) => void;
|
|
8
|
+
rowHeight?: number;
|
|
9
|
+
renderCellContextMenu?: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare function Table<TData extends RowData>({ table, isLoading, fetchNextPage, onRowClick, rowHeight, renderCellContextMenu }: TableProps<TData>): ReactElement;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,MAAM,SAAS,aAAa,uBAAwB;AAClE,OAAO,cAAc,oBAAyC,OAAQ;UAI5D,WAAW,cAAc,SAAS;CAC1C,OAAO,MAAM;CACb;CACA,sBAAsB;CACtB,cAAcA,KAAK;CACnB;CACA,yBACEA,KAAK,OACLC,MAAM,KAAK,oBACR,MAAM;AACZ;AAED,OAAO,iBAAS,MAAM,cAAc,SAClC,EACE,OACA,WACA,eACA,YACA,WACA,uBACkB,EAAjB,WAAW,SACb","names":["row: TData","cell: Cell<TData, unknown>"],"sources":["../../../src/object-table/Table.tsx"],"version":3,"file":"Table.d.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Cell, Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface TableBodyProps<TData extends RowData> {
|
|
4
|
+
rows: Array<Row<TData>>;
|
|
5
|
+
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
6
|
+
onRowClick?: (row: TData) => void;
|
|
7
|
+
rowHeight?: number;
|
|
8
|
+
renderCellContextMenu?: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function TableBody<TData extends RowData>({ rows, tableContainerRef, onRowClick, renderCellContextMenu, rowHeight }: TableBodyProps<TData>): React.ReactElement;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,MAAM,KAAK,eAAe,uBAAwB;AAEhE,OAAO,WAAgC,OAAQ;UAGrC,eAAe,cAAc,SAAS;CAC9C,MAAM,MAAM,IAAI;CAChB,mBAAmB,MAAM,UAAU;CACnC,cAAcA,KAAK;CACnB;CACA,yBACEA,KAAK,OACLC,MAAM,KAAK,oBACR,MAAM;AACZ;AAED,OAAO,iBAAS,UAAU,cAAc,SAAS,EAC/C,MACA,mBACA,YACA,uBACA,WACsB,EAArB,eAAe,SAAS,MAAM","names":["row: TData","cell: Cell<TData, unknown>"],"sources":["../../../src/object-table/TableBody.tsx"],"version":3,"file":"TableBody.d.ts"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Cell, RowData } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface TableCellProps<TData extends RowData> {
|
|
4
|
+
cell: Cell<TData, unknown>;
|
|
5
|
+
renderCellContextMenu?: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function TableCell<TData extends RowData>({ cell, renderCellContextMenu }: TableCellProps<TData>): React.ReactElement;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,MAAM,eAAe,uBAAwB;AAE3D,OAAO,WAAuB,OAAQ;UAK5B,eAAe,cAAc,SAAS;CAC9C,MAAM,KAAK;CACX,yBACEA,KAAK,OACLC,MAAM,KAAK,oBACR,MAAM;AACZ;AAED,OAAO,iBAAS,UAAU,cAAc,SACtC,EAAE,MAAM,uBAA8C,EAArB,eAAe,SAC/C,MAAM","names":["row: TData","cell: Cell<TData, unknown>"],"sources":["../../../src/object-table/TableCell.tsx"],"version":3,"file":"TableCell.d.ts"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface TableHeaderProps<TData extends RowData> {
|
|
4
|
+
table: Table<TData>;
|
|
5
|
+
}
|
|
6
|
+
export declare function TableHeader<TData extends RowData>({ table }: TableHeaderProps<TData>): React.ReactElement;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,SAAS,aAAa,uBAAwB;AAE5D,OAAO,WAAW,OAAQ;UAEhB,iBAAiB,cAAc,SAAS;CAChD,OAAO,MAAM;AACd;AAED,OAAO,iBAAS,YAAY,cAAc,SAAS,EACjD,OACwB,EAAvB,iBAAiB,SAAS,MAAM","names":[],"sources":["../../../src/object-table/TableHeader.tsx"],"version":3,"file":"TableHeader.d.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Cell, Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
import type { VirtualItem } from "@tanstack/react-virtual";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface TableRowProps<TData extends RowData> {
|
|
5
|
+
row: Row<TData>;
|
|
6
|
+
virtualRow: VirtualItem;
|
|
7
|
+
onRowClick?: (row: TData) => void;
|
|
8
|
+
renderCellContextMenu?: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function TableRow<TData extends RowData>({ row, virtualRow, onRowClick, renderCellContextMenu }: TableRowProps<TData>): React.ReactElement;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,MAAM,KAAK,eAAe,uBAAwB;AAChE,cAAc,mBAAmB,yBAA0B;AAC3D,OAAO,WAA4B,OAAQ;UAGjC,cAAc,cAAc,SAAS;CAC7C,KAAK,IAAI;CACT,YAAY;CACZ,cAAcA,KAAK;CACnB,yBACEA,KAAK,OACLC,MAAM,KAAK,oBACR,MAAM;AACZ;AAED,OAAO,iBAAS,SAAS,cAAc,SAAS,EAC9C,KACA,YACA,YACA,uBACqB,EAApB,cAAc,SAAS,MAAM","names":["row: TData","cell: Cell<TData, unknown>"],"sources":["../../../src/object-table/TableRow.tsx"],"version":3,"file":"TableRow.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../../../src/object-table/hooks/__tests__/useCellContextMenu.test.tsx"],"version":3,"file":"useCellContextMenu.test.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../../../src/object-table/hooks/__tests__/useColumnDefs.test.tsx"],"version":3,"file":"useColumnDefs.test.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../../../src/object-table/hooks/__tests__/useDefaultTableStates.test.tsx"],"version":3,"file":"useDefaultTableStates.test.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../../../src/object-table/hooks/__tests__/useObjectTableData.test.tsx"],"version":3,"file":"useObjectTableData.test.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../../../../../src/object-table/hooks/__tests__/useRowSelection.test.tsx"],"version":3,"file":"useRowSelection.test.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|