@operato/property-panel 9.2.0 → 10.0.0-beta.1
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/CHANGELOG.md +8 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-property-panel.d.ts +8 -0
- package/dist/src/ox-property-panel.js +44 -3
- package/dist/src/ox-property-panel.js.map +1 -1
- package/dist/src/property-panel/abstract-property.js +1 -0
- package/dist/src/property-panel/abstract-property.js.map +1 -1
- package/dist/src/property-panel/data-binding/data-binding-mapper.js +1 -1
- package/dist/src/property-panel/data-binding/data-binding-mapper.js.map +1 -1
- package/dist/src/property-panel/data-binding/data-binding.js.map +1 -1
- package/dist/src/property-panel/effects/property-animation.js +1 -1
- package/dist/src/property-panel/effects/property-animation.js.map +1 -1
- package/dist/src/property-panel/effects/property-event-hover.d.ts +1 -1
- package/dist/src/property-panel/effects/property-event-hover.js +3 -3
- package/dist/src/property-panel/effects/property-event-hover.js.map +1 -1
- package/dist/src/property-panel/effects/property-event-tap.js +4 -4
- package/dist/src/property-panel/effects/property-event-tap.js.map +1 -1
- package/dist/src/property-panel/inspector/inspector.js +6 -6
- package/dist/src/property-panel/inspector/inspector.js.map +1 -1
- package/dist/src/property-panel/shapes/shapes.d.ts +0 -2
- package/dist/src/property-panel/shapes/shapes.js +5 -44
- package/dist/src/property-panel/shapes/shapes.js.map +1 -1
- package/dist/src/property-panel/threed/property-material3d.d.ts +27 -0
- package/dist/src/property-panel/threed/property-material3d.js +189 -0
- package/dist/src/property-panel/threed/property-material3d.js.map +1 -0
- package/dist/src/property-panel/threed/property-scene3d.d.ts +26 -0
- package/dist/src/property-panel/threed/property-scene3d.js +314 -0
- package/dist/src/property-panel/threed/property-scene3d.js.map +1 -0
- package/dist/src/property-panel/threed/threed.d.ts +17 -0
- package/dist/src/property-panel/threed/threed.js +98 -0
- package/dist/src/property-panel/threed/threed.js.map +1 -0
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -9
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -5
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/index.html +0 -30
- package/dist/stories/index.stories.d.ts +0 -22
- package/dist/stories/index.stories.js +0 -121
- package/dist/stories/index.stories.js.map +0 -1
- package/src/graphql/board.ts +0 -144
- package/src/graphql/data-subscription.ts +0 -30
- package/src/graphql/favorite-board.ts +0 -25
- package/src/graphql/group.ts +0 -138
- package/src/graphql/index.ts +0 -4
- package/src/graphql/play-group.ts +0 -225
- package/src/graphql/scenario.ts +0 -79
- package/src/index.ts +0 -8
- package/src/ox-property-panel.ts +0 -347
- package/src/property-panel/abstract-property.ts +0 -65
- package/src/property-panel/data-binding/data-binding-mapper.ts +0 -408
- package/src/property-panel/data-binding/data-binding-value-map.ts +0 -19
- package/src/property-panel/data-binding/data-binding-value-range.ts +0 -19
- package/src/property-panel/data-binding/data-binding.ts +0 -470
- package/src/property-panel/effects/effects.ts +0 -77
- package/src/property-panel/effects/property-animation.ts +0 -155
- package/src/property-panel/effects/property-animations.ts +0 -73
- package/src/property-panel/effects/property-event-hover-emphasize.ts +0 -74
- package/src/property-panel/effects/property-event-hover.ts +0 -255
- package/src/property-panel/effects/property-event-tap.ts +0 -269
- package/src/property-panel/effects/property-event.ts +0 -73
- package/src/property-panel/effects/property-shadow.ts +0 -77
- package/src/property-panel/effects/value-converter.ts +0 -17
- package/src/property-panel/inspector/inspector.ts +0 -376
- package/src/property-panel/shapes/shapes.ts +0 -379
- package/src/property-panel/specifics/specific-properties-builder.ts +0 -160
- package/src/property-panel/specifics/specifics.ts +0 -81
- package/src/property-panel/styles/styles.ts +0 -285
- package/src/types.ts +0 -63
- package/stories/index.stories.ts +0 -134
- package/tsconfig.json +0 -26
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@operato/input/ox-input-angle.js'
|
|
6
|
-
import '@operato/input/ox-buttons-radio.js'
|
|
7
|
-
import '@material/web/icon/icon.js'
|
|
8
|
-
import '@operato/i18n/ox-i18n.js'
|
|
9
|
-
import '@operato/help/ox-title-with-help.js'
|
|
10
|
-
|
|
11
|
-
import { css, html } from 'lit'
|
|
12
|
-
import { property, state } from 'lit/decorators.js'
|
|
13
|
-
import { keyed } from 'lit/directives/keyed.js'
|
|
14
|
-
|
|
15
|
-
import { BOUNDS, Component, Properties } from '@hatiolab/things-scene'
|
|
16
|
-
import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
|
|
17
|
-
import { BoxPaddingEditorStyles } from '@operato/styles/box-padding-editor-styles.js'
|
|
18
|
-
|
|
19
|
-
import { AbstractProperty } from '../abstract-property.js'
|
|
20
|
-
|
|
21
|
-
export class PropertyShapes extends AbstractProperty {
|
|
22
|
-
static styles = [PropertyGridStyles, BoxPaddingEditorStyles]
|
|
23
|
-
|
|
24
|
-
@property({ type: Object }) value?: Properties
|
|
25
|
-
@property({ type: Object }) bounds: BOUNDS | null = null
|
|
26
|
-
@property({ type: Array }) selected: Component[] = []
|
|
27
|
-
|
|
28
|
-
@state() private _3dExpanded: boolean = false
|
|
29
|
-
@state() private _positionExpanded: boolean = false
|
|
30
|
-
|
|
31
|
-
firstUpdated() {
|
|
32
|
-
this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
render() {
|
|
36
|
-
const value = this.value || {}
|
|
37
|
-
const { width, height } = this.bounds || {}
|
|
38
|
-
|
|
39
|
-
return html`
|
|
40
|
-
<fieldset>
|
|
41
|
-
<div class="property-grid">
|
|
42
|
-
${this._isIdentifiable(this.selected)
|
|
43
|
-
? html`
|
|
44
|
-
<label> <ox-i18n msgid="label.id">ID</ox-i18n> </label>
|
|
45
|
-
<input value-key="id" .value=${value.id || ''} />
|
|
46
|
-
`
|
|
47
|
-
: html``}
|
|
48
|
-
${this._isClassIdentifiable(this.selected)
|
|
49
|
-
? html`
|
|
50
|
-
<label> <ox-i18n msgid="label.class">Class</ox-i18n> </label>
|
|
51
|
-
<input value-key="class" .value=${value.class || ''} />
|
|
52
|
-
`
|
|
53
|
-
: html``}
|
|
54
|
-
${this._hasTextProperty(this.selected)
|
|
55
|
-
? html`
|
|
56
|
-
<label> <ox-i18n msgid="label.text">Text</ox-i18n> </label>
|
|
57
|
-
<input value-key="text" .value=${value.text || ''} />
|
|
58
|
-
<label> <ox-i18n msgid="label.text-format">Text Format</ox-i18n> </label>
|
|
59
|
-
<input value-key="textFormat" .value=${value.textFormat || ''} list="format-list" />
|
|
60
|
-
<datalist id="format-list">
|
|
61
|
-
<option value="#,###."></option>
|
|
62
|
-
<option value="#,###.#"></option>
|
|
63
|
-
<option value="#,###.0"></option>
|
|
64
|
-
<option value="#,##0.#"></option>
|
|
65
|
-
<option value="#,##0.0"></option>
|
|
66
|
-
<option value="#,##0.0%"></option>
|
|
67
|
-
</datalist>
|
|
68
|
-
`
|
|
69
|
-
: html``}
|
|
70
|
-
${this._hasProperties(this.selected)
|
|
71
|
-
? html`
|
|
72
|
-
<input id="checkbox-hidden" value-key="hidden" type="checkbox" .checked=${value.hidden} />
|
|
73
|
-
<label for="checkbox-hidden"> <ox-i18n msgid="label.item-hidden">Item Hidden</ox-i18n> </label>
|
|
74
|
-
|
|
75
|
-
<input id="checkbox-locked" value-key="locked" type="checkbox" .checked=${value.locked} />
|
|
76
|
-
<label for="checkbox-locked"> <ox-i18n msgid="label.locked">Locked</ox-i18n> </label>
|
|
77
|
-
`
|
|
78
|
-
: html``}
|
|
79
|
-
</div>
|
|
80
|
-
</fieldset>
|
|
81
|
-
|
|
82
|
-
${!this._isLine(this.selected)
|
|
83
|
-
? keyed(
|
|
84
|
-
this.selected,
|
|
85
|
-
html`
|
|
86
|
-
<fieldset class="icon-label">
|
|
87
|
-
<legend>
|
|
88
|
-
<ox-title-with-help topic="board-modeller/shapes/size" msgid="label.size">size</ox-title-with-help>
|
|
89
|
-
</legend>
|
|
90
|
-
|
|
91
|
-
<div class="property-grid">
|
|
92
|
-
<label> <md-icon>arrow_range</md-icon><ox-i18n msgid="label.width">width</ox-i18n> </label>
|
|
93
|
-
<input type="number" value-key="bounds.width" .value=${String(width)} />
|
|
94
|
-
<label> <md-icon>height</md-icon><ox-i18n msgid="label.height">height</ox-i18n> </label>
|
|
95
|
-
<input type="number" value-key="bounds.height" .value=${String(height)} />
|
|
96
|
-
|
|
97
|
-
${this.selected.length && this.selected[0].isRootModel()
|
|
98
|
-
? html``
|
|
99
|
-
: html`
|
|
100
|
-
<label class="rotate">
|
|
101
|
-
<md-icon>rotate_90_degrees_cw</md-icon><ox-i18n msgid="label.rotate">rotate</ox-i18n>
|
|
102
|
-
</label>
|
|
103
|
-
<ox-input-angle value-key="rotation" .value=${value.rotation}> </ox-input-angle>
|
|
104
|
-
`}
|
|
105
|
-
</div>
|
|
106
|
-
</fieldset>
|
|
107
|
-
`
|
|
108
|
-
)
|
|
109
|
-
: html``}
|
|
110
|
-
${this._isPositionable(this.selected)
|
|
111
|
-
? keyed(
|
|
112
|
-
this.selected,
|
|
113
|
-
html`
|
|
114
|
-
<fieldset class="icon-label" collapsable ?collapsed=${!this._positionExpanded}>
|
|
115
|
-
<legend
|
|
116
|
-
@click=${(e: Event) => {
|
|
117
|
-
this._positionExpanded = !this._positionExpanded
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
<ox-title-with-help topic="board-modeller/shapes/position" msgid="label.position"
|
|
121
|
-
>position</ox-title-with-help
|
|
122
|
-
>
|
|
123
|
-
<md-icon>${this._positionExpanded ? 'expand_less' : 'expand_more'}</md-icon>
|
|
124
|
-
</legend>
|
|
125
|
-
|
|
126
|
-
<div class="property-grid">
|
|
127
|
-
<label>Position</label>
|
|
128
|
-
<select value-key="position" .value=${value.position}>
|
|
129
|
-
<option value=""> </option>
|
|
130
|
-
<option value="static">static</option>
|
|
131
|
-
<option value="relative">relative</option>
|
|
132
|
-
<option value="absolute">absolute</option>
|
|
133
|
-
<option value="fixed">fixed</option>
|
|
134
|
-
<option value="sticky">sticky</option>
|
|
135
|
-
</select>
|
|
136
|
-
|
|
137
|
-
<label>Origin</label>
|
|
138
|
-
<select value-key="origin" .value=${value.origin}>
|
|
139
|
-
<option value=""> </option>
|
|
140
|
-
<option value="left-top">left-top</option>
|
|
141
|
-
<option value="center-top">center-top</option>
|
|
142
|
-
<option value="right-top">right-top</option>
|
|
143
|
-
<option value="left-middle">left-middle</option>
|
|
144
|
-
<option value="center-middle">center-middle</option>
|
|
145
|
-
<option value="right-middle">right-middle</option>
|
|
146
|
-
<option value="left-bottom">left-bottom</option>
|
|
147
|
-
<option value="center-bottom">center-bottom</option>
|
|
148
|
-
<option value="right-bottom">right-bottom</option>
|
|
149
|
-
</select>
|
|
150
|
-
|
|
151
|
-
<label> <ox-i18n msgid="label.offset-x">offset-X</ox-i18n> </label>
|
|
152
|
-
<input type="number" value-key="offsetX" .value=${String(value.offsetX ?? '')} />
|
|
153
|
-
<label> <ox-i18n msgid="label.offset-y">offset-Y</ox-i18n> </label>
|
|
154
|
-
<input type="number" value-key="offsetY" .value=${String(value.offsetY ?? '')} />
|
|
155
|
-
</div>
|
|
156
|
-
</fieldset>
|
|
157
|
-
`
|
|
158
|
-
)
|
|
159
|
-
: html``}
|
|
160
|
-
${this._is3dish(this.selected)
|
|
161
|
-
? html`
|
|
162
|
-
<fieldset class="icon-label" collapsable ?collapsed=${!this._3dExpanded}>
|
|
163
|
-
<legend
|
|
164
|
-
@click=${(e: Event) => {
|
|
165
|
-
this._3dExpanded = !this._3dExpanded
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
<ox-title-with-help topic="board-modeller/shapes/3dish" msgid="label.3dish">3D</ox-title-with-help>
|
|
169
|
-
<md-icon>${this._3dExpanded ? 'expand_less' : 'expand_more'}</md-icon>
|
|
170
|
-
</legend>
|
|
171
|
-
|
|
172
|
-
<div class="property-grid">
|
|
173
|
-
<label class="zPos"> <ox-i18n msgid="label.z-pos">pos. Z</ox-i18n> </label>
|
|
174
|
-
<input type="number" value-key="zPos" .value=${value.zPos} />
|
|
175
|
-
<label class="depth"> <ox-i18n msgid="label.depth">depth</ox-i18n> </label>
|
|
176
|
-
<input type="number" value-key="depth" .value=${value.depth} />
|
|
177
|
-
|
|
178
|
-
<label class="rotationX"> <ox-i18n msgid="label.rotation-x">rot. X</ox-i18n> </label>
|
|
179
|
-
<ox-input-angle value-key="rotationX" .value=${value.rotationX}> </ox-input-angle>
|
|
180
|
-
|
|
181
|
-
<label class="rotationY"> <ox-i18n msgid="label.rotation-y">rot. Y</ox-i18n> </label>
|
|
182
|
-
<ox-input-angle value-key="rotationY" .value=${value.rotationY}> </ox-input-angle>
|
|
183
|
-
|
|
184
|
-
<label class="rotationZ"> <ox-i18n msgid="label.rotation-z">rot. Z</ox-i18n> </label>
|
|
185
|
-
<ox-input-angle value-key="rotation" .value=${value.rotation}> </ox-input-angle>
|
|
186
|
-
</div>
|
|
187
|
-
</fieldset>
|
|
188
|
-
`
|
|
189
|
-
: html``}
|
|
190
|
-
${this._hasTextProperty(this.selected)
|
|
191
|
-
? html`
|
|
192
|
-
<fieldset>
|
|
193
|
-
<legend>
|
|
194
|
-
<ox-title-with-help topic="board-modeller/shapes/text-box" msgid="label.text-box"
|
|
195
|
-
>text box</ox-title-with-help
|
|
196
|
-
>
|
|
197
|
-
</legend>
|
|
198
|
-
|
|
199
|
-
<div class="property-grid">
|
|
200
|
-
<label> <ox-i18n msgid="label.horizontal">horizontal</ox-i18n> </label>
|
|
201
|
-
<ox-buttons-radio value-key="textAlign" .value=${value.textAlign}>
|
|
202
|
-
<md-icon data-value="left">format_align_left</md-icon>
|
|
203
|
-
<md-icon data-value="center">format_align_center</md-icon>
|
|
204
|
-
<md-icon data-value="right">format_align_right</md-icon>
|
|
205
|
-
<md-icon data-value="justify">format_align_justify</md-icon>
|
|
206
|
-
</ox-buttons-radio>
|
|
207
|
-
|
|
208
|
-
<label> <ox-i18n msgid="label.vertical">vertical</ox-i18n> </label>
|
|
209
|
-
<ox-buttons-radio value-key="textBaseline" .value=${value.textBaseline}>
|
|
210
|
-
<md-icon data-value="top">align_vertical_top</md-icon>
|
|
211
|
-
<md-icon data-value="middle">align_vertical_center</md-icon>
|
|
212
|
-
<md-icon data-value="bottom">align_vertical_bottom</md-icon>
|
|
213
|
-
</ox-buttons-radio>
|
|
214
|
-
|
|
215
|
-
<input
|
|
216
|
-
id="checkbox-support-markdown"
|
|
217
|
-
type="checkbox"
|
|
218
|
-
value-key="supportMarkdown"
|
|
219
|
-
.checked=${value.supportMarkdown}
|
|
220
|
-
/>
|
|
221
|
-
<label for="checkbox-support-markdown">
|
|
222
|
-
<ox-i18n msgid="label.support-markdown">Support Markdown</ox-i18n>
|
|
223
|
-
</label>
|
|
224
|
-
|
|
225
|
-
<input id="checkbox-textwrap" type="checkbox" value-key="textWrap" .checked=${value.textWrap} />
|
|
226
|
-
<label for="checkbox-textwrap"> <ox-i18n msgid="label.text-wrap">Text Wrap</ox-i18n> </label>
|
|
227
|
-
|
|
228
|
-
${!value.textWrap
|
|
229
|
-
? html` <label for="checkbox-textOverflow">
|
|
230
|
-
<ox-i18n msgid="label.text-overflow">Text Overflow</ox-i18n>
|
|
231
|
-
</label>
|
|
232
|
-
<select value-key="textOverflow" .value=${value.textOverflow || ''}>
|
|
233
|
-
<option value="" selected>none</option>
|
|
234
|
-
<option value="ellipsis">ellipsis</option>
|
|
235
|
-
<option value="clip">clip</option>
|
|
236
|
-
</select>`
|
|
237
|
-
: ''}
|
|
238
|
-
|
|
239
|
-
<label> <ox-i18n msgid="label.padding">padding</ox-i18n> </label>
|
|
240
|
-
<table class="box-padding custom-editor">
|
|
241
|
-
<tr>
|
|
242
|
-
<td class="slide1"></td>
|
|
243
|
-
<td class="slide2"></td>
|
|
244
|
-
<td class="slide3"></td>
|
|
245
|
-
</tr>
|
|
246
|
-
<tr>
|
|
247
|
-
<td class="slide4"></td>
|
|
248
|
-
<td class="slide5">
|
|
249
|
-
<input type="number" value-key="paddingTop" .value=${value.paddingTop || 0} />
|
|
250
|
-
<input type="number" value-key="paddingLeft" .value=${value.paddingLeft || 0} />
|
|
251
|
-
<input type="number" value-key="paddingRight" .value=${value.paddingRight || 0} />
|
|
252
|
-
<input type="number" value-key="paddingBottom" .value=${value.paddingBottom || 0} />
|
|
253
|
-
</td>
|
|
254
|
-
<td class="slide6"></td>
|
|
255
|
-
</tr>
|
|
256
|
-
<tr>
|
|
257
|
-
<td class="slide7"></td>
|
|
258
|
-
<td class="slide8"></td>
|
|
259
|
-
<td class="slide9"></td>
|
|
260
|
-
</tr>
|
|
261
|
-
</table>
|
|
262
|
-
</div>
|
|
263
|
-
</fieldset>
|
|
264
|
-
`
|
|
265
|
-
: html``}
|
|
266
|
-
${this.selected.length && this.selected[0].isRootModel()
|
|
267
|
-
? html`
|
|
268
|
-
<fieldset class="icon-label">
|
|
269
|
-
<legend>
|
|
270
|
-
<ox-title-with-help topic="board-modeller/shapes/viewer-option" msgid="label.viewer-option"
|
|
271
|
-
>Viewer Option</ox-title-with-help
|
|
272
|
-
>
|
|
273
|
-
</legend>
|
|
274
|
-
|
|
275
|
-
<div class="property-grid">
|
|
276
|
-
<label><ox-i18n msgid="label.fit">Fit</ox-i18n></label>
|
|
277
|
-
<select value-key="fitMode" .value=${value.fitMode || 'ratio'}>
|
|
278
|
-
<option value="none">none</option>
|
|
279
|
-
<option value="center">center</option>
|
|
280
|
-
<option value="ratio" selected>ratio</option>
|
|
281
|
-
<option value="both">both</option>
|
|
282
|
-
<option value="width">width</option>
|
|
283
|
-
<option value="height">height</option>
|
|
284
|
-
</select>
|
|
285
|
-
</div>
|
|
286
|
-
</fieldset>
|
|
287
|
-
<fieldset class="icon-label">
|
|
288
|
-
<legend>
|
|
289
|
-
<ox-title-with-help topic="board-modeller/shapes/print-option" msgid="label.label-print"
|
|
290
|
-
>Print Option</ox-title-with-help
|
|
291
|
-
>
|
|
292
|
-
</legend>
|
|
293
|
-
|
|
294
|
-
<div class="property-grid">
|
|
295
|
-
<label class="rotate"><ox-i18n msgid="label.label-rotation">Label Rotation</ox-i18n></label>
|
|
296
|
-
<select value-key="labelRotation" .value=${value.labelRotation || 'N'}>
|
|
297
|
-
<option value="N" selected>0°</option>
|
|
298
|
-
<option value="B">90°</option>
|
|
299
|
-
<option value="I">180°</option>
|
|
300
|
-
<option value="R">270°</option>
|
|
301
|
-
</select>
|
|
302
|
-
</div>
|
|
303
|
-
</fieldset>
|
|
304
|
-
`
|
|
305
|
-
: html``}
|
|
306
|
-
`
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
onValueChange(e: Event) {
|
|
310
|
-
var element = e.target as HTMLElement
|
|
311
|
-
var key = element.getAttribute('value-key')
|
|
312
|
-
|
|
313
|
-
if (!key) {
|
|
314
|
-
return
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
var value = this.getValueFromEventTarget(element)
|
|
318
|
-
|
|
319
|
-
if (key.indexOf('bounds.') == 0) {
|
|
320
|
-
if (isNaN(value)) return
|
|
321
|
-
this.dispatchEvent(
|
|
322
|
-
new CustomEvent('bounds-change', {
|
|
323
|
-
bubbles: true,
|
|
324
|
-
composed: true,
|
|
325
|
-
detail: {
|
|
326
|
-
[key.substr(7)]: value
|
|
327
|
-
}
|
|
328
|
-
})
|
|
329
|
-
)
|
|
330
|
-
} else {
|
|
331
|
-
this.onAfterValueChange(key, value)
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
_hasTextProperty(selected: Component[]) {
|
|
336
|
-
for (let i = 0; i < selected.length; i++) {
|
|
337
|
-
if (!selected[i].hasTextProperty) return false
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return true
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
_hasProperties(selected: Component[]) {
|
|
344
|
-
if (!selected || selected.length == 0 || (selected[0] && selected[0].isLayer && selected[0].isLayer())) return false
|
|
345
|
-
|
|
346
|
-
return true
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
_isIdentifiable(selected: Component[]) {
|
|
350
|
-
if (!selected || selected.length == 0 || selected.length > 1 || (selected[0].isLayer && selected[0].isLayer()))
|
|
351
|
-
return false
|
|
352
|
-
|
|
353
|
-
return true
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
_isClassIdentifiable(selected: Component[]) {
|
|
357
|
-
if (!selected || (selected[0] && selected[0].isLayer())) return false
|
|
358
|
-
|
|
359
|
-
return true
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
_isLine(selected: Component[]) {
|
|
363
|
-
if (!selected || !(selected[0] && selected[0].isLine())) return false
|
|
364
|
-
|
|
365
|
-
return true
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
_is3dish(selected: Component[]) {
|
|
369
|
-
if (!selected || !(selected[0] && selected[0].is3dish())) return false
|
|
370
|
-
|
|
371
|
-
return true
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
_isPositionable(selected: Component[]) {
|
|
375
|
-
if (!selected || !(selected[0] && selected[0].isPositionable())) return false
|
|
376
|
-
|
|
377
|
-
return true
|
|
378
|
-
}
|
|
379
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@operato/app/property-editor.js' /* for registering property editors */
|
|
6
|
-
|
|
7
|
-
import { html, LitElement, PropertyValues } from 'lit'
|
|
8
|
-
import { property } from 'lit/decorators.js'
|
|
9
|
-
|
|
10
|
-
import { CSSStyles, OxPropertyEditor, PropertySpec } from '@operato/property-editor'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
|
|
14
|
-
|
|
15
|
-
Example:
|
|
16
|
-
|
|
17
|
-
<specific-properties-builder value="{{value}}">
|
|
18
|
-
<label>Center X</label>
|
|
19
|
-
<input type="number" .value="${value.cx}">
|
|
20
|
-
<label>Width</label>
|
|
21
|
-
<input type="number" .value="${value.width}">
|
|
22
|
-
</specific-properties-builder>
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const DEFAULT_VALUE = {
|
|
26
|
-
legend: '',
|
|
27
|
-
// number: 0, // should be undefined
|
|
28
|
-
angle: 0,
|
|
29
|
-
string: '',
|
|
30
|
-
password: '',
|
|
31
|
-
textarea: '',
|
|
32
|
-
checkbox: false,
|
|
33
|
-
select: '',
|
|
34
|
-
color: '#000000',
|
|
35
|
-
'solidcolor-stops': null,
|
|
36
|
-
'gradientcolor-stops': null,
|
|
37
|
-
'gltf-selector': '',
|
|
38
|
-
'image-selector': '',
|
|
39
|
-
multiplecolor: null,
|
|
40
|
-
editortable: null,
|
|
41
|
-
imageselector: '',
|
|
42
|
-
options: null,
|
|
43
|
-
date: null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function convertValue(type: string, value: any) {
|
|
47
|
-
var converted = String(value).trim() == '' ? undefined : value
|
|
48
|
-
switch (type) {
|
|
49
|
-
case 'number':
|
|
50
|
-
case 'angle':
|
|
51
|
-
converted = parseFloat(value)
|
|
52
|
-
converted = isNaN(converted) ? undefined : converted
|
|
53
|
-
break
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return converted
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class SpecificPropertiesBuilder extends LitElement {
|
|
60
|
-
@property({ type: Object }) value: { [name: string]: any } = {}
|
|
61
|
-
@property({ type: Array }) props?: PropertySpec[]
|
|
62
|
-
@property({ type: Object }) propertyEditor: any
|
|
63
|
-
|
|
64
|
-
render() {
|
|
65
|
-
return html`<slot></slot>`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
firstUpdated() {
|
|
69
|
-
this.addEventListener('change', this.onValueChanged.bind(this))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
updated(changes: PropertyValues<this>) {
|
|
73
|
-
changes.has('props') && this.onPropsChanged(this.props || [])
|
|
74
|
-
changes.has('value') && this.setValues()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private onPropsChanged(props: PropertySpec[]) {
|
|
78
|
-
const specs = this.props || []
|
|
79
|
-
|
|
80
|
-
this.textContent = ''
|
|
81
|
-
specs.forEach((spec: PropertySpec) => {
|
|
82
|
-
const { label, type, placeholder, name, observe, property, editor, quantifier, defaultValue, disabled, styles } =
|
|
83
|
-
spec
|
|
84
|
-
|
|
85
|
-
const elementType = OxPropertyEditor.getEditor(type)
|
|
86
|
-
if (!elementType) {
|
|
87
|
-
console.warn('Property Editor not defined', type)
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
const element = document.createElement(elementType) as OxPropertyEditor
|
|
91
|
-
|
|
92
|
-
element.label = label
|
|
93
|
-
element.type = type
|
|
94
|
-
element.placeholder = placeholder
|
|
95
|
-
element.name = name
|
|
96
|
-
element.setAttribute('name', name)
|
|
97
|
-
|
|
98
|
-
if (observe) {
|
|
99
|
-
element.observeHandler = observe
|
|
100
|
-
}
|
|
101
|
-
element.property = property
|
|
102
|
-
element.editor = editor
|
|
103
|
-
element.quantifier = quantifier
|
|
104
|
-
element.defaultValue = defaultValue
|
|
105
|
-
element.setAttribute('property-editor', 'true')
|
|
106
|
-
element.disabled = disabled
|
|
107
|
-
|
|
108
|
-
if (styles) {
|
|
109
|
-
Object.keys(styles).forEach((key: string) => {
|
|
110
|
-
element.style[key as keyof CSSStyles] = styles[key as keyof CSSStyles]
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this.appendChild(element)
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private setValues() {
|
|
119
|
-
this.value &&
|
|
120
|
-
Array.from(this.querySelectorAll('[name]')).forEach((prop: { [name: string]: any }) => {
|
|
121
|
-
let name = prop.getAttribute('name')
|
|
122
|
-
if (!name) {
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
var convertedValue = convertValue(prop.type, this.value[name])
|
|
126
|
-
if (convertedValue === undefined) {
|
|
127
|
-
convertedValue = (DEFAULT_VALUE as any)[prop.type]
|
|
128
|
-
}
|
|
129
|
-
prop.value = convertedValue
|
|
130
|
-
prop.observe.call(prop, prop.value)
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private onValueChanged(e: Event) {
|
|
135
|
-
e.stopPropagation()
|
|
136
|
-
var target = e.target as Element
|
|
137
|
-
|
|
138
|
-
const prop = target.closest('[property-editor]') as OxPropertyEditor
|
|
139
|
-
|
|
140
|
-
var name = prop.getAttribute('name')
|
|
141
|
-
if (!name) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.value[name] = prop.value
|
|
146
|
-
|
|
147
|
-
prop.observe(prop.value)
|
|
148
|
-
this.setValues()
|
|
149
|
-
|
|
150
|
-
this.dispatchEvent(
|
|
151
|
-
new CustomEvent('property-change', {
|
|
152
|
-
bubbles: true,
|
|
153
|
-
composed: true,
|
|
154
|
-
detail: {
|
|
155
|
-
[name]: prop.value
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@operato/help/ox-help-icon.js'
|
|
6
|
-
|
|
7
|
-
import { css, html, LitElement } from 'lit'
|
|
8
|
-
import { property } from 'lit/decorators.js'
|
|
9
|
-
|
|
10
|
-
import { Component, Scene } from '@hatiolab/things-scene'
|
|
11
|
-
import { ScopedElementsMixin } from '@open-wc/scoped-elements'
|
|
12
|
-
|
|
13
|
-
import { i18next } from '@operato/i18n'
|
|
14
|
-
import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
|
|
15
|
-
|
|
16
|
-
import { SpecificPropertiesBuilder } from './specific-properties-builder.js'
|
|
17
|
-
|
|
18
|
-
export class PropertySpecific extends ScopedElementsMixin(LitElement) {
|
|
19
|
-
static styles = [
|
|
20
|
-
PropertyGridStyles,
|
|
21
|
-
css`
|
|
22
|
-
label {
|
|
23
|
-
display: flex;
|
|
24
|
-
margin: 10px;
|
|
25
|
-
text-align: right;
|
|
26
|
-
font: bold 14px var(--theme-font);
|
|
27
|
-
color: var(--md-sys-color-on-primary-container);
|
|
28
|
-
text-transform: capitalize;
|
|
29
|
-
align-items: center;
|
|
30
|
-
}
|
|
31
|
-
`
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
@property({ type: Object }) value: any
|
|
35
|
-
@property({ type: Object }) scene: Scene | null = null
|
|
36
|
-
@property({ type: Array }) selected: Component[] = []
|
|
37
|
-
@property({ type: Array }) props: any[] = []
|
|
38
|
-
@property({ type: Array }) propertyEditor: any[] = []
|
|
39
|
-
|
|
40
|
-
private boundINeedSelected: any = this.onINeedSelected.bind(this)
|
|
41
|
-
|
|
42
|
-
connectedCallback() {
|
|
43
|
-
super.connectedCallback()
|
|
44
|
-
|
|
45
|
-
this.addEventListener('i-need-selected', this.boundINeedSelected)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
disconnectedCallback() {
|
|
49
|
-
super.disconnectedCallback()
|
|
50
|
-
|
|
51
|
-
this.removeEventListener('i-need-selected', this.boundINeedSelected)
|
|
52
|
-
}
|
|
53
|
-
static get scopedElements() {
|
|
54
|
-
return {
|
|
55
|
-
'specific-properties-builder': SpecificPropertiesBuilder
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
const selected = this.selected && this.selected[0]
|
|
60
|
-
const value = this.value || {}
|
|
61
|
-
|
|
62
|
-
return html`
|
|
63
|
-
<label
|
|
64
|
-
>${i18next.t(`component.${value.type}`)}<ox-help-icon .topic=${selected?.nature?.help}></ox-help-icon
|
|
65
|
-
></label>
|
|
66
|
-
|
|
67
|
-
<specific-properties-builder .value=${value} .props=${this.props} .propertyEditor=${this.propertyEditor}>
|
|
68
|
-
</specific-properties-builder>
|
|
69
|
-
`
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private onINeedSelected(e: CustomEvent) {
|
|
73
|
-
e.stopPropagation()
|
|
74
|
-
|
|
75
|
-
var { callback } = e.detail
|
|
76
|
-
|
|
77
|
-
this.scene!.undoableChange(() => {
|
|
78
|
-
callback.call(null, this.selected)
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
}
|