@cute-widgets/base 20.0.1
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/CHANGELOG.md +1 -0
- package/LICENSE.md +191 -0
- package/README.md +190 -0
- package/abstract/index.d.ts +327 -0
- package/alert/index.d.ts +68 -0
- package/autocomplete/index.d.ts +442 -0
- package/badge/index.d.ts +26 -0
- package/bottom-sheet/index.d.ts +231 -0
- package/button/index.d.ts +182 -0
- package/button-toggle/index.d.ts +225 -0
- package/card/index.d.ts +163 -0
- package/checkbox/index.d.ts +174 -0
- package/chips/index.d.ts +963 -0
- package/collapse/index.d.ts +97 -0
- package/core/animation/index.d.ts +43 -0
- package/core/datetime/index.d.ts +404 -0
- package/core/directives/index.d.ts +168 -0
- package/core/error/index.d.ts +74 -0
- package/core/index.d.ts +1039 -0
- package/core/interfaces/index.d.ts +114 -0
- package/core/layout/index.d.ts +53 -0
- package/core/line/index.d.ts +37 -0
- package/core/nav/index.d.ts +321 -0
- package/core/observers/index.d.ts +124 -0
- package/core/option/index.d.ts +185 -0
- package/core/pipes/index.d.ts +53 -0
- package/core/ripple/index.d.ts +66 -0
- package/core/testing/index.d.ts +154 -0
- package/core/theming/index.d.ts +118 -0
- package/core/types/index.d.ts +53 -0
- package/core/utils/index.d.ts +129 -0
- package/cute-widgets-base-20.0.1.tgz +0 -0
- package/datepicker/index.d.ts +1817 -0
- package/dialog/index.d.ts +484 -0
- package/divider/index.d.ts +24 -0
- package/expansion/README.md +8 -0
- package/expansion/index.d.ts +308 -0
- package/fesm2022/cute-widgets-base-abstract.mjs +547 -0
- package/fesm2022/cute-widgets-base-abstract.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-alert.mjs +198 -0
- package/fesm2022/cute-widgets-base-alert.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs +1217 -0
- package/fesm2022/cute-widgets-base-autocomplete.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-badge.mjs +75 -0
- package/fesm2022/cute-widgets-base-badge.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs +416 -0
- package/fesm2022/cute-widgets-base-bottom-sheet.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs +640 -0
- package/fesm2022/cute-widgets-base-button-toggle.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-button.mjs +546 -0
- package/fesm2022/cute-widgets-base-button.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-card.mjs +471 -0
- package/fesm2022/cute-widgets-base-card.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs +390 -0
- package/fesm2022/cute-widgets-base-checkbox.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-chips.mjs +2360 -0
- package/fesm2022/cute-widgets-base-chips.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-collapse.mjs +259 -0
- package/fesm2022/cute-widgets-base-collapse.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs +53 -0
- package/fesm2022/cute-widgets-base-core-animation.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs +568 -0
- package/fesm2022/cute-widgets-base-core-datetime.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs +404 -0
- package/fesm2022/cute-widgets-base-core-directives.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-error.mjs +105 -0
- package/fesm2022/cute-widgets-base-core-error.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-interfaces.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs +74 -0
- package/fesm2022/cute-widgets-base-core-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-line.mjs +87 -0
- package/fesm2022/cute-widgets-base-core-line.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs +863 -0
- package/fesm2022/cute-widgets-base-core-nav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs +304 -0
- package/fesm2022/cute-widgets-base-core-observers.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-option.mjs +373 -0
- package/fesm2022/cute-widgets-base-core-option.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs +97 -0
- package/fesm2022/cute-widgets-base-core-pipes.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs +172 -0
- package/fesm2022/cute-widgets-base-core-ripple.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs +210 -0
- package/fesm2022/cute-widgets-base-core-testing.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs +314 -0
- package/fesm2022/cute-widgets-base-core-theming.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-types.mjs +22 -0
- package/fesm2022/cute-widgets-base-core-types.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs +257 -0
- package/fesm2022/cute-widgets-base-core-utils.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-core.mjs +1600 -0
- package/fesm2022/cute-widgets-base-core.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs +4827 -0
- package/fesm2022/cute-widgets-base-datepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-dialog.mjs +1046 -0
- package/fesm2022/cute-widgets-base-dialog.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-divider.mjs +86 -0
- package/fesm2022/cute-widgets-base-divider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-expansion.mjs +623 -0
- package/fesm2022/cute-widgets-base-expansion.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-form-field.mjs +969 -0
- package/fesm2022/cute-widgets-base-form-field.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs +715 -0
- package/fesm2022/cute-widgets-base-grid-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-icon.mjs +1105 -0
- package/fesm2022/cute-widgets-base-icon.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-input.mjs +726 -0
- package/fesm2022/cute-widgets-base-input.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs +95 -0
- package/fesm2022/cute-widgets-base-layout-container.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs +166 -0
- package/fesm2022/cute-widgets-base-layout-stack.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-layout.mjs +250 -0
- package/fesm2022/cute-widgets-base-layout.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-list.mjs +1557 -0
- package/fesm2022/cute-widgets-base-list.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-menu.mjs +1283 -0
- package/fesm2022/cute-widgets-base-menu.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-navbar.mjs +359 -0
- package/fesm2022/cute-widgets-base-navbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-paginator.mjs +485 -0
- package/fesm2022/cute-widgets-base-paginator.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-progress.mjs +321 -0
- package/fesm2022/cute-widgets-base-progress.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-radio.mjs +637 -0
- package/fesm2022/cute-widgets-base-radio.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-select.mjs +1208 -0
- package/fesm2022/cute-widgets-base-select.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs +1095 -0
- package/fesm2022/cute-widgets-base-sidenav.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-slider.mjs +99 -0
- package/fesm2022/cute-widgets-base-slider.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs +897 -0
- package/fesm2022/cute-widgets-base-snack-bar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-sort.mjs +639 -0
- package/fesm2022/cute-widgets-base-sort.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-spinner.mjs +154 -0
- package/fesm2022/cute-widgets-base-spinner.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-stepper.mjs +673 -0
- package/fesm2022/cute-widgets-base-stepper.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-table.mjs +1023 -0
- package/fesm2022/cute-widgets-base-table.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tabs.mjs +729 -0
- package/fesm2022/cute-widgets-base-tabs.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs +965 -0
- package/fesm2022/cute-widgets-base-timepicker.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs +120 -0
- package/fesm2022/cute-widgets-base-toolbar.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs +947 -0
- package/fesm2022/cute-widgets-base-tooltip.mjs.map +1 -0
- package/fesm2022/cute-widgets-base-tree.mjs +598 -0
- package/fesm2022/cute-widgets-base-tree.mjs.map +1 -0
- package/fesm2022/cute-widgets-base.mjs +68 -0
- package/fesm2022/cute-widgets-base.mjs.map +1 -0
- package/form-field/index.d.ts +401 -0
- package/grid-list/index.d.ts +361 -0
- package/icon/index.d.ts +477 -0
- package/index.d.ts +3 -0
- package/input/index.d.ts +256 -0
- package/layout/container/index.d.ts +31 -0
- package/layout/index.d.ts +78 -0
- package/layout/stack/index.d.ts +52 -0
- package/list/index.d.ts +659 -0
- package/menu/index.d.ts +497 -0
- package/navbar/index.d.ts +91 -0
- package/package.json +279 -0
- package/paginator/index.d.ts +216 -0
- package/progress/index.d.ts +130 -0
- package/radio/index.d.ts +259 -0
- package/select/index.d.ts +426 -0
- package/sidenav/index.d.ts +369 -0
- package/slider/index.d.ts +48 -0
- package/snack-bar/index.d.ts +374 -0
- package/sort/index.d.ts +334 -0
- package/spinner/index.d.ts +70 -0
- package/stepper/index.d.ts +295 -0
- package/table/index.d.ts +395 -0
- package/tabs/index.d.ts +307 -0
- package/timepicker/index.d.ts +350 -0
- package/toolbar/index.d.ts +36 -0
- package/tooltip/index.d.ts +299 -0
- package/tree/index.d.ts +314 -0
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, InjectionToken, Input, inject, Attribute, ElementRef, NgZone, contentChild, Injector, computed, isDevMode, afterEveryRender, ContentChildren, ContentChild, ViewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet, CommonModule } from '@angular/common';
|
|
4
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
5
|
+
import { Platform } from '@angular/cdk/platform';
|
|
6
|
+
import { Subject, pairwise, merge, EMPTY } from 'rxjs';
|
|
7
|
+
import { startWith, map, filter, takeUntil } from 'rxjs/operators';
|
|
8
|
+
import { _IdGenerator } from '@angular/cdk/a11y';
|
|
9
|
+
import { CuteBaseControl } from '@cute-widgets/base/abstract';
|
|
10
|
+
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
11
|
+
import { _animationsDisabled } from '@cute-widgets/base/core/animation';
|
|
12
|
+
|
|
13
|
+
/** An interface which allows a control to work inside a `CuteFormField`. */
|
|
14
|
+
class CuteFormFieldControl {
|
|
15
|
+
constructor() {
|
|
16
|
+
/** The value of the control. */
|
|
17
|
+
this.value = null;
|
|
18
|
+
/** Gets the `AbstractControlDirective` for this control. */
|
|
19
|
+
this.ngControl = null;
|
|
20
|
+
/** Whether the control is focused. */
|
|
21
|
+
this.focused = false;
|
|
22
|
+
/** Whether the control is empty. */
|
|
23
|
+
this.empty = false;
|
|
24
|
+
/** Whether the `CuteFormField` label should try to float. */
|
|
25
|
+
this.shouldLabelFloat = false;
|
|
26
|
+
/** Whether the control is required. */
|
|
27
|
+
this.required = false;
|
|
28
|
+
/** Whether the control is disabled. */
|
|
29
|
+
this.disabled = false;
|
|
30
|
+
/** Whether the control is in an error state. */
|
|
31
|
+
this.errorState = false;
|
|
32
|
+
}
|
|
33
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldControl, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
34
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteFormFieldControl, isStandalone: true, ngImport: i0 }); }
|
|
35
|
+
}
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldControl, decorators: [{
|
|
37
|
+
type: Directive
|
|
38
|
+
}] });
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @license Apache-2.0
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
44
|
+
*
|
|
45
|
+
* You may not use this file except in compliance with the License
|
|
46
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Injection token that can be used to reference instances of `CutePrefix`. It serves as
|
|
50
|
+
* an alternative token to the actual `CutePrefix` class, which could cause unnecessary
|
|
51
|
+
* retention of the class and its directive metadata.
|
|
52
|
+
*/
|
|
53
|
+
const CUTE_PREFIX = new InjectionToken('CutePrefix');
|
|
54
|
+
/** Prefix to be placed in front of the form field. */
|
|
55
|
+
class CutePrefix {
|
|
56
|
+
constructor() {
|
|
57
|
+
this._isText = false;
|
|
58
|
+
}
|
|
59
|
+
set _isTextSelector(value) {
|
|
60
|
+
this._isText = true;
|
|
61
|
+
}
|
|
62
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CutePrefix, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
63
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CutePrefix, isStandalone: true, selector: "[cutePrefix], [cuteIconPrefix], [cuteTextPrefix]", inputs: { _isTextSelector: ["cuteTextPrefix", "_isTextSelector"] }, host: { classAttribute: "input-group-text" }, providers: [{ provide: CUTE_PREFIX, useExisting: CutePrefix }], ngImport: i0 }); }
|
|
64
|
+
}
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CutePrefix, decorators: [{
|
|
66
|
+
type: Directive,
|
|
67
|
+
args: [{
|
|
68
|
+
selector: '[cutePrefix], [cuteIconPrefix], [cuteTextPrefix]',
|
|
69
|
+
providers: [{ provide: CUTE_PREFIX, useExisting: CutePrefix }],
|
|
70
|
+
host: {
|
|
71
|
+
'class': 'input-group-text'
|
|
72
|
+
},
|
|
73
|
+
}]
|
|
74
|
+
}], propDecorators: { _isTextSelector: [{
|
|
75
|
+
type: Input,
|
|
76
|
+
args: ['cuteTextPrefix']
|
|
77
|
+
}] } });
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @license Apache-2.0
|
|
81
|
+
*
|
|
82
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
83
|
+
*
|
|
84
|
+
* You may not use this file except in compliance with the License
|
|
85
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Injection token that can be used to reference instances of `CuteSuffix`. It serves as
|
|
89
|
+
* an alternative token to the actual `CuteSuffix` class which could cause unnecessary
|
|
90
|
+
* retention of the class and its directive metadata.
|
|
91
|
+
*/
|
|
92
|
+
const CUTE_SUFFIX = new InjectionToken('CuteSuffix');
|
|
93
|
+
/** Suffix to be placed at the end of the form field. */
|
|
94
|
+
class CuteSuffix {
|
|
95
|
+
constructor() {
|
|
96
|
+
this._isText = false;
|
|
97
|
+
}
|
|
98
|
+
set _isTextSelector(value) {
|
|
99
|
+
this._isText = true;
|
|
100
|
+
}
|
|
101
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSuffix, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
102
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteSuffix, isStandalone: true, selector: "[cuteSuffix], [cuteIconSuffix], [cuteTextSuffix]", inputs: { _isTextSelector: ["cuteTextSuffix", "_isTextSelector"] }, host: { classAttribute: "input-group-text" }, providers: [{ provide: CUTE_SUFFIX, useExisting: CuteSuffix }], ngImport: i0 }); }
|
|
103
|
+
}
|
|
104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSuffix, decorators: [{
|
|
105
|
+
type: Directive,
|
|
106
|
+
args: [{
|
|
107
|
+
selector: '[cuteSuffix], [cuteIconSuffix], [cuteTextSuffix]',
|
|
108
|
+
providers: [{ provide: CUTE_SUFFIX, useExisting: CuteSuffix }],
|
|
109
|
+
host: {
|
|
110
|
+
'class': 'input-group-text'
|
|
111
|
+
},
|
|
112
|
+
}]
|
|
113
|
+
}], propDecorators: { _isTextSelector: [{
|
|
114
|
+
type: Input,
|
|
115
|
+
args: ['cuteTextSuffix']
|
|
116
|
+
}] } });
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @license Apache-2.0
|
|
120
|
+
*
|
|
121
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
122
|
+
*
|
|
123
|
+
* You may not use this file except in compliance with the License
|
|
124
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
125
|
+
*
|
|
126
|
+
* This code is a modification of the `@angular/material` original
|
|
127
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
128
|
+
*/
|
|
129
|
+
/**
|
|
130
|
+
* Injection token that can be used to reference instances of `CuteError`. It serves as
|
|
131
|
+
* an alternative token to the actual `CuteError` class, which could cause unnecessary
|
|
132
|
+
* retention of the class and its directive metadata.
|
|
133
|
+
*/
|
|
134
|
+
const CUTE_ERROR = new InjectionToken('CuteError');
|
|
135
|
+
/** Single error message to be shown underneath the form-field. */
|
|
136
|
+
class CuteError {
|
|
137
|
+
constructor(ariaLive, elementRef) {
|
|
138
|
+
this.id = inject(_IdGenerator).getId('cute-error-');
|
|
139
|
+
// If no aria-live value is set, add 'polite' as a default. This is preferred over setting
|
|
140
|
+
// role='alert' so that screen readers do not interrupt the current task to read this aloud.
|
|
141
|
+
if (!ariaLive) {
|
|
142
|
+
elementRef.nativeElement.setAttribute('aria-live', 'polite');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
ngOnInit() {
|
|
146
|
+
console.log("cute-error init.");
|
|
147
|
+
}
|
|
148
|
+
ngOnDestroy() {
|
|
149
|
+
console.log("cute-error destroy.");
|
|
150
|
+
}
|
|
151
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteError, deps: [{ token: 'aria-live', attribute: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
152
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteError, isStandalone: true, selector: "cute-error, [cuteError]", inputs: { id: "id" }, host: { attributes: { "aria-atomic": "true" }, properties: { "id": "id", "attr.cuteErrorAttr": "true" }, classAttribute: "cute-form-field-error cute-form-field-bottom-align invalid-feedback" }, providers: [{ provide: CUTE_ERROR, useExisting: CuteError }], ngImport: i0 }); }
|
|
153
|
+
}
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteError, decorators: [{
|
|
155
|
+
type: Directive,
|
|
156
|
+
args: [{
|
|
157
|
+
selector: 'cute-error, [cuteError]',
|
|
158
|
+
host: {
|
|
159
|
+
'class': 'cute-form-field-error cute-form-field-bottom-align invalid-feedback',
|
|
160
|
+
'aria-atomic': 'true',
|
|
161
|
+
'[id]': 'id',
|
|
162
|
+
'[attr.cuteErrorAttr]': 'true',
|
|
163
|
+
},
|
|
164
|
+
providers: [{ provide: CUTE_ERROR, useExisting: CuteError }],
|
|
165
|
+
}]
|
|
166
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
167
|
+
type: Attribute,
|
|
168
|
+
args: ['aria-live']
|
|
169
|
+
}] }, { type: i0.ElementRef }], propDecorators: { id: [{
|
|
170
|
+
type: Input
|
|
171
|
+
}] } });
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @license Apache-2.0
|
|
175
|
+
*
|
|
176
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
177
|
+
*
|
|
178
|
+
* You may not use this file except in compliance with the License
|
|
179
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
180
|
+
*
|
|
181
|
+
* This code is a modification of the `@angular/material` original
|
|
182
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
183
|
+
*/
|
|
184
|
+
/** Hint text to be shown underneath the form field control. */
|
|
185
|
+
class CuteHint {
|
|
186
|
+
constructor() {
|
|
187
|
+
/** Whether to align the hint label at the start or end of the line. */
|
|
188
|
+
this.align = 'start';
|
|
189
|
+
/** Unique ID for the hint. Used for the `aria-describedby` on the form field control. */
|
|
190
|
+
this.id = inject(_IdGenerator).getId('cute-hint-');
|
|
191
|
+
}
|
|
192
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteHint, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
193
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteHint, isStandalone: true, selector: "cute-hint", inputs: { align: "align", id: "id" }, host: { properties: { "class.cute-form-field-hint-end": "align === \"end\"", "id": "id", "attr.align": "null" }, classAttribute: "form-text cute-form-field-hint cute-form-field-bottom-align" }, exportAs: ["cuteHint"], ngImport: i0 }); }
|
|
194
|
+
}
|
|
195
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteHint, decorators: [{
|
|
196
|
+
type: Directive,
|
|
197
|
+
args: [{
|
|
198
|
+
selector: 'cute-hint',
|
|
199
|
+
exportAs: 'cuteHint',
|
|
200
|
+
host: {
|
|
201
|
+
'class': 'form-text cute-form-field-hint cute-form-field-bottom-align',
|
|
202
|
+
'[class.cute-form-field-hint-end]': 'align === "end"',
|
|
203
|
+
'[id]': 'id',
|
|
204
|
+
// Remove align attribute to prevent it from interfering with layout.
|
|
205
|
+
'[attr.align]': 'null',
|
|
206
|
+
},
|
|
207
|
+
}]
|
|
208
|
+
}], propDecorators: { align: [{
|
|
209
|
+
type: Input
|
|
210
|
+
}], id: [{
|
|
211
|
+
type: Input
|
|
212
|
+
}] } });
|
|
213
|
+
|
|
214
|
+
/** @docs-private */
|
|
215
|
+
function getCuteFormFieldPlaceholderConflictError() {
|
|
216
|
+
return Error('Placeholder attribute and child element were both specified.');
|
|
217
|
+
}
|
|
218
|
+
/** @docs-private */
|
|
219
|
+
function getCuteFormFieldDuplicatedHintError(align) {
|
|
220
|
+
return Error(`A hint was already declared for 'align="${align}"'.`);
|
|
221
|
+
}
|
|
222
|
+
/** @docs-private */
|
|
223
|
+
function getCuteFormFieldMissingControlError() {
|
|
224
|
+
return Error('cute-form-field must contain a CuteFormFieldControl.');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @license Apache-2.0
|
|
229
|
+
*
|
|
230
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
231
|
+
*
|
|
232
|
+
* You may not use this file except in compliance with the License
|
|
233
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
234
|
+
*/
|
|
235
|
+
/** The floating label for a `cute-form-field`. */
|
|
236
|
+
class CuteLabel /* extends ... */ {
|
|
237
|
+
constructor() {
|
|
238
|
+
this._elementRef = inject(ElementRef);
|
|
239
|
+
}
|
|
240
|
+
/** Returns the label's current text. */
|
|
241
|
+
getText() {
|
|
242
|
+
return this._elementRef.nativeElement.innerText;
|
|
243
|
+
}
|
|
244
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLabel /* extends ... */, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
245
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteLabel /* extends ... */, isStandalone: true, selector: "cute-label", inputs: { magnitude: "magnitude" }, host: { properties: { "style.font-size": "magnitude==\"small\" ? \"0.875rem\" : (magnitude==\"large\"? \"1.25rem\" : \"\")" } }, ngImport: i0 }); }
|
|
246
|
+
}
|
|
247
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLabel /* extends ... */, decorators: [{
|
|
248
|
+
type: Directive,
|
|
249
|
+
args: [{
|
|
250
|
+
selector: 'cute-label',
|
|
251
|
+
host: {
|
|
252
|
+
'[style.font-size]': 'magnitude=="small" ? "0.875rem" : (magnitude=="large"? "1.25rem" : "")'
|
|
253
|
+
}
|
|
254
|
+
}]
|
|
255
|
+
}], propDecorators: { magnitude: [{
|
|
256
|
+
type: Input
|
|
257
|
+
}] } });
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @license Apache-2.0
|
|
261
|
+
*
|
|
262
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
263
|
+
*
|
|
264
|
+
* You may not use this file except in compliance with the License
|
|
265
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
266
|
+
*
|
|
267
|
+
* This code is a modification of the `@angular/material` original
|
|
268
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
269
|
+
*/
|
|
270
|
+
/**
|
|
271
|
+
* Injection token that can be used to inject an instances of `CuteFormField`. It serves
|
|
272
|
+
* as an alternative token to the actual `CuteFormField` class which would cause unnecessary
|
|
273
|
+
* retention of the `CuteFormField` class and its component metadata.
|
|
274
|
+
*/
|
|
275
|
+
const CUTE_FORM_FIELD = new InjectionToken('CuteFormField');
|
|
276
|
+
/**
|
|
277
|
+
* Injection token that can be used to configure the
|
|
278
|
+
* default options for all form fields within an app.
|
|
279
|
+
*/
|
|
280
|
+
const CUTE_FORM_FIELD_DEFAULT_OPTIONS = new InjectionToken('CUTE_FORM_FIELD_DEFAULT_OPTIONS');
|
|
281
|
+
/**
|
|
282
|
+
* Whether the label for form fields should by default float `always`,
|
|
283
|
+
* `never`, or `auto`.
|
|
284
|
+
*/
|
|
285
|
+
const DEFAULT_FLOAT_LABEL = 'never';
|
|
286
|
+
/** Default way that the subscript element height is set. */
|
|
287
|
+
const DEFAULT_SUBSCRIPT_SIZING = 'fixed';
|
|
288
|
+
let nextUniqueId = 0;
|
|
289
|
+
class CuteFormField extends CuteBaseControl {
|
|
290
|
+
/** Whether to display the CSS styles for a _valid_ control status after it has been checked. */
|
|
291
|
+
get hideValidStyle() { return this._hideValidStyle; }
|
|
292
|
+
set hideValidStyle(hideValid) {
|
|
293
|
+
this._hideValidStyle = coerceBooleanProperty(hideValid);
|
|
294
|
+
this.displayValidity(!this._hideValidStyle);
|
|
295
|
+
}
|
|
296
|
+
/** Whether the required marker should be hidden. */
|
|
297
|
+
get hideRequiredMarker() { return this._hideRequiredMarker; }
|
|
298
|
+
set hideRequiredMarker(value) {
|
|
299
|
+
this._hideRequiredMarker = coerceBooleanProperty(value);
|
|
300
|
+
}
|
|
301
|
+
/** Whether the label should always float or float as the user types. */
|
|
302
|
+
get floatLabel() {
|
|
303
|
+
return this._floatLabel || this._defaults?.floatLabel || DEFAULT_FLOAT_LABEL;
|
|
304
|
+
}
|
|
305
|
+
set floatLabel(value) {
|
|
306
|
+
if (value !== this._floatLabel) {
|
|
307
|
+
this._floatLabel = value;
|
|
308
|
+
// For backwards compatibility. Custom form field controls or directives might set
|
|
309
|
+
// the "floatLabel" input and expect the form field view to be updated automatically.
|
|
310
|
+
// e.g. autocomplete trigger. Ideally we'd get rid of this and the consumers would just
|
|
311
|
+
// emit the "stateChanges" observable. TODO(devversion): consider removing.
|
|
312
|
+
this.markForCheck();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Whether the form field should reserve space for one line of hint/error text (default)
|
|
317
|
+
* or to have the spacing grow from 0px as needed based on the size of the hint/error content.
|
|
318
|
+
* Note that when using dynamic sizing, layout shifts will occur when hint/error text changes.
|
|
319
|
+
*/
|
|
320
|
+
get subscriptSizing() {
|
|
321
|
+
return this._subscriptSizing || this._defaults?.subscriptSizing || DEFAULT_SUBSCRIPT_SIZING;
|
|
322
|
+
}
|
|
323
|
+
set subscriptSizing(value) {
|
|
324
|
+
this._subscriptSizing = value || this._defaults?.subscriptSizing || DEFAULT_SUBSCRIPT_SIZING;
|
|
325
|
+
}
|
|
326
|
+
/** Text for the form field hint. */
|
|
327
|
+
get hintLabel() { return this._hintLabel; }
|
|
328
|
+
set hintLabel(value) {
|
|
329
|
+
this._hintLabel = value;
|
|
330
|
+
this._processHints();
|
|
331
|
+
}
|
|
332
|
+
/** Gets the current form field control */
|
|
333
|
+
get _control() {
|
|
334
|
+
return this._explicitFormFieldControl || this._formFieldControl;
|
|
335
|
+
}
|
|
336
|
+
set _control(value) {
|
|
337
|
+
this._explicitFormFieldControl = value;
|
|
338
|
+
}
|
|
339
|
+
/** Returns bootstrap's size suffix for CSS classes */
|
|
340
|
+
get magnitudeSuffix() {
|
|
341
|
+
if (this.magnitude == "small") {
|
|
342
|
+
return "-sm";
|
|
343
|
+
}
|
|
344
|
+
else if (this.magnitude == "large") {
|
|
345
|
+
return "-lg";
|
|
346
|
+
}
|
|
347
|
+
return "";
|
|
348
|
+
}
|
|
349
|
+
get _isFloatLabel() {
|
|
350
|
+
return this.floatLabel == "auto" || this.floatLabel == "always";
|
|
351
|
+
}
|
|
352
|
+
generateId() {
|
|
353
|
+
return "";
|
|
354
|
+
}
|
|
355
|
+
constructor() {
|
|
356
|
+
super();
|
|
357
|
+
this._elementRef = inject(ElementRef);
|
|
358
|
+
this._dir = inject(Directionality);
|
|
359
|
+
this._platform = inject(Platform);
|
|
360
|
+
this._ngZone = inject(NgZone);
|
|
361
|
+
this._defaults = inject(CUTE_FORM_FIELD_DEFAULT_OPTIONS, {
|
|
362
|
+
optional: true,
|
|
363
|
+
});
|
|
364
|
+
this._labelChild = contentChild(CuteLabel, ...(ngDevMode ? [{ debugName: "_labelChild" }] : []));
|
|
365
|
+
this._hideValidStyle = false;
|
|
366
|
+
this._hideRequiredMarker = false;
|
|
367
|
+
this._floatLabel = "never";
|
|
368
|
+
this._subscriptSizing = null;
|
|
369
|
+
this._hintLabel = '';
|
|
370
|
+
this._hasIconPrefix = false;
|
|
371
|
+
this._hasTextPrefix = false;
|
|
372
|
+
this._hasIconSuffix = false;
|
|
373
|
+
this._hasTextSuffix = false;
|
|
374
|
+
// Unique id for the internal form field label.
|
|
375
|
+
this._labelId = `cute-form-field-label-${nextUniqueId++}`;
|
|
376
|
+
// Unique id for the hint label.
|
|
377
|
+
this._hintLabelId = `cute-hint-${nextUniqueId++}`;
|
|
378
|
+
/** Subject that emits when the component has been destroyed. */
|
|
379
|
+
this._destroyed = new Subject();
|
|
380
|
+
this._isFocused = null;
|
|
381
|
+
this._needsOutlineLabelOffsetUpdate = false;
|
|
382
|
+
this._previousControl = undefined;
|
|
383
|
+
this._previousControlValidatorFn = null;
|
|
384
|
+
this._animationsDisabled = _animationsDisabled();
|
|
385
|
+
this._injector = inject(Injector);
|
|
386
|
+
/**
|
|
387
|
+
* Gets the id of the label element. If no label is present, returns `null`.
|
|
388
|
+
*/
|
|
389
|
+
this.getLabelId = computed(() => (this._hasFloatingLabel() ? this._labelId : null), ...(ngDevMode ? [{ debugName: "getLabelId" }] : []));
|
|
390
|
+
/** Is there any `<cute-label>` in the form field? */
|
|
391
|
+
this._hasFloatingLabel = computed(() => !!this._labelChild(), ...(ngDevMode ? [{ debugName: "_hasFloatingLabel" }] : []));
|
|
392
|
+
const defaults = this._defaults;
|
|
393
|
+
if (defaults) {
|
|
394
|
+
//if (_defaults.appearance) {
|
|
395
|
+
// this.appearance = _defaults.appearance;
|
|
396
|
+
//}
|
|
397
|
+
this.hideRequiredMarker = Boolean(defaults?.hideRequiredMarker);
|
|
398
|
+
if (defaults.color) {
|
|
399
|
+
this.color = defaults.color;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
setDisabledState(newState, emitEvent) {
|
|
404
|
+
this._control?.setDisabledState(coerceBooleanProperty(newState));
|
|
405
|
+
return super.setDisabledState(newState, emitEvent);
|
|
406
|
+
}
|
|
407
|
+
ngAfterViewInit() {
|
|
408
|
+
super.ngAfterViewInit();
|
|
409
|
+
// Initial focus state sync. This happens rarely, but we want to account for
|
|
410
|
+
// it in case the form field control has "focused" set to true on init.
|
|
411
|
+
this._updateFocusState();
|
|
412
|
+
if (!this._animationsDisabled) {
|
|
413
|
+
this._ngZone.runOutsideAngular(() => {
|
|
414
|
+
// Enable animations after a certain amount of time so that they don't run on init.
|
|
415
|
+
setTimeout(() => {
|
|
416
|
+
this._elementRef.nativeElement.classList.add('cute-form-field-animations-enabled');
|
|
417
|
+
}, 300);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
// Because the above changes a value used in the template after it was checked, we need
|
|
421
|
+
// to trigger CD or the change might not be reflected if there is no other CD scheduled.
|
|
422
|
+
this._changeDetectorRef.detectChanges();
|
|
423
|
+
}
|
|
424
|
+
ngAfterContentInit() {
|
|
425
|
+
super.ngAfterContentInit();
|
|
426
|
+
this._assertFormFieldControl();
|
|
427
|
+
this._initializeSubscript();
|
|
428
|
+
this._initializePrefixAndSuffix();
|
|
429
|
+
this._initializeOutlineLabelOffsetSubscriptions();
|
|
430
|
+
// CWT: Set `magnitude` value of the component to the child's `label` control as a default value
|
|
431
|
+
const childLabel = this._labelChildNonStatic || this._labelChildStatic;
|
|
432
|
+
if (childLabel && !childLabel.magnitude) {
|
|
433
|
+
childLabel.magnitude = this.magnitude;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
ngAfterContentChecked() {
|
|
437
|
+
this._assertFormFieldControl();
|
|
438
|
+
if (this._control !== this._previousControl) {
|
|
439
|
+
this._initializeControl(this._previousControl);
|
|
440
|
+
// keep a reference for last validator we had.
|
|
441
|
+
if (this._control?.ngControl && this._control.ngControl.control) {
|
|
442
|
+
this._previousControlValidatorFn = this._control.ngControl.control.validator;
|
|
443
|
+
}
|
|
444
|
+
this._previousControl = this._control;
|
|
445
|
+
}
|
|
446
|
+
// make sure the control has been initialized.
|
|
447
|
+
if (this._control?.ngControl && this._control.ngControl.control) {
|
|
448
|
+
// get the validators for current control.
|
|
449
|
+
const validatorFn = this._control.ngControl.control.validator;
|
|
450
|
+
// if our current validatorFn isn't equal to it might be we are CD behind, marking the
|
|
451
|
+
// component will allow us to catch up.
|
|
452
|
+
if (validatorFn !== this._previousControlValidatorFn) {
|
|
453
|
+
this._changeDetectorRef.markForCheck();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
ngOnDestroy() {
|
|
458
|
+
super.ngOnDestroy();
|
|
459
|
+
this._stateChanges?.unsubscribe();
|
|
460
|
+
this._valueChanges?.unsubscribe();
|
|
461
|
+
this._destroyed.next();
|
|
462
|
+
this._destroyed.complete();
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Gets an ElementRef for the element that an overlay attached to the form field
|
|
466
|
+
* should be positioned relative to.
|
|
467
|
+
*/
|
|
468
|
+
getConnectedOverlayOrigin() {
|
|
469
|
+
//return this._control?.controlElementRef || this._textField || this._elementRef;
|
|
470
|
+
return this._textField || this._elementRef;
|
|
471
|
+
}
|
|
472
|
+
/** Animates the placeholder up and locks it in position. */
|
|
473
|
+
_animateAndLockLabel() {
|
|
474
|
+
// This is for backwards compatibility only. Consumers of the form field might use
|
|
475
|
+
// this method. e.g. the autocomplete trigger. This method has been added to the non-MDC
|
|
476
|
+
// form field because setting "floatLabel" to "always" caused the label to float without
|
|
477
|
+
// animation. This is different in MDC where the label always animates, so this method
|
|
478
|
+
// is no longer necessary. There doesn't seem any benefit in adding logic to allow changing
|
|
479
|
+
// the floating label state without animations. The non-MDC implementation was inconsistent
|
|
480
|
+
// because it always animates if "floatLabel" is set away from "always".
|
|
481
|
+
// TODO(devversion): consider removing this method when releasing the MDC form field.
|
|
482
|
+
if (this._hasFloatingLabel()) {
|
|
483
|
+
this.floatLabel = 'always';
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Toggles Bootstrap's validation classes `is-valid` & `is-invalid`.
|
|
488
|
+
* @param hideValid Whether to remove Bootstrap's `is-valid` class.
|
|
489
|
+
*/
|
|
490
|
+
displayValidity(hideValid) {
|
|
491
|
+
const elem = this._control?.controlElementRef?.nativeElement;
|
|
492
|
+
const classList = elem?.classList;
|
|
493
|
+
if (classList) {
|
|
494
|
+
const touched = classList.contains("ng-touched");
|
|
495
|
+
const dirty = classList.contains("ng-dirty");
|
|
496
|
+
if (hideValid) {
|
|
497
|
+
classList.toggle("is-valid", false);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
classList.toggle("is-valid", classList.contains("ng-valid") && (touched));
|
|
501
|
+
}
|
|
502
|
+
if (this._control?.errorState) {
|
|
503
|
+
classList.toggle("is-invalid", classList.contains("ng-invalid") && (touched || dirty));
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
classList.toggle("is-invalid", false);
|
|
507
|
+
}
|
|
508
|
+
this.markForCheck();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/** Initializes the registered form field control. */
|
|
512
|
+
_initializeControl(previousControl) {
|
|
513
|
+
const control = this._control;
|
|
514
|
+
const classPrefix = 'cute-form-field-type-';
|
|
515
|
+
if (previousControl) {
|
|
516
|
+
this._elementRef.nativeElement.classList.remove(classPrefix + previousControl.controlType);
|
|
517
|
+
}
|
|
518
|
+
this._stateChanges?.unsubscribe();
|
|
519
|
+
this._valueChanges?.unsubscribe();
|
|
520
|
+
this._describedByChanges?.unsubscribe();
|
|
521
|
+
if (control) {
|
|
522
|
+
if (control.controlType) {
|
|
523
|
+
this._elementRef.nativeElement.classList.add(classPrefix + control.controlType);
|
|
524
|
+
}
|
|
525
|
+
// Subscribe to changes in the child control state to update the form field UI.
|
|
526
|
+
this._stateChanges = control.stateChanges?.subscribe(() => {
|
|
527
|
+
this._updateFocusState();
|
|
528
|
+
this.markForCheck();
|
|
529
|
+
// CWT: Run CSS-classes validity after the change detection
|
|
530
|
+
setTimeout(() => {
|
|
531
|
+
this.displayValidity(this.hideValidStyle);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
// Updating the `aria-describedby` touches the DOM. Only do it if it actually needs to change.
|
|
535
|
+
this._describedByChanges = control.stateChanges?.pipe(startWith([undefined, undefined]), map(() => [control.errorState, control.userAriaDescribedBy]), pairwise(), filter(([[prevErrorState, prevDescribedBy], [currentErrorState, currentDescribedBy]]) => {
|
|
536
|
+
return prevErrorState !== currentErrorState || prevDescribedBy !== currentDescribedBy;
|
|
537
|
+
}))
|
|
538
|
+
.subscribe(() => this._syncDescribedByIds());
|
|
539
|
+
// Run change detection if the value changes.
|
|
540
|
+
if (control.ngControl && control.ngControl.valueChanges) {
|
|
541
|
+
this._valueChanges = control.ngControl.valueChanges
|
|
542
|
+
.pipe(takeUntil(this._destroyed))
|
|
543
|
+
.subscribe(() => this.markForCheck());
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
_checkPrefixAndSuffixTypes() {
|
|
548
|
+
this._hasIconPrefix = !!this._prefixChildren?.find(p => !p._isText);
|
|
549
|
+
this._hasTextPrefix = !!this._prefixChildren?.find(p => p._isText);
|
|
550
|
+
this._hasIconSuffix = !!this._suffixChildren?.find(s => !s._isText);
|
|
551
|
+
this._hasTextSuffix = !!this._suffixChildren?.find(s => s._isText);
|
|
552
|
+
}
|
|
553
|
+
/** Initializes the prefix and suffix containers. */
|
|
554
|
+
_initializePrefixAndSuffix() {
|
|
555
|
+
this._checkPrefixAndSuffixTypes();
|
|
556
|
+
// Mark the form field as dirty whenever the prefix or suffix children change. This
|
|
557
|
+
// is necessary because we conditionally display the prefix/suffix containers based
|
|
558
|
+
// on whether there is projected content.
|
|
559
|
+
merge(this._prefixChildren?.changes || EMPTY, this._suffixChildren?.changes || EMPTY).subscribe(() => {
|
|
560
|
+
this._checkPrefixAndSuffixTypes();
|
|
561
|
+
this.markForCheck();
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Initializes the subscript by validating hints and synchronizing "aria-describedby" ids
|
|
566
|
+
* with the custom form field control. Also subscribe to hint and error changes
|
|
567
|
+
* to be able to validate and synchronize ids on change.
|
|
568
|
+
*/
|
|
569
|
+
_initializeSubscript() {
|
|
570
|
+
// Re-validate when the number of hints changes.
|
|
571
|
+
this._hintChildren?.changes.subscribe(() => {
|
|
572
|
+
this._processHints();
|
|
573
|
+
this.markForCheck();
|
|
574
|
+
});
|
|
575
|
+
// Update the aria-described by when the number of errors changes.
|
|
576
|
+
this._errorChildren?.changes.subscribe(() => {
|
|
577
|
+
this._syncDescribedByIds();
|
|
578
|
+
this.markForCheck();
|
|
579
|
+
});
|
|
580
|
+
// Initial mat-hint validation and subscript describedByIds sync.
|
|
581
|
+
this._validateHints();
|
|
582
|
+
this._syncDescribedByIds();
|
|
583
|
+
}
|
|
584
|
+
/** Throws an error if the form field's control is missing. */
|
|
585
|
+
_assertFormFieldControl() {
|
|
586
|
+
if (!this._control && isDevMode()) {
|
|
587
|
+
throw getCuteFormFieldMissingControlError();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
_updateFocusState() {
|
|
591
|
+
const controlFocused = this._control?.focused;
|
|
592
|
+
// Usually, the MDC foundation would call "activateFocus" and "deactivateFocus" whenever
|
|
593
|
+
// certain DOM events are emitted. This is not possible in our implementation of the
|
|
594
|
+
// form field because we support abstract form field controls which are not necessarily
|
|
595
|
+
// of type input, nor do we have a reference to a native form field control element. Instead,
|
|
596
|
+
// we handle the focus by checking if the abstract form field control focused state changes.
|
|
597
|
+
if (controlFocused && !this._isFocused) {
|
|
598
|
+
this._isFocused = true;
|
|
599
|
+
//this._lineRipple?.activate();
|
|
600
|
+
}
|
|
601
|
+
else if (!controlFocused && (this._isFocused || this._isFocused === null)) {
|
|
602
|
+
this._isFocused = false;
|
|
603
|
+
//this._lineRipple?.deactivate();
|
|
604
|
+
}
|
|
605
|
+
this._elementRef.nativeElement.classList.toggle('cute-focused', controlFocused);
|
|
606
|
+
this._textField?.nativeElement.classList.toggle('cute-text-field--focused', controlFocused);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* The floating label in the docked state needs to account for prefixes. The horizontal offset
|
|
610
|
+
* is calculated whenever the appearance changes to `outline`, the prefixes change, or when the
|
|
611
|
+
* form field is added to the DOM. This method sets up all subscriptions that are needed to
|
|
612
|
+
* trigger the label offset update. In general, we want to avoid performing measurements often,
|
|
613
|
+
* so we rely on the `NgZone` as indicator when the offset should be recalculated, instead of
|
|
614
|
+
* checking every change detection cycle.
|
|
615
|
+
* @deprecated
|
|
616
|
+
*/
|
|
617
|
+
_initializeOutlineLabelOffsetSubscriptions() {
|
|
618
|
+
// Whenever the prefix changes, schedule an update of the label offset.
|
|
619
|
+
this._prefixChildren?.changes.subscribe(() => (this._needsOutlineLabelOffsetUpdate = true));
|
|
620
|
+
// TODO(mmalerba): Split this into separate `afterEveryRender` calls using the `EarlyRead` and
|
|
621
|
+
// `Write` phases.
|
|
622
|
+
afterEveryRender(() => {
|
|
623
|
+
if (this._needsOutlineLabelOffsetUpdate) {
|
|
624
|
+
this._needsOutlineLabelOffsetUpdate = false;
|
|
625
|
+
this._getOutlinedLabelOffset();
|
|
626
|
+
}
|
|
627
|
+
}, {
|
|
628
|
+
injector: this._injector,
|
|
629
|
+
});
|
|
630
|
+
this._dir.change
|
|
631
|
+
.pipe(takeUntil(this._destroyed))
|
|
632
|
+
.subscribe(() => (this._needsOutlineLabelOffsetUpdate = true));
|
|
633
|
+
}
|
|
634
|
+
/** Whether the floating label should always float or not. */
|
|
635
|
+
_shouldAlwaysFloat() {
|
|
636
|
+
return this.floatLabel === 'always';
|
|
637
|
+
}
|
|
638
|
+
/** <cute-datepicker> uses this method */
|
|
639
|
+
_shouldLabelFloat() {
|
|
640
|
+
//return false;
|
|
641
|
+
if (!this._hasFloatingLabel()) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
return this._control?.shouldLabelFloat || this._shouldAlwaysFloat();
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Determines whether a class from the AbstractControlDirective
|
|
648
|
+
* should be forwarded to the host element.
|
|
649
|
+
*/
|
|
650
|
+
_shouldForward(prop) {
|
|
651
|
+
const control = this._control ? this._control.ngControl : null;
|
|
652
|
+
return control && control[prop];
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Determines whether to display hints or errors.
|
|
656
|
+
* @author A.Strelkov:
|
|
657
|
+
* + Add _undefined_ to return value when no hints and errors exist.
|
|
658
|
+
* + Change to `protected`.
|
|
659
|
+
*/
|
|
660
|
+
_getSubscriptMessageType() {
|
|
661
|
+
return this._errorChildren && this._errorChildren.length > 0 && this._control?.errorState
|
|
662
|
+
? 'error'
|
|
663
|
+
: this._hintChildren && this._hintChildren.length > 0
|
|
664
|
+
? 'hint'
|
|
665
|
+
: undefined;
|
|
666
|
+
}
|
|
667
|
+
/** Does any extra processing required when handling the hints. */
|
|
668
|
+
_processHints() {
|
|
669
|
+
this._validateHints();
|
|
670
|
+
this._syncDescribedByIds();
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Ensure that there is a maximum of one of each "cute-hint" alignment specified. The hint
|
|
674
|
+
* label specified set through the input is being considered as "start" aligned.
|
|
675
|
+
*
|
|
676
|
+
* This method is a noop if Angular runs in production mode.
|
|
677
|
+
*/
|
|
678
|
+
_validateHints() {
|
|
679
|
+
if (this._hintChildren && isDevMode()) {
|
|
680
|
+
let startHint;
|
|
681
|
+
let endHint;
|
|
682
|
+
this._hintChildren.forEach((hint) => {
|
|
683
|
+
if (hint.align === 'start') {
|
|
684
|
+
if (startHint || this.hintLabel) {
|
|
685
|
+
throw getCuteFormFieldDuplicatedHintError('start');
|
|
686
|
+
}
|
|
687
|
+
startHint = hint;
|
|
688
|
+
}
|
|
689
|
+
else if (hint.align === 'end') {
|
|
690
|
+
if (endHint) {
|
|
691
|
+
throw getCuteFormFieldDuplicatedHintError('end');
|
|
692
|
+
}
|
|
693
|
+
endHint = hint;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Sets the list of element IDs that describe the child control. This allows the control to update
|
|
700
|
+
* its `aria-describedby` attribute accordingly.
|
|
701
|
+
*/
|
|
702
|
+
_syncDescribedByIds() {
|
|
703
|
+
if (this._control) {
|
|
704
|
+
let ids = [];
|
|
705
|
+
// TODO(wagnermaciel): Remove the type check when we find the root cause of this bug.
|
|
706
|
+
if (this._control.userAriaDescribedBy &&
|
|
707
|
+
typeof this._control.userAriaDescribedBy === 'string') {
|
|
708
|
+
ids.push(...this._control.userAriaDescribedBy.split(' '));
|
|
709
|
+
}
|
|
710
|
+
if (this._getSubscriptMessageType() === 'hint') {
|
|
711
|
+
const startHint = this._hintChildren
|
|
712
|
+
? this._hintChildren.find(hint => hint.align === 'start')
|
|
713
|
+
: null;
|
|
714
|
+
const endHint = this._hintChildren
|
|
715
|
+
? this._hintChildren.find(hint => hint.align === 'end')
|
|
716
|
+
: null;
|
|
717
|
+
if (startHint) {
|
|
718
|
+
ids.push(startHint.id);
|
|
719
|
+
}
|
|
720
|
+
else if (this._hintLabel) {
|
|
721
|
+
ids.push(this._hintLabelId);
|
|
722
|
+
}
|
|
723
|
+
if (endHint) {
|
|
724
|
+
ids.push(endHint.id);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
else if (this._errorChildren) {
|
|
728
|
+
ids.push(...this._errorChildren.map(error => error.id));
|
|
729
|
+
}
|
|
730
|
+
const existingDescribedBy = this._control.describedByIds;
|
|
731
|
+
let toAssign;
|
|
732
|
+
// In some cases there might be some `aria-describedby` IDs that were assigned directly,
|
|
733
|
+
// like by the `AriaDescriber` (see #30011). Attempt to preserve them by taking the previous
|
|
734
|
+
// attribute value and filtering out the IDs that came from the previous `setDescribedByIds`
|
|
735
|
+
// call. Note the `|| ids` here allows us to avoid duplicating IDs on the first render.
|
|
736
|
+
if (existingDescribedBy) {
|
|
737
|
+
const exclude = this._describedByIds || ids;
|
|
738
|
+
toAssign = ids.concat(existingDescribedBy.filter(id => id && !exclude.includes(id)));
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
toAssign = ids;
|
|
742
|
+
}
|
|
743
|
+
this._control.setDescribedByIds(toAssign);
|
|
744
|
+
this._describedByIds = ids;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Calculates the horizontal offset of the label in the outline appearance. In the outline
|
|
749
|
+
* appearance, the notched-outline and label are not relative to the infix container because
|
|
750
|
+
* the outline intends to surround prefixes, suffixes and the infix. This means that the
|
|
751
|
+
* floating label by default overlaps prefixes in the docked state. To avoid this, we need to
|
|
752
|
+
* horizontally offset the label by the width of the prefix container. The MDC text-field does
|
|
753
|
+
* not need to do this because they use a fixed width for prefixes. Hence, they can simply
|
|
754
|
+
* incorporate the horizontal offset into their default text-field styles.
|
|
755
|
+
*/
|
|
756
|
+
_getOutlinedLabelOffset() {
|
|
757
|
+
return null;
|
|
758
|
+
/*
|
|
759
|
+
if (!this._hasOutline() || !this._floatingLabel) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const floatingLabel = this._floatingLabel.element;
|
|
763
|
+
// If no prefix is displayed, reset the outline label offset from potential
|
|
764
|
+
// previous label offset updates.
|
|
765
|
+
if (!(this._iconPrefixContainer || this._textPrefixContainer)) {
|
|
766
|
+
floatingLabel.style.transform = '';
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
// If the form field is not attached to the DOM yet (e.g. in a tab), we defer
|
|
770
|
+
// the label offset update until the zone stabilizes.
|
|
771
|
+
if (!this._isAttachedToDom()) {
|
|
772
|
+
this._needsOutlineLabelOffsetUpdate = true;
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const iconPrefixContainer = this._iconPrefixContainer?.nativeElement;
|
|
776
|
+
const textPrefixContainer = this._textPrefixContainer?.nativeElement;
|
|
777
|
+
const iconSuffixContainer = this._iconSuffixContainer?.nativeElement;
|
|
778
|
+
const textSuffixContainer = this._textSuffixContainer?.nativeElement;
|
|
779
|
+
const iconPrefixContainerWidth = iconPrefixContainer?.getBoundingClientRect().width ?? 0;
|
|
780
|
+
const textPrefixContainerWidth = textPrefixContainer?.getBoundingClientRect().width ?? 0;
|
|
781
|
+
const iconSuffixContainerWidth = iconSuffixContainer?.getBoundingClientRect().width ?? 0;
|
|
782
|
+
const textSuffixContainerWidth = textSuffixContainer?.getBoundingClientRect().width ?? 0;
|
|
783
|
+
// If the directionality is RTL, the x-axis transform needs to be inverted. This
|
|
784
|
+
// is because `transformX` does not change based on the page directionality.
|
|
785
|
+
const negate = this._dir.value === 'rtl' ? '-1' : '1';
|
|
786
|
+
const prefixWidth = `${iconPrefixContainerWidth + textPrefixContainerWidth}px`;
|
|
787
|
+
const labelOffset = `var(--mat-mdc-form-field-label-offset-x, 0px)`;
|
|
788
|
+
const labelHorizontalOffset = `calc(${negate} * (${prefixWidth} + ${labelOffset}))`;
|
|
789
|
+
|
|
790
|
+
// Update the translateX of the floating label to account for the prefix container,
|
|
791
|
+
// but allow the CSS to override this setting via a CSS variable when the label is
|
|
792
|
+
// floating.
|
|
793
|
+
floatingLabel.style.transform = `var(
|
|
794
|
+
--mat-mdc-form-field-label-transform,
|
|
795
|
+
${FLOATING_LABEL_DEFAULT_DOCKED_TRANSFORM} translateX(${labelHorizontalOffset})
|
|
796
|
+
)`;
|
|
797
|
+
|
|
798
|
+
// Prevent the label from overlapping the suffix when in resting position.
|
|
799
|
+
const prefixAndSuffixWidth =
|
|
800
|
+
iconPrefixContainerWidth +
|
|
801
|
+
textPrefixContainerWidth +
|
|
802
|
+
iconSuffixContainerWidth +
|
|
803
|
+
textSuffixContainerWidth;
|
|
804
|
+
this._elementRef.nativeElement.style.setProperty(
|
|
805
|
+
'--mat-form-field-notch-max-width',
|
|
806
|
+
`calc(100% - ${prefixAndSuffixWidth}px)`,
|
|
807
|
+
);
|
|
808
|
+
*/
|
|
809
|
+
}
|
|
810
|
+
/** Checks whether the form field is attached to the DOM. */
|
|
811
|
+
_isAttachedToDom() {
|
|
812
|
+
const element = this._elementRef.nativeElement;
|
|
813
|
+
if (element.getRootNode) {
|
|
814
|
+
const rootNode = element.getRootNode();
|
|
815
|
+
// If the element is inside the DOM, the root node will be either the document
|
|
816
|
+
// or the closest shadow root, otherwise it'll be the element itself.
|
|
817
|
+
return rootNode && rootNode !== element;
|
|
818
|
+
}
|
|
819
|
+
// Otherwise, fall back to checking if it's in the document. This doesn't account for
|
|
820
|
+
// shadow DOM, however, browser that supports shadow DOM should support `getRootNode` as well.
|
|
821
|
+
return document.documentElement.contains(element);
|
|
822
|
+
}
|
|
823
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormField, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
824
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: CuteFormField, isStandalone: true, selector: "cute-form-field", inputs: { hideValidStyle: "hideValidStyle", hideRequiredMarker: "hideRequiredMarker", magnitude: "magnitude", floatLabel: "floatLabel", subscriptSizing: "subscriptSizing", hintLabel: "hintLabel" }, host: { properties: { "class.cute-form-field-label-always-float": "_shouldAlwaysFloat()", "class.cute-form-field-invalid": "_control?.errorState", "class.cute-form-field-disabled": "_control?.disabled", "class.cute-form-field-autofilled": "_control?.autofilled", "class.ng-untouched": "_shouldForward(\"untouched\")", "class.ng-touched": "_shouldForward(\"touched\")", "class.ng-pristine": "_shouldForward(\"pristine\")", "class.ng-dirty": "_shouldForward(\"dirty\")", "class.ng-valid": "_shouldForward(\"valid\")", "class.ng-invalid": "_shouldForward(\"invalid\")", "class.ng-pending": "_shouldForward(\"pending\")" }, classAttribute: "cute-form-field" }, providers: [
|
|
825
|
+
{ provide: CUTE_FORM_FIELD, useExisting: CuteFormField },
|
|
826
|
+
], queries: [{ propertyName: "_labelChild", first: true, predicate: CuteLabel, descendants: true, isSignal: true }, { propertyName: "_labelChildNonStatic", first: true, predicate: CuteLabel, descendants: true }, { propertyName: "_labelChildStatic", first: true, predicate: CuteLabel, descendants: true, static: true }, { propertyName: "_formFieldControl", first: true, predicate: CuteFormFieldControl, descendants: true }, { propertyName: "_prefixChildren", predicate: CUTE_PREFIX, descendants: true }, { propertyName: "_suffixChildren", predicate: CUTE_SUFFIX, descendants: true }, { propertyName: "_errorChildren", predicate: CUTE_ERROR, descendants: true }, { propertyName: "_hintChildren", predicate: CuteHint, descendants: true }], viewQueries: [{ propertyName: "_textField", first: true, predicate: ["textField"], descendants: true }], exportAs: ["cuteFormField"], usesInheritance: true, ngImport: i0, template: "<ng-template #labelTemplate>\r\n @if (_hasFloatingLabel()) {\r\n <label class=\"form-label cute-form-control-placeholder\"\r\n [id]=\"_labelId\"\r\n [attr.for]=\"(_control && !_control.disableAutomaticLabeling) ? _control.id : null\"\r\n tabindex=\"-1\">\r\n <ng-content select=\"cute-label\"></ng-content>\r\n <!--\r\n We set the required marker as a separate element, in order to make it easier to target if\r\n apps want to override it and to be able to set `aria-hidden` so that screen readers don't\r\n pick it up.\r\n -->\r\n @if (!hideRequiredMarker && _control?.required) {\r\n <span aria-hidden=\"true\"\r\n class=\"cute-form-field-required-marker cute-floating-label--required\">\r\n </span>\r\n }\r\n </label>\r\n }\r\n</ng-template>\r\n\r\n<div class=\"cute-text-field\" #textField (click)=\"_control?.onContainerClick($event)\">\r\n\r\n <!-- label -->\r\n @if (!_isFloatLabel) {\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\r\n }\r\n\r\n <!-- brief instruction -->\r\n <!-- <ng-content select=\"cute-intro\"></ng-content>-->\r\n\r\n <!-- input -->\r\n <div class=\"flex-nowrap cute-text-field__input\"\r\n [class]=\"!_isFloatLabel?'input-group '+(magnitudeSuffix?' input-group'+magnitudeSuffix :''):''\"\r\n [class.form-floating]=\"_isFloatLabel\">\r\n\r\n @if (_hasIconPrefix) {\r\n <ng-content select=\"[cutePrefix], [cuteIconPrefix]\"></ng-content>\r\n }\r\n @if (_hasTextPrefix) {\r\n <ng-content select=\"[cuteTextPrefix]\"></ng-content>\r\n }\r\n\r\n<!-- <div #infixField class=\"cute-form-field-control input-group-text\">-->\r\n <ng-content></ng-content>\r\n @if (_isFloatLabel) {\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\r\n }\r\n<!-- </div>-->\r\n\r\n @if (_hasTextSuffix) {\r\n <ng-content select=\"[cuteTextSuffix]\"></ng-content>\r\n }\r\n @if (_hasIconSuffix) {\r\n <ng-content select=\"[cuteSuffix], [cuteIconSuffix]\"></ng-content>\r\n }\r\n </div>\r\n\r\n</div>\r\n\r\n<!--<ng-content select=\"cute-error, [cuteError]\"></ng-content>-->\r\n\r\n<!-- messages -->\r\n\r\n<div [class.cute-form-field-bottom-align]=\"subscriptSizing=='fixed'\">\r\n\r\n @let subscriptMessageType = _getSubscriptMessageType();\r\n\r\n @switch (subscriptMessageType) {\r\n @case ('error') {\r\n <div class=\"cute-form-field-error-wrapper\">\r\n <ng-content select=\"cute-error, [cuteError]\"></ng-content>\r\n </div>\r\n }\r\n\r\n @case ('hint') {\r\n <div class=\"cute-form-field-hint-wrapper\">\r\n @if (hintLabel) {\r\n <cute-hint [id]=\"_hintLabelId\">{{hintLabel}}</cute-hint>\r\n }\r\n <ng-content select=\"cute-hint:not([align='end'])\"></ng-content>\r\n <div class=\"cute-form-field-hint-spacer\"></div>\r\n <ng-content select=\"cute-hint[align='end']\"></ng-content>\r\n </div>\r\n }\r\n }\r\n</div>\r\n\r\n", styles: [".cute-form-field{display:inline-flex;flex-direction:column;min-width:0;max-width:100%;text-align:start}.cute-form-field .cute-text-field{display:inline-flex;flex-direction:column;width:100%;justify-content:start}.cute-form-field .form-label{margin-bottom:.25rem}.cute-form-field .form-floating>.form-control:focus~label:after,.cute-form-field .form-floating>.form-control:not(:placeholder-shown)~label:after,.cute-form-field .form-floating>.form-control-plaintext~label:after,.cute-form-field .form-floating>.form-select~label:after{background-color:transparent}.cute-form-field .cute-form-field-hint-wrapper,.cute-form-field .cute-form-field-error-wrapper{display:flex;animation:_cute-form-field-subscript-animation 0ms cubic-bezier(.55,0,.55,.2)}.cute-form-field.cute-form-field-animations-enabled .cute-form-field-hint-wrapper,.cute-form-field.cute-form-field-animations-enabled .cute-form-field-error-wrapper{animation-duration:.3s}.cute-form-field.cute-form-field-disabled input:not([readonly]){opacity:.85;pointer-events:none}.cute-form-field.cute-form-field-disabled.cute-input-disabled-interactive{pointer-events:auto}.cute-form-field .cute-form-field-hint-spacer{flex:1 0 1em}.cute-form-field .cute-form-field-bottom-align:empty:before{display:block;content:\"-\";margin-top:.125rem;font-size:.875em;color:transparent;pointer-events:none}.cute-form-field .cute-form-field-required-marker:after,.cute-form-field .cute-floating-label--required:after{content:\"*\";margin-inline-start:3px;margin-inline-end:0;vertical-align:top;color:var(--bs-danger)}.cute-form-field input.ng-dirty:not(:placeholder-shown){background-color:var(--bs-warning-bg-subtle)}.cute-form-field input:placeholder-shown{text-overflow:ellipsis}[dir=rtl] .input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback){margin-left:0;margin-right:calc(var(--bs-border-width) * -1);border-radius:var(--bs-border-radius) 0 0 var(--bs-border-radius)}[dir=rtl] .input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback):not(:last-child){border-radius:0}[dir=rtl] .input-group:not(.has-validation)>:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),[dir=rtl] .input-group:not(.has-validation)>.dropdown-toggle:nth-last-child(n+3),[dir=rtl] .input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-control,[dir=rtl] .input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-select{border-radius:0 var(--bs-border-radius) var(--bs-border-radius) 0}:not([dir=rtl]) .input-group .cute-widget:not(:first-child) .form-select,:not([dir=rtl]) .input-group .cute-widget:not(:first-child) .dropdown-toggle{margin-left:calc(var(--bs-border-width) * -1);border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group .cute-widget:not(:first-child) .form-select,[dir=rtl] .input-group .cute-widget:not(:first-child) .dropdown-toggle{margin-right:calc(var(--bs-border-width) * 1);border-top-right-radius:0;border-bottom-right-radius:0}:not([dir=rtl]) .input-group .cute-widget:not(:last-child) .form-select,:not([dir=rtl]) .input-group .cute-widget:not(:last-child) .dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .input-group .cute-widget:not(:last-child) .form-select,[dir=rtl] .input-group .cute-widget:not(:last-child) .dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group .cute-widget:not(:last-child) .form-select:first-child,[dir=rtl] .input-group .cute-widget:not(:last-child) .dropdown-toggle:first-child{border-top-right-radius:var(--bs-border-radius);border-bottom-right-radius:var(--bs-border-radius)}.input-group .cute-form-field-control{display:contents;border:2px gray solid;border-radius:inherit}.input-group .cute-form-field-control .form-control,.input-group .cute-form-field-control .form-select{border:1px gray solid;border-radius:inherit;position:relative;box-sizing:border-box}.input-group [cutePrefix],[cuteIconPrefix],[cuteSuffix],[cuteIconSuffix]{display:inline-flex!important;justify-content:center}.cute-form-field-prefix .cute-icon,.cute-form-field-suffix .cute-icon{display:block}.cute-form-field-prefix .cute-icon-button .cute-icon,.cute-form-field-suffix .cute-icon-button .cute-icon{margin:auto}.cute-form-field-hint,.cute-form-field-error{display:block;text-align:start;font-size:.75rem;-webkit-font-smoothing:antialiased}.cute-form-field-hint-end{order:1}.form-floating>.form-control:focus::placeholder{color:var(--bs-body-color);opacity:.75}.form-floating>.form-control-plaintext~.form-label,.form-floating>.form-control:focus~.form-label,.form-floating>.form-control:not(:placeholder-shown)~.form-label,.form-floating>.form-select~.form-label{color:rgba(var(--bs-body-color-rgb),.9);transform:scale(.85) translateY(-.625rem) translate(.15rem)}.cute-form-field-label-always-float .form-label{transform:scale(.85) translateY(-.625rem) translate(.15rem)}.cute-form-field-label-always-float .form-floating>.form-control:not(:focus):placeholder-shown{padding-top:2rem}.cute-form-field-label-always-float .form-floating>.form-control:not(:focus)::placeholder{color:var(--bs-body-color);opacity:.75}@keyframes _cute-form-field-subscript-animation{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translateY(0)}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CuteHint, selector: "cute-hint", inputs: ["align", "id"], exportAs: ["cuteHint"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
827
|
+
}
|
|
828
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormField, decorators: [{
|
|
829
|
+
type: Component,
|
|
830
|
+
args: [{ selector: 'cute-form-field', exportAs: 'cuteFormField', host: {
|
|
831
|
+
'class': 'cute-form-field',
|
|
832
|
+
'[class.cute-form-field-label-always-float]': '_shouldAlwaysFloat()',
|
|
833
|
+
'[class.cute-form-field-invalid]': '_control?.errorState',
|
|
834
|
+
'[class.cute-form-field-disabled]': '_control?.disabled',
|
|
835
|
+
'[class.cute-form-field-autofilled]': '_control?.autofilled',
|
|
836
|
+
'[class.ng-untouched]': '_shouldForward("untouched")',
|
|
837
|
+
'[class.ng-touched]': '_shouldForward("touched")',
|
|
838
|
+
'[class.ng-pristine]': '_shouldForward("pristine")',
|
|
839
|
+
'[class.ng-dirty]': '_shouldForward("dirty")',
|
|
840
|
+
'[class.ng-valid]': '_shouldForward("valid")',
|
|
841
|
+
'[class.ng-invalid]': '_shouldForward("invalid")',
|
|
842
|
+
'[class.ng-pending]': '_shouldForward("pending")',
|
|
843
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
844
|
+
{ provide: CUTE_FORM_FIELD, useExisting: CuteFormField },
|
|
845
|
+
], imports: [
|
|
846
|
+
NgTemplateOutlet,
|
|
847
|
+
CuteHint
|
|
848
|
+
], template: "<ng-template #labelTemplate>\r\n @if (_hasFloatingLabel()) {\r\n <label class=\"form-label cute-form-control-placeholder\"\r\n [id]=\"_labelId\"\r\n [attr.for]=\"(_control && !_control.disableAutomaticLabeling) ? _control.id : null\"\r\n tabindex=\"-1\">\r\n <ng-content select=\"cute-label\"></ng-content>\r\n <!--\r\n We set the required marker as a separate element, in order to make it easier to target if\r\n apps want to override it and to be able to set `aria-hidden` so that screen readers don't\r\n pick it up.\r\n -->\r\n @if (!hideRequiredMarker && _control?.required) {\r\n <span aria-hidden=\"true\"\r\n class=\"cute-form-field-required-marker cute-floating-label--required\">\r\n </span>\r\n }\r\n </label>\r\n }\r\n</ng-template>\r\n\r\n<div class=\"cute-text-field\" #textField (click)=\"_control?.onContainerClick($event)\">\r\n\r\n <!-- label -->\r\n @if (!_isFloatLabel) {\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\r\n }\r\n\r\n <!-- brief instruction -->\r\n <!-- <ng-content select=\"cute-intro\"></ng-content>-->\r\n\r\n <!-- input -->\r\n <div class=\"flex-nowrap cute-text-field__input\"\r\n [class]=\"!_isFloatLabel?'input-group '+(magnitudeSuffix?' input-group'+magnitudeSuffix :''):''\"\r\n [class.form-floating]=\"_isFloatLabel\">\r\n\r\n @if (_hasIconPrefix) {\r\n <ng-content select=\"[cutePrefix], [cuteIconPrefix]\"></ng-content>\r\n }\r\n @if (_hasTextPrefix) {\r\n <ng-content select=\"[cuteTextPrefix]\"></ng-content>\r\n }\r\n\r\n<!-- <div #infixField class=\"cute-form-field-control input-group-text\">-->\r\n <ng-content></ng-content>\r\n @if (_isFloatLabel) {\r\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\r\n }\r\n<!-- </div>-->\r\n\r\n @if (_hasTextSuffix) {\r\n <ng-content select=\"[cuteTextSuffix]\"></ng-content>\r\n }\r\n @if (_hasIconSuffix) {\r\n <ng-content select=\"[cuteSuffix], [cuteIconSuffix]\"></ng-content>\r\n }\r\n </div>\r\n\r\n</div>\r\n\r\n<!--<ng-content select=\"cute-error, [cuteError]\"></ng-content>-->\r\n\r\n<!-- messages -->\r\n\r\n<div [class.cute-form-field-bottom-align]=\"subscriptSizing=='fixed'\">\r\n\r\n @let subscriptMessageType = _getSubscriptMessageType();\r\n\r\n @switch (subscriptMessageType) {\r\n @case ('error') {\r\n <div class=\"cute-form-field-error-wrapper\">\r\n <ng-content select=\"cute-error, [cuteError]\"></ng-content>\r\n </div>\r\n }\r\n\r\n @case ('hint') {\r\n <div class=\"cute-form-field-hint-wrapper\">\r\n @if (hintLabel) {\r\n <cute-hint [id]=\"_hintLabelId\">{{hintLabel}}</cute-hint>\r\n }\r\n <ng-content select=\"cute-hint:not([align='end'])\"></ng-content>\r\n <div class=\"cute-form-field-hint-spacer\"></div>\r\n <ng-content select=\"cute-hint[align='end']\"></ng-content>\r\n </div>\r\n }\r\n }\r\n</div>\r\n\r\n", styles: [".cute-form-field{display:inline-flex;flex-direction:column;min-width:0;max-width:100%;text-align:start}.cute-form-field .cute-text-field{display:inline-flex;flex-direction:column;width:100%;justify-content:start}.cute-form-field .form-label{margin-bottom:.25rem}.cute-form-field .form-floating>.form-control:focus~label:after,.cute-form-field .form-floating>.form-control:not(:placeholder-shown)~label:after,.cute-form-field .form-floating>.form-control-plaintext~label:after,.cute-form-field .form-floating>.form-select~label:after{background-color:transparent}.cute-form-field .cute-form-field-hint-wrapper,.cute-form-field .cute-form-field-error-wrapper{display:flex;animation:_cute-form-field-subscript-animation 0ms cubic-bezier(.55,0,.55,.2)}.cute-form-field.cute-form-field-animations-enabled .cute-form-field-hint-wrapper,.cute-form-field.cute-form-field-animations-enabled .cute-form-field-error-wrapper{animation-duration:.3s}.cute-form-field.cute-form-field-disabled input:not([readonly]){opacity:.85;pointer-events:none}.cute-form-field.cute-form-field-disabled.cute-input-disabled-interactive{pointer-events:auto}.cute-form-field .cute-form-field-hint-spacer{flex:1 0 1em}.cute-form-field .cute-form-field-bottom-align:empty:before{display:block;content:\"-\";margin-top:.125rem;font-size:.875em;color:transparent;pointer-events:none}.cute-form-field .cute-form-field-required-marker:after,.cute-form-field .cute-floating-label--required:after{content:\"*\";margin-inline-start:3px;margin-inline-end:0;vertical-align:top;color:var(--bs-danger)}.cute-form-field input.ng-dirty:not(:placeholder-shown){background-color:var(--bs-warning-bg-subtle)}.cute-form-field input:placeholder-shown{text-overflow:ellipsis}[dir=rtl] .input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback){margin-left:0;margin-right:calc(var(--bs-border-width) * -1);border-radius:var(--bs-border-radius) 0 0 var(--bs-border-radius)}[dir=rtl] .input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback):not(:last-child){border-radius:0}[dir=rtl] .input-group:not(.has-validation)>:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),[dir=rtl] .input-group:not(.has-validation)>.dropdown-toggle:nth-last-child(n+3),[dir=rtl] .input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-control,[dir=rtl] .input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-select{border-radius:0 var(--bs-border-radius) var(--bs-border-radius) 0}:not([dir=rtl]) .input-group .cute-widget:not(:first-child) .form-select,:not([dir=rtl]) .input-group .cute-widget:not(:first-child) .dropdown-toggle{margin-left:calc(var(--bs-border-width) * -1);border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group .cute-widget:not(:first-child) .form-select,[dir=rtl] .input-group .cute-widget:not(:first-child) .dropdown-toggle{margin-right:calc(var(--bs-border-width) * 1);border-top-right-radius:0;border-bottom-right-radius:0}:not([dir=rtl]) .input-group .cute-widget:not(:last-child) .form-select,:not([dir=rtl]) .input-group .cute-widget:not(:last-child) .dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .input-group .cute-widget:not(:last-child) .form-select,[dir=rtl] .input-group .cute-widget:not(:last-child) .dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group .cute-widget:not(:last-child) .form-select:first-child,[dir=rtl] .input-group .cute-widget:not(:last-child) .dropdown-toggle:first-child{border-top-right-radius:var(--bs-border-radius);border-bottom-right-radius:var(--bs-border-radius)}.input-group .cute-form-field-control{display:contents;border:2px gray solid;border-radius:inherit}.input-group .cute-form-field-control .form-control,.input-group .cute-form-field-control .form-select{border:1px gray solid;border-radius:inherit;position:relative;box-sizing:border-box}.input-group [cutePrefix],[cuteIconPrefix],[cuteSuffix],[cuteIconSuffix]{display:inline-flex!important;justify-content:center}.cute-form-field-prefix .cute-icon,.cute-form-field-suffix .cute-icon{display:block}.cute-form-field-prefix .cute-icon-button .cute-icon,.cute-form-field-suffix .cute-icon-button .cute-icon{margin:auto}.cute-form-field-hint,.cute-form-field-error{display:block;text-align:start;font-size:.75rem;-webkit-font-smoothing:antialiased}.cute-form-field-hint-end{order:1}.form-floating>.form-control:focus::placeholder{color:var(--bs-body-color);opacity:.75}.form-floating>.form-control-plaintext~.form-label,.form-floating>.form-control:focus~.form-label,.form-floating>.form-control:not(:placeholder-shown)~.form-label,.form-floating>.form-select~.form-label{color:rgba(var(--bs-body-color-rgb),.9);transform:scale(.85) translateY(-.625rem) translate(.15rem)}.cute-form-field-label-always-float .form-label{transform:scale(.85) translateY(-.625rem) translate(.15rem)}.cute-form-field-label-always-float .form-floating>.form-control:not(:focus):placeholder-shown{padding-top:2rem}.cute-form-field-label-always-float .form-floating>.form-control:not(:focus)::placeholder{color:var(--bs-body-color);opacity:.75}@keyframes _cute-form-field-subscript-animation{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translateY(0)}}\n"] }]
|
|
849
|
+
}], ctorParameters: () => [], propDecorators: { _textField: [{
|
|
850
|
+
type: ViewChild,
|
|
851
|
+
args: ['textField']
|
|
852
|
+
}], _labelChildNonStatic: [{
|
|
853
|
+
type: ContentChild,
|
|
854
|
+
args: [CuteLabel]
|
|
855
|
+
}], _labelChildStatic: [{
|
|
856
|
+
type: ContentChild,
|
|
857
|
+
args: [CuteLabel, { static: true }]
|
|
858
|
+
}], _formFieldControl: [{
|
|
859
|
+
type: ContentChild,
|
|
860
|
+
args: [CuteFormFieldControl]
|
|
861
|
+
}], _prefixChildren: [{
|
|
862
|
+
type: ContentChildren,
|
|
863
|
+
args: [CUTE_PREFIX, { descendants: true }]
|
|
864
|
+
}], _suffixChildren: [{
|
|
865
|
+
type: ContentChildren,
|
|
866
|
+
args: [CUTE_SUFFIX, { descendants: true }]
|
|
867
|
+
}], _errorChildren: [{
|
|
868
|
+
type: ContentChildren,
|
|
869
|
+
args: [CUTE_ERROR, { descendants: true }]
|
|
870
|
+
}], _hintChildren: [{
|
|
871
|
+
type: ContentChildren,
|
|
872
|
+
args: [CuteHint, { descendants: true }]
|
|
873
|
+
}], _labelChild: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CuteLabel), { isSignal: true }] }], hideValidStyle: [{
|
|
874
|
+
type: Input
|
|
875
|
+
}], hideRequiredMarker: [{
|
|
876
|
+
type: Input
|
|
877
|
+
}], magnitude: [{
|
|
878
|
+
type: Input
|
|
879
|
+
}], floatLabel: [{
|
|
880
|
+
type: Input
|
|
881
|
+
}], subscriptSizing: [{
|
|
882
|
+
type: Input
|
|
883
|
+
}], hintLabel: [{
|
|
884
|
+
type: Input
|
|
885
|
+
}] } });
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* @license Apache-2.0
|
|
889
|
+
*
|
|
890
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
891
|
+
*
|
|
892
|
+
* You may not use this file except in compliance with the License
|
|
893
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
894
|
+
*/
|
|
895
|
+
/** Intro text to be shown underneath the label of the form field control. */
|
|
896
|
+
class CuteIntro /* extends ... */ {
|
|
897
|
+
constructor() {
|
|
898
|
+
this._elementRef = inject(ElementRef);
|
|
899
|
+
}
|
|
900
|
+
/** Returns the intro's current text. */
|
|
901
|
+
getText() {
|
|
902
|
+
return this._elementRef.nativeElement.innerText;
|
|
903
|
+
}
|
|
904
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteIntro /* extends ... */, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
905
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteIntro /* extends ... */, isStandalone: true, selector: "cute-intro", inputs: { magnitude: "magnitude" }, host: { properties: { "style.font-size": "magnitude==\"small\" ? \"0.875rem\" : (magnitude==\"large\"? \"1.25rem\" : \"\")" } }, exportAs: ["cuteIntro"], ngImport: i0 }); }
|
|
906
|
+
}
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteIntro /* extends ... */, decorators: [{
|
|
908
|
+
type: Directive,
|
|
909
|
+
args: [{
|
|
910
|
+
selector: 'cute-intro',
|
|
911
|
+
exportAs: 'cuteIntro',
|
|
912
|
+
host: {
|
|
913
|
+
'[style.font-size]': 'magnitude=="small" ? "0.875rem" : (magnitude=="large"? "1.25rem" : "")'
|
|
914
|
+
},
|
|
915
|
+
standalone: true,
|
|
916
|
+
}]
|
|
917
|
+
}], propDecorators: { magnitude: [{
|
|
918
|
+
type: Input
|
|
919
|
+
}] } });
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* @license Apache-2.0
|
|
923
|
+
*
|
|
924
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
925
|
+
*
|
|
926
|
+
* You may not use this file except in compliance with the License
|
|
927
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
928
|
+
*/
|
|
929
|
+
const TYPES = [
|
|
930
|
+
CuteFormField,
|
|
931
|
+
CuteLabel,
|
|
932
|
+
CuteIntro,
|
|
933
|
+
CuteHint,
|
|
934
|
+
CutePrefix,
|
|
935
|
+
CuteSuffix,
|
|
936
|
+
CuteError,
|
|
937
|
+
];
|
|
938
|
+
class CuteFormFieldModule {
|
|
939
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
940
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldModule, imports: [CommonModule, CuteFormField,
|
|
941
|
+
CuteLabel,
|
|
942
|
+
CuteIntro,
|
|
943
|
+
CuteHint,
|
|
944
|
+
CutePrefix,
|
|
945
|
+
CuteSuffix,
|
|
946
|
+
CuteError], exports: [CuteFormField,
|
|
947
|
+
CuteLabel,
|
|
948
|
+
CuteIntro,
|
|
949
|
+
CuteHint,
|
|
950
|
+
CutePrefix,
|
|
951
|
+
CuteSuffix,
|
|
952
|
+
CuteError] }); }
|
|
953
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldModule, imports: [CommonModule] }); }
|
|
954
|
+
}
|
|
955
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteFormFieldModule, decorators: [{
|
|
956
|
+
type: NgModule,
|
|
957
|
+
args: [{
|
|
958
|
+
declarations: [],
|
|
959
|
+
imports: [CommonModule, ...TYPES],
|
|
960
|
+
exports: TYPES,
|
|
961
|
+
}]
|
|
962
|
+
}] });
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Generated bundle index. Do not edit.
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
export { CUTE_ERROR, CUTE_FORM_FIELD, CUTE_FORM_FIELD_DEFAULT_OPTIONS, CUTE_PREFIX, CUTE_SUFFIX, CuteError, CuteFormField, CuteFormFieldControl, CuteFormFieldModule, CuteHint, CuteIntro, CuteLabel, CutePrefix, CuteSuffix };
|
|
969
|
+
//# sourceMappingURL=cute-widgets-base-form-field.mjs.map
|