x4js 1.4.18 → 1.4.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 (118) hide show
  1. package/lib/application.d.ts +1 -1
  2. package/lib/application.js +4 -3
  3. package/lib/base_component.d.ts +1 -1
  4. package/lib/base_component.js +3 -3
  5. package/lib/button.d.ts +1 -1
  6. package/lib/button.js +3 -3
  7. package/lib/calendar.d.ts +1 -1
  8. package/lib/calendar.js +5 -4
  9. package/lib/canvas.d.ts +1 -1
  10. package/lib/canvas.js +2 -2
  11. package/lib/cardview.d.ts +1 -1
  12. package/lib/cardview.js +2 -2
  13. package/lib/checkbox.d.ts +1 -1
  14. package/lib/checkbox.js +2 -2
  15. package/lib/colorpicker.d.ts +1 -1
  16. package/lib/colorpicker.js +5 -5
  17. package/lib/combobox.d.ts +1 -1
  18. package/lib/combobox.js +3 -3
  19. package/lib/component.d.ts +1 -5
  20. package/lib/component.js +35 -39
  21. package/lib/datastore.d.ts +1 -1
  22. package/lib/datastore.js +5 -5
  23. package/lib/dialog.d.ts +1 -1
  24. package/lib/dialog.js +4 -3
  25. package/lib/drag_manager.js +30 -1
  26. package/lib/fileupload.js +2 -1
  27. package/lib/form.d.ts +1 -1
  28. package/lib/gridview.d.ts +1 -5
  29. package/lib/gridview.js +8 -7
  30. package/lib/i18n.d.ts +35 -33
  31. package/lib/i18n.js +180 -93
  32. package/lib/icon.d.ts +1 -1
  33. package/lib/icon.js +10 -13
  34. package/lib/image.js +4 -3
  35. package/lib/index.d.ts +1 -1
  36. package/lib/index.js +1 -1
  37. package/lib/input.js +1 -1
  38. package/lib/link.d.ts +1 -1
  39. package/lib/link.js +2 -2
  40. package/lib/listview.d.ts +1 -1
  41. package/lib/listview.js +10 -9
  42. package/lib/menu.d.ts +1 -1
  43. package/lib/menu.js +5 -4
  44. package/lib/popup.d.ts +1 -1
  45. package/lib/popup.js +13 -12
  46. package/lib/property_editor.d.ts +1 -1
  47. package/lib/property_editor.js +2 -2
  48. package/lib/radiobtn.d.ts +1 -1
  49. package/lib/radiobtn.js +4 -3
  50. package/lib/rating.d.ts +1 -1
  51. package/lib/rating.js +2 -2
  52. package/lib/router.d.ts +1 -1
  53. package/lib/router.js +5 -4
  54. package/lib/spreadsheet.d.ts +1 -1
  55. package/lib/spreadsheet.js +9 -8
  56. package/lib/styles.js +6 -5
  57. package/lib/svgcomponent.d.ts +1 -1
  58. package/lib/svgcomponent.js +4 -1
  59. package/lib/tabbar.d.ts +1 -1
  60. package/lib/tabbar.js +2 -2
  61. package/lib/textarea.d.ts +1 -1
  62. package/lib/textarea.js +2 -2
  63. package/lib/textedit.d.ts +1 -1
  64. package/lib/textedit.js +5 -4
  65. package/lib/tools.d.ts +1 -0
  66. package/lib/tools.js +15 -6
  67. package/lib/tooltips.js +6 -5
  68. package/lib/treeview.d.ts +1 -1
  69. package/lib/treeview.js +8 -8
  70. package/lib/x4dom.d.ts +21 -0
  71. package/lib/x4dom.js +7 -0
  72. package/lib/x4events.d.ts +266 -0
  73. package/lib/x4events.js +389 -0
  74. package/package.json +4 -3
  75. package/src/application.ts +5 -4
  76. package/src/base_component.ts +1 -1
  77. package/src/button.ts +1 -1
  78. package/src/calendar.ts +5 -3
  79. package/src/canvas.ts +1 -1
  80. package/src/cardview.ts +1 -1
  81. package/src/checkbox.ts +1 -1
  82. package/src/colorpicker.ts +1 -1
  83. package/src/combobox.ts +1 -1
  84. package/src/component.ts +34 -39
  85. package/src/datastore.ts +1 -1
  86. package/src/dialog.ts +4 -2
  87. package/src/drag_manager.ts +4 -1
  88. package/src/fileupload.ts +2 -1
  89. package/src/form.ts +1 -1
  90. package/src/gridview.ts +4 -3
  91. package/src/hosts/electron.ts +4 -1
  92. package/src/i18n.ts +234 -97
  93. package/src/icon.ts +9 -12
  94. package/src/image.ts +5 -3
  95. package/src/index.ts +1 -1
  96. package/src/input.ts +1 -1
  97. package/src/layout.ts +1 -1
  98. package/src/link.ts +1 -1
  99. package/src/listview.ts +6 -4
  100. package/src/menu.ts +5 -3
  101. package/src/popup.ts +14 -12
  102. package/src/property_editor.ts +1 -1
  103. package/src/radiobtn.ts +4 -2
  104. package/src/rating.ts +1 -1
  105. package/src/router.ts +4 -2
  106. package/src/smartedit.ts +3 -2
  107. package/src/spreadsheet.ts +8 -6
  108. package/src/styles.ts +7 -5
  109. package/src/svgcomponent.ts +4 -1
  110. package/src/tabbar.ts +1 -1
  111. package/src/textarea.ts +1 -1
  112. package/src/textedit.ts +4 -2
  113. package/src/tools.ts +15 -5
  114. package/src/tooltips.ts +7 -5
  115. package/src/treeview.ts +1 -1
  116. package/src/x4dom.ts +57 -0
  117. package/src/{x4_events.ts → x4events.ts} +1 -1
  118. package/tsconfig.json +5 -1
package/src/i18n.ts CHANGED
@@ -28,6 +28,205 @@
28
28
  **/
29
29
 
30
30
 
31
+
32
+
33
+ /**
34
+ * language definition
35
+ */
36
+
37
+ interface Language {
38
+ name: string;
39
+ base: string;
40
+ src_translations: any;
41
+ translations: any;
42
+ }
43
+
44
+ const sym_lang = Symbol( "i18n" );
45
+
46
+ let languages: Record<string,Language> = {
47
+ };
48
+
49
+ /**
50
+ * create a new language
51
+ * @param name language name (code)
52
+ * @param base base language (code)
53
+ * @example:
54
+ * ```js
55
+ * createLanguage( 'en', 'fr' );
56
+ * ```
57
+ */
58
+
59
+ export function createLanguage( name: string, base: string ) {
60
+ languages[name] = {
61
+ name,
62
+ base,
63
+ src_translations: {},
64
+ translations: {}
65
+ };
66
+ }
67
+
68
+ /**
69
+ * check if the given language is known
70
+ * @param name language name (code)
71
+ */
72
+
73
+ export function isLanguage( name: string ): boolean {
74
+ return languages[name]!==undefined;
75
+ }
76
+
77
+ /**
78
+ * build the language with given fragments
79
+ * @param name language name (code)
80
+ * @param parts misc elements that make the language
81
+ * @example:
82
+ * ```js
83
+ * createLanguage( 'en', 'fr' );
84
+ * const app = {
85
+ * clients: {
86
+ * translation1: "hello",
87
+ * }
88
+ * }
89
+ * addTranslation( 'en', app );
90
+ * ```
91
+ */
92
+
93
+ export function addTranslation( name, ...parts ) {
94
+
95
+ if( !isLanguage(name) ) {
96
+ return;
97
+ }
98
+
99
+ const lang = languages[name];
100
+
101
+ parts.forEach( p => {
102
+ _patch( lang.src_translations, p, lang.base );
103
+ } );
104
+
105
+ lang.translations = _mk_proxy( lang.src_translations, lang.base, true );
106
+ }
107
+
108
+ /**
109
+ *
110
+ */
111
+
112
+ function _patch( obj: any, by: any, def: string ) {
113
+ for( let n in by ) {
114
+ if( obj[n] instanceof Object ) {
115
+ _patch( obj[n], by[n], def );
116
+ }
117
+ else {
118
+ obj[n] = by[n];
119
+ obj[n] = _mk_proxy( obj[n], def, false );
120
+ }
121
+ }
122
+
123
+ return obj;
124
+ }
125
+
126
+ /**
127
+ * when we ask for _tr.xxx
128
+ * reqpath is set to [xxx]
129
+ *
130
+ * then when we try to get _tr.xxx.yyy
131
+ * reqpath is [xxx,yyy]
132
+ * if yyy is not found, we try with base langage for the full reqpath
133
+ * until no base found
134
+ */
135
+
136
+ let req_path: (string | symbol)[];
137
+
138
+ /**
139
+ *
140
+ */
141
+
142
+ function _findBaseTrans( base ) {
143
+
144
+ while( base ) {
145
+ const lang = languages[base];
146
+ let trans = lang.translations;
147
+ let value;
148
+
149
+ for( const p of req_path ) {
150
+ value = trans[p];
151
+ if( value===undefined ) {
152
+ break;
153
+ }
154
+
155
+ trans = value;
156
+ }
157
+
158
+ if( value!==undefined ) {
159
+ return trans;
160
+ }
161
+
162
+ base = lang.base;
163
+ }
164
+
165
+ console.error( "I18N error: unable to find", '_tr.'+req_path.join('.') );
166
+ return undefined;
167
+ }
168
+
169
+ /**
170
+ *
171
+ */
172
+
173
+ function _mk_proxy( obj: any, base: string, root: boolean ) : any {
174
+ return new Proxy( obj, {
175
+ get: (target, prop) => {
176
+ if( root ) {
177
+ req_path = [prop];
178
+ }
179
+ else {
180
+ req_path.push( prop );
181
+ }
182
+
183
+ let value = target[prop];
184
+ if( value===undefined && base ) {
185
+ value = _findBaseTrans( base );
186
+ // keep it for later
187
+ target[prop] = value;
188
+ }
189
+ return value;
190
+ }
191
+ });
192
+ }
193
+
194
+ export let _tr: any = {};
195
+
196
+ /**
197
+ * select the given language as current
198
+ * @param name laguage name (code)
199
+ */
200
+
201
+ export function selectLanguage( name: string ) {
202
+
203
+ if( !isLanguage(name) ) {
204
+ return;
205
+ }
206
+
207
+ _tr = languages[name].translations;
208
+ _tr[sym_lang] = name;
209
+ }
210
+
211
+ /**
212
+ *
213
+ */
214
+
215
+ export function getCurrentLanguage( ): string {
216
+ return _tr[sym_lang];
217
+ }
218
+
219
+ /**
220
+ *
221
+ */
222
+
223
+ export function getAvailableLanguages( ): string[] {
224
+ return Object.keys( languages );
225
+ }
226
+
227
+
228
+
229
+
31
230
  /**
32
231
  * language definition
33
232
  * x4 specific strings
@@ -55,9 +254,9 @@ let fr = {
55
254
  invalid_email: 'adresse mail invalide',
56
255
  invalid_number: 'valeur numérique invalide',
57
256
 
58
- diff_date_seconds: '{0} seconds',
257
+ diff_date_seconds: '{0} secondes',
59
258
  diff_date_minutes: '{0} minutes',
60
- diff_date_hours: '{0} hours',
259
+ diff_date_hours: '{0} heures',
61
260
 
62
261
  invalid_date: 'Date non reconnue ({0})',
63
262
  empty_list: 'Liste vide',
@@ -83,6 +282,7 @@ let fr = {
83
282
  };
84
283
 
85
284
  /** @ignore */
285
+
86
286
  let en = {
87
287
  global: {
88
288
  ok: 'OK',
@@ -91,119 +291,56 @@ let en = {
91
291
  yes: 'Yes',
92
292
  no: 'No',
93
293
 
94
- required_field: "required field",
294
+ open: 'Open',
295
+ new: 'New',
296
+ delete: 'Delete',
297
+ close: 'Close',
298
+ save: 'Save',
299
+
300
+ search: 'Search',
301
+ search_tip: 'Type in the text to search. <b>Enter</b> to start the search. <b>Esc</b> to cancel.',
302
+
303
+ required_field: "missing information",
95
304
  invalid_format: "invalid format",
305
+ invalid_email: 'invalid email address',
306
+ invalid_number: 'bad numeric value',
96
307
 
97
308
  diff_date_seconds: '{0} seconds',
98
309
  diff_date_minutes: '{0} minutes',
99
310
  diff_date_hours: '{0} hours',
100
311
 
101
- invalid_date: 'Bad date format {0}',
312
+ invalid_date: 'Unrecognized date({0})',
313
+ empty_list: 'Empty list',
102
314
 
103
- copy: 'Copy',
104
- cut: 'Cut',
105
- paste: 'Paste'
106
- }
107
- }
315
+ date_input_formats: 'm/d/y|m.d.y|m d y|m-d-y|mdy',
316
+ date_format: 'M/D/Y',
108
317
 
109
- /** @ignore */
110
- let all_langs = {
111
- 'fr': fr,
112
- 'en': _mk_proxy( _patch( {}, en ) )
113
- };
318
+ day_short: [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ],
319
+ day_long: [ 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ],
114
320
 
115
- /**
116
- * current language
117
- * FR by default
118
- * @example ```typescript
119
- * console.log( _tr.global.ok );
120
- */
321
+ month_short: [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jui', 'aug', 'sep', 'oct', 'nov', 'dec' ],
322
+ month_long: [ 'january', 'february', 'march', 'april', 'mau', 'june', 'jully', 'august', 'september', 'october', 'november', 'december' ],
121
323
 
122
- export let _tr: any = all_langs['fr'];
324
+ property: 'Property',
325
+ value: 'Value',
123
326
 
124
- /**
125
- * check if the language is known
126
- * @param name - language name to test
127
- * @example ```typescript
128
- * if( isLanguage('fr') ) {
129
- * }
130
- */
131
-
132
- export function isLanguage( name ) {
133
- return all_langs[name]!==undefined;
134
- }
327
+ err_403: `You do not have sufficient rights to do that action`,
135
328
 
136
- /**
137
- * select the current language
138
- * @param name - language name
139
- * @example ```typescript
140
- * selectLanguage( 'en' );
141
- */
142
-
143
- export function selectLanguage( name ) {
144
-
145
- if( !isLanguage(name) ) {
146
- return;
329
+ copy: 'Copy',
330
+ cut: 'Cut',
331
+ paste: 'Paste'
147
332
  }
333
+ };
148
334
 
149
- _tr = all_langs[name];
150
- }
335
+ createLanguage( 'fr', null );
336
+ addTranslation( 'fr', fr );
151
337
 
152
- /**
153
- * define a translation
154
- * you can also patch 'global' elements witch are defined by x4
155
- * @param name - language name
156
- * @param definition - definition of the language
157
- * @example ```typescript
158
- * setTranslation( 'fr', {
159
- * this_is_an_example: 'ceci est un exemple',
160
- * this_is: {
161
- * another_example: 'ceci est un autre exemple'
162
- * },
163
- * global: {
164
- * ok: 'O.K.'
165
- * }
166
- * });
167
- * console.log( _tr.this_is_an_example ); // defined by the previous line
168
- * selectLanguage( 'en' );
169
- * console.log( _tr.this_is_an_example ); // 'en' do not define this, so we get 'fr' one
170
- *
171
- */
338
+ createLanguage( 'en', 'fr' );
339
+ addTranslation( 'en', en );
172
340
 
173
- export function extendTranslation( name, definition ) {
174
-
175
- if( !isLanguage(name) ) {
176
- return;
177
- }
341
+ selectLanguage( 'fr' ); // by default
178
342
 
179
- _patch( all_langs[name], definition );
180
- }
181
343
 
182
344
 
183
- function _patch( obj, by ) {
184
- for( let n in by ) {
185
- if( obj[n] instanceof Object ) {
186
- _patch( obj[n], by[n] );
187
- }
188
- else {
189
- obj[n] = by[n];
190
- if( obj[n] instanceof Object ) {
191
- obj[n] = _mk_proxy( obj[n] );
192
- }
193
- }
194
- }
195
345
 
196
- return obj;
197
- }
198
346
 
199
- function _mk_proxy( obj: any ) : any {
200
- return new Proxy( obj, {
201
- get: function(target, prop, receiver) {
202
- let value = target[prop];
203
- if( value===undefined ) {
204
- return fr[prop];
205
- }
206
- return value;
207
- }
208
- });
209
- }
package/src/icon.ts CHANGED
@@ -30,7 +30,7 @@
30
30
  import { Component, CProps } from './component'
31
31
  import { Stylesheet } from './styles'
32
32
  import { HtmlString, isString } from './tools';
33
- import { BasicEvent, EvChange, EventMap, EventSource } from './x4_events';
33
+ import { BasicEvent, EvChange, EventMap, EventSource } from './x4events';
34
34
 
35
35
  // ============================================================================
36
36
  // [ICON]
@@ -153,6 +153,7 @@ export class Icon extends Component<IconProps>
153
153
  if (typeof (icon) === 'number') {
154
154
  icon = icon.toString(16);
155
155
  name = icon;
156
+ console.error( "deprecation error: invalid icon name" );
156
157
  }
157
158
  else {
158
159
  // var( <var-name> )
@@ -160,7 +161,7 @@ export class Icon extends Component<IconProps>
160
161
  // in the .css
161
162
  // --------------------------
162
163
  // :root {
163
- // --chevron-up: svgpath( "M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96z" );
164
+ // --chevron-up: data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96z"/></svg>';
164
165
  // }
165
166
  //
166
167
  // var( "--chevron-up" )
@@ -193,15 +194,6 @@ export class Icon extends Component<IconProps>
193
194
  return;
194
195
  }
195
196
 
196
- // svgpath( <svg-path> )
197
- // svgpath( "M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96z" )
198
- const reSvg3 = /\s*svgpath\s*\(\s*(.+)\s*\)\s*/gi;
199
- let match_pth = reSvg3.exec( icon );
200
- if( match_pth ) {
201
- const pth = this._setSVGPath( match_pth[1].trim( ) );
202
- return;
203
- }
204
-
205
197
  // data( <direct> )
206
198
  // data( "data:image/svg+xml;utf8,<svg...></svg>" )
207
199
 
@@ -212,6 +204,8 @@ export class Icon extends Component<IconProps>
212
204
  return;
213
205
  }
214
206
 
207
+ // cls( "fas fa-angle-up" )
208
+ //
215
209
  const reCls = /\s*cls\s*\(\s*(.+)\s*\)\s*/gi;
216
210
  let match_cls = reCls.exec( icon );
217
211
  if( match_cls ) {
@@ -220,6 +214,8 @@ export class Icon extends Component<IconProps>
220
214
  return;
221
215
  }
222
216
 
217
+ // url( "www.google.com" )
218
+ //
223
219
  const reUrl = /\s*url\s*\(\s*(.+)\s*\)\s*/gi;
224
220
  let match_url = reUrl.exec( icon );
225
221
  if( match_url ) {
@@ -234,6 +230,8 @@ export class Icon extends Component<IconProps>
234
230
  }
235
231
  else {
236
232
  // todo: deprecated
233
+ console.error( "deprecation error: invalid icon name" );
234
+
237
235
  name = icon;
238
236
  icon = Stylesheet.getVar( 'icon-'+icon ) as string;
239
237
 
@@ -241,7 +239,6 @@ export class Icon extends Component<IconProps>
241
239
  // name your icon 'icon-xxx'
242
240
  // ex:
243
241
  // :root { --icon-zoom-p: f00e; }
244
- console.assert( false );
245
242
  icon = '0';
246
243
  }
247
244
  }
package/src/image.ts CHANGED
@@ -27,6 +27,8 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
+ import { x4document } from './x4dom'
31
+
30
32
  import { Component, CProps, html } from './component'
31
33
 
32
34
  // ============================================================================
@@ -167,7 +169,7 @@ export class Image extends Component<ImageProps>
167
169
  src = el.src;
168
170
 
169
171
  // skip deleted elements
170
- if( !dom || !document.contains(dom) ) {
172
+ if( !dom || dom.offsetParent === null ) {
171
173
  // do not append to newList
172
174
  return;
173
175
  }
@@ -177,8 +179,8 @@ export class Image extends Component<ImageProps>
177
179
  // if it is visible & inserted inside the document
178
180
  if( !done && dom.offsetParent!==null &&
179
181
  rc.bottom >= 0 && rc.right >= 0 &&
180
- rc.top <= (window.innerHeight || document.documentElement.clientHeight) &&
181
- rc.left <= (window.innerWidth || document.documentElement.clientWidth) ) {
182
+ rc.top <= (window.innerHeight || x4document.documentElement.clientHeight) &&
183
+ rc.left <= (window.innerWidth || x4document.documentElement.clientWidth) ) {
182
184
 
183
185
  // ok, we load the image
184
186
  let img = <HTMLElement>dom.firstChild;
package/src/index.ts CHANGED
@@ -81,4 +81,4 @@ export * from "./toaster"
81
81
  export * from "./tools"
82
82
  export * from "./tooltips"
83
83
  export * from "./treeview"
84
- export * from "./x4_events"
84
+ export * from "./x4events"
package/src/input.ts CHANGED
@@ -84,7 +84,7 @@ export class Input extends Component<InputProps,InputEventMap>
84
84
  autofocus: props.autoFocus,
85
85
  readonly: props.readOnly,
86
86
  autocomplete: 'new-password', // chrome ignore 'off' but not something else than 'on'
87
- tabindex: props.tabIndex,
87
+ tabIndex: props.tabIndex,
88
88
  spellcheck: props.spellcheck===false ? 'false' : undefined,
89
89
  min: props.min,
90
90
  max: props.max,
package/src/layout.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
 
30
30
  import { Component, CProps, ComponentContent, Container, ContainerProps, ContainerEventMap } from './component'
31
- import { } from './x4_events'
31
+ import { } from './x4events'
32
32
  import { isArray } from './tools';
33
33
 
34
34
  // ============================================================================
package/src/link.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  **/
29
29
 
30
30
  import { Component, CProps, CEventMap, isHtmlString, HtmlString, html } from './component'
31
- import { EvClick, EventCallback } from './x4_events'
31
+ import { EvClick, EventCallback } from './x4events'
32
32
 
33
33
  // ============================================================================
34
34
  // [LINK]
package/src/listview.ts CHANGED
@@ -27,6 +27,8 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
+ import { x4document } from './x4dom'
31
+
30
32
  import { Container, Component, ContainerProps, ContainerEventMap, EvDblClick } from './component'
31
33
  import { IconID } from './icon';
32
34
  import { HLayout, VLayout } from './layout'
@@ -34,7 +36,7 @@ import { Popup, PopupEventMap, PopupProps } from './popup';
34
36
  import { HtmlString, isFunction } from './tools';
35
37
  import { Menu, MenuItem } from "./menu";
36
38
 
37
- import { EvContextMenu, EvSelectionChange, EvClick, EventCallback, BasicEvent, EvChange } from "./x4_events";
39
+ import { EvContextMenu, EvSelectionChange, EvClick, EventCallback, BasicEvent, EvChange } from "./x4events";
38
40
 
39
41
  /**
40
42
  * item definition
@@ -728,18 +730,18 @@ export class PopupListView extends Popup<PopupListViewProps,PopupListViewEventMa
728
730
 
729
731
  // todo: move into popup
730
732
  show(modal?: boolean) {
731
- document.addEventListener('mousedown', this._handleClick);
733
+ x4document.addEventListener('mousedown', this._handleClick);
732
734
  super.show(modal);
733
735
  }
734
736
 
735
737
  hide( ) {
736
- document.removeEventListener('mousedown', this._handleClick);
738
+ x4document.removeEventListener('mousedown', this._handleClick);
737
739
  super.hide( );
738
740
  }
739
741
 
740
742
  // todo: move into popup
741
743
  close() {
742
- document.removeEventListener('mousedown', this._handleClick);
744
+ x4document.removeEventListener('mousedown', this._handleClick);
743
745
  super.close();
744
746
  }
745
747
 
package/src/menu.ts CHANGED
@@ -27,8 +27,10 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
+ import { x4document } from './x4dom'
31
+
30
32
  import { CEventMap, Component, CProps } from './component'
31
- import { EvClick, EventCallback } from './x4_events'
33
+ import { EvClick, EventCallback } from './x4events'
32
34
 
33
35
  import { Popup, PopupProps } from './popup'
34
36
  import { Icon, IconID } from './icon'
@@ -155,7 +157,7 @@ export class Menu extends Popup<MenuProps>
155
157
  //console.log( 'addmenu' );
156
158
  if (Menu.watchCount == 0) {
157
159
  Menu.rootMenu = menu;
158
- document.addEventListener('mousedown', Menu._mouseWatcher);
160
+ x4document.addEventListener('mousedown', Menu._mouseWatcher);
159
161
  }
160
162
 
161
163
  Menu.watchCount++;
@@ -167,7 +169,7 @@ export class Menu extends Popup<MenuProps>
167
169
  Menu.watchCount--;
168
170
 
169
171
  if (Menu.watchCount == 0) {
170
- document.removeEventListener('mousedown', Menu._mouseWatcher);
172
+ x4document.removeEventListener('mousedown', Menu._mouseWatcher);
171
173
  }
172
174
  }
173
175
 
package/src/popup.ts CHANGED
@@ -27,9 +27,11 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
+ import { x4document } from './x4dom'
31
+
30
32
  import { Container, CProps, flyWrap, SizerOverlay, EvOverlayResize, Component, ContainerEventMap, EvSize } from './component'
31
33
  import { Point, Size, getMousePos, asap } from './tools'
32
- import { BasicEvent } from './x4_events';
34
+ import { BasicEvent } from './x4events';
33
35
  import { Application } from './application';
34
36
 
35
37
 
@@ -89,11 +91,11 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap =
89
91
  if (this.m_hasMask) {
90
92
 
91
93
  // remove the focus
92
- const focus = document.activeElement as HTMLElement;
94
+ const focus = x4document.activeElement as HTMLElement;
93
95
  if (focus) {
94
96
  focus.blur()
95
97
  }
96
- this.m_ui_mask = <HTMLElement>document.body.lastChild;
98
+ this.m_ui_mask = <HTMLElement>x4document.body.lastChild;
97
99
 
98
100
  while (this.m_ui_mask) {
99
101
 
@@ -134,13 +136,13 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap =
134
136
  top: 0
135
137
  });
136
138
 
137
- document.body.appendChild(this._build());
139
+ x4document.body.appendChild(this._build());
138
140
 
139
141
  this.removeClass('@hidden');
140
142
  this.centerOnScreen( );
141
143
 
142
144
  if (modal) {
143
- let focus = document.activeElement;
145
+ let focus = x4document.activeElement;
144
146
  if (!this.dom.contains(focus)) {
145
147
 
146
148
  const autofocus = this.queryItem('[autofocus]');
@@ -167,8 +169,8 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap =
167
169
  centerOnScreen( ) {
168
170
  let rc = this.getBoundingRect();
169
171
 
170
- let x = (document.body.clientWidth - rc.width) / 2,
171
- y = (document.body.clientHeight - rc.height) / 2;
172
+ let x = (x4document.body.clientWidth - rc.width) / 2,
173
+ y = (x4document.body.clientHeight - rc.height) / 2;
172
174
 
173
175
  this.setStyleValue('left', x);
174
176
  this.setStyleValue('top', y);
@@ -196,7 +198,7 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap =
196
198
  }
197
199
 
198
200
  // @TODO: this is a minimal overflow problem solution
199
- let rc = document.body.getBoundingClientRect(),
201
+ let rc = x4document.body.getBoundingClientRect(),
200
202
  rm = this.getBoundingRect();
201
203
 
202
204
  if (halign == 'r') {
@@ -418,7 +420,7 @@ function x4handleKeyDown(e: KeyboardEvent) {
418
420
  return;
419
421
  }
420
422
 
421
- let topStack = document.body;
423
+ let topStack = x4document.body;
422
424
  if (Popup.modal_stack.length) {
423
425
  topStack = Popup.modal_stack[Popup.modal_stack.length - 1];
424
426
  }
@@ -436,7 +438,7 @@ function x4handleKeyDown(e: KeyboardEvent) {
436
438
  function _nextTab(root: HTMLElement, el: HTMLElement, prev: boolean) {
437
439
 
438
440
  // first check if the focus is one of our child (disabled...)
439
- let focusEl = document.activeElement;
441
+ let focusEl = x4document.activeElement;
440
442
  if (!root.contains(focusEl)) {
441
443
  return;
442
444
  }
@@ -482,8 +484,8 @@ function _nextTab(root: HTMLElement, el: HTMLElement, prev: boolean) {
482
484
 
483
485
  function installKBHandler( ) {
484
486
  // set on body to be called after document (where all component domevent go)
485
- document.body.addEventListener('keydown', x4handleKeyDown, true);
487
+ x4document.body.addEventListener('keydown', x4handleKeyDown, true);
486
488
  }
487
489
 
488
490
  // too early ?
489
- document.body ? installKBHandler( ) : window.addEventListener( 'load', installKBHandler );
491
+ x4document.body ? installKBHandler( ) : window.addEventListener( 'load', installKBHandler );
@@ -28,7 +28,7 @@
28
28
  **/
29
29
 
30
30
  import { CEventMap, Component, CProps } from './component'
31
- import { EvChange, EventCallback } from './x4_events'
31
+ import { EvChange, EventCallback } from './x4events'
32
32
 
33
33
  import { InputProps, Input } from './input'
34
34
  import { TextEdit } from './textedit'