@osdk/react-components 0.1.0 → 0.2.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -19
- package/README.md +56 -23
- package/build/browser/base-components/action-button/ActionButton.js +31 -0
- package/build/browser/base-components/action-button/ActionButton.js.map +1 -0
- package/build/browser/base-components/action-button/ActionButton.module.css +70 -0
- package/build/browser/base-components/action-button/ActionButton.module.css.js +8 -0
- package/build/browser/base-components/checkbox/Checkbox.js +27 -32
- package/build/browser/base-components/checkbox/Checkbox.module.css +79 -0
- package/build/browser/base-components/checkbox/Checkbox.module.css.js +7 -0
- package/build/browser/base-components/combobox/Combobox.js +124 -0
- package/build/browser/base-components/combobox/Combobox.js.map +1 -0
- package/build/browser/base-components/combobox/Combobox.module.css +177 -0
- package/build/browser/base-components/combobox/Combobox.module.css.js +16 -0
- package/build/browser/base-components/dialog/Dialog.js +52 -0
- package/build/browser/base-components/dialog/Dialog.js.map +1 -0
- package/build/browser/base-components/dialog/Dialog.module.css +101 -0
- package/build/browser/base-components/dialog/Dialog.module.css.js +13 -0
- package/build/browser/base-components/draggable-list/DraggableList.js +155 -0
- package/build/browser/base-components/draggable-list/DraggableList.js.map +1 -0
- package/build/browser/base-components/draggable-list/DraggableList.module.css +108 -0
- package/build/browser/base-components/draggable-list/DraggableList.module.css.js +11 -0
- package/build/browser/base-components/search-bar/SearchBar.js +44 -0
- package/build/browser/base-components/search-bar/SearchBar.js.map +1 -0
- package/build/browser/base-components/search-bar/SearchBar.module.css +53 -0
- package/build/browser/base-components/search-bar/SearchBar.module.css.js +8 -0
- package/build/browser/base-components/select/Select.js +89 -0
- package/build/browser/base-components/select/Select.js.map +1 -0
- package/build/browser/base-components/select/Select.module.css +138 -0
- package/build/browser/base-components/select/Select.module.css.js +11 -0
- package/build/browser/base-components/switch/Switch.js +33 -0
- package/build/browser/base-components/switch/Switch.js.map +1 -0
- package/build/browser/base-components/switch/Switch.module.css +91 -0
- package/build/browser/base-components/switch/Switch.module.css.js +7 -0
- package/build/browser/filter-list/FilterListApi.js.map +1 -1
- package/build/browser/filter-list/FilterListItemApi.js.map +1 -1
- package/build/browser/filter-list/__tests__/LinkedPropertyInput.test.js +202 -0
- package/build/browser/filter-list/__tests__/LinkedPropertyInput.test.js.map +1 -0
- package/build/browser/filter-list/__tests__/dateUtils.test.js +55 -0
- package/build/browser/filter-list/__tests__/dateUtils.test.js.map +1 -0
- package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js +296 -0
- package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js.map +1 -0
- package/build/browser/filter-list/__tests__/getFilterKey.test.js +53 -0
- package/build/browser/filter-list/__tests__/getFilterKey.test.js.map +1 -0
- package/build/browser/filter-list/__tests__/testUtils.js +203 -0
- package/build/browser/filter-list/__tests__/testUtils.js.map +1 -0
- package/build/browser/filter-list/base/FilterInput.js +542 -0
- package/build/browser/filter-list/base/FilterInput.js.map +1 -0
- package/build/browser/filter-list/base/FilterList.js +77 -0
- package/build/browser/filter-list/base/FilterList.js.map +1 -0
- package/build/browser/filter-list/base/FilterList.module.css +67 -0
- package/build/browser/filter-list/base/FilterList.module.css.js +8 -0
- package/build/browser/filter-list/base/FilterListContent.js +57 -0
- package/build/browser/filter-list/base/FilterListContent.js.map +1 -0
- package/build/browser/filter-list/base/FilterListContent.module.css +27 -0
- package/build/browser/filter-list/base/FilterListContent.module.css.js +7 -0
- package/build/browser/filter-list/base/FilterListHeader.js +58 -0
- package/build/browser/filter-list/base/FilterListHeader.js.map +1 -0
- package/build/browser/filter-list/base/FilterListHeader.module.css +127 -0
- package/build/browser/filter-list/base/FilterListHeader.module.css.js +13 -0
- package/build/browser/filter-list/base/FilterListItem.js +75 -0
- package/build/browser/filter-list/base/FilterListItem.js.map +1 -0
- package/build/browser/filter-list/base/FilterListItem.module.css +38 -0
- package/build/browser/filter-list/base/FilterListItem.module.css.js +9 -0
- package/build/browser/filter-list/base/index.js +22 -0
- package/build/browser/filter-list/base/index.js.map +1 -0
- package/build/browser/filter-list/base/inputs/CheckboxListInput.js +75 -0
- package/build/browser/filter-list/base/inputs/CheckboxListInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/CheckboxListInput.module.css +42 -0
- package/build/browser/filter-list/base/inputs/CheckboxListInput.module.css.js +9 -0
- package/build/browser/filter-list/base/inputs/ContainsTextInput.js +85 -0
- package/build/browser/filter-list/base/inputs/ContainsTextInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/ContainsTextInput.module.css +91 -0
- package/build/browser/filter-list/base/inputs/ContainsTextInput.module.css.js +10 -0
- package/build/browser/filter-list/base/inputs/DateRangeInput.js +37 -0
- package/build/browser/filter-list/base/inputs/DateRangeInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/LinkedPropertyInput.js +237 -0
- package/build/browser/filter-list/base/inputs/LinkedPropertyInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/LinkedPropertyInput.module.css +20 -0
- package/build/browser/filter-list/base/inputs/LinkedPropertyInput.module.css.js +6 -0
- package/build/browser/filter-list/base/inputs/ListogramInput.js +98 -0
- package/build/browser/filter-list/base/inputs/ListogramInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/ListogramInput.module.css +88 -0
- package/build/browser/filter-list/base/inputs/ListogramInput.module.css.js +12 -0
- package/build/browser/filter-list/base/inputs/MultiDateInput.js +82 -0
- package/build/browser/filter-list/base/inputs/MultiDateInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/MultiDateInput.module.css +54 -0
- package/build/browser/filter-list/base/inputs/MultiDateInput.module.css.js +9 -0
- package/build/browser/filter-list/base/inputs/MultiSelectInput.js +100 -0
- package/build/browser/filter-list/base/inputs/MultiSelectInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/MultiSelectInput.module.css +35 -0
- package/build/browser/filter-list/base/inputs/MultiSelectInput.module.css.js +9 -0
- package/build/browser/filter-list/base/inputs/NullValueWrapper.js +76 -0
- package/build/browser/filter-list/base/inputs/NullValueWrapper.js.map +1 -0
- package/build/browser/filter-list/base/inputs/NullValueWrapper.module.css +49 -0
- package/build/browser/filter-list/base/inputs/NullValueWrapper.module.css.js +10 -0
- package/build/browser/filter-list/base/inputs/NumberRangeInput.js +48 -0
- package/build/browser/filter-list/base/inputs/NumberRangeInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/RangeInput.js +187 -0
- package/build/browser/filter-list/base/inputs/RangeInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/RangeInput.module.css +81 -0
- package/build/browser/filter-list/base/inputs/RangeInput.module.css.js +13 -0
- package/build/browser/filter-list/base/inputs/SingleDateInput.js +61 -0
- package/build/browser/filter-list/base/inputs/SingleDateInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/SingleDateInput.module.css +63 -0
- package/build/browser/filter-list/base/inputs/SingleDateInput.module.css.js +9 -0
- package/build/browser/filter-list/base/inputs/SingleSelectInput.js +95 -0
- package/build/browser/filter-list/base/inputs/SingleSelectInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/SingleSelectInput.module.css +55 -0
- package/build/browser/filter-list/base/inputs/SingleSelectInput.module.css.js +8 -0
- package/build/browser/filter-list/base/inputs/TextTagsInput.js +141 -0
- package/build/browser/filter-list/base/inputs/TextTagsInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/TextTagsInput.module.css +25 -0
- package/build/browser/filter-list/base/inputs/TextTagsInput.module.css.js +7 -0
- package/build/browser/filter-list/base/inputs/TimelineInput.js +74 -0
- package/build/browser/filter-list/base/inputs/TimelineInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/TimelineInput.module.css +73 -0
- package/build/browser/filter-list/base/inputs/TimelineInput.module.css.js +10 -0
- package/build/browser/filter-list/base/inputs/ToggleInput.js +43 -0
- package/build/browser/filter-list/base/inputs/ToggleInput.js.map +1 -0
- package/build/browser/filter-list/base/inputs/ToggleInput.module.css +34 -0
- package/build/browser/filter-list/base/inputs/ToggleInput.module.css.js +8 -0
- package/build/browser/filter-list/base/inputs/createHistogramBuckets.js +53 -0
- package/build/browser/filter-list/base/inputs/createHistogramBuckets.js.map +1 -0
- package/build/browser/filter-list/base/inputs/dateUtils.js +57 -0
- package/build/browser/filter-list/base/inputs/dateUtils.js.map +1 -0
- package/build/browser/filter-list/base/inputs/index.js +25 -0
- package/build/browser/filter-list/base/inputs/index.js.map +1 -0
- package/build/browser/filter-list/base/inputs/shared.module.css +79 -0
- package/build/browser/filter-list/base/inputs/shared.module.css.js +11 -0
- package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js +128 -0
- package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js.map +1 -0
- package/build/browser/filter-list/hooks/useFilterListState.js +119 -0
- package/build/browser/filter-list/hooks/useFilterListState.js.map +1 -0
- package/build/browser/filter-list/hooks/usePropertyAggregation.js +92 -0
- package/build/browser/filter-list/hooks/usePropertyAggregation.js.map +1 -0
- package/build/browser/filter-list/types/AddFilterMenuTypes.js +2 -0
- package/build/browser/filter-list/types/AddFilterMenuTypes.js.map +1 -0
- package/build/browser/filter-list/types/CustomRendererTypes.js +2 -0
- package/build/browser/filter-list/types/CustomRendererTypes.js.map +1 -0
- package/build/browser/filter-list/types/FilterPanelTypes.js +2 -0
- package/build/browser/filter-list/types/FilterPanelTypes.js.map +1 -0
- package/build/browser/filter-list/types/KeywordSearchTypes.js +2 -0
- package/build/browser/filter-list/types/KeywordSearchTypes.js.map +1 -0
- package/build/browser/filter-list/types/LinkedFilterTypes.js +2 -0
- package/build/browser/filter-list/types/LinkedFilterTypes.js.map +1 -0
- package/build/browser/filter-list/types/index.js +22 -0
- package/build/browser/filter-list/types/index.js.map +1 -0
- package/build/browser/filter-list/utils/aggregationHelpers.js +44 -0
- package/build/browser/filter-list/utils/aggregationHelpers.js.map +1 -0
- package/build/browser/filter-list/utils/assertUnreachable.js +25 -0
- package/build/browser/filter-list/utils/assertUnreachable.js.map +1 -0
- package/build/browser/filter-list/utils/coerceFilterValue.js +33 -0
- package/build/browser/filter-list/utils/coerceFilterValue.js.map +1 -0
- package/build/browser/filter-list/utils/filterStateToWhereClause.js +337 -0
- package/build/browser/filter-list/utils/filterStateToWhereClause.js.map +1 -0
- package/build/browser/filter-list/utils/filterValues.js +55 -0
- package/build/browser/filter-list/utils/filterValues.js.map +1 -0
- package/build/browser/filter-list/utils/getFilterKey.js +34 -0
- package/build/browser/filter-list/utils/getFilterKey.js.map +1 -0
- package/build/browser/object-table/CellContextMenu.js +23 -20
- package/build/browser/object-table/CellContextMenu.module.css +20 -0
- package/build/browser/object-table/CellContextMenu.module.css.js +6 -0
- package/build/browser/object-table/ColumnConfigDialog.js +259 -0
- package/build/browser/object-table/ColumnConfigDialog.js.map +1 -0
- package/build/browser/object-table/ColumnConfigDialog.module.css +247 -0
- package/build/browser/object-table/ColumnConfigDialog.module.css.js +29 -0
- package/build/browser/object-table/DefaultCellRenderer.js +43 -0
- package/build/browser/object-table/DefaultCellRenderer.js.map +1 -0
- package/build/browser/object-table/EditableCell.js +91 -0
- package/build/browser/object-table/EditableCell.js.map +1 -0
- package/build/browser/object-table/EditableCell.module.css +3 -0
- package/build/browser/object-table/EditableCell.module.css.js +6 -0
- package/build/browser/object-table/LoadingCell.js +24 -29
- package/build/browser/object-table/LoadingCell.module.css +48 -0
- package/build/browser/object-table/LoadingCell.module.css.js +8 -0
- package/build/browser/object-table/LoadingRow.js +24 -50
- package/build/browser/object-table/LoadingStateTable.js +49 -343
- package/build/browser/object-table/LoadingStateTable.js.map +1 -1
- package/build/browser/object-table/MultiColumnSortDialog.js +178 -0
- package/build/browser/object-table/MultiColumnSortDialog.js.map +1 -0
- package/build/browser/object-table/MultiColumnSortDialog.module.css +195 -0
- package/build/browser/object-table/MultiColumnSortDialog.module.css.js +22 -0
- package/build/browser/object-table/NonIdealState.js +23 -20
- package/build/browser/object-table/NonIdealState.module.css +27 -0
- package/build/browser/object-table/NonIdealState.module.css.js +7 -0
- package/build/browser/object-table/ObjectTable.js +74 -15
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/SelectionCells.js +15 -4
- package/build/browser/object-table/SelectionCells.js.map +1 -1
- package/build/browser/object-table/SortableItemsList.js +35 -0
- package/build/browser/object-table/SortableItemsList.js.map +1 -0
- package/build/browser/object-table/Table.js +70 -935
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/Table.module.css +45 -0
- package/build/browser/object-table/Table.module.css.js +8 -0
- package/build/browser/object-table/TableBody.js +36 -260
- package/build/browser/object-table/TableBody.module.css +22 -0
- package/build/browser/object-table/TableBody.module.css.js +6 -0
- package/build/browser/object-table/TableCell.js +31 -111
- package/build/browser/object-table/TableCell.module.css +83 -0
- package/build/browser/object-table/TableCell.module.css.js +8 -0
- package/build/browser/object-table/TableHeader.js +126 -216
- package/build/browser/object-table/TableHeader.js.map +1 -1
- package/build/browser/object-table/TableHeader.module.css +108 -0
- package/build/browser/object-table/TableHeader.module.css.js +10 -0
- package/build/browser/object-table/TableHeaderContent.js +21 -18
- package/build/browser/object-table/TableHeaderContent.module.css +30 -0
- package/build/browser/object-table/TableHeaderContent.module.css.js +6 -0
- package/build/browser/object-table/TableHeaderWithPopover.js +110 -93
- package/build/browser/object-table/TableHeaderWithPopover.js.map +1 -1
- package/build/browser/object-table/TableHeaderWithPopover.module.css +141 -0
- package/build/browser/object-table/TableHeaderWithPopover.module.css.js +17 -0
- package/build/browser/object-table/TableRow.js +26 -144
- package/build/browser/object-table/TableRow.module.css +62 -0
- package/build/browser/object-table/TableRow.module.css.js +6 -0
- package/build/browser/object-table/__tests__/useEditableTable.test.js +197 -0
- package/build/browser/object-table/__tests__/useEditableTable.test.js.map +1 -0
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js +14 -2
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js.map +1 -1
- package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js +160 -138
- package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js.map +1 -1
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js +113 -25
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js +48 -0
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -1
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js +27 -82
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -1
- package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js +290 -0
- package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js.map +1 -1
- package/build/browser/object-table/hooks/useColumnDefs.js +16 -3
- package/build/browser/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/browser/object-table/hooks/useColumnResize.js +45 -0
- package/build/browser/object-table/hooks/useColumnResize.js.map +1 -0
- package/build/browser/object-table/hooks/useColumnVisibility.js +52 -20
- package/build/browser/object-table/hooks/useColumnVisibility.js.map +1 -1
- package/build/browser/object-table/hooks/useEditableTable.js +57 -0
- package/build/browser/object-table/hooks/useEditableTable.js.map +1 -0
- package/build/browser/object-table/hooks/useObjectTableData.js +42 -7
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/object-table/hooks/useRowSelection.js +31 -10
- package/build/browser/object-table/hooks/useRowSelection.js.map +1 -1
- package/build/browser/object-table/hooks/useSelectionColumn.js +15 -6
- package/build/browser/object-table/hooks/useSelectionColumn.js.map +1 -1
- package/build/browser/object-table/utils/getCellId.js +27 -0
- package/build/browser/object-table/utils/getCellId.js.map +1 -0
- package/build/browser/object-table/utils/types.js +2 -0
- package/build/browser/object-table/utils/types.js.map +1 -0
- package/build/browser/public/experimental.js +2 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/shared/ErrorBoundary.js +62 -0
- package/build/browser/shared/ErrorBoundary.js.map +1 -0
- package/build/browser/shared/ErrorBoundary.module.css +55 -0
- package/build/browser/shared/ErrorBoundary.module.css.js +8 -0
- package/build/browser/styles.css +3073 -0
- package/build/cjs/public/experimental.cjs +4026 -240
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +1834 -154
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +453 -50
- package/build/esm/base-components/action-button/ActionButton.js +31 -0
- package/build/esm/base-components/action-button/ActionButton.js.map +1 -0
- package/build/esm/base-components/action-button/ActionButton.module.css +70 -0
- package/build/esm/base-components/checkbox/Checkbox.module.css +1 -1
- package/build/esm/base-components/combobox/Combobox.js +124 -0
- package/build/esm/base-components/combobox/Combobox.js.map +1 -0
- package/build/esm/base-components/combobox/Combobox.module.css +177 -0
- package/build/esm/base-components/dialog/Dialog.js +52 -0
- package/build/esm/base-components/dialog/Dialog.js.map +1 -0
- package/build/esm/base-components/dialog/Dialog.module.css +101 -0
- package/build/esm/base-components/draggable-list/DraggableList.js +155 -0
- package/build/esm/base-components/draggable-list/DraggableList.js.map +1 -0
- package/build/esm/base-components/draggable-list/DraggableList.module.css +108 -0
- package/build/esm/base-components/search-bar/SearchBar.js +44 -0
- package/build/esm/base-components/search-bar/SearchBar.js.map +1 -0
- package/build/esm/base-components/search-bar/SearchBar.module.css +53 -0
- package/build/esm/base-components/select/Select.js +89 -0
- package/build/esm/base-components/select/Select.js.map +1 -0
- package/build/esm/base-components/select/Select.module.css +138 -0
- package/build/esm/base-components/switch/Switch.js +33 -0
- package/build/esm/base-components/switch/Switch.js.map +1 -0
- package/build/esm/base-components/switch/Switch.module.css +91 -0
- package/build/esm/filter-list/FilterListApi.js.map +1 -1
- package/build/esm/filter-list/FilterListItemApi.js.map +1 -1
- package/build/esm/filter-list/__tests__/LinkedPropertyInput.test.js +202 -0
- package/build/esm/filter-list/__tests__/LinkedPropertyInput.test.js.map +1 -0
- package/build/esm/filter-list/__tests__/dateUtils.test.js +55 -0
- package/build/esm/filter-list/__tests__/dateUtils.test.js.map +1 -0
- package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js +296 -0
- package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js.map +1 -0
- package/build/esm/filter-list/__tests__/getFilterKey.test.js +53 -0
- package/build/esm/filter-list/__tests__/getFilterKey.test.js.map +1 -0
- package/build/esm/filter-list/__tests__/testUtils.js +203 -0
- package/build/esm/filter-list/__tests__/testUtils.js.map +1 -0
- package/build/esm/filter-list/base/FilterInput.js +542 -0
- package/build/esm/filter-list/base/FilterInput.js.map +1 -0
- package/build/esm/filter-list/base/FilterList.js +77 -0
- package/build/esm/filter-list/base/FilterList.js.map +1 -0
- package/build/esm/filter-list/base/FilterList.module.css +67 -0
- package/build/esm/filter-list/base/FilterListContent.js +57 -0
- package/build/esm/filter-list/base/FilterListContent.js.map +1 -0
- package/build/esm/filter-list/base/FilterListContent.module.css +27 -0
- package/build/esm/filter-list/base/FilterListHeader.js +58 -0
- package/build/esm/filter-list/base/FilterListHeader.js.map +1 -0
- package/build/esm/filter-list/base/FilterListHeader.module.css +127 -0
- package/build/esm/filter-list/base/FilterListItem.js +75 -0
- package/build/esm/filter-list/base/FilterListItem.js.map +1 -0
- package/build/esm/filter-list/base/FilterListItem.module.css +38 -0
- package/build/esm/filter-list/base/index.js +22 -0
- package/build/esm/filter-list/base/index.js.map +1 -0
- package/build/esm/filter-list/base/inputs/CheckboxListInput.js +75 -0
- package/build/esm/filter-list/base/inputs/CheckboxListInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/CheckboxListInput.module.css +42 -0
- package/build/esm/filter-list/base/inputs/ContainsTextInput.js +85 -0
- package/build/esm/filter-list/base/inputs/ContainsTextInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/ContainsTextInput.module.css +91 -0
- package/build/esm/filter-list/base/inputs/DateRangeInput.js +37 -0
- package/build/esm/filter-list/base/inputs/DateRangeInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/LinkedPropertyInput.js +237 -0
- package/build/esm/filter-list/base/inputs/LinkedPropertyInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/LinkedPropertyInput.module.css +20 -0
- package/build/esm/filter-list/base/inputs/ListogramInput.js +98 -0
- package/build/esm/filter-list/base/inputs/ListogramInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/ListogramInput.module.css +88 -0
- package/build/esm/filter-list/base/inputs/MultiDateInput.js +82 -0
- package/build/esm/filter-list/base/inputs/MultiDateInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/MultiDateInput.module.css +54 -0
- package/build/esm/filter-list/base/inputs/MultiSelectInput.js +100 -0
- package/build/esm/filter-list/base/inputs/MultiSelectInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/MultiSelectInput.module.css +35 -0
- package/build/esm/filter-list/base/inputs/NullValueWrapper.js +76 -0
- package/build/esm/filter-list/base/inputs/NullValueWrapper.js.map +1 -0
- package/build/esm/filter-list/base/inputs/NullValueWrapper.module.css +49 -0
- package/build/esm/filter-list/base/inputs/NumberRangeInput.js +48 -0
- package/build/esm/filter-list/base/inputs/NumberRangeInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/RangeInput.js +187 -0
- package/build/esm/filter-list/base/inputs/RangeInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/RangeInput.module.css +81 -0
- package/build/esm/filter-list/base/inputs/SingleDateInput.js +61 -0
- package/build/esm/filter-list/base/inputs/SingleDateInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/SingleDateInput.module.css +63 -0
- package/build/esm/filter-list/base/inputs/SingleSelectInput.js +95 -0
- package/build/esm/filter-list/base/inputs/SingleSelectInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/SingleSelectInput.module.css +55 -0
- package/build/esm/filter-list/base/inputs/TextTagsInput.js +141 -0
- package/build/esm/filter-list/base/inputs/TextTagsInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/TextTagsInput.module.css +25 -0
- package/build/esm/filter-list/base/inputs/TimelineInput.js +74 -0
- package/build/esm/filter-list/base/inputs/TimelineInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/TimelineInput.module.css +73 -0
- package/build/esm/filter-list/base/inputs/ToggleInput.js +43 -0
- package/build/esm/filter-list/base/inputs/ToggleInput.js.map +1 -0
- package/build/esm/filter-list/base/inputs/ToggleInput.module.css +34 -0
- package/build/esm/filter-list/base/inputs/createHistogramBuckets.js +53 -0
- package/build/esm/filter-list/base/inputs/createHistogramBuckets.js.map +1 -0
- package/build/esm/filter-list/base/inputs/dateUtils.js +57 -0
- package/build/esm/filter-list/base/inputs/dateUtils.js.map +1 -0
- package/build/esm/filter-list/base/inputs/index.js +25 -0
- package/build/esm/filter-list/base/inputs/index.js.map +1 -0
- package/build/esm/filter-list/base/inputs/shared.module.css +79 -0
- package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js +128 -0
- package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js.map +1 -0
- package/build/esm/filter-list/hooks/useFilterListState.js +119 -0
- package/build/esm/filter-list/hooks/useFilterListState.js.map +1 -0
- package/build/esm/filter-list/hooks/usePropertyAggregation.js +92 -0
- package/build/esm/filter-list/hooks/usePropertyAggregation.js.map +1 -0
- package/build/esm/filter-list/types/AddFilterMenuTypes.js +2 -0
- package/build/esm/filter-list/types/AddFilterMenuTypes.js.map +1 -0
- package/build/esm/filter-list/types/CustomRendererTypes.js +2 -0
- package/build/esm/filter-list/types/CustomRendererTypes.js.map +1 -0
- package/build/esm/filter-list/types/FilterPanelTypes.js +2 -0
- package/build/esm/filter-list/types/FilterPanelTypes.js.map +1 -0
- package/build/esm/filter-list/types/KeywordSearchTypes.js +2 -0
- package/build/esm/filter-list/types/KeywordSearchTypes.js.map +1 -0
- package/build/esm/filter-list/types/LinkedFilterTypes.js +2 -0
- package/build/esm/filter-list/types/LinkedFilterTypes.js.map +1 -0
- package/build/esm/filter-list/types/index.js +22 -0
- package/build/esm/filter-list/types/index.js.map +1 -0
- package/build/esm/filter-list/utils/aggregationHelpers.js +44 -0
- package/build/esm/filter-list/utils/aggregationHelpers.js.map +1 -0
- package/build/esm/filter-list/utils/assertUnreachable.js +25 -0
- package/build/esm/filter-list/utils/assertUnreachable.js.map +1 -0
- package/build/esm/filter-list/utils/coerceFilterValue.js +33 -0
- package/build/esm/filter-list/utils/coerceFilterValue.js.map +1 -0
- package/build/esm/filter-list/utils/filterStateToWhereClause.js +337 -0
- package/build/esm/filter-list/utils/filterStateToWhereClause.js.map +1 -0
- package/build/esm/filter-list/utils/filterValues.js +55 -0
- package/build/esm/filter-list/utils/filterValues.js.map +1 -0
- package/build/esm/filter-list/utils/getFilterKey.js +34 -0
- package/build/esm/filter-list/utils/getFilterKey.js.map +1 -0
- package/build/esm/object-table/ColumnConfigDialog.js +259 -0
- package/build/esm/object-table/ColumnConfigDialog.js.map +1 -0
- package/build/esm/object-table/ColumnConfigDialog.module.css +247 -0
- package/build/esm/object-table/DefaultCellRenderer.js +43 -0
- package/build/esm/object-table/DefaultCellRenderer.js.map +1 -0
- package/build/esm/object-table/EditableCell.js +91 -0
- package/build/esm/object-table/EditableCell.js.map +1 -0
- package/build/esm/object-table/EditableCell.module.css +3 -0
- package/build/esm/object-table/LoadingStateTable.js +4 -4
- package/build/esm/object-table/LoadingStateTable.js.map +1 -1
- package/build/esm/object-table/MultiColumnSortDialog.js +178 -0
- package/build/esm/object-table/MultiColumnSortDialog.js.map +1 -0
- package/build/esm/object-table/MultiColumnSortDialog.module.css +195 -0
- package/build/esm/object-table/NonIdealState.module.css +2 -3
- package/build/esm/object-table/ObjectTable.js +74 -15
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/SelectionCells.js +15 -4
- package/build/esm/object-table/SelectionCells.js.map +1 -1
- package/build/esm/object-table/SortableItemsList.js +35 -0
- package/build/esm/object-table/SortableItemsList.js.map +1 -0
- package/build/esm/object-table/Table.js +25 -8
- package/build/esm/object-table/Table.js.map +1 -1
- package/build/esm/object-table/Table.module.css +26 -3
- package/build/esm/object-table/TableBody.module.css +2 -0
- package/build/esm/object-table/TableCell.module.css +22 -1
- package/build/esm/object-table/TableHeader.js +93 -6
- package/build/esm/object-table/TableHeader.js.map +1 -1
- package/build/esm/object-table/TableHeader.module.css +9 -2
- package/build/esm/object-table/TableHeaderWithPopover.js +53 -22
- package/build/esm/object-table/TableHeaderWithPopover.js.map +1 -1
- package/build/esm/object-table/TableHeaderWithPopover.module.css +56 -25
- package/build/esm/object-table/TableRow.module.css +2 -0
- package/build/esm/object-table/__tests__/useEditableTable.test.js +197 -0
- package/build/esm/object-table/__tests__/useEditableTable.test.js.map +1 -0
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js +14 -2
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js.map +1 -1
- package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js +160 -138
- package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js.map +1 -1
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js +113 -25
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js.map +1 -1
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js +48 -0
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js.map +1 -1
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js +27 -82
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js.map +1 -1
- package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js +290 -0
- package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js.map +1 -1
- package/build/esm/object-table/hooks/useColumnDefs.js +16 -3
- package/build/esm/object-table/hooks/useColumnDefs.js.map +1 -1
- package/build/esm/object-table/hooks/useColumnResize.js +45 -0
- package/build/esm/object-table/hooks/useColumnResize.js.map +1 -0
- package/build/esm/object-table/hooks/useColumnVisibility.js +52 -20
- package/build/esm/object-table/hooks/useColumnVisibility.js.map +1 -1
- package/build/esm/object-table/hooks/useEditableTable.js +57 -0
- package/build/esm/object-table/hooks/useEditableTable.js.map +1 -0
- package/build/esm/object-table/hooks/useObjectTableData.js +42 -7
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/object-table/hooks/useRowSelection.js +31 -10
- package/build/esm/object-table/hooks/useRowSelection.js.map +1 -1
- package/build/esm/object-table/hooks/useSelectionColumn.js +15 -6
- package/build/esm/object-table/hooks/useSelectionColumn.js.map +1 -1
- package/build/esm/object-table/utils/getCellId.js +27 -0
- package/build/esm/object-table/utils/getCellId.js.map +1 -0
- package/build/esm/object-table/utils/types.js +2 -0
- package/build/esm/object-table/utils/types.js.map +1 -0
- package/build/esm/public/experimental.js +2 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/esm/shared/ErrorBoundary.js +62 -0
- package/build/esm/shared/ErrorBoundary.js.map +1 -0
- package/build/esm/shared/ErrorBoundary.module.css +55 -0
- package/build/types/base-components/action-button/ActionButton.d.ts +5 -0
- package/build/types/base-components/action-button/ActionButton.d.ts.map +1 -0
- package/build/types/base-components/combobox/Combobox.d.ts +52 -0
- package/build/types/base-components/combobox/Combobox.d.ts.map +1 -0
- package/build/types/base-components/dialog/Dialog.d.ts +10 -0
- package/build/types/base-components/dialog/Dialog.d.ts.map +1 -0
- package/build/types/base-components/draggable-list/DraggableList.d.ts +17 -0
- package/build/types/base-components/draggable-list/DraggableList.d.ts.map +1 -0
- package/build/types/base-components/search-bar/SearchBar.d.ts +11 -0
- package/build/types/base-components/search-bar/SearchBar.d.ts.map +1 -0
- package/build/types/base-components/select/Select.d.ts +34 -0
- package/build/types/base-components/select/Select.d.ts.map +1 -0
- package/build/types/base-components/switch/Switch.d.ts +10 -0
- package/build/types/base-components/switch/Switch.d.ts.map +1 -0
- package/build/types/filter-list/FilterListApi.d.ts +62 -17
- package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
- package/build/types/filter-list/FilterListItemApi.d.ts +101 -53
- package/build/types/filter-list/FilterListItemApi.d.ts.map +1 -1
- package/build/types/filter-list/__tests__/LinkedPropertyInput.test.d.ts +1 -0
- package/build/types/filter-list/__tests__/LinkedPropertyInput.test.d.ts.map +1 -0
- package/build/types/filter-list/__tests__/dateUtils.test.d.ts +1 -0
- package/build/types/filter-list/__tests__/dateUtils.test.d.ts.map +1 -0
- package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts +1 -0
- package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts.map +1 -0
- package/build/types/filter-list/__tests__/getFilterKey.test.d.ts +1 -0
- package/build/types/filter-list/__tests__/getFilterKey.test.d.ts.map +1 -0
- package/build/types/filter-list/__tests__/testUtils.d.ts +65 -0
- package/build/types/filter-list/__tests__/testUtils.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterInput.d.ts +15 -0
- package/build/types/filter-list/base/FilterInput.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterList.d.ts +4 -0
- package/build/types/filter-list/base/FilterList.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterListContent.d.ts +16 -0
- package/build/types/filter-list/base/FilterListContent.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterListHeader.d.ts +14 -0
- package/build/types/filter-list/base/FilterListHeader.d.ts.map +1 -0
- package/build/types/filter-list/base/FilterListItem.d.ts +18 -0
- package/build/types/filter-list/base/FilterListItem.d.ts.map +1 -0
- package/build/types/filter-list/base/index.d.ts +5 -0
- package/build/types/filter-list/base/index.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts +21 -0
- package/build/types/filter-list/base/inputs/CheckboxListInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/ContainsTextInput.d.ts +13 -0
- package/build/types/filter-list/base/inputs/ContainsTextInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/DateRangeInput.d.ts +22 -0
- package/build/types/filter-list/base/inputs/DateRangeInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/LinkedPropertyInput.d.ts +21 -0
- package/build/types/filter-list/base/inputs/LinkedPropertyInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/ListogramInput.d.ts +22 -0
- package/build/types/filter-list/base/inputs/ListogramInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/MultiDateInput.d.ts +12 -0
- package/build/types/filter-list/base/inputs/MultiDateInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/MultiSelectInput.d.ts +24 -0
- package/build/types/filter-list/base/inputs/MultiSelectInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/NullValueWrapper.d.ts +21 -0
- package/build/types/filter-list/base/inputs/NullValueWrapper.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/NumberRangeInput.d.ts +22 -0
- package/build/types/filter-list/base/inputs/NumberRangeInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/RangeInput.d.ts +37 -0
- package/build/types/filter-list/base/inputs/RangeInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/SingleDateInput.d.ts +13 -0
- package/build/types/filter-list/base/inputs/SingleDateInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/SingleSelectInput.d.ts +24 -0
- package/build/types/filter-list/base/inputs/SingleSelectInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/TextTagsInput.d.ts +24 -0
- package/build/types/filter-list/base/inputs/TextTagsInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/TimelineInput.d.ts +11 -0
- package/build/types/filter-list/base/inputs/TimelineInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/ToggleInput.d.ts +10 -0
- package/build/types/filter-list/base/inputs/ToggleInput.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/createHistogramBuckets.d.ts +16 -0
- package/build/types/filter-list/base/inputs/createHistogramBuckets.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/dateUtils.d.ts +17 -0
- package/build/types/filter-list/base/inputs/dateUtils.d.ts.map +1 -0
- package/build/types/filter-list/base/inputs/index.d.ts +8 -0
- package/build/types/filter-list/base/inputs/index.d.ts.map +1 -0
- package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts +1 -0
- package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts.map +1 -0
- package/build/types/filter-list/hooks/useFilterListState.d.ts +11 -0
- package/build/types/filter-list/hooks/useFilterListState.d.ts.map +1 -0
- package/build/types/filter-list/hooks/usePropertyAggregation.d.ts +20 -0
- package/build/types/filter-list/hooks/usePropertyAggregation.d.ts.map +1 -0
- package/build/types/filter-list/types/AddFilterMenuTypes.d.ts +56 -0
- package/build/types/filter-list/types/AddFilterMenuTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/CustomRendererTypes.d.ts +76 -0
- package/build/types/filter-list/types/CustomRendererTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/FilterPanelTypes.d.ts +18 -0
- package/build/types/filter-list/types/FilterPanelTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/KeywordSearchTypes.d.ts +56 -0
- package/build/types/filter-list/types/KeywordSearchTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/LinkedFilterTypes.d.ts +89 -0
- package/build/types/filter-list/types/LinkedFilterTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/index.d.ts +5 -0
- package/build/types/filter-list/types/index.d.ts.map +1 -0
- package/build/types/filter-list/utils/aggregationHelpers.d.ts +9 -0
- package/build/types/filter-list/utils/aggregationHelpers.d.ts.map +1 -0
- package/build/types/filter-list/utils/assertUnreachable.d.ts +6 -0
- package/build/types/filter-list/utils/assertUnreachable.d.ts.map +1 -0
- package/build/types/filter-list/utils/coerceFilterValue.d.ts +11 -0
- package/build/types/filter-list/utils/coerceFilterValue.d.ts.map +1 -0
- package/build/types/filter-list/utils/filterStateToWhereClause.d.ts +16 -0
- package/build/types/filter-list/utils/filterStateToWhereClause.d.ts.map +1 -0
- package/build/types/filter-list/utils/filterValues.d.ts +5 -0
- package/build/types/filter-list/utils/filterValues.d.ts.map +1 -0
- package/build/types/filter-list/utils/getFilterKey.d.ts +3 -0
- package/build/types/filter-list/utils/getFilterKey.d.ts.map +1 -0
- package/build/types/object-table/ColumnConfigDialog.d.ts +18 -0
- package/build/types/object-table/ColumnConfigDialog.d.ts.map +1 -0
- package/build/types/object-table/DefaultCellRenderer.d.ts +3 -0
- package/build/types/object-table/DefaultCellRenderer.d.ts.map +1 -0
- package/build/types/object-table/EditableCell.d.ts +10 -0
- package/build/types/object-table/EditableCell.d.ts.map +1 -0
- package/build/types/object-table/LoadingStateTable.d.ts.map +1 -1
- package/build/types/object-table/MultiColumnSortDialog.d.ts +15 -0
- package/build/types/object-table/MultiColumnSortDialog.d.ts.map +1 -0
- package/build/types/object-table/ObjectTable.d.ts +1 -1
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +79 -8
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/SortableItemsList.d.ts +13 -0
- package/build/types/object-table/SortableItemsList.d.ts.map +1 -0
- package/build/types/object-table/Table.d.ts +26 -1
- package/build/types/object-table/Table.d.ts.map +1 -1
- package/build/types/object-table/TableHeader.d.ts +3 -1
- package/build/types/object-table/TableHeader.d.ts.map +1 -1
- package/build/types/object-table/TableHeaderWithPopover.d.ts +30 -6
- package/build/types/object-table/TableHeaderWithPopover.d.ts.map +1 -1
- package/build/types/object-table/__tests__/useEditableTable.test.d.ts +1 -0
- package/build/types/object-table/__tests__/useEditableTable.test.d.ts.map +1 -0
- package/build/types/object-table/hooks/useColumnDefs.d.ts.map +1 -1
- package/build/types/object-table/hooks/useColumnResize.d.ts +10 -0
- package/build/types/object-table/hooks/useColumnResize.d.ts.map +1 -0
- package/build/types/object-table/hooks/useColumnVisibility.d.ts +18 -7
- package/build/types/object-table/hooks/useColumnVisibility.d.ts.map +1 -1
- package/build/types/object-table/hooks/useEditableTable.d.ts +22 -0
- package/build/types/object-table/hooks/useEditableTable.d.ts.map +1 -0
- package/build/types/object-table/hooks/useObjectTableData.d.ts +6 -5
- package/build/types/object-table/hooks/useObjectTableData.d.ts.map +1 -1
- package/build/types/object-table/hooks/useRowSelection.d.ts +5 -4
- package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
- package/build/types/object-table/utils/getCellId.d.ts +3 -0
- package/build/types/object-table/utils/getCellId.d.ts.map +1 -0
- package/build/types/object-table/utils/types.d.ts +14 -0
- package/build/types/object-table/utils/types.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +6 -2
- package/build/types/public/experimental.d.ts.map +1 -1
- package/build/types/shared/ErrorBoundary.d.ts +19 -0
- package/build/types/shared/ErrorBoundary.d.ts.map +1 -0
- package/package.json +17 -9
|
@@ -0,0 +1,57 @@
|
|
|
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 { useCallback, useState } from "react";
|
|
18
|
+
import { getCellIdentifier } from "../utils/getCellId.js";
|
|
19
|
+
export function useEditableTable({
|
|
20
|
+
onCellValueChanged,
|
|
21
|
+
onSubmitEdits
|
|
22
|
+
}) {
|
|
23
|
+
const [cellEdits, setCellEdits] = useState({});
|
|
24
|
+
const handleCellEdit = useCallback((cellId, state) => {
|
|
25
|
+
const cellIdentifier = getCellIdentifier(cellId);
|
|
26
|
+
|
|
27
|
+
// If value is changed back to original, remove it from edits
|
|
28
|
+
if (state.newValue === state.oldValue) {
|
|
29
|
+
setCellEdits(prev => {
|
|
30
|
+
const {
|
|
31
|
+
[cellId]: _,
|
|
32
|
+
...rest
|
|
33
|
+
} = prev;
|
|
34
|
+
return rest;
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
setCellEdits(prev => ({
|
|
38
|
+
...prev,
|
|
39
|
+
[cellId]: state
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
onCellValueChanged?.(cellIdentifier, state);
|
|
43
|
+
}, [onCellValueChanged]);
|
|
44
|
+
const clearEdits = useCallback(() => {
|
|
45
|
+
setCellEdits({});
|
|
46
|
+
}, []);
|
|
47
|
+
const handleSubmitEdits = useCallback(async () => {
|
|
48
|
+
await onSubmitEdits?.(cellEdits);
|
|
49
|
+
}, [cellEdits, onSubmitEdits]);
|
|
50
|
+
return {
|
|
51
|
+
cellEdits,
|
|
52
|
+
handleCellEdit,
|
|
53
|
+
handleSubmitEdits,
|
|
54
|
+
clearEdits
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=useEditableTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditableTable.js","names":["useCallback","useState","getCellIdentifier","useEditableTable","onCellValueChanged","onSubmitEdits","cellEdits","setCellEdits","handleCellEdit","cellId","state","cellIdentifier","newValue","oldValue","prev","_","rest","clearEdits","handleSubmitEdits"],"sources":["useEditableTable.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 QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useCallback, useState } from \"react\";\nimport type { ObjectTableProps } from \"../ObjectTableApi.js\";\nimport { getCellIdentifier } from \"../utils/getCellId.js\";\nimport type { CellValueState } from \"../utils/types.js\";\n\nexport interface UseEditableTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n onCellValueChanged?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onCellValueChanged\"];\n\n onSubmitEdits?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onSubmitEdits\"];\n}\n\nexport interface UseEditableTableResult {\n cellEdits: Record<string, CellValueState>;\n handleCellEdit: (\n cellId: string,\n state: CellValueState,\n ) => void;\n handleSubmitEdits: () => Promise<void>;\n clearEdits: () => void;\n}\n\nexport function useEditableTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n onCellValueChanged,\n onSubmitEdits,\n}: UseEditableTableProps<Q, RDPs, FunctionColumns>): UseEditableTableResult {\n const [cellEdits, setCellEdits] = useState<Record<string, CellValueState>>(\n {},\n );\n\n const handleCellEdit = useCallback(\n (cellId: string, state: CellValueState) => {\n const cellIdentifier = getCellIdentifier(cellId);\n\n // If value is changed back to original, remove it from edits\n if (state.newValue === state.oldValue) {\n setCellEdits(prev => {\n const { [cellId]: _, ...rest } = prev;\n return rest;\n });\n } else {\n setCellEdits(prev => ({\n ...prev,\n [cellId]: state,\n }));\n }\n\n onCellValueChanged?.(cellIdentifier, state);\n },\n [onCellValueChanged],\n );\n\n const clearEdits = useCallback(() => {\n setCellEdits({});\n }, []);\n\n const handleSubmitEdits = useCallback(async () => {\n await onSubmitEdits?.(cellEdits);\n }, [cellEdits, onSubmitEdits]);\n\n return {\n cellEdits,\n handleCellEdit,\n handleSubmitEdits,\n clearEdits,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAE7C,SAASC,iBAAiB,QAAQ,uBAAuB;AAqCzD,OAAO,SAASC,gBAAgBA,CAU9B;EACAC,kBAAkB;EAClBC;AAC+C,CAAC,EAA0B;EAC1E,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGN,QAAQ,CACxC,CAAC,CACH,CAAC;EAED,MAAMO,cAAc,GAAGR,WAAW,CAChC,CAACS,MAAc,EAAEC,KAAqB,KAAK;IACzC,MAAMC,cAAc,GAAGT,iBAAiB,CAACO,MAAM,CAAC;;IAEhD;IACA,IAAIC,KAAK,CAACE,QAAQ,KAAKF,KAAK,CAACG,QAAQ,EAAE;MACrCN,YAAY,CAACO,IAAI,IAAI;QACnB,MAAM;UAAE,CAACL,MAAM,GAAGM,CAAC;UAAE,GAAGC;QAAK,CAAC,GAAGF,IAAI;QACrC,OAAOE,IAAI;MACb,CAAC,CAAC;IACJ,CAAC,MAAM;MACLT,YAAY,CAACO,IAAI,KAAK;QACpB,GAAGA,IAAI;QACP,CAACL,MAAM,GAAGC;MACZ,CAAC,CAAC,CAAC;IACL;IAEAN,kBAAkB,GAAGO,cAAc,EAAED,KAAK,CAAC;EAC7C,CAAC,EACD,CAACN,kBAAkB,CACrB,CAAC;EAED,MAAMa,UAAU,GAAGjB,WAAW,CAAC,MAAM;IACnCO,YAAY,CAAC,CAAC,CAAC,CAAC;EAClB,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMW,iBAAiB,GAAGlB,WAAW,CAAC,YAAY;IAChD,MAAMK,aAAa,GAAGC,SAAS,CAAC;EAClC,CAAC,EAAE,CAACA,SAAS,EAAED,aAAa,CAAC,CAAC;EAE9B,OAAO;IACLC,SAAS;IACTE,cAAc;IACdU,iBAAiB;IACjBD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { useOsdkObjects } from "@osdk/react/experimental";
|
|
17
|
+
import { useObjectSet, useOsdkObjects } from "@osdk/react/experimental";
|
|
18
18
|
import { useMemo } from "react";
|
|
19
19
|
const PAGE_SIZE = 50;
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
|
-
* This hook is a wrapper
|
|
23
|
-
*
|
|
21
|
+
* This hook is a wrapper that conditionally uses either useObjectSet or useOsdkObjects
|
|
22
|
+
* based on whether an objectSet prop is provided.
|
|
23
|
+
* It extracts RDP locators from columnDefinitions and applies withProperties
|
|
24
24
|
* to return data containing the derived properties.
|
|
25
25
|
*/
|
|
26
|
-
export function useObjectTableData(objectOrInterfaceType, columnDefinitions, filter, sorting) {
|
|
26
|
+
export function useObjectTableData(objectOrInterfaceType, columnDefinitions, filter, sorting, objectSet, objectSetOptions) {
|
|
27
27
|
const orderBy = useMemo(() => {
|
|
28
28
|
if (!sorting || sorting.length === 0) {
|
|
29
29
|
return undefined;
|
|
@@ -52,11 +52,46 @@ export function useObjectTableData(objectOrInterfaceType, columnDefinitions, fil
|
|
|
52
52
|
};
|
|
53
53
|
}, {});
|
|
54
54
|
}, [columnDefinitions]);
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
// When objectSet is provided and it's an object type, use useObjectSet. Otherwise, use useOsdkObjects.
|
|
57
|
+
const isObjectType = objectOrInterfaceType.type === "object";
|
|
58
|
+
const shouldUseObjectSet = !!objectSet && isObjectType;
|
|
59
|
+
|
|
60
|
+
// When shouldUseObjectSet is true, we know objectSet is defined
|
|
61
|
+
// and objectOrInterfaceType is an ObjectTypeDefinition
|
|
62
|
+
const objectSetResult = useObjectSet(shouldUseObjectSet ? objectSet : undefined, {
|
|
63
|
+
...objectSetOptions,
|
|
64
|
+
withProperties: withProperties,
|
|
65
|
+
where: filter,
|
|
66
|
+
orderBy,
|
|
67
|
+
pageSize: PAGE_SIZE,
|
|
68
|
+
enabled: shouldUseObjectSet
|
|
69
|
+
});
|
|
70
|
+
const osdkObjectsResult = useOsdkObjects(objectOrInterfaceType, {
|
|
56
71
|
withProperties,
|
|
57
72
|
pageSize: PAGE_SIZE,
|
|
58
73
|
where: filter,
|
|
59
|
-
orderBy
|
|
74
|
+
orderBy,
|
|
75
|
+
enabled: !shouldUseObjectSet
|
|
60
76
|
});
|
|
77
|
+
|
|
78
|
+
// Return the appropriate result based on which hook is enabled
|
|
79
|
+
if (shouldUseObjectSet) {
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
81
|
+
console.debug("Using useObjectSet for data fetching in ObjectTable because objectSet is provided and objectType is an object.");
|
|
82
|
+
// Convert UseObjectSetResult to UseOsdkListResult format
|
|
83
|
+
return {
|
|
84
|
+
data: objectSetResult.data,
|
|
85
|
+
fetchMore: objectSetResult.fetchMore,
|
|
86
|
+
isLoading: objectSetResult.isLoading,
|
|
87
|
+
error: objectSetResult.error,
|
|
88
|
+
totalCount: objectSetResult.totalCount,
|
|
89
|
+
isOptimistic: false // ObjectSet doesn't support optimistic updates
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.debug("Using useOsdkObjects for data fetching in ObjectTable because objectSet is not provided or objectType is an interface.");
|
|
95
|
+
return osdkObjectsResult;
|
|
61
96
|
}
|
|
62
97
|
//# sourceMappingURL=useObjectTableData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectTableData.js","names":["useOsdkObjects","useMemo","PAGE_SIZE","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","
|
|
1
|
+
{"version":3,"file":"useObjectTableData.js","names":["useObjectSet","useOsdkObjects","useMemo","PAGE_SIZE","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","objectSet","objectSetOptions","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","isObjectType","shouldUseObjectSet","objectSetResult","where","pageSize","enabled","osdkObjectsResult","console","debug","data","fetchMore","isLoading","error","totalCount","isOptimistic"],"sources":["useObjectTableData.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { UseOsdkListResult } from \"@osdk/react/experimental\";\nimport { useObjectSet, useOsdkObjects } from \"@osdk/react/experimental\";\nimport type { SortingState } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\nimport type { ColumnDefinition, ObjectSetOptions } from \"../ObjectTableApi.js\";\n\nconst PAGE_SIZE = 50;\n\ntype WithProperties<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n> = {\n [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]>;\n};\n/**\n * This hook is a wrapper that conditionally uses either useObjectSet or useOsdkObjects\n * based on whether an objectSet prop is provided.\n * It extracts RDP locators from columnDefinitions and applies withProperties\n * to return data containing the derived properties.\n */\nexport function useObjectTableData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectOrInterfaceType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n filter?: WhereClause<Q, RDPs>,\n sorting?: SortingState,\n objectSet?: ObjectSet<Q>,\n objectSetOptions?: ObjectSetOptions<Q>,\n): UseOsdkListResult<Q, RDPs> {\n const orderBy = useMemo(() => {\n if (!sorting || sorting.length === 0) {\n return undefined;\n }\n\n return sorting.reduce<{ [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" }>(\n (acc, sort) => {\n acc[sort.id as PropertyKeys<Q>] = sort.desc ? \"desc\" : \"asc\";\n return acc;\n },\n {},\n );\n }, [sorting]);\n\n // Extract derived properties definition\n const withProperties = useMemo(() => {\n if (!columnDefinitions) {\n return;\n }\n\n const rdpColumns = columnDefinitions.map(colDef => colDef.locator).filter(\n (colLocator) => {\n return colLocator.type === \"rdp\";\n },\n );\n\n if (!rdpColumns.length) {\n return;\n }\n\n return rdpColumns.reduce<WithProperties<Q, RDPs>>(\n (acc, cur) => {\n return {\n ...acc,\n [cur.id]: cur.creator,\n };\n },\n {} as WithProperties<Q, RDPs>,\n );\n }, [columnDefinitions]);\n\n // When objectSet is provided and it's an object type, use useObjectSet. Otherwise, use useOsdkObjects.\n const isObjectType = objectOrInterfaceType.type === \"object\";\n const shouldUseObjectSet = !!objectSet && isObjectType;\n\n // When shouldUseObjectSet is true, we know objectSet is defined\n // and objectOrInterfaceType is an ObjectTypeDefinition\n const objectSetResult = useObjectSet(\n shouldUseObjectSet ? objectSet as ObjectSet<Q> : undefined as any,\n {\n ...(objectSetOptions as ObjectSetOptions<Q>),\n withProperties: withProperties as WithProperties<\n Q,\n RDPs\n >,\n where: filter,\n orderBy,\n pageSize: PAGE_SIZE,\n enabled: shouldUseObjectSet,\n },\n );\n\n const osdkObjectsResult = useOsdkObjects<\n Q,\n RDPs\n >(\n objectOrInterfaceType,\n {\n withProperties,\n pageSize: PAGE_SIZE,\n where: filter,\n orderBy,\n enabled: !shouldUseObjectSet,\n },\n );\n\n // Return the appropriate result based on which hook is enabled\n if (shouldUseObjectSet) {\n // eslint-disable-next-line no-console\n console.debug(\n \"Using useObjectSet for data fetching in ObjectTable because objectSet is provided and objectType is an object.\",\n );\n // Convert UseObjectSetResult to UseOsdkListResult format\n return {\n data: objectSetResult.data,\n fetchMore: objectSetResult.fetchMore,\n isLoading: objectSetResult.isLoading,\n error: objectSetResult.error,\n totalCount: objectSetResult.totalCount,\n isOptimistic: false, // ObjectSet doesn't support optimistic updates\n } as UseOsdkListResult<Q, RDPs>;\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n \"Using useOsdkObjects for data fetching in ObjectTable because objectSet is not provided or objectType is an interface.\",\n );\n return osdkObjectsResult;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,YAAY,EAAEC,cAAc,QAAQ,0BAA0B;AAEvE,SAASC,OAAO,QAAQ,OAAO;AAG/B,MAAMC,SAAS,GAAG,EAAE;AAWpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAWhCC,qBAAwB,EACxBC,iBAAqE,EACrEC,MAA6B,EAC7BC,OAAsB,EACtBC,SAAwB,EACxBC,gBAAsC,EACV;EAC5B,MAAMC,OAAO,GAAGT,OAAO,CAAC,MAAM;IAC5B,IAAI,CAACM,OAAO,IAAIA,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACpC,OAAOC,SAAS;IAClB;IAEA,OAAOL,OAAO,CAACM,MAAM,CACnB,CAACC,GAAG,EAAEC,IAAI,KAAK;MACbD,GAAG,CAACC,IAAI,CAACC,EAAE,CAAoB,GAAGD,IAAI,CAACE,IAAI,GAAG,MAAM,GAAG,KAAK;MAC5D,OAAOH,GAAG;IAC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IACtB;IACAM,OAAO,CAACC,KAAK,CACX,gHACF,CAAC;IACD;IACA,OAAO;MACLC,IAAI,EAAEP,eAAe,CAACO,IAAI;MAC1BC,SAAS,EAAER,eAAe,CAACQ,SAAS;MACpCC,SAAS,EAAET,eAAe,CAACS,SAAS;MACpCC,KAAK,EAAEV,eAAe,CAACU,KAAK;MAC5BC,UAAU,EAAEX,eAAe,CAACW,UAAU;MACtCC,YAAY,EAAE,KAAK,CAAE;IACvB,CAAC;EACH;;EAEA;EACAP,OAAO,CAACC,KAAK,CACX,wHACF,CAAC;EACD,OAAOF,iBAAiB;AAC1B","ignoreList":[]}
|
|
@@ -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
|
|
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 (!
|
|
37
|
+
if (!enableRowSelection) return {};
|
|
38
38
|
if (isControlled && selectedRows) {
|
|
39
39
|
return getRowSelectionState(selectedRows);
|
|
40
40
|
}
|
|
41
41
|
return internalRowSelection;
|
|
42
|
-
}, [
|
|
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 (!
|
|
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
|
-
}, [
|
|
53
|
+
}, [enableRowSelection, data, isAllSelected, isControlled, onRowSelection]);
|
|
54
54
|
const onToggleRow = useCallback((rowId, rowIndex, isShiftClick = false) => {
|
|
55
|
-
if (!
|
|
55
|
+
if (!enableRowSelection || !data) return;
|
|
56
56
|
let newSelectedRows = [];
|
|
57
57
|
if (selectionMode === "single") {
|
|
58
58
|
newSelectedRows = getSingleSelectionRows({
|
|
@@ -61,7 +61,6 @@ export function useRowSelection({
|
|
|
61
61
|
data,
|
|
62
62
|
rowSelectionState
|
|
63
63
|
});
|
|
64
|
-
setLastSelectedRowIndex(rowIndex);
|
|
65
64
|
} else {
|
|
66
65
|
// Multiple selection mode
|
|
67
66
|
|
|
@@ -75,6 +74,7 @@ export function useRowSelection({
|
|
|
75
74
|
lastSelectedRowIndex,
|
|
76
75
|
rowSelectionState
|
|
77
76
|
});
|
|
77
|
+
setLastSelectedRowIndex(rowIndex);
|
|
78
78
|
} else {
|
|
79
79
|
newSelectedRows = getMultipleSelectionRows({
|
|
80
80
|
rowId,
|
|
@@ -82,17 +82,25 @@ export function useRowSelection({
|
|
|
82
82
|
data,
|
|
83
83
|
rowSelectionState
|
|
84
84
|
});
|
|
85
|
+
// Only update lastSelectedRowIndex if we're selecting (not deselecting)
|
|
86
|
+
if (!isCurrentlySelected({
|
|
87
|
+
rowIndex,
|
|
88
|
+
data,
|
|
89
|
+
rowSelectionState
|
|
90
|
+
})) {
|
|
91
|
+
setLastSelectedRowIndex(rowIndex);
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
|
-
setLastSelectedRowIndex(rowIndex);
|
|
87
94
|
}
|
|
88
95
|
if (!isControlled) {
|
|
89
96
|
setInternalRowSelection(getRowSelectionState(newSelectedRows));
|
|
90
97
|
}
|
|
91
98
|
onRowSelection?.(newSelectedRows);
|
|
92
|
-
}, [
|
|
99
|
+
}, [enableRowSelection, data, selectionMode, lastSelectedRowIndex, isControlled, rowSelectionState, onRowSelection]);
|
|
93
100
|
return {
|
|
94
101
|
rowSelection: rowSelectionState,
|
|
95
102
|
isAllSelected,
|
|
103
|
+
enableRowSelection,
|
|
96
104
|
hasSelection: selectedCount > 0,
|
|
97
105
|
onToggleAll,
|
|
98
106
|
onToggleRow
|
|
@@ -133,6 +141,15 @@ function getRangeSelectionRows({
|
|
|
133
141
|
}
|
|
134
142
|
return [];
|
|
135
143
|
}
|
|
144
|
+
function isCurrentlySelected({
|
|
145
|
+
rowIndex,
|
|
146
|
+
data,
|
|
147
|
+
rowSelectionState
|
|
148
|
+
}) {
|
|
149
|
+
const primaryKey = data[rowIndex].$primaryKey;
|
|
150
|
+
const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);
|
|
151
|
+
return currentlySelected.includes(primaryKey);
|
|
152
|
+
}
|
|
136
153
|
function getMultipleSelectionRows({
|
|
137
154
|
rowIndex,
|
|
138
155
|
data,
|
|
@@ -141,7 +158,11 @@ function getMultipleSelectionRows({
|
|
|
141
158
|
const primaryKey = data[rowIndex].$primaryKey;
|
|
142
159
|
const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);
|
|
143
160
|
// Handles single row toggle in multiple selection mode
|
|
144
|
-
const newSelectedRows =
|
|
161
|
+
const newSelectedRows = isCurrentlySelected({
|
|
162
|
+
rowIndex,
|
|
163
|
+
data,
|
|
164
|
+
rowSelectionState
|
|
165
|
+
}) ? currentlySelected.filter(i => i !== primaryKey) : [...currentlySelected, primaryKey];
|
|
145
166
|
return newSelectedRows;
|
|
146
167
|
}
|
|
147
168
|
|
|
@@ -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,EAClBF,YAAY,EACZP,YAAY,EACZG,oBAAoB,CACrB,CAAC;EAEF,MAAMS,aAAa,GAAGC,MAAM,CAACC,MAAM,CAACJ,iBAAiB,CAAC,CAACK,MAAM,CAACC,OAAO,CAAC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xC,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","isCurrentlySelected","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 } 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 setLastSelectedRowIndex(rowIndex);\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n // Only update lastSelectedRowIndex if we're selecting (not deselecting)\n if (\n !isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\n ) {\n setLastSelectedRowIndex(rowIndex);\n }\n }\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 isCurrentlySelected<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { rowIndex, data, rowSelectionState }: Pick<\n GetSelectedRowsProps<Q, RDPs>,\n \"rowIndex\" | \"data\" | \"rowSelectionState\"\n >,\n): boolean {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n return currentlySelected.includes(primaryKey);\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n // Handles single row toggle in multiple selection mode\n const newSelectedRows =\n isCurrentlySelected<Q, RDPs>({ rowIndex, data, rowSelectionState })\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}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,sBAAsB;AA2BvE,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,EAClBF,YAAY,EACZP,YAAY,EACZG,oBAAoB,CACrB,CAAC;EAEF,MAAMS,aAAa,GAAGC,MAAM,CAACC,MAAM,CAACJ,iBA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gB,EACsD;EACtE,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAACJ,UAAU,EAAEC,QAAQ,CAAC;EAC5C,MAAMI,GAAG,GAAGF,IAAI,CAACG,GAAG,CAACN,UAAU,EAAEC,QAAQ,CAAC;EAC1C,MAAMM,IAEL,GAAG,EAAE;EAEN,KAAK,IAAIR,CAAC,GAAGG,KAAK,EAAEH,CAAC,IAAIM,GAAG,EAAEN,CAAC,EAAE,EAAE;IACjC,MAAMrB,IAAI,GAAGrB,IAAI,CAAC0C,CAAC,CAAC;IACpB,IAAIrB,IAAI,EAAE;MACR6B,IAAI,CAACT,IAAI,CAACpB,IAAI,CAAC;IACjB;EACF;EAEA,OAAO6B,IAAI;AACb;;AAEA;AACA;AACA;AACA,SAASzC,oBAAoBA,CAC3B0C,WAAgC,EACb;EACnB,OAAOA,WAAW,CAACC,MAAM,CACvB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IACnBoB,GAAG,CAAC1D,sBAAsB,CAACsC,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCtD,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRa,MAAM,CAACQ,IAAI,IAAIiC,cAAc,CAAC5D,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:
|
|
33
|
-
hasSelection:
|
|
34
|
-
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:
|
|
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
|
|
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={
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9C,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;EACA,MAAMC,gBAAgB,GAAGV,MAAM,CAACM,aAAa,CA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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
|
+
export function getCellId(cellIdentifier) {
|
|
18
|
+
return JSON.stringify(cellIdentifier);
|
|
19
|
+
}
|
|
20
|
+
export function getCellIdentifier(cellId) {
|
|
21
|
+
const parsed = JSON.parse(cellId);
|
|
22
|
+
if (typeof parsed === "object" && parsed != null && "rowId" in parsed && "columnId" in parsed) {
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Parsed cellId does not have required properties");
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=getCellId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCellId.js","names":["getCellId","cellIdentifier","JSON","stringify","getCellIdentifier","cellId","parsed","parse","Error"],"sources":["getCellId.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 { CellIdentifier } from \"./types.js\";\n\nexport function getCellId(cellIdentifier: CellIdentifier): string {\n return JSON.stringify(cellIdentifier);\n}\n\nexport function getCellIdentifier(cellId: string): CellIdentifier {\n const parsed = JSON.parse(cellId);\n if (\n typeof parsed === \"object\" && parsed != null && \"rowId\" in parsed\n && \"columnId\" in parsed\n ) {\n return parsed as CellIdentifier;\n }\n throw new Error(\"Parsed cellId does not have required properties\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,SAASA,CAACC,cAA8B,EAAU;EAChE,OAAOC,IAAI,CAACC,SAAS,CAACF,cAAc,CAAC;AACvC;AAEA,OAAO,SAASG,iBAAiBA,CAACC,MAAc,EAAkB;EAChE,MAAMC,MAAM,GAAGJ,IAAI,CAACK,KAAK,CAACF,MAAM,CAAC;EACjC,IACE,OAAOC,MAAM,KAAK,QAAQ,IAAIA,MAAM,IAAI,IAAI,IAAI,OAAO,IAAIA,MAAM,IAC9D,UAAU,IAAIA,MAAM,EACvB;IACA,OAAOA,MAAM;EACf;EACA,MAAM,IAAIE,KAAK,CAAC,iDAAiD,CAAC;AACpE","ignoreList":[]}
|
|
@@ -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\nimport type { RowData } from \"@tanstack/react-table\";\n\nexport interface ColumnOption {\n id: string;\n name: string;\n canSort: boolean;\n}\n\nexport interface CellIdentifier {\n rowId: string;\n columnId: string;\n}\n\nexport interface CellValueState<TData extends RowData = unknown> {\n newValue: TData;\n oldValue: TData;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
export { FilterList } from "../filter-list/base/FilterList.js";
|
|
17
18
|
// ObjectTable that loads and displays data for a given objectSet
|
|
18
19
|
export { ObjectTable } from "../object-table/ObjectTable.js";
|
|
19
20
|
|
|
20
21
|
// BaseTable that does not handle data fetching
|
|
21
22
|
|
|
22
23
|
export { BaseTable } from "../object-table/Table.js";
|
|
24
|
+
export { ColumnConfigDialog } from "../object-table/ColumnConfigDialog.js";
|
|
23
25
|
//# 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 {
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["FilterList","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 { FilterList } from \"../filter-list/base/FilterList.js\";\nexport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../filter-list/FilterListApi.js\";\nexport type {\n FilterComponentType,\n FilterListItemProps,\n FilterState,\n PropertyFilterDefinition,\n} 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\";\nexport type {\n CellIdentifier,\n CellValueState,\n} from \"../object-table/utils/types.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;;AAEA,SAASA,UAAU,QAAQ,mCAAmC;AAY9D;AACA,SAASC,WAAW,QAAQ,gCAAgC;;AAW5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { Button } from "@base-ui/react/button";
|
|
18
|
+
import React, { Component } from "react";
|
|
19
|
+
import styles from "./ErrorBoundary.module.css";
|
|
20
|
+
export class ErrorBoundary extends Component {
|
|
21
|
+
state = {
|
|
22
|
+
hasError: false,
|
|
23
|
+
error: null
|
|
24
|
+
};
|
|
25
|
+
static getDerivedStateFromError(error) {
|
|
26
|
+
return {
|
|
27
|
+
hasError: true,
|
|
28
|
+
error
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
componentDidCatch(error, errorInfo) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.error("[ErrorBoundary]", error);
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
|
+
console.error("[ErrorBoundary] Component stack:", errorInfo.componentStack);
|
|
36
|
+
this.props.onError?.(error);
|
|
37
|
+
}
|
|
38
|
+
handleRetry = () => {
|
|
39
|
+
this.setState({
|
|
40
|
+
hasError: false,
|
|
41
|
+
error: null
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
render() {
|
|
45
|
+
if (this.state.hasError) {
|
|
46
|
+
if (this.props.fallback) {
|
|
47
|
+
return this.props.fallback;
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: styles.errorContainer
|
|
51
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
52
|
+
className: styles.errorMessage
|
|
53
|
+
}, this.props.errorMessage ?? "Something went wrong"), /*#__PURE__*/React.createElement(Button, {
|
|
54
|
+
className: styles.retryButton,
|
|
55
|
+
onClick: this.handleRetry,
|
|
56
|
+
"aria-label": "Retry"
|
|
57
|
+
}, "Retry"));
|
|
58
|
+
}
|
|
59
|
+
return this.props.children;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","names":["Button","React","Component","styles","ErrorBoundary","state","hasError","error","getDerivedStateFromError","componentDidCatch","errorInfo","console","componentStack","props","onError","handleRetry","setState","render","fallback","createElement","className","errorContainer","errorMessage","retryButton","onClick","children"],"sources":["ErrorBoundary.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 { Button } from \"@base-ui/react/button\";\nimport React, { Component, type ReactNode } from \"react\";\nimport styles from \"./ErrorBoundary.module.css\";\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n errorMessage?: string;\n fallback?: ReactNode;\n onError?: (error: Error) => void;\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n error: Error | null;\n}\n\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n state: ErrorBoundaryState = { hasError: false, error: null };\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n // eslint-disable-next-line no-console\n console.error(\"[ErrorBoundary]\", error);\n // eslint-disable-next-line no-console\n console.error(\n \"[ErrorBoundary] Component stack:\",\n errorInfo.componentStack,\n );\n this.props.onError?.(error);\n }\n\n handleRetry = (): void => {\n this.setState({ hasError: false, error: null });\n };\n\n render(): ReactNode {\n if (this.state.hasError) {\n if (this.props.fallback) {\n return this.props.fallback;\n }\n\n return (\n <div className={styles.errorContainer}>\n <p className={styles.errorMessage}>\n {this.props.errorMessage ?? \"Something went wrong\"}\n </p>\n <Button\n className={styles.retryButton}\n onClick={this.handleRetry}\n aria-label=\"Retry\"\n >\n Retry\n </Button>\n </div>\n );\n }\n return this.props.children;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,OAAOC,KAAK,IAAIC,SAAS,QAAwB,OAAO;AACxD,OAAOC,MAAM,MAAM,4BAA4B;AAc/C,OAAO,MAAMC,aAAa,SAASF,SAAS,CAG1C;EACAG,KAAK,GAAuB;IAAEC,QAAQ,EAAE,KAAK;IAAEC,KAAK,EAAE;EAAK,CAAC;EAE5D,OAAOC,wBAAwBA,CAACD,KAAY,EAAsB;IAChE,OAAO;MAAED,QAAQ,EAAE,IAAI;MAAEC;IAAM,CAAC;EAClC;EAEAE,iBAAiBA,CAACF,KAAY,EAAEG,SAA0B,EAAQ;IAChE;IACAC,OAAO,CAACJ,KAAK,CAAC,iBAAiB,EAAEA,KAAK,CAAC;IACvC;IACAI,OAAO,CAACJ,KAAK,CACX,kCAAkC,EAClCG,SAAS,CAACE,cACZ,CAAC;IACD,IAAI,CAACC,KAAK,CAACC,OAAO,GAAGP,KAAK,CAAC;EAC7B;EAEAQ,WAAW,GAAGA,CAAA,KAAY;IACxB,IAAI,CAACC,QAAQ,CAAC;MAAEV,QAAQ,EAAE,KAAK;MAAEC,KAAK,EAAE;IAAK,CAAC,CAAC;EACjD,CAAC;EAEDU,MAAMA,CAAA,EAAc;IAClB,IAAI,IAAI,CAACZ,KAAK,CAACC,QAAQ,EAAE;MACvB,IAAI,IAAI,CAACO,KAAK,CAACK,QAAQ,EAAE;QACvB,OAAO,IAAI,CAACL,KAAK,CAACK,QAAQ;MAC5B;MAEA,oBACEjB,KAAA,CAAAkB,aAAA;QAAKC,SAAS,EAAEjB,MAAM,CAACkB;MAAe,gBACpCpB,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