@ptsecurity/mosaic 17.2.8 → 17.2.10
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/core/locales/locale-service.d.ts +11 -0
- package/core/pop-up/pop-up-trigger.d.ts +8 -9
- package/core/pop-up/pop-up.d.ts +3 -3
- package/ellipsis-center/ellipsis-center.directive.d.ts +3 -7
- package/esm2022/core/locales/locale-service.mjs +34 -1
- package/esm2022/core/pop-up/pop-up-trigger.mjs +13 -16
- package/esm2022/core/pop-up/pop-up.mjs +7 -6
- package/esm2022/core/version.mjs +2 -2
- package/esm2022/ellipsis-center/ellipsis-center.directive.mjs +12 -23
- package/esm2022/input/input-number.mjs +29 -57
- package/esm2022/input/input-password.mjs +15 -26
- package/esm2022/navbar/navbar-item.component.mjs +16 -30
- package/esm2022/popover/popover-confirm.component.mjs +11 -20
- package/esm2022/popover/popover.component.mjs +21 -28
- package/esm2022/select/select-option.directive.mjs +7 -18
- package/esm2022/timezone/timezone-option.directive.mjs +7 -18
- package/esm2022/title/title.directive.mjs +7 -18
- package/esm2022/tooltip/tooltip.component.mjs +32 -44
- package/fesm2022/ptsecurity-mosaic-core.mjs +54 -23
- package/fesm2022/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-ellipsis-center.mjs +11 -19
- package/fesm2022/ptsecurity-mosaic-ellipsis-center.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-input.mjs +35 -71
- package/fesm2022/ptsecurity-mosaic-input.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-navbar.mjs +14 -26
- package/fesm2022/ptsecurity-mosaic-navbar.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-popover.mjs +27 -38
- package/fesm2022/ptsecurity-mosaic-popover.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-select.mjs +17 -23
- package/fesm2022/ptsecurity-mosaic-select.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-timezone.mjs +10 -17
- package/fesm2022/ptsecurity-mosaic-timezone.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-title.mjs +6 -14
- package/fesm2022/ptsecurity-mosaic-title.mjs.map +1 -1
- package/fesm2022/ptsecurity-mosaic-tooltip.mjs +31 -41
- package/fesm2022/ptsecurity-mosaic-tooltip.mjs.map +1 -1
- package/input/input-number.d.ts +9 -10
- package/input/input-password.d.ts +3 -6
- package/navbar/navbar-item.component.d.ts +5 -7
- package/package.json +4 -4
- package/popover/popover-confirm.component.d.ts +3 -6
- package/popover/popover.component.d.ts +4 -6
- package/select/select-option.directive.d.ts +3 -6
- package/timezone/timezone-option.directive.d.ts +3 -6
- package/title/title.directive.d.ts +3 -6
- package/tooltip/tooltip.component.d.ts +10 -11
@@ -1,26 +1,23 @@
|
|
1
|
-
import * as i3 from '@angular/cdk/a11y';
|
2
|
-
import * as i2 from '@angular/cdk/bidi';
|
3
|
-
import * as i1 from '@angular/cdk/overlay';
|
4
1
|
import * as i0 from '@angular/core';
|
5
|
-
import {
|
6
|
-
import { McTooltipTrigger
|
2
|
+
import { inject, Renderer2, Directive, Input, NgModule } from '@angular/core';
|
3
|
+
import { McTooltipTrigger } from '@ptsecurity/mosaic/tooltip';
|
7
4
|
import { Subject, Subscription } from 'rxjs';
|
8
5
|
import { debounceTime } from 'rxjs/operators';
|
9
6
|
|
10
7
|
const MIN_VISIBLE_LENGTH = 50;
|
11
8
|
class McEllipsisCenterDirective extends McTooltipTrigger {
|
12
|
-
|
13
|
-
|
14
|
-
this.refresh();
|
15
|
-
}
|
16
|
-
constructor(overlay, elementRef, ngZone, scrollDispatcher, hostView, scrollStrategy, direction, focusMonitor, renderer) {
|
17
|
-
super(overlay, elementRef, ngZone, scrollDispatcher, hostView, scrollStrategy, direction, focusMonitor);
|
18
|
-
this.renderer = renderer;
|
9
|
+
constructor() {
|
10
|
+
super(...arguments);
|
19
11
|
this.minVisibleLength = MIN_VISIBLE_LENGTH;
|
20
12
|
this.resizeStream = new Subject();
|
13
|
+
this.renderer = inject(Renderer2);
|
21
14
|
this.resizeSubscription = Subscription.EMPTY;
|
22
15
|
this.debounceInterval = 50;
|
23
16
|
}
|
17
|
+
set mcEllipsisCenter(value) {
|
18
|
+
this._mcEllipsisCenter = value;
|
19
|
+
this.refresh();
|
20
|
+
}
|
24
21
|
ngOnInit() {
|
25
22
|
super.ngOnInit();
|
26
23
|
this.content = this._mcEllipsisCenter;
|
@@ -68,7 +65,7 @@ class McEllipsisCenterDirective extends McTooltipTrigger {
|
|
68
65
|
this.renderer.appendChild(this.elementRef.nativeElement, dataTextStart);
|
69
66
|
this.renderer.appendChild(this.elementRef.nativeElement, dataTextEnd);
|
70
67
|
}
|
71
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McEllipsisCenterDirective, deps:
|
68
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McEllipsisCenterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
72
69
|
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.0", type: McEllipsisCenterDirective, selector: "[mcEllipsisCenter]", inputs: { mcEllipsisCenter: "mcEllipsisCenter", minVisibleLength: "minVisibleLength" }, host: { listeners: { "window:resize": "resizeStream.next($event)" }, classAttribute: "mc-ellipsis-center" }, usesInheritance: true, ngImport: i0 }); }
|
73
70
|
}
|
74
71
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McEllipsisCenterDirective, decorators: [{
|
@@ -80,12 +77,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
80
77
|
'(window:resize)': 'resizeStream.next($event)'
|
81
78
|
}
|
82
79
|
}]
|
83
|
-
}],
|
84
|
-
type: Inject,
|
85
|
-
args: [MC_TOOLTIP_SCROLL_STRATEGY]
|
86
|
-
}] }, { type: i2.Directionality, decorators: [{
|
87
|
-
type: Optional
|
88
|
-
}] }, { type: i3.FocusMonitor }, { type: i0.Renderer2 }], propDecorators: { mcEllipsisCenter: [{
|
80
|
+
}], propDecorators: { mcEllipsisCenter: [{
|
89
81
|
type: Input
|
90
82
|
}], minVisibleLength: [{
|
91
83
|
type: Input
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ptsecurity-mosaic-ellipsis-center.mjs","sources":["../../../packages/mosaic/ellipsis-center/ellipsis-center.directive.ts","../../../packages/mosaic/ellipsis-center/ptsecurity-mosaic-ellipsis-center.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"file":"ptsecurity-mosaic-ellipsis-center.mjs","sources":["../../../packages/mosaic/ellipsis-center/ellipsis-center.directive.ts","../../../packages/mosaic/ellipsis-center/ptsecurity-mosaic-ellipsis-center.ts"],"sourcesContent":["import {\n Directive,\n Input,\n OnInit,\n OnDestroy,\n Renderer2,\n AfterViewInit,\n NgModule,\n inject\n} from '@angular/core';\nimport { McTooltipTrigger } from '@ptsecurity/mosaic/tooltip';\nimport { Subject, Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\n\n\nconst MIN_VISIBLE_LENGTH = 50;\n\n@Directive({\n selector: '[mcEllipsisCenter]',\n host: {\n class: 'mc-ellipsis-center',\n '(window:resize)': 'resizeStream.next($event)'\n }\n})\nexport class McEllipsisCenterDirective extends McTooltipTrigger implements OnInit, AfterViewInit, OnDestroy {\n @Input() set mcEllipsisCenter(value: string) {\n this._mcEllipsisCenter = value;\n this.refresh();\n }\n @Input() minVisibleLength: number = MIN_VISIBLE_LENGTH;\n\n readonly resizeStream = new Subject<Event>();\n\n private renderer: Renderer2 = inject(Renderer2);\n\n private _mcEllipsisCenter: string;\n\n private resizeSubscription = Subscription.EMPTY;\n\n private readonly debounceInterval: number = 50;\n\n override ngOnInit(): void {\n super.ngOnInit();\n this.content = this._mcEllipsisCenter;\n this.refresh();\n }\n\n ngAfterViewInit(): void {\n this.resizeSubscription = this.resizeStream\n .pipe(debounceTime(this.debounceInterval))\n .subscribe(() => this.refresh());\n }\n\n ngOnDestroy() {\n super.ngOnDestroy();\n this.resizeSubscription.unsubscribe();\n }\n\n private refresh() {\n let start = '';\n let end = '';\n const dataTextStartLength = 0.75;\n this.content = this._mcEllipsisCenter;\n\n const [dataTextStart, dataTextEnd] = ['data-text-start', 'data-text-end'].map((querySelector) => {\n const element = this.elementRef.nativeElement.querySelector(`.${querySelector}`);\n if (element) {\n this.renderer.removeChild(this.elementRef.nativeElement, element);\n }\n const newElement = this.renderer.createElement('span');\n this.renderer.addClass(newElement, querySelector);\n\n return newElement;\n });\n\n this.renderer.appendChild(dataTextStart, this.renderer.createText(this._mcEllipsisCenter));\n this.renderer.appendChild(dataTextEnd, this.renderer.createText(end));\n setTimeout(() => {\n this.disabled = this.elementRef.nativeElement.clientWidth > dataTextStart.scrollWidth;\n if (this.disabled) {\n start = '';\n end = this._mcEllipsisCenter;\n } else {\n const sliceIndex: number = Math.round(this._mcEllipsisCenter.length * dataTextStartLength);\n\n start = this._mcEllipsisCenter.slice(0, sliceIndex);\n end = this._mcEllipsisCenter.slice(sliceIndex);\n }\n dataTextStart.innerText = start;\n dataTextEnd.innerText = end;\n });\n\n this.renderer.appendChild(this.elementRef.nativeElement, dataTextStart);\n this.renderer.appendChild(this.elementRef.nativeElement, dataTextEnd);\n }\n}\n\n@NgModule({\n imports: [],\n exports: [McEllipsisCenterDirective],\n declarations: [McEllipsisCenterDirective]\n})\nexport class McEllipsisCenterModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAeA,MAAM,kBAAkB,GAAG,EAAE,CAAC;AASxB,MAAO,yBAA0B,SAAQ,gBAAgB,CAAA;AAP/D,IAAA,WAAA,GAAA;;QAYa,IAAgB,CAAA,gBAAA,GAAW,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AAsB,EAAA,YAAA,EAAA,CA9EtB,yBAAyB,CAAA,EAAA,OAAA,EAAA,CAAzB,yBAAyB,CAAA,EAAA,CAAA,CAAA,EAAA;kIA8EzB,sBAAsB,EAAA,CAAA,CAAA,EAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBALlC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC,yBAAyB,CAAC;oBACpC,YAAY,EAAE,CAAC,yBAAyB,CAAC;AAC5C,iBAAA,CAAA;;;ACrGD;;AAEG;;;;"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import * as i3$1 from '@angular/cdk/a11y';
|
2
1
|
import { A11yModule } from '@angular/cdk/a11y';
|
3
2
|
import { CommonModule } from '@angular/common';
|
4
3
|
import * as i0 from '@angular/core';
|
@@ -6,21 +5,21 @@ import { forwardRef, EventEmitter, Directive, Attribute, Optional, Inject, Input
|
|
6
5
|
import * as i1 from '@angular/forms';
|
7
6
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators, FormsModule } from '@angular/forms';
|
8
7
|
import * as i3 from '@ptsecurity/mosaic/core';
|
9
|
-
import { MC_LOCALE_SERVICE, mixinErrorState, PopUpTriggers, McCommonModule } from '@ptsecurity/mosaic/core';
|
8
|
+
import { ruRULocaleData, checkAndNormalizeLocalizedNumber, normalizeNumber, MC_LOCALE_SERVICE, mixinErrorState, PopUpTriggers, McCommonModule } from '@ptsecurity/mosaic/core';
|
10
9
|
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
11
10
|
import { getSupportedInputTypes } from '@angular/cdk/platform';
|
12
|
-
import * as
|
11
|
+
import * as i1$1 from '@ptsecurity/mosaic/form-field';
|
13
12
|
import { McFormFieldControl } from '@ptsecurity/mosaic/form-field';
|
14
|
-
import { Subject
|
13
|
+
import { Subject } from 'rxjs';
|
14
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
15
15
|
import { A, C, V, X, Z, NUMPAD_MINUS, DASH, FF_MINUS, DELETE, BACKSPACE, TAB, ESCAPE, ENTER, LEFT_ARROW, RIGHT_ARROW, HOME, END, isFunctionKey, isNumberKey, isNumpadKey, UP_ARROW, DOWN_ARROW } from '@ptsecurity/cdk/keycodes';
|
16
|
-
import
|
17
|
-
import * as i1$1 from '@angular/cdk/overlay';
|
18
|
-
import { McTooltipTrigger, MC_TOOLTIP_SCROLL_STRATEGY } from '@ptsecurity/mosaic/tooltip';
|
16
|
+
import { McTooltipTrigger } from '@ptsecurity/mosaic/tooltip';
|
19
17
|
|
20
18
|
function getMcInputUnsupportedTypeError(inputType) {
|
21
19
|
return Error(`Input type "${inputType}" isn't supported by mcInput.`);
|
22
20
|
}
|
23
21
|
|
22
|
+
const MC_INPUT_NUMBER_DEFAULT_CONFIGURATION = ruRULocaleData['ru-RU'].input.number;
|
24
23
|
const BIG_STEP = 10;
|
25
24
|
const SMALL_STEP = 1;
|
26
25
|
// TODO: подставлять локализованный сплиттер
|
@@ -103,20 +102,18 @@ class McNumberInput {
|
|
103
102
|
this.withThousandSeparator = true;
|
104
103
|
this._disabled = false;
|
105
104
|
this.focused = false;
|
106
|
-
this.localeSubscription = Subscription.EMPTY;
|
107
105
|
// tslint:disable-next-line:no-empty
|
108
106
|
this.onTouched = () => { };
|
109
107
|
// tslint:disable-next-line:no-empty
|
110
108
|
this.cvaOnChange = () => { };
|
111
|
-
this.updateLocaleParams = (
|
112
|
-
this.
|
109
|
+
this.updateLocaleParams = () => {
|
110
|
+
this.config = this.localeService.getParams('input').number;
|
113
111
|
this.setViewValue(this.formatNumber(this.value));
|
114
112
|
};
|
115
113
|
this.step = isDigit(step) ? parseFloat(step) : SMALL_STEP;
|
116
114
|
this.bigStep = isDigit(bigStep) ? parseFloat(bigStep) : BIG_STEP;
|
117
115
|
this.min = isDigit(min) ? parseFloat(min) : -Infinity;
|
118
116
|
this.max = isDigit(max) ? parseFloat(max) : Infinity;
|
119
|
-
setTimeout(() => this.nativeElement.type = 'text', 0);
|
120
117
|
if ('valueAsNumber' in this.nativeElement) {
|
121
118
|
/* переделать алгоритм */
|
122
119
|
Object.defineProperty(Object.getPrototypeOf(this.nativeElement), 'valueAsNumber', {
|
@@ -127,14 +124,12 @@ class McNumberInput {
|
|
127
124
|
}
|
128
125
|
});
|
129
126
|
}
|
130
|
-
this.
|
131
|
-
|
132
|
-
|
133
|
-
}
|
134
|
-
this.localeSubscription = this.localeService.changes.subscribe(this.updateLocaleParams);
|
127
|
+
this.localeService?.changes.pipe(takeUntilDestroyed()).subscribe(this.updateLocaleParams);
|
128
|
+
if (!localeService) {
|
129
|
+
this.initDefaultParams();
|
130
|
+
}
|
135
131
|
}
|
136
132
|
ngOnDestroy() {
|
137
|
-
this.localeSubscription.unsubscribe();
|
138
133
|
this.valueChange.complete();
|
139
134
|
this.disabledChange.complete();
|
140
135
|
}
|
@@ -174,8 +169,8 @@ class McNumberInput {
|
|
174
169
|
const isCtrlV = (e) => e.keyCode === V && (e.ctrlKey || e.metaKey);
|
175
170
|
const isCtrlX = (e) => e.keyCode === X && (e.ctrlKey || e.metaKey);
|
176
171
|
const isCtrlZ = (e) => e.keyCode === Z && (e.ctrlKey || e.metaKey);
|
177
|
-
const isPeriod = (e) => this.
|
178
|
-
|| [this.
|
172
|
+
const isPeriod = (e) => this.config.groupSeparator.includes(e.key)
|
173
|
+
|| [this.config.fractionSeparator, '.'].includes(e.key);
|
179
174
|
const minuses = [NUMPAD_MINUS, DASH, FF_MINUS];
|
180
175
|
const serviceKeys = [DELETE, BACKSPACE, TAB, ESCAPE, ENTER];
|
181
176
|
const arrows = [LEFT_ARROW, RIGHT_ARROW];
|
@@ -186,8 +181,8 @@ class McNumberInput {
|
|
186
181
|
return;
|
187
182
|
}
|
188
183
|
if (isPeriod(event)) {
|
189
|
-
if (event.key === this.
|
190
|
-
this.viewValue.indexOf(this.
|
184
|
+
if (event.key === this.config.fractionSeparator &&
|
185
|
+
this.viewValue.indexOf(this.config.fractionSeparator) !== -1) {
|
191
186
|
event.preventDefault();
|
192
187
|
return;
|
193
188
|
}
|
@@ -243,7 +238,7 @@ class McNumberInput {
|
|
243
238
|
});
|
244
239
|
}
|
245
240
|
onPaste(event) {
|
246
|
-
this.valueFromPaste =
|
241
|
+
this.valueFromPaste = checkAndNormalizeLocalizedNumber(event.clipboardData?.getData('text'));
|
247
242
|
if (this.valueFromPaste === null) {
|
248
243
|
event.preventDefault();
|
249
244
|
}
|
@@ -264,6 +259,9 @@ class McNumberInput {
|
|
264
259
|
this.cvaOnChange(res);
|
265
260
|
this.valueChange.emit(res);
|
266
261
|
}
|
262
|
+
initDefaultParams() {
|
263
|
+
this.config = MC_INPUT_NUMBER_DEFAULT_CONFIGURATION;
|
264
|
+
}
|
267
265
|
setViewValue(value, savePosition = false) {
|
268
266
|
const cursorPosition = this.nativeElement.selectionStart;
|
269
267
|
this.renderer.setProperty(this.nativeElement, 'value', value);
|
@@ -273,7 +271,7 @@ class McNumberInput {
|
|
273
271
|
}
|
274
272
|
}
|
275
273
|
viewToModelUpdate(newValue) {
|
276
|
-
const normalizedValue = newValue === null ? null : +
|
274
|
+
const normalizedValue = newValue === null ? null : +normalizeNumber(newValue, this.config);
|
277
275
|
if (normalizedValue !== this.value) {
|
278
276
|
this._value = normalizedValue;
|
279
277
|
this.cvaOnChange(normalizedValue);
|
@@ -282,15 +280,15 @@ class McNumberInput {
|
|
282
280
|
this.ngControl?.updateValueAndValidity({ emitEvent: false });
|
283
281
|
}
|
284
282
|
formatViewValue() {
|
285
|
-
if (this.viewValue === null || this.viewValue === '' || Number.isNaN(+
|
283
|
+
if (this.viewValue === null || this.viewValue === '' || Number.isNaN(+normalizeNumber(this.viewValue, this.config))) {
|
286
284
|
return null;
|
287
285
|
}
|
288
|
-
const separator = this.
|
289
|
-
&& this.
|
286
|
+
const separator = this.config.groupSeparator.includes(' ')
|
287
|
+
&& this.config.fractionSeparator === ','
|
290
288
|
? /[,.]/
|
291
|
-
: this.
|
289
|
+
: this.config.fractionSeparator;
|
292
290
|
const [intPart, fractionPart] = this.viewValue.split(separator)
|
293
|
-
.map((valuePart) =>
|
291
|
+
.map((valuePart) => normalizeNumber(valuePart, this.config));
|
294
292
|
return this.createLocalizedNumberFromParts(+intPart, fractionPart);
|
295
293
|
}
|
296
294
|
formatNumber(value) {
|
@@ -305,47 +303,18 @@ class McNumberInput {
|
|
305
303
|
useGrouping: this.withThousandSeparator,
|
306
304
|
maximumFractionDigits: 20
|
307
305
|
};
|
308
|
-
if (this.withThousandSeparator && this.
|
306
|
+
if (this.withThousandSeparator && this.config.startFormattingFrom) {
|
309
307
|
formatOptions.useGrouping = intPart >= Math.pow(
|
310
308
|
// tslint:disable-next-line:no-magic-numbers
|
311
|
-
10, this.
|
309
|
+
10, this.config.startFormattingFrom);
|
312
310
|
}
|
313
|
-
const localeId = this.localeService.id === 'es-LA' ? 'ru-RU' : this.localeService.id;
|
311
|
+
const localeId = !this.localeService || this.localeService?.id === 'es-LA' ? 'ru-RU' : this.localeService.id;
|
314
312
|
const formatter = new Intl.NumberFormat(localeId, formatOptions);
|
315
313
|
const formattedFractionPart = fractionPart?.split('')
|
316
314
|
.map((numChar) => formatter.format(+numChar)).join('');
|
317
315
|
return formattedFractionPart === undefined
|
318
316
|
? formatter.format(intPart)
|
319
|
-
: `${formatter.format(intPart)}${this.
|
320
|
-
}
|
321
|
-
/**
|
322
|
-
* Method that returns a string representation of a number without localized separators
|
323
|
-
*/
|
324
|
-
normalizeNumber(value, customConfig) {
|
325
|
-
if (value === null || value === undefined) {
|
326
|
-
return '';
|
327
|
-
}
|
328
|
-
const { groupSeparator, fractionSeparator } = customConfig || this.numberLocaleConfig;
|
329
|
-
const groupSeparatorRegexp = new RegExp(`[${groupSeparator.join('')}]`, 'g');
|
330
|
-
const fractionSeparatorRegexp = new RegExp(`\\${fractionSeparator}`, 'g');
|
331
|
-
return value.toString()
|
332
|
-
.replace(groupSeparatorRegexp, '')
|
333
|
-
.replace(fractionSeparatorRegexp, '.');
|
334
|
-
}
|
335
|
-
checkAndNormalizeLocalizedNumber(num) {
|
336
|
-
if (num === null || num === undefined) {
|
337
|
-
return null;
|
338
|
-
}
|
339
|
-
/* if some locale input config satisfies pasted number, try to normalise with selected locale config */
|
340
|
-
let numberOutput = null;
|
341
|
-
for (const { config } of this.allNumberLocaleConfigs) {
|
342
|
-
const normalized = +this.normalizeNumber(num, config);
|
343
|
-
if (!Number.isNaN(normalized)) {
|
344
|
-
numberOutput = normalized;
|
345
|
-
break;
|
346
|
-
}
|
347
|
-
}
|
348
|
-
return numberOutput;
|
317
|
+
: `${formatter.format(intPart)}${this.config.fractionSeparator}${formattedFractionPart}`;
|
349
318
|
}
|
350
319
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McNumberInput, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: 'step', attribute: true }, { token: 'big-step', attribute: true }, { token: 'min', attribute: true }, { token: 'max', attribute: true }, { token: MC_LOCALE_SERVICE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
351
320
|
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.0", type: McNumberInput, selector: "input[mcNumberInput]", inputs: { bigStep: "bigStep", step: "step", min: "min", max: "max", withThousandSeparator: "withThousandSeparator", startFormattingFrom: "startFormattingFrom", value: "value", disabled: "disabled" }, host: { listeners: { "blur": "focusChanged(false)", "focus": "focusChanged(true)", "paste": "onPaste($event)", "keydown": "onKeyDown($event)", "input": "onInput($event)" } }, providers: [MC_NUMBER_INPUT_VALUE_ACCESSOR], exportAs: ["mcNumericalInput"], ngImport: i0 }); }
|
@@ -800,8 +769,8 @@ class McPasswordToggle extends McTooltipTrigger {
|
|
800
769
|
get visibility() {
|
801
770
|
return this.disabled && this.formField.control.empty ? 'hidden' : 'visible';
|
802
771
|
}
|
803
|
-
constructor(
|
804
|
-
super(
|
772
|
+
constructor(formField) {
|
773
|
+
super();
|
805
774
|
this.formField = formField;
|
806
775
|
this._tabIndex = 0;
|
807
776
|
this.trigger = `${PopUpTriggers.Hover}`;
|
@@ -833,7 +802,7 @@ class McPasswordToggle extends McTooltipTrigger {
|
|
833
802
|
stopFocusMonitor() {
|
834
803
|
this.focusMonitor.stopMonitoring(this.elementRef);
|
835
804
|
}
|
836
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McPasswordToggle, deps: [{ token: i1$1.
|
805
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McPasswordToggle, deps: [{ token: i1$1.McFormField }], target: i0.ɵɵFactoryTarget.Component }); }
|
837
806
|
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: McPasswordToggle, selector: "mc-password-toggle", inputs: { content: ["mcTooltipNotHidden", "content"], mcTooltipHidden: "mcTooltipHidden", disabled: "disabled", tabIndex: "tabIndex" }, host: { listeners: { "click": "toggle()", "keydown.ENTER": "toggle()", "keydown.SPACE": "toggle()" }, properties: { "class.mc-eye_16": "hidden", "class.mc-eye-crossed_16": "!hidden", "style.visibility": "visibility", "attr.tabindex": "disabled ? null : tabIndex", "attr.disabled": "disabled || null" }, classAttribute: "mc-password-toggle mc" }, exportAs: ["mcPasswordToggle"], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
838
807
|
}
|
839
808
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: McPasswordToggle, decorators: [{
|
@@ -856,12 +825,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
856
825
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
857
826
|
encapsulation: ViewEncapsulation.None
|
858
827
|
}]
|
859
|
-
}], ctorParameters: () => [{ type: i1$1.
|
860
|
-
type: Inject,
|
861
|
-
args: [MC_TOOLTIP_SCROLL_STRATEGY]
|
862
|
-
}] }, { type: i2.Directionality, decorators: [{
|
863
|
-
type: Optional
|
864
|
-
}] }, { type: i3$1.FocusMonitor }, { type: i4.McFormField }], propDecorators: { content: [{
|
828
|
+
}], ctorParameters: () => [{ type: i1$1.McFormField }], propDecorators: { content: [{
|
865
829
|
type: Input,
|
866
830
|
args: ['mcTooltipNotHidden']
|
867
831
|
}], mcTooltipHidden: [{
|
@@ -1149,5 +1113,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
|
|
1149
1113
|
* Generated bundle index. Do not edit.
|
1150
1114
|
*/
|
1151
1115
|
|
1152
|
-
export { BIG_STEP, MAX_VALIDATOR, MC_INPUT_VALUE_ACCESSOR, MC_NUMBER_INPUT_VALUE_ACCESSOR, MIN_VALIDATOR, MaxValidator, McInput, McInputBase, McInputMixinBase, McInputModule, McInputMono, McInputPassword, McNumberInput, McPasswordToggle, MinValidator, SMALL_STEP, add, getPrecision, isDigit, isFloat, isInt, normalizeSplitter };
|
1116
|
+
export { BIG_STEP, MAX_VALIDATOR, MC_INPUT_NUMBER_DEFAULT_CONFIGURATION, MC_INPUT_VALUE_ACCESSOR, MC_NUMBER_INPUT_VALUE_ACCESSOR, MIN_VALIDATOR, MaxValidator, McInput, McInputBase, McInputMixinBase, McInputModule, McInputMono, McInputPassword, McNumberInput, McPasswordToggle, MinValidator, SMALL_STEP, add, getPrecision, isDigit, isFloat, isInt, normalizeSplitter };
|
1153
1117
|
//# sourceMappingURL=ptsecurity-mosaic-input.mjs.map
|