feat : sélecteur d'année dans le calendrier (3ᵉ niveau) (#83)
## Sélecteur d'année dans le calendrier (3ᵉ niveau de navigation) Ajoute un 3ᵉ niveau de navigation à la famille de composants date, et corrige le bornage min/max du sélecteur de mois. ### Comportement - Clic sur le champ → calendrier (vue **jours**) - Clic sur l'en-tête → **sélecteur de mois** - **Re-clic sur l'en-tête → sélecteur d'année** (grille de 12 ans, chevrons paginant par pas de 12 ans, fenêtre centrée sur l'année courante − 5) - Clic sur une année → retour au sélecteur de mois ; clic sur un mois → retour à la grille de jours - Les props `min`/`max` **grisent les mois ET les années** hors plage (corrige l'asymétrie : le `MonthPicker` affichait jusqu'ici tous les mois) En-tête contextuel : « Mai 2026 » (jours) / « 2026 » (mois) / « 2020 – 2031 » (années). ### Périmètre - Shell partagé `internal/CalendarField.vue` → bénéficie aux 4 composants publics `Date`, `DateRange`, `DateTime`, `DateWeek` - **Aucune API publique modifiée** - Nouveau composant `internal/YearPicker.vue` (calqué sur `MonthPicker`) - Helpers purs `isMonthInRange` / `isYearInRange` (comparaison par préfixe ISO, bornes inclusives) - State machine `viewMode` à 3 niveaux (`useCalendarPopover` / `useCalendarView`) ### Tests - Suite date **246/246 verte**, ESLint propre - Unitaires : helpers, `YearPicker`, `MonthPicker` (grisage), composables (pagination ±12, recentrage, `selectYear`) - e2e `Date.test.ts` : flux complet jours→mois→années→mois→jours + grisage min/max ### Process Développé en brainstorming → spec → plan → exécution TDD (un commit par étape). Spec et plan inclus sous `docs/superpowers/`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #83 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #83.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {describe, expect, it} from 'vitest'
|
||||
import {formatIsoToDisplay, isDateInRange, isValidIso, parseDisplayToIso} from './dateFormat'
|
||||
import {formatIsoToDisplay, isDateInRange, isMonthInRange, isValidIso, isYearInRange, parseDisplayToIso} from './dateFormat'
|
||||
|
||||
describe('dateFormat', () => {
|
||||
describe('isValidIso', () => {
|
||||
@@ -59,4 +59,36 @@ describe('dateFormat', () => {
|
||||
expect(isDateInRange('2026-05-25', '2026-05-10', '2026-05-20')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('isMonthInRange', () => {
|
||||
it('returns true when no bounds are given', () => {
|
||||
expect(isMonthInRange(2026, 4)).toBe(true)
|
||||
})
|
||||
it('respects the min bound by month (inclusive)', () => {
|
||||
expect(isMonthInRange(2026, 4, '2026-05-10')).toBe(true) // mai chevauche
|
||||
expect(isMonthInRange(2026, 3, '2026-05-10')).toBe(false) // avril < mai
|
||||
})
|
||||
it('respects the max bound by month (inclusive)', () => {
|
||||
expect(isMonthInRange(2026, 4, undefined, '2026-05-31')).toBe(true)
|
||||
expect(isMonthInRange(2026, 5, undefined, '2026-05-31')).toBe(false) // juin > mai
|
||||
})
|
||||
it('disables months in years outside the range', () => {
|
||||
expect(isMonthInRange(2025, 11, '2026-05-10')).toBe(false)
|
||||
expect(isMonthInRange(2027, 0, undefined, '2026-05-31')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('isYearInRange', () => {
|
||||
it('returns true when no bounds are given', () => {
|
||||
expect(isYearInRange(2026)).toBe(true)
|
||||
})
|
||||
it('respects the min bound by year (inclusive)', () => {
|
||||
expect(isYearInRange(2026, '2026-05-10')).toBe(true)
|
||||
expect(isYearInRange(2025, '2026-05-10')).toBe(false)
|
||||
})
|
||||
it('respects the max bound by year (inclusive)', () => {
|
||||
expect(isYearInRange(2026, undefined, '2026-05-31')).toBe(true)
|
||||
expect(isYearInRange(2027, undefined, '2026-05-31')).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user