@operato/board 1.0.25 → 1.0.26

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.25",
3
+ "version": "1.0.26",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "license": "MIT",
@@ -116,5 +116,5 @@
116
116
  "prettier --write"
117
117
  ]
118
118
  },
119
- "gitHead": "cc9a66e8eff17dfa7b2d63bd927a5fbc0641e887"
119
+ "gitHead": "b8aa0bf37d1f502c3937880b5965c273486258f4"
120
120
  }
@@ -1,5 +1,7 @@
1
+ import '@operato/input/ox-input-search.js'
2
+
1
3
  import { css, html, LitElement, PropertyValues, TemplateResult } from 'lit'
2
- import { property } from 'lit/decorators.js'
4
+ import { property, state } from 'lit/decorators.js'
3
5
  import Sortable from 'sortablejs'
4
6
 
5
7
  import { Component, Container, Scene } from '@hatiolab/things-scene'
@@ -8,9 +10,21 @@ export class SceneInspector extends LitElement {
8
10
  static styles = [
9
11
  css`
10
12
  :host {
13
+ display: flex;
14
+ flex-direction: column;
15
+
11
16
  color: var(--scene-inspector-color);
12
17
  }
13
18
 
19
+ div[result] {
20
+ flex: 1;
21
+
22
+ display: flex;
23
+ flex-direction: column;
24
+
25
+ overflow-y: auto;
26
+ }
27
+
14
28
  .component {
15
29
  display: block;
16
30
  overflow: hidden;
@@ -90,11 +104,18 @@ export class SceneInspector extends LitElement {
90
104
 
91
105
  @property({ type: Object }) scene?: Scene
92
106
 
107
+ @state() private searchText: string = ''
108
+
93
109
  private _extendedMap: any
94
110
  private show: boolean = false
95
111
 
96
112
  render() {
97
- return html` ${!this.scene ? html`` : this.renderComponent(this.scene.root, 0)} `
113
+ return html`
114
+ <ox-input-search
115
+ @change=${(e: Event) => (this.searchText = (e.target as HTMLInputElement).value)}
116
+ ></ox-input-search>
117
+ <div result>${!this.scene ? html`` : this.renderComponent(this.scene.root, 0)}</div>
118
+ `
98
119
  }
99
120
 
100
121
  firstUpdated() {
@@ -131,21 +152,21 @@ export class SceneInspector extends LitElement {
131
152
  }
132
153
  })
133
154
 
134
- this.requestUpdate()
155
+ this.refresh()
135
156
  })
136
157
 
137
158
  this.scene.on('execute', () => {
138
- this.requestUpdate()
159
+ this.refresh()
139
160
  })
140
161
 
141
162
  this.scene.on('undo', () => {
142
163
  this.extendedMap.set(this.scene!.root, true)
143
- this.requestUpdate()
164
+ this.refresh()
144
165
  })
145
166
 
146
167
  this.scene.on('redo', () => {
147
168
  this.extendedMap.set(this.scene!.root, true)
148
- this.requestUpdate()
169
+ this.refresh()
149
170
  })
150
171
  }
151
172
  }
@@ -157,6 +178,10 @@ export class SceneInspector extends LitElement {
157
178
  })
158
179
  }
159
180
 
181
+ refresh() {
182
+ this.scene && this.requestUpdate()
183
+ }
184
+
160
185
  sortableConfig: Sortable.Options = {
161
186
  group: 'inspector',
162
187
  animation: 150,
@@ -183,8 +208,8 @@ export class SceneInspector extends LitElement {
183
208
  disconnectedCallback() {
184
209
  super.disconnectedCallback()
185
210
 
186
- delete this.scene
187
- delete this._extendedMap
211
+ this.scene = undefined
212
+ this._extendedMap = undefined
188
213
  }
189
214
 
190
215
  _onclick(e: MouseEvent) {
@@ -219,7 +244,7 @@ export class SceneInspector extends LitElement {
219
244
  }
220
245
  }
221
246
 
222
- this.requestUpdate()
247
+ this.refresh()
223
248
  }
224
249
 
225
250
  _ondblclick(e: MouseEvent) {
@@ -242,12 +267,13 @@ export class SceneInspector extends LitElement {
242
267
  this.toggleExtended(component)
243
268
  }
244
269
 
245
- this.requestUpdate()
270
+ this.refresh()
246
271
  }
247
272
 
248
273
  get extendedMap() {
249
274
  if (!this._extendedMap) {
250
275
  this._extendedMap = new WeakMap()
276
+ this._extendedMap.set(this.scene!.root, true)
251
277
  }
252
278
 
253
279
  return this._extendedMap
@@ -274,19 +300,29 @@ export class SceneInspector extends LitElement {
274
300
  this.extendedMap.set(component, !extended)
275
301
  }
276
302
 
277
- this.requestUpdate()
303
+ this.refresh()
278
304
  }
279
305
 
280
306
  toggleHidden(component: Component) {
281
307
  component.set('hidden', !component.hidden)
282
308
 
283
- this.requestUpdate()
309
+ this.refresh()
284
310
  }
285
311
 
286
312
  selectComponent(component: Component) {
287
313
  this.scene!.selected = [component]
288
314
 
289
- this.requestUpdate()
315
+ this.refresh()
316
+ }
317
+
318
+ shouldBeShown(component: Component): boolean {
319
+ const { type, name, id, tag } = component.state
320
+
321
+ return !!(
322
+ !this.searchText ||
323
+ `${type} ${name || ''} ${id || ''} ${tag || ''}`.search(this.searchText) > -1 ||
324
+ ((component as Container).components || []).find((child: Component) => this.shouldBeShown(child))
325
+ )
290
326
  }
291
327
 
292
328
  renderComponent(component: Component, depth: number): TemplateResult {
@@ -294,8 +330,12 @@ export class SceneInspector extends LitElement {
294
330
  return html``
295
331
  }
296
332
 
333
+ if (!this.shouldBeShown(component)) {
334
+ return html``
335
+ }
336
+
297
337
  const children = (component.isContainer() && (component as Container).components) || []
298
- const extended = this.isExtended(component) ? children : []
338
+ const extended = this.isExtended(component) ? children.filter(child => this.shouldBeShown(child)) : []
299
339
  const { type, id, tag, class: clazz } = component.state
300
340
 
301
341
  const name = (id ? `#${id}` : '') + (tag ? `@${tag}` : '') + (clazz ? `.(${clazz})` : '')