@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/input.js DELETED
@@ -1,204 +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
- type: 'checkbox',
42
- label: 'submit-on-change',
43
- name: 'submitOnChange'
44
- },
45
- {
46
- type: 'checkbox',
47
- label: 'spread-on-init',
48
- name: 'spreadOnInit'
49
- },
50
- {
51
- type: 'string',
52
- label: 'next-input',
53
- name: 'nextInput'
54
- },
55
- {
56
- type: 'checkbox',
57
- label: 'autofocus',
58
- name: 'autofocus'
59
- },
60
- {
61
- type: 'checkbox',
62
- label: 'alltime-focus',
63
- name: 'alltimeFocus'
64
- },
65
- {
66
- type: 'number',
67
- label: 'alltime-focus-pending',
68
- name: 'alltimeFocusPending',
69
- placeholder: 'milli-seconds'
70
- },
71
- {
72
- type: 'checkbox',
73
- label: 'hide-keyboard',
74
- name: 'hideKeyboard'
75
- }
76
- ],
77
- 'value-property': 'text',
78
- help: 'scene/component/input'
79
- }
80
-
81
- import { Component, HTMLOverlayElement, error } from '@hatiolab/things-scene'
82
-
83
- export default class Input extends HTMLOverlayElement {
84
- get nature() {
85
- return NATURE
86
- }
87
-
88
- get tagName() {
89
- return 'input'
90
- }
91
-
92
- get inputType() {
93
- return this.get('type').substr(6)
94
- }
95
-
96
- select() {
97
- this.element.select()
98
- }
99
-
100
- createElement() {
101
- super.createElement()
102
-
103
- /* element.property => component.property */
104
- this.element.onchange = e => {
105
- this.value = this.element.value
106
- // this.data = this.value
107
- }
108
-
109
- var alltimeFocus = this.get('alltimeFocus')
110
- var alltimeFocusPending = this.get('alltimeFocusPending')
111
- var hideKeyboard = this.get('hideKeyboard')
112
- if (this.app.isViewMode) {
113
- this.element.addEventListener('focusout', e => {
114
- if (alltimeFocus) {
115
- setTimeout(
116
- () => {
117
- this.element.select()
118
- },
119
- !alltimeFocusPending || alltimeFocusPending == 0 ? 1000 : alltimeFocusPending
120
- )
121
- }
122
- })
123
-
124
- this.element.addEventListener('focusin', e => {
125
- if(hideKeyboard){
126
- this.element.setAttribute('readonly',true)
127
- this.element.select()
128
- setTimeout(()=>{
129
- this.element.removeAttribute('readonly')
130
- },50)
131
- }
132
- })
133
- }
134
-
135
-
136
- var nextInput = this.get('nextInput')
137
- if (nextInput) {
138
- this.element.addEventListener('keypress', e => {
139
- if (e.keyCode == 13) {
140
- var n = this.root.findById(nextInput)
141
- n && n.select && n.select()
142
- }
143
- })
144
- }
145
-
146
- setTimeout(() => {
147
- this.get('autofocus') && this.element.select()
148
- }, 300)
149
- }
150
-
151
- /* component.property => element.property */
152
- setElementProperties(element) {
153
- var { name = '', placeholder = '', disabled, readonly, maxlength, spreadOnInit, nextInput, autofocus} = this.state
154
-
155
- try {
156
- element.type = this.inputType
157
- element.name = name
158
- element.placeholder = placeholder
159
- element.disabled = disabled
160
- element.readonly = readonly
161
- element.maxlength = maxlength
162
- element.value = this.value
163
- autofocus && element.setAttribute('autofocus', '')
164
- } catch (e) {
165
- error(e)
166
- }
167
-
168
- // if (spreadOnInit) {
169
- // this.data = this.value
170
- // }
171
- }
172
-
173
- onchange(after, before) {
174
- super.onchange(after, before)
175
- var { spreadOnInit, submitOnChange } = this.state
176
-
177
- var valueProperty = this.nature['value-property']
178
- if (valueProperty && valueProperty in after && this.element) {
179
- this.element.value = after.text
180
- if (!spreadOnInit) {
181
- this.data = this.value
182
- }
183
-
184
- if (submitOnChange && this.element.form)
185
- this.element.form.dispatchEvent(
186
- new Event('submit', {
187
- cancelable: true
188
- })
189
- )
190
- }
191
- }
192
- }
193
-
194
- ;[
195
- 'input',
196
- 'input-text',
197
- 'input-password',
198
- 'input-email',
199
- 'input-search',
200
- 'input-time',
201
- 'input-datetime-local',
202
- 'input-month',
203
- 'input-week'
204
- ].forEach(input => Component.register(input, Input))
@@ -1,116 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { Layout } from '@hatiolab/things-scene'
6
-
7
- var GridLayout = {
8
- reflow: function(container) {
9
- var layoutConfig = container.get('layoutConfig')
10
-
11
- var columns = (layoutConfig && layoutConfig.columns) || container.get('columns')
12
- var rows = (layoutConfig && layoutConfig.rows) || container.get('rows')
13
- var widths = (layoutConfig && layoutConfig.widths) || container.get('widths')
14
- var heights = (layoutConfig && layoutConfig.heights) || container.get('heights')
15
-
16
- var widths_sum = widths ? widths.filter((width, i) => i < columns).reduce((sum, width) => sum + width, 0) : columns
17
- var heights_sum = heights ? heights.filter((height, i) => i < rows).reduce((sum, height) => sum + height, 0) : rows
18
-
19
- var inside = container.textBounds
20
- var paddingLeft = container.get('paddingLeft') || 0
21
- var paddingTop = container.get('paddingTop') || 0
22
-
23
- var width_unit = inside.width / widths_sum
24
- var height_unit = inside.height / heights_sum
25
-
26
- var x = 0
27
- var y = 0
28
- var components = container.components
29
-
30
- components.forEach((component, idx) => {
31
- let w = widths ? widths[idx % columns] : 1
32
- let h = heights ? heights[Math.floor(idx / columns)] : 1
33
-
34
- let colspan = component.colspan || 1
35
- let wspan = 0
36
- while (--colspan > 0) wspan += widths ? widths[(idx + colspan) % columns] : 1
37
-
38
- let rowspan = component.rowspan || 1
39
- let hspan = 0
40
- while (--rowspan > 0) hspan += heights ? heights[Math.floor(idx / columns) + rowspan] : 1
41
-
42
- component.bounds = {
43
- left: paddingLeft + x,
44
- top: paddingTop + y,
45
- width: width_unit * (w + wspan),
46
- height: height_unit * (h + hspan)
47
- }
48
- component.set('rotation', 0)
49
-
50
- if (idx % columns == columns - 1) {
51
- x = 0
52
- y += h * height_unit
53
- } else {
54
- x += w * width_unit
55
- }
56
- })
57
- },
58
-
59
- capturables: function(container) {
60
- return container.components.filter(cell => {
61
- return !cell.merged
62
- })
63
- },
64
-
65
- drawables: function(container) {
66
- return container.components.filter(cell => {
67
- return !cell.merged
68
- })
69
- },
70
-
71
- isStuck: function(component) {
72
- return true
73
- },
74
-
75
- /*
76
- * 레이아웃별로, 키보드 방향키 등을 사용해서 네비게이션 할 수 있는 기능을 제공할 수 있다.
77
- * 하나의 컴포넌트만 선택되어있고, 키보드 이벤트가 발생했을 때 호출되게 된다.
78
- * keyNavigate 메쏘드가 정의되어 있지 않으면, 'Tab' 키에 대한 네비게이션만 작동한다.
79
- * 'Tab'키에 의한 네비게이션은 모든 레이아웃에 공통으로 적용된다.
80
- */
81
- keyNavigate: function(container, component, e) {
82
- var layoutConfig = container.get('layoutConfig')
83
-
84
- var columns = (layoutConfig && layoutConfig.columns) || container.get('columns')
85
- var rows = (layoutConfig && layoutConfig.rows) || container.get('rows')
86
-
87
- var { row, column } = container.getRowColumn(component)
88
-
89
- switch (e.code) {
90
- case 'ArrowUp':
91
- if (row > 0) return container.getAt((row - 1) * columns + column)
92
- break
93
- case 'ArrowDown':
94
- if (row < rows - 1) return container.getAt((row + 1) * columns + column)
95
- break
96
- case 'ArrowRight':
97
- if (column < columns - 1) return container.getAt(row * columns + column + 1)
98
- break
99
- case 'ArrowLeft':
100
- if (column > 0) return container.getAt(row * columns + column - 1)
101
- break
102
- default:
103
- return component
104
- }
105
- },
106
-
107
- /*
108
- * 하위 컴포넌트를 영역으로 선택하는 경우에, 바운드에 join만 되어도 선택된 것으로 판단하도록 한다.
109
- * joinType이 false이거나, 정의되어있지 않으면, 바운드에 포함되어야 선택된 것으로 판단한다.
110
- */
111
- joinType: true
112
- }
113
-
114
- Layout.register('grid', GridLayout)
115
-
116
- export default GridLayout
package/src/link.js DELETED
@@ -1,75 +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: 'href',
13
- name: 'href',
14
- property: 'href'
15
- },
16
- {
17
- type: 'select',
18
- label: 'target',
19
- name: 'target',
20
- property: {
21
- options: [
22
- {
23
- display: 'self',
24
- value: '_self'
25
- },
26
- {
27
- display: 'blank',
28
- value: '_blank'
29
- },
30
- {
31
- display: 'parent',
32
- value: '_parent'
33
- },
34
- {
35
- display: 'top',
36
- value: '_top'
37
- }
38
- ]
39
- }
40
- }
41
- ],
42
- 'value-property': 'href'
43
- }
44
-
45
- import { Component, HTMLOverlayContainer } from '@hatiolab/things-scene'
46
-
47
- export default class Link extends HTMLOverlayContainer {
48
- get tagName() {
49
- return 'a'
50
- }
51
-
52
- get href() {
53
- return this.get('href')
54
- }
55
-
56
- set href(href) {
57
- this.set('href', href)
58
- }
59
-
60
- setElementProperties(link) {
61
- var { href = '', target } = this.state
62
-
63
- if (link.href != href) link.href = href
64
-
65
- link.target = target
66
-
67
- if (this.components.length == 0) this.element.textContent = this.text || href
68
- }
69
-
70
- get nature() {
71
- return NATURE
72
- }
73
- }
74
-
75
- Component.register('link', Link)
@@ -1,70 +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: 'checkbox',
12
- label: 'submit-on-change',
13
- name: 'submitOnChange'
14
- },
15
- {
16
- type: 'checkbox',
17
- label: 'copy-value-to-data',
18
- name: 'copyValueToData'
19
- }
20
- ],
21
- 'value-property': 'value'
22
- }
23
-
24
- import { Component, HTMLOverlayContainer, warn } from '@hatiolab/things-scene'
25
- export default class RadioGroup extends HTMLOverlayContainer {
26
- get nature() {
27
- return NATURE
28
- }
29
-
30
- containable(component) {
31
- return component.model.type == 'input-radio'
32
- }
33
-
34
- setElementProperties(element) {
35
- element.onchange = () => {
36
- this.changeChecked()
37
- }
38
- }
39
-
40
- onchange(after, before) {
41
- super.onchange(after, before)
42
- if ('value' in after && this.element) {
43
- this.element.value = after.value
44
- if (this.get('copyValueToData')) {
45
- try {
46
- this.data = JSON.parse(after.value)
47
- } catch (e) {
48
- this.data = after.value
49
- }
50
- }
51
- if (this.get('submitOnChange') && this.element.parentElement.tagName == 'FORM')
52
- this.element.parentElement.dispatchEvent(
53
- new Event('submit', {
54
- cancelable: true
55
- })
56
- )
57
- }
58
- }
59
-
60
- changeChecked() {
61
- var allRadioList = this.element.querySelectorAll('input')
62
- var specificList = Array.prototype.slice.call(allRadioList).filter(e => e.name == this.element.id)
63
- if (specificList.length) {
64
- var checkedValue = specificList.filter(e => e.checked == true)
65
- this.set('value', checkedValue[0].value)
66
- }
67
- }
68
- }
69
-
70
- Component.register('radio-group', RadioGroup)
package/src/radio.js DELETED
@@ -1,102 +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: 'checked',
28
- name: 'checked'
29
- }
30
- ],
31
- 'value-property': 'value'
32
- }
33
-
34
- import Input from './input'
35
-
36
- import { Component } from '@hatiolab/things-scene'
37
-
38
- export default class Radio extends Input {
39
- get nature() {
40
- return NATURE
41
- }
42
-
43
- get tagName() {
44
- return 'input'
45
- }
46
-
47
- get inputType() {
48
- return 'radio'
49
- }
50
-
51
- createElement() {
52
- this.element = document.createElement('label')
53
- if (!this.element) return
54
-
55
- var input = document.createElement('input')
56
- this.element.appendChild(input)
57
-
58
- var text = document.createElement('p')
59
- text.style.display = 'inline'
60
- text.innerHTML = this.get('text')
61
- this.element.appendChild(text)
62
-
63
- this.setElementProperties(this.element)
64
-
65
- if (this.parent.isHTMLElement && this.parent.isHTMLElement()) this.parent.element.appendChild(this.element)
66
- else this.root.model_layer.overlay.appendChild(this.element)
67
-
68
- Component.reposition(this)
69
- this.oncreate_element && this.oncreate_element(this.element)
70
- }
71
-
72
- setElementProperties(element) {
73
- var eText = this.element.querySelector('text')
74
- var eInput = this.element.querySelector('input')
75
-
76
- var { text, checked, value } = this.state
77
-
78
- if (eText) {
79
- eText.textContent = text
80
- }
81
-
82
- if (eInput) {
83
- eInput.checked = checked
84
- eInput.value = value
85
- }
86
-
87
- super.setElementProperties(eInput)
88
- }
89
- postrender(context) {
90
- /* postrender() 함수는 거의 상속하지 않는다.
91
- * 텍스트, 효과, 애니메이션 등 컴포넌트 공통 기능에 대한 표현을 담당한다.
92
- */
93
- this.changeText(context)
94
- }
95
- changeText(context) {
96
- if (this.text && this.hasTextProperty && this.element.querySelector('p')) {
97
- this.element.querySelector('p').innerText = this.text
98
- }
99
- }
100
- }
101
-
102
- Component.register('input-radio', Radio)