@osdk/react-components 0.1.0-beta.1 → 0.1.0-beta.3

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 (131) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +51 -1
  3. package/build/browser/base-components/checkbox/Checkbox.js +40 -0
  4. package/build/browser/base-components/checkbox/Checkbox.js.map +1 -0
  5. package/build/browser/base-components/checkbox/Checkbox.module.css +71 -0
  6. package/build/browser/css-modules.d.ts +20 -0
  7. package/build/browser/object-table/CellContextMenu.js +48 -0
  8. package/build/browser/object-table/CellContextMenu.js.map +1 -0
  9. package/build/browser/object-table/ObjectTable.js +53 -9
  10. package/build/browser/object-table/ObjectTable.js.map +1 -1
  11. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  12. package/build/browser/object-table/SelectionCells.js +45 -0
  13. package/build/browser/object-table/SelectionCells.js.map +1 -0
  14. package/build/browser/object-table/Table.js +8 -4
  15. package/build/browser/object-table/Table.js.map +1 -1
  16. package/build/browser/object-table/TableBody.js +3 -1
  17. package/build/browser/object-table/TableBody.js.map +1 -1
  18. package/build/browser/object-table/TableCell.js +51 -0
  19. package/build/browser/object-table/TableCell.js.map +1 -0
  20. package/build/browser/object-table/TableHeader.js +20 -4
  21. package/build/browser/object-table/TableHeader.js.map +1 -1
  22. package/build/browser/object-table/TableRow.js +7 -9
  23. package/build/browser/object-table/TableRow.js.map +1 -1
  24. package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js +147 -0
  25. package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js.map +1 -0
  26. package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js +12 -0
  27. package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
  28. package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js +548 -0
  29. package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -0
  30. package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js +274 -0
  31. package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -0
  32. package/build/browser/object-table/hooks/useCellContextMenu.js +48 -0
  33. package/build/browser/object-table/hooks/useCellContextMenu.js.map +1 -0
  34. package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
  35. package/build/browser/object-table/hooks/useObjectTableData.js +3 -2
  36. package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
  37. package/build/browser/object-table/hooks/useRowSelection.js +180 -0
  38. package/build/browser/object-table/hooks/useRowSelection.js.map +1 -0
  39. package/build/browser/object-table/hooks/useSelectionColumn.js +51 -0
  40. package/build/browser/object-table/hooks/useSelectionColumn.js.map +1 -0
  41. package/build/browser/object-table/utils/getRowId.js +21 -0
  42. package/build/browser/object-table/utils/getRowId.js.map +1 -0
  43. package/build/browser/public/experimental.js +1 -0
  44. package/build/browser/public/experimental.js.map +1 -1
  45. package/build/cjs/public/experimental.cjs +424 -3611
  46. package/build/cjs/public/experimental.cjs.map +1 -1
  47. package/build/cjs/public/experimental.css +48 -0
  48. package/build/cjs/public/experimental.css.map +1 -0
  49. package/build/cjs/public/experimental.d.cts +6 -11
  50. package/build/esm/base-components/checkbox/Checkbox.js +40 -0
  51. package/build/esm/base-components/checkbox/Checkbox.js.map +1 -0
  52. package/build/esm/base-components/checkbox/Checkbox.module.css +71 -0
  53. package/build/esm/css-modules.d.ts +20 -0
  54. package/build/esm/object-table/CellContextMenu.js +48 -0
  55. package/build/esm/object-table/CellContextMenu.js.map +1 -0
  56. package/build/esm/object-table/ObjectTable.js +53 -9
  57. package/build/esm/object-table/ObjectTable.js.map +1 -1
  58. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  59. package/build/esm/object-table/SelectionCells.js +45 -0
  60. package/build/esm/object-table/SelectionCells.js.map +1 -0
  61. package/build/esm/object-table/Table.js +8 -4
  62. package/build/esm/object-table/Table.js.map +1 -1
  63. package/build/esm/object-table/TableBody.js +3 -1
  64. package/build/esm/object-table/TableBody.js.map +1 -1
  65. package/build/esm/object-table/TableCell.js +51 -0
  66. package/build/esm/object-table/TableCell.js.map +1 -0
  67. package/build/esm/object-table/TableHeader.js +20 -4
  68. package/build/esm/object-table/TableHeader.js.map +1 -1
  69. package/build/esm/object-table/TableRow.js +7 -9
  70. package/build/esm/object-table/TableRow.js.map +1 -1
  71. package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js +147 -0
  72. package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js.map +1 -0
  73. package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js +12 -0
  74. package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
  75. package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js +548 -0
  76. package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -0
  77. package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js +274 -0
  78. package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -0
  79. package/build/esm/object-table/hooks/useCellContextMenu.js +48 -0
  80. package/build/esm/object-table/hooks/useCellContextMenu.js.map +1 -0
  81. package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
  82. package/build/esm/object-table/hooks/useObjectTableData.js +3 -2
  83. package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
  84. package/build/esm/object-table/hooks/useRowSelection.js +180 -0
  85. package/build/esm/object-table/hooks/useRowSelection.js.map +1 -0
  86. package/build/esm/object-table/hooks/useSelectionColumn.js +51 -0
  87. package/build/esm/object-table/hooks/useSelectionColumn.js.map +1 -0
  88. package/build/esm/object-table/utils/getRowId.js +21 -0
  89. package/build/esm/object-table/utils/getRowId.js.map +1 -0
  90. package/build/esm/public/experimental.js +1 -0
  91. package/build/esm/public/experimental.js.map +1 -1
  92. package/build/types/base-components/checkbox/Checkbox.d.ts +10 -0
  93. package/build/types/base-components/checkbox/Checkbox.d.ts.map +1 -0
  94. package/build/types/css-modules.d.d.ts +6 -0
  95. package/build/types/css-modules.d.d.ts.map +1 -0
  96. package/build/types/object-table/CellContextMenu.d.ts +11 -0
  97. package/build/types/object-table/CellContextMenu.d.ts.map +1 -0
  98. package/build/types/object-table/ObjectTable.d.ts +1 -1
  99. package/build/types/object-table/ObjectTable.d.ts.map +1 -1
  100. package/build/types/object-table/ObjectTableApi.d.ts +5 -10
  101. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  102. package/build/types/object-table/SelectionCells.d.ts +14 -0
  103. package/build/types/object-table/SelectionCells.d.ts.map +1 -0
  104. package/build/types/object-table/Table.d.ts +4 -3
  105. package/build/types/object-table/Table.d.ts.map +1 -1
  106. package/build/types/object-table/TableBody.d.ts +3 -2
  107. package/build/types/object-table/TableBody.d.ts.map +1 -1
  108. package/build/types/object-table/TableCell.d.ts +8 -0
  109. package/build/types/object-table/TableCell.d.ts.map +1 -0
  110. package/build/types/object-table/TableHeader.d.ts +3 -3
  111. package/build/types/object-table/TableHeader.d.ts.map +1 -1
  112. package/build/types/object-table/TableRow.d.ts +3 -2
  113. package/build/types/object-table/TableRow.d.ts.map +1 -1
  114. package/build/types/object-table/hooks/__tests__/useCellContextMenu.test.d.ts +1 -0
  115. package/build/types/object-table/hooks/__tests__/useCellContextMenu.test.d.ts.map +1 -0
  116. package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts +1 -0
  117. package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts.map +1 -0
  118. package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts +1 -0
  119. package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts.map +1 -0
  120. package/build/types/object-table/hooks/useCellContextMenu.d.ts +17 -0
  121. package/build/types/object-table/hooks/useCellContextMenu.d.ts.map +1 -0
  122. package/build/types/object-table/hooks/useObjectTableData.d.ts +2 -2
  123. package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
  124. package/build/types/object-table/hooks/useRowSelection.d.ts +22 -0
  125. package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -0
  126. package/build/types/object-table/hooks/useSelectionColumn.d.ts +15 -0
  127. package/build/types/object-table/hooks/useSelectionColumn.d.ts.map +1 -0
  128. package/build/types/object-table/utils/getRowId.d.ts +6 -0
  129. package/build/types/object-table/utils/getRowId.d.ts.map +1 -0
  130. package/build/types/public/experimental.d.ts.map +1 -1
  131. package/package.json +13 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @osdk/react-components
2
2
 
3
+ ## 0.1.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 9cd0b26: Add base UI component and css module
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [acf6331]
12
+ - Updated dependencies [6cfe14a]
13
+ - Updated dependencies [ec6ad57]
14
+ - Updated dependencies [38d5958]
15
+ - Updated dependencies [56ba08f]
16
+ - Updated dependencies [d5cfc38]
17
+ - @osdk/react@0.9.0-beta.7
18
+ - @osdk/client@2.7.0-beta.11
19
+ - @osdk/api@2.7.0-beta.11
20
+
21
+ ## 0.1.0-beta.2
22
+
23
+ ### Minor Changes
24
+
25
+ - 9c9fb9b: Row selection, column resize, filter clause
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [6b27d8a]
30
+ - Updated dependencies [ba3159c]
31
+ - Updated dependencies [0395d4b]
32
+ - @osdk/client@2.7.0-beta.9
33
+ - @osdk/react@0.9.0-beta.6
34
+ - @osdk/api@2.7.0-beta.9
35
+
3
36
  ## 0.1.0-beta.1
4
37
 
5
38
  ### Minor Changes
package/README.md CHANGED
@@ -6,8 +6,14 @@ Built on top of [@osdk/react](../react), these components use OSDK hooks interna
6
6
 
7
7
  ## Installation
8
8
 
9
+ Run the command to install:
10
+
11
+ - @osdk/react-components - The unstyled components from this package
12
+ - @osdk/react - The react toolkit for data-handling
13
+ - @osdk/react-components-styles - The default styles for the components
14
+
9
15
  ```sh
10
- npm install @osdk/react-components @osdk/react
16
+ npm install @osdk/react-components @osdk/react @osdk/react-components-styles
11
17
  ```
12
18
 
13
19
  **Prerequisites:**
@@ -16,6 +22,17 @@ npm install @osdk/react-components @osdk/react
16
22
  - A configured OSDK client
17
23
  - An OsdkProvider wrapping your application
18
24
 
25
+ ## Setup
26
+
27
+ Add this to your application layout root as we are using Base UI portals. See https://base-ui.com/react/overview/quick-start#portals
28
+
29
+ ```css
30
+ /* index.css */
31
+ .root {
32
+ isolation: isolate;
33
+ }
34
+ ```
35
+
19
36
  ## Components
20
37
 
21
38
  > **Note:** This package is under active development. Not all components listed below are available yet.
@@ -28,6 +45,10 @@ The components that this package will provide are:
28
45
  | `FilterList` | Visualize a high-level summary of objects data to allow users to filter that data. |
29
46
  | `ActionForm` | Auto-generated form for executing Ontology Actions |
30
47
 
48
+ ## Custom Styling
49
+
50
+ See `@osdk/react-components-styles` README on how to apply custom themes and styling to the components.
51
+
31
52
  ## Example Usage
32
53
 
33
54
  ### Object Table
@@ -48,6 +69,35 @@ function EmployeeDirectory() {
48
69
  }
49
70
  ```
50
71
 
72
+ ### Running the Example People App
73
+
74
+ The examples are added to `packages/e2e.sandbox.peopleapp`, so we need to run the example app.
75
+
76
+ #### Steps:
77
+
78
+ 1. Create a .env.local file with the content below in packages/e2e.sandbox.peopleapp:
79
+
80
+ ```
81
+ VITE_FOUNDRY_URL=https://swirl.palantirfoundry.com
82
+ VITE_FOUNDRY_CLIENT_ID=<insert_client_id>
83
+ VITE_FOUNDRY_CLIENT_SECRET=<insert_token>
84
+ VITE_FOUNDRY_REDIRECT_URL=http://localhost:8080/auth/callback
85
+ ```
86
+
87
+ 2. Get VITE_FOUNDRY_CLIENT_ID from "https://swirl.palantirfoundry.com/workspace/developer-console/app/ri.third-party-applications.main.application.91b973ac-e504-4322-95b4-4962b60495fe/oauth" under App Credentials > Client ID.
88
+
89
+ 3. Transpile @osdk/react-components and its dependencies
90
+
91
+ ```
92
+ pnpm --filter @osdk/react-components transpileAllDeps && pnpm --filter @osdk/react-components transpileBrowser
93
+ ```
94
+
95
+ 4. Run the people app
96
+
97
+ ```
98
+ pnpm --filter @osdk/e2e.sandbox.peopleapp dev
99
+ ```
100
+
51
101
  ## Why this package?
52
102
 
53
103
  **OSDK-native.** These components understand Foundry concepts like Objects, Object Sets, and Actions. They are purpose-built for Ontology data.
@@ -0,0 +1,40 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ /*
3
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { Checkbox as BaseUICheckbox } from "@base-ui/react/checkbox";
19
+ import { Minus, Tick } from "@blueprintjs/icons";
20
+ import classnames from "classnames";
21
+ import React from "react";
22
+ import styles from "./Checkbox.module.css";
23
+ export function Checkbox({
24
+ indeterminate,
25
+ className,
26
+ indicatorProps,
27
+ ...rest
28
+ }) {
29
+ return /*#__PURE__*/React.createElement(BaseUICheckbox.Root, _extends({
30
+ className: classnames(styles.osdkCheckboxRoot, className),
31
+ indeterminate: indeterminate
32
+ }, rest), /*#__PURE__*/React.createElement(BaseUICheckbox.Indicator, _extends({}, indicatorProps, {
33
+ className: classnames(styles.osdkCheckboxIndicator, indicatorProps?.className)
34
+ }), indeterminate ? /*#__PURE__*/React.createElement(Minus, {
35
+ color: "currentColor"
36
+ }) : /*#__PURE__*/React.createElement(Tick, {
37
+ color: "currentColor"
38
+ })));
39
+ }
40
+ //# sourceMappingURL=Checkbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checkbox.js","names":["Checkbox","BaseUICheckbox","Minus","Tick","classnames","React","styles","indeterminate","className","indicatorProps","rest","createElement","Root","_extends","osdkCheckboxRoot","Indicator","osdkCheckboxIndicator","color"],"sources":["Checkbox.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 {\n Checkbox as BaseUICheckbox,\n type CheckboxIndicatorProps,\n type CheckboxRootProps,\n} from \"@base-ui/react/checkbox\";\nimport { Minus, Tick } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React from \"react\";\nimport styles from \"./Checkbox.module.css\";\n\ninterface CheckboxProps extends Omit<CheckboxRootProps, \"className\"> {\n className?: string;\n indicatorProps?: Omit<CheckboxIndicatorProps, \"className\"> & {\n className?: string;\n };\n}\n\nexport function Checkbox(\n {\n indeterminate,\n className,\n indicatorProps,\n ...rest\n }: CheckboxProps,\n): React.ReactElement {\n return (\n <BaseUICheckbox.Root\n className={classnames(styles.osdkCheckboxRoot, className)}\n indeterminate={indeterminate}\n {...rest}\n >\n <BaseUICheckbox.Indicator\n {...indicatorProps}\n className={classnames(\n styles.osdkCheckboxIndicator,\n indicatorProps?.className,\n )}\n >\n {/* Color is used as the \"fill\" attribute on the svg */}\n {indeterminate\n ? (\n <Minus\n color={\"currentColor\"}\n />\n )\n : <Tick color={\"currentColor\"} />}\n </BaseUICheckbox.Indicator>\n </BaseUICheckbox.Root>\n );\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,QAAQ,IAAIC,cAAc,QAGrB,yBAAyB;AAChC,SAASC,KAAK,EAAEC,IAAI,QAAQ,oBAAoB;AAChD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,uBAAuB;AAS1C,OAAO,SAASN,QAAQA,CACtB;EACEO,aAAa;EACbC,SAAS;EACTC,cAAc;EACd,GAAGC;AACU,CAAC,EACI;EACpB,oBACEL,KAAA,CAAAM,aAAA,CAACV,cAAc,CAACW,IAAI,EAAAC,QAAA;IAClBL,SAAS,EAAEJ,UAAU,CAACE,MAAM,CAACQ,gBAAgB,EAAEN,SAAS,CAAE;IAC1DD,aAAa,EAAEA;EAAc,GACzBG,IAAI,gBAERL,KAAA,CAAAM,aAAA,CAACV,cAAc,CAACc,SAAS,EAAAF,QAAA,KACnBJ,cAAc;IAClBD,SAAS,EAAEJ,UAAU,CACnBE,MAAM,CAACU,qBAAqB,EAC5BP,cAAc,EAAED,SAClB;EAAE,IAGDD,aAAa,gBAEVF,KAAA,CAAAM,aAAA,CAACT,KAAK;IACJe,KAAK,EAAE;EAAe,CACvB,CAAC,gBAEFZ,KAAA,CAAAM,aAAA,CAACR,IAAI;IAACc,KAAK,EAAE;EAAe,CAAE,CACV,CACP,CAAC;AAE1B","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ .osdkCheckboxRoot{
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ min-width: calc(var(--osdk-checkbox-icon-size) + var(--osdk-checkbox-padding) * 2);
22
+ min-height: calc(var(--osdk-checkbox-icon-size) + var(--osdk-checkbox-padding) * 2);
23
+ padding: var(--osdk-checkbox-padding);
24
+ box-sizing: border-box;
25
+ cursor: pointer;
26
+ border-radius: var(--bp-surface-borderRadius);
27
+
28
+ &[data-unchecked] {
29
+ background-color: var(--osdk-checkbox-bg);
30
+ border: var(--osdk-checkbox-border);
31
+
32
+ &:hover {
33
+ background-color: var(--osdk-checkbox-bg-hover);
34
+ }
35
+
36
+ &:active {
37
+ background-color: var(--osdk-checkbox-bg-active);
38
+ }
39
+ }
40
+
41
+ &[data-checked], &[data-indeterminate] {
42
+ background-color: var(--osdk-checkbox-bg-checked);
43
+
44
+ &:hover {
45
+ background-color: var(--osdk-checkbox-bg-checked-hover);
46
+ }
47
+
48
+ &:active {
49
+ background-color: var(--osdk-checkbox-bg-checked-active);
50
+ }
51
+ }
52
+
53
+ &:focus-visible {
54
+ outline: var(--bp-emphasis-focusWidth) solid var(--bp-emphasis-focusColor);
55
+ outline-offset: var(--bp-emphasis-focusOffset);
56
+ }
57
+ }
58
+
59
+ .osdkCheckboxIndicator {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ color: var(--osdk-checkbox-checked-foreground);
64
+ width: var(--osdk-checkbox-icon-size);
65
+ height: var(--osdk-checkbox-icon-size);
66
+
67
+
68
+ &[data-unchecked] {
69
+ display: none;
70
+ }
71
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ declare module "*.module.css" {
18
+ const classes: { readonly [key: string]: string };
19
+ export default classes;
20
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useEffect, useRef } from "react";
18
+ import { createPortal } from "react-dom";
19
+ export function CellContextMenu({
20
+ cell,
21
+ position,
22
+ onClose,
23
+ renderContent
24
+ }) {
25
+ const ref = useRef(null);
26
+ useEffect(() => {
27
+ const handleClickOutside = event => {
28
+ if (ref.current && !ref.current.contains(event.target)) {
29
+ onClose();
30
+ }
31
+ };
32
+ document.addEventListener("mousedown", handleClickOutside);
33
+ return () => {
34
+ document.removeEventListener("mousedown", handleClickOutside);
35
+ };
36
+ }, [onClose]);
37
+ return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement("div", {
38
+ ref: ref,
39
+ style: {
40
+ position: "fixed",
41
+ zIndex: 9999,
42
+ left: position.left,
43
+ top: position.top,
44
+ minWidth: position.width
45
+ }
46
+ }, renderContent(cell.row.original, cell)), document.body);
47
+ }
48
+ //# sourceMappingURL=CellContextMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CellContextMenu.js","names":["React","useEffect","useRef","createPortal","CellContextMenu","cell","position","onClose","renderContent","ref","handleClickOutside","event","current","contains","target","document","addEventListener","removeEventListener","createElement","style","zIndex","left","top","minWidth","width","row","original","body"],"sources":["CellContextMenu.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 { Cell, RowData } from \"@tanstack/react-table\";\nimport React, { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { PopoverPosition } from \"./hooks/useCellContextMenu.js\";\n\ninterface CellContextMenuProps<TData extends RowData> {\n cell: Cell<TData, unknown>;\n position: PopoverPosition;\n onClose: () => void;\n renderContent: (row: TData, cell: Cell<TData, unknown>) => React.ReactNode;\n}\n\nexport function CellContextMenu<TData extends RowData>({\n cell,\n position,\n onClose,\n renderContent,\n}: CellContextMenuProps<TData>): React.ReactElement {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n onClose();\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [onClose]);\n\n return createPortal(\n <div\n ref={ref}\n style={{\n position: \"fixed\",\n zIndex: 9999,\n left: position.left,\n top: position.top,\n minWidth: position.width,\n }}\n >\n {renderContent(cell.row.original, cell)}\n </div>,\n document.body,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,YAAY,QAAQ,WAAW;AAUxC,OAAO,SAASC,eAAeA,CAAwB;EACrDC,IAAI;EACJC,QAAQ;EACRC,OAAO;EACPC;AAC2B,CAAC,EAAsB;EAClD,MAAMC,GAAG,GAAGP,MAAM,CAAiB,IAAI,CAAC;EAExCD,SAAS,CAAC,MAAM;IACd,MAAMS,kBAAkB,GAAIC,KAAiB,IAAK;MAChD,IAAIF,GAAG,CAACG,OAAO,IAAI,CAACH,GAAG,CAACG,OAAO,CAACC,QAAQ,CAACF,KAAK,CAACG,MAAc,CAAC,EAAE;QAC9DP,OAAO,CAAC,CAAC;MACX;IACF,CAAC;IAEDQ,QAAQ,CAACC,gBAAgB,CAAC,WAAW,EAAEN,kBAAkB,CAAC;IAE1D,OAAO,MAAM;MACXK,QAAQ,CAACE,mBAAmB,CAAC,WAAW,EAAEP,kBAAkB,CAAC;IAC/D,CAAC;EACH,CAAC,EAAE,CAACH,OAAO,CAAC,CAAC;EAEb,oBAAOJ,YAAY,cACjBH,KAAA,CAAAkB,aAAA;IACET,GAAG,EAAEA,GAAI;IACTU,KAAK,EAAE;MACLb,QAAQ,EAAE,OAAO;MACjBc,MAAM,EAAE,IAAI;MACZC,IAAI,EAAEf,QAAQ,CAACe,IAAI;MACnBC,GAAG,EAAEhB,QAAQ,CAACgB,GAAG;MACjBC,QAAQ,EAAEjB,QAAQ,CAACkB;IACrB;EAAE,GAEDhB,aAAa,CAACH,IAAI,CAACoB,GAAG,CAACC,QAAQ,EAAErB,IAAI,CACnC,CAAC,EACNU,QAAQ,CAACY,IACX,CAAC;AACH","ignoreList":[]}
@@ -15,11 +15,14 @@
15
15
  */
16
16
 
17
17
  import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
18
- import React from "react";
18
+ import React, { useCallback, useMemo, useState } from "react";
19
19
  import { useColumnDefs } from "./hooks/useColumnDefs.js";
20
20
  import { useDefaultTableStates } from "./hooks/useDefaultTableStates.js";
21
21
  import { useObjectTableData } from "./hooks/useObjectTableData.js";
22
+ import { useRowSelection } from "./hooks/useRowSelection.js";
23
+ import { useSelectionColumn } from "./hooks/useSelectionColumn.js";
22
24
  import { Table } from "./Table.js";
25
+ import { getRowId } from "./utils/getRowId.js";
23
26
 
24
27
  /**
25
28
  * ObjectTable - A headless table component for displaying OSDK object sets
@@ -34,14 +37,18 @@ export function ObjectTable({
34
37
  objectSet,
35
38
  objectType,
36
39
  columnDefinitions,
37
- onRowClick,
38
- rowHeight
40
+ filter,
41
+ onRowSelection,
42
+ renderCellContextMenu,
43
+ selectionMode = "none",
44
+ selectedRows,
45
+ ...props
39
46
  }) {
40
47
  const {
41
48
  data,
42
49
  fetchMore,
43
50
  isLoading
44
- } = useObjectTableData(objectSet, columnDefinitions);
51
+ } = useObjectTableData(objectSet, columnDefinitions, filter);
45
52
  const {
46
53
  columns,
47
54
  loading: isColumnsLoading
@@ -51,20 +58,57 @@ export function ObjectTable({
51
58
  } = useDefaultTableStates({
52
59
  columnDefinitions
53
60
  });
61
+ const [columnSizing, setColumnSizing] = useState({});
62
+ const {
63
+ rowSelection,
64
+ isAllSelected,
65
+ hasSelection,
66
+ onToggleAll,
67
+ onToggleRow
68
+ } = useRowSelection({
69
+ selectionMode,
70
+ selectedRows,
71
+ onRowSelection,
72
+ data
73
+ });
74
+ const selectionColumn = useSelectionColumn({
75
+ selectionMode,
76
+ isAllSelected,
77
+ hasSelection,
78
+ onToggleAll,
79
+ onToggleRow
80
+ });
81
+ const allColumns = useMemo(() => {
82
+ return selectionColumn ? [selectionColumn, ...columns] : columns;
83
+ }, [selectionColumn, columns]);
54
84
  const table = useReactTable({
55
85
  data: data ?? [],
56
- columns,
86
+ columns: allColumns,
57
87
  getCoreRowModel: getCoreRowModel(),
58
88
  state: {
59
- columnVisibility
60
- }
89
+ columnVisibility,
90
+ rowSelection,
91
+ columnSizing
92
+ },
93
+ onColumnSizingChange: setColumnSizing,
94
+ enableRowSelection: selectionMode !== "none",
95
+ columnResizeMode: "onChange",
96
+ columnResizeDirection: "ltr",
97
+ defaultColumn: {
98
+ minSize: 80
99
+ },
100
+ getRowId
61
101
  });
102
+ const onRenderCellContextMenu = useCallback((row, cell) => {
103
+ return renderCellContextMenu?.(row, cell.getValue());
104
+ }, [renderCellContextMenu]);
62
105
  return /*#__PURE__*/React.createElement(Table, {
63
106
  table: table,
64
107
  isLoading: isLoading || isColumnsLoading,
65
108
  fetchNextPage: fetchMore,
66
- onRowClick: onRowClick,
67
- rowHeight: rowHeight
109
+ onRowClick: props.onRowClick,
110
+ rowHeight: props.rowHeight,
111
+ renderCellContextMenu: onRenderCellContextMenu
68
112
  });
69
113
  }
70
114
  //# sourceMappingURL=ObjectTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useColumnDefs","useDefaultTableStates","useObjectTableData","Table","ObjectTable","objectSet","objectType","columnDefinitions","onRowClick","rowHeight","data","fetchMore","isLoading","columns","loading","isColumnsLoading","columnVisibility","table","state","createElement","fetchNextPage"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { getCoreRowModel, useReactTable } from \"@tanstack/react-table\";\nimport React from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useDefaultTableStates } from \"./hooks/useDefaultTableStates.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { Table } from \"./Table.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectSet,\n objectType,\n columnDefinitions,\n onRowClick,\n rowHeight,\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { data, fetchMore, isLoading } = useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectSet,\n columnDefinitions,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const { columnVisibility } = useDefaultTableStates({ columnDefinitions });\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n },\n });\n\n const isTableLoading = isLoading || isColumnsLoading;\n\n return (\n <Table\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,eAAe,EAAEC,aAAa,QAAQ,uBAAuB;AACtE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,KAAK,QAAQ,YAAY;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,SAAS;EACTC,UAAU;EACVC,iBAAiB;EACjBC,UAAU;EACVC;AAC0C,CAAC,EAAsB;EACjE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGV,kBAAkB,CAKvDG,SAAS,EACTE,iBACF,CAAC;EAED,MAAM;IAAEM,OAAO;IAAEC,OAAO,EAAEC;EAAiB,CAAC,GAAGf,aAAa,CAK1DM,UAAU,EACVC,iBACF,CAAC;EAED,MAAM;IAAES;EAAiB,CAAC,GAAGf,qBAAqB,CAAC;IAAEM;EAAkB,CAAC,CAAC;EAEzE,MAAMU,KAAK,GAAGnB,aAAa,CAEzB;IACAY,IAAI,EAAEA,IAAI,IAAI,EAAE;IAChBG,OAAO;IACPhB,eAAe,EAAEA,eAAe,CAAC,CAAC;IAClCqB,KAAK,EAAE;MACLF;IACF;EACF,CAAC,CAAC;EAIF,oBACEjB,KAAA,CAAAoB,aAAA,CAAChB,KAAK;IACJc,KAAK,EAAEA,KAAM;IACbL,SAAS,EALUA,SAAS,IAAIG,gBAKN;IAC1BK,aAAa,EAAET,SAAU;IACzBH,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN","ignoreList":[]}
1
+ {"version":3,"file":"ObjectTable.js","names":["getCoreRowModel","useReactTable","React","useCallback","useMemo","useState","useColumnDefs","useDefaultTableStates","useObjectTableData","useRowSelection","useSelectionColumn","Table","getRowId","ObjectTable","objectSet","objectType","columnDefinitions","filter","onRowSelection","renderCellContextMenu","selectionMode","selectedRows","props","data","fetchMore","isLoading","columns","loading","isColumnsLoading","columnVisibility","columnSizing","setColumnSizing","rowSelection","isAllSelected","hasSelection","onToggleAll","onToggleRow","selectionColumn","allColumns","table","state","onColumnSizingChange","enableRowSelection","columnResizeMode","columnResizeDirection","defaultColumn","minSize","onRenderCellContextMenu","row","cell","getValue","createElement","fetchNextPage","onRowClick","rowHeight"],"sources":["ObjectTable.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport {\n type Cell,\n type ColumnSizingState,\n getCoreRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { useColumnDefs } from \"./hooks/useColumnDefs.js\";\nimport { useDefaultTableStates } from \"./hooks/useDefaultTableStates.js\";\nimport { useObjectTableData } from \"./hooks/useObjectTableData.js\";\nimport { useRowSelection } from \"./hooks/useRowSelection.js\";\nimport { useSelectionColumn } from \"./hooks/useSelectionColumn.js\";\nimport type { ObjectTableProps } from \"./ObjectTableApi.js\";\nimport { Table } from \"./Table.js\";\nimport { getRowId } from \"./utils/getRowId.js\";\n\n/**\n * ObjectTable - A headless table component for displaying OSDK object sets\n *\n * @example\n * ```tsx\n * <ObjectTable objectSet={myObjectSet} objectType={MyObjectType} />\n * ```\n */\n\nexport function ObjectTable<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n objectSet,\n objectType,\n columnDefinitions,\n filter,\n onRowSelection,\n renderCellContextMenu,\n selectionMode = \"none\",\n selectedRows,\n ...props\n}: ObjectTableProps<Q, RDPs, FunctionColumns>): React.ReactElement {\n const { data, fetchMore, isLoading } = useObjectTableData<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectSet,\n columnDefinitions,\n filter,\n );\n\n const { columns, loading: isColumnsLoading } = useColumnDefs<\n Q,\n RDPs,\n FunctionColumns\n >(\n objectType,\n columnDefinitions,\n );\n\n const { columnVisibility } = useDefaultTableStates({ columnDefinitions });\n\n const [columnSizing, setColumnSizing] = useState<ColumnSizingState>({});\n\n const {\n rowSelection,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n } = useRowSelection<Q, RDPs>({\n selectionMode,\n selectedRows,\n onRowSelection,\n data,\n });\n\n const selectionColumn = useSelectionColumn<Q, RDPs>(\n { selectionMode, isAllSelected, hasSelection, onToggleAll, onToggleRow },\n );\n\n const allColumns = useMemo(() => {\n return selectionColumn ? [selectionColumn, ...columns] : columns;\n }, [selectionColumn, columns]);\n\n const table = useReactTable<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >({\n data: data ?? [],\n columns: allColumns,\n getCoreRowModel: getCoreRowModel(),\n state: {\n columnVisibility,\n rowSelection,\n columnSizing,\n },\n onColumnSizingChange: setColumnSizing,\n enableRowSelection: selectionMode !== \"none\",\n columnResizeMode: \"onChange\",\n columnResizeDirection: \"ltr\",\n defaultColumn: {\n minSize: 80,\n },\n getRowId,\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 isTableLoading = isLoading || isColumnsLoading;\n\n return (\n <Table\n table={table}\n isLoading={isTableLoading}\n fetchNextPage={fetchMore}\n onRowClick={props.onRowClick}\n rowHeight={props.rowHeight}\n renderCellContextMenu={onRenderCellContextMenu}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAGEA,eAAe,EACfC,aAAa,QACR,uBAAuB;AAC9B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC7D,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,SAASC,KAAK,QAAQ,YAAY;AAClC,SAASC,QAAQ,QAAQ,qBAAqB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAWA,CAUzB;EACAC,SAAS;EACTC,UAAU;EACVC,iBAAiB;EACjBC,MAAM;EACNC,cAAc;EACdC,qBAAqB;EACrBC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZ,GAAGC;AACuC,CAAC,EAAsB;EACjE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGjB,kBAAkB,CAKvDM,SAAS,EACTE,iBAAiB,EACjBC,MACF,CAAC;EAED,MAAM;IAAES,OAAO;IAAEC,OAAO,EAAEC;EAAiB,CAAC,GAAGtB,aAAa,CAK1DS,UAAU,EACVC,iBACF,CAAC;EAED,MAAM;IAAEa;EAAiB,CAAC,GAAGtB,qBAAqB,CAAC;IAAES;EAAkB,CAAC,CAAC;EAEzE,MAAM,CAACc,YAAY,EAAEC,eAAe,CAAC,GAAG1B,QAAQ,CAAoB,CAAC,CAAC,CAAC;EAEvE,MAAM;IACJ2B,YAAY;IACZC,aAAa;IACbC,YAAY;IACZC,WAAW;IACXC;EACF,CAAC,GAAG3B,eAAe,CAAU;IAC3BW,aAAa;IACbC,YAAY;IACZH,cAAc;IACdK;EACF,CAAC,CAAC;EAEF,MAAMc,eAAe,GAAG3B,kBAAkB,CACxC;IAAEU,aAAa;IAAEa,aAAa;IAAEC,YAAY;IAAEC,WAAW;IAAEC;EAAY,CACzE,CAAC;EAED,MAAME,UAAU,GAAGlC,OAAO,CAAC,MAAM;IAC/B,OAAOiC,eAAe,GAAG,CAACA,eAAe,EAAE,GAAGX,OAAO,CAAC,GAAGA,OAAO;EAClE,CAAC,EAAE,CAACW,eAAe,EAAEX,OAAO,CAAC,CAAC;EAE9B,MAAMa,KAAK,GAAGtC,aAAa,CAEzB;IACAsB,IAAI,EAAEA,IAAI,IAAI,EAAE;IAChBG,OAAO,EAAEY,UAAU;IACnBtC,eAAe,EAAEA,eAAe,CAAC,CAAC;IAClCwC,KAAK,EAAE;MACLX,gBAAgB;MAChBG,YAAY;MACZF;IACF,CAAC;IACDW,oBAAoB,EAAEV,eAAe;IACrCW,kBAAkB,EAAEtB,aAAa,KAAK,MAAM;IAC5CuB,gBAAgB,EAAE,UAAU;IAC5BC,qBAAqB,EAAE,KAAK;IAC5BC,aAAa,EAAE;MACbC,OAAO,EAAE;IACX,CAAC;IACDlC;EACF,CAAC,CAAC;EAEF,MAAMmC,uBAAuB,GAAG5C,WAAW,CACzC,CACE6C,GAAkE,EAClEC,IAGC,KACE;IACH,OAAO9B,qBAAqB,GAAG6B,GAAG,EAAEC,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;EACtD,CAAC,EACD,CAAC/B,qBAAqB,CACxB,CAAC;EAID,oBACEjB,KAAA,CAAAiD,aAAA,CAACxC,KAAK;IACJ4B,KAAK,EAAEA,KAAM;IACbd,SAAS,EALUA,SAAS,IAAIG,gBAKN;IAC1BwB,aAAa,EAAE5B,SAAU;IACzB6B,UAAU,EAAE/B,KAAK,CAAC+B,UAAW;IAC7BC,SAAS,EAAEhC,KAAK,CAACgC,SAAU;IAC3BnC,qBAAqB,EAAE4B;EAAwB,CAChD,CAAC;AAEN","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\n\nexport type ColumnDefinition<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | {\n type: \"property\";\n id: PropertyKeys<Q>;\n }\n | {\n type: \"function\";\n id: keyof FunctionColumns;\n }\n | {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n };\n\nexport interface ObjectTableProps<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The set of objects to show in the table\n */\n objectSet: ObjectSet<Q>;\n\n /**\n * The object type of the object\n */\n objectType: Q;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n filterable?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n orderable?: boolean;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called when the visible columns change.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The new list of column visibility states\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number,\n ) => void;\n\n /**\n * Called when a cell is clicked.\n *\n * @param object The object representing the row\n * @param columnDefinition The column definition for the clicked cell\n */\n onCellClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param objects The currently selected objects\n */\n onRowSelection?: (objects: PrimaryKeyType<Q>[]) => void;\n\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\n\nexport type ColumnDefinition<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | {\n type: \"property\";\n id: PropertyKeys<Q>;\n }\n | {\n type: \"function\";\n id: keyof FunctionColumns;\n }\n | {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n };\n\nexport interface ObjectTableProps<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The set of objects to show in the table\n */\n objectSet: ObjectSet<Q>;\n\n /**\n * The object type of the object\n */\n objectType: Q;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n filterable?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n orderable?: boolean;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called when the visible columns change.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The new list of column visibility states\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @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 * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n */\n\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n\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 * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useCallback } from "react";
18
+ import { Checkbox } from "../base-components/checkbox/Checkbox.js";
19
+ export function SelectionHeaderCell({
20
+ isAllSelected,
21
+ hasSelection,
22
+ onToggleAll
23
+ }) {
24
+ return /*#__PURE__*/React.createElement(Checkbox, {
25
+ indeterminate: hasSelection && !isAllSelected,
26
+ checked: isAllSelected,
27
+ onCheckedChange: onToggleAll,
28
+ "aria-label": "Select all rows"
29
+ });
30
+ }
31
+ export function SelectionCell({
32
+ row,
33
+ onToggleRow
34
+ }) {
35
+ const handleClick = useCallback(event => {
36
+ const isShiftClick = event.shiftKey;
37
+ onToggleRow(row.id, row.index, isShiftClick);
38
+ }, [row, onToggleRow]);
39
+ return /*#__PURE__*/React.createElement(Checkbox, {
40
+ checked: row.getIsSelected(),
41
+ onClick: handleClick,
42
+ "aria-label": `Select row ${row.index + 1}`
43
+ });
44
+ }
45
+ //# sourceMappingURL=SelectionCells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectionCells.js","names":["React","useCallback","Checkbox","SelectionHeaderCell","isAllSelected","hasSelection","onToggleAll","createElement","indeterminate","checked","onCheckedChange","SelectionCell","row","onToggleRow","handleClick","event","isShiftClick","shiftKey","id","index","getIsSelected","onClick"],"sources":["SelectionCells.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Row, RowData } from \"@tanstack/react-table\";\nimport React, { useCallback } from \"react\";\nimport { Checkbox } from \"../base-components/checkbox/Checkbox.js\";\n\ninterface SelectionHeaderCellProps {\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n}\n\nexport function SelectionHeaderCell({\n isAllSelected,\n hasSelection,\n onToggleAll,\n}: SelectionHeaderCellProps): React.ReactElement {\n return (\n <Checkbox\n indeterminate={hasSelection && !isAllSelected}\n checked={isAllSelected}\n onCheckedChange={onToggleAll}\n aria-label={\"Select all rows\"}\n />\n );\n}\n\ninterface SelectionCellProps<TData extends RowData> {\n row: Row<TData>;\n onToggleRow: (rowId: string, rowIndex: number, isShiftClick: boolean) => void;\n}\n\nexport function SelectionCell<TData extends RowData>({\n row,\n onToggleRow,\n}: SelectionCellProps<TData>): React.ReactElement {\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {\n const isShiftClick = event.shiftKey;\n onToggleRow(row.id, row.index, isShiftClick);\n },\n [row, onToggleRow],\n );\n\n return (\n <Checkbox\n checked={row.getIsSelected()}\n onClick={handleClick}\n aria-label={`Select row ${row.index + 1}`}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,QAAQ,QAAQ,yCAAyC;AAQlE,OAAO,SAASC,mBAAmBA,CAAC;EAClCC,aAAa;EACbC,YAAY;EACZC;AACwB,CAAC,EAAsB;EAC/C,oBACEN,KAAA,CAAAO,aAAA,CAACL,QAAQ;IACPM,aAAa,EAAEH,YAAY,IAAI,CAACD,aAAc;IAC9CK,OAAO,EAAEL,aAAc;IACvBM,eAAe,EAAEJ,WAAY;IAC7B,cAAY;EAAkB,CAC/B,CAAC;AAEN;AAOA,OAAO,SAASK,aAAaA,CAAwB;EACnDC,GAAG;EACHC;AACyB,CAAC,EAAsB;EAChD,MAAMC,WAAW,GAAGb,WAAW,CAC5Bc,KAAoD,IAAK;IACxD,MAAMC,YAAY,GAAGD,KAAK,CAACE,QAAQ;IACnCJ,WAAW,CAACD,GAAG,CAACM,EAAE,EAAEN,GAAG,CAACO,KAAK,EAAEH,YAAY,CAAC;EAC9C,CAAC,EACD,CAACJ,GAAG,EAAEC,WAAW,CACnB,CAAC;EAED,oBACEb,KAAA,CAAAO,aAAA,CAACL,QAAQ;IACPO,OAAO,EAAEG,GAAG,CAACQ,aAAa,CAAC,CAAE;IAC7BC,OAAO,EAAEP,WAAY;IACrB,cAAY,cAAcF,GAAG,CAACO,KAAK,GAAG,CAAC;EAAG,CAC3C,CAAC;AAEN","ignoreList":[]}
@@ -22,7 +22,8 @@ export function Table({
22
22
  isLoading,
23
23
  fetchNextPage,
24
24
  onRowClick,
25
- rowHeight
25
+ rowHeight,
26
+ renderCellContextMenu
26
27
  }) {
27
28
  const tableContainerRef = useRef(null);
28
29
 
@@ -58,7 +59,9 @@ export function Table({
58
59
  // needed for sticky header
59
60
  height: "100%",
60
61
  // needed for scrolling
61
- overflow: "auto"
62
+ overflow: "auto",
63
+ cursor: table.getState().columnSizingInfo?.isResizingColumn ? "col-resize" : "default",
64
+ userSelect: table.getState().columnSizingInfo?.isResizingColumn ? "none" : "auto"
62
65
  },
63
66
  onScroll: handleScroll
64
67
  }, /*#__PURE__*/React.createElement("table", {
@@ -66,12 +69,13 @@ export function Table({
66
69
  display: "grid"
67
70
  }
68
71
  }, /*#__PURE__*/React.createElement(TableHeader, {
69
- headerGroups: table.getHeaderGroups()
72
+ table: table
70
73
  }), /*#__PURE__*/React.createElement(TableBody, {
71
74
  rows: table.getRowModel().rows,
72
75
  tableContainerRef: tableContainerRef,
73
76
  onRowClick: onRowClick,
74
- rowHeight: rowHeight
77
+ rowHeight: rowHeight,
78
+ renderCellContextMenu: renderCellContextMenu
75
79
  })));
76
80
  }
77
81
  //# sourceMappingURL=Table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","names":["React","useCallback","useRef","TableBody","TableHeader","Table","table","isLoading","fetchNextPage","onRowClick","rowHeight","tableContainerRef","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","createElement","ref","style","position","height","overflow","onScroll","display","headerGroups","getHeaderGroups","rows","getRowModel"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RowData, Table } from \"@tanstack/react-table\";\nimport React, { type ReactElement, useCallback, useRef } from \"react\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableHeader } from \"./TableHeader.js\";\n\ninterface TableProps<TData extends RowData> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n}\n\nexport function Table<TData extends RowData>(\n { table, isLoading, fetchNextPage, onRowClick, rowHeight }: TableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading\n ) {\n fetchingRef.current = true;\n try {\n await fetchNextPage?.();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n // TODO: Handle error, loading and empty states\n\n return (\n <div\n ref={tableContainerRef}\n style={{\n position: \"relative\", // needed for sticky header\n height: \"100%\", // needed for scrolling\n overflow: \"auto\",\n }}\n onScroll={handleScroll}\n >\n <table\n style={{ display: \"grid\" }}\n >\n <TableHeader headerGroups={table.getHeaderGroups()} />\n <TableBody\n rows={table.getRowModel().rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n />\n </table>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAuBC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AACrE,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAU9C,OAAO,SAASC,KAAKA,CACnB;EAAEC,KAAK;EAAEC,SAAS;EAAEC,aAAa;EAAEC,UAAU;EAAEC;AAA6B,CAAC,EAC/D;EACd,MAAMC,iBAAiB,GAAGT,MAAM,CAAiB,IAAI,CAAC;;EAEtD;EACA,MAAMU,WAAW,GAAGV,MAAM,CAAC,KAAK,CAAC;EAEjC,MAAMW,qBAAqB,GAAGZ,WAAW,CACvC,MAAOa,mBAA2C,IAAK;IACrD,IAAIA,mBAAmB,IAAI,CAACF,WAAW,CAACG,OAAO,EAAE;MAC/C,MAAM;QAAEC,YAAY;QAAEC,SAAS;QAAEC;MAAa,CAAC,GAAGJ,mBAAmB;MACrE,IACEE,YAAY,GAAGC,SAAS,GAAGC,YAAY,GAAG,GAAG,IAC1C,CAACX,SAAS,EACb;QACAK,WAAW,CAACG,OAAO,GAAG,IAAI;QAC1B,IAAI;UACF,MAAMP,aAAa,GAAG,CAAC;QACzB,CAAC,SAAS;UACRI,WAAW,CAACG,OAAO,GAAG,KAAK;QAC7B;MACF;IACF;EACF,CAAC,EACD,CAACP,aAAa,EAAED,SAAS,CAC3B,CAAC;EAED,MAAMY,YAAY,GAAGlB,WAAW,CAC9B,MAAOmB,CAAgC,IAAK;IAC1C,MAAMP,qBAAqB,CAACO,CAAC,CAACC,aAAa,CAAC;EAC9C,CAAC,EACD,CAACR,qBAAqB,CACxB,CAAC;;EAED;;EAEA,oBACEb,KAAA,CAAAsB,aAAA;IACEC,GAAG,EAAEZ,iBAAkB;IACvBa,KAAK,EAAE;MACLC,QAAQ,EAAE,UAAU;MAAE;MACtBC,MAAM,EAAE,MAAM;MAAE;MAChBC,QAAQ,EAAE;IACZ,CAAE;IACFC,QAAQ,EAAET;EAAa,gBAEvBnB,KAAA,CAAAsB,aAAA;IACEE,KAAK,EAAE;MAAEK,OAAO,EAAE;IAAO;EAAE,gBAE3B7B,KAAA,CAAAsB,aAAA,CAAClB,WAAW;IAAC0B,YAAY,EAAExB,KAAK,CAACyB,eAAe,CAAC;EAAE,CAAE,CAAC,eACtD/B,KAAA,CAAAsB,aAAA,CAACnB,SAAS;IACR6B,IAAI,EAAE1B,KAAK,CAAC2B,WAAW,CAAC,CAAC,CAACD,IAAK;IAC/BrB,iBAAiB,EAAEA,iBAAkB;IACrCF,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA;EAAU,CACtB,CACI,CACJ,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"Table.js","names":["React","useCallback","useRef","TableBody","TableHeader","Table","table","isLoading","fetchNextPage","onRowClick","rowHeight","renderCellContextMenu","tableContainerRef","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","createElement","ref","style","position","height","overflow","cursor","getState","columnSizingInfo","isResizingColumn","userSelect","onScroll","display","rows","getRowModel"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData, Table } from \"@tanstack/react-table\";\nimport React, { type ReactElement, useCallback, useRef } from \"react\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableHeader } from \"./TableHeader.js\";\n\ninterface TableProps<TData extends RowData> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n}\n\nexport function Table<TData extends RowData>(\n {\n table,\n isLoading,\n fetchNextPage,\n onRowClick,\n rowHeight,\n renderCellContextMenu,\n }: TableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading\n ) {\n fetchingRef.current = true;\n try {\n await fetchNextPage?.();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n // TODO: Handle error, loading and empty states\n\n return (\n <div\n ref={tableContainerRef}\n style={{\n position: \"relative\", // needed for sticky header\n height: \"100%\", // needed for scrolling\n overflow: \"auto\",\n cursor: table.getState().columnSizingInfo?.isResizingColumn\n ? \"col-resize\"\n : \"default\",\n userSelect: table.getState().columnSizingInfo?.isResizingColumn\n ? \"none\"\n : \"auto\",\n }}\n onScroll={handleScroll}\n >\n <table\n style={{ display: \"grid\" }}\n >\n <TableHeader table={table} />\n <TableBody\n rows={table.getRowModel().rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n renderCellContextMenu={renderCellContextMenu}\n />\n </table>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAuBC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AACrE,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAc9C,OAAO,SAASC,KAAKA,CACnB;EACEC,KAAK;EACLC,SAAS;EACTC,aAAa;EACbC,UAAU;EACVC,SAAS;EACTC;AACiB,CAAC,EACN;EACd,MAAMC,iBAAiB,GAAGV,MAAM,CAAiB,IAAI,CAAC;;EAEtD;EACA,MAAMW,WAAW,GAAGX,MAAM,CAAC,KAAK,CAAC;EAEjC,MAAMY,qBAAqB,GAAGb,WAAW,CACvC,MAAOc,mBAA2C,IAAK;IACrD,IAAIA,mBAAmB,IAAI,CAACF,WAAW,CAACG,OAAO,EAAE;MAC/C,MAAM;QAAEC,YAAY;QAAEC,SAAS;QAAEC;MAAa,CAAC,GAAGJ,mBAAmB;MACrE,IACEE,YAAY,GAAGC,SAAS,GAAGC,YAAY,GAAG,GAAG,IAC1C,CAACZ,SAAS,EACb;QACAM,WAAW,CAACG,OAAO,GAAG,IAAI;QAC1B,IAAI;UACF,MAAMR,aAAa,GAAG,CAAC;QACzB,CAAC,SAAS;UACRK,WAAW,CAACG,OAAO,GAAG,KAAK;QAC7B;MACF;IACF;EACF,CAAC,EACD,CAACR,aAAa,EAAED,SAAS,CAC3B,CAAC;EAED,MAAMa,YAAY,GAAGnB,WAAW,CAC9B,MAAOoB,CAAgC,IAAK;IAC1C,MAAMP,qBAAqB,CAACO,CAAC,CAACC,aAAa,CAAC;EAC9C,CAAC,EACD,CAACR,qBAAqB,CACxB,CAAC;;EAED;;EAEA,oBACEd,KAAA,CAAAuB,aAAA;IACEC,GAAG,EAAEZ,iBAAkB;IACvBa,KAAK,EAAE;MACLC,QAAQ,EAAE,UAAU;MAAE;MACtBC,MAAM,EAAE,MAAM;MAAE;MAChBC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EAAEvB,KAAK,CAACwB,QAAQ,CAAC,CAAC,CAACC,gBAAgB,EAAEC,gBAAgB,GACvD,YAAY,GACZ,SAAS;MACbC,UAAU,EAAE3B,KAAK,CAACwB,QAAQ,CAAC,CAAC,CAACC,gBAAgB,EAAEC,gBAAgB,GAC3D,MAAM,GACN;IACN,CAAE;IACFE,QAAQ,EAAEd;EAAa,gBAEvBpB,KAAA,CAAAuB,aAAA;IACEE,KAAK,EAAE;MAAEU,OAAO,EAAE;IAAO;EAAE,gBAE3BnC,KAAA,CAAAuB,aAAA,CAACnB,WAAW;IAACE,KAAK,EAAEA;EAAM,CAAE,CAAC,eAC7BN,KAAA,CAAAuB,aAAA,CAACpB,SAAS;IACRiC,IAAI,EAAE9B,KAAK,CAAC+B,WAAW,CAAC,CAAC,CAACD,IAAK;IAC/BxB,iBAAiB,EAAEA,iBAAkB;IACrCH,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,qBAAqB,EAAEA;EAAsB,CAC9C,CACI,CACJ,CAAC;AAEV","ignoreList":[]}
@@ -21,6 +21,7 @@ export function TableBody({
21
21
  rows,
22
22
  tableContainerRef,
23
23
  onRowClick,
24
+ renderCellContextMenu,
24
25
  rowHeight = 40
25
26
  }) {
26
27
  // Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.
@@ -47,7 +48,8 @@ export function TableBody({
47
48
  key: row.id,
48
49
  row: row,
49
50
  virtualRow: virtualRow,
50
- onRowClick: onRowClick
51
+ onRowClick: onRowClick,
52
+ renderCellContextMenu: renderCellContextMenu
51
53
  });
52
54
  }));
53
55
  }