@covalent/core 11.3.3 → 11.4.1
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/common/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { PipeTransform, ChangeDetectorRef } from '@angular/core';
|
2
|
+
import { PipeTransform, ChangeDetectorRef, OnInit } from '@angular/core';
|
3
3
|
import * as i10 from '@angular/forms';
|
4
4
|
import { ControlValueAccessor, NgControl, ValidatorFn, AbstractControl } from '@angular/forms';
|
5
5
|
import * as i11 from '@angular/common';
|
@@ -250,20 +250,24 @@ interface ICanDisableRipple {
|
|
250
250
|
/** Mixin to augment a component or directive with a `disabled` property. */
|
251
251
|
declare function mixinDisableRipple<T extends Constructor<Record<string, unknown>>>(base: T): Constructor<ICanDisableRipple> & T;
|
252
252
|
|
253
|
-
declare class CovalentTextfieldValueAccessorDirective implements ControlValueAccessor {
|
253
|
+
declare class CovalentTextfieldValueAccessorDirective implements ControlValueAccessor, OnInit {
|
254
|
+
private _destroyRef;
|
254
255
|
private _elementRef;
|
255
256
|
_ngControl: NgControl;
|
256
257
|
private _onChange;
|
257
258
|
private _onTouched;
|
258
259
|
constructor();
|
260
|
+
ngOnInit(): void;
|
259
261
|
writeValue(value: string): void;
|
260
262
|
registerOnChange(fn: any): void;
|
261
263
|
registerOnTouched(fn: any): void;
|
264
|
+
handleInput(): void;
|
262
265
|
handleChange(event: Event): void;
|
263
266
|
handleBlur(): void;
|
264
267
|
setDisabledState(isDisabled: boolean): void;
|
265
268
|
private _isCheckBox;
|
266
269
|
private _isRadio;
|
270
|
+
private _isTextAreaOrField;
|
267
271
|
private _updateValidity;
|
268
272
|
static ɵfac: i0.ɵɵFactoryDeclaration<CovalentTextfieldValueAccessorDirective, never>;
|
269
273
|
static ɵdir: i0.ɵɵDirectiveDeclaration<CovalentTextfieldValueAccessorDirective, "cv-textfield[formControl], cv-textarea[formControl], cv-select[formControl], cv-checkbox[formControl], cv-checkbox-icon[formControl], cv-radio[formControl], cv-radio-icon[formControl], cv-textfield[formControlName], cv-textarea[formControlName], cv-select[formControlName], cv-checkbox[formControlName], cv-checkbox-icon[formControlName], cv-radio[formControlName], cv-radio-icon[formControlName],", never, {}, {}, never, never, true, never>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { inject, Directive, HostListener, ElementRef, Pipe, Injectable, NgModule } from '@angular/core';
|
2
|
+
import { inject, Directive, HostListener, ElementRef, Pipe, Injectable, NgModule, DestroyRef } from '@angular/core';
|
3
3
|
import { DOCUMENT, DecimalPipe, CommonModule } from '@angular/common';
|
4
4
|
import { NgModel, FormsModule, NgControl, Validators } from '@angular/forms';
|
5
5
|
import { MAT_ICON_DEFAULT_OPTIONS } from '@angular/material/icon';
|
@@ -9,6 +9,7 @@ import { filter, pairwise } from 'rxjs/operators';
|
|
9
9
|
import { trigger, state, transition, style, group, query, animate, animateChild, AUTO_STYLE, keyframes } from '@angular/animations';
|
10
10
|
import { Subject } from 'rxjs';
|
11
11
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
12
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
12
13
|
|
13
14
|
class TdAutoTrimDirective {
|
14
15
|
_model = inject(NgModel, { optional: true, host: true });
|
@@ -2060,6 +2061,7 @@ function mixinDisableRipple(base) {
|
|
2060
2061
|
|
2061
2062
|
/* eslint-disable @angular-eslint/directive-selector */
|
2062
2063
|
class CovalentTextfieldValueAccessorDirective {
|
2064
|
+
_destroyRef = inject(DestroyRef);
|
2063
2065
|
_elementRef = inject(ElementRef);
|
2064
2066
|
_ngControl = inject(NgControl);
|
2065
2067
|
_onChange = () => {
|
@@ -2072,6 +2074,17 @@ class CovalentTextfieldValueAccessorDirective {
|
|
2072
2074
|
const _ngControl = this._ngControl;
|
2073
2075
|
_ngControl.valueAccessor = this;
|
2074
2076
|
}
|
2077
|
+
ngOnInit() {
|
2078
|
+
// Set up a subscription to monitor status changes
|
2079
|
+
if (this._ngControl.control) {
|
2080
|
+
this._ngControl.control.statusChanges
|
2081
|
+
.pipe(takeUntilDestroyed(this._destroyRef))
|
2082
|
+
.subscribe(() => {
|
2083
|
+
this._onTouched();
|
2084
|
+
this._updateValidity();
|
2085
|
+
});
|
2086
|
+
}
|
2087
|
+
}
|
2075
2088
|
writeValue(value) {
|
2076
2089
|
if (this._isCheckBox()) {
|
2077
2090
|
this._elementRef.nativeElement.value = value || '';
|
@@ -2092,6 +2105,15 @@ class CovalentTextfieldValueAccessorDirective {
|
|
2092
2105
|
registerOnTouched(fn) {
|
2093
2106
|
this._onTouched = fn;
|
2094
2107
|
}
|
2108
|
+
handleInput() {
|
2109
|
+
if (!this._isTextAreaOrField()) {
|
2110
|
+
return;
|
2111
|
+
}
|
2112
|
+
const value = this._elementRef.nativeElement.value;
|
2113
|
+
this._onChange(value);
|
2114
|
+
this._onTouched();
|
2115
|
+
this._updateValidity();
|
2116
|
+
}
|
2095
2117
|
handleChange(event) {
|
2096
2118
|
const value = this._isCheckBox()
|
2097
2119
|
? this._elementRef.nativeElement.checked
|
@@ -2115,6 +2137,10 @@ class CovalentTextfieldValueAccessorDirective {
|
|
2115
2137
|
const tagName = this._elementRef.nativeElement.tagName.toLowerCase();
|
2116
2138
|
return tagName === 'cv-radio' || tagName === 'cv-radio-icon';
|
2117
2139
|
}
|
2140
|
+
_isTextAreaOrField() {
|
2141
|
+
const tagName = this._elementRef.nativeElement.tagName.toLowerCase();
|
2142
|
+
return tagName === 'cv-textarea' || tagName === 'cv-textfield';
|
2143
|
+
}
|
2118
2144
|
_updateValidity() {
|
2119
2145
|
const element = this._elementRef.nativeElement;
|
2120
2146
|
const control = this._ngControl.control;
|
@@ -2134,7 +2160,7 @@ class CovalentTextfieldValueAccessorDirective {
|
|
2134
2160
|
}
|
2135
2161
|
static ɵfac = function CovalentTextfieldValueAccessorDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CovalentTextfieldValueAccessorDirective)(); };
|
2136
2162
|
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: CovalentTextfieldValueAccessorDirective, selectors: [["cv-textfield", "formControl", ""], ["cv-textarea", "formControl", ""], ["cv-select", "formControl", ""], ["cv-checkbox", "formControl", ""], ["cv-checkbox-icon", "formControl", ""], ["cv-radio", "formControl", ""], ["cv-radio-icon", "formControl", ""], ["cv-textfield", "formControlName", ""], ["cv-textarea", "formControlName", ""], ["cv-select", "formControlName", ""], ["cv-checkbox", "formControlName", ""], ["cv-checkbox-icon", "formControlName", ""], ["cv-radio", "formControlName", ""], ["cv-radio-icon", "formControlName", ""], [""]], hostBindings: function CovalentTextfieldValueAccessorDirective_HostBindings(rf, ctx) { if (rf & 1) {
|
2137
|
-
i0.ɵɵlistener("change", function CovalentTextfieldValueAccessorDirective_change_HostBindingHandler($event) { return ctx.handleChange($event); })("blur", function CovalentTextfieldValueAccessorDirective_blur_HostBindingHandler() { return ctx.handleBlur(); });
|
2163
|
+
i0.ɵɵlistener("input", function CovalentTextfieldValueAccessorDirective_input_HostBindingHandler() { return ctx.handleInput(); })("change", function CovalentTextfieldValueAccessorDirective_change_HostBindingHandler($event) { return ctx.handleChange($event); })("blur", function CovalentTextfieldValueAccessorDirective_blur_HostBindingHandler() { return ctx.handleBlur(); });
|
2138
2164
|
} } });
|
2139
2165
|
}
|
2140
2166
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentTextfieldValueAccessorDirective, [{
|
@@ -2155,7 +2181,10 @@ class CovalentTextfieldValueAccessorDirective {
|
|
2155
2181
|
cv-radio[formControlName],
|
2156
2182
|
cv-radio-icon[formControlName],`,
|
2157
2183
|
}]
|
2158
|
-
}], () => [], {
|
2184
|
+
}], () => [], { handleInput: [{
|
2185
|
+
type: HostListener,
|
2186
|
+
args: ['input']
|
2187
|
+
}], handleChange: [{
|
2159
2188
|
type: HostListener,
|
2160
2189
|
args: ['change', ['$event']]
|
2161
2190
|
}], handleBlur: [{
|