x4js 2.2.71 → 2.2.73

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.2.71",
3
+ "version": "2.2.73",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -425,6 +425,10 @@ export class Keyboard extends HBox<KeyboardProps>
425
425
  text = cb.call( this, caret, text, String.fromCharCode(key) );
426
426
  this.input.value = text;
427
427
  this._restoreCaretPos(caret);
428
+
429
+ //<eco: fire change event
430
+ this.input.dispatchEvent(new Event('input', { bubbles: true }));
431
+ this.input.dispatchEvent(new Event('change', { bubbles: true }));
428
432
  }
429
433
 
430
434
  /**
@@ -26,8 +26,6 @@
26
26
  translations: any;
27
27
  }
28
28
 
29
- const sym_lang = Symbol( "i18n" );
30
-
31
29
  let languages: Record<string,Language> = {
32
30
  };
33
31
 
@@ -211,7 +209,46 @@ function _findBaseTrans( base: any ) {
211
209
  return undefined;
212
210
  }
213
211
 
214
- export let _tr: Partial<typeof fr> = {};
212
+ /**
213
+ * current language state
214
+ */
215
+
216
+ const current = {
217
+ name: "",
218
+ translations: {} as any,
219
+ };
220
+
221
+ /**
222
+ * stable translation object: forwards every access to the current language,
223
+ * so references to _tr stay valid after selectLanguage
224
+ */
225
+
226
+ const tr_handler: ProxyHandler<any> = {
227
+ get( _target, prop ) {
228
+ return current.translations[prop];
229
+ },
230
+
231
+ has( _target, prop ) {
232
+ return prop in current.translations;
233
+ },
234
+
235
+ ownKeys( ) {
236
+ return Reflect.ownKeys( current.translations );
237
+ },
238
+
239
+ getOwnPropertyDescriptor( _target, prop ) {
240
+ const value = current.translations[prop];
241
+
242
+ if( value === undefined ) {
243
+ return undefined;
244
+ }
245
+
246
+ return { value, enumerable: true, configurable: true };
247
+ },
248
+ };
249
+
250
+ export const _tr: Partial<typeof fr> = new Proxy( {}, tr_handler );
251
+
215
252
 
216
253
  /**
217
254
  * select the given language as current
@@ -224,8 +261,9 @@ export function selectLanguage( name: string ) {
224
261
  return;
225
262
  }
226
263
 
227
- _tr = languages[name].translations;
228
- (_tr as any)[sym_lang] = name;
264
+ current.name = name;
265
+ current.translations = languages[name].translations;
266
+
229
267
  return _tr;
230
268
  }
231
269
 
@@ -234,7 +272,7 @@ export function selectLanguage( name: string ) {
234
272
  */
235
273
 
236
274
  export function getCurrentLanguage( ): string {
237
- return (_tr as any)[sym_lang];
275
+ return current.name;
238
276
  }
239
277
 
240
278
  /**
@@ -359,8 +397,8 @@ let en = {
359
397
  day_short: [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ],
360
398
  day_long: [ 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ],
361
399
 
362
- month_short: [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jui', 'aug', 'sep', 'oct', 'nov', 'dec' ],
363
- month_long: [ 'january', 'february', 'march', 'april', 'mau', 'june', 'jully', 'august', 'september', 'october', 'november', 'december' ],
400
+ month_short: [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ],
401
+ month_long: [ 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december' ],
364
402
 
365
403
  property: 'Property',
366
404
  value: 'Value',