@nanahoshi/mona-ui 0.1.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.
Files changed (134) hide show
  1. package/README.md +25 -0
  2. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
  3. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
  4. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
  5. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
  6. package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
  7. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
  8. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
  9. package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
  10. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
  11. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
  12. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
  13. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
  14. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
  15. package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
  16. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
  17. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
  18. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
  19. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
  20. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
  21. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
  22. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
  23. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
  24. package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
  25. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
  26. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
  27. package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
  28. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
  29. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
  30. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
  31. package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
  32. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
  33. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
  34. package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
  35. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
  36. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
  37. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
  38. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
  39. package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
  40. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
  41. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
  42. package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
  43. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
  44. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
  45. package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
  46. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
  47. package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
  48. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
  49. package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
  50. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
  51. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
  52. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
  53. package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
  54. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
  55. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
  56. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
  57. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
  58. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
  59. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
  60. package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
  61. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
  62. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
  63. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
  64. package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
  65. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
  66. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
  67. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
  68. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
  69. package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
  70. package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
  71. package/package.json +289 -0
  72. package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
  73. package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
  74. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
  75. package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
  76. package/types/nanahoshi-mona-ui-button.d.ts +111 -0
  77. package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
  78. package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
  79. package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
  80. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
  81. package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
  82. package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
  83. package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
  84. package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
  85. package/types/nanahoshi-mona-ui-common.d.ts +386 -0
  86. package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
  87. package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
  88. package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
  89. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
  90. package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
  91. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
  92. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
  93. package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
  94. package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
  95. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
  96. package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
  97. package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
  98. package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
  99. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
  100. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
  101. package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
  102. package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
  103. package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
  104. package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
  105. package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
  106. package/types/nanahoshi-mona-ui-list.d.ts +1 -0
  107. package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
  108. package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
  109. package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
  110. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
  111. package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
  112. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
  113. package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
  114. package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
  115. package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
  116. package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
  117. package/types/nanahoshi-mona-ui-query.d.ts +89 -0
  118. package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
  119. package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
  120. package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
  121. package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
  122. package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
  123. package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
  124. package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
  125. package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
  126. package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
  127. package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
  128. package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
  129. package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
  130. package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
  131. package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
  132. package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
  133. package/types/nanahoshi-mona-ui-window.d.ts +295 -0
  134. package/types/nanahoshi-mona-ui.d.ts +2 -0
@@ -0,0 +1,308 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { Directive, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef, input, model, output, afterNextRender, Component } from '@angular/core';
4
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
+ import { ThemeService } from '@nanahoshi/mona-ui/theme';
6
+ import { fromEvent, filter, tap, merge } from 'rxjs';
7
+ import { twMerge } from 'tailwind-merge';
8
+ import { cva } from 'class-variance-authority';
9
+
10
+ class SwitchHandleContentTemplateDirective {
11
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchHandleContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
12
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SwitchHandleContentTemplateDirective, isStandalone: true, selector: "ng-template[monaSwitchHandleContentTemplate]", ngImport: i0 }); }
13
+ }
14
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchHandleContentTemplateDirective, decorators: [{
15
+ type: Directive,
16
+ args: [{
17
+ selector: "ng-template[monaSwitchHandleContentTemplate]"
18
+ }]
19
+ }] });
20
+
21
+ class SwitchOffLabelTemplateDirective {
22
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchOffLabelTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
23
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SwitchOffLabelTemplateDirective, isStandalone: true, selector: "ng-template[monaSwitchOffLabelTemplate]", ngImport: i0 }); }
24
+ }
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchOffLabelTemplateDirective, decorators: [{
26
+ type: Directive,
27
+ args: [{
28
+ selector: "ng-template[monaSwitchOffLabelTemplate]"
29
+ }]
30
+ }] });
31
+
32
+ class SwitchOnLabelTemplateDirective {
33
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchOnLabelTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
34
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SwitchOnLabelTemplateDirective, isStandalone: true, selector: "ng-template[monaSwitchOnLabelTemplate]", ngImport: i0 }); }
35
+ }
36
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchOnLabelTemplateDirective, decorators: [{
37
+ type: Directive,
38
+ args: [{
39
+ selector: "ng-template[monaSwitchOnLabelTemplate]"
40
+ }]
41
+ }] });
42
+
43
+ const switchVariants = cva(`
44
+ relative flex items-center cursor-pointer select-none
45
+ transition-[background]
46
+
47
+ bg-input-background
48
+ border border-input-border
49
+ outline-none
50
+
51
+ focus-within:ring-2 focus-within:ring-primary/40
52
+
53
+ data-[disabled='true']:pointer-events-none
54
+ data-[disabled='true']:opacity-50
55
+
56
+ data-[active='true']:bg-primary
57
+ data-[active='true']:text-primary-foreground
58
+
59
+ [&.ng-touched.ng-invalid]:border-error
60
+
61
+ data-[invalid='true']:border-error
62
+ data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/40
63
+ `, {
64
+ variants: {
65
+ rounded: {
66
+ full: "rounded-full",
67
+ large: "rounded-lg",
68
+ medium: "rounded-md",
69
+ none: "rounded-none",
70
+ small: "rounded-sm"
71
+ },
72
+ size: {
73
+ large: "w-14 h-7.5 text-md",
74
+ medium: "w-12 h-6.5 text-sm",
75
+ small: "w-10 h-5.5 text-xs"
76
+ }
77
+ }
78
+ });
79
+ const switchHandleVariants = cva(`
80
+ absolute inline-flex
81
+ items-center justify-center
82
+ outline-none transition-[left,background] ease-in-out duration-300
83
+ border border-border bg-secondary
84
+ data-[active='true']:bg-background
85
+ `, {
86
+ variants: {
87
+ rounded: {
88
+ full: "rounded-full",
89
+ large: "rounded-lg",
90
+ medium: "rounded-md",
91
+ none: "rounded-none",
92
+ small: "rounded-sm"
93
+ },
94
+ size: {
95
+ large: `
96
+ w-6 h-6
97
+ data-[active='true']:left-[calc(100%-26px)]
98
+ data-[active='false']:left-0.5
99
+ `,
100
+ medium: `
101
+ w-5 h-5
102
+ data-[active='true']:left-[calc(100%-22px)]
103
+ data-[active='false']:left-0.5
104
+ `,
105
+ small: `
106
+ w-4 h-4
107
+ data-[active='true']:left-[calc(100%-18px)]
108
+ data-[active='false']:left-0.5
109
+ `
110
+ }
111
+ }
112
+ });
113
+ const switchLabelVariants = cva(`
114
+ h-full flex flex-1 items-center justify-center text-xs
115
+ `);
116
+
117
+ const switchThemeVariants = (theme) => {
118
+ switch (theme) {
119
+ case "mona":
120
+ return switchVariants;
121
+ default:
122
+ return switchVariants; // Default to Mona styles
123
+ }
124
+ };
125
+ const switchHandleThemeVariants = (theme) => {
126
+ switch (theme) {
127
+ case "mona":
128
+ return switchHandleVariants;
129
+ default:
130
+ return switchHandleVariants; // Default to Mona styles
131
+ }
132
+ };
133
+ const switchLabelThemeVariants = (theme) => {
134
+ switch (theme) {
135
+ case "mona":
136
+ return switchLabelVariants;
137
+ default:
138
+ return switchLabelVariants; // Default to Mona styles
139
+ }
140
+ };
141
+
142
+ class SwitchComponent {
143
+ #destroyRef;
144
+ #hostElementRef;
145
+ #themeService;
146
+ constructor() {
147
+ this.#destroyRef = inject(DestroyRef);
148
+ this.#hostElementRef = inject((ElementRef));
149
+ this.#themeService = inject(ThemeService);
150
+ this.classes = computed(() => {
151
+ const theme = this.#themeService.theme();
152
+ const rounded = this.rounded();
153
+ const size = this.size();
154
+ const classes = switchThemeVariants(theme)({ rounded, size });
155
+ return twMerge(classes, this.userClass());
156
+ }, /* @ts-ignore */
157
+ ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
158
+ this.invalidState = computed(() => this.invalid() || (this.required() && this.touched() && !this.checked()), /* @ts-ignore */
159
+ ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
160
+ this.handleClasses = computed(() => {
161
+ const theme = this.#themeService.theme();
162
+ const rounded = this.rounded();
163
+ const size = this.size();
164
+ const classes = switchHandleThemeVariants(theme)({ rounded, size });
165
+ return twMerge(classes);
166
+ }, /* @ts-ignore */
167
+ ...(ngDevMode ? [{ debugName: "handleClasses" }] : /* istanbul ignore next */ []));
168
+ this.handleContentTemplate = contentChild(SwitchHandleContentTemplateDirective, { ...(ngDevMode ? { debugName: "handleContentTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
169
+ this.labelClasses = computed(() => {
170
+ const theme = this.#themeService.theme();
171
+ const classes = switchLabelThemeVariants(theme)();
172
+ return twMerge(classes);
173
+ }, /* @ts-ignore */
174
+ ...(ngDevMode ? [{ debugName: "labelClasses" }] : /* istanbul ignore next */ []));
175
+ this.offLabelTemplate = contentChild(SwitchOffLabelTemplateDirective, { ...(ngDevMode ? { debugName: "offLabelTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
176
+ this.onLabelTemplate = contentChild(SwitchOnLabelTemplateDirective, { ...(ngDevMode ? { debugName: "onLabelTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
177
+ /**
178
+ * @description Accessible name for the host element. Describe what the component represents.
179
+ * When empty, assistive technology announces the role without a label.
180
+ * @default null
181
+ */
182
+ this.ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
183
+ /**
184
+ * @description ID of an external element that provides the accessible name for the host element.
185
+ * @default null
186
+ */
187
+ this.ariaLabelledBy = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
188
+ /**
189
+ * @description Whether the control is checked.
190
+ * @default false
191
+ */
192
+ this.checked = model(false, /* @ts-ignore */
193
+ ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
194
+ /**
195
+ * @description Renders the component with reduced visual emphasis and removes pointer interaction.
196
+ * @default false
197
+ */
198
+ this.disabled = input(false, /* @ts-ignore */
199
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
200
+ /**
201
+ * @description Marks the switch as invalid. When bound to a signal form field via `[field]`,
202
+ * this is written by the signal forms `Field` directive.
203
+ * @default false
204
+ */
205
+ this.invalid = input(false, /* @ts-ignore */
206
+ ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
207
+ /**
208
+ * @description Label displayed inside the switch track when it is in the off state.
209
+ * @default ""
210
+ */
211
+ this.offLabel = input("", /* @ts-ignore */
212
+ ...(ngDevMode ? [{ debugName: "offLabel" }] : /* istanbul ignore next */ []));
213
+ /**
214
+ * @description Label displayed inside the switch track when it is in the on state.
215
+ * @default ""
216
+ */
217
+ this.onLabel = input("", /* @ts-ignore */
218
+ ...(ngDevMode ? [{ debugName: "onLabel" }] : /* istanbul ignore next */ []));
219
+ /**
220
+ * @description Marks the switch as required for form validation.
221
+ * @default false
222
+ */
223
+ this.required = input(false, /* @ts-ignore */
224
+ ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
225
+ /**
226
+ * @description Border-radius preset applied to the component.
227
+ * @default "full"
228
+ */
229
+ this.rounded = input("full", /* @ts-ignore */
230
+ ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
231
+ /**
232
+ * @description Size preset controlling the component's dimensions.
233
+ * @default "medium"
234
+ */
235
+ this.size = input("medium", /* @ts-ignore */
236
+ ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
237
+ /**
238
+ * @description Emitted when the switch loses focus or its value changes.
239
+ */
240
+ this.touch = output();
241
+ /**
242
+ * @description Marks the switch as touched. When bound to a signal form field via `[field]`,
243
+ * this is written by the signal forms `Field` directive.
244
+ * @default false
245
+ */
246
+ this.touched = input(false, /* @ts-ignore */
247
+ ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
248
+ /**
249
+ * @description Additional CSS classes merged onto the host element via `tailwind-merge`.
250
+ * @default ""
251
+ */
252
+ this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
253
+ afterNextRender({
254
+ read: () => this.#setEventListeners()
255
+ });
256
+ }
257
+ onBlur() {
258
+ this.touch.emit();
259
+ }
260
+ #setEventListeners() {
261
+ const host = this.#hostElementRef.nativeElement;
262
+ const click$ = fromEvent(host, "click");
263
+ const keydown$ = fromEvent(host, "keydown").pipe(filter(event => event.key === " " || event.key === "Enter"), tap(event => event.preventDefault()) // Prevent page scroll on Space
264
+ );
265
+ merge(click$, keydown$)
266
+ .pipe(takeUntilDestroyed(this.#destroyRef))
267
+ .subscribe(() => this.#toggleState());
268
+ }
269
+ #toggleState() {
270
+ if (this.disabled()) {
271
+ return;
272
+ }
273
+ this.checked.set(!this.checked());
274
+ this.touch.emit();
275
+ }
276
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
277
+ 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": "disabled() || undefined", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.tabindex": "disabled() ? -1 : 0", "attr.data-active": "checked()", "attr.data-disabled": "disabled()", "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 [class]=\"labelClasses()\">\r\n @if (checked() && !onLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ onLabel() }}</span>\r\n }\r\n @if (checked() && onLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\r\n <ng-container [ngTemplateOutlet]=\"onLabelTemplate() ?? null\"></ng-container>\r\n </span>\r\n }\r\n</span>\r\n<span [class]=\"labelClasses()\">\r\n @if (!checked() && !offLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ offLabel() }}</span>\r\n }\r\n @if (!checked() && offLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\r\n <ng-container [ngTemplateOutlet]=\"offLabelTemplate() ?? null\"></ng-container>\r\n </span>\r\n }\r\n</span>\r\n<div [class]=\"handleClasses()\" [attr.data-active]=\"checked()\">\r\n @if (handleContentTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"handleContentTemplate() ?? null\"\r\n [ngTemplateOutletContext]=\"{ $implicit: checked() }\"></ng-container>\r\n }\r\n</div>\r\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"] }] }); }
278
+ }
279
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchComponent, decorators: [{
280
+ type: Component,
281
+ args: [{ selector: "mona-switch", imports: [NgTemplateOutlet], host: {
282
+ "[attr.role]": "'switch'",
283
+ "[attr.aria-checked]": "checked()",
284
+ "[attr.aria-disabled]": "disabled() || undefined",
285
+ "[attr.aria-label]": "ariaLabel()",
286
+ "[attr.aria-labelledby]": "ariaLabelledBy()",
287
+ "[attr.tabindex]": "disabled() ? -1 : 0",
288
+ "[attr.data-active]": "checked()",
289
+ "[attr.data-disabled]": "disabled()",
290
+ "[attr.data-invalid]": "invalidState() || null",
291
+ "[attr.aria-invalid]": "invalidState() ? 'true' : null",
292
+ "[class]": "classes()",
293
+ "(blur)": "onBlur()"
294
+ }, template: "<span [class]=\"labelClasses()\">\r\n @if (checked() && !onLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ onLabel() }}</span>\r\n }\r\n @if (checked() && onLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\r\n <ng-container [ngTemplateOutlet]=\"onLabelTemplate() ?? null\"></ng-container>\r\n </span>\r\n }\r\n</span>\r\n<span [class]=\"labelClasses()\">\r\n @if (!checked() && !offLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">{{ offLabel() }}</span>\r\n }\r\n @if (!checked() && offLabelTemplate()) {\r\n <span animate.enter=\"mona-switch-label-enter\" animate.leave=\"mona-switch-label-leave\">\r\n <ng-container [ngTemplateOutlet]=\"offLabelTemplate() ?? null\"></ng-container>\r\n </span>\r\n }\r\n</span>\r\n<div [class]=\"handleClasses()\" [attr.data-active]=\"checked()\">\r\n @if (handleContentTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"handleContentTemplate() ?? null\"\r\n [ngTemplateOutletContext]=\"{ $implicit: checked() }\"></ng-container>\r\n }\r\n</div>\r\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"] }]
295
+ }], ctorParameters: () => [], propDecorators: { handleContentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SwitchHandleContentTemplateDirective), { ...{
296
+ read: TemplateRef
297
+ }, 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 }] }] } });
298
+
299
+ /*
300
+ * Public API Surface of @nanahoshi/mona-ui/switch
301
+ */
302
+
303
+ /**
304
+ * Generated bundle index. Do not edit.
305
+ */
306
+
307
+ export { SwitchComponent, SwitchHandleContentTemplateDirective, SwitchOffLabelTemplateDirective, SwitchOnLabelTemplateDirective };
308
+ //# sourceMappingURL=nanahoshi-mona-ui-switch.mjs.map