npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-govuk-datepicker

v1.0.12

Published

A React GOV.UK date picker for government platforms and services.

Downloads

80

Readme

GOV.UK React Date Picker User Guide

The GOV.UK Design System is an official design framework produced by the UK Government and defines best practices and rules that must be followed to ensure that your code base is GDS Compliant.

You can find the guide at the GOV.UK Design System website.

Overview

The standard implementation for the GDS Date input uses three separate controls for day, month and year. User feedback indicated that this control did not support fast data entry due to the tabbing required between the components.

Standard HTML5 date inputs provided fast data entry on desktop but the locale of the control is determined by the browser and additionally the control renders differently across different browsers, on mobile devices. Android and IOS now display calendars on a control touch, which did not allow easy entry of historic dates, which was often required by users.

The remit was to develop a react based date picker that would enable keyboard data entry similar to how the HTML5 control works on desktop, for both desktop and mobile, and also include an accessible calendar component that could be activated by the user.

The calendar part of this control has been implemented from the Scottish Government Date Picker, converting the original Javascript to React. The resulting component is shown below:

Date Picker!

A working (Demo) can be found under the dates menu option, highlighting the differences between standard HTML5 date controls and the date picker implementation.

Configuration

The below shows one of our example implementations of the date picker integrated with React Hook Form:

<Controller
  control={control}
  name="datePicker"
  render={({ field: { value, onBlur, onChange }, fieldState: { error } }) => (
    <DatePicker
      identifier="datePicker"
      label="When was your passport issued?"
      hint="For example, 27/03/2007"
      width={InputWidth.Char10}
      multiQuestion={true}
      value={value}
      error={error?.message}
      onChange={x => onChange(x)}
      onBlur={onBlur}
    />
  )}
/>

Installation

The package can be installed via npm:

npm install react-govuk-datepicker --save

Or via yarn:

yarn add react-govuk-datepicker

The date picker uses GDS styles which can be installed via the govuk-frontend package:

npm install govuk-frontend --save
yarn add govuk-frontend

Accessibility

Keyboard support for Input

  • Left: Move to the previous date part section e.g.: move from month to day.
  • Right: Move to the next date part section e.g.: move from day to month.
  • Up: Increment the currently selected date part section.
  • Down: Decrement the currently selected date part section.

Keyboard support for Calendar

  • Left: Move to the previous day.
  • Right: Move to the next day.
  • Up: Move to the previous week.
  • Down: Move to the next week.
  • PgUp: Move to the previous month.
  • Shift+PgUp: Move to the same day and month of the previous year
  • PgDn: Move to the next month.
  • Shift+PgDn: Move to the same day and month of the next year
  • Home: Move to the first day of the current week.
  • End: Move to the last day of the current week.

License

Copyright (c) 2024 Barry Jacobs and individual contributors. Licensed under MIT license, see LICENSE for the full license.