@osdk/react-components 0.20.0-main-4e2a115a796e8664c3972548bb02e707baafa912 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -10
- package/build/browser/object-table/ObjectTable.js +2 -1
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/hooks/useObjectTableData.js +5 -3
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewer.js +4 -6
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfAnnotationOverlay.js +43 -0
- package/build/browser/pdf-viewer/components/PdfAnnotationOverlay.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +22 -14
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +4 -6
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js +83 -13
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -1
- package/build/browser/pdf-viewer/types.js.map +1 -1
- package/build/browser/shared/calendar/DatePickerCommon.module.css +5 -0
- package/build/browser/styles.css +5 -0
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/chunk-2GAPPUP5.cjs +11 -0
- package/build/cjs/{chunk-BN5MGNSI.cjs.map → chunk-2GAPPUP5.cjs.map} +1 -1
- package/build/cjs/{chunk-QYUADULX.cjs → chunk-4MGATUJ3.cjs} +17 -17
- package/build/cjs/{chunk-QYUADULX.cjs.map → chunk-4MGATUJ3.cjs.map} +1 -1
- package/build/cjs/{chunk-HOPH2463.cjs → chunk-4WDDVYWV.cjs} +3 -3
- package/build/cjs/chunk-4WDDVYWV.cjs.map +1 -0
- package/build/cjs/chunk-5UTN55T6.cjs +11 -0
- package/build/cjs/{chunk-LLGHXDSY.cjs.map → chunk-5UTN55T6.cjs.map} +1 -1
- package/build/cjs/{chunk-YWDLYGD5.cjs → chunk-AICPFRJQ.cjs} +32 -32
- package/build/cjs/{chunk-YWDLYGD5.cjs.map → chunk-AICPFRJQ.cjs.map} +1 -1
- package/build/cjs/{chunk-WYIUQ3FZ.cjs → chunk-DAHWLFFD.cjs} +4 -4
- package/build/cjs/{chunk-WYIUQ3FZ.cjs.map → chunk-DAHWLFFD.cjs.map} +1 -1
- package/build/cjs/{chunk-ETOC4FJE.cjs → chunk-FWZS3WQ4.cjs} +135 -34
- package/build/cjs/chunk-FWZS3WQ4.cjs.map +1 -0
- package/build/cjs/{chunk-67LMSFXM.cjs → chunk-GUBIWML7.cjs} +16 -13
- package/build/cjs/chunk-GUBIWML7.cjs.map +1 -0
- package/build/cjs/chunk-KLL6MAZL.cjs +11 -0
- package/build/cjs/{chunk-YWYFWFUF.cjs.map → chunk-KLL6MAZL.cjs.map} +1 -1
- package/build/cjs/{chunk-7CYKOZFL.cjs → chunk-LIF2LJ2I.cjs} +7 -7
- package/build/cjs/{chunk-7CYKOZFL.cjs.map → chunk-LIF2LJ2I.cjs.map} +1 -1
- package/build/cjs/{chunk-4JJP3RNQ.cjs → chunk-PPQSIR4K.cjs} +4 -4
- package/build/cjs/{chunk-4JJP3RNQ.cjs.map → chunk-PPQSIR4K.cjs.map} +1 -1
- package/build/cjs/{chunk-4V245Z6A.cjs → chunk-PWXV5SBK.cjs} +26 -28
- package/build/cjs/chunk-PWXV5SBK.cjs.map +1 -0
- package/build/cjs/chunk-UJKIIMIE.cjs +11 -0
- package/build/cjs/{chunk-DCRVOHKP.cjs.map → chunk-UJKIIMIE.cjs.map} +1 -1
- package/build/cjs/chunk-VBM5GWFP.cjs +11 -0
- package/build/cjs/{chunk-LGUTBX34.cjs.map → chunk-VBM5GWFP.cjs.map} +1 -1
- package/build/cjs/{chunk-4KC5U44T.cjs → chunk-XA3S7YAO.cjs} +2 -2
- package/build/cjs/chunk-XA3S7YAO.cjs.map +1 -0
- package/build/cjs/{chunk-GN3PIYGH.cjs → chunk-Y6BGC7DP.cjs} +22 -22
- package/build/cjs/{chunk-GN3PIYGH.cjs.map → chunk-Y6BGC7DP.cjs.map} +1 -1
- package/build/cjs/public/experimental/action-form.cjs +6 -6
- package/build/cjs/public/experimental/action-form.css +3 -0
- package/build/cjs/public/experimental/action-form.css.map +1 -1
- package/build/cjs/public/experimental/document-viewer.cjs +5 -5
- package/build/cjs/public/experimental/document-viewer.d.cts +1 -1
- package/build/cjs/public/experimental/email-viewer.cjs +3 -3
- package/build/cjs/public/experimental/excel-viewer.cjs +3 -3
- package/build/cjs/public/experimental/filter-list.cjs +15 -15
- package/build/cjs/public/experimental/filter-list.css +3 -0
- package/build/cjs/public/experimental/filter-list.css.map +1 -1
- package/build/cjs/public/experimental/image-viewer.cjs +3 -3
- package/build/cjs/public/experimental/markdown-renderer.cjs +3 -3
- package/build/cjs/public/experimental/object-table.cjs +10 -10
- package/build/cjs/public/experimental/object-table.css +3 -0
- package/build/cjs/public/experimental/object-table.css.map +1 -1
- package/build/cjs/public/experimental/object-table.d.cts +14 -1
- package/build/cjs/public/experimental/pdf-viewer.cjs +25 -25
- package/build/cjs/public/experimental/pdf-viewer.d.cts +9 -4
- package/build/cjs/public/experimental/tiff-renderer.cjs +3 -3
- package/build/cjs/public/experimental/video-viewer.cjs +3 -3
- package/build/cjs/public/experimental/xml-viewer.cjs +3 -3
- package/build/cjs/public/experimental.cjs +67 -67
- package/build/cjs/public/experimental.css +3 -0
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +1 -1
- package/build/cjs/{types-CbSNeyzw.d.cts → types-Cg_LdKf-.d.cts} +1 -0
- package/build/esm/object-table/ObjectTable.js +2 -1
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/hooks/useObjectTableData.js +5 -3
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewer.js +4 -6
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfAnnotationOverlay.js +43 -0
- package/build/esm/pdf-viewer/components/PdfAnnotationOverlay.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +22 -14
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +4 -6
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js +83 -13
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationPortals.js.map +1 -1
- package/build/esm/pdf-viewer/types.js.map +1 -1
- package/build/esm/shared/calendar/DatePickerCommon.module.css +5 -0
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/object-table/ObjectTable.d.ts +1 -1
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +13 -0
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts +1 -1
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfAnnotationOverlay.d.ts +9 -0
- package/build/types/pdf-viewer/components/PdfAnnotationOverlay.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts +2 -1
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts +5 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationPortals.d.ts.map +1 -1
- package/build/types/pdf-viewer/types.d.ts +1 -0
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/docs/GettingStarted.md +65 -0
- package/docs/ObjectTable.md +6 -5
- package/docs/Prerequisites.md +1 -2
- package/docs/StylingOverview.md +146 -0
- package/docs/TokenColors.md +130 -0
- package/docs/TokenSpacing.md +73 -0
- package/docs/TokenTypography.md +57 -0
- package/docs/UsageWithOsdk.md +47 -0
- package/docs/Welcome.md +42 -0
- package/package.json +8 -8
- package/build/cjs/chunk-4KC5U44T.cjs.map +0 -1
- package/build/cjs/chunk-4V245Z6A.cjs.map +0 -1
- package/build/cjs/chunk-67LMSFXM.cjs.map +0 -1
- package/build/cjs/chunk-BN5MGNSI.cjs +0 -11
- package/build/cjs/chunk-DCRVOHKP.cjs +0 -11
- package/build/cjs/chunk-ETOC4FJE.cjs.map +0 -1
- package/build/cjs/chunk-HOPH2463.cjs.map +0 -1
- package/build/cjs/chunk-LGUTBX34.cjs +0 -11
- package/build/cjs/chunk-LLGHXDSY.cjs +0 -11
- package/build/cjs/chunk-YWYFWFUF.cjs +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
-
## 0.20.0
|
|
3
|
+
## 0.20.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- 2c491f4: filter-list: forward formatDate to single-date, multi-date, and timeline inputs so date formatting is consistent across all date-typed filters
|
|
7
8
|
- dfc4226: `FilterList` now supports combining linked-property and direct-property filters via a single objectSet. Pass the unfiltered scope as `objectSet` and the new `onEffectiveObjectSet` observer receives the fully-narrowed `ObjectSet` (direct + linked filters applied) on every filter change. Adds optional `LinkedPropertyFilterDefinition.reverseLinkName` (opt-in: set it to make the filter narrow `objectSet` via a pivot round-trip; omit it for UI-only behavior) and `showFilteredOutValues`, which renders count=0 greyed-out rows for values present in the unfiltered scope but absent under an active filter. Filtered-out rows apply symmetrically to both direct-property facets (Listogram, MultiSelect, SingleSelect) and linked-property facets configured with `MULTI_SELECT` / `SINGLE_SELECT` / `LISTOGRAM` sub-components.
|
|
8
9
|
|
|
9
10
|
Existing `filterClause` / `onFilterClauseChanged` props still work and continue to emit a `WhereClause<Q>` covering direct filters (LINKED_PROPERTY narrowing cannot be expressed as a `WhereClause<Q>` and surfaces only through `onEffectiveObjectSet`). Linked filters are composed via the new exported `narrowObjectSet(objectSet, whereClause, linkedFilters)` helper for consumers building their own headless pipelines.
|
|
@@ -16,16 +17,7 @@
|
|
|
16
17
|
• new `searchField` flag on `FilterDefinition` hides the header monocle for filters that already have their own inline search (e.g. `MULTI_SELECT`)
|
|
17
18
|
• extracted reusable helpers `toggleIsExcluding`, `clearFilterState`, `filterHasActiveState`, `getEffectiveFilterState`, and `getSelectedCount` from inline component logic into `filterValues.ts`
|
|
18
19
|
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- 2c491f4: filter-list: forward formatDate to single-date, multi-date, and timeline inputs so date formatting is consistent across all date-typed filters
|
|
22
20
|
- 7f8e93b: thread `renderValue` through `LinkedPropertyFilter` inputs
|
|
23
|
-
- Updated dependencies [a492285]
|
|
24
|
-
- Updated dependencies [60aff19]
|
|
25
|
-
- Updated dependencies [6923158]
|
|
26
|
-
- @osdk/api@2.24.0-main-4e2a115a796e8664c3972548bb02e707baafa912
|
|
27
|
-
- @osdk/client@2.24.0-main-4e2a115a796e8664c3972548bb02e707baafa912
|
|
28
|
-
- @osdk/react@2.24.0-main-4e2a115a796e8664c3972548bb02e707baafa912
|
|
29
21
|
|
|
30
22
|
## 0.19.0
|
|
31
23
|
|
|
@@ -45,6 +45,7 @@ export function ObjectTable({
|
|
|
45
45
|
objectSetOptions,
|
|
46
46
|
dedupeIntervalMs,
|
|
47
47
|
pageSize,
|
|
48
|
+
streamUpdates,
|
|
48
49
|
orderBy,
|
|
49
50
|
defaultOrderBy,
|
|
50
51
|
onOrderByChanged,
|
|
@@ -88,7 +89,7 @@ export function ObjectTable({
|
|
|
88
89
|
isLoading,
|
|
89
90
|
error,
|
|
90
91
|
objectSet: resultingObjectSet
|
|
91
|
-
} = useObjectTableData(objectType, columnDefinitions, filter, sorting, objectSet, objectSetOptions, dedupeIntervalMs, pageSize);
|
|
92
|
+
} = useObjectTableData(objectType, columnDefinitions, filter, sorting, objectSet, objectSetOptions, dedupeIntervalMs, pageSize, streamUpdates);
|
|
92
93
|
const {
|
|
93
94
|
columns,
|
|
94
95
|
loading: isColumnsLoading
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","EMPTY_ARRAY","ObjectTable","objectType","objectSet","columnDefinitions","filter","objectSetOptions","dedupeIntervalMs","pageSize","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onColumnResize","onRowSelection","onRowSelectionChanged","onColumnHeaderClick","renderCellContextMenu","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onColumnVisibilityChanged","onCellValueChanged","onSubmitEdits","enableOrdering","enableColumnPinning","enableColumnResizing","enableColumnConfig","editMode","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","data","fetchMore","isLoading","error","resultingObjectSet","columns","loading","isColumnsLoading","primaryKeyApiName","type","undefined","handleRowSelectionChanged","change","derivedObjectSet","isSelectAll","length","where","$in","map","r","$primaryKey","rowSelection","hasSelection","onToggleAll","onToggleRow","enableRowSelection","selectionColumn","columnVisibility","onColumnVisibilityChange","columnOrder","onColumnOrderChange","allColumns","columnPinning","onColumnPinningChange","hasSelectionColumn","editableConfig","table","state","enableSorting","columnResizeMode","columnResizeDirection","manualSorting","defaultColumn","minSize","meta","onCellEdit","onCellValidationError","clearCellValidationError","cellEdits","isInEditMode","editModeState","isActive","validationErrors","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useColumnPinning } from \"./hooks/useColumnPinning.js\";\nimport { useColumnResize } from \"./hooks/useColumnResize.js\";\nimport { useColumnVisibility } from \"./hooks/useColumnVisibility.js\";\nimport { useEditableTable } from \"./hooks/useEditableTable.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { UseRowSelectionChange } from \"./hooks/useRowSelection.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport { useTableSorting } from \"./hooks/useTableSorting.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { BaseTable } from \"./Table.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\nconst EMPTY_ARRAY: [] = [];\nimport type { EditableConfig } from \"./utils/types.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectType,\n objectSet,\n columnDefinitions,\n filter,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n onColumnsPinnedChanged,\n onColumnResize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility\n onRowSelection,\n onRowSelectionChanged,\n onColumnHeaderClick,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onColumnVisibilityChanged,\n onCellValueChanged,\n onSubmitEdits,\n enableOrdering = true,\n enableColumnPinning = true,\n enableColumnResizing = true,\n enableColumnConfig = true,\n editMode = \"manual\",\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >(\n {\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n },\n );\n\n const { data, fetchMore, isLoading, error, objectSet: resultingObjectSet } =\n useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n filter,\n sorting,\n objectSet,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const primaryKeyApiName = objectType.type === \"object\"\n ? objectType.primaryKeyApiName\n : undefined;\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n let derivedObjectSet: ObjectSet<Q, RDPs> | undefined;\n if (resultingObjectSet) {\n if (primaryKeyApiName) {\n derivedObjectSet =\n change.isSelectAll && change.selectedRows.length > 0\n ? resultingObjectSet\n : resultingObjectSet.where({\n [primaryKeyApiName]: {\n $in: change.selectedRows.map(r => r.$primaryKey),\n },\n } as WhereClause<Q, RDPs>);\n } else if (change.isSelectAll && change.selectedRows.length > 0) {\n derivedObjectSet = resultingObjectSet;\n }\n }\n\n onRowSelectionChanged({\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: derivedObjectSet,\n });\n },\n [\n onRowSelectionChanged,\n resultingObjectSet,\n primaryKeyApiName,\n ],\n );\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n enableRowSelection,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onRowSelection,\n onRowSelectionChanged: handleRowSelectionChanged,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n {\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n },\n );\n\n const {\n columnVisibility,\n onColumnVisibilityChange,\n columnOrder,\n onColumnOrderChange,\n } = useColumnVisibility({\n allColumns: columns,\n onColumnVisibilityChanged,\n });\n\n const { columnPinning, onColumnPinningChange } = useColumnPinning({\n columnDefinitions,\n hasSelectionColumn: enableRowSelection,\n onColumnsPinnedChanged,\n });\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const editableConfig: EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n > = useEditableTable({\n editMode,\n onCellValueChanged,\n onSubmitEdits,\n });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? EMPTY_ARRAY,\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n columnOrder,\n rowSelection,\n sorting,\n columnSizing,\n columnPinning,\n },\n onSortingChange,\n onColumnSizingChange,\n onColumnPinningChange,\n onColumnVisibilityChange,\n onColumnOrderChange,\n enableRowSelection,\n enableSorting: enableOrdering,\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n manualSorting: true, // Enable manual sorting to indicate server-side sorting\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\n meta: {\n onCellEdit: editableConfig.onCellEdit,\n onCellValidationError: editableConfig.onCellValidationError,\n clearCellValidationError: editableConfig.clearCellValidationError,\n cellEdits: editableConfig.cellEdits,\n isInEditMode: editableConfig.editModeState.isActive,\n validationErrors: editableConfig.validationErrors,\n },\n });\n\n const onRenderCellContextMenu = useCallback(\n (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cell: Cell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n return renderCellContextMenu?.(row, cell.getValue());\n },\n [renderCellContextMenu],\n );\n\n const handleColumnHeaderClick = useMemo(\n () =>\n onColumnHeaderClick\n ? (columnId: string) =>\n onColumnHeaderClick(\n columnId as\n | PropertyKeys<Q>\n | keyof RDPs\n | keyof FunctionColumns,\n )\n : undefined,\n [onColumnHeaderClick],\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(() => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }), [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]);\n\n return (\n <BaseTable<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n onColumnHeaderClick={handleColumnHeaderClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n renderEmptyState={props.renderEmptyState}\n className={props.className}\n error={error}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n editableConfig={editableConfig}\n getRowAttributes={props.getRowAttributes}\n showEditFooter={props.showEditFooter}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAE5D,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,qBAAqB;AAE9C,MAAMC,WAAe,GAAG,EAAE;AAG1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,UAAU;EACVC,SAAS;EACTC,iBAAiB;EACjBC,MAAM;EACNC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,OAAO;EACPC,cAAc;EACdC,gBAAgB;EAChBC,sBAAsB;EACtBC,cAAc;EACd;EACAC,cAAc;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,CAAC,CAAC;EACtD,CAAC,EACD,CAAC1E,qBAAqB,CACxB,CAAC;EAED,MAAM2E,uBAAuB,GAAGxG,OAAO,CACrC,MACE4B,mBAAmB,GACd6E,QAAgB,IACjB7E,mBAAmB,CACjB6E,QAIF,CAAC,GACDhD,SAAS,EACf,CAAC7B,mBAAmB,CACtB,CAAC;EAID,MAAM8E,sBAA8C,GAAG1G,OAAO,CAAC,OAAO;IACpE2G,gBAAgB,EAAEtE,cAAc;IAChCuE,gBAAgB,EAAEtE,mBAAmB;IACrCuE,cAAc,EAAEtE,oBAAoB;IACpCuE,cAAc,EAAEtE;EAClB,CAAC,CAAC,EAAE,CACFH,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,kBAAkB,CACnB,CAAC;EAEF,oBACE1C,KAAA,CAAAiH,aAAA,CAACrG,SAAS;IACRyE,KAAK,EAAEA,KAAM;IACblC,SAAS,EAjBUA,SAAS,IAAIK,gBAiBN;IAC1B0D,aAAa,EAAEhE,SAAU;IACzBiE,UAAU,EAAEvE,KAAK,CAACuE,UAAW;IAC7BrF,mBAAmB,EAAE4E,uBAAwB;IAC7CU,SAAS,EAAExE,KAAK,CAACwE,SAAU;IAC3BrF,qBAAqB,EAAEuE,uBAAwB;IAC/Ce,gBAAgB,EAAEzE,KAAK,CAACyE,gBAAiB;IACzCC,SAAS,EAAE1E,KAAK,CAAC0E,SAAU;IAC3BlE,KAAK,EAAEA,KAAM;IACbwD,sBAAsB,EAAEA,sBAAuB;IAC/CxB,cAAc,EAAEA,cAAe;IAC/BmC,gBAAgB,EAAE3E,KAAK,CAAC2E,gBAAiB;IACzCC,cAAc,EAAE5E,KAAK,CAAC4E;EAAe,CACtC,CAAC;AAEN","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","EMPTY_ARRAY","ObjectTable","objectType","objectSet","columnDefinitions","filter","objectSetOptions","dedupeIntervalMs","pageSize","streamUpdates","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onColumnResize","onRowSelection","onRowSelectionChanged","onColumnHeaderClick","renderCellContextMenu","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onColumnVisibilityChanged","onCellValueChanged","onSubmitEdits","enableOrdering","enableColumnPinning","enableColumnResizing","enableColumnConfig","editMode","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","data","fetchMore","isLoading","error","resultingObjectSet","columns","loading","isColumnsLoading","primaryKeyApiName","type","undefined","handleRowSelectionChanged","change","derivedObjectSet","isSelectAll","length","where","$in","map","r","$primaryKey","rowSelection","hasSelection","onToggleAll","onToggleRow","enableRowSelection","selectionColumn","columnVisibility","onColumnVisibilityChange","columnOrder","onColumnOrderChange","allColumns","columnPinning","onColumnPinningChange","hasSelectionColumn","editableConfig","table","state","enableSorting","columnResizeMode","columnResizeDirection","manualSorting","defaultColumn","minSize","meta","onCellEdit","onCellValidationError","clearCellValidationError","cellEdits","isInEditMode","editModeState","isActive","validationErrors","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useColumnPinning } from \"./hooks/useColumnPinning.js\";\nimport { useColumnResize } from \"./hooks/useColumnResize.js\";\nimport { useColumnVisibility } from \"./hooks/useColumnVisibility.js\";\nimport { useEditableTable } from \"./hooks/useEditableTable.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { UseRowSelectionChange } from \"./hooks/useRowSelection.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport { useTableSorting } from \"./hooks/useTableSorting.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { BaseTable } from \"./Table.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\nconst EMPTY_ARRAY: [] = [];\nimport type { EditableConfig } from \"./utils/types.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectType,\n objectSet,\n columnDefinitions,\n filter,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n streamUpdates,\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n onColumnsPinnedChanged,\n onColumnResize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility\n onRowSelection,\n onRowSelectionChanged,\n onColumnHeaderClick,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onColumnVisibilityChanged,\n onCellValueChanged,\n onSubmitEdits,\n enableOrdering = true,\n enableColumnPinning = true,\n enableColumnResizing = true,\n enableColumnConfig = true,\n editMode = \"manual\",\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >(\n {\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n },\n );\n\n const { data, fetchMore, isLoading, error, objectSet: resultingObjectSet } =\n useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n filter,\n sorting,\n objectSet,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n streamUpdates,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const primaryKeyApiName = objectType.type === \"object\"\n ? objectType.primaryKeyApiName\n : undefined;\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n let derivedObjectSet: ObjectSet<Q, RDPs> | undefined;\n if (resultingObjectSet) {\n if (primaryKeyApiName) {\n derivedObjectSet =\n change.isSelectAll && change.selectedRows.length > 0\n ? resultingObjectSet\n : resultingObjectSet.where({\n [primaryKeyApiName]: {\n $in: change.selectedRows.map(r => r.$primaryKey),\n },\n } as WhereClause<Q, RDPs>);\n } else if (change.isSelectAll && change.selectedRows.length > 0) {\n derivedObjectSet = resultingObjectSet;\n }\n }\n\n onRowSelectionChanged({\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: derivedObjectSet,\n });\n },\n [\n onRowSelectionChanged,\n resultingObjectSet,\n primaryKeyApiName,\n ],\n );\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n enableRowSelection,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onRowSelection,\n onRowSelectionChanged: handleRowSelectionChanged,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n {\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n },\n );\n\n const {\n columnVisibility,\n onColumnVisibilityChange,\n columnOrder,\n onColumnOrderChange,\n } = useColumnVisibility({\n allColumns: columns,\n onColumnVisibilityChanged,\n });\n\n const { columnPinning, onColumnPinningChange } = useColumnPinning({\n columnDefinitions,\n hasSelectionColumn: enableRowSelection,\n onColumnsPinnedChanged,\n });\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const editableConfig: EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n > = useEditableTable({\n editMode,\n onCellValueChanged,\n onSubmitEdits,\n });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? EMPTY_ARRAY,\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n columnOrder,\n rowSelection,\n sorting,\n columnSizing,\n columnPinning,\n },\n onSortingChange,\n onColumnSizingChange,\n onColumnPinningChange,\n onColumnVisibilityChange,\n onColumnOrderChange,\n enableRowSelection,\n enableSorting: enableOrdering,\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n manualSorting: true, // Enable manual sorting to indicate server-side sorting\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\n meta: {\n onCellEdit: editableConfig.onCellEdit,\n onCellValidationError: editableConfig.onCellValidationError,\n clearCellValidationError: editableConfig.clearCellValidationError,\n cellEdits: editableConfig.cellEdits,\n isInEditMode: editableConfig.editModeState.isActive,\n validationErrors: editableConfig.validationErrors,\n },\n });\n\n const onRenderCellContextMenu = useCallback(\n (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cell: Cell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n return renderCellContextMenu?.(row, cell.getValue());\n },\n [renderCellContextMenu],\n );\n\n const handleColumnHeaderClick = useMemo(\n () =>\n onColumnHeaderClick\n ? (columnId: string) =>\n onColumnHeaderClick(\n columnId as\n | PropertyKeys<Q>\n | keyof RDPs\n | keyof FunctionColumns,\n )\n : undefined,\n [onColumnHeaderClick],\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(() => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }), [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]);\n\n return (\n <BaseTable<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n onColumnHeaderClick={handleColumnHeaderClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n renderEmptyState={props.renderEmptyState}\n className={props.className}\n error={error}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n editableConfig={editableConfig}\n getRowAttributes={props.getRowAttributes}\n showEditFooter={props.showEditFooter}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OA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AACtG,SAAS;IACR0E,KAAK,EAAEA,KAAM;IACblC,SAAS,EAjBUA,SAAS,IAAIK,gBAiBN;IAC1B0D,aAAa,EAAEhE,SAAU;IACzBiE,UAAU,EAAEvE,KAAK,CAACuE,UAAW;IAC7BrF,mBAAmB,EAAE4E,uBAAwB;IAC7CU,SAAS,EAAExE,KAAK,CAACwE,SAAU;IAC3BrF,qBAAqB,EAAEuE,uBAAwB;IAC/Ce,gBAAgB,EAAEzE,KAAK,CAACyE,gBAAiB;IACzCC,SAAS,EAAE1E,KAAK,CAAC0E,SAAU;IAC3BlE,KAAK,EAAEA,KAAM;IACbwD,sBAAsB,EAAEA,sBAAuB;IAC/CxB,cAAc,EAAEA,cAAe;IAC/BmC,gBAAgB,EAAE3E,KAAK,CAAC2E,gBAAiB;IACzCC,cAAc,EAAE5E,KAAK,CAAC4E;EAAe,CACtC,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 CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { QueryParameterType } from \"@osdk/client/observable\";\nimport type * as React from \"react\";\nimport type { CellEditInfo, EditFieldConfig } from \"./utils/types.js\";\n\nexport type { EditFieldConfig } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | EditableColumnDefinition<Q, RDPs, FunctionColumns>\n | ReadonlyColumnDefinition<Q, RDPs, FunctionColumns>;\n\ninterface SharedColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n\n /**\n * Custom renderer for the cell value.\n *\n * Interaction with `editable` columns:\n * - When `editMode: \"manual\"` (default), `renderCell` is used while the\n * table is read-only (Edit Table button visible) and the editable cell\n * takes over once the user enters edit mode.\n * - When `editMode: \"always\"`, the editable cell always wins on editable\n * columns and `renderCell` is ignored — `editMode: \"always\"` opts the\n * column into a permanently-editable surface, leaving no read-only\n * state for `renderCell` to render. Use `editMode: \"manual\"` if you\n * need a custom display alongside editing.\n */\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n}\n\ninterface EditableColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n /**\n * `editable` can be a boolean or a predicate that receives the row's object\n * and returns whether the cell is editable\n */\n editable:\n | true\n | ((\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => boolean);\n\n /**\n * Configuration for the cell editor component.\n *\n * When provided, the column uses the specified field component\n * (e.g. dropdown) instead of the default auto-detected text/number input.\n *\n * `getFieldComponentProps` receives the row's object and a map of any\n * pending edits for that row (keyed by column id), and returns the props to\n * pass to the field component. Editor configuration can depend on the\n * current row or on other in-progress edits within the row.\n */\n editFieldConfig?: EditFieldConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >;\n\n /**\n * Additional function to validate the cell value during edit.\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n}\n\n/**\n * Column definition for a read-only column (default).\n * `editFieldConfig` and `validateEdit` are not available.\n */\ninterface ReadonlyColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n editable?: false;\n}\n\nexport type ExtractQueryParameters<\n Q extends QueryDefinition,\n> = CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\n/**\n * Concrete function column locator for a single key K.\n * Correlates the id, queryDefinition, and getFunctionParams types.\n */\ninterface FunctionColumnLocatorForKey<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n FunctionColumns extends Record<string, QueryDefinition<{}>>,\n K extends keyof FunctionColumns,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: K;\n queryDefinition: FunctionColumns[K];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => ExtractQueryParameters<FunctionColumns[K]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData?: unknown) => unknown;\n\n /**\n * Minimum time between re-fetches of the same function with the same parameters, in milliseconds.\n * Defaults to 5 minutes as it is expensive to fetch function columns for a large object set\n * and they are expected to be relatively static in the context of an object table\n *\n * @default 300_000 (5 minutes)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Object type apiNames the function reads but doesn't take as a parameter (e.g.\n * linked object types the function traverses internally). The column auto-revalidates\n * when an action edits an object of any of these types. Param-derived types are\n * tracked automatically and don't need to be listed here.\n */\n dependsOn?: string[];\n}\n\n/**\n * Distributes over each key in FunctionColumns so that id, queryDefinition,\n * and getFunctionParams are correlated per key.\n */\nexport type FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = keyof FunctionColumns extends infer K\n ? K extends keyof FunctionColumns\n ? FunctionColumnLocatorForKey<Q, RDPs, FunctionColumns, K>\n : never\n : never;\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Minimum time between fetch requests in milliseconds.\n * Increasing this value reduces redundant network calls when the same data\n * is requested multiple times in quick succession.\n *\n * @default 60_000 1 minute\n */\n dedupeIntervalMs?: number;\n\n /**\n * Number of objects to fetch per page.\n *\n * @default 50\n */\n pageSize?: number;\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 enableFiltering?: 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 enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * Whether to render the bottom edit footer that hosts the\n * \"Edit Table\" / \"Cancel\" / \"Submit Edits\" buttons and the edit-state\n * indicators (modification count, validation errors).\n *\n * @default true whenever the table has at least one column declared\n * editable (i.e. any column with `editable: true` or `editable: (object) => boolean`).\n * When `false`, the \"Edit Table\" and \"Submit Edits\" buttons will not be shown.\n */\n showEditFooter?: boolean;\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\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> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the \"Submit Edits\" button will be shown in the edit footer.\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\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. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\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 * Called when a column header is clicked.\n *\n * The columnId matches the `locator.id` configured on the column definition.\n * The dropdown menu trigger is excluded — clicking the chevron opens the\n * header menu instead of firing this callback.\n *\n * @param columnId The id of the clicked column\n */\n onColumnHeaderClick?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n *\n * @deprecated Use {@link onRowSelectionChanged} instead. The new callback\n * delivers a {@link RowSelectionChange} object with `selectedRows`,\n * `isSelectAll`, and a derived `objectSet`. This legacy callback\n * continues to fire alongside the new one for backwards compatibility.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n\n /**\n * Called when the row selection changes, with a {@link RowSelectionChange}\n * payload describing the new state.\n *\n * @param change The new selection state. See {@link RowSelectionChange}.\n */\n onRowSelectionChanged?: (\n change: RowSelectionChange<Q, RDPs>,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * Render override for the empty state. Called when the table has no\n * rows and no error. When omitted, a default \"No Data\" indicator is\n * rendered.\n */\n renderEmptyState?: () => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n /**\n * Returns extra HTML attributes (typically `data-*`) to apply to each\n * row element. Use this to drive conditional row styling\n */\n getRowAttributes?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => Record<string, string | undefined>;\n\n className?: string;\n}\n\n/**\n * Payload for {@link ObjectTableProps.onRowSelectionChanged}. Consolidates\n * the loaded row instances, the `isSelectAll` semantic intent, and an\n * `ObjectSet` covering the selection.\n */\nexport interface RowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /**\n * Loaded row instances currently selected. When `isSelectAll` is true,\n * this reflects only the rows currently in the table — pages not yet\n * fetched are absent. Use `objectSet` for the cross-page view, and\n * `selectedRows.map(r => r.$primaryKey)` if you need the primary keys.\n */\n selectedRows: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[];\n\n /**\n * True when the user invoked \"select all\" (header checkbox) or when\n * controlled mode supplies `isAllSelected={true}`. Distinct from \"every\n * loaded row happens to be selected\" — that condition is reflected by\n * `selectedRows.length` matching the visible row count but does not set\n * this flag.\n */\n isSelectAll: boolean;\n\n /**\n * An `ObjectSet` representing the selection.\n *\n * - \"Select all\" → the underlying `ObjectSet` (`objectSet` prop if\n * provided, otherwise derived from `objectType` via `client(...)`).\n * This includes rows not yet loaded into the table.\n * - Partial selection → the underlying `ObjectSet` narrowed to\n * `{ [primaryKeyApiName]: { $in: selectedRows.map(r => r.$primaryKey) } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * `undefined` for interface types without a resolvable\n * `primaryKeyApiName` when the selection is partial or empty (a\n * `$primaryKey`-style filter can't be expressed). For \"select all\" on\n * those types the underlying `ObjectSet` is still emitted.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
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 CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { QueryParameterType } from \"@osdk/client/observable\";\nimport type * as React from \"react\";\nimport type { CellEditInfo, EditFieldConfig } from \"./utils/types.js\";\n\nexport type { EditFieldConfig } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | EditableColumnDefinition<Q, RDPs, FunctionColumns>\n | ReadonlyColumnDefinition<Q, RDPs, FunctionColumns>;\n\ninterface SharedColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n\n /**\n * Custom renderer for the cell value.\n *\n * Interaction with `editable` columns:\n * - When `editMode: \"manual\"` (default), `renderCell` is used while the\n * table is read-only (Edit Table button visible) and the editable cell\n * takes over once the user enters edit mode.\n * - When `editMode: \"always\"`, the editable cell always wins on editable\n * columns and `renderCell` is ignored — `editMode: \"always\"` opts the\n * column into a permanently-editable surface, leaving no read-only\n * state for `renderCell` to render. Use `editMode: \"manual\"` if you\n * need a custom display alongside editing.\n */\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n}\n\ninterface EditableColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n /**\n * `editable` can be a boolean or a predicate that receives the row's object\n * and returns whether the cell is editable\n */\n editable:\n | true\n | ((\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => boolean);\n\n /**\n * Configuration for the cell editor component.\n *\n * When provided, the column uses the specified field component\n * (e.g. dropdown) instead of the default auto-detected text/number input.\n *\n * `getFieldComponentProps` receives the row's object and a map of any\n * pending edits for that row (keyed by column id), and returns the props to\n * pass to the field component. Editor configuration can depend on the\n * current row or on other in-progress edits within the row.\n */\n editFieldConfig?: EditFieldConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >;\n\n /**\n * Additional function to validate the cell value during edit.\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n}\n\n/**\n * Column definition for a read-only column (default).\n * `editFieldConfig` and `validateEdit` are not available.\n */\ninterface ReadonlyColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n editable?: false;\n}\n\nexport type ExtractQueryParameters<\n Q extends QueryDefinition,\n> = CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\n/**\n * Concrete function column locator for a single key K.\n * Correlates the id, queryDefinition, and getFunctionParams types.\n */\ninterface FunctionColumnLocatorForKey<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n FunctionColumns extends Record<string, QueryDefinition<{}>>,\n K extends keyof FunctionColumns,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: K;\n queryDefinition: FunctionColumns[K];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => ExtractQueryParameters<FunctionColumns[K]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData?: unknown) => unknown;\n\n /**\n * Minimum time between re-fetches of the same function with the same parameters, in milliseconds.\n * Defaults to 5 minutes as it is expensive to fetch function columns for a large object set\n * and they are expected to be relatively static in the context of an object table\n *\n * @default 300_000 (5 minutes)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Object type apiNames the function reads but doesn't take as a parameter (e.g.\n * linked object types the function traverses internally). The column auto-revalidates\n * when an action edits an object of any of these types. Param-derived types are\n * tracked automatically and don't need to be listed here.\n */\n dependsOn?: string[];\n}\n\n/**\n * Distributes over each key in FunctionColumns so that id, queryDefinition,\n * and getFunctionParams are correlated per key.\n */\nexport type FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = keyof FunctionColumns extends infer K\n ? K extends keyof FunctionColumns\n ? FunctionColumnLocatorForKey<Q, RDPs, FunctionColumns, K>\n : never\n : never;\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Minimum time between fetch requests in milliseconds.\n * Increasing this value reduces redundant network calls when the same data\n * is requested multiple times in quick succession.\n *\n * @default 60_000 1 minute\n */\n dedupeIntervalMs?: number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the table will automatically update when matching\n * objects are added, updated, or removed in Foundry.\n *\n * Limitations: `streamUpdates` cannot be used together with `pivotTo` or\n * `withProperties`. The server does not support websocket subscriptions\n * for link-traversal or derived-property queries. Those queries still\n * fetch data normally but won't receive real-time updates.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Number of objects to fetch per page.\n *\n * @default 50\n */\n pageSize?: number;\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 enableFiltering?: 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 enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * Whether to render the bottom edit footer that hosts the\n * \"Edit Table\" / \"Cancel\" / \"Submit Edits\" buttons and the edit-state\n * indicators (modification count, validation errors).\n *\n * @default true whenever the table has at least one column declared\n * editable (i.e. any column with `editable: true` or `editable: (object) => boolean`).\n * When `false`, the \"Edit Table\" and \"Submit Edits\" buttons will not be shown.\n */\n showEditFooter?: boolean;\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\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> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the \"Submit Edits\" button will be shown in the edit footer.\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\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. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\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 * Called when a column header is clicked.\n *\n * The columnId matches the `locator.id` configured on the column definition.\n * The dropdown menu trigger is excluded — clicking the chevron opens the\n * header menu instead of firing this callback.\n *\n * @param columnId The id of the clicked column\n */\n onColumnHeaderClick?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n *\n * @deprecated Use {@link onRowSelectionChanged} instead. The new callback\n * delivers a {@link RowSelectionChange} object with `selectedRows`,\n * `isSelectAll`, and a derived `objectSet`. This legacy callback\n * continues to fire alongside the new one for backwards compatibility.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n\n /**\n * Called when the row selection changes, with a {@link RowSelectionChange}\n * payload describing the new state.\n *\n * @param change The new selection state. See {@link RowSelectionChange}.\n */\n onRowSelectionChanged?: (\n change: RowSelectionChange<Q, RDPs>,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * Render override for the empty state. Called when the table has no\n * rows and no error. When omitted, a default \"No Data\" indicator is\n * rendered.\n */\n renderEmptyState?: () => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n /**\n * Returns extra HTML attributes (typically `data-*`) to apply to each\n * row element. Use this to drive conditional row styling\n */\n getRowAttributes?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => Record<string, string | undefined>;\n\n className?: string;\n}\n\n/**\n * Payload for {@link ObjectTableProps.onRowSelectionChanged}. Consolidates\n * the loaded row instances, the `isSelectAll` semantic intent, and an\n * `ObjectSet` covering the selection.\n */\nexport interface RowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /**\n * Loaded row instances currently selected. When `isSelectAll` is true,\n * this reflects only the rows currently in the table — pages not yet\n * fetched are absent. Use `objectSet` for the cross-page view, and\n * `selectedRows.map(r => r.$primaryKey)` if you need the primary keys.\n */\n selectedRows: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[];\n\n /**\n * True when the user invoked \"select all\" (header checkbox) or when\n * controlled mode supplies `isAllSelected={true}`. Distinct from \"every\n * loaded row happens to be selected\" — that condition is reflected by\n * `selectedRows.length` matching the visible row count but does not set\n * this flag.\n */\n isSelectAll: boolean;\n\n /**\n * An `ObjectSet` representing the selection.\n *\n * - \"Select all\" → the underlying `ObjectSet` (`objectSet` prop if\n * provided, otherwise derived from `objectType` via `client(...)`).\n * This includes rows not yet loaded into the table.\n * - Partial selection → the underlying `ObjectSet` narrowed to\n * `{ [primaryKeyApiName]: { $in: selectedRows.map(r => r.$primaryKey) } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * `undefined` for interface types without a resolvable\n * `primaryKeyApiName` when the selection is partial or empty (a\n * `$primaryKey`-style filter can't be expressed). For \"select all\" on\n * those types the underlying `ObjectSet` is still emitted.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -24,7 +24,7 @@ import { useFunctionColumnsData } from "./useFunctionColumnsData.js";
|
|
|
24
24
|
* It extracts RDP locators from columnDefinitions and applies withProperties
|
|
25
25
|
* to return data containing the derived properties.
|
|
26
26
|
*/
|
|
27
|
-
export function useObjectTableData(objectOrInterfaceType, columnDefinitions, filter, sorting, objectSet, objectSetOptions, dedupeIntervalMs = DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS, pageSize = DEFAULT_PAGE_SIZE) {
|
|
27
|
+
export function useObjectTableData(objectOrInterfaceType, columnDefinitions, filter, sorting, objectSet, objectSetOptions, dedupeIntervalMs = DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS, pageSize = DEFAULT_PAGE_SIZE, streamUpdates) {
|
|
28
28
|
const orderBy = useMemo(() => {
|
|
29
29
|
if (!sorting || sorting.length === 0) {
|
|
30
30
|
return undefined;
|
|
@@ -67,7 +67,8 @@ export function useObjectTableData(objectOrInterfaceType, columnDefinitions, fil
|
|
|
67
67
|
orderBy,
|
|
68
68
|
pageSize,
|
|
69
69
|
enabled: shouldUseObjectSet,
|
|
70
|
-
dedupeIntervalMs
|
|
70
|
+
dedupeIntervalMs,
|
|
71
|
+
streamUpdates
|
|
71
72
|
});
|
|
72
73
|
const osdkObjectsResult = useOsdkObjects(objectOrInterfaceType, {
|
|
73
74
|
withProperties,
|
|
@@ -75,7 +76,8 @@ export function useObjectTableData(objectOrInterfaceType, columnDefinitions, fil
|
|
|
75
76
|
where: filter,
|
|
76
77
|
orderBy,
|
|
77
78
|
enabled: !shouldUseObjectSet,
|
|
78
|
-
dedupeIntervalMs
|
|
79
|
+
dedupeIntervalMs,
|
|
80
|
+
streamUpdates
|
|
79
81
|
});
|
|
80
82
|
|
|
81
83
|
// Get the result from the appropriate hook
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectTableData.js","names":["useObjectSet","useOsdkObjects","useMemo","DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS","DEFAULT_PAGE_SIZE","useFunctionColumnsData","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","objectSet","objectSetOptions","dedupeIntervalMs","pageSize","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","isObjectType","shouldUseObjectSet","objectSetResult","where","enabled","osdkObjectsResult","baseResult","primaryKeyApiName","functionColumnData","objects","data","mergedData","obj","objKey","String","$primaryKey","functionData","Object","entries","forEach","columnId","columnData"],"sources":["useObjectTableData.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport {\n useObjectSet,\n type UseOsdkListResult,\n useOsdkObjects,\n} from \"@osdk/react\";\nimport type { SortingState } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\nimport type { ColumnDefinition, ObjectSetOptions } from \"../ObjectTableApi.js\";\nimport type { AsyncCellData } from \"../utils/AsyncCellData.js\";\nimport {\n DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS,\n DEFAULT_PAGE_SIZE,\n} from \"../utils/constants.js\";\nimport { useFunctionColumnsData } from \"./useFunctionColumnsData.js\";\n\ntype WithProperties<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n> = {\n [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]>;\n};\n\ninterface UseObjectTableDataResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> extends Omit<UseOsdkListResult<Q, RDPs>, \"isOptimistic\"> {}\n/**\n * This hook is a wrapper that conditionally uses either useObjectSet or useOsdkObjects\n * based on whether an objectSet prop is provided.\n * It extracts RDP locators from columnDefinitions and applies withProperties\n * to return data containing the derived properties.\n */\nexport function useObjectTableData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectOrInterfaceType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n filter?: WhereClause<Q, RDPs>,\n sorting?: SortingState,\n objectSet?: ObjectSet<Q>,\n objectSetOptions?: ObjectSetOptions<Q>,\n dedupeIntervalMs: number = DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS,\n pageSize: number = DEFAULT_PAGE_SIZE,\n): UseObjectTableDataResult<Q, RDPs> {\n const orderBy = useMemo(() => {\n if (!sorting || sorting.length === 0) {\n return undefined;\n }\n\n return sorting.reduce<{ [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" }>(\n (acc, sort) => {\n acc[sort.id as PropertyKeys<Q>] = sort.desc ? \"desc\" : \"asc\";\n return acc;\n },\n {},\n );\n }, [sorting]);\n\n // Extract derived properties definition\n const withProperties = useMemo(() => {\n if (!columnDefinitions) {\n return;\n }\n\n const rdpColumns = columnDefinitions.map(colDef => colDef.locator).filter(\n (colLocator) => {\n return colLocator.type === \"rdp\";\n },\n );\n\n if (!rdpColumns.length) {\n return;\n }\n\n return rdpColumns.reduce<WithProperties<Q, RDPs>>(\n (acc, cur) => {\n return {\n ...acc,\n [cur.id]: cur.creator,\n };\n },\n {} as WithProperties<Q, RDPs>,\n );\n }, [columnDefinitions]);\n\n // When objectSet is provided and it's an object type, use useObjectSet. Otherwise, use useOsdkObjects.\n const isObjectType = objectOrInterfaceType.type === \"object\";\n const shouldUseObjectSet = !!objectSet && isObjectType;\n\n // When shouldUseObjectSet is true, we know objectSet is defined\n // and objectOrInterfaceType is an ObjectTypeDefinition\n const objectSetResult = useObjectSet(\n shouldUseObjectSet ? objectSet as ObjectSet<Q, RDPs> : undefined as any,\n {\n ...(objectSetOptions as ObjectSetOptions<Q>),\n withProperties: withProperties as WithProperties<\n Q,\n RDPs\n >,\n where: filter,\n orderBy,\n pageSize,\n enabled: shouldUseObjectSet,\n dedupeIntervalMs,\n },\n );\n\n const osdkObjectsResult = useOsdkObjects<\n Q,\n RDPs\n >(\n objectOrInterfaceType,\n {\n withProperties,\n pageSize,\n where: filter,\n orderBy,\n enabled: !shouldUseObjectSet,\n dedupeIntervalMs,\n },\n );\n\n // Get the result from the appropriate hook\n const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult;\n\n const primaryKeyApiName = objectOrInterfaceType.type === \"object\"\n ? objectOrInterfaceType.primaryKeyApiName\n : undefined;\n\n // Call useFunctionColumnsData to get function column data\n const functionColumnData = useFunctionColumnsData<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType,\n objects: baseResult.data,\n columnDefinitions,\n primaryKeyApiName,\n pageSize,\n });\n\n // Merge function column data into each object\n const mergedData = useMemo(() => {\n if (!baseResult.data) return baseResult.data;\n\n return baseResult.data.map(obj => {\n const objKey = String(obj.$primaryKey);\n const functionData: Record<string, AsyncCellData> = {};\n\n // Collect all function column data for this object\n Object.entries(functionColumnData).forEach(([columnId, columnData]) => {\n if (columnData[objKey]) {\n functionData[columnId] = columnData[objKey];\n }\n });\n\n // Return object with function data merged in\n return {\n ...obj,\n ...functionData,\n };\n });\n }, [baseResult.data, functionColumnData]);\n\n // Return the result with merged data\n return {\n ...baseResult,\n data: mergedData,\n } as UseObjectTableDataResult<Q, RDPs>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SACEA,YAAY,EAEZC,cAAc,QACT,aAAa;AAEpB,SAASC,OAAO,QAAQ,OAAO;AAG/B,SACEC,uCAAuC,EACvCC,iBAAiB,QACZ,uBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,6BAA6B;AAgBpE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAWhCC,qBAAwB,EACxBC,iBAAqE,EACrEC,MAA6B,EAC7BC,OAAsB,EACtBC,SAAwB,EACxBC,gBAAsC,EACtCC,gBAAwB,GAAGV,uCAAuC,EAClEW,QAAgB,GAAGV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useObjectTableData.js","names":["useObjectSet","useOsdkObjects","useMemo","DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS","DEFAULT_PAGE_SIZE","useFunctionColumnsData","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","objectSet","objectSetOptions","dedupeIntervalMs","pageSize","streamUpdates","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","isObjectType","shouldUseObjectSet","objectSetResult","where","enabled","osdkObjectsResult","baseResult","primaryKeyApiName","functionColumnData","objects","data","mergedData","obj","objKey","String","$primaryKey","functionData","Object","entries","forEach","columnId","columnData"],"sources":["useObjectTableData.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport {\n useObjectSet,\n type UseOsdkListResult,\n useOsdkObjects,\n} from \"@osdk/react\";\nimport type { SortingState } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\nimport type { ColumnDefinition, ObjectSetOptions } from \"../ObjectTableApi.js\";\nimport type { AsyncCellData } from \"../utils/AsyncCellData.js\";\nimport {\n DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS,\n DEFAULT_PAGE_SIZE,\n} from \"../utils/constants.js\";\nimport { useFunctionColumnsData } from \"./useFunctionColumnsData.js\";\n\ntype WithProperties<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n> = {\n [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]>;\n};\n\ninterface UseObjectTableDataResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> extends Omit<UseOsdkListResult<Q, RDPs>, \"isOptimistic\"> {}\n/**\n * This hook is a wrapper that conditionally uses either useObjectSet or useOsdkObjects\n * based on whether an objectSet prop is provided.\n * It extracts RDP locators from columnDefinitions and applies withProperties\n * to return data containing the derived properties.\n */\nexport function useObjectTableData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectOrInterfaceType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n filter?: WhereClause<Q, RDPs>,\n sorting?: SortingState,\n objectSet?: ObjectSet<Q>,\n objectSetOptions?: ObjectSetOptions<Q>,\n dedupeIntervalMs: number = DEFAULT_OBJECT_TABLE_DEDUPE_INTERVAL_MS,\n pageSize: number = DEFAULT_PAGE_SIZE,\n streamUpdates?: boolean,\n): UseObjectTableDataResult<Q, RDPs> {\n const orderBy = useMemo(() => {\n if (!sorting || sorting.length === 0) {\n return undefined;\n }\n\n return sorting.reduce<{ [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" }>(\n (acc, sort) => {\n acc[sort.id as PropertyKeys<Q>] = sort.desc ? \"desc\" : \"asc\";\n return acc;\n },\n {},\n );\n }, [sorting]);\n\n // Extract derived properties definition\n const withProperties = useMemo(() => {\n if (!columnDefinitions) {\n return;\n }\n\n const rdpColumns = columnDefinitions.map(colDef => colDef.locator).filter(\n (colLocator) => {\n return colLocator.type === \"rdp\";\n },\n );\n\n if (!rdpColumns.length) {\n return;\n }\n\n return rdpColumns.reduce<WithProperties<Q, RDPs>>(\n (acc, cur) => {\n return {\n ...acc,\n [cur.id]: cur.creator,\n };\n },\n {} as WithProperties<Q, RDPs>,\n );\n }, [columnDefinitions]);\n\n // When objectSet is provided and it's an object type, use useObjectSet. Otherwise, use useOsdkObjects.\n const isObjectType = objectOrInterfaceType.type === \"object\";\n const shouldUseObjectSet = !!objectSet && isObjectType;\n\n // When shouldUseObjectSet is true, we know objectSet is defined\n // and objectOrInterfaceType is an ObjectTypeDefinition\n const objectSetResult = useObjectSet(\n shouldUseObjectSet ? objectSet as ObjectSet<Q, RDPs> : undefined as any,\n {\n ...(objectSetOptions as ObjectSetOptions<Q>),\n withProperties: withProperties as WithProperties<\n Q,\n RDPs\n >,\n where: filter,\n orderBy,\n pageSize,\n enabled: shouldUseObjectSet,\n dedupeIntervalMs,\n streamUpdates,\n },\n );\n\n const osdkObjectsResult = useOsdkObjects<\n Q,\n RDPs\n >(\n objectOrInterfaceType,\n {\n withProperties,\n pageSize,\n where: filter,\n orderBy,\n enabled: !shouldUseObjectSet,\n dedupeIntervalMs,\n streamUpdates,\n },\n );\n\n // Get the result from the appropriate hook\n const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult;\n\n const primaryKeyApiName = objectOrInterfaceType.type === \"object\"\n ? objectOrInterfaceType.primaryKeyApiName\n : undefined;\n\n // Call useFunctionColumnsData to get function column data\n const functionColumnData = useFunctionColumnsData<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType,\n objects: baseResult.data,\n columnDefinitions,\n primaryKeyApiName,\n pageSize,\n });\n\n // Merge function column data into each object\n const mergedData = useMemo(() => {\n if (!baseResult.data) return baseResult.data;\n\n return baseResult.data.map(obj => {\n const objKey = String(obj.$primaryKey);\n const functionData: Record<string, AsyncCellData> = {};\n\n // Collect all function column data for this object\n Object.entries(functionColumnData).forEach(([columnId, columnData]) => {\n if (columnData[objKey]) {\n functionData[columnId] = columnData[objKey];\n }\n });\n\n // Return object with function data merged in\n return {\n ...obj,\n ...functionData,\n };\n });\n }, [baseResult.data, functionColumnData]);\n\n // Return the result with merged data\n return {\n ...baseResult,\n data: mergedData,\n } as UseObjectTableDataResult<Q, RDPs>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SACEA,YAAY,EAEZC,cAAc,QACT,aAAa;AAEpB,SAASC,OAAO,QAAQ,OAAO;AAG/B,SACEC,uCAAuC,EACvCC,iBAAiB,QACZ,uBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,6BAA6B;AAgBpE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAWhCC,qBAAwB,EACxBC,iBAAqE,EACrEC,MAA6B,EAC7BC,OAAsB,EACtBC,SAAwB,EACxBC,gBAAsC,EACtCC,gBAAwB,GAAGV,uCAAuC,EAClEW,QAAgB,GAAGV,iBAAiB,EACpCW,aAAuB,EACY;EACnC,MAAMC,OAAO,GAAGd,OAAO,CAAC,MAAM;IAC5B,IAAI,CAACQ,OAAO,IAAIA,OAAO,CAACO,MAAM,KAAK,CAAC,EAAE;MACpC,OAAOC,SAAS;IAClB;IAEA,OAAOR,OAAO,CAACS,MAAM,CACnB,CAACC,GAAG,EAAEC,IAAI,KAAK;MACbD,GAAG,CA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|
@@ -18,8 +18,7 @@ import { Error as ErrorIcon, Spin } from "@blueprintjs/icons";
|
|
|
18
18
|
import classnames from "classnames";
|
|
19
19
|
import "pdfjs-dist/web/pdf_viewer.css";
|
|
20
20
|
import React, { forwardRef, useImperativeHandle } from "react";
|
|
21
|
-
import {
|
|
22
|
-
import { PdfViewerAnnotationLayer } from "./components/PdfViewerAnnotationLayer.js";
|
|
21
|
+
import { PdfAnnotationOverlay } from "./components/PdfAnnotationOverlay.js";
|
|
23
22
|
import { PdfViewerOutlineSidebar } from "./components/PdfViewerOutlineSidebar.js";
|
|
24
23
|
import { PdfViewerSearchBar } from "./components/PdfViewerSearchBar.js";
|
|
25
24
|
import { PdfViewerSidebar } from "./components/PdfViewerSidebar.js";
|
|
@@ -172,13 +171,12 @@ export const BasePdfViewer = /*#__PURE__*/forwardRef(function ({
|
|
|
172
171
|
if (pageAnnotations.length === 0) {
|
|
173
172
|
return null;
|
|
174
173
|
}
|
|
175
|
-
return /*#__PURE__*/
|
|
174
|
+
return /*#__PURE__*/React.createElement(PdfAnnotationOverlay, {
|
|
176
175
|
key: target.pageNumber,
|
|
176
|
+
target: target,
|
|
177
177
|
annotations: pageAnnotations,
|
|
178
|
-
pageHeight: target.pageHeight,
|
|
179
|
-
scale: target.scale,
|
|
180
178
|
onAnnotationClick: onAnnotationClick
|
|
181
|
-
})
|
|
179
|
+
});
|
|
182
180
|
})))));
|
|
183
181
|
});
|
|
184
182
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","forwardRef","useImperativeHandle","createPortal","PdfViewerAnnotationLayer","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","enableHighlight","onTextHighlight","onHighlightDelete","formData","onFormSubmit","onFormChange","initialPage","initialScale","initialAutoSize","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","ref","viewer","highlightModeActive","toggleHighlightMode","deleteHighlight","pdfViewerRef","document","enabled","scrollToPage","hasFormFields","submitFormData","eventBusRef","annotationsByPage","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","autoSize","sidebarOpen","onPageChange","onZoomIn","zoomIn","onZoomOut","zoomOut","onAutoSizeToggle","toggleAutoSize","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","onRotateLeft","rotateLeft","onRotateRight","rotateRight","onHighlightToggle","enableFormSave","onFormSave","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key","pageHeight","container"],"sources":["PdfViewer.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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { forwardRef, useImperativeHandle } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { PdfViewerAnnotationLayer } from \"./components/PdfViewerAnnotationLayer.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerHandle, PdfViewerProps } from \"./types.js\";\n\nexport const BasePdfViewer: React.ForwardRefExoticComponent<\n PdfViewerProps & React.RefAttributes<PdfViewerHandle>\n> = forwardRef<PdfViewerHandle, PdfViewerProps>(\n function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n onDownload,\n enableHighlight = false,\n onTextHighlight,\n onHighlightDelete,\n formData,\n onFormSubmit,\n onFormChange,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n }, ref) {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode, deleteHighlight } =\n usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\n });\n\n useImperativeHandle(ref, () => ({\n scrollToPage: viewer.scrollToPage,\n deleteHighlight,\n }), [viewer.scrollToPage, deleteHighlight]);\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormSubmit,\n onFormChange,\n });\n\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n autoSize={viewer.autoSize}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onZoomIn={viewer.zoomIn}\n onZoomOut={viewer.zoomOut}\n onAutoSizeToggle={viewer.toggleAutoSize}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n enableHighlight={enableHighlight}\n highlightModeActive={highlightModeActive}\n onHighlightToggle={toggleHighlightMode}\n enableFormSave={onFormSubmit != null && hasFormFields}\n onFormSave={submitFormData}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return createPortal(\n <PdfViewerAnnotationLayer\n key={target.pageNumber}\n annotations={pageAnnotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n onAnnotationClick={onAnnotationClick}\n />,\n target.container,\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n },\n);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,UAAU,EAAEC,mBAAmB,QAAQ,OAAO;AAC9D,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,wBAAwB,QAAQ,0CAA0C;AACnF,SAASC,uBAAuB,QAAQ,yCAAyC;AACjF,SAASC,kBAAkB,QAAQ,oCAAoC;AACvE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,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M,CAACqE,aAAa,CAACC,GAAG,CAAEC,MAAM,IAAK;IACpC,MAAMC,eAAe,GAAG7D,iBAAiB,CAAC4D,MAAM,CAACE,UAAU,CAAC,IACvDpG,sBAAsB;IAC3B,IAAImG,eAAe,CAACE,MAAM,KAAK,CAAC,EAAE;MAChC,OAAO,IAAI;IACb;IACA,oBAAO3G,YAAY,cACjBH,KAAA,CAAAmD,aAAA,CAAC/C,wBAAwB;MACvB2G,GAAG,EAAEJ,MAAM,CAACE,UAAW;MACvB5F,WAAW,EAAE2F,eAAgB;MAC7BI,UAAU,EAAEL,MAAM,CAACK,UAAW;MAC9BpD,KAAK,EAAE+C,MAAM,CAAC/C,KAAM;MACpB1C,iBAAiB,EAAEA;IAAkB,CACtC,CAAC,EACFyF,MAAM,CAACM,SACT,CAAC;EACH,CAAC,CACE,CACF,CACF,CACF,CAAC;AAEV,CACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PdfViewer.js","names":["Error","ErrorIcon","Spin","classnames","React","forwardRef","useImperativeHandle","PdfAnnotationOverlay","PdfViewerOutlineSidebar","PdfViewerSearchBar","PdfViewerSidebar","PdfViewerToolbar","EMPTY_ANNOTATION_ARRAY","usePdfAnnotationsByPage","usePdfFormFields","usePdfHighlightMode","usePdfViewerState","styles","BasePdfViewer","src","annotations","onAnnotationClick","onDownload","enableHighlight","onTextHighlight","onHighlightDelete","formData","onFormSubmit","onFormChange","initialPage","initialScale","initialAutoSize","initialSidebarOpen","enableDownload","sidebarMode","sidebarModeProp","outlineIcons","className","ref","viewer","highlightModeActive","toggleHighlightMode","deleteHighlight","pdfViewerRef","document","enabled","scrollToPage","hasFormFields","submitFormData","eventBusRef","annotationsByPage","rootClassName","pdfViewer","loading","createElement","loadingContainer","spinnerIcon","error","errorContainer","errorIcon","message","currentPage","numPages","scale","autoSize","sidebarOpen","onPageChange","onZoomIn","zoomIn","onZoomOut","zoomOut","onAutoSizeToggle","toggleAutoSize","onSearchOpen","search","openSearch","onSidebarToggle","toggleSidebar","download","onRotateLeft","rotateLeft","onRotateRight","rotateRight","onHighlightToggle","enableFormSave","onFormSave","isSearchOpen","query","totalMatches","currentMatchIndex","onQueryChange","setQuery","onNext","nextMatch","onPrev","prevMatch","onClose","closeSearch","contentArea","onPageClick","onSidebarModeChange","setSidebarMode","outlineItems","onItemClick","scrollContainerWrapper","containerRef","scrollContainer","viewerRef","portalTargets","map","target","pageAnnotations","pageNumber","length","key"],"sources":["PdfViewer.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 { Error as ErrorIcon, Spin } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport React, { forwardRef, useImperativeHandle } from \"react\";\nimport { PdfAnnotationOverlay } from \"./components/PdfAnnotationOverlay.js\";\nimport { PdfViewerOutlineSidebar } from \"./components/PdfViewerOutlineSidebar.js\";\nimport { PdfViewerSearchBar } from \"./components/PdfViewerSearchBar.js\";\nimport { PdfViewerSidebar } from \"./components/PdfViewerSidebar.js\";\nimport { PdfViewerToolbar } from \"./components/PdfViewerToolbar.js\";\nimport { EMPTY_ANNOTATION_ARRAY } from \"./constants.js\";\nimport { usePdfAnnotationsByPage } from \"./hooks/usePdfAnnotationsByPage.js\";\nimport { usePdfFormFields } from \"./hooks/usePdfFormFields.js\";\nimport { usePdfHighlightMode } from \"./hooks/usePdfHighlightMode.js\";\nimport { usePdfViewerState } from \"./hooks/usePdfViewerState.js\";\nimport styles from \"./PdfViewer.module.css\";\nimport type { PdfViewerHandle, PdfViewerProps } from \"./types.js\";\n\nexport const BasePdfViewer: React.ForwardRefExoticComponent<\n PdfViewerProps & React.RefAttributes<PdfViewerHandle>\n> = forwardRef<PdfViewerHandle, PdfViewerProps>(\n function BasePdfViewer({\n src,\n annotations = EMPTY_ANNOTATION_ARRAY,\n onAnnotationClick,\n onDownload,\n enableHighlight = false,\n onTextHighlight,\n onHighlightDelete,\n formData,\n onFormSubmit,\n onFormChange,\n initialPage = 1,\n initialScale = 1.0,\n initialAutoSize = false,\n initialSidebarOpen = false,\n enableDownload = false,\n sidebarMode: sidebarModeProp = \"thumbnails\",\n outlineIcons,\n className,\n }, ref) {\n const viewer = usePdfViewerState({\n src,\n initialPage,\n initialScale,\n initialAutoSize,\n initialSidebarOpen,\n sidebarMode: sidebarModeProp,\n onDownload,\n });\n\n const { highlightModeActive, toggleHighlightMode, deleteHighlight } =\n usePdfHighlightMode({\n pdfViewerRef: viewer.pdfViewerRef,\n document: viewer.document,\n enabled: enableHighlight,\n onTextHighlight,\n onHighlightDelete,\n });\n\n useImperativeHandle(ref, () => ({\n scrollToPage: viewer.scrollToPage,\n deleteHighlight,\n }), [viewer.scrollToPage, deleteHighlight]);\n\n const { hasFormFields, submitFormData } = usePdfFormFields({\n pdfViewerRef: viewer.pdfViewerRef,\n eventBusRef: viewer.eventBusRef,\n document: viewer.document,\n formData,\n onFormSubmit,\n onFormChange,\n });\n\n const annotationsByPage = usePdfAnnotationsByPage(annotations);\n\n const rootClassName = classnames(styles.pdfViewer, className);\n\n if (viewer.loading) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>\n <Spin className={styles.spinnerIcon} />\n Loading…\n </div>\n </div>\n );\n }\n\n if (viewer.error != null) {\n return (\n <div className={rootClassName}>\n <div className={styles.errorContainer}>\n <ErrorIcon className={styles.errorIcon} />\n Failed to load PDF: {viewer.error.message}\n </div>\n </div>\n );\n }\n\n if (viewer.document == null) {\n return (\n <div className={rootClassName}>\n <div className={styles.loadingContainer}>No document</div>\n </div>\n );\n }\n\n return (\n <div className={rootClassName}>\n <PdfViewerToolbar\n currentPage={viewer.currentPage}\n numPages={viewer.numPages}\n scale={viewer.scale}\n autoSize={viewer.autoSize}\n sidebarOpen={viewer.sidebarOpen}\n onPageChange={viewer.scrollToPage}\n onZoomIn={viewer.zoomIn}\n onZoomOut={viewer.zoomOut}\n onAutoSizeToggle={viewer.toggleAutoSize}\n onSearchOpen={viewer.search.openSearch}\n onSidebarToggle={viewer.toggleSidebar}\n onDownload={viewer.download}\n enableDownload={enableDownload}\n onRotateLeft={viewer.rotateLeft}\n onRotateRight={viewer.rotateRight}\n enableHighlight={enableHighlight}\n highlightModeActive={highlightModeActive}\n onHighlightToggle={toggleHighlightMode}\n enableFormSave={onFormSubmit != null && hasFormFields}\n onFormSave={submitFormData}\n />\n {viewer.search.isSearchOpen && (\n <PdfViewerSearchBar\n query={viewer.search.query}\n totalMatches={viewer.search.totalMatches}\n currentMatchIndex={viewer.search.currentMatchIndex}\n onQueryChange={viewer.search.setQuery}\n onNext={viewer.search.nextMatch}\n onPrev={viewer.search.prevMatch}\n onClose={viewer.search.closeSearch}\n />\n )}\n <div className={styles.contentArea}>\n {viewer.sidebarOpen && viewer.sidebarMode === \"thumbnails\" && (\n <PdfViewerSidebar\n document={viewer.document}\n numPages={viewer.numPages}\n currentPage={viewer.currentPage}\n onPageClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n />\n )}\n {viewer.sidebarOpen && viewer.sidebarMode === \"outline\" && (\n <PdfViewerOutlineSidebar\n outlineItems={viewer.outlineItems}\n currentPage={viewer.currentPage}\n onItemClick={viewer.scrollToPage}\n sidebarMode={viewer.sidebarMode}\n onSidebarModeChange={viewer.setSidebarMode}\n outlineIcons={outlineIcons}\n />\n )}\n <div className={styles.scrollContainerWrapper}>\n <div ref={viewer.containerRef} className={styles.scrollContainer}>\n <div ref={viewer.viewerRef} className=\"pdfViewer\" />\n {viewer.portalTargets.map((target) => {\n const pageAnnotations = annotationsByPage[target.pageNumber]\n ?? EMPTY_ANNOTATION_ARRAY;\n if (pageAnnotations.length === 0) {\n return null;\n }\n return (\n <PdfAnnotationOverlay\n key={target.pageNumber}\n target={target}\n annotations={pageAnnotations}\n onAnnotationClick={onAnnotationClick}\n />\n );\n })}\n </div>\n </div>\n </div>\n </div>\n );\n },\n);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,EAAEC,IAAI,QAAQ,oBAAoB;AAC7D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAO,+BAA+B;AACtC,OAAOC,KAAK,IAAIC,UAAU,EAAEC,mBAAmB,QAAQ,OAAO;AAC9D,SAASC,oBAAoB,QAAQ,sCAAsC;AAC3E,SAASC,uBAAuB,QAAQ,yCAAyC;AACjF,SAASC,kBAAkB,QAAQ,oCAAoC;AACvE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,uBAAuB,QAAQ,oCAAoC;AAC5E,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,OAAOC,MAAM,MAAM,wBAAwB;AAG3C,OAAO,MAAMC,aAEZ,gBAAGb,UAAU,CACZ,UAAuB;EACrBc,GAAG;EACHC,WAAW,GAAGR,sBAAsB;EACpCS,iBAAiB;EACjBC,UAAU;EACVC,eAAe,GAAG,KAAK;EACvBC,eAAe;EACfC,iBAAiB;EACjBC,QAAQ;EACRC,YAAY;EACZC,YAAY;EACZC,WAAW,GAAG,CAAC;EACfC,YAAY,GAAG,GAAG;EAClBC,eAAe,GAAG,KAAK;EACvBC,kBAAkB,GAAG,KAAK;EAC1BC,cAA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
+
/*
|
|
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 { PdfViewerAnnotationLayer } from "./PdfViewerAnnotationLayer.js";
|
|
19
|
+
export const PdfAnnotationOverlay = ({
|
|
20
|
+
target,
|
|
21
|
+
annotations,
|
|
22
|
+
onAnnotationClick
|
|
23
|
+
}) => {
|
|
24
|
+
const style = useMemo(() => ({
|
|
25
|
+
position: "absolute",
|
|
26
|
+
left: target.left,
|
|
27
|
+
top: target.top,
|
|
28
|
+
width: target.width,
|
|
29
|
+
height: target.height,
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
zIndex: 1
|
|
32
|
+
}), [target.left, target.top, target.width, target.height]);
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
style: style
|
|
35
|
+
}, /*#__PURE__*/React.createElement(PdfViewerAnnotationLayer, {
|
|
36
|
+
annotations: annotations,
|
|
37
|
+
pageHeight: target.pageHeight,
|
|
38
|
+
scale: target.scale,
|
|
39
|
+
transform: target.transform,
|
|
40
|
+
onAnnotationClick: onAnnotationClick
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=PdfAnnotationOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdfAnnotationOverlay.js","names":["React","useMemo","PdfViewerAnnotationLayer","PdfAnnotationOverlay","target","annotations","onAnnotationClick","style","position","left","top","width","height","pointerEvents","zIndex","createElement","pageHeight","scale","transform"],"sources":["PdfAnnotationOverlay.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from \"react\";\nimport type { AnnotationPortalTarget } from \"../hooks/usePdfAnnotationPortals.js\";\nimport type { PdfAnnotation } from \"../types.js\";\nimport { PdfViewerAnnotationLayer } from \"./PdfViewerAnnotationLayer.js\";\n\nexport interface PdfAnnotationOverlayProps {\n target: AnnotationPortalTarget;\n annotations: PdfAnnotation[];\n onAnnotationClick?: (annotation: PdfAnnotation) => void;\n}\n\nexport const PdfAnnotationOverlay: React.FC<PdfAnnotationOverlayProps> = ({\n target,\n annotations,\n onAnnotationClick,\n}) => {\n const style = useMemo<React.CSSProperties>(() => ({\n position: \"absolute\",\n left: target.left,\n top: target.top,\n width: target.width,\n height: target.height,\n pointerEvents: \"none\",\n zIndex: 1,\n }), [target.left, target.top, target.width, target.height]);\n\n return (\n <div style={style}>\n <PdfViewerAnnotationLayer\n annotations={annotations}\n pageHeight={target.pageHeight}\n scale={target.scale}\n transform={target.transform}\n onAnnotationClick={onAnnotationClick}\n />\n </div>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAGtC,SAASC,wBAAwB,QAAQ,+BAA+B;AAQxE,OAAO,MAAMC,oBAAyD,GAAGA,CAAC;EACxEC,MAAM;EACNC,WAAW;EACXC;AACF,CAAC,KAAK;EACJ,MAAMC,KAAK,GAAGN,OAAO,CAAsB,OAAO;IAChDO,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAEL,MAAM,CAACK,IAAI;IACjBC,GAAG,EAAEN,MAAM,CAACM,GAAG;IACfC,KAAK,EAAEP,MAAM,CAACO,KAAK;IACnBC,MAAM,EAAER,MAAM,CAACQ,MAAM;IACrBC,aAAa,EAAE,MAAM;IACrBC,MAAM,EAAE;EACV,CAAC,CAAC,EAAE,CAACV,MAAM,CAACK,IAAI,EAAEL,MAAM,CAACM,GAAG,EAAEN,MAAM,CAACO,KAAK,EAAEP,MAAM,CAACQ,MAAM,CAAC,CAAC;EAE3D,oBACEZ,KAAA,CAAAe,aAAA;IAAKR,KAAK,EAAEA;EAAM,gBAChBP,KAAA,CAAAe,aAAA,CAACb,wBAAwB;IACvBG,WAAW,EAAEA,WAAY;IACzBW,UAAU,EAAEZ,MAAM,CAACY,UAAW;IAC9BC,KAAK,EAAEb,MAAM,CAACa,KAAM;IACpBC,SAAS,EAAEd,MAAM,CAACc,SAAU;IAC5BZ,iBAAiB,EAAEA;EAAkB,CACtC,CACE,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -17,13 +17,19 @@
|
|
|
17
17
|
import classnames from "classnames";
|
|
18
18
|
import React, { useCallback, useMemo } from "react";
|
|
19
19
|
import styles from "./PdfViewerAnnotationLayer.module.css.js";
|
|
20
|
+
function applyTransform(point, m) {
|
|
21
|
+
return [m[0] * point[0] + m[2] * point[1] + m[4], m[1] * point[0] + m[3] * point[1] + m[5]];
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
/** Convert a single PDF rect (bottom-left origin) to CSS positioning (top-left origin). */
|
|
21
|
-
function computeRectStyle(rect,
|
|
25
|
+
function computeRectStyle(rect, transform, color) {
|
|
26
|
+
const [x1, y1] = applyTransform([rect.x, rect.y], transform);
|
|
27
|
+
const [x2, y2] = applyTransform([rect.x + rect.width, rect.y + rect.height], transform);
|
|
22
28
|
return {
|
|
23
|
-
left:
|
|
24
|
-
top: (
|
|
25
|
-
width:
|
|
26
|
-
height:
|
|
29
|
+
left: Math.min(x1, x2),
|
|
30
|
+
top: Math.min(y1, y2),
|
|
31
|
+
width: Math.abs(x2 - x1),
|
|
32
|
+
height: Math.abs(y2 - y1),
|
|
27
33
|
...(color != null ? {
|
|
28
34
|
"--osdk-pdf-annotation-color": color
|
|
29
35
|
} : {})
|
|
@@ -46,8 +52,7 @@ function useAnnotationHandlers(annotation, onClick) {
|
|
|
46
52
|
}
|
|
47
53
|
function AnnotationItem({
|
|
48
54
|
annotation,
|
|
49
|
-
|
|
50
|
-
scale,
|
|
55
|
+
transform,
|
|
51
56
|
onClick
|
|
52
57
|
}) {
|
|
53
58
|
const {
|
|
@@ -57,7 +62,7 @@ function AnnotationItem({
|
|
|
57
62
|
const className = classnames(styles.annotation, styles[annotation.type]);
|
|
58
63
|
const multiRects = annotation.rects;
|
|
59
64
|
const hasMultipleRects = multiRects != null && multiRects.length > 1;
|
|
60
|
-
const style = useMemo(() => computeRectStyle(annotation.rect,
|
|
65
|
+
const style = useMemo(() => computeRectStyle(annotation.rect, transform, annotation.color), [annotation, transform]);
|
|
61
66
|
|
|
62
67
|
// Multi-rect: render a group wrapper with one div per rect
|
|
63
68
|
if (hasMultipleRects) {
|
|
@@ -72,7 +77,7 @@ function AnnotationItem({
|
|
|
72
77
|
}, multiRects.map((rect, i) => /*#__PURE__*/React.createElement("div", {
|
|
73
78
|
key: i,
|
|
74
79
|
className: className,
|
|
75
|
-
style: computeRectStyle(rect,
|
|
80
|
+
style: computeRectStyle(rect, transform, annotation.color)
|
|
76
81
|
})));
|
|
77
82
|
}
|
|
78
83
|
|
|
@@ -93,18 +98,20 @@ function CustomAnnotationItem({
|
|
|
93
98
|
annotation,
|
|
94
99
|
pageHeight,
|
|
95
100
|
scale,
|
|
101
|
+
transform,
|
|
96
102
|
onClick
|
|
97
103
|
}) {
|
|
98
104
|
const {
|
|
99
105
|
handleClick,
|
|
100
106
|
handleKeyDown
|
|
101
107
|
} = useAnnotationHandlers(annotation, onClick);
|
|
102
|
-
const style = useMemo(() => computeRectStyle(annotation.rect,
|
|
108
|
+
const style = useMemo(() => computeRectStyle(annotation.rect, transform, undefined), [annotation, transform]);
|
|
103
109
|
const renderProps = useMemo(() => ({
|
|
104
110
|
annotation,
|
|
105
111
|
scale,
|
|
106
|
-
pageHeight
|
|
107
|
-
|
|
112
|
+
pageHeight,
|
|
113
|
+
transform
|
|
114
|
+
}), [annotation, scale, pageHeight, transform]);
|
|
108
115
|
return /*#__PURE__*/React.createElement("div", {
|
|
109
116
|
className: styles.annotation,
|
|
110
117
|
style: style,
|
|
@@ -120,6 +127,7 @@ export function PdfViewerAnnotationLayer({
|
|
|
120
127
|
annotations,
|
|
121
128
|
pageHeight,
|
|
122
129
|
scale,
|
|
130
|
+
transform,
|
|
123
131
|
onAnnotationClick
|
|
124
132
|
}) {
|
|
125
133
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -129,12 +137,12 @@ export function PdfViewerAnnotationLayer({
|
|
|
129
137
|
annotation: annotation,
|
|
130
138
|
pageHeight: pageHeight,
|
|
131
139
|
scale: scale,
|
|
140
|
+
transform: transform,
|
|
132
141
|
onClick: onAnnotationClick
|
|
133
142
|
}) : /*#__PURE__*/React.createElement(AnnotationItem, {
|
|
134
143
|
key: annotation.id,
|
|
135
144
|
annotation: annotation,
|
|
136
|
-
|
|
137
|
-
scale: scale,
|
|
145
|
+
transform: transform,
|
|
138
146
|
onClick: onAnnotationClick
|
|
139
147
|
})));
|
|
140
148
|
}
|