Giter Site home page Giter Site logo

vaadin / vaadin-date-picker Goto Github PK

View Code? Open in Web Editor NEW
166.0 22.0 78.0 7.65 MB

The Web Component providing a date selection field with scrollable month calendar. Part of the Vaadin components.

Home Page: https://vaadin.com/components

License: Apache License 2.0

JavaScript 2.64% HTML 97.36%
vaadin vaadin-date-picker polymer date-picker webcomponents polymer-element polymer2 web-component

vaadin-date-picker's Introduction

<vaadin-date-picker>

⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the vaadin/web-components monorepository. This repository contains the source code and releases of <vaadin-date-picker> for the Vaadin versions 10 to 19.

<vaadin-date-picker> is a Web Component providing a date selection field which includes a scrollable month calendar view, part of the Vaadin components.

Live Demo ↗ | API documentation ↗

npm version [Published on webcomponents.org](https://www.webcomponents.org/element/vaadin/va Published on Vaadin Directory Discord

<vaadin-date-picker label="Label" placeholder="Placeholder">
</vaadin-date-picker>

Screenshot of vaadin-date-picker

Installation

The Vaadin components are distributed as Bower and npm packages. Please note that the version range is the same, as the API has not changed. You should not mix Bower and npm versions in the same application, though.

Unlike the official Polymer Elements, the converted Polymer 3 compatible Vaadin components are only published on npm, not pushed to GitHub repositories.

Polymer 2 and HTML Imports Compatible Version

Install vaadin-date-picker:

bower i vaadin/vaadin-date-picker --save

Once installed, import it in your application:

<link rel="import" href="bower_components/vaadin-date-picker/vaadin-date-picker.html">

Polymer 3 and ES Modules Compatible Version

Install vaadin-date-picker:

npm i @vaadin/vaadin-date-picker --save

Once installed, import it in your application:

import '@vaadin/vaadin-date-picker/vaadin-date-picker.js';

Getting started

Vaadin components use the Lumo theme by default.

To use the Material theme, import the correspondent file from the theme/material folder.

Entry points

  • The components with the Lumo theme:

    theme/lumo/vaadin-date-picker.html theme/lumo/vaadin-date-picker-light.html

  • The components with the Material theme:

    theme/material/vaadin-date-picker.html theme/material/vaadin-date-picker-light.html

  • Alias for theme/lumo/vaadin-date-picker.html theme/lumo/vaadin-date-picker-light.html:

    vaadin-date-picker.html vaadin-date-picker-light.html

Running demos and tests in a browser

  1. Fork the vaadin-date-picker repository and clone it locally.

  2. Make sure you have npm and Bower and Polymer installed.

  3. When in the vaadin-date-picker directory, run npm install and then bower install to install dependencies.

  4. Run npm start, browser will automatically open the component API documentation.

  5. You can also open demo or in-browser tests by adding demo or test to the URL, for example:

Running tests from the command line

  1. When in the vaadin-date-picker directory, run npm test (this will execute:"test": "wct") (tests will be fetched from the test/basics.html file)

Following the coding style

We are using ESLint for linting JavaScript code. You can check if your code is following our standards by running npm run lint, which will automatically lint all .js files as well as JavaScript snippets inside .html files.

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs.

Contributing

To contribute to the component, please read the guideline first.

License

Apache License 2.0

Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.

vaadin-date-picker's People

Contributors

alvarezguille avatar artur- avatar cwdoh avatar czp13 avatar danners avatar dependabot[bot] avatar diegocardoso avatar jouni avatar legioth avatar limonte avatar magi42 avatar manolo avatar marcushellberg avatar mukherjeesudebi avatar patgmiller avatar pekam avatar phan-thanhdat avatar platosha avatar samiheikki avatar saulis avatar shadikhani avatar sissbruecker avatar sohrabtaee avatar tehapo avatar tomivirkki avatar upstairlounge avatar vicsstar avatar vursen avatar web-padawan avatar yuriy-fix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vaadin-date-picker's Issues

Footer and (fullscreen) header

Footer with a "cancel" button and a fullscreen header with value label and a clear button. Today button is a separate task.

Integration with `iron-form`

iron-form support initial plan:

  • Add Polymer.IronFormElementBehavior and Polymer.IronValidatableBehavior
  • Separate properties for selectedDate (Date object, default null) and value (formatted String, empty by default)
    • both writeable, updating each other if needed
    • value might also support Date assignment
  • valueFormat property. Use input field format when empty.
  • Date formatting depends on locale. Update value on locale change.

Fix the ghost click issue

Making a selection will produce a "ghost click" that might focus an underlying input component after the overlay gets closed.

Add initial styling

We'll use fixed colors for now. Using CSS variables seems to have some issues with current implementation on all other browsers than Chrome. Trying to reduce those issues into a simple test case for Polymer.

Screenreader support

A visually impaired user should be able to select a specific date with the help of a screenreader, using the keyboard.

After #196, the user should still be able to navigate the calendar list and to choose a specific date using that instead of just typing in a valid date in the input field.

Should be validated at least on Windows and macOS.

Phase 1 DoD

  • The team should be able to select a specific date with the help of a screenreader, using the keyboard, with the following:
    • macOS VoiceOver on Chrome, Firefox and Safari
    • JAWS (free trial) and NVDA on Windows
    • iOS VoiceOver
    • Android Talkback

Phase 2 DoD

  • A visually impaired outside user should be able to select a specific date (perhaps ask on the previously mentioned Reddit thread for help)
    • We assume this is just a validation for the work, and doesn’t require much extra work from us

declarative locale not working

<vaadin-date-picker locale='fi'> does not show finish, but document.querySelector('vaadin-date-picker').locale = 'fi' ` works

Binding value to a YYYY-MM-DD value fails

Setting a YYYY-MM-DD value manually works, but if using Polymer data binding or programmatically setting the same string value, it does not get converted to a Date which causes and exception in date comparison (_dateEquals in vaadin-month-calendar.html)

Add localization support

Localization (autodetection, 1st day of week, months, weekdays, date format, ...).

Nice idea would be to have each locale as a pluggable package. This would enable easy contributions to the component by providing new locales.

Themability

The component should use colors from the paper-styles.

A couple of notices also related to the calendar and clear icons.

  • Anton: Currently the target size are 24px × 24px. Material design guideline suggest at least 48px × 48px. But that would feel too big to align with an input field.
  • Anton: Would be nice to have a ripple effect for icons.

Use media queries to make the component responsive

Currently the vaadin-date-picker does work in _updateAlignmentAndPosition function to determine whether to open in "full screen mode" or not.

In addition the vaadin-date-picker-overlay has a _desktopMode property to determine if the year scroller should be always visible.

We should look into having nice media queries that also make the component responsive in regards to changes in the device orientation and browser viewport size changes.

Make sure page-up/down doesn't skip a month

If January 31th has the keyboard focus and you hit page-down to hop to february, it should focus 28th (or whatever happens to be the last date). Currently it hops over to march so it's a bug.

According to WAI-ARIA spec:
Page Up - Moves to the same date in the previous month.
Page Down - Moves to the same date in the next month.

DX user testing findings

  • Document "value-changed" as an event in the API documentation
  • Document valid date formats (both in API docs and in asciidoc) #51
  • Clarify in the documentation that value is not dependent on locale (relates to previous point)
  • Document supported locales (what moment.js provides), both in API docs and in asciidoc

Add year navigation

Let’s start by drawing mockups of the few new options that we’ve discussed (in addition to the previous separate year list view):

  • Year scroller next to the month scroller, always visible if there is enough horizontal screen space
    • Ensure proper touch targets for the year numbers (users can tap in between years as well to jump to "june/july" immediately)
  • When not enough horizontal space:
    • Have the year scroller become visible on top of the month scroller. Once scrolling stops, hide it after a short delay
    • Have an explicit toggling for the year scroller (the year number in the header)
      • The year scroller overlaps the month scroller
      • The year scroller pushes the month scroller sideways

Create MVP

MVP Features

  • Month calendar view.
  • Allow navigation between months.
  • Allow picking a date from the month calendar (mouse/touch).
  • Allow clearing of the selected value.
  • Scroll to the selected date in month view when opening (current day by default).
  • Allow two-way Polymer data-binding (value-changed event).
  • Locale for the MVP is fixed to en-us.
  • Asciidoc documentation

Feature backlog

1.0

  • Replace iron-list with vaadin-scroller #33
  • Refactor dropdown alignment/position, with a responsive breakpoint #34
    • Validate our layout design with mobile devices
  • Year navigation #35
  • Localization #36

  • Today shortcut #40
  • Setting the initial position of month view (without setting the value) #46
  • Integration with iron-form #51
  • Themability #55
  • Keyboard navigation #76

Future

  • Min/max date #197
  • Keyboard input and related input validation #196 #238
  • Week numbers
  • Accessibility, screenreader support (ARIA) #70
  • Disabled dates #646
  • Range selection #2
  • Selecting multiple dates
  • Selecting repeating dates (weekly/monthly/yearly)
  • Allow customizing the date cells
  • Inline date picker
  • Adding custom content to the dropdown (custom footer, etc)

Feature backlog

A component for selecting a date or multiple dates/a range of dates.

Features

1.0

  • Select a single date
  • Date input by pointer and/or keyboard
    • Calendar picker, with quick access to all months and years
      • Optional week numbers
      • Start week from Sunday or Monday
  • Accessibility
    • Keyboard focus and navigation handling
    • WAI-ARIA role attributes
  • Localization (a way to replace all texts in the picker UI)
    • Provide one language (English) by default
  • Customizable theme (cross-scope styling support)
Related tasks

Future

  • Custom locale which automatically sets the UI texts and date formatting
  • Custom date formatting
  • Textual input
    • Input validation
  • Disabled/disallowed dates
    • A range (from–to is disabled)
    • Until a certain date (e.g. only allow future dates)
    • Starting from a certain date (e.g. only allow past dates)
  • Select multiple dates or date ranges
    • Select a full week (or any predefined range/set)
  • Customizable styling for days/months/years

Modal paper-dialog cuts of date picker

vaadin-date-picker gets cut off by modal paper-dialog. Needs overflow: visible; on the paper-dialog to work properly. Workaround should be documented unless we can think of a good solution.

screen shot 2016-02-24 at 3 14 03 pm

Usability improvements prototyping

Prototype and ask user feedback (lightweight UX testing) would the following changes improve the date picker usability:

  • tweak mouse scroll speed to less sensitive (issue origin) (#102)
  • replace year scroll dots with month names (issue origin) (#138)
    • At the same time, consider adding another breakpoint above 375px and increase the width and font-size of the year scroller
  • stack year numbers stacked more closely vertically (issue origin) (#138)
  • ARIA spec regarding year browse with keyboard shortcut (prototype if needed, issue origin) (Shift+Page Up/Down already work)
  • replace month grid with e.g. big year number overlay while scrolling (scrolling speed distracting eyesight, issue origin)

Add calendar icon

Add calendar icon to the input field as a visual indicator of the possibility to open the calendar view.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.