mn-angular-lib 0.0.49 → 0.0.51

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.
@@ -1066,12 +1066,13 @@ class MnInputField {
1066
1066
  */
1067
1067
  resolveErrorMessageForKey(errorKey, errors) {
1068
1068
  const errorArgs = errors[errorKey];
1069
- // Priority: custom > built-in > fallback > default
1069
+ // Priority: custom (props) > config > built-in > fallback > default
1070
1070
  const customMsg = this.props.errorMessages?.[errorKey];
1071
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1071
1072
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1072
1073
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1073
1074
  const fallbackMsg = this.props.defaultErrorMessage;
1074
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1075
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1075
1076
  // If the message is a function, call it with error arguments
1076
1077
  if (typeof msgDef === 'function') {
1077
1078
  return msgDef(errorArgs, errors);
@@ -1519,13 +1520,18 @@ class MnTextarea {
1519
1520
  resolveErrorMessageForKey(errorKey, errors) {
1520
1521
  const errorArgs = errors[errorKey];
1521
1522
  const customMsg = this.props.errorMessages?.[errorKey];
1523
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1522
1524
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1523
1525
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1524
1526
  const fallbackMsg = this.props.defaultErrorMessage;
1525
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1527
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1526
1528
  if (typeof msgDef === 'function') {
1527
1529
  return msgDef(errorArgs, errors);
1528
1530
  }
1531
+ // Interpolate {{placeholder}} tokens with validation error args
1532
+ if (typeof msgDef === 'string' && errorArgs && typeof errorArgs === 'object') {
1533
+ return msgDef.replace(/\{\{(\w+)\}\}/g, (_, key) => errorArgs[key] ?? _);
1534
+ }
1529
1535
  return msgDef;
1530
1536
  }
1531
1537
  /**
@@ -1694,10 +1700,11 @@ class MnCheckbox {
1694
1700
  resolveErrorMessageForKey(errorKey, errors) {
1695
1701
  const errorArgs = errors[errorKey];
1696
1702
  const customMsg = this.props.errorMessages?.[errorKey];
1703
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1697
1704
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1698
1705
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1699
1706
  const fallbackMsg = this.props.defaultErrorMessage;
1700
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1707
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1701
1708
  if (typeof msgDef === 'function') {
1702
1709
  return msgDef(errorArgs, errors);
1703
1710
  }
@@ -1864,10 +1871,11 @@ class MnDatetime {
1864
1871
  resolveErrorMessageForKey(errorKey, errors) {
1865
1872
  const errorArgs = errors[errorKey];
1866
1873
  const customMsg = this.props.errorMessages?.[errorKey];
1874
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
1867
1875
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
1868
1876
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
1869
1877
  const fallbackMsg = this.props.defaultErrorMessage;
1870
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1878
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
1871
1879
  if (typeof msgDef === 'function') {
1872
1880
  return msgDef(errorArgs, errors);
1873
1881
  }
@@ -2093,13 +2101,18 @@ class MnMultiSelect {
2093
2101
  resolveErrorMessageForKey(errorKey, errors) {
2094
2102
  const errorArgs = errors[errorKey];
2095
2103
  const customMsg = this.props.errorMessages?.[errorKey];
2104
+ const configMsg = this.uiConfig.errorMessages?.[errorKey];
2096
2105
  const useBuiltIn = this.props.useBuiltInErrorMessages !== false;
2097
2106
  const builtInMsg = useBuiltIn ? this.builtInErrorMessages[errorKey] : undefined;
2098
2107
  const fallbackMsg = this.props.defaultErrorMessage;
2099
- const msgDef = customMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
2108
+ const msgDef = customMsg ?? configMsg ?? builtInMsg ?? fallbackMsg ?? 'Invalid input';
2100
2109
  if (typeof msgDef === 'function') {
2101
2110
  return msgDef(errorArgs, errors);
2102
2111
  }
2112
+ // Interpolate {{placeholder}} tokens with validation error args
2113
+ if (typeof msgDef === 'string' && errorArgs && typeof errorArgs === 'object') {
2114
+ return msgDef.replace(/\{\{(\w+)\}\}/g, (_, key) => errorArgs[key] ?? _);
2115
+ }
2103
2116
  return msgDef;
2104
2117
  }
2105
2118
  get errorMessages() {