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

hmpo-date-controller

v1.0.0

Published

A controller for the hmpo-form-wizard that provides out-of-the-box support for hmpo-template-mixins' 'input-date' mixin.

Downloads

2

Readme

hmpo-date-controller

npm version Build Status

A controller for the hmpo-form-wizard that provides out-of-the-box support for hmpo-template-mixins' 'input-date' mixin. It is a drop-in replacement for the standard controller and, if need be, can be inherited from in your custom controllers.

The functionality in this module could, at some point, be merged into hmpo-form-controller as that already has knowledge of the date component fields provided by input-date.

Main Benefits

  • No more silly custom controllers just so that date fields can be handled.
  • The date validators from hmpo-form-controller can finally be leaveraged, giving us easy validation on date fields. (e.g. Date must not be in the future, person must be over 18 etc.)
  • No more date components in the steps definition. (Surely a source of confusion for new developers?)
  • The date components are also validated individually allowing a missing month, let's say, to be highlighted directly. The validators are automatically applied and come from hmpo-form-controller. i.e. 'date-year', 'date-month' and 'date-day'. This gives the developer a lot of date validation for free helping to avoid bugs in their forms.

Quality Assurance

The controller's functionality is fully documented in the unit test.

Whilst this is the first version of this module the code coverage is 100% as measured by [Istanbul]. This is tested for in CI to ensure new changes do not introduce untested code.

Linting is also checked in CI using the .eslintrc from hmpo-form-controller.

Migrating from HOF's date-controller

If you were using HOF's date-controller then you would have had a custom controller which declared a single field as being the only date field. You will also have added the date components to your steps definition. None of this is required in hmpo-date-controller so your migration is more about deleting this redundant code.

e.g. Consider the following steps definition:

[...]
'/step-one': {
  controller: require('dob-controller'),
  fields: [
    'fullname',
    'date-of-birth',
    'date-of-birth-day',
    'date-of-birth-month',
    'date-of-birth-year',
    'nationality'
  ],
  next:
  '/step-two'
},
[...]

This can now become simply:

[...]
'/step-one': {
  fields: [
    'fullname',
    'date-of-birth',
    'nationality'
  ],
  next:
  '/step-two'
},
[...]

This of course means that you are now free to have more than one date field per step.

If you were doing any validation on the date you might need to add it to the definition for the field.

The only thing left to do is to ensure the default controller is, or inherits from, hmpo-date-controller.