@gravitee/ui-particles-angular 16.2.2 → 16.2.3

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.
@@ -2964,9 +2964,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
2964
2964
  * limitations under the License.
2965
2965
  */
2966
2966
  class GioFormlyJsonSchemaService {
2967
- constructor(formlyJsonschema, builder) {
2967
+ constructor(formlyJsonschema) {
2968
2968
  this.formlyJsonschema = formlyJsonschema;
2969
- this.builder = builder;
2970
2969
  }
2971
2970
  toFormlyFieldConfig(jsonSchema, context) {
2972
2971
  return this.formlyJsonschema.toFieldConfig(jsonSchema, {
@@ -2981,6 +2980,7 @@ class GioFormlyJsonSchemaService {
2981
2980
  mappedField = this.enumLabelMap(mappedField, mapSource);
2982
2981
  mappedField = this.sanitizeOneOf(mappedField, mapSource);
2983
2982
  mappedField = this.deprecatedMap(mappedField, mapSource);
2983
+ mappedField = this.uniqueValueMap(mappedField, mapSource);
2984
2984
  return mappedField;
2985
2985
  },
2986
2986
  });
@@ -3174,12 +3174,41 @@ class GioFormlyJsonSchemaService {
3174
3174
  }
3175
3175
  return mappedField;
3176
3176
  }
3177
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService, deps: [{ token: i1$7.FormlyJsonschema }, { token: i1$8.FormlyFormBuilder }], target: i0.ɵɵFactoryTarget.Injectable }); }
3177
+ uniqueValueMap(mappedField, mapSource) {
3178
+ let fieldNameWithErrors = undefined;
3179
+ if (mapSource.gioConfig?.uniqueItemProperties) {
3180
+ mappedField = {
3181
+ ...mappedField,
3182
+ validators: {
3183
+ ...mappedField.validators,
3184
+ uniqueFields: {
3185
+ expression: (control) => {
3186
+ const items = control.value;
3187
+ const uniqueProps = mapSource.gioConfig?.uniqueItemProperties ?? [];
3188
+ if (!Array.isArray(items) || !uniqueProps.length)
3189
+ return true;
3190
+ for (const prop of uniqueProps) {
3191
+ const values = items.map(i => i?.[prop]).filter(v => v != null);
3192
+ if (new Set(values).size !== values.length) {
3193
+ fieldNameWithErrors = prop;
3194
+ return false;
3195
+ }
3196
+ }
3197
+ return true;
3198
+ },
3199
+ message: (_error, _field) => `${fieldNameWithErrors || 'This field'} must be unique`,
3200
+ },
3201
+ },
3202
+ };
3203
+ }
3204
+ return mappedField;
3205
+ }
3206
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService, deps: [{ token: i1$7.FormlyJsonschema }], target: i0.ɵɵFactoryTarget.Injectable }); }
3178
3207
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService }); }
3179
3208
  }
3180
3209
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService, decorators: [{
3181
3210
  type: Injectable
3182
- }], ctorParameters: () => [{ type: i1$7.FormlyJsonschema }, { type: i1$8.FormlyFormBuilder }] });
3211
+ }], ctorParameters: () => [{ type: i1$7.FormlyJsonschema }] });
3183
3212
  const getBannerProperties = (banner) => {
3184
3213
  return {
3185
3214
  bannerText: banner.text,