@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.12 → 2.2.0-next.13

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 (24) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +55 -26
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +20 -2
  4. package/dist/automation/transmitter/transmitter.css.js +26 -13
  5. package/dist/automation/transmitter/transmitter.css.js.map +1 -1
  6. package/dist/automation/transmitter/transmitter.d.ts +9 -0
  7. package/dist/automation/transmitter/transmitter.d.ts.map +1 -1
  8. package/dist/automation/transmitter/transmitter.js +6 -0
  9. package/dist/automation/transmitter/transmitter.js.map +1 -1
  10. package/dist/automation/transmitter-stack/transmitter-stack.css.js +17 -13
  11. package/dist/automation/transmitter-stack/transmitter-stack.css.js.map +1 -1
  12. package/dist/automation/transmitter-stack/transmitter-stack.d.ts +8 -0
  13. package/dist/automation/transmitter-stack/transmitter-stack.d.ts.map +1 -1
  14. package/dist/automation/transmitter-stack/transmitter-stack.js +6 -0
  15. package/dist/automation/transmitter-stack/transmitter-stack.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/automation/transmitter/transmitter.css +14 -1
  18. package/src/automation/transmitter/transmitter.spec.ts +34 -0
  19. package/src/automation/transmitter/transmitter.stories.ts +22 -0
  20. package/src/automation/transmitter/transmitter.ts +9 -0
  21. package/src/automation/transmitter-stack/transmitter-stack.css +5 -1
  22. package/src/automation/transmitter-stack/transmitter-stack.spec.ts +27 -0
  23. package/src/automation/transmitter-stack/transmitter-stack.stories.ts +12 -0
  24. package/src/automation/transmitter-stack/transmitter-stack.ts +8 -0
@@ -0,0 +1,34 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {render} from 'vitest-browser-lit';
3
+ import {html} from 'lit';
4
+ import '../../main.css';
5
+ import './transmitter.js';
6
+ import type {ObcTransmitter} from './transmitter.js';
7
+ import type {ObcTransmitterButton} from '../transmitter-button/transmitter-button.js';
8
+
9
+ describe('obc-transmitter', () => {
10
+ it('keeps a line-less chip at the host edge in a wider container', async () => {
11
+ const screen = render(
12
+ html`<div style="width: 600px">
13
+ <obc-transmitter .showLine=${false} .value=${12.3} unit="m">
14
+ </obc-transmitter>
15
+ </div>`
16
+ );
17
+ const el = screen.container.querySelector(
18
+ 'obc-transmitter'
19
+ ) as ObcTransmitter;
20
+ await el.updateComplete;
21
+ const chip = el.shadowRoot!.querySelector('.chip') as ObcTransmitterButton;
22
+ await chip.updateComplete;
23
+
24
+ const host = el.getBoundingClientRect();
25
+ const chipBox = chip.getBoundingClientRect();
26
+ const box = el
27
+ .shadowRoot!.querySelector('.transmitter')!
28
+ .getBoundingClientRect();
29
+
30
+ expect(chipBox.width).toBeGreaterThan(0);
31
+ expect(chipBox.left).toBeCloseTo(host.left, 0);
32
+ expect(box.width).toBeCloseTo(chipBox.width, 0);
33
+ });
34
+ });
@@ -32,6 +32,7 @@ const meta: Meta<typeof ObcTransmitter> = {
32
32
  type: TransmitterType.value,
33
33
  size: TransmitterButtonSize.regular,
34
34
  lineType: LineType.fluid,
35
+ showLine: true,
35
36
  value: 12.3,
36
37
  unit: 'C',
37
38
  fractionDigits: 1,
@@ -105,6 +106,7 @@ function renderComponent(args: ObcTransmitter) {
105
106
  .orientation=${args.orientation}
106
107
  .type=${args.type}
107
108
  .lineType=${args.lineType}
109
+ .showLine=${args.showLine}
108
110
  .size=${args.size}
109
111
  .value=${args.value}
110
112
  .unit=${args.unit}
@@ -161,6 +163,26 @@ export const Right: Story = {
161
163
  render: (args) => renderComponent(args as ObcTransmitter),
162
164
  };
163
165
 
166
+ export const WithoutLine: Story = {
167
+ args: {showLine: false},
168
+ render: (args) => renderComponent(args as ObcTransmitter),
169
+ };
170
+
171
+ export const WithoutLineTop: Story = {
172
+ args: {showLine: false, orientation: TransmitterOrientation.top},
173
+ render: (args) => renderComponent(args as ObcTransmitter),
174
+ };
175
+
176
+ export const WithoutLineLeft: Story = {
177
+ args: {showLine: false, orientation: TransmitterOrientation.left},
178
+ render: (args) => renderComponent(args as ObcTransmitter),
179
+ };
180
+
181
+ export const WithoutLineRight: Story = {
182
+ args: {showLine: false, orientation: TransmitterOrientation.right},
183
+ render: (args) => renderComponent(args as ObcTransmitter),
184
+ };
185
+
164
186
  export const Indicator: Story = {
165
187
  args: {type: TransmitterType.indicator},
166
188
  render: (args) => renderComponent(args as ObcTransmitter),
@@ -53,6 +53,10 @@ export enum TransmitterType {
53
53
  * paired with a `horizontal-graph` (beside) or `vertical-graph` (below).
54
54
  * - **`orientation`** – `top`, `right`, `bottom`, `left`; controls which edge
55
55
  * the leader line attaches to.
56
+ * - **`showLine`** – draw the leader line (default). Set `false` when the
57
+ * line is drawn by other tools: the transmitter is then a plain box with no
58
+ * padding or anchor offset, and `orientation` only sets the side of the
59
+ * chip the id tag sits on.
56
60
  * - **Segments** – opt into a leading advice segment with `hasAdvice`/
57
61
  * `adviceValue` and a setpoint segment with `hasSetPoint`/`setpointValue`;
58
62
  * both are read-only and shown in the value chip for non-`indicator` types.
@@ -86,6 +90,9 @@ export enum TransmitterType {
86
90
  * only while a value is negative, so the chip's width does not change
87
91
  * across zero.
88
92
  * @property hasDegree - Show a degree column between the value and the unit (e.g. `12.3°` then `C`).
93
+ * @property showLine - Draw the leader line. Set `false` when the line is drawn by other tools;
94
+ * the transmitter is then a plain box with no padding or anchor offset, and
95
+ * `orientation` only sets the side of the chip the id tag sits on.
89
96
  * @property hasAlert - Wrap the transmitter in an `<obc-alert-frame>` when true.
90
97
  * @property alertFrameStatus - Severity of the alert frame, which picks its colour and flap badge:
91
98
  * `alarm` (default), `warning`, `caution` or one of the `level-*` severities.
@@ -121,6 +128,7 @@ export class ObcTransmitter extends LitElement {
121
128
  TransmitterOrientation.bottom;
122
129
  @property({type: String}) type: TransmitterType = TransmitterType.value;
123
130
  @property({type: String}) lineType: LineType | undefined = undefined;
131
+ @property({type: Boolean, attribute: false}) showLine = true;
124
132
 
125
133
  @property({type: Number}) value?: number | null;
126
134
  @property({type: String}) unit = '';
@@ -259,6 +267,7 @@ export class ObcTransmitter extends LitElement {
259
267
  class=${classMap({
260
268
  transmitter: true,
261
269
  'has-alert': this.hasAlert,
270
+ 'no-line': !this.showLine,
262
271
  [`orientation-${this.orientation}`]: true,
263
272
  [`type-${this.type}`]: true,
264
273
  })}
@@ -6,10 +6,14 @@
6
6
  display: block;
7
7
  }
8
8
 
9
- .transmitter {
9
+ .transmitter:not(.no-line) {
10
10
  @mixin transmitter-leader;
11
11
  }
12
12
 
13
+ .transmitter.no-line {
14
+ width: fit-content; /* a full-width box would stretch the 1fr segments across the container */
15
+ }
16
+
13
17
  .values {
14
18
  display: grid;
15
19
  grid-auto-flow: column;
@@ -188,6 +188,33 @@ describe('obc-transmitter-stack', () => {
188
188
  expect(narrow).toBeCloseTo(wide, 0);
189
189
  });
190
190
 
191
+ it('keeps line-less segments at their reading width in a wider container', async () => {
192
+ const screen = render(
193
+ html`<div style="width: 600px">
194
+ <obc-transmitter-stack
195
+ .showLine=${false}
196
+ .values=${[
197
+ {value: 1, unit: 'm'},
198
+ {value: 2, unit: 'm'},
199
+ ]}
200
+ ></obc-transmitter-stack>
201
+ </div>`
202
+ );
203
+ const el = screen.container.querySelector(
204
+ 'obc-transmitter-stack'
205
+ ) as ObcTransmitterStack;
206
+ await el.updateComplete;
207
+ await Promise.all(segments(el).map((segment) => segment.updateComplete));
208
+ const host = el.getBoundingClientRect();
209
+ const [first, second] = segments(el).map((segment) =>
210
+ segment.getBoundingClientRect()
211
+ );
212
+
213
+ expect(first.width).toBeGreaterThan(0);
214
+ expect(first.left).toBeCloseTo(host.left, 0);
215
+ expect(second.right - first.left).toBeLessThan(host.width / 2);
216
+ });
217
+
191
218
  it('keeps each segment at or above the 24 px pointer-target floor', async () => {
192
219
  const el = await setup([{value: 1, unit: 'm'}]);
193
220
  const [segment] = segments(el);
@@ -33,6 +33,7 @@ const meta: Meta<typeof ObcTransmitterStack> = {
33
33
  args: {
34
34
  orientation: TransmitterOrientation.bottom,
35
35
  lineType: LineType.fluid,
36
+ showLine: true,
36
37
  values: designValues,
37
38
  },
38
39
  argTypes: {
@@ -65,6 +66,7 @@ function renderComponent(args: ObcTransmitterStack) {
65
66
  <obc-transmitter-stack
66
67
  .orientation=${args.orientation}
67
68
  .lineType=${args.lineType}
69
+ .showLine=${args.showLine}
68
70
  .values=${args.values}
69
71
  >
70
72
  <obi-temperature-air slot="temperature"></obi-temperature-air>
@@ -93,6 +95,16 @@ export const Right: Story = {
93
95
  render: (args) => renderComponent(args as ObcTransmitterStack),
94
96
  };
95
97
 
98
+ export const WithoutLine: Story = {
99
+ args: {showLine: false},
100
+ render: (args) => renderComponent(args as ObcTransmitterStack),
101
+ };
102
+
103
+ export const WithoutLineTop: Story = {
104
+ args: {showLine: false, orientation: TransmitterOrientation.top},
105
+ render: (args) => renderComponent(args as ObcTransmitterStack),
106
+ };
107
+
96
108
  export const WithoutIdTags: Story = {
97
109
  args: {
98
110
  values: designValues.map((entry) => ({...entry, idTag: undefined})),
@@ -51,6 +51,10 @@ export interface TransmitterStackValueClickDetail {
51
51
  * ### Features / Variants
52
52
  * - **`orientation`** – `top`, `right`, `bottom`, `left`; the edge the leader
53
53
  * line attaches to. `top` places the id tags above the chip.
54
+ * - **`showLine`** – draw the leader line (default). Set `false` when the
55
+ * line is drawn by other tools: the stack is then a plain box with no
56
+ * padding or anchor offset, and `orientation` only decides whether the id
57
+ * tags sit above (`top`) or below the chip.
54
58
  * - **Values** – `value` and `unit` per segment. `idTag` adds a label row under
55
59
  * every segment once any value has one, so the chip stays aligned.
56
60
  * - **Formatting** – per value `fractionDigits` (default `1`), `maxDigits`
@@ -79,6 +83,8 @@ export interface TransmitterStackValueClickDetail {
79
83
  *
80
84
  * @property orientation - Edge of the chip the leader line attaches to.
81
85
  * @property lineType - Line the transmitter sits on; offsets the leader line by half its stroke.
86
+ * @property showLine - Draw the leader line. Set `false` when the line is drawn by other tools;
87
+ * the stack is then a plain box with no padding or anchor offset.
82
88
  * @property values - One segment per entry, in order.
83
89
  * @fires {CustomEvent<TransmitterStackValueClickDetail>} value-click - Fired when a segment is activated, with its value and index.
84
90
  * @fires click - Fired when any segment is clicked; `value-click` tells which.
@@ -89,6 +95,7 @@ export class ObcTransmitterStack extends LitElement {
89
95
  @property({type: String}) orientation: TransmitterOrientation =
90
96
  TransmitterOrientation.bottom;
91
97
  @property({type: String}) lineType: LineType | undefined = undefined;
98
+ @property({type: Boolean, attribute: false}) showLine = true;
92
99
  @property({type: Array}) values: TransmitterStackValue[] = [];
93
100
 
94
101
  private handleValueClick(index: number, value: TransmitterStackValue): void {
@@ -153,6 +160,7 @@ export class ObcTransmitterStack extends LitElement {
153
160
  <div
154
161
  class=${classMap({
155
162
  transmitter: true,
163
+ 'no-line': !this.showLine,
156
164
  [`orientation-${this.orientation}`]: true,
157
165
  })}
158
166
  style="--offset: ${transmitterLeaderOffset(this.lineType)}px;"