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

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 (40) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +726 -504
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +2035 -720
  4. package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts +76 -0
  5. package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts.map +1 -0
  6. package/dist/automation/analog-threeway-valve/analog-threeway-valve.js +61 -0
  7. package/dist/automation/analog-threeway-valve/analog-threeway-valve.js.map +1 -0
  8. package/dist/automation/analog-valve/analog-valve.js +1 -1
  9. package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts +82 -0
  10. package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts.map +1 -0
  11. package/dist/automation/digital-threeway-valve/digital-threeway-valve.js +90 -0
  12. package/dist/automation/digital-threeway-valve/digital-threeway-valve.js.map +1 -0
  13. package/dist/automation/threeway-valve-shared/threeway-valve-shared.d.ts +39 -0
  14. package/dist/automation/threeway-valve-shared/threeway-valve-shared.d.ts.map +1 -0
  15. package/dist/automation/threeway-valve-shared/threeway-valve-shared.js +80 -0
  16. package/dist/automation/threeway-valve-shared/threeway-valve-shared.js.map +1 -0
  17. package/dist/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.d.ts +65 -4
  18. package/dist/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.d.ts.map +1 -1
  19. package/dist/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.js +153 -111
  20. package/dist/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.js.map +1 -1
  21. package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts +21 -0
  22. package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts.map +1 -1
  23. package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js +39 -58
  24. package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js.map +1 -1
  25. package/dist/components/automation-button-readout-stack/automation-button-readout-stack.d.ts +3 -0
  26. package/dist/components/automation-button-readout-stack/automation-button-readout-stack.d.ts.map +1 -1
  27. package/dist/components/automation-button-readout-stack/automation-button-readout-stack.js +17 -10
  28. package/dist/components/automation-button-readout-stack/automation-button-readout-stack.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/automation/analog-threeway-valve/analog-threeway-valve.stories.ts +106 -0
  31. package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +105 -0
  32. package/src/automation/digital-threeway-valve/digital-threeway-valve.stories.ts +122 -0
  33. package/src/automation/digital-threeway-valve/digital-threeway-valve.ts +143 -0
  34. package/src/automation/threeway-valve-shared/threeway-valve-shared.ts +110 -0
  35. package/src/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.stories.ts +145 -37
  36. package/src/automation/valve-analog-three-way-icon/valve-analog-three-way-icon.ts +225 -126
  37. package/src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.stories.ts +63 -0
  38. package/src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts +58 -60
  39. package/src/components/automation-button-readout-stack/automation-button-readout-stack.stories.ts +13 -0
  40. package/src/components/automation-button-readout-stack/automation-button-readout-stack.ts +31 -16
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Shared vocabulary of the three-way valves: `obc-digital-threeway-valve`,
3
+ * `obc-analog-threeway-valve` and `obc-valve-analog-three-way-icon`.
4
+ *
5
+ * ## Ports
6
+ *
7
+ * A three-way valve has three ports and one side without a port. The ports
8
+ * are numbered from the side without a port, in the order left, stem, right
9
+ * as seen with the stem pointing down: with `orientation` `bottom`, port 1 is
10
+ * the left port, port 2 the bottom port (the stem) and port 3 the right port.
11
+ * The numbering turns with the symbol, so port 2 is always the stem.
12
+ *
13
+ * ## Flow readouts
14
+ *
15
+ * Flow through a three-way valve can go several ways at once, so the readout
16
+ * is a list: one row per flow, each with an optional arrow direction and
17
+ * either a value with a unit (`%` when left out) or a state (`Open` /
18
+ * `Closed`).
19
+ *
20
+ * @module
21
+ */
22
+ import {AutomationButtonLabelDirection} from '../automation-button/automation-button.js';
23
+ import {AutomationButtonReadoutStack} from '../../components/automation-button-readout-stack/automation-button-readout-stack.js';
24
+
25
+ /**
26
+ * The side the stem (port 2) points to. `bottom` and `top` lay the valve on a
27
+ * horizontal pipe, `left` and `right` on a vertical one.
28
+ */
29
+ export enum ThreewayValveOrientation {
30
+ bottom = 'bottom',
31
+ left = 'left',
32
+ top = 'top',
33
+ right = 'right',
34
+ }
35
+
36
+ /** Clockwise rotation from the `bottom` drawing, in degrees. */
37
+ export function threewayValveRotation(
38
+ orientation: ThreewayValveOrientation
39
+ ): number {
40
+ switch (orientation) {
41
+ case ThreewayValveOrientation.left:
42
+ return 90;
43
+ case ThreewayValveOrientation.top:
44
+ return 180;
45
+ case ThreewayValveOrientation.right:
46
+ return 270;
47
+ default:
48
+ return 0;
49
+ }
50
+ }
51
+
52
+ /** A flow readout row with a value: `→ 060 %`. */
53
+ export interface ThreewayValveValueFlow {
54
+ /** Arrow direction on screen; left out or `none` hides the arrow. */
55
+ direction?: AutomationButtonLabelDirection;
56
+ value: number;
57
+ /** Defaults to `%`. */
58
+ unit?: string;
59
+ }
60
+
61
+ /** A flow readout row with a state: `→ Open`, `→ Closed`, or the on/off icon without a direction. */
62
+ export interface ThreewayValveStateFlow {
63
+ /**
64
+ * Arrow direction on screen; left out or `none` shows the on or off icon
65
+ * instead.
66
+ */
67
+ direction?: AutomationButtonLabelDirection;
68
+ open: boolean;
69
+ }
70
+
71
+ /** One row of the flow readout. */
72
+ export type ThreewayValveFlow = ThreewayValveValueFlow | ThreewayValveStateFlow;
73
+
74
+ /**
75
+ * The readout rows of a three-way valve: `Closed` while no flow can pass,
76
+ * the flow rows while it can, and `Open` when the application gives no flows.
77
+ */
78
+ export function threewayValveReadouts(
79
+ passing: boolean,
80
+ flows: ThreewayValveFlow[]
81
+ ): AutomationButtonReadoutStack[] {
82
+ if (!passing) {
83
+ return [{type: 'state-off', value: 'Closed', hasIcon: true}];
84
+ }
85
+ if (flows.length === 0) {
86
+ return [{type: 'state-on', value: 'Open', hasIcon: true}];
87
+ }
88
+ return flows.map((flow): AutomationButtonReadoutStack => {
89
+ if ('open' in flow) {
90
+ return {
91
+ type: flow.open ? 'state-on' : 'state-off',
92
+ value: flow.open ? 'Open' : 'Closed',
93
+ hasIcon:
94
+ flow.direction === undefined ||
95
+ flow.direction === AutomationButtonLabelDirection.none,
96
+ direction: flow.direction,
97
+ };
98
+ }
99
+ const direction = flow.direction ?? AutomationButtonLabelDirection.none;
100
+ return {
101
+ type: 'value',
102
+ value: flow.value,
103
+ nDigits: 3,
104
+ unit: flow.unit ?? '%',
105
+ direction,
106
+ icon:
107
+ direction === AutomationButtonLabelDirection.none ? 'none' : 'arrow',
108
+ };
109
+ });
110
+ }
@@ -1,69 +1,177 @@
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 {ObcValveAnalogThreeWayIcon} from './valve-analog-three-way-icon.js';
3
5
  import './valve-analog-three-way-icon.js';
6
+ import {ThreewayValveOrientation} from '../threeway-valve-shared/threeway-valve-shared.js';
7
+
8
+ import '../../icons/icon-threeway-analog-closed.js';
9
+ import '../../icons/icon-threeway-analog-inleft-bottom-0.js';
10
+ import '../../icons/icon-threeway-analog-inleft-bottom-100.js';
11
+ import '../../icons/icon-threeway-analog-inleft-bottom-25.js';
12
+ import '../../icons/icon-threeway-analog-inleft-bottom-50.js';
13
+ import '../../icons/icon-threeway-analog-inleft-bottom-75.js';
14
+ import '../../icons/icon-threeway-analog-inleft-left-0.js';
15
+ import '../../icons/icon-threeway-analog-inleft-left-100.js';
16
+ import '../../icons/icon-threeway-analog-inleft-left-25.js';
17
+ import '../../icons/icon-threeway-analog-inleft-left-50.js';
18
+ import '../../icons/icon-threeway-analog-inleft-left-75.js';
19
+ import '../../icons/icon-threeway-analog-inleft-right-0.js';
20
+ import '../../icons/icon-threeway-analog-inleft-right-100.js';
21
+ import '../../icons/icon-threeway-analog-inleft-right-25.js';
22
+ import '../../icons/icon-threeway-analog-inleft-right-50.js';
23
+ import '../../icons/icon-threeway-analog-inleft-right-75.js';
24
+ import '../../icons/icon-threeway-analog-open.js';
4
25
 
5
26
  const meta: Meta<typeof ObcValveAnalogThreeWayIcon> = {
6
27
  title: 'Automation/Icon/Valve Analog Three Way',
7
28
  tags: ['autodocs'],
8
29
  component: 'obc-valve-analog-three-way-icon',
9
30
  args: {
10
- horisontal: false,
31
+ open1: 100,
32
+ open2: 50,
33
+ open3: 50,
34
+ orientation: ThreewayValveOrientation.bottom,
11
35
  },
12
36
  argTypes: {
13
- horisontal: {
14
- control: {type: 'boolean'},
37
+ open1: {control: {type: 'range', min: 0, max: 100, step: 1}},
38
+ open2: {control: {type: 'range', min: 0, max: 100, step: 1}},
39
+ open3: {control: {type: 'range', min: 0, max: 100, step: 1}},
40
+ orientation: {
41
+ options: Object.values(ThreewayValveOrientation),
42
+ control: {type: 'radio'},
15
43
  },
44
+ value: {table: {disable: true}},
45
+ value2: {table: {disable: true}},
46
+ closed: {table: {disable: true}},
47
+ horisontal: {table: {disable: true}},
16
48
  },
49
+ render: (args) =>
50
+ html`<obc-valve-analog-three-way-icon
51
+ style="width: 96px; height: 96px"
52
+ .open1=${args.open1}
53
+ .open2=${args.open2}
54
+ .open3=${args.open3}
55
+ .orientation=${args.orientation}
56
+ ></obc-valve-analog-three-way-icon>`,
17
57
  } satisfies Meta<ObcValveAnalogThreeWayIcon>;
18
58
 
19
59
  export default meta;
20
60
  type Story = StoryObj<ObcValveAnalogThreeWayIcon>;
21
61
 
62
+ export const Split: Story = {};
63
+
22
64
  export const Open: Story = {
23
- args: {
24
- value: 100,
25
- value2: 0,
26
- closed: false,
27
- },
65
+ args: {open1: 100, open2: 100, open3: 100},
28
66
  };
29
67
 
30
68
  export const Closed: Story = {
31
- args: {
32
- value: 0,
33
- value2: 0,
34
- closed: true,
35
- },
69
+ args: {open1: 0, open2: 0, open3: 0},
36
70
  };
37
71
 
38
- export const HalfOpen: Story = {
39
- args: {
40
- value: 50,
41
- value2: 50,
42
- closed: false,
43
- },
72
+ export const Plugged: Story = {
73
+ args: {open1: 100, open2: 100, open3: 0},
44
74
  };
45
75
 
46
- export const OnePartOpen: Story = {
47
- args: {
48
- value: 50,
49
- value2: 0,
50
- closed: false,
51
- },
76
+ export const Continuous: Story = {
77
+ args: {open1: 100, open2: 63, open3: 37},
52
78
  };
53
79
 
54
- export const OnePartOpenHorizontal: Story = {
55
- args: {
56
- value: 50,
57
- value2: 0,
58
- closed: false,
59
- horisontal: true,
60
- },
80
+ export const Orientations: Story = {
81
+ render: (args) =>
82
+ html`<div style="display: flex; gap: 16px">
83
+ ${Object.values(ThreewayValveOrientation).map(
84
+ (orientation) =>
85
+ html`<obc-valve-analog-three-way-icon
86
+ style="width: 96px; height: 96px"
87
+ .open1=${args.open1}
88
+ .open2=${args.open2}
89
+ .open3=${args.open3}
90
+ .orientation=${orientation}
91
+ ></obc-valve-analog-three-way-icon>`
92
+ )}
93
+ </div>`,
94
+ args: {open1: 100, open2: 75, open3: 25},
61
95
  };
62
96
 
63
- export const NearClosed: Story = {
64
- args: {
65
- value: 0,
66
- value2: 100,
67
- closed: false,
97
+ /** Top row: the `obi-threeway-analog-*` icons. Bottom row: this component at the same openings. */
98
+ export const MatchesIcons: Story = {
99
+ parameters: {
100
+ docs: {
101
+ description: {
102
+ story:
103
+ 'Each column is one `obi-threeway-analog-inleft-*` icon above this component at the same openings. ' +
104
+ 'The 0 and 100 % steps match exactly; the symbol is linear in between, so the 25/50/75 steps differ slightly. ' +
105
+ 'The `inleft-bottom` and `inleft-right` series are compared at their 25/50/75 steps and at the opposite end step, ' +
106
+ 'because their 0 and 100 steps are named the other way round.',
107
+ },
108
+ },
68
109
  },
110
+ play: async ({canvasElement}) => {
111
+ const elements = [...canvasElement.querySelectorAll('*')].filter((el) =>
112
+ el.localName.includes('-')
113
+ );
114
+ await Promise.all(
115
+ elements.map((el) => customElements.whenDefined(el.localName))
116
+ );
117
+ await Promise.all(
118
+ elements.map((el) => (el as Partial<LitElement>).updateComplete)
119
+ );
120
+ },
121
+ render: () => {
122
+ const columns: {icon: string; ports: [number, number, number]}[] = [];
123
+ for (const step of [0, 25, 50, 75, 100]) {
124
+ columns.push({
125
+ icon: `inleft-left-${step}`,
126
+ ports: [100, 100 - step, step],
127
+ });
128
+ }
129
+ for (const step of [0, 25, 50, 75, 100]) {
130
+ const name = step === 0 || step === 100 ? 100 - step : step;
131
+ columns.push({
132
+ icon: `inleft-bottom-${name}`,
133
+ ports: [step, 100, 100 - step],
134
+ });
135
+ }
136
+ for (const step of [0, 25, 50, 75, 100]) {
137
+ const name = step === 0 || step === 100 ? 100 - step : step;
138
+ columns.push({
139
+ icon: `inleft-right-${name}`,
140
+ ports: [step, 100 - step, 100],
141
+ });
142
+ }
143
+ columns.push({icon: 'open', ports: [100, 100, 100]});
144
+ columns.push({icon: 'closed', ports: [0, 0, 0]});
145
+ return html`<div
146
+ style="display: grid; grid-template-columns: repeat(${columns.length}, 48px); gap: 8px"
147
+ >
148
+ ${columns.map(
149
+ ({icon}) =>
150
+ html`<div style="width: 48px; height: 48px">
151
+ ${unsafeHTML(
152
+ `<obi-threeway-analog-${icon} usecsscolor></obi-threeway-analog-${icon}>`
153
+ )}
154
+ </div>`
155
+ )}
156
+ ${columns.map(
157
+ ({ports}) =>
158
+ html`<obc-valve-analog-three-way-icon
159
+ style="width: 48px; height: 48px"
160
+ .open1=${ports[0]}
161
+ .open2=${ports[1]}
162
+ .open3=${ports[2]}
163
+ ></obc-valve-analog-three-way-icon>`
164
+ )}
165
+ </div>`;
166
+ },
167
+ };
168
+
169
+ /** The deprecated `value`/`value2` properties draw the symbol stem up with the left port fully open. */
170
+ export const DeprecatedValueProperties: Story = {
171
+ render: () =>
172
+ html`<obc-valve-analog-three-way-icon
173
+ style="width: 96px; height: 96px"
174
+ .value=${50}
175
+ .value2=${50}
176
+ ></obc-valve-analog-three-way-icon>`,
69
177
  };