@rivet-health/design-system 40.6.1 → 40.6.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/input/select/state.mjs +34 -13
- package/fesm2015/rivet-health-design-system.mjs +33 -12
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +33 -12
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/lib/input/select/state.d.ts +3 -0
- package/package.json +1 -1
|
@@ -2073,28 +2073,45 @@ var RivSelect;
|
|
|
2073
2073
|
* determined by the option's ID rather than the object reference.
|
|
2074
2074
|
*/
|
|
2075
2075
|
class OptionSet extends Set {
|
|
2076
|
+
constructor(values) {
|
|
2077
|
+
super();
|
|
2078
|
+
// Parallel id → option map so has()/add()/delete() are O(1) instead of
|
|
2079
|
+
// spreading the Set and linear-scanning it. Rebuilding an O(N²) lookup
|
|
2080
|
+
// for a 16k-option selection was the primary cause of the multi-minute
|
|
2081
|
+
// freeze that surfaced RVT-25383's tree-select scale problem.
|
|
2082
|
+
this.byId = new Map();
|
|
2083
|
+
if (values) {
|
|
2084
|
+
for (const value of values) {
|
|
2085
|
+
this.add(value);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2076
2089
|
has(option) {
|
|
2077
|
-
return
|
|
2090
|
+
return this.byId.has(option.id);
|
|
2078
2091
|
}
|
|
2079
2092
|
add(option) {
|
|
2080
|
-
if (this.has(option)) {
|
|
2081
|
-
//
|
|
2082
|
-
//
|
|
2083
|
-
//
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2093
|
+
if (this.byId.has(option.id)) {
|
|
2094
|
+
// Preserve insertion order while swapping to the newer object
|
|
2095
|
+
// reference. Rebuilding the full Set matches the previous
|
|
2096
|
+
// implementation's semantics; the cost of that rebuild only hits
|
|
2097
|
+
// the rare "re-add existing" path — the common O(N²) case (fresh
|
|
2098
|
+
// adds during construction) no longer pays it.
|
|
2099
|
+
const items = [...this].map(o => (o.id === option.id ? option : o));
|
|
2100
|
+
this.byId.set(option.id, option);
|
|
2101
|
+
super.clear();
|
|
2102
|
+
for (const item of items)
|
|
2103
|
+
super.add(item);
|
|
2089
2104
|
}
|
|
2090
2105
|
else {
|
|
2106
|
+
this.byId.set(option.id, option);
|
|
2091
2107
|
super.add(option);
|
|
2092
2108
|
}
|
|
2093
2109
|
return this;
|
|
2094
2110
|
}
|
|
2095
2111
|
delete(option) {
|
|
2096
|
-
const existing =
|
|
2112
|
+
const existing = this.byId.get(option.id);
|
|
2097
2113
|
if (existing) {
|
|
2114
|
+
this.byId.delete(option.id);
|
|
2098
2115
|
super.delete(existing);
|
|
2099
2116
|
return true;
|
|
2100
2117
|
}
|
|
@@ -2102,6 +2119,10 @@ var RivSelect;
|
|
|
2102
2119
|
return false;
|
|
2103
2120
|
}
|
|
2104
2121
|
}
|
|
2122
|
+
clear() {
|
|
2123
|
+
this.byId.clear();
|
|
2124
|
+
super.clear();
|
|
2125
|
+
}
|
|
2105
2126
|
}
|
|
2106
2127
|
RivSelect.OptionSet = OptionSet;
|
|
2107
2128
|
const MIN_OPTIONS_FOR_CONTROLS = 5;
|
|
@@ -2702,7 +2723,7 @@ var RivSelect;
|
|
|
2702
2723
|
}
|
|
2703
2724
|
function toggleVisibleSelected(state) {
|
|
2704
2725
|
const leaves = flattenOptions(getTopLevelOptions(state.sourceOptionGroups), true);
|
|
2705
|
-
const isAllSelected = leaves.every(leaf =>
|
|
2726
|
+
const isAllSelected = leaves.every(leaf => state.selection.selected.has(leaf));
|
|
2706
2727
|
const newSelection = new OptionSet(state.selection.selected);
|
|
2707
2728
|
for (const leaf of leaves) {
|
|
2708
2729
|
if (isAllSelected)
|