@cauca-911/material 20.2.12 → 20.2.13
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/.eslintrc.json +77 -0
- package/README.md +24 -5
- package/README_PACKAGE.md +5 -0
- package/karma.conf.js +50 -0
- package/ng-package.json +7 -0
- package/package.json +23 -38
- package/{assets → src/assets}/i18n/cauca/en-material.json +104 -104
- package/{assets → src/assets}/i18n/cauca/es-material.json +104 -104
- package/{assets → src/assets}/i18n/cauca/fr-material.json +106 -106
- package/src/lib/cauca-material.component.html +1 -0
- package/src/lib/cauca-material.component.spec.ts +29 -0
- package/src/lib/cauca-material.component.ts +12 -0
- package/src/lib/cauca-material.service.spec.ts +16 -0
- package/src/lib/cauca-material.service.ts +7 -0
- package/src/lib/components/button/button.component.html +52 -0
- package/src/lib/components/button/button.component.scss +6 -0
- package/src/lib/components/button/button.component.spec.ts +134 -0
- package/src/lib/components/button/button.component.ts +21 -0
- package/src/lib/components/buttons/base-button.ts +35 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.html +5 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.scss +12 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.ts +17 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.html +3 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.scss +12 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.spec.ts +82 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.ts +16 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.html +5 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.scss +12 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.ts +17 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.html +3 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.scss +23 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.spec.ts +38 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.ts +15 -0
- package/src/lib/components/buttons/link-button/link-button.component.html +1 -0
- package/src/lib/components/buttons/link-button/link-button.component.scss +3 -0
- package/src/lib/components/buttons/link-button/link-button.component.spec.ts +97 -0
- package/src/lib/components/buttons/link-button/link-button.component.ts +25 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.html +5 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.scss +6 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.spec.ts +66 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.ts +19 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.html +5 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.scss +12 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.spec.ts +108 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.ts +17 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.html +1 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.scss +0 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.spec.ts +81 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.ts +19 -0
- package/src/lib/components/buttons/round-button/round-button.component.html +3 -0
- package/src/lib/components/buttons/round-button/round-button.component.scss +34 -0
- package/src/lib/components/buttons/round-button/round-button.component.spec.ts +26 -0
- package/src/lib/components/buttons/round-button/round-button.component.ts +14 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.html +5 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.scss +23 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.spec.ts +114 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.ts +17 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.scss +7 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.spec.ts +68 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.ts +155 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.html +6 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.scss +25 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.spec.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.html +53 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.scss +124 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.spec.ts +93 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.ts +227 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.scss +15 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.spec.ts +103 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.ts +47 -0
- package/src/lib/components/cauca-date-time-picker/models/dialog-date-time-picker-data.ts +29 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.html +11 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.ts +87 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.html +8 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.spec.ts +35 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.ts +57 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.html +19 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.scss +142 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.spec.ts +30 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.ts +112 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.html +26 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.scss +52 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.spec.ts +28 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.ts +53 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.html +7 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.scss +4 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.spec.ts +39 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.ts +20 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.html +7 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.scss +41 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.spec.ts +24 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.ts +67 -0
- package/src/lib/components/deprecated-components/shared/models/menu-item.ts +11 -0
- package/src/lib/components/deprecated-components/shared/models/simple-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.html +10 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.spec.ts +90 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.ts +41 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.html +11 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.scss +29 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.spec.ts +137 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.ts +47 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.html +17 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.spec.ts +96 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.ts +40 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.spec.ts +7 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/dialog-styles.css +9 -0
- package/src/lib/components/dialogs/dialog-styles.scss +9 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.html +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.scss +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.spec.ts +91 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.ts +32 -0
- package/src/lib/components/dialogs/services/dialog.service.spec.ts +82 -0
- package/src/lib/components/dialogs/services/dialog.service.ts +107 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.html +24 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.scss +22 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.spec.ts +126 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.ts +66 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.html +9 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.scss +0 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.spec.ts +29 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.ts +111 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.html +13 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.scss +0 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.spec.ts +80 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.ts +46 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.html +40 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.scss +39 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.spec.ts +135 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.ts +263 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.html +6 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.scss +27 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.spec.ts +90 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.ts +17 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.html +5 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.scss +8 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.spec.ts +98 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.ts +16 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.html +11 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.scss +12 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.spec.ts +141 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.ts +67 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.html +15 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.scss +32 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.spec.ts +138 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.ts +100 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.html +19 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.scss +0 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.spec.ts +213 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.ts +108 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.html +12 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.scss +43 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.spec.ts +48 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.ts +19 -0
- package/src/lib/components/layout/group-container/group-container.component.html +6 -0
- package/src/lib/components/layout/group-container/group-container.component.scss +22 -0
- package/src/lib/components/layout/group-container/group-container.component.spec.ts +34 -0
- package/src/lib/components/layout/group-container/group-container.component.ts +14 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.html +13 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.scss +27 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.spec.ts +144 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.ts +52 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.html +4 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.scss +10 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.spec.ts +80 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.ts +28 -0
- package/src/lib/components/layout/page-title/page-title.component.html +28 -0
- package/src/lib/components/layout/page-title/page-title.component.scss +40 -0
- package/src/lib/components/layout/page-title/page-title.component.spec.ts +162 -0
- package/src/lib/components/layout/page-title/page-title.component.ts +28 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.html +6 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.scss +27 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.spec.ts +42 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.ts +13 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.html +3 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.scss +18 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.spec.ts +35 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.ts +12 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.html +21 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.scss +44 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.spec.ts +74 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.ts +22 -0
- package/src/lib/components/list-paginator/list-paginator.component.html +16 -0
- package/src/lib/components/list-paginator/list-paginator.component.scss +46 -0
- package/src/lib/components/list-paginator/list-paginator.component.spec.ts +248 -0
- package/src/lib/components/list-paginator/list-paginator.component.ts +81 -0
- package/src/lib/components/misc/loading-error/loading-error.component.html +11 -0
- package/src/lib/components/misc/loading-error/loading-error.component.scss +0 -0
- package/src/lib/components/misc/loading-error/loading-error.component.spec.ts +75 -0
- package/src/lib/components/misc/loading-error/loading-error.component.ts +18 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.html +3 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.scss +0 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.spec.ts +43 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.ts +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.html +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.scss +84 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.spec.ts +136 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.ts +39 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.html +11 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.spec.ts +67 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.ts +15 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.html +11 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.spec.ts +77 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.ts +17 -0
- package/src/lib/components/presenters/badge/badge.component.html +6 -0
- package/src/lib/components/presenters/badge/badge.component.scss +10 -0
- package/src/lib/components/presenters/badge/badge.component.spec.ts +41 -0
- package/src/lib/components/presenters/badge/badge.component.ts +18 -0
- package/src/lib/components/presenters/icon/icon.component.scss +9 -0
- package/src/lib/components/presenters/icon/icon.component.spec.ts +38 -0
- package/src/lib/components/presenters/icon/icon.component.ts +37 -0
- package/src/lib/core/breadcrumb.service.spec.ts +35 -0
- package/src/lib/core/breadcrumb.service.ts +24 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.spec.ts +22 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.ts +19 -0
- package/src/lib/core/directives/form-error/form-error.module.ts +21 -0
- package/src/lib/core/directives/form-error/has-error-root.directive.ts +29 -0
- package/src/lib/core/directives/form-error/has-error.directive.ts +95 -0
- package/src/lib/core/loading-state.service.spec.ts +57 -0
- package/src/lib/core/loading-state.service.ts +44 -0
- package/src/lib/core/models/breadcrumb-location.ts +6 -0
- package/src/lib/core/models/password-validation.ts +20 -0
- package/src/lib/core/validators/password/password-validator.spec.ts +155 -0
- package/src/lib/core/validators/password/password-validator.ts +30 -0
- package/src/lib/provide-cauca-material.ts +10 -0
- package/src/public-api.ts +74 -0
- package/src/test.ts +17 -0
- package/tsconfig.lib.json +22 -0
- package/tsconfig.lib.prod.json +4 -0
- package/tsconfig.spec.json +17 -0
- package/LICENSE +0 -21
- package/fesm2022/cauca-911-material.mjs +0 -4640
- package/fesm2022/cauca-911-material.mjs.map +0 -1
- package/index.d.ts +0 -795
- /package/{assets → src/assets}/images/loading.gif +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Component, ElementRef, EventEmitter, HostBinding, Input, OnDestroy, Optional, Output, Self } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
3
|
+
import { MatFormFieldControl } from '@angular/material/form-field';
|
|
4
|
+
import { MatInputModule } from '@angular/material/input';
|
|
5
|
+
import { ColorPickerDirective } from 'ngx-color-picker';
|
|
6
|
+
import { Subject } from 'rxjs';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'cauca-color-picker',
|
|
10
|
+
imports: [MatInputModule, ColorPickerDirective],
|
|
11
|
+
templateUrl: './color-picker.component.html',
|
|
12
|
+
styleUrl: './color-picker.component.scss',
|
|
13
|
+
providers: [{
|
|
14
|
+
provide: MatFormFieldControl,
|
|
15
|
+
useExisting: ColorPickerComponent,
|
|
16
|
+
}]
|
|
17
|
+
})
|
|
18
|
+
export class ColorPickerComponent implements ControlValueAccessor, MatFormFieldControl<string>, OnDestroy {
|
|
19
|
+
|
|
20
|
+
public stateChanges = new Subject<void>();
|
|
21
|
+
public static nextId = 0;
|
|
22
|
+
|
|
23
|
+
@HostBinding()public id = `example-tel-input-${ColorPickerComponent.nextId++}`;
|
|
24
|
+
public placeholder: string;
|
|
25
|
+
public focused: boolean = false;
|
|
26
|
+
public touched = false;
|
|
27
|
+
public required: boolean;
|
|
28
|
+
public disabled: boolean;
|
|
29
|
+
public errorState: boolean;
|
|
30
|
+
public controlType?: string;
|
|
31
|
+
public autofilled?: boolean;
|
|
32
|
+
public userAriaDescribedBy?: string;
|
|
33
|
+
@Output() public valueChanged = new EventEmitter<string>();
|
|
34
|
+
private _value: string;
|
|
35
|
+
@HostBinding('class.floating')
|
|
36
|
+
public get shouldLabelFloat() {
|
|
37
|
+
return this.focused || !this.empty;
|
|
38
|
+
}
|
|
39
|
+
public get empty() {
|
|
40
|
+
return !this._value?.length;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Input()
|
|
44
|
+
public get value(): string | null {
|
|
45
|
+
return this._value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public set value(newValue: string | null) {
|
|
49
|
+
this._value = newValue;
|
|
50
|
+
this.onChange(this._value);
|
|
51
|
+
this.stateChanges.next();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public constructor(
|
|
55
|
+
private elementRef: ElementRef<HTMLElement>,
|
|
56
|
+
@Optional() @Self() public ngControl: NgControl) {
|
|
57
|
+
if (this.ngControl != null) {
|
|
58
|
+
this.ngControl.valueAccessor = this;
|
|
59
|
+
}
|
|
60
|
+
elementRef.nativeElement.addEventListener('focusin', this.onFocusIn.bind(this));
|
|
61
|
+
elementRef.nativeElement.addEventListener('focusout', this.onFocusOut.bind(this));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public onFocusIn(_: FocusEvent) {
|
|
65
|
+
if (!this.focused) {
|
|
66
|
+
this.focused = true;
|
|
67
|
+
this.stateChanges.next();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public onFocusOut(event: FocusEvent) {
|
|
72
|
+
if (!this.elementRef.nativeElement.contains(event.relatedTarget as Element)) {
|
|
73
|
+
this.touched = true;
|
|
74
|
+
this.focused = false;
|
|
75
|
+
this.onTouched();
|
|
76
|
+
this.stateChanges.next();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public ngOnDestroy(): void {
|
|
81
|
+
this.stateChanges.complete();
|
|
82
|
+
}
|
|
83
|
+
public setDescribedByIds(_: string[]): void {
|
|
84
|
+
// Do nothing for now
|
|
85
|
+
}
|
|
86
|
+
public onContainerClick(_: MouseEvent): void {
|
|
87
|
+
// Do nothing for now
|
|
88
|
+
}
|
|
89
|
+
public writeValue(value: string): void {
|
|
90
|
+
this.value = value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public registerOnChange(fn: any): void {
|
|
94
|
+
this.onChange = fn;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public registerOnTouched(fn: any): void {
|
|
98
|
+
this.onTouched = fn;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public onChange = (_: any): void => {
|
|
102
|
+
// Do nothing for now
|
|
103
|
+
};
|
|
104
|
+
public onTouched = (): void => {
|
|
105
|
+
// Do nothing for now
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
public onChangeColor(color: string): void {
|
|
109
|
+
this.value = color;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<mat-form-field class="full-width-field" subscriptSizing="dynamic">
|
|
2
|
+
<mat-datepicker-toggle matPrefix (click)="clear()" onkeypress="clear()">
|
|
3
|
+
<mat-icon matDatepickerToggleIcon>clear</mat-icon>
|
|
4
|
+
</mat-datepicker-toggle>
|
|
5
|
+
<mat-label>{{'dateRangeSelectorLabel'|translate}}</mat-label>
|
|
6
|
+
<mat-date-range-input [formGroup]="form" [rangePicker]="campaignOnePicker">
|
|
7
|
+
<input matStartDate formControlName="from" [readOnly]="true">
|
|
8
|
+
<input matEndDate formControlName="to" [readOnly]="true">
|
|
9
|
+
</mat-date-range-input>
|
|
10
|
+
<mat-datepicker-toggle matIconSuffix [for]="campaignOnePicker">
|
|
11
|
+
</mat-datepicker-toggle>
|
|
12
|
+
<mat-date-range-picker #campaignOnePicker></mat-date-range-picker>
|
|
13
|
+
</mat-form-field>
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { DateRangePickerComponent } from './date-range-picker.component';
|
|
4
|
+
import { HarnessLoader } from '@angular/cdk/testing';
|
|
5
|
+
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
|
6
|
+
import { MatDateRangeInputHarness } from '@angular/material/datepicker/testing';
|
|
7
|
+
import { MockModule, MockPipe } from 'ng-mocks';
|
|
8
|
+
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
|
|
9
|
+
|
|
10
|
+
describe('DateRangePickerComponent', () => {
|
|
11
|
+
let component: DateRangePickerComponent;
|
|
12
|
+
let fixture: ComponentFixture<DateRangePickerComponent>;
|
|
13
|
+
let harness: HarnessLoader;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [DateRangePickerComponent, MockModule(TranslateModule)],
|
|
18
|
+
declarations: [MockPipe(TranslatePipe, value => value),],
|
|
19
|
+
})
|
|
20
|
+
.compileComponents();
|
|
21
|
+
|
|
22
|
+
fixture = TestBed.createComponent(DateRangePickerComponent);
|
|
23
|
+
harness = TestbedHarnessEnvironment.loader(fixture);
|
|
24
|
+
component = fixture.componentInstance;
|
|
25
|
+
fixture.detectChanges();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should create', () => {
|
|
29
|
+
expect(component).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should not have a range selected by default', () => {
|
|
33
|
+
expect(component.range()).toEqual({ from: null, to: null });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should update form from date when date picker changes', async () => {
|
|
37
|
+
const selectedDate = new Date();
|
|
38
|
+
const picker = await harness.getHarness(MatDateRangeInputHarness);
|
|
39
|
+
const input = await picker.getStartInput();
|
|
40
|
+
|
|
41
|
+
await input.setValue(selectedDate.toUTCString());
|
|
42
|
+
|
|
43
|
+
expect(component.form.value.from).not.toBeNull();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should update form to date when date picker changes', async () => {
|
|
47
|
+
const selectedDate = new Date();
|
|
48
|
+
const picker = await harness.getHarness(MatDateRangeInputHarness);
|
|
49
|
+
const input = await picker.getEndInput();
|
|
50
|
+
|
|
51
|
+
await input.setValue(selectedDate.toUTCString());
|
|
52
|
+
|
|
53
|
+
expect(component.form.value.to).not.toBeNull();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should clear the form when clear is called', async () => {
|
|
57
|
+
const selectedDate = new Date();
|
|
58
|
+
const picker = await harness.getHarness(MatDateRangeInputHarness);
|
|
59
|
+
const input = await picker.getStartInput();
|
|
60
|
+
|
|
61
|
+
await input.setValue(selectedDate.toUTCString());
|
|
62
|
+
expect(component.form.value.from).not.toBeNull();
|
|
63
|
+
|
|
64
|
+
component.clear();
|
|
65
|
+
expect(component.form.value.from).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should emit new range when form changes', async () => {
|
|
69
|
+
const selectedDate = new Date();
|
|
70
|
+
const picker = await harness.getHarness(MatDateRangeInputHarness);
|
|
71
|
+
const input = await picker.getStartInput();
|
|
72
|
+
|
|
73
|
+
await input.setValue(selectedDate.toUTCString());
|
|
74
|
+
expect(component.range()).toEqual({ from: component.form.value.from, to: null });
|
|
75
|
+
|
|
76
|
+
const toInput = await picker.getEndInput();
|
|
77
|
+
await toInput.setValue(selectedDate.toUTCString());
|
|
78
|
+
expect(component.range()).toEqual({ from: component.form.value.from, to: component.form.value.to });
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, model, OnInit } from '@angular/core';
|
|
2
|
+
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
|
3
|
+
import { provideNativeDateAdapter } from '@angular/material/core';
|
|
4
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
5
|
+
import {MatDatepickerModule} from '@angular/material/datepicker';
|
|
6
|
+
import { MatIcon } from '@angular/material/icon';
|
|
7
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
8
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'cauca-date-range-picker',
|
|
12
|
+
standalone: true,
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
imports: [MatFormFieldModule, MatDatepickerModule, ReactiveFormsModule, MatIcon, TranslateModule],
|
|
15
|
+
templateUrl: './date-range-picker.component.html',
|
|
16
|
+
styleUrl: './date-range-picker.component.scss',
|
|
17
|
+
providers: [provideNativeDateAdapter()]
|
|
18
|
+
})
|
|
19
|
+
export class DateRangePickerComponent implements OnInit {
|
|
20
|
+
public range = model<DateRange>({ from: null, to: null });
|
|
21
|
+
|
|
22
|
+
public readonly form = new FormGroup({
|
|
23
|
+
from: new FormControl(null),
|
|
24
|
+
to: new FormControl(null)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
public constructor() {
|
|
28
|
+
this.form.valueChanges
|
|
29
|
+
.pipe(takeUntilDestroyed())
|
|
30
|
+
.subscribe(value => this.range.set({ from: value.from, to: value.to }));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public ngOnInit(): void {
|
|
34
|
+
this.form.patchValue(this.range());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public clear(): void {
|
|
38
|
+
this.form.patchValue({ from: null, to: null });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DateRange {
|
|
44
|
+
from: Date|null,
|
|
45
|
+
to: Date|null
|
|
46
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<div role="group" class="dropdown-chip-autocomplete-container">
|
|
2
|
+
|
|
3
|
+
<mat-chip-grid #chipGrid [disabled]="disabled">
|
|
4
|
+
|
|
5
|
+
@for (key of value; track key) {
|
|
6
|
+
<mat-chip highlighted [disabled]="disabled" (removed)="removeSelectedItem(key)" color="primary">
|
|
7
|
+
{{getValueDisplay(key)}}
|
|
8
|
+
@if (allowRemove) {
|
|
9
|
+
<mat-icon matChipRemove>cancel</mat-icon>
|
|
10
|
+
}
|
|
11
|
+
</mat-chip>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
<div class="input-wrapper">
|
|
15
|
+
<input
|
|
16
|
+
#chipInput
|
|
17
|
+
[(ngModel)]="searchValue"
|
|
18
|
+
[matAutocomplete]="auto"
|
|
19
|
+
[matChipInputFor]="chipGrid"
|
|
20
|
+
[matChipInputSeparatorKeyCodes]="separatorKeysCodes">
|
|
21
|
+
@if (value.length > 0 && canRemoveAll()) {
|
|
22
|
+
<mat-icon matPrefix class="clearAll" (click)="onClearAll();">clear</mat-icon>
|
|
23
|
+
}
|
|
24
|
+
<mat-icon matSuffix>arrow_drop_down</mat-icon>
|
|
25
|
+
</div>
|
|
26
|
+
</mat-chip-grid>
|
|
27
|
+
|
|
28
|
+
<mat-autocomplete #auto="matAutocomplete" panelWidth="500px" [class.full-width-field]="optionTemplate" (optionSelected)="selectItemOnAutocomplete($event)">
|
|
29
|
+
@for (item of filteredListAutoComplete | async; track item) {
|
|
30
|
+
<mat-option [value]="item[keyValue]" class="full-width-option">
|
|
31
|
+
@if (optionTemplate) {
|
|
32
|
+
<ng-container *ngTemplateOutlet="optionTemplate; context: {data: item}" />
|
|
33
|
+
} @else {
|
|
34
|
+
{{item[displayValue]}}
|
|
35
|
+
}
|
|
36
|
+
</mat-option>
|
|
37
|
+
}
|
|
38
|
+
</mat-autocomplete>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
span {
|
|
2
|
+
opacity: 0;
|
|
3
|
+
transition: opacity 200ms;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host.floating span {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
mat-icon {
|
|
14
|
+
align-self: center;
|
|
15
|
+
color: var(--mat-select-enabled-arrow-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
input.mat-mdc-chip-input {
|
|
19
|
+
flex: 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.input-wrapper {
|
|
24
|
+
flex: 1;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: row;
|
|
27
|
+
gap: 8px;
|
|
28
|
+
align-items: center;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.input-wrapper > input {
|
|
33
|
+
flex: 1;
|
|
34
|
+
min-width: 150px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.input-wrapper > mat-icon {
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed, fakeAsync, flush } from '@angular/core/testing';
|
|
2
|
+
import { DropdownChipAutocompleteComponent } from './dropdown-chip-autocomplete.component';
|
|
3
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
4
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
+
import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
|
6
|
+
import { FormsModule } from '@angular/forms';
|
|
7
|
+
|
|
8
|
+
describe('DropdownChipAutocompleteComponent', () => {
|
|
9
|
+
let component: DropdownChipAutocompleteComponent;
|
|
10
|
+
let fixture: ComponentFixture<DropdownChipAutocompleteComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
TestBed.configureTestingModule({
|
|
14
|
+
imports: [
|
|
15
|
+
DropdownChipAutocompleteComponent,
|
|
16
|
+
MatAutocompleteModule,
|
|
17
|
+
MatChipsModule,
|
|
18
|
+
MatIconModule,
|
|
19
|
+
FormsModule
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
fixture = TestBed.createComponent(DropdownChipAutocompleteComponent);
|
|
23
|
+
component = fixture.componentInstance;
|
|
24
|
+
fixture.detectChanges();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should create', () => {
|
|
28
|
+
expect(component).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should call "onChange" when an item is selected from autocomplete', () => {
|
|
32
|
+
spyOn(component, 'onChange');
|
|
33
|
+
const event = {
|
|
34
|
+
option: { value: 'test 2' }
|
|
35
|
+
} as MatAutocompleteSelectedEvent;
|
|
36
|
+
|
|
37
|
+
component.selectItemOnAutocomplete(event);
|
|
38
|
+
|
|
39
|
+
expect(component.onChange).toHaveBeenCalled();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should call "onChange" when an item is removed from autocomplete', () => {
|
|
43
|
+
spyOn(component, 'onChange');
|
|
44
|
+
component.value = ['test'];
|
|
45
|
+
component.removeSelectedItem(0);
|
|
46
|
+
|
|
47
|
+
expect(component.onChange).toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should clear all value when "clear" beside the "arrow_drop_down" is click', () => {
|
|
51
|
+
spyOn(component, 'onClearAll');
|
|
52
|
+
component.value = ['test'];
|
|
53
|
+
fixture.detectChanges();
|
|
54
|
+
|
|
55
|
+
const clearAllIcon = fixture.nativeElement.querySelector('.clearAll');
|
|
56
|
+
clearAllIcon.click();
|
|
57
|
+
|
|
58
|
+
expect(component.onClearAll).toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should not display the remove all button when the props is false', () => {
|
|
62
|
+
fixture.componentRef.setInput('canRemoveAll', false);
|
|
63
|
+
component.value = ['test'];
|
|
64
|
+
fixture.detectChanges();
|
|
65
|
+
|
|
66
|
+
const clearAllIcon = fixture.nativeElement.querySelector('.clearAll');
|
|
67
|
+
expect(clearAllIcon).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should filter datasource when filter is changed', fakeAsync(() => {
|
|
71
|
+
component.keyValue = 'id';
|
|
72
|
+
component.displayValue = 'text';
|
|
73
|
+
component.listAutoComplete = [
|
|
74
|
+
{ id: '1', 'text': 'Patate' },
|
|
75
|
+
{ id: '2', 'text': 'Chou' },
|
|
76
|
+
{ id: '3', 'text': 'Hibou' },
|
|
77
|
+
{ id: '4', 'text': 'Genou' }
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
component.searchValue = 'Pat';
|
|
81
|
+
|
|
82
|
+
flush();
|
|
83
|
+
|
|
84
|
+
expect(component.searchValue).toBe('Pat');
|
|
85
|
+
component.filteredListAutoComplete.subscribe(filteredList => {
|
|
86
|
+
expect(filteredList.length).toBe(1);
|
|
87
|
+
expect(filteredList[0]).toBe(component.listAutoComplete[0]);
|
|
88
|
+
});
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
it('should display everything when filter has been cleared', fakeAsync(() => {
|
|
92
|
+
component.keyValue = 'id';
|
|
93
|
+
component.displayValue = 'text';
|
|
94
|
+
component.listAutoComplete = [
|
|
95
|
+
{ id: '1', 'text': 'Patate' },
|
|
96
|
+
{ id: '2', 'text': 'Chou' },
|
|
97
|
+
{ id: '3', 'text': 'Hibou' },
|
|
98
|
+
{ id: '4', 'text': 'Genou' }
|
|
99
|
+
];
|
|
100
|
+
component.searchValue = 'Pat';
|
|
101
|
+
flush();
|
|
102
|
+
|
|
103
|
+
component.searchValue = '';
|
|
104
|
+
flush();
|
|
105
|
+
|
|
106
|
+
expect(component.searchValue).toBe('');
|
|
107
|
+
component.filteredListAutoComplete.subscribe(filteredList => {
|
|
108
|
+
expect(filteredList.length).toBe(component.listAutoComplete.length);
|
|
109
|
+
expect(filteredList[0]).toBe(component.listAutoComplete[0]);
|
|
110
|
+
});
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
it('should not labelFloat when empty', () => {
|
|
114
|
+
expect(component.shouldLabelFloat).toBeFalsy();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should labelFloat when not empty', () => {
|
|
118
|
+
component.value = ['123'];
|
|
119
|
+
|
|
120
|
+
expect(component.shouldLabelFloat).toBeTruthy();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should not labelFloat when there is no search value', () => {
|
|
124
|
+
component.searchValue = '';
|
|
125
|
+
|
|
126
|
+
expect(component.shouldLabelFloat).toBeFalsy();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should labelFloat when there is a search value', () => {
|
|
130
|
+
component.searchValue = 'a';
|
|
131
|
+
|
|
132
|
+
expect(component.shouldLabelFloat).toBeTruthy();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
});
|