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

@_lucky/app-datepicker

v6.0.0-rc.32

Published

Google Material Design based date picker built with lit

Downloads

2

Readme

buymeacoffee tippin.me Follow me Join Discord

Version lit MIT License

Downloads Total downloads Packagephobia Bundlephobia

ci ci-helpers codecov

Code of Conduct

Table of contents

Miracle happens when marrying Material Design with date pickers on the web.

💯 Also, featured in awesome-lit-html.

This marks another completion of an important milestone of app-datepicker with all the love from the Web Components community in making this element great and wonderful. As Web Components getting more and more traction and better at providing a web standard way of creating shareable components, it plays an important role in the JavaScript community as many developers depend on a plethora of development tools written in JavaScript for the web to create a better developer experience when developing a library, a component, or even a large scalable application.

date-pickers-in-different-themes

Today, app-datepicker has been completely rewritten to adapt to the best of both worlds by leveraging the modern technologies the community most familiar with since year 2018.

The following are the list of tools used that makes it shine:

  1. TypeScript
  2. lit

Table of contents

Pre-requisite

  • ES2019 (The element is compiled with features targeting ES2019, so it might not work properly without transpilation on older browsers.)
  • lit >= 2.2.0
  • [OPTIONAL] TypeScript >= 4.5.5 (TypeScript users only)

Installation

  • NPM

    $ npm i app-datepicker@next
  • Alternatively, it can be downloaded from any of the following awesome CDNs:

    1. esm.run/ jsdelivr
    2. esm.sh

How to use

Polyfills

Please make sure you have all these features available on the browsers you are supporting. If no, please consider polyfill-ing in order to run the datepicker element.

The following snippet shows a simple script used in the demo to load polyfills via feature detection on different browsers:

<script>
  if (null == Array.prototype.find) {
    Object.defineProperty(Array.prototype, 'find', {
      value: function arrayFind(cb) {
        var filtered = this.filter(cb);
        return !filtered.length ? void 0 : filtered[0];
      },
    });
  }

  if (!window.Intl) {
    var wa = document.createElement('script');
    /** NOTE: Pin package version due to https://github.com/andyearnshaw/Intl.js/issues/256 */
    wa.src = 'https://esm.run/[email protected]/dist/Intl.complete.js';
    wa.onload = function onLoad() { console.info('🌐 Intl polyfill loaded'); };
    wa.onerror = console.error;
    document.head.appendChild(wa);
  }
</script>

ES Modules

my-app.js

/**
 * Say you've already installed the element via NPM, simply import the package to your application.
 * Here I'm using `lit` for developing my application.
 */
import { css, html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import 'app-datepicker';

const localName = 'my-app';

@customElement(localName)
export class MyApp extends LitElement {
  static styles = [
    css`
    :host {
      display: block;
    }

    * {
      box-sizing: border-box;
    }
    `
  ];

  render() {
    return html`<app-date-picker></app-date-picker>`;
  }
}

index.html

<!doctype html>
<html>
  <!-- Using ES modules to load the app -->
  <script type="module" src="/my-app.js"></script>
  ...
  <body>
    <my-app>
      <!-- <AppDatepicker> will be rendered when <MyApp> loads. -->
    </my-app>
  </body>
  ...
</html>

Browser compatibility

All the elements work in last 2 versions of all evergreen browsers (Chrome/ Edge, Firefox, and Safari). Internet Explorer 11 is no longer supported in favor of the new Microsoft Edge.

Tested on the following browsers:

  1. Chrome/ Edge 100
  2. Firefox 96
  3. Safari 15.4

Not tested on the following browsers but it should work with all the polyfills needed:

  1. Edge 18 and below
  2. Safari 13.1 and below

Q&A

  1. Does it work well with material-components-web-components?

    For material-components-web-components users, you can create your own custom date picker element by wrapping app-date-picker inside mwc-dialog.

    // Simplified code snippet
    
    class MWCDatePicker extends LitElement {
      render() {
        return html`
        <mwc-dialog>
          <app-date-picker></app-date-picker>
    
          <mwc-button slot="secondaryAction" dialogAction="cancel">cancel</mwc-button>
          <mwc-button slot="primaryAction" dialogAction="set">set</mwc-button>
        </mwc-dialog>
        `;
      }
    }

API references

Demo

Older versions

License

MIT License © Rong Sen Ng