@gravitee/ui-particles-angular 16.4.0 → 17.0.0

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.
@@ -7087,6 +7087,23 @@ class GioFormCronHarness extends ComponentHarness {
7087
7087
  }
7088
7088
  }
7089
7089
 
7090
+ /*
7091
+ * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
7092
+ *
7093
+ * Licensed under the Apache License, Version 2.0 (the "License");
7094
+ * you may not use this file except in compliance with the License.
7095
+ * You may obtain a copy of the License at
7096
+ *
7097
+ * http://www.apache.org/licenses/LICENSE-2.0
7098
+ *
7099
+ * Unless required by applicable law or agreed to in writing, software
7100
+ * distributed under the License is distributed on an "AS IS" BASIS,
7101
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7102
+ * See the License for the specific language governing permissions and
7103
+ * limitations under the License.
7104
+ */
7105
+ const GIO_FORM_SELECTION_INLINE_STATE = new InjectionToken('GIO_FORM_SELECTION_INLINE_STATE');
7106
+
7090
7107
  /*
7091
7108
  * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
7092
7109
  *
@@ -7103,68 +7120,86 @@ class GioFormCronHarness extends ComponentHarness {
7103
7120
  * limitations under the License.
7104
7121
  */
7105
7122
  class GioFormSelectionInlineCardComponent {
7123
+ get valueAttr() {
7124
+ return this.value ?? null;
7125
+ }
7106
7126
  get _disabled() {
7107
- return this.disabled || this._parendDisabled || this.lock;
7127
+ return this._disabledState();
7128
+ }
7129
+ get _selected() {
7130
+ return this._selectedState();
7108
7131
  }
7109
- constructor(changeDetector) {
7110
- this.changeDetector = changeDetector;
7132
+ constructor() {
7111
7133
  this.lock = false;
7112
7134
  this.disabled = false;
7113
- this.selected = false;
7114
- this._parendDisabled = false;
7135
+ this.parentState = inject(GIO_FORM_SELECTION_INLINE_STATE, { optional: true });
7136
+ this._disabledState = computed(() => {
7137
+ const parentDisabled = this.parentState?.disabled() ?? false;
7138
+ return this.disabled || parentDisabled || this.lock;
7139
+ }, ...(ngDevMode ? [{ debugName: "_disabledState" }] : []));
7140
+ this._selectedState = computed(() => {
7141
+ if (!this.parentState) {
7142
+ return false;
7143
+ }
7144
+ return this.value === this.parentState.selectedValue();
7145
+ }, ...(ngDevMode ? [{ debugName: "_selectedState" }] : []));
7115
7146
  }
7116
7147
  onSelectCard() {
7117
7148
  if (!this._disabled && !this.lock) {
7118
- this.selected = !this.selected;
7119
- if (this.onSelectFn) {
7149
+ // Use injected callback if available, otherwise fall back to onSelectFn
7150
+ if (this.parentState) {
7151
+ this.parentState.onCardSelect(this.value);
7152
+ }
7153
+ else if (this.onSelectFn) {
7120
7154
  this.onSelectFn(this.value);
7121
7155
  }
7122
7156
  }
7123
7157
  }
7124
- _markForCheck() {
7125
- // When group value changes, the button will not be notified. Use `markForCheck` to explicit
7126
- // update radio button's status
7127
- this.changeDetector.markForCheck();
7128
- this.changeDetector.detectChanges();
7129
- }
7130
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineCardComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
7131
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: GioFormSelectionInlineCardComponent, isStandalone: false, selector: "gio-form-selection-inline-card", inputs: { value: "value", lock: "lock", disabled: "disabled" }, host: { listeners: { "click": "onSelectCard()" }, properties: { "class.disabled": "this._disabled", "class.selected": "this.selected" } }, ngImport: i0, template: `
7132
- <div matRipple [matRippleDisabled]="_disabled" class="card" [class.selected]="selected" [class.disabled]="_disabled">
7158
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
7159
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: GioFormSelectionInlineCardComponent, isStandalone: false, selector: "gio-form-selection-inline-card", inputs: { value: "value", lock: "lock", disabled: "disabled" }, host: { listeners: { "click": "onSelectCard()" }, properties: { "attr.value": "this.valueAttr", "class.disabled": "this._disabled", "class.selected": "this._selected" } }, ngImport: i0, template: `
7160
+ <div matRipple [matRippleDisabled]="_disabled" class="card" [class.selected]="_selected" [class.disabled]="_disabled">
7133
7161
  <span class="selection-icon">
7134
7162
  @if (lock) {
7135
7163
  <mat-icon class="selection-icon__lock-icon" svgIcon="gio:lock"></mat-icon>
7136
7164
  }
7137
- <mat-icon class="selection-icon__radio-icon">{{ selected ? 'radio_button_checked' : 'radio_button_unchecked' }}</mat-icon>
7165
+ <mat-icon class="selection-icon__radio-icon">{{ _selected ? 'radio_button_checked' : 'radio_button_unchecked' }}</mat-icon>
7138
7166
  </span>
7139
7167
 
7140
- <div class="card__content"><ng-content></ng-content></div>
7168
+ <div class="card__content">
7169
+ <ng-content></ng-content>
7170
+ </div>
7141
7171
  </div>
7142
7172
  `, isInline: true, styles: ["@charset \"UTF-8\";.gio-top-bar-menu .gio-badge-accent{background-color:var(--gio-oem-palette--active, #ffc2ac);color:var(--gio-oem-palette--active-contrast, #1e1b1b)}:host{display:flex;flex:1 0 0%}.card{min-width:64px;min-height:40px;flex:1 1 auto;border:1px solid var(--mat-form-field-outlined-outline-color);border-radius:4px;margin:6px 0;cursor:pointer}.card .selection-icon{position:absolute;top:8px;right:8px;display:flex;height:24px;flex-direction:row;align-items:center;border-radius:100%;gap:4px}.card .selection-icon__lock-icon{height:22px;cursor:pointer}.card .selection-icon__lock-icon,.card .selection-icon__radio-icon{color:var(--mat-form-field-outlined-outline-color)}.card.selected{border:2px solid #da3b00;margin:5px 0;color:#da3b00}.card.selected .selection-icon__radio-icon{color:#da3b00}.card.disabled{border-color:#0003;color:#00000061;cursor:auto}.card.disabled__content{opacity:.4}.card.disabled .selection-icon__radio-icon{color:#0003}.card.disabled .selection-icon__lock-icon{color:#da3b00}.card:hover:not(.disabled,.selected){border-color:var(--mat-form-field-outlined-hover-outline-color)}.card:hover:not(.disabled,.selected) .selection-icon__radio-icon{color:var(--mat-form-field-outlined-hover-outline-color)}.card__content{padding:16px}\n"], dependencies: [{ kind: "component", type: i1$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i3$1.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
7143
7173
  }
7144
7174
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineCardComponent, decorators: [{
7145
7175
  type: Component,
7146
7176
  args: [{ selector: 'gio-form-selection-inline-card', template: `
7147
- <div matRipple [matRippleDisabled]="_disabled" class="card" [class.selected]="selected" [class.disabled]="_disabled">
7177
+ <div matRipple [matRippleDisabled]="_disabled" class="card" [class.selected]="_selected" [class.disabled]="_disabled">
7148
7178
  <span class="selection-icon">
7149
7179
  @if (lock) {
7150
7180
  <mat-icon class="selection-icon__lock-icon" svgIcon="gio:lock"></mat-icon>
7151
7181
  }
7152
- <mat-icon class="selection-icon__radio-icon">{{ selected ? 'radio_button_checked' : 'radio_button_unchecked' }}</mat-icon>
7182
+ <mat-icon class="selection-icon__radio-icon">{{ _selected ? 'radio_button_checked' : 'radio_button_unchecked' }}</mat-icon>
7153
7183
  </span>
7154
7184
 
7155
- <div class="card__content"><ng-content></ng-content></div>
7185
+ <div class="card__content">
7186
+ <ng-content></ng-content>
7187
+ </div>
7156
7188
  </div>
7157
7189
  `, changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, styles: ["@charset \"UTF-8\";.gio-top-bar-menu .gio-badge-accent{background-color:var(--gio-oem-palette--active, #ffc2ac);color:var(--gio-oem-palette--active-contrast, #1e1b1b)}:host{display:flex;flex:1 0 0%}.card{min-width:64px;min-height:40px;flex:1 1 auto;border:1px solid var(--mat-form-field-outlined-outline-color);border-radius:4px;margin:6px 0;cursor:pointer}.card .selection-icon{position:absolute;top:8px;right:8px;display:flex;height:24px;flex-direction:row;align-items:center;border-radius:100%;gap:4px}.card .selection-icon__lock-icon{height:22px;cursor:pointer}.card .selection-icon__lock-icon,.card .selection-icon__radio-icon{color:var(--mat-form-field-outlined-outline-color)}.card.selected{border:2px solid #da3b00;margin:5px 0;color:#da3b00}.card.selected .selection-icon__radio-icon{color:#da3b00}.card.disabled{border-color:#0003;color:#00000061;cursor:auto}.card.disabled__content{opacity:.4}.card.disabled .selection-icon__radio-icon{color:#0003}.card.disabled .selection-icon__lock-icon{color:#da3b00}.card:hover:not(.disabled,.selected){border-color:var(--mat-form-field-outlined-hover-outline-color)}.card:hover:not(.disabled,.selected) .selection-icon__radio-icon{color:var(--mat-form-field-outlined-hover-outline-color)}.card__content{padding:16px}\n"] }]
7158
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { value: [{
7190
+ }], ctorParameters: () => [], propDecorators: { value: [{
7159
7191
  type: Input
7160
7192
  }], lock: [{
7161
7193
  type: Input
7162
7194
  }], disabled: [{
7163
7195
  type: Input
7196
+ }], valueAttr: [{
7197
+ type: HostBinding,
7198
+ args: ['attr.value']
7164
7199
  }], _disabled: [{
7165
7200
  type: HostBinding,
7166
7201
  args: ['class.disabled']
7167
- }], selected: [{
7202
+ }], _selected: [{
7168
7203
  type: HostBinding,
7169
7204
  args: ['class.selected']
7170
7205
  }], onSelectCard: [{
@@ -7188,32 +7223,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
7188
7223
  * limitations under the License.
7189
7224
  */
7190
7225
  class GioFormSelectionInlineComponent {
7191
- constructor(changeDetector) {
7192
- this.changeDetector = changeDetector;
7193
- this.disabled = false;
7226
+ constructor() {
7227
+ this._disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : []));
7228
+ this._selection = signal(undefined, ...(ngDevMode ? [{ debugName: "_selection" }] : []));
7194
7229
  this._onChange = () => ({});
7195
7230
  this._onTouched = () => ({});
7196
7231
  }
7197
- ngAfterContentInit() {
7198
- this.selectCardsList?.forEach(card => {
7199
- card._parendDisabled = this.disabled;
7200
- if (card.value === this.selection) {
7201
- card.selected = true;
7202
- this.changeDetector.markForCheck();
7203
- }
7204
- card.onSelectFn = value => {
7205
- if (!this.disabled) {
7232
+ // Expose state for injection token
7233
+ getState() {
7234
+ return {
7235
+ disabled: this._disabled.asReadonly(),
7236
+ selectedValue: this._selection.asReadonly(),
7237
+ onCardSelect: (value) => {
7238
+ if (!this._disabled()) {
7206
7239
  this.updateCardsSelection(value);
7207
7240
  }
7208
- };
7209
- card._markForCheck();
7210
- });
7241
+ },
7242
+ };
7211
7243
  }
7212
7244
  // From ControlValueAccessor interface
7213
7245
  writeValue(value) {
7214
- this.selection = value;
7246
+ this._selection.set(value);
7215
7247
  this.updateCardsSelection(value);
7216
- this.changeDetector.markForCheck();
7217
7248
  }
7218
7249
  // From ControlValueAccessor interface
7219
7250
  registerOnChange(fn) {
@@ -7225,51 +7256,42 @@ class GioFormSelectionInlineComponent {
7225
7256
  }
7226
7257
  // From ControlValueAccessor interface
7227
7258
  setDisabledState(isDisabled) {
7228
- this.disabled = isDisabled;
7229
- if (this.selectCardsList) {
7230
- this.selectCardsList.forEach(card => {
7231
- card._parendDisabled = this.disabled;
7232
- card._markForCheck();
7233
- });
7234
- }
7235
- this.changeDetector.markForCheck();
7259
+ this._disabled.set(isDisabled);
7236
7260
  }
7237
7261
  updateCardsSelection(value) {
7238
- if (this.selectCardsList) {
7239
- this.selectCardsList.forEach(card => {
7240
- const newSelectedValue = card.value === value;
7241
- if (newSelectedValue !== card.selected) {
7242
- card.selected = card.value === value;
7243
- card._markForCheck();
7244
- }
7245
- });
7246
- this.selection = value;
7247
- this._onChange(this.selection);
7248
- this._onTouched();
7249
- }
7262
+ this._selection.set(value);
7263
+ this._onChange(this._selection());
7264
+ this._onTouched();
7250
7265
  }
7251
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
7266
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
7252
7267
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: GioFormSelectionInlineComponent, isStandalone: false, selector: "gio-form-selection-inline", providers: [
7253
7268
  {
7254
7269
  provide: NG_VALUE_ACCESSOR,
7255
7270
  multi: true,
7256
7271
  useExisting: forwardRef(() => GioFormSelectionInlineComponent),
7257
7272
  },
7258
- ], queries: [{ propertyName: "selectCardsList", predicate: i0.forwardRef(() => GioFormSelectionInlineCardComponent), descendants: true }], ngImport: i0, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<ng-content select=\"gio-form-selection-inline-card\"></ng-content>\n", styles: [":host{display:grid;gap:6px;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
7273
+ {
7274
+ provide: GIO_FORM_SELECTION_INLINE_STATE,
7275
+ useFactory: (component) => component.getState(),
7276
+ deps: [forwardRef(() => GioFormSelectionInlineComponent)],
7277
+ },
7278
+ ], ngImport: i0, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<ng-content select=\"gio-form-selection-inline-card\"></ng-content>\n", styles: [":host{display:grid;gap:6px;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
7259
7279
  }
7260
7280
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GioFormSelectionInlineComponent, decorators: [{
7261
7281
  type: Component,
7262
- args: [{ selector: 'gio-form-selection-inline', providers: [
7282
+ args: [{ selector: 'gio-form-selection-inline', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
7263
7283
  {
7264
7284
  provide: NG_VALUE_ACCESSOR,
7265
7285
  multi: true,
7266
7286
  useExisting: forwardRef(() => GioFormSelectionInlineComponent),
7267
7287
  },
7268
- ], changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<ng-content select=\"gio-form-selection-inline-card\"></ng-content>\n", styles: [":host{display:grid;gap:6px;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}\n"] }]
7269
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { selectCardsList: [{
7270
- type: ContentChildren,
7271
- args: [forwardRef(() => GioFormSelectionInlineCardComponent), { descendants: true }]
7272
- }] } });
7288
+ {
7289
+ provide: GIO_FORM_SELECTION_INLINE_STATE,
7290
+ useFactory: (component) => component.getState(),
7291
+ deps: [forwardRef(() => GioFormSelectionInlineComponent)],
7292
+ },
7293
+ ], standalone: false, template: "<!--\n\n Copyright (C) 2015 The Gravitee team (http://gravitee.io)\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<ng-content select=\"gio-form-selection-inline-card\"></ng-content>\n", styles: [":host{display:grid;gap:6px;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}\n"] }]
7294
+ }], ctorParameters: () => [] });
7273
7295
 
7274
7296
  /*
7275
7297
  * Copyright (C) 2015 The Gravitee team (http://gravitee.io)