@osdk/react-components 0.0.0 → 0.1.0-beta.1
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 +29 -0
- package/README.md +56 -6
- package/build/browser/object-table/ObjectTable.js +70 -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/Table.js +77 -0
- package/build/browser/object-table/Table.js.map +1 -0
- package/build/browser/object-table/TableBody.js +54 -0
- package/build/browser/object-table/TableBody.js.map +1 -0
- package/build/browser/object-table/TableHeader.js +47 -0
- package/build/browser/object-table/TableHeader.js.map +1 -0
- package/build/browser/object-table/TableRow.js +44 -0
- package/build/browser/object-table/TableRow.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 +217 -0
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.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 +48 -0
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -0
- package/build/browser/public/experimental.js +17 -1
- package/build/browser/public/experimental.js.map +1 -1
- package/build/cjs/public/experimental.cjs +3880 -0
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +36 -9
- package/build/esm/object-table/ObjectTable.js +70 -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/Table.js +77 -0
- package/build/esm/object-table/Table.js.map +1 -0
- package/build/esm/object-table/TableBody.js +54 -0
- package/build/esm/object-table/TableBody.js.map +1 -0
- package/build/esm/object-table/TableHeader.js +47 -0
- package/build/esm/object-table/TableHeader.js.map +1 -0
- package/build/esm/object-table/TableRow.js +44 -0
- package/build/esm/object-table/TableRow.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 +217 -0
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.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 +48 -0
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -0
- package/build/esm/public/experimental.js +17 -1
- package/build/esm/public/experimental.js.map +1 -1
- 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 +27 -12
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/Table.d.ts +11 -0
- package/build/types/object-table/Table.d.ts.map +1 -0
- package/build/types/object-table/TableBody.d.ts +10 -0
- package/build/types/object-table/TableBody.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 +10 -0
- package/build/types/object-table/TableRow.d.ts.map +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/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/public/experimental.d.ts +2 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +9 -4
- package/build/browser/junk.test.js +0 -23
- package/build/browser/junk.test.js.map +0 -1
- package/build/esm/junk.test.js +0 -23
- 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__/useColumnDefs.test.d.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ObjectTypeDefinition, PropertyKeys, WirePropertyTypes, CompileTimeMetadata, ObjectSet, WhereClause, SimplePropertyDef, QueryDefinition, DerivedProperty, Osdk, PrimaryKeyType } from '@osdk/api';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Props for a single filter list item component
|
|
@@ -173,9 +174,15 @@ interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
|
173
174
|
type FilterKey<Q extends ObjectTypeDefinition> = FilterDefinition<Q>["key"];
|
|
174
175
|
type FilterState<Q extends ObjectTypeDefinition> = FilterDefinition<Q>["filterState"];
|
|
175
176
|
|
|
176
|
-
type ColumnDefinition<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef>, FunctionColumns extends Record<string, QueryDefinition<{}
|
|
177
|
+
type ColumnDefinition<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = Record<string, never>, FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>> = {
|
|
177
178
|
locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;
|
|
179
|
+
/**
|
|
180
|
+
* @default true
|
|
181
|
+
*/
|
|
178
182
|
isVisible?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* @default none
|
|
185
|
+
*/
|
|
179
186
|
pinned?: "left" | "right" | "none";
|
|
180
187
|
width?: number;
|
|
181
188
|
minWidth?: number;
|
|
@@ -183,12 +190,12 @@ type ColumnDefinition<Q extends ObjectTypeDefinition, RDPs extends Record<string
|
|
|
183
190
|
resizable?: boolean;
|
|
184
191
|
orderable?: boolean;
|
|
185
192
|
filterable?: boolean;
|
|
186
|
-
renderCell?: (object: Osdk.Instance<Q>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode;
|
|
193
|
+
renderCell?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode;
|
|
187
194
|
renderHeader?: () => React.ReactNode;
|
|
188
195
|
};
|
|
189
|
-
type ColumnDefinitionLocator<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef>, FunctionColumns extends Record<string, QueryDefinition<{}>> =
|
|
196
|
+
type ColumnDefinitionLocator<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = Record<string, never>, FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>> = {
|
|
190
197
|
type: "property";
|
|
191
|
-
|
|
198
|
+
id: PropertyKeys<Q>;
|
|
192
199
|
} | {
|
|
193
200
|
type: "function";
|
|
194
201
|
id: keyof FunctionColumns;
|
|
@@ -197,11 +204,15 @@ type ColumnDefinitionLocator<Q extends ObjectTypeDefinition, RDPs extends Record
|
|
|
197
204
|
id: keyof RDPs;
|
|
198
205
|
creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;
|
|
199
206
|
};
|
|
200
|
-
interface ObjectTableProps<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> =
|
|
207
|
+
interface ObjectTableProps<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = Record<string, never>, FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>> {
|
|
201
208
|
/**
|
|
202
209
|
* The set of objects to show in the table
|
|
203
210
|
*/
|
|
204
211
|
objectSet: ObjectSet<Q>;
|
|
212
|
+
/**
|
|
213
|
+
* The object type of the object
|
|
214
|
+
*/
|
|
215
|
+
objectType: Q;
|
|
205
216
|
/**
|
|
206
217
|
* Ordered list of column definitions to show in the table
|
|
207
218
|
*
|
|
@@ -285,13 +296,13 @@ interface ObjectTableProps<Q extends ObjectTypeDefinition, RDPs extends Record<s
|
|
|
285
296
|
* @param object The object representing the row
|
|
286
297
|
* @param columnDefinition The column definition for the clicked cell
|
|
287
298
|
*/
|
|
288
|
-
onCellClick?: (object: Osdk.Instance<Q>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => void;
|
|
299
|
+
onCellClick?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => void;
|
|
289
300
|
/**
|
|
290
301
|
* Called when a row is clicked.
|
|
291
302
|
*
|
|
292
303
|
* @param object The object representing the clicked row
|
|
293
304
|
*/
|
|
294
|
-
onRowClick?: (object: Osdk.Instance<Q>) => void;
|
|
305
|
+
onRowClick?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>) => void;
|
|
295
306
|
/**
|
|
296
307
|
* Selection mode for the table rows.
|
|
297
308
|
*
|
|
@@ -314,7 +325,23 @@ interface ObjectTableProps<Q extends ObjectTypeDefinition, RDPs extends Record<s
|
|
|
314
325
|
/**
|
|
315
326
|
* If provided, will render this context menu when right clicking on a cell
|
|
316
327
|
*/
|
|
317
|
-
renderCellContextMenu?: (object: Osdk.Instance<Q>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode;
|
|
328
|
+
renderCellContextMenu?: (object: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>, locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>) => React.ReactNode;
|
|
329
|
+
/**
|
|
330
|
+
* The height of each row in pixels.
|
|
331
|
+
*
|
|
332
|
+
* @default 40
|
|
333
|
+
*/
|
|
334
|
+
rowHeight?: number;
|
|
318
335
|
}
|
|
319
336
|
|
|
320
|
-
|
|
337
|
+
/**
|
|
338
|
+
* ObjectTable - A headless table component for displaying OSDK object sets
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```tsx
|
|
342
|
+
* <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
declare function ObjectTable<Q extends ObjectTypeDefinition, RDPs extends Record<string, SimplePropertyDef> = Record<string, never>, FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<string, never>>({ objectSet, objectType, columnDefinitions, onRowClick, rowHeight, }: ObjectTableProps<Q, RDPs, FunctionColumns>): React__default.ReactElement;
|
|
346
|
+
|
|
347
|
+
export { type ColumnDefinition, type ColumnDefinitionLocator, type FilterListItemProps, type FilterListProps, ObjectTable, type ObjectTableProps };
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
|
18
|
+
import React from "react";
|
|
19
|
+
import { useColumnDefs } from "./hooks/useColumnDefs.js";
|
|
20
|
+
import { useDefaultTableStates } from "./hooks/useDefaultTableStates.js";
|
|
21
|
+
import { useObjectTableData } from "./hooks/useObjectTableData.js";
|
|
22
|
+
import { Table } from "./Table.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* ObjectTable - A headless table component for displaying OSDK object sets
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export function ObjectTable({
|
|
34
|
+
objectSet,
|
|
35
|
+
objectType,
|
|
36
|
+
columnDefinitions,
|
|
37
|
+
onRowClick,
|
|
38
|
+
rowHeight
|
|
39
|
+
}) {
|
|
40
|
+
const {
|
|
41
|
+
data,
|
|
42
|
+
fetchMore,
|
|
43
|
+
isLoading
|
|
44
|
+
} = useObjectTableData(objectSet, columnDefinitions);
|
|
45
|
+
const {
|
|
46
|
+
columns,
|
|
47
|
+
loading: isColumnsLoading
|
|
48
|
+
} = useColumnDefs(objectType, columnDefinitions);
|
|
49
|
+
const {
|
|
50
|
+
columnVisibility
|
|
51
|
+
} = useDefaultTableStates({
|
|
52
|
+
columnDefinitions
|
|
53
|
+
});
|
|
54
|
+
const table = useReactTable({
|
|
55
|
+
data: data ?? [],
|
|
56
|
+
columns,
|
|
57
|
+
getCoreRowModel: getCoreRowModel(),
|
|
58
|
+
state: {
|
|
59
|
+
columnVisibility
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/React.createElement(Table, {
|
|
63
|
+
table: table,
|
|
64
|
+
isLoading: isLoading || isColumnsLoading,
|
|
65
|
+
fetchNextPage: fetchMore,
|
|
66
|
+
onRowClick: onRowClick,
|
|
67
|
+
rowHeight: rowHeight
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=ObjectTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useColumnDefs","useDefaultTableStates","useObjectTableData","Table","ObjectTable","objectSet","objectType","columnDefinitions","onRowClick","rowHeight","data","fetchMore","isLoading","columns","loading","isColumnsLoading","columnVisibility","table","state","createElement","fetchNextPage"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useDefaultTableStates } from \"./hooks/useDefaultTableStates.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { Table } from \"./Table.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectSet,\n objectType,\n columnDefinitions,\n onRowClick,\n rowHeight,\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { data, fetchMore, isLoading } = useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectSet,\n columnDefinitions,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const { columnVisibility } = useDefaultTableStates({ columnDefinitions });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n },\n });\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n return (\n <Table\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,KAAK,QAAQ,YAAY;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,SAAS;EACTC,UAAU;EACVC,iBAAiB;EACjBC,UAAU;EACVC;AAC0C,CAAC,EAAsB;EACjE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGV,kBAAkB,CAKvDG,SAAS,EACTE,iBACF,CAAC;EAED,MAAM;IAAEM,OAAO;IAAEC,OAAO,EAAEC;EAAiB,CAAC,GAAGf,aAAa,CAK1DM,UAAU,EACVC,iBACF,CAAC;EAED,MAAM;IAAES;EAAiB,CAAC,GAAGf,qBAAqB,CAAC;IAAEM;EAAkB,CAAC,CAAC;EAEzE,MAAMU,KAAK,GAAGnB,aAAa,CAEzB;IACAY,IAAI,EAAEA,IAAI,IAAI,EAAE;IAChBG,OAAO;IACPhB,eAAe,EAAEA,eAAe,CAAC,CAAC;IAClCqB,KAAK,EAAE;MACLF;IACF;EACF,CAAC,CAAC;EAIF,oBACEjB,KAAA,CAAAoB,aAAA,CAAChB,KAAK;IACJc,KAAK,EAAEA,KAAM;IACbL,SAAS,EALUA,SAAS,IAAIG,gBAKN;IAC1BK,aAAa,EAAET,SAAU;IACzBH,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\n\nexport type ColumnDefinition<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n FunctionColumns extends Record<string, QueryDefinition<{}
|
|
1
|
+
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\n\nexport type ColumnDefinition<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | {\n type: \"property\";\n id: PropertyKeys<Q>;\n }\n | {\n type: \"function\";\n id: keyof FunctionColumns;\n }\n | {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n };\n\nexport interface ObjectTableProps<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The set of objects to show in the table\n */\n objectSet: ObjectSet<Q>;\n\n /**\n * The object type of the object\n */\n objectType: Q;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n filterable?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n orderable?: boolean;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called when the visible columns change.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The new list of column visibility states\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number,\n ) => void;\n\n /**\n * Called when a cell is clicked.\n *\n * @param object The object representing the row\n * @param columnDefinition The column definition for the clicked cell\n */\n onCellClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param objects The currently selected objects\n */\n onRowSelection?: (objects: PrimaryKeyType<Q>[]) => void;\n\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
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, { useCallback, useRef } from "react";
|
|
18
|
+
import { TableBody } from "./TableBody.js";
|
|
19
|
+
import { TableHeader } from "./TableHeader.js";
|
|
20
|
+
export function Table({
|
|
21
|
+
table,
|
|
22
|
+
isLoading,
|
|
23
|
+
fetchNextPage,
|
|
24
|
+
onRowClick,
|
|
25
|
+
rowHeight
|
|
26
|
+
}) {
|
|
27
|
+
const tableContainerRef = useRef(null);
|
|
28
|
+
|
|
29
|
+
// Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight
|
|
30
|
+
const fetchingRef = useRef(false);
|
|
31
|
+
const fetchMoreOnEndReached = useCallback(async containerRefElement => {
|
|
32
|
+
if (containerRefElement && !fetchingRef.current) {
|
|
33
|
+
const {
|
|
34
|
+
scrollHeight,
|
|
35
|
+
scrollTop,
|
|
36
|
+
clientHeight
|
|
37
|
+
} = containerRefElement;
|
|
38
|
+
if (scrollHeight - scrollTop - clientHeight < 100 && !isLoading) {
|
|
39
|
+
fetchingRef.current = true;
|
|
40
|
+
try {
|
|
41
|
+
await fetchNextPage?.();
|
|
42
|
+
} finally {
|
|
43
|
+
fetchingRef.current = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [fetchNextPage, isLoading]);
|
|
48
|
+
const handleScroll = useCallback(async e => {
|
|
49
|
+
await fetchMoreOnEndReached(e.currentTarget);
|
|
50
|
+
}, [fetchMoreOnEndReached]);
|
|
51
|
+
|
|
52
|
+
// TODO: Handle error, loading and empty states
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
ref: tableContainerRef,
|
|
56
|
+
style: {
|
|
57
|
+
position: "relative",
|
|
58
|
+
// needed for sticky header
|
|
59
|
+
height: "100%",
|
|
60
|
+
// needed for scrolling
|
|
61
|
+
overflow: "auto"
|
|
62
|
+
},
|
|
63
|
+
onScroll: handleScroll
|
|
64
|
+
}, /*#__PURE__*/React.createElement("table", {
|
|
65
|
+
style: {
|
|
66
|
+
display: "grid"
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
69
|
+
headerGroups: table.getHeaderGroups()
|
|
70
|
+
}), /*#__PURE__*/React.createElement(TableBody, {
|
|
71
|
+
rows: table.getRowModel().rows,
|
|
72
|
+
tableContainerRef: tableContainerRef,
|
|
73
|
+
onRowClick: onRowClick,
|
|
74
|
+
rowHeight: rowHeight
|
|
75
|
+
})));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","names":["React","useCallback","useRef","TableBody","TableHeader","Table","table","isLoading","fetchNextPage","onRowClick","rowHeight","tableContainerRef","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","createElement","ref","style","position","height","overflow","onScroll","display","headerGroups","getHeaderGroups","rows","getRowModel"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RowData, Table } from \"@tanstack/react-table\";\nimport React, { type ReactElement, useCallback, useRef } from \"react\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableHeader } from \"./TableHeader.js\";\n\ninterface TableProps<TData extends RowData> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n}\n\nexport function Table<TData extends RowData>(\n { table, isLoading, fetchNextPage, onRowClick, rowHeight }: TableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading\n ) {\n fetchingRef.current = true;\n try {\n await fetchNextPage?.();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n // TODO: Handle error, loading and empty states\n\n return (\n <div\n ref={tableContainerRef}\n style={{\n position: \"relative\", // needed for sticky header\n height: \"100%\", // needed for scrolling\n overflow: \"auto\",\n }}\n onScroll={handleScroll}\n >\n <table\n style={{ display: \"grid\" }}\n >\n <TableHeader headerGroups={table.getHeaderGroups()} />\n <TableBody\n rows={table.getRowModel().rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n />\n </table>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAuBC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AACrE,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAU9C,OAAO,SAASC,KAAKA,CACnB;EAAEC,KAAK;EAAEC,SAAS;EAAEC,aAAa;EAAEC,UAAU;EAAEC;AAA6B,CAAC,EAC/D;EACd,MAAMC,iBAAiB,GAAGT,MAAM,CAAiB,IAAI,CAAC;;EAEtD;EACA,MAAMU,WAAW,GAAGV,MAAM,CAAC,KAAK,CAAC;EAEjC,MAAMW,qBAAqB,GAAGZ,WAAW,CACvC,MAAOa,mBAA2C,IAAK;IACrD,IAAIA,mBAAmB,IAAI,CAACF,WAAW,CAACG,OAAO,EAAE;MAC/C,MAAM;QAAEC,YAAY;QAAEC,SAAS;QAAEC;MAAa,CAAC,GAAGJ,mBAAmB;MACrE,IACEE,YAAY,GAAGC,SAAS,GAAGC,YAAY,GAAG,GAAG,IAC1C,CAACX,SAAS,EACb;QACAK,WAAW,CAACG,OAAO,GAAG,IAAI;QAC1B,IAAI;UACF,MAAMP,aAAa,GAAG,CAAC;QACzB,CAAC,SAAS;UACRI,WAAW,CAACG,OAAO,GAAG,KAAK;QAC7B;MACF;IACF;EACF,CAAC,EACD,CAACP,aAAa,EAAED,SAAS,CAC3B,CAAC;EAED,MAAMY,YAAY,GAAGlB,WAAW,CAC9B,MAAOmB,CAAgC,IAAK;IAC1C,MAAMP,qBAAqB,CAACO,CAAC,CAACC,aAAa,CAAC;EAC9C,CAAC,EACD,CAACR,qBAAqB,CACxB,CAAC;;EAED;;EAEA,oBACEb,KAAA,CAAAsB,aAAA;IACEC,GAAG,EAAEZ,iBAAkB;IACvBa,KAAK,EAAE;MACLC,QAAQ,EAAE,UAAU;MAAE;MACtBC,MAAM,EAAE,MAAM;MAAE;MAChBC,QAAQ,EAAE;IACZ,CAAE;IACFC,QAAQ,EAAET;EAAa,gBAEvBnB,KAAA,CAAAsB,aAAA;IACEE,KAAK,EAAE;MAAEK,OAAO,EAAE;IAAO;EAAE,gBAE3B7B,KAAA,CAAAsB,aAAA,CAAClB,WAAW;IAAC0B,YAAY,EAAExB,KAAK,CAACyB,eAAe,CAAC;EAAE,CAAE,CAAC,eACtD/B,KAAA,CAAAsB,aAAA,CAACnB,SAAS;IACR6B,IAAI,EAAE1B,KAAK,CAAC2B,WAAW,CAAC,CAAC,CAACD,IAAK;IAC/BrB,iBAAiB,EAAEA,iBAAkB;IACrCF,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA;EAAU,CACtB,CACI,CACJ,CAAC;AAEV","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { useVirtualizer } from "@tanstack/react-virtual";
|
|
18
|
+
import React, { useLayoutEffect } from "react";
|
|
19
|
+
import { TableRow } from "./TableRow.js";
|
|
20
|
+
export function TableBody({
|
|
21
|
+
rows,
|
|
22
|
+
tableContainerRef,
|
|
23
|
+
onRowClick,
|
|
24
|
+
rowHeight = 40
|
|
25
|
+
}) {
|
|
26
|
+
// Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.
|
|
27
|
+
const rowVirtualizer = useVirtualizer({
|
|
28
|
+
count: rows.length,
|
|
29
|
+
estimateSize: () => rowHeight,
|
|
30
|
+
getScrollElement: () => tableContainerRef.current,
|
|
31
|
+
overscan: 5
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Measure the virtualizer after the DOM has been laid out to ensure proper dimensions
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
rowVirtualizer.measure();
|
|
37
|
+
}, [rowVirtualizer, rows.length]);
|
|
38
|
+
return /*#__PURE__*/React.createElement("tbody", {
|
|
39
|
+
style: {
|
|
40
|
+
display: "grid",
|
|
41
|
+
position: "relative",
|
|
42
|
+
height: `${rowVirtualizer.getTotalSize()}px`
|
|
43
|
+
}
|
|
44
|
+
}, rowVirtualizer.getVirtualItems().map(virtualRow => {
|
|
45
|
+
const row = rows[virtualRow.index];
|
|
46
|
+
return /*#__PURE__*/React.createElement(TableRow, {
|
|
47
|
+
key: row.id,
|
|
48
|
+
row: row,
|
|
49
|
+
virtualRow: virtualRow,
|
|
50
|
+
onRowClick: onRowClick
|
|
51
|
+
});
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=TableBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.js","names":["useVirtualizer","React","useLayoutEffect","TableRow","TableBody","rows","tableContainerRef","onRowClick","rowHeight","rowVirtualizer","count","length","estimateSize","getScrollElement","current","overscan","measure","createElement","style","display","position","height","getTotalSize","getVirtualItems","map","virtualRow","row","index","key","id"],"sources":["TableBody.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Row, RowData } from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useLayoutEffect } from \"react\";\nimport { TableRow } from \"./TableRow.js\";\n\ninterface TableBodyProps<TData extends RowData> {\n rows: Array<Row<TData>>;\n tableContainerRef: React.RefObject<HTMLDivElement>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n}\n\nexport function TableBody<TData extends RowData>({\n rows,\n tableContainerRef,\n onRowClick,\n rowHeight = 40,\n}: TableBodyProps<TData>): React.ReactElement {\n // Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.\n const rowVirtualizer = useVirtualizer<HTMLDivElement, HTMLTableRowElement>({\n count: rows.length,\n estimateSize: () => rowHeight,\n getScrollElement: () => tableContainerRef.current,\n overscan: 5,\n });\n\n // Measure the virtualizer after the DOM has been laid out to ensure proper dimensions\n useLayoutEffect(() => {\n rowVirtualizer.measure();\n }, [rowVirtualizer, rows.length]);\n\n return (\n <tbody\n style={{\n display: \"grid\",\n position: \"relative\",\n height: `${rowVirtualizer.getTotalSize()}px`,\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n\n return (\n <TableRow\n key={row.id}\n row={row}\n virtualRow={virtualRow}\n onRowClick={onRowClick}\n />\n );\n })}\n </tbody>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,yBAAyB;AACxD,OAAOC,KAAK,IAAIC,eAAe,QAAQ,OAAO;AAC9C,SAASC,QAAQ,QAAQ,eAAe;AASxC,OAAO,SAASC,SAASA,CAAwB;EAC/CC,IAAI;EACJC,iBAAiB;EACjBC,UAAU;EACVC,SAAS,GAAG;AACS,CAAC,EAAsB;EAC5C;EACA,MAAMC,cAAc,GAAGT,cAAc,CAAsC;IACzEU,KAAK,EAAEL,IAAI,CAACM,MAAM;IAClBC,YAAY,EAAEA,CAAA,KAAMJ,SAAS;IAC7BK,gBAAgB,EAAEA,CAAA,KAAMP,iBAAiB,CAACQ,OAAO;IACjDC,QAAQ,EAAE;EACZ,CAAC,CAAC;;EAEF;EACAb,eAAe,CAAC,MAAM;IACpBO,cAAc,CAACO,OAAO,CAAC,CAAC;EAC1B,CAAC,EAAE,CAACP,cAAc,EAAEJ,IAAI,CAACM,MAAM,CAAC,CAAC;EAEjC,oBACEV,KAAA,CAAAgB,aAAA;IACEC,KAAK,EAAE;MACLC,OAAO,EAAE,MAAM;MACfC,QAAQ,EAAE,UAAU;MACpBC,MAAM,EAAE,GAAGZ,cAAc,CAACa,YAAY,CAAC,CAAC;IAC1C;EAAE,GAEDb,cAAc,CAACc,eAAe,CAAC,CAAC,CAACC,GAAG,CAAEC,UAAU,IAAK;IACpD,MAAMC,GAAG,GAAGrB,IAAI,CAACoB,UAAU,CAACE,KAAK,CAAC;IAElC,oBACE1B,KAAA,CAAAgB,aAAA,CAACd,QAAQ;MACPyB,GAAG,EAAEF,GAAG,CAACG,EAAG;MACZH,GAAG,EAAEA,GAAI;MACTD,UAAU,EAAEA,UAAW;MACvBlB,UAAU,EAAEA;IAAW,CACxB,CAAC;EAEN,CAAC,CACI,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { flexRender } from "@tanstack/react-table";
|
|
18
|
+
import React from "react";
|
|
19
|
+
export function TableHeader({
|
|
20
|
+
headerGroups
|
|
21
|
+
}) {
|
|
22
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
23
|
+
style: {
|
|
24
|
+
display: "grid",
|
|
25
|
+
position: "sticky",
|
|
26
|
+
top: 0,
|
|
27
|
+
zIndex: 1
|
|
28
|
+
}
|
|
29
|
+
}, headerGroups.map(headerGroup => /*#__PURE__*/React.createElement("tr", {
|
|
30
|
+
key: headerGroup.id,
|
|
31
|
+
style: {
|
|
32
|
+
display: "flex"
|
|
33
|
+
}
|
|
34
|
+
}, headerGroup.headers.map(header =>
|
|
35
|
+
/*#__PURE__*/
|
|
36
|
+
// TODO: Move inline styling to CSS file
|
|
37
|
+
React.createElement("th", {
|
|
38
|
+
key: header.id,
|
|
39
|
+
style: {
|
|
40
|
+
display: "flex",
|
|
41
|
+
width: header.getSize(),
|
|
42
|
+
justifyContent: "flex-start",
|
|
43
|
+
alignItems: "center"
|
|
44
|
+
}
|
|
45
|
+
}, header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()))))));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=TableHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHeader.js","names":["flexRender","React","TableHeader","headerGroups","createElement","style","display","position","top","zIndex","map","headerGroup","key","id","headers","header","width","getSize","justifyContent","alignItems","isPlaceholder","column","columnDef","getContext"],"sources":["TableHeader.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HeaderGroup, RowData } from \"@tanstack/react-table\";\nimport { flexRender } from \"@tanstack/react-table\";\nimport React from \"react\";\n\ninterface TableHeaderProps<TData extends RowData> {\n headerGroups: Array<HeaderGroup<TData>>;\n}\n\nexport function TableHeader<TData extends RowData>({\n headerGroups,\n}: TableHeaderProps<TData>): React.ReactElement {\n return (\n <thead\n style={{\n display: \"grid\",\n position: \"sticky\",\n top: 0,\n zIndex: 1,\n }}\n >\n {headerGroups.map((headerGroup) => (\n <tr\n key={headerGroup.id}\n style={{\n display: \"flex\",\n }}\n >\n {headerGroup.headers.map((header) => (\n // TODO: Move inline styling to CSS file\n <th\n key={header.id}\n style={{\n display: \"flex\",\n width: header.getSize(),\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n }}\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </th>\n ))}\n </tr>\n ))}\n </thead>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,OAAOC,KAAK,MAAM,OAAO;AAMzB,OAAO,SAASC,WAAWA,CAAwB;EACjDC;AACuB,CAAC,EAAsB;EAC9C,oBACEF,KAAA,CAAAG,aAAA;IACEC,KAAK,EAAE;MACLC,OAAO,EAAE,MAAM;MACfC,QAAQ,EAAE,QAAQ;MAClBC,GAAG,EAAE,CAAC;MACNC,MAAM,EAAE;IACV;EAAE,GAEDN,YAAY,CAACO,GAAG,CAAEC,WAAW,iBAC5BV,KAAA,CAAAG,aAAA;IACEQ,GAAG,EAAED,WAAW,CAACE,EAAG;IACpBR,KAAK,EAAE;MACLC,OAAO,EAAE;IACX;EAAE,GAEDK,WAAW,CAACG,OAAO,CAACJ,GAAG,CAAEK,MAAM;EAAA;EAC9B;EACAd,KAAA,CAAAG,aAAA;IACEQ,GAAG,EAAEG,MAAM,CAACF,EAAG;IACfR,KAAK,EAAE;MACLC,OAAO,EAAE,MAAM;MACfU,KAAK,EAAED,MAAM,CAACE,OAAO,CAAC,CAAC;MACvBC,cAAc,EAAE,YAAY;MAC5BC,UAAU,EAAE;IACd;EAAE,GAEDJ,MAAM,CAACK,aAAa,GACjB,IAAI,GACJpB,UAAU,CACVe,MAAM,CAACM,MAAM,CAACC,SAAS,CAACP,MAAM,EAC9BA,MAAM,CAACQ,UAAU,CAAC,CACpB,CACA,CACL,CACC,CACL,CACI,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { flexRender } from "@tanstack/react-table";
|
|
18
|
+
import React, { useCallback } from "react";
|
|
19
|
+
export function TableRow({
|
|
20
|
+
row,
|
|
21
|
+
virtualRow,
|
|
22
|
+
onRowClick
|
|
23
|
+
}) {
|
|
24
|
+
const handleClick = useCallback(() => {
|
|
25
|
+
onRowClick?.(row.original);
|
|
26
|
+
}, [onRowClick, row.original]);
|
|
27
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
28
|
+
style: {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
height: `${virtualRow.size}px`,
|
|
31
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
32
|
+
display: "flex"
|
|
33
|
+
},
|
|
34
|
+
onClick: handleClick
|
|
35
|
+
}, row.getVisibleCells().map(cell => /*#__PURE__*/React.createElement("td", {
|
|
36
|
+
key: cell.id,
|
|
37
|
+
style: {
|
|
38
|
+
display: "flex",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
width: cell.column.getSize()
|
|
41
|
+
}
|
|
42
|
+
}, flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=TableRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRow.js","names":["flexRender","React","useCallback","TableRow","row","virtualRow","onRowClick","handleClick","original","createElement","style","position","height","size","transform","start","display","onClick","getVisibleCells","map","cell","key","id","alignItems","width","column","getSize","columnDef","getContext"],"sources":["TableRow.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 { Row, RowData } from \"@tanstack/react-table\";\nimport { flexRender } from \"@tanstack/react-table\";\nimport type { VirtualItem } from \"@tanstack/react-virtual\";\nimport React, { useCallback } from \"react\";\n\ninterface TableRowProps<TData extends RowData> {\n row: Row<TData>;\n virtualRow: VirtualItem;\n onRowClick?: (row: TData) => void;\n}\n\nexport function TableRow<TData extends RowData>({\n row,\n virtualRow,\n onRowClick,\n}: TableRowProps<TData>): React.ReactElement {\n const handleClick = useCallback(() => {\n onRowClick?.(row.original);\n }, [onRowClick, row.original]);\n\n return (\n <tr\n style={{\n position: \"absolute\",\n height: `${virtualRow.size}px`,\n transform: `translateY(${virtualRow.start}px)`,\n display: \"flex\",\n }}\n onClick={handleClick}\n >\n {row.getVisibleCells().map((cell) => (\n <td\n key={cell.id}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n width: cell.column.getSize(),\n }}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n ))}\n </tr>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,uBAAuB;AAElD,OAAOC,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAQ1C,OAAO,SAASC,QAAQA,CAAwB;EAC9CC,GAAG;EACHC,UAAU;EACVC;AACoB,CAAC,EAAsB;EAC3C,MAAMC,WAAW,GAAGL,WAAW,CAAC,MAAM;IACpCI,UAAU,GAAGF,GAAG,CAACI,QAAQ,CAAC;EAC5B,CAAC,EAAE,CAACF,UAAU,EAAEF,GAAG,CAACI,QAAQ,CAAC,CAAC;EAE9B,oBACEP,KAAA,CAAAQ,aAAA;IACEC,KAAK,EAAE;MACLC,QAAQ,EAAE,UAAU;MACpBC,MAAM,EAAE,GAAGP,UAAU,CAACQ,IAAI,IAAI;MAC9BC,SAAS,EAAE,cAAcT,UAAU,CAACU,KAAK,KAAK;MAC9CC,OAAO,EAAE;IACX,CAAE;IACFC,OAAO,EAAEV;EAAY,GAEpBH,GAAG,CAACc,eAAe,CAAC,CAAC,CAACC,GAAG,CAAEC,IAAI,iBAC9BnB,KAAA,CAAAQ,aAAA;IACEY,GAAG,EAAED,IAAI,CAACE,EAAG;IACbZ,KAAK,EAAE;MACLM,OAAO,EAAE,MAAM;MACfO,UAAU,EAAE,QAAQ;MACpBC,KAAK,EAAEJ,IAAI,CAACK,MAAM,CAACC,OAAO,CAAC;IAC7B;EAAE,GAED1B,UAAU,CAACoB,IAAI,CAACK,MAAM,CAACE,SAAS,CAACP,IAAI,EAAEA,IAAI,CAACQ,UAAU,CAAC,CAAC,CACvD,CACL,CACC,CAAC;AAET","ignoreList":[]}
|