@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
|
@@ -8910,6 +8910,50 @@ var TableResultHelpers;
|
|
|
8910
8910
|
|
|
8911
8911
|
var TableSearchHelpers;
|
|
8912
8912
|
(function (TableSearchHelpers) {
|
|
8913
|
+
/**
|
|
8914
|
+
* The configured fuse options, without the keys for columns search does not
|
|
8915
|
+
* cover: the ones marked `searchable: false` and the ones turned off in
|
|
8916
|
+
* "Search in". Keys that don't belong to a column are left alone.
|
|
8917
|
+
*/
|
|
8918
|
+
function fuseOptionsForSearchColumns(fuseOptions, columns, query) {
|
|
8919
|
+
if (!fuseOptions?.keys)
|
|
8920
|
+
return fuseOptions;
|
|
8921
|
+
const excludedPaths = new Set(Array.from(columns.entries())
|
|
8922
|
+
.filter(([key, column]) => column.searchable === false ||
|
|
8923
|
+
query.searchColumns.get(key) === false)
|
|
8924
|
+
.map(([key, column]) => columnPath(key, column)));
|
|
8925
|
+
return {
|
|
8926
|
+
...fuseOptions,
|
|
8927
|
+
keys: fuseOptions.keys.filter(key => !excludedPaths.has(fuseKeyPath(key))),
|
|
8928
|
+
};
|
|
8929
|
+
}
|
|
8930
|
+
TableSearchHelpers.fuseOptionsForSearchColumns = fuseOptionsForSearchColumns;
|
|
8931
|
+
/**
|
|
8932
|
+
* Marks the columns with no key in `fuseOptions.keys` as `searchable: false`,
|
|
8933
|
+
* so "Search in" only offers columns that search can cover.
|
|
8934
|
+
*/
|
|
8935
|
+
function markColumnsOutsideFuseKeysUnsearchable(columns, fuseOptions) {
|
|
8936
|
+
if (!fuseOptions?.keys)
|
|
8937
|
+
return columns;
|
|
8938
|
+
const keyPaths = new Set(fuseOptions.keys.map(fuseKeyPath));
|
|
8939
|
+
return new Map(Array.from(columns.entries()).map(([key, column]) => [
|
|
8940
|
+
key,
|
|
8941
|
+
keyPaths.has(columnPath(key, column))
|
|
8942
|
+
? column
|
|
8943
|
+
: { ...column, searchable: false },
|
|
8944
|
+
]));
|
|
8945
|
+
}
|
|
8946
|
+
TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable = markColumnsOutsideFuseKeysUnsearchable;
|
|
8947
|
+
function columnPath(key, column) {
|
|
8948
|
+
return column.orderKey?.toString() ?? key.toString();
|
|
8949
|
+
}
|
|
8950
|
+
function fuseKeyPath(key) {
|
|
8951
|
+
if (typeof key === 'string')
|
|
8952
|
+
return key;
|
|
8953
|
+
if (Array.isArray(key))
|
|
8954
|
+
return key.join('.');
|
|
8955
|
+
return Array.isArray(key.name) ? key.name.join('.') : key.name;
|
|
8956
|
+
}
|
|
8913
8957
|
function getSearchColumnsSelectedState(state, expectedValue) {
|
|
8914
8958
|
switch (expectedValue) {
|
|
8915
8959
|
case 'all':
|
|
@@ -10034,43 +10078,15 @@ var RivTable;
|
|
|
10034
10078
|
*/
|
|
10035
10079
|
RivTable.NestedPaginateByOptions = ['bottomRows', 'topRows'];
|
|
10036
10080
|
function createInMemoryManager(fetchDataset, columns, pluralEntityName, options) {
|
|
10081
|
+
columns = TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable(columns, options?.fuseOptions);
|
|
10037
10082
|
let data;
|
|
10038
10083
|
let fuse;
|
|
10039
10084
|
const source = async (query, mostRecentAction) => {
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
if (mostRecentAction.type === 'load') {
|
|
10043
|
-
//Prevent searching on columns that are in fuse options but not supported by search.
|
|
10044
|
-
const nonSearchableColumnsKeys = options?.fuseOptions?.keys
|
|
10045
|
-
? Array.from(columns.entries())
|
|
10046
|
-
.filter(([key, column]) => {
|
|
10047
|
-
return column.searchable == false;
|
|
10048
|
-
})
|
|
10049
|
-
.map(([key, column]) => {
|
|
10050
|
-
return column.orderKey?.toString() || key.toString();
|
|
10051
|
-
})
|
|
10052
|
-
: undefined;
|
|
10053
|
-
const fuseOptions = options?.fuseOptions && nonSearchableColumnsKeys
|
|
10054
|
-
? {
|
|
10055
|
-
...options?.fuseOptions,
|
|
10056
|
-
keys: options?.fuseOptions?.keys?.filter(k => !nonSearchableColumnsKeys.includes(k.toString())),
|
|
10057
|
-
}
|
|
10058
|
-
: options?.fuseOptions;
|
|
10059
|
-
data = await fetchDataset();
|
|
10060
|
-
fuse = new Fuse(data, fuseOptions);
|
|
10061
|
-
}
|
|
10062
|
-
if (mostRecentAction.type === 'searchColumnsChange' ||
|
|
10085
|
+
if (mostRecentAction.type === 'load' ||
|
|
10086
|
+
mostRecentAction.type === 'searchColumnsChange' ||
|
|
10063
10087
|
mostRecentAction.type === 'toggleAllSearchColumns') {
|
|
10064
10088
|
data = await fetchDataset();
|
|
10065
|
-
fuse = new Fuse(data,
|
|
10066
|
-
...options?.fuseOptions,
|
|
10067
|
-
keys: Array.from(query.searchColumns.entries())
|
|
10068
|
-
.filter(([_, value]) => !!value)
|
|
10069
|
-
.map(([key, _]) => {
|
|
10070
|
-
const columnKey = columns.get(key);
|
|
10071
|
-
return columnKey?.orderKey || key;
|
|
10072
|
-
}),
|
|
10073
|
-
});
|
|
10089
|
+
fuse = new Fuse(data, TableSearchHelpers.fuseOptionsForSearchColumns(options?.fuseOptions, columns, query));
|
|
10074
10090
|
}
|
|
10075
10091
|
const orderColumn = query.order
|
|
10076
10092
|
? columns.get(query.order.column)?.orderKey
|
|
@@ -10126,47 +10142,18 @@ var RivTable;
|
|
|
10126
10142
|
}
|
|
10127
10143
|
RivTable.createInMemoryManager = createInMemoryManager;
|
|
10128
10144
|
function createInMemoryManagerNested(fetchDataset, columns, pluralEntityName, options) {
|
|
10145
|
+
columns = TableSearchHelpers.markColumnsOutsideFuseKeysUnsearchable(columns, options?.fuseOptions);
|
|
10129
10146
|
let data;
|
|
10130
10147
|
let rowsFromData;
|
|
10131
10148
|
// The fuse will search the individual rows
|
|
10132
10149
|
let fuse;
|
|
10133
10150
|
const source = async (query, mostRecentAction) => {
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
if (mostRecentAction.type === 'load') {
|
|
10137
|
-
//Prevent searching on columns that are in fuse options but not supported by search.
|
|
10138
|
-
const nonSearchableColumnsKeys = options?.fuseOptions?.keys
|
|
10139
|
-
? Array.from(columns.entries())
|
|
10140
|
-
.filter(([key, column]) => {
|
|
10141
|
-
return column.searchable == false;
|
|
10142
|
-
})
|
|
10143
|
-
.map(([key, column]) => {
|
|
10144
|
-
return column.orderKey?.toString() || key.toString();
|
|
10145
|
-
})
|
|
10146
|
-
: undefined;
|
|
10147
|
-
const fuseOptions = options?.fuseOptions && nonSearchableColumnsKeys
|
|
10148
|
-
? {
|
|
10149
|
-
...options?.fuseOptions,
|
|
10150
|
-
keys: options?.fuseOptions?.keys?.filter(k => !nonSearchableColumnsKeys.includes(k.toString())),
|
|
10151
|
-
}
|
|
10152
|
-
: options?.fuseOptions;
|
|
10153
|
-
data = await fetchDataset();
|
|
10154
|
-
rowsFromData = TableResultHelpers.getAllRowsFromNestedHeaders(data);
|
|
10155
|
-
fuse = new Fuse(rowsFromData, fuseOptions);
|
|
10156
|
-
}
|
|
10157
|
-
if (mostRecentAction.type === 'searchColumnsChange' ||
|
|
10151
|
+
if (mostRecentAction.type === 'load' ||
|
|
10152
|
+
mostRecentAction.type === 'searchColumnsChange' ||
|
|
10158
10153
|
mostRecentAction.type === 'toggleAllSearchColumns') {
|
|
10159
10154
|
data = await fetchDataset();
|
|
10160
10155
|
rowsFromData = TableResultHelpers.getAllRowsFromNestedHeaders(data);
|
|
10161
|
-
fuse = new Fuse(rowsFromData,
|
|
10162
|
-
...options?.fuseOptions,
|
|
10163
|
-
keys: Array.from(query.searchColumns.entries())
|
|
10164
|
-
.filter(([_, value]) => !!value)
|
|
10165
|
-
.map(([key, _]) => {
|
|
10166
|
-
const columnKey = columns.get(key);
|
|
10167
|
-
return columnKey?.orderKey || key;
|
|
10168
|
-
}),
|
|
10169
|
-
});
|
|
10156
|
+
fuse = new Fuse(rowsFromData, TableSearchHelpers.fuseOptionsForSearchColumns(options?.fuseOptions, columns, query));
|
|
10170
10157
|
}
|
|
10171
10158
|
const orderColumn = query.order
|
|
10172
10159
|
? columns.get(query.order.column)?.orderKey
|