mn-angular-lib 0.0.48 → 0.0.50

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject, inject, Input, ChangeDetectionStrategy, Component, HostBinding, Self, DestroyRef, APP_INITIALIZER, ElementRef, HostListener, forwardRef, Directive, EventEmitter, TemplateRef, Output, ViewChildren, ViewContainerRef, ViewChild, ApplicationRef, EnvironmentInjector, createComponent, SkipSelf, Attribute, Pipe } from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, inject, Input, ChangeDetectionStrategy, Component, HostBinding, DestroyRef, Self, APP_INITIALIZER, ElementRef, HostListener, forwardRef, Directive, EventEmitter, TemplateRef, Output, ViewChildren, ViewContainerRef, ViewChild, ApplicationRef, EnvironmentInjector, createComponent, SkipSelf, Attribute, Pipe } from '@angular/core';
3
3
  export { TemplateRef, Type } from '@angular/core';
4
4
  import { BehaviorSubject, firstValueFrom, skip, Subject, debounceTime, map, catchError, of } from 'rxjs';
5
5
  import * as i1 from '@angular/common';
@@ -870,6 +870,8 @@ class MnInputField {
870
870
  configService = inject(MnConfigService);
871
871
  sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
872
872
  explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
873
+ lang = inject(MnLanguageService);
874
+ destroyRef = inject(DestroyRef);
873
875
  /** Current raw string value of the input element */
874
876
  value = null;
875
877
  /** Whether the input is disabled */
@@ -904,6 +906,10 @@ class MnInputField {
904
906
  }
905
907
  ngOnInit() {
906
908
  this.resolveConfig();
909
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
910
+ this.resolveConfig();
911
+ });
912
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
907
913
  }
908
914
  resolveConfig() {
909
915
  const instanceId = this.explicitInstanceId || `mn-input-${this.props.id}`;
@@ -1060,12 +1066,13 @@ class MnInputField {
1060
1066
  */
1061
1067
  resolveErrorMessageForKey(errorKey, errors) {
1062
1068
  const errorArgs = errors[errorKey];
1063
- // Priority: custom > built-in > fallback > default
1069
+ // Priority: custom (props) > config > built-in > fallback > default
1064
1070
  const customMsg = this.props.errorMessages?.[errorKey];
1071
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1065
1072
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1066
1073
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1067
1074
  const fallbackMsg = this.props.defaultErrorMessage;
1068
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1075
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1069
1076
  // If the message is a function, call it with error arguments
1070
1077
  if (typeof msgDef === 'function') {
1071
1078
  return msgDef(errorArgs, errors);
@@ -1372,6 +1379,8 @@ class MnTextarea {
1372
1379
  configService = inject(MnConfigService);
1373
1380
  sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
1374
1381
  explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
1382
+ lang = inject(MnLanguageService);
1383
+ destroyRef = inject(DestroyRef);
1375
1384
  /** Current raw string value of the textarea element */
1376
1385
  value = null;
1377
1386
  /** Whether the textarea is disabled */
@@ -1403,6 +1412,10 @@ class MnTextarea {
1403
1412
  }
1404
1413
  ngOnInit() {
1405
1414
  this.resolveConfig();
1415
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
1416
+ this.resolveConfig();
1417
+ });
1418
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
1406
1419
  }
1407
1420
  resolveConfig() {
1408
1421
  const instanceId = this.explicitInstanceId || `mn-textarea-${this.props.id}`;
@@ -1507,10 +1520,11 @@ class MnTextarea {
1507
1520
  resolveErrorMessageForKey(errorKey, errors) {
1508
1521
  const errorArgs = errors[errorKey];
1509
1522
  const customMsg = this.props.errorMessages?.[errorKey];
1523
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1510
1524
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1511
1525
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1512
1526
  const fallbackMsg = this.props.defaultErrorMessage;
1513
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1527
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1514
1528
  if (typeof msgDef === 'function') {
1515
1529
  return msgDef(errorArgs, errors);
1516
1530
  }
@@ -1607,6 +1621,8 @@ class MnCheckbox {
1607
1621
  configService = inject(MnConfigService);
1608
1622
  sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
1609
1623
  explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
1624
+ lang = inject(MnLanguageService);
1625
+ destroyRef = inject(DestroyRef);
1610
1626
  value = false;
1611
1627
  isDisabled = false;
1612
1628
  onChange = () => { };
@@ -1621,6 +1637,10 @@ class MnCheckbox {
1621
1637
  }
1622
1638
  ngOnInit() {
1623
1639
  this.resolveConfig();
1640
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
1641
+ this.resolveConfig();
1642
+ });
1643
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
1624
1644
  }
1625
1645
  resolveConfig() {
1626
1646
  const instanceId = this.explicitInstanceId || `mn-checkbox-${this.props.id}`;
@@ -1676,10 +1696,11 @@ class MnCheckbox {
1676
1696
  resolveErrorMessageForKey(errorKey, errors) {
1677
1697
  const errorArgs = errors[errorKey];
1678
1698
  const customMsg = this.props.errorMessages?.[errorKey];
1699
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1679
1700
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1680
1701
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1681
1702
  const fallbackMsg = this.props.defaultErrorMessage;
1682
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1703
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1683
1704
  if (typeof msgDef === 'function') {
1684
1705
  return msgDef(errorArgs, errors);
1685
1706
  }
@@ -1766,6 +1787,8 @@ class MnDatetime {
1766
1787
  configService = inject(MnConfigService);
1767
1788
  sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
1768
1789
  explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
1790
+ lang = inject(MnLanguageService);
1791
+ destroyRef = inject(DestroyRef);
1769
1792
  value = null;
1770
1793
  isDisabled = false;
1771
1794
  onChange = () => { };
@@ -1782,6 +1805,10 @@ class MnDatetime {
1782
1805
  }
1783
1806
  ngOnInit() {
1784
1807
  this.resolveConfig();
1808
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
1809
+ this.resolveConfig();
1810
+ });
1811
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
1785
1812
  }
1786
1813
  resolveConfig() {
1787
1814
  const instanceId = this.explicitInstanceId || `mn-datetime-${this.props.id}`;
@@ -1840,10 +1867,11 @@ class MnDatetime {
1840
1867
  resolveErrorMessageForKey(errorKey, errors) {
1841
1868
  const errorArgs = errors[errorKey];
1842
1869
  const customMsg = this.props.errorMessages?.[errorKey];
1870
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1843
1871
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1844
1872
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1845
1873
  const fallbackMsg = this.props.defaultErrorMessage;
1846
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1874
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1847
1875
  if (typeof msgDef === 'function') {
1848
1876
  return msgDef(errorArgs, errors);
1849
1877
  }
@@ -1936,6 +1964,8 @@ class MnMultiSelect {
1936
1964
  sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
1937
1965
  explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
1938
1966
  elRef = inject(ElementRef);
1967
+ lang = inject(MnLanguageService);
1968
+ destroyRef = inject(DestroyRef);
1939
1969
  /** Currently selected values */
1940
1970
  selectedValues = [];
1941
1971
  isOpen = false;
@@ -1953,6 +1983,10 @@ class MnMultiSelect {
1953
1983
  }
1954
1984
  ngOnInit() {
1955
1985
  this.resolveConfig();
1986
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
1987
+ this.resolveConfig();
1988
+ });
1989
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
1956
1990
  }
1957
1991
  resolveConfig() {
1958
1992
  const instanceId = this.explicitInstanceId || `mn-multi-select-${this.props.id}`;
@@ -2063,10 +2097,11 @@ class MnMultiSelect {
2063
2097
  resolveErrorMessageForKey(errorKey, errors) {
2064
2098
  const errorArgs = errors[errorKey];
2065
2099
  const customMsg = this.props.errorMessages?.[errorKey];
2100
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
2066
2101
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
2067
2102
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
2068
2103
  const fallbackMsg = this.props.defaultErrorMessage;
2069
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
2104
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
2070
2105
  if (typeof msgDef === 'function') {
2071
2106
  return msgDef(errorArgs, errors);
2072
2107
  }