@rivet-health/design-system 33.1.2 → 34.0.1
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/input/select/state.mjs +73 -16
- package/esm2020/lib/visualization/chart/chart.mjs +52 -5
- package/fesm2015/rivet-health-design-system.mjs +126 -21
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +123 -19
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/lib/input/select/state.d.ts +24 -1
- package/package.json +1 -1
|
@@ -2001,6 +2001,7 @@ var RivSelect;
|
|
|
2001
2001
|
error: null,
|
|
2002
2002
|
},
|
|
2003
2003
|
sourceOptionGroups: [],
|
|
2004
|
+
originalOptionGroups: [],
|
|
2004
2005
|
selection: {
|
|
2005
2006
|
selected: new OptionSet(),
|
|
2006
2007
|
},
|
|
@@ -2014,7 +2015,7 @@ var RivSelect;
|
|
|
2014
2015
|
const actions = new Subject();
|
|
2015
2016
|
const internalActions = new Subject();
|
|
2016
2017
|
const coreStateWithSelectionSnapshot = merge(actions, internalActions).pipe(scan(([state, snapshot], action) => {
|
|
2017
|
-
const newState = sideEffects(reduce(state, action), action, source, internalActions);
|
|
2018
|
+
const newState = sideEffects(reduce(state, action, options), action, source, internalActions);
|
|
2018
2019
|
const newSelectionSnapshot = (action.type === 'openChange' && action.open) ||
|
|
2019
2020
|
(action.type === 'loadComplete' &&
|
|
2020
2021
|
(newState.display.open || (options === null || options === void 0 ? void 0 : options.inline)))
|
|
@@ -2028,7 +2029,7 @@ var RivSelect;
|
|
|
2028
2029
|
const state = connectable(coreStateWithSelectionSnapshot.pipe(map(([s, selectionAtOpen]) => {
|
|
2029
2030
|
var _a, _b, _c, _d, _e, _f;
|
|
2030
2031
|
const allOptionGroups = s.sourceOptionGroups.map(optionGroup => {
|
|
2031
|
-
return Object.assign(Object.assign({}, optionGroup), { options: optionGroup.options.map(option => augmentOptionToFullOption(s, option)) });
|
|
2032
|
+
return Object.assign(Object.assign({}, optionGroup), { options: optionGroup.options.map(option => augmentOptionToFullOption(s, option, options)) });
|
|
2032
2033
|
});
|
|
2033
2034
|
const topLevelOptions = getTopLevelOptions(allOptionGroups);
|
|
2034
2035
|
const sortedOptionGroups = (options === null || options === void 0 ? void 0 : options.allowMultiSelect)
|
|
@@ -2227,7 +2228,10 @@ var RivSelect;
|
|
|
2227
2228
|
: null)));
|
|
2228
2229
|
});
|
|
2229
2230
|
}
|
|
2230
|
-
return
|
|
2231
|
+
return {
|
|
2232
|
+
data: [{ options: addHighlightsToOption(ordered) }],
|
|
2233
|
+
originalData: data,
|
|
2234
|
+
};
|
|
2231
2235
|
});
|
|
2232
2236
|
return createManager(source, options);
|
|
2233
2237
|
}
|
|
@@ -2358,7 +2362,16 @@ var RivSelect;
|
|
|
2358
2362
|
if ((options === null || options === void 0 ? void 0 : options.selectedOptionLimit) === undefined) {
|
|
2359
2363
|
return optionGroups;
|
|
2360
2364
|
}
|
|
2361
|
-
|
|
2365
|
+
// When useTopLevelOptionsForDisplay is true and search is active, count
|
|
2366
|
+
// selected top-level options from the original (unfiltered) data to ensure
|
|
2367
|
+
// already-selected options that don't match the search are still counted.
|
|
2368
|
+
const useOriginalForCounting = (options === null || options === void 0 ? void 0 : options.useTopLevelOptionsForDisplay) &&
|
|
2369
|
+
state.query.search &&
|
|
2370
|
+
state.originalOptionGroups.length > 0;
|
|
2371
|
+
const topOptionsForCounting = useOriginalForCounting
|
|
2372
|
+
? getTopLevelOptions(state.originalOptionGroups).map(option => augmentOptionToFullOption(state, option, options))
|
|
2373
|
+
: topLevelOptions;
|
|
2374
|
+
const selectedOrIndeterminateTopOptions = topOptionsForCounting.filter(option => option.selected != false);
|
|
2362
2375
|
const numSelectedOptions = (options === null || options === void 0 ? void 0 : options.useTopLevelOptionsForDisplay)
|
|
2363
2376
|
? selectedOrIndeterminateTopOptions.length
|
|
2364
2377
|
: state.selection.selected.size;
|
|
@@ -2431,13 +2444,43 @@ var RivSelect;
|
|
|
2431
2444
|
return false;
|
|
2432
2445
|
return 'indeterminate';
|
|
2433
2446
|
}
|
|
2434
|
-
function augmentOptionToFullOption(state, option) {
|
|
2435
|
-
var _a;
|
|
2447
|
+
function augmentOptionToFullOption(state, option, managerOptions) {
|
|
2448
|
+
var _a, _b;
|
|
2436
2449
|
if ((_a = option.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2437
|
-
const augmentedChildren = option.children.map(child => augmentOptionToFullOption(state, child));
|
|
2438
|
-
|
|
2450
|
+
const augmentedChildren = option.children.map(child => augmentOptionToFullOption(state, child, managerOptions));
|
|
2451
|
+
const selectableWhenSearching = (_b = managerOptions === null || managerOptions === void 0 ? void 0 : managerOptions.allowSelectNonLeafDuringSearch) !== null && _b !== void 0 ? _b : false;
|
|
2452
|
+
// When allowSelectNonLeafDuringSearch is enabled and search is active,
|
|
2453
|
+
// calculate selection state from ALL original children, not just the
|
|
2454
|
+
// filtered ones visible in search results.
|
|
2455
|
+
const useOriginalForSelectionState = (managerOptions === null || managerOptions === void 0 ? void 0 : managerOptions.allowSelectNonLeafDuringSearch) &&
|
|
2456
|
+
state.query.search &&
|
|
2457
|
+
state.originalOptionGroups.length > 0;
|
|
2458
|
+
let selected;
|
|
2459
|
+
if (useOriginalForSelectionState) {
|
|
2460
|
+
const originalOption = findOption(getTopLevelOptions(state.originalOptionGroups), option.id);
|
|
2461
|
+
if (originalOption) {
|
|
2462
|
+
const allLeaves = flattenOptions([originalOption], true);
|
|
2463
|
+
const selectedCount = allLeaves.filter(leaf => state.selection.selected.has(leaf)).length;
|
|
2464
|
+
if (selectedCount === 0) {
|
|
2465
|
+
selected = false;
|
|
2466
|
+
}
|
|
2467
|
+
else if (selectedCount === allLeaves.length) {
|
|
2468
|
+
selected = true;
|
|
2469
|
+
}
|
|
2470
|
+
else {
|
|
2471
|
+
selected = 'indeterminate';
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
else {
|
|
2475
|
+
selected = getParentMultiSelectionState(augmentedChildren);
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
else {
|
|
2479
|
+
selected = getParentMultiSelectionState(augmentedChildren);
|
|
2480
|
+
}
|
|
2481
|
+
return Object.assign(Object.assign({}, option), { children: augmentedChildren, selected, expanded: state.query.search
|
|
2439
2482
|
? true
|
|
2440
|
-
: state.display.expandedOptions.has(option.id), selectable: !state.query.search, expandable: !state.query.search });
|
|
2483
|
+
: state.display.expandedOptions.has(option.id), selectable: !state.query.search || selectableWhenSearching, expandable: !state.query.search });
|
|
2441
2484
|
}
|
|
2442
2485
|
return Object.assign(Object.assign({}, option), { children: undefined, selected: state.selection.selected.has(option), expanded: false, selectable: true, expandable: false });
|
|
2443
2486
|
}
|
|
@@ -2501,14 +2544,24 @@ var RivSelect;
|
|
|
2501
2544
|
}
|
|
2502
2545
|
}));
|
|
2503
2546
|
}
|
|
2504
|
-
function toggleSelected(state, id) {
|
|
2547
|
+
function toggleSelected(state, id, managerOptions) {
|
|
2548
|
+
var _a;
|
|
2505
2549
|
const topLevelOptions = getTopLevelOptions(state.sourceOptionGroups);
|
|
2506
2550
|
const option = findOption(topLevelOptions, id);
|
|
2507
2551
|
if (!option)
|
|
2508
2552
|
return state;
|
|
2509
2553
|
const newSelection = new OptionSet(state.selection.selected);
|
|
2510
|
-
const newValue = !(augmentOptionToFullOption(state, option).selected === true);
|
|
2511
|
-
|
|
2554
|
+
const newValue = !(augmentOptionToFullOption(state, option, managerOptions).selected === true);
|
|
2555
|
+
// When allowSelectNonLeafDuringSearch is enabled and search is active,
|
|
2556
|
+
// use the original (unfiltered) data to get all children, not just
|
|
2557
|
+
// those visible in the filtered search results.
|
|
2558
|
+
const useOriginalData = (managerOptions === null || managerOptions === void 0 ? void 0 : managerOptions.allowSelectNonLeafDuringSearch) &&
|
|
2559
|
+
state.query.search &&
|
|
2560
|
+
state.originalOptionGroups.length > 0;
|
|
2561
|
+
const optionForLeaves = useOriginalData
|
|
2562
|
+
? (_a = findOption(getTopLevelOptions(state.originalOptionGroups), id)) !== null && _a !== void 0 ? _a : option
|
|
2563
|
+
: option;
|
|
2564
|
+
const leaves = flattenOptions([optionForLeaves], true);
|
|
2512
2565
|
for (const leaf of leaves) {
|
|
2513
2566
|
if (newValue) {
|
|
2514
2567
|
newSelection.add(leaf);
|
|
@@ -2559,8 +2612,12 @@ var RivSelect;
|
|
|
2559
2612
|
action.type === 'orderChange' ||
|
|
2560
2613
|
(action.type === 'openChange' && action.open)) {
|
|
2561
2614
|
source(state.query, action)
|
|
2562
|
-
.then(
|
|
2563
|
-
|
|
2615
|
+
.then(result => {
|
|
2616
|
+
const data = Array.isArray(result) ? result : result.data;
|
|
2617
|
+
const originalData = Array.isArray(result)
|
|
2618
|
+
? undefined
|
|
2619
|
+
: result.originalData;
|
|
2620
|
+
internalActions.next({ type: 'loadComplete', data, originalData });
|
|
2564
2621
|
})
|
|
2565
2622
|
.catch(error => {
|
|
2566
2623
|
// eslint-disable-next-line no-console
|
|
@@ -2574,7 +2631,8 @@ var RivSelect;
|
|
|
2574
2631
|
}
|
|
2575
2632
|
return state;
|
|
2576
2633
|
}
|
|
2577
|
-
function reduce(state, action) {
|
|
2634
|
+
function reduce(state, action, managerOptions) {
|
|
2635
|
+
var _a;
|
|
2578
2636
|
switch (action.type) {
|
|
2579
2637
|
case 'load':
|
|
2580
2638
|
return state;
|
|
@@ -2582,7 +2640,7 @@ var RivSelect;
|
|
|
2582
2640
|
return Object.assign(Object.assign({}, state), { load: {
|
|
2583
2641
|
loading: false,
|
|
2584
2642
|
error: null,
|
|
2585
|
-
}, sourceOptionGroups: action.data });
|
|
2643
|
+
}, sourceOptionGroups: action.data, originalOptionGroups: (_a = action.originalData) !== null && _a !== void 0 ? _a : [] });
|
|
2586
2644
|
case 'loadError':
|
|
2587
2645
|
return Object.assign(Object.assign({}, state), { load: {
|
|
2588
2646
|
loading: false,
|
|
@@ -2597,7 +2655,7 @@ var RivSelect;
|
|
|
2597
2655
|
case 'selectionChange':
|
|
2598
2656
|
return Object.assign(Object.assign({}, state), { selection: action.payload });
|
|
2599
2657
|
case 'toggleOptionSelected':
|
|
2600
|
-
return toggleSelected(state, action.id);
|
|
2658
|
+
return toggleSelected(state, action.id, managerOptions);
|
|
2601
2659
|
case 'setSelectedOption':
|
|
2602
2660
|
return setSelectedOption(state, action.id);
|
|
2603
2661
|
case 'visibleSelectedChange':
|
|
@@ -7899,7 +7957,7 @@ var Chart;
|
|
|
7899
7957
|
: scaleUtc(timeseriesDomain(data), yRange);
|
|
7900
7958
|
const dateFormat = (date) => formatedDate(config.dateFormat || 'day', date);
|
|
7901
7959
|
const { pipe, fullPipe } = getPipes(config.valueType);
|
|
7902
|
-
const yTicks = yScale.ticks(data.x.length - 1).map(tick => ({
|
|
7960
|
+
const yTicks = yScale.ticks(Math.max(data.x.length - 1, 1)).map(tick => ({
|
|
7903
7961
|
y: yScale(tick),
|
|
7904
7962
|
label: isNumber(tick)
|
|
7905
7963
|
? data.type == 'labeled'
|
|
@@ -7935,7 +7993,29 @@ var Chart;
|
|
|
7935
7993
|
yPos: yValue,
|
|
7936
7994
|
width,
|
|
7937
7995
|
});
|
|
7938
|
-
|
|
7996
|
+
//Don't draw anything for zero-value bars
|
|
7997
|
+
if (width == 0) {
|
|
7998
|
+
return '';
|
|
7999
|
+
}
|
|
8000
|
+
//These checks are to make sure we still round if all previous/later values are 0
|
|
8001
|
+
const allLeftZero = data.ys
|
|
8002
|
+
.slice(0, yIndex)
|
|
8003
|
+
.map(y => y.values[index])
|
|
8004
|
+
.filter(val => val != 0).length == 0;
|
|
8005
|
+
const leftSideRound = yIndex == 0 ||
|
|
8006
|
+
data.ys.length == 1 ||
|
|
8007
|
+
config.groupingType == 'clustered' ||
|
|
8008
|
+
allLeftZero;
|
|
8009
|
+
const allRightZero = data.ys
|
|
8010
|
+
.slice(yIndex + 1, data.ys.length)
|
|
8011
|
+
.map(y => y.values[index])
|
|
8012
|
+
//If the later data's value is the same as the current data's, that indicates 0 width
|
|
8013
|
+
.filter(val => val != data.ys[yIndex].values[index]).length == 0;
|
|
8014
|
+
const rightSideRound = yIndex == data.ys.length - 1 ||
|
|
8015
|
+
data.ys.length == 1 ||
|
|
8016
|
+
config.groupingType == 'clustered' ||
|
|
8017
|
+
allRightZero;
|
|
8018
|
+
if (leftSideRound && rightSideRound) {
|
|
7939
8019
|
//Both-sides rounding variation
|
|
7940
8020
|
const pathD = `
|
|
7941
8021
|
M ${xValue + horR},${yValue}
|
|
@@ -7951,7 +8031,7 @@ var Chart;
|
|
|
7951
8031
|
`;
|
|
7952
8032
|
return pathD;
|
|
7953
8033
|
}
|
|
7954
|
-
if (
|
|
8034
|
+
if (leftSideRound) {
|
|
7955
8035
|
//Left-side rounding variation
|
|
7956
8036
|
const pathD = `
|
|
7957
8037
|
M ${xValue + horR},${yValue}
|
|
@@ -7965,7 +8045,7 @@ var Chart;
|
|
|
7965
8045
|
`;
|
|
7966
8046
|
return pathD;
|
|
7967
8047
|
}
|
|
7968
|
-
if (
|
|
8048
|
+
if (rightSideRound) {
|
|
7969
8049
|
//Right-side rounding variation
|
|
7970
8050
|
const pathD = `
|
|
7971
8051
|
M ${xValue},${yValue}
|
|
@@ -8021,6 +8101,31 @@ var Chart;
|
|
|
8021
8101
|
visibleYIndex = data.ys.length - 1;
|
|
8022
8102
|
}
|
|
8023
8103
|
const yIndex = visibleIndices[visibleYIndex];
|
|
8104
|
+
//Check if we've landed on a zero-width bar (only really relevant on ends)
|
|
8105
|
+
if (simplifiedHorizontalBars[visibleYIndex][xIndex].width == 0 &&
|
|
8106
|
+
config.groupingType == 'stacked') {
|
|
8107
|
+
let altBarFound = false;
|
|
8108
|
+
//Check upwards
|
|
8109
|
+
for (let i = visibleYIndex + 1; i < simplifiedHorizontalBars.length; i++) {
|
|
8110
|
+
if (altBarFound) {
|
|
8111
|
+
break;
|
|
8112
|
+
}
|
|
8113
|
+
if (simplifiedHorizontalBars[i][xIndex].width != 0) {
|
|
8114
|
+
visibleYIndex = i;
|
|
8115
|
+
altBarFound = true;
|
|
8116
|
+
}
|
|
8117
|
+
}
|
|
8118
|
+
//Check downwards
|
|
8119
|
+
for (let i = visibleYIndex - 1; i >= 0; i--) {
|
|
8120
|
+
if (altBarFound) {
|
|
8121
|
+
break;
|
|
8122
|
+
}
|
|
8123
|
+
if (simplifiedHorizontalBars[i][xIndex].width != 0) {
|
|
8124
|
+
visibleYIndex = i;
|
|
8125
|
+
altBarFound = true;
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
}
|
|
8024
8129
|
const anchor = new DOMRect(pos.rect.x +
|
|
8025
8130
|
simplifiedHorizontalBars[visibleYIndex][xIndex].xPos -
|
|
8026
8131
|
SMALL_PADDING, pos.rect.y + simplifiedHorizontalBars[visibleYIndex][xIndex].yPos, simplifiedHorizontalBars[visibleYIndex][xIndex].width +
|