@things-factory/board-ui 4.0.13 → 4.0.14
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/client/index.js +0 -2
- package/client/pages/board-modeller-page.js +6 -75
- package/client/pages/board-player-page.js +1 -1
- package/client/pages/board-viewer-page.js +1 -1
- package/package.json +9 -9
- package/assets/images/icon-properties-ipattern.png +0 -0
- package/client/board-modeller/board-modeller.js +0 -229
- package/client/board-modeller/component-toolbar/component-menu.js +0 -153
- package/client/board-modeller/component-toolbar/component-toolbar.js +0 -193
- package/client/board-modeller/edit-toolbar-style.js +0 -228
- package/client/board-modeller/edit-toolbar.js +0 -637
- package/client/board-modeller/property-sidebar/abstract-property.js +0 -73
- package/client/board-modeller/property-sidebar/data-binding/data-binding-mapper.js +0 -366
- package/client/board-modeller/property-sidebar/data-binding/data-binding.js +0 -476
- package/client/board-modeller/property-sidebar/effects/effects-shared-style.js +0 -58
- package/client/board-modeller/property-sidebar/effects/effects.js +0 -64
- package/client/board-modeller/property-sidebar/effects/property-animation.js +0 -141
- package/client/board-modeller/property-sidebar/effects/property-animations.js +0 -92
- package/client/board-modeller/property-sidebar/effects/property-event-hover.js +0 -144
- package/client/board-modeller/property-sidebar/effects/property-event-tap.js +0 -146
- package/client/board-modeller/property-sidebar/effects/property-event.js +0 -72
- package/client/board-modeller/property-sidebar/effects/property-shadow.js +0 -122
- package/client/board-modeller/property-sidebar/effects/value-converter.js +0 -26
- package/client/board-modeller/property-sidebar/inspector/inspector.js +0 -338
- package/client/board-modeller/property-sidebar/property-shared-style.js +0 -132
- package/client/board-modeller/property-sidebar/property-sidebar.js +0 -324
- package/client/board-modeller/property-sidebar/shapes/box-padding-editor-styles.js +0 -94
- package/client/board-modeller/property-sidebar/shapes/shapes.js +0 -421
- package/client/board-modeller/property-sidebar/specifics/specific-properties-builder.js +0 -149
- package/client/board-modeller/property-sidebar/specifics/specifics.js +0 -248
- package/client/board-modeller/property-sidebar/styles/styles.js +0 -591
- package/client/board-modeller/scene-viewer/confidential-overlay.js +0 -18
- package/client/board-modeller/scene-viewer/things-scene-handler.js +0 -50
- package/client/board-modeller/scene-viewer/things-scene-layer.js +0 -52
- package/client/board-modeller/scene-viewer/things-scene-player.js +0 -115
- package/client/board-modeller/scene-viewer/things-scene-property.js +0 -25
- package/client/board-modeller/scene-viewer/things-scene-viewer.js +0 -312
package/client/index.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import '../board-modeller/board-modeller'
|
|
2
|
-
import '../board-modeller/edit-toolbar'
|
|
3
1
|
import './things-scene-components.import'
|
|
2
|
+
import '@operato/board/dist/src/ox-board-modeller.js'
|
|
4
3
|
|
|
5
|
-
import { PageView, client, store } from '@things-factory/shell'
|
|
4
|
+
import { PageView, client, gqlContext, store } from '@things-factory/shell'
|
|
6
5
|
import { css, html } from 'lit-element'
|
|
7
|
-
import { isMacOS, togglefullscreen } from '@things-factory/utils'
|
|
8
6
|
|
|
9
7
|
import { ADD_BOARD_COMPONENTS } from '../actions/board'
|
|
10
8
|
import { OxPropertyEditor } from '@operato/property-editor'
|
|
11
9
|
import components from './things-scene-components-with-tools.import'
|
|
12
10
|
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
13
11
|
import gql from 'graphql-tag'
|
|
14
|
-
import { gqlContext } from '@things-factory/shell'
|
|
15
12
|
import { provider } from '../board-provider'
|
|
16
|
-
import { saveAs } from 'file-saver'
|
|
17
13
|
|
|
18
14
|
const NOOP = () => {}
|
|
19
15
|
|
|
@@ -62,7 +58,6 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
62
58
|
baseUrl: String,
|
|
63
59
|
selected: Array,
|
|
64
60
|
mode: Number,
|
|
65
|
-
// provider: Object,
|
|
66
61
|
hideProperty: Boolean,
|
|
67
62
|
overlay: String,
|
|
68
63
|
scene: Object,
|
|
@@ -127,12 +122,8 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
get editToolbar() {
|
|
131
|
-
return this.renderRoot.querySelector('#edittoolbar')
|
|
132
|
-
}
|
|
133
|
-
|
|
134
125
|
get modeller() {
|
|
135
|
-
return this.renderRoot.querySelector('board-modeller')
|
|
126
|
+
return this.renderRoot.querySelector('ox-board-modeller')
|
|
136
127
|
}
|
|
137
128
|
|
|
138
129
|
async refresh() {
|
|
@@ -201,12 +192,10 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
201
192
|
pageUpdated(changes, lifecycle) {
|
|
202
193
|
if (this.active) {
|
|
203
194
|
this.boardId = lifecycle.resourceId
|
|
204
|
-
this.bindShortcutEvent()
|
|
205
195
|
} else {
|
|
206
196
|
this.boardId = null
|
|
207
197
|
this.model = null
|
|
208
|
-
this.modeller
|
|
209
|
-
this.unbindShortcutEvent()
|
|
198
|
+
this.modeller?.close()
|
|
210
199
|
}
|
|
211
200
|
}
|
|
212
201
|
|
|
@@ -230,20 +219,7 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
230
219
|
></oops-note>
|
|
231
220
|
`
|
|
232
221
|
: html`
|
|
233
|
-
<
|
|
234
|
-
id="edittoolbar"
|
|
235
|
-
.scene=${this.scene}
|
|
236
|
-
.board=${this.board}
|
|
237
|
-
.selected=${this.selected}
|
|
238
|
-
@hide-property-changed=${e => (this.hideProperty = e.detail.value)}
|
|
239
|
-
@open-preview=${e => this.onOpenPreview(e)}
|
|
240
|
-
@download-model=${e => this.onDownloadModel(e)}
|
|
241
|
-
@modeller-fullscreen=${e => this.onFullscreen(e)}
|
|
242
|
-
>
|
|
243
|
-
${this.renderBrandingZone()}
|
|
244
|
-
</edit-toolbar>
|
|
245
|
-
|
|
246
|
-
<board-modeller
|
|
222
|
+
<ox-board-modeller
|
|
247
223
|
.mode=${this.mode}
|
|
248
224
|
@mode-changed=${e => {
|
|
249
225
|
this.mode = e.detail.value
|
|
@@ -267,33 +243,13 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
267
243
|
.fonts=${this.fonts}
|
|
268
244
|
.hideProperty=${this.hideProperty}
|
|
269
245
|
>
|
|
270
|
-
</board-modeller>
|
|
246
|
+
</ox-board-modeller>
|
|
271
247
|
<oops-spinner ?show=${this._showSpinner}></oops-spinner>
|
|
272
248
|
`
|
|
273
249
|
|
|
274
250
|
return html``
|
|
275
251
|
}
|
|
276
252
|
|
|
277
|
-
renderBrandingZone() {
|
|
278
|
-
return html``
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
onOpenPreview() {
|
|
282
|
-
this.modeller.preview()
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
onDownloadModel() {
|
|
286
|
-
if (!this.scene) return
|
|
287
|
-
|
|
288
|
-
var model = JSON.stringify(this.model, null, 2)
|
|
289
|
-
var filename = (this.boardName || 'NONAME') + '-' + Date.now() + '.json'
|
|
290
|
-
saveAs(new Blob([model], { type: 'application/octet-stream' }), filename)
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
onFullscreen() {
|
|
294
|
-
togglefullscreen(this)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
253
|
async updateBoard() {
|
|
298
254
|
try {
|
|
299
255
|
this._showSpinner = true
|
|
@@ -344,31 +300,6 @@ export class BoardModellerPage extends connect(store)(PageView) {
|
|
|
344
300
|
async saveBoard() {
|
|
345
301
|
await this.updateBoard()
|
|
346
302
|
}
|
|
347
|
-
|
|
348
|
-
bindShortcutEvent() {
|
|
349
|
-
var isMac = isMacOS()
|
|
350
|
-
|
|
351
|
-
// TODO: Global Hotkey에 대한 정의를 edit-toolbar에서 가져올 수 있도록 수정해야 함.
|
|
352
|
-
const GLOBAL_HOTKEYS = ['Digit1', 'Digit2', 'F11', 'KeyD', 'KeyP', 'KeyS']
|
|
353
|
-
|
|
354
|
-
this._shortcutHandler = e => {
|
|
355
|
-
var tagName = e.composedPath()[0].tagName
|
|
356
|
-
var isInput = tagName.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA'
|
|
357
|
-
var isGlobalHotkey = GLOBAL_HOTKEYS.includes(e.code)
|
|
358
|
-
|
|
359
|
-
if (!isGlobalHotkey && isInput) return
|
|
360
|
-
if (!this.editToolbar.onShortcut(e, isMac)) this.modeller.onShortcut(e, isMac)
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
document.addEventListener('keydown', this._shortcutHandler)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
unbindShortcutEvent() {
|
|
367
|
-
if (this._shortcutHandler) {
|
|
368
|
-
document.removeEventListener('keydown', this._shortcutHandler)
|
|
369
|
-
delete this._shortcutHandler
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
303
|
}
|
|
373
304
|
|
|
374
305
|
customElements.define('board-modeller-page', BoardModellerPage)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/board-ui",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.14",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@material/mwc-list": "^0.25.3",
|
|
28
28
|
"@material/mwc-select": "^0.25.3",
|
|
29
|
-
"@operato/board": "^0.2.
|
|
30
|
-
"@operato/popup": "^0.2.
|
|
29
|
+
"@operato/board": "^0.2.46",
|
|
30
|
+
"@operato/popup": "^0.2.46",
|
|
31
31
|
"@polymer/iron-icon": "^3.0.1",
|
|
32
32
|
"@polymer/iron-icons": "^3.0.1",
|
|
33
33
|
"@polymer/paper-button": "^3.0.1",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"@polymer/paper-listbox": "^3.0.1",
|
|
38
38
|
"@polymer/paper-menu-button": "^3.0.1",
|
|
39
39
|
"@polymer/paper-slider": "^3.0.1",
|
|
40
|
-
"@things-factory/barcode-base": "^4.0.
|
|
41
|
-
"@things-factory/grist-ui": "^4.0.
|
|
42
|
-
"@things-factory/help": "^4.0.
|
|
43
|
-
"@things-factory/i18n-base": "^4.0.
|
|
44
|
-
"@things-factory/modeller-ui": "^4.0.
|
|
40
|
+
"@things-factory/barcode-base": "^4.0.14",
|
|
41
|
+
"@things-factory/grist-ui": "^4.0.14",
|
|
42
|
+
"@things-factory/help": "^4.0.14",
|
|
43
|
+
"@things-factory/i18n-base": "^4.0.14",
|
|
44
|
+
"@things-factory/modeller-ui": "^4.0.14",
|
|
45
45
|
"file-saver": "^2.0.2",
|
|
46
46
|
"sortablejs": "^1.10.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "956c782b5b2a6ff4c4e18f4a1bdcf778814f1b52"
|
|
49
49
|
}
|
|
Binary file
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import '@material/mwc-fab'
|
|
2
|
-
import '@operato/board' // ox-board-viewer
|
|
3
|
-
import './scene-viewer/things-scene-viewer'
|
|
4
|
-
import './component-toolbar/component-toolbar'
|
|
5
|
-
import './property-sidebar/property-sidebar'
|
|
6
|
-
|
|
7
|
-
import { LitElement, css, html } from 'lit-element'
|
|
8
|
-
|
|
9
|
-
import { OxPopup } from '@operato/popup'
|
|
10
|
-
|
|
11
|
-
export class BoardModeller extends LitElement {
|
|
12
|
-
constructor() {
|
|
13
|
-
super()
|
|
14
|
-
|
|
15
|
-
this.boardName = ''
|
|
16
|
-
this.model = null
|
|
17
|
-
this.baseUrl = ''
|
|
18
|
-
this.selected = []
|
|
19
|
-
this.mode = 1
|
|
20
|
-
this.provider = null
|
|
21
|
-
this.hideProperty = false
|
|
22
|
-
this.overlay = null
|
|
23
|
-
this.scene = null
|
|
24
|
-
this.componentGroupList = []
|
|
25
|
-
this.fonts = []
|
|
26
|
-
this.propertyEditor = []
|
|
27
|
-
|
|
28
|
-
document.addEventListener('get-all-scene-component-ids', e => {
|
|
29
|
-
var { component, callback } = e.detail
|
|
30
|
-
|
|
31
|
-
if (!this.scene) return
|
|
32
|
-
|
|
33
|
-
var ids
|
|
34
|
-
if (component) ids = this.scene.findAll(component).map(c => c.model.id)
|
|
35
|
-
else ids = this.scene.ids.map(({ key, value }) => key)
|
|
36
|
-
|
|
37
|
-
ids = ids.filter(id => !!id).sort()
|
|
38
|
-
callback(ids)
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static get properties() {
|
|
43
|
-
return {
|
|
44
|
-
boardName: String,
|
|
45
|
-
model: Object,
|
|
46
|
-
baseUrl: String,
|
|
47
|
-
selected: Array,
|
|
48
|
-
mode: Number,
|
|
49
|
-
provider: Object,
|
|
50
|
-
hideProperty: Boolean,
|
|
51
|
-
overlay: String,
|
|
52
|
-
scene: Object,
|
|
53
|
-
componentGroupList: Array,
|
|
54
|
-
fonts: Array,
|
|
55
|
-
propertyEditor: Array
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static get styles() {
|
|
60
|
-
return [
|
|
61
|
-
css`
|
|
62
|
-
:host {
|
|
63
|
-
display: flex;
|
|
64
|
-
flex-direction: row;
|
|
65
|
-
height: 100%;
|
|
66
|
-
overflow: hidden;
|
|
67
|
-
position: relative;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
#scene-wrap {
|
|
71
|
-
flex: 1;
|
|
72
|
-
position: relative;
|
|
73
|
-
|
|
74
|
-
display: flex;
|
|
75
|
-
flex-direction: row;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
things-scene-viewer {
|
|
79
|
-
flex: 1;
|
|
80
|
-
width: 100%;
|
|
81
|
-
height: 100%;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
mwc-fab {
|
|
85
|
-
position: absolute;
|
|
86
|
-
right: 15px;
|
|
87
|
-
bottom: 15px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
ox-popup {
|
|
91
|
-
width: 90%;
|
|
92
|
-
height: 90%;
|
|
93
|
-
left: 50%;
|
|
94
|
-
top: 50%;
|
|
95
|
-
transform: translateX(-50%) translateY(-50%);
|
|
96
|
-
background: var(--secondary-color, black);
|
|
97
|
-
|
|
98
|
-
display: flex;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
ox-board-viewer {
|
|
104
|
-
width: 98%;
|
|
105
|
-
height: 98%;
|
|
106
|
-
margin: auto;
|
|
107
|
-
padding: 0;
|
|
108
|
-
}
|
|
109
|
-
`
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
render() {
|
|
114
|
-
return html`
|
|
115
|
-
<component-toolbar
|
|
116
|
-
.scene=${this.scene}
|
|
117
|
-
.mode=${this.mode}
|
|
118
|
-
@mode-changed=${e => {
|
|
119
|
-
this.mode = e.detail.value
|
|
120
|
-
}}
|
|
121
|
-
.componentGroupList=${this.componentGroupList}
|
|
122
|
-
.group=${this.group}
|
|
123
|
-
>
|
|
124
|
-
</component-toolbar>
|
|
125
|
-
|
|
126
|
-
<div id="scene-wrap">
|
|
127
|
-
<things-scene-viewer
|
|
128
|
-
id="scene"
|
|
129
|
-
.scene=${this.scene}
|
|
130
|
-
@scene-changed=${e => {
|
|
131
|
-
this.scene = e.detail.value
|
|
132
|
-
}}
|
|
133
|
-
.model=${this.model}
|
|
134
|
-
.selected=${this.selected}
|
|
135
|
-
@selected-changed=${e => {
|
|
136
|
-
this.selected = e.detail.value
|
|
137
|
-
}}
|
|
138
|
-
.mode=${this.mode}
|
|
139
|
-
@mode-changed=${e => {
|
|
140
|
-
this.mode = e.detail.value
|
|
141
|
-
}}
|
|
142
|
-
fit="ratio"
|
|
143
|
-
.baseUrl=${this.baseUrl}
|
|
144
|
-
@contextmenu=${e => this.onContextMenu(e)}
|
|
145
|
-
.provider=${this.provider}
|
|
146
|
-
name="modeller"
|
|
147
|
-
>
|
|
148
|
-
<things-scene-layer type="selection-layer"></things-scene-layer>
|
|
149
|
-
<things-scene-layer type="modeling-layer"></things-scene-layer>
|
|
150
|
-
<things-scene-layer type="guide-layer">
|
|
151
|
-
<things-scene-property name="ruler" value="disabled"></things-scene-property>
|
|
152
|
-
</things-scene-layer>
|
|
153
|
-
<things-scene-layer type="shift-layer">
|
|
154
|
-
<things-scene-property name="text" value="${this.overlay}"></things-scene-property>
|
|
155
|
-
<things-scene-property name="alpha" value="0.3"></things-scene-property>
|
|
156
|
-
<things-scene-property name="fontFamily" value="arial"></things-scene-property>
|
|
157
|
-
<things-scene-property name="fontSize" value="30" type="number"></things-scene-property>
|
|
158
|
-
<things-scene-property name="fontColor" value="navy"></things-scene-property>
|
|
159
|
-
<things-scene-property name="textBaseline" value="top"></things-scene-property>
|
|
160
|
-
<things-scene-property name="textAlign" value="left"></things-scene-property>
|
|
161
|
-
<things-scene-property name="paddingTop" value="50" type="number"></things-scene-property>
|
|
162
|
-
<things-scene-property name="paddingLeft" value="50" type="number"></things-scene-property>
|
|
163
|
-
</things-scene-layer>
|
|
164
|
-
<things-scene-layer type="tag-layer"></things-scene-layer>
|
|
165
|
-
<things-scene-handler type="text-editor"></things-scene-handler>
|
|
166
|
-
<things-scene-handler type="move-handler"></things-scene-handler>
|
|
167
|
-
</things-scene-viewer>
|
|
168
|
-
|
|
169
|
-
<mwc-fab icon="save" @click=${e => this.onTapSave(e)} title="save"> </mwc-fab>
|
|
170
|
-
</div>
|
|
171
|
-
|
|
172
|
-
<property-sidebar
|
|
173
|
-
.scene=${this.scene}
|
|
174
|
-
.selected=${this.selected}
|
|
175
|
-
.collapsed=${this.hideProperty}
|
|
176
|
-
.fonts=${this.fonts}
|
|
177
|
-
.propertyEditor=${this.propertyEditor}
|
|
178
|
-
>
|
|
179
|
-
</property-sidebar>
|
|
180
|
-
`
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
close() {
|
|
184
|
-
this.model = null
|
|
185
|
-
this.requestUpdate()
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
get modellingContainer() {
|
|
189
|
-
return this.renderRoot.getElementById('scene-wrap')
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
onShortcut(e, MacOS) {
|
|
193
|
-
if (MacOS) var ctrlKey = e.metaKey
|
|
194
|
-
else var ctrlKey = e.ctrlKey
|
|
195
|
-
|
|
196
|
-
switch (e.code) {
|
|
197
|
-
case 'KeyS':
|
|
198
|
-
if (ctrlKey) {
|
|
199
|
-
this.onTapSave()
|
|
200
|
-
e.preventDefault()
|
|
201
|
-
}
|
|
202
|
-
break
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
preview() {
|
|
207
|
-
const board = {
|
|
208
|
-
id: 'preview',
|
|
209
|
-
model: this.scene?.model ? JSON.parse(JSON.stringify(this.scene.model)) : null
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
OxPopup.open({
|
|
213
|
-
template: html` <ox-board-viewer .provider=${this.provider} .board=${board}></ox-board-viewer> `,
|
|
214
|
-
parent: this.renderRoot
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
requestAnimationFrame(() => {
|
|
218
|
-
dispatchEvent(new Event('resize'))
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
onTapSave() {
|
|
223
|
-
this.dispatchEvent(new CustomEvent('save-model', { bubbles: true, composed: true, detail: { model: this.model } }))
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
onContextMenu() {}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
customElements.define('board-modeller', BoardModeller)
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { LitElement, html, css } from 'lit-element'
|
|
6
|
-
|
|
7
|
-
import { deepClone } from '@things-factory/utils'
|
|
8
|
-
import { ScrollbarStyles } from '@things-factory/styles'
|
|
9
|
-
|
|
10
|
-
import noImage from '../../../assets/images/components/no-image.png'
|
|
11
|
-
|
|
12
|
-
class ComponentMenu extends LitElement {
|
|
13
|
-
static get styles() {
|
|
14
|
-
return [
|
|
15
|
-
ScrollbarStyles,
|
|
16
|
-
css`
|
|
17
|
-
:host {
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
align-content: stretch;
|
|
21
|
-
|
|
22
|
-
background-color: var(--component-menu-background-color);
|
|
23
|
-
margin: 0px;
|
|
24
|
-
padding: 0px;
|
|
25
|
-
|
|
26
|
-
width: 180px;
|
|
27
|
-
height: 100%;
|
|
28
|
-
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
|
|
31
|
-
border: 2px solid var(--component-menu-border-color);
|
|
32
|
-
box-sizing: border-box;
|
|
33
|
-
|
|
34
|
-
position: absolute;
|
|
35
|
-
top: 0px;
|
|
36
|
-
|
|
37
|
-
z-index: 1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
h2 {
|
|
41
|
-
background-color: var(--component-menu-border-color);
|
|
42
|
-
padding: 1px 5px;
|
|
43
|
-
margin: 0;
|
|
44
|
-
font: var(--component-menu-title);
|
|
45
|
-
color: #fff;
|
|
46
|
-
text-transform: capitalize;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
[templates] {
|
|
50
|
-
flex: 1;
|
|
51
|
-
|
|
52
|
-
display: block;
|
|
53
|
-
margin: 0;
|
|
54
|
-
padding: 0;
|
|
55
|
-
overflow-y: auto;
|
|
56
|
-
|
|
57
|
-
background-color: var(--component-menu-background-color);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[template] {
|
|
61
|
-
display: flex;
|
|
62
|
-
align-items: center;
|
|
63
|
-
min-height: var(--component-menu-item-icon-size);
|
|
64
|
-
padding: 0 5px 0 0;
|
|
65
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
66
|
-
font-size: 11px;
|
|
67
|
-
color: var(--component-menu-item-color);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
[template]:hover,
|
|
71
|
-
[template]:focus {
|
|
72
|
-
color: var(--component-menu-item-hover-color);
|
|
73
|
-
font-weight: bold;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
[template] img {
|
|
78
|
-
margin: 5px;
|
|
79
|
-
width: var(--component-menu-item-icon-size);
|
|
80
|
-
height: var(--component-menu-item-icon-size);
|
|
81
|
-
}
|
|
82
|
-
`
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static get properties() {
|
|
87
|
-
return {
|
|
88
|
-
groups: Object,
|
|
89
|
-
scene: Object,
|
|
90
|
-
group: String,
|
|
91
|
-
templates: Array
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
render() {
|
|
96
|
-
return this.group
|
|
97
|
-
? html`
|
|
98
|
-
<h2 onclick=${e => e.stopPropagation()}>${this.group} list</h2>
|
|
99
|
-
|
|
100
|
-
<div templates>
|
|
101
|
-
${(this.templates || []).map(
|
|
102
|
-
template => html`
|
|
103
|
-
<div @click=${this.onClickTemplate} data-type=${template.type} template>
|
|
104
|
-
<img src=${this.templateIcon(template)} />${template.type}
|
|
105
|
-
</div>
|
|
106
|
-
`
|
|
107
|
-
)}
|
|
108
|
-
</div>
|
|
109
|
-
`
|
|
110
|
-
: html``
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
updated(changes) {
|
|
114
|
-
if (changes.has('group')) {
|
|
115
|
-
if (!this.group) {
|
|
116
|
-
this.style.display = 'none'
|
|
117
|
-
this.templates = []
|
|
118
|
-
} else {
|
|
119
|
-
this.style.display = 'flex'
|
|
120
|
-
this.templates = this.groups.find(g => g.name === this.group).templates
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onClickTemplate(e) {
|
|
126
|
-
var item = e.target
|
|
127
|
-
|
|
128
|
-
while (!(item !== this) || !item || !item.hasAttribute || !item.hasAttribute('data-type')) {
|
|
129
|
-
item = item.parentElement
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
var type = item.getAttribute('data-type')
|
|
133
|
-
|
|
134
|
-
if (!type) {
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var group = this.groups.find(g => g.name == this.group)
|
|
139
|
-
|
|
140
|
-
if (this.scene && group) {
|
|
141
|
-
var template = group.templates.find(template => template.type == type)
|
|
142
|
-
template && this.scene.add(deepClone(template.model), { cx: 200, cy: 200 })
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.group = null
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
templateIcon(template) {
|
|
149
|
-
return template.icon || noImage
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
customElements.define('component-menu', ComponentMenu)
|