@nanahoshi/mona-ui 0.25.1 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/chart/README.md +2 -2
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart-bar.md +714 -0
- package/docs/chart-financial.md +567 -0
- package/docs/chart-funnel.md +546 -0
- package/docs/chart-heatmap.md +535 -0
- package/docs/chart-line-area.md +462 -0
- package/docs/chart-pie.md +645 -0
- package/docs/chart-radar.md +518 -0
- package/docs/chart-radial.md +658 -0
- package/docs/chart-scatter.md +479 -0
- package/docs/chart-treemap.md +651 -0
- package/docs/chart.md +2465 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +212 -66
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +133 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +250 -20
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
package/docs/calendar.md
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# Calendar
|
|
2
|
+
|
|
3
|
+
> Date selection in single, multiple and range modes across month, year and decade views.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/calendar`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-calendar`
|
|
8
|
+
|
|
9
|
+
`CalendarComponent` is a standalone date selection control supporting single, multiple, and range modes across interactive month, year, and decade views.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`CalendarComponent` renders a full calendar widget for selecting one date (`selection="single"`), a set of individual dates (`selection="multiple"`), or a date range (`selection="range"`). Navigation across months, years, and decades is available by pointer and keyboard.
|
|
14
|
+
|
|
15
|
+
Use the calendar as a standalone date selection control when a popup picker is not needed. For a compact text-input-based picker that embeds the calendar in a dropdown, use `DatePickerComponent` or `DateTimePickerComponent`.
|
|
16
|
+
|
|
17
|
+
## Import & Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { CalendarComponent } from "@nanahoshi/mona-ui/calendar";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add `CalendarComponent` to your standalone component's `imports` array.
|
|
24
|
+
|
|
25
|
+
**Single-date binding:**
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<mona-calendar [(value)]="selectedDate"></mona-calendar>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
protected readonly selectedDate = signal<Date | null>(null);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Anatomy
|
|
36
|
+
|
|
37
|
+
Three template directives customize the rendered cell content in each calendar view.
|
|
38
|
+
|
|
39
|
+
### Month cell — `monaCalendarMonthCellTemplate`
|
|
40
|
+
|
|
41
|
+
Replaces the default day number in the month view:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<mona-calendar [(value)]="date">
|
|
45
|
+
<ng-template monaCalendarMonthCellTemplate let-day let-date="date">
|
|
46
|
+
<span [class.font-bold]="isHoliday(date)">{{ day }}</span>
|
|
47
|
+
</ng-template>
|
|
48
|
+
</mona-calendar>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Template context:**
|
|
52
|
+
|
|
53
|
+
| Variable | Type | Description |
|
|
54
|
+
|----------------------------|----------|-----------------------------------|
|
|
55
|
+
| `$implicit` (as `let-day`) | `number` | Day of the month (1–31). |
|
|
56
|
+
| `date` | `Date` | Full `Date` object for this cell. |
|
|
57
|
+
|
|
58
|
+
### Year cell — `monaCalendarYearCellTemplate`
|
|
59
|
+
|
|
60
|
+
Replaces the default month label in the year (month-selection) view:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<mona-calendar [(value)]="date">
|
|
64
|
+
<ng-template monaCalendarYearCellTemplate let-month let-text="text">
|
|
65
|
+
<span class="italic">{{ text }}</span>
|
|
66
|
+
</ng-template>
|
|
67
|
+
</mona-calendar>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Template context:**
|
|
71
|
+
|
|
72
|
+
| Variable | Type | Description |
|
|
73
|
+
|------------------------------|----------|--------------------------------------------------|
|
|
74
|
+
| `$implicit` (as `let-month`) | `number` | Month number (1–12). |
|
|
75
|
+
| `text` | `string` | Abbreviated month name (e.g., `"Jan"`, `"Feb"`). |
|
|
76
|
+
|
|
77
|
+
### Decade cell — `monaCalendarDecadeCellTemplate`
|
|
78
|
+
|
|
79
|
+
Replaces the default year label in the decade view:
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<mona-calendar [(value)]="date">
|
|
83
|
+
<ng-template monaCalendarDecadeCellTemplate let-year>
|
|
84
|
+
<em>{{ year }}</em>
|
|
85
|
+
</ng-template>
|
|
86
|
+
</mona-calendar>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Template context:**
|
|
90
|
+
|
|
91
|
+
| Variable | Type | Description |
|
|
92
|
+
|-----------------------------|----------|------------------------------------|
|
|
93
|
+
| `$implicit` (as `let-year`) | `number` | The year represented by this cell. |
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
### Multiple date selection
|
|
98
|
+
|
|
99
|
+
`multiple-example.component.ts`
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { DatePipe } from "@angular/common";
|
|
103
|
+
import { Component, computed, signal } from "@angular/core";
|
|
104
|
+
import { CalendarComponent } from "@nanahoshi/mona-ui/calendar";
|
|
105
|
+
|
|
106
|
+
@Component({
|
|
107
|
+
selector: "app-calendar-multiple-example",
|
|
108
|
+
imports: [CalendarComponent, DatePipe],
|
|
109
|
+
templateUrl: "./multiple-example.component.html"
|
|
110
|
+
})
|
|
111
|
+
export class CalendarMultipleExampleComponent {
|
|
112
|
+
protected readonly dates = computed(() => {
|
|
113
|
+
const value = this.value();
|
|
114
|
+
return Array.isArray(value) ? value : [];
|
|
115
|
+
});
|
|
116
|
+
protected readonly value = signal<Date | Date[] | null>([]);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`multiple-example.component.html`
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<div class="flex flex-wrap items-start gap-6">
|
|
124
|
+
<mona-calendar selection="multiple" [(value)]="value" />
|
|
125
|
+
<div aria-live="polite" class="text-sm">
|
|
126
|
+
<p>{{ dates().length }} days off</p>
|
|
127
|
+
<ul>
|
|
128
|
+
@for (date of dates(); track date.getTime()) {
|
|
129
|
+
<li>{{ date | date: "EEE, MMM d" }}</li>
|
|
130
|
+
}
|
|
131
|
+
</ul>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Click to select the first date. Then:
|
|
137
|
+
|
|
138
|
+
- **Ctrl+click** (or **Cmd+click**) toggles an individual date in or out of the selection.
|
|
139
|
+
- **Shift+click** selects a contiguous block from the last selected date to the clicked date.
|
|
140
|
+
|
|
141
|
+
All selected dates are emitted as a flat `Date[]`.
|
|
142
|
+
|
|
143
|
+
### Range selection
|
|
144
|
+
|
|
145
|
+
Click the start date, then click the end date. The emitted `value` is always `[startDate, endDate]` — a `Date[]` with exactly two elements. Clicking a new date while a range is pending resets the selection.
|
|
146
|
+
|
|
147
|
+
`range-example.component.ts`
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { DatePipe } from "@angular/common";
|
|
151
|
+
import { Component, computed, signal } from "@angular/core";
|
|
152
|
+
import { CalendarComponent } from "@nanahoshi/mona-ui/calendar";
|
|
153
|
+
|
|
154
|
+
@Component({
|
|
155
|
+
selector: "app-calendar-range-example",
|
|
156
|
+
imports: [CalendarComponent, DatePipe],
|
|
157
|
+
templateUrl: "./range-example.component.html"
|
|
158
|
+
})
|
|
159
|
+
export class CalendarRangeExampleComponent {
|
|
160
|
+
protected readonly ends = computed(() => {
|
|
161
|
+
const range = this.range();
|
|
162
|
+
return Array.isArray(range) && range.length === 2 ? range : null;
|
|
163
|
+
});
|
|
164
|
+
protected readonly range = signal<Date | Date[] | null>(null);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`range-example.component.html`
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<div class="flex flex-col items-start gap-2">
|
|
172
|
+
<mona-calendar selection="range" [(value)]="range" />
|
|
173
|
+
<span aria-live="polite" class="text-sm">
|
|
174
|
+
@if (ends(); as ends) {
|
|
175
|
+
Stay: {{ ends[0] | date }} to {{ ends[1] | date }}
|
|
176
|
+
} @else {
|
|
177
|
+
Choose the first night, then the last.
|
|
178
|
+
}
|
|
179
|
+
</span>
|
|
180
|
+
</div>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Date constraints
|
|
184
|
+
|
|
185
|
+
`minDate` and `maxDate` bound the dates that can be chosen. `disabledDates` takes a predicate, as here to skip weekends, or an array of specific dates.
|
|
186
|
+
|
|
187
|
+
`constraints-example.component.ts`
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { Component, signal } from "@angular/core";
|
|
191
|
+
import { CalendarComponent } from "@nanahoshi/mona-ui/calendar";
|
|
192
|
+
|
|
193
|
+
/** Midnight, a number of days from today. */
|
|
194
|
+
const daysFromToday = (days: number): Date => {
|
|
195
|
+
const date = new Date();
|
|
196
|
+
date.setHours(0, 0, 0, 0);
|
|
197
|
+
date.setDate(date.getDate() + days);
|
|
198
|
+
return date;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
@Component({
|
|
202
|
+
selector: "app-calendar-constraints-example",
|
|
203
|
+
imports: [CalendarComponent],
|
|
204
|
+
templateUrl: "./constraints-example.component.html"
|
|
205
|
+
})
|
|
206
|
+
export class CalendarConstraintsExampleComponent {
|
|
207
|
+
protected readonly date = signal<Date | Date[] | null>(null);
|
|
208
|
+
protected readonly maxDate = daysFromToday(30);
|
|
209
|
+
protected readonly minDate = daysFromToday(1);
|
|
210
|
+
protected readonly isWeekend = (date: Date): boolean => date.getDay() === 0 || date.getDay() === 6;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`constraints-example.component.html`
|
|
215
|
+
|
|
216
|
+
```html
|
|
217
|
+
<mona-calendar [disabledDates]="isWeekend" [maxDate]="maxDate" [minDate]="minDate" [(value)]="date" />
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Week numbers
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<mona-calendar [(value)]="date" [weekNumber]="true"></mona-calendar>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Displays ISO week numbers in a left column of the month grid.
|
|
227
|
+
|
|
228
|
+
### Week starting day
|
|
229
|
+
|
|
230
|
+
```html
|
|
231
|
+
<mona-calendar [(value)]="date" firstDay="sunday"></mona-calendar>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Without `firstDay`, the week starts on the day the active locale uses, such as Sunday for `en-US` and Monday for `de-DE`. Set it to override the locale.
|
|
235
|
+
|
|
236
|
+
### Signal forms integration
|
|
237
|
+
|
|
238
|
+
`CalendarComponent` implements `FormValueControl<Date | Date[] | null>` from `@angular/forms/signals`. Use the `[formField]` binding:
|
|
239
|
+
|
|
240
|
+
`forms-example.component.ts`
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { Component, signal } from "@angular/core";
|
|
244
|
+
import { form, FormField, required } from "@angular/forms/signals";
|
|
245
|
+
import { CalendarComponent } from "@nanahoshi/mona-ui/calendar";
|
|
246
|
+
|
|
247
|
+
interface DeliveryModel {
|
|
248
|
+
date: Date | Date[] | null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Component({
|
|
252
|
+
selector: "app-calendar-forms-example",
|
|
253
|
+
imports: [CalendarComponent, FormField],
|
|
254
|
+
templateUrl: "./forms-example.component.html"
|
|
255
|
+
})
|
|
256
|
+
export class CalendarFormsExampleComponent {
|
|
257
|
+
readonly #model = signal<DeliveryModel>({ date: null });
|
|
258
|
+
protected readonly delivery = form(this.#model, path => {
|
|
259
|
+
required(path.date);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
`forms-example.component.html`
|
|
265
|
+
|
|
266
|
+
```html
|
|
267
|
+
<div class="flex flex-col items-start gap-2">
|
|
268
|
+
<p id="delivery-date-hint" class="text-sm">Choose a delivery date.</p>
|
|
269
|
+
<mona-calendar aria-describedby="delivery-date-hint" [formField]="delivery.date" />
|
|
270
|
+
@if (delivery.date().touched() && delivery.date().invalid()) {
|
|
271
|
+
<p class="text-error text-sm" role="alert">A delivery date is required.</p>
|
|
272
|
+
}
|
|
273
|
+
</div>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
It has no `ControlValueAccessor`, but `[(ngModel)]`, `[formControl]` and `formControlName` work too, because Angular binds a control's `value` and `touch` directly when it has no accessor.
|
|
277
|
+
|
|
278
|
+
## Behavior
|
|
279
|
+
|
|
280
|
+
**View navigation:** The calendar starts in the month view. Clicking the month/year header button cycles upward: month → year → decade. Clicking a cell in the year or decade view drills down.
|
|
281
|
+
|
|
282
|
+
**Range selection pending state:** After the first click in `selection="range"` mode, the calendar previews that date as the start. The range is committed only after the second click.
|
|
283
|
+
|
|
284
|
+
**Disabled dates and navigation:** When `minDate` or `maxDate` changes so that the currently focused date falls outside the allowed range, the calendar automatically moves focus to the nearest bound.
|
|
285
|
+
|
|
286
|
+
**Readonly state:** Navigation and view switching remain active while `readonly` is `true`. Date selection is prevented.
|
|
287
|
+
|
|
288
|
+
## Forms Integration
|
|
289
|
+
|
|
290
|
+
`CalendarComponent` implements `FormValueControl<Date | Date[] | null>` from `@angular/forms/signals`.
|
|
291
|
+
|
|
292
|
+
The `FormField` directive writes the following inputs automatically when a `[formField]` binding is active:
|
|
293
|
+
|
|
294
|
+
| Input | Written by `FormField` |
|
|
295
|
+
|------------|------------------------|
|
|
296
|
+
| `disabled` | ✓ |
|
|
297
|
+
| `invalid` | ✓ |
|
|
298
|
+
| `readonly` | ✓ |
|
|
299
|
+
| `required` | ✓ |
|
|
300
|
+
| `touched` | ✓ |
|
|
301
|
+
|
|
302
|
+
The `touch` output fires each time the user completes a date selection. `FormField` listens to this output to mark the field as touched.
|
|
303
|
+
|
|
304
|
+
> For selection modes other than `"single"`, declare the form model field with the matching type (`Date[] | null`).
|
|
305
|
+
|
|
306
|
+
## Accessibility
|
|
307
|
+
|
|
308
|
+
Each view renders a `role="grid"` with rows of `role="gridcell"` cells, labelled by the heading above it. Day cells are named by their full date, and the month grid's column headers carry the full weekday name for screen readers. A polite live region announces the current view and position when it changes, such as "Calendar, June 2025" or "Year view, 2025".
|
|
309
|
+
|
|
310
|
+
| Attribute | Where | Value |
|
|
311
|
+
|-----------------|------------------------------------------------|------------------------------------------|
|
|
312
|
+
| `role` | Each view's container | `"grid"` |
|
|
313
|
+
| `role` | Each day, month, and year cell | `"gridcell"` |
|
|
314
|
+
| `role` | Each weekday header (month view) | `"columnheader"` |
|
|
315
|
+
| `aria-label` | Each cell, and the navigation buttons | Descriptive text |
|
|
316
|
+
| `aria-selected` | A selected cell | `"true"` |
|
|
317
|
+
| `aria-current` | Today, or the current month or year | `"date"` |
|
|
318
|
+
| `aria-disabled` | A disabled day, or the grid when disabled | `"true"` |
|
|
319
|
+
| `aria-invalid` | The month grid, when invalid | `"true"` |
|
|
320
|
+
| `aria-readonly` | The month grid, when `readonly` | `"true"` |
|
|
321
|
+
| `tabindex` | Each cell | `0` on the focused cell, `-1` on the rest |
|
|
322
|
+
|
|
323
|
+
A grid may not carry `aria-required`, so `required` shows only as `data-required` on the host and through the invalid state.
|
|
324
|
+
|
|
325
|
+
**Consumer responsibilities:** None. The grids are named by the calendar's own heading.
|
|
326
|
+
|
|
327
|
+
### Keyboard Interaction
|
|
328
|
+
|
|
329
|
+
All keyboard actions apply to the focused cell of the grid. The grid is one Tab stop, and arrow keys move focus between its cells.
|
|
330
|
+
|
|
331
|
+
#### Month view
|
|
332
|
+
|
|
333
|
+
| Key | Action |
|
|
334
|
+
|-------------------------|--------------------------------------|
|
|
335
|
+
| `ArrowLeft` | Move focus one day back |
|
|
336
|
+
| `ArrowRight` | Move focus one day forward |
|
|
337
|
+
| `ArrowUp` | Move focus one week back |
|
|
338
|
+
| `ArrowDown` | Move focus one week forward |
|
|
339
|
+
| `Ctrl/Cmd + ArrowLeft` | Navigate to previous month |
|
|
340
|
+
| `Ctrl/Cmd + ArrowRight` | Navigate to next month |
|
|
341
|
+
| `Ctrl/Cmd + ArrowUp` | Switch to year view |
|
|
342
|
+
| `Home` | Move focus to first day of the month |
|
|
343
|
+
| `End` | Move focus to last day of the month |
|
|
344
|
+
| `PageUp` | Navigate to previous month |
|
|
345
|
+
| `PageDown` | Navigate to next month |
|
|
346
|
+
| `Enter` / `Space` | Select focused date |
|
|
347
|
+
| `T` | Navigate to today |
|
|
348
|
+
|
|
349
|
+
#### Multiple selection additions (month view only)
|
|
350
|
+
|
|
351
|
+
| Key | Action |
|
|
352
|
+
|---------------------------|-------------------------------------------------------------|
|
|
353
|
+
| `Shift + ArrowLeft/Right` | Extend selection by one day |
|
|
354
|
+
| `Shift + ArrowUp/Down` | Extend selection by one week |
|
|
355
|
+
| `Ctrl/Cmd + Enter` | Toggle focused date in the selection |
|
|
356
|
+
| `Shift + Enter` | Select all dates from the last selected to the focused date |
|
|
357
|
+
|
|
358
|
+
#### Year view (month selection)
|
|
359
|
+
|
|
360
|
+
| Key | Action |
|
|
361
|
+
|----------------------------|---------------------------------------|
|
|
362
|
+
| `ArrowLeft` / `ArrowRight` | Move focus one month |
|
|
363
|
+
| `ArrowUp` / `ArrowDown` | Move focus three months (one row) |
|
|
364
|
+
| `Ctrl/Cmd + ArrowLeft` | Navigate to previous year |
|
|
365
|
+
| `Ctrl/Cmd + ArrowRight` | Navigate to next year |
|
|
366
|
+
| `Ctrl/Cmd + ArrowDown` | Switch to month view |
|
|
367
|
+
| `Home` | Move focus to January |
|
|
368
|
+
| `End` | Move focus to December |
|
|
369
|
+
| `PageUp` | Navigate to previous year |
|
|
370
|
+
| `PageDown` | Navigate to next year |
|
|
371
|
+
| `Enter` / `Space` | Select month and switch to month view |
|
|
372
|
+
|
|
373
|
+
#### Decade view (year selection)
|
|
374
|
+
|
|
375
|
+
| Key | Action |
|
|
376
|
+
|----------------------------|-------------------------------------|
|
|
377
|
+
| `ArrowLeft` / `ArrowRight` | Move focus one year |
|
|
378
|
+
| `ArrowUp` / `ArrowDown` | Move focus four years (one row) |
|
|
379
|
+
| `Ctrl/Cmd + ArrowLeft` | Navigate to previous decade |
|
|
380
|
+
| `Ctrl/Cmd + ArrowRight` | Navigate to next decade |
|
|
381
|
+
| `Ctrl/Cmd + ArrowDown` | Switch to year view |
|
|
382
|
+
| `Home` | Move focus to first year of decade |
|
|
383
|
+
| `End` | Move focus to last year of decade |
|
|
384
|
+
| `PageUp` | Navigate to previous decade |
|
|
385
|
+
| `PageDown` | Navigate to next decade |
|
|
386
|
+
| `Enter` / `Space` | Select year and switch to year view |
|
|
387
|
+
|
|
388
|
+
## API
|
|
389
|
+
|
|
390
|
+
Everything below is imported from `@nanahoshi/mona-ui/calendar`.
|
|
391
|
+
|
|
392
|
+
### `CalendarComponent`
|
|
393
|
+
|
|
394
|
+
**Selector:** `mona-calendar`
|
|
395
|
+
**Implements:** `FormValueControl<Date \| Date[] \| null>`
|
|
396
|
+
|
|
397
|
+
#### Inputs
|
|
398
|
+
|
|
399
|
+
| Name | Type | Default | Description |
|
|
400
|
+
| --- | --- | --- | --- |
|
|
401
|
+
| `class` | `string` | `""` | Adds custom CSS classes to the calendar host element. |
|
|
402
|
+
| `disabled` | `boolean` | `false` | Sets the disabled state of the calendar. |
|
|
403
|
+
| `disabledDates` | `DateDisabledType` | — | Sets the disabled dates of the calendar. Accepts either an iterable of Date objects or a predicate function. |
|
|
404
|
+
| `firstDay` | `FirstDayOfWeek \| null` | `null` | Sets the first day of the week. If not specified, derives from the active locale. |
|
|
405
|
+
| `focusOnMount` | `boolean` | `false` | Moves focus to the active day when the calendar first renders. An inline calendar on a page should leave focus where it is; a calendar that opens in a popup sets this so focus moves into it. |
|
|
406
|
+
| `invalid` | `boolean` | `false` | Marks the calendar as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
407
|
+
| `maxDate` | `Date \| null` | — | Sets the maximum date that can be selected. |
|
|
408
|
+
| `minDate` | `Date \| null` | — | Sets the minimum date that can be selected. |
|
|
409
|
+
| `readonly` | `boolean` | `false` | Sets the readonly state of the calendar. |
|
|
410
|
+
| `required` | `boolean` | `false` | Sets whether the calendar is required. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
411
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Sets the border radius of the calendar. |
|
|
412
|
+
| `selection` | `CalendarSelection` | `"single"` | Sets the selection mode of the calendar. |
|
|
413
|
+
| `touched` | `boolean` | `false` | Sets the touched state of the calendar. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
414
|
+
| `value` (two-way) | `Date \| Date[] \| null` | `null` | The current value of the calendar: a `Date` in single selection, the selected dates in multiple selection, and `[start, end]` in range selection. A range is written once both ends are picked. |
|
|
415
|
+
| `weekNumber` | `boolean` | `false` | Enables the display of week numbers in the calendar. |
|
|
416
|
+
|
|
417
|
+
#### Outputs
|
|
418
|
+
|
|
419
|
+
| Name | Type | Description |
|
|
420
|
+
| --- | --- | --- |
|
|
421
|
+
| `touch` | `void` | Emitted when focus leaves the calendar, as a native input is touched on blur. Moving between its buttons and days doesn't count. The `FormField` directive listens to this to mark the field as touched. |
|
|
422
|
+
| `valueChange` | `Date \| Date[] \| null` | Emitted when `value` changes. |
|
|
423
|
+
|
|
424
|
+
### `CalendarDecadeCellTemplateDirective`
|
|
425
|
+
|
|
426
|
+
Provides a custom template for each year cell in the decade view.
|
|
427
|
+
|
|
428
|
+
**Selector:** `ng-template[monaCalendarDecadeCellTemplate]`
|
|
429
|
+
|
|
430
|
+
### `CalendarMonthCellTemplateDirective`
|
|
431
|
+
|
|
432
|
+
Provides a custom template for each day cell in the month view.
|
|
433
|
+
|
|
434
|
+
**Selector:** `ng-template[monaCalendarMonthCellTemplate]`
|
|
435
|
+
|
|
436
|
+
### `CalendarYearCellTemplateDirective`
|
|
437
|
+
|
|
438
|
+
Provides a custom template for each month cell in the year (month-selection) view.
|
|
439
|
+
|
|
440
|
+
**Selector:** `ng-template[monaCalendarYearCellTemplate]`
|
|
441
|
+
|
|
442
|
+
### Types
|
|
443
|
+
|
|
444
|
+
#### `CALENDAR_DEFAULT_MESSAGES`
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
const CALENDAR_DEFAULT_MESSAGES: MonaCalendarMessages;
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### `DecadeCellTemplateContext`
|
|
451
|
+
|
|
452
|
+
| Name | Type | Description |
|
|
453
|
+
| --- | --- | --- |
|
|
454
|
+
| `$implicit` | `number` | The year interval of per decade. |
|
|
455
|
+
|
|
456
|
+
#### `MonthCellTemplateContext`
|
|
457
|
+
|
|
458
|
+
| Name | Type | Description |
|
|
459
|
+
| --- | --- | --- |
|
|
460
|
+
| `$implicit` | `number` | The day of the month. |
|
|
461
|
+
| `date` | `Date` | The date object representing the day. |
|
|
462
|
+
|
|
463
|
+
#### `YearCellTemplateContext`
|
|
464
|
+
|
|
465
|
+
| Name | Type | Description |
|
|
466
|
+
| --- | --- | --- |
|
|
467
|
+
| `$implicit` | `number` | The month number (1–12) represented by this cell. |
|
|
468
|
+
| `text` | `string` | The text representation of the month. |
|
|
469
|
+
|
|
470
|
+
#### `CalendarSelection`
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
type CalendarSelection = "multiple" | "range" | "single";
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
#### `FirstDayOfWeek`
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
type FirstDayOfWeek = | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### `DateDisabledType`
|
|
483
|
+
|
|
484
|
+
From `@nanahoshi/mona-ui/date-input`.
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
type DateDisabledType = Iterable<Date> | Predicate<Date> | null | undefined;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
#### `MonaCalendarMessages`
|
|
491
|
+
|
|
492
|
+
From `@nanahoshi/mona-ui/i18n`.
|
|
493
|
+
|
|
494
|
+
| Name | Type |
|
|
495
|
+
| --- | --- |
|
|
496
|
+
| `nextDecade` (read-only) | `string` |
|
|
497
|
+
| `nextMonth` (read-only) | `string` |
|
|
498
|
+
| `nextYear` (read-only) | `string` |
|
|
499
|
+
| `previousDecade` (read-only) | `string` |
|
|
500
|
+
| `previousMonth` (read-only) | `string` |
|
|
501
|
+
| `previousYear` (read-only) | `string` |
|
|
502
|
+
| `today` (read-only) | `string` |
|
|
503
|
+
|
|
504
|
+
**Methods**
|
|
505
|
+
|
|
506
|
+
| Signature |
|
|
507
|
+
| --- |
|
|
508
|
+
| `calendarLabel(formattedMonthAndYear: string): string` |
|
|
509
|
+
| `decadeRange(start: number, end: number): string` |
|
|
510
|
+
| `decadeViewLabel(start: number, end: number): string` |
|
|
511
|
+
| `goToToday(formattedDate: string): string` |
|
|
512
|
+
| `switchToDecadeView(currentYear: string): string` |
|
|
513
|
+
| `switchToYearView(currentMonthAndYear: string): string` |
|
|
514
|
+
| `yearCellLabel(year: number): string` |
|
|
515
|
+
| `yearViewLabel(year: string): string` |
|