@things-factory/modeller-ui 5.0.0-alpha.5 → 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 -156
  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,164 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@operato/i18n/ox-i18n.js'
6
- import './things-editor-angle-input'
7
-
8
- import { css, html, LitElement } from 'lit'
9
-
10
- class ThingsEditor3Dish extends LitElement {
11
- static get is() {
12
- return 'things-editor-3dish'
13
- }
14
-
15
- static get properties() {
16
- return {
17
- dimension: Object,
18
- /*
19
- * translate는 고유한 html element의 attribute이므로, property는 translatex로 한다.
20
- */
21
- translatex: Object,
22
- rotate: Object,
23
- scale: Object
24
- }
25
- }
26
-
27
- static get styles() {
28
- // FIXME grid-template-columns: repeat(4, 1fr); 이 왜 작동하지 않는지..
29
- return [
30
- css`
31
- :host {
32
- display: grid;
33
- /* grid-template-columns: repeat(4, 1fr); */
34
- grid-template-columns: 60px 60px 60px 60px;
35
- grid-gap: 5px;
36
- grid-auto-rows: minmax(24px, auto);
37
- }
38
-
39
- :host > * {
40
- grid-column: span 1;
41
- }
42
-
43
- label {
44
- text-align: right;
45
- }
46
-
47
- span {
48
- text-align: center;
49
- }
50
- `
51
- ]
52
- }
53
-
54
- firstUpdated() {
55
- this.shadowRoot.addEventListener('change', this._onChange.bind(this))
56
- }
57
-
58
- _onChange(e) {
59
- var element = e.target
60
- var id = element.id
61
- var prop = id.substr(1)
62
- var value = Number(element.value)
63
-
64
- switch (element.tagName) {
65
- case 'THINGS-EDITOR-ANGLE-INPUT':
66
- value = element.radian || 0
67
- break
68
- }
69
-
70
- switch (id) {
71
- case 'tx':
72
- case 'ty':
73
- case 'tz':
74
- this.dispatchEvent(
75
- new CustomEvent('translate-changed', {
76
- bubbles: true,
77
- composed: true,
78
- detail: {
79
- value: {
80
- ...this.translatex,
81
- [prop]: value
82
- }
83
- }
84
- })
85
- )
86
-
87
- break
88
- case 'rx':
89
- case 'ry':
90
- case 'rz':
91
- this.dispatchEvent(
92
- new CustomEvent('rotate-changed', {
93
- bubbles: true,
94
- composed: true,
95
- detail: {
96
- value: {
97
- ...this.rotate,
98
- [prop]: value
99
- }
100
- }
101
- })
102
- )
103
-
104
- break
105
- case 'sx':
106
- case 'sy':
107
- case 'sz':
108
- this.dispatchEvent(
109
- new CustomEvent('scale-changed', {
110
- bubbles: true,
111
- composed: true,
112
- detail: {
113
- value: {
114
- ...this.scale,
115
- [prop]: value
116
- }
117
- }
118
- })
119
- )
120
-
121
- break
122
-
123
- default:
124
- // dimension
125
- this.dispatchEvent(
126
- new CustomEvent('dimension-changed', {
127
- bubbles: true,
128
- composed: true,
129
- detail: {
130
- value: {
131
- ...this.dimension,
132
- [prop]: value
133
- }
134
- }
135
- })
136
- )
137
- }
138
- }
139
-
140
- render() {
141
- return html`
142
- <span></span> <span><ox-i18n msgid="label.x-axes"></ox-i18n></span>
143
- <span><ox-i18n msgid="label.y-axes"></ox-i18n></span>
144
- <span><ox-i18n msgid="label.z-axes"></ox-i18n></span>
145
-
146
- <label><ox-i18n msgid="label.dimension"></ox-i18n></label>
147
- <input type="number" id="dwidth" .value=${this.dimension && this.dimension.width} />
148
- <input type="number" id="dheight" .value=${this.dimension && this.dimension.height} />
149
- <input type="number" id="ddepth" .value=${this.dimension && this.dimension.depth} />
150
-
151
- <label><ox-i18n msgid="label.translate"></ox-i18n></label>
152
- <input type="number" id="tx" .value=${this.translatex && this.translatex.x} />
153
- <input type="number" id="ty" .value=${this.translatex && this.translatex.y} />
154
- <input type="number" id="tz" .value=${this.translatex && this.translatex.z} />
155
-
156
- <label><ox-i18n msgid="label.rotate"></ox-i18n></label>
157
- <things-editor-angle-input id="rx" .radian=${this.rotate && this.rotate.x}></things-editor-angle-input>
158
- <things-editor-angle-input id="ry" .radian=${this.rotate && this.rotate.y}></things-editor-angle-input>
159
- <things-editor-angle-input id="rz" .radian=${this.rotate && this.rotate.z}></things-editor-angle-input>
160
- `
161
- }
162
- }
163
-
164
- customElements.define(ThingsEditor3Dish.is, ThingsEditor3Dish)
@@ -1,69 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement, html, css } from 'lit'
6
-
7
- class ThingsEditorAngleInput extends LitElement {
8
- static get is() {
9
- return 'things-editor-angle-input'
10
- }
11
-
12
- static get properties() {
13
- return {
14
- radian: Number
15
- }
16
- }
17
-
18
- static get styles() {
19
- return [
20
- css`
21
- :host {
22
- display: inline-block;
23
- }
24
-
25
- input {
26
- width: 100%;
27
- height: 100%;
28
- box-sizing: border-box;
29
- border: 1px solid rgba(0, 0, 0, 0.2);
30
- }
31
- `
32
- ]
33
- }
34
-
35
- render() {
36
- return html`
37
- <input
38
- type="number"
39
- .value=${this._toDegree(this.radian)}
40
- @change="${e => this._onChangeValue(e)}"
41
- .placeholder=${this.placeholder}
42
- />
43
- `
44
- }
45
-
46
- get placeholder() {
47
- return this.getAttribute('placeholder') || '0°'
48
- }
49
-
50
- get input() {
51
- return this.shadowRoot.querySelector('input')
52
- }
53
-
54
- _onChangeValue(e) {
55
- this.radian = this._toRadian(this.input.value)
56
-
57
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
58
- }
59
-
60
- _toDegree(radian) {
61
- return Math.round(((radian || 0) * 180) / Math.PI)
62
- }
63
-
64
- _toRadian(degree) {
65
- return isNaN(Number(degree)) ? undefined : Number(degree) * (Math.PI / 180)
66
- }
67
- }
68
-
69
- customElements.define(ThingsEditorAngleInput.is, ThingsEditorAngleInput)
@@ -1,110 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/mwc-icon'
6
- import '@things-factory/attachment-ui'
7
-
8
- import { css, html, LitElement } from 'lit'
9
-
10
- import { i18next } from '@operato/i18n'
11
- import { openPopup } from '@operato/layout'
12
-
13
- export default class ThingsEditorAttachmentSelector extends LitElement {
14
- static get properties() {
15
- return {
16
- value: String,
17
- properties: Object
18
- }
19
- }
20
-
21
- static get styles() {
22
- return [
23
- css`
24
- :host {
25
- position: relative;
26
- display: inline-block;
27
- }
28
-
29
- input[type='text'] {
30
- box-sizing: border-box;
31
- width: 100%;
32
- height: 100%;
33
- border: 1px solid rgba(0, 0, 0, 0.2);
34
- }
35
-
36
- mwc-icon {
37
- position: absolute;
38
- top: 0;
39
- right: 3px;
40
- }
41
- `
42
- ]
43
- }
44
-
45
- render() {
46
- return html`
47
- <input id="text" type="text" .value=${this.value || ''} @change=${e => this._onInputChanged(e)} />
48
-
49
- <mwc-icon @click=${e => this.openSelector(e)}>${this.getIconByCategory()}</mwc-icon>
50
- `
51
- }
52
-
53
- getIconByCategory() {
54
- var { category } = this.properties || {}
55
- switch (category) {
56
- case 'audio':
57
- return 'library_music'
58
- case 'video':
59
- return 'video_library'
60
- case 'image':
61
- return 'image'
62
- case 'text':
63
- case 'application':
64
- default:
65
- return 'attachment'
66
- }
67
- }
68
-
69
- _onInputChanged(e) {
70
- this.value = e.target.value
71
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
72
- }
73
-
74
- openSelector() {
75
- if (this.popup) {
76
- delete this.popup
77
- }
78
-
79
- /*
80
- * 기존 설정된 이미지가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
81
- * 주의. value는 object일 수도 있고, string일 수도 있다.
82
- * string인 경우에는 해당 보드의 id로 해석한다.
83
- */
84
- var value = this.value || {}
85
- var { category = 'application' } = this.properties || {}
86
-
87
- var template = html`
88
- <attachment-selector
89
- .creatable=${true}
90
- .category="${category}"
91
- @attachment-selected=${async e => {
92
- var attachment = e.detail.attachment
93
- this.value = `/attachment/${attachment.path}`
94
-
95
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
96
-
97
- this.popup && this.popup.close()
98
- }}
99
- ></attachment-selector>
100
- `
101
-
102
- this.popup = openPopup(template, {
103
- backdrop: true,
104
- size: 'large',
105
- title: i18next.t('title.select attachment')
106
- })
107
- }
108
- }
109
-
110
- customElements.define('things-editor-attachment-selector', ThingsEditorAttachmentSelector)
@@ -1,93 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement, html, css } from 'lit'
6
-
7
- /**
8
- 여러 버튼 중에서 하나만 눌리거나, 모두 눌리지 않은 상태만을 갖는 라디오 형태의 버튼이다.
9
-
10
- Example:
11
-
12
- <things-editor-buttons-radio @change=${e => this._onChange(e)} value=${value}>
13
- <div data-value="top"></div>
14
- <div data-value="middle"></div>
15
- <div data-value="bottom"></div>
16
- </things-editor-buttons-radio>
17
- */
18
- class ThingsEditorButtonsRadio extends LitElement {
19
- static get is() {
20
- return 'things-editor-buttons-radio'
21
- }
22
-
23
- static get properties() {
24
- return {
25
- /**
26
- * `value`는 버튼의 눌린 상태를 값으로 갖는 속성이다.
27
- */
28
- value: Object,
29
- mandatory: Boolean
30
- }
31
- }
32
-
33
- static get styles() {
34
- return [
35
- css`
36
- :host {
37
- display: inline-block;
38
- }
39
- `
40
- ]
41
- }
42
-
43
- updated(changes) {
44
- changes.has('value') && this._onValueChanged(this.value)
45
- }
46
-
47
- render() {
48
- return html` <slot @click=${e => this._onTapButton(e)}></slot> `
49
- }
50
-
51
- get buttons() {
52
- return Array.from(this.querySelectorAll('*'))
53
- }
54
-
55
- _onValueChanged(value) {
56
- this.buttons.forEach(button => {
57
- if (value === button.getAttribute('data-value')) {
58
- button.setAttribute('active', '')
59
- } else {
60
- button.removeAttribute('active')
61
- }
62
- })
63
- }
64
-
65
- _onTapButton(e) {
66
- var target = e.target
67
-
68
- while (!target.hasAttribute('data-value') && target !== this) target = target.parentElement
69
-
70
- if (target === this) return
71
-
72
- var old = this.value
73
-
74
- if (!this.mandatory) {
75
- if (!target.getAttribute('active')) {
76
- this.value = target.getAttribute('data-value')
77
- target.setAttribute('active', '')
78
- } else {
79
- this.value = null
80
- target.removeAttribute('active')
81
- }
82
- } else {
83
- this.value = target.getAttribute('data-value')
84
- target.setAttribute('active', '')
85
- }
86
-
87
- if (old !== this.value) {
88
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
89
- }
90
- }
91
- }
92
-
93
- customElements.define(ThingsEditorButtonsRadio.is, ThingsEditorButtonsRadio)
@@ -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 CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
8
- import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
9
- import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
10
-
11
- import CodeMirror from 'codemirror'
12
- import 'codemirror/mode/javascript/javascript'
13
- import 'codemirror/mode/python/python'
14
- import 'codemirror/addon/display/fullscreen'
15
- import 'codemirror/addon/display/autorefresh'
16
-
17
- import { ScrollbarStyles } from '@things-factory/styles'
18
-
19
- /**
20
- WEB Component for code-mirror code editor.
21
-
22
- Example:
23
-
24
- <things-editor-code .value=${text} mode=${mode} tab-size="4" tab-as-space="true">
25
- </things-editor-code>
26
- */
27
- export default class ThingsEditorCode extends LitElement {
28
- static get is() {
29
- return 'things-editor-code'
30
- }
31
-
32
- static get properties() {
33
- return {
34
- /**
35
- * `value`는 에디터에서 작성중인 contents이다.
36
- */
37
- value: String,
38
- mode: String,
39
- tabSize: {
40
- attribute: 'tab-size'
41
- },
42
- tabAsSpace: {
43
- attribute: 'tab-as-space'
44
- }
45
- }
46
- }
47
-
48
- static get styles() {
49
- return [
50
- ScrollbarStyles,
51
- css`
52
- ${unsafeCSS(CodeMirrorStyle)}
53
- ${unsafeCSS(FullScreenStyle)}
54
- ${unsafeCSS(NightThemeStyle)}
55
- `,
56
- css`
57
- :host {
58
- display: block;
59
- position: relative;
60
- }
61
-
62
- textarea {
63
- display: block;
64
- height: 100%;
65
- width: 100%;
66
- resize: none;
67
- font-size: 16px;
68
- line-height: 20px;
69
- border: 0px;
70
- padding: 0px;
71
- }
72
- `
73
- ]
74
- }
75
-
76
- updated(change) {
77
- this._outside_changing = true
78
- if (change.has('value') && this.editor && !this._self_changing) {
79
- this.editor.setValue(this.value === undefined ? '' : String(this.value))
80
- this.editor.refresh()
81
- }
82
- this._outside_changing = false
83
- }
84
-
85
- render() {
86
- return html` <textarea></textarea> `
87
- }
88
-
89
- get editor() {
90
- if (!this._editor) {
91
- let textarea = this.shadowRoot.querySelector('textarea')
92
- let mode = this.mode || 'javascript'
93
- let tabSize = Number(this.tabSize) || 2
94
- let indentUnit = tabSize
95
- let lint = this.lint
96
- let hintOptions = this.hintOptions
97
- let tabAsSpace = (this.tabAsSpace || 'false').toLowerCase() == 'true'
98
- let tabCallback = tabAsSpace
99
- ? function (cm) {
100
- var spaces = Array(cm.getOption('indentUnit') + 1).join(' ')
101
- cm.replaceSelection(spaces, 'end', '+input')
102
- }
103
- : null
104
- if (textarea) {
105
- this._editor = CodeMirror.fromTextArea(textarea, {
106
- value: this.value,
107
- mode,
108
- lint,
109
- hintOptions,
110
- tabSize,
111
- indentUnit,
112
- lineNumbers: false,
113
- showCursorWhenSelecting: true,
114
- theme: 'night',
115
- extraKeys: {
116
- F11: function (cm) {
117
- cm.setOption('fullScreen', !cm.getOption('fullScreen'))
118
- },
119
- Esc: function (cm) {
120
- cm.setOption('fullScreen', !cm.getOption('fullScreen'))
121
- },
122
- // https://github.com/codemirror/CodeMirror/issues/988#issuecomment-37095621
123
- Tab: tabCallback
124
- },
125
- autoRefresh: {
126
- delay: 500
127
- }
128
- })
129
-
130
- this._editor.on('blur', e => {
131
- if (!this._changed) return
132
-
133
- this.value = e.getValue()
134
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
135
- })
136
-
137
- this._editor.on('change', async e => {
138
- this._self_changing = true
139
-
140
- this._changed = true
141
-
142
- await this.renderComplete
143
- this._self_changing = false
144
- })
145
- }
146
- }
147
-
148
- return this._editor
149
- }
150
- }
151
-
152
- customElements.define(ThingsEditorCode.is, ThingsEditorCode)