Omni Result
Description
A search-result row: icon tile, title, excerpt, footer and the full view behind it
OmniResult<T> is one object that describes a result wherever it is drawn: in a list of search hits, in a picker, in a table, and as the modal that opens when it is clicked. It carries the item it stands for as Result, so a click, selection or command handler shared by a whole list can act on the right one without a closure per row.
A row is made of slots rather than one custom component, which is what keeps rows lined up with each other:
| Slot | Set with | What it is |
|---|---|---|
| Icon tile | SetIcon |
A glyph on an accent background, an image, or any component. |
| Icon badge | SetIconBadge |
A marker pinned to a corner of the tile (OmniResultBadgeCorner). |
| Identifier | SetId |
A short key before the title, with a chevron between them. |
| Title | SetTitle |
The row's heading, highlighted against the search query. |
| Badge | SetBadge |
A quiet pill beside the title. |
| Excerpt | SetText |
Plain text, clamped to TextLines, highlighted. |
| Content | SetContent |
A rich component under the excerpt, capped with ContentMaxHeight. |
| Footer | SetFooterEntries / AddFooterEntry |
A line of InlineLabels, separated by dots. |
| Source | SetSource |
Where the result came from, with OnSourceClick to open it there. |
| Page rail | SetPages |
A PagesStack pinned to the right. |
| Contribution bar | SetContributionBar |
A ContributionBar showing how the score breaks down. |
Selection, commands and highlighting are the row's own. Selectable(OmniResultSelectionMode) adds a checkbox that can sit beside or over the icon; OnContextMenu(…, OmniResultCommandsMode) wires right-click and an optional [...] button; InlineCommands(…) puts a few buttons before it. Highlight / HighlightWords mark the query in the title and the excerpt structurally, without walking the rendered DOM.
SetModalContent hangs the full view on the row, and ToModal() turns it into the sheet that shows it, with ModalSize, ModalTitle, SetModalHeader, ModalNavigation, ModalShortcutsBar and ModalFullScreen shaping it. GetModalContentAsync() returns that content on its own when you want it without a modal around it.
Samples
A result row
Identifier, badge and inline commands
A selectable list of results
API reference
public enum OmniResultBadgeCornerWhich corner of an OmniResult{T} icon tile a badge is pinned to.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| TopLeft | The top-left corner - where a "pinned" marker usually goes. |
| TopRight | The top-right corner. |
| BottomLeft | The bottom-left corner. |
| BottomRight | The bottom-right corner - where a "where it came from" marker usually goes. |
TopLeftThe top-left corner - where a "pinned" marker usually goes.
public enum OmniResultSelectionModeWhere the selection checkbox of an OmniResult{T} lives, and when it shows. A selected result always shows its checkbox, whatever the mode.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| OnHoverBeforeIcon | A checkbox in its own column before the icon, revealed while the result is hovered. |
| OnHoverOverIcon | A checkbox over the icon tile, revealed - and covering the icon - while the result is hovered. |
| AlwaysBeforeIcon | A checkbox in its own column before the icon, always visible. |
| ReplacingIcon | A checkbox in place of the icon tile, which is not drawn at all. |
OnHoverBeforeIconA checkbox in its own column before the icon, revealed while the result is hovered.
OnHoverOverIconA checkbox over the icon tile, revealed - and covering the icon - while the result is hovered.
AlwaysBeforeIconA checkbox in its own column before the icon, always visible.
public enum OmniResultCommandsModeHow the commands of an OmniResult{T} are reached.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| RightClickOnly | Right-clicking the result, and nothing else - no button is drawn. |
| ButtonOnHover | Right-clicking the result, or a [...] button revealed while it is hovered. |
| ButtonAlwaysVisible | Right-clicking the result, or a [...] button that is always visible. |
RightClickOnlyRight-clicking the result, and nothing else - no button is drawn.
ButtonOnHoverRight-clicking the result, or a [...] button revealed while it is hovered.
public enum OmniResultCommandsVisibilityWhen the inline commands of an OmniResult{T} show.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| OnHover | Revealed while the result is hovered (or focused). |
| AlwaysVisible | Always visible. |
public sealed class OmniResult<T> : ComponentBase<OmniResult<T>, HTMLElement>A search-result card: an icon tile, a title with an optional badge, an optional excerpt with the matched terms highlighted, an optional footer naming the source and whatever metadata the host wants beside it, and an optional PagesStack preview pinned to its right. The result it stands for is carried as Result, so a click, selection or command handler shared by a whole list of results can act on the right one without a closure per card. Rows are selectable (Selectable) with a checkbox that can sit beside or over the icon; commands are reached by right-click and, optionally, a [...] button (OnContextMenu), with room for a few inline commands before it (InlineCommands).
- Namespace
- Tesserae
- Inheritance
- ComponentBase<OmniResult<T>, HTMLElement> → OmniResult<T>
Constructors
| Name | Description |
|---|---|
| OmniResult | Initializes a new instance of this class standing for the given result. |
Properties
| Name | Description |
|---|---|
| Result | Gets the result this card stands for - the search hit, document, record or row it was built from. |
| Title | Gets or sets the title of the result. |
| Id | Gets or sets the identifier shown before the title - an issue number, a ticket key, a row number - followed by a chevron pointing at the title. A null or empty value drops both. |
| Text | Gets or sets the excerpt shown under the title, or null when the result has none. Plain text: the only markup it gets is the highlighting of Highlight. |
| IsSelectionEnabled | Returns a value indicating whether the result can be selected. |
| IsSelected | Gets or sets whether the result is selected. Setting it runs the OnSelectionChanged handlers, so a host list can keep its own selection in step whether the change came from the user or from code. |
| IsActive | Gets or sets whether the result is the active one - the row a keyboard-driven list has moved to. It is styled like a hovered row, and reveals whatever the row reveals on hover. |
| Pages | Gets the PagesStack preview shown at the end of the row, or null when it has none. |
| Contribution | Gets the ContributionBar shown under the footer, or null when it has none. |
| CommandsEvent | Gets the pointer event that last asked for this result's commands - the right-click, or the click on the [...] button - or null when they were asked for from the keyboard. A host that shows its own command surface (rather than a ContextMenu through ShowMenu) reads this to place it where the user asked. |
| HasModalContent | Gets a value indicating whether the result has content to open as a modal (see ToModal). |
| OpenActions | Gets the ways this result can be opened where it actually lives, in the order they were added - the first one is the primary, and the rest hang off the arrow beside it. |
| CanOpenInSource | Gets a value indicating whether the result can be opened at its source. |
| HasModalHeader | Gets a value indicating whether a header of the host's own was set with SetModalHeader - so a caller applying a default one can tell whether anyone got there first. |
| CurrentModal | Gets the modal ToModal last built for this result, or null when it has not built one yet - what a host reaches for to close, resize or otherwise get at the surface it opened. |
public T Result { get; }Gets the result this card stands for - the search hit, document, record or row it was built from.
public string Id { get ; set ; }Gets or sets the identifier shown before the title - an issue number, a ticket key, a row number - followed by a chevron pointing at the title. A null or empty value drops both.
public string Text { get ; set ; }Gets or sets the excerpt shown under the title, or null when the result has none. Plain text: the only markup it gets is the highlighting of Highlight.
public bool IsSelectionEnabledReturns a value indicating whether the result can be selected.
public bool IsSelected { get ; set ; }Gets or sets whether the result is selected. Setting it runs the OnSelectionChanged handlers, so a host list can keep its own selection in step whether the change came from the user or from code.
public bool IsActive { get ; set ; }Gets or sets whether the result is the active one - the row a keyboard-driven list has moved to. It is styled like a hovered row, and reveals whatever the row reveals on hover.
public PagesStack PagesGets the PagesStack preview shown at the end of the row, or null when it has none.
public ContributionBar ContributionGets the ContributionBar shown under the footer, or null when it has none.
public MouseEvent CommandsEventGets the pointer event that last asked for this result's commands - the right-click, or the click on the [...] button - or null when they were asked for from the keyboard. A host that shows its own command surface (rather than a ContextMenu through ShowMenu) reads this to place it where the user asked.
public bool HasModalContentGets a value indicating whether the result has content to open as a modal (see ToModal).
public IReadOnlyList<OmniResultOpenAction<T>> OpenActionsGets the ways this result can be opened where it actually lives, in the order they were added - the first one is the primary, and the rest hang off the arrow beside it.
public bool CanOpenInSourceGets a value indicating whether the result can be opened at its source.
public bool HasModalHeaderGets a value indicating whether a header of the host's own was set with SetModalHeader - so a caller applying a default one can tell whether anyone got there first.
Methods
| Name | Description |
|---|---|
| Render | Renders the component's root HTML element. |
| SetTitle | Sets the title of the result. The title is ellipsized to one line, carries the full text as its native tooltip, and has the terms of Highlight marked in it. |
| SetId | Sets the identifier shown before the title - an issue number, a ticket key, a row number - drawn in the quiet way an identifier reads and followed by a chevron pointing at the title. A null or empty value drops the identifier and the chevron with it. |
| SetIcon | Puts the given icon on the tile, in the given color, over a paler wash of that same color. Pass the full-strength color the glyph should be - the background is computed from it (and cached), a light tint of it under a light theme and a deep one under a dark theme. |
| SetBadge | Puts a badge next to the title - what matched, how many times, how the result was found. A null or empty value hides it. |
| SetText | Sets the excerpt shown under the title. It is plain text, not a component: whatever the search returned as the matching passage, ellipsized to the two lines the row gives it, with the terms of Highlight marked in it. A null or empty value drops the line entirely. |
| TextLines | Caps how many lines of the excerpt are shown before it is ellipsized. Two by default. |
| SetContent | Puts a component under the excerpt, in the text column: the rich preview a result has of its own - a thumbnail, a quoted message, a table of the fields that matched - for everything a plain excerpt can't say. Pass null to take it away. Cap how tall it is allowed to be with ContentMaxHeight, which fades the overflow out rather than cutting it off. |
| ContentMaxHeight | Caps how tall the SetContent preview is allowed to grow, fading whatever runs past it out instead of cutting it off. Pass null to un-cap it. |
| SetIconBadge | Pins a badge to a corner of the icon tile - where a result came from, that it is pinned - drawn over the tile's corner and outside its clipping. Pass null to clear that corner. |
| Highlight | Marks every match of the given expression in the title and the excerpt - the same pattern a search backend hands back for highlighting. Matching is done against the text itself and the matches are wrapped in their own elements, so neither is ever treated as markup. |
| HighlightWords | Marks every occurrence of the given words in the excerpt, case-insensitively - the convenience form of Highlight for a host that has the query terms rather than a pattern. |
| SetSource | Names where the result came from: a small rounded square in the given color, followed by the text, at the start of the footer. A null or empty text hides it. Passing a handler makes the source itself clickable - scoping a search to that source is the usual thing to do with it - without the click counting as opening the result. It takes a tab stop of its own and answers Enter and Space, and the result is handed to the handler so one shared handler can read Result. |
| OnSourceClick | Registers what clicking the source in the footer does - scope the search to it, open it, filter by it - and marks the source as clickable. Clicking it does not also count as opening the result. Pass null to make the source plain text again. |
| SetFooterEntries | Sets the metadata shown after the source in the footer - a path, a size, an owner, a date - as InlineLabels, each separated from the next by a dot. Each one can carry a mark (a glyph, an image, a square of colour), be pressable, or be a real link, and they are all drawn at one size so the line reads as one row of facts. Replaces whatever entries were there. |
| AddFooterEntry | Adds one more entry to the end of the footer line, as a component of the host's own rather than an InlineLabel - a badge, a chip, a small control a label cannot be. It gets the same box and the same separating dot as every other entry. |
| Selectable | Makes the result selectable, with its checkbox shown as the given mode says. The checkbox toggles the selection on click; ctrl-clicking the row does the same, and shift-clicking it asks for a range (see OnRangeSelectionRequested). |
| NotSelectable | Takes the checkbox away again, unselecting the result if it was selected. |
| Selected | Selects (or unselects) the result. Does nothing on a result that isn't selectable. |
| OnSelectionChanged | Registers a callback invoked whenever the result is selected or unselected, by the user or by code, with the new state. |
| OnRangeSelectionRequested | Registers a callback invoked when the user shift-clicks the result, i.e. asks for everything between the last result they selected and this one. A single card knows nothing about its siblings, so the host list owns what "between" means - and selects them itself. |
| OnContextMenu | Registers the handler that opens the commands of this result, and says how it is reached: by right-click alone, or also by a [...] button at the top-right of the row - shown always, or only while the row is hovered. The handler is given the result, so it can build a menu from Result and show it with ShowMenu. |
| CommandsMode | Changes how the commands registered with OnContextMenu are reached, without touching the handler itself. |
| InlineCommands | Puts the given components in the row's command area, before the [...] button - the one or two actions worth reaching without opening a menu. They show only while the row is hovered by default; the space they take is reserved either way, so revealing them never shifts the row. |
| SetContributionBar | Puts a ContributionBar under the footer, spanning the text column: what the result's score is made of - a title match, a content match, recency, popularity - as one stacked bar. Pass null to take it away. A bar with many segments is worth collapsing (Collapsable), so a list of results reads as one line each until the breakdown is asked for. |
| SetPages | Pins the given PagesStack preview to the end of the row, in a rail wide enough for it to fan into. Pass null to take it away. |
| PagesFanOnHover | Configures whether the PagesStack fans while the row is hovered, rather than only while the pointer is over the pages themselves. On by default. |
| OpenInSource | Adds a way to open the result where it actually lives - "Open in Dropbox", "Open in Outlook", "Reveal in folder" - as a named button in the modal's header. The handler is told whether the user asked for a new tab (they shift-clicked the button, or pressed Shift+Enter). Call it more than once to offer several: the first one stays the button, and the rest are reached through an arrow beside it. |
| NoOpenInSource | Takes every way of opening the result at its source away again. |
| Open | Opens the result at its source the way the primary action says to, as pressing the button (or Ctrl+Enter in the modal) would. Does nothing on a result that has no such action. |
| ModalCommands | Registers what the [...] button in the modal's header opens - the same commands the row's own [...] opens, usually. Read CommandsEvent in the handler to place a command surface of the host's own where the user clicked. Pass null to leave the button out. |
| ModalFullScreen | Registers what the full-screen button in the modal's header does - open the result on a page of its own, usually. Without one the button is still there and simply grows the modal to fill the window (and back), which is what "full screen" means to a modal that has nowhere else to go. |
| NoModalFullScreen | Leaves the full-screen button out of the modal's header. |
| ModalNavigation | Puts the previous/next arrows in the modal's header, so a result opened out of a list can be stepped through without going back to it. A null handler greys its arrow out - that is how the first and the last result say so. Passing a position and a count (both 1-based, the count being how many results there are) draws "3 of 27" between the arrows. |
| ModalShortcuts | Configures whether the modal shows the keyboard shortcuts it answers along its bottom edge - what closes it, what steps through the results, what opens the result at its source. On by default. |
| SetModalContent | Sets what ToModal puts inside the modal for this result - the full view of the thing the row stands for. Pass null to make the result modal-less again. |
| GetModalContentAsync | Builds the modal content on its own, for a host that shows it somewhere other than in a modal - a side panel, a page, a pane of its own. Returns null when the result has no modal content. |
| SetModalHeader | Replaces the modal's header - by default the same identifier, title and badge the row shows - with one built from the result. Pass null to go back to the default header. |
| ModalSize | Sets the size the modal of ToModal opens at. Auto by default, which lets the modal size itself to its content (and to whatever bounds the caller sets on it afterwards). |
| ModalKeepsIcon | Keeps the icon tile in the modal's header, before the identifier and the title - so an opened result still shows what kind of thing it is, and the row and the modal read as one thing rather than two. Whatever the tile carries comes with it: the glyph or the thumbnail, the color it is tinted with, and any corner badges. Off by default. |
| ModalKeepsFooter | Keeps the footer - the source and the metadata beside it - as a second line under the title in the modal's header, so where a result came from is still said once it is open. The source stays clickable when the row's is. Off by default. |
| ToModal | Builds a Modal showing this result: the row's identifier, title and badge as the header, and whatever SetModalContent was given as the body, at the size ModalSize asked for. Everything else - commands, dismissal, bounds, how it is shown - is left to the caller to chain on the returned modal. Returns null when the result has no modal content, so a caller can treat "this result has no preview" as one check. |
| ModalHeaderCommands | The commands ToModal puts at the end of the modal's header: the way to open the result at its source, the arrows stepping through the results, the [...] commands, the full-screen button and the close button - whichever of them this result was configured for. Useful to a caller building a header of its own around them. |
| ModalShortcutsBar | The keyboard shortcuts ToModal lists along the bottom of the modal - only the ones this result actually answers, so a modal that can't be stepped through never says it can. |
| ModalTitle | The header ToModal uses by default: the identifier and the title, drawn the way the row draws them, plus whatever ModalKeepsIcon and ModalKeepsFooter asked to keep. Useful to a caller building its own header around it. |
| ShowMenu | Shows the given menu where the commands were asked for: at the pointer when the row was right-clicked, and under the [...] button when it was pressed. This is what a OnContextMenu handler uses to put its menu in the right place without tracking the event itself. |
public override HTMLElement Render()Renders the component's root HTML element.
| Overload | |
|---|---|
| SetTitle(string) | Sets the title of the result. The title is ellipsized to one line, carries the full text as its native tooltip, and has the terms of Highlight marked in it. |
| SetTitle(IComponent, string) | Puts a component in the title slot in place of the plain title - the escape hatch for a result whose title genuinely isn't text, such as one built from fields an administrator configured. The text passed alongside it stays the row's Title, so the tooltip, the modal header and anything else reading the title still have something to say. Pass null to go back to plain text. A component title is drawn as it was given: Highlight does not reach inside it. |
SetTitle(string)
public OmniResult<T> SetTitle(string title)Sets the title of the result. The title is ellipsized to one line, carries the full text as its native tooltip, and has the terms of Highlight marked in it.
Parameters
- title string
SetTitle(IComponent, string)
public OmniResult<T> SetTitle(IComponent title, string text = null)Puts a component in the title slot in place of the plain title - the escape hatch for a result whose title genuinely isn't text, such as one built from fields an administrator configured. The text passed alongside it stays the row's Title, so the tooltip, the modal header and anything else reading the title still have something to say. Pass null to go back to plain text. A component title is drawn as it was given: Highlight does not reach inside it.
Parameters
- title IComponent
- text string
public OmniResult<T> SetId(string id)Sets the identifier shown before the title - an issue number, a ticket key, a row number - drawn in the quiet way an identifier reads and followed by a chevron pointing at the title. A null or empty value drops the identifier and the chevron with it.
| Overload | |
|---|---|
| SetIcon(UIcons, string, UIconsWeight) | Puts the given icon on the tile, in the given color, over a paler wash of that same color. Pass the full-strength color the glyph should be - the background is computed from it (and cached), a light tint of it under a light theme and a deep one under a dark theme. |
| SetIcon(string, string) | Puts the given short text on the tile in place of an icon - a file type, "PPTX" or "CSV", where no glyph says it as plainly - in the given color, over a paler wash of that same color. |
| SetIcon(IComponent, string) | Puts the given component on the tile - an Image thumbnail, an Avatar, an emoji - optionally tinting the tile with the given color. |
SetIcon(UIcons, string, UIconsWeight)
public OmniResult<T> SetIcon(UIcons icon, string color = null, UIconsWeight weight = UIconsWeight.Regular)Puts the given icon on the tile, in the given color, over a paler wash of that same color. Pass the full-strength color the glyph should be - the background is computed from it (and cached), a light tint of it under a light theme and a deep one under a dark theme.
Parameters
- icon UIcons
- color string
- weight UIconsWeight
SetIcon(string, string)
public OmniResult<T> SetIcon(string text, string color = null)Puts the given short text on the tile in place of an icon - a file type, "PPTX" or "CSV", where no glyph says it as plainly - in the given color, over a paler wash of that same color.
Parameters
- text string
- color string
| Overload | |
|---|---|
| SetBadge(string) | Puts a badge next to the title - what matched, how many times, how the result was found. A null or empty value hides it. |
| SetBadge(IComponent) | Puts the given component next to the title in place of the plain badge - a Badge with a tone of its own, a Spinner, a small button. A null value empties the slot. |
public OmniResult<T> SetText(string text)Sets the excerpt shown under the title. It is plain text, not a component: whatever the search returned as the matching passage, ellipsized to the two lines the row gives it, with the terms of Highlight marked in it. A null or empty value drops the line entirely.
public OmniResult<T> TextLines(int lines)Caps how many lines of the excerpt are shown before it is ellipsized. Two by default.
public OmniResult<T> SetContent(IComponent content)Puts a component under the excerpt, in the text column: the rich preview a result has of its own - a thumbnail, a quoted message, a table of the fields that matched - for everything a plain excerpt can't say. Pass null to take it away. Cap how tall it is allowed to be with ContentMaxHeight, which fades the overflow out rather than cutting it off.
public OmniResult<T> ContentMaxHeight(UnitSize maxHeight)Caps how tall the SetContent preview is allowed to grow, fading whatever runs past it out instead of cutting it off. Pass null to un-cap it.
public OmniResult<T> SetIconBadge(IComponent badge, OmniResultBadgeCorner corner = OmniResultBadgeCorner.BottomRight)Pins a badge to a corner of the icon tile - where a result came from, that it is pinned - drawn over the tile's corner and outside its clipping. Pass null to clear that corner.
| Overload | |
|---|---|
| Highlight(Regex) | Marks every match of the given expression in the title and the excerpt - the same pattern a search backend hands back for highlighting. Matching is done against the text itself and the matches are wrapped in their own elements, so neither is ever treated as markup. |
| Highlight(string, bool) | Marks every match of the given regular expression in the excerpt, case-insensitively by default. |
Highlight(Regex)
public OmniResult<T> Highlight(Regex highlighter)Marks every match of the given expression in the title and the excerpt - the same pattern a search backend hands back for highlighting. Matching is done against the text itself and the matches are wrapped in their own elements, so neither is ever treated as markup.
Parameters
- highlighter Regex
public OmniResult<T> HighlightWords(params string[] words)Marks every occurrence of the given words in the excerpt, case-insensitively - the convenience form of Highlight for a host that has the query terms rather than a pattern.
| Overload | |
|---|---|
| SetSource(string, string, Action<OmniResult<T>>) | Names where the result came from: a small rounded square in the given color, followed by the text, at the start of the footer. A null or empty text hides it. Passing a handler makes the source itself clickable - scoping a search to that source is the usual thing to do with it - without the click counting as opening the result. It takes a tab stop of its own and answers Enter and Space, and the result is handed to the handler so one shared handler can read Result. |
| SetSource(IComponent, string, Action<OmniResult<T>>) | Names where the result came from with a marker of the host's own - the source's logo, an avatar - in place of the plain colored square, followed by the text. Everything else behaves as SetSource: a null or empty text hides it, and passing a handler makes the source clickable. |
SetSource(string, string, Action<OmniResult<T>>)
public OmniResult<T> SetSource(string color, string text, Action<OmniResult<T>> onClick = null)Names where the result came from: a small rounded square in the given color, followed by the text, at the start of the footer. A null or empty text hides it. Passing a handler makes the source itself clickable - scoping a search to that source is the usual thing to do with it - without the click counting as opening the result. It takes a tab stop of its own and answers Enter and Space, and the result is handed to the handler so one shared handler can read Result.
Parameters
- color string
- text string
- onClick Action<OmniResult<T>>
SetSource(IComponent, string, Action<OmniResult<T>>)
public OmniResult<T> SetSource(IComponent marker, string text, Action<OmniResult<T>> onClick = null)Names where the result came from with a marker of the host's own - the source's logo, an avatar - in place of the plain colored square, followed by the text. Everything else behaves as SetSource: a null or empty text hides it, and passing a handler makes the source clickable.
Parameters
- marker IComponent
- text string
- onClick Action<OmniResult<T>>
public OmniResult<T> OnSourceClick(Action<OmniResult<T>> onClick)Registers what clicking the source in the footer does - scope the search to it, open it, filter by it - and marks the source as clickable. Clicking it does not also count as opening the result. Pass null to make the source plain text again.
public OmniResult<T> Selectable(OmniResultSelectionMode mode = OmniResultSelectionMode.OnHoverBeforeIcon)Makes the result selectable, with its checkbox shown as the given mode says. The checkbox toggles the selection on click; ctrl-clicking the row does the same, and shift-clicking it asks for a range (see OnRangeSelectionRequested).
public OmniResult<T> NotSelectable()Takes the checkbox away again, unselecting the result if it was selected.
public OmniResult<T> Selected(bool value = true)Selects (or unselects) the result. Does nothing on a result that isn't selectable.
public OmniResult<T> OnSelectionChanged(Action<OmniResult<T>, bool> onSelectionChanged)Registers a callback invoked whenever the result is selected or unselected, by the user or by code, with the new state.
public OmniResult<T> OnRangeSelectionRequested(Action<OmniResult<T>> onRangeSelectionRequested)Registers a callback invoked when the user shift-clicks the result, i.e. asks for everything between the last result they selected and this one. A single card knows nothing about its siblings, so the host list owns what "between" means - and selects them itself.
| Overload | |
|---|---|
| OnContextMenu(Action<OmniResult<T>>, OmniResultCommandsMode) | Registers the handler that opens the commands of this result, and says how it is reached: by right-click alone, or also by a [...] button at the top-right of the row - shown always, or only while the row is hovered. The handler is given the result, so it can build a menu from Result and show it with ShowMenu. |
| OnContextMenu(Func<OmniResult<T>, ContextMenu.Item[]>, OmniResultCommandsMode) | Attaches a ContextMenu of actions to the result: the generator runs on every open and is given the result, and the items it returns are shown at the pointer (or under the [...] button). Returning null or an empty array opens nothing. |
OnContextMenu(Action<OmniResult<T>>, OmniResultCommandsMode)
public OmniResult<T> OnContextMenu(Action<OmniResult<T>> handler, OmniResultCommandsMode mode = OmniResultCommandsMode.RightClickOnly)Registers the handler that opens the commands of this result, and says how it is reached: by right-click alone, or also by a [...] button at the top-right of the row - shown always, or only while the row is hovered. The handler is given the result, so it can build a menu from Result and show it with ShowMenu.
Parameters
- handler Action<OmniResult<T>>
- mode OmniResultCommandsMode
OnContextMenu(Func<OmniResult<T>, ContextMenu.Item[]>, OmniResultCommandsMode)
public OmniResult<T> OnContextMenu(Func<OmniResult<T>, ContextMenu.Item[]> menu, OmniResultCommandsMode mode = OmniResultCommandsMode.RightClickOnly)Attaches a ContextMenu of actions to the result: the generator runs on every open and is given the result, and the items it returns are shown at the pointer (or under the [...] button). Returning null or an empty array opens nothing.
Parameters
- menu Func<OmniResult<T>, ContextMenu.Item[]>
- mode OmniResultCommandsMode
public OmniResult<T> CommandsMode(OmniResultCommandsMode mode)Changes how the commands registered with OnContextMenu are reached, without touching the handler itself.
| Overload | |
|---|---|
| InlineCommands(OmniResultCommandsVisibility, IComponent[]) | Puts the given components in the row's command area, before the [...] button - the one or two actions worth reaching without opening a menu. They show only while the row is hovered by default; the space they take is reserved either way, so revealing them never shifts the row. |
| InlineCommands(IComponent[]) | Puts the given components in the row's command area, revealed while the row is hovered. |
InlineCommands(OmniResultCommandsVisibility, IComponent[])
public OmniResult<T> InlineCommands(OmniResultCommandsVisibility visibility, params IComponent[] commands)Puts the given components in the row's command area, before the [...] button - the one or two actions worth reaching without opening a menu. They show only while the row is hovered by default; the space they take is reserved either way, so revealing them never shifts the row.
Parameters
- visibility OmniResultCommandsVisibility
- commands IComponent[]
public OmniResult<T> SetContributionBar(ContributionBar bar)Puts a ContributionBar under the footer, spanning the text column: what the result's score is made of - a title match, a content match, recency, popularity - as one stacked bar. Pass null to take it away. A bar with many segments is worth collapsing (Collapsable), so a list of results reads as one line each until the breakdown is asked for.
public OmniResult<T> SetPages(PagesStack pages)Pins the given PagesStack preview to the end of the row, in a rail wide enough for it to fan into. Pass null to take it away.
public OmniResult<T> PagesFanOnHover(bool value = true)Configures whether the PagesStack fans while the row is hovered, rather than only while the pointer is over the pages themselves. On by default.
| Overload | |
|---|---|
| OpenInSource(string, Action<bool>, UIcons?) | Adds a way to open the result where it actually lives - "Open in Dropbox", "Open in Outlook", "Reveal in folder" - as a named button in the modal's header. The handler is told whether the user asked for a new tab (they shift-clicked the button, or pressed Shift+Enter). Call it more than once to offer several: the first one stays the button, and the rest are reached through an arrow beside it. |
| OpenInSource(string, Action<bool>, Func<IComponent>) | Adds a way to open the result where it actually lives, marked with an icon of the host's own - the source's logo, usually. The factory runs every time the icon is drawn, so one action can be shown more than once without the two fighting over the same element. |
| OpenInSource(string, Func<T, Uri>, UIcons?) | Adds a way to open the result at an address computed from what it stands for - the usual shape of "open this where it came from" when the source is a web address. The result is opened in a new tab either way: an external address replacing the page the user is on would lose their place. |
| OpenInSource(string, Func<T, Uri>, Func<IComponent>) | Adds a way to open the result at a computed address, marked with an icon of the host's own. |
OpenInSource(string, Action<bool>, UIcons?)
public OmniResult<T> OpenInSource(string name, Action<bool> onOpen, UIcons? icon = null)Adds a way to open the result where it actually lives - "Open in Dropbox", "Open in Outlook", "Reveal in folder" - as a named button in the modal's header. The handler is told whether the user asked for a new tab (they shift-clicked the button, or pressed Shift+Enter). Call it more than once to offer several: the first one stays the button, and the rest are reached through an arrow beside it.
Parameters
- name string
- onOpen Action<bool>
- icon UIcons?
OpenInSource(string, Action<bool>, Func<IComponent>)
public OmniResult<T> OpenInSource(string name, Action<bool> onOpen, Func<IComponent> icon)Adds a way to open the result where it actually lives, marked with an icon of the host's own - the source's logo, usually. The factory runs every time the icon is drawn, so one action can be shown more than once without the two fighting over the same element.
Parameters
- name string
- onOpen Action<bool>
- icon Func<IComponent>
OpenInSource(string, Func<T, Uri>, UIcons?)
public OmniResult<T> OpenInSource(string name, Func<T, Uri> url, UIcons? icon = null)Adds a way to open the result at an address computed from what it stands for - the usual shape of "open this where it came from" when the source is a web address. The result is opened in a new tab either way: an external address replacing the page the user is on would lose their place.
Parameters
- name string
- url Func<T, Uri>
- icon UIcons?
public OmniResult<T> NoOpenInSource()Takes every way of opening the result at its source away again.
public OmniResult<T> Open(bool inNewTab = false)Opens the result at its source the way the primary action says to, as pressing the button (or Ctrl+Enter in the modal) would. Does nothing on a result that has no such action.
public OmniResult<T> ModalCommands(Action<OmniResult<T>> onCommands)Registers what the [...] button in the modal's header opens - the same commands the row's own [...] opens, usually. Read CommandsEvent in the handler to place a command surface of the host's own where the user clicked. Pass null to leave the button out.
public OmniResult<T> ModalFullScreen(Action<OmniResult<T>> onFullScreen)Registers what the full-screen button in the modal's header does - open the result on a page of its own, usually. Without one the button is still there and simply grows the modal to fill the window (and back), which is what "full screen" means to a modal that has nowhere else to go.
public OmniResult<T> NoModalFullScreen()Leaves the full-screen button out of the modal's header.
public OmniResult<T> ModalShortcuts(bool value = true)Configures whether the modal shows the keyboard shortcuts it answers along its bottom edge - what closes it, what steps through the results, what opens the result at its source. On by default.
| Overload | |
|---|---|
| SetModalContent(IComponent) | Sets what ToModal puts inside the modal for this result - the full view of the thing the row stands for. Pass null to make the result modal-less again. |
| SetModalContent(Func<OmniResult<T>, Task<IComponent>>) | Sets what ToModal puts inside the modal, built on open and given the result - for content that shouldn't be paid for until someone asks to see it. |
SetModalContent(IComponent)
public OmniResult<T> SetModalContent(IComponent content)Sets what ToModal puts inside the modal for this result - the full view of the thing the row stands for. Pass null to make the result modal-less again.
Parameters
- content IComponent
SetModalContent(Func<OmniResult<T>, Task<IComponent>>)
public OmniResult<T> SetModalContent(Func<OmniResult<T>, Task<IComponent>> content)Sets what ToModal puts inside the modal, built on open and given the result - for content that shouldn't be paid for until someone asks to see it.
Parameters
- content Func<OmniResult<T>, Task<IComponent>>
public Task<IComponent> GetModalContentAsync()Builds the modal content on its own, for a host that shows it somewhere other than in a modal - a side panel, a page, a pane of its own. Returns null when the result has no modal content.
public OmniResult<T> SetModalHeader(Func<OmniResult<T>, IComponent> header)Replaces the modal's header - by default the same identifier, title and badge the row shows - with one built from the result. Pass null to go back to the default header.
public OmniResult<T> ModalSize(UnitSize width, UnitSize height)Sets the size the modal of ToModal opens at. Auto by default, which lets the modal size itself to its content (and to whatever bounds the caller sets on it afterwards).
public OmniResult<T> ModalKeepsIcon(bool value = true)Keeps the icon tile in the modal's header, before the identifier and the title - so an opened result still shows what kind of thing it is, and the row and the modal read as one thing rather than two. Whatever the tile carries comes with it: the glyph or the thumbnail, the color it is tinted with, and any corner badges. Off by default.
public Modal ToModal()Builds a Modal showing this result: the row's identifier, title and badge as the header, and whatever SetModalContent was given as the body, at the size ModalSize asked for. Everything else - commands, dismissal, bounds, how it is shown - is left to the caller to chain on the returned modal. Returns null when the result has no modal content, so a caller can treat "this result has no preview" as one check.
public IComponent[] ModalHeaderCommands()The commands ToModal puts at the end of the modal's header: the way to open the result at its source, the arrows stepping through the results, the [...] commands, the full-screen button and the close button - whichever of them this result was configured for. Useful to a caller building a header of its own around them.
public IComponent ModalShortcutsBar()The keyboard shortcuts ToModal lists along the bottom of the modal - only the ones this result actually answers, so a modal that can't be stepped through never says it can.
public IComponent ModalTitle()The header ToModal uses by default: the identifier and the title, drawn the way the row draws them, plus whatever ModalKeepsIcon and ModalKeepsFooter asked to keep. Useful to a caller building its own header around it.
public OmniResult<T> ShowMenu(ContextMenu menu)Shows the given menu where the commands were asked for: at the pointer when the row was right-clicked, and under the [...] button when it was pressed. This is what a OnContextMenu handler uses to put its menu in the right place without tracking the event itself.
public sealed class OmniResultOpenAction<T>One named way of opening an OmniResult{T} where it actually lives - "Open in Dropbox", "Open in Outlook", "Reveal in folder" - either as something the host does itself or as an address computed from the result.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Name | Gets what this way of opening the result is called. |
| Icon | Gets what draws the mark shown before the name, or null when it has none. It is a factory rather than a component so that showing the action twice never moves one element between two places. |
public string Name { get; }Gets what this way of opening the result is called.
Methods
| Name | Description |
|---|---|
| UrlFor | Gets the address this action opens for the given result, or null when it isn't an address at all but something the host does itself. |
| Invoke | Opens the given result this way. An address is always opened in a new tab, whatever was asked for: replacing the page with somewhere else entirely would lose the user's place. |
public Uri UrlFor(OmniResult<T> result)Gets the address this action opens for the given result, or null when it isn't an address at all but something the host does itself.
internal sealed class OmniResultTintThe colors an OmniResult{T} icon tile is drawn with, derived from the one color the host passed: the glyph in that color and the tile in a wash of it, in a light and a dark variant.
- Namespace
- Tesserae
internal static class OmniResultTintsComputes - and remembers - the tile colors derived from a given icon color. A list of results usually draws the same handful of colors over and over (one per file type), and every one of them costs a parse and two HSL round-trips, so the results are cached by the color they came from.
- Namespace
- Tesserae
See also
- Inline Label — what an
OmniResultfooter is made of. - Pages Stack — the preview rail on the right of a row.
- Details Grid — the label/value block a preview shows.
- Modal — the sheet
ToModal()produces. - Components overview