@osdk/react-components 0.2.0-beta.1 → 0.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +21 -5
- 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__/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 +192 -0
- package/build/browser/filter-list/__tests__/testUtils.js.map +1 -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/useDebouncedValue.js +52 -0
- package/build/browser/filter-list/hooks/useDebouncedValue.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/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 +21 -0
- package/build/browser/filter-list/types/index.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/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 +43 -13
- 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/SortableItemsList.js +35 -0
- package/build/browser/object-table/SortableItemsList.js.map +1 -0
- package/build/browser/object-table/Table.js +54 -934
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/Table.module.css +29 -0
- package/build/browser/object-table/Table.module.css.js +6 -0
- package/build/browser/object-table/TableBody.js +36 -260
- package/build/browser/object-table/TableBody.module.css +20 -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 +73 -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 +106 -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 +60 -0
- package/build/browser/object-table/TableRow.module.css.js +6 -0
- 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__/useRowSelection.test.js +3 -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 +7 -2
- 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/useRowSelection.js +8 -7
- 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/types.js +2 -0
- package/build/browser/object-table/utils/types.js.map +1 -0
- package/build/browser/public/experimental.js +1 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +1875 -0
- package/build/cjs/public/experimental.cjs +1036 -197
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +659 -29
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +435 -44
- 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__/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 +192 -0
- package/build/esm/filter-list/__tests__/testUtils.js.map +1 -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/useDebouncedValue.js +52 -0
- package/build/esm/filter-list/hooks/useDebouncedValue.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/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 +21 -0
- package/build/esm/filter-list/types/index.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/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 +43 -13
- 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/SortableItemsList.js +35 -0
- package/build/esm/object-table/SortableItemsList.js.map +1 -0
- package/build/esm/object-table/Table.js +9 -7
- package/build/esm/object-table/Table.js.map +1 -1
- package/build/esm/object-table/Table.module.css +9 -2
- package/build/esm/object-table/TableCell.module.css +11 -0
- 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 +7 -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 +54 -23
- 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__/useRowSelection.test.js +3 -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 +7 -2
- 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/useRowSelection.js +8 -7
- 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/types.js +2 -0
- package/build/esm/object-table/utils/types.js.map +1 -0
- package/build/esm/public/experimental.js +1 -0
- package/build/esm/public/experimental.js.map +1 -1
- 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 +63 -12
- 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__/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 +59 -0
- package/build/types/filter-list/__tests__/testUtils.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/useDebouncedValue.d.ts +11 -0
- package/build/types/filter-list/hooks/useDebouncedValue.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 +61 -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/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 +70 -0
- package/build/types/filter-list/types/LinkedFilterTypes.d.ts.map +1 -0
- package/build/types/filter-list/types/index.d.ts +4 -0
- package/build/types/filter-list/types/index.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/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 +41 -6
- 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 +12 -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/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/useRowSelection.d.ts +5 -4
- package/build/types/object-table/hooks/useRowSelection.d.ts.map +1 -1
- package/build/types/object-table/utils/types.d.ts +5 -0
- package/build/types/object-table/utils/types.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +2 -0
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +16 -8
|
@@ -28,31 +28,31 @@ export function useRowSelection({
|
|
|
28
28
|
// Used for shift-click behavior in "multiple" mode
|
|
29
29
|
const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState(null);
|
|
30
30
|
const isControlled = selectedRows !== undefined;
|
|
31
|
-
const
|
|
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({
|
|
@@ -89,10 +89,11 @@ export function useRowSelection({
|
|
|
89
89
|
setInternalRowSelection(getRowSelectionState(newSelectedRows));
|
|
90
90
|
}
|
|
91
91
|
onRowSelection?.(newSelectedRows);
|
|
92
|
-
}, [
|
|
92
|
+
}, [enableRowSelection, data, selectionMode, lastSelectedRowIndex, isControlled, rowSelectionState, onRowSelection]);
|
|
93
93
|
return {
|
|
94
94
|
rowSelection: rowSelectionState,
|
|
95
95
|
isAllSelected,
|
|
96
|
+
enableRowSelection,
|
|
96
97
|
hasSelection: selectedCount > 0,
|
|
97
98
|
onToggleAll,
|
|
98
99
|
onToggleRow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowSelection.js","names":["useCallback","useMemo","useState","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","onRowSelection","data","internalRowSelection","setInternalRowSelection","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","isSelectionEnabled","rowSelectionState","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","isAllSelected","onToggleAll","newSelectedRows","map","item","$primaryKey","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","rowSelection","hasSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\nexport interface UseRowSelectionProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (\n rowId: string,\n rowIndex: number,\n isShiftClick?: boolean,\n ) => void;\n}\n\nexport function useRowSelection<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n onRowSelection,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n // The rowSelectionState in uncontrolled mode\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\n\n // Used for shift-click behavior in \"multiple\" mode\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const isSelectionEnabled = selectionMode !== \"none\";\n\n // Row selection state\n // If controlled mode, return the state from selectedRows prop\n // If uncontrolled, return the internalRowSelection state\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!isSelectionEnabled) return {};\n if (isControlled && selectedRows) {\n return getRowSelectionState(selectedRows);\n }\n return internalRowSelection;\n }, [\n isSelectionEnabled,\n isControlled,\n selectedRows,\n internalRowSelection,\n ]);\n\n const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;\n const totalCount = data?.length ?? 0;\n const isAllSelected = totalCount > 0 && selectedCount === totalCount;\n const hasSelection = selectedCount > 0;\n\n const onToggleAll = useCallback(() => {\n if (!isSelectionEnabled || !data) return;\n\n const newSelectedRows: PrimaryKeyType<Q>[] = isAllSelected\n ? []\n : data.map(item => item.$primaryKey);\n\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n }, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!isSelectionEnabled || !data) return;\n\n let newSelectedRows: PrimaryKeyType<Q>[] = [];\n\n if (selectionMode === \"single\") {\n newSelectedRows = getSingleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n setLastSelectedRowIndex(rowIndex);\n } else {\n // Multiple selection mode\n\n // When user does shiftClick but lastSelectedRowIndex is null,\n // it is treated as a normal click in multiple selection\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows(\n { rowId, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n }\n setLastSelectedRowIndex(rowIndex);\n }\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n },\n [\n isSelectionEnabled,\n data,\n selectionMode,\n lastSelectedRowIndex,\n isControlled,\n rowSelectionState,\n onRowSelection,\n ],\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { rowId, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n // Toggle row selection in single selection mode\n const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];\n return newSelectedRows;\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { lastSelectedRowIndex, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n // This function is only called if lastSelectedRowIndex is not null\n // This condition is added for typechecks only\n if (lastSelectedRowIndex != null) {\n const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);\n const primaryKeysInRange = rowsInRange.map(item => item.$primaryKey);\n\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n\n // Add all rows in range to selectedRows if not yet selected\n const newSelectedRows = [...currentlySelected];\n primaryKeysInRange.forEach(item => {\n if (!newSelectedRows.includes(item)) {\n newSelectedRows.push(item);\n }\n });\n return newSelectedRows;\n }\n return [];\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n { rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n // Handles single row toggle in multiple selection mode\n const newSelectedRows = currentlySelected.includes(primaryKey)\n ? currentlySelected.filter(i => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n return newSelectedRows;\n}\n\n/**\n * Builds a range of rows from startIndex to endIndex\n */\nfunction getRowsInRange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>,\n startIndex: number,\n endIndex: number,\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>> = [];\n\n for (let i = start; i <= end; i++) {\n const item = data[i];\n if (item) {\n rows.push(item);\n }\n }\n\n return rows;\n}\n\n/**\n * Converts an array of primary keys to a RowSelectionState object\n */\nfunction getRowSelectionState<Q extends ObjectOrInterfaceDefinition>(\n primaryKeys: PrimaryKeyType<Q>[],\n): RowSelectionState {\n return primaryKeys.reduce<RowSelectionState>(\n (acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n },\n {},\n );\n}\n\n/**\n * Converts from a RowSelectionState object back to an array of primary keys\n */\nfunction getSelectedPrimaryKeys<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, any> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", any, RDPs>>,\n): PrimaryKeyType<Q>[] {\n return data\n .filter(item => selectionState[getRowId(item)])\n .map(item => item.$primaryKey);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,sBAAsB;AAwBvE,OAAO,SAASC,eAAeA,CAG7B;EACAC,aAAa,GAAG,MAAM;EACtBC,YAAY;EACZC,c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js","names":["useCallback","useMemo","useState","getRowId","getRowIdFromPrimaryKey","useRowSelection","selectionMode","selectedRows","onRowSelection","data","internalRowSelection","setInternalRowSelection","lastSelectedRowIndex","setLastSelectedRowIndex","isControlled","undefined","enableRowSelection","rowSelectionState","getRowSelectionState","selectedCount","Object","values","filter","Boolean","length","totalCount","isAllSelected","onToggleAll","newSelectedRows","map","item","$primaryKey","onToggleRow","rowId","rowIndex","isShiftClick","getSingleSelectionRows","getRangeSelectionRows","getMultipleSelectionRows","rowSelection","hasSelection","primaryKey","rowsInRange","getRowsInRange","primaryKeysInRange","currentlySelected","getSelectedPrimaryKeys","forEach","includes","push","i","startIndex","endIndex","start","Math","min","end","max","rows","primaryKeys","reduce","acc","selectionState"],"sources":["useRowSelection.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport type { RowSelectionState } from \"@tanstack/react-table\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { getRowId, getRowIdFromPrimaryKey } from \"../utils/getRowId.js\";\n\nexport interface UseRowSelectionProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n selectedRows?: PrimaryKeyType<Q>[];\n onRowSelection?: (selectedRowIds: PrimaryKeyType<Q>[]) => void;\n data:\n | Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>\n | undefined;\n}\n\nexport interface UseRowSelectionResult {\n rowSelection: RowSelectionState;\n isAllSelected: boolean;\n hasSelection: boolean;\n enableRowSelection: boolean;\n onToggleAll: () => void;\n onToggleRow: (\n rowId: string,\n rowIndex: number,\n isShiftClick?: boolean,\n ) => void;\n}\n\nexport function useRowSelection<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>({\n selectionMode = \"none\",\n selectedRows,\n onRowSelection,\n data,\n}: UseRowSelectionProps<Q, RDPs>): UseRowSelectionResult {\n // The rowSelectionState in uncontrolled mode\n const [internalRowSelection, setInternalRowSelection] = useState<\n RowSelectionState\n >({});\n\n // Used for shift-click behavior in \"multiple\" mode\n const [lastSelectedRowIndex, setLastSelectedRowIndex] = useState<\n number | null\n >(null);\n\n const isControlled = selectedRows !== undefined;\n const enableRowSelection = selectionMode !== \"none\";\n\n // Row selection state\n // If controlled mode, return the state from selectedRows prop\n // If uncontrolled, return the internalRowSelection state\n const rowSelectionState: RowSelectionState = useMemo(() => {\n if (!enableRowSelection) return {};\n if (isControlled && selectedRows) {\n return getRowSelectionState(selectedRows);\n }\n return internalRowSelection;\n }, [\n enableRowSelection,\n isControlled,\n selectedRows,\n internalRowSelection,\n ]);\n\n const selectedCount = Object.values(rowSelectionState).filter(Boolean).length;\n const totalCount = data?.length ?? 0;\n const isAllSelected = totalCount > 0 && selectedCount === totalCount;\n const hasSelection = selectedCount > 0;\n\n const onToggleAll = useCallback(() => {\n if (!enableRowSelection || !data) return;\n\n const newSelectedRows: PrimaryKeyType<Q>[] = isAllSelected\n ? []\n : data.map(item => item.$primaryKey);\n\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n }, [enableRowSelection, data, isAllSelected, isControlled, onRowSelection]);\n\n const onToggleRow = useCallback(\n (rowId: string, rowIndex: number, isShiftClick: boolean = false) => {\n if (!enableRowSelection || !data) return;\n\n let newSelectedRows: PrimaryKeyType<Q>[] = [];\n\n if (selectionMode === \"single\") {\n newSelectedRows = getSingleSelectionRows({\n rowId,\n rowIndex,\n data,\n rowSelectionState,\n });\n setLastSelectedRowIndex(rowIndex);\n } else {\n // Multiple selection mode\n\n // When user does shiftClick but lastSelectedRowIndex is null,\n // it is treated as a normal click in multiple selection\n if (isShiftClick && lastSelectedRowIndex != null) {\n newSelectedRows = getRangeSelectionRows(\n { rowId, rowIndex, data, lastSelectedRowIndex, rowSelectionState },\n );\n } else {\n newSelectedRows = getMultipleSelectionRows(\n { rowId, rowIndex, data, rowSelectionState },\n );\n }\n setLastSelectedRowIndex(rowIndex);\n }\n if (!isControlled) {\n setInternalRowSelection(getRowSelectionState(newSelectedRows));\n }\n onRowSelection?.(newSelectedRows);\n },\n [\n enableRowSelection,\n data,\n selectionMode,\n lastSelectedRowIndex,\n isControlled,\n rowSelectionState,\n onRowSelection,\n ],\n );\n\n return {\n rowSelection: rowSelectionState,\n isAllSelected,\n enableRowSelection,\n hasSelection,\n onToggleAll,\n onToggleRow,\n };\n}\n\ninterface GetSelectedRowsProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n rowId: string;\n rowIndex: number;\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>;\n rowSelectionState: RowSelectionState;\n lastSelectedRowIndex?: number;\n}\n\nfunction getSingleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { rowId, rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n // Toggle row selection in single selection mode\n const newSelectedRows = rowSelectionState[rowId] ? [] : [primaryKey];\n return newSelectedRows;\n}\n\nfunction getRangeSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { lastSelectedRowIndex, rowIndex, data, rowSelectionState }:\n GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n // This function is only called if lastSelectedRowIndex is not null\n // This condition is added for typechecks only\n if (lastSelectedRowIndex != null) {\n const rowsInRange = getRowsInRange(data, lastSelectedRowIndex, rowIndex);\n const primaryKeysInRange = rowsInRange.map(item => item.$primaryKey);\n\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n\n // Add all rows in range to selectedRows if not yet selected\n const newSelectedRows = [...currentlySelected];\n primaryKeysInRange.forEach(item => {\n if (!newSelectedRows.includes(item)) {\n newSelectedRows.push(item);\n }\n });\n return newSelectedRows;\n }\n return [];\n}\n\nfunction getMultipleSelectionRows<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n { rowIndex, data, rowSelectionState }: GetSelectedRowsProps<Q, RDPs>,\n): PrimaryKeyType<Q>[] {\n const primaryKey = data[rowIndex].$primaryKey;\n const currentlySelected = getSelectedPrimaryKeys(rowSelectionState, data);\n // Handles single row toggle in multiple selection mode\n const newSelectedRows = currentlySelected.includes(primaryKey)\n ? currentlySelected.filter(i => i !== primaryKey)\n : [...currentlySelected, primaryKey];\n return newSelectedRows;\n}\n\n/**\n * Builds a range of rows from startIndex to endIndex\n */\nfunction getRowsInRange<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>,\n startIndex: number,\n endIndex: number,\n): Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>> {\n const start = Math.min(startIndex, endIndex);\n const end = Math.max(startIndex, endIndex);\n const rows: Array<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>\n > = [];\n\n for (let i = start; i <= end; i++) {\n const item = data[i];\n if (item) {\n rows.push(item);\n }\n }\n\n return rows;\n}\n\n/**\n * Converts an array of primary keys to a RowSelectionState object\n */\nfunction getRowSelectionState<Q extends ObjectOrInterfaceDefinition>(\n primaryKeys: PrimaryKeyType<Q>[],\n): RowSelectionState {\n return primaryKeys.reduce<RowSelectionState>(\n (acc, primaryKey) => {\n acc[getRowIdFromPrimaryKey(primaryKey)] = true;\n return acc;\n },\n {},\n );\n}\n\n/**\n * Converts from a RowSelectionState object back to an array of primary keys\n */\nfunction getSelectedPrimaryKeys<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n selectionState: RowSelectionState,\n data: Array<Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>>,\n): PrimaryKeyType<Q>[] {\n return data\n .filter(item => selectionState[getRowId(item)])\n .map(item => item.$primaryKey);\n}\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,CAAC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AU,EAAEC,QAAQ,CAAC;EAC1C,MAAMM,IAEL,GAAG,EAAE;EAEN,KAAK,IAAIR,CAAC,GAAGG,KAAK,EAAEH,CAAC,IAAIM,GAAG,EAAEN,CAAC,EAAE,EAAE;IACjC,MAAMpB,IAAI,GAAGrB,IAAI,CAACyC,CAAC,CAAC;IACpB,IAAIpB,IAAI,EAAE;MACR4B,IAAI,CAACT,IAAI,CAACnB,IAAI,CAAC;IACjB;EACF;EAEA,OAAO4B,IAAI;AACb;;AAEA;AACA;AACA;AACA,SAASxC,oBAAoBA,CAC3ByC,WAAgC,EACb;EACnB,OAAOA,WAAW,CAACC,MAAM,CACvB,CAACC,GAAG,EAAEpB,UAAU,KAAK;IACnBoB,GAAG,CAACzD,sBAAsB,CAACqC,UAAU,CAAC,CAAC,GAAG,IAAI;IAC9C,OAAOoB,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASf,sBAAsBA,CAI7BgB,cAAiC,EACjCrD,IAA0E,EACrD;EACrB,OAAOA,IAAI,CACRa,MAAM,CAACQ,IAAI,IAAIgC,cAAc,CAAC3D,QAAQ,CAAC2B,IAAI,CAAC,CAAC,CAAC,CAC9CD,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,WAAW,CAAC;AAClC","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { useMemo } from "react";
|
|
17
|
+
import React, { useMemo, useRef } from "react";
|
|
18
18
|
import { SelectionCell, SelectionHeaderCell } from "../SelectionCells.js";
|
|
19
19
|
import { SELECTION_COLUMN_ID } from "../utils/constants.js";
|
|
20
20
|
export const useSelectionColumn = ({
|
|
@@ -24,20 +24,29 @@ export const useSelectionColumn = ({
|
|
|
24
24
|
onToggleAll,
|
|
25
25
|
onToggleRow
|
|
26
26
|
}) => {
|
|
27
|
+
// TODO: Replace with useLatestRef
|
|
28
|
+
const isAllSelectedRef = useRef(isAllSelected);
|
|
29
|
+
isAllSelectedRef.current = isAllSelected;
|
|
30
|
+
const hasSelectionRef = useRef(hasSelection);
|
|
31
|
+
hasSelectionRef.current = hasSelection;
|
|
32
|
+
const onToggleAllRef = useRef(onToggleAll);
|
|
33
|
+
onToggleAllRef.current = onToggleAll;
|
|
34
|
+
const onToggleRowRef = useRef(onToggleRow);
|
|
35
|
+
onToggleRowRef.current = onToggleRow;
|
|
27
36
|
const selectionColumn = useMemo(() => {
|
|
28
37
|
if (selectionMode === "none") return null;
|
|
29
38
|
return {
|
|
30
39
|
id: SELECTION_COLUMN_ID,
|
|
31
40
|
header: () => selectionMode === "multiple" ? /*#__PURE__*/React.createElement(SelectionHeaderCell, {
|
|
32
|
-
isAllSelected:
|
|
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,CAAC;EAC9CI,gBAAgB,CAACC,OAAO,GAAGL,aAAa;EAExC,MAAMM,eAAe,GAAGZ,MAAM,CAACO,YAAY,CAAC;EAC5CK,eAAe,CAACD,OAAO,GAAGJ,YAAY;EAEtC,MAAMM,cAAc,GAAGb,MAAM,CAACQ,WAAW,CAAC;EAC1CK,cAAc,CAACF,OAAO,GAAGH,WAAW;EAEpC,MAAMM,cAAc,GAAGd,MAAM,CAACS,WAAW,CAAC;EAC1CK,cAAc,CAACH,OAAO,GAAGF,WAAW;EAEpC,MAAMM,eAAe,GAAGhB,OAAO,CAAC,MAAM;IACpC,IAAIM,aAAa,KAAK,MAAM,EAAE,OAAO,IAAI;IA+BzC,OA3BI;MACFW,EAAE,EAAEb,mBAAmB;MACvBc,MAAM,EAAEA,CAAA,KACNZ,aAAa,KAAK,UAAU,gBAExBP,KAAA,CAAAoB,aAAA,CAAChB,mBAAmB;QAClBI,aAAa,EAAEI,gBAAgB,CAACC,OAAQ;QACxCJ,YAAY,EAAEK,eAAe,CAACD,OAAQ;QACtCH,WAAW,EAAEK,cAAc,CAACF;MAAQ,CACrC,CAAC,GAEF,IACL;MACDQ,IAAI,EAAEA,CAAC;QAAEC;MAAkB,CAAC,kBAC1BtB,KAAA,CAAAoB,aAAA,CAACjB,aAAa;QACZmB,GAAG,EAAEA,GAAI;QACTX,WAAW,EAAEK,cAAc,CAACH;MAAQ,CACrC,CACF;MACDU,IAAI,EAAE,EAAE;MACRC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,aAAa,EAAE,KAAK;MACpBC,cAAc,EAAE,KAAK;MACrBC,aAAa,EAAE;IACjB,CAAC;EAGH,CAAC,EAAE,CACDrB,aAAa,CACd,CAAC;EAEF,OAAOU,eAAe;AACxB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface ColumnOption {\n id: string;\n name: string;\n canSort: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -20,4 +20,5 @@ export { ObjectTable } from "../object-table/ObjectTable.js";
|
|
|
20
20
|
// BaseTable that does not handle data fetching
|
|
21
21
|
|
|
22
22
|
export { BaseTable } from "../object-table/Table.js";
|
|
23
|
+
export { ColumnConfigDialog } from "../object-table/ColumnConfigDialog.js";
|
|
23
24
|
//# sourceMappingURL=experimental.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["ObjectTable","BaseTable"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,SAASA,WAAW,QAAQ,gCAAgC;;AAO5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["ObjectTable","BaseTable","ColumnConfigDialog"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { FilterListProps } from \"../filter-list/FilterListApi.js\";\nexport type { FilterListItemProps } from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n\nexport { ColumnConfigDialog } from \"../object-table/ColumnConfigDialog.js\";\nexport type {\n ColumnConfigDialogProps,\n ColumnConfigOptions,\n} from \"../object-table/ColumnConfigDialog.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,SAASA,WAAW,QAAQ,gCAAgC;;AAO5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAkBA,OAAO,WAAW,OAAQ;AAG1B,iBAAiB,oBACP,MAAM,qBAAqB,mBACrC;CACE,UAAU,YAAY;AACvB;AAED,OAAO,iBAAS,aAAa,EAC3B,SACA,UACA,GAAG,MACS,EAAX,cAAc,MAAM","names":[],"sources":["../../../../src/base-components/action-button/ActionButton.tsx"],"version":3,"file":"ActionButton.d.ts"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Combobox as BaseUICombobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxPopupProps, type ComboboxPositionerProps } from "@base-ui/react/combobox";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface ComboboxInputComponentProps extends Omit<ComboboxInputProps, "className"> {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function ComboboxInput({ className,...rest }: ComboboxInputComponentProps): React.ReactElement;
|
|
7
|
+
interface ComboboxPositionerComponentProps extends Omit<ComboboxPositionerProps, "className"> {
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function ComboboxPositioner({ className, children,...rest }: ComboboxPositionerComponentProps): React.ReactElement;
|
|
11
|
+
interface ComboboxPopupComponentProps extends Omit<ComboboxPopupProps, "className"> {
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function ComboboxPopup({ className, children,...rest }: ComboboxPopupComponentProps): React.ReactElement;
|
|
15
|
+
interface ComboboxItemComponentProps extends Omit<ComboboxItemProps, "className"> {
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function ComboboxItem({ className, children,...rest }: ComboboxItemComponentProps): React.ReactElement;
|
|
19
|
+
declare function ComboboxChips({ children, className }: {
|
|
20
|
+
children: React.ReactNode
|
|
21
|
+
className?: string
|
|
22
|
+
}): React.ReactElement;
|
|
23
|
+
interface ComboboxChipComponentProps extends Omit<ComboboxChipProps, "className"> {
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
declare function ComboboxChip({ className, children,...rest }: ComboboxChipComponentProps): React.ReactElement;
|
|
27
|
+
interface ComboboxChipRemoveComponentProps extends Omit<ComboboxChipRemoveProps, "className"> {
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function ComboboxChipRemove({ className,...rest }: ComboboxChipRemoveComponentProps): React.ReactElement;
|
|
31
|
+
interface ComboboxClearComponentProps extends Omit<ComboboxClearProps, "className"> {
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
declare function ComboboxClear({ className,...rest }: ComboboxClearComponentProps): React.ReactElement;
|
|
35
|
+
declare function ComboboxEmpty({ children, className }: {
|
|
36
|
+
children: React.ReactNode
|
|
37
|
+
className?: string
|
|
38
|
+
}): React.ReactElement;
|
|
39
|
+
export declare const Combobox: {
|
|
40
|
+
Root: typeof BaseUICombobox.Root
|
|
41
|
+
Input: typeof ComboboxInput
|
|
42
|
+
Portal: typeof BaseUICombobox.Portal
|
|
43
|
+
Positioner: typeof ComboboxPositioner
|
|
44
|
+
Popup: typeof ComboboxPopup
|
|
45
|
+
Item: typeof ComboboxItem
|
|
46
|
+
Chips: typeof ComboboxChips
|
|
47
|
+
Chip: typeof ComboboxChip
|
|
48
|
+
ChipRemove: typeof ComboboxChipRemove
|
|
49
|
+
Clear: typeof ComboboxClear
|
|
50
|
+
Empty: typeof ComboboxEmpty
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,SACE,YAAY,qBACP,wBACA,8BACA,yBACA,yBACA,wBACA,yBACA,+BACA,yBAA0B;AAGjC,OAAO,WAAW,OAAQ;UAGhB,oCACA,KAAK,oBAAoB,aACnC;CACE;AACD;AAED,iBAAS,cAAc,EACrB,UACA,GAAG,MACyB,EAA3B,8BAA8B,MAAM;UAY7B,yCACA,KAAK,yBAAyB,aACxC;CACE;AACD;AAED,iBAAS,mBAAmB,EAC1B,WACA,SACA,GAAG,MAC8B,EAAhC,mCAAmC,MAAM;UAYlC,oCACA,KAAK,oBAAoB,aACnC;CACE;AACD;AAED,iBAAS,cAAc,EACrB,WACA,SACA,GAAG,MACyB,EAA3B,8BAA8B,MAAM;UAW7B,mCACA,KAAK,mBAAmB,aAClC;CACE;AACD;AAED,iBAAS,aAAa,EACpB,WACA,SACA,GAAG,MACwB,EAA1B,6BAA6B,MAAM;AAWtC,iBAAS,cAAc,EACrB,UACA,WAID,EAHE;CACD,UAAU,MAAM;CAChB;AACD,IAAG,MAAM;UAUA,mCACA,KAAK,mBAAmB,aAClC;CACE;AACD;AAED,iBAAS,aAAa,EACpB,WACA,SACA,GAAG,MACwB,EAA1B,6BAA6B,MAAM;UAW5B,yCACA,KAAK,yBAAyB,aACxC;CACE;AACD;AAED,iBAAS,mBAAmB,EAC1B,UACA,GAAG,MAC8B,EAAhC,mCAAmC,MAAM;UAYlC,oCACA,KAAK,oBAAoB,aACnC;CACE;AACD;AAED,iBAAS,cAAc,EACrB,UACA,GAAG,MACyB,EAA3B,8BAA8B,MAAM;AAYvC,iBAAS,cAAc,EACrB,UACA,WAID,EAHE;CACD,UAAU,MAAM;CAChB;AACD,IAAG,MAAM;AAUV,OAAO,cAAMA,UAAU;CACrB,aAAa,eAAe;CAC5B,cAAc;CACd,eAAe,eAAe;CAC9B,mBAAmB;CACnB,cAAc;CACd,aAAa;CACb,cAAc;CACd,aAAa;CACb,mBAAmB;CACnB,cAAc;CACd,cAAc;AACf","names":["Combobox: {\n Root: typeof BaseUICombobox.Root;\n Input: typeof ComboboxInput;\n Portal: typeof BaseUICombobox.Portal;\n Positioner: typeof ComboboxPositioner;\n Popup: typeof ComboboxPopup;\n Item: typeof ComboboxItem;\n Chips: typeof ComboboxChips;\n Chip: typeof ComboboxChip;\n ChipRemove: typeof ComboboxChipRemove;\n Clear: typeof ComboboxClear;\n Empty: typeof ComboboxEmpty;\n}"],"sources":["../../../../src/base-components/combobox/Combobox.tsx"],"version":3,"file":"Combobox.d.ts"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DialogProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onOpenChange: () => void;
|
|
5
|
+
title: React.ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
footer?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function Dialog({ isOpen, onOpenChange, title, children, footer, className }: DialogProps): React.ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAmBA,OAAO,WAAW,OAAQ;AAG1B,iBAAiB,YAAY;CAC3B;CACA;CACA,OAAO,MAAM;CACb,UAAU,MAAM;CAChB,SAAS,MAAM;CACf;AACD;AAED,OAAO,iBAAS,OAAO,EACrB,QACA,cACA,OACA,UACA,QACA,WACY,EAAX,cAAc,MAAM","names":[],"sources":["../../../../src/base-components/dialog/Dialog.tsx"],"version":3,"file":"Dialog.d.ts"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DraggableItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
type RemoveIconVariant = "trash" | "cross";
|
|
7
|
+
export interface DraggableListProps<T extends DraggableItem> {
|
|
8
|
+
items: T[];
|
|
9
|
+
onReorder: (fromIndex: number, toIndex: number) => void;
|
|
10
|
+
onRemove: (id: string) => void;
|
|
11
|
+
removeIconVariant?: RemoveIconVariant;
|
|
12
|
+
renderContent?: (item: T) => React.ReactNode;
|
|
13
|
+
emptyMessage?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function DraggableList<T extends DraggableItem>({ items, onReorder, onRemove, removeIconVariant, renderContent, emptyMessage, className }: DraggableListProps<T>): React.ReactElement;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAoCA,OAAO,WAAwD,OAAQ;AAGvE,iBAAiB,cAAc;CAC7B;CACA;AACD;KAEI,oBAAoB,UAAU;AAkEnC,iBAAiB,mBAAmB,UAAU,eAAe;CAC3D,OAAO;CACP,YAAYA,mBAAmBC;CAC/B,WAAWC;CACX,oBAAoB;CACpB,iBAAiBC,MAAM,MAAM,MAAM;CACnC;CACA;AACD;AAED,OAAO,iBAAS,cAAc,UAAU,eAAe,EACrD,OACA,WACA,UACA,mBACA,eACA,cACA,WACsB,EAArB,mBAAmB,KAAK,MAAM","names":["fromIndex: number","toIndex: number","id: string","item: T"],"sources":["../../../../src/base-components/draggable-list/DraggableList.tsx"],"version":3,"file":"DraggableList.d.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SearchBarProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function SearchBar({ value, onChange, placeholder, "aria-label": ariaLabel, className, onKeyDown }: SearchBarProps): React.ReactElement;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAmBA,OAAO,WAAW,OAAQ;UAGhB,eAAe;CACvB;CACA,WAAWA,OAAO,MAAM,YAAY;CACpC;CACA;CACA;CACA,aAAaC,OAAO,MAAM,cAAc;AACzC;AAED,OAAO,iBAAS,UAAU,EACxB,OACA,UACA,aACA,cAAc,WACd,WACA,WACe,EAAd,iBAAiB,MAAM","names":["event: React.ChangeEvent<HTMLInputElement>","event: React.KeyboardEvent<HTMLInputElement>"],"sources":["../../../../src/base-components/search-bar/SearchBar.tsx"],"version":3,"file":"SearchBar.d.ts"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Select as BaseUISelect, type SelectItemProps, type SelectPopupProps, type SelectPositionerProps, type SelectRootProps, type SelectTriggerProps, type SelectValueProps } from "@base-ui/react/select";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface SelectProps<Value extends string | number> extends Omit<SelectRootProps<Value, false>, "className" | "multiple"> {}
|
|
4
|
+
declare function SelectRoot<Value extends string | number>({ children,...rest }: SelectProps<Value>): React.ReactElement;
|
|
5
|
+
interface SelectTriggerComponentProps extends Omit<SelectTriggerProps, "className"> {
|
|
6
|
+
className?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function SelectTrigger({ className, placeholder, children,...rest }: SelectTriggerComponentProps): React.ReactElement;
|
|
10
|
+
declare function SelectValue(props: Omit<SelectValueProps, "className"> & {
|
|
11
|
+
className?: string
|
|
12
|
+
}): React.ReactElement;
|
|
13
|
+
interface SelectPositionerComponentProps extends Omit<SelectPositionerProps, "className"> {
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function SelectPositioner({ className, children,...rest }: SelectPositionerComponentProps): React.ReactElement;
|
|
17
|
+
interface SelectPopupComponentProps extends Omit<SelectPopupProps, "className"> {
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
declare function SelectPopup({ className, children,...rest }: SelectPopupComponentProps): React.ReactElement;
|
|
21
|
+
interface SelectItemComponentProps extends Omit<SelectItemProps, "className"> {
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
declare function SelectItem({ className, children,...rest }: SelectItemComponentProps): React.ReactElement;
|
|
25
|
+
export declare const Select: {
|
|
26
|
+
Root: typeof SelectRoot
|
|
27
|
+
Trigger: typeof SelectTrigger
|
|
28
|
+
Value: typeof SelectValue
|
|
29
|
+
Portal: typeof BaseUISelect.Portal
|
|
30
|
+
Positioner: typeof SelectPositioner
|
|
31
|
+
Popup: typeof SelectPopup
|
|
32
|
+
Item: typeof SelectItem
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,SACE,UAAU,mBACL,sBACA,uBACA,4BACA,sBACA,yBACA,wBACA,uBAAwB;AAG/B,OAAO,WAAW,OAAQ;AAG1B,iBAAiB,YAAY,uCACnB,KAAK,gBAAgB,OAAO,QAAQ,cAAc,YAC5D,CAAE;AAEF,iBAAS,WAAW,+BAA+B,EACjD,SACA,GAAG,MACgB,EAAlB,YAAY,SAAS,MAAM;UAQpB,oCACA,KAAK,oBAAoB,aACnC;CACE;CACA;AACD;AAED,iBAAS,cAAc,EACrB,WACA,aACA,SACA,GAAG,MACyB,EAA3B,8BAA8B,MAAM;AAoBvC,iBAAS,YACPA,OAAO,KAAK,kBAAkB,eAAe;CAAE;AAAoB,IAClE,MAAM;UAUC,uCACA,KAAK,uBAAuB,aACtC;CACE;AACD;AAED,iBAAS,iBAAiB,EACxB,WACA,SACA,GAAG,MAC4B,EAA9B,iCAAiC,MAAM;UAYhC,kCACA,KAAK,kBAAkB,aACjC;CACE;AACD;AAED,iBAAS,YAAY,EACnB,WACA,SACA,GAAG,MACuB,EAAzB,4BAA4B,MAAM;UAW3B,iCAAiC,KAAK,iBAAiB,aAAa;CAC5E;AACD;AAED,iBAAS,WAAW,EAClB,WACA,SACA,GAAG,MACsB,EAAxB,2BAA2B,MAAM;AAWpC,OAAO,cAAMC,QAAQ;CACnB,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,eAAe,aAAa;CAC5B,mBAAmB;CACnB,cAAc;CACd,aAAa;AACd","names":["props: Omit<SelectValueProps, \"className\"> & { className?: string }","Select: {\n Root: typeof SelectRoot;\n Trigger: typeof SelectTrigger;\n Value: typeof SelectValue;\n Portal: typeof BaseUISelect.Portal;\n Positioner: typeof SelectPositioner;\n Popup: typeof SelectPopup;\n Item: typeof SelectItem;\n}"],"sources":["../../../../src/base-components/select/Select.tsx"],"version":3,"file":"Select.d.ts"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SwitchRootProps, type SwitchThumbProps } from "@base-ui/react/switch";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface SwitchProps extends Omit<SwitchRootProps, "className"> {
|
|
4
|
+
className?: string;
|
|
5
|
+
thumbProps?: Omit<SwitchThumbProps, "className"> & {
|
|
6
|
+
className?: string
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function Switch({ className, thumbProps,...rest }: SwitchProps): React.ReactElement;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAEO,sBACA,wBACA,uBAAwB;AAE/B,OAAO,WAAW,OAAQ;UAGhB,oBAAoB,KAAK,iBAAiB,aAAa;CAC/D;CACA,aAAa,KAAK,kBAAkB,eAAe;EACjD;CACD;AACF;AAED,OAAO,iBAAS,OAAO,EACrB,WACA,WACA,GAAG,MACS,EAAX,cAAc,MAAM","names":[],"sources":["../../../../src/base-components/switch/Switch.tsx"],"version":3,"file":"Switch.d.ts"}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import type { ObjectSet, ObjectTypeDefinition, WhereClause } from "@osdk/api";
|
|
2
|
-
import type {
|
|
1
|
+
import type { LinkNames, ObjectSet, ObjectTypeDefinition, WhereClause } from "@osdk/api";
|
|
2
|
+
import type { FilterState as FilterStateType, PropertyFilterDefinition } from "./FilterListItemApi.js";
|
|
3
|
+
import type { FilterTemplate } from "./types/AddFilterMenuTypes.js";
|
|
4
|
+
import type { CustomFilterDefinition } from "./types/CustomRendererTypes.js";
|
|
5
|
+
import type { KeywordSearchFilterDefinition } from "./types/KeywordSearchTypes.js";
|
|
6
|
+
import type { HasLinkFilterDefinition, LinkedPropertyFilterDefinition } from "./types/LinkedFilterTypes.js";
|
|
7
|
+
/**
|
|
8
|
+
* Union type of all filter definition types
|
|
9
|
+
*/
|
|
10
|
+
export type FilterDefinitionUnion<Q extends ObjectTypeDefinition> = PropertyFilterDefinition<Q> | HasLinkFilterDefinition<Q> | LinkedPropertyFilterDefinition<Q, LinkNames<Q>> | KeywordSearchFilterDefinition<Q> | CustomFilterDefinition<Q>;
|
|
11
|
+
/**
|
|
12
|
+
* Extract the key from a filter definition union
|
|
13
|
+
*/
|
|
14
|
+
export type FilterKey<Q extends ObjectTypeDefinition> = FilterDefinitionUnion<Q> extends infer D ? D extends {
|
|
15
|
+
key: infer K
|
|
16
|
+
} ? K : D extends {
|
|
17
|
+
linkName: infer L
|
|
18
|
+
} ? L : never : never;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the filter state from a filter definition union
|
|
21
|
+
*/
|
|
22
|
+
export type FilterState<Q extends ObjectTypeDefinition> = FilterDefinitionUnion<Q> extends infer D ? D extends {
|
|
23
|
+
filterState: infer S
|
|
24
|
+
} ? S : never : never;
|
|
25
|
+
/**
|
|
26
|
+
* Map from filter definition objects to their current state.
|
|
27
|
+
* Uses object identity for keys, ensuring stable lookups across reorders.
|
|
28
|
+
*/
|
|
29
|
+
export type FilterStatesMap<Q extends ObjectTypeDefinition> = Map<FilterDefinitionUnion<Q>, FilterStateType>;
|
|
3
30
|
export interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
4
31
|
/**
|
|
5
32
|
* The set of objects to be filtered
|
|
@@ -9,7 +36,7 @@ export interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
|
9
36
|
* The definition for all supported filter items in the list
|
|
10
37
|
* If not supplied, all filterable properties will be available
|
|
11
38
|
*/
|
|
12
|
-
filterDefinitions?: Array<
|
|
39
|
+
filterDefinitions?: Array<FilterDefinitionUnion<Q>>;
|
|
13
40
|
/**
|
|
14
41
|
* The current where clause to filter the objectSet.
|
|
15
42
|
* If provided, the filter clause is controlled.
|
|
@@ -30,12 +57,12 @@ export interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
|
30
57
|
*/
|
|
31
58
|
filterOperator?: "and" | "or";
|
|
32
59
|
/**
|
|
33
|
-
* Called when filter state
|
|
60
|
+
* Called when filter state changes
|
|
34
61
|
*
|
|
35
|
-
* @param
|
|
62
|
+
* @param definition The filter definition whose state changed
|
|
36
63
|
* @param newState The updated filter state
|
|
37
64
|
*/
|
|
38
|
-
onFilterStateChanged?: (
|
|
65
|
+
onFilterStateChanged?: (definition: FilterDefinitionUnion<Q>, newState: FilterStateType) => void;
|
|
39
66
|
/**
|
|
40
67
|
* Called when a filter is added
|
|
41
68
|
* If provided, user will be allowed to add filters
|
|
@@ -43,7 +70,7 @@ export interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
|
43
70
|
* @param filterKey The key of the added filter
|
|
44
71
|
* @param newDefinitions The filter list with the new filter added
|
|
45
72
|
*/
|
|
46
|
-
onFilterAdded?: (filterKey: FilterKey<Q>, newDefinitions: Array<
|
|
73
|
+
onFilterAdded?: (filterKey: FilterKey<Q>, newDefinitions: Array<FilterDefinitionUnion<Q>>) => void;
|
|
47
74
|
/**
|
|
48
75
|
* Called when a filter is removed
|
|
49
76
|
* If provided, user will be allowed to remove filters
|
|
@@ -51,15 +78,39 @@ export interface FilterListProps<Q extends ObjectTypeDefinition> {
|
|
|
51
78
|
* @param filterKey The key of the removed filter
|
|
52
79
|
* @param newDefinitions The updated filter list with the filter removed
|
|
53
80
|
*/
|
|
54
|
-
onFilterRemoved?: (filterKey: FilterKey<Q>, newDefinitions: Array<
|
|
81
|
+
onFilterRemoved?: (filterKey: FilterKey<Q>, newDefinitions: Array<FilterDefinitionUnion<Q>>) => void;
|
|
55
82
|
/**
|
|
56
83
|
* Called when filters are reordered
|
|
57
84
|
* If provided, the filter list becomes sortable
|
|
58
85
|
*
|
|
59
86
|
* @param newOrder The updated filter definitions in new order
|
|
60
87
|
*/
|
|
61
|
-
onFiltersReordered?: (newOrder: ReadonlyArray<
|
|
88
|
+
onFiltersReordered?: (newOrder: ReadonlyArray<FilterDefinitionUnion<Q>>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Show reset filters button in header
|
|
91
|
+
*/
|
|
92
|
+
showResetButton?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Called when reset button is clicked
|
|
95
|
+
*/
|
|
96
|
+
onReset?: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Available filter templates for the "Add filter" menu.
|
|
99
|
+
* When provided along with onFilterAdded, clicking the add button
|
|
100
|
+
* shows a popover with these templates organized by category.
|
|
101
|
+
*/
|
|
102
|
+
filterTemplates?: FilterTemplate[];
|
|
103
|
+
/**
|
|
104
|
+
* Called when a filter template is selected from the add filter menu.
|
|
105
|
+
* The consumer should create a new filter definition and add it to filterDefinitions.
|
|
106
|
+
*/
|
|
107
|
+
onFilterTemplateSelected?: (template: FilterTemplate) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Show count of active filters in header
|
|
110
|
+
*/
|
|
111
|
+
showActiveFilterCount?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Additional CSS class name
|
|
114
|
+
*/
|
|
115
|
+
className?: string;
|
|
62
116
|
}
|
|
63
|
-
type FilterKey<Q extends ObjectTypeDefinition> = FilterDefinition<Q>["key"];
|
|
64
|
-
type FilterState<Q extends ObjectTypeDefinition> = FilterDefinition<Q>["filterState"];
|
|
65
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,WAAW,sBAAsB,
|
|
1
|
+
{"mappings":"AAgBA,cACE,WACA,WACA,sBACA,mBACK,WAAY;AACnB,cACE,eAAe,iBACf,gCACK,wBAAyB;AAChC,cAAc,sBAAsB,+BAAgC;AACpE,cAAc,8BAA8B,gCAAiC;AAC7E,cAAc,qCAAqC,+BAAgC;AACnF,cACE,yBACA,sCACK,8BAA+B;;;;AAKtC,YAAY,sBAAsB,UAAU,wBACxC,yBAAyB,KACzB,wBAAwB,KACxB,+BAA+B,GAAG,UAAU,MAC5C,8BAA8B,KAC9B,uBAAuB;;;;AAK3B,YAAY,UAAU,UAAU,wBAC9B,sBAAsB,iBAAiB,IAAI,UAAU;CAAE,WAAW;AAAG,IAAG,IACpE,UAAU;CAAE,gBAAgB;AAAG,IAAG;;;;AAOxC,YAAY,YAAY,UAAU,wBAChC,sBAAsB,iBAAiB,IACnC,UAAU;CAAE,mBAAmB;AAAG,IAAG;;;;;AAQ3C,YAAY,gBAAgB,UAAU,wBAAwB,IAC5D,sBAAsB,IACtB;AAGF,iBAAiB,gBAAgB,UAAU,sBAAsB;;;;CAI/D,WAAW,UAAU;;;;;CAMrB,oBAAoB,MAAM,sBAAsB;;;;;CAMhD,eAAe,YAAY;;;;;;;;CAS3B,yBAAyBA,WAAW,YAAY;;;;;;CAOhD,iBAAiB,QAAQ;;;;;;;CAQzB,wBACEC,YAAY,sBAAsB,IAClCC,UAAU;;;;;;;;CAUZ,iBACEC,WAAW,UAAU,IACrBC,gBAAgB,MAAM,sBAAsB;;;;;;;;CAU9C,mBACED,WAAW,UAAU,IACrBC,gBAAgB,MAAM,sBAAsB;;;;;;;CAS9C,sBACEC,UAAU,cAAc,sBAAsB;;;;CAMhD;;;;CAKA;;;;;;CAOA,kBAAkB;;;;;CAMlB,4BAA4BC,UAAU;;;;CAKtC;;;;CAKA;AACD","names":["newClause: WhereClause<Q>","definition: FilterDefinitionUnion<Q>","newState: FilterStateType","filterKey: FilterKey<Q>","newDefinitions: Array<FilterDefinitionUnion<Q>>","newOrder: ReadonlyArray<FilterDefinitionUnion<Q>>","template: FilterTemplate"],"sources":["../../../src/filter-list/FilterListApi.ts"],"version":3,"file":"FilterListApi.d.ts"}
|