@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":[]}
|