@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,13 +1,16 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Directive, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef, input, model, output, afterNextRender, Component } from '@angular/core';
|
|
3
|
+
import { Directive, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef, input, model, booleanAttribute, numberAttribute, output, afterNextRender, Component } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { fromEvent, filter, tap, merge } from 'rxjs';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
|
-
import { themeControlSurfaceClasses, themeRaisedSurfaceClasses } from '@nanahoshi/mona-ui/internal';
|
|
8
|
+
import { themeControlSurfaceClasses, themeRaisedSurfaceClasses, injectLabelAssociation, injectEffectiveDisabled } from '@nanahoshi/mona-ui/internal';
|
|
9
9
|
|
|
10
10
|
class SwitchHandleContentTemplateDirective {
|
|
11
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
11
14
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchHandleContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
12
15
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SwitchHandleContentTemplateDirective, isStandalone: true, selector: "ng-template[monaSwitchHandleContentTemplate]", ngImport: i0 }); }
|
|
13
16
|
}
|
|
@@ -45,7 +48,7 @@ const switchThemeVariants = cva(`
|
|
|
45
48
|
cursor-pointer select-none
|
|
46
49
|
${themeControlSurfaceClasses}
|
|
47
50
|
border border-input-border
|
|
48
|
-
outline-none
|
|
51
|
+
outline-none focus-visible:outline-hidden
|
|
49
52
|
transition-[background,border-color]
|
|
50
53
|
|
|
51
54
|
data-[disabled='true']:pointer-events-none
|
|
@@ -54,8 +57,14 @@ const switchThemeVariants = cva(`
|
|
|
54
57
|
data-[disabled='true']:bg-disabled-background
|
|
55
58
|
data-[disabled='true']:text-disabled-foreground
|
|
56
59
|
|
|
57
|
-
data-[
|
|
58
|
-
|
|
60
|
+
data-[readonly='true']:cursor-default
|
|
61
|
+
|
|
62
|
+
data-[active='true']:bg-[var(--mona-indicator-color,var(--color-primary))]
|
|
63
|
+
data-[active='true']:text-[var(--mona-indicator-foreground,var(--color-primary-foreground))]
|
|
64
|
+
data-[active='true']:not-data-[disabled='true']:forced-color-adjust-none
|
|
65
|
+
data-[active='true']:not-data-[disabled='true']:forced-colors:border-[CanvasText]
|
|
66
|
+
data-[active='true']:not-data-[disabled='true']:forced-colors:bg-[Highlight]
|
|
67
|
+
data-[active='true']:not-data-[disabled='true']:forced-colors:text-[HighlightText]
|
|
59
68
|
data-[disabled='true']:data-[active='true']:bg-disabled-background
|
|
60
69
|
|
|
61
70
|
focus-visible:border-focus-indicator
|
|
@@ -77,19 +86,21 @@ const switchThemeVariants = cva(`
|
|
|
77
86
|
size: {
|
|
78
87
|
large: "h-7.5 w-14 text-base",
|
|
79
88
|
medium: "h-6.5 w-12 text-sm",
|
|
80
|
-
small: "h-5.5 w-10 text-xs"
|
|
89
|
+
small: "h-5.5 w-10 text-xs before:absolute before:inset-x-0 before:-inset-y-px before:content-['']"
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
});
|
|
84
93
|
const switchHandleThemeVariants = cva(`
|
|
85
94
|
absolute inline-flex items-center justify-center
|
|
95
|
+
forced-color-adjust-auto
|
|
86
96
|
${themeRaisedSurfaceClasses} text-foreground
|
|
87
97
|
border border-border-subtle shadow-(--shadow-control)
|
|
88
|
-
outline-none
|
|
98
|
+
outline-none focus-visible:outline-hidden
|
|
89
99
|
transition-[inset-inline-start,background] duration-(--mona-motion-standard) ease-in-out
|
|
90
|
-
data-[active='true']:bg-primary-foreground
|
|
91
|
-
group-data-[disabled='true']:border-disabled-
|
|
92
|
-
group-data-[disabled='true']:bg-disabled-
|
|
100
|
+
data-[active='true']:bg-[var(--mona-indicator-foreground,var(--color-primary-foreground))]
|
|
101
|
+
group-data-[disabled='true']:border-disabled-foreground
|
|
102
|
+
group-data-[disabled='true']:bg-disabled-foreground
|
|
103
|
+
group-data-[disabled='true']:data-[active='true']:bg-disabled-foreground
|
|
93
104
|
`, {
|
|
94
105
|
variants: {
|
|
95
106
|
rounded: {
|
|
@@ -125,9 +136,15 @@ const switchLabelThemeVariants = cva(`
|
|
|
125
136
|
class SwitchComponent {
|
|
126
137
|
#destroyRef;
|
|
127
138
|
#hostElementRef;
|
|
139
|
+
#label;
|
|
128
140
|
constructor() {
|
|
129
141
|
this.#destroyRef = inject(DestroyRef);
|
|
130
142
|
this.#hostElementRef = inject((ElementRef));
|
|
143
|
+
this.#label = injectLabelAssociation({
|
|
144
|
+
activate: () => this.activateFromLabel(),
|
|
145
|
+
ariaLabel: () => this.ariaLabel(),
|
|
146
|
+
ariaLabelledBy: () => this.ariaLabelledBy()
|
|
147
|
+
});
|
|
131
148
|
this.classes = computed(() => {
|
|
132
149
|
const rounded = this.rounded();
|
|
133
150
|
const size = this.size();
|
|
@@ -135,6 +152,7 @@ class SwitchComponent {
|
|
|
135
152
|
return twMerge(classes, this.userClass());
|
|
136
153
|
}, /* @ts-ignore */
|
|
137
154
|
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
155
|
+
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
138
156
|
this.handleClasses = computed(() => {
|
|
139
157
|
const rounded = this.rounded();
|
|
140
158
|
const size = this.size();
|
|
@@ -150,6 +168,7 @@ class SwitchComponent {
|
|
|
150
168
|
return twMerge(classes);
|
|
151
169
|
}, /* @ts-ignore */
|
|
152
170
|
...(ngDevMode ? [{ debugName: "labelClasses" }] : /* istanbul ignore next */ []));
|
|
171
|
+
this.labelledBy = this.#label.labelledBy;
|
|
153
172
|
this.offLabelTemplate = contentChild(SwitchOffLabelTemplateDirective, { ...(ngDevMode ? { debugName: "offLabelTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
154
173
|
this.onLabelTemplate = contentChild(SwitchOnLabelTemplateDirective, { ...(ngDevMode ? { debugName: "onLabelTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
155
174
|
/**
|
|
@@ -173,15 +192,13 @@ class SwitchComponent {
|
|
|
173
192
|
* @description Renders the component with reduced visual emphasis and removes pointer interaction.
|
|
174
193
|
* @default false
|
|
175
194
|
*/
|
|
176
|
-
this.disabled = input(false, /*
|
|
177
|
-
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
195
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
178
196
|
/**
|
|
179
|
-
* @description Marks the switch as invalid. When bound to a signal form field via `[
|
|
180
|
-
*
|
|
197
|
+
* @description Marks the switch as invalid. When bound to a signal form field via `[formField]`, this is written by
|
|
198
|
+
* the `FormField` directive.
|
|
181
199
|
* @default false
|
|
182
200
|
*/
|
|
183
|
-
this.invalid = input(false, /*
|
|
184
|
-
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
201
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
185
202
|
/**
|
|
186
203
|
* @description Label displayed inside the switch track when it is in the off state.
|
|
187
204
|
* @default ""
|
|
@@ -194,12 +211,17 @@ class SwitchComponent {
|
|
|
194
211
|
*/
|
|
195
212
|
this.onLabel = input("", /* @ts-ignore */
|
|
196
213
|
...(ngDevMode ? [{ debugName: "onLabel" }] : /* istanbul ignore next */ []));
|
|
214
|
+
/**
|
|
215
|
+
* @description Prevents value changes while the control stays focusable and readable. When bound to a signal form
|
|
216
|
+
* field via `[formField]`, this is written by the `FormField` directive.
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
197
220
|
/**
|
|
198
221
|
* @description Marks the switch as required for form validation.
|
|
199
222
|
* @default false
|
|
200
223
|
*/
|
|
201
|
-
this.required = input(false, /*
|
|
202
|
-
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
224
|
+
this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
203
225
|
/**
|
|
204
226
|
* @description Border-radius preset applied to the component.
|
|
205
227
|
* @default "full"
|
|
@@ -212,17 +234,21 @@ class SwitchComponent {
|
|
|
212
234
|
*/
|
|
213
235
|
this.size = input("medium", /* @ts-ignore */
|
|
214
236
|
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
237
|
+
/**
|
|
238
|
+
* @description Tab index of the switch while it's enabled.
|
|
239
|
+
* @default 0
|
|
240
|
+
*/
|
|
241
|
+
this.tabindex = input(0, { ...(ngDevMode ? { debugName: "tabindex" } : /* istanbul ignore next */ {}), transform: (value) => numberAttribute(value, 0) });
|
|
215
242
|
/**
|
|
216
243
|
* @description Emitted when the switch loses focus or its value changes.
|
|
217
244
|
*/
|
|
218
245
|
this.touch = output();
|
|
219
246
|
/**
|
|
220
|
-
* @description Marks the switch as touched. When bound to a signal form field via `[
|
|
221
|
-
*
|
|
247
|
+
* @description Marks the switch as touched. When bound to a signal form field via `[formField]`, this is written by
|
|
248
|
+
* the `FormField` directive.
|
|
222
249
|
* @default false
|
|
223
250
|
*/
|
|
224
|
-
this.touched = input(false, /*
|
|
225
|
-
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
251
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
226
252
|
/**
|
|
227
253
|
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
228
254
|
* @default ""
|
|
@@ -232,47 +258,73 @@ class SwitchComponent {
|
|
|
232
258
|
read: () => this.#setEventListeners()
|
|
233
259
|
});
|
|
234
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Toggles the switch when a label for it is clicked, as a native label does for a checkbox.
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
activateFromLabel() {
|
|
266
|
+
this.focus();
|
|
267
|
+
this.#toggleState();
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @description Moves focus to the switch.
|
|
271
|
+
* @param options Options passed to the native `focus()` call, such as `preventScroll`.
|
|
272
|
+
*/
|
|
273
|
+
focus(options) {
|
|
274
|
+
this.#hostElementRef.nativeElement.focus(options);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @internal
|
|
278
|
+
*/
|
|
279
|
+
setLabelledBy(id) {
|
|
280
|
+
this.#label.setLabelledBy(id);
|
|
281
|
+
}
|
|
235
282
|
onBlur() {
|
|
236
283
|
this.touch.emit();
|
|
237
284
|
}
|
|
238
285
|
#setEventListeners() {
|
|
239
286
|
const host = this.#hostElementRef.nativeElement;
|
|
240
287
|
const click$ = fromEvent(host, "click");
|
|
241
|
-
const keydown$ = fromEvent(host, "keydown").pipe(
|
|
242
|
-
|
|
288
|
+
const keydown$ = fromEvent(host, "keydown").pipe(
|
|
289
|
+
// Keys pressed on a control inside a handle or label template are that control's.
|
|
290
|
+
filter(event => event.target === host && (event.key === " " || event.key === "Enter")), tap(event => event.preventDefault()), // Prevent page scroll on Space
|
|
291
|
+
filter(event => !event.repeat));
|
|
243
292
|
merge(click$, keydown$)
|
|
244
293
|
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
245
294
|
.subscribe(() => this.#toggleState());
|
|
246
295
|
}
|
|
247
296
|
#toggleState() {
|
|
248
|
-
if (this.
|
|
297
|
+
if (this.effectiveDisabled() || this.readonly()) {
|
|
249
298
|
return;
|
|
250
299
|
}
|
|
251
300
|
this.checked.set(!this.checked());
|
|
252
301
|
this.touch.emit();
|
|
253
302
|
}
|
|
254
303
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
255
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SwitchComponent, isStandalone: true, selector: "mona-switch", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", 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 }, offLabel: { classPropertyName: "offLabel", publicName: "offLabel", isSignal: true, isRequired: false, transformFunction: null }, onLabel: { classPropertyName: "onLabel", publicName: "onLabel", 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 }, size: { classPropertyName: "size", publicName: "size", 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 } }, outputs: { checked: "checkedChange", touch: "touch" }, host: { listeners: { "blur": "onBlur()" }, properties: { "attr.role": "'switch'", "attr.aria-checked": "checked()", "attr.aria-disabled": "
|
|
304
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SwitchComponent, isStandalone: true, selector: "mona-switch", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", 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 }, offLabel: { classPropertyName: "offLabel", publicName: "offLabel", isSignal: true, isRequired: false, transformFunction: null }, onLabel: { classPropertyName: "onLabel", publicName: "onLabel", 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 }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", 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 } }, outputs: { checked: "checkedChange", touch: "touch" }, host: { listeners: { "blur": "onBlur()" }, properties: { "attr.role": "'switch'", "attr.aria-checked": "checked()", "attr.aria-disabled": "effectiveDisabled() || undefined", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "labelledBy()", "attr.aria-readonly": "readonly() || null", "attr.aria-required": "required() || null", "attr.data-readonly": "readonly() || null", "attr.tabindex": "effectiveDisabled() ? -1 : tabindex()", "attr.data-active": "checked()", "attr.data-disabled": "effectiveDisabled()", "attr.data-invalid": "invalidState() || null", "attr.aria-invalid": "invalidState() ? 'true' : null", "class": "classes()" } }, queries: [{ propertyName: "handleContentTemplate", first: true, predicate: SwitchHandleContentTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "offLabelTemplate", first: true, predicate: SwitchOffLabelTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "onLabelTemplate", first: true, predicate: SwitchOnLabelTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<span aria-hidden=\"true\" [class]=\"labelClasses()\">\n @if (checked() && !onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ onLabel() }}</span>\n }\n @if (checked() && onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"onLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<span aria-hidden=\"true\" [class]=\"labelClasses()\">\n @if (!checked() && !offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ offLabel() }}</span>\n }\n @if (!checked() && offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"offLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<div [class]=\"handleClasses()\" [attr.data-active]=\"checked()\">\n @if (handleContentTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"handleContentTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: checked() }\"></ng-container>\n }\n</div>\n", styles: [".mona-switch-label-enter{animation:mona-switch-label-fade-in .3s ease-out}.mona-switch-label-leave{animation:mona-switch-label-fade-out .3s ease-out}@keyframes mona-switch-label-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-switch-label-fade-out{0%{opacity:1}to{opacity:0}}@media(prefers-reduced-motion:reduce){.mona-switch-label-enter,.mona-switch-label-leave{animation-duration:1ms}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
256
305
|
}
|
|
257
306
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchComponent, decorators: [{
|
|
258
307
|
type: Component,
|
|
259
308
|
args: [{ selector: "mona-switch", imports: [NgTemplateOutlet], host: {
|
|
260
309
|
"[attr.role]": "'switch'",
|
|
261
310
|
"[attr.aria-checked]": "checked()",
|
|
262
|
-
"[attr.aria-disabled]": "
|
|
311
|
+
"[attr.aria-disabled]": "effectiveDisabled() || undefined",
|
|
263
312
|
"[attr.aria-label]": "ariaLabel()",
|
|
264
|
-
"[attr.aria-labelledby]": "
|
|
265
|
-
"[attr.
|
|
313
|
+
"[attr.aria-labelledby]": "labelledBy()",
|
|
314
|
+
"[attr.aria-readonly]": "readonly() || null",
|
|
315
|
+
"[attr.aria-required]": "required() || null",
|
|
316
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
317
|
+
"[attr.tabindex]": "effectiveDisabled() ? -1 : tabindex()",
|
|
266
318
|
"[attr.data-active]": "checked()",
|
|
267
|
-
"[attr.data-disabled]": "
|
|
319
|
+
"[attr.data-disabled]": "effectiveDisabled()",
|
|
268
320
|
"[attr.data-invalid]": "invalidState() || null",
|
|
269
321
|
"[attr.aria-invalid]": "invalidState() ? 'true' : null",
|
|
270
322
|
"[class]": "classes()",
|
|
271
323
|
"(blur)": "onBlur()"
|
|
272
|
-
}, template: "<span [class]=\"labelClasses()\">\n @if (checked() && !onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ onLabel() }}</span>\n }\n @if (checked() && onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"onLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<span [class]=\"labelClasses()\">\n @if (!checked() && !offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ offLabel() }}</span>\n }\n @if (!checked() && offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"offLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<div [class]=\"handleClasses()\" [attr.data-active]=\"checked()\">\n @if (handleContentTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"handleContentTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: checked() }\"></ng-container>\n }\n</div>\n", styles: [".mona-switch-label-enter{animation:mona-switch-label-fade-in .3s ease-out}.mona-switch-label-leave{animation:mona-switch-label-fade-out .3s ease-out}@keyframes mona-switch-label-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-switch-label-fade-out{0%{opacity:1}to{opacity:0}}@media(prefers-reduced-motion:reduce){.mona-switch-label-enter,.mona-switch-label-leave{animation-duration:1ms}}\n"] }]
|
|
324
|
+
}, template: "<span aria-hidden=\"true\" [class]=\"labelClasses()\">\n @if (checked() && !onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ onLabel() }}</span>\n }\n @if (checked() && onLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"onLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<span aria-hidden=\"true\" [class]=\"labelClasses()\">\n @if (!checked() && !offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ offLabel() }}</span>\n }\n @if (!checked() && offLabelTemplate()) {\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\n <ng-container [ngTemplateOutlet]=\"offLabelTemplate() ?? null\"></ng-container>\n </span>\n }\n</span>\n<div [class]=\"handleClasses()\" [attr.data-active]=\"checked()\">\n @if (handleContentTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"handleContentTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: checked() }\"></ng-container>\n }\n</div>\n", styles: [".mona-switch-label-enter{animation:mona-switch-label-fade-in .3s ease-out}.mona-switch-label-leave{animation:mona-switch-label-fade-out .3s ease-out}@keyframes mona-switch-label-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-switch-label-fade-out{0%{opacity:1}to{opacity:0}}@media(prefers-reduced-motion:reduce){.mona-switch-label-enter,.mona-switch-label-leave{animation-duration:1ms}}\n"] }]
|
|
273
325
|
}], ctorParameters: () => [], propDecorators: { handleContentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchHandleContentTemplateDirective), { ...{
|
|
274
326
|
read: TemplateRef
|
|
275
|
-
}, isSignal: true }] }], offLabelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchOffLabelTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], onLabelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchOnLabelTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], offLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "offLabel", required: false }] }], onLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "onLabel", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", 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 }] }] } });
|
|
327
|
+
}, isSignal: true }] }], offLabelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchOffLabelTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], onLabelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchOnLabelTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], offLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "offLabel", required: false }] }], onLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "onLabel", 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 }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", 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 }] }] } });
|
|
276
328
|
|
|
277
329
|
/*
|
|
278
330
|
* Public API Surface of @nanahoshi/mona-ui/switch
|