@operato/board 0.2.45 → 0.2.46

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