@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.70 → 2.0.0-next.71

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.
@@ -0,0 +1,103 @@
1
+ import {LitElement, html, unsafeCSS} from 'lit';
2
+ import {customElement} from '../../decorator.js';
3
+ import componentStyle from './textbox.css?inline';
4
+ import {property} from 'lit/decorators.js';
5
+ import {classMap} from 'lit/directives/class-map.js';
6
+
7
+ export enum ObcTextboxAlignment {
8
+ Left = 'left',
9
+ Center = 'center',
10
+ Right = 'right',
11
+ }
12
+
13
+ export enum ObcTextboxSize {
14
+ xs = 'xs',
15
+ s = 's',
16
+ m = 'm',
17
+ l = 'l',
18
+ xl = 'xl',
19
+ }
20
+
21
+ export enum ObcTextboxFontWeight {
22
+ regular = 'regular',
23
+ semibold = 'semibold',
24
+ bold = 'bold',
25
+ }
26
+
27
+ /**
28
+ * `<obc-textbox>` – A text container that renders inline text at a
29
+ * precise, cap-height-trimmed size with configurable alignment and reservable
30
+ * width.
31
+ *
32
+ * Use it to present short, read-only strings – such as values, labels, or
33
+ * units – where vertical metrics must line up exactly across rows and the
34
+ * horizontal footprint should stay stable while the text changes (for example
35
+ * a numeric value that updates frequently). Synonyms: text container, value
36
+ * box, label box.
37
+ *
38
+ * ## Features / Variants
39
+ * - **Size:** `xs`, `s`, `m` (default), `l`, `xl` – each maps to a fixed box
40
+ * height (16 / 20 / 24 / 32 / 40 px) with 4px padding above and below, giving
41
+ * cap heights of 8 / 12 / 16 / 24 / 32 px so text aligns to a predictable
42
+ * grid.
43
+ * - **Font weight:** `regular` (default), `semibold`, `bold`.
44
+ * - **Alignment:** `left`, `center`, `right` (default) – positions the text
45
+ * within the box's width when the box is wider than the content.
46
+ * - **Reserved width:** content placed in the `length` slot reserves a minimum
47
+ * width invisibly, so the box does not resize as the visible text changes.
48
+ * The box always shows all content – it never crops.
49
+ *
50
+ * ## Usage Guidelines
51
+ * - Pass the longest expected string to the `length` slot (e.g. `"888.8"` or
52
+ * `"Wind speed"`) so the box reserves space and does not jump in width as the
53
+ * visible value updates.
54
+ * - This is a display primitive for static text – use an input component for
55
+ * editable values.
56
+ *
57
+ * ## Slots
58
+ * | Slot | Renders when… | Purpose |
59
+ * |-----------|--------------------|------------------------------------------------------|
60
+ * | (default) | Always | The visible text content. |
61
+ * | `length` | Always (invisible) | Reserves a minimum width based on its content width. |
62
+ *
63
+ * @slot - The visible text content.
64
+ * @slot length - Reserves a minimum width based on its content width.
65
+ */
66
+ @customElement('obc-textbox')
67
+ export class ObcTextbox extends LitElement {
68
+ @property({type: String}) alignment: ObcTextboxAlignment =
69
+ ObcTextboxAlignment.Right;
70
+ @property({type: String}) size: ObcTextboxSize = ObcTextboxSize.m;
71
+ @property({type: String}) fontWeight: ObcTextboxFontWeight =
72
+ ObcTextboxFontWeight.regular;
73
+
74
+ override render() {
75
+ return html`
76
+ <div
77
+ class=${classMap({
78
+ wrapper: true,
79
+ [`alignment-${this.alignment}`]: true,
80
+ [`size-${this.size}`]: true,
81
+ [`font-weight-${this.fontWeight}`]: true,
82
+ })}
83
+ >
84
+ <div class="inner-wrapper">
85
+ <div class="content">
86
+ <slot></slot>
87
+ </div>
88
+ </div>
89
+ <div class="length-spacer" aria-hidden="true">
90
+ <slot name="length"></slot>
91
+ </div>
92
+ </div>
93
+ `;
94
+ }
95
+
96
+ static override styles = unsafeCSS(componentStyle);
97
+ }
98
+
99
+ declare global {
100
+ interface HTMLElementTagNameMap {
101
+ 'obc-textbox': ObcTextbox;
102
+ }
103
+ }