Reference·JavaScript · @bimworks/viewercommonJavaScript

TemplateSpec

Interface in @bimworks/viewercommon.

API catalogue · @bimworks/viewercommon · Interface

TypeScript#
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#

TypeScript#
compactSize?: [width: number, height: number]

The compact state's size in CSS pixels when it is fixed: never measured. Required for kind "svg"

css#

TypeScript#
css?: string

CSS for this template, in its own shadow root: its class names are its own

defaults#

TypeScript#
defaults?: Partial<AnnotationLayerOptions<D>>

Layer options this template works best with; the layer's own options win

expandable#

TypeScript#
expandable?: boolean

Whether render draws an expanded state (ctx.state "expanded"), shown in a card on hover or click

fields#

TypeScript#
fields?: Record<string, string>

BQL expressions this template needs, by data key: a layer's {where} query asks for them as GET

hover#

TypeScript#
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#

TypeScript#
kind?: "html" | "svg"

"html" (default), or "svg": the viewer draws the result into an root of compactSize

name#

TypeScript#
name: string

Unique name: of the stylesheet, in diagnostics, and the one a layer or BVL refers to

origin#

TypeScript#
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#

TypeScript#
refreshMs?: number

Draw the shown annotations again this often, and evaluate every row's status and priority (relative times, readings going stale)

expands#

TypeScript#
expands?(data: D): boolean

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 it). Default: every row of an expandable template opens one

Parameters#

Name Type Description
data D

label#

TypeScript#
label?(data: D): string

Accessible name of the annotation

Parameters#

Name Type Description
data D

priority#

TypeScript#
priority?(data: D): number

Higher first: which annotations survive limits and front a cluster; nearest first among equals

Parameters#

Name Type Description
data D

render#

TypeScript#
render(data: D, ctx: TemplateContext): string | Node | TemplateResult | null

Draws one row

Parameters#

Name Type Description
data D
ctx TemplateContext

status#

TypeScript#
status?(data: D): { color: string; label: string } | null

A 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