@things-factory/modeller-ui 5.0.0-alpha.3 → 5.0.0-alpha.6

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 (29) hide show
  1. package/client/bootstrap.js +22 -26
  2. package/client/editors/things-editor-layout/things-card-layout.js +1 -1
  3. package/client/editors/things-editor-property.js +1 -546
  4. package/package.json +15 -14
  5. package/client/editors/paper-color-picker/paper-color-circle.js +0 -466
  6. package/client/editors/paper-color-picker/paper-color-input.js +0 -266
  7. package/client/editors/paper-color-picker/paper-color-picker.js +0 -584
  8. package/client/editors/things-editor-3dish.js +0 -164
  9. package/client/editors/things-editor-angle-input.js +0 -69
  10. package/client/editors/things-editor-attachment-selector.js +0 -110
  11. package/client/editors/things-editor-buttons-radio.js +0 -93
  12. package/client/editors/things-editor-code.js +0 -152
  13. package/client/editors/things-editor-color-stops.js +0 -499
  14. package/client/editors/things-editor-color-style.js +0 -345
  15. package/client/editors/things-editor-color.js +0 -313
  16. package/client/editors/things-editor-data.js +0 -152
  17. package/client/editors/things-editor-gradient.js +0 -335
  18. package/client/editors/things-editor-graphql.js +0 -173
  19. package/client/editors/things-editor-id.js +0 -85
  20. package/client/editors/things-editor-multiple-color.js +0 -132
  21. package/client/editors/things-editor-options.js +0 -155
  22. package/client/editors/things-editor-pattern.js +0 -161
  23. package/client/editors/things-editor-property-styles.js +0 -71
  24. package/client/editors/things-editor-range-input.js +0 -166
  25. package/client/editors/things-editor-script.js +0 -213
  26. package/client/editors/things-editor-stack.js +0 -107
  27. package/client/editors/things-editor-table.js +0 -376
  28. package/client/editors/things-editor-value-map.js +0 -290
  29. package/client/editors/things-editor-value-range.js +0 -292
@@ -1,376 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/mwc-icon'
6
- import '@polymer/paper-dropdown-menu/paper-dropdown-menu'
7
- import '@polymer/paper-item/paper-item'
8
- import '@operato/i18n/ox-i18n.js'
9
- import './things-editor-color'
10
-
11
- import { css, html, LitElement } from 'lit'
12
-
13
- /**
14
- * 테이블 셀의 좌,우,상,하 경계선의 스타일을 편집하는 컴포넌트이다.
15
- * Example:
16
- * <things-editor-table value=${border}>
17
- * </things-editor-table>
18
- */
19
- class ThingsEditorTable extends LitElement {
20
- static get is() {
21
- return 'things-editor-table'
22
- }
23
-
24
- static get properties() {
25
- return {
26
- borderWidth: Number,
27
- borderColor: String,
28
- borderStyle: String
29
- }
30
- }
31
-
32
- static get styles() {
33
- return [
34
- css`
35
- :host {
36
- display: block;
37
- }
38
-
39
- fieldset {
40
- border: none;
41
- border-bottom: 1px solid #cfd8dc;
42
- color: var(--primary-text-color);
43
- font-size: 12px;
44
- padding: 0 0 10px 0;
45
- margin: 0 0 10px 0;
46
- }
47
-
48
- fieldset legend {
49
- padding: 5px 0 0 5px;
50
- font-size: 11px;
51
- color: #e46c2e;
52
- font-weight: bold;
53
- text-transform: capitalize;
54
- }
55
-
56
- .icon-only-label {
57
- background: url(/assets/images/icon-properties-label.png) no-repeat;
58
- width: 30px;
59
- height: 24px;
60
- }
61
-
62
- .property-grid {
63
- display: grid;
64
- grid-template-columns: repeat(10, 1fr);
65
- grid-gap: 5px;
66
- grid-auto-rows: minmax(24px, auto);
67
- margin: 10px 0 0 0;
68
- }
69
-
70
- .property-grid > * {
71
- line-height: 1.5;
72
- }
73
-
74
- #border-set > mwc-icon {
75
- grid-column: span 2;
76
- margin: 0 0 0 8px;
77
- width: 32px;
78
- height: 32px;
79
- }
80
-
81
- .property-grid > label {
82
- grid-column: span 3;
83
- text-align: right;
84
- text-transform: capitalize;
85
- }
86
-
87
- .property-grid > label.icon-only-label {
88
- grid-column: span 1;
89
- }
90
-
91
- .property-grid > things-editor-color,
92
- .property-grid > input[type='number'] {
93
- grid-column: span 4;
94
- padding: 0;
95
- margin: 0;
96
- }
97
-
98
- .property-grid > paper-dropdown-menu {
99
- grid-column: span 7;
100
- padding: 0;
101
- margin: 0;
102
- }
103
-
104
- [table-event] {
105
- position: relative;
106
- background: url('/assets/images/icon-properties-table.png') no-repeat;
107
- grid-column: span 2;
108
- min-height: 65px;
109
- }
110
-
111
- [table-event] span {
112
- position: absolute;
113
- bottom: 0;
114
- font-size: 0.9em;
115
- line-height: 1.2;
116
- text-transform: capitalize;
117
- text-align: center;
118
- vertical-align: bottom;
119
- }
120
-
121
- #merge-cells {
122
- background-position: 50% 3px;
123
- }
124
-
125
- #split-cells {
126
- background-position: 50% -97px;
127
- }
128
-
129
- #delete-row {
130
- background-position: 50% -197px;
131
- }
132
-
133
- #delete-column {
134
- background-position: 50% -297px;
135
- }
136
-
137
- #insert-above {
138
- background-position: 50% -397px;
139
- }
140
-
141
- #insert-below {
142
- background-position: 50% -497px;
143
- }
144
-
145
- #insert-left {
146
- background-position: 50% -597px;
147
- }
148
-
149
- #insert-right {
150
- background-position: 50% -697px;
151
- }
152
-
153
- #distribute-horizontal {
154
- background-position: 50% -797px;
155
- }
156
-
157
- #distribute-vertical {
158
- background-position: 50% -897px;
159
- }
160
-
161
- .line-type paper-item {
162
- background: no-repeat url(/assets/images/icon-properties-line-type.png);
163
- width: 80px;
164
- min-height: 25px;
165
- }
166
- .line-type paper-item.solid {
167
- background-position: 50% 12px;
168
- }
169
- .line-type paper-item.round-dot {
170
- background-position: 50% -38px;
171
- }
172
- .line-type paper-item.square-dot {
173
- background-position: 50% -88px;
174
- }
175
- .line-type paper-item.dash {
176
- background-position: 50% -138px;
177
- }
178
- .line-type paper-item.dash-dot {
179
- background-position: 50% -188px;
180
- }
181
- .line-type paper-item.long-dash {
182
- background-position: 50% -238px;
183
- }
184
- .line-type paper-item.long-dash-dot {
185
- background-position: 50% -288px;
186
- }
187
- .line-type paper-item.long-dash-dot-dot {
188
- background-position: 50% -338px;
189
- }
190
- `
191
- ]
192
- }
193
-
194
- constructor() {
195
- super()
196
-
197
- this.borderWidth = 1
198
- this.borderColor = 'black'
199
- this.borderStyle = 'solid'
200
- }
201
-
202
- firstUpdated() {
203
- this.shadowRoot.querySelector('#border-fieldset').addEventListener('change', this._onClickType.bind(this))
204
- }
205
-
206
- render() {
207
- return html`
208
- <fieldset id="border-fieldset">
209
- <legend><ox-i18n msgid="label.border-style">border style</ox-i18n></legend>
210
-
211
- <div
212
- id="border-set"
213
- class="property-grid
214
- border-style-btn"
215
- @click=${e => this._onClickType(e)}
216
- >
217
- <mwc-icon data-value="out">border_outer</mwc-icon>
218
- <mwc-icon data-value="in">border_inner</mwc-icon>
219
- <mwc-icon data-value="all">border_all</mwc-icon>
220
- <mwc-icon data-value="left">border_left</mwc-icon>
221
- <mwc-icon data-value="center">border_vertical</mwc-icon>
222
- <mwc-icon data-value="right">border_right</mwc-icon>
223
- <mwc-icon data-value="top">border_top</mwc-icon>
224
- <mwc-icon data-value="middle">border_horizontal</mwc-icon>
225
- <mwc-icon data-value="bottom">border_bottom</mwc-icon>
226
- <mwc-icon data-value="clear">border_clear</mwc-icon>
227
- </div>
228
-
229
- <div class="property-grid">
230
- <label class="icon-only-label linewidth"> </label>
231
- <input
232
- type="number"
233
- id="border-width"
234
- @change=${e => (this.borderWidth = e.target.value)}
235
- .value=${this.borderWidth}
236
- />
237
-
238
- <label class="icon-only-label color"> </label>
239
- <things-editor-color
240
- id="border-color"
241
- @change=${e => (this.borderColor = e.target.value)}
242
- .value=${this.borderColor}
243
- >
244
- </things-editor-color>
245
-
246
- <label> <ox-i18n msgid="label.border-type">border type</ox-i18n> </label>
247
- <paper-dropdown-menu no-label-float="true" class="line-type solid">
248
- <!-- solid는 선택된 항목 보여주기위한 class로 하위 paper-item의 class와 동일하게 -->
249
- <paper-listbox
250
- id="border-style"
251
- @iron-select=${e => (this.borderStyle = e.target.selected)}
252
- slot="dropdown-content"
253
- .selected=${this.borderStyle}
254
- attr-for-selected="name"
255
- >
256
- <paper-item class="solid" name="solid"></paper-item>
257
- <paper-item class="round-dot" name="round-dot"></paper-item>
258
- <paper-item class="square-dot" name="square-dot"></paper-item>
259
- <paper-item class="dash" name="dash"></paper-item>
260
- <paper-item class="dash-dot" name="dash-dot"></paper-item>
261
- <paper-item class="long-dash" name="long-dash"></paper-item>
262
- <paper-item class="long-dash-dot" name="long-dash-dot"></paper-item>
263
- <paper-item class="long-dash-dot-dot" name="long-dash-dot-dot"></paper-item>
264
- </paper-listbox>
265
- </paper-dropdown-menu>
266
- </div>
267
- </fieldset>
268
-
269
- <fieldset id="cell-fieldset" @click=${e => this._onClickCell(e)}>
270
- <div class="property-grid">
271
- <div id="merge-cells" table-event><span>merge cells</span></div>
272
- <div id="split-cells" table-event><span>split cells</span></div>
273
- <div id="delete-row" table-event><span>delete row</span></div>
274
- <div id="delete-column" table-event><span>delete column</span></div>
275
- <div id="insert-above" table-event><span>insert above</span></div>
276
- <div id="insert-below" table-event><span>insert below</span></div>
277
- <div id="insert-left" table-event><span>insert left</span></div>
278
- <div id="insert-right" table-event><span>insert right</span></div>
279
- <div id="distribute-horizontal" table-event><span>distribute horizontal</span></div>
280
- <div id="distribute-vertical" table-event><span>distribute vertical</span></div>
281
- </div>
282
- </fieldset>
283
- `
284
- }
285
-
286
- _onClickCell(e) {
287
- var target = e.target
288
-
289
- const event = target?.closest('[table-event]')?.getAttribute('id')
290
- if (!event) {
291
- return
292
- }
293
-
294
- this.dispatchEvent(
295
- new CustomEvent('i-need-selected', {
296
- bubbles: true,
297
- composed: true,
298
- detail: {
299
- callback: selected => {
300
- const table = selected[0].parent
301
-
302
- switch (event) {
303
- case 'delete-row':
304
- table.deleteRows(selected)
305
- break
306
- case 'delete-column':
307
- table.deleteColumns(selected)
308
- break
309
- case 'insert-above':
310
- table.insertCellsAbove(selected)
311
- break
312
- case 'insert-below':
313
- table.insertCellsBelow(selected)
314
- break
315
- case 'insert-left':
316
- table.insertCellsLeft(selected)
317
- break
318
- case 'insert-right':
319
- table.insertCellsRight(selected)
320
- break
321
- case 'merge-cells':
322
- table.mergeCells(selected)
323
- break
324
- case 'split-cells':
325
- table.splitCells(selected)
326
- break
327
- case 'distribute-horizontal':
328
- table.distributeHorizontal(selected)
329
- break
330
- case 'distribute-vertical':
331
- table.distributeVertical(selected)
332
- break
333
- }
334
- }
335
- }
336
- })
337
- )
338
-
339
- e.stopPropagation()
340
- }
341
-
342
- _onClickType(e) {
343
- var target = e.target
344
-
345
- const where = target?.closest('[data-value]')?.getAttribute('data-value')
346
- if (!where) {
347
- return
348
- }
349
-
350
- this.dispatchEvent(
351
- new CustomEvent('i-need-selected', {
352
- bubbles: true,
353
- composed: true,
354
- detail: {
355
- callback: selected => {
356
- const table = selected[0].parent
357
-
358
- table.setCellsStyle(
359
- selected,
360
- {
361
- strokeStyle: this.borderColor,
362
- lineDash: this.borderStyle,
363
- lineWidth: this.borderWidth
364
- },
365
- where
366
- )
367
- }
368
- }
369
- })
370
- )
371
-
372
- e.stopPropagation()
373
- }
374
- }
375
-
376
- customElements.define(ThingsEditorTable.is, ThingsEditorTable)
@@ -1,290 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement, html, css } from 'lit'
6
-
7
- import './things-editor-color'
8
-
9
- /**
10
- map value editor element
11
-
12
- Example:
13
-
14
- <things-editor-value-map value=${map}
15
- keytype=${keytype}
16
- valuetype=${valuetype}>
17
- </things-editor-value-map>
18
- */
19
- export default class ThingsEditorValueMap extends LitElement {
20
- static get is() {
21
- return 'things-editor-value-map'
22
- }
23
-
24
- static get properties() {
25
- return {
26
- value: Object,
27
- valuetype: String
28
- }
29
- }
30
-
31
- static get styles() {
32
- return [
33
- css`
34
- :host {
35
- display: flex;
36
- flex-direction: column;
37
- align-content: center;
38
-
39
- width: 100%;
40
- overflow: hidden;
41
- border: 1px solid #ccc;
42
- }
43
-
44
- div {
45
- display: flex;
46
- flex-flow: row nowrap;
47
- align-items: center;
48
-
49
- border-bottom: 1px solid #c0c0c0;
50
- }
51
-
52
- div:last-child {
53
- border-bottom: none;
54
- }
55
-
56
- div > * {
57
- min-width: 0px;
58
- margin: 2px;
59
- padding: 0;
60
- }
61
-
62
- button {
63
- width: 20px;
64
- text-align: center;
65
- }
66
-
67
- input,
68
- things-editor-color {
69
- flex: 1;
70
- }
71
-
72
- things-editor-color {
73
- --things-editor-color-input-color: {
74
- margin: 1px;
75
- }
76
- --things-editor-color-input-span: {
77
- width: 10px;
78
- height: 10px;
79
- }
80
- }
81
-
82
- input[type='checkbox'] {
83
- width: initial;
84
- }
85
- `
86
- ]
87
- }
88
-
89
- constructor() {
90
- super()
91
- this.value = {}
92
- this.valuetype = 'string'
93
- this.keytype = 'string'
94
- }
95
-
96
- firstUpdated() {
97
- this.renderRoot.addEventListener('change', this._onChange.bind(this))
98
- }
99
-
100
- render() {
101
- return html`
102
- ${this._toArray(this.value).map(
103
- item => html`
104
- <div data-record>
105
- <input type="text" data-key placeholder="key" .value=${item.key} /> ${this.valuetype == 'boolean'
106
- ? html` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
107
- : this.valuetype == 'color'
108
- ? html` <things-editor-color data-value .value=${item.value} tabindex="-1"> </things-editor-color> `
109
- : html`
110
- <input
111
- type="text"
112
- data-value
113
- placeholder="value"
114
- .value=${item.value}
115
- data-value-type=${this.valuetype}
116
- />
117
- `} <button class="record-action" @click=${e => this._delete(e)} tabindex="-1">-</button>
118
- </div>
119
- `
120
- )}
121
-
122
- <div data-record-new>
123
- <input type="text" data-key placeholder="key" value="" /> ${this.valuetype == 'boolean'
124
- ? html` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
125
- : this.valuetype == 'color'
126
- ? html` <things-editor-color data-value value="" tabindex="-1" placeholder="value"> </things-editor-color> `
127
- : html` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
128
- <button class="record-action" @click=${e => this._add(e)} tabindex="-1">+</button>
129
- </div>
130
-
131
- <div data-record>
132
- <input type="text" data-key data-default="" value="default" disabled /> ${this.valuetype == 'boolean'
133
- ? html`
134
- <input
135
- type="checkbox"
136
- data-value
137
- .checked=${this.value && this.value.default}
138
- data-value-type=${this.valuetype}
139
- />
140
- `
141
- : this.valuetype == 'color'
142
- ? html`
143
- <things-editor-color
144
- data-value
145
- .value=${(this.value && this.value.default) || ''}
146
- placeholder="value"
147
- tabindex="-1"
148
- >
149
- </things-editor-color>
150
- `
151
- : html`
152
- <input
153
- type="text"
154
- data-value
155
- placeholder="value"
156
- .value=${(this.value && this.value.default) || ''}
157
- data-value-type=${this.valuetype}
158
- />
159
- `} <button class="record-action" @click=${e => this._sort(e)} tabindex="-1">&gt;</button>
160
- </div>
161
- `
162
- }
163
-
164
- _defaultValue(type) {
165
- switch (type || this.valuetype) {
166
- case 'color':
167
- return '#000000'
168
- case 'boolean':
169
- case 'checkbox':
170
- return false
171
- default:
172
- return ''
173
- }
174
- }
175
-
176
- _onChange(e) {
177
- if (this._changingNow) {
178
- return
179
- }
180
-
181
- this._changingNow = true
182
-
183
- var input = e.target
184
- var value
185
-
186
- if (input.type == 'checkbox') value = Boolean(input.checked)
187
- else value = input.value
188
-
189
- var div = input.parentElement
190
-
191
- if (div.hasAttribute('data-record')) {
192
- var dataList = div.querySelectorAll('[data-value]:not([hidden])')
193
- for (var i = 0; i < dataList.length; i++)
194
- if (dataList[i] !== input) dataList[i].value = value || this._defaultValue()
195
- }
196
-
197
- if (div.hasAttribute('data-record')) this._build()
198
- else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()
199
-
200
- this._changingNow = false
201
- }
202
-
203
- _build(includeNewRecord) {
204
- if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')
205
- else var records = this.renderRoot.querySelectorAll('[data-record]')
206
-
207
- var newmap = {}
208
-
209
- for (var i = 0; i < records.length; i++) {
210
- var record = records[i]
211
-
212
- var key = record.querySelector('[data-key]').value
213
- var inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])')
214
- if (!inputs || inputs.length == 0) continue
215
-
216
- var input = inputs[inputs.length - 1]
217
-
218
- var value
219
-
220
- if (input.type == 'checkbox') value = Boolean(input.checked)
221
- else value = input.value
222
-
223
- if (key) newmap[key] = value || this._defaultValue()
224
- }
225
-
226
- this.value = newmap
227
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
228
- }
229
-
230
- /* default를 제외한 map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
231
- _toArray(map) {
232
- var array = []
233
-
234
- for (var key in map) {
235
- if (key == 'default') continue
236
- array.push({
237
- key: key,
238
- value: map[key]
239
- })
240
- }
241
-
242
- return array
243
- }
244
-
245
- _sort(e) {
246
- var sorter =
247
- this.keytype === 'number'
248
- ? function (a, b) {
249
- return parseFloat(b.key) < parseFloat(a.key)
250
- }
251
- : function (a, b) {
252
- return b.key < a.key
253
- }
254
-
255
- var map = this._toArray(this.value)
256
- .sort(sorter)
257
- .reduce(function (sum, i) {
258
- sum[i.key] = i.value
259
- return sum
260
- }, {})
261
-
262
- map.default = this.value.default
263
-
264
- this.value = map
265
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
266
- }
267
-
268
- _add(e) {
269
- this._build(true)
270
-
271
- var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])')
272
-
273
- for (var i = 0; i < inputs.length; i++) {
274
- let input = inputs[i]
275
-
276
- if (input.type == 'checkbox') input.checked = false
277
- else input.value = this._defaultValue(input.type)
278
- }
279
-
280
- inputs[0].focus()
281
- }
282
-
283
- _delete(e) {
284
- var record = e.target.parentElement
285
- record.querySelector('[data-key]').value = ''
286
- this._build()
287
- }
288
- }
289
-
290
- customElements.define(ThingsEditorValueMap.is, ThingsEditorValueMap)