mapa-library-ui 1.5.3 → 1.6.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-dropdown-v2.mjs +159 -0
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown-v2.mjs.map +1 -0
- package/fesm2022/mapa-library-ui-src-lib-core-utils.mjs +7 -1
- package/fesm2022/mapa-library-ui-src-lib-core-utils.mjs.map +1 -1
- package/fesm2022/mapa-library-ui.mjs +106 -2
- package/fesm2022/mapa-library-ui.mjs.map +1 -1
- package/index.d.ts +29 -2
- package/mapa-library-ui-1.6.0.tgz +0 -0
- package/package.json +9 -1
- package/src/lib/components/dropdown-v2/index.d.ts +150 -0
- package/src/lib/core/utils/index.d.ts +5 -2
- package/mapa-library-ui-1.5.3.tgz +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, signal, HostListener, ViewChild, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
|
|
6
|
+
class ElementBase {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.value = options.value || "";
|
|
9
|
+
this.key = options.key || "";
|
|
10
|
+
this.label = options.label || "";
|
|
11
|
+
this.required = !!options.required;
|
|
12
|
+
this.order = options.order === undefined ? 1 : options.order;
|
|
13
|
+
this.controlType = options.controlType || "";
|
|
14
|
+
this.type = options.type || "";
|
|
15
|
+
this.placeholder = options.placeholder || "";
|
|
16
|
+
this.readonly = options.readonly || false;
|
|
17
|
+
this.hint = options.hint || "";
|
|
18
|
+
this.prefix = options.prefix || "";
|
|
19
|
+
this.suffix = options.suffix || "";
|
|
20
|
+
this.autosize = options.autosize || false;
|
|
21
|
+
this.autosizeMinWidth = options.autosizeMinWidth || "212px";
|
|
22
|
+
this.autosizeMaxWidth = options.autosizeMaxWidth || "400px";
|
|
23
|
+
this.autosizeMinRow = options.autosizeMinRow || 2;
|
|
24
|
+
this.autosizeMaxRow = options.autosizeMaxRow || 5;
|
|
25
|
+
this.options = options.options || [];
|
|
26
|
+
this.tree = options.tree || [];
|
|
27
|
+
this.multiple = options.multiple || false;
|
|
28
|
+
this.search = options.search || undefined;
|
|
29
|
+
this.maxLength = options.maxLength || null;
|
|
30
|
+
this.errors = options.errors || undefined;
|
|
31
|
+
this.actionButton = options.actionButton || undefined;
|
|
32
|
+
this.mask = options.mask || undefined;
|
|
33
|
+
this.autocomplete = options.autocomplete || "";
|
|
34
|
+
this.clearValue =
|
|
35
|
+
options.clearValue !== undefined ? options.clearValue : true;
|
|
36
|
+
this.minDate = options.minDate || undefined;
|
|
37
|
+
this.maxDate = options.maxDate || undefined;
|
|
38
|
+
this.status = options.status || undefined;
|
|
39
|
+
this.checkParent = options.checkParent || false;
|
|
40
|
+
this.checkChildren = options.checkChildren || false;
|
|
41
|
+
this.openedChange = options.openedChange || undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Dropdown extends ElementBase {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.controlType = 'dropdown';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class MapaDropdownV2Component {
|
|
53
|
+
constructor() {
|
|
54
|
+
this.hostElement = inject((ElementRef));
|
|
55
|
+
this.isOpenState = signal(false, ...(ngDevMode ? [{ debugName: "isOpenState" }] : []));
|
|
56
|
+
}
|
|
57
|
+
isOpen() {
|
|
58
|
+
return this.isOpenState();
|
|
59
|
+
}
|
|
60
|
+
selectedLabel() {
|
|
61
|
+
return this.formControl.value?.value || this.element.placeholder || "";
|
|
62
|
+
}
|
|
63
|
+
options() {
|
|
64
|
+
return this.element.options ?? [];
|
|
65
|
+
}
|
|
66
|
+
filteredOptions() {
|
|
67
|
+
const options = this.options();
|
|
68
|
+
const searchTerm = this.searchControl?.value?.trim().toLocaleLowerCase() ?? "";
|
|
69
|
+
if (!searchTerm) {
|
|
70
|
+
return options;
|
|
71
|
+
}
|
|
72
|
+
return options.filter((option) => option.value?.toLocaleLowerCase().includes(searchTerm));
|
|
73
|
+
}
|
|
74
|
+
hasSearch() {
|
|
75
|
+
return !!this.searchControl;
|
|
76
|
+
}
|
|
77
|
+
searchPlaceholder() {
|
|
78
|
+
return this.element.search?.placeholder ?? "";
|
|
79
|
+
}
|
|
80
|
+
shouldShowRequiredError() {
|
|
81
|
+
return (this.formControl.invalid &&
|
|
82
|
+
(this.formControl.dirty || this.formControl.touched));
|
|
83
|
+
}
|
|
84
|
+
toggleDropdown() {
|
|
85
|
+
const isOpening = !this.isOpenState();
|
|
86
|
+
this.isOpenState.set(isOpening);
|
|
87
|
+
if (isOpening) {
|
|
88
|
+
this.searchControl?.setValue("", { emitEvent: true });
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
this.triggerButton?.nativeElement.blur();
|
|
91
|
+
this.searchInput?.nativeElement.focus();
|
|
92
|
+
this.searchInput?.nativeElement.select();
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.markAsTouchedIfEmpty();
|
|
97
|
+
}
|
|
98
|
+
selectOption(option) {
|
|
99
|
+
this.formControl.setValue(option);
|
|
100
|
+
this.formControl.markAsDirty();
|
|
101
|
+
this.formControl.markAsTouched();
|
|
102
|
+
this.closeDropdown();
|
|
103
|
+
}
|
|
104
|
+
closeDropdown() {
|
|
105
|
+
this.isOpenState.set(false);
|
|
106
|
+
this.searchControl?.setValue("", { emitEvent: true });
|
|
107
|
+
this.markAsTouchedIfEmpty();
|
|
108
|
+
}
|
|
109
|
+
handleDocumentClick(event) {
|
|
110
|
+
if (this.isOpenState() &&
|
|
111
|
+
!this.hostElement.nativeElement.contains(event.target)) {
|
|
112
|
+
this.closeDropdown();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
get searchControl() {
|
|
116
|
+
return this.element.search?.formControl;
|
|
117
|
+
}
|
|
118
|
+
markAsTouchedIfEmpty() {
|
|
119
|
+
if (!this.formControl.value) {
|
|
120
|
+
this.formControl.markAsTouched();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaDropdownV2Component, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
124
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaDropdownV2Component, isStandalone: true, selector: "mapa-dropdown-v2", inputs: { element: "element", formControl: "formControl" }, host: { listeners: { "document:click": "handleDocumentClick($event)" } }, viewQueries: [{ propertyName: "triggerButton", first: true, predicate: ["triggerButton"], descendants: true }, { propertyName: "searchInput", first: true, predicate: ["searchInput"], descendants: true }], ngImport: i0, template: "<div\n class=\"mapa-dropdown-v2\"\n [class.mapa-dropdown-v2--open]=\"isOpen()\"\n [class.mapa-dropdown-v2--invalid]=\"shouldShowRequiredError()\"\n>\n @if (element.label) {\n <label class=\"mapa-dropdown-v2__label\" [attr.for]=\"element.key || null\">\n {{ element.label }}\n </label>\n }\n\n <button\n #triggerButton\n class=\"mapa-dropdown-v2__trigger\"\n [id]=\"element.key || null\"\n type=\"button\"\n (click)=\"toggleDropdown()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-haspopup]=\"true\"\n >\n <span\n class=\"mapa-dropdown-v2__trigger-text\"\n [class.mapa-dropdown-v2__trigger-text--placeholder]=\"!formControl.value\"\n >\n {{ selectedLabel() }}\n </span>\n </button>\n\n @if (isOpen()) {\n <div class=\"mapa-dropdown-v2__panel\">\n @if (hasSearch()) {\n <input\n #searchInput\n class=\"mapa-dropdown-v2__search-input\"\n type=\"text\"\n [formControl]=\"searchControl!\"\n [placeholder]=\"searchPlaceholder()\"\n />\n }\n\n <div class=\"mapa-dropdown-v2__options\" role=\"listbox\">\n @for (option of filteredOptions(); track option.key) {\n <button\n class=\"mapa-dropdown-v2__option\"\n [class.mapa-dropdown-v2__option--selected]=\"\n formControl.value?.key === option.key\n \"\n type=\"button\"\n (click)=\"selectOption(option)\"\n >\n {{ option.value }}\n </button>\n }\n\n @if (!filteredOptions().length) {\n <p class=\"mapa-dropdown-v2__empty-state\">\n {{ element.search?.noEntriesFoundLabel }}\n </p>\n }\n </div>\n </div>\n }\n\n @if (shouldShowRequiredError() && element.errors?.['required']) {\n <p class=\"mapa-dropdown-v2__error\">\n {{ element.errors?.['required'] }}\n </p>\n }\n</div>\n", styles: [".mapa-dropdown-v2{position:relative;display:inline-block;max-width:min-content;min-width:235px}.mapa-dropdown-v2__label{display:inline-block;margin-bottom:8px;color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-heading, \"Asap\", sans-serif);font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.mapa-dropdown-v2__trigger,.mapa-dropdown-v2__search-input,.mapa-dropdown-v2__option{width:100%;min-height:48px;padding:12px 16px;border:0;background:var(--mapa-color-surface, #ffffff);color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-body, \"Asap\", sans-serif);font-size:16px;line-height:24px}.mapa-dropdown-v2__trigger:focus,.mapa-dropdown-v2__search-input:focus,.mapa-dropdown-v2__option:focus{outline:none}.mapa-dropdown-v2__trigger::placeholder,.mapa-dropdown-v2__search-input::placeholder,.mapa-dropdown-v2__option::placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__trigger{position:relative;display:flex;align-items:center;text-align:left;cursor:pointer;padding-right:46px;border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .18));border-radius:var(--mapa-radius-sm, 12px);transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease}.mapa-dropdown-v2__trigger:after{content:\"\";position:absolute;top:50%;right:18px;width:9px;height:9px;border-right:2px solid var(--mapa-color-ink, #1a1a1a);border-bottom:2px solid var(--mapa-color-ink, #1a1a1a);transform:translateY(-70%) rotate(45deg);transition:transform .2s ease;pointer-events:none}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger,.mapa-dropdown-v2__trigger:focus{border-color:var(--mapa-color-accent, #ff560b);box-shadow:0 0 0 3px #ff560b1f}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger:after{transform:translateY(-20%) rotate(-135deg)}.mapa-dropdown-v2__trigger-text{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--mapa-color-ink, #1a1a1a)}.mapa-dropdown-v2__trigger-text--placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__panel{position:absolute;top:calc(100% + 8px);left:0;right:0;z-index:20;background:var(--mapa-color-surface, #ffffff);border:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));border-radius:var(--mapa-radius-md, 16px);box-shadow:var(--mapa-shadow-panel, 0 18px 40px rgba(26, 26, 26, .08));overflow:hidden}.mapa-dropdown-v2__search-input{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}.mapa-dropdown-v2__options{background:var(--mapa-color-surface, #ffffff);max-height:240px;overflow-y:auto}.mapa-dropdown-v2__option{display:flex;align-items:center;text-align:left;cursor:pointer;min-height:44px;transition:background-color .2s ease,color .2s ease}.mapa-dropdown-v2__option:hover{background:#ff560b14}.mapa-dropdown-v2__option--selected{background:#ff560b1f;color:var(--mapa-color-accent, #ff560b)}.mapa-dropdown-v2__empty-state{margin:0;padding:14px 16px;color:var(--mapa-color-muted, #555555);font-size:14px;line-height:20px}.mapa-dropdown-v2--invalid .mapa-dropdown-v2__trigger{border-color:#b54242;box-shadow:0 0 0 3px #b542421f}.mapa-dropdown-v2__error{display:block;margin:8px 0 0;padding-left:4px;color:#b54242;font-size:13px;line-height:18px}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
125
|
+
}
|
|
126
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaDropdownV2Component, decorators: [{
|
|
127
|
+
type: Component,
|
|
128
|
+
args: [{ selector: "mapa-dropdown-v2", standalone: true, imports: [ReactiveFormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"mapa-dropdown-v2\"\n [class.mapa-dropdown-v2--open]=\"isOpen()\"\n [class.mapa-dropdown-v2--invalid]=\"shouldShowRequiredError()\"\n>\n @if (element.label) {\n <label class=\"mapa-dropdown-v2__label\" [attr.for]=\"element.key || null\">\n {{ element.label }}\n </label>\n }\n\n <button\n #triggerButton\n class=\"mapa-dropdown-v2__trigger\"\n [id]=\"element.key || null\"\n type=\"button\"\n (click)=\"toggleDropdown()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-haspopup]=\"true\"\n >\n <span\n class=\"mapa-dropdown-v2__trigger-text\"\n [class.mapa-dropdown-v2__trigger-text--placeholder]=\"!formControl.value\"\n >\n {{ selectedLabel() }}\n </span>\n </button>\n\n @if (isOpen()) {\n <div class=\"mapa-dropdown-v2__panel\">\n @if (hasSearch()) {\n <input\n #searchInput\n class=\"mapa-dropdown-v2__search-input\"\n type=\"text\"\n [formControl]=\"searchControl!\"\n [placeholder]=\"searchPlaceholder()\"\n />\n }\n\n <div class=\"mapa-dropdown-v2__options\" role=\"listbox\">\n @for (option of filteredOptions(); track option.key) {\n <button\n class=\"mapa-dropdown-v2__option\"\n [class.mapa-dropdown-v2__option--selected]=\"\n formControl.value?.key === option.key\n \"\n type=\"button\"\n (click)=\"selectOption(option)\"\n >\n {{ option.value }}\n </button>\n }\n\n @if (!filteredOptions().length) {\n <p class=\"mapa-dropdown-v2__empty-state\">\n {{ element.search?.noEntriesFoundLabel }}\n </p>\n }\n </div>\n </div>\n }\n\n @if (shouldShowRequiredError() && element.errors?.['required']) {\n <p class=\"mapa-dropdown-v2__error\">\n {{ element.errors?.['required'] }}\n </p>\n }\n</div>\n", styles: [".mapa-dropdown-v2{position:relative;display:inline-block;max-width:min-content;min-width:235px}.mapa-dropdown-v2__label{display:inline-block;margin-bottom:8px;color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-heading, \"Asap\", sans-serif);font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.mapa-dropdown-v2__trigger,.mapa-dropdown-v2__search-input,.mapa-dropdown-v2__option{width:100%;min-height:48px;padding:12px 16px;border:0;background:var(--mapa-color-surface, #ffffff);color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-body, \"Asap\", sans-serif);font-size:16px;line-height:24px}.mapa-dropdown-v2__trigger:focus,.mapa-dropdown-v2__search-input:focus,.mapa-dropdown-v2__option:focus{outline:none}.mapa-dropdown-v2__trigger::placeholder,.mapa-dropdown-v2__search-input::placeholder,.mapa-dropdown-v2__option::placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__trigger{position:relative;display:flex;align-items:center;text-align:left;cursor:pointer;padding-right:46px;border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .18));border-radius:var(--mapa-radius-sm, 12px);transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease}.mapa-dropdown-v2__trigger:after{content:\"\";position:absolute;top:50%;right:18px;width:9px;height:9px;border-right:2px solid var(--mapa-color-ink, #1a1a1a);border-bottom:2px solid var(--mapa-color-ink, #1a1a1a);transform:translateY(-70%) rotate(45deg);transition:transform .2s ease;pointer-events:none}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger,.mapa-dropdown-v2__trigger:focus{border-color:var(--mapa-color-accent, #ff560b);box-shadow:0 0 0 3px #ff560b1f}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger:after{transform:translateY(-20%) rotate(-135deg)}.mapa-dropdown-v2__trigger-text{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--mapa-color-ink, #1a1a1a)}.mapa-dropdown-v2__trigger-text--placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__panel{position:absolute;top:calc(100% + 8px);left:0;right:0;z-index:20;background:var(--mapa-color-surface, #ffffff);border:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));border-radius:var(--mapa-radius-md, 16px);box-shadow:var(--mapa-shadow-panel, 0 18px 40px rgba(26, 26, 26, .08));overflow:hidden}.mapa-dropdown-v2__search-input{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}.mapa-dropdown-v2__options{background:var(--mapa-color-surface, #ffffff);max-height:240px;overflow-y:auto}.mapa-dropdown-v2__option{display:flex;align-items:center;text-align:left;cursor:pointer;min-height:44px;transition:background-color .2s ease,color .2s ease}.mapa-dropdown-v2__option:hover{background:#ff560b14}.mapa-dropdown-v2__option--selected{background:#ff560b1f;color:var(--mapa-color-accent, #ff560b)}.mapa-dropdown-v2__empty-state{margin:0;padding:14px 16px;color:var(--mapa-color-muted, #555555);font-size:14px;line-height:20px}.mapa-dropdown-v2--invalid .mapa-dropdown-v2__trigger{border-color:#b54242;box-shadow:0 0 0 3px #b542421f}.mapa-dropdown-v2__error{display:block;margin:8px 0 0;padding-left:4px;color:#b54242;font-size:13px;line-height:18px}\n"] }]
|
|
129
|
+
}], propDecorators: { element: [{
|
|
130
|
+
type: Input,
|
|
131
|
+
args: [{ required: true }]
|
|
132
|
+
}], formControl: [{
|
|
133
|
+
type: Input,
|
|
134
|
+
args: [{ required: true }]
|
|
135
|
+
}], triggerButton: [{
|
|
136
|
+
type: ViewChild,
|
|
137
|
+
args: ["triggerButton"]
|
|
138
|
+
}], searchInput: [{
|
|
139
|
+
type: ViewChild,
|
|
140
|
+
args: ["searchInput"]
|
|
141
|
+
}], handleDocumentClick: [{
|
|
142
|
+
type: HostListener,
|
|
143
|
+
args: ["document:click", ["$event"]]
|
|
144
|
+
}] } });
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Public API Surface of mapa-library-ui dropdown-v2
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
* Public API Surface of mapa-library-ui dropdown-v2
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Generated bundle index. Do not edit.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
export { Dropdown, ElementBase, MapaDropdownV2Component };
|
|
159
|
+
//# sourceMappingURL=mapa-library-ui-src-lib-components-dropdown-v2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapa-library-ui-src-lib-components-dropdown-v2.mjs","sources":["../../../projects/mapa-library-ui/src/lib/core/elements/element-base.ts","../../../projects/mapa-library-ui/src/lib/core/elements/dropdown.ts","../../../projects/mapa-library-ui/src/lib/components/dropdown-v2/src/dropdown-v2.component.ts","../../../projects/mapa-library-ui/src/lib/components/dropdown-v2/src/dropdown-v2.component.html","../../../projects/mapa-library-ui/src/lib/components/dropdown-v2/public-api.ts","../../../projects/mapa-library-ui/src/dropdown-v2.ts","../../../projects/mapa-library-ui/src/mapa-library-ui-src-lib-components-dropdown-v2.ts"],"sourcesContent":["import { EventEmitter } from \"@angular/core\";\nimport { ElementGroup } from \"../interfaces/element-group.interface\";\nimport { ElementOption, ElementTreeNode } from \"../interfaces/element-option.interface\";\nimport { ActionButton } from \"./action-button\";\nimport { ElementSearch } from \"./element-search\";\nimport { Errors } from \"./errors\";\nexport interface Status {\n label: string;\n}\n\nexport class ElementBase {\n value: string;\n key: string;\n label: string;\n required: boolean;\n order: number;\n controlType: string;\n type: string;\n placeholder?: string;\n readonly: boolean;\n hint?: string;\n prefix?: string;\n suffix?: string;\n autosize?: boolean;\n autosizeMinWidth?: string;\n autosizeMaxWidth?: string;\n autosizeMinRow?: number;\n autosizeMaxRow?: number;\n options: ElementOption[] | ElementGroup[];\n tree: ElementTreeNode[];\n multiple?: boolean;\n search?: ElementSearch;\n maxLength!: string | number | null;\n errors?: Errors;\n actionButton?: ActionButton;\n mask?: string;\n autocomplete?: string;\n clearValue?: boolean;\n minDate?: string | Date | null;\n maxDate?: string | Date | null;\n status?: Status[];\n checkParent?: boolean;\n checkChildren?: boolean;\n openedChange?: EventEmitter<boolean>;\n\n constructor(\n options: {\n value?: string;\n key?: string;\n label?: string;\n required?: boolean;\n order?: number;\n controlType?: string;\n type?: string;\n placeholder?: string;\n readonly?: boolean;\n hint?: string;\n prefix?: string;\n suffix?: string;\n autosize?: boolean;\n autosizeMinWidth?: string;\n autosizeMaxWidth?: string;\n autosizeMinRow?: number;\n autosizeMaxRow?: number;\n options?: ElementOption[] | ElementGroup[];\n tree?: ElementTreeNode[];\n multiple?: boolean;\n search?: ElementSearch;\n maxLength?: string | number | null;\n errors?: Errors;\n actionButton?: ActionButton;\n mask?: string;\n autocomplete?: string;\n clearValue?: boolean;\n minDate?: string | Date | null;\n maxDate?: string | Date | null;\n status?: Status[];\n checkParent?: boolean;\n checkChildren?: boolean;\n openedChange?: EventEmitter<boolean>;\n } = {}\n ) {\n this.value = options.value || \"\";\n this.key = options.key || \"\";\n this.label = options.label || \"\";\n this.required = !!options.required;\n this.order = options.order === undefined ? 1 : options.order;\n this.controlType = options.controlType || \"\";\n this.type = options.type || \"\";\n this.placeholder = options.placeholder || \"\";\n this.readonly = options.readonly || false;\n this.hint = options.hint || \"\";\n this.prefix = options.prefix || \"\";\n this.suffix = options.suffix || \"\";\n this.autosize = options.autosize || false;\n this.autosizeMinWidth = options.autosizeMinWidth || \"212px\";\n this.autosizeMaxWidth = options.autosizeMaxWidth || \"400px\";\n this.autosizeMinRow = options.autosizeMinRow || 2;\n this.autosizeMaxRow = options.autosizeMaxRow || 5;\n this.options = options.options || [];\n this.tree = options.tree || [];\n this.multiple = options.multiple || false;\n this.search = options.search || undefined;\n this.maxLength = options.maxLength || null;\n this.errors = options.errors || undefined;\n this.actionButton = options.actionButton || undefined;\n this.mask = options.mask || undefined;\n this.autocomplete = options.autocomplete || \"\";\n this.clearValue =\n options.clearValue !== undefined ? options.clearValue : true;\n this.minDate = options.minDate || undefined;\n this.maxDate = options.maxDate || undefined;\n this.status = options.status || undefined;\n this.checkParent = options.checkParent || false;\n this.checkChildren = options.checkChildren || false;\n this.openedChange = options.openedChange || undefined;\n }\n}\n","import { ElementBase } from './element-base';\n\nexport class Dropdown extends ElementBase {\n override controlType = 'dropdown';\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n HostListener,\n Input,\n ViewChild,\n inject,\n signal,\n} from \"@angular/core\";\nimport { FormControl, ReactiveFormsModule } from \"@angular/forms\";\nimport { Dropdown } from \"../../../core/elements/dropdown\";\nimport { ElementOption } from \"../../../core/interfaces/element-option.interface\";\n\n@Component({\n selector: \"mapa-dropdown-v2\",\n standalone: true,\n imports: [ReactiveFormsModule],\n templateUrl: \"./dropdown-v2.component.html\",\n styleUrl: \"./dropdown-v2.component.scss\",\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MapaDropdownV2Component {\n private readonly hostElement = inject(ElementRef<HTMLElement>);\n private readonly isOpenState = signal(false);\n\n @Input({ required: true }) element!: Dropdown;\n @Input({ required: true }) formControl!: FormControl<ElementOption | null>;\n\n @ViewChild(\"triggerButton\")\n private triggerButton?: ElementRef<HTMLButtonElement>;\n @ViewChild(\"searchInput\")\n private searchInput?: ElementRef<HTMLInputElement>;\n\n isOpen(): boolean {\n return this.isOpenState();\n }\n\n selectedLabel(): string {\n return this.formControl.value?.value || this.element.placeholder || \"\";\n }\n\n options(): ElementOption[] {\n return (this.element.options as ElementOption[]) ?? [];\n }\n\n filteredOptions(): ElementOption[] {\n const options = this.options();\n const searchTerm =\n this.searchControl?.value?.trim().toLocaleLowerCase() ?? \"\";\n\n if (!searchTerm) {\n return options;\n }\n\n return options.filter((option) =>\n option.value?.toLocaleLowerCase().includes(searchTerm),\n );\n }\n\n hasSearch(): boolean {\n return !!this.searchControl;\n }\n\n searchPlaceholder(): string {\n return this.element.search?.placeholder ?? \"\";\n }\n\n shouldShowRequiredError(): boolean {\n return (\n this.formControl.invalid &&\n (this.formControl.dirty || this.formControl.touched)\n );\n }\n\n toggleDropdown(): void {\n const isOpening = !this.isOpenState();\n this.isOpenState.set(isOpening);\n\n if (isOpening) {\n this.searchControl?.setValue(\"\", { emitEvent: true });\n setTimeout(() => {\n this.triggerButton?.nativeElement.blur();\n this.searchInput?.nativeElement.focus();\n this.searchInput?.nativeElement.select();\n });\n return;\n }\n\n this.markAsTouchedIfEmpty();\n }\n\n selectOption(option: ElementOption): void {\n this.formControl.setValue(option);\n this.formControl.markAsDirty();\n this.formControl.markAsTouched();\n this.closeDropdown();\n }\n\n closeDropdown(): void {\n this.isOpenState.set(false);\n this.searchControl?.setValue(\"\", { emitEvent: true });\n this.markAsTouchedIfEmpty();\n }\n\n @HostListener(\"document:click\", [\"$event\"])\n handleDocumentClick(event: MouseEvent): void {\n if (\n this.isOpenState() &&\n !this.hostElement.nativeElement.contains(event.target as Node)\n ) {\n this.closeDropdown();\n }\n }\n\n get searchControl(): FormControl<string | null> | undefined {\n return this.element.search?.formControl as\n | FormControl<string | null>\n | undefined;\n }\n\n private markAsTouchedIfEmpty(): void {\n if (!this.formControl.value) {\n this.formControl.markAsTouched();\n }\n }\n}\n","<div\n class=\"mapa-dropdown-v2\"\n [class.mapa-dropdown-v2--open]=\"isOpen()\"\n [class.mapa-dropdown-v2--invalid]=\"shouldShowRequiredError()\"\n>\n @if (element.label) {\n <label class=\"mapa-dropdown-v2__label\" [attr.for]=\"element.key || null\">\n {{ element.label }}\n </label>\n }\n\n <button\n #triggerButton\n class=\"mapa-dropdown-v2__trigger\"\n [id]=\"element.key || null\"\n type=\"button\"\n (click)=\"toggleDropdown()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-haspopup]=\"true\"\n >\n <span\n class=\"mapa-dropdown-v2__trigger-text\"\n [class.mapa-dropdown-v2__trigger-text--placeholder]=\"!formControl.value\"\n >\n {{ selectedLabel() }}\n </span>\n </button>\n\n @if (isOpen()) {\n <div class=\"mapa-dropdown-v2__panel\">\n @if (hasSearch()) {\n <input\n #searchInput\n class=\"mapa-dropdown-v2__search-input\"\n type=\"text\"\n [formControl]=\"searchControl!\"\n [placeholder]=\"searchPlaceholder()\"\n />\n }\n\n <div class=\"mapa-dropdown-v2__options\" role=\"listbox\">\n @for (option of filteredOptions(); track option.key) {\n <button\n class=\"mapa-dropdown-v2__option\"\n [class.mapa-dropdown-v2__option--selected]=\"\n formControl.value?.key === option.key\n \"\n type=\"button\"\n (click)=\"selectOption(option)\"\n >\n {{ option.value }}\n </button>\n }\n\n @if (!filteredOptions().length) {\n <p class=\"mapa-dropdown-v2__empty-state\">\n {{ element.search?.noEntriesFoundLabel }}\n </p>\n }\n </div>\n </div>\n }\n\n @if (shouldShowRequiredError() && element.errors?.['required']) {\n <p class=\"mapa-dropdown-v2__error\">\n {{ element.errors?.['required'] }}\n </p>\n }\n</div>\n","/*\n * Public API Surface of mapa-library-ui dropdown-v2\n */\n\nexport * from './src/dropdown-v2.component';\n","/*\n * Public API Surface of mapa-library-ui dropdown-v2\n */\n\nexport * from './lib/core/elements/element-search';\nexport * from './lib/core/elements/element-base';\nexport * from './lib/core/elements/dropdown';\nexport * from './lib/core/interfaces/element-option.interface';\n\nexport * from './lib/components/dropdown-v2/public-api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './dropdown-v2';\n"],"names":[],"mappings":";;;;;MAUa,WAAW,CAAA;AAmCtB,IAAA,WAAA,CACE,UAkCI,EAAE,EAAA;QAEN,IAAI,CAAC,KAAK,GAAG,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AAI,EAAA,OAAA,EACP,CAAC,mBAAmB,CAAC,EAAA,eAAA,EAGb,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,65DAAA,EAAA,MAAA,EAAA,CAAA,krGAAA,CAAA,EAAA;;sBAM9C,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBACxB,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBAExB,SAAS;uBAAC,eAAe;;sBAEzB,SAAS;uBAAC,aAAa;;sBA0EvB,YAAY;uBAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC;;;AEzG5C;;AAEG;;ACFH;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -68,9 +68,15 @@ function toDatepickerLocale(language) {
|
|
|
68
68
|
function getDateFormatByLanguage(language) {
|
|
69
69
|
return language === 'en' ? 'MM/DD/YYYY' : 'DD/MM/YYYY';
|
|
70
70
|
}
|
|
71
|
+
function getDateTimeFormatByLanguage(language) {
|
|
72
|
+
return language === 'en' ? 'MM/DD/YYYY HH:mm' : 'DD/MM/YYYY HH:mm';
|
|
73
|
+
}
|
|
71
74
|
function formatDateByLanguage(value, language) {
|
|
72
75
|
return formatDateValue(value, getDateFormatByLanguage(language));
|
|
73
76
|
}
|
|
77
|
+
function formatDateTimeByLanguage(value, language) {
|
|
78
|
+
return formatDateValue(value, getDateTimeFormatByLanguage(language));
|
|
79
|
+
}
|
|
74
80
|
function isValidDateByLanguage(value, language) {
|
|
75
81
|
if (!value) {
|
|
76
82
|
return false;
|
|
@@ -293,5 +299,5 @@ function toUtcDayExclusiveEndIso(value) {
|
|
|
293
299
|
* Generated bundle index. Do not edit.
|
|
294
300
|
*/
|
|
295
301
|
|
|
296
|
-
export { addDays, addMonthsToDateValue, formatBrazilianDate, formatDateAsDayMonthYear, formatDateAsMonthDayYear, formatDateByLanguage, formatDateForLocale, formatDateValue, formatLocaleDate, formatLocaleDateTime, getActiveDateFormat, getActiveDateLocale, getActiveMaterialDateFormat, getDateFormatByLanguage, getDateInputMask, getDayOfMonthFromDateValue, getDefaultDateRange, getRelativeDateRange, getYearFromDateValue, isAfterDateValue, isDateValue, isMonthFirstDateLocale, isValidDateByLanguage, isValidDateValue, normalizeDateInput, normalizeDateLocale, parseBrazilianDate, parseDateByLanguage, parseDateValue, parseDateValueFns, parseLocaleDateValue, reformatDateStringForLanguage, setTimeOnDateValue, toDatepickerLocale, toIsoDateByLanguage, toIsoDateByLanguageWithUtcTime, toIsoDateValue, toIsoDateValueWithTime, toIsoDateValueWithUtcTime, toUtcDayExclusiveEndIso, toUtcRangeEndIso, toUtcRangeStartIso };
|
|
302
|
+
export { addDays, addMonthsToDateValue, formatBrazilianDate, formatDateAsDayMonthYear, formatDateAsMonthDayYear, formatDateByLanguage, formatDateForLocale, formatDateTimeByLanguage, formatDateValue, formatLocaleDate, formatLocaleDateTime, getActiveDateFormat, getActiveDateLocale, getActiveMaterialDateFormat, getDateFormatByLanguage, getDateInputMask, getDateTimeFormatByLanguage, getDayOfMonthFromDateValue, getDefaultDateRange, getRelativeDateRange, getYearFromDateValue, isAfterDateValue, isDateValue, isMonthFirstDateLocale, isValidDateByLanguage, isValidDateValue, normalizeDateInput, normalizeDateLocale, parseBrazilianDate, parseDateByLanguage, parseDateValue, parseDateValueFns, parseLocaleDateValue, reformatDateStringForLanguage, setTimeOnDateValue, toDatepickerLocale, toIsoDateByLanguage, toIsoDateByLanguageWithUtcTime, toIsoDateValue, toIsoDateValueWithTime, toIsoDateValueWithUtcTime, toUtcDayExclusiveEndIso, toUtcRangeEndIso, toUtcRangeStartIso };
|
|
297
303
|
//# sourceMappingURL=mapa-library-ui-src-lib-core-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapa-library-ui-src-lib-core-utils.mjs","sources":["../../../projects/mapa-library-ui/src/lib/core/utils/date-fns.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/date-locale.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/date.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/public-api.ts","../../../projects/mapa-library-ui/src/mapa-library-ui-src-lib-core-utils.ts"],"sourcesContent":["import {\n addMonths,\n format,\n getDate,\n getYear,\n isAfter,\n isValid,\n parse,\n parseISO,\n set,\n} from 'date-fns';\n\ntype DateInput = Date | string | number | null | undefined;\n\ninterface TimeParts {\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\nconst ISO_DATE_RE = /^\\d{4}-\\d{2}-\\d{2}T/;\n\nconst toDateFnsFormat = (formatPattern: string) =>\n formatPattern\n .replaceAll('YYYY', 'yyyy')\n .replaceAll('DD', 'dd')\n .replaceAll('A', 'a');\n\nexport const parseDateValueFns = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): Date => {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === 'number') {\n return new Date(value);\n }\n\n if (typeof value === 'string') {\n if (!value.trim()) {\n return new Date(NaN);\n }\n\n if (ISO_DATE_RE.test(value)) {\n return parseISO(value);\n }\n\n const parsed = parse(value, toDateFnsFormat(inputFormat), new Date());\n if (isValid(parsed)) {\n return parsed;\n }\n\n return new Date(value);\n }\n\n return new Date(NaN);\n};\n\nexport const formatDateValue = (\n value: DateInput,\n outputFormat = 'DD/MM/YYYY',\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n if (!isValid(parsed)) {\n return '';\n }\n\n return format(parsed, toDateFnsFormat(outputFormat));\n};\n\nexport const isValidDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): boolean => {\n const parsed = parseDateValueFns(value, inputFormat);\n return isValid(parsed);\n};\n\nexport const toIsoDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n return isValid(parsed) ? parsed.toISOString() : '';\n};\n\nexport const addMonthsToDateValue = (\n value: DateInput,\n months: number,\n inputFormat = 'DD/MM/YYYY',\n): Date => addMonths(parseDateValueFns(value, inputFormat), months);\n\nexport const setTimeOnDateValue = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): Date => set(parseDateValueFns(value, inputFormat), time);\n\nexport const toIsoDateValueWithTime = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = setTimeOnDateValue(value, time, inputFormat);\n return isValid(parsed) ? parsed.toISOString() : '';\n};\n\nexport const toIsoDateValueWithUtcTime = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n\n if (!isValid(parsed)) {\n return '';\n }\n\n const utcDate = new Date(parsed.getTime());\n utcDate.setUTCHours(\n time.hours ?? utcDate.getUTCHours(),\n time.minutes ?? utcDate.getUTCMinutes(),\n time.seconds ?? utcDate.getUTCSeconds(),\n time.milliseconds ?? utcDate.getUTCMilliseconds(),\n );\n\n return utcDate.toISOString();\n};\n\nexport const getYearFromDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): number => getYear(parseDateValueFns(value, inputFormat));\n\nexport const getDayOfMonthFromDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): number => getDate(parseDateValueFns(value, inputFormat));\n\nexport const isAfterDateValue = (\n value: DateInput,\n compareValue: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): boolean =>\n isAfter(\n parseDateValueFns(value, inputFormat),\n parseDateValueFns(compareValue, inputFormat),\n );\n","import { AppLanguage } from 'mapa-frontend-i18n';\nimport {\n formatDateValue,\n isValidDateValue,\n parseDateValueFns,\n toIsoDateValue,\n toIsoDateValueWithUtcTime,\n} from './date-fns.util';\n\nexport type DatepickerLocale = 'pt-BR' | 'es' | 'en';\nexport type DateFormatPattern = 'DD/MM/YYYY' | 'MM/DD/YYYY';\n\nexport function toDatepickerLocale(language: AppLanguage): DatepickerLocale {\n return language === 'en' ? 'en' : language === 'es' ? 'es' : 'pt-BR';\n}\n\nexport function getDateFormatByLanguage(\n language: AppLanguage,\n): DateFormatPattern {\n return language === 'en' ? 'MM/DD/YYYY' : 'DD/MM/YYYY';\n}\n\nexport function formatDateByLanguage(\n value: Date | string | number | null | undefined,\n language: AppLanguage,\n): string {\n return formatDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function isValidDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): boolean {\n if (!value) {\n return false;\n }\n\n return isValidDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function parseDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): Date {\n return parseDateValueFns(value, getDateFormatByLanguage(language));\n}\n\nexport function toIsoDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): string {\n return toIsoDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function toIsoDateByLanguageWithUtcTime(\n value: string | null | undefined,\n language: AppLanguage,\n time: {\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n },\n): string {\n return toIsoDateValueWithUtcTime(\n value,\n time,\n getDateFormatByLanguage(language),\n );\n}\n\nexport function reformatDateStringForLanguage(\n value: string | null | undefined,\n fromLanguage: AppLanguage,\n toLanguage: AppLanguage,\n): string {\n if (!value) {\n return '';\n }\n\n return formatDateValue(\n value,\n getDateFormatByLanguage(toLanguage),\n getDateFormatByLanguage(fromLanguage),\n );\n}\n","import { getIntlLocale, getStoredAppLanguage } from \"mapa-frontend-i18n\";\n\nconst DAY_MONTH_YEAR_PATTERN = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst MONTH_DAY_YEAR_PATTERN = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst DOCS_LANGUAGE_STORAGE_KEY = \"mapa-library-ui-docs-language\";\n\nexport type MapaDateLocale = \"pt-BR\" | \"en\" | \"es\";\nexport type MapaDateFormat = \"DD/MM/YYYY\" | \"MM/DD/YYYY\";\n\nexport type DateInput = Date | string | number | null | undefined;\n\nfunction isValidDate(date: Date): boolean {\n return !Number.isNaN(date.getTime());\n}\n\nfunction buildUtcDate(\n date: Date,\n dayOffset: number,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number,\n): Date {\n return new Date(\n Date.UTC(\n date.getFullYear(),\n date.getMonth(),\n date.getDate() + dayOffset,\n hours,\n minutes,\n seconds,\n milliseconds,\n ),\n );\n}\n\nexport function formatDateAsDayMonthYear(date: Date): string {\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const year = `${date.getFullYear()}`;\n\n return `${day}/${month}/${year}`;\n}\n\nexport function formatDateAsMonthDayYear(date: Date): string {\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const year = `${date.getFullYear()}`;\n\n return `${month}/${day}/${year}`;\n}\n\nexport function normalizeDateLocale(value: unknown): MapaDateLocale {\n if (typeof value !== \"string\") {\n return \"pt-BR\";\n }\n\n const normalizedValue = value.trim().toLowerCase();\n\n if (normalizedValue.startsWith(\"en\")) {\n return \"en\";\n }\n\n if (normalizedValue.startsWith(\"es\")) {\n return \"es\";\n }\n\n return \"pt-BR\";\n}\n\nfunction getDocsStoredLanguage(): string | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n try {\n return window.localStorage.getItem(DOCS_LANGUAGE_STORAGE_KEY);\n } catch {\n return null;\n }\n}\n\nexport function getActiveDateLocale(): MapaDateLocale {\n return normalizeDateLocale(getDocsStoredLanguage() ?? getStoredAppLanguage());\n}\n\nexport function isMonthFirstDateLocale(locale = getActiveDateLocale()): boolean {\n return normalizeDateLocale(locale) === \"en\";\n}\n\nexport function getActiveDateFormat(locale = getActiveDateLocale()): MapaDateFormat {\n return isMonthFirstDateLocale(locale) ? \"MM/DD/YYYY\" : \"DD/MM/YYYY\";\n}\n\nexport function getActiveMaterialDateFormat(locale = getActiveDateLocale()): string {\n return isMonthFirstDateLocale(locale) ? \"MM/dd/yyyy\" : \"dd/MM/yyyy\";\n}\n\nexport function getDateInputMask(_locale = getActiveDateLocale()): string {\n return \"00/00/0000\";\n}\n\nexport function formatDateForLocale(date: Date, locale = getActiveDateLocale()): string {\n return isMonthFirstDateLocale(locale)\n ? formatDateAsMonthDayYear(date)\n : formatDateAsDayMonthYear(date);\n}\n\nfunction parseOrderedDate(\n value: string,\n pattern: RegExp,\n order: \"day-first\" | \"month-first\"\n): Date | null {\n const match = pattern.exec(value.trim());\n if (!match) {\n return null;\n }\n\n const [, firstValue, secondValue, yearValue] = match;\n const year = Number(yearValue);\n const month = Number(order === \"month-first\" ? firstValue : secondValue);\n const day = Number(order === \"month-first\" ? secondValue : firstValue);\n const parsedDate = new Date(year, month - 1, day);\n\n if (\n parsedDate.getFullYear() !== year ||\n parsedDate.getMonth() !== month - 1 ||\n parsedDate.getDate() !== day\n ) {\n return null;\n }\n\n return parsedDate;\n}\n\nexport function parseLocaleDateValue(\n value: string,\n locale = getActiveDateLocale()\n): Date | null {\n const normalizedLocale = normalizeDateLocale(locale);\n const parsers =\n normalizedLocale === \"en\"\n ? [\n () => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, \"month-first\"),\n () => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\"),\n ]\n : [\n () => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\"),\n () => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, \"month-first\"),\n ];\n\n for (const parse of parsers) {\n const parsedDate = parse();\n if (parsedDate) {\n return parsedDate;\n }\n }\n\n return null;\n}\n\nexport function parseDateValue(\n value: unknown,\n locale = getActiveDateLocale()\n): Date | null {\n if (value instanceof Date) {\n return isValidDate(value) ? new Date(value.getTime()) : null;\n }\n\n if (typeof value === \"number\") {\n const parsedDate = new Date(value);\n return isValidDate(parsedDate) ? parsedDate : null;\n }\n\n if (typeof value !== \"string\") {\n return null;\n }\n\n const trimmedValue = value.trim();\n if (!trimmedValue) {\n return null;\n }\n\n const localeDate = parseLocaleDateValue(trimmedValue, locale);\n if (localeDate) {\n return localeDate;\n }\n\n if (DAY_MONTH_YEAR_PATTERN.test(trimmedValue) || MONTH_DAY_YEAR_PATTERN.test(trimmedValue)) {\n return null;\n }\n\n const parsedDate = new Date(trimmedValue);\n return isValidDate(parsedDate) ? parsedDate : null;\n}\n\nexport function isDateValue(value: unknown): boolean {\n return parseDateValue(value) !== null;\n}\n\nexport function parseBrazilianDate(value: string): Date | null {\n return parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\");\n}\n\nexport function normalizeDateInput(value: DateInput): Date | null {\n return parseDateValue(value);\n}\n\nexport function formatBrazilianDate(value: DateInput): string {\n const date = normalizeDateInput(value);\n return date ? formatDateAsDayMonthYear(date) : \"\";\n}\n\nexport function addDays(date: Date, days: number): Date {\n const nextDate = new Date(date);\n nextDate.setDate(nextDate.getDate() + days);\n return nextDate;\n}\n\nexport type LocaleDateStyle = \"short\" | \"medium\" | \"long\" | \"full\";\n\nexport function formatLocaleDate(\n value: DateInput,\n dateStyle: LocaleDateStyle = \"short\",\n): string {\n const date = normalizeDateInput(value);\n if (!date) {\n return \"\";\n }\n\n return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {\n dateStyle,\n }).format(date);\n}\n\nexport function formatLocaleDateTime(\n value: DateInput,\n options: { dateStyle?: LocaleDateStyle; timeStyle?: LocaleDateStyle } = {},\n): string {\n const date = normalizeDateInput(value);\n if (!date) {\n return \"\";\n }\n\n const { dateStyle = \"short\", timeStyle = \"short\" } = options;\n\n return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {\n dateStyle,\n timeStyle,\n }).format(date);\n}\n\nexport function getDefaultDateRange(days = 60): {\n startDate: string;\n endDate: string;\n} {\n const today = new Date();\n\n return {\n startDate: formatBrazilianDate(addDays(today, -days)),\n endDate: formatBrazilianDate(today),\n };\n}\n\nexport function getRelativeDateRange(daysBack: number): {\n startDate: Date;\n endDate: Date;\n} {\n const endDate = new Date();\n endDate.setHours(23, 59, 59, 999);\n\n const startDate = new Date();\n startDate.setHours(0, 0, 0, 0);\n startDate.setDate(startDate.getDate() - daysBack);\n\n return { startDate, endDate };\n}\n\nexport function toUtcRangeStartIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 0, 3, 0, 0, 0).toISOString() : undefined;\n}\n\nexport function toUtcRangeEndIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 1, 2, 59, 59, 999).toISOString() : undefined;\n}\n\nexport function toUtcDayExclusiveEndIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 1, 3, 0, 0, 0).toISOString() : undefined;\n}\n","/*\n * Public API Surface of mapa-library-ui authorize\n */\nexport * from './date-fns.util';\nexport * from './date-locale.util';\nexport * from './date.util';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './util';\n"],"names":[],"mappings":";;;AAqBA,MAAM,WAAW,GAAG,qBAAqB;AAEzC,MAAM,eAAe,GAAG,CAAC,aAAqB,KAC5C;AACG,KAAA,UAAU,CAAC,MAAM,EAAE,MAAM;AACzB,KAAA,UAAU,CAAC,IAAI,EAAE,IAAI;AACrB,KAAA,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAElB,MAAM,iBAAiB,GAAG,CAC/B,KAAgB,EAChB,WAAW,GAAG,YAAY,KAClB;AACR,IAAA,IAAI,KAAK,YAAY,IAAI,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC;IACxB;AAEA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE;AACjB,YAAA,OAAO,IAAI,IAAI,CAAC,GAAG,CAA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,CAAC,CAAC;IAC9B,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;AAEjD,IAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;AAC/B;AAEM,SAAU,kBAAkB,CAAC,KAAgB,EAAA;AACjD,IAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC;IACtC,OAAO,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS;AAC3E;AAEM,SAAU,gBAAgB,CAAC,KAAgB,EAAA;AAC/C,IAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC;IACtC,OAAO,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS;AAC/E;AAEM,SAAU,uBAAuB,CAAC,KAAgB,EAAA;AACtD,IAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC;IACtC,OAAO,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS;AAC3E;;ACnSA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mapa-library-ui-src-lib-core-utils.mjs","sources":["../../../projects/mapa-library-ui/src/lib/core/utils/date-fns.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/date-locale.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/date.util.ts","../../../projects/mapa-library-ui/src/lib/core/utils/public-api.ts","../../../projects/mapa-library-ui/src/mapa-library-ui-src-lib-core-utils.ts"],"sourcesContent":["import {\n addMonths,\n format,\n getDate,\n getYear,\n isAfter,\n isValid,\n parse,\n parseISO,\n set,\n} from 'date-fns';\n\ntype DateInput = Date | string | number | null | undefined;\n\ninterface TimeParts {\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\nconst ISO_DATE_RE = /^\\d{4}-\\d{2}-\\d{2}T/;\n\nconst toDateFnsFormat = (formatPattern: string) =>\n formatPattern\n .replaceAll('YYYY', 'yyyy')\n .replaceAll('DD', 'dd')\n .replaceAll('A', 'a');\n\nexport const parseDateValueFns = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): Date => {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === 'number') {\n return new Date(value);\n }\n\n if (typeof value === 'string') {\n if (!value.trim()) {\n return new Date(NaN);\n }\n\n if (ISO_DATE_RE.test(value)) {\n return parseISO(value);\n }\n\n const parsed = parse(value, toDateFnsFormat(inputFormat), new Date());\n if (isValid(parsed)) {\n return parsed;\n }\n\n return new Date(value);\n }\n\n return new Date(NaN);\n};\n\nexport const formatDateValue = (\n value: DateInput,\n outputFormat = 'DD/MM/YYYY',\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n if (!isValid(parsed)) {\n return '';\n }\n\n return format(parsed, toDateFnsFormat(outputFormat));\n};\n\nexport const isValidDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): boolean => {\n const parsed = parseDateValueFns(value, inputFormat);\n return isValid(parsed);\n};\n\nexport const toIsoDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n return isValid(parsed) ? parsed.toISOString() : '';\n};\n\nexport const addMonthsToDateValue = (\n value: DateInput,\n months: number,\n inputFormat = 'DD/MM/YYYY',\n): Date => addMonths(parseDateValueFns(value, inputFormat), months);\n\nexport const setTimeOnDateValue = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): Date => set(parseDateValueFns(value, inputFormat), time);\n\nexport const toIsoDateValueWithTime = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = setTimeOnDateValue(value, time, inputFormat);\n return isValid(parsed) ? parsed.toISOString() : '';\n};\n\nexport const toIsoDateValueWithUtcTime = (\n value: DateInput,\n time: TimeParts,\n inputFormat = 'DD/MM/YYYY',\n): string => {\n const parsed = parseDateValueFns(value, inputFormat);\n\n if (!isValid(parsed)) {\n return '';\n }\n\n const utcDate = new Date(parsed.getTime());\n utcDate.setUTCHours(\n time.hours ?? utcDate.getUTCHours(),\n time.minutes ?? utcDate.getUTCMinutes(),\n time.seconds ?? utcDate.getUTCSeconds(),\n time.milliseconds ?? utcDate.getUTCMilliseconds(),\n );\n\n return utcDate.toISOString();\n};\n\nexport const getYearFromDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): number => getYear(parseDateValueFns(value, inputFormat));\n\nexport const getDayOfMonthFromDateValue = (\n value: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): number => getDate(parseDateValueFns(value, inputFormat));\n\nexport const isAfterDateValue = (\n value: DateInput,\n compareValue: DateInput,\n inputFormat = 'DD/MM/YYYY',\n): boolean =>\n isAfter(\n parseDateValueFns(value, inputFormat),\n parseDateValueFns(compareValue, inputFormat),\n );\n","import { AppLanguage } from 'mapa-frontend-i18n';\nimport {\n formatDateValue,\n isValidDateValue,\n parseDateValueFns,\n toIsoDateValue,\n toIsoDateValueWithUtcTime,\n} from './date-fns.util';\n\nexport type DatepickerLocale = 'pt-BR' | 'es' | 'en';\nexport type DateFormatPattern = 'DD/MM/YYYY' | 'MM/DD/YYYY';\nexport type DateTimeFormatPattern =\n | 'DD/MM/YYYY HH:mm'\n | 'MM/DD/YYYY HH:mm';\n\nexport function toDatepickerLocale(language: AppLanguage): DatepickerLocale {\n return language === 'en' ? 'en' : language === 'es' ? 'es' : 'pt-BR';\n}\n\nexport function getDateFormatByLanguage(\n language: AppLanguage,\n): DateFormatPattern {\n return language === 'en' ? 'MM/DD/YYYY' : 'DD/MM/YYYY';\n}\n\nexport function getDateTimeFormatByLanguage(\n language: AppLanguage,\n): DateTimeFormatPattern {\n return language === 'en' ? 'MM/DD/YYYY HH:mm' : 'DD/MM/YYYY HH:mm';\n}\n\nexport function formatDateByLanguage(\n value: Date | string | number | null | undefined,\n language: AppLanguage,\n): string {\n return formatDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function formatDateTimeByLanguage(\n value: Date | string | number | null | undefined,\n language: AppLanguage,\n): string {\n return formatDateValue(value, getDateTimeFormatByLanguage(language));\n}\n\nexport function isValidDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): boolean {\n if (!value) {\n return false;\n }\n\n return isValidDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function parseDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): Date {\n return parseDateValueFns(value, getDateFormatByLanguage(language));\n}\n\nexport function toIsoDateByLanguage(\n value: string | null | undefined,\n language: AppLanguage,\n): string {\n return toIsoDateValue(value, getDateFormatByLanguage(language));\n}\n\nexport function toIsoDateByLanguageWithUtcTime(\n value: string | null | undefined,\n language: AppLanguage,\n time: {\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n },\n): string {\n return toIsoDateValueWithUtcTime(\n value,\n time,\n getDateFormatByLanguage(language),\n );\n}\n\nexport function reformatDateStringForLanguage(\n value: string | null | undefined,\n fromLanguage: AppLanguage,\n toLanguage: AppLanguage,\n): string {\n if (!value) {\n return '';\n }\n\n return formatDateValue(\n value,\n getDateFormatByLanguage(toLanguage),\n getDateFormatByLanguage(fromLanguage),\n );\n}\n","import { getIntlLocale, getStoredAppLanguage } from \"mapa-frontend-i18n\";\n\nconst DAY_MONTH_YEAR_PATTERN = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst MONTH_DAY_YEAR_PATTERN = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst DOCS_LANGUAGE_STORAGE_KEY = \"mapa-library-ui-docs-language\";\n\nexport type MapaDateLocale = \"pt-BR\" | \"en\" | \"es\";\nexport type MapaDateFormat = \"DD/MM/YYYY\" | \"MM/DD/YYYY\";\n\nexport type DateInput = Date | string | number | null | undefined;\n\nfunction isValidDate(date: Date): boolean {\n return !Number.isNaN(date.getTime());\n}\n\nfunction buildUtcDate(\n date: Date,\n dayOffset: number,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number,\n): Date {\n return new Date(\n Date.UTC(\n date.getFullYear(),\n date.getMonth(),\n date.getDate() + dayOffset,\n hours,\n minutes,\n seconds,\n milliseconds,\n ),\n );\n}\n\nexport function formatDateAsDayMonthYear(date: Date): string {\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const year = `${date.getFullYear()}`;\n\n return `${day}/${month}/${year}`;\n}\n\nexport function formatDateAsMonthDayYear(date: Date): string {\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n const year = `${date.getFullYear()}`;\n\n return `${month}/${day}/${year}`;\n}\n\nexport function normalizeDateLocale(value: unknown): MapaDateLocale {\n if (typeof value !== \"string\") {\n return \"pt-BR\";\n }\n\n const normalizedValue = value.trim().toLowerCase();\n\n if (normalizedValue.startsWith(\"en\")) {\n return \"en\";\n }\n\n if (normalizedValue.startsWith(\"es\")) {\n return \"es\";\n }\n\n return \"pt-BR\";\n}\n\nfunction getDocsStoredLanguage(): string | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n try {\n return window.localStorage.getItem(DOCS_LANGUAGE_STORAGE_KEY);\n } catch {\n return null;\n }\n}\n\nexport function getActiveDateLocale(): MapaDateLocale {\n return normalizeDateLocale(getDocsStoredLanguage() ?? getStoredAppLanguage());\n}\n\nexport function isMonthFirstDateLocale(locale = getActiveDateLocale()): boolean {\n return normalizeDateLocale(locale) === \"en\";\n}\n\nexport function getActiveDateFormat(locale = getActiveDateLocale()): MapaDateFormat {\n return isMonthFirstDateLocale(locale) ? \"MM/DD/YYYY\" : \"DD/MM/YYYY\";\n}\n\nexport function getActiveMaterialDateFormat(locale = getActiveDateLocale()): string {\n return isMonthFirstDateLocale(locale) ? \"MM/dd/yyyy\" : \"dd/MM/yyyy\";\n}\n\nexport function getDateInputMask(_locale = getActiveDateLocale()): string {\n return \"00/00/0000\";\n}\n\nexport function formatDateForLocale(date: Date, locale = getActiveDateLocale()): string {\n return isMonthFirstDateLocale(locale)\n ? formatDateAsMonthDayYear(date)\n : formatDateAsDayMonthYear(date);\n}\n\nfunction parseOrderedDate(\n value: string,\n pattern: RegExp,\n order: \"day-first\" | \"month-first\"\n): Date | null {\n const match = pattern.exec(value.trim());\n if (!match) {\n return null;\n }\n\n const [, firstValue, secondValue, yearValue] = match;\n const year = Number(yearValue);\n const month = Number(order === \"month-first\" ? firstValue : secondValue);\n const day = Number(order === \"month-first\" ? secondValue : firstValue);\n const parsedDate = new Date(year, month - 1, day);\n\n if (\n parsedDate.getFullYear() !== year ||\n parsedDate.getMonth() !== month - 1 ||\n parsedDate.getDate() !== day\n ) {\n return null;\n }\n\n return parsedDate;\n}\n\nexport function parseLocaleDateValue(\n value: string,\n locale = getActiveDateLocale()\n): Date | null {\n const normalizedLocale = normalizeDateLocale(locale);\n const parsers =\n normalizedLocale === \"en\"\n ? [\n () => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, \"month-first\"),\n () => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\"),\n ]\n : [\n () => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\"),\n () => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, \"month-first\"),\n ];\n\n for (const parse of parsers) {\n const parsedDate = parse();\n if (parsedDate) {\n return parsedDate;\n }\n }\n\n return null;\n}\n\nexport function parseDateValue(\n value: unknown,\n locale = getActiveDateLocale()\n): Date | null {\n if (value instanceof Date) {\n return isValidDate(value) ? new Date(value.getTime()) : null;\n }\n\n if (typeof value === \"number\") {\n const parsedDate = new Date(value);\n return isValidDate(parsedDate) ? parsedDate : null;\n }\n\n if (typeof value !== \"string\") {\n return null;\n }\n\n const trimmedValue = value.trim();\n if (!trimmedValue) {\n return null;\n }\n\n const localeDate = parseLocaleDateValue(trimmedValue, locale);\n if (localeDate) {\n return localeDate;\n }\n\n if (DAY_MONTH_YEAR_PATTERN.test(trimmedValue) || MONTH_DAY_YEAR_PATTERN.test(trimmedValue)) {\n return null;\n }\n\n const parsedDate = new Date(trimmedValue);\n return isValidDate(parsedDate) ? parsedDate : null;\n}\n\nexport function isDateValue(value: unknown): boolean {\n return parseDateValue(value) !== null;\n}\n\nexport function parseBrazilianDate(value: string): Date | null {\n return parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, \"day-first\");\n}\n\nexport function normalizeDateInput(value: DateInput): Date | null {\n return parseDateValue(value);\n}\n\nexport function formatBrazilianDate(value: DateInput): string {\n const date = normalizeDateInput(value);\n return date ? formatDateAsDayMonthYear(date) : \"\";\n}\n\nexport function addDays(date: Date, days: number): Date {\n const nextDate = new Date(date);\n nextDate.setDate(nextDate.getDate() + days);\n return nextDate;\n}\n\nexport type LocaleDateStyle = \"short\" | \"medium\" | \"long\" | \"full\";\n\nexport function formatLocaleDate(\n value: DateInput,\n dateStyle: LocaleDateStyle = \"short\",\n): string {\n const date = normalizeDateInput(value);\n if (!date) {\n return \"\";\n }\n\n return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {\n dateStyle,\n }).format(date);\n}\n\nexport function formatLocaleDateTime(\n value: DateInput,\n options: { dateStyle?: LocaleDateStyle; timeStyle?: LocaleDateStyle } = {},\n): string {\n const date = normalizeDateInput(value);\n if (!date) {\n return \"\";\n }\n\n const { dateStyle = \"short\", timeStyle = \"short\" } = options;\n\n return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {\n dateStyle,\n timeStyle,\n }).format(date);\n}\n\nexport function getDefaultDateRange(days = 60): {\n startDate: string;\n endDate: string;\n} {\n const today = new Date();\n\n return {\n startDate: formatBrazilianDate(addDays(today, -days)),\n endDate: formatBrazilianDate(today),\n };\n}\n\nexport function getRelativeDateRange(daysBack: number): {\n startDate: Date;\n endDate: Date;\n} {\n const endDate = new Date();\n endDate.setHours(23, 59, 59, 999);\n\n const startDate = new Date();\n startDate.setHours(0, 0, 0, 0);\n startDate.setDate(startDate.getDate() - daysBack);\n\n return { startDate, endDate };\n}\n\nexport function toUtcRangeStartIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 0, 3, 0, 0, 0).toISOString() : undefined;\n}\n\nexport function toUtcRangeEndIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 1, 2, 59, 59, 999).toISOString() : undefined;\n}\n\nexport function toUtcDayExclusiveEndIso(value: DateInput): string | undefined {\n const date = normalizeDateInput(value);\n return date ? buildUtcDate(date, 1, 3, 0, 0, 0).toISOString() : undefined;\n}\n","/*\n * Public API Surface of mapa-library-ui authorize\n */\nexport * from './date-fns.util';\nexport * from './date-locale.util';\nexport * from './date.util';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './util';\n"],"names":[],"mappings":";;;AAqBA,MAAM,WAAW,GAAG,qBAAqB;AAEzC,MAAM,eAAe,GAAG,CAAC,aAAqB,KAC5C;AACG,KAAA,UAAU,CAAC,MAAM,EAAE,MAAM;AACzB,KAAA,UAAU,CAAC,IAAI,EAAE,IAAI;AACrB,KAAA,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAElB,MAAM,iBAAiB,GAAG,CAC/B,KAAgB,EAChB,WAAW,GAAG,YAAY,KAClB;AACR,IAAA,IAAI,KAAK,YAAY,IAAI,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC;IACxB;AAEA,IAAA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SAAS;AAC3E;;ACnSA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, DestroyRef, Input, Self, Optional, Directive, EventEmitter, Output, InjectionToken, Injector, signal, Inject, Injectable, Component, SecurityContext, Pipe, ChangeDetectionStrategy, EnvironmentInjector, createComponent, HostListener, ViewChild, forwardRef, effect } from '@angular/core';
|
|
2
|
+
import { inject, DestroyRef, Input, Self, Optional, Directive, EventEmitter, Output, InjectionToken, Injector, signal, Inject, Injectable, Component, SecurityContext, Pipe, ChangeDetectionStrategy, EnvironmentInjector, createComponent, HostListener, ViewChild, forwardRef, ElementRef, effect } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { fromEvent, ReplaySubject } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/material/input';
|
|
@@ -4643,9 +4643,15 @@ function toDatepickerLocale(language) {
|
|
|
4643
4643
|
function getDateFormatByLanguage(language) {
|
|
4644
4644
|
return language === 'en' ? 'MM/DD/YYYY' : 'DD/MM/YYYY';
|
|
4645
4645
|
}
|
|
4646
|
+
function getDateTimeFormatByLanguage(language) {
|
|
4647
|
+
return language === 'en' ? 'MM/DD/YYYY HH:mm' : 'DD/MM/YYYY HH:mm';
|
|
4648
|
+
}
|
|
4646
4649
|
function formatDateByLanguage(value, language) {
|
|
4647
4650
|
return formatDateValue(value, getDateFormatByLanguage(language));
|
|
4648
4651
|
}
|
|
4652
|
+
function formatDateTimeByLanguage(value, language) {
|
|
4653
|
+
return formatDateValue(value, getDateTimeFormatByLanguage(language));
|
|
4654
|
+
}
|
|
4649
4655
|
function isValidDateByLanguage(value, language) {
|
|
4650
4656
|
if (!value) {
|
|
4651
4657
|
return false;
|
|
@@ -6367,6 +6373,104 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImpo
|
|
|
6367
6373
|
* Public API Surface of mapa-library-ui dropdown-tree
|
|
6368
6374
|
*/
|
|
6369
6375
|
|
|
6376
|
+
class MapaDropdownV2Component {
|
|
6377
|
+
constructor() {
|
|
6378
|
+
this.hostElement = inject((ElementRef));
|
|
6379
|
+
this.isOpenState = signal(false, ...(ngDevMode ? [{ debugName: "isOpenState" }] : []));
|
|
6380
|
+
}
|
|
6381
|
+
isOpen() {
|
|
6382
|
+
return this.isOpenState();
|
|
6383
|
+
}
|
|
6384
|
+
selectedLabel() {
|
|
6385
|
+
return this.formControl.value?.value || this.element.placeholder || "";
|
|
6386
|
+
}
|
|
6387
|
+
options() {
|
|
6388
|
+
return this.element.options ?? [];
|
|
6389
|
+
}
|
|
6390
|
+
filteredOptions() {
|
|
6391
|
+
const options = this.options();
|
|
6392
|
+
const searchTerm = this.searchControl?.value?.trim().toLocaleLowerCase() ?? "";
|
|
6393
|
+
if (!searchTerm) {
|
|
6394
|
+
return options;
|
|
6395
|
+
}
|
|
6396
|
+
return options.filter((option) => option.value?.toLocaleLowerCase().includes(searchTerm));
|
|
6397
|
+
}
|
|
6398
|
+
hasSearch() {
|
|
6399
|
+
return !!this.searchControl;
|
|
6400
|
+
}
|
|
6401
|
+
searchPlaceholder() {
|
|
6402
|
+
return this.element.search?.placeholder ?? "";
|
|
6403
|
+
}
|
|
6404
|
+
shouldShowRequiredError() {
|
|
6405
|
+
return (this.formControl.invalid &&
|
|
6406
|
+
(this.formControl.dirty || this.formControl.touched));
|
|
6407
|
+
}
|
|
6408
|
+
toggleDropdown() {
|
|
6409
|
+
const isOpening = !this.isOpenState();
|
|
6410
|
+
this.isOpenState.set(isOpening);
|
|
6411
|
+
if (isOpening) {
|
|
6412
|
+
this.searchControl?.setValue("", { emitEvent: true });
|
|
6413
|
+
setTimeout(() => {
|
|
6414
|
+
this.triggerButton?.nativeElement.blur();
|
|
6415
|
+
this.searchInput?.nativeElement.focus();
|
|
6416
|
+
this.searchInput?.nativeElement.select();
|
|
6417
|
+
});
|
|
6418
|
+
return;
|
|
6419
|
+
}
|
|
6420
|
+
this.markAsTouchedIfEmpty();
|
|
6421
|
+
}
|
|
6422
|
+
selectOption(option) {
|
|
6423
|
+
this.formControl.setValue(option);
|
|
6424
|
+
this.formControl.markAsDirty();
|
|
6425
|
+
this.formControl.markAsTouched();
|
|
6426
|
+
this.closeDropdown();
|
|
6427
|
+
}
|
|
6428
|
+
closeDropdown() {
|
|
6429
|
+
this.isOpenState.set(false);
|
|
6430
|
+
this.searchControl?.setValue("", { emitEvent: true });
|
|
6431
|
+
this.markAsTouchedIfEmpty();
|
|
6432
|
+
}
|
|
6433
|
+
handleDocumentClick(event) {
|
|
6434
|
+
if (this.isOpenState() &&
|
|
6435
|
+
!this.hostElement.nativeElement.contains(event.target)) {
|
|
6436
|
+
this.closeDropdown();
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
get searchControl() {
|
|
6440
|
+
return this.element.search?.formControl;
|
|
6441
|
+
}
|
|
6442
|
+
markAsTouchedIfEmpty() {
|
|
6443
|
+
if (!this.formControl.value) {
|
|
6444
|
+
this.formControl.markAsTouched();
|
|
6445
|
+
}
|
|
6446
|
+
}
|
|
6447
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaDropdownV2Component, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6448
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaDropdownV2Component, isStandalone: true, selector: "mapa-dropdown-v2", inputs: { element: "element", formControl: "formControl" }, host: { listeners: { "document:click": "handleDocumentClick($event)" } }, viewQueries: [{ propertyName: "triggerButton", first: true, predicate: ["triggerButton"], descendants: true }, { propertyName: "searchInput", first: true, predicate: ["searchInput"], descendants: true }], ngImport: i0, template: "<div\n class=\"mapa-dropdown-v2\"\n [class.mapa-dropdown-v2--open]=\"isOpen()\"\n [class.mapa-dropdown-v2--invalid]=\"shouldShowRequiredError()\"\n>\n @if (element.label) {\n <label class=\"mapa-dropdown-v2__label\" [attr.for]=\"element.key || null\">\n {{ element.label }}\n </label>\n }\n\n <button\n #triggerButton\n class=\"mapa-dropdown-v2__trigger\"\n [id]=\"element.key || null\"\n type=\"button\"\n (click)=\"toggleDropdown()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-haspopup]=\"true\"\n >\n <span\n class=\"mapa-dropdown-v2__trigger-text\"\n [class.mapa-dropdown-v2__trigger-text--placeholder]=\"!formControl.value\"\n >\n {{ selectedLabel() }}\n </span>\n </button>\n\n @if (isOpen()) {\n <div class=\"mapa-dropdown-v2__panel\">\n @if (hasSearch()) {\n <input\n #searchInput\n class=\"mapa-dropdown-v2__search-input\"\n type=\"text\"\n [formControl]=\"searchControl!\"\n [placeholder]=\"searchPlaceholder()\"\n />\n }\n\n <div class=\"mapa-dropdown-v2__options\" role=\"listbox\">\n @for (option of filteredOptions(); track option.key) {\n <button\n class=\"mapa-dropdown-v2__option\"\n [class.mapa-dropdown-v2__option--selected]=\"\n formControl.value?.key === option.key\n \"\n type=\"button\"\n (click)=\"selectOption(option)\"\n >\n {{ option.value }}\n </button>\n }\n\n @if (!filteredOptions().length) {\n <p class=\"mapa-dropdown-v2__empty-state\">\n {{ element.search?.noEntriesFoundLabel }}\n </p>\n }\n </div>\n </div>\n }\n\n @if (shouldShowRequiredError() && element.errors?.['required']) {\n <p class=\"mapa-dropdown-v2__error\">\n {{ element.errors?.['required'] }}\n </p>\n }\n</div>\n", styles: [".mapa-dropdown-v2{position:relative;display:inline-block;max-width:min-content;min-width:235px}.mapa-dropdown-v2__label{display:inline-block;margin-bottom:8px;color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-heading, \"Asap\", sans-serif);font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.mapa-dropdown-v2__trigger,.mapa-dropdown-v2__search-input,.mapa-dropdown-v2__option{width:100%;min-height:48px;padding:12px 16px;border:0;background:var(--mapa-color-surface, #ffffff);color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-body, \"Asap\", sans-serif);font-size:16px;line-height:24px}.mapa-dropdown-v2__trigger:focus,.mapa-dropdown-v2__search-input:focus,.mapa-dropdown-v2__option:focus{outline:none}.mapa-dropdown-v2__trigger::placeholder,.mapa-dropdown-v2__search-input::placeholder,.mapa-dropdown-v2__option::placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__trigger{position:relative;display:flex;align-items:center;text-align:left;cursor:pointer;padding-right:46px;border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .18));border-radius:var(--mapa-radius-sm, 12px);transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease}.mapa-dropdown-v2__trigger:after{content:\"\";position:absolute;top:50%;right:18px;width:9px;height:9px;border-right:2px solid var(--mapa-color-ink, #1a1a1a);border-bottom:2px solid var(--mapa-color-ink, #1a1a1a);transform:translateY(-70%) rotate(45deg);transition:transform .2s ease;pointer-events:none}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger,.mapa-dropdown-v2__trigger:focus{border-color:var(--mapa-color-accent, #ff560b);box-shadow:0 0 0 3px #ff560b1f}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger:after{transform:translateY(-20%) rotate(-135deg)}.mapa-dropdown-v2__trigger-text{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--mapa-color-ink, #1a1a1a)}.mapa-dropdown-v2__trigger-text--placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__panel{position:absolute;top:calc(100% + 8px);left:0;right:0;z-index:20;background:var(--mapa-color-surface, #ffffff);border:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));border-radius:var(--mapa-radius-md, 16px);box-shadow:var(--mapa-shadow-panel, 0 18px 40px rgba(26, 26, 26, .08));overflow:hidden}.mapa-dropdown-v2__search-input{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}.mapa-dropdown-v2__options{background:var(--mapa-color-surface, #ffffff);max-height:240px;overflow-y:auto}.mapa-dropdown-v2__option{display:flex;align-items:center;text-align:left;cursor:pointer;min-height:44px;transition:background-color .2s ease,color .2s ease}.mapa-dropdown-v2__option:hover{background:#ff560b14}.mapa-dropdown-v2__option--selected{background:#ff560b1f;color:var(--mapa-color-accent, #ff560b)}.mapa-dropdown-v2__empty-state{margin:0;padding:14px 16px;color:var(--mapa-color-muted, #555555);font-size:14px;line-height:20px}.mapa-dropdown-v2--invalid .mapa-dropdown-v2__trigger{border-color:#b54242;box-shadow:0 0 0 3px #b542421f}.mapa-dropdown-v2__error{display:block;margin:8px 0 0;padding-left:4px;color:#b54242;font-size:13px;line-height:18px}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
6449
|
+
}
|
|
6450
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaDropdownV2Component, decorators: [{
|
|
6451
|
+
type: Component,
|
|
6452
|
+
args: [{ selector: "mapa-dropdown-v2", standalone: true, imports: [ReactiveFormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"mapa-dropdown-v2\"\n [class.mapa-dropdown-v2--open]=\"isOpen()\"\n [class.mapa-dropdown-v2--invalid]=\"shouldShowRequiredError()\"\n>\n @if (element.label) {\n <label class=\"mapa-dropdown-v2__label\" [attr.for]=\"element.key || null\">\n {{ element.label }}\n </label>\n }\n\n <button\n #triggerButton\n class=\"mapa-dropdown-v2__trigger\"\n [id]=\"element.key || null\"\n type=\"button\"\n (click)=\"toggleDropdown()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-haspopup]=\"true\"\n >\n <span\n class=\"mapa-dropdown-v2__trigger-text\"\n [class.mapa-dropdown-v2__trigger-text--placeholder]=\"!formControl.value\"\n >\n {{ selectedLabel() }}\n </span>\n </button>\n\n @if (isOpen()) {\n <div class=\"mapa-dropdown-v2__panel\">\n @if (hasSearch()) {\n <input\n #searchInput\n class=\"mapa-dropdown-v2__search-input\"\n type=\"text\"\n [formControl]=\"searchControl!\"\n [placeholder]=\"searchPlaceholder()\"\n />\n }\n\n <div class=\"mapa-dropdown-v2__options\" role=\"listbox\">\n @for (option of filteredOptions(); track option.key) {\n <button\n class=\"mapa-dropdown-v2__option\"\n [class.mapa-dropdown-v2__option--selected]=\"\n formControl.value?.key === option.key\n \"\n type=\"button\"\n (click)=\"selectOption(option)\"\n >\n {{ option.value }}\n </button>\n }\n\n @if (!filteredOptions().length) {\n <p class=\"mapa-dropdown-v2__empty-state\">\n {{ element.search?.noEntriesFoundLabel }}\n </p>\n }\n </div>\n </div>\n }\n\n @if (shouldShowRequiredError() && element.errors?.['required']) {\n <p class=\"mapa-dropdown-v2__error\">\n {{ element.errors?.['required'] }}\n </p>\n }\n</div>\n", styles: [".mapa-dropdown-v2{position:relative;display:inline-block;max-width:min-content;min-width:235px}.mapa-dropdown-v2__label{display:inline-block;margin-bottom:8px;color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-heading, \"Asap\", sans-serif);font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.mapa-dropdown-v2__trigger,.mapa-dropdown-v2__search-input,.mapa-dropdown-v2__option{width:100%;min-height:48px;padding:12px 16px;border:0;background:var(--mapa-color-surface, #ffffff);color:var(--mapa-color-ink, #1a1a1a);font-family:var(--mapa-font-body, \"Asap\", sans-serif);font-size:16px;line-height:24px}.mapa-dropdown-v2__trigger:focus,.mapa-dropdown-v2__search-input:focus,.mapa-dropdown-v2__option:focus{outline:none}.mapa-dropdown-v2__trigger::placeholder,.mapa-dropdown-v2__search-input::placeholder,.mapa-dropdown-v2__option::placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__trigger{position:relative;display:flex;align-items:center;text-align:left;cursor:pointer;padding-right:46px;border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .18));border-radius:var(--mapa-radius-sm, 12px);transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease}.mapa-dropdown-v2__trigger:after{content:\"\";position:absolute;top:50%;right:18px;width:9px;height:9px;border-right:2px solid var(--mapa-color-ink, #1a1a1a);border-bottom:2px solid var(--mapa-color-ink, #1a1a1a);transform:translateY(-70%) rotate(45deg);transition:transform .2s ease;pointer-events:none}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger,.mapa-dropdown-v2__trigger:focus{border-color:var(--mapa-color-accent, #ff560b);box-shadow:0 0 0 3px #ff560b1f}.mapa-dropdown-v2--open .mapa-dropdown-v2__trigger:after{transform:translateY(-20%) rotate(-135deg)}.mapa-dropdown-v2__trigger-text{display:block;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--mapa-color-ink, #1a1a1a)}.mapa-dropdown-v2__trigger-text--placeholder{color:var(--mapa-color-muted, #555555)}.mapa-dropdown-v2__panel{position:absolute;top:calc(100% + 8px);left:0;right:0;z-index:20;background:var(--mapa-color-surface, #ffffff);border:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));border-radius:var(--mapa-radius-md, 16px);box-shadow:var(--mapa-shadow-panel, 0 18px 40px rgba(26, 26, 26, .08));overflow:hidden}.mapa-dropdown-v2__search-input{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}.mapa-dropdown-v2__options{background:var(--mapa-color-surface, #ffffff);max-height:240px;overflow-y:auto}.mapa-dropdown-v2__option{display:flex;align-items:center;text-align:left;cursor:pointer;min-height:44px;transition:background-color .2s ease,color .2s ease}.mapa-dropdown-v2__option:hover{background:#ff560b14}.mapa-dropdown-v2__option--selected{background:#ff560b1f;color:var(--mapa-color-accent, #ff560b)}.mapa-dropdown-v2__empty-state{margin:0;padding:14px 16px;color:var(--mapa-color-muted, #555555);font-size:14px;line-height:20px}.mapa-dropdown-v2--invalid .mapa-dropdown-v2__trigger{border-color:#b54242;box-shadow:0 0 0 3px #b542421f}.mapa-dropdown-v2__error{display:block;margin:8px 0 0;padding-left:4px;color:#b54242;font-size:13px;line-height:18px}\n"] }]
|
|
6453
|
+
}], propDecorators: { element: [{
|
|
6454
|
+
type: Input,
|
|
6455
|
+
args: [{ required: true }]
|
|
6456
|
+
}], formControl: [{
|
|
6457
|
+
type: Input,
|
|
6458
|
+
args: [{ required: true }]
|
|
6459
|
+
}], triggerButton: [{
|
|
6460
|
+
type: ViewChild,
|
|
6461
|
+
args: ["triggerButton"]
|
|
6462
|
+
}], searchInput: [{
|
|
6463
|
+
type: ViewChild,
|
|
6464
|
+
args: ["searchInput"]
|
|
6465
|
+
}], handleDocumentClick: [{
|
|
6466
|
+
type: HostListener,
|
|
6467
|
+
args: ["document:click", ["$event"]]
|
|
6468
|
+
}] } });
|
|
6469
|
+
|
|
6470
|
+
/*
|
|
6471
|
+
* Public API Surface of mapa-library-ui dropdown-v2
|
|
6472
|
+
*/
|
|
6473
|
+
|
|
6370
6474
|
class MapaEmptyStateComponent {
|
|
6371
6475
|
constructor() {
|
|
6372
6476
|
this.title = null;
|
|
@@ -7866,5 +7970,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImpo
|
|
|
7866
7970
|
* Generated bundle index. Do not edit.
|
|
7867
7971
|
*/
|
|
7868
7972
|
|
|
7869
|
-
export { AIH_ESTADOS, AIH_TIPOS, BubblePaginationDirective, ButtonComponent, ButtonIconComponent, CEPRange, CID_NAME, CID_REGEX, CORES, CPFPipe, CapabilityClassificationService, CheckboxComponent, Datepicker, DatepickerRange, Dropdown, DropdownTree, ESTADOS, ESTADOS_SIGLA, ElementBase, FiltersComponent, HtmlSanitizerService, IPTUCREATE, IPTUMASKS, IPTUVALIDATE, IconComponent, InputText, LOCALIZACAO_BAIRROS, LOCALIZACAO_CIDADES, LOCALIZACAO_COMPLEMENTOS, LOCALIZACAO_ESTADOS, LOCALIZACAO_LOGRADOUROS, LOCALIZACAO_RUAS, LocaleDatePipe, LocaleDateTimePipe, MAPA_DATEPICKER_FORMATS, MAPA_UI_TEXTS, MASKSIE, MapaBenchmarkChartComponent, MapaBenchmarkIndicatorComponent, MapaBreadcrumbComponent, MapaCapabilityComparativeChartComponent, MapaCapabilityComparativeComponent, MapaCapabilityComparativeHeaderComponent, MapaCapabilityDetailComponent, MapaCapabilityDotComponent, MapaCapabilityExpandComponent, MapaCapabilityIndicatorChartComponent, MapaCapabilityIndicatorComponent, MapaCapabilityIndicatorListComponent, MapaCapabilityIntervalBarComponent, MapaCapabilityIntervalComponent, MapaChartComponent, MapaDatepicker, MapaDatepickerRange, MapaDetailsComponent, MapaDialogComponent, MapaDropdownComponent, MapaDropdownTreeComponent, MapaEmptyStateComponent, MapaFormComponent, MapaFormErrorsComponent, MapaGroupReportComponent, MapaI18nService, MapaInputComponent, MapaMenuComponent, MapaNavListComponent, MapaProgressbarComponent, MapaScaleComponent, MapaScaleParameterizationComponent, MapaSvgIconComponent, MapaTableComponent, MapaTextareaComponent, MapaTooltipComponent, MapaTooltipDirective, MapaWarningComponent, MatInputAutosizeDirective, PLACAS_INVALID, PLACAS_RANGE, RadioButton, RadioButtonComponent, ReportItemComponent, SafeHtmlPipe, SlideToggle, SlideToggleComponent, TagComponent, Textarea, ValidationMessageResolverService, addDays, addMonthsToDateValue, allNumbersAreSame, buildDetailedIndicatorSections, buildIndicatorCollections, cep_ranges, create_aih, create_cartaocredito, create_certidao, create_cnh, create_cnhespelho, create_cnpj, create_cns, create_cpf, create_ect, create_iptu, create_iptu_ctba, create_iptu_sp, create_pispasep, create_processo, create_renachestadual, create_renachseguranca, create_renavam, create_titulo, create_titulo_atual, creditCardValidator, currencyToNumber, customPaginatorFactory, faker_iptu, fillString, formatBrazilianDate, formatDateAsDayMonthYear, formatDateAsMonthDayYear, formatDateByLanguage, formatDateForLocale, formatDateValue, formatLocaleDate, formatLocaleDateTime, generateInscricaoEstadual, getActiveDateFormat, getActiveDateLocale, getActiveMaterialDateFormat, getAllDigits, getAllWords, getDateFormatByLanguage, getDateInputMask, getDayOfMonthFromDateValue, getDefaultDateRange, getMapaDatepickerRangeFormats, getRelativeDateRange, getSpecialProperty, getYearFromDateValue, isAfterDateValue, isArray, isDateValue, isMonthFirstDateLocale, isNil, isNumber, isPresent, isString, isValidDateByLanguage, isValidDateValue, makeGenericFaker, maskBr, mask_iptu, mergeMapaUiTexts, modulo11, modulo11Custom, modulo11a, normalizeDateInput, normalizeDateLocale, normalizeLookup, normalizeText, numberToCurrency, openDialog, parseBrazilianDate, parseDateByLanguage, parseDateValue, parseDateValueFns, parseLocaleDateValue, processCaretTraps, provideMapaUiTexts, rand, randArray, randomEstadoSigla, randomLetter, randomLetterOrNumber, randomNumber, reformatDateStringForLanguage, rg_rj, rg_sp, sanitizeHtmlContent, setTimeOnDateValue, slugify, toDatepickerLocale, toIsoDateByLanguage, toIsoDateByLanguageWithUtcTime, toIsoDateValue, toIsoDateValueWithTime, toIsoDateValueWithUtcTime, toUtcDayExclusiveEndIso, toUtcRangeEndIso, toUtcRangeStartIso, utilsBr, validateBr, validate_aih, validate_cartaocredito, validate_celular, validate_cep, validate_certidao, validate_chassi, validate_cnh, validate_cnhespelho, validate_cnpj, validate_cns, validate_cpf, validate_currency, validate_datahora, validate_datetime, validate_ect, validate_inscricaoestadual, validate_iptu, validate_iptu_contagem, validate_iptu_ctba, validate_iptu_sp, validate_number, validate_pispasep, validate_placa, validate_porcentagem, validate_processo, validate_renachestadual, validate_renachseguranca, validate_renavam, validate_rg, validate_sped, validate_telefone, validate_time, validate_titulo };
|
|
7973
|
+
export { AIH_ESTADOS, AIH_TIPOS, BubblePaginationDirective, ButtonComponent, ButtonIconComponent, CEPRange, CID_NAME, CID_REGEX, CORES, CPFPipe, CapabilityClassificationService, CheckboxComponent, Datepicker, DatepickerRange, Dropdown, DropdownTree, ESTADOS, ESTADOS_SIGLA, ElementBase, FiltersComponent, HtmlSanitizerService, IPTUCREATE, IPTUMASKS, IPTUVALIDATE, IconComponent, InputText, LOCALIZACAO_BAIRROS, LOCALIZACAO_CIDADES, LOCALIZACAO_COMPLEMENTOS, LOCALIZACAO_ESTADOS, LOCALIZACAO_LOGRADOUROS, LOCALIZACAO_RUAS, LocaleDatePipe, LocaleDateTimePipe, MAPA_DATEPICKER_FORMATS, MAPA_UI_TEXTS, MASKSIE, MapaBenchmarkChartComponent, MapaBenchmarkIndicatorComponent, MapaBreadcrumbComponent, MapaCapabilityComparativeChartComponent, MapaCapabilityComparativeComponent, MapaCapabilityComparativeHeaderComponent, MapaCapabilityDetailComponent, MapaCapabilityDotComponent, MapaCapabilityExpandComponent, MapaCapabilityIndicatorChartComponent, MapaCapabilityIndicatorComponent, MapaCapabilityIndicatorListComponent, MapaCapabilityIntervalBarComponent, MapaCapabilityIntervalComponent, MapaChartComponent, MapaDatepicker, MapaDatepickerRange, MapaDetailsComponent, MapaDialogComponent, MapaDropdownComponent, MapaDropdownTreeComponent, MapaDropdownV2Component, MapaEmptyStateComponent, MapaFormComponent, MapaFormErrorsComponent, MapaGroupReportComponent, MapaI18nService, MapaInputComponent, MapaMenuComponent, MapaNavListComponent, MapaProgressbarComponent, MapaScaleComponent, MapaScaleParameterizationComponent, MapaSvgIconComponent, MapaTableComponent, MapaTextareaComponent, MapaTooltipComponent, MapaTooltipDirective, MapaWarningComponent, MatInputAutosizeDirective, PLACAS_INVALID, PLACAS_RANGE, RadioButton, RadioButtonComponent, ReportItemComponent, SafeHtmlPipe, SlideToggle, SlideToggleComponent, TagComponent, Textarea, ValidationMessageResolverService, addDays, addMonthsToDateValue, allNumbersAreSame, buildDetailedIndicatorSections, buildIndicatorCollections, cep_ranges, create_aih, create_cartaocredito, create_certidao, create_cnh, create_cnhespelho, create_cnpj, create_cns, create_cpf, create_ect, create_iptu, create_iptu_ctba, create_iptu_sp, create_pispasep, create_processo, create_renachestadual, create_renachseguranca, create_renavam, create_titulo, create_titulo_atual, creditCardValidator, currencyToNumber, customPaginatorFactory, faker_iptu, fillString, formatBrazilianDate, formatDateAsDayMonthYear, formatDateAsMonthDayYear, formatDateByLanguage, formatDateForLocale, formatDateTimeByLanguage, formatDateValue, formatLocaleDate, formatLocaleDateTime, generateInscricaoEstadual, getActiveDateFormat, getActiveDateLocale, getActiveMaterialDateFormat, getAllDigits, getAllWords, getDateFormatByLanguage, getDateInputMask, getDateTimeFormatByLanguage, getDayOfMonthFromDateValue, getDefaultDateRange, getMapaDatepickerRangeFormats, getRelativeDateRange, getSpecialProperty, getYearFromDateValue, isAfterDateValue, isArray, isDateValue, isMonthFirstDateLocale, isNil, isNumber, isPresent, isString, isValidDateByLanguage, isValidDateValue, makeGenericFaker, maskBr, mask_iptu, mergeMapaUiTexts, modulo11, modulo11Custom, modulo11a, normalizeDateInput, normalizeDateLocale, normalizeLookup, normalizeText, numberToCurrency, openDialog, parseBrazilianDate, parseDateByLanguage, parseDateValue, parseDateValueFns, parseLocaleDateValue, processCaretTraps, provideMapaUiTexts, rand, randArray, randomEstadoSigla, randomLetter, randomLetterOrNumber, randomNumber, reformatDateStringForLanguage, rg_rj, rg_sp, sanitizeHtmlContent, setTimeOnDateValue, slugify, toDatepickerLocale, toIsoDateByLanguage, toIsoDateByLanguageWithUtcTime, toIsoDateValue, toIsoDateValueWithTime, toIsoDateValueWithUtcTime, toUtcDayExclusiveEndIso, toUtcRangeEndIso, toUtcRangeStartIso, utilsBr, validateBr, validate_aih, validate_cartaocredito, validate_celular, validate_cep, validate_certidao, validate_chassi, validate_cnh, validate_cnhespelho, validate_cnpj, validate_cns, validate_cpf, validate_currency, validate_datahora, validate_datetime, validate_ect, validate_inscricaoestadual, validate_iptu, validate_iptu_contagem, validate_iptu_ctba, validate_iptu_sp, validate_number, validate_pispasep, validate_placa, validate_porcentagem, validate_processo, validate_renachestadual, validate_renachseguranca, validate_renavam, validate_rg, validate_sped, validate_telefone, validate_time, validate_titulo };
|
|
7870
7974
|
//# sourceMappingURL=mapa-library-ui.mjs.map
|