@rivet-health/design-system 40.35.1 → 40.35.2
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/esm2020/lib/table/table/state-helpers/search-helpers.mjs +45 -1
- package/esm2020/lib/table/table/state.mjs +9 -66
- package/fesm2015/rivet-health-design-system.mjs +56 -59
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +52 -65
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/lib/table/table/state-helpers/search-helpers.d.ts +12 -0
- package/package.json +1 -1
|
@@ -8657,6 +8657,48 @@ var TableResultHelpers;
|
|
|
8657
8657
|
|
|
8658
8658
|
var TableSearchHelpers;
|
|
8659
8659
|
(function (TableSearchHelpers) {
|
|
8660
|
+
/**
|
|
8661
|
+
* The configured fuse options, without the keys for columns search does not
|
|
8662
|
+
* cover: the ones marked `searchable: false` and the ones turned off in
|
|
8663
|
+
* "Search in". Keys that don't belong to a column are left alone.
|
|
8664
|
+
*/
|
|
8665
|
+
function fuseOptionsForSearchColumns(fuseOptions, columns, query) {
|
|
8666
|
+
if (!(fuseOptions === null || fuseOptions === void 0 ? void 0 : fuseOptions.keys))
|
|
8667
|
+
return fuseOptions;
|
|
8668
|
+
const excludedPaths = new Set(Array.from(columns.entries())
|
|
8669
|
+
.filter(([key, column]) => column.searchable === false ||
|
|
8670
|
+
query.searchColumns.get(key) === false)
|
|
8671
|
+
.map(([key, column]) => columnPath(key, column)));
|
|
8672
|
+
return Object.assign(Object.assign({}, fuseOptions), { keys: fuseOptions.keys.filter(key => !excludedPaths.has(fuseKeyPath(key))) });
|
|
8673
|
+
}
|
|
8674
|
+
TableSearchHelpers.fuseOptionsForSearchColumns = fuseOptionsForSearchColumns;
|
|
8675
|
+
/**
|
|
8676
|
+
* Marks the columns with no key in `fuseOptions.keys` as `searchable: false`,
|
|
8677
|
+
* so "Search in" only offers columns that search can cover.
|
|
8678
|
+
*/
|
|
8679
|
+
function markColumnsOutsideFuseKeysUnsearchable(columns, fuseOptions) {
|
|
8680
|
+
if (!(fuseOptions === null || fuseOptions === void 0 ? void 0 : fuseOptions.keys))
|
|
8681
|
+
return columns;
|
|
8682
|
+
const keyPaths = new Set(fuseOptions.keys.map(fuseKeyPath));
|
|
8683
|
+
return new Map(Array.from(columns.entries()).map(([key, column]) => [
|
|
8684
|
+
key,
|
|
8685
|
+
keyPaths.has(columnPath(key, column))
|
|
8686
|
+
? column
|
|
8687
|
+
: Object.assign(Object.assign({}, column), { searchable: false }),
|
|
8688
|
+
]));
|
|
8689
|
+
}
|
|
8690
|
+
TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable = markColumnsOutsideFuseKeysUnsearchable;
|
|
8691
|
+
function columnPath(key, column) {
|
|
8692
|
+
var _a, _b;
|
|
8693
|
+
return (_b = (_a = column.orderKey) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : key.toString();
|
|
8694
|
+
}
|
|
8695
|
+
function fuseKeyPath(key) {
|
|
8696
|
+
if (typeof key === 'string')
|
|
8697
|
+
return key;
|
|
8698
|
+
if (Array.isArray(key))
|
|
8699
|
+
return key.join('.');
|
|
8700
|
+
return Array.isArray(key.name) ? key.name.join('.') : key.name;
|
|
8701
|
+
}
|
|
8660
8702
|
function getSearchColumnsSelectedState(state, expectedValue) {
|
|
8661
8703
|
switch (expectedValue) {
|
|
8662
8704
|
case 'all':
|
|
@@ -9628,41 +9670,19 @@ var RivTable;
|
|
|
9628
9670
|
*/
|
|
9629
9671
|
RivTable.NestedPaginateByOptions = ['bottomRows', 'topRows'];
|
|
9630
9672
|
function createInMemoryManager(fetchDataset, columns, pluralEntityName, options) {
|
|
9673
|
+
columns = TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable(columns, options === null || options === void 0 ? void 0 : options.fuseOptions);
|
|
9631
9674
|
let data;
|
|
9632
9675
|
let fuse;
|
|
9633
9676
|
const source = (query, mostRecentAction) => __awaiter(this, void 0, void 0, function* () {
|
|
9634
|
-
var _a
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
if (mostRecentAction.type === 'load') {
|
|
9638
|
-
//Prevent searching on columns that are in fuse options but not supported by search.
|
|
9639
|
-
const nonSearchableColumnsKeys = ((_a = options === null || options === void 0 ? void 0 : options.fuseOptions) === null || _a === void 0 ? void 0 : _a.keys)
|
|
9640
|
-
? Array.from(columns.entries())
|
|
9641
|
-
.filter(([key, column]) => {
|
|
9642
|
-
return column.searchable == false;
|
|
9643
|
-
})
|
|
9644
|
-
.map(([key, column]) => {
|
|
9645
|
-
var _a;
|
|
9646
|
-
return ((_a = column.orderKey) === null || _a === void 0 ? void 0 : _a.toString()) || key.toString();
|
|
9647
|
-
})
|
|
9648
|
-
: undefined;
|
|
9649
|
-
const fuseOptions = (options === null || options === void 0 ? void 0 : options.fuseOptions) && nonSearchableColumnsKeys
|
|
9650
|
-
? Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.fuseOptions), { keys: (_c = (_b = options === null || options === void 0 ? void 0 : options.fuseOptions) === null || _b === void 0 ? void 0 : _b.keys) === null || _c === void 0 ? void 0 : _c.filter(k => !nonSearchableColumnsKeys.includes(k.toString())) }) : options === null || options === void 0 ? void 0 : options.fuseOptions;
|
|
9651
|
-
data = yield fetchDataset();
|
|
9652
|
-
fuse = new Fuse(data, fuseOptions);
|
|
9653
|
-
}
|
|
9654
|
-
if (mostRecentAction.type === 'searchColumnsChange' ||
|
|
9677
|
+
var _a;
|
|
9678
|
+
if (mostRecentAction.type === 'load' ||
|
|
9679
|
+
mostRecentAction.type === 'searchColumnsChange' ||
|
|
9655
9680
|
mostRecentAction.type === 'toggleAllSearchColumns') {
|
|
9656
9681
|
data = yield fetchDataset();
|
|
9657
|
-
fuse = new Fuse(data,
|
|
9658
|
-
.filter(([_, value]) => !!value)
|
|
9659
|
-
.map(([key, _]) => {
|
|
9660
|
-
const columnKey = columns.get(key);
|
|
9661
|
-
return (columnKey === null || columnKey === void 0 ? void 0 : columnKey.orderKey) || key;
|
|
9662
|
-
}) }));
|
|
9682
|
+
fuse = new Fuse(data, TableSearchHelpers.fuseOptionsForSearchColumns(options === null || options === void 0 ? void 0 : options.fuseOptions, columns, query));
|
|
9663
9683
|
}
|
|
9664
9684
|
const orderColumn = query.order
|
|
9665
|
-
? (
|
|
9685
|
+
? (_a = columns.get(query.order.column)) === null || _a === void 0 ? void 0 : _a.orderKey
|
|
9666
9686
|
: undefined;
|
|
9667
9687
|
const hasExplicitSort = query.order != null && orderColumn !== undefined;
|
|
9668
9688
|
const defaultSortSpec = (() => {
|
|
@@ -9716,45 +9736,22 @@ var RivTable;
|
|
|
9716
9736
|
}
|
|
9717
9737
|
RivTable.createInMemoryManager = createInMemoryManager;
|
|
9718
9738
|
function createInMemoryManagerNested(fetchDataset, columns, pluralEntityName, options) {
|
|
9739
|
+
columns = TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable(columns, options === null || options === void 0 ? void 0 : options.fuseOptions);
|
|
9719
9740
|
let data;
|
|
9720
9741
|
let rowsFromData;
|
|
9721
9742
|
// The fuse will search the individual rows
|
|
9722
9743
|
let fuse;
|
|
9723
9744
|
const source = (query, mostRecentAction) => __awaiter(this, void 0, void 0, function* () {
|
|
9724
|
-
var _a, _b, _c
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
if (mostRecentAction.type === 'load') {
|
|
9728
|
-
//Prevent searching on columns that are in fuse options but not supported by search.
|
|
9729
|
-
const nonSearchableColumnsKeys = ((_a = options === null || options === void 0 ? void 0 : options.fuseOptions) === null || _a === void 0 ? void 0 : _a.keys)
|
|
9730
|
-
? Array.from(columns.entries())
|
|
9731
|
-
.filter(([key, column]) => {
|
|
9732
|
-
return column.searchable == false;
|
|
9733
|
-
})
|
|
9734
|
-
.map(([key, column]) => {
|
|
9735
|
-
var _a;
|
|
9736
|
-
return ((_a = column.orderKey) === null || _a === void 0 ? void 0 : _a.toString()) || key.toString();
|
|
9737
|
-
})
|
|
9738
|
-
: undefined;
|
|
9739
|
-
const fuseOptions = (options === null || options === void 0 ? void 0 : options.fuseOptions) && nonSearchableColumnsKeys
|
|
9740
|
-
? Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.fuseOptions), { keys: (_c = (_b = options === null || options === void 0 ? void 0 : options.fuseOptions) === null || _b === void 0 ? void 0 : _b.keys) === null || _c === void 0 ? void 0 : _c.filter(k => !nonSearchableColumnsKeys.includes(k.toString())) }) : options === null || options === void 0 ? void 0 : options.fuseOptions;
|
|
9741
|
-
data = yield fetchDataset();
|
|
9742
|
-
rowsFromData = TableResultHelpers.getAllRowsFromNestedHeaders(data);
|
|
9743
|
-
fuse = new Fuse(rowsFromData, fuseOptions);
|
|
9744
|
-
}
|
|
9745
|
-
if (mostRecentAction.type === 'searchColumnsChange' ||
|
|
9745
|
+
var _a, _b, _c;
|
|
9746
|
+
if (mostRecentAction.type === 'load' ||
|
|
9747
|
+
mostRecentAction.type === 'searchColumnsChange' ||
|
|
9746
9748
|
mostRecentAction.type === 'toggleAllSearchColumns') {
|
|
9747
9749
|
data = yield fetchDataset();
|
|
9748
9750
|
rowsFromData = TableResultHelpers.getAllRowsFromNestedHeaders(data);
|
|
9749
|
-
fuse = new Fuse(rowsFromData,
|
|
9750
|
-
.filter(([_, value]) => !!value)
|
|
9751
|
-
.map(([key, _]) => {
|
|
9752
|
-
const columnKey = columns.get(key);
|
|
9753
|
-
return (columnKey === null || columnKey === void 0 ? void 0 : columnKey.orderKey) || key;
|
|
9754
|
-
}) }));
|
|
9751
|
+
fuse = new Fuse(rowsFromData, TableSearchHelpers.fuseOptionsForSearchColumns(options === null || options === void 0 ? void 0 : options.fuseOptions, columns, query));
|
|
9755
9752
|
}
|
|
9756
9753
|
const orderColumn = query.order
|
|
9757
|
-
? (
|
|
9754
|
+
? (_a = columns.get(query.order.column)) === null || _a === void 0 ? void 0 : _a.orderKey
|
|
9758
9755
|
: undefined;
|
|
9759
9756
|
const hasExplicitSort = query.order != null && orderColumn !== undefined;
|
|
9760
9757
|
const defaultSortSpec = (() => {
|
|
@@ -9787,7 +9784,7 @@ var RivTable;
|
|
|
9787
9784
|
const nestedRowsToDisplay = didRestrictDisplayedRows
|
|
9788
9785
|
? TableNestingHelpers.findNestedRowsWithHeadersToKeep(data, rowsMatchingFilters)
|
|
9789
9786
|
: data;
|
|
9790
|
-
const matchingRowCount = TableNestingHelpers.countNestedRows(nestedRowsToDisplay, (
|
|
9787
|
+
const matchingRowCount = TableNestingHelpers.countNestedRows(nestedRowsToDisplay, (_b = options === null || options === void 0 ? void 0 : options.paginateBy) !== null && _b !== void 0 ? _b : 'bottomRows');
|
|
9791
9788
|
let sortedNestedRows;
|
|
9792
9789
|
if (hasExplicitSort && query.order) {
|
|
9793
9790
|
// Explicit sort override has priority over everything else
|
|
@@ -9807,7 +9804,7 @@ var RivTable;
|
|
|
9807
9804
|
// Don't sort if we have no information to use to sort
|
|
9808
9805
|
sortedNestedRows = nestedRowsToDisplay;
|
|
9809
9806
|
}
|
|
9810
|
-
const paginatedHeaderRows = TablePaginationHelpers.paginateNestedHeaderRows(sortedNestedRows, query.pagination.page, query.pagination.pageSize, (
|
|
9807
|
+
const paginatedHeaderRows = TablePaginationHelpers.paginateNestedHeaderRows(sortedNestedRows, query.pagination.page, query.pagination.pageSize, (_c = options === null || options === void 0 ? void 0 : options.paginateBy) !== null && _c !== void 0 ? _c : 'bottomRows');
|
|
9811
9808
|
const hasHeaders = paginatedHeaderRows.some(header => header.headerText != null);
|
|
9812
9809
|
return {
|
|
9813
9810
|
currentPageNestedHeaders: paginatedHeaderRows,
|