@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,537 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, inject, ElementRef, computed, input, afterRenderEffect, DestroyRef, signal, contentChild, TemplateRef, model, effect, afterNextRender, Component } from '@angular/core';
3
+ import { NgTemplateOutlet } from '@angular/common';
4
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
+ import { select } from '@mirei/ts-collections';
6
+ import { fromEvent } from 'rxjs';
7
+ import { ThemeService } from '@nanahoshi/mona-ui/theme';
8
+ import { cva } from 'class-variance-authority';
9
+
10
+ /**
11
+ * Marks an ng-template as the custom indicator template for mona-stepper.
12
+ * The template context provides the step options, index, active state, and current step index.
13
+ */
14
+ class StepperIndicatorTemplateDirective {
15
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperIndicatorTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
16
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: StepperIndicatorTemplateDirective, isStandalone: true, selector: "ng-template[monaStepperIndicatorTemplate]", ngImport: i0 }); }
17
+ }
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperIndicatorTemplateDirective, decorators: [{
19
+ type: Directive,
20
+ args: [{
21
+ selector: "ng-template[monaStepperIndicatorTemplate]"
22
+ }]
23
+ }] });
24
+
25
+ /**
26
+ * Marks an ng-template as the custom label template for mona-stepper.
27
+ * The template context provides the step options, index, active state, and current step index.
28
+ */
29
+ class StepperLabelTemplateDirective {
30
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperLabelTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
31
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: StepperLabelTemplateDirective, isStandalone: true, selector: "ng-template[monaStepperLabelTemplate]", ngImport: i0 }); }
32
+ }
33
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperLabelTemplateDirective, decorators: [{
34
+ type: Directive,
35
+ args: [{
36
+ selector: "ng-template[monaStepperLabelTemplate]"
37
+ }]
38
+ }] });
39
+
40
+ /**
41
+ * Marks an ng-template as the custom step template for mona-stepper.
42
+ * When provided, this template replaces the entire default step indicator and label for each step.
43
+ * The template context provides the step options, index, active state, and current step index.
44
+ */
45
+ class StepperStepTemplateDirective {
46
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperStepTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
47
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: StepperStepTemplateDirective, isStandalone: true, selector: "ng-template[monaStepperStepTemplate]", ngImport: i0 }); }
48
+ }
49
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperStepTemplateDirective, decorators: [{
50
+ type: Directive,
51
+ args: [{
52
+ selector: "ng-template[monaStepperStepTemplate]"
53
+ }]
54
+ }] });
55
+
56
+ const stepperBaseVariants = cva(`
57
+ relative grid outline-none
58
+ `, {
59
+ variants: {
60
+ orientation: {
61
+ horizontal: "w-full h-auto",
62
+ vertical: "h-full w-auto"
63
+ }
64
+ },
65
+ defaultVariants: {
66
+ orientation: "horizontal"
67
+ }
68
+ });
69
+ const stepperStepListVariants = cva(`
70
+ absolute flex list-none col-span-full
71
+ font-medium z-1
72
+ `, {
73
+ variants: {
74
+ orientation: {
75
+ horizontal: `
76
+ flex-row w-full
77
+ -translate-y-3
78
+ `,
79
+ vertical: `
80
+ flex-col h-full w-max
81
+ -translate-x-3
82
+ `
83
+ }
84
+ },
85
+ defaultVariants: {
86
+ orientation: "horizontal"
87
+ }
88
+ });
89
+ const stepperStepListItemVariants = cva(`
90
+ flex items-center
91
+ grow-1 shrink-0 basis-auto
92
+ z-1
93
+ `, {
94
+ variants: {
95
+ orientation: {
96
+ horizontal: "flex-col gap-2",
97
+ vertical: "flex-row gap-2 justify-start"
98
+ }
99
+ },
100
+ defaultVariants: {
101
+ orientation: "horizontal"
102
+ }
103
+ });
104
+ const stepperStepIndicatorVariants = cva(`
105
+ w-8 h-8
106
+ flex items-center justify-center
107
+ bg-background border border-border
108
+ text-foreground outline-none
109
+ transition-colors duration-400 ease-in-out
110
+ `, {
111
+ variants: {
112
+ active: {
113
+ true: "bg-primary text-primary-foreground",
114
+ false: ""
115
+ },
116
+ focused: {
117
+ true: "ring-2 ring-primary/40",
118
+ false: ""
119
+ },
120
+ rounded: {
121
+ small: "rounded-sm",
122
+ medium: "rounded-md",
123
+ large: "rounded-lg",
124
+ full: "rounded-full",
125
+ none: "rounded-none"
126
+ }
127
+ }
128
+ });
129
+ const stepperTrackVariants = cva(`
130
+ relative grid
131
+ bg-background border border-border
132
+ `, {
133
+ variants: {
134
+ orientation: {
135
+ horizontal: "w-full h-2",
136
+ vertical: "h-full w-2"
137
+ }
138
+ },
139
+ defaultVariants: {
140
+ orientation: "horizontal"
141
+ }
142
+ });
143
+ const stepperTrackLineVariants = cva(`
144
+ absolute bg-primary
145
+ `, {
146
+ variants: {
147
+ orientation: {
148
+ horizontal: "h-full transition-width duration-300 ease-out",
149
+ vertical: "w-full transition-height duration-300 ease-out"
150
+ }
151
+ },
152
+ defaultVariants: {
153
+ orientation: "horizontal"
154
+ }
155
+ });
156
+
157
+ const stepperBaseThemeVariants = (theme) => {
158
+ switch (theme) {
159
+ case "mona":
160
+ return stepperBaseVariants;
161
+ default:
162
+ return stepperBaseVariants;
163
+ }
164
+ };
165
+ const stepperStepListThemeVariants = (theme) => {
166
+ switch (theme) {
167
+ case "mona":
168
+ return stepperStepListVariants;
169
+ default:
170
+ return stepperStepListVariants;
171
+ }
172
+ };
173
+ const stepperStepListItemThemeVariants = (theme) => {
174
+ switch (theme) {
175
+ case "mona":
176
+ return stepperStepListItemVariants;
177
+ default:
178
+ return stepperStepListItemVariants;
179
+ }
180
+ };
181
+ const stepperStepIndicatorThemeVariants = (theme) => {
182
+ switch (theme) {
183
+ case "mona":
184
+ return stepperStepIndicatorVariants;
185
+ default:
186
+ return stepperStepIndicatorVariants;
187
+ }
188
+ };
189
+ const stepperTrackThemeVariants = (theme) => {
190
+ switch (theme) {
191
+ case "mona":
192
+ return stepperTrackVariants;
193
+ default:
194
+ return stepperTrackVariants;
195
+ }
196
+ };
197
+ const stepperTrackLineThemeVariants = (theme) => {
198
+ switch (theme) {
199
+ case "mona":
200
+ return stepperTrackLineVariants;
201
+ default:
202
+ return stepperTrackLineVariants;
203
+ }
204
+ };
205
+
206
+ class StepperIndicatorDirective {
207
+ #wasFocused;
208
+ #host;
209
+ #themeService;
210
+ constructor() {
211
+ this.#wasFocused = false;
212
+ this.#host = inject(ElementRef);
213
+ this.#themeService = inject(ThemeService);
214
+ this.stepIndicatorClass = computed(() => {
215
+ const theme = this.#themeService.theme();
216
+ const active = this.active();
217
+ const focused = this.focused();
218
+ const rounded = this.rounded();
219
+ return stepperStepIndicatorThemeVariants(theme)({ active, focused, rounded });
220
+ }, /* @ts-ignore */
221
+ ...(ngDevMode ? [{ debugName: "stepIndicatorClass" }] : /* istanbul ignore next */ []));
222
+ this.active = input.required(/* @ts-ignore */
223
+ ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
224
+ this.focused = input.required(/* @ts-ignore */
225
+ ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
226
+ this.rounded = input.required(/* @ts-ignore */
227
+ ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
228
+ afterRenderEffect({
229
+ read: () => {
230
+ const focused = this.focused();
231
+ if (focused && !this.#wasFocused) {
232
+ this.#host.nativeElement.focus();
233
+ }
234
+ this.#wasFocused = focused;
235
+ }
236
+ });
237
+ }
238
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperIndicatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
239
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: StepperIndicatorDirective, isStandalone: true, selector: "span[monaStepperIndicator]", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: true, transformFunction: null }, focused: { classPropertyName: "focused", publicName: "focused", isSignal: true, isRequired: true, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class": "stepIndicatorClass()" } }, ngImport: i0 }); }
240
+ }
241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperIndicatorDirective, decorators: [{
242
+ type: Directive,
243
+ args: [{
244
+ selector: "span[monaStepperIndicator]",
245
+ host: {
246
+ "[class]": "stepIndicatorClass()"
247
+ }
248
+ }]
249
+ }], ctorParameters: () => [], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: true }] }], focused: [{ type: i0.Input, args: [{ isSignal: true, alias: "focused", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }] } });
250
+
251
+ class StepperComponent {
252
+ #destroyRef;
253
+ #hostElementRef;
254
+ #themeService;
255
+ #trackItemSize;
256
+ #trackLength;
257
+ constructor() {
258
+ this.#destroyRef = inject(DestroyRef);
259
+ this.#hostElementRef = inject(ElementRef);
260
+ this.#themeService = inject(ThemeService);
261
+ this.#trackItemSize = computed(() => {
262
+ const stepCount = this.viewSteps().length;
263
+ return stepCount !== 0 ? 100 / stepCount : 0;
264
+ }, /* @ts-ignore */
265
+ ...(ngDevMode ? [{ debugName: "#trackItemSize" }] : /* istanbul ignore next */ []));
266
+ this.#trackLength = computed(() => {
267
+ const step = this.activeStep();
268
+ const stepCount = this.viewSteps().length;
269
+ return step && stepCount > 1 ? `${(100 / (stepCount - 1)) * step.index}%` : "0%";
270
+ }, /* @ts-ignore */
271
+ ...(ngDevMode ? [{ debugName: "#trackLength" }] : /* istanbul ignore next */ []));
272
+ this.activeStep = computed(() => {
273
+ const steps = this.viewSteps();
274
+ if (steps.length === 0) {
275
+ return undefined;
276
+ }
277
+ const step = this.step();
278
+ const clampedIndex = Math.min(Math.max(step, 0), steps.length - 1);
279
+ return steps.elementAt(clampedIndex);
280
+ }, /* @ts-ignore */
281
+ ...(ngDevMode ? [{ debugName: "activeStep" }] : /* istanbul ignore next */ []));
282
+ this.baseClass = computed(() => {
283
+ const theme = this.#themeService.theme();
284
+ const orientation = this.orientation();
285
+ return stepperBaseThemeVariants(theme)({ orientation });
286
+ }, /* @ts-ignore */
287
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
288
+ this.highlightedStep = signal(0, /* @ts-ignore */
289
+ ...(ngDevMode ? [{ debugName: "highlightedStep" }] : /* istanbul ignore next */ []));
290
+ this.hostStyles = computed(() => {
291
+ const orientation = this.orientation();
292
+ const stepCount = this.viewSteps().length;
293
+ return {
294
+ gridTemplateColumns: orientation === "horizontal" ? `repeat(${stepCount * 2}, 1fr)` : undefined,
295
+ gridTemplateRows: orientation === "vertical" ? `repeat(${stepCount * 2}, 1fr)` : undefined
296
+ };
297
+ }, /* @ts-ignore */
298
+ ...(ngDevMode ? [{ debugName: "hostStyles" }] : /* istanbul ignore next */ []));
299
+ this.indicatorTemplate = contentChild(StepperIndicatorTemplateDirective, {
300
+ read: TemplateRef
301
+ });
302
+ this.labelTemplate = contentChild(StepperLabelTemplateDirective, { read: TemplateRef });
303
+ this.listClass = computed(() => {
304
+ const theme = this.#themeService.theme();
305
+ const orientation = this.orientation();
306
+ return stepperStepListThemeVariants(theme)({ orientation });
307
+ }, /* @ts-ignore */
308
+ ...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
309
+ this.listItemClass = computed(() => {
310
+ const theme = this.#themeService.theme();
311
+ const orientation = this.orientation();
312
+ return stepperStepListItemThemeVariants(theme)({ orientation });
313
+ }, /* @ts-ignore */
314
+ ...(ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []));
315
+ this.progressMax = computed(() => Math.max(this.viewSteps().length - 1, 0), /* @ts-ignore */
316
+ ...(ngDevMode ? [{ debugName: "progressMax" }] : /* istanbul ignore next */ []));
317
+ this.stepTemplate = contentChild(StepperStepTemplateDirective, {
318
+ read: TemplateRef
319
+ });
320
+ this.trackClass = computed(() => {
321
+ const theme = this.#themeService.theme();
322
+ const orientation = this.orientation();
323
+ return stepperTrackThemeVariants(theme)({ orientation });
324
+ }, /* @ts-ignore */
325
+ ...(ngDevMode ? [{ debugName: "trackClass" }] : /* istanbul ignore next */ []));
326
+ this.trackInnerStyles = computed(() => {
327
+ const orientation = this.orientation();
328
+ const length = this.#trackLength();
329
+ return {
330
+ [orientation === "horizontal" ? "width" : "height"]: length
331
+ };
332
+ }, /* @ts-ignore */
333
+ ...(ngDevMode ? [{ debugName: "trackInnerStyles" }] : /* istanbul ignore next */ []));
334
+ this.trackItemStyles = computed(() => {
335
+ const orientation = this.orientation();
336
+ const itemSize = this.#trackItemSize();
337
+ return {
338
+ [orientation === "horizontal" ? "maxWidth" : "maxHeight"]: `${itemSize}%`
339
+ };
340
+ }, /* @ts-ignore */
341
+ ...(ngDevMode ? [{ debugName: "trackItemStyles" }] : /* istanbul ignore next */ []));
342
+ this.trackLineClass = computed(() => {
343
+ const theme = this.#themeService.theme();
344
+ const orientation = this.orientation();
345
+ return stepperTrackLineThemeVariants(theme)({ orientation });
346
+ }, /* @ts-ignore */
347
+ ...(ngDevMode ? [{ debugName: "trackLineClass" }] : /* istanbul ignore next */ []));
348
+ this.trackStyles = computed(() => {
349
+ const orientation = this.orientation();
350
+ const step = this.activeStep();
351
+ const stepCount = this.viewSteps().length;
352
+ const gridColumn = orientation === "horizontal" && step != null ? `2/${stepCount * 2}` : undefined;
353
+ const gridRow = orientation === "vertical" && step != null ? `2/${stepCount * 2}` : undefined;
354
+ return { gridColumn, gridRow };
355
+ }, /* @ts-ignore */
356
+ ...(ngDevMode ? [{ debugName: "trackStyles" }] : /* istanbul ignore next */ []));
357
+ this.viewSteps = computed(() => {
358
+ const steps = this.steps();
359
+ return select(steps, (step, index) => ({
360
+ options: step,
361
+ index
362
+ })).toImmutableSet();
363
+ }, /* @ts-ignore */
364
+ ...(ngDevMode ? [{ debugName: "viewSteps" }] : /* istanbul ignore next */ []));
365
+ /**
366
+ * @description Sets the accessible label for the stepper group.
367
+ * @default "Progress"
368
+ */
369
+ this.ariaLabel = input("Progress", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
370
+ /**
371
+ * @description Sets the flow of the stepper.
372
+ * If set to true, the user will only be able to navigate to the previous or the next step.
373
+ * @default true
374
+ */
375
+ this.linear = input(true, /* @ts-ignore */
376
+ ...(ngDevMode ? [{ debugName: "linear" }] : /* istanbul ignore next */ []));
377
+ /**
378
+ * @description Sets the orientation of the stepper.
379
+ */
380
+ this.orientation = input("horizontal", /* @ts-ignore */
381
+ ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
382
+ /**
383
+ * @description Sets the accessible label for the progress bar element.
384
+ * @default "Step progress"
385
+ */
386
+ this.progressAriaLabel = input("Step progress", /* @ts-ignore */
387
+ ...(ngDevMode ? [{ debugName: "progressAriaLabel" }] : /* istanbul ignore next */ []));
388
+ /**
389
+ * @description Sets the roundness of the stepper steps.
390
+ */
391
+ this.rounded = input("full", /* @ts-ignore */
392
+ ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
393
+ /**
394
+ * @description Sets the active step of the stepper.
395
+ */
396
+ this.step = model(0, /* @ts-ignore */
397
+ ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
398
+ /**
399
+ * @description Sets the steps of the stepper.
400
+ */
401
+ this.steps = input([], /* @ts-ignore */
402
+ ...(ngDevMode ? [{ debugName: "steps" }] : /* istanbul ignore next */ []));
403
+ effect(() => {
404
+ const activeIndex = this.step();
405
+ const stepCount = this.viewSteps().length;
406
+ if (stepCount === 0) {
407
+ return;
408
+ }
409
+ const clampedIndex = Math.min(Math.max(activeIndex, 0), stepCount - 1);
410
+ this.highlightedStep.set(clampedIndex);
411
+ });
412
+ afterNextRender({
413
+ read: () => this.setKeyboardEvents()
414
+ });
415
+ }
416
+ isStepActive(step) {
417
+ const active = this.activeStep();
418
+ return active != null && step.index <= active.index;
419
+ }
420
+ isStepLocked(step) {
421
+ if (step.options.disabled) {
422
+ return true;
423
+ }
424
+ if (!this.linear()) {
425
+ return false;
426
+ }
427
+ const active = this.activeStep();
428
+ if (!active) {
429
+ return false;
430
+ }
431
+ return Math.abs(step.index - active.index) > 1;
432
+ }
433
+ onIndicatorFocus(step) {
434
+ this.setHighlightedStep(step.index);
435
+ }
436
+ onStepClick(step) {
437
+ this.setActiveStep(step);
438
+ }
439
+ moveHighlight(offset) {
440
+ const steps = this.viewSteps();
441
+ const current = this.highlightedStep();
442
+ const linear = this.linear();
443
+ const activeStep = this.activeStep();
444
+ const stepCount = steps.length;
445
+ let target = current + offset;
446
+ const minIndex = linear && activeStep ? Math.max(activeStep.index - 1, 0) : 0;
447
+ const maxIndex = linear && activeStep ? Math.min(activeStep.index + 1, stepCount - 1) : stepCount - 1;
448
+ target = Math.min(Math.max(target, minIndex), maxIndex);
449
+ // Skip over disabled steps in the direction of travel.
450
+ while (target >= 0 && target < stepCount && steps.elementAt(target)?.options.disabled) {
451
+ target += offset;
452
+ }
453
+ if (target >= 0 && target < stepCount) {
454
+ this.setHighlightedStep(target);
455
+ }
456
+ }
457
+ setActiveStep(step) {
458
+ if (step.options.disabled) {
459
+ return;
460
+ }
461
+ const linear = this.linear();
462
+ const activeStep = this.activeStep();
463
+ const isPreviousStep = activeStep && activeStep.index - 1 === step.index;
464
+ const isNextStep = activeStep && activeStep.index + 1 === step.index;
465
+ if (!linear || (activeStep && (isPreviousStep || isNextStep))) {
466
+ this.step.set(step.index);
467
+ this.highlightedStep.set(step.index);
468
+ }
469
+ }
470
+ setHighlightedStep(index) {
471
+ const stepCount = this.viewSteps().length;
472
+ if (stepCount === 0) {
473
+ return;
474
+ }
475
+ const clampedIndex = Math.min(Math.max(index, 0), stepCount - 1);
476
+ this.highlightedStep.set(clampedIndex);
477
+ }
478
+ setKeyboardEvents() {
479
+ fromEvent(this.#hostElementRef.nativeElement, "keydown")
480
+ .pipe(takeUntilDestroyed(this.#destroyRef))
481
+ .subscribe(event => {
482
+ const orientation = this.orientation();
483
+ const previousKey = orientation === "vertical" ? "ArrowUp" : "ArrowLeft";
484
+ const nextKey = orientation === "vertical" ? "ArrowDown" : "ArrowRight";
485
+ if (event.key === previousKey) {
486
+ event.preventDefault();
487
+ this.moveHighlight(-1);
488
+ }
489
+ else if (event.key === nextKey) {
490
+ event.preventDefault();
491
+ this.moveHighlight(1);
492
+ }
493
+ else if (event.key === "Home") {
494
+ event.preventDefault();
495
+ this.setHighlightedStep(0);
496
+ }
497
+ else if (event.key === "End") {
498
+ event.preventDefault();
499
+ this.setHighlightedStep(this.viewSteps().length - 1);
500
+ }
501
+ else if (event.key === "Enter" || event.key === " ") {
502
+ event.preventDefault();
503
+ const highlightedStep = this.highlightedStep();
504
+ const step = this.viewSteps().elementAt(highlightedStep);
505
+ if (step) {
506
+ this.setActiveStep(step);
507
+ }
508
+ }
509
+ });
510
+ }
511
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
512
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: StepperComponent, isStandalone: true, selector: "mona-stepper", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, linear: { classPropertyName: "linear", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, progressAriaLabel: { classPropertyName: "progressAriaLabel", publicName: "progressAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, steps: { classPropertyName: "steps", publicName: "steps", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { step: "stepChange" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "ariaLabel()", "class": "baseClass()", "style": "hostStyles()" } }, queries: [{ propertyName: "indicatorTemplate", first: true, predicate: StepperIndicatorTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "labelTemplate", first: true, predicate: StepperLabelTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "stepTemplate", first: true, predicate: StepperStepTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<ol [class]=\"listClass()\">\r\n @for (step of viewSteps(); track step.index) {\r\n @let active = isStepActive(step);\r\n @let locked = isStepLocked(step);\r\n @let focused = step.index === highlightedStep();\r\n @let options = step.options;\r\n @let index = step.index;\r\n @let currentIndex = activeStep()?.index ?? -1;\r\n @let disabled = !!options.disabled;\r\n <li\r\n [class]=\"listItemClass()\"\r\n [class.cursor-pointer]=\"!locked\"\r\n [class.cursor-not-allowed]=\"locked\"\r\n [style]=\"trackItemStyles()\"\r\n role=\"presentation\"\r\n (click)=\"onStepClick(step)\">\r\n @if (stepTemplate()) {\r\n <span\r\n role=\"button\"\r\n [attr.aria-current]=\"step.index === activeStep()?.index ? 'step' : undefined\"\r\n [attr.aria-disabled]=\"locked ? true : undefined\"\r\n [attr.aria-label]=\"options.label\"\r\n [attr.tabindex]=\"focused ? 0 : -1\"\r\n (focus)=\"onIndicatorFocus(step)\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"stepTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n </span>\r\n } @else {\r\n <span\r\n monaStepperIndicator\r\n [rounded]=\"rounded()\"\r\n [active]=\"active\"\r\n [focused]=\"focused\"\r\n role=\"button\"\r\n [attr.aria-current]=\"step.index === activeStep()?.index ? 'step' : undefined\"\r\n [attr.aria-disabled]=\"locked ? true : undefined\"\r\n [attr.aria-label]=\"options.label\"\r\n [attr.tabindex]=\"focused ? 0 : -1\"\r\n (focus)=\"onIndicatorFocus(step)\">\r\n @if (indicatorTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"indicatorTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n } @else {\r\n {{ step.index + 1 }}\r\n }\r\n </span>\r\n }\r\n @if (labelTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"labelTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n } @else {\r\n <span aria-hidden=\"true\">{{ options.label }}</span>\r\n }\r\n </li>\r\n }\r\n</ol>\r\n<div\r\n [class]=\"trackClass()\"\r\n [style]=\"trackStyles()\"\r\n role=\"progressbar\"\r\n [attr.aria-valuenow]=\"step()\"\r\n [attr.aria-valuemin]=\"0\"\r\n [attr.aria-valuemax]=\"progressMax()\"\r\n [attr.aria-label]=\"progressAriaLabel()\">\r\n <div [class]=\"trackLineClass()\" [style]=\"trackInnerStyles()\"></div>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: StepperIndicatorDirective, selector: "span[monaStepperIndicator]", inputs: ["active", "focused", "rounded"] }] }); }
513
+ }
514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: StepperComponent, decorators: [{
515
+ type: Component,
516
+ args: [{ selector: "mona-stepper", imports: [NgTemplateOutlet, StepperIndicatorDirective], host: {
517
+ role: "group",
518
+ "[attr.aria-label]": "ariaLabel()",
519
+ "[class]": "baseClass()",
520
+ "[style]": "hostStyles()"
521
+ }, template: "<ol [class]=\"listClass()\">\r\n @for (step of viewSteps(); track step.index) {\r\n @let active = isStepActive(step);\r\n @let locked = isStepLocked(step);\r\n @let focused = step.index === highlightedStep();\r\n @let options = step.options;\r\n @let index = step.index;\r\n @let currentIndex = activeStep()?.index ?? -1;\r\n @let disabled = !!options.disabled;\r\n <li\r\n [class]=\"listItemClass()\"\r\n [class.cursor-pointer]=\"!locked\"\r\n [class.cursor-not-allowed]=\"locked\"\r\n [style]=\"trackItemStyles()\"\r\n role=\"presentation\"\r\n (click)=\"onStepClick(step)\">\r\n @if (stepTemplate()) {\r\n <span\r\n role=\"button\"\r\n [attr.aria-current]=\"step.index === activeStep()?.index ? 'step' : undefined\"\r\n [attr.aria-disabled]=\"locked ? true : undefined\"\r\n [attr.aria-label]=\"options.label\"\r\n [attr.tabindex]=\"focused ? 0 : -1\"\r\n (focus)=\"onIndicatorFocus(step)\">\r\n <ng-container\r\n [ngTemplateOutlet]=\"stepTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n </span>\r\n } @else {\r\n <span\r\n monaStepperIndicator\r\n [rounded]=\"rounded()\"\r\n [active]=\"active\"\r\n [focused]=\"focused\"\r\n role=\"button\"\r\n [attr.aria-current]=\"step.index === activeStep()?.index ? 'step' : undefined\"\r\n [attr.aria-disabled]=\"locked ? true : undefined\"\r\n [attr.aria-label]=\"options.label\"\r\n [attr.tabindex]=\"focused ? 0 : -1\"\r\n (focus)=\"onIndicatorFocus(step)\">\r\n @if (indicatorTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"indicatorTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n } @else {\r\n {{ step.index + 1 }}\r\n }\r\n </span>\r\n }\r\n @if (labelTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"labelTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: options,\r\n index,\r\n active,\r\n currentIndex,\r\n disabled\r\n }\"></ng-container>\r\n } @else {\r\n <span aria-hidden=\"true\">{{ options.label }}</span>\r\n }\r\n </li>\r\n }\r\n</ol>\r\n<div\r\n [class]=\"trackClass()\"\r\n [style]=\"trackStyles()\"\r\n role=\"progressbar\"\r\n [attr.aria-valuenow]=\"step()\"\r\n [attr.aria-valuemin]=\"0\"\r\n [attr.aria-valuemax]=\"progressMax()\"\r\n [attr.aria-label]=\"progressAriaLabel()\">\r\n <div [class]=\"trackLineClass()\" [style]=\"trackInnerStyles()\"></div>\r\n</div>\r\n" }]
522
+ }], ctorParameters: () => [], propDecorators: { indicatorTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => StepperIndicatorTemplateDirective), { ...{
523
+ read: TemplateRef
524
+ }, isSignal: true }] }], labelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => StepperLabelTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], stepTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => StepperStepTemplateDirective), { ...{
525
+ read: TemplateRef
526
+ }, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], linear: [{ type: i0.Input, args: [{ isSignal: true, alias: "linear", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], progressAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "progressAriaLabel", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }, { type: i0.Output, args: ["stepChange"] }], steps: [{ type: i0.Input, args: [{ isSignal: true, alias: "steps", required: false }] }] } });
527
+
528
+ /*
529
+ * Public API Surface of @nanahoshi/mona-ui/stepper
530
+ */
531
+
532
+ /**
533
+ * Generated bundle index. Do not edit.
534
+ */
535
+
536
+ export { StepperComponent, StepperIndicatorTemplateDirective, StepperLabelTemplateDirective, StepperStepTemplateDirective };
537
+ //# sourceMappingURL=nanahoshi-mona-ui-stepper.mjs.map