@breadstone/mosaik-elements-angular 0.0.187 → 0.0.189

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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.0.189 (2025-12-02)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **choice-group:** add flex property to root part for better layout ([51e2a1a9be](https://github.com/RueDeRennes/mosaik/commit/51e2a1a9be))
6
+
7
+ ## 0.0.188 (2025-12-02)
8
+
9
+ ### 🚀 Features
10
+
11
+ - **directives:** update FormFieldDirective to improve error handling and usage documentation ([7c07bb43fd](https://github.com/RueDeRennes/mosaik/commit/7c07bb43fd))
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **directives:** rename applyError to setError for clarity in FormFieldDirective ([747560c657](https://github.com/RueDeRennes/mosaik/commit/747560c657))
16
+ - **directives:** enhance error handling in FormFieldDirective to check for invalid state ([3b098ac14c](https://github.com/RueDeRennes/mosaik/commit/3b098ac14c))
17
+
1
18
  ## 0.0.187 (2025-12-02)
2
19
 
3
20
  This was a version bump only for mosaik-elements-angular to align it with other projects, there were no code changes.
@@ -61155,22 +61155,40 @@ class Validators {
61155
61155
  }
61156
61156
 
61157
61157
  // #region Imports
61158
+ // #endregion
61159
+ /**
61160
+ * Retrieves the option value, evaluating it if it's a function.
61161
+ *
61162
+ * @private
61163
+ * @param opt The option value or function to evaluate.
61164
+ * @param ctx The field context to pass if `opt` is a function.
61165
+ * @returns The resolved option value.
61166
+ */
61167
+ function getOption(opt, ctx) {
61168
+ return opt instanceof Function ? opt(ctx) : opt;
61169
+ }
61158
61170
  /**
61159
61171
  * Validator to check if control value is only numeric.
61160
61172
  *
61161
61173
  * @param path The schema path to validate.
61162
61174
  * @public
61163
61175
  */
61164
- function numeric(path) {
61176
+ function numeric(path, config) {
61165
61177
  validate(path, (ctx) => {
61166
61178
  const value = ctx.value();
61167
61179
  if (value === null || value === undefined || !Number.isNaN(+value)) {
61168
61180
  return null;
61169
61181
  }
61170
- return {
61171
- kind: 'numeric',
61172
- actualValue: value
61173
- };
61182
+ if (config?.error) {
61183
+ return getOption(config.error, ctx);
61184
+ }
61185
+ else {
61186
+ return {
61187
+ kind: 'numeric',
61188
+ actualValue: value,
61189
+ message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
61190
+ };
61191
+ }
61174
61192
  });
61175
61193
  }
61176
61194
  /**
@@ -61180,18 +61198,24 @@ function numeric(path) {
61180
61198
  * @param other A value or getter function returning the other value.
61181
61199
  * @public
61182
61200
  */
61183
- function equalsTo(path, other) {
61201
+ function equalsTo(path, other, config) {
61184
61202
  validate(path, (ctx) => {
61185
61203
  const value = ctx.value();
61186
61204
  const otherValue = typeof other === 'function' ? other() : other;
61187
61205
  if (value === otherValue) {
61188
61206
  return null;
61189
61207
  }
61190
- return {
61191
- kind: 'equalsTo',
61192
- actualValue: value,
61193
- other: otherValue
61194
- };
61208
+ if (config?.error) {
61209
+ return getOption(config.error, ctx);
61210
+ }
61211
+ else {
61212
+ return {
61213
+ kind: 'equalsTo',
61214
+ actualValue: value,
61215
+ other: otherValue,
61216
+ message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
61217
+ };
61218
+ }
61195
61219
  });
61196
61220
  }
61197
61221
  /**
@@ -61200,16 +61224,22 @@ function equalsTo(path, other) {
61200
61224
  * @param path The schema path to validate.
61201
61225
  * @public
61202
61226
  */
61203
- function blank(path) {
61227
+ function blank(path, config) {
61204
61228
  validate(path, (ctx) => {
61205
61229
  const value = ctx.value();
61206
- if (typeof value === 'string' && (/\s/).test(value)) {
61230
+ if (!(typeof value === 'string' && (/\s/).test(value))) {
61231
+ return null;
61232
+ }
61233
+ if (config?.error) {
61234
+ return getOption(config.error, ctx);
61235
+ }
61236
+ else {
61207
61237
  return {
61208
61238
  kind: 'blank',
61209
- actualValue: value
61239
+ actualValue: value,
61240
+ message: typeof config?.message === 'function' ? config.message(ctx) : config?.message,
61210
61241
  };
61211
61242
  }
61212
- return null;
61213
61243
  });
61214
61244
  }
61215
61245
  /**
@@ -61219,7 +61249,7 @@ function blank(path) {
61219
61249
  * @param domains The list of allowed domains.
61220
61250
  * @public
61221
61251
  */
61222
- function emailEndsWithDomain(path, domains) {
61252
+ function emailEndsWithDomain(path, domains, config) {
61223
61253
  const pattern = `^\\w+([-.']\\w+)*@(?:(${domains.join('|')}))$`;
61224
61254
  const regex = new RegExp(pattern);
61225
61255
  validate(path, (ctx) => {
@@ -61230,11 +61260,16 @@ function emailEndsWithDomain(path, domains) {
61230
61260
  if (typeof value === 'string' && regex.test(value)) {
61231
61261
  return null;
61232
61262
  }
61233
- return {
61234
- kind: 'emailEndsWithDomain',
61235
- requiredDomains: domains,
61236
- actualValue: value
61237
- };
61263
+ if (config?.error) {
61264
+ return getOption(config.error, ctx);
61265
+ }
61266
+ else {
61267
+ return {
61268
+ kind: 'emailEndsWithDomain',
61269
+ requiredDomains: domains,
61270
+ actualValue: value
61271
+ };
61272
+ }
61238
61273
  });
61239
61274
  }
61240
61275
  /**
@@ -61243,7 +61278,7 @@ function emailEndsWithDomain(path, domains) {
61243
61278
  * @param path The schema path to validate.
61244
61279
  * @public
61245
61280
  */
61246
- function phoneNumber(path) {
61281
+ function phoneNumber(path, config) {
61247
61282
  const pattern = '^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\.\\/0-9]*$';
61248
61283
  const regex = new RegExp(pattern);
61249
61284
  validate(path, (ctx) => {
@@ -61254,10 +61289,15 @@ function phoneNumber(path) {
61254
61289
  if (typeof value === 'string' && regex.test(value)) {
61255
61290
  return null;
61256
61291
  }
61257
- return {
61258
- kind: 'phoneNumber',
61259
- actualValue: value
61260
- };
61292
+ if (config?.error) {
61293
+ return getOption(config.error, ctx);
61294
+ }
61295
+ else {
61296
+ return {
61297
+ kind: 'phoneNumber',
61298
+ actualValue: value
61299
+ };
61300
+ }
61261
61301
  });
61262
61302
  }
61263
61303
 
@@ -61753,7 +61793,7 @@ class FormFieldDirective {
61753
61793
  // we recalc the error message and apply it to the Web Component.
61754
61794
  effect(() => {
61755
61795
  const fs = this.fieldState();
61756
- this.applyError(fs);
61796
+ this.setError(fs);
61757
61797
  });
61758
61798
  }
61759
61799
  //#endregion
@@ -61780,16 +61820,16 @@ class FormFieldDirective {
61780
61820
  *
61781
61821
  * @param fieldState The current FieldState
61782
61822
  */
61783
- applyError(fieldState) {
61823
+ setError(fieldState) {
61784
61824
  const el = this._elementRef.nativeElement;
61785
61825
  if (!fieldState) {
61786
- // No state → clear any previous error
61787
61826
  el.error = '';
61788
61827
  return;
61789
61828
  }
61790
61829
  const errors = fieldState.errors(); // array of validation errors
61791
61830
  const isTouched = fieldState.touched(); // whether the field was touched
61792
- if (errors.length > 0 && isTouched) {
61831
+ const isInvalid = fieldState.invalid(); // whether the field is invalid
61832
+ if (errors.length > 0 && isTouched && isInvalid) {
61793
61833
  // Use the last error in the array as the “active” error message
61794
61834
  const lastError = errors[errors.length - 1];
61795
61835
  el.error = lastError.message ?? '';