@operato/board 1.0.9 → 1.0.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/board",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "license": "MIT",
@@ -78,7 +78,7 @@
78
78
  "devDependencies": {
79
79
  "@custom-elements-manifest/analyzer": "^0.4.17",
80
80
  "@hatiolab/prettier-config": "^1.0.0",
81
- "@hatiolab/things-scene": "^3.0.19",
81
+ "@hatiolab/things-scene": "^3.0.22",
82
82
  "@material/mwc-fab": "^0.26.1",
83
83
  "@material/mwc-icon": "^0.26.1",
84
84
  "@open-wc/eslint-config": "^4.3.0",
@@ -114,5 +114,5 @@
114
114
  "prettier --write"
115
115
  ]
116
116
  },
117
- "gitHead": "2e0182e37744a96a75b9fc4f5e0781c8a1c233f2"
117
+ "gitHead": "53120783ec56d0b4d2e27b495c43f7ae24569424"
118
118
  }
@@ -224,7 +224,8 @@ export default class DataBindingMapper extends LitElement {
224
224
  />
225
225
  <datalist id="target-list">
226
226
  <option value="(self)"></option>
227
- <option value="[key]"></option>
227
+ <option value="(key)"></option>
228
+ <option value="[propkey]"></option>
228
229
  ${this._componentIds.length
229
230
  ? html`
230
231
  ${this._componentIds.map(
@@ -29,7 +29,8 @@ class PropertyEventTap extends LitElement {
29
29
  }
30
30
 
31
31
  render() {
32
- var { action, value = '', target = '', pressed } = this.value || {}
32
+ var { action, value = '', target = '', pressed, options } = this.value || {}
33
+ var { input = '(self)', output = true } = options || {}
33
34
 
34
35
  return html`
35
36
  <input id="checkbox-pressed" type="checkbox" value-key="pressed" .checked=${pressed} />
@@ -68,7 +69,7 @@ class PropertyEventTap extends LitElement {
68
69
 
69
70
  <label> <ox-i18n msgid="label.target">target</ox-i18n> </label>
70
71
 
71
- ${action === 'goto' || action === 'popup'
72
+ ${action === 'goto' || action?.includes('popup')
72
73
  ? html`
73
74
  <things-editor-board-selector
74
75
  value-key="target"
@@ -83,7 +84,7 @@ class PropertyEventTap extends LitElement {
83
84
  list="target-list"
84
85
  .placeholder=${this._getPlaceHoder(action)}
85
86
  @focusin=${() => {
86
- this.targetList = this._getTargetList(action)
87
+ this.targetList = this._getInputList(action)
87
88
  }}
88
89
  />
89
90
 
@@ -93,7 +94,24 @@ class PropertyEventTap extends LitElement {
93
94
  )}
94
95
  </datalist>
95
96
  `}
96
- ${action === 'data-set' || action === 'value-set' || action === 'start-scenario' || action === 'run-scenario'
97
+ ${action === 'goto' || action?.includes('popup')
98
+ ? html`
99
+ <label for="input"> <ox-i18n msgid="label.input-data">input</ox-i18n> </label>
100
+ <input id="input" value-key="input" .value=${input} list="input-list" />
101
+ <datalist id="input-list">
102
+ ${this._getInputList(action).map(item => html` <option .value=${item}></option> `)}
103
+ </datalist>
104
+ ${
105
+ /* currently 'goto' does not support returning result */
106
+ action?.includes('popup')
107
+ ? html` <input id="checkbox-output" type="checkbox" value-key="output" .checked=${output} />
108
+ <label for="checkbox-output" class="checkbox-label">
109
+ <ox-i18n msgid="label.will-get-return">will-get-return</ox-i18n>
110
+ </label>`
111
+ : html``
112
+ }
113
+ `
114
+ : action === 'data-set' || action === 'value-set' || action === 'start-scenario' || action === 'run-scenario'
97
115
  ? html`
98
116
  <label> <ox-i18n msgid="label.value">value</ox-i18n> </label>
99
117
  <ox-input-data value-key="value" .value=${value} custom-editor fullwidth></ox-input-data>
@@ -104,9 +122,6 @@ class PropertyEventTap extends LitElement {
104
122
 
105
123
  _getPlaceHoder(action: string) {
106
124
  switch (action) {
107
- case 'popup':
108
- case 'goto':
109
- return 'SCENE-100'
110
125
  case 'link-open':
111
126
  case 'link-move':
112
127
  return 'http://www.hatiolab.com/'
@@ -115,12 +130,14 @@ class PropertyEventTap extends LitElement {
115
130
  }
116
131
  }
117
132
 
118
- _getTargetList(action: string): { value: string; description: string }[] {
133
+ _getInputList(action: string): { value: string; description: string }[] {
119
134
  switch (action) {
120
135
  case 'data-toggle':
121
136
  case 'data-tristate':
122
137
  case 'data-set':
123
138
  case 'value-set':
139
+ case 'popup':
140
+ case 'modal-popup':
124
141
  let ids =
125
142
  (this.scene &&
126
143
  this.scene.ids.map(i => {
@@ -160,9 +177,27 @@ class PropertyEventTap extends LitElement {
160
177
  return
161
178
  }
162
179
 
163
- this.value = {
164
- ...this.value,
165
- [key]: convert(element)
180
+ if (key === 'input' || key === 'output') {
181
+ var { options = {} } = this.value || {}
182
+
183
+ this.value = {
184
+ ...this.value,
185
+ options: {
186
+ ...options,
187
+ [key]: convert(element)
188
+ }
189
+ }
190
+ } else {
191
+ this.value = {
192
+ ...this.value,
193
+ [key]: convert(element)
194
+ }
195
+ }
196
+
197
+ var { action } = this.value
198
+ if (action !== 'goto' && !action?.includes('popup')) {
199
+ /* clear unused options */
200
+ delete this.value.options
166
201
  }
167
202
 
168
203
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
@@ -422,8 +422,10 @@ export class BoardViewer extends LitElement {
422
422
  )
423
423
  }
424
424
 
425
- onLinkGoto(targetBoardId: string, value: any, fromComponent: Component) {
426
- this.showScene(targetBoardId, fromComponent.data)
425
+ onLinkGoto(targetBoardId: string, options: any, fromComponent: any) {
426
+ const { input, output } = options || { input: '(self)' }
427
+ const data = input && fromComponent.root.findFirst(input, fromComponent)?.data
428
+ this.showScene(targetBoardId, data)
427
429
  }
428
430
 
429
431
  onLinkOpen(url: string, value: any, fromComponent: Component) {