@oicl/openbridge-webcomponents-full-bundle 2.1.0-next.2 → 2.1.0-next.3

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.
@@ -2886,7 +2886,7 @@
2886
2886
  {
2887
2887
  "kind": "variable",
2888
2888
  "name": "ObcValveAnalogTwoWayIcon",
2889
- "default": "class ObcValveAnalogTwoWayIcon extends LitElement { constructor(..._args) { super(..._args); this.value = 0; this.closed = false; this.vertical = false; } render() { const transform = this.vertical ? \"transform: rotate(90deg);\" : \"\"; if (this.closed) return html` <div class=\"wrapper\" style=\"${transform}\"> <obi-twoway-analog-closed useCssColor> </obi-twoway-analog-closed> </div>`; const handleRotation = -(1 - this.value / 100) * 90; const handleTranslation = (1 - this.value / 100) * 2; const handle = svg` <g transform=\"translate(0, ${handleTranslation}) rotate(${handleRotation} 12 3.5) \"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M9.5 5H14.5C15.3284 5 16 4.32843 16 3.5C16 2.67157 15.3284 2 14.5 2H9.5C8.67157 2 8 2.67157 8 3.5C8 4.32843 8.67157 5 9.5 5ZM9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z\" fill=\"var(--automation-device-tertiary-color)\"/> <path d=\"M9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z\" fill=\"var(--automation-device-primary-color)\"/> </g> `; const xmin = 10.5; const xmax = 2.5; const x = xmin + -8 * this.value / 100; return html` <div class=\"wrapper\" style=\"${transform}\"> <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" > <path d=\"M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z\" fill=\"var(--automation-device-tertiary-color)\" /> <path d=\"M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z\" fill=\"var(--automation-device-primary-color)\" /> ${handle} <g clip-path=\"url(#clip0)\"> <rect x=${xmax} y=\"0\" width=${x - xmax} height=\"24\" fill=\"var(--automation-device-secondary-color)\" /> <line x1=${x} y1=\"0\" x2=${x} y2=\"24\" stroke=\"var(--automation-device-tertiary-color)\" stroke-width=\"1\" /> <rect x=${24 - x} y=\"0\" width=${x - xmax} height=\"24\" fill=\"var(--automation-device-secondary-color)\" /> <line x1=${24 - x} y1=\"0\" x2=${24 - x} y2=\"24\" stroke=\"var(--automation-device-tertiary-color)\" stroke-width=\"1\" /> </g> <defs> <clipPath id=\"clip0\"> <path d=\"M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z\" /> </clipPath> </defs> </svg> </div> `; } static { this.styles = unsafeCSS(valve_analog_two_way_icon_default); } }"
2889
+ "default": "class ObcValveAnalogTwoWayIcon extends LitElement { constructor(..._args) { super(..._args); this.value = 0; this.closed = false; this.vertical = false; } renderBands(width) { if (width <= 0) return null; const left = 3 + width; const right = 21 - width; return svg`<g clip-path=\"url(#body)\"> <rect x=\"2\" y=\"0\" width=${left - 2} height=\"24\" style=${SECONDARY}/> <rect x=${left} y=\"0\" width=\"1\" height=\"24\" style=${TERTIARY}/> <rect x=${right} y=\"0\" width=${22 - right} height=\"24\" style=${SECONDARY}/> <rect x=${right - 1} y=\"0\" width=\"1\" height=\"24\" style=${TERTIARY}/> </g>`; } /** * Horizontal at the top when open, turning to vertical and moving 2 units * down as the valve shuts, matching `obi-twoway-analog-open` at 100 %. */ renderHandle(value) { const shut = 1 - value / 100; const angle = -90 * shut; const cx = 12; const cy = 3.5 + 2 * shut; return svg`<g transform=\"rotate(${angle} ${cx} ${cy})\"> <rect x=${8} y=${cy - 1.5} width=\"8\" height=\"3\" rx=\"1.5\" style=${TERTIARY}/> <rect x=${9} y=${cy - .5} width=\"6\" height=\"1\" rx=\"0.5\" style=${PRIMARY}/> </g>`; } render() { const transform = this.vertical ? \"transform: rotate(90deg);\" : \"\"; if (this.closed) return html` <div class=\"wrapper\" style=\"${transform}\"> <obi-twoway-analog-closed useCssColor> </obi-twoway-analog-closed> </div>`; const value = clampPercent(this.value); return html` <div class=\"wrapper\" style=\"${transform}\"> <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" > <defs> <clipPath id=\"body\"><path d=${BODY} /></clipPath> </defs> <path d=${OUTLINE} style=${TERTIARY} /> <path d=${BODY} style=${PRIMARY} /> ${this.renderBands(BAND_RANGE * (100 - value) / 100)} ${this.renderHandle(value)} </svg> </div> `; } static { this.styles = unsafeCSS(valve_analog_two_way_icon_default); } }"
2890
2890
  }
2891
2891
  ],
2892
2892
  "exports": [
@@ -40950,7 +40950,7 @@
40950
40950
  "declarations": [
40951
40951
  {
40952
40952
  "kind": "class",
40953
- "description": "",
40953
+ "description": "Two-way analog valve symbol whose opening moves continuously from 0 to\n100 %.\n\nDraws the same symbol as the `obi-twoway-analog-*` icons. The shut bands at\nthe port ends and the handle are linear in the opening: exact at 100 %\n(`obi-twoway-analog-open`) and at 0 % (vertical handle, ports shut to the\ncentre), and close to the icons' 10/25/50/75 % steps in between. Used as\nthe icon of `obc-analog-valve`.",
40954
40954
  "name": "ObcValveAnalogTwoWayIcon",
40955
40955
  "members": [
40956
40956
  {
@@ -40959,7 +40959,8 @@
40959
40959
  "type": {
40960
40960
  "text": "number"
40961
40961
  },
40962
- "default": "0"
40962
+ "default": "0",
40963
+ "description": "Opening in percent (0–100)."
40963
40964
  },
40964
40965
  {
40965
40966
  "kind": "field",
@@ -40967,7 +40968,8 @@
40967
40968
  "type": {
40968
40969
  "text": "boolean"
40969
40970
  },
40970
- "default": "false"
40971
+ "default": "false",
40972
+ "description": "Shows the closed symbol."
40971
40973
  },
40972
40974
  {
40973
40975
  "kind": "field",
@@ -40975,7 +40977,35 @@
40975
40977
  "type": {
40976
40978
  "text": "boolean"
40977
40979
  },
40978
- "default": "false"
40980
+ "default": "false",
40981
+ "description": "Turns the symbol 90° for a vertical pipe."
40982
+ },
40983
+ {
40984
+ "kind": "method",
40985
+ "name": "renderBands",
40986
+ "privacy": "private",
40987
+ "parameters": [
40988
+ {
40989
+ "name": "width",
40990
+ "type": {
40991
+ "text": "number"
40992
+ }
40993
+ }
40994
+ ]
40995
+ },
40996
+ {
40997
+ "kind": "method",
40998
+ "name": "renderHandle",
40999
+ "privacy": "private",
41000
+ "parameters": [
41001
+ {
41002
+ "name": "value",
41003
+ "type": {
41004
+ "text": "number"
41005
+ }
41006
+ }
41007
+ ],
41008
+ "description": "Horizontal at the top when open, turning to vertical and moving 2 units\ndown as the valve shuts, matching `obi-twoway-analog-open` at 100 %."
40979
41009
  },
40980
41010
  {
40981
41011
  "kind": "method",
@@ -1,13 +1,34 @@
1
1
  import { LitElement } from 'lit';
2
2
  import '../../icons/icon-twoway-analog-closed.js';
3
3
  /**
4
+ * Two-way analog valve symbol whose opening moves continuously from 0 to
5
+ * 100 %.
6
+ *
7
+ * Draws the same symbol as the `obi-twoway-analog-*` icons. The shut bands at
8
+ * the port ends and the handle are linear in the opening: exact at 100 %
9
+ * (`obi-twoway-analog-open`) and at 0 % (vertical handle, ports shut to the
10
+ * centre), and close to the icons' 10/25/50/75 % steps in between. Used as
11
+ * the icon of `obc-analog-valve`.
12
+ *
13
+ * @property value - Opening in percent (0–100).
4
14
  * @availableWhen value closed==false
15
+ * @property closed - Shows the closed symbol.
16
+ * @property vertical - Turns the symbol 90° for a vertical pipe.
5
17
  * @stable
6
18
  */
7
19
  export declare class ObcValveAnalogTwoWayIcon extends LitElement {
20
+ /** Opening in percent (0–100). */
8
21
  value: number;
22
+ /** Shows the closed symbol. */
9
23
  closed: boolean;
24
+ /** Turns the symbol 90° for a vertical pipe. */
10
25
  vertical: boolean;
26
+ private renderBands;
27
+ /**
28
+ * Horizontal at the top when open, turning to vertical and moving 2 units
29
+ * down as the valve shuts, matching `obi-twoway-analog-open` at 100 %.
30
+ */
31
+ private renderHandle;
11
32
  render(): import('lit-html').TemplateResult<1>;
12
33
  static styles: import('lit').CSSResult;
13
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"valve-analog-two-way-icon.d.ts","sourceRoot":"","sources":["../../../src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAuB,MAAM,KAAK,CAAC;AAIrD,OAAO,0CAA0C,CAAC;AAElD;;;GAGG;AACH,qBACa,wBAAyB,SAAQ,UAAU;IAC5B,KAAK,EAAE,MAAM,CAAK;IACjB,MAAM,EAAE,OAAO,CAAS;IACxB,QAAQ,EAAE,OAAO,CAAS;IAE5C,MAAM;IAoFf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,+BAA+B,EAAE,wBAAwB,CAAC;KAC3D;CACF"}
1
+ {"version":3,"file":"valve-analog-two-way-icon.d.ts","sourceRoot":"","sources":["../../../src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAuB,MAAM,KAAK,CAAC;AAKrD,OAAO,0CAA0C,CAAC;AAclD;;;;;;;;;;;;;;;GAeG;AACH,qBACa,wBAAyB,SAAQ,UAAU;IAC5B,KAAK,EAAE,MAAM,CAAK;IACjB,MAAM,EAAE,OAAO,CAAS;IACxB,QAAQ,EAAE,OAAO,CAAS;IAErD,OAAO,CAAC,WAAW;IAYnB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAWX,MAAM;IA8Bf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,+BAA+B,EAAE,wBAAwB,CAAC;KAC3D;CACF"}
@@ -1,10 +1,18 @@
1
1
  import { customElement } from "../../decorator.js";
2
+ import { clampPercent } from "../../svghelpers/math.js";
2
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
3
4
  import "../../icons/icon-twoway-analog-closed.js";
4
5
  import valve_analog_two_way_icon_default from "./valve-analog-two-way-icon.css.js";
5
6
  import { LitElement, html, svg, unsafeCSS } from "lit";
6
7
  import { property } from "lit/decorators.js";
7
8
  //#region src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts
9
+ var OUTLINE = "M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z";
10
+ var BODY = "M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z";
11
+ /** Width of the shut band at each port end when the opening is 0 %, in icon units. */
12
+ var BAND_RANGE = 7;
13
+ var SECONDARY = "fill: var(--automation-device-secondary-color)";
14
+ var TERTIARY = "fill: var(--automation-device-tertiary-color)";
15
+ var PRIMARY = "fill: var(--automation-device-primary-color)";
8
16
  var ObcValveAnalogTwoWayIcon = class ObcValveAnalogTwoWayIcon extends LitElement {
9
17
  constructor(..._args) {
10
18
  super(..._args);
@@ -12,22 +20,37 @@ var ObcValveAnalogTwoWayIcon = class ObcValveAnalogTwoWayIcon extends LitElement
12
20
  this.closed = false;
13
21
  this.vertical = false;
14
22
  }
23
+ renderBands(width) {
24
+ if (width <= 0) return null;
25
+ const left = 3 + width;
26
+ const right = 21 - width;
27
+ return svg`<g clip-path="url(#body)">
28
+ <rect x="2" y="0" width=${left - 2} height="24" style=${SECONDARY}/>
29
+ <rect x=${left} y="0" width="1" height="24" style=${TERTIARY}/>
30
+ <rect x=${right} y="0" width=${22 - right} height="24" style=${SECONDARY}/>
31
+ <rect x=${right - 1} y="0" width="1" height="24" style=${TERTIARY}/>
32
+ </g>`;
33
+ }
34
+ /**
35
+ * Horizontal at the top when open, turning to vertical and moving 2 units
36
+ * down as the valve shuts, matching `obi-twoway-analog-open` at 100 %.
37
+ */
38
+ renderHandle(value) {
39
+ const shut = 1 - value / 100;
40
+ const angle = -90 * shut;
41
+ const cx = 12;
42
+ const cy = 3.5 + 2 * shut;
43
+ return svg`<g transform="rotate(${angle} ${cx} ${cy})">
44
+ <rect x=${8} y=${cy - 1.5} width="8" height="3" rx="1.5" style=${TERTIARY}/>
45
+ <rect x=${9} y=${cy - .5} width="6" height="1" rx="0.5" style=${PRIMARY}/>
46
+ </g>`;
47
+ }
15
48
  render() {
16
49
  const transform = this.vertical ? "transform: rotate(90deg);" : "";
17
50
  if (this.closed) return html` <div class="wrapper" style="${transform}">
18
51
  <obi-twoway-analog-closed useCssColor> </obi-twoway-analog-closed>
19
52
  </div>`;
20
- const handleRotation = -(1 - this.value / 100) * 90;
21
- const handleTranslation = (1 - this.value / 100) * 2;
22
- const handle = svg`
23
- <g transform="translate(0, ${handleTranslation}) rotate(${handleRotation} 12 3.5) ">
24
- <path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 5H14.5C15.3284 5 16 4.32843 16 3.5C16 2.67157 15.3284 2 14.5 2H9.5C8.67157 2 8 2.67157 8 3.5C8 4.32843 8.67157 5 9.5 5ZM9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z" fill="var(--automation-device-tertiary-color)"/>
25
- <path d="M9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z" fill="var(--automation-device-primary-color)"/>
26
- </g>
27
- `;
28
- const xmin = 10.5;
29
- const xmax = 2.5;
30
- const x = xmin + -8 * this.value / 100;
53
+ const value = clampPercent(this.value);
31
54
  return html`
32
55
  <div class="wrapper" style="${transform}">
33
56
  <svg
@@ -37,55 +60,13 @@ var ObcValveAnalogTwoWayIcon = class ObcValveAnalogTwoWayIcon extends LitElement
37
60
  fill="none"
38
61
  xmlns="http://www.w3.org/2000/svg"
39
62
  >
40
- <path
41
- d="M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z"
42
- fill="var(--automation-device-tertiary-color)"
43
- />
44
- <path
45
- d="M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z"
46
- fill="var(--automation-device-primary-color)"
47
- />
48
- ${handle}
49
- <g clip-path="url(#clip0)">
50
- <rect
51
- x=${xmax}
52
- y="0"
53
- width=${x - xmax}
54
- height="24"
55
- fill="var(--automation-device-secondary-color)"
56
- />
57
- <line
58
- x1=${x}
59
- y1="0"
60
- x2=${x}
61
- y2="24"
62
- stroke="var(--automation-device-tertiary-color)"
63
- stroke-width="1"
64
- />
65
-
66
- <rect
67
- x=${24 - x}
68
- y="0"
69
- width=${x - xmax}
70
- height="24"
71
- fill="var(--automation-device-secondary-color)"
72
- />
73
- <line
74
- x1=${24 - x}
75
- y1="0"
76
- x2=${24 - x}
77
- y2="24"
78
- stroke="var(--automation-device-tertiary-color)"
79
- stroke-width="1"
80
- />
81
- </g>
82
63
  <defs>
83
- <clipPath id="clip0">
84
- <path
85
- d="M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z"
86
- />
87
- </clipPath>
64
+ <clipPath id="body"><path d=${BODY} /></clipPath>
88
65
  </defs>
66
+ <path d=${OUTLINE} style=${TERTIARY} />
67
+ <path d=${BODY} style=${PRIMARY} />
68
+ ${this.renderBands(BAND_RANGE * (100 - value) / 100)}
69
+ ${this.renderHandle(value)}
89
70
  </svg>
90
71
  </div>
91
72
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"valve-analog-two-way-icon.js","names":[],"sources":["../../../src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts"],"sourcesContent":["import {LitElement, html, svg, unsafeCSS} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport compentStyle from './valve-analog-two-way-icon.css?inline';\nimport {customElement} from '../../decorator.js';\nimport '../../icons/icon-twoway-analog-closed.js';\n\n/**\n * @availableWhen value closed==false\n * @stable\n */\n@customElement('obc-valve-analog-two-way-icon')\nexport class ObcValveAnalogTwoWayIcon extends LitElement {\n @property({type: Number}) value: number = 0;\n @property({type: Boolean}) closed: boolean = false;\n @property({type: Boolean}) vertical: boolean = false;\n\n override render() {\n const transform = this.vertical ? 'transform: rotate(90deg);' : '';\n if (this.closed) {\n return html` <div class=\"wrapper\" style=\"${transform}\">\n <obi-twoway-analog-closed useCssColor> </obi-twoway-analog-closed>\n </div>`;\n }\n\n const handleRotation = -(1 - this.value / 100) * 90;\n const handleTranslation = (1 - this.value / 100) * 2;\n const handle = svg`\n <g transform=\"translate(0, ${handleTranslation}) rotate(${handleRotation} 12 3.5) \">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M9.5 5H14.5C15.3284 5 16 4.32843 16 3.5C16 2.67157 15.3284 2 14.5 2H9.5C8.67157 2 8 2.67157 8 3.5C8 4.32843 8.67157 5 9.5 5ZM9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z\" fill=\"var(--automation-device-tertiary-color)\"/>\n <path d=\"M9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z\" fill=\"var(--automation-device-primary-color)\"/>\n </g>\n `;\n\n const xmin = 10.5;\n const xmax = 2.5;\n const x = xmin + ((xmax - xmin) * this.value) / 100;\n\n return html`\n <div class=\"wrapper\" style=\"${transform}\">\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z\"\n fill=\"var(--automation-device-tertiary-color)\"\n />\n <path\n d=\"M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z\"\n fill=\"var(--automation-device-primary-color)\"\n />\n ${handle}\n <g clip-path=\"url(#clip0)\">\n <rect\n x=${xmax}\n y=\"0\"\n width=${x - xmax}\n height=\"24\"\n fill=\"var(--automation-device-secondary-color)\"\n />\n <line\n x1=${x}\n y1=\"0\"\n x2=${x}\n y2=\"24\"\n stroke=\"var(--automation-device-tertiary-color)\"\n stroke-width=\"1\"\n />\n\n <rect\n x=${24 - x}\n y=\"0\"\n width=${x - xmax}\n height=\"24\"\n fill=\"var(--automation-device-secondary-color)\"\n />\n <line\n x1=${24 - x}\n y1=\"0\"\n x2=${24 - x}\n y2=\"24\"\n stroke=\"var(--automation-device-tertiary-color)\"\n stroke-width=\"1\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0\">\n <path\n d=\"M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z\"\n />\n </clipPath>\n </defs>\n </svg>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-valve-analog-two-way-icon': ObcValveAnalogTwoWayIcon;\n }\n}\n"],"mappings":";;;;;;;AAWO,IAAM,2BAAN,MAAM,iCAAiC,WAAW;;;EACb,KAAA,QAAA;EACG,KAAA,SAAA;EACE,KAAA,WAAA;;CAE/C,SAAkB;EAChB,MAAM,YAAY,KAAK,WAAW,8BAA8B;EAChE,IAAI,KAAK,QACP,OAAO,IAAI,gCAAgC,UAAU;;;EAKvD,MAAM,iBAAiB,EAAE,IAAI,KAAK,QAAQ,OAAO;EACjD,MAAM,qBAAqB,IAAI,KAAK,QAAQ,OAAO;EACnD,MAAM,SAAS,GAAG;mCACa,kBAAkB,WAAW,eAAe;;;;;EAM3E,MAAM,OAAO;EACb,MAAM,OAAO;EACb,MAAM,IAAI,OAAS,KAAe,KAAK,QAAS;EAEhD,OAAO,IAAI;oCACqB,UAAU;;;;;;;;;;;;;;;;YAgBlC,OAAO;;;kBAGD,KAAK;;sBAED,IAAI,KAAK;;;;;mBAKZ,EAAE;;mBAEF,EAAE;;;;;;;kBAOH,KAAK,EAAE;;sBAEH,IAAI,KAAK;;;;;mBAKZ,KAAK,EAAE;;mBAEP,KAAK,EAAE;;;;;;;;;;;;;;;;CAgBxB;;EAEyB,KAAA,SAAA,UAAU,iCAAY;;AACjD;AAzFG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,yBAAA,WAAA,SAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,yBAAA,WAAA,UAAA,KAAA,CAAA;AACxB,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,yBAAA,WAAA,YAAA,KAAA,CAAA;AAJ1B,2BAAA,WAAA,CAAA,cAAc,+BAA+B,CAAA,GAAA,wBAAA"}
1
+ {"version":3,"file":"valve-analog-two-way-icon.js","names":[],"sources":["../../../src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts"],"sourcesContent":["import {LitElement, html, svg, unsafeCSS} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport compentStyle from './valve-analog-two-way-icon.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {clampPercent} from '../../svghelpers/math.js';\nimport '../../icons/icon-twoway-analog-closed.js';\n\nconst OUTLINE =\n 'M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z';\nconst BODY =\n 'M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z';\n\n/** Width of the shut band at each port end when the opening is 0 %, in icon units. */\nconst BAND_RANGE = 7;\n\nconst SECONDARY = 'fill: var(--automation-device-secondary-color)';\nconst TERTIARY = 'fill: var(--automation-device-tertiary-color)';\nconst PRIMARY = 'fill: var(--automation-device-primary-color)';\n\n/**\n * Two-way analog valve symbol whose opening moves continuously from 0 to\n * 100 %.\n *\n * Draws the same symbol as the `obi-twoway-analog-*` icons. The shut bands at\n * the port ends and the handle are linear in the opening: exact at 100 %\n * (`obi-twoway-analog-open`) and at 0 % (vertical handle, ports shut to the\n * centre), and close to the icons' 10/25/50/75 % steps in between. Used as\n * the icon of `obc-analog-valve`.\n *\n * @property value - Opening in percent (0–100).\n * @availableWhen value closed==false\n * @property closed - Shows the closed symbol.\n * @property vertical - Turns the symbol 90° for a vertical pipe.\n * @stable\n */\n@customElement('obc-valve-analog-two-way-icon')\nexport class ObcValveAnalogTwoWayIcon extends LitElement {\n @property({type: Number}) value: number = 0;\n @property({type: Boolean}) closed: boolean = false;\n @property({type: Boolean}) vertical: boolean = false;\n\n private renderBands(width: number) {\n if (width <= 0) return null;\n const left = 3 + width;\n const right = 21 - width;\n return svg`<g clip-path=\"url(#body)\">\n <rect x=\"2\" y=\"0\" width=${left - 2} height=\"24\" style=${SECONDARY}/>\n <rect x=${left} y=\"0\" width=\"1\" height=\"24\" style=${TERTIARY}/>\n <rect x=${right} y=\"0\" width=${22 - right} height=\"24\" style=${SECONDARY}/>\n <rect x=${right - 1} y=\"0\" width=\"1\" height=\"24\" style=${TERTIARY}/>\n </g>`;\n }\n\n /**\n * Horizontal at the top when open, turning to vertical and moving 2 units\n * down as the valve shuts, matching `obi-twoway-analog-open` at 100 %.\n */\n private renderHandle(value: number) {\n const shut = 1 - value / 100;\n const angle = -90 * shut;\n const cx = 12;\n const cy = 3.5 + 2 * shut;\n return svg`<g transform=\"rotate(${angle} ${cx} ${cy})\">\n <rect x=${cx - 4} y=${cy - 1.5} width=\"8\" height=\"3\" rx=\"1.5\" style=${TERTIARY}/>\n <rect x=${cx - 3} y=${cy - 0.5} width=\"6\" height=\"1\" rx=\"0.5\" style=${PRIMARY}/>\n </g>`;\n }\n\n override render() {\n const transform = this.vertical ? 'transform: rotate(90deg);' : '';\n if (this.closed) {\n return html` <div class=\"wrapper\" style=\"${transform}\">\n <obi-twoway-analog-closed useCssColor> </obi-twoway-analog-closed>\n </div>`;\n }\n\n const value = clampPercent(this.value);\n return html`\n <div class=\"wrapper\" style=\"${transform}\">\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <clipPath id=\"body\"><path d=${BODY} /></clipPath>\n </defs>\n <path d=${OUTLINE} style=${TERTIARY} />\n <path d=${BODY} style=${PRIMARY} />\n ${this.renderBands((BAND_RANGE * (100 - value)) / 100)}\n ${this.renderHandle(value)}\n </svg>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-valve-analog-two-way-icon': ObcValveAnalogTwoWayIcon;\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAM,UACJ;AACF,IAAM,OACJ;;AAGF,IAAM,aAAa;AAEnB,IAAM,YAAY;AAClB,IAAM,WAAW;AACjB,IAAM,UAAU;AAmBT,IAAM,2BAAN,MAAM,iCAAiC,WAAW;;;EACb,KAAA,QAAA;EACG,KAAA,SAAA;EACE,KAAA,WAAA;;CAE/C,YAAoB,OAAe;EACjC,IAAI,SAAS,GAAG,OAAO;EACvB,MAAM,OAAO,IAAI;EACjB,MAAM,QAAQ,KAAK;EACnB,OAAO,GAAG;gCACkB,OAAO,EAAE,qBAAqB,UAAU;gBACxD,KAAK,qCAAqC,SAAS;gBACnD,MAAM,eAAe,KAAK,MAAM,qBAAqB,UAAU;gBAC/D,QAAQ,EAAE,qCAAqC,SAAS;;CAEtE;;;;;CAMA,aAAqB,OAAe;EAClC,MAAM,OAAO,IAAI,QAAQ;EACzB,MAAM,QAAQ,MAAM;EACpB,MAAM,KAAK;EACX,MAAM,KAAK,MAAM,IAAI;EACrB,OAAO,GAAG,wBAAwB,MAAM,GAAG,GAAG,GAAG,GAAG;gBACxC,EAAO,KAAK,KAAK,IAAI,uCAAuC,SAAS;gBACrE,EAAO,KAAK,KAAK,GAAI,uCAAuC,QAAQ;;CAElF;CAEA,SAAkB;EAChB,MAAM,YAAY,KAAK,WAAW,8BAA8B;EAChE,IAAI,KAAK,QACP,OAAO,IAAI,gCAAgC,UAAU;;;EAKvD,MAAM,QAAQ,aAAa,KAAK,KAAK;EACrC,OAAO,IAAI;oCACqB,UAAU;;;;;;;;;0CASJ,KAAK;;oBAE3B,QAAQ,SAAS,SAAS;oBAC1B,KAAK,SAAS,QAAQ;YAC9B,KAAK,YAAa,cAAc,MAAM,SAAU,GAAG,EAAE;YACrD,KAAK,aAAa,KAAK,EAAE;;;;CAInC;;EAEyB,KAAA,SAAA,UAAU,iCAAY;;AACjD;AA9DG,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,yBAAA,WAAA,SAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,yBAAA,WAAA,UAAA,KAAA,CAAA;AACxB,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,yBAAA,WAAA,YAAA,KAAA,CAAA;AAJ1B,2BAAA,WAAA,CAAA,cAAc,+BAA+B,CAAA,GAAA,wBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oicl/openbridge-webcomponents-full-bundle",
3
- "version": "2.1.0-next.2",
3
+ "version": "2.1.0-next.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,14 @@
1
1
  import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
+ import {html, type LitElement} from 'lit';
3
+ import {unsafeHTML} from 'lit/directives/unsafe-html.js';
2
4
  import {ObcValveAnalogTwoWayIcon} from './valve-analog-two-way-icon.js';
3
5
  import './valve-analog-two-way-icon.js';
6
+ import '../../icons/icon-twoway-analog-open.js';
7
+ import '../../icons/icon-twoway-analog-75.js';
8
+ import '../../icons/icon-twoway-analog-50.js';
9
+ import '../../icons/icon-twoway-analog-25.js';
10
+ import '../../icons/icon-twoway-analog-10.js';
11
+ import '../../icons/icon-twoway-analog-closed.js';
4
12
 
5
13
  const meta: Meta<typeof ObcValveAnalogTwoWayIcon> = {
6
14
  title: 'Automation/Icon/Valve Analog Two Way',
@@ -39,3 +47,58 @@ export const NearClosed: Story = {
39
47
  closed: false,
40
48
  },
41
49
  };
50
+
51
+ export const Continuous: Story = {
52
+ args: {
53
+ value: 63,
54
+ closed: false,
55
+ },
56
+ };
57
+
58
+ /**
59
+ * Top row: the `obi-twoway-analog-*` icons. Bottom row: this component at the
60
+ * same opening; open and closed match exactly, the steps between are close.
61
+ */
62
+ export const MatchesIcons: Story = {
63
+ play: async ({canvasElement}) => {
64
+ const elements = [...canvasElement.querySelectorAll('*')].filter((el) =>
65
+ el.localName.includes('-')
66
+ );
67
+ await Promise.all(
68
+ elements.map((el) => customElements.whenDefined(el.localName))
69
+ );
70
+ await Promise.all(
71
+ elements.map((el) => (el as Partial<LitElement>).updateComplete)
72
+ );
73
+ },
74
+ render: () => {
75
+ const columns: {icon: string; value: number; closed: boolean}[] = [
76
+ {icon: 'open', value: 100, closed: false},
77
+ {icon: '75', value: 75, closed: false},
78
+ {icon: '50', value: 50, closed: false},
79
+ {icon: '25', value: 25, closed: false},
80
+ {icon: '10', value: 10, closed: false},
81
+ {icon: 'closed', value: 0, closed: true},
82
+ ];
83
+ return html`<div
84
+ style="display: grid; grid-template-columns: repeat(${columns.length}, 96px); gap: 8px"
85
+ >
86
+ ${columns.map(
87
+ ({icon}) =>
88
+ html`<div style="width: 96px; height: 96px">
89
+ ${unsafeHTML(
90
+ `<obi-twoway-analog-${icon} usecsscolor></obi-twoway-analog-${icon}>`
91
+ )}
92
+ </div>`
93
+ )}
94
+ ${columns.map(
95
+ ({value, closed}) =>
96
+ html`<obc-valve-analog-two-way-icon
97
+ style="width: 96px; height: 96px"
98
+ .value=${value}
99
+ .closed=${closed}
100
+ ></obc-valve-analog-two-way-icon>`
101
+ )}
102
+ </div>`;
103
+ },
104
+ };
@@ -2,10 +2,35 @@ import {LitElement, html, svg, unsafeCSS} from 'lit';
2
2
  import {property} from 'lit/decorators.js';
3
3
  import compentStyle from './valve-analog-two-way-icon.css?inline';
4
4
  import {customElement} from '../../decorator.js';
5
+ import {clampPercent} from '../../svghelpers/math.js';
5
6
  import '../../icons/icon-twoway-analog-closed.js';
6
7
 
8
+ const OUTLINE =
9
+ 'M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z';
10
+ const BODY =
11
+ 'M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z';
12
+
13
+ /** Width of the shut band at each port end when the opening is 0 %, in icon units. */
14
+ const BAND_RANGE = 7;
15
+
16
+ const SECONDARY = 'fill: var(--automation-device-secondary-color)';
17
+ const TERTIARY = 'fill: var(--automation-device-tertiary-color)';
18
+ const PRIMARY = 'fill: var(--automation-device-primary-color)';
19
+
7
20
  /**
21
+ * Two-way analog valve symbol whose opening moves continuously from 0 to
22
+ * 100 %.
23
+ *
24
+ * Draws the same symbol as the `obi-twoway-analog-*` icons. The shut bands at
25
+ * the port ends and the handle are linear in the opening: exact at 100 %
26
+ * (`obi-twoway-analog-open`) and at 0 % (vertical handle, ports shut to the
27
+ * centre), and close to the icons' 10/25/50/75 % steps in between. Used as
28
+ * the icon of `obc-analog-valve`.
29
+ *
30
+ * @property value - Opening in percent (0–100).
8
31
  * @availableWhen value closed==false
32
+ * @property closed - Shows the closed symbol.
33
+ * @property vertical - Turns the symbol 90° for a vertical pipe.
9
34
  * @stable
10
35
  */
11
36
  @customElement('obc-valve-analog-two-way-icon')
@@ -14,6 +39,33 @@ export class ObcValveAnalogTwoWayIcon extends LitElement {
14
39
  @property({type: Boolean}) closed: boolean = false;
15
40
  @property({type: Boolean}) vertical: boolean = false;
16
41
 
42
+ private renderBands(width: number) {
43
+ if (width <= 0) return null;
44
+ const left = 3 + width;
45
+ const right = 21 - width;
46
+ return svg`<g clip-path="url(#body)">
47
+ <rect x="2" y="0" width=${left - 2} height="24" style=${SECONDARY}/>
48
+ <rect x=${left} y="0" width="1" height="24" style=${TERTIARY}/>
49
+ <rect x=${right} y="0" width=${22 - right} height="24" style=${SECONDARY}/>
50
+ <rect x=${right - 1} y="0" width="1" height="24" style=${TERTIARY}/>
51
+ </g>`;
52
+ }
53
+
54
+ /**
55
+ * Horizontal at the top when open, turning to vertical and moving 2 units
56
+ * down as the valve shuts, matching `obi-twoway-analog-open` at 100 %.
57
+ */
58
+ private renderHandle(value: number) {
59
+ const shut = 1 - value / 100;
60
+ const angle = -90 * shut;
61
+ const cx = 12;
62
+ const cy = 3.5 + 2 * shut;
63
+ return svg`<g transform="rotate(${angle} ${cx} ${cy})">
64
+ <rect x=${cx - 4} y=${cy - 1.5} width="8" height="3" rx="1.5" style=${TERTIARY}/>
65
+ <rect x=${cx - 3} y=${cy - 0.5} width="6" height="1" rx="0.5" style=${PRIMARY}/>
66
+ </g>`;
67
+ }
68
+
17
69
  override render() {
18
70
  const transform = this.vertical ? 'transform: rotate(90deg);' : '';
19
71
  if (this.closed) {
@@ -22,19 +74,7 @@ export class ObcValveAnalogTwoWayIcon extends LitElement {
22
74
  </div>`;
23
75
  }
24
76
 
25
- const handleRotation = -(1 - this.value / 100) * 90;
26
- const handleTranslation = (1 - this.value / 100) * 2;
27
- const handle = svg`
28
- <g transform="translate(0, ${handleTranslation}) rotate(${handleRotation} 12 3.5) ">
29
- <path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 5H14.5C15.3284 5 16 4.32843 16 3.5C16 2.67157 15.3284 2 14.5 2H9.5C8.67157 2 8 2.67157 8 3.5C8 4.32843 8.67157 5 9.5 5ZM9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z" fill="var(--automation-device-tertiary-color)"/>
30
- <path d="M9.5 4L14.5 4C14.7761 4 15 3.77614 15 3.5C15 3.22386 14.7761 3 14.5 3L9.5 3C9.22386 3 9 3.22386 9 3.5C9 3.77614 9.22386 4 9.5 4Z" fill="var(--automation-device-primary-color)"/>
31
- </g>
32
- `;
33
-
34
- const xmin = 10.5;
35
- const xmax = 2.5;
36
- const x = xmin + ((xmax - xmin) * this.value) / 100;
37
-
77
+ const value = clampPercent(this.value);
38
78
  return html`
39
79
  <div class="wrapper" style="${transform}">
40
80
  <svg
@@ -44,55 +84,13 @@ export class ObcValveAnalogTwoWayIcon extends LitElement {
44
84
  fill="none"
45
85
  xmlns="http://www.w3.org/2000/svg"
46
86
  >
47
- <path
48
- d="M11 11L3.5547 6.03645C2.89015 5.59342 2 6.06981 2 6.8685V19.1315C2 19.9302 2.89015 20.4066 3.5547 19.9635L11 15H13L20.4453 19.9635C21.1099 20.4066 22 19.9302 22 19.1315V6.8685C22 6.06981 21.1099 5.59342 20.4453 6.03645L13 11H11ZM3 6.8685L3 19.1315L10.6972 14H13.3028L21 19.1315V6.8685L13.3028 12H10.6972L3 6.8685Z"
49
- fill="var(--automation-device-tertiary-color)"
50
- />
51
- <path
52
- d="M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z"
53
- fill="var(--automation-device-primary-color)"
54
- />
55
- ${handle}
56
- <g clip-path="url(#clip0)">
57
- <rect
58
- x=${xmax}
59
- y="0"
60
- width=${x - xmax}
61
- height="24"
62
- fill="var(--automation-device-secondary-color)"
63
- />
64
- <line
65
- x1=${x}
66
- y1="0"
67
- x2=${x}
68
- y2="24"
69
- stroke="var(--automation-device-tertiary-color)"
70
- stroke-width="1"
71
- />
72
-
73
- <rect
74
- x=${24 - x}
75
- y="0"
76
- width=${x - xmax}
77
- height="24"
78
- fill="var(--automation-device-secondary-color)"
79
- />
80
- <line
81
- x1=${24 - x}
82
- y1="0"
83
- x2=${24 - x}
84
- y2="24"
85
- stroke="var(--automation-device-tertiary-color)"
86
- stroke-width="1"
87
- />
88
- </g>
89
87
  <defs>
90
- <clipPath id="clip0">
91
- <path
92
- d="M10.6972 12H13.3028L21 6.8685V19.1315L13.3028 14H10.6972L3 19.1315V6.8685L10.6972 12Z"
93
- />
94
- </clipPath>
88
+ <clipPath id="body"><path d=${BODY} /></clipPath>
95
89
  </defs>
90
+ <path d=${OUTLINE} style=${TERTIARY} />
91
+ <path d=${BODY} style=${PRIMARY} />
92
+ ${this.renderBands((BAND_RANGE * (100 - value)) / 100)}
93
+ ${this.renderHandle(value)}
96
94
  </svg>
97
95
  </div>
98
96
  `;