@oicl/openbridge-webcomponents-full-bundle 2.1.0-next.8 → 2.1.0-next.9

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 (52) hide show
  1. package/.storybook/preview.tsx +6 -1
  2. package/bundle/openbridge-webcomponents.bundle.js +25 -16
  3. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  4. package/custom-elements.json +8 -8
  5. package/dist/components/menu-button/menu-button.css.js +1 -1
  6. package/dist/components/menu-button/menu-button.css.js.map +1 -1
  7. package/dist/icons/icon-log-open-google.d.ts +16 -0
  8. package/dist/icons/icon-log-open-google.d.ts.map +1 -0
  9. package/dist/icons/icon-log-open-google.js +10 -0
  10. package/dist/icons/icon-log-open-google.js.map +1 -0
  11. package/dist/icons/icon-timer-google.d.ts +16 -0
  12. package/dist/icons/icon-timer-google.d.ts.map +1 -0
  13. package/dist/icons/icon-timer-google.js +10 -0
  14. package/dist/icons/icon-timer-google.js.map +1 -0
  15. package/dist/icons/index.d.ts +2 -0
  16. package/dist/icons/index.d.ts.map +1 -1
  17. package/dist/icons/index.js +2 -0
  18. package/dist/navigation-instruments/compass/compass.js +1 -1
  19. package/dist/navigation-instruments/compass/compass.js.map +1 -1
  20. package/dist/navigation-instruments/compass-flat/compass-flat.js +1 -1
  21. package/dist/navigation-instruments/compass-flat/compass-flat.js.map +1 -1
  22. package/dist/navigation-instruments/compass-sector/compass-sector.js +1 -1
  23. package/dist/navigation-instruments/compass-sector/compass-sector.js.map +1 -1
  24. package/dist/navigation-instruments/rate-of-turn/rate-of-turn.controller.js +2 -2
  25. package/dist/navigation-instruments/rate-of-turn/rate-of-turn.controller.js.map +1 -1
  26. package/dist/navigation-instruments/rate-of-turn/rate-of-turn.js +1 -1
  27. package/dist/navigation-instruments/rate-of-turn/rate-of-turn.js.map +1 -1
  28. package/dist/palettes/blinking.d.ts +5 -4
  29. package/dist/palettes/blinking.d.ts.map +1 -1
  30. package/dist/palettes/blinking.js +10 -9
  31. package/dist/palettes/blinking.js.map +1 -1
  32. package/docs/MigrationGuide.mdx +2 -0
  33. package/docs/MigrationGuide21.mdx +124 -0
  34. package/docs/migration-guide/flash-tempo.md +2 -2
  35. package/docs/migration-guide-2-1/automation-tokens.md +12 -0
  36. package/package.json +1 -1
  37. package/script/download-icons.ts +12 -0
  38. package/script/icon-aliases.test.ts +77 -0
  39. package/script/icon-aliases.ts +79 -0
  40. package/src/components/menu-button/menu-button.css +1 -1
  41. package/src/components/menu-button/menu-button.stories.ts +15 -1
  42. package/src/icons/icon-log-open-google.ts +18 -0
  43. package/src/icons/icon-timer-google.ts +18 -0
  44. package/src/icons/index.ts +2 -0
  45. package/src/navigation-instruments/compass/compass.ts +1 -1
  46. package/src/navigation-instruments/compass-flat/compass-flat.ts +1 -1
  47. package/src/navigation-instruments/compass-sector/compass-sector.ts +1 -1
  48. package/src/navigation-instruments/rate-of-turn/rate-of-turn.controller.ts +2 -2
  49. package/src/navigation-instruments/rate-of-turn/rate-of-turn.ts +1 -1
  50. package/src/navigation-instruments/rate-of-turn/rotations-per-minute.spec.ts +105 -0
  51. package/src/palettes/blinking.spec.ts +20 -6
  52. package/src/palettes/blinking.ts +10 -9
@@ -1,20 +1,21 @@
1
1
  import { FlashingSpeed } from "../types.js";
2
2
  //#region src/palettes/blinking.ts
3
- /** Shared on phase: every tempo lights up for the first 400 ms of its cycle. */
4
- var FLASH_ON_MS = {
5
- [FlashingSpeed.Fast]: 400,
6
- [FlashingSpeed.Slow]: 400,
7
- [FlashingSpeed.VerySlow]: 400
8
- };
9
3
  /**
10
- * The off phase carries the tempo. The cycles (800/1600/3200 ms) nest, so
11
- * every tempo lights up together at the start of the longest one (#1224).
4
+ * The on phase carries the tempo, so a flashing alert stays coloured for most
5
+ * of its cycle. The cycles (800/1600/3200 ms) nest, so every tempo lights up
6
+ * together at the start of the longest one and goes off with it (#1367).
12
7
  */
13
- var FLASH_OFF_MS = {
8
+ var FLASH_ON_MS = {
14
9
  [FlashingSpeed.Fast]: 400,
15
10
  [FlashingSpeed.Slow]: 1200,
16
11
  [FlashingSpeed.VerySlow]: 2800
17
12
  };
13
+ /** Shared off phase: every tempo goes off for the last 400 ms of its cycle. */
14
+ var FLASH_OFF_MS = {
15
+ [FlashingSpeed.Fast]: 400,
16
+ [FlashingSpeed.Slow]: 400,
17
+ [FlashingSpeed.VerySlow]: 400
18
+ };
18
19
  var FLASH_TEMPOS = [
19
20
  FlashingSpeed.Fast,
20
21
  FlashingSpeed.Slow,
@@ -1 +1 @@
1
- {"version":3,"file":"blinking.js","names":[],"sources":["../../src/palettes/blinking.ts"],"sourcesContent":["import {FlashingSpeed, type FlashTempo} from '../types.js';\n\n/** Shared on phase: every tempo lights up for the first 400 ms of its cycle. */\nexport const FLASH_ON_MS: Record<FlashTempo, number> = {\n [FlashingSpeed.Fast]: 400,\n [FlashingSpeed.Slow]: 400,\n [FlashingSpeed.VerySlow]: 400,\n};\n\n/**\n * The off phase carries the tempo. The cycles (800/1600/3200 ms) nest, so\n * every tempo lights up together at the start of the longest one (#1224).\n */\nexport const FLASH_OFF_MS: Record<FlashTempo, number> = {\n [FlashingSpeed.Fast]: 400,\n [FlashingSpeed.Slow]: 1200,\n [FlashingSpeed.VerySlow]: 2800,\n};\n\nexport const FLASH_TEMPOS: readonly FlashTempo[] = [\n FlashingSpeed.Fast,\n FlashingSpeed.Slow,\n FlashingSpeed.VerySlow,\n];\n\nexport function flashPeriodMs(tempo: FlashTempo): number {\n return FLASH_ON_MS[tempo] + FLASH_OFF_MS[tempo];\n}\n\n/** Animated custom property name; `on` reads 1 during the on phase, `off` 1 during the off phase. */\nexport function flashVariable(tempo: FlashTempo, phase: 'on' | 'off'): string {\n return `--flash-${tempo}-${phase}`;\n}\n\n/**\n * Animates `--flash-<tempo>-on` / `-off` on `el` for one tempo. Returns the\n * cancel function.\n */\nexport function installFlashing(\n el: HTMLElement,\n tempo: FlashTempo\n): () => void {\n const on = flashVariable(tempo, 'on');\n const off = flashVariable(tempo, 'off');\n const period = flashPeriodMs(tempo);\n const frames: Keyframe[] = [\n {[on]: 1, [off]: 0, easing: 'step-end'},\n {\n [on]: 0,\n [off]: 1,\n offset: FLASH_ON_MS[tempo] / period,\n easing: 'step-end',\n },\n {[on]: 0, [off]: 1},\n ];\n const anim = el.animate(frames, {duration: period, iterations: Infinity});\n // Document-timeline origin, so every flashing element is in the same phase.\n anim.startTime = 0;\n return () => anim.cancel();\n}\n\n/** Installs every tempo on `el`, for CSS that reads the variables directly. */\nexport function blinkingAll(el: HTMLElement): () => void {\n const cancels = FLASH_TEMPOS.map((tempo) => installFlashing(el, tempo));\n return () => cancels.forEach((cancel) => cancel());\n}\n"],"mappings":";;;AAGA,IAAa,cAA0C;EACpD,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,WAAW;AAC5B;;;;;AAMA,IAAa,eAA2C;EACrD,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,WAAW;AAC5B;AAEA,IAAa,eAAsC;CACjD,cAAc;CACd,cAAc;CACd,cAAc;AAChB;AAEA,SAAgB,cAAc,OAA2B;CACvD,OAAO,YAAY,SAAS,aAAa;AAC3C;;AAGA,SAAgB,cAAc,OAAmB,OAA6B;CAC5E,OAAO,WAAW,MAAM,GAAG;AAC7B;;;;;AAMA,SAAgB,gBACd,IACA,OACY;CACZ,MAAM,KAAK,cAAc,OAAO,IAAI;CACpC,MAAM,MAAM,cAAc,OAAO,KAAK;CACtC,MAAM,SAAS,cAAc,KAAK;CAClC,MAAM,SAAqB;EACzB;IAAE,KAAK;IAAI,MAAM;GAAG,QAAQ;EAAU;EACtC;IACG,KAAK;IACL,MAAM;GACP,QAAQ,YAAY,SAAS;GAC7B,QAAQ;EACV;EACA;IAAE,KAAK;IAAI,MAAM;EAAC;CACpB;CACA,MAAM,OAAO,GAAG,QAAQ,QAAQ;EAAC,UAAU;EAAQ,YAAY;CAAQ,CAAC;CAExE,KAAK,YAAY;CACjB,aAAa,KAAK,OAAO;AAC3B;;AAGA,SAAgB,YAAY,IAA6B;CACvD,MAAM,UAAU,aAAa,KAAK,UAAU,gBAAgB,IAAI,KAAK,CAAC;CACtE,aAAa,QAAQ,SAAS,WAAW,OAAO,CAAC;AACnD"}
1
+ {"version":3,"file":"blinking.js","names":[],"sources":["../../src/palettes/blinking.ts"],"sourcesContent":["import {FlashingSpeed, type FlashTempo} from '../types.js';\n\n/**\n * The on phase carries the tempo, so a flashing alert stays coloured for most\n * of its cycle. The cycles (800/1600/3200 ms) nest, so every tempo lights up\n * together at the start of the longest one and goes off with it (#1367).\n */\nexport const FLASH_ON_MS: Record<FlashTempo, number> = {\n [FlashingSpeed.Fast]: 400,\n [FlashingSpeed.Slow]: 1200,\n [FlashingSpeed.VerySlow]: 2800,\n};\n\n/** Shared off phase: every tempo goes off for the last 400 ms of its cycle. */\nexport const FLASH_OFF_MS: Record<FlashTempo, number> = {\n [FlashingSpeed.Fast]: 400,\n [FlashingSpeed.Slow]: 400,\n [FlashingSpeed.VerySlow]: 400,\n};\n\nexport const FLASH_TEMPOS: readonly FlashTempo[] = [\n FlashingSpeed.Fast,\n FlashingSpeed.Slow,\n FlashingSpeed.VerySlow,\n];\n\nexport function flashPeriodMs(tempo: FlashTempo): number {\n return FLASH_ON_MS[tempo] + FLASH_OFF_MS[tempo];\n}\n\n/** Animated custom property name; `on` reads 1 during the on phase, `off` 1 during the off phase. */\nexport function flashVariable(tempo: FlashTempo, phase: 'on' | 'off'): string {\n return `--flash-${tempo}-${phase}`;\n}\n\n/**\n * Animates `--flash-<tempo>-on` / `-off` on `el` for one tempo. Returns the\n * cancel function.\n */\nexport function installFlashing(\n el: HTMLElement,\n tempo: FlashTempo\n): () => void {\n const on = flashVariable(tempo, 'on');\n const off = flashVariable(tempo, 'off');\n const period = flashPeriodMs(tempo);\n const frames: Keyframe[] = [\n {[on]: 1, [off]: 0, easing: 'step-end'},\n {\n [on]: 0,\n [off]: 1,\n offset: FLASH_ON_MS[tempo] / period,\n easing: 'step-end',\n },\n {[on]: 0, [off]: 1},\n ];\n const anim = el.animate(frames, {duration: period, iterations: Infinity});\n // Document-timeline origin, so every flashing element is in the same phase.\n anim.startTime = 0;\n return () => anim.cancel();\n}\n\n/** Installs every tempo on `el`, for CSS that reads the variables directly. */\nexport function blinkingAll(el: HTMLElement): () => void {\n const cancels = FLASH_TEMPOS.map((tempo) => installFlashing(el, tempo));\n return () => cancels.forEach((cancel) => cancel());\n}\n"],"mappings":";;;;;;;AAOA,IAAa,cAA0C;EACpD,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,WAAW;AAC5B;;AAGA,IAAa,eAA2C;EACrD,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,cAAc,WAAW;AAC5B;AAEA,IAAa,eAAsC;CACjD,cAAc;CACd,cAAc;CACd,cAAc;AAChB;AAEA,SAAgB,cAAc,OAA2B;CACvD,OAAO,YAAY,SAAS,aAAa;AAC3C;;AAGA,SAAgB,cAAc,OAAmB,OAA6B;CAC5E,OAAO,WAAW,MAAM,GAAG;AAC7B;;;;;AAMA,SAAgB,gBACd,IACA,OACY;CACZ,MAAM,KAAK,cAAc,OAAO,IAAI;CACpC,MAAM,MAAM,cAAc,OAAO,KAAK;CACtC,MAAM,SAAS,cAAc,KAAK;CAClC,MAAM,SAAqB;EACzB;IAAE,KAAK;IAAI,MAAM;GAAG,QAAQ;EAAU;EACtC;IACG,KAAK;IACL,MAAM;GACP,QAAQ,YAAY,SAAS;GAC7B,QAAQ;EACV;EACA;IAAE,KAAK;IAAI,MAAM;EAAC;CACpB;CACA,MAAM,OAAO,GAAG,QAAQ,QAAQ;EAAC,UAAU;EAAQ,YAAY;CAAQ,CAAC;CAExE,KAAK,YAAY;CACjB,aAAa,KAAK,OAAO;AAC3B;;AAGA,SAAgB,YAAY,IAA6B;CACvD,MAAM,UAAU,aAAa,KAAK,UAAU,gBAAgB,IAAI,KAAK,CAAC;CACtE,aAAa,QAAQ,SAAS,WAAW,OAAO,CAAC;AACnD"}
@@ -23,6 +23,8 @@ This guide takes an app from `@oicl/openbridge-webcomponents` 1.0.1, the last re
23
23
 
24
24
  The [Changelog](?path=/docs/introduction-changelog--docs) lists every change. If you already run a `2.0.0-next` prerelease, use it for the changes between prereleases; this guide covers the difference from 1.0.1.
25
25
 
26
+ Already on 2.0? See [Migrating from 2.0 to 2.1](?path=/docs/introduction-migration-guide-2-0-to-2-1--docs) for what changed after this guide.
27
+
26
28
  ## Contents
27
29
 
28
30
  1. [Major Breaking Changes](#major-breaking-changes)
@@ -0,0 +1,124 @@
1
+ import {Meta, Markdown} from '@storybook/addon-docs/blocks';
2
+ import automationTokens from './migration-guide-2-1/automation-tokens.md?raw';
3
+
4
+ <Meta title="Introduction/Migration Guide 2.0 to 2.1" />
5
+
6
+ # Migrating from 2.0 to 2.1
7
+
8
+ 2.1 is a minor release for the components: no element, property, attribute, event or slot was removed or renamed, so markup and TypeScript that use them need no change. The design tokens are where the work is ([#1353](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1353)). Two things to do before upgrading: rename the 62 CSS variables you override, which go quiet rather than failing, and the 15 PostCSS mixins if your build compiles the sources from the full-bundle package, which fail the build until you do. Two icons were renamed as well, with their old names kept as aliases, and 711 palette values moved without any API change.
9
+
10
+ Coming from 1.0.1? Read [Migrating from 1.x to 2.0](?path=/docs/introduction-migration-guide--docs) first; this page is what changed after it. The [Changelog](?path=/docs/introduction-changelog--docs) lists every change.
11
+
12
+ ## Contents
13
+
14
+ 1. [Renamed CSS Variables](#renamed-css-variables)
15
+ 2. [Font Mixins](#font-mixins)
16
+ 3. [Icons](#icons)
17
+ 4. [Palette Values](#palette-values)
18
+ 5. [Deprecated Properties](#deprecated-properties)
19
+ 6. [Fixes You May See](#fixes-you-may-see)
20
+
21
+ ## Renamed CSS Variables
22
+
23
+ 62 names are gone from `openbridge.css`. A `var()` that names one resolves to nothing, and an override that sets one no longer reaches the component; neither raises an error, so search your stylesheets for the old names.
24
+
25
+ The palette variables are the library's own theming tokens rather than part of the stable component API, which is why a refresh of them lands in a minor release. They are listed here because an override that names one stops working without saying so.
26
+
27
+ ### Automation Colors
28
+
29
+ The automation colors moved from tone-based names to state-based ones: `device` became `symbol` and the pipes became `connector`, and `primary`, `secondary`, `tertiary` and their inverted pairs became the states `on`, `off`, `static` and `no-flow` with a background and a border role each. The whole family was recolored in the same change, so the pairs below match by the role each token plays, not by value.
30
+
31
+ <div style={{overflowX: 'auto'}}>
32
+
33
+ <Markdown>{automationTokens}</Markdown>
34
+
35
+ </div>
36
+
37
+ The inverted pipe pair has no exact successor; `no-flow` is the nearest role and is what the library and `@oicl/connector-diagram` now read. `--automation-device-secondary-inverted-color`, `--automation-pipe-secondary-color` and `--automation-pipe-secondary-inverted-color` are gone with no successor: nothing in the library read them.
38
+
39
+ ```css
40
+ /* 2.0 */
41
+ obc-pump {
42
+ --automation-device-primary-color: #2b6ad6;
43
+ }
44
+
45
+ /* 2.1 */
46
+ obc-pump {
47
+ --automation-symbol-on-background-color: #2b6ad6;
48
+ }
49
+ ```
50
+
51
+ ### Typography
52
+
53
+ 47 `--global-typography-generic-*` variables are `--global-typography-general-*`. Only that word changes:
54
+
55
+ ```css
56
+ /* 2.0 */
57
+ font-size: var(--global-typography-generic-m-font-size);
58
+
59
+ /* 2.1 */
60
+ font-size: var(--global-typography-general-m-font-size);
61
+ ```
62
+
63
+ The font-weight primitives were renumbered in the same refresh and every pointer into them was shifted to compensate, so the weight you get from a typography token is unchanged.
64
+
65
+ ## Font Mixins
66
+
67
+ The PostCSS mixins ship with the sources in `@oicl/openbridge-webcomponents-full-bundle`, so this applies only if your build uses them. The 15 `font-generic-beta-*` mixins are `font-general-*`, with the same five sizes and three weights:
68
+
69
+ ```css
70
+ /* 2.0 */
71
+ .label {
72
+ @mixin font-generic-beta-m-semibold;
73
+ }
74
+
75
+ /* 2.1 */
76
+ .label {
77
+ @mixin font-general-m-semibold;
78
+ }
79
+ ```
80
+
81
+ Eight `font-dev-code-*` and `font-dev-console-*` mixins are new.
82
+
83
+ ## Icons
84
+
85
+ Two icons were redrawn under new names, and both old names keep working as deprecated aliases, so markup and deep imports written against 2.0 still resolve:
86
+
87
+ - `obi-log-open-google` is `obi-log-open`
88
+ - `obi-timer-google` is `obi-timer`
89
+
90
+ An alias draws what the current icon draws, so the drawing changed even under the old name. The old names are left out of `iconIds`, so a picker built from it lists every icon once, under its current name. `obc-user-menu` uses the new names.
91
+
92
+ 553 icons changed their drawing and 15 arrived. The seven `obi-critical-*` alert icons are now kept by hand in the repository rather than generated from Figma; their names and drawings are unchanged.
93
+
94
+ ## Palette Values
95
+
96
+ 711 resolved values moved, 80 of them steps in the `--base-*` ramps. No code needs to change, but screenshot tests will show differences. The two visible groups:
97
+
98
+ - The automation devices and connectors carry the design team's recolor.
99
+ - `obc-integration-app-bar` and `obc-integration-bar-dropdown` read `--integration-container-global-color`, the same token `obc-integration-bar` reads, instead of `--integration-container-background-color`. The two values were a shade apart and are now the same, darker one.
100
+
101
+ To keep the 2.0 appearance of those two bars, point the token they now read back at the one they read before:
102
+
103
+ ```css
104
+ obc-integration-app-bar,
105
+ obc-integration-bar-dropdown {
106
+ --integration-container-global-color: var(
107
+ --integration-container-background-color
108
+ );
109
+ }
110
+ ```
111
+
112
+ ## Deprecated Properties
113
+
114
+ `obc-valve-analog-three-way-icon` gained `open1`, `open2`, `open3` and `orientation` ([#1346](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1346)). `value`, `value2` and `horisontal` are deprecated in favor of them, and `closed` in favor of setting every opening to `0`. All four still work. The two new elements built on it, `obc-analog-threeway-valve` and `obc-digital-threeway-valve`, are experimental.
115
+
116
+ ## Fixes You May See
117
+
118
+ These need no change, but they change what you see or what a test asserts:
119
+
120
+ - A component that first renders inside a hidden container, such as a closed tab, a dialog or a collapsed panel, draws correctly once it is shown ([#1351](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1351)). `obc-watch-flat`, `obc-rot-linear`, `obc-line-graph` and `obc-area-graph` were blank or mis-scaled in that case, so a workaround that forced a resize can go.
121
+ - `obc-textbox` paints descenders and diacritics instead of clipping them at the cap-height box ([#1338](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1338)).
122
+ - `obc-number-input-field` lets the browser place the caret and sizes a centered value to its content ([#1239](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1239)).
123
+ - `obc-analog-valve` draws its icon from the `obi-twoway-analog` set ([#1347](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1347)).
124
+ - `obc-alert-icon` draws a silenced warning with the warning's silenced glyph, and an unacknowledged alert held steady by `flashingSpeed="fixed"`; both drew the wrong thing or nothing ([#1340](https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/pull/1340)). An `obc-alert-menu-item` with the `rectified-unacknowledged` status keeps its ACK action and lists under Unacked.
@@ -1,5 +1,5 @@
1
1
  | 1.0.1 (on / off) | 2.0 | On / off | Alert types |
2
2
  | ------------------------------------------------------- | ----------------------------------------------- | ---------------- | ---------------------------- |
3
3
  | `--alarm-blink-on`, `--alarm-blink-off` (1 s / 1 s) | `--flash-fast-on`, `--flash-fast-off` | 400 ms / 400 ms | alarm, high, critical |
4
- | `--warning-blink-on`, `--warning-blink-off` (2 s / 2 s) | `--flash-slow-on`, `--flash-slow-off` | 400 ms / 1200 ms | warning, medium |
5
- | none | `--flash-very-slow-on`, `--flash-very-slow-off` | 400 ms / 2800 ms | low, and any rectified alert |
4
+ | `--warning-blink-on`, `--warning-blink-off` (2 s / 2 s) | `--flash-slow-on`, `--flash-slow-off` | 1200 ms / 400 ms | warning, medium |
5
+ | none | `--flash-very-slow-on`, `--flash-very-slow-off` | 2800 ms / 400 ms | low, and any rectified alert |
@@ -0,0 +1,12 @@
1
+ | 2.0 | 2.1 |
2
+ | --------------------------------------------- | -------------------------------------------------------------------------------- |
3
+ | `--automation-device-primary-color` | `--automation-symbol-on-background-color` |
4
+ | `--automation-device-tertiary-color` | `--automation-symbol-on-border-color` |
5
+ | `--automation-device-secondary-color` | `--automation-symbol-static-background-color` |
6
+ | `--automation-device-primary-inverted-color` | `--automation-symbol-off-background-color` |
7
+ | `--automation-device-tertiary-inverted-color` | `--automation-symbol-off-border-color` |
8
+ | `--automation-pipe-primary-color` | `--automation-connector-on-background-color` |
9
+ | `--automation-pipe-tertiary-color` | `--automation-connector-on-border-color` |
10
+ | `--automation-pipe-primary-inverted-color` | `--automation-connector-no-flow-background-color` |
11
+ | `--automation-pipe-tertiary-inverted-color` | `--automation-connector-no-flow-border-color` |
12
+ | `--on-background-color`, `--on-border-color` | `--automation-button-on-background-color`, `--automation-button-on-border-color` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oicl/openbridge-webcomponents-full-bundle",
3
- "version": "2.1.0-next.8",
3
+ "version": "2.1.0-next.9",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,6 +17,7 @@ import {
17
17
  kebabToUpperCamelCase,
18
18
  writeUnresolvedFigmaVariablesReport,
19
19
  } from './convert-icons.js';
20
+ import {planRenamedIconAliases, renamedIconAlias} from './icon-aliases.js';
20
21
 
21
22
  dotenv.config();
22
23
 
@@ -356,6 +357,17 @@ declare global {
356
357
  scriptMapping.push(`'${icon.name}': ['${icon.categories.join("', '")}']`);
357
358
  }
358
359
 
360
+ const aliases = planRenamedIconAliases(
361
+ icons.map((icon) => icon.name.toLowerCase())
362
+ );
363
+ for (const {oldName, currentName} of aliases) {
364
+ fs.writeFileSync(
365
+ `./src/icons/icon-${oldName}.ts`,
366
+ renamedIconAlias(oldName, currentName)
367
+ );
368
+ fileImport.push(`import './icon-${oldName}.js';`);
369
+ }
370
+
359
371
  // write script
360
372
  const script = `export const iconIds: Record<string, string[]> = {
361
373
  ${scriptMapping.sort().join(',\n')}
@@ -0,0 +1,77 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {
3
+ RENAMED_ICONS,
4
+ planRenamedIconAliases,
5
+ renamedIconAlias,
6
+ } from './icon-aliases.js';
7
+
8
+ describe('renamedIconAlias', () => {
9
+ const source = renamedIconAlias('log-open-google', 'log-open');
10
+
11
+ it('registers the old tag on a subclass of the current icon', () => {
12
+ expect(source).toContain("@customElement('obi-log-open-google')");
13
+ expect(source).toContain(
14
+ 'export class ObiLogOpenGoogle extends ObiLogOpen {}'
15
+ );
16
+ expect(source).toContain("import {ObiLogOpen} from './icon-log-open.js';");
17
+ });
18
+
19
+ it('marks the alias deprecated and names its replacement', () => {
20
+ expect(source).toContain('@deprecated');
21
+ expect(source).toContain('`<obi-log-open>`');
22
+ });
23
+
24
+ it('declares the tag so TypeScript resolves it', () => {
25
+ expect(source).toContain("'obi-log-open-google': ObiLogOpenGoogle;");
26
+ });
27
+
28
+ it('upper-camel-cases every segment, digits included', () => {
29
+ expect(renamedIconAlias('wind-true-10-old', 'wind-true-10')).toContain(
30
+ 'export class ObiWindTrue10Old extends ObiWindTrue10 {}'
31
+ );
32
+ });
33
+ });
34
+
35
+ describe('RENAMED_ICONS', () => {
36
+ it('points every old name at a different, current one', () => {
37
+ for (const [from, to] of Object.entries(RENAMED_ICONS)) {
38
+ expect(from).not.toBe(to);
39
+ expect(RENAMED_ICONS[to]).toBeUndefined();
40
+ }
41
+ });
42
+ });
43
+
44
+ describe('planRenamedIconAliases', () => {
45
+ it('pairs every entry with the icon it extends', () => {
46
+ expect(
47
+ planRenamedIconAliases(['log-open', 'timer', 'anchor'], {
48
+ 'log-open-google': 'log-open',
49
+ 'timer-google': 'timer',
50
+ })
51
+ ).toEqual([
52
+ {oldName: 'log-open-google', currentName: 'log-open'},
53
+ {oldName: 'timer-google', currentName: 'timer'},
54
+ ]);
55
+ });
56
+
57
+ it('fails when the export has no icon under the current name', () => {
58
+ expect(() =>
59
+ planRenamedIconAliases(['timer'], {'log-open-google': 'log-open'})
60
+ ).toThrow(/obi-log-open, which this export does not have/);
61
+ });
62
+
63
+ it('fails when the export carries the old name again', () => {
64
+ expect(() =>
65
+ planRenamedIconAliases(['log-open', 'log-open-google'], {
66
+ 'log-open-google': 'log-open',
67
+ })
68
+ ).toThrow(/carries obi-log-open-google again/);
69
+ });
70
+
71
+ it('plans the committed map against the generated set', () => {
72
+ const generated = Object.values(RENAMED_ICONS);
73
+ expect(planRenamedIconAliases(generated, RENAMED_ICONS)).toHaveLength(
74
+ Object.keys(RENAMED_ICONS).length
75
+ );
76
+ });
77
+ });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @module IconAliases
3
+ * @description
4
+ * The old tags of renamed icons, emitted by `download:icons` beside the
5
+ * generated set.
6
+ *
7
+ * Figma renames an icon from time to time, and the generated set then carries
8
+ * only the new name: the old tag resolves to nothing and renders nothing. An
9
+ * entry here keeps that tag alive as an element extending the current icon, so
10
+ * markup and deep imports written against an earlier release still work and the
11
+ * drawing is the current one. Dropping an alias removes a published element and
12
+ * belongs in a major release.
13
+ */
14
+ import {kebabToUpperCamelCase} from './convert-icons.js';
15
+
16
+ /** Old icon name to the name it carries now. */
17
+ export const RENAMED_ICONS: Record<string, string> = {
18
+ 'log-open-google': 'log-open',
19
+ 'timer-google': 'timer',
20
+ };
21
+
22
+ /**
23
+ * The aliases to write for one export, checked against the names it generated.
24
+ *
25
+ * Two ways the map can go stale, both of which stop the run rather than
26
+ * quietly writing the wrong thing: the icon an alias extends is gone, so the
27
+ * alias would not compile, and the export carries the old name again, where
28
+ * writing the alias would overwrite a generated icon and leave its name in
29
+ * `names.ts`. Either way the map needs reconciling against the export.
30
+ */
31
+ export function planRenamedIconAliases(
32
+ generatedNames: Iterable<string>,
33
+ renamed: Record<string, string> = RENAMED_ICONS
34
+ ): Array<{oldName: string; currentName: string}> {
35
+ const generated = new Set(generatedNames);
36
+ return Object.entries(renamed).map(([oldName, currentName]) => {
37
+ if (generated.has(oldName)) {
38
+ throw new Error(
39
+ `[icon-aliases] This export carries obi-${oldName} again, which RENAMED_ICONS keeps as an alias of obi-${currentName}. Drop the entry so the generated icon stands on its own.`
40
+ );
41
+ }
42
+ if (!generated.has(currentName)) {
43
+ throw new Error(
44
+ `[icon-aliases] RENAMED_ICONS points obi-${oldName} at obi-${currentName}, which this export does not have. Point it at the current name or drop the entry.`
45
+ );
46
+ }
47
+ return {oldName, currentName};
48
+ });
49
+ }
50
+
51
+ /**
52
+ * The source of one alias element.
53
+ *
54
+ * The alias stays out of `names.ts`, so an icon picker built from `iconIds`
55
+ * lists every icon once, under its current name.
56
+ */
57
+ export function renamedIconAlias(oldName: string, currentName: string): string {
58
+ const oldClass = `Obi${kebabToUpperCamelCase(oldName)}`;
59
+ const currentClass = `Obi${kebabToUpperCamelCase(currentName)}`;
60
+ return `import {customElement} from '../decorator.js';
61
+ import {${currentClass}} from './icon-${currentName}.js';
62
+
63
+ /**
64
+ * \`<obi-${oldName}>\` is the name this icon had before it was renamed to
65
+ * \`<obi-${currentName}>\`, kept so markup from an earlier release keeps working.
66
+ * It draws what \`<obi-${currentName}>\` draws.
67
+ *
68
+ * @deprecated Use \`obi-${currentName}\`.
69
+ */
70
+ @customElement('obi-${oldName}')
71
+ export class ${oldClass} extends ${currentClass} {}
72
+
73
+ declare global {
74
+ interface HTMLElementTagNameMap {
75
+ 'obi-${oldName}': ${oldClass};
76
+ }
77
+ }
78
+ `;
79
+ }
@@ -101,7 +101,7 @@
101
101
  }
102
102
 
103
103
  &.open-top {
104
- .positioned-menu {
104
+ & + .positioned-menu {
105
105
  bottom: anchor(bottom);
106
106
  top: unset;
107
107
  }
@@ -1,4 +1,5 @@
1
1
  import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
+ import {expect, waitFor} from 'storybook/test';
2
3
  import {ObcMenuButton} from './menu-button.js';
3
4
  import './menu-button.js';
4
5
  import {html} from 'lit';
@@ -156,7 +157,20 @@ export const OpenTop: Story = {
156
157
  hasIcon: true,
157
158
  openTop: true,
158
159
  },
159
- render: renderWithIcon,
160
+ render: (args) =>
161
+ html`<div style="padding-top: 160px">${renderWithIcon(args)}</div>`,
162
+ play: async ({canvasElement, userEvent}) => {
163
+ const el = canvasElement.querySelector('obc-menu-button')!;
164
+ const trigger = el.shadowRoot!.querySelector<HTMLElement>('.wrapper')!;
165
+ const menu = el.shadowRoot!.querySelector<HTMLElement>('.positioned-menu')!;
166
+ await userEvent.click(trigger);
167
+ await waitFor(() => expect(menu.matches(':popover-open')).toBe(true));
168
+ const triggerBottom = trigger.getBoundingClientRect().bottom;
169
+ await expect(menu.getBoundingClientRect().bottom).toBeCloseTo(
170
+ triggerBottom,
171
+ 0
172
+ );
173
+ },
160
174
  };
161
175
 
162
176
  /** Default regular context menu button with icon and label. */
@@ -0,0 +1,18 @@
1
+ import {customElement} from '../decorator.js';
2
+ import {ObiLogOpen} from './icon-log-open.js';
3
+
4
+ /**
5
+ * `<obi-log-open-google>` is the name this icon had before it was renamed to
6
+ * `<obi-log-open>`, kept so markup from an earlier release keeps working.
7
+ * It draws what `<obi-log-open>` draws.
8
+ *
9
+ * @deprecated Use `obi-log-open`.
10
+ */
11
+ @customElement('obi-log-open-google')
12
+ export class ObiLogOpenGoogle extends ObiLogOpen {}
13
+
14
+ declare global {
15
+ interface HTMLElementTagNameMap {
16
+ 'obi-log-open-google': ObiLogOpenGoogle;
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ import {customElement} from '../decorator.js';
2
+ import {ObiTimer} from './icon-timer.js';
3
+
4
+ /**
5
+ * `<obi-timer-google>` is the name this icon had before it was renamed to
6
+ * `<obi-timer>`, kept so markup from an earlier release keeps working.
7
+ * It draws what `<obi-timer>` draws.
8
+ *
9
+ * @deprecated Use `obi-timer`.
10
+ */
11
+ @customElement('obi-timer-google')
12
+ export class ObiTimerGoogle extends ObiTimer {}
13
+
14
+ declare global {
15
+ interface HTMLElementTagNameMap {
16
+ 'obi-timer-google': ObiTimerGoogle;
17
+ }
18
+ }
@@ -1137,6 +1137,7 @@ import './icon-location-u.js';
1137
1137
  import './icon-location.js';
1138
1138
  import './icon-log-add-google.js';
1139
1139
  import './icon-log-edit-google.js';
1140
+ import './icon-log-open-google.js';
1140
1141
  import './icon-log-open.js';
1141
1142
  import './icon-logic-01-off.js';
1142
1143
  import './icon-logic-01-on.js';
@@ -1836,6 +1837,7 @@ import './icon-time-less.js';
1836
1837
  import './icon-time-more.js';
1837
1838
  import './icon-time.js';
1838
1839
  import './icon-timer-2.js';
1840
+ import './icon-timer-google.js';
1839
1841
  import './icon-timer.js';
1840
1842
  import './icon-touch.js';
1841
1843
  import './icon-track-no.js';
@@ -235,7 +235,7 @@ export class ObcCompass extends LitElement {
235
235
  * `rotDotAnimationFactor`) instead. Takes effect only when
236
236
  * `rateOfTurnDegreesPerMinute` is `undefined`.
237
237
  */
238
- @property({type: Number}) rotationsPerMinute: number = 1;
238
+ @property({type: Number}) rotationsPerMinute: number = 0;
239
239
  @property({type: String}) rotType: RotType = RotType.dots;
240
240
  @property({type: String}) rotPosition: RotPosition = RotPosition.innerCircle;
241
241
  @property({type: Number}) rotMaxValue: number = 60;
@@ -118,7 +118,7 @@ export class ObcCompassFlat extends LitElement {
118
118
  * @deprecated Use `rateOfTurnDegreesPerMinute` instead.
119
119
  * @availableWhen rotType!=undefined
120
120
  */
121
- @property({type: Number}) rotationsPerMinute: number = 1;
121
+ @property({type: Number}) rotationsPerMinute: number = 0;
122
122
  @property({type: Number}) rotMaxValue: number = 60;
123
123
  @property({type: Number}) rotArcExtent: number = 60;
124
124
  @property({type: Boolean}) rotPortStarboard: boolean = false;
@@ -185,7 +185,7 @@ export class ObcCompassSector extends LitElement {
185
185
  * `rateOfTurnDegreesPerMinute` is `undefined`.
186
186
  * @availableWhen rotType!=undefined && rateOfTurnDegreesPerMinute==undefined
187
187
  */
188
- @property({type: Number}) rotationsPerMinute: number = 1;
188
+ @property({type: Number}) rotationsPerMinute: number = 0;
189
189
  @property({type: Number}) rotMaxValue: number = 60;
190
190
  @property({type: Boolean}) rotPortStarboard: boolean = false;
191
191
  @property({type: Number}) rotAtZeroDeadband: number = ROT_ZERO_DEADBAND_DEG;
@@ -5,13 +5,13 @@ export class RateOfTurnController implements ReactiveController {
5
5
  private host: ReactiveControllerHost;
6
6
  readonly el: Element;
7
7
  private animation?: Animation;
8
- private _rotationsPerMinute = 1;
8
+ private _rotationsPerMinute = 0;
9
9
  private _cyclePx = 0;
10
10
 
11
11
  constructor(
12
12
  host: ReactiveControllerHost,
13
13
  el: Element,
14
- initialRotationsPerMinute = 1,
14
+ initialRotationsPerMinute = 0,
15
15
  cyclePx = 0
16
16
  ) {
17
17
  this.host = host;
@@ -95,7 +95,7 @@ export class ObcRateOfTurn extends LitElement {
95
95
  * `rotDotAnimationFactor`) instead. Takes effect only when
96
96
  * `rateOfTurnDegreesPerMinute` is `undefined`.
97
97
  */
98
- @property({type: Number}) rotationsPerMinute: number = 1;
98
+ @property({type: Number}) rotationsPerMinute: number = 0;
99
99
 
100
100
  @property({type: String}) rotType: RotType = RotType.dots;
101
101
  @property({type: String}) rotPosition: RotPosition = RotPosition.scale;
@@ -0,0 +1,105 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {render} from 'vitest-browser-lit';
3
+ import {html, type TemplateResult} from 'lit';
4
+ import type {LitElement} from 'lit';
5
+ import './rate-of-turn.js';
6
+ import '../compass/compass.js';
7
+ import '../compass-flat/compass-flat.js';
8
+ import '../compass-sector/compass-sector.js';
9
+ import {RotType} from './rot-renderer.js';
10
+
11
+ type RotHost = LitElement & {
12
+ rotationsPerMinute: number;
13
+ rateOfTurnDegreesPerMinute: number | undefined;
14
+ };
15
+
16
+ /**
17
+ * One controller, four renderings: each host forwards its rate of turn to a
18
+ * watch (or the flat strip), which owns the spinning dots.
19
+ */
20
+ const HOSTS: {tag: string; watchTag: string; template: TemplateResult}[] = [
21
+ {
22
+ tag: 'obc-compass',
23
+ watchTag: 'obc-watch',
24
+ template: html`<obc-compass .rotType=${RotType.dots}></obc-compass>`,
25
+ },
26
+ {
27
+ tag: 'obc-compass-flat',
28
+ watchTag: 'obc-watch-flat',
29
+ template: html`<obc-compass-flat
30
+ .rotType=${RotType.dots}
31
+ ></obc-compass-flat>`,
32
+ },
33
+ {
34
+ tag: 'obc-compass-sector',
35
+ watchTag: 'obc-watch',
36
+ template: html`<obc-compass-sector
37
+ .rotType=${RotType.dots}
38
+ ></obc-compass-sector>`,
39
+ },
40
+ {
41
+ tag: 'obc-rate-of-turn',
42
+ watchTag: 'obc-watch',
43
+ template: html`<obc-rate-of-turn
44
+ .rotType=${RotType.dots}
45
+ ></obc-rate-of-turn>`,
46
+ },
47
+ ];
48
+
49
+ async function mount(host: (typeof HOSTS)[number]): Promise<{
50
+ el: RotHost;
51
+ watch: RotHost;
52
+ spinner: () => Animation | undefined;
53
+ }> {
54
+ const screen = render(
55
+ html`<div style="width: 400px; height: 400px">${host.template}</div>`
56
+ );
57
+ const el = screen.container.querySelector(host.tag) as RotHost;
58
+ await el.updateComplete;
59
+ const watch = el.shadowRoot!.querySelector(host.watchTag) as RotHost;
60
+ await watch.updateComplete;
61
+ const spinner = () =>
62
+ (
63
+ watch.shadowRoot!.querySelector('#rot-spinner') as SVGGElement | null
64
+ )?.getAnimations()[0];
65
+ return {el, watch, spinner};
66
+ }
67
+
68
+ for (const host of HOSTS) {
69
+ describe(`${host.tag} with no rate-of-turn input`, () => {
70
+ it('does not spin the dots', async () => {
71
+ const {el, watch, spinner} = await mount(host);
72
+ expect(el.rateOfTurnDegreesPerMinute).toBeUndefined();
73
+ expect(el.rotationsPerMinute).toBe(0);
74
+ expect(watch.rotationsPerMinute).toBe(0);
75
+ expect(spinner()?.playState).toBe('paused');
76
+ });
77
+
78
+ it('still spins them for the deprecated rotationsPerMinute', async () => {
79
+ const {el, watch, spinner} = await mount(host);
80
+ el.rotationsPerMinute = 1;
81
+ await el.updateComplete;
82
+ await watch.updateComplete;
83
+ expect(spinner()?.playState).toBe('running');
84
+ });
85
+ });
86
+
87
+ describe(`${host.tag} with rateOfTurnDegreesPerMinute set`, () => {
88
+ it('spins the dots', async () => {
89
+ const {el, watch, spinner} = await mount(host);
90
+ el.rateOfTurnDegreesPerMinute = 360;
91
+ await el.updateComplete;
92
+ await watch.updateComplete;
93
+ expect(spinner()?.playState).toBe('running');
94
+ });
95
+
96
+ it('wins over the deprecated rotationsPerMinute', async () => {
97
+ const {el, watch, spinner} = await mount(host);
98
+ el.rotationsPerMinute = 1;
99
+ el.rateOfTurnDegreesPerMinute = 0;
100
+ await el.updateComplete;
101
+ await watch.updateComplete;
102
+ expect(spinner()?.playState).toBe('paused');
103
+ });
104
+ });
105
+ }