@osdk/react-components 0.2.0-beta.1 → 0.2.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 (330) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +21 -5
  3. package/build/browser/base-components/action-button/ActionButton.js +31 -0
  4. package/build/browser/base-components/action-button/ActionButton.js.map +1 -0
  5. package/build/browser/base-components/action-button/ActionButton.module.css +70 -0
  6. package/build/browser/base-components/action-button/ActionButton.module.css.js +8 -0
  7. package/build/browser/base-components/checkbox/Checkbox.js +27 -32
  8. package/build/browser/base-components/checkbox/Checkbox.module.css +79 -0
  9. package/build/browser/base-components/checkbox/Checkbox.module.css.js +7 -0
  10. package/build/browser/base-components/combobox/Combobox.js +124 -0
  11. package/build/browser/base-components/combobox/Combobox.js.map +1 -0
  12. package/build/browser/base-components/combobox/Combobox.module.css +177 -0
  13. package/build/browser/base-components/combobox/Combobox.module.css.js +16 -0
  14. package/build/browser/base-components/dialog/Dialog.js +52 -0
  15. package/build/browser/base-components/dialog/Dialog.js.map +1 -0
  16. package/build/browser/base-components/dialog/Dialog.module.css +101 -0
  17. package/build/browser/base-components/dialog/Dialog.module.css.js +13 -0
  18. package/build/browser/base-components/draggable-list/DraggableList.js +155 -0
  19. package/build/browser/base-components/draggable-list/DraggableList.js.map +1 -0
  20. package/build/browser/base-components/draggable-list/DraggableList.module.css +108 -0
  21. package/build/browser/base-components/draggable-list/DraggableList.module.css.js +11 -0
  22. package/build/browser/base-components/search-bar/SearchBar.js +44 -0
  23. package/build/browser/base-components/search-bar/SearchBar.js.map +1 -0
  24. package/build/browser/base-components/search-bar/SearchBar.module.css +53 -0
  25. package/build/browser/base-components/search-bar/SearchBar.module.css.js +8 -0
  26. package/build/browser/base-components/select/Select.js +89 -0
  27. package/build/browser/base-components/select/Select.js.map +1 -0
  28. package/build/browser/base-components/select/Select.module.css +138 -0
  29. package/build/browser/base-components/select/Select.module.css.js +11 -0
  30. package/build/browser/base-components/switch/Switch.js +33 -0
  31. package/build/browser/base-components/switch/Switch.js.map +1 -0
  32. package/build/browser/base-components/switch/Switch.module.css +91 -0
  33. package/build/browser/base-components/switch/Switch.module.css.js +7 -0
  34. package/build/browser/filter-list/FilterListApi.js.map +1 -1
  35. package/build/browser/filter-list/FilterListItemApi.js.map +1 -1
  36. package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js +296 -0
  37. package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js.map +1 -0
  38. package/build/browser/filter-list/__tests__/getFilterKey.test.js +53 -0
  39. package/build/browser/filter-list/__tests__/getFilterKey.test.js.map +1 -0
  40. package/build/browser/filter-list/__tests__/testUtils.js +192 -0
  41. package/build/browser/filter-list/__tests__/testUtils.js.map +1 -0
  42. package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js +128 -0
  43. package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js.map +1 -0
  44. package/build/browser/filter-list/hooks/useDebouncedValue.js +52 -0
  45. package/build/browser/filter-list/hooks/useDebouncedValue.js.map +1 -0
  46. package/build/browser/filter-list/hooks/useFilterListState.js +119 -0
  47. package/build/browser/filter-list/hooks/useFilterListState.js.map +1 -0
  48. package/build/browser/filter-list/hooks/usePropertyAggregation.js +92 -0
  49. package/build/browser/filter-list/hooks/usePropertyAggregation.js.map +1 -0
  50. package/build/browser/filter-list/types/AddFilterMenuTypes.js +2 -0
  51. package/build/browser/filter-list/types/AddFilterMenuTypes.js.map +1 -0
  52. package/build/browser/filter-list/types/CustomRendererTypes.js +2 -0
  53. package/build/browser/filter-list/types/CustomRendererTypes.js.map +1 -0
  54. package/build/browser/filter-list/types/KeywordSearchTypes.js +2 -0
  55. package/build/browser/filter-list/types/KeywordSearchTypes.js.map +1 -0
  56. package/build/browser/filter-list/types/LinkedFilterTypes.js +2 -0
  57. package/build/browser/filter-list/types/LinkedFilterTypes.js.map +1 -0
  58. package/build/browser/filter-list/types/index.js +21 -0
  59. package/build/browser/filter-list/types/index.js.map +1 -0
  60. package/build/browser/filter-list/utils/assertUnreachable.js +25 -0
  61. package/build/browser/filter-list/utils/assertUnreachable.js.map +1 -0
  62. package/build/browser/filter-list/utils/coerceFilterValue.js +33 -0
  63. package/build/browser/filter-list/utils/coerceFilterValue.js.map +1 -0
  64. package/build/browser/filter-list/utils/filterStateToWhereClause.js +337 -0
  65. package/build/browser/filter-list/utils/filterStateToWhereClause.js.map +1 -0
  66. package/build/browser/filter-list/utils/filterValues.js +55 -0
  67. package/build/browser/filter-list/utils/filterValues.js.map +1 -0
  68. package/build/browser/filter-list/utils/getFilterKey.js +34 -0
  69. package/build/browser/filter-list/utils/getFilterKey.js.map +1 -0
  70. package/build/browser/object-table/CellContextMenu.js +23 -20
  71. package/build/browser/object-table/CellContextMenu.module.css +20 -0
  72. package/build/browser/object-table/CellContextMenu.module.css.js +6 -0
  73. package/build/browser/object-table/ColumnConfigDialog.js +259 -0
  74. package/build/browser/object-table/ColumnConfigDialog.js.map +1 -0
  75. package/build/browser/object-table/ColumnConfigDialog.module.css +247 -0
  76. package/build/browser/object-table/ColumnConfigDialog.module.css.js +29 -0
  77. package/build/browser/object-table/LoadingCell.js +24 -29
  78. package/build/browser/object-table/LoadingCell.module.css +48 -0
  79. package/build/browser/object-table/LoadingCell.module.css.js +8 -0
  80. package/build/browser/object-table/LoadingRow.js +24 -50
  81. package/build/browser/object-table/LoadingStateTable.js +49 -343
  82. package/build/browser/object-table/LoadingStateTable.js.map +1 -1
  83. package/build/browser/object-table/MultiColumnSortDialog.js +178 -0
  84. package/build/browser/object-table/MultiColumnSortDialog.js.map +1 -0
  85. package/build/browser/object-table/MultiColumnSortDialog.module.css +195 -0
  86. package/build/browser/object-table/MultiColumnSortDialog.module.css.js +22 -0
  87. package/build/browser/object-table/NonIdealState.js +23 -20
  88. package/build/browser/object-table/NonIdealState.module.css +27 -0
  89. package/build/browser/object-table/NonIdealState.module.css.js +7 -0
  90. package/build/browser/object-table/ObjectTable.js +43 -13
  91. package/build/browser/object-table/ObjectTable.js.map +1 -1
  92. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  93. package/build/browser/object-table/SortableItemsList.js +35 -0
  94. package/build/browser/object-table/SortableItemsList.js.map +1 -0
  95. package/build/browser/object-table/Table.js +54 -934
  96. package/build/browser/object-table/Table.js.map +1 -1
  97. package/build/browser/object-table/Table.module.css +29 -0
  98. package/build/browser/object-table/Table.module.css.js +6 -0
  99. package/build/browser/object-table/TableBody.js +36 -260
  100. package/build/browser/object-table/TableBody.module.css +20 -0
  101. package/build/browser/object-table/TableBody.module.css.js +6 -0
  102. package/build/browser/object-table/TableCell.js +31 -111
  103. package/build/browser/object-table/TableCell.module.css +73 -0
  104. package/build/browser/object-table/TableCell.module.css.js +8 -0
  105. package/build/browser/object-table/TableHeader.js +126 -216
  106. package/build/browser/object-table/TableHeader.js.map +1 -1
  107. package/build/browser/object-table/TableHeader.module.css +106 -0
  108. package/build/browser/object-table/TableHeader.module.css.js +10 -0
  109. package/build/browser/object-table/TableHeaderContent.js +21 -18
  110. package/build/browser/object-table/TableHeaderContent.module.css +30 -0
  111. package/build/browser/object-table/TableHeaderContent.module.css.js +6 -0
  112. package/build/browser/object-table/TableHeaderWithPopover.js +110 -93
  113. package/build/browser/object-table/TableHeaderWithPopover.js.map +1 -1
  114. package/build/browser/object-table/TableHeaderWithPopover.module.css +141 -0
  115. package/build/browser/object-table/TableHeaderWithPopover.module.css.js +17 -0
  116. package/build/browser/object-table/TableRow.js +26 -144
  117. package/build/browser/object-table/TableRow.module.css +60 -0
  118. package/build/browser/object-table/TableRow.module.css.js +6 -0
  119. package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js +160 -138
  120. package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js.map +1 -1
  121. package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js +3 -0
  122. package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -1
  123. package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js +27 -82
  124. package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -1
  125. package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js +290 -0
  126. package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js.map +1 -1
  127. package/build/browser/object-table/hooks/useColumnDefs.js +7 -2
  128. package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
  129. package/build/browser/object-table/hooks/useColumnResize.js +45 -0
  130. package/build/browser/object-table/hooks/useColumnResize.js.map +1 -0
  131. package/build/browser/object-table/hooks/useColumnVisibility.js +52 -20
  132. package/build/browser/object-table/hooks/useColumnVisibility.js.map +1 -1
  133. package/build/browser/object-table/hooks/useRowSelection.js +8 -7
  134. package/build/browser/object-table/hooks/useRowSelection.js.map +1 -1
  135. package/build/browser/object-table/hooks/useSelectionColumn.js +15 -6
  136. package/build/browser/object-table/hooks/useSelectionColumn.js.map +1 -1
  137. package/build/browser/object-table/utils/types.js +2 -0
  138. package/build/browser/object-table/utils/types.js.map +1 -0
  139. package/build/browser/public/experimental.js +1 -0
  140. package/build/browser/public/experimental.js.map +1 -1
  141. package/build/browser/styles.css +1875 -0
  142. package/build/cjs/public/experimental.cjs +1036 -197
  143. package/build/cjs/public/experimental.cjs.map +1 -1
  144. package/build/cjs/public/experimental.css +659 -29
  145. package/build/cjs/public/experimental.css.map +1 -1
  146. package/build/cjs/public/experimental.d.cts +435 -44
  147. package/build/esm/base-components/action-button/ActionButton.js +31 -0
  148. package/build/esm/base-components/action-button/ActionButton.js.map +1 -0
  149. package/build/esm/base-components/action-button/ActionButton.module.css +70 -0
  150. package/build/esm/base-components/checkbox/Checkbox.module.css +1 -1
  151. package/build/esm/base-components/combobox/Combobox.js +124 -0
  152. package/build/esm/base-components/combobox/Combobox.js.map +1 -0
  153. package/build/esm/base-components/combobox/Combobox.module.css +177 -0
  154. package/build/esm/base-components/dialog/Dialog.js +52 -0
  155. package/build/esm/base-components/dialog/Dialog.js.map +1 -0
  156. package/build/esm/base-components/dialog/Dialog.module.css +101 -0
  157. package/build/esm/base-components/draggable-list/DraggableList.js +155 -0
  158. package/build/esm/base-components/draggable-list/DraggableList.js.map +1 -0
  159. package/build/esm/base-components/draggable-list/DraggableList.module.css +108 -0
  160. package/build/esm/base-components/search-bar/SearchBar.js +44 -0
  161. package/build/esm/base-components/search-bar/SearchBar.js.map +1 -0
  162. package/build/esm/base-components/search-bar/SearchBar.module.css +53 -0
  163. package/build/esm/base-components/select/Select.js +89 -0
  164. package/build/esm/base-components/select/Select.js.map +1 -0
  165. package/build/esm/base-components/select/Select.module.css +138 -0
  166. package/build/esm/base-components/switch/Switch.js +33 -0
  167. package/build/esm/base-components/switch/Switch.js.map +1 -0
  168. package/build/esm/base-components/switch/Switch.module.css +91 -0
  169. package/build/esm/filter-list/FilterListApi.js.map +1 -1
  170. package/build/esm/filter-list/FilterListItemApi.js.map +1 -1
  171. package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js +296 -0
  172. package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js.map +1 -0
  173. package/build/esm/filter-list/__tests__/getFilterKey.test.js +53 -0
  174. package/build/esm/filter-list/__tests__/getFilterKey.test.js.map +1 -0
  175. package/build/esm/filter-list/__tests__/testUtils.js +192 -0
  176. package/build/esm/filter-list/__tests__/testUtils.js.map +1 -0
  177. package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js +128 -0
  178. package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js.map +1 -0
  179. package/build/esm/filter-list/hooks/useDebouncedValue.js +52 -0
  180. package/build/esm/filter-list/hooks/useDebouncedValue.js.map +1 -0
  181. package/build/esm/filter-list/hooks/useFilterListState.js +119 -0
  182. package/build/esm/filter-list/hooks/useFilterListState.js.map +1 -0
  183. package/build/esm/filter-list/hooks/usePropertyAggregation.js +92 -0
  184. package/build/esm/filter-list/hooks/usePropertyAggregation.js.map +1 -0
  185. package/build/esm/filter-list/types/AddFilterMenuTypes.js +2 -0
  186. package/build/esm/filter-list/types/AddFilterMenuTypes.js.map +1 -0
  187. package/build/esm/filter-list/types/CustomRendererTypes.js +2 -0
  188. package/build/esm/filter-list/types/CustomRendererTypes.js.map +1 -0
  189. package/build/esm/filter-list/types/KeywordSearchTypes.js +2 -0
  190. package/build/esm/filter-list/types/KeywordSearchTypes.js.map +1 -0
  191. package/build/esm/filter-list/types/LinkedFilterTypes.js +2 -0
  192. package/build/esm/filter-list/types/LinkedFilterTypes.js.map +1 -0
  193. package/build/esm/filter-list/types/index.js +21 -0
  194. package/build/esm/filter-list/types/index.js.map +1 -0
  195. package/build/esm/filter-list/utils/assertUnreachable.js +25 -0
  196. package/build/esm/filter-list/utils/assertUnreachable.js.map +1 -0
  197. package/build/esm/filter-list/utils/coerceFilterValue.js +33 -0
  198. package/build/esm/filter-list/utils/coerceFilterValue.js.map +1 -0
  199. package/build/esm/filter-list/utils/filterStateToWhereClause.js +337 -0
  200. package/build/esm/filter-list/utils/filterStateToWhereClause.js.map +1 -0
  201. package/build/esm/filter-list/utils/filterValues.js +55 -0
  202. package/build/esm/filter-list/utils/filterValues.js.map +1 -0
  203. package/build/esm/filter-list/utils/getFilterKey.js +34 -0
  204. package/build/esm/filter-list/utils/getFilterKey.js.map +1 -0
  205. package/build/esm/object-table/ColumnConfigDialog.js +259 -0
  206. package/build/esm/object-table/ColumnConfigDialog.js.map +1 -0
  207. package/build/esm/object-table/ColumnConfigDialog.module.css +247 -0
  208. package/build/esm/object-table/LoadingStateTable.js +4 -4
  209. package/build/esm/object-table/LoadingStateTable.js.map +1 -1
  210. package/build/esm/object-table/MultiColumnSortDialog.js +178 -0
  211. package/build/esm/object-table/MultiColumnSortDialog.js.map +1 -0
  212. package/build/esm/object-table/MultiColumnSortDialog.module.css +195 -0
  213. package/build/esm/object-table/NonIdealState.module.css +2 -3
  214. package/build/esm/object-table/ObjectTable.js +43 -13
  215. package/build/esm/object-table/ObjectTable.js.map +1 -1
  216. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  217. package/build/esm/object-table/SortableItemsList.js +35 -0
  218. package/build/esm/object-table/SortableItemsList.js.map +1 -0
  219. package/build/esm/object-table/Table.js +9 -7
  220. package/build/esm/object-table/Table.js.map +1 -1
  221. package/build/esm/object-table/Table.module.css +9 -2
  222. package/build/esm/object-table/TableCell.module.css +11 -0
  223. package/build/esm/object-table/TableHeader.js +93 -6
  224. package/build/esm/object-table/TableHeader.js.map +1 -1
  225. package/build/esm/object-table/TableHeader.module.css +7 -2
  226. package/build/esm/object-table/TableHeaderWithPopover.js +53 -22
  227. package/build/esm/object-table/TableHeaderWithPopover.js.map +1 -1
  228. package/build/esm/object-table/TableHeaderWithPopover.module.css +54 -23
  229. package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js +160 -138
  230. package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js.map +1 -1
  231. package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js +3 -0
  232. package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -1
  233. package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js +27 -82
  234. package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -1
  235. package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js +290 -0
  236. package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js.map +1 -1
  237. package/build/esm/object-table/hooks/useColumnDefs.js +7 -2
  238. package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
  239. package/build/esm/object-table/hooks/useColumnResize.js +45 -0
  240. package/build/esm/object-table/hooks/useColumnResize.js.map +1 -0
  241. package/build/esm/object-table/hooks/useColumnVisibility.js +52 -20
  242. package/build/esm/object-table/hooks/useColumnVisibility.js.map +1 -1
  243. package/build/esm/object-table/hooks/useRowSelection.js +8 -7
  244. package/build/esm/object-table/hooks/useRowSelection.js.map +1 -1
  245. package/build/esm/object-table/hooks/useSelectionColumn.js +15 -6
  246. package/build/esm/object-table/hooks/useSelectionColumn.js.map +1 -1
  247. package/build/esm/object-table/utils/types.js +2 -0
  248. package/build/esm/object-table/utils/types.js.map +1 -0
  249. package/build/esm/public/experimental.js +1 -0
  250. package/build/esm/public/experimental.js.map +1 -1
  251. package/build/types/base-components/action-button/ActionButton.d.ts +5 -0
  252. package/build/types/base-components/action-button/ActionButton.d.ts.map +1 -0
  253. package/build/types/base-components/combobox/Combobox.d.ts +52 -0
  254. package/build/types/base-components/combobox/Combobox.d.ts.map +1 -0
  255. package/build/types/base-components/dialog/Dialog.d.ts +10 -0
  256. package/build/types/base-components/dialog/Dialog.d.ts.map +1 -0
  257. package/build/types/base-components/draggable-list/DraggableList.d.ts +17 -0
  258. package/build/types/base-components/draggable-list/DraggableList.d.ts.map +1 -0
  259. package/build/types/base-components/search-bar/SearchBar.d.ts +11 -0
  260. package/build/types/base-components/search-bar/SearchBar.d.ts.map +1 -0
  261. package/build/types/base-components/select/Select.d.ts +34 -0
  262. package/build/types/base-components/select/Select.d.ts.map +1 -0
  263. package/build/types/base-components/switch/Switch.d.ts +10 -0
  264. package/build/types/base-components/switch/Switch.d.ts.map +1 -0
  265. package/build/types/filter-list/FilterListApi.d.ts +63 -12
  266. package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
  267. package/build/types/filter-list/FilterListItemApi.d.ts +101 -53
  268. package/build/types/filter-list/FilterListItemApi.d.ts.map +1 -1
  269. package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts +1 -0
  270. package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts.map +1 -0
  271. package/build/types/filter-list/__tests__/getFilterKey.test.d.ts +1 -0
  272. package/build/types/filter-list/__tests__/getFilterKey.test.d.ts.map +1 -0
  273. package/build/types/filter-list/__tests__/testUtils.d.ts +59 -0
  274. package/build/types/filter-list/__tests__/testUtils.d.ts.map +1 -0
  275. package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts +1 -0
  276. package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts.map +1 -0
  277. package/build/types/filter-list/hooks/useDebouncedValue.d.ts +11 -0
  278. package/build/types/filter-list/hooks/useDebouncedValue.d.ts.map +1 -0
  279. package/build/types/filter-list/hooks/useFilterListState.d.ts +11 -0
  280. package/build/types/filter-list/hooks/useFilterListState.d.ts.map +1 -0
  281. package/build/types/filter-list/hooks/usePropertyAggregation.d.ts +20 -0
  282. package/build/types/filter-list/hooks/usePropertyAggregation.d.ts.map +1 -0
  283. package/build/types/filter-list/types/AddFilterMenuTypes.d.ts +61 -0
  284. package/build/types/filter-list/types/AddFilterMenuTypes.d.ts.map +1 -0
  285. package/build/types/filter-list/types/CustomRendererTypes.d.ts +76 -0
  286. package/build/types/filter-list/types/CustomRendererTypes.d.ts.map +1 -0
  287. package/build/types/filter-list/types/KeywordSearchTypes.d.ts +56 -0
  288. package/build/types/filter-list/types/KeywordSearchTypes.d.ts.map +1 -0
  289. package/build/types/filter-list/types/LinkedFilterTypes.d.ts +70 -0
  290. package/build/types/filter-list/types/LinkedFilterTypes.d.ts.map +1 -0
  291. package/build/types/filter-list/types/index.d.ts +4 -0
  292. package/build/types/filter-list/types/index.d.ts.map +1 -0
  293. package/build/types/filter-list/utils/assertUnreachable.d.ts +6 -0
  294. package/build/types/filter-list/utils/assertUnreachable.d.ts.map +1 -0
  295. package/build/types/filter-list/utils/coerceFilterValue.d.ts +11 -0
  296. package/build/types/filter-list/utils/coerceFilterValue.d.ts.map +1 -0
  297. package/build/types/filter-list/utils/filterStateToWhereClause.d.ts +16 -0
  298. package/build/types/filter-list/utils/filterStateToWhereClause.d.ts.map +1 -0
  299. package/build/types/filter-list/utils/filterValues.d.ts +5 -0
  300. package/build/types/filter-list/utils/filterValues.d.ts.map +1 -0
  301. package/build/types/filter-list/utils/getFilterKey.d.ts +3 -0
  302. package/build/types/filter-list/utils/getFilterKey.d.ts.map +1 -0
  303. package/build/types/object-table/ColumnConfigDialog.d.ts +18 -0
  304. package/build/types/object-table/ColumnConfigDialog.d.ts.map +1 -0
  305. package/build/types/object-table/LoadingStateTable.d.ts.map +1 -1
  306. package/build/types/object-table/MultiColumnSortDialog.d.ts +15 -0
  307. package/build/types/object-table/MultiColumnSortDialog.d.ts.map +1 -0
  308. package/build/types/object-table/ObjectTable.d.ts +1 -1
  309. package/build/types/object-table/ObjectTable.d.ts.map +1 -1
  310. package/build/types/object-table/ObjectTableApi.d.ts +41 -6
  311. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  312. package/build/types/object-table/SortableItemsList.d.ts +13 -0
  313. package/build/types/object-table/SortableItemsList.d.ts.map +1 -0
  314. package/build/types/object-table/Table.d.ts +12 -1
  315. package/build/types/object-table/Table.d.ts.map +1 -1
  316. package/build/types/object-table/TableHeader.d.ts +3 -1
  317. package/build/types/object-table/TableHeader.d.ts.map +1 -1
  318. package/build/types/object-table/TableHeaderWithPopover.d.ts +30 -6
  319. package/build/types/object-table/TableHeaderWithPopover.d.ts.map +1 -1
  320. package/build/types/object-table/hooks/useColumnResize.d.ts +10 -0
  321. package/build/types/object-table/hooks/useColumnResize.d.ts.map +1 -0
  322. package/build/types/object-table/hooks/useColumnVisibility.d.ts +18 -7
  323. package/build/types/object-table/hooks/useColumnVisibility.d.ts.map +1 -1
  324. package/build/types/object-table/hooks/useRowSelection.d.ts +5 -4
  325. package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
  326. package/build/types/object-table/utils/types.d.ts +5 -0
  327. package/build/types/object-table/utils/types.d.ts.map +1 -0
  328. package/build/types/public/experimental.d.ts +2 -0
  329. package/build/types/public/experimental.d.ts.map +1 -1
  330. package/package.json +16 -8
@@ -28,31 +28,31 @@ export function useRowSelection({
28
28
  // Used for shift-click behavior in "multiple" mode
29
29
  const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState(null);
30
30
  const isControlled = selectedRows !== undefined;
31
- const isSelectionEnabled = selectionMode !== "none";
31
+ const enableRowSelection = selectionMode !== "none";
32
32
 
33
33
  // Row selection state
34
34
  // If controlled mode, return the state from selectedRows prop
35
35
  // If uncontrolled, return the internalRowSelection state
36
36
  const rowSelectionState = useMemo(() => {
37
- if (!isSelectionEnabled) return {};
37
+ if (!enableRowSelection) return {};
38
38
  if (isControlled && selectedRows) {
39
39
  return getRowSelectionState(selectedRows);
40
40
  }
41
41
  return internalRowSelection;
42
- }, [isSelectionEnabled, isControlled, selectedRows, internalRowSelection]);
42
+ }, [enableRowSelection, isControlled, selectedRows, internalRowSelection]);
43
43
  const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;
44
44
  const totalCount = data?.length ?? 0;
45
45
  const isAllSelected = totalCount > 0 && selectedCount === totalCount;
46
46
  const onToggleAll = useCallback(() => {
47
- if (!isSelectionEnabled || !data) return;
47
+ if (!enableRowSelection || !data) return;
48
48
  const newSelectedRows = isAllSelected ? [] : data.map(item => item.$primaryKey);
49
49
  if (!isControlled) {
50
50
  setInternalRowSelection(getRowSelectionState(newSelectedRows));
51
51
  }
52
52
  onRowSelection?.(newSelectedRows);
53
- }, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);
53
+ }, [enableRowSelection, data, isAllSelected, isControlled, onRowSelection]);
54
54
  const onToggleRow = useCallback((rowId, rowIndex, isShiftClick = false) => {
55
- if (!isSelectionEnabled || !data) return;
55
+ if (!enableRowSelection || !data) return;
56
56
  let newSelectedRows = [];
57
57
  if (selectionMode === "single") {
58
58
  newSelectedRows = getSingleSelectionRows({
@@ -89,10 +89,11 @@ export function useRowSelection({
89
89
  setInternalRowSelection(getRowSelectionState(newSelectedRows));
90
90
  }
91
91
  onRowSelection?.(newSelectedRows);
92
- }, [isSelectionEnabled, data, selectionMode, lastSelectedRowIndex, isControlled, rowSelectionState, onRowSelection]);
92
+ }, [enableRowSelection, data, selectionMode, lastSelectedRowIndex, isControlled, rowSelectionState, onRowSelection]);
93
93
  return {
94
94
  rowSelection: rowSelectionState,
95
95
  isAllSelected,
96
+ enableRowSelection,
96
97
  hasSelection: selectedCount > 0,
97
98
  onToggleAll,
98
99
  onToggleRow
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.js","names":["useCallback","useMemo","useState","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","onRowSelection","data","internalRowSelection","setInternalRowSelection","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","isSelectionEnabled","rowSelectionState","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","isAllSelected","onToggleAll","newSelectedRows","map","item","$primaryKey","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","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} from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\nexport interface UseRowSelectionProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: 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, any> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n onRowSelection,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n // The rowSelectionState in uncontrolled mode\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\n\n // Used for shift-click behavior in \"multiple\" mode\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const isSelectionEnabled = selectionMode !== \"none\";\n\n // Row selection state\n // If controlled mode, return the state from selectedRows prop\n // If uncontrolled, return the internalRowSelection state\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!isSelectionEnabled) return {};\n if (isControlled && selectedRows) {\n return getRowSelectionState(selectedRows);\n }\n return internalRowSelection;\n }, [\n isSelectionEnabled,\n isControlled,\n selectedRows,\n internalRowSelection,\n ]);\n\n const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;\n const totalCount = data?.length ?? 0;\n const isAllSelected = totalCount > 0 && selectedCount === totalCount;\n const hasSelection = selectedCount > 0;\n\n const onToggleAll = useCallback(() => {\n if (!isSelectionEnabled || !data) return;\n\n const newSelectedRows: PrimaryKeyType<Q>[] = isAllSelected\n ? []\n : data.map(item => item.$primaryKey);\n\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n }, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!isSelectionEnabled || !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 setLastSelectedRowIndex(rowIndex);\n } else {\n // Multiple selection mode\n\n // When user does shiftClick but lastSelectedRowIndex is null,\n // it is treated as a normal click in multiple selection\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows(\n { rowId, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n }\n setLastSelectedRowIndex(rowIndex);\n }\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n },\n [\n isSelectionEnabled,\n data,\n selectionMode,\n lastSelectedRowIndex,\n isControlled,\n rowSelectionState,\n onRowSelection,\n ],\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { rowId, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n // Toggle row selection in single selection mode\n const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];\n return newSelectedRows;\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { lastSelectedRowIndex, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n // This function is only called if lastSelectedRowIndex is not null\n // This condition is added for typechecks only\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 // Add all rows in range to selectedRows if not yet selected\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 getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = 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 // Handles single row toggle in multiple selection mode\n const newSelectedRows = currentlySelected.includes(primaryKey)\n ? currentlySelected.filter(i => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n return newSelectedRows;\n}\n\n/**\n * Builds a range of rows from startIndex to endIndex\n */\nfunction getRowsInRange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>,\n startIndex: number,\n endIndex: number,\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> = [];\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\n/**\n * Converts an array of primary keys to a RowSelectionState object\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\n/**\n * Converts from a RowSelectionState object back to an array of primary keys\n */\nfunction getSelectedPrimaryKeys<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, 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;;AAQA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,sBAAsB;AAwBvE,OAAO,SAASC,eAAeA,CAG7B;EACAC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,cAAc;EACdC;AAC6B,CAAC,EAAyB;EACvD;EACA,MAAM,CAACC,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGT,QAAQ,CAE9D,CAAC,CAAC,CAAC;;EAEL;EACA,MAAM,CAACU,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGX,QAAQ,CAE9D,IAAI,CAAC;EAEP,MAAMY,YAAY,GAAGP,YAAY,KAAKQ,SAAS;EAC/C,MAAMC,kBAAkB,GAAGV,aAAa,KAAK,MAAM;;EAEnD;EACA;EACA;EACA,MAAMW,iBAAoC,GAAGhB,OAAO,CAAC,MAAM;IACzD,IAAI,CAACe,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAClC,IAAIF,YAAY,IAAIP,YAAY,EAAE;MAChC,OAAOW,oBAAoB,CAACX,YAAY,CAAC;IAC3C;IACA,OAAOG,oBAAoB;EAC7B,CAAC,EAAE,CACDM,kBAAkB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yC,CAAC,CAAC;IACpB,IAAIpB,IAAI,EAAE;MACR4B,IAAI,CAACT,IAAI,CAACnB,IAAI,CAAC;IACjB;EACF;EAEA,OAAO4B,IAAI;AACb;;AAEA;AACA;AACA;AACA,SAASxC,oBAAoBA,CAC3ByC,WAAgC,EACb;EACnB,OAAOA,WAAW,CAACC,MAAM,CACvB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IACnBoB,GAAG,CAACzD,sBAAsB,CAACqC,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCrD,IAA8D,EACzC;EACrB,OAAOA,IAAI,CACRa,MAAM,CAACQ,IAAI,IAAIgC,cAAc,CAAC3D,QAAQ,CAAC2B,IAAI,CAAC,CAAC,CAAC,CAC9CD,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,WAAW,CAAC;AAClC","ignoreList":[]}
1
+ {"version":3,"file":"useRowSelection.js","names":["useCallback","useMemo","useState","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","onRowSelection","data","internalRowSelection","setInternalRowSelection","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","enableRowSelection","rowSelectionState","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","isAllSelected","onToggleAll","newSelectedRows","map","item","$primaryKey","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","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, useMemo, useState } from \"react\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\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 onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => 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 onRowSelection,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n // The rowSelectionState in uncontrolled mode\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\n\n // Used for shift-click behavior in \"multiple\" mode\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const enableRowSelection = selectionMode !== \"none\";\n\n // Row selection state\n // If controlled mode, return the state from selectedRows prop\n // If uncontrolled, return the internalRowSelection state\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!enableRowSelection) return {};\n if (isControlled && selectedRows) {\n return getRowSelectionState(selectedRows);\n }\n return internalRowSelection;\n }, [\n enableRowSelection,\n isControlled,\n selectedRows,\n internalRowSelection,\n ]);\n\n const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;\n const totalCount = data?.length ?? 0;\n const isAllSelected = totalCount > 0 && selectedCount === totalCount;\n const hasSelection = selectedCount > 0;\n\n const onToggleAll = useCallback(() => {\n if (!enableRowSelection || !data) return;\n\n const newSelectedRows: PrimaryKeyType<Q>[] = isAllSelected\n ? []\n : data.map(item => item.$primaryKey);\n\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n }, [enableRowSelection, data, isAllSelected, isControlled, onRowSelection]);\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 setLastSelectedRowIndex(rowIndex);\n } else {\n // Multiple selection mode\n\n // When user does shiftClick but lastSelectedRowIndex is null,\n // it is treated as a normal click in multiple selection\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows(\n { rowId, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n }\n setLastSelectedRowIndex(rowIndex);\n }\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n },\n [\n enableRowSelection,\n data,\n selectionMode,\n lastSelectedRowIndex,\n isControlled,\n rowSelectionState,\n onRowSelection,\n ],\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n enableRowSelection,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { rowId, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n // Toggle row selection in single selection mode\n const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];\n return newSelectedRows;\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 // This function is only called if lastSelectedRowIndex is not null\n // This condition is added for typechecks only\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 // Add all rows in range to selectedRows if not yet selected\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 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 // Handles single row toggle in multiple selection mode\n const newSelectedRows = currentlySelected.includes(primaryKey)\n ? currentlySelected.filter(i => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n return newSelectedRows;\n}\n\n/**\n * Builds a range of rows from startIndex to endIndex\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\n/**\n * Converts an array of primary keys to a RowSelectionState object\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\n/**\n * Converts from a RowSelectionState object back to an array of primary keys\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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AEA;AACA;AACA;AACA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCrD,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRa,MAAM,CAACQ,IAAI,IAAIgC,cAAc,CAAC3D,QAAQ,CAAC2B,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
- import React, { useMemo } from "react";
17
+ import React, { useMemo, useRef } from "react";
18
18
  import { SelectionCell, SelectionHeaderCell } from "../SelectionCells.js";
19
19
  import { SELECTION_COLUMN_ID } from "../utils/constants.js";
20
20
  export const useSelectionColumn = ({
@@ -24,20 +24,29 @@ export const useSelectionColumn = ({
24
24
  onToggleAll,
25
25
  onToggleRow
26
26
  }) => {
27
+ // TODO: Replace with useLatestRef
28
+ const isAllSelectedRef = useRef(isAllSelected);
29
+ isAllSelectedRef.current = isAllSelected;
30
+ const hasSelectionRef = useRef(hasSelection);
31
+ hasSelectionRef.current = hasSelection;
32
+ const onToggleAllRef = useRef(onToggleAll);
33
+ onToggleAllRef.current = onToggleAll;
34
+ const onToggleRowRef = useRef(onToggleRow);
35
+ onToggleRowRef.current = onToggleRow;
27
36
  const selectionColumn = useMemo(() => {
28
37
  if (selectionMode === "none") return null;
29
38
  return {
30
39
  id: SELECTION_COLUMN_ID,
31
40
  header: () => selectionMode === "multiple" ? /*#__PURE__*/React.createElement(SelectionHeaderCell, {
32
- isAllSelected: isAllSelected,
33
- hasSelection: hasSelection,
34
- onToggleAll: onToggleAll
41
+ isAllSelected: isAllSelectedRef.current,
42
+ hasSelection: hasSelectionRef.current,
43
+ onToggleAll: onToggleAllRef.current
35
44
  }) : null,
36
45
  cell: ({
37
46
  row
38
47
  }) => /*#__PURE__*/React.createElement(SelectionCell, {
39
48
  row: row,
40
- onToggleRow: onToggleRow
49
+ onToggleRow: onToggleRowRef.current
41
50
  }),
42
51
  size: 50,
43
52
  minSize: 50,
@@ -46,7 +55,7 @@ export const useSelectionColumn = ({
46
55
  enableResizing: false,
47
56
  enablePinning: false
48
57
  };
49
- }, [selectionMode, isAllSelected, hasSelection, onToggleAll, onToggleRow]);
58
+ }, [selectionMode]);
50
59
  return selectionColumn;
51
60
  };
52
61
  //# sourceMappingURL=useSelectionColumn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectionColumn.js","names":["React","useMemo","SelectionCell","SelectionHeaderCell","SELECTION_COLUMN_ID","useSelectionColumn","selectionMode","isAllSelected","hasSelection","onToggleAll","onToggleRow","selectionColumn","id","header","createElement","cell","row","size","minSize","maxSize","enableSorting","enableResizing","enablePinning"],"sources":["useSelectionColumn.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { ColumnDef } from \"@tanstack/react-table\";\nimport React, { useMemo } from \"react\";\nimport { SelectionCell, SelectionHeaderCell } from \"../SelectionCells.js\";\nimport { SELECTION_COLUMN_ID } from \"../utils/constants.js\";\n\ninterface UseSelectionColumnProps {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (id: string, rowIndex: number, isShiftClick: boolean) => void;\n}\n\nexport const useSelectionColumn = <\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n>({\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n}: UseSelectionColumnProps):\n | ColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n | null =>\n{\n const selectionColumn = useMemo(() => {\n if (selectionMode === \"none\") return null;\n\n const colDef: ColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n id: SELECTION_COLUMN_ID,\n header: () => (\n selectionMode === \"multiple\"\n ? (\n <SelectionHeaderCell\n isAllSelected={isAllSelected}\n hasSelection={hasSelection}\n onToggleAll={onToggleAll}\n />\n )\n : null\n ),\n cell: ({ row }: { row: any }) => (\n <SelectionCell\n row={row}\n onToggleRow={onToggleRow}\n />\n ),\n size: 50,\n minSize: 50,\n maxSize: 50,\n enableSorting: false,\n enableResizing: false,\n enablePinning: false,\n };\n\n return colDef;\n }, [\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n ]);\n\n return selectionColumn;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,aAAa,EAAEC,mBAAmB,QAAQ,sBAAsB;AACzE,SAASC,mBAAmB,QAAQ,uBAAuB;AAU3D,OAAO,MAAMC,kBAAkB,GAAGA,CAMhC;EACAC,aAAa;EACbC,aAAa;EACbC,YAAY;EACZC,WAAW;EACXC;AACuB,CAAC,KAK1B;EACE,MAAMC,eAAe,GAAGV,OAAO,CAAC,MAAM;IACpC,IAAIK,aAAa,KAAK,MAAM,EAAE,OAAO,IAAI;IA+BzC,OA3BI;MACFM,EAAE,EAAER,mBAAmB;MACvBS,MAAM,EAAEA,CAAA,KACNP,aAAa,KAAK,UAAU,gBAExBN,KAAA,CAAAc,aAAA,CAACX,mBAAmB;QAClBI,aAAa,EAAEA,aAAc;QAC7BC,YAAY,EAAEA,YAAa;QAC3BC,WAAW,EAAEA;MAAY,CAC1B,CAAC,GAEF,IACL;MACDM,IAAI,EAAEA,CAAC;QAAEC;MAAkB,CAAC,kBAC1BhB,KAAA,CAAAc,aAAA,CAACZ,aAAa;QACZc,GAAG,EAAEA,GAAI;QACTN,WAAW,EAAEA;MAAY,CAC1B,CACF;MACDO,IAAI,EAAE,EAAE;MACRC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,aAAa,EAAE,KAAK;MACpBC,cAAc,EAAE,KAAK;MACrBC,aAAa,EAAE;IACjB,CAAC;EAGH,CAAC,EAAE,CACDhB,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,WAAW,CACZ,CAAC;EAEF,OAAOC,eAAe;AACxB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useSelectionColumn.js","names":["React","useMemo","useRef","SelectionCell","SelectionHeaderCell","SELECTION_COLUMN_ID","useSelectionColumn","selectionMode","isAllSelected","hasSelection","onToggleAll","onToggleRow","isAllSelectedRef","current","hasSelectionRef","onToggleAllRef","onToggleRowRef","selectionColumn","id","header","createElement","cell","row","size","minSize","maxSize","enableSorting","enableResizing","enablePinning"],"sources":["useSelectionColumn.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { ColumnDef } from \"@tanstack/react-table\";\nimport React, { useMemo, useRef } from \"react\";\nimport { SelectionCell, SelectionHeaderCell } from \"../SelectionCells.js\";\nimport { SELECTION_COLUMN_ID } from \"../utils/constants.js\";\n\ninterface UseSelectionColumnProps {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (id: string, rowIndex: number, isShiftClick: boolean) => void;\n}\n\nexport const useSelectionColumn = <\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n>({\n selectionMode,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n}: UseSelectionColumnProps):\n | ColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n >\n | null =>\n{\n // TODO: Replace with useLatestRef\n const isAllSelectedRef = useRef(isAllSelected);\n isAllSelectedRef.current = isAllSelected;\n\n const hasSelectionRef = useRef(hasSelection);\n hasSelectionRef.current = hasSelection;\n\n const onToggleAllRef = useRef(onToggleAll);\n onToggleAllRef.current = onToggleAll;\n\n const onToggleRowRef = useRef(onToggleRow);\n onToggleRowRef.current = onToggleRow;\n\n const selectionColumn = useMemo(() => {\n if (selectionMode === \"none\") return null;\n\n const colDef: ColumnDef<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = {\n id: SELECTION_COLUMN_ID,\n header: () => (\n selectionMode === \"multiple\"\n ? (\n <SelectionHeaderCell\n isAllSelected={isAllSelectedRef.current}\n hasSelection={hasSelectionRef.current}\n onToggleAll={onToggleAllRef.current}\n />\n )\n : null\n ),\n cell: ({ row }: { row: any }) => (\n <SelectionCell\n row={row}\n onToggleRow={onToggleRowRef.current}\n />\n ),\n size: 50,\n minSize: 50,\n maxSize: 50,\n enableSorting: false,\n enableResizing: false,\n enablePinning: false,\n };\n\n return colDef;\n }, [\n selectionMode,\n ]);\n\n return selectionColumn;\n};\n"],"mappings":"AAAA;AACA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MAAQ,CACrC,CACF;MACDU,IAAI,EAAE,EAAE;MACRC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,aAAa,EAAE,KAAK;MACpBC,cAAc,EAAE,KAAK;MACrBC,aAAa,EAAE;IACjB,CAAC;EAGH,CAAC,EAAE,CACDrB,aAAa,CACd,CAAC;EAEF,OAAOU,eAAe;AACxB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["types.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\nexport interface ColumnOption {\n id: string;\n name: string;\n canSort: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -20,4 +20,5 @@ export { ObjectTable } from "../object-table/ObjectTable.js";
20
20
  // BaseTable that does not handle data fetching
21
21
 
22
22
  export { BaseTable } from "../object-table/Table.js";
23
+ export { ColumnConfigDialog } from "../object-table/ColumnConfigDialog.js";
23
24
  //# sourceMappingURL=experimental.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["ObjectTable","BaseTable"],"sources":["experimental.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\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,SAASA,WAAW,QAAQ,gCAAgC;;AAO5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["ObjectTable","BaseTable","ColumnConfigDialog"],"sources":["experimental.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\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n\nexport { ColumnConfigDialog } from \"../object-table/ColumnConfigDialog.js\";\nexport type {\n ColumnConfigDialogProps,\n ColumnConfigOptions,\n} from \"../object-table/ColumnConfigDialog.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,SAASA,WAAW,QAAQ,gCAAgC;;AAO5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC","ignoreList":[]}