Precision setting#6
Merged
Merged
Conversation
There was a problem hiding this comment.
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) | ||
| }) |
|
|
||
| ### 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. |
|
|
||
| ### 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). |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.