TemplateSpec
Interface in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Interface
interface TemplateSpec<D>Type parameters#
| Name | Constraint | Description |
|---|---|---|
D |
`` |
Members#
| Member | Kind | Description |
|---|---|---|
| compactSize | Property | The compact state's size in CSS pixels when it is fixed: never measured. Required for kind "svg" |
| css | Property | CSS for this template, in its own shadow root: its class names are its own |
| defaults | Property | Layer options this template works best with; the layer's own options win |
| expandable | Property | Whether render draws an expanded state (ctx.state "expanded"), shown in a card on hover or click |
| fields | Property | BQL expressions this template needs, by data key: a layer's {where} query asks for them as GET |
| hover | Property | How the compact state shows that it, or its object, is hovered: "lift" (default), the viewer raises it with an outline in the accent along its shape; "templa… |
| kind | Property | "html" (default), or "svg": the viewer draws the result into an root of compactSize |
| name | Property | Unique name: of the stylesheet, in diagnostics, and the one a layer or BVL refers to |
| origin | Property | Which point of the compact box sits on the anchor: [0.5, 0.5] centre (default), [0.5, 1] a pin's tip |
| refreshMs | Property | Draw the shown annotations again this often, and evaluate every row's status and priority (relative times, readings going stale) |
| expands | Method | Whether a row's expanded state shows more than its compact state; a row for which it is false opens no card (that card would repeat the compact state beside … |
| label | Method | Accessible name of the annotation |
| priority | Method | Higher first: which annotations survive limits and front a cluster; nearest first among equals |
| render | Method | Draws one row |
| status | Method | A row's status colour and label: a cluster's count is ringed by its members' colours, and its tooltip counts the labels |
compactSize#
compactSize?: [width: number, height: number]The compact state's size in CSS pixels when it is fixed: never measured. Required for kind "svg"
css#
css?: stringCSS for this template, in its own shadow root: its class names are its own
defaults#
defaults?: Partial<AnnotationLayerOptions<D>>Layer options this template works best with; the layer's own options win
expandable#
expandable?: booleanWhether render draws an expanded state (ctx.state "expanded"), shown in a card on hover or click
fields#
fields?: Record<string, string>BQL expressions this template needs, by data key: a layer's {where} query asks for them as GET
hover#
hover?: "template" | "lift"How the compact state shows that it, or its object, is hovered: "lift" (default), the viewer raises it with an outline in the accent along its shape; "template", render draws it from ctx.hovered and the viewer adds nothing
kind#
kind?: "html" | "svg""html" (default), or "svg": the viewer draws the result into an
name#
name: stringUnique name: of the stylesheet, in diagnostics, and the one a layer or BVL refers to
origin#
origin?: [x: number, y: number]Which point of the compact box sits on the anchor: [0.5, 0.5] centre (default), [0.5, 1] a pin's tip
refreshMs#
refreshMs?: numberDraw the shown annotations again this often, and evaluate every row's status and priority (relative times, readings going stale)
expands#
expands?(data: D): booleanWhether a row's expanded state shows more than its compact state; a row for which it is false opens no card (that card would repeat the compact state beside it). Default: every row of an expandable template opens one
Parameters#
| Name | Type | Description |
|---|---|---|
data |
D |
label#
label?(data: D): stringAccessible name of the annotation
Parameters#
| Name | Type | Description |
|---|---|---|
data |
D |
priority#
priority?(data: D): numberHigher first: which annotations survive limits and front a cluster; nearest first among equals
Parameters#
| Name | Type | Description |
|---|---|---|
data |
D |
render#
render(data: D, ctx: TemplateContext): string | Node | TemplateResult | nullDraws one row
Parameters#
| Name | Type | Description |
|---|---|---|
data |
D |
|
ctx |
TemplateContext |
status#
status?(data: D): { color: string; label: string } | nullA row's status colour and label: a cluster's count is ringed by its members' colours, and its tooltip counts the labels
Parameters#
| Name | Type | Description |
|---|---|---|
data |
D |