1.1.4 • Published 4 years ago

@bitbite/datepicker-plus v1.1.4

Weekly downloads
32
License
MIT
Repository
-
Last release
4 years ago

Datepicker Plus

select date range

Datepicker Plus is an input control to select dates. It's a web component built with StencilJS. Datepicker Plus can be used directly in a web page or you can integrate the Datepicker with other frameworks, like angular, react or Vue. check stenciljs framework integration for more info.

Features

  • supports single, multiple and range select mode
  • flexible view range
  • dynamic date attributes
  • fully customizable
  • supports select constraints
  • i18n support
  • ability to integrate with other frameworks

Documentation


Installation

npm i @bitbite/datepicker-plus --save

Integration


Configuration

  • Datepicker Plus takes a single config. Object as a prop. check below:
/**
 * datepicker web component configuration
 *
 * The standard date format for datepicker config.
 * is the DateString. DateString is a formatted string
 * that can be converted to a Javascript Date Object.
 * 
 * example dateString:
 * 2019-10-19 (YYYY-MM-dd)
 */
export interface IPlusConfig {
    /**
     * Optionally set select mode to one of the available
     * select modes listed below:
     * 
     * 'single'   - select a single date 
     * 'multiple' - select multiple distinct dates
     * 'range'    - select a range between two dates (default)
     */
    selectMode?: SelectMode
    
    /**
     * Optionally set the view range given the pair
     * (start date string, end date string).
     * 
     * if not provided, the current month will be
     * the default view range.
     */
    viewRange ?: [DateString, DateString]
  
    /**
     * Optionally provide one 'dateString', date attribute
     * or more to be selected on init.
     */
    selected  ?: DateString[]
  
    /**
     * Optionally provide one 'dateString', date attribute
     * to be disabled on init.
     */
    disabled  ?: DateString[]
  
    /**
     * Optionally select week header mode.
     * 
     * there are two modes available:
     * 'single'     - a single header for all months
     * 'per-month'  - each month has his own header (default)
     */
    weekHeader?: WeekHeader
  
    /**
     * Optionally set a scope size. if present
     * a scope size larger than 0. on date select
     * the user will be limited to choose from within
     * the scope.
     * 
     * for example, give the configuration below.
     * { selectScopeSize: 7 }
     * 
     * The user can select up to 7 dates
     * [-6][-5][-4][-3][-2][-1][ <-*-> ][1][2][3][4][5][6]
     */
    selectScopeSize?: number
  
    /**
     * Optionally provide a custom style sheet url to be
     * loaded and injected inside the datepicker component.
     */
    stylesheetUrl ?: string
  
    /**
     * optionally provide a localized content
     * for datepicker.
     */
    i18n?: {
      /**
       * (default)
       *  1 Sunday     (Sun)
       *  2 Monday     (Mon)
       *  3 Tuesday    (Tue)
       *  4 Wednesday  (Wed)
       *  5 Thursday   (Thu)
       *  6 Friday     (Fri)
       *  7 Saturday   (Sat)
       */
      weekDays?: IWeekDay[]
      /**
       * (default)
       *  01 January        (Jan)
       *  02 February       (Feb)
       *  03 March          (Mar)
       *  04 April          (Apr)
       *  05 May            (May)
       *  06 June           (Jun)
       *  07 July           (Jul)
       *  08 August         (Aug)
       *  09 September      (Sep)
       *  10 October        (Oct)
       *  11 November       (Nov)
       *  12 December       (Dec)
       */
      months?: IMonth[]
    }
    
    /**
     * Optionally select datepicker layout
     * 'vertical' (default)
     */
    layout?: 'vertical' | 'horizontal'
  }

Events

onDateSelect

  • emits when a date is selected. use it to react to a date selected.

  • emitted CustomEvent<string[]>


onDeselect

  • emits when a date is deselected use it to react to date deselected

  • emitted CustomEvent<string[]>


onHighlight

  • emits when a date or more is highlighted as potential select candidate

  • emitted CustomEvent<string[]>


onHighlight

  • emits when a date or more is highlighted as potential select candidate

  • emitted CustomEvent<string[]>


onHighlightClear

  • emits when date highlight is cleared after dates deselect

  • emitted CustomEvent<void>


onRangeSelect

  • emits when a complete date range is selected use it to react to a complete date range selected

  • emitted CustomEvent<string[]>


Custom Styling

Applying custom styles to Datepicker plus is as easy as passing a stylesheet url as a prop. to the config. Object. You can as well use web component stylable parts to style the datepicker.

{
   stylesheetUrl ?: string // stylesheet url
}
selectordescription
.dpp-customtargets datepicker plus container
.daytargets every datepicker day control
.yeartargets date controls in a year
.disabledtargets disabled date controls
.checkedtargets selected date controls
.monthtargets month container
.month-nametargets month name
.month-headertargets month header
.month-contenttargets month controls container
.weektargets week container
.emptytargets empty slots
.week-headertargets week header
.week-header > abbrtargets week header abbreviation
.week-contenttargets week controls container
.weekendtargets weekend header
.checkboxtargets hidden checkbox controls
.single-headerif header mode is single you can override this class
.highlighttargets highlighted controls
.connectortargets selected date controls between two selected dates
.rangeStarttargets selected range start date controls
.rangeEndtargets selected range end date controls

Dynamic attributes will reflect it's class to every control that has an attribute enabled. This attributes can be styled as well. ( .today - .tomorrow - .yesterday - .past - .future )

Web Component parts styling is also available:

datepicker-plus::part(dpp-container) { ... }
datepicker-plus::part(month-header) { ... }
datepicker-plus::part(month) { ... }
datepicker-plus::part(week-header) { ... }
datepicker-plus::part(week) { ... }
datepicker-plus::part(day) { ... }

Development

Built With Stencil


Getting Started

  • install dependencies
npm install
  • start development server
npm start

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test

Need help? Check out stencilJS docs here.

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago