@ngrdt/forms 0.0.80 → 0.0.81
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-forms.mjs +43 -31
- package/fesm2022/ngrdt-forms.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/package.json +3 -3
package/fesm2022/ngrdt-forms.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { inject, Injector, signal, model, linkedSignal, input, booleanAttribute, computed, effect, untracked, Directive, InjectionToken, output, forwardRef, numberAttribute, ElementRef, Pipe } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { FormControlName, FormControlDirective, NgModel, NgControl, Validators, NG_VALUE_ACCESSOR, FormControl, FormGroup } from '@angular/forms';
|
|
5
|
-
import { RdtInteractiveElementComponent, RdtComponentOutletDirective } from '@ngrdt/core';
|
|
5
|
+
import { RdtInteractiveElementComponent, RdtComponentOutletDirective, RdtTranslateService } from '@ngrdt/core';
|
|
6
6
|
import { startWith, take, map, forkJoin, of, from, switchMap, debounceTime, distinctUntilChanged, merge, takeUntil } from 'rxjs';
|
|
7
7
|
import { RdtFileUtils, RdtObjectUtils, RdtDateUtils } from '@ngrdt/utils';
|
|
8
8
|
import { signalStore, withState, withHooks, withComputed, withMethods, patchState } from '@ngrx/signals';
|
|
@@ -407,23 +407,27 @@ const RDT_DEFAULT_FILE_READER = new InjectionToken('RDT_DEFAULT_FILE_READER', {
|
|
|
407
407
|
providedIn: 'root',
|
|
408
408
|
});
|
|
409
409
|
|
|
410
|
-
function
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
410
|
+
function fileLabelTranslate(translate, files) {
|
|
411
|
+
const count = files.length;
|
|
412
|
+
if (count === 0) {
|
|
413
|
+
return translate.instant('RDT_FILE_LABEL_EMPTY');
|
|
414
|
+
}
|
|
415
|
+
if (count === 1) {
|
|
416
|
+
return translate.instant('RDT_FILE_LABEL_SINGLE', {
|
|
417
|
+
fileName: files[0].fileName,
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (count >= 2 && count <= 4) {
|
|
421
|
+
return translate.instant('RDT_FILE_LABEL_FEW', { count });
|
|
422
422
|
}
|
|
423
|
+
return translate.instant('RDT_FILE_LABEL_MANY', { count });
|
|
423
424
|
}
|
|
424
425
|
const RDT_DEFAULT_FILE_LABEL_FN = new InjectionToken('RDT_DEFAULT_FILE_LABEL_FN', {
|
|
425
426
|
providedIn: 'root',
|
|
426
|
-
factory: () =>
|
|
427
|
+
factory: () => {
|
|
428
|
+
const translate = inject(RdtTranslateService);
|
|
429
|
+
return (files) => fileLabelTranslate(translate, files);
|
|
430
|
+
},
|
|
427
431
|
});
|
|
428
432
|
|
|
429
433
|
const RDT_DEFAULT_MAX_FILE_SIZE = new InjectionToken('RDT_DEFAULT_MAX_FILE_SIZE', {
|
|
@@ -685,8 +689,10 @@ const rdtSelectInitialState = {
|
|
|
685
689
|
datasource: null,
|
|
686
690
|
selectedMap: new Map(),
|
|
687
691
|
fetchError: null,
|
|
688
|
-
loadingValuePlaceholder: 'Načítání (ID = {id})...',
|
|
689
|
-
missingValuePlaceholder: 'Neznámá hodnota (ID = {id})',
|
|
692
|
+
/* loadingValuePlaceholder: 'Načítání (ID = {id})...',
|
|
693
|
+
missingValuePlaceholder: 'Neznámá hodnota (ID = {id})', */
|
|
694
|
+
loadingValuePlaceholder: 'RDT_SELECT_LOADING_ID',
|
|
695
|
+
missingValuePlaceholder: 'RDT_SELECT_UNKNOWN_ID',
|
|
690
696
|
_fetchRequest: null,
|
|
691
697
|
_fetchMissingRequest: null,
|
|
692
698
|
_missingSelected: [],
|
|
@@ -733,13 +739,13 @@ function getRdtSelectStore(initialState = rdtSelectInitialState) {
|
|
|
733
739
|
const loadingPlaceholder = state.loadingValuePlaceholder();
|
|
734
740
|
const loadingPlaceholders = missing.map((id) => ({
|
|
735
741
|
id,
|
|
736
|
-
label: loadingPlaceholder
|
|
742
|
+
label: loadingPlaceholder + '::id=' + String(id),
|
|
737
743
|
value: null,
|
|
738
744
|
selected: true,
|
|
739
745
|
}));
|
|
740
746
|
const missingPlaceholders = unfetchable.map((id) => ({
|
|
741
747
|
id,
|
|
742
|
-
label: missingPlaceholder
|
|
748
|
+
label: missingPlaceholder + '::id=' + String(id),
|
|
743
749
|
value: null,
|
|
744
750
|
selected: true,
|
|
745
751
|
}));
|
|
@@ -1076,7 +1082,7 @@ function getRdtSelectError(error) {
|
|
|
1076
1082
|
else if (error && typeof error === 'object' && 'message' in error) {
|
|
1077
1083
|
return error.message;
|
|
1078
1084
|
}
|
|
1079
|
-
return '
|
|
1085
|
+
return 'RDT_SELECT_ERROR';
|
|
1080
1086
|
}
|
|
1081
1087
|
|
|
1082
1088
|
class RdtSelectOfflineDatasourceProviderDirective {
|
|
@@ -1371,14 +1377,15 @@ function getFirstError(errors) {
|
|
|
1371
1377
|
return null;
|
|
1372
1378
|
}
|
|
1373
1379
|
const defaultRdtFormErrorCodes = {
|
|
1374
|
-
required: () => `
|
|
1375
|
-
email: () => '
|
|
1376
|
-
minlength: (value) =>
|
|
1377
|
-
maxlength: (value) =>
|
|
1378
|
-
notFound: () => '
|
|
1379
|
-
multipleFound: () => '
|
|
1380
|
+
required: () => `RDT_ERROR_REQUIRED`,
|
|
1381
|
+
email: () => 'RDT_ERROR_EMAIL_INVALID',
|
|
1382
|
+
minlength: (value) => ['RDT_ERROR_MIN_LENGTH', value.requiredLength],
|
|
1383
|
+
maxlength: (value) => ['RDT_ERROR_MAX_LENGTH', value.requiredLength],
|
|
1384
|
+
notFound: () => 'RDT_ERROR_NOT_FOUND',
|
|
1385
|
+
multipleFound: () => 'RDT_ERROR_MULTIPLE_FOUND',
|
|
1380
1386
|
};
|
|
1381
1387
|
class RdtFormErrorPipe {
|
|
1388
|
+
translateService = inject(RdtTranslateService);
|
|
1382
1389
|
errorCodes = (() => {
|
|
1383
1390
|
const injected = inject(RDT_FORM_ERROR_CODES_PROVIDER, {
|
|
1384
1391
|
optional: true,
|
|
@@ -1396,13 +1403,18 @@ class RdtFormErrorPipe {
|
|
|
1396
1403
|
if (error) {
|
|
1397
1404
|
const fn = this.errorCodes[error.key];
|
|
1398
1405
|
if (fn) {
|
|
1399
|
-
|
|
1406
|
+
if (Array.isArray(fn())) {
|
|
1407
|
+
return this.translateService.instant(fn()[0], [
|
|
1408
|
+
fn().slice(1),
|
|
1409
|
+
]);
|
|
1410
|
+
}
|
|
1411
|
+
return this.translateService.instant(fn());
|
|
1400
1412
|
}
|
|
1401
1413
|
else if (typeof error.value === 'string') {
|
|
1402
|
-
return error.value;
|
|
1414
|
+
return this.translateService.instant(error.value);
|
|
1403
1415
|
}
|
|
1404
1416
|
else {
|
|
1405
|
-
return '
|
|
1417
|
+
return this.translateService.instant('RDT_ERROR_UNKNOWN');
|
|
1406
1418
|
}
|
|
1407
1419
|
}
|
|
1408
1420
|
return '';
|
|
@@ -1453,7 +1465,7 @@ class RdtDateValidators {
|
|
|
1453
1465
|
lastDayOfMonth: true,
|
|
1454
1466
|
};
|
|
1455
1467
|
};
|
|
1456
|
-
static greaterOrEqualToField(startDateField, error = '
|
|
1468
|
+
static greaterOrEqualToField(startDateField, error = 'RDT_DATE_TOO_SOON', unsubscribeSubj) {
|
|
1457
1469
|
let subbed = false;
|
|
1458
1470
|
return (endControl) => {
|
|
1459
1471
|
const startControl = startDateField instanceof FormControl
|
|
@@ -1485,7 +1497,7 @@ class RdtDateValidators {
|
|
|
1485
1497
|
return null;
|
|
1486
1498
|
};
|
|
1487
1499
|
}
|
|
1488
|
-
static lessOrEqualToField(endDateField, error = '
|
|
1500
|
+
static lessOrEqualToField(endDateField, error = 'RDT_DATE_TOO_LATE', unsubscribeSubj) {
|
|
1489
1501
|
let subbed = false;
|
|
1490
1502
|
return (startControl) => {
|
|
1491
1503
|
const endControl = endDateField instanceof FormControl
|
|
@@ -1666,5 +1678,5 @@ class RdtCommonValidators {
|
|
|
1666
1678
|
* Generated bundle index. Do not edit.
|
|
1667
1679
|
*/
|
|
1668
1680
|
|
|
1669
|
-
export { NO_OP_FILE_READER, NoOpFileReader, RDT_CHECKBOX_BASE_PROVIDER, RDT_DEFAULT_FILE_LABEL_FN, RDT_DEFAULT_FILE_READER, RDT_DEFAULT_MAX_FILE_SIZE, RDT_FORM_ERROR_CODES_PROVIDER, RdtBaseFormInputComponent, RdtBaseSelectCommonComponent, RdtCheckboxComponent, RdtCheckboxOutletDirective, RdtCommonValidators, RdtDateComponent, RdtDateValidators, RdtFileInputComponent, RdtFileReader, RdtFileReaderArrayBuffer, RdtFileReaderBase64, RdtFormErrorPipe, RdtFormInputOutletDirective, RdtMultiSelectComponent, RdtNumericInputComponent, RdtOfflineSelectDatasource, RdtSelectDatasource, RdtSelectOfflineDatasourceProviderDirective, RdtSelectOptionDirective, RdtSelectStore, RdtSingleSelectComponent, RdtTextAreaComponent, RdtTextInputComponent, VnshFileReaderText,
|
|
1681
|
+
export { NO_OP_FILE_READER, NoOpFileReader, RDT_CHECKBOX_BASE_PROVIDER, RDT_DEFAULT_FILE_LABEL_FN, RDT_DEFAULT_FILE_READER, RDT_DEFAULT_MAX_FILE_SIZE, RDT_FORM_ERROR_CODES_PROVIDER, RdtBaseFormInputComponent, RdtBaseSelectCommonComponent, RdtCheckboxComponent, RdtCheckboxOutletDirective, RdtCommonValidators, RdtDateComponent, RdtDateValidators, RdtFileInputComponent, RdtFileReader, RdtFileReaderArrayBuffer, RdtFileReaderBase64, RdtFormErrorPipe, RdtFormInputOutletDirective, RdtMultiSelectComponent, RdtNumericInputComponent, RdtOfflineSelectDatasource, RdtSelectDatasource, RdtSelectOfflineDatasourceProviderDirective, RdtSelectOptionDirective, RdtSelectStore, RdtSingleSelectComponent, RdtTextAreaComponent, RdtTextInputComponent, VnshFileReaderText, defaultRdtFormErrorCodes, fileLabelTranslate, getFirstError, getRdtSelectPage, rdtSelectInitialState };
|
|
1670
1682
|
//# sourceMappingURL=ngrdt-forms.mjs.map
|