@gravitee/ui-particles-angular 16.2.1 → 16.2.2-apim-11833-llm-proxy-ui-does-not-match-designs-748e778

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,73 @@ 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
+ if (!mapSource.gioConfig?.unique) {
3179
+ return mappedField;
3180
+ }
3181
+ mappedField.asyncValidators = {
3182
+ ...mappedField.asyncValidators,
3183
+ unique: {
3184
+ expression: (control) => {
3185
+ if (!control.value || control.value === '') {
3186
+ return Promise.resolve(true); // Empty values are valid
3187
+ }
3188
+ let currentControl = control.parent;
3189
+ let parentArrayControl = null;
3190
+ while (currentControl) {
3191
+ const value = currentControl.value;
3192
+ if (isArray(value)) {
3193
+ parentArrayControl = currentControl;
3194
+ break;
3195
+ }
3196
+ currentControl = currentControl.parent;
3197
+ }
3198
+ if (!parentArrayControl) {
3199
+ return Promise.resolve(true);
3200
+ }
3201
+ const controls = parentArrayControl.controls;
3202
+ if (!controls || !isArray(controls) || controls.length <= 1) {
3203
+ return Promise.resolve(true); // No duplicates possible
3204
+ }
3205
+ const fieldKey = mappedField.key;
3206
+ const currentValue = control.value;
3207
+ const occurrences = controls.filter((formGroup) => {
3208
+ const siblingControl = fieldKey ? formGroup.get(fieldKey) : formGroup;
3209
+ if (!siblingControl) {
3210
+ return false;
3211
+ }
3212
+ const siblingValue = siblingControl.value;
3213
+ if (isNil(siblingValue)) {
3214
+ return false;
3215
+ }
3216
+ return siblingValue === currentValue;
3217
+ }).length;
3218
+ const isValid = occurrences <= 1;
3219
+ if (isValid) {
3220
+ setTimeout(() => {
3221
+ controls.forEach((formGroup) => {
3222
+ const siblingControl = fieldKey ? formGroup.get(fieldKey) : formGroup;
3223
+ if (siblingControl && siblingControl !== control && siblingControl.hasError('unique')) {
3224
+ siblingControl.updateValueAndValidity({ emitEvent: false });
3225
+ }
3226
+ });
3227
+ }, 0);
3228
+ }
3229
+ return Promise.resolve(isValid);
3230
+ },
3231
+ message: (error, field) => {
3232
+ return `${field.props?.label} must be unique`;
3233
+ },
3234
+ },
3235
+ };
3236
+ return mappedField;
3237
+ }
3238
+ 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
3239
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService }); }
3179
3240
  }
3180
3241
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormlyJsonSchemaService, decorators: [{
3181
3242
  type: Injectable
3182
- }], ctorParameters: () => [{ type: i1$7.FormlyJsonschema }, { type: i1$8.FormlyFormBuilder }] });
3243
+ }], ctorParameters: () => [{ type: i1$7.FormlyJsonschema }] });
3183
3244
  const getBannerProperties = (banner) => {
3184
3245
  return {
3185
3246
  bannerText: banner.text,