@operato/process 7.1.31 → 7.1.33

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 (57) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +14 -14
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/preview.js +0 -52
  6. package/.storybook/server.mjs +0 -8
  7. package/demo/index-modeller.html +0 -112
  8. package/demo/index-viewer.html +0 -112
  9. package/demo/index.html +0 -112
  10. package/src/data-storage/data-storage.ts +0 -47
  11. package/src/graphql/data-subscription.ts +0 -30
  12. package/src/graphql/favorite-process.ts +0 -25
  13. package/src/graphql/index.ts +0 -3
  14. package/src/graphql/process-group.ts +0 -138
  15. package/src/graphql/process.ts +0 -141
  16. package/src/graphql/scenario.ts +0 -79
  17. package/src/index.ts +0 -8
  18. package/src/modeller/component-toolbar/component-detail.ts +0 -58
  19. package/src/modeller/component-toolbar/component-menu.ts +0 -193
  20. package/src/modeller/component-toolbar/component-toolbar.ts +0 -196
  21. package/src/modeller/component-toolbar/mode-icons.ts +0 -88
  22. package/src/modeller/edit-toolbar-style.ts +0 -229
  23. package/src/modeller/edit-toolbar.ts +0 -576
  24. package/src/modeller/property-sidebar/abstract-property.ts +0 -69
  25. package/src/modeller/property-sidebar/data-binding/data-binding-mapper.ts +0 -475
  26. package/src/modeller/property-sidebar/data-binding/data-binding.ts +0 -479
  27. package/src/modeller/property-sidebar/effects/effects-shared-style.ts +0 -62
  28. package/src/modeller/property-sidebar/effects/effects.ts +0 -52
  29. package/src/modeller/property-sidebar/effects/property-event-hover.ts +0 -201
  30. package/src/modeller/property-sidebar/effects/property-event-tap.ts +0 -212
  31. package/src/modeller/property-sidebar/effects/property-event.ts +0 -76
  32. package/src/modeller/property-sidebar/effects/property-shadow.ts +0 -114
  33. package/src/modeller/property-sidebar/effects/value-converter.ts +0 -23
  34. package/src/modeller/property-sidebar/inspector/inspector.ts +0 -408
  35. package/src/modeller/property-sidebar/property-shared-style.ts +0 -136
  36. package/src/modeller/property-sidebar/property-sidebar.ts +0 -342
  37. package/src/modeller/property-sidebar/shapes/box-padding-editor-styles.ts +0 -94
  38. package/src/modeller/property-sidebar/shapes/shapes.ts +0 -410
  39. package/src/modeller/property-sidebar/specifics/specific-properties-builder.ts +0 -147
  40. package/src/modeller/property-sidebar/specifics/specifics.ts +0 -81
  41. package/src/modeller/property-sidebar/styles/styles.ts +0 -577
  42. package/src/ox-editor-process-selector.ts +0 -91
  43. package/src/ox-process-list.ts +0 -401
  44. package/src/ox-process-modeller.ts +0 -432
  45. package/src/ox-process-template-list.ts +0 -272
  46. package/src/ox-process-template-viewer.ts +0 -198
  47. package/src/ox-process-viewer.ts +0 -575
  48. package/src/ox-property-editor-process-selector.ts +0 -23
  49. package/src/selector/ox-process-creation-card.ts +0 -95
  50. package/src/selector/ox-process-selector.ts +0 -324
  51. package/src/selector/process-creation-popup.ts +0 -151
  52. package/src/selector/process-thumbnail-card.ts +0 -175
  53. package/src/types.ts +0 -57
  54. package/stories/index.stories.ts +0 -54
  55. package/tsconfig.json +0 -24
  56. package/web-dev-server.config.mjs +0 -30
  57. package/web-test-runner.config.mjs +0 -29
@@ -1,576 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { html, LitElement, PropertyValues } from 'lit'
6
- import { property, query, queryAll } from 'lit/decorators.js'
7
-
8
- import { Component, Scene } from '@hatiolab/things-scene'
9
- import { copyToClipboard, isMacOS } from '@operato/utils'
10
-
11
- import { style } from './edit-toolbar-style'
12
-
13
- const MACOS = isMacOS()
14
-
15
- export class EditToolbar extends LitElement {
16
- static styles = [style]
17
-
18
- @property({ type: Object }) scene?: Scene
19
- @property({ type: Array }) selected: any[] = []
20
- @property({ type: Boolean }) hideProperty: boolean = false
21
-
22
- private cliped?: string
23
-
24
- @query('#redo') private redo!: HTMLElement
25
- @query('#undo') private undo!: HTMLElement
26
-
27
- @query('#fullscreen') private fullscreen!: HTMLElement
28
- @query('#cut') private cut!: HTMLElement
29
- @query('#copy') private copy!: HTMLElement
30
- @query('#paste') private paste!: HTMLElement
31
- @query('#delete') private delete!: HTMLElement
32
-
33
- @query('#forward') private forward!: HTMLElement
34
- @query('#backward') private backward!: HTMLElement
35
- @query('#front') private front!: HTMLElement
36
- @query('#back') private back!: HTMLElement
37
-
38
- @queryAll('[data-align]') private aligners!: NodeListOf<HTMLSpanElement>
39
- @queryAll('[data-zorder]') private zorders!: NodeListOf<HTMLSpanElement>
40
- @queryAll('[data-distribute]') private distributes!: NodeListOf<HTMLSpanElement>
41
-
42
- firstUpdated() {
43
- this.addEventListener('mousewheel', this.onWheelEvent.bind(this) as EventListener, false)
44
-
45
- window.addEventListener('paste', (e: Event) => {
46
- try {
47
- this.cliped = (e as ClipboardEvent).clipboardData?.getData('text/plain')
48
- } catch (e) {
49
- console.error('model paste failed', e)
50
- }
51
- })
52
-
53
- this.aligners.forEach(aligner => aligner.addEventListener('tap', this.onTapAlign.bind(this) as EventListener))
54
- this.zorders.forEach(zorder => zorder.addEventListener('tap', this.onTapZorder.bind(this) as EventListener))
55
- this.distributes.forEach(distribute =>
56
- distribute.addEventListener('tap', this.onTapDistribute.bind(this) as EventListener)
57
- )
58
-
59
- this.undo.addEventListener('tap', this.onTapUndo.bind(this) as EventListener)
60
- this.redo.addEventListener('tap', this.onTapRedo.bind(this) as EventListener)
61
- this.fullscreen.addEventListener('tap', this.onTapFullscreen.bind(this) as EventListener)
62
- this.cut.addEventListener('tap', this.onTapCut.bind(this) as EventListener)
63
- this.copy.addEventListener('tap', this.onTapCopy.bind(this) as EventListener)
64
- this.paste.addEventListener('tap', this.onTapPaste.bind(this) as EventListener)
65
- this.delete.addEventListener('tap', this.onTapDelete.bind(this) as EventListener)
66
-
67
- this.renderRoot
68
- .querySelector('#font-increase')!
69
- .addEventListener('tap', this.onTapFontIncrease.bind(this) as EventListener)
70
- this.renderRoot
71
- .querySelector('#font-decrease')!
72
- .addEventListener('tap', this.onTapFontDecrease.bind(this) as EventListener)
73
- this.renderRoot.querySelector('#group')!.addEventListener('tap', this.onTapGroup.bind(this) as EventListener)
74
- this.renderRoot.querySelector('#ungroup')!.addEventListener('tap', this.onTapUngroup.bind(this) as EventListener)
75
- this.renderRoot
76
- .querySelector('#toggle-property')!
77
- .addEventListener('tap', this.onTapToggle.bind(this) as EventListener)
78
- this.renderRoot.querySelector('#fit-scene')!.addEventListener('tap', this.onTapFitScene.bind(this) as EventListener)
79
- this.renderRoot.querySelector('#preview')!.addEventListener('tap', this.onTapPreview.bind(this) as EventListener)
80
- }
81
-
82
- updated(changes: PropertyValues<this>) {
83
- changes.has('scene') && this.onSceneChanged(this.scene, changes.get('scene') as Scene)
84
- changes.has('selected') && this.onSelectedChanged(this.selected, changes.get('selected') as Component[])
85
- }
86
-
87
- render() {
88
- return html`
89
- <div tools>
90
- <span><slot></slot></span>
91
-
92
- <span button id="undo" title="undo (${this.getShortcutString('cmd', 'z')})"> </span>
93
- <span button id="redo" title="redo (${this.getShortcutString('cmd', 'shift', 'z')})"> </span>
94
-
95
- <span class="vline"></span>
96
-
97
- <span button id="cut" title="cut (${this.getShortcutString('cmd', 'x')})"> </span>
98
- <span button id="copy" title="copy (${this.getShortcutString('cmd', 'c')})"> </span>
99
- <span button id="paste" title="paste (${this.getShortcutString('cmd', 'v')})"> </span>
100
- <span
101
- button
102
- id="delete"
103
- title="delete (${this.getShortcutString('backspace')}, ${this.getShortcutString('delete')})"
104
- >
105
- </span>
106
-
107
- <span class="vline"></span>
108
-
109
- <!-- TODO Implement style-copy
110
- <span button id="style-copy" title="format painter"></span>
111
- <span class="vline"></span>
112
- -->
113
-
114
- <span
115
- button
116
- data-align="left"
117
- id="align-left"
118
- title="align left (${this.getShortcutString('alt', 'shift', 'l')})"
119
- >
120
- </span>
121
- <span
122
- button
123
- data-align="center"
124
- id="align-center"
125
- title="align center (${this.getShortcutString('alt', 'shift', 'c')})"
126
- >
127
- </span>
128
- <span
129
- button
130
- data-align="right"
131
- id="align-right"
132
- title="align right (${this.getShortcutString('alt', 'shift', 'r')})"
133
- >
134
- </span>
135
-
136
- <span button data-align="top" id="align-top" title="align top (${this.getShortcutString('alt', 'shift', 't')})">
137
- </span>
138
- <span
139
- button
140
- data-align="middle"
141
- id="align-middle"
142
- title="align middle (${this.getShortcutString('alt', 'shift', 'm')})"
143
- >
144
- </span>
145
- <span
146
- button
147
- data-align="bottom"
148
- id="align-bottom"
149
- title="align bottom (${this.getShortcutString('alt', 'shift', 'b')})"
150
- >
151
- </span>
152
-
153
- <span
154
- button
155
- data-distribute="HORIZONTAL"
156
- id="distribute-horizontal"
157
- title="distribute horizontally (${this.getShortcutString('alt', 'shift', 'h')})"
158
- >
159
- </span>
160
-
161
- <span
162
- button
163
- data-distribute="VERTICAL"
164
- id="distribute-vertical"
165
- title="distribute vertically (${this.getShortcutString('alt', 'shift', 'v')})"
166
- >
167
- </span>
168
-
169
- <span class="vline"></span>
170
-
171
- <span
172
- button
173
- id="front"
174
- data-zorder="front"
175
- title="bring to front (${this.getShortcutString('cmd', 'shift', 'f')})"
176
- >
177
- </span>
178
- <span button id="back" data-zorder="back" title="send to back (${this.getShortcutString('cmd', 'shift', 'b')})">
179
- </span>
180
- <span button id="forward" data-zorder="forward" title="bring forward (${this.getShortcutString('cmd', 'f')})">
181
- </span>
182
- <span button id="backward" data-zorder="backward" title="send backward (${this.getShortcutString('cmd', 'b')})">
183
- </span>
184
-
185
- <span class="vline"></span>
186
-
187
- <span button id="group" title="group (${this.getShortcutString('cmd', 'g')})"> </span>
188
- <span button id="ungroup" title="ungroup (${this.getShortcutString('cmd', 'shift', 'g')})"> </span>
189
-
190
- <span class="vline"></span>
191
-
192
- <span button id="font-increase" title="increase font size"></span>
193
- <span button id="font-decrease" title="decrease font size" style="scale: 0.7;"></span>
194
-
195
- <span class="vline"></span>
196
- <span padding></span>
197
-
198
- <span button id="fit-scene" title="fit scene (${this.getShortcutString('cmd', 'd')})"> </span>
199
-
200
- <span class="vline"></span>
201
-
202
- <span button id="preview" title="preview (${this.getShortcutString('ctrl', 'p')})"> </span>
203
-
204
- <span button id="fullscreen" title="fullscreen (${this.getShortcutString('f11')})"> </span>
205
-
206
- <span
207
- button
208
- id="toggle-property"
209
- title="toggle property panel (${this.getShortcutString('cmd', 'h')})"
210
- toggles="true"
211
- >
212
- </span>
213
- </div>
214
- `
215
- }
216
-
217
- onWheelEvent(e: Event) {
218
- var delta = Math.max(-1, Math.min(1, (e as WheelEvent).deltaY || -(e as WheelEvent).detail))
219
- this.scrollLeft -= delta * 40
220
-
221
- e.preventDefault()
222
- }
223
-
224
- getSymbol(key: string) {
225
- var symbol
226
- switch (key) {
227
- case 'cmd':
228
- case 'ctrl':
229
- symbol = MACOS ? '⌘' : 'Ctrl'
230
- break
231
- case 'shift':
232
- symbol = MACOS ? '⇧' : 'Shift'
233
- break
234
- case 'alt':
235
- case 'option':
236
- symbol = MACOS ? '⌥' : 'Alt'
237
- break
238
- case 'backspace':
239
- symbol = MACOS ? '⌫' : 'BackSpace'
240
- break
241
- case 'delete':
242
- symbol = MACOS ? '⌦' : 'Del'
243
- break
244
- default:
245
- symbol = key.toUpperCase()
246
- break
247
- }
248
-
249
- return symbol
250
- }
251
-
252
- private getShortcutString(...keys: string[]) {
253
- var symbols = []
254
- for (var i = 0; i < arguments.length; i++) {
255
- symbols.push(this.getSymbol(arguments[i]))
256
- }
257
-
258
- return symbols.join(MACOS ? '' : '+')
259
- }
260
-
261
- onShortcut(e: KeyboardEvent) {
262
- if (MACOS) var ctrlKey = e.metaKey
263
- else var ctrlKey = e.ctrlKey
264
-
265
- var altKey = e.altKey
266
- var shiftKey = e.shiftKey
267
-
268
- var defaultPrevent = ctrlKey || altKey
269
-
270
- switch (e.code) {
271
- case 'KeyZ':
272
- if (ctrlKey && !shiftKey) this.onTapUndo()
273
- else if (ctrlKey && shiftKey) this.onTapRedo()
274
- break
275
- case 'KeyY':
276
- if (ctrlKey && !shiftKey) this.onTapRedo()
277
- break
278
- case 'KeyC':
279
- if (ctrlKey && !shiftKey) this.onTapCopy()
280
- else if (altKey && shiftKey) this.onTapAlign('center')
281
- break
282
- case 'KeyX':
283
- if (ctrlKey && !shiftKey) this.onTapCut()
284
- break
285
- case 'KeyV':
286
- if (ctrlKey && !shiftKey) {
287
- this.onTapPaste()
288
- defaultPrevent = false
289
- } else if (altKey && shiftKey) this.onTapDistribute('VERTICAL')
290
- break
291
- case 'Delete':
292
- case 'Backspace':
293
- this.onTapDelete()
294
- defaultPrevent = true
295
- break
296
- case 'KeyG':
297
- if (ctrlKey && !shiftKey) this.onTapGroup()
298
- else if (ctrlKey && shiftKey) this.onTapUngroup()
299
- break
300
- case 'KeyF':
301
- if (ctrlKey && !shiftKey) this.scene?.zorder('forward')
302
- else if (ctrlKey && shiftKey) this.scene?.zorder('front')
303
- break
304
- case 'KeyB':
305
- if (ctrlKey && !shiftKey) this.scene?.zorder('backward')
306
- else if (ctrlKey && shiftKey) this.scene?.zorder('back')
307
- else if (altKey && shiftKey) this.onTapAlign('bottom')
308
- break
309
- // case 'Equal':
310
- // if (ctrlKey) this.onTapZoom(zoomin)
311
- // break
312
- // case 'Minus':
313
- // if (ctrlKey) this.onTapZoom(zoomout)
314
- // break
315
- case 'KeyH':
316
- if (ctrlKey && !shiftKey) this.onTapToggle()
317
- else if (altKey && shiftKey) this.onTapDistribute('HORIZONTAL')
318
- break
319
- case 'F11':
320
- this.onTapFullscreen()
321
- defaultPrevent = true
322
- break
323
- case 'KeyP':
324
- if (ctrlKey) {
325
- this.onTapPreview()
326
- defaultPrevent = true
327
- }
328
- break
329
- case 'KeyA':
330
- if (ctrlKey) this.onTapSelectAll()
331
- break
332
- case 'KeyL':
333
- if (altKey && shiftKey) this.onTapAlign('left')
334
- break
335
- case 'KeyR':
336
- if (altKey && shiftKey) this.onTapAlign('right')
337
- break
338
- case 'KeyM':
339
- if (altKey && shiftKey) this.onTapAlign('middle')
340
- break
341
- case 'KeyT':
342
- if (altKey && shiftKey) this.onTapAlign('top')
343
- break
344
- case 'KeyD':
345
- if (ctrlKey) {
346
- this.onTapFitScene()
347
- defaultPrevent = true
348
- }
349
- break
350
- case 'KeyE':
351
- if (ctrlKey && shiftKey) this.onTapDownloadModel()
352
- break
353
- case 'Digit1':
354
- if (ctrlKey) {
355
- console.log('MODEL', this.scene && this.scene.model)
356
- defaultPrevent = true
357
- }
358
- break
359
- case 'Digit2':
360
- if (ctrlKey) {
361
- console.log('SELECTED', this.scene && this.scene.selected)
362
- defaultPrevent = true
363
- }
364
- break
365
-
366
- default:
367
- return false
368
- }
369
-
370
- if (defaultPrevent) e.preventDefault()
371
- return true
372
- }
373
-
374
- onExecute(command: string, undoable: boolean, redoable: boolean) {
375
- !undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
376
- !redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
377
- }
378
-
379
- onUndo(undoable: boolean, redoable: boolean) {
380
- !undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
381
- !redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
382
- }
383
-
384
- onRedo(undoable: boolean, redoable: boolean) {
385
- !undoable ? this.undo.setAttribute('disabled', '') : this.undo.removeAttribute('disabled')
386
- !redoable ? this.redo.setAttribute('disabled', '') : this.redo.removeAttribute('disabled')
387
- }
388
-
389
- onSceneChanged(after?: Scene, before?: Scene) {
390
- if (before) {
391
- before.off('execute', this.onExecute, this)
392
- before.off('undo', this.onUndo, this)
393
- before.off('redo', this.onRedo, this)
394
- }
395
-
396
- if (after) {
397
- after.on('execute', this.onExecute, this)
398
- after.on('undo', this.onUndo, this)
399
- after.on('redo', this.onRedo, this)
400
- }
401
- }
402
-
403
- // @query('#align-left') private alignLeft!: HTMLElement
404
- // @query('#align-center') private alignCenter!: HTMLElement
405
- // @query('#align-right') private alignRight!: HTMLElement
406
- // @query('#align-top') private alignTop!: HTMLElement
407
- // @query('#align-middle') private alignMiddle!: HTMLElement
408
- // @query('#align-bottom') private alignBottom!: HTMLElement
409
-
410
- onSelectedChanged(after: Component[], before: Component[]) {
411
- var alignable = after.length > 1
412
-
413
- this.aligners.forEach(aligner =>
414
- alignable ? aligner.removeAttribute('disabled') : aligner.setAttribute('disabled', '')
415
- )
416
-
417
- var movable = after.length === 1
418
-
419
- /* forward, backward 이동은 한 컴포넌트만 가능하다. */
420
- !movable ? this.forward.setAttribute('disabled', '') : this.forward.removeAttribute('disabled')
421
- !movable ? this.backward.setAttribute('disabled', '') : this.backward.removeAttribute('disabled')
422
-
423
- /* 여러 컴포넌트는 front, back 이동이 가능하다. */
424
- !(alignable || movable) ? this.front.setAttribute('disabled', '') : this.front.removeAttribute('disabled')
425
- !(alignable || movable) ? this.back.setAttribute('disabled', '') : this.back.removeAttribute('disabled')
426
- }
427
-
428
- onTapUndo() {
429
- this.scene?.undo()
430
- }
431
-
432
- onTapRedo() {
433
- this.scene?.redo()
434
- }
435
-
436
- onTapCut() {
437
- this.scene?.cut()
438
- }
439
-
440
- async onTapCopy() {
441
- var copied = this.scene?.copy()
442
-
443
- if (!copied) return
444
-
445
- await copyToClipboard(copied)
446
- this.cliped = copied
447
- }
448
-
449
- onTapPaste() {
450
- setTimeout(() => {
451
- this.cliped && this.scene?.paste(this.cliped)
452
- }, 100)
453
- }
454
-
455
- onTapDelete() {
456
- this.scene?.remove()
457
- }
458
-
459
- onTapSelectAll() {
460
- this.scene?.select('(child)')
461
- }
462
-
463
- onTapFontIncrease(e: TouchEvent) {
464
- var selected = this.scene?.selected
465
- if (!selected || !selected.length) {
466
- return
467
- }
468
-
469
- this.scene?.undoableChange(function () {
470
- selected!.forEach(function (component) {
471
- var fontSize = component.get('fontSize')
472
-
473
- if (!fontSize) fontSize = '15'
474
-
475
- if (fontSize) {
476
- var size = parseInt(fontSize)
477
- component.set('fontSize', size + 1)
478
- }
479
- })
480
- })
481
- }
482
-
483
- onTapFontDecrease(e: TouchEvent) {
484
- var selected = this.scene?.selected
485
-
486
- if (!selected || !selected.length) {
487
- return
488
- }
489
-
490
- this.scene?.undoableChange(function () {
491
- selected!.forEach(function (component) {
492
- var fontSize = component.get('fontSize')
493
-
494
- if (!fontSize) fontSize = '15'
495
-
496
- if (fontSize) {
497
- var size = parseInt(fontSize)
498
- if (size > 1) component.set('fontSize', size - 1)
499
- }
500
- })
501
- })
502
- }
503
-
504
- onTapAlign(e: TouchEvent | string) {
505
- if (!this.scene) return
506
-
507
- var selected = this.scene.selected
508
- if (selected.length <= 1) return
509
-
510
- var align = typeof e === 'string' ? e : (e.target as HTMLElement).getAttribute('data-align')
511
-
512
- align && this.scene.align(align)
513
- }
514
-
515
- onTapZorder(e: TouchEvent | string) {
516
- if (!this.scene) return
517
-
518
- var selected = this.scene.selected
519
- if (selected.length < 1) return
520
-
521
- var zorder = typeof e === 'string' ? e : (e.target as HTMLElement).getAttribute('data-zorder')
522
-
523
- zorder && this.scene.zorder(zorder)
524
- }
525
-
526
- onTapGroup() {
527
- this.scene && this.scene.group()
528
- }
529
-
530
- onTapUngroup() {
531
- this.scene && this.scene.ungroup()
532
- }
533
-
534
- onTapFullscreen() {
535
- this.dispatchEvent(new CustomEvent('modeller-fullscreen'))
536
- }
537
-
538
- onTapToggle() {
539
- this.hideProperty = !this.hideProperty
540
- this.dispatchEvent(
541
- new CustomEvent('hide-property-changed', {
542
- bubbles: true,
543
- composed: true,
544
- detail: { value: this.hideProperty }
545
- })
546
- )
547
- }
548
-
549
- onTapFitScene() {
550
- if (this.scene) {
551
- this.scene.resize()
552
- this.scene.fit('ratio')
553
- }
554
- }
555
-
556
- onTapPreview() {
557
- this.dispatchEvent(new CustomEvent('open-preview'))
558
- }
559
-
560
- onTapDownloadModel() {
561
- this.dispatchEvent(new CustomEvent('download-model'))
562
- }
563
-
564
- onTapDistribute(e: TouchEvent | string) {
565
- if (!this.scene) return
566
-
567
- var selected = this.scene.selected
568
- if (selected.length <= 1) {
569
- return
570
- }
571
-
572
- var distribute = typeof e === 'string' ? e : (e.target as HTMLElement)!.getAttribute('data-distribute')
573
-
574
- distribute && this.scene.distribute(distribute)
575
- }
576
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement } from 'lit'
6
-
7
- export class AbstractProperty extends LitElement {
8
- firstUpdated() {
9
- this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
10
- }
11
-
12
- _onValueChange(e: Event) {
13
- var element = e.target as HTMLElement
14
- var key = element.getAttribute('value-key')
15
-
16
- if (!key) {
17
- return
18
- }
19
-
20
- var value = this._getValueFromEventTarget(element)
21
-
22
- this._onAfterValueChange(key, value)
23
- }
24
-
25
- _getValueFromEventTarget(element: HTMLElement) {
26
- var value
27
-
28
- switch (element.tagName) {
29
- case 'INPUT':
30
- switch ((element as any).type) {
31
- case 'checkbox':
32
- value = (element as any).checked
33
- break
34
- case 'number':
35
- value = Number((element as any).valueAsNumber)
36
- break
37
- case 'text':
38
- value = String((element as any).value)
39
- }
40
- break
41
-
42
- case 'PAPER-BUTTON':
43
- value = (element as any).active
44
- break
45
-
46
- case 'PAPER-LISTBOX':
47
- value = (element as any).selected
48
- break
49
-
50
- default:
51
- value = (element as any).value
52
- break
53
- }
54
-
55
- return value
56
- }
57
-
58
- _onAfterValueChange(key: string, value: any) {
59
- this.dispatchEvent(
60
- new CustomEvent('property-change', {
61
- bubbles: true,
62
- composed: true,
63
- detail: {
64
- [key]: value
65
- }
66
- })
67
- )
68
- }
69
- }