@osdk/react-components 0.39.0 → 0.40.0-main-a2b6fc49d4e2239fddc00a2d4ed0782fd1f96fd0
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 +6 -0
- package/build/browser/object-table/ObjectTable.js +0 -3
- 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/useColumnDefs.js +0 -2
- package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/browser/object-table/hooks/useRowSelection.js +0 -3
- package/build/browser/object-table/hooks/useRowSelection.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/chunk-2NG63762.cjs +11 -0
- package/build/cjs/{chunk-ZHBPBYCD.cjs.map → chunk-2NG63762.cjs.map} +1 -1
- package/build/cjs/{chunk-E5UOPUAL.cjs → chunk-5PZHBX7V.cjs} +4 -4
- package/build/cjs/{chunk-E5UOPUAL.cjs.map → chunk-5PZHBX7V.cjs.map} +1 -1
- package/build/cjs/{chunk-WFSXNLPN.cjs → chunk-5XZG6BTX.cjs} +4 -4
- package/build/cjs/{chunk-WFSXNLPN.cjs.map → chunk-5XZG6BTX.cjs.map} +1 -1
- package/build/cjs/{chunk-AYHARI77.cjs → chunk-FNOJVZSD.cjs} +4 -4
- package/build/cjs/{chunk-AYHARI77.cjs.map → chunk-FNOJVZSD.cjs.map} +1 -1
- package/build/cjs/{chunk-VPD5ZNXM.cjs → chunk-IWZT7CPM.cjs} +3 -3
- package/build/cjs/chunk-IWZT7CPM.cjs.map +1 -0
- package/build/cjs/chunk-KG2TGIJC.cjs +11 -0
- package/build/cjs/{chunk-JVER3ZOK.cjs.map → chunk-KG2TGIJC.cjs.map} +1 -1
- package/build/cjs/{chunk-QYY4YHS5.cjs → chunk-MH3QGGPZ.cjs} +4 -4
- package/build/cjs/{chunk-QYY4YHS5.cjs.map → chunk-MH3QGGPZ.cjs.map} +1 -1
- package/build/cjs/chunk-OVSNQE7J.cjs +11 -0
- package/build/cjs/{chunk-ZISGRA73.cjs.map → chunk-OVSNQE7J.cjs.map} +1 -1
- package/build/cjs/chunk-TE2RAPFZ.cjs +11 -0
- package/build/cjs/{chunk-2FZYBU6I.cjs.map → chunk-TE2RAPFZ.cjs.map} +1 -1
- package/build/cjs/{chunk-RO3PPGFU.cjs → chunk-TPO6JWZY.cjs} +4 -4
- package/build/cjs/{chunk-RO3PPGFU.cjs.map → chunk-TPO6JWZY.cjs.map} +1 -1
- package/build/cjs/{chunk-MO4KAKAY.cjs → chunk-W252RLXO.cjs} +4 -12
- package/build/cjs/chunk-W252RLXO.cjs.map +1 -0
- package/build/cjs/chunk-XRRPXIG7.cjs +11 -0
- package/build/cjs/{chunk-7TXID3FA.cjs.map → chunk-XRRPXIG7.cjs.map} +1 -1
- package/build/cjs/{chunk-Z5OGPHAS.cjs → chunk-XS663NKN.cjs} +4 -4
- package/build/cjs/{chunk-Z5OGPHAS.cjs.map → chunk-XS663NKN.cjs.map} +1 -1
- package/build/cjs/{chunk-IDNB6BWX.cjs → chunk-XZCS5XKY.cjs} +4 -4
- package/build/cjs/{chunk-IDNB6BWX.cjs.map → chunk-XZCS5XKY.cjs.map} +1 -1
- package/build/cjs/public/experimental/action-form.cjs +4 -4
- package/build/cjs/public/experimental/cbac-picker.cjs +11 -11
- package/build/cjs/public/experimental/document-viewer.cjs +4 -4
- 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/image-viewer.cjs +3 -3
- package/build/cjs/public/experimental/markdown-renderer.cjs +3 -3
- package/build/cjs/public/experimental/object-table.cjs +21 -21
- package/build/cjs/public/experimental/object-table.d.cts +2 -32
- package/build/cjs/public/experimental/pdf-viewer.cjs +7 -7
- 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 +71 -71
- package/build/esm/object-table/ObjectTable.js +0 -3
- 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/useColumnDefs.js +0 -2
- package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/esm/object-table/hooks/useRowSelection.js +0 -3
- package/build/esm/object-table/hooks/useRowSelection.js.map +1 -1
- 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 +0 -26
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/hooks/useRowSelection.d.ts +1 -5
- package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
- package/docs/ObjectTable.md +9 -36
- package/package.json +5 -5
- package/build/cjs/chunk-2FZYBU6I.cjs +0 -11
- package/build/cjs/chunk-7TXID3FA.cjs +0 -11
- package/build/cjs/chunk-JVER3ZOK.cjs +0 -11
- package/build/cjs/chunk-MO4KAKAY.cjs.map +0 -1
- package/build/cjs/chunk-VPD5ZNXM.cjs.map +0 -1
- package/build/cjs/chunk-ZHBPBYCD.cjs +0 -11
- package/build/cjs/chunk-ZISGRA73.cjs +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
+
## 0.40.0-main-a2b6fc49d4e2239fddc00a2d4ed0782fd1f96fd0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 647d743: Remove the deprecated `onRowSelection` prop and the dead filtering API (`enableFiltering`, `onFilterChanged`, and the per-column `filterable`) from ObjectTable. Use `onRowSelectionChanged` for selection changes; programmatic filtering via the controlled `filter` prop is unchanged.
|
|
8
|
+
|
|
3
9
|
## 0.39.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -44,8 +44,6 @@ export function ObjectTable({
|
|
|
44
44
|
onOrderByChanged,
|
|
45
45
|
onColumnsPinnedChanged,
|
|
46
46
|
onColumnResize,
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility
|
|
48
|
-
onRowSelection,
|
|
49
47
|
onRowSelectionChanged,
|
|
50
48
|
onColumnHeaderClick,
|
|
51
49
|
renderCellContextMenu,
|
|
@@ -121,7 +119,6 @@ export function ObjectTable({
|
|
|
121
119
|
selectionMode,
|
|
122
120
|
selectedRows,
|
|
123
121
|
isAllSelected: isAllSelectedProp,
|
|
124
|
-
onRowSelection,
|
|
125
122
|
onRowSelectionChanged: handleRowSelectionChanged,
|
|
126
123
|
data
|
|
127
124
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useImperativeHandle","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useObjectTableSnapshot","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","deriveSelectionObjectSet","getRowId","getRowIdFromPrimaryKey","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","focusedRow","onFocusedRowChanged","tableRef","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","orderByState","data","fetchMore","isLoading","error","totalCount","resultingObjectSet","objectOrInterfaceType","columns","loading","isColumnsLoading","handleRowSelectionChanged","change","isSelectAll","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","getSnapshot","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","undefined","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter","focusedRowId"],"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 Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useImperativeHandle, useMemo } from \"react\";\n\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 { useObjectTableSnapshot } from \"./hooks/useObjectTableSnapshot.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 { deriveSelectionObjectSet } from \"./utils/deriveSelectionObjectSet.js\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"./utils/getRowId.js\";\nimport type { EditableConfig } from \"./utils/types.js\";\n\nconst EMPTY_ARRAY: [] = [];\n\nexport function ObjectTable<\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 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 focusedRow,\n onFocusedRowChanged,\n tableRef,\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange, orderByState } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >({\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n });\n\n const {\n data,\n fetchMore,\n isLoading,\n error,\n totalCount,\n objectSet: resultingObjectSet,\n } = useObjectTableData<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType: 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 >(objectType, columnDefinitions);\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n onRowSelectionChanged({\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: deriveSelectionObjectSet(resultingObjectSet, change),\n });\n },\n [onRowSelectionChanged, resultingObjectSet]\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 selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\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 { getSnapshot } = useObjectTableSnapshot<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType: objectType,\n table,\n columnDefinitions,\n objectSet: resultingObjectSet,\n pageSize,\n totalCount,\n orderBy: orderByState,\n });\n\n useImperativeHandle(tableRef, () => ({ getSnapshot }), [getSnapshot]);\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 PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns\n )\n : undefined,\n [onColumnHeaderClick]\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(\n () => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }),\n [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]\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 focusedRowId={\n focusedRow == null ? focusedRow : getRowIdFromPrimaryKey<Q>(focusedRow)\n }\n onFocusedRowChanged={onFocusedRowChanged}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,mBAAmB,EAAEC,OAAO,QAAQ,OAAO;AAExE,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;AAClE,SAASC,sBAAsB,QAAQ,mCAAmC;AAE1E,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+B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AAK,CAACsE,gBAAiB;IACzCC,cAAc,EAAEvE,KAAK,CAACuE,cAAe;IACrCC,YAAY,EACV3E,UAAU,IAAI,IAAI,GAAGA,UAAU,GAAGhC,sBAAsB,CAAIgC,UAAU,CACvE;IACDC,mBAAmB,EAAEA;EAAoB,CAC1C,CAAC;AAEN","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useImperativeHandle","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useObjectTableSnapshot","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","deriveSelectionObjectSet","getRowId","getRowIdFromPrimaryKey","EMPTY_ARRAY","ObjectTable","objectType","objectSet","columnDefinitions","filter","objectSetOptions","dedupeIntervalMs","pageSize","streamUpdates","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onColumnResize","onRowSelectionChanged","onColumnHeaderClick","renderCellContextMenu","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onColumnVisibilityChanged","onCellValueChanged","onSubmitEdits","enableOrdering","enableColumnPinning","enableColumnResizing","enableColumnConfig","editMode","focusedRow","onFocusedRowChanged","tableRef","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","orderByState","data","fetchMore","isLoading","error","totalCount","resultingObjectSet","objectOrInterfaceType","columns","loading","isColumnsLoading","handleRowSelectionChanged","change","isSelectAll","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","getSnapshot","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","undefined","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter","focusedRowId"],"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 Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useImperativeHandle, useMemo } from \"react\";\n\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 { useObjectTableSnapshot } from \"./hooks/useObjectTableSnapshot.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 { deriveSelectionObjectSet } from \"./utils/deriveSelectionObjectSet.js\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"./utils/getRowId.js\";\nimport type { EditableConfig } from \"./utils/types.js\";\n\nconst EMPTY_ARRAY: [] = [];\n\nexport function ObjectTable<\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 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 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 focusedRow,\n onFocusedRowChanged,\n tableRef,\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange, orderByState } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >({\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n });\n\n const {\n data,\n fetchMore,\n isLoading,\n error,\n totalCount,\n objectSet: resultingObjectSet,\n } = useObjectTableData<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType: 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 >(objectType, columnDefinitions);\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n onRowSelectionChanged({\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: deriveSelectionObjectSet(resultingObjectSet, change),\n });\n },\n [onRowSelectionChanged, resultingObjectSet]\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 onRowSelectionChanged: handleRowSelectionChanged,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>({\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\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 { getSnapshot } = useObjectTableSnapshot<Q, RDPs, FunctionColumns>({\n objectOrInterfaceType: objectType,\n table,\n columnDefinitions,\n objectSet: resultingObjectSet,\n pageSize,\n totalCount,\n orderBy: orderByState,\n });\n\n useImperativeHandle(tableRef, () => ({ getSnapshot }), [getSnapshot]);\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 PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns\n )\n : undefined,\n [onColumnHeaderClick]\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(\n () => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }),\n [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]\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 focusedRowId={\n focusedRow == null ? focusedRow : getRowIdFromPrimaryKey<Q>(focusedRow)\n }\n onFocusedRowChanged={onFocusedRowChanged}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,mBAAmB,EAAEC,OAAO,QAAQ,OAAO;AAExE,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;AAClE,SAASC,sBAAsB,QAAQ,mCAAmC;AAE1E,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAE5D,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,wBAAwB,QAAQ,qCAAqC;AAC9E,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,qBAAqB;AAGtE,MAAMC,WAAe,GAAG,EAAE;AAE1B,OAAO,SAASC,WAAWA,CAOzB;EACAC,UAAU;EACVC,SAAS;EACTC,iBAAiB;EACjBC,MAAM;EACNC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,aAAa;EACbC,OAAO;EACPC,cAAc;EACdC,gBAAgB;EAChBC,sBAAsB;EACtBC,cAAc;EACdC,qBAAqB;EACrBC,mBAAmB;EACnBC,qBAAqB;EACrBC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,aAAa,EAAEC,iBAAiB;EAChCC,yBAAyB;EACzBC,kBAAkB;EAClBC,aAAa;EACbC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c,EAAEpE,oBAAoB;IACpCqE,cAAc,EAAEpE;EAClB,CAAC,CAAC,EACF,CACEH,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,kBAAkB,CAEtB,CAAC;EAED,oBACE9C,KAAA,CAAAmH,aAAA,CAACrG,SAAS;IACRuE,KAAK,EAAEA,KAAM;IACb1B,SAAS,EApBUA,SAAS,IAAIO,gBAoBN;IAC1BkD,aAAa,EAAE1D,SAAU;IACzB2D,UAAU,EAAElE,KAAK,CAACkE,UAAW;IAC7BnF,mBAAmB,EAAEyE,uBAAwB;IAC7CW,SAAS,EAAEnE,KAAK,CAACmE,SAAU;IAC3BnF,qBAAqB,EAAEoE,uBAAwB;IAC/CgB,gBAAgB,EAAEpE,KAAK,CAACoE,gBAAiB;IACzCC,SAAS,EAAErE,KAAK,CAACqE,SAAU;IAC3B5D,KAAK,EAAEA,KAAM;IACbkD,sBAAsB,EAAEA,sBAAuB;IAC/C1B,cAAc,EAAEA,cAAe;IAC/BqC,gBAAgB,EAAEtE,KAAK,CAACsE,gBAAiB;IACzCC,cAAc,EAAEvE,KAAK,CAACuE,cAAe;IACrCC,YAAY,EACV3E,UAAU,IAAI,IAAI,GAAGA,UAAU,GAAG/B,sBAAsB,CAAI+B,UAAU,CACvE;IACDC,mBAAmB,EAAEA;EAAoB,CAC1C,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\";\n\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 /**\n * Defines what the column shows:\n * an object/interface property, a linked object property (derived property), a function\n * column, or a custom column — and carries that locator's configuration.\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?: (value: unknown) => 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<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, the table fetches through this object set instead of fetching based on\n * objectType. Supported for both object and interface types.\n *\n * For an interface object set, rows expose the interface's declared properties;\n * the underlying concrete object's non-interface properties are not loaded.\n * Use objectType-based fetching if you need those.\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?: (\n edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]\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 * The primary key of the row to render as visually focused (the\n * \"last interacted\" row). When provided, focus state is controlled by\n * the caller.\n *\n * Stored as a primary key rather than a full object so the focus does\n * not go stale when the underlying row data changes.\n *\n * Pass `null` to render no row as focused.\n */\n focusedRow?: PrimaryKeyType<Q> | null;\n\n /**\n * Called when the focused row changes — fires in both controlled and\n * uncontrolled modes so callers can observe focus without taking it\n * over.\n *\n * @param row The newly-focused row object, or `null` if focus was\n * cleared\n */\n onFocusedRowChanged?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs> | null\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?: (change: RowSelectionChange<Q, RDPs>) => 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 /**\n * Imperative handle for programmatic table actions. Pass a ref\n * (`useRef<ObjectTableHandle<Q, RDPs>>(null)`) to call\n * {@link ObjectTableHandle} methods such as\n * {@link ObjectTableHandle.getSnapshot}.\n */\n tableRef?: React.Ref<ObjectTableHandle<Q, RDPs>>;\n\n className?: string;\n}\n\n/**\n * Imperative handle exposing programmatic actions on an {@link ObjectTable}.\n * Obtain it by passing {@link ObjectTableProps.tableRef}.\n */\nexport interface ObjectTableHandle<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /**\n * Loads every row matching the object set and returns a format-agnostic\n * snapshot of the table's columns, row values, and total count. The caller\n * is responsible for turning the snapshot into a downloadable artifact\n * (CSV, Excel, JSON, clipboard, …).\n *\n * Property, derived-property, and function-backed columns are included.\n * Function-backed cells are fetched per page during snapshot collection;\n * when a page's fetch fails, `row.getValue(columnId)` returns the thrown\n * `Error` instance for the affected cells while the rest of the snapshot\n * resolves normally.\n * Columns defined with `locator.type === \"custom\"` are omitted because\n * they have no underlying value to export.\n *\n * The returned promise rejects up front when the object set's `totalCount`\n * exceeds `rowLimit`. When `totalCount` is unavailable, it instead rejects\n * mid-load once more than `rowLimit` rows have been pulled, so an unknown\n * count can't drain an unbounded set into the client. Otherwise every\n * matching row is loaded.\n *\n * @param options See {@link ObjectTableSnapshotOptions}.\n */\n getSnapshot: (\n options?: ObjectTableSnapshotOptions\n ) => Promise<ObjectTableSnapshot<Q, RDPs>>;\n}\n\n/**\n * Options for {@link ObjectTableHandle[\"getSnapshot\"]}.\n */\nexport interface ObjectTableSnapshotOptions {\n /**\n * Upper bound on how many rows the snapshot may contain. When the object\n * set's total row count exceeds this value, `getSnapshot` rejects;\n * otherwise every matching row is loaded.\n *\n * @default 10_000\n */\n rowLimit?: number;\n}\n\n/**\n * A point-in-time capture of an {@link ObjectTable}'s columns and row values,\n * returned by {@link ObjectTableHandle.getSnapshot}.\n */\nexport interface ObjectTableSnapshot<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n columns: ObjectTableDataColumn[];\n rows: ObjectTableDataRow<Q, RDPs>[];\n /**\n * Total number of objects matching the underlying object set, as reported\n * by the API. `undefined` when the API did not provide a count. Encoded as\n * a string to match the underlying list-payload representation.\n */\n totalCount: string | undefined;\n}\n\n/**\n * A single column in an {@link ObjectTableSnapshot}.\n */\nexport interface ObjectTableDataColumn {\n /** Column id, matching the `locator.id` of the column definition. */\n id: string;\n /** Display name shown in the table header. */\n name: string;\n}\n\n/**\n * A single row in an {@link ObjectTableSnapshot}.\n */\nexport interface ObjectTableDataRow<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /** Row id (the underlying object's `$primaryKey` rendered as a string). */\n id: string;\n /** The underlying loaded object. */\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>;\n /**\n * Returns the cell value for a given column id, or `undefined` when the\n * column is not part of the snapshot. Function-backed cells whose query\n * failed surface the thrown `Error` instance as their value.\n */\n getValue: (columnId: string) => unknown;\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 * `{ $primaryKey: { $in: selectedRows.map(r => r.$primaryKey) } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * Works for both object and interface types, since the `$primaryKey`\n * special property does not require resolving the underlying primary key\n * property name. `undefined` only when there is no underlying `ObjectSet`\n * to derive from.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<Q extends ObjectOrInterfaceDefinition> {\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\";\n\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 /**\n * Defines what the column shows:\n * an object/interface property, a linked object property (derived property), a function\n * column, or a custom column — and carries that locator's configuration.\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\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?: (value: unknown) => 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<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, the table fetches through this object set instead of fetching based on\n * objectType. Supported for both object and interface types.\n *\n * For an interface object set, rows expose the interface's declared properties;\n * the underlying concrete object's non-interface properties are not loaded.\n * Use objectType-based fetching if you need those.\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 * 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 * 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?: (\n edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]\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 * The primary key of the row to render as visually focused (the\n * \"last interacted\" row). When provided, focus state is controlled by\n * the caller.\n *\n * Stored as a primary key rather than a full object so the focus does\n * not go stale when the underlying row data changes.\n *\n * Pass `null` to render no row as focused.\n */\n focusedRow?: PrimaryKeyType<Q> | null;\n\n /**\n * Called when the focused row changes — fires in both controlled and\n * uncontrolled modes so callers can observe focus without taking it\n * over.\n *\n * @param row The newly-focused row object, or `null` if focus was\n * cleared\n */\n onFocusedRowChanged?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs> | null\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, with a {@link RowSelectionChange}\n * payload describing the new state.\n *\n * @param change The new selection state. See {@link RowSelectionChange}.\n */\n onRowSelectionChanged?: (change: RowSelectionChange<Q, RDPs>) => 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 /**\n * Imperative handle for programmatic table actions. Pass a ref\n * (`useRef<ObjectTableHandle<Q, RDPs>>(null)`) to call\n * {@link ObjectTableHandle} methods such as\n * {@link ObjectTableHandle.getSnapshot}.\n */\n tableRef?: React.Ref<ObjectTableHandle<Q, RDPs>>;\n\n className?: string;\n}\n\n/**\n * Imperative handle exposing programmatic actions on an {@link ObjectTable}.\n * Obtain it by passing {@link ObjectTableProps.tableRef}.\n */\nexport interface ObjectTableHandle<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /**\n * Loads every row matching the object set and returns a format-agnostic\n * snapshot of the table's columns, row values, and total count. The caller\n * is responsible for turning the snapshot into a downloadable artifact\n * (CSV, Excel, JSON, clipboard, …).\n *\n * Property, derived-property, and function-backed columns are included.\n * Function-backed cells are fetched per page during snapshot collection;\n * when a page's fetch fails, `row.getValue(columnId)` returns the thrown\n * `Error` instance for the affected cells while the rest of the snapshot\n * resolves normally.\n * Columns defined with `locator.type === \"custom\"` are omitted because\n * they have no underlying value to export.\n *\n * The returned promise rejects up front when the object set's `totalCount`\n * exceeds `rowLimit`. When `totalCount` is unavailable, it instead rejects\n * mid-load once more than `rowLimit` rows have been pulled, so an unknown\n * count can't drain an unbounded set into the client. Otherwise every\n * matching row is loaded.\n *\n * @param options See {@link ObjectTableSnapshotOptions}.\n */\n getSnapshot: (\n options?: ObjectTableSnapshotOptions\n ) => Promise<ObjectTableSnapshot<Q, RDPs>>;\n}\n\n/**\n * Options for {@link ObjectTableHandle[\"getSnapshot\"]}.\n */\nexport interface ObjectTableSnapshotOptions {\n /**\n * Upper bound on how many rows the snapshot may contain. When the object\n * set's total row count exceeds this value, `getSnapshot` rejects;\n * otherwise every matching row is loaded.\n *\n * @default 10_000\n */\n rowLimit?: number;\n}\n\n/**\n * A point-in-time capture of an {@link ObjectTable}'s columns and row values,\n * returned by {@link ObjectTableHandle.getSnapshot}.\n */\nexport interface ObjectTableSnapshot<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n columns: ObjectTableDataColumn[];\n rows: ObjectTableDataRow<Q, RDPs>[];\n /**\n * Total number of objects matching the underlying object set, as reported\n * by the API. `undefined` when the API did not provide a count. Encoded as\n * a string to match the underlying list-payload representation.\n */\n totalCount: string | undefined;\n}\n\n/**\n * A single column in an {@link ObjectTableSnapshot}.\n */\nexport interface ObjectTableDataColumn {\n /** Column id, matching the `locator.id` of the column definition. */\n id: string;\n /** Display name shown in the table header. */\n name: string;\n}\n\n/**\n * A single row in an {@link ObjectTableSnapshot}.\n */\nexport interface ObjectTableDataRow<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /** Row id (the underlying object's `$primaryKey` rendered as a string). */\n id: string;\n /** The underlying loaded object. */\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>;\n /**\n * Returns the cell value for a given column id, or `undefined` when the\n * column is not part of the snapshot. Function-backed cells whose query\n * failed surface the thrown `Error` instance as their value.\n */\n getValue: (columnId: string) => unknown;\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 * `{ $primaryKey: { $in: selectedRows.map(r => r.$primaryKey) } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * Works for both object and interface types, since the `$primaryKey`\n * special property does not require resolving the underlying primary key\n * property name. `undefined` only when there is no underlying `ObjectSet`\n * to derive from.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<Q extends ObjectOrInterfaceDefinition> {\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":[]}
|
|
@@ -52,7 +52,6 @@ function getColumnsFromColumnDefinitions(columnDefinitions, objectProperties) {
|
|
|
52
52
|
maxWidth,
|
|
53
53
|
resizable,
|
|
54
54
|
orderable,
|
|
55
|
-
filterable,
|
|
56
55
|
editable,
|
|
57
56
|
renderCell,
|
|
58
57
|
renderHeader,
|
|
@@ -88,7 +87,6 @@ function getColumnsFromColumnDefinitions(columnDefinitions, objectProperties) {
|
|
|
88
87
|
enableResizing: resizable,
|
|
89
88
|
// Function-backed columns must be sorted on the frontend, so disable sorting for now
|
|
90
89
|
enableSorting: locator.type === "function" ? false : orderable,
|
|
91
|
-
enableColumnFilter: filterable,
|
|
92
90
|
cell: cellContext => {
|
|
93
91
|
const object = cellContext.row.original;
|
|
94
92
|
const meta = cellContext.table.options.meta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useColumnDefs.js","names":["useOsdkMetadata","useMemo","renderDefaultCell","shouldShowEditableCell","useColumnDefs","objectType","columnDefinitions","metadata","loading","error","columns","objectProperties","properties","getColumnsFromColumnDefinitions","getDefaultColumns","map","col","locator","width","minWidth","maxWidth","resizable","orderable","filterable","editable","renderCell","renderHeader","columnName","editFieldConfig","undefined","validateEdit","propertyMetadata","type","id","colKey","dataType","markingType","typeMetadata","colDef","accessorKey","header","displayName","meta","isAsyncColumn","isVisible","size","minSize","maxSize","enableResizing","enableSorting","enableColumnFilter","cell","cellContext","object","row","original","table","options","isEditable","onCellEdit","isInEditMode","Object","entries","key","property"],"sources":["useColumnDefs.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 ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useOsdkMetadata } from \"@osdk/react\";\nimport type { AccessorColumnDef } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\n\nimport { renderDefaultCell } from \"../DefaultCellRenderer.js\";\nimport type { ColumnDefinition } from \"../ObjectTableApi.js\";\nimport { shouldShowEditableCell } from \"../utils/shouldShowEditableCell.js\";\n\nexport interface UseColumnDefsResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n columns: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >[];\n\n loading: boolean;\n\n error: string | undefined;\n}\n\n/**\n * Hook which builds column definitions for tanstack-table given the objectSet\n */\nexport function useColumnDefs<\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 objectType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>\n): UseColumnDefsResult<Q, RDPs> {\n const { metadata, loading, error } = useOsdkMetadata(objectType);\n\n const columns: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >[] = useMemo(() => {\n const objectProperties = metadata?.properties;\n // If columnDefinitions is provided, construct colDefs with it\n if (columnDefinitions) {\n return getColumnsFromColumnDefinitions<Q, RDPs, FunctionColumns>(\n columnDefinitions,\n objectProperties\n );\n }\n\n // If not, return the default columns from the object properties\n return getDefaultColumns<Q, RDPs>(objectProperties);\n }, [columnDefinitions, metadata?.properties]);\n\n return { columns, loading, error };\n}\n\nfunction getColumnsFromColumnDefinitions<\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 columnDefinitions: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n objectProperties?: Record<any, ObjectMetadata.Property>\n): Array<\n AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n> {\n return columnDefinitions.map((col) => {\n const {\n locator,\n width,\n minWidth,\n maxWidth,\n resizable,\n orderable,\n filterable,\n editable,\n renderCell,\n renderHeader,\n columnName,\n } = col;\n\n const editFieldConfig = col.editable ? col.editFieldConfig : undefined;\n const validateEdit = col.editable ? col.validateEdit : undefined;\n\n const propertyMetadata =\n locator.type === \"property\" ? objectProperties?.[locator.id] : undefined;\n\n const colKey = locator.id as string;\n\n const dataType =\n propertyMetadata?.type && typeof propertyMetadata.type === \"string\"\n ? propertyMetadata.type\n : undefined;\n\n const markingType =\n propertyMetadata?.typeMetadata?.type === \"marking\"\n ? propertyMetadata.typeMetadata.markingType\n : undefined;\n\n const colDef: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n id: colKey,\n accessorKey: colKey,\n header: renderHeader ?? (columnName || propertyMetadata?.displayName),\n meta: {\n columnName: columnName || propertyMetadata?.displayName,\n isAsyncColumn: locator.type === \"function\",\n isVisible: col.isVisible !== false,\n editable,\n editFieldConfig,\n dataType,\n markingType,\n validateEdit,\n },\n size: width,\n ...(minWidth ? { minSize: minWidth } : {}),\n ...(maxWidth ? { maxSize: maxWidth } : {}),\n enableResizing: resizable,\n // Function-backed columns must be sorted on the frontend, so disable sorting for now\n enableSorting: locator.type === \"function\" ? false : orderable,\n enableColumnFilter: filterable,\n cell: (cellContext) => {\n const object: Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n > = cellContext.row.original;\n\n const meta = cellContext.table.options.meta;\n const isEditable = shouldShowEditableCell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >(editable, meta?.onCellEdit, meta?.isInEditMode);\n\n if (renderCell && !isEditable) {\n return renderCell(object, locator);\n }\n\n return renderDefaultCell(cellContext);\n },\n };\n\n return colDef;\n });\n}\n\nfunction getDefaultColumns<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n objectProperties?: Record<any, ObjectMetadata.Property>\n): Array<\n AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n> {\n if (!objectProperties) return [];\n\n return Object.entries(objectProperties).map(([key, property]) => {\n const colDef: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n accessorKey: key,\n header: property.displayName ?? key,\n };\n return colDef;\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,eAAe,QAAQ,aAAa;AAE7C,SAASC,OAAO,QAAQ,OAAO;AAE/B,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,SAASC,sBAAsB,QAAQ,oCAAoC;AAe3E;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAQ3BC,UAAa,EACbC,iBAAqE,EACvC;EAC9B,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGT,eAAe,CAACK,UAAU,CAAC;EAEhE,MAAMK,OAEH,GAAGT,OAAO,CAAC,MAAM;IAClB,MAAMU,gBAAgB,GAAGJ,QAAQ,EAAEK,UAAU;IAC7C;IACA,IAAIN,iBAAiB,EAAE;MACrB,OAAOO,+BAA+B,CACpCP,iBAAiB,EACjBK,gBACF,CAAC;IACH;;IAEA;IACA,OAAOG,iBAAiB,CAAUH,gBAAgB,CAAC;EACrD,CAAC,EAAE,CAACL,iBAAiB,EAAEC,QAAQ,EAAEK,UAAU,CAAC,CAAC;EAE7C,OAAO;IAAEF,OAAO;IAAEF,OAAO;IAAEC;EAAM,CAAC;AACpC;AAEA,SAASI,+BAA+BA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","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useColumnDefs.js","names":["useOsdkMetadata","useMemo","renderDefaultCell","shouldShowEditableCell","useColumnDefs","objectType","columnDefinitions","metadata","loading","error","columns","objectProperties","properties","getColumnsFromColumnDefinitions","getDefaultColumns","map","col","locator","width","minWidth","maxWidth","resizable","orderable","editable","renderCell","renderHeader","columnName","editFieldConfig","undefined","validateEdit","propertyMetadata","type","id","colKey","dataType","markingType","typeMetadata","colDef","accessorKey","header","displayName","meta","isAsyncColumn","isVisible","size","minSize","maxSize","enableResizing","enableSorting","cell","cellContext","object","row","original","table","options","isEditable","onCellEdit","isInEditMode","Object","entries","key","property"],"sources":["useColumnDefs.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 ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useOsdkMetadata } from \"@osdk/react\";\nimport type { AccessorColumnDef } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\n\nimport { renderDefaultCell } from \"../DefaultCellRenderer.js\";\nimport type { ColumnDefinition } from \"../ObjectTableApi.js\";\nimport { shouldShowEditableCell } from \"../utils/shouldShowEditableCell.js\";\n\nexport interface UseColumnDefsResult<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n columns: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >[];\n\n loading: boolean;\n\n error: string | undefined;\n}\n\n/**\n * Hook which builds column definitions for tanstack-table given the objectSet\n */\nexport function useColumnDefs<\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 objectType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>\n): UseColumnDefsResult<Q, RDPs> {\n const { metadata, loading, error } = useOsdkMetadata(objectType);\n\n const columns: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >[] = useMemo(() => {\n const objectProperties = metadata?.properties;\n // If columnDefinitions is provided, construct colDefs with it\n if (columnDefinitions) {\n return getColumnsFromColumnDefinitions<Q, RDPs, FunctionColumns>(\n columnDefinitions,\n objectProperties\n );\n }\n\n // If not, return the default columns from the object properties\n return getDefaultColumns<Q, RDPs>(objectProperties);\n }, [columnDefinitions, metadata?.properties]);\n\n return { columns, loading, error };\n}\n\nfunction getColumnsFromColumnDefinitions<\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 columnDefinitions: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n objectProperties?: Record<any, ObjectMetadata.Property>\n): Array<\n AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n> {\n return columnDefinitions.map((col) => {\n const {\n locator,\n width,\n minWidth,\n maxWidth,\n resizable,\n orderable,\n editable,\n renderCell,\n renderHeader,\n columnName,\n } = col;\n\n const editFieldConfig = col.editable ? col.editFieldConfig : undefined;\n const validateEdit = col.editable ? col.validateEdit : undefined;\n\n const propertyMetadata =\n locator.type === \"property\" ? objectProperties?.[locator.id] : undefined;\n\n const colKey = locator.id as string;\n\n const dataType =\n propertyMetadata?.type && typeof propertyMetadata.type === \"string\"\n ? propertyMetadata.type\n : undefined;\n\n const markingType =\n propertyMetadata?.typeMetadata?.type === \"marking\"\n ? propertyMetadata.typeMetadata.markingType\n : undefined;\n\n const colDef: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n id: colKey,\n accessorKey: colKey,\n header: renderHeader ?? (columnName || propertyMetadata?.displayName),\n meta: {\n columnName: columnName || propertyMetadata?.displayName,\n isAsyncColumn: locator.type === \"function\",\n isVisible: col.isVisible !== false,\n editable,\n editFieldConfig,\n dataType,\n markingType,\n validateEdit,\n },\n size: width,\n ...(minWidth ? { minSize: minWidth } : {}),\n ...(maxWidth ? { maxSize: maxWidth } : {}),\n enableResizing: resizable,\n // Function-backed columns must be sorted on the frontend, so disable sorting for now\n enableSorting: locator.type === \"function\" ? false : orderable,\n cell: (cellContext) => {\n const object: Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n > = cellContext.row.original;\n\n const meta = cellContext.table.options.meta;\n const isEditable = shouldShowEditableCell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >(editable, meta?.onCellEdit, meta?.isInEditMode);\n\n if (renderCell && !isEditable) {\n return renderCell(object, locator);\n }\n\n return renderDefaultCell(cellContext);\n },\n };\n\n return colDef;\n });\n}\n\nfunction getDefaultColumns<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n objectProperties?: Record<any, ObjectMetadata.Property>\n): Array<\n AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n> {\n if (!objectProperties) return [];\n\n return Object.entries(objectProperties).map(([key, property]) => {\n const colDef: AccessorColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n accessorKey: key,\n header: property.displayName ?? key,\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B,MAAMZ,IAAI,GAAGS,WAAW,CAACI,KAAK,CAACC,OAAO,CAACd,IAAI;QAC3C,MAAMe,UAAU,GAAGrD,sBAAsB,CAEvCoB,QAAQ,EAAEkB,IAAI,EAAEgB,UAAU,EAAEhB,IAAI,EAAEiB,YAAY,CAAC;QAEjD,IAAIlC,UAAU,IAAI,CAACgC,UAAU,EAAE;UAC7B,OAAOhC,UAAU,CAAC2B,MAAM,EAAElC,OAAO,CAAC;QACpC;QAEA,OAAOf,iBAAiB,CAACgD,WAAW,CAAC;MACvC;IACF,CAAC;IAED,OAAOb,MAAM;EACf,CAAC,CAAC;AACJ;AAEA,SAASvB,iBAAiBA,CAIxBH,gBAAuD,EAKvD;EACA,IAAI,CAACA,gBAAgB,EAAE,OAAO,EAAE;EAEhC,OAAOgD,MAAM,CAACC,OAAO,CAACjD,gBAAgB,CAAC,CAACI,GAAG,CAAC,CAAC,CAAC8C,GAAG,EAAEC,QAAQ,CAAC,KAAK;IAC/D,MAAMzB,MAEL,GAAG;MACFC,WAAW,EAAEuB,GAAG;MAChBtB,MAAM,EAAEuB,QAAQ,CAACtB,WAAW,IAAIqB;IAClC,CAAC;IACD,OAAOxB,MAAM;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -28,8 +28,6 @@ export function useRowSelection({
|
|
|
28
28
|
selectionMode = "none",
|
|
29
29
|
selectedRows,
|
|
30
30
|
isAllSelected: isAllSelectedProp,
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility
|
|
32
|
-
onRowSelection,
|
|
33
31
|
onRowSelectionChanged,
|
|
34
32
|
data
|
|
35
33
|
}) {
|
|
@@ -59,7 +57,6 @@ export function useRowSelection({
|
|
|
59
57
|
// Dedupes refires when "select all" is active and data grows.
|
|
60
58
|
const lastFiredAllSelectedIdsRef = useRef(null);
|
|
61
59
|
const fireSelectionCallbacks = useEventCallback((ids, isSelectAll) => {
|
|
62
|
-
onRowSelection?.(ids, isSelectAll);
|
|
63
60
|
if (onRowSelectionChanged) {
|
|
64
61
|
const selectedKeySet = new Set(ids.map(id => String(id)));
|
|
65
62
|
const instances = (data ?? []).filter(item => selectedKeySet.has(String(item.$primaryKey)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowSelection.js","names":["useCallback","useEffect","useMemo","useRef","useState","useEventCallback","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onRowSelection","onRowSelectionChanged","data","internalRowSelection","setInternalRowSelection","internalIsAllSelected","setInternalIsAllSelected","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","enableRowSelection","rowSelectionState","selectedRowIds","map","item","$primaryKey","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","deriveIsAllSelected","hasSelection","lastFiredAllSelectedIdsRef","fireSelectionCallbacks","ids","isSelectAll","selectedKeySet","Set","id","String","instances","has","onToggleAll","newIsAllSelected","newSelectedRows","current","JSON","stringify","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","isCurrentlySelected","serializedIds","rowSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { useEventCallback } from \"../../shared/hooks/useEventCallback.js\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\n/**\n * Payload delivered by {@link UseRowSelectionProps.onRowSelectionChanged}.\n * Mirrors the OSDK-level `RowSelectionChange` but without the `objectSet`\n * field, which requires OSDK context and is composed in `ObjectTable`.\n */\nexport interface UseRowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n selectedRows: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[];\n isSelectAll: boolean;\n}\n\nexport interface UseRowSelectionProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n isAllSelected?: boolean;\n /**\n * @deprecated Use {@link onRowSelectionChanged} instead.\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll: boolean\n ) => void;\n onRowSelectionChanged?: (change: UseRowSelectionChange<Q, RDPs>) => void;\n data:\n | Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: boolean;\n enableRowSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (\n rowId: string,\n rowIndex: number,\n isShiftClick?: boolean\n ) => void;\n}\n\nexport function useRowSelection<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility\n onRowSelection,\n onRowSelectionChanged,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n const [internalRowSelection, setInternalRowSelection] =\n useState<RowSelectionState>({});\n\n // When true, newly fetched rows are auto-selected (uncontrolled mode only).\n const [internalIsAllSelected, setInternalIsAllSelected] = useState(false);\n\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const enableRowSelection = selectionMode !== \"none\";\n\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!enableRowSelection) return {};\n if (isControlled) {\n const selectedRowIds = isAllSelectedProp\n ? (data ?? []).map((item) => item.$primaryKey)\n : selectedRows;\n return getRowSelectionState(selectedRowIds);\n }\n if (internalIsAllSelected) {\n return getRowSelectionState((data ?? []).map((item) => item.$primaryKey));\n }\n return internalRowSelection;\n }, [\n enableRowSelection,\n isControlled,\n selectedRows,\n isAllSelectedProp,\n internalIsAllSelected,\n internalRowSelection,\n data,\n ]);\n\n const selectedCount = useMemo(\n () => Object.values(rowSelectionState).filter(Boolean).length,\n [rowSelectionState]\n );\n const totalCount = data?.length ?? 0;\n const isAllSelected = deriveIsAllSelected(\n isControlled,\n isAllSelectedProp,\n internalIsAllSelected,\n selectedCount,\n totalCount\n );\n const hasSelection = isAllSelected || selectedCount > 0;\n\n // Dedupes refires when \"select all\" is active and data grows.\n const lastFiredAllSelectedIdsRef = useRef<string | null>(null);\n\n const fireSelectionCallbacks = useEventCallback(\n (ids: PrimaryKeyType<Q>[], isSelectAll: boolean) => {\n onRowSelection?.(ids, isSelectAll);\n if (onRowSelectionChanged) {\n const currentData = data ?? [];\n const selectedKeySet = new Set(ids.map((id) => String(id)));\n const instances = currentData.filter((item) =>\n selectedKeySet.has(String(item.$primaryKey))\n );\n onRowSelectionChanged({\n selectedRows: instances,\n isSelectAll,\n });\n }\n }\n );\n\n const onToggleAll = useCallback(() => {\n if (!enableRowSelection || !data) return;\n\n // Any existing selection (full or partial/indeterminate) clears on click;\n // only an empty selection promotes to \"select all\".\n const newIsAllSelected = !hasSelection;\n const newSelectedRows: PrimaryKeyType<Q>[] = newIsAllSelected\n ? data.map((item) => item.$primaryKey)\n : [];\n\n if (!isControlled) {\n setInternalIsAllSelected(newIsAllSelected);\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n lastFiredAllSelectedIdsRef.current = newIsAllSelected\n ? JSON.stringify(newSelectedRows)\n : null;\n fireSelectionCallbacks(newSelectedRows, newIsAllSelected);\n }, [\n enableRowSelection,\n data,\n hasSelection,\n isControlled,\n fireSelectionCallbacks,\n ]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!enableRowSelection || !data) return;\n\n let newSelectedRows: PrimaryKeyType<Q>[];\n\n if (selectionMode === \"single\") {\n newSelectedRows = getSingleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n } else {\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows({\n rowId,\n rowIndex,\n data,\n lastSelectedRowIndex,\n rowSelectionState,\n });\n setLastSelectedRowIndex(rowIndex);\n } else {\n newSelectedRows = getMultipleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n if (\n !isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\n ) {\n setLastSelectedRowIndex(rowIndex);\n }\n }\n }\n if (!isControlled) {\n setInternalIsAllSelected(false);\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n lastFiredAllSelectedIdsRef.current = null;\n fireSelectionCallbacks(newSelectedRows, false);\n },\n [\n enableRowSelection,\n data,\n selectionMode,\n isControlled,\n fireSelectionCallbacks,\n rowSelectionState,\n lastSelectedRowIndex,\n ]\n );\n\n // Refire callbacks when uncontrolled \"select all\" is active and new rows arrive.\n useEffect(\n function syncSelectAllOnDataChange() {\n if (isControlled || !internalIsAllSelected || !data) {\n if (!internalIsAllSelected) {\n lastFiredAllSelectedIdsRef.current = null;\n }\n return;\n }\n const ids = data.map((item) => item.$primaryKey);\n const serializedIds = JSON.stringify(ids);\n if (lastFiredAllSelectedIdsRef.current === serializedIds) return;\n lastFiredAllSelectedIdsRef.current = serializedIds;\n fireSelectionCallbacks(ids, true);\n },\n [isControlled, internalIsAllSelected, data, fireSelectionCallbacks]\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n enableRowSelection,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n return rowSelectionState[rowId] ? [] : [primaryKey];\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n lastSelectedRowIndex,\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n if (lastSelectedRowIndex != null) {\n const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);\n const primaryKeysInRange = rowsInRange.map((item) => item.$primaryKey);\n\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n\n const newSelectedRows = [...currentlySelected];\n primaryKeysInRange.forEach((item) => {\n if (!newSelectedRows.includes(item)) {\n newSelectedRows.push(item);\n }\n });\n return newSelectedRows;\n }\n return [];\n}\n\nfunction isCurrentlySelected<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowIndex,\n data,\n rowSelectionState,\n}: Pick<\n GetSelectedRowsProps<Q, RDPs>,\n \"rowIndex\" | \"data\" | \"rowSelectionState\"\n>): boolean {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n return currentlySelected.includes(primaryKey);\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n return isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\n ? currentlySelected.filter((i) => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n}\n\nfunction getRowsInRange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>,\n startIndex: number,\n endIndex: number\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = [];\n\n for (let i = start; i <= end; i++) {\n const item = data[i];\n if (item) {\n rows.push(item);\n }\n }\n\n return rows;\n}\n\nfunction deriveIsAllSelected(\n isControlled: boolean,\n isAllSelectedProp: boolean | undefined,\n internalIsAllSelected: boolean,\n selectedCount: number,\n totalCount: number\n): boolean {\n if (isControlled && isAllSelectedProp !== undefined) return isAllSelectedProp;\n if (!isControlled && internalIsAllSelected) return true;\n return totalCount > 0 && selectedCount === totalCount;\n}\n\nfunction getRowSelectionState<Q extends ObjectOrInterfaceDefinition>(\n primaryKeys: PrimaryKeyType<Q>[]\n): RowSelectionState {\n return primaryKeys.reduce<RowSelectionState>((acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n }, {});\n}\n\nfunction getSelectedPrimaryKeys<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n): PrimaryKeyType<Q>[] {\n return data\n .filter((item) => selectionState[getRowId(item)])\n .map((item) => item.$primaryKey);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEzE,SAASC,gBAAgB,QAAQ,wCAAwC;AACzE,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,sBAAsB;;AAEvE;AACA;AACA;AACA;AACA;;AA0CA,OAAO,SAASC,eAAeA,CAG7B;EACAC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,aAAa,EAAEC,iBAAiB;EAChC;EACAC,cAAc;EACdC,qBAAqB;EACrBC;AAC6B,CAAC,EAAyB;EACvD,MAAM,CAACC,oBAAoB,EAAEC,uBAAuB,CAAC,GACnDb,QAAQ,CAAoB,CAAC,CAAC,CAAC;;EAEjC;EACA,MAAM,CAACc,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGf,QAAQ,CAAC,KAAK,CAAC;EAEzE,MAAM,CAACgB,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGjB,QAAQ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GAAGG,KAAK,EAAEH,CAAC,IAAIM,GAAG,EAAEN,CAAC,EAAE,EAAE;IACjC,MAAM/C,IAAI,GAAGb,IAAI,CAAC4D,CAAC,CAAC;IACpB,IAAI/C,IAAI,EAAE;MACRuD,IAAI,CAACT,IAAI,CAAC9C,IAAI,CAAC;IACjB;EACF;EAEA,OAAOuD,IAAI;AACb;AAEA,SAAS7C,mBAAmBA,CAC1BhB,YAAqB,EACrBV,iBAAsC,EACtCM,qBAA8B,EAC9Ba,aAAqB,EACrBM,UAAkB,EACT;EACT,IAAIf,YAAY,IAAIV,iBAAiB,KAAKW,SAAS,EAAE,OAAOX,iBAAiB;EAC7E,IAAI,CAACU,YAAY,IAAIJ,qBAAqB,EAAE,OAAO,IAAI;EACvD,OAAOmB,UAAU,GAAG,CAAC,IAAIN,aAAa,KAAKM,UAAU;AACvD;AAEA,SAASP,oBAAoBA,CAC3BsD,WAAgC,EACb;EACnB,OAAOA,WAAW,CAACC,MAAM,CAAoB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IAChEoB,GAAG,CAAC/E,sBAAsB,CAAC2D,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCxE,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRmB,MAAM,CAAEN,IAAI,IAAK2D,cAAc,CAACjF,QAAQ,CAACsB,IAAI,CAAC,CAAC,CAAC,CAChDD,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,WAAW,CAAC;AACpC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useRowSelection.js","names":["useCallback","useEffect","useMemo","useRef","useState","useEventCallback","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onRowSelectionChanged","data","internalRowSelection","setInternalRowSelection","internalIsAllSelected","setInternalIsAllSelected","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","enableRowSelection","rowSelectionState","selectedRowIds","map","item","$primaryKey","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","deriveIsAllSelected","hasSelection","lastFiredAllSelectedIdsRef","fireSelectionCallbacks","ids","isSelectAll","selectedKeySet","Set","id","String","instances","has","onToggleAll","newIsAllSelected","newSelectedRows","current","JSON","stringify","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","isCurrentlySelected","serializedIds","rowSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { useEventCallback } from \"../../shared/hooks/useEventCallback.js\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\n/**\n * Payload delivered by {@link UseRowSelectionProps.onRowSelectionChanged}.\n * Mirrors the OSDK-level `RowSelectionChange` but without the `objectSet`\n * field, which requires OSDK context and is composed in `ObjectTable`.\n */\nexport interface UseRowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n selectedRows: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[];\n isSelectAll: boolean;\n}\n\nexport interface UseRowSelectionProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n isAllSelected?: boolean;\n onRowSelectionChanged?: (change: UseRowSelectionChange<Q, RDPs>) => void;\n data:\n | Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: boolean;\n enableRowSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (\n rowId: string,\n rowIndex: number,\n isShiftClick?: boolean\n ) => void;\n}\n\nexport function useRowSelection<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onRowSelectionChanged,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n const [internalRowSelection, setInternalRowSelection] =\n useState<RowSelectionState>({});\n\n // When true, newly fetched rows are auto-selected (uncontrolled mode only).\n const [internalIsAllSelected, setInternalIsAllSelected] = useState(false);\n\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const enableRowSelection = selectionMode !== \"none\";\n\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!enableRowSelection) return {};\n if (isControlled) {\n const selectedRowIds = isAllSelectedProp\n ? (data ?? []).map((item) => item.$primaryKey)\n : selectedRows;\n return getRowSelectionState(selectedRowIds);\n }\n if (internalIsAllSelected) {\n return getRowSelectionState((data ?? []).map((item) => item.$primaryKey));\n }\n return internalRowSelection;\n }, [\n enableRowSelection,\n isControlled,\n selectedRows,\n isAllSelectedProp,\n internalIsAllSelected,\n internalRowSelection,\n data,\n ]);\n\n const selectedCount = useMemo(\n () => Object.values(rowSelectionState).filter(Boolean).length,\n [rowSelectionState]\n );\n const totalCount = data?.length ?? 0;\n const isAllSelected = deriveIsAllSelected(\n isControlled,\n isAllSelectedProp,\n internalIsAllSelected,\n selectedCount,\n totalCount\n );\n const hasSelection = isAllSelected || selectedCount > 0;\n\n // Dedupes refires when \"select all\" is active and data grows.\n const lastFiredAllSelectedIdsRef = useRef<string | null>(null);\n\n const fireSelectionCallbacks = useEventCallback(\n (ids: PrimaryKeyType<Q>[], isSelectAll: boolean) => {\n if (onRowSelectionChanged) {\n const currentData = data ?? [];\n const selectedKeySet = new Set(ids.map((id) => String(id)));\n const instances = currentData.filter((item) =>\n selectedKeySet.has(String(item.$primaryKey))\n );\n onRowSelectionChanged({\n selectedRows: instances,\n isSelectAll,\n });\n }\n }\n );\n\n const onToggleAll = useCallback(() => {\n if (!enableRowSelection || !data) return;\n\n // Any existing selection (full or partial/indeterminate) clears on click;\n // only an empty selection promotes to \"select all\".\n const newIsAllSelected = !hasSelection;\n const newSelectedRows: PrimaryKeyType<Q>[] = newIsAllSelected\n ? data.map((item) => item.$primaryKey)\n : [];\n\n if (!isControlled) {\n setInternalIsAllSelected(newIsAllSelected);\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n lastFiredAllSelectedIdsRef.current = newIsAllSelected\n ? JSON.stringify(newSelectedRows)\n : null;\n fireSelectionCallbacks(newSelectedRows, newIsAllSelected);\n }, [\n enableRowSelection,\n data,\n hasSelection,\n isControlled,\n fireSelectionCallbacks,\n ]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!enableRowSelection || !data) return;\n\n let newSelectedRows: PrimaryKeyType<Q>[];\n\n if (selectionMode === \"single\") {\n newSelectedRows = getSingleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n } else {\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows({\n rowId,\n rowIndex,\n data,\n lastSelectedRowIndex,\n rowSelectionState,\n });\n setLastSelectedRowIndex(rowIndex);\n } else {\n newSelectedRows = getMultipleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n if (\n !isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\n ) {\n setLastSelectedRowIndex(rowIndex);\n }\n }\n }\n if (!isControlled) {\n setInternalIsAllSelected(false);\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n lastFiredAllSelectedIdsRef.current = null;\n fireSelectionCallbacks(newSelectedRows, false);\n },\n [\n enableRowSelection,\n data,\n selectionMode,\n isControlled,\n fireSelectionCallbacks,\n rowSelectionState,\n lastSelectedRowIndex,\n ]\n );\n\n // Refire callbacks when uncontrolled \"select all\" is active and new rows arrive.\n useEffect(\n function syncSelectAllOnDataChange() {\n if (isControlled || !internalIsAllSelected || !data) {\n if (!internalIsAllSelected) {\n lastFiredAllSelectedIdsRef.current = null;\n }\n return;\n }\n const ids = data.map((item) => item.$primaryKey);\n const serializedIds = JSON.stringify(ids);\n if (lastFiredAllSelectedIdsRef.current === serializedIds) return;\n lastFiredAllSelectedIdsRef.current = serializedIds;\n fireSelectionCallbacks(ids, true);\n },\n [isControlled, internalIsAllSelected, data, fireSelectionCallbacks]\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n enableRowSelection,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n return rowSelectionState[rowId] ? [] : [primaryKey];\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n lastSelectedRowIndex,\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n if (lastSelectedRowIndex != null) {\n const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);\n const primaryKeysInRange = rowsInRange.map((item) => item.$primaryKey);\n\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n\n const newSelectedRows = [...currentlySelected];\n primaryKeysInRange.forEach((item) => {\n if (!newSelectedRows.includes(item)) {\n newSelectedRows.push(item);\n }\n });\n return newSelectedRows;\n }\n return [];\n}\n\nfunction isCurrentlySelected<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowIndex,\n data,\n rowSelectionState,\n}: Pick<\n GetSelectedRowsProps<Q, RDPs>,\n \"rowIndex\" | \"data\" | \"rowSelectionState\"\n>): boolean {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n return currentlySelected.includes(primaryKey);\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n rowIndex,\n data,\n rowSelectionState,\n}: GetSelectedRowsProps<Q, RDPs>): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n return isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\n ? currentlySelected.filter((i) => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n}\n\nfunction getRowsInRange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>,\n startIndex: number,\n endIndex: number\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = [];\n\n for (let i = start; i <= end; i++) {\n const item = data[i];\n if (item) {\n rows.push(item);\n }\n }\n\n return rows;\n}\n\nfunction deriveIsAllSelected(\n isControlled: boolean,\n isAllSelectedProp: boolean | undefined,\n internalIsAllSelected: boolean,\n selectedCount: number,\n totalCount: number\n): boolean {\n if (isControlled && isAllSelectedProp !== undefined) return isAllSelectedProp;\n if (!isControlled && internalIsAllSelected) return true;\n return totalCount > 0 && selectedCount === totalCount;\n}\n\nfunction getRowSelectionState<Q extends ObjectOrInterfaceDefinition>(\n primaryKeys: PrimaryKeyType<Q>[]\n): RowSelectionState {\n return primaryKeys.reduce<RowSelectionState>((acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n }, {});\n}\n\nfunction getSelectedPrimaryKeys<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n): PrimaryKeyType<Q>[] {\n return data\n .filter((item) => selectionState[getRowId(item)])\n .map((item) => item.$primaryKey);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCxE,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRmB,MAAM,CAAEN,IAAI,IAAK2D,cAAc,CAAChF,QAAQ,CAACqB,IAAI,CAAC,CAAC,CAAC,CAChDD,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,WAAW,CAAC;AACpC","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.
|
|
17
|
+
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.40.0-main-a2b6fc49d4e2239fddc00a2d4ed0782fd1f96fd0"}`;
|
|
18
18
|
export function componentUserAgent(componentName) {
|
|
19
19
|
return `${PACKAGE_USER_AGENT}/${componentName}`;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.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\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.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\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,iFAAsD;AAEjF,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkRVZE7LPI_cjs = require('./chunk-RVZE7LPI.cjs');
|
|
4
|
+
var chunkIWZT7CPM_cjs = require('./chunk-IWZT7CPM.cjs');
|
|
5
|
+
|
|
6
|
+
// src/public/experimental/xml-viewer.ts
|
|
7
|
+
var XmlViewer2 = chunkIWZT7CPM_cjs.withOsdkMetrics(chunkRVZE7LPI_cjs.XmlViewer, "XmlViewer");
|
|
8
|
+
|
|
9
|
+
exports.XmlViewer = XmlViewer2;
|
|
10
|
+
//# sourceMappingURL=chunk-2NG63762.cjs.map
|
|
11
|
+
//# sourceMappingURL=chunk-2NG63762.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public/experimental/xml-viewer.ts"],"names":["XmlViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,UAAAA,GAAYC,iCAAA,CAAgBD,2BAAA,EAAY,WAAW","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/public/experimental/xml-viewer.ts"],"names":["XmlViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,UAAAA,GAAYC,iCAAA,CAAgBD,2BAAA,EAAY,WAAW","file":"chunk-2NG63762.cjs","sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// BaseXmlViewer\nexport { BaseXmlViewer } from \"../../xml-viewer/BaseXmlViewer.js\";\n// XmlViewer (Media wrapper)\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nimport { XmlViewer as _XmlViewer } from \"../../xml-viewer/XmlViewer.js\";\nexport const XmlViewer = withOsdkMetrics(_XmlViewer, \"XmlViewer\");"]}
|
|
@@ -9,7 +9,7 @@ var chunkXJDMSVW4_cjs = require('./chunk-XJDMSVW4.cjs');
|
|
|
9
9
|
var chunkLB3IHFAB_cjs = require('./chunk-LB3IHFAB.cjs');
|
|
10
10
|
var chunkUCTQICPR_cjs = require('./chunk-UCTQICPR.cjs');
|
|
11
11
|
var chunkOISZU73V_cjs = require('./chunk-OISZU73V.cjs');
|
|
12
|
-
var
|
|
12
|
+
var chunkIWZT7CPM_cjs = require('./chunk-IWZT7CPM.cjs');
|
|
13
13
|
var icons = require('@blueprintjs/icons');
|
|
14
14
|
var classnames = require('classnames');
|
|
15
15
|
var React2 = require('react');
|
|
@@ -310,9 +310,9 @@ function DocumentViewer({
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
// src/public/experimental/document-viewer.ts
|
|
313
|
-
var DocumentViewer2 =
|
|
313
|
+
var DocumentViewer2 = chunkIWZT7CPM_cjs.withOsdkMetrics(DocumentViewer, "DocumentViewer");
|
|
314
314
|
|
|
315
315
|
exports.DocumentViewer = DocumentViewer2;
|
|
316
316
|
exports.ViewerType = ViewerType;
|
|
317
|
-
//# sourceMappingURL=chunk-
|
|
318
|
-
//# sourceMappingURL=chunk-
|
|
317
|
+
//# sourceMappingURL=chunk-5PZHBX7V.cjs.map
|
|
318
|
+
//# sourceMappingURL=chunk-5PZHBX7V.cjs.map
|