@operato/board 1.4.47 → 1.4.48

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.4.47",
3
+ "version": "1.4.48",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/src/index.js",
@@ -148,5 +148,5 @@
148
148
  "prettier --write"
149
149
  ]
150
150
  },
151
- "gitHead": "183fefa68487e65a84cf0638fa8b35fd680ba2e8"
151
+ "gitHead": "98c601e3a5a8bd67ad66f64746cdeff4d762d747"
152
152
  }
@@ -23,6 +23,7 @@ export type Rule =
23
23
  | any
24
24
 
25
25
  export type Mapping = {
26
+ source?: string
26
27
  rule: 'map' | 'range' | 'eval' | 'value'
27
28
  accessor?: string
28
29
  target?: string
@@ -180,6 +181,7 @@ export class DataBindingMapper extends LitElement {
180
181
  @state() _componentIds: { value: string; description: string }[] = []
181
182
 
182
183
  @query('#eval-editor') editor!: HTMLInputElement
184
+ @query('#source-input') source!: HTMLInputElement
183
185
  @query('#target-input') target!: HTMLInputElement
184
186
 
185
187
  firstUpdated() {
@@ -190,12 +192,33 @@ export class DataBindingMapper extends LitElement {
190
192
  changes.has('mapping') && this._onChangedMapping()
191
193
  }
192
194
 
195
+ findComponentIds() {
196
+ return (
197
+ (this.scene &&
198
+ this.scene.ids.map(i => {
199
+ const id = i.key
200
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
201
+ })) ||
202
+ []
203
+ )
204
+ }
205
+
193
206
  render() {
194
207
  const mapping = this.mapping || {
195
208
  rule: 'value'
196
209
  }
197
210
 
198
211
  return html`
212
+ <label for="source-input"> <ox-i18n msgid="label.source">source</ox-i18n> </label>
213
+ <input
214
+ id="source-input"
215
+ type="text"
216
+ value-key="source"
217
+ list="source-list"
218
+ .value=${mapping.source || ''}
219
+ @focusin=${() => this.findComponentIds()}
220
+ />
221
+
199
222
  <label for="accessor-input">
200
223
  <ox-i18n msgid="label.accessor">accessor</ox-i18n><ox-help-icon topic="board-modeller/accessor"></ox-help-icon>
201
224
  </label>
@@ -214,16 +237,20 @@ export class DataBindingMapper extends LitElement {
214
237
  value-key="target"
215
238
  list="target-list"
216
239
  .value=${mapping.target || ''}
217
- @focusin=${() => {
218
- this._componentIds =
219
- (this.scene &&
220
- this.scene.ids.map(i => {
221
- const id = i.key
222
- return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
223
- })) ||
224
- []
225
- }}
240
+ @focusin=${() => this.findComponentIds()}
226
241
  />
242
+
243
+ <datalist id="source-list">
244
+ <option value="">(self)</option>
245
+ ${this._componentIds.length
246
+ ? html`
247
+ ${this._componentIds.map(
248
+ ({ value, description }) => html` <option value=${value}>${description}</option> `
249
+ )}
250
+ `
251
+ : html``}
252
+ </datalist>
253
+
227
254
  <datalist id="target-list">
228
255
  <option value="(self)"></option>
229
256
  <option value="(children)"></option>
@@ -364,7 +391,18 @@ export class DataBindingMapper extends LitElement {
364
391
 
365
392
  var value: string | boolean = element.value
366
393
 
367
- if (key === 'target') {
394
+ if (key === 'source') {
395
+ if (value.length > 0) {
396
+ value = value.trim()
397
+
398
+ this.source.value = value
399
+ }
400
+
401
+ this.mapping = {
402
+ ...this.mapping,
403
+ source: value
404
+ }
405
+ } else if (key === 'target') {
368
406
  if (value.length > 0 && !/^[.#(\[]/.test(value)) {
369
407
  value = '#' + value.trim()
370
408