@mozaic-ds/angular 2.0.3 → 2.0.4

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, computed, ChangeDetectionStrategy, Component, contentChild, ViewEncapsulation, signal, forwardRef, output, ContentChild, viewChild, inject, model, InjectionToken, HostListener, Injector, Injectable, TemplateRef, afterNextRender, Directive, linkedSignal, EnvironmentInjector, createComponent, ChangeDetectorRef, NgZone, viewChildren, EventEmitter, effect, Output, ContentChildren, ElementRef, Input, booleanAttribute, contentChildren } from '@angular/core';
2
+ import { input, computed, ChangeDetectionStrategy, Component, contentChild, ViewEncapsulation, signal, forwardRef, output, ContentChild, viewChild, inject, model, InjectionToken, HostListener, Injector, Injectable, TemplateRef, afterNextRender, Directive, linkedSignal, EnvironmentInjector, createComponent, ChangeDetectorRef, NgZone, viewChildren, EventEmitter, effect, Output, ContentChildren, ApplicationRef, Renderer2, ElementRef, Input, booleanAttribute, contentChildren } from '@angular/core';
3
3
  import { RouterLink, RouterLinkActive, RouterLinkWithHref } from '@angular/router';
4
4
  import { NgTemplateOutlet, NgClass, NgComponentOutlet } from '@angular/common';
5
5
  import * as i1 from '@angular/forms';
@@ -1733,8 +1733,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1733
1733
  }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { isInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "isInvalid", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], minLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minLength", required: false }] }], maxLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxLength", required: false }] }] } });
1734
1734
 
1735
1735
  class MozTextInput {
1736
- elementRef;
1737
- renderer;
1738
1736
  isInvalid = input(false, ...(ngDevMode ? [{ debugName: "isInvalid" }] : []));
1739
1737
  disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1740
1738
  readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
@@ -1752,18 +1750,49 @@ class MozTextInput {
1752
1750
  isClearable = computed(() => this.clearable() && this._value(), ...(ngDevMode ? [{ debugName: "isClearable" }] : []));
1753
1751
  isDisabledState = computed(() => this.disabled() || this._isDisabled(), ...(ngDevMode ? [{ debugName: "isDisabledState" }] : []));
1754
1752
  environmentInjector = inject(EnvironmentInjector);
1755
- constructor(elementRef, renderer) {
1756
- this.elementRef = elementRef;
1757
- this.renderer = renderer;
1758
- }
1753
+ applicationRef = inject(ApplicationRef);
1754
+ renderer = inject(Renderer2);
1755
+ elementRef = inject((ElementRef));
1756
+ injector = inject(Injector);
1759
1757
  ngAfterViewInit() {
1760
1758
  this.wrapInput();
1759
+ this.setupEffects();
1761
1760
  }
1762
1761
  ngOnDestroy() {
1763
1762
  if (this.iconComponentRef) {
1763
+ this.applicationRef.detachView(this.iconComponentRef.hostView);
1764
1764
  this.iconComponentRef.destroy();
1765
1765
  }
1766
1766
  }
1767
+ setupEffects() {
1768
+ // Effect pour mettre à jour la classe 'is-invalid'
1769
+ effect(() => {
1770
+ if (this.wrapper) {
1771
+ if (this.isInvalid()) {
1772
+ this.renderer.addClass(this.wrapper, 'is-invalid');
1773
+ }
1774
+ else {
1775
+ this.renderer.removeClass(this.wrapper, 'is-invalid');
1776
+ }
1777
+ }
1778
+ }, { injector: this.injector });
1779
+ // Effect pour mettre à jour la classe de taille
1780
+ effect(() => {
1781
+ if (this.wrapper) {
1782
+ // Retirer toutes les classes de taille existantes
1783
+ this.renderer.removeClass(this.wrapper, 'text-input--s');
1784
+ this.renderer.removeClass(this.wrapper, 'text-input--m');
1785
+ // Ajouter la nouvelle classe de taille
1786
+ if (this.size()) {
1787
+ this.renderer.addClass(this.wrapper, `text-input--${this.size()}`);
1788
+ }
1789
+ }
1790
+ }, { injector: this.injector });
1791
+ // Effect pour mettre à jour la visibilité du bouton clear
1792
+ effect(() => {
1793
+ this.updateClearButtonVisibility();
1794
+ }, { injector: this.injector });
1795
+ }
1767
1796
  wrapInput() {
1768
1797
  const input = this.elementRef.nativeElement;
1769
1798
  const parent = input.parentElement;
@@ -1771,6 +1800,7 @@ class MozTextInput {
1771
1800
  return;
1772
1801
  this.wrapper = this.renderer.createElement('div');
1773
1802
  this.renderer.addClass(this.wrapper, 'text-input');
1803
+ // Appliquer les classes initiales
1774
1804
  if (this.size()) {
1775
1805
  this.renderer.addClass(this.wrapper, `text-input--${this.size()}`);
1776
1806
  }
@@ -1829,6 +1859,8 @@ class MozTextInput {
1829
1859
  this.iconComponentRef = createComponent(CrossCircleFilled24, {
1830
1860
  environmentInjector: this.environmentInjector,
1831
1861
  });
1862
+ // Attacher la vue à ApplicationRef pour activer la détection de changements
1863
+ this.applicationRef.attachView(this.iconComponentRef.hostView);
1832
1864
  const iconElement = this.iconComponentRef.location.nativeElement;
1833
1865
  this.renderer.addClass(iconElement, 'controls-options__icon');
1834
1866
  this.renderer.setAttribute(iconElement, 'aria-hidden', 'true');
@@ -1862,13 +1894,11 @@ class MozTextInput {
1862
1894
  this.onTouched();
1863
1895
  const event = new Event('input', { bubbles: true });
1864
1896
  input.dispatchEvent(event);
1865
- this.updateClearButtonVisibility();
1866
1897
  }
1867
1898
  onInput(event) {
1868
1899
  const value = event.target.value;
1869
1900
  this._value.set(value);
1870
1901
  this.onChange(value);
1871
- this.updateClearButtonVisibility();
1872
1902
  }
1873
1903
  onChange = () => void 0;
1874
1904
  onTouched = () => void 0;
@@ -1876,7 +1906,6 @@ class MozTextInput {
1876
1906
  const normalizedValue = value == null ? '' : String(value);
1877
1907
  this._value.set(normalizedValue);
1878
1908
  this.renderer.setProperty(this.elementRef.nativeElement, 'value', normalizedValue);
1879
- this.updateClearButtonVisibility();
1880
1909
  }
1881
1910
  registerOnChange(fn) {
1882
1911
  this.onChange = fn;
@@ -1888,8 +1917,8 @@ class MozTextInput {
1888
1917
  this._isDisabled.set(isDisabled);
1889
1918
  this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', isDisabled);
1890
1919
  }
1891
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MozTextInput, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1892
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.3", type: MozTextInput, isStandalone: true, selector: "input[moz-text-input]", inputs: { isInvalid: { classPropertyName: "isInvalid", publicName: "isInvalid", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, clearLabel: { classPropertyName: "clearLabel", publicName: "clearLabel", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)", "blur": "onTouched()" }, properties: { "class": "\"text-input__control\"", "attr.aria-invalid": "isInvalid()", "disabled": "isDisabledState()" } }, providers: [
1920
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MozTextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
1921
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.3", type: MozTextInput, isStandalone: true, selector: "input[moz-text-input]", inputs: { isInvalid: { classPropertyName: "isInvalid", publicName: "isInvalid", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, clearLabel: { classPropertyName: "clearLabel", publicName: "clearLabel", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)", "blur": "onTouched()" }, properties: { "class": "\"text-input__control\"", "attr.aria-invalid": "isInvalid()", "readOnly": "readonly()", "disabled": "isDisabledState()" } }, providers: [
1893
1922
  {
1894
1923
  provide: NG_VALUE_ACCESSOR,
1895
1924
  useExisting: forwardRef(() => MozTextInput),
@@ -1908,11 +1937,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1908
1937
  ], encapsulation: ViewEncapsulation.None, host: {
1909
1938
  '[class]': '"text-input__control"',
1910
1939
  '[attr.aria-invalid]': 'isInvalid()',
1940
+ '[readOnly]': 'readonly()',
1911
1941
  '[disabled]': 'isDisabledState()',
1912
1942
  '(input)': 'onInput($event)',
1913
1943
  '(blur)': 'onTouched()',
1914
1944
  }, styles: [".mc-controls-options,.controls-options{align-items:center;display:inline-flex;justify-content:center;gap:.5rem}.mc-controls-options__button,.controls-options__button{background-color:transparent;border-width:0;color:initial;font-family:inherit;outline:none;appearance:none;cursor:pointer;padding:0;border-radius:var(--border-radius-full, 100%)}.mc-controls-options__button:hover .mc-controls-options__icon,.controls-options__button:hover .mc-controls-options__icon,.mc-controls-options__button:hover .controls-options__icon,.controls-options__button:hover .controls-options__icon{fill:var(--forms-color-icon-clear-hover, #4d4d4d)}.mc-controls-options__button:focus-visible,.controls-options__button:focus-visible{box-shadow:0 0 0 .125rem var(--focus-color-mid, var(--focus-color-outline-mid, #ffffff)),0 0 0 .25rem var(--focus-color-outer, var(--focus-color-outline-outer, #000000));outline:.125rem solid transparent;outline-offset:.125rem}.mc-controls-options__icon,.controls-options__icon{fill:var(--forms-color-icon-clear, #666666)}.mc-controls-options__button,.controls-options__button,.mc-controls-options__icon,.controls-options__icon{height:1.5rem;width:1.5rem}.mc-controls-options__label,.controls-options__label{clip-path:inset(100%);clip:rect(1px,1px,1px,1px);height:1px;overflow:hidden;position:absolute;white-space:nowrap;padding:0;width:1px}.mc-controls-options__unit{font-size:var(--font-size-150, 1rem);line-height:var(--line-height-s, 1.3);font-weight:var(--font-weight-semi-bold, 600);color:var(--forms-color-text-default, #000000)}.mc-text-input,.text-input{transition:box-shadow .2s ease;background-color:var(--forms-color-background-default, #ffffff);border:var(--border-width-s, .0625rem) solid var(--forms-color-border-default, #666666);border-radius:var(--forms-border-radius, .25rem);transition:all ease .2s;color:var(--forms-color-text-default, #000000);display:block;width:100%;height:3rem;box-sizing:border-box;display:flex;align-items:center;gap:.5rem}.mc-text-input__control,.text-input__control{background-color:transparent;border-width:0;font-family:inherit;outline:none}.mc-text-input__control[type=number]::-webkit-inner-spin-button,[type=number].text-input__control::-webkit-inner-spin-button,.mc-text-input__control[type=number]::-webkit-outer-spin-button,[type=number].text-input__control::-webkit-outer-spin-button{appearance:none;margin:0}.mc-text-input__control[type=number],[type=number].text-input__control{appearance:textfield}.mc-text-input__control[type=search]::-webkit-search-decoration,[type=search].text-input__control::-webkit-search-decoration,.mc-text-input__control[type=search]::-webkit-search-cancel-button,[type=search].text-input__control::-webkit-search-cancel-button{appearance:none}.mc-text-input__control,.text-input__control{padding:.75rem .6875rem;font-size:var(--font-size-150, 1rem);line-height:var(--line-height-s, 1.3);font-weight:var(--font-weight-regular, 400);flex-grow:1}.mc-text-input__control::placeholder,.text-input__control::placeholder{color:var(--forms-color-placeholder, #666666)}.mc-text-input__addon,.text-input__addon{font-size:var(--font-size-150, 1rem);font-weight:var(--font-weight-semi-bold, 600);color:var(--forms-color-text-default, #000000)}.mc-text-input__icon,.text-input__icon{fill:var(--forms-color-icon-default, #666666);height:1.5rem;width:1.5rem;flex-shrink:0}.mc-text-input:focus-within,.text-input:focus-within{box-shadow:0 0 0 .125rem var(--focus-color-mid, var(--focus-color-outline-mid, #ffffff)),0 0 0 .25rem var(--focus-color-outer, var(--focus-color-outline-outer, #000000));outline:.125rem solid transparent;outline-offset:.125rem}.mc-text-input:hover:not(:focus-within),.text-input:hover:not(:focus-within){border-color:var(--forms-color-border-hover, #4d4d4d);box-shadow:0 0 0 var(--border-width-s, .0625rem) var(--forms-color-border-hover, #4d4d4d)}.mc-text-input:has(input:disabled),.text-input:has(input:disabled){background-color:var(--forms-color-background-disabled, #d9d9d9);cursor:not-allowed;border-color:transparent;box-shadow:none;color:var(--forms-color-text-disabled, #737373);pointer-events:none}.mc-text-input:has(input[readonly]),.text-input:has(input[readonly]){border-color:var(--forms-color-border-read-only, #cccccc);pointer-events:none}.mc-text-input:has(.mc-text-input__icon,.text-input__icon),.text-input:has(.mc-text-input__icon,.text-input__icon),.mc-text-input:has(.mc-text-input__addon,.text-input__addon),.text-input:has(.mc-text-input__addon,.text-input__addon){padding-inline-start:.6875rem}.mc-text-input:has(.mc-text-input__icon,.text-input__icon) .mc-text-input__control,.text-input:has(.mc-text-input__icon,.text-input__icon) .mc-text-input__control,.mc-text-input:has(.mc-text-input__icon,.text-input__icon) .text-input__control,.text-input:has(.mc-text-input__icon,.text-input__icon) .text-input__control,.mc-text-input:has(.mc-text-input__addon,.text-input__addon) .mc-text-input__control,.text-input:has(.mc-text-input__addon,.text-input__addon) .mc-text-input__control,.mc-text-input:has(.mc-text-input__addon,.text-input__addon) .text-input__control,.text-input:has(.mc-text-input__addon,.text-input__addon) .text-input__control{padding-inline-start:0}.mc-text-input:has(.mc-controls-options,.controls-options),.text-input:has(.mc-controls-options,.controls-options),.mc-text-input:has(.mc-text-input__addon,.text-input__addon),.text-input:has(.mc-text-input__addon,.text-input__addon){padding-inline-end:.6875rem}.mc-text-input:has(.mc-controls-options,.controls-options) .mc-text-input__control,.text-input:has(.mc-controls-options,.controls-options) .mc-text-input__control,.mc-text-input:has(.mc-controls-options,.controls-options) .text-input__control,.text-input:has(.mc-controls-options,.controls-options) .text-input__control,.mc-text-input:has(.mc-text-input__addon,.text-input__addon) .mc-text-input__control,.text-input:has(.mc-text-input__addon,.text-input__addon) .mc-text-input__control,.mc-text-input:has(.mc-text-input__addon,.text-input__addon) .text-input__control,.text-input:has(.mc-text-input__addon,.text-input__addon) .text-input__control{padding-inline-end:0}.mc-text-input--s,.text-input--s{height:2rem}.mc-text-input--s .mc-text-input__control,.text-input--s .mc-text-input__control,.mc-text-input--s .text-input__control,.text-input--s .text-input__control{padding:.375rem .6875rem;font-size:var(--font-size-100, .875rem);line-height:var(--line-height-s, 1.3)}.mc-text-input--s:has(.mc-text-input__icon,.text-input__icon),.text-input--s:has(.mc-text-input__icon,.text-input__icon){padding-inline-start:.4375rem}.mc-text-input--s:has(.mc-controls-options,.controls-options),.text-input--s:has(.mc-controls-options,.controls-options){padding-inline-end:.4375rem}.mc-text-input.is-invalid,.is-invalid.text-input{border-color:var(--forms-color-border-invalid, #ea302d);box-shadow:0 0 0 var(--border-width-s, .0625rem) var(--forms-color-border-invalid, #ea302d)}.mc-text-input.is-invalid:hover:not(:focus-within),.is-invalid.text-input:hover:not(:focus-within){border-color:var(--forms-color-border-invalid-hover, #c61112);box-shadow:0 0 0 var(--border-width-s, .0625rem) var(--forms-color-border-invalid-hover, #c61112)}.mc-text-input *,.text-input *{box-sizing:border-box}.text-input__icon:empty{display:none}\n"] }]
1915
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { isInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "isInvalid", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], clearable: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearable", required: false }] }], clearLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearLabel", required: false }] }], prefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "prefix", required: false }] }], suffix: [{ type: i0.Input, args: [{ isSignal: true, alias: "suffix", required: false }] }] } });
1945
+ }], propDecorators: { isInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "isInvalid", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], clearable: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearable", required: false }] }], clearLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearLabel", required: false }] }], prefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "prefix", required: false }] }], suffix: [{ type: i0.Input, args: [{ isSignal: true, alias: "suffix", required: false }] }] } });
1916
1946
 
1917
1947
  class MozToggleComponent {
1918
1948
  id = input.required(...(ngDevMode ? [{ debugName: "id" }] : []));