41010060ff
## 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>
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import MonthPicker from './MonthPicker.vue'
|
|
|
|
const mountPicker = (props: { currentYear: number, selectedMonth?: number, min?: string, max?: string }) =>
|
|
mount(MonthPicker, { props })
|
|
|
|
describe('MalioDateMonthPicker', () => {
|
|
it('renders 12 months', () => {
|
|
const wrapper = mountPicker({ currentYear: 2026 })
|
|
expect(wrapper.findAll('[data-test="month"]')).toHaveLength(12)
|
|
})
|
|
|
|
it('emits select with the clicked month index', async () => {
|
|
const wrapper = mountPicker({ currentYear: 2026 })
|
|
await wrapper.get('[data-test="month"][data-month="0"]').trigger('click')
|
|
expect(wrapper.emitted('select')?.[0]).toEqual([0])
|
|
})
|
|
|
|
it('disables months before min in the current year and does not emit', async () => {
|
|
const wrapper = mountPicker({ currentYear: 2026, min: '2026-05-01' })
|
|
const april = wrapper.get('[data-test="month"][data-month="3"]')
|
|
expect(april.attributes('disabled')).toBeDefined()
|
|
await april.trigger('click')
|
|
expect(wrapper.emitted('select')).toBeUndefined()
|
|
})
|
|
|
|
it('disables months after max in the current year', () => {
|
|
const wrapper = mountPicker({ currentYear: 2026, max: '2026-05-31' })
|
|
expect(wrapper.get('[data-test="month"][data-month="5"]').attributes('disabled')).toBeDefined()
|
|
expect(wrapper.get('[data-test="month"][data-month="4"]').attributes('disabled')).toBeUndefined()
|
|
})
|
|
})
|