Date and date-range pickers for Formwright, powered by
ember-power-calendar 2 and ember-basic-dropdown. Dates are
handled with the browser's Date and Intl: no moment or luxon needed.
npm install @ember-formwright/ember @ember-formwright/power-calendar ember-power-calendar ember-basic-dropdown ember-concurrency
// app/app.ts
import { registerPowerCalendarControls } from '@ember-formwright/power-calendar'
import 'ember-basic-dropdown/styles'
import '@ember-formwright/power-calendar/theme.css' // optional; after the Formwright theme
registerPowerCalendarControls() // @control="date-picker" and @control="date-range"
The package types these names for Glint: which paths each fits, and which args it takes. If you register under other names, declare them.
Render <BasicDropdownWormhole /> (from ember-basic-dropdown/components/basic-dropdown-wormhole)
once in your application template; calendars open into it. In tests, add
<div id="ember-basic-dropdown-wormhole"></div> next to #ember-testing in tests/index.html.
<f.Field @for="checkIn" @control="date-picker" @label="Check-in" @min={{this.today}} />
{{! stores { start, end } once both ends are chosen }}
<f.Field @for="stay" @control="date-range" @label="Stay" />
{{! a Date, for @attr('date'); weekends off }}
<f.Field @for="shipsOn" @control="date-picker" @label="Ships on" @format={{formatDate}} as |field|>
<field.Control @storeDate={{true}} @disabledDates={{array "Sat" "Sun"}} />
</f.Field>
A date-picker stores an ISO YYYY-MM-DD string, a date-range { start, end } of them; with
@storeDate, Dates at local midnight. Both read either. The field's @min, @max and
@locale apply. field.Control also takes @dateFormat (Intl.DateTimeFormat options for
the trigger), @disabledDates, @startOfWeek, @renderInPlace, and for a range @minRange
and @maxRange (in days).
formatDate(value, { locale, format }) and formatDateRange(value, { locale, format }) turn a
stored value into text, for a field's @format in inline mode.
import { DatePickerHarness } from '@ember-formwright/power-calendar/test-support'
class BookingForm extends FormHarness {
@field(DatePickerHarness) declare checkIn: DatePickerHarness
@field(DatePickerHarness) declare stay: DatePickerHarness
}
await booking.checkIn.select('2026-03-04') // opens, pages to March 2026, clicks the 4th
await booking.stay.selectRange('2026-03-04', '2026-03-09')
assert.strictEqual(booking.checkIn.text, 'Mar 4, 2026')
It also has open(), close(), isOpen, month, nextMonth(), previousMonth(),
day(isoDate), isDayDisabled(isoDate) and trigger.
registerPowerCalendarControls() registers one built on Date and Intl
(nativeDateLibrary), unless the app registered its own (moment, luxon) first.<button>, so <label for> points at it and clicking the label
focuses it. Its aria-label is the field's label followed by what it shows
("Check-in: Mar 4, 2026").@inline @callout forms the calendar renders in place, inside the popover,
so a click on a day doesn't close the callout.@requireConfirm or @inline, Enter on a day doesn't commit, and the first
Escape closes the calendar instead of cancelling the edit.2026-03-04T10:00Z) is read by its date part.select, readonly disables the trigger.data-fw-name
with the field's path.