Skip to content

feat: add NeDatePicker and NeDateRangeFilter - #229

Open
andre8244 wants to merge 5 commits into
mainfrom
feat/date-picker
Open

andre8244 wants to merge 5 commits into
mainfrom
feat/date-picker

Conversation

@andre8244

Copy link
Copy Markdown
Collaborator

Add a date and time picker, to replace @vuepic/vue-datepicker in My Nethesis and NethSecurity, and the native date and time inputs of ns8-visitors.

  • NeDatePicker: a form field to choose a day ('yyyy-MM-dd'), a date and time (Date) or a time ('HH:mm'), with min/max, disabled days, timeZone, minuteStep, seconds, hourCycle, typed values, Cancel/Select buttons, ranges of days and presets. The trigger and popup-header slots allow a custom button.
  • NeDateRangeFilter: a filter button for a range of days, next to NeDropdownFilterV2, with presets and a link to clear the selection.

No new dependencies: built on date-fns and @date-fns/tz. Texts, month and day names, formats, the first day of the week and the 12 or 24-hour clock follow locale. The popup works inside NeSideDrawer and NeModal, with the keyboard support of the WAI-ARIA date picker dialog and spin button patterns.

Tested in the playground: keyboard and focus, typed values, min/max, time zones, presets, ranges, forms, drawer and modal, light and dark theme, English and Italian, desktop and phone width.

Add a field to choose a day, a date and time, or a time of day, to
replace @vuepic/vue-datepicker in My Nethesis and NethSecurity and the
native date and time inputs of ns8-visitors.

The value is a 'yyyy-MM-dd' string for 'date', a Date for 'datetime'
and a 'HH:mm' string for 'time'. It supports min, max and disabled
days, a time zone for 'datetime', a minute step, seconds, the 12 or
24-hour clock, typed values in the format of the locale, and Cancel
and Select buttons. The calendar opens in a popup that works inside
NeSideDrawer and NeModal, with the keyboard support of the WAI-ARIA
date picker dialog and spin button patterns.

Assisted-by: Claude Code:claude-opus-5-5
Add the range prop, to choose a range of days as [first, last] with
two clicks, typed or from the calendar, as the date range filters of
My Nethesis and ns8-visitors need.

Add presets, values chosen with a click next to the calendar, such as
"Last 7 days" or "Tomorrow at 09:00". Each product passes its own,
with translated labels: the library has none.

Add the hourCycle prop, to use the 12 or 24-hour clock regardless of
the locale.

Assisted-by: Claude Code:claude-opus-5-5
Add a filter button that opens a calendar to choose a range of days,
for the toolbars above tables and lists, next to NeDropdownFilterV2:
the date range filters of My Nethesis and ns8-visitors. Its badge shows
the range, or the label of the preset that matches it, and the popup
has a link to clear the selection.

To build it, NeDatePicker gets the trigger slot, to open the calendar
from a custom button, and the popup-header slot, to add content above
the calendar.

Assisted-by: Claude Code:claude-opus-5-5
Fix the bugs found by the reviews of NeDatePicker, NeDateRangeFilter
and their internal components:

- typed dates and times: time zone names of summer and winter, AM and
  PM before the time, the time before the date, the Arabic comma, and
  the Gregorian calendar with Latin digits in every locale
- min and max: the default time, presets outside the limits, rounding
  to the minute step in the time zone, and the message for a time
  outside the limits
- daylight saving time: skipped and repeated times in the spinner
- invalid time zones fall back to the browser time zone
- focus: the popup keeps the focus after a click on an empty area or a
  disabled button, and gives it back to the element that opened it
- accessibility: labelled step buttons and AM/PM spin button, months
  and years as grids, alerts for typed errors, the end of a range
  announced, the field name without a label
- the popup scrolls on small screens; the field padding follows the
  icons

Rename openCalendarLabel to chooseDateLabel and add the labels of the
spinner, chooseEndDateLabel, and the id of NeDateRangeFilter.

Assisted-by: Claude Code:claude-sonnet-5-5
The descriptions of NeDatePicker and NeDateRangeFilter were much
longer than those of the other components. They now say what each
component is for and what to use instead, as CONTRIBUTING.md asks.

The details move to JSDoc comments on the props, and to the slots
declared with defineSlots, so that the Docs page shows them. Remove
the WithValue, Placeholder and Optional stories of NeDatePicker.

Assisted-by: Claude Code:claude-sonnet-5-5
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.

1 participant