Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit d14ee77

Browse files
Googlernshahan
authored andcommitted
Allow clients to configure a way to segment results to option groups.
Previously, search results were set as a single option group. This allows us to bucket search results into distinct option groups. 1) Why do we *really* need this? We are running into use cases where search results need to be bucketed into option groups. (e.g. agencies vs companies). We feel it's kind of silly to bootstrap our own SearchDataSourceProvider just to support this. 2) Can't we just sort the items and avoid the need for this UX? No. UX specifically wants to visually bucket the items into distinct groups. OptionGroups are what we need. PiperOrigin-RevId: 209796557
1 parent 4b471ef commit d14ee77

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/model/selection/selection_options.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export 'package:angular_components/src/model/selection/delegating_selection_opti
1515
part 'package:angular_components/src/model/selection/future_selection_options_impl.dart';
1616
part 'package:angular_components/src/model/selection/stream_selection_options_impl.dart';
1717

18+
/// An interface for functions that segment [items] into option groups.
19+
typedef OptionGroupMapper<T> = List<OptionGroup<T>> Function(Iterable<T> items);
20+
1821
/// A collection of options with an optional label.
1922
class OptionGroup<T> extends LabeledList<T> {
2023
String get emptyLabel => _emptyLabelFcn != null ? _emptyLabelFcn() : null;
@@ -29,6 +32,8 @@ class OptionGroup<T> extends LabeledList<T> {
2932
[LabelFunction labelFcn, this._emptyLabelFcn])
3033
: super.withLabelFunction(items, labelFcn);
3134

35+
/// An option group with a label is recommended when multiple option groups
36+
/// exist in a selection list.
3237
OptionGroup.withLabel(List<T> items, [String label, String emptyLabel])
3338
: _emptyLabelFcn = emptyLabel != null ? (() => emptyLabel) : null,
3439
super.withLabel(items, label);

0 commit comments

Comments
 (0)