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
@@ -0,0 +1,90 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file x4react.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
+
30
+ import { Component, ComponentContent, CProps, CEventMap } from './component';
31
+
32
+
33
+ const createElement = ( clsOrTag, attrs, ...children ): ComponentContent => {
34
+
35
+ let comp: Component;
36
+
37
+ // fragment
38
+ if( clsOrTag==createFragment || clsOrTag==Fragment ) {
39
+ return children;
40
+ }
41
+ // class constructor, yes : dirty
42
+ else if( clsOrTag instanceof Function ) {
43
+ comp = new (clsOrTag as any)( attrs );
44
+ }
45
+ // basic tag
46
+ else {
47
+ comp = new Component( {
48
+ tag: clsOrTag,
49
+ ...attrs,
50
+ });
51
+ }
52
+
53
+ if( children && children.length ) {
54
+ comp.setContent( children );
55
+ }
56
+
57
+ return comp;
58
+ }
59
+
60
+ const Fragment = Symbol( "fragment" );
61
+
62
+ const createFragment = ( ): ComponentContent => {
63
+ return null;
64
+ }
65
+
66
+ export let React = {
67
+ createElement,
68
+ createFragment,
69
+ Fragment,
70
+ }
71
+
72
+
73
+
74
+
75
+
76
+ /**
77
+ *
78
+ */
79
+
80
+ export abstract class TSXComponent<P extends CProps<CEventMap> = CProps<CEventMap>, E extends CEventMap = CEventMap> extends Component<P,E> {
81
+ public render(props: P) {
82
+ const tsx = this.renderTSX( props );
83
+ if( tsx ) {
84
+ this.setContent( tsx );
85
+ }
86
+ }
87
+
88
+ public abstract renderTSX( props: P ): Component | Component[];
89
+ }
90
+
package/package.json CHANGED
@@ -1,49 +1,52 @@
1
- {
2
- "name": "x4js",
3
- "version": "1.5.17",
4
- "description": "X4js core files",
5
- "main": "lib/cjs/index.js",
6
- "types": "lib/types/index.d.ts",
7
- "style": "lib/x4.css",
8
- "files": [
9
- "lib/**/*"
10
- ],
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/rlibre/x4js.git"
14
- },
15
- "keywords": [
16
- "typescript",
17
- "framework",
18
- "sap",
19
- "web",
20
- "desktop",
21
- "application"
22
- ],
23
- "scripts": {
24
- "build": "bash ./build.sh",
25
- "mkdoc": "typedoc --tsconfig tsconfig.json --readme none",
26
- "prepack": "bash ./build.sh"
27
- },
28
- "author": "etienne cochard",
29
- "license": "MIT",
30
- "bugs": {
31
- "url": "https://github.com/rlibre/x4js/issues"
32
- },
33
- "homepage": "https://x4js.org",
34
- "exports": {
35
- ".": {
36
- "import": {
37
- "types": "./lib/types/index.d.ts",
38
- "default": "./lib/esm/index.mjs"
39
- },
40
- "require": {
41
- "types": "./lib/types/index.d.ts",
42
- "default": "./lib/cjs/index.js"
43
- }
44
- }
45
- },
46
- "dependencies": {
47
- "typescript": "^4.9.3"
48
- }
49
- }
1
+ {
2
+ "name": "x4js",
3
+ "version": "1.5.20",
4
+ "description": "X4js core files",
5
+ "main": "lib/cjs/index.js",
6
+ "types": "lib/types/index.d.ts",
7
+ "style": "lib/x4.css",
8
+ "files": [
9
+ "lib/**/*"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/rlibre/x4js.git"
14
+ },
15
+ "keywords": [
16
+ "typescript",
17
+ "framework",
18
+ "sap",
19
+ "web",
20
+ "desktop",
21
+ "application"
22
+ ],
23
+ "scripts": {
24
+ "build": "node ./build.js",
25
+ "mkdoc": "typedoc --tsconfig tsconfig.json --readme none",
26
+ "prepack": "node ./build.js"
27
+ },
28
+ "author": "etienne cochard",
29
+ "license": "MIT",
30
+ "bugs": {
31
+ "url": "https://github.com/rlibre/x4js/issues"
32
+ },
33
+ "homepage": "https://x4js.org",
34
+ "module": "lib/esm/index.js",
35
+ "exports": {
36
+ ".": {
37
+ "import": {
38
+ "types": "./lib/types/index.d.ts",
39
+ "default": "./lib/esm/index.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./lib/types/index.d.ts",
43
+ "default": "./lib/cjs/index.js"
44
+ }
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "esbuild": "^0.17.8",
49
+ "fs-extra": "^11.1.0",
50
+ "less": "^4.1.3"
51
+ }
52
+ }
package/lib/cjs/action.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \/ / / _
5
- * \ / /_| |_
6
- * / \____ _|
7
- * /__/\__\ |_|
8
- *
9
- * @file action.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.Action = exports.EvAction = void 0;
32
- const x4events_1 = require("./x4events");
33
- const base_component_1 = require("./base_component");
34
- function EvAction(source) {
35
- return (0, x4events_1.BasicEvent)({ source });
36
- }
37
- exports.EvAction = EvAction;
38
- class Action extends base_component_1.BaseComponent {
39
- constructor(props) {
40
- super(props);
41
- this.mapPropEvents(props, "run");
42
- }
43
- get props() {
44
- return this.m_props;
45
- }
46
- set text(t) {
47
- this.m_props.text = t;
48
- this.emit("change", (0, x4events_1.EvChange)(this));
49
- }
50
- set icon(i) {
51
- this.m_props.icon = i;
52
- this.emit("change", (0, x4events_1.EvChange)(this));
53
- }
54
- fire() {
55
- this.emit("run", EvAction(this));
56
- }
57
- }
58
- exports.Action = Action;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \/ / / _
5
- * \ / /_| |_
6
- * / \____ _|
7
- * /__/\__\ |_|
8
- *
9
- * @file app_sockets.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.setupWSMessaging = void 0;
32
- const application_1 = require("./application");
33
- /**
34
- * WEB SOCKETS
35
- *
36
- * les messages reçus par l'application sont retransmis au websocket.
37
- * comme ça, tous les clients connectés sur le serveur recevront une copie du message.
38
- * ca permet de mettre a jour les clients dynamiquement
39
- *
40
- */
41
- const msg_sent = Symbol('msg_sent');
42
- function setupWSMessaging(closeCB) {
43
- const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
44
- const sockets = new WebSocket(`${protocol}${window.location.hostname}:${window.location.port}`, 'messaging');
45
- const app = application_1.Application.instance();
46
- // pour tous les messages recus par l'application
47
- // on transmet aux autres
48
- app.on('global', (e) => {
49
- if (e[msg_sent]) {
50
- return;
51
- }
52
- sockets.send(JSON.stringify({
53
- msg: e.msg,
54
- params: e.params,
55
- }));
56
- });
57
- // reception d'un message
58
- sockets.onmessage = (e) => {
59
- if (e.data != 'ping') {
60
- const message = JSON.parse(e.data);
61
- message[msg_sent] = true;
62
- app.signal('global', message);
63
- }
64
- };
65
- // perte du socket
66
- sockets.onclose = (ev) => {
67
- console.log('websocket closed:', ev);
68
- closeCB();
69
- };
70
- sockets.onerror = (ev) => {
71
- console.log('websocket error:', ev);
72
- };
73
- }
74
- exports.setupWSMessaging = setupWSMessaging;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \/ / / _
5
- * \ / /_| |_
6
- * / \____ _|
7
- * /__/\__\ |_|
8
- *
9
- * @file application.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.Application = void 0;
32
- const x4dom_1 = require("./x4dom");
33
- const base_component_1 = require("./base_component");
34
- const component_1 = require("./component");
35
- const settings_1 = require("./settings");
36
- const _x4_touch_time = Symbol();
37
- /**
38
- * Represents an x4 application, which is typically a single page app.
39
- * You should inherit Application to define yours.
40
- * Application derives from BaseComponent so you can use that to implement a global messaging system.
41
- * @example ```ts
42
- *
43
- * // in yout main caode
44
- * let app = new Application( );
45
- *
46
- * app.events.close.on( ( ev ) => {
47
- * ... do something
48
- * });
49
- *
50
- * // somewhere else in the source
51
- * function xxx( ) {
52
- * let app = Application.instance( );
53
- * app.events.close.emit( new Events.close() );
54
- * }
55
- */
56
- class Application extends base_component_1.BaseComponent {
57
- /**
58
- * the application singleton
59
- */
60
- static instance() {
61
- return Application.self;
62
- }
63
- constructor(props) {
64
- var _a, _b, _c;
65
- console.assert(Application.self === null, 'application is a singleton');
66
- super(props);
67
- this.m_app_name = (_a = props.app_name) !== null && _a !== void 0 ? _a : 'application';
68
- this.m_app_version = (_b = props.app_version) !== null && _b !== void 0 ? _b : '1.0';
69
- this.m_app_uid = (_c = props.app_uid) !== null && _c !== void 0 ? _c : 'application';
70
- let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
71
- this.m_local_storage = new settings_1.Settings(settings_name);
72
- this.m_user_data = {};
73
- this.m_touch_time = 0;
74
- this.m_touch_count = 0;
75
- Application.self = this;
76
- if ('onload' in globalThis) {
77
- globalThis.addEventListener('load', () => {
78
- this.ApplicationCreated();
79
- });
80
- }
81
- else {
82
- this.ApplicationCreated();
83
- }
84
- }
85
- ApplicationCreated() {
86
- this.setTitle('');
87
- }
88
- get app_name() {
89
- return this.m_app_name;
90
- }
91
- get app_uid() {
92
- return this.m_app_uid;
93
- }
94
- get app_version() {
95
- return this.m_app_version;
96
- }
97
- get local_storage() {
98
- return this.m_local_storage;
99
- }
100
- get user_data() {
101
- return this.m_user_data;
102
- }
103
- get history() {
104
- //if( !this.m_history ) {
105
- // this.m_history = new NavigationHistory( );
106
- //}
107
- //
108
- //return this.m_history;
109
- debugger;
110
- return null;
111
- }
112
- /**
113
- * define the application root object (MainView)
114
- * @example ```ts
115
- *
116
- * let myApp = new Application( ... );
117
- * let mainView = new VLayout( ... );
118
- * myApp.mainView = mainView;
119
- */
120
- setMainView(root, clearBefore) {
121
- var _a;
122
- const ddom = (_a = this.m_props.renderTo) !== null && _a !== void 0 ? _a : x4dom_1.x4document.body;
123
- const dest = (0, component_1.flyWrap)(ddom);
124
- if (!this.m_props.renderTo) {
125
- dest.setStyleValue('position', 'absolute');
126
- }
127
- dest.addClass('x4-root-element');
128
- if (clearBefore) {
129
- dest._empty();
130
- }
131
- this.m_mainView = root;
132
- root.setStyleValue('position', 'absolute');
133
- root._build();
134
- ddom.appendChild(root.dom);
135
- }
136
- set mainView(root) {
137
- this.setMainView(root, false);
138
- }
139
- get mainView() {
140
- return this.m_mainView;
141
- }
142
- setTitle(title) {
143
- x4dom_1.x4document.title = this.m_app_name + (title ? (' > ' + title) : '');
144
- }
145
- disableZoomWheel() {
146
- window.addEventListener('wheel', function (ev) {
147
- if (ev.ctrlKey) {
148
- ev.preventDefault();
149
- //ev.stopPropagation( );
150
- }
151
- }, { passive: false, capture: true });
152
- }
153
- enterModal(enter) {
154
- }
155
- enableTouchDblClick() {
156
- x4dom_1.x4document.addEventListener('touchstart', (ev) => {
157
- let now = Date.now();
158
- if ((now - this.m_touch_time) > 700) {
159
- this.m_touch_count = 1;
160
- }
161
- else {
162
- this.m_touch_count++;
163
- }
164
- this.m_touch_time = now;
165
- if (this.m_touch_count == 2) {
166
- this.m_touch_count = 0;
167
- // dirty fake dblclick event
168
- const tch = ev.touches[0];
169
- let fake = { type: "dblclick" };
170
- for (const n in tch) {
171
- fake[n] = tch[n];
172
- }
173
- // ignore -> private: dirty x2
174
- component_1.Component._dispatchEvent(fake);
175
- ev.stopPropagation();
176
- }
177
- });
178
- }
179
- }
180
- exports.Application = Application;
181
- Application.self = null;
182
- ;
@@ -1,155 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \/ / / _
5
- * \ / /_| |_
6
- * / \____ _|
7
- * /__/\__\ |_|
8
- *
9
- * @file autocomplete.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.AutoComplete = void 0;
32
- const listview_1 = require("./listview");
33
- const textedit_1 = require("./textedit");
34
- /**
35
- *
36
- */
37
- class AutoComplete extends textedit_1.TextEdit {
38
- constructor(props) {
39
- super(props);
40
- this.setDomEvent("input", () => this._onChange());
41
- this.setDomEvent("focusin", () => this._onFocus());
42
- this.startTimer("focus-check", 100, true, () => this._checkFocus());
43
- this.m_popvis = false;
44
- this.m_needval = false;
45
- this.m_lockpop = false;
46
- this.setDomEvent("keydown", e => this._onKey(e));
47
- }
48
- _onKey(e) {
49
- if (this.m_popvis) {
50
- if (e.key == "ArrowUp" || e.key == "ArrowDown") {
51
- this.m_lockpop = true;
52
- this.m_popup.handleKey(e);
53
- this.m_lockpop = false;
54
- e.preventDefault();
55
- e.stopPropagation();
56
- }
57
- else if (e.key == "Escape") {
58
- this._hidePopup();
59
- e.preventDefault();
60
- e.stopPropagation();
61
- }
62
- }
63
- else if (e.key == "ArrowDown") {
64
- this._onChange();
65
- e.preventDefault();
66
- e.stopPropagation();
67
- }
68
- }
69
- _onChange() {
70
- const items = this.m_props.enumValues(this.value);
71
- this.showPopup(items);
72
- }
73
- componentDisposed() {
74
- if (this.m_popup) {
75
- this._hidePopup();
76
- }
77
- super.componentDisposed();
78
- }
79
- /**
80
- * display the popup
81
- */
82
- showPopup(items) {
83
- let props = this.m_props;
84
- if (props.readOnly || this.hasClass("@disable")) {
85
- return;
86
- }
87
- // need creation ?
88
- if (!this.m_popup) {
89
- let cstyle = this.getComputedStyle();
90
- let fontFamily = cstyle.value('fontFamily');
91
- let fontSize = cstyle.value('fontSize');
92
- // prepare the combo listview
93
- this.m_popup = new listview_1.PopupListView({
94
- cls: '@combo-popup',
95
- attrs: {
96
- tabindex: 0
97
- },
98
- selectionChange: (e) => {
99
- this.value = e.selection.id;
100
- if (!this.m_lockpop) {
101
- this._hidePopup();
102
- this.focus();
103
- }
104
- },
105
- style: {
106
- fontFamily,
107
- fontSize
108
- }
109
- });
110
- }
111
- this.m_popup.items = items.map(c => ({ id: c, text: c }));
112
- let r1 = this.m_ui_input.getBoundingRect();
113
- this.m_popup.setStyle({
114
- minWidth: r1.width,
115
- });
116
- this.m_popup.displayAt(r1.left, r1.bottom);
117
- this.m_popvis = true;
118
- //if( this.value!==undefined ) {
119
- // this.m_popup.selection = this.value;
120
- //}
121
- }
122
- _validate(value) {
123
- return true;
124
- }
125
- validate() {
126
- return super._validate(this.value);
127
- }
128
- _checkFocus() {
129
- const focus = document.activeElement;
130
- if (this.dom && this.dom.contains(focus)) {
131
- return;
132
- }
133
- if (this.m_popup && this.m_popup.dom && this.m_popup.dom.contains(focus)) {
134
- return;
135
- }
136
- this._hidePopup();
137
- }
138
- _hidePopup() {
139
- if (this.m_popvis) {
140
- this.m_popup.close();
141
- this.m_popvis = false;
142
- }
143
- if (this.m_needval) {
144
- this.validate();
145
- this.m_needval = false;
146
- }
147
- }
148
- _onFocus() {
149
- if (this.value.length == 0) {
150
- this._onChange();
151
- }
152
- this.m_needval = true;
153
- }
154
- }
155
- exports.AutoComplete = AutoComplete;