x4js 1.5.17 → 1.5.20

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 (242) hide show
  1. package/lib/{README.md → README.txt} +0 -0
  2. package/lib/cjs/index.js +39 -103
  3. package/lib/cjs/index.js.map +7 -0
  4. package/lib/esm/index.mjs +39 -87
  5. package/lib/esm/index.mjs.map +7 -0
  6. package/lib/{license.md → licence.md} +0 -0
  7. package/lib/src/MIT-license.md +14 -0
  8. package/lib/{types/action.d.ts → src/action.ts} +64 -33
  9. package/lib/src/alpha.jpg +0 -0
  10. package/lib/src/app_sockets.ts +81 -0
  11. package/lib/src/application.ts +251 -0
  12. package/lib/src/autocomplete.ts +197 -0
  13. package/lib/src/base64.ts +166 -0
  14. package/lib/src/base_component.ts +152 -0
  15. package/lib/src/button.ts +355 -0
  16. package/lib/src/calendar.ts +328 -0
  17. package/lib/src/canvas.ts +505 -0
  18. package/lib/src/cardview.ts +227 -0
  19. package/lib/src/checkbox.ts +188 -0
  20. package/lib/src/color.ts +752 -0
  21. package/lib/src/colorpicker.ts +1639 -0
  22. package/lib/src/combobox.ts +465 -0
  23. package/lib/src/component.ts +2329 -0
  24. package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
  25. package/lib/src/datastore.ts +1322 -0
  26. package/lib/src/dialog.ts +656 -0
  27. package/lib/src/dom_events.ts +315 -0
  28. package/lib/src/drag_manager.ts +199 -0
  29. package/lib/src/drawtext.ts +355 -0
  30. package/lib/src/fileupload.ts +213 -0
  31. package/lib/src/form.ts +375 -0
  32. package/lib/src/formatters.ts +105 -0
  33. package/lib/src/gridview.ts +1185 -0
  34. package/lib/src/i18n.ts +346 -0
  35. package/lib/src/icon.ts +335 -0
  36. package/lib/src/image.ts +204 -0
  37. package/lib/src/index.ts +89 -0
  38. package/lib/src/input.ts +249 -0
  39. package/lib/src/label.ts +128 -0
  40. package/lib/src/layout.ts +430 -0
  41. package/lib/src/link.ts +86 -0
  42. package/lib/src/listview.ts +765 -0
  43. package/lib/{esm/md5.js → src/md5.ts} +438 -403
  44. package/lib/src/menu.ts +425 -0
  45. package/lib/src/messagebox.ts +224 -0
  46. package/lib/src/panel.ts +86 -0
  47. package/lib/src/popup.ts +494 -0
  48. package/lib/src/property_editor.ts +337 -0
  49. package/lib/src/radiobtn.ts +197 -0
  50. package/lib/src/rating.ts +135 -0
  51. package/lib/src/request.ts +300 -0
  52. package/lib/src/router.ts +185 -0
  53. package/lib/src/settings.ts +77 -0
  54. package/lib/src/sidebarview.ts +103 -0
  55. package/lib/src/spreadsheet.ts +1449 -0
  56. package/lib/src/styles.ts +343 -0
  57. package/lib/src/svgcomponent.ts +577 -0
  58. package/lib/src/tabbar.ts +151 -0
  59. package/lib/src/tabview.ts +110 -0
  60. package/lib/src/textarea.ts +235 -0
  61. package/lib/src/textedit.ts +544 -0
  62. package/lib/src/toaster.ts +80 -0
  63. package/lib/src/tools.ts +1473 -0
  64. package/lib/src/tooltips.ts +191 -0
  65. package/lib/src/treeview.ts +716 -0
  66. package/lib/{esm/version.js → src/version.ts} +30 -29
  67. package/lib/{styles → src}/x4.less +0 -0
  68. package/lib/src/x4dom.ts +57 -0
  69. package/lib/src/x4events.ts +585 -0
  70. package/lib/src/x4react.ts +90 -0
  71. package/package.json +52 -49
  72. package/lib/cjs/action.js +0 -58
  73. package/lib/cjs/app_sockets.js +0 -74
  74. package/lib/cjs/application.js +0 -182
  75. package/lib/cjs/autocomplete.js +0 -155
  76. package/lib/cjs/base_component.js +0 -124
  77. package/lib/cjs/button.js +0 -263
  78. package/lib/cjs/calendar.js +0 -254
  79. package/lib/cjs/canvas.js +0 -361
  80. package/lib/cjs/cardview.js +0 -161
  81. package/lib/cjs/checkbox.js +0 -139
  82. package/lib/cjs/color.js +0 -591
  83. package/lib/cjs/colorpicker.js +0 -1468
  84. package/lib/cjs/combobox.js +0 -349
  85. package/lib/cjs/component.js +0 -1719
  86. package/lib/cjs/datastore.js +0 -985
  87. package/lib/cjs/dialog.js +0 -478
  88. package/lib/cjs/dom_events.js +0 -30
  89. package/lib/cjs/drag_manager.js +0 -145
  90. package/lib/cjs/drawtext.js +0 -276
  91. package/lib/cjs/fileupload.js +0 -167
  92. package/lib/cjs/form.js +0 -304
  93. package/lib/cjs/formatters.js +0 -90
  94. package/lib/cjs/gridview.js +0 -881
  95. package/lib/cjs/i18n.js +0 -266
  96. package/lib/cjs/icon.js +0 -272
  97. package/lib/cjs/image.js +0 -157
  98. package/lib/cjs/input.js +0 -174
  99. package/lib/cjs/label.js +0 -95
  100. package/lib/cjs/layout.js +0 -322
  101. package/lib/cjs/link.js +0 -64
  102. package/lib/cjs/listview.js +0 -546
  103. package/lib/cjs/md5.js +0 -403
  104. package/lib/cjs/menu.js +0 -301
  105. package/lib/cjs/messagebox.js +0 -177
  106. package/lib/cjs/panel.js +0 -68
  107. package/lib/cjs/popup.js +0 -383
  108. package/lib/cjs/property_editor.js +0 -252
  109. package/lib/cjs/radiobtn.js +0 -140
  110. package/lib/cjs/rating.js +0 -102
  111. package/lib/cjs/request.js +0 -246
  112. package/lib/cjs/router.js +0 -139
  113. package/lib/cjs/settings.js +0 -69
  114. package/lib/cjs/sidebarview.js +0 -82
  115. package/lib/cjs/spreadsheet.js +0 -1084
  116. package/lib/cjs/styles.js +0 -275
  117. package/lib/cjs/svgcomponent.js +0 -447
  118. package/lib/cjs/tabbar.js +0 -111
  119. package/lib/cjs/tabview.js +0 -85
  120. package/lib/cjs/textarea.js +0 -165
  121. package/lib/cjs/textedit.js +0 -415
  122. package/lib/cjs/toaster.js +0 -64
  123. package/lib/cjs/tools.js +0 -1197
  124. package/lib/cjs/tooltips.js +0 -157
  125. package/lib/cjs/treeview.js +0 -535
  126. package/lib/cjs/version.js +0 -32
  127. package/lib/cjs/x4dom.js +0 -32
  128. package/lib/cjs/x4events.js +0 -384
  129. package/lib/cjs/x4react.js +0 -72
  130. package/lib/esm/action.js +0 -53
  131. package/lib/esm/app_sockets.js +0 -70
  132. package/lib/esm/application.js +0 -184
  133. package/lib/esm/autocomplete.js +0 -155
  134. package/lib/esm/base_component.js +0 -107
  135. package/lib/esm/button.js +0 -257
  136. package/lib/esm/calendar.js +0 -249
  137. package/lib/esm/canvas.js +0 -358
  138. package/lib/esm/cardview.js +0 -159
  139. package/lib/esm/checkbox.js +0 -134
  140. package/lib/esm/color.js +0 -588
  141. package/lib/esm/colorpicker.js +0 -1475
  142. package/lib/esm/combobox.js +0 -351
  143. package/lib/esm/component.js +0 -1711
  144. package/lib/esm/datastore.js +0 -990
  145. package/lib/esm/dialog.js +0 -490
  146. package/lib/esm/drag_manager.js +0 -147
  147. package/lib/esm/drawtext.js +0 -271
  148. package/lib/esm/fileupload.js +0 -163
  149. package/lib/esm/form.js +0 -304
  150. package/lib/esm/formatters.js +0 -81
  151. package/lib/esm/gridview.js +0 -889
  152. package/lib/esm/i18n.js +0 -257
  153. package/lib/esm/icon.js +0 -261
  154. package/lib/esm/image.js +0 -154
  155. package/lib/esm/input.js +0 -182
  156. package/lib/esm/label.js +0 -90
  157. package/lib/esm/layout.js +0 -310
  158. package/lib/esm/link.js +0 -59
  159. package/lib/esm/listview.js +0 -534
  160. package/lib/esm/menu.js +0 -300
  161. package/lib/esm/messagebox.js +0 -161
  162. package/lib/esm/panel.js +0 -65
  163. package/lib/esm/popup.js +0 -379
  164. package/lib/esm/property_editor.js +0 -251
  165. package/lib/esm/radiobtn.js +0 -136
  166. package/lib/esm/rating.js +0 -97
  167. package/lib/esm/request.js +0 -224
  168. package/lib/esm/router.js +0 -136
  169. package/lib/esm/settings.js +0 -66
  170. package/lib/esm/sidebarview.js +0 -79
  171. package/lib/esm/spreadsheet.js +0 -1097
  172. package/lib/esm/styles.js +0 -270
  173. package/lib/esm/svgcomponent.js +0 -450
  174. package/lib/esm/tabbar.js +0 -107
  175. package/lib/esm/tabview.js +0 -83
  176. package/lib/esm/textarea.js +0 -160
  177. package/lib/esm/textedit.js +0 -412
  178. package/lib/esm/toaster.js +0 -62
  179. package/lib/esm/tools.js +0 -1158
  180. package/lib/esm/tooltips.js +0 -153
  181. package/lib/esm/treeview.js +0 -527
  182. package/lib/esm/x4dom.js +0 -29
  183. package/lib/esm/x4events.js +0 -376
  184. package/lib/esm/x4react.js +0 -71
  185. package/lib/types/app_sockets.d.ts +0 -29
  186. package/lib/types/application.d.ts +0 -104
  187. package/lib/types/autocomplete.d.ts +0 -58
  188. package/lib/types/base_component.d.ts +0 -88
  189. package/lib/types/button.d.ts +0 -151
  190. package/lib/types/calendar.d.ts +0 -82
  191. package/lib/types/canvas.d.ts +0 -92
  192. package/lib/types/cardview.d.ts +0 -87
  193. package/lib/types/checkbox.d.ts +0 -77
  194. package/lib/types/color.d.ts +0 -148
  195. package/lib/types/colorpicker.d.ts +0 -107
  196. package/lib/types/combobox.d.ts +0 -107
  197. package/lib/types/component.d.ts +0 -601
  198. package/lib/types/datastore.d.ts +0 -396
  199. package/lib/types/dialog.d.ts +0 -175
  200. package/lib/types/dom_events.d.ts +0 -302
  201. package/lib/types/drag_manager.d.ts +0 -54
  202. package/lib/types/drawtext.d.ts +0 -48
  203. package/lib/types/fileupload.d.ts +0 -64
  204. package/lib/types/form.d.ts +0 -133
  205. package/lib/types/formatters.d.ts +0 -35
  206. package/lib/types/gridview.d.ts +0 -175
  207. package/lib/types/i18n.d.ts +0 -73
  208. package/lib/types/icon.d.ts +0 -64
  209. package/lib/types/image.d.ts +0 -55
  210. package/lib/types/index.d.ts +0 -84
  211. package/lib/types/input.d.ts +0 -91
  212. package/lib/types/label.d.ts +0 -58
  213. package/lib/types/layout.d.ts +0 -87
  214. package/lib/types/link.d.ts +0 -50
  215. package/lib/types/listview.d.ts +0 -178
  216. package/lib/types/md5.d.ts +0 -61
  217. package/lib/types/menu.d.ts +0 -130
  218. package/lib/types/messagebox.d.ts +0 -69
  219. package/lib/types/panel.d.ts +0 -47
  220. package/lib/types/popup.d.ts +0 -75
  221. package/lib/types/property_editor.d.ts +0 -71
  222. package/lib/types/radiobtn.d.ts +0 -73
  223. package/lib/types/rating.d.ts +0 -53
  224. package/lib/types/request.d.ts +0 -52
  225. package/lib/types/router.d.ts +0 -42
  226. package/lib/types/settings.d.ts +0 -37
  227. package/lib/types/sidebarview.d.ts +0 -49
  228. package/lib/types/spreadsheet.d.ts +0 -222
  229. package/lib/types/styles.d.ts +0 -85
  230. package/lib/types/svgcomponent.d.ts +0 -215
  231. package/lib/types/tabbar.d.ts +0 -58
  232. package/lib/types/tabview.d.ts +0 -49
  233. package/lib/types/textarea.d.ts +0 -77
  234. package/lib/types/textedit.d.ts +0 -123
  235. package/lib/types/toaster.d.ts +0 -42
  236. package/lib/types/tools.d.ts +0 -394
  237. package/lib/types/tooltips.d.ts +0 -46
  238. package/lib/types/treeview.d.ts +0 -144
  239. package/lib/types/version.d.ts +0 -29
  240. package/lib/types/x4dom.d.ts +0 -49
  241. package/lib/types/x4events.d.ts +0 -269
  242. package/lib/types/x4react.d.ts +0 -41
package/lib/esm/input.js DELETED
@@ -1,182 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file input.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Component } from './component';
30
- /**
31
- * base class for elements implementing an input
32
- * CARE derived classes must set this.ui.input
33
- */
34
- export class Input extends Component {
35
- constructor(props) {
36
- super(props);
37
- }
38
- /** @ignore */
39
- render(props) {
40
- this.setTag('input');
41
- this._setTabIndex(props.tabIndex);
42
- this.setAttributes({
43
- value: props.value,
44
- type: props.type || 'text',
45
- name: props.name,
46
- placeholder: props.placeHolder,
47
- autofocus: props.autoFocus,
48
- readonly: props.readOnly,
49
- autocomplete: 'new-password',
50
- tabIndex: props.tabIndex,
51
- spellcheck: props.spellcheck === false ? 'false' : undefined,
52
- min: props.min,
53
- max: props.max,
54
- ...props.attrs
55
- });
56
- this.m_props.autosel = props.autosel ?? true;
57
- if (props.uppercase) {
58
- this.setStyleValue('textTransform', 'uppercase');
59
- }
60
- if (this.m_props.autosel) {
61
- this.setDomEvent("focus", () => {
62
- this.selectAll();
63
- });
64
- }
65
- }
66
- getType() {
67
- return this.m_props.type;
68
- }
69
- /**
70
- * return the current editor value
71
- */
72
- get value() {
73
- if (this.dom) {
74
- this.m_props.value = this.dom.value;
75
- }
76
- if (this.m_props.uppercase) {
77
- let upper = this.m_props.value.toUpperCase(); // todo: locale ?
78
- if (this.dom && upper != this.m_props.value) {
79
- this.dom.value = upper; // update the input
80
- }
81
- this.m_props.value = upper;
82
- }
83
- return this.m_props.value;
84
- }
85
- /**
86
- * Change the editor value
87
- * @param value - new value to set
88
- */
89
- set value(value) {
90
- this.m_props.value = value;
91
- if (this.dom) {
92
- this.dom.value = value;
93
- }
94
- }
95
- getStoreValue() {
96
- if (this.m_props.value_hook) {
97
- return this.m_props.value_hook.get();
98
- }
99
- else {
100
- let type = this.getAttribute('type');
101
- if (type) {
102
- type = type.toLowerCase();
103
- }
104
- let value, dom = this.dom;
105
- if (type === "file") {
106
- value = [];
107
- let files = dom.files;
108
- for (let file = 0; file < files.length; file++) {
109
- value.push(files[file].name);
110
- }
111
- }
112
- else if (type === 'checkbox') {
113
- if (dom.checked) {
114
- value = 1;
115
- }
116
- else {
117
- value = 0;
118
- }
119
- }
120
- else if (type === 'radio') {
121
- if (dom.checked) {
122
- value = this.value;
123
- }
124
- }
125
- else if (type === 'date') {
126
- debugger;
127
- }
128
- else {
129
- value = this.value;
130
- }
131
- return value;
132
- }
133
- }
134
- setStoreValue(v) {
135
- if (this.m_props.value_hook) {
136
- return this.m_props.value_hook.set(v);
137
- }
138
- else {
139
- let type = this.getAttribute('type'), dom = this.dom;
140
- if (type) {
141
- type = type.toLowerCase();
142
- }
143
- if (type === 'checkbox') {
144
- let newval = v !== null && v !== '0' && v !== 0 && v !== false;
145
- if (newval !== dom.checked) {
146
- dom.setAttribute('checked', '' + newval);
147
- dom.dispatchEvent(new Event('change'));
148
- }
149
- }
150
- else {
151
- this.value = v;
152
- }
153
- }
154
- }
155
- set readOnly(ro) {
156
- this.setAttribute('readonly', ro);
157
- }
158
- /**
159
- * select all the text
160
- */
161
- selectAll() {
162
- this.dom.select();
163
- }
164
- /**
165
- * select a part of the text
166
- * @param start
167
- * @param length
168
- */
169
- select(start, length = 9999) {
170
- this.dom.setSelectionRange(start, start + length);
171
- }
172
- /**
173
- * get the selection as { start, length }
174
- */
175
- getSelection() {
176
- let idom = this.dom;
177
- return {
178
- start: idom.selectionStart,
179
- length: idom.selectionEnd - idom.selectionStart,
180
- };
181
- }
182
- }
package/lib/esm/label.js DELETED
@@ -1,90 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file label.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Component } from './component';
30
- import { escapeHtml, HtmlString } from './tools';
31
- import { Icon } from './icon';
32
- /**
33
- * Standard label
34
- */
35
- export class Label extends Component {
36
- constructor(param) {
37
- if (typeof (param) === 'string' || param instanceof HtmlString) {
38
- super({ text: param });
39
- }
40
- else {
41
- super(param);
42
- }
43
- }
44
- /** @ignore */
45
- render(props) {
46
- let text = this.m_props.text;
47
- if (this.m_props.multiline && !(text instanceof HtmlString)) {
48
- text = new HtmlString(escapeHtml(text, true));
49
- }
50
- if (!props.icon) {
51
- this.setContent(text);
52
- }
53
- else {
54
- this.setTag('span');
55
- this.addClass('@hlayout');
56
- this.setContent([
57
- new Icon({ icon: props.icon }),
58
- new Component({ content: text, ref: 'text' })
59
- ]);
60
- }
61
- this.addClass(props.align ?? 'left');
62
- }
63
- /**
64
- * change the displayed text
65
- * @param text - new text
66
- */
67
- set text(txt) {
68
- let props = this.m_props;
69
- if (props.text !== txt) {
70
- props.text = txt;
71
- let text = this.m_props.text;
72
- if (this.m_props.multiline && !(text instanceof HtmlString)) {
73
- text = new HtmlString(escapeHtml(text, true));
74
- }
75
- if (this.dom) {
76
- let comp = this;
77
- if (this.m_props.icon) {
78
- comp = this.itemWithRef('text');
79
- }
80
- comp.setContent(text);
81
- }
82
- }
83
- }
84
- /**
85
- *
86
- */
87
- get text() {
88
- return this.m_props.text;
89
- }
90
- }
package/lib/esm/layout.js DELETED
@@ -1,310 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file layout.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
- import { Component, Container } from './component';
30
- import { isArray } from './tools';
31
- // ============================================================================
32
- // [ABSLAYOUT]
33
- // ============================================================================
34
- export class AbsLayout extends Container {
35
- }
36
- // ============================================================================
37
- // [HLAYOUT]
38
- // ============================================================================
39
- export class HLayout extends Container {
40
- }
41
- // ============================================================================
42
- // [VLAYOUT]
43
- // ============================================================================
44
- export class VLayout extends Container {
45
- }
46
- export class AutoLayout extends Container {
47
- constructor(props) {
48
- super(props);
49
- this.setDomEvent('sizechange', () => this._updateLayout());
50
- }
51
- componentCreated() {
52
- super.componentCreated();
53
- this._updateLayout();
54
- }
55
- _updateLayout() {
56
- let horz = this.m_props.defaultLayout == 'horizontal' ? true : false;
57
- if (this.m_props.switchSize <= 0 && window.screen.height > window.screen.width) {
58
- horz = !horz;
59
- }
60
- else {
61
- let rc = this.getBoundingRect();
62
- if ((horz && rc.width < this.m_props.switchSize) || (!horz && rc.height < this.m_props.switchSize)) {
63
- horz = !horz;
64
- }
65
- }
66
- if (horz) {
67
- this.removeClass('@vlayout');
68
- this.addClass('@hlayout');
69
- }
70
- else {
71
- this.addClass('@vlayout');
72
- this.removeClass('@hlayout');
73
- }
74
- }
75
- }
76
- export class GridLayout extends Container {
77
- constructor(props) {
78
- /// @ts-ignore
79
- // Argument of type 'GridLayoutProps' is not assignable to parameter of type 'P'.
80
- // 'GridLayoutProps' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'GridLayoutProps'.
81
- super(props);
82
- }
83
- /** @ignore */
84
- render() {
85
- if (this.m_props.colSizes) {
86
- this.setStyleValue('grid-template-columns', this.m_props.colSizes);
87
- }
88
- if (this.m_props.rowSizes) {
89
- this.setStyleValue('grid-template-rows', this.m_props.rowSizes);
90
- }
91
- if (this.m_props.colGap) {
92
- this.setStyleValue('grid-gap', this.m_props.colGap);
93
- }
94
- if (this.m_props.template) {
95
- this.setStyleValue('grid-template-areas', this.m_props.template.join('\n'));
96
- }
97
- }
98
- }
99
- export class TableLayout extends Container {
100
- m_cells;
101
- constructor(props) {
102
- super(props);
103
- this.setTag('table');
104
- this.m_cells = new Map();
105
- }
106
- _getCell(row, col, create = true) {
107
- let idx = _mkid(row, col);
108
- return this.m_cells.get(idx) ?? (create ? { item: undefined } : null);
109
- }
110
- _setCell(row, col, cell, update = false) {
111
- let idx = _mkid(row, col);
112
- this.m_cells.set(idx, cell);
113
- if (this.dom && cell.item && update) {
114
- if (cell.item instanceof Component) {
115
- cell.item.update();
116
- }
117
- else {
118
- this.enumChilds((c) => {
119
- let crow = c.getData('row');
120
- if (crow == row) {
121
- let ccol = c.getData('col');
122
- if (ccol == col) {
123
- c.setContent(cell.item);
124
- c.update();
125
- return true;
126
- }
127
- }
128
- });
129
- }
130
- }
131
- }
132
- setCell(row, col, item) {
133
- let cell = this._getCell(row, col);
134
- cell.item = item;
135
- this._setCell(row, col, cell, true);
136
- }
137
- merge(row, col, rowCount, colCount) {
138
- let cell = this._getCell(row, col);
139
- cell.rowSpan = rowCount;
140
- cell.colSpan = colCount;
141
- this._setCell(row, col, cell);
142
- }
143
- setCellWidth(row, col, width) {
144
- let cell = this._getCell(row, col);
145
- cell.width = width;
146
- this._setCell(row, col, cell);
147
- }
148
- setCellHeight(row, col, height) {
149
- let cell = this._getCell(row, col);
150
- cell.height = height;
151
- this._setCell(row, col, cell);
152
- }
153
- setCellClass(row, col, cls) {
154
- let cell = this._getCell(row, col);
155
- cell.cls = cls;
156
- this._setCell(row, col, cell);
157
- }
158
- setColClass(col, cls) {
159
- let cell = this._getCell(-1, col);
160
- cell.cls = cls;
161
- this._setCell(-1, col, cell);
162
- }
163
- setRowClass(row, cls) {
164
- let cell = this._getCell(row, 999);
165
- cell.cls = cls;
166
- this._setCell(row, 999, cell);
167
- }
168
- getCell(row, col) {
169
- let cell = this._getCell(row, col);
170
- return cell?.item;
171
- }
172
- render() {
173
- let rows = [];
174
- let skip = [];
175
- for (let r = 0; r < this.m_props.rows; r++) {
176
- let cols = [];
177
- for (let c = 0; c < this.m_props.columns; c++) {
178
- let idx = _mkid(r, c);
179
- if (skip.indexOf(idx) >= 0) {
180
- continue;
181
- }
182
- let cell = this.m_cells.get(idx);
183
- let cdata = this.m_cells.get(_mkid(-1, c));
184
- let cls = '';
185
- if (cell && cell.cls) {
186
- cls = cell.cls;
187
- }
188
- if (cdata && cdata.cls) {
189
- cls += ' ' + cdata.cls;
190
- }
191
- let cc = new Component({
192
- tag: 'td',
193
- content: cell?.item,
194
- width: cell?.width,
195
- height: cell?.height,
196
- data: { row: r, col: c },
197
- cls
198
- });
199
- if (cell) {
200
- let rs = cell.rowSpan ?? 0, cs = cell.colSpan ?? 0;
201
- if (rs > 0) {
202
- cc.setAttribute('rowspan', rs + 1);
203
- }
204
- if (cs > 0) {
205
- cc.setAttribute('colspan', cs + 1);
206
- }
207
- if (rs || cs) {
208
- for (let sr = 0; sr <= rs; sr++) {
209
- for (let sc = 0; sc <= cs; sc++) {
210
- skip.push(_mkid(sr + r, sc + c));
211
- }
212
- }
213
- }
214
- }
215
- cols.push(cc);
216
- }
217
- let rdata = this._getCell(r, 999, false);
218
- let rr = new Component({
219
- tag: 'tr',
220
- data: { row: r },
221
- content: cols,
222
- cls: rdata?.cls
223
- });
224
- rows.push(rr);
225
- }
226
- this.setContent(rows);
227
- }
228
- }
229
- /**
230
- * @ignore
231
- */
232
- function _mkid(row, col) {
233
- return row * 1000 + col;
234
- }
235
- /**
236
- * @ignore
237
- */
238
- function _getid(key) {
239
- return {
240
- row: Math.floor(key / 1000) | 0,
241
- col: (key % 1000) | 0
242
- };
243
- }
244
- export class ScrollView extends Component {
245
- constructor(props) {
246
- super(props);
247
- this.setContent(props.content);
248
- }
249
- setContent(content) {
250
- if (!content) {
251
- super.setContent(null);
252
- }
253
- else {
254
- let container;
255
- if (isArray(content)) {
256
- container = new VLayout({ content });
257
- }
258
- else {
259
- container = content;
260
- }
261
- container.addClass('@scroll-container');
262
- super.setContent(container);
263
- }
264
- }
265
- }
266
- // :: MASONERY ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
267
- // from a nice article of Andy Barefoot
268
- // https://medium.com/@andybarefoot/a-masonry-style-layout-using-css-grid-8c663d355ebb
269
- export class Masonry extends Container {
270
- constructor(props) {
271
- const items = props.items;
272
- props.items = undefined;
273
- super(props);
274
- this.setDomEvent('sizechange', () => {
275
- this.resizeAllItems();
276
- });
277
- if (items) {
278
- items.forEach(i => {
279
- this.addItem(i);
280
- });
281
- }
282
- }
283
- resizeItem(item) {
284
- const style = this.getComputedStyle();
285
- const rowHeight = style.parse('grid-auto-rows');
286
- const rowGap = style.parse('grid-row-gap');
287
- let content = item.queryItem('.content');
288
- if (!content) {
289
- content = item;
290
- }
291
- if (content && (rowHeight + rowGap)) {
292
- const rc = content.getBoundingRect();
293
- const rowSpan = Math.ceil((rc.height + rowGap) / (rowHeight + rowGap));
294
- item.setStyleValue('gridRowEnd', "span " + rowSpan);
295
- }
296
- }
297
- resizeAllItems() {
298
- this.queryAll(".item", (itm) => {
299
- ;
300
- this.resizeItem(itm);
301
- });
302
- }
303
- addItem(itm) {
304
- itm.addClass('content');
305
- this.appendChild(new Container({
306
- cls: 'item',
307
- content: itm
308
- }));
309
- }
310
- }
package/lib/esm/link.js DELETED
@@ -1,59 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file link.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Component, isHtmlString, html } from './component';
30
- import { EvClick } from './x4events';
31
- /**
32
- * Standard Link
33
- */
34
- export class Link extends Component {
35
- constructor(props) {
36
- super(props);
37
- this.setDomEvent('click', () => this._handleClick());
38
- this.mapPropEvents(props, 'click');
39
- }
40
- _handleClick() {
41
- this.emit('click', EvClick());
42
- }
43
- /** @ignore */
44
- render(props) {
45
- let text = props.text ?? '';
46
- let href = props.href ?? '#';
47
- this.setTag('a');
48
- this.setAttribute('tabindex', 0);
49
- this.setAttribute('href', href);
50
- this.setAttribute('target', props.target);
51
- if (text) {
52
- this.setContent(isHtmlString(text) ? text : html `<span>${text}</span>`);
53
- }
54
- }
55
- set text(text) {
56
- this.m_props.text = text;
57
- this.update();
58
- }
59
- }