@rivet-health/design-system 37.2.1 → 37.3.0
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.mjs +45 -6
- package/fesm2015/rivet-health-design-system.mjs +41 -9
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +44 -5
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/lib/table/table/state.d.ts +9 -0
- package/package.json +1 -1
|
@@ -6438,11 +6438,35 @@ var RivTable;
|
|
|
6438
6438
|
const orderColumn = query.order
|
|
6439
6439
|
? columns.get(query.order.column)?.orderKey
|
|
6440
6440
|
: undefined;
|
|
6441
|
-
const
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6441
|
+
const hasExplicitSort = query.order != null && orderColumn !== undefined;
|
|
6442
|
+
const defaultSortSpec = (() => {
|
|
6443
|
+
if (options?.defaultSort) {
|
|
6444
|
+
const key = columns.get(options.defaultSort.column)?.orderKey;
|
|
6445
|
+
if (key !== undefined) {
|
|
6446
|
+
return { key, direction: options.defaultSort.direction };
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
const firstOrderable = [...columns.entries()].find(([, meta]) => meta.orderKey != null);
|
|
6450
|
+
const key = firstOrderable?.[1].orderKey;
|
|
6451
|
+
return key !== undefined ? { key, direction: 'asc' } : null;
|
|
6452
|
+
})();
|
|
6453
|
+
let ordered;
|
|
6454
|
+
if (query.search) {
|
|
6455
|
+
const matches = fuse.search(query.search).map(result => result.item);
|
|
6456
|
+
ordered =
|
|
6457
|
+
hasExplicitSort && query.order
|
|
6458
|
+
? orderBy(matches, orderColumn, query.order.direction)
|
|
6459
|
+
: matches;
|
|
6460
|
+
}
|
|
6461
|
+
else if (hasExplicitSort && query.order) {
|
|
6462
|
+
ordered = orderBy(data, orderColumn, query.order.direction);
|
|
6463
|
+
}
|
|
6464
|
+
else if (query.order == null && defaultSortSpec) {
|
|
6465
|
+
ordered = orderBy(data, defaultSortSpec.key, defaultSortSpec.direction);
|
|
6466
|
+
}
|
|
6467
|
+
else {
|
|
6468
|
+
ordered = data;
|
|
6469
|
+
}
|
|
6446
6470
|
const filter = options?.filter;
|
|
6447
6471
|
const filtered = filter
|
|
6448
6472
|
? ordered.filter(row => filter(query.filters, row))
|
|
@@ -6470,6 +6494,21 @@ var RivTable;
|
|
|
6470
6494
|
displayName: metadata.displayName,
|
|
6471
6495
|
},
|
|
6472
6496
|
]));
|
|
6497
|
+
// When a defaultSort is specified, seed the initial query.order so the
|
|
6498
|
+
// table header shows the sort indicator from the start.
|
|
6499
|
+
if (options?.defaultSort && !options?.initialState?.query?.order) {
|
|
6500
|
+
const order = options.defaultSort;
|
|
6501
|
+
options = {
|
|
6502
|
+
...options,
|
|
6503
|
+
initialState: {
|
|
6504
|
+
...options.initialState,
|
|
6505
|
+
query: {
|
|
6506
|
+
...options.initialState?.query,
|
|
6507
|
+
order,
|
|
6508
|
+
},
|
|
6509
|
+
},
|
|
6510
|
+
};
|
|
6511
|
+
}
|
|
6473
6512
|
return createManager(source, columnMetadata, pluralEntityName, options);
|
|
6474
6513
|
}
|
|
6475
6514
|
RivTable.createInMemoryManager = createInMemoryManager;
|