@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.16 → 2.2.0-next.17

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 (36) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +173 -20
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +1713 -14
  4. package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts +4 -4
  5. package/dist/automation/analog-threeway-valve/analog-threeway-valve.js.map +1 -1
  6. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +20 -0
  7. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
  8. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +1 -0
  9. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
  10. package/dist/automation/automation-button/abstract-automation-button.d.ts +11 -2
  11. package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
  12. package/dist/automation/automation-button/abstract-automation-button.js +40 -20
  13. package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
  14. package/dist/automation/automation-button/badge-layout.d.ts +34 -0
  15. package/dist/automation/automation-button/badge-layout.d.ts.map +1 -0
  16. package/dist/automation/automation-button/badge-layout.js +64 -0
  17. package/dist/automation/automation-button/badge-layout.js.map +1 -0
  18. package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts +4 -4
  19. package/dist/automation/digital-threeway-valve/digital-threeway-valve.js.map +1 -1
  20. package/dist/automation/electricity-battery/electricity-battery.d.ts +4 -4
  21. package/dist/automation/electricity-battery/electricity-battery.js.map +1 -1
  22. package/dist/internal/global-setting.d.ts +55 -0
  23. package/dist/internal/global-setting.d.ts.map +1 -0
  24. package/dist/internal/global-setting.js +86 -0
  25. package/dist/internal/global-setting.js.map +1 -0
  26. package/package.json +1 -1
  27. package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +4 -4
  28. package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
  29. package/src/automation/automation-button/abstract-automation-button.ts +57 -23
  30. package/src/automation/automation-button/badge-layout.spec.ts +138 -0
  31. package/src/automation/automation-button/badge-layout.ts +120 -0
  32. package/src/automation/digital-threeway-valve/digital-threeway-valve.ts +4 -4
  33. package/src/automation/electricity-battery/electricity-battery.ts +4 -4
  34. package/src/automation/pump/pump.stories.ts +59 -0
  35. package/src/internal/global-setting.spec.ts +119 -0
  36. package/src/internal/global-setting.ts +105 -0
@@ -20165,6 +20165,139 @@ var ObcAutomationBadge = class ObcAutomationBadge extends i$4 {
20165
20165
  __decorate([n$4({ type: String })], ObcAutomationBadge.prototype, "mode", void 0);
20166
20166
  __decorate([n$4({ type: String })], ObcAutomationBadge.prototype, "type", void 0);
20167
20167
  ObcAutomationBadge = __decorate([customElement("obc-automation-badge")], ObcAutomationBadge);
20168
+ // src/internal/global-setting.ts
20169
+ /**
20170
+ * One app-wide setting the components render from.
20171
+ *
20172
+ * The application sets it once through a module setter such as
20173
+ * `setAutomationBadgeLayout()` or `setAlertStandard()`. Every connected host
20174
+ * that holds a controller for it re-renders on each change; a host detached
20175
+ * while the value changed catches up on its next connect, and one reattached
20176
+ * unchanged renders nothing extra. Setting the same value again is a no-op.
20177
+ *
20178
+ * It is a plain subscriber set rather than a signal: the value rarely changes
20179
+ * and derives nothing, and the library stays off a pre-standard polyfill. A
20180
+ * setter built on it can move to a signal later without changing its signature.
20181
+ *
20182
+ * ```ts
20183
+ * const alertStandard = new GlobalSetting<AlertStandard | undefined>(undefined);
20184
+ * export const setAlertStandard = (s?: AlertStandard) => alertStandard.set(s);
20185
+ *
20186
+ * class ObcAlertIcon extends LitElement {
20187
+ * private readonly standard = alertStandard.controller(this);
20188
+ * render() { return draw(this.standard.value); }
20189
+ * }
20190
+ * ```
20191
+ */
20192
+ var GlobalSetting = class {
20193
+ constructor(value) {
20194
+ this.value = value;
20195
+ this.currentVersion = 0;
20196
+ this.hosts = /* @__PURE__ */ new Set();
20197
+ }
20198
+ get() {
20199
+ return this.value;
20200
+ }
20201
+ /** Stores the value and re-renders every connected host. */
20202
+ set(value) {
20203
+ if (Object.is(value, this.value)) return;
20204
+ this.value = value;
20205
+ this.currentVersion++;
20206
+ for (const host of this.hosts) host.requestUpdate();
20207
+ }
20208
+ /** Re-renders `host` whenever the value changes; create it once, in the host's constructor. */
20209
+ controller(host) {
20210
+ return new GlobalSettingController(host, this);
20211
+ }
20212
+ /** Counts the changes, so a controller can tell whether its host rendered the current value. */
20213
+ get version() {
20214
+ return this.currentVersion;
20215
+ }
20216
+ attach(host) {
20217
+ this.hosts.add(host);
20218
+ }
20219
+ detach(host) {
20220
+ this.hosts.delete(host);
20221
+ }
20222
+ };
20223
+ /** Keeps one host rendered with the current value of a `GlobalSetting`. */
20224
+ var GlobalSettingController = class {
20225
+ constructor(host, setting) {
20226
+ this.host = host;
20227
+ this.setting = setting;
20228
+ this.renderedVersion = setting.version;
20229
+ this.renderingVersion = setting.version;
20230
+ host.addController(this);
20231
+ }
20232
+ get value() {
20233
+ return this.setting.get();
20234
+ }
20235
+ /** A value set while the host was detached never reached it. */
20236
+ hostConnected() {
20237
+ this.setting.attach(this.host);
20238
+ if (this.renderedVersion !== this.setting.version) this.host.requestUpdate();
20239
+ }
20240
+ hostDisconnected() {
20241
+ this.setting.detach(this.host);
20242
+ }
20243
+ /** The version a render starts from; a change while it runs detached must not count as rendered. */
20244
+ hostUpdate() {
20245
+ this.renderingVersion = this.setting.version;
20246
+ }
20247
+ hostUpdated() {
20248
+ this.renderedVersion = this.renderingVersion;
20249
+ }
20250
+ };
20251
+ // src/automation/automation-button/badge-layout.ts
20252
+ var AutomationButtonBadgeKind = /* @__PURE__ */ function(AutomationButtonBadgeKind) {
20253
+ AutomationButtonBadgeKind["Control"] = "control";
20254
+ AutomationButtonBadgeKind["Alert"] = "alert";
20255
+ AutomationButtonBadgeKind["Interlock"] = "interlock";
20256
+ AutomationButtonBadgeKind["CommandLocked"] = "command-locked";
20257
+ return AutomationButtonBadgeKind;
20258
+ }({});
20259
+ var corners = [
20260
+ "topLeft",
20261
+ "topRight",
20262
+ "bottomLeft",
20263
+ "bottomRight"
20264
+ ];
20265
+ var defaultAutomationButtonBadgeLayout = Object.freeze({
20266
+ topLeft: "control",
20267
+ topRight: "alert",
20268
+ bottomLeft: "interlock",
20269
+ bottomRight: "command-locked"
20270
+ });
20271
+ /**
20272
+ * The `base` layout with the corners `override` names put on top of it.
20273
+ * A kind `override` names twice stays in the first corner, in reading order.
20274
+ */
20275
+ function resolveBadgeLayout(base, override) {
20276
+ const result = { ...base };
20277
+ if (!override) return result;
20278
+ const placed = /* @__PURE__ */ new Set();
20279
+ for (const corner of corners) {
20280
+ const kind = override[corner];
20281
+ if (kind === void 0) continue;
20282
+ result[corner] = kind !== null && placed.has(kind) ? null : kind;
20283
+ if (kind !== null) placed.add(kind);
20284
+ }
20285
+ for (const corner of corners) {
20286
+ const kind = result[corner];
20287
+ if (override[corner] === void 0 && kind !== null && placed.has(kind)) result[corner] = null;
20288
+ }
20289
+ return result;
20290
+ }
20291
+ var globalLayout = new GlobalSetting({ ...defaultAutomationButtonBadgeLayout });
20292
+ /** Re-renders its host when the global badge layout changes, and puts the host's own corners on top of it. */
20293
+ var BadgeLayoutController = class extends GlobalSettingController {
20294
+ constructor(host) {
20295
+ super(host, globalLayout);
20296
+ }
20297
+ resolve(local) {
20298
+ return resolveBadgeLayout(this.value, local);
20299
+ }
20300
+ };
20168
20301
  // src/automation/automation-button/abstract-automation-button.ts
20169
20302
  var AutomationButtonBadgeAlert = /* @__PURE__ */ function(AutomationButtonBadgeAlert) {
20170
20303
  AutomationButtonBadgeAlert["None"] = "none";
@@ -20207,8 +20340,11 @@ var AutomationButtonBadgeCommandLocked = /* @__PURE__ */ function(AutomationButt
20207
20340
  *
20208
20341
  * Renders an `<obc-automation-button>` with the shared surface every device
20209
20342
  * button needs: the readout stack and its status row, the alert frame, the
20210
- * circular progress indicator, and the four badge corners (control, alert,
20211
- * interlock, command-locked) with their slots and enum-driven fallbacks.
20343
+ * circular progress indicator, and the four badge corners with their slots and
20344
+ * enum-driven fallbacks. Which badge goes in which corner follows the badge
20345
+ * layout (`badge-layout.ts`): control top-left, alert top-right, interlock
20346
+ * bottom-left and command-locked bottom-right unless the app or `badgeLayout`
20347
+ * moves them.
20212
20348
  *
20213
20349
  * ## Usage Guidelines
20214
20350
  *
@@ -20230,6 +20366,7 @@ var AutomationButtonBadgeCommandLocked = /* @__PURE__ */ function(AutomationButt
20230
20366
  * @availableWhen alertFrameMode alert==true
20231
20367
  * @availableWhen showAlertCategoryIcon alert==true && alertFrameType in [SmallSideFlip, LargeSideFlip, BottomFlip, TopFlip]
20232
20368
  * @availableWhen showAlertIcon alert==true && alertFrameType in [LargeSideFlip, BottomFlip, TopFlip]
20369
+ * @property badgeLayout - Which badge kind each corner shows, on top of the app-wide layout set with `setAutomationBadgeLayout()`. A corner left out keeps the app-wide badge, `null` leaves it empty, and a badge moved here leaves the corner it came from.
20233
20370
  * @property progress - Shows a progress indicator, used to indicate that an user action is in progress
20234
20371
  * @availableWhen progressMode progress==true
20235
20372
  * @availableWhen progressValue progress==true && progressMode in [determinate, progressiveIndeterminate]
@@ -20260,6 +20397,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20260
20397
  this.badgeCommandLocked = "none";
20261
20398
  this.badgeInterlock = "none";
20262
20399
  this.badgeAlert = "none";
20400
+ this.badgeLayout = void 0;
20401
+ this._badgeLayout = new BadgeLayoutController(this);
20263
20402
  }
20264
20403
  get icon() {
20265
20404
  throw new Error("Method \"icon\" must be implemented in subclass");
@@ -20310,12 +20449,12 @@ var ObcAbstractAutomationButton = class extends i$4 {
20310
20449
  get _isVertical() {
20311
20450
  return this._orientation !== AutomationButtonOrientation.horizontal || "vertical" in this && Boolean(this.vertical);
20312
20451
  }
20313
- getBadgeSpacer() {
20452
+ getBadgeSpacer(badges) {
20314
20453
  if (!this.showReadoutStack) return false;
20315
- const topLeft = this.badgeTopLeft.length > 0 || this.getBadgeControlType() !== null;
20316
- const topRight = this.badgeTopRight.length > 0 || this.getBadgeAlertType() !== null;
20317
- const bottomLeft = this.badgeBottomLeft.length > 0 || this.getBadgeInterlockType() !== null;
20318
- const bottomRight = this.badgeBottomRight.length > 0 || this.getBadgeCommandLockedType() !== null;
20454
+ const topLeft = this.badgeTopLeft.length > 0 || badges.topLeft !== null;
20455
+ const topRight = this.badgeTopRight.length > 0 || badges.topRight !== null;
20456
+ const bottomLeft = this.badgeBottomLeft.length > 0 || badges.bottomLeft !== null;
20457
+ const bottomRight = this.badgeBottomRight.length > 0 || badges.bottomRight !== null;
20319
20458
  if (this._readoutPosition === AutomationButtonReadoutPosition.top) return topRight || topLeft;
20320
20459
  else if (this._readoutPosition === AutomationButtonReadoutPosition.bottom) return bottomLeft || bottomRight;
20321
20460
  else if (this._readoutPosition === AutomationButtonReadoutPosition.left) return topLeft || bottomLeft;
@@ -20325,6 +20464,15 @@ var ObcAbstractAutomationButton = class extends i$4 {
20325
20464
  handleBadgeSlotChange() {
20326
20465
  this.requestUpdate();
20327
20466
  }
20467
+ getBadgeType(kind) {
20468
+ switch (kind) {
20469
+ case AutomationButtonBadgeKind.Control: return this.getBadgeControlType();
20470
+ case AutomationButtonBadgeKind.Alert: return this.getBadgeAlertType();
20471
+ case AutomationButtonBadgeKind.Interlock: return this.getBadgeInterlockType();
20472
+ case AutomationButtonBadgeKind.CommandLocked: return this.getBadgeCommandLockedType();
20473
+ default: return null;
20474
+ }
20475
+ }
20328
20476
  getBadgeAlertType() {
20329
20477
  if (this.badgeAlert === "silence") return ObcAutomationBadgeType.AlertSilenced;
20330
20478
  else if (this.badgeAlert === "shelved") return ObcAutomationBadgeType.AlertShelved;
@@ -20359,10 +20507,13 @@ var ObcAbstractAutomationButton = class extends i$4 {
20359
20507
  }
20360
20508
  render() {
20361
20509
  const readouts = [...this.extraReadouts];
20362
- const badgeAlertType = this.getBadgeAlertType();
20363
- const badgeControlType = this.getBadgeControlType();
20364
- const badgeInterlockType = this.getBadgeInterlockType();
20365
- const badgeCommandLockedType = this.getBadgeCommandLockedType();
20510
+ const layout = this._badgeLayout.resolve(this.badgeLayout);
20511
+ const badges = {
20512
+ topLeft: this.getBadgeType(layout.topLeft),
20513
+ topRight: this.getBadgeType(layout.topRight),
20514
+ bottomLeft: this.getBadgeType(layout.bottomLeft),
20515
+ bottomRight: this.getBadgeType(layout.bottomRight)
20516
+ };
20366
20517
  return b`<obc-automation-button
20367
20518
  .state=${this._on ? AutomationButtonState.open : AutomationButtonState.closed}
20368
20519
  .readouts=${readouts}
@@ -20384,7 +20535,7 @@ var ObcAbstractAutomationButton = class extends i$4 {
20384
20535
  .variant=${this._variant}
20385
20536
  .direction=${this._direction}
20386
20537
  .orientation=${this._orientation}
20387
- .hasBadgeSpacer=${this.getBadgeSpacer()}
20538
+ .hasBadgeSpacer=${this.getBadgeSpacer(badges)}
20388
20539
  .handlePosition=${this._handlePosition}
20389
20540
  .static=${this.static}
20390
20541
  .handleSize=${this._handleSize}
@@ -20398,8 +20549,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20398
20549
  slot="badge-top-right"
20399
20550
  @slotchange=${this.handleBadgeSlotChange}
20400
20551
  >
20401
- ${badgeAlertType ? b`<obc-automation-badge
20402
- .type=${badgeAlertType}
20552
+ ${badges.topRight ? b`<obc-automation-badge
20553
+ .type=${badges.topRight}
20403
20554
  ></obc-automation-badge>` : A}
20404
20555
  </slot>
20405
20556
  <slot
@@ -20407,8 +20558,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20407
20558
  slot="badge-top-left"
20408
20559
  @slotchange=${this.handleBadgeSlotChange}
20409
20560
  >
20410
- ${badgeControlType ? b`<obc-automation-badge
20411
- .type=${badgeControlType}
20561
+ ${badges.topLeft ? b`<obc-automation-badge
20562
+ .type=${badges.topLeft}
20412
20563
  ></obc-automation-badge>` : A}
20413
20564
  </slot>
20414
20565
  <slot
@@ -20416,8 +20567,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20416
20567
  slot="badge-bottom-left"
20417
20568
  @slotchange=${this.handleBadgeSlotChange}
20418
20569
  >
20419
- ${badgeInterlockType ? b`<obc-automation-badge
20420
- .type=${badgeInterlockType}
20570
+ ${badges.bottomLeft ? b`<obc-automation-badge
20571
+ .type=${badges.bottomLeft}
20421
20572
  ></obc-automation-badge>` : A}
20422
20573
  </slot>
20423
20574
  <slot
@@ -20425,8 +20576,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20425
20576
  slot="badge-bottom-right"
20426
20577
  @slotchange=${this.handleBadgeSlotChange}
20427
20578
  >
20428
- ${badgeCommandLockedType ? b`<obc-automation-badge
20429
- .type=${badgeCommandLockedType}
20579
+ ${badges.bottomRight ? b`<obc-automation-badge
20580
+ .type=${badges.bottomRight}
20430
20581
  ></obc-automation-badge>` : A}
20431
20582
  </slot>
20432
20583
  ${this._handle !== false ? this._handle : A}
@@ -20468,6 +20619,7 @@ __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badg
20468
20619
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeCommandLocked", void 0);
20469
20620
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeInterlock", void 0);
20470
20621
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeAlert", void 0);
20622
+ __decorate([n$4({ attribute: false })], ObcAbstractAutomationButton.prototype, "badgeLayout", void 0);
20471
20623
  __decorate([o$7({ slot: "badge-top-right" })], ObcAbstractAutomationButton.prototype, "badgeTopRight", void 0);
20472
20624
  __decorate([o$7({ slot: "badge-top-left" })], ObcAbstractAutomationButton.prototype, "badgeTopLeft", void 0);
20473
20625
  __decorate([o$7({ slot: "badge-bottom-left" })], ObcAbstractAutomationButton.prototype, "badgeBottomLeft", void 0);
@@ -20916,6 +21068,7 @@ var argTypesAbstractAutomationButton = {
20916
21068
  options: Object.values(AutomationButtonBadgeAlert),
20917
21069
  control: { type: "select" }
20918
21070
  },
21071
+ badgeLayout: { control: { type: "object" } },
20919
21072
  progressMode: {
20920
21073
  options: Object.values(CircularProgressMode),
20921
21074
  control: { type: "select" },