@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.171 → 2.0.0-next.172

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 (90) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +104 -70
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +691 -41
  4. package/dist/automation/automation-button/abstract-automation-button-motorized.d.ts +11 -1
  5. package/dist/automation/automation-button/abstract-automation-button-motorized.d.ts.map +1 -1
  6. package/dist/automation/automation-button/abstract-automation-button-motorized.js +14 -4
  7. package/dist/automation/automation-button/abstract-automation-button-motorized.js.map +1 -1
  8. package/dist/automation/automation-button/abstract-automation-button-squared.d.ts +25 -1
  9. package/dist/automation/automation-button/abstract-automation-button-squared.d.ts.map +1 -1
  10. package/dist/automation/automation-button/abstract-automation-button-squared.js +27 -3
  11. package/dist/automation/automation-button/abstract-automation-button-squared.js.map +1 -1
  12. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +12 -0
  13. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
  14. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +8 -0
  15. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
  16. package/dist/automation/bipolar-transistor/bipolar-transistor.js +4 -4
  17. package/dist/automation/bipolar-transistor/bipolar-transistor.js.map +1 -1
  18. package/dist/automation/capacitor/capacitor.js +4 -4
  19. package/dist/automation/capacitor/capacitor.js.map +1 -1
  20. package/dist/automation/converter/converter.js +4 -4
  21. package/dist/automation/converter/converter.js.map +1 -1
  22. package/dist/automation/damper/damper.js +1 -1
  23. package/dist/automation/damper/damper.js.map +1 -1
  24. package/dist/automation/diodes/diodes.js +6 -6
  25. package/dist/automation/diodes/diodes.js.map +1 -1
  26. package/dist/automation/fan/fan.js +1 -1
  27. package/dist/automation/fan/fan.js.map +1 -1
  28. package/dist/automation/filter/filter.js +4 -4
  29. package/dist/automation/filter/filter.js.map +1 -1
  30. package/dist/automation/ground/ground.js +3 -3
  31. package/dist/automation/ground/ground.js.map +1 -1
  32. package/dist/automation/logic/logic.js +6 -6
  33. package/dist/automation/logic/logic.js.map +1 -1
  34. package/dist/automation/mosfet/mosfet.js +8 -8
  35. package/dist/automation/mosfet/mosfet.js.map +1 -1
  36. package/dist/automation/motor/motor.js +2 -2
  37. package/dist/automation/motor/motor.js.map +1 -1
  38. package/dist/automation/pump/pump.js +2 -2
  39. package/dist/automation/pump/pump.js.map +1 -1
  40. package/dist/automation/resistor/resistor.js +5 -5
  41. package/dist/automation/resistor/resistor.js.map +1 -1
  42. package/dist/automation/router/router.js +2 -2
  43. package/dist/automation/router/router.js.map +1 -1
  44. package/dist/automation/source/source.js +5 -5
  45. package/dist/automation/source/source.js.map +1 -1
  46. package/dist/automation/switch/switch.js +4 -4
  47. package/dist/automation/switch/switch.js.map +1 -1
  48. package/dist/automation/transformer/transformer.js +2 -2
  49. package/dist/automation/transformer/transformer.js.map +1 -1
  50. package/eslint.config.mjs +56 -0
  51. package/package.json +1 -1
  52. package/script/eslint-rules.test.ts +44 -0
  53. package/src/automation/automation-button/abstract-automation-button-motorized.ts +20 -4
  54. package/src/automation/automation-button/abstract-automation-button-squared.ts +33 -3
  55. package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +2 -0
  56. package/src/automation/automation-button/turned-on.spec.ts +64 -0
  57. package/src/automation/bipolar-transistor/bipolar-transistor.stories.ts +2 -2
  58. package/src/automation/bipolar-transistor/bipolar-transistor.ts +4 -4
  59. package/src/automation/capacitor/capacitor.stories.ts +2 -2
  60. package/src/automation/capacitor/capacitor.ts +4 -4
  61. package/src/automation/converter/converter.stories.ts +2 -2
  62. package/src/automation/converter/converter.ts +4 -4
  63. package/src/automation/damper/damper.stories.ts +2 -2
  64. package/src/automation/damper/damper.ts +1 -1
  65. package/src/automation/diodes/diodes.stories.ts +2 -2
  66. package/src/automation/diodes/diodes.ts +6 -6
  67. package/src/automation/fan/fan.stories.ts +3 -3
  68. package/src/automation/fan/fan.ts +1 -1
  69. package/src/automation/filter/filter.stories.ts +2 -2
  70. package/src/automation/filter/filter.ts +4 -4
  71. package/src/automation/ground/ground.stories.ts +2 -2
  72. package/src/automation/ground/ground.ts +3 -3
  73. package/src/automation/logic/logic.stories.ts +2 -2
  74. package/src/automation/logic/logic.ts +6 -6
  75. package/src/automation/mosfet/mosfet.stories.ts +2 -2
  76. package/src/automation/mosfet/mosfet.ts +8 -8
  77. package/src/automation/motor/motor.stories.ts +7 -7
  78. package/src/automation/motor/motor.ts +2 -2
  79. package/src/automation/pump/pump.stories.ts +5 -5
  80. package/src/automation/pump/pump.ts +2 -2
  81. package/src/automation/resistor/resistor.stories.ts +2 -2
  82. package/src/automation/resistor/resistor.ts +5 -5
  83. package/src/automation/router/router.stories.ts +2 -2
  84. package/src/automation/router/router.ts +2 -2
  85. package/src/automation/source/source.stories.ts +2 -2
  86. package/src/automation/source/source.ts +5 -5
  87. package/src/automation/switch/switch.stories.ts +4 -4
  88. package/src/automation/switch/switch.ts +4 -4
  89. package/src/automation/transformer/transformer.stories.ts +2 -2
  90. package/src/automation/transformer/transformer.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","names":[],"sources":["../../../src/automation/source/source.ts"],"sourcesContent":["import {html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport '../../icons/icon-sources-01-on.js';\nimport '../../icons/icon-sources-01-off.js';\nimport '../../icons/icon-sources-02-on.js';\nimport '../../icons/icon-sources-02-off.js';\nimport '../../icons/icon-sources-03-on.js';\nimport '../../icons/icon-sources-03-off.js';\nimport '../../icons/icon-sources-04-on.js';\nimport '../../icons/icon-sources-04-off.js';\nimport '../../icons/icon-sources-05-on.js';\nimport '../../icons/icon-sources-05-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\n\nexport enum SourceAlternativeIcon {\n sources01 = 'sources01',\n sources02 = 'sources02',\n sources03 = 'sources03',\n sources04 = 'sources04',\n sources05 = 'sources05',\n}\n\n/**\n * @stable\n */\n@customElement('obc-source')\nexport class ObcSource extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: SourceAlternativeIcon =\n SourceAlternativeIcon.sources01;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case SourceAlternativeIcon.sources02:\n if (this.on) {\n return html`<obi-sources-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-02-on>\n <obi-sources-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-02-on>`;\n } else {\n return html`<obi-sources-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-02-off>\n <obi-sources-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-02-off>`;\n }\n case SourceAlternativeIcon.sources03:\n if (this.on) {\n return html`<obi-sources-03-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-03-on>\n <obi-sources-03-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-03-on>`;\n } else {\n return html`<obi-sources-03-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-03-off>\n <obi-sources-03-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-03-off>`;\n }\n case SourceAlternativeIcon.sources04:\n if (this.on) {\n return html`<obi-sources-04-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-04-on>\n <obi-sources-04-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-04-on>`;\n } else {\n return html`<obi-sources-04-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-04-off>\n <obi-sources-04-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-04-off>`;\n }\n case SourceAlternativeIcon.sources05:\n if (this.on) {\n return html`<obi-sources-05-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-05-on>\n <obi-sources-05-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-05-on>`;\n } else {\n return html`<obi-sources-05-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-05-off>\n <obi-sources-05-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-05-off>`;\n }\n default:\n if (this.on) {\n return html`<obi-sources-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-01-on>\n <obi-sources-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-01-on>`;\n } else {\n return html`<obi-sources-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-01-off>\n <obi-sources-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-01-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-source': ObcSource;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,YAAN,MAAM,kBAAkB,mCAAmC;;;;;CAIhE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,aACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AA3GG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,UAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,YAAA,WAAA,CAAA,cAAc,YAAY,CAAA,GAAA,SAAA"}
1
+ {"version":3,"file":"source.js","names":[],"sources":["../../../src/automation/source/source.ts"],"sourcesContent":["import {html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport '../../icons/icon-sources-01-on.js';\nimport '../../icons/icon-sources-01-off.js';\nimport '../../icons/icon-sources-02-on.js';\nimport '../../icons/icon-sources-02-off.js';\nimport '../../icons/icon-sources-03-on.js';\nimport '../../icons/icon-sources-03-off.js';\nimport '../../icons/icon-sources-04-on.js';\nimport '../../icons/icon-sources-04-off.js';\nimport '../../icons/icon-sources-05-on.js';\nimport '../../icons/icon-sources-05-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\n\nexport enum SourceAlternativeIcon {\n sources01 = 'sources01',\n sources02 = 'sources02',\n sources03 = 'sources03',\n sources04 = 'sources04',\n sources05 = 'sources05',\n}\n\n/**\n * @stable\n */\n@customElement('obc-source')\nexport class ObcSource extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: SourceAlternativeIcon =\n SourceAlternativeIcon.sources01;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case SourceAlternativeIcon.sources02:\n if (this.turnedOn) {\n return html`<obi-sources-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-02-on>\n <obi-sources-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-02-on>`;\n } else {\n return html`<obi-sources-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-02-off>\n <obi-sources-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-02-off>`;\n }\n case SourceAlternativeIcon.sources03:\n if (this.turnedOn) {\n return html`<obi-sources-03-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-03-on>\n <obi-sources-03-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-03-on>`;\n } else {\n return html`<obi-sources-03-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-03-off>\n <obi-sources-03-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-03-off>`;\n }\n case SourceAlternativeIcon.sources04:\n if (this.turnedOn) {\n return html`<obi-sources-04-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-04-on>\n <obi-sources-04-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-04-on>`;\n } else {\n return html`<obi-sources-04-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-04-off>\n <obi-sources-04-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-04-off>`;\n }\n case SourceAlternativeIcon.sources05:\n if (this.turnedOn) {\n return html`<obi-sources-05-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-05-on>\n <obi-sources-05-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-05-on>`;\n } else {\n return html`<obi-sources-05-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-05-off>\n <obi-sources-05-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-05-off>`;\n }\n default:\n if (this.turnedOn) {\n return html`<obi-sources-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-sources-01-on>\n <obi-sources-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-01-on>`;\n } else {\n return html`<obi-sources-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-sources-01-off>\n <obi-sources-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-sources-01-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-source': ObcSource;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;CACA,sBAAA,eAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,YAAN,MAAM,kBAAkB,mCAAmC;;;;;CAIhE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,aACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,aACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AA3GG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,UAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,YAAA,WAAA,CAAA,cAAc,YAAY,CAAA,GAAA,SAAA"}
@@ -26,7 +26,7 @@ var ObcSwitch = class ObcSwitch extends ObcAbstractAutomationButtonSquared {
26
26
  }
27
27
  get icon() {
28
28
  switch (this.alternativeIcon) {
29
- case "s1": if (this.on) return html`<obi-switch-01-on
29
+ case "s1": if (this.turnedOn) return html`<obi-switch-01-on
30
30
  usecsscolor
31
31
  slot="icon"
32
32
  ></obi-switch-01-on>
@@ -42,7 +42,7 @@ var ObcSwitch = class ObcSwitch extends ObcAbstractAutomationButtonSquared {
42
42
  usecsscolor
43
43
  slot="icon-silhouette"
44
44
  ></obi-switch-01-off>`;
45
- case "s2": if (this.on) return html`<obi-switch-02-on
45
+ case "s2": if (this.turnedOn) return html`<obi-switch-02-on
46
46
  usecsscolor
47
47
  slot="icon"
48
48
  ></obi-switch-02-on>
@@ -58,7 +58,7 @@ var ObcSwitch = class ObcSwitch extends ObcAbstractAutomationButtonSquared {
58
58
  usecsscolor
59
59
  slot="icon-silhouette"
60
60
  ></obi-switch-02-off>`;
61
- case "s3": if (this.on) return html`<obi-switch-03-on
61
+ case "s3": if (this.turnedOn) return html`<obi-switch-03-on
62
62
  usecsscolor
63
63
  slot="icon"
64
64
  ></obi-switch-03-on>
@@ -74,7 +74,7 @@ var ObcSwitch = class ObcSwitch extends ObcAbstractAutomationButtonSquared {
74
74
  usecsscolor
75
75
  slot="icon-silhouette"
76
76
  ></obi-switch-03-off>`;
77
- default: if (this.on) return html`<obi-switch-horizontal-on
77
+ default: if (this.turnedOn) return html`<obi-switch-horizontal-on
78
78
  usecsscolor
79
79
  slot="icon"
80
80
  ></obi-switch-horizontal-on>
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","names":[],"sources":["../../../src/automation/switch/switch.ts"],"sourcesContent":["import {html} from 'lit';\nimport '../../icons/icon-switch-horizontal-on.js';\nimport '../../icons/icon-switch-horizontal-off.js';\nimport '../../icons/icon-switch-01-on.js';\nimport '../../icons/icon-switch-01-off.js';\nimport '../../icons/icon-switch-02-on.js';\nimport '../../icons/icon-switch-02-off.js';\nimport '../../icons/icon-switch-03-on.js';\nimport '../../icons/icon-switch-03-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\nimport {property} from 'lit/decorators.js';\n\nexport enum SwitchAlternativeIcon {\n regular = 'regular',\n s1 = 's1',\n s2 = 's2',\n s3 = 's3',\n}\n\n/**\n * @stable\n */\n@customElement('obc-switch')\nexport class ObcSwitch extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: SwitchAlternativeIcon =\n SwitchAlternativeIcon.regular;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case SwitchAlternativeIcon.s1:\n if (this.on) {\n return html`<obi-switch-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-01-on>\n <obi-switch-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-01-on>`;\n } else {\n return html`<obi-switch-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-01-off>\n <obi-switch-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-01-off>`;\n }\n case SwitchAlternativeIcon.s2:\n if (this.on) {\n return html`<obi-switch-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-02-on>\n <obi-switch-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-02-on>`;\n } else {\n return html`<obi-switch-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-02-off>\n <obi-switch-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-02-off>`;\n }\n case SwitchAlternativeIcon.s3:\n if (this.on) {\n return html`<obi-switch-03-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-03-on>\n <obi-switch-03-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-03-on>`;\n } else {\n return html`<obi-switch-03-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-03-off>\n <obi-switch-03-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-03-off>`;\n }\n default:\n if (this.on) {\n return html`<obi-switch-horizontal-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-horizontal-on>\n <obi-switch-horizontal-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-horizontal-on>`;\n } else {\n return html`<obi-switch-horizontal-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-horizontal-off>\n <obi-switch-horizontal-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-horizontal-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-switch': ObcSwitch;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,aAAA;CACA,sBAAA,QAAA;CACA,sBAAA,QAAA;CACA,sBAAA,QAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,YAAN,MAAM,kBAAkB,mCAAmC;;;;;CAIhE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,MACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,MACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,MACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AAvFG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,UAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,YAAA,WAAA,CAAA,cAAc,YAAY,CAAA,GAAA,SAAA"}
1
+ {"version":3,"file":"switch.js","names":[],"sources":["../../../src/automation/switch/switch.ts"],"sourcesContent":["import {html} from 'lit';\nimport '../../icons/icon-switch-horizontal-on.js';\nimport '../../icons/icon-switch-horizontal-off.js';\nimport '../../icons/icon-switch-01-on.js';\nimport '../../icons/icon-switch-01-off.js';\nimport '../../icons/icon-switch-02-on.js';\nimport '../../icons/icon-switch-02-off.js';\nimport '../../icons/icon-switch-03-on.js';\nimport '../../icons/icon-switch-03-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\nimport {property} from 'lit/decorators.js';\n\nexport enum SwitchAlternativeIcon {\n regular = 'regular',\n s1 = 's1',\n s2 = 's2',\n s3 = 's3',\n}\n\n/**\n * @stable\n */\n@customElement('obc-switch')\nexport class ObcSwitch extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: SwitchAlternativeIcon =\n SwitchAlternativeIcon.regular;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case SwitchAlternativeIcon.s1:\n if (this.turnedOn) {\n return html`<obi-switch-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-01-on>\n <obi-switch-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-01-on>`;\n } else {\n return html`<obi-switch-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-01-off>\n <obi-switch-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-01-off>`;\n }\n case SwitchAlternativeIcon.s2:\n if (this.turnedOn) {\n return html`<obi-switch-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-02-on>\n <obi-switch-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-02-on>`;\n } else {\n return html`<obi-switch-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-02-off>\n <obi-switch-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-02-off>`;\n }\n case SwitchAlternativeIcon.s3:\n if (this.turnedOn) {\n return html`<obi-switch-03-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-03-on>\n <obi-switch-03-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-03-on>`;\n } else {\n return html`<obi-switch-03-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-03-off>\n <obi-switch-03-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-03-off>`;\n }\n default:\n if (this.turnedOn) {\n return html`<obi-switch-horizontal-on\n usecsscolor\n slot=\"icon\"\n ></obi-switch-horizontal-on>\n <obi-switch-horizontal-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-horizontal-on>`;\n } else {\n return html`<obi-switch-horizontal-off\n usecsscolor\n slot=\"icon\"\n ></obi-switch-horizontal-off>\n <obi-switch-horizontal-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-switch-horizontal-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-switch': ObcSwitch;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,aAAA;CACA,sBAAA,QAAA;CACA,sBAAA,QAAA;CACA,sBAAA,QAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,YAAN,MAAM,kBAAkB,mCAAmC;;;;;CAIhE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,MACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,MACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,KAAA,MACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AAvFG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,UAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,YAAA,WAAA,CAAA,cAAc,YAAY,CAAA,GAAA,SAAA"}
@@ -20,7 +20,7 @@ var ObcTransformer = class ObcTransformer extends ObcAbstractAutomationButtonSqu
20
20
  }
21
21
  get icon() {
22
22
  switch (this.alternativeIcon) {
23
- case "transformer02": if (this.on) return html`<obi-transformer-02-on
23
+ case "transformer02": if (this.turnedOn) return html`<obi-transformer-02-on
24
24
  usecsscolor
25
25
  slot="icon"
26
26
  ></obi-transformer-02-on>
@@ -36,7 +36,7 @@ var ObcTransformer = class ObcTransformer extends ObcAbstractAutomationButtonSqu
36
36
  usecsscolor
37
37
  slot="icon-silhouette"
38
38
  ></obi-transformer-02-off>`;
39
- default: if (this.on) return html`<obi-transformer-01-on
39
+ default: if (this.turnedOn) return html`<obi-transformer-01-on
40
40
  usecsscolor
41
41
  slot="icon"
42
42
  ></obi-transformer-01-on>
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.js","names":[],"sources":["../../../src/automation/transformer/transformer.ts"],"sourcesContent":["import {html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport '../../icons/icon-transformer-01-on.js';\nimport '../../icons/icon-transformer-01-off.js';\nimport '../../icons/icon-transformer-02-on.js';\nimport '../../icons/icon-transformer-02-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\n\nexport enum TransformerAlternativeIcon {\n transformer01 = 'transformer01',\n transformer02 = 'transformer02',\n}\n\n/**\n * @stable\n */\n@customElement('obc-transformer')\nexport class ObcTransformer extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: TransformerAlternativeIcon =\n TransformerAlternativeIcon.transformer01;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case TransformerAlternativeIcon.transformer02:\n if (this.on) {\n return html`<obi-transformer-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-02-on>\n <obi-transformer-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-02-on>`;\n } else {\n return html`<obi-transformer-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-02-off>\n <obi-transformer-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-02-off>`;\n }\n default:\n if (this.on) {\n return html`<obi-transformer-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-01-on>\n <obi-transformer-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-01-on>`;\n } else {\n return html`<obi-transformer-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-01-off>\n <obi-transformer-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-01-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-transformer': ObcTransformer;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAY,6BAAL,yBAAA,4BAAA;CACL,2BAAA,mBAAA;CACA,2BAAA,mBAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,iBAAN,MAAM,uBAAuB,mCAAmC;;;;;CAIrE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,iBACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,IACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AA/CG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,eAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,iBAAA,WAAA,CAAA,cAAc,iBAAiB,CAAA,GAAA,cAAA"}
1
+ {"version":3,"file":"transformer.js","names":[],"sources":["../../../src/automation/transformer/transformer.ts"],"sourcesContent":["import {html} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport '../../icons/icon-transformer-01-on.js';\nimport '../../icons/icon-transformer-01-off.js';\nimport '../../icons/icon-transformer-02-on.js';\nimport '../../icons/icon-transformer-02-off.js';\nimport {customElement} from '../../decorator.js';\nimport {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-automation-button-squared.js';\n\nexport enum TransformerAlternativeIcon {\n transformer01 = 'transformer01',\n transformer02 = 'transformer02',\n}\n\n/**\n * @stable\n */\n@customElement('obc-transformer')\nexport class ObcTransformer extends ObcAbstractAutomationButtonSquared {\n @property({type: String}) alternativeIcon: TransformerAlternativeIcon =\n TransformerAlternativeIcon.transformer01;\n\n override get icon() {\n switch (this.alternativeIcon) {\n case TransformerAlternativeIcon.transformer02:\n if (this.turnedOn) {\n return html`<obi-transformer-02-on\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-02-on>\n <obi-transformer-02-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-02-on>`;\n } else {\n return html`<obi-transformer-02-off\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-02-off>\n <obi-transformer-02-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-02-off>`;\n }\n default:\n if (this.turnedOn) {\n return html`<obi-transformer-01-on\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-01-on>\n <obi-transformer-01-on\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-01-on>`;\n } else {\n return html`<obi-transformer-01-off\n usecsscolor\n slot=\"icon\"\n ></obi-transformer-01-off>\n <obi-transformer-01-off\n usecsscolor\n slot=\"icon-silhouette\"\n ></obi-transformer-01-off>`;\n }\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-transformer': ObcTransformer;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAY,6BAAL,yBAAA,4BAAA;CACL,2BAAA,mBAAA;CACA,2BAAA,mBAAA;;AACF,EAAA,CAAA,CAAA;AAMO,IAAM,iBAAN,MAAM,uBAAuB,mCAAmC;;;;;CAIrE,IAAa,OAAO;EAClB,QAAQ,KAAK,iBAAb;GACE,KAAA,iBACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;GASf,SACE,IAAI,KAAK,UACP,OAAO,IAAI;;;;;;;;QASX,OAAO,IAAI;;;;;;;;EASjB;CACF;AACF;AA/CG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,eAAA,WAAA,mBAAA,KAAA,CAAA;AAFzB,iBAAA,WAAA,CAAA,cAAc,iBAAiB,CAAA,GAAA,cAAA"}
package/eslint.config.mjs CHANGED
@@ -1077,6 +1077,60 @@ export const openbridgePlugin = {
1077
1077
  };
1078
1078
  },
1079
1079
  },
1080
+
1081
+ // Svelte binds an `on…={…}` markup attribute as an event listener, so a
1082
+ // property named like one cannot be set from a template (#1090).
1083
+ 'no-event-like-property-name': {
1084
+ meta: {
1085
+ type: 'problem',
1086
+ docs: {
1087
+ description:
1088
+ 'Keep @property names and attributes from starting with `on`',
1089
+ },
1090
+ schema: [],
1091
+ },
1092
+ create(context) {
1093
+ const propertyOptions = (node) => {
1094
+ for (const decorator of node.decorators ?? []) {
1095
+ const expr = decorator.expression;
1096
+ if (
1097
+ expr?.type === 'CallExpression' &&
1098
+ expr.callee.type === 'Identifier' &&
1099
+ expr.callee.name === 'property'
1100
+ ) {
1101
+ return expr.arguments[0]?.properties ?? [];
1102
+ }
1103
+ }
1104
+ return null;
1105
+ };
1106
+ const check = (node) => {
1107
+ if (node.key.type !== 'Identifier') return;
1108
+ const options = propertyOptions(node);
1109
+ if (!options) return;
1110
+ const attribute = options.find(
1111
+ (p) =>
1112
+ p.type === 'Property' &&
1113
+ p.key.type === 'Identifier' &&
1114
+ p.key.name === 'attribute' &&
1115
+ p.value.type === 'Literal' &&
1116
+ typeof p.value.value === 'string'
1117
+ )?.value.value;
1118
+ const name = [node.key.name, attribute].find(
1119
+ (n) => typeof n === 'string' && /^on/i.test(n)
1120
+ );
1121
+ if (!name) return;
1122
+ context.report({
1123
+ node: node.key,
1124
+ message: `\`${name}\` starts with \`on\`, which Svelte binds as an event listener in markup, so the property cannot be set there (docs/agents/coding-standards.md § Property names).`,
1125
+ });
1126
+ };
1127
+ return {
1128
+ PropertyDefinition: check,
1129
+ MethodDefinition: check,
1130
+ AccessorProperty: check,
1131
+ };
1132
+ },
1133
+ },
1080
1134
  },
1081
1135
  };
1082
1136
 
@@ -1128,6 +1182,7 @@ export default [
1128
1182
  'openbridge/use-math-helpers': 'error',
1129
1183
  'openbridge/no-positive-tabindex': 'error',
1130
1184
  'openbridge/positive-boolean-name': 'error',
1185
+ 'openbridge/no-event-like-property-name': 'error',
1131
1186
  'openbridge/storybook-title-case': 'off',
1132
1187
  'openbridge/story-lifecycle-tags': 'off',
1133
1188
  // Disabled because eslint-plugin-file-extension-in-import-ts is not yet
@@ -1163,6 +1218,7 @@ export default [
1163
1218
  'openbridge/use-math-helpers': 'off',
1164
1219
  'openbridge/no-positive-tabindex': 'off',
1165
1220
  'openbridge/positive-boolean-name': 'off',
1221
+ 'openbridge/no-event-like-property-name': 'off',
1166
1222
  },
1167
1223
  },
1168
1224
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oicl/openbridge-webcomponents-full-bundle",
3
- "version": "2.0.0-next.171",
3
+ "version": "2.0.0-next.172",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -440,3 +440,47 @@ describe('openbridge/positive-boolean-name', () => {
440
440
  );
441
441
  });
442
442
  });
443
+
444
+ describe('openbridge/no-event-like-property-name', () => {
445
+ it('rejects properties and attributes that start with on', () => {
446
+ ruleTester.run(
447
+ 'no-event-like-property-name',
448
+ openbridgePlugin.rules['no-event-like-property-name'],
449
+ {
450
+ valid: [
451
+ 'class A { @property({type: Boolean}) turnedOn = false; }',
452
+ "class A { @property({type: Boolean, attribute: 'is-on'}) active = false; }",
453
+ 'class A { @state() onHold = false; }',
454
+ 'class A { get _on() { return true; } }',
455
+ 'class A { onClick = () => {}; }',
456
+ ],
457
+ invalid: [
458
+ {
459
+ code: 'class A { @property({type: Boolean}) on = false; }',
460
+ errors: 1,
461
+ },
462
+ {
463
+ code: 'class A { @property({type: String}) onTop = ""; }',
464
+ errors: 1,
465
+ },
466
+ {
467
+ code: "class A { @property({type: Boolean, attribute: 'on-state'}) active = false; }",
468
+ errors: 1,
469
+ },
470
+ {
471
+ code: "class A { @property({type: Boolean, attribute: 'hold'}) onHold = false; }",
472
+ errors: 1,
473
+ },
474
+ {
475
+ code: 'class A { @property({type: Boolean}) set on(v) {} }',
476
+ errors: 1,
477
+ },
478
+ {
479
+ code: 'class A { @property({type: Boolean}) accessor onHold = false; }',
480
+ errors: 1,
481
+ },
482
+ ],
483
+ }
484
+ );
485
+ });
486
+ });
@@ -1,3 +1,4 @@
1
+ import {PropertyValues} from 'lit';
1
2
  import {property} from 'lit/decorators.js';
2
3
  import {ObcAbstractAutomationButton} from '../automation-button/abstract-automation-button.js';
3
4
  import {
@@ -26,10 +27,18 @@ export enum MotorizedVariant {
26
27
  * Not registered as a custom element. `obc-fan`, `obc-motor` and `obc-pump`
27
28
  * extend it and supply their own `icon` and `variant`.
28
29
  *
30
+ * @property turnedOn - Whether the device is running. Selects the running
31
+ * icon and the speed readout instead of the `Off` state. Not named `on`,
32
+ * which Svelte binds as an event listener in markup (#1090).
33
+ * @property on - Alias of `turnedOn` for 1.x markup: setting it sets
34
+ * `turnedOn`.
29
35
  * @availableWhen direction variant in [double, forward, flatForward]
30
36
  */
31
37
  export class ObcAbstractAutomationButtonMotorized extends ObcAbstractAutomationButton {
32
- @property({type: Boolean}) on: boolean = false;
38
+ @property({type: Boolean}) turnedOn: boolean = false;
39
+ /** @deprecated Use `turnedOn`. */
40
+ // eslint-disable-next-line openbridge/no-event-like-property-name -- deprecated alias kept for 1.x markup (#1090)
41
+ @property({type: Boolean}) on?: boolean;
33
42
  /**
34
43
  * @deprecated Use `speed` together with `speedUnit` instead. When `speed`
35
44
  * is set it takes precedence over `speedInPercent`.
@@ -50,7 +59,7 @@ export class ObcAbstractAutomationButtonMotorized extends ObcAbstractAutomationB
50
59
  if (!this.showStatus) {
51
60
  return [];
52
61
  }
53
- if (speed !== undefined && speed !== null && this.on) {
62
+ if (speed !== undefined && speed !== null && this.turnedOn) {
54
63
  return [
55
64
  {
56
65
  type: 'value',
@@ -64,7 +73,7 @@ export class ObcAbstractAutomationButtonMotorized extends ObcAbstractAutomationB
64
73
  : 'chevron',
65
74
  },
66
75
  ];
67
- } else if (!this.on) {
76
+ } else if (!this.turnedOn) {
68
77
  return [
69
78
  {
70
79
  type: 'state-off',
@@ -76,7 +85,14 @@ export class ObcAbstractAutomationButtonMotorized extends ObcAbstractAutomationB
76
85
  return [];
77
86
  }
78
87
 
88
+ override willUpdate(changed: PropertyValues<this>): void {
89
+ super.willUpdate(changed);
90
+ if (changed.has('on') && this.on !== undefined) {
91
+ this.turnedOn = this.on;
92
+ }
93
+ }
94
+
79
95
  override get _on(): boolean {
80
- return this.on;
96
+ return this.turnedOn;
81
97
  }
82
98
  }
@@ -1,3 +1,4 @@
1
+ import {PropertyValues} from 'lit';
1
2
  import {property} from 'lit/decorators.js';
2
3
  import {ObcAbstractAutomationButton} from './abstract-automation-button.js';
3
4
  import {AutomationButtonReadoutStack} from '../../components/automation-button-readout-stack/automation-button-readout-stack.js';
@@ -8,8 +9,30 @@ export enum SquaredVariant {
8
9
  flat = 'flat',
9
10
  }
10
11
 
12
+ /**
13
+ * Base class for two-state automation buttons.
14
+ *
15
+ * Extends `ObcAbstractAutomationButton` with the on/off state: the subclass
16
+ * picks its icon from `turnedOn`, and the readout adds the `On` or `Off`
17
+ * state row.
18
+ *
19
+ * ## Usage Guidelines
20
+ *
21
+ * Not registered as a custom element. `obc-switch`, `obc-converter`,
22
+ * `obc-diodes` and the other two-state devices extend it and supply their own
23
+ * `icon`.
24
+ *
25
+ * @property turnedOn - Whether the device is on. Selects the on icon and the
26
+ * `On` state row instead of `Off`. Not named `on`, which Svelte binds as an
27
+ * event listener in markup (#1090).
28
+ * @property on - Alias of `turnedOn` for 1.x markup: setting it sets
29
+ * `turnedOn`.
30
+ */
11
31
  export class ObcAbstractAutomationButtonSquared extends ObcAbstractAutomationButton {
12
- @property({type: Boolean}) on: boolean = false;
32
+ @property({type: Boolean}) turnedOn: boolean = false;
33
+ /** @deprecated Use `turnedOn`. */
34
+ // eslint-disable-next-line openbridge/no-event-like-property-name -- deprecated alias kept for 1.x markup (#1090)
35
+ @property({type: Boolean}) on?: boolean;
13
36
  @property({type: String}) variant: SquaredVariant = SquaredVariant.square;
14
37
  @property({type: String}) orientation: AutomationButtonOrientation =
15
38
  AutomationButtonOrientation.horizontal;
@@ -22,7 +45,7 @@ export class ObcAbstractAutomationButtonSquared extends ObcAbstractAutomationBut
22
45
  if (!this.showStatus) {
23
46
  return [];
24
47
  }
25
- if (this.on) {
48
+ if (this.turnedOn) {
26
49
  return [
27
50
  {
28
51
  type: 'state-on',
@@ -41,7 +64,14 @@ export class ObcAbstractAutomationButtonSquared extends ObcAbstractAutomationBut
41
64
  }
42
65
  }
43
66
 
67
+ override willUpdate(changed: PropertyValues<this>): void {
68
+ super.willUpdate(changed);
69
+ if (changed.has('on') && this.on !== undefined) {
70
+ this.turnedOn = this.on;
71
+ }
72
+ }
73
+
44
74
  override get _on(): boolean {
45
- return this.on;
75
+ return this.turnedOn;
46
76
  }
47
77
  }
@@ -88,6 +88,7 @@ export const argTypesAbstractAutomationButtonPassiveRound = {
88
88
 
89
89
  export const argTypesAbstractAutomationButtonPassiveSquare = {
90
90
  ...argTypesAbstractAutomationButton,
91
+ on: {table: {disable: true}, control: false},
91
92
  variant: {
92
93
  options: ['square', 'flat'],
93
94
  control: {type: 'radio'},
@@ -100,6 +101,7 @@ export const argTypesAbstractAutomationButtonPassiveSquare = {
100
101
 
101
102
  export const argTypesAbstractAutomationButtonMotorized = {
102
103
  ...argTypesAbstractAutomationButton,
104
+ on: {table: {disable: true}, control: false},
103
105
  speedInPercent: {
104
106
  control: {type: 'range', min: 0, max: 100, step: 1},
105
107
  description: 'Deprecated, use `speed` together with `speedUnit` instead.',
@@ -0,0 +1,64 @@
1
+ import {describe, it, expect, afterEach} from 'vitest';
2
+ import '../pump/pump.js';
3
+ import '../switch/switch.js';
4
+ import type {ObcPump} from '../pump/pump.js';
5
+ import type {ObcSwitch} from '../switch/switch.js';
6
+ import {AutomationButtonState} from './automation-button.js';
7
+
8
+ type Device = ObcPump | ObcSwitch;
9
+
10
+ const mounted: HTMLElement[] = [];
11
+ afterEach(() => mounted.splice(0).forEach((el) => el.remove()));
12
+
13
+ async function mount(tag: string, configure: (el: Device) => void) {
14
+ const el = document.createElement(tag) as Device;
15
+ configure(el);
16
+ document.body.appendChild(el);
17
+ mounted.push(el);
18
+ await el.updateComplete;
19
+ return el;
20
+ }
21
+
22
+ const state = (el: Device) =>
23
+ (
24
+ el.shadowRoot!.querySelector('obc-automation-button') as unknown as {
25
+ state: AutomationButtonState;
26
+ }
27
+ ).state;
28
+
29
+ describe.each(['obc-pump', 'obc-switch'])('%s turnedOn', (tag) => {
30
+ it('turns the device on', async () => {
31
+ const el = await mount(tag, (e) => {
32
+ e.turnedOn = true;
33
+ });
34
+ expect(state(el)).toBe(AutomationButtonState.open);
35
+ });
36
+
37
+ it('keeps the 1.x `on` attribute working on the first render', async () => {
38
+ const el = await mount(tag, (e) => e.setAttribute('on', ''));
39
+ expect(el.turnedOn).toBe(true);
40
+ expect(state(el)).toBe(AutomationButtonState.open);
41
+ });
42
+
43
+ it('follows `on` when it is set or removed later', async () => {
44
+ const el = await mount(tag, (e) => e.setAttribute('on', ''));
45
+ el.removeAttribute('on');
46
+ await el.updateComplete;
47
+ expect(el.turnedOn).toBe(false);
48
+ el.on = true;
49
+ await el.updateComplete;
50
+ expect(state(el)).toBe(AutomationButtonState.open);
51
+ });
52
+
53
+ // The generated Vue wrapper writes every prop's creation-time value back on
54
+ // its second render; for `on` that value is undefined.
55
+ it('leaves turnedOn alone when `on` is written back unset', async () => {
56
+ const el = await mount(tag, (e) => {
57
+ e.turnedOn = true;
58
+ });
59
+ el.on = undefined;
60
+ await el.updateComplete;
61
+ expect(el.turnedOn).toBe(true);
62
+ expect(state(el)).toBe(AutomationButtonState.open);
63
+ });
64
+ });
@@ -37,12 +37,12 @@ type Story = StoryObj<ObcBipolarTransistor>;
37
37
 
38
38
  export const On: Story = {
39
39
  args: {
40
- on: true,
40
+ turnedOn: true,
41
41
  },
42
42
  };
43
43
 
44
44
  export const Off: Story = {
45
45
  args: {
46
- on: false,
46
+ turnedOn: false,
47
47
  },
48
48
  };
@@ -33,7 +33,7 @@ export class ObcBipolarTransistor extends ObcAbstractAutomationButtonSquared {
33
33
  override get icon() {
34
34
  switch (this.alternativeIcon) {
35
35
  case BipolarTransistorAlternativeIcon.bipolarTransistor02:
36
- if (this.on) {
36
+ if (this.turnedOn) {
37
37
  return html`<obi-bipolar-transistor-02-on
38
38
  usecsscolor
39
39
  slot="icon"
@@ -53,7 +53,7 @@ export class ObcBipolarTransistor extends ObcAbstractAutomationButtonSquared {
53
53
  ></obi-bipolar-transistor-02-off>`;
54
54
  }
55
55
  case BipolarTransistorAlternativeIcon.bipolarTransistor03:
56
- if (this.on) {
56
+ if (this.turnedOn) {
57
57
  return html`<obi-bipolar-transistor-03-on
58
58
  usecsscolor
59
59
  slot="icon"
@@ -73,7 +73,7 @@ export class ObcBipolarTransistor extends ObcAbstractAutomationButtonSquared {
73
73
  ></obi-bipolar-transistor-03-off>`;
74
74
  }
75
75
  case BipolarTransistorAlternativeIcon.bipolarTransistor04:
76
- if (this.on) {
76
+ if (this.turnedOn) {
77
77
  return html`<obi-bipolar-transistor-04-on
78
78
  usecsscolor
79
79
  slot="icon"
@@ -111,7 +111,7 @@ export class ObcBipolarTransistor extends ObcAbstractAutomationButtonSquared {
111
111
  slot="icon-silhouette"
112
112
  ></obi-bipolar-transistor-04-flat>`;
113
113
  default:
114
- if (this.on) {
114
+ if (this.turnedOn) {
115
115
  return html`<obi-bipolar-transistor-on
116
116
  usecsscolor
117
117
  slot="icon"
@@ -34,12 +34,12 @@ type Story = StoryObj<ObcCapacitor>;
34
34
 
35
35
  export const On: Story = {
36
36
  args: {
37
- on: true,
37
+ turnedOn: true,
38
38
  },
39
39
  };
40
40
 
41
41
  export const Off: Story = {
42
42
  args: {
43
- on: false,
43
+ turnedOn: false,
44
44
  },
45
45
  };
@@ -29,7 +29,7 @@ export class ObcCapacitor extends ObcAbstractAutomationButtonSquared {
29
29
  override get icon() {
30
30
  switch (this.alternativeIcon) {
31
31
  case CapacitorAlternativeIcon.capacitor02:
32
- if (this.on) {
32
+ if (this.turnedOn) {
33
33
  return html`<obi-capacitor-02-on
34
34
  usecsscolor
35
35
  slot="icon"
@@ -49,7 +49,7 @@ export class ObcCapacitor extends ObcAbstractAutomationButtonSquared {
49
49
  ></obi-capacitor-02-off>`;
50
50
  }
51
51
  case CapacitorAlternativeIcon.capacitor03:
52
- if (this.on) {
52
+ if (this.turnedOn) {
53
53
  return html`<obi-capacitor-03-on
54
54
  usecsscolor
55
55
  slot="icon"
@@ -69,7 +69,7 @@ export class ObcCapacitor extends ObcAbstractAutomationButtonSquared {
69
69
  ></obi-capacitor-03-off>`;
70
70
  }
71
71
  case CapacitorAlternativeIcon.capacitor04:
72
- if (this.on) {
72
+ if (this.turnedOn) {
73
73
  return html`<obi-capacitor-04-on
74
74
  usecsscolor
75
75
  slot="icon"
@@ -89,7 +89,7 @@ export class ObcCapacitor extends ObcAbstractAutomationButtonSquared {
89
89
  ></obi-capacitor-04-off>`;
90
90
  }
91
91
  default:
92
- if (this.on) {
92
+ if (this.turnedOn) {
93
93
  return html`<obi-capacitor-01-on
94
94
  usecsscolor
95
95
  slot="icon"
@@ -34,12 +34,12 @@ type Story = StoryObj<ObcConverter>;
34
34
 
35
35
  export const On: Story = {
36
36
  args: {
37
- on: true,
37
+ turnedOn: true,
38
38
  },
39
39
  };
40
40
 
41
41
  export const Off: Story = {
42
42
  args: {
43
- on: false,
43
+ turnedOn: false,
44
44
  },
45
45
  };
@@ -29,7 +29,7 @@ export class ObcConverter extends ObcAbstractAutomationButtonSquared {
29
29
  override get icon() {
30
30
  switch (this.alternativeIcon) {
31
31
  case ConverterAlternativeIcon.converterDcac:
32
- if (this.on) {
32
+ if (this.turnedOn) {
33
33
  return html`<obi-converter-dcac-on
34
34
  usecsscolor
35
35
  slot="icon"
@@ -49,7 +49,7 @@ export class ObcConverter extends ObcAbstractAutomationButtonSquared {
49
49
  ></obi-converter-dcac-off>`;
50
50
  }
51
51
  case ConverterAlternativeIcon.converterAcdc:
52
- if (this.on) {
52
+ if (this.turnedOn) {
53
53
  return html`<obi-converter-acdc-on
54
54
  usecsscolor
55
55
  slot="icon"
@@ -69,7 +69,7 @@ export class ObcConverter extends ObcAbstractAutomationButtonSquared {
69
69
  ></obi-converter-acdc-off>`;
70
70
  }
71
71
  case ConverterAlternativeIcon.converterFilter1:
72
- if (this.on) {
72
+ if (this.turnedOn) {
73
73
  return html`<obi-converter-filter-1-on
74
74
  usecsscolor
75
75
  slot="icon"
@@ -89,7 +89,7 @@ export class ObcConverter extends ObcAbstractAutomationButtonSquared {
89
89
  ></obi-converter-filter-1-off>`;
90
90
  }
91
91
  default:
92
- if (this.on) {
92
+ if (this.turnedOn) {
93
93
  return html`<obi-converter-dcdc-on
94
94
  usecsscolor
95
95
  slot="icon"
@@ -35,12 +35,12 @@ type Story = StoryObj<ObcDamper>;
35
35
 
36
36
  export const On: Story = {
37
37
  args: {
38
- on: true,
38
+ turnedOn: true,
39
39
  },
40
40
  };
41
41
 
42
42
  export const Off: Story = {
43
43
  args: {
44
- on: false,
44
+ turnedOn: false,
45
45
  },
46
46
  };
@@ -10,7 +10,7 @@ import {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-
10
10
  @customElement('obc-damper')
11
11
  export class ObcDamper extends ObcAbstractAutomationButtonSquared {
12
12
  override get icon() {
13
- if (this.on) {
13
+ if (this.turnedOn) {
14
14
  return html`<obi-damper-horizontal-on
15
15
  usecsscolor
16
16
  slot="icon"