@operato/board 1.4.41 → 1.4.42

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.41",
3
+ "version": "1.4.42",
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": "f08abc45b71c195fb3b8e4db2d001acc8f7fe40a"
151
+ "gitHead": "3e8f072f9711f2a72892a757bfdd13e4057f1c69"
152
152
  }
@@ -2,7 +2,9 @@ import '@operato/input/ox-input-search.js'
2
2
 
3
3
  import { css, html, LitElement, PropertyValues, TemplateResult } from 'lit'
4
4
  import { property, state } from 'lit/decorators.js'
5
- import Sortable from 'sortablejs'
5
+
6
+ // TODO test Sortable
7
+ // import Sortable from 'sortablejs'
6
8
  import { i18next } from '@operato/i18n'
7
9
 
8
10
  import { Component, Container, Scene } from '@hatiolab/things-scene'
@@ -122,6 +124,7 @@ export class SceneInspector extends LitElement {
122
124
 
123
125
  private _extendedMap: any
124
126
  private show: boolean = false
127
+ private count: number = -1
125
128
 
126
129
  disconnectScene(scene?: Scene) {
127
130
  if (scene) {
@@ -140,11 +143,13 @@ export class SceneInspector extends LitElement {
140
143
  }
141
144
 
142
145
  render() {
146
+ this.count = 0
147
+
143
148
  return html`
144
149
  <ox-input-search
145
150
  .placeholder=${i18next.t('text.search with type, id or tag')}
146
151
  autofocus
147
- @change=${(e: Event) => (this.searchText = (e.target as HTMLInputElement).value)}
152
+ @change=${(e: Event) => (this.searchText = ((e.target as HTMLInputElement).value || '').toLowerCase())}
148
153
  ></ox-input-search>
149
154
 
150
155
  <div result>${!this.scene ? html`` : this.renderComponent(this.scene.root, 0)}</div>
@@ -191,35 +196,38 @@ export class SceneInspector extends LitElement {
191
196
  }
192
197
  }
193
198
 
194
- this.updateComplete.then(() => {
195
- this.renderRoot.querySelectorAll('[sortable]').forEach(sortable => {
196
- new Sortable(sortable as HTMLElement, this.sortableConfig)
197
- })
198
- })
199
+ // TODO test Sortable
200
+ // this.updateComplete.then(() => {
201
+ // this.renderRoot.querySelectorAll('[sortable]').forEach(sortable => {
202
+ // new Sortable(sortable as HTMLElement, this.sortableConfig)
203
+ // })
204
+ // })
199
205
  }
200
206
 
201
- sortableConfig: Sortable.Options = {
202
- group: 'inspector',
203
- animation: 150,
204
- draggable: '.component',
205
- swapThreshold: 1,
206
- onSort: this.onSort.bind(this)
207
- }
207
+ // TODO test Sortable
208
+ // sortableConfig: Sortable.Options = {
209
+ // group: 'inspector',
210
+ // animation: 150,
211
+ // draggable: '.component',
212
+ // swapThreshold: 1,
213
+ // onSort: this.onSort.bind(this)
214
+ // }
208
215
 
209
- onSort(e: Sortable.SortableEvent) {
210
- if (!this.scene) return
216
+ // TODO test Sortable
217
+ // onSort(e: Sortable.SortableEvent) {
218
+ // if (!this.scene) return
211
219
 
212
- var component = (e.item as HTMLElement & { component: Component }).component
213
- var to_container = (e.to as HTMLElement & { component: Component }).component as Container
214
- var to_index = e.newIndex! - 1
220
+ // var component = (e.item as HTMLElement & { component: Component }).component
221
+ // var to_container = (e.to as HTMLElement & { component: Component }).component as Container
222
+ // var to_index = e.newIndex! - 1
215
223
 
216
- this.scene.move(component, to_container, to_index)
224
+ // this.scene.move(component, to_container, to_index)
217
225
 
218
- this.show = false
219
- this.updateComplete.then(() => {
220
- this.show = true
221
- })
222
- }
226
+ // this.show = false
227
+ // this.updateComplete.then(() => {
228
+ // this.show = true
229
+ // })
230
+ // }
223
231
 
224
232
  _onclick(e: MouseEvent) {
225
233
  e.stopPropagation()
@@ -326,14 +334,24 @@ export class SceneInspector extends LitElement {
326
334
  this.requestUpdate()
327
335
  }
328
336
 
329
- shouldBeShown(component: Component): boolean {
337
+ shouldBeShown(component: Component, counting: boolean = false): boolean {
330
338
  const { type, name, id, tag } = component.state
339
+ const found =
340
+ !this.searchText || `${type} ${name || ''} ${id || ''} ${tag || ''}`.toLowerCase().search(this.searchText) > -1
341
+
342
+ if (counting && found) {
343
+ this.count++
344
+ }
345
+
346
+ if (counting) {
347
+ console.log(found)
348
+ }
349
+
350
+ const foundChildren = ((component as Container).components || []).filter((child: Component) =>
351
+ this.shouldBeShown(child, counting)
352
+ ).length
331
353
 
332
- return !!(
333
- !this.searchText ||
334
- `${type} ${name || ''} ${id || ''} ${tag || ''}`.search(this.searchText) > -1 ||
335
- ((component as Container).components || []).find((child: Component) => this.shouldBeShown(child))
336
- )
354
+ return !!(found || foundChildren > 0)
337
355
  }
338
356
 
339
357
  renderComponent(component: Component, depth: number): TemplateResult {
@@ -341,7 +359,7 @@ export class SceneInspector extends LitElement {
341
359
  return html``
342
360
  }
343
361
 
344
- if (!this.shouldBeShown(component)) {
362
+ if (!this.shouldBeShown(component, depth == 0)) {
345
363
  return html``
346
364
  }
347
365
 
@@ -368,9 +386,8 @@ export class SceneInspector extends LitElement {
368
386
 
369
387
  <span class=${this.getNodeHandleClass(component)}> </span>
370
388
 
371
- <span class="type">${depth == 0 ? 'ROOT' : type}</span> ${name
372
- ? html` <span class="name">${name}</span> `
373
- : html``}
389
+ <span class="type">${depth == 0 ? html`ROOT(count: ${this.count})` : type}</span>
390
+ ${name ? html` <span class="name">${name}</span> ` : html``}
374
391
  </span>
375
392
 
376
393
  ${extended.map(child => this.renderComponent(child, depth + 1))}