@things-factory/board-ui 4.0.13 → 4.0.18
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
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@things-factory/i18n-base'
|
|
6
|
-
import { css, html } from 'lit-element'
|
|
7
|
-
import '@things-factory/modeller-ui/client/editors/things-editor-angle-input'
|
|
8
|
-
import '@things-factory/modeller-ui/client/editors/things-editor-buttons-radio'
|
|
9
|
-
import { AbstractProperty } from '../abstract-property'
|
|
10
|
-
import { PropertySharedStyle } from '../property-shared-style'
|
|
11
|
-
import { BoxPaddingEditorStyles } from './box-padding-editor-styles'
|
|
12
|
-
import '@material/mwc-icon'
|
|
13
|
-
|
|
14
|
-
class PropertyShapes extends AbstractProperty {
|
|
15
|
-
static get is() {
|
|
16
|
-
return 'property-shape'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static get properties() {
|
|
20
|
-
return {
|
|
21
|
-
value: Object,
|
|
22
|
-
bounds: Object,
|
|
23
|
-
selected: Array,
|
|
24
|
-
_3dExpanded: Boolean
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return [
|
|
30
|
-
PropertySharedStyle,
|
|
31
|
-
BoxPaddingEditorStyles,
|
|
32
|
-
css`
|
|
33
|
-
fieldset[collapsable] legend {
|
|
34
|
-
box-sizing: border-box;
|
|
35
|
-
width: 100%;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
fieldset[collapsable] legend mwc-icon {
|
|
39
|
-
float: right;
|
|
40
|
-
font-size: medium;
|
|
41
|
-
margin: 0;
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
fieldset[collapsable][collapsed] > :not(legend) {
|
|
46
|
-
display: none;
|
|
47
|
-
}
|
|
48
|
-
`,
|
|
49
|
-
css`
|
|
50
|
-
.icon-label label {
|
|
51
|
-
background: url(/assets/images/icon-properties-label.png) 7px -900px no-repeat;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.icon-label label.width {
|
|
55
|
-
background-position: 7px -96px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.icon-label label.height {
|
|
59
|
-
background-position: 7px 4px;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.icon-label label.rotate {
|
|
63
|
-
background-position: 7px -198px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.icon-label label.twidth {
|
|
67
|
-
background-position: 7px -296px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.icon-label label.theight {
|
|
71
|
-
background-position: 7px -396px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.icon-label label.zPos {
|
|
75
|
-
background-position: 5px -1098px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.icon-label label.depth {
|
|
79
|
-
background-position: 5px -1198px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.icon-label label.rotationX {
|
|
83
|
-
background-position: 5px -1296px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.icon-label label.rotationY {
|
|
87
|
-
background-position: 5px -1396px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.icon-label label.rotationZ {
|
|
91
|
-
background-position: 5px -1496px;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
things-editor-buttons-radio > * {
|
|
95
|
-
width: 30px;
|
|
96
|
-
height: 25px;
|
|
97
|
-
min-width: initial;
|
|
98
|
-
margin: 0 4px 0 0;
|
|
99
|
-
padding: 0;
|
|
100
|
-
border-radius: 0;
|
|
101
|
-
display: inline-block;
|
|
102
|
-
border-bottom: 2px solid #fff;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
things-editor-buttons-radio div {
|
|
106
|
-
background: url(/assets/images/icon-properties.png) no-repeat;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
things-editor-buttons-radio div[data-value='left'] {
|
|
110
|
-
background-position: 50% 3px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
things-editor-buttons-radio div[data-value='center'] {
|
|
114
|
-
background-position: 50% -47px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
things-editor-buttons-radio div[data-value='right'] {
|
|
118
|
-
background-position: 50% -97px;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
things-editor-buttons-radio div[data-value='justify'] {
|
|
122
|
-
background-position: 50% -147px;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
things-editor-buttons-radio div[data-value='top'] {
|
|
126
|
-
background-position: 50% -197px;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
things-editor-buttons-radio div[data-value='middle'] {
|
|
130
|
-
background-position: 50% -193px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
things-editor-buttons-radio div[data-value='bottom'] {
|
|
134
|
-
background-position: 50% -188px;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
things-editor-buttons-radio div[active] {
|
|
138
|
-
border-color: #f2471c;
|
|
139
|
-
}
|
|
140
|
-
`
|
|
141
|
-
]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
constructor() {
|
|
145
|
-
super()
|
|
146
|
-
|
|
147
|
-
this.value = {}
|
|
148
|
-
this.bounds = {}
|
|
149
|
-
this.selected = []
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
firstUpdated() {
|
|
153
|
-
this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
render() {
|
|
157
|
-
return html`
|
|
158
|
-
<fieldset>
|
|
159
|
-
<div class="property-grid">
|
|
160
|
-
${this._isIdentifiable(this.selected)
|
|
161
|
-
? html`
|
|
162
|
-
<label> <i18n-msg msgid="label.id">ID</i18n-msg> </label>
|
|
163
|
-
<input value-key="id" .value=${this.value.id || ''} />
|
|
164
|
-
`
|
|
165
|
-
: html``}
|
|
166
|
-
${this._isClassIdentifiable(this.selected)
|
|
167
|
-
? html`
|
|
168
|
-
<label> <i18n-msg msgid="label.class">Class</i18n-msg> </label>
|
|
169
|
-
<input value-key="class" .value=${this.value.class || ''} />
|
|
170
|
-
`
|
|
171
|
-
: html``}
|
|
172
|
-
${this._hasTextProperty(this.selected)
|
|
173
|
-
? html`
|
|
174
|
-
<label> <i18n-msg msgid="label.text">Text</i18n-msg> </label>
|
|
175
|
-
<input value-key="text" .value=${this.value.text || ''} />
|
|
176
|
-
<label> <i18n-msg msgid="label.text-format">Text Format</i18n-msg> </label>
|
|
177
|
-
<input value-key="textFormat" .value=${this.value.textFormat || ''} list="format-list" />
|
|
178
|
-
<datalist id="format-list">
|
|
179
|
-
<option value="#,###."></option>
|
|
180
|
-
<option value="#,###.#"></option>
|
|
181
|
-
<option value="#,###.0"></option>
|
|
182
|
-
<option value="#,##0.#"></option>
|
|
183
|
-
<option value="#,##0.0"></option>
|
|
184
|
-
<option value="#,##0.0%"></option>
|
|
185
|
-
</datalist>
|
|
186
|
-
`
|
|
187
|
-
: html``}
|
|
188
|
-
${this._hasProperties(this.selected)
|
|
189
|
-
? html`
|
|
190
|
-
<div class="checkbox-row">
|
|
191
|
-
<input id="checkbox-hidden" value-key="hidden" type="checkbox" .checked=${this.value.hidden} />
|
|
192
|
-
<label for="checkbox-hidden"> <i18n-msg msgid="label.item-hidden">Item Hidden</i18n-msg> </label>
|
|
193
|
-
|
|
194
|
-
<input id="checkbox-locked" value-key="locked" type="checkbox" .checked=${this.value.locked} />
|
|
195
|
-
<label for="checkbox-locked"> <i18n-msg msgid="label.locked">Locked</i18n-msg> </label>
|
|
196
|
-
</div>
|
|
197
|
-
`
|
|
198
|
-
: html``}
|
|
199
|
-
</div>
|
|
200
|
-
</fieldset>
|
|
201
|
-
|
|
202
|
-
${!this._isLine(this.selected)
|
|
203
|
-
? html`
|
|
204
|
-
<fieldset class="icon-label unit ratio">
|
|
205
|
-
<legend>
|
|
206
|
-
<title-with-help topic="board-modeller/shapes/size" msgid="label.size">size</title-with-help>
|
|
207
|
-
</legend>
|
|
208
|
-
|
|
209
|
-
<div class="property-grid">
|
|
210
|
-
<label class="width"> <i18n-msg msgid="label.width">width</i18n-msg> </label>
|
|
211
|
-
<input type="number" value-key="bounds.width" .value=${this.bounds.width} />
|
|
212
|
-
<label class="height"> <i18n-msg msgid="label.height">height</i18n-msg> </label>
|
|
213
|
-
<input type="number" value-key="bounds.height" .value=${this.bounds.height} />
|
|
214
|
-
|
|
215
|
-
${this.selected.length && this.selected[0].isRootModel()
|
|
216
|
-
? html``
|
|
217
|
-
: html`
|
|
218
|
-
<label class="rotate"> <i18n-msg msgid="label.rotate">rotate</i18n-msg> </label>
|
|
219
|
-
<things-editor-angle-input value-key="rotation" .radian=${this.value.rotation}>
|
|
220
|
-
</things-editor-angle-input>
|
|
221
|
-
`}
|
|
222
|
-
</div>
|
|
223
|
-
</fieldset>
|
|
224
|
-
`
|
|
225
|
-
: html``}
|
|
226
|
-
${this._is3dish(this.selected)
|
|
227
|
-
? html`
|
|
228
|
-
<fieldset class="icon-label unit ratio" collapsable ?collapsed=${!this._3dExpanded}>
|
|
229
|
-
<legend>
|
|
230
|
-
<title-with-help topic="board-modeller/shapes/3dish" msgid="label.3dish">3D</title-with-help>
|
|
231
|
-
<mwc-icon
|
|
232
|
-
@click=${e => {
|
|
233
|
-
this._3dExpanded = !this._3dExpanded
|
|
234
|
-
}}
|
|
235
|
-
>${this._3dExpanded ? 'expand_less' : 'expand_more'}</mwc-icon
|
|
236
|
-
>
|
|
237
|
-
</legend>
|
|
238
|
-
|
|
239
|
-
<div class="property-grid">
|
|
240
|
-
<label class="zPos"> <i18n-msg msgid="label.z-pos">pos. Z</i18n-msg> </label>
|
|
241
|
-
<input type="number" value-key="zPos" .value=${this.value.zPos} />
|
|
242
|
-
<label class="depth"> <i18n-msg msgid="label.depth">depth</i18n-msg> </label>
|
|
243
|
-
<input type="number" value-key="depth" .value=${this.value.depth} />
|
|
244
|
-
|
|
245
|
-
<label class="rotationX"> <i18n-msg msgid="label.rotation-x">rot. X</i18n-msg> </label>
|
|
246
|
-
<things-editor-angle-input value-key="rotationX" .radian=${this.value.rotationX}>
|
|
247
|
-
</things-editor-angle-input>
|
|
248
|
-
|
|
249
|
-
<label class="rotationY"> <i18n-msg msgid="label.rotation-y">rot. Y</i18n-msg> </label>
|
|
250
|
-
<things-editor-angle-input value-key="rotationY" .radian=${this.value.rotationY}>
|
|
251
|
-
</things-editor-angle-input>
|
|
252
|
-
|
|
253
|
-
<label class="rotationZ"> <i18n-msg msgid="label.rotation-z">rot. Z</i18n-msg> </label>
|
|
254
|
-
<things-editor-angle-input value-key="rotation" .radian=${this.value.rotation}>
|
|
255
|
-
</things-editor-angle-input>
|
|
256
|
-
</div>
|
|
257
|
-
</fieldset>
|
|
258
|
-
`
|
|
259
|
-
: html``}
|
|
260
|
-
${this._hasTextProperty(this.selected)
|
|
261
|
-
? html`
|
|
262
|
-
<fieldset>
|
|
263
|
-
<legend>
|
|
264
|
-
<title-with-help topic="board-modeller/shapes/text-box" msgid="label.text-box">text box</title-with-help>
|
|
265
|
-
</legend>
|
|
266
|
-
|
|
267
|
-
<div class="property-grid">
|
|
268
|
-
<label> <i18n-msg msgid="label.horizontal">horizontal</i18n-msg> </label>
|
|
269
|
-
<things-editor-buttons-radio value-key="textAlign" .value=${this.value.textAlign}>
|
|
270
|
-
<div data-value="left"></div>
|
|
271
|
-
<div data-value="center"></div>
|
|
272
|
-
<div data-value="right"></div>
|
|
273
|
-
<div data-value="justify"></div>
|
|
274
|
-
</things-editor-buttons-radio>
|
|
275
|
-
|
|
276
|
-
<label> <i18n-msg msgid="label.vertical">vertical</i18n-msg> </label>
|
|
277
|
-
<things-editor-buttons-radio value-key="textBaseline" .value=${this.value.textBaseline}>
|
|
278
|
-
<div data-value="top"></div>
|
|
279
|
-
<div data-value="middle"></div>
|
|
280
|
-
<div data-value="bottom"></div>
|
|
281
|
-
</things-editor-buttons-radio>
|
|
282
|
-
|
|
283
|
-
<div class="checkbox-row">
|
|
284
|
-
<input id="checkbox-textwrap" type="checkbox" value-key="textWrap" .checked=${this.value.textWrap} />
|
|
285
|
-
<label for="checkbox-textwrap"> <i18n-msg msgid="label.text-wrap">Text Wrap</i18n-msg> </label>
|
|
286
|
-
</div>
|
|
287
|
-
|
|
288
|
-
<label> <i18n-msg msgid="label.padding">padding</i18n-msg> </label>
|
|
289
|
-
<table class="box-padding">
|
|
290
|
-
<tr>
|
|
291
|
-
<td class="slide1"></td>
|
|
292
|
-
<td class="slide2"></td>
|
|
293
|
-
<td class="slide3"></td>
|
|
294
|
-
</tr>
|
|
295
|
-
<tr>
|
|
296
|
-
<td class="slide4"></td>
|
|
297
|
-
<td class="slide5">
|
|
298
|
-
<input type="number" value-key="paddingTop" .value=${this.value.paddingTop} />
|
|
299
|
-
<input type="number" value-key="paddingLeft" .value=${this.value.paddingLeft} />
|
|
300
|
-
<input type="number" value-key="paddingRight" .value=${this.value.paddingRight} />
|
|
301
|
-
<input type="number" value-key="paddingBottom" .value=${this.value.paddingBottom} />
|
|
302
|
-
</td>
|
|
303
|
-
<td class="slide6"></td>
|
|
304
|
-
</tr>
|
|
305
|
-
<tr>
|
|
306
|
-
<td class="slide7"></td>
|
|
307
|
-
<td class="slide8"></td>
|
|
308
|
-
<td class="slide9"></td>
|
|
309
|
-
</tr>
|
|
310
|
-
</table>
|
|
311
|
-
</div>
|
|
312
|
-
</fieldset>
|
|
313
|
-
`
|
|
314
|
-
: html``}
|
|
315
|
-
${this.selected.length && this.selected[0].isRootModel()
|
|
316
|
-
? html`
|
|
317
|
-
<fieldset class="icon-label">
|
|
318
|
-
<legend>
|
|
319
|
-
<title-with-help topic="board-modeller/shapes/viewer-option" msgid="label.viewer-option">Viewer Option</title-with-help>
|
|
320
|
-
</legend>
|
|
321
|
-
|
|
322
|
-
<div class="property-grid">
|
|
323
|
-
<label><i18n-msg msgid="label.fit">Fit</i18n-msg></label>
|
|
324
|
-
<select value-key="fitMode" .value=${this.value.fitMode || 'ratio'}>
|
|
325
|
-
<option value="none">none</option>
|
|
326
|
-
<option value="ratio" selected>ratio</option>
|
|
327
|
-
<option value="both">both</option>
|
|
328
|
-
<option value="width">width</option>
|
|
329
|
-
<option value="height">height</option>
|
|
330
|
-
</select>
|
|
331
|
-
</things-editor-angle-input>
|
|
332
|
-
</div>
|
|
333
|
-
</fieldset>
|
|
334
|
-
<fieldset class="icon-label">
|
|
335
|
-
<legend>
|
|
336
|
-
<title-with-help topic="board-modeller/shapes/print-option" msgid="label.label-print">Print Option</title-with-help>
|
|
337
|
-
</legend>
|
|
338
|
-
|
|
339
|
-
<div class="property-grid">
|
|
340
|
-
<label class="rotate"><i18n-msg msgid="label.label-rotation">Label Rotation</i18n-msg></label>
|
|
341
|
-
<select value-key="labelRotation" .value=${this.value.labelRotation || 'N'}>
|
|
342
|
-
<option value="N" selected>0°</option>
|
|
343
|
-
<option value="B">90°</option>
|
|
344
|
-
<option value="I">180°</option>
|
|
345
|
-
<option value="R">270°</option>
|
|
346
|
-
</select>
|
|
347
|
-
</things-editor-angle-input>
|
|
348
|
-
</div>
|
|
349
|
-
</fieldset>
|
|
350
|
-
`
|
|
351
|
-
: html``}
|
|
352
|
-
`
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
_onValueChange(e) {
|
|
356
|
-
var element = e.target
|
|
357
|
-
var key = element.getAttribute('value-key')
|
|
358
|
-
|
|
359
|
-
if (!key) {
|
|
360
|
-
return
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
var value = this._getValueFromEventTarget(element)
|
|
364
|
-
|
|
365
|
-
if (key.indexOf('bounds.') == 0) {
|
|
366
|
-
if (isNaN(value)) return
|
|
367
|
-
this.dispatchEvent(
|
|
368
|
-
new CustomEvent('bounds-change', {
|
|
369
|
-
bubbles: true,
|
|
370
|
-
composed: true,
|
|
371
|
-
detail: {
|
|
372
|
-
[key.substr(7)]: value
|
|
373
|
-
}
|
|
374
|
-
})
|
|
375
|
-
)
|
|
376
|
-
} else {
|
|
377
|
-
this._onAfterValueChange(key, value)
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
_hasTextProperty(selected) {
|
|
382
|
-
for (let i = 0; i < selected.length; i++) {
|
|
383
|
-
if (!selected[i].hasTextProperty) return false
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return true
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
_hasProperties(selected) {
|
|
390
|
-
if (!selected || selected.length == 0 || (selected[0] && selected[0].isLayer && selected[0].isLayer())) return false
|
|
391
|
-
|
|
392
|
-
return true
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
_isIdentifiable(selected) {
|
|
396
|
-
if (!selected || selected.length == 0 || selected.length > 1 || (selected[0].isLayer && selected[0].isLayer()))
|
|
397
|
-
return false
|
|
398
|
-
|
|
399
|
-
return true
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
_isClassIdentifiable(selected) {
|
|
403
|
-
if (!selected || (selected[0] && selected[0].isLayer && selected[0].isLayer())) return false
|
|
404
|
-
|
|
405
|
-
return true
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
_isLine(selected) {
|
|
409
|
-
if (!selected || !(selected[0] && selected[0].isLine && selected[0].isLine())) return false
|
|
410
|
-
|
|
411
|
-
return true
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
_is3dish(selected) {
|
|
415
|
-
if (!selected || !(selected[0] && selected[0].is3dish && selected[0].is3dish())) return false
|
|
416
|
-
|
|
417
|
-
return true
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
customElements.define(PropertyShapes.is, PropertyShapes)
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@things-factory/modeller-ui/client/editors/things-editor-property'
|
|
6
|
-
|
|
7
|
-
import { LitElement } from 'lit-element'
|
|
8
|
-
import { OxPropertyEditor } from '@operato/property-editor'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
|
|
12
|
-
|
|
13
|
-
Example:
|
|
14
|
-
|
|
15
|
-
<specific-properties-builder value="{{value}}">
|
|
16
|
-
<label>Center X</label>
|
|
17
|
-
<input type="number" .value="${value.cx}">
|
|
18
|
-
<label>Width</label>
|
|
19
|
-
<input type="number" .value="${value.width}">
|
|
20
|
-
</specific-properties-builder>
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const DEFAULT_VALUE = {
|
|
24
|
-
legend: '',
|
|
25
|
-
number: 0,
|
|
26
|
-
angle: 0,
|
|
27
|
-
string: '',
|
|
28
|
-
password: '',
|
|
29
|
-
textarea: '',
|
|
30
|
-
checkbox: false,
|
|
31
|
-
select: '',
|
|
32
|
-
color: '#000000',
|
|
33
|
-
'solidcolor-stops': null,
|
|
34
|
-
'gradientcolor-stops': null,
|
|
35
|
-
'gltf-selector': '',
|
|
36
|
-
'image-selector': '',
|
|
37
|
-
multiplecolor: null,
|
|
38
|
-
editortable: null,
|
|
39
|
-
imageselector: '',
|
|
40
|
-
options: null,
|
|
41
|
-
date: null
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function convertValue(type, value) {
|
|
45
|
-
var converted = String(value).trim() == '' ? undefined : value
|
|
46
|
-
switch (type) {
|
|
47
|
-
case 'number':
|
|
48
|
-
case 'angle':
|
|
49
|
-
converted = parseFloat(value)
|
|
50
|
-
converted = converted == NaN ? undefined : converted
|
|
51
|
-
break
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return converted
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class SpecificPropertiesBuilder extends LitElement {
|
|
58
|
-
static get is() {
|
|
59
|
-
return 'specific-properties-builder'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static get properties() {
|
|
63
|
-
return {
|
|
64
|
-
value: Object,
|
|
65
|
-
props: Array,
|
|
66
|
-
propertyEditor: Object
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
constructor() {
|
|
71
|
-
super()
|
|
72
|
-
|
|
73
|
-
this.props = []
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
firstUpdated() {
|
|
77
|
-
this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
updated(change) {
|
|
81
|
-
change.has('props') && this._onPropsChanged(this.props)
|
|
82
|
-
change.has('value') && this._setValues()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_onPropsChanged(props) {
|
|
86
|
-
this.renderRoot.textContent = ''
|
|
87
|
-
;(props || []).forEach(prop => {
|
|
88
|
-
let elementType = OxPropertyEditor.getEditor(prop.type)
|
|
89
|
-
if (!elementType) {
|
|
90
|
-
console.warn('Property Editor not defined', prop.type)
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
let element = document.createElement(elementType)
|
|
94
|
-
|
|
95
|
-
element.label = prop.label
|
|
96
|
-
element.type = prop.type
|
|
97
|
-
element.placeholder = prop.placeholder
|
|
98
|
-
element.setAttribute('name', prop.name)
|
|
99
|
-
|
|
100
|
-
if (prop.observe) {
|
|
101
|
-
element.observe = prop.observe
|
|
102
|
-
}
|
|
103
|
-
element.property = prop.property
|
|
104
|
-
element.setAttribute('property-editor', true)
|
|
105
|
-
|
|
106
|
-
this.renderRoot.appendChild(element)
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
_setValues() {
|
|
111
|
-
this.value &&
|
|
112
|
-
Array.from(this.renderRoot.querySelectorAll('[name]')).forEach(prop => {
|
|
113
|
-
let name = prop.getAttribute('name')
|
|
114
|
-
var convertedValue = convertValue(prop.type, this.value[name])
|
|
115
|
-
if (convertedValue == undefined) convertedValue = DEFAULT_VALUE[prop.type]
|
|
116
|
-
prop.value = convertedValue
|
|
117
|
-
prop.observe && prop.observe.call(prop, prop.value)
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
_onValueChanged(e) {
|
|
122
|
-
e.stopPropagation()
|
|
123
|
-
var prop = e.target
|
|
124
|
-
|
|
125
|
-
while (prop && !prop.hasAttribute('property-editor')) {
|
|
126
|
-
prop = prop.parentNode
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!prop || !prop.hasAttribute('property-editor')) {
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
var name = prop.getAttribute('name')
|
|
134
|
-
this.value[name] = prop.value
|
|
135
|
-
this._setValues()
|
|
136
|
-
|
|
137
|
-
this.dispatchEvent(
|
|
138
|
-
new CustomEvent('property-change', {
|
|
139
|
-
bubbles: true,
|
|
140
|
-
composed: true,
|
|
141
|
-
detail: {
|
|
142
|
-
[name]: prop.value
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
customElements.define(SpecificPropertiesBuilder.is, SpecificPropertiesBuilder)
|