@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.88 → 2.0.0-next.90

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.
Files changed (31) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +17477 -16780
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +742 -43
  4. package/dist/building-blocks/readout-block/readout-block.css.js +229 -0
  5. package/dist/building-blocks/readout-block/readout-block.css.js.map +1 -0
  6. package/dist/building-blocks/readout-block/readout-block.d.ts +146 -0
  7. package/dist/building-blocks/readout-block/readout-block.d.ts.map +1 -0
  8. package/dist/building-blocks/readout-block/readout-block.js +273 -0
  9. package/dist/building-blocks/readout-block/readout-block.js.map +1 -0
  10. package/dist/navigation-instruments/readout-list/readout-list.css.js +26 -0
  11. package/dist/navigation-instruments/readout-list/readout-list.css.js.map +1 -0
  12. package/dist/navigation-instruments/readout-list/readout-list.d.ts +70 -0
  13. package/dist/navigation-instruments/readout-list/readout-list.d.ts.map +1 -0
  14. package/dist/navigation-instruments/readout-list/readout-list.js +154 -0
  15. package/dist/navigation-instruments/readout-list/readout-list.js.map +1 -0
  16. package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js +139 -124
  17. package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js.map +1 -1
  18. package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts +57 -26
  19. package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts.map +1 -1
  20. package/dist/navigation-instruments/readout-list-item/readout-list-item.js +139 -125
  21. package/dist/navigation-instruments/readout-list-item/readout-list-item.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/building-blocks/readout-block/readout-block.css +192 -0
  24. package/src/building-blocks/readout-block/readout-block.stories.ts +347 -0
  25. package/src/building-blocks/readout-block/readout-block.ts +355 -0
  26. package/src/navigation-instruments/readout-list/readout-list.css +15 -0
  27. package/src/navigation-instruments/readout-list/readout-list.stories.ts +358 -0
  28. package/src/navigation-instruments/readout-list/readout-list.ts +216 -0
  29. package/src/navigation-instruments/readout-list-item/readout-list-item.css +141 -120
  30. package/src/navigation-instruments/readout-list-item/readout-list-item.stories.ts +145 -29
  31. package/src/navigation-instruments/readout-list-item/readout-list-item.ts +169 -146
@@ -0,0 +1,355 @@
1
+ import {LitElement, html, nothing, unsafeCSS, type TemplateResult} from 'lit';
2
+ import {property, state} from 'lit/decorators.js';
3
+ import {classMap} from 'lit/directives/class-map.js';
4
+ import componentStyle from './readout-block.css?inline';
5
+ import {customElement} from '../../decorator.js';
6
+ import '../../components/textbox/textbox.js';
7
+ import {
8
+ ObcTextboxSize,
9
+ ObcTextboxFontWeight,
10
+ ObcTextboxAlignment,
11
+ } from '../../components/textbox/textbox.js';
12
+ import '../../icons/icon-input-right.js';
13
+ import '../../icons/icon-notification-advice.js';
14
+ import {
15
+ formatNumericValue,
16
+ readoutFormattedInteger,
17
+ type ReadoutNumericFormatOptions,
18
+ } from '../../navigation-instruments/readout/readout-formatters.js';
19
+ import {
20
+ type AlertFrameConfig,
21
+ wrapWithAlertFrame,
22
+ } from '../../components/alert-frame/alert-frame.js';
23
+
24
+ // Re-exported so consumers can configure typography without a second import path.
25
+ export {
26
+ ObcTextboxSize,
27
+ ObcTextboxFontWeight,
28
+ ObcTextboxAlignment,
29
+ } from '../../components/textbox/textbox.js';
30
+
31
+ /**
32
+ * Semantic variant of the block. Drives the default marker icon and the
33
+ * colour token; the layout is identical across variants.
34
+ * - `value`: the primary reading (no default marker icon).
35
+ * - `setpoint`: a setpoint reference (default `input-right` marker).
36
+ * - `advice`: an advisory reference (default `notification-advice` marker).
37
+ */
38
+ export enum ReadoutBlockVariant {
39
+ value = 'value',
40
+ setpoint = 'setpoint',
41
+ advice = 'advice',
42
+ }
43
+
44
+ /**
45
+ * Density tier of the block — drives icon size, the icon↔number gap, and the
46
+ * degree-column width tier. The number typography size is controlled
47
+ * independently via {@link ObcReadoutBlock.valueSize} so a parent can de-emphasise
48
+ * one block relative to another within the same tier.
49
+ */
50
+ export enum ReadoutBlockSize {
51
+ small = 'small',
52
+ medium = 'medium',
53
+ large = 'large',
54
+ }
55
+
56
+ /**
57
+ * Per-block measurement quality, rendered as a non-shifting outline chip.
58
+ * - `low-integrity`: the value is suspect.
59
+ * - `invalid`: the value is invalid.
60
+ */
61
+ export enum ReadoutBlockDataQuality {
62
+ lowIntegrity = 'low-integrity',
63
+ invalid = 'invalid',
64
+ }
65
+
66
+ /**
67
+ * Pop-up fade phase for a setpoint block. Driven by the parent's setpoint
68
+ * interaction state machine; only meaningful for `role="setpoint"`.
69
+ */
70
+ export enum ReadoutBlockHidePhase {
71
+ none = 'none',
72
+ hiding = 'hiding',
73
+ hidden = 'hidden',
74
+ }
75
+
76
+ /**
77
+ * `<obc-readout-block>` – the most atomic readout primitive: a single
78
+ * cap-height-aligned, width-reservable numeric segment (value / setpoint /
79
+ * advice).
80
+ *
81
+ * It renders one `obc-textbox` number with optional hinted leading zeros, a
82
+ * reservable width, an optional leading marker icon (via the `icon` slot or the
83
+ * role default), an optional trailing degree glyph, an `off`/unavailable text
84
+ * state, per-block data-quality and an optional per-block alert frame.
85
+ *
86
+ * This is a building block used inside `obc-readout-list-item` (and, in a future
87
+ * refactor, inside `obc-readout`); it is not normally used on its own. Colour is
88
+ * inherited from the host context (the parent sets the role colour), so the
89
+ * block stays neutral until placed.
90
+ *
91
+ * @experimental Pilot for the new primitives + per-block options Readout API; the
92
+ * API may change in a future release.
93
+ *
94
+ * @slot icon - Replaces the role's default marker icon.
95
+ *
96
+ * @csspart block - The block container (carries role / tone / data-quality).
97
+ * @csspart block-content - The number + degree group.
98
+ * @csspart block-text - The `obc-textbox` rendering the number.
99
+ * @csspart block-icon - The leading marker-icon container.
100
+ * @csspart degree - The trailing degree-glyph column.
101
+ */
102
+ @customElement('obc-readout-block')
103
+ export class ObcReadoutBlock extends LitElement {
104
+ /** Semantic variant (value / setpoint / advice). */
105
+ @property({type: String}) variant: ReadoutBlockVariant =
106
+ ReadoutBlockVariant.value;
107
+
108
+ /** The numeric value; `null`/`undefined` renders a dash. */
109
+ @property({type: Number}) value: number | null = null;
110
+
111
+ /** Density tier — icon size, gap, degree tier. */
112
+ @property({type: String}) size: ReadoutBlockSize = ReadoutBlockSize.small;
113
+
114
+ /**
115
+ * Resolved number-typography size. When unset it is derived from `size`
116
+ * (small→s, medium→m, large→l), so a parent that de-emphasises a block (e.g.
117
+ * a secondary setpoint) can pass a smaller size without changing the tier.
118
+ */
119
+ @property({type: String}) valueSize?: ObcTextboxSize;
120
+
121
+ /** Accent (in-command) colour tone. */
122
+ @property({type: Boolean}) enhanced = false;
123
+
124
+ /** Number font weight (regular / semibold / bold); colour is independent. */
125
+ @property({type: String}) weight: ObcTextboxFontWeight =
126
+ ObcTextboxFontWeight.regular;
127
+
128
+ /** Render the trailing cap-height degree glyph (`°`). */
129
+ @property({type: Boolean}) hasDegree = false;
130
+
131
+ /** Show the leading marker-icon container (always on for setpoint/advice). */
132
+ @property({type: Boolean}) hasIcon = false;
133
+
134
+ /** Number of fraction digits. */
135
+ @property({type: Number}) fractionDigits = 0;
136
+
137
+ /** Integer digits to reserve / hint (independent of `fractionDigits`). */
138
+ @property({type: Number}) maxDigits = 0;
139
+
140
+ /** Render muted leading zeros filling the integer part to `maxDigits`. */
141
+ @property({type: Boolean}) hintedZeros = false;
142
+
143
+ /** Explicit longest string to reserve width for (e.g. `"0000.0"`). */
144
+ @property({type: String}) spaceReserver?: string;
145
+
146
+ /** Render `offText` instead of a number (e.g. equipment powered down). */
147
+ @property({type: Boolean}) off = false;
148
+
149
+ /** Text shown when `off` is true. */
150
+ @property({type: String}) offText = 'OFF';
151
+
152
+ /** Text alignment of the number within its reserved width. */
153
+ @property({type: String}) alignment: ObcTextboxAlignment =
154
+ ObcTextboxAlignment.Right;
155
+
156
+ /** Per-block measurement quality (outline chip). */
157
+ @property({type: String}) dataQuality?: ReadoutBlockDataQuality;
158
+
159
+ // `boolean | …` (not `false | …`): the generated Angular wrapper widens a
160
+ // literal-`false` union to `boolean`. `wrapWithAlertFrame` treats any
161
+ // non-object as "no frame", so accepting `boolean` is harmless.
162
+ /** Per-block alert frame; nests inside any parent alert frame. */
163
+ @property({type: Object}) alert: boolean | AlertFrameConfig = false;
164
+
165
+ /** Setpoint focus (touch) state — only meaningful for `role="setpoint"`. */
166
+ @property({type: Boolean}) touching = false;
167
+
168
+ /** Setpoint pop-up fade phase — only meaningful for `role="setpoint"`. */
169
+ @property({type: String}) hidePhase: ReadoutBlockHidePhase =
170
+ ReadoutBlockHidePhase.none;
171
+
172
+ @state() private hasAssignedIcon = false;
173
+
174
+ private get resolvedValueSize(): ObcTextboxSize {
175
+ if (this.valueSize) {
176
+ return this.valueSize;
177
+ }
178
+ switch (this.size) {
179
+ case ReadoutBlockSize.large:
180
+ return ObcTextboxSize.l;
181
+ case ReadoutBlockSize.medium:
182
+ return ObcTextboxSize.m;
183
+ default:
184
+ return ObcTextboxSize.s;
185
+ }
186
+ }
187
+
188
+ private get numericFormatOptions(): ReadoutNumericFormatOptions {
189
+ return {
190
+ showZeroPadding: false,
191
+ minValueLength: this.maxDigits,
192
+ fractionDigits: this.fractionDigits,
193
+ };
194
+ }
195
+
196
+ /** Widest possible value string for width reservation (e.g. `"000.0"`). */
197
+ private get reserverText(): string {
198
+ const maxDigits = this.maxDigits;
199
+ if (maxDigits <= 0) {
200
+ return '';
201
+ }
202
+ const integer = '0'.repeat(Math.max(maxDigits, 1));
203
+ return this.fractionDigits > 0
204
+ ? `${integer}.${'0'.repeat(this.fractionDigits)}`
205
+ : integer;
206
+ }
207
+
208
+ /**
209
+ * Effective width reserver: the wider of the explicit `spaceReserver` and the
210
+ * `maxDigits`/`fractionDigits`-derived reserve, so an explicit reserver can
211
+ * never reserve *less* than the formatted value needs. Under tabular-nums the
212
+ * rendered width is proportional to character count, so "wider" compares length.
213
+ */
214
+ private widerReserver(explicit: string | undefined, derived: string): string {
215
+ if (!explicit) {
216
+ return derived;
217
+ }
218
+ if (!derived) {
219
+ return explicit;
220
+ }
221
+ return explicit.length >= derived.length ? explicit : derived;
222
+ }
223
+
224
+ private dataQualityClasses(): Record<string, boolean> {
225
+ return {
226
+ 'data-low-integrity':
227
+ this.dataQuality === ReadoutBlockDataQuality.lowIntegrity,
228
+ 'data-invalid': this.dataQuality === ReadoutBlockDataQuality.invalid,
229
+ };
230
+ }
231
+
232
+ private onIconSlotChange = (event: Event): void => {
233
+ // `slotchange` fires after the first render once content is (re)assigned,
234
+ // so it covers the initial state without a firstUpdated re-render.
235
+ this.hasAssignedIcon =
236
+ (event.target as HTMLSlotElement).assignedElements({flatten: true})
237
+ .length > 0;
238
+ };
239
+
240
+ private renderIcon(): TemplateResult | typeof nothing {
241
+ // Value blocks only show an icon when asked; setpoint/advice always reserve
242
+ // their marker. The role default is rendered as a direct child (so it sizes
243
+ // via `.block-icon obi-*`) and hidden once an icon is assigned to the slot —
244
+ // `{flatten: true}` sees through a forwarded-but-empty parent slot, so the
245
+ // default still shows when the consumer overrides nothing.
246
+ const showIcon = this.variant !== ReadoutBlockVariant.value || this.hasIcon;
247
+ if (!showIcon) {
248
+ return nothing;
249
+ }
250
+ let fallback: TemplateResult | typeof nothing = nothing;
251
+ if (this.variant === ReadoutBlockVariant.setpoint) {
252
+ fallback = html`<obi-input-right></obi-input-right>`;
253
+ } else if (this.variant === ReadoutBlockVariant.advice) {
254
+ fallback = html`<obi-notification-advice></obi-notification-advice>`;
255
+ }
256
+ return html`<span class="block-icon" part="block-icon" aria-hidden="true">
257
+ <slot name="icon" @slotchange=${this.onIconSlotChange}></slot>
258
+ ${this.hasAssignedIcon ? nothing : fallback}
259
+ </span>`;
260
+ }
261
+
262
+ /**
263
+ * A cap-height `°` column whose width scales with the number size. Inherits the
264
+ * block's colour.
265
+ */
266
+ private renderDegreeGlyph(size: ObcTextboxSize): TemplateResult {
267
+ return html`
268
+ <span
269
+ class=${classMap({
270
+ 'degree-column': true,
271
+ [`degree-${size}`]: true,
272
+ 'degree-inherit': true,
273
+ })}
274
+ part="degree"
275
+ >
276
+ <obc-textbox class="degree-glyph" .size=${size} alignment="center"
277
+ >°</obc-textbox
278
+ >
279
+ </span>
280
+ `;
281
+ }
282
+
283
+ override render() {
284
+ const valueSize = this.resolvedValueSize;
285
+ const formatOptions = this.numericFormatOptions;
286
+ const valueForFormat = this.value ?? undefined;
287
+ const text = this.off
288
+ ? this.offText
289
+ : formatNumericValue(valueForFormat, formatOptions);
290
+ // Hinted zeros pad the INTEGER part up to `maxDigits`, independent of
291
+ // `fractionDigits` (the decimal point and fraction digits never count toward
292
+ // `maxDigits`). Negative / dashed values are not padded. Example: value 1.2,
293
+ // maxDigits 3, fractionDigits 1 → "001.2".
294
+ const hintCount =
295
+ this.off ||
296
+ !this.hintedZeros ||
297
+ valueForFormat === undefined ||
298
+ valueForFormat < 0
299
+ ? 0
300
+ : Math.max(this.maxDigits - readoutFormattedInteger(text), 0);
301
+ const hinted = hintCount > 0 ? '0'.repeat(hintCount) : '';
302
+ // Hinted zeros own the width — they already fill to `maxDigits` — so when
303
+ // `hintedZeros` is enabled an explicit `spaceReserver` is ignored (it has
304
+ // higher priority). Otherwise the wider of the explicit reserver and the
305
+ // `maxDigits`-derived reserve wins.
306
+ const reserver = this.hintedZeros
307
+ ? this.reserverText
308
+ : this.widerReserver(this.spaceReserver, this.reserverText);
309
+
310
+ const block = html`
311
+ <div
312
+ class=${classMap({
313
+ block: true,
314
+ [`block-${this.variant}`]: true,
315
+ [`size-${this.size}`]: true,
316
+ 'tone-enhanced': this.enhanced,
317
+ touching: this.touching,
318
+ 'is-hiding': this.hidePhase === ReadoutBlockHidePhase.hiding,
319
+ 'is-hidden': this.hidePhase === ReadoutBlockHidePhase.hidden,
320
+ ...this.dataQualityClasses(),
321
+ })}
322
+ part="block block-${this.variant}"
323
+ >
324
+ ${this.renderIcon()}
325
+ <span class="block-content" part="block-content">
326
+ <obc-textbox
327
+ class="block-text"
328
+ part="block-text"
329
+ .size=${valueSize}
330
+ .fontWeight=${this.weight}
331
+ .alignment=${this.alignment}
332
+ .tabularNums=${true}
333
+ >
334
+ ${hinted
335
+ ? html`<span class="hinted-zero" aria-hidden="true"
336
+ >${hinted}</span
337
+ >`
338
+ : nothing}${text}
339
+ ${reserver ? html`<span slot="length">${reserver}</span>` : nothing}
340
+ </obc-textbox>
341
+ ${this.hasDegree ? this.renderDegreeGlyph(valueSize) : nothing}
342
+ </span>
343
+ </div>
344
+ `;
345
+ return wrapWithAlertFrame(this.alert ?? false, block);
346
+ }
347
+
348
+ static override styles = unsafeCSS(componentStyle);
349
+ }
350
+
351
+ declare global {
352
+ interface HTMLElementTagNameMap {
353
+ 'obc-readout-block': ObcReadoutBlock;
354
+ }
355
+ }
@@ -0,0 +1,15 @@
1
+ :host {
2
+ display: block;
3
+ width: 100%;
4
+ }
5
+
6
+ /* Vertical stack of rows. The 8px default row gap leaves room for a value alert
7
+ frame, which overhangs ~3px above and below each row — so two stacked rows that
8
+ both carry an alarm frame never collide. Override via
9
+ `--obc-readout-list-row-gap`. */
10
+ .list {
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: var(--obc-readout-list-row-gap, 8px);
14
+ width: 100%;
15
+ }