@brggroup/share-lib 0.0.69 → 0.0.70
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.
|
@@ -5122,22 +5122,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImpor
|
|
|
5122
5122
|
class NumberOnlyDirective {
|
|
5123
5123
|
el;
|
|
5124
5124
|
renderer;
|
|
5125
|
-
|
|
5125
|
+
inputEl;
|
|
5126
|
+
onChange = (_) => { };
|
|
5126
5127
|
onTouched = () => { };
|
|
5127
5128
|
constructor(el, renderer) {
|
|
5128
5129
|
this.el = el;
|
|
5129
5130
|
this.renderer = renderer;
|
|
5130
5131
|
}
|
|
5131
|
-
|
|
5132
|
-
const
|
|
5133
|
-
|
|
5134
|
-
if (
|
|
5135
|
-
this.
|
|
5132
|
+
ngAfterViewInit() {
|
|
5133
|
+
const native = this.el.nativeElement;
|
|
5134
|
+
// nếu gắn trực tiếp vào input
|
|
5135
|
+
if (native.tagName === 'INPUT') {
|
|
5136
|
+
this.inputEl = native;
|
|
5137
|
+
}
|
|
5138
|
+
else {
|
|
5139
|
+
// nếu gắn vào cha → tìm input con đầu tiên
|
|
5140
|
+
this.inputEl = native.querySelector('input');
|
|
5136
5141
|
}
|
|
5137
5142
|
}
|
|
5143
|
+
onInput(target) {
|
|
5144
|
+
if (!this.inputEl || target !== this.inputEl)
|
|
5145
|
+
return;
|
|
5146
|
+
const formattedValue = this.formatValue(this.inputEl.value);
|
|
5147
|
+
this.renderer.setProperty(this.inputEl, 'value', formattedValue);
|
|
5148
|
+
this.onChange(formattedValue);
|
|
5149
|
+
}
|
|
5138
5150
|
writeValue(value) {
|
|
5151
|
+
if (!this.inputEl)
|
|
5152
|
+
return;
|
|
5139
5153
|
const formattedValue = value ? this.formatValue(value) : '';
|
|
5140
|
-
this.renderer.setProperty(this.
|
|
5154
|
+
this.renderer.setProperty(this.inputEl, 'value', formattedValue);
|
|
5141
5155
|
}
|
|
5142
5156
|
registerOnChange(fn) {
|
|
5143
5157
|
this.onChange = fn;
|
|
@@ -5146,13 +5160,15 @@ class NumberOnlyDirective {
|
|
|
5146
5160
|
this.onTouched = fn;
|
|
5147
5161
|
}
|
|
5148
5162
|
setDisabledState(isDisabled) {
|
|
5149
|
-
|
|
5163
|
+
if (this.inputEl) {
|
|
5164
|
+
this.renderer.setProperty(this.inputEl, 'disabled', isDisabled);
|
|
5165
|
+
}
|
|
5150
5166
|
}
|
|
5151
5167
|
formatValue(value) {
|
|
5152
5168
|
return value.replace(/\D/g, '');
|
|
5153
5169
|
}
|
|
5154
5170
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: NumberOnlyDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5155
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.7", type: NumberOnlyDirective, isStandalone: true, selector: "[numberOnly]", host: { listeners: { "input": "onInput($event.target
|
|
5171
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.7", type: NumberOnlyDirective, isStandalone: true, selector: "[numberOnly]", host: { listeners: { "input": "onInput($event.target)" } }, providers: [
|
|
5156
5172
|
{
|
|
5157
5173
|
provide: NG_VALUE_ACCESSOR,
|
|
5158
5174
|
useExisting: forwardRef(() => NumberOnlyDirective),
|
|
@@ -5174,7 +5190,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImpor
|
|
|
5174
5190
|
}]
|
|
5175
5191
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { onInput: [{
|
|
5176
5192
|
type: HostListener,
|
|
5177
|
-
args: ['input', ['$event.target
|
|
5193
|
+
args: ['input', ['$event.target']]
|
|
5178
5194
|
}] } });
|
|
5179
5195
|
|
|
5180
5196
|
class UpperCaseFirsLetterEachWordDirective {
|