@things-factory/scene-form 5.0.0-alpha.9 → 5.0.0-zeta.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.
Files changed (67) hide show
  1. package/package.json +3 -3
  2. package/README.md +0 -15
  3. package/assets/button.png +0 -0
  4. package/assets/fieldset.png +0 -0
  5. package/assets/form.png +0 -0
  6. package/assets/icon-embed.png +0 -0
  7. package/assets/icon-radio-group.png +0 -0
  8. package/assets/icon-video.png +0 -0
  9. package/assets/iframe.png +0 -0
  10. package/assets/img.png +0 -0
  11. package/assets/input-checkbox.png +0 -0
  12. package/assets/input-color.png +0 -0
  13. package/assets/input-date.png +0 -0
  14. package/assets/input-email.png +0 -0
  15. package/assets/input-file.png +0 -0
  16. package/assets/input-number.png +0 -0
  17. package/assets/input-password.png +0 -0
  18. package/assets/input-radio.png +0 -0
  19. package/assets/input-range.png +0 -0
  20. package/assets/input-reset.png +0 -0
  21. package/assets/input-search.png +0 -0
  22. package/assets/input-submit.png +0 -0
  23. package/assets/input-text.png +0 -0
  24. package/assets/link.png +0 -0
  25. package/assets/select.png +0 -0
  26. package/assets/textarea.png +0 -0
  27. package/helps/scene/component/input.ko.md +0 -59
  28. package/helps/scene/component/input.md +0 -59
  29. package/helps/scene/component/input.zh.md +0 -58
  30. package/src/button.js +0 -34
  31. package/src/checkbox.js +0 -103
  32. package/src/div.js +0 -27
  33. package/src/embed.js +0 -47
  34. package/src/fieldset.js +0 -48
  35. package/src/form.js +0 -245
  36. package/src/iframe.js +0 -41
  37. package/src/img.js +0 -41
  38. package/src/index.js +0 -27
  39. package/src/input-color.js +0 -53
  40. package/src/input-date.js +0 -62
  41. package/src/input-file.js +0 -44
  42. package/src/input-number.js +0 -69
  43. package/src/input-submit.js +0 -39
  44. package/src/input.js +0 -204
  45. package/src/layout/grid-layout.js +0 -116
  46. package/src/link.js +0 -75
  47. package/src/radio-group.js +0 -70
  48. package/src/radio.js +0 -102
  49. package/src/select.js +0 -172
  50. package/src/soap-client.js +0 -213
  51. package/src/template.js +0 -99
  52. package/src/textarea.js +0 -85
  53. package/src/video.js +0 -139
  54. package/templates/index.js +0 -271
  55. package/test/basic-test.html +0 -61
  56. package/test/index.html +0 -20
  57. package/test/soap/broker.js +0 -22
  58. package/test/soap/sample.wsdl +0 -94
  59. package/test/soap/soap-client.js +0 -13
  60. package/test/soap/soap-server.js +0 -51
  61. package/test/unit/test-form.js +0 -33
  62. package/test/unit/util.js +0 -22
  63. package/things-scene.config.js +0 -5
  64. package/translations/en.json +0 -15
  65. package/translations/ko.json +0 -16
  66. package/translations/ms.json +0 -14
  67. package/translations/zh.json +0 -15
package/src/select.js DELETED
@@ -1,172 +0,0 @@
1
- /*
2
- * Copyright � HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'string',
12
- label: 'value',
13
- name: 'value'
14
- },
15
- {
16
- type: 'number',
17
- label: 'size',
18
- name: 'size'
19
- },
20
- {
21
- type: 'string',
22
- label: 'name',
23
- name: 'name'
24
- },
25
- {
26
- type: 'checkbox',
27
- label: 'submit-on-change',
28
- name: 'submitOnChange'
29
- },
30
- {
31
- type: 'checkbox',
32
- label: 'copy-value-to-data',
33
- name: 'copyValueToData'
34
- },
35
- {
36
- type: 'string',
37
- label: 'text-field',
38
- name: 'textField'
39
- },
40
- {
41
- type: 'string',
42
- label: 'value-field',
43
- name: 'valueField'
44
- },
45
- {
46
- type: 'options',
47
- label: 'options',
48
- name: 'options'
49
- }
50
- ],
51
- 'value-property': 'value'
52
- }
53
-
54
- import { Component, HTMLOverlayElement, warn } from '@hatiolab/things-scene'
55
-
56
- export default class Select extends HTMLOverlayElement {
57
- get nature() {
58
- return NATURE
59
- }
60
-
61
- buildOptions() {
62
- var { options = [], textField, valueField, value } = this.state
63
-
64
- if (!(options instanceof Array)) options = []
65
-
66
- this.element.textContent = ''
67
- var defaultValue
68
-
69
- options.map &&
70
- options
71
- .map((option, index) => {
72
- let text, value
73
-
74
- if (!textField) {
75
- text = option && (option['text'] || option)
76
- } else if (textField == '(index)') {
77
- text = index
78
- } else {
79
- // String.fromCharCode(160) == '&nbsp'
80
- text = (option && option[textField]) || String.fromCharCode(160)
81
- }
82
-
83
- if (!valueField) {
84
- value = option && (option['value'] || option)
85
- } else if (valueField == '(index)') {
86
- value = index
87
- } else {
88
- value = option && option[valueField]
89
- }
90
-
91
- if (defaultValue === undefined) {
92
- defaultValue = value
93
- }
94
-
95
- if (value == this.value) {
96
- defaultValue = this.value
97
- }
98
-
99
- return { text, value }
100
- })
101
- .forEach(option => {
102
- var el = document.createElement('option')
103
- el.value = typeof option.value == 'string' ? option.value : JSON.stringify(option.value)
104
- el.text = option.text
105
- this.element.appendChild(el)
106
- })
107
-
108
- if (defaultValue !== undefined && this.value !== defaultValue) {
109
- this.value = JSON.stringify(defaultValue)
110
- }
111
-
112
- if (this.element.value != this.value) {
113
- this.element.value = this.value
114
- this.element.dispatchEvent(new Event('change'))
115
- }
116
- }
117
-
118
- createElement() {
119
- super.createElement()
120
-
121
- this.buildOptions()
122
-
123
- var element = this.element
124
-
125
- element.value = this.get('value') || ''
126
-
127
- element.onchange = e => {
128
- this.set('value', element.value)
129
- }
130
- }
131
-
132
- setElementProperties(element) {
133
- var { size, name } = this.state
134
-
135
- element.size = size
136
- element.name = name
137
- }
138
-
139
- onchange(after, before) {
140
- super.onchange(after, before)
141
-
142
- if ('value' in after && this.element) {
143
- this.element.value = after.value
144
- if (this.get('copyValueToData')) {
145
- try {
146
- this.data = JSON.parse(after.value)
147
- } catch (e) {
148
- this.data = after.value
149
- }
150
- }
151
-
152
- if (this.get('submitOnChange') && this.element.form)
153
- this.element.form.dispatchEvent(
154
- new Event('submit', {
155
- cancelable: true
156
- })
157
- )
158
- }
159
-
160
- if ('options' in after) this.buildOptions()
161
- }
162
-
163
- get options() {
164
- return this.getState('options')
165
- }
166
-
167
- set options(options) {
168
- this.setState('options', options)
169
- }
170
- }
171
-
172
- Component.register('select', Select)
@@ -1,213 +0,0 @@
1
- /*
2
- * Copyright � HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'string',
12
- label: 'endpoint',
13
- name: 'endpoint'
14
- },
15
- {
16
- type: 'string',
17
- label: 'soap-action',
18
- name: 'soapAction'
19
- },
20
- {
21
- type: 'string',
22
- label: 'method',
23
- name: 'method'
24
- },
25
- {
26
- type: 'string',
27
- label: 'namespace',
28
- name: 'namespace'
29
- },
30
- {
31
- type: 'number',
32
- label: 'period',
33
- name: 'period'
34
- },
35
- {
36
- type: 'string',
37
- label: 'name',
38
- name: 'name'
39
- },
40
- {
41
- type: 'string',
42
- label: 'authorization',
43
- name: 'authorization'
44
- },
45
- {
46
- type: 'checkbox',
47
- label: 'with-credentials',
48
- name: 'withCredentials'
49
- },
50
- {
51
- type: 'checkbox',
52
- label: 'submit-on-load',
53
- name: 'submitOnLoad'
54
- },
55
- {
56
- type: 'checkbox',
57
- label: 'debug',
58
- name: 'debug'
59
- }
60
- ],
61
- 'value-property': 'endpoint'
62
- }
63
-
64
- import { Component, HTMLOverlayContainer } from '@hatiolab/things-scene'
65
- import { xml2js } from 'xml-js'
66
-
67
- export default class SoapClient extends HTMLOverlayContainer {
68
- dispose() {
69
- super.dispose()
70
- this._stopRepeater()
71
- }
72
-
73
- get tagName() {
74
- return 'form'
75
- }
76
-
77
- setElementProperties(form) {
78
- var { endpoint = '', name = '' } = this.state
79
-
80
- form.action = endpoint
81
- form.method = 'POST'
82
- form.name = name
83
- }
84
-
85
- get endpoint() {
86
- return this.state.endpoint
87
- }
88
-
89
- set endpoint(endpoint) {
90
- this.setState('endpoint', endpoint)
91
- this._startRepeater()
92
- }
93
-
94
- get period() {
95
- return this.state.period * 1000
96
- }
97
-
98
- set period(period) {
99
- this.setState('period', period)
100
- this._startRepeater()
101
- }
102
-
103
- _startRepeater() {
104
- this._stopRepeater()
105
-
106
- if (!this.app.isViewMode) return
107
-
108
- if (this.period) {
109
- this._repeatInterval = setInterval(this._submit.bind(this), this.period)
110
- }
111
- }
112
-
113
- _stopRepeater() {
114
- if (this._repeatInterval) clearInterval(this._repeatInterval)
115
- }
116
-
117
- _onload(e) {
118
- var result = e.target.response
119
- try {
120
- result = xml2js(result, {
121
- compact: true
122
- })
123
-
124
- if (this.state.debug) {
125
- console.log('[SOAP-RESULT]', result)
126
- }
127
-
128
- this.setState('data', result)
129
- } catch (e) {
130
- console.error(e)
131
- }
132
- }
133
-
134
- oncreate_element(form) {
135
- if (!this.app.isViewMode) return
136
-
137
- var _ = e => {
138
- e.preventDefault()
139
-
140
- var { endpoint, soapAction, method, namespace, debug } = this.state
141
-
142
- var xhr = new XMLHttpRequest()
143
-
144
- var params = [].filter
145
- .call(form.elements, el => {
146
- if (el.type == 'radio' || el.type == 'checkbox') return el.checked
147
- return true
148
- })
149
- .filter(el => {
150
- return !!el.name
151
- })
152
- .filter(el => {
153
- return !el.disabled
154
- })
155
- .map(el => {
156
- return `<${el.name}>${el.value}</${el.name}>`
157
- })
158
- .join('\n ')
159
-
160
- xhr.onloadend = this._onload.bind(this)
161
-
162
- xhr.open('POST', endpoint)
163
-
164
- xhr.setRequestHeader('Content-Type', 'text/xml;charset=UTF-8')
165
- xhr.setRequestHeader('SOAPAction', `${endpoint}#${soapAction}`)
166
-
167
- if (this.get('authorization')) xhr.setRequestHeader('Authorization', this.get('authorization'))
168
- if (this.get('withCredentials')) xhr.withCredentials = true
169
-
170
- let soapEnvelope = `
171
- <s:Envelope
172
- xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
173
- <s:Header/>
174
- <s:Body>
175
- <ns0:${method} xmlns:ns0="${namespace}">
176
- ${params}
177
- </ns0:${method}>
178
- </s:Body>
179
- </s:Envelope>
180
- `
181
-
182
- if (debug) {
183
- console.log('[SOAP-REQUEST-ENVELOPE]', soapEnvelope)
184
- }
185
-
186
- xhr.send(soapEnvelope)
187
-
188
- return false
189
- }
190
-
191
- form.onsubmit = _
192
-
193
- if (this.getState('submitOnLoad')) {
194
- setTimeout(this._submit.bind(this), 100)
195
- }
196
-
197
- this._startRepeater()
198
- }
199
-
200
- _submit() {
201
- this.element.dispatchEvent(
202
- new Event('submit', {
203
- cancelable: true
204
- })
205
- )
206
- }
207
-
208
- get nature() {
209
- return NATURE
210
- }
211
- }
212
-
213
- Component.register('soap-client', SoapClient)
package/src/template.js DELETED
@@ -1,99 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'textarea',
12
- label: 'template',
13
- name: 'template'
14
- },
15
- {
16
- type: 'string',
17
- label: 'apply-to',
18
- name: 'applyTo'
19
- }
20
- ]
21
- }
22
-
23
- import { Component, HTMLOverlayContainer, error } from '@hatiolab/things-scene'
24
-
25
- const FILLSTYLE = {
26
- type: 'pattern',
27
- fitPattern: true,
28
- image:
29
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAMFBMVEUAAAAdHR0AAAAAAAAAAAAREREODg4AAAATExMAAAAAAAAAAAAAAAAAAAAWFhYAAABtUS6TAAAAD3RSTlMArnboZDwVtVUHmMTU9CygGbkuAAABBklEQVR42u3Vy47DMAgFUMbE78f9/7+dqpVKFNUzwKqLnD0RvjGYbrdvF8tK9JBWieTRAO6tdQYyeWS8DfIYeONEdmlCLE+GOClkV3ASyC7gpPn+ouiODAdOeJkjHMAZF2OCE1eHK0BfkLXho5yU8XVsjKWKj7E1iya/44kvpcdLJa3LOdg3zIIr2fg7qEd4umYQXpJqiPZyVbQwsMXJtoq889CwkUknMT6ai5QOfBRcb4oY1fMmiBnV1TFk+YDooST6T30UM7a4h5hoS4r/wjnEusleLeiusPFKFwhXCx0GXHUjZBmrDJNRfQ2IYthDYv/grwmrqG1AtV0ShKuF+ONQ6Hb7Hr9EkkNRgwrYbAAAAABJRU5ErkJggg=='
30
- }
31
-
32
- export default class Template extends HTMLOverlayContainer {
33
- createElement() {
34
- super.createElement()
35
-
36
- this.element.value = this.get('value') || ''
37
- this.element.onchange = e => {
38
- this.set('value', this.element.value)
39
- }
40
- }
41
-
42
- dispose() {
43
- super.dispose()
44
-
45
- this.targets && this.targets.forEach(target => (target.shadowRoot.innerHTML = '<slot></slot>'))
46
- delete this.targets
47
- }
48
-
49
- /*
50
- * 컴포넌트의 생성 또는 속성 변화 시에 호출되며,
51
- * 그에 따른 html element의 반영이 필요한 부분을 구현한다.
52
- */
53
- setElementProperties(template) {
54
- template.innerHTML = this.state.template
55
- }
56
-
57
- /*
58
- * 컴포넌트가 ready 상태가 되거나, 컴포넌트의 속성이 변화될 시 setElementProperties 뒤에 호출된다.
59
- * 변화에 따른 기본적인 html 속성이 super.reposition()에서 진행되고, 그 밖의 작업이 필요할 때, 오버라이드 한다.
60
- */
61
- reposition() {
62
- super.reposition()
63
-
64
- var old_targets = this.targets || []
65
- var targets =
66
- this.rootModel && Array.prototype.slice.call(this.rootModel.overlay.querySelectorAll(this.state.applyTo))
67
-
68
- targets &&
69
- targets.forEach(target => {
70
- try {
71
- !target.shadowRoot && target.attachShadow({ mode: 'open' })
72
- target.shadowRoot.innerHTML = this.state.template
73
- } catch (e) {
74
- error(e)
75
- }
76
-
77
- let idx = old_targets.indexOf(target)
78
- if (idx >= 0) old_targets.splice(idx, 1)
79
- })
80
-
81
- old_targets.forEach(target => (target.shadowRoot.innerHTML = '<slot></slot>'))
82
-
83
- this.targets = targets
84
- }
85
-
86
- get tagName() {
87
- return 'template'
88
- }
89
-
90
- get fillStyle() {
91
- return FILLSTYLE
92
- }
93
-
94
- get nature() {
95
- return NATURE
96
- }
97
- }
98
-
99
- Component.register('template', Template)
package/src/textarea.js DELETED
@@ -1,85 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'string',
12
- label: 'name',
13
- name: 'name'
14
- },
15
- {
16
- type: 'string',
17
- label: 'value',
18
- name: 'text'
19
- },
20
- {
21
- type: 'string',
22
- label: 'placeholder',
23
- name: 'placeholder'
24
- },
25
- {
26
- type: 'checkbox',
27
- label: 'readonly',
28
- name: 'readonly'
29
- },
30
- {
31
- type: 'checkbox',
32
- label: 'disabled',
33
- name: 'disabled'
34
- },
35
- {
36
- type: 'number',
37
- label: 'max-length',
38
- name: 'maxlength'
39
- }
40
- ],
41
- 'value-property': 'text'
42
- }
43
-
44
- import { Component, HTMLOverlayElement } from '@hatiolab/things-scene'
45
-
46
- export default class TextArea extends HTMLOverlayElement {
47
- get nature() {
48
- return NATURE
49
- }
50
-
51
- get tagName() {
52
- return 'textarea'
53
- }
54
-
55
- createElement() {
56
- super.createElement()
57
-
58
- this.element.style.resize = 'none'
59
-
60
- /* element.property => component.property */
61
- this.element.onchange = e => {
62
- this.value = this.element.value
63
- }
64
- }
65
-
66
- /* component.property => element.property */
67
- setElementProperties(element) {
68
- var { name = '', placeholder = '', disabled, readonly, maxlength } = this.state
69
-
70
- try {
71
- element.name = name
72
- element.placeholder = placeholder
73
- element.disabled = disabled
74
- element.readonly = readonly
75
- element.maxlength = maxlength
76
- element.value = this.value
77
- } catch (e) {
78
- error(e)
79
- }
80
-
81
- this.data = this.value
82
- }
83
- }
84
-
85
- Component.register('textarea', TextArea)
package/src/video.js DELETED
@@ -1,139 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'string',
12
- label: 'src',
13
- name: 'src'
14
- },
15
- {
16
- type: 'checkbox',
17
- label: 'started',
18
- name: 'started'
19
- },
20
- {
21
- type: 'checkbox',
22
- label: 'controls',
23
- name: 'controls'
24
- }
25
- ],
26
- 'value-property': 'src'
27
- }
28
-
29
- import { Component, HTMLOverlayElement } from '@hatiolab/things-scene'
30
- import Hls from '!hls.js'
31
-
32
- export default class Video extends HTMLOverlayElement {
33
- async oncreate_element(video) {
34
- var { src, started } = this.state
35
-
36
- video.addEventListener('canplay', () => {
37
- this.started && video.play()
38
- })
39
-
40
- this.onchangesrc(src)
41
- this.onchangestarted(started)
42
- }
43
-
44
- dispose() {
45
- this.reset()
46
- super.dispose()
47
- }
48
-
49
- reset() {
50
- this._hlsSupporter && this._hlsSupporter.destroy()
51
- delete this._hlsSupporter
52
- }
53
-
54
- onchange(after, before) {
55
- super.onchange(after, before)
56
-
57
- 'src' in after && this.onchangesrc(after.src)
58
- 'started' in after && this.onchangestarted(after.started)
59
- }
60
-
61
- setElementProperties(video) {
62
- var { controls } = this.state
63
-
64
- if (controls) video.setAttribute('controls', true)
65
- else video.removeAttribute('controls')
66
- }
67
-
68
- onchangestarted(started) {
69
- var video = this.element
70
-
71
- if (started) {
72
- /*
73
- [ video.readyState ]
74
- 0 = HAVE_NOTHING - no information whether or not the audio/video is ready
75
- 1 = HAVE_METADATA - metadata for the audio/video is ready
76
- 2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond
77
- 3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
78
- 4 = HAVE_ENOUGH_DATA - enough data available to start playing
79
- */
80
- video.readyState == 4 && video.play()
81
- } else {
82
- video.pause()
83
- }
84
- }
85
-
86
- onchangesrc(src) {
87
- this.reset()
88
-
89
- var video = this.element
90
-
91
- if (!video) return
92
-
93
- video.src = src
94
-
95
- if (src.endsWith('.m3u8') && Hls.isSupported()) {
96
- // http-live-streaming protocol
97
- this._hlsSupporter = new Hls()
98
- this._hlsSupporter.loadSource(src)
99
- this._hlsSupporter.attachMedia(video)
100
-
101
- this._hlsSupporter.on(Hls.Events.MANIFEST_PARSED, () => {
102
- this.started && video.play()
103
- })
104
- // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
105
- // When the browser has built-in HLS support (check using `canPlayType`),
106
- // we can provide an HLS manifest(i.e. .m3u8 URL) directly to the video element throught the`src` property.
107
- // This is using the built-in support of the plain video element, without using hls.js.
108
- // [ sample ... ]
109
- // if (video.canPlayType('application/vnd.apple.mpegurl')) {
110
- // console.log('m3u8 supporting browser...')
111
- // video.addEventListener('canplay', () => {
112
- // video.play()
113
- // })
114
- // }
115
- }
116
- }
117
-
118
- get src() {
119
- return this.getState('src')
120
- }
121
-
122
- set src(src) {
123
- this.setState('src', src)
124
- }
125
-
126
- get started() {
127
- return this.getState('started')
128
- }
129
-
130
- set started(started) {
131
- this.setState('started', started)
132
- }
133
-
134
- get nature() {
135
- return NATURE
136
- }
137
- }
138
-
139
- Component.register('video', Video)