@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,152 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement, html, css, unsafeCSS } from 'lit'
6
-
7
- import './things-editor-code'
8
-
9
- /**
10
- WEB Component for code-mirror based data editor.
11
-
12
- Example:
13
-
14
- <things-editor-data value=${text}>
15
- </things-editor-data>
16
- */
17
- export default class ThingsEditorData extends LitElement {
18
- static get is() {
19
- return 'things-editor-data'
20
- }
21
-
22
- static get properties() {
23
- return {
24
- /**
25
- * `value`는 에디터에서 작성중인 contents이다.
26
- */
27
- value: Object
28
- }
29
- }
30
-
31
- static get styles() {
32
- return [
33
- css`
34
- :host {
35
- display: flex;
36
- flex-direction: column;
37
- position: relative;
38
- }
39
-
40
- div[datatype] {
41
- display: flex;
42
- align-items: center;
43
- padding: 2px;
44
- background-color: rgba(0, 0, 0, 0.08);
45
- font-size: small;
46
- }
47
-
48
- div[datatype] mwc-icon {
49
- margin-left: auto;
50
- }
51
-
52
- things-editor-code {
53
- flex: 1;
54
- max-width: 260px;
55
- overflow: auto;
56
- }
57
- `
58
- ]
59
- }
60
-
61
- render() {
62
- return html`
63
- <div datatype>
64
- <input type="radio"
65
- name="data-type"
66
- data-value="string"
67
- .checked=${typeof this.value == 'string'}
68
- @click=${e => this._setDataType('string')}
69
- >string</input>
70
- <input type="radio"
71
- name="data-type"
72
- data-value="number"
73
- .checked=${typeof this.value == 'number'}
74
- @click=${e => this._setDataType('number')}
75
- >number</input>
76
- <input type="radio"
77
- name="data-type"
78
- data-value="object"
79
- .checked=${typeof this.value == 'object'}
80
- @click=${e => this._setDataType('object')}
81
- >object</input>
82
- <mwc-icon @click=${e => this._clearData()} title="delete">delete_forever</mwc-icon>
83
- </div>
84
-
85
- <things-editor-code .value=${this._getData(this.value)} editor> </things-editor-code>
86
- `
87
- }
88
-
89
- firstUpdated() {
90
- this.renderRoot.addEventListener('change', e => {
91
- e.stopPropagation()
92
- if (e.target.hasAttribute('editor')) {
93
- this.value = e.target.value
94
- }
95
-
96
- const type = this.renderRoot.querySelector('input[name=data-type]:checked')?.getAttribute('data-value')
97
- this._setDataType(type)
98
- })
99
- }
100
-
101
- udpated(changes) {
102
- if (changes.has('value')) {
103
- this.value = this._getData(this.value)
104
- }
105
- }
106
-
107
- _setDataType(type) {
108
- if (typeof this.value !== type) {
109
- var value = this.value
110
-
111
- try {
112
- switch (type) {
113
- case 'string':
114
- this.value = String(value || '')
115
- break
116
- case 'number':
117
- if (!isNaN(value)) {
118
- this.value = Number(value)
119
- }
120
- break
121
- case 'object':
122
- this.value = eval('(' + value + ')')
123
- break
124
- }
125
- } catch (e) {
126
- console.log(e)
127
- }
128
- }
129
-
130
- this._onAfterValueChange()
131
- }
132
-
133
- _clearData() {
134
- this.value = undefined
135
- this._onAfterValueChange()
136
- }
137
-
138
- _getData(data) {
139
- return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1)
140
- }
141
-
142
- _onAfterValueChange() {
143
- this.dispatchEvent(
144
- new CustomEvent('change', {
145
- bubbles: true,
146
- composed: true
147
- })
148
- )
149
- }
150
- }
151
-
152
- customElements.define(ThingsEditorData.is, ThingsEditorData)
@@ -1,335 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@operato/i18n/ox-i18n.js'
6
- import '@polymer/paper-dropdown-menu/paper-dropdown-menu'
7
- import '@polymer/paper-listbox/paper-listbox'
8
- import '@polymer/paper-item/paper-item'
9
- import './things-editor-angle-input'
10
- import './things-editor-color-stops'
11
-
12
- import { css, html, LitElement } from 'lit'
13
-
14
- export default class ThingsEditorGradient extends LitElement {
15
- constructor() {
16
- super()
17
-
18
- this.value = {}
19
- }
20
-
21
- static get is() {
22
- return 'things-editor-gradient'
23
- }
24
-
25
- static get properties() {
26
- return {
27
- value: Object
28
- }
29
- }
30
-
31
- static get styles() {
32
- return [
33
- css`
34
- :host {
35
- display: grid;
36
-
37
- grid-template-columns: repeat(10, 1fr);
38
- grid-gap: 5px;
39
- grid-auto-rows: minmax(24px, auto);
40
-
41
- align-items: center;
42
- }
43
-
44
- :host > * {
45
- align-self: stretch;
46
- }
47
-
48
- :host > label {
49
- grid-column: span 2;
50
- text-align: right;
51
- text-transform: capitalize;
52
- align-self: center;
53
- }
54
-
55
- :host > .icon-only-label {
56
- grid-column: span 1;
57
- }
58
-
59
- :host > input,
60
- :host > [editors] {
61
- grid-column: span 8;
62
- }
63
-
64
- :host > select {
65
- grid-column: span 4;
66
- height: 100%;
67
- border: 1px solid rgba(0, 0, 0, 0.2);
68
- }
69
-
70
- :host > things-editor-angle-input {
71
- grid-column: span 3;
72
- }
73
-
74
- things-editor-color-stops {
75
- grid-column: span 10;
76
- }
77
-
78
- .host > input[type='checkbox'] {
79
- grid-column: 3 / 4;
80
- }
81
-
82
- .host > input[type='checkbox'] ~ label {
83
- grid-column: span 7;
84
- text-align: left;
85
- }
86
-
87
- [editors] > :not([active-selector]) {
88
- display: none;
89
- }
90
-
91
- [gradient-direction] {
92
- overflow: hidden;
93
- max-width: 210px;
94
- }
95
-
96
- [gradient-direction] paper-item {
97
- background: url(/assets/images/icon-editor-gradient-direction.png) 50% 0 no-repeat;
98
- min-height: 32px;
99
- padding: 3px 5px;
100
- width: 30px;
101
- float: left;
102
- }
103
-
104
- [gradient-direction] [name='lefttop-to-rightbottom'] {
105
- background-position: 50% 4px;
106
- }
107
-
108
- [gradient-direction] [name='left-top'] {
109
- background-position: 50% 4px;
110
- }
111
-
112
- [gradient-direction] [name='top-to-bottom'] {
113
- background-position: 50% -46px;
114
- }
115
-
116
- [gradient-direction] [name='righttop-to-leftbottom'] {
117
- background-position: 50% -96px;
118
- }
119
-
120
- [gradient-direction] [name='right-top'] {
121
- background-position: 50% -96px;
122
- }
123
-
124
- [gradient-direction] [name='right-to-left'] {
125
- background-position: 50% -146px;
126
- }
127
-
128
- [gradient-direction] [name='rightbottom-to-lefttop'] {
129
- background-position: 50% -196px;
130
- }
131
-
132
- [gradient-direction] [name='right-bottom'] {
133
- background-position: 50% -196px;
134
- }
135
-
136
- [gradient-direction] [name='bottom-to-top'] {
137
- background-position: 50% -246px;
138
- }
139
-
140
- [gradient-direction] [name='leftbottom-to-righttop'] {
141
- background-position: 50% -296px;
142
- }
143
-
144
- [gradient-direction] [name='left-bottom'] {
145
- background-position: 50% -296px;
146
- }
147
-
148
- [gradient-direction] [name='left-to-right'] {
149
- background-position: 50% -346px;
150
- }
151
-
152
- [gradient-direction] [name='center-to-corner'] {
153
- background-position: 50% -396px;
154
- }
155
-
156
- [gradient-direction] [name='center'] {
157
- background-position: 50% -396px;
158
- }
159
-
160
- [gradient-direction] paper-item[focused] {
161
- background-color: rgba(255, 246, 143, 0.5);
162
- }
163
-
164
- .icon-only-label {
165
- top: 0 !important;
166
- width: 30px !important;
167
- height: 24px;
168
- background: url(/assets/images/icon-properties-label.png) no-repeat;
169
- }
170
-
171
- .icon-only-label.color {
172
- background-position: 70% -198px;
173
- }
174
- `
175
- ]
176
- }
177
-
178
- firstUpdated() {
179
- this.shadowRoot.addEventListener('change', this._onChange.bind(this))
180
- }
181
-
182
- _onChange(e) {
183
- var element = e.target
184
- var key = element.getAttribute('value-key')
185
-
186
- if (!key) {
187
- return
188
- }
189
-
190
- var value
191
-
192
- switch (element.tagName) {
193
- case 'THINGS-EDITOR-ANGLE-INPUT':
194
- value = Number(element.radian) || 0
195
- break
196
-
197
- case 'INPUT':
198
- switch (element.type) {
199
- case 'checkbox':
200
- value = element.checked
201
- break
202
- case 'number':
203
- value = Number(element.value) || 0
204
- break
205
- case 'text':
206
- value = String(element.value)
207
- }
208
- break
209
-
210
- case 'PAPER-BUTTON':
211
- value = element.active
212
- break
213
-
214
- case 'PAPER-LISTBOX':
215
- value = element.selected
216
- break
217
-
218
- default:
219
- value = element.value
220
- break
221
- }
222
-
223
- if (key == 'direction') {
224
- key = 'rotation'
225
- value = this._convertDirectionToRotation(value)
226
- }
227
-
228
- this.value = {
229
- ...this.value,
230
- [key]: value
231
- }
232
-
233
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
234
- }
235
-
236
- render() {
237
- var selector = (this.value && this.value.type) || 'linear'
238
-
239
- return html`
240
- <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
241
- <select value-key="type" .value=${(this.value && this.value.type) || 'linear'}>
242
- <option>linear</option>
243
- <option>radial</option>
244
- </select>
245
-
246
- <label class="icon-only-label color"></label>
247
- <things-editor-angle-input value-key="rotation" .radian=${(this.value && this.value.rotation) || 0}>
248
- </things-editor-angle-input>
249
-
250
- <label> <ox-i18n msgid="label.direction">direction</ox-i18n> </label>
251
- <div editors>
252
- <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'linear'}>
253
- <paper-listbox
254
- @selected-changed="${e => this._onChange(e)}"
255
- value-key="direction"
256
- slot="dropdown-content"
257
- gradient-direction
258
- .selected=${(this.value && this.value.direction) || 'left-to-right'}
259
- attr-for-selected="name"
260
- >
261
- <paper-item name="lefttop-to-rightbottom"></paper-item>
262
- <paper-item name="top-to-bottom"></paper-item>
263
- <paper-item name="righttop-to-leftbottom"></paper-item>
264
- <paper-item name="right-to-left"></paper-item>
265
- <paper-item name="rightbottom-to-lefttop"></paper-item>
266
- <paper-item name="bottom-to-top"></paper-item>
267
- <paper-item name="leftbottom-to-righttop"></paper-item>
268
- <paper-item name="left-to-right"></paper-item>
269
- <paper-item name="center-to-corner"></paper-item>
270
- </paper-listbox>
271
- </paper-dropdown-menu>
272
-
273
- <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'radial'}>
274
- <paper-listbox
275
- @selected-changed="${e => this._onChange(e)}"
276
- value-key="center"
277
- slot="dropdown-content"
278
- gradient-direction
279
- .selected=${(this.value && this.value.center) || 'center'}
280
- attr-for-selected="name"
281
- >
282
- <paper-item name="center"></paper-item>
283
- <paper-item name="left-top"></paper-item>
284
- <paper-item name="right-top"></paper-item>
285
- <paper-item name="right-bottom"></paper-item>
286
- <paper-item name="left-bottom"></paper-item>
287
- </paper-listbox>
288
- </paper-dropdown-menu>
289
- </div>
290
-
291
- <things-editor-color-stops
292
- value-key="colorStops"
293
- type="gradient"
294
- .value=${(this.value && this.value.colorStops) || {}}
295
- >
296
- </things-editor-color-stops>
297
- `
298
- }
299
-
300
- _convertDirectionToRotation(direction) {
301
- var rotation
302
- switch (direction) {
303
- case 'lefttop-to-rightbottom':
304
- rotation = 45
305
- break
306
- case 'top-to-bottom':
307
- rotation = 90
308
- break
309
- case 'righttop-to-leftbottom':
310
- rotation = 135
311
- break
312
- case 'right-to-left':
313
- rotation = 180
314
- break
315
- case 'rightbottom-to-lefttop':
316
- rotation = 215
317
- break
318
- case 'bottom-to-top':
319
- rotation = 270
320
- break
321
- case 'leftbottom-to-righttop':
322
- rotation = 315
323
- break
324
- case 'left-to-right':
325
- rotation = 0
326
- break
327
- default:
328
- return
329
- }
330
-
331
- return (rotation / 360) * Math.PI * 2
332
- }
333
- }
334
-
335
- customElements.define(ThingsEditorGradient.is, ThingsEditorGradient)
@@ -1,173 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import 'codemirror/addon/display/fullscreen'
6
- import 'codemirror/addon/display/autorefresh'
7
- import 'codemirror/addon/hint/show-hint'
8
- import 'codemirror/addon/lint/lint'
9
- import 'codemirror-graphql/hint'
10
- import 'codemirror-graphql/lint'
11
- import 'codemirror-graphql/mode'
12
-
13
- import { GRAPHQL_URI, client } from '@things-factory/shell'
14
- import { LitElement, css, html, unsafeCSS } from 'lit'
15
- import { introspectSchema, wrapSchema } from '@graphql-tools/wrap'
16
-
17
- import CodeMirror from 'codemirror'
18
- import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
19
- import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
20
- import LintStyle from '!!text-loader!codemirror/addon/lint/lint.css'
21
- import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
22
- import ShowHintStyle from '!!text-loader!codemirror/addon/hint/show-hint.css'
23
- import { fetch } from 'cross-fetch'
24
- import { print } from 'graphql'
25
-
26
- /**
27
- WEB Component for code-mirror graphql editor.
28
-
29
- Example:
30
-
31
- <things-editor-graphql value=${text} link=${link}>
32
- </things-editor-graphql>
33
- */
34
- export default class ThingsEditorGraphql extends LitElement {
35
- static get is() {
36
- return 'things-editor-graphql'
37
- }
38
-
39
- static get properties() {
40
- return {
41
- /**
42
- * `value`는 에디터에서 작성중인 contents이다.
43
- */
44
- value: String,
45
- link: String
46
- }
47
- }
48
-
49
- static get styles() {
50
- return [
51
- css`
52
- ${unsafeCSS(CodeMirrorStyle)}
53
- ${unsafeCSS(FullScreenStyle)}
54
- ${unsafeCSS(NightThemeStyle)}
55
- ${unsafeCSS(LintStyle)}
56
- ${unsafeCSS(ShowHintStyle)}
57
- `,
58
- css`
59
- :host {
60
- display: block;
61
- position: relative;
62
- }
63
-
64
- textarea {
65
- display: block;
66
- height: 100%;
67
- width: 100%;
68
- resize: none;
69
- font-size: 16px;
70
- line-height: 20px;
71
- border: 0px;
72
- padding: 0px;
73
- }
74
- `
75
- ]
76
- }
77
-
78
- async updated(change) {
79
- this._outside_changing = true
80
- if ((!this._editor || change.has('value') || change.has('link')) && !this._self_changing) {
81
- if (change.has('link')) {
82
- this._editor = null
83
- }
84
- ;(await this.getEditor()).setValue(this.value === undefined ? '' : String(this.value))
85
- // ;(await this.getEditor()).refresh()
86
- }
87
- this._outside_changing = false
88
- }
89
-
90
- render() {
91
- return html` <textarea></textarea> `
92
- }
93
-
94
- async getSchema() {
95
- const executor = async ({ document, variables }) => {
96
- const query = print(document)
97
- const uri = this.link || GRAPHQL_URI
98
-
99
- const fetchResult = await fetch(uri, {
100
- method: 'POST',
101
- headers: {
102
- 'Content-Type': 'application/json'
103
- },
104
- body: JSON.stringify({ query, variables })
105
- })
106
- return fetchResult.json()
107
- }
108
-
109
- return await wrapSchema({
110
- schema: await introspectSchema(executor),
111
- executor
112
- })
113
- }
114
-
115
- async getEditor() {
116
- if (!this._editor) {
117
- try {
118
- var schema = await this.getSchema()
119
- } catch (err) {
120
- console.error(err)
121
- }
122
-
123
- let textarea = this.shadowRoot.querySelector('textarea')
124
- if (textarea) {
125
- this._editor = CodeMirror.fromTextArea(textarea, {
126
- value: this.value,
127
- mode: 'graphql',
128
- lint: {
129
- schema
130
- },
131
- hintOptions: {
132
- schema
133
- },
134
- tabSize: 2,
135
- lineNumbers: false,
136
- showCursorWhenSelecting: true,
137
- theme: 'night',
138
- extraKeys: {
139
- F11: function (cm) {
140
- cm.setOption('fullScreen', !cm.getOption('fullScreen'))
141
- },
142
- Esc: function (cm) {
143
- cm.setOption('fullScreen', !cm.getOption('fullScreen'))
144
- }
145
- },
146
- autoRefresh: {
147
- delay: 500
148
- }
149
- })
150
-
151
- this._editor.on('blur', e => {
152
- if (!this._changed) return
153
-
154
- this.value = e.getValue()
155
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
156
- })
157
-
158
- this._editor.on('change', async e => {
159
- this._self_changing = true
160
-
161
- this._changed = true
162
-
163
- await this.renderComplete
164
- this._self_changing = false
165
- })
166
- }
167
- }
168
-
169
- return this._editor
170
- }
171
- }
172
-
173
- customElements.define(ThingsEditorGraphql.is, ThingsEditorGraphql)