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
@@ -1,246 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file request.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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
31
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
- return new (P || (P = Promise))(function (resolve, reject) {
33
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
34
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
35
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36
- step((generator = generator.apply(thisArg, _arguments || [])).next());
37
- });
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.ajax = exports.ajaxAsText = exports.ajaxAsJSON = exports.ajaxRequest = void 0;
41
- /**
42
- * TODO: use fetch api
43
- *
44
-
45
- async function xx( resp, cb ) {
46
- cb( await resp.json() );
47
- }
48
-
49
- async function getToto( cb ) {
50
- fetch('home/toto', { method: 'GET' }).then( (resp) => { xx(resp,cb); } );
51
- }
52
-
53
- function dump( resp ) {
54
- console.log( resp );
55
- }
56
-
57
- getToto( dump );
58
-
59
- */
60
- const tools_1 = require("./tools");
61
- const DEFAULT_TIMEOUT = 10000;
62
- function ajaxRequest(cfg) {
63
- let params, url = cfg.url, method = cfg.method || 'GET', formdata = false;
64
- if (cfg.params instanceof FormData) {
65
- params = cfg.params;
66
- formdata = true;
67
- }
68
- else if (method == 'POST') {
69
- params = buildQuery(cfg.params, false);
70
- }
71
- else {
72
- url += buildQuery(cfg.params, true);
73
- }
74
- url = encodeURI(url);
75
- let xhr = new XMLHttpRequest();
76
- xhr.open(method, url);
77
- xhr.upload.addEventListener('progress', progress, false);
78
- xhr.addEventListener('timeout', failure);
79
- xhr.addEventListener('error', failure);
80
- xhr.addEventListener('load', success);
81
- if (!formdata) {
82
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
83
- }
84
- if (method != 'POST') {
85
- xhr.responseType = cfg.responseType || 'json';
86
- xhr.timeout = cfg.timeout || DEFAULT_TIMEOUT;
87
- }
88
- if (cfg.headers) {
89
- for (let h in cfg.headers) {
90
- xhr.setRequestHeader(h, cfg.headers[h]);
91
- }
92
- }
93
- function progress(ev) {
94
- console.log(ev);
95
- if (cfg.progress) {
96
- try {
97
- if (ev.lengthComputable) {
98
- let disp = humanSize(ev.loaded) + ' / ' + humanSize(ev.total);
99
- cfg.progress(ev.loaded, ev.total, disp);
100
- }
101
- }
102
- catch (e) {
103
- console.error('unhandled exception:', e);
104
- }
105
- }
106
- }
107
- function humanSize(bytes) {
108
- let unit, value;
109
- if (bytes >= 1e9) {
110
- unit = 'Gb';
111
- value = bytes / 1e9;
112
- }
113
- else if (bytes >= 1e6) {
114
- unit = 'Mb';
115
- value = bytes / 1e6;
116
- }
117
- else if (bytes >= 1e3) {
118
- unit = 'Kb';
119
- value = bytes / 1e3;
120
- }
121
- else {
122
- unit = 'bytes';
123
- value = bytes;
124
- }
125
- return value.toFixed(2) + unit;
126
- }
127
- function failure() {
128
- if (cfg.failure) {
129
- cfg.failure(xhr.status, xhr.statusText, cfg.userData);
130
- }
131
- }
132
- function success() {
133
- if (xhr.status >= 200 && xhr.status < 300) {
134
- if (cfg.success) {
135
- try {
136
- cfg.success(xhr.response, cfg.userData);
137
- }
138
- catch (e) {
139
- console.error('unhandled exception:', e);
140
- }
141
- }
142
- }
143
- else {
144
- failure();
145
- }
146
- }
147
- if (formdata || method == 'POST') {
148
- xhr.send(params);
149
- }
150
- else {
151
- xhr.send();
152
- }
153
- return function () {
154
- xhr.abort();
155
- };
156
- }
157
- exports.ajaxRequest = ajaxRequest;
158
- function buildQuery(params, getMethod) {
159
- if (!params) {
160
- return '';
161
- }
162
- let query = [];
163
- for (let key in params) {
164
- let param = params[key];
165
- // array
166
- if ((0, tools_1.isArray)(param)) {
167
- for (let i = 0, n = param.length; i < n; i++) {
168
- query.push(encodeURIComponent(key) + '[]=' + encodeURIComponent('' + param[i]));
169
- }
170
- }
171
- // simple string ...
172
- else {
173
- if (param === undefined) {
174
- param = '';
175
- }
176
- query.push(encodeURIComponent(key) + '=' + encodeURIComponent('' + param));
177
- }
178
- }
179
- let result = query.join('&');
180
- if (getMethod) {
181
- return '?' + result;
182
- }
183
- else {
184
- return result;
185
- }
186
- }
187
- function ajaxAsJSON(url, init) {
188
- return __awaiter(this, void 0, void 0, function* () {
189
- let response = yield ajax(url, init, 'application/json');
190
- return response.json();
191
- });
192
- }
193
- exports.ajaxAsJSON = ajaxAsJSON;
194
- function ajaxAsText(url, init) {
195
- return __awaiter(this, void 0, void 0, function* () {
196
- let response = yield ajax(url, init, 'text/plain');
197
- return response.text();
198
- });
199
- }
200
- exports.ajaxAsText = ajaxAsText;
201
- /**
202
- * use encodeURIComponent for elements in url
203
- */
204
- function ajax(url, init, type) {
205
- return __awaiter(this, void 0, void 0, function* () {
206
- let options = {
207
- method: 'GET',
208
- headers: {
209
- 'X-Requested-With': 'XMLHttpRequest'
210
- }
211
- };
212
- if (type) {
213
- options.headers['Content-Type'] = type;
214
- }
215
- if (init) {
216
- options = Object.assign(Object.assign({}, options), init);
217
- if (init.body && !(0, tools_1.isString)(init.body)) {
218
- let cvt = false;
219
- if ((0, tools_1.isLiteralObject)(init.body)) {
220
- cvt = true;
221
- }
222
- else if (!(init.body instanceof Blob) && !(init.body instanceof ArrayBuffer) && !(init.body instanceof FormData) &&
223
- !(init.body instanceof URLSearchParams) && !(init.body instanceof ReadableStream)) {
224
- cvt = true;
225
- }
226
- if (cvt) {
227
- options.body = JSON.stringify(init.body);
228
- }
229
- else {
230
- options.body = init.body;
231
- }
232
- }
233
- }
234
- let response = yield fetch(url, options);
235
- if (init && init.noGenX) {
236
- return response;
237
- }
238
- else {
239
- if (!response.ok) {
240
- throw new tools_1.NetworkError(response);
241
- }
242
- return response;
243
- }
244
- });
245
- }
246
- exports.ajax = ajax;
package/lib/cjs/router.js DELETED
@@ -1,139 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file router.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.Router = void 0;
32
- const x4dom_1 = require("./x4dom");
33
- const x4events_1 = require("./x4events");
34
- function parseRoute(str, loose = false) {
35
- if (str instanceof RegExp) {
36
- return {
37
- keys: null,
38
- pattern: str
39
- };
40
- }
41
- const arr = str.split('/');
42
- let keys = [];
43
- let pattern = '';
44
- if (arr[0] == '') {
45
- arr.shift();
46
- }
47
- for (const tmp of arr) {
48
- const c = tmp[0];
49
- if (c === '*') {
50
- keys.push('wild');
51
- pattern += '/(.*)';
52
- }
53
- else if (c === ':') {
54
- const o = tmp.indexOf('?', 1);
55
- const ext = tmp.indexOf('.', 1);
56
- keys.push(tmp.substring(1, o >= 0 ? o : ext >= 0 ? ext : tmp.length));
57
- pattern += o >= 0 && ext < 0 ? '(?:/([^\/]+?))?' : '/([^\/]+?)';
58
- if (ext >= 0) {
59
- pattern += (o >= 0 ? '?' : '') + '\\' + tmp.substring(ext);
60
- }
61
- }
62
- else {
63
- pattern += '/' + tmp;
64
- }
65
- }
66
- return {
67
- keys,
68
- pattern: new RegExp(`^${pattern}${loose ? '(?=$|\/)' : '\/?$'}`, 'i')
69
- };
70
- }
71
- class Router extends x4events_1.EventSource {
72
- constructor() {
73
- super();
74
- this.routes = [];
75
- window.addEventListener('popstate', (event) => {
76
- const url = x4dom_1.x4document.location.pathname;
77
- const found = this._find(url);
78
- found.handlers.forEach(h => {
79
- h(found.params, url);
80
- });
81
- });
82
- }
83
- get(uri, handler) {
84
- let { keys, pattern } = parseRoute(uri);
85
- this.routes.push({ keys, pattern, handler });
86
- }
87
- init() {
88
- this.navigate(window.location.pathname);
89
- }
90
- navigate(uri, notify = true) {
91
- const found = this._find(uri);
92
- if (!found || found.handlers.length == 0) {
93
- //window.history.pushState({}, '', 'error')
94
- console.log('route not found: ' + uri);
95
- this.signal("error", (0, x4events_1.EvError)(404, "route not found"));
96
- return;
97
- }
98
- window.history.pushState({}, '', uri);
99
- if (notify) {
100
- found.handlers.forEach(h => {
101
- h(found.params, uri);
102
- });
103
- }
104
- }
105
- _find(url) {
106
- let matches = [];
107
- let params = {};
108
- let handlers = [];
109
- for (const tmp of this.routes) {
110
- if (!tmp.keys) {
111
- matches = tmp.pattern.exec(url);
112
- if (!matches) {
113
- continue;
114
- }
115
- if (matches['groups']) {
116
- for (const k in matches['groups']) {
117
- params[k] = matches['groups'][k];
118
- }
119
- }
120
- handlers = [...handlers, tmp.handler];
121
- }
122
- else if (tmp.keys.length > 0) {
123
- matches = tmp.pattern.exec(url);
124
- if (matches === null) {
125
- continue;
126
- }
127
- for (let j = 0; j < tmp.keys.length;) {
128
- params[tmp.keys[j]] = matches[++j];
129
- }
130
- handlers = [...handlers, tmp.handler];
131
- }
132
- else if (tmp.pattern.test(url)) {
133
- handlers = [...handlers, tmp.handler];
134
- }
135
- }
136
- return { params, handlers };
137
- }
138
- }
139
- exports.Router = Router;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file local_storage.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.Settings = void 0;
32
- class Settings {
33
- constructor(name) {
34
- this.m_data = null;
35
- this.m_name = name !== null && name !== void 0 ? name : 'settings';
36
- }
37
- set(name, value) {
38
- this._load();
39
- this.m_data[name] = value;
40
- this._save();
41
- }
42
- get(name, defValue) {
43
- var _a;
44
- this._load();
45
- return (_a = this.m_data[name]) !== null && _a !== void 0 ? _a : defValue;
46
- }
47
- _save() {
48
- let data = JSON.stringify(this.m_data);
49
- localStorage.setItem(this.m_name, data);
50
- }
51
- _load() {
52
- if (this.m_data) {
53
- return;
54
- }
55
- this.m_data = {};
56
- let data = localStorage.getItem(this.m_name);
57
- if (data !== null) {
58
- data = JSON.parse(data);
59
- if (data) {
60
- this.m_data = data;
61
- }
62
- else {
63
- console.info('There was an error attempting to read your settings.');
64
- }
65
- }
66
- // console.info('There was an error attempting to read your settings.');
67
- }
68
- }
69
- exports.Settings = Settings;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file sidebarview.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.SideBarView = void 0;
32
- const component_1 = require("./component");
33
- const layout_1 = require("./layout");
34
- const button_1 = require("./button");
35
- const cardview_1 = require("./cardview");
36
- /**
37
- *
38
- */
39
- class SideBarView extends cardview_1.CardView {
40
- constructor(props) {
41
- var _a;
42
- super(props);
43
- this.addClass('@hlayout');
44
- this.m_sidebar = new layout_1.VLayout({
45
- cls: '@side-bar',
46
- width: (_a = props.bar_width) !== null && _a !== void 0 ? _a : undefined,
47
- });
48
- this.m_content = new layout_1.HLayout({ flex: 1, cls: '@tab-container' });
49
- }
50
- /** @ignore */
51
- render() {
52
- let tabs = [];
53
- this.m_cards.forEach((p) => {
54
- tabs.push(p.selector);
55
- });
56
- this.m_sidebar.setContent(new layout_1.VLayout({
57
- flex: 1,
58
- cls: 'content',
59
- content: tabs
60
- }));
61
- this.setContent([
62
- this.m_sidebar,
63
- this.m_props.bar_sizable ? new component_1.Separator({ orientation: "horizontal", sizing: "before" }) : undefined,
64
- this.m_content
65
- ]);
66
- }
67
- _prepareSelector(card) {
68
- return new button_1.Button({
69
- text: card.title,
70
- icon: card.icon,
71
- tooltip: card.title,
72
- click: () => { this.switchTo(card.name); }
73
- });
74
- }
75
- _preparePage(page) {
76
- super._preparePage(page);
77
- if (!page.dom) {
78
- this.m_content.appendChild(page);
79
- }
80
- }
81
- }
82
- exports.SideBarView = SideBarView;