@osdk/react-components 0.17.0 → 0.18.0-main-ca8ef7c5d52f3369478e1d4c5b7eded97eb73215

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/browser/object-table/ObjectTable.js +4 -4
  3. package/build/browser/object-table/ObjectTable.js.map +1 -1
  4. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  5. package/build/browser/object-table/hooks/useRowSelection.js +5 -4
  6. package/build/browser/object-table/hooks/useRowSelection.js.map +1 -1
  7. package/build/browser/util/UserAgent.js +1 -1
  8. package/build/browser/util/UserAgent.js.map +1 -1
  9. package/build/cjs/chunk-2BLJCM7D.cjs +11 -0
  10. package/build/cjs/{chunk-DVE44R2H.cjs.map → chunk-2BLJCM7D.cjs.map} +1 -1
  11. package/build/cjs/{chunk-QOKXBBSR.cjs → chunk-2QDWXDLC.cjs} +204 -236
  12. package/build/cjs/chunk-2QDWXDLC.cjs.map +1 -0
  13. package/build/cjs/{chunk-ONBWRKWJ.cjs → chunk-3P75JCUA.cjs} +14 -14
  14. package/build/cjs/chunk-3P75JCUA.cjs.map +1 -0
  15. package/build/cjs/chunk-6SWH5XK7.cjs +11 -0
  16. package/build/cjs/{chunk-HHVL4RYG.cjs.map → chunk-6SWH5XK7.cjs.map} +1 -1
  17. package/build/cjs/{chunk-25R5WVUR.cjs → chunk-7N22MOQP.cjs} +4 -4
  18. package/build/cjs/{chunk-25R5WVUR.cjs.map → chunk-7N22MOQP.cjs.map} +1 -1
  19. package/build/cjs/{chunk-JNFOPEN2.cjs → chunk-DDIMME5J.cjs} +4 -4
  20. package/build/cjs/{chunk-JNFOPEN2.cjs.map → chunk-DDIMME5J.cjs.map} +1 -1
  21. package/build/cjs/{chunk-6HVKQP7I.cjs → chunk-DSBCDOFJ.cjs} +4 -4
  22. package/build/cjs/{chunk-6HVKQP7I.cjs.map → chunk-DSBCDOFJ.cjs.map} +1 -1
  23. package/build/cjs/{chunk-ZBJEZKOD.cjs → chunk-FRSIMUPL.cjs} +90 -59
  24. package/build/cjs/chunk-FRSIMUPL.cjs.map +1 -0
  25. package/build/cjs/{chunk-R4M6VGVD.cjs → chunk-IEF4VCDI.cjs} +3 -3
  26. package/build/cjs/chunk-IEF4VCDI.cjs.map +1 -0
  27. package/build/cjs/chunk-M3FP4G7N.cjs +11 -0
  28. package/build/cjs/{chunk-AL43X5RI.cjs.map → chunk-M3FP4G7N.cjs.map} +1 -1
  29. package/build/cjs/chunk-XJ5TTKHA.cjs +11 -0
  30. package/build/cjs/{chunk-U2JT7LIS.cjs.map → chunk-XJ5TTKHA.cjs.map} +1 -1
  31. package/build/cjs/{chunk-BKLX3JZ5.cjs → chunk-YD76TX23.cjs} +4 -4
  32. package/build/cjs/{chunk-BKLX3JZ5.cjs.map → chunk-YD76TX23.cjs.map} +1 -1
  33. package/build/cjs/{chunk-BGTMZNYD.cjs → chunk-YNPAQDMC.cjs} +4 -4
  34. package/build/cjs/{chunk-BGTMZNYD.cjs.map → chunk-YNPAQDMC.cjs.map} +1 -1
  35. package/build/cjs/chunk-Z7VYBF3X.cjs +11 -0
  36. package/build/cjs/{chunk-VICC2NSA.cjs.map → chunk-Z7VYBF3X.cjs.map} +1 -1
  37. package/build/cjs/public/experimental/action-form.cjs +5 -5
  38. package/build/cjs/public/experimental/document-viewer.cjs +4 -4
  39. package/build/cjs/public/experimental/email-viewer.cjs +3 -3
  40. package/build/cjs/public/experimental/excel-viewer.cjs +3 -3
  41. package/build/cjs/public/experimental/filter-list.cjs +13 -13
  42. package/build/cjs/public/experimental/image-viewer.cjs +3 -3
  43. package/build/cjs/public/experimental/markdown-renderer.cjs +3 -3
  44. package/build/cjs/public/experimental/object-table.cjs +9 -9
  45. package/build/cjs/public/experimental/object-table.d.cts +11 -14
  46. package/build/cjs/public/experimental/pdf-viewer.cjs +7 -7
  47. package/build/cjs/public/experimental/tiff-renderer.cjs +3 -3
  48. package/build/cjs/public/experimental/video-viewer.cjs +3 -3
  49. package/build/cjs/public/experimental/xml-viewer.cjs +3 -3
  50. package/build/cjs/public/experimental.cjs +47 -47
  51. package/build/esm/object-table/ObjectTable.js +4 -4
  52. package/build/esm/object-table/ObjectTable.js.map +1 -1
  53. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  54. package/build/esm/object-table/hooks/useRowSelection.js +5 -4
  55. package/build/esm/object-table/hooks/useRowSelection.js.map +1 -1
  56. package/build/esm/util/UserAgent.js +1 -1
  57. package/build/esm/util/UserAgent.js.map +1 -1
  58. package/build/types/object-table/ObjectTable.d.ts.map +1 -1
  59. package/build/types/object-table/ObjectTableApi.d.ts +11 -14
  60. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  61. package/build/types/object-table/hooks/useRowSelection.d.ts +0 -1
  62. package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
  63. package/docs/ObjectTable.md +17 -17
  64. package/package.json +4 -4
  65. package/build/cjs/chunk-AL43X5RI.cjs +0 -11
  66. package/build/cjs/chunk-DVE44R2H.cjs +0 -11
  67. package/build/cjs/chunk-HHVL4RYG.cjs +0 -11
  68. package/build/cjs/chunk-ONBWRKWJ.cjs.map +0 -1
  69. package/build/cjs/chunk-QOKXBBSR.cjs.map +0 -1
  70. package/build/cjs/chunk-R4M6VGVD.cjs.map +0 -1
  71. package/build/cjs/chunk-U2JT7LIS.cjs +0 -11
  72. package/build/cjs/chunk-VICC2NSA.cjs +0 -11
  73. package/build/cjs/chunk-ZBJEZKOD.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @osdk/react-components
2
2
 
3
+ ## 0.18.0-main-ca8ef7c5d52f3369478e1d4c5b7eded97eb73215
4
+
5
+ ### Minor Changes
6
+
7
+ - ca8ef7c: ObjectTable: drop the redundant `selectedRowIds` field from the `RowSelectionChange` payload delivered to `onRowSelectionChanged`. The primary keys are still available via `selectedRows.map(r => r.$primaryKey)`. `selectedRowIds` was redundant with `selectedRows` and was kept only as a transitional alias.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Minor Changes
@@ -50,6 +50,7 @@ export function ObjectTable({
50
50
  onOrderByChanged,
51
51
  onColumnsPinnedChanged,
52
52
  onColumnResize,
53
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility
53
54
  onRowSelection,
54
55
  onRowSelectionChanged,
55
56
  onColumnHeaderClick,
@@ -98,17 +99,16 @@ export function ObjectTable({
98
99
  let derivedObjectSet;
99
100
  if (resultingObjectSet) {
100
101
  if (primaryKeyApiName) {
101
- derivedObjectSet = change.isSelectAll && change.selectedRowIds.length > 0 ? resultingObjectSet : resultingObjectSet.where({
102
+ derivedObjectSet = change.isSelectAll && change.selectedRows.length > 0 ? resultingObjectSet : resultingObjectSet.where({
102
103
  [primaryKeyApiName]: {
103
- $in: change.selectedRowIds
104
+ $in: change.selectedRows.map(r => r.$primaryKey)
104
105
  }
105
106
  });
106
- } else if (change.isSelectAll && change.selectedRowIds.length > 0) {
107
+ } else if (change.isSelectAll && change.selectedRows.length > 0) {
107
108
  derivedObjectSet = resultingObjectSet;
108
109
  }
109
110
  }
110
111
  onRowSelectionChanged({
111
- selectedRowIds: change.selectedRowIds,
112
112
  selectedRows: change.selectedRows,
113
113
  isSelectAll: change.isSelectAll,
114
114
  objectSet: derivedObjectSet
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","EMPTY_ARRAY","ObjectTable","objectType","objectSet","columnDefinitions","filter","objectSetOptions","dedupeIntervalMs","pageSize","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onColumnResize","onRowSelection","onRowSelectionChanged","onColumnHeaderClick","renderCellContextMenu","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onColumnVisibilityChanged","onCellValueChanged","onSubmitEdits","enableOrdering","enableColumnPinning","enableColumnResizing","enableColumnConfig","editMode","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","data","fetchMore","isLoading","error","resultingObjectSet","columns","loading","isColumnsLoading","primaryKeyApiName","type","undefined","handleRowSelectionChanged","change","derivedObjectSet","isSelectAll","selectedRowIds","length","where","$in","rowSelection","hasSelection","onToggleAll","onToggleRow","enableRowSelection","selectionColumn","columnVisibility","onColumnVisibilityChange","columnOrder","onColumnOrderChange","allColumns","columnPinning","onColumnPinningChange","hasSelectionColumn","editableConfig","table","state","enableSorting","columnResizeMode","columnResizeDirection","manualSorting","defaultColumn","minSize","meta","onCellEdit","onCellValidationError","clearCellValidationError","cellEdits","isInEditMode","editModeState","isActive","validationErrors","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useColumnPinning } from \"./hooks/useColumnPinning.js\";\nimport { useColumnResize } from \"./hooks/useColumnResize.js\";\nimport { useColumnVisibility } from \"./hooks/useColumnVisibility.js\";\nimport { useEditableTable } from \"./hooks/useEditableTable.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { UseRowSelectionChange } from \"./hooks/useRowSelection.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport { useTableSorting } from \"./hooks/useTableSorting.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { BaseTable } from \"./Table.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\nconst EMPTY_ARRAY: [] = [];\nimport type { EditableConfig } from \"./utils/types.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectType,\n objectSet,\n columnDefinitions,\n filter,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n onColumnsPinnedChanged,\n onColumnResize,\n onRowSelection,\n onRowSelectionChanged,\n onColumnHeaderClick,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onColumnVisibilityChanged,\n onCellValueChanged,\n onSubmitEdits,\n enableOrdering = true,\n enableColumnPinning = true,\n enableColumnResizing = true,\n enableColumnConfig = true,\n editMode = \"manual\",\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >(\n {\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n },\n );\n\n const { data, fetchMore, isLoading, error, objectSet: resultingObjectSet } =\n useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n filter,\n sorting,\n objectSet,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const primaryKeyApiName = objectType.type === \"object\"\n ? objectType.primaryKeyApiName\n : undefined;\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n let derivedObjectSet: ObjectSet<Q, RDPs> | undefined;\n if (resultingObjectSet) {\n if (primaryKeyApiName) {\n derivedObjectSet =\n change.isSelectAll && change.selectedRowIds.length > 0\n ? resultingObjectSet\n : resultingObjectSet.where({\n [primaryKeyApiName]: { $in: change.selectedRowIds },\n } as WhereClause<Q, RDPs>);\n } else if (change.isSelectAll && change.selectedRowIds.length > 0) {\n derivedObjectSet = resultingObjectSet;\n }\n }\n\n onRowSelectionChanged({\n selectedRowIds: change.selectedRowIds,\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: derivedObjectSet,\n });\n },\n [\n onRowSelectionChanged,\n resultingObjectSet,\n primaryKeyApiName,\n ],\n );\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n enableRowSelection,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onRowSelection,\n onRowSelectionChanged: handleRowSelectionChanged,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n {\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n },\n );\n\n const {\n columnVisibility,\n onColumnVisibilityChange,\n columnOrder,\n onColumnOrderChange,\n } = useColumnVisibility({\n allColumns: columns,\n onColumnVisibilityChanged,\n });\n\n const { columnPinning, onColumnPinningChange } = useColumnPinning({\n columnDefinitions,\n hasSelectionColumn: enableRowSelection,\n onColumnsPinnedChanged,\n });\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const editableConfig: EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n > = useEditableTable({\n editMode,\n onCellValueChanged,\n onSubmitEdits,\n });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? EMPTY_ARRAY,\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n columnOrder,\n rowSelection,\n sorting,\n columnSizing,\n columnPinning,\n },\n onSortingChange,\n onColumnSizingChange,\n onColumnPinningChange,\n onColumnVisibilityChange,\n onColumnOrderChange,\n enableRowSelection,\n enableSorting: enableOrdering,\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n manualSorting: true, // Enable manual sorting to indicate server-side sorting\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\n meta: {\n onCellEdit: editableConfig.onCellEdit,\n onCellValidationError: editableConfig.onCellValidationError,\n clearCellValidationError: editableConfig.clearCellValidationError,\n cellEdits: editableConfig.cellEdits,\n isInEditMode: editableConfig.editModeState.isActive,\n validationErrors: editableConfig.validationErrors,\n },\n });\n\n const onRenderCellContextMenu = useCallback(\n (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cell: Cell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n return renderCellContextMenu?.(row, cell.getValue());\n },\n [renderCellContextMenu],\n );\n\n const handleColumnHeaderClick = useMemo(\n () =>\n onColumnHeaderClick\n ? (columnId: string) =>\n onColumnHeaderClick(\n columnId as\n | PropertyKeys<Q>\n | keyof RDPs\n | keyof FunctionColumns,\n )\n : undefined,\n [onColumnHeaderClick],\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(() => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }), [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]);\n\n return (\n <BaseTable<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n onColumnHeaderClick={handleColumnHeaderClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n renderEmptyState={props.renderEmptyState}\n className={props.className}\n error={error}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n editableConfig={editableConfig}\n getRowAttributes={props.getRowAttributes}\n showEditFooter={props.showEditFooter}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,Q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SAAU;IAC3BhE,KAAK,EAAEA,KAAM;IACbsD,sBAAsB,EAAEA,sBAAuB;IAC/CxB,cAAc,EAAEA,cAAe;IAC/BmC,gBAAgB,EAAEzE,KAAK,CAACyE,gBAAiB;IACzCC,cAAc,EAAE1E,KAAK,CAAC0E;EAAe,CACtC,CAAC;AAEN","ignoreList":[]}
1
+ {"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useColumnDefs","useColumnPinning","useColumnResize","useColumnVisibility","useEditableTable","useObjectTableData","useRowSelection","useSelectionColumn","useTableSorting","BaseTable","getRowId","EMPTY_ARRAY","ObjectTable","objectType","objectSet","columnDefinitions","filter","objectSetOptions","dedupeIntervalMs","pageSize","orderBy","defaultOrderBy","onOrderByChanged","onColumnsPinnedChanged","onColumnResize","onRowSelection","onRowSelectionChanged","onColumnHeaderClick","renderCellContextMenu","selectionMode","selectedRows","isAllSelected","isAllSelectedProp","onColumnVisibilityChanged","onCellValueChanged","onSubmitEdits","enableOrdering","enableColumnPinning","enableColumnResizing","enableColumnConfig","editMode","props","columnSizing","onColumnSizingChange","sorting","onSortingChange","data","fetchMore","isLoading","error","resultingObjectSet","columns","loading","isColumnsLoading","primaryKeyApiName","type","undefined","handleRowSelectionChanged","change","derivedObjectSet","isSelectAll","length","where","$in","map","r","$primaryKey","rowSelection","hasSelection","onToggleAll","onToggleRow","enableRowSelection","selectionColumn","columnVisibility","onColumnVisibilityChange","columnOrder","onColumnOrderChange","allColumns","columnPinning","onColumnPinningChange","hasSelectionColumn","editableConfig","table","state","enableSorting","columnResizeMode","columnResizeDirection","manualSorting","defaultColumn","minSize","meta","onCellEdit","onCellValidationError","clearCellValidationError","cellEdits","isInEditMode","editModeState","isActive","validationErrors","onRenderCellContextMenu","row","cell","getValue","handleColumnHeaderClick","columnId","headerMenuFeatureFlags","showSortingItems","showPinningItems","showResizeItem","showConfigItem","createElement","fetchNextPage","onRowClick","rowHeight","renderEmptyState","className","getRowAttributes","showEditFooter"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Cell } from \"@tanstack/react-table\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useColumnPinning } from \"./hooks/useColumnPinning.js\";\nimport { useColumnResize } from \"./hooks/useColumnResize.js\";\nimport { useColumnVisibility } from \"./hooks/useColumnVisibility.js\";\nimport { useEditableTable } from \"./hooks/useEditableTable.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { UseRowSelectionChange } from \"./hooks/useRowSelection.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport { useTableSorting } from \"./hooks/useTableSorting.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { BaseTable } from \"./Table.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\nconst EMPTY_ARRAY: [] = [];\nimport type { EditableConfig } from \"./utils/types.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectType,\n objectSet,\n columnDefinitions,\n filter,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n onColumnsPinnedChanged,\n onColumnResize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility\n onRowSelection,\n onRowSelectionChanged,\n onColumnHeaderClick,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onColumnVisibilityChanged,\n onCellValueChanged,\n onSubmitEdits,\n enableOrdering = true,\n enableColumnPinning = true,\n enableColumnResizing = true,\n enableColumnConfig = true,\n editMode = \"manual\",\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { columnSizing, onColumnSizingChange } = useColumnResize({\n onColumnResize,\n });\n\n const { sorting, onSortingChange } = useTableSorting<\n Q,\n RDPs,\n FunctionColumns\n >(\n {\n orderBy,\n defaultOrderBy,\n onOrderByChanged,\n },\n );\n\n const { data, fetchMore, isLoading, error, objectSet: resultingObjectSet } =\n useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n filter,\n sorting,\n objectSet,\n objectSetOptions,\n dedupeIntervalMs,\n pageSize,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const primaryKeyApiName = objectType.type === \"object\"\n ? objectType.primaryKeyApiName\n : undefined;\n\n const handleRowSelectionChanged = useCallback(\n (change: UseRowSelectionChange<Q, RDPs>) => {\n if (!onRowSelectionChanged) return;\n\n let derivedObjectSet: ObjectSet<Q, RDPs> | undefined;\n if (resultingObjectSet) {\n if (primaryKeyApiName) {\n derivedObjectSet =\n change.isSelectAll && change.selectedRows.length > 0\n ? resultingObjectSet\n : resultingObjectSet.where({\n [primaryKeyApiName]: {\n $in: change.selectedRows.map(r => r.$primaryKey),\n },\n } as WhereClause<Q, RDPs>);\n } else if (change.isSelectAll && change.selectedRows.length > 0) {\n derivedObjectSet = resultingObjectSet;\n }\n }\n\n onRowSelectionChanged({\n selectedRows: change.selectedRows,\n isSelectAll: change.isSelectAll,\n objectSet: derivedObjectSet,\n });\n },\n [\n onRowSelectionChanged,\n resultingObjectSet,\n primaryKeyApiName,\n ],\n );\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n enableRowSelection,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n isAllSelected: isAllSelectedProp,\n onRowSelection,\n onRowSelectionChanged: handleRowSelectionChanged,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n {\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n },\n );\n\n const {\n columnVisibility,\n onColumnVisibilityChange,\n columnOrder,\n onColumnOrderChange,\n } = useColumnVisibility({\n allColumns: columns,\n onColumnVisibilityChanged,\n });\n\n const { columnPinning, onColumnPinningChange } = useColumnPinning({\n columnDefinitions,\n hasSelectionColumn: enableRowSelection,\n onColumnsPinnedChanged,\n });\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const editableConfig: EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n > = useEditableTable({\n editMode,\n onCellValueChanged,\n onSubmitEdits,\n });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? EMPTY_ARRAY,\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n columnOrder,\n rowSelection,\n sorting,\n columnSizing,\n columnPinning,\n },\n onSortingChange,\n onColumnSizingChange,\n onColumnPinningChange,\n onColumnVisibilityChange,\n onColumnOrderChange,\n enableRowSelection,\n enableSorting: enableOrdering,\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n manualSorting: true, // Enable manual sorting to indicate server-side sorting\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\n meta: {\n onCellEdit: editableConfig.onCellEdit,\n onCellValidationError: editableConfig.onCellValidationError,\n clearCellValidationError: editableConfig.clearCellValidationError,\n cellEdits: editableConfig.cellEdits,\n isInEditMode: editableConfig.editModeState.isActive,\n validationErrors: editableConfig.validationErrors,\n },\n });\n\n const onRenderCellContextMenu = useCallback(\n (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cell: Cell<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n return renderCellContextMenu?.(row, cell.getValue());\n },\n [renderCellContextMenu],\n );\n\n const handleColumnHeaderClick = useMemo(\n () =>\n onColumnHeaderClick\n ? (columnId: string) =>\n onColumnHeaderClick(\n columnId as\n | PropertyKeys<Q>\n | keyof RDPs\n | keyof FunctionColumns,\n )\n : undefined,\n [onColumnHeaderClick],\n );\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n const headerMenuFeatureFlags: HeaderMenuFeatureFlags = useMemo(() => ({\n showSortingItems: enableOrdering,\n showPinningItems: enableColumnPinning,\n showResizeItem: enableColumnResizing,\n showConfigItem: enableColumnConfig,\n }), [\n enableOrdering,\n enableColumnPinning,\n enableColumnResizing,\n enableColumnConfig,\n ]);\n\n return (\n <BaseTable<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n onColumnHeaderClick={handleColumnHeaderClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n renderEmptyState={props.renderEmptyState}\n className={props.className}\n error={error}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n editableConfig={editableConfig}\n getRowAttributes={props.getRowAttributes}\n showEditFooter={props.showEditFooter}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAE5D,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,qBAAqB;AAE9C,MAAMC,WAAe,GAAG,EAAE;AAG1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,UAAU;EACVC,SAAS;EACTC,iBAAiB;EACjBC,MAAM;EACNC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,OAAO;EACPC,cAAc;EACdC,gBAAgB;EAChBC,sBAAsB;EACtBC,cAAc;EACd;EACAC,cAAc;EACdC,qBAAqB;EACrBC,mBAAmB;EACnBC,qBAAqB;EACrBC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,aAAa,EAAEC,iBAAiB;EAChCC,yBAAyB;EACzBC,kBAAkB;EAClBC,aAAa;EACbC,cAAc,GAAG,IAAI;EACrBC,mBAAmB,GAAG,IAA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tB,CAAC;EAID,MAAM8E,sBAA8C,GAAG1G,OAAO,CAAC,OAAO;IACpE2G,gBAAgB,EAAEtE,cAAc;IAChCuE,gBAAgB,EAAEtE,mBAAmB;IACrCuE,cAAc,EAAEtE,oBAAoB;IACpCuE,cAAc,EAAEtE;EAClB,CAAC,CAAC,EAAE,CACFH,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,kBAAkB,CACnB,CAAC;EAEF,oBACE1C,KAAA,CAAAiH,aAAA,CAACrG,SAAS;IACRyE,KAAK,EAAEA,KAAM;IACblC,SAAS,EAjBUA,SAAS,IAAIK,gBAiBN;IAC1B0D,aAAa,EAAEhE,SAAU;IACzBiE,UAAU,EAAEvE,KAAK,CAACuE,UAAW;IAC7BrF,mBAAmB,EAAE4E,uBAAwB;IAC7CU,SAAS,EAAExE,KAAK,CAACwE,SAAU;IAC3BrF,qBAAqB,EAAEuE,uBAAwB;IAC/Ce,gBAAgB,EAAEzE,KAAK,CAACyE,gBAAiB;IACzCC,SAAS,EAAE1E,KAAK,CAAC0E,SAAU;IAC3BlE,KAAK,EAAEA,KAAM;IACbwD,sBAAsB,EAAEA,sBAAuB;IAC/CxB,cAAc,EAAEA,cAAe;IAC/BmC,gBAAgB,EAAE3E,KAAK,CAAC2E,gBAAiB;IACzCC,cAAc,EAAE5E,KAAK,CAAC4E;EAAe,CACtC,CAAC;AAEN","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { QueryParameterType } from \"@osdk/client/observable\";\nimport type * as React from \"react\";\nimport type { CellEditInfo, EditFieldConfig } from \"./utils/types.js\";\n\nexport type { EditFieldConfig } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | EditableColumnDefinition<Q, RDPs, FunctionColumns>\n | ReadonlyColumnDefinition<Q, RDPs, FunctionColumns>;\n\ninterface SharedColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n\n /**\n * Custom renderer for the cell value.\n *\n * Interaction with `editable` columns:\n * - When `editMode: \"manual\"` (default), `renderCell` is used while the\n * table is read-only (Edit Table button visible) and the editable cell\n * takes over once the user enters edit mode.\n * - When `editMode: \"always\"`, the editable cell always wins on editable\n * columns and `renderCell` is ignored — `editMode: \"always\"` opts the\n * column into a permanently-editable surface, leaving no read-only\n * state for `renderCell` to render. Use `editMode: \"manual\"` if you\n * need a custom display alongside editing.\n */\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n}\n\ninterface EditableColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n /**\n * `editable` can be a boolean or a predicate that receives the row's object\n * and returns whether the cell is editable\n */\n editable:\n | true\n | ((\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => boolean);\n\n /**\n * Configuration for the cell editor component.\n *\n * When provided, the column uses the specified field component\n * (e.g. dropdown) instead of the default auto-detected text/number input.\n *\n * `getFieldComponentProps` receives the row's object and a map of any\n * pending edits for that row (keyed by column id), and returns the props to\n * pass to the field component. Editor configuration can depend on the\n * current row or on other in-progress edits within the row.\n */\n editFieldConfig?: EditFieldConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >;\n\n /**\n * Additional function to validate the cell value during edit.\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n}\n\n/**\n * Column definition for a read-only column (default).\n * `editFieldConfig` and `validateEdit` are not available.\n */\ninterface ReadonlyColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n editable?: false;\n}\n\nexport type ExtractQueryParameters<\n Q extends QueryDefinition,\n> = CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\n/**\n * Concrete function column locator for a single key K.\n * Correlates the id, queryDefinition, and getFunctionParams types.\n */\ninterface FunctionColumnLocatorForKey<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n FunctionColumns extends Record<string, QueryDefinition<{}>>,\n K extends keyof FunctionColumns,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: K;\n queryDefinition: FunctionColumns[K];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => ExtractQueryParameters<FunctionColumns[K]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData?: unknown) => unknown;\n\n /**\n * Minimum time between re-fetches of the same function with the same parameters, in milliseconds.\n * Defaults to 5 minutes as it is expensive to fetch function columns for a large object set\n * and they are expected to be relatively static in the context of an object table\n *\n * @default 300_000 (5 minutes)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Object type apiNames the function reads but doesn't take as a parameter (e.g.\n * linked object types the function traverses internally). The column auto-revalidates\n * when an action edits an object of any of these types. Param-derived types are\n * tracked automatically and don't need to be listed here.\n */\n dependsOn?: string[];\n}\n\n/**\n * Distributes over each key in FunctionColumns so that id, queryDefinition,\n * and getFunctionParams are correlated per key.\n */\nexport type FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = keyof FunctionColumns extends infer K\n ? K extends keyof FunctionColumns\n ? FunctionColumnLocatorForKey<Q, RDPs, FunctionColumns, K>\n : never\n : never;\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Minimum time between fetch requests in milliseconds.\n * Increasing this value reduces redundant network calls when the same data\n * is requested multiple times in quick succession.\n *\n * @default 60_000 1 minute\n */\n dedupeIntervalMs?: number;\n\n /**\n * Number of objects to fetch per page.\n *\n * @default 50\n */\n pageSize?: number;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n enableFiltering?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * Whether to render the bottom edit footer that hosts the\n * \"Edit Table\" / \"Cancel\" / \"Submit Edits\" buttons and the edit-state\n * indicators (modification count, validation errors).\n *\n * @default true whenever the table has at least one column declared\n * editable (i.e. any column with `editable: true` or `editable: (object) => boolean`).\n * When `false`, the \"Edit Table\" and \"Submit Edits\" buttons will not be shown.\n */\n showEditFooter?: boolean;\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the \"Submit Edits\" button will be shown in the edit footer.\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Called when a column header is clicked.\n *\n * The columnId matches the `locator.id` configured on the column definition.\n * The dropdown menu trigger is excluded — clicking the chevron opens the\n * header menu instead of firing this callback.\n *\n * @param columnId The id of the clicked column\n */\n onColumnHeaderClick?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n *\n * @deprecated Use {@link onRowSelectionChanged} instead. The new callback\n * delivers a {@link RowSelectionChange} object with `selectedRowIds`,\n * `selectedRows`, `isSelectAll`, and a derived `objectSet`. This legacy\n * callback continues to fire alongside the new one for backwards\n * compatibility.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n\n /**\n * Called when the row selection changes, with a {@link RowSelectionChange}\n * payload describing the new state.\n *\n * @param change The new selection state. See {@link RowSelectionChange}.\n */\n onRowSelectionChanged?: (\n change: RowSelectionChange<Q, RDPs>,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * Render override for the empty state. Called when the table has no\n * rows and no error. When omitted, a default \"No Data\" indicator is\n * rendered.\n */\n renderEmptyState?: () => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n /**\n * Returns extra HTML attributes (typically `data-*`) to apply to each\n * row element. Use this to drive conditional row styling\n */\n getRowAttributes?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => Record<string, string | undefined>;\n\n className?: string;\n}\n\n/**\n * Payload for {@link ObjectTableProps.onRowSelectionChanged}. Consolidates\n * the primary-key list, loaded row instances, the `isSelectAll` semantic\n * intent, and an `ObjectSet` covering the selection.\n */\nexport interface RowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /** Primary keys of currently selected rows. */\n selectedRowIds: PrimaryKeyType<Q>[];\n\n /**\n * Loaded row instances corresponding to `selectedRowIds`. When\n * `isSelectAll` is true, this reflects only the rows currently in the\n * table — pages not yet fetched are absent. Use `objectSet` for the\n * cross-page view.\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 * `selectedRowIds.length` matching the visible row count but does not set\n * this flag.\n */\n isSelectAll: boolean;\n\n /**\n * An `ObjectSet` representing the selection.\n *\n * - \"Select all\" → the underlying `ObjectSet` (`objectSet` prop if\n * provided, otherwise derived from `objectType` via `client(...)`).\n * This includes rows not yet loaded into the table.\n * - Partial selection → the underlying `ObjectSet` narrowed to\n * `{ [primaryKeyApiName]: { $in: selectedRowIds } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * `undefined` for interface types without a resolvable\n * `primaryKeyApiName` when the selection is partial or empty (a\n * `$primaryKey`-style filter can't be expressed). For \"select all\" on\n * those types the underlying `ObjectSet` is still emitted.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { QueryParameterType } from \"@osdk/client/observable\";\nimport type * as React from \"react\";\nimport type { CellEditInfo, EditFieldConfig } from \"./utils/types.js\";\n\nexport type { EditFieldConfig } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | EditableColumnDefinition<Q, RDPs, FunctionColumns>\n | ReadonlyColumnDefinition<Q, RDPs, FunctionColumns>;\n\ninterface SharedColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n\n /**\n * Custom renderer for the cell value.\n *\n * Interaction with `editable` columns:\n * - When `editMode: \"manual\"` (default), `renderCell` is used while the\n * table is read-only (Edit Table button visible) and the editable cell\n * takes over once the user enters edit mode.\n * - When `editMode: \"always\"`, the editable cell always wins on editable\n * columns and `renderCell` is ignored — `editMode: \"always\"` opts the\n * column into a permanently-editable surface, leaving no read-only\n * state for `renderCell` to render. Use `editMode: \"manual\"` if you\n * need a custom display alongside editing.\n */\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n}\n\ninterface EditableColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n /**\n * `editable` can be a boolean or a predicate that receives the row's object\n * and returns whether the cell is editable\n */\n editable:\n | true\n | ((\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => boolean);\n\n /**\n * Configuration for the cell editor component.\n *\n * When provided, the column uses the specified field component\n * (e.g. dropdown) instead of the default auto-detected text/number input.\n *\n * `getFieldComponentProps` receives the row's object and a map of any\n * pending edits for that row (keyed by column id), and returns the props to\n * pass to the field component. Editor configuration can depend on the\n * current row or on other in-progress edits within the row.\n */\n editFieldConfig?: EditFieldConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >;\n\n /**\n * Additional function to validate the cell value during edit.\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n}\n\n/**\n * Column definition for a read-only column (default).\n * `editFieldConfig` and `validateEdit` are not available.\n */\ninterface ReadonlyColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> extends SharedColumnDefinition<Q, RDPs, FunctionColumns> {\n editable?: false;\n}\n\nexport type ExtractQueryParameters<\n Q extends QueryDefinition,\n> = CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\n/**\n * Concrete function column locator for a single key K.\n * Correlates the id, queryDefinition, and getFunctionParams types.\n */\ninterface FunctionColumnLocatorForKey<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef>,\n FunctionColumns extends Record<string, QueryDefinition<{}>>,\n K extends keyof FunctionColumns,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: K;\n queryDefinition: FunctionColumns[K];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => ExtractQueryParameters<FunctionColumns[K]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData?: unknown) => unknown;\n\n /**\n * Minimum time between re-fetches of the same function with the same parameters, in milliseconds.\n * Defaults to 5 minutes as it is expensive to fetch function columns for a large object set\n * and they are expected to be relatively static in the context of an object table\n *\n * @default 300_000 (5 minutes)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Object type apiNames the function reads but doesn't take as a parameter (e.g.\n * linked object types the function traverses internally). The column auto-revalidates\n * when an action edits an object of any of these types. Param-derived types are\n * tracked automatically and don't need to be listed here.\n */\n dependsOn?: string[];\n}\n\n/**\n * Distributes over each key in FunctionColumns so that id, queryDefinition,\n * and getFunctionParams are correlated per key.\n */\nexport type FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = keyof FunctionColumns extends infer K\n ? K extends keyof FunctionColumns\n ? FunctionColumnLocatorForKey<Q, RDPs, FunctionColumns, K>\n : never\n : never;\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Minimum time between fetch requests in milliseconds.\n * Increasing this value reduces redundant network calls when the same data\n * is requested multiple times in quick succession.\n *\n * @default 60_000 1 minute\n */\n dedupeIntervalMs?: number;\n\n /**\n * Number of objects to fetch per page.\n *\n * @default 50\n */\n pageSize?: number;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n enableFiltering?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * Whether to render the bottom edit footer that hosts the\n * \"Edit Table\" / \"Cancel\" / \"Submit Edits\" buttons and the edit-state\n * indicators (modification count, validation errors).\n *\n * @default true whenever the table has at least one column declared\n * editable (i.e. any column with `editable: true` or `editable: (object) => boolean`).\n * When `false`, the \"Edit Table\" and \"Submit Edits\" buttons will not be shown.\n */\n showEditFooter?: boolean;\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q> | keyof RDPs;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the \"Submit Edits\" button will be shown in the edit footer.\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Called when a column header is clicked.\n *\n * The columnId matches the `locator.id` configured on the column definition.\n * The dropdown menu trigger is excluded — clicking the chevron opens the\n * header menu instead of firing this callback.\n *\n * @param columnId The id of the clicked column\n */\n onColumnHeaderClick?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n *\n * @deprecated Use {@link onRowSelectionChanged} instead. The new callback\n * delivers a {@link RowSelectionChange} object with `selectedRows`,\n * `isSelectAll`, and a derived `objectSet`. This legacy callback\n * continues to fire alongside the new one for backwards compatibility.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n\n /**\n * Called when the row selection changes, with a {@link RowSelectionChange}\n * payload describing the new state.\n *\n * @param change The new selection state. See {@link RowSelectionChange}.\n */\n onRowSelectionChanged?: (\n change: RowSelectionChange<Q, RDPs>,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * Render override for the empty state. Called when the table has no\n * rows and no error. When omitted, a default \"No Data\" indicator is\n * rendered.\n */\n renderEmptyState?: () => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n /**\n * Returns extra HTML attributes (typically `data-*`) to apply to each\n * row element. Use this to drive conditional row styling\n */\n getRowAttributes?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => Record<string, string | undefined>;\n\n className?: string;\n}\n\n/**\n * Payload for {@link ObjectTableProps.onRowSelectionChanged}. Consolidates\n * the loaded row instances, the `isSelectAll` semantic intent, and an\n * `ObjectSet` covering the selection.\n */\nexport interface RowSelectionChange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n /**\n * Loaded row instances currently selected. When `isSelectAll` is true,\n * this reflects only the rows currently in the table — pages not yet\n * fetched are absent. Use `objectSet` for the cross-page view, and\n * `selectedRows.map(r => r.$primaryKey)` if you need the primary keys.\n */\n selectedRows: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[];\n\n /**\n * True when the user invoked \"select all\" (header checkbox) or when\n * controlled mode supplies `isAllSelected={true}`. Distinct from \"every\n * loaded row happens to be selected\" — that condition is reflected by\n * `selectedRows.length` matching the visible row count but does not set\n * this flag.\n */\n isSelectAll: boolean;\n\n /**\n * An `ObjectSet` representing the selection.\n *\n * - \"Select all\" → the underlying `ObjectSet` (`objectSet` prop if\n * provided, otherwise derived from `objectType` via `client(...)`).\n * This includes rows not yet loaded into the table.\n * - Partial selection → the underlying `ObjectSet` narrowed to\n * `{ [primaryKeyApiName]: { $in: selectedRows.map(r => r.$primaryKey) } }`.\n * - \"Deselect all\" → an empty `ObjectSet` (`$in: []`).\n *\n * `undefined` for interface types without a resolvable\n * `primaryKeyApiName` when the selection is partial or empty (a\n * `$primaryKey`-style filter can't be expressed). For \"select all\" on\n * those types the underlying `ObjectSet` is still emitted.\n */\n objectSet: ObjectSet<Q, RDPs> | undefined;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
+ import { useEventCallback } from "../../shared/hooks/useEventCallback.js";
18
19
  import { getRowId, getRowIdFromPrimaryKey } from "../utils/getRowId.js";
19
20
 
20
21
  /**
@@ -27,6 +28,7 @@ export function useRowSelection({
27
28
  selectionMode = "none",
28
29
  selectedRows,
29
30
  isAllSelected: isAllSelectedProp,
31
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentional pass-through to fire alongside onRowSelectionChanged for backwards compatibility
30
32
  onRowSelection,
31
33
  onRowSelectionChanged,
32
34
  data
@@ -54,18 +56,17 @@ export function useRowSelection({
54
56
  const isAllSelected = deriveIsAllSelected(isControlled, isAllSelectedProp, internalIsAllSelected, selectedCount, totalCount);
55
57
  // Dedupes refires when "select all" is active and data grows.
56
58
  const lastFiredAllSelectedIdsRef = useRef(null);
57
- const fireSelectionCallbacks = useCallback((ids, isSelectAll) => {
59
+ const fireSelectionCallbacks = useEventCallback((ids, isSelectAll) => {
58
60
  onRowSelection?.(ids, isSelectAll);
59
61
  if (onRowSelectionChanged) {
60
62
  const selectedKeySet = new Set(ids.map(id => String(id)));
61
63
  const instances = (data ?? []).filter(item => selectedKeySet.has(String(item.$primaryKey)));
62
64
  onRowSelectionChanged({
63
- selectedRowIds: ids,
64
65
  selectedRows: instances,
65
66
  isSelectAll
66
67
  });
67
68
  }
68
- }, [onRowSelection, onRowSelectionChanged, data]);
69
+ });
69
70
  const onToggleAll = useCallback(() => {
70
71
  if (!enableRowSelection || !data) return;
71
72
  const newIsAllSelected = !isAllSelected;
@@ -122,7 +123,7 @@ export function useRowSelection({
122
123
  }, [enableRowSelection, data, selectionMode, isControlled, fireSelectionCallbacks, rowSelectionState, lastSelectedRowIndex]);
123
124
 
124
125
  // Refire callbacks when uncontrolled "select all" is active and new rows arrive.
125
- useEffect(() => {
126
+ useEffect(function () {
126
127
  if (isControlled || !internalIsAllSelected || !data) {
127
128
  if (!internalIsAllSelected) {
128
129
  lastFiredAllSelectedIdsRef.current = null;
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.js","names":["useCallback","useEffect","useMemo","useRef","useState","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","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","hasSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\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\";\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 selectedRowIds: PrimaryKeyType<Q>[];\n selectedRows: Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[];\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?: (\n change: UseRowSelectionChange<Q, RDPs>,\n ) => 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 onRowSelection,\n onRowSelectionChanged,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\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(\n (data ?? []).map(item => item.$primaryKey),\n );\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 = useCallback(\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 selectedRowIds: ids,\n selectedRows: instances,\n isSelectAll,\n });\n }\n },\n [onRowSelection, onRowSelectionChanged, data],\n );\n\n const onToggleAll = useCallback(() => {\n if (!enableRowSelection || !data) return;\n\n const newIsAllSelected = !isAllSelected;\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 isAllSelected,\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, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n setLastSelectedRowIndex(rowIndex);\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, 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 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 }, [isControlled, internalIsAllSelected, data, fireSelectionCallbacks]);\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, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): 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, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): 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, data, rowSelectionState }: Pick<\n GetSelectedRowsProps<Q, RDPs>,\n \"rowIndex\" | \"data\" | \"rowSelectionState\"\n >,\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, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): 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>(\n (acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n },\n {},\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;AACzE,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,sBAAsB;;AAEvE;AACA;AACA;AACA;AACA;;AAkDA,OAAO,SAASC,eAAeA,CAG7B;EACAC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,aAAa,EAAEC,iBAAiB;EAChCC,cAAc;EACdC,qBAAqB;EACrBC;AAC6B,CAAC,EAAyB;EACvD,MAAM,CAACC,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGZ,QAAQ,CAE9D,CAAC,CAAC,CAAC;;EAEL;EACA,MAAM,CAACa,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGd,QAAQ,CAAC,KAAK,CAAC;EAEzE,MAAM,CAACe,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGhB,QAAQ,CAE9D,IAAI,CAAC;EAEP,MAAMiB,YAAY,GAAGZ,YAAY,KAAKa,SAAS;EAC/C,MAAMC,kBAAkB,GAAGf,aAAa,KAAK,MAAM;EAEnD,MAAMgB,iBAAoC,GAAGtB,OAAO,CAAC,MAAM;IACzD,IAAI,CAACqB,kB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pB,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,CACvB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IACnBoB,GAAG,CAAC/E,sBAAsB,CAAC2D,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH;AAEA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCxE,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRmB,MAAM,CAACN,IAAI,IAAI2D,cAAc,CAACjF,QAAQ,CAACsB,IAAI,CAAC,CAAC,CAAC,CAC9CD,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,WAAW,CAAC;AAClC","ignoreList":[]}
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","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","hasSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\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\";\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<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[];\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?: (\n change: UseRowSelectionChange<Q, RDPs>,\n ) => 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] = useState<\n RowSelectionState\n >({});\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(\n (data ?? []).map(item => item.$primaryKey),\n );\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 const newIsAllSelected = !isAllSelected;\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 isAllSelected,\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, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n setLastSelectedRowIndex(rowIndex);\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, 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(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 }, [isControlled, internalIsAllSelected, data, fireSelectionCallbacks]);\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, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): 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, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): 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, data, rowSelectionState }: Pick<\n GetSelectedRowsProps<Q, RDPs>,\n \"rowIndex\" | \"data\" | \"rowSelectionState\"\n >,\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, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): 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>(\n (acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n },\n {},\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;AAC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AM,CACvB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IACnBoB,GAAG,CAAC/E,sBAAsB,CAAC2D,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH;AAEA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCxE,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRmB,MAAM,CAACN,IAAI,IAAI2D,cAAc,CAACjF,QAAQ,CAACsB,IAAI,CAAC,CAAC,CAAC,CAC9CD,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,WAAW,CAAC;AAClC","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.0"}`;
17
+ const PACKAGE_USER_AGENT = `osdk-react-components/${"0.18.0-main-ca8ef7c5d52f3369478e1d4c5b7eded97eb73215"}`;
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 =\n `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,GACtB,mCAAsD;AAExD,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
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 =\n `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,GACtB,iFAAsD;AAExD,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 chunkKHMOMROL_cjs = require('./chunk-KHMOMROL.cjs');
4
+ var chunkIEF4VCDI_cjs = require('./chunk-IEF4VCDI.cjs');
5
+
6
+ // src/public/experimental/video-viewer.ts
7
+ var VideoViewer2 = chunkIEF4VCDI_cjs.withOsdkMetrics(chunkKHMOMROL_cjs.VideoViewer, "VideoViewer");
8
+
9
+ exports.VideoViewer = VideoViewer2;
10
+ //# sourceMappingURL=chunk-2BLJCM7D.cjs.map
11
+ //# sourceMappingURL=chunk-2BLJCM7D.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/public/experimental/video-viewer.ts"],"names":["VideoViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-DVE44R2H.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// BaseVideoViewer\nexport { BaseVideoViewer } from \"../../video-viewer/BaseVideoViewer.js\";\n// VideoViewer (Media wrapper)\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nimport { VideoViewer as _VideoViewer } from \"../../video-viewer/VideoViewer.js\";\nexport const VideoViewer = withOsdkMetrics(_VideoViewer, \"VideoViewer\");"]}
1
+ {"version":3,"sources":["../../src/public/experimental/video-viewer.ts"],"names":["VideoViewer","withOsdkMetrics"],"mappings":";;;;;;AAqBO,IAAMA,YAAAA,GAAcC,iCAAA,CAAgBD,6BAAA,EAAc,aAAa","file":"chunk-2BLJCM7D.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// BaseVideoViewer\nexport { BaseVideoViewer } from \"../../video-viewer/BaseVideoViewer.js\";\n// VideoViewer (Media wrapper)\nimport { withOsdkMetrics } from \"../../util/withOsdkMetrics.js\";\nimport { VideoViewer as _VideoViewer } from \"../../video-viewer/VideoViewer.js\";\nexport const VideoViewer = withOsdkMetrics(_VideoViewer, \"VideoViewer\");"]}