@nanahoshi/mona-ui 0.24.11 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
- package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
- package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +27 -22
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
- package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +39 -4
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
- package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
- package/i18n/catalogs/en-US.messages.json +33 -4
- package/locales/ar-sa/ar-sa.messages.json +33 -4
- package/locales/de-de/de-de.messages.json +33 -4
- package/locales/es-es/es-es.messages.json +33 -4
- package/locales/fr-fr/fr-fr.messages.json +33 -4
- package/locales/id-id/id-id.messages.json +33 -4
- package/locales/it-it/it-it.messages.json +33 -4
- package/locales/ja-jp/ja-jp.messages.json +33 -4
- package/locales/ko-kr/ko-kr.messages.json +33 -4
- package/locales/pt-br/pt-br.messages.json +33 -4
- package/locales/ru-ru/ru-ru.messages.json +33 -4
- package/locales/tr-tr/tr-tr.messages.json +33 -4
- package/locales/zh-cn/zh-cn.messages.json +33 -4
- package/locales/zh-tw/zh-tw.messages.json +33 -4
- package/package.json +2 -1
- package/styles.css +156 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
- package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
- package/types/nanahoshi-mona-ui-button.d.ts +26 -3
- package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
- package/types/nanahoshi-mona-ui-card.d.ts +22 -6
- package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
- package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
- package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
- package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
- package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-common.d.ts +28 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
- package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
- package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
- package/types/nanahoshi-mona-ui-i18n.d.ts +38 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
- package/types/nanahoshi-mona-ui-label.d.ts +17 -2
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
- package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
- package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
- package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
- package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
- package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
- package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
- package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
- package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
- package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
- package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
- package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
- package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
- package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
- package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { computed, input, output, model, Component, Directive } from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, computed, viewChild, input, booleanAttribute, output, model, afterRenderEffect, Component, ElementRef, signal, afterNextRender, isDevMode, Directive } from '@angular/core';
|
|
4
4
|
import { FormsModule } from '@angular/forms';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { cva } from 'class-variance-authority';
|
|
7
|
-
import { themeControlSurfaceClasses } from '@nanahoshi/mona-ui/internal';
|
|
7
|
+
import { themeControlSurfaceClasses, injectLabelAssociation, injectEffectiveDisabled, createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
8
8
|
|
|
9
|
+
const radioGroupThemeVariants = cva("flex", {
|
|
10
|
+
variants: {
|
|
11
|
+
orientation: {
|
|
12
|
+
horizontal: "flex-row flex-wrap gap-4",
|
|
13
|
+
vertical: "flex-col gap-2"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
orientation: "vertical"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
9
20
|
const radioButtonThemeVariants = cva(`
|
|
10
|
-
peer
|
|
11
|
-
cursor-pointer appearance-none opacity-0
|
|
12
|
-
outline-none
|
|
13
|
-
disabled:cursor-not-allowed
|
|
21
|
+
peer sr-only appearance-none outline-none focus-visible:outline-hidden
|
|
14
22
|
`);
|
|
15
23
|
const radioButtonCircleThemeVariants = cva(`
|
|
16
24
|
relative flex h-4.5 w-4.5 items-center justify-center
|
|
@@ -24,6 +32,7 @@ const radioButtonCircleThemeVariants = cva(`
|
|
|
24
32
|
|
|
25
33
|
peer-focus-visible:border-focus-indicator
|
|
26
34
|
peer-focus-visible:ring-2 peer-focus-visible:ring-focus-indicator/35
|
|
35
|
+
peer-focus-visible:outline-hidden
|
|
27
36
|
|
|
28
37
|
data-[invalid='true']:border-error
|
|
29
38
|
data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
|
|
@@ -42,7 +51,8 @@ const radioButtonCircleThemeVariants = cva(`
|
|
|
42
51
|
});
|
|
43
52
|
const radioButtonIndicatorThemeVariants = cva(`
|
|
44
53
|
flex h-3 w-3
|
|
45
|
-
bg-primary
|
|
54
|
+
bg-[var(--mona-indicator-color,var(--color-primary))]
|
|
55
|
+
forced-color-adjust-none forced-colors:bg-[Highlight]
|
|
46
56
|
transition-all duration-(--mona-motion-fast)
|
|
47
57
|
`, {
|
|
48
58
|
variants: {
|
|
@@ -58,9 +68,12 @@ const radioButtonIndicatorThemeVariants = cva(`
|
|
|
58
68
|
const radioButtonContainerLabelThemeVariants = cva(`
|
|
59
69
|
relative flex h-full w-full items-center justify-center gap-1
|
|
60
70
|
cursor-pointer
|
|
71
|
+
isolate before:absolute before:-inset-[3px] before:-z-10 before:content-['']
|
|
61
72
|
data-[disabled='true']:pointer-events-none
|
|
62
73
|
data-[disabled='true']:cursor-not-allowed
|
|
63
74
|
data-[disabled='true']:text-disabled-foreground
|
|
75
|
+
data-[readonly='true']:cursor-default
|
|
76
|
+
[&[data-readonly='true']>*]:cursor-default
|
|
64
77
|
`, {
|
|
65
78
|
variants: {
|
|
66
79
|
labelSize: {
|
|
@@ -78,7 +91,7 @@ const radioButtonDirectiveThemeVariants = cva(`
|
|
|
78
91
|
cursor-pointer appearance-none
|
|
79
92
|
${themeControlSurfaceClasses}
|
|
80
93
|
border border-input-border
|
|
81
|
-
outline-none
|
|
94
|
+
outline-none focus-visible:outline-hidden
|
|
82
95
|
|
|
83
96
|
disabled:pointer-events-none disabled:cursor-not-allowed
|
|
84
97
|
disabled:border-disabled-border disabled:bg-disabled-background disabled:text-disabled-foreground
|
|
@@ -132,8 +145,21 @@ const radioButtonDirectiveThemeVariants = cva(`
|
|
|
132
145
|
]
|
|
133
146
|
});
|
|
134
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Provided by `mona-radio-group` to the radio buttons inside it.
|
|
150
|
+
*/
|
|
151
|
+
const MONA_RADIO_GROUP = new InjectionToken("MONA_RADIO_GROUP");
|
|
152
|
+
|
|
135
153
|
class RadioButtonComponent {
|
|
154
|
+
#group;
|
|
155
|
+
#label;
|
|
136
156
|
constructor() {
|
|
157
|
+
this.#group = inject(MONA_RADIO_GROUP, { optional: true });
|
|
158
|
+
this.#label = injectLabelAssociation({
|
|
159
|
+
ariaLabel: () => this.ariaLabel(),
|
|
160
|
+
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
161
|
+
wrapped: false
|
|
162
|
+
});
|
|
137
163
|
this.containerLabelClasses = computed(() => {
|
|
138
164
|
const labelSize = this.labelSize();
|
|
139
165
|
const userClasses = this.userClass();
|
|
@@ -141,8 +167,27 @@ class RadioButtonComponent {
|
|
|
141
167
|
return twMerge(variantClasses, userClasses);
|
|
142
168
|
}, /* @ts-ignore */
|
|
143
169
|
...(ngDevMode ? [{ debugName: "containerLabelClasses" }] : /* istanbul ignore next */ []));
|
|
144
|
-
this.
|
|
170
|
+
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled() || (this.#group?.disabled() ?? false));
|
|
171
|
+
this.effectiveName = computed(() => this.#group?.name() ?? this.name(), /* @ts-ignore */
|
|
172
|
+
...(ngDevMode ? [{ debugName: "effectiveName" }] : /* istanbul ignore next */ []));
|
|
173
|
+
this.effectiveReadonly = computed(() => this.readonly() || (this.#group?.readonly() ?? false), /* @ts-ignore */
|
|
174
|
+
...(ngDevMode ? [{ debugName: "effectiveReadonly" }] : /* istanbul ignore next */ []));
|
|
175
|
+
this.effectiveRequired = computed(() => this.required() || (this.#group?.required() ?? false), /* @ts-ignore */
|
|
176
|
+
...(ngDevMode ? [{ debugName: "effectiveRequired" }] : /* istanbul ignore next */ []));
|
|
177
|
+
this.inputInvalid = computed(() => !this.#group && this.touched() && this.invalid(), /* @ts-ignore */
|
|
178
|
+
...(ngDevMode ? [{ debugName: "inputInvalid" }] : /* istanbul ignore next */ []));
|
|
179
|
+
this.inputRef = viewChild.required("input", /* @ts-ignore */
|
|
180
|
+
...(ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []));
|
|
181
|
+
// Inside a group the group carries aria-invalid, and the radios only paint it.
|
|
182
|
+
this.invalidState = computed(() => this.#group?.invalid() ?? (this.touched() && this.invalid()), /* @ts-ignore */
|
|
145
183
|
...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
|
|
184
|
+
this.labelledBy = this.#label.labelledBy;
|
|
185
|
+
// Only a primitive means anything to a native form. An object is still compared and written through the model.
|
|
186
|
+
this.nativeValue = computed(() => {
|
|
187
|
+
const radioValue = this.radioValue();
|
|
188
|
+
return typeof radioValue === "object" ? null : radioValue;
|
|
189
|
+
}, /* @ts-ignore */
|
|
190
|
+
...(ngDevMode ? [{ debugName: "nativeValue" }] : /* istanbul ignore next */ []));
|
|
146
191
|
this.radioButtonCircleClasses = computed(() => {
|
|
147
192
|
const rounded = this.rounded();
|
|
148
193
|
return radioButtonCircleThemeVariants({ rounded });
|
|
@@ -155,12 +200,31 @@ class RadioButtonComponent {
|
|
|
155
200
|
return radioButtonIndicatorThemeVariants({ rounded });
|
|
156
201
|
}, /* @ts-ignore */
|
|
157
202
|
...(ngDevMode ? [{ debugName: "radioButtonIndicatorClasses" }] : /* istanbul ignore next */ []));
|
|
203
|
+
this.selected = computed(() => {
|
|
204
|
+
const radioValue = this.radioValue();
|
|
205
|
+
return radioValue !== undefined && radioValue === (this.#group ? this.#group.value() : this.value());
|
|
206
|
+
}, /* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
208
|
+
/**
|
|
209
|
+
* @description Id of an element that describes the radio button, such as an error message.
|
|
210
|
+
* @default ""
|
|
211
|
+
*/
|
|
212
|
+
this.ariaDescribedBy = input("", { ...(ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {}), alias: "aria-describedby" });
|
|
213
|
+
/**
|
|
214
|
+
* @description Accessible name of the radio button when it has no visible label.
|
|
215
|
+
* @default ""
|
|
216
|
+
*/
|
|
217
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
218
|
+
/**
|
|
219
|
+
* @description Id of the element that labels the radio button.
|
|
220
|
+
* @default ""
|
|
221
|
+
*/
|
|
222
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
158
223
|
/**
|
|
159
224
|
* @description Sets the disabled state of the radio button.
|
|
160
225
|
* @default false
|
|
161
226
|
*/
|
|
162
|
-
this.disabled = input(false, /*
|
|
163
|
-
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
227
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
164
228
|
/**
|
|
165
229
|
* @description Emits when the input loses focus.
|
|
166
230
|
*/
|
|
@@ -174,17 +238,23 @@ class RadioButtonComponent {
|
|
|
174
238
|
*/
|
|
175
239
|
this.inputFocus = output();
|
|
176
240
|
/**
|
|
177
|
-
* @description
|
|
178
|
-
*
|
|
241
|
+
* @description Id of the native radio input. Point a `<label for>` at it to label the radio button from outside.
|
|
242
|
+
* A unique id is generated when it isn't set.
|
|
243
|
+
* @default generated
|
|
244
|
+
*/
|
|
245
|
+
this.inputId = input(createElementControlId(), /* @ts-ignore */
|
|
246
|
+
...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
|
|
247
|
+
/**
|
|
248
|
+
* @description Marks the radio button as invalid. When bound to a signal form field via `[formField]`, this is
|
|
249
|
+
* written by the `FormField` directive.
|
|
179
250
|
* @default false
|
|
180
251
|
*/
|
|
181
|
-
this.invalid = input(false, /*
|
|
182
|
-
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
252
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
183
253
|
/**
|
|
184
254
|
* @description Text label displayed alongside the radio button.
|
|
185
255
|
* When provided, takes precedence over projected content.
|
|
186
256
|
* When empty, projected content inside `<mona-radio-button>` is used.
|
|
187
|
-
* When both are absent, the radio button
|
|
257
|
+
* When both are absent, name the radio button with `aria-label` or `aria-labelledby`.
|
|
188
258
|
* @default ""
|
|
189
259
|
*/
|
|
190
260
|
this.label = input("", /* @ts-ignore */
|
|
@@ -212,56 +282,286 @@ class RadioButtonComponent {
|
|
|
212
282
|
* @description The identity value of this radio button within a group.
|
|
213
283
|
* Compared against `value()` to determine whether this button is selected.
|
|
214
284
|
* When this button is chosen, its `radioValue` is written to the form as the new group value.
|
|
285
|
+
* A radio button without one can't be selected.
|
|
215
286
|
* @default undefined
|
|
216
287
|
*/
|
|
217
288
|
this.radioValue = input(undefined, /* @ts-ignore */
|
|
218
289
|
...(ngDevMode ? [{ debugName: "radioValue" }] : /* istanbul ignore next */ []));
|
|
290
|
+
/**
|
|
291
|
+
* @description Prevents value changes while the control stays focusable and readable. When bound to a signal form
|
|
292
|
+
* field via `[formField]`, this is written by the `FormField` directive.
|
|
293
|
+
* @default false
|
|
294
|
+
*/
|
|
295
|
+
this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
296
|
+
/**
|
|
297
|
+
* @description Marks the radio button as required, as the native `required` attribute. When bound to a signal form
|
|
298
|
+
* field via `[formField]`, this is written by the `FormField` directive.
|
|
299
|
+
* @default false
|
|
300
|
+
*/
|
|
301
|
+
this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
219
302
|
/**
|
|
220
303
|
* @description Sets the border radius of the radio button circle and indicator.
|
|
221
304
|
* @default "full"
|
|
222
305
|
*/
|
|
223
306
|
this.rounded = input("full", /* @ts-ignore */
|
|
224
307
|
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
308
|
+
/**
|
|
309
|
+
* @description Emits when the radio button loses focus or is selected.
|
|
310
|
+
*/
|
|
225
311
|
this.touch = output();
|
|
226
312
|
/**
|
|
227
313
|
* @description Marks the radio button as touched. Error styling requires both `invalid` and `touched` to be `true`.
|
|
228
|
-
* When bound to a signal form field via `[
|
|
314
|
+
* When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
|
|
229
315
|
* @default false
|
|
230
316
|
*/
|
|
231
|
-
this.touched = input(false, /*
|
|
232
|
-
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
317
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
233
318
|
/**
|
|
234
319
|
* @description Additional CSS classes merged onto the label container element via `tailwind-merge`.
|
|
235
320
|
* @default ""
|
|
236
321
|
*/
|
|
237
322
|
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
238
323
|
/**
|
|
239
|
-
* @description The currently selected value in
|
|
240
|
-
*
|
|
241
|
-
* When bound via `[(ngModel)]` or `[formControl]`, the CVA layer manages this value.
|
|
324
|
+
* @description The currently selected value of a group of radio buttons that aren't in a `mona-radio-group`. When
|
|
325
|
+
* bound to a signal form field via `[formField]`, the `FormField` directive keeps it in sync.
|
|
242
326
|
* @default undefined
|
|
243
327
|
*/
|
|
244
328
|
this.value = model(undefined, /* @ts-ignore */
|
|
245
329
|
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
330
|
+
const group = this.#group;
|
|
331
|
+
if (group) {
|
|
332
|
+
afterRenderEffect({
|
|
333
|
+
write: () => {
|
|
334
|
+
group.selectionVersion();
|
|
335
|
+
this.inputRef().nativeElement.checked = this.selected();
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Selects the radio button when a label pointing at it through `[for]` is clicked.
|
|
342
|
+
* @internal
|
|
343
|
+
*/
|
|
344
|
+
activateFromLabel() {
|
|
345
|
+
const input = this.inputRef().nativeElement;
|
|
346
|
+
input.focus();
|
|
347
|
+
input.click();
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* @description Moves focus to the native radio input.
|
|
351
|
+
* @param options Options passed to the native `focus()` call, such as `preventScroll`.
|
|
352
|
+
*/
|
|
353
|
+
focus(options) {
|
|
354
|
+
this.inputRef().nativeElement.focus(options);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* @internal
|
|
358
|
+
*/
|
|
359
|
+
setLabelledBy(id) {
|
|
360
|
+
this.#label.setLabelledBy(id);
|
|
246
361
|
}
|
|
247
362
|
onBlur(event) {
|
|
248
363
|
this.inputBlur.emit(event);
|
|
249
364
|
this.touch.emit();
|
|
250
365
|
}
|
|
366
|
+
onInputClick(event) {
|
|
367
|
+
// Canceling the click makes the browser restore the previously checked radio.
|
|
368
|
+
if (this.effectiveReadonly()) {
|
|
369
|
+
event.preventDefault();
|
|
370
|
+
}
|
|
371
|
+
this.inputClick.emit(event);
|
|
372
|
+
}
|
|
251
373
|
onSelectionChange() {
|
|
374
|
+
if (this.#group) {
|
|
375
|
+
this.#group.select(this.radioValue());
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
252
378
|
this.value.set(this.radioValue());
|
|
253
379
|
this.touch.emit();
|
|
254
380
|
}
|
|
255
381
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
256
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: RadioButtonComponent, isStandalone: true, selector: "mona-radio-button", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, labelSize: { classPropertyName: "labelSize", publicName: "labelSize", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, radioValue: { classPropertyName: "radioValue", publicName: "radioValue", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { inputBlur: "inputBlur", inputClick: "inputClick", inputFocus: "inputFocus", touch: "touch", value: "valueChange" }, host: { properties: { "attr.data-
|
|
382
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: RadioButtonComponent, isStandalone: true, selector: "mona-radio-button", inputs: { ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, labelSize: { classPropertyName: "labelSize", publicName: "labelSize", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, radioValue: { classPropertyName: "radioValue", publicName: "radioValue", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { inputBlur: "inputBlur", inputClick: "inputClick", inputFocus: "inputFocus", touch: "touch", value: "valueChange" }, host: { properties: { "attr.aria-describedby": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.data-readonly": "effectiveReadonly() || null", "attr.data-selected": "selected()", "attr.data-disabled": "effectiveDisabled()" } }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"effectiveReadonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n <input\n #input\n type=\"radio\"\n [id]=\"inputId()\"\n [required]=\"effectiveRequired()\"\n [disabled]=\"effectiveDisabled()\"\n [name]=\"effectiveName()\"\n [attr.value]=\"nativeValue()\"\n [class]=\"radioButtonClasses()\"\n [checked]=\"selected()\"\n [attr.aria-invalid]=\"inputInvalid() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"ariaDescribedBy() || null\"\n (blur)=\"onBlur($event)\"\n (click)=\"onInputClick($event)\"\n (focus)=\"inputFocus.emit($event)\"\n (change)=\"onSelectionChange()\" />\n <span [class]=\"radioButtonCircleClasses()\" [attr.data-invalid]=\"invalidState() || null\">\n @if (selected()) {\n <span [class]=\"radioButtonIndicatorClasses()\"></span>\n }\n </span>\n @if (labelPosition() === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n</label>\n\n<ng-template #labelTemplate>\n @if (label()) {\n <span>{{ label() }}</span>\n } @else {\n <ng-content></ng-content>\n }\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
257
383
|
}
|
|
258
384
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioButtonComponent, decorators: [{
|
|
259
385
|
type: Component,
|
|
260
386
|
args: [{ selector: "mona-radio-button", imports: [FormsModule, NgTemplateOutlet], host: {
|
|
261
|
-
|
|
262
|
-
"[attr.
|
|
263
|
-
|
|
264
|
-
|
|
387
|
+
// The ARIA inputs below are applied to the native input, so the host must not keep the static attributes.
|
|
388
|
+
"[attr.aria-describedby]": "null",
|
|
389
|
+
"[attr.aria-label]": "null",
|
|
390
|
+
"[attr.aria-labelledby]": "null",
|
|
391
|
+
"[attr.data-readonly]": "effectiveReadonly() || null",
|
|
392
|
+
"[attr.data-selected]": "selected()",
|
|
393
|
+
"[attr.data-disabled]": "effectiveDisabled()"
|
|
394
|
+
}, template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"effectiveReadonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n <input\n #input\n type=\"radio\"\n [id]=\"inputId()\"\n [required]=\"effectiveRequired()\"\n [disabled]=\"effectiveDisabled()\"\n [name]=\"effectiveName()\"\n [attr.value]=\"nativeValue()\"\n [class]=\"radioButtonClasses()\"\n [checked]=\"selected()\"\n [attr.aria-invalid]=\"inputInvalid() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"ariaDescribedBy() || null\"\n (blur)=\"onBlur($event)\"\n (click)=\"onInputClick($event)\"\n (focus)=\"inputFocus.emit($event)\"\n (change)=\"onSelectionChange()\" />\n <span [class]=\"radioButtonCircleClasses()\" [attr.data-invalid]=\"invalidState() || null\">\n @if (selected()) {\n <span [class]=\"radioButtonIndicatorClasses()\"></span>\n }\n </span>\n @if (labelPosition() === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n</label>\n\n<ng-template #labelTemplate>\n @if (label()) {\n <span>{{ label() }}</span>\n } @else {\n <ng-content></ng-content>\n }\n</ng-template>\n" }]
|
|
395
|
+
}], ctorParameters: () => [], propDecorators: { inputRef: [{ type: i0.ViewChild, args: ["input", { isSignal: true }] }], ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-describedby", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputClick: [{ type: i0.Output, args: ["inputClick"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelPosition", required: false }] }], labelSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelSize", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], radioValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "radioValue", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
396
|
+
|
|
397
|
+
class RadioGroupComponent {
|
|
398
|
+
#generatedName;
|
|
399
|
+
#hostElementRef;
|
|
400
|
+
#label;
|
|
401
|
+
#selectionVersion;
|
|
402
|
+
constructor() {
|
|
403
|
+
this.#generatedName = createElementControlId();
|
|
404
|
+
this.#hostElementRef = inject(ElementRef);
|
|
405
|
+
this.#label = injectLabelAssociation({
|
|
406
|
+
activate: () => this.focus(),
|
|
407
|
+
ariaLabel: () => this.ariaLabel(),
|
|
408
|
+
ariaLabelledBy: () => this.ariaLabelledBy()
|
|
409
|
+
});
|
|
410
|
+
this.#selectionVersion = signal(0, /* @ts-ignore */
|
|
411
|
+
...(ngDevMode ? [{ debugName: "#selectionVersion" }] : /* istanbul ignore next */ []));
|
|
412
|
+
this.classes = computed(() => twMerge(radioGroupThemeVariants({ orientation: this.orientation() }), this.userClass()), /* @ts-ignore */
|
|
413
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
414
|
+
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
415
|
+
this.invalidState = computed(() => this.touched() && this.invalid(), /* @ts-ignore */
|
|
416
|
+
...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
|
|
417
|
+
this.labelledBy = this.#label.labelledBy;
|
|
418
|
+
/**
|
|
419
|
+
* @description Id of an element that describes the group, such as an error message.
|
|
420
|
+
* @default ""
|
|
421
|
+
*/
|
|
422
|
+
this.ariaDescribedBy = input("", { ...(ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {}), alias: "aria-describedby" });
|
|
423
|
+
/**
|
|
424
|
+
* @description Accessible name of the group. A group needs a name from this, `aria-labelledby` or a `mona-label`.
|
|
425
|
+
* @default ""
|
|
426
|
+
*/
|
|
427
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
428
|
+
/**
|
|
429
|
+
* @description Id of the element that labels the group.
|
|
430
|
+
* @default ""
|
|
431
|
+
*/
|
|
432
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
433
|
+
/**
|
|
434
|
+
* @internal
|
|
435
|
+
*/
|
|
436
|
+
this.context = {
|
|
437
|
+
disabled: this.effectiveDisabled,
|
|
438
|
+
invalid: this.invalidState,
|
|
439
|
+
name: computed(() => this.name() || this.#generatedName),
|
|
440
|
+
readonly: computed(() => this.readonly()),
|
|
441
|
+
required: computed(() => this.required()),
|
|
442
|
+
select: value => this.#select(value),
|
|
443
|
+
selectionVersion: this.#selectionVersion,
|
|
444
|
+
value: computed(() => this.value())
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* @description Disables every radio button in the group. When bound to a signal form field via `[formField]`, this
|
|
448
|
+
* is written by the `FormField` directive.
|
|
449
|
+
* @default false
|
|
450
|
+
*/
|
|
451
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
452
|
+
/**
|
|
453
|
+
* @description Marks the group as invalid. It shows once `touched` is also true. When bound to a signal form field
|
|
454
|
+
* via `[formField]`, this is written by the `FormField` directive.
|
|
455
|
+
* @default false
|
|
456
|
+
*/
|
|
457
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
458
|
+
/**
|
|
459
|
+
* @description The native `name` shared by the radio buttons in the group. A unique name is generated when it isn't
|
|
460
|
+
* set. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
|
|
461
|
+
* @default ""
|
|
462
|
+
*/
|
|
463
|
+
this.name = input("", /* @ts-ignore */
|
|
464
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
465
|
+
/**
|
|
466
|
+
* @description The direction the radio buttons are laid out and announced in.
|
|
467
|
+
* @default "vertical"
|
|
468
|
+
*/
|
|
469
|
+
this.orientation = input("vertical", /* @ts-ignore */
|
|
470
|
+
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
471
|
+
/**
|
|
472
|
+
* @description Prevents value changes while the radio buttons stay focusable and readable. When bound to a signal
|
|
473
|
+
* form field via `[formField]`, this is written by the `FormField` directive.
|
|
474
|
+
* @default false
|
|
475
|
+
*/
|
|
476
|
+
this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
477
|
+
/**
|
|
478
|
+
* @description Marks the group as required. When bound to a signal form field via `[formField]`, this is written by
|
|
479
|
+
* the `FormField` directive.
|
|
480
|
+
* @default false
|
|
481
|
+
*/
|
|
482
|
+
this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
483
|
+
/**
|
|
484
|
+
* @description Emits when a radio button is selected and when focus leaves the group.
|
|
485
|
+
*/
|
|
486
|
+
this.touch = output();
|
|
487
|
+
/**
|
|
488
|
+
* @description Marks the group as touched. Error styling needs both `invalid` and `touched`. When bound to a signal
|
|
489
|
+
* form field via `[formField]`, this is written by the `FormField` directive.
|
|
490
|
+
* @default false
|
|
491
|
+
*/
|
|
492
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
493
|
+
/**
|
|
494
|
+
* @description Additional CSS classes merged onto the group via `tailwind-merge`.
|
|
495
|
+
* @default ""
|
|
496
|
+
*/
|
|
497
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
498
|
+
/**
|
|
499
|
+
* @description The `radioValue` of the selected radio button.
|
|
500
|
+
* @default undefined
|
|
501
|
+
*/
|
|
502
|
+
this.value = model(undefined, /* @ts-ignore */
|
|
503
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
504
|
+
afterNextRender(() => {
|
|
505
|
+
if (isDevMode() && !this.labelledBy() && !this.ariaLabel()) {
|
|
506
|
+
console.warn("[Mona Radio Group] A radio group needs an accessible name. Set aria-label, aria-labelledby or " +
|
|
507
|
+
"use a mona-label.", this.#hostElementRef.nativeElement);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* @description Moves focus to the selected radio button, or the first enabled one.
|
|
513
|
+
* @param options Options passed to the native `focus()` call, such as `preventScroll`.
|
|
514
|
+
*/
|
|
515
|
+
focus(options) {
|
|
516
|
+
const host = this.#hostElementRef.nativeElement;
|
|
517
|
+
const target = host.querySelector("input[type='radio']:checked:not(:disabled)") ??
|
|
518
|
+
host.querySelector("input[type='radio']:not(:disabled)");
|
|
519
|
+
target?.focus(options);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
setLabelledBy(id) {
|
|
525
|
+
this.#label.setLabelledBy(id);
|
|
526
|
+
}
|
|
527
|
+
#select(value) {
|
|
528
|
+
this.value.set(value);
|
|
529
|
+
this.#selectionVersion.update(version => version + 1);
|
|
530
|
+
this.touch.emit();
|
|
531
|
+
}
|
|
532
|
+
onFocusOut(event) {
|
|
533
|
+
const nextTarget = event.relatedTarget;
|
|
534
|
+
if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
this.touch.emit();
|
|
538
|
+
}
|
|
539
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
540
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: RadioGroupComponent, isStandalone: true, selector: "mona-radio-group", inputs: { ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch", value: "valueChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusout": "onFocusOut($event)" }, properties: { "attr.aria-describedby": "ariaDescribedBy() || null", "attr.aria-disabled": "effectiveDisabled() || null", "attr.aria-invalid": "invalidState() ? 'true' : null", "attr.aria-label": "ariaLabel() || null", "attr.aria-labelledby": "labelledBy()", "attr.aria-orientation": "orientation()", "attr.aria-readonly": "readonly() || null", "attr.aria-required": "required() || null", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-readonly": "readonly() || null", "class": "classes()" } }, providers: [{ provide: MONA_RADIO_GROUP, useFactory: () => inject(RadioGroupComponent).context }], ngImport: i0, template: `<ng-content />`, isInline: true }); }
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioGroupComponent, decorators: [{
|
|
543
|
+
type: Component,
|
|
544
|
+
args: [{
|
|
545
|
+
selector: "mona-radio-group",
|
|
546
|
+
template: `<ng-content />`,
|
|
547
|
+
providers: [{ provide: MONA_RADIO_GROUP, useFactory: () => inject(RadioGroupComponent).context }],
|
|
548
|
+
host: {
|
|
549
|
+
role: "radiogroup",
|
|
550
|
+
"[attr.aria-describedby]": "ariaDescribedBy() || null",
|
|
551
|
+
"[attr.aria-disabled]": "effectiveDisabled() || null",
|
|
552
|
+
"[attr.aria-invalid]": "invalidState() ? 'true' : null",
|
|
553
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
554
|
+
"[attr.aria-labelledby]": "labelledBy()",
|
|
555
|
+
"[attr.aria-orientation]": "orientation()",
|
|
556
|
+
"[attr.aria-readonly]": "readonly() || null",
|
|
557
|
+
"[attr.aria-required]": "required() || null",
|
|
558
|
+
"[attr.data-disabled]": "effectiveDisabled() || null",
|
|
559
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
560
|
+
"[class]": "classes()",
|
|
561
|
+
"(focusout)": "onFocusOut($event)"
|
|
562
|
+
}
|
|
563
|
+
}]
|
|
564
|
+
}], ctorParameters: () => [], propDecorators: { ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-describedby", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
265
565
|
|
|
266
566
|
class RadioButtonDirective {
|
|
267
567
|
constructor() {
|
|
@@ -276,23 +576,21 @@ class RadioButtonDirective {
|
|
|
276
576
|
* @description Marks the radio button as invalid, triggering error border and ring styling.
|
|
277
577
|
* @default false
|
|
278
578
|
*/
|
|
279
|
-
this.invalid = input(false, /*
|
|
280
|
-
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
579
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
281
580
|
/**
|
|
282
581
|
* @description Sets the border radius of the radio button.
|
|
283
|
-
* @default "
|
|
582
|
+
* @default "full"
|
|
284
583
|
*/
|
|
285
|
-
this.rounded = input("
|
|
584
|
+
this.rounded = input("full", /* @ts-ignore */
|
|
286
585
|
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
287
586
|
/**
|
|
288
587
|
* @description Marks the radio button as touched. Error styling is only shown when both `invalid` and `touched` are `true`.
|
|
289
588
|
* @default false
|
|
290
589
|
*/
|
|
291
|
-
this.touched = input(false, /*
|
|
292
|
-
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
590
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
293
591
|
}
|
|
294
592
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
295
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RadioButtonDirective, isStandalone: true, selector: "input[type='radio'][monaRadioButton]", inputs: { invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-invalid": "inputInvalid() || null", "attr.data-invalid": "inputInvalid() || null", "class": "classes()"
|
|
593
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RadioButtonDirective, isStandalone: true, selector: "input[type='radio'][monaRadioButton]", inputs: { invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-invalid": "inputInvalid() || null", "attr.data-invalid": "inputInvalid() || null", "class": "classes()" } }, ngImport: i0 }); }
|
|
296
594
|
}
|
|
297
595
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RadioButtonDirective, decorators: [{
|
|
298
596
|
type: Directive,
|
|
@@ -301,8 +599,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
301
599
|
host: {
|
|
302
600
|
"[attr.aria-invalid]": "inputInvalid() || null",
|
|
303
601
|
"[attr.data-invalid]": "inputInvalid() || null",
|
|
304
|
-
"[class]": "classes()"
|
|
305
|
-
"[attr.role]": "'radio'"
|
|
602
|
+
"[class]": "classes()"
|
|
306
603
|
}
|
|
307
604
|
}]
|
|
308
605
|
}], propDecorators: { invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }] } });
|
|
@@ -315,5 +612,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
315
612
|
* Generated bundle index. Do not edit.
|
|
316
613
|
*/
|
|
317
614
|
|
|
318
|
-
export { RadioButtonComponent, RadioButtonDirective };
|
|
615
|
+
export { RadioButtonComponent, RadioButtonDirective, RadioGroupComponent };
|
|
319
616
|
//# sourceMappingURL=nanahoshi-mona-ui-radio-button.mjs.map
|