Skip to content

Precision setting#6

Merged
afonic merged 5 commits into
mainfrom
feature/precision-month
May 30, 2026
Merged

Precision setting#6
afonic merged 5 commits into
mainfrom
feature/precision-month

Conversation

@afonic
Copy link
Copy Markdown
Contributor

@afonic afonic commented May 30, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new precision configuration option to support a month-level picker mode intended for “departure month”-style selections, along with documentation, demo updates, and a dedicated unit test suite.

Changes:

  • Added precision?: 'day' | 'month' config with month-picker behavior (months grid only, commits first-of-month, month-specific defaults/clamping).
  • Added comprehensive Vitest coverage for month precision behavior.
  • Documented and demoed the month picker; adjusted ESLint rules for test ergonomics.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/plugin/calendar-component.ts Implements precision: 'month' behavior (view initialization, clamped opening view, month commit flow, read-only input handling, reopen behavior).
tests/unit/precision-month.test.ts Adds unit tests covering initial positioning, month commits, restoring from value, clamping, read-only input, and config warnings.
README.md Documents precision: 'month' usage and behavior and adds it to the options table.
demo/index.html Adds a “Month Picker” section demonstrating the new precision mode.
eslint.config.js Disables no-non-null-assertion for test files.
CHANGELOG.md Adds an Unreleased entry describing the new month-precision feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2476 to +2480
} else if (precision === 'month') {
// Always reopen on the months grid, repositioned onto the committed selection.
this.view = 'months'
const sel = this._selection.toArray()[0] as CalendarDate | undefined
if (sel) {
Comment on lines +1575 to +1579
// Month-precision pickers are selection-only: a 'MMMM YYYY' value can't be
// re-parsed from typed text, so make the input read-only (click to open).
if (precision === 'month') {
el.readOnly = true
}
Comment on lines +2476 to +2480
} else if (precision === 'month') {
// Always reopen on the months grid, repositioned onto the committed selection.
this.view = 'months'
const sel = this._selection.toArray()[0] as CalendarDate | undefined
if (sel) {
Comment on lines +1575 to +1579
// Month-precision pickers are selection-only: a 'MMMM YYYY' value can't be
// re-parsed from typed text, so make the input read-only (click to open).
if (precision === 'month') {
el.readOnly = true
}
Comment on lines +62 to +71
it('clamps the opening view UP to minDate when today precedes it', () => {
// today (real run date) is well before 2030, so the clamp must engage.
const { c } = createComponent({
precision: 'month',
minDate: '2030-06-01',
maxDate: '2031-12-31',
})
expect(c.year).toBe(2030)
expect(c.month).toBe(6)
})
Comment on lines +73 to +81
it('clamps the opening view DOWN to maxDate when today is after it', () => {
const { c } = createComponent({
precision: 'month',
minDate: '2019-01-01',
maxDate: '2020-12-31',
})
expect(c.year).toBe(2020)
expect(c.month).toBe(12)
})
Comment thread README.md

### Month Picker (departure-month)

Set `precision: 'month'` to turn the calendar into a forward-looking **month picker**. It opens directly on the months grid (with the year prev/next arrows), and clicking a month commits the **first day of that month** as the selection — there is no day grid and no separate year step.
Comment thread CHANGELOG.md

### Added

- **`precision: 'month'` — a forward-looking month picker.** Opens directly on the months grid (with the year prev/next arrows), positioned by the usual `value` > `initialMonth` > today precedence and clamped into `[minDate, maxDate]`. Clicking a month commits the first day of that month as the single selection, emits `calendar:change` (`detail.dates[0]` = first-of-month), formats the input via `format` (e.g. `'MMMM YYYY'` → `"August 2026"`), and closes the popup — no day grid, no year step. The bound input becomes read-only (selection-only), `format` defaults to `'MM/YYYY'`, and a stored first-of-month `value` restores both the displayed string and the highlighted month. Designed to compose with `mode: 'single'`; combining with `range`/`multiple` or `wizard` warns (precision takes precedence over the wizard).
afonic added 4 commits May 30, 2026 21:09
The precision-month picker, wizard precedence, and month keyboard
navigation grew every bundle a few KB, pushing them past the existing
raw-byte budgets (ESM 135.7KB > 130KB, CDN 61.7KB > 60KB, UMD 65.2KB >
65KB) and failing CI. Raise the budgets with ~5-7% headroom; the 75KB
"not bloated with Alpine" ceiling stays as the real regression alarm.
@afonic afonic merged commit 703dae4 into main May 30, 2026
2 checks passed
@afonic afonic deleted the feature/precision-month branch May 30, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants