mapa-library-ui 1.0.1 → 1.1.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.
- package/fesm2022/mapa-library-ui-src-lib-components-benchmarking.mjs +6 -6
- package/fesm2022/mapa-library-ui-src-lib-components-breadcrumb.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-button-icon.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-button.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-capability.mjs +81 -73
- package/fesm2022/mapa-library-ui-src-lib-components-capability.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-chart.mjs +32 -24
- package/fesm2022/mapa-library-ui-src-lib-components-chart.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-checkbox.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker-range.mjs +394 -0
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker-range.mjs.map +1 -0
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker.mjs +215 -117
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-dialog.mjs +15 -15
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown-tree.mjs +34 -24
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown-tree.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown.mjs +31 -21
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-empty.mjs +13 -9
- package/fesm2022/mapa-library-ui-src-lib-components-empty.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-filters.mjs +44 -36
- package/fesm2022/mapa-library-ui-src-lib-components-filters.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-form.mjs +402 -49
- package/fesm2022/mapa-library-ui-src-lib-components-form.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-group-report.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-icon.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-input.mjs +26 -18
- package/fesm2022/mapa-library-ui-src-lib-components-input.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-menu.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-nav-list.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-radio-button.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-report-item.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-scale-parameterization.mjs +79 -71
- package/fesm2022/mapa-library-ui-src-lib-components-scale-parameterization.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-scale.mjs +76 -68
- package/fesm2022/mapa-library-ui-src-lib-components-scale.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-slide-toggle.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-svg-icon.mjs +9 -9
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs +78 -23
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-tag.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-components-textarea.mjs +20 -12
- package/fesm2022/mapa-library-ui-src-lib-components-textarea.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-tooltip.mjs +6 -6
- package/fesm2022/mapa-library-ui-src-lib-components-warning.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-core-guards-authorize-guard.mjs +3 -3
- package/fesm2022/mapa-library-ui-src-lib-core-services.mjs +3 -3
- package/fesm2022/mapa-library-ui.mjs +425 -199
- package/fesm2022/mapa-library-ui.mjs.map +1 -1
- package/index.d.ts +101 -22
- package/mapa-library-ui-1.1.0.tgz +0 -0
- package/package.json +9 -1
- package/src/lib/components/capability/index.d.ts +8 -0
- package/src/lib/components/chart/index.d.ts +4 -0
- package/src/lib/components/datepicker/index.d.ts +136 -99
- package/src/lib/components/datepicker-range/index.d.ts +255 -0
- package/src/lib/components/dropdown/index.d.ts +8 -0
- package/src/lib/components/dropdown-tree/index.d.ts +4 -0
- package/src/lib/components/empty/index.d.ts +2 -2
- package/src/lib/components/filters/index.d.ts +8 -0
- package/src/lib/components/form/index.d.ts +4 -0
- package/src/lib/components/input/index.d.ts +4 -0
- package/src/lib/components/radio-button/index.d.ts +4 -0
- package/src/lib/components/scale/index.d.ts +4 -0
- package/src/lib/components/scale-parameterization/index.d.ts +4 -0
- package/src/lib/components/slide-toggle/index.d.ts +4 -0
- package/src/lib/components/table/index.d.ts +22 -2
- package/src/lib/components/textarea/index.d.ts +4 -0
- package/mapa-library-ui-1.0.1.tgz +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import * as i2 from '@angular/common';
|
|
1
2
|
import { CommonModule } from '@angular/common';
|
|
2
3
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, inject, Injector, signal, Optional, Inject, Injectable,
|
|
4
|
+
import { InjectionToken, inject, Injector, signal, Optional, Inject, Injectable, Input, Component, DestroyRef, ChangeDetectionStrategy } from '@angular/core';
|
|
4
5
|
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import * as i2$1 from '@angular/forms';
|
|
7
|
+
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
5
8
|
import { provideNativeDateAdapter } from '@angular/material/core';
|
|
6
9
|
import * as i3 from '@angular/material/datepicker';
|
|
7
10
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
@@ -11,64 +14,8 @@ import * as i5 from '@angular/material/icon';
|
|
|
11
14
|
import { MatIconModule } from '@angular/material/icon';
|
|
12
15
|
import * as i6 from '@angular/material/input';
|
|
13
16
|
import { MatInputModule } from '@angular/material/input';
|
|
14
|
-
import * as i2 from '@angular/forms';
|
|
15
|
-
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
16
17
|
import { NgxMaskDirective, provideNgxMask } from 'ngx-mask';
|
|
17
18
|
|
|
18
|
-
const DAY_MONTH_YEAR_PATTERN = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
19
|
-
function isValidDate(date) {
|
|
20
|
-
return !Number.isNaN(date.getTime());
|
|
21
|
-
}
|
|
22
|
-
function formatDateAsDayMonthYear(date) {
|
|
23
|
-
const day = `${date.getDate()}`.padStart(2, "0");
|
|
24
|
-
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
25
|
-
const year = `${date.getFullYear()}`;
|
|
26
|
-
return `${day}/${month}/${year}`;
|
|
27
|
-
}
|
|
28
|
-
function parseDateValue(value) {
|
|
29
|
-
if (value instanceof Date) {
|
|
30
|
-
return isValidDate(value) ? new Date(value.getTime()) : null;
|
|
31
|
-
}
|
|
32
|
-
if (typeof value === "number") {
|
|
33
|
-
const parsedDate = new Date(value);
|
|
34
|
-
return isValidDate(parsedDate) ? parsedDate : null;
|
|
35
|
-
}
|
|
36
|
-
if (typeof value !== "string") {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const trimmedValue = value.trim();
|
|
40
|
-
if (!trimmedValue) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const dayMonthYearMatch = DAY_MONTH_YEAR_PATTERN.exec(trimmedValue);
|
|
44
|
-
if (dayMonthYearMatch) {
|
|
45
|
-
const [, dayValue, monthValue, yearValue] = dayMonthYearMatch;
|
|
46
|
-
const day = Number(dayValue);
|
|
47
|
-
const month = Number(monthValue);
|
|
48
|
-
const year = Number(yearValue);
|
|
49
|
-
const parsedDate = new Date(year, month - 1, day);
|
|
50
|
-
if (parsedDate.getFullYear() === year &&
|
|
51
|
-
parsedDate.getMonth() === month - 1 &&
|
|
52
|
-
parsedDate.getDate() === day) {
|
|
53
|
-
return parsedDate;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
const parsedDate = new Date(trimmedValue);
|
|
58
|
-
return isValidDate(parsedDate) ? parsedDate : null;
|
|
59
|
-
}
|
|
60
|
-
function isDateValue(value) {
|
|
61
|
-
return parseDateValue(value) !== null;
|
|
62
|
-
}
|
|
63
|
-
function getRelativeDateRange(daysBack) {
|
|
64
|
-
const endDate = new Date();
|
|
65
|
-
endDate.setHours(23, 59, 59, 999);
|
|
66
|
-
const startDate = new Date();
|
|
67
|
-
startDate.setHours(0, 0, 0, 0);
|
|
68
|
-
startDate.setDate(startDate.getDate() - daysBack);
|
|
69
|
-
return { startDate, endDate };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
19
|
const MAPA_UI_TEXTS = new InjectionToken("MAPA_UI_TEXTS");
|
|
73
20
|
const MAPA_UI_DEFAULT_TEXTS = {
|
|
74
21
|
common: {
|
|
@@ -121,6 +68,10 @@ const MAPA_UI_DEFAULT_TEXTS = {
|
|
|
121
68
|
return `Mostrando ${startIndex + 1} - ${endIndex} de ${length} ${itemLabel}`;
|
|
122
69
|
},
|
|
123
70
|
},
|
|
71
|
+
table: {
|
|
72
|
+
emptyTitle: "Nao foram encontrados resultados",
|
|
73
|
+
emptySubtitle: "",
|
|
74
|
+
},
|
|
124
75
|
validation: {
|
|
125
76
|
cnpj: "CNPJ inválido",
|
|
126
77
|
cpf: "CPF inválido",
|
|
@@ -155,6 +106,10 @@ function mergeMapaUiTexts(customTexts) {
|
|
|
155
106
|
...MAPA_UI_DEFAULT_TEXTS.paginator,
|
|
156
107
|
...(customTexts?.paginator ?? {}),
|
|
157
108
|
},
|
|
109
|
+
table: {
|
|
110
|
+
...MAPA_UI_DEFAULT_TEXTS.table,
|
|
111
|
+
...(customTexts?.table ?? {}),
|
|
112
|
+
},
|
|
158
113
|
validation: {
|
|
159
114
|
...MAPA_UI_DEFAULT_TEXTS.validation,
|
|
160
115
|
...(customTexts?.validation ?? {}),
|
|
@@ -190,10 +145,10 @@ class MapaI18nService {
|
|
|
190
145
|
resolveText(value, context) {
|
|
191
146
|
return typeof value === "function" ? value(context) : value;
|
|
192
147
|
}
|
|
193
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
194
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.
|
|
148
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaI18nService, deps: [{ token: MAPA_UI_TEXTS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
149
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaI18nService, providedIn: "root" }); }
|
|
195
150
|
}
|
|
196
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaI18nService, decorators: [{
|
|
197
152
|
type: Injectable,
|
|
198
153
|
args: [{
|
|
199
154
|
providedIn: "root",
|
|
@@ -205,7 +160,149 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
205
160
|
args: [MAPA_UI_TEXTS]
|
|
206
161
|
}] }] });
|
|
207
162
|
|
|
208
|
-
|
|
163
|
+
class ValidationMessageResolverService {
|
|
164
|
+
constructor(i18n) {
|
|
165
|
+
this.i18n = i18n;
|
|
166
|
+
this.errorOrder = [
|
|
167
|
+
"required",
|
|
168
|
+
"minlength",
|
|
169
|
+
"maxlength",
|
|
170
|
+
"cpf",
|
|
171
|
+
"cnpj",
|
|
172
|
+
"email",
|
|
173
|
+
"pattern",
|
|
174
|
+
"min",
|
|
175
|
+
"max",
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
resolveFirstError(control, errors) {
|
|
179
|
+
const validationErrors = control?.errors;
|
|
180
|
+
if (!validationErrors) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const firstErrorKey = this.errorOrder.find((key) => control?.hasError(key));
|
|
184
|
+
if (!firstErrorKey) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return this.resolveErrorMessage(firstErrorKey, validationErrors, errors);
|
|
188
|
+
}
|
|
189
|
+
resolveErrorMessage(errorKey, validationErrors, errors) {
|
|
190
|
+
const errorOverrides = errors;
|
|
191
|
+
const customMessage = this.getCustomMessage(errorKey, errorOverrides);
|
|
192
|
+
if (customMessage) {
|
|
193
|
+
return customMessage;
|
|
194
|
+
}
|
|
195
|
+
const errorValue = validationErrors[errorKey];
|
|
196
|
+
switch (errorKey) {
|
|
197
|
+
case "minlength":
|
|
198
|
+
return this.i18n.resolveValidationText("minLength", errorValue);
|
|
199
|
+
case "maxlength":
|
|
200
|
+
return this.i18n.resolveValidationText("maxLength", errorValue);
|
|
201
|
+
case "min":
|
|
202
|
+
return this.i18n.resolveValidationText("min", errorValue);
|
|
203
|
+
case "max":
|
|
204
|
+
return this.i18n.resolveValidationText("max", errorValue);
|
|
205
|
+
default:
|
|
206
|
+
return this.i18n.resolveValidationText(errorKey);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
getCustomMessage(errorKey, errors) {
|
|
210
|
+
if (!errors) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
switch (errorKey) {
|
|
214
|
+
case "minlength":
|
|
215
|
+
return errors.minLength ?? errors.minlength;
|
|
216
|
+
case "maxlength":
|
|
217
|
+
return errors.maxLength ?? errors.maxlength;
|
|
218
|
+
default:
|
|
219
|
+
return errors[errorKey];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: ValidationMessageResolverService, deps: [{ token: MapaI18nService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
223
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: ValidationMessageResolverService, providedIn: "root" }); }
|
|
224
|
+
}
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: ValidationMessageResolverService, decorators: [{
|
|
226
|
+
type: Injectable,
|
|
227
|
+
args: [{
|
|
228
|
+
providedIn: "root",
|
|
229
|
+
}]
|
|
230
|
+
}], ctorParameters: () => [{ type: MapaI18nService }] });
|
|
231
|
+
|
|
232
|
+
class MapaFormErrorsComponent {
|
|
233
|
+
constructor(validationMessageResolver) {
|
|
234
|
+
this.validationMessageResolver = validationMessageResolver;
|
|
235
|
+
}
|
|
236
|
+
get message() {
|
|
237
|
+
return this.validationMessageResolver.resolveFirstError(this.control, this.errors);
|
|
238
|
+
}
|
|
239
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaFormErrorsComponent, deps: [{ token: ValidationMessageResolverService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
240
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: MapaFormErrorsComponent, isStandalone: true, selector: "mapa-form-errors", inputs: { control: "control", errors: "errors" }, ngImport: i0, template: "<span *ngIf=\"message\">\n {{ message }}\n</span>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatFormFieldModule }] }); }
|
|
241
|
+
}
|
|
242
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaFormErrorsComponent, decorators: [{
|
|
243
|
+
type: Component,
|
|
244
|
+
args: [{ selector: "mapa-form-errors", imports: [CommonModule, MatFormFieldModule], template: "<span *ngIf=\"message\">\n {{ message }}\n</span>\n" }]
|
|
245
|
+
}], ctorParameters: () => [{ type: ValidationMessageResolverService }], propDecorators: { control: [{
|
|
246
|
+
type: Input
|
|
247
|
+
}], errors: [{
|
|
248
|
+
type: Input
|
|
249
|
+
}] } });
|
|
250
|
+
|
|
251
|
+
const DAY_MONTH_YEAR_PATTERN = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
252
|
+
function isValidDate(date) {
|
|
253
|
+
return !Number.isNaN(date.getTime());
|
|
254
|
+
}
|
|
255
|
+
function formatDateAsDayMonthYear(date) {
|
|
256
|
+
const day = `${date.getDate()}`.padStart(2, "0");
|
|
257
|
+
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
258
|
+
const year = `${date.getFullYear()}`;
|
|
259
|
+
return `${day}/${month}/${year}`;
|
|
260
|
+
}
|
|
261
|
+
function parseDateValue(value) {
|
|
262
|
+
if (value instanceof Date) {
|
|
263
|
+
return isValidDate(value) ? new Date(value.getTime()) : null;
|
|
264
|
+
}
|
|
265
|
+
if (typeof value === "number") {
|
|
266
|
+
const parsedDate = new Date(value);
|
|
267
|
+
return isValidDate(parsedDate) ? parsedDate : null;
|
|
268
|
+
}
|
|
269
|
+
if (typeof value !== "string") {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const trimmedValue = value.trim();
|
|
273
|
+
if (!trimmedValue) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
const dayMonthYearMatch = DAY_MONTH_YEAR_PATTERN.exec(trimmedValue);
|
|
277
|
+
if (dayMonthYearMatch) {
|
|
278
|
+
const [, dayValue, monthValue, yearValue] = dayMonthYearMatch;
|
|
279
|
+
const day = Number(dayValue);
|
|
280
|
+
const month = Number(monthValue);
|
|
281
|
+
const year = Number(yearValue);
|
|
282
|
+
const parsedDate = new Date(year, month - 1, day);
|
|
283
|
+
if (parsedDate.getFullYear() === year &&
|
|
284
|
+
parsedDate.getMonth() === month - 1 &&
|
|
285
|
+
parsedDate.getDate() === day) {
|
|
286
|
+
return parsedDate;
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const parsedDate = new Date(trimmedValue);
|
|
291
|
+
return isValidDate(parsedDate) ? parsedDate : null;
|
|
292
|
+
}
|
|
293
|
+
function isDateValue(value) {
|
|
294
|
+
return parseDateValue(value) !== null;
|
|
295
|
+
}
|
|
296
|
+
function getRelativeDateRange(daysBack) {
|
|
297
|
+
const endDate = new Date();
|
|
298
|
+
endDate.setHours(23, 59, 59, 999);
|
|
299
|
+
const startDate = new Date();
|
|
300
|
+
startDate.setHours(0, 0, 0, 0);
|
|
301
|
+
startDate.setDate(startDate.getDate() - daysBack);
|
|
302
|
+
return { startDate, endDate };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const MAPA_DATEPICKER_FORMATS = {
|
|
209
306
|
parse: {
|
|
210
307
|
dateInput: "DD/MM/YYYY",
|
|
211
308
|
},
|
|
@@ -216,68 +313,72 @@ const MY_DATE_FORMATS = {
|
|
|
216
313
|
monthYearA11yLabel: "MMMM YYYY",
|
|
217
314
|
},
|
|
218
315
|
};
|
|
219
|
-
class
|
|
220
|
-
constructor(
|
|
221
|
-
this.i18n = i18n;
|
|
316
|
+
class MapaDatepicker {
|
|
317
|
+
constructor(cdr) {
|
|
222
318
|
this.cdr = cdr;
|
|
223
319
|
this.destroyRef = inject(DestroyRef);
|
|
224
|
-
this.defaultDaysBack = 60;
|
|
225
320
|
this.formDatepicker = new FormGroup({
|
|
226
|
-
|
|
227
|
-
endDate: new FormControl(null),
|
|
321
|
+
date: new FormControl(null),
|
|
228
322
|
});
|
|
229
|
-
|
|
323
|
+
}
|
|
324
|
+
ngOnInit() {
|
|
325
|
+
this.formControl = this.formGroup.get(this.element.key);
|
|
326
|
+
this.syncDatepickerControl(this.formControl.value);
|
|
327
|
+
this.formControl.valueChanges
|
|
230
328
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
231
329
|
.subscribe((value) => {
|
|
232
|
-
this.
|
|
330
|
+
this.syncDatepickerControl(value);
|
|
233
331
|
});
|
|
234
|
-
|
|
235
|
-
get texts() {
|
|
236
|
-
return this.i18n.textsSignal();
|
|
237
|
-
}
|
|
238
|
-
ngOnInit() {
|
|
239
|
-
this.syncRangeForm(this.formGroup.getRawValue());
|
|
240
|
-
this.formGroup.valueChanges
|
|
332
|
+
this.formDatepicker.controls.date.valueChanges
|
|
241
333
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
242
334
|
.subscribe((value) => {
|
|
243
|
-
this.
|
|
335
|
+
this.updateExternalControl(value);
|
|
244
336
|
});
|
|
245
337
|
}
|
|
246
|
-
get
|
|
247
|
-
return this.
|
|
338
|
+
get minDate() {
|
|
339
|
+
return parseDateValue(this.element.minDate);
|
|
340
|
+
}
|
|
341
|
+
get maxDate() {
|
|
342
|
+
return parseDateValue(this.element.maxDate);
|
|
248
343
|
}
|
|
249
|
-
|
|
250
|
-
return this.
|
|
344
|
+
hasValue() {
|
|
345
|
+
return !!this.formControl?.value;
|
|
251
346
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
endDate: parseDateValue(value.endDate),
|
|
256
|
-
};
|
|
257
|
-
const currentValue = this.formDatepicker.getRawValue();
|
|
258
|
-
if (this.areDatesEqual(currentValue.startDate, nextRangeValue.startDate) &&
|
|
259
|
-
this.areDatesEqual(currentValue.endDate, nextRangeValue.endDate)) {
|
|
347
|
+
cleanDatepicker() {
|
|
348
|
+
this.formDatepicker.patchValue({ date: null }, { emitEvent: false });
|
|
349
|
+
if (this.formControl.value === "") {
|
|
260
350
|
return;
|
|
261
351
|
}
|
|
262
|
-
this.
|
|
352
|
+
this.formControl.patchValue("");
|
|
263
353
|
this.cdr.markForCheck();
|
|
264
354
|
}
|
|
265
|
-
|
|
266
|
-
|
|
355
|
+
syncDatepickerControl(value) {
|
|
356
|
+
const nextDate = parseDateValue(value);
|
|
357
|
+
const currentDate = this.formDatepicker.controls.date.value;
|
|
358
|
+
if (this.areDatesEqual(currentDate, nextDate)) {
|
|
267
359
|
return;
|
|
268
360
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
361
|
+
this.formDatepicker.patchValue({ date: nextDate }, { emitEvent: false });
|
|
362
|
+
this.cdr.markForCheck();
|
|
363
|
+
}
|
|
364
|
+
updateExternalControl(value) {
|
|
365
|
+
if (!value) {
|
|
366
|
+
if (this.formControl.value !== "") {
|
|
367
|
+
this.formControl.patchValue("");
|
|
368
|
+
this.cdr.markForCheck();
|
|
369
|
+
}
|
|
276
370
|
return;
|
|
277
371
|
}
|
|
278
|
-
|
|
372
|
+
const formattedDate = formatDateAsDayMonthYear(value);
|
|
373
|
+
if (this.formControl.value === formattedDate) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
this.formControl.patchValue(formattedDate);
|
|
279
377
|
this.cdr.markForCheck();
|
|
280
378
|
}
|
|
379
|
+
closePicker(picker) {
|
|
380
|
+
picker.close();
|
|
381
|
+
}
|
|
281
382
|
areDatesEqual(first, second) {
|
|
282
383
|
if (first === second) {
|
|
283
384
|
return true;
|
|
@@ -287,19 +388,13 @@ class DatepickerComponent {
|
|
|
287
388
|
}
|
|
288
389
|
return first.getTime() === second.getTime();
|
|
289
390
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.formDatepicker.patchValue(defaultRange, { emitEvent: false });
|
|
293
|
-
this.updateExternalForm(defaultRange);
|
|
294
|
-
this.cdr.markForCheck();
|
|
295
|
-
}
|
|
296
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DatepickerComponent, deps: [{ token: MapaI18nService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
297
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.18", type: DatepickerComponent, isStandalone: true, selector: "mapa-datepicker", inputs: { formGroup: "formGroup" }, providers: [
|
|
391
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaDatepicker, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
392
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.19", type: MapaDatepicker, isStandalone: true, selector: "mapa-datepicker", inputs: { formGroup: "formGroup", element: "element" }, providers: [
|
|
298
393
|
provideNgxMask(),
|
|
299
|
-
provideNativeDateAdapter(
|
|
300
|
-
], ngImport: i0, template: "
|
|
394
|
+
provideNativeDateAdapter(MAPA_DATEPICKER_FORMATS),
|
|
395
|
+
], ngImport: i0, template: "@if (element && formGroup) {\n <section class=\"mapa-datepicker\" [formGroup]=\"formGroup\">\n @if (element.label) {\n <label class=\"mapa-datepicker__label\">\n {{ element.label }}\n </label>\n }\n\n <section class=\"mapa-datepicker__field\" [formGroup]=\"formGroup\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <input\n matInput\n [formControlName]=\"element.key\"\n [placeholder]=\"element.placeholder || element.label || ''\"\n [mask]=\"element.mask\"\n [readonly]=\"element.readonly\"\n />\n <mat-icon *ngIf=\"hasValue()\" matSuffix (click)=\"cleanDatepicker()\">close</mat-icon>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker touchUi=\"true\" #picker></mat-datepicker>\n @if (element.hint) {\n <mat-hint>{{ element.hint }}</mat-hint>\n }\n <mat-error>\n <mapa-form-errors\n [control]=\"formControl\"\n [errors]=\"element.errors\"\n ></mapa-form-errors>\n </mat-error>\n </mat-form-field>\n </section>\n\n <section class=\"mapa-datepicker--hidden\">\n <mat-form-field [formGroup]=\"formDatepicker\">\n <input\n matInput\n formControlName=\"date\"\n [min]=\"minDate\"\n [max]=\"maxDate\"\n [matDatepicker]=\"picker\"\n (dateChange)=\"closePicker(picker)\"\n />\n </mat-form-field>\n </section>\n </section>\n}\n", styles: [":host{display:block;width:100%}:host ::ng-deep .mapa-datepicker{display:flex;flex-direction:column;gap:8px}:host ::ng-deep .mapa-datepicker__label{font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);display:block;font-size:12px;font-style:normal;font-weight:600;line-height:16px;text-transform:uppercase;margin-bottom:16px}:host ::ng-deep .mapa-datepicker .mdc-text-field{padding:0}:host ::ng-deep .mapa-datepicker__field .mat-mdc-form-field{width:100%;max-width:100%!important}:host ::ng-deep .mapa-datepicker__field .mat-mdc-form-field-subscript-wrapper{min-height:22px}:host ::ng-deep .mapa-datepicker--hidden{display:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime", "leadZero", "triggerOnMaskChange", "apm", "inputTransformFn", "outputTransformFn", "keepCharacterPositions", "instantPrefix"], outputs: ["maskFilled"], exportAs: ["mask", "ngxMask"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i3.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i3.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i3.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MapaFormErrorsComponent, selector: "mapa-form-errors", inputs: ["control", "errors"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
301
396
|
}
|
|
302
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
397
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: MapaDatepicker, decorators: [{
|
|
303
398
|
type: Component,
|
|
304
399
|
args: [{ selector: "mapa-datepicker", changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
305
400
|
CommonModule,
|
|
@@ -309,25 +404,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
|
|
|
309
404
|
MatFormFieldModule,
|
|
310
405
|
MatIconModule,
|
|
311
406
|
MatInputModule,
|
|
407
|
+
MapaFormErrorsComponent,
|
|
312
408
|
], providers: [
|
|
313
409
|
provideNgxMask(),
|
|
314
|
-
provideNativeDateAdapter(
|
|
315
|
-
], standalone: true, template: "
|
|
316
|
-
}], ctorParameters: () => [{ type:
|
|
410
|
+
provideNativeDateAdapter(MAPA_DATEPICKER_FORMATS),
|
|
411
|
+
], standalone: true, template: "@if (element && formGroup) {\n <section class=\"mapa-datepicker\" [formGroup]=\"formGroup\">\n @if (element.label) {\n <label class=\"mapa-datepicker__label\">\n {{ element.label }}\n </label>\n }\n\n <section class=\"mapa-datepicker__field\" [formGroup]=\"formGroup\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <input\n matInput\n [formControlName]=\"element.key\"\n [placeholder]=\"element.placeholder || element.label || ''\"\n [mask]=\"element.mask\"\n [readonly]=\"element.readonly\"\n />\n <mat-icon *ngIf=\"hasValue()\" matSuffix (click)=\"cleanDatepicker()\">close</mat-icon>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker touchUi=\"true\" #picker></mat-datepicker>\n @if (element.hint) {\n <mat-hint>{{ element.hint }}</mat-hint>\n }\n <mat-error>\n <mapa-form-errors\n [control]=\"formControl\"\n [errors]=\"element.errors\"\n ></mapa-form-errors>\n </mat-error>\n </mat-form-field>\n </section>\n\n <section class=\"mapa-datepicker--hidden\">\n <mat-form-field [formGroup]=\"formDatepicker\">\n <input\n matInput\n formControlName=\"date\"\n [min]=\"minDate\"\n [max]=\"maxDate\"\n [matDatepicker]=\"picker\"\n (dateChange)=\"closePicker(picker)\"\n />\n </mat-form-field>\n </section>\n </section>\n}\n", styles: [":host{display:block;width:100%}:host ::ng-deep .mapa-datepicker{display:flex;flex-direction:column;gap:8px}:host ::ng-deep .mapa-datepicker__label{font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);display:block;font-size:12px;font-style:normal;font-weight:600;line-height:16px;text-transform:uppercase;margin-bottom:16px}:host ::ng-deep .mapa-datepicker .mdc-text-field{padding:0}:host ::ng-deep .mapa-datepicker__field .mat-mdc-form-field{width:100%;max-width:100%!important}:host ::ng-deep .mapa-datepicker__field .mat-mdc-form-field-subscript-wrapper{min-height:22px}:host ::ng-deep .mapa-datepicker--hidden{display:none}\n"] }]
|
|
412
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { formGroup: [{
|
|
413
|
+
type: Input
|
|
414
|
+
}], element: [{
|
|
317
415
|
type: Input
|
|
318
416
|
}] } });
|
|
319
417
|
|
|
320
418
|
/*
|
|
321
|
-
* Public API Surface of mapa-library-ui datepicker
|
|
419
|
+
* Public API Surface of mapa-library-ui datepicker (single)
|
|
322
420
|
*/
|
|
323
421
|
|
|
324
422
|
/*
|
|
325
|
-
* Public API Surface of mapa-library-ui datepicker
|
|
423
|
+
* Public API Surface of mapa-library-ui datepicker (single)
|
|
326
424
|
*/
|
|
327
425
|
|
|
328
426
|
/**
|
|
329
427
|
* Generated bundle index. Do not edit.
|
|
330
428
|
*/
|
|
331
429
|
|
|
332
|
-
export {
|
|
430
|
+
export { MAPA_DATEPICKER_FORMATS, MapaDatepicker };
|
|
333
431
|
//# sourceMappingURL=mapa-library-ui-src-lib-components-datepicker.mjs.map
|