@ngrdt/core 0.0.83 → 0.0.85
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/fesm2022/ngrdt-core.mjs +182 -255
- package/fesm2022/ngrdt-core.mjs.map +1 -1
- package/index.d.ts +182 -72
- package/package.json +2 -2
package/fesm2022/ngrdt-core.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, ElementRef, Directive, Injectable, DestroyRef, ViewContainerRef, input, effect, signal, computed, Pipe, booleanAttribute, untracked, linkedSignal, afterNextRender, isSignal } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, ElementRef, Directive, Injectable, DestroyRef, ViewContainerRef, input, effect, signal, computed, LOCALE_ID, Pipe, booleanAttribute, untracked, linkedSignal, afterNextRender, isSignal } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import { of, concat, filter, map, catchError, defer, from } from 'rxjs';
|
|
5
|
+
import { cs, enUS } from 'date-fns/locale';
|
|
6
|
+
import { formatDate } from 'date-fns';
|
|
7
|
+
import { toObservable } from '@angular/core/rxjs-interop';
|
|
5
8
|
import { RdtObjectUtils } from '@ngrdt/utils';
|
|
6
9
|
|
|
7
10
|
const RDT_AUTOFOCUSABLE_COMPONENT = new InjectionToken('');
|
|
@@ -380,280 +383,181 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
380
383
|
type: Directive
|
|
381
384
|
}] });
|
|
382
385
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
RDT_SELECT_LOADING_ID: RDT_SELECT_LOADING_ID$1,
|
|
422
|
-
RDT_SELECT_UNKNOWN_ID: RDT_SELECT_UNKNOWN_ID$1,
|
|
423
|
-
RDT_TABLE_NOT_FOUND_HEADER: RDT_TABLE_NOT_FOUND_HEADER$1,
|
|
424
|
-
RDT_TABLE_NOT_FOUND_MESSAGE: RDT_TABLE_NOT_FOUND_MESSAGE$1,
|
|
425
|
-
RDT_TABLE_ERROR_HEADER: RDT_TABLE_ERROR_HEADER$1,
|
|
426
|
-
RDT_TABLE_ERROR_MESSAGE: RDT_TABLE_ERROR_MESSAGE$1,
|
|
427
|
-
RDT_FILE_LABEL_EMPTY: RDT_FILE_LABEL_EMPTY$1,
|
|
428
|
-
RDT_FILE_LABEL_SINGLE: RDT_FILE_LABEL_SINGLE$1,
|
|
429
|
-
RDT_FILE_LABEL_FEW: RDT_FILE_LABEL_FEW$1,
|
|
430
|
-
RDT_FILE_LABEL_MANY: RDT_FILE_LABEL_MANY$1,
|
|
431
|
-
RDT_DATE_TOO_LATE: RDT_DATE_TOO_LATE$1,
|
|
432
|
-
RDT_DATE_TOO_SOON: RDT_DATE_TOO_SOON$1,
|
|
433
|
-
RDT_ERROR_REQUIRED: RDT_ERROR_REQUIRED$1,
|
|
434
|
-
RDT_ERROR_EMAIL_INVALID: RDT_ERROR_EMAIL_INVALID$1,
|
|
435
|
-
RDT_ERROR_MIN_LENGTH: RDT_ERROR_MIN_LENGTH$1,
|
|
436
|
-
RDT_ERROR_MAX_LENGTH: RDT_ERROR_MAX_LENGTH$1,
|
|
437
|
-
RDT_ERROR_NOT_FOUND: RDT_ERROR_NOT_FOUND$1,
|
|
438
|
-
RDT_ERROR_MULTIPLE_FOUND: RDT_ERROR_MULTIPLE_FOUND$1,
|
|
439
|
-
RDT_ERROR_UNKNOWN: RDT_ERROR_UNKNOWN$1,
|
|
440
|
-
RDT_GOV_SELECT_LOADING_VALUES: RDT_GOV_SELECT_LOADING_VALUES$1,
|
|
441
|
-
RDT_GOV_SELECT_NO_VALUES_FOUND: RDT_GOV_SELECT_NO_VALUES_FOUND$1,
|
|
442
|
-
RDT_GOV_SELECT_NO_VALUES_AVAILABLE: RDT_GOV_SELECT_NO_VALUES_AVAILABLE$1,
|
|
443
|
-
RDT_GOV_NOTIFY_SUCCESS: RDT_GOV_NOTIFY_SUCCESS$1,
|
|
444
|
-
RDT_GOV_NOTIFY_WARNING: RDT_GOV_NOTIFY_WARNING$1,
|
|
445
|
-
RDT_GOV_NOTIFY_ERROR: RDT_GOV_NOTIFY_ERROR$1
|
|
386
|
+
const csRdtDictionary = {
|
|
387
|
+
RDT_YES: 'Ano',
|
|
388
|
+
RDT_NO: 'Ne',
|
|
389
|
+
RDT_SELECT_DEFAULT_PLACEHOLDER: 'Vyberte',
|
|
390
|
+
RDT_SELECT_LOADING: 'Načítání',
|
|
391
|
+
RDT_SELECT_ERROR: 'Nastala chyba',
|
|
392
|
+
RDT_SELECT_ENTER_SEARCH: 'Zadejte hledaný výraz',
|
|
393
|
+
RDT_SELECT_LOADING_ID: 'Načítání (ID = {{id}})...',
|
|
394
|
+
RDT_SELECT_UNKNOWN_ID: 'Neznámá hodnota (ID = {{id}})',
|
|
395
|
+
RDT_TABLE_NOT_FOUND_HEADER: 'Nic nenalezeno',
|
|
396
|
+
RDT_TABLE_NOT_FOUND_MESSAGE: 'Nepodařilo se dohledat žádné výsledky, zkuste prosím hledaný výraz upravit.',
|
|
397
|
+
RDT_TABLE_ERROR_HEADER: 'Při načítání dat došlo k chybě.',
|
|
398
|
+
RDT_TABLE_ERROR_MESSAGE: 'Chyba',
|
|
399
|
+
RDT_FILE_LABEL_EMPTY: 'Vyberte soubor',
|
|
400
|
+
RDT_FILE_LABEL_SINGLE: '{{fileName}}',
|
|
401
|
+
RDT_FILE_LABEL_FEW: 'Vybrány {{count}} soubory',
|
|
402
|
+
RDT_FILE_LABEL_MANY: 'Vybráno {{count}} souborů',
|
|
403
|
+
RDT_DATE_TOO_LATE: 'Platnost od musí být dříve než platnost do.',
|
|
404
|
+
RDT_DATE_TOO_SOON: 'Platnost do musí být později než platnost od.',
|
|
405
|
+
RDT_ERROR_REQUIRED: 'Povinné pole',
|
|
406
|
+
RDT_ERROR_EMAIL_INVALID: 'Neplatný email',
|
|
407
|
+
RDT_ERROR_MIN_LENGTH: 'Minimální délka je {{requiredLength}} znaků.',
|
|
408
|
+
RDT_ERROR_MAX_LENGTH: 'Maximální délka je {{requiredLength}} znaků.',
|
|
409
|
+
RDT_ERROR_NOT_FOUND: 'Pro zadaný kód nebyla nalezena žádná položka.',
|
|
410
|
+
RDT_ERROR_MULTIPLE_FOUND: 'Pro zadaný kód bylo nalezeno více položek.',
|
|
411
|
+
RDT_ERROR_UNKNOWN: 'Neznámá chyba',
|
|
412
|
+
RDT_GOV_SELECT_LOADING_VALUES: 'Načítání hodnot..',
|
|
413
|
+
RDT_GOV_SELECT_NO_VALUES_FOUND: 'Pro zadaný výraz nejsou k dispozici žádné záznamy',
|
|
414
|
+
RDT_GOV_SELECT_NO_VALUES_AVAILABLE: 'Nejsou k dispozici žádné hodnoty',
|
|
415
|
+
RDT_GOV_NOTIFY_SUCCESS: 'Operace byla úspěšně dokončena.',
|
|
416
|
+
RDT_GOV_NOTIFY_WARNING: 'Operace proběhla s upozorněním.',
|
|
417
|
+
RDT_GOV_NOTIFY_ERROR: 'Operace se nezdařila',
|
|
418
|
+
RDT_GOV_DATE_CALENDAR_LABEL: 'Kalendář',
|
|
419
|
+
RDT_GOV_DATE_OPEN_CALENDAR: 'Otevřít kalendář',
|
|
420
|
+
RDT_GOV_DATE_PREV_MONTH: 'Předchozí měsíc',
|
|
421
|
+
RDT_GOV_DATE_NEXT_MONTH: 'Další měsíc',
|
|
422
|
+
RDT_GOV_DATE_PREV_YEAR: 'Předchozí rok',
|
|
423
|
+
RDT_GOV_DATE_NEXT_YEAR: 'Další rok',
|
|
446
424
|
};
|
|
447
425
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
RDT_FILE_LABEL_SINGLE:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
var RDT_SELECT_DEFAULT_PLACEHOLDER = "Select";
|
|
487
|
-
var RDT_SELECT_LOADING = "Loading";
|
|
488
|
-
var RDT_SELECT_ERROR = "An error occurred";
|
|
489
|
-
var RDT_SELECT_ENTER_SEARCH = "Enter search term";
|
|
490
|
-
var RDT_SELECT_LOADING_ID = "Loading (ID = {{id}})...";
|
|
491
|
-
var RDT_SELECT_UNKNOWN_ID = "Unknown value (ID = {{id}})";
|
|
492
|
-
var RDT_TABLE_NOT_FOUND_HEADER = "Nothing found";
|
|
493
|
-
var RDT_TABLE_NOT_FOUND_MESSAGE = "No results could be found, please adjust your search term.";
|
|
494
|
-
var RDT_TABLE_ERROR_HEADER = "Error loading data.";
|
|
495
|
-
var RDT_TABLE_ERROR_MESSAGE = "Error";
|
|
496
|
-
var RDT_FILE_LABEL_EMPTY = "Select file";
|
|
497
|
-
var RDT_FILE_LABEL_SINGLE = "{{fileName}}";
|
|
498
|
-
var RDT_FILE_LABEL_FEW = "{{count}} files selected";
|
|
499
|
-
var RDT_FILE_LABEL_MANY = "{{count}} files selected";
|
|
500
|
-
var RDT_DATE_TOO_LATE = "Start date must be before end date.";
|
|
501
|
-
var RDT_DATE_TOO_SOON = "End date must be after start date.";
|
|
502
|
-
var RDT_ERROR_REQUIRED = "Required field";
|
|
503
|
-
var RDT_ERROR_EMAIL_INVALID = "Invalid email";
|
|
504
|
-
var RDT_ERROR_MIN_LENGTH = "Minimum length is {{requiredLength}} characters.";
|
|
505
|
-
var RDT_ERROR_MAX_LENGTH = "Maximum length is {{requiredLength}} characters.";
|
|
506
|
-
var RDT_ERROR_NOT_FOUND = "No item found for the provided code.";
|
|
507
|
-
var RDT_ERROR_MULTIPLE_FOUND = "Multiple items found for the provided code.";
|
|
508
|
-
var RDT_ERROR_UNKNOWN = "Unknown error";
|
|
509
|
-
var RDT_GOV_SELECT_LOADING_VALUES = "Loading values...";
|
|
510
|
-
var RDT_GOV_SELECT_NO_VALUES_FOUND = "No records available for the entered term";
|
|
511
|
-
var RDT_GOV_SELECT_NO_VALUES_AVAILABLE = "No values available";
|
|
512
|
-
var RDT_GOV_NOTIFY_SUCCESS = "Operation completed successfully.";
|
|
513
|
-
var RDT_GOV_NOTIFY_WARNING = "Operation completed with a warning.";
|
|
514
|
-
var RDT_GOV_NOTIFY_ERROR = "Operation failed.";
|
|
515
|
-
var en = {
|
|
516
|
-
RDT_YES: RDT_YES,
|
|
517
|
-
RDT_NO: RDT_NO,
|
|
518
|
-
RDT_SELECT_DEFAULT_PLACEHOLDER: RDT_SELECT_DEFAULT_PLACEHOLDER,
|
|
519
|
-
RDT_SELECT_LOADING: RDT_SELECT_LOADING,
|
|
520
|
-
RDT_SELECT_ERROR: RDT_SELECT_ERROR,
|
|
521
|
-
RDT_SELECT_ENTER_SEARCH: RDT_SELECT_ENTER_SEARCH,
|
|
522
|
-
RDT_SELECT_LOADING_ID: RDT_SELECT_LOADING_ID,
|
|
523
|
-
RDT_SELECT_UNKNOWN_ID: RDT_SELECT_UNKNOWN_ID,
|
|
524
|
-
RDT_TABLE_NOT_FOUND_HEADER: RDT_TABLE_NOT_FOUND_HEADER,
|
|
525
|
-
RDT_TABLE_NOT_FOUND_MESSAGE: RDT_TABLE_NOT_FOUND_MESSAGE,
|
|
526
|
-
RDT_TABLE_ERROR_HEADER: RDT_TABLE_ERROR_HEADER,
|
|
527
|
-
RDT_TABLE_ERROR_MESSAGE: RDT_TABLE_ERROR_MESSAGE,
|
|
528
|
-
RDT_FILE_LABEL_EMPTY: RDT_FILE_LABEL_EMPTY,
|
|
529
|
-
RDT_FILE_LABEL_SINGLE: RDT_FILE_LABEL_SINGLE,
|
|
530
|
-
RDT_FILE_LABEL_FEW: RDT_FILE_LABEL_FEW,
|
|
531
|
-
RDT_FILE_LABEL_MANY: RDT_FILE_LABEL_MANY,
|
|
532
|
-
RDT_DATE_TOO_LATE: RDT_DATE_TOO_LATE,
|
|
533
|
-
RDT_DATE_TOO_SOON: RDT_DATE_TOO_SOON,
|
|
534
|
-
RDT_ERROR_REQUIRED: RDT_ERROR_REQUIRED,
|
|
535
|
-
RDT_ERROR_EMAIL_INVALID: RDT_ERROR_EMAIL_INVALID,
|
|
536
|
-
RDT_ERROR_MIN_LENGTH: RDT_ERROR_MIN_LENGTH,
|
|
537
|
-
RDT_ERROR_MAX_LENGTH: RDT_ERROR_MAX_LENGTH,
|
|
538
|
-
RDT_ERROR_NOT_FOUND: RDT_ERROR_NOT_FOUND,
|
|
539
|
-
RDT_ERROR_MULTIPLE_FOUND: RDT_ERROR_MULTIPLE_FOUND,
|
|
540
|
-
RDT_ERROR_UNKNOWN: RDT_ERROR_UNKNOWN,
|
|
541
|
-
RDT_GOV_SELECT_LOADING_VALUES: RDT_GOV_SELECT_LOADING_VALUES,
|
|
542
|
-
RDT_GOV_SELECT_NO_VALUES_FOUND: RDT_GOV_SELECT_NO_VALUES_FOUND,
|
|
543
|
-
RDT_GOV_SELECT_NO_VALUES_AVAILABLE: RDT_GOV_SELECT_NO_VALUES_AVAILABLE,
|
|
544
|
-
RDT_GOV_NOTIFY_SUCCESS: RDT_GOV_NOTIFY_SUCCESS,
|
|
545
|
-
RDT_GOV_NOTIFY_WARNING: RDT_GOV_NOTIFY_WARNING,
|
|
546
|
-
RDT_GOV_NOTIFY_ERROR: RDT_GOV_NOTIFY_ERROR
|
|
426
|
+
const enUsRdtDictionary = {
|
|
427
|
+
RDT_YES: 'Yes',
|
|
428
|
+
RDT_NO: 'No',
|
|
429
|
+
RDT_SELECT_DEFAULT_PLACEHOLDER: 'Select',
|
|
430
|
+
RDT_SELECT_LOADING: 'Loading',
|
|
431
|
+
RDT_SELECT_ERROR: 'An error occurred',
|
|
432
|
+
RDT_SELECT_ENTER_SEARCH: 'Enter search term',
|
|
433
|
+
RDT_SELECT_LOADING_ID: 'Loading (ID = {{id}})...',
|
|
434
|
+
RDT_SELECT_UNKNOWN_ID: 'Unknown value (ID = {{id}})',
|
|
435
|
+
RDT_TABLE_NOT_FOUND_HEADER: 'Nothing found',
|
|
436
|
+
RDT_TABLE_NOT_FOUND_MESSAGE: 'No results could be found, please adjust your search term.',
|
|
437
|
+
RDT_TABLE_ERROR_HEADER: 'Error loading data.',
|
|
438
|
+
RDT_TABLE_ERROR_MESSAGE: 'Error',
|
|
439
|
+
RDT_FILE_LABEL_EMPTY: 'Select file',
|
|
440
|
+
RDT_FILE_LABEL_SINGLE: '{{fileName}}',
|
|
441
|
+
RDT_FILE_LABEL_FEW: '{{count}} files selected',
|
|
442
|
+
RDT_FILE_LABEL_MANY: '{{count}} files selected',
|
|
443
|
+
RDT_DATE_TOO_LATE: 'Start date must be before end date.',
|
|
444
|
+
RDT_DATE_TOO_SOON: 'End date must be after start date.',
|
|
445
|
+
RDT_ERROR_REQUIRED: 'Required field',
|
|
446
|
+
RDT_ERROR_EMAIL_INVALID: 'Invalid email',
|
|
447
|
+
RDT_ERROR_MIN_LENGTH: 'Minimum length is {{requiredLength}} characters.',
|
|
448
|
+
RDT_ERROR_MAX_LENGTH: 'Maximum length is {{requiredLength}} characters.',
|
|
449
|
+
RDT_ERROR_NOT_FOUND: 'No item found for the provided code.',
|
|
450
|
+
RDT_ERROR_MULTIPLE_FOUND: 'Multiple items found for the provided code.',
|
|
451
|
+
RDT_ERROR_UNKNOWN: 'Unknown error',
|
|
452
|
+
RDT_GOV_SELECT_LOADING_VALUES: 'Loading values...',
|
|
453
|
+
RDT_GOV_SELECT_NO_VALUES_FOUND: 'No records available for the entered term',
|
|
454
|
+
RDT_GOV_SELECT_NO_VALUES_AVAILABLE: 'No values available',
|
|
455
|
+
RDT_GOV_NOTIFY_SUCCESS: 'Operation completed successfully.',
|
|
456
|
+
RDT_GOV_NOTIFY_WARNING: 'Operation completed with a warning.',
|
|
457
|
+
RDT_GOV_NOTIFY_ERROR: 'Operation failed.',
|
|
458
|
+
RDT_GOV_DATE_CALENDAR_LABEL: 'Calendar',
|
|
459
|
+
RDT_GOV_DATE_OPEN_CALENDAR: 'Open calendar',
|
|
460
|
+
RDT_GOV_DATE_PREV_MONTH: 'Previous month',
|
|
461
|
+
RDT_GOV_DATE_NEXT_MONTH: 'Next month',
|
|
462
|
+
RDT_GOV_DATE_PREV_YEAR: 'Previous year',
|
|
463
|
+
RDT_GOV_DATE_NEXT_YEAR: 'Next year',
|
|
547
464
|
};
|
|
548
465
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
RDT_ERROR_MIN_LENGTH: RDT_ERROR_MIN_LENGTH,
|
|
556
|
-
RDT_ERROR_MULTIPLE_FOUND: RDT_ERROR_MULTIPLE_FOUND,
|
|
557
|
-
RDT_ERROR_NOT_FOUND: RDT_ERROR_NOT_FOUND,
|
|
558
|
-
RDT_ERROR_REQUIRED: RDT_ERROR_REQUIRED,
|
|
559
|
-
RDT_ERROR_UNKNOWN: RDT_ERROR_UNKNOWN,
|
|
560
|
-
RDT_FILE_LABEL_EMPTY: RDT_FILE_LABEL_EMPTY,
|
|
561
|
-
RDT_FILE_LABEL_FEW: RDT_FILE_LABEL_FEW,
|
|
562
|
-
RDT_FILE_LABEL_MANY: RDT_FILE_LABEL_MANY,
|
|
563
|
-
RDT_FILE_LABEL_SINGLE: RDT_FILE_LABEL_SINGLE,
|
|
564
|
-
RDT_GOV_NOTIFY_ERROR: RDT_GOV_NOTIFY_ERROR,
|
|
565
|
-
RDT_GOV_NOTIFY_SUCCESS: RDT_GOV_NOTIFY_SUCCESS,
|
|
566
|
-
RDT_GOV_NOTIFY_WARNING: RDT_GOV_NOTIFY_WARNING,
|
|
567
|
-
RDT_GOV_SELECT_LOADING_VALUES: RDT_GOV_SELECT_LOADING_VALUES,
|
|
568
|
-
RDT_GOV_SELECT_NO_VALUES_AVAILABLE: RDT_GOV_SELECT_NO_VALUES_AVAILABLE,
|
|
569
|
-
RDT_GOV_SELECT_NO_VALUES_FOUND: RDT_GOV_SELECT_NO_VALUES_FOUND,
|
|
570
|
-
RDT_NO: RDT_NO,
|
|
571
|
-
RDT_SELECT_DEFAULT_PLACEHOLDER: RDT_SELECT_DEFAULT_PLACEHOLDER,
|
|
572
|
-
RDT_SELECT_ENTER_SEARCH: RDT_SELECT_ENTER_SEARCH,
|
|
573
|
-
RDT_SELECT_ERROR: RDT_SELECT_ERROR,
|
|
574
|
-
RDT_SELECT_LOADING: RDT_SELECT_LOADING,
|
|
575
|
-
RDT_SELECT_LOADING_ID: RDT_SELECT_LOADING_ID,
|
|
576
|
-
RDT_SELECT_UNKNOWN_ID: RDT_SELECT_UNKNOWN_ID,
|
|
577
|
-
RDT_TABLE_ERROR_HEADER: RDT_TABLE_ERROR_HEADER,
|
|
578
|
-
RDT_TABLE_ERROR_MESSAGE: RDT_TABLE_ERROR_MESSAGE,
|
|
579
|
-
RDT_TABLE_NOT_FOUND_HEADER: RDT_TABLE_NOT_FOUND_HEADER,
|
|
580
|
-
RDT_TABLE_NOT_FOUND_MESSAGE: RDT_TABLE_NOT_FOUND_MESSAGE,
|
|
581
|
-
RDT_YES: RDT_YES,
|
|
582
|
-
default: en
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
const DEFAULT_TRANSLATE_SET = {
|
|
586
|
-
cs: csTranslates,
|
|
587
|
-
en: enTranslates,
|
|
588
|
-
};
|
|
589
|
-
class CzFormatStrategy {
|
|
590
|
-
formatDate(date) {
|
|
591
|
-
return date.toLocaleDateString('cs-CZ');
|
|
592
|
-
}
|
|
593
|
-
formatNumber(value) {
|
|
594
|
-
return new Intl.NumberFormat('cs-CZ').format(value);
|
|
595
|
-
}
|
|
596
|
-
formatCurrency(value, currency) {
|
|
597
|
-
return new Intl.NumberFormat('cs-CZ', {
|
|
598
|
-
style: 'currency',
|
|
599
|
-
currency: currency,
|
|
600
|
-
}).format(value);
|
|
466
|
+
class RdtLocaleFormat {
|
|
467
|
+
dateFnsLocale;
|
|
468
|
+
formatLocale;
|
|
469
|
+
constructor(config) {
|
|
470
|
+
this.dateFnsLocale = config.dateFnsLocale;
|
|
471
|
+
this.formatLocale = config.formatLocale;
|
|
601
472
|
}
|
|
602
|
-
}
|
|
603
|
-
class EnFormatStrategy {
|
|
604
473
|
formatDate(date) {
|
|
605
|
-
return date
|
|
474
|
+
return formatDate(date, 'P', { locale: this.dateFnsLocale });
|
|
606
475
|
}
|
|
607
476
|
formatNumber(value) {
|
|
608
|
-
return new Intl.NumberFormat(
|
|
477
|
+
return new Intl.NumberFormat(this.formatLocale).format(value);
|
|
609
478
|
}
|
|
610
479
|
formatCurrency(value, currency) {
|
|
611
|
-
return new Intl.NumberFormat(
|
|
480
|
+
return new Intl.NumberFormat(this.formatLocale, {
|
|
612
481
|
style: 'currency',
|
|
613
482
|
currency: currency,
|
|
614
483
|
}).format(value);
|
|
615
484
|
}
|
|
616
485
|
}
|
|
617
486
|
|
|
618
|
-
const
|
|
487
|
+
const csRdtLocaleFormat = new RdtLocaleFormat({
|
|
488
|
+
dateFnsLocale: cs,
|
|
489
|
+
formatLocale: 'cs-CZ',
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
const enUsRdtLocaleFormat = new RdtLocaleFormat({
|
|
493
|
+
dateFnsLocale: enUS,
|
|
494
|
+
formatLocale: 'en-US',
|
|
495
|
+
});
|
|
619
496
|
|
|
497
|
+
const RDT_DEFAULT_LOCALE_STORE = {
|
|
498
|
+
'cs-CZ': {
|
|
499
|
+
dictionary: csRdtDictionary,
|
|
500
|
+
format: csRdtLocaleFormat,
|
|
501
|
+
},
|
|
502
|
+
'en-US': {
|
|
503
|
+
dictionary: enUsRdtDictionary,
|
|
504
|
+
format: enUsRdtLocaleFormat,
|
|
505
|
+
},
|
|
506
|
+
};
|
|
507
|
+
const RDT_LOCALE_STORE_PROVIDER = new InjectionToken('RDT_LOCALE_STORE_PROVIDER', {
|
|
508
|
+
providedIn: 'root',
|
|
509
|
+
factory: () => RDT_DEFAULT_LOCALE_STORE,
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// This locale is necessary and must always be present.
|
|
513
|
+
const DEFAULT_LOCALE = 'cs-CZ';
|
|
620
514
|
class RdtTranslateService {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
515
|
+
_localeStore = signal(inject(RDT_LOCALE_STORE_PROVIDER));
|
|
516
|
+
availableLocales = computed(() => Object.keys(this._localeStore()));
|
|
517
|
+
_localeCode = signal(this.getNearestLocaleCode(inject(LOCALE_ID)));
|
|
518
|
+
currentLocaleCode = this._localeCode.asReadonly();
|
|
519
|
+
currentLanguage = computed(() => this._localeCode().split('-')[0]);
|
|
520
|
+
currentLocale = computed(() => this._localeStore()[this._localeCode()] ??
|
|
521
|
+
this._localeStore()[DEFAULT_LOCALE]);
|
|
522
|
+
currentFormat = computed(() => this.currentLocale().format);
|
|
523
|
+
currentDictionary = computed(() => this.currentLocale().dictionary);
|
|
524
|
+
currentLocaleChange$ = toObservable(this.currentLocale);
|
|
624
525
|
constructor() {
|
|
625
|
-
if (!this.
|
|
626
|
-
|
|
526
|
+
if (!this._localeStore()[DEFAULT_LOCALE]) {
|
|
527
|
+
throw new Error(`Default locale '${DEFAULT_LOCALE}' is missing in the dictionary store.`);
|
|
627
528
|
}
|
|
628
|
-
this.addLanguage(DEFAULT_TRANSLATE_SET);
|
|
629
529
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
code: 'cs',
|
|
633
|
-
strategy: new CzFormatStrategy(),
|
|
634
|
-
});
|
|
635
|
-
strategy = computed(() => {
|
|
636
|
-
return (this.language().strategy ?? this.defaultStrategy ?? new CzFormatStrategy());
|
|
637
|
-
});
|
|
638
|
-
get currentLanguage() {
|
|
639
|
-
return this.language().code;
|
|
530
|
+
setCurrentLocale(locale) {
|
|
531
|
+
this._localeCode.set(this.getNearestLocaleCode(locale));
|
|
640
532
|
}
|
|
641
533
|
formatDate(date) {
|
|
642
|
-
return this.
|
|
534
|
+
return this.currentFormat().formatDate(date);
|
|
643
535
|
}
|
|
644
536
|
formatCurrency(value, currency) {
|
|
645
|
-
return this.
|
|
537
|
+
return this.currentFormat().formatCurrency(value, currency);
|
|
646
538
|
}
|
|
647
539
|
formatNumber(value) {
|
|
648
|
-
return this.
|
|
540
|
+
return this.currentFormat().formatNumber(value);
|
|
649
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Translates given key using current dictionary.
|
|
544
|
+
* Will trigger warnings if translation or parameters are missing.
|
|
545
|
+
* Will trigger effect re-evaluation when current locale changes.
|
|
546
|
+
* @param key RdtTranslateKey
|
|
547
|
+
* @param params RdtTranslateParams | string[]
|
|
548
|
+
* @returns Translated string.
|
|
549
|
+
*/
|
|
650
550
|
instant(key, params) {
|
|
651
|
-
const currentTranslateSet = this.
|
|
652
|
-
if (!currentTranslateSet)
|
|
551
|
+
const currentTranslateSet = this.currentDictionary();
|
|
552
|
+
if (!currentTranslateSet) {
|
|
553
|
+
console.warn(`Missing translation set for locale: '${this._localeCode()}'`);
|
|
653
554
|
return key;
|
|
555
|
+
}
|
|
654
556
|
const value = currentTranslateSet[key];
|
|
655
|
-
if (!value)
|
|
557
|
+
if (!value) {
|
|
558
|
+
console.warn(`Missing translation for key '${key}' for locale: '${this._localeCode()}'`);
|
|
656
559
|
return key;
|
|
560
|
+
}
|
|
657
561
|
if (typeof value === 'function') {
|
|
658
562
|
return value(Array.isArray(params) ? {} : params);
|
|
659
563
|
}
|
|
@@ -673,22 +577,45 @@ class RdtTranslateService {
|
|
|
673
577
|
});
|
|
674
578
|
}
|
|
675
579
|
}
|
|
580
|
+
if (template.includes('{{') && template.includes('}}')) {
|
|
581
|
+
console.warn(`Translation for key '${key}' is missing parameters: ${template}`);
|
|
582
|
+
}
|
|
676
583
|
return template;
|
|
677
584
|
}
|
|
678
|
-
|
|
679
|
-
|
|
585
|
+
updateDictionary(localeCode, dictionary) {
|
|
586
|
+
this._localeStore.update((store) => ({
|
|
587
|
+
...store,
|
|
588
|
+
[localeCode]: {
|
|
589
|
+
...store[localeCode],
|
|
590
|
+
dictionary: {
|
|
591
|
+
...store[localeCode]?.dictionary,
|
|
592
|
+
...dictionary,
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
}));
|
|
680
596
|
}
|
|
681
|
-
|
|
682
|
-
this.
|
|
597
|
+
registerLocale(code, locale) {
|
|
598
|
+
this._localeStore.update((store) => ({
|
|
599
|
+
...store,
|
|
600
|
+
[code]: locale,
|
|
601
|
+
}));
|
|
683
602
|
}
|
|
684
|
-
|
|
685
|
-
this.
|
|
603
|
+
isLocaleAvailable(locale) {
|
|
604
|
+
return this.availableLocales().includes(locale);
|
|
686
605
|
}
|
|
687
|
-
|
|
688
|
-
this.
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
606
|
+
getNearestLocaleCode(locale) {
|
|
607
|
+
const availableLocales = this.availableLocales();
|
|
608
|
+
if (this.isLocaleAvailable(locale)) {
|
|
609
|
+
return locale;
|
|
610
|
+
}
|
|
611
|
+
const shortLang = locale.split('-')[0];
|
|
612
|
+
const matchedLang = availableLocales.find((l) => l.startsWith(`${shortLang}-`));
|
|
613
|
+
if (matchedLang) {
|
|
614
|
+
console.warn(`Locale '${locale}' not found, falling back to '${matchedLang}'.`);
|
|
615
|
+
return matchedLang;
|
|
616
|
+
}
|
|
617
|
+
console.warn(`Locale '${locale}' not found, falling back to default locale '${DEFAULT_LOCALE}'.`);
|
|
618
|
+
return DEFAULT_LOCALE;
|
|
692
619
|
}
|
|
693
620
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: RdtTranslateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
694
621
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: RdtTranslateService, providedIn: 'root' });
|
|
@@ -857,5 +784,5 @@ function rdtCreateLinkedState(params) {
|
|
|
857
784
|
* Generated bundle index. Do not edit.
|
|
858
785
|
*/
|
|
859
786
|
|
|
860
|
-
export {
|
|
787
|
+
export { RDT_AUTOFOCUSABLE_COMPONENT, RDT_CONTAINER, RDT_DEFAULT_DISABLED_KEY, RDT_DEFAULT_LOADING_KEY, RDT_DEFAULT_LOCALE_STORE, RDT_GUARDED_COMPONENT, RDT_LOCALE_STORE_PROVIDER, RdtAutoFocusOnInitDirective, RdtAutofocusableDirective, RdtChildDirective, RdtComponentGuardStoreService, RdtComponentOutletDirective, RdtContainerDirective, RdtFormatPipe, RdtInteractiveElementComponent, RdtLocaleFormat, RdtTranslatePipe, RdtTranslateService, canTransition$, csRdtDictionary, csRdtLocaleFormat, enUsRdtDictionary, enUsRdtLocaleFormat, getRdtAutofocusable, rdtCreateLinkedState, rdtGetAllResultsTrue$, rdtGetResult$ };
|
|
861
788
|
//# sourceMappingURL=ngrdt-core.mjs.map
|