@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,637 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { forwardRef, InjectionToken, inject, ChangeDetectorRef, EventEmitter, booleanAttribute, Input, ContentChildren, Output, Directive, NgZone, Injector, DestroyRef, afterNextRender, ViewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
|
|
3
|
+
import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
|
|
4
|
+
import { CuteInputControl } from '@cute-widgets/base/abstract';
|
|
5
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @license Apache-2.0
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
13
|
+
*
|
|
14
|
+
* You may not use this file except in compliance with the License
|
|
15
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* This code is a modification of the `@angular/material` original
|
|
18
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Provider Expression that allows `cute-radio-group` to register as a `ControlValueAccessor`. This
|
|
22
|
+
* allows it to support `[(ngModel)]` and `ngControl`.
|
|
23
|
+
*/
|
|
24
|
+
const CUTE_RADIO_GROUP_CONTROL_VALUE_ACCESSOR = {
|
|
25
|
+
provide: NG_VALUE_ACCESSOR,
|
|
26
|
+
useExisting: forwardRef(() => CuteRadioGroup),
|
|
27
|
+
multi: true,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Injection token that can be used to inject instances of `CuteRadioGroup`. It serves as
|
|
31
|
+
* an alternative token to the actual `CuteRadioGroup` class which could cause unnecessary
|
|
32
|
+
* retention of the class and its component metadata.
|
|
33
|
+
*/
|
|
34
|
+
const CUTE_RADIO_GROUP = new InjectionToken('CuteRadioGroup');
|
|
35
|
+
// Increasing integer for generating unique ids for checkbox components.
|
|
36
|
+
let nextUniqueId$1 = 0;
|
|
37
|
+
/**
|
|
38
|
+
* A group of radio buttons. May contain one or more `<cute-radio-button>` elements.
|
|
39
|
+
*/
|
|
40
|
+
class CuteRadioGroup {
|
|
41
|
+
/** Name of the radio button group. All radio buttons inside this group will use this name. */
|
|
42
|
+
get name() { return this._name; }
|
|
43
|
+
set name(value) {
|
|
44
|
+
this._name = value;
|
|
45
|
+
this._updateRadioButtonNames();
|
|
46
|
+
}
|
|
47
|
+
/** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
|
|
48
|
+
get labelPosition() { return this._labelPosition; }
|
|
49
|
+
set labelPosition(v) {
|
|
50
|
+
this._labelPosition = v === 'before' ? 'before' : 'after';
|
|
51
|
+
this._markRadiosForCheck();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Value for the radio-group. Should equal the value of the selected radio button if there is
|
|
55
|
+
* a corresponding radio button with a matching value. If there is not such a corresponding
|
|
56
|
+
* radio button, this value persists to be applied in case a new radio button is added with a
|
|
57
|
+
* matching value.
|
|
58
|
+
*/
|
|
59
|
+
get value() { return this._value; }
|
|
60
|
+
set value(newValue) {
|
|
61
|
+
if (this._value !== newValue) {
|
|
62
|
+
// Set this before proceeding to ensure no circular loop occurs with selection.
|
|
63
|
+
this._value = newValue;
|
|
64
|
+
this._updateSelectedRadioFromValue();
|
|
65
|
+
this._checkSelectedRadioButton();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_checkSelectedRadioButton() {
|
|
69
|
+
if (this._selected && !this._selected.checked) {
|
|
70
|
+
this._selected.checked = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The currently selected radio button. If set to a new radio button, the radio group value
|
|
75
|
+
* will be updated to match the new selected button.
|
|
76
|
+
*/
|
|
77
|
+
get selected() { return this._selected; }
|
|
78
|
+
set selected(selected) {
|
|
79
|
+
this._selected = selected;
|
|
80
|
+
this.value = selected ? selected.value : null;
|
|
81
|
+
this._checkSelectedRadioButton();
|
|
82
|
+
}
|
|
83
|
+
/** Whether the radio group is disabled */
|
|
84
|
+
get disabled() { return this._disabled; }
|
|
85
|
+
set disabled(value) {
|
|
86
|
+
this._disabled = value;
|
|
87
|
+
this._markRadiosForCheck();
|
|
88
|
+
}
|
|
89
|
+
/** Whether the radio group is required */
|
|
90
|
+
get required() { return this._required; }
|
|
91
|
+
set required(value) {
|
|
92
|
+
this._required = value;
|
|
93
|
+
this._markRadiosForCheck();
|
|
94
|
+
}
|
|
95
|
+
/** Whether buttons in the group should be interactive while they're disabled. */
|
|
96
|
+
get disabledInteractive() {
|
|
97
|
+
return this._disabledInteractive;
|
|
98
|
+
}
|
|
99
|
+
set disabledInteractive(value) {
|
|
100
|
+
this._disabledInteractive = value;
|
|
101
|
+
this._markRadiosForCheck();
|
|
102
|
+
}
|
|
103
|
+
constructor() {
|
|
104
|
+
this._changeDetector = inject(ChangeDetectorRef);
|
|
105
|
+
/** Selected value for the radio group. */
|
|
106
|
+
this._value = null;
|
|
107
|
+
/** The HTML name attribute applied to radio buttons in this group. */
|
|
108
|
+
this._name = `cute-radio-group-${nextUniqueId$1++}`;
|
|
109
|
+
/** The currently selected radio button. Should match value. */
|
|
110
|
+
this._selected = null;
|
|
111
|
+
/** Whether the `value` has been set to its initial value. */
|
|
112
|
+
this._isInitialized = false;
|
|
113
|
+
/** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
|
|
114
|
+
this._labelPosition = 'after';
|
|
115
|
+
/** Whether the radio group is disabled. */
|
|
116
|
+
this._disabled = false;
|
|
117
|
+
/** Whether the radio group is required. */
|
|
118
|
+
this._required = false;
|
|
119
|
+
/** The method to be called in order to update ngModel */
|
|
120
|
+
this._controlValueAccessorChangeFn = () => { };
|
|
121
|
+
/**
|
|
122
|
+
* onTouch function registered via registerOnTouch (ControlValueAccessor).
|
|
123
|
+
* @docs-private
|
|
124
|
+
*/
|
|
125
|
+
this.onTouched = () => { };
|
|
126
|
+
/**
|
|
127
|
+
* Event emitted when the group value changes.
|
|
128
|
+
* Change events are only emitted when the value changes due to user interaction with
|
|
129
|
+
* a radio button (the same behavior as `<input type-"radio">`).
|
|
130
|
+
*/
|
|
131
|
+
this.change = new EventEmitter();
|
|
132
|
+
this._disabledInteractive = false;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Initialize properties once content children are available.
|
|
136
|
+
* This allows us to propagate relevant attributes to associated buttons.
|
|
137
|
+
*/
|
|
138
|
+
ngAfterContentInit() {
|
|
139
|
+
// Mark this component as initialized in AfterContentInit because the initial value can
|
|
140
|
+
// possibly be set by NgModel on CuteRadioGroup, and it is possible that the OnInit of the
|
|
141
|
+
// NgModel occurs *after* the OnInit of the CuteRadioGroup.
|
|
142
|
+
this._isInitialized = true;
|
|
143
|
+
// Clear the `selected` button when it's destroyed since the tabindex of the rest of the
|
|
144
|
+
// buttons depends on it. Note that we don't clear the `value`, because the radio button
|
|
145
|
+
// may be swapped out with a similar one and there are some internal apps that depend on
|
|
146
|
+
// that behavior.
|
|
147
|
+
if (this._radios) {
|
|
148
|
+
this._buttonChanges = this._radios.changes.subscribe(() => {
|
|
149
|
+
if (this.selected && this._radios && !this._radios.find(radio => radio === this.selected)) {
|
|
150
|
+
this._selected = null;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
ngOnDestroy() {
|
|
156
|
+
this._buttonChanges?.unsubscribe();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Mark this group as being "touched" (for ngModel). Meant to be called by the contained
|
|
160
|
+
* radio buttons upon their blur.
|
|
161
|
+
*/
|
|
162
|
+
_touch() {
|
|
163
|
+
if (this.onTouched) {
|
|
164
|
+
this.onTouched();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
_updateRadioButtonNames() {
|
|
168
|
+
if (this._radios) {
|
|
169
|
+
this._radios.forEach(radio => {
|
|
170
|
+
radio.name = this.name;
|
|
171
|
+
radio.markForCheck();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Updates the `selected` radio button from the internal _value state. */
|
|
176
|
+
_updateSelectedRadioFromValue() {
|
|
177
|
+
// If the value already matches the selected radio, do nothing.
|
|
178
|
+
const isAlreadySelected = this._selected !== null && this._selected.value === this._value;
|
|
179
|
+
if (this._radios && !isAlreadySelected) {
|
|
180
|
+
this._selected = null;
|
|
181
|
+
this._radios.forEach(radio => {
|
|
182
|
+
radio.checked = this.value === radio.value;
|
|
183
|
+
if (radio.checked) {
|
|
184
|
+
this._selected = radio;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Dispatch change event with current selection and group value. */
|
|
190
|
+
_emitChangeEvent() {
|
|
191
|
+
if (this._isInitialized) {
|
|
192
|
+
this.change.emit(new CuteRadioChange(this._selected, this._value));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
_markRadiosForCheck() {
|
|
196
|
+
if (this._radios) {
|
|
197
|
+
this._radios.forEach(radio => radio.markForCheck());
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Sets the model value. Implemented as part of ControlValueAccessor.
|
|
202
|
+
* @param value
|
|
203
|
+
*/
|
|
204
|
+
writeValue(value) {
|
|
205
|
+
this.value = value;
|
|
206
|
+
this._changeDetector.markForCheck();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Registers a callback to be triggered when the model value changes.
|
|
210
|
+
* Implemented as part of ControlValueAccessor.
|
|
211
|
+
* @param fn Callback to be registered.
|
|
212
|
+
*/
|
|
213
|
+
registerOnChange(fn) {
|
|
214
|
+
this._controlValueAccessorChangeFn = fn;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Registers a callback to be triggered when the control is touched.
|
|
218
|
+
* Implemented as part of ControlValueAccessor.
|
|
219
|
+
* @param fn Callback to be registered.
|
|
220
|
+
*/
|
|
221
|
+
registerOnTouched(fn) {
|
|
222
|
+
this.onTouched = fn;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
|
|
226
|
+
* @param isDisabled Whether the control should be disabled.
|
|
227
|
+
*/
|
|
228
|
+
setDisabledState(isDisabled) {
|
|
229
|
+
this.disabled = isDisabled;
|
|
230
|
+
this._changeDetector.markForCheck();
|
|
231
|
+
}
|
|
232
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
233
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.15", type: CuteRadioGroup, isStandalone: true, selector: "cute-radio-group", inputs: { color: "color", name: "name", labelPosition: "labelPosition", value: "value", selected: "selected", disabled: ["disabled", "disabled", booleanAttribute], required: ["required", "required", booleanAttribute], disabledInteractive: ["disabledInteractive", "disabledInteractive", booleanAttribute] }, outputs: { change: "change" }, host: { attributes: { "role": "radiogroup" }, classAttribute: "cute-radio-group" }, providers: [
|
|
234
|
+
CUTE_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
|
|
235
|
+
{ provide: CUTE_RADIO_GROUP, useExisting: CuteRadioGroup },
|
|
236
|
+
], queries: [{ propertyName: "_radios", predicate: i0.forwardRef(() => CuteRadioButton), descendants: true }], exportAs: ["cuteRadioGroup"], ngImport: i0 }); }
|
|
237
|
+
}
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioGroup, decorators: [{
|
|
239
|
+
type: Directive,
|
|
240
|
+
args: [{
|
|
241
|
+
selector: 'cute-radio-group',
|
|
242
|
+
exportAs: 'cuteRadioGroup',
|
|
243
|
+
standalone: true,
|
|
244
|
+
providers: [
|
|
245
|
+
CUTE_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
|
|
246
|
+
{ provide: CUTE_RADIO_GROUP, useExisting: CuteRadioGroup },
|
|
247
|
+
],
|
|
248
|
+
host: {
|
|
249
|
+
'role': 'radiogroup',
|
|
250
|
+
'class': 'cute-radio-group',
|
|
251
|
+
},
|
|
252
|
+
}]
|
|
253
|
+
}], ctorParameters: () => [], propDecorators: { change: [{
|
|
254
|
+
type: Output
|
|
255
|
+
}], _radios: [{
|
|
256
|
+
type: ContentChildren,
|
|
257
|
+
args: [forwardRef(() => CuteRadioButton), { descendants: true }]
|
|
258
|
+
}], color: [{
|
|
259
|
+
type: Input
|
|
260
|
+
}], name: [{
|
|
261
|
+
type: Input
|
|
262
|
+
}], labelPosition: [{
|
|
263
|
+
type: Input
|
|
264
|
+
}], value: [{
|
|
265
|
+
type: Input
|
|
266
|
+
}], selected: [{
|
|
267
|
+
type: Input
|
|
268
|
+
}], disabled: [{
|
|
269
|
+
type: Input,
|
|
270
|
+
args: [{ transform: booleanAttribute }]
|
|
271
|
+
}], required: [{
|
|
272
|
+
type: Input,
|
|
273
|
+
args: [{ transform: booleanAttribute }]
|
|
274
|
+
}], disabledInteractive: [{
|
|
275
|
+
type: Input,
|
|
276
|
+
args: [{ transform: booleanAttribute }]
|
|
277
|
+
}] } });
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @license Apache-2.0
|
|
281
|
+
*
|
|
282
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
283
|
+
*
|
|
284
|
+
* You may not use this file except in compliance with the License
|
|
285
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
286
|
+
*
|
|
287
|
+
* This code is a modification of the `@angular/material` original
|
|
288
|
+
* code licensed under MIT-style License (https://angular.dev/license).
|
|
289
|
+
*/
|
|
290
|
+
// Increasing integer for generating unique ids for checkbox components.
|
|
291
|
+
let nextUniqueId = 0;
|
|
292
|
+
/** Change an event object emitted by radio button and radio group. */
|
|
293
|
+
class CuteRadioChange {
|
|
294
|
+
constructor(
|
|
295
|
+
/** The radio button that emits the change event. */
|
|
296
|
+
source,
|
|
297
|
+
/** The value of the radio button. */
|
|
298
|
+
value) {
|
|
299
|
+
this.source = source;
|
|
300
|
+
this.value = value;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const CUTE_RADIO_DEFAULT_OPTIONS = new InjectionToken('cute-radio-default-options', {
|
|
304
|
+
providedIn: 'root',
|
|
305
|
+
factory: () => ({
|
|
306
|
+
color: "primary",
|
|
307
|
+
disabledInteractive: false,
|
|
308
|
+
}),
|
|
309
|
+
});
|
|
310
|
+
class CuteRadioButton extends CuteInputControl {
|
|
311
|
+
/** Whether this radio button is checked. */
|
|
312
|
+
get checked() { return this._checked; }
|
|
313
|
+
set checked(value) {
|
|
314
|
+
if (this._checked !== value) {
|
|
315
|
+
this._checked = value;
|
|
316
|
+
if (value && this.radioGroup && this.radioGroup.value !== this.value) {
|
|
317
|
+
this.radioGroup.selected = this;
|
|
318
|
+
}
|
|
319
|
+
else if (!value && this.radioGroup && this.radioGroup.value === this.value) {
|
|
320
|
+
// When unchecking the selected radio button, update the selected radio
|
|
321
|
+
// property on the group.
|
|
322
|
+
this.radioGroup.selected = null;
|
|
323
|
+
}
|
|
324
|
+
if (value) {
|
|
325
|
+
// Notify all radio buttons with the same name to uncheck.
|
|
326
|
+
this._radioDispatcher.notify(this.id || "", this.name || "");
|
|
327
|
+
}
|
|
328
|
+
this.markForCheck();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/** Whether the label should appear after or before the radio button. Defaults to 'after' */
|
|
332
|
+
get labelPosition() {
|
|
333
|
+
return this._labelPosition || (this.radioGroup && this.radioGroup.labelPosition) || 'after';
|
|
334
|
+
}
|
|
335
|
+
set labelPosition(value) {
|
|
336
|
+
this._labelPosition = value;
|
|
337
|
+
}
|
|
338
|
+
/** The value of this radio button. */
|
|
339
|
+
get value() { return this._value; }
|
|
340
|
+
set value(value) {
|
|
341
|
+
if (this._value !== value) {
|
|
342
|
+
this._value = value;
|
|
343
|
+
if (this.radioGroup !== null) {
|
|
344
|
+
if (!this.checked) {
|
|
345
|
+
// Update checked when the value changed to match the radio group's value
|
|
346
|
+
this.checked = this.radioGroup.value === value;
|
|
347
|
+
}
|
|
348
|
+
if (this.checked) {
|
|
349
|
+
this.radioGroup.selected = this;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/** Whether the radio button should remain interactive when it is disabled. */
|
|
355
|
+
get disabledInteractive() {
|
|
356
|
+
return (this._disabledInteractive || (this.radioGroup !== null && this.radioGroup.disabledInteractive));
|
|
357
|
+
}
|
|
358
|
+
set disabledInteractive(value) {
|
|
359
|
+
this._disabledInteractive = value;
|
|
360
|
+
}
|
|
361
|
+
generateId() {
|
|
362
|
+
return `cute-radio-button-${++nextUniqueId}`;
|
|
363
|
+
}
|
|
364
|
+
constructor() {
|
|
365
|
+
super();
|
|
366
|
+
this._ngZone = inject(NgZone);
|
|
367
|
+
this._injector = inject(Injector);
|
|
368
|
+
this._destroyRef = inject(DestroyRef);
|
|
369
|
+
this._radioDispatcher = inject(UniqueSelectionDispatcher);
|
|
370
|
+
this._defaultOptions = inject(CUTE_RADIO_DEFAULT_OPTIONS, {
|
|
371
|
+
optional: true,
|
|
372
|
+
});
|
|
373
|
+
/** Unregister function for _radioDispatcher */
|
|
374
|
+
this._removeUniqueSelectionListener = () => { };
|
|
375
|
+
this._checked = false;
|
|
376
|
+
/** Group radios on the same horizontal row */
|
|
377
|
+
this.inline = false;
|
|
378
|
+
this._labelPosition = 'after';
|
|
379
|
+
this._disabledInteractive = false;
|
|
380
|
+
/** Relative size of the radio icon. */
|
|
381
|
+
this.iconSize = "middle";
|
|
382
|
+
/**
|
|
383
|
+
* Event emitted when the checked state of this radio button changes.
|
|
384
|
+
* Change events are only emitted when the value changes due to user interaction with
|
|
385
|
+
* the radio button (the same behavior as `<input type-"radio">`).
|
|
386
|
+
*/
|
|
387
|
+
this.change = new EventEmitter();
|
|
388
|
+
/** Called when the input is clicked. */
|
|
389
|
+
this._onInputClick = (event) => {
|
|
390
|
+
// If the input is disabled while interactive, we need to prevent the
|
|
391
|
+
// selection from happening in this event handler. Note that even though
|
|
392
|
+
// this happens on `click` events, the logic applies when the user is
|
|
393
|
+
// navigating with the keyboard as well. An alternative way of doing
|
|
394
|
+
// this is by resetting the `checked` state in the `change` callback but
|
|
395
|
+
// it isn't optimal, because it can allow a pre-checked disabled button
|
|
396
|
+
// to be un-checked. This approach seems to cover everything.
|
|
397
|
+
if (this.disabled && this.disabledInteractive) {
|
|
398
|
+
event.preventDefault();
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const radioGroup = inject(CUTE_RADIO_GROUP, { optional: true });
|
|
402
|
+
// Assertions. Ideally these should be stripped out by the compiler.
|
|
403
|
+
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
|
|
404
|
+
this.radioGroup = radioGroup;
|
|
405
|
+
this._disabledInteractive = this._defaultOptions?.disabledInteractive ?? false;
|
|
406
|
+
}
|
|
407
|
+
/** Focuses the radio button. */
|
|
408
|
+
focus(origin, options) {
|
|
409
|
+
if (this._inputElement) {
|
|
410
|
+
if (origin) {
|
|
411
|
+
this._focusMonitor.focusVia(this._inputElement, origin, options);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
this._inputElement.nativeElement.focus(options);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Marks the radio button as needing checking for change detection.
|
|
420
|
+
* This method is exposed because the parent radio group will directly
|
|
421
|
+
* update bound properties of the radio button.
|
|
422
|
+
*/
|
|
423
|
+
_markForCheck() {
|
|
424
|
+
// When group value changes, the button will not be notified.
|
|
425
|
+
// Use `markForCheck` to explicitly update radio button's status.
|
|
426
|
+
this.markForCheck();
|
|
427
|
+
}
|
|
428
|
+
ngOnInit() {
|
|
429
|
+
super.ngOnInit();
|
|
430
|
+
if (this.radioGroup) {
|
|
431
|
+
// If the radio is inside a radio group, determine if it should be checked
|
|
432
|
+
this.checked = this.radioGroup.value === this.value;
|
|
433
|
+
if (this.checked) {
|
|
434
|
+
this.radioGroup.selected = this;
|
|
435
|
+
}
|
|
436
|
+
// Copy name from a parent radio group
|
|
437
|
+
this.name = this.radioGroup.name;
|
|
438
|
+
}
|
|
439
|
+
this._removeUniqueSelectionListener = this._radioDispatcher.listen((id, name) => {
|
|
440
|
+
if (id !== this.id && name === this.name) {
|
|
441
|
+
this.checked = false;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
ngDoCheck() {
|
|
446
|
+
this._updateTabIndex();
|
|
447
|
+
}
|
|
448
|
+
ngAfterViewInit() {
|
|
449
|
+
super.ngAfterViewInit();
|
|
450
|
+
this._updateTabIndex();
|
|
451
|
+
this._focusMonitor.monitor(this._elementRef, true)
|
|
452
|
+
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
453
|
+
.subscribe(focusOrigin => {
|
|
454
|
+
if (!focusOrigin && this.radioGroup) {
|
|
455
|
+
this.radioGroup._touch();
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
// We bind this outside of the zone, because:
|
|
459
|
+
// 1. Its logic is completely DOM-related so we can avoid some change detections.
|
|
460
|
+
// 2. There appear to be some internal tests that break when this triggers a change detection.
|
|
461
|
+
this._ngZone.runOutsideAngular(() => {
|
|
462
|
+
if (this._inputElement) {
|
|
463
|
+
this._cleanupClick = this._renderer.listen(this._inputElement.nativeElement, 'click', this._onInputClick);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
ngOnDestroy() {
|
|
468
|
+
super.ngOnDestroy();
|
|
469
|
+
this._cleanupClick?.();
|
|
470
|
+
this._removeUniqueSelectionListener();
|
|
471
|
+
}
|
|
472
|
+
/** Dispatch change event with current value. */
|
|
473
|
+
_emitChangeEvent() {
|
|
474
|
+
this.change.emit(new CuteRadioChange(this, this.value));
|
|
475
|
+
}
|
|
476
|
+
_preventBubblingFromLabel(event) {
|
|
477
|
+
// We have to stop propagation for click events on the visual hidden input element.
|
|
478
|
+
// By default, when a user clicks on a label element, a generated click event will be
|
|
479
|
+
// dispatched on the associated input element. Since we are using a label element as our
|
|
480
|
+
// root container, the click event on the `radio-button` will be executed twice.
|
|
481
|
+
// The real click event will bubble up, and the generated click event also tries to bubble up.
|
|
482
|
+
// This will lead to multiple click events.
|
|
483
|
+
// Preventing bubbling for the second event will solve that issue.
|
|
484
|
+
event.stopPropagation();
|
|
485
|
+
}
|
|
486
|
+
/** Triggered when the radio button receives an interaction from the user. */
|
|
487
|
+
_onInputInteraction(event) {
|
|
488
|
+
// We always have to stop propagation on the change event.
|
|
489
|
+
// Otherwise, the change event, from the input element, will bubble up and
|
|
490
|
+
// emit its event object to the `change` output.
|
|
491
|
+
event.stopPropagation();
|
|
492
|
+
if (!this.checked && !this.disabled) {
|
|
493
|
+
const groupValueChanged = this.radioGroup && this.value !== this.radioGroup.value;
|
|
494
|
+
this.checked = true;
|
|
495
|
+
this._emitChangeEvent();
|
|
496
|
+
if (this.radioGroup) {
|
|
497
|
+
this.radioGroup._controlValueAccessorChangeFn(this.value);
|
|
498
|
+
if (groupValueChanged) {
|
|
499
|
+
this.radioGroup._emitChangeEvent();
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/** Triggered when the user clicks on the touch target. */
|
|
505
|
+
_onTouchTargetClick(event) {
|
|
506
|
+
this._onInputInteraction(event);
|
|
507
|
+
if (!this.disabled || this.disabledInteractive) {
|
|
508
|
+
// Normally, the input should be focused already, but if the click
|
|
509
|
+
// comes from the touch target, then we might have to focus it ourselves.
|
|
510
|
+
this._inputElement?.nativeElement.focus();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/** Gets the tabindex for the underlying input element. */
|
|
514
|
+
_updateTabIndex() {
|
|
515
|
+
const group = this.radioGroup;
|
|
516
|
+
let value;
|
|
517
|
+
// Implement a roving tabindex if the button is inside a group. For most cases, this isn't
|
|
518
|
+
// necessary. The browser handles the tab order for inputs inside a group automatically,
|
|
519
|
+
// but we need an explicitly higher tabindex for the selected button in order for things like
|
|
520
|
+
// the focus trap to pick it up correctly.
|
|
521
|
+
if (!group || !group.selected || this.disabled) {
|
|
522
|
+
value = this.tabIndex || 0;
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
value = group.selected === this ? this.tabIndex || 0 : -1;
|
|
526
|
+
}
|
|
527
|
+
if (value !== this._previousTabIndex) {
|
|
528
|
+
// We have to set the tabindex directly on the DOM node, because it depends on
|
|
529
|
+
// the selected state which is prone to "changed after checked errors".
|
|
530
|
+
const input = this._inputElement?.nativeElement;
|
|
531
|
+
if (input) {
|
|
532
|
+
input.setAttribute('tabindex', value + '');
|
|
533
|
+
this._previousTabIndex = value;
|
|
534
|
+
}
|
|
535
|
+
// Wait for any pending tabindex changes to be applied
|
|
536
|
+
afterNextRender(() => {
|
|
537
|
+
queueMicrotask(() => {
|
|
538
|
+
// The radio group uses a "selection follows focus" pattern for tab management, so if this
|
|
539
|
+
// radio button is currently focused and another radio button in the group becomes
|
|
540
|
+
// selected, we should move focus to the newly selected radio button to maintain
|
|
541
|
+
// consistency between the focused and selected states.
|
|
542
|
+
if (group &&
|
|
543
|
+
group.selected &&
|
|
544
|
+
group.selected !== this &&
|
|
545
|
+
document.activeElement === input) {
|
|
546
|
+
group.selected._inputElement?.nativeElement.focus();
|
|
547
|
+
// If this radio button still has focus, the selected one must be disabled. In this
|
|
548
|
+
// case the radio group as a whole should lose focus.
|
|
549
|
+
if (document.activeElement === input) {
|
|
550
|
+
this._inputElement?.nativeElement.blur();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}, { injector: this._injector });
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
writeValue(obj) {
|
|
558
|
+
this.value = obj;
|
|
559
|
+
this.markForCheck();
|
|
560
|
+
}
|
|
561
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioButton, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
562
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.15", type: CuteRadioButton, isStandalone: true, selector: "cute-radio-button", inputs: { checked: ["checked", "checked", booleanAttribute], inline: ["inline", "inline", booleanAttribute], labelPosition: "labelPosition", value: "value", disabledInteractive: ["disabledInteractive", "disabledInteractive", booleanAttribute], iconSize: "iconSize" }, outputs: { change: "change" }, host: { listeners: { "focus": "_inputElement?.nativeElement.focus()" }, properties: { "class.cute-radio-checked": "checked", "class.cute-radio-disabled": "disabled", "class.cute-radio-disabled-interactive": "disabledInteractive", "attr.id": "id", "attr.tabindex": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.role": "null" }, classAttribute: "cute-radio-button" }, viewQueries: [{ propertyName: "_inputElement", first: true, predicate: ["input"], descendants: true }], exportAs: ["cuteRadioButton"], usesInheritance: true, ngImport: i0, template: "<div class=\"form-check\"\r\n [class.form-check-reverse]=\"labelPosition == 'before'\"\r\n [class.form-check-inline]=\"inline\"\r\n>\r\n <!-- This handler prevents our job in CuteListOption -->\r\n <!-- (click)=\"_preventBubblingFromLabel($event)\"-->\r\n <input #input type=\"radio\"\r\n class=\"form-check-input\"\r\n [class.icon-small]=\"iconSize=='small'\"\r\n [class.icon-large]=\"iconSize=='large'\"\r\n aria-invalid=\"false\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [attr.aria-labelledby]=\"ariaLabelledby\"\r\n [attr.aria-describedby]=\"ariaDescribedby\"\r\n [attr.aria-disabled]=\"disabled && disabledInteractive ? 'true' : null\"\r\n [attr.name] = \"name\"\r\n [attr.value]=\"value\"\r\n [id]=\"inputId\"\r\n [checked]=\"checked\"\r\n [disabled]=\"disabled && !disabledInteractive\"\r\n [required]=\"required\"\r\n [tabIndex]=\"disabled ? -1 : tabIndex\"\r\n [autocomplete]=\"false\"\r\n (change)=\"_onInputInteraction($event)\"\r\n />\r\n <label #label\r\n class=\"form-check-label\"\r\n [for]=\"inputId\">\r\n <ng-content></ng-content>\r\n </label>\r\n</div>\r\n", styles: [".cute-radio-button .form-check-input{cursor:pointer}.cute-radio-button .form-check-input.icon-small{font-size:.875em;transform:translate(-2px,2px)}.cute-radio-button .form-check-input.icon-large{font-size:1.375em;margin-right:1.125em;transform:translate(.45em,-.125em)}.cute-radio-button .form-check-label{cursor:pointer}.cute-radio-button .form-check-label:disabled{cursor:default}.cute-radio-button .form-check-label:empty{display:none}.cute-radio-button.cute-radio-disabled{cursor:default;pointer-events:none}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive{pointer-events:auto}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive .form-check-label{cursor:default;opacity:.5}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive .form-check-input{cursor:default;filter:grayscale(1)}.cute-radio-group{display:block}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
563
|
+
}
|
|
564
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioButton, decorators: [{
|
|
565
|
+
type: Component,
|
|
566
|
+
args: [{ selector: 'cute-radio-button', exportAs: 'cuteRadioButton', host: {
|
|
567
|
+
'class': 'cute-radio-button',
|
|
568
|
+
'[class.cute-radio-checked]': 'checked',
|
|
569
|
+
'[class.cute-radio-disabled]': 'disabled',
|
|
570
|
+
'[class.cute-radio-disabled-interactive]': 'disabledInteractive',
|
|
571
|
+
'[attr.id]': 'id',
|
|
572
|
+
// Needs to be removed since it causes some a11y issues (see #21266).
|
|
573
|
+
'[attr.tabindex]': 'null',
|
|
574
|
+
'[attr.aria-label]': 'null',
|
|
575
|
+
'[attr.aria-labelledby]': 'null',
|
|
576
|
+
'[attr.role]': 'null',
|
|
577
|
+
// Note: under normal conditions focus shouldn't land on this element, however, it may be
|
|
578
|
+
// programmatically set, for example, inside a focus trap, in this case we want to forward
|
|
579
|
+
// the focus to the native element.
|
|
580
|
+
'(focus)': '_inputElement?.nativeElement.focus()',
|
|
581
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-check\"\r\n [class.form-check-reverse]=\"labelPosition == 'before'\"\r\n [class.form-check-inline]=\"inline\"\r\n>\r\n <!-- This handler prevents our job in CuteListOption -->\r\n <!-- (click)=\"_preventBubblingFromLabel($event)\"-->\r\n <input #input type=\"radio\"\r\n class=\"form-check-input\"\r\n [class.icon-small]=\"iconSize=='small'\"\r\n [class.icon-large]=\"iconSize=='large'\"\r\n aria-invalid=\"false\"\r\n [attr.aria-label]=\"ariaLabel\"\r\n [attr.aria-labelledby]=\"ariaLabelledby\"\r\n [attr.aria-describedby]=\"ariaDescribedby\"\r\n [attr.aria-disabled]=\"disabled && disabledInteractive ? 'true' : null\"\r\n [attr.name] = \"name\"\r\n [attr.value]=\"value\"\r\n [id]=\"inputId\"\r\n [checked]=\"checked\"\r\n [disabled]=\"disabled && !disabledInteractive\"\r\n [required]=\"required\"\r\n [tabIndex]=\"disabled ? -1 : tabIndex\"\r\n [autocomplete]=\"false\"\r\n (change)=\"_onInputInteraction($event)\"\r\n />\r\n <label #label\r\n class=\"form-check-label\"\r\n [for]=\"inputId\">\r\n <ng-content></ng-content>\r\n </label>\r\n</div>\r\n", styles: [".cute-radio-button .form-check-input{cursor:pointer}.cute-radio-button .form-check-input.icon-small{font-size:.875em;transform:translate(-2px,2px)}.cute-radio-button .form-check-input.icon-large{font-size:1.375em;margin-right:1.125em;transform:translate(.45em,-.125em)}.cute-radio-button .form-check-label{cursor:pointer}.cute-radio-button .form-check-label:disabled{cursor:default}.cute-radio-button .form-check-label:empty{display:none}.cute-radio-button.cute-radio-disabled{cursor:default;pointer-events:none}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive{pointer-events:auto}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive .form-check-label{cursor:default;opacity:.5}.cute-radio-button.cute-radio-disabled.cute-radio-disabled-interactive .form-check-input{cursor:default;filter:grayscale(1)}.cute-radio-group{display:block}\n"] }]
|
|
582
|
+
}], ctorParameters: () => [], propDecorators: { _inputElement: [{
|
|
583
|
+
type: ViewChild,
|
|
584
|
+
args: ['input']
|
|
585
|
+
}], checked: [{
|
|
586
|
+
type: Input,
|
|
587
|
+
args: [{ transform: booleanAttribute }]
|
|
588
|
+
}], inline: [{
|
|
589
|
+
type: Input,
|
|
590
|
+
args: [{ transform: booleanAttribute }]
|
|
591
|
+
}], labelPosition: [{
|
|
592
|
+
type: Input
|
|
593
|
+
}], value: [{
|
|
594
|
+
type: Input
|
|
595
|
+
}], disabledInteractive: [{
|
|
596
|
+
type: Input,
|
|
597
|
+
args: [{ transform: booleanAttribute }]
|
|
598
|
+
}], iconSize: [{
|
|
599
|
+
type: Input
|
|
600
|
+
}], change: [{
|
|
601
|
+
type: Output
|
|
602
|
+
}] } });
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* @license Apache-2.0
|
|
606
|
+
*
|
|
607
|
+
* Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
|
|
608
|
+
*
|
|
609
|
+
* You may not use this file except in compliance with the License
|
|
610
|
+
* that can be found at http://www.apache.org/licenses/LICENSE-2.0
|
|
611
|
+
*/
|
|
612
|
+
const TYPES = [
|
|
613
|
+
CuteRadioButton,
|
|
614
|
+
CuteRadioGroup
|
|
615
|
+
];
|
|
616
|
+
class CuteRadioModule {
|
|
617
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
618
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioModule, imports: [CommonModule, CuteRadioButton,
|
|
619
|
+
CuteRadioGroup], exports: [CuteRadioButton,
|
|
620
|
+
CuteRadioGroup] }); }
|
|
621
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioModule, imports: [CommonModule] }); }
|
|
622
|
+
}
|
|
623
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRadioModule, decorators: [{
|
|
624
|
+
type: NgModule,
|
|
625
|
+
args: [{
|
|
626
|
+
imports: [CommonModule, ...TYPES],
|
|
627
|
+
exports: TYPES,
|
|
628
|
+
declarations: [],
|
|
629
|
+
}]
|
|
630
|
+
}] });
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Generated bundle index. Do not edit.
|
|
634
|
+
*/
|
|
635
|
+
|
|
636
|
+
export { CUTE_RADIO_DEFAULT_OPTIONS, CUTE_RADIO_GROUP, CUTE_RADIO_GROUP_CONTROL_VALUE_ACCESSOR, CuteRadioButton, CuteRadioChange, CuteRadioGroup, CuteRadioModule };
|
|
637
|
+
//# sourceMappingURL=cute-widgets-base-radio.mjs.map
|